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 d855883..0f9ea3f 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 @@ -73,4 +73,12 @@ public class CabinetCellController extends BaseController { cabinetCellApplicationService.configureGoodsCells(cellId, goodsId); return ResponseDTO.ok(); } + + @Operation(summary = "配置格口商品库存") + @AccessLog(title = "格口管理", businessType = BusinessTypeEnum.MODIFY) + @PutMapping("/configureGoodsCellsStock/{cellId}/{goodsId}/{stock}") + public ResponseDTO configureGoodsCellsStock(@PathVariable Long cellId, @PathVariable Long goodsId, @PathVariable Integer stock) { + cabinetCellApplicationService.configureGoodsCellsStock(cellId, goodsId, stock); + return ResponseDTO.ok(); + } } \ No newline at end of file diff --git a/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/SmartCabinetController.java b/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/SmartCabinetController.java index 097f988..04c3f48 100644 --- a/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/SmartCabinetController.java +++ b/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/SmartCabinetController.java @@ -71,6 +71,11 @@ public class SmartCabinetController extends BaseController { return ResponseDTO.ok(); } + @Operation(summary = "获取所有柜机数据") + @GetMapping("/allCabinets") + public ResponseDTO> allCabinets() { + return ResponseDTO.ok(smartCabinetApplicationService.selectAll()); + } @Operation(summary = "获取所有柜机和格口数据") @GetMapping("/all") 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 db9d633..99626da 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 @@ -10,6 +10,8 @@ import com.agileboot.domain.cabinet.cell.dto.CabinetCellDTO; import com.agileboot.domain.cabinet.cell.model.CabinetCellModel; import com.agileboot.domain.cabinet.cell.model.CabinetCellModelFactory; import com.agileboot.domain.cabinet.cell.query.SearchCabinetCellQuery; +import com.agileboot.domain.shop.goods.db.ShopGoodsEntity; +import com.agileboot.domain.shop.goods.db.ShopGoodsService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import java.util.List; import java.util.stream.Collectors; @@ -24,11 +26,25 @@ import org.springframework.web.bind.annotation.PathVariable; public class CabinetCellApplicationService { private final CabinetCellService cabinetCellService; private final CabinetCellModelFactory cabinetCellModelFactory; + private final ShopGoodsService shopGoodsService; public PageDTO getCabinetCellList(SearchCabinetCellQuery query) { Page page = cabinetCellService.getCellList(query); + List goodsList = shopGoodsService.selectAll(); List dtoList = page.getRecords().stream() - .map(CabinetCellDTO::new) + .map(cell -> { + CabinetCellDTO dto = new CabinetCellDTO(cell); + ShopGoodsEntity goods = goodsList.stream() + .filter(g -> g.getGoodsId().equals(cell.getGoodsId())) + .findFirst() + .orElse(null); + if (goods != null) { + dto.setGoodsName(goods.getGoodsName()); + dto.setPrice(goods.getPrice()); + dto.setCoverImg(goods.getCoverImg()); + } + return dto; + }) .collect(Collectors.toList()); return new PageDTO<>(dtoList, page.getTotal()); } @@ -67,4 +83,12 @@ public class CabinetCellApplicationService { model.setUsageStatus(2); model.updateById(); } + + public void configureGoodsCellsStock(Long cellId, Long goodsId, Integer stock) { + CabinetCellModel model = cabinetCellModelFactory.loadById(cellId); + model.setGoodsId(goodsId); + model.setStock(stock); + model.setUsageStatus(2); + model.updateById(); + } } \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/db/CabinetCellEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/db/CabinetCellEntity.java index 88cc4e6..3b52a46 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/db/CabinetCellEntity.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/db/CabinetCellEntity.java @@ -43,6 +43,10 @@ public class CabinetCellEntity extends BaseEntity { @TableField("pin_no") private Integer pinNo; + @ApiModelProperty("库存数量") + @TableField("stock") + private Integer stock; + @ApiModelProperty("格口类型(1小格 2中格 3大格 4超大格)") @TableField("cell_type") private Integer cellType; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/dto/CabinetCellDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/dto/CabinetCellDTO.java index 0db69ac..84f9570 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/dto/CabinetCellDTO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/dto/CabinetCellDTO.java @@ -8,6 +8,8 @@ import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity; import com.agileboot.domain.system.user.db.SysUserEntity; import lombok.Data; +import java.math.BigDecimal; + @ExcelSheet(name = "柜机格口信息列表") @Data public class CabinetCellDTO { @@ -35,6 +37,9 @@ public class CabinetCellDTO { @ExcelColumn(name = "针脚序号") private Integer pinNo; + @ExcelColumn(name = "库存数量") + private Integer stock; + @ExcelColumn(name = "格口类型") private Integer cellType; @@ -47,6 +52,13 @@ public class CabinetCellDTO { @ExcelColumn(name = "关联商品ID") private Long goodsId; + @ExcelColumn(name = "商品名称") + private String goodsName; + @ExcelColumn(name = "商品价格") + private BigDecimal price; + @ExcelColumn(name = "封面图URL") + private String coverImg; + @ExcelColumn(name = "操作人") private String operator; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalEntity.java index ad32352..9b56575 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalEntity.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalEntity.java @@ -84,6 +84,21 @@ public class ReturnApprovalEntity extends BaseEntity { @TableField(exist = false) private String coverImg; + @ApiModelProperty("手机号码") + @TableField(exist = false) + private String mobile; + + @ApiModelProperty("企业微信用户ID或汇邦云用户ID") + @TableField(exist = false) + private String userid; + + @ApiModelProperty("用户姓名") + @TableField(exist = false) + private String name; + + @ApiModelProperty("是否内部用户(0否 1汇邦云用户 2企业微信用户)") + @TableField(exist = false) + private Integer isInternal; @Override public Serializable pkVal() { diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalMapper.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalMapper.java index a507c94..169d2f2 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalMapper.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalMapper.java @@ -18,9 +18,11 @@ import org.apache.ibatis.annotations.Select; */ public interface ReturnApprovalMapper extends BaseMapper { - @Select("SELECT ra.*, sog.goods_name AS goodsName, sog.cover_img AS coverImg " + + @Select("SELECT ra.*, sog.goods_name AS goodsName, sog.cover_img AS coverImg, " + + "so.mobile, so.userid, so.name, so.is_internal AS isInternal " + "FROM return_approval ra " + - "LEFT JOIN shop_order_goods sog ON ra.order_goods_id = sog.order_goods_id " + + "LEFT JOIN shop_order so ON ra.order_id = so.order_id AND so.deleted = 0 " + + "LEFT JOIN shop_order_goods sog ON ra.order_goods_id = sog.order_goods_id AND sog.deleted = 0 " + "${ew.customSqlSegment}") Page selectApprovalWithGoodsInfo(Page page, @Param(Constants.WRAPPER) Wrapper queryWrapper); 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 1f60691..e42eaaf 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,4 +18,6 @@ public class SearchGoodsDO extends ShopGoodsEntity { private String cabinetName; @TableField("cell_no") private Integer cellNo; + @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 deae2d6..7a43c3f 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 @@ -23,7 +23,7 @@ public interface ShopGoodsMapper extends BaseMapper { * @param queryWrapper 查询条件 * @return 商品分页列表 */ - @Select("SELECT g.goods_id, g.goods_name, g.category_id, g.price, " + + /* @Select("SELECT g.goods_id, g.goods_name, g.category_id, g.price, " + "g.stock, g.status, g.cover_img, c.category_name, " + "sc.cabinet_id, sc.cabinet_name, cc.cell_no " + "FROM shop_goods g " + @@ -34,6 +34,19 @@ public interface ShopGoodsMapper extends BaseMapper { Page getGoodsList( Page page, @Param(Constants.WRAPPER) Wrapper queryWrapper + ); */ + @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 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") + Page getGoodsList( + Page page, + @Param(Constants.WRAPPER) Wrapper queryWrapper ); /** 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 b6de37e..d4eb887 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 @@ -18,7 +18,9 @@ public class ShopGoodsDTO { public ShopGoodsDTO(ShopGoodsEntity entity) { if (entity != null) { BeanUtil.copyProperties(entity, this); - + if (this.getTotalStock() == null) { + this.setTotalStock(0); + } /* ShopCategoryEntity category = CacheCenter.categoryCache.get(entity.getCategoryId() + ""); if (category != null) { this.categoryName = category.getCategoryName(); @@ -77,4 +79,6 @@ public class ShopGoodsDTO { private String cabinetName; @ExcelColumn(name = "格口号") private Integer cellNo; + @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 760ffec..026e8e0 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 @@ -23,7 +23,7 @@ public class SearchShopGoodsQuery extends AbstractPageQuery { queryWrapper .like(StrUtil.isNotEmpty(goodsName), "g.goods_name", goodsName) - .eq(categoryId != null, "g.category_id", categoryId) + .eq(categoryId != null, "cc.cabinet_id", categoryId) .eq(status != null, "g.status", status) .ge(minPrice != null, "g.price", minPrice) .le(maxPrice != null, "g.price", maxPrice) diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java index e23c003..d1b5577 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java @@ -124,6 +124,7 @@ public class OrderApplicationService { orderModel.setMobile(command.getMobile()); orderModel.setIsInternal(command.getIsInternal()); orderModel.setUserid(command.getQyUserid()); + orderModel.setName(command.getName()); orderModel.insert(); processOrderGoods(orderModel, goodsList); diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/command/SubmitOrderCommand.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/command/SubmitOrderCommand.java index a7e7a5f..6a0c701 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/command/SubmitOrderCommand.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/command/SubmitOrderCommand.java @@ -31,6 +31,9 @@ public class SubmitOrderCommand { @ApiModelProperty("企业微信用户ID或汇邦云用户ID") private String qyUserid; + @ApiModelProperty("用户姓名") + private String name; + @ApiModelProperty("是否内部订单 0否 1汇邦云用户 2企业微信用户") private Integer isInternal; } \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/db/ShopOrderEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/db/ShopOrderEntity.java index ffbce36..553cd32 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/db/ShopOrderEntity.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/db/ShopOrderEntity.java @@ -53,6 +53,10 @@ public class ShopOrderEntity extends BaseEntity { @TableField("userid") private String userid; + @ApiModelProperty("用户姓名") + @TableField("name") + private String name; + @ApiModelProperty("是否内部用户(0否 1汇邦云用户 2企业微信用户)") @TableField("is_internal") private Integer isInternal; diff --git a/sql/20250317.sql b/sql/20250317.sql index aee9e68..ec5b916 100644 --- a/sql/20250317.sql +++ b/sql/20250317.sql @@ -25,6 +25,7 @@ CREATE TABLE `cabinet_cell` ( `goods_id` BIGINT DEFAULT NULL COMMENT '关联商品ID', `cell_no` INT NOT NULL COMMENT '格口号', `pin_no` INT NOT NULL COMMENT '针脚序号', + `stock` INT NOT NULL DEFAULT 0 COMMENT '库存数量', `cell_type` TINYINT NOT NULL DEFAULT 1 COMMENT '格口类型(1小格 2中格 3大格 4超大格)', `usage_status` TINYINT NOT NULL DEFAULT 1 COMMENT '使用状态(1空闲 2已占用)', `available_status` TINYINT NOT NULL DEFAULT 1 COMMENT '可用状态(1正常 2故障)', diff --git a/sql/20250328_return_approval.sql b/sql/20250328_return_approval.sql index c9e77a2..4992aa6 100644 --- a/sql/20250328_return_approval.sql +++ b/sql/20250328_return_approval.sql @@ -67,5 +67,5 @@ ADD COLUMN `is_internal` TINYINT(1) DEFAULT 0 COMMENT '是否内部用户(0否 ALTER TABLE `shop_order` ADD COLUMN `userid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信用户ID或汇邦云用户ID' AFTER `mobile`; -ALTER TABLE `cabinet_cell` -ADD COLUMN `stock` INT NOT NULL DEFAULT 0 COMMENT '库存数量' AFTER `pin_no`; +ALTER TABLE `shop_order` +ADD COLUMN `name` varchar(30) DEFAULT NULL COMMENT '成员名称' AFTER `mobile`;