User.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class User extends Model
  6. {
  7. use SoftDelete;
  8. protected $deleteTime = 'deletetime';
  9. protected $defaultSoftDelete = 0;
  10. // 设置字段信息
  11. protected $schema = [
  12. 'id' => 'int',
  13. 'groupsid' => 'int',
  14. 'groupid' => 'int',
  15. 'brokerid' => 'int',
  16. 'nickname' => 'string',
  17. 'avatar' => 'string',
  18. 'realname' => 'string',
  19. 'mobile' => 'string',
  20. 'integral' => 'int',
  21. 'inttotal' => 'int',
  22. 'status' => 'tinyint',
  23. 'isvip' => 'tinyint',
  24. 'authstatus' => 'int',
  25. 'authremark' => 'string',
  26. 'idcardzpic' => 'string',
  27. 'idcardfpic' => 'string',
  28. 'idcard' => 'string',
  29. 'gender' => 'tinyint',
  30. 'birthday' => 'string',
  31. 'address' => 'string',
  32. 'education' => 'string',
  33. 'createtime' => 'int',
  34. 'jobintention' => 'string',
  35. 'workexperience' => 'string',
  36. 'eduexperience' => 'string',
  37. 'followstatus' => 'tinyint',
  38. 'wxampcode' => 'string',
  39. 'bankcard' => 'string',
  40. 'emp_time' => 'string',
  41. 'user_tags' => 'string',
  42. 'com_cate' => 'string',
  43. 'is_public' => 'int',
  44. 'volume' => 'int',
  45. 'deletetime' => 'int',
  46. 'work_place' => 'string',
  47. 'com_cate_type' => 'int',
  48. 'com_cate_other' => 'string',
  49. 'is_perfect' => 'int',
  50. 'is_auth' => 'int',
  51. ];
  52. // 设置字段自动转换类型
  53. protected $type = [
  54. 'bankcard' => 'json',
  55. 'createtime' => 'timestamp:Y-m-d H:i:s',
  56. 'emp_time' => 'json',
  57. 'com_cate' => 'json',
  58. 'work_place' => 'json',
  59. 'user_tags' => 'json',
  60. ];
  61. protected $jsonAssoc = true;
  62. public function getStatusTextAttr($value, $data)
  63. {
  64. $status = [1 => '待审核', 2 => '已通过', 3 => '未通过'];
  65. return $status[$data['status']];
  66. }
  67. public function getIsvipTextAttr($value, $data)
  68. {
  69. $isvip = [1 => '否', 2 => '是'];
  70. return $isvip[$data['isvip']];
  71. }
  72. public function getAuthstatusTextAttr($value, $data)
  73. {
  74. $authstatus = [1 => '待认证', 2 => '待审核', 3 => '已认证'];
  75. return $authstatus[$data['authstatus']];
  76. }
  77. public function getFollowstatusTextAttr($value, $data)
  78. {
  79. $followstatus = [1 => '未跟进', 2 => '未面试', 3 => '面试通过', 4 => '面试未通过', 5 => '用户放弃', 6 => '已入职', 7 => '已离职'];
  80. return $followstatus[$data['followstatus']];
  81. }
  82. public function getEducationTextAttr($value, $data)
  83. {
  84. $education = ['' => '', 1 => '初中', 2 => '高中', 3 => '中技', 4 => '中专', 5 => '大专', 6 => '本科', 7 => '硕士', 8 => '博士'];
  85. return $education[$data['education']];
  86. }
  87. public function getWorkerTextAttr($value, $data)
  88. {
  89. $experience = ['' => '', 1 => '无经验', 2 => '一年以下', 3 => '1-3年', 4 => '3-5年', 5 => '5-10年', 6 => '10年以上'];
  90. return $experience[$data['workexperience']];
  91. }
  92. public function getJobintentionTextAttr($value, $data)
  93. {
  94. $title = '';
  95. if ($data['jobintention']) {
  96. $title = UserWill::where('id', $data['jobintention'])->value('title');
  97. }
  98. return $title;
  99. }
  100. // 关联UserGroups
  101. public function userGroups()
  102. {
  103. return $this->hasOne(UserGroups::class, "id", "groupsid");
  104. }
  105. // 关联WorkerGroups
  106. public function workerGroup()
  107. {
  108. return $this->hasOne(WorkerGroup::class, "id", "groupid");
  109. }
  110. // 关联Broker
  111. public function broker()
  112. {
  113. return $this->hasOne(Broker::class, "id", "brokerid");
  114. }
  115. // 关联UserPart
  116. public function userPart()
  117. {
  118. return $this->hasMany(UserPart::class, "puserid", "id");
  119. }
  120. // 关联UserAuths
  121. public function userAuths()
  122. {
  123. return $this->hasMany(UserAuths::class, "userid", "id");
  124. }
  125. // 关联UserFollow
  126. public function userFollow()
  127. {
  128. return $this->hasMany(UserFollow::class, "userid", "id")->order('id', 'desc');
  129. }
  130. }