Commit 3fbbd115dc90321b21f4430d0ad43ba00f70db15

Authored by chenyueqi
2 parents 34b196c0 d9d63fa0

Merge branch 'tr/develop' into cn/develop

src/actions/ActivityAction.lua
... ... @@ -140,6 +140,13 @@ function _M.signRpc(agent, data)
140 140 role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}})
141 141 role:checkTaskEnter("SignIn")
142 142  
  143 + if monthData[curDay].daily_sign_email ~= "" then
  144 + local emails = monthData[curDay].daily_sign_email:toArray(true,"=")
  145 + for _, emailId in pairs(emails) do
  146 + redisproxy:insertEmail({roleId = role:getProperty("id"), emailId = emailId})
  147 + end
  148 + end
  149 +
143 150 SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(role:packReward(reward, change)))
144 151 return true
145 152 end
... ...
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
... ... @@ -161,13 +162,14 @@ function _M.googleRechargeRpc(agent, data)
161 162 local role = agent.role
162 163 local msg = MsgPack.unpack(data)
163 164 local id = msg.id
  165 + local choose = msg.choose or ""
164 166 local dataSet = csvdb["shop_rechargeCsv"][id]
165 167 if not dataSet then return end
166 168 local roleId = role:getProperty("id")
167 169  
168 170 role.ignoreHeartbeat = true
169 171 --创建订单号
170   - local partnerOrderId = role:getPurchaseOrder(id)
  172 + local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
171 173 -- 签名
172 174 -- local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075"
173 175 local secret_key = "8920e9dcf0cb4ebca87393ce48021ead"
... ... @@ -189,13 +191,14 @@ function _M.myCardRechargeRpc(agent, data)
189 191 local role = agent.role
190 192 local msg = MsgPack.unpack(data)
191 193 local id = msg.id
  194 + local choose = msg.choose or ""
192 195 local dataSet = csvdb["shop_rechargeCsv"][id]
193 196 if not dataSet then return end
194 197 local roleId = role:getProperty("id")
195 198  
196 199 role.ignoreHeartbeat = true
197 200 --创建订单号
198   - local partnerOrderId = role:getPurchaseOrder(id)
  201 + local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
199 202 -- 签名
200 203 local secret_key = "48759e07540f46d9af17ec82669b4272"
201 204 local need = {
... ... @@ -215,13 +218,14 @@ function _M.iosRechargeRpc(agent, data)
215 218 local role = agent.role
216 219 local msg = MsgPack.unpack(data)
217 220 local id = msg.id
  221 + local choose = msg.choose or ""
218 222 local dataSet = csvdb["shop_rechargeCsv"][id]
219 223 if not dataSet then return end
220 224 local roleId = role:getProperty("id")
221 225  
222 226 role.ignoreHeartbeat = true
223 227 --创建订单号
224   - local partnerOrderId = role:getPurchaseOrder(id)
  228 + local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
225 229 -- 签名
226 230 local secret_key = "1916d62251dd4a8aa5e452121eefc9a1"
227 231 local need = {
... ...
src/models/Order.lua
... ... @@ -13,6 +13,7 @@ Order.schema = {
13 13 finishTime = {"number", 0}, -- 服务端验证完成时间
14 14 status = {"string", "create"},
15 15 sid = {"number",0}, -- 创建单号的设备的sid
  16 + choose = {"string", ""}, -- 自选奖励
16 17 }
17 18  
18 19 Order.fields = {
... ... @@ -23,6 +24,7 @@ Order.fields = {
23 24 finishTime = true,
24 25 status = true,
25 26 sid = true,
  27 + choose = true,
26 28 }
27 29  
28 30 return Order
29 31 \ No newline at end of file
... ...
src/models/RolePlugin.lua
... ... @@ -1349,8 +1349,7 @@ function RolePlugin.bind(Role)
1349 1349 local donate = seaport.donate or {}
1350 1350 if not reset and (not donate[1] or not donate[2]) then
1351 1351 local result = self:getSeaportServerProgress()
1352   - local seaportCsv = csvdb["seaport_purchaseCsv"]
1353   - for idx, set in ipairs(seaportCsv) do
  1352 + for idx, set in ipairs(csvdb["seaport_purchaseCsv"]) do
1354 1353 local done = true
1355 1354 for id, data in ipairs(set) do
1356 1355 if donate[id] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then
... ... @@ -1360,7 +1359,12 @@ function RolePlugin.bind(Role)
1360 1359 end
1361 1360 if done then
1362 1361 update = true
1363   - self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}})
  1362 + redisproxy:insertEmail({
  1363 + roleId = self:getProperty("id"),
  1364 + emailId = idx == 1 and 361 or 362,
  1365 + attachments = set[1].phase_award,
  1366 + })
  1367 + -- self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}})
