public function index($offset, $offsettennis, $showtype)
 {
     // 羽毛球的数据处理
     $d = date('Y-m-d', strtotime('+' . $offset . ' day'));
     $today = date('Y-m-d');
     $totalday = BadmintonState::where('date', '>=', $today)->distinct()->count('date');
     for ($i = 0; $i < $totalday; $i++) {
         $days[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
     }
     // 羽毛球的数据处理结束
     // 乒乓球的数据处理
     $pingpangs = Pingpang::where('date', '=', $today)->get();
     // 乒乓球的数据处理结束
     // 网球的数据处理
     $dtennis = date('Y-m-d', strtotime('+' . $offsettennis . ' day'));
     $totaldaytennis = Tennis::where('date', '>=', $today)->distinct()->count('date');
     for ($i = 0; $i < $totaldaytennis; $i++) {
         $daystennis[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
     }
     $tennises = Tennis::where('date', '=', $dtennis)->get();
     // 网球的数据处理结束
     // 篮球订单的数据处理
     $basketballs = Application::where('type', '=', 'basketball')->get();
     //  篮球订单的数据处理结束
     return view('query.queryhome', ['days' => $days, 'daystennis' => $daystennis, 'offset' => $offset, 'offsettennis' => $offsettennis, 'totalday' => $totalday, 'totaldaytennis' => $totaldaytennis, 'pingpangs' => $pingpangs, 'tennises' => $tennises, 'showtype' => $showtype, 'basketballs' => $basketballs])->withBadmintonstates(BadmintonState::where('date', '=', $d)->get());
 }
 public function run()
 {
     DB::table('tennis')->delete();
     for ($offset = 0; $offset < 7; $offset++) {
         for ($i = 1; $i <= 4; $i++) {
             Tennis::create(['name' => '网球' . $i . '号场', 'date' => date('Y-m-d', strtotime('+' . $offset . ' day')), 'six2seven' => 0, 'seven2eight' => 0, 'eight2nine' => 0]);
         }
     }
 }
Example #3
0
 public function Dealwithapp($id)
 {
     $offset = 0;
     $offsettennis = 0;
     $showtype = 5;
     $d = date('Y-m-d', strtotime('+' . $offset . ' day'));
     $today = date('Y-m-d');
     $totalday = BadmintonState::where('date', '>=', $today)->distinct()->count('date');
     for ($i = 0; $i < $totalday; $i++) {
         $days[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
     }
     $pingpangs = Pingpang::where('date', '=', $today)->get();
     $dtennis = date('Y-m-d', strtotime('+' . $offsettennis . ' day'));
     $totaldaytennis = Tennis::where('date', '>=', $today)->distinct()->count('date');
     for ($i = 0; $i < $totaldaytennis; $i++) {
         $daystennis[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
     }
     $tennises = Tennis::where('date', '=', $dtennis)->get();
     $application = Application::find($id);
     if (Input::get('result') == 'yes') {
         $application->enable = 2;
     } else {
         $application->enable = 0;
     }
     if ($application->save()) {
         // 篮球订单的数据处理
         $basketballs = Application::where('type', '=', 'basketball')->get();
         // 篮球订单的数据处理结束
         // 足球订单的数据处理
         $footballs = Application::where('type', '=', 'football')->get();
         // 足球订单的数据处理结束
         return view('query.queryadminhome', ['days' => $days, 'daystennis' => $daystennis, 'offset' => $offset, 'offsettennis' => $offsettennis, 'totalday' => $totalday, 'totaldaytennis' => $totaldaytennis, 'pingpangs' => $pingpangs, 'tennises' => $tennises, 'showtype' => $showtype, 'basketballs' => $basketballs, 'footballs' => $footballs])->withBadmintonstates(BadmintonState::where('date', '=', $d)->get());
     } else {
         return Redirect::back()->withInput()->withErrors('保存失败!');
     }
 }
Example #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $tennis = Tennis::find($id);
     if (Input::get('changetype') == 'lock') {
         if (Input::get('time') == 'six2seven') {
             $tennis->six2seven = 1;
         } else {
             if (Input::get('time') == 'seven2eight') {
                 $tennis->seven2eight = 1;
             } else {
                 $tennis->eight2nine = 1;
             }
         }
     } else {
         if (Input::get('changetype') == 'unlock') {
             if (Input::get('time') == 'six2seven') {
                 $tennis->six2seven = 0;
             } else {
                 if (Input::get('time') == 'seven2eight') {
                     $tennis->seven2eight = 0;
                 } else {
                     $tennis->eight2nine = 0;
                 }
             }
         }
     }
     if ($tennis->save()) {
         $offset = 0;
         $startdate = strtotime(date('Y-m-d'));
         $enddate = strtotime($tennis->date);
         $offsettennis = round(($enddate - $startdate) / 86400);
         $showtype = 3;
         $d = date('Y-m-d', strtotime('+' . $offset . ' day'));
         $today = date('Y-m-d');
         $totalday = BadmintonState::where('date', '>=', $today)->distinct()->count('date');
         for ($i = 0; $i < $totalday; $i++) {
             $days[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
         }
         $pingpangs = Pingpang::where('date', '=', $today)->get();
         $dtennis = date('Y-m-d', strtotime('+' . $offsettennis . ' day'));
         $totaldaytennis = Tennis::where('date', '>=', $today)->distinct()->count('date');
         for ($i = 0; $i < $totaldaytennis; $i++) {
             $daystennis[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
         }
         $tennises = Tennis::where('date', '=', $dtennis)->get();
         // 篮球订单的数据处理
         $basketballs = Application::where('type', '=', 'basketball')->get();
         $basketballs = $basketballs->sortByDesc('id');
         //  篮球订单的数据处理结束
         // 足球订单的数据处理
         $footballs = Application::where('type', '=', 'football')->get();
         $footballs = $footballs->sortByDesc('id');
         // 足球订单的数据处理结束
         // 游泳订单的数据处理
         $swimmings = Application::where('type', '=', 'swimming')->get();
         $swimmings = $swimmings->sortByDesc('id');
         // 游泳订单的数据处理结束
         return view('query.queryadminhome', ['days' => $days, 'daystennis' => $daystennis, 'offset' => $offset, 'offsettennis' => $offsettennis, 'totalday' => $totalday, 'totaldaytennis' => $totaldaytennis, 'pingpangs' => $pingpangs, 'tennises' => $tennises, 'showtype' => $showtype, 'basketballs' => $basketballs, 'footballs' => $footballs, 'swimmings' => $swimmings])->withBadmintonstates(BadmintonState::where('date', '=', $d)->get());
     } else {
         return Redirect::back()->withInput()->withErrors('保存失败!');
     }
 }
 /**
  * 用于完成支付,将账单写入数据库,并且修改场馆状态
  *
  * @return Response
  */
 public function pay($userid, $type, $gymname, $bookingdate, $time, $id)
 {
     $order = new Order();
     $order->userid = $userid;
     $order->type = $type;
     $order->gymname = $gymname;
     $order->paytime = date('Y-m-d H:i:s');
     $order->bookingtime = $bookingdate;
     $order->time = $time;
     //如果账单成功存储,就修改场馆状态
     if ($order->save()) {
         $startdate = strtotime(date('Y-m-d'));
         $enddate = strtotime($bookingdate);
         if ($type == "badminton") {
             $offset = round(($enddate - $startdate) / 86400);
             $offsettennis = 0;
         } else {
             if ($type == "tennis") {
                 $offset = 0;
                 $offsettennis = round(($enddate - $startdate) / 86400);
             } else {
                 $offset = 0;
                 $offsettennis = 0;
             }
         }
         $d = date('Y-m-d', strtotime('+' . $offset . ' day'));
         $today = date('Y-m-d');
         $totalday = BadmintonState::where('date', '>=', $today)->distinct()->count('date');
         for ($i = 0; $i < $totalday; $i++) {
             $days[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
         }
         $dtennis = date('Y-m-d', strtotime('+' . $offsettennis . ' day'));
         $totaldaytennis = Tennis::where('date', '>=', $today)->distinct()->count('date');
         for ($i = 0; $i < $totaldaytennis; $i++) {
             $daystennis[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
         }
         if ($type == "badminton") {
             //这里处理羽毛球
             $badmintonstate = BadmintonState::find($id);
             if ($time == 'morning') {
                 $badmintonstate->morning = 2;
             } else {
                 if ($time == 'afternoon') {
                     $badmintonstate->afternoon = 2;
                 } else {
                     $badmintonstate->evening = 2;
                 }
             }
             if ($badmintonstate->save()) {
                 //成功完成!
                 $pingpangs = Pingpang::where('date', '=', $today)->get();
                 $tennises = Tennis::where('date', '=', $dtennis)->get();
                 return view('query.queryhome', ['days' => $days, 'daystennis' => $daystennis, 'offset' => $offset, 'offsettennis' => $offsettennis, 'totalday' => $totalday, 'totaldaytennis' => $totaldaytennis, 'pingpangs' => $pingpangs, 'tennises' => $tennises, 'showtype' => 1])->withBadmintonstates(BadmintonState::where('date', '=', $d)->get());
             } else {
                 return Redirect::back()->withInput()->withErrors('修改状态失败!');
             }
         } else {
             if ($type == 'pingpang') {
                 //这里处理乒乓球
                 $pingpang = Pingpang::find($id);
                 if ($time == 'six2seven') {
                     $pingpang->six2seven = 2;
                 } else {
                     if ($time == 'seven2eight') {
                         $pingpang->seven2eight = 2;
                     } else {
                         $pingpang->eight2nine = 2;
                     }
                 }
                 if ($pingpang->save()) {
                     //成功完成!
                     $pingpangs = Pingpang::where('date', '=', $today)->get();
                     $tennises = Tennis::where('date', '=', $dtennis)->get();
                     return view('query.queryhome', ['days' => $days, 'daystennis' => $daystennis, 'offset' => $offset, 'offsettennis' => $offsettennis, 'totalday' => $totalday, 'totaldaytennis' => $totaldaytennis, 'pingpangs' => $pingpangs, 'tennises' => $tennises, 'showtype' => 2])->withBadmintonstates(BadmintonState::where('date', '=', $d)->get());
                 } else {
                     return Redirect::back()->withInput()->withErrors('修改状态失败!');
                 }
             } else {
                 if ($type == 'tennis') {
                     $tennis = Tennis::find($id);
                     if ($time == 'six2seven') {
                         $tennis->six2seven = 2;
                     } else {
                         if ($time == 'seven2eight') {
                             $tennis->seven2eight = 2;
                         } else {
                             $tennis->eight2nine = 2;
                         }
                     }
                     if ($tennis->save()) {
                         //成功完成!
                         $pingpangs = Pingpang::where('date', '=', $today)->get();
                         $tennises = Tennis::where('date', '=', $dtennis)->get();
                         return view('query.queryhome', ['days' => $days, 'daystennis' => $daystennis, 'offset' => $offset, 'offsettennis' => $offsettennis, 'totalday' => $totalday, 'totaldaytennis' => $totaldaytennis, 'pingpangs' => $pingpangs, 'tennises' => $tennises, 'showtype' => 3])->withBadmintonstates(BadmintonState::where('date', '=', $d)->get());
                     } else {
                         return Redirect::back()->withInput()->withErrors('修改状态失败!');
                     }
                 } else {
                     //这里处理其他类型的场馆
                 }
             }
         }
     } else {
         return Redirect::back()->withInput()->withErrors('预订失败!');
     }
 }