NoticeService.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. namespace App\Services\Goodnight;
  3. use App\Models\Goodnight\SubscribeModel;
  4. use App\Models\Goodnight\VoiceModel;
  5. use App\Models\User\UserModel;
  6. use App\Services\Service;
  7. use PocketBE\MsyPush\Jobs\RegistEventJob;
  8. class NoticeService extends Service
  9. {
  10. /**
  11. * 定制晚安(每日提醒)
  12. * @param int $to_uid
  13. * @param int $from_uid
  14. * @param int $voice_id
  15. * @return bool
  16. * @throws \App\Exceptions\AlertException
  17. * @throws \App\Exceptions\ApiException
  18. */
  19. public function subscribe(int $to_uid, int $from_uid, int $voice_id)
  20. {
  21. $user = UserModel::find($to_uid);
  22. $from_user = UserModel::find($from_uid);
  23. $voice = VoiceModel::find($voice_id);
  24. $subscribe_count = SubscribeModel::where('uid', $to_uid)->where('type', 0)->count();
  25. $payload = [
  26. 'to_user' => $user->getAuth(),
  27. 'from_user' => $from_user->toArray(),
  28. 'voice' => $voice->toArray(),
  29. 'meta' => [
  30. 'subscribe_count' => $subscribe_count,
  31. 'date' => date('Y-m-d'),
  32. ],
  33. ];
  34. dispatch(new RegistEventJob(10401, $payload))->onQueue("{push}");
  35. }
  36. /**
  37. * 公域语音审核(审核通过)
  38. * @param int $to_uid
  39. * @param int $voice_id
  40. * @return bool
  41. */
  42. public function checkSuccess(int $to_uid, int $voice_id)
  43. {
  44. $user = UserModel::find($to_uid);
  45. $voice = VoiceModel::find($voice_id);
  46. $payload = [
  47. 'to_user' => $user->getAuth(),
  48. 'voice' => $voice->toArray(),
  49. 'meta' => [
  50. 'date' => date('Y-m-d'),
  51. ],
  52. ];
  53. dispatch(new RegistEventJob(10402, $payload))->onQueue("{push}");
  54. }
  55. /**
  56. * 公域语音审核(审核失败)
  57. * @param int $to_uid
  58. * @param int $voice_id
  59. * @return bool
  60. */
  61. public function checkFail(int $to_uid, int $voice_id)
  62. {
  63. $user = UserModel::find($to_uid);
  64. $voice = VoiceModel::find($voice_id);
  65. $payload = [
  66. 'to_user' => $user->getAuth(),
  67. 'voice' => $voice->toArray(),
  68. 'meta' => [
  69. 'date' => date('Y-m-d'),
  70. ],
  71. ];
  72. dispatch(new RegistEventJob(10403, $payload))->onQueue("{push}");
  73. }
  74. /**
  75. * 晚安伴侣匹配成功
  76. * @param int $to_uid
  77. * @param int $match_uid
  78. */
  79. public function matchSuccess(int $to_uid, $match_uid)
  80. {
  81. $user = UserModel::find($to_uid);
  82. $match_user = UserModel::find($match_uid);
  83. $payload = [
  84. 'to_user' => $user->getAuth(),
  85. 'match_user' => $match_user->toArray(),
  86. 'meta' => [
  87. 'date' => date('Y-m-d'),
  88. ],
  89. ];
  90. dispatch(new RegistEventJob(10404, $payload))->onQueue("{push}");
  91. }
  92. /**
  93. * 晚安伴侣匹配失败
  94. * @param int $to_uid 要发送的人的uid
  95. * @return bool
  96. * @throws \Exception
  97. */
  98. public function matchFail(int $to_uid)
  99. {
  100. $user = UserModel::find($to_uid);
  101. $payload = [
  102. 'to_user' => $user->getAuth(),
  103. 'meta' => [
  104. 'date' => date('Y-m-d'),
  105. ],
  106. ];
  107. dispatch(new RegistEventJob(10405, $payload))->onQueue("{push}");
  108. }
  109. /**
  110. * 晚安伴侣留言
  111. * @param int $from_uid 来自uid
  112. * @param int $to_uid 发送uid
  113. * @return bool
  114. */
  115. public function receiveRoomComment(int $to_uid, int $from_uid)
  116. {
  117. $user = UserModel::find($to_uid);
  118. $from_user = UserModel::find($from_uid);
  119. $payload = [
  120. 'to_user' => $user->getAuth(),
  121. 'from_user' => $from_user->toArray(),
  122. 'meta' => [
  123. 'date' => date('Y-m-d'),
  124. ],
  125. ];
  126. dispatch(new RegistEventJob(10406, $payload))->onQueue("{push}");
  127. }
  128. /**
  129. * 语音卡片留言
  130. * @param int $to_uid 要发送的人的uid
  131. * @param int $voice_id 被留言的语音
  132. * @param int $from_uid
  133. * @return bool
  134. * @throws \App\Exceptions\AlertException
  135. * @throws \App\Exceptions\ApiException
  136. */
  137. public function voiceComment(int $to_uid, int $from_uid, int $voice_id)
  138. {
  139. $user = UserModel::find($to_uid);
  140. $from_user = UserModel::find($from_uid);
  141. $voice = VoiceModel::find($voice_id);
  142. $payload = [
  143. 'to_user' => $user->getAuth(),
  144. 'from_user' => $from_user->toArray(),
  145. 'voice' => $voice->toArray(),
  146. 'meta' => [
  147. 'date' => date('Y-m-d'),
  148. ],
  149. ];
  150. dispatch(new RegistEventJob(10407, $payload))->onQueue("{push}");
  151. }
  152. /**
  153. * 漂流瓶留言回复提醒
  154. * @param int $to_uid 要发送的人的uid
  155. * @param int $voice_id 被回复的语音
  156. * @param string $content 回复内容
  157. * @return bool
  158. */
  159. public function receiveCommentReply(int $to_uid, int $voice_id, $auther, string $content = "")
  160. {
  161. $user = UserModel::find($to_uid);
  162. $from_user = UserModel::find($auther);
  163. $voice = VoiceModel::find($voice_id);
  164. $payload = [
  165. 'to_user' => $user->getAuth(),
  166. 'from_user' => $from_user->toArray(),
  167. 'voice' => $voice->toArray(),
  168. 'meta' => [
  169. 'date' => date('Y-m-d'),
  170. ],
  171. ];
  172. dispatch(new RegistEventJob(10408, $payload))->onQueue("{push}");
  173. }
  174. }