fix comb298y

This commit is contained in:
liangzai 2025-06-14 13:36:54 +08:00
parent 59d07a4c71
commit 766a972af1

View File

@ -107,17 +107,13 @@ func (l *COMB298YLogic) COMB298Y(req *types.Request) (resp string, err *errs.App
return "", errs.ErrParamValidation
}
// 3、西部加密
westConfig := l.svcCtx.Config.WestConfig
encryptedFields, encryptStructFieldsErr := common.EncryptStructFields(data, westConfig.Key)
if encryptStructFieldsErr != nil {
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
var encryptedFields map[string]interface{}
unmarshalErr := json.Unmarshal(decryptData, &encryptedFields)
if unmarshalErr != nil {
logx.Errorf("解密数据转换为map失败%v", err)
return "", errs.ErrSystem
}
// 4、发送请求到西部
logx.Infof("交易号:%s", transactionID)
// 准备并发请求
apiRequests := []APIRequest{
{SourceId: "G16BJ02", ServiceId: "YYSY09CD", Mapping: westmodel.YYSY09CDFieldMapping, Wrap: "data", Service: "west"},
@ -137,7 +133,18 @@ func (l *COMB298YLogic) COMB298Y(req *types.Request) (resp string, err *errs.App
// 为每个请求构建对应的请求参数
for i := range apiRequests {
apiRequests[i].Request = common.MapStructToAPIRequest(encryptedFields, apiRequests[i].Mapping, apiRequests[i].Wrap)
request := encryptedFields
if apiRequests[i].Service == "west" {
// 3、西部加密
westConfig := l.svcCtx.Config.WestConfig
encryptedRequest, encryptStructFieldsErr := common.EncryptStructFields(request, westConfig.Key)
if encryptStructFieldsErr != nil {
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
}
request = encryptedRequest
}
logx.Infof("sourceId:%s,请求参数:%v", apiRequests[i].SourceId, request)
apiRequests[i].Request = common.MapStructToAPIRequest(request, apiRequests[i].Mapping, apiRequests[i].Wrap)
}
// 创建响应通道
@ -156,8 +163,13 @@ func (l *COMB298YLogic) COMB298Y(req *types.Request) (resp string, err *errs.App
// 根据服务类型选择不同的调用方式
switch req.Service {
case "west":
// 4、发送请求到西部
logx.Infof("交易号:%s", transactionID)
respData, err := l.svcCtx.WestDexService.CallAPI(req.SourceId, req.Request, l.svcCtx.Config.WestConfig.SecretId)
if err != nil {
logx.Errorf("西部请求失败sourceId:%s,err:%v", req.SourceId, err)
callAPIErr = err
westResp = "{}" // 发生错误时返回空对象
} else {
@ -177,6 +189,7 @@ func (l *COMB298YLogic) COMB298Y(req *types.Request) (resp string, err *errs.App
case "yushan":
respData, err := l.svcCtx.YushanService.Request(req.SourceId, req.Request)
if err != nil {
logx.Errorf("羽山请求失败sourceId:%s,err:%v", req.SourceId, err)
if appErr, ok := err.(*errs.AppError); ok {
callAPIErr = appErr
} else {