feat(智能柜): 添加格口租赁功能及相关查询接口

添加格口租赁价格和租赁状态字段
新增获取租赁柜体详情接口
修改查询条件支持按租赁状态筛选
This commit is contained in:
dzq 2025-06-26 11:39:40 +08:00
parent 065912f2c7
commit 65a0ceeb2b
8 changed files with 96 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModel;
import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModelFactory;
import com.agileboot.domain.cabinet.smartCabinet.SmartCabinetApplicationService;
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
import com.agileboot.domain.cabinet.smartCabinet.dto.RentingCabinetDetailDTO;
import com.agileboot.domain.cabinet.smartCabinet.model.SmartCabinetModel;
import com.agileboot.domain.cabinet.smartCabinet.model.SmartCabinetModelFactory;
import com.agileboot.domain.mqtt.MqttService;
@ -49,6 +50,11 @@ public class CabinetCellController {
return ResponseDTO.ok(smartCabinetApplicationService.getCabinetDetail(shopId));
}
@GetMapping("/detail/renting")
public ResponseDTO<List<RentingCabinetDetailDTO>> getRentingCabinetDetail(@RequestParam Long shopId) {
return ResponseDTO.ok(smartCabinetApplicationService.getRentingCabinetDetail(shopId));
}
@Operation(summary = "配置格口商品库存")
@PutMapping("/configureGoodsCellsStock/{cellId}/{goodsId}/{stock}")

