作者 李忠强
1 个管道 的构建 通过 耗费 3 秒

更新

... ... @@ -54,7 +54,7 @@ class Idea extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['ideatype','ideaweather','ideaarea'])
->with(['ideatype','ideaweather','ideaarea','ideafeel'])
->where($where)
->order($sort, $order)
->paginate($limit);
... ... @@ -64,6 +64,7 @@ class Idea extends Backend
$row->getRelation('ideatype')->visible(['name']);
$row->getRelation('ideaweather')->visible(['name']);
$row->getRelation('ideaarea')->visible(['name']);
$row->getRelation('ideafeel')->visible(['name']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
... ...
... ... @@ -5,7 +5,7 @@ return [
'Title' => '点子标题',
'Key_word' => '点子关键词',
'Duration' => '时长(分钟)',
'Mid_feel' => '体验感受中位数',
'Mid_feel' => '体验感受中位数id',
'All_number' => '体验总人数',
'Collection' => '收藏数',
'Idea_area_id' => '城市id',
... ...
... ... @@ -53,4 +53,9 @@ class Idea extends Model
{
return $this->belongsTo('IdeaArea', 'idea_area_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function ideafeel()
{
return $this->belongsTo('IdeaFeel', 'idea_feel_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
... ... @@ -27,7 +27,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Mid_feel')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-mid_feel" class="form-control" name="row[mid_feel]" type="text">
<input id="c-mid_feel" class="form-control selectpage" data-source="idea_feel/index" name="row[idea_feel_id]" type="text">
</div>
</div>
<!-- <div class="form-group">-->
... ...
... ... @@ -27,7 +27,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Mid_feel')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-mid_feel" class="form-control" name="row[mid_feel]" type="text" value="{$row.mid_feel|htmlentities}">
<input id="c-mid_feel" class="form-control selectpage" name="row[idea_feel_id]" data-source="idea_feel/index" type="text" value="{$row.idea_feel_id|htmlentities}">
</div>
</div>
<!-- <div class="form-group">-->
... ...
... ... @@ -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('发布成功');
}
... ...
... ... @@ -32,7 +32,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'key_word', title: __('Key_word'), operate: 'LIKE'},
{field: 'duration', title: __('Duration')},
{field: 'mid_feel', title: __('Mid_feel'), operate: false},
{field: 'idea_feel_id', title: __('Mid_feel')},
{field: 'ideafeel.name', title: __('体验感受名称'), operate: 'LIKE'},
{field: 'all_number', title: __('All_number')},
{field: 'collection', title: __('Collection')},
{field: 'idea_area_id', title: __('Idea_area_id'),visible:false,operate: false},
... ...