Commit 94f99134916258c1a3cd9b434a31179742b846d9
1 parent
98f7d4a8
fix: shop_card字段修改
1. buyLimit update 2. itemFirst add 3. itemOnce add 4. countLimit add 5. itemDaily add
Showing
1 changed file
with
58 additions
and
22 deletions
Show diff stats
src/models/Store.lua
| @@ -98,37 +98,67 @@ local SuperMonthCard = {} | @@ -98,37 +98,67 @@ local SuperMonthCard = {} | ||
| 98 | SuperMonthCard["buy"] = function(self, id) | 98 | SuperMonthCard["buy"] = function(self, id) |
| 99 | local smonthCards = self:getProperty("smonthCards") or {} | 99 | local smonthCards = self:getProperty("smonthCards") or {} |
| 100 | 100 | ||
| 101 | + local buyLimitFunc = function(buylimit) | ||
| 102 | + for k, v in pairs(buylimit) do | ||
| 103 | + if k == 1 then | ||
| 104 | + if v == 101 then | ||
| 105 | + if self:isMonthCardExpire() then | ||
| 106 | + skynet.error("月卡过期") | ||
| 107 | + return false | ||
| 108 | + end | ||
| 109 | + else | ||
| 110 | + if smonthCards[v] == nil then | ||
| 111 | + skynet.error("没有购买增刊里的条件, %d", v) | ||
| 112 | + return false | ||
| 113 | + end | ||
| 114 | + end | ||
| 115 | + elseif k == 2 then | ||
| 116 | + if smonthCards[v] == nil and v ~= 101 then | ||
| 117 | + skynet.error("没有购买增刊里的条件, %d", v) | ||
| 118 | + return false | ||
| 119 | + end | ||
| 120 | + if SuperMonthCard["isExpired"](self, v) == false and v ~= 101 then | ||
| 121 | + skynet.error("上期特刊奖励没有领取完") | ||
| 122 | + return false | ||
| 123 | + end | ||
| 124 | + end | ||
| 125 | + end | ||
| 126 | + return true | ||
| 127 | + end | ||
| 128 | + | ||
| 101 | local BuyMonthCard = {} | 129 | local BuyMonthCard = {} |
| 102 | BuyMonthCard["renewal"]= function() | 130 | BuyMonthCard["renewal"]= function() |
| 103 | --续刊 | 131 | --续刊 |
| 104 | - if self:isMonthCardExpire() then return false end | 132 | + local card = csvdb["shop_cardCsv"][id] or {} |
| 133 | + if card["buyLimit"] and card["buyLimit"] ~= "" then | ||
| 134 | + if buyLimitFunc(card["buyLimit"]:toNumMap()) == false then | ||
| 135 | + skynet.error("不满足购买条件") | ||
| 136 | + return false | ||
| 137 | + end | ||
| 138 | + end | ||
| 105 | 139 | ||
| 106 | local smonthCard = smonthCards[id] or {} | 140 | local smonthCard = smonthCards[id] or {} |
| 107 | if next(smonthCard) then | 141 | if next(smonthCard) then |
| 108 | - | ||
| 109 | smonthCard["buyCount"] = (smonthCard["buyCount"] or 0) + 1 | 142 | smonthCard["buyCount"] = (smonthCard["buyCount"] or 0) + 1 |
| 110 | - | ||
| 111 | - local card = csvdb["shop_cardCsv"][id] or {} | ||
| 112 | - local periods = SuperMonthCard["periods"](self, id) + (card["cardPlusPeriods"] or 30) | 143 | + local periods = SuperMonthCard["periods"](self, id) + (card["amount"] or 30) |
| 113 | smonthCard["periods"] = periods | 144 | smonthCard["periods"] = periods |
| 114 | 145 | ||
| 115 | - self:updateProperty({filed = "smonthCards", value = smonthCards}) | 146 | + self:updateProperty({field = "smonthCards", value = smonthCards}) |
| 116 | return true | 147 | return true |
| 117 | end | 148 | end |
| 118 | end | 149 | end |
| 119 | BuyMonthCard["order"] = function() | 150 | BuyMonthCard["order"] = function() |
| 120 | --增刊条件 | 151 | --增刊条件 |
| 121 | local card = csvdb["shop_cardCsv"][id] or {} | 152 | local card = csvdb["shop_cardCsv"][id] or {} |
| 122 | - --判断是否购买过增刊条件里的特刊 | ||
| 123 | - local cardId = card["cardPlusCondition"] or 0 | ||
| 124 | - if self:isMonthCardExpire() or smonthCards[cardId] == nil then return false end | ||
| 125 | - | ||
| 126 | - --如果上期特刊奖励没有领取玩,则不能购买这期特刊。 | ||
| 127 | - if SuperMonthCard["isExpired"](self, cardId) == false and cardId ~= 101 then return false end | ||
| 128 | - | ||
| 129 | - smonthCards[id] = {["periods"] = (card["cardPlusPeriods"] or 30), ["buyCount"] = 1} | 153 | + if card["buyLimit"] and card["buyLimit"] ~= "" then |
| 154 | + if buyLimitFunc(card["buyLimit"]:toNumMap()) == false then | ||
| 155 | + skynet.error("不满足增刊条件") | ||
| 156 | + return false | ||
| 157 | + end | ||
| 158 | + end | ||
| 159 | + smonthCards[id] = {["periods"] = (card["amount"] or 30), ["buyCount"] = 1} | ||
| 130 | 160 | ||
| 131 | - self:updateProperty({filed = "smonthCards", value = smonthCards}) | 161 | + self:updateProperty({field= "smonthCards", value = smonthCards}) |
| 132 | return true | 162 | return true |
| 133 | end | 163 | end |
| 134 | 164 | ||
| @@ -171,6 +201,12 @@ SuperMonthCard["itemDaily"] = function(self, id) | @@ -171,6 +201,12 @@ SuperMonthCard["itemDaily"] = function(self, id) | ||
| 171 | return reward, change, cur_ex | 201 | return reward, change, cur_ex |
| 172 | end | 202 | end |
| 173 | 203 | ||
| 204 | +SuperMonthCard["itemFirst"] = function(self, id) | ||
| 205 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 206 | + local reward, _ = self.owner:award(card["itemFirst"], {isRecharge = true, log = {desc = "recharge", int1 = id}}) | ||
| 207 | + return reward | ||
| 208 | +end | ||
| 209 | + | ||
| 174 | -- 删除过期商品 | 210 | -- 删除过期商品 |
| 175 | function Store:deleteExpireLimitGoods() | 211 | function Store:deleteExpireLimitGoods() |
| 176 | local timeNow = skynet.timex() | 212 | local timeNow = skynet.timex() |
| @@ -313,7 +349,7 @@ function Store:getMonthCardDailyReward(id) | @@ -313,7 +349,7 @@ function Store:getMonthCardDailyReward(id) | ||
| 313 | self:updateProperty({field = "monthCardEx", delta = -1}) | 349 | self:updateProperty({field = "monthCardEx", delta = -1}) |
| 314 | local cur_ex = self:getProperty("monthCardEx") | 350 | local cur_ex = self:getProperty("monthCardEx") |
| 315 | 351 | ||
| 316 | - local actCfg = csvdb["shop_card"][id] or {} | 352 | + local actCfg = csvdb["shop_cardCsv"][id] or {} |
| 317 | local award = actCfg.itemDaily:toNumMap() | 353 | local award = actCfg.itemDaily:toNumMap() |
| 318 | local reward, change = self.owner:award(award, {log = {desc = "monthCardReward", int1 = id, int2 = cur_ex}}) | 354 | local reward, change = self.owner:award(award, {log = {desc = "monthCardReward", int1 = id, int2 = cur_ex}}) |
| 319 | 355 | ||
| @@ -354,7 +390,7 @@ function Store:firstBuyMonthCard(id) | @@ -354,7 +390,7 @@ function Store:firstBuyMonthCard(id) | ||
| 354 | if self:getProperty("firstMonthCard") == 1 then | 390 | if self:getProperty("firstMonthCard") == 1 then |
| 355 | self:updateProperty({field = "firstMonthCard", value = 0}) | 391 | self:updateProperty({field = "firstMonthCard", value = 0}) |
| 356 | local card = csvdb["shop_cardCsv"][id] or {} | 392 | local card = csvdb["shop_cardCsv"][id] or {} |
| 357 | - return self:award(card["cardFirst"], {log = {desc = "monthCardReward", int1 = id, int2 = 30}}) | 393 | + return self.owner:award(card["itemOnce"], {log = {desc = "monthCardReward", int1 = id, int2 = 30}}) |
| 358 | end | 394 | end |
| 359 | return nil | 395 | return nil |
| 360 | end | 396 | end |
| @@ -377,9 +413,8 @@ function Store:onBuyCard(type, duration, id, actid) | @@ -377,9 +413,8 @@ function Store:onBuyCard(type, duration, id, actid) | ||
| 377 | end | 413 | end |
| 378 | end | 414 | end |
| 379 | 415 | ||
| 380 | - --签收奖励 | ||
| 381 | - tmpreward, _= self:getMonthCardDailyReward(id) | ||
| 382 | - if tmpreward then | 416 | + tmpreward = SuperMonthCard["itemFirst"](self, id) |
| 417 | + if next(tmpreward) then | ||
| 383 | for k, v in pairs(tmpreward) do | 418 | for k, v in pairs(tmpreward) do |
| 384 | reward[k] = (reward[k] or 0) + v | 419 | reward[k] = (reward[k] or 0) + v |
| 385 | end | 420 | end |
| @@ -387,9 +422,10 @@ function Store:onBuyCard(type, duration, id, actid) | @@ -387,9 +422,10 @@ function Store:onBuyCard(type, duration, id, actid) | ||
| 387 | return reward | 422 | return reward |
| 388 | elseif type == CardType.SuperMonthCard then | 423 | elseif type == CardType.SuperMonthCard then |
| 389 | if SuperMonthCard["buy"](self, id) then | 424 | if SuperMonthCard["buy"](self, id) then |
| 390 | - return self:getSMonthCardDailyReward(id) | 425 | + skynet.error("特刊购买成功:"..id) |
| 426 | + return SuperMonthCard["itemFirst"](self, id) | ||
| 391 | end | 427 | end |
| 392 | - return nil, nil | 428 | + return nil |
| 393 | elseif type == CardType.NormalMonthCardLevelUp then | 429 | elseif type == CardType.NormalMonthCardLevelUp then |
| 394 | if self:isMonthCardExpire() then | 430 | if self:isMonthCardExpire() then |
| 395 | skynet.error(string.format("month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | 431 | skynet.error(string.format("month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) |