Forráskód Böngészése

Merge branch 'master' of http://git.bjzxtw.org.cn:3000/zxt/public_producer

LiuJ 1 napja
szülő
commit
fa2bc2cad2

+ 65 - 30
app/JsonRpc/PublicRpcService.php

@@ -35,7 +35,7 @@ use App\Model\Website;
 use App\Constants\ErrorCode;
 use GuzzleHttp\Client;
 use GuzzleHttp\Exception\GuzzleException;
-
+use App\Model\SectorPlace;
 #[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class PublicRpcService implements PublicRpcServiceInterface
 {
@@ -945,6 +945,23 @@ class PublicRpcService implements PublicRpcServiceInterface
             return Result::success('更新成功');
         }
     }
+    /**
+     * 获取所有尺寸
+     * @param array $data
+     * @return array
+     */
+    public function getAllSize(array $data): array
+    {
+        if(isset($data['id']) && !empty($data['id'])){
+            $result = Size::where('id', $data['id'])->get()->all();
+        }else{
+            $result = Size::get()->all();
+        }
+        if(empty($result)){
+            return Result::error("暂无尺寸", 0);
+        }
+        return Result::success($result);
+    }
     /**
      * 根据皮肤名称-获取所有皮肤
      * @param array $data
@@ -974,7 +991,7 @@ class PublicRpcService implements PublicRpcServiceInterface
     {
         $where = [];
         if (isset($data['template_class_id']) && !empty($data['template_class_id'])) {
-            $where['template_class.class_id'] = $data['template_class_id'];
+            $where['template.template_class_id'] = $data['template_class_id'];
         }
         if (isset($data['template_id']) && !empty($data['template_id'])) {
             array_push($where, ['template.template_id', $data['template_id']]);
@@ -991,17 +1008,20 @@ class PublicRpcService implements PublicRpcServiceInterface
         } else {
             $size_id = [];
         }
-        // $size_id = $size_id->toArray();
-        $result = Sector::where($where)
-            ->when(!empty($size_id), function ($query) use ($size_id) {
+        $result = Sector::when(!empty($size_id), function ($query) use ($size_id) {
                 $query->whereIn('size_id', $size_id);
             })
             ->leftJoin('size', 'size.id', '=', 'sector.size_id')
-            ->leftJoin('template_class', 'template_class.class_id', '=', 'sector.template_class_id')
             ->leftJoin('template', 'template.template_id', '=', 'sector.template_id')
-            ->select('sector.*', 'size.width', 'size.height', 'template_class.name as class_name', 'template.template_name')
+            ->leftJoin('template_class', 'template_class.class_id', '=', 'template.template_class_id') 
+            ->where($where)
+            ->select('sector.*', 'size.width','size.height','template_class.name as class_name','template.template_name')
+            
             ->orderBy('sector.id', 'desc')
             ->paginate($data['page_size'], ['*'], 'page', $data['page']);
+        if(empty($result)){
+            return Result::error('暂无通栏!');
+        }
         return Result::success($result);
     }
     /**
@@ -1129,23 +1149,14 @@ class PublicRpcService implements PublicRpcServiceInterface
         $data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
         $data['page_type'] = json_encode($data['page_type']);
         $template = Template::where('template_id', $data['template_id'])
-            ->whereRaw("JSON_CONTAINS(template.page_type, ?)", [$data['page_type']])
             ->first();
         if (empty($template)) {
             return Result::error('皮肤不存在!');
         }
-        // 皮肤相关信息
-        $data['template_name'] = $template['template_name'];
-        $data['template_id'] = $template['template_id'];
-        // 风格相关信息
-        $template_class = TemplateClass::where('class_id', $template['template_class_id'])->first();
-        if (empty($template_class)) {
-            return Result::error('所属风格不存在!');
+        $sector_id = Sector::where('sector_id',$data['sector_id'])->first();
+        if(!empty($sector_id)){
+            return Result::error('通栏编号已存在!');
         }
-        // $data['sector_keyword'] = json_encode($data['sector_keyword']);
-        $data['template_class_id'] = $template_class['class_id'];
-        $data['template_class_name'] = $template_class['name'];
-
         $result = Sector::insertGetId($data);
         if (empty($result)) {
             return Result::error('添加失败');
@@ -1182,6 +1193,12 @@ class PublicRpcService implements PublicRpcServiceInterface
         if (empty($sector)) {
             return Result::error('通栏不存在!');
         }
+        if($sector['sector_id'] != $data['sector_id']){
+            $sector_id = Sector::where('sector_id',$data['sector_id'])->first();
+            if(!empty($sector_id)){
+                return Result::error('通栏编号已存在!');
+            }
+        }
         // 对传入的 page_type 数组进行去重、转换为整数并重新索引
         $data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
         $data['page_type'] = json_encode($data['page_type']);
@@ -1191,17 +1208,6 @@ class PublicRpcService implements PublicRpcServiceInterface
         if (empty($template)) {
             return Result::error('皮肤不存在!');
         }
-        // 皮肤相关信息
-        $data['template_name'] = $template['template_name'];
-        $data['template_id'] = $template['template_id'];
-        // 风格相关信息
-        $template_class = TemplateClass::where('class_id', $template['template_class_id'])->first();
-        if (empty($template_class)) {
-            return Result::error('所属风格不存在!');
-        }
-        // $data['sector_keyword'] = json_encode($data['sector_keyword']);
-        $data['template_class_id'] = $template_class['class_id'];
-        $data['template_class_name'] = $template_class['name'];
         $result = Sector::where('id', $data['id'])->update($data);
         if ($result == 1) {
             return Result::success('修改成功');
@@ -1518,4 +1524,33 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         return Result::success($template);
     }
+    /**
+     * 自助建站-通栏管理-获取通栏位置
+     */
+    public function getSectorPlace(array $data): array
+    {
+        if(isset($data['sector_num']) && !empty($data['sector_num'])){
+            $where['t.sector_num'] = $data['sector_num'];
+            $template = DB::table(DB::raw('(
+                SELECT 
+                    sp.*, 
+                    s.width, 
+                    s.height,
+                    ROW_NUMBER() OVER (PARTITION BY sp.type ORDER BY sp.id DESC) as rn
+                FROM sector_place sp
+                LEFT JOIN size s ON sp.size_id = s.id
+            ) as t'))
+            ->where('rn', 1)
+            ->where($where)
+            ->select('t.*')
+            ->get();
+        }
+        if(isset($data['type']) && !empty($data['type'])){
+            $template = SectorPlace::where('type', $data['type'])->get()->all();
+        }
+        if(empty($template)){
+            return Result::error('未查询到通栏位置相关模版!');
+        }
+        return Result::success($template);
+    }
 }

