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.
235 lines
9.7 KiB
235 lines
9.7 KiB
package common |
|
|
|
const ( |
|
StatusROrderWaitting = iota // 等待提交状态 |
|
StatusROrderCreate |
|
StatusROrderPay |
|
StatusROrderFinish |
|
StatusROrderFail |
|
StatusROrderRefuse |
|
StatusROrderPending // 挂起 |
|
StatusROrderAll |
|
) |
|
|
|
type PayType int |
|
|
|
// 支付类型,巴西代表cpf|cnpj|email|phone|evp |
|
const ( |
|
PayTypeInvalid PayType = iota |
|
PayTypeCPF |
|
PayTypeCNPJ |
|
PayTypePhone |
|
PayTypeEmail |
|
PayTypeEVP |
|
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 { |
|
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"` |
|
} |
|
|
|
func (r *RechargeOrder) TableName() string { |
|
return "recharge_order" |
|
} |
|
|
|
const ( |
|
WithdrawOrderTypeZero = iota |
|
WithdrawOrderTypeNormal |
|
WithdrawOrderTypeShare |
|
WithdrawOrderTypeAll |
|
) |
|
|
|
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"` |
|
} |
|
|
|
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"` |
|
Name string `gorm:"column:name;default:'';type:varchar(256);comment:收款人姓名"` |
|
Mobile string `gorm:"column:mobile;default:'';type:varchar(256);comment:收款人手机号码"` |
|
Email string `gorm:"column:email;default:'';type:varchar(256);comment:收款人邮箱"` |
|
PayType PayType `gorm:"column:pay_type;default:1;type:int(11);comment:收款方式"` |
|
Number string `gorm:"column:number;default:'';type:varchar(256);comment:卡号或收款信息"` |
|
} |
|
|
|
func (p *PayInfo) TableName() string { |
|
return "pay_info" |
|
} |
|
|
|
// WithdrawCommon 支付信息公共部分 地址格式{"city":"Mumbai","street":"sarang street","houseNumber":"-54/a"} |
|
type WithdrawCommon struct { |
|
Name string // 收款人姓名 |
|
Mobile string // 收款人手机号码 |
|
Email string // 收款人邮箱 |
|
PayType PayType |
|
Number string |
|
Address string |
|
IP string |
|
}
|
|
|