@@ -95,7 +95,7 @@ func Demo(c *gin.Context) { | |||||
sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAlipayAppid, enum.OpenAlipayAppPrivateKey, enum.OpenAlipayPublicKey) | sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAlipayAppid, enum.OpenAlipayAppPrivateKey, enum.OpenAlipayPublicKey) | ||||
//调用支付宝进行退款 | //调用支付宝进行退款 | ||||
err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ | |||||
err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{ | |||||
Config: struct { | Config: struct { | ||||
PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | ||||
PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` | PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` | ||||
@@ -1306,9 +1306,9 @@ func SelfSupportForSchoolOrdRefund(req md.SelfSupportForSchoolOrdRefundReq) (err | |||||
return 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 := db.CompanyWithAlipayAppAuthTokenDb{} | ||||
companyWithAlipayAppAuthTokenDb.Set() | companyWithAlipayAppAuthTokenDb.Set() | ||||
@@ -1333,20 +1333,11 @@ func SelfSupportForSchoolOrdRefund(req md.SelfSupportForSchoolOrdRefundReq) (err | |||||
//2、支付宝进行退款 | //2、支付宝进行退款 | ||||
err1, _ = svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ | 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 { | if err1 != nil { | ||||
return err1 | return err1 | ||||
@@ -350,7 +350,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch | |||||
//调用支付宝进行退款 | //调用支付宝进行退款 | ||||
for k, v := range dealReturnOrdMap { | for k, v := range dealReturnOrdMap { | ||||
err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ | |||||
err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{ | |||||
Config: struct { | Config: struct { | ||||
PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | ||||
PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` | PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` | ||||
@@ -128,7 +128,7 @@ func NursingHomeOrderRefundAudit(req md.NursingHomeOrderRefundAuditReq) (err err | |||||
userWithDay.State = enum.NursingHomeUserWithDayStateForCancel | userWithDay.State = enum.NursingHomeUserWithDayStateForCancel | ||||
time.Sleep(250 * time.Millisecond) //TODO::避免频繁调用 | time.Sleep(250 * time.Millisecond) //TODO::避免频繁调用 | ||||
//调用支付宝进行退款 | //调用支付宝进行退款 | ||||
err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ | |||||
err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{ | |||||
Config: struct { | Config: struct { | ||||
PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | ||||
PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` | PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` | ||||
@@ -57,7 +57,7 @@ type CurlAlipayTradeQueryResp struct { | |||||
TradeStatus string `json:"trade_status" label:"交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)"` | TradeStatus string `json:"trade_status" label:"交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)"` | ||||
} | } | ||||
type CurlAlipayTradeRefundReq struct { | |||||
type OldCurlAlipayTradeRefundReq struct { | |||||
Config struct { | Config struct { | ||||
PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | ||||
PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"` | 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"` | 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 { | type CurlAlipayTradeRefundQueryReq struct { | ||||
Config struct { | Config struct { | ||||
PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"` | ||||
@@ -135,7 +135,7 @@ func CurlAlipayTradeQuery(args md.CurlAlipayTradeQueryReq) (err error, resp md.C | |||||
return | 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" | url := cfg.SmartCanteenPay + "/alipay/pay/tradeRefund" | ||||
utils.FilePutContents("CurlAlipayTradeRefund", utils.SerializeStr(map[string]interface{}{ | utils.FilePutContents("CurlAlipayTradeRefund", utils.SerializeStr(map[string]interface{}{ | ||||
"args": args, | "args": args, | ||||
@@ -165,6 +165,36 @@ func CurlAlipayTradeRefund(args md.CurlAlipayTradeRefundReq) (err error, resp in | |||||
return nil, result.Data | 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{}) { | func CurlAlipayTradeRefundQuery(args md.CurlAlipayTradeRefundQueryReq) (err error, resp interface{}) { | ||||
url := cfg.SmartCanteenPay + "/alipay/pay/tradeRefundQuery" | url := cfg.SmartCanteenPay + "/alipay/pay/tradeRefundQuery" | ||||
utils.FilePutContents("CurlAlipayTradeRefundQuery", utils.SerializeStr(map[string]interface{}{ | utils.FilePutContents("CurlAlipayTradeRefundQuery", utils.SerializeStr(map[string]interface{}{ | ||||