兼容退余额和采购款
This commit is contained in:
parent
e5d514bdd4
commit
f010d54c7a
@ -8,6 +8,7 @@ use app\admin\lists\store_order\StoreOrderLists;
|
|||||||
use app\admin\lists\store_order\StoreRefundOrderLists;
|
use app\admin\lists\store_order\StoreRefundOrderLists;
|
||||||
use app\admin\logic\store_order\StoreOrderLogic;
|
use app\admin\logic\store_order\StoreOrderLogic;
|
||||||
use app\admin\validate\store_order\StoreOrderValidate;
|
use app\admin\validate\store_order\StoreOrderValidate;
|
||||||
|
use app\common\enum\PayEnum;
|
||||||
use app\common\logic\PayNotifyLogic;
|
use app\common\logic\PayNotifyLogic;
|
||||||
use app\common\model\store_order\StoreOrder;
|
use app\common\model\store_order\StoreOrder;
|
||||||
|
|
||||||
@ -115,10 +116,25 @@ class StoreOrderController extends BaseAdminController
|
|||||||
if(empty($detail)){
|
if(empty($detail)){
|
||||||
return $this->fail('无该订单请检查');
|
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(in_array($detail['pay_type'],[PayEnum::WECHAT_PAY_MINI,PayEnum::WECHAT_PAY_BARCODE])){
|
||||||
if($refund){
|
$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 = [
|
$arr = [
|
||||||
'amount'=>[
|
'amount'=>[
|
||||||
'refund'=>$money
|
'refund'=>$money
|
||||||
@ -126,7 +142,10 @@ class StoreOrderController extends BaseAdminController
|
|||||||
];
|
];
|
||||||
PayNotifyLogic::refund($params['order_id'],$arr);
|
PayNotifyLogic::refund($params['order_id'],$arr);
|
||||||
return $this->success();
|
return $this->success();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//支付包支付
|
||||||
|
|
||||||
return $this->fail('退款失败');
|
return $this->fail('退款失败');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +264,19 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$order->refund_reason_time = time();
|
$order->refund_reason_time = time();
|
||||||
$order->refund_num += 1;
|
$order->refund_num += 1;
|
||||||
$order->save();
|
$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']);
|
// self::afterPay($order,$extra['transaction_id']);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user