新增天聚数行平台,手机归属地查询,身份证归属地查询

This commit is contained in:
liangzai 2025-03-20 20:32:57 +08:00
parent 9eb13590fc
commit b8377d8887
8 changed files with 382 additions and 172 deletions

View File

@ -28,6 +28,9 @@ YushanConfig:
ApiKey: "4c566c4a4b543164535455685655316c" ApiKey: "4c566c4a4b543164535455685655316c"
AcctID: "YSSJ843926726" AcctID: "YSSJ843926726"
Url: "http://proxy.tianyuanapi.com/credit-gw/service" Url: "http://proxy.tianyuanapi.com/credit-gw/service"
TianjuConfig:
ApiKey: "479bcac2a77b56e976d044ff2bd996f4"
Url: "https://apis.tianapi.com"
Alipay: Alipay:
AppID: "2021004165608254" AppID: "2021004165608254"
PrivateKey: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCvo8TmTNnVguKwMYrX0z01PfUlSS+AqwwCH1+/P39q6No+09yO1bjhy4LowtDfwKX8F+IZLl5Cx06f1M8KzPvjQliBAfMJ1FuTEOOXPmtE1YLAYIUMLbltR6Crnp16T28eF41Uo0PUo2ple/oSjWhYgsTJjyBMXY04f6HM2uZlHOhG2aOUz2CDNbvkEhNddazuPMgo8Xl7vwENGDFTPa85HmSSoDppFowLdYfAw2Jl1ilKNg4sOPc6d507nXdgpMlUguwZxol6OQ2hBS6v9OjII5cJ1tyR/klJRapnIPmFaPvhDozYwjU6Z3jMvcbrByl0qNpLrbEFS4pn9hfRo4YrAgMBAAECggEAZAi0Ri6TCqXnEk7FMzMec0p8auYJ5hCFYFgaIkS5/1vroUjtH3TePcu5HXSHnkiMwM2hepIMIaB+SU3dNduVwtOwsJk5oOmP1m0SErv8QFISjBrs7AjGyVS4T8ahDl5bfRoQ5pmuMld4a6B2x0Y+ndqs1ddsn9HQctNOhexOuFsSjX1N3PZxFzfRTmGzxf7kwZGlXMN7G1r3Rp4koylYHVpqjXIK34Anc8SVljxFVkFOk62QvBdYcCucepymHNl0pYwPDCCylPH8OpIXOErmPldTflmoLRc+ywu9rw4I8UvkoPgT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B8Kf8/WBcJSJ8JX5/UMw7/4PTWEaaAf4wKBgQCEXu7YVgIccYbV7wdQhm7q3rxFI7hTkU6UL4ylRDQPCJDyhREUValf0DozS1XkdueM3MWWJ8i0N+G/MsohnjdQTnZT+DBQFqM5eEai/Y1AAWpMw5N5oS2O1barIR1iU2053QzeZwCyfuTuUFRjk+mSevhFSgDfKN5qKRTor7kDUQKBgB3fC6jO8XCwimPvpsiGnuddNAq/w8iqSjSwuSvbI0Q7Lq6rvAIw2AmkC5t4kW4JcZLUgDvAs4GFoPDYhoL73vc1e2c35VTNck6IxZSQzzQ9pfXFiLtTe6eqggN4EOPGHKLd92CMAgoeySsp3NydpGSx2N/NUqp8BkoFLQ/k2W9o"

View File

