Explorar el Código

任务计划更新状态

moonsflyer hace 8 meses
padre
commit
6bfab7ca75
Se han modificado 2 ficheros con 25 adiciones y 2 borrados
  1. 6 1
      app/api/controller/ServiceController.php
  2. 19 1
      app/api/logic/ServiceLogic.php

+ 6 - 1
app/api/controller/ServiceController.php

@@ -29,7 +29,7 @@ use app\api\lists\service\ServiceLists;
 class ServiceController extends BaseApiController
 {
 
-    public array $notNeedLogin = ['getServiceList','getAreaList','getCateList','getServiceInfo'];
+    public array $notNeedLogin = ['getServiceList','getAreaList','getCateList','getServiceInfo','autoUpdateStatus'];
 
 
     /**
@@ -145,4 +145,9 @@ class ServiceController extends BaseApiController
             return $this->fail('请求方式错误');
         }
     }
+
+    public function autoUpdateStatus(){
+        $result = ServiceLogic::updateServiceStatus();
+        return $this->success($result, [], 1, 1);
+    }
 }

+ 19 - 1
app/api/logic/ServiceLogic.php

@@ -248,6 +248,24 @@ class ServiceLogic extends BaseLogic
         }
     }
 
-
+    public static function updateServiceStatus(){
+        $where = [];
+        $where[]=['status','=' ,1];
+        $where[]=['is_auto_upd','=', 0];
+        $where[]=['expiration_time','<', time()];
+        $list = UserService::where($where)->select()->toArray();
+        $remark = '';
+        foreach($list as $k=>$v){
+            $updatewhere['id'] = $v['id'];
+            $updateData['status'] = 2;
+            $updateData['is_auto_upd'] = 1;
+            UserService::where($updatewhere)->update($updateData);
+            $remark .='id='.$v['id'].'~已到期,状态更新~';
+        }
+        if(empty($remark)){
+            $remark = '无更新数据';
+        }
+        return $remark;
+    }
 
 }