whereRwa
$where = '';
$value = [];
if ($senduid) {
if ($senduid == '全部用户') {
$u_id = 0;
} else {
$u_id = DB::name('Member')->where('nickname', $senduid)->value('id');
}
$where .= ' AND senduid = :senduid';
$value['senduid'] = $u_id;
}
if (!empty($m_status) && $m_status != 'none') {
$where .= ' AND status = :status';
$value['status'] = $m_status;
}
//得到limit参数
$limit_start = $data['start'];
$limit_length = $data['length'];
$list = Db::name('messages')->whereRaw('msg_status = 2 AND status <> 2' . $where . '', $value)->limit($limit_start, $limit_length)->order('date', 'desc')->select();
$total = Db::name('messages')->whereRaw('msg_status = 2 AND status <> 2' . $where . '', $value)->count();
query
//获取一个本周7天以内的资金走向表
public function sevenpicture(Request $request)
{
$uid = input('uid');
//佣金走势图
$timestr = time(); //当前时间戳
$now_day = date('w',$timestr); //当前是周几
//获取周一
$monday_str = $timestr - ($now_day-1)*60*60*24;
$monday = date('Y-m-d', $monday_str);
//获取周日
$sunday_str = $timestr + (7-$now_day)*60*60*24;
$sunday = date('Y-m-d', $sunday_str);
for($i=0;$i<7;$i++)
{
$arr[date('Y-m-d',strtotime($monday.'+'.$i.'day'))]=0;
}
$sql =
"SELECT
sum(`carprice`) as price,
date_format(`createtime`,\"%Y-%m-%d\") as date
FROM
`y_agent`
WHERE
`caruid` = :uid
AND date_format(`createtime`,\"%Y-%m-%d\") BETWEEN :s_time
AND :c_time
GROUP BY date";
$re = Db::query($sql,['uid'=>$uid,'s_time'=>$monday,'c_time'=>$sunday]);
foreach ($re as $k=>$v)
{
$dateinfo[$v['date']] =$v['price'];
}
$linepicture =array_merge($arr,$dateinfo);
foreach ($linepicture as $key=>$value )
{
$line[] =[
'time'=>$key,
'tem'=>$value,
];
}
//`````````````````````
if($line)
{
return json(['code'=>1,'data'=>$line,'msg'=>"获取数据成功"]);
}else{
return json(['code'=>2,'data'=>'','msg'=>"获取数据失败!"]);
}
}