temp
This commit is contained in:
@@ -2,6 +2,13 @@ package FLXG
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"tianyuan-api/apps/api/internal/common"
|
||||
"tianyuan-api/apps/api/internal/validator"
|
||||
"tianyuan-api/apps/api/internal/westmodel"
|
||||
"tianyuan-api/pkg/crypto"
|
||||
"tianyuan-api/pkg/errs"
|
||||
|
||||
"tianyuan-api/apps/api/internal/svc"
|
||||
"tianyuan-api/apps/api/internal/types"
|
||||
@@ -24,7 +31,64 @@ func NewFLXG162ALogic(ctx context.Context, svcCtx *svc.ServiceContext) *FLXG162A
|
||||
}
|
||||
|
||||
func (l *FLXG162ALogic) FLXG162A(req *types.Request) (resp *types.Response, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
secretKey, ok := l.ctx.Value("secretKey").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
transactionID, ok := l.ctx.Value("transactionID").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
// 1、解密
|
||||
key, decodeErr := hex.DecodeString(secretKey)
|
||||
if decodeErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
||||
if aesDecryptErr != nil || len(decryptData) == 0 {
|
||||
return nil, errs.ErrParamDecryption
|
||||
}
|
||||
|
||||
return
|
||||
// 2、校验
|
||||
var data validator.FLXG162ARequest
|
||||
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
||||
return nil, errs.ErrParamValidation
|
||||
}
|
||||
|
||||
// 3、西部加密
|
||||
westConfig := l.svcCtx.Config.WestConfig
|
||||
encryptedFields, err := common.EncryptStructFields(data, westConfig.Key)
|
||||
if err != nil {
|
||||
logx.Errorf("西部加密错误:%v", err)
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 4、发送请求到西部
|
||||
logx.Infof("交易号:%s", transactionID)
|
||||
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.FLXG162AFieldMapping, "data")
|
||||
|
||||
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G32BJ05", apiRequest)
|
||||
if callAPIErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 5、响应解析
|
||||
var respData westmodel.G32BJ05Response
|
||||
unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||
if unmarshalErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||
l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||
} else {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
if aesEncrypt != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
return &types.Response{
|
||||
Data: encryptData,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package FLXG
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"encoding/json"
|
||||
"tianyuan-api/apps/api/internal/common"
|
||||
"tianyuan-api/apps/api/internal/validator"
|
||||
"tianyuan-api/apps/api/internal/westmodel"
|
||||
"tianyuan-api/pkg/crypto"
|
||||
"tianyuan-api/pkg/errs"
|
||||
|
||||
"tianyuan-api/apps/api/internal/svc"
|
||||
"tianyuan-api/apps/api/internal/types"
|
||||
@@ -27,72 +30,66 @@ func NewFLXG3D56Logic(ctx context.Context, svcCtx *svc.ServiceContext) *FLXG3D56
|
||||
}
|
||||
}
|
||||
|
||||
// FLXG3D56 特殊名单
|
||||
func (l *FLXG3D56Logic) FLXG3D56(req *types.Request) (resp *types.Response, err error) {
|
||||
//userId, ok := l.ctx.Value("userId").(int64)
|
||||
//if !ok {
|
||||
// return &types.Response{}, errors.New("系统错误,请联系管理员")
|
||||
//}
|
||||
secretKey, ok := l.ctx.Value("secretKey").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errors.New("系统错误,请联系管理员")
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
transactionID, ok := l.ctx.Value("transactionID").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 1、解密
|
||||
key, err := hex.DecodeString(secretKey)
|
||||
decryptData, err := crypto.AesDecrypt(req.Data, key)
|
||||
if err != nil || len(decryptData) == 0 {
|
||||
return nil, errors.New("参数解密失败")
|
||||
key, decodeErr := hex.DecodeString(secretKey)
|
||||
if decodeErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
||||
if aesDecryptErr != nil || len(decryptData) == 0 {
|
||||
return nil, errs.ErrParamDecryption
|
||||
}
|
||||
|
||||
// 2、校验
|
||||
var data validator.FLXG3D56Request
|
||||
|
||||
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
||||
return nil, validatorErr
|
||||
return nil, errs.ErrParamValidation
|
||||
}
|
||||
|
||||
// 3、西部加密
|
||||
westConfig := l.svcCtx.Config.WestConfig
|
||||
mobileNo, err := crypto.WestDexEncrypt(data.MobileNo, westConfig.Key)
|
||||
encryptedFields, err := common.EncryptStructFields(data, westConfig.Key)
|
||||
if err != nil {
|
||||
logx.Errorf("西部加密错误:%v", err)
|
||||
return nil, errors.New("业务异常")
|
||||
}
|
||||
name, err := crypto.WestDexEncrypt(data.Name, westConfig.Key)
|
||||
if err != nil {
|
||||
logx.Errorf("西部加密错误:%v", err)
|
||||
return nil, errors.New("业务异常")
|
||||
}
|
||||
idCard, err := crypto.WestDexEncrypt(data.IDCard, westConfig.Key)
|
||||
if err != nil {
|
||||
logx.Errorf("西部加密错误:%v", err)
|
||||
return nil, errors.New("业务异常")
|
||||
}
|
||||
timeRange, err := crypto.WestDexEncrypt(data.TimeRange, westConfig.Key)
|
||||
if err != nil {
|
||||
logx.Errorf("西部加密错误:%v", err)
|
||||
return nil, errors.New("业务异常")
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 4、发送请求到西部
|
||||
westdexRequest := map[string]interface{}{
|
||||
"id": idCard,
|
||||
"cell": mobileNo,
|
||||
"name": name,
|
||||
"time_range": timeRange,
|
||||
}
|
||||
westResp, err := l.svcCtx.WestDexService.CallAPI("G26BJ05", westdexRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
logx.Infof("交易号:%s", transactionID)
|
||||
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.FLXG3D56FieldMapping, "data")
|
||||
|
||||
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G26BJ05", apiRequest)
|
||||
if callAPIErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 5、响应解析
|
||||
//var respData westmodel.G09GX01Response
|
||||
//unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||
//if unmarshalErr != nil {
|
||||
// return nil, unmarshalErr
|
||||
//}
|
||||
//crypto.AesEncrypt()
|
||||
var respData westmodel.G26BJ05Response
|
||||
unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||
if unmarshalErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||
l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||
} else {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
if aesEncrypt != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
return &types.Response{
|
||||
Data: string(westResp),
|
||||
Data: encryptData,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,13 @@ package FLXG
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"tianyuan-api/apps/api/internal/common"
|
||||
"tianyuan-api/apps/api/internal/validator"
|
||||
"tianyuan-api/apps/api/internal/westmodel"
|
||||
"tianyuan-api/pkg/crypto"
|
||||
"tianyuan-api/pkg/errs"
|
||||
|
||||
"tianyuan-api/apps/api/internal/svc"
|
||||
"tianyuan-api/apps/api/internal/types"
|
||||
@@ -24,7 +31,64 @@ func NewFLXG54F5Logic(ctx context.Context, svcCtx *svc.ServiceContext) *FLXG54F5
|
||||
}
|
||||
|
||||
func (l *FLXG54F5Logic) FLXG54F5(req *types.Request) (resp *types.Response, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
secretKey, ok := l.ctx.Value("secretKey").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
transactionID, ok := l.ctx.Value("transactionID").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
// 1、解密
|
||||
key, decodeErr := hex.DecodeString(secretKey)
|
||||
if decodeErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
||||
if aesDecryptErr != nil || len(decryptData) == 0 {
|
||||
return nil, errs.ErrParamDecryption
|
||||
}
|
||||
|
||||
return
|
||||
// 2、校验
|
||||
var data validator.FLXG54F5Request
|
||||
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
||||
return nil, errs.ErrParamValidation
|
||||
}
|
||||
|
||||
// 3、西部加密
|
||||
westConfig := l.svcCtx.Config.WestConfig
|
||||
encryptedFields, err := common.EncryptStructFields(data, westConfig.Key)
|
||||
if err != nil {
|
||||
logx.Errorf("西部加密错误:%v", err)
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 4、发送请求到西部
|
||||
logx.Infof("交易号:%s", transactionID)
|
||||
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.FLXG54F5FieldMapping, "data")
|
||||
|
||||
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G03HZ01", apiRequest)
|
||||
if callAPIErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 5、响应解析
|
||||
var respData westmodel.G03HZ01Response
|
||||
unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||
if unmarshalErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
if respData.Code == "0000" {
|
||||
l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||
} else {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
if aesEncrypt != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
return &types.Response{
|
||||
Data: encryptData,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@ package FLXG
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"tianyuan-api/apps/api/internal/common"
|
||||
"tianyuan-api/apps/api/internal/validator"
|
||||
"tianyuan-api/apps/api/internal/westmodel"
|
||||
"tianyuan-api/pkg/crypto"
|
||||
"tianyuan-api/pkg/errs"
|
||||
|
||||
"tianyuan-api/apps/api/internal/svc"
|
||||
"tianyuan-api/apps/api/internal/types"
|
||||
@@ -24,7 +30,64 @@ func NewFLXG5876Logic(ctx context.Context, svcCtx *svc.ServiceContext) *FLXG5876
|
||||
}
|
||||
|
||||
func (l *FLXG5876Logic) FLXG5876(req *types.Request) (resp *types.Response, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
secretKey, ok := l.ctx.Value("secretKey").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
transactionID, ok := l.ctx.Value("transactionID").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
// 1、解密
|
||||
key, decodeErr := hex.DecodeString(secretKey)
|
||||
if decodeErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
||||
if aesDecryptErr != nil || len(decryptData) == 0 {
|
||||
return nil, errs.ErrParamDecryption
|
||||
}
|
||||
|
||||
return
|
||||
// 2、校验
|
||||
var data validator.FLXG5876Request
|
||||
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
||||
return nil, errs.ErrParamValidation
|
||||
}
|
||||
|
||||
// 3、西部加密
|
||||
westConfig := l.svcCtx.Config.WestConfig
|
||||
encryptedFields, err := common.EncryptStructFields(data, westConfig.Key)
|
||||
if err != nil {
|
||||
logx.Errorf("西部加密错误:%v", err)
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 4、发送请求到西部
|
||||
logx.Infof("交易号:%s", transactionID)
|
||||
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.FLXG5876FieldMapping, "")
|
||||
|
||||
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G03XM02", apiRequest)
|
||||
if callAPIErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 5、响应解析
|
||||
//var respData westmodel.G26BJ05Response
|
||||
//unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||
//if unmarshalErr != nil {
|
||||
// return nil, errs.ErrSystem
|
||||
//}
|
||||
//
|
||||
//if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||
// l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||
//} else {
|
||||
// return nil, errs.ErrSystem
|
||||
//}
|
||||
//encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
//if aesEncrypt != nil {
|
||||
// return nil, errs.ErrSystem
|
||||
//}
|
||||
return &types.Response{
|
||||
Data: string(westResp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@ package FLXG
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"tianyuan-api/apps/api/internal/common"
|
||||
"tianyuan-api/apps/api/internal/validator"
|
||||
"tianyuan-api/apps/api/internal/westmodel"
|
||||
"tianyuan-api/pkg/crypto"
|
||||
"tianyuan-api/pkg/errs"
|
||||
|
||||
"tianyuan-api/apps/api/internal/svc"
|
||||
"tianyuan-api/apps/api/internal/types"
|
||||
@@ -24,7 +30,64 @@ func NewFLXG970FLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FLXG970F
|
||||
}
|
||||
|
||||
func (l *FLXG970FLogic) FLXG970F(req *types.Request) (resp *types.Response, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
secretKey, ok := l.ctx.Value("secretKey").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
transactionID, ok := l.ctx.Value("transactionID").(string)
|
||||
if !ok {
|
||||
return &types.Response{}, errs.ErrSystem
|
||||
}
|
||||
// 1、解密
|
||||
key, decodeErr := hex.DecodeString(secretKey)
|
||||
if decodeErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
||||
if aesDecryptErr != nil || len(decryptData) == 0 {
|
||||
return nil, errs.ErrParamDecryption
|
||||
}
|
||||
|
||||
return
|
||||
// 2、校验
|
||||
var data validator.FLXG970FRequest
|
||||
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
||||
return nil, errs.ErrParamValidation
|
||||
}
|
||||
|
||||
// 3、西部加密
|
||||
westConfig := l.svcCtx.Config.WestConfig
|
||||
encryptedFields, err := common.EncryptStructFields(data, westConfig.Key)
|
||||
if err != nil {
|
||||
logx.Errorf("西部加密错误:%v", err)
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 4、发送请求到西部
|
||||
logx.Infof("交易号:%s", transactionID)
|
||||
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.FLXG970FFieldMapping, "")
|
||||
|
||||
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("WEST00028", apiRequest)
|
||||
if callAPIErr != nil {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
// 5、响应解析
|
||||
//var respData westmodel.G32BJ05Response
|
||||
//unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||
//if unmarshalErr != nil {
|
||||
// return nil, errs.ErrSystem
|
||||
//}
|
||||
//
|
||||
//if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||
// l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||
//} else {
|
||||
// return nil, errs.ErrSystem
|
||||
//}
|
||||
//encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
//if aesEncrypt != nil {
|
||||
// return nil, errs.ErrSystem
|
||||
//}
|
||||
return &types.Response{
|
||||
Data: string(westResp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user