更新
This commit is contained in:
parent
3911709d32
commit
e2f1dbafd0
@ -118,6 +118,17 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
if ($oldProductStock < $cart['cart_num']) {
|
||||
throw new ValidateException('商品库存不足');
|
||||
}
|
||||
if ($source == 103) {
|
||||
$canBuy = (new StoreActivityDao())->canBuy($cart['uid'], $cart['product_id']);
|
||||
if ($canBuy['is_true'] == false) {
|
||||
throw new ValidateException('活动商品限购1个');
|
||||
}
|
||||
if ($canBuy['activityId'] == 2) {
|
||||
$activityProductCount += $cart['cart_num'];
|
||||
if ($activityProductCount > 1) {
|
||||
throw new ValidateException('活动商品限购1个');
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($cart['product_type'] <= 97 && $cart['product_type'] > 0 && (($cart['product_type'] != 10 && count($merchantCart['list']) != 1) || count($merchantCartList) != 1)) {
|
||||
throw new ValidateException('活动商品必须单独购买');
|
||||
@ -131,17 +142,18 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
}
|
||||
if ($address) {
|
||||
if ($cart['source'] == 0 || $cart['source'] == 103) {
|
||||
$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;
|
||||
$curl = new Curl();
|
||||
$response = $curl->get($getUrl);
|
||||
$courierData = json_decode($response, true);
|
||||
if (empty($courierData['data']['user_id'])) {
|
||||
$allowDelivery = false;
|
||||
}
|
||||
$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;
|
||||
$curl = new Curl();
|
||||
$response = $curl->get($getUrl);
|
||||
$courierData = json_decode($response, true);
|
||||
if (empty($courierData['data']['user_id'])) {
|
||||
$allowDelivery = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (($order_type == 98 || $order_type == 99) && count($merchantCartList) > 1) {
|
||||
// throw new ValidateException('采购、委托商品不支持跨店购买');
|
||||
@ -154,6 +166,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$order_coupon_price = 0;
|
||||
$noDeliver = false;
|
||||
$presellType = 0;
|
||||
$consumption_coupon_id = 0;
|
||||
$fn = [];
|
||||
if (in_array($source, [0, 2, 103])) {
|
||||
$enabledPlatformCoupon = true;
|
||||
@ -174,7 +187,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
|
||||
if ($consumption_id > 0) {
|
||||
$this->store_consumption_user = Db::name('store_consumption_user')->where('coupon_user_id', $consumption_id)->where('uid', $uid)->find();
|
||||
$this->balance=$this->store_consumption_user['balance'];
|
||||
$this->balance = $this->store_consumption_user['balance'];
|
||||
}
|
||||
// 循环计算每个店铺的订单数据 委托商品是否设置收货方式 ?
|
||||
foreach ($merchantCartList as &$merchantCart) {
|
||||
@ -586,36 +599,42 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$pay_price = $org_price;
|
||||
}
|
||||
//计算总红包金额
|
||||
if ($consumption_id > 0 ) {
|
||||
if ($this->store_consumption_user) {
|
||||
if ($this->store_consumption_user['type'] == 2 && $pay_price>=6) {
|
||||
$a = bcdiv($pay_price, 6);
|
||||
if ($this->balance > $a) {
|
||||
$pay_price = bcsub($pay_price, $a, 2);
|
||||
$this->consumption_money = bcadd($this->consumption_money, $a, 2);
|
||||
$this->balance = bcsub($this->balance, $a, 2);
|
||||
} else {
|
||||
$pay_price = bcsub($pay_price, $this->balance, 2);
|
||||
$this->consumption_money = bcadd($this->consumption_money, $this->balance, 2);
|
||||
$this->balance = 0;
|
||||
if ($source == 105) {
|
||||
$this->consumption_money = bcsub($pay_price, 2, 2);
|
||||
$pay_price =2; ;
|
||||
$this->balance = 0;
|
||||
$consumption_coupon_id=100;
|
||||
} else {
|
||||
if ($consumption_id > 0) {
|
||||
if ($this->store_consumption_user) {
|
||||
if ($this->store_consumption_user['type'] == 2 && $pay_price >= 6) {
|
||||
$a = bcdiv($pay_price, 6);
|
||||
if ($this->balance > $a) {
|
||||
$pay_price = bcsub($pay_price, $a, 2);
|
||||
$this->consumption_money = bcadd($this->consumption_money, $a, 2);
|
||||
$this->balance = bcsub($this->balance, $a, 2);
|
||||
} else {
|
||||
$pay_price = bcsub($pay_price, $this->balance, 2);
|
||||
$this->consumption_money = bcadd($this->consumption_money, $this->balance, 2);
|
||||
$this->balance = 0;
|
||||
}
|
||||
}
|
||||
if ($this->store_consumption_user['type'] == 1) {
|
||||
if ($pay_price > $this->balance) {
|
||||
$pay_price = bcsub($pay_price, $this->balance, 2);
|
||||
$this->consumption_money = bcadd($this->consumption_money, $this->balance, 2);
|
||||
$this->balance = 0;
|
||||
} else {
|
||||
$this->consumption_money = $pay_price;
|
||||
$this->balance = bcsub($this->balance, $pay_price, 2);
|
||||
$pay_price = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->store_consumption_user['type'] == 1) {
|
||||
if ($pay_price > $this->balance) {
|
||||
$pay_price = bcsub($pay_price, $this->balance, 2);
|
||||
$this->consumption_money = bcadd($this->consumption_money, $this->balance, 2);
|
||||
$this->balance=0;
|
||||
} else {
|
||||
$this->consumption_money = $pay_price;
|
||||
$this->balance = bcsub($this->balance, $pay_price, 2);
|
||||
$pay_price = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$giveIntegralFlag = $sysIntegralConfig['integral_status'] && $sysIntegralConfig['integral_order_rate'] > 0;
|
||||
$total_give_integral = 0;
|
||||
|
||||
@ -687,7 +706,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'key',
|
||||
'platformConsumption',
|
||||
'consumption_money',
|
||||
'consumption_id'
|
||||
'consumption_id',
|
||||
'consumption_coupon_id'
|
||||
) + ['allow_address' => !$allow_no_address, 'order_delivery_status' => $orderDeliveryStatus];
|
||||
}
|
||||
|
||||
@ -697,7 +717,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true, $consumption_id);
|
||||
$order_model = $orderInfo['order_model'];
|
||||
$order_extend = $orderInfo['order_extend'];
|
||||
if($pay_type=='balance' && $orderInfo['source']!=103){
|
||||
if ($pay_type == 'balance' && $orderInfo['source'] != 103) {
|
||||
throw new ValidateException('余额支付只能用于里海云仓');
|
||||
}
|
||||
if (!$orderInfo['order_delivery_status']) {
|
||||
@ -958,7 +978,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
//创建订单
|
||||
$groupOrder = $storeGroupOrderRepository->create($groupOrder);
|
||||
$bills = [];
|
||||
$consumptionDetails=[];
|
||||
$consumptionDetails = [];
|
||||
if ($groupOrder['integral'] > 0) {
|
||||
$user->integral = bcsub($user->integral, $groupOrder['integral'], 0);
|
||||
app()->make(UserBillRepository::class)->decBill($user['uid'], 'integral', 'deduction', [
|
||||
@ -971,22 +991,30 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
]);
|
||||
$user->save();
|
||||
}
|
||||
|
||||
$consumption_coupon_id = 0;
|
||||
if ($groupOrder['consumption_money'] > 0) {
|
||||
$balance = 0;
|
||||
$store_consumption_user = Db::name('store_consumption_user')->where('uid',$uid)->where('coupon_user_id', $groupOrder['consumption_id'])->where('status', 0)->find();
|
||||
if ($store_consumption_user) {
|
||||
if ($store_consumption_user['type'] == 1) {
|
||||
if ($store_consumption_user['balance'] > $groupOrder['consumption_money']) {
|
||||
$balance = bcsub($store_consumption_user['balance'], $groupOrder['consumption_money'], 2);
|
||||
$balanceArr = ['balance' => $balance];
|
||||
Db::name('store_consumption_user')->where('coupon_user_id', $store_consumption_user['coupon_user_id'])->update($balanceArr);
|
||||
} else {
|
||||
$balanceArr = ['balance' => 0, 'status' => 1];
|
||||
Db::name('store_consumption_user')->where('coupon_user_id', $store_consumption_user['coupon_user_id'])->update($balanceArr);
|
||||
if($groupOrder['consumption_coupon_id']==100){
|
||||
$consumption_coupon_id=Db::name('store_consumption_user')->insertGetId(['coupon_id'=>100,'mer_id'=>0,'uid'=>$uid,
|
||||
'order_amount'=>$groupOrder['pay_price'],'coupon_title'=>'2元活动红包','coupon_price'=>$groupOrder['consumption_money'],
|
||||
'balance'=>0,'use_min_price'=>0,'order_id_set'=>'','create_time'=>date('Y-m-d H:i:s'),'start_time'=>date('Y-m-d H:i:s'),
|
||||
'end_time'=>date('Y-m-d H:i:s'),'use_time'=>date('Y-m-d H:i:s'),'type'=>1,'send_id'=>0,'status'=>1]);
|
||||
}else{
|
||||
$store_consumption_user = Db::name('store_consumption_user')->where('uid', $uid)->where('coupon_user_id', $groupOrder['consumption_id'])->where('status', 0)->find();
|
||||
if ($store_consumption_user) {
|
||||
if ($store_consumption_user['type'] == 1) {
|
||||
if ($store_consumption_user['balance'] > $groupOrder['consumption_money']) {
|
||||
$balance = bcsub($store_consumption_user['balance'], $groupOrder['consumption_money'], 2);
|
||||
$balanceArr = ['balance' => $balance];
|
||||
Db::name('store_consumption_user')->where('coupon_user_id', $store_consumption_user['coupon_user_id'])->update($balanceArr);
|
||||
} else {
|
||||
$balanceArr = ['balance' => 0, 'status' => 1];
|
||||
Db::name('store_consumption_user')->where('coupon_user_id', $store_consumption_user['coupon_user_id'])->update($balanceArr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app()->make(UserBillRepository::class)->decBill($user['uid'], 'consumption', 'deduction', [
|
||||
'link_id' => $groupOrder['group_order_id'],
|
||||
'status' => 1,
|
||||
@ -1032,7 +1060,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'user_id' => $uid,
|
||||
'order_id' => $_order->order_id,
|
||||
'group_order_id' => $groupOrder->group_order_id,
|
||||
'coupon_user_id' => $order['consumption_id'],
|
||||
'coupon_user_id' => $order['consumption_id']!=0?$order['consumption_id']:$consumption_coupon_id,
|
||||
'type' => 1,
|
||||
'amount' => $order['consumption_money'],
|
||||
'pay_price' => $order['pay_price'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user