refactor(订单): 重构退款逻辑并更新库存
- 注释掉现金支付方式下的退款操作 - 新增更新产品库存的逻辑 - 优化退款流程,确保库存和销量的准确更新
This commit is contained in:
parent
bc4a9554b5
commit
ec69ae6c09
@ -145,7 +145,7 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
//现金支付
|
//现金支付
|
||||||
if ($detail['pay_type'] = PayEnum::CASH_PAY) {
|
if ($detail['pay_type'] = PayEnum::CASH_PAY) {
|
||||||
PayNotifyLogic::cash_refund($params['order_id']);
|
// PayNotifyLogic::cash_refund($params['order_id']);
|
||||||
self::refundProduct($detail, $params);
|
self::refundProduct($detail, $params);
|
||||||
return '退款成功';
|
return '退款成功';
|
||||||
|
|
||||||
@ -189,6 +189,7 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
$refund_price = $params['refund_price'];
|
$refund_price = $params['refund_price'];
|
||||||
$refund_num = 0;
|
$refund_num = 0;
|
||||||
|
$updateData=[];
|
||||||
foreach ($params['product_arr'] as $k => $v) {
|
foreach ($params['product_arr'] as $k => $v) {
|
||||||
$find = StoreOrderCartInfo::where('oid', $detail['id'])->where('product_id', $v['product_id'])->find();
|
$find = StoreOrderCartInfo::where('oid', $detail['id'])->where('product_id', $v['product_id'])->find();
|
||||||
if ($find) {
|
if ($find) {
|
||||||
@ -208,6 +209,12 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
$value['update_time'] = strtotime($value['update_time']);
|
$value['update_time'] = strtotime($value['update_time']);
|
||||||
StoreFinanceFlowProduct::create($value);
|
StoreFinanceFlowProduct::create($value);
|
||||||
}
|
}
|
||||||
|
$updateData[] = [
|
||||||
|
'id' => $v['product_id'],
|
||||||
|
'store_id' => $find['store_id'],
|
||||||
|
'stock' => ['inc',$v['cart_num']],
|
||||||
|
'sales' => ['dec', $v['cart_num']]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$village_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 14)->value('other_uid');
|
$village_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 14)->value('other_uid');
|
||||||
@ -217,6 +224,7 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
$detail['refund_price']=$refund_price;
|
$detail['refund_price']=$refund_price;
|
||||||
StoreOrder::where('id', $detail['id'])->inc('refund_price',$refund_price)->inc('refund_num',$refund_num)->update();
|
StoreOrder::where('id', $detail['id'])->inc('refund_price',$refund_price)->inc('refund_num',$refund_num)->update();
|
||||||
CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id);
|
CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id);
|
||||||
|
(new StoreBranchProduct())->saveAll($updateData);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user