Commit 9b20dbfcce3bf997f0c0af2c2cb75f71585711d8
Merge branch 'cn/develop' into cn/publish/zhaolu
Showing
2 changed files
with
13 additions
and
14 deletions
Show diff stats
src/actions/StoreAction.lua
... | ... | @@ -366,7 +366,7 @@ function _M.shopBuyRpc(agent , data) |
366 | 366 | local id = msg.id |
367 | 367 | local count = msg.count or 1 |
368 | 368 | |
369 | - local dataSet = csvdb["shop_normalCsv"][id] | |
369 | + local dataSet = csvdb["shop_normalCsv"][id] | |
370 | 370 | if not dataSet then return end |
371 | 371 | |
372 | 372 | if dataSet.unlock ~= "" then |
... | ... | @@ -383,20 +383,13 @@ function _M.shopBuyRpc(agent , data) |
383 | 383 | if not role.activity:isOpenById(dataSet.activity_id, "ActShopGoods") then return 3 end |
384 | 384 | end |
385 | 385 | |
386 | - local buyRecord = role.storeData:getProperty("buyR") | |
387 | - if math.illegalNum(count, 1, (dataSet.limit == 0 and 10000 or dataSet.limit - (buyRecord[id] or 0))) then | |
388 | - skynet.error(string.format("shop buy over limit, user_id:%d, goods_id:%d", role:getProperty("id"), id)) | |
389 | - return 6 | |
390 | - end | |
391 | - | |
392 | - local cost | |
393 | - if dataSet.disount == 0 then | |
386 | + local cost | |
387 | + if dataSet.disount == 0 then | |
394 | 388 | cost = {[dataSet.icon] = math.ceil(dataSet.cost * count)} |
395 | 389 | else |
396 | 390 | cost = {[dataSet.icon] = math.ceil(dataSet.cost * count * ((dataSet.disount or 10) / 10))} |
397 | 391 | end |
398 | 392 | |
399 | - | |
400 | 393 | local desc = "unknowShop" |
401 | 394 | if dataSet.shop == 1 then -- 普通商店 |
402 | 395 | desc = "dailyShop" |
... | ... | @@ -407,14 +400,20 @@ function _M.shopBuyRpc(agent , data) |
407 | 400 | end |
408 | 401 | |
409 | 402 | if not role:checkItemEnough(cost) then return 4 end |
403 | + if not role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}}) then return 5 end | |
410 | 404 | |
411 | - local limitStr = "" | |
405 | + local buyRecord = role.storeData:getProperty("buyR") | |
406 | + if math.illegalNum(count, 1, (dataSet.limit == 0 and 10000 or dataSet.limit - (buyRecord[id] or 0))) then | |
407 | + skynet.error(string.format("shop buy over limit, user_id:%d, goods_id:%d", role:getProperty("id"), id)) | |
408 | + return 6 | |
409 | + end | |
410 | + | |
411 | + local limitStr = "" | |
412 | 412 | if dataSet.limit ~= 0 then |
413 | 413 | buyRecord[id] = (buyRecord[id] or 0) + count |
414 | 414 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) |
415 | - limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) | |
415 | + limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) | |
416 | 416 | end |
417 | - if not role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}}) then return 5 end | |
418 | 417 | |
419 | 418 | local gift = {} |
420 | 419 | for _id, _count in pairs(dataSet.gift:toNumMap()) do | ... | ... |
src/models/RolePlugin.lua