refactor(PayNotifyLogic): 优化支付回调处理逻辑,提高代码可读性

This commit is contained in:
mkm 2024-06-08 22:06:30 +08:00
parent f5185ea377
commit e6405cd648

@ -38,7 +38,6 @@ class PayNotifyLogic extends BaseLogic
} else {
$payNotifyLogLogic->insert($action, $extra);
}
}
self::$action($orderSn, $extra);
Db::commit();
@ -160,6 +159,10 @@ class PayNotifyLogic extends BaseLogic
$order->save();
$uid = $order->uid;
$user = User::where('id', $uid)->findOrEmpty();
//用户的财务add
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userIncome('user_balance_recharge', 'user_recharge', $order['id'], $price);
if ($user->isEmpty()) {
return true;
}
@ -167,13 +170,10 @@ class PayNotifyLogic extends BaseLogic
$user->now_money = bcadd($user->now_money, $price, 2);
$user->total_recharge_amount = bcadd($user->total_recharge_amount, $price, 2);
$user->save();
//用户的财务add
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userIncome('user_balance_recharge', 'user_recharge', $order['id'], $price);
//更新等级
self::dealLevel($uid, $user->total_recharge_amount);
return true;
}
/**
@ -262,7 +262,6 @@ class PayNotifyLogic extends BaseLogic
$amount = min($deposit, $frozen);
$financeLogic->in($transaction_id, $amount, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id']);
}
}
$financeLogic->save();
}
@ -283,7 +282,6 @@ class PayNotifyLogic extends BaseLogic
}
}
return true;
}
//处理活动期间直接改用户的等级
@ -313,5 +311,4 @@ class PayNotifyLogic extends BaseLogic
];
PayNotify::create($data);
}
}