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.
 
 
 
 

247 lines
9.3 KiB

  1. /**
  2. * Created by luocj on 2016/12/8.
  3. */
  4. // var order_id = getPar('order_id');
  5. // var order_id = getPar('org_id');
  6. //order_id=" + order_id + "&order_status=" + order_status + "&org_id=" + org_id + "&hotel_id=" + hotel_id + "&org_name=" + getPar('org_name') + "&room_type=" + room_type1
  7. var order_id = getPar('order_id');
  8. var order_status = getPar('order_status');
  9. var org_id = getPar('org_id');
  10. var hotel_id = getPar('hotel_id');
  11. var org_name = getPar('org_name');
  12. var room_type1 = getPar('room_type');
  13. var main_tr = $('.main_tr').prop('outerHTML');
  14. var memo_tr = $('.memo_tr').prop('outerHTML');
  15. var tr1 = $('.second_style').prop('outerHTML');
  16. window.onload = function () {
  17. getOrderDetail();
  18. getUpStatus();
  19. downBookingRecord();
  20. toOrderLog()
  21. };
  22. //获取订单详情
  23. function getOrderDetail() {
  24. if (order_id) {
  25. $.ajax({
  26. url: base_api,
  27. type: 'post',
  28. dataType: 'json',
  29. data: {
  30. order_id: order_id,
  31. type: 'order_HotelOrderDetail'
  32. },
  33. success: function (res_data) {
  34. ZZLog(res_data);
  35. if (res_data['order_id']) {
  36. setMainInfo(res_data);
  37. } else {
  38. return;
  39. }
  40. },
  41. error: function (e) {
  42. ZZLog(e);
  43. }
  44. })
  45. }
  46. }
  47. function setMainInfo(data) {
  48. $('#order_id').text('订单号:' + data['order_id']);
  49. $('#order_status').text(data['order_status_name']);
  50. if (data['order_confirm_code'] != null) {
  51. $('#make_sure_num').text('酒店确认号:' + data['order_confirm_code']);
  52. }
  53. $('#hotel_name').text(data['hotel_name']);
  54. $('#product_name').text(data['room_name']);
  55. $('#org_name_down').text(data['org_name']);
  56. $('#org_name').text('订单渠道:' + data['org_name']);
  57. $('#start_date').text(data['start_date']);
  58. $('#end_date').text(data['end_date']);
  59. $('#org_num').text(data['org_num']);
  60. $('#customer_name').text(data['customer_name']);
  61. $('#phone').text(data['customer_mobile']);
  62. //替换主表
  63. var sumHTML = '';
  64. for (var i = 0, m = data['one_day'].length; i < m; i++) {
  65. var dict = data['one_day'][i];
  66. var HTML = main_tr;
  67. HTML = HTML.replace('[入住日期]', dict['start_date']);
  68. HTML = HTML.replace('[数量]', dict['count']);
  69. HTML = HTML.replace('[结算价]', parseFloat(dict['order_price'] / dict['count']).toFixed(2));
  70. HTML = HTML.replace('[佣金]', parseFloat(dict['commission']).toFixed(2));
  71. HTML = HTML.replace('[结算价总额]', parseFloat(dict['order_price']).toFixed(2));
  72. HTML = HTML.replace('[销售利润]', parseFloat(dict['profit_value']).toFixed(2));
  73. sumHTML += HTML;
  74. }
  75. $('#sum_price').text(data['all_price']);
  76. $('#sum_profit').text(data['all_profit']);
  77. $('#make_order_list').html(sumHTML);
  78. $('#main_table').show();
  79. //替换备注
  80. if (data['memo'].length>0){
  81. var sumDownHTML = '';
  82. for (var j = 0, n = data['memo'].length; j < n; j++) {
  83. var dict1 = data['memo'][j];
  84. var HTML1 = memo_tr;
  85. if (dict1['memo_type'] == 0) {
  86. HTML1 = HTML1.replace('[备注类型]', '公共备注');
  87. } else {
  88. HTML1 = HTML1.replace('[备注类型]', '内部备注');
  89. }
  90. HTML1 = HTML1.replace('[备注内容]', dict1['memo_info']);
  91. if (dict1['user_name'] != '') {
  92. HTML1 = HTML1.replace('[备注人]', dict1['user_name']);
  93. } else {
  94. HTML1 = HTML1.replace('[备注人]', '');
  95. }
  96. HTML1 = HTML1.replace('[备注时间]', getLocalTime(dict1['time']));
  97. sumDownHTML += HTML1;
  98. }
  99. $('#memo_body').html(sumDownHTML);
  100. $('.note').show();
  101. }
  102. var days = data.one_day.length;
  103. $('#datediff').html('共 ' + days + ' 晚');
  104. }
  105. //获取上方状态栏
  106. function getUpStatus() {
  107. if (order_id) {
  108. $.ajax({
  109. url: base_api,
  110. type: 'post',
  111. dataType: 'json',
  112. data: {
  113. order_id: order_id,
  114. type: 'order_ModifyHTOrder',
  115. op: 'order_status'
  116. },
  117. success: function (res_data) {
  118. ZZLog(res_data);
  119. if (res_data['order_status'].length>0){
  120. for (var i = 0, m = res_data['order_status'].length;i<m; i++) {
  121. var dict = res_data['order_status'][i];
  122. var temp_date = dict['create_time'].split(" ");
  123. var date = temp_date[0];
  124. var time = temp_date[1];
  125. if (dict['order_status_name'] == "待支付") {
  126. $('li[data-target="#step1"]').addClass('active');
  127. $('li[data-target="#step2"]').addClass('active');
  128. $('#create_date').text(date);
  129. $('#create_time').text(time);
  130. $('#pay_date').text(date);
  131. $('#pay_time').text(time);
  132. } else if (dict['order_status_name'] == "待发单") {
  133. $('li[data-target="#step1"]').addClass('active');
  134. $('li[data-target="#step2"]').addClass('active');
  135. $('#create_date').text(date);
  136. $('#create_time').text(time);
  137. $('#pay_date').text(date);
  138. $('#pay_time').text(time);
  139. } else if (dict['order_status_name'] == "待确认") {
  140. $('li[data-target="#step3"]').addClass('active');
  141. $('#send_date').text(date);
  142. $('#send_time').text(time);
  143. } else if (dict['order_status_name'] == "已安排") {
  144. $('li[data-target="#step4"]').addClass('active');
  145. $('#arr_date').text(date);
  146. $('#arr_time').text(time);
  147. } else if (dict['order_status_name'] == "已完成") {
  148. $('li[data-target="#step5"]').addClass('active');
  149. $('#finish_date').text(date);
  150. $('#finish_time').text(time);
  151. } else {
  152. }
  153. }
  154. }
  155. },
  156. error: function (e) {
  157. ZZLog(e);
  158. }
  159. })
  160. }
  161. }
  162. //点击下载附件
  163. function downBookingRecord() {
  164. $('#down_record').on('click', function () {
  165. window.location.href = "/zz-jd/st-ht/HTcontrol.php?type=order_ModifyHTOrder&op=export&order_id=" + order_id;
  166. })
  167. }
  168. //隐藏弹窗
  169. function hideDiv() {
  170. $('.main_style').hide();
  171. }
  172. function toOrderLog() {
  173. $('#log').on('click', function () {
  174. window.location.href = "./hotel_detail_log.html?order_id=" + order_id + "&order_status=" + order_status + "&org_id=" + org_id + "&hotel_id=" + hotel_id + "&org_name=" + getPar('org_name') + "&room_type=" + room_type1;
  175. })
  176. }
  177. //时间戳转换函数
  178. function getLocalTime(nS) {
  179. return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
  180. }
  181. //短信
  182. function getMessage() {
  183. //var url = base_api +"?type=hotel_HotelOrderList&op=getmessage&order_id="+order_id;
  184. var param = {
  185. type: 'order_HotelOrderList',
  186. op: 'getmessage',
  187. order_id: order_id
  188. };
  189. ZZLog(param);
  190. $.ajax({
  191. url: base_api,
  192. type: "post",
  193. dataType: "json",
  194. data: param,
  195. success: function (res_data) {
  196. ZZLog(res_data);
  197. var HTML = tr1;
  198. var sumHTML = '';
  199. $('#send_message').text('短信通知:' + res_data['count']['count(order_id)'] + '条')
  200. for (var i = 0; i < res_data['message'].length; i++) {
  201. HTML = tr1;
  202. var dict = res_data['message'][i]['send_message'];
  203. HTML = HTML.replace('[短信内容]', dict);
  204. HTML = HTML.replace('[内容]', dict);
  205. sumHTML += HTML;
  206. }
  207. $('.second_style').html(sumHTML);
  208. $('.resend_message').on('click', function () {
  209. var messsage_info = $(this).attr('data-MSinfo');
  210. var phone = $('#phone').val();
  211. var param = {
  212. message: messsage_info,
  213. mobile: phone,
  214. op: 'messageAgain',
  215. type: 'order_HotelOrderList'
  216. };
  217. ZZLog(param);
  218. $.ajax({
  219. url: base_api,
  220. type: 'post',
  221. dataType: 'json',
  222. data: param,
  223. success: function (res_data) {
  224. ZZLog(res_data);
  225. alert('短信已发送');
  226. },
  227. error: function (e) {
  228. ZZLog(e)
  229. }
  230. })
  231. })
  232. },
  233. error: function (e) {
  234. ZZLog('Ajax_error');
  235. ZZLog(e);
  236. }
  237. })
  238. }
  239. function showMessage() {
  240. $('#send_message').on('click', function () {
  241. $('.main_style').show();
  242. })
  243. }