From ba21c2c5fc954a0d89abd3ed23cf93a797d2531e Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Mon, 21 Aug 2023 17:32:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=8B=E5=8D=95=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=8C=BA=E5=9F=9F=E6=98=AF=E5=90=A6=E9=85=8D=E9=80=81?= =?UTF-8?q?=E5=BF=AB=E9=80=92=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/order/StoreOrderCreateRepository.php | 17 ++++++++++++++++- app/controller/api/store/order/StoreOrder.php | 2 -- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index a7241ee9..bbf0fac2 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -43,6 +43,21 @@ class StoreOrderCreateRepository extends StoreOrderRepository if ($addressId) { $addressRepository = app()->make(UserAddressRepository::class); $address = $addressRepository->getWhere(['uid' => $uid, 'address_id' => $addressId]); + $userAddressCode = ($address['province_code'] ?? '') . ',' . ($address['city_code'] ?? '') . ',' . ($address['district_code'] ?? '') . ',' . ($address['street_code'] ?? '') . ',' . ($address['village_code'] ?? '') . ',' . ($address['brigade_id'] ?? 0); + $getUrl = env('LOGISTICS_HOST_URL') . '/api/hasCourier?user_address_code=' . $userAddressCode; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $getUrl); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_TIMEOUT, 2); + $hasCourierData = curl_exec($ch); + curl_close($ch); + if (!empty($hasCourierData) && is_string($hasCourierData)) { + $courierData = json_decode($hasCourierData, true); + if (empty($courierData['code']) || $courierData['code'] != 1) { + throw new ValidateException('该收货区域未配送快递员'); + } + } } $storeCartRepository = app()->make(StoreCartRepository::class); $res = $storeCartRepository->checkCartList($storeCartRepository->cartIbByData($cartId, $uid, $address), 0, $user); @@ -943,7 +958,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository if ($orderInfo['order_price'] > 1000000) { throw new ValidateException('支付金额超出最大限制'); } - if ($orderInfo['status'] == 'noDeliver') throw new ValidateException('部分商品不支持该区域'); + if ($orderInfo['status'] == 'noDeliver') throw new ValidateException('商品不支持该区域'); if ($orderInfo['status'] == 'noAddress') throw new ValidateException('请选择地址'); if (!$order_model && $orderInfo['allow_address']) { if (!$orderInfo['address']) throw new ValidateException('请选择正确的收货地址'); diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 773532cd..17c86571 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -82,12 +82,10 @@ class StoreOrder extends BaseController $mark = (array)$this->request->param('mark', []); $payType = $this->request->param('pay_type'); $post = (array)$this->request->param('post'); - $isPc = $payType === 'pc'; if ($isPc) { $payType = 'balance'; } - if (!in_array($payType, StoreOrderRepository::PAY_TYPE, true)) return app('json')->fail('请选择正确的支付方式');