新增提现实名认证
This commit is contained in:
parent
21a88b42f8
commit
cb936ad30a
@ -65,6 +65,9 @@ service main {
|
|||||||
// 下级贡献详情
|
// 下级贡献详情
|
||||||
@handler GetAgentSubordinateContributionDetail
|
@handler GetAgentSubordinateContributionDetail
|
||||||
get /subordinate/contribution/detail (GetAgentSubordinateContributionDetailReq) returns (GetAgentSubordinateContributionDetailResp)
|
get /subordinate/contribution/detail (GetAgentSubordinateContributionDetailReq) returns (GetAgentSubordinateContributionDetailResp)
|
||||||
|
|
||||||
|
@handler AgentRealName
|
||||||
|
post /real_name (AgentRealNameReq) returns (AgentRealNameResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -75,8 +78,8 @@ type (
|
|||||||
level string `json:"level"`
|
level string `json:"level"`
|
||||||
region string `json:"region"`
|
region string `json:"region"`
|
||||||
mobile string `json:"mobile"`
|
mobile string `json:"mobile"`
|
||||||
wechatID string `json:"wechat_id"`
|
|
||||||
expiryTime string `json:"expiry_time"`
|
expiryTime string `json:"expiry_time"`
|
||||||
|
isRealName bool `json:"is_real_name"`
|
||||||
}
|
}
|
||||||
// 查询代理申请状态响应
|
// 查询代理申请状态响应
|
||||||
AgentAuditStatusResp {
|
AgentAuditStatusResp {
|
||||||
@ -150,6 +153,16 @@ type (
|
|||||||
DescendantWithdrawCount int64 `json:"descendant_withdraw_count"` // 下级提现次数
|
DescendantWithdrawCount int64 `json:"descendant_withdraw_count"` // 下级提现次数
|
||||||
DescendantWithdrawAmount float64 `json:"descendant_withdraw_amount"` // 下级提现总额
|
DescendantWithdrawAmount float64 `json:"descendant_withdraw_amount"` // 下级提现总额
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AgentRealNameReq {
|
||||||
|
Name string `json:"name"`
|
||||||
|
IDCard string `json:"id_card"`
|
||||||
|
Mobile string `json:"mobile"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
}
|
||||||
|
AgentRealNameResp {
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@server (
|
@server (
|
||||||
@ -331,7 +344,6 @@ type (
|
|||||||
AgentApplyReq {
|
AgentApplyReq {
|
||||||
Region string `json:"region"`
|
Region string `json:"region"`
|
||||||
Mobile string `json:"mobile"`
|
Mobile string `json:"mobile"`
|
||||||
WechatID string `json:"wechat_id"`
|
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Ancestor string `json:"ancestor,optional"`
|
Ancestor string `json:"ancestor,optional"`
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ service main {
|
|||||||
@handler queryShareDetail
|
@handler queryShareDetail
|
||||||
get /query/share/:id (QueryShareDetailReq) returns (QueryShareDetailResp)
|
get /query/share/:id (QueryShareDetailReq) returns (QueryShareDetailResp)
|
||||||
|
|
||||||
@doc "查询示例"
|
@doc "查询示例"
|
||||||
@handler queryExample
|
@handler queryExample
|
||||||
get /query/example (QueryExampleReq) returns (QueryExampleResp)
|
get /query/example (QueryExampleReq) returns (QueryExampleResp)
|
||||||
|
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package agent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/logic/agent"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/svc"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/types"
|
||||||
|
"tydata-server/common/result"
|
||||||
|
"tydata-server/pkg/lzkit/validator"
|
||||||
|
)
|
||||||
|
|
||||||
|
func AgentRealNameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.AgentRealNameReq
|
||||||
|
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 := agent.NewAgentRealNameLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.AgentRealName(&req)
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/product_config",
|
Path: "/product_config",
|
||||||
Handler: agent.GetAgentProductConfigHandler(serverCtx),
|
Handler: agent.GetAgentProductConfigHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/real_name",
|
||||||
|
Handler: agent.AgentRealNameHandler(serverCtx),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/subordinate/contribution/detail",
|
Path: "/subordinate/contribution/detail",
|
||||||
|
99
app/user/cmd/api/internal/logic/agent/agentrealnamelogic.go
Normal file
99
app/user/cmd/api/internal/logic/agent/agentrealnamelogic.go
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
package agent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"tydata-server/app/user/cmd/api/internal/service"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/svc"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/types"
|
||||||
|
"tydata-server/app/user/model"
|
||||||
|
"tydata-server/common/ctxdata"
|
||||||
|
"tydata-server/common/xerr"
|
||||||
|
"tydata-server/pkg/lzkit/crypto"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/redis"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AgentRealNameLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAgentRealNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AgentRealNameLogic {
|
||||||
|
return &AgentRealNameLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *AgentRealNameLogic) AgentRealName(req *types.AgentRealNameReq) (resp *types.AgentRealNameResp, err error) {
|
||||||
|
userID, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户ID失败, %v", err)
|
||||||
|
}
|
||||||
|
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||||
|
encryptedMobile, err := crypto.EncryptMobile(req.Mobile, secretKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "代理实名, 加密手机号失败: %v", err)
|
||||||
|
}
|
||||||
|
// 检查手机号是否在一分钟内已发送过验证码
|
||||||
|
redisKey := fmt.Sprintf("%s:%s", "realName", encryptedMobile)
|
||||||
|
cacheCode, err := l.svcCtx.Redis.Get(redisKey)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, redis.Nil) {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrMsg("验证码已过期"), "代理实名, 验证码过期: %s", encryptedMobile)
|
||||||
|
}
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "代理实名, 读取验证码redis缓存失败, mobile: %s, err: %+v", encryptedMobile, err)
|
||||||
|
}
|
||||||
|
if cacheCode != req.Code {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrMsg("验证码不正确"), "代理实名, 验证码不正确: %s", encryptedMobile)
|
||||||
|
}
|
||||||
|
agent, err := l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理信息失败, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
agentRealName, err := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agent.Id)
|
||||||
|
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理实名信息失败, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if agentRealName != nil && agentRealName.Status == model.AgentRealNameStatusApproved {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrMsg("代理实名信息已审核通过"), "代理实名信息已审核通过")
|
||||||
|
}
|
||||||
|
// 三要素验证
|
||||||
|
threeVerification := service.ThreeFactorVerificationRequest{
|
||||||
|
Name: req.Name,
|
||||||
|
IDCard: req.IDCard,
|
||||||
|
Mobile: req.Mobile,
|
||||||
|
}
|
||||||
|
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "三要素验证失败: %v", err)
|
||||||
|
}
|
||||||
|
if !verification.Passed {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "三要素验证不通过: %v", err)
|
||||||
|
}
|
||||||
|
agentRealName = &model.AgentRealName{
|
||||||
|
AgentId: agent.Id,
|
||||||
|
Status: model.AgentRealNameStatusApproved,
|
||||||
|
Name: req.Name,
|
||||||
|
IdCard: req.IDCard,
|
||||||
|
ApproveTime: sql.NullTime{Time: time.Now(), Valid: true},
|
||||||
|
}
|
||||||
|
_, err = l.svcCtx.AgentRealNameModel.Insert(l.ctx, nil, agentRealName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "添加代理实名信息失败, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.AgentRealNameResp{
|
||||||
|
Status: agentRealName.Status,
|
||||||
|
}, nil
|
||||||
|
}
|
@ -66,7 +66,19 @@ func (l *AgentWithdrawalLogic) AgentWithdrawal(req *types.WithdrawalReq) (*types
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败: %v", err)
|
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败: %v", err)
|
||||||
}
|
}
|
||||||
|
agentRealName, err := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agentModel.Id)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, model.ErrNotFound) {
|
||||||
|
return errors.Wrapf(xerr.NewErrMsg("您未进行实名认证, 无法提现"), "您未进行实名认证")
|
||||||
|
}
|
||||||
|
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询代理实名信息失败: %v", err)
|
||||||
|
}
|
||||||
|
if agentRealName.Status != model.AgentRealNameStatusApproved {
|
||||||
|
return errors.Wrapf(xerr.NewErrMsg("您的实名认证未通过, 无法提现"), "您的实名认证未通过")
|
||||||
|
}
|
||||||
|
if agentRealName.Name != req.PayeeName {
|
||||||
|
return errors.Wrapf(xerr.NewErrMsg("您的实名认证信息不匹配, 无法提现"), "您的实名认证信息不匹配")
|
||||||
|
}
|
||||||
// 查询钱包
|
// 查询钱包
|
||||||
agentWallet, err := l.svcCtx.AgentWalletModel.FindOneByAgentId(l.ctx, agentModel.Id)
|
agentWallet, err := l.svcCtx.AgentWalletModel.FindOneByAgentId(l.ctx, agentModel.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
jwtx "tydata-server/common/jwt"
|
jwtx "tydata-server/common/jwt"
|
||||||
"tydata-server/common/xerr"
|
"tydata-server/common/xerr"
|
||||||
"tydata-server/pkg/lzkit/crypto"
|
"tydata-server/pkg/lzkit/crypto"
|
||||||
"tydata-server/pkg/lzkit/lzUtils"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/zeromicro/go-zero/core/stores/redis"
|
"github.com/zeromicro/go-zero/core/stores/redis"
|
||||||
@ -108,7 +107,6 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type
|
|||||||
agentAudit.UserId = user.Id
|
agentAudit.UserId = user.Id
|
||||||
agentAudit.Mobile = encryptedMobile
|
agentAudit.Mobile = encryptedMobile
|
||||||
agentAudit.Region = req.Region
|
agentAudit.Region = req.Region
|
||||||
agentAudit.WechatId = lzUtils.StringToNullString(req.WechatID)
|
|
||||||
agentAudit.Status = 1
|
agentAudit.Status = 1
|
||||||
_, insetAgentAuditErr := l.svcCtx.AgentAuditModel.Insert(transCtx, session, &agentAudit)
|
_, insetAgentAuditErr := l.svcCtx.AgentAuditModel.Insert(transCtx, session, &agentAudit)
|
||||||
if insetAgentAuditErr != nil {
|
if insetAgentAuditErr != nil {
|
||||||
@ -132,7 +130,6 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type
|
|||||||
agentModel.Region = agentAudit.Region
|
agentModel.Region = agentAudit.Region
|
||||||
agentModel.LevelName = model.AgentLeveNameNormal
|
agentModel.LevelName = model.AgentLeveNameNormal
|
||||||
agentModel.UserId = agentAudit.UserId
|
agentModel.UserId = agentAudit.UserId
|
||||||
agentModel.WechatId = lzUtils.StringToNullString(req.WechatID)
|
|
||||||
agentModelInsert, insertAgentModelErr := l.svcCtx.AgentModel.Insert(transCtx, session, &agentModel)
|
agentModelInsert, insertAgentModelErr := l.svcCtx.AgentModel.Insert(transCtx, session, &agentModel)
|
||||||
if insertAgentModelErr != nil {
|
if insertAgentModelErr != nil {
|
||||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "代理申请, 新增代理失败: %+v", insertAgentModelErr)
|
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "代理申请, 新增代理失败: %+v", insertAgentModelErr)
|
||||||
|
@ -6,12 +6,12 @@ import (
|
|||||||
"tydata-server/common/ctxdata"
|
"tydata-server/common/ctxdata"
|
||||||
"tydata-server/common/xerr"
|
"tydata-server/common/xerr"
|
||||||
"tydata-server/pkg/lzkit/crypto"
|
"tydata-server/pkg/lzkit/crypto"
|
||||||
"tydata-server/pkg/lzkit/lzUtils"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"tydata-server/app/user/cmd/api/internal/svc"
|
"tydata-server/app/user/cmd/api/internal/svc"
|
||||||
"tydata-server/app/user/cmd/api/internal/types"
|
"tydata-server/app/user/cmd/api/internal/types"
|
||||||
|
"tydata-server/app/user/model"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
@ -64,6 +64,15 @@ func (l *GetAgentInfoLogic) GetAgentInfo() (resp *types.AgentInfoResp, err error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理信息, 解密手机号失败: %v", err)
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理信息, 解密手机号失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IsRealName := false
|
||||||
|
agentRealName, err := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agent.Id)
|
||||||
|
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理实名信息失败, %v", err)
|
||||||
|
}
|
||||||
|
if agentRealName != nil {
|
||||||
|
IsRealName = true
|
||||||
|
}
|
||||||
return &types.AgentInfoResp{
|
return &types.AgentInfoResp{
|
||||||
AgentID: agent.Id,
|
AgentID: agent.Id,
|
||||||
Level: agent.LevelName,
|
Level: agent.LevelName,
|
||||||
@ -72,6 +81,6 @@ func (l *GetAgentInfoLogic) GetAgentInfo() (resp *types.AgentInfoResp, err error
|
|||||||
Region: agent.Region,
|
Region: agent.Region,
|
||||||
Mobile: agent.Mobile,
|
Mobile: agent.Mobile,
|
||||||
ExpiryTime: agent.MembershipExpiryTime.Time.Format("2006-01-02 15:04:05"),
|
ExpiryTime: agent.MembershipExpiryTime.Time.Format("2006-01-02 15:04:05"),
|
||||||
WechatID: lzUtils.NullStringToString(agent.WechatId),
|
IsRealName: IsRealName,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ type ServiceContext struct {
|
|||||||
AgentPlatformDeductionModel model.AgentPlatformDeductionModel
|
AgentPlatformDeductionModel model.AgentPlatformDeductionModel
|
||||||
AgentActiveStatModel model.AgentActiveStatModel
|
AgentActiveStatModel model.AgentActiveStatModel
|
||||||
AgentWithdrawalModel model.AgentWithdrawalModel
|
AgentWithdrawalModel model.AgentWithdrawalModel
|
||||||
|
AgentRealNameModel model.AgentRealNameModel
|
||||||
ExampleModel model.ExampleModel
|
ExampleModel model.ExampleModel
|
||||||
GlobalNotificationsModel model.GlobalNotificationsModel
|
GlobalNotificationsModel model.GlobalNotificationsModel
|
||||||
AlipayService *service.AliPayService
|
AlipayService *service.AliPayService
|
||||||
@ -104,6 +105,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||||||
agentPlatformDeductionModel := model.NewAgentPlatformDeductionModel(db, c.CacheRedis)
|
agentPlatformDeductionModel := model.NewAgentPlatformDeductionModel(db, c.CacheRedis)
|
||||||
agentActiveStatModel := model.NewAgentActiveStatModel(db, c.CacheRedis)
|
agentActiveStatModel := model.NewAgentActiveStatModel(db, c.CacheRedis)
|
||||||
agentWithdrawalModel := model.NewAgentWithdrawalModel(db, c.CacheRedis)
|
agentWithdrawalModel := model.NewAgentWithdrawalModel(db, c.CacheRedis)
|
||||||
|
agentRealNameModel := model.NewAgentRealNameModel(db, c.CacheRedis)
|
||||||
exampleModel := model.NewExampleModel(db, c.CacheRedis)
|
exampleModel := model.NewExampleModel(db, c.CacheRedis)
|
||||||
|
|
||||||
alipayService := service.NewAliPayService(c)
|
alipayService := service.NewAliPayService(c)
|
||||||
@ -156,6 +158,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||||||
AgentPlatformDeductionModel: agentPlatformDeductionModel,
|
AgentPlatformDeductionModel: agentPlatformDeductionModel,
|
||||||
AgentActiveStatModel: agentActiveStatModel,
|
AgentActiveStatModel: agentActiveStatModel,
|
||||||
AgentWithdrawalModel: agentWithdrawalModel,
|
AgentWithdrawalModel: agentWithdrawalModel,
|
||||||
|
AgentRealNameModel: agentRealNameModel,
|
||||||
ExampleModel: exampleModel,
|
ExampleModel: exampleModel,
|
||||||
UserService: userService,
|
UserService: userService,
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ type AgentActivateMembershipResp struct {
|
|||||||
type AgentApplyReq struct {
|
type AgentApplyReq struct {
|
||||||
Region string `json:"region"`
|
Region string `json:"region"`
|
||||||
Mobile string `json:"mobile"`
|
Mobile string `json:"mobile"`
|
||||||
WechatID string `json:"wechat_id"`
|
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Ancestor string `json:"ancestor,optional"`
|
Ancestor string `json:"ancestor,optional"`
|
||||||
}
|
}
|
||||||
@ -58,8 +57,8 @@ type AgentInfoResp struct {
|
|||||||
Level string `json:"level"`
|
Level string `json:"level"`
|
||||||
Region string `json:"region"`
|
Region string `json:"region"`
|
||||||
Mobile string `json:"mobile"`
|
Mobile string `json:"mobile"`
|
||||||
WechatID string `json:"wechat_id"`
|
|
||||||
ExpiryTime string `json:"expiry_time"`
|
ExpiryTime string `json:"expiry_time"`
|
||||||
|
IsRealName bool `json:"is_real_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AgentMembershipProductConfigReq struct {
|
type AgentMembershipProductConfigReq struct {
|
||||||
@ -98,6 +97,17 @@ type AgentProductConfigResp struct {
|
|||||||
AgentProductConfig []AgentProductConfig
|
AgentProductConfig []AgentProductConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AgentRealNameReq struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
IDCard string `json:"id_card"`
|
||||||
|
Mobile string `json:"mobile"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AgentRealNameResp struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
type AgentSubordinateContributionDetail struct {
|
type AgentSubordinateContributionDetail struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
CreateTime string `json:"create_time"`
|
CreateTime string `json:"create_time"`
|
||||||
|
27
app/user/model/agentRealNameModel.go
Normal file
27
app/user/model/agentRealNameModel.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ AgentRealNameModel = (*customAgentRealNameModel)(nil)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// AgentRealNameModel is an interface to be customized, add more methods here,
|
||||||
|
// and implement the added methods in customAgentRealNameModel.
|
||||||
|
AgentRealNameModel interface {
|
||||||
|
agentRealNameModel
|
||||||
|
}
|
||||||
|
|
||||||
|
customAgentRealNameModel struct {
|
||||||
|
*defaultAgentRealNameModel
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewAgentRealNameModel returns a model for the database table.
|
||||||
|
func NewAgentRealNameModel(conn sqlx.SqlConn, c cache.CacheConf) AgentRealNameModel {
|
||||||
|
return &customAgentRealNameModel{
|
||||||
|
defaultAgentRealNameModel: newAgentRealNameModel(conn, c),
|
||||||
|
}
|
||||||
|
}
|
411
app/user/model/agentRealNameModel_gen.go
Normal file
411
app/user/model/agentRealNameModel_gen.go
Normal file
@ -0,0 +1,411 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT!
|
||||||
|
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
"github.com/zeromicro/go-zero/core/stringx"
|
||||||
|
"tydata-server/common/globalkey"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
agentRealNameFieldNames = builder.RawFieldNames(&AgentRealName{})
|
||||||
|
agentRealNameRows = strings.Join(agentRealNameFieldNames, ",")
|
||||||
|
agentRealNameRowsExpectAutoSet = strings.Join(stringx.Remove(agentRealNameFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
|
||||||
|
agentRealNameRowsWithPlaceHolder = strings.Join(stringx.Remove(agentRealNameFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
||||||
|
|
||||||
|
cacheTydataAgentRealNameIdPrefix = "cache:tydata:agentRealName:id:"
|
||||||
|
cacheTydataAgentRealNameAgentIdPrefix = "cache:tydata:agentRealName:agentId:"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
agentRealNameModel interface {
|
||||||
|
Insert(ctx context.Context, session sqlx.Session, data *AgentRealName) (sql.Result, error)
|
||||||
|
FindOne(ctx context.Context, id int64) (*AgentRealName, error)
|
||||||
|
FindOneByAgentId(ctx context.Context, agentId int64) (*AgentRealName, error)
|
||||||
|
Update(ctx context.Context, session sqlx.Session, data *AgentRealName) (sql.Result, error)
|
||||||
|
UpdateWithVersion(ctx context.Context, session sqlx.Session, data *AgentRealName) error
|
||||||
|
Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error
|
||||||
|
SelectBuilder() squirrel.SelectBuilder
|
||||||
|
DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentRealName) error
|
||||||
|
FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error)
|
||||||
|
FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error)
|
||||||
|
FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*AgentRealName, error)
|
||||||
|
FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentRealName, error)
|
||||||
|
FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentRealName, int64, error)
|
||||||
|
FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentRealName, error)
|
||||||
|
FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentRealName, error)
|
||||||
|
Delete(ctx context.Context, session sqlx.Session, id int64) error
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultAgentRealNameModel struct {
|
||||||
|
sqlc.CachedConn
|
||||||
|
table string
|
||||||
|
}
|
||||||
|
|
||||||
|
AgentRealName struct {
|
||||||
|
Id int64 `db:"id"` // 主键ID
|
||||||
|
AgentId int64 `db:"agent_id"` // 代理ID
|
||||||
|
Name string `db:"name"` // 实名姓名
|
||||||
|
IdCard string `db:"id_card"` // 身份证号
|
||||||
|
Status string `db:"status"` // 认证状态(认证中、通过、拒绝)
|
||||||
|
DelState int64 `db:"del_state"` // 删除状态
|
||||||
|
Version int64 `db:"version"` // 版本号
|
||||||
|
CreateTime time.Time `db:"create_time"` // 创建时间
|
||||||
|
UpdateTime time.Time `db:"update_time"` // 更新时间
|
||||||
|
ApproveTime sql.NullTime `db:"approve_time"` // 认证通过时间
|
||||||
|
RejectTime sql.NullTime `db:"reject_time"` // 认证拒绝时间
|
||||||
|
DeleteTime sql.NullTime `db:"delete_time"` // 删除时间
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func newAgentRealNameModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultAgentRealNameModel {
|
||||||
|
return &defaultAgentRealNameModel{
|
||||||
|
CachedConn: sqlc.NewConn(conn, c),
|
||||||
|
table: "`agent_real_name`",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) Insert(ctx context.Context, session sqlx.Session, data *AgentRealName) (sql.Result, error) {
|
||||||
|
data.DelState = globalkey.DelStateNo
|
||||||
|
tydataAgentRealNameAgentIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameAgentIdPrefix, data.AgentId)
|
||||||
|
tydataAgentRealNameIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameIdPrefix, data.Id)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, agentRealNameRowsExpectAutoSet)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, data.AgentId, data.Name, data.IdCard, data.Status, data.DelState, data.Version, data.ApproveTime, data.RejectTime, data.DeleteTime)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, data.AgentId, data.Name, data.IdCard, data.Status, data.DelState, data.Version, data.ApproveTime, data.RejectTime, data.DeleteTime)
|
||||||
|
}, tydataAgentRealNameAgentIdKey, tydataAgentRealNameIdKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) FindOne(ctx context.Context, id int64) (*AgentRealName, error) {
|
||||||
|
tydataAgentRealNameIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameIdPrefix, id)
|
||||||
|
var resp AgentRealName
|
||||||
|
err := m.QueryRowCtx(ctx, &resp, tydataAgentRealNameIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", agentRealNameRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo)
|
||||||
|
})
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return &resp, nil
|
||||||
|
case sqlc.ErrNotFound:
|
||||||
|
return nil, ErrNotFound
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) FindOneByAgentId(ctx context.Context, agentId int64) (*AgentRealName, error) {
|
||||||
|
tydataAgentRealNameAgentIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameAgentIdPrefix, agentId)
|
||||||
|
var resp AgentRealName
|
||||||
|
err := m.QueryRowIndexCtx(ctx, &resp, tydataAgentRealNameAgentIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `agent_id` = ? and del_state = ? limit 1", agentRealNameRows, m.table)
|
||||||
|
if err := conn.QueryRowCtx(ctx, &resp, query, agentId, globalkey.DelStateNo); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp.Id, nil
|
||||||
|
}, m.queryPrimary)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return &resp, nil
|
||||||
|
case sqlc.ErrNotFound:
|
||||||
|
return nil, ErrNotFound
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) Update(ctx context.Context, session sqlx.Session, newData *AgentRealName) (sql.Result, error) {
|
||||||
|
data, err := m.FindOne(ctx, newData.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tydataAgentRealNameAgentIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameAgentIdPrefix, data.AgentId)
|
||||||
|
tydataAgentRealNameIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameIdPrefix, data.Id)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, agentRealNameRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, newData.AgentId, newData.Name, newData.IdCard, newData.Status, newData.DelState, newData.Version, newData.ApproveTime, newData.RejectTime, newData.DeleteTime, newData.Id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, newData.AgentId, newData.Name, newData.IdCard, newData.Status, newData.DelState, newData.Version, newData.ApproveTime, newData.RejectTime, newData.DeleteTime, newData.Id)
|
||||||
|
}, tydataAgentRealNameAgentIdKey, tydataAgentRealNameIdKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *AgentRealName) error {
|
||||||
|
|
||||||
|
oldVersion := newData.Version
|
||||||
|
newData.Version += 1
|
||||||
|
|
||||||
|
var sqlResult sql.Result
|
||||||
|
var err error
|
||||||
|
|
||||||
|
data, err := m.FindOne(ctx, newData.Id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tydataAgentRealNameAgentIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameAgentIdPrefix, data.AgentId)
|
||||||
|
tydataAgentRealNameIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameIdPrefix, data.Id)
|
||||||
|
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, agentRealNameRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, newData.AgentId, newData.Name, newData.IdCard, newData.Status, newData.DelState, newData.Version, newData.ApproveTime, newData.RejectTime, newData.DeleteTime, newData.Id, oldVersion)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, newData.AgentId, newData.Name, newData.IdCard, newData.Status, newData.DelState, newData.Version, newData.ApproveTime, newData.RejectTime, newData.DeleteTime, newData.Id, oldVersion)
|
||||||
|
}, tydataAgentRealNameAgentIdKey, tydataAgentRealNameIdKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
updateCount, err := sqlResult.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if updateCount == 0 {
|
||||||
|
return ErrNoRowsUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentRealName) error {
|
||||||
|
data.DelState = globalkey.DelStateYes
|
||||||
|
data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true}
|
||||||
|
if err := m.UpdateWithVersion(ctx, session, data); err != nil {
|
||||||
|
return errors.Wrapf(errors.New("delete soft failed "), "AgentRealNameModel delete err : %+v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("IFNULL(SUM(" + field + "),0)")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp float64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("COUNT(" + field + ")")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp int64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*AgentRealName, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(agentRealNameRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*AgentRealName
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentRealName, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(agentRealNameRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*AgentRealName
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentRealName, int64, error) {
|
||||||
|
|
||||||
|
total, err := m.FindCount(ctx, builder, "id")
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns(agentRealNameRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*AgentRealName
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, total, nil
|
||||||
|
default:
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentRealName, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(agentRealNameRows)
|
||||||
|
|
||||||
|
if preMinId > 0 {
|
||||||
|
builder = builder.Where(" id < ? ", preMinId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*AgentRealName
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentRealName, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(agentRealNameRows)
|
||||||
|
|
||||||
|
if preMaxId > 0 {
|
||||||
|
builder = builder.Where(" id > ? ", preMaxId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*AgentRealName
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error {
|
||||||
|
|
||||||
|
return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||||
|
return fn(ctx, session)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) SelectBuilder() squirrel.SelectBuilder {
|
||||||
|
return squirrel.Select().From(m.table)
|
||||||
|
}
|
||||||
|
func (m *defaultAgentRealNameModel) Delete(ctx context.Context, session sqlx.Session, id int64) error {
|
||||||
|
data, err := m.FindOne(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tydataAgentRealNameAgentIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameAgentIdPrefix, data.AgentId)
|
||||||
|
tydataAgentRealNameIdKey := fmt.Sprintf("%s%v", cacheTydataAgentRealNameIdPrefix, id)
|
||||||
|
_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, id)
|
||||||
|
}, tydataAgentRealNameAgentIdKey, tydataAgentRealNameIdKey)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
func (m *defaultAgentRealNameModel) formatPrimary(primary interface{}) string {
|
||||||
|
return fmt.Sprintf("%s%v", cacheTydataAgentRealNameIdPrefix, primary)
|
||||||
|
}
|
||||||
|
func (m *defaultAgentRealNameModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", agentRealNameRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultAgentRealNameModel) tableName() string {
|
||||||
|
return m.table
|
||||||
|
}
|
@ -15,7 +15,7 @@ $tables = @(
|
|||||||
# "agent_commission_deduction",
|
# "agent_commission_deduction",
|
||||||
# "agent_link",
|
# "agent_link",
|
||||||
# "agent_membership_config",
|
# "agent_membership_config",
|
||||||
"agent_membership_recharge_order"
|
# "agent_membership_recharge_order"
|
||||||
# "agent_membership_user_config",
|
# "agent_membership_user_config",
|
||||||
# "agent_order",
|
# "agent_order",
|
||||||
# "agent_platform_deduction",
|
# "agent_platform_deduction",
|
||||||
@ -23,6 +23,7 @@ $tables = @(
|
|||||||
# "agent_rewards",
|
# "agent_rewards",
|
||||||
# "agent_wallet",
|
# "agent_wallet",
|
||||||
# "agent_withdrawal",
|
# "agent_withdrawal",
|
||||||
|
"agent_real_name"
|
||||||
# "feature",
|
# "feature",
|
||||||
# "global_notifications",
|
# "global_notifications",
|
||||||
# "order",
|
# "order",
|
||||||
|
Loading…
Reference in New Issue
Block a user