User.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: qisse
  5. * Date: 2017/6/27
  6. * Time: 20:02
  7. */
  8. namespace app\core\model;
  9. use think\Config;
  10. use think\Db;
  11. use think\Exception;
  12. use think\Log;
  13. use think\Model;
  14. use tool\Common;
  15. class User extends Model
  16. {
  17. protected $resultSetType = 'collection';
  18. protected $updateTime = 'updateTime';
  19. protected $createTime = 'addTime';
  20. protected $autoWriteTimestamp = true;
  21. const STATUS_OK = 0;
  22. const STATUS_UNBANDING = 1;
  23. const STATUSS = [
  24. self::STATUS_OK=>'正常',
  25. self::STATUS_UNBANDING=>'锁定',
  26. ];
  27. public function userAccount() {
  28. return $this->hasOne('userAccount', 'userID');
  29. }
  30. public function channel() {
  31. return $this->belongsTo('channel', 'channelID');
  32. }
  33. public function createUUID($userID) {
  34. return Common::timetodate(THINK_START_TIME,110).mt_rand(1000,9999).sprintf('%06s', $userID);
  35. }
  36. public function userBank() {
  37. return $this->hasOne('userBank', 'userID');
  38. }
  39. public function createPassword($password) {
  40. return md5('uaaoidusoia9a8d8fsd7f900a7d9sfadjfjadjf'.$password);
  41. }
  42. public function createToken() {
  43. return md5(THINK_START_TIME.Common::token_create(10));
  44. }
  45. public function createTokenOverTime() {
  46. return (int)THINK_START_TIME + 7 * 86400;
  47. }
  48. public function getMobileAsteriskAttr($value, $data) {
  49. return Common::mobileAsterisk($data['mobile']);
  50. }
  51. public function getLoginTimeAttr($value)
  52. {
  53. if($value == 0) {
  54. return '';
  55. }
  56. return 0;
  57. }
  58. public function getAvatarAttr($value, $data) {
  59. return 'http://slb.dahengdian.com/jiaqiancaifu/2018/01/03/V5KL8LKbLE.png';
  60. }
  61. }