|
@@ -529,6 +529,7 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
if(tradeOrderDO.getPayStatus()==1){
|
|
if(tradeOrderDO.getPayStatus()==1){
|
|
|
orderStatus = 6;
|
|
orderStatus = 6;
|
|
|
}
|
|
}
|
|
|
|
|
+ String policyAmountAdjustmentLog = updateOrderPolicyAmountOnAudit(tradeOrderDO);
|
|
|
LocalDateTime confireDate = tradeOrderDO.getConfirmDate();
|
|
LocalDateTime confireDate = tradeOrderDO.getConfirmDate();
|
|
|
LambdaUpdateWrapper<TradeOrderDO> updateWrapper = Wrappers.<TradeOrderDO>lambdaUpdate()
|
|
LambdaUpdateWrapper<TradeOrderDO> updateWrapper = Wrappers.<TradeOrderDO>lambdaUpdate()
|
|
|
.set(TradeOrderDO::getOrderStatus, orderStatus)
|
|
.set(TradeOrderDO::getOrderStatus, orderStatus)
|
|
@@ -551,7 +552,8 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
|
|
|
|
|
tradeOrderMapper.update(updateWrapper);
|
|
tradeOrderMapper.update(updateWrapper);
|
|
|
Map<String, Object> extMap = new HashMap<>();
|
|
Map<String, Object> extMap = new HashMap<>();
|
|
|
- extMap.put("result", "审核通过,审核意见:"+auditAdvice);
|
|
|
|
|
|
|
+ extMap.put("result", appendOrderLogContent(
|
|
|
|
|
+ "审核通过,审核意见:" + auditAdvice, policyAmountAdjustmentLog));
|
|
|
TradeOrderLogUtils.setOrderInfo(orderId, tradeOrderDO.getOrderStatus(), TradeOrderStatusEnum.UNPAID.getStatus(), extMap);
|
|
TradeOrderLogUtils.setOrderInfo(orderId, tradeOrderDO.getOrderStatus(), TradeOrderStatusEnum.UNPAID.getStatus(), extMap);
|
|
|
} else {
|
|
} else {
|
|
|
AuditUserDO auditUserDO = auditUserMapper.selectOne(new QueryWrapper<AuditUserDO>().eq("type", tradeOrderDO.getAuditType()).eq("audit_status", tradeOrderDO.getAuditStatus() + 1).last("limit 1"));
|
|
AuditUserDO auditUserDO = auditUserMapper.selectOne(new QueryWrapper<AuditUserDO>().eq("type", tradeOrderDO.getAuditType()).eq("audit_status", tradeOrderDO.getAuditStatus() + 1).last("limit 1"));
|
|
@@ -2599,8 +2601,10 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
orderPolicyMapper.deleteByOrderId(orderId);
|
|
orderPolicyMapper.deleteByOrderId(orderId);
|
|
|
List<OrderPolicyDO> orderPolicyDOList = new ArrayList<>();
|
|
List<OrderPolicyDO> orderPolicyDOList = new ArrayList<>();
|
|
|
List<TradeOrderPolicyReqVO> policyList = createVO.getPolicyList();
|
|
List<TradeOrderPolicyReqVO> policyList = createVO.getPolicyList();
|
|
|
|
|
+ String policyAdjustmentLog = "";
|
|
|
if (policyList != null) {
|
|
if (policyList != null) {
|
|
|
- adjustPolicySurplusNum(Collections.emptyList(), policyList, voyageId);
|
|
|
|
|
|
|
+ policyAdjustmentLog = appendOrderLogContent(policyAdjustmentLog,
|
|
|
|
|
+ adjustPolicySurplusNum(Collections.emptyList(), policyList, voyageId));
|
|
|
policyList.forEach(policy -> {
|
|
policyList.forEach(policy -> {
|
|
|
OrderPolicyDO orderPolicyDO = new OrderPolicyDO();
|
|
OrderPolicyDO orderPolicyDO = new OrderPolicyDO();
|
|
|
orderPolicyDO.setOrderId(orderId);
|
|
orderPolicyDO.setOrderId(orderId);
|
|
@@ -2621,7 +2625,6 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
//TODO: 判断优惠政策是否需要审核
|
|
//TODO: 判断优惠政策是否需要审核
|
|
|
orderPolicyMapper.insertBatch(orderPolicyDOList);
|
|
orderPolicyMapper.insertBatch(orderPolicyDOList);
|
|
|
}
|
|
}
|
|
|
- updateOrderPolicyAmount(orderId, tradeOrderTotalDO.getRealMoney(), sumPolicyAmount(policyList));
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int auditType = 0;
|
|
int auditType = 0;
|
|
@@ -2659,8 +2662,8 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
tradeOrderRoomModelMapper.insertBatch(tradeOrderRoomDOList);
|
|
tradeOrderRoomModelMapper.insertBatch(tradeOrderRoomDOList);
|
|
|
}
|
|
}
|
|
|
//支付倒计时--不超时,有预订单
|
|
//支付倒计时--不超时,有预订单
|
|
|
- Map<String, Object> append = TradeOrderLogUtils.append("result", "订单创建成功");
|
|
|
|
|
- append.put("content", "");
|
|
|
|
|
|
|
+ String createResultLog = appendOrderLogContent("订单创建成功", policyAdjustmentLog);
|
|
|
|
|
+ Map<String, Object> append = TradeOrderLogUtils.append("result", createResultLog);
|
|
|
tradePublishUtils.publishOrderCreateSuccessMsg(orderId + "");
|
|
tradePublishUtils.publishOrderCreateSuccessMsg(orderId + "");
|
|
|
// 如果是留位订单,发送 4 小时自动取消延迟消息
|
|
// 如果是留位订单,发送 4 小时自动取消延迟消息
|
|
|
if (createVO.getIsYd() != null && createVO.getIsYd() == 1) {
|
|
if (createVO.getIsYd() != null && createVO.getIsYd() == 1) {
|
|
@@ -2753,6 +2756,7 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
Long oldvoyageId = tradeOrderDO.getVoyageId();
|
|
Long oldvoyageId = tradeOrderDO.getVoyageId();
|
|
|
Long newvoyageId = voyageId;
|
|
Long newvoyageId = voyageId;
|
|
|
List<TradeOrderPolicyReqVO> policyList = createVO.getPolicyList();
|
|
List<TradeOrderPolicyReqVO> policyList = createVO.getPolicyList();
|
|
|
|
|
+ String policyAdjustmentLog = "";
|
|
|
// 航次ID
|
|
// 航次ID
|
|
|
if (newvoyageId == null) {
|
|
if (newvoyageId == null) {
|
|
|
return CommonResult.error(ORDER_NOT_VOYAGE);
|
|
return CommonResult.error(ORDER_NOT_VOYAGE);
|
|
@@ -3040,7 +3044,8 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
List<OrderPolicyDO> insetOrderPolicyDOList = new ArrayList<>();
|
|
List<OrderPolicyDO> insetOrderPolicyDOList = new ArrayList<>();
|
|
|
List<OrderPolicyDO> updateOrderPolicyDOList = new ArrayList<>();
|
|
List<OrderPolicyDO> updateOrderPolicyDOList = new ArrayList<>();
|
|
|
if (policyList != null) {
|
|
if (policyList != null) {
|
|
|
- adjustPolicySurplusNum(orderPolicyList, policyList, voyageId);
|
|
|
|
|
|
|
+ policyAdjustmentLog = appendOrderLogContent(policyAdjustmentLog,
|
|
|
|
|
+ adjustPolicySurplusNum(orderPolicyList, policyList, voyageId));
|
|
|
// 传入的优惠政策id
|
|
// 传入的优惠政策id
|
|
|
List<Long> newIds = CollUtil.emptyIfNull(policyList).stream()
|
|
List<Long> newIds = CollUtil.emptyIfNull(policyList).stream()
|
|
|
.map(TradeOrderPolicyReqVO::getId)
|
|
.map(TradeOrderPolicyReqVO::getId)
|
|
@@ -3096,7 +3101,6 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- updateOrderPolicyAmount(orderId, tradeOrderTotalDO.getRealMoney(), sumPolicyAmount(policyList));
|
|
|
|
|
}
|
|
}
|
|
|
int oldSize = orderPolicyList==null?0:orderPolicyList.size();
|
|
int oldSize = orderPolicyList==null?0:orderPolicyList.size();
|
|
|
int newSize = orderPolicyDOList.size();
|
|
int newSize = orderPolicyDOList.size();
|
|
@@ -3197,8 +3201,9 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
|
|
|
|
|
//支付倒计时--不超时,有预订单
|
|
//支付倒计时--不超时,有预订单
|
|
|
Map<String, Object> append = TradeOrderLogUtils.append("result", "订单修改成功");
|
|
Map<String, Object> append = TradeOrderLogUtils.append("result", "订单修改成功");
|
|
|
|
|
+ content = appendOrderLogContent(content, policyAdjustmentLog);
|
|
|
if(StringUtils.isNotEmpty(desc) && !Objects.equals(tradeOrderDO.getOrderStatus(), neworderStatus)){
|
|
if(StringUtils.isNotEmpty(desc) && !Objects.equals(tradeOrderDO.getOrderStatus(), neworderStatus)){
|
|
|
- content = content + "," + desc;
|
|
|
|
|
|
|
+ content = appendOrderLogContent(content, desc);
|
|
|
}
|
|
}
|
|
|
append.put("content", content);
|
|
append.put("content", content);
|
|
|
TradeOrderLogUtils.setOrderInfo(neworderId, tradeOrderDO.getOrderStatus(), neworderStatus, append);
|
|
TradeOrderLogUtils.setOrderInfo(neworderId, tradeOrderDO.getOrderStatus(), neworderStatus, append);
|
|
@@ -3216,9 +3221,9 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
* 按营销政策新增使用数量扣减库存,避免订单反复修改时按完整使用量重复扣减。
|
|
* 按营销政策新增使用数量扣减库存,避免订单反复修改时按完整使用量重复扣减。
|
|
|
* 政策数量减少、删除或订单回滚时不退回库存。
|
|
* 政策数量减少、删除或订单回滚时不退回库存。
|
|
|
*/
|
|
*/
|
|
|
- private void adjustPolicySurplusNum(List<OrderPolicyDO> oldPolicyList,
|
|
|
|
|
- List<TradeOrderPolicyReqVO> newPolicyList,
|
|
|
|
|
- Long voyageId) {
|
|
|
|
|
|
|
+ private String adjustPolicySurplusNum(List<OrderPolicyDO> oldPolicyList,
|
|
|
|
|
+ List<TradeOrderPolicyReqVO> newPolicyList,
|
|
|
|
|
+ Long voyageId) {
|
|
|
Map<Long, BigDecimal> oldUseNumMap = CollUtil.emptyIfNull(oldPolicyList).stream()
|
|
Map<Long, BigDecimal> oldUseNumMap = CollUtil.emptyIfNull(oldPolicyList).stream()
|
|
|
.filter(item -> item.getPolicyId() != null)
|
|
.filter(item -> item.getPolicyId() != null)
|
|
|
.collect(Collectors.toMap(OrderPolicyDO::getPolicyId,
|
|
.collect(Collectors.toMap(OrderPolicyDO::getPolicyId,
|
|
@@ -3229,11 +3234,15 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
.collect(Collectors.toMap(TradeOrderPolicyReqVO::getPolicyId,
|
|
.collect(Collectors.toMap(TradeOrderPolicyReqVO::getPolicyId,
|
|
|
item -> ObjectUtil.defaultIfNull(item.getUseNum(), BigDecimal.ZERO),
|
|
item -> ObjectUtil.defaultIfNull(item.getUseNum(), BigDecimal.ZERO),
|
|
|
BigDecimal::add));
|
|
BigDecimal::add));
|
|
|
- Map<Long, String> policyNameMap = CollUtil.emptyIfNull(newPolicyList).stream()
|
|
|
|
|
|
|
+ Map<Long, String> policyNameMap = CollUtil.emptyIfNull(oldPolicyList).stream()
|
|
|
.filter(item -> item.getPolicyId() != null)
|
|
.filter(item -> item.getPolicyId() != null)
|
|
|
- .collect(Collectors.toMap(TradeOrderPolicyReqVO::getPolicyId,
|
|
|
|
|
|
|
+ .collect(Collectors.toMap(OrderPolicyDO::getPolicyId,
|
|
|
item -> ObjectUtil.defaultIfNull(item.getPolicyName(), String.valueOf(item.getPolicyId())),
|
|
item -> ObjectUtil.defaultIfNull(item.getPolicyName(), String.valueOf(item.getPolicyId())),
|
|
|
(first, second) -> first));
|
|
(first, second) -> first));
|
|
|
|
|
+ CollUtil.emptyIfNull(newPolicyList).stream()
|
|
|
|
|
+ .filter(item -> item.getPolicyId() != null)
|
|
|
|
|
+ .forEach(item -> policyNameMap.put(item.getPolicyId(),
|
|
|
|
|
+ ObjectUtil.defaultIfNull(item.getPolicyName(), String.valueOf(item.getPolicyId()))));
|
|
|
|
|
|
|
|
Set<Long> policyIds = new TreeSet<>();
|
|
Set<Long> policyIds = new TreeSet<>();
|
|
|
policyIds.addAll(oldUseNumMap.keySet());
|
|
policyIds.addAll(oldUseNumMap.keySet());
|
|
@@ -3254,6 +3263,7 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
+ ",本次新增使用房间数:" + changeUseNum));
|
|
+ ",本次新增使用房间数:" + changeUseNum));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ StringJoiner adjustmentJoiner = new StringJoiner(";");
|
|
|
for (Long policyId : policyIds) {
|
|
for (Long policyId : policyIds) {
|
|
|
BigDecimal oldUseNum = oldUseNumMap.getOrDefault(policyId, BigDecimal.ZERO);
|
|
BigDecimal oldUseNum = oldUseNumMap.getOrDefault(policyId, BigDecimal.ZERO);
|
|
|
BigDecimal newUseNum = newUseNumMap.getOrDefault(policyId, BigDecimal.ZERO);
|
|
BigDecimal newUseNum = newUseNumMap.getOrDefault(policyId, BigDecimal.ZERO);
|
|
@@ -3261,24 +3271,73 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
if (changeUseNum.compareTo(BigDecimal.ZERO) > 0) {
|
|
if (changeUseNum.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
policyApi.updatePolicySurplusNum(policyId, voyageId, changeUseNum);
|
|
policyApi.updatePolicySurplusNum(policyId, voyageId, changeUseNum);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (changeUseNum.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
+ StringBuilder adjustment = new StringBuilder()
|
|
|
|
|
+ .append(policyNameMap.getOrDefault(policyId, String.valueOf(policyId)))
|
|
|
|
|
+ .append("使用数量由").append(oldUseNum)
|
|
|
|
|
+ .append("调整为").append(newUseNum);
|
|
|
|
|
+ if (changeUseNum.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ adjustment.append(",扣减政策库存").append(changeUseNum);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ adjustment.append(",按当前规则不退回政策库存");
|
|
|
|
|
+ }
|
|
|
|
|
+ adjustmentJoiner.add(adjustment.toString());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ return adjustmentJoiner.length() == 0 ? "" : "营销政策调整:" + adjustmentJoiner;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private BigDecimal sumPolicyAmount(List<TradeOrderPolicyReqVO> policyList) {
|
|
|
|
|
- return CollUtil.emptyIfNull(policyList).stream()
|
|
|
|
|
- .map(TradeOrderPolicyReqVO::getAmount)
|
|
|
|
|
|
|
+ private String updateOrderPolicyAmountOnAudit(TradeOrderDO order) {
|
|
|
|
|
+ List<OrderPolicyDO> policyList = orderPolicyMapper.selectList(OrderPolicyDO::getOrderId, order.getId());
|
|
|
|
|
+ BigDecimal beforeFreeAmount = ObjectUtil.defaultIfNull(order.getFreeAmount(), BigDecimal.ZERO);
|
|
|
|
|
+ if (CollUtil.isEmpty(policyList) && beforeFreeAmount.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ TradeOrderTotalDO orderTotal = tradeOrderTotalMapper.selectByOrderId(order.getId());
|
|
|
|
|
+ if (orderTotal == null) {
|
|
|
|
|
+ throw exception(ORDER_NOT_EXIST);
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal policyAmount = CollUtil.emptyIfNull(policyList).stream()
|
|
|
|
|
+ .map(OrderPolicyDO::getAmount)
|
|
|
.filter(Objects::nonNull)
|
|
.filter(Objects::nonNull)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ return updateOrderPolicyAmount(order.getId(), orderTotal.getRealMoney(), policyAmount);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void updateOrderPolicyAmount(Long orderId, BigDecimal realMoney, BigDecimal policyAmount) {
|
|
|
|
|
|
|
+ private String updateOrderPolicyAmount(Long orderId, BigDecimal realMoney, BigDecimal policyAmount) {
|
|
|
|
|
+ TradeOrderDO order = tradeOrderMapper.selectById(orderId);
|
|
|
|
|
+ if (order == null) {
|
|
|
|
|
+ throw exception(ORDER_NOT_EXIST);
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal beforePayAmount = ObjectUtil.defaultIfNull(order.getPayAmount(), BigDecimal.ZERO);
|
|
|
|
|
+ BigDecimal beforeFreeAmount = ObjectUtil.defaultIfNull(order.getFreeAmount(), BigDecimal.ZERO);
|
|
|
BigDecimal actualRealMoney = ObjectUtil.defaultIfNull(realMoney, BigDecimal.ZERO);
|
|
BigDecimal actualRealMoney = ObjectUtil.defaultIfNull(realMoney, BigDecimal.ZERO);
|
|
|
BigDecimal actualPolicyAmount = ObjectUtil.defaultIfNull(policyAmount, BigDecimal.ZERO);
|
|
BigDecimal actualPolicyAmount = ObjectUtil.defaultIfNull(policyAmount, BigDecimal.ZERO);
|
|
|
|
|
+ BigDecimal afterPayAmount = actualRealMoney.subtract(actualPolicyAmount);
|
|
|
tradeOrderMapper.update(Wrappers.<TradeOrderDO>lambdaUpdate()
|
|
tradeOrderMapper.update(Wrappers.<TradeOrderDO>lambdaUpdate()
|
|
|
- .set(TradeOrderDO::getPayAmount, actualRealMoney.subtract(actualPolicyAmount))
|
|
|
|
|
|
|
+ .set(TradeOrderDO::getPayAmount, afterPayAmount)
|
|
|
.set(TradeOrderDO::getFreeAmount, actualPolicyAmount)
|
|
.set(TradeOrderDO::getFreeAmount, actualPolicyAmount)
|
|
|
.set(TradeOrderDO::getUpdateTime, LocalDateTime.now())
|
|
.set(TradeOrderDO::getUpdateTime, LocalDateTime.now())
|
|
|
.eq(TradeOrderDO::getId, orderId));
|
|
.eq(TradeOrderDO::getId, orderId));
|
|
|
|
|
+
|
|
|
|
|
+ StringJoiner amountJoiner = new StringJoiner(",");
|
|
|
|
|
+ if (beforePayAmount.compareTo(afterPayAmount) != 0) {
|
|
|
|
|
+ amountJoiner.add("实际金额由" + beforePayAmount + "调整为" + afterPayAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (beforeFreeAmount.compareTo(actualPolicyAmount) != 0) {
|
|
|
|
|
+ amountJoiner.add("优惠金额由" + beforeFreeAmount + "调整为" + actualPolicyAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+ return amountJoiner.length() == 0 ? "" : "营销政策金额调整:" + amountJoiner;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String appendOrderLogContent(String content, String addition) {
|
|
|
|
|
+ if (StringUtils.isBlank(addition)) {
|
|
|
|
|
+ return ObjectUtil.defaultIfNull(content, "");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(content)) {
|
|
|
|
|
+ return addition;
|
|
|
|
|
+ }
|
|
|
|
|
+ return content + ";" + addition;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|