Commit 87beef2ff10bc9819d9c303b93827eedc23a2151

Authored by 熊润斐
2 parents da3aa52f 648d9726

Merge branch 'bugfix' into tr/qa

src/GlobalVar.lua
... ... @@ -315,6 +315,7 @@ TriggerEventType = {
315 315 LevelUp = 4,
316 316 AddNewHero = 5,
317 317 SSRCount = 6,
  318 + AfterTs = 7, -- 某时间以后
318 319 }
319 320  
320 321 DrawCardType = {
... ...
src/RedisKeys.lua
... ... @@ -12,6 +12,8 @@ R_RUNE = "role:%d:rune:%d" -- 符文详细信息
12 12 R_EMAIL = "role:%d:emailIds" --邮件列表
13 13 R_EMAIL_ITEM = "email:%d:%d" --邮件
14 14 R_STORE = "role:%d:store" -- 商店
  15 +R_ORDERS = "role:%d:orders" -- 订单
  16 +R_ORDER = "order:%d:%d"
15 17  
16 18  
17 19 -- rank
... ...
src/actions/ActivityAction.lua
... ... @@ -195,6 +195,7 @@ function _M.actPaySignRpc(agent, data)
195 195 local diffDay = diffFromTs(ts) + 1
196 196  
197 197 local curData = role.activity:getActData("PaySignIn")
  198 + if not curData then return 3 end
198 199 local reward, change = {}
199 200 for day, csvData in ipairs(csvdb["pay_signInCsv"]) do
200 201 if day <= diffDay and day == dayIndex then
... ...
src/actions/HeroAction.lua
... ... @@ -738,7 +738,7 @@ function _M.drawHeroRpc(agent, data)
738 738  
739 739 if btype == 1 then
740 740 -- 判断定向卡池活动开启
741   - if not role.activity:isOpen("SsrUpPoolChange") then
  741 + if not role.activity:isOpen("RaceDraw") then
742 742 return
743 743 end
744 744 end
... ... @@ -982,8 +982,9 @@ function _M.drawHeroRpc(agent, data)
982 982 --end
983 983 SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change)))
984 984 elseif drawCardReward and drawCardReward ~= "" then
985   - role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}})
986   - SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack({reward = drawCardReward:toNumMap()}))
  985 + local r,change = {}
  986 + r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}})
  987 + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change)))
987 988 end
988 989 role:updateProperty({field = "repayHero", value = val})
989 990 end
... ...
src/actions/StoreAction.lua
1 1 local _M = {}
2 2  
3   -local serverId = tonumber(skynet.getenv("servId"))
4 3 local md5 = require "md5"
5 4  
6   -local function makeOrder(roleId, rechargeId)
7   - local orderId = redisproxy:hincrby("autoincrement_set", "order", 1)
8   - local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId)
9   - local orderKey = string.format("order:%d:%d", roleId, orderId)
10   - redisproxy:del(orderKey)
11   - local order = require("models.Order").new({
12   - key = orderKey,
13   - order = partnerOrderId,
14   - rechargeId = rechargeId,
15   - })
16   - order:create()
17   - redisproxy:sadd(string.format("role:%d:orders", roleId), partnerOrderId)
18   - return partnerOrderId
19   -end
20   -
21 5 -- 入口在正式服关闭 -- mock 充值
22 6 function _M.rechargeRpc(agent , data)
23 7 local role = agent.role
... ... @@ -28,7 +12,7 @@ function _M.rechargeRpc(agent , data)
28 12 local roleId = role:getProperty("id")
29 13  
30 14 --创建订单号
31   - local partnerOrderId = makeOrder(roleId, id)
  15 + local partnerOrderId = role:getPurchaseOrder(id)
32 16 SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId }))
33 17  
34 18  
... ... @@ -77,7 +61,7 @@ function _M.googleRechargeRpc(agent, data)
77 61  
78 62 role.ignoreHeartbeat = true
79 63 --创建订单号
80   - local partnerOrderId = makeOrder(roleId, id)
  64 + local partnerOrderId = role:getPurchaseOrder(id)
