Example #1
0
 public function run(array $params)
 {
     $pageSize = 500;
     $goodsBasicService = new Goods();
     $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array());
     for ($pageNo = 0; $pageNo * $pageSize < $totalGoodsCount; $pageNo++) {
         // 查询商品
         $goodsArray = SearchHelper::search(SearchHelper::Module_Goods, 'g.goods_id', array(), array(array('g.goods_id', 'asc')), $pageNo * $pageSize, $pageSize);
         foreach ($goodsArray as $goodsItem) {
             $goods_id = $goodsItem['goods_id'];
             printLog('begin process goods [' . $goods_id . ']');
             $goodsObj = $goodsBasicService->loadGoodsById($goods_id);
             if ($goodsObj->isEmpty()) {
                 printLog('goods [' . $goods_id . '] is empty');
             } else {
                 $goodsObj->goods_desc = str_replace('tuan.bangzhufu.com', 'www.bangzhufu.com', $goodsObj->goods_desc);
                 $goodsObj->goods_desc = str_replace('cdn.bzfshop.net', 'img.bangzhufu.com', $goodsObj->goods_desc);
                 $goodsObj->goods_desc = preg_replace('!/Goods/View/goods_id~([0-9]+).html!', '/Goods/View/goods_id-\\1.html', $goodsObj->goods_desc);
                 $goodsObj->update_time = \Core\Helper\Utility\Time::gmTime();
                 $goodsObj->save();
             }
             unset($goodsObj);
             printLog('end process goods [' . $goods_id . ']');
         }
     }
 }
Example #2
0
 public function get($f3)
 {
     global $smarty;
     $myOrderTitleDesc = array(0 => '未付款订单', 1 => '已付款订单');
     // 构造查询条件
     $searchFormQuery = array();
     // 参数验证
     $validator = new Validator($f3->get('GET'));
     $orderStatus = $f3->get('GET[orderStatus]');
     if (isset($orderStatus)) {
         $orderStatus = $searchFormQuery['order_status'] = $validator->digits('订单状态非法')->min(0)->filter('ValidatorIntValue')->validate('orderStatus');
     }
     $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;
     if (!$this->validate($validator)) {
         goto out_display;
     }
     $myOrderTitle = '全部订单';
     if (isset($orderStatus)) {
         $myOrderTitle = $myOrderTitleDesc[$orderStatus];
     }
     $smarty->assign('myOrderTitle', $myOrderTitle);
     $userInfo = AuthHelper::getAuthUser();
     // 查询订单
     $searchFormQuery['user_id'] = $userInfo['user_id'];
     // 合并查询参数
     $searchParamArray = array_merge(QueryBuilder::buildSearchParamArray($searchFormQuery), $this->searchExtraCondArray);
     $totalCount = SearchHelper::count(SearchHelper::Module_OrderInfo, $searchParamArray);
     if ($totalCount <= 0) {
         // 没订单,可以直接退出了
         goto out_display;
     }
     // 页数超过最大值,返回第一页
     if ($pageNo * $pageSize >= $totalCount) {
         RouteHelper::reRoute($this, '/My/Order');
     }
     // 订单排序
     $orderByParam = array();
     $orderByParam[] = array('order_id', 'desc');
     // 订单列表
     $orderInfoArray = SearchHelper::search(SearchHelper::Module_OrderInfo, '*', $searchParamArray, $orderByParam, $pageNo * $pageSize, $pageSize);
     foreach ($orderInfoArray as &$orderInfoItem) {
         $orderInfoItem['order_status_desc'] = OrderBasicService::$orderStatusDesc[$orderInfoItem['order_status']];
         $orderInfoItem['pay_status_desc'] = OrderBasicService::$payStatusDesc[$orderInfoItem['pay_status']];
     }
     unset($orderInfoItem);
     // 给模板赋值
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     $smarty->assign('orderInfoArray', $orderInfoArray);
     out_display:
     $smarty->display('my_order.tpl', 'get');
 }
Example #3
0
 /**
  * 用户搜索
  */
 public function Search($f3)
 {
     // 权限检查
     $this->requirePrivilege('manage_account_user_search');
     global $smarty;
     // 参数验证
     $validator = new Validator($f3->get('GET'));
     $pageNo = $validator->digits()->min(0)->validate('pageNo');
     $pageSize = $validator->digits()->min(0)->validate('pageSize');
     //查询条件
     $searchFormQuery = array();
     $searchFormQuery['user_id'] = $validator->digits()->filter('ValidatorIntValue')->validate('user_id');
     $searchFormQuery['user_name'] = $validator->validate('user_name');
     $searchFormQuery['email'] = $validator->validate('email');
     $orderByUserMoney = $validator->validate('orderByUserMoney');
     // 设置缺省值
     $pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
     $pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10;
     if (!$this->validate($validator)) {
         goto out_display;
     }
     // 建立查询条件
     $searchParamArray = QueryBuilder::buildSearchParamArray($searchFormQuery);
     // 查询管理员列表
     $totalCount = SearchHelper::count(SearchHelper::Module_User, $searchParamArray);
     if ($totalCount <= 0) {
         // 没用户,可以直接退出了
         goto out_display;
     }
     // 页数超过最大值,返回第一页
     if ($pageNo * $pageSize >= $totalCount) {
         RouteHelper::reRoute($this, '/Account/User/Search');
     }
     $orderByArray = array();
     switch ($orderByUserMoney) {
         case 1:
             $orderByArray[] = array('user_money', 'desc');
             break;
         case 2:
             $orderByArray[] = array('user_money', 'asc');
             break;
         default:
             break;
     }
     // 加入缺省排序
     $orderByArray[] = array('user_id', 'desc');
     // 用户列表
     $userInfoArray = SearchHelper::search(SearchHelper::Module_User, 'user_id, user_name, email, sns_login, user_money, last_login', $searchParamArray, $orderByArray, $pageNo * $pageSize, $pageSize);
     // 给模板赋值
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     $smarty->assign('userInfoArray', $userInfoArray);
     out_display:
     $smarty->display('account_user_search.tpl');
 }
