|
@@ -1004,8 +1004,8 @@ class NewsService implements NewsServiceInterface
|
|
|
];
|
|
|
|
|
|
$result = Article::where($where)
|
|
|
- ->leftJoin("article_data", "article.id", "article_data.article_id")
|
|
|
- ->leftJoin ("article_extend", "article_extend.article_id", "article.id")
|
|
|
+ ->leftJoin("article_data", "article.id", "article_data.article_id")
|
|
|
+ ->leftJoin("article_extend", "article_extend.article_id", "article.id")
|
|
|
->where(function ($query) use ($data) {
|
|
|
$query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
->orWhereNull("ignore_ids");
|
|
@@ -3853,7 +3853,7 @@ class NewsService implements NewsServiceInterface
|
|
|
if (isset($data['status']) && !empty($data['status'])) {
|
|
|
$where[] = ['notice.status', '=', $data['status']];
|
|
|
}
|
|
|
- var_dump($data, '-----------------test---------');
|
|
|
+ var_dump($data, '------------11111-2----test---------');
|
|
|
if ($data['type_id'] == 10000) {
|
|
|
$result = Notice::when(!empty($data['status1']), function ($query) use ($data) {
|
|
|
return $query->whereIn('notice.status', [1, 3]); //1待审核2已审核3已拒绝
|
|
@@ -3878,11 +3878,18 @@ class NewsService implements NewsServiceInterface
|
|
|
->orWhere('notice.user_id', $data['user_id']);
|
|
|
});
|
|
|
})
|
|
|
+
|
|
|
+ ->when(!empty($data['status1']), function ($query) use ($data) {
|
|
|
+ return $query->whereIn('notice.status', [1, 3]); //1待审核2已审核3已拒绝
|
|
|
+ })
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
->limit($data['page_size'])
|
|
|
->offset(($data['page'] - 1) * $data['page_size'])
|
|
|
->get();
|
|
|
$total = Notice::where($where)
|
|
|
+ ->when(!empty($data['status1']), function ($query) use ($data) {
|
|
|
+ return $query->whereIn('notice.status', [1, 3]); //1待审核2已审核3已拒绝
|
|
|
+ })
|
|
|
// ->where('user_id', $data['user_id'])
|
|
|
->Where(function ($query) use ($data) {
|
|
|
$query->Where(function ($q) use ($data) {
|
|
@@ -4008,8 +4015,8 @@ class NewsService implements NewsServiceInterface
|
|
|
->select('job_resume.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name', 'job_company.business_name as business_name')
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
->limit(5)->get();
|
|
|
-
|
|
|
- $count = count($chat) + count($chat_group) + count($apply_articale) + count($good) + count($notice) + count($complaint) + count($book) + count($job_hunting) + count($job_recruiting) + count($job_apply) + count($job_resume);
|
|
|
+ // count($chat) + count($chat_group) +
|
|
|
+ $count = count($apply_articale) + count($good) + count($notice) + count($complaint) + count($book) + count($job_hunting) + count($job_recruiting) + count($job_apply) + count($job_resume);
|
|
|
$result = [
|
|
|
'apply_articale' => $apply_articale,
|
|
|
'chat' => $chat,
|
|
@@ -4046,7 +4053,8 @@ class NewsService implements NewsServiceInterface
|
|
|
->where('user_id', $user_id)
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
->limit(5)->get();
|
|
|
- $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
|
|
|
+ //count($chat) + count($chat_group)
|
|
|
+ $count = count($apply_articale) + count($good);
|
|
|
$result = [
|
|
|
'apply_articale' => $apply_articale,
|
|
|
'chat' => $chat,
|
|
@@ -4076,7 +4084,9 @@ class NewsService implements NewsServiceInterface
|
|
|
->where('user_id', $user_id)
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
->limit(5)->get();
|
|
|
- $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
|
|
|
+
|
|
|
+ //count($chat) + count($chat_group) +
|
|
|
+ $count = count($apply_articale) + count($good);
|
|
|
$result = [
|
|
|
'apply_articale' => $apply_articale,
|
|
|
'chat' => $chat,
|
|
@@ -5370,9 +5380,9 @@ class NewsService implements NewsServiceInterface
|
|
|
$container = \Hyperf\Context\ApplicationContext::getContainer();
|
|
|
$cache = $container->get(\Psr\SimpleCache\CacheInterface::class);
|
|
|
|
|
|
- if ($cachedData = $cache->get($cacheKey)) {
|
|
|
- return Result::success(unserialize($cachedData));
|
|
|
- }
|
|
|
+ if ($cachedData = $cache->get($cacheKey)) {
|
|
|
+ return Result::success(unserialize($cachedData));
|
|
|
+ }
|
|
|
|
|
|
//查询老黄历
|
|
|
try {
|
|
@@ -5455,11 +5465,11 @@ class NewsService implements NewsServiceInterface
|
|
|
->limit(6)
|
|
|
->get();
|
|
|
// 获取分类文章数据
|
|
|
- $categoryIds = WebsiteCategory::where(['website_id'=> $data['website_id'], 'pid'=>0])
|
|
|
- ->pluck('category_id')
|
|
|
- ->toArray();
|
|
|
+ $categoryIds = WebsiteCategory::where(['website_id' => $data['website_id'], 'pid' => 0])
|
|
|
+ ->pluck('category_id')
|
|
|
+ ->toArray();
|
|
|
|
|
|
-// $categoryIds = [627, 628, 629, 630, 631, 632, 633, 634, 635, 636];
|
|
|
+ // $categoryIds = [627, 628, 629, 630, 631, 632, 633, 634, 635, 636];
|
|
|
|
|
|
// 使用子查询优化
|
|
|
$articlesList = DB::table('article')
|
|
@@ -5514,7 +5524,7 @@ class NewsService implements NewsServiceInterface
|
|
|
->toArray();
|
|
|
|
|
|
$result = [
|
|
|
- 'almanac' => $almanacInfo,
|
|
|
+ 'almanac' => $almanacInfo,
|
|
|
'historyTodayList' => [
|
|
|
'category_name' => '历史上的今天',
|
|
|
'list' => $historyTodayList,
|
|
@@ -5691,61 +5701,62 @@ class NewsService implements NewsServiceInterface
|
|
|
/**
|
|
|
* 农网导航首页数据
|
|
|
*/
|
|
|
- public function getWebsiteNwHomeList(array $data): array{
|
|
|
- $categoryIds = WebsiteCategory::where(['website_id'=> $data['website_id']])->where("pid","!=",0)
|
|
|
- ->pluck('category_id')
|
|
|
- ->toArray();
|
|
|
- // 使用子查询优化
|
|
|
- $articlesList = DB::table('article')
|
|
|
- ->select([
|
|
|
- 'article.id',
|
|
|
- 'article.title',
|
|
|
- 'article.imgurl',
|
|
|
- 'article.created_at',
|
|
|
- 'category.name as category_name',
|
|
|
- 'category.id as category_id',
|
|
|
- 'website_category.aLIas_pinyin as pinyin',
|
|
|
- DB::raw('100 as type')
|
|
|
- ])
|
|
|
- ->join('category', 'article.catid', '=', 'category.id')
|
|
|
- ->leftJoin('website_category', 'website_category.category_id', '=', 'category.id')
|
|
|
- ->where('website_category.website_id', $data['website_id'])
|
|
|
- ->where('article.status', 1)
|
|
|
- ->whereIn('category.id', $categoryIds)
|
|
|
- // ->whereRaw('article.created_at >= DATE_SUB(NOW(), INTERVAL 30 DAY)')
|
|
|
- ->orderBy('article.created_at', 'desc')
|
|
|
- ->get()
|
|
|
- ->groupBy('category_id')
|
|
|
- ->map(function ($group) {
|
|
|
- // 确保第一条数据有图片
|
|
|
- $firstWithImage = $group->first(function ($item) {
|
|
|
- return !empty($item->imgurl);
|
|
|
- });
|
|
|
-
|
|
|
- if ($firstWithImage) {
|
|
|
- // 如果有带图片的文章,将其放在第一位
|
|
|
- $group = $group->filter(function ($item) use ($firstWithImage) {
|
|
|
- return $item->id !== $firstWithImage->id;
|
|
|
- })->prepend($firstWithImage);
|
|
|
- }
|
|
|
+ public function getWebsiteNwHomeList(array $data): array
|
|
|
+ {
|
|
|
+ $categoryIds = WebsiteCategory::where(['website_id' => $data['website_id']])->where("pid", "!=", 0)
|
|
|
+ ->pluck('category_id')
|
|
|
+ ->toArray();
|
|
|
+ // 使用子查询优化
|
|
|
+ $articlesList = DB::table('article')
|
|
|
+ ->select([
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.imgurl',
|
|
|
+ 'article.created_at',
|
|
|
+ 'category.name as category_name',
|
|
|
+ 'category.id as category_id',
|
|
|
+ 'website_category.aLIas_pinyin as pinyin',
|
|
|
+ DB::raw('100 as type')
|
|
|
+ ])
|
|
|
+ ->join('category', 'article.catid', '=', 'category.id')
|
|
|
+ ->leftJoin('website_category', 'website_category.category_id', '=', 'category.id')
|
|
|
+ ->where('website_category.website_id', $data['website_id'])
|
|
|
+ ->where('article.status', 1)
|
|
|
+ ->whereIn('category.id', $categoryIds)
|
|
|
+ // ->whereRaw('article.created_at >= DATE_SUB(NOW(), INTERVAL 30 DAY)')
|
|
|
+ ->orderBy('article.created_at', 'desc')
|
|
|
+ ->get()
|
|
|
+ ->groupBy('category_id')
|
|
|
+ ->map(function ($group) {
|
|
|
+ // 确保第一条数据有图片
|
|
|
+ $firstWithImage = $group->first(function ($item) {
|
|
|
+ return !empty($item->imgurl);
|
|
|
+ });
|
|
|
|
|
|
- return [
|
|
|
- 'category_name' => $group->first()->category_name,
|
|
|
- 'catid' => $group->first()->category_id,
|
|
|
- 'pinyin' => $group->first()->pinyin,
|
|
|
-// 'type' => 100,
|
|
|
- 'list' => $group->take(4)->map(function ($item) {
|
|
|
- return [
|
|
|
- 'id' => $item->id,
|
|
|
- 'title' => $item->title,
|
|
|
-// 'imgurl' => $item->imgurl,
|
|
|
-// 'created_at' => $item->created_at
|
|
|
- ];
|
|
|
- })->values()
|
|
|
- ];
|
|
|
- })
|
|
|
- ->values()
|
|
|
- ->toArray();
|
|
|
- return Result::success($articlesList);
|
|
|
+ if ($firstWithImage) {
|
|
|
+ // 如果有带图片的文章,将其放在第一位
|
|
|
+ $group = $group->filter(function ($item) use ($firstWithImage) {
|
|
|
+ return $item->id !== $firstWithImage->id;
|
|
|
+ })->prepend($firstWithImage);
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'category_name' => $group->first()->category_name,
|
|
|
+ 'catid' => $group->first()->category_id,
|
|
|
+ 'pinyin' => $group->first()->pinyin,
|
|
|
+ // 'type' => 100,
|
|
|
+ 'list' => $group->take(4)->map(function ($item) {
|
|
|
+ return [
|
|
|
+ 'id' => $item->id,
|
|
|
+ 'title' => $item->title,
|
|
|
+ // 'imgurl' => $item->imgurl,
|
|
|
+ // 'created_at' => $item->created_at
|
|
|
+ ];
|
|
|
+ })->values()
|
|
|
+ ];
|
|
|
+ })
|
|
|
+ ->values()
|
|
|
+ ->toArray();
|
|
|
+ return Result::success($articlesList);
|
|
|
}
|
|
|
}
|