pull/5/head
wanghousheng 4 months ago
parent 5b4f0bea4d
commit fc03e2e464
  1. 5
      app/api/controller/Notify.php
  2. 5
      app/api/service/Notify.php

@ -12,8 +12,9 @@ declare (strict_types=1);
namespace app\api\controller; namespace app\api\controller;
use cores\BaseController;
use app\api\service\Notify as NotifyService; use app\api\service\Notify as NotifyService;
use cores\BaseController;
use think\facade\Db;
/** /**
* 支付成功异步通知接口 * 支付成功异步通知接口
@ -42,9 +43,11 @@ class Notify extends BaseController
*/ */
public function wechatV3(): string public function wechatV3(): string
{ {
Db::table('yoshop_wx_server')->insertGetId(['content' => "进入回调第一步", 'created_at' => date('Y-m-d H:i:s')]);
try { try {
$NotifyService = new NotifyService; $NotifyService = new NotifyService;
return $NotifyService->wechatV3(); return $NotifyService->wechatV3();
} catch (\Throwable $e) { } catch (\Throwable $e) {
return '{"code": "FAIL","message": "失败"}'; return '{"code": "FAIL","message": "失败"}';
} }

@ -68,6 +68,7 @@ class Notify
*/ */
public function wechatV3(): string public function wechatV3(): string
{ {
Db::table('yoshop_wx_server')->insertGetId(['content' => "进入回调第二步", 'created_at' => date('Y-m-d H:i:s')]);
try { try {
// 通过微信支付v3平台证书序号 获取支付模板 // 通过微信支付v3平台证书序号 获取支付模板
$wechatpaySerial = \request()->header('wechatpay-serial'); $wechatpaySerial = \request()->header('wechatpay-serial');
@ -84,7 +85,7 @@ class Notify
$platformCertificateFilePath = PaymentTemplateModel::realPathCertFile( $platformCertificateFilePath = PaymentTemplateModel::realPathCertFile(
PaymentMethodEnum::WECHAT, $fileName, $templateInfo['store_id'] PaymentMethodEnum::WECHAT, $fileName, $templateInfo['store_id']
); );
Db::table('yoshop_wx_server')->insertGetId(['content' => "进入回调第三步", 'created_at' => date('Y-m-d H:i:s')]);
// 验证异步通知是否合法并获取第三方支付交易订单号 // 验证异步通知是否合法并获取第三方支付交易订单号
$V3 = new WechatPaymentV3(); $V3 = new WechatPaymentV3();
$outTradeNo = $V3->notify($apiv3Key, $platformCertificateFilePath); $outTradeNo = $V3->notify($apiv3Key, $platformCertificateFilePath);
@ -93,6 +94,7 @@ class Notify
// 获取第三方交易记录 // 获取第三方交易记录
$tradeInfo = PaymentTradeModel::detailByOutTradeNo($outTradeNo); $tradeInfo = PaymentTradeModel::detailByOutTradeNo($outTradeNo);
// 订单支付成功事件 // 订单支付成功事件
Db::table('yoshop_wx_server')->insertGetId(['content' => "进入回调第四步", 'created_at' => date('Y-m-d H:i:s')]);
$this->orderPaySucces($tradeInfo, $V3->getNotifyParams()); $this->orderPaySucces($tradeInfo, $V3->getNotifyParams());
} catch (\Throwable $e) { } catch (\Throwable $e) {
// 记录错误日志 // 记录错误日志
@ -137,6 +139,7 @@ class Notify
'orderType' => OrderTypeEnum::data()[$tradeInfo['order_type']]['name'], 'orderType' => OrderTypeEnum::data()[$tradeInfo['order_type']]['name'],
'tradeInfo' => $tradeInfo->toArray(), 'tradeInfo' => $tradeInfo->toArray(),
]); ]);
Db::table('yoshop_wx_server')->insertGetId(['content' => "进入回调第五步", 'created_at' => date('Y-m-d H:i:s')]);
try { try {
// 订单支付成功业务处理 (商城订单) // 订单支付成功业务处理 (商城订单)
if ($tradeInfo['order_type'] == OrderTypeEnum::ORDER) { if ($tradeInfo['order_type'] == OrderTypeEnum::ORDER) {

Loading…
Cancel
Save