feat(StoreFinanceFlowLogic): 修改了财务流水退还逻辑,添加了商户ID参数,优化了退款流程,提高了资金流水的准确性,并更新了相关API接口。

This commit is contained in:
mkm 2024-08-20 21:09:50 +08:00
parent b31a2fff15
commit bc2ed0635a
3 changed files with 16 additions and 10 deletions

View File

@ -357,7 +357,7 @@ class DemoPayNotifyLogic extends BaseLogic
//微信日志 user_order_refund
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1);
//处理财务流水退还
(new StoreFinanceFlowLogic())->store_finance_back($orderSn);
(new StoreFinanceFlowLogic())->store_finance_back($orderSn,$order['store_id']);
self::addStock($order['id']); //微信
return true;
// self::afterPay($order,$extra['transaction_id']);

View File

@ -324,7 +324,7 @@ class PayNotifyLogic extends BaseLogic
StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]);
//处理财务流水退还
(new StoreFinanceFlowLogic())->store_finance_back($orderSn);
(new StoreFinanceFlowLogic())->store_finance_back($orderSn,$order['store_id']);
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付
$user = User::where('id', $order['uid'])->findOrEmpty();
@ -393,6 +393,7 @@ class PayNotifyLogic extends BaseLogic
//增加数量
self::addStock($order['id']);
StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]);
(new StoreFinanceFlowLogic())->store_finance_back($orderSn,$order['store_id']);
return true;
}

View File

@ -176,7 +176,7 @@ class StoreFinanceFlowLogic extends BaseLogic
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function store_finance_back($orderSn)
public function store_finance_back($orderSn, $store_id)
{
$list = StoreFinanceFlow::where('order_sn', $orderSn)
->where(['financial_pm' => 1, 'status' => 1])
@ -198,15 +198,20 @@ class StoreFinanceFlowLogic extends BaseLogic
break;
//商户
case 1:
$store = SystemStore::where('id', $store_id)->find();
$capitalFlowDao = new CapitalFlowLogic($store, 'store');
if ($value['number'] > 0 && $value['financial_type'] == 2) {
SystemStore::where('id', $value['store_id'])->dec('store_money', $value['number'])->update();
$capitalFlowDao->storeExpense('store_paid_deposit_dec', 'order', $value['order_id'],$value['number']);
}
if ($value['number'] > 0 && $value['financial_type'] == 16) {
SystemStore::where('id', $value['store_id'])->dec('attrition', $value['number'])->update();
$capitalFlowDao->storeExpense('store_attrition_dec', 'order', $value['order_id'], $value['number']);
}
break;
}
}
$find = StoreFinanceFlow::where('order_sn', $orderSn)->where('financial_type', 11)->where('status', 1)->find();
if ($find && $find['number'] > 0) {