Exemplo n.º 1
0
 @ResponseBody
 @RequestMapping(params = "method=getCategoryItemSearch")
 public Object getCategoryItemSearch(
     ModelMap model,
     HttpServletRequest request,
     CategoryServiceSearchDTO categoryServiceSearchDTO) {
   RFITxnService txnService = ServiceManager.getService(RFITxnService.class);
   Long shopId = WebUtil.getShopId(request);
   Long startPageNo = 1l;
   if (StringUtils.isNotBlank(request.getParameter("startPageNo"))
       && NumberUtil.isNumber(request.getParameter("startPageNo"))) {
     startPageNo = NumberUtil.longValue(request.getParameter("startPageNo"));
   }
   Map<String, Object> returnMap = new HashMap<String, Object>();
   try {
     if (categoryServiceSearchDTO == null) {
       categoryServiceSearchDTO = new CategoryServiceSearchDTO();
     }
     Pager pager = null;
     // 全部
     if (categoryServiceSearchDTO.getCategoryServiceType() == null) {
       categoryServiceSearchDTO.setServiceDTOs(
           txnService.getServicesByCategory(
               shopId,
               categoryServiceSearchDTO.getServiceName(),
               categoryServiceSearchDTO.getCategoryName(),
               CategoryType.BUSINESS_CLASSIFICATION,
               startPageNo,
               PAGE_SIZE));
       pager =
           new Pager(
               txnService.countServiceByCategory(
                   shopId,
                   categoryServiceSearchDTO.getServiceName(),
                   categoryServiceSearchDTO.getCategoryName(),
                   CategoryType.BUSINESS_CLASSIFICATION),
               startPageNo.intValue(),
               (int) PAGE_SIZE);
     }
     categoryServiceSearchDTO.setCategoryDTOs(txnService.getCategoryByShopId(shopId));
     returnMap.put("pager", pager);
     returnMap.put("categoryServiceSearchDTO", categoryServiceSearchDTO);
     returnMap.put("result", new Result(true));
     return returnMap;
   } catch (Exception e) {
     LOG.debug("/category.do");
     LOG.debug("method=getCategoryItemSearch");
     LOG.error(e.getMessage(), e);
     returnMap.put("result", new Result(false));
     return returnMap;
   }
 }
Exemplo n.º 2
0
  /**
   * 根据前台查询条件获得某个具体的标准产品各个店铺的采购统计
   *
   * @param request
   * @param response
   * @param productSearchCondition
   * @return
   */
  @RequestMapping(params = "method=getNormalProductStatDetailByNormalProductId")
  @ResponseBody
  public Object getNormalProductStatDetailByNormalProductId(
      HttpServletRequest request,
      HttpServletResponse response,
      ProductSearchCondition productSearchCondition) {

    try {
      Long shopId = WebUtil.getShopId(request);
      if (shopId == null) throw new Exception("shopId is null!");
      productSearchCondition.setShopId(shopId);
      if (productSearchCondition == null
          || productSearchCondition.getNormalProductStatType() == null
          || !NumberUtil.isNumber(productSearchCondition.getNormalProductIdStr())) {
        return null;
      }
      INormalProductStatService normalProductStatService =
          ServiceManager.getService(INormalProductStatService.class);
      Pager pager = new Pager();
      pager.setRowStart(productSearchCondition.getStart());
      pager.setPageSize(productSearchCondition.getLimit());

      List<Long> shopIdList = null;
      if (StringUtil.isNotEmpty(productSearchCondition.getShopVersion())
          || productSearchCondition.getProvinceId() != null
          || productSearchCondition.getCityId() != null
          || productSearchCondition.getRegionId() != null) {
        IConfigService configService = ServiceManager.getService(IConfigService.class);

        List<Long> shopVersionIds = new ArrayList<Long>();

        if ("REPAIR_VERSION".equals(productSearchCondition.getShopVersion())) {
          shopVersionIds.add(10000010017531654L);
          shopVersionIds.add(10000010017531655L);
          shopVersionIds.add(10000010039823882L);
        } else if ("WHOLESALER_VERSION".equals(productSearchCondition.getShopVersion())) {
          shopVersionIds.add(10000010017531657L);
          shopVersionIds.add(10000010037193619L);
          shopVersionIds.add(10000010037193620L);
          shopVersionIds.add(10000010017531653L);
        }

        shopIdList =
            configService.getShopByShopVersionAndArea(
                shopVersionIds.toArray(new Long[shopVersionIds.size()]),
                productSearchCondition.getProvinceId(),
                productSearchCondition.getCityId(),
                productSearchCondition.getRegionId());
        if (CollectionUtils.isEmpty(shopIdList)) {
          return null;
        }
      } else {
        shopIdList = new ArrayList<Long>();
      }

      NormalProductStatSearchResult normalProductStatSearchResult =
          normalProductStatService.getStatDetailByCondition(
              shopIdList.toArray(new Long[shopIdList.size()]),
              Long.valueOf(productSearchCondition.getNormalProductIdStr()),
              productSearchCondition.getNormalProductStatType(),
              pager);
      return normalProductStatSearchResult;
    } catch (Exception e) {
      LOG.error("normalProductStat.do method=getNormalProductStatByCondition");
      LOG.error("normalProductIdStr" + productSearchCondition.getNormalProductIdStr());
      LOG.error(e.getMessage(), e);
    }
    return null;
  }