Jelajahi Sumber

新增 通知

shish 3 tahun lalu
induk
melakukan
49ea00978d

+ 43 - 0
app-ghs/controllers/NotifyController.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace ghs\controllers;
+
+use bizGhs\notify\classes\NotifyClass;
+use common\components\util;
+use Yii;
+
+class NotifyController extends BaseController
+{
+
+    //通知列表 ssh 20230802
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $staffId = $this->shopAdminId;
+        $where = ['mainId' => $this->mainId, 'staffId' => $staffId];
+        $read = $get['read'] ?? '';
+        if (is_numeric($read)) {
+            $where['read'] = $read;
+        }
+        $list = NotifyClass::getNotifyList($where);
+        util::success($list);
+    }
+
+    //已读操作 ssh 20230802
+    public function actionRead()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $notify = NotifyClass::getById($id, true);
+        if (empty($notify)) {
+            util::fail('没有找到消息');
+        }
+        if ($notify->mainId != $this->mainId || $notify->staffId != $this->shopAdminId) {
+            util::fail('没有权限');
+        }
+        $notify->read = 1;
+        $notify->save();
+        util::complete();
+    }
+
+}

+ 19 - 0
biz-ghs/notify/classes/NotifyClass.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace bizGhs\notify\classes;
+
+use bizGhs\base\classes\BaseClass;
+use Yii;
+
+class NotifyClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\notify\models\Notify';
+
+    public static function getNotifyList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC');
+        return $data;
+    }
+
+}

+ 13 - 0
biz-ghs/notify/models/Notify.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizGhs\notify\models;
+use bizGhs\base\models\Base;
+
+class Notify extends Base
+{
+
+	public static function tableName()
+	{
+		return 'xhGhsNotify';
+	}
+
+}

+ 13 - 0
biz-ghs/notify/services/NotifyService.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace bizGhs\notify\services;
+
+use bizGhs\base\services\BaseService;
+use Yii;
+
+class NotifyService extends BaseService
+{
+
+    public static $baseFile = '\bizGhs\notify\classes\NotifyClass';
+
+}