Example #4
0
    public function get($f3)
    {
        global $smarty;
        $smartyCacheId = 'EtaoFeed|' . md5(__NAMESPACE__ . '\\' . __CLASS__ . '_\\' . __METHOD__);
        // 判断是否有缓存
        enableSmartyCache(true, 1200);
        // 缓存 20 分钟
        if ($smarty->isCached('empty.tpl', $smartyCacheId)) {
            goto out_display;
        }
        $currentStamp = Time::localTimeStr();
        $sellerId = EtaoFeedPlugin::getOptionValue('etaofeed_seller_id');
        $categoryUrl = RouteHelper::makeUrl('/Thirdpart/EtaoFeed/Category', null, false, true);
        $itemDir = RouteHelper::makeUrl('/Thirdpart/EtaoFeed/Item', null, false, true);
        $itemIdXmlList = '';
        // 处理 delete 的商品
        $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance();
        $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array('is_on_sale = 0'), array('update_time', '>=', EtaoFeedPlugin::getOptionValue('etaofeed_query_timestamp')), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray()))));
        if ($totalGoodsCount <= 0) {
            goto query_update_goods;
        }
        $totalPageCount = ceil($totalGoodsCount / Item::$pageSize);
        for ($index = 0; $index < $totalPageCount; $index++) {
            $itemIdXmlList .= '<outer_id action="delete">1' . $index . '</outer_id>';
        }
        query_update_goods:
        // 处理修改过的商品
        $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array('is_on_sale = 1'), array('update_time', '>=', EtaoFeedPlugin::getOptionValue('etaofeed_query_timestamp')), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray()))));
        if ($totalGoodsCount <= 0) {
            goto out_output;
        }
        $totalPageCount = ceil($totalGoodsCount / Item::$pageSize);
        for ($index = 0; $index < $totalPageCount; $index++) {
            $itemIdXmlList .= '<outer_id action="upload">2' . $index . '</outer_id>';
        }
        out_output:
        $apiXml = <<<XML
<?xml version="1.0" encoding="utf-8" ?>
<root>
  <version>1.0</version>
  <modified>{$currentStamp}</modified>
  <seller_id>{$sellerId}</seller_id>
  <cat_url>{$categoryUrl}</cat_url>
  <dir>{$itemDir}/</dir>
  <item_ids>{$itemIdXmlList}</item_ids>
</root>
XML;
        $smarty->assign('outputContent', $apiXml);
        // 更新查询时间
        //EtaoFeedPlugin::saveOptionValue('etaofeed_query_timestamp', Time::gmTime());
        out_display:
        header('Content-Type:text/xml;charset=utf-8');
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1 //查询信息
        $smarty->display('empty.tpl', $smartyCacheId);
    }
Example #5
0
 public function get($f3)
 {
     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;
     if (!$this->validate($validator)) {
         goto out_display;
     }
     $userInfo = AuthHelper::getAuthUser();
     // 构造查询条件
     $searchFormQuery = array();
     $searchFormQuery['oi.user_id'] = $userInfo['user_id'];
     // 合并查询参数
     $searchParamArray = array_merge(QueryBuilder::buildSearchParamArray($searchFormQuery), $this->searchExtraCondArray);
     // 查询订单
     $totalCount = SearchHelper::count(SearchHelper::Module_OrderGoodsOrderInfo, $searchParamArray);
     if ($totalCount <= 0) {
         // 没订单,可以直接退出了
         goto out_display;
     }
     // 页数超过最大值,返回第一页
     if ($pageNo * $pageSize >= $totalCount) {
         RouteHelper::reRoute($this, '/My/Order');
     }
     // 订单排序
     $orderByParam = array();
     $orderByParam[] = array('og.rec_id', 'desc');
     // 订单列表
     $orderGoodsArray = SearchHelper::search(SearchHelper::Module_OrderGoodsOrderInfo, 'og.order_id, og.goods_id, og.goods_attr, og.goods_number, og.goods_price, og.shipping_fee' . ', og.create_time, og.order_goods_status, oi.order_sn, oi.pay_time', $searchParamArray, $orderByParam, $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('my_order.tpl', 'get');
 }
 public function run(array $params)
 {
     global $f3;
     $outputFile = $f3->get('TEMP') . 'CheckGoodsInnerImageUrl.log';
     $imageHostAllow = array('img.bangzhufu.com');
     $pageSize = 500;
     $goodsBasicService = new Goods();
     $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array());
     for ($pageNo = 0; $pageNo * $pageSize < $totalGoodsCount; $pageNo++) {
         // 查询商品
         $goodsArray = SearchHelper::search(SearchHelper::Module_Goods, 'g.goods_id', array(), array(array('g.goods_id', 'asc')), $pageNo * $pageSize, $pageSize);
         foreach ($goodsArray as $goodsItem) {
             $goods_id = $goodsItem['goods_id'];
             printLog('begin process goods [' . $goods_id . ']');
             $goodsObj = $goodsBasicService->loadGoodsById($goods_id);
             if ($goodsObj->isEmpty()) {
                 printLog('goods [' . $goods_id . '] is empty');
             } else {
                 $patternMatch = array();
                 preg_match_all('/<img(.*?)src="(.*?)"(.*?)\\/?>/', $goodsObj->goods_desc, $patternMatch, PREG_SET_ORDER);
                 $isFirst = true;
                 // 处理每一个图片
                 foreach ($patternMatch as $matchItem) {
                     $imageUrl = $matchItem[2];
                     $urlInfo = parse_url($imageUrl);
                     if (!in_array(@$urlInfo['host'], $imageHostAllow)) {
                         if ($isFirst) {
                             $isFirst = false;
                             $f3->write($outputFile, "\n\ngoods_id:" . $goodsObj->goods_id . "\n", true);
                         }
                         $f3->write($outputFile, "\t" . $matchItem[2] . "\n", true);
                         printLog('illegal image url [' . $matchItem[2] . ']');
                     }
                 }
                 unset($patternMatch);
             }
             unset($goodsObj);
             printLog('end process goods [' . $goods_id . ']');
         }
     }
 }
