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.
 
 
 
 

175 rivejä
7.9 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: admin
  5. * Date: 2017/5/23
  6. * Time: 11:21
  7. */
  8. class reparations extends base
  9. {
  10. //获取价格列表
  11. public function getList($post)
  12. {
  13. /**==========接收参数============**/
  14. $param = array(
  15. 'date_type' => empty($post['date_type']) ? '1' : $post['date_type'],//时间类型 1、创建时间 2、赔款时间
  16. 'start_date' => empty($post['start_date']) ? '' : $post['start_date'],//开始时间
  17. 'end_date' => empty($post['end_date']) ? '' : $post['end_date'],//接收时间
  18. 'org_id' => empty($post['org_id']) ? '' : $post['org_id'],//渠道商ID
  19. 'more_search' => empty($post['more_search ']) ? '' : $post['more_search '],//更多查询条件
  20. 'current_page' => empty($post['current_page']) ? '1' : $post['current_page'],//当前页
  21. 'page_size' => empty($post['page_size']) ? '10' : $post['page_size'],//每页展示条数
  22. );
  23. $where = array();
  24. $dateCol = $param['date_type'] == 1 ? 'a.create_time' : 'a.date';
  25. if (!empty($param['start_date'])) {
  26. $where[] = " {$dateCol} >= {$param['start_date']} ";
  27. }
  28. if (!empty($param['end_date'])) {
  29. $where[] = " {$dateCol} < date_add('{$param['end_date']}', INTERVAL 1 day) ";
  30. }
  31. if (!empty($param['org_id'])) {
  32. $where[] = " b.OUTSIDE_SALE_ORG_ID = {$param['org_id']} ";
  33. }
  34. if (!empty($param['more_search'])) {
  35. $where[] = " (a.order_id like '%{$param['more_search']}%' or b.PARENT_PROD_NAME like '%{$param['more_search']}%') ";
  36. }
  37. $whereStr = ' ';
  38. if (count($where)) {
  39. $whereStr .= 'where ' . implode(' and ', $where);
  40. }
  41. if ($param['current_page'] == 1) {
  42. $sql = "SELECT count(1) cnt
  43. FROM order_finance_reparations a
  44. JOIN order_main b ON a.order_id = b.ORDER_ID
  45. JOIN base_supplier c ON b.OUTSIDE_SALE_ORG_ID = c.ID
  46. {$whereStr}";
  47. $getTotal = $this->query($sql);
  48. $data['page']['total_count'] = $getTotal[0]['cnt'];
  49. $data['page']['total_page'] = (string)ceil($getTotal[0]['cnt'] / $param['page_size']);
  50. }
  51. $sql2 = "SELECT a.date,a.order_id,c.SUPPLIER_NAME ,a.reparations,a.memo,a.create_time,a.memo_title,
  52. ifnull((SELECT CONCAT(b.PARENT_PROD_NAME, '<br />',PROD_START_STATION_RES_NAME,' - ',PROD_END_STATION_RES_NAME) from order_main WHERE PARENT_ORDER_ID = b.ORDER_ID LIMIT 1),b.PARENT_PROD_NAME )'PARENT_PROD_NAME'
  53. FROM order_finance_reparations a
  54. JOIN order_main b ON a.order_id = b.ORDER_ID
  55. JOIN base_supplier c ON b.OUTSIDE_SALE_ORG_ID = c.ID
  56. {$whereStr}
  57. ORDER BY a.create_time DESC
  58. ";
  59. $list = $this->query($sql2);
  60. $json['code'] = '0';
  61. $json['info'] = '获取列表成功';
  62. $data['order_list'] = $list;
  63. $data['page']['page_size'] = $param['page_size'];
  64. $data['page']['current_page'] = $param['current_page'];
  65. $json['data'] = $data;
  66. return $json;
  67. }
  68. //获取订单信息
  69. public function getOrderInfo($post)
  70. {
  71. $order_id = empty($post['order_id']) ? '' : $post['order_id'];
  72. if (!preg_match('/^[1-9][0-9]{0,10}$/', $order_id)) {
  73. $json['code'] = '1';
  74. $json['info'] = 'params error';
  75. return $json;
  76. }
  77. $sql = "SELECT IFNULL(b.reparations,0) 'reparations',memo_id,
  78. IFNULL(b.date,'') 'date',IFNULL(b.memo,'') 'memo',ifnull(b.memo_title, '') 'memo_title',
  79. ifnull((SELECT CONCAT(a.PARENT_PROD_NAME, '<br />',PROD_START_STATION_RES_NAME,' - ',PROD_END_STATION_RES_NAME) from order_main WHERE PARENT_ORDER_ID = b.ORDER_ID LIMIT 1),a.PARENT_PROD_NAME )'PARENT_PROD_NAME'
  80. from order_main a
  81. LEFT JOIN order_finance_reparations b on a.order_id = b.order_id
  82. where a.ORDER_ID= {$order_id}";
  83. $info = $this->query($sql);
  84. if (empty($info[0])) {
  85. $json['code'] = '1';
  86. $json['info'] = '订单不存在!请核对订单号!';
  87. return $json;
  88. }
  89. $json['code'] = '0';
  90. $json['info'] = '获取信息成功';
  91. $json['data'] = $info[0];
  92. return $json;
  93. }
  94. //设置订单的赔款
  95. public function setReparations($post)
  96. {
  97. $param = array(
  98. 'order_id' => empty($post['order_id']) ? '' : $post['order_id'],//订单ID
  99. 'reparations' => empty($post['reparations']) ? 0 : $post['reparations'],//金额
  100. 'date' => empty($post['date']) ? '' : $post['date'],//赔款日期
  101. 'memo_id' => empty($post['memo_id'])?'':$post['memo_id'],//原因ID
  102. 'memo' => empty($post['memo']) ? '' : $post['memo'],//赔款备注 原因
  103. 'memo_title' => empty($post['memo_title']) ? '' : $post['memo_title'],//赔款备注 标题
  104. );
  105. if (!preg_match('/^[1-9][0-9]{0,10}$/', $param['order_id'])) {
  106. $json['code'] = '1';
  107. $json['info'] = '参数错误,请联系开发人员!001';
  108. return $json;
  109. }
  110. if (empty($param['date']) || empty($param['reparations'])) {
  111. $json['code'] = '1';
  112. $json['info'] = '请选择赔款日期或填写赔款金额!';
  113. return $json;
  114. }
  115. $sql = "REPLACE INTO `order_finance_reparations` ( `order_id`,`reparations`,`user_id`, `memo`,`date`,`create_time`,memo_title,memo_id)
  116. VALUES
  117. ('{$param['order_id']}','{$param['reparations']}','{$_SESSION['user_id']}','{$param['memo']}'
  118. ,'{$param['date']}',now(),'{$param['memo_title']}','{$param['memo_id']}');";
  119. $this->insert($sql);
  120. $json['code'] = '0';
  121. $json['info'] = '设置订单赔款金额成功!';
  122. return $json;
  123. }
  124. //删除定的赔款记录
  125. public function del($post)
  126. {
  127. $param = array(
  128. 'order_id' => empty($post['order_id']) ? '' : $post['order_id'],//订单ID
  129. );
  130. if (!preg_match('/^[1-9][0-9]{0,10}$/', $param['order_id'])) {
  131. $json['code'] = '1';
  132. $json['info'] = '参数错误,请联系开发人员!001';
  133. return $json;
  134. }
  135. $sql = "DELETE from order_finance_reparations WHERE order_id = {$param['order_id']}";
  136. $flag = $this->edit($sql);
  137. if ($flag) {
  138. $json['code'] = '0';
  139. $json['info'] = '删除成功!';
  140. return $json;
  141. } else {
  142. $json['code'] = '0';
  143. $json['info'] = '删除失败!';
  144. return $json;
  145. }
  146. }
  147. /**
  148. * 获取原因列表
  149. */
  150. public function getMemoArr()
  151. {
  152. $return = array();
  153. $return[] = array('memo_id'=>1,'memo_title'=>'漏单','memo'=>'漏单:目前的紧急处理方案是退客人现场购票的金额。');
  154. $return[] = array('memo_id'=>2,'memo_title'=>'产品问题','memo'=>'产品问题:赔付方案需要与运营沟通。');
  155. $return[] = array('memo_id'=>3,'memo_title'=>'客人问题','memo'=>'客人问题:包括未收到短信,未找到车,未接到司机电话等。');
  156. $return[] = array('memo_id'=>4,'memo_title'=>'下错单','memo'=>'下错单:上下站点问题,时间问题。');
  157. $return[] = array('memo_id'=>5,'memo_title'=>'汽车晚点','memo'=>'汽车晚点:');
  158. $return[] = array('memo_id'=>6,'memo_title'=>'交通管制','memo'=>'交通管制:');
  159. $return[] = array('memo_id'=>7,'memo_title'=>'并班原因','memo'=>'并班原因:');
  160. $return[] = array('memo_id'=>8,'memo_title'=>'车队原因','memo'=>'车队原因:');
  161. $return[] = array('memo_id'=>9,'memo_title'=>'司机原因','memo'=>'司机原因:');
  162. $return[] = array('memo_id'=>10000,'memo_title'=>'其他','memo'=>'其他。');
  163. $json['code'] = '0';
  164. $json['info'] = '获取列表成功';
  165. $json['list'] = $return;
  166. return $json;
  167. }
  168. }