User.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. 'balance' => 'decimal',
  52. ];
  53. // 设置字段自动转换类型
  54. protected $type = [
  55. 'bankcard' => 'json',
  56. 'createtime' => 'timestamp:Y-m-d H:i:s',
  57. 'emp_time' => 'json',
  58. 'com_cate' => 'json',
  59. 'work_place' => 'json',
  60. 'user_tags' => 'json',
  61. ];
  62. protected $jsonAssoc = true;
  63. public function getStatusTextAttr($value, $data)
  64. {
  65. $status = [1 => '待审核', 2 => '已通过', 3 => '未通过'];
  66. return $status[$data['status']];
  67. }
  68. public function getIsvipTextAttr($value, $data)
  69. {
  70. $isvip = [1 => '否', 2 => '是'];
  71. return $isvip[$data['isvip']];
  72. }
  73. public function getAuthstatusTextAttr($value, $data)
  74. {
  75. $authstatus = [1 => '待认证', 2 => '待审核', 3 => '已认证'];
  76. return $authstatus[$data['authstatus']];
  77. }
  78. public function getFollowstatusTextAttr($value, $data)
  79. {
  80. $followstatus = [1 => '未跟进', 2 => '未面试', 3 => '面试通过', 4 => '面试未通过', 5 => '用户放弃', 6 => '已入职', 7 => '已离职'];
  81. return $followstatus[$data['followstatus']];
  82. }
  83. public function getEducationTextAttr($value, $data)
  84. {
  85. $education = ['' => '', 1 => '初中', 2 => '高中', 3 => '中技', 4 => '中专', 5 => '大专', 6 => '本科', 7 => '硕士', 8 => '博士'];
  86. return $education[$data['education']];
  87. }
  88. public function getWorkerTextAttr($value, $data)
  89. {
  90. $experience = ['' => '', 1 => '无经验', 2 => '一年以下', 3 => '1-3年', 4 => '3-5年', 5 => '5-10年', 6 => '10年以上'];
  91. return $experience[$data['workexperience']];
  92. }
  93. public function getJobintentionTextAttr($value, $data)
  94. {
  95. $title = '';
  96. if ($data['jobintention']) {
  97. $title = UserWill::where('id', $data['jobintention'])->value('title');
  98. }
  99. return $title;
  100. }
  101. // 关联UserGroups
  102. public function userGroups()
  103. {
  104. return $this->hasOne(UserGroups::class, "id", "groupsid");
  105. }
  106. // 关联WorkerGroups
  107. public function workerGroup()
  108. {
  109. return $this->hasOne(WorkerGroup::class, "id", "groupid");
  110. }
  111. // 关联Broker
  112. public function broker()
  113. {
  114. return $this->hasOne(Broker::class, "id", "brokerid");
  115. }
  116. // 关联UserPart
  117. public function userPart()
  118. {
  119. return $this->hasMany(UserPart::class, "puserid", "id");
  120. }
  121. // 关联UserAuths
  122. public function userAuths()
  123. {
  124. return $this->hasMany(UserAuths::class, "userid", "id");
  125. }
  126. // 关联UserFollow
  127. public function userFollow()
  128. {
  129. return $this->hasMany(UserFollow::class, "userid", "id")->order('id', 'desc');
  130. }
  131. }