NoticeService.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. namespace App\Services\Pair;
  3. use App\Models\Fpdx\FormModel;
  4. use App\Models\Fpdx\PairModel;
  5. use App\Models\NoticeModel;
  6. use App\Models\User\UserModel;
  7. use App\Services\Service;
  8. use PocketBE\MsyPush\Jobs\RegistEventJob;
  9. class NoticeService extends Service
  10. {
  11. /**
  12. * 72小时-单方面确认关系通知
  13. * @param int $to_uid
  14. * @param int $pair_id
  15. * @return void
  16. */
  17. public function unilateralConfirm(int $to_uid, int $pair_id)
  18. {
  19. $title = "72小时-单方面确认关系通知";
  20. $user = UserModel::find($to_uid);
  21. $pair = PairModel::find($pair_id);
  22. $payload = [
  23. 'to_user' => $user->getAuth(),
  24. 'pair' => $pair->toArray(),
  25. ];
  26. dispatch(new RegistEventJob(10101, $payload))->onQueue("{push}");
  27. }
  28. /**
  29. * 单方面选择重配
  30. * @param int $to_user
  31. * @param int $pair_id
  32. * @return void
  33. */
  34. public function unilateralAgain(int $to_user, int $pair_id)
  35. {
  36. $title = "72小时-单方面重配通知";
  37. $user = UserModel::find($to_user);
  38. $pair = PairModel::find($pair_id);
  39. $payload = [
  40. 'to_user' => $user->getAuth(),
  41. 'pair' => $pair->toArray(),
  42. ];
  43. dispatch(new RegistEventJob(10102, $payload))->onQueue("{push}");
  44. }
  45. /**
  46. * 单方确认关系反悔通知
  47. * @param int $to_user
  48. */
  49. public function regretConfirm($to_user)
  50. {
  51. $title = "72小时-单方确认关系反悔通知";
  52. $user = UserModel::find($to_user);
  53. $payload = [
  54. 'to_user' => $user->getAuth(),
  55. ];
  56. dispatch(new RegistEventJob(10103, $payload))->onQueue("{push}");
  57. }
  58. /**
  59. * 单方选择重匹反悔通知
  60. * @param int $to_user
  61. */
  62. public function regretAgain($to_user)
  63. {
  64. $title = "72小时-单方选择重匹反悔通知";
  65. $user = UserModel::find($to_user);
  66. $payload = [
  67. 'to_user' => $user->getAuth(),
  68. ];
  69. dispatch(new RegistEventJob(10104, $payload))->onQueue("{push}");
  70. }
  71. /**
  72. * 72小时-活动群解锁通知
  73. * @param int $to_uid
  74. * @param int $pair_id
  75. * @return void
  76. */
  77. public function unlockGroup(int $to_uid, int $pair_id)
  78. {
  79. $title = '72小时-活动群解锁通知';
  80. $user = UserModel::find($to_uid);
  81. $pair = PairModel::find($pair_id);
  82. $payload = [
  83. 'to_user' => $user->getAuth(),
  84. 'pair' => $pair->toArray(),
  85. ];
  86. dispatch(new RegistEventJob(10105, $payload))->onQueue("{push}");
  87. }
  88. /**
  89. * 72小时-匹配结果通知
  90. * @param int $to_uid
  91. * @param int $pair_id
  92. * @return void
  93. */
  94. public function pairResult(int $to_uid, int $pair_id)
  95. {
  96. $title = "72小时-匹配结果通知";
  97. $user = UserModel::find($to_uid);
  98. $pair = PairModel::find($pair_id);
  99. $payload = [
  100. 'to_user' => $user->getAuth(),
  101. 'pair' => $pair->toArray(),
  102. ];
  103. dispatch(new RegistEventJob(10106, $payload))->onQueue("{push}");
  104. // 系统消息
  105. NoticeModel::create([
  106. 'uid' => $to_uid,
  107. 'title' => '匹配结果已公布',
  108. 'content' => "你参与的“72小时恋爱体验”活动第{$pair->stage_id}期,匹配结果已公布,记得要和CP确认关系,这样才会解锁活动群聊。",
  109. 'type' => 5,
  110. 'tab_content' => '查看结果',
  111. 'tab_url' => "/fpdx/pages/matchsuccess/matchsuccess?stage_id={$pair->stage_id}",
  112. ]);
  113. }
  114. /**
  115. * 72小时-重配结果通知
  116. * @param int $to_uid
  117. * @param int $pair_id
  118. * @return void
  119. */
  120. public function rematchResult($to_uid, $pair_id)
  121. {
  122. $title = "72小时-重配结果通知";
  123. $user = UserModel::find($to_uid);
  124. $pair = PairModel::find($pair_id);
  125. $payload = [
  126. 'to_user' => $user->getAuth(),
  127. 'pair' => $pair->toArray(),
  128. ];
  129. dispatch(new RegistEventJob(10107, $payload))->onQueue("{push}");
  130. }
  131. /**
  132. * 72小时活动结束反馈
  133. * @param int $to_uid
  134. * @param int $pair_id
  135. * @return void
  136. */
  137. public function feedback($to_uid, $pair_id)
  138. {
  139. $title = "72小时-活动反馈通知";
  140. $user = UserModel::find($to_uid);
  141. $pair = PairModel::find($pair_id);
  142. $form = FormModel::where('stage_id', $pair->stage_id)->where('activity_type', '72h')->first();
  143. $payload = [
  144. 'to_user' => $user->getAuth(),
  145. 'pair' => $pair->toArray(),
  146. 'form' => $form->toArray(),
  147. ];
  148. dispatch(new RegistEventJob(10108, $payload))->onQueue("{push}");
  149. }
  150. /**
  151. * 72小时-帮助好友助力通知
  152. * @param int $to_user
  153. * @param int $pair_id
  154. * @return void
  155. */
  156. public function helpToScore($to_user, $pair_id)
  157. {
  158. $title = "72小时-帮助好友助力通知";
  159. $user = UserModel::find($to_user);
  160. $pair = PairModel::find($pair_id);
  161. $friend_user = UserModel::find($pair->uid);
  162. $payload = [
  163. 'to_user' => $user->getAuth() ?? [],
  164. 'pair' => $pair->toArray(),
  165. 'friend_user' => $friend_user->toArray(),
  166. ];
  167. dispatch(new RegistEventJob(10109, $payload))->onQueue("{push}");
  168. }
  169. /**
  170. * 72小时-好友助力提高成功率通知
  171. * @param int $to_uid
  172. * @param int $pair_id
  173. */
  174. public function inviteToScore($to_uid, $pair_id)
  175. {
  176. $title = "72小时-好友助力提高成功率通知";
  177. $user = UserModel::find($to_uid);
  178. $pair = PairModel::find($pair_id);
  179. $payload = [
  180. 'to_user' => $user->getAuth(),
  181. 'pair' => $pair->toArray(),
  182. ];
  183. dispatch(new RegistEventJob(10110, $payload))->onQueue("{push}");
  184. }
  185. /**
  186. * 72小时-好友助力成功通知
  187. * @param int $to_uid
  188. * @return void
  189. */
  190. public function inviteToSuccess($to_uid)
  191. {
  192. $title = "72小时-好友助力成功通知";
  193. $user = UserModel::find($to_uid);
  194. $payload = [
  195. 'to_user' => $user->getAuth(),
  196. ];
  197. dispatch(new RegistEventJob(10111, $payload))->onQueue("{push}");
  198. // 系统消息
  199. NoticeModel::create([
  200. 'uid' => $to_uid,
  201. 'title' => '活动报名成功',
  202. 'content' => "你已成功报名活动,活动匹配结果将于下一个周四18:00公布,记得来回来查询匹配结果哦~",
  203. 'type' => 5,
  204. 'type_id' => 0,
  205. ]);
  206. }
  207. /**
  208. * 好友助力退费
  209. * @param int $to_uid
  210. * @param int $pair_id
  211. * @param int $dis_score
  212. * @return void
  213. */
  214. public function inviteToRefund($to_uid, int $pair_id, int $dis_score)
  215. {
  216. $title = "72小时-好友助力退费通知";
  217. $user = UserModel::find($to_uid);
  218. $pair = PairModel::find($pair_id);
  219. $payload = [
  220. 'to_user' => $user->getAuth(),
  221. 'pair' => $pair->toArray(),
  222. 'meta' => [
  223. 'dis_score' => $dis_score,
  224. ],
  225. ];
  226. dispatch(new RegistEventJob(10112, $payload))->onQueue("{push}");
  227. }
  228. }