更新区域快递员判断
This commit is contained in:
parent
ba21c2c5fc
commit
1047347491
@ -43,20 +43,23 @@ 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('该收货区域未配送快递员');
|
||||
}
|
||||
$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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user