Parcourir la source

修改接口获取通栏版式;添加、删除通栏版式;添加通栏的接口

15313670163 il y a 1 jour
Parent
commit
29337b1cbe
1 fichiers modifiés avec 30 ajouts et 5 suppressions
  1. 30 5
      app/JsonRpc/PublicRpcService.php

+ 30 - 5
app/JsonRpc/PublicRpcService.php

@@ -1159,7 +1159,7 @@ class PublicRpcService implements PublicRpcServiceInterface
         if(!empty($sector_id)){
             return Result::error('通栏编号已存在!');
         }
-        
+        $data['status'] = 0;
         // 通栏分类:1:资讯类:2:通栏广告类;3:混合类;4:头条类;5:轮播图类;
         $sector_code = [
             'sectorName' => $data['sector_name'],
@@ -1604,18 +1604,35 @@ class PublicRpcService implements PublicRpcServiceInterface
                 'sector_img' => $data['sector_img'],
                 'sector_type' => $data['type'],
                 'type_id' => $data['type_id'],
+                'status' => 0,
             ];
         }else{
             $sector_type = SectorPlace::where('sector_type', $data['sector_type'])->where('type_id',1)->first(); 
             if(empty($sector_type)){
                 return Result::error('通栏版式类别不存在!');
             }
-            $component = SectorPlace::where('component_type', $data['type'])
-            ->where('type_id',2)
-            ->first();
+            // $com_query = SectorPlace::where('type_id',2);
+            // ->query(function($query) use ($data){
+            //     $query->where('component_type', $data['type'])
+            //         ->Subquery(function($subQuery) use ($data) {
+            //             $subQuery->where('sector_type', $data['sector_type'])
+            //                      ->where('sort_id', $data['sort']);
+            //         });
+            // })                                                               //若是组件版式编号或者组件版式位置重复用此语句筛选
+            // ->where('sector_type',$data['sector_type'])                      //若是组件版式编号在同一个通栏版式下不重复就行,则启用此语句
+            $component =  SectorPlace::where('type_id',2)->where('component_type',$data['type'])->first();
             if(!empty($component)){
                 return Result::error('组件版式类别编号已存在!');
             }
+            // $com_query = clone $com_query;
+            $com_num =  SectorPlace::where('type_id',2)->where('sector_type',$data['sector_type'])->count('sort_id');
+            // return Result::success($com_num);
+            if($sector_type['component_num'] = $com_num){
+                $sector = SectorPlace::where('sector_type',$data['sector_type'])->where('type_id',1)->update(['status'=>1]);
+                if(empty($sector)){
+                    return Result::error('通栏版式状态修改失败!');
+                }
+            }
             $data = [
                 'name' => $data['name'],
                 'component_num' => 0, 
@@ -1698,7 +1715,7 @@ class PublicRpcService implements PublicRpcServiceInterface
             $sector = Sector::where('place_type', $sector_place['sector_type'])->first();
             $component = SectorPlace::where('sector_type', $sector_place['sector_type'])
             ->where('type_id',2)
-            ->first();
+            ->first(); 
             if(!empty($sector) || !empty($component)){
                 return Result::error('通栏版式分类已应用,暂不可删除!');
             }
@@ -1707,6 +1724,11 @@ class PublicRpcService implements PublicRpcServiceInterface
             if(!empty($sector)){
                 return Result::error('组件版式分类已应用,暂不可删除!');
             }
+            $component_num = SectorPlace::where('sector_type', $sector_place['sector_type'])
+            ->where('type_id',1)->update(['status'=> 0]);
+            if(empty($component_num)){
+                return Result::error('通栏版式状态修改失败!');
+            }
         }
        $result = SectorPlace::where('id',$data['id'])->delete();
         if(empty($result)){
@@ -1770,6 +1792,9 @@ class PublicRpcService implements PublicRpcServiceInterface
     public function getAllSectorPlace(array $data): array
     {
         $where['type_id'] = $data['type_id'];
+        if($data['type_id'] == 1){
+            $where['status'] = 1;
+        }
         if(isset($data['sector_type']) && !empty($data['sector_type'])){
             $where['sector_type'] = $data['sector_type'];
         }