本文整理汇总了PHP中Core\Helper\Utility\Validator::min方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::min方法的具体用法?PHP Validator::min怎么用?PHP Validator::min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core\Helper\Utility\Validator
的用法示例。
在下文中一共展示了Validator::min方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Search
public function Search($f3)
{
/**
* 我们使用搜索模块做搜索操作
*/
$searchFieldSelector = 'og.*, oi.system_id, oi.consignee';
global $smarty;
// 参数验证
$validator = new Validator($f3->get('GET'));
$pageNo = $validator->digits()->min(0)->validate('pageNo');
$pageSize = $validator->digits()->min(0)->validate('pageSize');
// 设置缺省值
$pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
$pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10;
// shippingStatus, 0 全部,1 已发货,2 未发货
$shippingStatus = $validator->digits()->min(1)->validate('shippingStatus');
//订单表单查询
$searchFormQuery = array();
$searchFormQuery['og.order_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('order_id');
$searchFormQuery['og.rec_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('rec_id');
$searchFormQuery['og.goods_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
$searchFormQuery['og.goods_name'] = $validator->validate('goods_name');
$searchFormQuery['oi.order_sn'] = $validator->validate('order_sn');
$order_goods_status = $validator->min(0)->filter('ValidatorIntValue')->validate('order_goods_status');
if (null == $order_goods_status) {
// 选择 请求退款、退款中、退款完成 状态的订单
$searchFormQuery['og.order_goods_status'] = array('>', OrderGoodsService::OGS_PAY);
} else {
$searchFormQuery['og.order_goods_status'] = $order_goods_status;
}
$searchFormQuery['oi.consignee'] = $validator->validate('consignee');
$searchFormQuery['oi.mobile'] = $validator->validate('mobile');
$searchFormQuery['oi.address'] = $validator->validate('address');
$searchFormQuery['oi.postscript'] = $validator->validate('postscript');
$searchFormQuery['og.memo'] = $validator->validate('memo');
//退款时间
$refundTimeStartStr = $validator->validate('refund_time_start');
$refundTimeStart = Time::gmStrToTime($refundTimeStartStr) ?: null;
$refundTimeEndStr = $validator->validate('refund_time_end');
$refundTimeEnd = Time::gmStrToTime($refundTimeEndStr) ?: null;
$searchFormQuery['og.refund_time'] = array($refundTimeStart, $refundTimeEnd);
//完成时间
$refundFinishTimeStartStr = $validator->validate('refund_finish_time_start');
$refundFinishTimeStart = Time::gmStrToTime($refundFinishTimeStartStr) ?: null;
$refundFinishTimeEndStr = $validator->validate('refund_finish_time_end');
$refundFinishTimeEnd = Time::gmStrToTime($refundFinishTimeEndStr) ?: null;
$searchFormQuery['og.refund_finish_time'] = array($refundFinishTimeStart, $refundFinishTimeEnd);
if (!$this->validate($validator)) {
goto out_display;
}
// 构造查询条件
$authSupplierUser = AuthHelper::getAuthUser();
// 供货商只能查看自己商品对应的订单
$searchFormQuery['og.suppliers_id'] = intval($authSupplierUser['suppliers_id']);
// 构造查询条件
$searchParamArray = array();
// 用户取消的订单商品我们就不再显示了
$searchParamArray[] = array(QueryBuilder::buildNotInCondition('oi.order_status', array(OrderBasicService::OS_CANCELED, OrderBasicService::OS_INVALID), \PDO::PARAM_INT));
if (1 == $shippingStatus) {
// 1 未发货
$searchParamArray[] = array('og.shipping_id = 0');
} elseif (2 == $shippingStatus) {
// 2 已发货
$searchParamArray[] = array('og.shipping_id <> 0');
} else {
// do nothing
}
// 表单查询
$searchParamArray = array_merge($searchParamArray, QueryBuilder::buildSearchParamArray($searchFormQuery));
// 使用哪个搜索模块
$searchModule = SearchHelper::Module_OrderGoodsOrderInfo;
// 查询订单列表
$totalCount = SearchHelper::count($searchModule, $searchParamArray);
if ($totalCount <= 0) {
// 没订单,可以直接退出了
goto out_display;
}
// 页数超过最大值,返回第一页
if ($pageNo * $pageSize >= $totalCount) {
RouteHelper::reRoute($this, '/Order/Refund/Search');
}
// 查询订单列表
$orderGoodsArray = SearchHelper::search($searchModule, $searchFieldSelector, $searchParamArray, array(array('og.order_id', 'desc')), $pageNo * $pageSize, $pageSize);
// 订单的支付状态显示
foreach ($orderGoodsArray as &$orderGoodsItem) {
$orderGoodsItem['order_goods_status_desc'] = OrderGoodsService::$orderGoodsStatusDesc[$orderGoodsItem['order_goods_status']];
}
// 前面用了引用,这里一定要清除,防止影响后面的数据
unset($orderGoodsItem);
// 给模板赋值
$smarty->assign('totalCount', $totalCount);
$smarty->assign('pageNo', $pageNo);
$smarty->assign('pageSize', $pageSize);
$smarty->assign('orderGoodsArray', $orderGoodsArray);
out_display:
$smarty->display('order_refund_search.tpl');
}
示例2: Search
public function Search($f3)
{
// 权限检查
$this->requirePrivilege('manage_order_goods_search');
/**
* 我们使用搜索模块做搜索操作
*/
$searchFieldSelector = 'og.*, oi.user_id, oi.system_id, oi.kefu_user_id, oi.kefu_user_name, oi.kefu_user_rate';
global $smarty;
// 参数验证
$validator = new Validator($f3->get('GET'));
$pageNo = $validator->digits()->min(0)->validate('pageNo');
$pageSize = $validator->digits()->min(0)->validate('pageSize');
// 设置缺省值
$pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
$pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10;
// shippingStatus, 0 全部,1 已发货,2 未发货
$shippingStatus = $validator->digits()->min(1)->validate('shippingStatus');
//订单表单查询
$searchFormQuery = array();
$searchFormQuery['og.order_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('order_id');
$searchFormQuery['og.rec_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('rec_id');
$searchFormQuery['og.goods_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
$searchFormQuery['og.goods_name'] = $validator->validate('goods_name');
$searchFormQuery['oi.order_sn'] = $validator->validate('order_sn');
$searchFormQuery['oi.pay_no'] = $validator->validate('pay_no');
$order_goods_status = $validator->min(-1)->filter('ValidatorIntValue')->validate('order_goods_status');
if ($order_goods_status >= 0) {
$searchFormQuery['og.order_goods_status'] = $order_goods_status;
}
$searchFormQuery['oi.consignee'] = $validator->validate('consignee');
$searchFormQuery['oi.mobile'] = $validator->validate('mobile');
$searchFormQuery['oi.address'] = $validator->validate('address');
$searchFormQuery['oi.postscript'] = $validator->validate('postscript');
$searchFormQuery['og.memo'] = $validator->validate('memo');
$searchFormQuery['oi.kefu_user_id'] = $validator->filter('ValidatorIntValue')->validate('kefu_user_id');
$searchFormQuery['og.goods_admin_user_id'] = $validator->filter('ValidatorIntValue')->validate('goods_admin_user_id');
//下单时间
$createTimeStartStr = $validator->validate('create_time_start');
$createTimeStart = Time::gmStrToTime($createTimeStartStr) ?: null;
$createTimeEndStr = $validator->validate('create_time_end');
$createTimeEnd = Time::gmStrToTime($createTimeEndStr) ?: null;
$searchFormQuery['og.create_time'] = array($createTimeStart, $createTimeEnd);
//付款时间
$payTimeStartStr = $validator->validate('pay_time_start');
$payTimeStart = Time::gmStrToTime($payTimeStartStr) ?: null;
$payTimeEndStr = $validator->validate('pay_time_end');
$payTimeEnd = Time::gmStrToTime($payTimeEndStr) ?: null;
$searchFormQuery['oi.pay_time'] = array($payTimeStart, $payTimeEnd);
if (!$this->validate($validator)) {
goto out_display;
}
// 构造查询条件
$searchParamArray = array();
// 用户取消的订单商品我们就不再显示了
$searchParamArray[] = array(QueryBuilder::buildNotInCondition('oi.order_status', array(OrderBasicService::OS_CANCELED, OrderBasicService::OS_INVALID), \PDO::PARAM_INT));
if (1 == $shippingStatus) {
// 1 未发货
$searchParamArray[] = array('og.shipping_id = 0');
} elseif (2 == $shippingStatus) {
// 2 已发货
$searchParamArray[] = array('og.shipping_id <> 0');
} else {
// do nothing
}
// 用户查询,目前支持 用户名、邮箱 查询
$user_name = $validator->validate('user_name');
$email = $validator->validate('email');
if (!empty($user_name) || !empty($email)) {
$userQuery = array();
$userQuery['user_name'] = $user_name;
$userQuery['email'] = $email;
$userBasicService = new UserBasicService();
$queryUserArray = $userBasicService->_fetchArray('users', 'user_id', QueryBuilder::buildQueryCondArray($userQuery), array('order' => 'user_id desc'), 0, 1000);
unset($userBasicService);
if (empty($queryUserArray)) {
$this->addFlashMessage('搜索的用户不存在');
} else {
$userIdArray = array();
foreach ($queryUserArray as $queryUser) {
$userIdArray[] = $queryUser['user_id'];
}
if (!empty($userIdArray)) {
$searchParamArray[] = array(QueryBuilder::buildInCondition('oi.user_id', $userIdArray, \PDO::PARAM_INT));
}
unset($userIdArray);
unset($queryUserArray);
}
}
$utmSource = $validator->validate('utm_source');
if ('SELF' == $utmSource) {
$searchParamArray[] = array('orf.utm_source is null');
} else {
$searchFormQuery['orf.utm_source'] = array('=', $utmSource);
}
$utmMedium = $validator->validate('utm_medium');
if ('SELF' == $utmMedium) {
$searchParamArray[] = array('orf.utm_medium is null');
} else {
$searchFormQuery['orf.utm_medium'] = array('=', $utmMedium);
//.........这里部分代码省略.........
示例3: Search
public function Search($f3)
{
/**
* 我们使用搜索模块做搜索操作
*/
$searchFieldSelector = 'og.*, oi.pay_time, oi.system_id';
global $smarty;
// 参数验证
$validator = new Validator($f3->get('GET'));
$pageNo = $validator->digits()->min(0)->validate('pageNo');
$pageSize = $validator->digits()->min(0)->validate('pageSize');
// 设置缺省值
$pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
$pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10;
// shippingStatus, 0 全部,1 已发货,2 未发货
$shippingStatus = $validator->digits()->min(1)->validate('shippingStatus');
//表单查询
$searchFormQuery = array();
$searchFormQuery['og.order_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('order_id');
$searchFormQuery['og.rec_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('rec_id');
$searchFormQuery['og.goods_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
$searchFormQuery['og.order_goods_status'] = $validator->min(1)->filter('ValidatorIntValue')->validate('order_goods_status');
$searchFormQuery['og.goods_sn'] = $validator->validate('goods_sn');
$searchFormQuery['oi.consignee'] = $validator->validate('consignee');
$searchFormQuery['oi.mobile'] = $validator->validate('mobile');
$searchFormQuery['oi.address'] = $validator->validate('address');
$searchFormQuery['oi.postscript'] = $validator->validate('postscript');
$searchFormQuery['og.memo'] = $validator->validate('memo');
//下单时间
$addTimeStartStr = $validator->validate('add_time_start');
$addTimeStart = Time::gmStrToTime($addTimeStartStr) ?: null;
$addTimeEndStr = $validator->validate('add_time_end');
$addTimeEnd = Time::gmStrToTime($addTimeEndStr) ?: null;
$searchFormQuery['oi.add_time'] = array($addTimeStart, $addTimeEnd);
//付款时间
$payTimeStartStr = $validator->validate('pay_time_start');
$payTimeStart = Time::gmStrToTime($payTimeStartStr) ?: null;
$payTimeEndStr = $validator->validate('pay_time_end');
$payTimeEnd = Time::gmStrToTime($payTimeEndStr) ?: null;
$searchFormQuery['oi.pay_time'] = array($payTimeStart, $payTimeEnd);
if (!$this->validate($validator)) {
goto out_display;
}
// 构造查询条件
$authSupplierUser = AuthHelper::getAuthUser();
// 供货商只能查看自己商品对应的订单
$searchFormQuery['og.suppliers_id'] = intval($authSupplierUser['suppliers_id']);
$searchParamArray = array();
// 供货商只能查看已经付款的订单
$searchParamArray[] = array('og.order_goods_status > 0');
if (1 == $shippingStatus) {
// 1 未发货
$searchParamArray[] = array('og.shipping_id = 0');
} elseif (2 == $shippingStatus) {
// 2 已发货
$searchParamArray[] = array('og.shipping_id <> 0');
} else {
// do nothing
}
// 表单查询
$searchParamArray = array_merge($searchParamArray, QueryBuilder::buildSearchParamArray($searchFormQuery));
// 查询订单列表
$totalCount = SearchHelper::count(SearchHelper::Module_OrderGoodsOrderInfo, $searchParamArray);
if ($totalCount <= 0) {
// 没订单,可以直接退出了
goto out_display;
}
// 页数超过最大值,返回第一页
if ($pageNo * $pageSize >= $totalCount) {
RouteHelper::reRoute($this, '/Order/Goods/Search');
}
// 订单列表
$orderGoodsArray = SearchHelper::search(SearchHelper::Module_OrderGoodsOrderInfo, $searchFieldSelector, $searchParamArray, array(array('oi.pay_time', 'desc')), $pageNo * $pageSize, $pageSize);
// 订单的支付状态显示
foreach ($orderGoodsArray as &$orderGoodsItem) {
$orderGoodsItem['order_goods_status_desc'] = OrderGoodsService::$orderGoodsStatusDesc[$orderGoodsItem['order_goods_status']];
}
// 前面用了引用,这里一定要清除,防止影响后面的数据
unset($orderGoodsItem);
// 给模板赋值
$smarty->assign('totalCount', $totalCount);
$smarty->assign('pageNo', $pageNo);
$smarty->assign('pageSize', $pageSize);
$smarty->assign('orderGoodsArray', $orderGoodsArray);
out_display:
$smarty->display('order_goods_search.tpl');
}