@ -3,58 +3,61 @@ Host: 0.0.0.0
Port: 8888 Port: 8888
DataSource: "qnc:5vg67b3UNHu8@tcp(qnc_mysql:3306)/qnc?charset=utf8mb4&parseTime=True&loc=Local" DataSource: "qnc:5vg67b3UNHu8@tcp(qnc_mysql:3306)/qnc?charset=utf8mb4&parseTime=True&loc=Local"
CacheRedis: CacheRedis:
- Host: "qnc_redis:6379" - Host: "qnc_redis:6379"
Pass: "3m3WsgyCKWqz" # Redis 密码,如果未设置则留空 Pass: "3m3WsgyCKWqz" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式 Type: "node" # 单节点模式
JwtAuth: JwtAuth:
AccessSecret: "WUvoIwL-FK0qnlxhvxR9tV6SjfOpeJMpKmY2QvT99lA" AccessSecret: "WUvoIwL-FK0qnlxhvxR9tV6SjfOpeJMpKmY2QvT99lA"
AccessExpire: 2592000 AccessExpire: 2592000
RefreshAfter: 1296000 RefreshAfter: 1296000
VerifyCode: VerifyCode:
AccessKeyID: "LTAI5tKGB3TVJbMHSoZN3yr9" AccessKeyID: "LTAI5tKGB3TVJbMHSoZN3yr9"
AccessKeySecret: "OCQ30GWp4yENMjmfOAaagksE18bp65" AccessKeySecret: "OCQ30GWp4yENMjmfOAaagksE18bp65"
EndpointURL: "dysmsapi.aliyuncs.com" EndpointURL: "dysmsapi.aliyuncs.com"
SignName: "全能查" SignName: "全能查"
TemplateCode: "SMS_473780047" TemplateCode: "SMS_473780047"
ValidTime: 300 ValidTime: 300
Encrypt: Encrypt:
SecretKey: "ff83609b2b24fc73196aac3d3dfb874f" SecretKey: "ff83609b2b24fc73196aac3d3dfb874f"
WestConfig: WestConfig:
Url: "https://apimaster.westdex.com.cn/api/invoke" Url: "https://apimaster.westdex.com.cn/api/invoke"
Key: "121a1e41fc1690dd6b90afbcacd80cf4" Key: "121a1e41fc1690dd6b90afbcacd80cf4"
SecretId: "449159" SecretId: "449159"
SecretSecondId: "296804" SecretSecondId: "296804"
YushanConfig: YushanConfig:
ApiKey: "4c566c4a4b543164535455685655316c" ApiKey: "4c566c4a4b543164535455685655316c"
AcctID: "YSSJ843926726" AcctID: "YSSJ843926726"
Url: "https://api.yushanshuju.com/credit-gw/service" Url: "https://api.yushanshuju.com/credit-gw/service"
TianjuConfig:
ApiKey: "479bcac2a77b56e976d044ff2bd996f4"
Url: "https://apis.tianapi.com"
Alipay: Alipay:
AppID: "2021004165608254" AppID: "2021004165608254"
PrivateKey: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCvo8TmTNnVguKwMYrX0z01PfUlSS+AqwwCH1+/P39q6No+09yO1bjhy4LowtDfwKX8F+IZLl5Cx06f1M8KzPvjQliBAfMJ1FuTEOOXPmtE1YLAYIUMLbltR6Crnp16T28eF41Uo0PUo2ple/oSjWhYgsTJjyBMXY04f6HM2uZlHOhG2aOUz2CDNbvkEhNddazuPMgo8Xl7vwENGDFTPa85HmSSoDppFowLdYfAw2Jl1ilKNg4sOPc6d507nXdgpMlUguwZxol6OQ2hBS6v9OjII5cJ1tyR/klJRapnIPmFaPvhDozYwjU6Z3jMvcbrByl0qNpLrbEFS4pn9hfRo4YrAgMBAAECggEAZAi0Ri6TCqXnEk7FMzMec0p8auYJ5hCFYFgaIkS5/1vroUjtH3TeP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iG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2CqoCp95w/JV3RT/gzF4/8QmVT1HQNaeW7yUp+mA7x9AbjvlTW/+eRn6oGAL/XhZLjvHD0XjKLVKX0MJVS1aUQHEHEbOJN4Eu8II45OavD4iZISa7Kp9V6AM+i4qTyaeV2wNDnGxHQBaLVUGCfMR+56EK2YpORdE1H9uy72SSQseVb3bmpsV9EW/IJNmcVL/ut3uA1JWAoRmzlQ7ekxg7p8AYXzYPEHQr1tl7W+M4zv9wO9GKZCxIqMA8U3RP5npPfRaCfIRGzXzCqFEEUvWuidOB7frsvN4jiPD07qpL2Bi9LM1X/ee2kC/oM8Uhd7ERZhG8MbZfijZKxgrsDKBcwIDAQAB"
IsProduction: true IsProduction: true
NotifyUrl: "https://www.tianyuancha.cn/api/v1/pay/alipay/callback" NotifyUrl: "https://www.tianyuancha.cn/api/v1/pay/alipay/callback"
ReturnURL: "https://www.tianyuancha.cn/report" ReturnURL: "https://www.tianyuancha.cn/report"
Wxpay: Wxpay:
AppID: "wxba8424db4771cc18" AppID: "wxba8424db4771cc18"
AppSecret: "89646203d7f76eb7aef0d926b9efffaa" AppSecret: "89646203d7f76eb7aef0d926b9efffaa"
MchID: "1682635136" MchID: "1682635136"
MchCertificateSerialNumber: "5369B8AEEBDCF7AF274510252E6A8C0659C30F61" MchCertificateSerialNumber: "5369B8AEEBDCF7AF274510252E6A8C0659C30F61"
MchApiv3Key: "e3ea4cf0765f1e71b01bb387dfcdbc9f" MchApiv3Key: "e3ea4cf0765f1e71b01bb387dfcdbc9f"
MchPrivateKeyPath: "etc/merchant/apiclient_key.pem" MchPrivateKeyPath: "etc/merchant/apiclient_key.pem"
NotifyUrl: "https://www.tianyuancha.cn/api/v1/pay/wechat/callback" NotifyUrl: "https://www.tianyuancha.cn/api/v1/pay/wechat/callback"
RefundNotifyUrl: "https://www.tianyuancha.cn/api/v1/wechat/refund_callback" RefundNotifyUrl: "https://www.tianyuancha.cn/api/v1/wechat/refund_callback"
Applepay: Applepay:
ProductionVerifyURL: "https://api.storekit.itunes.apple.com/inApps/v1/transactions/receipt" ProductionVerifyURL: "https://api.storekit.itunes.apple.com/inApps/v1/transactions/receipt"
SandboxVerifyURL: "https://api.storekit-sandbox.itunes.apple.com/inApps/v1/transactions/receipt" SandboxVerifyURL: "https://api.storekit-sandbox.itunes.apple.com/inApps/v1/transactions/receipt"
Sandbox: true Sandbox: true
BundleID: "com.allinone.check" BundleID: "com.allinone.check"
IssuerID: "bf828d85-5269-4914-9660-c066e09cd6ef" IssuerID: "bf828d85-5269-4914-9660-c066e09cd6ef"
KeyID: "LAY65829DQ" KeyID: "LAY65829DQ"
LoadPrivateKeyPath: "etc/merchant/AuthKey_LAY65829DQ.p8" LoadPrivateKeyPath: "etc/merchant/AuthKey_LAY65829DQ.p8"
Ali: Ali:
Code: "d55b58829efb41c8aa8e86769cba4844" Code: "d55b58829efb41c8aa8e86769cba4844"
SystemConfig: SystemConfig:
ThreeVerify: false ThreeVerify: false

