Commit 2dbe4fb9ebe21ce4526d3d47eff0696051923f7f
1 parent
3dbe0d5d
充值礼包自选部分逻辑
Showing
3 changed files
with
46 additions
and
8 deletions
Show diff stats
src/actions/StoreAction.lua
| ... | ... | @@ -7,12 +7,13 @@ function _M.rechargeRpc(agent , data) |
| 7 | 7 | local role = agent.role |
| 8 | 8 | local msg = MsgPack.unpack(data) |
| 9 | 9 | local id = msg.id |
| 10 | + local choose = msg.choose or "" | |
| 10 | 11 | local dataSet = csvdb["shop_rechargeCsv"][id] |
| 11 | 12 | if not dataSet then return end |
| 12 | 13 | local roleId = role:getProperty("id") |
| 13 | 14 | |
| 14 | 15 | --创建订单号 |
| 15 | - local partnerOrderId = role:getPurchaseOrder(id) | |
| 16 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) | |
| 16 | 17 | if partnerOrderId == "" then |
| 17 | 18 | return 1 |
| 18 | 19 | end |
| ... | ... | @@ -58,13 +59,14 @@ function _M.googleRechargeRpc(agent, data) |
| 58 | 59 | local role = agent.role |
| 59 | 60 | local msg = MsgPack.unpack(data) |
| 60 | 61 | local id = msg.id |
| 62 | + local choose = msg.choose or "" | |
| 61 | 63 | local dataSet = csvdb["shop_rechargeCsv"][id] |
| 62 | 64 | if not dataSet then return end |
| 63 | 65 | local roleId = role:getProperty("id") |
| 64 | 66 | |
| 65 | 67 | role.ignoreHeartbeat = true |
| 66 | 68 | --创建订单号 |
| 67 | - local partnerOrderId = role:getPurchaseOrder(id) | |
| 69 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) | |
| 68 | 70 | -- 签名 |
| 69 | 71 | local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" |
| 70 | 72 | local need = { |
| ... | ... | @@ -85,13 +87,14 @@ function _M.myCardRechargeRpc(agent, data) |
| 85 | 87 | local role = agent.role |
| 86 | 88 | local msg = MsgPack.unpack(data) |
| 87 | 89 | local id = msg.id |
| 90 | + local choose = msg.choose or "" | |
| 88 | 91 | local dataSet = csvdb["shop_rechargeCsv"][id] |
| 89 | 92 | if not dataSet then return end |
| 90 | 93 | local roleId = role:getProperty("id") |
| 91 | 94 | |
| 92 | 95 | role.ignoreHeartbeat = true |
| 93 | 96 | --创建订单号 |
| 94 | - local partnerOrderId = role:getPurchaseOrder(id) | |
| 97 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) | |
| 95 | 98 | -- 签名 |
| 96 | 99 | local secret_key = "48759e07540f46d9af17ec82669b4272" |
| 97 | 100 | local need = { |
| ... | ... | @@ -111,13 +114,14 @@ function _M.iosRechargeRpc(agent, data) |
| 111 | 114 | local role = agent.role |
| 112 | 115 | local msg = MsgPack.unpack(data) |
| 113 | 116 | local id = msg.id |
| 117 | + local choose = msg.choose or "" | |
| 114 | 118 | local dataSet = csvdb["shop_rechargeCsv"][id] |
| 115 | 119 | if not dataSet then return end |
| 116 | 120 | local roleId = role:getProperty("id") |
| 117 | 121 | |
| 118 | 122 | role.ignoreHeartbeat = true |
| 119 | 123 | --创建订单号 |
| 120 | - local partnerOrderId = role:getPurchaseOrder(id) | |
| 124 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) | |
| 121 | 125 | -- 签名 |
| 122 | 126 | local secret_key = "9647d2efe1074c73b9ac19af4337a70e" |
| 123 | 127 | local need = { | ... | ... |
src/models/Order.lua
| ... | ... | @@ -12,6 +12,7 @@ Order.schema = { |
| 12 | 12 | createTime = {"number", skynet.timex()}, -- 订单创建时间 |
| 13 | 13 | finishTime = {"number", 0}, -- 服务端验证完成时间 |
| 14 | 14 | status = {"string", "create"}, |
| 15 | + choose = {"string", ""}, -- 自选奖励 | |
| 15 | 16 | } |
| 16 | 17 | |
| 17 | 18 | Order.fields = { |
| ... | ... | @@ -21,6 +22,7 @@ Order.fields = { |
| 21 | 22 | createTime = true, |
| 22 | 23 | finishTime = true, |
| 23 | 24 | status = true, |
| 25 | + choose = true, | |
| 24 | 26 | } |
| 25 | 27 | |
| 26 | 28 | return Order |
| 27 | 29 | \ No newline at end of file | ... | ... |
src/models/RolePlugin.lua
| ... | ... | @@ -2013,7 +2013,7 @@ function RolePlugin.bind(Role) |
| 2013 | 2013 | return "error money" |
| 2014 | 2014 | end |
| 2015 | 2015 | -- 发现需要的id |
| 2016 | - local partnerOrderId = self:getPurchaseOrder(k, params.transactionId) | |
| 2016 | + local partnerOrderId = self:getPurchaseOrder(k, params.transactionId, params.choose) | |
| 2017 | 2017 | if partnerOrderId == "" then |
| 2018 | 2018 | return "no product" |
| 2019 | 2019 | end |
| ... | ... | @@ -2023,7 +2023,7 @@ function RolePlugin.bind(Role) |
| 2023 | 2023 | end |
| 2024 | 2024 | |
| 2025 | 2025 | -- 获取充值订单号 |
| 2026 | - function Role:getPurchaseOrder(rechargeId, transactionId) | |
| 2026 | + function Role:getPurchaseOrder(rechargeId, transactionId, choose) | |
| 2027 | 2027 | local roleId = self:getProperty("id") |
| 2028 | 2028 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] |
| 2029 | 2029 | if not rechargeData then |
| ... | ... | @@ -2035,6 +2035,25 @@ function RolePlugin.bind(Role) |
| 2035 | 2035 | if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then |
| 2036 | 2036 | return "" |
| 2037 | 2037 | end |
| 2038 | + | |
| 2039 | + -- 检查礼包自选奖励合法 | |
| 2040 | + if choose and choose ~= "" then | |
| 2041 | + if rechargeData.itemgift == "" then return "" end | |
| 2042 | + local slot = rechargeData.itemdirect or 0 | |
| 2043 | + local set = choose:toTableArray(true) | |
| 2044 | + if slot ~= #set then return "" end | |
| 2045 | + local pass = {} | |
| 2046 | + local groups = rechargeData.itemdirect:toTableArray(true) | |
| 2047 | + for _, item in ipairs(set) do | |
| 2048 | + for _, group in ipairs(groups) do | |
| 2049 | + if group[2] == item[1] and group[3] == item[2] then | |
| 2050 | + pass[group[1]] = 1 | |
| 2051 | + break | |
| 2052 | + end | |
| 2053 | + end | |
| 2054 | + end | |
| 2055 | + if #pass ~= slot then return "" end | |
| 2056 | + end | |
| 2038 | 2057 | |
| 2039 | 2058 | --判断是否是活动商品 |
| 2040 | 2059 | if rechargeData.activity_id ~= 0 then |
| ... | ... | @@ -2061,6 +2080,7 @@ function RolePlugin.bind(Role) |
| 2061 | 2080 | rechargeId = rechargeId, |
| 2062 | 2081 | createTime = skynet.timex(), |
| 2063 | 2082 | transactionId = transactionId, |
| 2083 | + choose = choose or "", | |
| 2064 | 2084 | }) |
| 2065 | 2085 | order:create() |
| 2066 | 2086 | -- 正在进行中的订单 缓存 |
| ... | ... | @@ -2128,7 +2148,7 @@ function RolePlugin.bind(Role) |
| 2128 | 2148 | }) |
| 2129 | 2149 | end |
| 2130 | 2150 | |
| 2131 | - return true, rechargeId | |
| 2151 | + return true, rechargeId, orderObject:getProperty("choose") | |
| 2132 | 2152 | end |
| 2133 | 2153 | |
| 2134 | 2154 | -- 充值 -- |
| ... | ... | @@ -2146,7 +2166,7 @@ function RolePlugin.bind(Role) |
| 2146 | 2166 | local roleId = self:getProperty("id") |
| 2147 | 2167 | local partnerOrderStr = params.order |
| 2148 | 2168 | |
| 2149 | - local status, back = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh") | |
| 2169 | + local status, back, choose = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh") | |
| 2150 | 2170 | if not status then |
| 2151 | 2171 | if back == "finsh" then |
| 2152 | 2172 | -- 订单已经处理 |
| ... | ... | @@ -2168,6 +2188,7 @@ function RolePlugin.bind(Role) |
| 2168 | 2188 | transactionId = params.transactionId, |
| 2169 | 2189 | pay_time = params.pay_time, |
| 2170 | 2190 | order = partnerOrderStr, |
| 2191 | + choose = choose, | |
| 2171 | 2192 | }) |
| 2172 | 2193 | |
| 2173 | 2194 | if not status then |
| ... | ... | @@ -2215,6 +2236,17 @@ function RolePlugin.bind(Role) |
| 2215 | 2236 | return 3 |
| 2216 | 2237 | end |
| 2217 | 2238 | |
| 2239 | + -- 自选奖励部分 | |
| 2240 | + if params.choose and params.choose ~= "" then | |
| 2241 | + local tReward, tChange = self:award(params.choose, {log = {desc = "recharge", int1 = id}}) | |
| 2242 | + for itemId, value in pairs(tReward) do | |
| 2243 | + reward[itemId] = (reward[itemId] or 0) + value | |
| 2244 | + end | |
| 2245 | + for itemId, value in pairs(tChange) do | |
| 2246 | + reward[itemId] = (reward[itemId] or 0) + value | |
| 2247 | + end | |
| 2248 | + end | |
| 2249 | + | |
| 2218 | 2250 | if diamondCount > 0 then |
| 2219 | 2251 | reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount |
| 2220 | 2252 | end | ... | ... |