コード例 #1
0
ファイル: Equip.php プロジェクト: null-1/fangtaitong
 /**
  * verify
  * 
  * @param array $record
  * @return bool
  */
 public function verify($record)
 {
     if (empty($record) || !is_array($record)) {
         return false;
     }
     if (isset($record['re_hid'])) {
         if (!Zyon_Util::isUnsignedInt($record['re_hid']) || empty($record['re_hid']) || strlen($record['re_hid']) > 10) {
             return false;
         }
     }
     if (isset($record['re_rid'])) {
         if (!Zyon_Util::isUnsignedInt($record['re_rid']) || empty($record['re_rid']) || strlen($record['re_rid']) > 10) {
             return false;
         }
     }
     if (isset($record['re_type'])) {
         if (!Zyon_Util::isInt($record['re_type']) || !in_array($record['re_type'], static::$_types, true) || strlen($record['re_type']) > 3) {
             return false;
         }
     }
     if (isset($record['re_qnty'])) {
         if (!Zyon_Util::isUnsignedInt($record['re_qnty']) || strlen($record['re_qnty']) > 5) {
             return false;
         }
     }
     if (isset($record['re_name'])) {
         if (!is_string($record['re_name']) || trim($record['re_name']) == '' || mb_strlen($record['re_name']) > 30) {
             return false;
         }
     }
     return true;
 }
コード例 #2
0
ファイル: Typedef.php プロジェクト: null-1/fangtaitong
 /**
  * verify
  * 
  * @param mixed $record
  * @return bool
  */
 public function verify($record)
 {
     if (empty($record) || !is_array($record)) {
         return false;
     }
     if (isset($record['ht_hid'])) {
         if (empty($record['ht_hid']) || !Zyon_Util::isUnsignedInt($record['ht_hid']) || strlen($record['ht_hid']) > 10) {
             return false;
         }
     }
     if (isset($record['ht_status'])) {
         if (!Zyon_Util::isUnsignedInt($record['ht_status']) || strlen($record['ht_status']) > 3) {
             return false;
         }
     }
     if (isset($record['ht_name'])) {
         if (!is_string($record['ht_name']) || trim($record['ht_name']) == '' || mb_strlen($record['ht_name']) > 30) {
             return false;
         }
     }
     if (isset($record['ht_memo'])) {
         if (!is_string($record['ht_memo']) || mb_strlen($record['ht_memo']) > 200) {
             return false;
         }
     }
     return true;
 }
コード例 #3
0
 /**
  * __construct
  * 
  * @param int $idx
  * @param int $all
  * @return mixed
  */
 public function __construct($idx, $all)
 {
     $this->_idx = $idx;
     $this->_all = $all;
     if (!Zyon_Util::isUnsignedInt($idx) || !Zyon_Util::isUnsignedInt($all)) {
         exit($this->flash(1, "Falied to init SendRoomStatMail: Invalid Arguments[{$idx}, {$all}]"));
     }
 }
コード例 #4
0
ファイル: Log.php プロジェクト: null-1/fangtaitong
 /**
  * getClientIp
  * 
  * @return string
  */
 public function getClientIp()
 {
     $ip = null;
     if (isset($_SERVER['HTTP_CLIENT_IP'])) {
         $ip = $_SERVER['HTTP_CLIENT_IP'];
     } else {
         if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
         } else {
             if (isset($_SERVER['REMOTE_ADDR'])) {
                 $ip = $_SERVER['REMOTE_ADDR'];
             }
         }
     }
     if (!Zyon_Util::isIP($ip)) {
         $ip = '';
     }
     return $ip;
 }
コード例 #5
0
 public function doUpdateRuleAction()
 {
     $h_order_default_stacode = $this->input('order_default_stacode', 'numeric');
     $h_order_enddays = $this->input('order_enddays', 'numeric');
     $h_order_minlens = $this->input('order_minlens', 'numeric');
     $h_order_maxlens = $this->input('order_maxlens', 'numeric');
     $h_prompt_checkin = $this->input('prompt_checkin', 'numeric');
     $h_prompt_checkout = $this->input('prompt_checkout', 'numeric');
     $checkin_time_hour = $this->input('checkin_time_hour', 'numeric');
     $checkin_time_min = $this->input('checkin_time_min', 'numeric');
     $checkout_time_hour = $this->input('checkout_time_hour', 'numeric');
     $checkout_time_min = $this->input('checkout_time_min', 'numeric');
     $keptime_hour = $this->input('keptime_hour', 'numeric');
     foreach (get_defined_vars() as $key => $val) {
         if ($key !== 'this' && !isset($val[0])) {
             $this->flash(0, '必须的项没有填写完整');
         }
     }
     if ($h_order_default_stacode !== ORDER_STATUS_YD && $h_order_default_stacode !== ORDER_STATUS_BL) {
         $this->flash(0, '不被允许的新订单默认状态');
     }
     isset($checkin_time_hour[1]) or $checkin_time_hour = '0' . $checkin_time_hour;
     isset($checkin_time_min[1]) or $checkin_time_min = '0' . $checkin_time_min;
     isset($checkout_time_hour[1]) or $checkout_time_hour = '0' . $checkout_time_hour;
     isset($checkout_time_min[1]) or $checkout_time_min = '0' . $checkout_time_min;
     if (!Zyon_Util::isTime($checkin_time_hour . ':' . $checkin_time_min)) {
         $this->flash(0, '入住时间格式错误');
     }
     if (!Zyon_Util::isTime($checkout_time_hour . ':' . $checkout_time_min)) {
         $this->flash(0, '离店时间格式错误');
     }
     $h_checkin_time = $checkin_time_hour * 3600 + $checkin_time_min * 60;
     $h_checkout_time = $checkout_time_hour * 3600 + $checkout_time_min * 60;
     if ($h_checkin_time < $h_checkout_time) {
         $this->flash(0, '入住时间必须大于离店时间');
     }
     if ($keptime_hour < 0 || $keptime_hour > 72 || !Zyon_Util::isUnsignedInt($keptime_hour)) {
         $this->flash(0, '账单预订保留过期时间错误');
     }
     $h_obill_keptime = $keptime_hour * 3600;
     $map = array('h_attr' => $this->model('hotel')->expr($this->input('keptime', 'numeric') ? 'h_attr | ' . HOTEL_ATTR_ZDGQ : 'h_attr & ' . ~(int) HOTEL_ATTR_ZDGQ), 'h_rosta_visible' => $this->model('hotel')->expr($this->input('rosta_visible', 'numeric') ? 'h_rosta_visible | ' . SYSTEM_GROUPS_GSER : 'h_rosta_visible & ' . ~(int) SYSTEM_GROUPS_GSER), 'h_order_enabled' => $this->model('hotel')->expr($this->input('order_enabled', 'numeric') ? 'h_order_enabled | ' . SYSTEM_GROUPS_GSER : 'h_order_enabled & ' . ~(int) SYSTEM_GROUPS_GSER), 'h_order_default_stacode' => $h_order_default_stacode, 'h_obill_keptime' => $h_obill_keptime, 'h_order_enddays' => $h_order_enddays, 'h_order_minlens' => $h_order_minlens, 'h_order_maxlens' => $h_order_maxlens, 'h_prompt_checkin' => $h_prompt_checkin, 'h_prompt_checkout' => $h_prompt_checkout, 'h_checkin_time' => $h_checkin_time, 'h_checkout_time' => $h_checkout_time);
     $this->flash((bool) $this->model('hotel')->modHotel($this->_hostel['h_id'], $map));
 }
