Commit e78e9554 authored by zw's avatar zw

1

parent a44b7af4
...@@ -63,6 +63,9 @@ class Square extends Basic ...@@ -63,6 +63,9 @@ class Square extends Basic
} }
} }
/**
* @return \think\Response
*/
public function getSquareSortList() public function getSquareSortList()
{ {
$params = $this->params; $params = $this->params;
...@@ -136,13 +139,13 @@ class Square extends Basic ...@@ -136,13 +139,13 @@ class Square extends Basic
{ {
$params = $this->params; $params = $this->params;
/* $params = array( /*$params = array(
"level" => 1,//不传是主评论 1是主评论第一级回复 2是第一级回复的回复 "level" => 1,//不传是主评论 1是主评论第一级回复 2是第一级回复的回复
"comment_id" => 1, //主评论ID "comment_id" => 1, //主评论ID
"agent_id_b" => 1, //被回复人的id "agent_id_b" => 1, //被回复人的id
"square_id" => 1, // 开盘id "square_id" => 5, // 开盘id
"comment" => "123123", // 开盘id
"author_id" => 1, // 主要做推送 "author_id" => 1, // 主要做推送
"square_site_id" => 10001,
);*/ );*/
$square_id = $params['square_id']; $square_id = $params['square_id'];
$comment = $params['comment']; $comment = $params['comment'];
......
...@@ -16,10 +16,10 @@ class SquareService ...@@ -16,10 +16,10 @@ class SquareService
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(); $this->redis = new RedisCacheService();
if (CURRENT_URL == 'https://api.tonglianjituan.com/') { if (CURRENT_URL == 'https://api.tonglianjituan.com/') {
$this->internet_path = IMAGES_URL . 'resource/lib/Attachments/images/'; $this->internet_path = IMAGES_URL . 'resource/lib/Attachments/images/';
...@@ -61,14 +61,14 @@ class SquareService ...@@ -61,14 +61,14 @@ class SquareService
*/ */
public function saveSquare($agent_id, $title, $house_id, $content, $cover_img, $site_id, $district_id) public function saveSquare($agent_id, $title, $house_id, $content, $cover_img, $site_id, $district_id)
{ {
$insert["agent_id"] = $agent_id;//经纪人id $insert["agent_id"] = $agent_id;//经纪人id
$insert["title"] = $title;//标题 $insert["title"] = $title;//标题
$insert["house_id"] = $house_id;//楼盘id $insert["house_id"] = $house_id;//楼盘id
$insert["content"] = $content;//text $insert["content"] = $content;//text
$insert["cover_img"] = $cover_img;//封面图 $insert["cover_img"] = $cover_img;//封面图
$insert["site_id"] = $site_id;//站点id $insert["site_id"] = $site_id;//站点id
$insert["district_lable_id"] = $district_id;//部门id $insert["district_lable_id"] = $district_id;//部门id
$insert["status"] = 0;//状态: 0正常 1删除 $insert["status"] = 0;//状态: 0正常 1删除
$res = $this->m_square->saveSquare($insert);//int(1) $res = $this->m_square->saveSquare($insert);//int(1)
if ($res == 1) { if ($res == 1) {
...@@ -85,7 +85,7 @@ class SquareService ...@@ -85,7 +85,7 @@ class SquareService
*/ */
public function getSquareList($params) public function getSquareList($params)
{ {
$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'];
//搜索 时间 //搜索 时间
...@@ -115,12 +115,12 @@ class SquareService ...@@ -115,12 +115,12 @@ class SquareService
$field .= 'Square.create_time';//发布时间 $field .= 'Square.create_time';//发布时间
$get_params['Square.status'] = 0; $get_params['Square.status'] = 0;
$res = $this->m_square->getSquareList($pageNo, $pageSize, $field, $get_params); $res = $this->m_square->getSquareList($pageNo, $pageSize, $field, $get_params);
$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) {
$agent = $this->redis->getRedisCache(2, $val['agent_id']); $agent = $this->redis->getRedisCache(2, $val['agent_id']);
$res[$key]['name'] = $agent['name']; $res[$key]['name'] = $agent['name'];
$res[$key]['image_path'] = AGENTHEADERIMGURL . $agent['img']; $res[$key]['image_path'] = AGENTHEADERIMGURL . $agent['img'];
//部门标签 //部门标签
...@@ -135,12 +135,36 @@ class SquareService ...@@ -135,12 +135,36 @@ class SquareService
return ['data' => $res, 'total' => $res_total]; return ['data' => $res, 'total' => $res_total];
} }
/**
* 热帖
* @param $list
* @return false|\PDOStatement|string|\think\Collection
*/
public function getSquareSortList($list) public function getSquareSortList($list)
{ {
dump($list); $ids = "";
foreach ($list as $key => $item) {
$ids .= $key . ",";
}
$ids = rtrim($ids, ",");
$field = 'id,title,agent_id,district_lable_id,cover_img,create_time';
$get_params['status'] = 0;
$get_params['id'] = array("in", $ids);
// $square_data = $this->m_square->getSquare('id,is_cream',['id'=>$v]); $res = $this->m_square->getSquare($field, $get_params);
// return $result;
foreach ($res as $key => $val) {
$agent = $this->redis->getRedisCache(2, $val['agent_id']);
$res[$key]['name'] = $agent['name'];
$res[$key]['image_path'] = AGENTHEADERIMGURL . $agent['img'];
//部门标签
$res[$key]['district_lable_name'] = $this->getDistrictLableName($val['district_lable_id']);
$res[$key]['cover_img_path'] = $val['cover_img'] ? $this->internet_path . $val['cover_img'] : '';
}
return $res;
} }
/** /**
...@@ -152,7 +176,7 @@ class SquareService ...@@ -152,7 +176,7 @@ class SquareService
{ {
// big_log(json_encode($params)); // big_log(json_encode($params));
$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 = 'Comment.id,'; $field = 'Comment.id,';
...@@ -162,27 +186,27 @@ class SquareService ...@@ -162,27 +186,27 @@ class SquareService
$field .= 'Comment.create_time'; $field .= 'Comment.create_time';
$get_params['Comment.square_id'] = $params['square_id']; $get_params['Comment.square_id'] = $params['square_id'];
$get_params['Comment.is_del'] = 0; $get_params['Comment.is_del'] = 0;
$res = $this->m_coment->getSquareCommentList($pageNo, $pageSize, $field, $get_params); $res = $this->m_coment->getSquareCommentList($pageNo, $pageSize, $field, $get_params);
$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) {
$agent = $this->redis->getRedisCache(2, $val['agent_id']); $agent = $this->redis->getRedisCache(2, $val['agent_id']);
$res[$key]['name'] = $agent['name']; $res[$key]['name'] = $agent['name'];
$res[$key]['img'] = AGENTHEADERIMGURL . $agent['img']; $res[$key]['img'] = AGENTHEADERIMGURL . $agent['img'];
$get_params = []; $get_params = [];
$field = 'CommentExt.id,CommentExt.level,CommentExt.comment,CommentExt.agent_id_a,CommentExt.agent_id_b';// $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'];
$get_params['CommentExt.is_del'] = 0; $get_params['CommentExt.is_del'] = 0;
$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);
$list = $this->m_coment_ext->getSquareCommentExtList(1, 2, $field, $get_params); $list = $this->m_coment_ext->getSquareCommentExtList(1, 2, $field, $get_params);
if ($list) { if ($list) {
foreach ($list as $key2 => $val2) { foreach ($list as $key2 => $val2) {
$agent_a = $this->redis->getRedisCache(2, $val2['agent_id_a']); $agent_a = $this->redis->getRedisCache(2, $val2['agent_id_a']);
$agent_b = $this->redis->getRedisCache(2, $val2['agent_id_b']); $agent_b = $this->redis->getRedisCache(2, $val2['agent_id_b']);
$list[$key2]['agent_name_a'] = $agent_a['name']; $list[$key2]['agent_name_a'] = $agent_a['name'];
$list[$key2]['agent_name_b'] = $agent_b['name']; $list[$key2]['agent_name_b'] = $agent_b['name'];
} }
...@@ -233,16 +257,16 @@ class SquareService ...@@ -233,16 +257,16 @@ class SquareService
// $get_params['house.status'] = 1;//上架的商铺 // $get_params['house.status'] = 1;//上架的商铺
$get_params['Square.id'] = $params['id']; $get_params['Square.id'] = $params['id'];
$res = $this->m_square->getSquareInfo($field, $get_params); $res = $this->m_square->getSquareInfo($field, $get_params);
$res['district_lable_name'] = $this->getDistrictLableName($res['district_lable_id']); $res['district_lable_name'] = $this->getDistrictLableName($res['district_lable_id']);
$agent = $this->redis->getRedisCache(2, $res['agent_id']); $agent = $this->redis->getRedisCache(2, $res['agent_id']);
$res['name'] = $agent['name']; $res['name'] = $agent['name'];
//用户置顶权限 //用户置顶权限
$res['user_competence'] = $this->userCompetence($agent_id); $res['user_competence'] = $this->userCompetence($agent_id);
$res['is_can_edit'] = 1;//兼容老版本 2019-04-22 $res['is_can_edit'] = 1;//兼容老版本 2019-04-22
return $res; return $res;
} }
...@@ -257,15 +281,15 @@ class SquareService ...@@ -257,15 +281,15 @@ class SquareService
switch ($params['type']) { switch ($params['type']) {
case 0: case 0:
$update_params['is_del'] = 1; $update_params['is_del'] = 1;
$res = $this->m_coment->updateStatus($where_params, $update_params); $res = $this->m_coment->updateStatus($where_params, $update_params);
break; break;
case 1: case 1:
$update_params['is_del'] = 1; $update_params['is_del'] = 1;
$res = $this->m_coment_ext->updateStatus($where_params, $update_params); $res = $this->m_coment_ext->updateStatus($where_params, $update_params);
break; break;
default: default:
$update_params['status'] = 1; $update_params['status'] = 1;
$res = $this->m_square->updateStatus($where_params, $update_params); $res = $this->m_square->updateStatus($where_params, $update_params);
} }
return $res; return $res;
} }
...@@ -321,10 +345,10 @@ class SquareService ...@@ -321,10 +345,10 @@ class SquareService
public function addBComment($square_id, $comment, $agent_id, $agent_b, $agent_name) public function addBComment($square_id, $comment, $agent_id, $agent_b, $agent_name)
{ {
$insert["square_id"] = $square_id;//文章id $insert["square_id"] = $square_id;//文章id
$insert["comment"] = $comment;//评价内容 $insert["comment"] = $comment;//评价内容
$insert["agent_id"] = $agent_id;//评论人 $insert["agent_id"] = $agent_id;//评论人
$insert["sort"] = 0;//排序 0没排序 大于0表示置顶数值越大排行越高 $insert["sort"] = 0;//排序 0没排序 大于0表示置顶数值越大排行越高
$insert["is_del"] = 0;//是否删除 0正常 1删除 $insert["is_del"] = 0;//是否删除 0正常 1删除
// $insert["sort_time"] = $params["sort_time"];//置顶时间s // $insert["sort_time"] = $params["sort_time"];//置顶时间s
$res = $this->m_coment->saveComment($insert);//int(1) $res = $this->m_coment->saveComment($insert);//int(1)
...@@ -353,9 +377,9 @@ class SquareService ...@@ -353,9 +377,9 @@ class SquareService
$insert["comment_id"] = $comment_id;//comment_id $insert["comment_id"] = $comment_id;//comment_id
$insert["agent_id_a"] = $agent_id_a;//经纪人a 回复人 $insert["agent_id_a"] = $agent_id_a;//经纪人a 回复人
$insert["agent_id_b"] = $agent_id_b;//经纪人b被回复人 $insert["agent_id_b"] = $agent_id_b;//经纪人b被回复人
$insert["comment"] = $comment;//回复内容 $insert["comment"] = $comment;//回复内容
$insert["level"] = $level;//评论级别 1直接评论 2回复评论 $insert["level"] = $level;//评论级别 1直接评论 2回复评论
$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)
...@@ -376,16 +400,16 @@ class SquareService ...@@ -376,16 +400,16 @@ class SquareService
*/ */
public function getCommenInfo($params, $agent_id) public function getCommenInfo($params, $agent_id)
{ {
$field = 'Comment.id,Comment.comment,Comment.create_time,Comment.agent_id';// $field = 'Comment.id,Comment.comment,Comment.create_time,Comment.agent_id';//
$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);
$agent = $this->redis->getRedisCache(2, $res['agent_id']); $agent = $this->redis->getRedisCache(2, $res['agent_id']);
$res['name'] = $agent['name']; $res['name'] = $agent['name'];
$res['image_path'] = AGENTHEADERIMGURL . $agent['img']; $res['image_path'] = AGENTHEADERIMGURL . $agent['img'];
//用户置顶权限 //用户置顶权限
$res['user_competence'] = $this->userCompetence($agent_id); $res['user_competence'] = $this->userCompetence($agent_id);
$res['is_can_edit'] = 1;//兼容老版本 2019-04-22 $res['is_can_edit'] = 1;//兼容老版本 2019-04-22
return $res; return $res;
} }
...@@ -397,7 +421,7 @@ class SquareService ...@@ -397,7 +421,7 @@ class SquareService
*/ */
public function userCompetence($agent_id) public function userCompetence($agent_id)
{ {
$vip = new VipService();//0:有权限 1:无权限 $vip = new VipService();//0:有权限 1:无权限
$user_competence['set_top'] = $vip->vip($agent_id, 'SquareSetTop'); $user_competence['set_top'] = $vip->vip($agent_id, 'SquareSetTop');
return $user_competence; return $user_competence;
} }
...@@ -410,13 +434,13 @@ class SquareService ...@@ -410,13 +434,13 @@ class SquareService
public function editCommenSort($params) public function editCommenSort($params)
{ {
$where_params['id'] = $params['id']; $where_params['id'] = $params['id'];
$update_params = []; $update_params = [];
if (!isset($params['sort'])) { if (!isset($params['sort'])) {
return false; return false;
} }
$update_params['sort'] = $params['sort']; $update_params['sort'] = $params['sort'];
$res = $this->m_coment->updateStatus($where_params, $update_params); $res = $this->m_coment->updateStatus($where_params, $update_params);
return $res; return $res;
} }
...@@ -427,24 +451,24 @@ class SquareService ...@@ -427,24 +451,24 @@ class SquareService
*/ */
public function getSquareCommentExtList($params) public function getSquareCommentExtList($params)
{ {
$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.level,CommentExt.create_time,CommentExt.agent_id_a,CommentExt.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'];
$get_params['CommentExt.is_del'] = 0; $get_params['CommentExt.is_del'] = 0;
$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);
if ($res) { if ($res) {
foreach ($res as $key2 => $val2) { foreach ($res as $key2 => $val2) {
$agent_a = $this->redis->getRedisCache(2, $val2['agent_id_a']); $agent_a = $this->redis->getRedisCache(2, $val2['agent_id_a']);
$agent_b = $this->redis->getRedisCache(2, $val2['agent_id_b']); $agent_b = $this->redis->getRedisCache(2, $val2['agent_id_b']);
$res[$key2]['agent_name_a'] = $agent_a['name']; $res[$key2]['agent_name_a'] = $agent_a['name'];
$res[$key2]['agent_name_a_img'] = AGENTHEADERIMGURL . $agent_a['img']; $res[$key2]['agent_name_a_img'] = AGENTHEADERIMGURL . $agent_a['img'];
$res[$key2]['agent_name_b'] = $agent_b['name']; $res[$key2]['agent_name_b'] = $agent_b['name'];
$res[$key2]['agent_name_b_img'] = AGENTHEADERIMGURL . $agent_b['img']; $res[$key2]['agent_name_b_img'] = AGENTHEADERIMGURL . $agent_b['img'];
} }
} }
...@@ -460,8 +484,8 @@ class SquareService ...@@ -460,8 +484,8 @@ class SquareService
public function getCommenNum($id) public function getCommenNum($id)
{ {
$get_params['square_id'] = $id; $get_params['square_id'] = $id;
$get_params['is_del'] = 0; $get_params['is_del'] = 0;
$res = $this->m_coment->getCommenNum($get_params); $res = $this->m_coment->getCommenNum($get_params);
return $res; return $res;
} }
......
...@@ -137,7 +137,7 @@ class SquareSortService ...@@ -137,7 +137,7 @@ class SquareSortService
if ($total <= $page_size) { if ($total <= $page_size) {
$cream_list = $this->redis->zRange(self::SORT_KEY_CREAM . $site_id, 0, -1, true); $cream_list = $this->redis->zRange(self::SORT_KEY_CREAM . $site_id, 0, -1, true);
$list = $this->redis->zRange(self::SORT_KEY . $site_id, 0, -1, true); $list = $this->redis->zRange(self::SORT_KEY . $site_id, 0, -1, true);
$result = array_merge($cream_list, $list); $result = $cream_list + $list;
} elseif ($index_min <= $cream_num && $index_max <= $cream_num) { } elseif ($index_min <= $cream_num && $index_max <= $cream_num) {
$cream_list = $this->redis->zRange(self::SORT_KEY_CREAM . $site_id, $index_min, $page_size, true); $cream_list = $this->redis->zRange(self::SORT_KEY_CREAM . $site_id, $index_min, $page_size, true);
$result = $cream_list; $result = $cream_list;
...@@ -145,7 +145,7 @@ class SquareSortService ...@@ -145,7 +145,7 @@ class SquareSortService
$residue = $index_max - $cream_num; $residue = $index_max - $cream_num;
$cream_list = $this->redis->zRange(self::SORT_KEY_CREAM . $site_id, $index_min, -1, true); $cream_list = $this->redis->zRange(self::SORT_KEY_CREAM . $site_id, $index_min, -1, true);
$list = $this->redis->zRange(self::SORT_KEY . $site_id, 0, $residue, true); $list = $this->redis->zRange(self::SORT_KEY . $site_id, 0, $residue, true);
$result = array_merge($cream_list, $list); $result = $cream_list + $list;
} elseif ($index_min > $cream_num) { } elseif ($index_min > $cream_num) {
$index_ = $index_min - $cream_num; $index_ = $index_min - $cream_num;
$list = $this->redis->zRange(self::SORT_KEY . $site_id, $index_, $page_size, true); $list = $this->redis->zRange(self::SORT_KEY . $site_id, $index_, $page_size, true);
......
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