feat(订单管理): 增加柜机和格口信息关联功能
在借还记录DTO和查询中新增柜机及格口相关字段 修改查询逻辑以支持状态筛选优化 添加柜机和格口表的DDL定义
This commit is contained in:
parent
35870dc1f1
commit
fb0ceaaecc
|
|
@ -49,6 +49,10 @@ public interface ShopOrderMapper extends BaseMapper<ShopOrderEntity> {
|
||||||
"sog.quantity as quantity, " +
|
"sog.quantity as quantity, " +
|
||||||
"ra.audit_name as auditName, " +
|
"ra.audit_name as auditName, " +
|
||||||
"ra.audit_remark as auditRemark, " +
|
"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 " +
|
"CASE " +
|
||||||
" WHEN ra.approval_id IS NULL THEN 0 " +
|
" WHEN ra.approval_id IS NULL THEN 0 " +
|
||||||
" WHEN ra.status IN (1, 4) THEN 1 " +
|
" WHEN ra.status IN (1, 4) THEN 1 " +
|
||||||
|
|
@ -59,6 +63,8 @@ public interface ShopOrderMapper extends BaseMapper<ShopOrderEntity> {
|
||||||
"FROM shop_order so " +
|
"FROM shop_order so " +
|
||||||
"INNER JOIN shop_order_goods sog ON so.order_id = sog.order_id AND sog.deleted = 0 " +
|
"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 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}" +
|
"${ew.customSqlSegment}" +
|
||||||
"</script>")
|
"</script>")
|
||||||
Page<BorrowReturnRecordDTO> getBorrowReturnRecordList(
|
Page<BorrowReturnRecordDTO> getBorrowReturnRecordList(
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,18 @@ public class BorrowReturnRecordDTO {
|
||||||
@ApiModelProperty("状态描述")
|
@ApiModelProperty("状态描述")
|
||||||
private String statusStr;
|
private String statusStr;
|
||||||
|
|
||||||
|
@ApiModelProperty("格口ID")
|
||||||
|
private Long cellId;
|
||||||
|
|
||||||
|
@ApiModelProperty("格口号")
|
||||||
|
private Integer cellNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("柜机ID")
|
||||||
|
private Long cabinetId;
|
||||||
|
|
||||||
|
@ApiModelProperty("柜机名称")
|
||||||
|
private String cabinetName;
|
||||||
|
|
||||||
public String getStatusStr() {
|
public String getStatusStr() {
|
||||||
if (status == null) return "-";
|
if (status == null) return "-";
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,18 @@ public class SearchBorrowReturnRecordQuery<T> extends AbstractPageQuery<T> {
|
||||||
public QueryWrapper<T> addQueryCondition() {
|
public QueryWrapper<T> addQueryCondition() {
|
||||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<T> 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)
|
queryWrapper.isNull("ra.approval_id");
|
||||||
.isNull("ra.approval_id");
|
|
||||||
} else if (status == 1) {
|
} else if (status == 1) {
|
||||||
// 待审批:有审批记录且状态为1(待审核)或4(开柜中)的订单
|
// 待审批:有审批记录且状态为1(待审核)或4(开柜中)的订单
|
||||||
queryWrapper.eq("ra.status", 1)
|
queryWrapper.and(wrapper -> wrapper.eq("ra.status", 1)
|
||||||
.or()
|
.or()
|
||||||
.eq("ra.status", 4);
|
.eq("ra.status", 4));
|
||||||
} else if (status == 2) {
|
} else if (status == 2) {
|
||||||
// 已通过:状态为2(已通过)的审批记录
|
// 已通过:状态为2(已通过)的审批记录
|
||||||
queryWrapper.eq("ra.status", 2);
|
queryWrapper.eq("ra.status", 2);
|
||||||
|
|
|
||||||
|
|
@ -136,4 +136,56 @@ CREATE TABLE `return_approval` (
|
||||||
CONSTRAINT `fk_return_goods` FOREIGN KEY (`goods_id`) REFERENCES `shop_goods` (`goods_id`),
|
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` 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`)
|
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='商品归还审批表';
|
) 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='智能柜信息表';
|
||||||
Loading…
Reference in New Issue