114 lines
3.2 KiB
Go
114 lines
3.2 KiB
Go
package IVYZ
|
|
|
|
import (
|
|
"context"
|
|
"tianyuan-api/pkg/errs"
|
|
|
|
"tianyuan-api/apps/api/internal/svc"
|
|
"tianyuan-api/apps/api/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type IVYZADEELogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewIVYZADEELogic(ctx context.Context, svcCtx *svc.ServiceContext) *IVYZADEELogic {
|
|
return &IVYZADEELogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *IVYZADEELogic) IVYZADEE(req *types.Request) (resp string, err *errs.AppError) {
|
|
return
|
|
//var status string
|
|
//var charges bool
|
|
//var remark = ""
|
|
//secretKey, ok := l.ctx.Value("secretKey").(string)
|
|
//if !ok {
|
|
// return "", errs.ErrSystem
|
|
//}
|
|
//transactionID, ok := l.ctx.Value("transactionID").(string)
|
|
//if !ok {
|
|
// return "", errs.ErrSystem
|
|
//}
|
|
//userId, userIdOk := l.ctx.Value("userId").(int64)
|
|
//if !userIdOk {
|
|
// return "", errs.ErrSystem
|
|
//}
|
|
//productCode, productCodeOk := l.ctx.Value("productCode").(string)
|
|
//if !productCodeOk || productCode == "" {
|
|
// return "", errs.ErrSystem
|
|
//}
|
|
//defer func() {
|
|
// if err != nil {
|
|
// status = "failed"
|
|
// charges = false
|
|
// } else {
|
|
// status = "success"
|
|
// charges = true
|
|
// }
|
|
// sendApiRequestMessageErr := l.svcCtx.ApiRequestMqsService.SendApiRequestMessage(l.ctx, transactionID, userId, productCode, status, charges, remark)
|
|
// if sendApiRequestMessageErr != nil {
|
|
// logx.Errorf("发送 API 请求消息失败: %v", err)
|
|
// }
|
|
//}()
|
|
//// 1、解密
|
|
//key, decodeErr := hex.DecodeString(secretKey)
|
|
//if decodeErr != nil {
|
|
// return "", errs.ErrSystem
|
|
//}
|
|
//decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
|
//if aesDecryptErr != nil || len(decryptData) == 0 {
|
|
// return "", errs.ErrParamDecryption
|
|
//}
|
|
//
|
|
//// 2、校验
|
|
//var data validator.FLXGDEC7Request
|
|
//if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
|
// return "", errs.ErrParamValidation
|
|
//}
|
|
//
|
|
//// 3、西部加密
|
|
//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.FLXGDEC7FieldMapping, "data")
|
|
//
|
|
//westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("idCardThreeElements", apiRequest, l.svcCtx.Config.WestConfig.SecretId)
|
|
//if callAPIErr != nil {
|
|
// return "", errs.ErrSystem
|
|
//}
|
|
//
|
|
//// 5、响应解析
|
|
////var respData westmodel.G32BJ05Response
|
|
////unmarshalErr := json.Unmarshal(westResp, &respData)
|
|
////if unmarshalErr != nil {
|
|
//// return "", errs.ErrSystem
|
|
////}
|
|
////
|
|
////if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
|
//// l.ctx = context.WithValue(l.ctx, "Charges", true)
|
|
////} else {
|
|
//// return "", errs.ErrSystem
|
|
////}
|
|
////encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
|
////if aesEncrypt != nil {
|
|
//// return "", errs.ErrSystem
|
|
////}
|
|
//return &types.Response{
|
|
// Data: string(westResp),
|
|
//}, nil
|
|
}
|