|
|
@@ -25,13 +25,17 @@ import com.ylx.massage.service.IMaTechnicianService;
|
|
|
import com.ylx.massage.service.TAddressService;
|
|
|
import com.ylx.massage.service.TWxUserService;
|
|
|
import com.ylx.massage.utils.OrderNumberGenerator;
|
|
|
+import com.ylx.order.domain.OrderStatusFlow;
|
|
|
import com.ylx.order.domain.TOrder;
|
|
|
import com.ylx.order.domain.dto.OrderDateQueryDTO;
|
|
|
import com.ylx.order.domain.dto.OrderSubmitDTO;
|
|
|
+import com.ylx.order.domain.dto.OrderUpdateStatusDTO;
|
|
|
import com.ylx.order.domain.vo.OrderDateQueryVo;
|
|
|
import com.ylx.order.enums.OrderStatusEnum;
|
|
|
import com.ylx.order.enums.PaymentMethodEnum;
|
|
|
+import com.ylx.order.mapper.OrderStatusFlowMapper;
|
|
|
import com.ylx.order.mapper.TOrderMapper;
|
|
|
+import com.ylx.order.service.OrderStatusFlowService;
|
|
|
import com.ylx.order.service.TOrderService;
|
|
|
import com.ylx.project.domain.Project;
|
|
|
import com.ylx.project.service.ProjectService;
|
|
|
@@ -79,6 +83,9 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
@Resource
|
|
|
private WxPayV3Service wxPayV3Service;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private OrderStatusFlowService orderStatusFlowService;
|
|
|
+
|
|
|
@Override
|
|
|
public TOrder addOrder(TOrder order) {
|
|
|
return null;
|
|
|
@@ -365,6 +372,40 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
// 5. 事务成功,返回(Controller中会返回 success 信息)
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * 更新订单状态(修改订单表状态必须使用此接口)
|
|
|
+ * @param dto
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void updateOrderStatus(OrderUpdateStatusDTO dto) {
|
|
|
+ Long orderId = dto.getOrderId();
|
|
|
+ Integer newStatus = dto.getStatus();
|
|
|
+
|
|
|
+ // 1. 查询订单
|
|
|
+ TOrder order = this.baseMapper.selectById(orderId);
|
|
|
+ if (order == null) {
|
|
|
+ throw new ServiceException("订单不存在");
|
|
|
+ }
|
|
|
+ Integer oldStatus = order.getStatus();
|
|
|
+
|
|
|
+ // 2. 更新订单状态
|
|
|
+ order.setStatus(newStatus);
|
|
|
+ // 可根据状态同步更新对应时间字段(例如:支付完成时间、接单时间等),此处省略具体业务逻辑
|
|
|
+ int updateCount = this.baseMapper.updateById(order);
|
|
|
+ if (updateCount == 0) {
|
|
|
+ throw new ServiceException("更新订单状态失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 记录状态流转流水
|
|
|
+ OrderStatusFlow flow = new OrderStatusFlow();
|
|
|
+ flow.setOrderId(orderId);
|
|
|
+ flow.setStatus(newStatus);
|
|
|
+ orderStatusFlowService.getBaseMapper().insert(flow);
|
|
|
+
|
|
|
+ log.info("订单状态变更: orderId={}, oldStatus={}, newStatus={}", orderId, oldStatus, newStatus);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 将 TOrder 转换为 OrderDateQueryVo,并处理 serviceTime 字段
|