View File

@ -18,6 +18,7 @@ type Config struct {
Ali AliConfig Ali AliConfig
WestConfig WestConfig WestConfig WestConfig
YushanConfig YushanConfig YushanConfig YushanConfig
TianjuConfig TianjuConfig
SystemConfig SystemConfig SystemConfig SystemConfig
} }
@ -80,6 +81,10 @@ type YushanConfig struct {
AcctID string AcctID string
Url string Url string
} }
type TianjuConfig struct {
ApiKey string
BaseURL string
}
type SystemConfig struct { type SystemConfig struct {
ThreeVerify bool ThreeVerify bool
} }

View File

@ -38,6 +38,85 @@ func NewQueryServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Quer
func (l *QueryServiceLogic) QueryService(req *types.QueryServiceReq) (resp *types.QueryServiceResp, err error) { func (l *QueryServiceLogic) QueryService(req *types.QueryServiceReq) (resp *types.QueryServiceResp, err error) {
return l.PreprocessLogic(req, req.Product) return l.PreprocessLogic(req, req.Product)
} }
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
}
// 校验验证码
func (l *QueryServiceLogic) VerifyCode(mobile string, code string) error {
codeRedisKey := fmt.Sprintf("%s:%s", "query", mobile)
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
}
// 二、三要素验证
func (l *QueryServiceLogic) Verify(Name string, IDCard string, Mobile string) error {
if l.svcCtx.Config.SystemConfig.ThreeVerify {
// 三要素验证
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)
}
} else {
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
}
// 缓存
func (l *QueryServiceLogic) CacheData(params map[string]interface{}, Product string, userID int64) (string, error) {
queryCache := types.QueryCacheLoad{
Params: params,
Product: Product,
}
jsonData, marshalErr := json.Marshal(queryCache)
if marshalErr != nil {
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 序列化参数失败: %+v", marshalErr)
}
outTradeNo := l.svcCtx.WechatPayService.GenerateOutTradeNo()
redisKey := fmt.Sprintf("%d:%s", userID, outTradeNo)
cacheErr := l.svcCtx.Redis.SetexCtx(l.ctx, redisKey, string(jsonData), int(2*time.Hour))
if cacheErr != nil {
return "", cacheErr
}
return outTradeNo, nil
}
var productProcessors = map[string]func(*QueryServiceLogic, *types.QueryServiceReq) (*types.QueryServiceResp, error){ var productProcessors = map[string]func(*QueryServiceLogic, *types.QueryServiceReq) (*types.QueryServiceResp, error){
"marriage": (*QueryServiceLogic).ProcessMarriageLogic, "marriage": (*QueryServiceLogic).ProcessMarriageLogic,
@ -64,26 +143,30 @@ var productProcessors = map[string]func(*QueryServiceLogic, *types.QueryServiceR
"toc_BankCardFourElements": (*QueryServiceLogic).ProcessTocBankCardFourElementsLogic, "toc_BankCardFourElements": (*QueryServiceLogic).ProcessTocBankCardFourElementsLogic,
"toc_PersonalConsumptionRestriction": (*QueryServiceLogic).ProcessTocPersonalConsumptionRestrictionLogic, "toc_PersonalConsumptionRestriction": (*QueryServiceLogic).ProcessTocPersonalConsumptionRestrictionLogic,
"toc_PersonalDiscredit": (*QueryServiceLogic).ProcessTocPersonalDiscreditLogic, "toc_PersonalDiscredit": (*QueryServiceLogic).ProcessTocPersonalDiscreditLogic,
"toc_BankCardBlacklist": (*QueryServiceLogic).ProcessTocBankCardBlacklistLogic,
// 查车部分
"toc_vehicleInsuranceSummary": (*QueryServiceLogic).ProcessTocVehicleInsuranceSummaryLogic, // 车辆出险信息
"toc_vehicleMaintenanceRecord": (*QueryServiceLogic).ProcessTocVehicleMaintenanceRecordLogic, // 车辆维修记录
"toc_VehiclesUnderName": (*QueryServiceLogic).ProcessTocVehiclesUnderNameLogic, // 名下车辆
"toc_vehicleValuation": (*QueryServiceLogic).ProcessTocVehicleValuationLogic, // 车辆估值
"toc_chassisNumberCheck": (*QueryServiceLogic).ProcessTocChassisNumberCheckLogic, // 车辆识别代码
"toc_vehicleTransferCount": (*QueryServiceLogic).ProcessTocVehicleTransferCountLogic, // 车辆过户次数
"toc_ExitRestriction": (*QueryServiceLogic).ProcessTocExitRestrictionLogic, // 限制出境
"toc_MonthlyMobileConsumptionLevel": (*QueryServiceLogic).ProcessTocMonthlyMobileConsumptionLevelLogic, // 月消费水平
"toc_EducationVerification": (*QueryServiceLogic).ProcessTocEducationVerificationLogic, // 学历认证
"toc_FraudGamblingCheck": (*QueryServiceLogic).ProcessTocFraudGamblingCheckLogic, // 反赌反诈
"toc_MobileNumberValidation": (*QueryServiceLogic).ProcessTocMobileNumberValidationLogic, // 手机号验证
"toc_BankCardLocation": (*QueryServiceLogic).ProcessTocBankCardLocationLogic, // 银行卡归属地
"toc_BankCardNameElementVerification": (*QueryServiceLogic).ProcessTocBankCardNameElementVerificationLogic, // 银行卡姓名认证
"toc_BankCardIDElementVerification": (*QueryServiceLogic).ProcessTocBankCardIDElementVerificationLogic, // 银行卡身份证认证
"toc_BankCardThreeElementsVerification": (*QueryServiceLogic).ProcessTocBankCardThreeElementsVerificationLogic, // 银行卡三要素认证
"toc_MobileRiskAssessment": (*QueryServiceLogic).ProcessTocMobileRiskAssessmentLogic, // 手机号风险评估
"toc_MobileDrugFraudRiskCheck": (*QueryServiceLogic).ProcessTocMobileDrugFraudRiskCheckLogic, // 手机号反赌反诈
"toc_MobileLocation": (*QueryServiceLogic).ProcessTocMobileLocationLogic, // 手机归属地
"toc_IDCardLocation": (*QueryServiceLogic).ProcessTocIDCardLocationLogic, // 身份证归属地
// 车辆部分
"toc_BankCardBlacklist": (*QueryServiceLogic).ProcessTocBankCardBlacklistLogic,
"toc_VehiclesUnderName": (*QueryServiceLogic).ProcessTocVehiclesUnderNameLogic,
"toc_vehicleInsuranceSummary": (*QueryServiceLogic).ProcessTocVehicleInsuranceSummaryLogic,
"toc_vehicleMaintenanceRecord": (*QueryServiceLogic).ProcessTocVehicleMaintenanceRecordLogic,
"toc_vehicleValuation": (*QueryServiceLogic).ProcessTocVehicleValuationLogic,
"toc_chassisNumberCheck": (*QueryServiceLogic).ProcessTocChassisNumberCheckLogic,
"toc_vehicleTransferCount": (*QueryServiceLogic).ProcessTocVehicleTransferCountLogic,
"toc_ExitRestriction": (*QueryServiceLogic).ProcessTocExitRestrictionLogic,
"toc_MonthlyMobileConsumptionLevel": (*QueryServiceLogic).ProcessTocMonthlyMobileConsumptionLevelLogic,
"toc_EducationVerification": (*QueryServiceLogic).ProcessTocEducationVerificationLogic,
"toc_FraudGamblingCheck": (*QueryServiceLogic).ProcessTocFraudGamblingCheckLogic,
"toc_MobileNumberValidation": (*QueryServiceLogic).ProcessTocMobileNumberValidationLogic,
"toc_BankCardLocation": (*QueryServiceLogic).ProcessTocBankCardLocationLogic,
"toc_BankCardNameElementVerification": (*QueryServiceLogic).ProcessTocBankCardNameElementVerificationLogic,
"toc_BankCardIDElementVerification": (*QueryServiceLogic).ProcessTocBankCardIDElementVerificationLogic,
"toc_BankCardThreeElementsVerification": (*QueryServiceLogic).ProcessTocBankCardThreeElementsVerificationLogic,
"toc_MobileRiskAssessment": (*QueryServiceLogic).ProcessTocMobileRiskAssessmentLogic,
"toc_MobileDrugFraudRiskCheck": (*QueryServiceLogic).ProcessTocMobileDrugFraudRiskCheckLogic,
} }
func (l *QueryServiceLogic) PreprocessLogic(req *types.QueryServiceReq, product string) (*types.QueryServiceResp, error) { func (l *QueryServiceLogic) PreprocessLogic(req *types.QueryServiceReq, product string) (*types.QueryServiceResp, error) {
@ -1750,82 +1833,71 @@ func (l *QueryServiceLogic) ProcessTocFraudGamblingCheckLogic(req *types.QuerySe
return &types.QueryServiceResp{Id: cacheNo}, nil return &types.QueryServiceResp{Id: cacheNo}, nil
} }
func (l *QueryServiceLogic) DecryptData(data string) ([]byte, error) {
secretKey := l.svcCtx.Config.Encrypt.SecretKey // ProcessTocMobileLocationLogic 手机归属地
key, decodeErr := hex.DecodeString(secretKey) func (l *QueryServiceLogic) ProcessTocMobileLocationLogic(req *types.QueryServiceReq) (*types.QueryServiceResp, error) {
if decodeErr != nil { userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "密钥获取失败: %+v", decodeErr) if getUidErr != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 获取用户信息失败, %+v", getUidErr)
} }
decryptData, aesDecryptErr := crypto.AesDecrypt(data, key)
if aesDecryptErr != nil || len(decryptData) == 0 { // AES解密
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "解密失败: %+v", aesDecryptErr) decryptData, DecryptDataErr := l.DecryptData(req.Data)
if DecryptDataErr != nil {
return nil, DecryptDataErr
} }
return decryptData, nil
// 校验参数
var data types.TocMobileLocation
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)
}
params := map[string]interface{}{
"mobile": data.Mobile,
}
cacheNo, cacheDataErr := l.CacheData(params, "toc_MobileLocation", userID)
if cacheDataErr != nil {
return nil, cacheDataErr
}
return &types.QueryServiceResp{Id: cacheNo}, nil
} }
// 校验验证码 // ProcessTocIDCardLocationLogic 身份证归属地
func (l *QueryServiceLogic) VerifyCode(mobile string, code string) error { func (l *QueryServiceLogic) ProcessTocIDCardLocationLogic(req *types.QueryServiceReq) (*types.QueryServiceResp, error) {
codeRedisKey := fmt.Sprintf("%s:%s", "query", mobile) userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
cacheCode, err := l.svcCtx.Redis.Get(codeRedisKey) if getUidErr != nil {
if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 获取用户信息失败, %+v", getUidErr)
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
}
// 二、三要素验证 // AES解密
func (l *QueryServiceLogic) Verify(Name string, IDCard string, Mobile string) error { decryptData, DecryptDataErr := l.DecryptData(req.Data)
if l.svcCtx.Config.SystemConfig.ThreeVerify { if DecryptDataErr != nil {
// 三要素验证 return nil, DecryptDataErr
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)
}
} else {
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
}
// 缓存 // 校验参数
func (l *QueryServiceLogic) CacheData(params map[string]interface{}, Product string, userID int64) (string, error) { var data types.TocIDCardLocation
queryCache := types.QueryCacheLoad{ if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
Params: params, return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
Product: Product,
} }
jsonData, marshalErr := json.Marshal(queryCache)
if marshalErr != nil { if validatorErr := validator.Validate(data); validatorErr != nil {
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 序列化参数失败: %+v", marshalErr) return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
} }
outTradeNo := l.svcCtx.WechatPayService.GenerateOutTradeNo()
redisKey := fmt.Sprintf("%d:%s", userID, outTradeNo) params := map[string]interface{}{
cacheErr := l.svcCtx.Redis.SetexCtx(l.ctx, redisKey, string(jsonData), int(2*time.Hour)) "id_card": data.IDCard,
if cacheErr != nil {
return "", cacheErr
} }
return outTradeNo, nil cacheNo, cacheDataErr := l.CacheData(params, "toc_IDCardLocation", userID)
if cacheDataErr != nil {
return nil, cacheDataErr
}
return &types.QueryServiceResp{Id: cacheNo}, nil
} }

