feat: 修改支付控制器以处理不同类型的支付通知
This commit is contained in:
parent
0dc0ebe48b
commit
87161dd9be
@ -68,7 +68,6 @@ class PayController extends BaseApiController
|
|||||||
public function wechatQuery()
|
public function wechatQuery()
|
||||||
{
|
{
|
||||||
$order_no = $this->request->get('order_no');
|
$order_no = $this->request->get('order_no');
|
||||||
$recharge = $this->request->get('recharge', 0);
|
|
||||||
$order = [
|
$order = [
|
||||||
'out_trade_no' => $order_no,
|
'out_trade_no' => $order_no,
|
||||||
];
|
];
|
||||||
@ -80,10 +79,17 @@ class PayController extends BaseApiController
|
|||||||
return $this->fail($e->extra['message']);
|
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) {
|
$attach = $res['attach'];
|
||||||
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
switch ($attach) {
|
||||||
} else {
|
case 'recharge':
|
||||||
PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
|
PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
|
||||||
|
$app->wechat->success();
|
||||||
|
break;
|
||||||
|
case 'wechat_common':
|
||||||
|
default:
|
||||||
|
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
||||||
|
$app->wechat->success();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return $this->success('支付成功');
|
return $this->success('支付成功');
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,6 +127,7 @@ class StoreController extends BaseApiController
|
|||||||
$order = UserRecharge::create($data);
|
$order = UserRecharge::create($data);
|
||||||
|
|
||||||
$order['pay_price']=$order['price'];
|
$order['pay_price']=$order['price'];
|
||||||
|
$order['attach']=$order['recharge'];
|
||||||
$result = PaymentLogic::codepay($auth_code, $order,'条码支付');
|
$result = PaymentLogic::codepay($auth_code, $order,'条码支付');
|
||||||
if (PaymentLogic::hasError()) {
|
if (PaymentLogic::hasError()) {
|
||||||
return $this->fail(PaymentLogic::getError());
|
return $this->fail(PaymentLogic::getError());
|
||||||
@ -155,6 +156,7 @@ class StoreController extends BaseApiController
|
|||||||
UserRecharge::where('id', $id)->update(['order_id'=>$order_id]);
|
UserRecharge::where('id', $id)->update(['order_id'=>$order_id]);
|
||||||
$order['order_id']=$order_id;
|
$order['order_id']=$order_id;
|
||||||
$order['pay_price']=$order['price'];
|
$order['pay_price']=$order['price'];
|
||||||
|
$order['attach']=$order['recharge'];
|
||||||
$result = PaymentLogic::codepay($auth_code, $order,'条码支付');
|
$result = PaymentLogic::codepay($auth_code, $order,'条码支付');
|
||||||
if (PaymentLogic::hasError()) {
|
if (PaymentLogic::hasError()) {
|
||||||
return $this->fail(PaymentLogic::getError());
|
return $this->fail(PaymentLogic::getError());
|
||||||
|
@ -83,7 +83,7 @@ class PaymentLogic extends BaseLogic
|
|||||||
self::$error = '请使用正确的微信收付款条码';
|
self::$error = '请使用正确的微信收付款条码';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$order = [
|
$data = [
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'out_trade_no' => (string)$order['order_id'],
|
'out_trade_no' => (string)$order['order_id'],
|
||||||
'payer' => [
|
'payer' => [
|
||||||
@ -97,10 +97,14 @@ class PaymentLogic extends BaseLogic
|
|||||||
'id' => (string)$order['store_id']??1
|
'id' => (string)$order['store_id']??1
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'attach'=>'wechat_common'
|
||||||
];
|
];
|
||||||
|
if(isset($order['attach']) && $order['attach']!=''){
|
||||||
|
$data['attach'] = $order['attach'];
|
||||||
|
}
|
||||||
$wechat = new PayService(1);
|
$wechat = new PayService(1);
|
||||||
try {
|
try {
|
||||||
$result = $wechat->wechat->pos($order)->toArray();
|
$result = $wechat->wechat->pos($data)->toArray();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::error('条码支付报错',['message' => $e->extra['message']?? $e->getMessage(),'code'=>$e->getCode()]);
|
Log::error('条码支付报错',['message' => $e->extra['message']?? $e->getMessage(),'code'=>$e->getCode()]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user