push_helper.php 36 KB

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