跨区域购买限制
This commit is contained in:
parent
ffb9e9051c
commit
69b511c2fa
@ -79,7 +79,7 @@ class StoreCartDao extends BaseDao
|
|||||||
$query->field('product_id,stock,price,unique,sku,image,svip_price');
|
$query->field('product_id,stock,price,unique,sku,image,svip_price');
|
||||||
},
|
},
|
||||||
'merchant' => function ($query) {
|
'merchant' => function ($query) {
|
||||||
$query->field('mer_id,mer_name,mer_state,mer_avatar,is_trader,type_id,credit_buy')->with(['type_names']);
|
$query->field('mer_id,mer_name,mer_state,mer_avatar,is_trader,type_id,credit_buy,street_id')->with(['type_names']);
|
||||||
}
|
}
|
||||||
])->select();
|
])->select();
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ class StoreCartDao extends BaseDao
|
|||||||
->append(['bc_extension_one', 'bc_extension_two']);
|
->append(['bc_extension_one', 'bc_extension_two']);
|
||||||
},
|
},
|
||||||
'merchant' => function (Relation $query) use ($uid) {
|
'merchant' => function (Relation $query) use ($uid) {
|
||||||
$query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id,credit_buy,settle_cycle,interest_rate')
|
$query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id,credit_buy,settle_cycle,interest_rate,type_id,street_id')
|
||||||
->with([
|
->with([
|
||||||
'coupon' => function ($query) use ($uid) {
|
'coupon' => function ($query) use ($uid) {
|
||||||
$query->where('uid', $uid);
|
$query->where('uid', $uid);
|
||||||
|
@ -5,6 +5,7 @@ namespace app\common\repositories\store\order;
|
|||||||
use app\common\dao\store\order\StoreCartDao;
|
use app\common\dao\store\order\StoreCartDao;
|
||||||
use app\common\model\store\order\StoreGroupOrder;
|
use app\common\model\store\order\StoreGroupOrder;
|
||||||
use app\common\model\store\order\StoreOrder;
|
use app\common\model\store\order\StoreOrder;
|
||||||
|
use app\common\model\system\merchant\Merchant;
|
||||||
use app\common\repositories\community\CommunityRepository;
|
use app\common\repositories\community\CommunityRepository;
|
||||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||||
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
||||||
@ -69,8 +70,12 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
//虚拟订单自定义数据
|
//虚拟订单自定义数据
|
||||||
$order_extend = [];
|
$order_extend = [];
|
||||||
//检查商品类型, 活动商品只能单独购买
|
//检查商品类型, 活动商品只能单独购买
|
||||||
|
|
||||||
foreach ($merchantCartList as $merchantCart) {
|
foreach ($merchantCartList as $merchantCart) {
|
||||||
|
if($merchantCart['type_id']!=Merchant::TypeSupplyChain){
|
||||||
|
if($merchantCart['street_id']!=$address['street_code']){
|
||||||
|
throw new ValidateException('不能跨区域购买商品');
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach ($merchantCart['list'] as $cart) {
|
foreach ($merchantCart['list'] as $cart) {
|
||||||
if ($cart['product_type']==0) {
|
if ($cart['product_type']==0) {
|
||||||
if ($cart['product']['once_min_count'] > 0 && $cart['product']['once_min_count'] > $cart['cart_num'])
|
if ($cart['product']['once_min_count'] > 0 && $cart['product']['once_min_count'] > $cart['cart_num'])
|
||||||
@ -204,30 +209,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
if ($deliveryStatus && !$isTake && ($merDelivery || $merTake)) {
|
if ($deliveryStatus && !$isTake && ($merDelivery || $merTake)) {
|
||||||
$isTake = $merDelivery ? 0 : 1;
|
$isTake = $merDelivery ? 0 : 1;
|
||||||
}
|
}
|
||||||
//加载商品数据
|
|
||||||
foreach ($merchantCart['list'] as $cart) {
|
|
||||||
//预售订单
|
|
||||||
if ($cart['product_type'] == 2) {
|
|
||||||
$cart->append(['productPresell', 'productPresellAttr']);
|
|
||||||
//助力订单
|
|
||||||
} else if ($cart['product_type'] == 3) {
|
|
||||||
$cart->append(['productAssistAttr']);
|
|
||||||
//拼团订单
|
|
||||||
} else if ($cart['product_type'] == 4) {
|
|
||||||
$cart->append(['activeSku']);
|
|
||||||
//套餐订单
|
|
||||||
} else if ($cart['product_type'] == 10) {
|
|
||||||
$cart->append(['productDiscount', 'productDiscountAttr']);
|
|
||||||
}
|
|
||||||
|
|
||||||
//如果是预售订单 获取预售的订单的首款,尾款预售类型
|
|
||||||
if ($order_type == 2) {
|
|
||||||
$final_price = bcadd($final_price, bcmul($cart['cart_num'], $cart['productPresellAttr']['final_price'], 2), 2);
|
|
||||||
$presellType = $cart['productPresell']['presell_type'];
|
|
||||||
if ($presellType == 2)
|
|
||||||
$down_price = bcadd($down_price, bcmul($cart['cart_num'], $cart['productPresellAttr']['down_price'], 2), 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($cart);
|
unset($cart);
|
||||||
|
|
||||||
$enabledCoupon = !($order_type && $order_type != 2);
|
$enabledCoupon = !($order_type && $order_type != 2);
|
||||||
|
@ -108,22 +108,14 @@ class StoreOrder extends BaseController
|
|||||||
if ($cartProductType == 0 && count($deliveryWay) == 0) {
|
if ($cartProductType == 0 && count($deliveryWay) == 0) {
|
||||||
$userAddressCode = ($address['province_code'] ?? '') . ',' . ($address['city_code'] ?? '') . ',' . ($address['district_code'] ?? '') . ',' . ($address['street_code'] ?? '') . ',' . ($address['village_code'] ?? '') . ',' . ($address['brigade_id'] ?? 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;
|
$getUrl = env('LOGISTICS_HOST_URL') . '/api/hasCourier?user_address_code=' . $userAddressCode;
|
||||||
$ch = curl_init();
|
$client = new \GuzzleHttp\Client();
|
||||||
curl_setopt($ch, CURLOPT_URL, $getUrl);
|
$response = $client->request('GET', $getUrl);
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
$courierData = json_decode($response->getBody(), true);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
if (empty($courierData['code']) || $courierData['code'] != 1) {
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
|
throw new ValidateException('该收货区域未设置快递员');
|
||||||
$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) {
|
$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);
|
return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user