コード例 #1
0
  @RequestMapping("/shangpubao/shopsbaoGoodsList.do")
  public Object showShopsBaoGoods(
      ModelMap model, HttpServletRequest request, HttpServletResponse response) {
    super.setCookieUrl(request, response);
    try {
      String merchantId = request.getParameter("merchantId");
      if (StringUtils.isEmpty(merchantId)) {
        request.setAttribute("ERRMSG", "没有找到相关品牌!");
        return new ModelAndView("redirect:../500.html");
      }
      // 现金券原价、现金券标志
      // String sourcePrice = request.getParameter("sourcePrice");
      String couponCash = request.getParameter("couponCash");
      String filterInfo = null;
      if (StringUtils.isNotEmpty(couponCash) && "1".equals(couponCash)) {
        filterInfo = "bg.couponcash='1'";
      }
      MerchantForm merchantForm = null;
      List<GoodsForm> listGoodsForm = null;
      Long mid = null;

      mid = Long.parseLong(merchantId);
      merchantForm = shopsBaoService.getMerchantDetailById(mid);

      if (merchantForm == null) {
        request.setAttribute("ERRMSG", "没有找到相关品牌!");
        return new ModelAndView("redirect:../500.html");
      }
      // 查询品牌下所有分店
      List<MerchantForm> listIdsForm = merchantService.getChildMerchnatById(mid);
      // 分店在售商品数量
      int goodCount = goodsService.getShopsBaoGoodsCount(listIdsForm, filterInfo);
      String currentPage = request.getParameter("cpage");
      if (StringUtils.isEmpty(currentPage)) {
        currentPage = "1";
      }
      // 分页
      Pager pager = PagerHelper.getPager(Integer.parseInt(currentPage), goodCount, listPageSize);
      if (pager.getCurrentPage() > pager.getTotalPages()) {
        pager.setCurrentPage(1);
        pager.setStartRow(0);
      }
      request.setAttribute("pager", pager);

      // 当前页商品数据
      List<Long> listIds = goodsService.getShopsBaoGoodsCountIds(listIdsForm, filterInfo, pager);
      listGoodsForm = goodsService.getGoodsFormByChildId(listIds);

      request.setAttribute("merchantForm", merchantForm);
      request.setAttribute("listGoodsForm", listGoodsForm);
      request.setAttribute("couponCash", couponCash);
    } catch (Exception e) {
      e.printStackTrace();
      request.setAttribute("ERRMSG", "没有找到相关品牌!");
      return new ModelAndView("redirect:../404.html");
    }
    // return "/brand/shopsbaoGoodsList";
    return "/brand/shopsbaoGoodsList";
  }
コード例 #2
0
  @RequestMapping("/shangpubao/shopsbaoCouponList.do")
  public Object showShopsBaoCouponList(
      ModelMap model, HttpServletRequest request, HttpServletResponse response) {
    super.setCookieUrl(request, response);
    try {
      String merchantId = request.getParameter("merchantId");
      if (StringUtils.isEmpty(merchantId)) {
        request.setAttribute("ERRMSG", "没有找到相关品牌!");
        return new ModelAndView("redirect:../500.html");
      }

      MerchantForm merchantForm = null;
      List<CouponForm> listCouponForm = null;
      Long mid = null;

      mid = Long.parseLong(merchantId);
      merchantForm = shopsBaoService.getMerchantDetailById(mid);
      if (merchantForm == null) {
        request.setAttribute("ERRMSG", "没有找到相关品牌!");
        return new ModelAndView("redirect:../500.html");
      }

      // 分店优惠劵数量
      int couponCount = shopsBaoService.getCouponCount(mid);
      String currentPage = request.getParameter("cpage");
      if (StringUtils.isEmpty(currentPage)) {
        currentPage = "1";
      }
      // 分页
      Pager pager = PagerHelper.getPager(Integer.parseInt(currentPage), couponCount, listPageSize);
      if (pager.getCurrentPage() > pager.getTotalPages()) {
        pager.setCurrentPage(1);
        pager.setStartRow(0);
      }
      request.setAttribute("pager", pager);

      // 当前页优惠劵数据
      List<Long> listIds = shopsBaoService.getCouponCountIds(mid, pager);
      listCouponForm = couponCatlogService.getCouponFormByIds(listIds);

      request.setAttribute("merchantForm", merchantForm);
      request.setAttribute("listCouponForm", listCouponForm);
    } catch (Exception e) {
      e.printStackTrace();
      request.setAttribute("ERRMSG", "没有找到相关品牌!");
      return new ModelAndView("redirect:../404.html");
    }
    // return "/brand/shopsbaoCouponList";
    return "/brand/shopsbaoCouponList";
  }