コード例 #6
0
ファイル: Expense.php プロジェクト: null-1/fangtaitong
 /**
  * verify
  * 
  * @param array $record
  * @return bool
  */
 public function verify($record)
 {
     if (empty($record) || !is_array($record)) {
         return false;
     }
     if (isset($record['be_hid'])) {
         if (!Zyon_Util::isUnsignedInt($record['be_hid']) || empty($record['be_hid']) || strlen($record['be_hid']) > 10) {
             return false;
         }
     }
     if (isset($record['be_bid'])) {
         if (!Zyon_Util::isUnsignedInt($record['be_bid']) || empty($record['be_bid']) || strlen($record['be_bid']) > 10) {
             return false;
         }
     }
     if (isset($record['be_uid'])) {
         if (!Zyon_Util::isUnsignedInt($record['be_uid']) || empty($record['be_uid']) || strlen($record['be_uid']) > 10) {
             return false;
         }
     }
     if (isset($record['be_sum'])) {
         if (!Zyon_Util::isInt($record['be_sum']) || strlen($record['be_sum']) > 10) {
             return false;
         }
     }
     if (isset($record['be_time'])) {
         if (!Zyon_Util::isUnsignedInt($record['be_time']) || strlen($record['be_time']) > 11) {
             return false;
         }
     }
     if (isset($record['be_user'])) {
         if (!is_string($record['be_user']) || mb_strlen($record['be_user']) > 20) {
             return false;
         }
     }
     if (isset($record['be_memo'])) {
         if (!is_string($record['be_memo']) || mb_strlen($record['be_memo']) > 200) {
             return false;
         }
     }
     return true;
 }
コード例 #7
0
ファイル: Price.php プロジェクト: null-1/fangtaitong
 /**
  * verify
  * 
  * @param array $record
  * @return bool
  */
 public function verify($record)
 {
     if (empty($record) || !is_array($record)) {
         return false;
     }
     if (isset($record['rp_hid'])) {
         if (!Zyon_Util::isUnsignedInt($record['rp_hid']) || empty($record['rp_hid']) || strlen($record['rp_hid']) > 10) {
             return false;
         }
     }
     if (isset($record['rp_rid'])) {
         if (!Zyon_Util::isUnsignedInt($record['rp_rid']) || empty($record['rp_rid']) || strlen($record['rp_rid']) > 10) {
             return false;
         }
     }
     if (isset($record['rp_uid'])) {
         if (!Zyon_Util::isUnsignedInt($record['rp_uid']) || empty($record['rp_uid']) || strlen($record['rp_uid']) > 10) {
             return false;
         }
     }
     if (isset($record['rp_value'])) {
         if (!Zyon_Util::isUnsignedInt($record['rp_value']) || strlen($record['rp_value']) > 7) {
             return false;
         }
     }
     if (isset($record['rp_btime'])) {
         if (!Zyon_Util::isUnsignedInt($record['rp_btime']) || strlen($record['rp_btime']) > 10) {
             return false;
         }
     }
     if (isset($record['rp_etime'])) {
         if (!Zyon_Util::isUnsignedInt($record['rp_etime']) || strlen($record['rp_etime']) > 10 || isset($record['rp_btime']) && $record['rp_btime'] > $record['rp_etime']) {
             return false;
         }
     }
     if (isset($record['rp_uname'])) {
         if (!is_string($record['rp_uname']) || mb_strlen($record['rp_uname']) > 20) {
             return false;
         }
     }
     return true;
 }
