|
@@ -65,28 +65,6 @@ class Topicdongtai extends Api
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //详情
|
|
|
|
- public function info(){
|
|
|
|
- $id = input('id');
|
|
|
|
-
|
|
|
|
- $info = Db::name('topic_dongtai')->alias('dt')
|
|
|
|
- ->join('user','dt.user_id = user.id','LEFT')
|
|
|
|
- ->field('dt.*,user.nickname,user.avatar')
|
|
|
|
- ->where('dt.id',$id)->find();
|
|
|
|
- $info = info_domain_image($info,['images','avatar']);
|
|
|
|
-
|
|
|
|
- //是否点赞过
|
|
|
|
- if($info){
|
|
|
|
- $info['isgood'] = $this->is_good($id,$this->auth->id);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //评论
|
|
|
|
- if($info){
|
|
|
|
- $info['answer'] = $this->answer_list($id);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $this->success('success',$info);
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -157,70 +135,93 @@ class Topicdongtai extends Api
|
|
}
|
|
}
|
|
|
|
|
|
//评论列表
|
|
//评论列表
|
|
- private function answer_list($dt_id){
|
|
|
|
|
|
+ public function answer_list(){
|
|
|
|
+ $dt_id = input('dt_id',0);
|
|
//楼
|
|
//楼
|
|
$floor_list = Db::name('topic_dongtai_answer')
|
|
$floor_list = Db::name('topic_dongtai_answer')
|
|
->alias('a')
|
|
->alias('a')
|
|
- ->field('a.*,user.nickname,user.avatar')
|
|
|
|
|
|
+ ->field('a.*,user.username,user.nickname,user.avatar,user.gender,user.birthday,user.attribute,user.idcard_status')
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
- ->where(['a.dt_id'=>$dt_id,'a.level'=>1])->order('id asc')->autopage()->select();
|
|
|
|
|
|
+ ->where(['a.dt_id'=>$dt_id,'a.level'=>1])->order('a.id desc')->autopage()->select();
|
|
$floor_list = list_domain_image($floor_list,['avatar']);
|
|
$floor_list = list_domain_image($floor_list,['avatar']);
|
|
- if(empty($floor_list)){
|
|
|
|
- return [];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //层
|
|
|
|
- $floors = array_column($floor_list,'floor');
|
|
|
|
- $child_lists = Db::name('topic_dongtai_answer')->alias('a')
|
|
|
|
- ->field('a.*,user.nickname,user.avatar,tuser.nickname as to_nickname,tuser.avatar as to_avatar')
|
|
|
|
- ->join('user','a.user_id = user.id','LEFT')
|
|
|
|
- ->join('user tuser','a.to_user_id = tuser.id','LEFT')
|
|
|
|
- ->where(['a.dt_id'=>$dt_id,'a.floor'=>['IN',$floors],'a.level'=>2])->order('id asc')->select();
|
|
|
|
- $child_lists = list_domain_image($child_lists,['avatar','to_avatar']);
|
|
|
|
- /*if(empty($child_lists)){
|
|
|
|
- return $floor_list;
|
|
|
|
- }*/
|
|
|
|
|
|
|
|
- //合并
|
|
|
|
- foreach($floor_list as $key => $val){
|
|
|
|
- $child = [];
|
|
|
|
- foreach($child_lists as $k => $v){
|
|
|
|
- if($val['floor'] == $v['floor']){
|
|
|
|
- $child[] = $v;
|
|
|
|
|
|
+ //追加子评论
|
|
|
|
+ if(!empty($floor_list)){
|
|
|
|
+ foreach($floor_list as $key => &$val){
|
|
|
|
+ //下面几条子回复,字符串
|
|
|
|
+ $val['childremark'] = '';
|
|
|
|
+
|
|
|
|
+ $map = [
|
|
|
|
+ 'a.dt_id' => $dt_id,
|
|
|
|
+ 'a.floor' => $val['floor'],
|
|
|
|
+ 'a.level' => 2,
|
|
|
|
+ ];
|
|
|
|
+ $number = Db::name('topic_dongtai_answer')->alias('a')->where($map)->count();
|
|
|
|
+ if($number > 0){
|
|
|
|
+ $answer_info = Db::name('topic_dongtai_answer')
|
|
|
|
+ ->alias('a')
|
|
|
|
+ ->field('user.nickname')
|
|
|
|
+ ->join('user','a.user_id = user.id','LEFT')
|
|
|
|
+ ->where($map)->order('a.id desc')->find();
|
|
|
|
+
|
|
|
|
+ $val['childremark'] = $answer_info['nickname'].'...等人,共'.$number.'条回复';
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //追加到外循环
|
|
|
|
- $floor_list[$key]['childcount'] = 0;
|
|
|
|
|
|
|
|
- if(count($child) > 4){
|
|
|
|
- $floor_list[$key]['childcount'] = count($child) - 4;
|
|
|
|
|
|
+ //时间处理
|
|
|
|
+ $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
|
+
|
|
|
|
+ //回复是否已赞
|
|
|
|
+ $val['is_good'] = $this->answer_is_good($val['id'],$this->auth->id);
|
|
|
|
+
|
|
|
|
+ //用户年龄
|
|
|
|
+ $val['age'] = birthtime_to_age($val['birthday']);
|
|
|
|
+ unset($val['birthday']);
|
|
}
|
|
}
|
|
- $floor_list[$key]['child'] = array_slice($child,0,4);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- return $floor_list;
|
|
|
|
|
|
+ $this->success(1,$floor_list);
|
|
}
|
|
}
|
|
|
|
|
|
//单独某一层的详细
|
|
//单独某一层的详细
|
|
- public function floor_info(){
|
|
|
|
- $floor_id = input('floor_id');
|
|
|
|
|
|
+ public function answer_info(){
|
|
|
|
+ $answer_id = input('answer_id');
|
|
|
|
|
|
//楼
|
|
//楼
|
|
$floor_info = Db::name('topic_dongtai_answer')
|
|
$floor_info = Db::name('topic_dongtai_answer')
|
|
->alias('a')
|
|
->alias('a')
|
|
- ->field('a.*,user.nickname,user.avatar')
|
|
|
|
|
|
+ ->field('a.*,user.username,user.nickname,user.avatar,user.gender,user.birthday,user.attribute,user.idcard_status')
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
- ->where(['a.id'=>$floor_id])->find();
|
|
|
|
|
|
+ ->where(['a.id'=>$answer_id])->find();
|
|
|
|
+ if(empty($floor_info)){
|
|
|
|
+ $this->success(1,[]);
|
|
|
|
+ }
|
|
$floor_info = info_domain_image($floor_info,['avatar']);
|
|
$floor_info = info_domain_image($floor_info,['avatar']);
|
|
|
|
+ $floor_info['createtime_text'] = get_last_time($floor_info['createtime']);
|
|
|
|
+ //用户年龄
|
|
|
|
+ $floor_info['age'] = birthtime_to_age($floor_info['birthday']);
|
|
|
|
+ unset($floor_info['birthday']);
|
|
|
|
+ //回复是否已赞
|
|
|
|
+ $floor_info['is_good'] = $this->answer_is_good($answer_id,$this->auth->id);
|
|
|
|
+ $floor_info['answernumber'] = Db::name('topic_dongtai_answer')->where(['dt_id'=>$floor_info['dt_id'],'floor'=>$floor_info['floor'],'level'=>2])->count();
|
|
|
|
|
|
//层
|
|
//层
|
|
$floors = $floor_info['floor'];
|
|
$floors = $floor_info['floor'];
|
|
$child_lists = Db::name('topic_dongtai_answer')->alias('a')
|
|
$child_lists = Db::name('topic_dongtai_answer')->alias('a')
|
|
- ->field('a.*,user.nickname,user.avatar,tuser.nickname as to_nickname,tuser.avatar as to_avatar')
|
|
|
|
|
|
+ ->field('a.*,user.username,user.nickname,user.avatar,user.gender,user.birthday,user.attribute,user.idcard_status,tu.nickname as to_user_nickname')
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
- ->join('user tuser','a.to_user_id = tuser.id','LEFT')
|
|
|
|
- ->where(['a.floor'=>$floors,'a.level'=>2])->order('id asc')->autopage()->select();
|
|
|
|
|
|
+ ->join('user tu','a.to_user_id = tu.id','LEFT')
|
|
|
|
+ ->where(['a.dt_id'=>$floor_info['dt_id'],'a.floor'=>$floors,'a.level'=>2])->order('a.id desc')->autopage()->select();
|
|
$child_lists = list_domain_image($child_lists,['avatar','to_avatar']);
|
|
$child_lists = list_domain_image($child_lists,['avatar','to_avatar']);
|
|
|
|
+ if(!empty($child_lists)){
|
|
|
|
+ foreach($child_lists as $key => &$answer){
|
|
|
|
+ //用户年龄
|
|
|
|
+ $answer['age'] = birthtime_to_age($answer['birthday']);
|
|
|
|
+ unset($answer['birthday']);
|
|
|
|
+
|
|
|
|
+ $answer['is_good'] = $this->answer_is_good($answer['id'],$this->auth->id);
|
|
|
|
+ $answer['createtime_text'] = get_last_time($answer['createtime']);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
//合并
|
|
//合并
|
|
$floor_info['child'] = $child_lists;
|
|
$floor_info['child'] = $child_lists;
|
|
@@ -229,8 +230,86 @@ class Topicdongtai extends Api
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //对评论点赞
|
|
|
|
+ public function answer_good(){
|
|
|
|
+ $dt_id = input('dt_id',0);
|
|
|
|
+ $answer_id = input('answer_id',0);
|
|
|
|
|
|
|
|
+ $where = [
|
|
|
|
+ 'dt_id' => $dt_id,
|
|
|
|
+ 'answer_id' => $answer_id,
|
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
|
+ ];
|
|
|
|
+ $check = Db::name('topic_answer_good')->where($where)->find();
|
|
|
|
|
|
|
|
+ if($check){
|
|
|
|
+ Db::name('topic_answer_good')->where($where)->delete();
|
|
|
|
+ Db::name('topic_dongtai_answer')->where('id',$answer_id)->setDec('goodnum');
|
|
|
|
+ $this->success('已取消点赞');
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ Db::startTrans();
|
|
|
|
+ $where['createtime'] = time();
|
|
|
|
+ $rs = Db::name('topic_answer_good')->insertGetId($where);
|
|
|
|
+ $up = Db::name('topic_dongtai_answer')->where('id',$answer_id)->setInc('goodnum');
|
|
|
|
+
|
|
|
|
+ if($rs && $up !== false){
|
|
|
|
+ Db::commit();
|
|
|
|
+ $this->success('点赞成功');
|
|
|
|
+ }
|
|
|
|
+ Db::rollback();
|
|
|
|
+ $this->error('点赞失败');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //回复是否点赞
|
|
|
|
+ private function answer_is_good($answer_id,$uid){
|
|
|
|
+ $where = [
|
|
|
|
+ 'answer_id' => $answer_id,
|
|
|
|
+ 'user_id' => $uid,
|
|
|
|
+ ];
|
|
|
|
+ $check = Db::name('topic_answer_good')->where($where)->find();
|
|
|
|
+ if($check){
|
|
|
|
+ return 1;
|
|
|
|
+ }else{
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //删除我的某个评论
|
|
|
|
+ public function delete_answer(){
|
|
|
|
+ $id = input('id',0);
|
|
|
|
+ if(!$id){
|
|
|
|
+ $this->error();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Db::startTrans();
|
|
|
|
+ $info = Db::name('topic_dongtai_answer')->where('id',$id)->where('user_id',$this->auth->id)->find();
|
|
|
|
+ if(!$info){
|
|
|
|
+ $this->error('不存在的动态评论');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($info['level'] == 1){
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //楼层内都删
|
|
|
|
+ $louceng_id = Db::name('topic_dongtai_answer')->where('dt_id',$info['dt_id'])->where('level',2)->where('floor',$info['floor'])->column('id');
|
|
|
|
+ if(!empty($louceng_id)){
|
|
|
|
+ Db::name('topic_dongtai')->where('id',$info['dt_id'])->setDec('answernum',count($louceng_id));//回复数减1
|
|
|
|
+ Db::name('topic_dongtai_answer')->where('id','IN',$louceng_id)->delete();//评论删掉
|
|
|
|
+ Db::name('topic_answer_good')->where('answer_id','IN',$louceng_id)->delete();//评论点赞删掉
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Db::name('topic_dongtai')->where('id',$info['dt_id'])->setDec('answernum');//回复数减1
|
|
|
|
+ Db::name('topic_dongtai_answer')->where('id',$id)->delete(); //评论删掉
|
|
|
|
+ Db::name('topic_answer_good')->where('answer_id',$id)->delete();//评论点赞删掉
|
|
|
|
+
|
|
|
|
+ Db::commit();
|
|
|
|
+
|
|
|
|
+ $this->success();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
//发布动态
|
|
//发布动态
|
|
@@ -432,7 +511,7 @@ class Topicdongtai extends Api
|
|
$info = Db::name('topic_dongtai')->alias('dt')
|
|
$info = Db::name('topic_dongtai')->alias('dt')
|
|
->join('user','dt.user_id = user.id','LEFT')
|
|
->join('user','dt.user_id = user.id','LEFT')
|
|
->join('topic_hub th','dt.topic_id = th.id','LEFT')
|
|
->join('topic_hub th','dt.topic_id = th.id','LEFT')
|
|
- ->field('dt.*,user.nickname,user.avatar,user.gender,user.birthday,user.cityname,user.is_hideaddress,th.name,user.real_status')
|
|
|
|
|
|
+ ->field('dt.*,user.nickname,user.avatar,user.gender,user.birthday,user.idcard_status,user.is_hideaddress,th.name,user.real_status')
|
|
->where('dt.id',$id)->find();
|
|
->where('dt.id',$id)->find();
|
|
if (!$info) {
|
|
if (!$info) {
|
|
$this->error('您的网络开小差啦~');
|
|
$this->error('您的网络开小差啦~');
|
|
@@ -442,6 +521,7 @@ class Topicdongtai extends Api
|
|
}
|
|
}
|
|
|
|
|
|
$info = info_domain_image($info,['images','avatar']);
|
|
$info = info_domain_image($info,['images','avatar']);
|
|
|
|
+ $info['name'] = $info['name'] ? : '';
|
|
$info['birthday'] = birthtime_to_age($info['birthday']);
|
|
$info['birthday'] = birthtime_to_age($info['birthday']);
|
|
$info['createtime'] = get_last_time($info['createtime']);
|
|
$info['createtime'] = get_last_time($info['createtime']);
|
|
$info['cityname'] = $info['is_hideaddress'] ? '' : $info['address'];
|
|
$info['cityname'] = $info['is_hideaddress'] ? '' : $info['address'];
|
|
@@ -457,7 +537,7 @@ class Topicdongtai extends Api
|
|
$info['is_chat'] = 0; //是否打过招呼: 1是 0否
|
|
$info['is_chat'] = 0; //是否打过招呼: 1是 0否
|
|
}
|
|
}
|
|
//查询财富等级和魅力等级
|
|
//查询财富等级和魅力等级
|
|
- $wallet_info = Db::name('user_wallet')->where(['user_id' => $info['user_id']])->find();
|
|
|
|
|
|
+ /* $wallet_info = Db::name('user_wallet')->where(['user_id' => $info['user_id']])->find();
|
|
$wealth_level = Db::name('wealth_level')->where(['value' => ['elt', $wallet_info['pay_money']]])->order('id desc')->find();
|
|
$wealth_level = Db::name('wealth_level')->where(['value' => ['elt', $wallet_info['pay_money']]])->order('id desc')->find();
|
|
if ($wealth_level) {
|
|
if ($wealth_level) {
|
|
$info['wealth_level'] = localpath_to_netpath($wealth_level['image']);
|
|
$info['wealth_level'] = localpath_to_netpath($wealth_level['image']);
|
|
@@ -469,7 +549,7 @@ class Topicdongtai extends Api
|
|
$info['charm_level'] = localpath_to_netpath($charm_level['image']);
|
|
$info['charm_level'] = localpath_to_netpath($charm_level['image']);
|
|
} else {
|
|
} else {
|
|
$info['charm_level'] = '';
|
|
$info['charm_level'] = '';
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
//创建视频缩略图
|
|
//创建视频缩略图
|
|
$info['images_thumb'] = '';
|
|
$info['images_thumb'] = '';
|
|
if ($info['type'] == 2) {
|
|
if ($info['type'] == 2) {
|
|
@@ -478,6 +558,7 @@ class Topicdongtai extends Api
|
|
$info['images_thumb'] = join('.', $images_url) . '_0.jpg';
|
|
$info['images_thumb'] = join('.', $images_url) . '_0.jpg';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
$this->success('success',$info);
|
|
$this->success('success',$info);
|
|
}
|
|
}
|
|
|
|
|