View File

@ -27,18 +27,20 @@ type ApiRequestService struct {
config config.Config config config.Config
westDexService *WestDexService westDexService *WestDexService
yushanService *YushanService yushanService *YushanService
tianjuService *TianjuService
featureModel model.FeatureModel featureModel model.FeatureModel
productFeatureModel model.ProductFeatureModel productFeatureModel model.ProductFeatureModel
} }
// NewApiRequestService 是一个构造函数,用于初始化 ApiRequestService // NewApiRequestService 是一个构造函数,用于初始化 ApiRequestService
func NewApiRequestService(c config.Config, westDexService *WestDexService, yushanService *YushanService, featureModel model.FeatureModel, productFeatureModel model.ProductFeatureModel) *ApiRequestService { func NewApiRequestService(c config.Config, westDexService *WestDexService, yushanService *YushanService, tianjuService *TianjuService, featureModel model.FeatureModel, productFeatureModel model.ProductFeatureModel) *ApiRequestService {
return &ApiRequestService{ return &ApiRequestService{
config: c, config: c,
featureModel: featureModel, featureModel: featureModel,
productFeatureModel: productFeatureModel, productFeatureModel: productFeatureModel,
westDexService: westDexService, westDexService: westDexService,
yushanService: yushanService, yushanService: yushanService,
tianjuService: tianjuService,
} }
} }
@ -173,47 +175,49 @@ func (a *ApiRequestService) ProcessRequests(params []byte, productID int64) ([]b
// ------------------------------------请求处理器-------------------------- // ------------------------------------请求处理器--------------------------
var requestProcessors = map[string]func(*ApiRequestService, []byte) ([]byte, error){ var requestProcessors = map[string]func(*ApiRequestService, []byte) ([]byte, error){
"G09SC02": (*ApiRequestService).ProcessG09SC02Request, "G09SC02": (*ApiRequestService).ProcessG09SC02Request,
"G27BJ05": (*ApiRequestService).ProcessG27BJ05Request, "G27BJ05": (*ApiRequestService).ProcessG27BJ05Request,
"G26BJ05": (*ApiRequestService).ProcessG26BJ05Request, "G26BJ05": (*ApiRequestService).ProcessG26BJ05Request,
"G34BJ03": (*ApiRequestService).ProcessG34BJ03Request, "G34BJ03": (*ApiRequestService).ProcessG34BJ03Request,
"G35SC01": (*ApiRequestService).ProcessG35SC01Request, "G35SC01": (*ApiRequestService).ProcessG35SC01Request,
"G28BJ05": (*ApiRequestService).ProcessG28BJ05Request, "G28BJ05": (*ApiRequestService).ProcessG28BJ05Request,
"G05HZ01": (*ApiRequestService).ProcessG05HZ01Request, "G05HZ01": (*ApiRequestService).ProcessG05HZ01Request,
"Q23SC01": (*ApiRequestService).ProcessQ23SC01Request, "Q23SC01": (*ApiRequestService).ProcessQ23SC01Request,
"G15BJ02": (*ApiRequestService).ProcessG15BJ02Request, "G15BJ02": (*ApiRequestService).ProcessG15BJ02Request,
"G17BJ02": (*ApiRequestService).ProcessG17BJ02Request, "G17BJ02": (*ApiRequestService).ProcessG17BJ02Request,
"G08SC02": (*ApiRequestService).ProcessG08SC02Request, "G08SC02": (*ApiRequestService).ProcessG08SC02Request,
"KZEYS": (*ApiRequestService).ProcessKZEYSRequest, "KZEYS": (*ApiRequestService).ProcessKZEYSRequest,
"P_C_B332": (*ApiRequestService).ProcessP_C_B332Request, "P_C_B332": (*ApiRequestService).ProcessP_C_B332Request,
"FIN019": (*ApiRequestService).ProcessFIN019Request, "FIN019": (*ApiRequestService).ProcessFIN019Request,
"CAR061": (*ApiRequestService).ProcessCAR061Request, "G10SC02": (*ApiRequestService).ProcessG10SC02Request,
"G10SC02": (*ApiRequestService).ProcessG10SC02Request, "G03HZ01": (*ApiRequestService).ProcessG03HZ01Request,
"G03HZ01": (*ApiRequestService).ProcessG03HZ01Request, "G02BJ02": (*ApiRequestService).ProcessG02BJ02Request,
"G02BJ02": (*ApiRequestService).ProcessG02BJ02Request, "G19BJ02": (*ApiRequestService).ProcessG19BJ02Request,
"G19BJ02": (*ApiRequestService).ProcessG19BJ02Request, "G20GZ01": (*ApiRequestService).ProcessG20GZ01Request,
"G20GZ01": (*ApiRequestService).ProcessG20GZ01Request, "CAR061": (*ApiRequestService).ProcessCAR061Request, // 名下车辆
"CAR074": (*ApiRequestService).ProcessCAR074Request, "CAR074": (*ApiRequestService).ProcessCAR074Request, // 车辆出险信息
"CAR058": (*ApiRequestService).ProcessCAR058Request, "CAR058": (*ApiRequestService).ProcessCAR058Request, // 车辆维保记录
"CAR079": (*ApiRequestService).ProcessCAR079Request, "CAR079": (*ApiRequestService).ProcessCAR079Request, // 车架号查车
"CAR066": (*ApiRequestService).ProcessCAR066Request, "CAR066": (*ApiRequestService).ProcessCAR066Request, // 车辆过户次数
"CAR100": (*ApiRequestService).ProcessCAR100Request, "CAR100": (*ApiRequestService).ProcessCAR100Request, // 车辆估值
"G37SC01": (*ApiRequestService).ProcessG37SC01Request, "G37SC01": (*ApiRequestService).ProcessG37SC01Request,
"G36SC01": (*ApiRequestService).ProcessG36SC01Request, "G36SC01": (*ApiRequestService).ProcessG36SC01Request,
"G22SC01": (*ApiRequestService).ProcessG22SC01Request, "G22SC01": (*ApiRequestService).ProcessG22SC01Request,
"Q03SC01": (*ApiRequestService).ProcessQ03SC01Request, "Q03SC01": (*ApiRequestService).ProcessQ03SC01Request,
"COM187": (*ApiRequestService).ProcessCOM187Request, "COM187": (*ApiRequestService).ProcessCOM187Request,
"MOB035": (*ApiRequestService).ProcessMOB035Request, "MOB035": (*ApiRequestService).ProcessMOB035Request,
"PCB915": (*ApiRequestService).ProcessPCB915Request, "PCB915": (*ApiRequestService).ProcessPCB915Request,
"RIS031": (*ApiRequestService).ProcessRIS031Request, "RIS031": (*ApiRequestService).ProcessRIS031Request,
"PCB601": (*ApiRequestService).ProcessPCB601Request, "PCB601": (*ApiRequestService).ProcessPCB601Request,
"PCB148": (*ApiRequestService).ProcessPCB148Request, "PCB148": (*ApiRequestService).ProcessPCB148Request,
"FIN011": (*ApiRequestService).ProcessFIN011Request, "FIN011": (*ApiRequestService).ProcessFIN011Request,
"FIN020": (*ApiRequestService).ProcessFIN020Request, "FIN020": (*ApiRequestService).ProcessFIN020Request,
"FIN018": (*ApiRequestService).ProcessFIN018Request, "FIN018": (*ApiRequestService).ProcessFIN018Request,
"MOB032": (*ApiRequestService).ProcessMOB032Request, "MOB032": (*ApiRequestService).ProcessMOB032Request,
"FIN032": (*ApiRequestService).ProcessFIN032Request, "FIN032": (*ApiRequestService).ProcessFIN032Request,
"HRD004": (*ApiRequestService).ProcessHRD004Request, "HRD004": (*ApiRequestService).ProcessHRD004Request,
"mobilelocal": (*ApiRequestService).ProcessMobilelocalRequest, // 手机归属地
"sfz": (*ApiRequestService).ProcessSfzRequest, // 身份证归属地
} }
// PreprocessRequestApi 调用指定的请求处理函数 // PreprocessRequestApi 调用指定的请求处理函数
@ -1446,3 +1450,39 @@ func (a *ApiRequestService) ProcessHRD004Request(params []byte) ([]byte, error)
} }
return resp, nil return resp, nil
} }
// 手机归属地查询
func (a *ApiRequestService) ProcessMobilelocalRequest(params []byte) ([]byte, error) {
mobile := gjson.GetBytes(params, "mobile")
if !mobile.Exists() {
return nil, errors.New("api请求, mobilelocal, 获取相关参数失败")
}
request := map[string]interface{}{
"phone": mobile.String(),
}
resp, err := a.tianjuService.Request("mobilelocal", request)
if err != nil {
return nil, fmt.Errorf("手机归属地查询失败: %+v", err)
}
return resp, nil
}
// 身份证归属地查询
func (a *ApiRequestService) ProcessSfzRequest(params []byte) ([]byte, error) {
idCard := gjson.GetBytes(params, "id_card")
if !idCard.Exists() {
return nil, errors.New("api请求, sfz, 获取相关参数失败")
}
request := map[string]interface{}{
"idcard": idCard.String(),
}
resp, err := a.tianjuService.Request("sfz", request)
if err != nil {
return nil, fmt.Errorf("身份证归属地查询失败: %+v", err)
}
return resp, nil
}

