User.php 4.7 KB

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