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