public function getRealTime() { global $db, $res; dbc(); @$p = $_GET['page'] == "" ? 1 : $_GET['page'];//获取用户选择的页码 @$pagesize = $_GET['limit'] == "" ? 10 : $_GET['limit'];//获取用户选择的每页显示多少条数据 @$keys = $_GET['keys'];//获取用户选择的每页显示多少条数据 @$fromTime = $_GET['fromTime'];//开始时间 @$toTime = $_GET['toTime'];//结束时间 @$limit = ($p - 1) * $pagesize;//偏移量 //筛选全部记录并随前端自动分页展示; //$sql = "select a.uniacid,a.should_paid,a.id,a.paid_at,b.uniacid,a.status,a.leader_id,b.name,b.short_name,b.dpopen,a.user_id,c.userid,c.name AS leader_name,c.title,c.mobile,d.id,d.name AS member_name,d.phone,CONCAT(d.city,d.area) AS member_address from " . $db->table('orders'); $sql = "select a.uniacid,a.should_paid,a.id,a.paid_at,b.uniacid,a.status,a.leader_id,a.all_num AS num,b.name,b.short_name,b.dpopen,a.user_id,c.userid,c.name AS leader_name,c.title,c.mobile,d.id,d.name AS member_name,CONCAT(d.address_name,d.address_other) AS member_address,d.phone,e.order_id,e.pro_id,f.id,f.name AS pname,f.unit from " . $db->table('orders'); $sql .= " AS a, " . $db->table('set_basic') . " AS b, " . $db->table('leader') . " AS c," . $db->table('member') . " AS d," . $db->table('order_items') . " AS e," . $db->table('products') . " AS f"; $sql .= " WHERE a.paid_at <> '' AND a.uniacid = b.uniacid AND b.dpopen = 1 AND a.leader_id = c.userid AND a.user_id = d.id AND a.id = e.order_id AND e.pro_id = f.id"; //按照站点筛选; IF ($keys != "") { $sql .= " AND a.uniacid = " . $keys; } //按照时间筛选; IF ($fromTime != "") { $sql .= " AND date_format(a.paid_at,'%Y-%m-%d') >= '$fromTime'"; } IF ($toTime != "") { $sql .= " AND date_format(a.paid_at,'%Y-%m-%d') <= '$toTime'"; } $sql .= " ORDER BY a.paid_at DESC"; //信息记录; $sql .= " LIMIT " . $limit . "," . $pagesize; $row = $db->queryall($sql); //获取总记录数量; $sql_c = "select a.uniacid,a.should_paid,a.id,a.paid_at,b.uniacid,a.status,a.leader_id,a.all_num AS num,b.name,b.short_name,b.dpopen from " . $db->table('orders'); $sql_c .= " AS a, " . $db->table('set_basic') . " AS b"; $sql_c .= " WHERE a.paid_at <> '' AND a.uniacid = b.uniacid AND b.dpopen = 1"; //按照站点筛选; IF ($keys != "") { $sql_c .= " AND a.uniacid = " . $keys; } //按照时间筛选; IF ($fromTime != "") { $sql_c .= " AND date_format(a.paid_at,'%Y-%m-%d') >= '$fromTime'"; } IF ($toTime != "") { $sql_c .= " AND date_format(a.paid_at,'%Y-%m-%d') <= '$toTime'"; } $sql_c .= " ORDER BY a.paid_at DESC"; $row_c = $db->queryall($sql_c); $count = count($row_c); $res['code'] = 0; $res['count'] = $count; $res["data"] = $row; die(json_encode_lockdata($res)); }
Done!