Jelajahi Sumber

修改门店

shish 10 bulan lalu
induk
melakukan
9a52f67d09

+ 20 - 7
app-ghs/controllers/IntraCityController.php

@@ -136,8 +136,9 @@ class IntraCityController extends BaseController
     public function actionUpdateStore()
     {
         // 首先从门店扩展表查询是否已经创建
-        $main = MainClass::getById($this->mainId, false, 'id, wxStoreId');
-        if ($main['wxStoreId'] == '') {
+        $main = $this->main;
+        $wxStoreId = $main->wxStoreId;
+        if (empty($wxStoreId)) {
             util::fail('未创建门店,请先创建');
         }
 
@@ -146,16 +147,26 @@ class IntraCityController extends BaseController
         $sjName = $shop->merchantName ?? '';
         $name = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
 
+        $adminId = $this->adminId;
+        util::checkRepeatCommit($adminId, 4);
+
+        if (empty($shop->latitude) || empty($shop->longitude)) {
+            util::fail('没有经纬度,请修改地址');
+        }
+        if (empty($shop->address)) {
+            util::fail('地址缺失,请修改');
+        }
+
         $storeData = [
-            'keys' => ['wx_store_id' => $main['wxStoreId']],
+            'keys' => ['wx_store_id' => $wxStoreId],
             'content' => [
                 'store_name' => $name,
                 'address_info' => [
                     'province' => $shop->province,
                     'city' => $shop->city,
                     'area' => $shop->dist,
-                    'street' => '',
-                    'house' => $shop->floor ? $shop->address . $shop->floor : $shop->address,
+                    'street' => $shop->address,
+                    'house' => $shop->floor,
                     'lat' => $shop->lat,
                     'lng' => $shop->long,
                     'phone' => $shop->telephone
@@ -168,8 +179,10 @@ class IntraCityController extends BaseController
         if ($result['errcode'] === 0) {
             util::success($result, "门店更新成功");
         } else {
-            Yii::error("门店更新失败:" . $result['errmsg']);
-            util::fail($result['errmsg']);
+            $errMsg = $result['errmsg'] ?? '';
+            Yii::error("门店更新失败:" . $errMsg);
+            noticeUtil::push("销花宝,跑腿修改门店报错:" . $errMsg, '15280215347');
+            util::fail('更新失败,请联系客服');
         }
     }
 

+ 17 - 9
app-hd/controllers/IntraCityController.php

@@ -135,30 +135,37 @@ class IntraCityController extends BaseController
     public function actionUpdateStore()
     {
         // 首先从门店扩展表查询是否已经创建
-        //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
-        $shopExt = MainClass::getById($this->mainId, false, 'id, wxStoreId');
-        if ($shopExt['wxStoreId'] == '') {
+        $main = $this->main;
+        $wxStoreId = $main->wxStoreId;
+        if (empty($wxStoreId)) {
             util::fail('未创建门店,请先创建');
         }
 
         $adminId = $this->adminId;
         util::checkRepeatCommit($adminId, 4);
 
+        if (empty($shop->latitude) || empty($shop->longitude)) {
+            util::fail('没有经纬度,请修改地址');
+        }
+        if (empty($shop->address)) {
+            util::fail('地址缺失,请修改');
+        }
+
         $shop = $this->shop;
         $shopName = $shop->shopName ?? '';
         $sjName = $shop->merchantName ?? '';
         $name = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
 
         $storeData = [
-            'keys' => ['wx_store_id' => $shopExt['wxStoreId']],
+            'keys' => ['wx_store_id' => $wxStoreId],
             'content' => [
                 'store_name' => $name,
                 'address_info' => [
                     'province' => $shop->province,
                     'city' => $shop->city,
                     'area' => $shop->dist,
-                    'street' => '',
-                    'house' => $shop->floor ? $shop->address . $shop->floor : $shop->address,
+                    'street' => $shop->address,
+                    'house' => $shop->floor,
                     'lat' => $shop->lat,
                     'lng' => $shop->long,
                     'phone' => $shop->telephone
@@ -171,9 +178,10 @@ class IntraCityController extends BaseController
         if ($result['errcode'] === 0) {
             util::success($result, "门店更新成功");
         } else {
-            Yii::error("门店更新失败:" . $result['errmsg']);
-            util::fail($result['errmsg']);
-            //util::fail('门店更新失败');
+            $errMsg = $result['errmsg'] ?? '';
+            Yii::error("门店更新失败:" . $errMsg);
+            noticeUtil::push("花掌柜,跑腿修改门店报错:" . $errMsg, '15280215347');
+            util::fail('更新失败,请联系客服');
         }
     }