NoticeService.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. namespace App\Services\Welfare;
  3. use App\Models\User\UserModel;
  4. use App\Models\Welfare\LotteryModel;
  5. use App\Services\QQMiniApp\Template;
  6. use PocketBE\MsyPush\Jobs\RegistEventJob;
  7. class NoticeService
  8. {
  9. /**
  10. * 福利中心-活动开奖前提醒
  11. * @param int $to_uid
  12. * @param int $id
  13. */
  14. public function beforeLottery($to_uid, $id)
  15. {
  16. $title = "福利中心-活动开奖前提醒";
  17. $lottery = LotteryModel::findOrFail($id);
  18. $user = UserModel::find($to_uid);
  19. $payload = [
  20. 'user' => $user->toArray(),
  21. 'lottery' => $lottery->toArray(),
  22. ];
  23. dispatch(new RegistEventJob(10601, $payload))->onQueue("{push}");
  24. // QQ通知
  25. $uuid = uuid();
  26. $template_id = "a1c1ba47f520de5bd1b5c064dc915108";
  27. $page = "reward/pages/welfare/welfare";
  28. $parameters = [
  29. 'keyword1' => [
  30. 'value' => "距本期开奖时间还剩1小时",
  31. ],
  32. 'keyword2' => [
  33. 'value' => $lottery->title,
  34. ],
  35. 'keyword3' => [
  36. 'value' => date("Y-m-d 20:00"),
  37. ],
  38. 'keyword4' => [
  39. 'value' => "点此消息继续邀请好友助力,还可获得更多抽奖码,增加中奖概率~",
  40. ],
  41. ];
  42. $qqTemplate = new Template();
  43. $qqTemplate->setUuid($uuid)
  44. ->setTitle($title)
  45. ->toUser($to_uid)
  46. ->setTemplateId($template_id)
  47. ->setParameters($parameters)
  48. ->setPage($page)
  49. ->send();
  50. }
  51. /**
  52. * 福利中心-活动开奖结果通知
  53. * @param int $to_uid
  54. * @param int $id
  55. */
  56. public function afterLottery($to_uid, $id)
  57. {
  58. $title = "福利中心-活动开奖结果通知";
  59. $lottery = LotteryModel::findOrFail($id);
  60. $user = UserModel::find($to_uid);
  61. $payload = [
  62. 'user' => $user->toArray(),
  63. 'lottery' => $lottery->toArray(),
  64. ];
  65. dispatch(new RegistEventJob(10602, $payload))->onQueue("{push}");
  66. // QQ通知
  67. $uuid = uuid();
  68. $template_id = "a1c1ba47f520de5bd1b5c064dc915108";
  69. $page = "reward/pages/welfare/welfare";
  70. $parameters = [
  71. 'keyword1' => [
  72. 'value' => "开奖结果已出",
  73. ],
  74. 'keyword2' => [
  75. 'value' => $lottery->title,
  76. ],
  77. 'keyword3' => [
  78. 'value' => date("Y-m-d 20:00"),
  79. ],
  80. 'keyword4' => [
  81. 'value' => "点此消息查看开奖结果",
  82. ],
  83. ];
  84. $qqTemplate = new Template();
  85. $qqTemplate->setUuid($uuid)
  86. ->setTitle($title)
  87. ->toUser($to_uid)
  88. ->setTemplateId($template_id)
  89. ->setParameters($parameters)
  90. ->setPage($page)
  91. ->send();
  92. }
  93. /**
  94. * 福利中心-好友助力获得抽奖码-助力者
  95. * @param int $to_uid
  96. * @param int $friend_uid
  97. */
  98. public function helpToScore($to_uid, $friend_uid)
  99. {
  100. $title = "福利中心-好友助力获得抽奖码-助力者";
  101. $friend_user = UserModel::select('nickname')->find($friend_uid);
  102. $user = UserModel::find($to_uid);
  103. $payload = [
  104. 'user' => $user->toArray(),
  105. 'friend_user' => $friend_user->toArray(),
  106. ];
  107. dispatch(new RegistEventJob(10603, $payload))->onQueue("{push}");
  108. // QQ通知
  109. $uuid = uuid();
  110. $template_id = "172b97e61188c41c15477a48181ef6c0";
  111. $page = "reward/pages/welfare/welfare";
  112. $parameters = [
  113. 'keyword1' => [
  114. 'value' => "你成功为你的好友@{$friend_user->nickname} 助力获取抽奖码",
  115. ],
  116. 'keyword2' => [
  117. 'value' => "助力成功,你的好友已获取额外抽奖码",
  118. ],
  119. 'keyword3' => [
  120. 'value' => "福利中心",
  121. ],
  122. 'keyword4' => [
  123. 'value' => "点此消息可参与福利抽奖,抽皮肤,抽视频会员",
  124. ],
  125. ];
  126. $qqTemplate = new Template();
  127. $qqTemplate->setUuid($uuid)
  128. ->setTitle($title)
  129. ->toUser($to_uid)
  130. ->setTemplateId($template_id)
  131. ->setParameters($parameters)
  132. ->setPage($page)
  133. ->send();
  134. }
  135. /**
  136. * 福利中心-好友助力获得抽奖码-分享者
  137. * @param int $to_uid
  138. * @param int $friend_uid
  139. */
  140. public function inviteToScore($to_uid, $friend_uid)
  141. {
  142. $title = "福利中心-好友助力获得抽奖码-分享者";
  143. $user = UserModel::find($to_uid);
  144. $friend_user = UserModel::find($friend_uid);
  145. $payload = [
  146. 'user' => $user->toArray(),
  147. 'friend_user' => $friend_user->toArray(),
  148. ];
  149. dispatch(new RegistEventJob(10604, $payload))->onQueue("{push}");
  150. // QQ通知
  151. $uuid = uuid();
  152. $template_id = "172b97e61188c41c15477a48181ef6c0";
  153. $page = "reward/pages/welfare/welfare";
  154. $parameters = [
  155. 'keyword1' => [
  156. 'value' => "获得额外抽奖码",
  157. ],
  158. 'keyword2' => [
  159. 'value' => "你的好友@{$friend_user->nickname}成功为你增加了抽奖机会",
  160. ],
  161. 'keyword3' => [
  162. 'value' => "福利中心",
  163. ],
  164. 'keyword4' => [
  165. 'value' => "点此查看抽奖详情",
  166. ],
  167. ];
  168. $qqTemplate = new Template();
  169. $qqTemplate->setUuid($uuid)
  170. ->setTitle($title)
  171. ->toUser($to_uid)
  172. ->setTemplateId($template_id)
  173. ->setParameters($parameters)
  174. ->setPage($page)
  175. ->send();
  176. }
  177. }