You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
291 lines
14 KiB
291 lines
14 KiB
package common |
|
|
|
import "gorm.io/gorm" |
|
|
|
const ( |
|
StatusROrderWaitting = iota // 等待提交状态 |
|
StatusROrderCreate |
|
StatusROrderPay |
|
StatusROrderFinish |
|
StatusROrderFail |
|
StatusROrderCancel |
|
StatusROrderRefuse |
|
StatusROrderPending // 挂起 |
|
StatusROrderAll |
|
) |
|
|
|
type PayType int |
|
|
|
// 支付类型,巴西代表cpf|cnpj|email|phone|evp |
|
// const ( |
|
// PayTypeInvalid PayType = iota |
|
// PayTypeCPF |
|
// PayTypeCNPJ |
|
// PayTypePhone |
|
// PayTypeEmail |
|
// PayTypeEVP |
|
// PayTypeAll |
|
// ) |
|
|
|
const ( |
|
PayTypeInvalid PayType = iota |
|
PayTypeBank |
|
PayTypeUPI |
|
PayTypeAll |
|
) |
|
|
|
func (p PayType) Isvalid() bool { |
|
return p > PayTypeInvalid && p < PayTypeAll |
|
} |
|
|
|
// func (p PayType) String() string { |
|
// switch p { |
|
// case PayTypeCPF: |
|
// return "CPF" |
|
// case PayTypeCNPJ: |
|
// return "CNPJ" |
|
// case PayTypePhone: |
|
// return "PHONE" |
|
// case PayTypeEmail: |
|
// return "EMAIL" |
|
// case PayTypeEVP: |
|
// return "EVP" |
|
// default: |
|
// return "" |
|
// } |
|
// } |
|
|
|
// ProductTypeRechargeWait 商品类型id |
|
const ( |
|
ProductTypeRechargeWait = iota + 1 |
|
ProductTypeAll |
|
) |
|
|
|
// 非常规支付方式 |
|
const ( |
|
PayTypePerson = -1 // 个卡支付 |
|
) |
|
|
|
// 首充活动id |
|
const ( |
|
WelcomeBonusProductID = 1111 |
|
) |
|
|
|
// 支付方式 |
|
const ( |
|
PaySourceZero = iota + 1 |
|
PaySourceModulePay // pay模块支付 |
|
PaySourceBlockPay // 区块链支付 |
|
PaySourceAll |
|
) |
|
|
|
// 用于记录商品id对应的购买次数,一个bigint可记录最多16个商品的最多15次购买记录 |
|
var ( |
|
ProductIDMap = map[int]int{} |
|
) |
|
|
|
func GetProductPayCount(total int64, id int) int { |
|
// log.Debug("total%v,id:%v", total, id) |
|
tmp, ok := ProductIDMap[id] |
|
if !ok { |
|
return 0 |
|
} |
|
return int((total >> (tmp * 4)) & 15) |
|
} |
|
|
|
func AddProductPayCount(total int64, id int) int64 { |
|
tmp, ok := ProductIDMap[id] |
|
if !ok { |
|
return total |
|
} |
|
// 右移,将当前需要操作的商品移动到最右侧 |
|
pos := tmp * 4 |
|
num := total >> (pos) |
|
|
|
// 拿到操作商品右侧的商品信息值 |
|
right := 1 |
|
for i := 0; i < pos; i++ { |
|
right *= 2 |
|
} |
|
right-- |
|
rightNum := total & int64(right) |
|
|
|
// 拿到需要操作的商品真实次数 |
|
realNum := num & 15 |
|
if realNum >= 15 { |
|
return total |
|
} |
|
num++ |
|
return rightNum | (num << (pos)) |
|
} |
|
|
|
type RechargeOrder struct { |
|
gorm.Model |
|
ID uint `gorm:"primarykey"` |
|
UID int `gorm:"column:uid;not null;type:int(11);index:uid"` |
|
CreateTime int64 `gorm:"column:create_time;type:bigint(20);comment:创建时间" redis:"create_time"` |
|
OrderID string `gorm:"column:orderid;not null;type:varchar(255);uniqueIndex:orderid;comment:本地ID"` |
|
APIPayID string `gorm:"column:apipayid;not null;type:varchar(255);comment:支付第三方生成的id"` |
|
Extra string `gorm:"column:extra;type:varchar(255);comment:额外信息字段"` |
|
PayAccount string `gorm:"column:payaccount;not null;type:varchar(512);comment:支付账户"` |
|
Amount int64 `gorm:"column:amount;not null;type:bigint(20);comment:单位8位小数"` |
|
PaySource int `gorm:"column:pay_source;not null;type:int(11);comment:支付来源"` |
|
PayChannel int `gorm:"column:pay_channel;type:int(11);comment:具体支付渠道"` |
|
Event int `gorm:"column:event;not null;type:smallint(4);comment:事件类型"` |
|
CurrencyType CurrencyType `gorm:"column:currency_type;not null;type:int(11);comment:货币类型"` |
|
ProductID int `gorm:"column:productid;not null;type:int(11)"` |
|
Status uint8 `gorm:"column:status;not null;type:tinyint(4);comment:1新建,2支付完成,3发货完成,4支付失败,5取消"` |
|
FailReason string `gorm:"column:fail_reason;type:varchar(255);comment:失败原因"` |
|
ChannelID int `gorm:"column:channel_id;type:bigint(20);default:1;comment:渠道id" redis:"channel_id"` |
|
Remarks string `gorm:"column:remarks;type:varchar(255);comment:备注" redis:"remarks"` |
|
CallbackTime int64 `gorm:"column:callback_time;type:bigint(20);comment:到账时间" redis:"callback_time"` |
|
UPI int `gorm:"column:upi;not null;type:int(11);comment:玩家选择的upi"` |
|
Bonus int64 `gorm:"column:bonus;type:bigint(20);default:0;comment:选择了bonus后赠送的数额"` |
|
Times int `gorm:"column:times;not null;type:int(11);comment:额度购买次数"` |
|
Scene int `gorm:"column:scene;type:int(11);default:0;comment:支付场景"` |
|
WithdrawCash int64 `gorm:"column:withdraw_cash;type:bigint(20);default:0;comment:提现扣除的金币" json:"withdraw_cash" redis:"withdraw_cash"` |
|
} |
|
|
|
func (r *RechargeOrder) TableName() string { |
|
return "recharge_order" |
|
} |
|
|
|
const ( |
|
WithdrawOrderTypeZero = iota |
|
WithdrawOrderTypeNormal |
|
WithdrawOrderTypeShare |
|
WithdrawOrderTypeAll |
|
) |
|
|
|
// 支付类型 |
|
const ( |
|
WithdrawTypeWallet = "3" |
|
WithdrawTypeUPI = "4" |
|
WithdrawTypeBank = "7" |
|
) |
|
|
|
type WithdrawOrder struct { |
|
ID uint `gorm:"primarykey"` |
|
UID int `gorm:"column:uid;not null;type:int(11)"` |
|
CreateTime int64 `gorm:"column:create_time;type:bigint(20);comment:创建时间"` |
|
OrderID string `gorm:"column:orderid;not null;type:varchar(255);uniqueIndex:orderid;comment:本地ID"` |
|
APIPayID string `gorm:"column:apipayid;not null;type:varchar(255);comment:支付第三方生成的id"` |
|
Extra string `gorm:"column:extra;type:varchar(64);comment:额外信息字段"` |
|
PayAccount string `gorm:"column:payaccount;not null;type:varchar(512);comment:支付账户"` |
|
Amount int64 `gorm:"column:amount;not null;type:bigint(20);comment:单位分"` |
|
WithdrawCash int64 `gorm:"column:withdraw_cash;type:bigint(20);default:0;comment:退出扣除的金币"` |
|
PaySource int `gorm:"column:pay_source;not null;type:int(11);comment:支付来源"` |
|
CurrencyType CurrencyType `gorm:"column:currency_type;not null;type:int(11);comment:货币类型"` |
|
PayChannel int `gorm:"column:pay_channel;type:int(11);comment:具体支付渠道"` |
|
Event int `gorm:"column:event;not null;type:smallint(4);comment:事件类型"` |
|
ProductID int `gorm:"column:productid;not null;type:int(11)"` |
|
Status uint8 `gorm:"column:status;not null;type:tinyint(4);comment:1新建,2支付完成,3发货完成,4支付失败,5取消"` |
|
FailReason string `gorm:"column:fail_reason;type:varchar(255);comment:失败原因"` |
|
ChannelID int `gorm:"column:channel_id;type:bigint(20);default:1;comment:渠道id"` |
|
Remarks string `gorm:"column:remarks;type:varchar(255);comment:备注"` |
|
AuditTime int64 `gorm:"column:audit_time;type:bigint(20);comment:审核时间"` |
|
CallbackTime int64 `gorm:"column:callback_time;type:bigint(20);comment:到账时间"` |
|
UPI int `gorm:"column:upi;not null;type:int(11);comment:玩家选择的upi"` |
|
Operator string `gorm:"column:operator;type:varchar(255);comment:操作人账号名"` |
|
OrderType int `gorm:"column:order_type;default:1;type:int(11);comment:订单类型 1普通 2分享单"` |
|
} |
|
|
|
func (r *WithdrawOrder) TableName() string { |
|
return "withdraw_order" |
|
} |
|
|
|
// RechargeInfo 玩家充值信息记录表 |
|
type RechargeInfo struct { |
|
ID uint `gorm:"primarykey"` |
|
UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` |
|
ProductPayCount int64 `gorm:"column:product_paycount;type:bigint(20);default:0;comment:记录玩家购买商品次数,映射表在代码里"` |
|
DayRecharge int64 `gorm:"column:day_recharge;type:bigint(20);default:0;comment:日充值"` |
|
TotalRechargeCount int64 `gorm:"column:total_recharge_count;type:bigint(20);default:0;comment:总充值次数"` |
|
LastRecharge int64 `gorm:"column:last_recharge;type:bigint(20);default:0;comment:最近一次充值的时间戳"` |
|
TotalRecharge int64 `gorm:"column:total_recharge;type:bigint(20);default:0;comment:总充值数额,不论货币"` |
|
TotalWithdrawCount int64 `gorm:"column:total_withdraw_count;type:bigint(20);default:0;comment:总退出次数"` |
|
TotalWithdraw int64 `gorm:"column:total_withdraw;type:bigint(20);default:0;comment:总退出数额,不论货币"` |
|
TotalWithdrawing int64 `gorm:"column:total_withdrawing;type:bigint(20);default:0;comment:提现中的钱"` |
|
DayWithdraw int64 `gorm:"column:day_withdraw;type:bigint(20);default:0;comment:当日退出数额,不论货币"` |
|
LastWithdraw int64 `gorm:"column:last_withdraw;type:bigint(20);default:0;comment:最近一次退出的时间戳"` |
|
WithdrawCount int `gorm:"column:withdraw_count;type:int(11);default:0;comment:当天累计退出次数"` |
|
WithdrawingCash int64 `gorm:"column:withdrawing_cash;type:bigint(20);default:0;comment:提现中的金币" json:"withdrawing_cash"` |
|
BuyAmountData string `gorm:"column:buy_amount_data;default:'';type:varchar(1024);comment:购买额度信息"` // 购买额度信息 |
|
BuyAmountDataMap map[string]int `gorm:"-"` |
|
} |
|
|
|
func (r *RechargeInfo) TableName() string { |
|
return "recharge_info" |
|
} |
|
|
|
// RechargeInfoCurrency 玩家各货币充值信息记录表模板 |
|
type RechargeInfoCurrency struct { |
|
ID uint `gorm:"primarykey"` |
|
UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` |
|
TotalRecharge int64 `gorm:"column:total_recharge;type:bigint(20);default:0;comment:总充值" json:"total_recharge"` |
|
TotoalWithdraw int64 `gorm:"column:total_withdraw;type:bigint(20);default:0;comment:总退出" json:"total_withdraw"` |
|
TotoalWithdrawing int64 `gorm:"column:total_withdrawing;type:bigint(20);default:0;comment:总退出中" json:"total_withdrawing"` |
|
} |
|
|
|
// PayInfo 支付信息 |
|
// Name 收款人姓名 |
|
// Mobile 收款人手机号码 |
|
// Email 收款人邮箱 |
|
// PayType 收款方式 |
|
// Number 卡号或收款信息 |
|
type PayInfo struct { |
|
ID uint `gorm:"primarykey"` |
|
UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` |
|
DeviceNo string `gorm:"column:device_no;default:'';type:varchar(256);comment:设备号" json:"DeviceNo"` // 设备号 |
|
Device string `gorm:"column:device;default:'';type:varchar(256);comment:MAC地址" json:"Device"` // Android:MAC地址 IOS:IDFA |
|
PhoneModel string `gorm:"column:phone_model;default:'';type:varchar(256);comment:机型" json:"PhoneModel"` // 机型 |
|
OperatorOs string `gorm:"column:model;default:'';type:varchar(256);comment:操作系统" json:"OperatorOs"` // 操作系统,例如Android4.4 |
|
|
|
AccountName string `gorm:"column:account_name;default:'';type:varchar(256);comment:收款人姓名" json:"AccountName"` // 收款人姓名 |
|
Mobile string `gorm:"column:mobile;default:'';type:varchar(256);comment:收款人手机号码" json:"Mobile"` // 收款人手机号码 |
|
Email string `gorm:"column:email;default:'';type:varchar(256);comment:收款人邮箱" json:"Email"` // 收款人邮箱 |
|
BankCardNo string `gorm:"column:bank_card_no;default:'';type:varchar(256);comment:收款银行卡号" json:"BankCardNo"` // 收款银行卡号,银行卡代付方式必填 |
|
PayType PayType `gorm:"column:pay_type;default:0;type:int(11);comment:收款方式1:银行卡 2:UPI" json:"PayType"` // 收款方式 |
|
BankCode string `gorm:"column:bank_code;default:'';type:varchar(256);comment:银行编码或者钱包类型" json:"BankCode"` // 银行编码或者钱包类型 UPI代付的VPA账号,3至50个字符。支持的字符:a-z,A-Z,0-9,.,-和一个@,虚拟付款地址,例如,dfumar@exampleupi |
|
Address string `gorm:"column:address;default:'';type:varchar(256);comment:收款人地址" json:"Address"` // 收款人地址 |
|
} |
|
|
|
func (p *PayInfo) TableName() string { |
|
return "pay_info" |
|
} |
|
|
|
type WithdrawInfo struct { |
|
ID uint `gorm:"primarykey"` |
|
UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` |
|
AccountNumber string `gorm:"column:account_number;default:'';type:varchar(256);comment:账户号码" json:"AccountNumber"` // 账户号码 |
|
UserName string `gorm:"column:user_name;default:'';type:varchar(256);comment:用户名" json:"UserName"` // 用户名 |
|
IFSCCode string `gorm:"column:ifsc_code;default:'';type:varchar(256);comment:ifsc" json:"IFSCCode"` // ifsc |
|
BankName string `gorm:"column:bank_name;default:'';type:varchar(256);comment:银行名称" json:"BankName"` // 银行名称 |
|
BankBranchName string `gorm:"column:bank_branch_name;default:'';type:varchar(256);comment:银行分行名称" json:"BankBranchName"` // 银行分行名称 |
|
PhoneNumber string `gorm:"column:phone_number;default:'';type:varchar(256);comment:手机号码" json:"PhoneNumber"` // 手机号码 |
|
Email string `gorm:"column:email;default:'';type:varchar(256);comment:邮箱" json:"Email"` // 邮箱 |
|
UpdateIp string `gorm:"column:update_ip;default:'';type:varchar(256);comment:更改ip" json:"UpdateIp"` // 更改ip |
|
UpdatedAt int64 `gorm:"column:updated_at;type:int(11);default:0;comment:更新时间" json:"UpdatedAt"` // 更改时间 |
|
} |
|
|
|
func (p *WithdrawInfo) TableName() string { |
|
return "withdraw_info" |
|
} |
|
|
|
// WithdrawCommon 支付信息公共部分 地址格式{"city":"Mumbai","street":"sarang street","houseNumber":"-54/a"} |
|
type WithdrawCommon struct { |
|
Name string |
|
DeviceNo string `json:"deviceNo"` // 设备号 |
|
// Device string `json:"device"` // Android:MAC地址 IOS:IDFA |
|
Model string `json:"model"` // 机型 |
|
OperatorOs string `json:"operatorOs"` // 操作系统,例如Android4.4 |
|
AccountName string `json:"accountName"` // 收款人姓名 |
|
Mobile string `json:"mobile"` // 收款人手机号码 |
|
Email string `json:"email"` // 收款人邮箱 |
|
BankCardNo string `json:"bankCardNo"` // 收款银行卡号,银行卡代付方式必填 |
|
PayType PayType `json:"payType"` |
|
BankCode string `json:"bankCode"` // 银行编码或者钱包类型 UPI代付的VPA账号,3至50个字符。支持的字符:a-z,A-Z,0-9,.,-和一个@,虚拟付款地址,例如,dfumar@exampleupi |
|
BankName string `json:"bankName"` // 银行名称 |
|
BankBranchName string `json:"bankBranchName"` // 银行子名称 |
|
IP string `json:"ip"` // ip |
|
}
|
|
|