RoutineFormId.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\admin\model\routine;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. /**
  6. * 表单ID表
  7. * Class RoutineFormId
  8. * @package app\admin\model\routine
  9. */
  10. class RoutineFormId extends BaseModel
  11. {
  12. /**
  13. * 数据表主键
  14. * @var string
  15. */
  16. protected $pk = 'id';
  17. /**
  18. * 模型名称
  19. * @var string
  20. */
  21. protected $name = 'routine_form_id';
  22. use ModelTrait;
  23. /**
  24. * 删除已失效的formID
  25. * @return int
  26. */
  27. public static function delStatusInvalid()
  28. {
  29. return self::where('status', 2)->where('stop_time', '<', time())->delete();
  30. }
  31. /**
  32. * 获取一个可以使用的formId
  33. * @return bool|mixed
  34. */
  35. public static function getFormIdOne($uid = 0)
  36. {
  37. $formId = self::where('status', 1)->where('stop_time', '>', time())->where('uid', $uid)->order('id asc')->find();
  38. if ($formId) return $formId['form_id'];
  39. else return false;
  40. }
  41. /**
  42. * 修改一个FormID为已使用
  43. * @param string $formId
  44. * @return $this|bool
  45. */
  46. public static function delFormIdOne($formId = '')
  47. {
  48. if ($formId == '') return true;
  49. return self::where('form_id', $formId)->update(['status' => 2]);
  50. }
  51. }