|
|
@@ -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");
|