feat(PayNotifyLogic): 更新支付通知逻辑,修复错误,优化代码
This commit is contained in:
parent
5ac2750227
commit
3723c9c047
@ -82,15 +82,15 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
if ($order['spread_uid'] > 0 && $user['user_ship'] == 1) {
|
if ($order['spread_uid'] > 0 && $user['user_ship'] == 1) {
|
||||||
$oldUser = User::where('id',$order['spread_uid'])->value('purchase_funds');
|
$oldUser = User::where('id', $order['spread_uid'])->value('purchase_funds');
|
||||||
if ($oldUser < $order['pay_price']) {
|
if ($oldUser < $order['pay_price']) {
|
||||||
$order['pay_price'] = $oldUser;
|
$order['pay_price'] = $oldUser;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||||
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'],'',0,$order['store_id']);
|
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']);
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
if($order['shipping_type'] == 3){
|
if ($order['shipping_type'] == 3) {
|
||||||
self::descStock($order['id']);
|
self::descStock($order['id']);
|
||||||
}
|
}
|
||||||
// self::afterPay($order);
|
// self::afterPay($order);
|
||||||
@ -136,16 +136,15 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
];
|
];
|
||||||
(new UserSign())->saveAll($sing);
|
(new UserSign())->saveAll($sing);
|
||||||
|
|
||||||
if($extra && $extra['store_id']){
|
if ($extra && $extra['store_id']) {
|
||||||
$params = [
|
$params = [
|
||||||
'verify_code'=>$order['verify_code'],
|
'verify_code' => $order['verify_code'],
|
||||||
'store_id'=>$extra['store_id'],
|
'store_id' => $extra['store_id'],
|
||||||
'staff_id'=>$extra['staff_id']
|
'staff_id' => $extra['staff_id']
|
||||||
];
|
];
|
||||||
OrderLogic::lessWriteOff($params);
|
OrderLogic::lessWriteOff($params);
|
||||||
}
|
}
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -176,23 +175,23 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||||
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price'],'',1,$order['store_id']);
|
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price'], '', 1, $order['store_id']);
|
||||||
// if ($user['user_ship'] == 1) {
|
// if ($user['user_ship'] == 1) {
|
||||||
// self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS);
|
// self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if($extra && $extra['store_id']){
|
if ($extra && $extra['store_id']) {
|
||||||
$params = [
|
$params = [
|
||||||
'verify_code'=>$order['verify_code'],
|
'verify_code' => $order['verify_code'],
|
||||||
'store_id'=>$extra['store_id'],
|
'store_id' => $extra['store_id'],
|
||||||
'staff_id'=>$extra['staff_id']
|
'staff_id' => $extra['staff_id']
|
||||||
];
|
];
|
||||||
OrderLogic::writeOff($params);
|
OrderLogic::writeOff($params);
|
||||||
}
|
}
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
// if($order['shipping_type'] == 3){
|
// if($order['shipping_type'] == 3){
|
||||||
// self::descStock($order['id']);
|
// self::descStock($order['id']);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// self::afterPay($order);
|
// self::afterPay($order);
|
||||||
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
|
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
|
||||||
@ -228,11 +227,11 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
} else {
|
} else {
|
||||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||||
//微信支付和用户余额无关
|
//微信支付和用户余额无关
|
||||||
$capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1,$order['store_id']);
|
$capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1, $order['store_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
if($order['shipping_type'] == 3){
|
if ($order['shipping_type'] == 3) {
|
||||||
self::descStock($order['id']);
|
self::descStock($order['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +332,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$cashFlowLogic = new CashFlowLogic();
|
$cashFlowLogic = new CashFlowLogic();
|
||||||
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
|
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
if($order['shipping_type'] == 3){
|
if ($order['shipping_type'] == 3) {
|
||||||
self::descStock($order['id']);
|
self::descStock($order['id']);
|
||||||
}
|
}
|
||||||
// Redis::send('push-platform-print', ['id' => $order['id']]);
|
// Redis::send('push-platform-print', ['id' => $order['id']]);
|
||||||
@ -367,7 +366,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
self::afterPay($order);
|
self::afterPay($order);
|
||||||
}
|
}
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
if($order['shipping_type'] == 3){
|
if ($order['shipping_type'] == 3) {
|
||||||
self::descStock($order['id']);
|
self::descStock($order['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,19 +397,18 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$user = User::where('id', $order['uid'])->find();
|
$user = User::where('id', $order['uid'])->find();
|
||||||
//纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额)
|
//纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额)
|
||||||
if ($order['spread_uid'] > 0) {
|
if ($order['spread_uid'] > 0) {
|
||||||
$oldUser = User::where('id',$order['spread_uid'])->field('purchase_funds,user_ship')->find();
|
$oldUser = User::where('id', $order['spread_uid'])->field('purchase_funds,user_ship')->find();
|
||||||
if ($oldUser && $oldUser['user_ship'] == 1){
|
if ($oldUser && $oldUser['user_ship'] == 1) {
|
||||||
if ($oldUser['purchase_funds'] < $order['pay_price']) {
|
if ($oldUser['purchase_funds'] < $order['pay_price']) {
|
||||||
$vipFen = $oldUser['purchase_funds'];
|
$vipFen = $oldUser['purchase_funds'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} elseif ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) {
|
||||||
elseif ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY){
|
|
||||||
$vipFrozenAmount = self::dealFrozenPrice($order['id']);
|
$vipFrozenAmount = self::dealFrozenPrice($order['id']);
|
||||||
//为1的时候要去减活动价
|
//为1的时候要去减活动价
|
||||||
// $final_price = bcsub($order['pay_price'],$order['deduction_price'],2);
|
// $final_price = bcsub($order['pay_price'],$order['deduction_price'],2);
|
||||||
// d($final_price,$vipFrozenAmount);
|
// d($final_price,$vipFrozenAmount);
|
||||||
$order['pay_price'] = bcsub($order['pay_price'],$vipFrozenAmount,2);
|
$order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2);
|
||||||
self::dealVipAmount($order, $order['pay_type']);
|
self::dealVipAmount($order, $order['pay_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,14 +447,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
if ($deposit > 0) {
|
if ($deposit > 0) {
|
||||||
if ($deposit > $store_profit) {
|
if ($deposit > $store_profit) {
|
||||||
if ($store_profit > 0) {
|
if ($store_profit > 0) {
|
||||||
SystemStore::where('id',$order['store_id'])->inc('paid_deposit',$store_profit)->update();
|
SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $store_profit)->update();
|
||||||
$financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
$financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||||
$financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费
|
$financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$money = bcsub($store_profit, $deposit, 2);
|
$money = bcsub($store_profit, $deposit, 2);
|
||||||
if ($deposit > 0) {
|
if ($deposit > 0) {
|
||||||
SystemStore::where('id',$order['store_id'])->inc('paid_deposit',$deposit)->update();
|
SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $deposit)->update();
|
||||||
$financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
$financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||||
}
|
}
|
||||||
if ($money) {
|
if ($money) {
|
||||||
@ -473,16 +471,16 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
// if ($order['is_vip'] >= 1) {
|
// if ($order['is_vip'] >= 1) {
|
||||||
if ($order['spread_uid'] > 0) {
|
if ($order['spread_uid'] > 0) {
|
||||||
$financeLogic->other_arr['vip_uid'] = $order['spread_uid'];
|
$financeLogic->other_arr['vip_uid'] = $order['spread_uid'];
|
||||||
if($vipFen){
|
if ($vipFen) {
|
||||||
$fees = bcdiv(bcmul($vipFen, '0.08', 2), 1, 2);
|
$fees = bcdiv(bcmul($vipFen, '0.08', 2), 1, 2);
|
||||||
}else{
|
} else {
|
||||||
$fees = bcdiv(bcmul($order['pay_price'], '0.08', 2), 1, 2);
|
$fees = bcdiv(bcmul($order['pay_price'], '0.08', 2), 1, 2);
|
||||||
}
|
}
|
||||||
$count_frees = bcadd($count_frees, $fees, 2);
|
$count_frees = bcadd($count_frees, $fees, 2);
|
||||||
if ($fees > 0) {
|
if ($fees > 0) {
|
||||||
User::where('id', $order['spread_uid'])->inc('now_money', $fees)->update();
|
User::where('id', $order['spread_uid'])->inc('now_money', $fees)->update();
|
||||||
//记录用户余额收入
|
//记录用户余额收入
|
||||||
$GiveUser = User::where('id',$order['spread_uid'])->find();
|
$GiveUser = User::where('id', $order['spread_uid'])->find();
|
||||||
$capitalFlowDao = new CapitalFlowLogic($GiveUser);
|
$capitalFlowDao = new CapitalFlowLogic($GiveUser);
|
||||||
$capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees);
|
$capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees);
|
||||||
|
|
||||||
@ -503,7 +501,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id');
|
$uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id');
|
||||||
if ($uid) {
|
if ($uid) {
|
||||||
User::where('id', $uid)->inc('integral', $fees)->update();
|
User::where('id', $uid)->inc('integral', $fees)->update();
|
||||||
$village_uid=$uid;
|
$village_uid = $uid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
|
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
|
||||||
@ -511,7 +509,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id');
|
$uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id');
|
||||||
if ($uid) {
|
if ($uid) {
|
||||||
User::where('id', $uid)->inc('integral', $fees)->update();
|
User::where('id', $uid)->inc('integral', $fees)->update();
|
||||||
$brigade_uid=$uid;
|
$brigade_uid = $uid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,12 +555,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
// 'user_ship' => 3,
|
// 'user_ship' => 3,
|
||||||
// ];
|
// ];
|
||||||
if ($village_uid > 0) {
|
if ($village_uid > 0) {
|
||||||
|
SystemStore::where('id', $village_uid)->inc('store_money', $fees)->update();
|
||||||
$financeLogic->other_arr['vip_uid'] = $village_uid;
|
$financeLogic->other_arr['vip_uid'] = $village_uid;
|
||||||
}
|
}
|
||||||
$financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
|
$financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
|
||||||
$financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
$financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||||
//队长获得
|
//队长获得
|
||||||
if ($brigade_uid > 0) {
|
if ($brigade_uid > 0) {
|
||||||
|
SystemStore::where('id', $brigade_uid)->inc('store_money', $fees)->update();
|
||||||
$financeLogic->other_arr['vip_uid'] = $brigade_uid;
|
$financeLogic->other_arr['vip_uid'] = $brigade_uid;
|
||||||
}
|
}
|
||||||
$financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
|
$financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
|
||||||
@ -616,10 +616,10 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
|
|
||||||
public static function dealFrozenPrice($oid)
|
public static function dealFrozenPrice($oid)
|
||||||
{
|
{
|
||||||
$detail = StoreOrderCartInfo::where('oid',$oid)->select()->toArray();
|
$detail = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
|
||||||
$total_vip = 0;
|
$total_vip = 0;
|
||||||
foreach ($detail as $value){
|
foreach ($detail as $value) {
|
||||||
$total_vip +=$value['cart_info']['vip_frozen_price'];
|
$total_vip += $value['cart_info']['vip_frozen_price'];
|
||||||
}
|
}
|
||||||
return $total_vip;
|
return $total_vip;
|
||||||
}
|
}
|
||||||
@ -635,20 +635,20 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function dealVipAmount($order,$pay_type =1,$transaction_id = 0)
|
public static function dealVipAmount($order, $pay_type = 1, $transaction_id = 0)
|
||||||
{
|
{
|
||||||
$total_vip = self::dealFrozenPrice($order['id']);
|
$total_vip = self::dealFrozenPrice($order['id']);
|
||||||
$data=[
|
$data = [
|
||||||
'order_id' => $order['id'],
|
'order_id' => $order['id'],
|
||||||
'transaction_id' => $transaction_id??0,
|
'transaction_id' => $transaction_id ?? 0,
|
||||||
'order_sn' =>$order['order_id'],
|
'order_sn' => $order['order_id'],
|
||||||
'user_id' => $order['uid'],
|
'user_id' => $order['uid'],
|
||||||
'number' => $total_vip,
|
'number' => $total_vip,
|
||||||
'pay_type' => $pay_type??1,
|
'pay_type' => $pay_type ?? 1,
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'store_id' => $order['store_id'],
|
'store_id' => $order['store_id'],
|
||||||
'staff_id' => $order['staff_id'],
|
'staff_id' => $order['staff_id'],
|
||||||
'create_time'=>time()
|
'create_time' => time()
|
||||||
];
|
];
|
||||||
Db::name('vip_flow')->insert($data);
|
Db::name('vip_flow')->insert($data);
|
||||||
return true;
|
return true;
|
||||||
@ -667,55 +667,52 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$store_id = $order['store_id'];
|
$store_id = $order['store_id'];
|
||||||
$cart_id = $order['cart_id'];
|
$cart_id = $order['cart_id'];
|
||||||
$uid = $order['uid'];
|
$uid = $order['uid'];
|
||||||
if($uid && $cart_id && $store_id){
|
if ($uid && $cart_id && $store_id) {
|
||||||
$cart_id = explode(',',$cart_id);
|
$cart_id = explode(',', $cart_id);
|
||||||
$productLog = StoreProductLog::where([
|
$productLog = StoreProductLog::where([
|
||||||
'uid'=>$uid
|
'uid' => $uid
|
||||||
])->whereIn('cart_id',$cart_id)
|
])->whereIn('cart_id', $cart_id)
|
||||||
->select()->toArray();
|
->select()->toArray();
|
||||||
|
|
||||||
foreach ($productLog as &$value){
|
foreach ($productLog as &$value) {
|
||||||
$value['pay_uid'] = $uid;
|
$value['pay_uid'] = $uid;
|
||||||
$value['oid'] = $order['id'];
|
$value['oid'] = $order['id'];
|
||||||
$cart_info = StoreOrderCartInfo::where([
|
$cart_info = StoreOrderCartInfo::where([
|
||||||
'uid'=>$uid,'old_cart_id'=>$value['cart_id'],'store_id'=>$store_id
|
'uid' => $uid, 'old_cart_id' => $value['cart_id'], 'store_id' => $store_id
|
||||||
])->find();
|
])->find();
|
||||||
$value['order_num'] = $cart_info['cart_num']??1;
|
$value['order_num'] = $cart_info['cart_num'] ?? 1;
|
||||||
$value['pay_num'] = $cart_info['cart_num']??1;
|
$value['pay_num'] = $cart_info['cart_num'] ?? 1;
|
||||||
$value['pay_price'] = $cart_info['price']??0;
|
$value['pay_price'] = $cart_info['price'] ?? 0;
|
||||||
$value['cost_price'] = $cart_info['cart_info']['cost']??0;
|
$value['cost_price'] = $cart_info['cart_info']['cost'] ?? 0;
|
||||||
$value['update_time'] = time();
|
$value['update_time'] = time();
|
||||||
unset($value['create_time'],$value['delete_time']);
|
unset($value['create_time'], $value['delete_time']);
|
||||||
}
|
}
|
||||||
|
|
||||||
(new StoreProductLog())->saveAll($productLog);
|
(new StoreProductLog())->saveAll($productLog);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function descSwap($oid)
|
public static function descSwap($oid)
|
||||||
{
|
{
|
||||||
$updateData = [];
|
$updateData = [];
|
||||||
$goods_list = StoreOrderCartInfo::where('oid',$oid)->select()->toArray();
|
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
|
||||||
foreach ($goods_list as $v) {
|
foreach ($goods_list as $v) {
|
||||||
$StoreBranchProduct =StoreBranchProduct::where(
|
$StoreBranchProduct = StoreBranchProduct::where(
|
||||||
[
|
[
|
||||||
'store_id'=>$v['store_id'],
|
'store_id' => $v['store_id'],
|
||||||
'product_id'=>$v['product_id'],
|
'product_id' => $v['product_id'],
|
||||||
]
|
]
|
||||||
)->withTrashed()->find();
|
)->withTrashed()->find();
|
||||||
$updateData[] = [
|
$updateData[] = [
|
||||||
'id' => $StoreBranchProduct['id'],
|
'id' => $StoreBranchProduct['id'],
|
||||||
'swap' => $StoreBranchProduct['swap']-$v['cart_num'],
|
'swap' => $StoreBranchProduct['swap'] - $v['cart_num'],
|
||||||
'sales' => ['inc', $v['cart_num']]
|
'sales' => ['inc', $v['cart_num']]
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(new StoreBranchProduct())->saveAll($updateData);
|
(new StoreBranchProduct())->saveAll($updateData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -730,26 +727,21 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
public static function descStock($oid)
|
public static function descStock($oid)
|
||||||
{
|
{
|
||||||
$updateData = [];
|
$updateData = [];
|
||||||
$goods_list = StoreOrderCartInfo::where('oid',$oid)->select()->toArray();
|
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
|
||||||
foreach ($goods_list as $v) {
|
foreach ($goods_list as $v) {
|
||||||
$StoreBranchProduct =StoreBranchProduct::where(
|
$StoreBranchProduct = StoreBranchProduct::where(
|
||||||
[
|
[
|
||||||
'store_id'=>$v['store_id'],
|
'store_id' => $v['store_id'],
|
||||||
'product_id'=>$v['product_id'],
|
'product_id' => $v['product_id'],
|
||||||
]
|
]
|
||||||
)->withTrashed()->find();
|
)->withTrashed()->find();
|
||||||
$updateData[] = [
|
$updateData[] = [
|
||||||
'id' => $StoreBranchProduct['id'],
|
'id' => $StoreBranchProduct['id'],
|
||||||
'stock' => $StoreBranchProduct['stock']-$v['cart_num'],
|
'stock' => $StoreBranchProduct['stock'] - $v['cart_num'],
|
||||||
'sales' => ['inc', $v['cart_num']]
|
'sales' => ['inc', $v['cart_num']]
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(new StoreBranchProduct())->saveAll($updateData);
|
(new StoreBranchProduct())->saveAll($updateData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user