From 0e1623165a0385733c46c5fbfc359d71eee38668 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 22 Nov 2021 09:13:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighOrderPreController.java | 12 +-------- .../com/hai/service/HighOrderPreService.java | 6 +++++ .../service/impl/HighOrderPreServiceImpl.java | 27 +++++++++++++++++++ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderPreController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderPreController.java index 333f10ad..32c3d21c 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderPreController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderPreController.java @@ -123,17 +123,7 @@ public class HighOrderPreController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - // 查询预约订单详情 - HighOrderPre orderPre = highOrderPreService.findByOrderId(body.getLong("preOrderId")); - if (orderPre == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到预约订单"); - } - if (orderPre.getStatus() != 2) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); - } - orderPre.setStatus(3); - orderPre.setUpdateTime(new Date()); - highOrderPreService.updateOrderPre(orderPre); + highOrderPreService.orderComplete(body.getLong("preOrderId")); return ResponseMsgUtil.success("操作成功"); diff --git a/hai-service/src/main/java/com/hai/service/HighOrderPreService.java b/hai-service/src/main/java/com/hai/service/HighOrderPreService.java index d5ed40b2..81c5a643 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderPreService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderPreService.java @@ -57,4 +57,10 @@ public interface HighOrderPreService { * @return void **/ void updateOrderPre(HighOrderPre highOrderPre); + + /** + * 订单完成 + * @param preOrderId + */ + void orderComplete(Long preOrderId); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderPreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderPreServiceImpl.java index 49aed02e..68e5fea4 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderPreServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderPreServiceImpl.java @@ -1,14 +1,20 @@ package com.hai.service.impl; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; import com.hai.common.utils.DateUtil; import com.hai.dao.HighOrderPreMapper; import com.hai.entity.HighOrder; import com.hai.entity.HighOrderPre; import com.hai.entity.HighOrderPreExample; import com.hai.service.HighOrderPreService; +import com.hai.service.HighOrderService; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Date; @@ -21,6 +27,9 @@ public class HighOrderPreServiceImpl implements HighOrderPreService { @Resource private HighOrderPreMapper highOrderPreMapper; + @Resource + private HighOrderService highOrderService; + @Override public List getListOrderPre(Map map) { HighOrderPreExample example = new HighOrderPreExample(); @@ -112,4 +121,22 @@ public class HighOrderPreServiceImpl implements HighOrderPreService { public void updateOrderPre(HighOrderPre highOrderPre) { highOrderPreMapper.updateByPrimaryKey(highOrderPre); } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void orderComplete(Long preOrderId) { + // 查询预约订单详情 + HighOrderPre orderPre = findByOrderId(preOrderId); + if (orderPre == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到预约订单"); + } + if (orderPre.getStatus() != 2) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); + } + orderPre.setStatus(3); + orderPre.setUpdateTime(new Date()); + updateOrderPre(orderPre); + + highOrderService.childOrderComplete(orderPre.getChildOrderId()); + } }