From fb0ceaaecc4bbf58eadb7ac5aa746c69d568b511 Mon Sep 17 00:00:00 2001 From: dzq Date: Thu, 27 Nov 2025 11:49:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9F=9C=E6=9C=BA=E5=92=8C=E6=A0=BC=E5=8F=A3?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=85=B3=E8=81=94=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在借还记录DTO和查询中新增柜机及格口相关字段 修改查询逻辑以支持状态筛选优化 添加柜机和格口表的DDL定义 --- .../domain/shop/order/db/ShopOrderMapper.java | 6 +++ .../shop/order/dto/BorrowReturnRecordDTO.java | 12 +++++ .../query/SearchBorrowReturnRecordQuery.java | 13 +++-- doc/sql/ddl.sql | 54 ++++++++++++++++++- 4 files changed, 79 insertions(+), 6 deletions(-) diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/db/ShopOrderMapper.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/db/ShopOrderMapper.java index ecfa6a1..eaa96a8 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/db/ShopOrderMapper.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/db/ShopOrderMapper.java @@ -49,6 +49,10 @@ public interface ShopOrderMapper extends BaseMapper { "sog.quantity as quantity, " + "ra.audit_name as auditName, " + "ra.audit_remark as auditRemark, " + + "cc.cell_id as cellId, " + + "cc.cell_no as cellNo, " + + "sc.cabinet_id as cabinetId, " + + "sc.cabinet_name as cabinetName, " + "CASE " + " WHEN ra.approval_id IS NULL THEN 0 " + " WHEN ra.status IN (1, 4) THEN 1 " + @@ -59,6 +63,8 @@ public interface ShopOrderMapper extends BaseMapper { "FROM shop_order so " + "INNER JOIN shop_order_goods sog ON so.order_id = sog.order_id AND sog.deleted = 0 " + "LEFT JOIN return_approval ra ON sog.order_goods_id = ra.order_goods_id AND ra.deleted = 0 " + + "LEFT JOIN cabinet_cell cc ON sog.cell_id = cc.cell_id " + + "LEFT JOIN smart_cabinet sc ON cc.cabinet_id = sc.cabinet_id " + "${ew.customSqlSegment}" + "") Page getBorrowReturnRecordList( diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/dto/BorrowReturnRecordDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/dto/BorrowReturnRecordDTO.java index 20969b7..7ad6467 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/dto/BorrowReturnRecordDTO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/dto/BorrowReturnRecordDTO.java @@ -51,6 +51,18 @@ public class BorrowReturnRecordDTO { @ApiModelProperty("状态描述") private String statusStr; + @ApiModelProperty("格口ID") + private Long cellId; + + @ApiModelProperty("格口号") + private Integer cellNo; + + @ApiModelProperty("柜机ID") + private Long cabinetId; + + @ApiModelProperty("柜机名称") + private String cabinetName; + public String getStatusStr() { if (status == null) return "-"; switch (status) { diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/query/SearchBorrowReturnRecordQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/query/SearchBorrowReturnRecordQuery.java index 1ecec39..e669e5d 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/query/SearchBorrowReturnRecordQuery.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/query/SearchBorrowReturnRecordQuery.java @@ -19,15 +19,18 @@ public class SearchBorrowReturnRecordQuery extends AbstractPageQuery { public QueryWrapper addQueryCondition() { QueryWrapper queryWrapper = new QueryWrapper<>(); - if (status == null || status == 0) { + if (status == null) { + status = -1; + } + queryWrapper.eq("so.pay_status", 2); + if (status == 0) { // 未退还:已支付但没有审批记录的订单商品 - queryWrapper.eq("so.pay_status", 2) - .isNull("ra.approval_id"); + queryWrapper.isNull("ra.approval_id"); } else if (status == 1) { // 待审批:有审批记录且状态为1(待审核)或4(开柜中)的订单 - queryWrapper.eq("ra.status", 1) + queryWrapper.and(wrapper -> wrapper.eq("ra.status", 1) .or() - .eq("ra.status", 4); + .eq("ra.status", 4)); } else if (status == 2) { // 已通过:状态为2(已通过)的审批记录 queryWrapper.eq("ra.status", 2); diff --git a/doc/sql/ddl.sql b/doc/sql/ddl.sql index 24c1c95..180482d 100644 --- a/doc/sql/ddl.sql +++ b/doc/sql/ddl.sql @@ -136,4 +136,56 @@ CREATE TABLE `return_approval` ( CONSTRAINT `fk_return_goods` FOREIGN KEY (`goods_id`) REFERENCES `shop_goods` (`goods_id`), CONSTRAINT `fk_return_order` FOREIGN KEY (`order_id`) REFERENCES `shop_order` (`order_id`), CONSTRAINT `fk_return_order_goods` FOREIGN KEY (`order_goods_id`) REFERENCES `shop_order_goods` (`order_goods_id`) -) ENGINE=InnoDB AUTO_INCREMENT=1448 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品归还审批表'; \ No newline at end of file +) ENGINE=InnoDB AUTO_INCREMENT=1448 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品归还审批表'; + +CREATE TABLE `cabinet_cell` ( + `cell_id` bigint NOT NULL AUTO_INCREMENT COMMENT '格口唯一ID', + `cabinet_id` bigint NOT NULL COMMENT '关联柜机ID', + `mainboard_id` bigint DEFAULT NULL COMMENT '归属主板ID', + `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_price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '格口租用价格', + `is_rented` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已租用:0-未租用,1-已租用', + `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故障)', + `creator_id` bigint NOT NULL DEFAULT '0' COMMENT '创建者ID', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater_id` bigint NOT NULL DEFAULT '0' COMMENT '更新者ID', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志(0存在 1删除)', + PRIMARY KEY (`cell_id`), + KEY `idx_cabinet` (`cabinet_id`), + KEY `idx_usage_status` (`usage_status`), + KEY `idx_available_status` (`available_status`), + KEY `idx_goods` (`goods_id`), + CONSTRAINT `fk_cell_cabinet` FOREIGN KEY (`cabinet_id`) REFERENCES `smart_cabinet` (`cabinet_id`), + CONSTRAINT `fk_cell_goods` FOREIGN KEY (`goods_id`) REFERENCES `shop_goods` (`goods_id`) +) ENGINE=InnoDB AUTO_INCREMENT=1268 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='柜机格口信息表'; + +CREATE TABLE `smart_cabinet` ( + `cabinet_id` bigint NOT NULL AUTO_INCREMENT COMMENT '柜机唯一ID', + `cabinet_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '柜机名称', + `cabinet_type` tinyint NOT NULL DEFAULT '0' COMMENT '柜机类型(0主柜 1副柜)', + `main_cabinet` bigint DEFAULT NULL COMMENT '归属主柜ID', + `balance_enable` tinyint NOT NULL DEFAULT '1' COMMENT '借呗支付(1-正常使用 0-禁止使用)', + `mode` tinyint NOT NULL DEFAULT '0' COMMENT '运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式)', + `belong_type` tinyint NOT NULL DEFAULT '0' COMMENT '归属类型(0-借还柜 1-固资通)', + `shop_id` bigint DEFAULT NULL COMMENT '归属商店ID', + `mqtt_server_id` bigint DEFAULT NULL COMMENT 'MQTT服务ID', + `template_no` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '柜机模版编号', + `lock_control_no` int NOT NULL COMMENT '锁控板序号', + `location` int NOT NULL COMMENT '柜机位置', + `creator_id` bigint NOT NULL DEFAULT '0' COMMENT '创建者ID', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater_id` bigint NOT NULL DEFAULT '0' COMMENT '更新者ID', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志(0存在 1删除)', + `return_deadline` int NOT NULL DEFAULT '0' COMMENT '归还期限(天),0表示不限制', + `corpid` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '企业微信id', + PRIMARY KEY (`cabinet_id`), + KEY `idx_template_no` (`template_no`), + KEY `idx_location` (`location`) +) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='智能柜信息表'; \ No newline at end of file