コード例 #8
0
 /**
  * 时间轴
  */
 public function indexAction()
 {
     $rosta = array('time' => time(), 'line' => array(), 'room' => array(), 'data' => array());
     $date = $this->input('date');
     $lgth = $this->input('lgth');
     $skip = $this->input('skip');
     $rids = $this->input('rids');
     $time = strtotime(Zyon_Util::isDate($date) ? $date : ($date = date('Y-m-d', $rosta['time'] - 86400)));
     if (!Zyon_Util::isInt($lgth)) {
         $lgth = 8;
     }
     $lgth = (int) $lgth;
     if (abs($lgth) > 30 || abs($lgth) < 2) {
         $this->flash(0, '入住时间和离店时间间隔最少 2天,最长 30天');
     }
     $lgth = $lgth > 0 ? $lgth - 1 : $lgth + 1;
     // 订单查询默认条件
     $where = array('o_hid = ' . $this->model('order')->quote($this->_master['u_hid']), 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YQX));
     // 指定房间编号集合
     if ($rids) {
         $rids = explode(',', $rids);
         if (empty($rids)) {
             $rooms = array();
         } else {
             $rooms = Zyon_Array::keyto($this->model('room')->getRoomAryByIds($rids, $this->_master['u_hid']), 'r_id');
         }
     } else {
         $rooms = Zyon_Array::keyto($this->model('room')->getRoomAryByHid($this->_master['u_hid']), 'r_id');
     }
     if (!empty($rooms)) {
         foreach ($rooms as $key => &$room) {
             if ($room['r_attr'] & ROOM_ATTR_YCFT) {
                 unset($rooms[$key]);
             }
         }
         unset($room);
         if (!empty($rooms)) {
             // 增加查询房间限定
             $where[] = sprintf('o_rid IN (%s)', implode(',', array_keys($rooms)));
         }
     }
     // 取得上(下)一个有订单时间临界点
     if (!empty($rooms) && $skip) {
         if ($lgth < 0) {
             $orders = $this->model('order')->fetch(array('where' => array_merge($where, array('o_etime < ' . $this->model('order')->quote($time))), 'order' => 'o_etime DESC', 'field' => 'o_edatm', 'limit' => 1));
             if ($orders) {
                 $time = (int) $orders[0]['o_edatm'];
             }
         } else {
             $orders = $this->model('order')->fetch(array('where' => array_merge($where, array('o_btime > ' . $this->model('order')->quote($time))), 'order' => 'o_btime ASC', 'field' => 'o_bdatm', 'limit' => 1));
             if ($orders) {
                 $time = (int) $orders[0]['o_bdatm'];
             }
         }
     }
     // 令 {$time} 为左值
     if ($lgth < 0) {
         $time = $time + $lgth * 86400;
         $lgth = abs($lgth);
     }
     $btime = $time;
     $etime = $btime + $lgth * 86400 + 86399;
     $rosta['line'][] = $btime;
     $rosta['line'][] = $etime;
     if (!empty($rooms)) {
         $obnum = $this->model('order')->calNumAryByRidAryAndSta(array_keys($rooms), ORDER_STATUS_YD, $rosta['time'] - 86400 * 3);
         foreach ($rooms as &$room) {
             $rosta['data'][$room['r_id']] = array();
             $rosta['room'][$room['r_id']] = array('rid' => $room['r_id'], 'sta' => $room['r_status'], 'rnm' => $this->view->escape($room['r_name']), 'ext' => array('rtp' => $this->view->escape($room['r_type']), 'rlo' => $this->view->escape($room['r_layout']), 'rze' => $this->view->escape($room['r_zone']), 'rvw' => $this->model('room')->getViewListByCode($room['r_view'])), 'ovt' => (int) $room['r_otime'], 'lvt' => (int) $room['r_btime'], 'rvt' => (int) $room['r_etime'], 'obn' => (int) (isset($obnum[$room['r_id']]) ? $obnum[$room['r_id']] : 0));
         }
         unset($room);
         $orders = Zyon_Array::keyto($this->model('order')->fetchAry(array_merge($where, array('o_btime < ' . $this->model('order')->quote($etime), 'o_etime > ' . $this->model('order')->quote($btime))), 'o_id DESC'), 'o_id');
         if (!empty($orders)) {
             $others = array();
             $owhere = array();
             foreach ($orders as &$order) {
                 $rosta['data'][$order['o_rid']][$order['o_id']] = array('key' => $order['o_mtime'], 'oid' => $order['o_id'], 'bid' => $order['o_bid'], 'ats' => (int) $order['o_attr'], 'sta' => (int) $order['o_status'], 'lvt' => $order['o_btime'], 'rvt' => $order['o_etime'], 'act' => $this->model('order')->getUsableActions($order, $this->_hostel, false), 'gst' => array('bkg' => array(array('gnm' => $this->view->escape($order['o_gbker_name']), 'tel' => $this->view->escape($order['o_gbker_phone']))), 'lvg' => array(array('gnm' => $this->view->escape($order['o_glver_name']), 'tel' => $this->view->escape($order['o_glver_phone'])))));
                 if ($order['o_memo'] == '') {
                     $rosta['data'][$order['o_rid']][$order['o_id']]['tip'] = '';
                 }
                 // 检测订单与房态的冲突
                 if ($order['o_btime'] <= $rooms[$order['o_rid']]['r_etime'] && $order['o_edatm'] > $rooms[$order['o_rid']]['r_btime']) {
                     unset($rosta['data'][$order['o_rid']][$order['o_id']]['act'][ORDER_ACTION_BLDD]);
                     unset($rosta['data'][$order['o_rid']][$order['o_id']]['act'][ORDER_ACTION_BLRZ]);
                 }
                 // 拆分占位和不占位订单
                 if ($order['o_status'] == ORDER_STATUS_YD) {
                     $owhere = empty($owhere) ? array(min($order['o_btime'], $btime), max($order['o_etime'], $etime)) : array(min($order['o_btime'], $owhere[0]), max($order['o_etime'], $owhere[1]));
                 } else {
                     $others[$order['o_id']] = $order;
                     unset($orders[$order['o_id']]);
                 }
             }
             unset($order);
             // 获取扩展时间段的订单
             if (!empty($owhere) && ($owhere[0] < $btime || $owhere[1] > $etime)) {
                 $others += Zyon_Array::keyto($this->model('order')->fetch(array('where' => array_merge($where, array(sprintf('o_id NOT IN (%s)', implode(',', array_merge(array_keys($orders), array_keys($others)))), 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YD), 'o_btime < ' . $this->model('order')->quote($owhere[1]), 'o_etime > ' . $this->model('order')->quote($owhere[0]))), 'field' => array('o_id', 'o_rid', 'o_btime', 'o_etime'))), 'o_id');
             }
             // 检测不占位的订单冲突
             foreach ($orders as &$order) {
                 foreach ($others as &$other) {
                     if ($other['o_rid'] === $order['o_rid'] && $other['o_btime'] < $order['o_etime'] && $other['o_etime'] > $order['o_btime']) {
                         unset($rosta['data'][$order['o_rid']][$order['o_id']]['act'][ORDER_ACTION_BLDD]);
                         unset($rosta['data'][$order['o_rid']][$order['o_id']]['act'][ORDER_ACTION_BLRZ]);
                         break;
                     }
                 }
                 unset($other);
             }
             unset($order, $orders, $others);
         }
     }
     if ($this->input('ct') === 'json') {
         $this->flash(1, array('context' => $rosta));
     }
     $this->view->hotel = $this->_hostel;
     $this->view->rosta = $rosta;
 }