1364 1368 donate[idx] = 1
1365 1369 end
1366 1370 end
... ... @@ -1397,6 +1401,8 @@ function RolePlugin.bind(Role)
1397 1401 local expCarbonId = self:getProperty("hangInfo").expCarbonId
1398 1402 local taskCsv = csvdb["seaport_taskCsv"]
1399 1403 local endTime = openTime0 + 86400 * 2
  1404 + local reward = {}
  1405 +
1400 1406 for slot, set in pairs(taskCsv) do
1401 1407 if collect[slot] then
1402 1408 update = true
... ... @@ -1433,9 +1439,28 @@ function RolePlugin.bind(Role)
1433 1439 itemReward[key] = math.ceil(1.5 * value)
1434 1440 end
1435 1441 end
1436   - self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}})
  1442 +
  1443 + for itemId, value in pairs(itemReward) do
  1444 + reward[itemId] = (reward[itemId] or 0) + value
  1445 + end
  1446 + -- self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}})
  1447 + end
  1448 + end
  1449 + end
  1450 +
  1451 + if next(reward) then
  1452 + local rewardStr = ""
  1453 + for itemId, value in pairs(reward) do
  1454 + if rewardStr ~= "" then
  1455 + rewardStr = rewardStr .. " "
1437 1456 end
  1457 + rewardStr = rewardStr .. string.format("%s=%s",itemId,value)
1438 1458 end
  1459 + redisproxy:insertEmail({
  1460 + roleId = self:getProperty("id"),
  1461 + emailId = 363,
  1462 + attachments = rewardStr,
  1463 + })
1439 1464 end
1440 1465 end
1441 1466 seaport.collect = {}
... ... @@ -2022,7 +2047,7 @@ function RolePlugin.bind(Role)
2022 2047 return "error money"
2023 2048 end
2024 2049 -- 发现需要的id
2025   - local partnerOrderId = self:getPurchaseOrder(k, params.transactionId)
  2050 + local partnerOrderId = self:getPurchaseOrder(k, params.transactionId, params.choose)
2026 2051 if partnerOrderId == "" then
2027 2052 return "no product"
2028 2053 end
... ... @@ -2032,7 +2057,7 @@ function RolePlugin.bind(Role)
2032 2057 end
2033 2058  
2034 2059 -- 获取充值订单号
2035   - function Role:getPurchaseOrder(rechargeId, transactionId)
  2060 + function Role:getPurchaseOrder(rechargeId, transactionId, choose)
2036 2061 local roleId = self:getProperty("id")
2037 2062 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
2038 2063 if not rechargeData then
... ... @@ -2044,7 +2069,24 @@ function RolePlugin.bind(Role)
2044 2069 if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then
2045 2070 return ""
2046 2071 end
2047   -
  2072 + -- 检查礼包自选奖励合法
  2073 + if choose and choose ~= "" then
  2074 + if rechargeData.itemgift == "" then return "" end
  2075 + local slot = rechargeData.itemdirect or 0
  2076 + local set = choose:toTableArray(true)
  2077 + if slot ~= #set then return "" end
  2078 + local pass = {}
  2079 + local groups = rechargeData.itemgift:toTableArray(true)
  2080 + for idx, item in ipairs(set) do
  2081 + for _, group in ipairs(groups) do
  2082 + if group[2] == item[1] and group[3] == item[2] and idx == group[1] then
  2083 + pass[group[1]] = 1
  2084 + break
  2085 + end
  2086 + end
  2087 + end
  2088 + if #pass ~= slot then return "" end
  2089 + end
2048 2090 --判断是否是活动商品
2049 2091 if rechargeData.activity_id ~= 0 then
2050 2092 local actCfg = csvdb["activity_ctrlCsv"][rechargeData.activity_id]
... ... @@ -2071,6 +2113,7 @@ function RolePlugin.bind(Role)
2071 2113 createTime = skynet.timex(),
2072 2114 transactionId = transactionId,
2073 2115 sid = self:getProperty("sid"),
  2116 + choose = choose or "",
2074 2117 })
2075 2118 order:create()
2076 2119 -- 正在进行中的订单 缓存
... ... @@ -2139,7 +2182,7 @@ function RolePlugin.bind(Role)
2139 2182 })
2140 2183 end
2141 2184  
2142   - return true, rechargeId, sid
  2185 + return true, rechargeId, sid, orderObject:getProperty("choose")
