Exemplo n.º 1
0
 public function doMobileorderlist()
 {
     global $_GPC, $_W;
     $weid = $this->_weid;
     $this->check_login();
     $memberid = $this->_user_info['id'];
     if (empty($memberid)) {
         $url = $this->createMobileUrl('index');
         header("Location: {$url}");
     }
     $ac = $_GPC['ac'];
     if ($ac == "getDate") {
         $pindex = max(1, intval($_GPC['page']));
         $psize = 10;
         $sql = "SELECT o.*, h.title ";
         $where = " FROM " . tablename('hotel2_order') . " AS o";
         $where .= " LEFT JOIN " . tablename('hotel2') . " AS h ON o.hotelid = h.id";
         $where .= " WHERE 1 = 1";
         $where .= " AND o.memberid = {$memberid}";
         $where .= " AND o.weid = {$weid}";
         $count_sql = "SELECT COUNT(o.id) " . $where;
         $sql .= $where;
         $sql .= " ORDER BY o.id DESC";
         if ($pindex > 0) {
             // 需要分页
             $start = ($pindex - 1) * $psize;
             $sql .= " LIMIT {$start},{$psize}";
         }
         $list = pdo_fetchall($sql);
         $total = pdo_fetchcolumn($count_sql);
         $page_array = get_page_array($total, $pindex, $psize);
         $data = array();
         $data['result'] = 1;
         ob_start();
         include $this->template('order_crumb');
         $data['code'] = ob_get_contents();
         ob_clean();
         $data['total'] = $total;
         $data['isshow'] = $page_array['isshow'];
         if ($page_array['isshow'] == 1) {
             $data['nindex'] = $page_array['nindex'];
         }
         die(json_encode($data));
     } else {
         include $this->template('orderlist');
     }
 }
Exemplo n.º 2
0
 public function doMobileorderlist()
 {
     global $_GPC, $_W;
     $weid = $_W['uniacid'];
     $openid = $_W['fans']['from_user'];
     checkauth();
     //订单提交用户登录验证
     $ac = $_GPC['ac'];
     // var_dump($openid);
     //die();
     if ($ac == "getDate") {
         $pindex = max(1, intval($_GPC['page']));
         $psize = 5;
         $sql = 'SELECT * FROM ' . tablename('fb_order') . ' WHERE `weid`=:weid AND `openid`=:openid';
         //查询订单
         $params = array(':weid' => $weid, ':openid' => $openid);
         $where = " FROM " . tablename('fb_order') . "WHERE `weid`=:weid  AND `openid`=:openid ";
         $count_sql = "SELECT COUNT(" . tablename('fb_order') . ".id)" . $where;
         //查询订单第一列
         if ($pindex > 0) {
             // 需要分页
             $start = ($pindex - 1) * $psize;
             $sql .= " LIMIT {$start},{$psize}";
         }
         $list = pdo_fetchall($sql, $params);
         //var_dump($list);die();
         $total = pdo_fetchcolumn($count_sql, $params);
         $page_array = get_page_array($total, $pindex, $psize);
         $data = array();
         $data['result'] = 1;
         ob_start();
         include $this->template('order_crumb');
         $data['code'] = ob_get_contents();
         ob_clean();
         $data['total'] = $total;
         $data['isshow'] = $page_array['isshow'];
         if ($page_array['isshow'] == 1) {
             $data['nindex'] = $page_array['nindex'];
         }
         die(json_encode($data));
     } else {
         include $this->template('orderlist');
     }
 }
