push_helper.php 38 KB

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