activities.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. package model
  2. import (
  3. "leafstalk/otherutils/deepcopy"
  4. "strconv"
  5. "xorm.io/xorm"
  6. )
  7. const (
  8. AcRewardStatusUnavailable = 0 // 不可领取
  9. AcRewardStatusAvailable = 1 // 可领取
  10. AcRewardStatusClaimed = 2 // 已领取
  11. // 月卡类型
  12. MonthCardTypeFreeAd = 1 // 观影月卡
  13. MonthCardTypeSuper = 2 // 超值月卡
  14. MonthCardTypeDouble = 3 // 双月卡
  15. // 活跃战令增加积分
  16. WarOrderActivePointFastPatrol = 15 // 快速巡逻15分
  17. WarOrderActivePointPassMainSingle = 5 // 通关主线5分 todo
  18. WarOrderActivePointPassMainMulti = 80 // 通关精英80分 todo
  19. WarOrderActivePointPassCooperationGeneral = 150 // 通关合作模式普通150分 todo
  20. WarOrderActivePointPassCooperationDifficulty = 220 // 通关合作模式困难220分 todo
  21. WarOrderActivePointPassCooperationNightmare = 260 // 通关合作模式噩梦260分 todo
  22. WarOrderActivePointPassPVP = 200 // 竞技场200分 todo
  23. )
  24. type PlayerAc struct {
  25. Id int64
  26. PlayerId int64 `xorm:"BIGINT index 'playerid'"`
  27. // 活跃战令
  28. ActiveWarOrder *ActiveWarOrder `xorm:"TEXT json 'activeWarOrder'"`
  29. // 等级战令
  30. GradeWarOrder *GeneralWarOrder `xorm:"TEXT json 'gradeWarOrder'"`
  31. // 主线战令
  32. LineWarOrder *GeneralWarOrder `xorm:"TEXT json 'lineWarOrder'"`
  33. // 7日签到
  34. SevenDaySignIn *SevenDaySignInStatus `xorm:"TEXT json 'sevenDaySignIn'"`
  35. // 每日特惠
  36. DailyDeal *DailyDealStatus `xorm:"TEXT json 'dailyDeal'"`
  37. // 特惠礼包-新手礼包
  38. DiscountPack *DiscountPackStatus `xorm:"TEXT json 'discountPack'"`
  39. // 特惠礼包-每日礼包
  40. DiscountDayPack *DiscountPackStatus `xorm:"TEXT json 'discountDayPack'"`
  41. // 特惠礼包-每周礼包
  42. DiscountWeekPack *DiscountPackStatus `xorm:"TEXT json 'discountWeekPack'"`
  43. // 特惠礼包-每月礼包
  44. DiscountMoonPack *DiscountPackStatus `xorm:"TEXT json 'discountMoonPack'"`
  45. DailyRecharges []*DayRecharge `xorm:"TEXT json 'dailyRecharges'"`
  46. CycleRecharge *CycleRecharge `xorm:"TEXT json 'cycleRecharge'"`
  47. TriggerGifts map[int64]int64 `xorm:"TEXT json 'triggerGifts'"`
  48. GateId int64 `xorm:"-"`
  49. // 开服活动-首充
  50. FirstCharge map[int64]*FirstChargeStatus `xorm:"TEXT json 'firstCharge'"` // 计费点区分档位 {计费点Id:FirstChargeStatus{}}
  51. }
  52. type ActiveWarOrder struct {
  53. // 周期开始时间
  54. StartTs int64 `json:"startTs"`
  55. // 是否开通高级战令
  56. IsSenior bool `json:"isSenior"`
  57. // 是否开通豪华战令
  58. IsLuxury bool `json:"isLuxury"`
  59. // 看广告获得双倍积分计数
  60. AdCount int64 `json:"adCount"`
  61. // 看广告获得双倍积分标志
  62. AdDoubleFlag bool `json:"adDoubleFlag"`
  63. // 今日获得积分统计
  64. DayPointCount int64 `json:"dayCountPoint"`
  65. // 最后一次获取积分的时间
  66. LastPointTs int64 `json:"lastPointTs"`
  67. // 周期内积分总数
  68. PointTotal int64 `json:"totalPoint"`
  69. FreeLevel int64 `json:"freeLevel"` // 已领取的最大免费奖励等级
  70. SeniorLevel int64 `json:"seniorLevel"` // 已领取的最大高级奖励等级
  71. LuxuryLevel int64 `json:"luxuryLevel"` // 已领取的最大豪华奖励等级
  72. // 最后一次领取奖励的时间
  73. LastAwardTs int64 `json:"lastAwardTs"`
  74. }
  75. // 通用
  76. type GeneralWarOrder struct {
  77. IsSenior bool `json:"isSenior"` // 是否开通高级战令
  78. FreeLevel int64 `json:"freeLevel"` // 已领取的最大免费奖励等级
  79. SeniorLevel int64 `json:"seniorLevel"` // 已领取的最大高级奖励等级
  80. }
  81. // 7日签到状态
  82. type SevenDaySignInStatus struct {
  83. // 当日活跃度
  84. DayActive int64 `json:"dayActive"`
  85. // 最后一次获取活跃度的时间
  86. LastActiveTs int64 `json:"lastActiveTs"`
  87. // 奖励状态
  88. Award map[int64]*SignInAwardStatus `json:"award"`
  89. // 最后一次签到时间
  90. LastSignInTs int64 `json:"lastSignInTs"`
  91. }
  92. // 签到奖励领取状态
  93. type SignInAwardStatus struct {
  94. Free int64 `json:"free"`
  95. Active int64 `json:"active"`
  96. }
  97. // 每日特惠
  98. type DailyDealStatus struct {
  99. // 每日特惠刷新时间
  100. RefreshTs int64 `json:"refreshTs"`
  101. // {Uid:周期内购买次数}
  102. BuyStatus map[int64]int64 `json:"buyStatus"`
  103. }
  104. // 特惠礼包
  105. type DiscountPackStatus struct {
  106. // 刷新时间
  107. RefreshTs int64 `json:"refreshTs"`
  108. // {Uid:周期内购买次数}
  109. BuyStatus map[int64]int64 `json:"buyStatus"`
  110. }
  111. // 每日充值
  112. type DayRecharge struct {
  113. Level int64 `json:"level"` // 档位
  114. Cycle int64 `json:"cycle"` // 总轮数
  115. OpenDaySum int64 `json:"openDay"` // 开放的天数
  116. ProcessReward int64 `json:"prcsReward"` // 领取的进度奖励
  117. LastTs int64 `json:"lastTs"` // 最后一次充值时间
  118. LastRecharge int64 `json:"recharge"` // 最后一天充值金额
  119. DayReward int64 `json:"dayReward"` // 领取的日奖励
  120. }
  121. // 任务完成的天数
  122. func (dr *DayRecharge) GetTaskSucessDay() int64 {
  123. if dr.LastRecharge >= dr.Level {
  124. return dr.OpenDaySum
  125. }
  126. return dr.OpenDaySum - 1
  127. }
  128. // 循环充值
  129. type CycleRecharge struct {
  130. Sum int64 `json:"sum"` // 总充值钻石数
  131. Num int64 `json:"num"` // 本轮累计充值钻石数
  132. Reward int64 `json:"reward"` // 领取的最后一个奖励的档位
  133. }
  134. // 首充
  135. type FirstChargeStatus struct {
  136. // 购买时间
  137. BuyTs int64 `json:"buyTs"`
  138. // 已领取奖励的最后一个天数
  139. Reward int64 `json:"reward"`
  140. }
  141. func (m PlayerAc) TableName() string {
  142. return "player_ac"
  143. }
  144. func (m *PlayerAc) QueryExist(eng *xorm.Engine) (bool, error) {
  145. player := new(PlayerAc)
  146. player.PlayerId = m.PlayerId
  147. return eng.Exist(player)
  148. }
  149. func (m *PlayerAc) UpdateDB(eng *xorm.Engine) (int64, error) {
  150. return eng.Where("playerid=?", m.PlayerId).AllCols().Update(m)
  151. }
  152. func (m *PlayerAc) GetUniqueKey() string {
  153. return strconv.FormatInt(m.PlayerId, 10)
  154. }
  155. func CopyPlayerAc(old *PlayerAc) *PlayerAc {
  156. nu := deepcopy.MustCopy(old).(*PlayerAc)
  157. return nu
  158. }
  159. func (m *PlayerAc) GetDailyRecharge(level int64) *DayRecharge {
  160. for _, v := range m.DailyRecharges {
  161. if v.Level == level {
  162. return v
  163. }
  164. }
  165. return nil
  166. }
  167. // 活跃战令-WarOrderActive exported from 活动-战令.xlsx
  168. type WarOrderActive struct {
  169. Lv int64 `json:"Lv"` // 等级
  170. Exp int64 `json:"Exp"` // 升级经验
  171. FreeFile [][]int64 `json:"FreeFile"` // 免费战令
  172. SeniorFile [][]int64 `json:"SeniorFile"` // 高级战令
  173. IuxuriousFile [][]int64 `json:"IuxuriousFile"` // 豪华战令
  174. } // package model
  175. // 等级战令-WarOrderGrade exported from 活动-战令.xlsx
  176. type WarOrderGrade struct {
  177. Lv int64 `json:"Lv"` // 玩家等级
  178. FreeFile [][]int64 `json:"FreeFile"` // 免费奖励
  179. SeniorFile [][]int64 `json:"SeniorFile"` // 高级奖励
  180. } // package model
  181. // 主线战令-WarOrderLine exported from 活动-战令.xlsx
  182. type WarOrderLine struct {
  183. Lv int64 `json:"Lv"` // 通过主线ID 关联关卡表ID
  184. FreeFile [][]int64 `json:"FreeFile"` // 免费奖励
  185. SeniorFile [][]int64 `json:"SeniorFile"` // 高级奖励
  186. } // package model
  187. // 战令配置-WarOrderValue exported from 活动-战令.xlsx
  188. type WarOrderValue struct {
  189. Uid int64 `json:"Uid"` // ID
  190. PriceId int64 `json:"PriceId"` // 参数
  191. }
  192. // 7日签到-SevenDaySignIn exported from 活动-签到.xlsx
  193. type SevenDaySignIn struct {
  194. Uid int64 `json:"Uid"` // ID
  195. Days int64 `json:"Days"` // 天数
  196. Reward [][]int64 `json:"Reward"` // 奖励
  197. }
  198. // 签到双倍-SevenDaySignInDouble exported from 活动-7日签到.xlsx
  199. type SevenDaySignInDouble struct {
  200. Condition int64 `json:"Condition"` // 签到奖励再次领取要求 (日常任务活跃度)
  201. }
  202. // 月卡-MonthlyCard exported from 活动-月卡.xlsx
  203. type MonthlyCard struct {
  204. Type int64 `json:"Type"` // 月卡类型 1--观影月卡 2--超值月卡 3---双月卡特权
  205. NoAd int64 `json:"NoAd"` // 免广告 0--无特权 1-有特权
  206. InfinitePatrol int64 `json:"InfinitePatrol"` // 无限快速巡逻 0--无特权 1-有特权
  207. BrawnUp int64 `json:"BrawnUp"` // 体力上限 0--无特权 数值-增加上限
  208. EnergyUp int64 `json:"EnergyUp"` // 精力上限 0--无特权 数值-增加上限
  209. BrawnNum int64 `json:"BrawnNum"` // 每日体力购买次数 0--无特权 数值-增加上限
  210. EnergyNum int64 `json:"EnergyNum"` // 每日精力购买次数 0--无特权 数值-增加上限
  211. BrawnreStore float64 `json:"BrawnreStore"` // 体力恢复速度 百分比值 0--无特权 数值-增加上限
  212. Speed int64 `json:"Speed"` // 主线关卡开启3倍速 0--无特权 1-有特权
  213. ActivationReward []int64 `json:"ActivationReward"` // 激活奖励
  214. Reward [][]int64 `json:"Reward"` // 每日奖励
  215. Price int64 `json:"Price"` // 计费点ID
  216. } // package model
  217. // 特权卡-PrivilegeCard exported from 活动-月卡.xlsx
  218. type PrivilegeCard struct {
  219. Type int64 `json:"Type"` // 月卡类型 1--永久钻石卡 2--永久巡逻卡
  220. NoAd int64 `json:"NoAd"` // 巡逻钻石基础产出 0--无 数值-增加上限(数量/时)
  221. InfinitePatrol int64 `json:"InfinitePatrol"` // 快速点数 0--无 数值-增加上限
  222. BrawnUp int64 `json:"BrawnUp"` // 快速时长增加值 0--无 数值-增加上限
  223. Price int64 `json:"Price"` // 计费点ID
  224. } // package model
  225. // 月卡福利-MonthlyCardBenefit exported from 活动-月卡.xlsx
  226. type MonthlyCardBenefit struct {
  227. Reward [][]int64 `json:"Reward"` // 奖励
  228. }
  229. const (
  230. DailyDealFree = 1 // 免费
  231. DailyDeal6Yuan = 2 // 6元礼包
  232. DailyDeal12Yuan = 3 // 12元礼包
  233. DailyDeal18Yuan = 4 // 18元礼包
  234. DailyDealLucky = 5 // 特惠专属福袋
  235. )
  236. // 每日特惠-DailyDeal exported from 活动-每日特惠.xlsx
  237. type DailyDeal struct {
  238. Uid int64 `json:"Uid"` // ID
  239. Name string `json:"Name"` // 名称
  240. GiftPack [][]int64 `json:"GiftPack"` // 礼包
  241. Quota int64 `json:"Quota"` // 每日限购次数
  242. Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费
  243. PriceId int64 `json:"PriceId"` // 价格挡位 关联计费点CDRP中ID
  244. Video int64 `json:"Video"` // 广告点ID
  245. } // package model
  246. // 特惠价格-DailyDealPrice exported from 活动-每日特惠.xlsx
  247. type DailyDealPrice struct {
  248. Uid int64 `json:"Uid"` // ID
  249. Name string `json:"Name"` // 名称
  250. Quota int64 `json:"Quota"` // 每日限购次数
  251. PriceId int64 `json:"PriceId"` // 价格挡位 关联计费点CDRP中ID
  252. }
  253. // 新手特惠礼包-DiscountPack exported from 活动-特惠礼包.xlsx
  254. type DiscountPack struct {
  255. Uid int64 `json:"Uid"` // ID
  256. Name string `json:"Name"` // 名称
  257. GiftPack []int64 `json:"GiftPack"` // 礼包
  258. Quota int64 `json:"Quota"` // 限购次数 终身限购
  259. Discount float64 `json:"Discount"` // 折扣 用于前端界面显示(百分比值)
  260. Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费
  261. CdrpId int64 `json:"CdrpId"` // 计费点
  262. Video int64 `json:"Video"` // 广告点ID
  263. } // package model
  264. // 每日特惠礼包-DiscountDayPack exported from 活动-特惠礼包.xlsx
  265. type DiscountDayPack struct {
  266. Uid int64 `json:"Uid"` // ID
  267. Name string `json:"Name"` // 名称
  268. GiftPack []int64 `json:"GiftPack"` // 礼包
  269. Quota int64 `json:"Quota"` // 限购次数 每日0点重置
  270. Discount float64 `json:"Discount"` // 折扣 用于前端界面显示(百分比值)
  271. Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费
  272. CdrpId int64 `json:"CdrpId"` // 计费点
  273. Video int64 `json:"Video"` // 广告点ID
  274. } // package model
  275. // 每周特惠礼包-DiscountWeekPack exported from 活动-特惠礼包.xlsx
  276. type DiscountWeekPack struct {
  277. Uid int64 `json:"Uid"` // ID
  278. Name string `json:"Name"` // 名称
  279. GiftPack []int64 `json:"GiftPack"` // 礼包
  280. Quota int64 `json:"Quota"` // 限购次数 每周一0点重置
  281. Discount float64 `json:"Discount"` // 折扣 用于前端界面显示(百分比值)
  282. Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费
  283. CdrpId int64 `json:"CdrpId"` // 计费点
  284. Video int64 `json:"Video"` // 广告点ID
  285. } // package model
  286. // 每月特惠礼包-DiscountMoonPack exported from 活动-特惠礼包.xlsx
  287. type DiscountMoonPack struct {
  288. Uid int64 `json:"Uid"` // ID
  289. Name string `json:"Name"` // 名称
  290. GiftPack []int64 `json:"GiftPack"` // 礼包
  291. Quota int64 `json:"Quota"` // 限购次数 每月1号0点重置
  292. Discount float64 `json:"Discount"` // 折扣 用于前端界面显示(百分比值)
  293. Price []int64 `json:"Price"` // 价格 [支付方式,道具ID,数量] 1-现金 2-广告 3-道具 4-免费
  294. CdrpId int64 `json:"CdrpId"` // 计费点
  295. Video int64 `json:"Video"` // 广告点ID
  296. }
  297. // 首充-FirstCharge exported from 活动-首充.xlsx
  298. type FirstCharge struct {
  299. Uid int64 `json:"Uid"` // ID
  300. PriceId int64 `json:"PriceId"` // 价格挡位 关联计费点CDRP中ID
  301. Day int64 `json:"Day"` // 天数
  302. Reward [][]int64 `json:"Reward"` // 奖励
  303. }