81 65 -- 签名
82 66 local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075"
83 67 local need = {
... ... @@ -104,7 +88,7 @@ function _M.myCardRechargeRpc(agent, data)
104 88  
105 89 role.ignoreHeartbeat = true
106 90 --创建订单号
107   - local partnerOrderId = makeOrder(roleId, id)
  91 + local partnerOrderId = role:getPurchaseOrder(id)
108 92 -- 签名
109 93 local secret_key = "48759e07540f46d9af17ec82669b4272"
110 94 local need = {
... ... @@ -130,7 +114,7 @@ function _M.iosRechargeRpc(agent, data)
130 114  
131 115 role.ignoreHeartbeat = true
132 116 --创建订单号
133   - local partnerOrderId = makeOrder(roleId, id)
  117 + local partnerOrderId = role:getPurchaseOrder(id)
134 118 -- 签名
135 119 local secret_key = "9647d2efe1074c73b9ac19af4337a70e"
136 120 local need = {
... ... @@ -154,43 +138,15 @@ function _M.purchaseOrderResult(agent, data)
154 138  
155 139 role.ignoreHeartbeat = false
156 140  
157   - local partnerOrderStr = msg.order
158   - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)")
159   - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) })
160   - if not orderObject:load() then
161   - -- 订单不存在
162   - skynet.error("cancelPurchaseRpc", string.format("order %s not exist", partnerOrderStr))
163   - return true
164   - end
165   -
166   - if msg.status == "success" then
167   - orderObject:setProperty("transactionId", msg.platformOrder or "")
168   - local rechargeId = orderObject:getProperty("rechargeId")
169   - local dataSet = csvdb["shop_rechargeCsv"][rechargeId]
170   -
171   - role:log("setOrder", {
172   - order_status = 100, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
173   - item_id = rechargeId, -- 道具id
174   - item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
175   - item_name = dataSet.title, -- 购买的道具名
176   - item_number = 1, -- 购买的道具数量
177   - item_level = 1, -- 购买的道具等级
178   - order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
179   - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
180   - order_type = role:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0
181   - order_id = msg.platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
182   - })
183   -
184   - return true
185   - end
  141 + local status = {
  142 + fail = true,
  143 + success = true
  144 + }
186 145  
187   - if orderObject:getProperty("finishTime") > 0 then
188   - return true
  146 + local partnerOrderStr = msg.order
  147 + if partnerOrderStr then
  148 + role:updatePurchaseOrder(partnerOrderStr, msg.platformOrder, status[msg.status] and msg.status or "unknown")
189 149 end
190   -
191   - orderObject:setProperty("status", msg.status)
192   -
193   - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr)
194 150 return true
195 151 end
196 152  
... ...
1   -Subproject commit fa67cf8b44c11ad75a4d67525fc906d91e17655b
  1 +Subproject commit 02a9bbbb10bb99a91cc5d67f62dc7e5b49d8cb46
