Commit fb3d084dbe61baecc5d20fa5c223d52c9aeb50e1

Authored by liuzujun
1 parent 1a0b3c56

月卡赛季卡发送邮件奖励

src/GlobalVar.lua
... ... @@ -2,6 +2,7 @@ XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18"
2 2 RESET_TIME = 0
3 3  
4 4 START_RESET_TIME_BASE = 1584316800 -- 0时区
  5 +DAY_SEC = 86400
5 6 TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区
6 7  
7 8 START_RESET_TIME = START_RESET_TIME_BASE - TIME_ZONE * 3600
... ...
src/actions/GmAction.lua
... ... @@ -512,12 +512,11 @@ function _M.helpRpc(agent, data)
512 512 return true
513 513 end
514 514  
515   -table.insert(helpDes, {"测试", "test", ""})
516 515 function _M.test(role, pms)
517 516 local id = tonum(pms.pm1, 0)
518 517 --local hero = require ("actions.HeroAction")
519 518 --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id}))
520   - role.storeData:resetStoreReored(id)
  519 + role.storeData:resetStoreReored(21)
521 520 return "成功"
522 521 end
523 522  
... ...
src/actions/HeroAction.lua
... ... @@ -1070,10 +1070,11 @@ function _M.repayHeroRpc(agent, data)
1070 1070 local role = agent.role
1071 1071  
1072 1072 local repayHero = role:getProperty("repayHero")
1073   - if repayHero < globalCsv.draw_free_count then
  1073 + local cnt = globalCsv.draw_times_to_get_ssr or 100
  1074 + if repayHero < cnt then
1074 1075 return
1075 1076 end
1076   - local result = repayHero - globalCsv.draw_free_count
  1077 + local result = repayHero - cnt
1077 1078  
1078 1079 role:updateProperty({field = "repayHero", value = result})
1079 1080 local id = math.randWeight(csvdb["build_giftCsv"], "pool_1")
... ... @@ -1113,7 +1114,7 @@ function _M.unlockPoolRpc(agent, data)
1113 1114 end
1114 1115  
1115 1116 if needCost then
1116   - if not role:costDiamond({count = 300, log = {desc = "unlockPool", short1 = type}}) then
  1117 + if not role:costDiamond({count = globalCsv.draw_unlock_pool_diamond or 300, log = {desc = "unlockPool", short1 = type}}) then
1117 1118 return
1118 1119 end
1119 1120 end
... ...
src/actions/StoreAction.lua
... ... @@ -371,7 +371,7 @@ function _M.getBattlePassRewardRpc(agent, data)
371 371 if not config then return end
372 372  
373 373 local timeNow = skynet.timex()
374   - local battleCardExTs = role.storeData:getProperty("battleCardEx")
  374 + local battleCardFlag = role.storeData:getProperty("battleCard")
375 375 local battleCardFreeRecord = role.storeData:getProperty("battleFR")
376 376 local battleCardLimitRecord = role.storeData:getProperty("battleLR")
377 377  
... ... @@ -383,11 +383,11 @@ function _M.getBattlePassRewardRpc(agent, data)
383 383 return 1
384 384 end
385 385  
386   - if battleCardExTs < timeNow and freeFlag == "1" then
  386 + if battleCardFlag == 1 and limitFlag == "1" then
387 387 return 1
388 388 end
389 389  
390   - if role:getProperty("battlePoint") < config.condition then
  390 + if role:getProperty("battlePoint") < config.point then
391 391 skynet.error(string.format("user do not have enough battle point, user_id:%d", role:getProperty("id")))
392 392 return 1
393 393 end
... ... @@ -400,14 +400,14 @@ function _M.getBattlePassRewardRpc(agent, data)
400 400 role.storeData:updateProperty({field = "battleFR", value = battleCardFreeRecord})
401 401 end
402 402  
403   - if battleCardExTs > timeNow and limitFlag == "0" then
  403 + if battleCardFlag == 1 and limitFlag == "0" then
