コード例 #1
0
ファイル: perform.php プロジェクト: h3len/Project
 function show()
 {
     $this->verify_content_prms(array('_action' => 'perform_manage'));
     //操作权限
     $offset = $this->input['offset'] ? $this->input['offset'] : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 20;
     $limit = ' LIMIT ' . $offset . ' , ' . $count;
     $condition = $this->get_condition();
     $sql = "SELECT * FROM " . DB_PREFIX . "performances WHERE 1 " . $condition . $limit;
     $q = $this->db->query($sql);
     $info = array();
     while ($r = $this->db->fetch_array($q)) {
         $perform_id[] = $r['id'];
         $week = hg_mk_weekday($r['show_time']);
         $r['show_time1'] = date('Y年m月d号', $r['show_time']);
         $r['show_time2'] = date('H:i', $r['show_time']);
         $r['show_time'] = $r['show_time1'] . ' ' . $week . ' ' . $r['show_time2'];
         $r['create_time'] = date("Y-m-d H:i", $r['create_time']);
         $info[$r['id']] = $r;
         //$this->addItem($r);
     }
     if (!empty($info)) {
         $perform_ids = implode(',', $perform_id);
         $sql = "SELECT perform_id,goods_total,goods_total_left FROM " . DB_PREFIX . "price WHERE perform_id IN (" . $perform_ids . ")";
         $q = $this->db->query($sql);
         while ($r = $this->db->fetch_array($q)) {
             $goods_info[$r['perform_id']]['goods_total'] += $r['goods_total'];
             $goods_info[$r['perform_id']]['goods_total_left'] += $r['goods_total_left'];
         }
         if ($goods_info) {
             foreach ($goods_info as $k => $v) {
                 if ($info[$k]) {
                     $info[$k]['goods_total'] = $v['goods_total'];
                     $info[$k]['goods_total_left'] = $v['goods_total_left'];
                 }
             }
         }
         foreach ($info as $k => $v) {
             $this->addItem($v);
         }
     }
     $this->output();
 }
コード例 #2
0
ファイル: ticket.php プロジェクト: h3len/Project
 /**
  * 订单获取商品信息(支持多个ids)
  * Enter description here ...
  */
 public function getGoodsInfo()
 {
     $goods = array();
     $goods = $this->input['goods'];
     /*$goods = array(
     			1 => array(
     				'id' => 1,
     				'goods_number' => 1,
     			),
     			2 => array(
     				'id' => 2,
     				'goods_number' => 20,
     			),
     		);*/
     if (!is_array($goods) && !count($goods)) {
         $this->errorOutput('数据异常');
     }
     $price_ids = implode(',', array_keys($goods));
     if (!$price_ids) {
         $this->errorOutput('票价id不存在');
     }
     $sql = "SELECT id,show_id,perform_id FROM " . DB_PREFIX . "price WHERE id IN (" . $price_ids . ")";
     $q = $this->db->query($sql);
     $price_info = array();
     $perform_id = array();
     while ($r = $this->db->fetch_array($q)) {
         $price_info[$r['id']] = $r;
         $show_id[$r['show_id']] = 1;
         $perform_id[$r['perform_id']] = 1;
     }
     if (empty($price_info)) {
         $this->errorOutput('票信息不存在');
     }
     $show_ids = implode(',', array_keys($show_id));
     if (!$show_ids) {
         $this->errorOutput('演出id不存在');
     }
     if ($perform_id) {
         $perform_ids = implode(',', array_keys($perform_id));
         $sql = "SELECT id,show_time FROM " . DB_PREFIX . "performances WHERE id IN (" . $perform_ids . ")";
         $q = $this->db->query($sql);
         $perform_info = array();
         while ($r = $this->db->fetch_array($q)) {
             $perform_info[$r['id']] = $r['show_time'];
         }
     }
     $offset = $this->input['offset'] ? intval($this->input['offset']) : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 100;
     $condition = ' AND s.id IN (' . $show_ids . ')';
     $res = $this->ticket->show($condition, '', $offset, $count);
     $data_tmp = array();
     foreach ($price_info as $k => $v) {
         if (!$res[$v['show_id']]) {
             continue;
         }
         $data_tmp[$k]['goods_title'] = $res[$v['show_id']]['title'];
         $data_tmp[$k]['goods_brief'] = $res[$v['show_id']]['brief'];
         $data_tmp[$k]['goods_id'] = $v['show_id'];
         $data_tmp[$k]['index_img'] = $res[$v['show_id']]['index_url'];
         $data_tmp[$k]['goods_discount'] = 0;
         if (!$perform_info[$v['perform_id']]) {
             $error_flag = 2;
             $error_data['data'][$k]['msg'] = '场次不存在';
         } else {
             $week = hg_mk_weekday($perform_info[$v['perform_id']]);
             $r['show_time1'] = date('m月d号', $perform_info[$v['perform_id']]);
             $r['show_time2'] = date('H:i', $perform_info[$v['perform_id']]);
             $data_tmp[$k]['extension']['session'] = $r['show_time1'] . ' ' . $week . ' ' . $r['show_time2'];
             $res['session'] = $r['show_time1'] . ' ' . $week . ' ' . $r['show_time2'];
             unset($r['show_time1'], $r['show_time2']);
         }
         $data_tmp[$k]['goods_all_info'] = $res;
     }
     if ($error_flag == 2) {
         $error_data['status'] = 2;
         foreach ($error_data as $key => $val) {
             $this->addItem_withkey($key, $val);
         }
         $this->output();
     }
     if (!empty($data_tmp)) {
         foreach ($data_tmp as $key => $val) {
             $this->addItem_withkey($key, $val);
         }
     } else {
         $this->addItem(array());
     }
     $this->output();
 }
コード例 #3
0
ファイル: ticket_new.php プロジェクト: h3len/Project
 public function get_perform()
 {
     $show_id = intval($this->input['show_id']);
     if (!$show_id) {
         $this->errorOutput('演出id不存在');
     }
     $sql = "SELECT id,show_time FROM " . DB_PREFIX . "performances WHERE show_id = " . $show_id . " ORDER BY show_time ASC";
     $q = $this->db->query($sql);
     $first_perform_id = '';
     while ($r = $this->db->fetch_array($q)) {
         if (time() > $r['show_time']) {
             continue;
         }
         if (!$first_perform_id) {
             $first_perform_id = $r['id'];
         }
         if ($r['show_time']) {
             $r['showtime'] = $r['show_time'];
             $week = hg_mk_weekday($r['show_time']);
             $r['show_time1'] = date('m月d号', $r['show_time']);
             $r['show_time2'] = date('H:i', $r['show_time']);
             $r['show_time'] = $r['show_time1'] . ' ' . $week . ' ' . $r['show_time2'];
         }
         unset($r['show_time1'], $r['show_time2']);
         $data['perform'][] = $r;
     }
     //查询票票数
     if ($first_perform_id) {
         $data['ticket_info'] = $this->get_ticket_info($first_perform_id);
     }
     if (!$data) {
         $data = array();
     }
     foreach ($data as $key => $val) {
         $this->addItem_withkey($key, $val);
     }
     //hg_pre($data,0);
     $this->output();
 }