Example #7
0
 public function get($f3)
 {
     global $smarty;
     // 首先做参数合法性验证
     $validator = new Validator($f3->get('GET'));
     $pageNo = $validator->digits('pageNo 参数非法')->min(0, true, 'pageNo 参数非法')->validate('pageNo');
     // 搜索参数数组
     $searchFormQuery = array();
     $searchFormQuery['category_id'] = $validator->digits('分类id非法')->min(1, true, '分类id非法')->filter('ValidatorIntValue')->validate('category_id');
     $searchFormQuery['suppliers_id'] = $validator->digits('供货商id非法')->min(1, true, '供货商id非法')->filter('ValidatorIntValue')->validate('suppliers_id');
     $searchFormQuery['goods_name'] = $validator->validate('goods_name');
     // 价格区间查询
     $shopPriceMin = $validator->filter('ValidatorFloatValue')->validate('shop_price_min');
     $shopPriceMax = $validator->filter('ValidatorFloatValue')->validate('shop_price_max');
     $searchFormQuery['shop_price'] = array($shopPriceMin, $shopPriceMax);
     // 排序
     $orderBy = $validator->oneOf(array('', 'total_buy_number', 'shop_price', 'add_time'))->validate('orderBy');
     $orderDir = $validator->oneOf(array('', 'asc', 'desc'))->validate('orderDir');
     $orderByParam = array();
     if (!empty($orderBy)) {
         $orderByParam = array(array($orderBy, $orderDir));
     }
     //增加一些我们的缺省排序
     $orderByParam[] = array('sort_order', 'desc');
     $orderByParam[] = array('goods_id', 'desc');
     // 参数验证
     if (!$this->validate($validator) || empty($searchFormQuery)) {
         goto out_fail;
     }
     $pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
     $pageSize = 10;
     // 每页固定显示 10 个商品
     // 生成 smarty 的缓存 id
     $smartyCacheId = 'Goods|Search|' . md5(json_encode($searchFormQuery) . json_encode($orderByParam) . '_' . $pageNo . '_' . $pageSize);
     // 开启并设置 smarty 缓存时间
     enableSmartyCache(true, MobileThemePlugin::getOptionValue('smarty_cache_time_goods_search'));
     if ($smarty->isCached('goods_search.tpl', $smartyCacheId)) {
         goto out_display;
     }
     // 合并查询参数
     $searchParamArray = array_merge(QueryBuilder::buildSearchParamArray($searchFormQuery), $this->searchExtraCondArray);
     $totalCount = SearchHelper::count(SearchHelper::Module_Goods, $searchParamArray);
     if ($totalCount <= 0) {
         goto out_display;
         // 没有商品,直接显示
     }
     // 页号可能是用户乱输入的,我们需要检查
     if ($pageNo * $pageSize >= $totalCount) {
         goto out_fail;
         // 返回首页
     }
     $goodsArray = SearchHelper::search(SearchHelper::Module_Goods, $this->searchFieldSelector, $searchParamArray, $orderByParam, $pageNo * $pageSize, $pageSize);
     if (empty($goodsArray)) {
         goto out_display;
     }
     // 取得 商品ID 列表
     $goodsIdArray = array();
     foreach ($goodsArray as $goodsItem) {
         $goodsIdArray[] = $goodsItem['goods_id'];
     }
     // 取得商品的图片
     $goodsGalleryService = new GoodsGalleryService();
     $goodsGalleryArray = $goodsGalleryService->fetchGoodsGalleryArrayByGoodsIdArray($goodsIdArray);
     $currentGoodsId = -1;
     $goodsThumbImageArray = array();
     $goodsImageArray = array();
     foreach ($goodsGalleryArray as $goodsGalleryItem) {
         if ($currentGoodsId == $goodsGalleryItem['goods_id']) {
             continue;
             //每个商品我们只需要一张图片,跳过其它的图片
         }
         $currentGoodsId = $goodsGalleryItem['goods_id'];
         // 新的商品 id
         $goodsThumbImageArray[$currentGoodsId] = RouteHelper::makeImageUrl($goodsGalleryItem['thumb_url']);
         $goodsImageArray[$currentGoodsId] = RouteHelper::makeImageUrl($goodsGalleryItem['img_url']);
     }
     // 赋值给模板
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     $smarty->assign('goodsArray', $goodsArray);
     $smarty->assign('goodsThumbImageArray', $goodsThumbImageArray);
     $smarty->assign('goodsImageArray', $goodsImageArray);
     out_display:
     $smarty->display('goods_search.tpl', $smartyCacheId);
     return;
     out_fail:
     // 失败从这里返回
     RouteHelper::reRoute($this, '/');
     // 返回首页
 }
