WIN-2308041133\Administrator 4 days ago
parent
commit
9fb9551031
1 changed files with 14 additions and 6 deletions
  1. 14 6
      app/api/controller/Education.php

+ 14 - 6
app/api/controller/Education.php

@@ -283,13 +283,21 @@ class Education
     }
 //    合约时间到期自动解约
     public function ContractTemplatEnd(){
-        $lst = (new UserContractRecordModel())->where("status",1)->where("end_time","<",time())->select();
-        if(!empty($lst)){
-            $lst = $lst->toArray();
-            Log::info('搜索条件:' . json_encode($lst, JSON_UNESCAPED_UNICODE));
+        try {
+            $lst = (new UserContractRecordModel())->where("status",1)->where("end_time","<",time())->select();
+            if(!empty($lst)){
+                $lst = $lst->toArray();
+                Log::info('搜索条件:' . json_encode($lst, JSON_UNESCAPED_UNICODE));
+            }
+            @file_put_contents('quanju.txt', json_encode($lst) . "-到期合约列表\r\n", 8);
+
+            (new UserContractRecordModel())->where("status",1)->where("end_time","<",time())->update(["status"=>2]);
+            return app('json')->success('修改完成');
+        } catch (\Exception $e) {
+            $errorMsg = date('Y-m-d H:i:s') . ' 错误: ' . $e->getMessage() . "\r\n";
+            @file_put_contents('quanju.txt', $errorMsg, FILE_APPEND);
+            return app('json')->fail('操作失败: ' . $e->getMessage());
         }
-        (new UserContractRecordModel())->where("status",1)->where("end_time","<",time())->update(["status"=>2]);
-        return app('json')->success('修改完成');
     }