更新逛逛

This commit is contained in:
mkm 2023-01-15 20:18:42 +08:00
parent df2d6a74c1
commit 39be5320b5
4 changed files with 76 additions and 4 deletions

View File

@ -142,5 +142,13 @@ class Community extends BaseModel
->column('left_id');
$query->where('community_id','in', $id);
}
public function searchNoCategoryIdAttr($query, $value)
{
$query->where('category_id', '<>',$value);
}
public function searchIdAndInAttr($query, $value)
{
$query->where('community_id', 'in',$value);
}
}

View File

@ -96,7 +96,58 @@ class CommunityRepository extends BaseRepository
return compact('count','list');
}
public function getApiListTwo(array $where, int $page, int $limit, $userInfo)
{
if (!$userInfo){
$count=0;
$list=[];
return compact('count','list');
}
$village_id=Db::name('nk_user')->where('user_id',$userInfo->uid)->value('village_id');
if (!$village_id){
$count=0;
$list=[];
return compact('count','list');
}
$arr=Db::name('community_address')->where('village_id',$village_id)->page($page, $limit)->select();
if (count($arr)==0){
$count=0;
$list=[];
return compact('count','list');
}
$arr2=[];
foreach ($arr as $k=>$v){
$arr2[]=$v['community_id'];
}
$arrWhere=['id_and_in'=>$arr2];
$query = $this->dao->getSearch($arrWhere)->order('start DESC,create_time DESC,community_id DESC');
$query->with([
'author' => function($query) use($userInfo){
$query->field('uid,real_name,status,avatar,nickname,count_start');
},
'is_start' => function($query) use ($userInfo) {
$query->where('left_id',$userInfo->uid ?? null);
},
'topic' => function($query) {
$query->where('status', 1)->where('is_del',0);
$query->field('topic_id,topic_name,status,category_id,pic,is_del');
},
'relevance' => [
'spu' => function($query) {
$query->field('spu_id,store_name,image,price,product_type,activity_id,product_id');
}
],
'is_fans' => function($query) use($userInfo){
$query->where('left_id',$userInfo->uid?? 0);
}
]);
$count = Db::name('community_address')->where('village_id',$village_id)->count();
$list = $query->setOption('field',[])
->field('community_id,title,image,topic_id,count_start,count_reply,start,create_time,uid,status,is_show,content')
->select()->append(['time']);
return compact('count','list');
}
/**
* TODO 后台详情
* @param int $id

View File

@ -54,7 +54,17 @@ class Community extends BaseController
public function lst()
{
$where = $this->request->params(['keyword','topic_id','is_hot','category_id','spu_id']);
if (!$where['category_id']) unset($where['category_id']);
$a=true;
if (!$where['category_id']){
unset($where['category_id']);
//查询非社区数据
$where['no_category_id']=69;
$a=false;
}
if ($a &&$where['category_id']==69){
[$page, $limit] = $this->getPage();
return app('json')->success($this->repository->getApiListTwo($where, $page, $limit, $this->user));
}
$where = array_merge($where,$this->repository::IS_SHOW_WHERE);
[$page, $limit] = $this->getPage();
return app('json')->success($this->repository->getApiList($where, $page, $limit, $this->user));
@ -178,9 +188,11 @@ class Community extends BaseController
$data['status'] = 0;
$data['is_show'] = 0;
}
$res = $this->repository->create($data);
if ($data['category_id']==69){
$data['community_id']=$res;
event('community_address',$data);
}
return app('json')->success(['community_id' => $res]);
}
@ -231,7 +243,7 @@ class Community extends BaseController
public function checkParams()
{
$data = $this->request->params(['image','topic_id','content','spu_id','order_id']);
$data = $this->request->params(['image','topic_id','content','spu_id','order_id','category_id']);
$data['content'] = filter_emoji($data['content']);
app()->make(CommunityValidate::class)->check($data);

View File

@ -58,6 +58,7 @@ return [
'pay_success_order' => [\crmeb\listens\pay\OrderPaySuccessListen::class],
'pay_success_presell' => [\crmeb\listens\pay\PresellPaySuccessListen::class],
'pay_success_meal' => [\crmeb\listens\pay\MealSuccessListen::class],
'community_address'=>[\app\listener\CommunityAddress::class]
],
'subscribe' => [],