View File

@ -0,0 +1,74 @@
package service
import (
"encoding/json"
"fmt"
"io"
"net/http"
"qnc-server/app/user/cmd/api/internal/config"
"strings"
"github.com/tidwall/gjson"
)
type TianjuService struct {
config config.TianjuConfig
}
func NewTianjuService(c config.Config) *TianjuService {
return &TianjuService{
config: c.TianjuConfig,
}
}
func (t *TianjuService) Request(apiPath string, params map[string]interface{}) ([]byte, error) {
// 确保params中包含key参数
reqParams := make(map[string]interface{})
// 复制用户参数
for k, v := range params {
reqParams[k] = v
}
// 如果未提供key则使用配置中的ApiKey
if _, ok := reqParams["key"]; !ok {
reqParams["key"] = t.config.ApiKey
}
// 构建完整的URL假设BaseURL已包含https://前缀
fullURL := fmt.Sprintf("%s/%s/index", strings.TrimRight(t.config.BaseURL, "/"), apiPath)
// 将请求数据转换为JSON
messageBytes, err := json.Marshal(reqParams)
if err != nil {
return nil, fmt.Errorf("参数序列化失败: %w", err)
}
// 发起HTTP请求
resp, err := http.Post(fullURL, "application/json", strings.NewReader(string(messageBytes)))
if err != nil {
return nil, fmt.Errorf("发送请求失败: %w", err)
}
defer resp.Body.Close()
// 读取响应体
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("读取响应失败: %w", err)
}
// 检查响应状态码
code := gjson.GetBytes(body, "code").Int()
if code != 200 {
msg := gjson.GetBytes(body, "msg").String()
return nil, fmt.Errorf("天聚请求失败: 状态码 %d, 信息: %s", code, msg)
}
// 获取结果数据
result := gjson.GetBytes(body, "result")
if !result.Exists() {
return nil, fmt.Errorf("天聚请求result为空: %s", string(body))
}
return []byte(result.Raw), nil
}

