コード例 #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
ファイル: Journal.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['bj_hid'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_hid']) || empty($record['bj_hid']) || strlen($record['bj_hid']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_bid'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_bid']) || empty($record['bj_bid']) || strlen($record['bj_bid']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_uid'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_uid']) || empty($record['bj_uid']) || strlen($record['bj_uid']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_sum'])) {
         if (!Zyon_Util::isInt($record['bj_sum']) || strlen($record['bj_sum']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_time'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_time']) || strlen($record['bj_time']) > 11) {
             return false;
         }
     }
     if (isset($record['bj_user'])) {
         if (!is_string($record['bj_user']) || mb_strlen($record['bj_user']) > 20) {
             return false;
         }
     }
     if (isset($record['bj_memo'])) {
         if (!is_string($record['bj_memo']) || mb_strlen($record['bj_memo']) > 200) {
             return false;
         }
     }
     if (isset($record['bj_pid'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_pid']) || strlen($record['bj_pid']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_pynm'])) {
         if (!is_string($record['bj_pynm']) || mb_strlen($record['bj_pynm']) > 30) {
             return false;
         }
     }
     return true;
 }
コード例 #5
0
ファイル: Job.php プロジェクト: null-1/fangtaitong
 /**
  * getUndoJobIds
  * 
  * @param int $remainder
  * @param int $base
  * @param int $limit
  * @return array
  */
 public function getUndoJobIds($remainder, $base, $limit = 0)
 {
     if (!Zyon_Util::isUnsignedInt($remainder) || !Zyon_Util::isUnsignedInt($base) || !Zyon_Util::isUnsignedInt($limit)) {
         return false;
     }
     try {
         $sql = $this->dbase()->select()->from($this->tname('mail_job'), 'mj_id')->where('mj_sendtimes = 0 OR (mj_sendtimes < 3 && mj_ecode > 0)')->where('mj_id%' . $base . ' = ' . $remainder)->order('mj_id');
         $limit and $sql->limit($limit);
         return $this->dbase()->fetchCol($sql);
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
 }
コード例 #6
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));
 }
コード例 #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
ファイル: 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;
     }
 }
コード例 #9
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);
 }
コード例 #10
0
ファイル: Room.php プロジェクト: null-1/fangtaitong
 /**
  * getRoomIdsGroupWithTypeByDayAndHid
  * 
  * @param date $day
  * @param int  $hid
  * @return array {$type: $rids, ...}
  */
 public function getRoomIdsGroupWithTypeByDayAndHid($day, $hid)
 {
     if (!Zyon_Util::isDate($day) || !Zyon_Util::isUnsignedInt($hid)) {
         return false;
     }
     $dtm = strtotime($day) + 86399;
     try {
         $sql = $this->dbase()->select()->from($this->tname('room'), 'r_type, GROUP_CONCAT(r_id)')->where('r_hid = :hid')->where('r_otime <= :dtm')->group('r_type');
         return $this->dbase()->fetchPairs($sql, array('hid' => $hid, 'dtm' => $dtm));
     } catch (Exception $e) {
         $this->log($e);
         return false;
     }
 }
