package model import ( "errors" "leafstalk/otherutils/deepcopy" "time" "xorm.io/xorm" ) const ( PayTypeMoney = 1 //现金支付 PayTypeAd = 2 //广告获得 PayTypeItem = 3 //道具兑换 PayTypeFree = 4 //免费 ) // 购买信息 type WxPayPlayer struct { Id int64 PlayerID int64 `xorm:"BIGINT 'playerid'"` Buys map[int64]*PeriodBuys `xorm:"BIGINT 'buys'"` Refreshs map[int64]*RefreshGoods `xorm:"varchar(255) json 'refresh'"` // LevelGoods map[int64]struct{} `xorm:"TEXT 'lvGoods'"` // DailyGoods *RefreshBuys `xorm:"TEXT json'dailys'"` // CoinGoods *PeriodBuys `xorm:"TEXT json 'coins'"` // DiamondGoods map[int64]int `xorm:"TEXT json 'diamonds'"` // BuyStatis map[int64]uint `xorm:"TEXT 'buyStatis'"` // NewerBox map[int64]int `xorm:"TEXT json 'orderBox'"` // VipGoods []*LastBuyItem `xorm:"TEXT 'vipGoods'"` // DailyDiscount *TickBuys `xorm:"TEXT json 'dailyDiscount'"` // RoleGift *RoleGiftBuys `xorm:"TEXT json 'roleGift'"` // Invite *InviteGift `xorm:"TEXT json 'invite'"` // AccPay *AccPayGift `xorm:"TEXT json 'accPay'"` // Balance int `xorm:"int 'balance'"` // LuckDraw *PlayerLuckDraw `xorm:"TEXT json 'luckDraw'"` // Growth *GrowthGift `xorm:"TEXT json 'growth'"` // BoxKeyGift *TickBuys2 `xorm:"TEXT json 'boxKeyGift'"` // 装备钥匙礼包 // NewYearGift *TickBuys2 `xorm:"TEXT json 'newYearGift'"` // Fifteen *TickBuys2 `xorm:"TEXT json 'fifteen'"` // NewFifteen *TickBuys2 `xorm:"TEXT json 'newFifteen'"` // TombSweep *TickBuys2 `xorm:"TEXT json 'tombSweep'"` // Lady38 *TickBuys2 `xorm:"TEXT json 'lady38'"` // SpecialGift *SpecialGift `xorm:"TEXT json 'specialGift'"` // RichManGift *TickBuys2 `xorm:"TEXT json 'richMan'"` // 51劳动节 // DragonBoat *TickBuys2 `xorm:"TEXT json 'dragonBoat'"` // 端午节 // WeekendGift *TickBuys `xorm:"TEXT json 'weekendGift'"` // 周末礼包 // QiXiGift *TickBuys2 `xorm:"TEXT json 'qiXiGift'"` // 七夕礼包 // MoonFestivalGift *TickBuys2 `xorm:"TEXT json 'moonFestivalGift'"` // 中秋礼包 // YuanDanGift *TickBuys2 `xorm:"TEXT json 'yuanDanGift'"` // 元旦礼包 // ReturneGift *ReturneTickBuys `xorm:"TEXT json 'returneGift'"` // 回归礼包 // EndLessPass *EndLessPassGift `xorm:"TEXT json 'endLessPassGift'"` // 无尽通行证 // PuzzlePass *PuzzlePassGift `xorm:"TEXT json 'puzzlePassGift'"` // 拼图通行证 // WinterJonesPass *PuzzlePassGift `xorm:"TEXT json 'winterjonesPassGift'"` // 冬日夺宝通行证 // AccCostDiamond *AccCostDiamond `xorm:"TEXT json 'accCostDiamond'"` // 累计花费钻石 // NewServerAct *NewServerActTickBuys `xorm:"TEXT json 'newServerAct'"` // 新服活动 // NewerBox2 *NewerBox2 `xorm:"TEXT json 'orderBox2'"` // // ChanceBoxGift *GiftInfo `xorm:"TEXT json 'chanceBoxGift'"` // 机缘宝盒 // NationalGift *TickBuys2 `xorm:"TEXT json 'nationalGift'"` // 国庆礼包 // Holiday12Gift *TickBuys2 `xorm:"TEXT json 'holiday12Gift'"` // 双11礼包 // MonarchGift *MonarchGift `xorm:"TEXT json 'monarchGift'"` // 魔君赠送 // MasterPass *MasterPassGift `xorm:"TEXT json 'masterPassGift'"` // 最强王者通行证 // RichManPass *RichManPassGift `xorm:"TEXT json 'richManPassGift'"` // 51通行证 OpenId string `xorm:"-"` // GdtVid string `xorm:"-"` // Friends []int64 `xorm:"-"` // GateId int `xorm:"-"` // RecentPayedOrders []string `xorm:"-"` //最近支付订单 不用保存太多,最多50笔 } type PeriodBuys struct { // Id int64 `json:"id"` Ts int64 `json:"ts"` //最后购买时间 Count int64 `json:"count"` //周期 Total int64 `json:"total"` //总 } type RefreshGoods struct { Ts int64 `json:"ts"` //刷新时间 Count int64 `json:"count"` //刷新次数 Goods []int64 `json:"goods"` //商品ID列表 } type PeriodBuysItem struct { Num int `json:"num"` Ts int64 `json:"ts"` //当前商品购买时间,计算CD用 } // TickBuysTick // 统计周期内购买商品及数量 type PeriodBuys2 struct { Ts int64 `json:"ts"` //周期开始时间 Buys map[int64]*PeriodBuysItem `json:"buys"` } type RefreshBuys struct { Ts int64 `json:"ts"` //周期开始时间 RefreshCount int64 `json:"refresh"` //刷新次数 Goods []int64 `json:"goods"` //商品ID列表 Buys map[int64]int `json:"buys"` //购买次数 } // StoreGoods // 商店表-Store exported from 商店表.xlsx type StoreGoods struct { Id int64 `json:"Uid"` // ID GoodsType int64 `json:"GoodsType"` // 商店类型 1--等级商店 2--每日商店 3--金币商店 4--钻石商店 UnlockLv int64 `json:"UnlockLv"` // 解锁要求 0--不限 1--等级 2--关卡 Name string `json:"Name"` // 礼包名称 Content [][]int64 `json:"Content"` // 商品内容 RandomGroup int64 `json:"RandomGroup"` // 随机组 Weight int64 `json:"Weight"` // 刷新权重 -1--必出 0--不出 Quota []int64 `json:"Quota"` // 限购次数 0--不限 1--每日 2--每周 3--总限 4--日刷新 Discount float64 `json:"Discount"` // 折扣比例 显示用 Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费 CdrpId int64 `json:"CdrpId"` // 计费点 Video int64 `json:"Video"` // 广告点ID } func (sg *StoreGoods) GetWeight() int64 { return sg.Weight } func (sg *StoreGoods) GetId() int64 { return sg.Id } func (sg *StoreGoods) GetCost() (payType int64, cost []int64, err error) { num := len(sg.Price) if num == 0 { err = errors.New("no price") return } payType = sg.Price[0] switch payType { case PayTypeMoney: return case PayTypeAd: return case PayTypeItem: if num != 3 { err = errors.New("price error") return } cost = sg.Price[1:] case PayTypeFree: return } return } // 商店刷新-StoreRefresh exported from 商店表.xlsx type StoreRefresh struct { Uid int64 `json:"Uid"` // ID RandomGroup int64 `json:"RandomGroup"` // 随机组 RefreshTime int64 `json:"RefreshTime"` // 刷新次数 0--表示无 RefreshNum int64 `json:"RefreshNum"` // 刷新数量 Price [][]int64 `json:"Price"` // 每次刷新消耗 [方式,具ID,数量] 3-道具 4-免费 } // 广告点配置-AdList exported from 广告点.xlsx type AdList struct { Uid int64 `json:"Uid"` // 广告点唯一编号 其它地方统一调用此编号 Name string `json:"Name"` // 广告点名字 CD int64 `json:"CD"` // 冷却时间 /秒 AdReward [][]int64 `json:"AdReward"` // 有广告时奖励 【【道具类型,道具ID,道具数量】】 【0】:无奖励/功能类广告 NormalReward [][]int64 `json:"NormalReward"` // 无广告时奖励 【】:不填则入口消失 【【道具类型,道具ID,道具数量】】 【0】:无奖励/功能类广告 } // package model // 渠道组-Channel exported from 广告点.xlsx type Channel struct { Uid int64 `json:"Uid"` // 唯一编号 Name string `json:"Name"` // 渠道名称 Channel int64 `json:"Channel"` // 是否观看广告 0-无 1-有 } // 计费点-CDRP exported from 计费点.xlsx type CDRP struct { Uid int64 `json:"Uid"` // 编号 Name string `json:"Name"` // 名称 Content []int64 `json:"Content"` // 奖励 [[道具类型,道具ID,道具数量]] FirstReward []int64 `json:"FirstReward"` // 首次额外奖励 [[道具类型,道具ID,道具数量]] Discount float64 `json:"Discount"` // 折扣比例 显示用 PlatformPrice1 int64 `json:"PlatformPrice1"` // 微信平台 现价 PlatformPrice2 int64 `json:"PlatformPrice2"` // 抖音平台 现价 } type VirtualPayOrder struct { Id int64 PlayerID int64 `xorm:"BIGINT index 'playerid'"` OrderId string `xorm:"varchar(255) index 'orderId'"` Price int64 `xorm:"BIGINT 'price'"` State int `xorm:"int 'state'"` GoodsId int64 `xorm:"BIGINT 'goodsId'"` // 购买物品 Platform int `xorm:"BIGINT 'platform'"` //平台 1:微信 2:抖音 PayMethod int `xorm:"int 'payMethod'"` //支付方式 //0:苹果游戏外微信支付 1:安卓游戏内支付 2:安卓游戏外微信支付 3:苹果游戏内支付 Balance int `xorm:"int 'balance'"` //游戏币个数(包含赠送) GenBalance int `xorm:"int 'genBalance'"` //赠送游戏币数量(赠送游戏币数量 SaveSum int `xorm:"int 'saveSum'"` //历史总游戏币金额 SaveAmt int `xorm:"int 'saveAmt'"` //累计充值金额的游戏币数量 CostSum int `xorm:"int 'costSum'"` //历史总消费游戏币金额 PresentSum int `xorm:"int 'presentSum'"` //历史累计收到赠送金额 Operation string `xorm:"varchar(255) 'operation'"` BillNo string `xorm:"varchar(255) 'billNo'"` PayedBalance int `xorm:"int 'payedBalance'"` //预扣后的余额 UsedGenAmt int `xorm:"int 'usedGenAmt'"` //本次扣的赠送币的金额 CreateTime time.Time `xorm:"created"` } func (m VirtualPayOrder) TableName() string { return "virtualpayorder" } func (m *VirtualPayOrder) QueryExist(eng *xorm.Engine) (bool, error) { q := new(VirtualPayOrder) //q.PlayerID = m.PlayerID q.BillNo = m.BillNo return eng.Exist(q) } // 不许修改 func (m *VirtualPayOrder) UpdateDB(eng *xorm.Engine) (int64, error) { //return eng.Where("playerid=?", m.PlayerID).Update(m) return 0, nil } func (m *VirtualPayOrder) GetUniqueKey() string { return m.BillNo } func CopyVirtualPayOrder(old *VirtualPayOrder) *VirtualPayOrder { new1, err := deepcopy.Copy(old) //.(*VirtualPayOrder) //new(VirtualPayOrder) if err != nil { return nil } // *new1 = *old return new1.(*VirtualPayOrder) } // 商品价格表-StoreItem exported from 商店表.xlsx type StoreItem struct { ItemId int64 `json:"ItemId"` // 道具ID Price []int64 `json:"Price"` // 购买价格 【道具ID,价格】 }