|
@@ -509,27 +509,26 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function getWebsiteAdvertisement(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
|
- 'website_id' => $data['website_id'],
|
|
|
'ad_place.status' => 1,
|
|
|
- // 'ad.status' => 1,
|
|
|
];
|
|
|
if (isset($data['ad_tag']) && !empty($data['ad_tag'])) {
|
|
|
$now = Carbon::now()->format('Y-m-d H:i:s'); // 获取当前时间
|
|
|
- $where[] = ['ad_place.ad_tag', 'like', '%' . $data['ad_tag'] . '%'];
|
|
|
- $result = AdPlace::where($where)
|
|
|
- ->leftJoin("ad", function ($join) use ($now) {
|
|
|
- $join->on("ad.pid", "=", "ad_place.id")
|
|
|
- ->where('ad.status', 1)
|
|
|
- ->where('ad.fromtime', '<=', $now)
|
|
|
- ->where('ad.totime', '>=', $now);
|
|
|
- })
|
|
|
- ->select("ad_place.*", 'ad.*', "ad_place.id as ad_place_id", "ad.name as ad_name")
|
|
|
- ->get()->all();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("此广告位不存在!", 0);
|
|
|
- }
|
|
|
- } else {
|
|
|
- return Result::error("请选择广告位!", 0);
|
|
|
+ $where[] = ['ad_place.ad_tag','like','%'.$data['ad_tag'].'%'];
|
|
|
+ // return Result::success($where);
|
|
|
+ $result = AdPlace::where($where)
|
|
|
+ ->leftJoin("ad", function ($join) use ($now) {
|
|
|
+ $join->on("ad.pid", "=", "ad_place.id")
|
|
|
+ ->where('ad.status', 1)
|
|
|
+ ->where('ad.fromtime', '<=', $now)
|
|
|
+ ->where('ad.totime', '>=', $now);
|
|
|
+ })
|
|
|
+ ->select("ad_place.*",'ad.*',"ad_place.id as ad_place_id","ad.name as ad_name")
|
|
|
+ ->get()->all();
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("此广告位不存在!",0);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("请选择广告位!",0);
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
|
|
@@ -646,7 +645,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
->offset($data['placeid'])
|
|
|
->limit($data['num'])
|
|
|
->orderBy('sort');
|
|
|
-
|
|
|
// 如果 $pid 数组不为空,添加 CASE WHEN 条件
|
|
|
if (!empty($pid)) {
|
|
|
$placeholders = implode(',', array_fill(0, count($pid), '?'));
|
|
@@ -657,13 +655,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
|
|
|
// 执行查询
|
|
|
- $result = $query->get();
|
|
|
- if (!empty($result)) {
|
|
|
- return Result::success($result);
|
|
|
- } else {
|
|
|
- return Result::error("本网站暂无栏目", 0);
|
|
|
- }
|
|
|
- }
|
|
|
+ $placeid = $data['placeid']-1;
|
|
|
+ $result = $query->offset($placeid)->limit($data['num'])->get();
|
|
|
+ if(!empty($result)){
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ return Result::error("本网站暂无栏目",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 获取友情链接
|
|
@@ -1545,13 +1544,17 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (isset($data['website_id']) && !empty($data['website_id'])) {
|
|
|
$website = Website::where('id', $data['website_id'])->where('status', 1)->first();
|
|
|
if (empty($website)) {
|
|
|
- return Result::error("暂无该网站", 0);
|
|
|
+
|
|
|
+ return Result::error("暂无该网站",0);
|
|
|
}
|
|
|
$category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['category_id'])->first();
|
|
|
if (empty($category)) {
|
|
|
return Result::error("暂无此导航", 0);
|
|
|
}
|
|
|
- $category['children_count'] = WebsiteCategory::where('website_id', $data['website_id'])->where('pid', $data['category_id'])->count();
|
|
|
+ $category['children_count'] = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['category_id'])->count();
|
|
|
+ $parent = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$category['pid'])->select('category_id as parent_id','alias as parent_name')->first();
|
|
|
+ $category['parent_id'] = $parent['parent_id']?? '';
|
|
|
+ $category['parent_name'] = $parent['parent_name']?? '';
|
|
|
return Result::success($category);
|
|
|
} else {
|
|
|
return Result::error("参数错误", 0);
|