shish 1 year ago
parent
commit
e401c3381c
2 changed files with 21 additions and 24 deletions
  1. 8 11
      app-mall/controllers/BaseController.php
  2. 13 13
      app-mall/controllers/OrderController.php

+ 8 - 11
app-mall/controllers/BaseController.php

@@ -24,7 +24,7 @@ class BaseController extends PublicController
     public $validate = true;
     public $guestAccess = [];
     public $userId = 0, $user, $shopId, $shop;
-    public $sjId, $sj, $sjExtend, $customId = 0, $custom, $hd, $mainId = 0, $main;
+    public $sjId, $sj, $sjExtend, $customId = 0, $custom, $hd, $hdId, $mainId = 0, $main;
     public $isWx;
 
     public function beforeAction($action)
@@ -41,7 +41,7 @@ class BaseController extends PublicController
         $user = UserClass::getById($userId, true);
         if (empty($user)) {
             if (!in_array($action->id, $this->guestAccess)) {
-                util::fail('请先登录');
+                util::fail('请先登录');
             }
         }
         $this->user = $user;
@@ -63,16 +63,13 @@ class BaseController extends PublicController
                 if (!empty($hdId)) {
                     $hd = HdClass::getById($hdId, true);
                     if (!empty($hd)) {
-                        if ($hd->userId != $this->userId) {
-                            util::fail('不是你的花店,无法访问哦');
+                        if (!empty($this->userId) && $hd->userId == $this->userId && $shopId == $hd->shopId) {
+                            $this->hd = $hd;
+                            $this->hdId = $hdId;
+                            $customId = $hd->customId ?? 0;
+                            $custom = CustomClass::getById($customId, true);
+                            $this->custom = $custom;
                         }
-                        if ($shopId != $hd->shopId) {
-                            util::fail('花店信息有问题哦');
-                        }
-                        $this->hd = $hd;
-                        $customId = $hd->customId ?? 0;
-                        $custom = CustomClass::getById($customId, true);
-                        $this->custom = $custom;
                     }
                 }
             }

+ 13 - 13
app-mall/controllers/OrderController.php

@@ -582,8 +582,8 @@ class OrderController extends BaseController
         $post['customId'] = $this->customId;
         $user = isset($this->user->attributes) ? $this->user->attributes : [];
         $post['bookName'] = isset($user['userName']) ? $user['userName'] : '';
-        $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
-        $bookMobile = empty($bookMobile) && isset($user['mobile']) && !empty($user['mobile']) ? $user['mobile'] : $bookMobile;
+        $bookMobile = !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
+        $bookMobile = empty($bookMobile) && !empty($user['mobile']) ? $user['mobile'] : $bookMobile;
         $post['bookMobile'] = $bookMobile;
         $prePrice = round($post['prePrice'], 2);
         $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
@@ -596,7 +596,7 @@ class OrderController extends BaseController
         $post['realPrice'] = $actPrice;
         $post['mainPay'] = $actPrice;
         $post['payStyle'] = 0;
-        $post['sjId'] = $this->sjId;
+        $post['userId'] = $this->userId;
         $post['needPrint'] = dict::getDict('needPrint', 'noNeed');
         $now = time();
         $expireTime = $now + 300;//订单5分钟后过期
@@ -609,29 +609,29 @@ class OrderController extends BaseController
         $post['modPrice'] = $this->isWx ? 0 : 1;
         $post['goodsNum'] = 1;
         $post['fromType'] = $post['fromType'] ?? 1;
-        $post['reachDate'] = isset($post['reachDate']) && !empty($post['reachDate']) ? $post['reachDate'] : '00-00-00';
+        $post['reachDate'] = !empty($post['reachDate']) ? $post['reachDate'] : '00-00-00';
         $post['onlinePay'] = dict::getDict('onlinePay', 'yes');
 
         //前端未修改时这边做兼容
-        if (isset($post['receiveAddress']) && !empty($post['receiveAddress'])) {
+        if (!empty($post['receiveAddress'])) {
             $post['address'] = $post['receiveAddress'];
-            if (isset($post['receiveProvince']) && !empty($post['receiveProvince'])) {
+            if (!empty($post['receiveProvince'])) {
                 $post['province'] = $post['receiveProvince'];
             }
-            if (isset($post['receiveCity']) && !empty($post['receiveCity'])) {
+            if (!empty($post['receiveCity'])) {
                 $post['city'] = $post['receiveCity'];
             }
-            if (isset($post['receiveFloor']) && !empty($post['receiveFloor'])) {
+            if (!empty($post['receiveFloor'])) {
                 $post['floor'] = $post['receiveFloor'];
             }
-            if (isset($post['latitude']) && !empty($post['latitude'])) {
+            if (!empty($post['latitude'])) {
                 $post['lat'] = $post['latitude'];
             }
-            if (isset($post['longitude']) && !empty($post['longitude'])) {
+            if (!empty($post['longitude'])) {
                 $post['long'] = $post['longitude'];
             }
             $city = $post['receiveCity'] ?? '';
-            $address = $post['receiveAddress'] ?? '';
+            $address = $post['receiveAddress'];
             $floor = $post['receiveFloor'] ?? '';
             $post['fullAddress'] = $city . $address . $floor;
         }
@@ -678,7 +678,7 @@ class OrderController extends BaseController
                 'couponId' => $couponId,
             ];
             $response = $laResource->driveWxPay($wxParams);
-            if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
+            if (!isset($response['code']) || $response['code'] != 'BBS00000') {
                 $errMsg = $response['msg'] ?? '';
                 noticeUtil::push($errMsg, '15280215347');
                 util::fail('支付失败');
@@ -729,7 +729,7 @@ class OrderController extends BaseController
                 'subject' => $subject,
             ];
             $response = $laResource->cashierPay($cashParams);
-            if (isset($response['code']) == false || $response['code'] != '000000') {
+            if (!isset($response['code']) || $response['code'] != '000000') {
                 util::fail('支付失败了');
             }
             $url = $response['resp_data']['counter_url'] ? $response['resp_data']['counter_url'] : '';