|
@@ -11,14 +11,11 @@ import com.palmnest.application.dto.ConditionerAddTimeOrderFeeVO;
|
|
|
import com.palmnest.application.dto.WechatMessageDto;
|
|
|
import com.palmnest.application.dto.WxMessageConfigVo;
|
|
|
import com.palmnest.application.dto.input.*;
|
|
|
-import com.palmnest.application.dto.output.AirConditionerAddTimeOutDto;
|
|
|
-import com.palmnest.application.dto.output.GoodsOperateDto;
|
|
|
+import com.palmnest.application.dto.output.*;
|
|
|
+import com.palmnest.dao.airconditioner.AirConditionerAddTimeOrderHistoryDao;
|
|
|
import com.palmnest.dao.estateserve.EnterprisePermissionDao;
|
|
|
import com.palmnest.model.*;
|
|
|
-import com.palmnest.model.airconditioner.AirConditionerAddTime;
|
|
|
-import com.palmnest.model.airconditioner.AirConditionerAddTimeOrderExtend;
|
|
|
-import com.palmnest.model.airconditioner.AirRule;
|
|
|
-import com.palmnest.model.airconditioner.ProjectConfig;
|
|
|
+import com.palmnest.model.airconditioner.*;
|
|
|
import com.palmnest.model.estateserve.AppUser;
|
|
|
import com.palmnest.model.estateserve.VirtualAccount;
|
|
|
import com.palmnest.model.estateserve.WxUser;
|
|
@@ -37,6 +34,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.File;
|
|
@@ -95,6 +93,8 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
private EnterprisePermissionDao enterprisePermissionDao;
|
|
|
@Autowired
|
|
|
private ConditionerAddTimeOrderExtendManager conditionerAddTimeOrderExtendManager;
|
|
|
+ @Autowired
|
|
|
+ private AirConditionerAddTimeOrderHistoryDao airConditionerAddTimeOrderHistoryDao;
|
|
|
|
|
|
|
|
|
MathContext mc = new MathContext(2, RoundingMode.HALF_UP);
|
|
@@ -2627,13 +2627,75 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
|
|
|
}
|
|
|
|
|
|
+ Integer dataType = 0;// 根据api 获得
|
|
|
+ // String currentDateStr=DateUtils.getTime(new Date(),"yyyyMMdd");//换成申请日期的
|
|
|
+ String applyTimeStr = DateUtils.getTime(airConditionerAddTime.getUseStartTime(), "yyyy-MM-dd");
|
|
|
+
|
|
|
+ String jsonStr = HttpKit.holidayGet("https://timor.tech/api/holiday/info/" + applyTimeStr, false);
|
|
|
+ System.out.println("节假日接口调用返回===>" + jsonStr);
|
|
|
+ Map<String, Object> jsApiMap = com.alibaba.fastjson.JSONObject.parseObject(jsonStr);
|
|
|
+ if (null != jsApiMap && jsApiMap.containsKey("code")) {
|
|
|
+ if (jsApiMap.get("code").equals(0)) {
|
|
|
+ // dataType = (Integer) jsApiMap.get("type");
|
|
|
+ Map<String, Object> jsApiMapType = (Map) jsApiMap.get("type");
|
|
|
+ if (jsApiMapType.containsKey("type")) {
|
|
|
+ dataType = (Integer) jsApiMapType.get("type");
|
|
|
+ if (dataType == 3) {
|
|
|
+ // 0, 1, 2, 3- 节假日类型,分别表示 工作日、周末、节日、调休 调休改为工作日
|
|
|
+ dataType = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("空调加时订单请求失败,节假日API异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 勾选后非节假日的周六为工作日=================================================2018.10.17
|
|
|
+ // 如果为 true 如果get为周六且非2节假日 将 dataType设置为0工作日
|
|
|
+ boolean isSaturday = DateUtils.checkIsSaturday(airConditionerAddTime.getUseStartTime());
|
|
|
+ if (isSaturday) {
|
|
|
+ dataType = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ VirtualArchitecture virtual = virtualArchManager.get(airConditionerAddTime.getVirtualId().intValue());
|
|
|
+ if (null != virtual && virtual.getOrganizationId() != null) {
|
|
|
+ ProjectConfig projectConfig = projectConfigManager.getProjectConfigByOrganizationId(Long.valueOf(virtual.getOrganizationId()));
|
|
|
+ if (null == projectConfig) {
|
|
|
+ throw new RuntimeException("空调部分项目配置为空,请系统管理员");
|
|
|
+ }
|
|
|
+ Integer satDataType = projectConfig.getSatDataType();
|
|
|
+ if (null != satDataType && satDataType == 1) {///如果为 true
|
|
|
+ if (isSaturday && dataType != 2) {// 如果get为周六且非2节假日 将 dataType设置为0工作日
|
|
|
+ dataType = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String dataTypeStr = "工作日";
|
|
|
+ if (dataType == GoodsCodeConstants.DATATYPE_WORKINGDAY) {// 工作日
|
|
|
+ dataTypeStr = "工作日";
|
|
|
+ } else if (dataType == GoodsCodeConstants.DATATYPE_RESTDAY) {// 休息日
|
|
|
+ dataTypeStr = "休息日";
|
|
|
+ } else if (dataType == GoodsCodeConstants.DATATYPE_VACATIONS) {// 节假日
|
|
|
+ dataTypeStr = "节假日";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用时间(合并显示 工作日2018-09-18 07:00~21:00
|
|
|
+ // 使用时间(合并显示 10月25日 07:00~21:00(工作日)
|
|
|
+ // String UseStartTimeStr=DateUtils.getDate(repairBill.getUseStartTime(), "yyyy-MM-dd HH:mm");
|
|
|
+ String UseStartTimeStr = DateUtils.getDate(airConditionerAddTime.getUseStartTime(), "MM月dd日 HH:mm");
|
|
|
+ String useEndTimeStr = DateUtils.getDate(airConditionerAddTime.getUseEndTime(), "HH:mm");
|
|
|
+
|
|
|
+
|
|
|
|
|
|
return ConditionerAddTimeOrderFeeVO.builder()
|
|
|
.priceDisplay(priceDisplay)// 单价
|
|
|
.useLengthTime(useLengthTime)// 使用时长
|
|
|
.feeDetail(freeDetail)// 费用明细
|
|
|
.feeTotal(calcFee)// 费用总计
|
|
|
- .monthlyFee(calcFee)//月结费用
|
|
|
+ .monthlyFee(calcFee)// 月结费用
|
|
|
+ .applyArea(applyArea)// 申请面积
|
|
|
+ .useDisplayTime(UseStartTimeStr + "~" + useEndTimeStr + "(" + dataTypeStr + ")")// 使用时间段
|
|
|
+ .roomInfos(roomInfos)// 房间信息
|
|
|
.build();
|
|
|
} catch (Exception e) {
|
|
|
log.error("计算空调加时费用异常", e);
|
|
@@ -2641,4 +2703,112 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新空调加时订单
|
|
|
+ * @param order 订单参数
|
|
|
+ * @param user 用户
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateAddTimeOrder(ConditionerAddTimeOrderUpdateParam order, User user) {
|
|
|
+ AirConditionerAddTime airConditionerAddTime = conditionerAddTimeManager.get(order.getOrderId());
|
|
|
+ if (airConditionerAddTime == null || !airConditionerAddTime.getCode().equalsIgnoreCase(order.getOrderNo())) {
|
|
|
+ throw new RuntimeException("订单不存在");
|
|
|
+ }
|
|
|
+ if (airConditionerAddTime.getModificationDisabled() != 0) {
|
|
|
+ throw new RuntimeException("订单不允许修改");
|
|
|
+ }
|
|
|
+ ConditionerAddTimeOrderFeeVO conditionerAddTimeOrderFeeVO = calcAddTimeOrderFee(order);
|
|
|
+
|
|
|
+ // 更新前
|
|
|
+ String history = JSON.toJSONString(airConditionerAddTime);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新订单信息
|
|
|
+ */
|
|
|
+ StringBuilder roomNos = new StringBuilder();
|
|
|
+ for (Integer roomId : order.getRoomIds()) {
|
|
|
+ roomNos.append(roomId).append(",");
|
|
|
+ }
|
|
|
+ List<RoomInfo> roomInfos = conditionerAddTimeOrderFeeVO.getRoomInfos();
|
|
|
+ Map<Integer,RoomInfo> map = new HashMap<>();
|
|
|
+ for (RoomInfo roomInfo : roomInfos) {
|
|
|
+ map.put(roomInfo.getId(), roomInfo);
|
|
|
+ }
|
|
|
+ StringBuilder roomNames = new StringBuilder();
|
|
|
+ HashSet<Integer> floorSet = new HashSet<>();
|
|
|
+ for (Integer roomId : order.getRoomIds()) {
|
|
|
+ roomNames.append(map.get(roomId).getName()).append(",");
|
|
|
+ floorSet.add(map.get(roomId).getFloorId().intValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder floorIds = new StringBuilder();
|
|
|
+ for (Integer floorId : floorSet) {
|
|
|
+ floorIds.append(floorId).append(",");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ airConditionerAddTime.setRoomNos(roomNos.toString());//申请房间id
|
|
|
+ airConditionerAddTime.setRoomNames(roomNames.toString());// 申请房间名称
|
|
|
+ airConditionerAddTime.setApplyArea(conditionerAddTimeOrderFeeVO.getApplyArea());// 申请面积
|
|
|
+ airConditionerAddTime.setUseLengthTime(conditionerAddTimeOrderFeeVO.getUseLengthTime()); // 使用时长
|
|
|
+ airConditionerAddTime.setUseStartTime(order.getUseStartTime());// 使用开始时间
|
|
|
+ airConditionerAddTime.setUseEndTime(order.getUseEndTime());// 使用结束时间
|
|
|
+ airConditionerAddTime.setPriceDisplay(conditionerAddTimeOrderFeeVO.getPriceDisplay());// 单价
|
|
|
+ airConditionerAddTime.setFreeDetail(conditionerAddTimeOrderFeeVO.getFeeDetail());// 费用明细
|
|
|
+ airConditionerAddTime.setFreeTotal(conditionerAddTimeOrderFeeVO.getFeeTotal());// 费用总计
|
|
|
+ airConditionerAddTime.setMonthlyFree(conditionerAddTimeOrderFeeVO.getMonthlyFee());// 月结费用
|
|
|
+ airConditionerAddTime.setModifier(user.getFullName());// 修改人
|
|
|
+ airConditionerAddTime.setModifyTime(new Date());// 修改时间
|
|
|
+ airConditionerAddTime.setFloorId(floorIds.toString());// 楼层id
|
|
|
+ airConditionerAddTime.setModificationDisabled(order.getModificationDisabled());// 是否关闭修改功能
|
|
|
+
|
|
|
+ // 保存修改记录
|
|
|
+ airConditionerAddTimeOrderHistoryDao.save(
|
|
|
+ AirConditionerAddTimeOrderHistory.builder()
|
|
|
+ .orderNo(airConditionerAddTime.getCode())// 订单号
|
|
|
+ .beforeUpdate(history)// 更新前
|
|
|
+ .afterUpdate(JSON.toJSONString(airConditionerAddTime)) // 更新后
|
|
|
+ .createTime(new Date())
|
|
|
+ .createUser(user.getFullName())
|
|
|
+ .remark(order.getRemark())// 备注
|
|
|
+ .modificationDisabled(order.getModificationDisabled()) // 是否关闭修改功能
|
|
|
+ .build()
|
|
|
+ );
|
|
|
+
|
|
|
+ // 更新原订单
|
|
|
+ conditionerAddTimeManager.updateModel(airConditionerAddTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 空调加时订单WEB端需要展示修改历史记录
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AirConditionerAddTimeOutWebVO assembleOrderHistory(AirConditionerAddTimeOutDto dto) {
|
|
|
+ String code = dto.getCode();// 订单号
|
|
|
+ List<AirConditionerAddTimeOrderHistory> list = airConditionerAddTimeOrderHistoryDao.getByOrderNo(code);
|
|
|
+
|
|
|
+ List<AirConditionerAddTimeHistoryVO> history = new ArrayList<>();
|
|
|
+
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ for (AirConditionerAddTimeOrderHistory airConditionerAddTimeOrderHistory : list) {
|
|
|
+ AirConditionerAddTimeHistoryVO.builder()
|
|
|
+ .createUser(airConditionerAddTimeOrderHistory.getCreateUser())
|
|
|
+ .createTime(DateUtils.getDate(airConditionerAddTimeOrderHistory.getCreateTime(), "yyyy-MM-dd HH:mm:ss"))
|
|
|
+ .remark(airConditionerAddTimeOrderHistory.getRemark())
|
|
|
+ .modificationDisabled(airConditionerAddTimeOrderHistory.getModificationDisabled())
|
|
|
+ .beforeUpdate(JSON.parseObject(airConditionerAddTimeOrderHistory.getBeforeUpdate(), AirConditionerAddTimeHistoryRecord.class))
|
|
|
+ .afterUpdate(JSON.parseObject(airConditionerAddTimeOrderHistory.getAfterUpdate(), AirConditionerAddTimeHistoryRecord.class))
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return AirConditionerAddTimeOutWebVO.builder()
|
|
|
+ .dto(dto)
|
|
|
+ .historyList(history)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
}
|