Merge branch 'main' of http://1.117.67.95:3000/team/ycc-proxy-server
This commit is contained in:
@@ -82,6 +82,10 @@ service main {
|
|||||||
// 邀请码列表查询
|
// 邀请码列表查询
|
||||||
@handler AdminGetInviteCodeList
|
@handler AdminGetInviteCodeList
|
||||||
get /invite_code/list (AdminGetInviteCodeListReq) returns (AdminGetInviteCodeListResp)
|
get /invite_code/list (AdminGetInviteCodeListReq) returns (AdminGetInviteCodeListResp)
|
||||||
|
|
||||||
|
// 代理手机号修改
|
||||||
|
@handler AdminUpdateAgentMobile
|
||||||
|
post /mobile/update (AdminUpdateAgentMobileReq) returns (AdminUpdateAgentMobileResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -109,6 +113,8 @@ type (
|
|||||||
FrozenBalance float64 `json:"frozen_balance"` // 冻结余额
|
FrozenBalance float64 `json:"frozen_balance"` // 冻结余额
|
||||||
WithdrawnAmount float64 `json:"withdrawn_amount"` // 提现总额
|
WithdrawnAmount float64 `json:"withdrawn_amount"` // 提现总额
|
||||||
IsRealName bool `json:"is_real_name"` // 是否已实名
|
IsRealName bool `json:"is_real_name"` // 是否已实名
|
||||||
|
RealName string `json:"real_name"` // 姓名(实名认证的姓名)
|
||||||
|
IdCardPlain string `json:"id_card_plain"` // 身份证号(解密后的明文)
|
||||||
CreateTime string `json:"create_time"` // 创建时间
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
}
|
}
|
||||||
AdminGetAgentListResp {
|
AdminGetAgentListResp {
|
||||||
@@ -429,5 +435,13 @@ type (
|
|||||||
Total int64 `json:"total"` // 总数
|
Total int64 `json:"total"` // 总数
|
||||||
Items []InviteCodeListItem `json:"items"` // 列表数据
|
Items []InviteCodeListItem `json:"items"` // 列表数据
|
||||||
}
|
}
|
||||||
|
// 代理手机号修改
|
||||||
|
AdminUpdateAgentMobileReq {
|
||||||
|
AgentId string `json:"agent_id"` // 代理ID
|
||||||
|
Mobile string `json:"mobile"` // 新手机号
|
||||||
|
}
|
||||||
|
AdminUpdateAgentMobileResp {
|
||||||
|
Success bool `json:"success"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package admin_agent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"ycc-server/app/main/api/internal/logic/admin_agent"
|
||||||
|
"ycc-server/app/main/api/internal/svc"
|
||||||
|
"ycc-server/app/main/api/internal/types"
|
||||||
|
"ycc-server/common/result"
|
||||||
|
"ycc-server/pkg/lzkit/validator"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func AdminUpdateAgentMobileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.AdminUpdateAgentMobileReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
result.ParamErrorResult(r, w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := validator.Validate(req); err != nil {
|
||||||
|
result.ParamValidateErrorResult(r, w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
l := admin_agent.NewAdminUpdateAgentMobileLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.AdminUpdateAgentMobile(&req)
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -94,6 +94,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/product_config/update",
|
Path: "/product_config/update",
|
||||||
Handler: admin_agent.AdminUpdateAgentProductConfigHandler(serverCtx),
|
Handler: admin_agent.AdminUpdateAgentProductConfigHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/mobile/update",
|
||||||
|
Handler: admin_agent.AdminUpdateAgentMobileHandler(serverCtx),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/real_name/list",
|
Path: "/real_name/list",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package admin_agent
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/hex"
|
||||||
|
|
||||||
"ycc-server/app/main/api/internal/svc"
|
"ycc-server/app/main/api/internal/svc"
|
||||||
"ycc-server/app/main/api/internal/types"
|
"ycc-server/app/main/api/internal/types"
|
||||||
@@ -79,11 +80,25 @@ func (l *AdminGetAgentListLogic) AdminGetAgentList(req *types.AdminGetAgentListR
|
|||||||
// 查询钱包信息
|
// 查询钱包信息
|
||||||
wallet, _ := l.svcCtx.AgentWalletModel.FindOneByAgentId(l.ctx, agent.Id)
|
wallet, _ := l.svcCtx.AgentWalletModel.FindOneByAgentId(l.ctx, agent.Id)
|
||||||
|
|
||||||
// 查询实名认证信息
|
// 查询实名认证信息(数据库姓名明文、身份证密文,解密后明文返回不脱敏)
|
||||||
realNameInfo, _ := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agent.Id)
|
realNameInfo, _ := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agent.Id)
|
||||||
isRealName := false
|
isRealName := false
|
||||||
if realNameInfo != nil && realNameInfo.VerifyTime.Valid {
|
realName := ""
|
||||||
isRealName = true // verify_time不为空表示已通过三要素核验
|
idCardPlain := "" // 解密后明文返回
|
||||||
|
if realNameInfo != nil {
|
||||||
|
if realNameInfo.VerifyTime.Valid {
|
||||||
|
isRealName = true // verify_time不为空表示已通过三要素核验
|
||||||
|
}
|
||||||
|
realName = realNameInfo.Name
|
||||||
|
if realNameInfo.IdCard != "" {
|
||||||
|
key, keyErr := hex.DecodeString(l.svcCtx.Config.Encrypt.SecretKey)
|
||||||
|
if keyErr == nil {
|
||||||
|
decrypted, err := crypto.DecryptIDCard(realNameInfo.IdCard, key)
|
||||||
|
if err == nil {
|
||||||
|
idCardPlain = decrypted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wechatId := ""
|
wechatId := ""
|
||||||
@@ -116,6 +131,8 @@ func (l *AdminGetAgentListLogic) AdminGetAgentList(req *types.AdminGetAgentListR
|
|||||||
FrozenBalance: 0,
|
FrozenBalance: 0,
|
||||||
WithdrawnAmount: 0,
|
WithdrawnAmount: 0,
|
||||||
IsRealName: isRealName,
|
IsRealName: isRealName,
|
||||||
|
RealName: realName,
|
||||||
|
IdCardPlain: idCardPlain,
|
||||||
CreateTime: agent.CreateTime.Format("2006-01-02 15:04:05"),
|
CreateTime: agent.CreateTime.Format("2006-01-02 15:04:05"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package admin_agent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"ycc-server/app/main/model"
|
||||||
|
"ycc-server/common/xerr"
|
||||||
|
"ycc-server/pkg/lzkit/crypto"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"ycc-server/app/main/api/internal/svc"
|
||||||
|
"ycc-server/app/main/api/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 手机号正则:11 位大陆手机号
|
||||||
|
var mobileRegexp = regexp.MustCompile(`^1[3-9]\d{9}$`)
|
||||||
|
|
||||||
|
type AdminUpdateAgentMobileLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAdminUpdateAgentMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminUpdateAgentMobileLogic {
|
||||||
|
return &AdminUpdateAgentMobileLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *AdminUpdateAgentMobileLogic) AdminUpdateAgentMobile(req *types.AdminUpdateAgentMobileReq) (resp *types.AdminUpdateAgentMobileResp, err error) {
|
||||||
|
// 1. 校验手机号格式
|
||||||
|
if req.Mobile == "" {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrMsg("手机号不能为空"), "")
|
||||||
|
}
|
||||||
|
if !mobileRegexp.MatchString(req.Mobile) {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrMsg("手机号格式不正确"), "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 查询代理
|
||||||
|
agent, err := l.svcCtx.AgentModel.FindOne(l.ctx, req.AgentId)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, model.ErrNotFound) {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrMsg("代理不存在"), "")
|
||||||
|
}
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理失败, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 加密新手机号
|
||||||
|
encryptedMobile, err := crypto.EncryptMobile(req.Mobile, l.svcCtx.Config.Encrypt.SecretKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "加密手机号失败, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 更新代理手机号
|
||||||
|
agent.Mobile = encryptedMobile
|
||||||
|
if err := l.svcCtx.AgentModel.UpdateWithVersion(l.ctx, nil, agent); err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新手机号失败, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.AdminUpdateAgentMobileResp{
|
||||||
|
Success: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
@@ -882,6 +882,16 @@ type AdminUpdateAgentProductConfigResp struct {
|
|||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 代理手机号修改
|
||||||
|
type AdminUpdateAgentMobileReq struct {
|
||||||
|
AgentId string `json:"agent_id"` // 代理ID
|
||||||
|
Mobile string `json:"mobile"` // 新手机号
|
||||||
|
}
|
||||||
|
|
||||||
|
type AdminUpdateAgentMobileResp struct {
|
||||||
|
Success bool `json:"success"`
|
||||||
|
}
|
||||||
|
|
||||||
type AdminUpdateApiReq struct {
|
type AdminUpdateApiReq struct {
|
||||||
Id string `path:"id"`
|
Id string `path:"id"`
|
||||||
ApiName string `json:"api_name"`
|
ApiName string `json:"api_name"`
|
||||||
@@ -1120,6 +1130,8 @@ type AgentListItem struct {
|
|||||||
FrozenBalance float64 `json:"frozen_balance"` // 冻结余额
|
FrozenBalance float64 `json:"frozen_balance"` // 冻结余额
|
||||||
WithdrawnAmount float64 `json:"withdrawn_amount"` // 提现总额
|
WithdrawnAmount float64 `json:"withdrawn_amount"` // 提现总额
|
||||||
IsRealName bool `json:"is_real_name"` // 是否已实名
|
IsRealName bool `json:"is_real_name"` // 是否已实名
|
||||||
|
RealName string `json:"real_name"` // 姓名(实名认证的姓名)
|
||||||
|
IdCardPlain string `json:"id_card_plain"` // 身份证号(解密后的明文)
|
||||||
CreateTime string `json:"create_time"` // 创建时间
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user