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)); }
/** * 更新预订状态的订单 */ public function doUpdateYD($order) { switch ($this->input('tab')) { case 'hfsx': if (!$this->hasUserPerm('/master/order/do-update-attr-yxhf')) { $this->flash(0, '没有更改该属性的权限'); } if ($this->model('order')->modOrder($order['o_id'], array('o_attr' => $this->model('order')->expr('o_attr ^ ' . ORDER_ATTR_YXHF)))) { $this->model('log.order')->addLog($this->model('log.order')->getNewUpdateLog($this->_master, $order, $this->model('order')->getOrder($order['o_id']), __('更改订单%s属性', getOrderAttrNameByCode(ORDER_ATTR_YXHF)))); $this->flash(1); } break; case 'jbxx': if ($order['o_memo'] === $this->input('memo')) { $this->flash(1); } if ($this->model('order')->modOrder($order['o_id'], array('o_memo' => $this->input('memo')))) { $this->model('log.order')->addLog($this->model('log.order')->getNewUpdateLog($this->_master, $order, $this->model('order')->getOrder($order['o_id']), __('基本信息'))); $this->flash(1); } break; case 'ffmx': if (!$this->hasUserPerm('/master/order/do-update-info-fxmx')) { $this->flash(0, '没有权限'); } $bdate = $this->input('bdate'); $bhour = $this->input('bhour', 'numeric'); $bminu = $this->input('bminu', 'numeric'); isset($bhour[1]) or $bhour = '0' . $bhour; isset($bminu[1]) or $bminu = '0' . $bminu; $edate = $this->input('edate'); $ehour = $this->input('ehour', 'numeric'); $eminu = $this->input('eminu', 'numeric'); isset($ehour[1]) or $ehour = '0' . $ehour; isset($eminu[1]) or $eminu = '0' . $eminu; if (!Zyon_Util::isDate($bdate) || !Zyon_Util::isDate($edate) || !Zyon_Util::isTime($bhour . ':' . $bminu) || !Zyon_Util::isTime($ehour . ':' . $eminu)) { $this->flash(0, '预订时间格式错误'); } $bdatm = strtotime($bdate); $edatm = strtotime($edate); $btime = $bdatm + Zyon_Util::timeToSecs($bhour . ':' . $bminu); $etime = $edatm + Zyon_Util::timeToSecs($ehour . ':' . $eminu); if ($edatm <= $bdatm) { $this->flash(0, '离店日期必须晚于入住日期'); } if ($edatm < strtotime(date('Y-m-d', $order['o_ctime']))) { $this->flash(0, '离店日期不能在订单创建日期之前'); } if (($edatm - $bdatm) / 86400 < $this->_hostel['h_order_minlens'] || ($edatm - $bdatm) / 86400 > $this->_hostel['h_order_maxlens']) { $this->flash(0, __('旅店仅支持天数介于 %d 到 %d 的订单', $this->_hostel['h_order_minlens'], $this->_hostel['h_order_maxlens'])); } for ($_btime = max($bdatm, strtotime(date('Y-m-d')) + 86400 * $this->_hostel['h_order_enddays']); $_btime < $etime; $_btime += 86400) { $this->flash(0, __('%s 超出旅店允许建立最多%d天内的订单规则', date('Y-m-d', $_btime), $this->_hostel['h_order_enddays'])); } $oroom = $this->loadUsableRoom($order['o_rid']); $flash = array(); if ($etime > $order['o_etime'] || $btime < $order['o_btime']) { if ($oroom['r_btime']) { $_r_btime = max($bdatm, $oroom['r_btime']); $_r_etime = min($edatm - 1, $oroom['r_etime']); while ($_r_btime < $_r_etime) { $flash[] = __('%s 该房间已被停用', date('Y-m-d', $_r_btime)); $_r_btime += 86400; } } $other = Zyon_Array::keyto($this->model('order')->getOrderAryByIds($this->model('order')->fetchIds(array('o_id <> ' . (int) $order['o_id'], 'o_hid = ' . (int) $order['o_hid'], 'o_rid = ' . (int) $order['o_rid'], 'o_status <> ' . (int) ORDER_STATUS_YQX, 'o_status <> ' . (int) ORDER_STATUS_YD, 'o_bdatm <= ' . (int) $edatm, 'o_edatm >= ' . (int) $bdatm))), 'o_id'); if (!empty($other)) { foreach ($other as $other) { if ($other['o_edatm'] == $bdatm && $other['o_etime'] > $btime) { $flash[] = __('%s 该房间已被其它订单占用', date('Y-m-d H:i', $btime)); } if ($other['o_bdatm'] == $edatm && $other['o_btime'] < $etime) { $flash[] = __('%s 该房间已被其它订单占用', date('Y-m-d H:i', $etime)); } $_o_btime = max($bdatm, $other['o_bdatm']); $_o_etime = min($edatm, $other['o_edatm']); while ($_o_btime < $_o_etime) { $flash[] = __('%s 该房间已被其它订单占用', date('Y-m-d', $_o_btime)); $_o_btime += 86400; } } unset($other); } } if (!empty($flash)) { $this->flash(0, array('content' => $flash)); } $price_array = $this->fetchOrderPrice($this->input('price', 'array'), $bdate, $edate); $brice_array = $this->fetchOrderPrice($this->input('brice', 'array'), $bdate, $edate); if (!$this->model('order')->chkCanUpdateOrder($this->_hostel, $oroom, $order, $btime, $etime)) { $this->flash(0, '无法更新订单至指定时间段'); } /** * 开启事务,更新订单 */ $this->model('order')->dbase()->beginTransaction(); try { $price = array_sum($price_array); $brice = array_sum($brice_array); if ((int) $order['o_brice'] !== $brice) { $bill_old = $this->loadUsableBill($order['o_bid']); if (!$this->model('bill')->modBill($order['o_bid'], array('b_cost' => $this->model('bill')->expr('b_cost + ' . ($brice - $order['o_brice']))))) { throw new exception('更新账单信息失败'); } if ($bill = $this->model('bill')->getBill($order['o_bid'])) { $this->model('log.bill')->addLog($this->model('log.bill')->getNewUpdateLog($this->_master, $bill_old, $bill, __('%d号订单房费 %d=>%d', $order['o_id'], $order['o_brice'] / 100, $brice / 100))); } } if (!$this->model('order')->modOrder($order['o_id'], array('o_btime' => $btime, 'o_etime' => $etime, 'o_price' => $price, 'o_brice' => $brice, 'o_prices' => json_encode($price_array), 'o_brices' => json_encode($brice_array)))) { throw new exception('更新房费明细失败'); } $this->model('order')->dbase()->commit(); $this->model('log.order')->addLog($this->model('log.order')->getNewUpdateLog($this->_master, $order, $this->model('order')->getOrder($order['o_id']), __("房费明细\n[预计入住 %s=>%s, 间夜 %d=>%d, 成交房费 %d=>%d, 账单房费 %d=>%d]", date('Y-m-d H:i', $order['o_btime']), date('Y-m-d H:i', $btime), ($order['o_edatm'] - $order['o_bdatm']) / 86400, ($edatm - $bdatm) / 86400, $order['o_price'] / 100, $price / 100, $order['o_brice'] / 100, $brice / 100))); } catch (Exception $e) { $this->model('order')->dbase()->rollBack(); $this->error($e); $this->flash(0); } $this->flash(1); break; case 'krxx': $gbker = $this->fetchOrderGuest($this->input('gbker', 'array'), HOTEL_GUEST_TYPE_BOOK); $glver = $this->fetchOrderGuest($this->input('glver', 'array'), HOTEL_GUEST_TYPE_LIVE); if ($this->model('order')->modOrder($order['o_id'], array_merge($gbker, $glver))) { $this->model('log.order')->addLog($this->model('log.order')->getNewUpdateGuestLog($this->_master, $order, $this->model('order')->getOrder($order['o_id']))); $this->flash(1); } break; default: $this->flash(0); break; } }
/** * 执行操作:过期时间 */ public function doActionGqsj($bill) { $gqsj = $this->input('gqsj', 'numeric'); if ($gqsj) { $date = $this->input('date'); $hour = $this->input('hour', 'numeric'); $minu = $this->input('minu', 'numeric'); isset($hour[1]) or $hour = '0' . $hour; isset($minu[1]) or $minu = '0' . $minu; if (!Zyon_Util::isDate($date) || !Zyon_Util::isTime($hour . ':' . $minu)) { $this->flash(0, '过期时间格式错误'); } $time = strtotime($date . ' ' . $hour . ':' . $minu); if ($time < $bill['b_ctime'] - 59) { $this->flash(0, __('过期时间不能早于账单创建时间%s', date('Y-m-d H:i', $bill['b_ctime']))); } } else { if (!($bill['b_attr'] & (int) BILL_ATTR_GQTX)) { $this->flash(0, '没有变更'); } $time = $bill['b_ltime']; } if ($this->model('bill')->modBill($bill['b_id'], array('b_attr' => $this->model('bill')->expr($gqsj ? 'b_attr | ' . BILL_ATTR_GQTX : 'b_attr & ' . ~(int) BILL_ATTR_GQTX), 'b_ltime' => $time))) { if ($bill_new = $this->model('bill')->getBill($bill['b_id'])) { $memo = $gqsj ? $bill['b_attr'] & (int) BILL_ATTR_GQTX && is_numeric($bill['b_ltime']) ? __('过期时间:%s=>%s', date('Y-m-d H:i', $bill['b_ltime']), date('Y-m-d H:i', $bill_new['b_ltime'])) : __('过期时间:%s', date('Y-m-d H:i', $bill_new['b_ltime'])) : '取消账单过期时间设定'; $this->model('log.bill')->addLog($this->model('log.bill')->getNewUpdateLog($this->_master, $bill, $bill_new, $memo)); } $this->flash(1, '修改账单过期时间成功'); } }