function Index()
 {
     if (empty(session('used_shop')) && empty(cookie("used_shop"))) {
         $this->error("商家未登录,请重试!");
         exit;
     }
     if (!empty(session('used_shop'))) {
         $used_shop = session('used_shop');
     }
     if (!empty(cookie('used_shop'))) {
         $used_shop = cookie('used_shop');
     }
     if (empty($used_shop)) {
         $this->error("商家未登录");
         die;
     }
     $total = M('coupons')->where(array('is_used' => 1, 'used_shop' => $used_shop))->order("used_at", "desc")->count();
     $page = \LfPageData::Page($total, U('Coupon/Index'));
     $coupons = M('coupons')->where(array('is_used' => 1, 'used_shop' => $used_shop))->limit($page['offset'], $page['perpagenum'])->order("used_at", "desc")->select();
     foreach ($coupons as $i => $v) {
         $coupons[$i]['salon'] = M('e_salon')->where(array('id' => $v['salon_id']))->getField('title');
         $coupons[$i]['user'] = M('e_user')->where(array('id' => $v['user_id']))->getField('student_name');
     }
     $this->assign("coupons", $coupons);
     $this->assign("page", $page);
     $this->display();
 }
 function Square()
 {
     e_auth();
     $sign_maps = 'end_date > ' . strtotime(date("Y-m-d"));
     $end_maps = 'end_date < ' . strtotime(date("Y-m-d"));
     $and = ' AND ';
     $maps = '';
     $data['type'] = \LfRequest::inStr('type');
     $data['date'] = \LfRequest::inStr('date');
     $data['number'] = \LfRequest::inStr('number');
     $maps = '';
     if (!empty($data['type'])) {
         $maps .= 'type = ' . "'" . $data['type'] . "'" . $and;
     }
     if (!empty($data['date'])) {
         switch ($data['date']) {
             //今天
             case 1:
                 $maps .= 'start_date = ' . strtotime(date("Y-m-d")) . $and;
                 break;
                 //明天
             //明天
             case 2:
                 $maps .= 'start_date = ' . strtotime(date("Y-m-d", time() + 1 * 24 * 3600)) . $and;
                 break;
                 //三天后
             //三天后
             case 3:
                 $maps .= 'start_date >= ' . strtotime(date("Y-m-d", time() + 3 * 24 * 3600)) . $and;
                 break;
                 //昨天
             //昨天
             case -1:
                 $maps .= 'start_date = ' . strtotime(date("Y-m-d", time() - 1 * 24 * 3600)) . $and;
                 break;
                 //过去三天
             //过去三天
             case -3:
                 $maps .= "start_date >= " . strtotime(date("Y-m-d", time() - 3 * 24 * 3600)) . $and . "start_date <=" . strtotime(date("Y-m-d")) . $and;
                 break;
                 //过去七天
             //过去七天
             case -7:
                 $maps .= "start_date >= " . strtotime(date("Y-m-d", time() - 7 * 24 * 3600)) . $and . "start_date <=" . strtotime(date("Y-m-d")) . $and;
                 break;
         }
     }
     if (!empty($data['number'])) {
         $maps .= 'participate_number = ' . $data['number'] . $and;
     }
     $sign_maps = $maps . $sign_maps;
     $end_maps = $maps . $end_maps;
     $SignIteamsCount = M('e_iteam')->where($sign_maps)->count();
     $EndIteamCount = M('e_iteam')->where($end_maps)->count();
     $param = array('type' => I('type', ''), 'date' => I('date', ''), 'number' => I('number', ''));
     $SignPage = \LfPageData::Page($SignIteamsCount, addons_url('Academic://Academic/Square/status/sign', $param));
     $EndPage = \LfPageData::Page($EndIteamCount, addons_url('Academic://Academic/Square/status/end', $param));
     $sign_iteams = M('e_iteam')->where($sign_maps)->limit($SignPage['offset'], $SignPage['perpagenum'])->order('id DESC')->select();
     $end_iteams = M('e_iteam')->where($end_maps)->limit($EndPage['offset'], $EndPage['perpagenum'])->order('id DESC')->select();
     $status = I('status', 'sign');
     $IteamType = M('e_iteam_type');
     $types = $IteamType->select();
     $this->assign('types', $types);
     $this->assign('status', $status);
     $this->type = I('type', '');
     $this->date = I('date', '');
     $this->number = I('number', '');
     $this->assign('sign_iteams', $sign_iteams);
     $this->assign('end_iteams', $end_iteams);
     $this->assign('url', 'Academic://Academic/IteamDetail');
     $this->assign('SignPage', $SignPage);
     $this->assign('EndPage', $EndPage);
     $this->title = "Iteam广场";
     $this->display();
 }
示例#3
0
 function GetSalonWith()
 {
     $status = \LfRequest::inStr('status');
     $type = \LfRequest::inStr('type');
     $day = \LfRequest::inStr('day');
     $space = \LfRequest::inStr('space');
     $param = array('type' => I('type', ''), 'day' => I('day', ''), 'space' => I('space', ''));
     $data = '';
     if (empty($type) && empty($day) && empty($space)) {
         redirect(addons_url('Salon://Salon/SalonSquare', array('status' => $status)));
     }
     if ($type != null) {
         if (!empty($space) || !empty($day)) {
             $data .= 'type = ' . "'" . $type . "'" . ' AND ';
         } else {
             $data .= 'type = ' . "'" . $type . "'";
         }
     }
     if ($space != null) {
         if (!empty($day)) {
             $data .= 'space = ' . "'" . $space . "'" . ' AND ';
         } else {
             $data .= 'space = ' . "'" . $space . "'";
         }
     }
     $today = date('Y-m-d', time());
     if ($day == 1) {
         $data .= 'start_date >= ' . strtotime($today) . ' AND start_date <= ' . (strtotime($today) + 24 * 3600);
     }
     if (!empty($day) && $day != 1) {
         if ($day >= 0) {
             $data .= 'start_date >= ' . strtotime($today) . ' AND start_date <= ' . (strtotime($today) + 24 * 3600 * $day) . ' AND end_date >= ' . time();
         } else {
             $data .= 'start_date >= ' . (strtotime($today) + 24 * 3600 * $day) . ' AND start_date <= ' . strtotime($today) . ' AND end_date <' . time();
         }
     }
     $map2 = $data . ' AND end_date < ' . time();
     $end_salons = M('e_salon')->where($map2)->select();
     $EndPage = \LfPageData::Page($end_salons, addons_url('Salon://Salon/GetSalonWith/status/end', $param));
     $this->end_salons = M('e_salon')->where($map2)->order('id desc')->limit($EndPage['offset'], $EndPage['perpagenum'])->select();
     $map1 = $data . ' AND end_date >= ' . time();
     $salons = M('e_salon')->where($map1)->select();
     $SignPage = \LfPageData::Page($salons, addons_url('Salon://Salon/GetSalonWith/status/sign', $param));
     $this->salons = M('e_salon')->where($map1)->order('id desc')->limit($SignPage['offset'], $SignPage['perpagenum'])->select();
     $this->assign('status', $status);
     $this->assign('EndPage', $EndPage);
     $this->assign('SignPage', $SignPage);
     $this->assign('url', 'Salon://Salon/CheckSalon');
     $this->assign('type', I('type', ''));
     $this->assign('day', I('day', ''));
     $this->assign('space', I('space', ''));
     $this->assign('title', '查询结果');
     $this->display('Salon/SalonSquare');
 }