From c5cc430b1e12d8c9c39cebf1239c5b97ccc9901f Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Tue, 3 Dec 2024 16:01:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=97=AE=E9=A2=98=E8=A7=A3?= =?UTF-8?q?=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../material/device/mapper/DevInfoMapper.java | 2 +- .../service/impl/DevInfoServiceImpl.java | 8 ++++--- .../order/controller/OrderController.java | 19 +++++++++++++++++ .../material/order/mapper/OrderMapper.java | 3 +++ .../mapper/material/device/DevInfoMapper.xml | 4 ++-- .../mapper/material/order/OrderInfoMapper.xml | 21 +++++++++++++++++++ 6 files changed, 51 insertions(+), 6 deletions(-) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java index 931e2b8..d3d73de 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java @@ -26,7 +26,7 @@ public interface DevInfoMapper { */ DevInfoVo selectDevInfoByMaId(Long maId); - Integer getMaStatusByMaId(Long maId); + DevInfo getMaStatusByMaId(Long maId); int getHotSearchCountByMaId(Long maId); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java index a2c5b9f..f8408d0 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java @@ -536,11 +536,13 @@ public class DevInfoServiceImpl implements DevInfoService { if (CollectionUtil.isNotEmpty(maIds)) { for (Long maId : maIds) { - Integer oldStatus = devInfoMapper.getMaStatusByMaId(maId); + DevInfo dto = devInfoMapper.getMaStatusByMaId(maId); Integer newStatus = devInfo.getMaStatus(); - + if (dto.getDeviceCount() == 0 && newStatus.equals(LISTING.getCode())){ + return AjaxResult.warn("设备ID:" + maId + "库存为0,无法上架"); + } // 根据旧状态和新状态进行状态转换检查 - switch (oldStatus) { + switch (dto.getMaStatus()) { case 0: if (newStatus.equals(TO_BE_LISTED.getCode()) || newStatus.equals(ON_HIRE.getCode())) {continue;} return AjaxResult.warn("设备ID:" + maId + "是草稿状态,只能进行保存操作:" + newStatus); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java index b91bc0c..9240854 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java @@ -11,6 +11,7 @@ import com.bonus.material.order.mapper.OrderMapper; import com.bonus.material.order.service.OrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -77,6 +78,24 @@ public class OrderController extends BaseController { @PostMapping("/updateOrderStatus") public AjaxResult updateOrderStatus(@RequestBody OrderDetailDto orderInfoDto) { String userName = SecurityUtils.getLoginUser().getUsername(); + if (orderInfoDto.getOrderId() == null || StringUtils.isBlank(orderInfoDto.getOrderStatus())) { + return error("参数错误"); + } + if (orderInfoDto.getOrderStatus().equals("5")) { + List dtos = orderMapper.getOrderDetailsByOrderId(orderInfoDto.getOrderId()); + if (dtos.size() > 0) { + for (OrderDetailDto dto : dtos) { + if ("0".equals(dto.getManageType())) { + // 编码设备已退租的重新上架 + dto.setMaStatus("2"); + orderMapper.updateDeviceStatus(dto); + } else { + // 数量设备已退租的增加库存 + orderMapper.updateAddDevCount(dto); + } + } + } + } Integer i = orderMapper.updateOrderStatus(orderInfoDto.getOrderId(), orderInfoDto.getOrderStatus(), userName); if (i > 0) { return success(); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/mapper/OrderMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/mapper/OrderMapper.java index 956098a..17c1f3b 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/mapper/OrderMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/mapper/OrderMapper.java @@ -30,6 +30,9 @@ public interface OrderMapper { Integer updateOrderStatus(@Param("orderId") Integer orderId, @Param("orderStatus") String orderStatus,@Param("userName") String userName); Integer updateDevCount(OrderDetailDto orderDetailDto); + Integer updateAddDevCount(OrderDetailDto orderDetailDto); List selectOrderDetailsByOderId(String orderId); + + List getOrderDetailsByOrderId(Integer orderId); } diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml index 0b7994d..e0cad84 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml @@ -619,8 +619,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + select ma_status,device_count from ma_dev_info where ma_id = #{maId} select device_count,device_name from ma_dev_info where ma_id = #{maId} and is_active = 1 @@ -233,4 +240,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" moi.order_id = #{orderId} and bfi.task_type = 17 GROUP BY hh.ma_id + + \ No newline at end of file