From 1aecbefd8d167f6c06f0844ff53258088d28c210 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 6 Mar 2024 19:28:11 +0800 Subject: [PATCH] update --- app/customer/hdl/hdl_demo.go | 59 +++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/app/customer/hdl/hdl_demo.go b/app/customer/hdl/hdl_demo.go index 70bd493..42db11b 100644 --- a/app/customer/hdl/hdl_demo.go +++ b/app/customer/hdl/hdl_demo.go @@ -149,8 +149,61 @@ func WxPay(c *gin.Context) { } func Demo(c *gin.Context) { + sysCfgDb := db.SysCfgDb{} + sysCfgDb.Set() + client, err := svc3.NewWxPayClient(c) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + wxSvc := jsapi.JsapiApiService{Client: client} + var m []model.CentralKitchenForSchoolPackageOrd + eg := db.Db + if err1 := eg.Where("state = 1 AND create_at >= '2024-02-16 00:00:00' AND create_at < '2024-02-16 23:59:59'").Desc("id").Find(&m); err1 != nil { + e.OutErr(c, e.ERR, err1.Error()) + return + } + companyWithWxpayInfoDb := db.CompanyWithWxpayInfoDb{} + companyWithWxpayInfoDb.Set() - _, err := svc.DealCentralKitchenForSchoolOrderCallBackForWx("141271708763327845", "4200002114202402240122111525", "SUCCESS", "") + sysCfg := sysCfgDb.SysCfgFindWithDb(enum.WxSpMchId) + centralKitchenForSchoolPackageOrd := db.CentralKitchenForSchoolPackageOrd{} + for _, v := range m { + wxMchId, err := companyWithWxpayInfoDb.GetCompanyWithWxpayInfoByEnterprise(v.EnterpriseId) + if err != nil { + fmt.Println(err) + e.OutErr(c, e.ERR, err.Error()) + return + } + result, _, err := wxSvc.QueryOrderByOutTradeNo(c, + jsapi.QueryOrderByOutTradeNoRequest{ + OutTradeNo: core.String(v.OutTradeNo), + SpMchid: core.String(sysCfg[enum.WxSpMchId]), + SubMchid: core.String(wxMchId), + }, + ) + if err != nil { + fmt.Println(err) + e.OutErr(c, e.ERR, err.Error()) + return + } + successTime, err := utils.ConvertWechatTime(*result.SuccessTime) + if err != nil { + fmt.Println(err) + e.OutErr(c, e.ERR, err.Error()) + return + } + v.PayAt = successTime + centralKitchenForSchoolPackageOrd.Set(v.OutTradeNo) + _, err = centralKitchenForSchoolPackageOrd.CentralKitchenForSchoolPackageOrdUpdate(&v, "pay_at") + if err != nil { + fmt.Println(err) + e.OutErr(c, e.ERR, err.Error()) + return + } + } + return + _, err = svc.DealCentralKitchenForSchoolOrderCallBackForWx("141271708763327845", "4200002114202402240122111525", "SUCCESS", "") if err != nil { e.OutErr(c, e.ERR, err.Error()) return @@ -158,10 +211,6 @@ func Demo(c *gin.Context) { e.OutSuc(c, "success", nil) return - sysCfgDb := db.SysCfgDb{} - sysCfgDb.Set() - sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAppid, enum.OpenAppletAppPrivateKey, enum.OpenAppletPublicKey) - //err, info := svc.CurlEducateFacepayApply(md.CurlEducateFacepayApplyReq{ // Config: struct { // AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"`