From a66cf583f65ceea981e2edbffa9a85263fd472b8 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 11 Oct 2023 18:16:49 +0800 Subject: [PATCH] update --- .../svc_central_kitchen_for_school_order.go | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/app/admin/svc/order/svc_central_kitchen_for_school_order.go b/app/admin/svc/order/svc_central_kitchen_for_school_order.go index b68863d..afdf54b 100644 --- a/app/admin/svc/order/svc_central_kitchen_for_school_order.go +++ b/app/admin/svc/order/svc_central_kitchen_for_school_order.go @@ -3,6 +3,7 @@ package svc import ( "applet/app/admin/md" svc "applet/app/admin/svc/enterprise_manage" + "applet/app/cfg" enum2 "applet/app/customer/enum" md2 "applet/app/customer/md" svc2 "applet/app/customer/svc" @@ -188,12 +189,6 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch }{} outRequestNoSuffix := "_" + utils.Int64ToStr(time.Now().Unix()) - client, err := svc3.NewWxPayClient(c) //初始化微信连接 - if err != nil { - e.OutErr(c, e.ERR, err.Error()) - return - } - wxSvc := refunddomestic.RefundsApiService{Client: client} for _, v := range req.Ids { //1、更新状态 @@ -305,27 +300,35 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch } //调用微信进行退款 - for k, v := range dealReturnOrdMapForWx { - resp, _, err6 := wxSvc.Create(c, - refunddomestic.CreateRequest{ - SubMchid: core.String(sysCfg[enum.WxMchId]), - OutTradeNo: core.String(k), - OutRefundNo: core.String(v.OutRequestNo), - Reason: core.String("央厨订餐退款"), - NotifyUrl: core.String(sysCfg[enum.WxJsapiRefundPayNotifyUrl]), - Amount: &refunddomestic.AmountReq{ - Currency: core.String("CNY"), - Refund: core.Int64(int64(math.Round(v.Amount * 100))), - Total: core.Int64(int64(math.Round(utils.StrToFloat64(v.Total) * 100))), + if !cfg.Prd { //TODO::正式环境暂不开启微信退款 + client, err := svc3.NewWxPayClient(c) //初始化微信连接 + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + wxSvc := refunddomestic.RefundsApiService{Client: client} + for k, v := range dealReturnOrdMapForWx { + resp, _, err6 := wxSvc.Create(c, + refunddomestic.CreateRequest{ + SubMchid: core.String(sysCfg[enum.WxMchId]), + OutTradeNo: core.String(k), + OutRefundNo: core.String(v.OutRequestNo), + Reason: core.String("央厨订餐退款"), + NotifyUrl: core.String(sysCfg[enum.WxJsapiRefundPayNotifyUrl]), + Amount: &refunddomestic.AmountReq{ + Currency: core.String("CNY"), + Refund: core.Int64(int64(math.Round(v.Amount * 100))), + Total: core.Int64(int64(math.Round(utils.StrToFloat64(v.Total) * 100))), + }, }, - }, - ) - if err6 != nil { - _ = session.Rollback() - return err6 + ) + if err6 != nil { + _ = session.Rollback() + return err6 + } + fmt.Println(">>>>wxRefund<<<<", resp.Status) + time.Sleep(20 * time.Millisecond) //TODO::避免频繁调用 } - fmt.Println(">>>>wxRefund<<<<", resp.Status) - time.Sleep(20 * time.Millisecond) //TODO::避免频繁调用 } session.Commit()