2143 2186 end
2144 2187  
2145 2188 -- 充值 --
... ... @@ -2157,7 +2200,7 @@ function RolePlugin.bind(Role)
2157 2200 local roleId = self:getProperty("id")
2158 2201 local partnerOrderStr = params.order
2159 2202  
2160   - local status, back, sid = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh")
  2203 + local status, back, sid, choose = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh")
2161 2204 if not status then
2162 2205 if back == "finsh" then
2163 2206 -- 订单已经处理
... ... @@ -2180,6 +2223,7 @@ function RolePlugin.bind(Role)
2180 2223 pay_time = params.pay_time,
2181 2224 order = partnerOrderStr,
2182 2225 sid = sid,
  2226 + choose = choose,
2183 2227 })
2184 2228  
2185 2229 if not status then
... ... @@ -2227,6 +2271,17 @@ function RolePlugin.bind(Role)
2227 2271 return 3
2228 2272 end
2229 2273  
  2274 + -- 自选奖励部分
  2275 + if params.choose and params.choose ~= "" then
  2276 + local tReward, tChange = self:award(params.choose, {log = {desc = "recharge", int1 = id}})
  2277 + for itemId, value in pairs(tReward) do
  2278 + reward[itemId] = (reward[itemId] or 0) + value
  2279 + end
  2280 + for itemId, value in pairs(tChange or {}) do
  2281 + reward[itemId] = (reward[itemId] or 0) + value
  2282 + end
  2283 + end
  2284 +
2230 2285 if diamondCount > 0 then
2231 2286 reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount
2232 2287 end
... ...
src/services/globald.lua
... ... @@ -184,6 +184,67 @@ local function check_trade_seaport_status()
184 184 skynet.timeout(interval, check_trade_seaport_status)
185 185 end
186 186  
  187 +-- @desc: 海港贸易捐赠作弊
  188 +local seaportTimes = {}
  189 +local function check_trade_seaport_donate()
  190 + local time1 = tonumber(redisproxy:hget("autoincrement_set", "seaportTime1")) or 0
  191 + local time2 = tonumber(redisproxy:hget("autoincrement_set", "seaportTime2")) or 0
  192 + if time1 == 0 and time2 == 0 then
  193 + seaportTimes = {}
  194 + skynet.timeout(360000, check_trade_seaport_donate)
  195 + return
  196 + end
  197 +
  198 + local csvdb = require "shared.csvdata"
  199 + local donateCsv = csvdb["seaport_purchaseCsv"]
  200 +
  201 + local times = {time1, time2}
  202 + for phase, open in ipairs(times) do
  203 + if open == 1 and not seaportTimes[phase] then
  204 + seaportTimes[phase] = {}
  205 + for _, _ in ipairs(donateCsv[phase]) do
  206 + table.insert(seaportTimes[phase],math.randomInt(1800, 3600))
  207 + end
  208 + end
  209 + end
  210 +
  211 + local interval = 3600
  212 + local phase, id = 0, 0
  213 +
  214 + for key1, data in ipairs(seaportTimes) do
  215 + for key2, temp in pairs(data) do
  216 + if times[key1] == 1 and temp < interval then
  217 + interval = temp
  218 + phase = key1
  219 + id = key2
  220 + end
  221 + end
  222 + end
  223 +
  224 + for _, data in ipairs(seaportTimes) do
  225 + for id, temp in pairs(data) do
  226 + data[id] = temp - interval
  227 + if data[id] == 0 then
  228 + data[id] = math.randomInt(1800, 3600)
  229 + end
  230 + end
  231 + end
  232 +
  233 + if phase ~= 0 and id ~= 0 then
  234 + local redisKeys = {SEAPORT_TRADE_TASK_1,SEAPORT_TRADE_TASK_2}
  235 + local all = donateCsv[phase][id].need_num
  236 + local old = tonumber(redisproxy:hget(redisKeys[phase],id)) or 0
  237 + local add = math.min(math.randomInt(math.floor(all/20),math.floor(all/12)),all - old)
  238 + if add > 0 then
  239 + redisproxy:hincrby(redisKeys[phase],id,add)
  240 + else
  241 + seaportTimes[phase][id] = nil
  242 + end
  243 + end
  244 +
  245 + skynet.timeout(interval * 100, check_trade_seaport_donate)
  246 +end
  247 +
187 248 local CMD = {}
188 249  
189 250  
... ... @@ -208,6 +269,7 @@ function CMD.start()
208 269 check_mail_queue()
209 270 --check_battle_act_close()
210 271 check_trade_seaport_status()
  272 + check_trade_seaport_donate()
211 273 end
212 274  
213 275 local function __init__()
... ...