Exemplo n.º 3
0
 /**
  * 考试进行中
  */
 public function doMobileStart()
 {
     global $_GPC, $_W;
     $this->check_member();
     $weid = $_W['uniacid'];
     $pindex = max(1, intval($_GPC['page']));
     $psize = 1;
     $paperid = intval($_GPC['paperid']);
     $recordid = intval($_GPC['recordid']);
     $types_config = $this->_types_config;
     $answer_array = $this->_answer_array;
     if (empty($paperid) || empty($recordid)) {
         echo "传递参数错误";
         exit;
     }
     $record_info = $this->getRecordInfo($recordid);
     //该试卷已经完成,不能再继续了
     if ($record_info['did'] == 1) {
         echo "该试卷已经完成,不能再继续了";
         exit;
     }
     $member_info = $this->getMemberInfo();
     //提交答案
     if (checksubmit('submit')) {
         $data = array();
         $data['result'] = 1;
         $count_flag = intval($_GPC['count_flag']);
         $questionid = intval($_GPC['questionid']);
         $now_page = intval($_GPC['now_page']);
         $btime = intval($_GPC['btime']);
         $type = intval($_GPC['type']);
         $items = "";
         $answer = "";
         $now_time = time();
         //试题类型
         switch ($type) {
             case 1:
                 //判断题
                 $answer = $_GPC['answer1'];
                 break;
             case 2:
                 //单选题
                 $answer = $_GPC['answer2'];
                 break;
             case 3:
                 //多选题
                 $arr = $_GPC['answer3'];
                 if (empty($arr)) {
                     $answer = '';
                 } else {
                     $answer = implode("", $arr);
                 }
                 break;
         }
         //判断答案是否正确
         $now_question_info = get_one_question($questionid);
         if (empty($answer)) {
             $isright = 0;
         } else {
             if ($now_question_info['answer'] == $answer) {
                 $isright = 1;
             } else {
                 $isright = 0;
             }
         }
         //判断用户是否回答过
         $params = array();
         $params[':weid'] = $weid;
         $params[':paperid'] = $paperid;
         $params[':memberid'] = $member_info['id'];
         $params[':recordid'] = $recordid;
         $params[':questionid'] = $questionid;
         $item = get_one_member_question($params);
         //要添加或者更新的数据
         $array = array();
         $array['isright'] = $isright;
         $array['answer'] = $answer;
         $array['type'] = $type;
         $array['pageid'] = $now_page;
         if ($item) {
             //已经回答过
             pdo_update('ewei_exam_paper_member_data', $array, array('id' => $item['id']));
             if ($isright == 1 && $item['isright'] == 0) {
                 //多少人正确+1
                 $this->updateQuestionMemberNum($questionid, 2);
             }
         } else {
             //还没有回答过
             $array['weid'] = $weid;
             $array['paperid'] = $paperid;
             $array['memberid'] = $member_info['id'];
             $array['recordid'] = $recordid;
             $array['questionid'] = $questionid;
             $array['createtime'] = $now_time;
             pdo_insert('ewei_exam_paper_member_data', $array);
             if ($isright) {
                 //多少人做过,正确+1
                 $this->updateQuestionMemberNum($questionid, 3);
             } else {
                 //多少人做过+1
                 $this->updateQuestionMemberNum($questionid, 1);
             }
         }
         //统计该用户当前试卷的做题情况
         if ($count_flag) {
             $paper_info = $this->getPaperInfo($paperid);
             $total = $paper_info['total'];
             $now_total = get_count_one_paper_record($params);
             if ($now_total == $total) {
                 $msg = "共" . $total . "题,您已全部做完";
             } else {
                 $msg = "共" . $total . "题,您做了" . $now_total . "题,还剩" . ($total - $now_total) . "题未做";
             }
             $data['count_msg'] = $msg;
         }
         die(json_encode($data));
     } else {
         $question_item = get_paper_question_list($paperid);
         $total = count($question_item);
         $ac = $_GPC['ac'];
         //获取题目信息
         if ($ac == "getDate") {
             $data = array();
             $data['result'] = 1;
             if ($pindex > $total) {
                 $data['result'] = 0;
                 $data['error'] = "抱歉,题数参数错误";
                 echo 12345;
                 exit;
                 die(json_encode($data));
             }
             $question_info = $question_item[$pindex - 1];
             if (!$question_info) {
                 $data['result'] = 0;
                 $data['error'] = "抱歉,试题错误";
                 die(json_encode($data));
             }
             //判断用户是否回答过
             $params = array();
             $params[':weid'] = $weid;
             $params[':paperid'] = $paperid;
             $params[':memberid'] = $member_info['id'];
             $params[':recordid'] = $recordid;
             $params[':questionid'] = $question_info['id'];
             $item = get_one_member_question($params);
             if ($item) {
                 //已经回答过
                 $is_has = 1;
             } else {
                 //还没有回答过
                 $is_has = 0;
             }
             $page_array = get_page_array($total, $pindex, $psize);
             ob_start();
             include $this->template('question_form');
             $data['code'] = ob_get_contents();
             ob_clean();
             $data['total'] = $total;
             $data['isshow'] = $page_array['isshow'];
             if ($page_array['isshow'] == 1) {
                 $data['nindex'] = $page_array['nindex'];
             }
             die(json_encode($data));
         } else {
             if ($ac == "close_exam") {
                 $paper_info = $this->getPaperInfo($paperid);
                 $now_question = $this->getRecordQuestion($paper_info, $recordid);
                 //结束本次考试记录
                 $data = array();
                 $data['score'] = $now_question['score'];
                 $data['did'] = 1;
                 pdo_update('ewei_exam_paper_member_record', $data, array('id' => $recordid));
                 //计算平均分和用时
                 $sql = "SELECT AVG(score) as avg_score, AVG(times) as avg_times FROM " . tablename('ewei_exam_paper_member_record');
                 $sql .= " WHERE paperid = :paperid AND weid = :weid AND did = 1";
                 $question_item = pdo_fetch($sql, array(':paperid' => $paperid, ':weid' => $weid));
                 $avg_score = round($question_item['avg_score'], 2);
                 $avg_times = $question_item['avg_times'];
                 //更新到试卷信息表中
                 $data = array();
                 $data['avscore'] = $avg_score;
                 $data['avtimes'] = $avg_times;
                 pdo_update('ewei_exam_paper', $data, array('id' => $paperid));
                 $url = $this->createMobileUrl('score', array('paperid' => $paperid, 'recordid' => $recordid));
                 die(json_encode(array("result" => 1, "url" => $url)));
             } else {
                 if ($ac == "update_countdown") {
                     $paper_info = $this->getPaperInfo($paperid);
                     if ($record_info['countdown'] > 0) {
                         $countdown = intval($_GPC['total_time']);
                         //更新考试剩余时间
                         $data = array();
                         $data['countdown'] = $countdown;
                         $data['times'] = $paper_info['times'] * 60 - $countdown;
                         pdo_update('ewei_exam_paper_member_record', $data, array('id' => $recordid));
                     } else {
                         $data['times'] = $paper_info['times'] * 60;
                         pdo_update('ewei_exam_paper_member_record', $data, array('id' => $recordid));
                     }
                 } else {
                     $paper_info = $this->getPaperInfo($paperid);
                     include $this->template('question');
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public function doReserve()
 {
     global $_GPC, $_W;
     $weid = $_W['weid'];
     $op = $_GPC['op'];
     if ($op == 'edit') {
         $id = intval($_GPC['id']);
         if (!empty($id)) {
             $params = array();
             $params[':weid'] = $weid;
             $params[':id'] = $id;
             $sql = "SELECT p.courseid, p.msg, p.username, p.mobile, p.email, p.status as reserve_stauts, p.createtime as reserve_createtime, c.*";
             $sql .= " FROM " . tablename('ewei_exam_course_reserve') . " AS p";
             $sql .= " LEFT JOIN " . tablename('ewei_exam_course') . " AS c ON p.courseid = c.id";
             $sql .= " WHERE 1 = 1";
             $sql .= " AND p.weid = :weid";
             $sql .= " AND p.id = :id";
             $item = pdo_fetch($sql, $params);
             if (empty($item)) {
                 message('抱歉,订单不存在或是已经删除!', '', 'error');
             }
         } else {
             message('抱歉,参数错误!', '', 'error');
         }
         if (checksubmit('submit')) {
             $old_status = $_GPC['oldstatus'];
             $data = array('status' => $_GPC['status'], 'msg' => $_GPC['msg'], 'mngtime' => time());
             //订单确认
             if ($data['status'] == 1 && $old_status != 1) {
                 pdo_query("update " . tablename('ewei_exam_course') . " set fansnum = fansnum + 1 where id=:id", array(":id" => $item['courseid']));
             }
             //订单取消
             if ($old_status == 1 && $data['status'] != 1) {
                 if ($item['fansnum'] > 0) {
                     pdo_query("update " . tablename('ewei_exam_course') . " set fansnum = fansnum - 1 where id=:id", array(":id" => $item['courseid']));
                 }
             }
             pdo_update('ewei_exam_course_reserve', $data, array('id' => $id));
             message('订单信息处理完成!', $this->createWebUrl('reserve'), 'success');
         }
         include $this->template('reserve_form');
     } else {
         if ($op == 'delete') {
             $id = intval($_GPC['id']);
             $item = pdo_fetch("SELECT id FROM " . tablename('ewei_exam_course_reserve') . " WHERE id = :id LIMIT 1", array(':id' => $id));
             if (empty($item)) {
                 message('抱歉,订单不存在或是已经删除!', '', 'error');
             }
             pdo_delete('ewei_exam_course_reserve', array('id' => $id));
             message('删除成功!', referer(), 'success');
         } else {
             if ($op == 'deleteall') {
                 foreach ($_GPC['idArr'] as $k => $id) {
                     $id = intval($id);
                     pdo_delete('ewei_exam_course_reserve', array('id' => $id));
                 }
                 //$this->message('订单删除成功!', '', 0);
                 exit;
             } else {
                 $pindex = max(1, intval($_GPC['page']));
                 $psize = 10;
                 $title = $_GPC['title'];
                 $username = $_GPC['username'];
                 $mobile = $_GPC['mobile'];
                 $ordersn = $_GPC['ordersn'];
                 $status = $_GPC['status'];
                 $ctype = $_GPC['ctype'];
                 $params = array();
                 $params[':weid'] = $weid;
                 $sql = "SELECT p.*, c.title, c.coursetime, c.ctype";
                 $count_sql = "SELECT COUNT(p.id)";
                 $where = '';
                 $where .= " FROM " . tablename('ewei_exam_course_reserve') . " AS p";
                 $where .= " LEFT JOIN " . tablename('ewei_exam_course') . " AS c ON p.courseid = c.id";
                 $where .= " WHERE 1 = 1";
                 $where .= " AND p.weid = :weid";
                 if (!empty($title)) {
                     $where .= ' AND c.title LIKE :title';
                     $params[':title'] = "%{$title}%";
                 }
                 if (!empty($username)) {
                     $where .= ' AND p.username LIKE :username';
                     $params[':username'] = "******";
                 }
                 if (!empty($mobile)) {
                     $where .= ' AND p.mobile LIKE :mobile';
                     $params[':mobile'] = "%{$mobile}%";
                 }
                 if (!empty($ordersn)) {
                     $where .= ' AND p.ordersn LIKE :ordersn';
                     $params[':ordersn'] = "%{$ordersn}%";
                 }
                 if ($status != '') {
                     $where .= " and p.status=" . intval($status);
                 }
                 if ($ctype != '') {
                     $where .= " and c.ctype=" . intval($ctype);
                 }
                 $sql .= $where;
                 $sql .= " ORDER BY id DESC";
                 if ($pindex > 0) {
                     // 需要分页
                     $start = ($pindex - 1) * $psize;
                     $sql .= " LIMIT {$start},{$psize}";
                 }
                 $count_sql .= $where;
                 $list = pdo_fetchall($sql, $params);
                 $total = pdo_fetchcolumn($count_sql, $params);
                 $page_array = get_page_array($total, $pindex, $psize);
                 //print_r($ctype);exit;
                 //
                 //
                 //            $roomtitle = $_GPC['roomtitle'];
                 //            $hoteltitle = $_GPC['hoteltitle'];
                 //            $condition = '';
                 //            $params = array();
                 //            if (!empty($hoteltitle)) {
                 //                $condition .= ' AND h.title LIKE :hoteltitle';
                 //                $params[':hoteltitle'] = "%{$hoteltitle}%";
                 //            }
                 //            if (!empty($roomtitle)) {
                 //                $condition .= ' AND r.title LIKE :roomtitle';
                 //                $params[':roomtitle'] = "%{$roomtitle}%";
                 //            }
                 //
                 //            if (!empty($realname)) {
                 //                $condition .= ' AND o.name LIKE :realname';
                 //                $params[':realname'] = "%{$realname}%";
                 //            }
                 //            if (!empty($mobile)) {
                 //                $condition .= ' AND o.mobile LIKE :mobile';
                 //                $params[':mobile'] = "%{$mobile}%";
                 //            }
                 //            if(!empty($hotelid)){
                 //                $condition.=" and o.hotelid=".$hotelid;
                 //            }
                 //            if(!empty($roomid)){
                 //                $condition.=" and o.roomid=".$roomid;
                 //            }
                 //
                 //            $pindex = max(1, intval($_GPC['page']));
                 //            $psize = 20;
                 //            $list = pdo_fetchall("SELECT o.*,h.title as hoteltitle,r.title as roomtitle FROM " . tablename('hotel2_order') . " o left join " . tablename('hotel2') .
                 //                "h on o.hotelid=h.id left join ".tablename("hotel2_room")." r on r.id = o.roomid  WHERE o.weid = '{$_W['weid']}' $condition ORDER BY o.id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize,$params);
                 //            $total = pdo_fetchcolumn('SELECT COUNT(*) FROM  ' . tablename('hotel2_order') . " o left join " . tablename('hotel2') .
                 //                "h on o.hotelid=h.id left join ".tablename("hotel2_room")." r on r.id = o.roomid  WHERE o.weid = '{$_W['weid']}' $condition",$params);
                 //$pager = pagination($total, $pindex, $psize);
                 include $this->template('order');
             }
         }
     }
 }