404 404 if gift ~= "" then
405 405 gift = gift .. " "
406 406 end
407 407 gift = gift .. config.giftLimit
408 408  
409 409 battleCardLimitRecord = string.setbit(battleCardLimitRecord, id)
410   - role.storeData:updateProperty({field = "battleFR", value = battleCardLimitRecord})
  410 + role.storeData:updateProperty({field = "battleLR", value = battleCardLimitRecord})
411 411 end
412 412  
413 413 local reward, _ = role:award(gift, {log = {desc = "battleCard", int1 = id}})
... ...
1   -Subproject commit 12409daded138b2934c0741b15b2e0de305bb109
  1 +Subproject commit 1cad049d6adc4948e9ff001acc64529e05e8acb6
... ...
src/models/Role.lua
... ... @@ -27,6 +27,7 @@ function Role:ctor( properties )
27 27 self.activity = nil
28 28 self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节
29 29 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳
  30 + self.sendMailFlag = false --发送邮件标识
30 31 end
31 32  
32 33 Role.schema = {
... ... @@ -147,7 +148,7 @@ Role.schema = {
147 148  
148 149 emailSync = {"number", 0}, -- 已经同步到的邮件Id
149 150  
150   - repayHero = {"number", 0}, -- 超级招募 回馈
  151 + repayHero = {"number", 0}, -- 招募次数 (除去友情招募)
151 152 floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count}
152 153 ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count}
153 154 newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr
... ... @@ -365,7 +366,7 @@ function Role:data()
365 366 battlePoint = self:getProperty("battlePoint"),
366 367  
367 368 rmbC = self:getProperty("rmbC"),
368   - -- repayHero = self:getProperty("repayHero"),
  369 + repayHero = self:getProperty("repayHero"),
369 370 newerDraw = self:getProperty("newerDraw"),
370 371 floorHero = self:getProperty("floorHero"),
371 372  
... ...
src/models/RolePlugin.lua
... ... @@ -1343,9 +1343,13 @@ function RolePlugin.bind(Role)
1343 1343 self:checkNewEvent(now)
1344 1344 end
1345 1345  
1346   - local function breath(sec)
  1346 + local function breath(sec, name)
1347 1347 local last_breath = 0
1348   - return function (now)
  1348 + return function (now, role)
  1349 + if name == "email" and role.sendMailFlag then
  1350 + last_breath = now + sec
  1351 + return true
  1352 + end
1349 1353 if now >= last_breath then
1350 1354 last_breath = now + sec
1351 1355 return true
... ... @@ -1354,8 +1358,8 @@ function RolePlugin.bind(Role)
1354 1358 end
1355 1359 end
1356 1360 local breathes = {
1357   - ["email"] = breath(120), -- email
1358   - ["pvphg"] = breath(300), -- 高级竞技场 奖励满的红点
  1361 + ["email"] = breath(120, "email"), -- email
  1362 + ["pvphg"] = breath(300, "pvphg"), -- 高级竞技场 奖励满的红点
1359 1363 }
1360 1364 function Role:checkNewEvent(now)
1361 1365 if now - self:getProperty("ltime") < 5 then
... ... @@ -1398,6 +1402,7 @@ function RolePlugin.bind(Role)
1398 1402 end)
1399 1403 for index, id in ipairs(emailIds) do
1400 1404 if tonumber(redret[index]) == 0 then
  1405 + self.SendMailFlag = false
1401 1406 return true
1402 1407 end
1403 1408 end
... ... @@ -1420,7 +1425,7 @@ function RolePlugin.bind(Role)
1420 1425  
1421 1426 local events = {}
1422 1427 for name, breath in pairs(breathes) do
1423   - if breath(now) and checks[name] then
  1428 + if breath(now, self) and checks[name] then
1424 1429 local status = checks[name]()
1425 1430 if status then
1426 1431 if status == true then
... ... @@ -1576,6 +1581,24 @@ function RolePlugin.bind(Role)
1576 1581 return reward
1577 1582 end
1578 1583  
  1584 + --直接给玩家发送邮件,立即推送小红点
  1585 + function Role:sendMail(mailId, createTime, reward)
  1586 + local tgift = {}
  1587 + if type(reward) == "string" then
  1588 + for _, one in pairs(reward:toTableArray(true)) do
  1589 + tgift[one[1]] = (tgift[one[1]] or 0) + one[2]
  1590 + end
  1591 + else
  1592 + tgift = gift
  1593 + end
  1594 + local gift = ""
  1595 + for k, v in pairs(tgift) do
  1596 + gift = gift .. k.."="..v.." "
  1597 + end
  1598 + redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = mailId, createtime = createTime, attachments = gift})
  1599 + self.sendMailFlag = true
  1600 + end
  1601 +
