f
This commit is contained in:
@@ -2,15 +2,18 @@ package queue
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"ycc-server/app/main/api/internal/pkg/querysubject"
|
||||
"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/pkg/lzkit/crypto"
|
||||
"ycc-server/pkg/lzkit/lzUtils"
|
||||
|
||||
@@ -73,6 +76,11 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq.
|
||||
return fmt.Errorf("解密参数失败: %+v", aesdecryptErr)
|
||||
}
|
||||
|
||||
var userInfo map[string]interface{}
|
||||
if err := json.Unmarshal(decryptData, &userInfo); err != nil {
|
||||
return fmt.Errorf("解析用户信息失败: %+v", err)
|
||||
}
|
||||
|
||||
query := &model.Query{
|
||||
Id: uuid.NewString(),
|
||||
OrderId: order.Id,
|
||||
@@ -86,6 +94,10 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq.
|
||||
return fmt.Errorf("保存查询失败: %+v", insertQueryErr)
|
||||
}
|
||||
|
||||
if err := l.insertQuerySubjectIndex(ctx, query.Id, order.Id, userInfo, key); err != nil {
|
||||
logx.Errorf("写入被查询人密文索引失败 order=%s query=%s err=%v", order.Id, query.Id, err)
|
||||
}
|
||||
|
||||
// 插入后使用预生成的查询ID
|
||||
queryId := query.Id
|
||||
|
||||
@@ -95,12 +107,6 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq.
|
||||
return fmt.Errorf("获取插入后的查询记录失败: %+v", err)
|
||||
}
|
||||
|
||||
// 解析解密后的参数获取用户信息
|
||||
var userInfo map[string]interface{}
|
||||
if err := json.Unmarshal(decryptData, &userInfo); err != nil {
|
||||
return fmt.Errorf("解析用户信息失败: %+v", err)
|
||||
}
|
||||
|
||||
// 生成授权书
|
||||
authDoc, err := l.svcCtx.AuthorizationService.GenerateAuthorizationDocument(
|
||||
ctx, order.UserId, order.Id, queryId, userInfo,
|
||||
@@ -262,6 +268,42 @@ func (l *PaySuccessNotifyUserHandler) handleError(ctx context.Context, err error
|
||||
return asynq.SkipRetry
|
||||
}
|
||||
|
||||
func (l *PaySuccessNotifyUserHandler) insertQuerySubjectIndex(
|
||||
ctx context.Context,
|
||||
queryId, orderId string,
|
||||
userInfo map[string]interface{},
|
||||
aesKey []byte,
|
||||
) error {
|
||||
name, mobile, idCard := querysubject.ExtractPlainSubject(userInfo)
|
||||
if name == "" && mobile == "" && idCard == "" {
|
||||
return nil
|
||||
}
|
||||
row := &model.QuerySubjectIndex{
|
||||
Id: uuid.New().String(),
|
||||
QueryId: queryId,
|
||||
OrderId: orderId,
|
||||
DelState: globalkey.DelStateNo,
|
||||
Version: 0,
|
||||
}
|
||||
if enc, ok, err := crypto.EncryptDeterministicOptional(name, aesKey); err != nil {
|
||||
return err
|
||||
} else if ok {
|
||||
row.EncRealName = sql.NullString{String: enc, Valid: true}
|
||||
}
|
||||
if enc, ok, err := crypto.EncryptDeterministicOptional(mobile, aesKey); err != nil {
|
||||
return err
|
||||
} else if ok {
|
||||
row.EncMobile = sql.NullString{String: enc, Valid: true}
|
||||
}
|
||||
if enc, ok, err := crypto.EncryptDeterministicOptional(idCard, aesKey); err != nil {
|
||||
return err
|
||||
} else if ok {
|
||||
row.EncIdCard = sql.NullString{String: enc, Valid: true}
|
||||
}
|
||||
_, err := l.svcCtx.QuerySubjectIndexModel.Insert(ctx, row)
|
||||
return err
|
||||
}
|
||||
|
||||
// desensitizeParams 对敏感数据进行脱敏处理
|
||||
func (l *PaySuccessNotifyUserHandler) desensitizeParams(data []byte) ([]byte, error) {
|
||||
// 解析JSON数据到map
|
||||
|
||||
Reference in New Issue
Block a user