WIN-2308041133\Administrator hai 2 meses
pai
achega
2aedd752fc
Modificáronse 1 ficheiros con 18 adicións e 3 borrados
  1. 18 3
      app/model/api/Sys.php

+ 18 - 3
app/model/api/Sys.php

@@ -48,11 +48,26 @@ class Sys extends Model
             "title"   => empty($data["title"])?"":$data["title"],
             "title"   => empty($data["title"])?"":$data["title"],
             "query"   => empty($data["query"])?"":$data["query"],
             "query"   => empty($data["query"])?"":$data["query"],
             "content" => empty($data["content"])?"":$data["content"],
             "content" => empty($data["content"])?"":$data["content"],
-            "is_show" => empty($data["is_show"])?"":$data["is_show"],
+            "is_show" => isset($data["is_show"]) ? $data["is_show"] : 0,
         ];
         ];
-        @file_put_contents('quanju.txt',  json_encode($save)."-应该保存的的传参\r\n", 8);
+        @file_put_contents('quanju.txt', "【".date('Y-m-d H:i:s')."】传参: ".json_encode($data, JSON_UNESCAPED_UNICODE)." \r\n", 8);
+        @file_put_contents('quanju.txt', "【".date('Y-m-d H:i:s')."】处理后: ".json_encode($save, JSON_UNESCAPED_UNICODE)." \r\n", 8);
 
 
-        $this->where("id",1)->update(["shareconfig"=> serialize($save)]);
+        // 检查 id=1 的记录是否存在
+        $exists = $this->where("id", 1)->find();
+        if (!$exists) {
+            @file_put_contents('quanju.txt', "【".date('Y-m-d H:i:s')."】id=1 不存在,执行插入 \r\n", 8);
+            $result = $this->insert([
+                "id" => 1,
+                "shareconfig" => serialize($save)
+            ]);
+        } else {
+            @file_put_contents('quanju.txt', "【".date('Y-m-d H:i:s')."】id=1 存在,执行更新 \r\n", 8);
+            $result = $this->where("id", 1)->update(["shareconfig" => serialize($save)]);
+        }
+        @file_put_contents('quanju.txt', "【".date('Y-m-d H:i:s')."】更新结果: ".$result." \r\n", 8);
+
+        return $result;
     }
     }
     /**
     /**
      * 邀请配置
      * 邀请配置