Example #8
0
 public function Search($f3)
 {
     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;
     // 搜索参数数组
     $searchFormQuery = array();
     $searchFormQuery['a.article_id'] = $validator->digits()->min(0)->filter('ValidatorIntValue')->validate('article_id');
     $searchFormQuery['a.title'] = $validator->validate('title');
     $searchFormQuery['a.description'] = $validator->validate('description');
     $searchFormQuery['a.cat_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('cat_id');
     $searchFormQuery['a.admin_user_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('admin_user_id');
     $searchFormQuery['a.is_open'] = $validator->digits()->min(0)->filter('ValidatorIntValue')->validate('is_open');
     if (!$this->validate($validator)) {
         goto out;
     }
     // 建立查询条件
     $searchParamArray = QueryBuilder::buildSearchParamArray($searchFormQuery);
     // 查询商品列表
     $totalCount = SearchHelper::count(SearchHelper::Module_Article, $searchParamArray);
     if ($totalCount <= 0) {
         // 没数据,可以直接退出了
         goto out;
     }
     // 页数超过最大值,返回第一页
     if ($pageNo * $pageSize >= $totalCount) {
         RouteHelper::reRoute($this, '/Article/Article/Search');
     }
     // 文章列表
     $articleArray = SearchHelper::search(SearchHelper::Module_Article, '*', $searchParamArray, array(array('a.article_id', 'desc')), $pageNo * $pageSize, $pageSize);
     // 取得 文章分类 id
     $categoryIdArray = array();
     foreach ($articleArray as $articleItem) {
         $categoryIdArray[] = $articleItem['cat_id'];
     }
     $categoryIdArray = array_unique($categoryIdArray);
     // 取得分类信息
     $articleCategoryService = new ArticleCategoryService();
     $categoryArray = $articleCategoryService->fetchCategoryArrayByIdArray($categoryIdArray);
     // 建立 cat_id  ---> cateogry 信息的反查表
     $categoryIdToCategoryArray = array();
     foreach ($categoryArray as $categoryItem) {
         $categoryIdToCategoryArray[$categoryItem['meta_id']] = $categoryItem;
     }
     // 放入分类信息
     foreach ($articleArray as &$articleItem) {
         if (isset($categoryIdToCategoryArray[$articleItem['cat_id']])) {
             // 很老的商品,分类信息可能已经不存在了
             $articleItem['cat_name'] = $categoryIdToCategoryArray[$articleItem['cat_id']]['meta_name'];
         }
     }
     unset($articleItem);
     // 给模板赋值
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     $smarty->assign('articleArray', $articleArray);
     out:
     $smarty->display('article_article_search.tpl');
 }
Example #9
0
 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);
     }
     // 表单查询
     $searchParamArray = array_merge($searchParamArray, QueryBuilder::buildSearchParamArray($searchFormQuery));
     // 使用哪个搜索模块
     $searchModule = SearchHelper::Module_OrderGoodsOrderInfo;
     if (!empty($utmSource) || !empty($utmMedium)) {
         $searchModule = SearchHelper::Module_OrderGoodsOrderInfoOrderRefer;
     }
     // 查询订单列表
     $totalCount = SearchHelper::count($searchModule, $searchParamArray);
     if ($totalCount <= 0) {
         // 没订单,可以直接退出了
         goto out_display;
     }
     // 页数超过最大值,返回第一页
     if ($pageNo * $pageSize >= $totalCount) {
         RouteHelper::reRoute($this, '/Order/Goods/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);
     // 取得用户 id 列表
     $userIdArray = array();
     foreach ($orderGoodsArray as $orderGoodsItem) {
         $userIdArray[] = $orderGoodsItem['user_id'];
     }
     $userIdArray = array_unique($userIdArray);
     //取得用户信息
     $userBasicService = new UserBasicService();
     $userArray = $userBasicService->fetchUserArrayByUserIdArray($userIdArray);
     // 建立 user_id --> user 的反查表,方便快速查询
     $userIdToUserArray = array();
     foreach ($userArray as $user) {
         $userIdToUserArray[$user['user_id']] = $user;
     }
     // 放入用户信息
     foreach ($orderGoodsArray as &$orderGoodsItem) {
         if (isset($userIdToUserArray[$orderGoodsItem['user_id']])) {
             // 很老的订单,用户可能被删除了
             $orderGoodsItem['user_name'] = $userIdToUserArray[$orderGoodsItem['user_id']]['user_name'];
             $orderGoodsItem['email'] = $userIdToUserArray[$orderGoodsItem['user_id']]['email'];
         }
     }
     // 前面用了引用,这里一定要清除,防止影响后面的数据
     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');
 }
Example #10
0
 public function get($f3)
 {
     global $smarty;
     // 首先做参数合法性验证
     $validator = new Validator($f3->get('GET'));
     $pageNo = $validator->digits('pageNo 参数非法')->min(0, true, 'pageNo 参数非法')->validate('pageNo');
     // 搜索参数数组
     $searchFormQuery = array();
     $searchFormQuery['g.category_id'] = $validator->required('商品分类不能为空')->digits('分类id非法')->min(1, true, '分类id非法')->filter('ValidatorIntValue')->validate('category_id');
     // 这里支持多品牌查询
     $searchFormQuery['g.brand_id'] = array('=', $validator->validate('brand_id'));
     // 价格区间查询
     $shopPriceMin = $validator->filter('ValidatorFloatValue')->validate('shop_price_min');
     $shopPriceMin = null == $shopPriceMin ? null : Money::toStorage($shopPriceMin);
     $shopPriceMax = $validator->filter('ValidatorFloatValue')->validate('shop_price_max');
     $shopPriceMax = null == $shopPriceMax ? null : Money::toStorage($shopPriceMax);
     $searchFormQuery['g.shop_price'] = array($shopPriceMin, $shopPriceMax);
     // 属性过滤
     $filter = $validator->validate('filter');
     // 排序
     $orderBy = $validator->oneOf(array('', 'total_buy_number', 'shop_price', 'add_time'))->validate('orderBy');
     $orderDir = $validator->oneOf(array('', 'asc', 'desc'))->validate('orderDir');
     $orderByParam = array();
     if (!empty($orderBy)) {
         $orderByParam = array(array($orderBy, $orderDir));
     }
     //增加一些我们的缺省排序
     $orderByParam[] = array('g.sort_order', 'desc');
     $orderByParam[] = array('g.goods_id', 'desc');
     // 参数验证
     if (!$this->validate($validator) || empty($searchFormQuery)) {
         goto out_fail;
     }
     $pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
     $pageSize = 45;
     // 每页固定显示 45 个商品
     // 生成 smarty 的缓存 id
     $smartyCacheId = 'Goods|Category|' . md5(json_encode($searchFormQuery) . json_encode($orderByParam) . '_' . $filter . '_' . $pageNo . '_' . $pageSize);
     // 开启并设置 smarty 缓存时间
     enableSmartyCache(true, bzf_get_option_value('smarty_cache_time_goods_search'));
     if ($smarty->isCached('goods_category.tpl', $smartyCacheId)) {
         goto out_display;
     }
     $goodsCategoryService = new GoodsCategoryService();
     $category = $goodsCategoryService->loadCategoryById($searchFormQuery['g.category_id'], 1800);
     if ($category->isEmpty()) {
         $this->addFlashMessage('分类[' . $searchFormQuery['category_id'] . ']不存在');
         goto out_fail;
     }
     $smarty->assign('category', $category);
     $metaData = json_decode($category['meta_data'], true);
     $metaFilterArray = @$metaData['filterArray'];
     // 1. 我们需要在左侧显示分类层级结构
     $goodsCategoryTreeArray = $goodsCategoryService->fetchCategoryTreeArray($category['parent_meta_id'], false, 1800);
     $smarty->assign('goodsCategoryTreeArray', $goodsCategoryTreeArray);
     /**
      * 构造 Filter 数组,结构如下
      *
      * array(
      *      '商品品牌' => array(
      *              filterKey => 'brand_id'
      *              filterValueArray => array( array(value=>'13', text=>'品牌1'), ...)
      *              ),
      *      '颜色' => array(
      *              filterKey => 'filter',
      *              filterValueArray => array( array(value=>'13', text=>'品牌1'), ...)
      *              )
      * )
      *
      */
     $goodsFilterArray = array();
     // filter 查询在这个条件下进行
     $goodsFilterQueryCond = array_merge($this->searchExtraCondArray, array(array('g.category_id', '=', $searchFormQuery['g.category_id'])));
     // 2. 商品品牌查询
     $goodsBrandIdArray = SearchHelper::search(SearchHelper::Module_Goods, 'distinct(g.brand_id)', array_merge($goodsFilterQueryCond, array(array('g.brand_id > 0'))), null, 0, 0);
     $brandIdArray = array_map(function ($elem) {
         return $elem['brand_id'];
     }, $goodsBrandIdArray);
     if (!empty($brandIdArray)) {
         $goodsBrandService = new GoodsBrandService();
         $goodsBrandArray = $goodsBrandService->fetchBrandArrayByIdArray(array_unique(array_values($brandIdArray)));
         $filterBrandArray = array();
         foreach ($goodsBrandArray as $brand) {
             $filterBrandArray[] = array('value' => $brand['brand_id'], 'text' => $brand['brand_name']);
         }
         if (!empty($filterBrandArray)) {
             $goodsFilterArray['品牌'] = array('filterKey' => 'brand_id', 'filterValueArray' => $filterBrandArray);
         }
     }
     // 3. 查询属性过滤
     if (!empty($metaFilterArray)) {
         $goodsTypeService = new GoodsTypeService();
         foreach ($metaFilterArray as $filterItem) {
             $goodsTypeAttrItem = $goodsTypeService->loadGoodsTypeAttrItemById($filterItem['attrItemId']);
             if ($goodsTypeAttrItem->isEmpty()) {
                 continue;
             }
             // 取得商品属性值列表
             $goodsAttrItemValueArray = SearchHelper::search(SearchHelper::Module_GoodsAttrGoods, 'min(ga.goods_attr_id) as goods_attr_id, ga.attr_item_value', array_merge($goodsFilterQueryCond, array(array('ga.attr_item_id', '=', $filterItem['attrItemId']))), null, 0, 0, 'ga.attr_item_value');
             if (!empty($goodsAttrItemValueArray)) {
                 $filterValueArray = array();
                 foreach ($goodsAttrItemValueArray as $itemValue) {
                     $filterValueArray[] = array('value' => $itemValue['goods_attr_id'], 'text' => $itemValue['attr_item_value']);
                 }
                 $goodsFilterArray[$goodsTypeAttrItem['meta_name']] = array('filterKey' => 'filter', 'filterValueArray' => $filterValueArray);
             } else {
                 // 如果这个属性完全没有值(没有一个商品设过任何值),我们弄一个空的
                 $goodsFilterArray[$goodsTypeAttrItem['meta_name']] = array('filterKey' => 'filter', 'filterValueArray' => array());
             }
         }
     }
     // 赋值给模板
     if (!empty($goodsFilterArray)) {
         $smarty->assign('goodsFilterArray', $goodsFilterArray);
     }
     // 4. 商品查询
     if (!empty($metaFilterArray)) {
         // 构造 attrItemId
         $metaFilterTypeIdArray = array();
         foreach ($metaFilterArray as $metaFilterItem) {
             $metaFilterTypeIdArray[] = $metaFilterItem['attrItemId'];
         }
         // 构造 filter 参数,注意 filter 参数在 GoodsGoodsAttr 中具体解析
         // 合并查询参数
         $searchParamArray = array_merge(QueryBuilder::buildSearchParamArray($searchFormQuery), $this->searchExtraCondArray, array(array('ga.filter', implode('.', $metaFilterTypeIdArray), $filter)));
     } else {
         // 合并查询参数
         $searchParamArray = array_merge(QueryBuilder::buildSearchParamArray($searchFormQuery), $this->searchExtraCondArray);
     }
     $totalCount = SearchHelper::count(SearchHelper::Module_GoodsGoodsAttr, $searchParamArray);
     if ($totalCount <= 0) {
         goto out_display;
         // 没有商品,直接显示
     }
     // 页号可能是用户乱输入的,我们需要检查
     if ($pageNo * $pageSize >= $totalCount) {
         goto out_fail;
         // 返回首页
     }
     $goodsArray = SearchHelper::search(SearchHelper::Module_GoodsGoodsAttr, 'g.goods_id, g.cat_id, g.goods_sn, g.goods_name, g.brand_id, g.goods_number, g.market_price' . ', g.shop_price, g.suppliers_id, g.virtual_buy_number, g.user_buy_number, g.user_pay_number' . ', (g.virtual_buy_number + g.user_pay_number) as total_buy_number', $searchParamArray, $orderByParam, $pageNo * $pageSize, $pageSize);
     if (empty($goodsArray)) {
         goto out_display;
     }
     $smarty->assign('goodsArray', $goodsArray);
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     // SEO 考虑,网页标题加上分类的名称
     $smarty->assign('seo_title', $category['meta_name'] . ',' . $smarty->getTemplateVars('seo_title'));
     out_display:
     // 滑动图片广告
     $goods_search_adv_slider = json_decode(bzf_get_option_value('goods_search_adv_slider'), true);
     if (!empty($goods_search_adv_slider)) {
         $smarty->assign('goods_search_adv_slider', $goods_search_adv_slider);
     }
     $smarty->display('goods_category.tpl', $smartyCacheId);
     return;
     out_fail:
     // 失败从这里返回
     RouteHelper::reRoute($this, '/');
     // 返回首页
 }
Example #11
0
    /**
     * 输出 sitemapIndex 文件
     */
    public function outputSiteMapXml($f3, $fileName)
    {
        global $smarty;
        //缓存 60 分钟
        enableSmartyCache(true, 3600, \Smarty::CACHING_LIFETIME_CURRENT);
        $smartyCacheId = 'Api|' . md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__);
        // 判断是否有缓存
        if ($smarty->isCached('empty.tpl', $smartyCacheId)) {
            goto out_display;
        }
        // sitemap 列表
        $siteMapFileList = '';
        // 当前时间
        $currentTime = time();
        /***************** 生成 /Goods/View 列表 *******************/
        // 查询商品数量,决定分页有多少页
        $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance();
        $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray(), 'g'))));
        $pageCount = ceil($totalGoodsCount / $this->pageSize);
        // 取得当前的目录路径
        $currentUrl = RouteHelper::getFullURL();
        $currentUrl = substr($currentUrl, 0, strrpos($currentUrl, $fileName));
        // 生成 goods 页面索引
        for ($index = 0; $index < $pageCount; $index++) {
            $siteMapFileList .= '<sitemap><loc>' . $currentUrl . 'GoodsView_' . $currentTime . '_' . $index . '.xml</loc></sitemap>';
        }
        /***************** 生成 /Goods/Search 列表 *******************/
        // 生成 search 页面索引
        $siteMapFileList .= '<sitemap><loc>' . $currentUrl . 'GoodsSearch_' . $currentTime . '_0.xml</loc></sitemap>';
        /***************** 生成 /Article/View 列表 *******************/
        // 查询商品数量,决定分页有多少页
        $totalArticleCount = SearchHelper::count(SearchHelper::Module_Article, QueryBuilder::buildSearchParamArray(array('a.is_open' => 1)));
        $pageCount = ceil($totalArticleCount / $this->pageSize);
        // 生成 Article 页面索引
        for ($index = 0; $index < $pageCount; $index++) {
            $siteMapFileList .= '<sitemap><loc>' . $currentUrl . 'ArticleView_' . $currentTime . '_' . $index . '.xml</loc></sitemap>';
        }
        $apiXml = <<<XML
