NotifyController.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 actionAllRead()
  10. {
  11. NotifyClass::updateByCondition(['mainId' => $this->mainId, 'staffId' => $this->shopAdminId], ['read' => 1]);
  12. util::complete('操作成功');
  13. }
  14. //通知列表 ssh 20230802
  15. public function actionList()
  16. {
  17. $get = Yii::$app->request->get();
  18. $staffId = $this->shopAdminId;
  19. $where = ['mainId' => $this->mainId, 'staffId' => $staffId];
  20. $read = $get['read'] ?? '';
  21. if (is_numeric($read)) {
  22. $where['read'] = $read;
  23. }
  24. $list = NotifyClass::getNotifyList($where);
  25. util::success($list);
  26. }
  27. //已读操作 ssh 20230802
  28. public function actionRead()
  29. {
  30. $get = Yii::$app->request->get();
  31. $id = $get['id'] ?? 0;
  32. $notify = NotifyClass::getById($id, true);
  33. if (empty($notify)) {
  34. util::fail('没有找到消息');
  35. }
  36. if ($notify->mainId != $this->mainId || $notify->staffId != $this->shopAdminId) {
  37. util::fail('没有权限');
  38. }
  39. $notify->read = 1;
  40. $notify->save();
  41. util::complete();
  42. }
  43. }