push_helper.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2016/11/15
  6. * Time: 下午12:26
  7. */
  8. require_once (BASE_ROOT_PATH . '/helper/sms_helper.php');
  9. require_once (BASE_ROOT_PATH . '/helper/bonus_helper.php');
  10. require_once (BASE_ROOT_PATH . '/helper/room_helper.php');
  11. require_once (BASE_ROOT_PATH . '/helper/push_sender.php');
  12. class push_helper
  13. {
  14. static $admin_info = null;
  15. private static function admin_alias() {
  16. return bonus\parameters::admin_member_id;
  17. }
  18. private static function admin_avatar()
  19. {
  20. if(self::$admin_info == null) {
  21. self::$admin_info = new member_info(self::admin_alias());
  22. }
  23. return self::$admin_info->avatar();
  24. }
  25. public static function stolen_bonus(member_info $from_info,member_info $to_info,$amount)
  26. {
  27. $thief = $to_info->nickname();
  28. $text = "{$thief}偷走了您{$amount}元的红包.";
  29. $push_param['alias'] = $from_info->member_id();
  30. $push_param['title'] = "摇红包";
  31. $push_param['text'] = $text;
  32. $push_param['extra']['go_type'] = 'bonus';
  33. $push_param['extra']['title'] = "红包被偷";
  34. $push_param['extra']['text'] = $text;
  35. $push_param['extra']['show_type'] = 'pop';
  36. $push_param['extra']['url'] = 'xmmz://p.lrlz.com/main/index?index=2';
  37. $push_param['extra']['image'] = $to_info->avatar();
  38. QueueClient::push('upushSendMsg',$push_param);
  39. $from = ['nickname' => $to_info->nickname(),'avatar' => $to_info->avatar(),'userid' => $to_info->member_id()];
  40. $content = ['type' => 'stolen_bonus','from' => $from,'amount' => $amount,'note' => "{偷走了您{$amount}元的红包}"];
  41. room\factory_client::instance()->notice_users([$from_info->member_id()],room\proto_type::push_notify,$content,$text);
  42. }
  43. public static function fly_bonus(member_info $from_info,member_info $to_info,$amount,$type_sn)
  44. {
  45. $name = $from_info->nickname();
  46. $text = "{$name}的{$amount}元的红包,在向您飞来~.";
  47. $push_param['alias'] = $to_info->member_id();
  48. $push_param['title'] = "摇红包";
  49. $push_param['text'] = $text;
  50. $push_param['extra']['go_type'] = 'bonus';
  51. $push_param['extra']['title'] = "摇红包";
  52. $push_param['extra']['text'] = $text;
  53. $push_param['extra']['show_type'] = 'pop';
  54. $push_param['extra']['url'] = 'xmmz://p.lrlz.com/main/index?index=2';
  55. $push_param['extra']['image'] = $from_info->avatar();
  56. QueueClient::push('upushSendMsg',$push_param);
  57. $from = ['nickname' => $from_info->nickname(),'avatar' => $from_info->avatar(),'userid' => $from_info->member_id()];
  58. $shema = schema_helper::bonus_detail($type_sn);
  59. $content = ['type' => 'fly_bonus','from' => $from,'amount' => $amount,'schema' => $shema,'note' => "{$name}摇飞了{$amount}元红包,到你账户."];
  60. room\factory_client::instance()->notice_users([$to_info->member_id()],room\proto_type::push_notify,$content,$text);
  61. }
  62. public static function order_refund_bonus($member_id,$amount)
  63. {
  64. $minfo = new member_info($member_id);
  65. $text = "退款通知:金额{$amount}元红包已退还到您的账户.";
  66. $push_param['alias'] = $member_id;
  67. $push_param['title'] = "退款";
  68. $push_param['text'] = $text;
  69. $push_param['extra']['go_type'] = 'bonus';
  70. $push_param['extra']['title'] = "退款";
  71. $push_param['extra']['text'] = $text;
  72. $push_param['extra']['show_type'] = 'pop';
  73. $push_param['extra']['url'] = 'xmmz://p.lrlz.com/main/index?index=2';
  74. $push_param['extra']['image'] = $minfo->avatar();
  75. QueueClient::push('upushSendMsg',$push_param);
  76. }
  77. public static function send_bonus($member_id,$to_ids,$type_sn)
  78. {
  79. $sender = new member_info($member_id);
  80. $name = $sender->nickname();
  81. $text = "新的红包:您的好友{$name}给您发了一个红包,请查收.";
  82. foreach ($to_ids as $member_id)
  83. {
  84. $push_param = [];
  85. $push_param['alias'] = $member_id;
  86. $push_param['title'] = "新到红包";
  87. $push_param['text'] = $text;
  88. $push_param['extra']['go_type'] = 'bonus';
  89. $push_param['extra']['title'] = "新到红包";
  90. $push_param['extra']['text'] = $text;
  91. $push_param['extra']['show_type'] = 'pop';
  92. $push_param['extra']['url'] = 'xmmz://p.lrlz.com/main/index?index=2';
  93. $push_param['extra']['image'] = $sender->avatar();
  94. QueueClient::push('upushSendMsg',$push_param);
  95. }
  96. $from = ['nickname' => $sender->nickname(),'avatar' => $sender->avatar(),'userid' => $sender->member_id()];
  97. $shema = schema_helper::bonus_detail($type_sn);
  98. $content = ['type' => 'receive_bonus','from' => $from,'schema' => $shema,'note' => "给您发了一个红包"];
  99. room\factory_client::instance()->notice_users($to_ids,room\proto_type::push_notify,$content,$text);
  100. }
  101. public static function bonus_refund($member_id,$amount,$type_sn)
  102. {
  103. $sender = new member_info($member_id);
  104. $text = "红包退还通知:您发送的红包已超过24小时,退还未被领取的金额{$amount}元,您可以重新发送并通知小伙伴及时领取.";
  105. $push_param['alias'] = $member_id;
  106. $push_param['title'] = "过期未领红包退还";
  107. $push_param['text'] = $text;
  108. $push_param['extra']['go_type'] = 'bonus';
  109. $push_param['extra']['title'] = "过期未领红包退还";
  110. $push_param['extra']['text'] = $text;
  111. $push_param['extra']['show_type'] = 'pop';
  112. $push_param['extra']['url'] = 'xmmz://p.lrlz.com/main/index?index=2';
  113. $push_param['extra']['image'] = $sender->avatar();
  114. QueueClient::push('upushSendMsg',$push_param);
  115. $from = ['nickname' => $sender->nickname(),'avatar' => $sender->avatar(),'userid' => $sender->member_id()];
  116. $shema = schema_helper::bonus_detail($type_sn);
  117. $content = ['type' => 'bonus_refund','from' => $from,'schema' => $shema,'note' => "红包过期退款¥{$amount}"];
  118. room\factory_client::instance()->notice_users([$member_id],room\proto_type::push_notify,$content,$text);
  119. }
  120. public static function invite_bonus($member_id,$money,$type_sn)
  121. {
  122. $minfo = new member_info($member_id);
  123. $text = "好东西就要与好盆友一起分享,感谢您的热情推荐,特奖励您{$money}元的友情红包,请查收~.";
  124. $push_param['alias'] = $member_id;
  125. $push_param['title'] = "邀请奖励";
  126. $push_param['text'] = $text;
  127. $push_param['extra']['go_type'] = 'bonus';
  128. $push_param['extra']['title'] = "邀请奖励";
  129. $push_param['extra']['text'] = $text;
  130. $push_param['extra']['show_type'] = 'pop';
  131. $push_param['extra']['url'] = 'xmmz://p.lrlz.com/main/index?index=2';
  132. $push_param['extra']['image'] = $minfo->avatar();
  133. QueueClient::push('upushSendMsg',$push_param);
  134. $from = ['nickname' => $minfo->nickname(),'avatar' => $minfo->avatar(),'userid' => $minfo->member_id()];
  135. $shema = schema_helper::bonus_detail($type_sn);
  136. $content = ['type' => 'invite_bonus','from' => $from,'schema' => $shema,'note' => "收到邀请奖励¥{$money}"];
  137. room\factory_client::instance()->notice_users([$member_id],room\proto_type::push_notify,$content,$text);
  138. }
  139. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  140. public static function register_bonus($user, $money,$type_sn,$fQueue=false)
  141. {
  142. $text = "您获得{$money}元的新人首单红包,请查收~";
  143. $push_param['alias'] = $user;
  144. $push_param['title'] = "收到新人首单红包";
  145. $push_param['text'] = $text;
  146. $push_param['extra']['go_type'] = 'bonus';
  147. $push_param['extra']['title'] = "收到新人首单红包";
  148. $push_param['extra']['text'] = $text;
  149. $push_param['extra']['show_type'] = 'pop';
  150. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  151. $push_param['extra']['image'] = self::admin_avatar();
  152. self::push($user,$push_param,Sms::tpl_reg_user_bonus,['amount' => $money],$fQueue);
  153. $minfo = new member_info($user);
  154. $from = ['nickname' => $minfo->nickname(),'avatar' => $minfo->avatar(),'userid' => $minfo->member_id()];
  155. $shema = schema_helper::bonus_detail($type_sn);
  156. $content = ['type' => 'register_bonus','from' => $from,'schema' => $shema,'note' => "收到新人红包¥{$money}"];
  157. room\factory_client::instance()->notice_users([$user],room\proto_type::push_notify,$content,$text);
  158. }
  159. public static function money_rate_desc($money,$rate)
  160. {
  161. $amount = intval($money * 100 + 0.5) / 100;
  162. return "{$amount}元";
  163. }
  164. private static function push($alias, $push_param, $sms_type='',$sms_param=[], $fQueue=false)
  165. {
  166. $alias_info = new member_info($alias);
  167. $mobile = $alias_info->mobile();
  168. $client_type = $alias_info->client_type();
  169. if($fQueue)
  170. {
  171. if($client_type > 0) {
  172. QueueClient::push('upushSendMsg',$push_param);
  173. }
  174. else
  175. {
  176. if(!empty($sms_type) && $alias_info->can_sms()) {
  177. $sms_param['mobile'] = $mobile;
  178. $sms_param['type'] = $sms_type;
  179. QueueClient::push('sendOperSMS',$sms_param);
  180. }
  181. else {
  182. QueueClient::push('upushSendMsg',$push_param);
  183. }
  184. }
  185. }
  186. else
  187. {
  188. if($client_type > 0) {
  189. $push = new push_sender();
  190. $status = $push->send($push_param,$client_type);
  191. }
  192. else
  193. {
  194. if(!empty($sms_type) && $alias_info->can_sms()) {
  195. $sms = new Sms();
  196. $status = $sms->send_oper($mobile,$sms_type,$sms_param);
  197. }
  198. else {
  199. $push = new push_sender();
  200. $status = $push->send($push_param,$client_type);
  201. }
  202. }
  203. }
  204. }
  205. private static function inviter_text(member_info $invitee, $level, $money, $rate)
  206. {
  207. $nickname = $invitee->nickname();
  208. $text = self::money_rate_desc($money, $rate);
  209. return "{$nickname} 成为您的{$level}度粉丝,您获得{$text}红包奖励.";
  210. }
  211. public static function inviter_bonus($inviter, $user, $level, $money, $rate, $type_sn,$fQueue=false)
  212. {
  213. $user_info = new member_info($user);
  214. $text = self::inviter_text($user_info,$level,$money,$rate);
  215. $push_param['alias'] = $inviter;
  216. $push_param['title'] = "收到邀请奖励红包";
  217. $push_param['text'] = $text;
  218. $push_param['extra']['go_type'] = 'bonus';
  219. $push_param['extra']['title'] = "收到邀请奖励红包";
  220. $push_param['extra']['text'] = $text;
  221. $push_param['extra']['show_type']= 'pop';
  222. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  223. $push_param['extra']['image'] = $user_info->avatar();
  224. self::push($inviter,$push_param,Sms::tpl_reg_inviter,['user_name' => $user_info->nickname(),'level' => $level,'amount' => $money],$fQueue);
  225. }
  226. private static function invitee_text(member_info $inviter, member_info $user, $level, $money, $rate)
  227. {
  228. $desc = self::money_rate_desc($money, $rate);
  229. $text = "{$user->nickname()}成为{$inviter->nickname()}的{$level}度粉丝,您获得{$desc}红包奖励.";
  230. return $text;
  231. }
  232. public static function invitee_bonus($inviter, $invitee,member_info $user,$level, $money, $rate, $type_sn,$fQueue=false)
  233. {
  234. $inviter_info = new member_info($inviter);
  235. $text = self::invitee_text($inviter_info,$user,$level,$money,$rate);
  236. $push_param['alias'] = $invitee;
  237. $push_param['title'] = "收到雨露均沾红包";
  238. $push_param['text'] = $text;
  239. $push_param['extra']['go_type'] = 'bonus';
  240. $push_param['extra']['title'] = "收到雨露均沾红包";
  241. $push_param['extra']['text'] = $text;
  242. $push_param['extra']['show_type']= 'pop';
  243. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  244. $push_param['extra']['image'] = $inviter_info->avatar();
  245. if($level < 2) {
  246. self::push($invitee,$push_param,Sms::tpl_reg_invitee,
  247. ['user_name' => $user->nickname(),'inviter_name' => $inviter_info->nickname(),'level' => $level,'amount' => $money],
  248. $fQueue);
  249. } else {
  250. $push = new push_sender();
  251. $push->send($push_param);
  252. }
  253. }
  254. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  255. private static function buygoods_inviter_text(member_info $user, $level, $goods_name)
  256. {
  257. $text = "您的{$level}度粉丝 {$user->nickname()},刚刚购买了《{$goods_name}》.";
  258. return $text;
  259. }
  260. public static function inviter_order_paied($inviter, $user, $level, $goods_info,$fQueue=false)
  261. {
  262. $user_info = new member_info($user);
  263. $text = self::buygoods_inviter_text($user_info,$level,$goods_info['goods_name']);
  264. $push_param['alias'] = $inviter;
  265. $push_param['title'] = "粉丝正在买";
  266. $push_param['text'] = $text;
  267. $push_param['extra']['go_type'] = 'bonus';
  268. $push_param['extra']['title'] = "粉丝正在买";
  269. $push_param['extra']['text'] = $text;
  270. $push_param['extra']['show_type']= 'pop';
  271. $push_param['extra']['url'] = schema_helper::goods($goods_info['goods_id']);
  272. $push_param['extra']['image'] = $goods_info['goods_image'];
  273. QueueClient::push('upushSendMsg',$push_param);
  274. }
  275. private static function buygoods_invitee_text(member_info $user, $goods_name)
  276. {
  277. $text = "您的好友 {$user->nickname()},刚刚购买了《{$goods_name}》.";
  278. return $text;
  279. }
  280. public static function invitee_order_paied($invitee, $user, $goods_info)
  281. {
  282. $user_info = new member_info($user);
  283. $text = self::buygoods_invitee_text($user_info,$goods_info['goods_name']);
  284. $push_param['alias'] = $invitee;
  285. $push_param['title'] = "好友正在买";
  286. $push_param['text'] = $text;
  287. $push_param['extra']['go_type'] = 'bonus';
  288. $push_param['extra']['title'] = "好友正在买";
  289. $push_param['extra']['text'] = $text;
  290. $push_param['extra']['show_type']= 'pop';
  291. $push_param['extra']['url'] = schema_helper::goods($goods_info['goods_id']);
  292. $push_param['extra']['image'] = $goods_info['goods_image'];
  293. QueueClient::push('upushSendMsg',$push_param);
  294. }
  295. public static function user_order_paied($user, $paysn)
  296. {
  297. $text = "请留意发货短信,确认收货后会有红包奖励~";
  298. $push_param['alias'] = $user;
  299. $push_param['title'] = "支付成功";
  300. $push_param['text'] = $text;
  301. $push_param['extra']['go_type'] = '';
  302. $push_param['extra']['title'] = "支付成功";
  303. $push_param['extra']['text'] = $text;
  304. $push_param['extra']['show_type'] = 'pop';
  305. $push_param['extra']['url'] = schema_helper::order_info($paysn);
  306. $push_param['extra']['image'] = self::admin_avatar();
  307. QueueClient::push('upushSendMsg',$push_param);
  308. }
  309. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  310. public static function user_order_complete_fixed($user, $money, $rate, $type_sn)
  311. {
  312. $desc = self::money_rate_desc($money,$rate);
  313. $text = "您的宝贝已被安全签收,小熊猫送您{$desc}红包,请查收~";
  314. $push_param['alias'] = $user;
  315. $push_param['title'] = "收货红包";
  316. $push_param['text'] = $text;
  317. $push_param['img'] = self::admin_avatar();
  318. $push_param['extra']['go_type'] = 'bonus';
  319. $push_param['extra']['title'] = "收货红包";
  320. $push_param['extra']['text'] = $text;
  321. $push_param['extra']['show_type']= 'pop';
  322. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  323. $push_param['extra']['image'] = self::admin_avatar();
  324. QueueClient::push('upushSendMsg',$push_param);
  325. $minfo = new member_info($user);
  326. $from = ['nickname' => $minfo->nickname(),'avatar' => $minfo->avatar(),'userid' => $minfo->member_id()];
  327. $shema = schema_helper::bonus_detail($type_sn);
  328. $content = ['type' => 'order_bonus','from' => $from,'schema' => $shema,'note' => "收到购物成功红包¥{$money}"];
  329. room\factory_client::instance()->notice_users([$user],room\proto_type::push_notify,$content,$text);
  330. }
  331. public static function user_order_complete_random($user,$num,$type_sn)
  332. {
  333. $text = "您的宝贝已被安全签收,小熊猫送您{$num}个可分享红包,分享给小伙伴吧~";
  334. $push_param['alias'] = $user;
  335. $push_param['title'] = "收货可分享红包";
  336. $push_param['text'] = $text;
  337. $push_param['img'] = self::admin_avatar();
  338. $push_param['extra']['go_type'] = 'bonus';
  339. $push_param['extra']['title'] = "收货可分享红包";
  340. $push_param['extra']['text'] = $text;
  341. $push_param['extra']['show_type']= 'pop';
  342. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  343. $push_param['extra']['image'] = self::admin_avatar();
  344. QueueClient::push('upushSendMsg',$push_param);
  345. $minfo = new member_info($user);
  346. $from = ['nickname' => $minfo->nickname(),'avatar' => $minfo->avatar(),'userid' => $minfo->member_id()];
  347. $shema = schema_helper::bonus_detail($type_sn);
  348. $content = ['type' => 'order_bonus','from' => $from,'schema' => $shema,'note' => "收到{$num}购物分享红包"];
  349. room\factory_client::instance()->notice_users([$user],room\proto_type::push_notify,$content,$text);
  350. }
  351. private static function inviter_order_complete_text(member_info $invitee, $level, $money, $rate)
  352. {
  353. $nickname = $invitee->nickname();
  354. $text = self::money_rate_desc($money, $rate);
  355. return "您的{$level}度粉丝 {$nickname} 下单成功,您获得{$text}红包奖励.";
  356. }
  357. public static function inviter_order_complete_bonus($inviter, $user, $level, $money, $rate, $type_sn,$fQueue=false)
  358. {
  359. $user_info = new member_info($user);
  360. $text = self::inviter_order_complete_text($user_info,$level,$money,$rate);
  361. $push_param['alias'] = $inviter;
  362. $push_param['title'] = "收到粉丝下单红包";
  363. $push_param['text'] = $text;
  364. $push_param['extra']['go_type'] = 'bonus';
  365. $push_param['extra']['title'] = "收到粉丝下单红包";
  366. $push_param['extra']['text'] = $text;
  367. $push_param['extra']['show_type']= 'pop';
  368. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  369. $push_param['extra']['image'] = $user_info->avatar();
  370. self::push($inviter,$push_param,Sms::tpl_order_complete_inviter,['level' => $level,'name' => $user_info->nickname(),'amount' => $money],$fQueue);
  371. }
  372. private static function invitee_order_complete_text(member_info $user, $money, $rate)
  373. {
  374. $nickname = $user->nickname();
  375. $text = self::money_rate_desc($money, $rate);
  376. return "好友{$nickname}下单成功,您获得{$text}红包奖励.";
  377. }
  378. public static function invitee_order_complete_bonus($invitee,member_info $user, $money, $rate, $type_sn,$fQueue=false)
  379. {
  380. $text = self::invitee_order_complete_text($user,$money,$rate);
  381. $push_param['alias'] = $invitee;
  382. $push_param['title'] = "收到好友下单红包";
  383. $push_param['text'] = $text;
  384. $push_param['extra']['go_type'] = 'bonus';
  385. $push_param['extra']['title'] = "收到好友下单红包";
  386. $push_param['extra']['text'] = $text;
  387. $push_param['extra']['show_type']= 'pop';
  388. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  389. $push_param['extra']['image'] = $user->avatar();
  390. self::push($invitee,$push_param,Sms::tpl_order_complete_invitee,['name' => $user->nickname(),'amount' => $money],$fQueue);
  391. }
  392. private static function all_order_complete_text(member_info $user, $money, $rate)
  393. {
  394. $nickname = $user->nickname();
  395. $text = self::money_rate_desc($money, $rate);
  396. return "{$nickname}下单成功,引发红包风暴,您获得{$text}红包奖励.";
  397. }
  398. public static function all_order_complete_bonus($user, member_info $buyer, $money, $rate, $type_sn, $fQueue=false)
  399. {
  400. $text = self::all_order_complete_text($buyer,$money,$rate);
  401. $push_param['alias'] = $user;
  402. $push_param['title'] = "收到下单红包雨";
  403. $push_param['text'] = $text;
  404. $push_param['extra']['go_type'] = 'bonus';
  405. $push_param['extra']['title'] = "收到下单红包雨";
  406. $push_param['extra']['text'] = $text;
  407. $push_param['extra']['show_type']= 'pop';
  408. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  409. $push_param['extra']['image'] = self::admin_avatar();
  410. self::push($user,$push_param,Sms::tpl_order_complete_all,['name' => $buyer->nickname(),'amount' => $money],$fQueue);
  411. }
  412. public static function order_cancel_bonus($member_id,$amount,$rate,$order_sn,$type_sn)
  413. {
  414. $desc = self::money_rate_desc($amount,$rate);
  415. $text = "订单{$order_sn}取消成功,退还{$desc}红包.";
  416. $push_param['alias'] = $member_id;
  417. $push_param['title'] = "收到取消订单红包";
  418. $push_param['text'] = $text;
  419. $push_param['extra']['go_type'] = 'bonus';
  420. $push_param['extra']['title'] = "收到取消订单红包";
  421. $push_param['extra']['text'] = $text;
  422. $push_param['extra']['show_type'] = 'pop';
  423. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  424. $push_param['extra']['image'] = self::admin_avatar();
  425. QueueClient::push('upushSendMsg',$push_param);
  426. $minfo = new member_info($member_id);
  427. $from = ['nickname' => $minfo->nickname(),'avatar' => $minfo->avatar(),'userid' => $minfo->member_id()];
  428. $shema = schema_helper::bonus_detail($type_sn);
  429. $content = ['type' => 'order_bonus','from' => $from,'schema' => $shema,'note' => "收到购物退款红包¥{$amount}"];
  430. room\factory_client::instance()->notice_users([$member_id],room\proto_type::push_notify,$content,$text);
  431. }
  432. public static function order_evaluate_bonus($user, $money,$rate,$type_sn)
  433. {
  434. $desc = self::money_rate_desc($money, $rate);
  435. $text = "感谢您的每一个评价,小熊猫送您{$desc}红包,请查收~.";
  436. $push_param['alias'] = $user;
  437. $push_param['title'] = "收到评价红包";
  438. $push_param['text'] = $text;
  439. $push_param['extra']['go_type'] = 'bonus';
  440. $push_param['extra']['title'] = "收到评价红包";
  441. $push_param['extra']['text'] = $text;
  442. $push_param['extra']['show_type'] = 'pop';
  443. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  444. $push_param['extra']['image'] = self::admin_avatar();
  445. QueueClient::push('upushSendMsg',$push_param);
  446. $minfo = new member_info($user);
  447. $from = ['nickname' => $minfo->nickname(),'avatar' => $minfo->avatar(),'userid' => $minfo->member_id()];
  448. $shema = schema_helper::bonus_detail($type_sn);
  449. $content = ['type' => 'order_bonus','from' => $from,'schema' => $shema,'note' => "收到订单评价红包¥{$money}"];
  450. room\factory_client::instance()->notice_users([$user],room\proto_type::push_notify,$content,$text);
  451. }
  452. private static function inviter_evaluated_text(member_info $user, $level, $goods_name)
  453. {
  454. $text = "您的{$level}度粉丝 {$user->nickname()},刚刚评论了《{$goods_name}》.";
  455. return $text;
  456. }
  457. public static function inviter_order_evaluated($inviter, $user, $level, $goods_info)
  458. {
  459. $user_info = new member_info($user);
  460. $text = self::inviter_evaluated_text($user_info,$level,$goods_info['goods_name']);
  461. $push_param['alias'] = $inviter;
  462. $push_param['title'] = "粉丝正在评论";
  463. $push_param['text'] = $text;
  464. $push_param['extra']['go_type'] = 'bonus';
  465. $push_param['extra']['title'] = "粉丝正在评论";
  466. $push_param['extra']['text'] = $text;
  467. $push_param['extra']['show_type']= 'pop';
  468. $push_param['extra']['url'] = schema_helper::goods($goods_info['goods_id']);
  469. $push_param['extra']['image'] = $goods_info['goods_image'];
  470. QueueClient::push('upushSendMsg',$push_param);
  471. }
  472. private static function invitee_evaluated_text(member_info $user, $goods_name)
  473. {
  474. $text = "您的好友 {$user->nickname()},刚刚评论了《{$goods_name}》.";
  475. return $text;
  476. }
  477. public static function invitee_order_evaluated($invitee, $user, $goods_info)
  478. {
  479. $user_info = new member_info($user);
  480. $text = self::invitee_evaluated_text($user_info,$goods_info['goods_name']);
  481. $push_param['alias'] = $invitee;
  482. $push_param['title'] = "好友正在评论";
  483. $push_param['text'] = $text;
  484. $push_param['extra']['go_type'] = 'bonus';
  485. $push_param['extra']['title'] = "好友正在评论";
  486. $push_param['extra']['text'] = $text;
  487. $push_param['extra']['show_type']= 'pop';
  488. $push_param['extra']['url'] = schema_helper::goods($goods_info['goods_id']);
  489. $push_param['extra']['image'] = $goods_info['goods_image'];
  490. QueueClient::push('upushSendMsg',$push_param);
  491. }
  492. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  493. public static function nofity_ugc_pub($follow,$author_id,$special_id,$title)
  494. {
  495. $author = new member_info($author_id);
  496. $text = "好友{$author->nickname()} 发表文章《{$title}》";
  497. $push_param['alias'] = $follow;
  498. $push_param['title'] = "好友发表文章";
  499. $push_param['text'] = $text;
  500. $push_param['extra']['go_type'] = 'bonus';
  501. $push_param['extra']['title'] = "好友发表文章";
  502. $push_param['extra']['text'] = $text;
  503. $push_param['extra']['show_type']= 'pop';
  504. $push_param['extra']['url'] = schema_helper::ugc($title,$special_id);
  505. $push_param['extra']['image'] = $author->avatar();
  506. QueueClient::push('upushSendMsg',$push_param);
  507. }
  508. public static function nofity_ugc_submit($author,$reader,$special_id,$title)
  509. {
  510. $user = new member_info($reader);
  511. $text = "好友{$user->nickname()} 阅读了您的文章《{$title}》";
  512. $push_param['alias'] = $author;
  513. $push_param['title'] = "好友阅读文章";
  514. $push_param['text'] = $text;
  515. $push_param['extra']['go_type'] = 'bonus';
  516. $push_param['extra']['title'] = "好友阅读文章";
  517. $push_param['extra']['text'] = $text;
  518. $push_param['extra']['show_type']= 'pop';
  519. $push_param['extra']['url'] = schema_helper::ugc($title,$special_id);
  520. $push_param['extra']['image'] = $user->avatar();
  521. QueueClient::push('upushSendMsg',$push_param);
  522. }
  523. public static function nofity_ugc_comment($author,$commender,$fcomment,$special_id,$content,$article_title)
  524. {
  525. $commender = new member_info($commender);
  526. if($fcomment) {
  527. $title = '收到留言回复';
  528. $text = "好友{$commender->nickname()} 回复您的评论:{$content}";
  529. } else {
  530. $title = '收到文章评论';
  531. $text = "文章《{$article_title}》收到一个新评论";
  532. }
  533. $push_param['alias'] = $author;
  534. $push_param['title'] = $title;
  535. $push_param['text'] = $text;
  536. $push_param['extra']['go_type'] = '';
  537. $push_param['extra']['title']= $title;
  538. $push_param['extra']['text'] = $text;
  539. $push_param['extra']['show_type'] = 'pop';
  540. $push_param['extra']['url'] = schema_helper::ugc($article_title,$special_id);
  541. $push_param['extra']['image'] = $commender->avatar();
  542. QueueClient::push('upushSendMsg',$push_param);
  543. }
  544. public static function nofity_ugc_support($author,$commender,$fcomment,$special_id,$content,$article_title)
  545. {
  546. if($commender > 0)
  547. {
  548. $commender = new member_info($commender);
  549. if($fcomment) {
  550. $text = "{$commender->nickname()} 点赞您的评论:{$content}";
  551. } else {
  552. $text = "{$commender->nickname()} 点赞您的文章《{$article_title}》";
  553. }
  554. $push_param['extra']['image'] = $commender->avatar();
  555. }
  556. else
  557. {
  558. if($fcomment) {
  559. $text = "刚刚有人点赞您的评论:{$content}";
  560. } else {
  561. $text = "刚刚有人点赞您的文章《{$article_title}》";
  562. }
  563. $push_param['extra']['image'] = "";
  564. }
  565. $push_param['alias'] = $author;
  566. $push_param['title'] = '收到点赞';
  567. $push_param['text'] = $text;
  568. $push_param['extra']['go_type'] = '';
  569. $push_param['extra']['title']= '收到点赞';
  570. $push_param['extra']['text'] = $text;
  571. $push_param['extra']['show_type'] = 'pop';
  572. $push_param['extra']['url'] = schema_helper::ugc($article_title,$special_id);
  573. QueueClient::push('upushSendMsg',$push_param);
  574. }
  575. public static function nofity_ugc_appreciate($author,$user,$special_id,$article,$rate,$amount)
  576. {
  577. $user_info = new member_info($user);
  578. $name = $user_info->nickname();
  579. $desc = self::money_rate_desc($amount,$rate);
  580. $text = "{$name}打赏您的文章《{$article}》{$desc}红包,快去查看吧.";
  581. $push_param['alias'] = $author;
  582. $push_param['title'] = "文章打赏";
  583. $push_param['text'] = $text;
  584. $push_param['extra']['go_type'] = 'bonus';
  585. $push_param['extra']['title'] = "文章打赏";
  586. $push_param['extra']['text'] = $text;
  587. $push_param['extra']['show_type'] = 'pop';
  588. $push_param['extra']['url'] = schema_helper::ugc($article,$special_id);
  589. $push_param['extra']['image'] = $user_info->avatar();
  590. QueueClient::push('upushSendMsg',$push_param);
  591. }
  592. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  593. public static function fcode_unlock($member_id,$num)
  594. {
  595. $text = "F码解锁通知:您有{$num}个F码已成功解锁,请注意过期时间~.";
  596. $push_param['alias'] = $member_id;
  597. $push_param['title'] = "F码";
  598. $push_param['text'] = $text;
  599. $push_param['extra']['go_type'] = 'fcode';
  600. $push_param['extra']['title'] = "F码";
  601. $push_param['extra']['text'] = $text;
  602. $push_param['extra']['show_type'] = 'pop';
  603. $push_param['extra']['url'] = schema_helper::mine_fcode();
  604. $push_param['extra']['image'] = self::admin_avatar();
  605. QueueClient::push('upushSendMsg', $push_param);
  606. }
  607. public static function notice_expring($member_id,$amount,$remain_days)
  608. {
  609. $minfo = new member_info($member_id);
  610. $text = "红包过期提醒:您价值{$amount}元的红包即将在{$remain_days}天内过期,尽快使用或者慷慨地分享给好友吧~";
  611. $push_param['alias'] = $member_id;
  612. $push_param['title'] = "红包过期提醒";
  613. $push_param['text'] = $text;
  614. $push_param['extra']['go_type'] = 'fcode';
  615. $push_param['extra']['title']= "红包过期提醒";
  616. $push_param['extra']['text'] = $text;
  617. $push_param['extra']['show_type'] = 'pop';
  618. $push_param['extra']['url'] = 'xmmz://p.lrlz.com/mine/fcode';
  619. $push_param['extra']['image'] = $minfo->avatar();
  620. QueueClient::push('upushSendMsg', $push_param);
  621. }
  622. public static function notice_expired($member_id,$amount)
  623. {
  624. $minfo = new member_info($member_id);
  625. $text = "红包过期通知:您价值{$amount}元的红包已过期,别伤心,每天十点试试手气,可以继续赚红包哦~";
  626. $push_param['alias'] = $member_id;
  627. $push_param['title'] = "红包过期通知";
  628. $push_param['text'] = $text;
  629. $push_param['extra']['go_type'] = 'bonus';
  630. $push_param['extra']['title']= "红包过期提醒";
  631. $push_param['extra']['text'] = $text;
  632. $push_param['extra']['show_type'] = 'pop';
  633. $push_param['extra']['url'] = 'xmmz://p.lrlz.com/mine/fcode';
  634. $push_param['extra']['image'] = $minfo->avatar();
  635. QueueClient::push('upushSendMsg', $push_param);
  636. }
  637. public static function notice_subscribe($member_id,member_info $user)
  638. {
  639. $name = $user->nickname();
  640. $text = "手机{$name}用户,关注了你~";
  641. $push_param['alias'] = $member_id;
  642. $push_param['title'] = "好友关系";
  643. $push_param['text'] = $text;
  644. $push_param['extra']['go_type'] = 'bonus';
  645. $push_param['extra']['title']= "好友关系";
  646. $push_param['extra']['text'] = $text;
  647. $push_param['extra']['show_type'] = 'pop';
  648. $push_param['extra']['image'] = $user->avatar();
  649. QueueClient::push('upushSendMsg',$push_param);
  650. }
  651. public static function oper_push($member_id,$content)
  652. {
  653. $minfo = new member_info($member_id);
  654. $push_param['alias'] = $member_id;
  655. $push_param['title'] = "日常活动";
  656. $push_param['text'] = $content;
  657. $push_param['extra']['go_type'] = '';
  658. $push_param['extra']['title']= "日常活动";
  659. $push_param['extra']['text'] = $content;
  660. $push_param['extra']['show_type'] = 'pop';
  661. $push_param['extra']['image'] = $minfo->avatar();
  662. QueueClient::push('upushSendMsg',$push_param);
  663. }
  664. public static function format_msg($member_id,$content)
  665. {
  666. $param['alias'] = $member_id;
  667. $param['text'] = $content;
  668. $param['extra']['go_type'] = '';
  669. $param['extra']['show_type'] = 'pop';
  670. return $param;
  671. }
  672. public static function fcode_warning($cid,$member_id,$usable_time)
  673. {
  674. $minfo = new member_info($member_id);
  675. $goods_name = self::goods_name($cid);
  676. $remain_days = intval((time() - $usable_time) / 86400);
  677. if(!empty($goods_name))
  678. {
  679. $param = [];
  680. $param['alias'] = $member_id;
  681. $param['title'] = "F码过期提醒";
  682. if($remain_days > 0) {
  683. $text = "F码过期提醒:您《{$goods_name}》的F码即将在{$remain_days}天内过期,请尽快使用";
  684. } else {
  685. $text = "F码过期提醒:您《{$goods_name}》的F码即将在今天过期,请尽快使用";
  686. }
  687. $param['text'] = $text;
  688. $param['extra']['go_type'] = 'fcode';
  689. $param['extra']['title']= "用户评价";
  690. $param['extra']['text'] = $text;
  691. $param['extra']['show_type'] = 'pop';
  692. $param['extra']['url'] = 'xmmz://p.lrlz.com/mine/fcode';
  693. $param['extra']['image'] = $minfo->avatar();
  694. QueueClient::push('upushSendMsg', $param);
  695. }
  696. }
  697. private static function goods_name($cid)
  698. {
  699. $items = Model()->table('goods_common')->field('goods_name')->where(['goods_commonid' => $cid])->select();
  700. if(empty($items)) {
  701. return false;
  702. }
  703. else {
  704. return $items[0]['goods_name'];
  705. }
  706. }
  707. private static function pushurl()
  708. {
  709. $url = BASE_SITE_URL . "/mobile/index.php?act=webpush";
  710. return $url;
  711. }
  712. //DialogMessage
  713. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  714. public static function poor_user_bonus($user, $money, $rate, $type_sn, $fQueue=false)
  715. {
  716. $desc = self::money_rate_desc($money,$rate);
  717. $text = "您的红包余额不足,好心人紧急为您充值{$desc}红包~";
  718. $push_param['alias'] = $user;
  719. $push_param['title'] = "收到津贴红包";
  720. $push_param['text'] = $text;
  721. $push_param['extra']['go_type'] = 'bonus';
  722. $push_param['extra']['title'] = "收到津贴红包";
  723. $push_param['extra']['text'] = $text;
  724. $push_param['extra']['show_type']= 'pop';
  725. $push_param['extra']['url'] = url_helper::bonus_open_url($type_sn);
  726. $push_param['extra']['image'] = self::admin_avatar();
  727. self::push($user,$push_param);
  728. }
  729. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  730. public static function first_present($member_id,$fcode)
  731. {
  732. $fc_id = intval($fcode['fc_id']);
  733. $url = self::pushurl() . "&op=fcode&fc_id={$fc_id}";
  734. $minfo = new member_info($member_id);
  735. $push_param['alias'] = $member_id;
  736. $push_param['title'] = "收到下单首单礼";
  737. $text = "恭喜您获得首单礼,现在就去下单";
  738. $push_param['text'] = $text;
  739. $push_param['extra']['go_type'] = '';
  740. $push_param['extra']['title']= "下单首单礼";
  741. $push_param['extra']['text'] = $text;
  742. $push_param['extra']['show_type'] = 'dialog';
  743. $push_param['extra']['image'] = $minfo->avatar();
  744. $push_param['extra']['url'] = $url;
  745. QueueClient::push('upushSendMsg',$push_param);
  746. }
  747. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  748. public static function call_friends($caller,$callee)
  749. {
  750. $minfo = new member_info($caller);
  751. $push_param['alias'] = $callee;
  752. $push_param['title'] = "{$minfo->nickname()} 的召唤";
  753. $text = "我正在赚红包,你也有得赚,赶快登陆App查看你的红包余额,赢免费大牌美妆~";
  754. $push_param['text'] = $text;
  755. $push_param['extra']['go_type'] = '';
  756. $push_param['extra']['title']= "{$minfo->nickname()} 的召唤";
  757. $push_param['extra']['text'] = $text;
  758. $push_param['extra']['show_type'] = 'pop';
  759. $push_param['extra']['image'] = $minfo->avatar();
  760. $push_param['extra']['url'] = schema_helper::invite_page();
  761. self::push($callee,$push_param,Sms::tpl_call_user_back,['name' => $minfo->nickname()],true);
  762. }
  763. public static function pop_message($user, $title, $text,$url)
  764. {
  765. $push_param['alias'] = $user;
  766. $push_param['title'] = $title;
  767. $push_param['text'] = $text;
  768. $push_param['extra']['go_type'] = '';
  769. $push_param['extra']['title']= $title;
  770. $push_param['extra']['text'] = $text;
  771. $push_param['extra']['show_type'] = 'pop';
  772. $push_param['extra']['image'] = self::admin_avatar();
  773. $push_param['extra']['url'] = $url;
  774. return $push_param;
  775. }
  776. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  777. public static function bargain_bonus($user, $money,$type_sn,$fQueue=false)
  778. {
  779. $text = "您获得{$money}元的砍价红包,请查收~";
  780. $push_param['alias'] = $user;
  781. $push_param['title'] = "收到砍价红包";
  782. $push_param['text'] = $text;
  783. $push_param['extra']['go_type'] = 'bonus';
  784. $push_param['extra']['title'] = "收到砍价红包";
  785. $push_param['extra']['text'] = $text;
  786. $push_param['extra']['show_type'] = 'pop';
  787. $push_param['extra']['url'] = schema_helper::bonus_detail($type_sn);
  788. $push_param['extra']['image'] = self::admin_avatar();
  789. QueueClient::push('upushSendMsg',$push_param);
  790. }
  791. }
  792. class push_event
  793. {
  794. static public function publish_special($member_ids,$ispub,$count)
  795. {
  796. if($ispub) {
  797. $visible_type = 'pub_visible';
  798. } else {
  799. $visible_type = 'pri_visible';
  800. }
  801. foreach ($member_ids as $member_id)
  802. {
  803. $info['alias'] = $member_id;
  804. $info['custom'] = ['type' => 'add_special','visible_type' => $visible_type,'count' => $count];
  805. QueueClient::push('sendPushMessage',$info);
  806. }
  807. }
  808. }