Explorar el Código

注册流程优化

shish hace 4 años
padre
commit
bcc78c7b48
Se han modificado 1 ficheros con 29 adiciones y 3 borrados
  1. 29 3
      app-hd/controllers/ApplyController.php

+ 29 - 3
app-hd/controllers/ApplyController.php

@@ -2,12 +2,14 @@
 
 namespace hd\controllers;
 
+use biz\shop\services\ShopAdminService;
 use biz\sj\classes\SjClass;
 use bizGhs\admin\services\AdminService;
 use bizHd\saas\services\ApplyService;
 use bizHd\wx\classes\WxOpenClass;
 use common\components\dict;
 use common\components\imgUtil;
+use common\components\jwt;
 use common\components\miniUtil;
 use common\components\noticeUtil;
 use common\components\sms;
@@ -150,20 +152,44 @@ class ApplyController extends BaseController
             $respond = ApplyService::replaceRetail($post);
 
             $id = $respond['id'] ?? 0;
-            if (!empty($id)) {
-                ApplyService::pass($id);
+            if (empty($id)) {
+                util::fail('申请失败');
             }
+            $passInfo = ApplyService::pass($id);
             $transaction->commit();
 
             $mobile = $post['mobile'] ?? '';
             noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 注册", '15280215347');
 
+            //输出登录信息
+            $newShop = $passInfo['shop'] ?? [];
+            $newShopId = $newShop->id ?? 0;
+            $adminId = $admin['id'];
+            $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'shopId' => $newShopId, 'delStatus' => 0], true);
+            $shopAdmin->lastLogin = date("Y-m-d H:i:s");
+            $shopAdmin->save();
+            $shopAdminId = $shopAdmin->id ?? 0;
+            //是否有切换门店的权限
+            $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin->attributes);
+            $showDemo = 1;
+            $token = jwt::getNewToken($adminId);
+            $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
+            //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
+            util::success([
+                'token' => $token,
+                'admin' => $admin,
+                'shopId' => $currentShopId,
+                'shopAdminId' => $shopAdminId,
+                'switchShop' => $switchShop,
+                'showDemo' => $showDemo,
+                //有小程序新版本提示更新
+                'update' => $remind,
+            ]);
         } catch (\Exception $exception) {
             $transaction->rollBack();
             Yii::info("申请报错:" . $exception->getMessage());
             util::fail('提交失败');
         }
-        util::complete();
     }
 
     //申请状态