Merge branch 'main' of http://1.117.67.95:3000/team/ycc-proxy-server
This commit is contained in:
@@ -2,12 +2,16 @@ package admin_order
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/crypto"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
@@ -72,6 +76,44 @@ func (l *AdminGetOrderListLogic) AdminGetOrderList(req *types.AdminGetOrderListR
|
||||
if req.RefundTimeEnd != "" {
|
||||
builder = builder.Where("refund_time <= ?", req.RefundTimeEnd)
|
||||
}
|
||||
if req.QuerySubjectName != "" || req.QuerySubjectMobile != "" || req.QuerySubjectIdCard != "" {
|
||||
key, decodeErr := hex.DecodeString(l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if decodeErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR),
|
||||
"AdminGetOrderList, AES密钥解析失败 err: %v", decodeErr)
|
||||
}
|
||||
conds := []string{"del_state = ?"}
|
||||
args := []interface{}{globalkey.DelStateNo}
|
||||
if req.QuerySubjectName != "" {
|
||||
enc, _, encErr := crypto.EncryptDeterministicOptional(req.QuerySubjectName, key)
|
||||
if encErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR),
|
||||
"AdminGetOrderList, 加密筛选姓名失败 err: %v", encErr)
|
||||
}
|
||||
conds = append(conds, "enc_real_name = ?")
|
||||
args = append(args, enc)
|
||||
}
|
||||
if req.QuerySubjectMobile != "" {
|
||||
enc, encErr := crypto.EncryptMobile(req.QuerySubjectMobile, l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if encErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR),
|
||||
"AdminGetOrderList, 加密筛选手机号失败 err: %v", encErr)
|
||||
}
|
||||
conds = append(conds, "enc_mobile = ?")
|
||||
args = append(args, enc)
|
||||
}
|
||||
if req.QuerySubjectIdCard != "" {
|
||||
enc, encErr := crypto.EncryptIDCard(req.QuerySubjectIdCard, key)
|
||||
if encErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR),
|
||||
"AdminGetOrderList, 加密筛选身份证失败 err: %v", encErr)
|
||||
}
|
||||
conds = append(conds, "enc_id_card = ?")
|
||||
args = append(args, enc)
|
||||
}
|
||||
subSQL := "id IN (SELECT order_id FROM query_subject_index WHERE " + strings.Join(conds, " AND ") + ")"
|
||||
builder = builder.Where(subSQL, args...)
|
||||
}
|
||||
|
||||
// 并发获取总数和列表
|
||||
var total int64
|
||||
@@ -85,7 +127,7 @@ func (l *AdminGetOrderListLogic) AdminGetOrderList(req *types.AdminGetOrderListR
|
||||
return nil
|
||||
}, func() error {
|
||||
var err error
|
||||
orders, err = l.svcCtx.OrderModel.FindPageListByPage(l.ctx, builder, req.Page, req.PageSize, "id DESC")
|
||||
orders, err = l.svcCtx.OrderModel.FindPageListByPage(l.ctx, builder, req.Page, req.PageSize, "create_time DESC")
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetOrderList, 查询订单列表失败 err: %v", err)
|
||||
}
|
||||
|
||||
@@ -72,16 +72,48 @@ func (l *AdminGetQueryDetailByOrderIdLogic) AdminGetQueryDetailByOrderId(req *ty
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 获取商品信息失败, %v", err)
|
||||
}
|
||||
query.ProductName = product.ProductName
|
||||
|
||||
// 查询代理订单信息,判断是否是代理单
|
||||
var agentUserName string
|
||||
var agentUserMobile string
|
||||
agentOrder, err := l.svcCtx.AgentOrderModel.FindOneByOrderId(l.ctx, queryModel.OrderId)
|
||||
if err == nil && agentOrder != nil {
|
||||
// 是代理单,查询代理实名信息获取姓名和手机号
|
||||
realNameInfo, realNameErr := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agentOrder.AgentId)
|
||||
if realNameErr == nil && realNameInfo != nil {
|
||||
agentUserName = realNameInfo.Name
|
||||
// 解密实名认证中的手机号(ECB加密,使用 DecryptMobile)
|
||||
if realNameInfo.Mobile != "" {
|
||||
decryptedMobile, decryptErr := crypto.DecryptMobile(realNameInfo.Mobile, l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if decryptErr == nil {
|
||||
agentUserMobile = decryptedMobile
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果实名认证中没有手机号,回退到Agent表获取
|
||||
if agentUserMobile == "" {
|
||||
agentInfo, agentErr := l.svcCtx.AgentModel.FindOne(l.ctx, agentOrder.AgentId)
|
||||
if agentErr == nil && agentInfo != nil {
|
||||
decryptedMobile, decryptErr := crypto.DecryptMobile(agentInfo.Mobile, l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if decryptErr == nil {
|
||||
agentUserMobile = decryptedMobile
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &types.AdminGetQueryDetailByOrderIdResp{
|
||||
Id: query.Id,
|
||||
OrderId: query.OrderId,
|
||||
UserId: query.UserId,
|
||||
ProductName: query.ProductName,
|
||||
QueryParams: query.QueryParams,
|
||||
QueryData: query.QueryData,
|
||||
CreateTime: query.CreateTime,
|
||||
UpdateTime: query.UpdateTime,
|
||||
QueryState: query.QueryState,
|
||||
Id: query.Id,
|
||||
OrderId: query.OrderId,
|
||||
UserId: query.UserId,
|
||||
ProductName: query.ProductName,
|
||||
QueryParams: query.QueryParams,
|
||||
QueryData: query.QueryData,
|
||||
CreateTime: query.CreateTime,
|
||||
UpdateTime: query.UpdateTime,
|
||||
QueryState: query.QueryState,
|
||||
AgentUserName: agentUserName,
|
||||
AgentUserMobile: agentUserMobile,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user