428 lines
17 KiB
Go
428 lines
17 KiB
Go
package sysin
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"hotgo/internal/consts"
|
|
"hotgo/internal/library/dict"
|
|
"hotgo/internal/model/entity"
|
|
"hotgo/internal/model/input/form"
|
|
|
|
"github.com/gogf/gf/v2/encoding/gjson"
|
|
"github.com/gogf/gf/v2/errors/gerror"
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
)
|
|
|
|
type AppMemberListInp struct {
|
|
form.PageReq
|
|
Username string `json:"username" dc:"用户名"`
|
|
Mobile string `json:"mobile" dc:"手机号(精确查询)"`
|
|
MemberStatus int `json:"memberStatus" dc:"会员状态"`
|
|
AutoDispatch int `json:"autoDispatch" dc:"派单模式"`
|
|
MemberCategory int `json:"memberCategory" dc:"会员类别"`
|
|
CreatedAt []*gtime.Time `json:"createdAt" dc:"注册时间"`
|
|
}
|
|
|
|
func (in *AppMemberListInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberListModel struct {
|
|
Id uint64 `json:"id"`
|
|
MemberNo string `json:"memberNo"`
|
|
Username string `json:"username"`
|
|
Mobile string `json:"mobile"`
|
|
RealNameMask string `json:"realNameMask"`
|
|
AvailableAmount int64 `json:"availableAmount"`
|
|
FrozenAmount int64 `json:"frozenAmount"`
|
|
ParentId uint64 `json:"parentId"`
|
|
ParentUsername string `json:"parentUsername"`
|
|
InviteCode string `json:"inviteCode"`
|
|
MemberStatus int `json:"memberStatus"`
|
|
RiskStatus int `json:"riskStatus"`
|
|
AutoDispatch int `json:"autoDispatch"`
|
|
MemberCategory int `json:"memberCategory"`
|
|
IsTestAccount int `json:"isTestAccount"`
|
|
LastLoginAt *gtime.Time `json:"lastLoginAt"`
|
|
LastLoginIpMask string `json:"lastLoginIpMask"`
|
|
LastLoginRegion string `json:"lastLoginRegion"`
|
|
TodayTradeCount int `json:"todayTradeCount"`
|
|
CreatedAt *gtime.Time `json:"createdAt"`
|
|
}
|
|
|
|
type AppMemberViewInp struct {
|
|
Id uint64 `json:"id" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
}
|
|
|
|
func (in *AppMemberViewInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberViewModel struct {
|
|
AppMemberListModel
|
|
LevelId uint64 `json:"levelId"`
|
|
Level int `json:"level"`
|
|
CreditScore int `json:"creditScore"`
|
|
KycStatus int `json:"kycStatus"`
|
|
IdNoMask string `json:"idNoMask"`
|
|
PaymentAccountCount int `json:"paymentAccountCount"`
|
|
AddressCount int `json:"addressCount"`
|
|
TeamCount int `json:"teamCount"`
|
|
}
|
|
|
|
type AppMemberEditInp struct {
|
|
Id uint64 `json:"id"`
|
|
Username string `json:"username" v:"required|length:3,64#用户名不能为空|用户名长度为3到64个字符"`
|
|
Mobile string `json:"mobile" v:"phone-loose#手机号格式不正确"`
|
|
Password string `json:"password"`
|
|
TradePassword string `json:"tradePassword"`
|
|
RealName string `json:"realName" v:"max-length:64#姓名不能超过64个字符"`
|
|
IdNo string `json:"idNo" v:"max-length:32#证件号不能超过32个字符"`
|
|
ParentId uint64 `json:"parentId"`
|
|
LevelId uint64 `json:"levelId"`
|
|
RiskStatus int `json:"riskStatus" d:"1"`
|
|
CreditScore int `json:"creditScore" d:"100" v:"between:0,1000#信用分范围为0到1000"`
|
|
AutoDispatch int `json:"autoDispatch" d:"1"`
|
|
MemberCategory int `json:"memberCategory"`
|
|
IsTestAccount int `json:"isTestAccount"`
|
|
}
|
|
|
|
func (in *AppMemberEditInp) Filter(ctx context.Context) error {
|
|
if in.Id == 0 && strings.TrimSpace(in.Mobile) == "" {
|
|
return gerror.New("新增会员时手机号不能为空")
|
|
}
|
|
if in.Id == 0 && len(in.Password) < 8 {
|
|
return gerror.New("新增会员密码不能少于8位")
|
|
}
|
|
if in.Password != "" && (len(in.Password) < 8 || !containsLetterAndNumber(in.Password)) {
|
|
return gerror.New("密码至少8位且必须同时包含字母和数字")
|
|
}
|
|
if in.TradePassword != "" && len(in.TradePassword) < 6 {
|
|
return gerror.New("交易密码不能少于6位")
|
|
}
|
|
if !dict.HasOptionKey(consts.AppMemberRiskStatusOptions, in.RiskStatus) {
|
|
return gerror.New("风控状态不合法")
|
|
}
|
|
if !dict.HasOptionKey(consts.AppMemberDispatchModeOptions, in.AutoDispatch) {
|
|
return gerror.New("派单模式不合法")
|
|
}
|
|
if in.MemberCategory == 0 {
|
|
if in.IsTestAccount == 1 {
|
|
in.MemberCategory = consts.AppMemberCategoryFake
|
|
} else {
|
|
in.MemberCategory = consts.AppMemberCategoryReal
|
|
}
|
|
}
|
|
if !dict.HasOptionKey(consts.AppMemberCategoryOptions, in.MemberCategory) {
|
|
return gerror.New("会员类别不合法")
|
|
}
|
|
return nil
|
|
}
|
|
func containsLetterAndNumber(value string) bool {
|
|
letter, number := false, false
|
|
for _, r := range value {
|
|
if r >= '0' && r <= '9' {
|
|
number = true
|
|
}
|
|
if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') {
|
|
letter = true
|
|
}
|
|
}
|
|
return letter && number
|
|
}
|
|
|
|
type AppMemberDeleteInp struct {
|
|
Id uint64 `json:"id" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
Reason string `json:"reason" v:"required|max-length:500#注销原因不能为空|注销原因不能超过500个字符"`
|
|
}
|
|
|
|
func (in *AppMemberDeleteInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberAutoDispatchInp struct {
|
|
Id uint64 `json:"id" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
AutoDispatch int `json:"autoDispatch" v:"required|in:1,2#派单模式不能为空|派单模式不合法"`
|
|
}
|
|
|
|
func (in *AppMemberAutoDispatchInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberCategoryInp struct {
|
|
Id uint64 `json:"id" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
MemberCategory int `json:"memberCategory" v:"required#会员类别不能为空"`
|
|
}
|
|
|
|
func (in *AppMemberCategoryInp) Filter(ctx context.Context) error {
|
|
if !dict.HasOptionKey(consts.AppMemberCategoryOptions, in.MemberCategory) {
|
|
return gerror.New("会员类别不合法")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type AppMemberPaymentListInp struct {
|
|
MemberId uint64 `json:"memberId" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
}
|
|
|
|
func (in *AppMemberPaymentListInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberPaymentModel struct {
|
|
Id uint64 `json:"id"`
|
|
MemberId uint64 `json:"memberId"`
|
|
AccountType int `json:"accountType"`
|
|
BankCode string `json:"bankCode"`
|
|
BankName string `json:"bankName"`
|
|
HolderMask string `json:"holderMask"`
|
|
MobileMask string `json:"mobileMask"`
|
|
AccountNoMask string `json:"accountNoMask"`
|
|
QrAttachmentId uint64 `json:"qrAttachmentId"`
|
|
VerifyStatus int `json:"verifyStatus"`
|
|
IsDefault int `json:"isDefault"`
|
|
CreatedAt *gtime.Time `json:"createdAt"`
|
|
UpdatedAt *gtime.Time `json:"updatedAt"`
|
|
}
|
|
type AppMemberPaymentEditInp struct {
|
|
Id uint64 `json:"id"`
|
|
MemberId uint64 `json:"memberId" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
AccountType int `json:"accountType" v:"required#账户类型不能为空"`
|
|
BankCode string `json:"bankCode" v:"max-length:32#银行编码不能超过32个字符"`
|
|
BankName string `json:"bankName" v:"max-length:100#银行名称不能超过100个字符"`
|
|
Holder string `json:"holder"`
|
|
Mobile string `json:"mobile" v:"phone-loose#手机号格式不正确"`
|
|
AccountNo string `json:"accountNo"`
|
|
QrAttachmentId uint64 `json:"qrAttachmentId"`
|
|
VerifyStatus int `json:"verifyStatus" d:"1"`
|
|
IsDefault int `json:"isDefault" d:"2"`
|
|
}
|
|
|
|
func (in *AppMemberPaymentEditInp) Filter(ctx context.Context) error {
|
|
if !dict.HasOptionKey(consts.PaymentAccountTypeOptions, in.AccountType) {
|
|
return gerror.New("收款账户类型不合法")
|
|
}
|
|
if in.Id == 0 && (strings.TrimSpace(in.Holder) == "" || strings.TrimSpace(in.AccountNo) == "") {
|
|
return gerror.New("新增收款账户时持有人和账号不能为空")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type AppMemberPaymentDeleteInp struct {
|
|
Id uint64 `json:"id" v:"required|min:1#账户ID不能为空|账户ID不能为空"`
|
|
}
|
|
|
|
func (in *AppMemberPaymentDeleteInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberAddressListInp struct {
|
|
MemberId uint64 `json:"memberId" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
}
|
|
|
|
func (in *AppMemberAddressListInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberAddressModel struct {
|
|
Id uint64 `json:"id"`
|
|
MemberId uint64 `json:"memberId"`
|
|
ReceiverMask string `json:"receiverMask"`
|
|
MobileMask string `json:"mobileMask"`
|
|
Province string `json:"province"`
|
|
City string `json:"city"`
|
|
District string `json:"district"`
|
|
AddressMask string `json:"addressMask"`
|
|
IsDefault int `json:"isDefault"`
|
|
CreatedAt *gtime.Time `json:"createdAt"`
|
|
UpdatedAt *gtime.Time `json:"updatedAt"`
|
|
}
|
|
type AppMemberAddressEditInp struct {
|
|
Id uint64 `json:"id"`
|
|
MemberId uint64 `json:"memberId" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
Receiver string `json:"receiver"`
|
|
Mobile string `json:"mobile" v:"phone-loose#手机号格式不正确"`
|
|
Province string `json:"province"`
|
|
City string `json:"city"`
|
|
District string `json:"district"`
|
|
Address string `json:"address"`
|
|
IsDefault int `json:"isDefault" d:"2"`
|
|
}
|
|
|
|
func (in *AppMemberAddressEditInp) Filter(ctx context.Context) error {
|
|
if in.Id == 0 && (strings.TrimSpace(in.Receiver) == "" || strings.TrimSpace(in.Mobile) == "" || strings.TrimSpace(in.Address) == "") {
|
|
return gerror.New("新增地址时收货人、手机号和详细地址不能为空")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type AppMemberAddressDeleteInp struct {
|
|
Id uint64 `json:"id" v:"required|min:1#地址ID不能为空|地址ID不能为空"`
|
|
}
|
|
|
|
func (in *AppMemberAddressDeleteInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberSensitiveInp struct {
|
|
TargetType string `json:"targetType" v:"required|in:member,payment,address#目标类型不能为空|目标类型不合法"`
|
|
TargetId uint64 `json:"targetId" v:"required|min:1#目标ID不能为空|目标ID不能为空"`
|
|
PurposeCode string `json:"purposeCode" v:"required|max-length:64#用途编码不能为空|用途编码不能超过64个字符"`
|
|
PurposeText string `json:"purposeText" v:"required|max-length:500#用途说明不能为空|用途说明不能超过500个字符"`
|
|
Confirm bool `json:"confirm" v:"required#必须确认敏感信息查看"`
|
|
}
|
|
|
|
func (in *AppMemberSensitiveInp) Filter(ctx context.Context) error {
|
|
if !in.Confirm {
|
|
return gerror.New("请确认本次敏感信息查看")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type AppMemberSensitiveModel struct {
|
|
Fields map[string]string `json:"fields"`
|
|
AccessNo string `json:"accessNo"`
|
|
}
|
|
|
|
type AppMemberTeamInp struct {
|
|
form.PageReq
|
|
MemberId uint64 `json:"memberId" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
MaxLevel int `json:"maxLevel" d:"3" v:"between:1,10#团队层级范围为1到10"`
|
|
}
|
|
|
|
func (in *AppMemberTeamInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberTeamModel struct {
|
|
Id uint64 `json:"id"`
|
|
Username string `json:"username"`
|
|
Mobile string `json:"mobile"`
|
|
ParentId uint64 `json:"parentId"`
|
|
RelativeLevel int `json:"relativeLevel"`
|
|
TeamCount int `json:"teamCount"`
|
|
AvailableAmount int64 `json:"availableAmount"`
|
|
FrozenAmount int64 `json:"frozenAmount"`
|
|
MemberStatus int `json:"memberStatus"`
|
|
CreatedAt *gtime.Time `json:"createdAt"`
|
|
}
|
|
|
|
type AppMemberStatusRequestInp struct {
|
|
MemberId uint64 `json:"memberId" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
ToStatus int `json:"toStatus" v:"required#目标状态不能为空"`
|
|
ReasonCode string `json:"reasonCode" v:"required|max-length:64#原因编码不能为空|原因编码不能超过64个字符"`
|
|
ReasonText string `json:"reasonText" v:"required|max-length:500#原因说明不能为空|原因说明不能超过500个字符"`
|
|
ExpireAt *gtime.Time `json:"expireAt"`
|
|
}
|
|
|
|
func (in *AppMemberStatusRequestInp) Filter(ctx context.Context) error {
|
|
if !dict.HasOptionKey(consts.AppMemberStatusOptions, in.ToStatus) {
|
|
return gerror.New("目标状态不合法")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type AppMemberStatusExecuteInp struct {
|
|
ApprovalId uint64 `json:"approvalId" v:"required|min:1#审批ID不能为空|审批ID不能为空"`
|
|
}
|
|
|
|
func (in *AppMemberStatusExecuteInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type AppMemberApprovalModel struct {
|
|
ApprovalId uint64 `json:"approvalId"`
|
|
ApprovalNo string `json:"approvalNo"`
|
|
}
|
|
|
|
type WalletAdjustmentListInp struct {
|
|
form.PageReq
|
|
MemberId uint64 `json:"memberId"`
|
|
RequestStatus int `json:"requestStatus"`
|
|
CreatedAt []*gtime.Time `json:"createdAt"`
|
|
}
|
|
|
|
func (in *WalletAdjustmentListInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type WalletLedgerListInp struct {
|
|
form.PageReq
|
|
MemberId uint64 `json:"memberId" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
}
|
|
|
|
func (in *WalletLedgerListInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type WalletLedgerListModel struct {
|
|
Id uint64 `json:"id"`
|
|
LedgerNo string `json:"ledgerNo"`
|
|
BizType string `json:"bizType"`
|
|
BizNo string `json:"bizNo"`
|
|
EntryType string `json:"entryType"`
|
|
Direction int `json:"direction"`
|
|
Amount int64 `json:"amount"`
|
|
BeforeAmount int64 `json:"beforeAmount"`
|
|
AfterAmount int64 `json:"afterAmount"`
|
|
Currency string `json:"currency"`
|
|
Remark string `json:"remark"`
|
|
OccurredAt *gtime.Time `json:"occurredAt"`
|
|
}
|
|
|
|
type WalletAdjustmentListModel struct {
|
|
Id uint64 `json:"id"`
|
|
RequestNo string `json:"requestNo"`
|
|
MemberId uint64 `json:"memberId"`
|
|
Username string `json:"username"`
|
|
Mobile string `json:"mobile"`
|
|
AdjustType int `json:"adjustType"`
|
|
Direction int `json:"direction"`
|
|
Amount int64 `json:"amount"`
|
|
ReasonCode string `json:"reasonCode"`
|
|
ReasonText string `json:"reasonText"`
|
|
RequestStatus int `json:"requestStatus"`
|
|
ApprovalRequestId uint64 `json:"approvalRequestId"`
|
|
LedgerId uint64 `json:"ledgerId"`
|
|
CreatedAt *gtime.Time `json:"createdAt"`
|
|
}
|
|
type WalletAdjustmentRequestInp struct {
|
|
MemberId uint64 `json:"memberId" v:"required|min:1#会员ID不能为空|会员ID不能为空"`
|
|
AdjustType int `json:"adjustType" v:"required#调整类型不能为空"`
|
|
Direction int `json:"direction" v:"required#资金方向不能为空"`
|
|
Amount int64 `json:"amount" v:"required|min:1#金额不能为空|金额必须大于0"`
|
|
ReasonCode string `json:"reasonCode" v:"required|max-length:64#原因编码不能为空|原因编码不能超过64个字符"`
|
|
ReasonText string `json:"reasonText" v:"required|max-length:500#原因说明不能为空|原因说明不能超过500个字符"`
|
|
EvidenceJson *gjson.Json `json:"evidenceJson"`
|
|
IdempotencyKey string `json:"idempotencyKey" v:"required|max-length:80#幂等键不能为空|幂等键不能超过80个字符"`
|
|
}
|
|
|
|
func (in *WalletAdjustmentRequestInp) Filter(ctx context.Context) error {
|
|
if !dict.HasOptionKey(consts.WalletAdjustTypeOptions, in.AdjustType) || !dict.HasOptionKey(consts.WalletDirectionOptions, in.Direction) {
|
|
return gerror.New("调整类型或资金方向不合法")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type WalletAdjustmentExecuteInp struct {
|
|
Id uint64 `json:"id" v:"required|min:1#调账申请ID不能为空|调账申请ID不能为空"`
|
|
}
|
|
|
|
func (in *WalletAdjustmentExecuteInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type MemberNoticeListInp struct {
|
|
form.PageReq
|
|
Title string `json:"title"`
|
|
SourceType int `json:"sourceType"`
|
|
NoticeStatus int `json:"noticeStatus"`
|
|
}
|
|
|
|
func (in *MemberNoticeListInp) Filter(ctx context.Context) error { return nil }
|
|
|
|
type MemberNoticeListModel struct {
|
|
entity.AppMemberNotice
|
|
Username string `json:"username"`
|
|
}
|
|
type MemberNoticeEditInp struct {
|
|
MemberId uint64 `json:"memberId"`
|
|
Title string `json:"title" v:"required|max-length:120#标题不能为空|标题不能超过120个字符"`
|
|
Content string `json:"content" v:"required|max-length:500#内容不能为空|内容不能超过500个字符"`
|
|
SourceType int `json:"sourceType" v:"required#来源不能为空"`
|
|
StartAt *gtime.Time `json:"startAt" v:"required#开始时间不能为空"`
|
|
EndAt *gtime.Time `json:"endAt" v:"required#结束时间不能为空"`
|
|
}
|
|
|
|
func (in *MemberNoticeEditInp) Filter(ctx context.Context) error {
|
|
if in.StartAt.After(in.EndAt) {
|
|
return gerror.New("结束时间必须晚于开始时间")
|
|
}
|
|
if !dict.HasOptionKey(consts.MemberNoticeSourceOptions, in.SourceType) {
|
|
return gerror.New("通知来源不合法")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type MemberNoticeRevokeInp struct {
|
|
Id uint64 `json:"id" v:"required|min:1#通知ID不能为空|通知ID不能为空"`
|
|
Reason string `json:"reason" v:"required|max-length:500#撤回原因不能为空|撤回原因不能超过500个字符"`
|
|
}
|
|
|
|
func (in *MemberNoticeRevokeInp) Filter(ctx context.Context) error { return nil }
|