fix(internal/service/supplier/third_party/init): 新增 FAVORABLE_CLOUDS 供应商名称映射
- 在供应商名称映射中新增 "FAVORABLE_CLOUDS" 对应的 "祥云核销平台" 名称,确保与最新业务需求一致。 fix(internal/service/supplier/third_party/favorable_clouds.go): 增强 PayNotify 方法的日志记录 - 在 PayNotify 方法中新增日志记录,记录回调数据以便于调试和监控。 fix(internal/service/supplier/third_party/favorable_clouds.go): 增强生成签名和支付通知的日志记录 - 在生成签名方法中新增日志记录,便于调试签名生成过程。 - 在 PayNotify 方法中移除冗余的 ClientUserPayRemark 字段,简化请求结构体。 fix(internal/service/supplier/third_party/favorable_clouds.go): 移除生成签名方法中的冗余参数 - 在 generateFavorableCloudsSign 方法中删除了不必要的 "sign" 参数,简化了签名生成逻辑。 fix(internal/service/supplier/third_party/favorable_clouds.go): 简化生成签名方法中的参数处理 - 在 generateFavorableCloudsSign 方法中移除了冗余的 "sign" 参数删除操作,优化了代码逻辑。 fix(internal/service/pay_solve.go): 修复上下文传递方式以提升代码稳定性 - 在 SolvePaySuccess 方法中,将上下文参数从父上下文修改为使用 context.Background(),确保在创建订单通知时的上下文独立性。 fix(internal/service/supplier/third_party/init.go): 更新 FAVORABLE_CLOUDS 供应商名称映射 - 将 "FAVORABLE_CLOUDS" 的名称从 "祥云核销平台" 修改为 "艾彼核销平台",以符合最新的业务需求。 fix(internal/service/supplier/third_party/init.go): 更新 Heepay 供应商名称映射 - 将 "Heepay" 的名称从 "汇付宝核销平台" 修改为 "俊卡官方接口",以符合最新的业务需求。 fix(internal/service/supplier/third_party/qixi.go): 修复 SendCard 方法返回值以提供更准确的消息 - 在 SendCard 方法中,将返回的响应信息从原始的 response 修改为 resData.Message,以确保返回的消息更具可读性和准确性。 fix(internal/service/supplier/third_party/qixi.go): 移除 PayNotify 方法中的冗余日志记录 - 在 PayNotify 方法中移除了不必要的回调数据日志记录,以简化代码并提高可读性。 fix(internal/service/supplier/third_party): 统一错误提示信息格式 - 在多个供应商的 Scan 方法中,将错误提示信息中的 "订单有有误" 统一修改为 "订单有误",以提升用户体验和一致性。 - 移除了冗余的注释代码,简化了代码结构。 fix(internal/dto/order_test.go, internal/service/base_service.go, internal/service/supplier/third_party/walmart_self.go): 更新订单测试和移除冗余代码 - 在订单测试中更新了参数生成逻辑,使用具体的测试数据替代注释代码,增强了测试的有效性。 - 移除了 base_service.go 中的 GetMerchantInfoByUID 方法,简化了代码结构。 - 在 walmart_self.go 中优化了日志记录,增强了请求参数和回调参数的日志输出,提升了调试能力。 fix(internal/controllers/gateway): 在订单和扫描控制器中添加空行以提升代码可读性 fix(internal/models/merchant_deploy): 修复获取单一路径平台费率映射的逻辑 - 将获取费率映射时使用的键从 "FactLabel" 修改为 "ShowLabel",确保映射的正确性。 fix(internal/models/merchant_deploy): 在 CheckSingleRoadPlatformRate 方法中添加空行以提升代码可读性 fix(internal/models/merchant_deploy, internal/service/pay_service): 优化费率检查逻辑 - 在 MerchantDeployInfo 中简化 CheckSingleRoadPlatformRate 方法的实现。 - 在 ChooseRoadV2 方法中同时检查单一路径和滚动路径平台费率,确保面额的有效性。 fix(internal/service/supplier/third_party/eggplant): 更新 Eggplant 测试用例和请求参数 - 移除了旧的 SendCard 测试代码,增加了新的 channelTwo 测试用例,使用 httplib 发送 POST 请求。 - 在 channelTwo 方法中,设置了请求头和参数,确保请求格式正确。 fix(internal/service/supplier/third_party/eggplant): 在 channelTwo 方法中添加调试请求和请求体 - 在 channelTwo 方法中增加了对调试请求的支持,使用 httplib 发送 GET 请求以便于调试。 - 设置了请求体,确保 POST 请求的参数格式正确,增强了请求的有效性。 fix(internal/service/supplier/third_party/eggplant): 移除 channelTwo 方法中的调试请求 - 在 channelTwo 方法中移除了对调试请求的支持,简化了代码逻辑。 fix(internal/service/supplier/third_party/eggplant): 在 channelTwo 方法中使用 netutil 发送请求并处理响应 - 将 channelTwo 方法中的请求逻辑从 httplib 替换为 netutil,简化了请求构建过程。 - 增强了错误处理,添加了对响应体的读取和解析,确保请求成功时能正确记录响应信息。 fix(internal/service/supplier/third_party/eggplant): 在 channelTwo 方法中使用 httplib 发送请求并处理响应 - 将 channelTwo 方法中的请求逻辑从 netutil 替换为 httplib,简化了请求构建过程。 - 增强了错误处理,添加了对请求参数和解析结果的日志记录,确保请求成功时能正确记录响应信息。
This commit is contained in:
@@ -101,6 +101,7 @@ func (c *OrderController) MerchantQuery() {
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
tmpSign := utils.GetMD5SignMF(map[string]any{
|
||||
"appKey": appKey,
|
||||
"orderNo": orderNo,
|
||||
@@ -120,6 +121,7 @@ func (c *OrderController) MerchantQuery() {
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
orderInfo := order.GetOrderByMerchantOrderId(ctx, orderNo)
|
||||
if orderInfo.Id == 0 {
|
||||
resp := response.Resp{
|
||||
@@ -130,6 +132,7 @@ func (c *OrderController) MerchantQuery() {
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
exValue, err := sonic.GetFromString(orderInfo.ExValue)
|
||||
if err != nil {
|
||||
resp := response.Resp{
|
||||
@@ -140,6 +143,7 @@ func (c *OrderController) MerchantQuery() {
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
cardNo, _ := exValue.Get("cardNo").String()
|
||||
cardPwd, _ := exValue.Get("data").String()
|
||||
_ = c.JSONResp(response.Resp{
|
||||
|
||||
@@ -75,6 +75,7 @@ func (c *ScanController) Scan() {
|
||||
attribute.String("sign", p.Params["sign"].(string)),
|
||||
))
|
||||
defer cancel()
|
||||
|
||||
if p.Code == -1 {
|
||||
c.SolveFailJSON(p)
|
||||
return
|
||||
@@ -230,6 +231,7 @@ func (c *ScanController) Scan() {
|
||||
c.StopRun()
|
||||
return
|
||||
}
|
||||
|
||||
otelTrace.Logger.WithContext(ctx).Info("【BaseGateway】获取到对应的上游", zap.Any("supplierByCode", supplierByCode), zap.String("supplierCode", supplierCode))
|
||||
|
||||
hiddenCfg := service.GetOrderHidden(ctx, &orderInfo)
|
||||
@@ -250,13 +252,6 @@ func (c *ScanController) Scan() {
|
||||
if err2 = service.CreateRelateHideOrderRecord(ctx, newBankOrderId, &orderInfo, hiddenCfg, delayDuration); err2 != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("添加订单关联失败【偷卡2】", zap.Error(err2))
|
||||
}
|
||||
//错误订单回调上游
|
||||
//oldBankOrderId := orderInfo.BankOrderId
|
||||
//delayPool.Go(func() {
|
||||
// ctx2, span := otelTrace.NewSchedulerTrace().Start(ctx, "Span", trace.WithNewRoot())
|
||||
// defer span.End()
|
||||
// service.SolvePayFail(ctx2, oldBankOrderId, orderInfo.BankTransId, hiddenCfg.ExtraReturnInfo)
|
||||
//})
|
||||
orderInfo.BankOrderId = newBankOrderId
|
||||
}
|
||||
//2.新的错误记录
|
||||
|
||||
@@ -15,18 +15,18 @@ import (
|
||||
)
|
||||
|
||||
func TestParams_Encrypt(t *testing.T) {
|
||||
//orderParams := Params{
|
||||
// GeneratedTime: time.Now().Unix(),
|
||||
// Duration: 24,
|
||||
// PayKey: "kkkkc9kit6bimggos5kk0100",
|
||||
// OrderNo: "1234556",
|
||||
// ProductCode: "6688",
|
||||
// ShowMMValue: 100,
|
||||
// NotifyUrl: "http://121.37.253.228:12307/",
|
||||
//}
|
||||
//p, _ := formatter.Pretty(orderParams)
|
||||
//otel.Logger.WithContext(c.Ctx.Request.Context()).Info(p, "https://shop.kkknametrans.buzz/?sign="+orderParams.Encrypt())
|
||||
|
||||
orderParams := Params{
|
||||
GeneratedTime: 1745838830,
|
||||
Duration: 24,
|
||||
PayKey: "kkkkcvf8e9bl5mqs739h2j3g",
|
||||
OrderNo: "FF6704071815701178777",
|
||||
ProductCode: "8700",
|
||||
ShowMMValue: 100.00,
|
||||
NotifyUrl: "https://localhost:44311/api/services/app/BPlatCallback/Callback_DMMWuDiBaoBao",
|
||||
}
|
||||
otelTrace.Logger.WithContext(otelTrace.InitCtx).Info(orderParams.Encrypt())
|
||||
p, _ := formatter.Pretty(orderParams)
|
||||
otelTrace.Logger.WithContext(otelTrace.InitCtx).Info(p)
|
||||
main()
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ import (
|
||||
"fmt"
|
||||
"gateway/internal/otelTrace"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MerchantDeployInfo struct {
|
||||
@@ -55,7 +56,7 @@ func (m *MerchantDeployInfo) GetSingleRoadPlatformRateMapping() (map[float64]flo
|
||||
err := json.Unmarshal([]byte(m.SingleRoadPlatformRate), &ms)
|
||||
|
||||
for i := range ms {
|
||||
myMap[ms[i].FactLabel] = ms[i].Value
|
||||
myMap[ms[i].ShowLabel] = ms[i].Value
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -119,12 +120,13 @@ func (m *MerchantDeployInfo) CheckSingleRoadPlatformRate(price float64) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
for k := range mapping {
|
||||
if k == price {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
_, ok := mapping[price]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (m *MerchantDeployInfo) CheckRollRoadPlatformRate(ctx context.Context, price float64) bool {
|
||||
_, err := m.GetShowMMValue(ctx, price)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
const MERCHANT_DEPLOY_INFO = "merchant_deploy_info"
|
||||
|
||||
@@ -17,23 +17,6 @@ import (
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// GetMerchantInfoByUID 获取商户信息
|
||||
func GetMerchantInfoByUID(ctx context.Context, params map[string]any) *response.PayBaseResp {
|
||||
c := new(response.PayBaseResp)
|
||||
c.Params = make(map[string]any)
|
||||
c.Params = params
|
||||
merchantInfo := merchant.GetMerchantByUid(ctx, convertor.ToString(params["MerchantUid"]))
|
||||
if merchantInfo.MerchantUid == "" || len(merchantInfo.MerchantUid) == 0 {
|
||||
c.Code = -1
|
||||
c.Msg = "商户不存在,或者paykey有误,请联系管理员"
|
||||
} else if merchantInfo.Status != config.ACTIVE {
|
||||
c.Code = -1
|
||||
c.Msg = "商户状态已经被冻结或者被删除,请联系管理员!"
|
||||
} else {
|
||||
c.MerchantInfo = merchantInfo
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// GetMerchantInfoByPayKey 通过payKey获取商户信息
|
||||
func GetMerchantInfoByPayKey(ctx context.Context, payKey string) (merchantInfo merchant.MerchantInfo, err error) {
|
||||
|
||||
@@ -58,11 +58,13 @@ func ChooseRoadV2(ctx context.Context, c *response.PayBaseResp) *response.PayBas
|
||||
c.Msg = "当前通道面额存在问题"
|
||||
return c
|
||||
}
|
||||
if !deployInfo.CheckSingleRoadPlatformRate(orderPrice) {
|
||||
|
||||
if !deployInfo.CheckSingleRoadPlatformRate(orderPrice) && !deployInfo.CheckRollRoadPlatformRate(ctx, orderPrice) {
|
||||
c.Code = -1
|
||||
c.Msg = "当前面额不被允许"
|
||||
return c
|
||||
}
|
||||
|
||||
c.RoadInfo = roadInfo
|
||||
c.PlatformRate = rate
|
||||
c.AgentRate = deployInfo.SingleRoadAgentRate
|
||||
|
||||
@@ -174,7 +174,7 @@ func SolvePaySuccess(ctx context.Context, bankOrderId string, factAmount float64
|
||||
})
|
||||
orderNotify.Go(func() {
|
||||
// 创建一个5分钟超时的上下文
|
||||
ctx2, span := otelTrace.NewSchedulerTrace().Start(ctx, "SolvePaySuccess", trace.WithNewRoot())
|
||||
ctx2, span := otelTrace.NewSchedulerTrace().Start(context.Background(), "SolvePaySuccess", trace.WithNewRoot())
|
||||
defer span.End()
|
||||
CreateOrderNotifyInfo(ctx2, bankOrderId, config.SUCCESS)
|
||||
})
|
||||
|
||||
13
internal/service/supplier/third_party/aibo.go
vendored
13
internal/service/supplier/third_party/aibo.go
vendored
@@ -18,6 +18,11 @@ import (
|
||||
"gateway/internal/service"
|
||||
"gateway/internal/service/supplier"
|
||||
"gateway/internal/utils"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/httplib"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/bytedance/sonic"
|
||||
@@ -28,10 +33,6 @@ import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.uber.org/zap"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AiboCardImpl struct {
|
||||
@@ -110,14 +111,14 @@ func (c *AiboCardImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, road
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
|
||||
@@ -161,7 +161,7 @@ func (c *AppleCardImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roa
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId, orderInfo.MerchantOrderId)
|
||||
var scanData supplier.ScanData
|
||||
|
||||
@@ -127,14 +127,14 @@ func (c *AppleCardSharkImpl) Scan(ctx context.Context, orderInfo order.OrderInfo
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId, orderInfo.MerchantOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
|
||||
@@ -117,14 +117,14 @@ func (c *CTripSelfImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roa
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId, orderInfo.MerchantOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
|
||||
224
internal/service/supplier/third_party/eggplant.go
vendored
224
internal/service/supplier/third_party/eggplant.go
vendored
@@ -19,6 +19,7 @@ import (
|
||||
"gateway/internal/utils"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -27,6 +28,7 @@ import (
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/duke-git/lancet/v2/convertor"
|
||||
"github.com/duke-git/lancet/v2/strutil"
|
||||
"github.com/widuu/gojson"
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
@@ -43,6 +45,146 @@ func (c *EggplantImpl) HasDependencyHTML() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type eggplantProductCode struct {
|
||||
ProductCode string `json:"productCode"`
|
||||
ForwoardUrl string `json:"forwoardUrl"`
|
||||
CardNo string `json:"cardNo"`
|
||||
CardPassword string `json:"cardPassword"`
|
||||
}
|
||||
|
||||
func (c *eggplantProductCode) SendData(ctx context.Context, forwardUrl *url.URL) (bool, string, string) {
|
||||
// 发送数据
|
||||
// 通道1
|
||||
chnnalOneCodeArray := []string{"8055", "8076", "8055"}
|
||||
if slices.Contains(chnnalOneCodeArray, strutil.Trim(c.ProductCode)) {
|
||||
return c.channelOne(ctx, forwardUrl)
|
||||
}
|
||||
// 通道2
|
||||
chnnalTwoCodeArray := []string{"8069"}
|
||||
if slices.Contains(chnnalTwoCodeArray, strutil.Trim(c.ProductCode)) {
|
||||
return c.channelTwo(ctx, forwardUrl)
|
||||
}
|
||||
return false, "通道不存在", ""
|
||||
}
|
||||
|
||||
// 第一个通道
|
||||
func (c *eggplantProductCode) channelOne(ctx context.Context, forwardUrl *url.URL) (bool, string, string) {
|
||||
// 获取数据 通道编码 8055
|
||||
req := httplib.NewBeegoRequestWithCtx(ctx, "https://api.djfkm.xyz/api/order/getOrderById", "GET").SetTransport(otelhttp.NewTransport(http.DefaultTransport)).
|
||||
SetTimeout(time.Second*30, time.Second*30).Retries(3)
|
||||
|
||||
req.Param("id", forwardUrl.Query().Get("orderId"))
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("获取订单接口失败", zap.Error(err))
|
||||
return false, "内部数据处理失败", ""
|
||||
}
|
||||
|
||||
var orderGetOrderByIdResp struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
ID int `json:"id"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
TraceNo string `json:"traceNo"`
|
||||
ChannelCode string `json:"channelCode"`
|
||||
ChannelName string `json:"channelName"`
|
||||
Amount float64 `json:"amount"`
|
||||
OrderTime string `json:"orderTime"`
|
||||
WarnNotes string `json:"warnNotes"`
|
||||
ShopPayTimeout string `json:"shopPayTimeout"`
|
||||
OrderStatus string `json:"orderStatus"`
|
||||
JumpUrl int `json:"jumpUrl"`
|
||||
} `json:"data"`
|
||||
}
|
||||
err = json.Unmarshal([]byte(response), &orderGetOrderByIdResp)
|
||||
otelTrace.Logger.WithContext(ctx).Info("获取订单接口", zap.Any("response", response), zap.Any("解析结果", orderGetOrderByIdResp))
|
||||
if orderGetOrderByIdResp.Code != 200 {
|
||||
return false, orderGetOrderByIdResp.Msg, ""
|
||||
}
|
||||
|
||||
req = httplib.NewBeegoRequestWithCtx(ctx, "https://api.djfkm.xyz/api/order/shopSubCard", "POST").
|
||||
SetTransport(otelhttp.NewTransport(http.DefaultTransport)).
|
||||
SetTimeout(time.Second*30, time.Second*30).Retries(3)
|
||||
|
||||
jsonBody := struct {
|
||||
OrderId string `json:"orderId"`
|
||||
TraceNo string `json:"traceNo"`
|
||||
Amount int `json:"amount"`
|
||||
ChannelName string `json:"channelName"`
|
||||
ChannelCode string `json:"channelCode"`
|
||||
CardNo string `json:"cardNo"`
|
||||
CardPassword string `json:"cardPassword"`
|
||||
}{
|
||||
OrderId: forwardUrl.Query().Get("orderId"),
|
||||
TraceNo: orderGetOrderByIdResp.Data.TraceNo,
|
||||
Amount: int(orderGetOrderByIdResp.Data.Amount),
|
||||
ChannelName: orderGetOrderByIdResp.Data.ChannelName,
|
||||
ChannelCode: orderGetOrderByIdResp.Data.ChannelCode,
|
||||
CardNo: c.CardNo,
|
||||
CardPassword: c.CardPassword,
|
||||
}
|
||||
|
||||
req, err = req.JSONBody(jsonBody)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("json序列化失败", zap.Error(err))
|
||||
return false, "内部数据处理失败", ""
|
||||
}
|
||||
|
||||
var respData struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
err = req.ToJSON(&respData)
|
||||
otelTrace.Logger.WithContext(ctx).Info("提交卡密接口", zap.Any("解析结果", respData), zap.Any("jsonBody", jsonBody))
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("json解析失败", zap.Error(err))
|
||||
return false, "内部数据处理失败", ""
|
||||
}
|
||||
if respData.Code != 200 {
|
||||
return false, respData.Msg, ""
|
||||
}
|
||||
return true, respData.Msg, ""
|
||||
}
|
||||
|
||||
// 第二个通道
|
||||
func (c *eggplantProductCode) channelTwo(ctx context.Context, forwardUrl *url.URL) (bool, string, string) {
|
||||
req := httplib.NewBeegoRequestWithCtx(ctx, "http://13.212.74.251:3767/pay", "POST").
|
||||
SetTransport(otelhttp.NewTransport(http.DefaultTransport)).
|
||||
SetTimeout(time.Second*30, time.Second*30).Retries(3).
|
||||
Header("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
req.Param("card_no", c.CardNo)
|
||||
req.Param("pass", c.CardPassword)
|
||||
req.Param("order_no", forwardUrl.Query().Get("orderId"))
|
||||
|
||||
// req.XMLBody(struct {
|
||||
// CardNo string `xml:"card_no"`
|
||||
// Pass string `xml:"pass"`
|
||||
// OrderNo string `xml:"order_no"`
|
||||
// }{
|
||||
// CardNo: c.CardNo,
|
||||
// Pass: c.CardPassword,
|
||||
// OrderNo: forwardUrl.Query().Get("orderId"),
|
||||
// })
|
||||
|
||||
var respData struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
err := req.ToJSON(&respData)
|
||||
otelTrace.Logger.WithContext(ctx).Info("提交卡密接口", zap.Any("请求参数", req.GetRequest().Form), zap.Any("解析结果", respData))
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("json解析失败", zap.Error(err))
|
||||
return false, "内部数据处理失败", ""
|
||||
}
|
||||
if respData.Code != 200 {
|
||||
return false, respData.Msg, ""
|
||||
}
|
||||
return true, respData.Msg, ""
|
||||
}
|
||||
|
||||
// 签名算法
|
||||
func (c *EggplantImpl) generateSign(ctx context.Context, params map[string]any, key string) string {
|
||||
keys := make([]string, 0, len(params))
|
||||
@@ -118,82 +260,16 @@ func (c *EggplantImpl) SendCard(ctx context.Context, jsonStr string, cardInfo su
|
||||
return false, "内部数据处理失败", ""
|
||||
}
|
||||
|
||||
req = httplib.NewBeegoRequestWithCtx(ctx, "https://api.djfkm.xyz/api/order/getOrderById", "GET").SetTransport(otelhttp.NewTransport(http.DefaultTransport)).
|
||||
SetTimeout(time.Second*30, time.Second*30).Retries(3)
|
||||
|
||||
req.Param("id", forwardUrl.Query().Get("orderId"))
|
||||
response, err = req.String()
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("获取订单接口失败", zap.Error(err))
|
||||
return false, "内部数据处理失败", ""
|
||||
}
|
||||
|
||||
var orderGetOrderByIdResp struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
ID int `json:"id"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
TraceNo string `json:"traceNo"`
|
||||
ChannelCode string `json:"channelCode"`
|
||||
ChannelName string `json:"channelName"`
|
||||
Amount float64 `json:"amount"`
|
||||
OrderTime string `json:"orderTime"`
|
||||
WarnNotes string `json:"warnNotes"`
|
||||
ShopPayTimeout string `json:"shopPayTimeout"`
|
||||
OrderStatus string `json:"orderStatus"`
|
||||
JumpUrl int `json:"jumpUrl"`
|
||||
} `json:"data"`
|
||||
}
|
||||
err = json.Unmarshal([]byte(response), &orderGetOrderByIdResp)
|
||||
otelTrace.Logger.WithContext(ctx).Info("获取订单接口", zap.Any("response", response), zap.Any("解析结果", orderGetOrderByIdResp))
|
||||
if orderGetOrderByIdResp.Code != 200 {
|
||||
return false, orderGetOrderByIdResp.Msg, ""
|
||||
}
|
||||
|
||||
req = httplib.NewBeegoRequestWithCtx(ctx, "https://api.djfkm.xyz/api/order/shopSubCard", "POST").
|
||||
SetTransport(otelhttp.NewTransport(http.DefaultTransport)).
|
||||
SetTimeout(time.Second*30, time.Second*30).Retries(3)
|
||||
|
||||
jsonBody := struct {
|
||||
OrderId string `json:"orderId"`
|
||||
TraceNo string `json:"traceNo"`
|
||||
Amount int `json:"amount"`
|
||||
ChannelName string `json:"channelName"`
|
||||
ChannelCode string `json:"channelCode"`
|
||||
CardNo string `json:"cardNo"`
|
||||
CardPassword string `json:"cardPassword"`
|
||||
}{
|
||||
OrderId: forwardUrl.Query().Get("orderId"),
|
||||
TraceNo: orderGetOrderByIdResp.Data.TraceNo,
|
||||
Amount: int(orderGetOrderByIdResp.Data.Amount),
|
||||
ChannelName: orderGetOrderByIdResp.Data.ChannelName,
|
||||
ChannelCode: orderGetOrderByIdResp.Data.ChannelCode,
|
||||
eggplantProductCodeInstance := &eggplantProductCode{
|
||||
CardNo: cardInfo.CardNo,
|
||||
CardPassword: cardInfo.Data,
|
||||
ProductCode: resData.Data.PayType,
|
||||
}
|
||||
|
||||
req, err = req.JSONBody(jsonBody)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("json序列化失败", zap.Error(err))
|
||||
return false, "内部数据处理失败", ""
|
||||
ok, str, _ := eggplantProductCodeInstance.SendData(ctx, forwardUrl)
|
||||
if !ok {
|
||||
return false, str, ""
|
||||
}
|
||||
|
||||
var respData struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
err = req.ToJSON(&respData)
|
||||
otelTrace.Logger.WithContext(ctx).Info("提交卡密接口", zap.Any("解析结果", respData), zap.Any("jsonBody", jsonBody))
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("json解析失败", zap.Error(err))
|
||||
return false, "内部数据处理失败", ""
|
||||
}
|
||||
if respData.Code != 200 {
|
||||
return false, respData.Msg, ""
|
||||
}
|
||||
|
||||
return true, resData.Data.ForwardUrl, ""
|
||||
return true, str, ""
|
||||
}
|
||||
|
||||
func (c *EggplantImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) supplier.ScanData {
|
||||
@@ -207,14 +283,14 @@ func (c *EggplantImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, road
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str, forwardUrl := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
|
||||
@@ -1,17 +1,38 @@
|
||||
package third_party
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gateway/internal/service/supplier"
|
||||
"gateway/internal/utils"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/httplib"
|
||||
)
|
||||
|
||||
func TestEggplantImpl_SendCard(t *testing.T) {
|
||||
eggplant := &EggplantImpl{}
|
||||
eggplant.SendCard(context.Background(), "{\"mid\":\"10142\",\"pay_type\":\"8055\",\"key\":\"34fbe3b5238923f74c13fe6d731abc1534fbe3b5238923f7\",\"url\":\"https://admin.djfkm.xyz\"}", supplier.RedeemCardInfo{
|
||||
FaceType: "100",
|
||||
CardNo: "1234567890",
|
||||
Data: "123456",
|
||||
}, utils.GenerateId())
|
||||
// eggplant := &EggplantImpl{}
|
||||
// eggplant.SendCard(context.Background(), "{\"mid\":\"10142\",\"pay_type\":\"8075\",\"key\":\"34fbe3b5238923f74c13fe6d731abc1534fbe3b5238923f7\",\"url\":\"https://admin.djfkm.xyz\"}", supplier.RedeemCardInfo{
|
||||
// FaceType: "100",
|
||||
// CardNo: "1234567890",
|
||||
// Data: "123456",
|
||||
// }, utils.GenerateId())
|
||||
|
||||
}
|
||||
|
||||
func Test_eggplantProductCode_channelTwo(t *testing.T) {
|
||||
req := httplib.Post("https://httpbin.org/post")
|
||||
req.SetTimeout(time.Second*10, time.Second*10).Header("Content-Type", "multipart/form-data")
|
||||
// var b bytes.Buffer
|
||||
req.Param("order_no", "1234567890")
|
||||
req.Param("card_no", "1234567890")
|
||||
req.Param("pass", "1234567890")
|
||||
|
||||
// body, err := req.String()
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// logs.Info(body)
|
||||
// request := &netutil.HttpRequest{
|
||||
// RawURL: "https://jsonplaceholder.typicode.com/todos/1",
|
||||
// Method: "POST",
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -145,13 +145,13 @@ func (f *FatSixImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadIn
|
||||
//err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
//if err != nil {
|
||||
// otel.Logger.WithContext(ctx).Error("格式化数据失败", orderInfo.ExValue)
|
||||
// return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
// return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
//}
|
||||
ok, response := f.sendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId)
|
||||
if !ok {
|
||||
return supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + convertor.ToString(response.ErrMsg),
|
||||
Msg: "订单有误,请稍后再试:" + convertor.ToString(response.ErrMsg),
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: convertor.ToString(response.ErrMsg),
|
||||
|
||||
@@ -47,13 +47,16 @@ func (c *FavorableCloudsCardImpl) HasDependencyHTML() bool {
|
||||
|
||||
// 生成md5加密
|
||||
func (c *FavorableCloudsCardImpl) generateFavorableCloudsSign(ctx context.Context, params map[string]interface{}, key string) string {
|
||||
delete(params, "sign")
|
||||
keys := maputil.Keys(params)
|
||||
// 删除sign
|
||||
sort.Strings(keys)
|
||||
sign := ""
|
||||
for _, key2 := range keys {
|
||||
sign += key2 + "=" + convertor.ToString(params[key2]) + "&"
|
||||
}
|
||||
sign += key
|
||||
otelTrace.Logger.WithContext(ctx).Info("祥云生成签名", zap.Any("sign", sign))
|
||||
return utils.EncodeMd5Str(sign)
|
||||
}
|
||||
|
||||
@@ -187,14 +190,14 @@ func (c *FavorableCloudsCardImpl) Scan(ctx context.Context, orderInfo order.Orde
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, orderInfo, cdata, orderInfo.BankOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
@@ -231,12 +234,11 @@ func (c *FavorableCloudsCardImpl) PayNotify() {
|
||||
ctx := c.Ctx.Request.Context()
|
||||
|
||||
type Request struct {
|
||||
MerOrderTid string `json:"merOrderTid"`
|
||||
Tid string `json:"tid"`
|
||||
Money string `json:"money"`
|
||||
Sign string `json:"sign"`
|
||||
Status int `json:"status"`
|
||||
ClientUserPayRemark string `json:"clientUserPayRemark"`
|
||||
MerOrderTid string `json:"merOrderTid"`
|
||||
Tid string `json:"tid"`
|
||||
Money string `json:"money"`
|
||||
Sign string `json:"sign"`
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
var req Request
|
||||
@@ -247,13 +249,14 @@ func (c *FavorableCloudsCardImpl) PayNotify() {
|
||||
return
|
||||
}
|
||||
|
||||
otelTrace.Logger.WithContext(ctx).Info("祥云回调数据", zap.Any("req", req))
|
||||
|
||||
ctx, cancel := otelTrace.Span(
|
||||
ctx, "祥云卡", "PayNotify", trace.WithAttributes(
|
||||
attribute.String("MerOrderTid", req.MerOrderTid),
|
||||
attribute.String("Tid", req.Tid),
|
||||
attribute.String("Money", req.Money),
|
||||
attribute.Int("Status", req.Status),
|
||||
attribute.String("ClientUserPayRemark", req.ClientUserPayRemark),
|
||||
),
|
||||
)
|
||||
defer cancel()
|
||||
@@ -416,6 +419,7 @@ func (c *FavorableCloudsCardImpl) PayQuery(orderInfo order.OrderInfo, roadInfo r
|
||||
func (c *FavorableCloudsCardImpl) PayQueryV2(orderInfo order.OrderInfo, roadInfo road.RoadInfo) supply_model.MsgModel {
|
||||
params := map[string]any{}
|
||||
ctx := context.Background()
|
||||
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
if err != nil {
|
||||
return supply_model.CardMsgErr
|
||||
|
||||
@@ -228,7 +228,7 @@ func (c *HeepayImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadIn
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
|
||||
ok, response, msg := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId, orderInfo.MerchantOrderId, orderInfo)
|
||||
|
||||
@@ -23,8 +23,9 @@ var supplierCode2Name = map[string]string{
|
||||
"CTripSelf": "携程(自有)",
|
||||
"AiBo": "爱博核销平台",
|
||||
"Ninja": "忍者API",
|
||||
"Heepay": "汇付宝核销平台",
|
||||
"Heepay": "俊卡官方接口",
|
||||
"EGGPLANT": "茄子核销平台",
|
||||
"FAVORABLE_CLOUDS": "艾彼核销平台",
|
||||
}
|
||||
|
||||
var registerSupplier = make(map[string]supplier.PayInterface)
|
||||
|
||||
4
internal/service/supplier/third_party/jd.go
vendored
4
internal/service/supplier/third_party/jd.go
vendored
@@ -123,14 +123,14 @@ func (c *JDCardImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadIn
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId, orderInfo.MerchantOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
|
||||
@@ -168,7 +168,7 @@ func (c *MFCardImpl) Scan(orderInfo order.OrderInfo, roadInfo road.RoadInfo, mer
|
||||
cdata := CardInfo{}
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试(01)"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试(01)"}
|
||||
}
|
||||
|
||||
// 类型 171 京东卡,核心代码
|
||||
@@ -176,10 +176,10 @@ func (c *MFCardImpl) Scan(orderInfo order.OrderInfo, roadInfo road.RoadInfo, mer
|
||||
|
||||
ok, str := c.SendCard(roadInfo.Params, cdata, orderInfo.BankOrderId)
|
||||
if !ok {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试(02)" + str}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试(02)" + str}
|
||||
}
|
||||
if str == "" {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试(03)" + str}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试(03)" + str}
|
||||
}
|
||||
|
||||
retStr := gojson.Json(str).Get("code").Tostring()
|
||||
@@ -189,7 +189,7 @@ func (c *MFCardImpl) Scan(orderInfo order.OrderInfo, roadInfo road.RoadInfo, mer
|
||||
|
||||
//keyList, valueList := gojson.Json(retStr).Get("data").ToArray()
|
||||
//if len(keyList) <= 0 {
|
||||
// return supply_model.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试(04)"}
|
||||
// return supply_model.ScanData{Status: "-1", Msg: "订单有误,请稍后再试(04)"}
|
||||
//}
|
||||
//idx := ""
|
||||
//for i := 0; i < len(keyList); i++ {
|
||||
@@ -212,7 +212,7 @@ func (c *MFCardImpl) Scan(orderInfo order.OrderInfo, roadInfo road.RoadInfo, mer
|
||||
|
||||
if err != nil {
|
||||
otel.Logger.WithContext(ctx).Error("SolvePaySuccess失败:", err)
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
|
||||
var scanData supplier.ScanData
|
||||
@@ -234,7 +234,7 @@ func (c *MFCardImpl) Syt(orderInfo order.OrderInfo, roadInfo road.RoadInfo, merc
|
||||
cdata := CardInfo{}
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试(01)"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试(01)"}
|
||||
}
|
||||
// 类型 171 京东卡
|
||||
//ok, str := c.SendCard(roadInfo.Params, cdata, orderInfo.BankOrderId)
|
||||
@@ -244,7 +244,7 @@ func (c *MFCardImpl) Syt(orderInfo order.OrderInfo, roadInfo road.RoadInfo, merc
|
||||
return supplier.ScanData{Status: "-1", Msg: "错误:" + str}
|
||||
}
|
||||
if str == "" {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试(03)" + str}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试(03)" + str}
|
||||
}
|
||||
|
||||
retStr := gojson.Json(str).Get("ret").Tostring()
|
||||
@@ -254,7 +254,7 @@ func (c *MFCardImpl) Syt(orderInfo order.OrderInfo, roadInfo road.RoadInfo, merc
|
||||
|
||||
if err != nil {
|
||||
otel.Logger.WithContext(ctx).Error("SolvePaySuccess失败:", err)
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
|
||||
var scanData supplier.ScanData
|
||||
|
||||
@@ -139,14 +139,14 @@ func (c *MFCardV2Impl) Scan(ctx context.Context, orderInfo order.OrderInfo, road
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue), zap.Error(err))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId)
|
||||
if !ok {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试:" + str}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试:" + str}
|
||||
}
|
||||
if str == "" {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试:" + str}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试:" + str}
|
||||
}
|
||||
|
||||
retStr := gojson.Json(str).Get("code").Tostring()
|
||||
@@ -156,7 +156,7 @@ func (c *MFCardV2Impl) Scan(ctx context.Context, orderInfo order.OrderInfo, road
|
||||
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("SolvePaySuccess失败:", zap.Error(err))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
var scanData supplier.ScanData
|
||||
scanData.Status = "00"
|
||||
|
||||
@@ -127,14 +127,14 @@ func (c *NinjaCardImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roa
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, orderInfo, cdata, orderInfo.BankOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
|
||||
11
internal/service/supplier/third_party/qixi.go
vendored
11
internal/service/supplier/third_party/qixi.go
vendored
@@ -113,7 +113,7 @@ func (c *QiXiCardImpl) SendCard(ctx context.Context, jsonStr string, cardInfo su
|
||||
Message string `json:"message" xml:"message"`
|
||||
}
|
||||
|
||||
var resData AutoGenerated
|
||||
resData := AutoGenerated{}
|
||||
err = xml.Unmarshal([]byte(response), &resData)
|
||||
otelTrace.Logger.WithContext(ctx).Info("远端请求返回数据:", zap.Any("response", string(resp)), zap.Any("解析结果", resData))
|
||||
if err != nil {
|
||||
@@ -121,9 +121,9 @@ func (c *QiXiCardImpl) SendCard(ctx context.Context, jsonStr string, cardInfo su
|
||||
return false, "内部数据处理失败"
|
||||
}
|
||||
if resData.Code == 1 {
|
||||
return true, response
|
||||
return true, resData.Message
|
||||
}
|
||||
return false, response
|
||||
return false, resData.Message
|
||||
}
|
||||
|
||||
func (c *QiXiCardImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) supplier.ScanData {
|
||||
@@ -137,14 +137,14 @@ func (c *QiXiCardImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, road
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
@@ -235,7 +235,6 @@ func (c *QiXiCardImpl) PayNotify() {
|
||||
}
|
||||
|
||||
//TODO: 需要二次查单
|
||||
otelTrace.Logger.WithContext(ctx).Info("【七喜】回调数据", zap.Any("params", params))
|
||||
if params["status"] == "2" {
|
||||
successAmount, _ := strconv.ParseFloat(convertor.ToString(params["successAmount"]), 64)
|
||||
isOk := false
|
||||
|
||||
@@ -104,14 +104,14 @@ func (c *SelfThirdImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roa
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo, roadInfo)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
|
||||
@@ -93,11 +93,11 @@ func (c *StarSilenceImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, r
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, &orderInfo)
|
||||
if !ok {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试:" + str}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试:" + str}
|
||||
}
|
||||
var scanData supplier.ScanData
|
||||
scanData.Status = "00"
|
||||
|
||||
@@ -137,7 +137,7 @@ func (c *TMAllGameImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roa
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
channel := ""
|
||||
if roadInfo.ProductUid == "TMALLGAME_CONFIRM" {
|
||||
@@ -147,10 +147,10 @@ func (c *TMAllGameImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roa
|
||||
}
|
||||
ok, str := c.SendCard(ctx, channel, cdata, orderInfo)
|
||||
if !ok {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试:" + str}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试:" + str}
|
||||
}
|
||||
if str == "" {
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试:" + str}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试:" + str}
|
||||
}
|
||||
var scanData supplier.ScanData
|
||||
scanData.Status = "00"
|
||||
|
||||
@@ -197,14 +197,14 @@ func (c *WalMartImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadI
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
|
||||
@@ -69,14 +69,15 @@ func (c *WalmartSelfImpl) SendCard(ctx context.Context, jsonStr string, cardInfo
|
||||
if err != nil {
|
||||
return false, "获取沃尔玛密地址失败!"
|
||||
}
|
||||
|
||||
req := httplib.NewBeegoRequestWithCtx(ctx, url, "POST")
|
||||
req.SetTransport(otelhttp.NewTransport(http.DefaultTransport))
|
||||
// req := httplib.Post(url)
|
||||
marshal, err := json.Marshal(params)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("Map转化为byte数组失败,异常。", zap.Error(err))
|
||||
return false, "内部错误请稍后再试试"
|
||||
}
|
||||
|
||||
otelTrace.Logger.WithContext(ctx).Info("请求参数:" + string(marshal))
|
||||
req.Header("Content-Type", "application/json")
|
||||
req.Body(marshal)
|
||||
@@ -87,11 +88,13 @@ func (c *WalmartSelfImpl) SendCard(ctx context.Context, jsonStr string, cardInfo
|
||||
otelTrace.Logger.WithContext(ctx).Error("沃尔玛请求失败:", zap.Error(err))
|
||||
return false, ""
|
||||
}
|
||||
|
||||
otelTrace.Logger.WithContext(ctx).Info("远端请求返回数据:" + response)
|
||||
if gojson.Json(response).Get("code").Tostring() == "" {
|
||||
otelTrace.Logger.WithContext(ctx).Error("远程调用失败")
|
||||
return false, ""
|
||||
}
|
||||
|
||||
type AutoGenerated struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
@@ -124,14 +127,14 @@ func (c *WalmartSelfImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, r
|
||||
err := json.Unmarshal([]byte(orderInfo.ExValue), &cdata)
|
||||
if err != nil {
|
||||
otelTrace.Logger.WithContext(ctx).Error("格式化数据失败", zap.String("ExValue", orderInfo.ExValue))
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有有误,请稍后再试"}
|
||||
return supplier.ScanData{Status: "-1", Msg: "订单有误,请稍后再试"}
|
||||
}
|
||||
ok, str := c.SendCard(ctx, roadInfo.Params, cdata, orderInfo.BankOrderId, orderInfo.MerchantOrderId)
|
||||
var scanData supplier.ScanData
|
||||
if !ok {
|
||||
scanData = supplier.ScanData{
|
||||
Status: "-1",
|
||||
Msg: "订单有有误,请稍后再试:" + str,
|
||||
Msg: "订单有误,请稍后再试:" + str,
|
||||
BankNo: orderInfo.MerchantOrderId,
|
||||
OrderNo: orderInfo.BankOrderId,
|
||||
ReturnData: str,
|
||||
@@ -168,33 +171,28 @@ func (c *WalmartSelfImpl) PayNotify() {
|
||||
ctx := context.Background()
|
||||
otelTrace.Logger.WithContext(ctx).Info("【沃尔玛】回调开始")
|
||||
attach := strings.TrimSpace(c.GetString("merchantId"))
|
||||
orderInfo := order.GetOrderByBankOrderId(ctx, attach) // OrderId
|
||||
orderInfo := order.GetOrderByBankOrderId(ctx, attach)
|
||||
|
||||
if orderInfo.BankOrderId == "" || len(orderInfo.BankOrderId) == 0 {
|
||||
otelTrace.Logger.WithContext(ctx).Error("【沃尔玛】回调的订单号不存在,订单号=", zap.String("attach", attach))
|
||||
c.Ctx.WriteString("FAIL")
|
||||
return
|
||||
}
|
||||
|
||||
roadInfo := road.GetRoadInfoByRoadUid(ctx, orderInfo.RoadUid)
|
||||
if roadInfo.RoadUid == "" || len(roadInfo.RoadUid) == 0 {
|
||||
otelTrace.Logger.WithContext(ctx).Error("【沃尔玛】支付通道已经关系或者删除,不进行回调")
|
||||
c.Ctx.WriteString("FAIL")
|
||||
return
|
||||
}
|
||||
//merchantUid := orderInfo.MerchantUid
|
||||
//merchantInfo := merchant.GetMerchantByUid(ctx, merchantUid)
|
||||
//if merchantInfo.MerchantUid == "" || len(merchantInfo.MerchantUid) == 0 {
|
||||
// otelTrace.Logger.WithContext(ctx).Error("【沃尔玛】回调失败,该商户不存在或者已经删除,商户uid=", zap.String("merchantUid", merchantUid))
|
||||
// c.Ctx.WriteString("FAIL")
|
||||
// return
|
||||
//}
|
||||
|
||||
params := map[string]string{
|
||||
"merchantId": strings.TrimSpace(c.GetString("merchantId")),
|
||||
"amount": strings.TrimSpace(c.GetString("amount")), // 时间戳
|
||||
//"timestamp": strings.TrimSpace(c.GetString("timestamp")),
|
||||
"status": strings.TrimSpace(c.GetString("status")),
|
||||
//"sign": strings.TrimSpace(c.GetString("sign")),
|
||||
"remark": strings.TrimSpace(c.GetString("remark")),
|
||||
}
|
||||
|
||||
otelTrace.Logger.WithContext(ctx).Info("【沃尔玛】回调参数:", zap.Any("params", params))
|
||||
orderInfo.BankTransId = params["merchantId"]
|
||||
if params["status"] == "1" {
|
||||
|
||||
Reference in New Issue
Block a user