View File

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@ -51,6 +53,14 @@ public class CabinetCellEntity extends BaseEntity<CabinetCellEntity> {
@TableField("stock")
private Integer stock;
@ApiModelProperty("格口租用价格")
@TableField("cell_price")
private BigDecimal cellPrice;
@ApiModelProperty("是否已租用0-未租用1-已租用")
@TableField("is_rented")
private Integer isRented;
@ApiModelProperty("格口类型1小格 2中格 3大格 4超大格")
@TableField("cell_type")
private Integer cellType;

View File

@ -49,6 +49,12 @@ public class CabinetCellDTO {
@ExcelColumn(name = "库存数量")
private Integer stock;
@ExcelColumn(name = "格口租用价格")
private BigDecimal cellPrice;
@ExcelColumn(name = "是否已租用")
private Integer isRented;
@ExcelColumn(name = "订单数量")
private Integer orderCount;

View File

@ -15,6 +15,9 @@ public class SearchCabinetCellQuery<T> extends AbstractPageQuery<T> {
private Long cabinetId;
private Integer cellNo;
private Integer cellType;
private Integer isRented;
private Integer usageStatus;
private Integer availableStatus;
private Date startTime;
@ -29,6 +32,7 @@ public class SearchCabinetCellQuery<T> extends AbstractPageQuery<T> {
.eq(cabinetId != null, "cabinet_id", cabinetId)
.eq(cellNo != null, "cell_no", cellNo)
.eq(cellType != null, "cell_type", cellType)
.eq(isRented != null, "is_rented", isRented)
.eq(usageStatus != null, "usage_status", usageStatus)
.eq(availableStatus != null, "available_status", availableStatus)
.eq("deleted", false)

View File

@ -15,6 +15,9 @@ public class SearchCabinetCellWithOrdersQuery<T> extends AbstractPageQuery<T> {
private Long cabinetId;
private Integer cellNo;
private Integer cellType;
private Integer isRented;
private Integer usageStatus;
private Integer availableStatus;
private Date startTime;
@ -30,7 +33,8 @@ public class SearchCabinetCellWithOrdersQuery<T> extends AbstractPageQuery<T> {
.eq(cabinetId != null, "cc.cabinet_id", cabinetId)
.eq(cellNo != null, "cc.cell_no", cellNo)
.eq(cellType != null, "cc.cell_type", cellType)
.eq(usageStatus != null, "cc.usage_status", usageStatus)
.eq(isRented != null, "cc.is_rented", isRented)
.eq(usageStatus != null, "cc.usage_status", usageStatus)
.eq(availableStatus != null, "cc.available_status", availableStatus)
.eq("cc.deleted", false)
.like(StringUtils.isNotBlank(goodsName), "sg.goods_name", goodsName)

View File

@ -12,6 +12,7 @@ import com.agileboot.domain.cabinet.mainboard.model.CabinetMainboardModel;
import com.agileboot.domain.cabinet.mainboard.model.CabinetMainboardModelFactory;
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetDO;
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
import com.agileboot.domain.cabinet.smartCabinet.dto.RentingCabinetDetailDTO;
import com.agileboot.domain.common.command.BulkOperationCommand;
import com.agileboot.domain.cabinet.smartCabinet.command.AddSmartCabinetCommand;
import com.agileboot.domain.cabinet.smartCabinet.command.UpdateSmartCabinetCommand;
@ -221,6 +222,47 @@ public class SmartCabinetApplicationService {
return result;
}
/**
* 获取所有智能柜的详细信息
* @return 包含柜体信息单元格信息和商品信息的列表
*/
public List<RentingCabinetDetailDTO> getRentingCabinetDetail(Long shopId) {
// 获取所有智能柜单元格和商品的基础数据
QueryWrapper<SmartCabinetEntity> smartCabinetEntityQueryWrapper = new QueryWrapper<>();
smartCabinetEntityQueryWrapper.eq("shop_id", shopId)
.eq("deleted", false);
List<SmartCabinetEntity> smartCabinets = smartCabinetService.list(smartCabinetEntityQueryWrapper);
QueryWrapper<CabinetCellEntity> cabinetCellEntityQueryWrapper = new QueryWrapper<>();
cabinetCellEntityQueryWrapper.in("cabinet_id",
smartCabinets.stream()
.map(SmartCabinetEntity::getCabinetId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList()))
.eq("is_rented", 0)
.eq("deleted", false);
List<CabinetCellEntity> cabinetCells = cabinetCellService.list(cabinetCellEntityQueryWrapper);
List<RentingCabinetDetailDTO> result = new ArrayList<>();
// 遍历每个智能柜构建详细信息
for (SmartCabinetEntity cabinet : smartCabinets) {
RentingCabinetDetailDTO rentingCabinetDetailDTO = new RentingCabinetDetailDTO();
// 设置柜体基础信息
rentingCabinetDetailDTO.setCabinetId(cabinet.getCabinetId());
rentingCabinetDetailDTO.setCabinetName(cabinet.getCabinetName());
rentingCabinetDetailDTO.setLockControlNo(cabinet.getLockControlNo());
// 将单元格列表加入柜体信息
rentingCabinetDetailDTO.setCells(cabinetCells.stream()
.filter(cell -> cell.getCabinetId().equals(cabinet.getCabinetId()))
.collect(Collectors.toList()));
result.add(rentingCabinetDetailDTO);
}
return result;
}
public List<CabinetMainboardModel> createCabinetMainboardByTemplate(SmartCabinetModel cabinetModel) {
CabinetTemplateEnum template = CabinetTemplateEnum.getByCode(Integer.parseInt(cabinetModel.getTemplateNo()));
if (template == null) {

View File

@ -0,0 +1,14 @@
package com.agileboot.domain.cabinet.smartCabinet.dto;
import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity;
import lombok.Data;
import java.util.List;
@Data
public class RentingCabinetDetailDTO {
private Long cabinetId;
private String cabinetName;
private Integer lockControlNo;
private List<CabinetCellEntity> cells;
}

9
sql/20250625.sql Normal file
View File

@ -0,0 +1,9 @@
ALTER TABLE `cabinet_cell`
ADD COLUMN `cell_price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '格口租用价格'
AFTER `stock`;
ALTER TABLE `cabinet_cell`
ADD COLUMN `is_rented` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已租用0-未租用1-已租用'
AFTER `cell_price`;