analysis.provider.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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. </table>
  148. <div class="echartsContent">
  149. <table id="checkChannel">
  150. <thead>
  151. <tr>
  152. <td style="padding-top: 5px;padding-bottom:10px;">
  153. <label>
  154. <input type="checkbox" id="checkAllChannel">
  155. 编号(通道列表)
  156. </label>
  157. <label style="padding-left: 10px;padding-right:10px;">排序:<select value="ratio1" id="changeSortType">
  158. <option value="ratio1">成功率(百分比)</option>
  159. <option value="ratio2">成功率(普通)</option>
  160. <option value="succ">成功单量</option>
  161. <option value="commit">提交单量</option>
  162. <option value="succ_time">成功回调时间</option>
  163. <option value="fail_time">失败回调时间</option>
  164. </select>
  165. </label>
  166. </td>
  167. </tr>
  168. </thead>
  169. <tbody id="checkChannelContent">
  170. </tbody>
  171. </table>
  172. <div id="echart">
  173. </div>
  174. </div>
  175. </form>
  176. <div id="box">
  177. <!-- <iframe
  178. src="https://www.xyzshops.cn/plot/index?time_stamp=1621488600&interval=60" scrolling="no" id="Iframe" frameborder="0"></iframe> -->
  179. </div>
  180. </div>
  181. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/laydate/laydate.js"></script>
  182. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/jquery.ui.js"></script>
  183. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/i18n/zh-CN.js" charset="utf-8"></script>
  184. <script type="text/javascript" src="<?php echo ADMIN_TEMPLATES_URL; ?>/js/xm-select.js"></script>
  185. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/refill/layer.js"></script>
  186. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/refill/moment-with-locales.js"></script>
  187. <link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css" />
  188. <script type="text/javascript">
  189. $(function() {
  190. let qualitys = {};
  191. let sortType = 'ratio1';
  192. let pageInit = false;
  193. const defaultChannelType = <?php echo refill\Quality::Normal; ?>;
  194. $.get(`index.php?act=refill_analysis&op=provider_data`, function(data) {
  195. data = JSON.parse(data)
  196. if (data.length > 0) {
  197. qualitys = init_channels(data);
  198. const items = [];
  199. Object.keys(qualitys).map(key => {
  200. items.push(qualitys[key])
  201. })
  202. formatChannelTable(items);
  203. }
  204. })
  205. $('.querySelect').on('change', function() {
  206. const qualityType = $(this).val();
  207. console.log('qualityType', $(this).val());
  208. $.get(`index.php?act=refill_analysis&op=provider_data&quality=${qualityType}`, function(data) {
  209. console.log('querySelectChangeData', JSON.parse(data));
  210. const channeValues = [];
  211. JSON.parse(data).map(item => {
  212. channeValues.push(item.value)
  213. })
  214. $('#checkChannelContent tr').css('display', 'none');
  215. $(`tr[name = "all"]`).css('display', 'block');
  216. channeValues.map(item => {
  217. $(`tr[name = "${item}"]`).css('display', 'block');
  218. })
  219. })
  220. })
  221. function init_channels(data) {
  222. let result = {};
  223. data.map(item => {
  224. let sname = item.value
  225. result[sname] = {
  226. name: sname,
  227. checked: false,
  228. value: sname,
  229. ratio: 0,
  230. succ: 0,
  231. commit: 0,
  232. succ_time: 0,
  233. fail_time: 0
  234. }
  235. })
  236. return result;
  237. }
  238. $('#changeSortType').change(function() {
  239. console.log('#changeSortType', $(this).val());
  240. if (sortType == $(this).val()) return;
  241. sortType = $(this).val();
  242. sortQualityTable()
  243. })
  244. function formatChannelTable(tableData) {
  245. console.log('formatChannelTable', tableData);
  246. $('#checkChannelContent').children().remove();
  247. let tableHTML = '';
  248. tableData.map(item => {
  249. if (item.name) {
  250. if (sortType == 'ratio1') {
  251. tableHTML += `
  252. <tr name="${item.value}">
  253. <td>
  254. <label>
  255. <input type="checkbox" name="channelValue" ${item.checked?'checked="checked"':''} value="${item.value}" />
  256. ${item.name.split(':').length >= 2 ? item.name.split(':')[1]:item.name.split(':')[0]}
  257. ${pageInit ? `(
  258. ${item.succ}/${item.commit} = <span style='color:${item.ratio > 0?'red':'#000'};'>${(item.ratio * 100).toFixed(3)}%</span>
  259. )`:''}</label></td>
  260. </tr>
  261. `;
  262. } else {
  263. tableHTML += `
  264. <tr name="${item.value}">
  265. <td>
  266. <label>
  267. <input type="checkbox" name="channelValue" ${item.checked?'checked="checked"':''} value="${item.value}" />
  268. ${item.name}
  269. ${pageInit ? `(
  270. ${sortType == 'succ'? "<span style='color:red;'>"+`${item.succ}`+"</span>": item.succ}/
  271. ${sortType == 'commit'? "<span style='color:red;'>"+`${item.commit}`+"</span>": item.commit}
  272. = ${sortType == 'ratio2'? "<span style='color:red;'>"+`${(item.ratio*100).toFixed(3)}%`+"</span>": (item.ratio*100).toFixed(3)+"%"}
  273. )
  274. (
  275. ${sortType == 'succ_time'? "<span style='color:red;'>"+`${item.succ_time}`+"</span>": item.succ_time},
  276. ${sortType == 'fail_time'? "<span style='color:red;'>"+`${item.fail_time}`+"</span>": item.fail_time}
  277. )
  278. `:''}</label></td>
  279. </tr>
  280. `;
  281. }
  282. }
  283. })
  284. $('#checkChannelContent').append(tableHTML);
  285. if (!pageInit) {
  286. $('#ncsubmit').trigger('click');
  287. }
  288. }
  289. laydate.render({
  290. elem: '#startTime',
  291. type: 'datetime'
  292. });
  293. laydate.render({
  294. elem: '#endTime',
  295. type: 'datetime'
  296. });
  297. let select_cardtypes
  298. $.get('index.php?act=refill_analysis&op=card_type_data', function(data) {
  299. data = JSON.parse(data)
  300. select_cardtypes = xmSelect.render({
  301. el: '#select_cardtypes',
  302. size: 'mini',
  303. filterable: true,
  304. style: {
  305. minHeight: '27px',
  306. lineHeight: '27px',
  307. marginLeft: '4px',
  308. width: '250px'
  309. },
  310. language: 'zn',
  311. data: data
  312. })
  313. })
  314. function select_set(selectArr) {
  315. let selectStr = ''
  316. for (let i = 0; i < selectArr.length; i++) {
  317. selectStr += selectArr[i].value + ','
  318. }
  319. selectStr = selectStr.substr(0, selectStr.length - 1)
  320. return selectStr
  321. }
  322. function sortQualityTable() {
  323. let headers = []
  324. let others = qualitys
  325. if (qualitys['all']) {
  326. headers.push(qualitys['all'])
  327. delete others['all']
  328. }
  329. let sortTypeStr = sortType;
  330. if (sortTypeStr == 'ratio1' || sortTypeStr == 'ratio2') {
  331. sortTypeStr = 'ratio';
  332. }
  333. let otherList = [];
  334. Object.keys(others).map(key => {
  335. otherList.push(others[key])
  336. })
  337. const checkedSortQualitys = otherList.filter(item => {
  338. return item.checked;
  339. }).sort(function(a, b) {
  340. return b[sortTypeStr] - a[sortTypeStr];
  341. })
  342. const unCheckedSortQualitys = otherList.filter(item => {
  343. return !item.checked;
  344. }).sort(function(a, b) {
  345. return b[sortTypeStr] - a[sortTypeStr];
  346. })
  347. formatChannelTable([...headers, ...checkedSortQualitys, ...unCheckedSortQualitys]);
  348. }
  349. function updateQualityTable() {
  350. const allQualityList = JSON.parse(JSON.stringify(qualitys));
  351. Object.keys(allQualityList).map(key => {
  352. allQualityList[key].checked = false;
  353. })
  354. // 并集成功后更新数据
  355. pageInit = true;
  356. sortQualityTable();
  357. }
  358. $('#ncsubmit').click(function() {
  359. let query_start_time = $("input[name=query_start_time]").val()
  360. let start_time = parseInt((new Date(query_start_time)).getTime() / 1000);
  361. let query_end_time = $("input[name=query_end_time]").val()
  362. let end_time = parseInt((new Date(query_end_time)).getTime() / 1000);
  363. if (!start_time && !end_time) {
  364. start_time = Date.parse(new Date()) / 1000 - 7200;
  365. end_time = Date.parse(new Date()) / 1000;
  366. }
  367. let chnamesList = [];
  368. $('input[name="channelValue"]').each(function() {
  369. if ($(this).attr('checked')) {
  370. key = $(this).attr('value')
  371. if (key != 'all') {
  372. chnamesList.push(key)
  373. }
  374. qualitys[key]['checked'] = true
  375. }
  376. })
  377. let chnames = chnamesList.join(',');
  378. let card_types = select_cardtypes && select_set(select_cardtypes.getValue())
  379. let spec = $("select[name=amount]").val()
  380. let filter_wave = $("select[name=filter_wave]").val()
  381. let only_all = $("select[name=only_all]").val()
  382. let url = window.location.origin + "/plot/ch_covratio?"
  383. if (start_time) {
  384. url += "&start_time=" + start_time;
  385. }
  386. if (end_time) {
  387. if (end_time < start_time || !start_time) {
  388. layer.msg('日期有误,结束日期需大于开始日期');
  389. return
  390. }
  391. url += "&end_time=" + end_time;
  392. }
  393. if (chnames) {
  394. url += "&chnames=" + chnames;
  395. }
  396. if (card_types) {
  397. url += "&card_types=" + card_types;
  398. }
  399. if (spec) {
  400. url += "&spec=" + spec;
  401. }
  402. if (filter_wave > 0) {
  403. url += '&filter_wave=' + filter_wave;
  404. }
  405. if (only_all > 0) {
  406. url += '&only_all=' + only_all;
  407. }
  408. $.get(url, function(data) {
  409. if (data.state === 'success') {
  410. $('#echart').html(`<img src='data:image/png;base64,${data.img}'/>`)
  411. Object.keys(qualitys).map(key => {
  412. qualitys[key]['checked'] = false
  413. })
  414. let detail = data.result.detail;
  415. Object.keys(detail).map(key => {
  416. let item = detail[key]
  417. let sname = qualitys[key] ? qualitys[key].name : key
  418. let checked = key == 'all' ? false : true
  419. let val = {
  420. name: sname,
  421. ratio: item[0],
  422. succ: item[1],
  423. commit: item[2],
  424. succ_time: item[3],
  425. fail_time: item[4],
  426. checked: checked,
  427. value: key
  428. }
  429. qualitys[key] = val
  430. })
  431. updateQualityTable(qualitys)
  432. }
  433. });
  434. });
  435. $('#checkAllChannel').click(function() {
  436. if ($(this).get(0).checked) {
  437. $('input[name="channelValue"]').attr('checked', 'checked')
  438. } else {
  439. $('input[name="channelValue"]').removeAttr('checked')
  440. }
  441. })
  442. $('.querySelect').trigger('change');
  443. })
  444. </script>