durong 5 anni fa
parent
commit
544a6d84a5
1 ha cambiato i file con 7 aggiunte e 9 eliminazioni
  1. 7 9
      app/Repositories/V2/CmsContentTemplateSetRepository.php

+ 7 - 9
app/Repositories/V2/CmsContentTemplateSetRepository.php

@@ -20,7 +20,6 @@ class CmsContentTemplateSetRepository {
     //banner模板选专题-被使用计数
     public function countSubject($request)
     {
-        Log::debug(json_encode($request));
         $type = intval($request['type']);
         if ($type == 0) {
             $rule = json_decode($request['rule'], true);
@@ -30,29 +29,28 @@ class CmsContentTemplateSetRepository {
                 $templates->save();
             }
         }
-        if ($type == 1) { Log::debug($request['type']);
+        if ($type == 1) {
             $subject_id_array = json_decode($request['old_rule'], true);
-            $rule = json_decode($request['rule'], true);
-            if ($subject_id_array['link_type'] == 1 && $rule['link_type'] == 1) {//链接方式都为专题
-                if ($subject_id_array['link_url'] != $rule['link_url']) {
+            if ($subject_id_array['link_type'] == 1 && $request['rule']['link_type'] == 1) {//链接方式都为专题
+                if ($subject_id_array['link_url'] != $request['rule']['link_url']) {
                     $templates = $this->cmsSubject->where('id', intval($subject_id_array['link_url']))->first();
                     $update_template = [
                         $templates->used_count -= 1
                     ];
                     $templates->update($update_template);
 
-                    $templates = $this->cmsSubject->where('id', intval($rule['link_type']))->first();
+                    $templates = $this->cmsSubject->where('id', intval($request['rule']['link_type']))->first();
                     $templates->used_count += 1;
                     $templates->save();
                 }
-            } elseif ($subject_id_array['link_type'] == 1 && $rule['link_type'] != 1) {
+            } elseif ($subject_id_array['link_type'] == 1 && $request['rule']['link_type'] != 1) {
                 $templates = $this->cmsSubject->where('id', intval($subject_id_array['link_url']))->first();
                 $update_template = [
                     $templates->used_count -= 1
                 ];
                 $templates->update($update_template);
-            } elseif ($subject_id_array['link_type'] != 1 && $rule['link_type'] == 1) {
-                $templates = $this->cmsSubject->where('id', intval($rule['link_url']))->first();
+            } elseif ($subject_id_array['link_type'] != 1 && $request['rule']['link_type'] == 1) {
+                $templates = $this->cmsSubject->where('id', intval($request['rule']['link_url']))->first();
                 $templates->used_count += 1;
                 $templates->save();
             }