总后台微信退款逻辑

This commit is contained in:
liu 2024-06-24 09:39:45 +08:00
parent 296953484b
commit 3ee83dcc86
2 changed files with 38 additions and 0 deletions

View File

@ -8,6 +8,8 @@ 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\logic\PayNotifyLogic;
use app\common\model\store_order\StoreOrder;
/**
@ -101,5 +103,31 @@ class StoreOrderController extends BaseAdminController
return $this->data($result);
}
/**
* 退款逻辑
* @return \support\Response
* @throws \Exception
*/
public function refund()
{
$params = (new StoreOrderValidate())->goCheck('refund');
$detail = StoreOrder::where('order_id',$params['order_id'])->findOrEmpty();
if(empty($detail)){
return $this->fail('无该订单请检查');
}
$money = 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();
}
return $this->fail('退款失败');
}
}

View File

@ -20,6 +20,7 @@ class StoreOrderValidate extends BaseValidate
*/
protected $rule = [
'id' => 'require',
'order_id' => 'require',
];
@ -29,8 +30,17 @@ class StoreOrderValidate extends BaseValidate
*/
protected $field = [
'id' => 'id',
'order_id' => '订单编号',
];
/**
* @return StoreOrderValidate
*/
public function sceneRefund()
{
return $this->only(['order_id']);
}
/**
* @notes 添加场景