RoutineFormId.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. * @var string
  14. */
  15. protected $pk = 'id';
  16. /**
  17. * 模型名称
  18. * @var string
  19. */
  20. protected $name = 'routine_form_id';
  21. use ModelTrait;
  22. /**
  23. * 删除已失效的formID
  24. * @return int
  25. */
  26. public static function delStatusInvalid(){
  27. return self::where('status',2)->where('stop_time','<',time())->delete();
  28. }
  29. /**
  30. * 获取一个可以使用的formId
  31. * @return bool|mixed
  32. */
  33. public static function getFormIdOne($uid = 0){
  34. $formId = self::where('status',1)->where('stop_time','>',time())->where('uid',$uid)->order('id asc')->find();
  35. if($formId) return $formId['form_id'];
  36. else return false;
  37. }
  38. /**
  39. * 修改一个FormID为已使用
  40. * @param string $formId
  41. * @return $this|bool
  42. */
  43. public static function delFormIdOne($formId = ''){
  44. if($formId == '') return true;
  45. return self::where('form_id',$formId)->update(['status'=>2]);
  46. }
  47. }