View File

@ -37,6 +37,7 @@ type ServiceContext struct {
ApplePayService *service.ApplePayService ApplePayService *service.ApplePayService
WestDexService *service.WestDexService WestDexService *service.WestDexService
YushanService *service.YushanService YushanService *service.YushanService
TianjuService *service.TianjuService
ApiRequestService *service.ApiRequestService ApiRequestService *service.ApiRequestService
AsynqServer *asynq.Server // 服务端 AsynqServer *asynq.Server // 服务端
AsynqService *service.AsynqService // 客户端 AsynqService *service.AsynqService // 客户端
@ -62,6 +63,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
) )
westDexService := service.NewWestDexService(c) westDexService := service.NewWestDexService(c)
yushanService := service.NewYushanService(c) yushanService := service.NewYushanService(c)
tianjuService := service.NewTianjuService(c)
productFeatureModel := model.NewProductFeatureModel(db, c.CacheRedis) productFeatureModel := model.NewProductFeatureModel(db, c.CacheRedis)
featureModel := model.NewFeatureModel(db, c.CacheRedis) featureModel := model.NewFeatureModel(db, c.CacheRedis)
userAuthModel := model.NewUserAuthModel(db, c.CacheRedis) userAuthModel := model.NewUserAuthModel(db, c.CacheRedis)
@ -74,9 +76,10 @@ func NewServiceContext(c config.Config) *ServiceContext {
ApplePayService: service.NewApplePayService(c), ApplePayService: service.NewApplePayService(c),
WestDexService: westDexService, WestDexService: westDexService,
YushanService: yushanService, YushanService: yushanService,
TianjuService: tianjuService,
VerificationService: service.NewVerificationService(c, westDexService), VerificationService: service.NewVerificationService(c, westDexService),
AsynqServer: asynqServer, AsynqServer: asynqServer,
ApiRequestService: service.NewApiRequestService(c, westDexService, yushanService, featureModel, productFeatureModel), ApiRequestService: service.NewApiRequestService(c, westDexService, yushanService, tianjuService, featureModel, productFeatureModel),
AsynqService: service.NewAsynqService(c), AsynqService: service.NewAsynqService(c),
UserModel: model.NewUserModel(db, c.CacheRedis), UserModel: model.NewUserModel(db, c.CacheRedis),
UserAuthModel: userAuthModel, UserAuthModel: userAuthModel,

View File

@ -177,3 +177,13 @@ type TocBankCardThreeElementsVerification struct {
type TocMobileRiskAssessment struct { type TocMobileRiskAssessment struct {
Mobile string `json:"mobile" validate:"required,mobile"` Mobile string `json:"mobile" validate:"required,mobile"`
} }
// 手机归属地
type TocMobileLocation struct {
Mobile string `json:"mobile" validate:"required,mobile"`
}
// 身份证归属地
type TocIDCardLocation struct {
IDCard string `json:"id_card" validate:"required,idCard"`
}