本文整理匯總了PHP中DateUtil::buildDateTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateUtil::buildDateTime方法的具體用法?PHP DateUtil::buildDateTime怎麽用?PHP DateUtil::buildDateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DateUtil
的用法示例。
在下文中一共展示了DateUtil::buildDateTime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: number_format
">
</a>
<a>
<h3 class="F14 FN"><?php
echo $order['project_name'];
?>
</h3>
</a>
<p>門店:<span class="F11"><?php
echo $shop;
?>
</span></p>
<strong
class="FN colorH">預約時間: <?php
echo DateUtil::buildDateTime($order['appointment_day'], $order['appointment_start_time']);
?>
</strong>
<strong class="add FN colorH">美容師:<?php
echo $order['beautician_name'];
?>
</strong>
<i class="order_list_i"> </i>
</div>
</dt>
<dd>
<a class="colorW pay-click">馬上支付</a>
<i class="colorH">總金額:<strong
class="F18 colorR">¥<?php
echo number_format($order['total_fee'], 2);
?>
示例2: notice
/**
* 微信支付後的異步回調
*/
public function notice()
{
$weixin = new WeixinPayUtil();
//通知微信
$notice = $weixin->notifyData();
// 簽名成功, 返回數組, 否則返回xml數據
if (!is_array($notice) || !isset($notice['transaction_id'])) {
exit($notice);
}
//簽名成功,處理數據
/**
* 返回的數據
* 'appid' => string 'wxf5b5e87a6a0fde94' (length=18)
* 'bank_type' => string 'CFT' (length=3)
* 'fee_type' => string 'CNY' (length=3)
* 'is_subscribe' => string 'N' (length=1)
* 'mch_id' => string '10000097' (length=8)
* 'nonce_str' => string 'dz8nirk7gmxhhxn38zgib28yx14ul2gf' (length=32)
* 'openid' => string 'ozoKAt-MmA74zs7MBafCix6Dg8o0' (length=28)
* 'out_trade_no' => string 'wxf5b5e87a6a0fde941409708791' (length=28)
* 'result_code' => string 'SUCCESS' (length=7)
* 'return_code' => string 'SUCCESS' (length=7)
* 'sign' => string 'EDACA525F6C675337B2DAC25B7145028' (length=32)
* 'sub_mch_id' => string '10000097' (length=8)
* 'time_end' => string '20140903094659' (length=14)
* 'total_fee' => string '1' (length=1)
* 'trade_type' => string 'NATIVE' (length=6)
* 'transaction_id' => string '1004400737201409030005091526' (length=28) //微信支付單號
*/
// $notice = array(
// 'out_trade_no' => '201512271710391206225994',
// 'transaction_id' => '1004400737201409030005091526'
// );
$orderNo = $notice['out_trade_no'];
$wxOrderNo = $notice['transaction_id'];
$openId = $notice['openid'];
$orderModel = new OrderModel();
// 獲得訂單
$orders = $orderModel->orders(array('order_no' => $orderNo));
if (!$orders || !$orders[0]) {
exit($weixin->notifyFailure());
}
// 判斷是否已經支付
$order = $orders[0];
if ($order['order_sign'] == OrderModel::ORDER_PAYED) {
exit($weixin->notifyPayed());
}
// 更新訂單信息
$this->db->trans_start();
$orderModel->payed($orderNo, $wxOrderNo);
// 更新積分
$customerModel = new CustomerModel();
$score = $order['total_fee'];
$customer = $customerModel->readOne($openId);
if ($customer) {
$customerModel->addCredits($openId, $score);
}
// 事物完成
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
exit($weixin->notifyFailure());
} else {
$this->db->trans_commit();
// 獲得access token
$weixinUtil = new WeixinUtil();
$token = $weixinUtil->getToken();
if ($token) {
//foreach ($orders as $order) {
$orderNo = $order['order_no'];
$appointmentDay = DateUtil::buildDateTime($order['appointment_day'], $order['appointment_start_time']);
$shops = (new ShopModel())->getAllShops();
$shop = $shops[$order['shop_id']];
$beautician = (new BeauticianModel())->readOne($order['beautician_id']);
$beauticianName = $beautician['name'];
$project = (new CurdUtil(new OrderProjectModel()))->readOne(array('order_id' => $order['order_id']));
$projectName = $project['project_name'];
// 計算總積分
$totalCredits = $customer['credits'] + $score;
// 發送模板消息
// $orderNo, $appointmentDay, $shop, $beautician, $projectName
$weixinUtil->sendOrderMessage($orderNo, $appointmentDay, $shop, $beauticianName, $projectName, $openId, $token, $totalCredits);
//}
}
exit($weixin->notifySuccess());
}
}
示例3: appointment
public function appointment()
{
$params = RequestUtil::postParams();
$userName = urldecode($params['user_name']);
if (empty($userName)) {
$this->message('聯係人不能為空!');
}
$phoneNumber = $params['phone_number'];
if (empty($phoneNumber)) {
$this->message('手機號不能為空!');
}
$appointmentDay = $params['appointment_day'];
$appointmentTime = $params['appointment_times'];
$today = date('Y-m-d');
if ($appointmentDay < $today) {
$this->message('錯誤的預約日期!');
}
// 檢查時間
$appointmentTime = explode(',', urldecode($appointmentTime));
if (!$appointmentTime || count($appointmentTime) < 1) {
$this->message('錯誤的預約時間!');
}
// 隻有30分鍾的項目
if (count($appointmentTime) == 1) {
array_push($appointmentTime, $appointmentTime[0]);
}
// 隻保留頭和尾的兩個數據
$startTime = array_shift($appointmentTime);
$endTime = array_pop($appointmentTime);
if ($endTime < $startTime) {
$this->message('錯誤的預約時間!');
}
// 預約時間是否小於當前時間
$now = date('Y-m-d H:i');
if (DateUtil::buildDateTime($appointmentDay, $startTime) < $now) {
$this->message('錯誤的預約開始時間!');
}
if (DateUtil::buildDateTime($appointmentDay, $endTime) < $now) {
$this->message('錯誤的預約結束時間!');
}
$beauticianId = $params['beautician_id'];
// 判斷相同的時間是否已經被預約
$findHasPayedAppointTimeWhere = array('appointment_day' => $appointmentDay, 'appointment_start_time' => $startTime, 'order_status' => OrderModel::ORDER_PAYED, 'beautician_id' => $beauticianId);
$findOrder = (new CurdUtil(new OrderModel()))->readOne($findHasPayedAppointTimeWhere);
if ($findOrder) {
$this->message('此時間段已被預約!');
}
unset($findOrder);
$findHasPayedAppointTimeWhere['order_status'] = OfflineOrderModel::ORDER_WAIT;
$findOrder = (new CurdUtil(new OfflineOrderModel()))->readOne($findHasPayedAppointTimeWhere);
if ($findOrder) {
$this->message('此時間段已被預約!');
}
// 沒有問題
$data = array('project_id' => $params['project_id'], 'project_name' => $params['project_name'], 'use_time' => $params['use_time'], 'shop_id' => $params['shop_id'], 'beautician_id' => $beauticianId, 'appointment_day' => $appointmentDay, 'appointment_start_time' => $startTime, 'appointment_end_time' => $endTime, 'user_name' => $userName, 'phone_number' => $phoneNumber, 'create_time' => DateUtil::now());
if ((new CurdUtil(new OfflineOrderModel()))->create($data)) {
$this->message('線下預約成功!', 'offlineOrder/index');
} else {
$this->message('線下預約失敗!');
}
}
示例4: order
/**
* 下單
* @param $shopId
* @param $beauticianId
* @param $appointmentDay
* @param $appointmentTime
* @param $userName
* @param $phoneNumber
*/
public function order($shopId, $beauticianId, $appointmentDay, $appointmentTime, $userName, $phoneNumber)
{
$openId = (new WeixinUtil())->getOpenId();
if (!$openId) {
$this->message('錯誤的授權');
}
if (!(new ShopModel())->isValidShopId($shopId)) {
$this->message('門店信息錯誤,請檢查!');
}
// 檢查美容師
if (!(new BeauticianModel())->isValidBeautician($beauticianId)) {
$this->message('美容師信息錯誤,請檢查!');
}
$userName = urldecode($userName);
// 檢查用戶
$userName = trim(strip_tags($userName));
if (empty($userName)) {
$this->message('聯係人不能為空,請檢查!');
}
if (!preg_match('~^1\\d{10}$~', $phoneNumber)) {
$this->message('手機號錯誤,請檢查!');
}
// 檢查日期,日期為今天或者以後
$today = date('Y-m-d');
if ($appointmentDay < $today) {
$this->message('錯誤的預約日期!');
}
// 檢查時間
$appointmentTime = explode(',', urldecode($appointmentTime));
if (!$appointmentTime || count($appointmentTime) < 1) {
$this->message('錯誤的預約時間!');
}
// 隻有30分鍾的項目
if (count($appointmentTime) == 1) {
array_push($appointmentTime, $appointmentTime[0]);
}
// 隻保留頭和尾的兩個數據
$startTime = array_shift($appointmentTime);
$endTime = array_pop($appointmentTime);
if ($endTime < $startTime) {
$this->message('錯誤的預約時間!');
}
// 預約時間是否小於當前時間
$now = date('Y-m-d H:i');
if (DateUtil::buildDateTime($appointmentDay, $startTime) < $now) {
$this->message('錯誤的預約開始時間!');
}
if (DateUtil::buildDateTime($appointmentDay, $endTime) < $now) {
$this->message('錯誤的預約結束時間!');
}
// 結束時間 + 30分鍾為真正的結束時間
//$timeStamp = DateUtil::buildDateTime($appointmentDay, $endTime);
//$timeStamp += 1800;
//$endTime = date('H:i', $timeStamp);
// 處理優惠
$couponId = $this->input->get('coupon_id', true) + 0;
$couponCode = $this->input->get('coupon_code', true) + 0;
$customerCouponModel = new CustomerCouponModel();
$couponCodeModel = new CouponCodeModel();
$today = date('Y-m-d');
if ($couponId) {
$couponCode = '';
$coupon = $customerCouponModel->readOneById($couponId);
// 判斷是否能使用
if ($coupon['is_use'] == 1) {
$this->message('選擇的優惠券已被使用!');
}
// 是否到領取時間
if ($today < $coupon['start_time']) {
$this->message('優惠券未到使用時間!');
}
if ($today > $coupon['expire_time']) {
$this->message('優惠券已到期!');
}
} else {
if ($couponCode) {
$couponId = '';
$queryCouponCode = $couponCodeModel->readOneByCode($couponCode);
if (!$queryCouponCode) {
$this->message('優惠碼不存在!');
}
// 是否到使用時間
if ($today < $queryCouponCode['start_time']) {
$this->message('優惠碼未到使用時間!');
}
// 是有已過期
if ($today > $queryCouponCode['expire_time']) {
$this->message('優惠碼已到期!');
}
} else {
}
//.........這裏部分代碼省略.........