Commit 684583d3 authored by clone's avatar clone

1

parent 789aed54
......@@ -16,14 +16,14 @@ class SquareService
public function __construct()
{
$this->m_square = new BSquare();
$this->m_coment = new BComment();
$this->m_square = new BSquare();
$this->m_coment = new BComment();
$this->m_coment_ext = new BCommentExt();
$this->redis = new RedisCacheService();
$this->redis = new RedisCacheService();
if (CURRENT_URL == 'https://api.tonglianjituan.com/') {
$this->internet_path = IMAGES_URL.'resource/lib/Attachments/images/';
}else {
$this->internet_path = IMAGES_URL . 'resource/lib/Attachments/images/';
} else {
$this->internet_path = 'http://pre2.tonglianjituan.com/resource/lib/Attachments/images/';
}
}
......@@ -32,17 +32,18 @@ class SquareService
* 文章部门
* @return array
*/
public function getDistrictLable(){
$res[]=['id'=>0,'name'=>'全部'];
$res[]=['id'=>1,'name'=>'一部'];
$res[]=['id'=>2,'name'=>'二部'];
$res[]=['id'=>3,'name'=>'三部'];
$res[]=['id'=>4,'name'=>'四部'];
$res[]=['id'=>5,'name'=>'五部'];
$res[]=['id'=>6,'name'=>'六部'];
$res[]=['id'=>7,'name'=>'七部'];
$res[]=['id'=>8,'name'=>'八部'];
$res[]=['id'=>9,'name'=>'九部'];
public function getDistrictLable()
{
$res[] = ['id' => 0, 'name' => '全部'];
$res[] = ['id' => 1, 'name' => '一部'];
$res[] = ['id' => 2, 'name' => '二部'];
$res[] = ['id' => 3, 'name' => '三部'];
$res[] = ['id' => 4, 'name' => '四部'];
$res[] = ['id' => 5, 'name' => '五部'];
$res[] = ['id' => 6, 'name' => '六部'];
$res[] = ['id' => 7, 'name' => '七部'];
$res[] = ['id' => 8, 'name' => '八部'];
$res[] = ['id' => 9, 'name' => '九部'];
// $res[]=['id'=>10,'name'=>'十部'];
return $res;
}
......@@ -58,21 +59,21 @@ class SquareService
* @param $district_id
* @return bool
*/
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["title"] = $title;//标题
$insert["house_id"] = $house_id;//楼盘id
$insert["content"] = $content;//text
$insert["cover_img"] = $cover_img;//封面图
$insert["site_id"] = $site_id;//站点id
$insert["agent_id"] = $agent_id;//经纪人id
$insert["title"] = $title;//标题
$insert["house_id"] = $house_id;//楼盘id
$insert["content"] = $content;//text
$insert["cover_img"] = $cover_img;//封面图
$insert["site_id"] = $site_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)
if($res == 1){
if ($res == 1) {
return true;
}else{
} else {
return false;
}
}
......@@ -82,13 +83,14 @@ class SquareService
* @param $params
* @return array
*/
public function getSquareList($params){
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
public function getSquareList($params)
{
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
//搜索 时间
if (!empty($params['start_date']) && !empty($params['end_date'])) {
$get_params['Square.create_time'] = [ 'between time', [ $params['start_date'] . ' 00:00:00', $params['end_date'] . ' 23:59:59' ] ];
$get_params['Square.create_time'] = ['between time', [$params['start_date'] . ' 00:00:00', $params['end_date'] . ' 23:59:59']];
}
//城市
......@@ -101,7 +103,7 @@ class SquareService
}
//文章标题
if (!empty($params['title'])) {
$get_params['Square.title'] = [ 'LIKE', '%' . $params['title'] . '%' ];
$get_params['Square.title'] = ['LIKE', '%' . $params['title'] . '%'];
}
$field = 'Square.id,';
......@@ -113,12 +115,12 @@ class SquareService
$field .= 'Square.create_time';//发布时间
$get_params['Square.status'] = 0;
$res = $this->m_square->getSquareList($pageNo, $pageSize, $field, $get_params);
$res_total = $this->m_square->getSquareListTotal($field, $get_params);
$res = $this->m_square->getSquareList($pageNo, $pageSize, $field, $get_params);
$res_total = $this->m_square->getSquareListTotal($field, $get_params);
foreach ($res as $key => $val) {
$agent = $this->redis->getRedisCache(2, $val['agent_id']) ;
$res[$key]['name'] = $agent['name'];
$agent = $this->redis->getRedisCache(2, $val['agent_id']);
$res[$key]['name'] = $agent['name'];
$res[$key]['image_path'] = AGENTHEADERIMGURL . $agent['img'];
//部门标签
......@@ -130,13 +132,14 @@ class SquareService
$res[$key]['cover_img_path'] = $val['cover_img'] ? $this->internet_path . $val['cover_img'] : '';
}
return [ 'data' => $res, 'total' => $res_total ];
return ['data' => $res, 'total' => $res_total];
}
public function getSquareCommentList($params){
public function getSquareCommentList($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'];
$field = 'Comment.id,';
......@@ -146,38 +149,38 @@ class SquareService
$field .= 'Comment.create_time';
$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);
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]['img'] = AGENTHEADERIMGURL . $agent['img'];
$res[$key]['img'] = AGENTHEADERIMGURL . $agent['img'];
$get_params = [];
$field = 'CommentExt.id,CommentExt.level,CommentExt.comment,CommentExt.agent_id_a,CommentExt.agent_id_b';//
$get_params = [];
$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.is_del'] = 0;
$get_params['CommentExt.is_del'] = 0;
$res[$key]['comment_ext']['total']= $this->m_coment_ext->getSquareCommentExtListTotal($field,$get_params);
$list = $this->m_coment_ext->getSquareCommentExtList(1, 2, $field, $get_params);
if($list){
$res[$key]['comment_ext']['total'] = $this->m_coment_ext->getSquareCommentExtListTotal($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'];
$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;
$res[$key]['comment_ext']['list'] = $list;
}
return [ 'data' => $res, 'total' => $res_total ];
return ['data' => $res, 'total' => $res_total];
}
/**
......@@ -186,7 +189,10 @@ class SquareService
* @param $agent_id
* @return array|false|\PDOStatement|string|\think\Model
*/
public function getSquareInfo($params,$agent_id){
public function getSquareInfo($params, $agent_id)
{
$squareSort = new SquareSortService();
$squareSort->setCream($params["id"], $agent_id);
$field = 'Square.id,';
$field .= 'Square.title,';
......@@ -212,18 +218,18 @@ class SquareService
$field .= 'house.status,';
$field .= 'house.industry_type';
// $get_params['house.status'] = 1;//上架的商铺
// $get_params['house.status'] = 1;//上架的商铺
$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']);
$agent = $this->redis->getRedisCache(2, $res['agent_id']) ;
$agent = $this->redis->getRedisCache(2, $res['agent_id']);
$res['name'] = $agent['name'];
//用户置顶权限
$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;
}
......@@ -233,15 +239,15 @@ class SquareService
switch ($params['type']) {
case 0:
$update_params['is_del'] = 1;
$res = $this->m_coment->updateStatus($where_params,$update_params);
$res = $this->m_coment->updateStatus($where_params, $update_params);
break;
case 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;
default:
$update_params['status'] = 1;
$res = $this->m_square->updateStatus($where_params,$update_params);
$res = $this->m_square->updateStatus($where_params, $update_params);
}
return $res;
}
......@@ -271,7 +277,7 @@ class SquareService
if (!empty($params['house_id'])) {
$update_params['house_id'] = $params['house_id'];
}
if(!$update_params){
if (!$update_params) {
return false;
}
......@@ -280,42 +286,41 @@ 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["comment"] = $comment;//评价内容
$insert["agent_id"] = $agent_id;//评论人
$insert["sort"] = 0;//排序 0没排序 大于0表示置顶数值越大排行越高
$insert["is_del"] = 0;//是否删除 0正常 1删除
$insert["square_id"] = $square_id;//文章id
$insert["comment"] = $comment;//评价内容
$insert["agent_id"] = $agent_id;//评论人
$insert["sort"] = 0;//排序 0没排序 大于0表示置顶数值越大排行越高
$insert["is_del"] = 0;//是否删除 0正常 1删除
// $insert["sort_time"] = $params["sort_time"];//置顶时间s
$res = $this->m_coment->saveComment($insert);//int(1)
if($res == 1){
if ($res == 1) {
$push_service = new PushMessageService();
$push_service->record(10, $square_id, [$agent_b], $agent_id, ['message'=>$agent_name .'评论了你的开盘']);
$push_service->record(10, $square_id, [$agent_b], $agent_id, ['message' => $agent_name . '评论了你的开盘']);
return true;
}else{
} else {
return false;
}
}
public function addBCommentExt($comment_id,$agent_id_a,$agent_id_b,$comment,$level, $agent_name, $square_id)
public function addBCommentExt($comment_id, $agent_id_a, $agent_id_b, $comment, $level, $agent_name, $square_id)
{
$insert["comment_id"] = $comment_id;//comment_id
$insert["agent_id_a"] = $agent_id_a;//经纪人a 回复人
$insert["agent_id_b"] = $agent_id_b;//经纪人b被回复人
$insert["comment"] = $comment;//回复内容
$insert["level"] = $level;//评论级别 1直接评论 2回复评论
$insert["is_del"] = 0;//是否删除 0正常 1删除
$insert["comment_id"] = $comment_id;//comment_id
$insert["agent_id_a"] = $agent_id_a;//经纪人a 回复人
$insert["agent_id_b"] = $agent_id_b;//经纪人b被回复人
$insert["comment"] = $comment;//回复内容
$insert["level"] = $level;//评论级别 1直接评论 2回复评论
$insert["is_del"] = 0;//是否删除 0正常 1删除
$res = $this->m_coment_ext->saveCommentExt($insert);//int(1)
if($res == 1){
if ($res == 1) {
$push_service = new PushMessageService();
$push_service->record(11, $square_id, [$agent_id_a], $agent_id_b, ['message'=>$agent_name .'回复了你的开盘评论']);
$push_service->record(11, $square_id, [$agent_id_a], $agent_id_b, ['message' => $agent_name . '回复了你的开盘评论']);
return true;
}else{
} else {
return false;
}
}
......@@ -326,17 +331,18 @@ class SquareService
* @param $agent_id
* @return array|false|\PDOStatement|string|\think\Model
*/
public function getCommenInfo($params,$agent_id){
$field = 'Comment.id,Comment.comment,Comment.create_time,Comment.agent_id';//
public function getCommenInfo($params, $agent_id)
{
$field = 'Comment.id,Comment.comment,Comment.create_time,Comment.agent_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']) ;
$res['name'] = $agent['name'];
$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';
//用户置顶权限
$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;
}
......@@ -346,8 +352,9 @@ class SquareService
* @param $agent_id
* @return mixed
*/
public function userCompetence($agent_id){
$vip = new VipService();//0:有权限 1:无权限
public function userCompetence($agent_id)
{
$vip = new VipService();//0:有权限 1:无权限
$user_competence['set_top'] = $vip->vip($agent_id, 'SquareSetTop');
return $user_competence;
}
......@@ -360,40 +367,41 @@ class SquareService
public function editCommenSort($params)
{
$where_params['id'] = $params['id'];
$update_params = [];
$update_params = [];
if (!isset($params['sort'])) {
return false;
}
$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;
}
public function getSquareCommentExtList($params){
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
public function getSquareCommentExtList($params)
{
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$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';//
$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);
if($res){
if ($res) {
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'];
$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_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'];
}
}
return [ 'data' => $res, 'total' => $res_total ];
return ['data' => $res, 'total' => $res_total];
}
/**
......@@ -401,10 +409,11 @@ class SquareService
* @param $id
* @return int|string
*/
public function getCommenNum($id){
public function getCommenNum($id)
{
$get_params['square_id'] = $id;
$get_params['is_del'] = 0;
$res = $this->m_coment->getCommenNum($get_params);
$get_params['is_del'] = 0;
$res = $this->m_coment->getCommenNum($get_params);
return $res;
}
......@@ -414,9 +423,10 @@ class SquareService
* @param $district_lable_id
* @return string
*/
public function getDistrictLableName($district_lable_id){
public function getDistrictLableName($district_lable_id)
{
foreach ($this->getDistrictLable() as $k => $v) {
if($district_lable_id == $v['id']){
if ($district_lable_id == $v['id']) {
return $v['name'];
continue;
}
......
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