From 2e0b8dc93998a1d08feaa5ef8ab60952c2c7af90 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Mon, 9 Oct 2023 17:43:26 +0800 Subject: [PATCH] update --- app/customer/hdl/hdl_pay.go | 59 +++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/app/customer/hdl/hdl_pay.go b/app/customer/hdl/hdl_pay.go index 752175c..094c1db 100644 --- a/app/customer/hdl/hdl_pay.go +++ b/app/customer/hdl/hdl_pay.go @@ -1,6 +1,7 @@ package hdl import ( + "applet/app/cfg" "applet/app/customer/lib/validate" "applet/app/customer/md" "applet/app/customer/svc" @@ -76,34 +77,36 @@ func OrdState(c *gin.Context) { return } - //if ord.State == enum.CentralKitchenForSchoolPackageOrdStateForWait { - // //处于待支付状态,请求支付宝同步订单状态 - // sysCfgDb := db.SysCfgDb{} - // sysCfgDb.Set() - // sysCfg := sysCfgDb.SysCfgFindWithDb(enum.JsapiPayAppAutToken, enum.OpenAlipayAppid, enum.OpenAlipayAppPrivateKey, enum.OpenAlipayPublicKey) - // err2, result := svc.CurlAlipayTradeQuery(md.CurlAlipayTradeQueryReq{ - // Config: struct { - // PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` - // PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` - // PayAliPublicKey string `json:"pay_ali_public_key" label:"支付宝开放平台-第三方应用-接口加签-支付宝公钥"` - // }{ - // PayAliAppId: sysCfg[enum.OpenAlipayAppid], - // PayAliPrivateKey: sysCfg[enum.OpenAlipayAppPrivateKey], - // PayAliPublicKey: sysCfg[enum.OpenAlipayPublicKey], - // }, - // OutTradeNo: outTradeNo, - // AppAuthToken: sysCfg[enum.JsapiPayAppAutToken], - // }) - // if err2 != nil { - // e.OutErr(c, e.ERR, err2.Error()) - // return - // } - // ord.State, err2 = svc.DealCentralKitchenForSchoolOrderCallBack(outTradeNo, result.TradeStatus) - // if err != nil { - // e.OutErr(c, e.ERR, err2.Error()) - // return - // } - //} + if !cfg.Prd { + if ord.State == enum.CentralKitchenForSchoolPackageOrdStateForWait { + //处于待支付状态,请求支付宝同步订单状态 + sysCfgDb := db.SysCfgDb{} + sysCfgDb.Set() + sysCfg := sysCfgDb.SysCfgFindWithDb(enum.JsapiPayAppAutToken, enum.OpenAlipayAppid, enum.OpenAlipayAppPrivateKey, enum.OpenAlipayPublicKey) + err2, result := svc.CurlAlipayTradeQuery(md.CurlAlipayTradeQueryReq{ + Config: struct { + PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` + PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` + PayAliPublicKey string `json:"pay_ali_public_key" label:"支付宝开放平台-第三方应用-接口加签-支付宝公钥"` + }{ + PayAliAppId: sysCfg[enum.OpenAlipayAppid], + PayAliPrivateKey: sysCfg[enum.OpenAlipayAppPrivateKey], + PayAliPublicKey: sysCfg[enum.OpenAlipayPublicKey], + }, + OutTradeNo: outTradeNo, + AppAuthToken: sysCfg[enum.JsapiPayAppAutToken], + }) + if err2 != nil { + e.OutErr(c, e.ERR, err2.Error()) + return + } + ord.State, err2 = svc.DealCentralKitchenForSchoolOrderCallBack(outTradeNo, result.TradeStatus) + if err != nil { + e.OutErr(c, e.ERR, err2.Error()) + return + } + } + } e.OutSuc(c, map[string]interface{}{ "sate": ord.State,