analysis.provider.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <style>
  2. #checkChannel {
  3. border-spacing: 0;
  4. border-collapse: collapse;
  5. }
  6. #checkChannel td {
  7. min-width: 110px;
  8. height: 20px;
  9. padding: 2px;
  10. background: #F3FBFE;
  11. border: 1px solid #fff;
  12. display: block;
  13. white-space: nowrap;
  14. font-size: 10px;
  15. }
  16. #checkChannel tr {
  17. height: 26px;
  18. }
  19. #checkChannel thead tr {
  20. table-layout: fixed;
  21. top: 0;
  22. left: 0;
  23. }
  24. #checkChannel tbody {
  25. height: calc(100vh - 180px);
  26. display: block;
  27. overflow-y: scroll;
  28. }
  29. .echartsContent {
  30. display: flex;
  31. height: calc(100vh - 150px);
  32. }
  33. #echart {
  34. flex: 1;
  35. margin-left: 5px;
  36. }
  37. #echart img {
  38. width: 100%;
  39. }
  40. </style>
  41. <div class="page">
  42. <div class="fixed-bar">
  43. <div class="item-title">
  44. <h3>成功率监控列表</h3>
  45. <ul class="tab-base">
  46. <li><a href="JavaScript:void(0);" class="current"><span>通道按时段成功率监控</span></a></li>
  47. <li><a href="?index.php&act=refill_analysis&op=index&type=provider_speed"><span>通道单量与成功率监控</span></a></li>
  48. <li><a href="?index.php&act=refill_analysis&op=new_version&type=provider_succs"><span>通道按时段成功单量监控</span></a></li>
  49. <li><a href="?index.php&act=refill_analysis&op=new_version&type=provider"><span>通道累计成功率监控</span></a></li>
  50. <li><a href="?index.php&act=refill_analysis&op=index&type=network"><span>通道网络监控</span></a></li>
  51. <li><a href="?index.php&act=refill_analysis&op=index&type=system"><span>机构成功率监控</span></a></li>
  52. <li><a href="?index.php&act=refill_analysis&op=new_version&type=system"><span>机构累计成功率监控</span></a></li>
  53. <li><a href="?index.php&act=refill_analysis&op=merchant_ratios"><span>机构成功率统计</span></a></li>
  54. <li><a href="?index.php&act=refill_analysis&op=new_version&type=mch_order_send"><span>机构单量监控</span></a></li>
  55. </ul>
  56. </div>
  57. </div>
  58. <div class="fixed-empty"></div>
  59. <!-- <div style="margin-top: 10px;color: #e60d0d;">
  60. 请先选择时间
  61. </div> -->
  62. <form method="get" action="index.php" name="formSearch" id="formSearch" style="min-width: 1200px;">
  63. <table class="tb-type1 noborder search tableFixed">
  64. <tr>
  65. <th><label for="query_start_time">统计时间</label></th>
  66. <td>
  67. <input class="txt date" type="text" value="<?php echo $_GET['query_start_time']; ?>" id="startTime" name="query_start_time" autocomplete="off" style="width:120px" />
  68. <label for="query_start_time">~</label>
  69. <input class="txt date" type="text" value="<?php echo $_GET['query_end_time']; ?>" id="endTime" name="query_end_time" autocomplete="off" style="width:120px" />
  70. </td>
  71. <th><label>通道质量</label></th>
  72. <td>
  73. <select name="quality" class="querySelect">
  74. <option value=""><?php echo $lang['nc_please_choose']; ?></option>
  75. <option value="">全部</option>
  76. <option value="<?php echo refill\Quality::Normal; ?>">普充(无流水)
  77. </option>
  78. <option value="<?php echo refill\Quality::Quick; ?>">快充
  79. </option>
  80. <option value="<?php echo refill\Quality::CardKey; ?>">卡密
  81. </option>
  82. <option value="<?php echo refill\Quality::ThirdShop; ?>">三方
  83. </option>
  84. <option value="<?php echo refill\Quality::SlowTwentyFour; ?>">慢24(有流水)
  85. </option>
  86. <option value="<?php echo refill\Quality::SlowSix; ?>">慢6
  87. </option>
  88. <option value="<?php echo refill\Quality::SlowTwo; ?>">慢2
  89. </option>
  90. <option value="<?php echo refill\Quality::SlowFortyEight; ?>">慢48
  91. </option>
  92. <option value="<?php echo refill\Quality::SlowSeventyTwo; ?>">慢72
  93. </option>
  94. <option value="<?php echo refill\Quality::Fastest; ?>">速充
  95. </option>
  96. </select>
  97. </td>
  98. <th><label>卡类型</label></th>
  99. <td>
  100. <div id="select_cardtypes"></div>
  101. </td>
  102. <th><label>面额</label></th>
  103. <td>
  104. <select name="amount">
  105. <option value=""><?php echo $lang['nc_please_choose']; ?></option>
  106. <option value="10" <?php if ($_GET['refill_amount'] == '10') { ?>selected<?php } ?>>10</option>
  107. <option value="20" <?php if ($_GET['refill_amount'] == '20') { ?>selected<?php } ?>>20</option>
  108. <option value="30" <?php if ($_GET['refill_amount'] == '30') { ?>selected<?php } ?>>30</option>
  109. <option value="50" <?php if ($_GET['refill_amount'] == '50') { ?>selected<?php } ?>>50</option>
  110. <option value="100" <?php if ($_GET['refill_amount'] == '100') { ?>selected<?php } ?>>100</option>
  111. <option value="200" <?php if ($_GET['refill_amount'] == '200') { ?>selected<?php } ?>>200</option>
  112. <option value="300" <?php if ($_GET['refill_amount'] == '300') { ?>selected<?php } ?>>300</option>
  113. <option value="500" <?php if ($_GET['refill_amount'] == '500') { ?>selected<?php } ?>>500</option>
  114. <option value="1000" <?php if ($_GET['refill_amount'] == '1000') { ?>selected<?php } ?>>1000</option>
  115. <option value="2000" <?php if ($_GET['refill_amount'] == '2000') { ?>selected<?php } ?>>2000</option>
  116. </select>
  117. </td>
  118. <th><label>窗口时长</label></th>
  119. <td>
  120. <select name="filter_wave">
  121. <option value=""><?php echo $lang['nc_please_choose']; ?></option>
  122. <option value="900">15分钟</option>
  123. <option value="1800">半小时</option>
  124. <option value="3600">1小时</option>
  125. <option value="7200">2小时</option>
  126. <option value="0" selected>关闭</option>
  127. </select>
  128. </td>
  129. <th><label>数据筛选(全部)</label></th>
  130. <td>
  131. <label>
  132. <select name="only_all">
  133. <!-- <option value="">--><?php //echo $lang['nc_please_choose'];
  134. ?>
  135. <!--</option>-->
  136. <option value="1">只看</option>
  137. <option value="2">看</option>
  138. <option value="3" selected>不看</option>
  139. </select>
  140. </label>
  141. </td>
  142. <td>
  143. <a href="javascript:void(0);" id="ncsubmit" class="btn-search" title="<?php echo $lang['nc_query']; ?>">&nbsp;
  144. </a>
  145. </td>
  146. </tr>
  147. <tr>
  148. <td></td>
  149. <td>
  150. <select name="msec">
  151. <option value="1800000">半小时</option>
  152. <option value="3600000">1小时</option>
  153. <option value="7200000">2小时</option>
  154. </select>
  155. <a href="#" class="btns time_rder" data-type='before'>
  156. <span><i class="icon-edit"></i>向前</span>
  157. </a>
  158. <a href="#" class="btns time_rder" data-type='after'>
  159. <span><i class="icon-edit"></i>向后</span>
  160. </a>
  161. <a href="#" class="btns" id="0_rder">
  162. <span><i class="icon-edit"></i>当天零点</span>
  163. </a>
  164. </td>
  165. </tr>
  166. </table>
  167. <div class="echartsContent">
  168. <table id="checkChannel">
  169. <thead>
  170. <tr>
  171. <td style="padding-top: 5px;padding-bottom:10px;">
  172. <label>
  173. <input type="checkbox" id="checkAllChannel">
  174. 编号(通道列表)
  175. </label>
  176. <label style="padding-left: 10px;padding-right:10px;">排序:<select value="ratio1" id="changeSortType">
  177. <option value="ratio1">成功率(百分比)</option>
  178. <option value="ratio2">成功率(普通)</option>
  179. <option value="succ">成功单量</option>
  180. <option value="commit">提交单量</option>
  181. <option value="succ_time">成功回调时间</option>
  182. <option value="fail_time">失败回调时间</option>
  183. </select>
  184. </label>
  185. </td>
  186. </tr>
  187. </thead>
  188. <tbody id="checkChannelContent">
  189. </tbody>
  190. </table>
  191. <div id="echart">
  192. </div>
  193. </div>
  194. </form>
  195. <div id="box">
  196. <!-- <iframe
  197. src="https://www.xyzshops.cn/plot/index?time_stamp=1621488600&interval=60" scrolling="no" id="Iframe" frameborder="0"></iframe> -->
  198. </div>
  199. </div>
  200. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/laydate/laydate.js"></script>
  201. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/jquery.ui.js"></script>
  202. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/i18n/zh-CN.js" charset="utf-8"></script>
  203. <script type="text/javascript" src="<?php echo ADMIN_TEMPLATES_URL; ?>/js/xm-select.js"></script>
  204. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/refill/layer.js"></script>
  205. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/refill/moment-with-locales.js"></script>
  206. <link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css" />
  207. <script type="text/javascript">
  208. $(function() {
  209. let qualitys = {};
  210. let sortType = 'ratio1';
  211. let pageInit = false;
  212. // 30分钟订单
  213. $('.time_rder').click(function() {
  214. let date = new Date()
  215. let type = $(this).data('type');
  216. let msec = $("select[name=msec]").val()
  217. msec = parseInt(msec);
  218. let startTime = $('#startTime').val();
  219. if (startTime === '') {
  220. startTime = date.getTime() - 1800000
  221. startTime = moment(startTime).format("YYYY-M-DD HH:mm:ss")
  222. }
  223. let endTime = $('#endTime').val();
  224. if (endTime === '') {
  225. endTime = moment(date.getTime()).format("YYYY-M-DD HH:mm:ss")
  226. }
  227. if (type === 'before') {
  228. startTime = Date.parse(startTime) - msec
  229. endTime = Date.parse(endTime) - msec
  230. } else {
  231. startTime = Date.parse(startTime) + msec
  232. endTime = Date.parse(endTime) + msec
  233. }
  234. let startTimeStr = moment(startTime).format("YYYY-M-DD HH:mm:ss")
  235. let endtTimeStr = moment(endTime).format("YYYY-M-DD HH:mm:ss")
  236. $('#startTime').val(startTimeStr)
  237. $('#endTime').val(endtTimeStr)
  238. });
  239. // 当前零点钟订单
  240. $('#0_rder').click(function() {
  241. let str = moment().startOf('day').format('YYYY-MM-DD HH:mm:ss');
  242. $('#startTime').val(str)
  243. $('#endTime').val('')
  244. })
  245. $.get(`index.php?act=refill_analysis&op=provider_data`, function(data) {
  246. data = JSON.parse(data)
  247. if (data.length > 0) {
  248. qualitys = init_channels(data);
  249. const items = [];
  250. Object.keys(qualitys).map(key => {
  251. items.push(qualitys[key])
  252. })
  253. formatChannelTable(items);
  254. }
  255. })
  256. $('.querySelect').on('change', function() {
  257. const qualityType = $(this).val();
  258. console.log('qualityType', $(this).val());
  259. $.get(`index.php?act=refill_analysis&op=provider_data&quality=${qualityType}`, function(data) {
  260. console.log('querySelectChangeData', JSON.parse(data));
  261. const channeValues = [];
  262. JSON.parse(data).map(item => {
  263. channeValues.push(item.value)
  264. })
  265. $('#checkChannelContent tr').css('display', 'none');
  266. $(`tr[name = "all"]`).css('display', 'block');
  267. channeValues.map(item => {
  268. $(`tr[name = "${item}"]`).css('display', 'block');
  269. })
  270. })
  271. })
  272. function init_channels(data) {
  273. let result = {};
  274. data.map(item => {
  275. let sname = item.value
  276. result[sname] = {
  277. name: sname,
  278. checked: false,
  279. value: sname,
  280. ratio: 0,
  281. succ: 0,
  282. commit: 0,
  283. succ_time: 0,
  284. fail_time: 0
  285. }
  286. })
  287. return result;
  288. }
  289. $('#changeSortType').change(function() {
  290. console.log('#changeSortType', $(this).val());
  291. if (sortType == $(this).val()) return;
  292. sortType = $(this).val();
  293. sortQualityTable()
  294. })
  295. function formatChannelTable(tableData) {
  296. console.log('formatChannelTable', tableData);
  297. $('#checkChannelContent').children().remove();
  298. let tableHTML = '';
  299. tableData.map(item => {
  300. if (item.name) {
  301. if (sortType == 'ratio1') {
  302. tableHTML += `
  303. <tr name="${item.value}">
  304. <td>
  305. <label>
  306. <input type="checkbox" name="channelValue" ${item.checked?'checked="checked"':''} value="${item.value}" />
  307. ${item.name.split(':').length >= 2 ? item.name.split(':')[1]:item.name.split(':')[0]}
  308. ${pageInit ? `(
  309. ${item.succ}/${item.commit} = <span style='color:${item.ratio > 0?'red':'#000'};'>${(item.ratio * 100).toFixed(3)}%</span>
  310. )`:''}</label></td>
  311. </tr>
  312. `;
  313. } else {
  314. tableHTML += `
  315. <tr name="${item.value}">
  316. <td>
  317. <label>
  318. <input type="checkbox" name="channelValue" ${item.checked?'checked="checked"':''} value="${item.value}" />
  319. ${item.name}
  320. ${pageInit ? `(
  321. ${sortType == 'succ'? "<span style='color:red;'>"+`${item.succ}`+"</span>": item.succ}/
  322. ${sortType == 'commit'? "<span style='color:red;'>"+`${item.commit}`+"</span>": item.commit}
  323. = ${sortType == 'ratio2'? "<span style='color:red;'>"+`${(item.ratio*100).toFixed(3)}%`+"</span>": (item.ratio*100).toFixed(3)+"%"}
  324. )
  325. (
  326. ${sortType == 'succ_time'? "<span style='color:red;'>"+`${item.succ_time}`+"</span>": item.succ_time},
  327. ${sortType == 'fail_time'? "<span style='color:red;'>"+`${item.fail_time}`+"</span>": item.fail_time}
  328. )
  329. `:''}</label></td>
  330. </tr>
  331. `;
  332. }
  333. }
  334. })
  335. $('#checkChannelContent').append(tableHTML);
  336. if (!pageInit) {
  337. $('#ncsubmit').trigger('click');
  338. }
  339. }
  340. laydate.render({
  341. elem: '#startTime',
  342. type: 'datetime'
  343. });
  344. laydate.render({
  345. elem: '#endTime',
  346. type: 'datetime'
  347. });
  348. let select_cardtypes
  349. $.get('index.php?act=refill_analysis&op=card_type_data', function(data) {
  350. data = JSON.parse(data)
  351. select_cardtypes = xmSelect.render({
  352. el: '#select_cardtypes',
  353. size: 'mini',
  354. filterable: true,
  355. style: {
  356. minHeight: '27px',
  357. lineHeight: '27px',
  358. marginLeft: '4px',
  359. width: '250px'
  360. },
  361. language: 'zn',
  362. data: data
  363. })
  364. })
  365. function select_set(selectArr) {
  366. let selectStr = ''
  367. for (let i = 0; i < selectArr.length; i++) {
  368. selectStr += selectArr[i].value + ','
  369. }
  370. selectStr = selectStr.substr(0, selectStr.length - 1)
  371. return selectStr
  372. }
  373. function sortQualityTable() {
  374. let headers = []
  375. let others = qualitys
  376. if (qualitys['all']) {
  377. headers.push(qualitys['all'])
  378. delete others['all']
  379. }
  380. let sortTypeStr = sortType;
  381. if (sortTypeStr == 'ratio1' || sortTypeStr == 'ratio2') {
  382. sortTypeStr = 'ratio';
  383. }
  384. let otherList = [];
  385. Object.keys(others).map(key => {
  386. otherList.push(others[key])
  387. })
  388. const checkedSortQualitys = otherList.filter(item => {
  389. return item.checked;
  390. }).sort(function(a, b) {
  391. return b[sortTypeStr] - a[sortTypeStr];
  392. })
  393. const unCheckedSortQualitys = otherList.filter(item => {
  394. return !item.checked;
  395. }).sort(function(a, b) {
  396. return b[sortTypeStr] - a[sortTypeStr];
  397. })
  398. formatChannelTable([...headers, ...checkedSortQualitys, ...unCheckedSortQualitys]);
  399. }
  400. function updateQualityTable() {
  401. const allQualityList = JSON.parse(JSON.stringify(qualitys));
  402. Object.keys(allQualityList).map(key => {
  403. allQualityList[key].checked = false;
  404. })
  405. // 并集成功后更新数据
  406. pageInit = true;
  407. sortQualityTable();
  408. }
  409. $('#ncsubmit').click(function() {
  410. let query_start_time = $("input[name=query_start_time]").val()
  411. let start_time = parseInt((new Date(query_start_time)).getTime() / 1000);
  412. let query_end_time = $("input[name=query_end_time]").val()
  413. let end_time = parseInt((new Date(query_end_time)).getTime() / 1000);
  414. if (!start_time && !end_time) {
  415. start_time = Date.parse(new Date()) / 1000 - 1800;
  416. end_time = Date.parse(new Date()) / 1000;
  417. }
  418. let chnamesList = [];
  419. $('input[name="channelValue"]').each(function() {
  420. if ($(this).attr('checked')) {
  421. key = $(this).attr('value')
  422. if (key != 'all') {
  423. chnamesList.push(key)
  424. qualitys[key]['checked'] = true
  425. }
  426. }
  427. })
  428. let chnames = chnamesList.join(',');
  429. let card_types = select_cardtypes && select_set(select_cardtypes.getValue())
  430. let spec = $("select[name=amount]").val()
  431. let filter_wave = $("select[name=filter_wave]").val()
  432. let only_all = $("select[name=only_all]").val()
  433. let url = window.location.origin + "/plot/ch_covratio?"
  434. if (start_time) {
  435. url += "&start_time=" + start_time;
  436. }
  437. if (end_time) {
  438. if (end_time < start_time || !start_time) {
  439. layer.msg('日期有误,结束日期需大于开始日期');
  440. return
  441. }
  442. if (end_time - start_time > 86400 * 5) {
  443. layer.msg('日期区间大于五天,请重新选择');
  444. return
  445. }
  446. url += "&end_time=" + end_time;
  447. }
  448. if (chnames) {
  449. url += "&chnames=" + chnames;
  450. }
  451. if (card_types) {
  452. url += "&card_types=" + card_types;
  453. }
  454. if (spec) {
  455. url += "&spec=" + spec;
  456. }
  457. if (filter_wave > 0) {
  458. url += '&filter_wave=' + filter_wave;
  459. }
  460. if (only_all > 0) {
  461. url += '&only_all=' + only_all;
  462. }
  463. $.get(url, function(data) {
  464. if (data.state === 'success') {
  465. $('#echart').html(`<img src='data:image/png;base64,${data.img}'/>`)
  466. Object.keys(qualitys).map(key => {
  467. qualitys[key]['checked'] = false
  468. })
  469. let detail = data.result.detail;
  470. Object.keys(detail).map(key => {
  471. let item = detail[key]
  472. let sname = qualitys[key] ? qualitys[key].name : key
  473. let checked = key == 'all' ? false : true
  474. let val = {
  475. name: sname,
  476. ratio: item[0],
  477. succ: item[1],
  478. commit: item[2],
  479. succ_time: item[3],
  480. fail_time: item[4],
  481. checked: checked,
  482. value: key
  483. }
  484. qualitys[key] = val
  485. })
  486. updateQualityTable(qualitys)
  487. }
  488. });
  489. });
  490. $('#checkAllChannel').click(function() {
  491. if ($(this).get(0).checked) {
  492. $('input[name="channelValue"]').attr('checked', 'checked')
  493. } else {
  494. $('input[name="channelValue"]').removeAttr('checked')
  495. }
  496. })
  497. $('.querySelect').trigger('change');
  498. const fixedHeight = $('.fixed-bar').height();
  499. $('.fixed-empty').css('cssText', 'height:' + (parseFloat(fixedHeight) + 16) + 'px !important');
  500. })
  501. </script>