+ 2 - 0
app/JsonRpc/PublicRpcServiceInterface.php

@@ -183,4 +183,6 @@ interface PublicRpcServiceInterface
     public function saveWebsiteTemplate(array $data): array;
     public function getAllTemplate(array $data): array;
     public function getWebsiteTemplate(array $data): array;
+    public function getAllSize(array $data): array;
+    public function getSectorPlace(array $data): array;
 }

+ 83 - 23
app/JsonRpc/WebsiteService.php

@@ -557,29 +557,49 @@ class WebsiteService implements WebsiteServiceInterface
             $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.name as place_name',
-                    'ad_place.thumb',
-                    'ad_place.ad_tag',
-                    'ad_place.introduce',
-                    'ad.name as ad_name',
-                    'ad.image_src',
-                    'ad.image_url',
-                    'ad.image_alt'
-                )
-                ->get()->all();
-            if (empty($result)) {
-                return Result::error("此广告位不存在!", 0);
-            }
-        } else {
-            return Result::error("请选择广告位!", 0);
+            ->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.name as place_name',
+                'ad_place.thumb',
+                'ad_place.ad_tag',
+                'ad_place.introduce',
+                'ad.name as ad_name',
+                'ad.image_src',
+                'ad.image_url',
+                'ad.image_alt')
+            ->get()->all();
+            
+        }else{
+            $now = Carbon::now()->format('Y-m-d H:i:s'); // 获取当前时间
+            // return Result::success($where);
+            $result =  AdPlace::where($where)
+            ->where('ad_place.website_id',$data['website_id'])
+            ->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.name as place_name',
+                'ad_place.thumb',
+                'ad_place.ad_tag',
+                'ad_place.introduce',
+                'ad.name as ad_name',
+                'ad.image_src',
+                'ad.image_url',
+                'ad.image_alt')
+            ->get()->all();
+            // return Result::error("请选择广告位!",0);
         }
+        if(empty($result)){
+                return Result::error("此广告位不存在!",0);
+            } 
         return Result::success($result);
     }
 
@@ -2457,7 +2477,47 @@ class WebsiteService implements WebsiteServiceInterface
         }
         return Result::success($result);
     }
-
+    /**
+     * 获取网站栏目信息
+     * @param array $data
+     */
+    public function getWebsiteAllinfo(array $data): array
+    {
+        $website = Website::where('id',$data['website_id'])->where('status',1)->first();
+        if (empty($website)) {
+            return Result::error("暂无该网站",0); 
+        }
+        if(isset($data['website_id']) && !empty($data['website_id'])){
+            $website_head = Website::where('id',$data['website_id'])
+                ->where('status',1)
+                ->select('id', 'website_name', 'logo', 'title', 'keywords', 'description', 
+                'suffix', 'website_url','ad_key','api_url','login_url','weblog_url')
+                ->first();
+            if (empty($website_head)) {
+                return Result::error("找不到网站",0); 
+            }
+        }else{
+            return Result::error("参数错误",0);
+        }
+        $website_foot['foot_info'] = WebsiteTemplateInfo::where('website_id',$data['website_id'])->first();
+        if (empty($website_foot)) {
+            return Result::error("暂无底部基础信息",0);
+        }
+        $website_head['website_url'] = $website_head['website_url'] ? json_decode($website_head['website_url']) : [];
+        $result['website_head'] =$website_head;
+        $result['website_foot'] = $website_foot;
+        
+        // return Result::success($result);
+        // 1:图片 2:文字 3:底部
+        $result['website_foot']['foot_cate'] = FooterCategory::where('website_id',$data['website_id'])->get()->all();
+        $result['website_foot']['link_img'] = Link::where('website_id',$data['website_id'])->where('type',1)->where('status',1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all(); 
+        $result['website_foot']['link_text'] = Link::where('website_id',$data['website_id'])->where('type',2)->where('status',1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
+        $result['website_foot']['link_foot'] = Link::where('website_id',$data['website_id'])->where('type',3)->where('status',1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();
+        if(empty($result)){
+            return Result::error("暂无此网站信息",0);
+        }
+        return Result::success($result);
+    }
     //20250212  网站标识
     public function addWebsiteGroup(array $data): array
     {

+ 1 - 0
app/JsonRpc/WebsiteServiceInterface.php

@@ -173,4 +173,5 @@ interface WebsiteServiceInterface
      */
     public function updateWebsiteStatus(array $data): array;
 
+    public function getWebsiteAllinfo(array $data): array;
 }

+ 27 - 0
app/Model/SectorPlace.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class SectorPlace extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'sector_place';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}