|
@@ -92,6 +92,8 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
private EnterprisePermissionDao enterprisePermissionDao;
|
|
private EnterprisePermissionDao enterprisePermissionDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ConditionerAddTimeOrderExtendManager conditionerAddTimeOrderExtendManager;
|
|
private ConditionerAddTimeOrderExtendManager conditionerAddTimeOrderExtendManager;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ConditionerAddTimeOrderAmountDetailManager conditionerAddTimeOrderAmountDetailManager;
|
|
|
|
|
|
|
|
|
|
MathContext mc = new MathContext(2, RoundingMode.HALF_UP);
|
|
MathContext mc = new MathContext(2, RoundingMode.HALF_UP);
|
|
@@ -618,6 +620,40 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
.build()
|
|
.build()
|
|
);
|
|
);
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * 保存每个房间均摊的金额
|
|
|
|
+ * 1.单个房间:申请房间面积=订单总金额。
|
|
|
|
+ * 2.多个房间:
|
|
|
|
+ * 申请房间费用=(申请房间面积/订单申请面积)*订单总金额。
|
|
|
|
+ * 最后一个申请房间的费用=订单总金额-申请房间1费用-申请房间N费用。
|
|
|
|
+ */
|
|
|
|
+ BigDecimal totalAmount = airConditionerAddTime.getFreeTotal();
|
|
|
|
+ BigDecimal remainingAmount = totalAmount;
|
|
|
|
+ BigDecimal totalArea = calcapplyArea;
|
|
|
|
+ List<AirConditionerAddTimeOrderAmountDetail> airConditionerAddTimeOrderAmountDetails = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < listRoomInfos.size(); i++) {
|
|
|
|
+ RoomInfo roomInfo = listRoomInfos.get(i);
|
|
|
|
+ BigDecimal roomArea = roomInfo.getArea();
|
|
|
|
+ AirConditionerAddTimeOrderAmountDetail airConditionerAddTimeOrderAmountDetail = new AirConditionerAddTimeOrderAmountDetail();
|
|
|
|
+ airConditionerAddTimeOrderAmountDetail.setCode(code);
|
|
|
|
+ airConditionerAddTimeOrderAmountDetail.setRoomId(roomInfo.getId());
|
|
|
|
+ if (i == listRoomInfos.size() - 1) {
|
|
|
|
+ airConditionerAddTimeOrderAmountDetail.setAmount(remainingAmount);
|
|
|
|
+ } else {
|
|
|
|
+ BigDecimal roomCost = roomArea.divide(totalArea, 2, RoundingMode.HALF_UP).multiply(totalAmount);
|
|
|
|
+ airConditionerAddTimeOrderAmountDetail.setAmount(roomCost);
|
|
|
|
+ remainingAmount = remainingAmount.subtract(roomCost);
|
|
|
|
+ }
|
|
|
|
+ airConditionerAddTimeOrderAmountDetails.add(airConditionerAddTimeOrderAmountDetail);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (cn.superdesk.libs.common.util.CollectionUtils.isNotEmpty(airConditionerAddTimeOrderAmountDetails)) {
|
|
|
|
+ for (AirConditionerAddTimeOrderAmountDetail airConditionerAddTimeOrderAmountDetail : airConditionerAddTimeOrderAmountDetails) {
|
|
|
|
+ conditionerAddTimeOrderAmountDetailManager.save(airConditionerAddTimeOrderAmountDetail);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
AirConditionerAddTime bill = conditionerAddTimeManager.save(airConditionerAddTime);
|
|
AirConditionerAddTime bill = conditionerAddTimeManager.save(airConditionerAddTime);
|
|
|
|
|
|
return AppResultUtil.createSuccesDto(convert(bill));
|
|
return AppResultUtil.createSuccesDto(convert(bill));
|