コード例 #9
0
ファイル: Hotel.php プロジェクト: null-1/fangtaitong
 /**
  * calRoomNumByDay
  * 
  * @param date $date
  * @return array {$hid: $num, ...}
  */
 public function calRoomNumByDay($date, $hids = null)
 {
     if (!Zyon_Util::isDate($date)) {
         return false;
     }
     $time = strtotime($date) + 86399;
     try {
         $sql = $this->dbase()->select()->from($this->tname('hotel'), 'h_id')->joinLeft($this->tname('room'), 'h_id=r_hid AND r_otime <= :dtm', 'count(r_id)')->group('h_id');
         $hids and $sql->where(sprintf("h_id IN (%s)", is_string($hids) ? $hids : implode(',', $hids)));
         return $this->dbase()->fetchPairs($sql, array('dtm' => $time));
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
 }
コード例 #10
0
 public function doUpdateAction()
 {
     if (!array_key_exists($this->input('idtype'), $this->model('user')->getIdTypes())) {
         $this->flash(0, '证件类型错误');
     }
     $this->checkActionTarget($user = $this->loadUsableUser($uid = $this->input('uid', 'numeric')));
     $account = array();
     $account['u_permit'] = 0;
     $account['u_phone'] = $this->input('mobile');
     $account['u_idtype'] = $this->input('idtype');
     $account['u_idno'] = $this->input('idno');
     $account['u_rolename'] = $this->input('rolename');
     $permit = $this->input('permit', 'array');
     if (!empty($permit)) {
         foreach ($permit as $key => $val) {
             if (!isset($key[1]) || $key[0] !== 'b' || !Zyon_Util::isBin($bin = substr($key, 1)) || ($dec = bindec($bin)) > PERMIT_MASTER || $dec < 1) {
                 $this->flash(0, '权限分配错误');
             }
             if ($val > 0) {
                 $account['u_permit'] = $account['u_permit'] | $dec;
             }
         }
     }
     if ($this->model('user')->modUser($uid, $account)) {
         $this->flash(1, '更新帐号信息成功');
     }
     $this->flash(0);
 }
コード例 #11
0
ファイル: Mber.php プロジェクト: null-1/fangtaitong
 /**
  * getMberByEmail
  * 
  * @param string $email 
  * @param int    $hid 
  * @return array
  */
 public function getMberByEmail($email, $hid)
 {
     if (empty($email) || !Zyon_Util::isEmail($email) || !Zyon_Util::isUnsignedInt($hid)) {
         return false;
     }
     try {
         $sql = $this->dbase()->select()->from($this->tname('mber'))->where('m_email = :email')->where('m_hid = :hid')->limit(1);
         return $this->dbase()->fetchRow($sql, array('email' => $email, 'hid' => $hid));
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
 }
コード例 #12
0
ファイル: Stat.php プロジェクト: null-1/fangtaitong
 /**
  * calYuDingLiang
  * 计算某一时段的预订量,以渠道分组
  * 
  * @param int  $hid
  * @param date $bdate
  * @param date $edate
  * @return array
  */
 public function calYuDingLiang($hid, $bdate, $edate)
 {
     if (!Zyon_Util::isUnsignedInt($hid) || !Zyon_Util::isDate($bdate) || !Zyon_Util::isDate($edate)) {
         return false;
     }
     $btime = strtotime($bdate) + 86399;
     $etime = strtotime($edate) + 86400;
     if ($etime <= $btime) {
         return false;
     }
     try {
         $sql = $this->dbase()->select()->from($this->tname('order'), 'o_cid, SUM(DATEDIFF(FROM_UNIXTIME(LEAST(o_etime, :etime)), FROM_UNIXTIME(GREATEST(o_btime, :btime))))')->where('o_hid = :hid')->where('NOT (o_btime >= :etime OR o_etime <= :btime)')->where(sprintf('o_status IN (%s, %s)', $this->quote(ORDER_STATUS_YD), $this->quote(ORDER_STATUS_BL)))->group('o_cid');
         return $this->dbase()->fetchPairs($sql, array('hid' => $hid, 'btime' => $btime, 'etime' => $etime));
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
 }
コード例 #13
0
ファイル: Journal.php プロジェクト: null-1/fangtaitong
 /**
  * getJournalAryByHidAndDay
  * 
  * @param int    $hid
  * @param string $day
  * @return array
  */
 public function getJournalAryByHidAndDay($hid, $day)
 {
     if (!is_numeric($hid) || !Zyon_Util::isDate($day)) {
         return false;
     }
     $dtm = strtotime($day);
     return $this->getJournalAryByIds($this->fetchIds(array('bj_hid = ' . $this->quote($hid), 'bj_time >= ' . $dtm, 'bj_time < ' . ($dtm + 86400))));
 }
コード例 #14
0
ファイル: Bill.php プロジェクト: null-1/fangtaitong
 /**
  * getRealTimeStateBillAryByHid
  * 
  * @param int $hid
  * @param int $btime
  * @param int $etime
  * @return array
  */
 public function getRealTimeStateBillAryByHid($hid, $btime, $etime)
 {
     if (!Zyon_Util::isUnsignedInt($hid) || !is_numeric($btime) || !is_numeric($etime)) {
         return false;
     }
     try {
         $sql = $this->dbase()->select()->from($this->tname('bill'))->where('b_hid = :hid')->where('b_status <> ' . BILL_STATUS_GB)->where('b_ctime < :etime')->where('b_ctime > :btime')->order('b_id ASC');
         return $this->dbase()->fetchAll($sql, array('hid' => $hid, 'btime' => $btime, 'etime' => $etime));
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
 }
コード例 #15
0
ファイル: RoomController.php プロジェクト: null-1/fangtaitong
 /**
  * 执行停用、启用房间操作
  */
 public function doRetainAction()
 {
     $room = $this->loadUsableRoom($this->input('rid'));
     $oper = $this->input('pause');
     $desc = $this->input('desc');
     if (!$oper) {
         if (!$this->model('room')->modRoom($room['r_id'], array('r_btime' => 0, 'r_etime' => 0))) {
             $this->flash(0);
         }
         $log = $this->model('log.room')->getNewRetainToLiveLog($this->_master, $room, $this->model('room')->getRoom($room['r_id']));
         $log['lr_memo'] = $desc;
         $this->model('log.room')->addLog($log);
         $this->flash(1);
     }
     /**
      * 处理停用起始时间
      */
     if (!Zyon_Util::isDate($bdate = $this->input('bdate'))) {
         $this->flash(0, ' 停用起始时间必须是合法的日期格式');
     }
     $btime = strtotime($bdate);
     /**
      * 处理停用结束时间
      */
     if (!Zyon_Util::isDate($edate = $this->input('edate'))) {
         $this->flash(0, '停用结束时间必须是合法的日期格式');
     }
     $etime = strtotime($edate) + 86399;
     if ($etime < $btime) {
         $this->flash(0, '停用结束时间不能早于停用起始时间');
     }
     if (!$this->model('room')->modRoom($room['r_id'], array('r_btime' => $btime, 'r_etime' => $etime))) {
         $this->flash(0);
     }
     $log = $this->model('log.room')->getNewRetainToStopLog($this->_master, $room, $this->model('room')->getRoom($room['r_id']));
     $log['lr_memo'] = $desc;
     $this->model('log.room')->addLog($log);
     $this->flash(1);
 }
コード例 #16
0
ファイル: Room.php プロジェクト: null-1/fangtaitong
 /**
  * calLiveNumByDay
  * 
  * @param date $date
  * @return int
  */
 public function calLiveNumByDateAndRids($date, $rids)
 {
     if (!Zyon_Util::isDate($date)) {
         return false;
     }
     $time = strtotime($date) + 86399;
     try {
         $sql = $this->dbase()->select()->from($this->tname('order'), 'count(o_id)')->where("o_itime <= :dtm AND (o_status = :sta OR o_otime > :dtm)");
         $rids and $sql->where(sprintf("o_rid IN (%s)", is_string($rids) ? $rids : implode(',', $rids)));
         return $this->dbase()->fetchOne($sql, array('dtm' => $time, 'sta' => ORDER_STATUS_ZZ));
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
 }
コード例 #17
0
ファイル: BillController.php プロジェクト: null-1/fangtaitong
 /**
  * fetchBillPaid
  * 
  * @param string $input
  * @param int    $total
  * @return array
  */
 public function fetchBillPaid($input, &$total)
 {
     /**
      * 处理账单已收
      */
     $bill = $this->input($input, 'array');
     if (empty($bill)) {
         $this->flash(0, '已收款项错误');
     }
     empty($total) and $total = 0;
     $froms = Zyon_Array::keyto($this->model('hotel.payment')->getUsablePaymentAryByHid($this->_hostel['h_id']), 'hp_id');
     empty($froms) and $froms = array();
     foreach ($bill as $key => $val) {
         if (!is_array($val) || !isset($val['qnty']) || !is_string($val['qnty']) || trim($val['qnty']) == '') {
             unset($bill[$key]);
             continue;
         }
         if (!Zyon_Util::isUnsignedInt($val['from']) || !Zyon_Util::isMoneyFloat($val['qnty']) || $val['qnty'] < 0 || !Zyon_Util::isDate($val['date']) || !isset($val['memo']) || !is_string($val['memo'])) {
             $this->flash(0, '已收款项错误');
         }
         if (!array_key_exists($val['from'], $froms)) {
             $this->flash(0, '已收款项渠道错误');
         }
         $val['qnty'] = (empty($val['oper']) ? $val['qnty'] : -$val['qnty']) * 100;
         $val['memo'] = trim($val['memo']);
         if (mb_strlen($val['memo']) > 200) {
             $this->flash(0, '备注内容不能超过200个字符');
         }
         $total += (int) $val['qnty'];
         if ($total >= 10000000) {
             $this->flash(0, '已收总金额超出系统限制,必须小于100000');
         }
         if ($total <= -10000000) {
             $this->flash(0, '已收总金额超出系统限制,必须大于-100000');
         }
         $bill[$key] = $this->model('bill.journal')->getNewJournal(0, $this->_hostel['h_id'], $this->_master['u_id'], $val['from'], $val['qnty'], strtotime($val['date']), $this->_master['u_realname'], $froms[$val['from']]['hp_name'], $val['memo']);
     }
     $total = (string) $total;
     if (empty($bill)) {
         $this->flash(0, '没有可用的已收款项记录');
     }
     return array_values($bill);
 }
コード例 #18
0
 /**
  * 创建订单
  */
 public function doCreateAction()
 {
     if (!$this->getRequest()->isPost()) {
         $this->flash(0, '错误来源的表单提交');
     }
     $captcha = new Geek_Captcha_Image('/hostel/order/do-create');
     if (!$captcha->isValid($this->input('captcha'))) {
         $this->flash(0, '请填写正确的验证码');
     }
     if (!Zyon_Util::isUnsignedInt($otime = $this->input('ctime')) || !is_array($order = $this->input('order', 'array')) || empty($order) || !is_array($orent = $this->input('price', 'array')) || empty($orent) || !is_array($gbker = $this->input('cuser', 'array')) || empty($gbker) || !is_array($glves = $this->input('guest', 'array')) || empty($glves) || ($count = count($order)) !== count($orent) || $count !== count($glves) || !isset($gbker['name']) || !isset($gbker['call']) || !isset($gbker['mail'])) {
         $this->flash(0, '提交订单的参数错误');
     }
     $gbker = array('o_gbker_name' => $gbker['name'], 'o_gbker_email' => $gbker['mail'], 'o_gbker_phone' => $gbker['call']);
     if (!$this->model('order')->verify($gbker)) {
         $this->flash(0, '预订客人信息参数错误');
     }
     $ctime = time();
     $dtime = strtotime(date('Y-m-d', $ctime));
     if ($ctime - $otime < 10 || $ctime - $otime > 1800 || $dtime !== strtotime(date('Y-m-d', $otime))) {
         $this->flash(0, '订单已失效,请刷新重试');
     }
     $this->checkHotelStat($hotel = $this->loadUsableHotel($hid = $this->input('hid')));
     if (!(SYSTEM_GROUPS_GSER & (int) $hotel['h_order_enabled'])) {
         $this->flash(0, '旅店尚未开放该功能');
     }
     if ($count > static::ORDER_LIMIT) {
         $this->flash(0, __('单次预订不允许超过%d个房间', static::ORDER_LIMIT));
     }
     $btmad = $hotel['h_checkin_time'];
     $etmad = $hotel['h_checkout_time'];
     $price_rules_conds = $other_order_conds = array();
     foreach ($order as $rid => &$val) {
         if (!Zyon_Util::isUnsignedInt($rid) || !is_array($val) || !isset($val['date']) || !isset($val['lgth']) || !Zyon_Util::isDate($val['date']) || !Zyon_Util::isUnsignedInt($val['lgth']) || $val['lgth'] < 1 || !is_array($val['time']) || !isset($val['time'][0]) || !isset($val['time'][1]) || !Zyon_Util::isUnsignedInt($val['time'][0]) || !Zyon_Util::isUnsignedInt($val['time'][1]) || $val['time'][0] < $btmad || $val['time'][0] > 86399 || $val['time'][1] > $etmad || $val['time'][0] < 1) {
             $this->flash(0, '参数错误');
         }
         if ($val['lgth'] < $hotel['h_order_minlens'] || $val['lgth'] > $hotel['h_order_maxlens']) {
             $this->flash(0, __('旅店仅支持创建天数介于 %d 到 %d 的订单', $hotel['h_order_minlens'], $hotel['h_order_maxlens']));
         }
         $val['datm'] = strtotime($val['date']);
         if ($val['datm'] < $dtime) {
             $this->flash(0, '不支持创建今天之前的订单');
         }
         $price_rules_conds[] = sprintf('(rp_rid = %d AND rp_btime <= %d AND rp_etime >= %d)', $rid, $val['datm'] + ($val['lgth'] - 1) * 86400, $val['datm']);
         $other_order_conds[] = sprintf('(o_rid = %d AND o_btime < %d AND o_etime > %d)', $rid, $val['datm'] + $val['lgth'] * 86400 + $val['time'][1], $val['datm'] + $val['time'][0]);
     }
     unset($val);
     $price_rules_conds = implode(' OR ', $price_rules_conds);
     $other_order_conds = implode(' OR ', $other_order_conds);
     $rooms = Zyon_Array::keyto($this->model('room')->getRoomAryByIds(array_keys($order)), 'r_id');
     if (empty($rooms) || count($rooms) !== $count) {
         $this->flash(0, '找不到指定预订的房间');
     }
     // 以下处理每个房间的启用日、停用段以及订单最长时间限制,
     // 整理入住客人信息
     foreach ($rooms as $rid => &$val) {
         if ($val['r_hid'] !== $hotel['h_id']) {
             $this->flash(0, '找不到指定预订的房间');
         }
         if ($val['r_attr'] & ROOM_ATTR_YCFT) {
             $this->flash(0, __('指定的房间 %s 不可预订', $val['r_name']));
         }
         if (!isset($glves[$rid]) || !is_array($glves[$rid]) || !isset($glves[$rid]['name']) || !isset($glves[$rid]['mail']) || !isset($glves[$rid]['call'])) {
             $this->flash(0, '缺少入住客人信息');
         }
         $glves[$rid] = array('o_glver_name' => $glves[$rid]['name'], 'o_glver_email' => $glves[$rid]['mail'], 'o_glver_phone' => $glves[$rid]['call']);
         if (!$this->model('order')->verify($glves[$rid])) {
             $this->flash(0, __('%s 房间的入住客人信息错误', $val['r_name']));
         }
         $btime = $order[$rid]['datm'];
         $etime = $btime + $order[$rid]['lgth'] * 86400 - 1;
         for ($_btime = max($btime, $dtime + 86400 * $hotel['h_order_enddays']); $_btime < $etime; $_btime += 86400) {
             $this->flash(0, __('%s 的 %s 房间不可用', date('Y-m-d', $_btime), $val['r_name']));
         }
         if ($val['r_btime']) {
             $_r_btime = max($btime, $val['r_btime']);
             $_r_etime = min($etime, $val['r_etime']);
             while ($_r_btime < $_r_etime) {
                 $this->flash(0, __('%s 的 %s 房间不可用', date('Y-m-d', $_r_btime), $val['r_name']));
             }
         }
         if ($btime < $val['r_otime']) {
             $this->flash(0, __('房间%s在%s之前尚未启用', $val['r_name'], date('Y-m-d', $val['r_otime'])));
         }
     }
     unset($val);
     // 以下检测旅店预订订单是否超出限制
     if ($hotel['h_order_default_stacode'] == ORDER_STATUS_YD) {
         $oldes = $this->model('order')->calNumAryByRidAryAndSta(array_keys($order), ORDER_STATUS_YD, $ctime - getSysLimit('BOOKING_LIVE'));
         if (!empty($oldes)) {
             if ($count + array_sum($oldes) > getSysLimit('BOOKING_QNTY')) {
                 $this->flash(0, '旅店预订订单数量已满');
             }
             $per = getSysLimit('BOOKING_PERN');
             foreach ($oldes as $rid => $num) {
                 if (array_key_exists($rid, $order) && $num > $per - 1) {
                     $this->flash(0, __('%s 房间预订订单数量已满', $rooms[$rid]['r_name']));
                 }
             }
         }
     }
     // 以下处理每个订单的冲突
     $other = $this->model('order')->getOrderAryByIds($this->model('order')->fetchIds(array('o_hid = ' . $hotel['h_id'], 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YQX), 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YD), $other_order_conds), null, 1));
     if (!is_array($other)) {
         $this->flash(0, '无法获取系统订单的信息');
     }
     if (!empty($other)) {
         foreach ($other as &$val) {
             $rid = $val['o_rid'];
             $_o_btime = max($order[$rid]['datm'], $val['o_bdatm']);
             $_o_etime = min($order[$rid]['datm'] + $order[$rid]['lgth'] * 86400, $val['o_edatm']);
             while ($_o_btime < $_o_etime) {
                 $this->flash(0, __('%s 的 %s 房间已被占用', date('Y-m-d', $_o_btime), $rooms[$rid]['r_name']));
             }
             if ($val['o_bdatm'] == $order[$rid]['datm'] + $order[$rid]['lgth'] * 86400 && $order[$rid]['time'][1] > $val['o_btime'] - $val['o_bdatm']) {
                 $this->flash(0, __('%s 的 %s 房间已被占用', date('Y-m-d', $val['o_bdatm']), $rooms[$rid]['r_name']));
             }
             if ($val['o_edatm'] == $order[$rid]['datm'] && $order[$rid]['time'][0] < $val['o_etime'] - $val['o_edatm']) {
                 $this->flash(0, __('%s 的 %s 房间已被占用', date('Y-m-d', $val['o_edatm']), $rooms[$rid]['r_name']));
             }
         }
         unset($val);
     }
     unset($other);
     // 以下处理每个订单的房费
     $basic = $this->model('room.price')->getBasicPriceByRids(array_keys($rooms));
     if (!$basic || count($basic) !== $count) {
         $this->flash(0, '无法获取预订房间的房价');
     }
     $rules = Zyon_Array::group($this->model('room.price')->getPriceAryByIds($this->model('room.price')->fetchIds(array('rp_hid = ' . $hotel['h_id'], $price_rules_conds))), 'rp_rid');
     $price = array();
     foreach (array_keys($basic) as $rid) {
         $price[$rid] = $this->model('room.price')->getPriceDotAry($basic[$rid], $order[$rid]['datm'], $order[$rid]['datm'] + $order[$rid]['lgth'] * 86400 - 1, isset($rules[$rid]) ? $rules[$rid] : array());
     }
     unset($basic, $rules);
     // 以下校验提交订单时的房费和当前是否相同
     if (count($price) !== count($orent)) {
         $this->flash(0, '订单价格错误');
     }
     $obsum = 0;
     foreach ($price as $rid => &$val) {
         if (!isset($orent[$rid]) || count($val) !== count($orent[$rid])) {
             $this->flash(0, '订单价格错误');
         }
         foreach ($val as $k => $v) {
             if (!isset($orent[$rid][$k])) {
                 $this->flash(0, '订单价格错误');
             }
             if ((string) ($v / 100) !== $orent[$rid][$k]) {
                 $this->flash(0, '订单价格已失效,请刷新重试');
             }
             $obsum += $v;
         }
     }
     unset($val);
     $sales = $this->model('user')->getUser($hotel['h_order_default_saleman']);
     if (!$sales) {
         $this->flash(0, '读取旅店销售人员信息失败');
     }
     $otype = $this->model('hotel.typedef')->getTypedef($hotel['h_order_default_typedef']);
     if (!$otype) {
         $this->flash(0, '读取旅店预订类型信息失败');
     }
     $cfrom = $this->model('hotel.channel')->getChannel($hotel['h_order_default_channel']);
     if (!$cfrom) {
         $this->flash(0, '读取旅店预订渠道信息失败');
     }
     $osetm = $this->model('hotel.settlem')->getSettlem($hotel['h_obill_default_settlem']);
     if (!$osetm) {
         $this->flash(0, '读取旅店结算方式信息失败');
     }
     $ltime = $hotel['h_attr'] & (int) HOTEL_ATTR_ZDGQ ? $ctime + $hotel['h_obill_keptime'] : null;
     /**
      * 开启事务,创建订单
      */
     $this->model('order')->dbase()->beginTransaction();
     try {
         $bid = $this->model('bill')->addBill($this->model('bill')->getNewBill($hid, $osetm['hs_id'], $osetm['hs_name'], $obsum, 0, mb_substr($gbker['o_gbker_name'], 0, 10) . '-' . date('ymdHi', $ctime), $ltime));
         if (!$bid) {
             throw new exception('创建订单相关账单信息失败');
         }
         foreach ($order as $rid => $order) {
             $order = $this->model('order')->getNewOrder($rooms[$rid], $order['datm'] + $order['time'][0], $order['datm'] + 86400 * $order['lgth'] + $order['time'][1], json_encode($price[$rid]), json_encode($price[$rid]), $hotel['h_order_default_stacode']);
             $order['o_bid'] = $bid;
             $order['o_cid'] = $cfrom['hc_id'];
             $order['o_cnm'] = $cfrom['hc_name'];
             $order['o_tid'] = $otype['ht_id'];
             $order['o_tnm'] = $otype['ht_name'];
             $order['o_sid'] = $sales['u_id'];
             $order['o_snm'] = $sales['u_realname'];
             $order['o_attr'] = ORDER_ATTR_ZXDD;
             $order = array_merge($gbker, $glves[$rid], $order);
             $oid = $this->model('order')->addOrder($order);
             if (!$oid) {
                 throw new exception('创建订单失败');
             }
             if ($order = $this->model('order')->getOrder($oid)) {
                 $this->model('log.order')->addLog($this->model('log.order')->getNewCreateByGserLog($gbker, $order));
             }
         }
         if ($bill = $this->model('bill')->getBill($bid)) {
             $this->model('log.bill')->addLog($this->model('log.bill')->getNewCreateByGserLog($gbker, $bill));
         }
         $this->model('order')->dbase()->commit();
         $this->flash(1, array('forward' => "/hostel/rosta?hid={$hid}"));
     } catch (Exception $e) {
         $this->model('order')->dbase()->rollBack();
         $this->error($e);
     }
     $this->flash(0);
 }
コード例 #19
0
ファイル: User.php プロジェクト: null-1/fangtaitong
 /**
  * getUserByEmail
  * 
  * @param string $email 
  * @return array
  */
 public function getUserByEmail($email)
 {
     if (empty($email) || !Zyon_Util::isEmail($email)) {
         return false;
     }
     try {
         if ($id = $this->cache()->load($key = $this->hash($email))) {
             if (($ret = $this->getUser($id)) && $ret['u_email'] === $email) {
                 return $ret;
             }
             $this->cache()->remove($key);
         }
         $sql = $this->dbase()->select()->from($this->tname('user'))->where('u_email = :email')->limit(1);
         if ($ret = $this->dbase()->fetchRow($sql, array('email' => $email))) {
             $this->cache()->save($ret['u_id'], $key);
         }
         return $ret;
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
 }
コード例 #20
0
ファイル: Order.php プロジェクト: null-1/fangtaitong
 /**
  * calNumAryByRidAryAndSta
  * 
  * @param array $ids
  * @param mixed $sta
  * @param int   $dtm
  * @return array
  */
 public function calNumAryByRidAryAndSta($ids, $sta, $dtm = 0)
 {
     if (!$sta || !is_array($ids) || !Zyon_Util::isUnsignedInt($dtm)) {
         return false;
     }
     try {
         $sql = $this->dbase()->select()->from($this->tname('order'), array('o_rid', 'count(o_id)'))->group('o_rid')->where(sprintf('o_rid IN (%s)', implode(',', $ids)))->where('o_status = ' . $this->quote($sta));
         if ($dtm) {
             $sql->where('o_ctime >= ' . $dtm);
         }
         return $this->dbase()->fetchPairs($sql);
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
 }
コード例 #21
0
 /**
  * fetchOrderPrice
  * 
  * @param mixed $value
  * @param mixed $bdate
  * @param mixed $edate
  * @return array
  */
 public function fetchOrderPrice($value, $bdate, $edate)
 {
     if (!Zyon_Util::isDate($bdate) || !Zyon_Util::isDate($edate)) {
         $this->flash(0, '订单日期错误');
     }
     if (empty($value) || !is_array($value)) {
         $this->flash(0, '房费参数错误');
     }
     $btime = strtotime($bdate);
     $etime = strtotime($edate) - 86400;
     $count = 0;
     while ($btime <= $etime) {
         if (!isset($value[$btime])) {
             $this->flash(0, date('Y-m-d', $btime) . '房费未定义');
         }
         if (!Zyon_Util::isMoneyFloat($value[$btime])) {
             $this->flash(0, date('Y-m-d', $btime) . '房费参数错误');
         }
         $value[$btime] = $value[$btime] * 100;
         if ($value[$btime] < 0) {
             $this->flash(0, date('Y-m-d', $btime) . '房费值太小,必须至少大于0');
         }
         if ($value[$btime] >= 10000000) {
             $this->flash(0, date('Y-m-d', $btime) . '房费值太大,必须小于100000');
         }
         $count += 1;
         $btime += 86400;
     }
     if ($count !== count($value)) {
         $this->flash(0, '房费参数错误');
     }
     return $value;
 }
コード例 #22
0
 /**
  * 执行登录动作
  */
 public function doSigninAction()
 {
     if ($this->_master) {
         $this->flash(1, '您已经登录过了');
     }
     if (!Zyon_Util::isEmail($usign = $this->input('username'))) {
         $this->flash(0, '请填写正确的邮箱地址');
     }
     $chash = md5(__CLASS__ . ':signin#' . $usign);
     if ($this->input('captcha') !== '' || $this->cache()->load($chash)) {
         $captcha = new Geek_Captcha_Image('/master/index/do-signin');
         if (!$captcha->isValid($this->input('captcha'))) {
             $this->flash($this->input('captcha') !== '' ? 0 : -1, '请填写正确的验证码');
         }
     }
     $outcome = $this->model('user')->getAuth()->verify($this);
     if (($session = $outcome->getSession()) && ($uid = $this->model('user')->parseAuthUqid($session->getIdentity()))) {
         $this->_master = $this->model('user')->getUser($uid);
         $this->checkUserStat();
         $this->model('log.user')->addLog($this->model('log.user')->getNewSigninLog($this->_master));
         $this->cache()->remove($chash);
         $this->flash(1, array('timeout' => 0, 'forward' => '/master'));
     }
     $this->cache()->save(1, $chash);
     $this->flash($this->input('captcha') !== '' ? 0 : -1, $outcome->getMessage());
 }
コード例 #23
0
ファイル: Job.php プロジェクト: null-1/fangtaitong
 /**
  * checkTimesLimit
  * 
  * @param string $to_email 
  * @param string $title 
  * @param string $from_name 
  * @return bool
  */
 public function checkTimesLimit($to_email, $title, $from_name)
 {
     if (!isset($from_name[0]) || !is_string($from_name) || !isset($title[0]) || !is_string($title)) {
         return false;
     }
     if (!Zyon_Util::isEmail($to_email)) {
         return false;
     }
     $now = time();
     $rules = array($now - 86400 => 5, $now - 3600 => 3, $now - 600 => 1);
     // ksort($rules, SORT_NUMERIC);
     try {
         $sql = $this->dbase()->select()->from($this->tname('mail_job'), 'mj_ctime as ctime')->where('mj_to_email = :to_email')->where('mj_title = :title')->where('mj_from_name = :from_name')->where('mj_ctime >= ?', min(array_keys($rules)))->order('mj_ctime ASC')->limit(max($rules));
         if ($ret = $this->dbase()->fetchCol($sql, array('to_email' => $to_email, 'title' => $title, 'from_name' => $from_name))) {
             if (isset($ret[max($rules) - 1])) {
                 return false;
             }
             if (!isset($ret[min($rules) - 1])) {
                 return true;
             }
             foreach ($rules as $ctime => $limit) {
                 foreach ($ret as $idx => $val) {
                     if ($val < $ctime) {
                         unset($ret[$idx]);
                     } else {
                         break;
                     }
                 }
                 if (empty($ret)) {
                     return true;
                 }
                 if (count($ret) >= $limit) {
                     return false;
                 }
             }
         }
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
     return true;
 }
コード例 #24
0
 /**
  * 旅店房态
  */
 public function indexAction()
 {
     $this->checkHotelStat($hotel = $this->loadUsableHotel($this->input('hid')));
     if ((!$this->_master || $this->_master['u_hid'] !== $hotel['h_id']) && !(SYSTEM_GROUPS_GSER & (int) $hotel['h_rosta_visible'])) {
         $this->flash(0, '旅店尚未开放该功能');
     }
     $rosta = array('time' => time(), 'line' => array(), 'room' => array(), 'data' => array());
     $date = $this->input('date');
     $lgth = $this->input('lgth');
     $time = strtotime(Zyon_Util::isDate($date) ? $date : ($date = date('Y-m-d', $rosta['time'])));
     if (!Zyon_Util::isInt($lgth)) {
         $lgth = 8;
     }
     $lgth = (int) $lgth;
     if (abs($lgth) > 30 || abs($lgth) < 2) {
         $this->flash(0, '入住时间和离店时间间隔最少 2天,最长 30天');
     }
     $lgth = $lgth > 0 ? $lgth - 1 : $lgth + 1;
     // 令 {$time} 为左值
     if ($lgth < 0) {
         $time = $time + $lgth * 86400;
         $lgth = abs($lgth);
     }
     $btime = $time;
     $etime = $btime + $lgth * 86400 + 86399;
     $rosta['line'][] = $btime;
     $rosta['line'][] = $etime;
     if ($btime > $rosta['time'] - 86400) {
         // 订单查询默认条件
         $where = array('o_hid = ' . $this->model('order')->quote($hotel['h_id']), 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YQX));
         $rooms = Zyon_Array::keyto($this->model('room')->getRoomAryByHid($hotel['h_id']), 'r_id');
         if (!empty($rooms)) {
             foreach ($rooms as $key => &$room) {
                 if ($room['r_attr'] & ROOM_ATTR_YCFT) {
                     unset($rooms[$key]);
                     continue;
                 }
                 $rosta['data'][$room['r_id']] = array();
                 $rosta['rent'][$room['r_id']] = array();
                 $rosta['room'][$room['r_id']] = array('rid' => $room['r_id'], 'rnm' => $this->view->escape($room['r_name']), 'ext' => array('rtp' => $this->view->escape($room['r_type']), 'rlo' => $this->view->escape($room['r_layout']), 'rze' => $this->view->escape($room['r_zone']), 'rvw' => $this->model('room')->getViewListByCode($room['r_view'])));
                 if ($btime < $room['r_otime']) {
                     $_r_btime = $btime;
                     $_r_otime = min($etime, $room['r_otime']);
                     while ($_r_btime < $_r_otime) {
                         $rosta['data'][$room['r_id']][($_r_btime - $btime) / 86400] = ROSTA_BL;
                         $_r_btime += 86400;
                     }
                 }
                 if ($room['r_btime']) {
                     $_r_btime = max($btime, $room['r_btime']);
                     $_r_etime = min($etime, $room['r_etime']);
                     while ($_r_btime < $_r_etime) {
                         $rosta['data'][$room['r_id']][($_r_btime - $btime) / 86400] = ROSTA_BL;
                         $_r_btime += 86400;
                     }
                 }
             }
             unset($room);
         }
         if (!empty($rooms)) {
             // 增加查询房间限定
             $where[] = sprintf('o_rid IN (%s)', implode(',', array_keys($rooms)));
             $orders = Zyon_Array::keyto($this->model('order')->getOrderAryByIds($this->model('order')->fetchIds(array_merge($where, array('o_bdatm < ' . $this->model('order')->quote($etime), 'o_edatm > ' . $this->model('order')->quote($btime))))), 'o_id');
             if (!empty($orders)) {
                 foreach ($orders as &$order) {
                     switch ($order['o_status']) {
                         case ORDER_STATUS_YD:
                             $sta = ROSTA_YD;
                             break;
                         default:
                             $sta = ROSTA_BL;
                             break;
                     }
                     $_o_btime = max($btime, $order['o_bdatm']);
                     $_o_etime = min($etime, $order['o_edatm']);
                     while ($_o_btime < $_o_etime) {
                         $key = ($_o_btime - $btime) / 86400;
                         if (!isset($rosta['data'][$order['o_rid']][$key]) || $rosta['data'][$order['o_rid']][$key] !== ROSTA_BL) {
                             $rosta['data'][$order['o_rid']][$key] = $sta;
                         }
                         $_o_btime += 86400;
                     }
                 }
                 unset($order);
             }
             $prices = $this->model('room.price')->getPriceDotAryByHid($hotel['h_id'], $btime, $etime);
             if (!empty($prices)) {
                 foreach ($prices as $rid => &$lst) {
                     if (isset($rooms[$rid])) {
                         foreach ($lst as $dtm => $val) {
                             $val = (int) $val;
                             if (($end = end($rosta['rent'][$rid])) !== false && $end === $val) {
                                 unset($rosta['rent'][$rid][$key = key($rosta['rent'][$rid])]);
                                 $key = explode(',', $key);
                                 $key[1] = ($dtm - $btime) / 86400;
                                 $rosta['rent'][$rid][implode(',', $key)] = $val;
                             } else {
                                 $rosta['rent'][$rid][($dtm - $btime) / 86400] = $val;
                             }
                         }
                     }
                 }
                 unset($lst);
             }
             // 合并相同状态的单元格,键 P 改为 L,R
             foreach ($rosta['data'] as $key => &$val) {
                 $lst = array();
                 ksort($val, SORT_NUMERIC);
                 $idx = -1;
                 foreach ($val as $k => $v) {
                     if ($k && isset($val[$k - 1]) && $val[$k - 1] === $v) {
                         $lst[$idx][2] = $k;
                     } else {
                         ++$idx;
                         $lst[] = array($v, $k);
                     }
                 }
                 $rosta['data'][$key] = array();
                 foreach ($lst as $k => $v) {
                     $rosta['data'][$key][isset($v[2]) ? $v[1] . ',' . $v[2] : $v[1]] = $v[0];
                 }
             }
         }
     }
     if ($this->input('ct') === 'json') {
         $this->flash(1, array('context' => $rosta));
     }
     $this->view->hotel = $hotel;
     $this->view->rosta = $rosta;
 }
コード例 #25
0
ファイル: LogController.php プロジェクト: null-1/fangtaitong
 /**
  * initQuery
  * 
  * @return void
  */
 public function initQuery()
 {
     $pager = $query = array();
     $pager['qnty'] = (int) $this->input('qnty', 'numeric');
     empty($pager['qnty']) and $pager['qnty'] = 30;
     $pager['qnty'] = $query['qnty'] = min($pager['qnty'], 30);
     $pager['page'] = (int) $this->input('page', 'numeric');
     empty($pager['page']) and $pager['page'] = 1;
     $query['bdate'] = $this->input('bdate', 'string');
     Zyon_Util::isDate($query['bdate']) or $query['bdate'] = null;
     $query['edate'] = $this->input('edate', 'string');
     Zyon_Util::isDate($query['edate']) or $query['edate'] = null;
     if ($query['bdate'] && $query['edate']) {
         $btime = strtotime($query['bdate']);
         $etime = strtotime($query['edate']);
         if ($etime < $btime) {
             $this->flash(0, '查询时间范围错误');
         }
     }
     $pager['args'] = $query;
     $this->view->query = $query;
     $this->view->pager = $pager;
 }
コード例 #26
0
ファイル: StatController.php プロジェクト: null-1/fangtaitong
 /**
  * 结算报表 - 预订客人对账明细
  */
 public function jsbbYdkrdzmxAction()
 {
     if (!($date = $this->input('date', 'array'))) {
         $this->_forward('jsbb-ydkrdzmx-form', 'stat', 'master');
         return;
     }
     if (!isset($date[0]) || !isset($date[1]) || !Zyon_Util::isDate($date[0]) || !Zyon_Util::isDate($date[1])) {
         $this->flash(0, '查询的日期格式错误');
     }
     $tmln = array();
     $tmln[0] = strtotime($date[0]);
     $tmln[1] = strtotime($date[1]) + 86400;
     $lgth = ($tmln[1] - $tmln[0]) / 86400;
     if (!Zyon_Util::isUnsignedInt($lgth) || $lgth > 31 || $lgth < 1) {
         $this->flash(0, '选择的日期超出了可查询的范围');
     }
     $tmln[1] -= 1;
     if (($bknm = $this->input('bknm')) == '') {
         $this->flash(0, '预订客人姓名不能为空');
     }
     $time = time();
     $ydkr = $this->model('order')->getIndexOrderAry(array('o_hid = ' . (int) $this->_hostel['h_id'], 'o_etime >= ' . (int) $tmln[0], 'o_etime <= ' . (int) $tmln[1], 'o_status = ' . (int) ORDER_STATUS_YJS), array('type' => HOTEL_GUEST_TYPE_BOOK, 'name' => $bknm));
     $this->view->time = $time;
     $this->view->tmln = $tmln;
     $this->view->bknm = $bknm;
     $this->view->ydkr = $ydkr;
 }