Ver código fonte

更新openId

shish 3 anos atrás
pai
commit
907c4f4e28
1 arquivos alterados com 24 adições e 0 exclusões
  1. 24 0
      app-pt/controllers/AdminController.php

+ 24 - 0
app-pt/controllers/AdminController.php

@@ -2,14 +2,38 @@
 
 namespace pt\controllers;
 
+use biz\admin\classes\AdminClass;
 use common\components\util;
 use Yii;
 
 class AdminController extends BaseController
 {
 
+    //更新openId ssh 20230501
     public function actionUpdateOpenId()
     {
+        $post = Yii::$app->request->post();
+        $adminId = $post['adminId'] ?? 0;
+        $admin = AdminClass::getById($adminId, true);
+        if (empty($admin)) {
+            util::fail('没有找到管理员信息');
+        }
+        $openId = $post['openId'] ?? '';
+        if (empty($openId)) {
+            util::fail('openId信息为空');
+        }
+        $ptStyle = $post['ptStyle'] ?? 0;
+        if (in_array($ptStyle, [1, 2]) == false) {
+            util::fail('参数错误');
+        }
+        if ($ptStyle == 1) {
+            $admin->openId = $openId;
+            $admin->save();
+        }
+        if ($ptStyle == 2) {
+            $admin->ghsOpenId = $openId;
+            $admin->save();
+        }
         util::complete();
     }