This commit is contained in:
Mrx
2026-01-26 15:47:59 +08:00
parent 018abc95d6
commit 67082972a9
8 changed files with 17 additions and 16 deletions

View File

@@ -63,8 +63,6 @@ Ali:
SystemConfig: SystemConfig:
ThreeVerify: false ThreeVerify: false
CommissionSafeMode: false # 佣金安全防御模式true-冻结模式false-直接结算模式 CommissionSafeMode: false # 佣金安全防御模式true-冻结模式false-直接结算模式
SkipVerifyCode: true # 开发环境下跳过验证码验证
SkipVerify: true # 空报告模式:开发环境跳过二/三要素验证避免未授权IP调用天元API失败
WechatH5: WechatH5:
AppID: "wxa581992dc74d860e" AppID: "wxa581992dc74d860e"
AppSecret: "4de1fbf521712247542d49907fcd5dbf" AppSecret: "4de1fbf521712247542d49907fcd5dbf"

View File

@@ -64,8 +64,6 @@ Ali:
SystemConfig: SystemConfig:
ThreeVerify: true ThreeVerify: true
CommissionSafeMode: false # 佣金安全防御模式true-冻结模式false-直接结算模式 CommissionSafeMode: false # 佣金安全防御模式true-冻结模式false-直接结算模式
SkipVerifyCode: false # 开发环境下跳过验证码验证
SkipVerify: false # 空报告模式:开发环境跳过二/三要素验证避免未授权IP调用天元API失败
WechatH5: WechatH5:
AppID: "wxa581992dc74d860e" AppID: "wxa581992dc74d860e"
AppSecret: "4de1fbf521712247542d49907fcd5dbf" AppSecret: "4de1fbf521712247542d49907fcd5dbf"

View File

