diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 7d93509..4f9b05e 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -2315,6 +2315,18 @@ function RolePlugin.bind(Role) -- end -- end + --月卡-特刊加判断; + -- 问题描述: 支付回调里订单支付完成,但是没有奖励,对应的特刊也没有购买成功。 + -- 避免这种情况发生,在生成订单的时候就判断是否能购买特刊,生成对应的订单id + if rechargeData.shop == 2 and rechargeData.type == CardType.SuperMonthCard then + local card = csvdb["shop_cardCsv"][rechargeData.id] + if not card then return "" end + + if not self.storeData:buySMonthCardLimit(card["buyLimit"]) then + return "" + end + end + local orderId = redisproxy:hincrby("autoincrement_set", "order", 1) local uid = orderId * MAX_SVR_ID + serverId local partnerOrderId = string.format("%d", orderId * MAX_SVR_ID + serverId) diff --git a/src/models/Store.lua b/src/models/Store.lua index 67ed5a1..db900a1 100644 --- a/src/models/Store.lua +++ b/src/models/Store.lua @@ -342,26 +342,26 @@ function Store:isSMonthCardExpired(id) end function Store:buySMonthCardLimit(buylimit) + if not buylimit or buylimit == "" then return true end + local smonthCards = self:getProperty("smonthCards") or {} - for k, v in pairs(buylimit) do + for k, v in pairs(buylimit:toNumMap() or {}) do if k == 1 then if v == 101 then if self:isMonthCardExpire() then - skynet.error("月卡过期") return false end else - if smonthCards[v] == nil then - skynet.error("没有购买增刊里的条件, %d", v) + if not smonthCards[v] then return false end end elseif k == 2 then - if smonthCards[v] == nil and v ~= 101 then + if not smonthCards[v] then skynet.error("没有购买增刊条件里的特刊, %d", v) return false end - if self:isSMonthCardExpired(v) == false and v ~= 101 then + if not self:isSMonthCardExpired(v) then skynet.error("上期特刊奖励没领完") --策划yc+hbw 没领完上期特刊,新一期特刊不展示,不允许购买 return false end @@ -372,18 +372,17 @@ end function Store:buySMonthCard(id) local smonthCards = self:getProperty("smonthCards") or {} + local card = csvdb["shop_cardCsv"][id] + if not card then return false end + + if not self:buySMonthCardLimit(card["buyLimit"]) then + skynet.error("不满足购买条件") + return false + end local BuyMonthCard = {} BuyMonthCard["renewal"]= function() --续刊 - local card = csvdb["shop_cardCsv"][id] or {} - if card["buyLimit"] and card["buyLimit"] ~= "" then - if not self:buySMonthCardLimit(card["buyLimit"]:toNumMap()) then - skynet.error("不满足购买条件") - return false - end - end - local smonthCard = smonthCards[id] or {} if next(smonthCard) then smonthCard["buyCount"] = (smonthCard["buyCount"] or 0) + 1 @@ -397,14 +396,6 @@ function Store:buySMonthCard(id) BuyMonthCard["order"] = function() --增刊 - local card = csvdb["shop_cardCsv"][id] or {} - if card["buyLimit"] and card["buyLimit"] ~= "" then - if not self:buySMonthCardLimit(card["buyLimit"]:toNumMap()) then - skynet.error("不满足增刊条件") - return false - end - end - smonthCards[id] = {["periods"] = (card["amount"] or 30), ["buyCount"] = 1} self:updateProperty({field= "smonthCards", value = smonthCards}) return true -- libgit2 0.21.2