/** 查询审核--商品列表 auditState */
  @ResponseBody
  @RequestMapping("/partner/act/audit/list")
  public ResponseObject<Map<String, Object>> listActivityProducts(
      @Valid PartnerActivityProductQueryForm form, Pageable pager) {
    Map<String, Object> paramsMap = new HashMap<String, Object>();
    if (StringUtils.isNoneBlank(form.getActId())) {
      paramsMap.put("activityId", form.getActId());
    }
    if (form.getAuditState() != null) {
      paramsMap.put("auditStatus", form.getAuditState());
    }
    if (form.getProductName() != null) {
      paramsMap.put("shortName", '%' + form.getProductName() + '%');
    }
    if (form.getProductBrand() != null) {
      paramsMap.put("productBrand", '%' + form.getProductBrand() + '%');
    }
    if (form.getStartTime() != null) {
      paramsMap.put("startTime", new Date(form.getStartTime()));
    }
    if (form.getEndTime() != null) {
      paramsMap.put("endTime", new Date(form.getEndTime()));
    }
    paramsMap.put("sortType", form.getSortType());
    Long totalCount = activityService.countCampaignProductByQuery(paramsMap);

    List<XQActivityProductVO> dataList = new ArrayList<XQActivityProductVO>();
    if (totalCount > 0) {
      List<CampaignProductEX> list = activityService.listCampaignProductByQuery(paramsMap, pager);
      for (int i = 0; i < list.size(); i++) {
        CampaignProductEX bean = list.get(i);
        XQActivityProductVO vo = new XQActivityProductVO(bean);
        Product p = productMapper.selectByPrimaryKey(bean.getProductId());
        if (p == null) {
          continue;
          // throw new BizException(GlobalErrorCode.NOT_FOUND, "活动商品"+bean.getProductId()+"不存在");
        }

        Shop shop = shopService.load(p.getShopId());
        vo.setShopName(shop.getName());
        vo.setOldPrice(p.getMarketPrice());
        if (bean.getDiscount() != null) {
          vo.setActPrice(p.getMarketPrice().multiply(new BigDecimal(bean.getDiscount())));
        } else if (bean.getReduction() != null) {
          vo.setActPrice(p.getMarketPrice().subtract(new BigDecimal(bean.getReduction())));
        } else {
          throw new BizException(GlobalErrorCode.UNKNOWN, "活动信息已不完整");
        }
        dataList.add(vo);
      }
    }
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("totalCount", totalCount);
    result.put("list", dataList);
    result.put("pager", pager);
    return new ResponseObject<Map<String, Object>>(result);
  }
Esempio n. 2
0
  @RequestMapping(value = "/shop/{id}/products")
  public String productAll(@PathVariable("id") String shopId, Model model, HttpServletRequest req) {
    Shop shop = shopService.load(shopId);
    List<Product> products = productService.listProducts(shop.getId());
    model.addAttribute("shop", shop);
    model.addAttribute("products", products);

    ShopStyle shopStyle = shopService.loadShopStyle(shopId);
    List<String> bodyClasses = new ArrayList<String>();
    bodyClasses.add(shopStyle.getAvatarStyle());
    bodyClasses.add(shopStyle.getBackgroundColor());
    bodyClasses.add(shopStyle.getFontColor());
    bodyClasses.add(shopStyle.getFontFamily());
    bodyClasses.add(
        StringUtils.isEmpty(shopStyle.getListView()) ? "smallimg" : shopStyle.getListView());
    model.addAttribute("styles", StringUtils.join(bodyClasses, " "));
    model.addAttribute("waterfall", "waterfall".equalsIgnoreCase(shopStyle.getListView()));

    return "shop/shopAll";
  }
