push_helper.php 32 KB

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