<?xml version="1.0" encoding="utf-8" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{$siteMapFileList}
</sitemapindex>
XML;
        $smarty->assign('outputContent', $apiXml);
        out_display:
        header('Content-Type:text/xml;charset=utf-8');
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1 //查询信息
        $smarty->display('empty.tpl', $smartyCacheId);
    }
Example #12
0
 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');
 }
Example #13
0
 public function get($f3)
 {
     global $smarty;
     // 首先做参数合法性验证
     $validator = new Validator($f3->get('GET'));
     $pageNo = $validator->digits('pageNo 参数非法')->min(0, true, 'pageNo 参数非法')->validate('pageNo');
     // 搜索参数数组
     $searchFormQuery = array();
     $searchKeywords = $validator->validate('keywords');
     $searchFormQuery['g.goods_name'] = $searchKeywords;
     // 这里支持多品牌查询
     $searchFormQuery['g.brand_id'] = array('=', $validator->validate('brand_id'));
     // 价格区间查询
     $shopPriceMin = $validator->filter('ValidatorFloatValue')->validate('shop_price_min');
     $shopPriceMin = null == $shopPriceMin ? null : Money::toStorage($shopPriceMin);
     $shopPriceMax = $validator->filter('ValidatorFloatValue')->validate('shop_price_max');
     $shopPriceMax = null == $shopPriceMax ? null : Money::toStorage($shopPriceMax);
     $searchFormQuery['g.shop_price'] = array($shopPriceMin, $shopPriceMax);
     // 排序
     $orderBy = $validator->oneOf(array('', 'total_buy_number', 'shop_price', 'add_time'))->validate('orderBy');
     $orderDir = $validator->oneOf(array('', 'asc', 'desc'))->validate('orderDir');
     $orderByParam = array();
     if (!empty($orderBy)) {
         $orderByParam = array(array($orderBy, $orderDir));
     }
     //增加一些我们的缺省排序
     $orderByParam[] = array('g.sort_order', 'desc');
     $orderByParam[] = array('g.goods_id', 'desc');
     // 参数验证
     if (!$this->validate($validator) || empty($searchFormQuery)) {
         goto out_fail;
     }
     $pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
     $pageSize = 45;
     // 每页固定显示 45 个商品
     // 生成 smarty 的缓存 id
     $smartyCacheId = 'Goods|Search|' . md5(json_encode($searchFormQuery) . json_encode($orderByParam) . '_' . $pageNo . '_' . $pageSize);
     // 开启并设置 smarty 缓存时间
     enableSmartyCache(true, bzf_get_option_value('smarty_cache_time_goods_search'));
     if ($smarty->isCached('goods_search.tpl', $smartyCacheId)) {
         goto out_display;
     }
     $goodsCategoryService = new GoodsCategoryService();
     // 1. 我们需要在左侧显示分类层级结构
     $goodsCategoryTreeArray = $goodsCategoryService->fetchCategoryTreeArray(0, false, 1800);
     $smarty->assign('goodsCategoryTreeArray', $goodsCategoryTreeArray);
     /**
      * 构造 Filter 数组,结构如下
      *
      * array(
      *      '商品品牌' => array(
      *              filterKey => 'brand_id'
      *              filterValueArray => array( array(value=>'13', text=>'品牌1'), ...)
      *              ),
      *      '颜色' => array(
      *              filterKey => 'filter',
      *              filterValueArray => array( array(value=>'13', text=>'品牌1'), ...)
      *              )
      * )
      *
      */
     $goodsFilterArray = array();
     // filter 查询在这个条件下进行
     $goodsFilterQueryCond = array_merge(QueryBuilder::buildSearchParamArray(array('g.goods_name' => $searchKeywords)), $this->searchExtraCondArray);
     // 2. 商品品牌查询
     $goodsBrandIdArray = SearchHelper::search(SearchHelper::Module_Goods, 'distinct(g.brand_id)', array_merge($goodsFilterQueryCond, array(array('g.brand_id > 0'))), null, 0, 0);
     $brandIdArray = array_map(function ($elem) {
         return $elem['brand_id'];
     }, $goodsBrandIdArray);
     if (!empty($brandIdArray)) {
         $goodsBrandService = new GoodsBrandService();
         $goodsBrandArray = $goodsBrandService->fetchBrandArrayByIdArray(array_unique(array_values($brandIdArray)));
         $filterBrandArray = array();
         foreach ($goodsBrandArray as $brand) {
             $filterBrandArray[] = array('value' => $brand['brand_id'], 'text' => $brand['brand_name']);
         }
         if (!empty($filterBrandArray)) {
             $goodsFilterArray['品牌'] = array('filterKey' => 'brand_id', 'filterValueArray' => $filterBrandArray);
         }
     }
     if (!empty($goodsFilterArray)) {
         $smarty->assign('goodsFilterArray', $goodsFilterArray);
     }
     // 3. 商品属性过滤   TODO: 等以后扩展,看看 Search 怎么做属性过滤
     // 4. 商品查询
     // 构造 filter 参数,注意 filter 参数在 GoodsGoodsAttr 中具体解析
     // 合并查询参数
     $searchParamArray = array_merge(QueryBuilder::buildSearchParamArray($searchFormQuery), $this->searchExtraCondArray);
     $totalCount = SearchHelper::count(SearchHelper::Module_GoodsGoodsAttr, $searchParamArray);
     if ($totalCount <= 0) {
         goto out_display;
         // 没有商品,直接显示
     }
     // 页号可能是用户乱输入的,我们需要检查
     if ($pageNo * $pageSize >= $totalCount) {
         goto out_fail;
         // 返回首页
     }
     $goodsArray = SearchHelper::search(SearchHelper::Module_GoodsGoodsAttr, 'g.goods_id, g.cat_id, g.goods_sn, g.goods_name, g.brand_id, g.goods_number, g.market_price' . ', g.shop_price, g.suppliers_id, g.virtual_buy_number, g.user_buy_number, g.user_pay_number' . ', (g.virtual_buy_number + g.user_pay_number) as total_buy_number', $searchParamArray, $orderByParam, $pageNo * $pageSize, $pageSize);
     if (empty($goodsArray)) {
         goto out_display;
     }
     $smarty->assign('goodsArray', $goodsArray);
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     // SEO 考虑,网页标题加上分类的名称
     $smarty->assign('seo_title', '商品搜索,' . $searchKeywords . ',' . $smarty->getTemplateVars('seo_title'));
     out_display:
     // 滑动图片广告
     $goods_search_adv_slider = json_decode(bzf_get_option_value('goods_search_adv_slider'), true);
     if (!empty($goods_search_adv_slider)) {
         $smarty->assign('goods_search_adv_slider', $goods_search_adv_slider);
     }
     $smarty->display('goods_search.tpl', $smartyCacheId);
     return;
     out_fail:
     // 失败从这里返回
     RouteHelper::reRoute($this, '/');
     // 返回首页
 }
