|
|
@@ -54,26 +54,13 @@ public class CancelOrderApplicationServiceImpl extends ServiceImpl<com.ylx.massa
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String createApplication(String orderId, String cancelReason) {
|
|
|
- log.info("开始创建退单申请,订单ID:{},退单原因:{}", orderId, cancelReason);
|
|
|
-
|
|
|
- // 1. 参数校验
|
|
|
- if (StringUtils.isEmpty(orderId)) {
|
|
|
- throw new ServiceException("订单ID不能为空");
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(cancelReason)) {
|
|
|
- throw new ServiceException("退单原因不能为空");
|
|
|
- }
|
|
|
- if (cancelReason.length() > 50) {
|
|
|
- throw new ServiceException("退单原因不能超过50个字符");
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 查询订单信息
|
|
|
+ // 查询订单信息
|
|
|
TOrder order = orderService.getById(orderId);
|
|
|
if (order == null) {
|
|
|
throw new ServiceException("订单不存在");
|
|
|
}
|
|
|
|
|
|
- // 3. 校验订单状态 - 只有进行中的订单才能申请退单
|
|
|
+ // 校验订单状态 - 只有进行中的订单才能申请退单
|
|
|
// 进行中状态包括: 待接单(0)、已接单(1)、已出发(6)、已到达(2)、服务中(3)
|
|
|
Integer currentStatus = order.getnStatus();
|
|
|
log.info("订单当前状态:{}", currentStatus);
|
|
|
@@ -81,20 +68,20 @@ public class CancelOrderApplicationServiceImpl extends ServiceImpl<com.ylx.massa
|
|
|
throw new ServiceException("当前订单状态不允许申请退单,只有进行中的订单可以申请退单");
|
|
|
}
|
|
|
|
|
|
- // 4. 检查是否已有待审核的退单申请
|
|
|
+ // 检查是否已有待审核的退单申请
|
|
|
CancelOrderApplication existingApplication = getInfoByOrderId(orderId);
|
|
|
if (existingApplication != null && existingApplication.getAuditStatus() == 0) {
|
|
|
throw new ServiceException("该订单已有待审核的退单申请,请勿重复提交");
|
|
|
}
|
|
|
|
|
|
|
|
|
- // 6. 查询技师信息
|
|
|
+ // 查询技师信息
|
|
|
TJs technician = null;
|
|
|
if (StringUtils.isNotEmpty(order.getcJsId())) {
|
|
|
technician = jsService.getById(order.getcJsId());
|
|
|
}
|
|
|
|
|
|
- // 7. 构建退单申请记录
|
|
|
+ // 构建退单申请记录
|
|
|
CancelOrderApplication application = new CancelOrderApplication();
|
|
|
application.setOrderId(order.getcId());
|
|
|
application.setOrderNo(order.getOrderNo());
|
|
|
@@ -105,7 +92,7 @@ public class CancelOrderApplicationServiceImpl extends ServiceImpl<com.ylx.massa
|
|
|
application.setTechName(technician != null ? technician.getcName() : null);
|
|
|
application.setTechNickName(technician != null ? technician.getcNickName() : null);
|
|
|
// 设置技师手机号
|
|
|
- application.setTechPhone(technician != null ? technician.getcPhone() : null);
|
|
|
+ application.setTechPhone(technician.getcPhone());
|
|
|
|
|
|
// 从订单明细中提取项目名称
|
|
|
String projectName = extractProjectName(order);
|
|
|
@@ -119,6 +106,8 @@ public class CancelOrderApplicationServiceImpl extends ServiceImpl<com.ylx.massa
|
|
|
application.setOrderAmount(order.getTotalPrice() != null ? order.getTotalPrice() : BigDecimal.ZERO);
|
|
|
//application.setRefundAmount(order.getTotalPrice() != null ? order.getTotalPrice() : BigDecimal.ZERO);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// 保存订单原始状态,用于取消申请时恢复订单状态
|
|
|
application.setOrderStatus(currentStatus);
|
|
|
|
|
|
@@ -130,7 +119,6 @@ public class CancelOrderApplicationServiceImpl extends ServiceImpl<com.ylx.massa
|
|
|
// 设置创建时间
|
|
|
application.setCreateTime(LocalDateTime.now());
|
|
|
application.setUpdateTime(LocalDateTime.now());
|
|
|
- application.setIsDelete(0);
|
|
|
|
|
|
// 8. 保存退单申请记录
|
|
|
boolean saved = this.save(application);
|