sugangqiang 2 년 전
부모
커밋
6768509f9b
1개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 14 0
      app/common/api/BatchApi.php

+ 14 - 0
app/common/api/BatchApi.php

@@ -140,9 +140,23 @@ class BatchApi {
         $data["id"] = $id;
         $data["active"] = $active ?: 2;
         Batch::update($data);
+        if ($active == 1) {
+            self::setOtherNoActive($id);
+        }
         return ["code" => 200, "msg" => "成功"];
     }
 
+    public static function setOtherNoActive($except_id) {
+        $open = self::getOne($except_id);
+        if ($open) {
+            $type = $open["type"];
+            $where[] = ["type", "=", $type];
+            $where[] = ["id", "<>", $except_id];
+            $data["active"] = 2;
+            Batch::where($where)->update($data);
+        }
+    }
+
     /**
      * 
      * @param type $type 申报类别