WIN-2308041133\Administrator hace 6 horas
padre
commit
d4f0ee45a0

+ 8 - 5
app/api/controller/v1/admin/StoreOrderController.php

@@ -553,12 +553,8 @@ class StoreOrderController
         ], true);
         ], true);
         if (!$verifyCode) return app('json')->fail(410188);
         if (!$verifyCode) return app('json')->fail(410188);
         $uid = $request->uid();
         $uid = $request->uid();
-        $orderInfo = $services->writeOffOrder($verifyCode, (int)$isConfirm, $uid);
-
-        if ($isConfirm == 0) {
-            return app('json')->success($orderInfo);
-        }
 
 
+        $orderInfo = $services->getOrderInfo($verifyCode);
         // 验证门店权限:只有订单选择的门店能核销这个订单
         // 验证门店权限:只有订单选择的门店能核销这个订单
         if (isset($orderInfo['store_id']) && $orderInfo['store_id'] > 0) {
         if (isset($orderInfo['store_id']) && $orderInfo['store_id'] > 0) {
             /** @var SystemStoreServices $systemStoreServices */
             /** @var SystemStoreServices $systemStoreServices */
@@ -569,6 +565,13 @@ class StoreOrderController
                 return app('json')->fail('只能核销本门店的订单');
                 return app('json')->fail('只能核销本门店的订单');
             }
             }
         }
         }
+        $orderInfo = $services->writeOffOrder($verifyCode, (int)$isConfirm, $uid);
+
+        if ($isConfirm == 0) {
+            return app('json')->success($orderInfo);
+        }
+
+
         // 核销确认后,根据订单类型发放佣金  核销礼包商品和复购商品后的佣金
         // 核销确认后,根据订单类型发放佣金  核销礼包商品和复购商品后的佣金
         if (isset($orderInfo['order_type']) && in_array((int)$orderInfo['order_type'], [1, 2])) {
         if (isset($orderInfo['order_type']) && in_array((int)$orderInfo['order_type'], [1, 2])) {
             $orderType = (int)$orderInfo['order_type'];
             $orderType = (int)$orderInfo['order_type'];

+ 16 - 0
app/services/order/StoreOrderWriteOffServices.php

@@ -135,4 +135,20 @@ class StoreOrderWriteOffServices extends BaseServices
             throw new ApiException(410272);
             throw new ApiException(410272);
         }
         }
     }
     }
+    public function getOrderInfo(string $code){
+        $orderInfo = $this->dao->getOne([
+            ['verify_code', '=', $code],
+            ['paid', '=', 1],
+            ['refund_status', '=', 0],
+            ['is_del', '=', 0],
+            ['pid', '>=', 0]
+        ]);
+        if (!$orderInfo) {
+            throw new ApiException(410173);
+        }
+        if (!$orderInfo['verify_code'] || ($orderInfo->shipping_type != 2 && $orderInfo->delivery_type != 'send')) {
+            throw new ApiException(410267);
+        }
+        return $orderInfo;
+    }
 }
 }