コード例 #11
0
ファイル: Hotel.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['h_attr']) && !$record['h_attr'] instanceof Zend_Db_Expr) {
         if (!Zyon_Util::isUnsignedInt($record['h_attr']) || strlen($record['h_attr']) > 10) {
             return false;
         }
     }
     if (isset($record['h_name'])) {
         if (!is_string($record['h_name']) || trim($record['h_name']) == '' || mb_strlen($record['h_name']) > 15) {
             return false;
         }
     }
     if (isset($record['h_note'])) {
         if (!is_string($record['h_note']) || mb_strlen($record['h_note']) > 500) {
             return false;
         }
     }
     if (isset($record['h_title'])) {
         if (!is_string($record['h_title']) || mb_strlen($record['h_title']) > 50) {
             return false;
         }
     }
     if (isset($record['h_iname'])) {
         if (!$this->isIname($record['h_iname'])) {
             return false;
         }
     }
     if (isset($record['h_email'])) {
         if (!Zyon_Util::isEmail($record['h_email']) || mb_strlen($record['h_email']) > 50) {
             return false;
         }
     }
     if (isset($record['h_phone'])) {
         if (!is_string($record['h_phone']) || !isset($record['h_phone'][5]) || mb_strlen($record['h_phone']) > 20) {
             return false;
         }
     }
     if (isset($record['h_domain'])) {
         if (!is_string($record['h_domain']) || mb_strlen($record['h_domain']) > 50) {
             return false;
         }
     }
     if (isset($record['h_website'])) {
         if (!is_string($record['h_website']) || mb_strlen($record['h_website']) > 50) {
             return false;
         }
     }
     if (isset($record['h_address'])) {
         if (!is_string($record['h_address']) || mb_strlen($record['h_address']) > 250) {
             return false;
         }
     }
     if (isset($record['h_country'])) {
         if (!is_string($record['h_country']) || mb_strlen($record['h_country']) > 50) {
             return false;
         }
     }
     if (isset($record['h_province'])) {
         if (!is_string($record['h_province']) || mb_strlen($record['h_province']) > 50) {
             return false;
         }
     }
     if (isset($record['h_city'])) {
         if (!is_string($record['h_city']) || mb_strlen($record['h_city']) > 50) {
             return false;
         }
     }
     if (isset($record['h_obill_default_settlem'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_obill_default_settlem']) || strlen($record['h_obill_default_settlem']) > 10) {
             return false;
         }
     }
     if (isset($record['h_order_default_typedef'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_order_default_typedef']) || strlen($record['h_order_default_typedef']) > 10) {
             return false;
         }
     }
     if (isset($record['h_order_default_channel'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_order_default_channel']) || strlen($record['h_order_default_channel']) > 10) {
             return false;
         }
     }
     if (isset($record['h_order_default_payment'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_order_default_payment']) || strlen($record['h_order_default_payment']) > 10) {
             return false;
         }
     }
     if (isset($record['h_order_default_stacode'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_order_default_stacode']) || strlen($record['h_order_default_stacode']) > 3) {
             return false;
         }
     }
     if (isset($record['h_order_enddays'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_order_enddays']) || strlen($record['h_order_enddays']) > 3 || $record['h_order_enddays'] > 450) {
             return false;
         }
     }
     if (isset($record['h_order_minlens'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_order_minlens']) || $record['h_order_minlens'] < 1 || strlen($record['h_order_minlens']) > 4) {
             return false;
         }
     }
     if (isset($record['h_order_maxlens'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_order_maxlens']) || $record['h_order_maxlens'] > 31) {
             return false;
         }
     }
     if (isset($record['h_obill_keptime'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_obill_keptime']) || strlen($record['h_obill_keptime']) > 10) {
             return false;
         }
     }
     if (isset($record['h_order_enabled']) && !$record['h_order_enabled'] instanceof Zend_Db_Expr) {
         if (!Zyon_Util::isUnsignedInt($record['h_order_enabled']) || $record['h_order_enabled'] > 3) {
             return false;
         }
     }
     if (isset($record['h_rosta_visible']) && !$record['h_rosta_visible'] instanceof Zend_Db_Expr) {
         if (!Zyon_Util::isUnsignedInt($record['h_rosta_visible']) || $record['h_rosta_visible'] > 3) {
             return false;
         }
     }
     if (isset($record['h_checkin_time'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_checkin_time']) || $record['h_checkin_time'] > 86399) {
             return false;
         }
     }
     if (isset($record['h_checkout_time'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_checkout_time']) || $record['h_checkout_time'] > 86399) {
             return false;
         }
     }
     if (isset($record['h_prompt_checkin'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_prompt_checkin']) || strlen($record['h_prompt_checkin']) > 10) {
             return false;
         }
     }
     if (isset($record['h_prompt_checkout'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_prompt_checkout']) || strlen($record['h_prompt_checkout']) > 10) {
             return false;
         }
     }
     if (isset($record['h_status'])) {
         if (!Zyon_Util::isUnsignedInt($record['h_status']) || strlen($record['h_status']) > 3) {
             return false;
         }
     }
     return true;
 }
コード例 #12
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);
 }
コード例 #13
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;
     }
 }
コード例 #14
0
ファイル: RoomController.php プロジェクト: null-1/fangtaitong
 /**
  * 批量创建价格计划
  */
 public function doCreatePricePlansAction()
 {
     $bdate = $this->input('bdate');
     $edate = $this->input('edate');
     $price = $this->input('price');
     if (!Zyon_Util::isDate($bdate) || !Zyon_Util::isDate($edate)) {
         $this->flash(0, '日期格式错误');
     }
     $btime = strtotime($bdate);
     $etime = strtotime($edate);
     if ($etime < $btime) {
         $this->flash(0, '结束日期不能早于起始日期');
     }
     if (!Zyon_Util::isMoneyFloat($price)) {
         $this->flash(0, '价格错误');
     }
     if ($price < 0) {
         $this->flash(0, '价格不能小于0');
     }
     $price = $price * 100;
     if ($price >= 10000000) {
         $this->flash(0, '价格超出系统限制范围,必须小于100000');
     }
     $rids = $this->input('rids', 'array');
     if (empty($rids)) {
         $this->flash(0, '没有选中任何房间');
     }
     foreach ($rids as &$val) {
         if (!Zyon_Util::isUnsignedInt($val)) {
             $this->flash(0, '指定的房间列表错误');
         }
     }
     unset($val);
     $rooms = $this->model('room')->getRoomAryByIds($rids);
     if (empty($rooms) || count($rooms) !== count($rids)) {
         $this->flash(0, '指定的房间列表错误');
     }
     $maps = array();
     foreach ($rooms as &$room) {
         if ($room['r_hid'] !== $this->_hostel['h_id']) {
             $this->flash(0, '指定的房间列表错误');
         }
         $maps[] = $this->model('room.price')->getNewPrice($room['r_hid'], $room['r_id'], $this->_master['u_id'], $this->_master['u_realname'], $price, $btime, $etime);
     }
     unset($room);
     if ($ret = $this->model('room.price')->addPriceAry($maps)) {
         $this->flash(1, "{$ret} 个房间已经应用新的价格计划");
     }
     $this->flash(0);
 }
コード例 #15
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;
     }
 }
コード例 #16
0
 /**
  * 变更订单操作(换房、移动)
  */
 public function doModifyAction()
 {
     $older = $this->loadUsableOrder($this->input('oid'));
     if ($this->input('key') !== $older['o_mtime']) {
         $this->flash(0, '表单已过期,请刷新重试');
     }
     if ($this->input('sta', 'numeric') !== $older['o_status']) {
         $this->flash(0, '订单状态错误或者有冲突');
     }
     $ctime = $_SERVER['REQUEST_TIME'];
     $dtime = strtotime(date('Y-m-d', $ctime));
     if ($older['o_edatm'] <= $dtime || !($older['o_attr'] & (int) ORDER_ATTR_YXHF) || $older['o_status'] === ORDER_STATUS_YQX || $older['o_status'] === ORDER_STATUS_YJS) {
         $this->flash(0, '指定的订单不可以换房');
     }
     $order = $this->input('order', 'array');
     if (empty($order)) {
         $this->flash(0, '没有选择需更换的房间');
     }
     $price = $this->input('price', 'array');
     if (empty($price)) {
         $this->flash(0, '没有指定成交房费明细');
     }
     $brice = $this->input('brice', 'array');
     if (empty($brice)) {
         $this->flash(0, '没有指定账单房费明细');
     }
     $osize = count($order);
     if ($osize !== count($price) || $osize !== count($brice)) {
         $this->flash(0, '订单和房费明细不匹配');
     }
     $obval = json_decode($older['o_brices'], true);
     $opval = json_decode($older['o_prices'], true);
     $obill = $this->loadUsableBill($older['o_bid']);
     if (isset($obill['b_status']) && $obill['b_status'] !== BILL_STATUS_KF) {
         $this->flash(0, '账单已关闭,不允许新的订单与其关联');
     }
     $oroom = $this->loadUsableRoom($older['o_rid']);
     $ostat = $older['o_status'] == ORDER_STATUS_YD ? ORDER_STATUS_YD : ORDER_STATUS_BL;
     // 以下处理订单集合
     $newid = 0;
     $order = array_values($order);
     $other_order_conds = array();
     foreach ($order as $idx => &$val) {
         if (!is_array($val) || !isset($val['room']) || !isset($val['date']) || !isset($val['lgth']) || !Zyon_Util::isUnsignedInt($val['room']) || !Zyon_Util::isDate($val['date']) || !Zyon_Util::isUnsignedInt($val['lgth']) || $val['room'] < 1 || $val['lgth'] < 1 || !isset($price[$idx]) || !is_array($price[$idx]) || !isset($brice[$idx]) || !is_array($brice[$idx])) {
             $this->flash(0, '参数错误');
         }
         if ($val['room'] == $older['o_rid']) {
             $this->flash(0, '调换的房间和当前房间相同');
         }
         $val['date'] = array($val['date'], date('Y-m-d', strtotime($val['date']) + $val['lgth'] * 86400));
         $val['datm'] = array(strtotime($val['date'][0]), strtotime($val['date'][1]));
         if ($val['datm'][0] < $dtime) {
             $this->flash(0, '调房的间夜不能在今天之前');
         }
         $oldot = $val['datm'][0];
         while ($oldot < $val['datm'][1]) {
             if (!isset($obval[$oldot]) || !isset($opval[$oldot])) {
                 $this->flash(0, '目标订单间夜重叠或者超出原订单范围');
             }
             unset($obval[$oldot], $opval[$oldot]);
             $oldot += 86400;
         }
         if ($val['lgth'] < $this->_hostel['h_order_minlens'] || $val['lgth'] > $this->_hostel['h_order_maxlens']) {
             $this->flash(0, __('旅店仅支持创建天数介于 %d 到 %d 的订单', $this->_hostel['h_order_minlens'], $this->_hostel['h_order_maxlens']));
         }
         $val['pval'] = $this->fetchOrderPrice($price[$idx], $val['date'][0], $val['date'][1]);
         $val['bval'] = $this->fetchOrderPrice($brice[$idx], $val['date'][0], $val['date'][1]);
         $val['time'][0] = max($val['datm'][0] + $this->_hostel['h_checkin_time'], $older['o_btime']);
         $val['time'][1] = min($val['datm'][1] + $this->_hostel['h_checkout_time'], $older['o_etime']);
         $other_order_conds[] = sprintf('(o_rid = %d AND o_bdatm <= %d AND o_edatm >= %d)', $val['room'], $val['datm'][1], $val['datm'][0]);
         if ($val['datm'][0] < $order[$newid]['datm'][0]) {
             $newid = $idx;
         }
     }
     unset($val);
     $other_order_conds = implode(' OR ', $other_order_conds);
     if (!empty($obval)) {
         // 有剩余订单间夜,构造新的订单
         $datms = array_keys($obval);
         for ($idx = 0, $len = count($datms); $idx < $len; $idx++) {
             $oitem = array('room' => $older['o_rid'], 'lgth' => 1, 'datm' => array($datms[$idx]), 'date' => array(), 'time' => array(), 'pval' => array($datms[$idx] => $opval[$datms[$idx]]), 'bval' => array($datms[$idx] => $obval[$datms[$idx]]));
             while ($idx + 1 < $len && $datms[$idx] + 86400 == $datms[$idx + 1]) {
                 $idx++;
                 $oitem['lgth']++;
                 $oitem['pval'][$datms[$idx]] = $opval[$datms[$idx]];
                 $oitem['bval'][$datms[$idx]] = $obval[$datms[$idx]];
             }
             $oitem['datm'][1] = $oitem['datm'][0] + $oitem['lgth'] * 86400;
             $oitem['date'][0] = date('Y-m-d', $oitem['datm'][0]);
             $oitem['date'][1] = date('Y-m-d', $oitem['datm'][1]);
             $oitem['time'][0] = max($oitem['datm'][0] + $this->_hostel['h_checkin_time'], $older['o_btime']);
             $oitem['time'][1] = min($oitem['datm'][1] + $this->_hostel['h_checkout_time'], $older['o_etime']);
             if ($oitem['lgth'] < $this->_hostel['h_order_minlens']) {
                 $this->flash(0, __('旅店仅支持创建天数介于 %d 到 %d 的订单', $this->_hostel['h_order_minlens'], $this->_hostel['h_order_maxlens']));
             }
             $order[$osize] = $oitem;
             if ($oitem['datm'][0] <= $order[$newid]['datm'][0]) {
                 $newid = $osize;
             }
             ++$osize;
         }
     }
     $oitem = $order[$newid];
     $order = Zyon_Array::group($order, 'room');
     $rooms = Zyon_Array::keyto($this->model('room')->getRoomAryByIds(array_keys($order)), 'r_id');
     if (empty($rooms) || count($rooms) !== count($order)) {
         $this->flash(0, '找不到指定预订的房间');
     }
     // 以下处理每个房间的停用段以及订单最长时间限制
     foreach ($rooms as $rid => &$val) {
         if ($val['r_hid'] !== $this->_hostel['h_id']) {
             $this->flash(0, '找不到指定预订的房间');
         }
         foreach ($order[$rid] as &$v) {
             $btime = $v['datm'][0];
             $etime = $v['datm'][1] - 1;
             if ($btime < $val['r_otime']) {
                 $this->flash(0, __('房间%s在%s之前尚未启用', $val['r_name'], date('Y-m-d', $val['r_otime'])));
             }
             for ($_btime = max($btime, $dtime + 86400 * $this->_hostel['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']));
                 }
             }
         }
         unset($v);
     }
     unset($val);
     // 加入原订单房间至房间集合
     $rooms[$oroom['r_id']] = $oroom;
     // 以下处理订单集合内的冲突
     foreach ($order as &$val) {
         foreach ($val as $k => &$v) {
             foreach ($val as $i => &$o) {
                 if ($k !== $i && $k['time'][0] < $o['time'][1] && $k['time'][1] > $o['time'][0]) {
                     $this->flash(0, __('房间%s的订单时间冲突,不能同时创建', $rooms[$v['room']]['r_name']));
                 }
             }
             unset($o);
         }
         unset($v);
     }
     unset($val);
     // 以下处理与系统订单的冲突
     $other = $this->model('order')->getOrderAryByIds($this->model('order')->fetchIds(array('o_hid = ' . $this->_hostel['h_id'], 'o_id <> ' . $older['o_id'], 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YQX), 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YD), $other_order_conds)));
     if (!is_array($other)) {
         $this->flash(0, '无法获取系统订单的信息');
     }
     if (!empty($other)) {
         foreach ($other as &$val) {
             $rid = $val['o_rid'];
             foreach ($order[$rid] as &$v) {
                 if ($val['o_edatm'] == $v['datm'][0]) {
                     $v['time'][0] = max($v['time'][0], $val['o_etime']);
                 }
                 if ($val['o_bdatm'] == $v['datm'][1]) {
                     $v['time'][1] = min($v['time'][1], $val['o_btime']);
                 }
                 $_o_btime = max($v['datm'][0], $val['o_bdatm']);
                 $_o_etime = min($v['datm'][1], $val['o_edatm']);
                 while ($_o_btime < $_o_etime) {
                     $this->flash(0, __('%s的房间%s已被其它订单占用', date('Y-m-d', $_o_btime), $rooms[$rid]['r_name']));
                 }
             }
             unset($v);
         }
         unset($val);
     }
     unset($other);
     // 从新订单中移除最靠近原订单入住时间的订单,以更改原订单时间实现
     $oitem = $order[$oitem['room']][$newid];
     unset($order[$oitem['room']][$newid]);
     --$osize;
     /**
      * 开启事务,创建订单
      */
     $this->model('order')->dbase()->beginTransaction();
     try {
         $bvsum = array_sum($oitem['bval']);
         $pvsum = array_sum($oitem['pval']);
         // 缩短或者取消原订单,更新账单房费
         if (!$this->model('order')->modOrder($older['o_id'], array('o_rid' => $oitem['room'], 'o_room' => $rooms[$oitem['room']]['r_name'], 'o_bdatm' => $oitem['datm'][0], 'o_edatm' => $oitem['datm'][1], 'o_btime' => $oitem['time'][0], 'o_etime' => $oitem['time'][1], 'o_brice' => $bvsum, 'o_price' => $pvsum, 'o_brices' => json_encode($oitem['bval']), 'o_prices' => json_encode($oitem['pval'])))) {
             throw new exception('更新原订单失败');
         }
         if ($bvsum != $older['o_brice']) {
             if (!$this->model('bill')->modBill($older['o_bid'], array('b_cost' => $this->model('bill')->expr('b_cost + ' . ($bvsum - $older['o_brice']))))) {
                 throw new exception('更新账单信息失败');
             }
             $bill_old = $obill;
             if (!($obill = $this->model('bill')->getBill($older['o_bid']))) {
                 throw new exception('读取账单信息失败');
             }
             $this->model('log.bill')->addLog($this->model('log.bill')->getNewUpdateLog($this->_master, $bill_old, $obill, __('%d号订单房费 %d=>%d', $older['o_id'], $older['o_brice'] / 100, $bvsum / 100)));
         }
         $this->model('log.order')->addLog($this->model('log.order')->getNewUpdateLog($this->_master, $older, $older_new = $this->model('order')->getOrder($older['o_id']), __("房费明细\n[预计入住 %s=>%s, 间夜 %d=>%d, 成交房费 %d=>%d, 账单房费 %d=>%d]", date('Y-m-d H:i', $older['o_btime']), date('Y-m-d H:i', $oitem['time'][0]), ($older['o_edatm'] - $older['o_bdatm']) / 86400, ($oitem['datm'][1] - $oitem['datm'][0]) / 86400, $older['o_price'] / 100, $pvsum / 100, $older['o_brice'] / 100, $bvsum / 100)));
         // 如果原订单在住且更换房间,则更新房间状态
         if ($older['o_rid'] != $oitem['room']) {
             $this->model('log.order')->addLog($this->model('log.order')->getNewChangeRoomLog($this->_master, $older, $this->model('order')->getOrder($older['o_id'])));
             if ($older['o_status'] == ORDER_STATUS_ZZ) {
                 if ($rooms[$oitem['room']]['r_status'] != ROOM_STATUS_GJKF) {
                     throw new exception('入住的目标房间状态不是干净空房');
                 }
                 if (!$this->model('room')->modRoom($older['o_rid'], array('r_status' => ROOM_STATUS_GJKF)) || !$this->model('room')->modRoom($oitem['room'], array('r_status' => $rooms[$older['o_rid']]['r_status']))) {
                     throw new exception('更新房间状态失败');
                 }
                 $this->model('log.room')->addLog($this->model('log.room')->getNewUpdateStatusLog($this->_master, $rooms[$older['o_rid']], $this->model('room')->getRoom($older['o_rid'])));
                 $this->model('log.room')->addLog($this->model('log.room')->getNewUpdateStatusLog($this->_master, $rooms[$oitem['room']], $this->model('room')->getRoom($oitem['room'])));
             }
         }
         if ($osize > 0) {
             // 获取原订单中的客人有效信息
             $guest = array();
             $guest['o_gbker_name'] = (string) $older['o_gbker_name'];
             $guest['o_gbker_phone'] = (string) $older['o_gbker_phone'];
             $guest['o_gbker_idtype'] = (string) $older['o_gbker_idtype'];
             $older['o_gbker_idno'] == '' or $guest['o_gbker_idno'] = $older['o_gbker_idno'];
             $older['o_gbker_email'] == '' or $guest['o_gbker_email'] = $older['o_gbker_email'];
             $guest['o_glver_name'] = (string) $older['o_glver_name'];
             $guest['o_glver_phone'] = (string) $older['o_glver_phone'];
             $guest['o_glver_idtype'] = (string) $older['o_glver_idtype'];
             $older['o_glver_idno'] == '' or $guest['o_glver_idno'] = $older['o_glver_idno'];
             $older['o_glver_email'] == '' or $guest['o_glver_email'] = $older['o_glver_email'];
             $obval = array();
             foreach (array_keys($order) as $rid) {
                 foreach ($order[$rid] as &$val) {
                     $map = $this->model('order')->getNewOrder($rooms[$rid], $val['time'][0], $val['time'][1], json_encode($val['pval']), json_encode($val['bval']), $ostat);
                     $map['o_bid'] = $older['o_bid'];
                     $map['o_sid'] = $older['o_sid'];
                     $map['o_snm'] = $older['o_snm'];
                     $map['o_cid'] = $older['o_cid'];
                     $map['o_cnm'] = $older['o_cnm'];
                     $map['o_tid'] = $older['o_tid'];
                     $map['o_tnm'] = $older['o_tnm'];
                     $map['o_attr'] = $older['o_attr'];
                     $map['o_memo'] = (string) $older['o_memo'];
                     // 加入旅客信息
                     $map = array_merge($guest, $map);
                     $oid = $this->model('order')->addOrder($map);
                     if (!$oid) {
                         throw new exception('创建订单记录失败');
                     }
                     if ($map = $this->model('order')->getOrder($oid)) {
                         $this->model('log.order')->addLog($this->model('log.order')->getNewCreateLog($this->_master, $map));
                     }
                     $obval[$oid] = $map['o_brice'];
                 }
                 unset($val);
             }
             if (!$this->model('bill')->modBill($obill['b_id'], array('b_cost' => $this->model('bill')->expr('b_cost + ' . array_sum($obval))))) {
                 throw new exception('更新账单信息失败');
             }
             foreach ($obval as $idx => $val) {
                 $obval[$idx] = __('%d号订单的账单房费 %d', $idx, $val / 100);
             }
             $this->model('log.bill')->addLog($this->model('log.bill')->getNewUpdateLog($this->_master, $obill, $this->model('bill')->getBill($obill['b_id']), implode(",\n", $obval)));
         }
         $this->model('order')->dbase()->commit();
         $this->flash(1, array('forward' => "/master/bill/detail?bid={$obill['b_id']}"));
     } catch (Exception $e) {
         $this->model('order')->dbase()->rollBack();
         $this->error($e);
     }
     $this->flash(0);
 }
コード例 #17
0
ファイル: User.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['u_hid'])) {
         if (!Zyon_Util::isUnsignedInt($record['u_hid']) || empty($record['u_hid']) || strlen($record['u_hid']) > 10) {
             return false;
         }
     }
     if (isset($record['u_sign'])) {
         if (!is_string($record['u_sign']) || trim($record['u_sign']) == '' || mb_strlen($record['u_sign']) > 100) {
             return false;
         }
     }
     if (isset($record['u_pswd'])) {
         if (!is_string($record['u_pswd']) || trim($record['u_pswd']) == '' || mb_strlen($record['u_pswd']) > 32) {
             return false;
         }
     }
     if (isset($record['u_salt'])) {
         if (!is_string($record['u_salt']) || trim($record['u_salt']) == '') {
             return false;
         }
     }
     if (isset($record['u_role'])) {
         if (!Zyon_Util::isUnsignedInt($record['u_role']) || strlen($record['u_role']) > 3) {
             return false;
         }
     }
     if (isset($record['u_email'])) {
         if (!Zyon_Util::isEmail($record['u_email']) || mb_strlen($record['u_email']) > 100) {
             return false;
         }
     }
     if (isset($record['u_phone'])) {
         if (!is_string($record['u_phone']) || mb_strlen($record['u_phone']) > 20) {
             return false;
         }
     }
     if (isset($record['u_realname'])) {
         if (!is_string($record['u_realname']) || trim($record['u_realname']) == '' || mb_strlen($record['u_realname']) > 20) {
             return false;
         }
     }
     if (isset($record['u_nickname'])) {
         if (!is_string($record['u_nickname']) || mb_strlen($record['u_nickname']) > 20) {
             return false;
         }
     }
     if (isset($record['u_rolename'])) {
         if (!is_string($record['u_rolename']) || mb_strlen($record['u_rolename']) > 20) {
             return false;
         }
     }
     if (isset($record['u_permit'])) {
         if (!Zyon_Util::isUnsignedInt($record['u_permit']) || strlen($record['u_permit']) > 10) {
             return false;
         }
     }
     if (isset($record['u_status'])) {
         if (!Zyon_Util::isUnsignedInt($record['u_status']) || strlen($record['u_status']) > 3) {
             return false;
         }
     }
     if (isset($record['u_active']) && !$record['u_active'] instanceof Zend_Db_Expr) {
         if (!Zyon_Util::isUnsignedInt($record['u_active']) || strlen($record['u_active']) > 3) {
             return false;
         }
     }
     if (isset($record['u_gender'])) {
         if (!Zyon_Util::isUnsignedInt($record['u_gender']) || strlen($record['u_gender']) > 3) {
             return false;
         }
     }
     if (isset($record['u_idtype'])) {
         if (!Zyon_Util::isUnsignedInt($record['u_idtype']) || strlen($record['u_idtype']) > 3) {
             return false;
         }
     }
     if (isset($record['u_idno'])) {
         if (!is_string($record['u_idno']) || mb_strlen($record['u_idno']) > 30) {
             return false;
         }
     }
     return true;
 }
コード例 #18
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;
     }
 }
コード例 #19
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;
 }