shish пре 3 година
родитељ
комит
5628458013
1 измењених фајлова са 104 додато и 5 уклоњено
  1. 104 5
      app-hd/controllers/LjhController.php

+ 104 - 5
app-hd/controllers/LjhController.php

@@ -6,6 +6,7 @@ use biz\shop\services\ShopAdminService;
 use biz\sj\classes\SjClass;
 use bizHd\saas\classes\ApplyClass;
 use bizHd\ljh\classes\LjhApplyClass;
+use bizHd\shop\classes\ShopClass;
 use common\components\dict;
 use common\components\httpUtil;
 use common\components\jwt;
@@ -28,14 +29,12 @@ class LjhController extends BaseController
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
         $info = LjhApplyClass::getById($id, true);
+        if (empty($info)) {
+            util::fail('没有信息');
+        }
         util::success($info);
     }
 
-    public function actionNew()
-    {
-
-    }
-
     public function actionApply()
     {
         $connection = Yii::$app->db;
@@ -161,4 +160,104 @@ class LjhController extends BaseController
         util::success($newParams);
     }
 
+    //免费领取商城 ssh 20230304
+    public function actionGetMall()
+    {
+        $shop = $this->shop;
+        if (!empty($shop)) {
+            util::complete('已经有店铺了');
+        }
+
+        $get = Yii::$app->request->get();
+        $orderSn = isset($get['orderSn']) ? $get['orderSn'] : 0;
+        $ljh = LjhApplyClass::getByCondition(['orderSn' => $orderSn], true);
+        if (empty($ljh)) {
+            util::complete('订单号无效');
+        }
+        $mobile = $ljh->mobile ?? 0;
+        if (empty($mobile)) {
+            util::complete('手机号无效');
+        }
+        $hasApply = ApplyClass::getByCondition(['mobile' => $mobile]);
+        if (!empty($hasApply)) {
+            util::complete('已有申请');
+        }
+        $hasShop = ShopClass::getByCondition(['mobile' => $mobile]);
+        if (!empty($hasShop)) {
+            util::complete('已经开店');
+        }
+        $ptStyle = Yii::$app->params['ptStyle'];
+        $adminName = $ljh->adminName ?? '';
+        $shopName = $ljh->name ?? '';
+        $miniOpenId = $post['miniOpenId'] ?? '';
+        $adminInfo = ['name' => $adminName, 'mobile' => $mobile, 'style' => $ptStyle, 'miniOpenId' => $miniOpenId];
+        $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
+        $admin = AdminClass::replaceAdmin($adminInfo, $fromApp);
+        $adminId = $admin['id'] ?? 0;
+        $currentShopId = $admin['currentShopId'] ?? 0;
+        if (!empty($currentShopId)) {
+            util::complete('已经有开店了');
+        }
+        if (isset($admin['openShop']) && $admin['openShop'] == 2) {
+            util::complete('已经有申请了');
+        }
+        $post['adminId'] = $adminId;
+        $post['adminName'] = $adminName;
+        $post['long'] = $ljh->long ?? '';
+        $post['lat'] = $ljh->lat ?? '';
+        $post['from'] = ApplyClass::FROM_RETAIL;
+        $post['style'] = SjClass::STYLE_RETAIL;
+
+        //增加或更新申请
+        $respond = ApplyService::replaceRetail($post);
+        $id = $respond['id'] ?? 0;
+        //提交申请资料失败
+        if (empty($id)) {
+            util::complete('申请失败了');
+        }
+
+        $passInfo = ApplyService::pass($id);
+        $mobile = $post['mobile'] ?? '';
+        //输出登录信息
+        $newShop = $passInfo['shop'] ?? [];
+        $newMainId = $newShop->mainId ?? 0;
+        $newShopId = $newShop->id ?? 0;
+        $pfShopId = $newShop->pfShopId ?? 0;
+        $onlyCg = 1;
+        //前端用于判断是否注册
+        $admin['currentShopId'] = $newShopId;
+        $adminId = $admin['id'];
+        $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'mainId' => $newMainId], 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);
+        $showDemo = 1;
+        $token = jwt::getNewToken($adminId);
+
+        noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 注册", '15280215347');
+        $apiHost = Yii::$app->params['hdHost'];
+        $imgUploadApi = $apiHost . '/upload/save-file';
+
+        //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
+        util::success([
+            'token' => $token,
+            'admin' => $admin,
+            'shopId' => $currentShopId,
+            'shopAdminId' => $shopAdminId,
+            'switchShop' => $switchShop,
+            'pfShopId' => $pfShopId,
+            'onlyCg' => $onlyCg,
+            'showDemo' => $showDemo,
+            'imgUploadApi' => $imgUploadApi,
+            'staff' => $shopAdmin,
+            'newUser' => 1,
+        ]);
+
+    }
+
 }