1579 1602 end
1580 1603  
1581 1604 return RolePlugin
1582 1605 \ No newline at end of file
... ...
src/models/RoleTimeReset.lua
... ... @@ -10,6 +10,7 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now)
10 10 self.dailyData:refreshDailyData(notify)
11 11 self.dinerData:refreshDailyData(notify)
12 12 self.activity:refreshDailyData(notify)
  13 + self.storeData:onCrossDay()
13 14  
14 15 self:setProperty("dTask", {})
15 16 self:advRandomSupportEffect(not notify)
... ...
src/models/Store.lua
... ... @@ -13,11 +13,13 @@ Store.schema = {
13 13 growFundR = {"string", ""}, -- 成长基金领取记录
14 14 monthCardEx = {"number", 0}, -- 月卡过期时间戳
15 15 smonthCardEx = {"number", 0}, -- 超级月卡过期时间戳
16   - battleCardEx = {"number", 0}, -- 赛季卡过期时间戳
  16 + battleCard = {"number", 0}, -- 赛季卡
17 17 battleFR = {"string", ""}, -- 免费赛季卡领取记录
18 18 battleLR = {"string", ""}, -- 付费赛季卡领取记录
19 19 limitTPack = {"table", {}}, -- 限时礼包 {id=expire_ts}
20   - privCardEx = {"number", 0} -- 特权卡过期时间戳
  20 + privCardEx = {"number", 0}, -- 特权卡过期时间戳
  21 + getMailT1 = {"number",0}, -- 上次发送月卡福利邮件的时间
  22 + getMailT2 = {"number",0}, -- 上次发送超级月卡福利邮件的时间
21 23 }
22 24  
23 25 function Store:updateProperty(params)
... ... @@ -39,46 +41,54 @@ function Store:updateProperty(params)
39 41 end
40 42 end
41 43  
42   -function Store:refreshData(notify, refreshType)
43   - local buyRecord = self:getProperty("buyR")
44   - local result = {}
45   - for id, data in pairs(csvdb["shop_normalCsv"]) do
46   - if data.shop == 1 and refreshType == RefreshType.RefreshType_Daily then
47   - buyRecord[id] = nil
48   - end
49   - if data.shop == 2 and refreshType == RefreshType.RefreshType_Weekly then
50   - buyRecord[id] = nil
51   - end
52   - end
53   - self:setProperty("buyR", buyRecord)
54   - if notify then
55   - self:notifyUpdateProperty({field="buyR", value=buyRecord})
56   - end
  44 +function Store:onCrossDay()
  45 + self:sendMonthCardEmail()
  46 + self:deleteExpireLimitGoods()
57 47 end
58 48  
59   -function Store:refreshPvpBuyRecord(notify)
60   - local buyRecord = self:getProperty("buyR")
61   - for id, data in pairs(csvdb["shop_normalCsv"]) do
62   - if data.shop == 3 then
63   - buyRecord[id] = nil
64   - end
  49 +-- 删除过期商品
  50 +function Store:deleteExpireLimitGoods()
  51 + local timeNow = skynet.timex()
  52 + local limitGoodsList = self:getProperty("limitTPack")
  53 + for k, v in pairs(limitGoodsList) do
  54 + if timeNow > v then
  55 + limitGoodsList[k] = nil
  56 + end
