浏览代码

base admin 对象化

shish 5 年之前
父节点
当前提交
3f6d2759f5

+ 4 - 4
app-ghs/controllers/AdminController.php

@@ -74,7 +74,7 @@ class AdminController extends BaseController
         if ($new != $confirm) {
             util::fail('二次密码不一致');
         }
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $adminId = $this->adminId;
         if (!empty($admin['password'])) {
             if (empty($old)) {
@@ -101,7 +101,7 @@ class AdminController extends BaseController
         if ($new != $confirm) {
             util::fail('二次密码不一致');
         }
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $adminId = $this->adminId;
         if (!empty($admin['payPassword'])) {
             if (empty($old)) {
@@ -130,7 +130,7 @@ class AdminController extends BaseController
         $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
         $merchant = WxOpenClass::getGhsWxInfo();
         $appId = $merchant['miniAppId'];
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $miniOpenId = $admin['miniOpenId'];
         if (empty($miniOpenId)) {
             util::fail('没有找到管理员信息(miniOpenId)');
@@ -163,7 +163,7 @@ class AdminController extends BaseController
         $encryptedData = $post['encryptedData'];
         $merchant = WxOpenClass::getGhsWxInfo();
         $appId = $merchant['miniAppId'];
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $miniOpenId = $admin['miniOpenId'];
         if (empty($miniOpenId)) {
             util::fail('没有找到管理员信息(miniOpenId)');

+ 1 - 1
app-ghs/controllers/ApplyController.php

@@ -33,7 +33,7 @@ class ApplyController extends BaseController
     {
         $post = Yii::$app->request->post();
         $post['adminId'] = $this->adminId;
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         if (isset($admin['currentShopId']) && !empty($admin['currentShopId'])) {
             util::fail('您已经是门店员工');
         }

+ 3 - 3
app-ghs/controllers/BaseController.php

@@ -37,18 +37,18 @@ class BaseController extends PublicController
             util::notLogin();
         }
         $this->adminId = $adminId;
-        $admin = AdminService::getById($adminId);
+        $admin = AdminService::getById($adminId, true);
         if (empty($admin)) {
             util::logout('帐号无效');
         }
         $this->admin = $admin;
         // 只能供货商访问
-        if ($admin['style'] != AdminClass::STYLE_GHS) {
+        if ($admin->style != AdminClass::STYLE_GHS) {
             util::fail('您没有权限访问哦!');
         }
 
         //后台
-        $currentShopId = $admin['currentShopId'] ?? 0;
+        $currentShopId = $admin->currentShopId ?? 0;
         if (empty($currentShopId)) {
             if (in_array($action->id, $this->guestAccess) == false) {
                 util::fail('您没有权限访问哦!');

+ 5 - 1
app-ghs/controllers/ExpressController.php

@@ -44,7 +44,11 @@ class ExpressController extends BaseController
 
         $shop_order_id = time();
         $shop_no = ""; //与快递签约时的门店ID(应该是固定的)
-        $openid = $this->admin['miniOpenId'];
+
+        $openid = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
+        if (empty($openId)) {
+            util::fail('没有找到openId');
+        }
 
         //客户id
         $customId = $post['customId'] ?? 0;

+ 4 - 1
app-ghs/controllers/OrderController.php

@@ -176,7 +176,10 @@ class OrderController extends BaseController
         $totalFee = $order['actPrice'];
 
         //强制使用小程序的miniOpenId
-        $openId = $this->admin['miniOpenId'];
+        $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
+        if (empty($openId)) {
+            util::fail('没有找到openId');
+        }
 
         $capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
         //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调

+ 5 - 1
app-ghs/controllers/RechargeController.php

@@ -47,7 +47,11 @@ class RechargeController extends BaseController
         $name = $order->orderName ?? '充值';
         $totalFee = $order->amount;
         //强制使用小程序的miniOpenId
-        $openId = $this->admin['miniOpenId'];
+        $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
+        if (empty($openId)) {
+            util::fail('没有找到openId');
+        }
+
         $capitalType = dict::getDict('capitalType', 'xhRecharge', 'id');
         //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
         $wxPayType = httpUtil::isMiniProgram() ? 1 : 0;

+ 1 - 1
app-ghs/controllers/RenewController.php

@@ -55,7 +55,7 @@ class RenewController extends BaseController
         $couponId = 0;
         $name = $set->name . '开通及续费';
         $totalFee = $actPrice;
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         //小程序使用miniOpenId
         $openId = $admin['miniOpenId'];
 

+ 1 - 1
app-ghs/controllers/ShopAdminController.php

@@ -49,7 +49,7 @@ class ShopAdminController extends BaseController
     {
         $post = Yii::$app->request->post();
         $post['adminId'] = $this->adminId;
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $currentShopId = $admin['currentShopId'] ?? 0;
         if (!empty($currentShopId)) {
             $shop = ShopClass::getShopInfo($currentShopId);

+ 5 - 6
app-hd/controllers/AdminController.php

@@ -18,8 +18,7 @@ class AdminController extends BaseController
     //最近店铺 ssh 2021.2.27
     public function actionRecentShop()
     {
-        $respond = AdminClass::getRecentShop($this->admin);
-        util::success($respond);
+        util::success([]);
     }
 
     //获取登陆员工的权限 ssh 2019.11.24
@@ -84,7 +83,7 @@ class AdminController extends BaseController
         if ($new != $confirm) {
             util::fail('二次密码不一致');
         }
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $adminId = $this->adminId;
         if (!empty($admin['password'])) {
             if (empty($old)) {
@@ -111,7 +110,7 @@ class AdminController extends BaseController
         if ($new != $confirm) {
             util::fail('二次密码不一致');
         }
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $adminId = $this->adminId;
         if (!empty($admin['payPassword'])) {
             if (empty($old)) {
@@ -141,7 +140,7 @@ class AdminController extends BaseController
         $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
         $merchant = WxOpenService::getWxInfo();
         $appId = $merchant['miniAppId'];
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $miniOpenId = $admin['miniOpenId'];
         if (empty($miniOpenId)) {
             util::fail('没有找到管理员信息(miniOpenId)');
@@ -174,7 +173,7 @@ class AdminController extends BaseController
         $encryptedData = $post['encryptedData'];
         $merchant = WxOpenService::getWxInfo();
         $appId = $merchant['miniAppId'];
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $miniOpenId = $admin['miniOpenId'];
         if (empty($miniOpenId)) {
             util::fail('没有找到管理员信息(miniOpenId)');

+ 1 - 1
app-hd/controllers/ApplyController.php

@@ -35,7 +35,7 @@ class ApplyController extends BaseController
     {
         $post = Yii::$app->request->post();
         $post['adminId'] = $this->adminId;
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         if (isset($admin['currentShopId']) && !empty($admin['currentShopId'])) {
             util::fail('您已经是门店员工');
         }

+ 4 - 4
app-hd/controllers/BaseController.php

@@ -38,19 +38,19 @@ class BaseController extends PublicController
         if (empty($adminId)) {
             util::notLogin();
         }
-        $admin = AdminClass::getAdminById($adminId);
+        $admin = AdminClass::getById($adminId, true);
         if (empty($admin)) {
             util::notLogin();
         }
-        $adminId = $admin['id'];
+        $adminId = $admin->id;
         $this->admin = $admin;
         $this->adminId = $adminId;
         // 只能供货商访问
-        if ($admin['style'] != ClassesAdminClass::STYLE_HD) {
+        if ($admin->style != ClassesAdminClass::STYLE_HD) {
             util::fail('您没有权限访问哦!');
         }
         //后台
-        $currentShopId = $admin['currentShopId'] ?? 0;
+        $currentShopId = $admin->currentShopId ?? 0;
         if (empty($currentShopId)) {
             if (in_array($action->id, $this->guestAccess) == false) {
                 util::fail('您不是员工没有权限访问');

+ 4 - 1
app-hd/controllers/PurchaseClearController.php

@@ -59,7 +59,10 @@ class PurchaseClearController extends BaseController
         $name = '采购单结算';
         $totalFee = $order->actPrice;
         //强制使用小程序的miniOpenId
-        $openId = $this->admin['miniOpenId'];
+        $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
+        if (empty($openId)) {
+            util::fail('没有openId');
+        }
         $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
         //小程序支付
         $wxPayType = 1;

+ 4 - 2
app-hd/controllers/PurchaseController.php

@@ -193,8 +193,10 @@ class PurchaseController extends BaseController
         $totalFee = $order->actPrice;
 
         //强制使用小程序的miniOpenId
-        $openId = $this->admin['miniOpenId'];
-
+        $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
+        if (empty($openId)) {
+            util::fail('没有openId');
+        }
         $purchaseCapital = dict::getDict('capitalType', 'xhPurchase', 'id');
         //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
         $wxPayType = 0;

+ 8 - 3
app-hd/controllers/RechargeController.php

@@ -71,8 +71,10 @@ class RechargeController extends BaseController
         $totalFee = $order->amount;
 
         //强制使用小程序的miniOpenId
-        $openId = $this->admin['miniOpenId'];
-
+        $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
+        if (empty($openId)) {
+            util::fail('没有找到openId');
+        }
         $capitalType = dict::getDict('capitalType', 'xhRecharge', 'id');
         //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
         $wxPayType = 1;
@@ -137,7 +139,10 @@ class RechargeController extends BaseController
         $totalFee = $order->amount;
 
         //强制使用小程序的miniOpenId
-        $openId = $this->admin['miniOpenId'];
+        $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
+        if (empty($openId)) {
+            util::fail('没有找到openId');
+        }
 
         $capitalType = dict::getDict('capitalType', 'xhRecharge', 'id');
         //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调

+ 1 - 1
app-hd/controllers/RenewController.php

@@ -55,7 +55,7 @@ class RenewController extends BaseController
         $couponId = 0;
         $name = $set->name . '开通及续费';
         $totalFee = $actPrice;
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         //小程序使用miniOpenId
         $openId = $admin['miniOpenId'];
 

+ 1 - 1
app-hd/controllers/ShopAdminController.php

@@ -48,7 +48,7 @@ class ShopAdminController extends BaseController
     {
         $post = Yii::$app->request->post();
         $post['adminId'] = $this->adminId;
-        $admin = $this->admin;
+        $admin = $this->admin->attributes;
         $currentShopId = $admin['currentShopId'] ?? 0;
         if (!empty($currentShopId)) {
             $shop = ShopClass::getShopInfo($currentShopId);