|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- require_once 'dictionary.php';
- header("Access-Control-Allow-Origin:*");
- //获取AJAX数据
- $post = $_POST;
- $start_time = $post['start_time'];
- $end_time = $post['end_time'];
- $money = $post['money'];
- $channel = $post['channel'];
- $keywords = $post['keywords'];
- $cur = $post['cur'];
- $apply_id = $post['id'];
- $sqlWhere = array();
- ($start_time=='')? null : $sqlWhere[] = " a.CREATE_TIME > '$start_time'";
- ($start_time=='')? null : $sqlWhere[] = " a.CREATE_TIME > '$start_time'";
- ($end_time=='')? null : $sqlWhere[] = " a.CREATE_TIME < '$end_time 23:59:59'";
- ($money==-1)? null : $sqlWhere[] = " a.ORDER_PAY_STATUS = $money";
- empty($keywords)? null : $sqlWhere[] = " $sale_shop[$channel] like '%$keywords%'";
-
- if(count($sqlWhere) == 0){
- $sql_txt = "";
- }else{
- $sql_txt = " and ".implode(" and ",$sqlWhere);
- }
-
-
- $currpage = $_POST['cur'];
- $pagesize = $_POST['pagesize'];
- $num = ($currpage-1)*$pagesize;
-
- if($apply_id == -1){
- $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
- from order_main as a,order_pay_main as b,base_customer as c
- where a.ID = b.ORDER_ID and b.CREATE_USER_ID = c.USER_ID".$sql_txt." limit ".$num.",".$pagesize;
- }else{
- $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
- from order_main as a,order_pay_main as b,base_customer as c,base_apply as d
- 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;
- }
-
- $result=$pdo->query($sql);
- if($result){
- $list=$result->fetchAll(PDO::FETCH_ASSOC);
- $code = 0;
- $info = 'success';
- $massge = '成功';
- foreach ($list as $key => $value) {
- foreach($value as $kk => $vv){
- if(array_key_exists($kk,$coutomer)){
- $list[$key][$kk] = $coutomer[$kk][$vv];
- }
- }
- $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]'";
- $result=$pdo->query($sql);
- $arr = $result->fetchAll(PDO::FETCH_ASSOC);
- $list[$key]['TYPE_NAME'] = $arr[0]['TYPE_NAME'];
- $sql = "select COMMISSION_REE from order_commission where ORDER_ID = '$value[ID]'";
- $result=$pdo->query($sql);
- $arr1 = $result->fetchAll(PDO::FETCH_ASSOC);
-
- $list[$key]['RECE_REE'] = $value['ORDER_PRICE'] - $arr1[0]['COMMISSION_REE'];
- if($value['ORDER_PAY_STATUS'] == 1){
- $list[$key]['COMMISSION_REE'] = $arr1[0]['COMMISSION_REE'];
- $list[$key]['ORDER_PAY_STATUS'] = '未结';
- $list[$key]['ORDER_PAY_ID'] = 1;
- }else{
- $list[$key]['COMMISSION_REE'] = '-';
- $list[$key]['ORDER_PAY_STATUS'] = '已结';
- $list[$key]['ORDER_PAY_ID'] = 0;
- }
- }
- if($apply_id == -1){
- $sql = "select count(*) as totalNum from order_main as a,order_pay_main as b,base_customer as c
- where a.ID = b.ORDER_ID and b.CREATE_USER_ID = c.USER_ID ".$sql_txt;
- }else{
- $sql = "select count(*) as totalNum from order_main as a,order_pay_main as b,base_customer as c,base_apply as d
- 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;
- }
- $result=$pdo->query($sql);
-
- $totalNum = $result->fetchAll(PDO::FETCH_ASSOC);
- $totalNum = $totalNum[0]['totalNum'];
- }else{
- $code = -1;
- $info = 'fail';
- $massge = '失败';
- $totalNum = 0;
- $list = '';
- }
-
- $json['code'] = $code;
- $json['info'] = $info;
- $json['massge'] = $massge;
- $json['totalNum'] = $totalNum;
- $json['list'] = $list;
- echo json_encode($json);
- ?>
|