package model import ( "errors" "leafstalk/otherutils/deepcopy" "strconv" "xorm.io/xorm" ) type StoreDailyDetail struct { RefreshTs int64 `json:"refreshTs"` // 上次自动刷新时间 RefreshFreeNum int64 `json:"refreshFreeNum"` // 免费刷新次数 RefreshGoldNum int64 `json:"refreshGoldNum"` // 金币刷新次数 RefreshAdNum int64 `json:"refreshAdNum"` // 广告刷新次数 AdGoodsByNum map[int64]int64 `json:"adGoodsByNum"` // 广告位商品购买次数 Goods map[int64]*DailyGood `json:"goods"` // 商品列表 {槽位id:{}} } type DailyGood struct { AdId int64 `json:"adId"` // 广告点id。为0表示不是广告点需要用DailyGoodsId DailyGoodsId int64 `json:"dailyGoodsId"` // 商品id。与AdId不能同时存在 BuyNum int64 `json:"buyNum"` // 购买次数 } type StoreGeneralDetail struct { RefreshTs int64 `json:"refreshTs"` // 上次自动刷新时间 BuyGoods map[int64]int64 `json:"goods"` // 购买过的商品列表 {商品id:购买次数} } type PlayerStore struct { Id int64 PlayerId int64 `xorm:"BIGINT 'playerid'"` StoreDiscount *StoreGeneralDetail `xorm:"TEXT json 'storeDiscount'"` // 特惠商店商品购买信息 {礼包id:购买次数} StoreDaily *StoreDailyDetail `xorm:"TEXT json 'storeDaily'"` // 每日商店信息 {槽位id} StoreGold *StoreGeneralDetail `xorm:"TEXT json 'storeGold'"` StoreDiamond *StoreGeneralDetail `xorm:"TEXT json 'storeDiamond'"` StoreExchange *StoreGeneralDetail `xorm:"TEXT json 'storeExchange'"` PlayerLevel int64 `xorm:"BIGINT 'level'"` } func (m PlayerStore) TableName() string { return "player_store" } // 需要保存的数据需确保在这里能复制到new1 中 // // func (m *PlayerStore) DeepCopy() interface{} { // new1 := new(PlayerStore) // *new1 = *m // // return new1 // } func (m *PlayerStore) QueryExist(eng *xorm.Engine) (bool, error) { player := new(PlayerStore) player.PlayerId = m.PlayerId return eng.Exist(player) } func (m *PlayerStore) UpdateDB(eng *xorm.Engine) (int64, error) { return eng.Where("playerid=?", m.PlayerId).AllCols().Update(m) } func (m *PlayerStore) GetUniqueKey() string { return strconv.FormatInt(m.PlayerId, 10) } func CopyPlayerStore(old *PlayerStore) *PlayerStore { nu := deepcopy.MustCopy(old).(*PlayerStore) return nu } const ( PayTypeMoney = 1 //现金支付 PayTypeAd = 2 //广告获得 PayTypeItem = 3 //道具兑换 PayTypeFree = 4 //免费 ) // 玩家商城购买记录 //type PlayerShop struct { // Id int64 // PlayerId int64 `xorm:"BIGINT 'playerid'"` // Levels map[int64]struct{} `xorm:"VARCHAR(1000) 'levels'"` //} // 购买信息 //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 // 渠道组-AdChannel exported from 广告点.xlsx type AdChannel struct { Uid int64 `json:"Uid"` // 唯一编号 Name string `json:"Name"` // 渠道名称 Ad int64 `json:"Ad"` // 是否观看广告 0-无 1-有 } // 计费点-CDRP exported from 计费点.xlsx type CDRP struct { Uid int64 `json:"Uid"` // 编号 Name string `json:"Name"` // 名称 UseType int64 `json:"UseType"` // 服务器需要统计不同功能的限购次数,查找不同的功能点 功能类型 1:特惠商店-StoreDiscount 2:钻石商店-StoreDiamond 3:兑换商店-StoreExchange 4:7日礼包-Ac7DayGiftPack 5:每日特惠-AcDailyDeal 6:每日特惠价格-AcDailyDealPrice 7:首充-AcFirstCharge 8:幸运礼包-AcLuckGift 9:活动列表-ActivityList 10:月卡-MonthlyCard 11:特权卡-PrivilegeCard 12:战令配置-WarOrderValue PlatformPrice1 int64 `json:"PlatformPrice1"` // 微信平台 现价 PlatformPrice2 int64 `json:"PlatformPrice2"` // 抖音平台 现价 Include int64 `json:"Include"` // 是否计入(每日充值,循环充值)金额 0-不计入 1-计入 } const ( PlatNameWX = "wx" PlatNameTT = "tt" PlatNameH5 = "h5" ) func (c *CDRP) GetPrice(plat string) int64 { switch plat { case "wx": return c.PlatformPrice1 case "tt": return c.PlatformPrice2 default: return c.PlatformPrice1 } } //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,价格】 } // 特惠商店-StoreDiscount exported from 商店表.xlsx type StoreDiscount struct { Uid int64 `json:"Uid"` // ID UnlockLv []int64 `json:"UnlockLv"` // 解锁要求 0--不限 1--等级 2--关卡 Name string `json:"Name"` // 礼包名称 Content [][]int64 `json:"Content"` // 商品内容 【【道具ID,道具数量】】 Quota int64 `json:"Quota"` // 总限购次数 Discount float64 `json:"Discount"` // 折扣比例 显示用 Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费 CdrpId int64 `json:"CdrpId"` // 计费点 Video int64 `json:"Video"` // 广告点ID } // package model // 每日商店基础-StoreDailyBase exported from 商店表.xlsx type StoreDailyBase struct { ResetTime int64 `json:"ResetTime"` // 每日商店 刷新倒计时 /秒 FreeNum int64 `json:"FreeNum"` // 每日免费 刷新次数 GoldNum []int64 `json:"GoldNum"` // 金币刷新 【消耗数量,次数】 ADNum int64 `json:"ADNum"` // 广告刷新 次数 Video int64 `json:"Video"` // 广告点ID } // package model // 每日商店-StoreDaily exported from 商店表.xlsx type StoreDaily struct { Uid int64 `json:"Uid"` // ID Slot int64 `json:"Slot"` // 槽位ID Video int64 `json:"Video"` // 广告点ID VideoNum int64 `json:"VideoNum"` // 广告点次数 } // package model // 每日商店随机商品-StoreDailyGoods exported from 商店表.xlsx type StoreDailyGoods struct { Uid int64 `json:"Uid"` // 唯一编号 UnlockLv []int64 `json:"UnlockLv"` // 等级范围 Content []int64 `json:"Content"` // 商品内容 【道具ID,道具数量】 Quota int64 `json:"Quota"` // 限购次数 Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费 Discount float64 `json:"Discount"` // 折扣比例 显示用 Weight int64 `json:"Weight"` // 出现权重 } // package model func (t *StoreDailyGoods) GetWeight() int64 { return t.Weight } // 金币商店-StoreGold exported from 商店表.xlsx type StoreGold struct { Uid int64 `json:"Uid"` // ID Name string `json:"Name"` // 礼包名称 Content []int64 `json:"Content"` // 商品内容 【道具ID,道具数量】 Quota int64 `json:"Quota"` // 每日限购次数 Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费 CdrpId int64 `json:"CdrpId"` // 计费点 Video int64 `json:"Video"` // 广告点ID } // package model // 钻石商店-StoreDiamond exported from 商店表.xlsx type StoreDiamond struct { Uid int64 `json:"Uid"` // ID Name string `json:"Name"` // 礼包名称 Content []int64 `json:"Content"` // 商品内容 【道具ID,道具数量】 ExtraReward []int64 `json:"ExtraReward"` // 首次额外奖励 [道具类型,道具ID,道具数量] Quota int64 `json:"Quota"` // 每日限购次数 Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费 CdrpId int64 `json:"CdrpId"` // 计费点 Video int64 `json:"Video"` // 广告点ID } // package model // 兑换商店-StoreExchange exported from 商店表.xlsx type StoreExchange struct { Uid int64 `json:"Uid"` // ID Name string `json:"Name"` // 礼包名称 Content []int64 `json:"Content"` // 商品内容 【道具ID,道具数量】 Quota int64 `json:"Quota"` // 终身限购 每个账号可购买次数 Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费 CdrpId int64 `json:"CdrpId"` // 计费点 Video int64 `json:"Video"` // 广告点ID } // package model func GetCost(price []int64) (payType int64, cost []int64, err error) { num := len(price) if num == 0 { err = errors.New("no price") return } payType = price[0] switch payType { case PayTypeMoney: return case PayTypeAd: return case PayTypeItem: if num != 3 { err = errors.New("price error") return } cost = price[1:] case PayTypeFree: return } return }