93 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			93 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
|  | <?php | ||
|  | 
 | ||
|  | namespace app\model; | ||
|  | 
 | ||
|  | //桌号管理
 | ||
|  | class Desk extends Base | ||
|  | { | ||
|  |     protected $autoWriteTimestamp = true; | ||
|  | 
 | ||
|  |     //桌号类型  1 - 12人
 | ||
|  |     static $desk_type = [ | ||
|  |         "1"=>"单人", | ||
|  |         "2"=>"双人", | ||
|  |         "3"=>"3人", | ||
|  |         "4"=>"4人", | ||
|  |         "5"=>"5人", | ||
|  |         "6"=>"6人", | ||
|  |         "7"=>"7人", | ||
|  |         "8"=>"8人", | ||
|  |         "9"=>"9人", | ||
|  |         "10"=>"10人", | ||
|  |         "12"=>"12人", | ||
|  |     ]; | ||
|  |     static $default_type = "12"; | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  |     /** | ||
|  |      * 获取文章列表 | ||
|  |      * @param int $per 每页数量 | ||
|  |      * @param string $keyword 关键词 | ||
|  |      * @return \think\Paginator | ||
|  |      * @throws \think\db\exception\DbException | ||
|  |      */ | ||
|  |     public static function getList( $per = 20, $keyword = '') | ||
|  |     { | ||
|  |         $whereMap = []; | ||
|  |         $pageParam = []; | ||
|  | 
 | ||
|  |         if (!empty($keyword)) { | ||
|  |             $whereMap[] = ['title', 'like', '%' . $keyword . '%']; | ||
|  |             $pageParam['keyword'] = $keyword; | ||
|  |         } | ||
|  | 
 | ||
|  |         $paginate = [ | ||
|  |             'list_rows' => $per, | ||
|  |             'query' => $pageParam | ||
|  |         ]; | ||
|  |         return self::when(count($whereMap) > 0, function ($query) use ($whereMap) { | ||
|  |             $query->where($whereMap); | ||
|  |         }) | ||
|  |             ->order("number asc") | ||
|  |             ->paginate($paginate, false); | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     public static function editRepeat($desk_id,$hall_id,$number) | ||
|  |     { | ||
|  |         $where=[ | ||
|  |             ["id","<>",$desk_id], | ||
|  |             ["hall_id","=",$hall_id], | ||
|  |             ["number","=",$number], | ||
|  |         ]; | ||
|  |         return self::where($where) | ||
|  |             ->findOrEmpty() | ||
|  |             ->toArray(); | ||
|  |     } | ||
|  |     public static function addRepeat($hall_id,$number) | ||
|  |     { | ||
|  |         $where=[ | ||
|  |             ["hall_id","=",$hall_id], | ||
|  |             ["number","=",$number], | ||
|  |         ]; | ||
|  |         return self::where($where) | ||
|  |             ->findOrEmpty() | ||
|  |             ->toArray(); | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  | } |