fix(supplier): 修复并优化第三方卡密发送相关代码

- 调整jinke支付回调测试用例中的请求参数及地址
- 将nuclear支付相关host信息动态替换为请求URL中的host
- 修复SendCardTaskTypeNuclear中判断域名包含问题,放宽匹配条件
- 在camel测试中打印更多请求数据便于调试
- 删除favorable_clouds中无用TODO注释
- jinke测试中添加解析URL测试函数
- 统一了pay50.baolong18080.com域名的代码判断逻辑为baolong18080.com域名匹配
This commit is contained in:
danial
2025-12-14 01:19:56 +08:00
parent 5d0c3d80c4
commit d0da121174
5 changed files with 34 additions and 23 deletions

View File

@@ -214,7 +214,6 @@ func (c *FavorableCloudsCardImpl) PayNotify() {
} else {
isOk = service.SolvePayFail(ctx, orderInfo.BankOrderId, orderInfo.BankOrderId, fmt.Sprintf("金额不一致 卡面金额:%.2f 实际金额:%.2f", orderInfo.OrderAmount, amount))
}
// TODO 订单支付成功
if isOk {
c.Ctx.WriteString("success")
} else {

View File

@@ -41,5 +41,5 @@ func TestSendCardTaskTypeCamel_sign(t *testing.T) {
createdOrderUrl := "http://47.243.53.92:8089/api/pay/create_order"
response, err := client.R().SetContext(t.Context()).SetFormData(formData).Post(createdOrderUrl)
t.Log(response.String(), err)
t.Log(formData, response.String(), err)
}

View File

@@ -139,7 +139,7 @@ func (s *SendCardTaskTypeJinke) HandleSendCardTask(ctx context.Context, orderIte
if strings.Contains(orderItem.PayURL, "alsopay.wtrpay.xyz") {
return (&SendCardTaskTypeWtr{}).HandleSendCardTask(ctx, orderItem, task)
}
if strings.Contains(orderItem.PayURL, "pay50.baolong18080.com") {
if strings.Contains(orderItem.PayURL, "baolong18080.com") {
return (&SendCardTaskTypeNuclear{}).HandleSendCardTask(ctx, orderItem, task)
}
if strings.Contains(orderItem.PayURL, "apiss.fkpay.online") {

View File

@@ -5,8 +5,8 @@ import (
"fmt"
"gateway/internal/config"
"gateway/internal/otelTrace"
"gateway/internal/service/supplier"
"gateway/internal/utils"
"net/url"
"testing"
"time"
@@ -21,6 +21,12 @@ func TestSendCardTaskTypeJinke_CreateOrder(t *testing.T) {
webClient := resty.New().SetTimeout(time.Second * 5).SetRetryCount(3)
otelresty.TraceClient(webClient)
//{
//"mchId":"1064",
//"productId":"112",
//"key":"jkk4jawlJpCXK7Zew62ATNE"
//}
orderId := utils.GenerateId()
reqData := struct {
MchId string `json:"mchId"`
@@ -31,8 +37,8 @@ func TestSendCardTaskTypeJinke_CreateOrder(t *testing.T) {
NotifyUrl string `json:"notifyUrl"`
Sign string `json:"sign,omitempty"`
}{
MchId: "1260",
ProductId: "tb11",
MchId: "1064",
ProductId: "112",
OutTradeNo: orderId,
Amount: 30 * 100,
ReqTime: time.Now().UnixMilli(),
@@ -40,8 +46,8 @@ func TestSendCardTaskTypeJinke_CreateOrder(t *testing.T) {
Sign: "",
}
params, _ := structs.ToMap(reqData)
reqData.Sign = (&SendCardTaskTypeJinke{}).sign(params, maputil.Keys(params), "jkkkPaOmM5gB3FTaCMxJcB8")
response, _ := webClient.R().SetBody(reqData).Post("https://jkapi-jihu.jknba.com/api/v1/pay/unifiedOrder")
reqData.Sign = (&SendCardTaskTypeJinke{}).sign(params, maputil.Keys(params), "jkk4jawlJpCXK7Zew62ATNE")
response, _ := webClient.R().SetBody(reqData).Post("https://jkapi-aibi-shagquw.jknba.com/api/v1/pay/unifiedOrder")
responseData := &struct {
Code int `json:"code"`
Message string `json:"message"`
@@ -66,15 +72,21 @@ func TestSendCardTaskTypeJinke_CreateOrder(t *testing.T) {
return
}
(&SendCardTaskTypeJinke{}).channelOne(t.Context(), OrderPoolItem{
OrderID: responseData.Data.TradeNo,
PayURL: responseData.Data.PayUrl,
RemoteOrderID: responseData.Data.OutTradeNo,
}, SendCardTask{
CardInfo: supplier.RedeemCardInfo{
CardNo: "417002500614",
Data: "123456",
FaceType: "1",
},
})
//(&SendCardTaskTypeJinke{}).channelOne(t.Context(), OrderPoolItem{
// OrderID: responseData.Data.TradeNo,
// PayURL: responseData.Data.PayUrl,
// RemoteOrderID: responseData.Data.OutTradeNo,
//}, SendCardTask{
// CardInfo: supplier.RedeemCardInfo{
// CardNo: "417002500614",
// Data: "123456",
// FaceType: "1",
// },
//})
}
func TestSendCardTaskTypeJinke_QueryOrder(t *testing.T) {
urlP := "https://pay11.baolong18080.com/pay/PxyAlai/payment?oid=BL20251214011348297436"
result, err := url.Parse(urlP)
t.Log(result, err)
}

View File

@@ -231,7 +231,7 @@ func (s *SendCardTaskTypeNuclear) channelOne(ctx context.Context, orderItem Orde
errRes = nil
webClient := resty.New().SetTimeout(10 * time.Second).SetHeaders(map[string]string{
"user-agent": useragent.GetUserAgentByPlatform(useragent.PlatformPhone),
"origin": "pay50.baolong18080.com",
"origin": queryOrderInfo.Host,
"referer": orderItem.PayURL,
})
otelresty.TraceClient(webClient)
@@ -252,7 +252,7 @@ func (s *SendCardTaskTypeNuclear) channelOne(ctx context.Context, orderItem Orde
"oe": orderId,
"seed": strconv.FormatFloat(rand.Float64(), 'f', -1, 64),
}).
Get("https://pay50.baolong18080.com/pay/index/captcha.html")
Get(queryOrderInfo.Scheme + "://" + queryOrderInfo.Host + "/pay/index/captcha.html")
span.AddEvent("finishGetCaptcha")
//设置cookie
@@ -296,7 +296,7 @@ func (s *SendCardTaskTypeNuclear) channelOne(ctx context.Context, orderItem Orde
}
resp, err5 := webClient.R().SetContext(ctx).SetBody(bodyData).
SetQueryParam("oe", orderId).Post("https://pay50.baolong18080.com/pay/PxyAlai/setParams")
SetQueryParam("oe", orderId).Post(queryOrderInfo.Scheme + "://" + queryOrderInfo.Host + "/pay/PxyAlai/setParams")
span.AddEvent("finishSubmitData")
//重置验证码
@@ -449,7 +449,7 @@ func (s *SendCardTaskTypeNuclear) channelThree(ctx context.Context, orderItem Or
}
func (s *SendCardTaskTypeNuclear) HandleSendCardTask(ctx context.Context, orderItem OrderPoolItem, task SendCardTask) error {
if strings.Contains(orderItem.PayURL, "pay50.baolong18080.com") {
if strings.Contains(orderItem.PayURL, "baolong18080.com") {
return s.channelOne(ctx, orderItem, task)
}
if strings.Contains(orderItem.PayURL, "yosyt.hy32.top") {