diff --git a/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/CabinetCellController.java b/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/CabinetCellController.java index 0f9ea3f..da7ed3e 100644 --- a/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/CabinetCellController.java +++ b/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/CabinetCellController.java @@ -16,6 +16,7 @@ import io.swagger.v3.oas.annotations.Operation; import java.util.List; import javax.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Slf4j @RestController @RequestMapping("/cabinet/cell") @RequiredArgsConstructor @@ -81,4 +83,24 @@ public class CabinetCellController extends BaseController { cabinetCellApplicationService.configureGoodsCellsStock(cellId, goodsId, stock); return ResponseDTO.ok(); } + + @Operation(summary = "调整格口商品库存") + @AccessLog(title = "格口管理", businessType = BusinessTypeEnum.MODIFY) + @PutMapping("/changeGoodsCellsStock/{cellId}/{stock}") + public ResponseDTO changeGoodsCellsStock(@PathVariable Long cellId, @PathVariable Integer stock) { + if (stock < 0) { + log.error("调整格口商品库存,库存不能小于0"); + return ResponseDTO.fail(); + } + cabinetCellApplicationService.changeGoodsCellsStock(cellId, stock); + return ResponseDTO.ok(); + } + + @Operation(summary = "清空格口商品") + @AccessLog(title = "格口管理", businessType = BusinessTypeEnum.MODIFY) + @PutMapping("/clearGoodsCells/{cellId}") + public ResponseDTO clearGoodsCells(@PathVariable Long cellId) { + cabinetCellApplicationService.clearGoodsCells(cellId); + return ResponseDTO.ok(); + } } \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/CabinetCellApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/CabinetCellApplicationService.java index 99626da..0805b37 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/CabinetCellApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/CabinetCellApplicationService.java @@ -91,4 +91,14 @@ public class CabinetCellApplicationService { model.setUsageStatus(2); model.updateById(); } + + public void changeGoodsCellsStock(Long cellId, Integer stock) { + CabinetCellModel model = cabinetCellModelFactory.loadById(cellId); + model.setStock(stock); + model.updateById(); + } + + public void clearGoodsCells(Long cellId) { + cabinetCellService.clearGoodsIdAndFreeCell(cellId); + } } \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/db/CabinetCellMapper.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/db/CabinetCellMapper.java index 123610b..61d4c06 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/db/CabinetCellMapper.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/db/CabinetCellMapper.java @@ -47,7 +47,7 @@ public interface CabinetCellMapper extends BaseMapper { List selectByGoodsId(@Param("goodsId")Long goodsId); @Update("UPDATE cabinet_cell " + - "SET goods_id = NULL, usage_status = 1 " + + "SET stock = 0, goods_id = NULL, usage_status = 1 " + "WHERE cell_id = #{cellId}") void clearGoodsIdAndFreeCell(@Param("cellId") Long cellId); diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/SearchGoodsDO.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/SearchGoodsDO.java index e42eaaf..57cf0d1 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/SearchGoodsDO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/SearchGoodsDO.java @@ -18,6 +18,8 @@ public class SearchGoodsDO extends ShopGoodsEntity { private String cabinetName; @TableField("cell_no") private Integer cellNo; + @TableField("cell_no_str") + private String cellNoStr; @TableField("total_stock") private Integer totalStock; } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsMapper.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsMapper.java index 3d4f156..7586b14 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsMapper.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsMapper.java @@ -37,13 +37,12 @@ public interface ShopGoodsMapper extends BaseMapper { ); */ @Select("SELECT g.goods_id, g.goods_name, g.category_id, g.price, " + "g.stock, g.status, g.cover_img, SUM(cc.stock) AS total_stock, " + - "GROUP_CONCAT(DISTINCT cc.cell_no) AS cell_no, " + + "GROUP_CONCAT(DISTINCT cc.cell_no) AS cell_no_str, " + "GROUP_CONCAT(DISTINCT sc.cabinet_name) AS cabinet_name " + "FROM shop_goods g " + "LEFT JOIN cabinet_cell cc ON g.goods_id = cc.goods_id AND cc.deleted = 0 " + "LEFT JOIN smart_cabinet sc ON cc.cabinet_id = sc.cabinet_id AND sc.deleted = 0 " + - "${ew.customSqlSegment} " + - "GROUP BY g.goods_id") + "${ew.customSqlSegment} ") Page getGoodsList( Page page, @Param(Constants.WRAPPER) Wrapper queryWrapper diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java index a481b31..40c2c3b 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java @@ -20,7 +20,7 @@ public class ShopGoodsServiceImpl extends ServiceImpl getGoodsList(AbstractPageQuery query) { QueryWrapper wrapper = query.toQueryWrapper(); - wrapper.orderByAsc("sc.cabinet_id IS NULL", "sc.cabinet_id", "cc.cell_no"); +// wrapper.orderByAsc("sc.cabinet_id IS NULL", "sc.cabinet_id", "cc.cell_no"); return baseMapper.getGoodsList(query.toPage(), wrapper); } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/dto/ShopGoodsDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/dto/ShopGoodsDTO.java index d4eb887..e5eda7b 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/dto/ShopGoodsDTO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/dto/ShopGoodsDTO.java @@ -79,6 +79,8 @@ public class ShopGoodsDTO { private String cabinetName; @ExcelColumn(name = "格口号") private Integer cellNo; + @ExcelColumn(name = "格口号") + private String cellNoStr; @ExcelColumn(name = "已分配库存") private Integer totalStock; } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/query/SearchShopGoodsQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/query/SearchShopGoodsQuery.java index 026e8e0..079b751 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/query/SearchShopGoodsQuery.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/query/SearchShopGoodsQuery.java @@ -27,7 +27,8 @@ public class SearchShopGoodsQuery extends AbstractPageQuery { .eq(status != null, "g.status", status) .ge(minPrice != null, "g.price", minPrice) .le(maxPrice != null, "g.price", maxPrice) - .eq("g.deleted", 0); + .eq("g.deleted", 0) + .groupBy("g.goods_id"); this.timeRangeColumn = "create_time";