...
|
...
|
@@ -409,13 +409,31 @@ class Index extends Api |
|
|
}
|
|
|
$images = implode(',',$imgarr);
|
|
|
}
|
|
|
$ideaname = Db::name('idea')->where('id',$ideaid)->find();
|
|
|
|
|
|
|
|
|
//计算中位数
|
|
|
$feel = Db::name('idea_feel')->where('id',$feel_id)->find();
|
|
|
if ($feel['fraction'] !== 0){
|
|
|
Db::name('idea')->where('id',$ideaid)->setInc('feel_number');
|
|
|
Db::name('idea')->where('id',$ideaid)->setInc('feel_number',$feel['fraction']);
|
|
|
}
|
|
|
$idea = Db::name('idea')->where('id',$ideaid)->find();
|
|
|
$fraction = $idea['feel_fraction']/$idea['feel_number'];
|
|
|
if ($fraction > 19){
|
|
|
$fraction = 19;
|
|
|
}elseif ($fraction < 1){
|
|
|
$fraction = 1;
|
|
|
}else{
|
|
|
$fraction = (int)$fraction;
|
|
|
}
|
|
|
|
|
|
|
|
|
if ($area == ''){
|
|
|
$area = Db::name('idea_area')->where('id',$ideaname['idea_area_id'])->value('name');
|
|
|
$area = Db::name('idea_area')->where('id',$idea['idea_area_id'])->value('name');
|
|
|
}
|
|
|
$data = [
|
|
|
'idea_id'=>$ideaid,
|
|
|
'idea_name'=>'#'.$ideaname['title'],
|
|
|
'idea_name'=>'#'.$idea['title'],
|
|
|
'user_id'=>$this->auth->id,
|
|
|
'comment'=>$comment,
|
|
|
'area'=>$area,
|
...
|
...
|
@@ -424,6 +442,8 @@ class Index extends Api |
|
|
'createtime'=>time(),
|
|
|
];
|
|
|
Db::name('idea_comment')->insert($data);
|
|
|
$feel = Db::name('idea_feel')->where('fraction',$fraction)->find();
|
|
|
Db::name('idea')->where('id',$ideaid)->update(['idea_feel_id'=>$feel['id']]);
|
|
|
$this->success('发布成功');
|
|
|
}
|
|
|
|
...
|
...
|
|