diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index e415982ba..f918c51d4 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -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) { diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 198915e16..1349cfbe6 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -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