... ...
src/models/Activity.lua
... ... @@ -18,7 +18,7 @@ Activity.ActivityType = {
18 18 DrawHero = 12, --抽卡周 招募
19 19 AdvDraw = 13, --拾荒抽周 资助
20 20 OpenBox = 14, --拆解周 时钟箱
21   - --RaceDraw = 15, -- 定向招募活动
  21 + RaceDraw = 16, -- 定向招募活动
22 22 }
23 23  
24 24  
... ... @@ -347,6 +347,15 @@ activityFunc[Activity.ActivityType.PaySignIn] = {
347 347 end,
348 348 ["close"] = function(self, actType, notify)
349 349 self.owner.storeData:SetActGoodsFlag("paySignIn", 0)
  350 +
  351 + local rechargeRecord = self.owner.storeData:getProperty("payR")
  352 + for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do
  353 + if cfg.shop == 2 and cfg.type == CardType.PaySignCard then
  354 + rechargeRecord[id] = nil
  355 + break
  356 + end
  357 + end
  358 + self.owner.storeData:updateProperty({field="payR", value=rechargeRecord})
350 359 end,
351 360 }
352 361  
... ...
src/models/Role.lua
... ... @@ -112,6 +112,7 @@ Role.schema = {
112 112 hangBag = {"table", {}}, -- 背包
113 113 hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限
114 114 bTeam = {"table", {}}, -- 奖励副本队伍
  115 + heroFormate = {"table", {}}, -- 自选编队 {adv={}, hang={}}
115 116  
116 117 --引导相关
117 118 newerGuide = {"string","1=1"}, -- 新手引导 master=slave
... ...
src/models/RoleCross.lua
... ... @@ -287,7 +287,7 @@ end
287 287  
288 288 function CMD.friendBattleInfo(roleId)
289 289 local info = CMD.getProperties(roleId, {"pvpTBC", "hangTB"})
290   - return next(info.pvpTBC) and info.pvpTBC or info.hangTB
  290 + return (next(info.pvpTBC) and next(info.pvpTBC.heros)) and info.pvpTBC or info.hangTB
291 291 end
292 292  
293 293 function CMD.pvpCInfo(roleId)
... ...
src/models/RolePlugin.lua
1 1  
2   -
  2 +local serverId = tonumber(skynet.getenv("servId"))
3 3 local RolePlugin = {}
4 4  
5 5 function RolePlugin.bind(Role)
... ... @@ -1497,6 +1497,102 @@ function RolePlugin.bind(Role)
1497 1497 self:updateProperty({field = "redp", value = redp})
1498 1498 end
1499 1499  
  1500 + -- 获取充值订单号
  1501 + function Role:getPurchaseOrder(rechargeId)
  1502 + local roleId = self:getProperty("id")
  1503 + local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
  1504 + if not rechargeData then
  1505 + skynet.error("recharge id not exist", rechargeId)
  1506 + return ""
  1507 + end
  1508 + local limit = rechargeData.limit
  1509 + local rechargeRecord = self:getProperty("payR") or {}
  1510 + if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then
  1511 + return ""
  1512 + end
  1513 +
  1514 + local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId)
  1515 + if orderId then
  1516 + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) })
  1517 + if orderObject:load() and orderObject:getProperty("rechargeId") == rechargeId and math.abs(skynet.timex() - orderObject:getProperty("createTime")) < 5 * 60 then
  1518 + return string.format("%d_%d_%d", serverId, roleId, orderId)
  1519 + end
  1520 + end
  1521 +
  1522 + orderId = redisproxy:hincrby("autoincrement_set", "order", 1)
  1523 + local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId)
  1524 + local orderKey = string.format(R_ORDER, roleId, orderId)
  1525 + redisproxy:del(orderKey) -- 删掉可能有了
  1526 + local order = require("models.Order").new({
  1527 + key = orderKey,
  1528 + order = partnerOrderId,
  1529 + rechargeId = rechargeId,
  1530 + })
  1531 + order:create()
  1532 + -- 正在进行中的订单 缓存
  1533 + redisproxy:hset(string.format(R_ORDERS, roleId), rechargeId, orderId)
  1534 + return partnerOrderId
  1535 + end
  1536 +
  1537 + -- 更新订单信息
  1538 + --[[
  1539 +
  1540 + status
  1541 +
  1542 + success
  1543 + fail
  1544 + finsh
  1545 + unknow
  1546 +
  1547 + --]]
  1548 + function Role:updatePurchaseOrder(partnerOrderStr, platformOrder, status)
  1549 + if not partnerOrderStr then return false end
  1550 + local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)")
  1551 +
  1552 + local roleId = self:getProperty("id")
  1553 + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) })
  1554 + if not orderObject:load() then
  1555 + return false
  1556 + end
  1557 +
  1558 + local rechargeId = orderObject:getProperty("rechargeId")
  1559 + local dataSet = csvdb["shop_rechargeCsv"][rechargeId]
  1560 +
  1561 + if orderObject:getProperty("finishTime") > 0 then
  1562 + return false, "finsh"
  1563 + end
  1564 +
  1565 + if platformOrder then
  1566 + orderObject:setProperty("transactionId", platformOrder)
  1567 + end
  1568 + orderObject:setProperty("status", status)
  1569 +
  1570 + -- 开始下单
  1571 + if status == "success" then
  1572 + elseif status == "fail" then
  1573 + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId)
  1574 + elseif status == "finsh" then
  1575 + orderObject:setProperty("finishTime", skynet.time())
  1576 + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId)
  1577 + end
  1578 +
  1579 + if status ~= "unknow" then
  1580 + self:log("setOrder", {
  1581 + order_status = ({success = 100, finsh = 200, fail = 300})[status] or 1000, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
  1582 + item_id = rechargeId, -- 道具id
  1583 + item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
  1584 + item_name = dataSet.title, -- 购买的道具名
  1585 + item_number = 1, -- 购买的道具数量
  1586 + item_level = 1, -- 购买的道具等级
  1587 + order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
  1588 + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
  1589 + order_type = self:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0
  1590 + order_id = platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
  1591 + })
  1592 + end
  1593 +
  1594 + return true, rechargeId
  1595 + end
