wsbusiness.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. // # 业务逻辑部分
  2. // ## 相关处理任务
  3. var fileTypes = {
  4. 'serverList': '开服',
  5. 'payList': '充值记录管理',
  6. 'memberList': '玩家信息汇总',
  7. 'memberSubList': '玩家注册归属',
  8. 'admin.complexMemberList': '聚合用户管理-注册用户',
  9. 'admin.complexMemberLoginList': '聚合用户管理-登录用户',
  10. 'admin.complexPayList': '聚合用户管理-充值记录',
  11. 'memberBindList': '绑定信息管理',
  12. 'memberLoginList': '登录用户列表',
  13. 'memberRoleList': '角色管理',
  14. 'playerActiveList': '玩家活跃记录',
  15. 'unionList': '商务账号管理报表',
  16. 'channelList': '推广账号管理报表',
  17. 'gameManagerDown':'游戏管理列表',
  18. 'admin.settleIndex': '结算一级审核',
  19. 'admin.settleCheckList': '结算审核',
  20. 'admin.withdrawIndex': '提现管理',
  21. 'admin.channelPay': '推广员数据',
  22. 'admin.memberCoinIndex': '用户专属平台币',
  23. 'admin.memberCoinDetList': '用户账户明细',
  24. 'admin.channelAccountIndex': '会长账户余额',
  25. 'admin.channelAccountDetList': '推广账户变动明细',
  26. 'admin.memberCoinGetList': '平台币充值记录管理',
  27. 'admin.memberCoinInfoList': '用户平台币明细',
  28. 'retaineGame':'游戏数据统计',
  29. 'retaineGameServer':'游戏区服数据统计',
  30. 'channelRatioCoin':'公会平台币充值导出',
  31. 'companyGameExport':'公司游戏绑定导出',
  32. // 聚合
  33. 'admin.complexSummary@complexSummaryGameExport':'渠道-游戏数据汇总',
  34. 'admin.complexSummary@complexSummaryComplexExport':'渠道-渠道数据汇总',
  35. 'admin.complexSummary@complexSummaryGameDayExport':'渠道-游戏单日报表',
  36. 'admin.complexSummary@complexSummaryGameRetentionExport':'渠道-游戏留存报表',
  37. 'admin.complexSummary@complexSummaryGameServerExport':'渠道-游戏区服数据',
  38. }
  39. // ## 相关处理方法
  40. BusinessActions["reloadBusiness"] = function (data) {
  41. loadWsBusiness();
  42. }
  43. BusinessActions["authFaild"] = function (data) {
  44. // wsConnector.send('{"action": "authFaild"}');
  45. }
  46. BusinessActions["ping"] = function (data) {
  47. wsConnector.send('{"action": "pong"}');
  48. }
  49. BusinessActions["loginResult"] = function (data) {
  50. if (0 !== data.code) {
  51. console.log('WS 登录失败, 原因: ' + data.message);
  52. wsConnector.close();
  53. } else {
  54. // 测试
  55. var template = $('#message-template').html();
  56. template = template.replace('__NAME__', data.message + '<small class="close-msg">×</small>');
  57. template = template.replace('__DATE__', '');
  58. template = template.replace('__CONTENT__', '');
  59. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  60. console.log('WS 登录完成');
  61. // <small class="close-msg">x</small>
  62. }
  63. }
  64. BusinessActions["receive_broadcast"] = function (data) {
  65. notice(data, '系统广播消息');
  66. var template = $('#message-template').html();
  67. template = template.replace('__NAME__', '系统广播消息:' + '<small class="close-msg">×</small>');
  68. template = template.replace('__DATE__', '');
  69. template = template.replace('__CONTENT__', data.message);
  70. // $('.small-chat-box .content').prepend(template);
  71. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  72. }
  73. BusinessActions["downloadPaylist"] = function (data) {}
  74. // test: BusinessActions.subpackageFinish({gamename: '卫龙'});
  75. BusinessActions["subpackageFinish"] = function (data) {
  76. var date = new Date();
  77. //时间补零
  78. var messageTime = "";
  79. if (date.getHours() >= 10) {
  80. messageTime += date.getHours() + ":";
  81. } else {
  82. messageTime += "0" + date.getHours() + ":";
  83. }
  84. if (date.getMinutes() >= 10) {
  85. messageTime += date.getMinutes();
  86. } else {
  87. messageTime += "0" + date.getMinutes();
  88. }
  89. var message = data.gamename;
  90. if (data.cid){
  91. message += '-'+data.cid;
  92. }
  93. var template = $('#message-template').html();
  94. template = template.replace('__NAME__', '游戏打包完成' + '<small class="close-msg">×</small>');
  95. template = template.replace('__DATE__', messageTime);
  96. template = template.replace('__CONTENT__', '您的游戏 ' + message + ' 已经打包完成!<br /><a class="btn btn-xs btn-info show-subpackage-list"></a>');
  97. // $('.small-chat-box .content').prepend(template);
  98. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  99. notice('你的游戏 ' + data.gamename + ' 已经打包完成!');
  100. window.localStorage['push_msg_' + messageTime] = data;
  101. $("iframe").each(function (index, item) {
  102. if ($(item).attr("src").indexOf("game/mine") > -1 || $(item).attr("src").indexOf("game/index") > -1 || $(item).attr("src").indexOf("sub_package/index") > -1) {
  103. $(this)[0].contentWindow.location.reload(true);
  104. }
  105. })
  106. return true;
  107. }
  108. BusinessActions["hasNewGrandMoneyApply"] = function (data) {
  109. // console.log(data);
  110. var date = new Date();
  111. //时间补零
  112. var messageTime = "";
  113. if (date.getHours() >= 10) {
  114. messageTime += date.getHours() + ":";
  115. } else {
  116. messageTime += "0" + date.getHours() + ":";
  117. }
  118. if (date.getMinutes() >= 10) {
  119. messageTime += date.getMinutes();
  120. } else {
  121. messageTime += "0" + date.getMinutes();
  122. }
  123. var template = $('#message-template').html();
  124. template = template.replace('__NAME__', '有新的发币申请' + '<small class="close-msg">×</small>');
  125. template = template.replace('__DATE__', messageTime);
  126. template = template.replace('__CONTENT__', '申请人: ' + data.alipay_nickname + ', 帐号: ' + data.alipay_account + ', 申请金额: ' + data.amount + '<br /><a class="btn btn-xs btn-info show-grand-money-apply-list">查看</a>');
  127. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  128. //点击【查看】打开【...币申请列表】页面
  129. $(".btn.btn-xs.btn-info.show-grand-money-apply-list").on("click", function () {
  130. var _that = this
  131. $("cite").each(function (index, item) {
  132. if (item.innerHTML.indexOf("币申请") > -1) {
  133. $(item).parent().parent()[0].click();
  134. $(_that).parent().parent().html("");
  135. }
  136. });
  137. })
  138. notice('有新的发币申请');
  139. window.localStorage['push_msg_' + messageTime] = data;
  140. return true;
  141. }
  142. BusinessActions["hasNewGrandMoneyApplyPassed"] = function (data) {
  143. var date = new Date();
  144. //时间补零
  145. var messageTime = "";
  146. if (date.getHours() >= 10) {
  147. messageTime += date.getHours() + ":";
  148. } else {
  149. messageTime += "0" + date.getHours() + ":";
  150. }
  151. if (date.getMinutes() >= 10) {
  152. messageTime += date.getMinutes();
  153. } else {
  154. messageTime += "0" + date.getMinutes();
  155. }
  156. var template = $('#message-template').html();
  157. template = template.replace('__NAME__', '有新的发币申请已审核通过' + '<small class="close-msg">×</small>');
  158. template = template.replace('__DATE__', messageTime);
  159. template = template.replace('__CONTENT__', '申请人: ' + data.alipay_nickname + ', 帐号: ' + data.alipay_account + ', 申请金额: ' + data.amount + '<br /><a class="btn btn-xs btn-info show-grand-money-apply-list">查看</a>');
  160. // $('.small-chat-box .content').prepend(template);
  161. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  162. notice('有新的发币申请已审核通过, 请发币');
  163. window.localStorage['push_msg_' + messageTime] = data;
  164. return true;
  165. }
  166. BusinessActions["makeExcelComplete"] = function (data) {
  167. var date = new Date();
  168. //时间补零
  169. var messageTime = "";
  170. if (date.getHours() >= 10) {
  171. messageTime += date.getHours() + ":";
  172. } else {
  173. messageTime += "0" + date.getHours() + ":";
  174. }
  175. if (date.getMinutes() >= 10) {
  176. messageTime += date.getMinutes();
  177. } else {
  178. messageTime += "0" + date.getMinutes();
  179. }
  180. var template = $('#message-template').html();
  181. date = new Date(data.task_time * 1000);
  182. var taskTime = date.getHours() + ':' + date.getMinutes();
  183. template = template.replace('__NAME__', '报表生成完成' + '<small class="close-msg">×</small>');
  184. template = template.replace('__DATE__', messageTime);
  185. template = template.replace('__CONTENT__', '您于 ' + taskTime + ' 生成的 ' + fileTypes[data.file_type] + ' 报表生成好了。<a href="' + data.file_path + '" target="_blank" class="btn btn-xs btn-info">下载</a>');
  186. // $('.small-chat-box .content').prepend(template);
  187. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  188. notice('报表生成完成,请在右边悬浮按钮里查看。');
  189. window.localStorage['push_msg_' + messageTime] = data;
  190. return true;
  191. }
  192. // 公司游戏绑定导出完成通知
  193. BusinessActions["companyGameExportComplete"] = function (data) {
  194. var date = new Date();
  195. //时间补零
  196. var messageTime = "";
  197. if (date.getHours() >= 10) {
  198. messageTime += date.getHours() + ":";
  199. } else {
  200. messageTime += "0" + date.getHours() + ":";
  201. }
  202. if (date.getMinutes() >= 10) {
  203. messageTime += date.getMinutes();
  204. } else {
  205. messageTime += "0" + date.getMinutes();
  206. }
  207. var template = $('#message-template').html();
  208. date = new Date(data.task_time * 1000);
  209. var taskTime = date.getHours() + ':' + date.getMinutes();
  210. template = template.replace('__NAME__', '公司游戏绑定导出完成' + '<small class="close-msg">×</small>');
  211. template = template.replace('__DATE__', messageTime);
  212. template = template.replace('__CONTENT__', '您于 ' + taskTime + ' 提交的‘公司游戏绑定数据’导出已完成。<a href="' + data.file_path + '" target="_blank" class="btn btn-xs btn-info">下载</a>');
  213. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  214. notice('公司游戏绑定导出完成,请在右边悬浮按钮里查看。');
  215. window.localStorage['push_msg_' + messageTime] = data;
  216. return true;
  217. }
  218. BusinessActions["hasNewGameEnterApply"] = function (data) {
  219. var date = new Date();
  220. var messageTime = date.getHours() + ':' + date.getMinutes();
  221. var template = $('#message-template').html();
  222. date = new Date(data.apply_time * 1000);
  223. var gameName = data.game_name;
  224. var channelName = data.channel_name;
  225. var applyTime = date.getHours() + ':' + date.getMinutes();
  226. template = template.replace('__NAME__', '有新的入驻游戏申请,请审核');
  227. template = template.replace('__DATE__', messageTime);
  228. template = template.replace('__CONTENT__', '游戏名称: ' + gameName + ' ,申请渠道: ' + channelName + '。 <a class="btn btn-xs btn-info has-new-game-enter-apply">查看</a>');
  229. $('.small-chat-box .content').prepend(template);
  230. notice('有新的入驻游戏申请,请审核');
  231. window.localStorage['push_msg_' + messageTime] = data;
  232. return true;
  233. }
  234. BusinessActions["hasNewDemandApply"] = function (data) {
  235. var date = new Date();
  236. var messageTime = date.getHours() + ':' + date.getMinutes();
  237. var template = $('#message-template').html();
  238. date = new Date(data.apply_time * 1000);
  239. var applyType = data.apply_type;
  240. var gameName = data.game_name;
  241. var channelName = data.channel_name;
  242. var applyTime = date.getHours() + ':' + date.getMinutes();
  243. if (applyType == 1) {
  244. var applyTypeName = '新游申请';
  245. template = template.replace('__NAME__', '有新的游戏需求申请,请审核');
  246. } else {
  247. applyType = 2;
  248. var applyTypeName = '点位申请';
  249. template = template.replace('__NAME__', '有新的点位需求申请,请审核');
  250. }
  251. template = template.replace('__DATE__', messageTime);
  252. template = template.replace('__CONTENT__', '申请类型: ' + applyTypeName + ',游戏名称: ' + gameName + ' ,申请渠道: ' + channelName + '。 <a class="btn btn-xs btn-info has-new-demand-apply">查看</a>');
  253. $('.small-chat-box .content').prepend(template);
  254. if (applyType == 1) {
  255. notice('有新的游戏需求申请,请审核');
  256. } else {
  257. notice('有新的点位需求申请,请审核');
  258. }
  259. window.localStorage['push_msg_' + messageTime] = data;
  260. return true;
  261. }
  262. BusinessActions["hasNewGiftApply"] = function (data) {
  263. var date = new Date();
  264. var messageTime = date.getHours() + ':' + date.getMinutes();
  265. var template = $('#message-template').html();
  266. date = new Date(data.apply_time * 1000);
  267. var giftName = data.gift_name;
  268. var channelName = data.channel_name;
  269. var applyTime = date.getHours() + ':' + date.getMinutes();
  270. template = template.replace('__NAME__', '有新的礼包领取申请,请审核');
  271. template = template.replace('__DATE__', messageTime);
  272. template = template.replace('__CONTENT__', '礼包名称: ' + giftName + ' ,申请渠道: ' + channelName + '。 <a class="btn btn-xs btn-info has-new-gift-apply">查看</a>');
  273. $('.small-chat-box .content').prepend(template);
  274. notice('有新的礼包领取申请,请审核');
  275. window.localStorage['push_msg_' + messageTime] = data;
  276. return true;
  277. }
  278. BusinessActions["startTask"] = function (data) {
  279. var template = $('#message-template').html();
  280. template = template.replace('__NAME__', '记录时间:' + format(data.task_time * 1000) + '<small class="close-msg">×</small><br/>');
  281. template = template.replace('__DATE__', '任务内容:' + fileTypes[data.file_type] + '<br>当前状态:任务开始');
  282. template = template.replace('__CONTENT__', '剩余任务:' + data.remain_task_number);
  283. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  284. notice('有新任务开始,请审核');
  285. window.localStorage['push_msg_' + data.task_time] = data;
  286. return true;
  287. }
  288. BusinessActions["taskProgress"] = function (data) {
  289. var template = $('#message-template').html();
  290. template = template.replace('__NAME__', '记录时间:' + format(data.task_time * 1000) + '<small class="close-msg">×</small><br/>');
  291. template = template.replace('__DATE__', '任务内容:' + fileTypes[data.file_type] + '<br>当前状态:任务进行中');
  292. template = template.replace('__CONTENT__', '已完成任务:' + data.records_number);
  293. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  294. notice('任务进行中,请审核');
  295. window.localStorage['push_msg_' + data.task_time] = data;
  296. return true;
  297. }
  298. BusinessActions["taskError"] = function (data) {
  299. var template = $('#message-template').html();
  300. template = template.replace('__NAME__', '记录时间:' + format(data.task_time * 1000) + '<small class="close-msg">×</small><br/>');
  301. template = template.replace('__DATE__', '任务内容:' + fileTypes[data.file_type] + '<br>当前状态:任务出错');
  302. template = template.replace('__CONTENT__', '报表出错:' + data.error_type);
  303. $(".floating_ball_wrap .content").prepend('<section>' + template + '</section>');
  304. notice('任务出错,请检查');
  305. window.localStorage['push_msg_' + data.task_time] = data;
  306. return true;
  307. }
  308. function format(timeStamp) {
  309. var time = new Date(parseInt(timeStamp));
  310. var y = time.getFullYear();
  311. var m = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1);
  312. var d = time.getDate() < 10 ? '0' + time.getDate() : time.getDate();
  313. var h = time.getHours() < 10 ? '0' + time.getHours() : time.getHours();
  314. var min = time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes();
  315. var s = time.getSeconds() < 10 ? '0' + time.getSeconds() : time.getSeconds();
  316. return y + '-' + m + '-' + d + ' ' + h + ':' + min + ':' + s;
  317. }