You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5637 lines
191 KiB

  1. -- PHP文档地址,用户名:dd 密码:ddtech
  2. -- http://120.76.238.236:8999/wiki/index.php?title=%E9%A6%96%E9%A1%B5
  3. local Cmd = require("luaScript.Protocol.Club.ClubCmd")
  4. local ClubProtocolPhp = class("ClubProtocolPhp")
  5. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  6. function ClubProtocolPhp:ctor()
  7. -- 添加分发事件的组件
  8. cc.GameObject.extend(self)
  9. self:addComponent(require("luaScript.cc.components.behavior.EventProtocol"):new()):exportMethods()
  10. -- 监听推送事件
  11. app:addEventListener("onPhpMessage", handler(self, self.onPhpMessage))
  12. --俱乐部列表
  13. self.clubList = {}
  14. self.selectGameId = -1
  15. self.selectBaoJianId = -1
  16. self.bChangeTable = false
  17. -- CEST
  18. self.clubCestInfo = {}
  19. self.tiantiInfo = {}
  20. end
  21. function ClubProtocolPhp:getMatchIsOpen(clubId)
  22. if not clubId then
  23. return false
  24. end
  25. if not self.clubList[tonumber(clubId)] then
  26. return false
  27. end
  28. local isArena = self.clubList[tonumber(clubId)].isArena
  29. return toNumber(isArena) == ClubDefine.MATCH_SWITCH.CLIENT_OPEN or toNumber(isArena) == ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_OPEN
  30. end
  31. function ClubProtocolPhp:getCestIsOpen(clubId)
  32. if not clubId then
  33. return false
  34. end
  35. if not self.clubList[tonumber(clubId)] then
  36. return false
  37. end
  38. local isArena = self.clubList[tonumber(clubId)].isArena
  39. return toNumber(isArena) == ClubDefine.MATCH_SWITCH.PEOPLE_CEST_OPEN
  40. end
  41. function ClubProtocolPhp:setCestFirst(clubId, bool)
  42. self.clubList[tonumber(clubId)].isFirst = bool
  43. end
  44. function ClubProtocolPhp:getCestFirst(clubId)
  45. if not clubId then
  46. return false
  47. end
  48. if not self.clubList[tonumber(clubId)] then
  49. return false
  50. end
  51. return self.clubList[tonumber(clubId)].isFirst
  52. end
  53. function ClubProtocolPhp:getIsQuanMinSai(clubId)
  54. if not clubId then
  55. return false
  56. end
  57. if not self.clubList[tonumber(clubId)] then
  58. return false
  59. end
  60. local isArena = self.clubList[tonumber(clubId)].isArena
  61. return toNumber(isArena) >= ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_OPEN
  62. end
  63. --判断是否是主盟
  64. function ClubProtocolPhp:getIsMasterUnion(clubId)
  65. if not clubId then
  66. return false
  67. end
  68. if not self.clubList[tonumber(clubId)] then
  69. return false
  70. end
  71. local isMasterUnion = self.clubList[tonumber(clubId)].groupext and (self.clubList[tonumber(clubId)].groupext.master_union == 2) or false
  72. return isMasterUnion
  73. end
  74. --判断是否是副盟
  75. function ClubProtocolPhp:getIsSlaveUnion(clubId)
  76. if not clubId then
  77. return false
  78. end
  79. if not self.clubList[tonumber(clubId)] then
  80. return false
  81. end
  82. local isMasterUnion = self.clubList[tonumber(clubId)].groupext and (self.clubList[tonumber(clubId)].groupext.slave_union == 2) or false
  83. return isMasterUnion
  84. end
  85. --判断是否是合盟
  86. function ClubProtocolPhp:getIsUnion(clubId)
  87. if not clubId then
  88. return false
  89. end
  90. if not self.clubList[tonumber(clubId)] then
  91. return false
  92. end
  93. if self:getIsMasterUnion(clubId) or self:getIsSlaveUnion(clubId) then
  94. return true
  95. else
  96. return false
  97. end
  98. end
  99. --判断是否有合盟开启权限
  100. function ClubProtocolPhp:getUnionPower(clubId)
  101. if not clubId then
  102. return false
  103. end
  104. if not self.clubList[tonumber(clubId)] then
  105. return false
  106. end
  107. local groupext = self.clubList[tonumber(clubId)].groupext
  108. local master_union = groupext and (groupext.master_union or 0) or 0
  109. local slave_union = groupext and (groupext.slave_union or 0) or 0
  110. local isMasterUnion = master_union >= 1
  111. local isSlaveUnion = slave_union >= 1
  112. if isMasterUnion or isSlaveUnion then
  113. return true
  114. else
  115. return false
  116. end
  117. end
  118. function ClubProtocolPhp:setSelectGameId(selectGameId)
  119. self.selectGameId = selectGameId
  120. end
  121. function ClubProtocolPhp:getSelectGameId()
  122. return self.selectGameId
  123. end
  124. function ClubProtocolPhp:setSelectBaoJianId(selectBaoJianId)
  125. self.selectBaoJianId = selectBaoJianId
  126. end
  127. function ClubProtocolPhp:getSelectBaoJianId()
  128. return self.selectBaoJianId
  129. end
  130. --快速组局包间
  131. function ClubProtocolPhp:setChangeTable(bChangeTable)
  132. self.bChangeTable = bChangeTable
  133. end
  134. function ClubProtocolPhp:getIsChangeTable()
  135. return self.bChangeTable
  136. end
  137. --bTopTip:true使用顶部tips
  138. function ClubProtocolPhp:showError(cmd,response,bTopTip)
  139. if response.error and response.error~="" then
  140. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  141. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  142. response.error = string.gsub(response.error, "玩家", "选手")
  143. end
  144. end
  145. if bTopTip then
  146. showTooltip(response.error)
  147. else
  148. showConfirmDialog(response.error,response.okCallBack,response.cancelCallBack)
  149. end
  150. else
  151. local code = response.code
  152. if code then
  153. if ClubDefine.Error[cmd] and ClubDefine.Error[cmd][code] then
  154. ClubDefine.Error[cmd][code] = string.gsub(ClubDefine.Error[cmd][code],"茶馆", "海选赛")
  155. if bTopTip then
  156. showTooltip(ClubDefine.Error[cmd][code])
  157. else
  158. showConfirmDialog(ClubDefine.Error[cmd][code],response.okCallBack,response.cancelCallBack)
  159. end
  160. else
  161. showConfirmDialog("错误码:"..code)
  162. end
  163. else
  164. showTooltip("未知错误!")
  165. end
  166. end
  167. end
  168. --发送请求
  169. function ClubProtocolPhp:post(action, param, callback)
  170. local phpAddress = getGlobalPhpUrl()
  171. local msg = {}
  172. msg.action = action
  173. msg.uid = app.user.loginInfo.uid
  174. msg.app = getAppId()
  175. if param then
  176. table.merge(msg,param)
  177. end
  178. httpPost(phpAddress, msg, function(status, response)
  179. app.waitDialogManager:closeWaitNetworkDialog()
  180. if status ~= "successed" then
  181. showPHPFailedResult("获取数据失败! status = " .. tostring(status))
  182. else
  183. local jsonData = json.decode(response)
  184. if not jsonData or type(jsonData) ~= "table" then
  185. showPHPFailedResult("返回数据异常! response = " .. tostring(response))
  186. else
  187. if callback then
  188. callback(jsonData)
  189. else
  190. error("callback is nil")
  191. end
  192. end
  193. end
  194. end)
  195. end
  196. --更新俱乐部数据
  197. function ClubProtocolPhp:updateClub(v,bAll)
  198. local club = nil
  199. if bAll then
  200. if not self.clubListAll[tonumber(v.gid)] then
  201. self.clubListAll[tonumber(v.gid)] = {}
  202. end
  203. club = self.clubListAll[tonumber(v.gid)]
  204. else
  205. if not self.clubList[tonumber(v.gid)] then
  206. self.clubList[tonumber(v.gid)] = {}
  207. end
  208. club = self.clubList[tonumber(v.gid)]
  209. end
  210. club.clubId = tonumber(v.gid) or club.clubId
  211. club.clubName = v.gname or club.clubName
  212. club.ownerId = v.owner and tonumber(v.owner) or club.ownerId
  213. club.playerNum = v.gnum and tonumber(v.gnum) or club.playerNum
  214. if v.ismanage then
  215. club.isManager = tonumber(v.ismanage)==1 --当前玩家请求茶馆列表是否管理员:1是,0否
  216. end
  217. club.role =v.role and tonumber(v.role) or club.role --1:成员 2:管理员 3:创始人
  218. club.ownerName = v.ownernick or club.ownerName --管理员昵称
  219. club.ownerSex = v.sex or club.ownerSex --管理员性别
  220. club.strOwnerHeadUrl = v.ownerhead or club.strOwnerHeadUrl --管理员头像地址
  221. club.mode = v.room_mode and tonumber(v.room_mode) or club.mode --房间模式修改1多玩法模式0包间模式
  222. if v.hints then
  223. club.isHints = tonumber(v.hints)==1 --1:有消息红点 0:无消息红点
  224. end
  225. if v.unionhints then
  226. club.isUnionHints = tonumber(v.unionhints)==1 --1:有消息红点 0:无消息红点
  227. end
  228. club.stickyTime = v.sticky_time or club.stickyTime --置顶时间
  229. club.onlineRoomNum = v.onlineroom and tonumber(v.onlineroom) or club.onlineRoomNum or 0 --在线桌数
  230. if v.is_apply then
  231. club.isApply = tonumber(v.is_apply) == 1 --加入茶馆是否需要审核。1需要申请,0无需申请
  232. end
  233. if v.is_exitapply then
  234. club.isExitApply = tonumber(v.is_exitapply) == 1 --退出茶馆是否需要审核。1需要申请,0无需申请
  235. end
  236. club.status = v.status and tonumber(v.status) or club.status --1正常2冻结
  237. club.onlinePlayerNum = v.onlinemember and tonumber(v.onlinemember) or club.onlinePlayerNum --在线人数
  238. club.playWinScore = v.play_win_threshold and tonumber(v.play_win_threshold) or club.playWinScore or 0
  239. --俱乐部公告
  240. club.notice = v.notice or ""
  241. club.noticeInfo = v.noticeInfo or {}
  242. club.rooms = club.rooms or {} --初始房间列表
  243. club.posList = club.posList or {} --初始房间pos列表
  244. club.baoJians = club.baoJians or {} --初始包间列表
  245. club.config = v.config or club.config or {}
  246. club.ext = v.ext or club.ext or {}
  247. club.players = club.players or {} --初始成员列表
  248. club.playersLevelOne = club.playersLevelOne or {} --初始一级(队长)合伙人成员列表
  249. club.playersLevelTwo = club.playersLevelTwo or {} --初始二级(小队长)合伙人成员列表
  250. club.playersLevelThree = club.playersLevelThree or {} --初始三级(小组长)合伙人成员列表
  251. club.playersMatch = club.playersMatch or {} --初始二级合伙人成员列表
  252. club.unionPlayerList = club.unionPlayerList or {} --合盟亲友圈列表
  253. --排名赛总数据(数据下分各个模块数据)玩家的数据和players保持一样,根据viewType状态机区分
  254. club.allPeopleMatch = club.allPeopleMatch or {}
  255. if v.is_coapply then
  256. club.isCoapply = tonumber(v.is_coapply)==1 --合伙人添加成员是否需要审核。1需要申请,0无需申请
  257. end
  258. --比赛场:0亲友圈关闭,亲友圈功能隐藏,1功能关闭, 创始人可见,2功能开启, 创始人可见
  259. club.isArena = tonumber(v.is_arena) or club.is_arena
  260. --0 无需处理; 1 上级发起取消当前合伙人权限通知(弹框)
  261. club.cancelCopartner = v.cancelCopartner or club.cancelCopartner
  262. --个人可用红花
  263. club.memberInfo = (v.memberInfo) or (club.memberInfo)
  264. club.club_bgprop = v.prop or club.club_bgprop or {} --亲友圈背景数据
  265. club.groupext = v.groupext or club.groupext or {} --亲友圈群特性
  266. club.activeGames = v.activeGames or club.activeGames or {} --亲友圈激活的游戏
  267. club.isplaying = v.isplaying or club.isplaying or false --是否在游戏内
  268. club.groupLevel = v.group_level or club.groupLevel or 1 --队长等级(亲友圈等级)
  269. club.noticeList = v.noticeList or {}
  270. --兼容旧的:隐私战绩 开启后只有创世人和管理员能看到战绩
  271. if club.groupext.cliext then
  272. club.isGamb = club.groupext.cliext.is_gamb == 1
  273. else
  274. club.isGamb = tonumber(v.is_gamb) == 1
  275. end
  276. --兼容旧的:微信分享1禁止微信分享0关闭
  277. if club.groupext.cliext then
  278. club.isWxshare = club.groupext.cliext.is_wxshare == 1
  279. else
  280. club.isWxshare = tonumber(v.is_wxshare) == 1
  281. end
  282. --初始化默认值
  283. if not club.groupext.cliext then
  284. club.groupext.cliext = {}
  285. end
  286. if table.nums(club.groupext.cliext) == 0 or (not club.groupext.cliext.is_privacy)
  287. or (not club.groupext.cliext.is_teamHide) or (not club.groupext.cliext.is_managerHide) then
  288. club.groupext.cliext.is_privacy = 1
  289. club.groupext.cliext.is_teamHide = 1
  290. club.groupext.cliext.is_managerHide = 1
  291. club.groupext.cliext.is_hideCreator = 1
  292. club.groupext.cliext.is_hideBelong = 1
  293. end
  294. -- 隐藏茶馆id
  295. if not club.groupext.cliext.is_hideGid then
  296. club.groupext.cliext.is_hideGid = 0
  297. end
  298. -- 隐藏游戏内选手id
  299. if not club.groupext.cliext.is_hideUid then
  300. club.groupext.cliext.is_hideUid = 0
  301. end
  302. club.isPrivacy = club.groupext.cliext.is_privacy == 1
  303. --合盟开关
  304. club.unionType = tonumber(v.unionType) --0未开启,1代表自己是主盟,2副盟已进入合盟状态
  305. club.unionGid = tonumber(v.unionGid)--unionType是2的情况下,合盟时显示主盟字段
  306. club.unionOwner = tonumber(v.unionOwner)--unionType是2的情况下,合盟时显示uid字段
  307. --小组长开关
  308. club.isCopartner7 = v.is_copartner7 or club.isCopartner7 or 0
  309. app.config.ModuleConfig.IsSupportThirdCopartner = club.isCopartner7 == 1
  310. end
  311. --更新俱乐部设置
  312. function ClubProtocolPhp:updateClubSettings(clubId,settings)
  313. if not self.clubList[tonumber(clubId)] then
  314. --self.clubList[tonumber(clubId)] = {}
  315. return
  316. end
  317. local club = self.clubList[tonumber(clubId)]
  318. if not settings or table.nums(settings)==0 then
  319. club.settings={}
  320. return
  321. end
  322. if not club.settings then
  323. club.settings={}
  324. end
  325. club.settings.baoJianId = settings.ruleid and tonumber(settings.ruleid) or club.settings.baoJianId
  326. club.settings.realGameId = settings.game_id and tonumber(settings.game_id) or club.settings.gameId
  327. club.settings.gameId = settings.game_id and tonumber(settings.game_id) or club.settings.gameId
  328. club.settings.strGameRule = settings.gamerule or club.settings.strGameRule --规则
  329. local config = getSubGameConfig(club.settings.gameId)
  330. if config and config.bSingleGame then
  331. local strGameRule = json.decode(club.settings.strGameRule)
  332. club.settings.gameId = toNumber(club.settings.gameId) * 10000 + toNumber(strGameRule.gamerule)
  333. end
  334. club.settings.gameNum = settings.game_num and tonumber(settings.game_num) or club.settings.gameNum --局数
  335. club.settings.orderId = settings.ranking or club.settings.orderId --序列号
  336. club.settings.title = settings.title or club.settings.title --标题
  337. club.settings.arena = settings.arena or club.settings.arena --比赛场设置
  338. club.settings.ext = settings.ext or club.settings.ext -- 扩展信息,json
  339. end
  340. --更新包间数据到俱乐部设置(切换包间)
  341. function ClubProtocolPhp:updateClubSettingsByBaoJian(clubId,baoJianId)
  342. local club = self.clubList[tonumber(clubId)]
  343. local baojian = self:getBaoJian(clubId,baoJianId)
  344. if club and baojian then
  345. club.settings.baoJianId = tonumber(baoJianId)
  346. club.settings.gameId = baojian.gameId or club.settings.gameId
  347. club.settings.realGameId = baojian.gameId or club.settings.gameId
  348. club.settings.strGameRule = baojian.strGameRule or club.settings.strGameRule --规则
  349. club.settings.gameNum = baojian.gameNum or club.settings.gameNum --局数
  350. club.settings.orderId = baojian.orderId or club.settings.orderId --序列号
  351. club.settings.title = baojian.title or club.settings.title --标题
  352. club.settings.arena = baojian.arena or club.settings.arena --比赛场设置
  353. club.settings.ext = baojian.ext or club.settings.ext -- 扩展信息,json
  354. local config = getSubGameConfig(club.settings.gameId)
  355. if config and config.bSingleGame then
  356. local strGameRule = json.decode(club.settings.strGameRule)
  357. club.settings.gameId = toNumber(club.settings.gameId) * 10000 + toNumber(strGameRule.gamerule)
  358. end
  359. if toNumber(club.settings.realGameId) > 10000 then
  360. club.settings.realGameId = math.floor(toNumber(club.settings.realGameId) / 10000)
  361. end
  362. end
  363. end
  364. --更新俱乐部房间列表
  365. function ClubProtocolPhp:updateClubRooms(clubId,rooms,posList)
  366. if not self.clubList[tonumber(clubId)] then
  367. self.clubList[tonumber(clubId)] = {}
  368. end
  369. local club = self.clubList[tonumber(clubId)]
  370. --改变游戏或者包间就清空数据
  371. if self.bChangeTable then
  372. club.rooms={}
  373. club.posList={}
  374. end
  375. if posList and table.nums(posList) > 0 then
  376. club.posList = {}
  377. for k,posNum in pairs(posList) do
  378. club.posList[posNum] = true
  379. end
  380. end
  381. for k,v in pairs(rooms) do
  382. self:updateClubRoom(clubId,v)
  383. end
  384. end
  385. function ClubProtocolPhp:updateClubRoom(clubId,v)
  386. if not self.clubList[tonumber(clubId)] then
  387. return
  388. end
  389. local club = self.clubList[tonumber(clubId)]
  390. if not club.rooms then
  391. club.rooms={}
  392. end
  393. if not club.posList then
  394. club.posList={}
  395. end
  396. club.posList[tonumber(v.pos_number)] = true
  397. if not club.rooms[tonumber(v.pos_number)] then
  398. club.rooms[tonumber(v.pos_number)] = {}
  399. end
  400. local room = club.rooms[tonumber(v.pos_number)]
  401. room.baoJianId = v.ruleid and tonumber(v.ruleid) or room.baoJianId --包间id
  402. room.roomId = v.roomid and tonumber(v.roomid) or room.roomId --房间号
  403. room.pos = v.pos_number and tonumber(v.pos_number) or room.pos --当前位置
  404. room.currentNum = v.current_play_nember and tonumber(v.current_play_nember) or room.currentNum --当前局数
  405. room.totalNum = v.play_number and tonumber(v.play_number) or room.totalNum --总局数
  406. room.status = v.status and tonumber(v.status) or room.status --1未开局(不需要展示当前局数/总数据)2开局(需展示当前局数/总数据)
  407. if tonumber(v.createtime) ~= 0 then
  408. room.createTime = v.createtime and tonumber(v.createtime) or room.createTime --服务器生成这个桌子的时间
  409. end
  410. --玩家列表
  411. room.players = room.players or {}
  412. if v.userInfo then
  413. if room.status==1 then
  414. room.players = {} --清理之前数据
  415. end
  416. for _,p in pairsByKeys(v.userInfo) do
  417. local palyer = room.players[tonumber(p.uid)] or {}
  418. palyer.uid = tonumber(p.uid)
  419. palyer.headimgurl = p.headimgurl or palyer.headimgurl
  420. palyer.nickname = p.nickname or palyer.nickname
  421. palyer.sex = p.sex and tonumber(p.sex) or palyer.sex
  422. palyer.state = p.state and tonumber(p.state) or palyer.state-- 0未连接,可判断离线1已登陆,正常为坐下2准备3在玩4在玩过程中离线5准备但离线6坐下但离线
  423. palyer.score = p.score and tonumber(p.score) or palyer.score
  424. room.players[palyer.uid] = palyer
  425. end
  426. end
  427. end
  428. function ClubProtocolPhp:updateClubBaoJians(clubId,baojians)
  429. if not self.clubList[clubId] then
  430. self.clubList[clubId] = {}
  431. end
  432. local club = self.clubList[clubId]
  433. club.baoJians={}
  434. if baojians then
  435. for _,bj in pairs(baojians) do --都为string
  436. self:updateClubBaoJian(clubId,bj)
  437. end
  438. end
  439. end
  440. function ClubProtocolPhp:updateClubBaoJian(clubId,bj,change)
  441. if not bj.ruleid then
  442. return
  443. end
  444. if not self.clubList[clubId] then
  445. return
  446. --self.clubList[clubId] = {}
  447. end
  448. local club = self.clubList[clubId]
  449. if not club.baoJians then
  450. club.baoJians={}
  451. end
  452. if not club.baoJians[tonumber(bj.ruleid)] then
  453. club.baoJians[tonumber(bj.ruleid)] = {}
  454. end
  455. local baojian = club.baoJians[tonumber(bj.ruleid)]
  456. baojian.baoJianId = tonumber(bj.ruleid) or baojian.baoJianId
  457. baojian.gameId = tonumber(bj.game_id) or baojian.gameId
  458. local config = tonumber(baojian.gameId) and getSubGameConfig(tonumber(baojian.gameId)) or nil
  459. if config and config.bSingleGame then
  460. local gamerule = json.decode(bj.gamerule).gamerule
  461. baojian.gameId = tonumber(bj.game_id) * 10000 + gamerule
  462. end
  463. baojian.realGameId = baojian.gameId
  464. if baojian.gameId and baojian.gameId > 10000 then
  465. baojian.realGameId = math.floor(baojian.gameId/10000)
  466. end
  467. baojian.onlineRoomNum = bj.onlineroom and tonumber(bj.onlineroom) or baojian.onlineRoomNum or 0
  468. baojian.gameNum = tonumber(bj.game_num) or baojian.gameNum
  469. baojian.strGameRule = bj.gamerule or baojian.strGameRule
  470. baojian.title = bj.title or baojian.title
  471. baojian.orderId = tonumber(bj.ranking) or baojian.orderId or table.nums(club.baoJians)
  472. --新增包间大赢家设置
  473. baojian.playWinScore = tonumber(bj.play_win_threshold) or baojian.playWinScore or 0
  474. --比赛设置信息
  475. baojian.arena = bj.arena or baojian.arena or ""
  476. baojian.is_use = bj.is_use or baojian.is_use or ""
  477. baojian.ext = bj.ext or baojian.ext or ""
  478. --如果当前俱乐部的设置刚好为当前包间或者第一次添加包间 则需要更新设置数据
  479. if club.settings and (not club.settings.baoJianId or club.settings.baoJianId==baojian.baoJianId) then
  480. self:updateClubSettingsByBaoJian(clubId,baojian.baoJianId)
  481. end
  482. local againid = getAgainGameBaoJianId()
  483. if tonumber(baojian.baoJianId) == tonumber(againid) and change == true then
  484. setRuleChangeStatus(true)
  485. end
  486. end
  487. --亲友圈消息
  488. function ClubProtocolPhp:updateClubMessages(clubId,messages)
  489. if not messages then
  490. return
  491. end
  492. if not self.clubList[clubId] then
  493. self.clubList[clubId] = {}
  494. end
  495. local club = self.clubList[clubId]
  496. club.messages={}
  497. for _,msg in pairs(messages) do
  498. if not club.messages[tonumber(msg.msgid)] then
  499. club.messages[tonumber(msg.msgid)] = {}
  500. end
  501. local messageItem = club.messages[tonumber(msg.msgid)]
  502. messageItem.messageId = tonumber(msg.msgid)
  503. messageItem.clubId = tonumber(msg.gid)
  504. messageItem.content = msg.content
  505. messageItem.date = msg.create_time
  506. end
  507. end
  508. --排名赛申请
  509. function ClubProtocolPhp:updateClubMatchMessages(clubId,messages)
  510. if not messages then
  511. return
  512. end
  513. if not self.clubList[clubId] then
  514. self.clubList[clubId] = {}
  515. end
  516. local club = self.clubList[clubId]
  517. club.matchMessages={}
  518. for _,msg in pairs(messages) do
  519. if not club.matchMessages[tonumber(msg.id)] then
  520. club.matchMessages[tonumber(msg.id)] = {}
  521. end
  522. local messageItem = club.matchMessages[tonumber(msg.id)]
  523. messageItem.messageId = tonumber(msg.id)
  524. messageItem.clubId = tonumber(msg.gid)
  525. messageItem.uid = tonumber(msg.uid)
  526. messageItem.nick = msg.nick or ""
  527. messageItem.strHeadUrl = msg.icon or ""
  528. messageItem.role = tonumber(msg.role)
  529. messageItem.warnum = tonumber(msg.warnum)
  530. messageItem.applyTime = tonumber(msg.apply_time)
  531. messageItem.endTime = tonumber(msg.end_time)
  532. messageItem.status = tonumber(msg.status)
  533. messageItem.copartner = tonumber(msg.copartner)
  534. messageItem.operuid = tonumber(msg.operuid)
  535. end
  536. end
  537. --海选赛申请
  538. function ClubProtocolPhp:updateClubCestMessages(clubId,messages)
  539. if not messages then
  540. return
  541. end
  542. if not self.clubList[clubId] then
  543. self.clubList[clubId] = {}
  544. end
  545. local club = self.clubList[clubId]
  546. club.cestMessages={}
  547. for _,msg in pairs(messages) do
  548. if not club.cestMessages[tonumber(msg.id)] then
  549. club.cestMessages[tonumber(msg.id)] = {}
  550. end
  551. local messageItem = club.cestMessages[tonumber(msg.id)]
  552. messageItem.messageId = tonumber(msg.id)
  553. messageItem.clubId = tonumber(msg.gid)
  554. messageItem.uid = tonumber(msg.uid)
  555. messageItem.nick = msg.nick or ""
  556. messageItem.icon = msg.icon or ""
  557. messageItem.role = tonumber(msg.role)
  558. -- messageItem.warnum = tonumber(msg.warnum)
  559. -- messageItem.cestext = msg.cestext
  560. messageItem.copartner = tonumber(msg.copartner)
  561. messageItem.copartner_nick = msg.copartner_nick
  562. messageItem.copartner = tonumber(msg.copartner)
  563. messageItem.contribute = tonumber(msg.contribute)
  564. messageItem.point = tonumber(msg.point) -- 积分
  565. messageItem.type = tonumber(msg.type)
  566. messageItem.applyTime = tonumber(msg.apply_time)
  567. messageItem.endTime = tonumber(msg.end_time)
  568. messageItem.status = tonumber(msg.status)
  569. messageItem.operuid = tonumber(msg.operuid)
  570. end
  571. end
  572. --奖励消息
  573. function ClubProtocolPhp:updateClubAwardMessages(clubId,messages)
  574. if not messages then
  575. return
  576. end
  577. if not self.clubList[clubId] then
  578. self.clubList[clubId] = {}
  579. end
  580. local club = self.clubList[clubId]
  581. if not club.awardMessages then
  582. club.awardMessages={}
  583. end
  584. for _,msg in pairs(messages) do
  585. if not club.awardMessages[tonumber(msg.awardid)] then
  586. club.awardMessages[tonumber(msg.awardid)] = {}
  587. end
  588. local messageItem = club.awardMessages[tonumber(msg.awardid)]
  589. messageItem.awardId = tonumber(msg.awardid)
  590. messageItem.awardSN = tonumber(msg.awardsn)
  591. messageItem.content = msg.content
  592. messageItem.status = tonumber(msg.status)
  593. end
  594. end
  595. -- 更新玩家申请消息列表
  596. -- @param clubId 俱乐部id
  597. -- @param messages 消息列表
  598. -- @msgType 消息类型,1为加入申请,2为退出申请
  599. function ClubProtocolPhp:updateClubApplyMessages(clubId,messages,msgType)
  600. if not messages then
  601. return
  602. end
  603. if not self.clubList[clubId] then
  604. self.clubList[clubId] = {}
  605. end
  606. local club = self.clubList[clubId]
  607. if not club.applyMessages then
  608. club.applyMessages={}
  609. end
  610. if not club.coapplyMessages then
  611. club.coapplyMessages={}
  612. end
  613. for i,msg in pairs(messages) do
  614. local index = msg.uid.."_"..msgType
  615. --数据类型msg.type{1普通成员申请, 2合伙人的成员申请}
  616. if tonumber(msg.type) == 2 or tonumber(msg.type) == 3 then -- todo lwq 添加type == 3
  617. --合伙人的成员申请
  618. if not club.coapplyMessages[index] then
  619. club.coapplyMessages[index] = {}
  620. end
  621. local messageItem = club.coapplyMessages[index]
  622. messageItem.uid = tonumber(msg.uid)
  623. messageItem.clubId = tonumber(msg.gid)
  624. messageItem.clubName = msg.gname
  625. messageItem.name = msg.nick
  626. messageItem.sex = tonumber(msg.sex)
  627. messageItem.strHeadUrl = msg.icon
  628. messageItem.applyTime = tonumber(msg.apply_time)
  629. messageItem.joinTime = tonumber(msg.join_time)
  630. messageItem.status = tonumber(msg.status) --0申请1通过2拒绝
  631. messageItem.copartner = tonumber(msg.copartner)
  632. messageItem.copartner_nick = msg.copartner_nick
  633. messageItem.copartner5 = tonumber(msg.copartner5)
  634. messageItem.copartner5_nick = msg.copartner5_nick
  635. messageItem.copartner6 = tonumber(msg.copartner6)
  636. messageItem.copartner6_nick = msg.copartner6_nick
  637. messageItem.copartner7 = tonumber(msg.copartner7)
  638. messageItem.copartner7_nick = msg.copartner7_nick
  639. messageItem.operuid = tonumber(msg.operuid)
  640. messageItem.opernick = msg.opernick
  641. messageItem.index = index --前端默认添加key
  642. messageItem.msgType = msgType -- 前端加入的key,标志申请消息类型
  643. else
  644. --普通成员申请
  645. if not club.applyMessages[index] then
  646. club.applyMessages[index] = {}
  647. end
  648. local messageItem = club.applyMessages[index]
  649. messageItem.uid = tonumber(msg.uid)
  650. messageItem.clubId = tonumber(msg.gid)
  651. messageItem.clubName = msg.gname
  652. messageItem.name = msg.nick
  653. messageItem.sex = tonumber(msg.sex)
  654. messageItem.strHeadUrl = msg.icon
  655. messageItem.applyTime = tonumber(msg.apply_time)
  656. messageItem.joinTime = tonumber(msg.join_time)
  657. messageItem.status = tonumber(msg.status) --0申请1通过2拒绝
  658. messageItem.index = index --前端默认添加key
  659. messageItem.msgType = msgType -- 前端加入的key,标志申请消息类型
  660. end
  661. end
  662. end
  663. function ClubProtocolPhp:updateClubApplyMessageStatus(clubId,index,status,id,name)
  664. local club = self.clubList[clubId]
  665. if not club then
  666. return
  667. end
  668. if club.applyMessages then
  669. for i,msg in pairs(club.applyMessages) do
  670. if msg.index==index then
  671. msg.status = status
  672. end
  673. end
  674. end
  675. if club.coapplyMessages then
  676. for i,msg in pairs(club.coapplyMessages) do
  677. if msg.index==index then
  678. msg.status = status
  679. if id and name then
  680. msg.operuid = id
  681. msg.opernick = name
  682. end
  683. end
  684. end
  685. end
  686. end
  687. function ClubProtocolPhp:updateClubMatchMessageApplyStatus(clubId,messageId,status,id,name)
  688. local club = self.clubList[clubId]
  689. if not club then
  690. return
  691. end
  692. if club.matchMessages then
  693. for i,msg in pairs(club.matchMessages) do
  694. if msg.messageId==messageId then
  695. msg.status = status
  696. end
  697. end
  698. end
  699. end
  700. function ClubProtocolPhp:updateClubPlayers(clubId,players,mType,dateType)
  701. if not players then
  702. return
  703. end
  704. if not self.clubList[clubId] then
  705. --self.clubList[clubId] = {}
  706. return
  707. end
  708. local club = self.clubList[clubId]
  709. if club.playersMatch then
  710. for k,v in pairs(club.playersMatch) do
  711. v.viewType = nil
  712. end
  713. end
  714. local pagePlayerList = {}
  715. for k,v in pairs(players) do
  716. local player = self:updateClubPlayer(clubId,v,nil,mType,dateType)
  717. if player then
  718. table.insert(pagePlayerList,player)
  719. end
  720. end
  721. return pagePlayerList
  722. end
  723. function ClubProtocolPhp:updateClubPlayer(clubId,v,isModified,mType,dateType)
  724. if not self.clubList[clubId] or not v then
  725. return
  726. -- self.clubList[clubId] = {}
  727. end
  728. mType = mType or ClubDefine.PlayListType.NORMAL_MEMBER
  729. local club = self.clubList[clubId]
  730. if not club.players then
  731. club.players={}
  732. end
  733. if not club.playersLevelOne then
  734. club.playersLevelOne={}
  735. end
  736. if not club.playersLevelTwo then
  737. club.playersLevelTwo={}
  738. end
  739. if not club.playersLevelThree then
  740. club.playersLevelThree={}
  741. end
  742. if not club.playersMatch then
  743. club.playersMatch={}
  744. end
  745. local curPlayerData = nil
  746. if mType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_MEMBER
  747. or mType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_RECORD
  748. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER then
  749. curPlayerData = club.playersLevelOne
  750. elseif mType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_MEMBER
  751. or mType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_RECORD
  752. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER then
  753. curPlayerData = club.playersLevelTwo
  754. elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then
  755. curPlayerData = club.playersLevelThree
  756. elseif mType == ClubDefine.PlayListType.MATCH_MEMBER or mType == ClubDefine.PlayListType.MATCH_RECORD
  757. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_RANK
  758. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LEVEL
  759. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER
  760. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LIST
  761. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LIST_TEAM
  762. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_SET_MEMBER then
  763. curPlayerData = club.playersMatch
  764. else
  765. curPlayerData = club.players
  766. end
  767. if not curPlayerData[tonumber(v.uid)] then
  768. if isModified then --如果是修改没有数据直接return
  769. return
  770. end
  771. curPlayerData[tonumber(v.uid)] = {}
  772. end
  773. local player = curPlayerData[tonumber(v.uid)]
  774. player.viewType = mType
  775. player.uid = v.uid and tonumber(v.uid) or player.uid
  776. player.name = v.nick or player.name
  777. player.sex = tonumber(v.sex) or player.sex --玩家性别:0未知1男2女
  778. player.strHeadUrl = v.icon or player.strHeadUrl --玩家头像地址
  779. player.desc = v.desc or player.desc --备注
  780. player.lastPlayNum = v.last_play_number or player.lastPlayNum --昨日局数
  781. player.lastPlayWinNum = v.last_play_win_number or player.lastPlayWinNum --昨日大赢家次数
  782. player.online = tonumber(v.online) or player.online --1在线0离线
  783. player.loginTime = tonumber(v.login_time) or player.loginTime --最近登录的时间戳, 如果数值为0, 直接为离线
  784. player.role = tonumber(v.role) or player.role or 0 --1成员2管理员3创建人
  785. player.status = tonumber(v.status) or player.status or 0 --1正常0黑名单成员-1退出群
  786. player.lastTotalScore = v.last_total_score or player.lastTotalScore --昨日输赢积分
  787. player.copartner = tonumber(v.copartner) or player.copartner --所属普通合伙人/二级合伙人/直属上级UID
  788. player.copartner_role = v.copartner_role or player.copartner_role --所属普通合伙人/二级合伙人
  789. player.copartner_nick = v.copartner_nick or player.copartner_nick --所属普通合伙人/二级合伙人/战队名
  790. player.copartner5 = tonumber(v.copartner5) or player.copartner5 --所属一级合伙人ID
  791. player.copartner5_nick = v.copartner5_nick or player.copartner5_nick --所属一级合伙人NICK
  792. player.notdesk = v.notdesk or 0 -- 禁止同队标志
  793. player.date = v.date or player.date --ljx 日期 小红点转用
  794. player.isred = v.isred or player.isred --ljx 是否显示小红点
  795. --数据分类处理,防止数据重复覆盖
  796. if mType == ClubDefine.PlayListType.MATCH_MEMBER or mType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_MEMBER
  797. or mType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_MEMBER
  798. or (mType == ClubDefine.PlayListType.SEARCH_PLAYER and dateType == ClubDefine.PlayListType.MATCH_MEMBER) then
  799. player.totalRedFlower = v.arena_opertotal or player.totalRedFlower or 0 --总红花数(加减总计)
  800. player.useRedFlower = v.arena_score or player.useRedFlower or 0 -- 可用红花
  801. player.arenaRatio = v.arena_ratio or player.arenaRatio or 0 -- 分成比例
  802. player.copartnerSubStatus = v.copartnerSubStatus or player.copartnerSubStatus or 0 -- 对合伙人有效, 1表示可冻结所有下属0表示解冻,-1无权对此合伙人批量处理/或是成员
  803. player.cancelDesc = v.cancel_desc or player.cancelDesc or "" --取消确认中的提示
  804. player.haveRole6 = v.haveRole6 or player.haveRole6 or 0 --该1级合伙人名下含有的二级数量
  805. if player.uid == app.user.loginInfo.uid and club.memberInfo then
  806. club.memberInfo.arena_score = player.useRedFlower
  807. self:dispatchEvent({name = GAME_EVENT.CLUB_UPDATE_RED_FLOWER})
  808. end
  809. elseif mType == ClubDefine.PlayListType.MATCH_RECORD or mType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_RECORD
  810. or mType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_RECORD
  811. or (mType == ClubDefine.PlayListType.SEARCH_PLAYER and dateType == ClubDefine.PlayListType.MATCH_RECORD) then
  812. player.changeRedFlower = v.arena_score or player.changeRedFlower or 0-- 红花变动(按日期统计)
  813. player.changeGreen = v.arena_profit or player.changeGreen or 0 -- 绿叶变动(按日期统计)
  814. player.playNum = v.play_number or player.playNum or 0 --局数
  815. player.playWinNum = v.play_win_number or player.playWinNum or 0 --大赢家次数
  816. player.totalScore = v.total_score or player.totalScore or 0 --输赢积分
  817. elseif mType == ClubDefine.PlayListType.NORMAL_MEMBER then
  818. player.agent = v.agent or player.agent --1是代理0不是代理
  819. player.playNum = v.play_number or player.playNum --局数
  820. player.playWinNum = v.play_win_number or player.playWinNum --大赢家次数
  821. player.totalScore = v.total_score or player.totalScore --输赢积分
  822. elseif mType == ClubDefine.PlayListType.INVITE_ONLINE then
  823. if v.isplay then
  824. player.isPlay = v.isplay == 1 --是否在游戏中(1:游戏中)
  825. end
  826. elseif mType == ClubDefine.PlayListType.MATCH_RANK then
  827. player.changeRedFlower = v.arena_score or player.changeRedFlower -- 红花变动(按日期统计)
  828. elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_RANK then
  829. player.captainLevel = tonumber(v.captain_level) or player.captainLevel--当前队长等级
  830. player.useMedal = tonumber(v.use_medal) or player.useMedal --已使用勋章
  831. player.medal = tonumber(v.medal) or player.medal --战队勋章
  832. player.warnum = tonumber(v.warnum) or player.warnum --排名分
  833. player.warreward = tonumber(v.warreward) or player.warreward --月排名奖
  834. player.ranking = tonumber(v.ranking) or player.ranking --排名
  835. player.level = tonumber(v.user_level) or player.level --玩牌等级
  836. player.rewardType = tonumber(v.rewardType) or player.rewardType --奖励类型
  837. -- cest
  838. if self:getCestIsOpen(clubId) then
  839. player.contribute = tonumber(v.contribute) or player.contribute or 0 -- 赛点
  840. player.play_gamenum = tonumber(v.play_gamenum) or player.play_gamenum or 0 -- 参赛人次
  841. player.totalscore = tonumber(v.totalscore ) or player.totalscore or 0 -- 技术分
  842. player.av_win = tonumber(v.av_win) or player.av_win or 0 -- 平均胜率
  843. player.win_num = tonumber(v.win_num) or player.win_num or 0 -- 冠军数量
  844. player.applynums = tonumber(v.applynums) or player.applynums or 0 -- 战队战况,总的
  845. player.curapplynums = tonumber(v.curapplynums) or player.curapplynums or 0 -- 战队战况,当前
  846. local playerInfo1 = app.club_php:getPlayer(self.clubId,player.uid)
  847. if not playerInfo1 then
  848. return
  849. end
  850. end
  851. elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LEVEL then
  852. player.captainLevel = tonumber(v.captain_level) or player.captainLevel --当前队长等级
  853. player.medal = tonumber(v.medal) or player.medal --战队勋章
  854. player.endMedal = tonumber(v.end_medal) or player.endMedal --下一级需要的勋章
  855. player.startMedal = tonumber(v.start_medal) or player.startMedal --下一级提升的勋章
  856. elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER
  857. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LIST
  858. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LIST_TEAM
  859. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_SET_MEMBER
  860. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER
  861. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER
  862. or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then
  863. --玩家数据
  864. player.haveRole6 = v.haveRole6 or player.haveRole6 or 0 --该1级合伙人名下含有的二级数量
  865. player.captainLevel = tonumber(v.captain_level) or player.captainLevel --当前队长等级
  866. player.level = tonumber(v.user_level) or player.level or 1 --玩牌等级
  867. player.warnum = tonumber(v.warnum) or player.warnum --排名分
  868. player.arenaSprint = tonumber(v.arena_sprint) or player.arenaSprint --初始化分
  869. player.arenaReport = tonumber(v.arena_report) or player.arenaReport --上报分
  870. player.playNum = tonumber(v.play_number) or player.playNum --局数
  871. player.playWinNum = tonumber(v.play_win_number) or player.playWinNum --大赢家次数
  872. player.totalScore = v.total_score or player.totalScore --输赢积分
  873. player.honor = tonumber(v.honor) or player.honor --抽奖
  874. player.copartner6 = v.copartner6 or player.copartner6 --所属二级合伙人ID
  875. player.copartner7 = v.copartner7 or player.copartner7 --所属三级合伙人(小组长)ID
  876. player.arenaRatio = v.arena_ratio or player.arenaRatio or 0 -- 分成比例
  877. player.copartnerSubStatus = v.copartnerSubStatus or player.copartnerSubStatus or 0 -- 对合伙人有效, 1表示可冻结所有下属0表示解冻,-1无权对此合伙人批量处理/或是成员
  878. player.grant = v.grant or player.grant or 0 --管理员所拥有的权限(裁判,上报排名,指派出赛)
  879. player.play_number = v.play_number or player.play_number or 0 --参赛总局数
  880. -- cest
  881. if self:getCestIsOpen(clubId) then
  882. player.point = v.point or player.point or 0 --积分
  883. player.contribute = v.contribute or player.contribute or 0 -- 赛点
  884. player.totalscore = v.totalscore or player.totalscore or 0 -- 技术分
  885. player.totalnum = v.totalnum or player.totalnum or 0 -- 轮次
  886. player.maxcontribute = tonumber(v.maxcontribute) or player.maxcontribute or 0 -- 最高赛点
  887. player.gamenum = v.gamenum or player.gamenum or 0 -- 本轮总轮次
  888. player.curgamenum = v.curgamenum or player.curgamenum or 0 -- 本轮使用轮次
  889. player.m_sumtotalscore = v.m_sumtotalscore or player.m_sumtotalscore or 0 -- 总技术分
  890. player.isJsfOrZf = 0 -- 技术分或者总技术分,0:技术分,1:总技术分
  891. end
  892. if player.uid == app.user.loginInfo.uid and club.memberInfo then
  893. club.memberInfo.warnum = player.warnum
  894. self:dispatchEvent({name = GAME_EVENT.CLUB_UPDATE_RED_FLOWER})
  895. end
  896. end
  897. return player
  898. end
  899. --更新排名赛数据
  900. function ClubProtocolPhp:updateAllPeopleMatchData(clubId,data,mType)
  901. if not self.clubList[clubId] or not data or not mType then
  902. return
  903. end
  904. local club = self.clubList[clubId]
  905. if not club.allPeopleMatch then
  906. club.allPeopleMatch = {}
  907. end
  908. if mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_RANK then
  909. --排名赛排名数据allRankList
  910. if not club.allPeopleMatch.allRankList then
  911. club.allPeopleMatch.allRankList = {}
  912. end
  913. club.allPeopleMatch.allRankList.sLastDay = data.sLastDay or club.allPeopleMatch.allRankList.sLastDay
  914. club.allPeopleMatch.allRankList.groupCfg = data.groupCfg or club.allPeopleMatch.allRankList.groupCfg
  915. elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_RANK then
  916. --排名赛战队排名数据allTeamRankList
  917. if not club.allPeopleMatch.allTeamRankList then
  918. club.allPeopleMatch.allTeamRankList = {}
  919. end
  920. club.allPeopleMatch.allTeamRankList.memberCfg = data.memberCfg or club.allPeopleMatch.allTeamRankList.memberCfg
  921. club.allPeopleMatch.allTeamRankList.stat = data.stat or club.allPeopleMatch.allTeamRankList.stat
  922. elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER then
  923. --排名赛管理
  924. if not club.allPeopleMatch.allManage then
  925. club.allPeopleMatch.allManage = {}
  926. end
  927. club.allPeopleMatch.allManage.sLastDay = data.sLastDay or club.allPeopleMatch.allManage.sLastDay
  928. club.allPeopleMatch.allManage.stat = data.stat or club.allPeopleMatch.allManage.stat
  929. elseif mType == ClubDefine.PlayListType.UNION_CLUB_LIST then
  930. --联盟亲友圈列表成员
  931. if not club.allPeopleMatch.allUnion then
  932. club.allPeopleMatch.allUnion = {}
  933. end
  934. club.allPeopleMatch.allUnion.sLastDay = data.sLastDay or club.allPeopleMatch.allUnion.sLastDay
  935. club.allPeopleMatch.allUnion.stat = data.stat or club.allPeopleMatch.allUnion.stat
  936. end
  937. end
  938. --获取排名配置
  939. function ClubProtocolPhp:getMatchRankConfig(clubId)
  940. local club = self.clubList[clubId]
  941. if not club or not club.allPeopleMatch or not club.allPeopleMatch.allRankList
  942. or not club.allPeopleMatch.allRankList.groupCfg then
  943. return nil
  944. end
  945. return club.allPeopleMatch.allRankList.groupCfg
  946. end
  947. --获取排名赛排名数据
  948. function ClubProtocolPhp:getMatchRank(clubId)
  949. local club = self.clubList[clubId]
  950. if not club or not club.allPeopleMatch or not club.allPeopleMatch.allRankList then
  951. return nil
  952. end
  953. return club.allPeopleMatch.allRankList
  954. end
  955. --获取战队/小队排名数据
  956. function ClubProtocolPhp:getMatchTeamRank(clubId)
  957. local club = self.clubList[clubId]
  958. if not club or not club.allPeopleMatch or not club.allPeopleMatch.allTeamRankList then
  959. return nil
  960. end
  961. return club.allPeopleMatch.allTeamRankList
  962. end
  963. --获取排名赛管理数据
  964. function ClubProtocolPhp:getMatchManage(clubId)
  965. local club = self.clubList[clubId]
  966. if not club or not club.allPeopleMatch or not club.allPeopleMatch.allManage then
  967. return nil
  968. end
  969. return club.allPeopleMatch.allManage
  970. end
  971. --获取合盟亲友圈列表数据
  972. function ClubProtocolPhp:getMatchUnionList(clubId)
  973. local club = self.clubList[clubId]
  974. if not club or not club.allPeopleMatch or not club.allPeopleMatch.allUnion then
  975. return nil
  976. end
  977. return club.allPeopleMatch.allUnion
  978. end
  979. function ClubProtocolPhp:getRoomData(clubId,index)
  980. local club = self.clubList[clubId]
  981. if not club or not club.rooms then
  982. return nil
  983. end
  984. return club.rooms[index]
  985. end
  986. function ClubProtocolPhp:getBaoJianByGameId(clubId,gameId)
  987. local tt = {}
  988. local club = self.clubList[clubId]
  989. if not club or not club.baoJians then
  990. return tt
  991. end
  992. for k,v in pairs(club.baoJians) do
  993. if tonumber(v.gameId) == tonumber(gameId) then
  994. table.insert(tt,v)
  995. end
  996. end
  997. return tt
  998. end
  999. function ClubProtocolPhp:getGameIdByBaoJianId(clubId,baoJianId)
  1000. local club = self.clubList[clubId]
  1001. if not club or not club.baoJians then
  1002. return 0
  1003. end
  1004. for k,v in pairs(club.baoJians) do
  1005. if tonumber(v.baoJianId) == tonumber(baoJianId) then
  1006. return v.gameId
  1007. end
  1008. end
  1009. end
  1010. function ClubProtocolPhp:getBaoJian(clubId,ruleId)
  1011. local club = self.clubList[clubId]
  1012. if not club or not club.baoJians then
  1013. return nil
  1014. end
  1015. return club.baoJians[tonumber(ruleId)]
  1016. end
  1017. function ClubProtocolPhp:getBaoJianRooms(clubId,baoJianId)
  1018. local rooms = {}
  1019. local club = self.clubList[clubId]
  1020. if club then
  1021. for k,v in pairsByKeys (club.rooms) do
  1022. if v.baoJianId == baoJianId then
  1023. table.insert(rooms,v)
  1024. end
  1025. end
  1026. end
  1027. return clone(rooms)
  1028. end
  1029. function ClubProtocolPhp:getClubRooms(clubId)
  1030. local rooms = {}
  1031. local club = self.clubList[clubId]
  1032. if club then
  1033. for k,v in pairsByKeys (club.rooms) do
  1034. table.insert(rooms,v)
  1035. end
  1036. end
  1037. return clone(rooms)
  1038. end
  1039. function ClubProtocolPhp:getSortClubBaoJians(clubId,baoJians)
  1040. local newBaoJians = {}
  1041. local club = self.clubList[clubId]
  1042. local tt = baoJians or club.baoJians
  1043. if tt then
  1044. for k,v in pairs(tt) do
  1045. table.insert(newBaoJians,v)
  1046. end
  1047. table.sort(newBaoJians,function (a,b)
  1048. if a.baoJianId and b.baoJianId then
  1049. return a.baoJianId < b.baoJianId
  1050. else
  1051. return false
  1052. end
  1053. end)
  1054. return newBaoJians
  1055. end
  1056. return {}
  1057. end
  1058. function ClubProtocolPhp:getSortClubRooms(clubId)
  1059. local rooms = {}
  1060. local club = self.clubList[clubId]
  1061. if club then
  1062. for k,v in pairsByKeys(club.rooms) do
  1063. table.insert(rooms,v)
  1064. end
  1065. --Tarry:未开局(桌子越老排前面) — 新开局 (桌子越新排前面)
  1066. local function sortRoom(a,b)
  1067. local numA = a.createTime or -1
  1068. local numB = b.createTime or -1
  1069. if a.status==1 and b.status~=1 then
  1070. return true
  1071. elseif a.status==1 and b.status==1 then
  1072. if numA<numB then
  1073. return true
  1074. end
  1075. elseif a.status==2 and b.status==2 then
  1076. if numA > numB then
  1077. return true
  1078. end
  1079. end
  1080. return false
  1081. end
  1082. table.sort(rooms,sortRoom)
  1083. end
  1084. return clone(rooms)
  1085. end
  1086. --查找我所在的房间
  1087. function ClubProtocolPhp:getMyInRoom(clubId)
  1088. local clubInfo = self.clubList[tonumber(clubId)]
  1089. local inRoom = false
  1090. if clubInfo then
  1091. inRoom = clubInfo.isplaying == 1
  1092. end
  1093. return inRoom
  1094. end
  1095. function ClubProtocolPhp:delBaoJian(clubId,baoJianId)
  1096. local club = self.clubList[clubId]
  1097. if not club or not club.baoJians or not club.baoJians[baoJianId] then
  1098. return
  1099. end
  1100. club.baoJians[baoJianId].is_use = 0
  1101. end
  1102. function ClubProtocolPhp:getUnionClubId(clubId,sgid)
  1103. if not clubId then
  1104. return
  1105. end
  1106. local club = self.clubList[clubId]
  1107. if club and club.unionPlayerList then
  1108. return club.unionPlayerList[sgid]
  1109. end
  1110. return nil
  1111. end
  1112. function ClubProtocolPhp:getPlayer(clubId,uid,viewType)
  1113. if not clubId then
  1114. return
  1115. end
  1116. local club = self.clubList[clubId]
  1117. if self:getMatchIsOpen(clubId) then
  1118. if club then
  1119. if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER and club.playersLevelOne then
  1120. return club.playersLevelOne[uid]
  1121. elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER and club.playersLevelOne then
  1122. return club.playersLevelTwo[uid]
  1123. elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER and club.playersLevelOne then
  1124. return club.playersLevelThree[uid]
  1125. else
  1126. return club.playersMatch[uid]
  1127. end
  1128. end
  1129. elseif self:getCestIsOpen(clubId) then
  1130. if club then
  1131. if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER and club.playersLevelOne then
  1132. return club.playersLevelOne[uid]
  1133. elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER and club.playersLevelOne then
  1134. return club.playersLevelTwo[uid]
  1135. elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER and club.playersLevelOne then
  1136. return club.playersLevelThree[uid]
  1137. else
  1138. return club.playersMatch[uid]
  1139. end
  1140. end
  1141. else
  1142. if club and club.players then
  1143. return club.players[uid]
  1144. end
  1145. end
  1146. return nil
  1147. end
  1148. function ClubProtocolPhp:getMatchPlayer(clubId,uid,viewType)
  1149. return self:getPlayer(clubId,uid,viewType)
  1150. end
  1151. function ClubProtocolPhp:getPlayerNum(settings)
  1152. if not settings then
  1153. return 4
  1154. end
  1155. local gameId = settings.realGameId
  1156. local ruleInfo = json.decode(settings.strGameRule)
  1157. local gameRule = ruleInfo.gamerule or ruleInfo.gameRule -- 子游戏不要使用gameRule,统一使用gamerule
  1158. local playerNum = ruleInfo.playnum or getSubGamePlayerNum(gameId, gameRule)
  1159. -- if playerNum==-1 or playerNum==1 then --字牌快速开始为-1,1
  1160. -- playerNum = 4
  1161. -- end
  1162. if playerNum<2 then --如果人数小于2 默认为4
  1163. playerNum = 4
  1164. end
  1165. if ruleInfo.isfaststart == 1 then --鬼麻将快速开始为1
  1166. if gameId == 42 or gameId == 27 or gameId == 55 then
  1167. -- 42自贡麻将、27三人两房、55三人三房特殊处理,最多3人玩
  1168. playerNum = 3
  1169. elseif gameId == 64 then
  1170. -- 自贡七张麻将
  1171. playerNum = 6
  1172. else
  1173. playerNum = 4
  1174. end
  1175. end
  1176. if ruleInfo.isHongZhong == 1 then
  1177. playerNum = (ruleInfo.playnum == 0) and 2 or (ruleInfo.playnum == 1 and 3 or 4)
  1178. end
  1179. return playerNum
  1180. end
  1181. function ClubProtocolPhp:onPhpMessage(event)
  1182. if not event or not event.msg or type(event.msg) ~= "table" then
  1183. return
  1184. end
  1185. local message = event.msg
  1186. local msgType = message.type and tonumber(message.type) or nil
  1187. if msgType == ClubDefine.PUSH.changeBaoJian then --更新包间玩法 注意 gid type 都为number 其他为string
  1188. local clubId = tonumber(message.gid)
  1189. local content = message.content
  1190. if message.content.type == 0 then --删除
  1191. self:delBaoJian(clubId,tonumber(content.ruleid))
  1192. --刷新包间管理
  1193. self:dispatchEvent({name = GAME_EVENT.CLUB_CALUATE_ACTIVE_GAME})
  1194. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE})
  1195. self:requestClubHome(clubId,nil,nil,0) --修改后需要刷新桌子
  1196. elseif message.content.type == 1 then --修改
  1197. self:updateClubBaoJian(clubId,content,true)
  1198. self:requestClubHome(clubId,nil,nil,0) --修改后需要刷新桌子
  1199. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE})
  1200. elseif message.content.type == 2 then --新增
  1201. self:updateClubBaoJian(clubId,content)
  1202. local clubInfo = self.clubList[tonumber(clubId)]
  1203. if clubInfo and content.activeGames then
  1204. clubInfo.activeGames = content.activeGames
  1205. end
  1206. self:dispatchEvent({name = GAME_EVENT.CLUB_CALUATE_ACTIVE_GAME})
  1207. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE,clubId = clubId,baoJianId = tonumber(content.ruleid)})
  1208. self:requestClubHome(clubId,nil,nil,0) --修改后需要刷新桌子
  1209. end
  1210. elseif msgType == ClubDefine.PUSH.setAllBaoJian then
  1211. local clubId = tonumber(message.gid)
  1212. if message.content then
  1213. --[[logD("content:",table.tostring(message.content))
  1214. for baoJianId,v in pairs(message.content) do
  1215. self:updateClubBaoJian(clubId,v)
  1216. end--]]
  1217. self:requestClubHome(clubId)
  1218. self:dispatchEvent({name = GAME_EVENT.CLUB_SET, clubId = clubId})
  1219. --self:dispatchEvent({name = GAME_EVENT.CLUB_ROOM_BAOJIAN_UPDATE, clubId = clubId})
  1220. end
  1221. elseif msgType == ClubDefine.PUSH.changeBaoJianSet then --更新包间名
  1222. local clubId = tonumber(message.gid)
  1223. self:updateClubBaoJian(clubId,message.content)
  1224. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE_PUSH, clubId = clubId})
  1225. elseif msgType == ClubDefine.PUSH.clubJieSan then --解散茶馆
  1226. local clubId = tonumber(message.gid)
  1227. self:requestClubList()
  1228. if app.club_php:getCestIsOpen(clubId) then
  1229. message.content = string.gsub(message.content, "亲友圈", "赛事")
  1230. end
  1231. if self.clubList and self.clubList[clubId] then -- todo lwq 不加判断的话,没拉取clublist信息有问题
  1232. if self.clubList[clubId].role ~= 3 then
  1233. showTooltip(message.content)
  1234. end
  1235. end
  1236. self.clubList[clubId] = nil
  1237. self:dispatchEvent({name = GAME_EVENT.CLUB_LIST})
  1238. self:dispatchEvent({name = GAME_EVENT.CLUB_JIE_SAN , clubId = clubId})
  1239. elseif msgType == ClubDefine.PUSH.changeClubName then --修改茶馆名字
  1240. local clubId = tonumber(message.gid)
  1241. local content = json.decode(message.content or "")
  1242. if self.clubList[clubId] and content then
  1243. self.clubList[clubId].clubName = content.gname or self.clubList[clubId].clubName
  1244. end
  1245. -- self:updateClub(clubId,message.content)
  1246. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_PUSH})
  1247. elseif msgType == ClubDefine.PUSH.dongJieClub or msgType == ClubDefine.PUSH.jieDongClub then --解冻 冻结茶馆
  1248. local clubId = tonumber(message.gid)
  1249. local content = json.decode(message.content or "")
  1250. if self.clubList[clubId] and content then
  1251. self.clubList[clubId].status = content.status and tonumber(content.status) or self.clubList[clubId].status
  1252. end
  1253. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_PUSH})
  1254. elseif msgType == ClubDefine.PUSH.changeClubSet then --茶馆设置修改
  1255. local clubId = tonumber(message.gid)
  1256. local content = json.decode(message.content or "")
  1257. if not clubId then
  1258. return
  1259. end
  1260. if not content then
  1261. return
  1262. end
  1263. local clubInfo = self.clubList[clubId]
  1264. if not clubInfo then
  1265. return
  1266. end
  1267. if self.clubList[clubId] and content then
  1268. if content.is_privacy then
  1269. self.clubList[clubId].isPrivacy = tonumber(content.is_privacy)==1 --隐私1开启隐私0默认关闭
  1270. -- self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_LIST})
  1271. end
  1272. if content.room_mode then
  1273. self.clubList[clubId].mode = tonumber(content.room_mode) --茶馆模式
  1274. -- 模式发生变化,需要重新更新桌子列表
  1275. self.clubList[clubId].rooms = {}
  1276. self:requestClubHome(clubId)
  1277. end
  1278. if content.is_gamb then
  1279. self.clubList[clubId].isGamb = tonumber(content.is_gamb) == 1
  1280. end
  1281. if content.is_coapply then
  1282. self.clubList[clubId].isCoapply = tonumber(content.is_coapply) == 1
  1283. end
  1284. if content.is_wxshare then
  1285. self.clubList[clubId].isWxshare = tonumber(content.is_wxshare)==0 -- 0微信分享
  1286. end
  1287. if content.is_apply then
  1288. self.clubList[clubId].isApply = tonumber(content.is_apply) == 1
  1289. end
  1290. if content.is_exitapply then
  1291. self.clubList[clubId].isExitApply = tonumber(content.is_exitapply) == 1
  1292. end
  1293. if content.groupext then
  1294. if not self.clubList[clubId].groupext then
  1295. self.clubList[clubId].groupext = {}
  1296. end
  1297. if content.groupext.playext and type(content.groupext.playext) == "string" then
  1298. self.clubList[clubId].groupext.playext = json.decode(content.groupext.playext)
  1299. end
  1300. if content.groupext.is_gps then
  1301. self.clubList[clubId].groupext.is_gps = tonumber(content.groupext.is_gps)
  1302. end
  1303. if content.groupext.gps_limit then
  1304. self.clubList[clubId].groupext.gps_limit = tonumber(content.groupext.gps_limit)
  1305. end
  1306. if content.groupext.cliext and type(content.groupext.cliext) == "string" then
  1307. self.clubList[clubId].groupext.cliext = json.decode(content.groupext.cliext)
  1308. end
  1309. if content.groupext.is_playerpri then
  1310. self.clubList[clubId].groupext.is_playerpri = tonumber(content.groupext.is_playerpri)
  1311. end
  1312. end
  1313. if content.gname then
  1314. if self.clubList[clubId] and content then
  1315. self.clubList[clubId].clubName = content.gname or self.clubList[clubId].clubName
  1316. end
  1317. end
  1318. if content.is_arena then
  1319. self.clubList[clubId].isArena = content.is_arena or clubInfo.isArena
  1320. self:dispatchEvent({name = GAME_EVENT.CLUB_SET,setType = GAME_CLUB_SET_STATE.Math_Switch})
  1321. end
  1322. end
  1323. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_PUSH})
  1324. elseif msgType == ClubDefine.PUSH.changePlayer then --成员修改
  1325. local clubId = tonumber(message.gid)
  1326. local viewType = toNumber(message.content.viewType) or 0
  1327. --合盟模式有些数据和排名赛一样,比如排名分,上报分,裁判等走了10022的通道,viewType下发是副盟模式,需要改为排名赛
  1328. if self:getIsUnion(clubId) and viewType == ClubDefine.PlayListType.UNION_CLUB_LIST then
  1329. viewType = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER
  1330. end
  1331. if message.content.type == 0 then --删除成员
  1332. local uids = message.content.delUids
  1333. if self.clubList[clubId] and uids then
  1334. if self.clubList[clubId].playersLevelOne then
  1335. for k,uid in pairs(uids) do
  1336. self.clubList[clubId].playersLevelOne[tonumber(uid)] = nil
  1337. end
  1338. end
  1339. if self.clubList[clubId].playersLevelTwo then
  1340. for k,uid in pairs(uids) do
  1341. self.clubList[clubId].playersLevelTwo[tonumber(uid)] = nil
  1342. end
  1343. end
  1344. if self.clubList[clubId].playersLevelThree then
  1345. for k,uid in pairs(uids) do
  1346. self.clubList[clubId].playersLevelThree[tonumber(uid)] = nil
  1347. end
  1348. end
  1349. if self.clubList[clubId].playersMatch then
  1350. for k,uid in pairs(uids) do
  1351. self.clubList[clubId].playersMatch[tonumber(uid)] = nil
  1352. end
  1353. end
  1354. for k,uid in pairs(uids) do
  1355. self.clubList[clubId].players[tonumber(uid)] = nil
  1356. end
  1357. self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST})
  1358. end
  1359. elseif message.content.type == 1 then --新增成员
  1360. local members = message.content.members
  1361. for k,v in pairs(members) do
  1362. self:updateClubPlayer(clubId,v,nil,viewType)
  1363. end
  1364. --self:requestClubList()如果是在俱乐部列表界面想刷新人数,被动刷新比较好,不要主动下发
  1365. --这里的ViewType是服务器主动下发的,空的,后续需要分发到界面,然后由界面去请求,这样可以请求到某一天的列表
  1366. self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST})
  1367. elseif message.content.type == 2 then --修改成员权限
  1368. local members = message.content.members
  1369. for k,v in pairs(members) do
  1370. --比赛场:在一级下属界面修改了一级合伙人的冻结权限,在比赛成员界面需要更新权限,类似的还有二级
  1371. if (viewType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_MEMBER and v.role == ClubDefine.Job.LevelOneCopartner)
  1372. or (viewType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_MEMBER and v.role == ClubDefine.Job.LevelTwoCopartner) then
  1373. self:updateClubPlayer(clubId,v,true,ClubDefine.PlayListType.MATCH_MEMBER)
  1374. end
  1375. --全民赛:在队长下属界面修改了队长的冻结权限等操作,在全民赛管理界面需要更新权限,类似的还有小队长,小组长
  1376. if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER
  1377. or viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER
  1378. or viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then
  1379. self:updateClubPlayer(clubId,v,true,ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER)
  1380. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER})
  1381. end
  1382. --全民赛:在小队长下属界面修改了小队长数据,需要刷新队长。
  1383. if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER
  1384. or viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then
  1385. self:updateClubPlayer(clubId,v,true,ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER)
  1386. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER})
  1387. end
  1388. --全民赛:在小组长下属界面修改了小组长数据,需要刷新小队长。
  1389. if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then
  1390. self:updateClubPlayer(clubId,v,true,ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER)
  1391. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER})
  1392. end
  1393. self:updateClubPlayer(clubId,v,true,viewType)
  1394. if v.uid==tonumber(app.user.loginInfo.uid) and v.role then--更新茶馆角色信息
  1395. if self.clubList[clubId] and self.clubList[clubId].role ~= tonumber(v.role) then
  1396. self.clubList[clubId].role = tonumber(v.role)
  1397. --取消
  1398. if self.clubList[clubId].role ~= ClubDefine.Job.Manager and self.clubList[clubId].role ~= ClubDefine.Job.Creator then
  1399. if self.clubList[clubId].groupext then
  1400. self.clubList[clubId].groupext.is_playerpri = 1
  1401. end
  1402. end
  1403. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_ROLE})
  1404. self:dispatchEvent({name = GAME_EVENT.CLUB_TABLE, clubId = clubId})
  1405. end
  1406. end
  1407. -- 海选赛修改权限,就修改消息:海选赛申请(管理员、队长和小队长的权限)
  1408. if app.club_php:getCestIsOpen(clubId) then
  1409. if v.grant then
  1410. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_UPDATE_APPLY_LIST})
  1411. end
  1412. end
  1413. end
  1414. if viewType == ClubDefine.PlayListType.MATCH_MEMBER then
  1415. self:dispatchEvent({name = GAME_EVENT.UPDATE_COPARTNER_RATDIO})
  1416. end
  1417. end
  1418. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_LIST,type = viewType})
  1419. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = viewType})
  1420. elseif msgType == ClubDefine.PUSH.kickClubPlayer then --踢出茶馆
  1421. local clubId = tonumber(message.gid)
  1422. self.clubList[clubId] = nil
  1423. -- 客户端自己改好了,有空再叫老麦改
  1424. message.content = string.gsub(message.content, "馆主", "主办人")
  1425. message.content = string.gsub(message.content, "退群", "退出赛事")
  1426. message.content = string.gsub(message.content, "亲友圈", "赛事")
  1427. message.content = string.gsub(message.content, "创始人", "主办人")
  1428. showTooltip(message.content)
  1429. self:dispatchEvent({name = GAME_EVENT.CLUB_LIST})
  1430. self:dispatchEvent({name = GAME_EVENT.CLUB_JIE_SAN, clubId = clubId})
  1431. --由于被踢出去了,之前打开的操作界面要关闭
  1432. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_ROLE})
  1433. elseif msgType == ClubDefine.PUSH.applyClubSuccess then --申请茶馆成功
  1434. local clubId = tonumber(message.gid)
  1435. -- showTooltip(message.content)
  1436. self:requestClub(clubId)
  1437. self:dispatchEvent({name = GAME_EVENT.CLUB_LIST})
  1438. elseif msgType == ClubDefine.PUSH.changeRoom then --更新房间数据
  1439. local clubId = tonumber(message.gid)
  1440. local content = json.decode(message.content or "")
  1441. if not clubId then
  1442. logD("ClubProtocolPhp:onPhpMessage() clubId is nil")
  1443. return
  1444. end
  1445. if not content then
  1446. logD("ClubProtocolPhp:onPhpMessage() content is nil")
  1447. return
  1448. end
  1449. local clubInfo = self.clubList[clubId]
  1450. if not clubInfo then
  1451. logD("ClubProtocolPhp:onPhpMessage() clubInfo is nil")
  1452. return
  1453. end
  1454. if not self:isNeedUpdateTable(clubId,content.ruleid) then
  1455. logD("ClubProtocolPhp:onPhpMessage() not need update table")
  1456. return
  1457. end
  1458. local isUpdateTable = false
  1459. local isTableNumChanged = false; -- 房间数量是否发生变化
  1460. if content then
  1461. local contentType = tonumber(content.type)
  1462. if content.userInfo and table.nums(content.userInfo) == 0 then --没有人在房间则删除房间
  1463. if self.clubList[clubId] and self.clubList[clubId].rooms then
  1464. self.clubList[clubId].rooms[tonumber(content.pos_number)] = nil
  1465. self.clubList[clubId].posList[tonumber(content.pos_number)] = false
  1466. isUpdateTable = true
  1467. isTableNumChanged = true
  1468. end
  1469. else
  1470. --没有房间为新增
  1471. if self.clubList[clubId] and self.clubList[clubId].rooms and not self.clubList[clubId].rooms[tonumber(content.pos_number)] then
  1472. isUpdateTable = true
  1473. isTableNumChanged = true
  1474. end
  1475. local status,statusNew
  1476. if contentType == 1 then --所有数据
  1477. status = content.status
  1478. self:updateClubRoom(clubId,content)
  1479. statusNew = self.clubList[clubId].rooms[tonumber(content.pos_number)].status
  1480. elseif contentType == 2 then --部分数据 需要判断房间数据是否存在不存在丢弃
  1481. if self.clubList[clubId] and self.clubList[clubId].rooms and self.clubList[clubId].rooms[tonumber(content.pos_number)] then
  1482. status = self.clubList[clubId].rooms[tonumber(content.pos_number)].status
  1483. self:updateClubRoom(clubId,content)
  1484. statusNew = self.clubList[clubId].rooms[tonumber(content.pos_number)].status
  1485. end
  1486. end
  1487. --未开局变为已开局的时候需要刷新
  1488. if status == 1 and statusNew == 2 then
  1489. isTableNumChanged = true
  1490. end
  1491. end
  1492. end
  1493. logD("ClubProtocolPhp:onPhpMessage() isTableNumChanged = ", tostring(isTableNumChanged))
  1494. -- 桌子数量发生变化则更新桌子列表,否则只更新发生变化的桌子
  1495. if isTableNumChanged then
  1496. local baoJian = self:getBaoJian(clubId,content.ruleid)
  1497. local gameId = baoJian.gameId
  1498. self:dispatchEvent({name = GAME_EVENT.CLUB_ROOM_LIST_UPDATE, clubId = clubId,gameId = gameId})
  1499. else
  1500. self:dispatchEvent({name = GAME_EVENT.CLUB_UPDATE_TABLE, clubId = clubId, pos = tonumber(content.pos_number)})
  1501. end
  1502. elseif msgType == ClubDefine.PUSH.changeClubNotice then --更新公告
  1503. local clubId = tonumber(message.gid)
  1504. if self.clubList[clubId] then
  1505. self.clubList[clubId].noticeInfo = message.content
  1506. self.clubList[clubId].notice = message.content.notice
  1507. end
  1508. self:dispatchEvent({name = GAME_EVENT.CLUB_NOTICE})
  1509. -- local content = json.decode(message.content or "")
  1510. elseif msgType == ClubDefine.PUSH.changeClubTableNum then --更新在线桌数
  1511. local clubId = tonumber(message.gid)
  1512. local content = json.decode(message.content or "")
  1513. if content then
  1514. local baoJianId = tonumber(content.ruleid)
  1515. local onlineroom = tonumber(content.onlineroom)
  1516. local baoJian = self:getBaoJian(clubId,baoJianId)
  1517. if baoJian then
  1518. baoJian.onlineRoomNum = onlineroom
  1519. end
  1520. if self.clubList[clubId] then
  1521. self.clubList[clubId].onlineRoomNum = onlineroom
  1522. self:dispatchEvent({name = GAME_EVENT.CLUB_TABLE_NUM})
  1523. end
  1524. end
  1525. elseif msgType == ClubDefine.PUSH.message then --消息推送
  1526. local clubId = tonumber(message.gid)
  1527. local newContent = message.newContent or {}
  1528. if self.clubList[clubId] and newContent.unionhints then
  1529. self.clubList[clubId].isUnionHints = tonumber(newContent.unionhints) == 1
  1530. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_HITS})
  1531. else
  1532. if self.clubList[clubId] then
  1533. self.clubList[clubId].isHints = true
  1534. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE})
  1535. end
  1536. end
  1537. elseif msgType == ClubDefine.PUSH.invite then --邀请好友
  1538. local clubId = tonumber(message.gid)
  1539. local content = json.decode(message.content or "")
  1540. if content then
  1541. self:dispatchEvent({name = GAME_EVENT.CLUB_INVITE, clubId = clubId, content = content})
  1542. end
  1543. elseif msgType == ClubDefine.PUSH.dayingjiaset then
  1544. local clubId = tonumber(message.gid)
  1545. local content = message.content or {}
  1546. if content then
  1547. local clubList = app.club_php.clubList[tonumber(clubId)]
  1548. if clubList then
  1549. local ruleList = clubList.baoJians;
  1550. for k,v in pairs(content) do
  1551. if ruleList[tonumber(k)] then
  1552. ruleList[tonumber(k)].playWinScore = v.play_win_threshold or 0
  1553. end
  1554. end
  1555. end
  1556. end
  1557. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_PUSH})
  1558. elseif msgType == ClubDefine.PUSH.changeClubBg then
  1559. local clubId = tonumber(message.gid)
  1560. local content = message.content or {}
  1561. local clubInfo = app.club_php.clubList[clubId];
  1562. if content.prop and clubInfo then
  1563. if clubInfo.club_bgprop then
  1564. clubInfo.club_bgprop = content.prop or clubInfo.club_bgprop or {}
  1565. end
  1566. end
  1567. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_BG})
  1568. elseif msgType == ClubDefine.PUSH.cancelCopartner then
  1569. local clubId = tonumber(message.gid)
  1570. local content = message.content or {}
  1571. local cancelCopartner = content.cancelCopartner
  1572. if cancelCopartner and cancelCopartner.uid then
  1573. self:dispatchEvent({name = GAME_EVENT.CLUB_CANCEL_COPARTNER_NOTICE,response = cancelCopartner})
  1574. end
  1575. elseif msgType == ClubDefine.PUSH.gameActive then
  1576. local clubId = tonumber(message.gid)
  1577. local content = message.content or {}
  1578. if clubId then
  1579. self:requestClubHome(clubId,nil,nil,2)
  1580. end
  1581. elseif msgType == ClubDefine.PUSH.updateUnionMasterState then
  1582. local clubId = tonumber(message.gid)
  1583. local clubId = tonumber(message.gid)
  1584. local viewType = toNumber(message.content.viewType) or ClubDefine.PlayListType.UNION_CLUB_LIST
  1585. if message.content.type == 0 then --删除成员
  1586. local gidList = message.content.delGids
  1587. if self.clubList[clubId] and gidList then
  1588. for k,gid in pairs(gidList) do
  1589. self.clubList[clubId].unionPlayerList[tonumber(gid)] = nil
  1590. end
  1591. self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST})
  1592. end
  1593. elseif message.content.type == 1 then --新增成员
  1594. local groups = message.content.groups
  1595. if groups then
  1596. for k,v in pairs(groups) do
  1597. self:updateClubUnionClubId(clubId,v,nil,viewType)
  1598. end
  1599. end
  1600. self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST})
  1601. elseif message.content.type == 2 then --修改副盟属性更新
  1602. local groups = message.content.groups
  1603. if groups then
  1604. for k,v in pairs(groups) do
  1605. self:updateClubUnionClubId(clubId,v,true,viewType)
  1606. end
  1607. end
  1608. end
  1609. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_JOIN_MASTER_LIST,type = viewType})
  1610. elseif msgType == ClubDefine.PUSH.updateUnionSlaveState then
  1611. local clubId = tonumber(message.gid)
  1612. local content = message.content or {}
  1613. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_SLAVE_UPDATE})
  1614. --status : {1正常, 2冻结, 0解除联盟关系, 3加入主盟,更新桌子}
  1615. if content.status == 0 or content.status == 3 or content.status == 4 then
  1616. self:requestClubHome(clubId)
  1617. end
  1618. elseif msgType == ClubDefine.PUSH.updateCestStatus then --刷新玩家CEST个人信息
  1619. local clubId = tonumber(message.gid)
  1620. self:requestCestUserInfo(clubId)
  1621. elseif msgType == ClubDefine.PUSH.updateCestSet then --刷新玩家CEST 三个场的设置
  1622. local clubId = tonumber(message.gid)
  1623. if clubId then
  1624. if app.club_php:getCestIsOpen(clubId) then
  1625. self:requestCestGameInfo({clubId=clubId})
  1626. end
  1627. end
  1628. elseif msgType == ClubDefine.PUSH.updateCestManage then -- 刷新CEST管理界面
  1629. self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST})
  1630. elseif msgType == ClubDefine.PUSH.updateCestMinge then -- 刷新CEST用户参赛名额次
  1631. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_REQUEST_MINGE_INFO})
  1632. elseif msgType == ClubDefine.PUSH.updateCestApplyMessage then -- 刷新CEST海选赛申请消息
  1633. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_UPDATE_APPLY_LIST})
  1634. end
  1635. end
  1636. function ClubProtocolPhp:isNeedUpdateTable(clubId,ruleid)
  1637. -- 如果不是当前激活的玩法的桌子数据,则丢弃不处理
  1638. local clubRuldId = self:getSelectBaoJianId()
  1639. local clubLeftGame = self:getSelectGameId()
  1640. local baoJian = self:getBaoJian(clubId,ruleid)
  1641. local currentGameId = 0
  1642. if baoJian then
  1643. currentGameId = baoJian.gameId
  1644. end
  1645. logD("clubLeftGame:",clubLeftGame)
  1646. logD("clubRuldId:",clubRuldId)
  1647. logD("currentGameId:",currentGameId)
  1648. --0代表全部游戏or包间选项
  1649. if clubLeftGame ~= 0 and currentGameId ~= clubLeftGame or currentGameId == 0 then
  1650. --非处于全部游戏状态,不同游戏禁止刷新
  1651. return false;
  1652. end
  1653. if clubLeftGame ~= 0 and clubRuldId ~= 0 and clubRuldId ~= tonumber(ruleid) then
  1654. --非处于全部游戏且非全部包间场景,不同玩法禁止刷新
  1655. return false;
  1656. end
  1657. return true
  1658. end
  1659. --获取俱乐部列表
  1660. function ClubProtocolPhp:requestClubList(callback)
  1661. local param = {
  1662. version = "20180605"
  1663. }
  1664. self:post(Cmd.PHP_CLUB_LIST,param,function(response)
  1665. --logD("ClubProtocolPhp:getClubList",table.tostring(response))
  1666. if response.code==200 then
  1667. local result = response.result
  1668. --被踢出茶馆时,(防止没有收到推送)检测删掉已经被踢出的茶馆的数据
  1669. if next(result) ~= nil then
  1670. local tExitClub = {}
  1671. for k,v in pairs(self.clubList) do
  1672. for i,j in pairs(result) do
  1673. if v.clubId == tonumber(j.gid) then
  1674. tExitClub[v.clubId] = true
  1675. end
  1676. end
  1677. end
  1678. for k,v in pairs(self.clubList) do
  1679. if not tExitClub[v.clubId] then
  1680. self.clubList[k] = nil
  1681. end
  1682. end
  1683. for k,v in pairs(result) do
  1684. self:updateClub(v)
  1685. self:updateClubSettings(v.gid,v.settings)
  1686. end
  1687. end
  1688. if callback then callback() end
  1689. self:dispatchEvent({name = GAME_EVENT.CLUB_LIST})
  1690. end
  1691. end)
  1692. end
  1693. --获取俱乐部列表
  1694. function ClubProtocolPhp:requestAllClubList(callback,version)
  1695. local param = {
  1696. version = version or "20190617"
  1697. }
  1698. self:post(Cmd.PHP_CLUB_LIST,param,function(response)
  1699. logD("ClubProtocolPhp:requestAllClubList",table.tostring(response))
  1700. if response.code==200 then
  1701. local result = response.result
  1702. --被踢出茶馆时,(防止没有收到推送)检测删掉已经被踢出的茶馆的数据
  1703. if next(result) ~= nil then
  1704. --[[local tExitClub = {}
  1705. for k,v in pairs(self.clubList) do
  1706. for i,j in pairs(result) do
  1707. if v.clubId == tonumber(j.gid) then
  1708. tExitClub[v.clubId] = true
  1709. end
  1710. end
  1711. end
  1712. for k,v in pairs(self.clubList) do
  1713. if not tExitClub[v.clubId] then
  1714. self.clubList[k] = nil
  1715. end
  1716. end--]]
  1717. self.clubListAll = {}
  1718. for k,v in pairs(result) do
  1719. self:updateClub(v,true)
  1720. end
  1721. end
  1722. if callback then callback() end
  1723. self:dispatchEvent({name = GAME_EVENT.CLUB_LIST})
  1724. end
  1725. end)
  1726. end
  1727. function ClubProtocolPhp:getClubList()
  1728. logD("getClubList 已经修改为 requestClubList")
  1729. self:requestClubList()
  1730. end
  1731. function ClubProtocolPhp:getClubInfo(clubId)
  1732. if self.clubList then
  1733. return self.clubList[clubId]
  1734. else
  1735. return nil
  1736. end
  1737. end
  1738. function ClubProtocolPhp:requestClub(clubId)
  1739. local param = {
  1740. gid = clubId,
  1741. version = "20180605"
  1742. }
  1743. self:post(Cmd.PHP_CLUB_ONE_CLUB,param,function(response)
  1744. logD("ClubProtocolPhp:requestClub",table.tostring(response))
  1745. if response.code==200 then
  1746. local result = response.result
  1747. if next(result) ~= nil then
  1748. self:updateClub(result)
  1749. self:updateClubSettings(result.gid,result.settings)
  1750. end
  1751. self:dispatchEvent({name = GAME_EVENT.CLUB_LIST})
  1752. end
  1753. end)
  1754. end
  1755. function ClubProtocolPhp:clubInviteSameTable()
  1756. local GameRoomId = getGameRoomId()
  1757. log("ClubProtocolPhp:clubInviteSameTable() GameRoomId = ", GameRoomId)
  1758. local BroadcastCode = 10050;
  1759. local Content = {};
  1760. Content.roomid = GameRoomId
  1761. Content.gname = self.clubList[app.club_php.clubID].clubName
  1762. local gclubInfo = self.clubList[app.club_php.clubID]
  1763. local myUserInfo = json.decode(app.user.userInfo)
  1764. local userInfo = {
  1765. uid = app.user.loginInfo.uid,
  1766. nick = myUserInfo.nickname,
  1767. icon = myUserInfo.headimgurl,
  1768. baojianid = tonumber(getAgainGameBaoJianId()),
  1769. }
  1770. local uids = ""
  1771. local againbol,wanfa,uidList = getIsAgainGamebol()
  1772. if uidList then
  1773. for k,v in pairs(uidList) do
  1774. uids = uids..v
  1775. if k ~= #uidList then
  1776. uids = uids..","
  1777. end
  1778. end
  1779. end
  1780. Content.userInfo = userInfo
  1781. self.ruleStr = wanfa
  1782. setIsAgainGamebol(false,"")
  1783. setMyGameCreateStatus(false)
  1784. setAgainGameBaoJianId(-1)
  1785. Content.gamerule = self.ruleStr
  1786. local BroadcastContent = json.encode(Content)
  1787. log("ClubProtocolPhp:clubInviteSameTable() BroadcastContent = ", BroadcastContent)
  1788. app.club_php:requestBroadcast(app.club_php.clubID, uids, BroadcastCode, BroadcastContent)
  1789. end
  1790. --请求茶馆玩法
  1791. function ClubProtocolPhp:requestGameRule(clubId)
  1792. local param = {
  1793. gid = clubId
  1794. }
  1795. self:post(Cmd.PHP_CLUB_GET_GAME_RULE,param,function(response)
  1796. logD("ClubProtocolPhp:requestGameRule",table.tostring(response))
  1797. --返回的status:1正常2禁止选择3隐藏
  1798. if response.code==200 then
  1799. local result = response.result
  1800. self:dispatchEvent({name = GAME_EVENT.CLUB_GAME_RULE, result = result})
  1801. end
  1802. end)
  1803. end
  1804. --设置玩法
  1805. function ClubProtocolPhp:requestChangeRule(clubId,baoJianId,gameId,gameNum,gameRule,isDelete,arena,title)
  1806. local param = {
  1807. gid = clubId,
  1808. ruleid = baoJianId,
  1809. game_id = gameId,
  1810. game_num = gameNum,
  1811. gamerule = gameRule,
  1812. is_delete = isDelete,
  1813. arena = arena,
  1814. title = title or "",
  1815. version = "20190822"
  1816. }
  1817. app.waitDialogManager:showWaitNetworkDialog("正在保存玩法...")
  1818. self:post(Cmd.PHP_CLUB_CHANGE_RULE,param,function(response)
  1819. app.waitDialogManager:closeWaitNetworkDialog()
  1820. logD("ClubProtocolPhp:requestChangeRule",table.tostring(response))
  1821. if response.code==200 then
  1822. if isDelete == 1 then
  1823. showTooltip("玩法删除成功")
  1824. else
  1825. showTooltip("玩法保存成功")
  1826. end
  1827. --save
  1828. local club = self.clubList[clubId]
  1829. if club then
  1830. local baojian = self:getBaoJian(clubId,gameId,baoJianId)
  1831. if baojian then
  1832. baojian.arena = arena
  1833. end
  1834. end
  1835. --self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE})
  1836. else
  1837. self:showError(Cmd.PHP_CLUB_CHANGE_RULE,response)
  1838. end
  1839. end)
  1840. end
  1841. --更新包间设置
  1842. function ClubProtocolPhp:requestRuleSet(clubId,baoJianId,tp,value)
  1843. local param = {
  1844. gid = clubId,
  1845. ruleid = baoJianId,
  1846. type = tp, --1:切换包间(任意成员) $value = 1, 2更新玩法名(管理员/创始人), $value = title type3包间信息更新 4 设置包间的比赛场参数你看看
  1847. value = value,
  1848. }
  1849. -- app.waitDialogManager:showWaitNetworkDialog("连接中...")
  1850. self:post(Cmd.PHP_CLUB_RULE_SET,param,function(response)
  1851. -- app.waitDialogManager:closeWaitNetworkDialog()
  1852. logD("ClubProtocolPhp:requestRuleSet",table.tostring(response))
  1853. if response.code==200 then
  1854. if tp==1 then --切换包间
  1855. if app.club_php:getCestIsOpen(clubId) then
  1856. showTooltip("切换赛事成功")
  1857. else
  1858. showTooltip("切换包间成功")
  1859. end
  1860. self:updateClubSettingsByBaoJian(clubId,baoJianId)
  1861. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_BAO_JIAN})
  1862. elseif tp == 2 then
  1863. self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_BAO_JIAN_NAME})
  1864. elseif tp == 3 then
  1865. showTooltip("设置成功")
  1866. self:dispatchEvent({name = GAME_EVENT.CLUB_SET})
  1867. elseif tp == 4 then
  1868. showTooltip("设置成功")
  1869. local club = self.clubList[clubId]
  1870. if club then
  1871. local baojian = self:getBaoJian(clubId,baoJianId)
  1872. if baojian then
  1873. local valueData = json.decode(value)
  1874. baojian.arena = json.encode(valueData[tostring(baoJianId)])
  1875. end
  1876. end
  1877. self:dispatchEvent({name = GAME_EVENT.CLUB_SET_MATCH})
  1878. end
  1879. else
  1880. self:showError(Cmd.PHP_CLUB_RULE_SET,response)
  1881. end
  1882. end)
  1883. end
  1884. --批量更新包间设置
  1885. function ClubProtocolPhp:requestSetAllBaoJian(clubId,tp,value)
  1886. local param = {
  1887. gid = clubId,
  1888. type = tp, --5更新包间样式
  1889. values = value,
  1890. }
  1891. self:post(Cmd.PHP_CLUB_BAOJIAN_SET_STYLE,param,function(response)
  1892. logD("ClubProtocolPhp:requestSetAllBaoJian",table.tostring(response))
  1893. if response.code == 200 then
  1894. if tp == 5 then --切换包间
  1895. showTooltip("设置成功")
  1896. --self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_BAO_JIAN})
  1897. end
  1898. else
  1899. self:showError(Cmd.PHP_CLUB_BAOJIAN_SET_STYLE,response)
  1900. end
  1901. end)
  1902. end
  1903. --创建茶馆
  1904. function ClubProtocolPhp:requestCreateClub(clubName)
  1905. local param = {
  1906. groupname = clubName,
  1907. version = app.config.ModuleConfig.IsSupportRankMatch and "20191101" or nil
  1908. }
  1909. app.waitDialogManager:showWaitNetworkDialog("连接中...")
  1910. self:post(Cmd.PHP_CLUB_CREATE,param,function(response)
  1911. app.waitDialogManager:closeWaitNetworkDialog()
  1912. logD("ClubProtocolPhp:requestCreateClub",table.tostring(response))
  1913. if response.code==200 then
  1914. showTooltip(PLN.CLUB_CEST_CREATE_SUCCESS)
  1915. local result = response.result
  1916. self:updateClub(result)
  1917. self:updateClubSettings(result.gid,result.settings)
  1918. self:dispatchEvent({name = GAME_EVENT.CLUB_LIST})
  1919. self:dispatchEvent({name = GAME_EVENT.CLUB_CREATE_SUCCESS, data = result})
  1920. if cc.Application:getInstance():getTargetPlatform() == 0 then
  1921. cc.UserDefault:getInstance():setIntegerForKey("LastTestClubID",result.gid)
  1922. cc.UserDefault:getInstance():flush()
  1923. end
  1924. else
  1925. response.error = string.gsub(response.error,"茶馆", "赛事")
  1926. response.error = string.gsub(response.error,"亲友圈", "赛事")
  1927. self:showError(Cmd.PHP_CLUB_CREATE,response)
  1928. end
  1929. end)
  1930. end
  1931. --加入茶馆
  1932. function ClubProtocolPhp:requestJoinClub(clubId,playerName,headImgUrl)
  1933. local param = {
  1934. gid = clubId,
  1935. nick = playerName,
  1936. icon = headImgUrl,
  1937. }
  1938. self:post(Cmd.PHP_CLUB_JOIN,param,function(response)
  1939. logD("ClubProtocolPhp:requestJoinClub",table.tostring(response))
  1940. self:dispatchEvent({name = GAME_EVENT.CLUB_JOIN , errCode = response.code})
  1941. end)
  1942. end
  1943. --退出茶馆
  1944. function ClubProtocolPhp:requestExitClub(clubId)
  1945. local param = {
  1946. gid = clubId,
  1947. }
  1948. self:post(Cmd.PHP_CLUB_EXIT,param,function(response)
  1949. logD("ClubProtocolPhp:requestExitClub",table.tostring(response))
  1950. if response.code == 200 then
  1951. -- 先帮PHP处理
  1952. if app.club_php:getCestIsOpen(clubId) then
  1953. if response.result.content then
  1954. response.result.content = string.gsub(response.result.content, "亲友圈", "赛事")
  1955. end
  1956. end
  1957. if response.result and response.result.is_exitapply == 1 then
  1958. if response.result.content then
  1959. showTooltip(tostring(response.result.content))
  1960. else
  1961. showTooltip(tostring(response.error))
  1962. end
  1963. else
  1964. self.clubList[clubId] = nil
  1965. self:dispatchEvent({name = GAME_EVENT.CLUB_JIE_SAN, clubId = clubId})
  1966. self:dispatchEvent({name = GAME_EVENT.CLUB_LIST})
  1967. end
  1968. else
  1969. -- 先帮PHP处理
  1970. if app.club_php:getCestIsOpen(clubId) then
  1971. if response.code then
  1972. if tostring(response.code) == "1011" then
  1973. response.error = "请先结束本轮比赛后再退出!"
  1974. end
  1975. end
  1976. if response.error then
  1977. response.error = string.gsub(response.error, "成员", "选手")
  1978. response.error = string.gsub(response.error, "排名分", "成绩")
  1979. end
  1980. end
  1981. self:showError(Cmd.PHP_CLUB_EXIT,response)
  1982. end
  1983. end)
  1984. end
  1985. --设置茶馆
  1986. function ClubProtocolPhp:requestSetClub(clubId,setType,value)
  1987. local param = {
  1988. gid = clubId,
  1989. type = setType,
  1990. value = value,
  1991. }
  1992. --1 => 状态操作茶馆(管理员) $value 1正常2冻结0解散,
  1993. --2 => 加入设置 (管理员) $value 1需要申请,0无需申请,
  1994. --3 => 修改昵称(管理员) $value 新群名
  1995. --4 => 隐私修改 $value 1开启隐私0默认关闭
  1996. --6 => 微信分享is_wxshare $value 1禁止微信分享, 0开启;
  1997. --7 => 房间模式修改room_mode$value 1多玩法模式, 0包间模式;
  1998. --8 => 大赢家特殊统计阈值修改修改play_win_threshold $value 给最后确认的数值(没有广播)
  1999. self:post(Cmd.PHP_CLUB_SET,param,function(response)
  2000. logD("ClubProtocolPhp:requestSetClub",table.tostring(response))
  2001. if response.code==200 then
  2002. --修改茶馆申请参数
  2003. if setType==GAME_CLUB_SET_STATE.Join_set then
  2004. local club = self.clubList[clubId]
  2005. if club then
  2006. club.isApply = value==1
  2007. end
  2008. elseif setType==GAME_CLUB_SET_STATE.Set_win_socre then
  2009. local club = self.clubList[clubId]
  2010. if club then
  2011. club.playWinScore = value
  2012. end
  2013. elseif setType==GAME_CLUB_SET_STATE.Quit_set then
  2014. local club = self.clubList[clubId]
  2015. if club then
  2016. club.isExitApply = value==1
  2017. end
  2018. end
  2019. showTooltip("设置成功")
  2020. -- local result = response.result
  2021. -- self:updateClub(result)
  2022. self:dispatchEvent({name = GAME_EVENT.CLUB_SET , setType = setType, value = value})
  2023. else
  2024. -- 先帮PHP处理
  2025. if app.club_php:getCestIsOpen(clubId) then
  2026. if response.code then
  2027. if tostring(response.code) == "1010" then
  2028. response.error = "解散失败,名下选手本轮成绩未上报,请结束本轮比赛后再解散!"
  2029. end
  2030. end
  2031. end
  2032. self:showError(Cmd.PHP_CLUB_SET,response)
  2033. end
  2034. end)
  2035. end
  2036. --多设置茶馆
  2037. function ClubProtocolPhp:requestSetClubNew(clubId,jsonData,callback)
  2038. local tt = {
  2039. gid = clubId,
  2040. type = jsonData.type or 1,
  2041. }
  2042. local params = jsonData
  2043. tt.params = json.encode(params)
  2044. self:post(Cmd.PHP_CLUB_SET_MORE,tt,function(response)
  2045. logD("ClubProtocolPhp:requestSetClubNew",table.tostring(response))
  2046. if response.code==200 then
  2047. --type 0的情况,服务器不做通知。
  2048. if tt.type == 0 then
  2049. local clubInfo = self.clubList[clubId]
  2050. if clubInfo then
  2051. local cliext = clubInfo.groupext and clubInfo.groupext.cliext
  2052. if cliext then
  2053. cliext.readUnionGuide = 1
  2054. end
  2055. end
  2056. else
  2057. --修改茶馆申请参数
  2058. showTooltip("设置成功")
  2059. self:dispatchEvent({name = GAME_EVENT.CLUB_SET})
  2060. end
  2061. if self:getCestIsOpen(clubId) then
  2062. self:setCestFirst(clubId, false)
  2063. if jsonData.cestext then -- 修改成功后,更新海选赛三个场的积分和轮数信息
  2064. local cestext = json.decode(jsonData.cestext)
  2065. local club = self.clubCestInfo
  2066. -- club.one_gamenum =cestext.one_gamenum or self.clubCestInfo.one_gamenum or 0
  2067. -- club.one_point =cestext.one_point or self.clubCestInfo.one_point or 0
  2068. -- club.two_gamenum =cestext.two_gamenum or self.clubCestInfo.two_gamenum or 0
  2069. -- club.two_point =cestext.two_point or self.clubCestInfo.two_point or 0
  2070. -- club.three_gamenum =cestext.three_gamenum or self.clubCestInfo.three_gamenum or 0
  2071. -- club.three_point =cestext.three_point or self.clubCestInfo.three_point or 0
  2072. local clubInfo = self:getClubInfo(clubId)
  2073. if clubInfo then
  2074. if clubInfo.groupext then
  2075. if clubInfo.groupext.cestext then
  2076. if clubInfo.groupext.cestext.one_gamenum then
  2077. clubInfo.groupext.cestext.one_gamenum = cestext.one_gamenum or self.clubCestInfo.one_gamenum or 0
  2078. clubInfo.groupext.cestext.one_point =cestext.one_point or self.clubCestInfo.one_point or 0
  2079. clubInfo.groupext.cestext.two_gamenum =cestext.two_gamenum or self.clubCestInfo.two_gamenum or 0
  2080. clubInfo.groupext.cestext.two_point =cestext.two_point or self.clubCestInfo.two_point or 0
  2081. clubInfo.groupext.cestext.three_gamenum =cestext.three_gamenum or self.clubCestInfo.three_gamenum or 0
  2082. clubInfo.groupext.cestext.three_point =cestext.three_point or self.clubCestInfo.three_point or 0
  2083. clubInfo.groupext.cestext.mid_gamenum =cestext.mid_gamenum or self.clubCestInfo.mid_gamenum or 0
  2084. clubInfo.groupext.cestext.mid_point =cestext.mid_point or self.clubCestInfo.mid_point or 0
  2085. end
  2086. end
  2087. end
  2088. end
  2089. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_GAMEINFO})
  2090. end
  2091. end
  2092. if callback then
  2093. callback()
  2094. end
  2095. else
  2096. if jsonData.clientSwitch == 1 then
  2097. local dailis = app.php.daili[0] or app.php.daili[-1] or {}
  2098. local kefu = ""
  2099. local index = 1
  2100. local max = 2
  2101. for k,v in pairs(dailis) do
  2102. if index < max then
  2103. kefu = kefu..v..","
  2104. elseif index == max then
  2105. if v ~= "" then
  2106. kefu = kefu..v
  2107. end
  2108. end
  2109. index = index + 1
  2110. end
  2111. self:dispatchEvent({name = GAME_EVENT.CLUB_SET_COPARTNER_ONE_FAILE , content = "",title = app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_SET_MATCH_SWITCH_TIP or PLN.CLUB_SET_MATCH_SWITCH_TIP})
  2112. else
  2113. self:showError(Cmd.PHP_CLUB_SET,response)
  2114. end
  2115. end
  2116. end)
  2117. end
  2118. --请求亲友圈消息
  2119. function ClubProtocolPhp:requestMsg(clubId)
  2120. local param = {
  2121. gid = clubId,
  2122. }
  2123. self:post(Cmd.PHP_CLUB_MANAGER_MSG,param,function(response)
  2124. logD("ClubProtocolPhp:requestMsg",table.tostring(response))
  2125. if response.code==200 then
  2126. local result = response.result
  2127. self:updateClubMessages(clubId,result.lists)
  2128. self:updateClubHints(clubId,result)
  2129. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CLUB_MESSAGE}) --茶馆消息tag为1
  2130. else
  2131. self:showError(Cmd.PHP_CLUB_MANAGER_MSG,response)
  2132. end
  2133. end)
  2134. end
  2135. --排名赛申请
  2136. function ClubProtocolPhp:requestMatchMessageList(clubId)
  2137. local param = {
  2138. gid = clubId,
  2139. }
  2140. app.waitDialogManager:showWaitNetworkDialog("正在请求...");
  2141. self:post(Cmd.PHP_CLUB_WARNUM_APPLY_LIST,param,function(response)
  2142. app.waitDialogManager:closeWaitNetworkDialog();
  2143. logD("ClubProtocolPhp:requestMatchMessageList",table.tostring(response))
  2144. if response.code==200 then
  2145. local result = response.result
  2146. self:updateClubMatchMessages(clubId,result.lists)
  2147. self:updateClubHints(clubId,result)
  2148. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.ALL_PEOPLE_MATCH_APPLY}) --茶馆消息tag为1
  2149. else
  2150. app.waitDialogManager:closeWaitNetworkDialog();
  2151. self:showError(Cmd.PHP_CLUB_WARNUM_APPLY_LIST,response)
  2152. end
  2153. end)
  2154. end
  2155. --请求加入申请消息
  2156. function ClubProtocolPhp:requestApplyMsg(clubId)
  2157. local param = {
  2158. version = "1",
  2159. gid = clubId,
  2160. type = 0,
  2161. }
  2162. self:post(Cmd.PHP_CLUB_APPLY_MSG,param,function(response)
  2163. logD("ClubProtocolPhp:requestApplyMsg",table.tostring(response))
  2164. if response.code==200 then
  2165. local result = response.result
  2166. self:updateClubApplyMessages(clubId,result.lists,1)
  2167. self:updateClubHints(clubId,result)
  2168. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.PLAYER_APPLY}) --申请消息
  2169. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.TEAMER_APPLY}) --合伙人申请消息
  2170. else
  2171. self:showError(Cmd.PHP_CLUB_APPLY_MSG,response)
  2172. end
  2173. end)
  2174. end
  2175. --请求退出申请消息
  2176. function ClubProtocolPhp:requestExitApplyMsg(clubId)
  2177. local param = {
  2178. gid = clubId,
  2179. }
  2180. self:post(Cmd.PHP_CLUB_EXIT_APPLY_MSG,param,function(response)
  2181. logD("ClubProtocolPhp:requestExitApplyMsg",table.tostring(response))
  2182. if response.code==200 then
  2183. local result = response.result
  2184. self:updateClubApplyMessages(clubId,result.lists,2)
  2185. self:updateClubHints(clubId,result)
  2186. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.PLAYER_APPLY}) --退出申请消息
  2187. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.TEAMER_APPLY}) --退出合伙人申请消息
  2188. else
  2189. self:showError(Cmd.PHP_CLUB_APPLY_MSG,response)
  2190. end
  2191. end)
  2192. end
  2193. --处理申请
  2194. function ClubProtocolPhp:requestChangeApplyStatus(clubId,uid,status,index)
  2195. local param = {
  2196. gid = clubId,
  2197. applyUid = uid,
  2198. ops = status, --1同意,2拒绝, 3全部同意(无需applyUid)
  2199. }
  2200. app.waitDialogManager:showWaitNetworkDialog();
  2201. self:post(Cmd.PHP_CLUB_CHANGE_APPLY_STATUS,param,function(response)
  2202. app.waitDialogManager:closeWaitNetworkDialog();
  2203. logD("ClubProtocolPhp:requestChangeApplyStatus",table.tostring(response))
  2204. if response.code==200 then
  2205. --修改状态
  2206. local userInfo = json.decode(app.user.userInfo);
  2207. self:updateClubApplyMessageStatus(clubId,index,status,app.user.loginInfo.uid,userInfo.nickname)
  2208. --检测处理完成后设置红点不显示
  2209. local isApplyHints = false
  2210. for k,v in pairs(self.clubList[clubId].applyMessages) do
  2211. if v.status==0 then
  2212. isApplyHints = true
  2213. end
  2214. end
  2215. if not isApplyHints then
  2216. self:requestSetHints(clubId,"applyhints")
  2217. end
  2218. --检测处理完成后设置合伙人红点不显示
  2219. local isCoApplyHints = false
  2220. for k,v in pairs(self.clubList[clubId].coapplyMessages) do
  2221. if v.status==0 then
  2222. isCoApplyHints = true
  2223. end
  2224. end
  2225. if not isCoApplyHints then
  2226. self:requestSetHints(clubId,"coapplyhints")
  2227. end
  2228. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.PLAYER_APPLY}) --申请消息
  2229. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.TEAMER_APPLY}) --合伙人申请消息
  2230. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED})
  2231. else
  2232. self:showError(Cmd.PHP_CLUB_CHANGE_APPLY_STATUS,response)
  2233. end
  2234. end)
  2235. end
  2236. function ClubProtocolPhp:requestChangeExitApplyStatus(clubId, uid, status, index)
  2237. local param = {
  2238. gid = clubId,
  2239. applyUid = uid,
  2240. uid = app.user.loginInfo.uid,
  2241. ops = status,
  2242. }
  2243. app.waitDialogManager:showWaitNetworkDialog();
  2244. self:post(Cmd.PHP_CLUB_CHANGE_EXIT_APPLY_STATUS,param,function(response)
  2245. app.waitDialogManager:closeWaitNetworkDialog();
  2246. logD("ClubProtocolPhp:requestChangeExitApplyStatus",table.tostring(response))
  2247. if response.code==200 then
  2248. --修改状态
  2249. self:updateClubApplyMessageStatus(clubId,index,status)
  2250. -- if index and self.clubList[clubId] and self.clubList[clubId].applyMessages[index] then
  2251. -- self.clubList[clubId].applyMessages[index].status = status
  2252. -- end
  2253. --检测处理完成后设置红点不显示
  2254. local isApplyHints = false
  2255. for k,v in pairs(self.clubList[clubId].applyMessages) do
  2256. if v.status==0 then
  2257. isApplyHints = true
  2258. end
  2259. end
  2260. if not isApplyHints then
  2261. self:requestSetHints(clubId,"exitapplyhints")
  2262. end
  2263. --检测处理完成后设置合伙人红点不显示
  2264. local isCoApplyHints = false
  2265. for k,v in pairs(self.clubList[clubId].coapplyMessages) do
  2266. if v.status==0 then
  2267. isCoApplyHints = true
  2268. end
  2269. end
  2270. if not isCoApplyHints then
  2271. self:requestSetHints(clubId,"coexitapplyhints")
  2272. end
  2273. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.PLAYER_APPLY}) --退出申请消息
  2274. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.TEAMER_APPLY}) --退出合伙人申请消息
  2275. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED})
  2276. else
  2277. self:showError(Cmd.PHP_CLUB_CHANGE_APPLY_STATUS,response)
  2278. end
  2279. end);
  2280. end
  2281. function ClubProtocolPhp:requestMatchMessageApplyStatus(clubId, id, status,viewType)
  2282. local param = {
  2283. gid = clubId,
  2284. id = id, --申请id
  2285. ops = status,
  2286. viewType = viewType,
  2287. }
  2288. app.waitDialogManager:showWaitNetworkDialog();
  2289. self:post(Cmd.PHP_CLUB_WARNUM_APPLY_STATUS,param,function(response)
  2290. app.waitDialogManager:closeWaitNetworkDialog();
  2291. logD("ClubProtocolPhp:requestMatchMessageApplyStatus",table.tostring(response))
  2292. if response.code==200 then
  2293. --修改状态
  2294. self:updateClubMatchMessageApplyStatus(clubId,id,status)
  2295. --检测处理完成后设置红点不显示
  2296. local isApplyHints = false
  2297. for k,v in pairs(self.clubList[clubId].matchMessages) do
  2298. if v.status==0 then
  2299. isApplyHints = true
  2300. end
  2301. end
  2302. --local player = self:getPlayer(clubId,app.user.loginInfo.uid)
  2303. if not isApplyHints and self.clubList[clubId].role ~= ClubDefine.Job.LevelOneCopartner
  2304. and self.clubList[clubId].role ~= ClubDefine.Job.LevelTwoCopartner and self.clubList[clubId].role ~= ClubDefine.Job.LevelThreeCopartner then
  2305. self:requestSetHints(clubId,"warnumhints")
  2306. end
  2307. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.ALL_PEOPLE_MATCH_APPLY})
  2308. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED})
  2309. else
  2310. app.waitDialogManager:closeWaitNetworkDialog();
  2311. self:showError(Cmd.PHP_CLUB_WARNUM_APPLY_STATUS,response)
  2312. end
  2313. end);
  2314. end
  2315. --请求奖励列表
  2316. function ClubProtocolPhp:requestAwardList(clubId)
  2317. local param = {
  2318. gid = clubId,
  2319. }
  2320. self:post(Cmd.PHP_CLUB_AWARD_LIST,param,function(response)
  2321. logD("ClubProtocolPhp:requestAwardList",table.tostring(response))
  2322. if response.code==200 then
  2323. local result = response.result
  2324. self:updateClubAwardMessages(clubId,result.list)
  2325. self:updateClubHints(clubId,result)
  2326. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.AWARD_APPLY}) --奖励消息tag为2
  2327. else
  2328. self:showError(Cmd.PHP_CLUB_AWARD_LIST,response)
  2329. end
  2330. end)
  2331. end
  2332. function ClubProtocolPhp:updateClubHints(clubId,result)
  2333. --loghints:亲友圈消息, awardhints:奖励消息, applyhints:申请消息,
  2334. --scorehints:疲劳值消息, fucardhints:福卡消息, exitapplyhints:退出申请
  2335. --warnumhints:排名赛申请红点 coapplyhints:合伙人相关的入群申请 coexitapplyhints:合伙人相关的退群申请
  2336. --奖励消息红点0:无,1:有
  2337. if self.clubList[clubId] and result then
  2338. if result.loghints then
  2339. self.clubList[clubId].isLogHints = tonumber(result.loghints)==1
  2340. end
  2341. if result.awardhints then
  2342. self.clubList[clubId].isAwardHints = tonumber(result.awardhints)==1
  2343. end
  2344. if result.applyhints then
  2345. self.clubList[clubId].isApplyHints = tonumber(result.applyhints)==1
  2346. end
  2347. if result.scorehints then
  2348. self.clubList[clubId].isScorehints = tonumber(result.scorehints)==1
  2349. end
  2350. if result.fucardhints then
  2351. self.clubList[clubId].isFucardhints = tonumber(result.fucardhints)==1
  2352. end
  2353. if result.exitapplyhints then
  2354. self.clubList[clubId].isExitApplyHints = tonumber(result.exitapplyhints)==1
  2355. end
  2356. if result.warnumhints then
  2357. self.clubList[clubId].isWarnumhints = tonumber(result.warnumhints)==1
  2358. end
  2359. if result.coapplyhints then
  2360. self.clubList[clubId].isCoApplyHints = tonumber(result.coapplyhints)==1
  2361. end
  2362. if result.coexitapplyhints then
  2363. self.clubList[clubId].isCoexitapplyhints = tonumber(result.coexitapplyhints)==1
  2364. end
  2365. --是否显示红点
  2366. self.clubList[clubId].isHints = self.clubList[clubId].isLogHints
  2367. or self.clubList[clubId].isAwardHints
  2368. or self.clubList[clubId].isApplyHints
  2369. or self.clubList[clubId].isScorehints
  2370. or self.clubList[clubId].isFucardhints
  2371. or self.clubList[clubId].isExitApplyHints
  2372. or self.clubList[clubId].isWarnumhints
  2373. or self.clubList[clubId].isCoApplyHints
  2374. or self.clubList[clubId].isCoexitapplyhints
  2375. end
  2376. end
  2377. --请求成员列表
  2378. --看了很多参数传了很多Nil,现在统一第一个为Json,不然参数一堆过来,传的时候还要数第几个,对于子游戏做了兼容
  2379. function ClubProtocolPhp:requestPlayerList(clubId,orderBy,sort,day,status)
  2380. if type(clubId) == "number" then
  2381. self.openData = {
  2382. clubId = clubId,
  2383. orderBy = orderBy or "role",
  2384. sort = sort or "desc",
  2385. day = day or 0,
  2386. status = status or 0,
  2387. }
  2388. else
  2389. self.openData = clubId
  2390. end
  2391. local param = {
  2392. gid = self.openData.clubId,
  2393. orderby = self.openData.orderBy or "role", --排序字段:play_number, play_win_number, role, online, 默认role desc
  2394. sort = self.openData.sort or "desc", --排序类型asc desc
  2395. lastday = self.openData.day or 0, --day时间标签,默认传0当天1昨天2前天3大前天
  2396. type = self.openData.status or 0, -- 0默认成员数据,1在线成员数据
  2397. lastweek = self.openData.day==3 and 1 or -1, --上周
  2398. lastmonth = self.openData.day==4 and 1 or -1, --上月
  2399. viewType = self.openData.viewType or 0, --要刷新那个界面,由于成员列表和比赛成员,记录都用一个接口,当不同消息来的时候,避免界面刷新错乱加这个控制
  2400. muid = self.openData.muid or 0, --创始人查看一级合伙人的下属成员时muid = 一级合伙人uid
  2401. suid = self.openData.suid or "", --搜索的ID
  2402. version = "20190227",
  2403. }
  2404. self:post(Cmd.PHP_CLUB_PLAYER_LIST,param,function(response)
  2405. if isWin32Platform() then
  2406. logD("ClubProtocolPhp:requestPlayerList",table.tostring(response))
  2407. end
  2408. if response.code==200 then
  2409. local result = response.result
  2410. if self.clubList[param.gid] then
  2411. if param.viewType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_MEMBER
  2412. or param.viewType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_RECORD then
  2413. self.clubList[param.gid].playersLevelTwo = {}
  2414. else
  2415. self.clubList[param.gid].playersLevelOne = {}
  2416. self.clubList[param.gid].playersLevelTwo = {}
  2417. end
  2418. self.clubList[param.gid].playerNum = tonumber(result.gnum)
  2419. self.clubList[param.gid].isHidePlay = tonumber(result.is_hideplay) == 1
  2420. self.clubList[param.gid].onlinePlayerNum = tonumber(result.onlinemember)
  2421. self.clubList[param.gid].totalPlayerNum = tonumber(result.count)--总人数根据角色变化的总人数,老的gnum不用
  2422. --为了显示大赢家信息加上请求的时间
  2423. self.clubList[param.gid].lastday = param.lastday
  2424. end
  2425. if param.suid ~= "" then
  2426. self.clubList[param.gid].players = {}
  2427. self:updateClubPlayers(param.gid,result.list,param.viewType,param.type)
  2428. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_SEARCH,result = result,type = param.viewType})
  2429. else
  2430. self:updateClubPlayers(param.gid,result.list,param.viewType)
  2431. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_LIST,type = param.viewType,clubId = param.gid})
  2432. end
  2433. else
  2434. self:showError(Cmd.PHP_CLUB_PLAYER_LIST,response)
  2435. end
  2436. end)
  2437. end
  2438. --请求邀请的成员列表
  2439. function ClubProtocolPhp:requestInvitePlayerList(clubId,orderBy,sort,day,status)
  2440. local param = {
  2441. gid = clubId,
  2442. orderby = orderBy or "role", --排序字段:play_number, play_win_number, role, online, 默认role desc
  2443. sort = sort or "desc", --排序类型asc desc
  2444. lastday = day or 0, --day时间标签,默认传0当天1昨天2前天3大前天
  2445. type = status or 0, -- 0默认成员数据,1在线成员数据
  2446. version = "180605",
  2447. }
  2448. self:post(Cmd.PHP_CLUB_PLAYER_LIST,param,function(response)
  2449. if isWin32Platform() then
  2450. logD("ClubProtocolPhp:requestInvitePlayerList",table.tostring(response))
  2451. end
  2452. if response.code==200 then
  2453. local result = response.result
  2454. if self.clubList[clubId] then
  2455. self.clubList[clubId].playerNum = tonumber(result.gnum)
  2456. self.clubList[clubId].isHidePlay = tonumber(result.is_hideplay) == 1
  2457. end
  2458. local players = {}
  2459. if result.list then
  2460. for k,v in pairs(result.list) do
  2461. local player = {}
  2462. player.uid = tonumber(v.uid)
  2463. player.name = v.nick
  2464. player.sex = v.sex --玩家性别:0未知1男2女
  2465. player.strHeadUrl = v.icon --玩家头像地址
  2466. player.desc = v.desc --备注
  2467. player.playNum = v.play_number --局数
  2468. player.lastPlayNum = v.last_play_number --昨日局数
  2469. player.playWinNum = v.play_win_number --大赢家次数
  2470. player.lastPlayWinNum = v.last_play_win_number --昨日大赢家次数
  2471. player.online = v.online --1在线0离线
  2472. player.role = tonumber(v.role) --1成员2管理员3创建人
  2473. player.status = v.status --1正常0黑名单成员
  2474. player.agent = v.agent --1是代理0不是代理
  2475. player.totalScore = v.total_score --输赢积分
  2476. player.lastTotalScore = v.last_total_score --昨日输赢积分
  2477. if v.isplay then
  2478. player.isPlay = v.isplay == 1 --是否在游戏中(1:游戏中)
  2479. end
  2480. players[player.uid] = player
  2481. end
  2482. end
  2483. self:dispatchEvent({name = GAME_EVENT.CLUB_INVITE_PLAYER_LIST , players = players})
  2484. else
  2485. self:showError(Cmd.PHP_CLUB_PLAYER_LIST,response)
  2486. end
  2487. end)
  2488. end
  2489. --设置成员
  2490. --[[
  2491. $type 1 加入管理员, 无需$value
  2492. $type 2 解除管理员, 无需$value
  2493. $type 3 加入黑名单, 无需$value
  2494. $type 4 解除黑名单, 无需$value
  2495. $type 5 备注昵称 $value = '备注的信息'
  2496. $type 6 加入合伙人, 无需$value
  2497. $type 7 解除普通合伙人, 无需$value
  2498. $type 8 解除普通合伙人对成员的绑定, 无需$value
  2499. $type 9 删除比赛场合伙人, 管理员调用时, 只能删除一级; 一级调用时, 只能删除二级
  2500. $type 10 加入比赛场合伙人, 管理员调用时, 只能增加一级; 一级调用时, 只能增加二级
  2501. $type 11 设置下级比赛合伙人分成比例
  2502. $type 12 指定合伙人和其下属冻结
  2503. $type 13 指定合伙人和其下属解冻
  2504. ]]
  2505. function ClubProtocolPhp:requestSetClubPlayer(clubId,uid,memberuid,opType,value,callback,viewType)
  2506. local param = {
  2507. gid = clubId,
  2508. uid = uid, --操作ID
  2509. memberuid = memberuid, --被操作ID
  2510. type = opType,
  2511. value = value,
  2512. viewType = viewType or 0,
  2513. }
  2514. self:post(Cmd.PHP_CLUB_PLAYER_SET,param,function(response)
  2515. logD("ClubProtocolPhp:requestSetClubPlayer",table.tostring(response))
  2516. if response.code==200 then
  2517. --TODO 暂时通过推送数据修改本地数据
  2518. if callback then
  2519. callback()
  2520. end
  2521. if response.error and response.error ~= "" then
  2522. showTooltip(response.error)
  2523. end
  2524. else
  2525. if opType == 10 then
  2526. self:dispatchEvent({name = GAME_EVENT.CLUB_SET_COPARTNER_ONE_FAILE , content = "",title = (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_SET_COPRATNER_FAIL_TIP or PLN.CLUB_SET_COPRATNER_FAIL_TIP)})
  2527. else
  2528. self:showError(Cmd.PHP_CLUB_PLAYER_SET,response)
  2529. end
  2530. end
  2531. end)
  2532. end
  2533. --排名赛新接口
  2534. --设置成员
  2535. --[[
  2536. $type 1 加入管理员, 无需$value
  2537. $type 2 解除管理员, 无需$value
  2538. $type 3 加入黑名单, 无需$value
  2539. $type 4 解除黑名单, 无需$value
  2540. $type 5 备注昵称 $value = '备注的信息'
  2541. $type 6 加入合伙人, 无需$value
  2542. $type 7 解除普通合伙人, 无需$value
  2543. $type 8 解除普通合伙人对成员的绑定, 无需$value
  2544. $type 9 删除比赛场合伙人, 管理员调用时, 只能删除一级; 一级调用时, 只能删除二级
  2545. $type 10 加入比赛场合伙人, 管理员调用时, 只能增加一级; 一级调用时, 只能增加二级
  2546. $type 11 设置下级比赛合伙人分成比例
  2547. $type 12 指定合伙人和其下属冻结
  2548. $type 13 指定合伙人和其下属解冻
  2549. ]]
  2550. function ClubProtocolPhp:requestSetPlayer(clubId,uid,memberuid,opType,value,callback,viewType)
  2551. local param = {
  2552. gid = clubId,
  2553. uid = uid, --操作ID
  2554. memberuid = memberuid, --被操作ID
  2555. type = opType,
  2556. value = value,
  2557. viewType = viewType or 0,
  2558. }
  2559. self:post(Cmd.PHP_CLUB_WARMEMBERSTATUS,param,function(response)
  2560. logD("ClubProtocolPhp:requestSetPlayer",table.tostring(response))
  2561. if response.code==200 then
  2562. --TODO 暂时通过推送数据修改本地数据
  2563. if callback then
  2564. callback()
  2565. end
  2566. self:showError(Cmd.PHP_CLUB_WARMEMBERSTATUS,response,true)
  2567. else
  2568. if opType == 10 and response.code == 1210 then
  2569. self:dispatchEvent({name = GAME_EVENT.CLUB_SET_COPARTNER_ONE_FAILE , content = "",title = (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_SET_COPRATNER_FAIL_TIP or PLN.CLUB_SET_COPRATNER_FAIL_TIP)})
  2570. else
  2571. self:showError(Cmd.PHP_CLUB_WARMEMBERSTATUS,response)
  2572. end
  2573. end
  2574. end)
  2575. end
  2576. --删除成员
  2577. function ClubProtocolPhp:requestRemovePlayer(clubId,uid,viewType)
  2578. local param = {
  2579. gid = clubId,
  2580. kickuid = uid,
  2581. viewType = viewType or 0,
  2582. }
  2583. self:post(Cmd.PHP_CLUB_REMOVE_PLAYER,param,function(response)
  2584. logD("ClubProtocolPhp:requestRemovePlayer",table.tostring(response))
  2585. if response.code==200 then
  2586. --TODO 暂时通过推送数据修改本地数据
  2587. if response.result.content then
  2588. showTooltip(tostring(response.result.content))
  2589. end
  2590. else
  2591. -- 先帮PHP处理
  2592. if app.club_php:getCestIsOpen(clubId) then
  2593. if response.code then
  2594. if tostring(response.code) == "1011" then
  2595. response.error = "请先结束本轮比赛后再退出!"
  2596. end
  2597. end
  2598. end
  2599. self:showError(Cmd.PHP_CLUB_REMOVE_PLAYER,response)
  2600. end
  2601. end)
  2602. end
  2603. --添加成员
  2604. function ClubProtocolPhp:requestAddPlayer(uid,clubId,viewType)
  2605. local param = {
  2606. gid = clubId,
  2607. addUid = uid,
  2608. viewType = viewType,
  2609. }
  2610. app.waitDialogManager:showWaitNetworkDialog();
  2611. self:post(Cmd.PHP_CLUB_ADD_PLAYER,param,function(response)
  2612. logD("ClubProtocolPhp:requestAddPlayer",table.tostring(response))
  2613. app.waitDialogManager:closeWaitNetworkDialog();
  2614. if response.code==200 then
  2615. if response.result.content then
  2616. showTooltip(string.format(response.result.content))
  2617. else
  2618. showTooltip("添加成员成功")
  2619. end
  2620. --TODO 暂时通过推送数据修改本地数据
  2621. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_ADD})
  2622. else
  2623. self:showError(Cmd.PHP_CLUB_ADD_PLAYER,response)
  2624. end
  2625. end)
  2626. end
  2627. --导入亲友圈前拉取数据
  2628. function ClubProtocolPhp:requestImportPlayerList(clubId,importClubId)
  2629. local param = {
  2630. gid = clubId, --被导入俱乐部ID
  2631. getgid = importClubId, -- 指定拉取成员的群
  2632. viewType = 0
  2633. }
  2634. app.waitDialogManager:showWaitNetworkDialog();
  2635. self:post(Cmd.PHP_CLUB_IMPORT_MEMBER,param,function(response)
  2636. app.waitDialogManager:closeWaitNetworkDialog();
  2637. if isWin32Platform() then
  2638. logD("ClubProtocolPhp:requestImportPlayerList",table.tostring(response))
  2639. end
  2640. if response.code==200 then
  2641. --self.clubList[param.gid].players = {}
  2642. local result = response.result.list
  2643. --self:updateClubPlayers(param.gid,result.list,param.viewType)
  2644. self:dispatchEvent({name = GAME_EVENT.CLUB_IMPORT_MBMBER,response = result})
  2645. else
  2646. self:showError(Cmd.PHP_CLUB_IMPORT_MEMBER,response)
  2647. end
  2648. end)
  2649. end
  2650. --导入成员
  2651. function ClubProtocolPhp:requestImportPlayer(clubId,importClubId,memberuid)
  2652. local param ={}
  2653. if memberuid then
  2654. param = {
  2655. gid = clubId,
  2656. getgid = importClubId,
  2657. getmuid = memberuid, --被操作ID,"," split
  2658. }
  2659. else
  2660. param = {
  2661. gid = clubId,
  2662. getgid = importClubId,
  2663. }
  2664. end
  2665. app.waitDialogManager:showWaitNetworkDialog();
  2666. self:post(Cmd.PHP_CLUB_IMPORT_PLAYER,param,function(response)
  2667. app.waitDialogManager:closeWaitNetworkDialog();
  2668. logD("ClubProtocolPhp:requestImportPlayer",table.tostring(response))
  2669. if response.code==200 then
  2670. --TODO 暂时通过推送数据修改本地数据
  2671. if app.club_php:getCestIsOpen(clubId) then
  2672. showPHPSuccessResult("导入选手成功")
  2673. else
  2674. showPHPSuccessResult("导入成员成功")
  2675. end
  2676. else
  2677. self:showError(Cmd.PHP_CLUB_IMPORT_PLAYER,response)
  2678. end
  2679. end)
  2680. end
  2681. --获取禁止同桌列表
  2682. function ClubProtocolPhp:requestBanList(clubId,uid,viewType,isNew)
  2683. local param = {
  2684. gid = clubId,
  2685. muid = uid,
  2686. viewType = viewType or 0,
  2687. isNew = isNew,
  2688. }
  2689. self:post(Cmd.PHP_CLUB_GET_JZ_SAME_TABLE,param,function(response)
  2690. logD("ClubProtocolPhp:requestBanList",table.tostring(response))
  2691. if response.code==200 then
  2692. local banList = {}
  2693. local result = response.result
  2694. if result.notdeskmate=="" then
  2695. else
  2696. if type(result.notdeskmate) == 'string' then
  2697. local list = string.split(result.notdeskmate,",")
  2698. for i,v in pairs(list) do
  2699. table.insert(banList,tonumber(v))
  2700. end
  2701. else
  2702. for k,v in pairs(result.notdeskmate) do
  2703. table.insert(banList,v)
  2704. end
  2705. end
  2706. end
  2707. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_BAN_LIST , uid = uid , banList = banList,viewType = viewType})
  2708. else
  2709. self:showError(Cmd.PHP_CLUB_GET_JZ_SAME_TABLE,response)
  2710. end
  2711. end)
  2712. end
  2713. --设置禁止同桌
  2714. function ClubProtocolPhp:requestSetNotDest(clubId,uid,banList)
  2715. local strJzList = ""
  2716. for i,v in pairs(banList) do
  2717. strJzList = strJzList..v..","
  2718. end
  2719. strJzList = string.sub(strJzList, 1, -2)
  2720. local param = {
  2721. gid = clubId,
  2722. muid = uid,
  2723. uids = strJzList
  2724. }
  2725. self:post(Cmd.PHP_CLUB_SET_JZ_SAME_TABLE,param,function(response)
  2726. logD("ClubProtocolPhp:requestSetNotDest",table.tostring(response))
  2727. if response.code==200 then
  2728. local result = response.result
  2729. --设置禁止同桌成功
  2730. local addPlayerList = {}
  2731. local delPlayerList = {}
  2732. if type(result.addUids) == 'table' then
  2733. --local list = string.split(result.notdeskmate,",")
  2734. for i,v in pairs(result.addUids) do
  2735. table.insert(addPlayerList,v)
  2736. end
  2737. end
  2738. if type(result.cancelUids) == 'table' then
  2739. for i,v in pairs(result.cancelUids) do
  2740. table.insert(delPlayerList,v)
  2741. end
  2742. end
  2743. showTooltip("设置成功")
  2744. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_BAN_SET,clubId = clubId,uid = uid,addPlayerList = addPlayerList,delPlayerList=delPlayerList})
  2745. else
  2746. self:showError(Cmd.PHP_CLUB_SET_JZ_SAME_TABLE,response)
  2747. end
  2748. end)
  2749. end
  2750. --请求茶馆更新公告接口
  2751. function ClubProtocolPhp:requestUpdateNotice(clubId,notice)
  2752. local param = {
  2753. gid = clubId,
  2754. notice = notice,
  2755. }
  2756. self:post(Cmd.PHP_CLUB_UPDATE_NOTICE,param,function(response)
  2757. logD("ClubProtocolPhp:requestUpdateNotice",table.tostring(response))
  2758. if response.code==200 then
  2759. --TODO 暂时通过推送数据修改本地数据
  2760. else
  2761. self:showError(Cmd.PHP_CLUB_UPDATE_NOTICE,response)
  2762. end
  2763. end)
  2764. end
  2765. --茶馆官方活动
  2766. function ClubProtocolPhp:requestClubOfficialActivity(clubId)
  2767. local param = {
  2768. gid = clubId
  2769. }
  2770. app.waitDialogManager:showWaitNetworkDialog("连接中...")
  2771. self:post(Cmd.PHP_CLUB_OFFICIAL_ACTIVITY,param,function(response)
  2772. app.waitDialogManager:closeWaitNetworkDialog()
  2773. logD("ClubProtocolPhp:requestClubOfficialActivity",table.tostring(response))
  2774. if response.code==200 then
  2775. local result = response.result
  2776. local activitys = {}
  2777. for k,v in pairsByKeys(result) do
  2778. local activity = {};
  2779. activity.type = v.type; --活动ID
  2780. activity.app = v.app; --
  2781. activity.tname = v.tname; --活动标题
  2782. activity.desc = v.desc; --活动描述
  2783. activity.img = v.img; --活动图
  2784. activitys[v.type] = activity
  2785. end
  2786. self:dispatchEvent({name = GAME_EVENT.CLUB_ACTIVITY_LIST, activitys = activitys})
  2787. elseif response.code==1049 then
  2788. showConfirmDialog("精彩活动,敬请期待!")
  2789. else
  2790. self:showError(Cmd.PHP_CLUB_OFFICIAL_ACTIVITY,response)
  2791. end
  2792. end)
  2793. end
  2794. --获取已设置的禁止同桌玩家列表
  2795. function ClubProtocolPhp:requestForbidList(clubId,page,suid)
  2796. local param = {
  2797. gid = clubId,
  2798. page = page or 0,
  2799. suid = suid or 0,
  2800. }
  2801. app.waitDialogManager:showWaitNetworkDialog("连接中...")
  2802. self:post(Cmd.PHP_CLUB_GET_FORBID_SAME_TABLE_LIST,param,function(response)
  2803. app.waitDialogManager:closeWaitNetworkDialog()
  2804. if isWin32Platform() then
  2805. logD("ClubProtocolPhp:requestForbidList",table.tostring(response))
  2806. end
  2807. if response.code == 200 then
  2808. local result = response.result
  2809. local playerList = {}
  2810. if result.lists and table.nums(result.lists) > 0 then
  2811. for uidK,uidV in pairs(result.lists) do
  2812. local list = string.split(uidV,",")
  2813. table.insert(playerList,list)
  2814. end
  2815. end
  2816. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_BAN_ALL_LIST,playerID = (result.lists == "" and {} or result.lists)})
  2817. else
  2818. self:showError(Cmd.PHP_CLUB_GET_FORBID_SAME_TABLE_LIST,response)
  2819. end
  2820. end)
  2821. end
  2822. --禁止同队,战队列表
  2823. function ClubProtocolPhp:requestNotdeskteam(clubId,page,suid, uid)
  2824. local param = {
  2825. gid = clubId,
  2826. page = page or 0,
  2827. suid = suid or 0,
  2828. uid = uid or 0,
  2829. app = getAppId(),
  2830. }
  2831. app.waitDialogManager:showWaitNetworkDialog("连接中...")
  2832. self:post(Cmd.PHP_CLUB_JZ_GET_ZHANDUI_TABLE_LIST,param,function(response)
  2833. app.waitDialogManager:closeWaitNetworkDialog()
  2834. if isWin32Platform() then
  2835. logD("ClubProtocolPhp:requestNotdeskteam",table.tostring(response))
  2836. end
  2837. if response.code == 200 then
  2838. -- local result = response.result
  2839. local result = response
  2840. local playerList = {}
  2841. if result.list and table.nums(result.list) > 0 then
  2842. for uidK,uidV in pairs(result.list) do
  2843. local list = string.split(uidV,",")
  2844. table.insert(playerList,list)
  2845. end
  2846. end
  2847. -- self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_TABLE_LIST,playerID = (result.list == "" and {} or result.list)})
  2848. -- self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_TABLE_LIST, playerID = (result.list == "" and {} or result.list)})
  2849. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_TABLE_LIST, result = result})
  2850. else
  2851. self:showError(Cmd.PHP_CLUB_JZ_GET_ZHANDUI_TABLE_LIST,response)
  2852. end
  2853. end)
  2854. end
  2855. --禁止同队,已经禁止战队
  2856. function ClubProtocolPhp:requestNotIndeskteam(clubId,page, uid)
  2857. local param = {
  2858. gid = clubId,
  2859. page = page or 0,
  2860. uid = uid or 0,
  2861. app = getAppId(),
  2862. }
  2863. app.waitDialogManager:showWaitNetworkDialog("连接中...")
  2864. self:post(Cmd.PHP_CLUB_JZ_GET_ZHANDUI_JZ_TABLE_LIST,param,function(response)
  2865. app.waitDialogManager:closeWaitNetworkDialog()
  2866. if isWin32Platform() then
  2867. logD("ClubProtocolPhp:requestNotIndeskteam",table.tostring(response))
  2868. end
  2869. if response.code == 200 then
  2870. -- local result = response.result
  2871. local result = response
  2872. -- local playerList = {}
  2873. -- if result.list and table.nums(result.list) > 0 then
  2874. -- for uidK,uidV in pairs(result.list) do
  2875. -- local list = string.split(uidV,",")
  2876. -- table.insert(playerList,list)
  2877. -- end
  2878. -- end
  2879. -- self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_YJ_TABLE_LIST,playerID = (result.list == "" and {} or result.list)})
  2880. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_YJ_TABLE_LIST, result = result})
  2881. else
  2882. self:showError(Cmd.PHP_CLUB_JZ_GET_ZHANDUI_JZ_TABLE_LIST,response)
  2883. end
  2884. end)
  2885. end
  2886. --禁止同队,设置禁止/全部禁止
  2887. function ClubProtocolPhp:requestSetNotDeskmateteam(clubId,uid,type,uids)
  2888. local param = {
  2889. gid = clubId,
  2890. uid = uid or 0,
  2891. app = getAppId(),
  2892. type = type or 0,
  2893. uids = uids or 0,
  2894. }
  2895. app.waitDialogManager:showWaitNetworkDialog("连接中...")
  2896. self:post(Cmd.PHP_CLUB_JZ_SET_NOT_DESK_MATE_TEAM,param,function(response)
  2897. app.waitDialogManager:closeWaitNetworkDialog()
  2898. if isWin32Platform() then
  2899. logD("ClubProtocolPhp:requestSetNotDeskmateteam",table.tostring(response))
  2900. end
  2901. if response.code == 200 then
  2902. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_BAN_ALL_BAN, Ban = 1})
  2903. else
  2904. self:showError(Cmd.PHP_CLUB_JZ_SET_NOT_DESK_MATE_TEAM,response)
  2905. end
  2906. end)
  2907. end
  2908. --禁止同队,设置取消/全部取消
  2909. function ClubProtocolPhp:requestCancelNotDeskteam(clubId,uid,type,uids)
  2910. local param = {
  2911. gid = clubId,
  2912. uid = uid or 0,
  2913. app = getAppId(),
  2914. type = type or 0,
  2915. uids = uids or 0,
  2916. }
  2917. app.waitDialogManager:showWaitNetworkDialog("连接中...")
  2918. self:post(Cmd.PHP_CLUB_JZ_CANCEL_NOT_DESK_MATE_TEAM,param,function(response)
  2919. app.waitDialogManager:closeWaitNetworkDialog()
  2920. if isWin32Platform() then
  2921. logD("ClubProtocolPhp:requestCancelNotDeskteam",table.tostring(response))
  2922. end
  2923. if response.code == 200 then
  2924. self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_CANCEL_ALL_CANCEL, Cancel = 1})
  2925. else
  2926. self:showError(Cmd.PHP_CLUB_JZ_CANCEL_NOT_DESK_MATE_TEAM,response)
  2927. end
  2928. end)
  2929. end
  2930. --请求茶馆转让接口
  2931. function ClubProtocolPhp:requestTransfer(clubId,newOwnerId,viewType)
  2932. local param = {
  2933. gid = clubId,
  2934. newOwner = newOwnerId,
  2935. viewType = viewType or 0
  2936. }
  2937. self:post(Cmd.PHP_CLUB_TRANSFER,param,function(response)
  2938. logD("ClubProtocolPhp:requestTransfer",table.tostring(response))
  2939. if response.code==200 then
  2940. showTooltip(app.club_php:getCestIsOpen(clubId) and PLN.CLUB_CEST_TRANSFER_SUCCESS or PLN.CLUB_TRANSFER_SUCCESS)
  2941. self:dispatchEvent({name = GAME_EVENT.CLUB_SET})
  2942. else
  2943. self:showError(Cmd.PHP_CLUB_TRANSFER,response)
  2944. end
  2945. end)
  2946. end
  2947. --请求设置茶馆红点
  2948. function ClubProtocolPhp:requestSetHints(clubId,hints)
  2949. local param = {
  2950. gid = clubId,
  2951. type = hints, --"type": loghints,// loghints:茶馆消息, awardhints:奖励消息, applyhints:申请消息
  2952. value = 0,--// 0:隐藏, 1:展示
  2953. }
  2954. self:post(Cmd.PHP_CLUB_SET_HINTS,param,function(response)
  2955. logD("ClubProtocolPhp:requestSetHints",table.tostring(response))
  2956. if response.code==200 then
  2957. local result = response.result
  2958. self:updateClubHints(clubId,result)
  2959. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE})
  2960. else
  2961. self:showError(Cmd.PHP_CLUB_SET_HINTS,response)
  2962. end
  2963. end)
  2964. end
  2965. --请求领取奖励
  2966. function ClubProtocolPhp:requestReward(clubId, awardId, awardSN)
  2967. local param = {
  2968. gid = clubId,
  2969. awardid = awardId,
  2970. awardsn = awardSN,
  2971. }
  2972. self:post(Cmd.PHP_CLUB_GET_REWARD,param,function(response)
  2973. logD("ClubProtocolPhp:requestReward",table.tostring(response))
  2974. if response.code==200 then
  2975. local result = response.result
  2976. if self.clubList[clubId].awardMessages and self.clubList[clubId].awardMessages[awardId] then
  2977. self.clubList[clubId].awardMessages[awardId].status = 1
  2978. local isAwardHints = false
  2979. for k,v in pairs(self.clubList[clubId].awardMessages) do
  2980. if v.status==0 then
  2981. isAwardHints = true
  2982. end
  2983. end
  2984. if not isAwardHints then
  2985. self:requestSetHints(clubId,"awardhints")
  2986. end
  2987. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = 2}) --奖励消息tag为2
  2988. end
  2989. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_REAWRD , type = tonumber(result.atype), num = tonumber(result.prize) })
  2990. else
  2991. self:showError(Cmd.PHP_CLUB_GET_REWARD,response)
  2992. end
  2993. end)
  2994. end
  2995. --茶馆主动发送广播
  2996. function ClubProtocolPhp:requestBroadcast(clubId, invitedUid, tp, content)
  2997. local param = {
  2998. gid = clubId,
  2999. invitedUids = invitedUid, --多个用,隔开
  3000. type = tp,
  3001. content = content,
  3002. }
  3003. self:post(Cmd.PHP_CLUB_SEND_BROADCAST,param,function(response)
  3004. logD("ClubProtocolPhp:requestBroadcast",table.tostring(response))
  3005. if response.code==200 then
  3006. local result = response.result
  3007. showTooltip("邀请成功")
  3008. app.waitDialogManager:closeAllNetWait()
  3009. elseif response.code == 1070 then --玩家已屏蔽邀请,不做处理
  3010. showTooltip("邀请成功")
  3011. app.waitDialogManager:closeAllNetWait()
  3012. else
  3013. self:showError(Cmd.PHP_CLUB_SEND_BROADCAST,response)
  3014. end
  3015. end)
  3016. end
  3017. --用户个性化设置
  3018. function ClubProtocolPhp:requestMemberSet(clubId, setType, setValues)
  3019. local param = {
  3020. gid = clubId,
  3021. type = setType,
  3022. value = setValues,
  3023. }
  3024. app.waitDialogManager:showWaitNetworkDialog()
  3025. self:post(Cmd.PHP_CLUB_MEMBER_SET,param,function(response)
  3026. app.waitDialogManager:closeWaitNetworkDialog()
  3027. logD("ClubProtocolPhp:requestMemberSet",table.tostring(response))
  3028. if response.code==200 then
  3029. local contentStr = "";
  3030. if setType == 1 then
  3031. contentStr = "屏蔽玩家邀请";
  3032. elseif setType == 2 and setValues == 1 then
  3033. contentStr = "屏蔽开局用户";
  3034. elseif setType == 2 and setValues == 0 then
  3035. contentStr = "取消屏蔽开局用户";
  3036. elseif setType == 3 and setValues == 1 then
  3037. contentStr = "置顶";
  3038. elseif setType == 3 and setValues == 0 then
  3039. contentStr = "取消置顶";
  3040. end
  3041. local result = response.result
  3042. showTooltip(contentStr.."成功")
  3043. if self.clubList[clubId] then
  3044. self.clubList[clubId].isHidePlay = setValues==1
  3045. end
  3046. self:dispatchEvent({name = GAME_EVENT.CLUB_MEMBER_SET_SUCCESS, setType = setType, setValues = setValues, gID = gID})
  3047. else
  3048. self:showError(Cmd.PHP_CLUB_MEMBER_SET,response)
  3049. end
  3050. end)
  3051. end
  3052. function ClubProtocolPhp:requestCopartnerSetup(gid, muid, uids)
  3053. local param = {
  3054. gid = gid,
  3055. muid = muid,
  3056. uids = uids,
  3057. }
  3058. log("ProtocolClubPhp:requestCopartnerSetup", table.tostring(param))
  3059. app.waitDialogManager:showWaitNetworkDialog()
  3060. self:post(Cmd.PHP_CLUB_COPARTNER_SET_UP, param, function(response)
  3061. app.waitDialogManager:closeWaitNetworkDialog()
  3062. log("ProtocolClubPhp:requestCopartnerSetup", table.tostring(response))
  3063. if response.code == 200 then
  3064. showTooltip("设置成功!")
  3065. self:dispatchEvent({name = GAME_EVENT.CopartnerSetup, result = response.result})
  3066. else
  3067. showTooltip(response.error)
  3068. end
  3069. end)
  3070. end
  3071. function ClubProtocolPhp:requestGetCopartnerSub(gid, muid)
  3072. local param = {
  3073. gid = gid,
  3074. muid = muid,
  3075. }
  3076. log("ProtocolClubPhp:requestGetCopartnerSub", table.tostring(param))
  3077. app.waitDialogManager:showWaitNetworkDialog()
  3078. self:post(Cmd.PHP_CLUB_GET_COPARTNER_SUB, param, function(response)
  3079. app.waitDialogManager:closeWaitNetworkDialog()
  3080. log("ProtocolClubPhp:requestGetCopartnerSub", table.tostring(response))
  3081. if response.code == 200 then
  3082. self:dispatchEvent({name = GAME_EVENT.GetCopartnerSub, result = response.result})
  3083. else
  3084. showTooltip(response.error)
  3085. end
  3086. end)
  3087. end
  3088. function ClubProtocolPhp:requestGetCopartnerStat(gid, score)
  3089. local param = {
  3090. gid = gid,
  3091. score = score,
  3092. }
  3093. logD("ProtocolClubPhp:requestGetCopartnerStat tt", table.tostring(tt))
  3094. app.waitDialogManager:showWaitNetworkDialog()
  3095. self:post(Cmd.PHP_CLUB_GET_COPARTNER_STAT, param, function(response)
  3096. app.waitDialogManager:closeWaitNetworkDialog()
  3097. logD("ProtocolClubPhp:requestGetCopartnerStat", table.tostring(response))
  3098. if response.code == 200 then
  3099. self:dispatchEvent({name = GAME_EVENT.GetCopartnerStat, result = response.result})
  3100. else
  3101. showTooltip(response.error)
  3102. end
  3103. end)
  3104. end
  3105. function ClubProtocolPhp:requestGetCopartnerDetail(gid, muid, score)
  3106. local param = {
  3107. gid = gid,
  3108. muid = muid,
  3109. score = score,
  3110. }
  3111. log("ProtocolClubPhp:requestGetCopartnerDetail", table.tostring(param))
  3112. app.waitDialogManager:showWaitNetworkDialog()
  3113. self:post(Cmd.PHP_CLUB_GET_COPARTNER_DETAIL, param, function(response)
  3114. app.waitDialogManager:closeWaitNetworkDialog()
  3115. log("ProtocolClubPhp:requestGetCopartnerDetail", table.tostring(response))
  3116. if response.code == 200 then
  3117. self:dispatchEvent({name = GAME_EVENT.GetCopartnerDetail, result = response.result})
  3118. else
  3119. showTooltip(response.error)
  3120. end
  3121. end)
  3122. end
  3123. function ClubProtocolPhp:requestGetCopartnerUnionDetail(gid, muid, score,sgid)
  3124. local param = {
  3125. gid = gid,
  3126. muid = muid,
  3127. score = score,
  3128. sgid = sgid,
  3129. }
  3130. log("ProtocolClubPhp:requestGetCopartnerUnionDetail", table.tostring(param))
  3131. app.waitDialogManager:showWaitNetworkDialog()
  3132. self:post(Cmd.PHP_CLUB_UNION_DETAIL, param, function(response)
  3133. app.waitDialogManager:closeWaitNetworkDialog()
  3134. log("ProtocolClubPhp:requestGetCopartnerUnionDetail", table.tostring(response))
  3135. if response.code == 200 then
  3136. self:dispatchEvent({name = GAME_EVENT.GetCopartnerDetail, result = response.result})
  3137. else
  3138. showTooltip(response.error)
  3139. end
  3140. end)
  3141. end
  3142. function ClubProtocolPhp:requestSetRedFlower(clubId,uid,memberuid,value,callback,viewType)
  3143. local param = {
  3144. gid = clubId,
  3145. uid = uid, --操作ID
  3146. muid = memberuid, --被操作ID,"," split
  3147. arena_score = value,
  3148. viewType = viewType,
  3149. }
  3150. logD("ClubProtocolPhp:requestSetRedFlower",table.tostring(param))
  3151. self:post(Cmd.PHP_CLUB_SET_RED_FLOWER,param,function(response)
  3152. logD("ClubProtocolPhp:requestSetRedFlower response",table.tostring(response))
  3153. if response.code==200 then
  3154. --TODO 暂时通过推送数据修改本地数据
  3155. if callback then
  3156. callback()
  3157. end
  3158. else
  3159. self:showError(Cmd.PHP_CLUB_SET_RED_FLOWER,response)
  3160. end
  3161. end)
  3162. end
  3163. function ClubProtocolPhp:requestRedFlowerRecord(clubId,uid,memberuid,mapType,lastday,page)
  3164. local param = {
  3165. gid = clubId,
  3166. uid = uid, --操作ID
  3167. muid = memberuid, --被操作ID,"," split
  3168. mapType = mapType or 0, -- {0:全部, 1:加减记录, 2赠送记录, 3赠送记录, 11:调整红花记录}
  3169. lastday = lastday or 0, -- 0今天,1昨天,2前天
  3170. page = page,
  3171. --[[limit = 10,--]]
  3172. }
  3173. --logD("ClubProtocolPhp:requestRedFlowerRecord",table.tostring(param))
  3174. self:post(Cmd.PHP_CLUB_RED_FLOWER_RECORD,param,function(response)
  3175. logD("ClubProtocolPhp:requestRedFlowerRecord",table.tostring(response))
  3176. if response.code==200 then
  3177. self:dispatchEvent({name = GAME_EVENT.CLUB_RED_FLOWER_RECORD, result = response.result,type = mapType})
  3178. else
  3179. self:showError(Cmd.PHP_CLUB_RED_FLOWER_RECORD,response)
  3180. end
  3181. end)
  3182. end
  3183. function ClubProtocolPhp:requestCancelCoparner(clubId,ops)
  3184. local param = {
  3185. gid = clubId,
  3186. ops = ops,
  3187. }
  3188. --logD("ClubProtocolPhp:requestCancelCoparner",table.tostring(param))
  3189. self:post(Cmd.PHP_CLUB_CANCELCOPARNER,param,function(response)
  3190. logD("ClubProtocolPhp:requestCancelCoparner",table.tostring(response))
  3191. if response.code==200 then
  3192. else
  3193. if response.code == 1010 then
  3194. self:dispatchEvent({name = GAME_EVENT.CLUB_CANCEL_COPARTNER_TIP})
  3195. else
  3196. self:showError(Cmd.PHP_CLUB_CANCELCOPARNER,response)
  3197. end
  3198. end
  3199. local clubInfo = self.clubList[clubId]
  3200. if clubInfo then
  3201. clubInfo.cancelCopartner = {}
  3202. end
  3203. self:dispatchEvent({name = GAME_EVENT.CLUB_CANCEL_COPARTNER, result = response.result})
  3204. end)
  3205. end
  3206. --请求调整合伙人成员
  3207. function ClubProtocolPhp:requestAdjustCopartnerMember(clubId,muid,uids,lastViewType,callBack,curType)
  3208. local param = {
  3209. gid = clubId,
  3210. muid = muid,
  3211. uids = uids,
  3212. viewType = lastViewType,
  3213. type = curType,
  3214. }
  3215. app.waitDialogManager:showWaitNetworkDialog("正在调配...")
  3216. self:post(Cmd.PHP_CLUB_ARENACOPARTNERSETUP,param,function(response)
  3217. app.waitDialogManager:closeWaitNetworkDialog()
  3218. logD("ClubProtocolPhp:requestAdjustCopartnerMember Response",table.tostring(response))
  3219. if response.code == 200 then
  3220. if callBack then
  3221. callBack()
  3222. end
  3223. self:showError(Cmd.PHP_CLUB_ARENACOPARTNERSETUP,response)
  3224. else
  3225. self:showError(Cmd.PHP_CLUB_ARENACOPARTNERSETUP,response)
  3226. end
  3227. end)
  3228. end
  3229. --获取单个成员信息
  3230. function ClubProtocolPhp:requestSinglePlayer(clubId,muid,viewType)
  3231. local param = {
  3232. gid = clubId,
  3233. muid = muid,
  3234. viewType = viewType,
  3235. }
  3236. logD("ClubProtocolPhp:requestSinglePlayer",table.tostring(param))
  3237. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  3238. self:post(Cmd.PHP_CLUB_MEMBER_INFO,param,function(response)
  3239. app.waitDialogManager:closeWaitNetworkDialog()
  3240. logD("ClubProtocolPhp:requestSinglePlayer Response",table.tostring(response))
  3241. if response.code == 200 then
  3242. self:updateClubPlayer(clubId,response.result,true,viewType)
  3243. self:updateClubPlayer(clubId,response.result.extInfo,true,viewType)
  3244. if viewType == ClubDefine.PlayListType.MATCH_MEMBER
  3245. or viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER then
  3246. self:dispatchEvent({name = GAME_EVENT.UPDATE_COPARTNER_RATDIO})
  3247. elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LEVEL then
  3248. self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_TEAM_LEVEL})
  3249. end
  3250. else
  3251. self:showError(Cmd.PHP_CLUB_MEMBER_INFO,response,response)
  3252. end
  3253. end)
  3254. end
  3255. --获取单个成员信息(合盟)
  3256. function ClubProtocolPhp:requestUnionSinglePlayer(clubId,muid,viewType,sgid)
  3257. local param = {
  3258. gid = sgid,
  3259. muid = muid,
  3260. viewType = viewType,
  3261. }
  3262. logD("ClubProtocolPhp:requestUnionSinglePlayer",table.tostring(param))
  3263. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  3264. self:post(Cmd.PHP_CLUB_MEMBER_INFO,param,function(response)
  3265. app.waitDialogManager:closeWaitNetworkDialog()
  3266. logD("ClubProtocolPhp:requestUnionSinglePlayer Response",table.tostring(response))
  3267. if response.code == 200 then
  3268. response.result.sgid = sgid
  3269. response.result.extInfo.sgid = sgid
  3270. self:updateClubUnionClubId(clubId,response.result,false,viewType)
  3271. self:updateClubUnionClubId(clubId,response.result.extInfo,false,viewType)
  3272. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_SLAVE_UPDATE_LEVEL})
  3273. self:dispatchEvent({name = GAME_EVENT.UPDATE_COPARTNER_RATDIO})
  3274. else
  3275. self:showError(Cmd.PHP_CLUB_MEMBER_INFO,response,response)
  3276. end
  3277. end)
  3278. end
  3279. --获取桌子界面信息
  3280. --[[
  3281. scrollState: 0 不滑动;1:向顶,2:向底
  3282. ]]
  3283. function ClubProtocolPhp:requestClubHome(clubId,gameId,ruleId,scrollState)
  3284. local param = {
  3285. gid = clubId,
  3286. gameid = gameId,
  3287. ruleid = ruleId,
  3288. ver = "1.0.0",
  3289. hallver = loadVersion(),
  3290. }
  3291. logD("ClubProtocolPhp:requestClubHome",table.tostring(param))
  3292. self:post(Cmd.PHP_CLUB_MAIN_VIEW,param,function(response)
  3293. logD("ClubProtocolPhp:requestClubHomeResponse",table.tostring(response))
  3294. if response.code==200 then
  3295. local result = response.result
  3296. self:updateClub(result)
  3297. --self:updateClubRooms(tonumber(result.gid),result.roomlist)
  3298. self:updateClubBaoJians(tonumber(result.gid),result.rules)
  3299. self:updateClubSettings(tonumber(result.gid),result.settings)
  3300. self:dispatchEvent({name = GAME_EVENT.CLUB_TABLE, clubId = clubId,scrollState = scrollState or 1})
  3301. elseif response.code==1011 then
  3302. app.waitDialogManager:showWaitNetworkDialog("连接中...")
  3303. self:dispatchEvent({name = GAME_EVENT.CLUB_BACK_ROOM})
  3304. local function callb()
  3305. app.waitDialogManager:closeWaitNetworkDialog()
  3306. end
  3307. self:requestClubList(callb)
  3308. end
  3309. end)
  3310. end
  3311. ---
  3312. -- 游戏中杀进程重连,此时不会经过亲友圈,拿不到亲友圈配置
  3313. -- 先拉取一次配置
  3314. -- @param clubId
  3315. -- @return
  3316. --
  3317. function ClubProtocolPhp:requestClubHomeInGame(clubId, callback)
  3318. local param = {
  3319. gid = clubId,
  3320. gameid = gameId,
  3321. ruleid = ruleId,
  3322. ver = "1.0.0",
  3323. hallver = loadVersion(),
  3324. }
  3325. logD("ClubProtocolPhp:requestClubHome",table.tostring(param))
  3326. self:post(Cmd.PHP_CLUB_MAIN_VIEW,param,function(response)
  3327. logD("ClubProtocolPhp:requestClubHomeResponse",table.tostring(response))
  3328. if response.code==200 then
  3329. local result = response.result
  3330. self:updateClub(result)
  3331. self:updateClubBaoJians(tonumber(result.gid),result.rules)
  3332. self:updateClubSettings(tonumber(result.gid),result.settings)
  3333. callback(result)
  3334. end
  3335. end)
  3336. end
  3337. --激活游戏
  3338. function ClubProtocolPhp:requestActiveGame(clubId,gameId)
  3339. local param = {
  3340. gid = clubId,
  3341. gameid = gameId,
  3342. }
  3343. logD("ClubProtocolPhp:requestActiveGame",table.tostring(param))
  3344. self:post(Cmd.PHP_CLUB_ACTIVE_GAME,param,function(response)
  3345. logD("ClubProtocolPhp:requestActiveGameResponse",table.tostring(response))
  3346. if response.code==200 then
  3347. local result = response.result
  3348. self:dispatchEvent({name = GAME_EVENT.CLUB_ACTIVE_GAME, clubId = clubId})
  3349. else
  3350. self:showError(Cmd.PHP_CLUB_ACTIVE_GAME,response)
  3351. end
  3352. end)
  3353. end
  3354. --激活游戏玩法
  3355. function ClubProtocolPhp:requestActiveRule(clubId,status,ruleId)
  3356. local param = {
  3357. gid = clubId,
  3358. status = status,
  3359. ruleid = ruleId,
  3360. }
  3361. logD("ClubProtocolPhp:requestActiveRule",table.tostring(param))
  3362. app.waitDialogManager:showWaitNetworkDialog("请稍等...")
  3363. self:post(Cmd.PHP_CLUB_ACTIVE_GAME_RULE,param,function(response)
  3364. app.waitDialogManager:closeWaitNetworkDialog()
  3365. logD("ClubProtocolPhp:requestActiveRuleResponse",table.tostring(response))
  3366. if response.code==200 then
  3367. local result = response.result
  3368. self:showError(Cmd.PHP_CLUB_ACTIVE_GAME_RULE,response,true)
  3369. self:dispatchEvent({name = GAME_EVENT.CLUB_ACTIVE_RULE, clubId = clubId,status = status})
  3370. else
  3371. self:showError(Cmd.PHP_CLUB_ACTIVE_GAME_RULE,response)
  3372. end
  3373. end)
  3374. end
  3375. --房间列表
  3376. function ClubProtocolPhp:requestRoomList(clubId,gameId,ruleId,page,bWait)
  3377. local param = {
  3378. gid = clubId,
  3379. gameid = gameId,
  3380. ruleid = ruleId,
  3381. page = page or 1,
  3382. hallver = loadVersion()
  3383. }
  3384. logD("ClubProtocolPhp:requestRoomList",table.tostring(param))
  3385. if bWait then
  3386. app.waitDialogManager:showWaitNetworkDialog("请求房间数据...")
  3387. end
  3388. self:post(Cmd.PHP_CLUB_ROOMLIST,param,function(response)
  3389. if bWait then
  3390. app.waitDialogManager:closeWaitNetworkDialog()
  3391. end
  3392. logD("ClubProtocolPhp:requestRoomListResponse",table.tostring(response))
  3393. if response.code == 200 then
  3394. local result = response.result
  3395. if not self.clubList[tonumber(clubId)] then
  3396. self.clubList[tonumber(clubId)] = {}
  3397. end
  3398. local club = self.clubList[tonumber(clubId)]
  3399. club.isplaying = result.isplaying
  3400. club.pageNum = result.pageNum or 16
  3401. --修复异常退出房间
  3402. --[[local currentView = app:getCurrentView();
  3403. if club.isplaying == 0 and currentView.__cname ~= "MainView" then
  3404. app.club_php.clubID = tonumber(clubId)
  3405. gotoMainView()
  3406. end--]]
  3407. self:updateClubRooms(tonumber(clubId),result.roomlist or {},result.posnumber)
  3408. self:dispatchEvent({name = GAME_EVENT.CLUB_ROOM_LIST_UPDATE, clubId = clubId,gameId = gameId,tpage = result.tpage})
  3409. else
  3410. self:showError(Cmd.PHP_CLUB_ROOMLIST,response)
  3411. end
  3412. end)
  3413. end
  3414. function ClubProtocolPhp:requestAllRankList(localData,callback)
  3415. local param = {
  3416. gid = localData.clubId,
  3417. lastday = localData.day or 0, --0今天,1昨日, 依次类推; 默认请求0=>今日
  3418. viewType = localData.viewType,
  3419. version = "20191213",
  3420. }
  3421. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  3422. self:post(Cmd.PHP_CLUB_ALL_RANK_LIST,param,function(response)
  3423. app.waitDialogManager:closeWaitNetworkDialog()
  3424. if cc.Application:getInstance():getTargetPlatform() == 0 then
  3425. logD("ClubProtocolPhp:requestAllRankList",table.tostring(response))
  3426. end
  3427. if response.code==200 then
  3428. local result = response.result
  3429. self:updateAllPeopleMatchData(param.gid,result,param.viewType)
  3430. if callback then
  3431. callback(result.list,result.memberInfo,param.viewType)
  3432. end
  3433. else
  3434. self:showError(Cmd.PHP_CLUB_ALL_RANK_LIST,response)
  3435. end
  3436. end)
  3437. end
  3438. --战队/小队排名
  3439. function ClubProtocolPhp:requestTeamRankList(localData)
  3440. local param = {
  3441. gid = localData.clubId,
  3442. viewType = localData.viewType,
  3443. muid = localData.muid,
  3444. lastmonth = localData.lastmonth,
  3445. version = "20191213",
  3446. }
  3447. self:post(Cmd.PHP_CLUB_TEAM_RANK_LIST,param,function(response)
  3448. logD("ClubProtocolPhp:requestTeamRankList",table.tostring(response))
  3449. if response.code==200 then
  3450. local result = response.result
  3451. self:updateClubPlayers(param.gid,result.list,param.viewType)
  3452. self:updateAllPeopleMatchData(param.gid,result,param.viewType)
  3453. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid})
  3454. else
  3455. self:showError(Cmd.PHP_CLUB_TEAM_RANK_LIST,response)
  3456. end
  3457. end)
  3458. end
  3459. --排名赛管理
  3460. function ClubProtocolPhp:requestMatchManage(localData)
  3461. local param = {
  3462. gid = localData.clubId,
  3463. viewType = localData.viewType,
  3464. type = localData.type, --1.排名赛管理,2下级管理,3调配成员
  3465. muid = localData.muid,
  3466. isMyMem = localData.isMyMem, --1仅查看下级成员, 2查看所有
  3467. orderby = localData.orderby, --row字段都可以排序, 比如,uid, role, logion_time
  3468. sort = localData.sort, --升降序
  3469. lastday = localData.lastday, --0今日,1昨日, 2前日依次类推
  3470. page = localData.page or 1, --是全部不分页,不传是0,1是第一页。
  3471. isPage = 1,
  3472. suid = localData.suid
  3473. }
  3474. logD("============start===============",localData.viewType)
  3475. app.waitDialogManager:showWaitNetworkDialog("请稍等...")
  3476. app.waitDialogManager:showWaitNetworkDialog("拉取数据中...")
  3477. self:post(Cmd.PHP_CLUB_WAR_MEMBER,param,function(response)
  3478. if cc.Application:getInstance():getTargetPlatform() == 0 then
  3479. logD("ClubProtocolPhp:requestMatchManage",table.tostring(response))
  3480. end
  3481. app.waitDialogManager:closeWaitNetworkDialog()
  3482. if response.code == 200 then
  3483. local result = response.result
  3484. logD("============end===============",localData.viewType)
  3485. if param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER then
  3486. self.clubList[param.gid].playersLevelOne = {}
  3487. elseif param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER then
  3488. self.clubList[param.gid].playersLevelTwo = {}
  3489. elseif param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then
  3490. self.clubList[param.gid].playersLevelThree = {}
  3491. end
  3492. local pagePlayerList = self:updateClubPlayers(param.gid,result.list,param.viewType)
  3493. self:updateAllPeopleMatchData(param.gid,result,param.viewType)
  3494. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid,result = result,pageList = pagePlayerList})
  3495. else
  3496. self:showError(Cmd.PHP_CLUB_WAR_MEMBER,response)
  3497. end
  3498. end)
  3499. end
  3500. --请求战队等级提升
  3501. function ClubProtocolPhp:requestLevelUpgrade(localData,callBack)
  3502. local param = {
  3503. gid = localData.clubId,
  3504. muid = localData.muid,
  3505. viewType = localData.viewType,
  3506. sgid = localData.sgid,
  3507. }
  3508. self:post(Cmd.PHP_CLUB_LEVEL_UPGRADE,param,function(response)
  3509. logD("ClubProtocolPhp:requestLevelUpgrade",table.tostring(response))
  3510. if response.code==200 then
  3511. if callBack then
  3512. callBack()
  3513. end
  3514. showTooltip("提升成功!")
  3515. local result = response.result
  3516. self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_LEVEL_UPGRADE,response = result})
  3517. else
  3518. self:showError(Cmd.PHP_CLUB_LEVEL_UPGRADE,response,true)
  3519. end
  3520. end)
  3521. end
  3522. --裁判请求--排名赛异常补偿/异常处罚(可批量)
  3523. function ClubProtocolPhp:requestJudgeApply(localData)
  3524. local param = {
  3525. gid = localData.clubId,
  3526. muid = localData.muid, -- 所有成员
  3527. value = localData.value, --大于0为补偿, 小于0为处罚
  3528. viewType = localData.viewType,
  3529. type = localData.type,
  3530. sgid = localData.sgid,
  3531. }
  3532. app.waitDialogManager:showWaitNetworkDialog("请求中...")
  3533. self:post(Cmd.PHP_CLUB_WAR_NUM_APPLY,param,function(response)
  3534. app.waitDialogManager:closeWaitNetworkDialog()
  3535. logD("ClubProtocolPhp:requestJudgeApply",table.tostring(response))
  3536. if response.code==200 then
  3537. local result = response.result
  3538. if localData.sgid and localData.sgid > 0 then
  3539. local groups = result.groups
  3540. if groups then
  3541. for k,v in pairs(groups) do
  3542. self:updateClubUnionClubId(localData.clubId,v,true,localData.viewType)
  3543. end
  3544. end
  3545. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_JOIN_MASTER_LIST,type = localData.viewType})
  3546. else
  3547. local members = result.members
  3548. for k,v in pairs(members) do
  3549. self:updateClubPlayer(localData.clubId,v,true,localData.viewType)
  3550. end
  3551. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = localData.viewType})
  3552. end
  3553. self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_JUDGE})
  3554. self:showError(Cmd.PHP_CLUB_WAR_NUM_APPLY,response,true)
  3555. else
  3556. self:showError(Cmd.PHP_CLUB_WAR_NUM_APPLY,response)
  3557. end
  3558. end)
  3559. end
  3560. --排名赛:指派出赛/上报排名
  3561. function ClubProtocolPhp:requestSetMatchWarNum(localData,callBack)
  3562. local param = {
  3563. gid = localData.clubId,
  3564. muid = localData.muid, -- 所有成员
  3565. viewType = localData.viewType,
  3566. type = localData.type,
  3567. warnum = localData.warnum, --小于0为上报排名; 大于0为指派出赛
  3568. sgid = localData.sgid,
  3569. }
  3570. app.waitDialogManager:showWaitNetworkDialog("请求中...")
  3571. self:post(Cmd.PHP_CLUB_SETMWARNUM,param,function(response)
  3572. app.waitDialogManager:closeWaitNetworkDialog()
  3573. logD("ClubProtocolPhp:requestSetMatchWarNum",table.tostring(response))
  3574. if response.code == 200 then
  3575. local result = response.result
  3576. if localData.sgid and localData.sgid > 0 then
  3577. local groups = result.groups
  3578. if groups then
  3579. for k,v in pairs(groups) do
  3580. self:updateClubUnionClubId(localData.clubId,v,true,localData.viewType)
  3581. end
  3582. end
  3583. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_JOIN_MASTER_LIST,type = localData.viewType})
  3584. else
  3585. local members = result.members
  3586. for k,v in pairs(members) do
  3587. self:updateClubPlayer(localData.clubId,v,true,localData.viewType)
  3588. end
  3589. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = localData.viewType})
  3590. end
  3591. if callBack then
  3592. callBack()
  3593. end
  3594. self:showError(Cmd.PHP_CLUB_SETMWARNUM,response,true)
  3595. else
  3596. self:showError(Cmd.PHP_CLUB_SETMWARNUM,response)
  3597. end
  3598. end)
  3599. end
  3600. --记录(上报记录/贡献记录/比赛记录)
  3601. function ClubProtocolPhp:requestMatchLog(localData,callBack)
  3602. local param = {
  3603. gid = localData.clubId,
  3604. muid = localData.muid, -- 所有成员
  3605. viewType = localData.viewType,
  3606. mapType = localData.mapType, --0所有类型记录,32上报记录,35贡献记录
  3607. sgid = localData.sgid,
  3608. -- 分页处理比赛记录问题
  3609. page = localData.page or 1, --是全部不分页,不传是0,1是第一页。
  3610. isPage = 1;
  3611. }
  3612. self:post(Cmd.PHP_CLUB_CONTENT_LOG,param,function(response)
  3613. if cc.Application:getInstance():getTargetPlatform() == 0 then
  3614. logD("ClubProtocolPhp:requestMatchLog",table.tostring(response))
  3615. end
  3616. if response.code==200 then
  3617. local result = response.result.list
  3618. -- 比赛记录 begin
  3619. local allpage = 1;
  3620. if localData.viewType == 3 then
  3621. allpage = response.result.allpage
  3622. end
  3623. -- 比赛记录 end
  3624. self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_LEVEL_LOG,response = result,viewType = param.viewType, allpage = allpage})
  3625. else
  3626. self:showError(Cmd.PHP_CLUB_CONTENT_LOG,response)
  3627. end
  3628. end)
  3629. end
  3630. --记录(等级提升)
  3631. function ClubProtocolPhp:requestMatchLevelUpgradeLog(localData)
  3632. local param = {
  3633. gid = localData.clubId,
  3634. muid = localData.muid,
  3635. viewType = localData.viewType,
  3636. }
  3637. self:post(Cmd.PHP_CLUB_WAR_RANKING_LIST,param,function(response)
  3638. if cc.Application:getInstance():getTargetPlatform() == 0 then
  3639. logD("ClubProtocolPhp:requestMatchLevelUpgradeLog",table.tostring(response))
  3640. end
  3641. if response.code==200 then
  3642. local result = response.result
  3643. self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_LEVEL_LOG,response = result,viewType = param.viewType})
  3644. else
  3645. self:showError(Cmd.PHP_CLUB_WAR_RANKING_LIST,response)
  3646. end
  3647. end)
  3648. end
  3649. --排名分申请
  3650. function ClubProtocolPhp:requestMatchChongBangFen(localData,callback)
  3651. local param = {
  3652. gid = localData.clubId,
  3653. warnum = localData.warnum,
  3654. }
  3655. self:post(Cmd.PHP_CLUB_WARNUM_APPLY,param,function(response)
  3656. logD("ClubProtocolPhp:requestMatchChongBangFen",table.tostring(response))
  3657. if response.code == 200 then
  3658. local result = response.result
  3659. if callback then
  3660. callback(result.content)
  3661. end
  3662. else
  3663. self:showError(Cmd.PHP_CLUB_WARNUM_APPLY,response)
  3664. end
  3665. end)
  3666. end
  3667. function ClubProtocolPhp:requestMatchBaoJianTongJi(localData,callback)
  3668. local param = {
  3669. gid = localData.clubId,
  3670. lastday = localData.lastday, --0今天1昨天..7
  3671. }
  3672. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  3673. self:post(Cmd.PHP_CLUB_BAOJIAN_TONGJI,param,function(response)
  3674. app.waitDialogManager:closeWaitNetworkDialog()
  3675. if cc.Application:getInstance():getTargetPlatform() == 0 then
  3676. logD("ClubProtocolPhp:requestMatchBaoJianTongJi",table.tostring(response))
  3677. end
  3678. if response.code==200 then
  3679. local result = response.result
  3680. if callback then
  3681. callback(result)
  3682. end
  3683. else
  3684. self:showError(Cmd.PHP_CLUB_BAOJIAN_TONGJI,response)
  3685. end
  3686. end)
  3687. end
  3688. function ClubProtocolPhp:requestMatchTongJi(localData,callback)
  3689. local param = {
  3690. gid = localData.clubId,
  3691. lastday = localData.lastday, --0今天1昨天..7
  3692. }
  3693. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  3694. self:post(Cmd.PHP_CLUB_MATCH_TONGJI,param,function(response)
  3695. app.waitDialogManager:closeWaitNetworkDialog()
  3696. if cc.Application:getInstance():getTargetPlatform() == 0 then
  3697. logD("ClubProtocolPhp:requestMatchTongJi",table.tostring(response))
  3698. end
  3699. if response.code==200 then
  3700. local result = response.result
  3701. if callback then
  3702. callback(result.list)
  3703. end
  3704. else
  3705. self:showError(Cmd.PHP_CLUB_MATCH_TONGJI,response)
  3706. end
  3707. end)
  3708. end
  3709. function ClubProtocolPhp:requestClubUnionRecord(localData,callback)
  3710. local tt = {
  3711. gid = localData.clubId,
  3712. lastday = localData.lastday, --0今天1昨天..7
  3713. }
  3714. self:post(Cmd.PHP_CLUB_UNION_RECORD,tt,function(response)
  3715. logD("ClubProtocolPhp:requestClubUnionRecord",table.tostring(response))
  3716. if cc.Application:getInstance():getTargetPlatform() == 0 then
  3717. logD("ClubProtocolPhp:requestClubUnionRecord",table.tostring(response))
  3718. end
  3719. if response.code==200 then
  3720. local result = response.result
  3721. if callback then
  3722. callback(result.list)
  3723. end
  3724. else
  3725. self:showError(Cmd.PHP_CLUB_UNION_RECORD,response)
  3726. end
  3727. end)
  3728. end
  3729. function ClubProtocolPhp:requestMatchChouJiang(localData)
  3730. local param = {
  3731. gid = localData.clubId,
  3732. reward_token = localData.reward_token, --服务器提供的奖励序号
  3733. idx = localData.idx, --服务器提供的领取奖励标识
  3734. }
  3735. self:post(Cmd.PHP_CLUB_MATCH_CHOUJIANG,param,function(response)
  3736. logD("ClubProtocolPhp:requestMatchChouJiang",table.tostring(response))
  3737. if response.code == 200 then
  3738. local result = response.result
  3739. else
  3740. self:showError(Cmd.PHP_CLUB_MATCH_CHOUJIANG,response)
  3741. end
  3742. end)
  3743. end
  3744. function ClubProtocolPhp:requestGrantPower(localData,callback)
  3745. local param = {
  3746. gid = localData.clubId,
  3747. muid = localData.muid,
  3748. value = localData.value,
  3749. viewType = localData.viewType
  3750. }
  3751. self:post(Cmd.PHP_CLUB_GRANT_SET,param,function(response)
  3752. logD("ClubProtocolPhp:requestGrantPower",table.tostring(response))
  3753. if response.code == 200 then
  3754. local result = response.result
  3755. if callback then
  3756. callback()
  3757. end
  3758. self:showError(Cmd.PHP_CLUB_GRANT_SET,response,true)
  3759. else
  3760. self:showError(Cmd.PHP_CLUB_GRANT_SET,response)
  3761. end
  3762. end)
  3763. end
  3764. function ClubProtocolPhp:requestCopyClub(localData)
  3765. local param = {
  3766. gid = localData.clubId,
  3767. getgid = localData.getgid,--指定拉取成员的群
  3768. viewType = localData.viewType,
  3769. }
  3770. self:post(Cmd.PHP_CLUB_COPY_CLUB,param,function(response)
  3771. logD("ClubProtocolPhp:requestMatchChouJiang",table.tostring(response))
  3772. if response.code == 200 then
  3773. local result = response.result
  3774. self:showError(Cmd.PHP_CLUB_COPY_CLUB,response)
  3775. else
  3776. self:showError(Cmd.PHP_CLUB_COPY_CLUB,response)
  3777. end
  3778. end)
  3779. end
  3780. function ClubProtocolPhp:getShowRooms(clubId, gameId)
  3781. clubId = clubId or self.clubID
  3782. gameId = gameId or self:getSelectGameId()
  3783. local clubInfo = self:getClubInfo(clubId)
  3784. if not clubInfo then
  3785. logD("clubInfo is not exist")
  3786. return
  3787. end
  3788. local maxPlayingRoomCount = gameId == 0 and (clubInfo.config.allPlayerPri or 10) or (clubInfo.config.playerPri or 8)
  3789. local playingRoomCount = 0
  3790. local rooms = {}
  3791. local hideRooms = {}
  3792. local tt = self:getSortClubRooms(clubId)
  3793. for i = 1, #tt do
  3794. local room = tt[i]
  3795. if clubInfo.groupext.is_playerpri == 0 then
  3796. table.insert(rooms, room)
  3797. else
  3798. if room.status == 2 then
  3799. -- 已开局的,限制桌数显示
  3800. if playingRoomCount < maxPlayingRoomCount then
  3801. table.insert(rooms, room)
  3802. playingRoomCount = playingRoomCount + 1
  3803. else
  3804. table.insert(hideRooms, room)
  3805. end
  3806. else
  3807. table.insert(rooms, room)
  3808. end
  3809. end
  3810. end
  3811. return rooms, hideRooms;
  3812. end
  3813. --params{master_union:{1关闭2开启}; slave_union:{1关闭2开启} }
  3814. function ClubProtocolPhp:requestUnionSwitch(clubId,localData)
  3815. local tt = {
  3816. gid = clubId,
  3817. params = json.encode(localData),
  3818. }
  3819. self:post(Cmd.PHP_CLUB_UNION_SWITCH,tt,function(response)
  3820. logD("ClubProtocolPhp:requestMatchChouJiang",table.tostring(response))
  3821. if response.code == 200 then
  3822. local result = response.result
  3823. if localData.master_union == 2 then
  3824. response.code = response.code + 1
  3825. self:showError(Cmd.PHP_CLUB_UNION_SWITCH ,response,true)
  3826. elseif localData.slave_union == 2 then
  3827. response.code = response.code + 2
  3828. self:showError(Cmd.PHP_CLUB_UNION_SWITCH,response,true)
  3829. else
  3830. self:showError(Cmd.PHP_CLUB_UNION_SWITCH,response,true)
  3831. end
  3832. local clubInfo = self.clubList[tonumber(clubId)]
  3833. if clubInfo then
  3834. local groupext = clubInfo.groupext
  3835. groupext.master_union = localData.master_union
  3836. groupext.slave_union = localData.slave_union
  3837. groupext.union_agree = localData.union_agree
  3838. end
  3839. self:dispatchEvent({name = GAME_EVENT.CLUB_SET, clubId = clubId})
  3840. else
  3841. self:showError(Cmd.PHP_CLUB_UNION_SWITCH,response)
  3842. end
  3843. end)
  3844. end
  3845. --搜索主盟
  3846. function ClubProtocolPhp:requestSearchMasterUnion(localData,callback)
  3847. local tt = {
  3848. gid = localData.clubId,
  3849. mastergid = localData.mastergid,
  3850. }
  3851. self:post(Cmd.PHP_CLUB_SEARCH_MATER_UNION,tt,function(response)
  3852. logD("ClubProtocolPhp:requestSearchMasterUnion",table.tostring(response))
  3853. if response.code == 200 then
  3854. else
  3855. local code = response.code
  3856. local cmd = Cmd.PHP_CLUB_SEARCH_MATER_UNION
  3857. if code then
  3858. if ClubDefine.Error[cmd] and ClubDefine.Error[cmd][code] then
  3859. response.error = ClubDefine.Error[cmd][code]
  3860. else
  3861. response.error = "错误码:"..code
  3862. end
  3863. else
  3864. response.error = "未知错误!"
  3865. end
  3866. end
  3867. if callback then
  3868. callback(response)
  3869. end
  3870. end)
  3871. end
  3872. --查询主盟
  3873. function ClubProtocolPhp:requestCheckMasterUnion(clubId)
  3874. local tt = {
  3875. gid = clubId,
  3876. }
  3877. app.waitDialogManager:showWaitNetworkDialog("查询主盟...")
  3878. self:post(Cmd.PHP_CLUB_GET_UNION_MASTER_INFO,tt,function(response)
  3879. app.waitDialogManager:closeWaitNetworkDialog()
  3880. logD("ClubProtocolPhp:requestCheckMasterUnion",table.tostring(response))
  3881. if response.code == 200 then
  3882. local result = response.result
  3883. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_CHECK_MASTER, clubId = clubId,result = result})
  3884. else
  3885. self:showError(Cmd.PHP_CLUB_GET_UNION_MASTER_INFO,response)
  3886. end
  3887. end)
  3888. end
  3889. --加入主盟
  3890. function ClubProtocolPhp:requestJoinMasterUnion(localData,callBack)
  3891. local tt = {
  3892. gid = localData.clubId,
  3893. mastergid = localData.mastergid,
  3894. }
  3895. app.waitDialogManager:showWaitNetworkDialog("正在申请...")
  3896. self:post(Cmd.PHP_CLUB_APPLY_MATER_UNION,tt,function(response)
  3897. app.waitDialogManager:closeWaitNetworkDialog()
  3898. logD("ClubProtocolPhp:requestJoinMasterUnion",table.tostring(response))
  3899. if response.code == 200 then
  3900. local result = response.result
  3901. response.okCallBack = callBack
  3902. end
  3903. self:showError(Cmd.PHP_CLUB_APPLY_MATER_UNION,response)
  3904. end)
  3905. end
  3906. --主盟请求加入的副盟列表
  3907. function ClubProtocolPhp:requestJoinMasterUnionList(localData)
  3908. local param = {
  3909. gid = localData.clubId,
  3910. type = localData.type,
  3911. lastday = localData.lastday or 0,
  3912. viewType = localData.viewType,
  3913. score = localData.score or 0,
  3914. }
  3915. app.waitDialogManager:showWaitNetworkDialog("请求中...")
  3916. self:post(Cmd.PHP_CLUB_MATER_UNION_LIST,param,function(response)
  3917. app.waitDialogManager:closeWaitNetworkDialog()
  3918. logD("ClubProtocolPhp:requestJoinMasterUnionList",table.tostring(response))
  3919. if response.code == 200 then
  3920. local result = response.result
  3921. if result and table.nums(result.list) == 0 then
  3922. self.clubList[tonumber(localData.clubId)].unionPlayerList = {}
  3923. end
  3924. self:updateClubUnionClub(param.gid,result.list,param.viewType)
  3925. self:updateAllPeopleMatchData(param.gid,result,param.viewType)
  3926. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_JOIN_MASTER_LIST, type = param.viewType,clubId = localData.clubId,result = result})
  3927. else
  3928. self:showError(Cmd.PHP_CLUB_MATER_UNION_LIST,response)
  3929. end
  3930. end)
  3931. end
  3932. --主盟msg
  3933. function ClubProtocolPhp:requestMasterUnionMessage(clubId)
  3934. local tt = {
  3935. gid = clubId,
  3936. }
  3937. app.waitDialogManager:showWaitNetworkDialog("请求中...")
  3938. self:post(Cmd.PHP_CLUB_MATER_UNION_MESSAGE,tt,function(response)
  3939. app.waitDialogManager:closeWaitNetworkDialog()
  3940. logD("ClubProtocolPhp:requestMasterUnionMessage",table.tostring(response))
  3941. if response.code == 200 then
  3942. local result = response.result
  3943. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_MESSAGE, clubId = clubId,result = result})
  3944. else
  3945. self:showError(Cmd.PHP_CLUB_MATER_UNION_MESSAGE,response)
  3946. end
  3947. end)
  3948. end
  3949. --合盟信息审批
  3950. function ClubProtocolPhp:requestMasterUnionMessageJudge(localData)
  3951. local tt = {
  3952. gid = localData.clubId,
  3953. ops = localData.ops,
  3954. value = localData.value,
  3955. id = localData.id,
  3956. viewType = localData.viewType,
  3957. }
  3958. app.waitDialogManager:showWaitNetworkDialog("请求中...")
  3959. self:post(Cmd.PHP_CLUB_MATER_UNION_MESSAGE_JUDGE,tt,function(response)
  3960. app.waitDialogManager:closeWaitNetworkDialog()
  3961. logD("ClubProtocolPhp:requestMasterUnionMessageJudge",table.tostring(response))
  3962. if response.code == 200 then
  3963. local result = response.result
  3964. --更新列表
  3965. self:requestMasterUnionMessage(localData.clubId)
  3966. else
  3967. self:showError(Cmd.PHP_CLUB_MATER_UNION_MESSAGE_JUDGE,response)
  3968. end
  3969. end)
  3970. end
  3971. --合盟解散主盟
  3972. function ClubProtocolPhp:requestMasterUnionDissmiss(localData,callback)
  3973. local tt = {
  3974. gid = localData.clubId,
  3975. viewType = localData.viewType
  3976. }
  3977. app.waitDialogManager:showWaitNetworkDialog("请求中...")
  3978. self:post(Cmd.PHP_CLUB_SLAVE_UNION_DISSMISS,tt,function(response)
  3979. app.waitDialogManager:closeWaitNetworkDialog()
  3980. logD("ClubProtocolPhp:requestMasterUnionDissmiss",table.tostring(response))
  3981. if response.code == 200 then
  3982. local result = response.result
  3983. self:showError(Cmd.PHP_CLUB_SLAVE_UNION_DISSMISS,response,true)
  3984. if callback then
  3985. callback()
  3986. end
  3987. else
  3988. self:showError(Cmd.PHP_CLUB_SLAVE_UNION_DISSMISS,response)
  3989. end
  3990. end)
  3991. end
  3992. --盟主发起冻结,取消冻结,解散关系,比例调配等操作
  3993. --[[
  3994. $type : {
  3995. 1状态操作 $value 1正常2冻结0解散
  3996. 2贡献分配 $value 0~100
  3997. }
  3998. ]]
  3999. function ClubProtocolPhp:requestMasterUnionOps(localData,callback)
  4000. local tt = {
  4001. gid = localData.clubId,
  4002. type = localData.type,
  4003. value = localData.value,
  4004. sgid = localData.sgid,
  4005. viewType = localData.viewType,
  4006. }
  4007. app.waitDialogManager:showWaitNetworkDialog("请求中...")
  4008. self:post(Cmd.PHP_CLUB_MASTER_UNION_SETUP,tt,function(response)
  4009. app.waitDialogManager:closeWaitNetworkDialog()
  4010. logD("ClubProtocolPhp:requestMasterUnionOps",table.tostring(response))
  4011. if response.code == 200 then
  4012. local result = response.result
  4013. self:showError(Cmd.PHP_CLUB_MASTER_UNION_SETUP,response,true)
  4014. if localData.type == 1 then
  4015. app.club_php:requestJoinMasterUnionList(localData)
  4016. end
  4017. else
  4018. self:showError(Cmd.PHP_CLUB_MASTER_UNION_SETUP,response)
  4019. end
  4020. end)
  4021. end
  4022. function ClubProtocolPhp:updateClubUnionClub(clubId,slaveUnionClubIdList,mType,dateType)
  4023. if not slaveUnionClubIdList then
  4024. return
  4025. end
  4026. if not self.clubList[clubId] then
  4027. return
  4028. end
  4029. local club = self.clubList[clubId]
  4030. --[[if club.playersMatch then
  4031. for k,v in pairs(club.playersMatch) do
  4032. v.viewType = nil
  4033. end
  4034. end--]]
  4035. for k,v in pairs(slaveUnionClubIdList) do
  4036. self:updateClubUnionClubId(clubId,v,nil,mType,dateType)
  4037. end
  4038. end
  4039. function ClubProtocolPhp:updateClubUnionClubId(clubId,v,isModified,mType,dateType)
  4040. if not self.clubList[clubId] or not v then
  4041. return
  4042. end
  4043. mType = mType or ClubDefine.PlayListType.UNION_CLUB_LIST
  4044. local club = self.clubList[clubId]
  4045. if not club.unionPlayerList then
  4046. club.unionPlayerList={}
  4047. end
  4048. if not club.mySelfData then
  4049. club.mySelfData = {}
  4050. end
  4051. local curUnionClubData = nil
  4052. if mType == ClubDefine.PlayListType.UNION_CLUB_LIST then
  4053. curUnionClubData = club.unionPlayerList
  4054. if tonumber(v.sgid) == self.clubID then
  4055. curUnionClubData = club.mySelfData
  4056. end
  4057. end
  4058. if not curUnionClubData[tonumber(v.sgid)] then
  4059. if isModified then --如果是修改没有数据直接return
  4060. return
  4061. end
  4062. curUnionClubData[tonumber(v.sgid)] = {}
  4063. end
  4064. local slaveUnion = curUnionClubData[tonumber(v.sgid)]
  4065. slaveUnion.viewType = mType
  4066. slaveUnion.uid = v.uid and tonumber(v.uid) or slaveUnion.uid
  4067. slaveUnion.name = v.nick or slaveUnion.name
  4068. slaveUnion.sex = tonumber(v.sex) or slaveUnion.sex --玩家性别:0未知1男2女
  4069. slaveUnion.strHeadUrl = v.icon or slaveUnion.strHeadUrl --玩家头像地址
  4070. slaveUnion.desc = v.desc or slaveUnion.desc --备注
  4071. slaveUnion.lastPlayNum = v.last_play_number or slaveUnion.lastPlayNum --昨日局数
  4072. slaveUnion.lastPlayWinNum = v.last_play_win_number or slaveUnion.lastPlayWinNum --昨日大赢家次数
  4073. slaveUnion.online = tonumber(v.online) or slaveUnion.online --1在线0离线
  4074. slaveUnion.loginTime = tonumber(v.login_time) or slaveUnion.loginTime --最近登录的时间戳, 如果数值为0, 直接为离线
  4075. slaveUnion.role = tonumber(v.role) or slaveUnion.role or 0 --1成员2管理员3创建人
  4076. slaveUnion.status = tonumber(v.status) or slaveUnion.status or 0 --1正常0黑名单成员-1退出群
  4077. slaveUnion.lastTotalScore = v.last_total_score or slaveUnion.lastTotalScore --昨日输赢积分
  4078. slaveUnion.copartner = tonumber(v.copartner) or slaveUnion.copartner --所属普通合伙人/二级合伙人/直属上级UID
  4079. slaveUnion.copartner_role = v.copartner_role or slaveUnion.copartner_role --所属普通合伙人/二级合伙人
  4080. slaveUnion.copartner_nick = v.copartner_nick or slaveUnion.copartner_nick --所属普通合伙人/二级合伙人/战队名
  4081. slaveUnion.copartner5 = tonumber(v.copartner5) or slaveUnion.copartner5 --所属一级合伙人ID
  4082. slaveUnion.copartner5_nick = v.copartner5_nick or slaveUnion.copartner5_nick --所属一级合伙人NICK
  4083. --数据分类处理,防止数据重复覆盖
  4084. if mType == ClubDefine.PlayListType.UNION_CLUB_LIST then
  4085. --玩家数据
  4086. slaveUnion.id = tonumber(v.id) or slaveUnion.id --id排序
  4087. slaveUnion.sgid = tonumber(v.sgid) or slaveUnion.sgid --合盟申请的亲友圈id
  4088. slaveUnion.sgname = v.sgname or slaveUnion.sgname --合盟群昵称
  4089. slaveUnion.nick = v.nick or slaveUnion.nick --合盟馆主昵称
  4090. slaveUnion.arenaRatio = v.arena_ratio or slaveUnion.arenaRatio or 0 -- 贡献比例
  4091. slaveUnion.status = v.status or slaveUnion.status --1正常2冻结
  4092. slaveUnion.create_time = v.create_time or slaveUnion.create_time --加入时间
  4093. slaveUnion.warnum = tonumber(v.warnum) or slaveUnion.warnum --排名分
  4094. slaveUnion.medal = tonumber(v.medal) or slaveUnion.medal --勋章
  4095. slaveUnion.arenaSprint = tonumber(v.arena_sprint) or slaveUnion.arenaSprint --初始化分
  4096. slaveUnion.arenaReport = tonumber(v.arena_report) or slaveUnion.arenaReport --上报分
  4097. slaveUnion.playNum = tonumber(v.play_number) or slaveUnion.playNum --局数
  4098. slaveUnion.totalScore = v.total_score or slaveUnion.totalScore --输赢积分
  4099. slaveUnion.honor = tonumber(v.honor) or slaveUnion.honor --抽奖
  4100. slaveUnion.captainLevel = tonumber(v.captain_level) or slaveUnion.captainLevel --当前队长等级
  4101. slaveUnion.level = tonumber(v.user_level) or slaveUnion.level --当前队长等级
  4102. slaveUnion.haveRole5 = v.haveRole5 or slaveUnion.haveRole5 or 0 --该盟主名下含有的队长数量
  4103. slaveUnion.playWinNum = tonumber(v.play_win_number) or slaveUnion.playWinNum --大赢家次数
  4104. slaveUnion.data = v.data or slaveUnion.data --常规赛合伙人贡献点
  4105. --[[if slaveUnion.uid == app.user.loginInfo.uid and club.memberInfo then
  4106. club.memberInfo.warnum = slaveUnion.warnum
  4107. self:dispatchEvent({name = GAME_EVENT.CLUB_UPDATE_RED_FLOWER})
  4108. end--]]
  4109. --[[
  4110. slaveUnion.level = tonumber(v.user_level) or slaveUnion.level or 1 --玩牌等级
  4111. slaveUnion.copartner6 = v.copartner6 or slaveUnion.copartner6 --所属二级合伙人ID
  4112. slaveUnion.arenaRatio = v.arena_ratio or slaveUnion.arenaRatio or 0 -- 分成比例
  4113. slaveUnion.copartnerSubStatus = v.copartnerSubStatus or slaveUnion.copartnerSubStatus or 0 -- 对合伙人有效, 1表示可冻结所有下属0表示解冻,-1无权对此合伙人批量处理/或是成员
  4114. slaveUnion.grant = v.grant or slaveUnion.grant or 0 --管理员所拥有的权限(裁判,上报排名,指派出赛)
  4115. --]]
  4116. end
  4117. end
  4118. function ClubProtocolPhp:requestClubBelong()
  4119. local tt = {
  4120. }
  4121. app.waitDialogManager:showWaitNetworkDialog("请求中...")
  4122. self:post(Cmd.PHP_CLUB_UNION_BELONG,tt,function(response)
  4123. app.waitDialogManager:closeWaitNetworkDialog()
  4124. logD("ClubProtocolPhp:requestClubBelong",table.tostring(response))
  4125. if response.code == 200 then
  4126. local result = response.result
  4127. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_CLUB_BELONG, result = result})
  4128. else
  4129. self:showError(Cmd.PHP_CLUB_UNION_BELONG,response)
  4130. end
  4131. end)
  4132. end
  4133. function ClubProtocolPhp:requestClubBelongList()
  4134. local tt = {
  4135. }
  4136. self:post(Cmd.PHP_CLUB_LOCAL_UNION,tt,function(response)
  4137. logD("ClubProtocolPhp:requestClubBelongList",table.tostring(response))
  4138. if response.code == 200 then
  4139. local result = response.result
  4140. self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_CLUB_BELONG_LIST, result = result})
  4141. else
  4142. self:showError(Cmd.PHP_CLUB_LOCAL_UNION,response)
  4143. end
  4144. end)
  4145. end
  4146. function ClubProtocolPhp:requestClubSetBelong(clubId,callback)
  4147. local tt = {
  4148. gid = clubId
  4149. }
  4150. self:post(Cmd.PHP_CLUB_BELONG_SET,tt,function(response)
  4151. logD("ClubProtocolPhp:requestClubSetBelong",table.tostring(response))
  4152. if response.code == 200 then
  4153. local result = response.result
  4154. if callback then
  4155. callback()
  4156. end
  4157. self:showError(Cmd.PHP_CLUB_BELONG_SET,response,true)
  4158. else
  4159. self:showError(Cmd.PHP_CLUB_BELONG_SET,response)
  4160. end
  4161. end)
  4162. end
  4163. function ClubProtocolPhp:requestClubReportRank(clubId,muid,day)
  4164. local tt = {
  4165. gid = clubId,
  4166. auid = app.user.loginInfo.uid,
  4167. muid = muid,
  4168. date = day,
  4169. viewType = ClubDefine.PlayListType.NORMAL_MEMBER,
  4170. }
  4171. self:post(Cmd.PHP_CLUB_SHANG_BAO,tt,function(response)
  4172. logD("ClubProtocolPhp:requestClubReportRank",table.tostring(response))
  4173. if response.code == 200 then
  4174. local result = response.result
  4175. self:showError(Cmd.PHP_CLUB_SHANG_BAO,response,true)
  4176. else
  4177. self:showError(Cmd.PHP_CLUB_SHANG_BAO,response)
  4178. end
  4179. end)
  4180. end
  4181. function ClubProtocolPhp:requestNormalRank(localData,callback)
  4182. local param = {
  4183. gid = localData.clubId,
  4184. date = localData.lastday, --0今天1昨天..7
  4185. }
  4186. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4187. self:post(Cmd.PHP_CLUB_CHECK_RANK,param,function(response)
  4188. app.waitDialogManager:closeWaitNetworkDialog()
  4189. if cc.Application:getInstance():getTargetPlatform() == 0 then
  4190. logD("ClubProtocolPhp:requestNormalRankResponse",table.tostring(response))
  4191. end
  4192. if response.code==200 then
  4193. local result = response.result
  4194. if callback then
  4195. callback(result)
  4196. end
  4197. else
  4198. self:showError(Cmd.PHP_CLUB_CHECK_RANK,response)
  4199. end
  4200. end)
  4201. end
  4202. --cest
  4203. -- cest初始参数信息
  4204. function ClubProtocolPhp:updateCestGameset(messages)
  4205. if not messages then
  4206. return
  4207. end
  4208. local club = self.clubCestInfo
  4209. club.points = {} -- 赛场设置,积分数组
  4210. club.gamenums = {} -- 赛场设置,每轮局数数组
  4211. club.applynums = {} -- 申请参赛名额数组,队长
  4212. club.applynums1 = {} -- 申请参赛名额数组,小队长
  4213. club.applynums2 = {} -- 申请参赛名额数组,小组长
  4214. local _messages = json.decode(messages)
  4215. local _point = string.split(_messages.point,",")
  4216. for _, v in ipairs(_point) do
  4217. table.insert(club.points, v)
  4218. end
  4219. local _gamenum = string.split(_messages.gamenum,",")
  4220. for _, v in ipairs(_gamenum) do
  4221. table.insert(club.gamenums, v)
  4222. end
  4223. if _messages.applynum then
  4224. local _applynum = string.split(_messages.applynum,",")
  4225. for _, v in ipairs(_applynum) do
  4226. table.insert(club.applynums, v)
  4227. end
  4228. end
  4229. if _messages.applynum1 then
  4230. local _applynum1 = string.split(_messages.applynum1,",")
  4231. for _, v in ipairs(_applynum1) do
  4232. table.insert(club.applynums1, v)
  4233. end
  4234. end
  4235. if _messages.applynum2 then
  4236. local _applynum2 = string.split(_messages.applynum2,",")
  4237. for _, v in ipairs(_applynum2) do
  4238. table.insert(club.applynums2, v)
  4239. end
  4240. end
  4241. club.max_contribute = _messages.contribute or 30 -- 最高赛点,比赛设置里面使用
  4242. -- logD("lwq_updateCestGameset"..table.tostring(self.clubCestInfo))
  4243. end
  4244. --cest
  4245. --获取初始参数信息
  4246. function ClubProtocolPhp:requestCestGetGameSet(clubId)
  4247. local param = {
  4248. gid = clubId,
  4249. uid = app.user.loginInfo.uid,
  4250. app = getAppId(),
  4251. }
  4252. self:post(Cmd.PHP_CLUB_CEST_GET_GAMESET,param,function(response)
  4253. logD("ClubProtocolPhp:requestCestGetGameSet",table.tostring(response))
  4254. if response.code==200 then
  4255. local result = response.result
  4256. self:updateCestGameset(result)
  4257. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_GET_GAMESET})
  4258. else
  4259. self:showError(Cmd.PHP_CLUB_CEST_GET_GAMESET,response)
  4260. end
  4261. end)
  4262. end
  4263. -- cest
  4264. --战队/小队排名
  4265. function ClubProtocolPhp:requestCestTeamRankList(localData)
  4266. local param = {
  4267. gid = localData.clubId,
  4268. uid = app.user.loginInfo.uid,
  4269. app = getAppId(),
  4270. page = localData.page,
  4271. orderby = localData.orderby,
  4272. sort = localData.sort, --升降序
  4273. -- lastmonth = localData.lastmonth,
  4274. lastday = localData.lastmonth,
  4275. viewType = localData.viewType,
  4276. version = "20191213",
  4277. -- suid = localData.suid,
  4278. }
  4279. app.waitDialogManager:showWaitNetworkDialog("请稍等...")
  4280. self:post(Cmd.PHP_CLUB_CEST_TEAM_RANK_LIST,param,function(response)
  4281. logD("ClubProtocolPhp:requestCestTeamRankList",table.tostring(response))
  4282. app.waitDialogManager:closeWaitNetworkDialog()
  4283. if response.code==200 then
  4284. local result = response.result
  4285. self:updateClubPlayers(param.gid,result.list,param.viewType)
  4286. self:updateAllPeopleMatchData(param.gid,result,param.viewType)
  4287. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid, allpage = result.allpage})
  4288. else
  4289. self:showError(Cmd.PHP_CLUB_CEST_TEAM_RANK_LIST,response)
  4290. end
  4291. end)
  4292. end
  4293. -- cest
  4294. --战队/小队排名,查自己的排名
  4295. function ClubProtocolPhp:requestCestTeamMyselfRank(localData, callback)
  4296. local param = {
  4297. gid = localData.clubId,
  4298. uid = app.user.loginInfo.uid,
  4299. app = getAppId(),
  4300. page = localData.page,
  4301. orderby = localData.orderby,
  4302. sort = localData.sort, --升降序
  4303. -- lastmonth = localData.lastmonth,
  4304. lastday = localData.lastmonth,
  4305. viewType = localData.viewType,
  4306. version = "20191213",
  4307. -- suid = localData.suid,
  4308. type = 2, -- 老麦说,战队排名里面传2
  4309. }
  4310. self:post(Cmd.PHP_CLUB_CEST_TEAM_RANK_LIST,param,function(response)
  4311. if cc.Application:getInstance():getTargetPlatform() == 0 then
  4312. logD("ClubProtocolPhp:requestCestTeamMyselfRank",table.tostring(response))
  4313. end
  4314. if response.code==200 then
  4315. local result = response.result
  4316. -- self:updateClubPlayers(param.gid,result.list,param.viewType)
  4317. -- self:updateAllPeopleMatchData(param.gid,result,param.viewType)
  4318. -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid, allpage = result.allpage})
  4319. if callback then
  4320. callback(result.memberInfo)
  4321. end
  4322. else
  4323. self:showError(Cmd.PHP_CLUB_CEST_TEAM_RANK_LIST,response)
  4324. end
  4325. end)
  4326. end
  4327. -- cest
  4328. -- 认领比赛接口
  4329. function ClubProtocolPhp:requestCestDrawTeam(localData, callBack)
  4330. local param = {
  4331. gid = localData.clubId,
  4332. uid = app.user.loginInfo.uid,
  4333. app = getAppId(),
  4334. oneNum = localData.oneNum,
  4335. twoNum = localData.twoNum,
  4336. threeNum = localData.threeNum,
  4337. }
  4338. self:post(Cmd.PHP_CLUB_CEST_DRAW_TEAM,param,function(response)
  4339. logD("ClubProtocolPhp:requestCestDrawTeam",table.tostring(response))
  4340. if response.code==200 then
  4341. if callBack then
  4342. callBack()
  4343. end
  4344. showTooltip("认领比赛成功")
  4345. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_DRAW_TEAM,param = param})
  4346. else
  4347. self:showError(Cmd.PHP_CLUB_CEST_DRAW_TEAM,response)
  4348. end
  4349. end)
  4350. end
  4351. -- cest
  4352. -- 结束比赛接口
  4353. function ClubProtocolPhp:requestCestEndTeam(localData, callBack)
  4354. local param = {
  4355. gid = localData.clubId,
  4356. uid = app.user.loginInfo.uid,
  4357. app = getAppId(),
  4358. }
  4359. self:post(Cmd.PHP_CLUB_CEST_END_TEAM,param,function(response)
  4360. logD("ClubProtocolPhp:requestCestEndTeam",table.tostring(response))
  4361. if response.code==200 then
  4362. if callBack then
  4363. callBack()
  4364. end
  4365. showTooltip("结束比赛成功")
  4366. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_END_TEAM,param = param})
  4367. else
  4368. self:showError(Cmd.PHP_CLUB_CEST_END_TEAM,response)
  4369. end
  4370. end)
  4371. end
  4372. --cest
  4373. function ClubProtocolPhp:updateCestInfo(clubId, messages)
  4374. if not messages then
  4375. return
  4376. end
  4377. -- local club = self.clubCestInfo
  4378. -- club.one_gamenum = messages.one_gamenum
  4379. -- club.one_point = messages.one_point
  4380. -- club.two_gamenum = messages.two_gamenum
  4381. -- club.two_point = messages.two_point
  4382. -- club.three_gamenum = messages.three_gamenum
  4383. -- club.three_point = messages.three_point
  4384. local clubInfo = self:getClubInfo(clubId)
  4385. if clubInfo.groupext.cestext then
  4386. clubInfo.groupext.cestext.one_gamenum = messages.one_gamenum or 0
  4387. clubInfo.groupext.cestext.one_point =messages.one_point or 0
  4388. clubInfo.groupext.cestext.two_gamenum =messages.two_gamenum or 0
  4389. clubInfo.groupext.cestext.two_point =messages.two_point or 0
  4390. clubInfo.groupext.cestext.three_gamenum =messages.three_gamenum or 0
  4391. clubInfo.groupext.cestext.three_point =messages.three_point or 0
  4392. clubInfo.groupext.cestext.mid_point =messages.mid_point or 0
  4393. clubInfo.groupext.cestext.mid_gamenum =messages.mid_gamenum or 0
  4394. end
  4395. end
  4396. -- cest
  4397. -- 报名开始接口
  4398. function ClubProtocolPhp:requestCestGameInfo(localData)
  4399. local param = {
  4400. gid = localData.clubId,
  4401. uid = app.user.loginInfo.uid,
  4402. app = getAppId(),
  4403. }
  4404. self:post(Cmd.PHP_CLUB_CEST_GAMEINFO,param,function(response)
  4405. logD("ClubProtocolPhp:requestCestGameInfo",table.tostring(response))
  4406. if response.code==200 then
  4407. -- showTooltip("报名开始")
  4408. self:updateCestInfo(localData.clubId, response.result)
  4409. -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_GAMEINFO,param = response.result})
  4410. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_GAMEINFO})
  4411. else
  4412. self:showError(Cmd.PHP_CLUB_CEST_GAMEINFO,response)
  4413. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_NO_GAMEINFO})
  4414. end
  4415. end)
  4416. end
  4417. -- cest
  4418. -- 报名参加接口
  4419. function ClubProtocolPhp:requestCestStartApply(localData, callBack)
  4420. local param = {
  4421. gid = localData.clubId,
  4422. uid = app.user.loginInfo.uid,
  4423. app = getAppId(),
  4424. type = localData.type
  4425. }
  4426. self:post(Cmd.PHP_CLUB_CEST_START_APPLY,param,function(response)
  4427. logD("ClubProtocolPhp:requestCestStartApply",table.tostring(response))
  4428. if response.code==200 then
  4429. if callBack then
  4430. callBack()
  4431. end
  4432. showTooltip("报名参加成功")
  4433. -- 成功后,修改成报名审核中
  4434. local club = self.clubCestInfo
  4435. club.type = localData.type
  4436. club.status = ClubDefine.SaichangStatus.Shenhe
  4437. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_START_APPLY,param = param})
  4438. else
  4439. self:showError(Cmd.PHP_CLUB_CEST_START_APPLY,response)
  4440. if callBack then
  4441. callBack()
  4442. end
  4443. end
  4444. end)
  4445. end
  4446. -- cest
  4447. -- 海选赛申请列表接口
  4448. function ClubProtocolPhp:requestCestApplyList(localData, callBack)
  4449. local param = {
  4450. gid = localData.clubId,
  4451. uid = app.user.loginInfo.uid,
  4452. app = getAppId(),
  4453. msgtype = localData.msgtype,
  4454. isMyMem = localData.isMyMem, --1仅查看下级成员, 2查看所有
  4455. suid = localData.suid,
  4456. page = localData.page,
  4457. }
  4458. self:post(Cmd.PHP_CLUB_CEST_APPLY_LIST,param,function(response)
  4459. logD("ClubProtocolPhp:requestCestApplyList",table.tostring(response))
  4460. if response.code==200 then
  4461. if callBack then
  4462. callBack()
  4463. end
  4464. local result = response.result
  4465. self:updateClubCestMessages(localData.clubId,result.lists)
  4466. self:updateClubHints(localData.clubId,result)
  4467. -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_APPLY_LIST,tag = ClubDefine.ClubMessage.CEST_MESSAGE})
  4468. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_APPLY_BTN,msgtype = localData.msgtype, pagenum = result.pagenum})
  4469. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MESSAGE}) --茶馆消息tag为1
  4470. else
  4471. if response.error == "您输入的ID有误或不在海选赛" then
  4472. showTooltip("您输入的ID有误或不在海选赛")
  4473. else
  4474. self:showError(Cmd.PHP_CLUB_CEST_APPLY_LIST,response)
  4475. end
  4476. end
  4477. end)
  4478. end
  4479. -- cest
  4480. function ClubProtocolPhp:updateClubCestMessageApplyStatus(clubId,messageId,status,id,name)
  4481. local club = self.clubList[clubId]
  4482. if not club then
  4483. return
  4484. end
  4485. if club.cestMessages then
  4486. for i,msg in pairs(club.cestMessages) do
  4487. if msg.messageId==messageId then
  4488. msg.status = status
  4489. end
  4490. end
  4491. end
  4492. end
  4493. -- cest
  4494. -- 海选赛报名审核接口
  4495. function ClubProtocolPhp:requestCestApplyStatus(clubId, id, status)
  4496. local param = {
  4497. gid = clubId,
  4498. uid = app.user.loginInfo.uid,
  4499. app = getAppId(),
  4500. id = id,
  4501. ops = status,
  4502. }
  4503. app.waitDialogManager:showWaitNetworkDialog()
  4504. self:post(Cmd.PHP_CLUB_CEST_APPLY_STATUS,param,function(response)
  4505. app.waitDialogManager:closeWaitNetworkDialog()
  4506. logD("ClubProtocolPhp:requestCestApplyStatus",table.tostring(response))
  4507. if response.code==200 then
  4508. --修改状态
  4509. self:updateClubCestMessageApplyStatus(clubId,id,status)
  4510. --检测处理完成后设置红点不显示
  4511. local isApplyHints = false
  4512. for k,v in pairs(self.clubList[clubId].cestMessages) do
  4513. if v.status==0 then
  4514. isApplyHints = true
  4515. end
  4516. end
  4517. if not isApplyHints and self.clubList[clubId].role ~= ClubDefine.Job.LevelOneCopartner
  4518. and self.clubList[clubId].role ~= ClubDefine.Job.LevelTwoCopartner and self.clubList[clubId].role ~= ClubDefine.Job.LevelThreeCopartner then
  4519. -- self:requestSetHints(clubId,"warnumhints") -- 之后再找老麦处理
  4520. end
  4521. -- self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.ALL_PEOPLE_MATCH_APPLY})
  4522. -- self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED})
  4523. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MESSAGE})
  4524. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED})
  4525. -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_APPLY_STATUS,result = response.result})
  4526. else
  4527. self:showError(Cmd.PHP_CLUB_CEST_APPLY_STATUS,response)
  4528. end
  4529. end)
  4530. end
  4531. --CEST
  4532. --海选赛管理
  4533. function ClubProtocolPhp:requestCestManage(localData)
  4534. local param = {
  4535. gid = localData.clubId,
  4536. viewType = localData.viewType,
  4537. type = localData.type, --1.排名赛管理,2下级管理,3调配成员
  4538. muid = localData.muid,
  4539. isMyMem = localData.isMyMem, --1仅查看下级成员, 2查看所有
  4540. orderby = localData.orderby, --row字段都可以排序, 比如,uid, role, logion_time
  4541. sort = localData.sort, --升降序
  4542. lastday = localData.lastday, --0今日,1昨日, 2前日依次类推
  4543. page = localData.page or 1, --是全部不分页,不传是0,1是第一页。
  4544. isPage = 1,
  4545. suid = localData.suid
  4546. }
  4547. logD("============startcest===============",localData.viewType)
  4548. app.waitDialogManager:showWaitNetworkDialog("请稍等...")
  4549. -- app.waitDialogManager:showWaitNetworkDialog("拉取数据中...")
  4550. self:post(Cmd.PHP_CLUB_CEST_MEMBER,param,function(response)
  4551. if cc.Application:getInstance():getTargetPlatform() == 0 then
  4552. logD("接口名字", Cmd.PHP_CLUB_CEST_MEMBER)
  4553. logD("ClubProtocolPhp:requestCestManage",table.tostring(response))
  4554. end
  4555. app.waitDialogManager:closeWaitNetworkDialog()
  4556. if response.code == 200 then
  4557. local result = response.result
  4558. logD("============endcest===============",localData.viewType)
  4559. if param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER then
  4560. self.clubList[param.gid].playersLevelOne = {}
  4561. elseif param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER then
  4562. self.clubList[param.gid].playersLevelTwo = {}
  4563. elseif param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then
  4564. self.clubList[param.gid].playersLevelThree = {}
  4565. end
  4566. local pagePlayerList = self:updateClubPlayers(param.gid,result.list,param.viewType)
  4567. self:updateAllPeopleMatchData(param.gid,result,param.viewType)
  4568. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid,result = result,pageList = pagePlayerList})
  4569. else
  4570. self:showError(Cmd.PHP_CLUB_CEST_MEMBER,response)
  4571. end
  4572. end)
  4573. end
  4574. --CEST
  4575. --海选赛排名
  4576. function ClubProtocolPhp:requestCestAllRankList(localData,callback)
  4577. local param = {
  4578. app = getAppId(), --
  4579. uid = app.user.loginInfo.uid, --
  4580. gid = localData.clubId,
  4581. lastday = localData.day or 0, --0今天,1昨日, 依次类推; 默认请求0=>今日
  4582. viewType = localData.viewType,
  4583. version = "20191213",
  4584. }
  4585. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4586. self:post(Cmd.PHP_CLUB_CEST_ALL_RANK_LIST,param,function(response)
  4587. app.waitDialogManager:closeWaitNetworkDialog()
  4588. if cc.Application:getInstance():getTargetPlatform() == 0 then
  4589. logD("ClubProtocolPhp:requestCestAllRankList",table.tostring(response))
  4590. end
  4591. if response.code==200 then
  4592. local result = response.result
  4593. self:updateAllPeopleMatchData(param.gid,result,param.viewType)
  4594. if callback then
  4595. callback(result.list,result.memberInfo,param.viewType)
  4596. end
  4597. else
  4598. self:showError(Cmd.PHP_CLUB_CEST_ALL_RANK_LIST,response)
  4599. end
  4600. end)
  4601. end
  4602. --CEST
  4603. --海选赛申请退赛
  4604. function ClubProtocolPhp:requestCestDrawEndGame(clubId,callback)
  4605. local param = {
  4606. app = getAppId(), --
  4607. uid = app.user.loginInfo.uid, --
  4608. gid = clubId,
  4609. }
  4610. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4611. self:post(Cmd.PHP_CLUB_CEST_DRAW_END_GAME,param,function(response)
  4612. app.waitDialogManager:closeWaitNetworkDialog()
  4613. logD("ClubProtocolPhp:requestCestDrawEndGame",table.tostring(response))
  4614. if response.code==200 then
  4615. local result = response.result
  4616. -- 成功后,修改成退赛申请中
  4617. local club = self.clubCestInfo
  4618. club.type = ClubDefine.Saichang.Tuisai
  4619. club.status = ClubDefine.SaichangStatus.Shenhe
  4620. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_END_GAME})
  4621. else
  4622. self:showError(Cmd.PHP_CLUB_CEST_DRAW_END_GAME,response)
  4623. end
  4624. end)
  4625. end
  4626. -- cest
  4627. -- 获取个人信息
  4628. function ClubProtocolPhp:requestCestUserInfo(clubId)
  4629. local param = {
  4630. gid = clubId,
  4631. uid = app.user.loginInfo.uid,
  4632. app = getAppId(),
  4633. }
  4634. self:post(Cmd.PHP_CLUB_CEST_USER_INFO,param,function(response)
  4635. logD("ClubProtocolPhp:requestCestUserInfo",table.tostring(response))
  4636. if response.code==200 then
  4637. -- type 为 1,2 ,3,的时候 status 状态,0,未领取,1领取 ,2审核中 ,
  4638. -- type 为4 是退赛,这时status 2是退赛申请 ,type如果0也是没有申请
  4639. local club = self.clubCestInfo
  4640. club.point = response.result.point or 0
  4641. club.contribute = response.result.contribute or 0
  4642. club.type = response.result.type or 0
  4643. club.status = response.result.status or 0
  4644. club.curgamenum = response.result.curgamenum or 0 -- 当前局数
  4645. club.gamenum = response.result.gamenum or 0 -- 总局数
  4646. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_USER_INFO})
  4647. else
  4648. --ljx 麦总要求这里上传日志让他看看什么情况
  4649. uploadLogs(Cmd.PHP_CLUB_CEST_USER_INFO.."Error")
  4650. self:showError(Cmd.PHP_CLUB_CEST_USER_INFO,response)
  4651. end
  4652. end)
  4653. end
  4654. -- cest
  4655. -- 终止比赛
  4656. function ClubProtocolPhp:requestCestEndGame(clubId, muid, viewType)
  4657. local param = {
  4658. app = getAppId(),
  4659. gid = clubId,
  4660. uid = app.user.loginInfo.uid,
  4661. muid = muid, -- 所有成员
  4662. viewType = viewType,
  4663. -- type = localData.type,
  4664. -- sgid = localData.sgid,
  4665. }
  4666. app.waitDialogManager:showWaitNetworkDialog("请求中...")
  4667. -- self:post(Cmd.PHP_CLUB_WAR_NUM_APPLY,param,function(response)
  4668. self:post(Cmd.PHP_CLUB_CEST_END_GAME,param,function(response)
  4669. app.waitDialogManager:closeWaitNetworkDialog()
  4670. logD("ClubProtocolPhp:requestCestEndGame",table.tostring(response))
  4671. if response.code==200 then
  4672. showTooltip("操作成功")
  4673. local result = response.result
  4674. local members = result.members
  4675. for k,v in pairs(members) do
  4676. self:updateClubPlayer(clubId,v,true,viewType)
  4677. end
  4678. self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = viewType})
  4679. self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST})
  4680. else
  4681. if response.error then
  4682. response.error = string.gsub(response.error, "无法上报", "无法操作")
  4683. end
  4684. self:showError(Cmd.PHP_CLUB_CEST_END_GAME,response)
  4685. end
  4686. end)
  4687. end
  4688. -- cest
  4689. -- 比赛局数统计
  4690. function ClubProtocolPhp:requestCestBaoJianTongJi(localData,callback)
  4691. local param = {
  4692. gid = localData.clubId,
  4693. lastday = localData.lastday, --0今天1昨天..7
  4694. }
  4695. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4696. self:post(Cmd.PHP_CLUB_CEST_BAOJIAN_TONGJI,param,function(response)
  4697. app.waitDialogManager:closeWaitNetworkDialog()
  4698. if cc.Application:getInstance():getTargetPlatform() == 0 then
  4699. logD("ClubProtocolPhp:requestCestBaoJianTongJi",table.tostring(response))
  4700. end
  4701. if response.code==200 then
  4702. local result = response.result
  4703. if callback then
  4704. callback(result)
  4705. end
  4706. else
  4707. self:showError(Cmd.PHP_CLUB_CEST_BAOJIAN_TONGJI,response)
  4708. end
  4709. end)
  4710. end
  4711. -- cest
  4712. -- 赛事纪录
  4713. function ClubProtocolPhp:requestCestTongJi(localData,callback)
  4714. local param = {
  4715. gid = localData.clubId,
  4716. lastday = localData.lastday, --0今天1昨天..7
  4717. muid = localData.muid, --查看的玩家ID
  4718. }
  4719. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4720. self:post(Cmd.PHP_CLUB_CEST_TONGJI,param,function(response)
  4721. app.waitDialogManager:closeWaitNetworkDialog()
  4722. if cc.Application:getInstance():getTargetPlatform() == 0 then
  4723. logD("ClubProtocolPhp:requestCestTongJi",table.tostring(response))
  4724. end
  4725. if response.code==200 then
  4726. local result = response.result
  4727. if callback then
  4728. callback(result.list)
  4729. end
  4730. else
  4731. self:showError(Cmd.PHP_CLUB_CEST_TONGJI,response)
  4732. end
  4733. end)
  4734. end
  4735. -- cest
  4736. -- 申请记录
  4737. --记录
  4738. function ClubProtocolPhp:requesCestApplyRecordList(localData)
  4739. local param = {
  4740. gid = localData.clubId,
  4741. muid = localData.muid,
  4742. -- viewType = localData.viewType,
  4743. app = getAppId(),
  4744. uid = app.user.loginInfo.uid,
  4745. }
  4746. self:post(Cmd.PHP_CLUB_CEST_APPLY_RECORD_LIST,param,function(response)
  4747. if cc.Application:getInstance():getTargetPlatform() == 0 then
  4748. logD("ClubProtocolPhp:requesCestApplyRecordList",table.tostring(response))
  4749. end
  4750. if response.code==200 then
  4751. local result = response.result
  4752. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_APPLY_LOG,response = result,viewType = param.viewType})
  4753. else
  4754. self:showError(Cmd.PHP_CLUB_CEST_APPLY_RECORD_LIST,response)
  4755. end
  4756. end)
  4757. end
  4758. -- cest
  4759. -- 游戏信息
  4760. function ClubProtocolPhp:requesCestMinge(callback, clubId, applynum)
  4761. local param = {
  4762. app = getAppId(),
  4763. uid = app.user.loginInfo.uid,
  4764. gid = clubId,
  4765. applynum = applynum,
  4766. }
  4767. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4768. self:post(Cmd.PHP_CLUB_CEST_APPLY_MINGE,param,function(response)
  4769. app.waitDialogManager:closeWaitNetworkDialog()
  4770. if cc.Application:getInstance():getTargetPlatform() == 0 then
  4771. logD("ClubProtocolPhp:requesCestMinge",table.tostring(response))
  4772. end
  4773. if response.code==200 then
  4774. local result = response.result
  4775. if callback then
  4776. callback(result)
  4777. end
  4778. self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_CANSAI_MINGE,response = result})
  4779. else
  4780. self:showError(Cmd.PHP_CLUB_CEST_APPLY_MINGE,response)
  4781. end
  4782. end)
  4783. end
  4784. --海选赛申请
  4785. function ClubProtocolPhp:updateClubCestMinge(clubId,messages)
  4786. if not messages then
  4787. return
  4788. end
  4789. if not self.clubList[clubId] then
  4790. self.clubList[clubId] = {}
  4791. end
  4792. local club = self.clubList[clubId]
  4793. club.cestMinge={}
  4794. for _,msg in pairs(messages) do
  4795. if not club.cestMinge[tonumber(msg.id)] then
  4796. club.cestMinge[tonumber(msg.id)] = {}
  4797. end
  4798. local messageItem = club.cestMinge[tonumber(msg.id)]
  4799. messageItem.messageId = tonumber(msg.id)
  4800. messageItem.clubId = tonumber(msg.gid)
  4801. messageItem.uid = tonumber(msg.uid)
  4802. messageItem.nick = msg.nick or ""
  4803. messageItem.icon = msg.icon or ""
  4804. messageItem.role = tonumber(msg.role)
  4805. messageItem.applynum = tonumber(msg.applynum)
  4806. messageItem.applyTime = tonumber(msg.apply_time)
  4807. messageItem.endTime = tonumber(msg.end_time)
  4808. messageItem.status = tonumber(msg.status)
  4809. messageItem.operuid = tonumber(msg.operuid)
  4810. end
  4811. end
  4812. -- cest
  4813. -- 报名参赛申请名额列表
  4814. function ClubProtocolPhp:requesCestMingeList(clubId, callback)
  4815. local param = {
  4816. app = getAppId(),
  4817. uid = app.user.loginInfo.uid,
  4818. gid = clubId,
  4819. }
  4820. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4821. self:post(Cmd.PHP_CLUB_CEST_APPLY_MINGE_LIST,param,function(response)
  4822. app.waitDialogManager:closeWaitNetworkDialog()
  4823. if cc.Application:getInstance():getTargetPlatform() == 0 then
  4824. logD("ClubProtocolPhp:requesCestMingeList",table.tostring(response))
  4825. end
  4826. if response.code==200 then
  4827. if callBack then
  4828. callBack()
  4829. end
  4830. local result = response.result
  4831. self:updateClubCestMinge(clubId,result.lists)
  4832. self:updateClubHints(clubId,result)
  4833. -- self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MESSAGE}) --茶馆消息tag为1
  4834. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MINGE}) --茶馆消息tag为1
  4835. else
  4836. self:showError(Cmd.PHP_CLUB_CEST_APPLY_MINGE_LIST,response)
  4837. end
  4838. end)
  4839. end
  4840. -- cest
  4841. function ClubProtocolPhp:updateClubCestMingeApplyStatus(clubId,messageId,status,id,name)
  4842. local club = self.clubList[clubId]
  4843. if not club then
  4844. return
  4845. end
  4846. if club.cestMinge then
  4847. for i,msg in pairs(club.cestMinge) do
  4848. if msg.messageId==messageId then
  4849. msg.status = status
  4850. end
  4851. end
  4852. end
  4853. end
  4854. -- cest
  4855. -- 海选赛申请名额审核
  4856. function ClubProtocolPhp:requestCestMingeStatus(clubId, id, status)
  4857. local param = {
  4858. gid = clubId,
  4859. uid = app.user.loginInfo.uid,
  4860. app = getAppId(),
  4861. id = id,
  4862. ops = status,
  4863. }
  4864. self:post(Cmd.PHP_CLUB_CEST_APPLY_MINGE_STATUS,param,function(response)
  4865. logD("ClubProtocolPhp:requestCestMingeStatus",table.tostring(response))
  4866. if response.code==200 then
  4867. --修改状态
  4868. self:updateClubCestMingeApplyStatus(clubId,id,status)
  4869. --检测处理完成后设置红点不显示
  4870. local isApplyHints = false
  4871. for k,v in pairs(self.clubList[clubId].cestMinge) do
  4872. if v.status==0 then
  4873. isApplyHints = true
  4874. end
  4875. end
  4876. if not isApplyHints and self.clubList[clubId].role ~= ClubDefine.Job.LevelOneCopartner
  4877. and self.clubList[clubId].role ~= ClubDefine.Job.LevelTwoCopartner and self.clubList[clubId].role ~= ClubDefine.Job.LevelThreeCopartner then
  4878. -- self:requestSetHints(clubId,"warnumhints") -- 之后再找老麦处理
  4879. end
  4880. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MINGE})
  4881. self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED})
  4882. else
  4883. self:showError(Cmd.PHP_CLUB_CEST_APPLY_MINGE_STATUS,response)
  4884. end
  4885. end)
  4886. end
  4887. -- cest
  4888. -- 参赛名额信息
  4889. function ClubProtocolPhp:requesCestMingeInfo(callback, clubId, lastday)
  4890. local param = {
  4891. app = getAppId(),
  4892. uid = app.user.loginInfo.uid,
  4893. gid = clubId,
  4894. lastday = lastday,
  4895. }
  4896. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4897. self:post(Cmd.PHP_CLUB_CEST_MINGE_INFO,param,function(response)
  4898. app.waitDialogManager:closeWaitNetworkDialog()
  4899. logD("ClubProtocolPhp:requesCestMingeInfo",table.tostring(response))
  4900. if response.code==200 then
  4901. local result = response.result
  4902. if callback then
  4903. callback(result)
  4904. end
  4905. -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_CANSAI_MINGE,response = result})
  4906. else
  4907. self:showError(Cmd.PHP_CLUB_CEST_MINGE_INFO,response)
  4908. end
  4909. end)
  4910. end
  4911. -- cest
  4912. -- 参赛名额信息
  4913. function ClubProtocolPhp:requesCestGameNum(callback, clubId, muid)
  4914. local param = {
  4915. app = getAppId(),
  4916. uid = muid,
  4917. gid = clubId,
  4918. }
  4919. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4920. self:post(Cmd.PHP_CLUB_CEST_GET_GAMENUM,param,function(response)
  4921. app.waitDialogManager:closeWaitNetworkDialog()
  4922. logD("ClubProtocolPhp:requesCestGameNum",table.tostring(response))
  4923. if response.code==200 then
  4924. local result = response.result
  4925. if callback then
  4926. callback(result)
  4927. end
  4928. else
  4929. self:showError(Cmd.PHP_CLUB_CEST_GET_GAMENUM,response)
  4930. end
  4931. end)
  4932. end
  4933. -- tianti
  4934. -- 获取sms
  4935. function ClubProtocolPhp:requestTiantiSms(phone,callback)
  4936. local param = {
  4937. phone = phone,
  4938. uid = app.user.loginInfo.uid,
  4939. }
  4940. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4941. self:post(Cmd.PHP_CLUB_TIANTI_AUTHTOKEN,param,function(response)
  4942. app.waitDialogManager:closeWaitNetworkDialog()
  4943. if response.code==200 then
  4944. local result = response.result
  4945. if callback then
  4946. -- callback(result.list)
  4947. -- callback(result)
  4948. end
  4949. showTooltip("验证码获取成功")
  4950. else
  4951. self:showError(Cmd.PHP_CLUB_TIANTI_AUTHTOKEN,response)
  4952. end
  4953. end)
  4954. end
  4955. -- 报名 type = 1报名界面 2报名信息界面
  4956. function ClubProtocolPhp:requestTiantiBaoming(localData,callback)
  4957. local param = {
  4958. app = getAppId(),
  4959. gamename = localData.gamename,
  4960. code = localData.code,
  4961. phone = localData.phone,
  4962. realname = localData.realname,
  4963. type = localData.type,
  4964. }
  4965. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4966. self:post(Cmd.PHP_CLUB_TIANTI_BAOMING_REG,param,function(response)
  4967. app.waitDialogManager:closeWaitNetworkDialog()
  4968. logD("ClubProtocolPhp:requestTiantiBaomingReq",table.tostring(response))
  4969. if response.code==200 then
  4970. local result = response.result
  4971. if callback then
  4972. -- callback(result.list)
  4973. callback(result)
  4974. if localData.type == 1 then
  4975. showTooltip("报名成功")
  4976. else
  4977. showTooltip("修改信息成功")
  4978. self.tiantiInfo =
  4979. {
  4980. phone = localData.phone,
  4981. realname = localData.realname,
  4982. }
  4983. end
  4984. self:dispatchEvent({name = GAME_EVENT.CLUB_TIANTI_BAOMING_REG, type = localData.type})
  4985. end
  4986. else
  4987. self:showError(Cmd.PHP_CLUB_TIANTI_BAOMING_REG,response)
  4988. end
  4989. end)
  4990. end
  4991. -- tianti
  4992. -- 报名信息
  4993. function ClubProtocolPhp:requestTiantiBaomingInfo(callback)
  4994. local param = {
  4995. app = getAppId(),
  4996. uid = app.user.loginInfo.uid,
  4997. }
  4998. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  4999. self:post(Cmd.PHP_CLUB_TIANTI_BAOMING_INFO,param,function(response)
  5000. app.waitDialogManager:closeWaitNetworkDialog()
  5001. logD("ClubProtocolPhp:requestTiantiBaomingInfo",table.tostring(response))
  5002. if response.code==200 then
  5003. local result = response.result
  5004. self.tiantiInfo = {}
  5005. self.tiantiInfo =
  5006. {
  5007. phone = result.phone,
  5008. realname = result.realname,
  5009. }
  5010. if callback then
  5011. callback(result)
  5012. end
  5013. else
  5014. -- self:showError(Cmd.PHP_CLUB_TIANTI_BAOMING_INFO,response)
  5015. end
  5016. end)
  5017. end
  5018. -- tianti
  5019. -- 排行榜
  5020. function ClubProtocolPhp:requestTiantiRank(callback, type)
  5021. local param = {
  5022. type = type,
  5023. app = getAppId(),
  5024. uid = app.user.loginInfo.uid,
  5025. }
  5026. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  5027. self:post(Cmd.PHP_CLUB_TIANTI_RANK,param,function(response)
  5028. app.waitDialogManager:closeWaitNetworkDialog()
  5029. if cc.Application:getInstance():getTargetPlatform() == 0 then
  5030. logD("ClubProtocolPhp:requestTiantiRank",table.tostring(response))
  5031. end
  5032. if response.code==200 then
  5033. local result = response.result
  5034. if callback then
  5035. callback(result)
  5036. end
  5037. else
  5038. self:showError(Cmd.PHP_CLUB_TIANTI_RANK,response)
  5039. end
  5040. end)
  5041. end
  5042. -- tianti
  5043. -- 游戏信息
  5044. function ClubProtocolPhp:requestTiantiGameInfo(callback)
  5045. local param = {
  5046. app = getAppId(),
  5047. uid = app.user.loginInfo.uid,
  5048. }
  5049. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  5050. self:post(Cmd.PHP_CLUB_TIANTI_GAME_INFO,param,function(response)
  5051. app.waitDialogManager:closeWaitNetworkDialog()
  5052. logD("ClubProtocolPhp:requestTiantiGameInfo",table.tostring(response))
  5053. if response.code==200 then
  5054. local result = response.result
  5055. if callback then
  5056. callback(result)
  5057. end
  5058. else
  5059. self:showError(Cmd.PHP_CLUB_TIANTI_GAME_INFO,response)
  5060. end
  5061. end)
  5062. end
  5063. --cest
  5064. --取消小红点
  5065. function ClubProtocolPhp:requestSaveRankred(localData, callback)
  5066. local param = {
  5067. app = getAppId(),
  5068. gid = localData.gid,
  5069. lastday = localData.lastday,
  5070. uid = app.user.loginInfo.uid,
  5071. ruid = localData.ruid,
  5072. }
  5073. app.waitDialogManager:showWaitNetworkDialog("请求数据...")
  5074. self:post(Cmd.PHP_CLUB_CEST_SAVE_RANKRED,param,function(response)
  5075. app.waitDialogManager:closeWaitNetworkDialog()
  5076. logD("ClubProtocolPhp:requestSaveRankred: <<group.saveRankred>>",table.tostring(response))
  5077. if response.code==200 then
  5078. if callback then
  5079. callback()
  5080. end
  5081. else
  5082. self:showError(Cmd.PHP_CLUB_CEST_SAVE_RANKRED,response)
  5083. end
  5084. end)
  5085. end
  5086. return ClubProtocolPhp