feat: 增加微信支付查询接口及条码支付功能

This commit is contained in:
mkm 2024-06-17 11:04:23 +08:00
parent 1eb395bbe0
commit f1219258c3
3 changed files with 9 additions and 4 deletions

View File

@ -68,6 +68,7 @@ class PayController extends BaseApiController
public function wechatQuery()
{
$order_no = $this->request->get('order_no');
$recharge = $this->request->get('recharge',0);
$order = [
'out_trade_no' => $order_no,
];
@ -75,7 +76,11 @@ class PayController extends BaseApiController
$res = $app->wechat->query($order);
if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
if($recharge==0){
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
}else{
PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
}
return $this->success('支付成功');
} else {
return $this->fail('订单支付中');

View File

@ -61,7 +61,7 @@ class StoreController extends BaseApiController
$order = UserRecharge::create($data);
$order['pay_price']=$order['price'];
$result = PaymentLogic::codepay($auth_code, $order);
$result = PaymentLogic::codepay($auth_code, $order,'条码支付');
if (PaymentLogic::hasError()) {
return $this->fail(PaymentLogic::getError(), $params);
}

View File

@ -74,7 +74,7 @@ class PaymentLogic extends BaseLogic
/**
* 微信条码支付
*/
public static function codepay($auth_code, $order)
public static function codepay($auth_code, $order,$description='条码商品')
{
$pattern = '/^(10|11|12|13|14|15)\d{16}$/';
@ -83,7 +83,7 @@ class PaymentLogic extends BaseLogic
return false;
}
$order = [
'description' => '条码商品',
'description' => $description,
'out_trade_no' => (string)$order['order_id'],
'payer' => [
'auth_code' => (string)$auth_code