Commit 7e61a962c7049616cc70796db9a6c9eac91f6a37

Authored by liuzujun
1 parent e9c1df55

新增通用生成订单协议,

上报登录等处消息到中宣
苹果支付回调修改
src/ProtocolCode.lua
... ... @@ -232,6 +232,7 @@ actionCodes = {
232 232 Store_getTotalRechargeAwardRpc = 564, -- 累计充值
233 233 Store_monthCardRewardRpc = 565, --每日月卡+特刊奖励
234 234 Store_dyhxAndroidRechargeRpc = 566, -- 东银河充值
  235 + Store_getCpOrderIdRpc = 567, -- 生成充值订单号
235 236  
236 237 Store_biliCloudRechargeRpc = 596,
237 238 Store_biliAndroidRechargeRpc = 597,
... ...
src/actions/RoleAction.lua
... ... @@ -334,6 +334,7 @@ function _M.loginRpc( agent, data )
334 334  
335 335 local hangPass = role:getProperty("hangPass")
336 336 role:mylog("login", {key1 = agent.ip:toArray(false, ":")[1], int1 = hangPass[1] or 0})
  337 + role:onUploadLoginout(1, agent.client_fd)
337 338  
338 339 -- 是否是新设备
339 340 local deviced = cluster.query("center", "deviced")
... ...
src/actions/StoreAction.lua
... ... @@ -280,6 +280,37 @@ function _M.dyhxAndroidRechargeRpc(agent, data)
280 280 return true
281 281 end
282 282  
  283 +local rechargeHandler = {
  284 + ali = function(cp_order_id, rechargeId, result)
  285 + end,
  286 + wx = function(cp_order_id, rechargeId, result)
  287 + end,
  288 +}
  289 +
  290 +function _M.getCpOrderIdRpc(agent, data)
  291 + local role = agent.role
  292 + local msg = MsgPack.unpack(data)
  293 + local id = msg.id
  294 + local type = msg.skd_type or ""
  295 + local choose = msg.choose or ""
  296 + local dataSet = csvdb["shop_rechargeCsv"][id]
  297 + if not dataSet then return end
  298 + local roleId = role:getProperty("id")
  299 +
  300 + role.ignoreHeartbeat = true
  301 + --创建订单号
  302 + local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
  303 +
  304 + local result = {}
  305 + result["order"] = partnerOrderId
  306 + local handler = rechargeHandler[type]
  307 + if handler then
  308 + handler(partnerOrderId, id, result)
  309 + end
  310 +
  311 + SendPacket(actionCodes.Store_getCpOrderIdRpc, MsgPack.pack(result))
  312 +end
  313 +
283 314  
284 315 function _M.purchaseOrderResult(agent, data)
285 316 local role = agent.role
... ...
src/agent.lua
... ... @@ -295,6 +295,7 @@ function CMD.close()
295 295 role:log("onLogout", {logtime = skynet.timex()-role:getProperty("ltime")})
296 296 role:mylog("logout", {int1 = skynet.timex()-role:getProperty("ltime")})
297 297 role:onOfflineEvent()
  298 + role:onUploadLoginout(0, agentInfo.client_fd)
298 299 end
299 300  
300 301 function CMD.exit()
... ...
src/models/RolePlugin.lua
... ... @@ -36,6 +36,26 @@ function RolePlugin.bind(Role)
36 36 self:saveRoleData()
37 37 end
38 38  
  39 + -- 上报中宣数据
  40 + function Role:onUploadLoginout(bt, session)
  41 + local uid = self:getProperty("uid")
  42 + local id = self:getProperty("id")
  43 + local time = skynet.timex()
  44 + local si = string.format("%s_%s", id, session)
  45 + local info = {{si = si, bt = bt, ot = time}}
  46 +
  47 + local codeurl = skynet.getenv("codeurl")
  48 + local content = {
  49 + ["si"] = si,
  50 + ["bt"] = bt,
  51 + ["ot"] = time,
  52 + ["uid"] = uid,
  53 + ["key"] = "zhaolugame20170831",
  54 + }
  55 + dump(content)
  56 + httpc.get(codeurl, "/collect?" .. httpGetFormatData(content), {})
  57 + end
  58 +
39 59 local function checkItemCount(self, itemId, count)
40 60 local itemData = csvdb["itemCsv"][itemId]
41 61 -- 种类 类型数量限制
... ... @@ -2410,11 +2430,20 @@ function RolePlugin.bind(Role)
2410 2430 end
2411 2431 local rechargeId = back
2412 2432 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
2413   - if (params.is_mycard and rechargeData.twd * 100 ~= tonumber(params.amount)) or (not params.is_mycard and ((rechargeData.rmb * 100) / globalCsv.QArecharge) ~= tonumber(params.amount)) then
2414   - skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
2415   - params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount
2416   - ))
2417   - return
  2433 + if params.amount == 0 then
  2434 + if params.product_id ~= rechargeData.iap_product_id then
  2435 + skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
  2436 + params.transactionId, roleId, partnerOrderStr, rechargeData.iap_product_id, params.product_id
  2437 + ))
  2438 + return
  2439 + end
  2440 + else
  2441 + if (params.is_mycard and rechargeData.twd * 100 ~= tonumber(params.amount)) or (not params.is_mycard and ((rechargeData.rmb * 100) / globalCsv.QArecharge) ~= tonumber(params.amount)) then
  2442 + skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
  2443 + params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount
  2444 + ))
  2445 + return
  2446 + end
2418 2447 end
2419 2448  
2420 2449 local status, reward = self:recharge({
... ...