兑换库存
This commit is contained in:
parent
c66e012b2a
commit
7ecd594588
@ -484,7 +484,7 @@ class OrderLogic extends BaseLogic
|
||||
// $capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']);
|
||||
// }
|
||||
$order=StoreOrder::where('id',$data['id'])->find();
|
||||
PayNotifyLogic::descStock($order['id']);
|
||||
PayNotifyLogic::descSwap($order['id']);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
|
@ -695,6 +695,30 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
|
||||
|
||||
public static function descSwap($oid)
|
||||
{
|
||||
$updateData = [];
|
||||
$goods_list = StoreOrderCartInfo::where('oid',$oid)->select()->toArray();
|
||||
foreach ($goods_list as $v) {
|
||||
$StoreBranchProduct =StoreBranchProduct::where(
|
||||
[
|
||||
'store_id'=>$v['store_id'],
|
||||
'product_id'=>$v['product_id'],
|
||||
]
|
||||
)->withTrashed()->find();
|
||||
$updateData[] = [
|
||||
'id' => $StoreBranchProduct['id'],
|
||||
'swap' => $StoreBranchProduct['swap']-$v['cart_num'],
|
||||
'sales' => ['inc', $v['cart_num']]
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
(new StoreBranchProduct())->saveAll($updateData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 扣库存
|
||||
* @param $oid
|
||||
|
Loading…
x
Reference in New Issue
Block a user