123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?php
- namespace App\Services\Goodnight;
- use App\Models\Goodnight\SubscribeModel;
- use App\Models\Goodnight\VoiceModel;
- use App\Models\User\UserModel;
- use App\Services\Service;
- use PocketBE\MsyPush\Jobs\RegistEventJob;
- class NoticeService extends Service
- {
- /**
- * 定制晚安(每日提醒)
- * @param int $to_uid
- * @param int $from_uid
- * @param int $voice_id
- * @return bool
- * @throws \App\Exceptions\AlertException
- * @throws \App\Exceptions\ApiException
- */
- public function subscribe(int $to_uid, int $from_uid, int $voice_id)
- {
- $user = UserModel::find($to_uid);
- $from_user = UserModel::find($from_uid);
- $voice = VoiceModel::find($voice_id);
- $subscribe_count = SubscribeModel::where('uid', $to_uid)->where('type', 0)->count();
- $payload = [
- 'to_user' => $user->getAuth(),
- 'from_user' => $from_user->toArray(),
- 'voice' => $voice->toArray(),
- 'meta' => [
- 'subscribe_count' => $subscribe_count,
- 'date' => date('Y-m-d'),
- ],
- ];
- dispatch(new RegistEventJob(10401, $payload))->onQueue("{push}");
- }
- /**
- * 公域语音审核(审核通过)
- * @param int $to_uid
- * @param int $voice_id
- * @return bool
- */
- public function checkSuccess(int $to_uid, int $voice_id)
- {
- $user = UserModel::find($to_uid);
- $voice = VoiceModel::find($voice_id);
- $payload = [
- 'to_user' => $user->getAuth(),
- 'voice' => $voice->toArray(),
- 'meta' => [
- 'date' => date('Y-m-d'),
- ],
- ];
- dispatch(new RegistEventJob(10402, $payload))->onQueue("{push}");
- }
- /**
- * 公域语音审核(审核失败)
- * @param int $to_uid
- * @param int $voice_id
- * @return bool
- */
- public function checkFail(int $to_uid, int $voice_id)
- {
- $user = UserModel::find($to_uid);
- $voice = VoiceModel::find($voice_id);
- $payload = [
- 'to_user' => $user->getAuth(),
- 'voice' => $voice->toArray(),
- 'meta' => [
- 'date' => date('Y-m-d'),
- ],
- ];
- dispatch(new RegistEventJob(10403, $payload))->onQueue("{push}");
- }
- /**
- * 晚安伴侣匹配成功
- * @param int $to_uid
- * @param int $match_uid
- */
- public function matchSuccess(int $to_uid, $match_uid)
- {
- $user = UserModel::find($to_uid);
- $match_user = UserModel::find($match_uid);
- $payload = [
- 'to_user' => $user->getAuth(),
- 'match_user' => $match_user->toArray(),
- 'meta' => [
- 'date' => date('Y-m-d'),
- ],
- ];
- dispatch(new RegistEventJob(10404, $payload))->onQueue("{push}");
- }
- /**
- * 晚安伴侣匹配失败
- * @param int $to_uid 要发送的人的uid
- * @return bool
- * @throws \Exception
- */
- public function matchFail(int $to_uid)
- {
- $user = UserModel::find($to_uid);
- $payload = [
- 'to_user' => $user->getAuth(),
- 'meta' => [
- 'date' => date('Y-m-d'),
- ],
- ];
- dispatch(new RegistEventJob(10405, $payload))->onQueue("{push}");
- }
- /**
- * 晚安伴侣留言
- * @param int $from_uid 来自uid
- * @param int $to_uid 发送uid
- * @return bool
- */
- public function receiveRoomComment(int $to_uid, int $from_uid)
- {
- $user = UserModel::find($to_uid);
- $from_user = UserModel::find($from_uid);
- $payload = [
- 'to_user' => $user->getAuth(),
- 'from_user' => $from_user->toArray(),
- 'meta' => [
- 'date' => date('Y-m-d'),
- ],
- ];
- dispatch(new RegistEventJob(10406, $payload))->onQueue("{push}");
- }
- /**
- * 语音卡片留言
- * @param int $to_uid 要发送的人的uid
- * @param int $voice_id 被留言的语音
- * @param int $from_uid
- * @return bool
- * @throws \App\Exceptions\AlertException
- * @throws \App\Exceptions\ApiException
- */
- public function voiceComment(int $to_uid, int $from_uid, int $voice_id)
- {
- $user = UserModel::find($to_uid);
- $from_user = UserModel::find($from_uid);
- $voice = VoiceModel::find($voice_id);
- $payload = [
- 'to_user' => $user->getAuth(),
- 'from_user' => $from_user->toArray(),
- 'voice' => $voice->toArray(),
- 'meta' => [
- 'date' => date('Y-m-d'),
- ],
- ];
- dispatch(new RegistEventJob(10407, $payload))->onQueue("{push}");
- }
- /**
- * 漂流瓶留言回复提醒
- * @param int $to_uid 要发送的人的uid
- * @param int $voice_id 被回复的语音
- * @param string $content 回复内容
- * @return bool
- */
- public function receiveCommentReply(int $to_uid, int $voice_id, $auther, string $content = "")
- {
- $user = UserModel::find($to_uid);
- $from_user = UserModel::find($auther);
- $voice = VoiceModel::find($voice_id);
- $payload = [
- 'to_user' => $user->getAuth(),
- 'from_user' => $from_user->toArray(),
- 'voice' => $voice->toArray(),
- 'meta' => [
- 'date' => date('Y-m-d'),
- ],
- ];
- dispatch(new RegistEventJob(10408, $payload))->onQueue("{push}");
- }
- }
|