| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace app\model; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use think\Collection; | 
					
						
							|  |  |  | use think\db\exception\DataNotFoundException; | 
					
						
							|  |  |  | use think\db\exception\DbException; | 
					
						
							|  |  |  | use think\db\exception\ModelNotFoundException; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * 商家分类 | 
					
						
							|  |  |  |  * Class Disease | 
					
						
							|  |  |  |  * @package app\model | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class Category extends Base | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 根据父级ID 获取病种列表 | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param  int  $pid | 
					
						
							|  |  |  |      * @param  string[]  $fields | 
					
						
							|  |  |  |      * @return Disease[]|array|Collection | 
					
						
							|  |  |  |      * @throws DataNotFoundException | 
					
						
							|  |  |  |      * @throws DbException | 
					
						
							|  |  |  |      * @throws ModelNotFoundException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public static function getListByPid(int $pid = 0, array $fields = ['pid', 'name', 'id']) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return self::where('pid', $pid)->order('id', 'desc')->field($fields)->select(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2021-11-23 17:13:55 +08:00
										 |  |  |      * 获取全部列表 | 
					
						
							| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return Disease[]|array|Collection | 
					
						
							|  |  |  |      * @throws DataNotFoundException | 
					
						
							|  |  |  |      * @throws DbException | 
					
						
							|  |  |  |      * @throws ModelNotFoundException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public static function getList() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return self::field('id,pid,name,commision')->order('id', 'desc')->order('id')->select(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 病种 xmSelect json数据 | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param  int  $pid | 
					
						
							|  |  |  |      * @param  array  $selected | 
					
						
							|  |  |  |      * @param  array  $disabled | 
					
						
							|  |  |  |      * @return array|Disease[]|Collection | 
					
						
							|  |  |  |      * @throws DataNotFoundException | 
					
						
							|  |  |  |      * @throws DbException | 
					
						
							|  |  |  |      * @throws ModelNotFoundException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public static function diseaseXmJson(int $pid = 0, array $selected = [], array $disabled = []) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $list = self::getListByPid($pid); | 
					
						
							|  |  |  |         foreach ($list as $k => $m) { | 
					
						
							|  |  |  |             $list[$k]['selected'] = in_array($m['id'], $selected); | 
					
						
							|  |  |  |             $list[$k]['disabled'] = in_array($m['id'], $disabled); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $list; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |