本文整理匯總了PHP中Core\Helper\Utility\Validator::float方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::float方法的具體用法?PHP Validator::float怎麽用?PHP Validator::float使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Core\Helper\Utility\Validator
的用法示例。
在下文中一共展示了Validator::float方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: post
public function post($f3)
{
// 首先做參數合法性驗證
$validator = new Validator($f3->get('GET'));
$order_id = $validator->required('訂單ID非法')->digits('訂單ID非法')->min(1, true, '訂單ID非法')->validate('order_id');
if (!$this->validate($validator)) {
goto out_fail;
}
$validator = new Validator($f3->get('POST'));
$payGatewayType = $validator->required('必須選擇一種支付方式')->validate('pay_gateway_type');
$surplus = Money::toStorage($validator->float('餘額格式錯誤')->min(0, true, '餘額格式錯誤')->validate('surplus'));
$bonusSn = $validator->validate('bonus_sn');
// 客服信息
$orderInfoKefuInfo = array();
$orderInfoKefuInfo['kefu_user_id'] = abs(intval($validator->digits()->validate('kefu_user_id')));
$orderInfoKefuInfo['kefu_user_rate'] = abs(intval($validator->digits()->validate('kefu_user_rate')));
$orderInfoKefuInfo['kefu_user_comment'] = $validator->validate('kefu_user_comment');
if (!$this->validate($validator)) {
goto out_fail;
}
// 取得用戶信息
$userInfo = AuthHelper::getAuthUser();
$userBasicService = new UserBasicService();
$userInfo = $userBasicService->loadUserById($userInfo['user_id']);
// 支付某一個特定的訂單需要把訂單加載到臨時購物車裏麵
$orderBasicService = new OrderBasicService();
// 檢查權限
$orderInfo = $orderBasicService->loadOrderInfoById($order_id);
if ($orderInfo->isEmpty() || $userInfo['user_id'] != $orderInfo['user_id'] || OrderBasicService::OS_UNCONFIRMED != $orderInfo['order_status']) {
$this->addFlashMessage('訂單ID非法');
goto out_fail;
}
// 更新客服信息
if ($orderInfoKefuInfo['kefu_user_id'] > 0) {
$adminUserService = new AdminUserService();
$adminUser = $adminUserService->loadAdminById($orderInfoKefuInfo['kefu_user_id']);
if (!$adminUser->isEmpty()) {
$orderInfoKefuInfo['kefu_user_name'] = $adminUser['user_name'];
} else {
$orderInfoKefuInfo['kefu_user_id'] = 0;
$orderInfoKefuInfo['kefu_user_name'] = null;
}
unset($adminUser);
unset($adminUserService);
} else {
$orderInfoKefuInfo['kefu_user_id'] = 0;
$orderInfoKefuInfo['kefu_user_name'] = null;
}
$orderInfo->copyFrom($orderInfoKefuInfo);
$orderInfo->save();
$cartBasicService = new CartBasicService();
// 加載訂單到購物車裏
if (!$cartBasicService->loadFromOrderInfo($order_id)) {
$this->addFlashMessage('訂單加載失敗');
goto out_fail;
}
$cartContext =& $cartBasicService->getCartContextRef();
if ($cartContext->isEmpty()) {
$this->addFlashMessage('訂單為空,不能支付');
goto out_fail;
}
// 做第一次購物車計算,需要計算原始訂單的金額,後麵紅包使用的時候有最低訂單金額限製
$cartBasicService->calcOrderPrice();
if (!empty($surplus) || !empty($bonusSn)) {
if (null != $surplus && $surplus > 0 && $surplus <= $userInfo['user_money']) {
// 設置餘額支付金額,餘額不能超過用戶已經有的錢
$cartContext->setValue('surplus', $surplus);
}
// 設置紅包支付
if (!empty($bonusSn)) {
$bonusService = new Bonus();
//檢查紅包是否可以使用
$bonus = $bonusService->fetchUsableBonusBySn($userInfo['user_id'], $cartContext->getValue('order_amount'), $bonusSn);
if (empty($bonus)) {
$this->addFlashMessage('紅包' . $bonusSn . '不能使用');
goto out_fail;
}
// 設置紅包的使用
$cartContext->setValue('bonus_id', $bonus['bonus_id']);
$cartContext->setValue('bonus', $bonus['type_money']);
}
}
// 做第二次購物車計算,需要計算使用了餘額或者紅包
$cartBasicService->calcOrderPayment();
// 更新訂單信息
$orderInfo = $cartBasicService->saveOrder($userInfo['user_id'], '買家:' . $userInfo['user_name']);
if (!$orderInfo || $orderInfo->isEmpty()) {
//訂單創建失敗,報錯
$this->addFlashMessage('更新訂單信息失敗,請聯係客服');
goto out_my_order_detail;
}
// 如果購物車裏麵有錯誤消息,我們需要顯示它
if ($cartContext->hasError()) {
$this->addFlashMessageArray($cartContext->getAndClearErrorMessageArray());
goto out_my_order_cart;
}
// 如果訂單金額為 0 ,使用 credit 支付網關
if ($orderInfo['order_amount'] <= 0) {
$payGatewayType = 'credit';
}
//.........這裏部分代碼省略.........