update ivyz5773
This commit is contained in:
@@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"tianyuan-api/apps/api/internal/common"
|
||||
"errors"
|
||||
"tianyuan-api/apps/api/internal/service"
|
||||
"tianyuan-api/apps/api/internal/svc"
|
||||
"tianyuan-api/apps/api/internal/types"
|
||||
"tianyuan-api/apps/api/internal/validator"
|
||||
"tianyuan-api/apps/api/internal/westmodel"
|
||||
"tianyuan-api/pkg/crypto"
|
||||
"tianyuan-api/pkg/errs"
|
||||
|
||||
@@ -79,31 +79,42 @@ func (l *IVYZ5733Logic) IVYZ5733(req *types.Request) (resp string, err *errs.App
|
||||
}
|
||||
|
||||
// 3、西部加密
|
||||
westConfig := l.svcCtx.Config.WestConfig
|
||||
encryptedFields, encryptStructFieldsErr := common.EncryptStructFields(data, westConfig.Key)
|
||||
if encryptStructFieldsErr != nil {
|
||||
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
|
||||
return "", errs.ErrSystem
|
||||
}
|
||||
// westConfig := l.svcCtx.Config.WestConfig
|
||||
// encryptedFields, encryptStructFieldsErr := common.EncryptStructFields(data, westConfig.Key)
|
||||
// if encryptStructFieldsErr != nil {
|
||||
// logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
|
||||
// return "", errs.ErrSystem
|
||||
// }
|
||||
|
||||
// 4、发送请求到西部
|
||||
logx.Infof("交易号:%s", transactionID)
|
||||
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.IVYZ5733FieldMapping, "data")
|
||||
// apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.IVYZ5733FieldMapping, "data")
|
||||
|
||||
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G09SC02", apiRequest, l.svcCtx.Config.WestConfig.SecretId)
|
||||
// westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G09SC02", apiRequest, l.svcCtx.Config.WestConfig.SecretId)
|
||||
// if callAPIErr != nil {
|
||||
// if callAPIErr.Code == errs.ErrDataSource.Code {
|
||||
// encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
// if aesEncrypt != nil {
|
||||
// return "", errs.ErrSystem
|
||||
// }
|
||||
|
||||
// return encryptData, callAPIErr
|
||||
// }
|
||||
// return "", callAPIErr
|
||||
// }
|
||||
apiRequest := map[string]interface{}{
|
||||
"cardNo": data.IDCard,
|
||||
"name": data.Name,
|
||||
}
|
||||
respData, callAPIErr := l.svcCtx.YushanService.Request("IDV044", apiRequest)
|
||||
if callAPIErr != nil {
|
||||
if callAPIErr.Code == errs.ErrDataSource.Code {
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
if aesEncrypt != nil {
|
||||
return "", errs.ErrSystem
|
||||
}
|
||||
|
||||
return encryptData, callAPIErr
|
||||
if errors.Is(callAPIErr, service.NotFound) {
|
||||
return "", errs.ErrNotFound
|
||||
}
|
||||
return "", callAPIErr
|
||||
return "", errs.ErrSystem
|
||||
}
|
||||
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(respData, key)
|
||||
if aesEncrypt != nil {
|
||||
return "", errs.ErrSystem
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user