Esempio n. 3
0
  /**
   * 只获取店铺信息,不获取商品列表
   *
   * @param shopId
   * @param model
   * @param req
   * @return
   */
  @RequestMapping(value = "/shop/{id}/withoutProduct")
  public String viewWithoutProduct(
      @PathVariable("id") String shopId, Model model, HttpServletRequest req) {
    Shop shop = shopService.load(shopId);
    if (shop == null) {
      throw new BizException(
          GlobalErrorCode.NOT_FOUND, new RequestContext(req).getMessage("shop.not.found"));
    }

    model.addAttribute("shop", shop);
    model.addAttribute("owner", userService.load(shop.getOwnerId()));

    ShopStyle shopStyle = shopService.loadShopStyle(shopId);
    List<String> bodyClasses = new ArrayList<String>();
    bodyClasses.add(shopStyle.getAvatarStyle());
    bodyClasses.add(shopStyle.getBackgroundColor());
    bodyClasses.add(shopStyle.getFontColor());
    bodyClasses.add(shopStyle.getFontFamily());
    bodyClasses.add(
        StringUtils.isEmpty(shopStyle.getListView()) ? "smallimg" : shopStyle.getListView());
    model.addAttribute("styles", StringUtils.join(bodyClasses, " "));
    model.addAttribute("waterfall", "waterfall".equalsIgnoreCase(shopStyle.getListView()));

    List<Category> categories = categoryService.listRootCategoriesByShop(shop.getId());
    List<CategoryVO> categoryVOs = new ArrayList<CategoryVO>();
    for (int i = 0; i < categories.size(); i++) {
      CategoryVO categoryVO = new CategoryVO();
      BeanUtils.copyProperties(categories.get(i), categoryVO);
      categoryVO.setProductCount(
          categoryService.countProductsUnderCategory((categories.get(i)).getId()));
      categoryVOs.add(categoryVO);
    }
    model.addAttribute("categories", categoryVOs);

    model.addAttribute("recommendCount", productService.countByRecommend(shopId));
    model.addAttribute("allCount", productService.countProductsBySales(shopId));

    return "shop/shopView";
  }
Esempio n. 4
0
  @RequestMapping(value = "/shop/{id}")
  public String view(@PathVariable("id") String shopId, Model model, HttpServletRequest req) {
    Shop shop = shopService.load(shopId);
    if (shop == null || shop.getArchive() == Boolean.TRUE) {
      throw new BizException(
          GlobalErrorCode.NOT_FOUND, new RequestContext(req).getMessage("shop.not.found"));
    }

    model.addAttribute("shop", shop);
    model.addAttribute("owner", userService.load(shop.getOwnerId()));

    // 取推荐,和热卖商品
    List<Product> recommends =
        productService.listProductsByRecommend(shop.getId(), new PageRequest(0, 4));
    model.addAttribute("prodsRecommended", recommends);

    List<Product> prodsHot =
        productService.listProductsBySales(shop.getId(), new PageRequest(0, 12), Direction.DESC);
    model.addAttribute("prodsHot", prodsHot);

    boolean isShowAll = false;
    if (prodsHot.size() == 12) {
      Long count = productService.countProductsByStatus(shop.getId(), ProductStatus.ONSALE);
      isShowAll = (count.longValue() > 12);
    }
    model.addAttribute("isShowAll", isShowAll);

    ShopStyleVO shopStyle = shopService.loadShopStyle(shopId);
    List<String> bodyClasses = new ArrayList<String>();
    bodyClasses.add(shopStyle.getAvatarStyle());
    bodyClasses.add(shopStyle.getBackgroundColor());
    bodyClasses.add(shopStyle.getFontColor());
    bodyClasses.add(shopStyle.getFontFamily());
    bodyClasses.add(
        StringUtils.isEmpty(shopStyle.getListView()) ? "smallimg" : shopStyle.getListView());
    model.addAttribute("styles", StringUtils.join(bodyClasses, " "));
    model.addAttribute("waterfall", "waterfall".equalsIgnoreCase(shopStyle.getListView()));
    model.addAttribute("banner", shopStyle.getBannerImg());

    if (shop.getProvinceId() != null) {
      Zone province = zoneService.load(shop.getProvinceId().toString());
      model.addAttribute("province", province);
    }
    if (shop.getCityId() != null) {
      Zone city = zoneService.load(shop.getCityId().toString());
      model.addAttribute("city", city);
    }

    List<Category> categories = categoryService.listRootCategoriesByShop(shop.getId());
    List<CategoryVO> categoryVOs = new ArrayList<CategoryVO>();
    for (int i = 0; i < categories.size(); i++) {
      CategoryVO categoryVO = new CategoryVO();
      BeanUtils.copyProperties(categories.get(i), categoryVO);
      categoryVO.setProductCount(
          categoryService.countProductsUnderCategory((categories.get(i)).getId()));
      categoryVOs.add(categoryVO);
    }
    model.addAttribute("categories", categoryVOs);

    model.addAttribute("recommendCount", productService.countByRecommend(shopId));
    model.addAttribute("allCount", productService.countProductsBySales(shopId));

    return "shop/shopView";
  }
Esempio n. 5
0
 @ResponseBody
 @RequestMapping(UrlHelper.SHOP_URL_PREFIX + "/{id}/styles")
 public ResponseObject<ShopStyleVO> shopStylesCss(@PathVariable String id) {
   ShopStyleVO ss = shopService.loadShopStyle(id);
   return new ResponseObject<ShopStyleVO>(ss);
 }