User.php 4.9 KB

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