shop.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. package model
  2. import (
  3. "errors"
  4. "leafstalk/otherutils/deepcopy"
  5. "time"
  6. "xorm.io/xorm"
  7. )
  8. const (
  9. PayTypeMoney = 1 //现金支付
  10. PayTypeAd = 2 //广告获得
  11. PayTypeItem = 3 //道具兑换
  12. PayTypeFree = 4 //免费
  13. )
  14. // 购买信息
  15. type WxPayPlayer struct {
  16. Id int64
  17. PlayerID int64 `xorm:"BIGINT 'playerid'"`
  18. Buys map[int64]*PeriodBuys `xorm:"BIGINT 'buys'"`
  19. Refreshs map[int64]*RefreshGoods `xorm:"varchar(255) json 'refresh'"`
  20. // LevelGoods map[int64]struct{} `xorm:"TEXT 'lvGoods'"`
  21. // DailyGoods *RefreshBuys `xorm:"TEXT json'dailys'"`
  22. // CoinGoods *PeriodBuys `xorm:"TEXT json 'coins'"`
  23. // DiamondGoods map[int64]int `xorm:"TEXT json 'diamonds'"`
  24. // BuyStatis map[int64]uint `xorm:"TEXT 'buyStatis'"`
  25. // NewerBox map[int64]int `xorm:"TEXT json 'orderBox'"`
  26. // VipGoods []*LastBuyItem `xorm:"TEXT 'vipGoods'"`
  27. // DailyDiscount *TickBuys `xorm:"TEXT json 'dailyDiscount'"`
  28. // RoleGift *RoleGiftBuys `xorm:"TEXT json 'roleGift'"`
  29. // Invite *InviteGift `xorm:"TEXT json 'invite'"`
  30. // AccPay *AccPayGift `xorm:"TEXT json 'accPay'"`
  31. // Balance int `xorm:"int 'balance'"`
  32. // LuckDraw *PlayerLuckDraw `xorm:"TEXT json 'luckDraw'"`
  33. // Growth *GrowthGift `xorm:"TEXT json 'growth'"`
  34. // BoxKeyGift *TickBuys2 `xorm:"TEXT json 'boxKeyGift'"` // 装备钥匙礼包
  35. // NewYearGift *TickBuys2 `xorm:"TEXT json 'newYearGift'"`
  36. // Fifteen *TickBuys2 `xorm:"TEXT json 'fifteen'"` // NewFifteen *TickBuys2 `xorm:"TEXT json 'newFifteen'"`
  37. // TombSweep *TickBuys2 `xorm:"TEXT json 'tombSweep'"`
  38. // Lady38 *TickBuys2 `xorm:"TEXT json 'lady38'"`
  39. // SpecialGift *SpecialGift `xorm:"TEXT json 'specialGift'"`
  40. // RichManGift *TickBuys2 `xorm:"TEXT json 'richMan'"` // 51劳动节
  41. // DragonBoat *TickBuys2 `xorm:"TEXT json 'dragonBoat'"` // 端午节
  42. // WeekendGift *TickBuys `xorm:"TEXT json 'weekendGift'"` // 周末礼包
  43. // QiXiGift *TickBuys2 `xorm:"TEXT json 'qiXiGift'"` // 七夕礼包
  44. // MoonFestivalGift *TickBuys2 `xorm:"TEXT json 'moonFestivalGift'"` // 中秋礼包
  45. // YuanDanGift *TickBuys2 `xorm:"TEXT json 'yuanDanGift'"` // 元旦礼包
  46. // ReturneGift *ReturneTickBuys `xorm:"TEXT json 'returneGift'"` // 回归礼包
  47. // EndLessPass *EndLessPassGift `xorm:"TEXT json 'endLessPassGift'"` // 无尽通行证
  48. // PuzzlePass *PuzzlePassGift `xorm:"TEXT json 'puzzlePassGift'"` // 拼图通行证
  49. // WinterJonesPass *PuzzlePassGift `xorm:"TEXT json 'winterjonesPassGift'"` // 冬日夺宝通行证
  50. // AccCostDiamond *AccCostDiamond `xorm:"TEXT json 'accCostDiamond'"` // 累计花费钻石
  51. // NewServerAct *NewServerActTickBuys `xorm:"TEXT json 'newServerAct'"` // 新服活动
  52. // NewerBox2 *NewerBox2 `xorm:"TEXT json 'orderBox2'"` //
  53. // ChanceBoxGift *GiftInfo `xorm:"TEXT json 'chanceBoxGift'"` // 机缘宝盒
  54. // NationalGift *TickBuys2 `xorm:"TEXT json 'nationalGift'"` // 国庆礼包
  55. // Holiday12Gift *TickBuys2 `xorm:"TEXT json 'holiday12Gift'"` // 双11礼包
  56. // MonarchGift *MonarchGift `xorm:"TEXT json 'monarchGift'"` // 魔君赠送
  57. // MasterPass *MasterPassGift `xorm:"TEXT json 'masterPassGift'"` // 最强王者通行证
  58. // RichManPass *RichManPassGift `xorm:"TEXT json 'richManPassGift'"` // 51通行证
  59. OpenId string `xorm:"-"`
  60. // GdtVid string `xorm:"-"`
  61. // Friends []int64 `xorm:"-"`
  62. // GateId int `xorm:"-"`
  63. // RecentPayedOrders []string `xorm:"-"` //最近支付订单 不用保存太多,最多50笔
  64. }
  65. type PeriodBuys struct {
  66. // Id int64 `json:"id"`
  67. Ts int64 `json:"ts"` //最后购买时间
  68. Count int64 `json:"count"` //周期
  69. Total int64 `json:"total"` //总
  70. }
  71. type RefreshGoods struct {
  72. Ts int64 `json:"ts"` //刷新时间
  73. Count int64 `json:"count"` //刷新次数
  74. Goods []int64 `json:"goods"` //商品ID列表
  75. }
  76. type PeriodBuysItem struct {
  77. Num int `json:"num"`
  78. Ts int64 `json:"ts"` //当前商品购买时间,计算CD用
  79. }
  80. // TickBuysTick
  81. // 统计周期内购买商品及数量
  82. type PeriodBuys2 struct {
  83. Ts int64 `json:"ts"` //周期开始时间
  84. Buys map[int64]*PeriodBuysItem `json:"buys"`
  85. }
  86. type RefreshBuys struct {
  87. Ts int64 `json:"ts"` //周期开始时间
  88. RefreshCount int64 `json:"refresh"` //刷新次数
  89. Goods []int64 `json:"goods"` //商品ID列表
  90. Buys map[int64]int `json:"buys"` //购买次数
  91. }
  92. // StoreGoods
  93. // 商店表-Store exported from 商店表.xlsx
  94. type StoreGoods struct {
  95. Id int64 `json:"Uid"` // ID
  96. GoodsType int64 `json:"GoodsType"` // 商店类型 1--等级商店 2--每日商店 3--金币商店 4--钻石商店
  97. UnlockLv int64 `json:"UnlockLv"` // 解锁要求 0--不限 1--等级 2--关卡
  98. Name string `json:"Name"` // 礼包名称
  99. Content [][]int64 `json:"Content"` // 商品内容
  100. RandomGroup int64 `json:"RandomGroup"` // 随机组
  101. Weight int64 `json:"Weight"` // 刷新权重 -1--必出 0--不出
  102. Quota []int64 `json:"Quota"` // 限购次数 0--不限 1--每日 2--每周 3--总限 4--日刷新
  103. Discount float64 `json:"Discount"` // 折扣比例 显示用
  104. Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费
  105. CdrpId int64 `json:"CdrpId"` // 计费点
  106. Video int64 `json:"Video"` // 广告点ID
  107. }
  108. func (sg *StoreGoods) GetWeight() int64 {
  109. return sg.Weight
  110. }
  111. func (sg *StoreGoods) GetId() int64 {
  112. return sg.Id
  113. }
  114. func (sg *StoreGoods) GetCost() (payType int64, cost []int64, err error) {
  115. num := len(sg.Price)
  116. if num == 0 {
  117. err = errors.New("no price")
  118. return
  119. }
  120. payType = sg.Price[0]
  121. switch payType {
  122. case PayTypeMoney:
  123. return
  124. case PayTypeAd:
  125. return
  126. case PayTypeItem:
  127. if num != 3 {
  128. err = errors.New("price error")
  129. return
  130. }
  131. cost = sg.Price[1:]
  132. case PayTypeFree:
  133. return
  134. }
  135. return
  136. }
  137. // 商店刷新-StoreRefresh exported from 商店表.xlsx
  138. type StoreRefresh struct {
  139. Uid int64 `json:"Uid"` // ID
  140. RandomGroup int64 `json:"RandomGroup"` // 随机组
  141. RefreshTime int64 `json:"RefreshTime"` // 刷新次数 0--表示无
  142. RefreshNum int64 `json:"RefreshNum"` // 刷新数量
  143. Price [][]int64 `json:"Price"` // 每次刷新消耗 [方式,具ID,数量] 3-道具 4-免费
  144. }
  145. // 广告点配置-AdList exported from 广告点.xlsx
  146. type AdList struct {
  147. Uid int64 `json:"Uid"` // 广告点唯一编号 其它地方统一调用此编号
  148. Name string `json:"Name"` // 广告点名字
  149. CD int64 `json:"CD"` // 冷却时间 /秒
  150. AdReward [][]int64 `json:"AdReward"` // 有广告时奖励 【【道具类型,道具ID,道具数量】】 【0】:无奖励/功能类广告
  151. NormalReward [][]int64 `json:"NormalReward"` // 无广告时奖励 【】:不填则入口消失 【【道具类型,道具ID,道具数量】】 【0】:无奖励/功能类广告
  152. } // package model
  153. // 渠道组-Channel exported from 广告点.xlsx
  154. type Channel struct {
  155. Uid int64 `json:"Uid"` // 唯一编号
  156. Name string `json:"Name"` // 渠道名称
  157. Channel int64 `json:"Channel"` // 是否观看广告 0-无 1-有
  158. }
  159. // 计费点-CDRP exported from 计费点.xlsx
  160. type CDRP struct {
  161. Uid int64 `json:"Uid"` // 编号
  162. Name string `json:"Name"` // 名称
  163. Content []int64 `json:"Content"` // 奖励 [[道具类型,道具ID,道具数量]]
  164. FirstReward []int64 `json:"FirstReward"` // 首次额外奖励 [[道具类型,道具ID,道具数量]]
  165. Discount float64 `json:"Discount"` // 折扣比例 显示用
  166. PlatformPrice1 int64 `json:"PlatformPrice1"` // 微信平台 现价
  167. PlatformPrice2 int64 `json:"PlatformPrice2"` // 抖音平台 现价
  168. }
  169. type VirtualPayOrder struct {
  170. Id int64
  171. PlayerID int64 `xorm:"BIGINT index 'playerid'"`
  172. OrderId string `xorm:"varchar(255) index 'orderId'"`
  173. Price int64 `xorm:"BIGINT 'price'"`
  174. State int `xorm:"int 'state'"`
  175. GoodsId int64 `xorm:"BIGINT 'goodsId'"` // 购买物品
  176. Platform int `xorm:"BIGINT 'platform'"` //平台 1:微信 2:抖音
  177. PayMethod int `xorm:"int 'payMethod'"` //支付方式 //0:苹果游戏外微信支付 1:安卓游戏内支付 2:安卓游戏外微信支付 3:苹果游戏内支付
  178. Balance int `xorm:"int 'balance'"` //游戏币个数(包含赠送)
  179. GenBalance int `xorm:"int 'genBalance'"` //赠送游戏币数量(赠送游戏币数量
  180. SaveSum int `xorm:"int 'saveSum'"` //历史总游戏币金额
  181. SaveAmt int `xorm:"int 'saveAmt'"` //累计充值金额的游戏币数量
  182. CostSum int `xorm:"int 'costSum'"` //历史总消费游戏币金额
  183. PresentSum int `xorm:"int 'presentSum'"` //历史累计收到赠送金额
  184. Operation string `xorm:"varchar(255) 'operation'"`
  185. BillNo string `xorm:"varchar(255) 'billNo'"`
  186. PayedBalance int `xorm:"int 'payedBalance'"` //预扣后的余额
  187. UsedGenAmt int `xorm:"int 'usedGenAmt'"` //本次扣的赠送币的金额
  188. CreateTime time.Time `xorm:"created"`
  189. }
  190. func (m VirtualPayOrder) TableName() string {
  191. return "virtualpayorder"
  192. }
  193. func (m *VirtualPayOrder) QueryExist(eng *xorm.Engine) (bool, error) {
  194. q := new(VirtualPayOrder)
  195. //q.PlayerID = m.PlayerID
  196. q.BillNo = m.BillNo
  197. return eng.Exist(q)
  198. }
  199. // 不许修改
  200. func (m *VirtualPayOrder) UpdateDB(eng *xorm.Engine) (int64, error) {
  201. //return eng.Where("playerid=?", m.PlayerID).Update(m)
  202. return 0, nil
  203. }
  204. func (m *VirtualPayOrder) GetUniqueKey() string {
  205. return m.BillNo
  206. }
  207. func CopyVirtualPayOrder(old *VirtualPayOrder) *VirtualPayOrder {
  208. new1, err := deepcopy.Copy(old) //.(*VirtualPayOrder) //new(VirtualPayOrder)
  209. if err != nil {
  210. return nil
  211. }
  212. // *new1 = *old
  213. return new1.(*VirtualPayOrder)
  214. }
  215. // 商品价格表-StoreItem exported from 商店表.xlsx
  216. type StoreItem struct {
  217. ItemId int64 `json:"ItemId"` // 道具ID
  218. Price []int64 `json:"Price"` // 购买价格 【道具ID,价格】
  219. }