65 57 end
66   - self:setProperty("buyR", buyRecord)
67   - if notify then
68   - self:notifyUpdateProperty({field="buyR", value=buyRecord})
69   - end
70 58 end
71 59  
72 60 -- 发送月卡邮件
73 61 function Store:sendMonthCardEmail()
74   - local monthCardEx = self:getProperty("monthCardEx")
75   - local smonthCardEx = self:getProperty("smonthCardEx")
76 62 local timeNow = skynet.timex()
77   - if monthCardEx < timeNow then
78   - redisproxy:insertEmail({roleId = self.owner:getProperty("id"), emailId = 19})
79   - end
80   - if smonthCardEx < timeNow then
81   - redisproxy:insertEmail({roleId = self.owner:getProperty("id"), emailId = 20})
  63 + local tabs = {{ex="monthCardEx", t="getMailT1", mail=201, alert=203}, {ex="smonthCardEx", t="getMailT2", mail=202, alert=204}}
  64 + for _, v in ipairs(tabs) do
  65 + local ex = self:getProperty(v.ex)
  66 + local ts = self:getProperty(v.t) or 0
  67 + local mailId = v.mail
  68 + local alertId = v.alert
  69 + local alertTs = dayLater(ex) - DAY_SEC
  70 + if ex > timeNow then
  71 + local cnt = 0
  72 + if ts == 0 then
  73 + cnt = 1
  74 + else
  75 + local diff = dayLater(timeNow) - dayLater(ts)
  76 + diff = diff < 0 and 0 or diff
  77 + diff = diff > 31 and 31 or diff
  78 + cnt = diff
  79 + end
  80 + for i = cnt - 1, 0, -1 do
  81 + local createTs = timeNow - i * DAY_SEC
  82 + self.owner:sendMail(mailId, createTs)
  83 + -- 过期头一天发提醒邮件
  84 + if dayLater(createTs) == alertTs then
  85 + self.owner:sendMail(alertId, createTs)
  86 + end
  87 + end
  88 + if cnt > 0 then
  89 + self:updateProperty({field=v.t, value=timeNow})
  90 + end
  91 + end
82 92 end
83 93 end
84 94  
... ... @@ -100,19 +110,13 @@ function Store:isPrivCardExpire()
100 110 return ts < timeNow
101 111 end
102 112  
103   -function Store:isBattleCardExpire()
104   - local timeNow = skynet.timex()
105   - local ts = self:getProperty("battleCardEx")
106   - return ts < timeNow
107   -end
108   -
109 113 -- 挂机栏位 特权卡额外个数
110 114 function Store:getHangSlotExtraCount()
111 115 if self:isPrivCardExpire() then
112 116 return 0
113 117 end
114 118  
115   - return 4
  119 + return csvdb.shop_priv_card_hang_slot_cnt or 4
116 120 end
117 121  
118 122 -- 探索加速/餐厅加速 特权卡系数
... ... @@ -120,8 +124,8 @@ function Store:getProduceItemSpeedCoef()
120 124 if self:isPrivCardExpire() then
121 125 return 1
122 126 end
123   -
124   - return 1 + 0.25
  127 + local coef = (globalCsv.shop_priv_card_produce_coef or 25)/ 100
  128 + return 1 + coef
125 129 end
126 130  
127 131 -- 拆解室栏位 特权卡额外个数
... ... @@ -130,7 +134,7 @@ function Store:getTimeBoxSlotExtraCount()
130 134 return 0
131 135 end
132 136  
133   - return 3
  137 + return csvdb.shop_priv_time_box_slot_cnt or 3
134 138 end
135 139  
136 140 -- 齿轮兑换 特权卡系数
... ... @@ -139,7 +143,8 @@ function Store:getGearExchangeCoef()
139 143 return 1
140 144 end
141 145  
142   - return 1 + 0.5
  146 + local coef = (globalCsv.shop_priv_card_produce_coef or 50)/ 100
  147 + return 1 + coef
143 148 end
144 149  
145 150 -- 购买通行证
... ... @@ -151,12 +156,14 @@ function Store:onBuyCard(type, duration)
151 156 else
152 157 self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration})
153 158 end
  159 + self:sendMonthCardEmail()
154 160 elseif type == CardType.SuperMonthCard then
155 161 if self:isSuperMonthCardExpire() then
156 162 self:updateProperty({field = "smonthCardEx", value = timeNow + duration})
157 163 else
158 164 self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration})
159 165 end
  166 + self:sendMonthCardEmail()
