|
@@ -43,14 +43,61 @@ class Jiankangdata extends Api
|
|
|
$type = $this->request->post('type','week','trim');
|
|
|
|
|
|
if($type == 'week'){
|
|
|
- $where = ['createtime' => ['>=', date('Y-m-d', strtotime('-7 day'))]];
|
|
|
+ $start_date = date('Y-m-d', strtotime('monday this week'));
|
|
|
+ $ended_date = date('Y-m-d', strtotime('sunday this week'));
|
|
|
+
|
|
|
+ $days = 7;
|
|
|
+ for($i=0;$i<$days;$i++){
|
|
|
+ $date_array[] = date('m.d', 86400*$i + strtotime('monday this week'));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if($type == 'month'){
|
|
|
- $where = ['createtime' => ['>=', date('Y-m-d', strtotime('-30 day'))]];
|
|
|
+ $start_date = date('Y-m-01');
|
|
|
+ $ended_date = date('Y-m-t');
|
|
|
+
|
|
|
+ $days = date('t');
|
|
|
+ for($i=0;$i<$days;$i++){
|
|
|
+ $date_array[] = date('m.d', 86400*$i + strtotime(date('Y-m-01')));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+// dump($start_date);
|
|
|
+// dump($ended_date);
|
|
|
+// dump($date_array);
|
|
|
+
|
|
|
+ $list = Db::name('jiankangdata')->where('user_id',$this->auth->id)->whereBetween('createdate',[$start_date,$ended_date])->order('id','asc')->select();
|
|
|
+
|
|
|
+ $xueya_low = [];
|
|
|
+ $xueya_high = [];
|
|
|
+ $xuetang = [];
|
|
|
+ foreach($date_array as $date){
|
|
|
+ $xueya_low[$date] = 0;
|
|
|
+ $xueya_high[$date] = 0;
|
|
|
+ $xuetang[$date] = 0;
|
|
|
+
|
|
|
+ foreach($list as $k=>$v){
|
|
|
+ if(date('m.d',strtotime($v['createdate'])) == $date){
|
|
|
+ $xueya_low[$date] = $v['xueya_low'];
|
|
|
+ $xueya_high[$date] = $v['xueya_high'];
|
|
|
+ $xuetang[$date] = $v['xuetang'];
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+// dump($xueya_low);
|
|
|
+// dump($xueya_high);
|
|
|
+// dump($xuetang);
|
|
|
|
|
|
- $list = Db::name('jiankangdata')->where('user_id',$this->auth->id)->order('id','asc')->select();
|
|
|
- $this->success(1,$list);
|
|
|
+ $rs = [
|
|
|
+ 'start_date' => date('Y.m.d',strtotime($start_date)),
|
|
|
+ 'end_date' => date('Y.m.d',strtotime($ended_date)),
|
|
|
+ 'date_array' => $date_array,
|
|
|
+ 'xueya_low' => array_values($xueya_low),
|
|
|
+ 'xueya_high' => array_values($xueya_high),
|
|
|
+ 'xuetang' => array_values($xuetang),
|
|
|
+ ];
|
|
|
+ $this->success(1,$rs);
|
|
|
}
|
|
|
|
|
|
|