NotifyController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\notify\classes\NotifyClass;
  4. use bizGhs\shop\classes\ShopAdminClass;
  5. use common\components\util;
  6. use Yii;
  7. class NotifyController extends BaseController
  8. {
  9. //全部设置为已读 ssh 20230802
  10. public function actionAllRead()
  11. {
  12. NotifyClass::updateByCondition(['mainId' => $this->mainId, 'staffId' => $this->shopAdminId], ['read' => 1]);
  13. $staffId = $this->shopAdminId;
  14. ShopAdminClass::updateById($staffId, ['notifyNum' => 0]);
  15. util::complete('操作成功');
  16. }
  17. //单个设置为已读 ssh 20231224
  18. public function actionSetRead()
  19. {
  20. $get = Yii::$app->request->get();
  21. $id = $get['id'] ?? 0;
  22. $notify = NotifyClass::getById($id, true);
  23. if (empty($notify)) {
  24. util::fail('没有找到通知');
  25. }
  26. $staffId = $this->shopAdminId;
  27. if ($notify->staffId != $staffId) {
  28. util::fail('不是你的通知哦');
  29. }
  30. $notify->read = 1;
  31. $notify->save();
  32. util::complete('操作成功');
  33. }
  34. //通知列表 ssh 20230802
  35. public function actionList()
  36. {
  37. $get = Yii::$app->request->get();
  38. $staffId = $this->shopAdminId;
  39. $where = ['mainId' => $this->mainId, 'staffId' => $staffId];
  40. $read = $get['read'] ?? '';
  41. if (is_numeric($read)) {
  42. $where['read'] = $read;
  43. }
  44. $list = NotifyClass::getNotifyList($where);
  45. util::success($list);
  46. }
  47. }