1500 1596  
1501 1597 -- 充值 --
1502 1598 --[[
... ... @@ -1511,63 +1607,37 @@ function RolePlugin.bind(Role)
1511 1607 local roleId = self:getProperty("id")
1512 1608 local partnerOrderStr = params.order
1513 1609  
1514   - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)")
1515   - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) })
1516   - if not orderObject:load() then
1517   - -- 订单不存在
1518   - skynet.error("ayncPurchaseRpc", string.format("order %s not exist", partnerOrderStr))
1519   - return
1520   - end
1521 1610  
1522   - if orderObject:getProperty("finishTime") > 0 then
1523   - -- 订单已经处理
1524   - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" }))
  1611 + local status, back = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh")
  1612 + if not status then
  1613 + if back == "finsh" then
  1614 + -- 订单已经处理
  1615 + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" }))
  1616 + end
1525 1617 return
1526 1618 end
1527   - local rechargeId = orderObject:getProperty("rechargeId")
  1619 + local rechargeId = back
1528 1620 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
1529 1621 if rechargeData.rmb ~= tonumber(params.amount) then
1530   - skynet.error(string.format("fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
  1622 + skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
1531 1623 params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount
1532 1624 ))
1533 1625 return
1534 1626 end
1535 1627  
1536   - local order_type = self:getProperty("rmbC") > 0 and 0 or 1
1537 1628 local status, reward = self:recharge({
1538 1629 id = rechargeId,
1539 1630 transactionId = params.transactionId,
1540 1631 pay_time = params.pay_time,
1541 1632 order = partnerOrderStr,
1542 1633 })
1543   - orderObject:setProperty("finishTime", skynet.time())
1544   - orderObject:setProperty("status", "finish")
1545   -
1546   - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr)
1547 1634  
1548 1635 if not status then
1549   - status = 200
1550   - else
1551   - status = 1000 + status
1552   - end
1553   - self:log("setOrder", {
1554   - order_status = status, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
1555   - item_id = rechargeId, -- 道具id
1556   - item_type = rechargeData.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
1557   - item_name = rechargeData.title, -- 购买的道具名
1558   - item_number = 1, -- 购买的道具数量
1559   - item_level = 1, -- 购买的道具等级
1560   - order_cost = rechargeData.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
1561   - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
1562   - order_type = order_type, -- 订单类型,首充记录为1,否则为0
1563   - order_id = params.transactionId, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
1564   - })
1565   - if status ~= 200 then return end
1566   -
1567   - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr,
1568   - result = "success", reward = reward}))
  1636 + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr,
  1637 + result = "success", reward = reward}))
  1638 + end
1569 1639  
1570   - return orderObject:getProperty("rechargeId")
  1640 + return rechargeId