Example #14
0
 public function get($f3)
 {
     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;
     // 查询条件
     $searchFormQuery = array();
     $searchFormQuery['g.is_on_sale'] = $validator->digits()->min(0)->filter('ValidatorIntValue')->validate('is_on_sale');
     $searchFormQuery['g.goods_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
     $searchFormQuery['g.goods_name'] = $validator->validate('goods_name');
     $searchFormQuery['g.goods_sn'] = $validator->validate('goods_sn');
     $searchFormQuery['g.warehouse'] = $validator->validate('warehouse');
     $searchFormQuery['g.shelf'] = $validator->validate('shelf');
     if (!$this->validate($validator)) {
         goto out_display;
     }
     // 构造查询条件
     $authSupplierUser = AuthHelper::getAuthUser();
     $searchFormQuery['g.suppliers_id'] = intval($authSupplierUser['suppliers_id']);
     // 建立查询条件
     $searchParamArray = QueryBuilder::buildSearchParamArray($searchFormQuery);
     // 查询商品列表
     $totalCount = SearchHelper::count(SearchHelper::Module_Goods, $searchParamArray);
     if ($totalCount <= 0) {
         // 没商品,可以直接退出了
         goto out_display;
     }
     // 页数超过最大值,返回第一页
     if ($pageNo * $pageSize >= $totalCount) {
         RouteHelper::reRoute($this, '/Goods/Search');
     }
     // 商品列表
     $goodsArray = SearchHelper::search(SearchHelper::Module_Goods, $this->searchFieldSelector, $searchParamArray, array(array('g.goods_id', 'desc')), $pageNo * $pageSize, $pageSize);
     $system_url_base_array = json_decode(ManageThemePlugin::getOptionValue('system_url_base_array'), true);
     foreach ($goodsArray as &$goodsItem) {
         // 解析 system_tag_list,放入 system_array 的信息
         $systeArray = Utils::parseTagString($goodsItem['system_tag_list']);
         $goodsItem['system_array'] = array();
         foreach ($systeArray as $systemItem) {
             $goodsItem['system_array'][] = @$system_url_base_array[$systemItem]['name'];
         }
         // 商品规格
         if (!empty($goodsItem['goods_spec'])) {
             $goodsSpecService = new GoodsSpecService();
             $goodsSpecService->initWithJson($goodsItem['goods_spec']);
             $goodsItem['goods_spec'] = $goodsSpecService->getGoodsSpecDataArray();
         }
     }
     unset($goodsItem);
     // 给模板赋值
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     $smarty->assign('goodsArray', $goodsArray);
     out_display:
     $smarty->display('goods_search.tpl');
 }
Example #15
0
 public function get($f3)
 {
     // 权限检查
     $this->requirePrivilege('manage_goods_search');
     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;
     // 搜索参数数组
     $searchFormQuery = array();
     $searchFormQuery['g.is_on_sale'] = $validator->digits()->min(0)->filter('ValidatorIntValue')->validate('is_on_sale');
     $searchFormQuery['g.goods_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
     $searchFormQuery['g.suppliers_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('suppliers_id');
     $searchFormQuery['g.goods_name'] = $validator->validate('goods_name');
     $searchFormQuery['g.cat_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('cat_id');
     $searchFormQuery['g.type_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('type_id');
     $searchFormQuery['g.brand_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('brand_id');
     $searchFormQuery['g.goods_sn'] = $validator->validate('goods_sn');
     $searchFormQuery['g.warehouse'] = $validator->validate('warehouse');
     $searchFormQuery['g.shelf'] = $validator->validate('shelf');
     $searchFormQuery['g.admin_user_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('admin_user_id');
     $systemTag = $validator->validate('system_tag');
     if (!empty($systemTag)) {
         $searchFormQuery['g.system_tag_list'] = Utils::makeTagString(array($systemTag));
     }
     if (!$this->validate($validator)) {
         goto out_display;
     }
     // 查询条件
     $searchParamArray = array();
     // 根据推广渠道做搜索
     $goods_promote = $validator->validate('goods_promote');
     if (!empty($goods_promote)) {
         switch ($goods_promote) {
             case '360tequan':
                 $searchParamArray[] = array('gp.360tequan_price > 0');
                 break;
             case '360tegong':
                 $searchParamArray[] = array('gp.360tegong_enable = 1');
                 break;
             default:
                 // do nothing
                 break;
         }
     }
     // 建立查询条件
     $searchParamArray = array_merge($searchParamArray, QueryBuilder::buildSearchParamArray($searchFormQuery));
     // 查询商品列表
     $totalCount = SearchHelper::count(SearchHelper::Module_GoodsGoodsPromote, $searchParamArray);
     if ($totalCount <= 0) {
         // 没商品,可以直接退出了
         goto out_display;
     }
     // 页数超过最大值,返回第一页
     if ($pageNo * $pageSize >= $totalCount) {
         RouteHelper::reRoute($this, '/Goods/Search');
     }
     // 商品列表
     $goodsArray = SearchHelper::search(SearchHelper::Module_GoodsGoodsPromote, 'g.goods_id, g.system_tag_list, g.cat_id, g.admin_user_name, g.goods_name, g.goods_number' . ', g.goods_spec, g.is_on_sale, g.type_id' . ', g.market_price, g.shop_price, g.shipping_fee, g.shipping_free_number' . ', g.suppliers_id, g.suppliers_price, g.suppliers_shipping_fee, g.warehouse, g.shelf', $searchParamArray, array(array('g.goods_id', 'desc')), $pageNo * $pageSize, $pageSize);
     // 取得供货商 id 列表,商品分类 id
     $supplierIdArray = array();
     $categoryIdArray = array();
     $typeIdArray = array();
     foreach ($goodsArray as $goodsItem) {
         $supplierIdArray[] = $goodsItem['suppliers_id'];
         $categoryIdArray[] = $goodsItem['cat_id'];
         $typeIdArray[] = $goodsItem['type_id'];
     }
     $supplierIdArray = array_unique($supplierIdArray);
     $categoryIdArray = array_unique($categoryIdArray);
     //取得供货商信息
     $userSupplierService = new UserSupplierService();
     $supplierArray = $userSupplierService->fetchSupplierArrayBySupplierIdArray($supplierIdArray);
     // 建立 suppliers_id --> supplier 的反查表,方便快速查询
     $supplierIdToSupplierArray = array();
     foreach ($supplierArray as $supplier) {
         $supplierIdToSupplierArray[$supplier['suppliers_id']] = $supplier;
     }
     $system_url_base_array = json_decode(ManageThemePlugin::getOptionValue('system_url_base_array'), true);
     // 放入供货商信息
     foreach ($goodsArray as &$goodsItem) {
         if (isset($supplierIdToSupplierArray[$goodsItem['suppliers_id']])) {
             // 很老的订单,用户可能被删除了
             $goodsItem['suppliers_name'] = $supplierIdToSupplierArray[$goodsItem['suppliers_id']]['suppliers_name'];
         }
         // 解析 system_tag_list,放入 system_array 的信息
         $systeArray = Utils::parseTagString($goodsItem['system_tag_list']);
         $goodsItem['system_array'] = array();
         foreach ($systeArray as $systemItem) {
             $goodsItem['system_array'][] = @$system_url_base_array[$systemItem]['name'];
         }
         // 商品规格
         if (!empty($goodsItem['goods_spec'])) {
             $goodsSpecService = new GoodsSpecService();
             $goodsSpecService->initWithJson($goodsItem['goods_spec']);
             $goodsItem['goods_spec'] = $goodsSpecService->getGoodsSpecDataArray();
         }
     }
     unset($goodsItem);
     // 取得分类信息
     $categoryBasicService = new CategoryBasicService();
     $categoryArray = $categoryBasicService->fetchCategoryArrayByIdArray($categoryIdArray);
     // 建立 cat_id  ---> cateogry 信息的反查表
     $categoryIdToCategoryArray = array();
     foreach ($categoryArray as $categoryItem) {
         $categoryIdToCategoryArray[$categoryItem['meta_id']] = $categoryItem;
     }
     // 放入分类信息
     foreach ($goodsArray as &$goodsItem) {
         if (isset($categoryIdToCategoryArray[$goodsItem['cat_id']])) {
             // 很老的商品,分类信息可能已经不存在了
             $goodsItem['cat_name'] = $categoryIdToCategoryArray[$goodsItem['cat_id']]['meta_name'];
         }
     }
     unset($goodsItem);
     // 取得商品类型信息
     $goodsTypeService = new GoodsTypeService();
     $goodsTypeArray = $goodsTypeService->fetchGoodsTypeArrayByTypeIdArray($typeIdArray);
     // 建立 type_id ---> type 信息的反查表
     $typeIdToTypeArray = array();
     foreach ($goodsTypeArray as $goodsType) {
         $typeIdToTypeArray[$goodsType['meta_id']] = $goodsType;
     }
     // 放入类型信息
     foreach ($goodsArray as &$goodsItem) {
         if (isset($typeIdToTypeArray[$goodsItem['type_id']])) {
             $goodsItem['type_name'] = $typeIdToTypeArray[$goodsItem['type_id']]['meta_name'];
         }
     }
     unset($goodsItem);
     // 给模板赋值
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     $smarty->assign('goodsArray', $goodsArray);
     $smarty->assign('system_url_base_array', json_decode(ManageThemePlugin::getOptionValue('system_url_base_array'), true));
     out_display:
     $smarty->display('goods_search.tpl');
 }
Example #16
0
 public function Search($f3)
 {
     // 权限检查
     $this->requirePrivilege('manage_order_order_search');
     /**
      * 我们使用搜索模块做搜索操作
      */
     $searchFieldSelector = 'oi.order_id, oi.order_sn, oi.add_time, oi.confirm_time, oi.user_id, oi.order_status, oi.pay_status' . ', oi.goods_amount, oi.shipping_fee, oi.discount, 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;
     // 构造查询条件
     $searchParamArray = array();
     //表单查询
     $searchFormQuery = array();
     $searchFormQuery['oi.order_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('order_id');
     $searchFormQuery['oi.order_sn'] = $validator->validate('order_sn');
     $searchFormQuery['oi.pay_no'] = $validator->validate('pay_no');
     $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['oi.system_id'] = array('=', $validator->validate('system_id'));
     $searchFormQuery['oi.kefu_user_id'] = $validator->filter('ValidatorIntValue')->validate('kefu_user_id');
     $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);
     }
     //下单时间
     $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;
     }
     // 构造查询条件
     $searchParamArray = array_merge($searchParamArray, QueryBuilder::buildSearchParamArray($searchFormQuery));
     // 使用哪个搜索模块
     $searchModule = SearchHelper::Module_OrderInfo;
     if (!empty($utmSource) || !empty($utmMedium)) {
         $searchModule = SearchHelper::Module_OrderInfoOrderRefer;
     }
     $totalCount = SearchHelper::count($searchModule, $searchParamArray);
     if ($totalCount <= 0) {
         // 没订单,可以直接退出了
         goto out_display;
     }
     // 页数超过最大值,返回第一页
     if ($pageNo * $pageSize >= $totalCount) {
         RouteHelper::reRoute($this, '/Order/Order/Search');
     }
     // 订单列表
     $orderInfoArray = SearchHelper::search($searchModule, $searchFieldSelector, $searchParamArray, array(array('oi.order_id', 'desc')), $pageNo * $pageSize, $pageSize);
     // 订单的支付状态显示
     foreach ($orderInfoArray as &$orderInfoItem) {
         $orderInfoItem['order_status_desc'] = OrderBasicService::$orderStatusDesc[$orderInfoItem['order_status']];
         $orderInfoItem['pay_status_desc'] = OrderBasicService::$payStatusDesc[$orderInfoItem['pay_status']];
     }
     // 前面用了引用,这里一定要清除,防止影响后面的数据
     unset($orderInfoItem);
     // 取得用户 id 列表
     $userIdArray = array();
     foreach ($orderInfoArray as $orderInfoItem) {
         $userIdArray[] = $orderInfoItem['user_id'];
     }
     $userIdArray = array_unique($userIdArray);
     //取得用户信息
     $userBasicService = new UserBasicService();
     $userArray = $userBasicService->fetchUserArrayByUserIdArray($userIdArray);
     // 建立 user_id --> user 的反查表,方便快速查询
     $userIdToUserArray = array();
     foreach ($userArray as $user) {
         $userIdToUserArray[$user['user_id']] = $user;
     }
     // 放入用户信息
     foreach ($orderInfoArray as &$orderInfoItem) {
         if (isset($userIdToUserArray[$orderInfoItem['user_id']])) {
             // 很老的订单,用户可能被删除了
             $orderInfoItem['user_name'] = $userIdToUserArray[$orderInfoItem['user_id']]['user_name'];
             $orderInfoItem['email'] = $userIdToUserArray[$orderInfoItem['user_id']]['email'];
         }
     }
     // 前面用了引用,这里一定要清除,防止影响后面的数据
     unset($orderInfoItem);
     // 给模板赋值
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     $smarty->assign('orderInfoArray', $orderInfoArray);
     out_display:
     $smarty->display('order_order_search.tpl');
 }
Example #17
0
 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');
 }