diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 310fc566..2f149e11 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -43,24 +43,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository if ($addressId) { $addressRepository = app()->make(UserAddressRepository::class); $address = $addressRepository->getWhere(['uid' => $uid, 'address_id' => $addressId]); - $cartProductType = Db::name('StoreCart')->where('cart_id', $cartId[0] ?? 0)->value('product_type'); - if ($cartProductType == 0) { - $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); diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index 9fe1eb51..6b0e5775 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -21,6 +21,7 @@ use crmeb\services\SmsService; use crmeb\services\SwooleTaskService; use crmeb\services\YunxinSmsService; use think\App; +use think\facade\Db; use crmeb\basic\BaseController; use app\common\repositories\system\merchant\MerchantIntentionRepository as repository; use think\exception\ValidateException; @@ -44,8 +45,10 @@ class MerchantIntention extends BaseController return app('json')->fail('未开启商户入驻'); } if ($this->userInfo) $data['uid'] = $this->userInfo->uid; - if ($this->userInfo->account == $data['phone']) - throw new ValidateException('手机号账户已存在,不可申请'); + $newUid = Db::name('User')->where('account', $data['phone'])->value('uid', 0); + if (!$newUid && ($this->userInfo->uid != $newUid)) { + throw new ValidateException('该申请手机已存在账户,不可申请'); + } $make = app()->make(MerchantRepository::class); if ($make->fieldExists('mer_name', $data['mer_name'])) throw new ValidateException('商户名称已存在,不可申请'); diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 17c86571..e6803f50 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -98,8 +98,29 @@ class StoreOrder extends BaseController $uid = $this->request->uid(); if (!($count = count($cartId)) || $count != count($cartRepository->validIntersection($cartId, $uid))) return app('json')->fail('数据无效'); -// if (!$addressId) -// return app('json')->fail('请选择地址'); + + if ($addressId) { + $addressRepository = app()->make(UserAddressRepository::class); + $address = $addressRepository->getWhere(['uid' => $uid, 'address_id' => $addressId]); + $cartProductType = Db::name('StoreCart')->where('cart_id', $cartId[0] ?? 0)->value('product_type'); + if ($cartProductType == 0) { + $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('该收货区域未配送快递员'); + } + } + } + } $groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post) { return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post);