Commit 2e283f60e01f7271b396f291e42ef44e191f26e4
1 parent
e8762443
月卡升级
Showing
3 changed files
with
56 additions
and
7 deletions
Show diff stats
src/GlobalVar.lua
| @@ -310,6 +310,8 @@ CardType = { | @@ -310,6 +310,8 @@ CardType = { | ||
| 310 | PaySignCard = 6, -- 付费签到卡 | 310 | PaySignCard = 6, -- 付费签到卡 |
| 311 | BattlePassCard = 7, -- 探索指令 | 311 | BattlePassCard = 7, -- 探索指令 |
| 312 | ActBattleCommandCard = 8, -- 战令活动卡 | 312 | ActBattleCommandCard = 8, -- 战令活动卡 |
| 313 | + NormalMonthCardLevelUp = 9, -- 月卡升级 | ||
| 314 | + SuperMonthCardLevelUp = 10, -- 超级月卡升级 | ||
| 313 | } | 315 | } |
| 314 | 316 | ||
| 315 | ShopPackType = { | 317 | ShopPackType = { |
src/models/Store.lua
| @@ -17,7 +17,9 @@ Store.schema = { | @@ -17,7 +17,9 @@ Store.schema = { | ||
| 17 | growFundR = {"string", ""}, -- 成长基金领取记录 | 17 | growFundR = {"string", ""}, -- 成长基金领取记录 |
| 18 | 18 | ||
| 19 | monthCardEx = {"number", 0}, -- 月卡过期时间戳 | 19 | monthCardEx = {"number", 0}, -- 月卡过期时间戳 |
| 20 | + monthCardId = {"number", 0}, -- 月卡id | ||
| 20 | smonthCardEx = {"number", 0}, -- 超级月卡过期时间戳 | 21 | smonthCardEx = {"number", 0}, -- 超级月卡过期时间戳 |
| 22 | + smonthCardId = {"number", 0}, -- 超级月卡id | ||
| 21 | 23 | ||
| 22 | battleCard = {"number", 0}, -- 赛季卡 | 24 | battleCard = {"number", 0}, -- 赛季卡 |
| 23 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 | 25 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 |
| @@ -51,7 +53,7 @@ function Store:updateProperty(params) | @@ -51,7 +53,7 @@ function Store:updateProperty(params) | ||
| 51 | return | 53 | return |
| 52 | end | 54 | end |
| 53 | local newValue = self:getProperty(params.field) | 55 | local newValue = self:getProperty(params.field) |
| 54 | - if not params.notNotify then | 56 | + if not params.notNotify then |
| 55 | self:notifyUpdateProperty(params.field, newValue, oldValue) | 57 | self:notifyUpdateProperty(params.field, newValue, oldValue) |
| 56 | end | 58 | end |
| 57 | end | 59 | end |
| @@ -77,13 +79,16 @@ end | @@ -77,13 +79,16 @@ end | ||
| 77 | -- 发送月卡邮件 | 79 | -- 发送月卡邮件 |
| 78 | function Store:sendMonthCardEmail() | 80 | function Store:sendMonthCardEmail() |
| 79 | local timeNow = skynet.timex() | 81 | local timeNow = skynet.timex() |
| 80 | - local tabs = {{ex="monthCardEx", t="getMailT1", mail=MailId.MonthCard, alert=MailId.MonthCardEx}, | ||
| 81 | - {ex="smonthCardEx", t="getMailT2", mail=MailId.SuperMonthCard, alert=MailId.SuperMonthCardEx}} | 82 | + |
| 83 | + local tabs = {{ex="monthCardEx", t="getMailT1", id= self:getProperty("monthCardId")}, | ||
| 84 | + {ex="smonthCardEx", t="getMailT2", id=self:getProperty("smonthCardId")}} | ||
| 82 | for _, v in ipairs(tabs) do | 85 | for _, v in ipairs(tabs) do |
| 83 | local ex = self:getProperty(v.ex) | 86 | local ex = self:getProperty(v.ex) |
| 84 | local ts = self:getProperty(v.t) or 0 | 87 | local ts = self:getProperty(v.t) or 0 |
| 85 | - local mailId = v.mail | ||
| 86 | - local alertId = v.alert | 88 | + local cfg = csvdb["shop_cardCsv"][v.id] or {} |
| 89 | + | ||
| 90 | + local mailId = cfg.email | ||
| 91 | + local alertId = cfg.email_2 | ||
| 87 | local alertTs = dayLater(ex) - DAY_SEC | 92 | local alertTs = dayLater(ex) - DAY_SEC |
| 88 | if ex > timeNow then | 93 | if ex > timeNow then |
| 89 | local cnt = 0 | 94 | local cnt = 0 |
| @@ -184,24 +189,64 @@ function Store:getHangDropCoef() | @@ -184,24 +189,64 @@ function Store:getHangDropCoef() | ||
| 184 | return (1 + globalCsv.hang_drop_exp_coef) or 1, (1 + globalCsv.hang_drop_item_coef) or 1 | 189 | return (1 + globalCsv.hang_drop_exp_coef) or 1, (1 + globalCsv.hang_drop_item_coef) or 1 |
| 185 | end | 190 | end |
| 186 | 191 | ||
| 192 | +function Store:getCurMonthCardLvl(isSuper) | ||
| 193 | + local id = 0 | ||
| 194 | + if isSuper then | ||
| 195 | + id = self:getProperty("smonthCardId") or 0 | ||
| 196 | + else | ||
| 197 | + id = self:getProperty("monthCardId") or 0 | ||
| 198 | + end | ||
| 199 | + local cfg = csvdb["shop_cardCsv"][id] | ||
| 200 | + if not cfg then return 0 end | ||
| 201 | + | ||
| 202 | + return cfg.level or 0 | ||
| 203 | +end | ||
| 187 | 204 | ||
| 188 | -- 购买通行证 | 205 | -- 购买通行证 |
| 189 | function Store:onBuyCard(type, duration, id, actid) | 206 | function Store:onBuyCard(type, duration, id, actid) |
| 190 | local timeNow = skynet.timex() | 207 | local timeNow = skynet.timex() |
| 191 | if type == CardType.NormalMonthCard then | 208 | if type == CardType.NormalMonthCard then |
| 192 | if self:isMonthCardExpire() then | 209 | if self:isMonthCardExpire() then |
| 210 | + self:updateProperty({field = "monthCardId", value = id}) | ||
| 193 | self:updateProperty({field = "monthCardEx", value = timeNow + duration}) | 211 | self:updateProperty({field = "monthCardEx", value = timeNow + duration}) |
| 194 | else | 212 | else |
| 195 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) | 213 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) |
| 196 | end | 214 | end |
| 197 | self:sendMonthCardEmail() | 215 | self:sendMonthCardEmail() |
| 216 | + elseif type == CardType.NormalMonthCardLevelUp then | ||
| 217 | + if self:isMonthCardExpire() then | ||
| 218 | + skynet.error(string.format("month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | ||
| 219 | + else | ||
| 220 | + local cfg = csvdb["shop_cardCsv"][id] | ||
| 221 | + if not cfg then return end | ||
| 222 | + if cfg.level - self:getCurMonthCardLvl() ~= 1 then | ||
| 223 | + return | ||
| 224 | + end | ||
| 225 | + self:updateProperty({field = "monthCardId", value = id}) | ||
| 226 | + self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) | ||
| 227 | + end | ||
| 228 | + self:sendMonthCardEmail() | ||
| 198 | elseif type == CardType.SuperMonthCard then | 229 | elseif type == CardType.SuperMonthCard then |
| 199 | if self:isSuperMonthCardExpire() then | 230 | if self:isSuperMonthCardExpire() then |
| 231 | + self:updateProperty({field = "smonthCardId", value = id}) | ||
| 200 | self:updateProperty({field = "smonthCardEx", value = timeNow + duration}) | 232 | self:updateProperty({field = "smonthCardEx", value = timeNow + duration}) |
| 201 | else | 233 | else |
| 202 | self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration}) | 234 | self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration}) |
| 203 | end | 235 | end |
| 204 | self:sendMonthCardEmail() | 236 | self:sendMonthCardEmail() |
| 237 | + elseif type == CardType.SuperMonthCardLevelUp then | ||
| 238 | + if self:isSuperMonthCardExpire() then | ||
| 239 | + skynet.error(string.format("super month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | ||
| 240 | + else | ||
| 241 | + local cfg = csvdb["shop_cardCsv"][id] | ||
| 242 | + if not cfg then return end | ||
| 243 | + if cfg.level - self:getCurMonthCardLvl() ~= 1 then | ||
| 244 | + return | ||
| 245 | + end | ||
| 246 | + self:updateProperty({field = "smonthCardId", value = id}) | ||
| 247 | + self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration}) | ||
| 248 | + end | ||
| 249 | + self:sendMonthCardEmail() | ||
| 205 | elseif type == CardType.PrivilegeCard then | 250 | elseif type == CardType.PrivilegeCard then |
| 206 | if self:isPrivCardExpire() then | 251 | if self:isPrivCardExpire() then |
| 207 | self:updateProperty({field = "privCardEx", value = timeNow + duration}) | 252 | self:updateProperty({field = "privCardEx", value = timeNow + duration}) |
| @@ -253,7 +298,7 @@ function Store:notifyUpdateProperty(field, newValue, oldValue) | @@ -253,7 +298,7 @@ function Store:notifyUpdateProperty(field, newValue, oldValue) | ||
| 253 | key = field, | 298 | key = field, |
| 254 | newValue = newValue, | 299 | newValue = newValue, |
| 255 | oldValue = oldValue, | 300 | oldValue = oldValue, |
| 256 | - } | 301 | + } |
| 257 | SendPacket(actionCodes.Store_updateproperty, MsgPack.pack(datas)) | 302 | SendPacket(actionCodes.Store_updateproperty, MsgPack.pack(datas)) |
| 258 | end | 303 | end |
| 259 | 304 | ||
| @@ -494,6 +539,8 @@ function Store:data() | @@ -494,6 +539,8 @@ function Store:data() | ||
| 494 | actGoodsFlag = self:getProperty("actGoodsFlag"), | 539 | actGoodsFlag = self:getProperty("actGoodsFlag"), |
| 495 | bpInfo = self:getProperty("bpInfo"), | 540 | bpInfo = self:getProperty("bpInfo"), |
| 496 | totalRR = self:getProperty("totalRR"), | 541 | totalRR = self:getProperty("totalRR"), |
| 542 | + monthCardId = self:getProperty("monthCardId"), | ||
| 543 | + smonthCardId = self:getProperty("smonthCardId"), | ||
| 497 | } | 544 | } |
| 498 | end | 545 | end |
| 499 | 546 |