예제 #1
0
 /**
  * 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);
 }
예제 #2
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;
 }
예제 #3
0
 /**
  * 批量创建价格计划
  */
 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);
 }