feat(PayController): 修改支付控制器代码,优化了小程序支付回调、微信支付查询等方法,并修复了相关bug。

This commit is contained in:
mkm 2024-06-22 19:27:53 +08:00
parent 89db630313
commit 136d9e1714

View File

@ -56,7 +56,6 @@ class PayController extends BaseApiController
} }
PayNotifyLogic::handle('refund', $ciphertext['out_trade_no'], $ciphertext); PayNotifyLogic::handle('refund', $ciphertext['out_trade_no'], $ciphertext);
$app->wechat->success(); $app->wechat->success();
} }
} }
} }
@ -74,7 +73,11 @@ class PayController extends BaseApiController
]; ];
$app = new PayService(0); $app = new PayService(0);
try {
$res = $app->wechat->query($order); $res = $app->wechat->query($order);
} catch (\Exception $e) {
return $this->fail($e->extra['message']);
}
if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') { if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
if ($recharge == 0) { if ($recharge == 0) {
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
@ -83,7 +86,7 @@ class PayController extends BaseApiController
} }
return $this->success('支付成功'); return $this->success('支付成功');
} else { } else {
return $this->fail('订单支付中或已失效'); return $this->fail('订单支付中');
} }
} }