shish hace 4 años
padre
commit
6c5ea8f09f

+ 63 - 1
app-ghs/controllers/AuthController.php

@@ -57,6 +57,69 @@ class AuthController extends PublicController
         if (empty($phoneNumber)) {
             util::fail('获取手机号失败..');
         }
+
+        $ptStyle = dict::getDict('ptStyle', 'ghs');
+        $admin = AdminClass::getByCondition(['mobile' => $phoneNumber, 'style' => $ptStyle]);
+        if (empty($admin)) {
+            $adminInfo = [
+                'name' => $phoneNumber,
+                'mobile' => $phoneNumber,
+                'style' => $ptStyle,
+            ];
+            $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
+            $admin = AdminService::replaceAdmin($adminInfo, $fromApp);
+        }
+        $currentShopId = $admin['currentShopId'] ?? 0;
+        $adminId = $admin['id'] ?? 0;
+        //1没有开店 2已申请待审核 3已开店
+        $openShop = $admin['openShop'] ?? 1;
+        if (!empty($currentShopId)) {
+            $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId], true);
+            if (empty($shopAdmin)) {
+                util::fail('没有找到员工哦');
+            }
+            $shopAdmin->lastLogin = date("Y-m-d H:i:s");
+            $shopAdmin->save();
+            $shopAdminId = $shopAdmin->id ?? 0;
+            //是否有切换门店的权限
+            $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin->attributes);
+
+            $admin['avatar'] = imgUtil::getPrefix() . '/retail/default-img.png';
+            $token = jwt::getNewToken($adminId);
+            $showDemo = 1;
+            $remind = getenv('GHS_UPDATE_REMIND') == false ? 0 : getenv('GHS_UPDATE_REMIND');
+            $shop = ShopClass::getById($currentShopId, true);
+            $skCustomId = $shop->skCustomId ?? 0;
+            $apiHost = Yii::$app->params['ghsHost'];
+            $imgUploadApi = $apiHost . '/upload/save-file';
+            //使用手册
+            $cacheKey = 'close_book_' . $shopAdminId;
+            $hasClose = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+            $showBook = !empty($hasClose) ? 0 : 1;
+
+            $cacheKey = 'has_hit_navigate_' . $shopAdminId;
+            $hasHit = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+            $hasHitNavigate = !empty($hasHit) ? 1 : 0;
+
+            //注意这里的输出内容有多个地方一样,要修改需要同步修改,请搜索关键词loginOK!!!!!!!!
+            util::success([
+                'token' => $token,
+                'admin' => $admin,
+                'shopAdminId' => $shopAdminId,
+                'shopId' => $currentShopId,
+                'switchShop' => $switchShop,
+                'openShop' => $openShop,
+                'showDemo' => $showDemo,
+                //有小程序新版本提示更新
+                'update' => $remind,
+                'skCustomId' => $skCustomId,
+                'apiHost' => $apiHost,
+                'imgUploadApi' => $imgUploadApi,
+                'showBook' => $showBook,
+                'hasHitNavigate' => $hasHitNavigate,
+            ]);
+        }
+        util::success(['admin' => $admin]);
     }
 
     //准备授权 ssh 2019.11.19
@@ -269,7 +332,6 @@ class AuthController extends PublicController
         if (!empty($currentShopId)) {
             $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId], true);
             if (empty($shopAdmin)) {
-                Yii::info('没有找到员工哦 adminId:' . $adminId);
                 util::fail('没有找到员工哦');
             }
             $shopAdmin->lastLogin = date("Y-m-d H:i:s");

+ 26 - 8
biz-ghs/admin/classes/AdminClass.php

@@ -5,6 +5,7 @@ namespace bizGhs\admin\classes;
 use bizHd\user\classes\UserClass;
 use bizGhs\shop\classes\ShopAdminClass;
 use biz\shop\classes\ShopClass;
+use common\components\dict;
 use common\components\imgUtil;
 use common\components\sms;
 use common\components\util;
