160 lines
6.4 KiB
Go
160 lines
6.4 KiB
Go
package awssqs
|
||
|
||
import (
|
||
"encoding/json"
|
||
|
||
"github.com/shopspring/decimal"
|
||
)
|
||
|
||
type SqsMessage struct {
|
||
Action SqsAction `json:"action"`
|
||
Content string `json:"content"`
|
||
}
|
||
|
||
type SqsAction int32
|
||
|
||
func (a SqsAction) GetId() int32 {
|
||
return int32(a)
|
||
}
|
||
|
||
func (a SqsAction) GetName() string {
|
||
return SqsActionMap[a].Name
|
||
}
|
||
|
||
const (
|
||
SqsActionCreateUser = SqsAction(10)
|
||
SqsActionIncreaseBetTotal = SqsAction(20)
|
||
SqsActionDecreaseBetTotal = SqsAction(21) // 结算后扣除稽核流水
|
||
SqsActionInviteCratesCheck = SqsAction(30)
|
||
SqsActionLoginIpCheck = SqsAction(40)
|
||
SqsActionExportData = SqsAction(50)
|
||
SqsActionSendEmailVerifyCode = SqsAction(60)
|
||
SqsActionDailyQuestProcess = SqsAction(70)
|
||
SqsActionDepositSuccess = SqsAction(80)
|
||
SqsActionVisit = SqsAction(90)
|
||
SqsActionSaveBonus = SqsAction(100)
|
||
SqsActionInviteBonusCheck = SqsAction(110)
|
||
SqsActionGenDepositDailyClaim = SqsAction(120)
|
||
SqsActionDeductWithdrawLimitAfterTransfer = SqsAction(130) // 回收后才结算,扣除稽核流水
|
||
|
||
// 用户行为日志
|
||
SqsActionUserBehaviorRegister = SqsAction(200) // 注册
|
||
SqsActionUserBehaviorLogin = SqsAction(201) // 登录
|
||
SqsActionUserBehaviorEditPassword = SqsAction(202) // 修改登录密码
|
||
SqsActionUserBehaviorEditPayPassword = SqsAction(203) // 修改支付密码
|
||
SqsActionUserBehaviorUpdateWallet = SqsAction(204) // 更新钱包地址(绑定钱包/银行卡)
|
||
SqsActionWalletBalanceChange = SqsAction(205) // 用户账户余额变更(充值、提现、游戏交易)
|
||
)
|
||
|
||
var SqsActionMap = map[SqsAction]struct {
|
||
Id int32
|
||
Name string
|
||
}{
|
||
SqsActionCreateUser: {Id: 10, Name: "SqsActionCreateUser"},
|
||
SqsActionIncreaseBetTotal: {Id: 20, Name: "SqsActionIncreaseBetTotal"},
|
||
SqsActionDecreaseBetTotal: {Id: 21, Name: "SqsActionDecreaseBetTotal"},
|
||
SqsActionInviteCratesCheck: {Id: 30, Name: "SqsActionInviteCratesCheck"},
|
||
SqsActionLoginIpCheck: {Id: 40, Name: "SqsActionLoginIpCheck"},
|
||
SqsActionExportData: {Id: 50, Name: "SqsActionExportData"},
|
||
SqsActionSendEmailVerifyCode: {Id: 60, Name: "SqsActionSendEmailVerifyCode"},
|
||
SqsActionDailyQuestProcess: {Id: 70, Name: "SqsActionDailyQuestProcess"},
|
||
SqsActionDepositSuccess: {Id: 80, Name: "SqsActionDepositSuccess"},
|
||
SqsActionVisit: {Id: 90, Name: "SqsActionVisit"},
|
||
SqsActionSaveBonus: {Id: 100, Name: "SqsActionSaveBonus"},
|
||
SqsActionInviteBonusCheck: {Id: 110, Name: "SqsActionInviteBonus"},
|
||
SqsActionGenDepositDailyClaim: {Id: 120, Name: "SqsActionGenDepositDailyClaim"},
|
||
SqsActionDeductWithdrawLimitAfterTransfer: {Id: 130, Name: "SqsActionDeductWithdrawLimitAfterTransfer"},
|
||
|
||
SqsActionUserBehaviorRegister: {Id: 200, Name: "SqsActionUserBehaviorRegister"},
|
||
SqsActionUserBehaviorLogin: {Id: 201, Name: "SqsActionUserBehaviorLogin"},
|
||
SqsActionUserBehaviorEditPassword: {Id: 202, Name: "SqsActionUserBehaviorEditPassword"},
|
||
SqsActionUserBehaviorEditPayPassword: {Id: 203, Name: "SqsActionUserBehaviorEditPayPassword"},
|
||
SqsActionUserBehaviorUpdateWallet: {Id: 204, Name: "SqsActionUserBehaviorUpdateWallet"},
|
||
SqsActionWalletBalanceChange: {Id: 205, Name: "SqsActionWalletBalanceChange"},
|
||
}
|
||
|
||
type SqsActionRegisterContent struct {
|
||
Userno string `json:"userno"`
|
||
ClientIp string `json:"clientIp"`
|
||
}
|
||
type LoginIpCheck struct {
|
||
Userno string `json:"userno"`
|
||
Ip string `json:"ip"`
|
||
}
|
||
|
||
type SqsActionSendEmailVerifyCodeContent struct {
|
||
Email string `json:"email"`
|
||
Lang string `json:"lang"`
|
||
}
|
||
|
||
type SqsActionDailyQuestProcessContent struct {
|
||
Userno string `json:"userno"`
|
||
QuestType string `json:"questType"`
|
||
IncreaseProcess string `json:"increaseProcess"`
|
||
}
|
||
|
||
type SqsActionDepositSuccessContent struct {
|
||
Orderno string `json:"orderno"`
|
||
Userno string `json:"userno"`
|
||
DepositAmount decimal.Decimal `json:"depositAmount"`
|
||
SuccessTime int64 `json:"successTime"`
|
||
DepositTimes int32 `json:"depositTimes"`
|
||
BonusId string `json:"bonusId"`
|
||
}
|
||
|
||
type SqsActionWebSocketInitContent struct {
|
||
Userno string `json:"userno"`
|
||
ConnectId string `json:"userno"`
|
||
}
|
||
|
||
type SqsActionSaveBonusContent struct {
|
||
Userno string `json:"userno"`
|
||
BonusCategory int32 `json:"bonusCategory"`
|
||
BonusType int32 `json:"bonusType"`
|
||
BonusDetail string `json:"bonusDetail"`
|
||
SourceId string `json:"sourceId"`
|
||
DoneValue string `json:"doneValue"`
|
||
BonusAmount string `json:"bonusAmount"`
|
||
ClaimTime int64 `json:"claimTime"`
|
||
}
|
||
|
||
type SqsActionGenDepositDailyClaimContent struct {
|
||
UserPromotionId uint64 `json:"userPromotionId"`
|
||
}
|
||
|
||
type SqsActionDeductWithdrawLimitAfterTransferContent struct {
|
||
Userno string `json:"userno"`
|
||
BetOrderno string `json:"betOrderno"`
|
||
ValidBetAmount decimal.Decimal `json:"validBetAmount"`
|
||
ProviderId int32 `json:"providerId"`
|
||
SourceType int32 `json:"sourceType"` // WalletRecordSourceType
|
||
}
|
||
|
||
// SqsActionUserBehaviorContent 用户行为日志:注册、登录、修改密码、修改支付密码、更新钱包地址
|
||
type SqsActionUserBehaviorContent struct {
|
||
Userno string `json:"userno"`
|
||
Ip string `json:"ip"`
|
||
Header string `json:"header"`
|
||
Phone string `json:"phone,omitempty"` // 手机号(注册时有值)
|
||
}
|
||
|
||
// 用户账户余额变更:充值、提现、游戏交易
|
||
type SqsActionWalletBalanceChangeContent struct {
|
||
Userno string `json:"userno"`
|
||
Amount string `json:"amount"` // 变更金额(正=加,负=减)
|
||
SourceType int32 `json:"sourceType"` // WalletRecordSourceType
|
||
SourceId string `json:"sourceId"` // 订单号/actionId等
|
||
GameId string `json:"gameId"` // 游戏ID(游戏交易时有值)
|
||
BeforeBalance string `json:"beforeBalance"` // 变更前余额
|
||
AfterBalance string `json:"afterBalance"` // 变更后余额
|
||
RecordNo string `json:"recordNo"` // 账变流水号
|
||
}
|
||
|
||
func (m SqsMessage) Json() (string, error) {
|
||
marshal, err := json.Marshal(m)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
return string(marshal), nil
|
||
}
|