|
@@ -1,7 +1,17 @@
|
|
|
<?php
|
|
|
namespace App\JsonRpc;
|
|
|
use App\Model\Article;
|
|
|
+
|
|
|
+use App\Model\Ad;
|
|
|
use App\Model\Category;
|
|
|
+
|
|
|
+use App\Model\AdPlace;
|
|
|
+use App\Model\Department;
|
|
|
+use App\Model\District;
|
|
|
+use App\Model\FooterCategory;
|
|
|
+use App\Model\FooterContent;
|
|
|
+use App\Model\WebsiteTemplateInfo;
|
|
|
+use App\Model\Link;
|
|
|
use App\Model\LetterOfComplaint;
|
|
|
use App\Model\TemplateClass;
|
|
|
use App\Model\Template;
|
|
@@ -13,6 +23,7 @@ use App\Model\WebsiteColumn;
|
|
|
use Hyperf\DbConnection\Db;
|
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
|
use App\Tools\Result;
|
|
|
+use Carbon\Carbon;
|
|
|
use App\Model\WebsiteCategory;
|
|
|
use function PHPUnit\Framework\isNull;
|
|
|
|
|
@@ -466,6 +477,193 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询网站的广告
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteAdvertisement(array $data): array
|
|
|
+ {
|
|
|
+
|
|
|
+ $where = [
|
|
|
+ 'website_id' => 1,
|
|
|
+ 'id' => $data['ad_placeid']
|
|
|
+ ];
|
|
|
+
|
|
|
+ //查询这个广告位是否存在
|
|
|
+ $ad_place = AdPlace::where($where)->orderBy('id','asc')->first();
|
|
|
+
|
|
|
+ var_dump("==========",$ad_place);
|
|
|
+ if(empty($ad_place)){
|
|
|
+ return Result::error("error",0);
|
|
|
+ }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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ /**网站行政职能搜索 */
|
|
|
+ public function selectWebsiteDepartment(array $data): array
|
|
|
+ {
|
|
|
+
|
|
|
+ $depart = Department::where('pid',0)->orderBy('id','asc')->limit(10)->get();
|
|
|
+ if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
|
+ $departments= Department::where('name', 'like', '%' . $data['keyword'] . '%')->get();
|
|
|
+ if(empty($departments)){
|
|
|
+ $result['message']="未查询到与此相关职能部门";
|
|
|
+ }else{
|
|
|
+ $count = Department::where('name','like',"%{$data['keyword']}%")->count();
|
|
|
+ $m = [
|
|
|
+ 'department'=>$depart,
|
|
|
+ 'type'=>$departments,
|
|
|
+ 'count'=>$count
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $result['sele'] = $m;
|
|
|
+ return Result::success($result['sele']);
|
|
|
+
|
|
|
+ }
|
|
|
+ $result=$depart;
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索地区
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function selectWebsiteArea(array $data): array
|
|
|
+ {
|
|
|
+ $provinces=District::where('pid',0)->where('status',1)->get();
|
|
|
+
|
|
|
+ if(isset($data['province'])){
|
|
|
+ $province=District::where('pid',0)->where('status',1)->where('id',$data['province'])->orderBy('id')->get();
|
|
|
+ $province=$province->toArray();
|
|
|
+ if(!empty($province)){
|
|
|
+ $citys=District::where('pid',$data['province'])->where('status',1)->orderBy('id')->get();
|
|
|
+ if(!empty($citys) && isset($data['city']) && !empty($data['city'])){
|
|
|
+ // $province = $province->toArray();
|
|
|
+ $province_id=[];
|
|
|
+ foreach($province as $val){
|
|
|
+ array_push($province_id,$val['id']);
|
|
|
+ }
|
|
|
+ // var_dump($province_id);
|
|
|
+ $city=District::whereIn('pid',$province_id)->where('status',1)->where('id',$data['city'])->orderBy('id')->get();
|
|
|
+ if(!empty($city)){
|
|
|
+ $city_id=[];
|
|
|
+ foreach($city as $val){
|
|
|
+ array_push($city_id,$val['id']);
|
|
|
+ }
|
|
|
+ $regions=District::whereIn('pid',$city_id)->where('status',1)->orderBy('id')->get();
|
|
|
+
|
|
|
+ $result=[
|
|
|
+ 'province' => $province,
|
|
|
+ 'city' => $city,
|
|
|
+ 'region' => $regions
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ return Result::error("未查询到此城市",0);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $result=[
|
|
|
+ 'province' => $province,
|
|
|
+ 'city' => $citys,
|
|
|
+ 'region' => null
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("未查询到此省份",0);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // $keys = array('data');
|
|
|
+ $result = $provinces;
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取栏目
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+
|
|
|
+ public function getWebsiteModelCategory(array $data): array
|
|
|
+ {
|
|
|
+ $website_id=[
|
|
|
+ 'website_id' => $data['website_id']
|
|
|
+ ];
|
|
|
+ $placeid=$data['placeid']-1;
|
|
|
+ $pid=[
|
|
|
+ 'pid' => $data['pid'],
|
|
|
+ ];
|
|
|
+ $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();
|
|
|
+
|
|
|
+ if(!empty($result)){
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ return Result::error("本网站暂无栏目",0);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取友情链接
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+
|
|
|
+ public function selectWebsiteLinks(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
+ 'status' => 1,
|
|
|
+ 'type' => $data['type']
|
|
|
+ ];
|
|
|
+ $num=$data['num'];
|
|
|
+ $result=Link::where($where)->orderBy('id')->limit($num)->get();
|
|
|
+ if(!empty($result)){
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ return Result::error("本网站暂无此类型友情链接",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 网站首页数据统计, 管理员
|
|
|
* @return void
|
|
@@ -1077,4 +1275,207 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::success($websiteInfo->toArray());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取网站底部基础信息
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteFootInfo(array $data): array
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ $website_foot = WebsiteTemplateInfo::where('website_id',$data['website_id'])->where('status',2)->first();
|
|
|
+ $website_head = Website::where('id',$data['website_id'])
|
|
|
+ ->select('id','website_name','logo','title','keywords','description')->first();
|
|
|
+ if (empty($website_foot)) {
|
|
|
+ return Result::error("暂无底部基础信息",0);
|
|
|
+ }
|
|
|
+ if (empty($website_head)) {
|
|
|
+ return Result::error("暂无头部基础信息",0);
|
|
|
+ }
|
|
|
+ $result = [
|
|
|
+ 'website_foot'=>$website_foot,
|
|
|
+ 'website_head'=>$website_head
|
|
|
+ ];
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取网站底部导航
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteFooterCategory(array $data): array
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ $result = FooterCategory::where('website_id',$data['website_id'])->get();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无底部导航",0);
|
|
|
+ }
|
|
|
+ return Result::success($result->toArray());
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取网站底部导航列表
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteFooterCategoryList(array $data): array
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ $footercategory = FooterCategory::where('website_id',$data['website_id'])->where('id',$data['fcat_id'])->first();
|
|
|
+ // '底部导航类型 0:内容型;1:列表型;',
|
|
|
+ if (!isset($footercategory['type']) || $footercategory['type'] == 0) {
|
|
|
+ return Result::error("底部导航id错误",0);
|
|
|
+ }else{
|
|
|
+ $query = FooterContent::where('fcat_id',$data['fcat_id']);
|
|
|
+ if($query->count() == 0){
|
|
|
+ return Result::error("暂无底部导航列表",0);
|
|
|
+ }elseif($query->count() == 1){
|
|
|
+ $result = $query->first();
|
|
|
+ }else{
|
|
|
+ $result = $query->get();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取网站底部导航
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteFooterCategoryInfo(array $data): array
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ if (isset($data['type']) && $data['type'] == 0) {
|
|
|
+ $fcatid = FooterCategory::where('website_id',$data['website_id'])->where('id',$data['fcat_id'])->first();
|
|
|
+ if (empty($fcatid)) {
|
|
|
+ return Result::error("底部导航id错误",0);
|
|
|
+ }
|
|
|
+ $result = FooterContent::where('fcat_id',$data['fcat_id'])->first();
|
|
|
+ }else{
|
|
|
+ $result = FooterContent::where('id',$data['fcat_id'])->first();
|
|
|
+ }
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无底部导航内容",0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 搜索网站二级导航
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function selectWebsiteCategory(array $data): array
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ $category = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['pid'])->pluck('category_id')->all();
|
|
|
+ // return Result::success($category);
|
|
|
+ if (empty($category)) {
|
|
|
+ // return Result::error("暂无二级导航",0);
|
|
|
+ }
|
|
|
+ $query = Category::whereIn('id', $category);
|
|
|
+ if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
|
+ $cityid = District::where('id', $data['cityid'])->first();
|
|
|
+ if (empty($cityid)) {
|
|
|
+ return Result::error("暂无此城市", 0);
|
|
|
+ } else {
|
|
|
+ $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->get();
|
|
|
+ // $where[] = ['JSON_CONTAINS(city_arr_id, ?)', $data['cityid']];
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无此城市下的二级导航", 0);
|
|
|
+ }
|
|
|
+ $city = 1;
|
|
|
+ // var_dump("城市====================",$result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($data['department_id']) && !empty($data['department_id'])) {
|
|
|
+ $departmentid = Department::where('id', $data['department_id'])->first();
|
|
|
+ if (empty($departmentid)) {
|
|
|
+ return Result::error("暂无此部门", 0);
|
|
|
+ } else {
|
|
|
+ $result = $query->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无此部门下的二级导航", 0);
|
|
|
+ }
|
|
|
+ // var_dump("职能部门*******************",$result);
|
|
|
+ $department = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($city) && !empty($department)){
|
|
|
+ // 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();
|
|
|
+ }
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无二级导航",0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // department_id
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取网站栏目seo
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteCategoryHead(array $data): array
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ if (isset($data['catid']) && !empty($data['catid'])) {
|
|
|
+ $fcatid = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['catid'])->first();
|
|
|
+ if (empty($fcatid)) {
|
|
|
+ return Result::error("导航id错误",0);
|
|
|
+ }
|
|
|
+ $result = Category::where('id',$data['catid'])->first();
|
|
|
+ }
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无导航",0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+
|
|
|
}
|