@@ -231,14 +232,25 @@ class AdminClass extends BaseClass
     //创建以及更新用户 ssh 2020.2.7
     public static function replaceAdmin($wxInfo, $source)
     {
-        $wxInfo = self::switchAdminInfo($wxInfo, $source);
-        $unionId = isset($wxInfo['unionId']) && !empty($wxInfo['unionId']) ? $wxInfo['unionId'] : '';
-        $style = Yii::$app->params['ptStyle'];
-        $admin = \biz\admin\classes\AdminClass::getByCondition(['unionId' => $unionId, 'style' => $style]);
-        if (empty($admin)) {
-            $admin = self::generateAdmin($wxInfo);
+        if ($source == dict::getDict('userSourceGetId', 'app', 'id')) {
+            //app来源
+            $mobile = $wxInfo['mobile'] ?? '';
+            $style = $wxInfo['style'] ?? '';
+            $admin = \biz\admin\classes\AdminClass::getByCondition(['mobile' => $mobile, 'style' => $style]);
+            if (empty($admin)) {
+                $admin = self::generateAdmin($wxInfo);
+            }
         } else {
-            $admin = self::updateAdmin($admin, $wxInfo);
+            //非app来源
+            $wxInfo = self::switchAdminInfo($wxInfo, $source);
+            $unionId = isset($wxInfo['unionId']) && !empty($wxInfo['unionId']) ? $wxInfo['unionId'] : '';
+            $style = Yii::$app->params['ptStyle'];
+            $admin = \biz\admin\classes\AdminClass::getByCondition(['unionId' => $unionId, 'style' => $style]);
+            if (empty($admin)) {
+                $admin = self::generateAdmin($wxInfo);
+            } else {
+                $admin = self::updateAdmin($admin, $wxInfo);
+            }
         }
         return $admin;
     }
@@ -301,6 +313,11 @@ class AdminClass extends BaseClass
         $time = time();
         //替换掉微信名称不支持的图片
         $nickName = isset($getAdminInfo['nickName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getAdminInfo['nickName']) : '';
+        if (empty($nickName)) {
+            if (isset($getAdminInfo['mobile']) && !empty($getAdminInfo['mobile'])) {
+                $nickName = $getAdminInfo['mobile'];
+            }
+        }
         $getAdminInfo['name'] = $nickName;
         $subscribe = isset($getAdminInfo['subscribe']) ? $getAdminInfo['subscribe'] : 0;
         $getAdminInfo['subscribe'] = $subscribe;
@@ -316,7 +333,8 @@ class AdminClass extends BaseClass
         $getAdminInfo['openShop'] = $getAdminInfo['openShop'] ?? \biz\admin\classes\AdminClass::OPEN_SHOP_NO;
         $getAdminInfo['super'] = $getAdminInfo['super'] ?? \biz\admin\classes\AdminClass::SUPER_NO;
         $getAdminInfo['delStatus'] = 0;
-        $getAdminInfo['style'] = Yii::$app->params['ptStyle'];
+        $style = $getAdminInfo['style'] ? $getAdminInfo['style'] : Yii::$app->params['ptStyle'];
+        $getAdminInfo['style'] = $style;
         $getAdminInfo['openShop'] = 1;
 
         if (isset($getAdminInfo['headImgUrl']) && !empty($getAdminInfo['headImgUrl'])) {

+ 2 - 0
common/components/dict.php

@@ -214,11 +214,13 @@ class dict
             0 => 'official',
             1 => 'alipay',
             2 => 'mini',
+            3 => 'app',
         ],
         'userSourceGetId' => [
             'official' => ['id' => 0, 'name' => 'official'],
             'alipay' => ['id' => 1, 'name' => 'alipay'],
             'mini' => ['id' => 2, 'name' => 'mini'],
+            'app' => ['id' => 3, 'name' => 'app'],
         ],
 
         //达达取消原因