Exemplo n.º 1
0
  /**
   * 根据折扣id获取其显示及折扣乘积
   *
   * @param discountId
   * @return
   */
  public static Map<String, String> getDiscountDetailShowAndMultiplyByDiscountId(
      HttpServletRequest request) {

    int discountId = Integer.parseInt(request.getParameter("unitDiscountId"));

    Map<String, String> retMap = new HashMap<String, String>();

    StringBuffer sb = new StringBuffer();
    BigDecimal multiply = new BigDecimal(1); // 具体的折扣

    UnitDiscount unitDiscount = unitDiscountServices.findUnitDiscountById(discountId);

    try {

      List<UnitDiscountDetail> detailList =
          unitDiscountDetailServices.findDetailByDiscountId(discountId);

      if (!CommonUtils.isCollectionEmpty(detailList)) {
        for (UnitDiscountDetail detail : detailList) {

          sb.append(detail.getDiscountPercent()).append("*");
          multiply = multiply.multiply(detail.getDiscountPercent().divide(new BigDecimal(100)));
        }
      } else {

        sb.append(unitDiscount.getDiscountName());
      }

      retMap = initSumMoneyAndContractMoney(request, discountId, multiply, retMap); // 设置其他的相关金额

    } catch (Exception e) {
      e.printStackTrace();
    }

    String detail = sb.toString();
    if (detail.endsWith("*")) {
      detail = detail.substring(0, detail.length() - 1);
    }

    // 增加折扣对应的说明
    String computeWay = unitDiscount.getComputeWay();
    String wayValue = computeWayMap.get(computeWay);
    if (!CommonUtils.isStrEmpty(wayValue)) {

      detail += wayValue;
    }

    retMap.put("detail", detail); // 折扣显示
    retMap.put("multiply", multiply.toString()); // 具体的折扣

    return retMap;
  }
Exemplo n.º 2
0
  public static String discountDetailListJson(List<UnitDiscountDetail> detailList) {

    if (CommonUtils.isCollectionEmpty(detailList)) {

      return "[]";
    }

    List<Map<String, String>> listMap = new ArrayList<Map<String, String>>();
    Map<String, String> map = null;

    for (UnitDiscountDetail detail : detailList) {

      map = new HashMap<String, String>();

      map.put("typeId", detail.getDiscountType());
      map.put("percent", detail.getDiscountPercent().toString());
      map.put("remark", detail.getRemark());

      listMap.add(map);
    }

    String out = CommonUtils.getListMapJsonAnd(listMap);

    return out;
  }
Exemplo n.º 3
0
  /**
   * 根据单元折扣id获取项目折扣的显示名称
   *
   * @param unitDiscountId
   * @return
   */
  public static String getProjectDiscountShowByUnitDiscountId(int unitDiscountId) {

    StringBuffer sb = new StringBuffer();

    UnitDiscount unitDiscount = unitDiscountServices.findUnitDiscountById(unitDiscountId);

    try {

      List<UnitDiscountDetail> detailList =
          unitDiscountDetailServices.findDetailByDiscountId(unitDiscountId);

      if (!CommonUtils.isCollectionEmpty(detailList)) {
        for (UnitDiscountDetail detail : detailList) {

          sb.append(detail.getDiscountPercent()).append("*");
        }
      }

      List<ProjectDiscount> proList =
          projectDiscountServices.findProjectDiscountByUnitDiscountId(unitDiscountId);

      if (!CommonUtils.isCollectionEmpty(proList)) {
        for (ProjectDiscount pro : proList) {

          sb.append(pro.getDiscountPercent()).append("*");
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
      sb.delete(0, sb.length());
      sb.append(unitDiscount.getDiscountName());
    }

    String ret = sb.toString();
    if (ret.endsWith("*")) {

      ret = ret.substring(0, ret.length() - 1);

      // 增加折扣对应的说明
      String computeWay = unitDiscount.getComputeWay();
      String wayValue = computeWayMap.get(computeWay);
      if (!CommonUtils.isStrEmpty(wayValue)) {

        ret += wayValue;
      }
    }

    if (CommonUtils.isStrEmpty(ret)) {
      ret = "查看折扣";
    }

    return ret;
  }