1571 1641 end
1572 1642  
1573 1643  
... ... @@ -1575,7 +1645,7 @@ function RolePlugin.bind(Role)
1575 1645 local id = tonumber(params.id)
1576 1646 local rechargeData = csvdb["shop_rechargeCsv"][id]
1577 1647 if not rechargeData then
1578   - skynet.error("recharge id not exist", id)
  1648 + skynet.error("[recharge] recharge id not exist", id)
1579 1649 return 1
1580 1650 end
1581 1651  
... ... @@ -1600,7 +1670,7 @@ function RolePlugin.bind(Role)
1600 1670 elseif rechargeData.shop == 3 then -- 礼包商店
1601 1671 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
1602 1672 else
1603   - skynet.error("invalid recharge shop type " .. id)
  1673 + skynet.error("[recharge] invalid recharge shop type " .. id)
1604 1674 return 3
1605 1675 end
1606 1676  
... ...
src/models/RoleTimeReset.lua
... ... @@ -90,7 +90,7 @@ function Role:updateTimeReset(now, notify)
90 90 self:setProperties({timeReset = timeReset, ltime = now})
91 91  
92 92 response.timeReset = timeReset
93   - response.ltime = ltime
  93 + response.ltime = now
94 94  
95 95 if notify then
96 96 self:notifyUpdateProperties(response)
... ...
src/models/Store.lua
... ... @@ -224,9 +224,9 @@ end
224 224  
225 225 --检测购买是否超过限制数量
226 226 function Store:checkRechargeRecord(limit, id)
227   - local rechargeRecord = self:getProperty("payR")
  227 + local rechargeRecord = self:getProperty("payR") or {}
228 228 if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then
229   - skynet.error(string.format("recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id")))
  229 + skynet.error(string.format("[recharge] recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id")))
230 230 return false
231 231 end
232 232 rechargeRecord[id] = (rechargeRecord[id] or 0) + 1
... ... @@ -383,6 +383,7 @@ end
383 383 -- 购买付费签到 按开服时间算奖励
384 384 function Store:onBuyPaySignCard(dur)
385 385 local curTs = skynet.timex()
  386 + curTs = getServerOpenTs()
386 387  
387 388 self:SetActGoodsFlag("paySignIn", curTs)
388 389  
... ... @@ -419,7 +420,35 @@ function Store:checkPaySignReward()
419 420 end
420 421 end
421 422  
  423 +-- 临时用 登录触发限时礼包 时间点以后
  424 +function Store:OnTriggerLimitTimePackAfterTs(eventType, param)
  425 + local limitPack = self:getProperty("limitTPack")
  426 + local timeNow = skynet.timex()
  427 + local config = nil
  428 + for id, cfg in pairs(csvdb["shop_packCsv"]) do
  429 + local ts = toUnixtime(""..cfg.condition)
  430 + if cfg.type == eventType and ts < param then
  431 + config = cfg
  432 +
  433 + if config ~= nil then
  434 + local rechargeCfg = csvdb["shop_rechargeCsv"][config.packId]
  435 + if rechargeCfg then
  436 + if not limitPack[rechargeCfg.id] then
  437 + limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id}
  438 + self.owner:log("push_gift", {
  439 + gift_id = rechargeCfg.id, --礼包ID
  440 + gift_name = rechargeCfg.title, --礼包名称
  441 + })
  442 + self:updateProperty({field = "limitTPack", value = limitPack, notNotify = false})
  443 + end
  444 + end
  445 + end
  446 + end
  447 + end
  448 +end
  449 +
422 450 function Store:data()
  451 + self:OnTriggerLimitTimePackAfterTs(TriggerEventType.AfterTs, skynet.timex())
423 452 return {
424 453 buyR = self:getProperty("buyR"),
425 454 payR = self:getProperty("payR"),
... ...
src/utils/CommonFunc.lua
... ... @@ -167,7 +167,7 @@ function diffFromTs(ts)
167 167  
168 168 local time = os.time({year = tm.year, month = tm.month, day = tm.day, hour = RESET_TIME})
169 169 if now < time then
170   - return -1
  170 + return 0
171 171 end
172 172  
173 173 return math.floor((now - time) / DAY_SEC)
... ...