wupengfei 2 years ago
parent
commit
a157ebcf77

+ 3 - 1
.idea/workspace.xml

@@ -3,6 +3,8 @@
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/common/model/PlatformSwitch.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common/model/PlatformSwitch.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/common/model/UserMessage.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common/model/UserMessage.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -204,7 +206,7 @@
       <workItem from="1670719843429" duration="8446000" />
       <workItem from="1670807412269" duration="9728000" />
       <workItem from="1671065604459" duration="7662000" />
-      <workItem from="1671152221434" duration="13253000" />
+      <workItem from="1671152221434" duration="13755000" />
     </task>
     <servers />
   </component>

+ 7 - 11
application/common/model/PlatformSwitch.php

@@ -13,7 +13,8 @@ class PlatformSwitch extends Model
      * @return int
      */
     public static function checkSwitch($user_id,$id,$type){
-        return self::where(['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type])->value('id') ? 1:0;
+        $switch_value = self::where(['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type])->value('switch_value');
+        return $switch_value === 0 ? 0 : 1;
     }
     /**
      * @param $user_id
@@ -22,17 +23,12 @@ class PlatformSwitch extends Model
      */
     public static function userSwitch($user_id,$id,$type)
     {
-        $ret_val = 0;
         $check_tags =  self::checkSwitch($user_id,$id,$type);
-        if($check_tags) {
-            self::where(['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type])->delete();
-        }else{
-            Data::save('PlatformSwitch',
-                ['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type],'user_id',
-                ['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type]);
-            $ret_val = 1;
-        }
-        return $ret_val;
+        $switch_value = $check_tags ? 0:1;
+        Data::save('PlatformSwitch',
+            ['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type,'switch_value'=>$switch_value],'user_id',
+            ['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type]);
+        return $switch_value;
     }
 
 }

+ 1 - 1
application/common/model/UserMessage.php

@@ -88,7 +88,7 @@ class UserMessage extends Model
                 if(in_array($type,[1])) Jpush($to_user,$from_name.$message['content'],$module,$type,$rel_id);// $message['jg_type'] = 1;
                 break;
             case 'forum':
-                $switch  = PlatformSwitch::userSwitch($to_user,$rel_id,1);
+                $switch  = PlatformSwitch::checkSwitch($to_user,$rel_id,1);
                 if($switch && in_array($type,[3,4,5]))Jpush($to_user,$from_name.$message['content'],$module,$type,$rel_id);// $message['jg_type'] = 1;
                 break;
             case 'feedback':