|
@@ -1,7 +1,12 @@
|
|
|
<?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\Link;
|
|
|
use App\Model\LetterOfComplaint;
|
|
|
use App\Model\TemplateClass;
|
|
|
use App\Model\Template;
|
|
@@ -13,6 +18,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 +472,186 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 查询网站的广告
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteAdvertisement(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
+ 'id' => $data['ad_placeid']
|
|
|
+ ];
|
|
|
+ $ad_place = AdPlace::where($where)->orderBy('id','asc')->limit(1)->get();
|
|
|
+
|
|
|
+
|
|
|
+ $today = Carbon::now();
|
|
|
+
|
|
|
+ if(empty($ad_place)){
|
|
|
+ return Result::error("error",0);
|
|
|
+ }else{
|
|
|
+ foreach($ad_place as $val){
|
|
|
+ $adplaceid = $val;
|
|
|
+ }
|
|
|
+ $ad=Ad::where('pid',$adplaceid['id'])->where('status',1)->orderBy('id','asc')->get();
|
|
|
+ if(empty($ad)){
|
|
|
+ $result=$adplaceid;
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ 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['data']);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @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)->orderBy('sort')->offset($placeid)->limit($num)->get();
|
|
|
+ $result = $result->toArray();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 网站首页数据统计, 管理员
|