@@ -94,8 +94,6 @@ type YushanConfig struct {
type SystemConfig struct { type SystemConfig struct {
ThreeVerify bool // 是否开启三级实名认证 ThreeVerify bool // 是否开启三级实名认证
CommissionSafeMode bool // 佣金安全防御模式true-冻结模式(status=1,进入frozen_balance)false-直接结算(status=0,进入balance) CommissionSafeMode bool // 佣金安全防御模式true-冻结模式(status=1,进入frozen_balance)false-直接结算(status=0,进入balance)
SkipVerifyCode bool // 开发环境下跳过验证码验证
SkipVerify bool // 空报告模式:开发环境下跳过二/三要素验证避免未授权IP调用天元API失败
} }
type WechatH5Config struct { type WechatH5Config struct {
AppID string AppID string

View File

@@ -4,6 +4,7 @@ import (
"context" "context"
"database/sql" "database/sql"
"fmt" "fmt"
"os"
"time" "time"
"tydata-server/app/main/api/internal/service" "tydata-server/app/main/api/internal/service"
@@ -44,7 +45,7 @@ func (l *AgentRealNameLogic) AgentRealName(req *types.AgentRealNameReq) (resp *t
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "代理实名, 加密手机号失败: %v", err) return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "代理实名, 加密手机号失败: %v", err)
} }
// 开发环境下跳过验证码验证 // 开发环境下跳过验证码验证
if !l.svcCtx.Config.SystemConfig.SkipVerifyCode { if os.Getenv("ENV") != "development" {
// 检查手机号是否在一分钟内已发送过验证码 // 检查手机号是否在一分钟内已发送过验证码
redisKey := fmt.Sprintf("%s:%s", "realName", encryptedMobile) redisKey := fmt.Sprintf("%s:%s", "realName", encryptedMobile)
cacheCode, err := l.svcCtx.Redis.Get(redisKey) cacheCode, err := l.svcCtx.Redis.Get(redisKey)

View File

@@ -4,6 +4,7 @@ import (
"context" "context"
"database/sql" "database/sql"
"fmt" "fmt"
"os"
"time" "time"
"tydata-server/app/main/model" "tydata-server/app/main/model"
"tydata-server/common/ctxdata" "tydata-server/common/ctxdata"
@@ -45,7 +46,7 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "加密手机号失败: %v", err) return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "加密手机号失败: %v", err)
} }
// 开发环境下跳过验证码验证,或者特定手机号跳过(保留原有逻辑) // 开发环境下跳过验证码验证,或者特定手机号跳过(保留原有逻辑)
if !l.svcCtx.Config.SystemConfig.SkipVerifyCode && req.Mobile != "18889793585" { if os.Getenv("ENV") != "development" && req.Mobile != "18889793585" {
// 校验验证码 // 校验验证码
redisKey := fmt.Sprintf("%s:%s", "agentApply", encryptedMobile) redisKey := fmt.Sprintf("%s:%s", "agentApply", encryptedMobile)
cacheCode, err := l.svcCtx.Redis.Get(redisKey) cacheCode, err := l.svcCtx.Redis.Get(redisKey)

View File

@@ -6,6 +6,7 @@ import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"fmt" "fmt"
"os"
"time" "time"
"tydata-server/app/main/api/internal/service" "tydata-server/app/main/api/internal/service"
"tydata-server/app/main/model" "tydata-server/app/main/model"
@@ -561,7 +562,7 @@ func (l *QueryServiceLogic) DecryptData(data string) ([]byte, error) {
// 校验验证码 // 校验验证码
func (l *QueryServiceLogic) VerifyCode(mobile string, code string) error { func (l *QueryServiceLogic) VerifyCode(mobile string, code string) error {
// 开发环境下跳过验证码验证 // 开发环境下跳过验证码验证
if l.svcCtx.Config.SystemConfig.SkipVerifyCode { if os.Getenv("ENV") == "development" {
return nil return nil
} }
secretKey := l.svcCtx.Config.Encrypt.SecretKey secretKey := l.svcCtx.Config.Encrypt.SecretKey
@@ -585,10 +586,12 @@ func (l *QueryServiceLogic) VerifyCode(mobile string, code string) error {
// 二、三要素验证 // 二、三要素验证
func (l *QueryServiceLogic) Verify(Name string, IDCard string, Mobile string) error { func (l *QueryServiceLogic) Verify(Name string, IDCard string, Mobile string) error {
// 空报告模式:开发环境下跳过二/三要素验证 // 开发环境下跳过二/三要素验证避免未授权IP调用天元API失败
if l.svcCtx.Config.SystemConfig.SkipVerify { isDevelopment := os.Getenv("ENV") == "development"
if isDevelopment {
return nil return nil
} }
if !l.svcCtx.Config.SystemConfig.ThreeVerify { if !l.svcCtx.Config.SystemConfig.ThreeVerify {
twoVerification := service.TwoFactorVerificationRequest{ twoVerification := service.TwoFactorVerificationRequest{
Name: Name, Name: Name,

View File

@@ -4,6 +4,7 @@ import (
"context" "context"
"database/sql" "database/sql"
"fmt" "fmt"
"os"
"time" "time"
"tydata-server/app/main/api/internal/svc" "tydata-server/app/main/api/internal/svc"
@@ -43,7 +44,7 @@ func (l *BindMobileLogic) BindMobile(req *types.BindMobileReq) (resp *types.Bind
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "绑定手机号, 加密手机号失败: %v", err) return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "绑定手机号, 加密手机号失败: %v", err)
} }
// 开发环境下跳过验证码验证,或者特定手机号跳过(保留原有逻辑) // 开发环境下跳过验证码验证,或者特定手机号跳过(保留原有逻辑)
if !l.svcCtx.Config.SystemConfig.SkipVerifyCode && req.Mobile != "18889793585" { if os.Getenv("ENV") != "development" && req.Mobile != "18889793585" {
// 检查手机号是否在一分钟内已发送过验证码 // 检查手机号是否在一分钟内已发送过验证码
redisKey := fmt.Sprintf("%s:%s", "bindMobile", encryptedMobile) redisKey := fmt.Sprintf("%s:%s", "bindMobile", encryptedMobile)
cacheCode, err := l.svcCtx.Redis.Get(redisKey) cacheCode, err := l.svcCtx.Redis.Get(redisKey)

View File

@@ -2,14 +2,15 @@ package user
import ( import (
"context" "context"
"database/sql"
"fmt"
"os"
"time"
"tydata-server/app/main/api/internal/svc" "tydata-server/app/main/api/internal/svc"
"tydata-server/app/main/api/internal/types" "tydata-server/app/main/api/internal/types"
"tydata-server/app/main/model" "tydata-server/app/main/model"
"tydata-server/common/xerr" "tydata-server/common/xerr"
"tydata-server/pkg/lzkit/crypto" "tydata-server/pkg/lzkit/crypto"
"database/sql"
"fmt"
"time"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/stores/redis" "github.com/zeromicro/go-zero/core/stores/redis"
@@ -38,7 +39,7 @@ func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (r
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 加密手机号失败: %+v", err) return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 加密手机号失败: %+v", err)
} }
// 开发环境下跳过验证码验证 // 开发环境下跳过验证码验证
if !l.svcCtx.Config.SystemConfig.SkipVerifyCode { if os.Getenv("ENV") != "development" {
// 检查手机号是否在一分钟内已发送过验证码 // 检查手机号是否在一分钟内已发送过验证码
redisKey := fmt.Sprintf("%s:%s", "login", encryptedMobile) redisKey := fmt.Sprintf("%s:%s", "login", encryptedMobile)
cacheCode, err := l.svcCtx.Redis.Get(redisKey) cacheCode, err := l.svcCtx.Redis.Get(redisKey)