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.
 
 
 
 

97 rivejä
4.2 KiB

  1. <?php
  2. require_once 'dictionary.php';
  3. header("Access-Control-Allow-Origin:*");
  4. //获取AJAX数据
  5. $post = $_POST;
  6. $start_time = $post['start_time'];
  7. $end_time = $post['end_time'];
  8. $money = $post['money'];
  9. $channel = $post['channel'];
  10. $keywords = $post['keywords'];
  11. $cur = $post['cur'];
  12. $apply_id = $post['id'];
  13. $sqlWhere = array();
  14. ($start_time=='')? null : $sqlWhere[] = " a.CREATE_TIME > '$start_time'";
  15. ($start_time=='')? null : $sqlWhere[] = " a.CREATE_TIME > '$start_time'";
  16. ($end_time=='')? null : $sqlWhere[] = " a.CREATE_TIME < '$end_time 23:59:59'";
  17. ($money==-1)? null : $sqlWhere[] = " a.ORDER_PAY_STATUS = $money";
  18. empty($keywords)? null : $sqlWhere[] = " $sale_shop[$channel] like '%$keywords%'";
  19. if(count($sqlWhere) == 0){
  20. $sql_txt = "";
  21. }else{
  22. $sql_txt = " and ".implode(" and ",$sqlWhere);
  23. }
  24. $currpage = $_POST['cur'];
  25. $pagesize = $_POST['pagesize'];
  26. $num = ($currpage-1)*$pagesize;
  27. if($apply_id == -1){
  28. $sql = "select a.ID,a.CREATE_USER_ID,a.CREATE_TIME,a.SALE_ORG_ID,a.ORDER_PRICE,a.PARENT_PROD_ID,a.ORDER_PAY_STATUS,b.CREATE_USER_ID,c.CHAN_QUALITY,c.CHAN_TYPE,c.CHAN_NAME
  29. from order_main as a,order_pay_main as b,base_customer as c
  30. where a.ID = b.ORDER_ID and b.CREATE_USER_ID = c.USER_ID".$sql_txt." limit ".$num.",".$pagesize;
  31. }else{
  32. $sql = "select a.ID,a.CREATE_USER_ID,a.CREATE_TIME,a.SALE_ORG_ID,a.ORDER_PRICE,a.PARENT_PROD_ID,a.ORDER_PAY_STATUS,b.CREATE_USER_ID,c.CHAN_QUALITY,c.CHAN_TYPE,c.CHAN_NAME
  33. from order_main as a,order_pay_main as b,base_customer as c,base_apply as d
  34. where a.ID = b.ORDER_ID and b.CREATE_USER_ID = c.USER_ID and a.APPLY_ID = d.ID and a.APPLY_ID = $apply_id ".$sql_txt." order by a.ID desc limit ".$num.",".$pagesize;
  35. }
  36. $result=$pdo->query($sql);
  37. if($result){
  38. $list=$result->fetchAll(PDO::FETCH_ASSOC);
  39. $code = 0;
  40. $info = 'success';
  41. $massge = '成功';
  42. foreach ($list as $key => $value) {
  43. foreach($value as $kk => $vv){
  44. if(array_key_exists($kk,$coutomer)){
  45. $list[$key][$kk] = $coutomer[$kk][$vv];
  46. }
  47. }
  48. $sql = "select a.ID,b.TYPE_NAME from order_pay_detail as a,dict_type as b where a.PAY_TYPE_ID_1 = b.ID and a.ID = '$value[ID]'";
  49. $result=$pdo->query($sql);
  50. $arr = $result->fetchAll(PDO::FETCH_ASSOC);
  51. $list[$key]['TYPE_NAME'] = $arr[0]['TYPE_NAME'];
  52. $sql = "select COMMISSION_REE from order_commission where ORDER_ID = '$value[ID]'";
  53. $result=$pdo->query($sql);
  54. $arr1 = $result->fetchAll(PDO::FETCH_ASSOC);
  55. $list[$key]['RECE_REE'] = $value['ORDER_PRICE'] - $arr1[0]['COMMISSION_REE'];
  56. if($value['ORDER_PAY_STATUS'] == 1){
  57. $list[$key]['COMMISSION_REE'] = $arr1[0]['COMMISSION_REE'];
  58. $list[$key]['ORDER_PAY_STATUS'] = '未结';
  59. $list[$key]['ORDER_PAY_ID'] = 1;
  60. }else{
  61. $list[$key]['COMMISSION_REE'] = '-';
  62. $list[$key]['ORDER_PAY_STATUS'] = '已结';
  63. $list[$key]['ORDER_PAY_ID'] = 0;
  64. }
  65. }
  66. if($apply_id == -1){
  67. $sql = "select count(*) as totalNum from order_main as a,order_pay_main as b,base_customer as c
  68. where a.ID = b.ORDER_ID and b.CREATE_USER_ID = c.USER_ID ".$sql_txt;
  69. }else{
  70. $sql = "select count(*) as totalNum from order_main as a,order_pay_main as b,base_customer as c,base_apply as d
  71. where a.ID = b.ORDER_ID and b.CREATE_USER_ID = c.USER_ID and a.APPLY_ID = d.ID and a.APPLY_ID = $apply_id ".$sql_txt;
  72. }
  73. $result=$pdo->query($sql);
  74. $totalNum = $result->fetchAll(PDO::FETCH_ASSOC);
  75. $totalNum = $totalNum[0]['totalNum'];
  76. }else{
  77. $code = -1;
  78. $info = 'fail';
  79. $massge = '失败';
  80. $totalNum = 0;
  81. $list = '';
  82. }
  83. $json['code'] = $code;
  84. $json['info'] = $info;
  85. $json['massge'] = $massge;
  86. $json['totalNum'] = $totalNum;
  87. $json['list'] = $list;
  88. echo json_encode($json);
  89. ?>