This commit is contained in:
mkm 2024-06-24 17:21:38 +08:00
commit 97641a18ce
4 changed files with 59 additions and 1 deletions

View File

@ -7,6 +7,8 @@ use app\admin\controller\BaseAdminController;
use app\admin\lists\user_recharge\UserRechargeLists;
use app\admin\logic\user_recharge\UserRechargeLogic;
use app\admin\validate\user_recharge\UserRechargeValidate;
use app\common\logic\PayNotifyLogic;
use app\common\model\user\UserRecharge;
/**
@ -91,5 +93,29 @@ class UserRechargeController extends BaseAdminController
return $this->data($result);
}
public function refund()
{
$params = (new UserRechargeValidate())->goCheck('refund');
$detail = UserRecharge::where('id',$params['id'])->findOrEmpty();
if(empty($detail)){
return $this->fail('无该充值订单请检查');
}
//现金
if($detail['recharge_type'] =='CASH_PAY'){
PayNotifyLogic::recharge_cash_refund($params['id']);
return $this->success();
}
//微信
if($detail['recharge_type'] == 'INDUSTRYMEMBERS'){
$money = (int)bcmul($detail['price'],100);
(new \app\common\logic\store_order\StoreOrderLogic())
->refund($detail['order_id'],$money,$money);
return $this->success();
}
//支付宝
}
}

View File

@ -32,6 +32,12 @@ class UserRechargeValidate extends BaseValidate
];
public function sceneRefund()
{
return $this->only(['id']);
}
/**
* @notes 添加场景
* @return UserRechargeValidate

View File

@ -28,6 +28,8 @@ class PayController extends BaseApiController
{
$app = new PayService(1);
$result = $app->wechat->callback(Request()->post());
Cache::set('6log'.time(),$result);
Cache::set('6logJ'.time(),json_encode($result));
if ($result && $result->event_type == 'TRANSACTION.SUCCESS') {
$ciphertext = $result->resource['ciphertext'];
if ($ciphertext['trade_state'] === 'SUCCESS') {
@ -47,6 +49,7 @@ class PayController extends BaseApiController
} else {
if ($result && $result->event_type == 'REFUND.SUCCESS') {
$ciphertext = $result->resource['ciphertext'];
Cache::set('6logC'.time(),json_encode($ciphertext));
if ($ciphertext['refund_status'] === 'SUCCESS') {
//处理订单 -1判断是退的一单还是拆分的订单
$out_trade_no = $ciphertext['out_trade_no'] . '-1';

View File

@ -296,7 +296,7 @@ class PayNotifyLogic extends BaseLogic
//处理财务流水退还
self::store_finance_back($orderSn);
self::addStock($order['id']);//微信
return true;
// self::afterPay($order,$extra['transaction_id']);
}
@ -359,6 +359,28 @@ class PayNotifyLogic extends BaseLogic
return true;
}
/**
* 充值现金退款相关
* @param $orderId
* @param $extra
* @return true
*/
public static function recharge_cash_refund($orderId,$extra = [])
{
$order = UserRecharge::where('id',$orderId)->findOrEmpty();
if ($order->isEmpty() || $order->status == -1) {
return true;
}
$order->status = -1;
$order->refund_price = $order->price;
$order->refund_time = time();
$order->remarks = '';
$order->save();
return true;
}
/**
* 充值
*/
@ -427,6 +449,7 @@ class PayNotifyLogic extends BaseLogic
self::descStock($order['id']);
}
// Redis::send('push-platform-print', ['id' => $order['id']]);
return true;
}
/**