diff --git a/server/app/common/queue/redis/AdminAnnouncementPushConsumer.php b/server/app/common/queue/redis/AdminAnnouncementPushConsumer.php index ab905c12e91d33ec9aeac2f646c161ded59ea175..ecc903a2e18dfc16caae1aecb4ca9c5a0c6aa69f 100644 --- a/server/app/common/queue/redis/AdminAnnouncementPushConsumer.php +++ b/server/app/common/queue/redis/AdminAnnouncementPushConsumer.php @@ -144,8 +144,13 @@ class AdminAnnouncementPushConsumer implements Consumer // 如果有UUID,则排除已推送的用户 if (!empty($uuid)) { - $query->whereDoesntHave('message', function ($q) use ($uuid) { - $q->where('message_uuid', $uuid); + $query->where(function ($q) use ($uuid) { + $q->whereDoesntHave('message', function ($subQuery) use ($uuid) { + $subQuery->where('message_uuid', $uuid); + }) + ->orWhereHas('message', function ($subQuery) { + $subQuery->whereNull('message_uuid'); + }); }); } diff --git a/server/app/common/services/system/SysNoticeService.php b/server/app/common/services/system/SysNoticeService.php index eb553013b2e6de4da6109f321cb0a4a4e473815a..2479ba6c7d9c578f2e07adb5fb1c63101143be9f 100644 --- a/server/app/common/services/system/SysNoticeService.php +++ b/server/app/common/services/system/SysNoticeService.php @@ -13,12 +13,13 @@ namespace app\common\services\system; use app\common\dao\system\SysNoticeDao; +use app\common\model\system\SysNotice; use core\abstract\BaseService; +use core\exception\handler\AdminException; +use core\uuid\UUIDGenerator; use support\Container; -/** - * @method save(array $data) - */ + class SysNoticeService extends BaseService { @@ -27,4 +28,46 @@ class SysNoticeService extends BaseService $this->dao = Container::make(SysNoticeDao::class); } + /** + * 保存 + * + * @param array $data + * + * @return \app\common\model\system\SysNotice|null + * @throws \core\exception\handler\AdminException + */ + public function save(array $data): ?SysNotice + { + try { + return $this->transaction(function () use ($data) { + $data['uuid'] = UUIDGenerator::generate(); + return $this->dao->save($data); + }); + } catch (\Throwable $e) { + throw new AdminException($e->getMessage()); + } + } + + /** + * 更新 + * + * @param string|int $id + * @param array $data + * + * @throws \core\exception\handler\AdminException + */ + public function update(string|int $id, array $data): void + { + try { + $this->transaction(function () use ($id, $data) { + $data['uuid'] = UUIDGenerator::generate();//更新之后变更uuid 再次推送重新发起 + $model = $this->dao->get($id); + $model->fill($data); + $model->save(); + }); + } catch (\Throwable $e) { + throw new AdminException($e->getMessage()); + } + } + }