| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace app\model; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use Exception; | 
					
						
							|  |  |  | use think\exception\ValidateException; | 
					
						
							| 
									
										
										
										
											2021-12-01 14:56:09 +08:00
										 |  |  | use think\model\relation\HasOne; | 
					
						
							| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class Account extends Base | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-24 16:19:54 +08:00
										 |  |  |     public const type_visitor       = -1;//游客
 | 
					
						
							|  |  |  |     public const type_consumer      = 0;//普通用户
 | 
					
						
							| 
									
										
										
										
											2021-11-19 19:06:22 +08:00
										 |  |  |     public const type_business      = 1;//商家
 | 
					
						
							|  |  |  |     public const type_staff         = 2;//员工
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-24 16:19:54 +08:00
										 |  |  |     // 默认头像
 | 
					
						
							|  |  |  |     public const DEFAULT_AVATAR         = '/static/images/default-avatar.png'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-30 15:26:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-19 19:06:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-24 16:19:54 +08:00
										 |  |  |     public static function accountTypeDescList(): array | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return [ | 
					
						
							|  |  |  |             (string) self::type_visitor     => '游客', | 
					
						
							|  |  |  |             (string) self::type_consumer    => '普通用户', | 
					
						
							|  |  |  |             (string) self::type_business    => '商家', | 
					
						
							|  |  |  |             (string) self::type_staff       => '员工', | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-19 19:06:22 +08:00
										 |  |  |     public function tag() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasOne(Tag::class,"id","tag_id"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 14:56:09 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * 关联的商户信息 | 
					
						
							|  |  |  |      * @return HasOne | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function business() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasOne(Business::class, 'code', 'business_code'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 关联的上级用户 | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function parent() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasOne(self::class, 'user_code', 'main_code'); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | } |