feat: 修改CapitalFlowLogic和PayNotifyLogic类中的userIncome和userExpense方法,增加新的支付类型和退款描述,优化代码格式。

This commit is contained in:
mkm 2024-07-05 18:38:26 +08:00
parent b8aad3cdc2
commit de313f1bed
2 changed files with 13 additions and 12 deletions

View File

@ -30,7 +30,7 @@ class CapitalFlowLogic extends BaseLogic
* @param $mark
* @return mixed
*/
public function userIncome($category, $linkType, $linkId, $amount, $mark = '',$type=0)
public function userIncome($category, $linkType, $linkId, $amount, $mark = '', $type = 0)
{
$model = new CapitalFlow();
$model->uid = $this->user['id'];
@ -38,10 +38,10 @@ class CapitalFlowLogic extends BaseLogic
$model->link_type = $linkType;
$model->link_id = $linkId;
$model->amount = $amount;
if($type){
if ($type) {
$model->before_balance = $this->user['purchase_funds'];
$model->balance = bcadd($this->user['purchase_funds'], $amount, 2);
}else{
} else {
$model->before_balance = $this->user['now_money'];
$model->balance = bcadd($this->user['now_money'], $amount, 2);
}
@ -63,7 +63,7 @@ class CapitalFlowLogic extends BaseLogic
* @param $mark
* @return mixed
*/
public function userExpense($category, $linkType, $linkId, $amount, $mark = '',$payType=0,$store_id=0)
public function userExpense($category, $linkType, $linkId, $amount, $mark = '', $payType = 0, $store_id = 0)
{
$model = new CapitalFlow();
$model->uid = $this->user['id'];
@ -72,13 +72,13 @@ class CapitalFlowLogic extends BaseLogic
$model->link_type = $linkType;
$model->link_id = $linkId;
$model->amount = $amount;
if($payType == OrderEnum::BALANCE_PAYMEN_NO){
if ($payType == OrderEnum::BALANCE_PAYMEN_NO) {
$model->before_balance = $this->user['purchase_funds'];
$model->balance = bcsub($this->user['purchase_funds'], $amount, 2);
}else{
$model->before_balance = $this->user['now_money'];
$model->balance = bcsub($this->user['now_money'], $amount, 2);
}
} else {
$model->before_balance = $this->user['now_money'];
$model->balance = bcsub($this->user['now_money'], $amount, 2);
}
$model->create_time = date('Y-m-d H:i:s');
$model->type = 'out';
$model->title = $this->getTitle($category, $amount);
@ -171,9 +171,10 @@ class CapitalFlowLogic extends BaseLogic
return "系统增加采购款{$amount}";
case 'system_balance_reduce':
return "系统减少余额{$amount}";
case 'user_balance_recharge_refund':
return "用户充值退还{$amount}";
default:
return "订单支付{$amount}";
}
}
}

View File

@ -308,10 +308,10 @@ class PayNotifyLogic extends BaseLogic
$capitalFlowDao = new CapitalFlowLogic($user);
if ($purchase_funds >= $orderRe['price']) {
User::where('id', $orderRe['uid'])->dec('purchase_funds', $orderRe['refund_price'])->update();
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $orderRe['refund_price'], '', 1, $orderRe['store_id']);
$capitalFlowDao->userExpense('user_balance_recharge_refund', 'order', $orderRe['id'], $orderRe['refund_price'], '', 1, $orderRe['store_id']);
} else {
User::where('id', $orderRe['uid'])->dec('purchase_funds', $purchase_funds)->update();
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']);
$capitalFlowDao->userExpense('user_balance_recharge_refund', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']);
}
//退还 充值得兑换券
UserSignLogic::RefundRecharge($orderRe);