Пример #1
0
  /**
   * 获取pay_way_discount(付款方式折扣)的table map String
   *
   * @param payWayDiscountList
   * @return
   */
  public static String payWayDiscountListJson(List<PayWayDiscount> payWayDiscountList) {

    if (CommonUtils.isCollectionEmpty(payWayDiscountList)) {

      return "[]";
    }

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

    for (PayWayDiscount detail : payWayDiscountList) {

      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;
  }
Пример #2
0
  /**
   * 获取单元折扣dialog关闭要设置的值
   *
   * @param request
   * @return
   */
  public static Map<String, String> getUnitDiscountManagerCloseShowAndMultiplyByDiscountId(
      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<PayWayDiscount> discountList =
          payWayDiscountServices.findPayWayDiscountByUnitDiscountId(discountId);

      if (!CommonUtils.isCollectionEmpty(discountList)) {
        for (PayWayDiscount discount : discountList) {

          sb.append(discount.getDiscountPercent()).append("*");
          multiply = multiply.multiply(discount.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;
  }
Пример #3
0
  /**
   * 根据payWayId获取具体的折扣(百分比)多选框
   *
   * @param payWayId
   * @return
   */
  public static Map<String, String> initSelPayWayDiscountByPayWayId(int payWayId) {

    List<PayWayDiscount> list = payWayDiscountServices.findPayWayDiscountByPayWayId(payWayId);

    Map<String, String> map = new HashMap<String, String>();
    if (CommonUtils.isCollectionEmpty(list)) return map;

    for (PayWayDiscount discount : list) {

      String key = discount.getId() + "";
      String value = discount.getDescDiscountType() + "(" + discount.getDiscountPercent() + ")";

      map.put(key, value);
    }

    return map;
  }
Пример #4
0
  /**
   * 获取折扣记忆名称
   *
   * @param payWayDiscountIds
   * @return
   */
  public static String initUnitDiscountDiscountNameByPayWayDiscountIds(String[] payWayDiscountIds) {

    StringBuffer sb = new StringBuffer();

    if (payWayDiscountIds != null) {
      for (String payWayDiscountId : payWayDiscountIds) {

        PayWayDiscount discount =
            payWayDiscountServices.findPayWayDiscountById(Integer.parseInt(payWayDiscountId));
        sb.append(discount.getDiscountPercent());
      }
    }

    String ret = sb.toString();
    ret = CommonUtils.removeLastChar(ret);

    return ret + "_" + CommonUtils.getNowForString();
  }