|
@@ -243,23 +243,25 @@ class SignController extends RestBaseController |
|
@@ -243,23 +243,25 @@ class SignController extends RestBaseController |
243
|
//用户信息
|
243
|
//用户信息
|
244
|
$user=Db::name('user')->where('id',$this->getUserId())->find();
|
244
|
$user=Db::name('user')->where('id',$this->getUserId())->find();
|
245
|
//判断是否是第一次周打卡
|
245
|
//判断是否是第一次周打卡
|
246
|
- $re=Db::name('user_week_sign')->where('user_id',$user['id'])->find();
|
246
|
+ $re=Db::name('user_week_sign')->where('user_id',$user['id'])->order('create_time','desc')->find();
|
247
|
if (!$re){
|
247
|
if (!$re){
|
248
|
- $param['pregnant_week']=$user['pregnant_week'];
|
|
|
249
|
- $param['day']=ceil((time()-$user['register_time'])/(60*60*21));
|
|
|
250
|
$param['weight']=$user['before_weight'];
|
248
|
$param['weight']=$user['before_weight'];
|
251
|
$paramService=new ParamService();
|
249
|
$paramService=new ParamService();
|
252
|
-
|
250
|
+ $param['status']=$paramService->status($user['before_weight'],$user['height']);
|
|
|
251
|
+ $param['increase']=0;
|
|
|
252
|
+ $param['overplus']=$paramService->overplus($user['before_weight'],$user['height']);
|
|
|
253
|
+ }else{
|
|
|
254
|
+ $param['weight']=$re['weight'];
|
|
|
255
|
+ $param['increase']=$re['weight']-$user['before_weight'];
|
|
|
256
|
+ $paramService=new ParamService();
|
|
|
257
|
+ $param['overplus']=$paramService->overplus($user['before_weight'],$user['height'])-($re['weight']-$user['before_weight']);
|
|
|
258
|
+ $record=Db::name('user_week_sign')->where('user_id',$user['id'])->select();
|
253
|
}
|
259
|
}
|
|
|
260
|
+ $param['day']=ceil((time()-$user['register_time'])/(60*60*21));
|
|
|
261
|
+ $param['pregnant_week']=$user['pregnant_week'];
|
254
|
//返回
|
262
|
//返回
|
255
|
$this->success('日打卡信息',array(
|
263
|
$this->success('日打卡信息',array(
|
256
|
- 'all'=>$user['all_sign_day'],
|
|
|
257
|
- 'last'=>$user['stay_sign_day'],
|
|
|
258
|
- 'longest'=>$user['longest_sign_day'],
|
|
|
259
|
- 'morning'=>$daySign['morning'],
|
|
|
260
|
- 'noon'=>$daySign['noon'],
|
|
|
261
|
- 'night'=>$daySign['night'],
|
|
|
262
|
- 'sleep'=>$daySign['sleep'],
|
264
|
+ $param,$record
|
263
|
));
|
265
|
));
|
264
|
}
|
266
|
}
|
265
|
} |
267
|
} |