agent_list.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. layui.use(['table', 'jquery', 'madmin', 'mhttp', 'layer', 'form', 'common', 'laydate'], function () {
  2. let table = layui.table;
  3. let $ = layui.jquery;
  4. let admin = layui.madmin;
  5. let layer = layui.layer;
  6. let form = layui.form;
  7. let mhttp = layui.mhttp;
  8. var laydate = layui.laydate;
  9. admin.getConfig();
  10. laydate.render({
  11. elem: '#start_date',
  12. type: 'date',
  13. format: "yyyy-MM-dd"
  14. });
  15. laydate.render({
  16. elem: '#end_date',
  17. type: 'date',
  18. format: "yyyy-MM-dd"
  19. });
  20. let beginTime = GetQueryString('start_date') ?? null;
  21. let endTime = GetQueryString('end_date') ?? null;
  22. let username = GetQueryString('username') ?? null;
  23. let nick = GetQueryString('nick') ?? null;
  24. let uid = GetQueryString('uid') ?? null;
  25. let agent_uid = GetQueryString('agent_uid') ?? null;
  26. let deduction_switch_num = GetQueryString('deduction_switch_num') ?? null;
  27. let mom_app_uid = GetQueryString('mom_app_uid') ?? null;
  28. let appArray = {};
  29. let appArrayInfo = {};
  30. if (deduction_switch_num){
  31. deduction_switch = deduction_switch_num;
  32. }
  33. $('.mom_app_uid').val(mom_app_uid);
  34. let ret = mhttp.ajax({
  35. url: '/app/all'
  36. });
  37. ret.then((data) => {
  38. if (data.code === 200) {
  39. let html = '<option value=""></option>';
  40. for (var i in data.data) {
  41. appArray[data.data[i].uid] = data.data[i].name;
  42. appArrayInfo[data.data[i].uid] = data.data[i];
  43. html += '<option class="se_' + data.data[i].uid + '" value="' + data.data[i].uid + '">' + data.data[i].name + '</option>';
  44. }
  45. $('.mom_app_uid').append(html);
  46. $('.mom_app_uid .se_' + mom_app_uid).attr('selected', 'selected');
  47. form.render();
  48. let cols = [
  49. [
  50. {
  51. title: 'UID',
  52. field: 'uid',
  53. align: 'center'
  54. },
  55. {
  56. title: '昵称',
  57. field: 'nick',
  58. align: 'center'
  59. },
  60. {
  61. title: '账号',
  62. field: 'username',
  63. align: 'center'
  64. },
  65. {
  66. title: '今日充值',
  67. field: 'td_order_success_money',
  68. align: 'center'
  69. },
  70. {
  71. title: '今日注册',
  72. field: 'td_users_total',
  73. align: 'center'
  74. },
  75. {
  76. title: '今日注册扣量',
  77. field: 'td_users_deduction',
  78. align: 'center'
  79. },
  80. {
  81. title: '总充值',
  82. field: 'order_success_money',
  83. align: 'center'
  84. },
  85. {
  86. title: '总注册扣量',
  87. field: 'users_deduction',
  88. align: 'center'
  89. },
  90. {
  91. title: 'cpa支出金额',
  92. field: 'cps_money',
  93. align: 'center'
  94. },
  95. {
  96. title: '总注册',
  97. field: 'users_total',
  98. align: 'center'
  99. },
  100. {
  101. title: '上级代理',
  102. field: 'parent_uid',
  103. align: 'center'
  104. },
  105. {
  106. title: '所属应用',
  107. field: 'app_name',
  108. align: 'center'
  109. },
  110. {
  111. title: '分成比例(%)',
  112. field: 'commission_ratio',
  113. align: 'center'
  114. },
  115. {
  116. title: '最低提现金额',
  117. field: 'withdraw_amount',
  118. align: 'center',
  119. templet: function (d) {
  120. return d.withdraw_amount === 0 ? '-' : d.withdraw_amount;
  121. }
  122. },
  123. {
  124. title: '最低提现USDT',
  125. field: 'withdraw_usdt',
  126. align: 'center',
  127. templet: function (d) {
  128. return d.withdraw_usdt === 0 ? '-' : d.withdraw_usdt;
  129. }
  130. },
  131. {
  132. title: '时间筛选总充值',
  133. field: 'all_success_money',
  134. align: 'center'
  135. },
  136. {
  137. title: '筛选总充值扣量',
  138. field: 'add_deduction_success_money',
  139. align: 'center'
  140. },
  141. {
  142. title: '今日充值扣量',
  143. field: 'td_deduction_money',
  144. align: 'center'
  145. },
  146. {
  147. title: '时间筛选总注册',
  148. field: 'all_users_total',
  149. align: 'center'
  150. },
  151. {
  152. title: '筛选总注册扣量',
  153. field: 'add_users_deduction',
  154. align: 'center'
  155. },
  156. {
  157. title: '今日提现',
  158. field: 'td_withdraw',
  159. align: 'center'
  160. },
  161. {
  162. title: '总充值扣量',
  163. field: 'deduction_success_money',
  164. align: 'center'
  165. },
  166. {
  167. title: '累计提现',
  168. field: 'withdraw_money',
  169. align: 'center'
  170. },
  171. {
  172. title: '余额',
  173. field: 'balance',
  174. align: 'center'
  175. },
  176. {
  177. title: '冻结资金',
  178. field: 'frozen',
  179. align: 'center'
  180. },
  181. {
  182. title: '扣量类型',
  183. field: 'jdata',
  184. templet: function (d) {
  185. var a;
  186. switch (d.deduction_switch) {
  187. case 0:
  188. a = "全局"
  189. break;
  190. case 1:
  191. a = "cps"
  192. break;
  193. case 2:
  194. a = '<span style=\'color: red\'>cpa</span>';
  195. break;
  196. case 3:
  197. a = 'cpa全局扣量';
  198. break;
  199. }
  200. return a;
  201. },
  202. align: 'center'
  203. },
  204. {
  205. title: '扣量单价',
  206. field: 'cpa_price',
  207. align: 'center'
  208. },
  209. {
  210. title: '状态',
  211. field: 'status',
  212. toolbar: '#agent-status',
  213. align: 'center'
  214. },
  215. {
  216. title: '上次登陆时间',
  217. field: 'last_login_at',
  218. align: 'center'
  219. },
  220. {
  221. title: '上次登陆IP',
  222. field: 'last_login_ip',
  223. align: 'center'
  224. },
  225. {
  226. title: '更新时间',
  227. field: 'updated_at',
  228. align: 'center'
  229. },
  230. {
  231. title: '操作',
  232. toolbar: '#agent-bar',
  233. width: '30',
  234. fixed: 'right',
  235. align: 'center'
  236. }
  237. ]
  238. ]
  239. let search = httpRequestPostData({
  240. username: username,
  241. mom_app_uid: mom_app_uid,
  242. nick: nick,
  243. uid: uid,
  244. parent_uid: agent_uid,
  245. deduction_switch: deduction_switch,
  246. manage: 1,
  247. start_date: beginTime,
  248. end_date: endTime
  249. });
  250. table.render({
  251. elem: '#agent-table',
  252. method: 'POST',
  253. request: {
  254. pageName: 'page',
  255. limitName: 'page_size'
  256. },
  257. async: false,
  258. headers: {
  259. "AUTH-TOKEN": localStorage.getItem('XSRF-TOKEN') ?? ''
  260. },
  261. contentType: 'application/json',
  262. where: search,
  263. url: getMyApiUrl('/agent/lists'),
  264. limit: 20,
  265. limits: [20, 30, 40, 50, 80, 100],
  266. parseData: function (res) {
  267. return httpRequestPagesParseData(res);
  268. },
  269. response: {
  270. "statusCode": 200,
  271. },
  272. done: function (data, page, total) {
  273. var intCode = parseInt(data.code);
  274. if (intCode === 403) {
  275. cbRespnseRedirectLogin(data);
  276. } else if (intCode === 401) {
  277. // 仅仅是过期了,这里可以有其他逻辑补偿.
  278. // 暂时跳到登陆页面
  279. cbRespnse401(data);
  280. }
  281. onloadRender();
  282. },
  283. error: function (obj, message) {
  284. cbRespnseReloadPage(obj, message);
  285. },
  286. page: true,
  287. cols: cols,
  288. skin: 'line',
  289. toolbar: '#agent-toolbar',
  290. defaultToolbar: [{
  291. title: '刷新',
  292. layEvent: 'refresh',
  293. icon: 'layui-icon-refresh',
  294. }, 'filter', 'print', 'exports']
  295. });
  296. } else {
  297. layer.msg(data.message, {icon: 2, time: 1000});
  298. }
  299. });
  300. form.on('submit(search)', function (data) {
  301. // 查询数据
  302. if (data.field.start_date !== '' || data.field.end_date !== '') {
  303. if (!data.field.start_date || !data.field.end_date) {
  304. layer.msg('请核对开始时间与结束时间!');
  305. return false;
  306. }
  307. let beginTimeC = new Date(data.field.start_date);
  308. let endTimeC = new Date(data.field.end_date);
  309. if (beginTimeC > endTimeC) {
  310. layer.msg('开始时间不能大于结束时间!');
  311. return false;
  312. }
  313. }
  314. });
  315. $('#start_date').val(beginTime);
  316. $('#end_date').val(endTime);
  317. $('.username').val(username);
  318. $('.nick').val(nick);
  319. $('.uid').val(uid);
  320. $('.agent_uid').val(agent_uid);
  321. $('.deduction_switch_num_'+deduction_switch_num).attr('selected','selected');
  322. form.render();
  323. table.on('toolbar(agent-table)', function (obj) {
  324. if (obj.event === 'add') {
  325. window.add();
  326. } else if (obj.event === 'refresh') {
  327. window.refresh();
  328. } else if (obj.event === 'batchRemove') {
  329. window.batchRemove(obj);
  330. }
  331. });
  332. window.add = function () {
  333. layer.open({
  334. id: 'agent_create',
  335. type: 2,
  336. title: '添加',
  337. shade: 0.1,
  338. offset: '0px',
  339. area: ['450px', '600px'],
  340. maxWidth: 500,
  341. maxHeight: 600,
  342. scrollbar: true,
  343. content: 'agent_create.html',
  344. });
  345. }
  346. // 表单内
  347. table.on('tool(agent-table)', function (obj) {
  348. if (obj.event === 'remove') {
  349. window.remove(obj);
  350. } else if (obj.event === 'edit') {
  351. window.edit(obj);
  352. }
  353. });
  354. window.edit = function (obj) {
  355. layer.open({
  356. id: 'agent-edit',
  357. type: 2,
  358. title: '修改',
  359. shade: 0.1,
  360. offset: '0px',
  361. area: ['450px', '600px'],
  362. maxWidth: 500,
  363. maxHeight: 600,
  364. scrollbar: true,
  365. content: 'agent_edit.html?agent_uid=' + obj.data.uid,
  366. });
  367. }
  368. // 状态修改
  369. form.on('switch(agent-status-edit)', function (obj) {
  370. let status = layer.load();
  371. let postData = {
  372. uid: this.value
  373. };
  374. let ret = mhttp.ajax({
  375. url: '/agent/edit/status',
  376. data: postData,
  377. });
  378. ret.then((data) => {
  379. layer.close(status);
  380. if (data.code === 200) {
  381. layer.msg(data.message, {icon: 1, time: 1000});
  382. } else {
  383. layer.msg(data.message, {icon: 2, time: 1000});
  384. }
  385. });
  386. });
  387. window.refresh = function (param) {
  388. table.reload('agent-table');
  389. }
  390. $('#reset').click(function (){
  391. $('.deduction_switch_num option').removeAttr('selected');
  392. form.render()
  393. });
  394. })