|
@@ -15,42 +15,6 @@ class Topicdongtai extends Api
|
|
|
|
|
|
|
|
|
|
|
|
- //自己看列表
|
|
|
- //某用户的帖子列表
|
|
|
- public function my_lists(){
|
|
|
-
|
|
|
- $uid = input('uid',$this->auth->id);
|
|
|
- $list = Db::name('topic_dongtai')->alias('dt')
|
|
|
- ->join('user','dt.user_id = user.id','LEFT')
|
|
|
- ->field('dt.*,user.nickname,user.avatar')
|
|
|
- ->where('dt.user_id',$uid)
|
|
|
- ->order('dt.id desc')->autopage()->select();
|
|
|
- $list = list_domain_image($list,['images','avatar']);
|
|
|
-
|
|
|
- if(!empty($list)){
|
|
|
- foreach($list as $key => $val){
|
|
|
- $list[$key]['isgood'] = $this->is_good($val['id'],$this->auth->id);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('success',$list);
|
|
|
- }
|
|
|
-
|
|
|
- //我回复的帖子列表
|
|
|
- public function answer_dt_lists(){
|
|
|
- $map = [
|
|
|
- 'answer.user_id' => $this->auth->id,
|
|
|
- 'answer.level' => 1,
|
|
|
- ];
|
|
|
- $lists = Db::name('topic_dongtai_answer')->alias('answer')
|
|
|
- ->field('answer.id,answer.content as answer_content,answer.createtime,user.nickname,user.avatar,dt.id as dt_id,dt.content as dt_content')
|
|
|
- ->join('user','answer.user_id = user.id','LEFT')
|
|
|
- ->join('topic_dongtai dt','answer.dt_id = dt.id','LEFT')
|
|
|
- ->where($map)->autopage()->select();
|
|
|
-
|
|
|
- $this->success('success',$lists);
|
|
|
- }
|
|
|
-
|
|
|
//是否点赞
|
|
|
private function is_good($dt_id,$uid){
|
|
|
$where = [
|
|
@@ -88,6 +52,22 @@ class Topicdongtai extends Api
|
|
|
$this->error('楼层错误');
|
|
|
}
|
|
|
|
|
|
+ //黑名单判断
|
|
|
+ //是否被动态发布者拉黑
|
|
|
+ $dongtai_user_id = Db::name('topic_dongtai')->where('id',$id)->value('user_id');
|
|
|
+ $black_check = $this->is_black($dongtai_user_id,$this->auth->id);
|
|
|
+ if($black_check){
|
|
|
+ $this->error('您已被对方拉黑,禁止评论此动态');
|
|
|
+ }
|
|
|
+ //是否被层主拉黑
|
|
|
+ if($level == 2){
|
|
|
+ $answer_info = Db::name('topic_dongtai_answer')->where(['dt_id'=>$id,'level'=>1,'floor'=>$floor])->find();
|
|
|
+ $black_check = $this->is_black($answer_info['user_id'],$this->auth->id);
|
|
|
+ if($black_check){
|
|
|
+ $this->error('您已被对方拉黑,禁止点评此评论');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//回复楼主,最新楼层
|
|
|
if($level == 1 || $floor == 0){
|
|
|
$to_user_id = 0;
|
|
@@ -122,25 +102,52 @@ class Topicdongtai extends Api
|
|
|
Db::startTrans();
|
|
|
$rs = Db::name('topic_dongtai_answer')->insertGetId($data);
|
|
|
|
|
|
- //tag任务赠送金币
|
|
|
- //评论奖励
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,13);
|
|
|
- if($task_rs === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('完成任务赠送奖励失败');
|
|
|
+ if($level == 1){
|
|
|
+ Db::name('topic_dongtai')->where('id',$id)->setInc('answernum');
|
|
|
}
|
|
|
|
|
|
+ //系统消息
|
|
|
+ if($level == 1){
|
|
|
+ //发给动态用户
|
|
|
+ $msg_user_id = Db::name('topic_dongtai')->where('id',$id)->value('user_id');
|
|
|
+ $msg_title = '动态评论';
|
|
|
+ $msg_content = $this->auth->nickname.'评论了你的动态';
|
|
|
+ $infotype_id = $rs;
|
|
|
+ }else{
|
|
|
+ //发给层主
|
|
|
+ $answer_info = Db::name('topic_dongtai_answer')->where(['dt_id'=>$id,'level'=>1,'floor'=>$floor])->find();
|
|
|
+ $msg_user_id = $answer_info['user_id'];
|
|
|
+ $msg_title = '动态评论点评';
|
|
|
+ $msg_content = $this->auth->nickname.'点评了你的动态评论';
|
|
|
+ $infotype_id = $answer_info['id'];
|
|
|
+ }
|
|
|
+ $msg_id = \app\common\model\Message::addMessage($msg_user_id,$msg_title,$msg_content,'dongtai_answer',$infotype_id);
|
|
|
+
|
|
|
Db::commit();
|
|
|
$this->success('评价成功');
|
|
|
}
|
|
|
|
|
|
- //评论列表
|
|
|
+ //用户是否拉黑
|
|
|
+ private function is_black($uid,$black_uid){
|
|
|
+ $where = [
|
|
|
+ 'uid' => $uid,
|
|
|
+ 'black_uid' => $black_uid,
|
|
|
+ ];
|
|
|
+ $check = Db::name('user_black')->where($where)->find();
|
|
|
+ if($check){
|
|
|
+ return 1;
|
|
|
+ }else{
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //某动态的评论列表
|
|
|
public function answer_list(){
|
|
|
- $dt_id = input('dt_id',0);
|
|
|
+ $dt_id = input('id',0);
|
|
|
//楼
|
|
|
$floor_list = Db::name('topic_dongtai_answer')
|
|
|
->alias('a')
|
|
|
- ->field('a.*,user.username,user.nickname,user.avatar,user.gender,user.birthday,user.attribute,user.idcard_status')
|
|
|
+ ->field('a.*,user.nickname,user.avatar,user.gender,user.birthday')
|
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
|
->where(['a.dt_id'=>$dt_id,'a.level'=>1])->order('a.id desc')->autopage()->select();
|
|
|
$floor_list = list_domain_image($floor_list,['avatar']);
|
|
@@ -168,14 +175,13 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
|
|
|
//时间处理
|
|
|
- $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
+ $val['createtime'] = 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']);
|
|
|
+ $val['birthday'] = birthtime_to_age($val['birthday']);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -189,17 +195,16 @@ class Topicdongtai extends Api
|
|
|
//楼
|
|
|
$floor_info = Db::name('topic_dongtai_answer')
|
|
|
->alias('a')
|
|
|
- ->field('a.*,user.username,user.nickname,user.avatar,user.gender,user.birthday,user.attribute,user.idcard_status')
|
|
|
+ ->field('a.*,user.nickname,user.avatar,user.gender,user.birthday')
|
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
|
->where(['a.id'=>$answer_id])->find();
|
|
|
if(empty($floor_info)){
|
|
|
$this->success(1,[]);
|
|
|
}
|
|
|
$floor_info = info_domain_image($floor_info,['avatar']);
|
|
|
- $floor_info['createtime_text'] = get_last_time($floor_info['createtime']);
|
|
|
+ $floor_info['createtime'] = get_last_time($floor_info['createtime']);
|
|
|
//用户年龄
|
|
|
- $floor_info['age'] = birthtime_to_age($floor_info['birthday']);
|
|
|
- unset($floor_info['birthday']);
|
|
|
+ $floor_info['birthday'] = birthtime_to_age($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();
|
|
@@ -207,19 +212,17 @@ class Topicdongtai extends Api
|
|
|
//层
|
|
|
$floors = $floor_info['floor'];
|
|
|
$child_lists = Db::name('topic_dongtai_answer')->alias('a')
|
|
|
- ->field('a.*,user.username,user.nickname,user.avatar,user.gender,user.birthday,user.attribute,user.idcard_status,tu.nickname as to_user_nickname')
|
|
|
+ ->field('a.*,user.nickname,user.avatar,user.gender,user.birthday')
|
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
|
- ->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']);
|
|
|
if(!empty($child_lists)){
|
|
|
foreach($child_lists as $key => &$answer){
|
|
|
//用户年龄
|
|
|
- $answer['age'] = birthtime_to_age($answer['birthday']);
|
|
|
- unset($answer['birthday']);
|
|
|
+ $answer['birthday'] = birthtime_to_age($answer['birthday']);
|
|
|
|
|
|
$answer['is_good'] = $this->answer_is_good($answer['id'],$this->auth->id);
|
|
|
- $answer['createtime_text'] = get_last_time($answer['createtime']);
|
|
|
+ $answer['createtime'] = get_last_time($answer['createtime']);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -431,8 +434,9 @@ class Topicdongtai extends Api
|
|
|
|
|
|
$list = Db::name('topic_dongtai')->alias('dt')
|
|
|
->join('user','dt.user_id = user.id','LEFT')
|
|
|
+ ->join('user_wallet uw','user.id = uw.user_id','LEFT')
|
|
|
->join('topic_hub th','dt.topic_id = th.id','LEFT')
|
|
|
- ->field('dt.*,user.nickname,user.avatar,user.gender,user.birthday,user.idcard_status,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,uw.vip_endtime')
|
|
|
->where($where)
|
|
|
->where($where_follow)
|
|
|
->order($orderby)->autopage()->select();
|
|
@@ -449,15 +453,15 @@ class Topicdongtai extends Api
|
|
|
$mt_user_greet = Db::name('user_greet'); //是否打过招呼
|
|
|
$mt_gift_user_dongtai = Db::name('gift_user_dongtai');
|
|
|
|
|
|
- //vip用户
|
|
|
- $user_vip = Db::name('user_wallet')->where('user_id','IN',array_column($list,'user_id'))->where('vip_endtime','gt',time())->column('user_id');
|
|
|
-
|
|
|
foreach ($list as &$val) {
|
|
|
$val['name'] = $val['name'] ? : '';
|
|
|
$val['birthday'] = birthtime_to_age($val['birthday']);
|
|
|
$val['createtime'] = get_last_time($val['createtime']);
|
|
|
$val['cityname'] = $val['is_hideaddress'] ? '' : $val['address'] ;
|
|
|
- $val['is_vip'] = in_array($val['user_id'],$user_vip) ? 1 : 0;
|
|
|
+ //用户vip
|
|
|
+ $val['is_vip'] = $val['vip_endtime'] > time() ? 1 : 0;
|
|
|
+ unset($val['vip_endtime']);
|
|
|
+
|
|
|
//是否点过赞:0否 1是
|
|
|
$val['isgood'] = 0;
|
|
|
foreach($good_list as $k => $v){
|
|
@@ -541,7 +545,7 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
|
|
|
//点赞
|
|
|
- public function dongtaigood(){
|
|
|
+ public function good(){
|
|
|
$id = input('id', 0, 'intval');
|
|
|
if (!$id) {
|
|
|
$this->error('您的网络开小差啦~');
|
|
@@ -559,30 +563,36 @@ class Topicdongtai extends Api
|
|
|
'user_id' => $this->auth->id,
|
|
|
];
|
|
|
$check = Db::name('topic_dongtai_good')->where($where)->find();
|
|
|
+ $dt_user_id = Db::name('topic_dongtai')->where('id',$id)->value('user_id');
|
|
|
|
|
|
if($check){
|
|
|
- $this->error('已经赞过了');
|
|
|
- }
|
|
|
+ Db::name('topic_dongtai_good')->where($where)->delete();
|
|
|
+ $down = Db::name('topic_dongtai')->where('id',$id)->setDec('goodnum');
|
|
|
+ $this->success('已取消点赞');
|
|
|
+ }else{
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ $where['createtime'] = time();
|
|
|
+ $rs = Db::name('topic_dongtai_good')->insertGetId($where);
|
|
|
+ if(!$rs){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('点赞失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ $up = Db::name('topic_dongtai')->where('id',$id)->setInc('goodnum');
|
|
|
+ if($up === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('点赞失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ //系统消息
|
|
|
+ /*if($dt_user_id != $this->auth->id){
|
|
|
+ $msg_id = \app\common\model\Message::addMessage($dt_user_id,'动态点赞',$this->auth->nickname.'赞了你的动态','dongtai_good',$id);
|
|
|
+ }*/
|
|
|
|
|
|
- $where['createtime'] = time();
|
|
|
- Db::startTrans();
|
|
|
- $rs = Db::name('topic_dongtai_good')->insertGetId($where);
|
|
|
- $up = Db::name('topic_dongtai')->where('id',$id)->setInc('goodnum');
|
|
|
-
|
|
|
- //tag任务赠送金币
|
|
|
- //点赞奖励
|
|
|
-// $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,14);
|
|
|
-// if($task_rs === false){
|
|
|
-// Db::rollback();
|
|
|
-// $this->error('完成任务赠送奖励失败');
|
|
|
-// }
|
|
|
-
|
|
|
- if($rs && $up !== false){
|
|
|
Db::commit();
|
|
|
$this->success('点赞成功');
|
|
|
}
|
|
|
- Db::rollback();
|
|
|
- $this->error('点赞失败');
|
|
|
}
|
|
|
|
|
|
//点赞列表
|
|
@@ -828,8 +838,9 @@ class Topicdongtai extends Api
|
|
|
|
|
|
$list = Db::name('topic_dongtai')->alias('dt')
|
|
|
->join('user','dt.user_id = user.id','LEFT')
|
|
|
+ ->join('user_wallet uw','user.id = uw.user_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.is_hideaddress,th.name,user.real_status,user.idcard_status,uw.vip_endtime')
|
|
|
->where($where)
|
|
|
->order($orderby)->autopage()->select();
|
|
|
$list = list_domain_image($list,['images','avatar']);
|
|
@@ -844,14 +855,17 @@ class Topicdongtai extends Api
|
|
|
$good_list = Db::name('topic_dongtai_good')->where($map)->select();
|
|
|
$mt_user_greet = Db::name('user_greet'); //是否打过招呼
|
|
|
$mt_gift_user_dongtai = Db::name('gift_user_dongtai');
|
|
|
- $mt_user_wallet = Db::name('user_wallet'); //钱包
|
|
|
- $mt_wealth_level = Db::name('wealth_level'); //财富等级
|
|
|
- $mt_charm_level = Db::name('charm_level'); //魅力等级
|
|
|
+
|
|
|
|
|
|
foreach ($list as &$val) {
|
|
|
$val['birthday'] = birthtime_to_age($val['birthday']);
|
|
|
$val['createtime'] = get_last_time($val['createtime']);
|
|
|
$val['cityname'] = $val['is_hideaddress'] ? '' : $val['address'];
|
|
|
+
|
|
|
+ //用户vip
|
|
|
+ $val['is_vip'] = $val['vip_endtime'] > time() ? 1 : 0;
|
|
|
+ unset($val['vip_endtime']);
|
|
|
+
|
|
|
//是否点过赞:0否 1是
|
|
|
$val['isgood'] = 0;
|
|
|
foreach($good_list as $k => $v){
|
|
@@ -868,20 +882,6 @@ class Topicdongtai extends Api
|
|
|
} else {
|
|
|
$val['is_chat'] = 0; //是否打过招呼: 1是 0否
|
|
|
}
|
|
|
- //查询财富等级和魅力等级
|
|
|
- $wallet_info = $mt_user_wallet->where(['user_id' => $val['user_id']])->find();
|
|
|
- $wealth_level = $mt_wealth_level->where(['value' => ['elt', $wallet_info['pay_money']]])->order('id desc')->find();
|
|
|
- if ($wealth_level) {
|
|
|
- $val['wealth_level'] = localpath_to_netpath($wealth_level['image']);
|
|
|
- } else {
|
|
|
- $val['wealth_level'] = '';
|
|
|
- }
|
|
|
- $charm_level = $mt_charm_level->where(['value' => ['elt', $wallet_info['get_money']]])->order('id desc')->find();
|
|
|
- if ($charm_level) {
|
|
|
- $val['charm_level'] = localpath_to_netpath($charm_level['image']);
|
|
|
- } else {
|
|
|
- $val['charm_level'] = '';
|
|
|
- }
|
|
|
|
|
|
//创建视频缩略图
|
|
|
$val['images_thumb'] = '';
|
|
@@ -895,7 +895,7 @@ class Topicdongtai extends Api
|
|
|
|
|
|
$this->success('success',$list);
|
|
|
}
|
|
|
-
|
|
|
+/////////////////////////////////////////////////////////////////////////////////
|
|
|
//删除动态
|
|
|
public function deldongtai() {
|
|
|
$id = input('id', 0, 'intval');
|