160 167 elseif type == CardType.PrivilegeCard then
161 168 if self:isPrivCardExpire() then
162 169 self:updateProperty({field = "privCardEx", value = timeNow + duration})
... ... @@ -166,14 +173,11 @@ function Store:onBuyCard(type, duration)
166 173 elseif type == CardType.GrowFund then
167 174 self:updateProperty({field = "growFund", value = 1})
168 175 elseif type == CardType.BattleCard then
169   - if self:isBattleCardExpire() then
170   - self:updateProperty({field = "battleCardEx", value = timeNow + duration})
171   - else
172   - self:updateProperty({field = "battleCardEx", value = self:getProperty("battleCardEx") + duration})
173   - end
  176 + self:updateProperty({field = "battleCard", value = 1})
174 177 end
175 178 end
176 179  
  180 +--检测购买是否超过限制数量
177 181 function Store:checkRechargeRecord(limit, id)
178 182 local rechargeRecord = self:getProperty("payR")
179 183 if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then
... ... @@ -194,6 +198,47 @@ function Store:notifyUpdateProperty(field, newValue, oldValue)
194 198 SendPacket(actionCodes.Store_updateproperty, MsgPack.pack(datas))
195 199 end
196 200  
  201 +-- 赛季卡重置 需要把未能领取的奖励通过邮件发送
  202 +function Store:onBattleCardReset()
  203 + local gift = ""
  204 + local function concatGift(data)
  205 + if gift == "" then
  206 + gift = data
  207 + else
  208 + gift = gift .. " " .. data
  209 + end
  210 + end
  211 + local battleCardFlag = self:getProperty("battleCard")
  212 + local battleCardFreeRecord = self:getProperty("battleFR")
  213 + local battleCardLimitRecord = self:getProperty("battleLR")
  214 + local battlePoint = self.owner:getProperty("battlePoint")
  215 +
  216 + for id, config in pairs(csvdb["reward_battlepassCsv"]) do
  217 + if config then
  218 + local freeFlag = string.char(string.getbit(battleCardFreeRecord, id))
  219 + local limitFlag = string.char(string.getbit(battleCardLimitRecord, id))
  220 +
  221 + if battlePoint < config.point then
  222 + break
  223 + end
  224 + if freeFlag == "0" then
  225 + concatGift(config.giftFree)
  226 + end
  227 + if limitFlag == "0" and battleCardFlag == 1 then
  228 + concatGift(config.giftLimit)
  229 + end
  230 + end
  231 + end
  232 + self.owner:sendMail(210, nil, gift)
  233 + -- 计算剩余奖励
  234 + self:updateProperty({field = "battleCard", value=0})
  235 + self:updateProperty({field = "battleCardR", value=""})
  236 + self:updateProperty({field = "battleFR", value=""})
  237 + self:updateProperty({field = "battleLR", value=""})
  238 + self.owner:updateProperty({field = "battlePoint", value=0})
  239 +end
  240 +
  241 +-- 重置购买记录
197 242 function Store:resetStoreReored(resetId)
198 243 local payRecord = self:getProperty("payR") or {}
199 244 local buyRecord = self:getProperty("buyR") or {}
... ... @@ -202,6 +247,12 @@ function Store:resetStoreReored(resetId)
202 247 if config then
203 248 if config.resetTime == resetId then
204 249 payRecord[k] = nil
  250 + --通行证商店
  251 + if config.shop == 2 then
  252 + if config.type == CardType.BattleCard then
  253 + self:onBattleCardReset()
  254 + end
  255 + end
205 256 end
206 257 end
207 258 end
... ... @@ -225,8 +276,9 @@ function Store:data()
225 276 growFundR = self:getProperty("growFundR"),
226 277 monthCardEx = self:getProperty("monthCardEx"),
227 278 smonthCardEx = self:getProperty("smonthCardEx"),
228   - battleCardEx = self:getProperty("battleCardEx"),
229   - battleCardR = self:getProperty("battleCardR"),
  279 + battleCard = self:getProperty("battleCard"),
  280 + battleFR = self:getProperty("battleFR"),
  281 + battleLR = self:getProperty("battleLR"),
230 282 limitTPack = self:getProperty("limitTPack"),
231 283 privCardEx = self:getProperty("privCardEx"),
232 284 }
... ...