Commit 2c04a1498ae7a59983d5b1f0e55e4a21ee1beab3
1 parent
2c585b73
fix: 特刊购买,在生成订单的时候进行判断是否能购买,不能购买则订单生成失败
Showing
2 changed files
with
25 additions
and
22 deletions
Show diff stats
src/models/RolePlugin.lua
| ... | ... | @@ -2315,6 +2315,18 @@ function RolePlugin.bind(Role) |
| 2315 | 2315 | -- end |
| 2316 | 2316 | -- end |
| 2317 | 2317 | |
| 2318 | + --月卡-特刊加判断; | |
| 2319 | + -- 问题描述: 支付回调里订单支付完成,但是没有奖励,对应的特刊也没有购买成功。 | |
| 2320 | + -- 避免这种情况发生,在生成订单的时候就判断是否能购买特刊,生成对应的订单id | |
| 2321 | + if rechargeData.shop == 2 and rechargeData.type == CardType.SuperMonthCard then | |
| 2322 | + local card = csvdb["shop_cardCsv"][rechargeData.id] | |
| 2323 | + if not card then return "" end | |
| 2324 | + | |
| 2325 | + if not self.storeData:buySMonthCardLimit(card["buyLimit"]) then | |
| 2326 | + return "" | |
| 2327 | + end | |
| 2328 | + end | |
| 2329 | + | |
| 2318 | 2330 | local orderId = redisproxy:hincrby("autoincrement_set", "order", 1) |
| 2319 | 2331 | local uid = orderId * MAX_SVR_ID + serverId |
| 2320 | 2332 | local partnerOrderId = string.format("%d", orderId * MAX_SVR_ID + serverId) | ... | ... |
src/models/Store.lua
| ... | ... | @@ -342,26 +342,26 @@ function Store:isSMonthCardExpired(id) |
| 342 | 342 | end |
| 343 | 343 | |
| 344 | 344 | function Store:buySMonthCardLimit(buylimit) |
| 345 | + if not buylimit or buylimit == "" then return true end | |
| 346 | + | |
| 345 | 347 | local smonthCards = self:getProperty("smonthCards") or {} |
| 346 | - for k, v in pairs(buylimit) do | |
| 348 | + for k, v in pairs(buylimit:toNumMap() or {}) do | |
| 347 | 349 | if k == 1 then |
| 348 | 350 | if v == 101 then |
| 349 | 351 | if self:isMonthCardExpire() then |
| 350 | - skynet.error("月卡过期") | |
| 351 | 352 | return false |
| 352 | 353 | end |
| 353 | 354 | else |
| 354 | - if smonthCards[v] == nil then | |
| 355 | - skynet.error("没有购买增刊里的条件, %d", v) | |
| 355 | + if not smonthCards[v] then | |
| 356 | 356 | return false |
| 357 | 357 | end |
| 358 | 358 | end |
| 359 | 359 | elseif k == 2 then |
| 360 | - if smonthCards[v] == nil and v ~= 101 then | |
| 360 | + if not smonthCards[v] then | |
| 361 | 361 | skynet.error("没有购买增刊条件里的特刊, %d", v) |
| 362 | 362 | return false |
| 363 | 363 | end |
| 364 | - if self:isSMonthCardExpired(v) == false and v ~= 101 then | |
| 364 | + if not self:isSMonthCardExpired(v) then | |
| 365 | 365 | skynet.error("上期特刊奖励没领完") --策划yc+hbw 没领完上期特刊,新一期特刊不展示,不允许购买 |
| 366 | 366 | return false |
| 367 | 367 | end |
| ... | ... | @@ -372,18 +372,17 @@ end |
| 372 | 372 | |
| 373 | 373 | function Store:buySMonthCard(id) |
| 374 | 374 | local smonthCards = self:getProperty("smonthCards") or {} |
| 375 | + local card = csvdb["shop_cardCsv"][id] | |
| 376 | + if not card then return false end | |
| 377 | + | |
| 378 | + if not self:buySMonthCardLimit(card["buyLimit"]) then | |
| 379 | + skynet.error("不满足购买条件") | |
| 380 | + return false | |
| 381 | + end | |
| 375 | 382 | |
| 376 | 383 | local BuyMonthCard = {} |
| 377 | 384 | BuyMonthCard["renewal"]= function() |
| 378 | 385 | --续刊 |
| 379 | - local card = csvdb["shop_cardCsv"][id] or {} | |
| 380 | - if card["buyLimit"] and card["buyLimit"] ~= "" then | |
| 381 | - if not self:buySMonthCardLimit(card["buyLimit"]:toNumMap()) then | |
| 382 | - skynet.error("不满足购买条件") | |
| 383 | - return false | |
| 384 | - end | |
| 385 | - end | |
| 386 | - | |
| 387 | 386 | local smonthCard = smonthCards[id] or {} |
| 388 | 387 | if next(smonthCard) then |
| 389 | 388 | smonthCard["buyCount"] = (smonthCard["buyCount"] or 0) + 1 |
| ... | ... | @@ -397,14 +396,6 @@ function Store:buySMonthCard(id) |
| 397 | 396 | |
| 398 | 397 | BuyMonthCard["order"] = function() |
| 399 | 398 | --增刊 |
| 400 | - local card = csvdb["shop_cardCsv"][id] or {} | |
| 401 | - if card["buyLimit"] and card["buyLimit"] ~= "" then | |
| 402 | - if not self:buySMonthCardLimit(card["buyLimit"]:toNumMap()) then | |
| 403 | - skynet.error("不满足增刊条件") | |
| 404 | - return false | |
| 405 | - end | |
| 406 | - end | |
| 407 | - | |
| 408 | 399 | smonthCards[id] = {["periods"] = (card["amount"] or 30), ["buyCount"] = 1} |
| 409 | 400 | self:updateProperty({field= "smonthCards", value = smonthCards}) |
| 410 | 401 | return true | ... | ... |