Commit c2f3bf05 authored by zhuwei's avatar zhuwei

bug

parent 7663057e
...@@ -11,12 +11,14 @@ class SquareService ...@@ -11,12 +11,14 @@ class SquareService
private $m_square; private $m_square;
private $m_coment; private $m_coment;
private $m_coment_ext; private $m_coment_ext;
private $redis;
public function __construct() public function __construct()
{ {
$this->m_square = new BSquare(); $this->m_square = new BSquare();
$this->m_coment = new BComment(); $this->m_coment = new BComment();
$this->m_coment_ext = new BCommentExt(); $this->m_coment_ext = new BCommentExt();
$this->redis = new RedisCacheService();
} }
public function getDistrictLable(){ public function getDistrictLable(){
...@@ -77,8 +79,8 @@ class SquareService ...@@ -77,8 +79,8 @@ class SquareService
$field = 'Square.id,';// $field = 'Square.id,';//
$field .= 'Square.title,';//标题 $field .= 'Square.title,';//标题
$field .= 'Square.agent_id,';//标题
$field .= 'Square.cover_img,';//cover_img $field .= 'Square.cover_img,';//cover_img
$field .= 'Agent.name,';//发布人
$field .= 'Site.name as site_name,';//城市 $field .= 'Site.name as site_name,';//城市
$field .= 'Square.create_time';//发布时间 $field .= 'Square.create_time';//发布时间
...@@ -88,7 +90,9 @@ class SquareService ...@@ -88,7 +90,9 @@ class SquareService
$res_total = $this->m_square->getSquareListTotal($field, $get_params); $res_total = $this->m_square->getSquareListTotal($field, $get_params);
foreach ($res as $key => $val) { foreach ($res as $key => $val) {
$res[$key]['image_path'] = 'http://n.sinaimg.cn/ent/transform/20170921/FVGl-fymesmp0851702.jpg'; $agent = $this->redis->getRedisCache(2, $val['agent_id']) ;
$res[$key]['name'] = $agent['name'];
$res[$key]['image_path'] = AGENTHEADERIMGURL . $agent['img'];
} }
return [ 'data' => $res, 'total' => $res_total ]; return [ 'data' => $res, 'total' => $res_total ];
...@@ -102,9 +106,7 @@ class SquareService ...@@ -102,9 +106,7 @@ class SquareService
$field .= 'Comment.comment,';// $field .= 'Comment.comment,';//
$field .= 'Comment.agent_id,';// $field .= 'Comment.agent_id,';//
$field .= 'Comment.sort,';// $field .= 'Comment.sort,';//
$field .= 'Comment.create_time,';// $field .= 'Comment.create_time';//
$field .= 'Agent.name,';//
$field .= 'Agent.img';//
$get_params['Comment.square_id'] = $params['square_id']; $get_params['Comment.square_id'] = $params['square_id'];
...@@ -112,14 +114,29 @@ class SquareService ...@@ -112,14 +114,29 @@ class SquareService
$res_total = $this->m_coment->getSquareCommentListTotal($field, $get_params); $res_total = $this->m_coment->getSquareCommentListTotal($field, $get_params);
foreach ($res as $key => $val) { foreach ($res as $key => $val) {
$res[$key]['img'] = 'http://n.sinaimg.cn/ent/transform/20170921/FVGl-fymesmp0851702.jpg'; $agent = $this->redis->getRedisCache(2, $val['agent_id']) ;
$get_params = []; $res[$key]['name'] = $agent['name'];
$res[$key]['img'] = AGENTHEADERIMGURL . $agent['img'];;
$field = 'CommentExt.id,CommentExt.level,CommentExt.comment,AgentA.name as agent_id_a,AgentB.name as agent_id_b';// $get_params = [];
$list = [];
$field = 'CommentExt.id,CommentExt.level,CommentExt.comment,CommentExt.agent_id_a,CommentExt.agent_id_b';//
$get_params['CommentExt.comment_id'] = $val['id']; $get_params['CommentExt.comment_id'] = $val['id'];
$res[$key]['comment_ext']['total']= $this->m_coment_ext->getSquareCommentExtListTotal($field,$get_params); $res[$key]['comment_ext']['total']= $this->m_coment_ext->getSquareCommentExtListTotal($field,$get_params);
$res[$key]['comment_ext']['list']= $this->m_coment_ext->getSquareCommentExtList(1, 2, $field, $get_params); $list = $this->m_coment_ext->getSquareCommentExtList(1, 2, $field, $get_params);
if($list){
foreach ($list as $key2 => $val2) {
$agent_a = $this->redis->getRedisCache(2, $val2['agent_id_a']) ;
$agent_b = $this->redis->getRedisCache(2, $val2['agent_id_b']) ;
$list[$key2]['agent_name_a']=$agent_a['name'];
$list[$key2]['agent_name_b']=$agent_b['name'];
}
}
$res[$key]['comment_ext']['list']= $list;
} }
return [ 'data' => $res, 'total' => $res_total ]; return [ 'data' => $res, 'total' => $res_total ];
...@@ -131,7 +148,6 @@ class SquareService ...@@ -131,7 +148,6 @@ class SquareService
$field .= 'Square.title,';//标题 $field .= 'Square.title,';//标题
$field .= 'Square.content,';//标题 $field .= 'Square.content,';//标题
$field .= 'Square.cover_img,';//cover_img $field .= 'Square.cover_img,';//cover_img
$field .= 'Agent.name,';//发布人
$field .= 'Square.site_id,';//城市 $field .= 'Square.site_id,';//城市
$field .= 'Site.name as site_name,';//城市 $field .= 'Site.name as site_name,';//城市
$field .= 'Square.district_lable_id,';//部门 $field .= 'Square.district_lable_id,';//部门
...@@ -148,9 +164,10 @@ class SquareService ...@@ -148,9 +164,10 @@ class SquareService
continue; continue;
} }
} }
$agent = $this->redis->getRedisCache(2, $res['agent_id']) ;
$res['name'] = $agent['name'];
return $res;
return [ 'data' => $res];
} }
public function delSquare($id) public function delSquare($id)
...@@ -220,6 +237,7 @@ class SquareService ...@@ -220,6 +237,7 @@ class SquareService
$insert["is_del"] = 0;//是否删除 0正常 1删除 $insert["is_del"] = 0;//是否删除 0正常 1删除
$res = $this->m_coment_ext->saveCommentExt($insert);//int(1) $res = $this->m_coment_ext->saveCommentExt($insert);//int(1)
if($res == 1){ if($res == 1){
return true; return true;
}else{ }else{
...@@ -228,11 +246,15 @@ class SquareService ...@@ -228,11 +246,15 @@ class SquareService
} }
public function getCommenInfo($params){ public function getCommenInfo($params){
$field = 'Comment.id,Comment.comment,Comment.create_time,Agent.name,Agent.img';// $field = 'Comment.id,Comment.comment,Comment.create_time';//
$get_params['Comment.id'] = $params['id']; $get_params['Comment.id'] = $params['id'];
$res = $this->m_coment->getCommenInfo($field,$get_params); $res = $this->m_coment->getCommenInfo($field,$get_params);
$res['image_path'] = 'http://n.sinaimg.cn/ent/transform/20170921/FVGl-fymesmp0851702.jpg';
return [ 'data' => $res]; $agent = $this->redis->getRedisCache(2, $res['agent_id']) ;
$res['name'] = $agent['name'];
$res['image_path'] = AGENTHEADERIMGURL . $agent['img'];//'http://n.sinaimg.cn/ent/transform/20170921/FVGl-fymesmp0851702.jpg';
return $res;
} }
public function editCommenSort($params) public function editCommenSort($params)
...@@ -256,15 +278,21 @@ class SquareService ...@@ -256,15 +278,21 @@ class SquareService
$pageNo = empty($params['page_no']) ? 1 : $params['page_no']; $pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 15 : $params['page_size']; $pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
$field = 'CommentExt.id,CommentExt.comment,CommentExt.create_time,AgentA.img,AgentA.name as agent_id_a,AgentB.name as agent_id_b';// $field = 'CommentExt.id,CommentExt.comment,CommentExt.level,CommentExt.create_time,CommentExt.agent_id_a,CommentExt.agent_id_b';//
$get_params['CommentExt.comment_id'] = $params['id']; $get_params['CommentExt.comment_id'] = $params['id'];
$res = $this->m_coment_ext->getSquareCommentExtList($pageNo, $pageSize, $field, $get_params); $res = $this->m_coment_ext->getSquareCommentExtList($pageNo, $pageSize, $field, $get_params);
$res_total = $this->m_coment_ext->getSquareCommentExtListTotal($field, $get_params); $res_total = $this->m_coment_ext->getSquareCommentExtListTotal($field, $get_params);
foreach ($res as $key => $val) { if($res){
$res[$key]['image_path'] = 'http://n.sinaimg.cn/ent/transform/20170921/FVGl-fymesmp0851702.jpg'; foreach ($res as $key2 => $val2) {
$agent_a = $this->redis->getRedisCache(2, $val2['agent_id_a']) ;
$agent_b = $this->redis->getRedisCache(2, $val2['agent_id_b']) ;
$res[$key2]['agent_name_a']=$agent_a['name'];
$res[$key2]['agent_name_b']=$agent_b['name'];
}
} }
return [ 'data' => $res, 'total' => $res_total ]; return [ 'data' => $res, 'total' => $res_total ];
......
...@@ -25,7 +25,6 @@ class BComment extends Model ...@@ -25,7 +25,6 @@ class BComment extends Model
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias('Comment') ->alias('Comment')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'right')
->where($params) ->where($params)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
...@@ -41,7 +40,6 @@ class BComment extends Model ...@@ -41,7 +40,6 @@ class BComment extends Model
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias('Comment') ->alias('Comment')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'right')
->where($params) ->where($params)
->count(); ->count();
//dump($this->getLastSql()); //dump($this->getLastSql());
...@@ -55,7 +53,6 @@ class BComment extends Model ...@@ -55,7 +53,6 @@ class BComment extends Model
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias('Comment') ->alias('Comment')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'left')
->where($params) ->where($params)
->order($order) ->order($order)
->find(); ->find();
......
...@@ -25,8 +25,6 @@ class BCommentExt extends Model ...@@ -25,8 +25,6 @@ class BCommentExt extends Model
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias('CommentExt') ->alias('CommentExt')
->join('a_agents AgentA', 'AgentA.id = CommentExt.agent_id_a', 'left')
->join('a_agents AgentB', 'AgentB.id = CommentExt.agent_id_b', 'left')
->where($params) ->where($params)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
...@@ -42,8 +40,6 @@ class BCommentExt extends Model ...@@ -42,8 +40,6 @@ class BCommentExt extends Model
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias('CommentExt') ->alias('CommentExt')
->join('a_agents AgentA', 'AgentA.id = CommentExt.agent_id_a', 'left')
->join('a_agents AgentB', 'AgentB.id = CommentExt.agent_id_b', 'left')
->where($params) ->where($params)
->count(); ->count();
//dump($this->getLastSql()); //dump($this->getLastSql());
......
...@@ -50,7 +50,6 @@ class BSquare extends Model ...@@ -50,7 +50,6 @@ class BSquare extends Model
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias('Square') ->alias('Square')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'left')
->join('a_site Site', 'Site.id = Square.site_id', 'left') ->join('a_site Site', 'Site.id = Square.site_id', 'left')
->where($params) ->where($params)
->limit($pageSize) ->limit($pageSize)
...@@ -67,7 +66,6 @@ class BSquare extends Model ...@@ -67,7 +66,6 @@ class BSquare extends Model
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias('Square') ->alias('Square')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'left')
->join('a_site Site', 'Site.id = Square.site_id', 'left') ->join('a_site Site', 'Site.id = Square.site_id', 'left')
->where($params) ->where($params)
->count(); ->count();
...@@ -81,7 +79,6 @@ class BSquare extends Model ...@@ -81,7 +79,6 @@ class BSquare extends Model
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias('Square') ->alias('Square')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'left')
->join('a_site Site', 'Site.id = Square.site_id', 'left') ->join('a_site Site', 'Site.id = Square.site_id', 'left')
// ->join('a_district District', 'District.id = Square.district_id', 'left') // ->join('a_district District', 'District.id = Square.district_id', 'left')
->where($params) ->where($params)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment