Applyskill.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. namespace app\admin\model\service\skill;
  3. use think\Model;
  4. class Applyskill extends Model
  5. {
  6. // 表名
  7. protected $name = 'service_apply_skill';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'applytype_text',
  17. 'sex_text',
  18. 'edu_text',
  19. 'exper_text',
  20. 'state_text'
  21. ];
  22. public function getApplytypeList()
  23. {
  24. return ['0' => __('Applytype 0'), '1' => __('Applytype 1')];
  25. }
  26. public function getSexList()
  27. {
  28. return ['1' => __('Sex 1'), '0' => __('Sex 0')];
  29. }
  30. public function getEduList()
  31. {
  32. return ['0' => __('Edu 0'), '1' => __('Edu 1'), '2' => __('Edu 2'), '3' => __('Edu 3'), '4' => __('Edu 4'), '5' => __('Edu 5'), '6' => __('Edu 6')];
  33. }
  34. public function getExperList()
  35. {
  36. return ['0' => __('Exper 0'), '1' => __('Exper 1'), '2' => __('Exper 2'), '3' => __('Exper 3')];
  37. }
  38. public function getStateList()
  39. {
  40. return ['0' => __('State 0'), '1' => __('State 1'), '-1' => __('State -1')];
  41. }
  42. public function getApplytypeTextAttr($value, $data)
  43. {
  44. $value = $value ? $value : (isset($data['applytype']) ? $data['applytype'] : '');
  45. $list = $this->getApplytypeList();
  46. return isset($list[$value]) ? $list[$value] : '';
  47. }
  48. public function getSexTextAttr($value, $data)
  49. {
  50. $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : '');
  51. $list = $this->getSexList();
  52. return isset($list[$value]) ? $list[$value] : '';
  53. }
  54. public function getEduTextAttr($value, $data)
  55. {
  56. $value = $value ? $value : (isset($data['edu']) ? $data['edu'] : '');
  57. $list = $this->getEduList();
  58. return isset($list[$value]) ? $list[$value] : '';
  59. }
  60. public function getExperTextAttr($value, $data)
  61. {
  62. $value = $value ? $value : (isset($data['exper']) ? $data['exper'] : '');
  63. $list = $this->getExperList();
  64. return isset($list[$value]) ? $list[$value] : '';
  65. }
  66. public function getStateTextAttr($value, $data)
  67. {
  68. $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
  69. $list = $this->getStateList();
  70. return isset($list[$value]) ? $list[$value] : '';
  71. }
  72. public static function createTime($id)
  73. {
  74. $start = strtotime(date("Y-m-d",time()));
  75. $data['skill_id'] = $id;
  76. for($a = 0;$a<3;$a++)
  77. {
  78. $data['timetype'] = $a;
  79. for($b = 0;$b<48;$b++)
  80. {
  81. $data['number'] = $b;
  82. switch ($a) {
  83. case 1:
  84. $data['starttime'] = 1800*$b+$start+86400;
  85. $data['endtime'] = 1800*$b+$start+1799+86400;
  86. break;
  87. case 2:
  88. $data['starttime'] = 1800*$b+$start+172800;
  89. $data['endtime'] = 1800*$b+$start+1799+172800;
  90. break;
  91. case 0:
  92. default:
  93. $data['starttime'] = 1800*$b+$start;
  94. $data['endtime'] = 1800*$b+$start+1799;
  95. break;
  96. }
  97. $data['createtime'] = time();
  98. $data['changetime'] = time();
  99. $data['state'] = 0;
  100. db('service_skill_time')->insert($data);
  101. }
  102. }
  103. return true;
  104. }
  105. public function cate()
  106. {
  107. return $this->hasOne('Skillcate','id','skill_cate_id')->field('id,name');
  108. }
  109. public function category()
  110. {
  111. return $this->hasOne('app\admin\model\service\Category','id','category_id')->field('id,name');
  112. }
  113. }