commit | author | age
|
2207d6
|
1 |
<?php |
W |
2 |
|
|
3 |
namespace app\models; |
|
4 |
|
|
5 |
use Yii; |
|
6 |
|
|
7 |
/** |
|
8 |
* This is the model class for table "{{%user_info}}". |
|
9 |
* |
|
10 |
* @property string $id |
|
11 |
* @property int $user_id |
|
12 |
* @property string $avatar 头像 |
|
13 |
* @property string $platform_user_id 用户所属平台的用户id |
|
14 |
* @property int $integral 积分 |
|
15 |
* @property int $total_integral 最高积分 |
|
16 |
* @property string $balance 余额 |
|
17 |
* @property string $total_balance 总余额 |
|
18 |
* @property int $parent_id 上级id |
|
19 |
* @property int $is_blacklist 是否黑名单 |
|
20 |
* @property string $contact_way 联系方式 |
|
21 |
* @property string $remark 备注 |
|
22 |
* @property int $is_delete |
|
23 |
* @property string $junior_at 成为下级时间 |
|
24 |
* @property string $platform 用户所属平台标识 |
|
25 |
* @property int $temp_parent_id 临时上级 |
|
26 |
* @property string $remark_name 备注名 |
|
27 |
* @property string $pay_password 支付密码 |
|
28 |
* @property User $parent 父级 |
|
29 |
* @property UserInfo[] $firstChildren 一级下级 |
|
30 |
* @property UserInfo[] $secondChildren 二级下级 |
|
31 |
* @property UserInfo[] $thirdChildren 三级下级 |
|
32 |
*/ |
|
33 |
class UserInfo extends ModelActiveRecord |
|
34 |
{ |
|
35 |
const PLATFORM_WXAPP = 'wxapp'; |
|
36 |
const PLATFORM_ALIAPP = 'aliapp'; |
|
37 |
const PLATFORM_BDAPP = 'bdapp'; |
|
38 |
const PLATFORM_TTAPP = 'ttapp'; |
|
39 |
const PLATFORM_H5 = 'mobile'; |
|
40 |
const PLATFORM_WECHAT = 'wechat'; |
|
41 |
|
|
42 |
/** |
|
43 |
* {@inheritdoc} |
|
44 |
*/ |
|
45 |
public static function tableName() |
|
46 |
{ |
|
47 |
return '{{%user_info}}'; |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* {@inheritdoc} |
|
52 |
*/ |
|
53 |
public function rules() |
|
54 |
{ |
|
55 |
return [ |
|
56 |
[['user_id'], 'required'], |
|
57 |
[['user_id', 'integral', 'total_integral', 'parent_id', 'is_blacklist', 'is_delete', 'temp_parent_id'], 'integer'], |
|
58 |
[['balance', 'total_balance'], 'number'], |
|
59 |
[['junior_at'], 'safe'], |
|
60 |
[['avatar', 'platform_user_id', 'contact_way', 'remark', 'platform', 'remark_name', 'pay_password'], 'string', 'max' => 255], |
|
61 |
]; |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* {@inheritdoc} |
|
66 |
*/ |
|
67 |
public function attributeLabels() |
|
68 |
{ |
|
69 |
return [ |
|
70 |
'id' => 'ID', |
|
71 |
'user_id' => 'User ID', |
|
72 |
'avatar' => '头像', |
|
73 |
'platform_user_id' => '用户所属平台的用户id', |
|
74 |
'integral' => '积分', |
|
75 |
'total_integral' => '最高积分', |
|
76 |
'balance' => '余额', |
|
77 |
'total_balance' => '总余额', |
|
78 |
'parent_id' => '上级id', |
|
79 |
'is_blacklist' => '是否黑名单', |
|
80 |
'contact_way' => '联系方式', |
|
81 |
'remark' => '备注', |
|
82 |
'is_delete' => 'Is Delete', |
|
83 |
'junior_at' => '成为下级时间', |
|
84 |
'platform' => '用户所属平台标识', |
|
85 |
'temp_parent_id' => '临时上级', |
|
86 |
'remark_name' => '备注名', |
|
87 |
'pay_password' => '支付密码', |
|
88 |
]; |
|
89 |
} |
|
90 |
|
|
91 |
public function getParent() |
|
92 |
{ |
|
93 |
return $this->hasOne(User::className(), ['id' => 'parent_id']); |
|
94 |
} |
|
95 |
|
|
96 |
public function getFirstChildren() |
|
97 |
{ |
|
98 |
return $this->hasMany(self::className(), ['parent_id' => 'user_id']); |
|
99 |
} |
|
100 |
|
|
101 |
public function getSecondChildren() |
|
102 |
{ |
|
103 |
return $this->hasMany(self::className(), ['parent_id' => 'user_id']) |
|
104 |
->via('firstChildren'); |
|
105 |
} |
|
106 |
|
|
107 |
public function getThirdChildren() |
|
108 |
{ |
|
109 |
return $this->hasMany(self::className(), ['parent_id' => 'user_id']) |
|
110 |
->via('secondChildren'); |
|
111 |
} |
|
112 |
|
|
113 |
public function getIdentity() |
|
114 |
{ |
|
115 |
return $this->hasOne(UserIdentity::className(), ['user_id' => 'user_id']); |
|
116 |
} |
|
117 |
} |