$where_params='WHERE '.implode(" AND ",$conditions);
}
//
// dump($where_params);
// dump($params["type"]);
switch($params["type"]){
case2:
$sql="SELECT * FROM
(( SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_march_in` `c` ON `b`.`id` = `c`.`order_id`
WHERE
$report_agent_str
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)UNION(
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_march_in` `c` ON `b`.`id` = `c`.`order_id`
WHERE
$house_str
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
) ) AS aaa ORDER BY `create_time` DESC LIMIT $start_index,$pageSize";
$result=$this->db->query($sql);
return$result;
case3:
$sql="SELECT * FROM
(
(
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_paylog` `c` ON `b`.`id` = `c`.`order_id`
WHERE
$report_agent_str
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)
UNION
(
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_paylog` `c` ON `b`.`id` = `c`.`order_id`
WHERE
$house_str
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)
) AS aaa ORDER BY `create_time` DESC LIMIT $start_index,$pageSize";
$result=$this->db->query($sql);
return$result;
case4:
$sql="SELECT * FROM
((
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_bargain` `c` ON `b`.`id` = `c`.`order_id`
WHERE
$report_agent_str
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)
UNION
(
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_bargain` `c` ON `b`.`id` = `c`.`order_id`
WHERE
$house_str
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)
) AS aaa ORDER BY `create_time` DESC limit $start_index,$pageSize";
$result=$this->db->query($sql);
return$result;
default:
$filed="a.id,a.user_id,a.report_agent_name,a.report_agent_phone,a.user_phone,a.user_name,a.predict_see_time,a.create_time,b.id as order_id,b.order_no,b.house_id,b.house_title,c.province,c.city,c.disc,c.internal_address";
$sql="SELECT * FROM
((SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
LEFT JOIN `g_houses` `c` ON `b`.`house_id` = `c`.`id`
WHERE
$report_agent_str
AND `a`.`status` = 0
AND `b`.`is_del` = 0)
UNION
(SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
LEFT JOIN `g_houses` `c` ON `b`.`house_id` = `c`.`id`
WHERE
$house_str
AND `a`.`status` = 0
AND `b`.`is_del` = 0
) ) as aaa $where_params ORDER BY `create_time` DESC limit $start_index,$pageSize";
$where_params='WHERE '.implode(" AND ",$conditions);
}
switch($params["type"]){
case2:
$sql="SELECT count(1) as total FROM
(( SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_march_in` `c` ON `b`.`id` = `c`.`order_id`
WHERE
`a`.`report_agent_id` IN ($report_agent_id )
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)UNION(
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_march_in` `c` ON `b`.`id` = `c`.`order_id`
WHERE
`b`.`house_id` IN ($house_ids)
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
) ) AS aaa ";
$result=$this->db->query($sql);
return$result;
case3:
$sql="SELECT count(1) as total FROM
(
(
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_paylog` `c` ON `b`.`id` = `c`.`order_id`
WHERE
`a`.`report_agent_id` IN ($report_agent_id )
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)
UNION
(
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_paylog` `c` ON `b`.`id` = `c`.`order_id`
WHERE
`b`.`house_id` IN ($house_ids)
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)
) AS aaa";
$result=$this->db->query($sql);
return$result;
case4:
$sql="SELECT count(1) as total FROM
((
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_bargain` `c` ON `b`.`id` = `c`.`order_id`
WHERE
`a`.`report_agent_id` IN ($report_agent_id )
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)
UNION
(
SELECT
$filed
FROM
`o_report` `a`
LEFT JOIN `o_order` `b` ON `a`.`id` = `b`.`f_id`
RIGHT JOIN `o_bargain` `c` ON `b`.`id` = `c`.`order_id`
WHERE
`b`.`house_id` IN ($house_ids)
AND `a`.`status` = 0
AND `b`.`is_del` = 0
GROUP BY
`c`.`order_id`
)
) AS aaa ";
$result=$this->db->query($sql);
return$result;
default:
$filed="a.id,a.user_id,a.report_agent_name,a.report_agent_phone,a.user_phone,a.user_name,a.predict_see_time,a.create_time,b.id as order_id,b.order_no,b.house_id,b.house_title,c.province,c.city,c.disc,c.internal_address";