From f3f6ccbbe1c03de8281a0cbc78e14887d9c4b8da Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Mon, 4 Sep 2023 11:29:41 +0800 Subject: [PATCH] 12 --- .../svc_central_kitchen_for_school_order.go | 64 ++++++++----------- 1 file changed, 28 insertions(+), 36 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 f1752ef..7496bbf 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 @@ -9,7 +9,6 @@ import ( "applet/app/enum" "applet/app/utils" "errors" - "fmt" "time" ) @@ -156,12 +155,38 @@ func CentralKitchenForSchoolOrderRefundAudit(req md.CentralKitchenForSchoolOrder if req.State == 1 { returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditPass userWithDay.State = enum.CentralKitchenForSchoolUserWithDayStateForCancel + + //调用支付宝进行退款 + err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ + 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: returnDay.OutTradeNo, + RefundAmount: returnDay.Amount, + RefundReason: "央厨订餐退款", + OutRequestNo: returnDay.OutRequestNo, + AppAuthToken: sysCfg[enum.JsapiPayAppAutToken], + }) + if err6 != nil { + _ = session.Rollback() + return err6 + } + + returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete + returnDay.RefundDate = time.Now().Format("2006-01-02 15:04:05") } else { returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditReject userWithDay.State = enum.CentralKitchenForSchoolUserWithDayStateForWait } + returnDay.Memo = req.Memo - updateAck, err2 := centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdate(returnDay.Id, returnDay, "state", "memo") + updateAck, err2 := centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdate(returnDay.Id, returnDay, "state", "memo", "refund_date") if err2 != nil { _ = session.Rollback() return err2 @@ -190,41 +215,8 @@ func CentralKitchenForSchoolOrderRefundAudit(req md.CentralKitchenForSchoolOrder return err5 } - //3、调用支付宝进行退款 if req.State == 1 { - err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ - 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: returnDay.OutTradeNo, - RefundAmount: returnDay.Amount, - RefundReason: "央厨订餐退款", - OutRequestNo: returnDay.OutRequestNo, - AppAuthToken: sysCfg[enum.JsapiPayAppAutToken], - }) - if err6 != nil { - _ = session.Rollback() - return err6 - } - returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete - returnDay.RefundDate = time.Now().Format("2006-01-02 15:04:05") - updateAck2, err7 := centralKitchenForSchoolUserWithDayDb.CentralKitchenForSchoolUserWithDayUpdate(userWithDay.Id, userWithDay, "state", "refund_date") - fmt.Println(">>>>>>>>>>>>>>>>>updateAck2<<<<<<<<<<<<<<", updateAck2) - if err7 != nil { - _ = session.Rollback() - return err7 - } - if updateAck2 <= 0 { - _ = session.Rollback() - err = errors.New("更新退款订单记录时间失败") - return - } + } }