"1", "info" => "用户未登录")); exit; } //$user_id=450; //取消订单原因 if (isset($_POST['reason'])) { $reason = $_POST['reason']; $order_id = $_POST['order_id']; $clock = $_POST['clock']; // $return_data = array(); // $return_data["code"] = 1; // $return_data["info"] = $reason; $pdo_insert = conn(); $sql = "insert into order_comment(ORDER_ID,COMMENT_TXT,CREATE_TIME) VALUES ({$order_id},'{$reason}','{$clock}')"; $result = $pdo_insert->exec($sql); } if ($method == "cancelOrder") { } else { $condition = array(); $timelimit = isset($_POST['timelimit']) ? $_POST['timelimit'] : ''; $starttime = isset($_POST['starttime']) ? $_POST['starttime'] : ''; $endtime = isset($_POST['endtime']) ? $_POST['endtime'] : ''; $ordersource = isset($_POST['ordersource']) ? $_POST['ordersource'] : 0; $typelimit = isset($_POST['typelimit']) ? $_POST['typelimit'] : ''; $moresearch = isset($_POST['moresearch']) ? trim($_POST['moresearch']) : ''; $orderstatus = isset($_POST['orderstatus']) ? $_POST['orderstatus'] : 0; if ($orderstatus) { $condition[] = " a.order_status =" . $orderstatus; } if ($timelimit == 0) { empty($starttime) ? null : $condition[] = ' a.create_time >= "' . $starttime . ' 00:00:00' . '"'; //创建时间条件筛选 empty($endtime) ? null : $condition[] = ' a.create_time <= "' . $endtime . ' 23:59:01' . '"'; } elseif ($timelimit == 1) { empty($starttime) ? null : $condition[] = ' a.run_date >= "' . $starttime . '"'; // 出发时间筛选 empty($endtime) ? null : $condition[] = ' a.run_date <= "' . $endtime . ' 23:59:01' . '"'; } if ($ordersource == '-1') { } else { empty($ordersource) ? null : $condition[] = ' a.outside_sale_org_id = ' . $ordersource; } if ($typelimit == 1) { $condition[] = ' a.order_prod_type in (258,259,282,311)'; } else { empty($typelimit) ? $condition[] = ' a.order_prod_type in (258,259)' : $condition[] = ' a.order_prod_type= ' . $typelimit; } empty($moresearch) ? $condition2 = 1 : $condition2 = ' a.order_id like "%' . $moresearch . '%" or a.customer_name like "%' . $moresearch . '%" or a.customer_mobile like "%' . $moresearch . '%" or a.outside_order_no like "%' . $moresearch . '%"'; $condition = implode(' AND ', $condition); //状态筛选环境 $condition1 = array(); if ($timelimit == 0) { empty($starttime) ? null : $condition1[] = ' a.create_time >= "' . $starttime . ' 00:00:00' . '"'; //创建时间条件筛选 empty($endtime) ? null : $condition1[] = ' a.create_time <= "' . $endtime . ' 23:59:01' . '"'; } elseif ($timelimit == 1) { empty($starttime) ? null : $condition1[] = ' a.run_date >= "' . $starttime . '"'; // 出发时间筛选 empty($endtime) ? null : $condition1[] = ' a.run_date <= "' . $endtime . ' 23:59:01' . '"'; } if ($ordersource == '-1') { } else { empty($ordersource) ? null : $condition1[] = ' a.outside_sale_org_id = ' . $ordersource; } if ($typelimit == 1) { $condition1[] = ' a.order_prod_type in (258,259,282,311)'; } else { empty($typelimit) ? $condition1[] = ' a.order_prod_type in (258,259)' : $condition1[] = ' a.order_prod_type= ' . $typelimit; } //2017.3.30 筛选条件新增当前用户运营主体 $sql=''."select main_corp_id from base_user where id=$user_id limit 1"; $user_corp_id=$pdo->query($sql); $rowset = $user_corp_id->fetchAll(PDO::FETCH_ASSOC); $main_corp_id=$rowset[0]['main_corp_id']; if($main_corp_id!=0){ $sql=''."select group_concat(prod_id) as prod_arr from opera_product a where main_corp_id = $main_corp_id and parent_id=0 and cancel_flag=0"; $result=$pdo->query($sql); $rowset = $result->fetchAll(PDO::FETCH_ASSOC); $result=$rowset[0]['prod_arr']; $condition1[] = " a.prod_id in($result)"; } $condition1 = implode(' AND ', $condition1); //结束 $orderstatus = isset($_POST['orderstatus']) ? (empty($_POST['orderstatus']) ? 0 : $_POST['orderstatus']) : 0; $paystatus = isset($_POST['paystatus']) ? (empty($_POST['paystatus']) ? -1 : $_POST['paystatus']) : -1; $billingstatus = isset($_POST['billingstatus']) ? $_POST['billingstatus'] : ''; $mealbounce = isset($_POST['mealbounce']) ? $_POST['mealbounce'] : ''; $refund = isset($_POST['refund']) ? $_POST['refund'] : ''; $export = isset($_POST['export']) ? $_POST['export'] : ''; //2016-07-15新增 $start_area = isset($_POST['start_area']) ? $_POST['start_area'] : ''; $end_area = isset($_POST['end_area']) ? $_POST['end_area'] : ''; $line = isset($_POST['line']) ? $_POST['line'] : ''; //..暂未加入存储过程 $currpage = isset($_POST['currpage']) ? (empty($_POST['currpage']) ? 1 : $_POST['currpage']) : 1; $pagesize = isset($_POST['pagesize']) ? (empty($_POST['pagesize']) ? 10 : $_POST['pagesize']) : 10; $pdo = conn(); // $sql = "select count(*) as will from order_main as a where a.order_status=145 and a.PARENT_ORDER_ID=0 and a.CANCEL_FLAG=0 and " . $condition1 . "; // select count(order_id) as pay from order_main as a where a.order_status=146 and a.PARENT_ORDER_ID=0 and a.CANCEL_FLAG=0 and " . $condition1 . "; // select count(order_id) as over from order_main as a where a.order_status=147 and a.PARENT_ORDER_ID=0 and a.CANCEL_FLAG=0 and " . $condition1 . "; // select count(order_id) as cancel from order_main as a where a.order_status=148 and a.PARENT_ORDER_ID=0 and a.CANCEL_FLAG=0 and " . $condition1; // $sql = "select a.order_status, count(a.order_id) as order_num from order_main as a where a.PARENT_ORDER_ID=0 and a.CANCEL_FLAG=0 and " . $condition1 . " group by a.order_status "; $result = $pdo->query($sql); writeLog("--des_order_list:" . __LINE__ . "|" . $sql); $data_count_list = array("will" => 0, "pay" => 0, "over" => "0", "cancel" => 0); // $rowset = $result -> fetchAll(PDO::FETCH_ASSOC); $rowset = $result->fetchAll(PDO::FETCH_ASSOC); $result->closeCursor(); foreach ($rowset as $row_info) { switch ($row_info["order_status"]) { case 145: $row_index = "will"; break; case 146: $row_index = "pay"; break; case 147: $row_index = "over"; break; case 148: $row_index = "cancel"; break; default: $row_index = "will"; break; } $data_count_list[$row_index] = $row_info["order_num"]; } if ($condition2 != 1) { $condition2 = " where " . $condition2 . " AND " . $condition1; } else { $condition2 = " where " . $condition1; } $sql = "select a.order_id " . "from order_main as a " . $condition2; //echo $sql;die; $result = $pdo->query($sql); $json22 = array(); do { $rowset = $result->fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $json22 = $rowset; } } while ($result->nextRowset()); if (empty($json22)) { $data = (array("code" => "1", "info" => "此条件下没有订单", "list_count" => 0, "searchInfo" => array())); echo json_encode($data); die; } foreach ($json22 as $v) { $arr_o[] = $v['order_id']; } $arr_o = implode(',', $arr_o); $sql_org = "select org_id,org_name from base_organization "; $result_org = $pdo->query($sql_org); $org_list = $result_org->fetchAll(PDO::FETCH_ASSOC); $o_list = array(); foreach ($org_list as $v) { $o_list[$v['org_id']] = array('org_name' => $v['org_name'], 'org_id' => $v['org_id']); } //3-28新增查询退款截止日期,退款截止时间--娄梦宁 $sql = "select b.refund_limit_time,b.refund_limit_day,a.prod_name,a.order_prod_type,a.order_description,a.run_date,a.ORDER_PAY_MAIN_ID,a.order_id,a.customer_name,a.customer_mobile,a.customer_id_type,a.customer_id_no,a.order_price,a.order_status,a.create_time,a.prod_id,a.customer_memo,a.main_create_user_id,a.outside_sale_org_id,a.outside_order_no " . "from order_main as a left join opera_product as b on a.prod_id=b.prod_id " . "where a.PARENT_ORDER_ID=0 and a.CANCEL_FLAG=0 and a.order_id in (" . $arr_o . ") AND " . $condition . " order by a.create_time desc"; $result = $pdo->query($sql); if (false != $result) { $json = array(); $rowset = $result->fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $json = $rowset; } $result->closeCursor(); } if (empty($json)) { $data = (array("code" => "1", "info" => '此条件下没有订单', "list_count" => 0, "searchInfo" => array())); echo json_encode($data); die; } //获取销售渠道信息 $json_id = array(); foreach ($json as $v) { $json_id[] = $v['order_id']; $json2[] = $v['order_id']; $org[$v['order_id']] = $v['main_create_user_id']; if ($v['outside_sale_org_id'] == 0 || !isset($o_list[$v['outside_sale_org_id']])) { $v['org_name'] = 'CS平台下单'; } else { $v['org_name'] = $o_list[$v['outside_sale_org_id']]["org_name"]; } $org_name[$v['order_id']] = $v['org_name']; $outside_order_no[$v['order_id']] = $v['outside_order_no']; $order_info[$v['order_id']] = $v; //价格手机 姓名 run_time pay_time } $array_order_desc = array(); foreach ($order_info as $v) { $arr_temp = explode('|', $v['order_description']); $arr = array(); foreach ($arr_temp as $k => $v2) { if (!empty($v2)) $arr[] = explode(',', $v2); } $array_order_desc[$v['order_id']] = $arr; } //var_dump($array_order_desc);die; $sql3 = "select parent_order_id,run_date,run_time,PROD_START_STATION_AREA_NAME,PROD_START_STATION_RES_NAME,PROD_END_STATION_AREA_NAME,PROD_END_STATION_RES_NAME " . "from order_main " . "where parent_order_id in (" . implode(",", $json_id) . ")"; $result3 = $pdo->query($sql3); $rowset3 = $result3->fetchAll(PDO::FETCH_ASSOC); foreach ($rowset3 as $v) { $station[$v['parent_order_id']] = $v;//上车站下车站 详情 } //获取支付方式 $sql2 = "select a.ORDER_ID,b.PAY_TYPE_ID_1,c.TYPE_NAME from (ORDER_MAIN a left join ORDER_PAY_DETAIL b on a.ORDER_PAY_MAIN_ID=b.pay_main_id) left join dict_type c on c.id=b.PAY_TYPE_ID_1 " . " where a.ORDER_ID in (" . implode(",", $json_id) . ")"; $result2 = $pdo->query($sql2); do { $rowset2 = $result2->fetchAll(PDO::FETCH_ASSOC); if ($rowset2) { $pay_type[] = $rowset2; } } while ($result2->nextRowset()); foreach ($pay_type[0] as $v) { $pay_type_arr[$v['ORDER_ID']] = $v['TYPE_NAME']; //支付方式 } //支付状态 $sql4 = "select a.ORDER_ID,a.order_status,c.TYPE_NAME from (ORDER_MAIN a left join ORDER_PAY_DETAIL b on a.ORDER_PAY_MAIN_ID=b.pay_main_id) left join dict_type c on c.id=a.ORDER_STATUS " . " where a.ORDER_ID in (" . implode(",", $json_id) . ")"; $result4 = $pdo->query($sql4); do { $rowset4 = $result4->fetchAll(PDO::FETCH_ASSOC); if ($rowset4) { $order_sta[] = $rowset4; } } while ($result4->nextRowset()); foreach ($order_sta[0] as $v) { $order_status[$v['ORDER_ID']] = $v['TYPE_NAME']; //订单的状态 } $array_order_list = array(); //echo count($pay_type_arr),'--', count($json_id); //var_dump($array_order_desc);die; foreach ($json_id as $v) { $tic = ''; $product_info = array(); if ($order_info[$v]['order_prod_type'] == 258 || $order_info[$v]['order_prod_type'] == 259) { foreach ($array_order_desc[$v] as $v1) { $tic .= str_replace('迪士尼剧场', '', $v1[0]) . '×' . $v1[2] . ' '; if (isset($v1['ifback'])) $ifback = $v1['ifback']; } $product_info = $order_info[$v]['prod_name'] . '
' . $tic; $ifdisn = 0; } elseif ($order_info[$v]['order_prod_type'] == 282) { foreach ($array_order_desc[$v] as $v1) { $tic .= str_replace('周庄门票', '', $v1[0]) . '×' . $v1[2] . ' '; if (isset($v1['ifback'])) $ifback = $v1['ifback']; } $product_info = $order_info[$v]['prod_name'] . '' . $tic; if ($order_info[$v]['run_date'] <= date('Y-m-d', time()) || $order_info[$v]['order_status'] != 146) { $ifdisn = 0; } else { $ifdisn = 1; } } else {//不是周庄也不是迪士尼--娄梦宁 foreach ($array_order_desc[$v] as $ky=>$v1) { $num=count($array_order_desc[$v]); if($ky!=($num-1)){ $tic .=$v1[0].'×' . $v1[2] . ' '; } if (isset($v1['ifback'])) $ifback = $v1['ifback']; } $product_info = $order_info[$v]['prod_name'] . '
' . $tic; //下面这句判断是否可退票 $time1='-'.$order_info[$v]['refund_limit_day'].' day'; $time2=$order_info[$v]['run_date'].' '.$order_info[$v]['refund_limit_time']; $refund_time=strtotime($time1,strtotime($time2)); if (time()>$refund_time|| $order_info[$v]['order_status'] != 146) { $ifdisn = 0; } else { $ifdisn = 1; } } if ($product_info != array()) { $array_order_list[] = array( 'order_id' => $v, 'create_time' => $order_info[$v]['create_time'], 'org_name' => $org_name[$v], 'product_info' => $product_info, 'outside_order_no' => $outside_order_no[$v], 'ifdisney' => $ifdisn, 'ifzhouzhuang' => $ifdisn, 'run_time' => $station[$v]['run_date'] . ' ' . $station[$v]['run_time'], 'customer_info' => $order_info[$v]['customer_name'] . '
' . $order_info[$v]['customer_mobile'] . '
' . $order_info[$v]['customer_id_no'], 'order_pay' => $order_info[$v]['order_price'], 'customer_memo' => $order_info[$v]['customer_memo'], 'order_pay_type' => $pay_type_arr[$v], 'order_status' => $order_status[$v], ); } } $list_count = count($array_order_list); //echo $list_count; $sta = ($currpage - 1) * ($pagesize + 0); $array_order_list = array_slice($array_order_list, $sta, $pagesize); $data = (array("code" => "0", "info" => "", "list_count" => $list_count, "searchInfo" => $array_order_list)); if (1) { $json = array("code" => "0", "info" => ""); $json['list_count'] = $list_count; $json['totalTickets'] = $list_count; $json['totalPages'] = ceil($list_count / $pagesize); $json['currentpage'] = $currpage; $json['pagesize'] = $pagesize; $json['orderSource'] = $o_list;//销售渠道 $json['orderList'] = $array_order_list; //订单详情 $json['count_list'] = isset($data_count_list) ? $data_count_list : array(); echo json_encode($json); die; } else { echo json_encode(array("code" => "0", "info" => "", "searchInfo" => array())); } } echo json_encode(array("code" => "1", "info" => "出现一些错误", "searchInfo" => array())); die;