兼容退余额和采购款

This commit is contained in:
liu 2024-06-24 10:11:13 +08:00
parent e5d514bdd4
commit f010d54c7a
2 changed files with 36 additions and 4 deletions

View File

@ -8,6 +8,7 @@ use app\admin\lists\store_order\StoreOrderLists;
use app\admin\lists\store_order\StoreRefundOrderLists;
use app\admin\logic\store_order\StoreOrderLogic;
use app\admin\validate\store_order\StoreOrderValidate;
use app\common\enum\PayEnum;
use app\common\logic\PayNotifyLogic;
use app\common\model\store_order\StoreOrder;
@ -115,10 +116,25 @@ class StoreOrderController extends BaseAdminController
if(empty($detail)){
return $this->fail('无该订单请检查');
}
$money = (int)bcmul($detail['pay_price'],100);
$refund = (new \app\common\logic\store_order\StoreOrderLogic())
->refund($params['order_id'],$money,$money);
if($refund){
//微信支付
if(in_array($detail['pay_type'],[PayEnum::WECHAT_PAY_MINI,PayEnum::WECHAT_PAY_BARCODE])){
$money = (int)bcmul($detail['pay_price'],100);
$refund = (new \app\common\logic\store_order\StoreOrderLogic())
->refund($params['order_id'],$money,$money);
if($refund){
$arr = [
'amount'=>[
'refund'=>$money
]
];
PayNotifyLogic::refund($params['order_id'],$arr);
return $this->success();
}
}
//余额支付 采购款支付
if (in_array($detail['pay_type'] ,[PayEnum::BALANCE_PAY,PayEnum::PURCHASE_FUNDS])){
$money = bcmul($detail['pay_price'],100);
$arr = [
'amount'=>[
'refund'=>$money
@ -126,7 +142,10 @@ class StoreOrderController extends BaseAdminController
];
PayNotifyLogic::refund($params['order_id'],$arr);
return $this->success();
}
//支付包支付
return $this->fail('退款失败');
}

View File

@ -264,6 +264,19 @@ class PayNotifyLogic extends BaseLogic
$order->refund_reason_time = time();
$order->refund_num += 1;
$order->save();
//加用户余额,采购款, 日志记录 加数量
if (in_array($order['pay_type'],[PayEnum::BALANCE_PAY,PayEnum::PURCHASE_FUNDS])){
$user = User::where('id', $order['uid'])->findOrEmpty();
if($order['pay_type'] == PayEnum::BALANCE_PAY){
$user->now_money = bcadd($user->now_money, $extra['amount']['refund'], 2);
$user->save();
}
if($order['pay_type'] == PayEnum::PURCHASE_FUNDS){
$user->purchase_funds = bcadd($user->purchase_funds, $extra['amount']['refund'], 2);
$user->save();
}
}
// self::afterPay($order,$extra['transaction_id']);
}