feat(StoreFinanceFlowLogic): 修改了财务流水退还逻辑,添加了商户ID参数,优化了退款流程,提高了资金流水的准确性,并更新了相关API接口。
This commit is contained in:
parent
b31a2fff15
commit
bc2ed0635a
@ -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']);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -176,39 +176,44 @@ 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)
|
||||
$list = StoreFinanceFlow::where('order_sn', $orderSn)
|
||||
->where(['financial_pm' => 1, 'status' => 1])
|
||||
->select();
|
||||
foreach ($list as $k => $value) {
|
||||
//用户
|
||||
switch ($value['type']) {
|
||||
case 0:
|
||||
if ($value['financial_type'] == 12&& $value['other_uid']>0) {
|
||||
if ($value['financial_type'] == 12 && $value['other_uid'] > 0) {
|
||||
$user = User::where('id', $value['other_uid'])->findOrEmpty();
|
||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||
$user->now_money = bcsub($user['now_money'],$value['number'], 2);
|
||||
$user->now_money = bcsub($user['now_money'], $value['number'], 2);
|
||||
$user->save();
|
||||
// Log::error('aa'.$a);
|
||||
// Log::error('aa'.$user['now_money']);
|
||||
// Log::error('aa'.$value['number']);
|
||||
$capitalFlowDao->userExpense('user_order_promotion_refund', 'system_back', $value['order_id'], $value['number'],'',$value['pay_type']);
|
||||
$capitalFlowDao->userExpense('user_order_promotion_refund', 'system_back', $value['order_id'], $value['number'], '', $value['pay_type']);
|
||||
}
|
||||
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();
|
||||
$find = StoreFinanceFlow::where('order_sn', $orderSn)->where('financial_type', 11)->where('status', 1)->find();
|
||||
if ($find && $find['number'] > 0) {
|
||||
SystemStore::where('id', $find['store_id'])->dec('paid_deposit', $find['number'])->update();
|
||||
}
|
||||
@ -220,7 +225,7 @@ class StoreFinanceFlowLogic extends BaseLogic
|
||||
// $value['financial_type'] = OrderEnum::PAY_BACK;
|
||||
// $value['create_time'] = time();
|
||||
// }
|
||||
StoreFinanceFlow::where('order_sn', $orderSn)->update(['status'=>-1]);
|
||||
StoreFinanceFlow::where('order_sn', $orderSn)->update(['status' => -1]);
|
||||
// (new StoreFinanceFlow)->saveAll($data);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user