作者 潘浩文
1 个管道 的构建 通过 耗费 5 秒

修改意见

... ... @@ -425,29 +425,31 @@ class SignController extends RestBaseController
$param['fat']=ceil($nengliang*0.2/9);
$param['water']=ceil($nengliang*0.6/4);
$data=Db::name('user_week_sign')->where('user_id',$this->getUserId())->select()->toArray();
$shangxian=[];
$xiaxian=[];
foreach ($data as $k=>$v){
$data[$k]['week']=ceil(($data[$k]['create_time'] - $user['register_time'])/(7*24*60*60));
$data[$k]['week_time']=date('m-d',strtotime('+'.$data[$k]['week'].' week',$data[$k]['create_time']));
if ($user['pregnant_week']+$data[$k]['week']<=12){
$data[$k]['shangxian']=$user['before_weight']+2;
$data[$k]['xiaxian']=$user['before_weight']+0.5;
array_push($shangxian,$user['before_weight']+2);
array_push($xiaxian,$user['before_weight']+0.5);
}else{
if ($paramService->status($user['before_weight'],$user['height'])=='正常') {
$data[$k]['shangxian']=$user['before_weight']+2+($user['pregnant_week']+$data[$k]['week']-12)*0.45;
$data[$k]['xiaxian']=$user['before_weight']+0.5+($user['pregnant_week']+$data[$k]['week']-12)*0.36;
array_push($shangxian,$user['before_weight']+2+($user['pregnant_week']+$data[$k]['week']-12)*0.45);
array_push($xiaxian,$user['before_weight']+0.5+($user['pregnant_week']+$data[$k]['week']-12)*0.36);
}elseif ($paramService->status($user['before_weight'],$user['height'])=='偏瘦'){
$data[$k]['shangxian']=$user['before_weight']+2+($user['pregnant_week']+$data[$k]['week']-12)*0.59;
$data[$k]['xiaxian']=$user['before_weight']+0.5+($user['pregnant_week']+$data[$k]['week']-12)*0.45;
array_push($shangxian,$user['before_weight']+2+($user['pregnant_week']+$data[$k]['week']-12)*0.59);
array_push($xiaxian,$user['before_weight']+0.5+($user['pregnant_week']+$data[$k]['week']-12)*0.45);
}elseif ($paramService->status($user['before_weight'],$user['height'])=='肥胖'){
$data[$k]['shangxian']=$user['before_weight']+2+($user['pregnant_week']+$data[$k]['week']-12)*0.32;
$data[$k]['xiaxian']=$user['before_weight']+0.5+($user['pregnant_week']+$data[$k]['week']-12)*0.23;
array_push($shangxian,$user['before_weight']+2+($user['pregnant_week']+$data[$k]['week']-12)*0.32);
array_push($xiaxian,$user['before_weight']+0.5+($user['pregnant_week']+$data[$k]['week']-12)*0.23);
}elseif ($paramService->status($user['before_weight'],$user['height'])=='超重'){
$data[$k]['shangxian']=$user['before_weight']+2+($user['pregnant_week']+$data[$k]['week']-12)*0.27;
$data[$k]['xiaxian']=$user['before_weight']+0.5+($user['pregnant_week']+$data[$k]['week']-12)*0.18;
array_push($shangxian,$user['before_weight']+2+($user['pregnant_week']+$data[$k]['week']-12)*0.27);
array_push($xiaxian,$user['before_weight']+0.5+($user['pregnant_week']+$data[$k]['week']-12)*0.18);
}
}
}
//返回
$this->success('我的体重数据',[$param,$data]);
$this->success('我的体重数据',[$param,$data,$shangxian,$xiaxian]);
}
}
... ...