/** * 根据单元折扣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; }
public static LinkedHashMap<Integer, String> getSelectMap(List<UnitDiscount> list) { LinkedHashMap<Integer, String> retMap = new LinkedHashMap<Integer, String>(); retMap.put(0, CommonUtils.EMPTY); for (UnitDiscount unitDis : list) { retMap.put(unitDis.getId(), unitDis.getDiscountName()); } return retMap; }
/** * 获取单元折扣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; }
/** * 根据type及mainId获取对应的折扣,如果有就返回查看的href,没有就返回新建的href * * @param type * @param mainId * @param unitId * @return */ public static String getDiscountModifyHref(String type, int mainId, int unitId) { StringBuffer sb = new StringBuffer(); UnitDiscount discount = unitDiscountServices.findUnitDiscountByTypeAndMainId(type, mainId); if (discount == null) { // <a href="#" id="addDiscountId" style="float:left;" onclick="return // createDiscountDialog(${selectUnit.id})"> // <font color="#5482DE">新增折扣</font></a> sb.append( "<a href='javascript:void(0)' id='modifyDiscountId' style='float:left;' onclick='return createProjectDiscountDialog(") .append(unitId) .append(",") .append(mainId) .append(",") .append(type) .append(")'>") .append("<font color='#5482DE'>新增折扣</font>") .append("</a>"); } else { // <a href="#" id="updateDiscountId" style="float:left;" onclick="return // createUpdateDiscountDialog(${unitDiscountId})"> // <font color="#5482DE">98.00%*97.00%</font></a> int unitDiscountId = discount.getId(); String detailShow = getProjectDiscountShowByUnitDiscountId(unitDiscountId); sb.append( "<a href='javascript:void(0)' id='modifyDiscountId' style='float:left;' onclick='return createUpdateProjectDiscountDialog(") .append(unitDiscountId) .append(")'>") .append("<font color='#5482DE'>") .append(detailShow) .append("</font>") .append("</a>"); } return sb.toString(); }
/** * 单元为签约,新建合同时,要显示的折扣href "新增折扣"functiont的type为ContConfirmType.CONTRACT * * @param mainId * @param unitId * @param unitDiscount * @return */ public static String getDiscountModifyHrefForContract( int mainId, int unitId, UnitDiscount discount) { StringBuffer sb = new StringBuffer(); // UnitDiscount discount = getUnitDiscountByTypeAndMainId(ContConfirmType.CONFIRM, mainId); if (discount == null || discount.getId() == 0) { sb.append( "<a href='javascript:void(0)' id='modifyDiscountId' style='float:left;' onclick='return createProjectDiscountDialog(") .append(unitId) .append(",") .append(mainId) .append(",") .append(ContConfirmType.CONTRACT) .append(")'>") .append("<font color='#5482DE'>新增折扣</font>") .append("</a>"); } else { int unitDiscountId = discount.getId(); String detailShow = getProjectDiscountShowByUnitDiscountId(unitDiscountId); sb.append( "<a href='javascript:void(0)' id='modifyDiscountId' style='float:left;' onclick='return createUpdateProjectDiscountDialog(") .append(unitDiscountId) .append(")'>") .append("<font color='#5482DE'>") .append(detailShow) .append("</font>") .append("</a>"); } return sb.toString(); }
/** * 设置房间总价及合同总价(合同总价=房间总价+装修总价) 房间总价的计算方式 (1) 先加附加再优惠减价再折 计算方式:(标准总价+附加价-优惠减价)×折扣 (2) 先折再附加价再优惠减价 * 计算方式:标准总价×折扣+附加价-优惠减价 (3) 先优惠减价再折再附加价 计算方式:(标准总价-优惠减价)×折扣+附加价 * * <p>并设置"建筑成交单价","套内成交单价" * * @param discountId * @param multiply, 具体的折扣 * @param map * @return */ private static Map<String, String> initSumMoneyAndContractMoney( HttpServletRequest request, int discountId, BigDecimal multiply, Map<String, String> map) { UnitDiscount unitDiscount = unitDiscountServices.findUnitDiscountById(discountId); String computeWay = unitDiscount.getComputeWay(); // 折扣方式 BigDecimal addSumPrice = unitDiscount.getAddSumPrice() == null ? new BigDecimal(0) : unitDiscount.getAddSumPrice(); // 附加价 BigDecimal reduceSumPrice = unitDiscount.getReduceSumPrice() == null ? new BigDecimal(0) : unitDiscount.getReduceSumPrice(); // 优惠减价 // PropertyUnit unit = unitServices.findPropertyUnitById(unitDiscount.getUnitId()); //对应的单元 // BigDecimal sumPrice = unit.getSumPrice() == null ? new BigDecimal(0) : unit.getSumPrice(); // //标准总价 // BigDecimal buildPrice = unit.getBuildPrice() == null ? new BigDecimal(0) : // unit.getBuildPrice(); //建筑单价 // BigDecimal insidePrice = unit.getInsidePrice() == null ? new BigDecimal(0) : // unit.getInsidePrice(); //套内单价 // 下面几个字段从页面传过来 BigDecimal sumPrice = new BigDecimal(request.getParameter("sumPrice")); // 标准总价 BigDecimal buildArea = new BigDecimal(request.getParameter("buildArea")); // 建筑面积 BigDecimal insideArea = new BigDecimal(request.getParameter("insideArea")); // 套内面积 BigDecimal sumMoney = new BigDecimal(0); // 成交总价 if ("1".equals(computeWay)) { sumMoney = (sumPrice.add(addSumPrice).subtract(reduceSumPrice)).multiply(multiply); } else if ("2".equals(computeWay)) { sumMoney = sumPrice.multiply(multiply).add(addSumPrice).subtract(reduceSumPrice); } else if ("3".equals(computeWay)) { sumMoney = (sumPrice.subtract(reduceSumPrice)).multiply(multiply).add(addSumPrice); } sumMoney = sumMoney.divide(new BigDecimal(1), 0, BigDecimal.ROUND_HALF_EVEN); // 四舍五入 map.put("sumMoney", sumMoney.toString()); // 成交总价 map.put("buildPrice", CommonUtils.moneyDivide(sumMoney, buildArea, 0)); // 建筑成交单价=成交总价/建筑面积 map.put("insidePrice", CommonUtils.moneyDivide(sumMoney, insideArea, 0)); // 套内成交单价=成交总价/套内面积 return map; }