$where_str.=" and create_time BETWEEN '".$params['create_time_start']." 00:00:00' AND '".$params['create_time_end']." 23:59:59'";
$where_str.=" and a.create_time BETWEEN '".$params['create_time_start']." 00:00:00' AND '".$params['create_time_end']." 23:59:59'";
}
if(!empty($params['user_phone'])){
$where_str.=" and user_phone LIKE '%".$params['user_phone']."%'";
$where_str.=" and a.user_phone LIKE '%".$params['user_phone']."%'";
}
if(!empty($params['user_id'])){
$where_str.=" and user_id = {$params['user_id']}";
$where_str.=" and a.user_id = {$params['user_id']}";
}
$sql="SELECT * FROM (
( SELECT id, user_id,source_id, money, user_name,create_time, 1 AS is_essay,status FROM `u_account_balance` WHERE `status` = 0 $where_str) UNION
( SELECT id, user_id,0 as source_id ,money, user_name,create_time, 2 AS is_essay,status FROM `u_account_check` WHERE `status` IN ( 0, 1, 2 ) $where_str)
FROM `u_account_balance` a left join a_coupon b on a.source_id=b.id
left join c_activity c on b.activity_id=c.id WHERE `a.status` = 0 and a.source_type = 0 $where_str) UNION
( SELECT a.id, a.user_id,0 as source_id , a.money, a.user_name, a.create_time, 2 AS is_essay, a.status,0 as title FROM `u_account_check` a WHERE `a.status` IN ( 0, 1, 2 ) $where_str)
) AS aaa ORDER BY `create_time` DESC LIMIT {$pageNo}, {$pageSize}";