NoticeService.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. namespace App\Services\Partner;
  3. use App\Models\NoticeModel;
  4. use App\Models\PartnerModel;
  5. use App\Models\User\UserModel;
  6. use App\Models\Log\PartnerCheckNoticeModel;
  7. use PocketBE\MsyPush\Jobs\RegistEventJob;
  8. class NoticeService
  9. {
  10. /**
  11. * 认证成功
  12. * @param int $to_uid
  13. * @return mixed
  14. */
  15. public function authenticationSuccess($to_uid)
  16. {
  17. $title = "交友卡片-身份认证成功";
  18. $user = UserModel::find($to_uid);
  19. $partner = PartnerModel::find($user->partner_id);
  20. $payload = [
  21. 'to_user' => $user->getAuth(),
  22. 'card' => $partner->toArray(),
  23. ];
  24. dispatch(new RegistEventJob(10201, $payload))->onQueue("{push}");
  25. }
  26. /**
  27. * 照片审核成功
  28. * @param int $to_uid
  29. * @return mixed
  30. */
  31. public function checkPartnerSuccess($to_uid)
  32. {
  33. $title = "交友卡片-照片审核成功";
  34. $user = UserModel::find($to_uid);
  35. $partner = PartnerModel::find($user->partner_id);
  36. $payload = [
  37. 'to_user' => $user->getAuth(),
  38. 'card' => $partner->toArray(),
  39. ];
  40. dispatch(new RegistEventJob(10202, $payload))->onQueue("{push}");
  41. }
  42. /**
  43. * 语音审核成功
  44. * @param int $to_uid
  45. * @return mixed
  46. */
  47. public function checkVoiceSuccess($to_uid)
  48. {
  49. $title = "交友卡片-语音审核成功";
  50. $user = UserModel::find($to_uid);
  51. $partner = PartnerModel::find($user->partner_id);
  52. $payload = [
  53. 'to_user' => $user->getAuth(),
  54. 'card' => $partner->toArray(),
  55. ];
  56. dispatch(new RegistEventJob(10203, $payload))->onQueue("{push}");
  57. }
  58. /**
  59. * 卡片审核失败
  60. * @param int $to_uid
  61. * @return mixed
  62. */
  63. public function checkPartnerFail($to_uid)
  64. {
  65. $title = "交友卡片-照片审核失败";
  66. $user = UserModel::find($to_uid);
  67. $partner = PartnerModel::find($user->partner_id);
  68. $payload = [
  69. 'to_user' => $user->getAuth(),
  70. 'card' => $partner->toArray(),
  71. ];
  72. dispatch(new RegistEventJob(10204, $payload))->onQueue("{push}");
  73. }
  74. /**
  75. * 语音审核失败
  76. * @param int $to_uid
  77. * @return void
  78. */
  79. public function checkVoiceFail($to_uid)
  80. {
  81. $user = UserModel::find($to_uid);
  82. $partner = PartnerModel::find($user->partner_id);
  83. $payload = [
  84. 'to_user' => $user->getAuth(),
  85. 'card' => $partner->toArray(),
  86. ];
  87. dispatch(new RegistEventJob(10205, $payload))->onQueue("{push}");
  88. }
  89. /**
  90. * 交友卡片-上架通知
  91. * @param int $to_uid
  92. * @return void
  93. */
  94. public function partnerSell($to_uid)
  95. {
  96. $title = "交友卡片-上架成功";
  97. // 系统通知
  98. NoticeModel::create([
  99. 'uid' => $to_uid,
  100. 'title' => '交友卡片审核通过',
  101. 'content' => "你好,你的交友卡片已审核通过,现在已经将有趣的你推荐到交友大厅了哦~",
  102. 'type' => 5
  103. ]);
  104. $user = UserModel::find($to_uid);
  105. $partner = PartnerModel::find($user->partner_id);
  106. $payload = [
  107. 'to_user' => $user->getAuth(),
  108. 'card' => $partner->toArray(),
  109. ];
  110. dispatch(new RegistEventJob(10206, $payload))->onQueue("{push}");
  111. }
  112. public function partnerCheckLog($uid, $partner_id, $field, $check, $new)
  113. {
  114. $log = PartnerCheckNoticeModel::create([
  115. 'uid' => $uid,
  116. 'partner_id' => $partner_id,
  117. 'field' => $field,
  118. 'check' => $check,
  119. 'new' => $new
  120. ]);
  121. return $log;
  122. }
  123. /**
  124. * 交友卡片-卡片取消推荐通知
  125. * @param int $to_uid
  126. */
  127. public function recommendCancel($to_uid)
  128. {
  129. $title = "交友卡片-卡片取消推荐通知";
  130. NoticeModel::create([
  131. 'uid' => $to_uid,
  132. 'title' => '这样的照片能迅速吸引异性的目光!',
  133. 'content' => "教你如何拍一张精致的照片,上传到你的交友卡片,一定会收到来自异性更多的心动!!",
  134. 'type' => 5,
  135. 'type_id' => 0,
  136. 'tab_content' => '查看教学',
  137. 'tab_url' => "https://mp.weixin.qq.com/s/Jsk1GRiVyE872PWM7XkAFQ",
  138. ]);
  139. $user = UserModel::find($to_uid);
  140. $payload = [
  141. 'to_user' => $user->getAuth(),
  142. 'user' => $user->toArray(),
  143. 'meta' => [
  144. 'number' => rand(1000, 2499),
  145. 'call' => ($user->sex == 2) ? "小哥哥" : "小姐姐",
  146. ]
  147. ];
  148. dispatch(new RegistEventJob(10207, $payload))->onQueue("{push}");
  149. }
  150. public function recommendCancelNotChange($to_uid)
  151. {
  152. $title = "交友卡片-卡片取消推荐未更换通知";
  153. $notification = new \App\Services\Partner\Notifications\RecommendNotChangeNotification($to_uid);
  154. $notification->send();
  155. }
  156. }