wip: 开发订单导入功能

This commit is contained in:
ah--desktop
2025-11-24 00:33:54 +08:00
parent 0921ff9fc5
commit 6776a5badc
26 changed files with 687 additions and 36 deletions
@@ -60,7 +60,7 @@ public class ImportFieldDefController {
}
@Operation(summary = "获取指定类型所有字段列表", description = "根据导入类型获取所有字段定义列表")
@GetMapping("/list-by-type/all/{type}")
@GetMapping("/all/{type}")
@RequireRole(description = "获取字段定义列表", allowUser = true)
public ApiResponse<List<ImportFieldDefVO>> getFieldDefsByType(
@Parameter(description = "导入类型", example = "product") @PathVariable String type) {
@@ -35,6 +35,12 @@ public class CreateImportFieldDefDTO {
@NotBlank(message = "字段标签不能为空")
private String fieldLabel;
/**
* 文件字段名,如 商品名称
*/
@Schema(description = "文件字段名", example = "商品名称")
private String fileFieldName;
/**
* 是否必填
*/
@@ -19,6 +19,12 @@ public class UpdateImportFieldDefDTO {
@NotBlank(message = "字段标签不能为空")
private String fieldLabel;
/**
* 文件字段名,如 商品名称
*/
@Schema(description = "文件字段名", example = "商品名称")
private String fileFieldName;
/**
* 是否必填
*/
@@ -2,6 +2,7 @@ package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importtask;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
@@ -12,6 +13,13 @@ import lombok.Data;
@Schema(description = "创建导入任务DTO")
public class CreateImportTaskDTO {
/**
* 所属店铺ID
*/
@Schema(description = "所属店铺ID", example = "1", required = true)
@NotNull(message = "店铺ID不能为空")
private Long shopId;
/**
* 导入类型(product-商品 order-订单)
*/
@@ -10,6 +10,12 @@ import lombok.Data;
@Schema(description = "导入任务过滤DTO")
public class ImportTaskFilterDTO {
/**
* 所属店铺ID
*/
@Schema(description = "所属店铺ID", example = "1")
private Long shopId;
/**
* 导入类型(product-商品 order-订单)
*/
@@ -38,6 +38,12 @@ public class ImportFieldDefPO {
@TableField("field_label")
private String fieldLabel;
/**
* 文件字段名,如 商品名称
*/
@TableField("file_field_name")
private String fileFieldName;
/**
* 是否必填
*/
@@ -26,6 +26,12 @@ public class ImportTaskPO {
@TableField("company_id")
private Long companyId;
/**
* 所属店铺ID
*/
@TableField("shop_id")
private Long shopId;
/**
* 导入类型(product-商品 order-订单)
*/
@@ -36,6 +36,12 @@ public class ImportFieldDefVO {
@Schema(description = "中文字段名", example = "商品名称")
private String fieldLabel;
/**
* 文件字段名,如 商品名称
*/
@Schema(description = "文件字段名", example = "商品名称")
private String fileFieldName;
/**
* 是否必填
*/
@@ -24,6 +24,12 @@ public class ImportTaskVO {
@Schema(description = "所属公司ID", example = "1")
private Long companyId;
/**
* 所属店铺ID
*/
@Schema(description = "所属店铺ID", example = "1")
private Long shopId;
/**
* 导入类型(product-商品 order-订单)
*/
@@ -77,6 +77,9 @@ public class ImportTaskServiceImpl extends ServiceImpl<ImportTaskMapper, ImportT
wrapper.eq(ImportTaskPO::getCompanyId, companyId);
if (filter != null) {
if (filter.getShopId() != null) {
wrapper.eq(ImportTaskPO::getShopId, filter.getShopId());
}
if (StringUtils.hasText(filter.getType())) {
wrapper.eq(ImportTaskPO::getType, filter.getType());
}
@@ -194,6 +194,7 @@ CREATE TABLE `ec_promotion_fee` (
CREATE TABLE `ec_import_tasks` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`company_id` bigint unsigned NOT NULL COMMENT '所属公司ID',
`shop_id` bigint unsigned NOT NULL COMMENT '所属店铺ID',
`type` enum('product','order') NOT NULL COMMENT '导入类型(product-商品 order-订单)',
`file_name` varchar(255) NOT NULL COMMENT '原始文件名',
`file_path` varchar(500) NOT NULL COMMENT '存储路径',
@@ -210,9 +211,11 @@ CREATE TABLE `ec_import_tasks` (
PRIMARY KEY (`id`),
KEY `idx_company_id` (`company_id`),
KEY `idx_shop_id` (`shop_id`),
KEY `idx_create_by` (`create_by`),
KEY `idx_update_by` (`update_by`),
CONSTRAINT `fk_import_task_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_import_task_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_import_task_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `fk_import_task_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-导入任务表';
@@ -241,6 +244,7 @@ CREATE TABLE `ec_import_field_defs` (
`type` enum('product','order') NOT NULL COMMENT '导入类型(product-商品 order-订单)',
`field_name` varchar(100) NOT NULL COMMENT '数据库字段名,如 name',
`field_label` varchar(100) NOT NULL COMMENT '中文字段名,如 商品名称',
`file_field_name` varchar(100) DEFAULT NULL COMMENT '文件字段名,如 商品名称',
`required` tinyint(1) DEFAULT 0 COMMENT '是否必填',
`sort` int unsigned DEFAULT 0 COMMENT '排序',
`data_type` varchar(50) DEFAULT 'string' COMMENT 'string, number, date等',