From eb7faf9bc3cd82366f76f51fea5f0f08fac2572c Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Thu, 14 Mar 2024 17:03:39 +0800 Subject: [PATCH] update --- app/customer/hdl/hdl_demo.go | 72 +++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/app/customer/hdl/hdl_demo.go b/app/customer/hdl/hdl_demo.go index a99c829..44d650c 100644 --- a/app/customer/hdl/hdl_demo.go +++ b/app/customer/hdl/hdl_demo.go @@ -159,7 +159,7 @@ func Demo(c *gin.Context) { 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' and pay_at ='2024-03-06 17:40:47'").Desc("id").Find(&m); err1 != nil { + if err1 := eg.Where("state = 1 AND create_at < '2024-04-01 23:59:59' and pay_at ='2024-03-06 17:40:47'").Desc("id").Find(&m); err1 != nil { e.OutErr(c, e.ERR, err1.Error()) return } @@ -169,40 +169,44 @@ func Demo(c *gin.Context) { 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) - continue - //result, _, err := wxSvc.QueryOrderByOutTradeNo(c, - // jsapi.QueryOrderByOutTradeNoRequest{ - // OutTradeNo: core.String(v.OutTradeNo), - // SpMchid: core.String(sysCfg[enum.WxSpMchId]), - // SubMchid: core.String("1663751886"), - // }, - //) - //fmt.Println(result) - //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 + if v.PayWay == 1 { + v.PayAt = v.CreateAt + } else { + 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) + continue + //result, _, err := wxSvc.QueryOrderByOutTradeNo(c, + // jsapi.QueryOrderByOutTradeNoRequest{ + // OutTradeNo: core.String(v.OutTradeNo), + // SpMchid: core.String(sysCfg[enum.WxSpMchId]), + // SubMchid: core.String("1663751886"), + // }, + //) + //fmt.Println(result) + //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 } - v.PayAt = successTime centralKitchenForSchoolPackageOrd.Set(v.OutTradeNo) updateAck, err := centralKitchenForSchoolPackageOrd.CentralKitchenForSchoolPackageOrdUpdate(&v, "pay_at") if err != nil {