From 1df7f8740a657f492e36b759afda9a5c41708b7d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 31 Jul 2024 11:59:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(store=5Forder):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AE=A2=E5=8D=95=E6=94=AF=E4=BB=98=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_order/StoreOrderController.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 37b1bd220..d5b269ac7 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -25,6 +25,7 @@ use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; use app\common\model\system_store\SystemStoreStaff; use app\common\model\user_recharge\UserRecharge; +use app\common\service\pay\PayService; use app\store\validate\store_order\StoreOrderValidate; use support\Cache; use support\Log; @@ -504,4 +505,41 @@ class StoreOrderController extends BaseAdminController } return $this->success('获取成功', $find?->toArray()); } + + /** + * @notes 查询订单支付状态 + */ + public function wechatQuery() + { + $order_no = $this->request->get('order_no'); + $order = [ + 'out_trade_no' => $order_no, + ]; + $app = new PayService(0); + + try { + $res = $app->wechat->query($order); + } catch (\Exception $e) { + return $this->fail($e->extra['message'] ?? $e->getMessage()); + } + if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') { + $attach = $res['attach']; + switch ($attach) { + case 'recharge': + PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res); + $app->wechat->success(); + break; + case 'wechat_common': + PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); + $app->wechat->success(); + break; + default: + Log::error('支付回调失败,订单号:' . $res['out_trade_no'], $res); + break; + } + return $this->success('支付成功'); + } else { + return $this->fail('订单支付中'); + } + } }