User.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020/2/12
  6. * Time: 17:11
  7. */
  8. namespace app\worker\controller;
  9. use app\index\model\Cweb;
  10. use think\facade\Db;
  11. use Workerman\Lib\Timer;
  12. class User
  13. {
  14. // 实验室预约 未上课处理 解除爽约时间限制
  15. public function index()
  16. {
  17. Timer::add(2, function () {
  18. // var_dump(1212);
  19. $this->laboratory_appointment(); // 实验室预约 未上课处理
  20. $this->laboratory_appointment_status();// 解除爽约时间限制
  21. var_dump("index");
  22. }, true);
  23. }
  24. /**
  25. * 获取学生成绩
  26. */
  27. public function student_status()
  28. {
  29. Timer::add(10, function () {
  30. $cweb=new Cweb();
  31. $cweb->student_status();
  32. var_dump("student_status");
  33. }, true);
  34. }
  35. /**
  36. 获取老师数据
  37. */
  38. public function getteacher()
  39. {
  40. Timer::add(10, function () {
  41. $cweb=new Cweb();
  42. $cweb->getteacher();
  43. var_dump("getteacher");
  44. }, true);
  45. }
  46. // 实验室预约 未上课处理
  47. public function laboratory_appointment()
  48. {
  49. $where[] = ["end_time", "<", time()];
  50. $where[] = ["status", "=", 0];
  51. $laboratory_appointment = Db::name("laboratory_appointment")->where($where)->limit(10)->select()->toArray();
  52. if ($laboratory_appointment) {
  53. $agreement = Db::name("systems")->where(["id" => 1])->value("agreement");
  54. foreach ($laboratory_appointment as $k => $v) {
  55. $update["status"] = 2;
  56. if ($agreement) {
  57. $update["day"] = (int)$agreement;
  58. $update["kai_time"] = $laboratory_appointment["stat_time"] + $agreement * 24 * 60 * 60;// 禁止报名时间
  59. }
  60. Db::name("laboratory_appointment")->where(["id" => $v["id"]])->update($update);
  61. }
  62. }
  63. }
  64. // 解除爽约时间限制
  65. public function laboratory_appointment_status()
  66. {
  67. $where["status"] = 2;
  68. $laboratory_appointment = Db::name("laboratory_appointment")
  69. ->where("kai_time", "<>", "")
  70. ->where("kai_time", "<", time())->where($where)->limit(10)->select()->toArray();
  71. if ($laboratory_appointment) {
  72. foreach ($laboratory_appointment as $k => $v) {
  73. Db::name("laboratory_appointment")->where(["id" => $v["id"]])->update(["kai_time" => ""]);
  74. }
  75. }
  76. }
  77. // 升级
  78. public function star_class()
  79. {
  80. }
  81. }