设备取消,增加库存 改状态

This commit is contained in:
liang.chao 2024-12-05 10:29:45 +08:00
parent 669ae27f9a
commit bb51e50555
4 changed files with 29 additions and 11 deletions

View File

@ -7,6 +7,7 @@ import com.bonus.material.device.service.SafeBookService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.List;
@ -30,7 +31,7 @@ public class SafeBookController extends BaseController {
@ApiOperation(value = "新增安全证书")
@PostMapping("/addSafeBook")
public AjaxResult addSafeBook(SafeBookInfo safeBookInfo) {
public AjaxResult addSafeBook(@RequestBody SafeBookInfo safeBookInfo) {
Integer i = safeBookService.addSafeBook(safeBookInfo);
if (i > 0) {
return AjaxResult.success("新增成功");
@ -42,7 +43,7 @@ public class SafeBookController extends BaseController {
@ApiOperation(value = "删除安全证书")
@PostMapping("/delSafeBook")
public AjaxResult delSafeBook(SafeBookInfo safeBookInfo) {
public AjaxResult delSafeBook(@RequestBody SafeBookInfo safeBookInfo) {
Integer i = safeBookService.delSafeBook(safeBookInfo);
if (i > 0) {
return AjaxResult.success("删除成功");

View File

@ -546,10 +546,10 @@ public class DevInfoServiceImpl implements DevInfoService {
public AjaxResult updateUpDown(DevInfo devInfo) {
// 检查是否提供了设备ID列表和新状态
if (devInfo == null || CollectionUtil.isEmpty(devInfo.getMaIds())) {
return AjaxResult.warn("请选择设备");
return AjaxResult.error("请选择设备");
}
if (devInfo.getMaStatus() == null) {
return AjaxResult.warn("请选择设备状态");
return AjaxResult.error("请选择设备状态");
}
devInfo.getMaIds().removeIf(Objects::isNull);
@ -560,7 +560,7 @@ public class DevInfoServiceImpl implements DevInfoService {
DevInfo dto = devInfoMapper.getMaStatusByMaId(maId);
Integer newStatus = devInfo.getMaStatus();
if (dto.getDeviceCount() == 0 && newStatus.equals(LISTING.getCode())) {
return AjaxResult.warn("设备ID:" + maId + "库存为0无法上架");
return AjaxResult.error("设备ID:" + maId + "库存为0无法上架");
}
// 根据旧状态和新状态进行状态转换检查
switch (dto.getMaStatus()) {
@ -568,21 +568,21 @@ public class DevInfoServiceImpl implements DevInfoService {
if (newStatus.equals(TO_BE_LISTED.getCode()) || newStatus.equals(ON_HIRE.getCode())) {
continue;
}
return AjaxResult.warn("设备ID:" + maId + "是草稿状态,只能进行保存操作:" + newStatus);
return AjaxResult.error("设备ID:" + maId + "是草稿状态,只能进行保存操作:" + newStatus);
case 1:
if (newStatus.equals(LISTING.getCode()) || newStatus.equals(ON_HIRE.getCode())) {
continue;
}
return AjaxResult.warn("设备ID:" + maId + "已下架,只能进行上下架操作!");
return AjaxResult.error("设备ID:" + maId + "已下架,只能进行上下架操作!");
case 2:
if (newStatus.equals(ON_HIRE.getCode()) || newStatus.equals(LISTING.getCode())) {
continue;
}
return AjaxResult.warn("设备ID:" + maId + "设备已上架,只能进行上下架操作!!");
return AjaxResult.error("设备ID:" + maId + "设备已上架,只能进行上下架操作!!");
case 3:
return AjaxResult.warn("设备ID:" + maId + "设备已出租,非法状态修改!!");
return AjaxResult.error("设备ID:" + maId + "设备已出租,非法状态修改!!");
default:
return AjaxResult.warn("设备ID:" + maId + "设备状态异常,请修改后重试");
return AjaxResult.error("设备ID:" + maId + "设备状态异常,请修改后重试");
}
}

View File

@ -81,6 +81,7 @@ public class OrderController extends BaseController {
if (orderInfoDto.getOrderId() == null || StringUtils.isBlank(orderInfoDto.getOrderStatus())) {
return error("参数错误");
}
// 退租
if (orderInfoDto.getOrderStatus().equals("5")) {
List<OrderDetailDto> dtos = orderMapper.getOrderDetailsByOrderId(orderInfoDto.getOrderId());
if (dtos.size() > 0) {
@ -96,6 +97,22 @@ public class OrderController extends BaseController {
}
}
}
// 取消
if (orderInfoDto.getOrderStatus().equals("7")) {
List<OrderDetailDto> 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();

View File

@ -68,7 +68,7 @@ public class OrderDetailDto {
@ApiModelProperty(value = "日租金")
private BigDecimal dayLeasePrice;
@ApiModelProperty(value = "订单状态0未下单 1已下单 2待出库 3待收货 4租赁中 5已退租 6已完成 7已驳回")
@ApiModelProperty(value = "订单状态0未下单 1已下单 2待出库 3待收货 4租赁中 5已退租 6已完成 7已取消")
private String orderStatus;
@ApiModelProperty(value = "创建日期")