|
@@ -1,6 +1,6 @@
|
|
|
<?php
|
|
|
namespace App\JsonRpc;
|
|
|
-
|
|
|
+use App\Model\AdSize;
|
|
|
use App\Model\Article;
|
|
|
|
|
|
use App\Model\Ad;
|
|
@@ -1685,6 +1685,30 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function addWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
+// var_dump("接收参数:",$data['webSiteData']['base']);
|
|
|
+ Db::beginTransaction();
|
|
|
+ try{
|
|
|
+ $websiteTemplateInfo = WebsiteTemplate::where(['website_id'=>$data['webSiteData']['base']['websiteId']])->first();
|
|
|
+// var_dump($websiteTemplateInfo);
|
|
|
+ //原始数据
|
|
|
+ $templateList = $data['webSiteData']['template'];
|
|
|
+ if($websiteTemplateInfo){
|
|
|
+ //模板存在-更新广告
|
|
|
+
|
|
|
+ }else{
|
|
|
+ //创建广告
|
|
|
+
|
|
|
+ $adList = $this->getAdlist($templateList);
|
|
|
+ if(!empty($adList)){
|
|
|
+ AdPlace::insert($adList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+// $result = WebsiteTemplate::updateOrInsert(['website_id'=>$data['webSiteData']['base']['websiteId']],['template_data'=>json_encode($data['webSiteData']),'updated_at'=>date("Y-m-d H:i:s",time())]);
|
|
|
+ Db::commit();
|
|
|
+ } catch(\Throwable $ex){
|
|
|
+ Db::rollBack();
|
|
|
+ var_dump($ex->getMessage());
|
|
|
+ return Result::error("创建失败",0);
|
|
|
$website = Website::where('website.id',$data['website_id'])->first();
|
|
|
if(empty($website)){
|
|
|
return Result::error("请输入正确的网站id!", 0);
|
|
@@ -1755,6 +1779,46 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}else{
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
+ return Result::success();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ //获取传过来的广告列表
|
|
|
+ public function getAdlist($templateList)
|
|
|
+ {
|
|
|
+ if($templateList){
|
|
|
+ $adList = [];
|
|
|
+ foreach ($templateList as $val){
|
|
|
+ if($val){
|
|
|
+ foreach ($val as $v){
|
|
|
+ if($v['componentList']){
|
|
|
+ foreach ($v['componentList'] as $p){
|
|
|
+ if($p['component_type']==3){
|
|
|
+// var_dump("ppppppppppppp:",$p);
|
|
|
+ $adSizeInfo = AdSize::where(['width'=>$p['componentData']['width'],'height'=>$p['componentData']['height']])->first();
|
|
|
+ $adSizeInfo = $adSizeInfo->toArray();
|
|
|
+ $adData = [
|
|
|
+ 'website_id'=> $data['webSiteData']['base']['websiteId'],
|
|
|
+ 'status'=>1,
|
|
|
+ 'name'=>$p['componentData']['text'],
|
|
|
+ 'ad_id'=>$p['componentData']['ad_id'],
|
|
|
+ 'ad_size_id'=>$adSizeInfo['id'],
|
|
|
+ ];
|
|
|
+ array_push($adList,$adData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(count($adList)>0){
|
|
|
+ return $adList;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 预览网站首页模板数据
|
|
|
+ * @param array $data
|
|
|
}
|
|
|
/**
|
|
|
* 获取网站基础信息
|
|
@@ -2077,4 +2141,279 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
|
|
|
// 自助建站---------------fr---------------
|
|
|
+
|
|
|
+ // 自助建站------liu-------------
|
|
|
+ /**
|
|
|
+ * 风格下的板块
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function templateSectorList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ 'template_id'=>$data['template_id']
|
|
|
+ ];
|
|
|
+ $result = Sector::where($where)->whereJsonContains("page_type",$data['page_type'])
|
|
|
+ ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ $count = Sector::where($where)->count();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("没有数据",0);
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'rows'=>$result->toArray(),
|
|
|
+ 'count'=>$count
|
|
|
+ ];
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("没有数据",0);
|
|
|
+ }
|
|
|
+ return Result::success($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 板块下的组件
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function sectorComponentList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ 'template_id'=>$data['template_id'],
|
|
|
+ 'sector_id'=>$data['sector_id'],
|
|
|
+ ];
|
|
|
+ $result = Component::where($where)
|
|
|
+ ->select("*")
|
|
|
+ ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ $count = Component::where($where)->count();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("没有数据",0);
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'rows'=>$result->toArray(),
|
|
|
+ 'count'=>$count
|
|
|
+ ];
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("没有数据",0);
|
|
|
+ }
|
|
|
+ return Result::success($data);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取模板内容
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function getWebsiteTemplateInfo(array $data): array //丢了
|
|
|
+ {
|
|
|
+ $wehre = [
|
|
|
+ "website_id" =>$data['website_id']
|
|
|
+ ];
|
|
|
+ $result = WebsiteTemplate::where($wehre)->first();
|
|
|
+ if($result){
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ return Result::error("没有数据",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 保存网站模板
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function addWebsiteTemplate(array $data): array
|
|
|
+ {
|
|
|
+// var_dump("接收参数:",$data['webSiteData']['base']);
|
|
|
+ Db::beginTransaction();
|
|
|
+ try{
|
|
|
+ $websiteTemplateInfo = WebsiteTemplate::where(['website_id'=>$data['webSiteData']['base']['websiteId']])->first();
|
|
|
+// var_dump($websiteTemplateInfo);
|
|
|
+ //原始数据
|
|
|
+ $templateList = $data['webSiteData']['template'];
|
|
|
+ if($websiteTemplateInfo){
|
|
|
+ //模板存在-更新广告
|
|
|
+
|
|
|
+ }else{
|
|
|
+ //创建广告
|
|
|
+
|
|
|
+ $adList = $this->getAdlist($templateList);
|
|
|
+ if(!empty($adList)){
|
|
|
+ AdPlace::insert($adList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+// $result = WebsiteTemplate::updateOrInsert(['website_id'=>$data['webSiteData']['base']['websiteId']],['template_data'=>json_encode($data['webSiteData']),'updated_at'=>date("Y-m-d H:i:s",time())]);
|
|
|
+ Db::commit();
|
|
|
+ } catch(\Throwable $ex){
|
|
|
+ Db::rollBack();
|
|
|
+ var_dump($ex->getMessage());
|
|
|
+ return Result::error("创建失败",0);
|
|
|
+ }
|
|
|
+ return Result::success();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ //获取传过来的广告列表
|
|
|
+ public function getAdlist($templateList)
|
|
|
+ {
|
|
|
+ if($templateList){
|
|
|
+ $adList = [];
|
|
|
+ foreach ($templateList as $val){
|
|
|
+ if($val){
|
|
|
+ foreach ($val as $v){
|
|
|
+ if($v['componentList']){
|
|
|
+ foreach ($v['componentList'] as $p){
|
|
|
+ if($p['component_type']==3){
|
|
|
+// var_dump("ppppppppppppp:",$p);
|
|
|
+ $adSizeInfo = AdSize::where(['width'=>$p['componentData']['width'],'height'=>$p['componentData']['height']])->first();
|
|
|
+ $adSizeInfo = $adSizeInfo->toArray();
|
|
|
+ $adData = [
|
|
|
+ 'website_id'=> $data['webSiteData']['base']['websiteId'],
|
|
|
+ 'status'=>1,
|
|
|
+ 'name'=>$p['componentData']['text'],
|
|
|
+ 'ad_id'=>$p['componentData']['ad_id'],
|
|
|
+ 'ad_size_id'=>$adSizeInfo['id'],
|
|
|
+ ];
|
|
|
+ array_push($adList,$adData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(count($adList)>0){
|
|
|
+ return $adList;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 预览网站首页模板数据
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteTemplateData(array $data): array
|
|
|
+ {
|
|
|
+ $wehre = [
|
|
|
+ "website_id" =>$data['website_id']
|
|
|
+ ];
|
|
|
+ $result = WebsiteTemplate::where($wehre)->first();
|
|
|
+ if($result){
|
|
|
+ $templateData = json_decode($result['template_data'],true);
|
|
|
+// var_dump("数据:",$templateData[1]);
|
|
|
+ $templateData[1] = $this->getNewsList($templateData[1]);
|
|
|
+
|
|
|
+ return Result::success($templateData);
|
|
|
+ }else{
|
|
|
+ return Result::error("没有数据",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取列表数据
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function getNewsList(array $data): array
|
|
|
+ {
|
|
|
+ if($data){
|
|
|
+ foreach ($data as $key=>$val){
|
|
|
+ if($val){
|
|
|
+ foreach ($val['data'] as $k=>$item){
|
|
|
+ if($item['isReturn'] && intval($item['isReturn'])==1){
|
|
|
+ $imgList = [];
|
|
|
+ if($item['data']['imgNum'] && intval($item['data']['imgNum'])>0){
|
|
|
+ $imgList = Article::where('imgurl',"!=","")
|
|
|
+ ->where('catid',$item['data']['category_id'])
|
|
|
+ ->select($item['data']['selectField'])
|
|
|
+ ->orderBy("created_at","desc")
|
|
|
+ ->offset(0)
|
|
|
+ ->limit(intval($item['data']['imgNum']))
|
|
|
+ ->get();
|
|
|
+ $imgList = $imgList->toArray();
|
|
|
+ $listIds = [];
|
|
|
+ if ($imgList){
|
|
|
+ $listIds = array_column($imgList, 'id');
|
|
|
+ }
|
|
|
+ $dataList = Article::whereNotIn('id',$listIds)
|
|
|
+ ->where('catid',$item['data']['category_id'])
|
|
|
+ ->select($item['data']['selectField'])
|
|
|
+ ->orderBy("created_at","desc")
|
|
|
+ ->offset(0)
|
|
|
+ ->limit(intval($item['data']['pageSize'])-intval($item['data']['imgNum']))
|
|
|
+ ->get();
|
|
|
+ $dataList = $dataList->toArray();
|
|
|
+ var_dump("图片列表:",$imgList,"数据列表:",$dataList);
|
|
|
+ $datas = array_merge($imgList,$dataList);
|
|
|
+// return $datas;
|
|
|
+ var_dump("合并列表:",$datas);
|
|
|
+ $data[$key]['data'][$k]['dataList'] = $datas;
|
|
|
+ }else{
|
|
|
+ $dataList = Article::where('catid',$item['data']['category_id'])
|
|
|
+ ->select($item['data']['selectField'])
|
|
|
+ ->orderBy("created_at","desc")
|
|
|
+ ->offset(0)
|
|
|
+ ->limit(intval($item['data']['pageSize']))
|
|
|
+ ->get();
|
|
|
+ $dataList = $dataList->toArray();
|
|
|
+ var_dump("数据列表:",$dataList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取底部导航列表
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getFooterCategoryList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ "website_id"=>$data['website_id']
|
|
|
+ ];
|
|
|
+ $result = FooterCategory::where($where)->get();
|
|
|
+ if($result){
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ return Result::error("没有数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取底部导航内容列表
|
|
|
+ public function getFooterContentList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ "fcat_id"=>$data['fcat_id'],
|
|
|
+ ];
|
|
|
+ switch (intval($data['type'])){
|
|
|
+ case 0:
|
|
|
+ $result = FooterContent::where($where)->first();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ $result = FooterContent::where($where)->get();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if($result){
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ return Result::error("没有数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取底部导航内容详情
|
|
|
+ public function getFooterContentInfo(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ "id"=>$data['content_id']
|
|
|
+ ];
|
|
|
+ $result = FooterContent::where($where)->first();
|
|
|
+ if($result){
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ return Result::error("没有数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// 自传建站---------------liu------------
|
|
|
}
|