NotifyController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\notify\classes\NotifyClass;
  4. use common\components\util;
  5. use Yii;
  6. class NotifyController extends BaseController
  7. {
  8. //通知列表 ssh 20230802
  9. public function actionList()
  10. {
  11. $get = Yii::$app->request->get();
  12. $staffId = $this->shopAdminId;
  13. $where = ['mainId' => $this->mainId, 'staffId' => $staffId];
  14. $read = $get['read'] ?? '';
  15. if (is_numeric($read)) {
  16. $where['read'] = $read;
  17. }
  18. $list = NotifyClass::getNotifyList($where);
  19. util::success($list);
  20. }
  21. //已读操作 ssh 20230802
  22. public function actionRead()
  23. {
  24. $get = Yii::$app->request->get();
  25. $id = $get['id'] ?? 0;
  26. $notify = NotifyClass::getById($id, true);
  27. if (empty($notify)) {
  28. util::fail('没有找到消息');
  29. }
  30. if ($notify->mainId != $this->mainId || $notify->staffId != $this->shopAdminId) {
  31. util::fail('没有权限');
  32. }
  33. $notify->read = 1;
  34. $notify->save();
  35. util::complete();
  36. }
  37. }