|
@@ -484,47 +484,29 @@ class WebsiteService implements WebsiteServiceInterface
|
|
*/
|
|
*/
|
|
public function getWebsiteAdvertisement(array $data): array
|
|
public function getWebsiteAdvertisement(array $data): array
|
|
{
|
|
{
|
|
-
|
|
|
|
$where = [
|
|
$where = [
|
|
- 'website_id' => 1,
|
|
|
|
- 'id' => $data['ad_placeid']
|
|
|
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
|
+ 'ad_place.status' => 1,
|
|
|
|
+ 'ad.status' => 1,
|
|
];
|
|
];
|
|
-
|
|
|
|
- //查询这个广告位是否存在
|
|
|
|
- $ad_place = AdPlace::where($where)->orderBy('id','asc')->first();
|
|
|
|
-
|
|
|
|
- var_dump("==========",$ad_place);
|
|
|
|
- if(empty($ad_place)){
|
|
|
|
- return Result::error("error",0);
|
|
|
|
|
|
+ if(isset($data['ad_tag']) && !empty($data['ad_tag'])){
|
|
|
|
+ $now = Carbon::now()->format('Y-m-d H:i:s'); // 获取当前时间
|
|
|
|
+ $where[] = ['ad_tag','like','%'.$data['ad_tag'].'%'];
|
|
|
|
+ $result = AdPlace::where($where)
|
|
|
|
+ ->leftJoin("ad","ad.pid","ad_place.id")
|
|
|
|
+ ->select("ad_place.*","ad.*",'ad.name as ad_name','ad.id as ad_id')
|
|
|
|
+ ->where('ad.fromtime', '<=', $now)
|
|
|
|
+ ->where('ad.totime', '>=', $now)
|
|
|
|
+ // ->whereBetween('ad.fromtime', [$now, 'ad.totime'])
|
|
|
|
+ ->get()->all();
|
|
|
|
+ if(empty($result)){
|
|
|
|
+ return Result::error("此广告位不存在!",0);
|
|
|
|
+ }
|
|
}else{
|
|
}else{
|
|
- $adplaceid = $ad_place['id'];
|
|
|
|
- //查找有没有广告
|
|
|
|
- $ad=Ad::where('pid',$adplaceid['id'])->where('status',1)->orderBy('id','asc')->get();
|
|
|
|
- if(empty($ad)){
|
|
|
|
- //若没有生效的广告,则显示默认的缩略图
|
|
|
|
- $result=$adplaceid;
|
|
|
|
- return Result::success($result);
|
|
|
|
- }else{
|
|
|
|
- //查找在生效时间的广告
|
|
|
|
- $today = Carbon::now();
|
|
|
|
- foreach($ad as $i)
|
|
|
|
- {
|
|
|
|
- $starttime=Carbon::parse($i['fromtime']);
|
|
|
|
- $endtime=Carbon::parse($i['totime']);
|
|
|
|
- $time=$today->between($starttime,$endtime);
|
|
|
|
- if($time)
|
|
|
|
- {
|
|
|
|
- $result=$i;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(empty($result)){
|
|
|
|
- $result=$ad;
|
|
|
|
- return Result::success($result);
|
|
|
|
- }else{
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ return Result::error("请选择广告位!",0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -622,17 +604,38 @@ class WebsiteService implements WebsiteServiceInterface
|
|
public function getWebsiteModelCategory(array $data): array
|
|
public function getWebsiteModelCategory(array $data): array
|
|
{
|
|
{
|
|
$website_id=[
|
|
$website_id=[
|
|
- 'website_id' => $data['website_id']
|
|
|
|
|
|
+ 'website_category.website_id' => $data['website_id']
|
|
];
|
|
];
|
|
$placeid=$data['placeid']-1;
|
|
$placeid=$data['placeid']-1;
|
|
$pid=[
|
|
$pid=[
|
|
- 'pid' => $data['pid'],
|
|
|
|
|
|
+ 'website_category.pid' => $data['pid'],
|
|
];
|
|
];
|
|
|
|
+ var_dump( "=======",$pid);
|
|
$num = $data['num'];
|
|
$num = $data['num'];
|
|
- $result=WebsiteCategory::where($website_id)->where($pid)->withCount(['children' => function ($query) use ($website_id) {
|
|
|
|
- $query->where($website_id);
|
|
|
|
- }])->orderBy('sort')->offset($placeid)->limit($num)->get();
|
|
|
|
-
|
|
|
|
|
|
+ // return Result::success($data);
|
|
|
|
+ $result=WebsiteCategory::where($website_id)
|
|
|
|
+ ->leftJoin("category",'website_category.category_id','category.id')
|
|
|
|
+ ->select('website_category.*','category.is_url','category.web_url')
|
|
|
|
+ ->where($pid)
|
|
|
|
+ // ->with(['children' => function ($query) use ($data) {
|
|
|
|
+ // $query->where('website_category.website_id', $data['website_id']);
|
|
|
|
+ // }])
|
|
|
|
+ ->orderBy('website_category.sort')
|
|
|
|
+
|
|
|
|
+ ->offset($placeid)
|
|
|
|
+ ->limit($num)
|
|
|
|
+ ->get();
|
|
|
|
+ foreach($result as $k=>$v){
|
|
|
|
+ $child[$k]['children_countent']=WebsiteCategory::where($website_id)
|
|
|
|
+ ->where('website_category.pid',$v['category_id'])
|
|
|
|
+ ->count();
|
|
|
|
+ if(!empty($child[$k]['children_countent'])){
|
|
|
|
+ $result[$k]['children_count']=$child[$k]['children_countent'];
|
|
|
|
+ }else{
|
|
|
|
+ $result[$k]['children_count']=0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
if(!empty($result)){
|
|
if(!empty($result)){
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}else{
|
|
}else{
|
|
@@ -1401,10 +1404,10 @@ class WebsiteService implements WebsiteServiceInterface
|
|
if (empty($website)) {
|
|
if (empty($website)) {
|
|
return Result::error("暂无该网站",0);
|
|
return Result::error("暂无该网站",0);
|
|
}
|
|
}
|
|
- $category = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['pid'])->pluck('category_id')->all();
|
|
|
|
|
|
+ $category = WebsiteCategory::where('website_id',$data['website_id'])->pluck('category_id')->all();
|
|
// return Result::success($category);
|
|
// return Result::success($category);
|
|
if (empty($category)) {
|
|
if (empty($category)) {
|
|
- return Result::error("暂无二级导航",0);
|
|
|
|
|
|
+ return Result::error("暂无此导航",0);
|
|
}
|
|
}
|
|
$query = Category::whereIn('id', $category);
|
|
$query = Category::whereIn('id', $category);
|
|
if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
@@ -1412,11 +1415,12 @@ class WebsiteService implements WebsiteServiceInterface
|
|
if (empty($cityid)) {
|
|
if (empty($cityid)) {
|
|
return Result::error("暂无此城市", 0);
|
|
return Result::error("暂无此城市", 0);
|
|
} else {
|
|
} else {
|
|
- $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->get();
|
|
|
|
|
|
+ $city_category = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->pluck('id');
|
|
// $where[] = ['JSON_CONTAINS(city_arr_id, ?)', $data['cityid']];
|
|
// $where[] = ['JSON_CONTAINS(city_arr_id, ?)', $data['cityid']];
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("暂无此城市下的二级导航", 0);
|
|
|
|
|
|
+ if (empty($city_category)) {
|
|
|
|
+ return Result::error("暂无此城市下的导航", 0);
|
|
}
|
|
}
|
|
|
|
+ $result['catid'] = $city_category;
|
|
$city = 1;
|
|
$city = 1;
|
|
// var_dump("城市====================",$result);
|
|
// var_dump("城市====================",$result);
|
|
}
|
|
}
|
|
@@ -1426,22 +1430,25 @@ class WebsiteService implements WebsiteServiceInterface
|
|
if (empty($departmentid)) {
|
|
if (empty($departmentid)) {
|
|
return Result::error("暂无此部门", 0);
|
|
return Result::error("暂无此部门", 0);
|
|
} else {
|
|
} else {
|
|
- $result = $query->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("暂无此部门下的二级导航", 0);
|
|
|
|
|
|
+ $depart_category = $query->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->pluck('id');
|
|
|
|
+ if (empty($depart_category)) {
|
|
|
|
+ return Result::error("暂无此部门下的导航", 0);
|
|
}
|
|
}
|
|
|
|
+ $result['catid'] = $depart_category;
|
|
// var_dump("职能部门*******************",$result);
|
|
// var_dump("职能部门*******************",$result);
|
|
$department = 1;
|
|
$department = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(!empty($city) && !empty($department)){
|
|
if(!empty($city) && !empty($department)){
|
|
// var_dump("城市和职能部门----------------------",$result);
|
|
// var_dump("城市和职能部门----------------------",$result);
|
|
- $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
|
|
|
|
- }else{
|
|
|
|
- $result = $query->get();
|
|
|
|
- }
|
|
|
|
|
|
+ $sel_category = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->pluck('id');
|
|
|
|
+ if (empty($sel_category)) {
|
|
|
|
+ return Result::error("暂无此城市和职能部门下的导航", 0);
|
|
|
|
+ }
|
|
|
|
+ $result['catid'] = $sel_category;
|
|
|
|
+ }
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
- return Result::error("暂无二级导航",0);
|
|
|
|
|
|
+ return Result::error("暂无导航",0);
|
|
}
|
|
}
|
|
|
|
|
|
// department_id
|
|
// department_id
|
|
@@ -1478,7 +1485,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
- * 搜索网站二级导航
|
|
|
|
|
|
+ * 获取某个栏目
|
|
* @param array $data
|
|
* @param array $data
|
|
* @return array
|
|
* @return array
|
|
* */
|
|
* */
|