1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2020/2/12
- * Time: 17:11
- */
- namespace app\worker\controller;
- use app\index\model\Cweb;
- use think\facade\Db;
- use Workerman\Lib\Timer;
- class User
- {
- // 实验室预约 未上课处理 解除爽约时间限制
- public function index()
- {
- Timer::add(2, function () {
- // var_dump(1212);
- $this->laboratory_appointment(); // 实验室预约 未上课处理
- $this->laboratory_appointment_status();// 解除爽约时间限制
- var_dump("index");
- }, true);
- }
- /**
- * 获取学生成绩
- */
- public function student_status()
- {
- Timer::add(10, function () {
- $cweb=new Cweb();
- $cweb->student_status();
- var_dump("student_status");
- }, true);
- }
- /**
- 获取老师数据
- */
- public function getteacher()
- {
- Timer::add(10, function () {
- $cweb=new Cweb();
- $cweb->getteacher();
- var_dump("getteacher");
- }, true);
- }
- // 实验室预约 未上课处理
- public function laboratory_appointment()
- {
- $where[] = ["end_time", "<", time()];
- $where[] = ["status", "=", 0];
- $laboratory_appointment = Db::name("laboratory_appointment")->where($where)->limit(10)->select()->toArray();
- if ($laboratory_appointment) {
- $agreement = Db::name("systems")->where(["id" => 1])->value("agreement");
- foreach ($laboratory_appointment as $k => $v) {
- $update["status"] = 2;
- if ($agreement) {
- $update["day"] = (int)$agreement;
- $update["kai_time"] = $laboratory_appointment["stat_time"] + $agreement * 24 * 60 * 60;// 禁止报名时间
- }
- Db::name("laboratory_appointment")->where(["id" => $v["id"]])->update($update);
- }
- }
- }
- // 解除爽约时间限制
- public function laboratory_appointment_status()
- {
- $where["status"] = 2;
- $laboratory_appointment = Db::name("laboratory_appointment")
- ->where("kai_time", "<>", "")
- ->where("kai_time", "<", time())->where($where)->limit(10)->select()->toArray();
- if ($laboratory_appointment) {
- foreach ($laboratory_appointment as $k => $v) {
- Db::name("laboratory_appointment")->where(["id" => $v["id"]])->update(["kai_time" => ""]);
- }
- }
- }
- // 升级
- public function star_class()
- {
- }
- }
|