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.
 
 
 
 

696 lines
23 KiB

  1. var httpData;
  2. var pagesize = 10;
  3. var tttHTML = '';
  4. var index = "0";
  5. var will = '';
  6. var over = '';
  7. var cancel = '';
  8. var pay = '';
  9. window.onload = function () {
  10. tttHTML = document.getElementById("tableOrder").innerHTML;
  11. var cur = "";
  12. var currpage = getPar('currpage');
  13. var timelimit = '';
  14. var starttime = '';
  15. var endtime = '';
  16. var ordersource = '';
  17. var moresearch = '';
  18. var typelimit = '';
  19. var ordersource_text = '';
  20. if (!currpage) {
  21. cur = 1;
  22. $('#starttime').val(getDateTime(12));
  23. $('#endtime').val(getDateTime(0));
  24. } else {
  25. cur = currpage;
  26. timelimit = getPar('timelimit');
  27. $('#timelimit').val(timelimit);
  28. starttime = getPar('starttime');
  29. $('#starttime').val(starttime);
  30. endtime = getPar('endtime');
  31. $('#endtime').val(endtime);
  32. ordersource = getPar('ordersource');
  33. $('#ordersource').attr('changeid', ordersource);
  34. ordersource_text = getPar('ordersource_text');
  35. $('#ordersource').val(ordersource_text);
  36. moresearch = getPar('moresearch');
  37. $('#moresearch').val(moresearch);
  38. typelimit = getPar('typelimit');
  39. $('#typelimit').val(typelimit);
  40. }
  41. searchBtnClicked(index, cur, timelimit, starttime, endtime, ordersource, moresearch, typelimit, ordersource_text);
  42. }
  43. function ordersourceSearch(value, self_id) {
  44. var ordersource = $("#ordersource").val();
  45. $.ajax({
  46. url: './st-xm/control.php',
  47. type: "post",
  48. data: {
  49. ordersource: ordersource,
  50. type: "des_ordersource"
  51. },
  52. dataType: "json",
  53. success: function (data) {
  54. if (data.code == 0) {
  55. console.log(data);
  56. createHtml(data.list, self_id)
  57. }
  58. },
  59. fail: function (data) {
  60. // 此处放失败后执行的代码
  61. }
  62. });
  63. }
  64. $(document).ready(function () {
  65. $("#ordersource").click(function (e) {
  66. e.stopPropagation();
  67. $("#select_ordersource").removeClass("hide1");
  68. });
  69. })
  70. $(document).click(function () {
  71. if (!$(".select_ordersource").hasClass("hide1")) {
  72. $(".select_ordersource").addClass("hide1");
  73. }
  74. })
  75. //筛选列表
  76. function createHtml(data, select_id) {
  77. var temp = '<div class="content" id="suoypuqudao" onmouseover="getDark(this.id)" onmouseout="getLight(this.id)" org_id="-1">所有渠道</div>';
  78. for (var i = 0; i < data.length; i++) {
  79. temp += '<div class="content" id="' + select_id + '' + data[i].org_id + '" onmouseover="getDark(this.id)" onmouseout="getLight(this.id)" org_id="' + data[i].org_id + '">' + data[i].org_name + '</div>'
  80. }
  81. $(".select_ordersource").html(temp);
  82. $(".content").click(function () {
  83. var line = $(this).text();
  84. var value = $(this).attr('org_id');
  85. $("#" + select_id).val(line);
  86. $("#" + select_id).attr('changeid', value);
  87. })
  88. }
  89. function getDark(value) {
  90. $('#' + value).addClass("get_dark");
  91. }
  92. function getLight(value) {
  93. $('#' + value).removeClass("get_dark");
  94. }
  95. function searchBtnClicked2(index, cur, timelimit, starttime, endtime, ordersource, moresearch, typelimit, ordersource_text) {
  96. if (!timelimit || !starttime || !endtime || !ordersource || !moresearch || !typelimit) {
  97. timelimit = $('#timelimit').val();
  98. starttime = $('#starttime').val();
  99. endtime = $('#endtime').val();
  100. ordersource = $('#ordersource').attr('changeid');
  101. ordersource_text = $('#ordersource').val();
  102. if (!ordersource) {
  103. ordersource = -1;
  104. }
  105. moresearch = $('#moresearch').val();
  106. if (!moresearch) {
  107. moresearch = "";
  108. }
  109. typelimit = $('#typelimit').val();
  110. }
  111. var url =
  112. "./st-xm/Model/des/export.php?tt=" + getDateTime(4) +
  113. "&timelimit=" + timelimit +
  114. "&starttime=" + starttime +
  115. "&endtime=" + endtime +
  116. "&ordersource=" + ordersource +
  117. "&moresearch=" + moresearch +
  118. "&typelimit=" + typelimit +
  119. "&orderstatus=" + index;
  120. var listURL = url;
  121. // 跳转前将URL编码
  122. listURL = encodeURI(listURL);
  123. window.location.href = listURL;
  124. }
  125. //查询按钮
  126. function searchBtnClicked(index, cur, timelimit, starttime, endtime, ordersource, moresearch, typelimit, ordersource_text) {
  127. $("#minus").children('span').removeClass("btn-primary");
  128. $("#minus").children('span').addClass("btn-default");
  129. $("#add" + index).removeClass("btn-default");
  130. $("#add" + index).addClass("btn-primary");
  131. if (!cur) {
  132. cur = 1;
  133. }
  134. if (!timelimit || !starttime || !endtime || !ordersource || !moresearch || !typelimit) {
  135. timelimit = $('#timelimit').val();
  136. starttime = $('#starttime').val();
  137. endtime = $('#endtime').val();
  138. ordersource = $('#ordersource').attr('changeid');
  139. ordersource_text = $('#ordersource').val();
  140. if (!ordersource) {
  141. ordersource = -1;
  142. }
  143. moresearch = $('#moresearch').val();
  144. if (!moresearch) {
  145. moresearch = "";
  146. }
  147. typelimit = $('#typelimit').val();
  148. }
  149. $.ajax({
  150. url: './st-xm/control.php', //请求地址
  151. type: "post", //请求方式
  152. //data: data, //请求参数
  153. data: {
  154. type: "des_orderlist",
  155. timelimit: timelimit,
  156. starttime: starttime,
  157. endtime: endtime,
  158. ordersource: ordersource,
  159. moresearch: moresearch,
  160. typelimit: typelimit,
  161. currpage: cur,
  162. pagesize: pagesize,
  163. orderstatus: index
  164. },
  165. async: false,
  166. dataType: "json",
  167. success: function (data) {
  168. console.log(data);
  169. if (data.code == 0) {
  170. var count_list = data['count_list'];
  171. var st_145 = count_list['will'];
  172. var st_146 = count_list['pay'];
  173. var st_147 = count_list['over'];
  174. var st_148 = count_list['cancel'];
  175. var orderAll = parseInt(st_145) + parseInt(st_146) + parseInt(st_147) + parseInt(st_148);
  176. $('#orderAll').text(orderAll);
  177. $('#will').text(st_145);
  178. $('#pay').text(st_146);
  179. $('#over').text(st_147);
  180. $('#cancel').text(st_148);
  181. var sum = data.totalTickets;
  182. var tag = "page";
  183. var sendurl = './des_order_list.html?timelimit=' + timelimit + '&starttime=' + starttime + '&endtime=' + endtime + '&ordersource=' + ordersource + '&moresearch=' + moresearch + '&typelimit=' + typelimit + '&ordersource_text=' + ordersource_text;
  184. getPager(sendurl, sum, cur, pagesize, tag, 'currpage');
  185. $('#sum').html('共' + data.list_count + '条记录');
  186. if (data.orderList.length > 0) {
  187. var temp = '';
  188. $("#tableOrder").html('');
  189. for (var i = 0; i < data.orderList.length; i++) {
  190. var ifzhouzhuang = data.orderList[i].ifzhouzhuang;
  191. var str = "";
  192. if (ifzhouzhuang == 0) {
  193. str = '-';
  194. } else if (ifzhouzhuang == 1) {
  195. str = '<a onclick = "refundTicket(' + data.orderList[i].order_id + ',\'' + data.orderList[i].product_info + '\')">退票</a>';
  196. }
  197. var orderType = '<span class="label label-primary">单</span>';
  198. if (data.orderList[i].order_title_id > 0) {
  199. orderType = '<span class="label btn-success">组</span>';
  200. }
  201. var top_org_name_show = data.orderList[i].top_org_name ==null?'-':data.orderList[i].top_org_name;
  202. temp += '<tr class="list_info" id="list_info' + i + '">'
  203. + '<td class="list_middle">' + orderType + data.orderList[i].order_id + '</td>'
  204. + '<td class="list_middle">' + data.orderList[i].create_user_name + '</td>'
  205. + '<td class="list_middle">' + data.orderList[i].create_time + '</td>'
  206. + '<td class="list_middle">' + data.orderList[i].org_name + '<br />' + data.orderList[i].outside_order_no + '</td>'
  207. // + '<td class="list_middle">'+data.orderList[i].outside_order_no+'</td>'
  208. + '<td class="list_middle">' + data.orderList[i].product_info + '</td>'
  209. + '<td class="list_middle">' + top_org_name_show + '</td>'
  210. + '<td class="list_middle">' + data.orderList[i].order_pay + '</td>'
  211. + '<td class="list_middle">' + data.orderList[i].run_time + '</td>'
  212. + '<td class="list_middle">' + data.orderList[i].customer_info + '</td>'
  213. + '<td class="list_middle">' + data.orderList[i].order_status + '</td>'
  214. + '<td class="list_middle">' + data.orderList[i].order_pay_type + '</td>'
  215. + '<td class="list_middle" onclick="change_customer_memo( ' + data.orderList[i].order_id + ',\'' + data.orderList[i].customer_memo + '\' )">' + data.orderList[i].customer_memo + '</td>'
  216. + '<td class="list_middle" id="caozuo' + data.orderList[i].order_id + '">' + str + '</td>'
  217. + '</tr>'
  218. }
  219. } else {
  220. $("#tableOrder").html('');
  221. }
  222. $("#tableOrder").html(temp);
  223. } else {
  224. $("#tableOrder").html('');
  225. $('#sum').html('共' + data.list_count + '条记录');
  226. var sum = 0;
  227. var tag = "page";
  228. var sendurl = './des_order_list.html?timelimit=' + timelimit + '&starttime=' + starttime + '&endtime=' + endtime + '&ordersource=' + ordersource + '&moresearch=' + moresearch + '&typelimit=' + typelimit + '&ordersource_text=' + ordersource_text;
  229. getPager(sendurl, sum, cur, pagesize, tag, 'currpage');
  230. }
  231. },
  232. error: function (data) {
  233. }
  234. });
  235. if (cur != 1) {
  236. var cur = cur;
  237. timelimit = getPar('timelimit');
  238. $('#timelimit').val(timelimit);
  239. var starttime = getPar('starttime');
  240. $('#starttime').val(starttime);
  241. var endtime = getPar('endtime');
  242. $('#endtime').val(endtime);
  243. var ordersource = getPar('ordersource');
  244. $('#ordersource').attr('changeid', ordersource);
  245. var ordersource_text = getPar('ordersource_text');
  246. $('#ordersource').val(ordersource_text);
  247. var moresearch = getPar('moresearch');
  248. $('#moresearch').val(moresearch);
  249. var typelimit = getPar('typelimit');
  250. $('#typelimit').val(typelimit);
  251. }
  252. }
  253. function refundTicket(order_id, ifzhouzhuang) {
  254. var result = confirm("是否决定退票?");
  255. if (result == true) {
  256. //判断是否是周庄门票
  257. if (ifzhouzhuang.indexOf("周庄门票") != -1) {
  258. $.ajax({
  259. url: './zz-fx/Model/cancelzhoutickets.php', //请求地址
  260. type: "post", //请求方式
  261. data: {
  262. order_id: order_id,
  263. method: 1
  264. },
  265. async: true,
  266. dataType: "json",
  267. success: function (data) {
  268. console.log(data);
  269. if (data.code == 0) {
  270. alert('退票成功!');
  271. $('#caozuo' + order_id).html('-');
  272. } else {
  273. alert(data.info);
  274. }
  275. }
  276. });
  277. } else {
  278. $.ajax({
  279. url: './zz-fx/Model/cancelnormaltickets.php',//请求地址
  280. type: "post", //请求方式
  281. data: {
  282. order_id: order_id,
  283. action: 'cancel_ticket_order'
  284. },
  285. xhrFields: {
  286. withCredentials: true
  287. },
  288. crossDomain: true,
  289. async: true,
  290. dataType: "json",
  291. success: function (data) {
  292. if (data.code == 0) {
  293. alert('退票成功!');
  294. $('#caozuo' + order_id).html('-');
  295. $('#caozuo' + order_id).prev().prev().prev().html('已取消');
  296. } else {
  297. alert(data.info);
  298. }
  299. }
  300. });
  301. }
  302. }
  303. else {
  304. return;
  305. }
  306. }
  307. function change_customer_memo(order_id, customer_memo) {
  308. swal({
  309. title: '请输入备注',
  310. input: 'textarea',
  311. inputValue: customer_memo,
  312. showCancelButton: true,
  313. cancelButtonText: '返 回',
  314. confirmButtonText: '确 定',
  315. showLoaderOnConfirm: true,
  316. allowOutsideClick: false
  317. }).then(function (email) {
  318. change_memo(order_id, email);
  319. })
  320. function change_memo(order_id, new_memo) {
  321. $.ajax({
  322. url: './st-xm/control.php',
  323. type: "post",
  324. data: {
  325. order_id: order_id,
  326. new_memo: new_memo,
  327. type: "des_changememo"
  328. },
  329. dataType: "json",
  330. success: function (data) {
  331. if (data.code == 0) {
  332. swal({
  333. title: '修改备注成功',
  334. type: 'success',
  335. timer: 20000,
  336. confirmButtonText: 'OK'
  337. }).then(
  338. function () {
  339. location.replace(location.href);
  340. },
  341. function (dismiss) {
  342. location.replace(location.href);
  343. }
  344. )
  345. } else {
  346. swal(
  347. '修改备注失败',
  348. ' ',
  349. 'error'
  350. );
  351. return;
  352. }
  353. },
  354. fail: function (data) {
  355. swal(
  356. '修改备注失败',
  357. ' ',
  358. 'error'
  359. );
  360. return;
  361. }
  362. });
  363. }
  364. }
  365. function getDateTime(nTypeFlag) {
  366. var tNowTime = new Date();
  367. var myYear = ';' + tNowTime.getFullYear() + ';';
  368. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  369. var myDay = ';' + tNowTime.getDate() + ';';
  370. var myHour = ';' + tNowTime.getHours() + ';';
  371. var myMinu = ';' + tNowTime.getMinutes() + ';';
  372. var mySecond = ';' + tNowTime.getSeconds() + ';';
  373. if (myMonth.length < 4) myMonth = '0' + myMonth;
  374. if (myDay.length < 4) myDay = '0' + myDay;
  375. if (myHour.length < 4) myHour = '0' + myHour;
  376. if (myMinu.length < 4) myMinu = '0' + myMinu;
  377. if (mySecond.length < 4) mySecond = '0' + mySecond;
  378. var cNewTimeStr;
  379. //alert(tNowTime);
  380. switch (nTypeFlag + 1 - 1) {
  381. case 0:
  382. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  383. break;
  384. case 1:
  385. cNewTimeStr = myYear + myMonth + myDay;
  386. break;
  387. case 2:
  388. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  389. break;
  390. case 3:
  391. cNewTimeStr = myHour + myMinu + mySecond;
  392. break;
  393. case 4:
  394. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  395. break;
  396. case 5:
  397. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  398. break;
  399. case 6:
  400. cNewTimeStr = myYear;
  401. break;
  402. case 7:
  403. cNewTimeStr = myYear + '-' + myMonth;
  404. break;
  405. case 8: //得到上一个月的今天
  406. var date = getDateTime(0);
  407. var arr = date.split('-');
  408. var year = arr[0]; //获取当前日期的年份
  409. var month = arr[1]; //获取当前日期的月份
  410. var day = arr[2]; //获取当前日期的日
  411. var days = new Date(year, month, 0);
  412. days = days.getDate(); //获取当前日期中月的天数
  413. var year2 = year;
  414. var month2 = parseInt(month) - 1;
  415. if (month2 == 0) {
  416. year2 = parseInt(year2) - 1;
  417. month2 = 12;
  418. }
  419. var day2 = day;
  420. var days2 = new Date(year2, month2, 0);
  421. days2 = days2.getDate();
  422. if (day2 > days2) {
  423. day2 = days2;
  424. }
  425. if (month2 < 10) {
  426. month2 = '0' + month2;
  427. }
  428. cNewTimeStr = year2 + '-' + month2 + '-' + day2;
  429. break;
  430. case 9: //得到下一个月的今天
  431. var date = getDateTime(0);
  432. var arr = date.split('-');
  433. var year = arr[0]; //获取当前日期的年份
  434. var month = arr[1]; //获取当前日期的月份
  435. var day = arr[2]; //获取当前日期的日
  436. var days = new Date(year, month, 0);
  437. days = days.getDate(); //获取当前日期中的月的天数
  438. var year2 = year;
  439. var month2 = parseInt(month) + 1;
  440. if (month2 == 13) {
  441. year2 = parseInt(year2) + 1;
  442. month2 = 1;
  443. }
  444. var day2 = day;
  445. var days2 = new Date(year2, month2, 0);
  446. days2 = days2.getDate();
  447. if (day2 > days2) {
  448. day2 = days2;
  449. }
  450. if (month2 < 10) {
  451. month2 = '0' + month2;
  452. }
  453. var t2 = year2 + '-' + month2 + '-' + day2;
  454. return t2;
  455. break;
  456. case 12: //本周起始日期
  457. return getBeforeDate(7);
  458. function getBeforeDate(n) {
  459. var n = n;
  460. var d = new Date();
  461. var year = d.getFullYear();
  462. var mon = d.getMonth() + 1;
  463. var day = d.getDate();
  464. if (day <= n) {
  465. if (mon > 1) {
  466. mon = mon - 1;
  467. }
  468. else {
  469. year = year - 1;
  470. mon = 12;
  471. }
  472. }
  473. d.setDate(d.getDate() - n);
  474. year = d.getFullYear();
  475. mon = d.getMonth() + 1;
  476. day = d.getDate();
  477. s = year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day);
  478. return s;
  479. }
  480. break;
  481. case 13: //本周结束日期
  482. return getWeekEndDate()
  483. function getWeekEndDate() {
  484. var now = new Date(); //当前日期
  485. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  486. var nowDay = now.getDate(); //当前日
  487. var nowMonth = now.getMonth(); //当前月
  488. var nowYear = now.getYear(); //当前年
  489. nowYear += (nowYear < 2000) ? 1900 : 0; //
  490. var lastMonthDate = new Date(); //上月日期
  491. lastMonthDate.setDate(1);
  492. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  493. var lastYear = lastMonthDate.getYear();
  494. var lastMonth = lastMonthDate.getMonth();
  495. var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
  496. return formatDate(weekEndDate);
  497. }
  498. break;
  499. default:
  500. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  501. break;
  502. }
  503. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  504. return cNewTimeStr;
  505. }
  506. function getPar(par) {
  507. //获取当前URL
  508. var local_url = document.location.href;
  509. local_url = decodeURI(local_url);
  510. //获取要取得的get参数位置
  511. var get = local_url.indexOf(par + "=");
  512. if (get == -1) {
  513. return "";
  514. }
  515. //截取字符串
  516. var get_par = local_url.slice(par.length + get + 1);
  517. //判断截取后的字符串是否还有其他get参数
  518. var nextPar = get_par.indexOf("&");
  519. if (nextPar != -1) {
  520. get_par = get_par.slice(0, nextPar);
  521. }
  522. return get_par;
  523. }
  524. //获取当前时间
  525. function CurrentTime() {
  526. var now = new Date();
  527. var year = now.getFullYear(); //年
  528. var month = now.getMonth() + 1; //月
  529. var day = now.getDate(); //日
  530. var hh = now.getHours(); //时
  531. var mm = now.getMinutes(); //分
  532. var ss = now.getSeconds(); //秒
  533. var clock = year + "-";
  534. if (month < 10)
  535. clock += "0";
  536. clock += month + "-";
  537. if (day < 10)
  538. clock += "0";
  539. clock += day + " ";
  540. if (hh < 10)
  541. clock += "0";
  542. clock += hh + ":";
  543. if (mm < 10) clock += '0';
  544. clock += mm + ":";
  545. if (ss < 10) clock += '0';
  546. clock += ss;
  547. return (clock);
  548. }
  549. function getList(index) {
  550. $("#minus").children().children().removeClass("addbackground");
  551. $("#add" + index).addClass("addbackground");
  552. click_type_id = index;
  553. var timelimit = $('#timelimit').val(); //时间类型
  554. var starttime = $('#starttime').val(); //开始时间
  555. var endtime = $('#endtime').val(); //结束时间
  556. //var ordersource=$('#ordersource').val();//订单渠道
  557. var ordersource = order_from_id; //订单渠道
  558. order_from_id = ordersource;
  559. var paystatus = $('#paystatus').val(); //支付状态
  560. /*以下三个条件暂时隐藏,''代替传入参数
  561. var billingstatus=document.getElementById("billingstatus").value;
  562. var mealbounce=document.getElementById("mealbounce").value;
  563. var refund=document.getElementById("refund").value;
  564. */
  565. var billingstatus = '';
  566. var mealbounce = '';
  567. var refund = '';
  568. var moresearch = document.getElementById("moresearch").value;
  569. //2016-07-15新增参数
  570. var start_area = $('#start_area').val();
  571. var end_area = $('#end_area').val();
  572. var line = $('#line').val();
  573. var tnowtime = getDateTime(4);
  574. var myURL =
  575. "./st-xm/Api/order_list.php?tt=" + tnowtime +
  576. "&timelimit=" + timelimit +
  577. "&starttime=" + starttime +
  578. "&endtime=" + endtime +
  579. "&ordersource=" + ordersource +
  580. "&orderstatus=" + index +
  581. "&will=" + will +
  582. "&over=" + over +
  583. "&pay=" + pay +
  584. "&cancel=" + cancel +
  585. "&paystatus=" + paystatus +
  586. "&currpage=1" +
  587. "&pagesize=" + pagesize;
  588. var myURL2 = "./des_order_list.html?tt=" + tnowtime +
  589. "&timelimit=" + timelimit +
  590. "&starttime=" + starttime +
  591. "&endtime=" + endtime +
  592. "&ordersource=" + ordersource +
  593. "&orderstatus=" + index +
  594. "&paystatus=" + paystatus +
  595. "&billingstatus=" + billingstatus +
  596. "&mealbounce=" + mealbounce +
  597. "&refund=" + refund +
  598. "&moresearch=" + moresearch +
  599. "&start_area=" + start_area +
  600. "&end_area=" + end_area +
  601. "&line=" + line
  602. // +"&currpage="+currpage
  603. +
  604. "&pagesize=" + pagesize;
  605. method(myURL, myURL2);
  606. $('#ordersource').val(order_from_id);
  607. }