2026-01-22 16:04:12 +08:00
|
|
|
|
package query
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"context"
|
2026-01-30 11:39:28 +08:00
|
|
|
|
"database/sql"
|
2026-01-22 16:04:12 +08:00
|
|
|
|
"encoding/hex"
|
|
|
|
|
|
"encoding/json"
|
|
|
|
|
|
"fmt"
|
2026-01-30 11:39:28 +08:00
|
|
|
|
"os"
|
2026-01-22 16:04:12 +08:00
|
|
|
|
"time"
|
|
|
|
|
|
"tyc-server/app/main/api/internal/service"
|
|
|
|
|
|
"tyc-server/app/main/model"
|
|
|
|
|
|
"tyc-server/common/ctxdata"
|
2026-01-30 11:39:28 +08:00
|
|
|
|
"tyc-server/common/globalkey"
|
2026-01-22 16:04:12 +08:00
|
|
|
|
"tyc-server/common/xerr"
|
|
|
|
|
|
"tyc-server/pkg/lzkit/crypto"
|
|
|
|
|
|
"tyc-server/pkg/lzkit/validator"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/redis"
|
|
|
|
|
|
|
|
|
|
|
|
"tyc-server/app/main/api/internal/svc"
|
|
|
|
|
|
"tyc-server/app/main/api/internal/types"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type QueryServiceLogic struct {
|
|
|
|
|
|
logx.Logger
|
|
|
|
|
|
ctx context.Context
|
|
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewQueryServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryServiceLogic {
|
|
|
|
|
|
return &QueryServiceLogic{
|
|
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
|
|
ctx: ctx,
|
|
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (l *QueryServiceLogic) QueryService(req *types.QueryServiceReq) (resp *types.QueryServiceResp, err error) {
|
|
|
|
|
|
if req.AgentIdentifier != "" {
|
|
|
|
|
|
l.ctx = context.WithValue(l.ctx, "agentIdentifier", req.AgentIdentifier)
|
|
|
|
|
|
} else if req.App {
|
|
|
|
|
|
l.ctx = context.WithValue(l.ctx, "app", req.App)
|
|
|
|
|
|
}
|
|
|
|
|
|
return l.PreprocessLogic(req, req.Product)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// queryHandlerFunc 通用查询 handler:解密后的数据 + 产品名 -> 校验并返回待缓存的 params
|
|
|
|
|
|
// 新增产品时只需在 productHandlers 里加一行并选用已有 handler 类型即可,无需再写 ProcessXxx
|
|
|
|
|
|
type queryHandlerFunc func(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error)
|
|
|
|
|
|
|
|
|
|
|
|
var productHandlers = map[string]queryHandlerFunc{
|
|
|
|
|
|
"marriage": runMarriageReq,
|
|
|
|
|
|
"homeservice": runMarriageReq,
|
|
|
|
|
|
"riskassessment": runMarriageReq,
|
|
|
|
|
|
"companyinfo": runMarriageReq,
|
|
|
|
|
|
"rentalinfo": runMarriageReq,
|
|
|
|
|
|
"preloanbackgroundcheck": runMarriageReq,
|
|
|
|
|
|
"backgroundcheck": runMarriageReq,
|
|
|
|
|
|
"personalData": runMarriageReq,
|
|
|
|
|
|
"toc_PersonalLawsuit": runMarriageReq,
|
|
|
|
|
|
"toc_EnterpriseLawsuit": runEntLawsuitReq,
|
|
|
|
|
|
"toc_ExecutedPerson": runMarriageReq,
|
|
|
|
|
|
"toc_LimitHigh": runMarriageReq,
|
|
|
|
|
|
"toc_Marriage": runMarriageReq,
|
|
|
|
|
|
"toc_PersonalMarriageStatus": runMarriageReq,
|
|
|
|
|
|
"toc_MarriageStatusRegisterTime": runMarriageReq,
|
|
|
|
|
|
"toc_MarriageStatusSupplement": runMarriageReq,
|
|
|
|
|
|
"toc_MarriageStatusVerify": runMarriageReq,
|
|
|
|
|
|
"toc_DualMarriageStatusRegisterTime": runDualMarriageReq,
|
|
|
|
|
|
"toc_VehiclesUnderName": runMarriageReq,
|
|
|
|
|
|
"toc_VehiclesUnderNamePlate": runMarriageReq,
|
|
|
|
|
|
"toc_PersonVehicleVerification": runPersonVehicleVerificationReq,
|
|
|
|
|
|
"toc_PersonVehicleVerificationDetail": runPersonVehicleVerificationReq,
|
|
|
|
|
|
// 车辆类产品(按 md 传参)
|
|
|
|
|
|
"toc_VehiclesUnderNameCount": runVehiclesUnderNameCountReq,
|
|
|
|
|
|
"toc_VehicleStaticInfo": runVehicleVinCodeReq,
|
|
|
|
|
|
"toc_VehicleMileageMixed": runVehicleMileageMixedReq,
|
|
|
|
|
|
"toc_VehicleVinValuation": runVehicleVinValuationReq,
|
|
|
|
|
|
"toc_VehicleTransferSimple": runVehicleTransferSimpleReq,
|
|
|
|
|
|
"toc_VehicleTransferDetail": runVehicleVinCodeReq,
|
|
|
|
|
|
"toc_VehicleMaintenanceSimple": runVehicleMaintenanceSimpleReq,
|
|
|
|
|
|
"toc_VehicleMaintenanceDetail": runVehicleMaintenanceDetailReq,
|
|
|
|
|
|
"toc_VehicleClaimDetail": runVehicleClaimDetailReq,
|
|
|
|
|
|
"toc_VehicleClaimVerify": runVehicleClaimVerifyReq,
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (l *QueryServiceLogic) PreprocessLogic(req *types.QueryServiceReq, product string) (*types.QueryServiceResp, error) {
|
2026-02-06 13:34:49 +08:00
|
|
|
|
decryptData, err := l.DecryptData(req.Data)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, err
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
handler, exists := productHandlers[product]
|
|
|
|
|
|
if !exists {
|
|
|
|
|
|
return nil, errors.New("未找到相应的处理程序")
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
params, err := handler(l, decryptData, product)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, err
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return l.commonQueryTail(params, product)
|
|
|
|
|
|
}
|
2026-01-22 16:04:12 +08:00
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// commonQueryTail 通用收尾:写缓存、生成 token 并返回
|
|
|
|
|
|
func (l *QueryServiceLogic) commonQueryTail(params map[string]interface{}, product string) (*types.QueryServiceResp, error) {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
userID, err := l.GetOrCreateUser()
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 处理用户失败: %v", err)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
cacheNo, cacheDataErr := l.CacheData(params, product, userID)
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if cacheDataErr != nil {
|
|
|
|
|
|
return nil, cacheDataErr
|
|
|
|
|
|
}
|
|
|
|
|
|
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
|
|
|
|
|
}
|
|
|
|
|
|
now := time.Now().Unix()
|
|
|
|
|
|
return &types.QueryServiceResp{
|
|
|
|
|
|
Id: cacheNo,
|
|
|
|
|
|
AccessToken: token,
|
|
|
|
|
|
AccessExpire: now + l.svcCtx.Config.JwtAuth.AccessExpire,
|
|
|
|
|
|
RefreshAfter: now + l.svcCtx.Config.JwtAuth.RefreshAfter,
|
|
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runMarriageReq 姓名+身份证+手机+验证码 类产品(婚恋、家政、司法涉诉、婚姻状况、名下车辆等)
|
|
|
|
|
|
func runMarriageReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.MarriageReq
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyErr := l.Verify(data.Name, data.IDCard, data.Mobile); verifyErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
2026-01-22 16:04:12 +08:00
|
|
|
|
"name": data.Name,
|
|
|
|
|
|
"id_card": data.IDCard,
|
|
|
|
|
|
"mobile": data.Mobile,
|
|
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runEntLawsuitReq 企业司法涉诉:企业名称+统一社会信用代码+手机+验证码
|
|
|
|
|
|
func runEntLawsuitReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.EntLawsuitReq
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"ent_name": data.EntName,
|
|
|
|
|
|
"ent_code": data.EntCode,
|
|
|
|
|
|
"mobile": data.Mobile,
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runDualMarriageReq 双人婚姻状态:男方/女方姓名+身份证+手机+验证码
|
|
|
|
|
|
func runDualMarriageReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocDualMarriageReq
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyErr := l.VerifyTwo(data.NameMan, data.IDCardMan); verifyErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyErr := l.VerifyTwo(data.NameWoman, data.IDCardWoman); verifyErr != nil {
|
|
|
|
|
|
return nil, verifyErr
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"name": data.NameMan,
|
|
|
|
|
|
"id_card": data.IDCardMan,
|
|
|
|
|
|
"mobile": data.Mobile,
|
|
|
|
|
|
"name_man": data.NameMan,
|
|
|
|
|
|
"id_card_man": data.IDCardMan,
|
|
|
|
|
|
"name_woman": data.NameWoman,
|
|
|
|
|
|
"id_card_woman": data.IDCardWoman,
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runPersonVehicleVerificationReq 人车核验简版:姓名+号牌类型+车牌号
|
|
|
|
|
|
func runPersonVehicleVerificationReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocPersonVehicleVerification
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"name": data.Name,
|
|
|
|
|
|
"plate_no": data.CarLicense,
|
|
|
|
|
|
"carplate_type": data.CarType,
|
|
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
2026-01-22 16:04:12 +08:00
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runVehiclesUnderNameCountReq 名下车辆(数量) QCXG4D2E:仅 user_type + id_card
|
|
|
|
|
|
func runVehiclesUnderNameCountReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocVehiclesUnderNameCountReq
|
|
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
userType := data.UserType
|
|
|
|
|
|
if userType == "" {
|
|
|
|
|
|
userType = "1"
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"user_type": userType,
|
|
|
|
|
|
"id_card": data.IDCard,
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runVehicleVinCodeReq 仅 vin_code(车辆静态信息、过户详版等)
|
|
|
|
|
|
func runVehicleVinCodeReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocVehicleVinCodeReq
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"vin_code": data.VinCode,
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runVehicleMileageMixedReq 车辆里程记录(混合) QCXG1U4U
|
|
|
|
|
|
func runVehicleMileageMixedReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocVehicleMileageMixedReq
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"vin_code": data.VinCode,
|
|
|
|
|
|
"return_url": data.ReturnURL,
|
|
|
|
|
|
"image_url": data.ImageURL,
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runVehicleVinValuationReq 二手车VIN估值 QCXGY7F2(仅必填)
|
|
|
|
|
|
func runVehicleVinValuationReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocVehicleVinValuationReq
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"vin_code": data.VinCode,
|
|
|
|
|
|
"vehicle_location": data.VehicleLocation,
|
|
|
|
|
|
"first_registrationdate": data.FirstRegistrationDate,
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runVehicleTransferSimpleReq 车辆过户简版 QCXG1H7Y(仅必填 vin_code)
|
|
|
|
|
|
func runVehicleTransferSimpleReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocVehicleTransferSimpleReq
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{"vin_code": data.VinCode}, nil
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runVehicleMaintenanceSimpleReq 车辆维保简版 QCXG3Y6B(仅必填 vin_code, return_url)
|
|
|
|
|
|
func runVehicleMaintenanceSimpleReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocVehicleMaintenanceSimpleReq
|
2026-02-02 19:35:58 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-02-02 19:35:58 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"vin_code": data.VinCode,
|
|
|
|
|
|
"return_url": data.ReturnURL,
|
2026-02-02 19:35:58 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
2026-01-22 16:04:12 +08:00
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runVehicleMaintenanceDetailReq 车辆维保详细版 QCXG3Z3L(仅必填 vin_code, return_url)
|
|
|
|
|
|
func runVehicleMaintenanceDetailReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocVehicleMaintenanceDetailReq
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"vin_code": data.VinCode,
|
|
|
|
|
|
"return_url": data.ReturnURL,
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runVehicleClaimDetailReq 车辆出险详版 QCXGP00W(仅必填 vin_code, return_url, vlphoto_data),vlphoto_data 由 API 层加密为 data
|
|
|
|
|
|
func runVehicleClaimDetailReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocVehicleClaimDetailReq
|
2026-01-22 16:04:12 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"vin_code": data.VinCode,
|
|
|
|
|
|
"return_url": data.ReturnURL,
|
|
|
|
|
|
"vlphoto_data": data.VlphotoData,
|
2026-02-02 19:35:58 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
2026-01-22 16:04:12 +08:00
|
|
|
|
|
2026-02-06 13:34:49 +08:00
|
|
|
|
// runVehicleClaimVerifyReq 车辆出险记录核验 QCXG6B4E
|
|
|
|
|
|
func runVehicleClaimVerifyReq(l *QueryServiceLogic, decryptData []byte, product string) (map[string]interface{}, error) {
|
|
|
|
|
|
var data types.TocVehicleClaimVerifyReq
|
2026-02-02 19:35:58 +08:00
|
|
|
|
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if validatorErr := validator.Validate(data); validatorErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
if verifyCodeErr := l.VerifyCode(data.Mobile, data.Code); verifyCodeErr != nil {
|
2026-02-02 19:35:58 +08:00
|
|
|
|
return nil, verifyCodeErr
|
|
|
|
|
|
}
|
2026-02-06 13:34:49 +08:00
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
|
"vin_code": data.VINCode,
|
|
|
|
|
|
"authorized": data.Authorized,
|
2026-01-22 16:04:12 +08:00
|
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (l *QueryServiceLogic) DecryptData(data string) ([]byte, error) {
|
|
|
|
|
|
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
|
|
|
|
|
key, decodeErr := hex.DecodeString(secretKey)
|
|
|
|
|
|
if decodeErr != nil {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "密钥获取失败: %+v", decodeErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
decryptData, aesDecryptErr := crypto.AesDecrypt(data, key)
|
|
|
|
|
|
if aesDecryptErr != nil || len(decryptData) == 0 {
|
|
|
|
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "解密失败: %+v", aesDecryptErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
return decryptData, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-30 11:39:28 +08:00
|
|
|
|
// 校验验证码(开发环境 ENV=development 可跳过)
|
2026-01-22 16:04:12 +08:00
|
|
|
|
func (l *QueryServiceLogic) VerifyCode(mobile string, code string) error {
|
2026-01-30 11:39:28 +08:00
|
|
|
|
if os.Getenv("ENV") == "development" {
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
2026-01-22 16:04:12 +08:00
|
|
|
|
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
|
|
|
|
|
encryptedMobile, err := crypto.EncryptMobile(mobile, secretKey)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "加密手机号失败: %+v", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
codeRedisKey := fmt.Sprintf("%s:%s", "query", encryptedMobile)
|
|
|
|
|
|
cacheCode, err := l.svcCtx.Redis.Get(codeRedisKey)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
if errors.Is(err, redis.Nil) {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrMsg("验证码已过期"), "验证码过期: %s", mobile)
|
|
|
|
|
|
}
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "读取验证码redis缓存失败, mobile: %s, err: %+v", mobile, err)
|
|
|
|
|
|
}
|
|
|
|
|
|
if cacheCode != code {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrMsg("验证码不正确"), "验证码不正确: %s", mobile)
|
|
|
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-25 17:02:24 +08:00
|
|
|
|
func (l *QueryServiceLogic) IsAgentQuery() bool {
|
|
|
|
|
|
agentID, _ := l.ctx.Value("agentIdentifier").(string)
|
|
|
|
|
|
return agentID != ""
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-30 11:39:28 +08:00
|
|
|
|
// 二要素验证(仅姓名+身份证号)(开发环境不调用验证 API)
|
2026-01-22 16:04:12 +08:00
|
|
|
|
func (l *QueryServiceLogic) VerifyTwo(Name string, IDCard string) error {
|
2026-01-30 11:39:28 +08:00
|
|
|
|
if os.Getenv("ENV") == "development" {
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
2026-01-22 16:04:12 +08:00
|
|
|
|
twoVerification := service.TwoFactorVerificationRequest{
|
|
|
|
|
|
Name: Name,
|
|
|
|
|
|
IDCard: IDCard,
|
|
|
|
|
|
}
|
|
|
|
|
|
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "二要素验证失败: %v", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
if !verification.Passed {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "二要素验证不通过: %v", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-30 11:39:28 +08:00
|
|
|
|
// 按代理/非代理切换要素验证:代理走三要素;非代理走二要素(开发环境不调用验证 API)
|
2026-01-22 16:04:12 +08:00
|
|
|
|
func (l *QueryServiceLogic) Verify(Name string, IDCard string, Mobile string) error {
|
2026-01-30 11:39:28 +08:00
|
|
|
|
if os.Getenv("ENV") == "development" {
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
2026-01-25 17:02:24 +08:00
|
|
|
|
if !l.IsAgentQuery() {
|
2026-01-22 16:04:12 +08:00
|
|
|
|
twoVerification := service.TwoFactorVerificationRequest{
|
|
|
|
|
|
Name: Name,
|
|
|
|
|
|
IDCard: IDCard,
|
|
|
|
|
|
}
|
|
|
|
|
|
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "二要素验证失败: %v", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
if !verification.Passed {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "二要素验证不通过: %v", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 三要素验证
|
2026-01-25 17:02:24 +08:00
|
|
|
|
if Mobile == "" {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, "手机号不能为空"), "三要素验证参数不正确: mobile为空")
|
|
|
|
|
|
}
|
2026-01-22 16:04:12 +08:00
|
|
|
|
threeVerification := service.ThreeFactorVerificationRequest{
|
|
|
|
|
|
Name: Name,
|
|
|
|
|
|
IDCard: IDCard,
|
|
|
|
|
|
Mobile: Mobile,
|
|
|
|
|
|
}
|
|
|
|
|
|
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "三要素验证失败: %v", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
if !verification.Passed {
|
|
|
|
|
|
return errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "三要素验证不通过: %v", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 缓存
|
|
|
|
|
|
func (l *QueryServiceLogic) CacheData(params map[string]interface{}, Product string, userID int64) (string, error) {
|
|
|
|
|
|
agentIdentifier, _ := l.ctx.Value("agentIdentifier").(string)
|
|
|
|
|
|
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
|
|
|
|
|
key, decodeErr := hex.DecodeString(secretKey)
|
|
|
|
|
|
if decodeErr != nil {
|
|
|
|
|
|
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 获取AES密钥失败: %+v", decodeErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
paramsMarshal, marshalErr := json.Marshal(params)
|
|
|
|
|
|
if marshalErr != nil {
|
|
|
|
|
|
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 序列化参数失败: %+v", marshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
encryptParams, aesEncryptErr := crypto.AesEncrypt(paramsMarshal, key)
|
|
|
|
|
|
if aesEncryptErr != nil {
|
|
|
|
|
|
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 加密参数失败: %+v", aesEncryptErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
queryCache := types.QueryCacheLoad{
|
|
|
|
|
|
Params: encryptParams,
|
|
|
|
|
|
Product: Product,
|
|
|
|
|
|
AgentIdentifier: agentIdentifier,
|
|
|
|
|
|
}
|
|
|
|
|
|
jsonData, marshalErr := json.Marshal(queryCache)
|
|
|
|
|
|
if marshalErr != nil {
|
|
|
|
|
|
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 序列化参数失败: %+v", marshalErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
outTradeNo := "Q_" + l.svcCtx.AlipayService.GenerateOutTradeNo()
|
|
|
|
|
|
redisKey := fmt.Sprintf(types.QueryCacheKey, userID, outTradeNo)
|
|
|
|
|
|
cacheErr := l.svcCtx.Redis.SetexCtx(l.ctx, redisKey, string(jsonData), int(2*time.Hour))
|
|
|
|
|
|
if cacheErr != nil {
|
|
|
|
|
|
return "", cacheErr
|
|
|
|
|
|
}
|
2026-01-30 11:39:28 +08:00
|
|
|
|
|
|
|
|
|
|
// 写入 query_user_record,用于后台按被查询人姓名/身份证/手机号追溯订单(见 query_user_record.sql 说明 1)
|
|
|
|
|
|
nameStr, _ := params["name"].(string)
|
|
|
|
|
|
idCardStr, _ := params["id_card"].(string)
|
|
|
|
|
|
mobileStr, _ := params["mobile"].(string)
|
|
|
|
|
|
if nameStr != "" || idCardStr != "" || mobileStr != "" {
|
|
|
|
|
|
var encName, encIdCard, encMobile string
|
|
|
|
|
|
if nameStr != "" {
|
|
|
|
|
|
encName, _ = crypto.AesEcbEncrypt([]byte(nameStr), key)
|
|
|
|
|
|
}
|
|
|
|
|
|
if idCardStr != "" {
|
|
|
|
|
|
encIdCard, _ = crypto.EncryptIDCard(idCardStr, key)
|
|
|
|
|
|
}
|
|
|
|
|
|
if mobileStr != "" {
|
|
|
|
|
|
encMobile, _ = crypto.EncryptMobile(mobileStr, secretKey)
|
|
|
|
|
|
}
|
|
|
|
|
|
agentIdent := sql.NullString{}
|
|
|
|
|
|
if agentIdentifier != "" {
|
|
|
|
|
|
agentIdent = sql.NullString{String: agentIdentifier, Valid: true}
|
|
|
|
|
|
}
|
|
|
|
|
|
rec := &model.QueryUserRecord{
|
|
|
|
|
|
DeleteTime: sql.NullTime{},
|
|
|
|
|
|
DelState: globalkey.DelStateNo,
|
|
|
|
|
|
Version: 0,
|
|
|
|
|
|
UserId: userID,
|
|
|
|
|
|
Name: encName,
|
|
|
|
|
|
IdCard: encIdCard,
|
|
|
|
|
|
Mobile: encMobile,
|
|
|
|
|
|
Product: Product,
|
|
|
|
|
|
QueryNo: outTradeNo,
|
|
|
|
|
|
OrderId: 0,
|
|
|
|
|
|
PlatformOrderId: sql.NullString{},
|
|
|
|
|
|
AgentIdentifier: agentIdent,
|
|
|
|
|
|
}
|
|
|
|
|
|
_, insertErr := l.svcCtx.QueryUserRecordModel.Insert(l.ctx, nil, rec)
|
|
|
|
|
|
if insertErr != nil {
|
|
|
|
|
|
logx.WithContext(l.ctx).Errorf("CacheData 写入 query_user_record 失败: %v", insertErr)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-22 16:04:12 +08:00
|
|
|
|
return outTradeNo, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GetOrCreateUser 获取或创建用户
|
|
|
|
|
|
// 1. 如果上下文中已有用户ID,直接返回
|
|
|
|
|
|
// 2. 如果是代理查询或APP请求,创建新用户
|
|
|
|
|
|
// 3. 其他情况返回未登录错误
|
|
|
|
|
|
func (l *QueryServiceLogic) GetOrCreateUser() (int64, error) {
|
|
|
|
|
|
// 尝试获取用户ID
|
|
|
|
|
|
claims, err := ctxdata.GetClaimsFromCtx(l.ctx)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return 0, err
|
|
|
|
|
|
}
|
|
|
|
|
|
userID := claims.UserId
|
|
|
|
|
|
return userID, nil
|
|
|
|
|
|
|
|
|
|
|
|
// // 如果不是未登录错误,说明是其他错误,直接返回
|
|
|
|
|
|
// if !ctxdata.IsNoUserIdError(err) {
|
|
|
|
|
|
// return 0, err
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// // 检查是否是代理查询或APP请求
|
|
|
|
|
|
// isAgentQuery := false
|
|
|
|
|
|
// if agentID, ok := l.ctx.Value("agentIdentifier").(string); ok && agentID != "" {
|
|
|
|
|
|
// isAgentQuery = true
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if app, ok := l.ctx.Value("app").(bool); ok && app {
|
|
|
|
|
|
// isAgentQuery = true
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// // 如果不是代理查询或APP请求,返回未登录错误
|
|
|
|
|
|
// if !isAgentQuery {
|
|
|
|
|
|
// return 0, ctxdata.ErrNoUserIdInCtx
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// // 创建新用户
|
|
|
|
|
|
// return l.svcCtx.UserService.RegisterUUIDUser(l.ctx)
|
|
|
|
|
|
}
|