From 26c7ac3b081521df80bcadb0df75f918fe0d7971 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 22 Apr 2024 19:26:55 +0800 Subject: [PATCH] update --- app/admin/hdl/hdl_demo.go | 2 +- .../svc_self_support_for_school.go | 25 +++++---------- .../svc_central_kitchen_for_school_order.go | 2 +- .../svc/order/svc_nursing_home_package_ord.go | 2 +- app/customer/md/md_curl_smart_pay.go | 10 +++++- app/customer/svc/svc_curl_smart_pay.go | 32 ++++++++++++++++++- 6 files changed, 51 insertions(+), 22 deletions(-) diff --git a/app/admin/hdl/hdl_demo.go b/app/admin/hdl/hdl_demo.go index e6be6dc..2edca0c 100644 --- a/app/admin/hdl/hdl_demo.go +++ b/app/admin/hdl/hdl_demo.go @@ -95,7 +95,7 @@ func Demo(c *gin.Context) { sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAlipayAppid, enum.OpenAlipayAppPrivateKey, enum.OpenAlipayPublicKey) //调用支付宝进行退款 - err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ + err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{ Config: struct { PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` diff --git a/app/admin/svc/enterprise_manage/svc_self_support_for_school.go b/app/admin/svc/enterprise_manage/svc_self_support_for_school.go index 4b937c5..0f1be0b 100644 --- a/app/admin/svc/enterprise_manage/svc_self_support_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_self_support_for_school.go @@ -1306,9 +1306,9 @@ func SelfSupportForSchoolOrdRefund(req md.SelfSupportForSchoolOrdRefundReq) (err return err } - sysCfgDb := db.SysCfgDb{} - sysCfgDb.Set() - sysCfg := sysCfgDb.SysCfgFindWithDb(enum2.OpenAlipayAppid, enum2.OpenAlipayAppPrivateKey, enum2.OpenAlipayPublicKey) + //sysCfgDb := db.SysCfgDb{} + //sysCfgDb.Set() + //sysCfg := sysCfgDb.SysCfgFindWithDb(enum2.OpenAlipayAppid, enum2.OpenAlipayAppPrivateKey, enum2.OpenAlipayPublicKey) companyWithAlipayAppAuthTokenDb := db.CompanyWithAlipayAppAuthTokenDb{} companyWithAlipayAppAuthTokenDb.Set() @@ -1333,20 +1333,11 @@ func SelfSupportForSchoolOrdRefund(req md.SelfSupportForSchoolOrdRefundReq) (err //2、支付宝进行退款 err1, _ = 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[enum2.OpenAlipayAppid], - PayAliPrivateKey: sysCfg[enum2.OpenAlipayAppPrivateKey], - PayAliPublicKey: sysCfg[enum2.OpenAlipayPublicKey], - }, - OutTradeNo: v.OutOrderNo, - RefundAmount: v.TradeAmount, - RefundReason: "刷脸就餐-退款", - OutRequestNo: utils.OrderUUID(v.Uid), - AppAuthToken: companyWithAlipayAppAuthToken.AppAuthToken, + OutOrderNo: v.OutOrderNo, + RefundAmount: v.TradeAmount, + RefundReason: "刷脸就餐-退款", + RefundOutOrderNo: utils.OrderUUID(v.Uid), + MerchantCode: v.CpMerchantId, }) if err1 != nil { return err1 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 a6c9fb4..ab6e8b3 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 @@ -350,7 +350,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch //调用支付宝进行退款 for k, v := range dealReturnOrdMap { - err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ + err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{ Config: struct { PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` diff --git a/app/admin/svc/order/svc_nursing_home_package_ord.go b/app/admin/svc/order/svc_nursing_home_package_ord.go index 081ca07..f10bbc4 100644 --- a/app/admin/svc/order/svc_nursing_home_package_ord.go +++ b/app/admin/svc/order/svc_nursing_home_package_ord.go @@ -128,7 +128,7 @@ func NursingHomeOrderRefundAudit(req md.NursingHomeOrderRefundAuditReq) (err err userWithDay.State = enum.NursingHomeUserWithDayStateForCancel time.Sleep(250 * time.Millisecond) //TODO::避免频繁调用 //调用支付宝进行退款 - err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ + err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{ Config: struct { PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` diff --git a/app/customer/md/md_curl_smart_pay.go b/app/customer/md/md_curl_smart_pay.go index 697b23c..1185fbd 100644 --- a/app/customer/md/md_curl_smart_pay.go +++ b/app/customer/md/md_curl_smart_pay.go @@ -57,7 +57,7 @@ type CurlAlipayTradeQueryResp struct { TradeStatus string `json:"trade_status" label:"交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)"` } -type CurlAlipayTradeRefundReq struct { +type OldCurlAlipayTradeRefundReq struct { Config struct { PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` @@ -70,6 +70,14 @@ type CurlAlipayTradeRefundReq struct { AppAuthToken string `json:"app_auth_token" binding:"required" label:"应用授权token"` } +type CurlAlipayTradeRefundReq struct { + OutOrderNo string `json:"out_order_no" label:"商户订单号"` + MerchantCode string `json:"merchant_code" label:"商户编号"` + RefundOutOrderNo string `json:"refund_out_order_no" label:"退款订单号"` + RefundAmount string `json:"refund_amount" label:"退款金额"` + RefundReason string `json:"refund_reason" label:"退款原因"` +} + type CurlAlipayTradeRefundQueryReq struct { Config struct { PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` diff --git a/app/customer/svc/svc_curl_smart_pay.go b/app/customer/svc/svc_curl_smart_pay.go index 8c6be1a..8a01f0b 100644 --- a/app/customer/svc/svc_curl_smart_pay.go +++ b/app/customer/svc/svc_curl_smart_pay.go @@ -135,7 +135,7 @@ func CurlAlipayTradeQuery(args md.CurlAlipayTradeQueryReq) (err error, resp md.C return } -func CurlAlipayTradeRefund(args md.CurlAlipayTradeRefundReq) (err error, resp interface{}) { +func OldCurlAlipayTradeRefund(args md.OldCurlAlipayTradeRefundReq) (err error, resp interface{}) { url := cfg.SmartCanteenPay + "/alipay/pay/tradeRefund" utils.FilePutContents("CurlAlipayTradeRefund", utils.SerializeStr(map[string]interface{}{ "args": args, @@ -165,6 +165,36 @@ func CurlAlipayTradeRefund(args md.CurlAlipayTradeRefundReq) (err error, resp in return nil, result.Data } +func CurlAlipayTradeRefund(args md.CurlAlipayTradeRefundReq) (err error, resp interface{}) { + url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiTradeRefund" + utils.FilePutContents("CurlAlipayTradeRefund", utils.SerializeStr(map[string]interface{}{ + "args": args, + })) + bytes, err := utils.CurlPost(url, utils.Serialize(args), nil) + if err != nil { + return + } + var result struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data interface{} `json:"data"` + } + utils.FilePutContents("CurlAlipayTradeRefund", utils.SerializeStr(result)) + err = json.Unmarshal(bytes, &result) + if err != nil { + return + } + if result.Code != 0 { + if result.Msg != "" { + err = errors.New(result.Msg) + return + } + err = errors.New("请求智慧餐厅支付 异常/失败") + return + } + return nil, result.Data +} + func CurlAlipayTradeRefundQuery(args md.CurlAlipayTradeRefundQueryReq) (err error, resp interface{}) { url := cfg.SmartCanteenPay + "/alipay/pay/tradeRefundQuery" utils.FilePutContents("CurlAlipayTradeRefundQuery", utils.SerializeStr(map[string]interface{}{