mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:59:20 +08:00
1
This commit is contained in:
+27
-13
@@ -7,14 +7,17 @@ import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.CreateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopProductFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopStatisticsQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.UpdateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopProductDetailVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopStatisticsVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ShopService;
|
||||
import top.xyquan.ecomdmbbackend.modules.media.model.vo.MediaImageVO;
|
||||
@@ -82,19 +85,30 @@ public class ShopController {
|
||||
return ApiResponse.success(mediaImageVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据名称精准查询店铺", description = "根据店铺名称精准查询店铺信息,用于数据导入")
|
||||
@GetMapping("/find-by-name/{name}")
|
||||
@RequireRole(description = "根据名称查询店铺", allowUser = true)
|
||||
public ApiResponse<ShopVO> getShopByName(@Parameter(description = "店铺名称") @PathVariable String name) {
|
||||
ShopVO shopVO = shopService.getShopByName(name);
|
||||
return ApiResponse.success(shopVO);
|
||||
@Operation(summary = "获取店铺当月统计信息", description = "获取当前店铺当月的销售额、订单数、客单价、成本、退款金额、推广费、费比等统计信息")
|
||||
@GetMapping("/statistics/current-month/{id}")
|
||||
@RequireRole(description = "查询店铺当月统计", allowUser = true)
|
||||
public ApiResponse<ShopStatisticsVO> getShopCurrentMonthStatistics(
|
||||
@Parameter(description = "店铺ID") @PathVariable Long id) {
|
||||
ShopStatisticsVO statistics = shopService.getShopCurrentMonthStatistics(id);
|
||||
return ApiResponse.success(statistics);
|
||||
}
|
||||
|
||||
@Operation(summary = "批量根据名称查询店铺", description = "批量根据店铺名称精准查询店铺信息,用于数据导入")
|
||||
@PostMapping("/find-by-names")
|
||||
@RequireRole(description = "批量根据名称查询店铺", allowUser = true)
|
||||
public ApiResponse<List<ShopVO>> getShopsByNames(@RequestBody List<String> names) {
|
||||
List<ShopVO> shopVOs = shopService.getShopsByNames(names);
|
||||
return ApiResponse.success(shopVOs);
|
||||
@Operation(summary = "获取店铺统计信息", description = "通过维度参数和时间范围返回不同维度指定时间的统计信息(销售额、订单数、客单价、成本、退款金额、推广费、费比)")
|
||||
@PostMapping("/statistics")
|
||||
@RequireRole(description = "查询店铺统计", allowUser = true)
|
||||
public ApiResponse<ShopStatisticsVO> getShopStatistics(
|
||||
@Valid @RequestBody ShopStatisticsQueryDTO queryDTO) {
|
||||
ShopStatisticsVO statistics = shopService.getShopStatistics(queryDTO);
|
||||
return ApiResponse.success(statistics);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取店铺商品详细信息", description = "分页获取店铺商品的详细信息,包含商品基础信息和统计数据(销售额、订单数、客单价),支持按商品名称、商品编码筛选,日期参数不传默认为当日")
|
||||
@PostMapping("/products/page")
|
||||
@RequireRole(description = "查询店铺商品列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<ShopProductDetailVO>> getShopProductPage(
|
||||
@Valid @RequestBody PageQueryDTO<ShopProductFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<ShopProductDetailVO> result = shopService.getShopProductPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ShopProductRelationPO;
|
||||
|
||||
/**
|
||||
* 店铺商品关联Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface ShopProductRelationMapper extends BaseMapper<ShopProductRelationPO> {
|
||||
}
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ public class BatchSortImportFieldDefDTO {
|
||||
/**
|
||||
* 排序项列表
|
||||
*/
|
||||
@Schema(description = "排序项列表", required = true)
|
||||
@Schema(description = "排序项列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Valid
|
||||
@NotNull(message = "排序项列表不能为空")
|
||||
private List<FieldDefSortItem> sortItems;
|
||||
@@ -39,14 +39,14 @@ public class BatchSortImportFieldDefDTO {
|
||||
/**
|
||||
* 字段定义ID
|
||||
*/
|
||||
@Schema(description = "字段定义ID", example = "1", required = true)
|
||||
@Schema(description = "字段定义ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "字段定义ID不能为空")
|
||||
private Long fieldDefId;
|
||||
|
||||
/**
|
||||
* 排序值
|
||||
*/
|
||||
@Schema(description = "排序值", example = "0", required = true)
|
||||
@Schema(description = "排序值", example = "0", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "排序值不能为空")
|
||||
@Min(value = 0, message = "排序值不能小于0")
|
||||
private Integer sort;
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@ public class CreateImportFieldDefDTO {
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product", required = true, allowableValues = {"product", "order"})
|
||||
@Schema(description = "导入类型", example = "product", requiredMode = Schema.RequiredMode.REQUIRED, allowableValues = {"product", "order"})
|
||||
@NotBlank(message = "导入类型不能为空")
|
||||
@Pattern(regexp = "^(product|order)$", message = "导入类型只能是product或order")
|
||||
private String type;
|
||||
@@ -24,14 +24,14 @@ public class CreateImportFieldDefDTO {
|
||||
/**
|
||||
* 数据库字段名,如 name
|
||||
*/
|
||||
@Schema(description = "数据库字段名", example = "name", required = true)
|
||||
@Schema(description = "数据库字段名", example = "name", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字段名不能为空")
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 中文字段名,如 商品名称
|
||||
*/
|
||||
@Schema(description = "中文字段名", example = "商品名称", required = true)
|
||||
@Schema(description = "中文字段名", example = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字段标签不能为空")
|
||||
private String fieldLabel;
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class UpdateImportFieldDefDTO {
|
||||
/**
|
||||
* 中文字段名,如 商品名称
|
||||
*/
|
||||
@Schema(description = "中文字段名", example = "商品名称", required = true)
|
||||
@Schema(description = "中文字段名", example = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字段标签不能为空")
|
||||
private String fieldLabel;
|
||||
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@ public class CreateImportMappingDTO {
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product", required = true, allowableValues = {"product", "order"})
|
||||
@Schema(description = "导入类型", example = "product", requiredMode = Schema.RequiredMode.REQUIRED, allowableValues = {"product", "order"})
|
||||
@NotBlank(message = "导入类型不能为空")
|
||||
@Pattern(regexp = "^(product|order)$", message = "导入类型只能是product或order")
|
||||
private String type;
|
||||
@@ -23,14 +23,14 @@ public class CreateImportMappingDTO {
|
||||
/**
|
||||
* 映射名称
|
||||
*/
|
||||
@Schema(description = "映射名称", example = "商品导入映射模板", required = true)
|
||||
@Schema(description = "映射名称", example = "商品导入映射模板", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "映射名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字段映射(JSON格式)
|
||||
*/
|
||||
@Schema(description = "字段映射(JSON格式)", example = "{\"商品名称\":\"name\",\"价格(元)\":\"price\"}", required = true)
|
||||
@Schema(description = "字段映射(JSON格式)", example = "{\"商品名称\":\"name\",\"价格(元)\":\"price\"}", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字段映射不能为空")
|
||||
private String mapping;
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public class UpdateImportMappingDTO {
|
||||
/**
|
||||
* 字段映射(JSON格式)
|
||||
*/
|
||||
@Schema(description = "字段映射(JSON格式)", example = "{\"商品名称\":\"name\",\"价格(元)\":\"price\"}", required = true)
|
||||
@Schema(description = "字段映射(JSON格式)", example = "{\"商品名称\":\"name\",\"价格(元)\":\"price\"}", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字段映射不能为空")
|
||||
private String mapping;
|
||||
}
|
||||
|
||||
+4
-4
@@ -16,14 +16,14 @@ public class CreateImportTaskDTO {
|
||||
/**
|
||||
* 所属店铺ID
|
||||
*/
|
||||
@Schema(description = "所属店铺ID", example = "1", required = true)
|
||||
@Schema(description = "所属店铺ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "店铺ID不能为空")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product", required = true, allowableValues = {"product", "order"})
|
||||
@Schema(description = "导入类型", example = "product", requiredMode = Schema.RequiredMode.REQUIRED, allowableValues = {"product", "order"})
|
||||
@NotBlank(message = "导入类型不能为空")
|
||||
@Pattern(regexp = "^(product|order)$", message = "导入类型只能是product或order")
|
||||
private String type;
|
||||
@@ -31,14 +31,14 @@ public class CreateImportTaskDTO {
|
||||
/**
|
||||
* 原始文件名
|
||||
*/
|
||||
@Schema(description = "原始文件名", example = "商品导入.xlsx", required = true)
|
||||
@Schema(description = "原始文件名", example = "商品导入.xlsx", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "文件名不能为空")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
@Schema(description = "存储路径", example = "/uploads/import/2025/01/xxx.xlsx", required = true)
|
||||
@Schema(description = "存储路径", example = "/uploads/import/2025/01/xxx.xlsx", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "存储路径不能为空")
|
||||
private String filePath;
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class BatchImportOrderDTO {
|
||||
/**
|
||||
* 订单列表
|
||||
*/
|
||||
@Schema(description = "订单列表", required = true)
|
||||
@Schema(description = "订单列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "订单列表不能为空")
|
||||
@Valid
|
||||
private List<CreateOrderDTO> orders;
|
||||
|
||||
+9
-9
@@ -18,7 +18,7 @@ public class CreateOrderDTO {
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1", required = true)
|
||||
@Schema(description = "店铺ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "店铺ID不能为空")
|
||||
private Long shopId;
|
||||
|
||||
@@ -31,28 +31,28 @@ public class CreateOrderDTO {
|
||||
/**
|
||||
* 订单状态ID
|
||||
*/
|
||||
@Schema(description = "订单状态ID", example = "1", required = true)
|
||||
@Schema(description = "订单状态ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "订单状态ID不能为空")
|
||||
private Long statusId;
|
||||
|
||||
/**
|
||||
* 商家实收金额
|
||||
*/
|
||||
@Schema(description = "商家实收金额", example = "9999.00", required = true)
|
||||
@Schema(description = "商家实收金额", example = "9999.00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "商家实收金额不能为空")
|
||||
private BigDecimal receivedAmount;
|
||||
|
||||
/**
|
||||
* 下单时间
|
||||
*/
|
||||
@Schema(description = "下单时间", example = "2024-01-01T10:00:00", required = true)
|
||||
@Schema(description = "下单时间", example = "2024-01-01T10:00:00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "下单时间不能为空")
|
||||
private LocalDateTime orderDate;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(description = "商品ID", example = "1", required = true)
|
||||
@Schema(description = "商品ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "商品ID不能为空")
|
||||
private Long productId;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class CreateOrderDTO {
|
||||
/**
|
||||
* 商品名称(冗余存储)
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", required = true)
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "商品名称不能为空")
|
||||
private String productName;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class CreateOrderDTO {
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@Schema(description = "数量", example = "1", required = true)
|
||||
@Schema(description = "数量", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "数量不能为空")
|
||||
@Positive(message = "数量必须大于0")
|
||||
private Integer quantity;
|
||||
@@ -86,14 +86,14 @@ public class CreateOrderDTO {
|
||||
/**
|
||||
* 销售单价
|
||||
*/
|
||||
@Schema(description = "销售单价", example = "9999.00", required = true)
|
||||
@Schema(description = "销售单价", example = "9999.00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "销售单价不能为空")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
/**
|
||||
* 成本价(下单时快照)
|
||||
*/
|
||||
@Schema(description = "成本价", example = "8000.00", required = true)
|
||||
@Schema(description = "成本价", example = "8000.00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "成本价不能为空")
|
||||
private BigDecimal costPrice;
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class CreateOrderStatusDTO {
|
||||
/**
|
||||
* 状态名称
|
||||
*/
|
||||
@Schema(description = "状态名称", example = "待发货", required = true)
|
||||
@Schema(description = "状态名称", example = "待发货", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "状态名称不能为空")
|
||||
private String statusName;
|
||||
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@ public class UpdateOrderDTO {
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1", required = true)
|
||||
@Schema(description = "店铺ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "店铺ID不能为空")
|
||||
private Long shopId;
|
||||
|
||||
@@ -36,14 +36,14 @@ public class UpdateOrderDTO {
|
||||
/**
|
||||
* 商家实收金额
|
||||
*/
|
||||
@Schema(description = "商家实收金额", example = "9999.00", required = true)
|
||||
@Schema(description = "商家实收金额", example = "9999.00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "商家实收金额不能为空")
|
||||
private BigDecimal receivedAmount;
|
||||
|
||||
/**
|
||||
* 下单时间
|
||||
*/
|
||||
@Schema(description = "下单时间", example = "2024-01-01T10:00:00", required = true)
|
||||
@Schema(description = "下单时间", example = "2024-01-01T10:00:00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "下单时间不能为空")
|
||||
private LocalDateTime orderDate;
|
||||
|
||||
|
||||
+3
-3
@@ -15,21 +15,21 @@ public class UpdateOrderStatusDTO {
|
||||
/**
|
||||
* 状态ID
|
||||
*/
|
||||
@Schema(description = "状态ID", example = "1", required = true)
|
||||
@Schema(description = "状态ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "状态ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
@Schema(description = "状态码", example = "0", required = true)
|
||||
@Schema(description = "状态码", example = "0", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "状态码不能为空")
|
||||
private Integer statusCode;
|
||||
|
||||
/**
|
||||
* 状态名称
|
||||
*/
|
||||
@Schema(description = "状态名称", example = "待发货", required = true)
|
||||
@Schema(description = "状态名称", example = "待发货", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "状态名称不能为空")
|
||||
private String statusName;
|
||||
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ public class CreateProductDTO {
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", required = true)
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "商品名称不能为空")
|
||||
private String name;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CreateProductDTO {
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
@Schema(description = "规格名称", example = "128GB 深空黑色", required = true)
|
||||
@Schema(description = "规格名称", example = "128GB 深空黑色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "规格名称不能为空")
|
||||
private String name;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class CreateProductDTO {
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
@Schema(description = "成本价", example = "8000.00", required = true)
|
||||
@Schema(description = "成本价", example = "8000.00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "成本价不能为空")
|
||||
private BigDecimal costPrice;
|
||||
}
|
||||
|
||||
+3
-3
@@ -17,14 +17,14 @@ public class CreateProductSpecDTO {
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(description = "商品ID", example = "1", required = true)
|
||||
@Schema(description = "商品ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "商品ID不能为空")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
@Schema(description = "规格名称", example = "128GB 深空黑色", required = true)
|
||||
@Schema(description = "规格名称", example = "128GB 深空黑色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "规格名称不能为空")
|
||||
private String name;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CreateProductSpecDTO {
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
@Schema(description = "成本价", example = "8000.00", required = true)
|
||||
@Schema(description = "成本价", example = "8000.00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "成本价不能为空")
|
||||
private BigDecimal costPrice;
|
||||
}
|
||||
|
||||
+5
@@ -9,6 +9,11 @@ import lombok.Data;
|
||||
@Data
|
||||
@Schema(description = "商品分页查询过滤DTO")
|
||||
public class ProductFilterDTO {
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(description = "商品ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商品名称(模糊查询)
|
||||
|
||||
+6
@@ -16,6 +16,12 @@ public class ProductSpecFilterDTO {
|
||||
@Schema(description = "商品ID", example = "1")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 规格ID
|
||||
*/
|
||||
@Schema(description = "规格ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
|
||||
+1
-4
@@ -2,11 +2,8 @@ package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 更新商品DTO
|
||||
*/
|
||||
@@ -17,7 +14,7 @@ public class UpdateProductDTO {
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", required = true)
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "商品名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
+3
-3
@@ -17,14 +17,14 @@ public class UpdateProductSpecDTO {
|
||||
/**
|
||||
* 规格ID
|
||||
*/
|
||||
@Schema(description = "规格ID", example = "1", required = true)
|
||||
@Schema(description = "规格ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "规格ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
@Schema(description = "规格名称", example = "128GB 深空黑色", required = true)
|
||||
@Schema(description = "规格名称", example = "128GB 深空黑色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "规格名称不能为空")
|
||||
private String name;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class UpdateProductSpecDTO {
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
@Schema(description = "成本价", example = "8000.00", required = true)
|
||||
@Schema(description = "成本价", example = "8000.00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "成本价不能为空")
|
||||
private BigDecimal costPrice;
|
||||
}
|
||||
|
||||
+5
-5
@@ -18,21 +18,21 @@ public class CreatePromotionFeeDTO {
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1", required = true)
|
||||
@Schema(description = "店铺ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "店铺ID不能为空")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 推广费类型ID
|
||||
*/
|
||||
@Schema(description = "推广费类型ID", example = "1", required = true)
|
||||
@Schema(description = "推广费类型ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "推广费类型ID不能为空")
|
||||
private Long feeTypeId;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
*/
|
||||
@Schema(description = "推广费名称", example = "直通车推广", required = true)
|
||||
@Schema(description = "推广费名称", example = "直通车推广", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "推广费名称不能为空")
|
||||
private String feeName;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CreatePromotionFeeDTO {
|
||||
/**
|
||||
* 推广费金额
|
||||
*/
|
||||
@Schema(description = "推广费金额", example = "1000.00", required = true)
|
||||
@Schema(description = "推广费金额", example = "1000.00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "推广费金额不能为空")
|
||||
private BigDecimal feeAmount;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class CreatePromotionFeeDTO {
|
||||
/**
|
||||
* 推广费发生日期
|
||||
*/
|
||||
@Schema(description = "推广费发生日期", example = "2024-01-01", required = true)
|
||||
@Schema(description = "推广费发生日期", example = "2024-01-01", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "推广费发生日期不能为空")
|
||||
private LocalDate feeDate;
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class CreatePromotionFeeTypeDTO {
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@Schema(description = "类型名称", example = "直通车", required = true)
|
||||
@Schema(description = "类型名称", example = "直通车", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "类型名称不能为空")
|
||||
private String typeName;
|
||||
|
||||
|
||||
+6
-6
@@ -18,28 +18,28 @@ public class UpdatePromotionFeeDTO {
|
||||
/**
|
||||
* 推广费记录ID
|
||||
*/
|
||||
@Schema(description = "推广费记录ID", example = "1", required = true)
|
||||
@Schema(description = "推广费记录ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "推广费记录ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1", required = true)
|
||||
@Schema(description = "店铺ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "店铺ID不能为空")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 推广费类型ID
|
||||
*/
|
||||
@Schema(description = "推广费类型ID", example = "1", required = true)
|
||||
@Schema(description = "推广费类型ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "推广费类型ID不能为空")
|
||||
private Long feeTypeId;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
*/
|
||||
@Schema(description = "推广费名称", example = "直通车推广", required = true)
|
||||
@Schema(description = "推广费名称", example = "直通车推广", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "推广费名称不能为空")
|
||||
private String feeName;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class UpdatePromotionFeeDTO {
|
||||
/**
|
||||
* 推广费金额
|
||||
*/
|
||||
@Schema(description = "推广费金额", example = "1000.00", required = true)
|
||||
@Schema(description = "推广费金额", example = "1000.00", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "推广费金额不能为空")
|
||||
private BigDecimal feeAmount;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class UpdatePromotionFeeDTO {
|
||||
/**
|
||||
* 推广费发生日期
|
||||
*/
|
||||
@Schema(description = "推广费发生日期", example = "2024-01-01", required = true)
|
||||
@Schema(description = "推广费发生日期", example = "2024-01-01", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "推广费发生日期不能为空")
|
||||
private LocalDate feeDate;
|
||||
|
||||
|
||||
+3
-3
@@ -15,21 +15,21 @@ public class UpdatePromotionFeeTypeDTO {
|
||||
/**
|
||||
* 推广费类型ID
|
||||
*/
|
||||
@Schema(description = "推广费类型ID", example = "1", required = true)
|
||||
@Schema(description = "推广费类型ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "推广费类型ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
@Schema(description = "类型编码", example = "DIRECT_TRAFFIC", required = true)
|
||||
@Schema(description = "类型编码", example = "DIRECT_TRAFFIC", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "类型编码不能为空")
|
||||
private String typeCode;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@Schema(description = "类型名称", example = "直通车", required = true)
|
||||
@Schema(description = "类型名称", example = "直通车", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "类型名称不能为空")
|
||||
private String typeName;
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class CreateShopDTO {
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
@Schema(description = "店铺名称", example = "旗舰店", required = true)
|
||||
@Schema(description = "店铺名称", example = "旗舰店", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "店铺名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 店铺商品分页查询过滤DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "店铺商品分页查询过滤DTO")
|
||||
public class ShopProductFilterDTO {
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 商品名称(模糊查询)
|
||||
*/
|
||||
@Schema(description = "商品名称(模糊查询)", example = "iPhone")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 商品编码(模糊查询)
|
||||
*/
|
||||
@Schema(description = "商品编码(模糊查询)", example = "IPHONE")
|
||||
private String productCode;
|
||||
|
||||
/**
|
||||
* 统计日期(不传默认为当日)
|
||||
*/
|
||||
@Schema(description = "统计日期(不传默认为当日)", example = "2024-01-01")
|
||||
private LocalDate statDate;
|
||||
}
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 店铺统计查询DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "店铺统计查询DTO")
|
||||
public class ShopStatisticsQueryDTO {
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "店铺ID不能为空")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
@Schema(description = "开始日期", example = "2024-01-01", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "开始日期不能为空")
|
||||
private LocalDate startDate;
|
||||
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
@Schema(description = "结束日期", example = "2024-01-31", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "结束日期不能为空")
|
||||
private LocalDate endDate;
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class UpdateShopDTO {
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
@Schema(description = "店铺名称", example = "旗舰店", required = true)
|
||||
@Schema(description = "店铺名称", example = "旗舰店", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "店铺名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 电商-店铺商品关联实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_shop_product_relation")
|
||||
public class ShopProductRelationPO {
|
||||
|
||||
/**
|
||||
* 关联ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@TableField("company_id")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@TableField("product_id")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("sort_order")
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@TableField("create_by")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@TableField("update_by")
|
||||
private Long updateBy;
|
||||
}
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 店铺商品详细信息VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "店铺商品详细信息VO")
|
||||
public class ShopProductDetailVO {
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(description = "商品ID", example = "1")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 商品编码
|
||||
*/
|
||||
@Schema(description = "商品编码", example = "IPHONE15PRO001")
|
||||
private String productCode;
|
||||
|
||||
/**
|
||||
* 主图URL
|
||||
*/
|
||||
@Schema(description = "主图URL", example = "https://example.com/product.jpg")
|
||||
private String mainImage;
|
||||
|
||||
/**
|
||||
* 关联ID
|
||||
*/
|
||||
@Schema(description = "关联ID", example = "1")
|
||||
private Long relationId;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "0")
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 销售额(商家实收金额总和)
|
||||
*/
|
||||
@Schema(description = "销售额", example = "10000.00")
|
||||
private BigDecimal salesAmount;
|
||||
|
||||
/**
|
||||
* 订单数
|
||||
*/
|
||||
@Schema(description = "订单数", example = "10")
|
||||
private Long orderCount;
|
||||
|
||||
/**
|
||||
* 客单价(销售额/订单数)
|
||||
*/
|
||||
@Schema(description = "客单价", example = "1000.00")
|
||||
private BigDecimal averageOrderValue;
|
||||
}
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 店铺统计VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "店铺统计VO")
|
||||
public class ShopStatisticsVO {
|
||||
|
||||
/**
|
||||
* 销售额(商家实收金额总和)
|
||||
*/
|
||||
@Schema(description = "销售额", example = "100000.00")
|
||||
private BigDecimal salesAmount;
|
||||
|
||||
/**
|
||||
* 订单数
|
||||
*/
|
||||
@Schema(description = "订单数", example = "100")
|
||||
private Long orderCount;
|
||||
|
||||
/**
|
||||
* 客单价(销售额/订单数)
|
||||
*/
|
||||
@Schema(description = "客单价", example = "1000.00")
|
||||
private BigDecimal averageOrderValue;
|
||||
|
||||
/**
|
||||
* 成本(成本价*数量总和)
|
||||
*/
|
||||
@Schema(description = "成本", example = "60000.00")
|
||||
private BigDecimal costAmount;
|
||||
|
||||
/**
|
||||
* 退款金额(已退款订单的实收金额总和)
|
||||
*/
|
||||
@Schema(description = "退款金额", example = "5000.00")
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
/**
|
||||
* 推广费
|
||||
*/
|
||||
@Schema(description = "推广费", example = "10000.00")
|
||||
private BigDecimal promotionFee;
|
||||
|
||||
/**
|
||||
* 费比(推广费/销售额)
|
||||
*/
|
||||
@Schema(description = "费比", example = "0.10")
|
||||
private BigDecimal feeRatio;
|
||||
}
|
||||
|
||||
+20
-10
@@ -6,13 +6,15 @@ import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.CreateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopProductFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopStatisticsQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.UpdateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ShopPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopProductDetailVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopStatisticsVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.media.model.vo.MediaImageVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺服务接口
|
||||
*/
|
||||
@@ -59,18 +61,26 @@ public interface ShopService extends IService<ShopPO> {
|
||||
MediaImageVO uploadLogo(MultipartFile file);
|
||||
|
||||
/**
|
||||
* 根据名称精准查询店铺
|
||||
* 获取店铺当月统计信息
|
||||
*
|
||||
* @param name 店铺名称
|
||||
* @return 店铺VO
|
||||
* @param shopId 店铺ID
|
||||
* @return 店铺统计信息
|
||||
*/
|
||||
ShopVO getShopByName(String name);
|
||||
ShopStatisticsVO getShopCurrentMonthStatistics(Long shopId);
|
||||
|
||||
/**
|
||||
* 批量根据名称查询店铺
|
||||
* 获取店铺指定时间范围的统计信息
|
||||
*
|
||||
* @param names 店铺名称列表
|
||||
* @return 店铺VO列表
|
||||
* @param queryDTO 统计查询DTO
|
||||
* @return 店铺统计信息
|
||||
*/
|
||||
List<ShopVO> getShopsByNames(List<String> names);
|
||||
ShopStatisticsVO getShopStatistics(ShopStatisticsQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 分页获取店铺商品详细信息
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<ShopProductDetailVO> getShopProductPage(PageQueryDTO<ShopProductFilterDTO> pageQueryDTO);
|
||||
}
|
||||
|
||||
+41
@@ -12,11 +12,13 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.OrderStatusMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.ShopProductRelationMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.order.CreateOrderDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportTaskPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.OrderStatusPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ProductSpecPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ShopProductRelationPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportTaskVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ImportTaskProcessorService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.OrderMapper;
|
||||
@@ -97,6 +99,7 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
private final OrderMapper orderMapper;
|
||||
private final ProductMapper productMapper;
|
||||
private final ShopService shopService;
|
||||
private final ShopProductRelationMapper shopProductRelationMapper;
|
||||
private final SseNotificationService sseNotificationService;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@@ -109,6 +112,7 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
OrderMapper orderMapper,
|
||||
ProductMapper productMapper,
|
||||
ShopService shopService,
|
||||
ShopProductRelationMapper shopProductRelationMapper,
|
||||
SseNotificationService sseNotificationService,
|
||||
ObjectMapper objectMapper) {
|
||||
this.importTaskService = importTaskService;
|
||||
@@ -117,6 +121,7 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
this.orderMapper = orderMapper;
|
||||
this.productMapper = productMapper;
|
||||
this.shopService = shopService;
|
||||
this.shopProductRelationMapper = shopProductRelationMapper;
|
||||
this.sseNotificationService = sseNotificationService;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
@@ -753,6 +758,9 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
}
|
||||
}
|
||||
|
||||
// 检查并创建店铺商品关联(如果不存在)
|
||||
ensureShopProductRelation(createOrderDTO.getShopId(), createOrderDTO.getProductId(), companyId, createBy);
|
||||
|
||||
// 创建订单(包含商品明细)
|
||||
OrderPO order = new OrderPO();
|
||||
order.setCompanyId(companyId);
|
||||
@@ -789,6 +797,39 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
return orderVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保店铺商品关联存在,如果不存在则创建
|
||||
*
|
||||
* @param shopId 店铺ID
|
||||
* @param productId 商品ID
|
||||
* @param companyId 公司ID
|
||||
* @param createBy 创建人ID
|
||||
*/
|
||||
private void ensureShopProductRelation(Long shopId, Long productId, Long companyId, Long createBy) {
|
||||
// 检查关联是否已存在
|
||||
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<ShopProductRelationPO> wrapper =
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopProductRelationPO::getShopId, shopId)
|
||||
.eq(ShopProductRelationPO::getProductId, productId)
|
||||
.eq(ShopProductRelationPO::getCompanyId, companyId);
|
||||
|
||||
ShopProductRelationPO existingRelation = shopProductRelationMapper.selectOne(wrapper);
|
||||
|
||||
if (existingRelation == null) {
|
||||
// 关联不存在,创建新关联
|
||||
ShopProductRelationPO relation = new ShopProductRelationPO();
|
||||
relation.setCompanyId(companyId);
|
||||
relation.setShopId(shopId);
|
||||
relation.setProductId(productId);
|
||||
relation.setSortOrder(0); // 默认排序为0
|
||||
relation.setCreateBy(createBy);
|
||||
shopProductRelationMapper.insert(relation);
|
||||
logger.info("创建店铺商品关联: 店铺ID={}, 商品ID={}", shopId, productId);
|
||||
} else {
|
||||
logger.debug("店铺商品关联已存在: 店铺ID={}, 商品ID={}", shopId, productId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过订单状态名称查找订单状态ID
|
||||
*
|
||||
|
||||
+300
-30
@@ -10,11 +10,25 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.OrderMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.OrderStatusMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.ProductMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.PromotionFeeMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.ShopMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.ShopProductRelationMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.CreateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopProductFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopStatisticsQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.UpdateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.OrderPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.OrderStatusPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ProductPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.PromotionFeePO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ShopPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ShopProductRelationPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopProductDetailVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopStatisticsVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ShopService;
|
||||
import top.xyquan.ecomdmbbackend.modules.media.service.MediaImageService;
|
||||
@@ -22,6 +36,10 @@ import top.xyquan.ecomdmbbackend.modules.media.model.vo.MediaImageVO;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -33,10 +51,23 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
|
||||
private final CurrentUserContext currentUserContext;
|
||||
private final MediaImageService mediaImageService;
|
||||
private final OrderMapper orderMapper;
|
||||
private final PromotionFeeMapper promotionFeeMapper;
|
||||
private final OrderStatusMapper orderStatusMapper;
|
||||
private final ProductMapper productMapper;
|
||||
private final ShopProductRelationMapper shopProductRelationMapper;
|
||||
|
||||
public ShopServiceImpl(CurrentUserContext currentUserContext, MediaImageService mediaImageService) {
|
||||
public ShopServiceImpl(CurrentUserContext currentUserContext, MediaImageService mediaImageService,
|
||||
OrderMapper orderMapper, PromotionFeeMapper promotionFeeMapper,
|
||||
OrderStatusMapper orderStatusMapper, ProductMapper productMapper,
|
||||
ShopProductRelationMapper shopProductRelationMapper) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
this.mediaImageService = mediaImageService;
|
||||
this.orderMapper = orderMapper;
|
||||
this.promotionFeeMapper = promotionFeeMapper;
|
||||
this.orderStatusMapper = orderStatusMapper;
|
||||
this.productMapper = productMapper;
|
||||
this.shopProductRelationMapper = shopProductRelationMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,52 +242,291 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称获取店铺
|
||||
* @param name 店铺名称
|
||||
* @return 店铺VO
|
||||
* 获取店铺当月统计信息
|
||||
*/
|
||||
@Override
|
||||
public ShopVO getShopByName(String name) {
|
||||
public ShopStatisticsVO getShopCurrentMonthStatistics(Long shopId) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 根据名称精准查询店铺
|
||||
LambdaQueryWrapper<ShopPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopPO::getName, name)
|
||||
.eq(ShopPO::getCompanyId, companyId);
|
||||
|
||||
ShopPO shop = this.getOne(wrapper);
|
||||
if (shop == null) {
|
||||
return null;
|
||||
// 验证店铺是否存在
|
||||
ShopPO shop = this.getById(shopId);
|
||||
if (shop == null || !shop.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("店铺不存在");
|
||||
}
|
||||
|
||||
return convertToVO(shop);
|
||||
// 获取当月开始和结束时间
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate startDate = now.withDayOfMonth(1);
|
||||
LocalDate endDate = now.withDayOfMonth(now.lengthOfMonth());
|
||||
|
||||
// 构建查询DTO
|
||||
ShopStatisticsQueryDTO queryDTO = new ShopStatisticsQueryDTO();
|
||||
queryDTO.setShopId(shopId);
|
||||
queryDTO.setStartDate(startDate);
|
||||
queryDTO.setEndDate(endDate);
|
||||
|
||||
return calculateStatistics(queryDTO, companyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称列表获取店铺列表
|
||||
* @param names 店铺名称列表
|
||||
* @return 店铺VO列表
|
||||
* 获取店铺指定时间范围的统计信息
|
||||
*/
|
||||
@Override
|
||||
public List<ShopVO> getShopsByNames(List<String> names) {
|
||||
if (names == null || names.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public ShopStatisticsVO getShopStatistics(ShopStatisticsQueryDTO queryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 批量根据名称查询店铺
|
||||
LambdaQueryWrapper<ShopPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(ShopPO::getName, names)
|
||||
.eq(ShopPO::getCompanyId, companyId)
|
||||
.orderByAsc(ShopPO::getName);
|
||||
// 验证店铺是否存在
|
||||
ShopPO shop = this.getById(queryDTO.getShopId());
|
||||
if (shop == null || !shop.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("店铺不存在");
|
||||
}
|
||||
|
||||
List<ShopPO> shops = this.list(wrapper);
|
||||
return shops.stream()
|
||||
.map(this::convertToVO)
|
||||
// 验证日期范围
|
||||
if (queryDTO.getStartDate().isAfter(queryDTO.getEndDate())) {
|
||||
throw new BusinessException("开始日期不能晚于结束日期");
|
||||
}
|
||||
|
||||
return calculateStatistics(queryDTO, companyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算统计信息
|
||||
*/
|
||||
private ShopStatisticsVO calculateStatistics(ShopStatisticsQueryDTO queryDTO, Long companyId) {
|
||||
ShopStatisticsVO statistics = new ShopStatisticsVO();
|
||||
|
||||
// 查询时间范围(订单使用orderDate,推广费使用feeDate)
|
||||
LocalDateTime startDateTime = queryDTO.getStartDate().atStartOfDay();
|
||||
LocalDateTime endDateTime = queryDTO.getEndDate().atTime(23, 59, 59);
|
||||
|
||||
// 查询订单数据
|
||||
LambdaQueryWrapper<OrderPO> orderWrapper = new LambdaQueryWrapper<>();
|
||||
orderWrapper.eq(OrderPO::getCompanyId, companyId)
|
||||
.eq(OrderPO::getShopId, queryDTO.getShopId())
|
||||
.ge(OrderPO::getOrderDate, startDateTime)
|
||||
.le(OrderPO::getOrderDate, endDateTime);
|
||||
List<OrderPO> orders = orderMapper.selectList(orderWrapper);
|
||||
|
||||
// 查询推广费数据
|
||||
LambdaQueryWrapper<PromotionFeePO> promotionWrapper = new LambdaQueryWrapper<>();
|
||||
promotionWrapper.eq(PromotionFeePO::getCompanyId, companyId)
|
||||
.eq(PromotionFeePO::getShopId, queryDTO.getShopId())
|
||||
.ge(PromotionFeePO::getFeeDate, queryDTO.getStartDate())
|
||||
.le(PromotionFeePO::getFeeDate, queryDTO.getEndDate());
|
||||
List<PromotionFeePO> promotionFees = promotionFeeMapper.selectList(promotionWrapper);
|
||||
|
||||
// 获取退款状态ID(状态名称为"已退款")
|
||||
Long refundStatusId = getRefundStatusId(companyId);
|
||||
|
||||
// 计算销售额(商家实收金额总和)
|
||||
BigDecimal salesAmount = orders.stream()
|
||||
.map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
statistics.setSalesAmount(salesAmount);
|
||||
|
||||
// 计算订单数(按平台订单号去重)
|
||||
long orderCount = orders.stream()
|
||||
.map(OrderPO::getPlatformOrderNo)
|
||||
.filter(no -> no != null && !no.isEmpty())
|
||||
.distinct()
|
||||
.count();
|
||||
// 如果没有平台订单号,则使用订单记录数
|
||||
if (orderCount == 0) {
|
||||
orderCount = orders.size();
|
||||
}
|
||||
statistics.setOrderCount(orderCount);
|
||||
|
||||
// 计算客单价(销售额/订单数)
|
||||
BigDecimal averageOrderValue = orderCount > 0
|
||||
? salesAmount.divide(BigDecimal.valueOf(orderCount), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
statistics.setAverageOrderValue(averageOrderValue);
|
||||
|
||||
// 计算成本(成本价*数量总和)
|
||||
BigDecimal costAmount = orders.stream()
|
||||
.map(order -> {
|
||||
BigDecimal cost = order.getCostPrice() != null ? order.getCostPrice() : BigDecimal.ZERO;
|
||||
Integer quantity = order.getQuantity() != null ? order.getQuantity() : 0;
|
||||
return cost.multiply(BigDecimal.valueOf(quantity));
|
||||
})
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
statistics.setCostAmount(costAmount);
|
||||
|
||||
// 计算退款金额(已退款订单的实收金额总和)
|
||||
BigDecimal refundAmount = BigDecimal.ZERO;
|
||||
if (refundStatusId != null) {
|
||||
refundAmount = orders.stream()
|
||||
.filter(order -> refundStatusId.equals(order.getStatusId()))
|
||||
.map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
statistics.setRefundAmount(refundAmount);
|
||||
|
||||
// 计算推广费
|
||||
BigDecimal promotionFee = promotionFees.stream()
|
||||
.map(fee -> fee.getFeeAmount() != null ? fee.getFeeAmount() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
statistics.setPromotionFee(promotionFee);
|
||||
|
||||
// 计算费比(推广费/销售额)
|
||||
BigDecimal feeRatio = salesAmount.compareTo(BigDecimal.ZERO) > 0
|
||||
? promotionFee.divide(salesAmount, 4, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
statistics.setFeeRatio(feeRatio);
|
||||
|
||||
return statistics;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取退款状态ID
|
||||
*/
|
||||
private Long getRefundStatusId(Long companyId) {
|
||||
LambdaQueryWrapper<OrderStatusPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrderStatusPO::getCompanyId, companyId)
|
||||
.eq(OrderStatusPO::getStatusName, "已退款")
|
||||
.eq(OrderStatusPO::getIsActive, 1);
|
||||
OrderStatusPO status = orderStatusMapper.selectOne(wrapper);
|
||||
return status != null ? status.getId() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取店铺商品详细信息
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<ShopProductDetailVO> getShopProductPage(PageQueryDTO<ShopProductFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 获取过滤条件
|
||||
ShopProductFilterDTO filter = pageQueryDTO.getFilters();
|
||||
if (filter == null || filter.getShopId() == null) {
|
||||
throw new BusinessException("店铺ID不能为空");
|
||||
}
|
||||
|
||||
Long shopId = filter.getShopId();
|
||||
|
||||
// 验证店铺是否存在
|
||||
ShopPO shop = this.getById(shopId);
|
||||
if (shop == null || !shop.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("店铺不存在");
|
||||
}
|
||||
|
||||
// 确定统计日期(不传默认为当日)
|
||||
LocalDate statDate = filter.getStatDate() != null ? filter.getStatDate() : LocalDate.now();
|
||||
LocalDateTime startDateTime = statDate.atStartOfDay();
|
||||
LocalDateTime endDateTime = statDate.atTime(23, 59, 59);
|
||||
|
||||
// 创建分页对象
|
||||
Page<ShopProductRelationPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
|
||||
// 构建查询条件(店铺商品关联表)
|
||||
LambdaQueryWrapper<ShopProductRelationPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopProductRelationPO::getCompanyId, companyId)
|
||||
.eq(ShopProductRelationPO::getShopId, shopId);
|
||||
|
||||
// 添加商品名称和编码过滤(需要关联商品表)
|
||||
// 如果同时有商品名称和编码过滤,需要取交集
|
||||
boolean hasProductFilter = (filter.getProductName() != null && !filter.getProductName().trim().isEmpty()) ||
|
||||
(filter.getProductCode() != null && !filter.getProductCode().trim().isEmpty());
|
||||
|
||||
if (hasProductFilter) {
|
||||
LambdaQueryWrapper<ProductPO> productWrapper = new LambdaQueryWrapper<>();
|
||||
productWrapper.eq(ProductPO::getCompanyId, companyId);
|
||||
|
||||
if (filter.getProductName() != null && !filter.getProductName().trim().isEmpty()) {
|
||||
productWrapper.like(ProductPO::getName, filter.getProductName().trim());
|
||||
}
|
||||
|
||||
if (filter.getProductCode() != null && !filter.getProductCode().trim().isEmpty()) {
|
||||
productWrapper.like(ProductPO::getProductCode, filter.getProductCode().trim());
|
||||
}
|
||||
|
||||
List<ProductPO> products = productMapper.selectList(productWrapper);
|
||||
if (products.isEmpty()) {
|
||||
// 如果没有匹配的商品,返回空结果
|
||||
return PageResultVO.create(List.of(), 0L, pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
List<Long> productIds = products.stream().map(ProductPO::getId).collect(Collectors.toList());
|
||||
wrapper.in(ShopProductRelationPO::getProductId, productIds);
|
||||
}
|
||||
|
||||
// 排序
|
||||
wrapper.orderByAsc(ShopProductRelationPO::getSortOrder)
|
||||
.orderByDesc(ShopProductRelationPO::getCreateTime);
|
||||
|
||||
// 执行分页查询
|
||||
IPage<ShopProductRelationPO> pageResult = shopProductRelationMapper.selectPage(page, wrapper);
|
||||
|
||||
// 转换为VO并填充统计数据
|
||||
List<ShopProductDetailVO> voList = pageResult.getRecords().stream()
|
||||
.map(relation -> {
|
||||
ShopProductDetailVO vo = new ShopProductDetailVO();
|
||||
vo.setRelationId(relation.getId());
|
||||
vo.setSortOrder(relation.getSortOrder());
|
||||
vo.setCreateTime(relation.getCreateTime());
|
||||
vo.setUpdateTime(relation.getUpdateTime());
|
||||
|
||||
// 查询商品信息
|
||||
ProductPO product = productMapper.selectById(relation.getProductId());
|
||||
if (product != null) {
|
||||
vo.setProductId(product.getId());
|
||||
vo.setProductName(product.getName());
|
||||
vo.setProductCode(product.getProductCode());
|
||||
vo.setMainImage(product.getMainImage());
|
||||
}
|
||||
|
||||
// 统计订单数据(按日期)
|
||||
calculateProductStatistics(vo, shopId, relation.getProductId(), companyId, startDateTime, endDateTime);
|
||||
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建分页结果
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算商品统计数据
|
||||
*/
|
||||
private void calculateProductStatistics(ShopProductDetailVO vo, Long shopId, Long productId,
|
||||
Long companyId, LocalDateTime startDateTime, LocalDateTime endDateTime) {
|
||||
// 查询该店铺该商品在指定日期的订单
|
||||
LambdaQueryWrapper<OrderPO> orderWrapper = new LambdaQueryWrapper<>();
|
||||
orderWrapper.eq(OrderPO::getCompanyId, companyId)
|
||||
.eq(OrderPO::getShopId, shopId)
|
||||
.eq(OrderPO::getProductId, productId)
|
||||
.ge(OrderPO::getOrderDate, startDateTime)
|
||||
.le(OrderPO::getOrderDate, endDateTime);
|
||||
|
||||
List<OrderPO> orders = orderMapper.selectList(orderWrapper);
|
||||
|
||||
// 计算销售额(商家实收金额总和)
|
||||
BigDecimal salesAmount = orders.stream()
|
||||
.map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
vo.setSalesAmount(salesAmount);
|
||||
|
||||
// 计算订单数(按平台订单号去重)
|
||||
long orderCount = orders.stream()
|
||||
.map(OrderPO::getPlatformOrderNo)
|
||||
.filter(no -> no != null && !no.isEmpty())
|
||||
.distinct()
|
||||
.count();
|
||||
// 如果没有平台订单号,则使用订单记录数
|
||||
if (orderCount == 0) {
|
||||
orderCount = orders.size();
|
||||
}
|
||||
vo.setOrderCount(orderCount);
|
||||
|
||||
// 计算客单价(销售额/订单数)
|
||||
BigDecimal averageOrderValue = orderCount > 0
|
||||
? salesAmount.divide(BigDecimal.valueOf(orderCount), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
vo.setAverageOrderValue(averageOrderValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class CompanyDTO {
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@Schema(description = "公司名称", example = "某某科技有限公司", required = true)
|
||||
@Schema(description = "公司名称", example = "某某科技有限公司", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "公司名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class CreateCompanyDTO {
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@Schema(description = "公司名称", example = "某某科技有限公司", required = true)
|
||||
@Schema(description = "公司名称", example = "某某科技有限公司", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "公司名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class UpdateCompanyDTO {
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@Schema(description = "公司名称", example = "某某科技有限公司", required = true)
|
||||
@Schema(description = "公司名称", example = "某某科技有限公司", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "公司名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
+2
-2
@@ -17,14 +17,14 @@ public class BatchCompanyMenuDTO {
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Schema(description = "公司ID", example = "1", required = true)
|
||||
@Schema(description = "公司ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "公司ID不能为空")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 菜单ID列表
|
||||
*/
|
||||
@Schema(description = "菜单ID列表", example = "[1, 2, 3]", required = true)
|
||||
@Schema(description = "菜单ID列表", example = "[1, 2, 3]", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "菜单ID列表不能为空")
|
||||
private List<Long> menuIds;
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ public class CompanyMenuDTO {
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Schema(description = "公司ID", example = "1", required = true)
|
||||
@Schema(description = "公司ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "公司ID不能为空")
|
||||
private Long companyId;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class CompanyMenuDTO {
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@Schema(description = "菜单ID", example = "1", required = true)
|
||||
@Schema(description = "菜单ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "菜单ID不能为空")
|
||||
private Long menuId;
|
||||
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ public class CreateCompanyMenuDTO {
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Schema(description = "公司ID", example = "1", required = true)
|
||||
@Schema(description = "公司ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "公司ID不能为空")
|
||||
private Long companyId;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CreateCompanyMenuDTO {
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@Schema(description = "菜单ID", example = "1", required = true)
|
||||
@Schema(description = "菜单ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "菜单ID不能为空")
|
||||
private Long menuId;
|
||||
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ public class UpdateCompanyMenuDTO {
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Schema(description = "公司ID", example = "1", required = true)
|
||||
@Schema(description = "公司ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "公司ID不能为空")
|
||||
private Long companyId;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class UpdateCompanyMenuDTO {
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@Schema(description = "菜单ID", example = "1", required = true)
|
||||
@Schema(description = "菜单ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "菜单ID不能为空")
|
||||
private Long menuId;
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class CreateDepartmentDTO {
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@Schema(description = "部门名称", example = "技术部", required = true)
|
||||
@Schema(description = "部门名称", example = "技术部", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ public class DepartmentDTO {
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@Schema(description = "部门名称", example = "技术部", required = true)
|
||||
@Schema(description = "部门名称", example = "技术部", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
private String name;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DepartmentDTO {
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Schema(description = "公司ID", example = "1", required = true)
|
||||
@Schema(description = "公司ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "公司ID不能为空")
|
||||
private Long companyId;
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class UpdateDepartmentDTO {
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@Schema(description = "部门名称", example = "技术部", required = true)
|
||||
@Schema(description = "部门名称", example = "技术部", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class CreatePositionDTO {
|
||||
/**
|
||||
* 岗位名称
|
||||
*/
|
||||
@Schema(description = "岗位名称", example = "软件工程师", required = true)
|
||||
@Schema(description = "岗位名称", example = "软件工程师", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "岗位名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ public class PositionDTO {
|
||||
/**
|
||||
* 岗位名称
|
||||
*/
|
||||
@Schema(description = "岗位名称", example = "软件工程师", required = true)
|
||||
@Schema(description = "岗位名称", example = "软件工程师", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "岗位名称不能为空")
|
||||
private String name;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class PositionDTO {
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Schema(description = "公司ID", example = "1", required = true)
|
||||
@Schema(description = "公司ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "公司ID不能为空")
|
||||
private Long companyId;
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class UpdatePositionDTO {
|
||||
/**
|
||||
* 岗位名称
|
||||
*/
|
||||
@Schema(description = "岗位名称", example = "软件工程师", required = true)
|
||||
@Schema(description = "岗位名称", example = "软件工程师", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "岗位名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
-- 为导入映射表添加名称字段并修改唯一约束
|
||||
-- 执行时间:2025-12-03
|
||||
|
||||
-- 1. 添加名称字段
|
||||
ALTER TABLE `ec_import_mappings`
|
||||
ADD COLUMN `name` varchar(20) NOT NULL COMMENT '映射名称' AFTER `type`;
|
||||
|
||||
-- 2. 为现有数据设置默认名称(根据类型设置,确保唯一性)
|
||||
UPDATE `ec_import_mappings` SET `name` = CONCAT('商品导入映射-', DATE_FORMAT(create_time, '%Y%m%d')) WHERE `type` = 'product';
|
||||
UPDATE `ec_import_mappings` SET `name` = CONCAT('订单导入映射-', DATE_FORMAT(create_time, '%Y%m%d')) WHERE `type` = 'order';
|
||||
|
||||
-- 3. 删除旧的唯一约束(如果存在)
|
||||
ALTER TABLE `ec_import_mappings` DROP INDEX IF EXISTS `uniq_company_type`;
|
||||
|
||||
-- 4. 添加新的唯一约束(公司ID、导入类型、名称)
|
||||
ALTER TABLE `ec_import_mappings`
|
||||
ADD UNIQUE KEY `uniq_company_type_name` (`company_id`, `type`, `name`);
|
||||
|
||||
@@ -257,3 +257,29 @@ CREATE TABLE `ec_import_field_defs` (
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uniq_type_field` (`type`,`field_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-导入字段定义表';
|
||||
|
||||
-- 店铺商品关联表(中间表)
|
||||
CREATE TABLE `ec_shop_product_relation` (
|
||||
`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',
|
||||
`product_id` BIGINT UNSIGNED NOT NULL COMMENT '商品ID',
|
||||
`sort_order` INT NOT NULL DEFAULT 0 COMMENT '排序',
|
||||
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_shop_product` (`shop_id`, `product_id`),
|
||||
KEY `idx_company_id` (`company_id`),
|
||||
KEY `idx_shop_id` (`shop_id`),
|
||||
KEY `idx_product_id` (`product_id`),
|
||||
KEY `idx_sort_order` (`sort_order`),
|
||||
KEY `fk_ec_shop_product_creator` (`create_by`),
|
||||
KEY `fk_ec_shop_product_updater` (`update_by`),
|
||||
CONSTRAINT `fk_ec_shop_product_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_shop_product_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_shop_product_product` FOREIGN KEY (`product_id`) REFERENCES `ec_product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_shop_product_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_shop_product_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-店铺商品关联表';
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
@@ -0,0 +1,77 @@
|
||||
import type { ProductSpecDTO, ProductSpecVO } from './types';
|
||||
|
||||
import type { ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 商品规格管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 创建商品规格
|
||||
*/
|
||||
export async function createProductSpecApi(data: ProductSpecDTO.Create) {
|
||||
return requestClient.post<ProductSpecVO.Info>(
|
||||
'/ec/product-spec/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品规格
|
||||
*/
|
||||
export async function updateProductSpecApi(
|
||||
id: number,
|
||||
data: ProductSpecDTO.Update,
|
||||
) {
|
||||
return requestClient.put<ProductSpecVO.Info>(
|
||||
`/ec/product-spec/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品规格
|
||||
*/
|
||||
export async function deleteProductSpecApi(id: number) {
|
||||
return requestClient.delete(`/ec/product-spec/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取商品规格列表
|
||||
*/
|
||||
export async function getProductSpecPageApi(
|
||||
params: PageQueryDTO<ProductSpecDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ProductSpecVO.Info>>(
|
||||
'/ec/product-spec/page',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品名称和规格编码精准查询商品规格
|
||||
*/
|
||||
export async function getProductSpecByProductAndSpecApi(
|
||||
productName: string,
|
||||
specCode: string,
|
||||
) {
|
||||
return requestClient.get<ProductSpecVO.Info>(
|
||||
`/ec/product-spec/find-by-product-and-spec/${encodeURIComponent(productName)}/${encodeURIComponent(specCode)}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据商品名称和规格编码查询商品规格
|
||||
* 返回商品信息列表,每个商品包含匹配的规格信息
|
||||
*/
|
||||
export async function getProductSpecsByProductAndSpecsApi(
|
||||
queries: ProductSpecDTO.Query[],
|
||||
) {
|
||||
return requestClient.post<ProductVO.Info[]>(
|
||||
'/ec/product-spec/find-by-product-and-specs',
|
||||
queries,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 商品规格模块API导出
|
||||
*/
|
||||
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 商品规格相关DTO类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductSpecDTO {
|
||||
/** 创建商品规格参数 */
|
||||
export interface Create {
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 更新商品规格参数 */
|
||||
export interface Update {
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 商品规格过滤条件 */
|
||||
export interface Filters {
|
||||
/** 商品ID */
|
||||
productId?: number;
|
||||
/** 规格ID */
|
||||
id?: number;
|
||||
/** 规格名称 */
|
||||
name?: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
}
|
||||
|
||||
/** 商品规格查询DTO(用于批量查询) */
|
||||
export interface Query {
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 规格编码 */
|
||||
specCode: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 商品规格相关VO类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductSpecVO {
|
||||
/** 商品规格信息 */
|
||||
export interface Info {
|
||||
/** 规格ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId: number;
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
}
|
||||
@@ -40,96 +40,3 @@ export async function updateProductApi(id: number, data: ProductDTO.Update) {
|
||||
export async function deleteProductApi(id: number) {
|
||||
return requestClient.delete(`/ec/product/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品规格管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取商品规格列表
|
||||
*/
|
||||
export async function getProductSpecPageApi(
|
||||
params: PageQueryDTO<ProductDTO.SpecFilters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ProductVO.SpecInfo>>(
|
||||
'/ec/product-spec/page',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品规格
|
||||
*/
|
||||
export async function createProductSpecApi(data: ProductDTO.CreateSpec) {
|
||||
return requestClient.post<ProductVO.SpecInfo>(
|
||||
'/ec/product-spec/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品规格
|
||||
*/
|
||||
export async function updateProductSpecApi(
|
||||
id: number,
|
||||
data: ProductDTO.UpdateSpec,
|
||||
) {
|
||||
return requestClient.put<ProductVO.SpecInfo>(
|
||||
`/ec/product-spec/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品规格
|
||||
*/
|
||||
export async function deleteProductSpecApi(id: number) {
|
||||
return requestClient.delete(`/ec/product-spec/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 精准查询API - 用于数据导入
|
||||
*/
|
||||
|
||||
/**
|
||||
* 根据名称精准查询商品
|
||||
*/
|
||||
export async function getProductByNameApi(name: string) {
|
||||
return requestClient.get<ProductVO.Info>(
|
||||
`/ec/product/find-by-name/${encodeURIComponent(name)}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据名称查询商品
|
||||
*/
|
||||
export async function getProductsByNamesApi(names: string[]) {
|
||||
return requestClient.post<ProductVO.Info[]>(
|
||||
'/ec/product/find-by-names',
|
||||
names,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品名称和规格编码精准查询商品规格
|
||||
*/
|
||||
export async function getProductSpecByProductAndSpecApi(
|
||||
productName: string,
|
||||
specCode: string,
|
||||
) {
|
||||
return requestClient.get<ProductVO.SpecInfo>(
|
||||
`/ec/product-spec/find-by-product-and-spec/${encodeURIComponent(productName)}/${encodeURIComponent(specCode)}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据商品名称和规格编码查询商品规格
|
||||
*/
|
||||
export async function getProductSpecsByProductAndSpecsApi(
|
||||
queries: { productName: string; specCode: string }[],
|
||||
) {
|
||||
return requestClient.post<ProductVO.Info[]>(
|
||||
'/ec/product-spec/find-by-product-and-specs',
|
||||
queries,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,8 @@ export namespace ProductDTO {
|
||||
name: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 商品编码 */
|
||||
specCode?: string;
|
||||
/** 商品SKU */
|
||||
skuCode?: string;
|
||||
/** 主图图片ID */
|
||||
mainImageId?: number;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 商品规格DTO */
|
||||
@@ -65,18 +59,12 @@ export namespace ProductDTO {
|
||||
|
||||
/** 商品过滤条件 */
|
||||
export interface Filters {
|
||||
/** 商品ID */
|
||||
id?: number;
|
||||
/** 商品名称(模糊查询) */
|
||||
name?: string;
|
||||
/** 商品编码(模糊查询) */
|
||||
productCode?: string;
|
||||
/** 商品编码(模糊查询) */
|
||||
specCode?: string;
|
||||
/** 商品SKU(模糊查询) */
|
||||
skuCode?: string;
|
||||
/** 成本价范围-最小值 */
|
||||
minCostPrice?: number;
|
||||
/** 成本价范围-最大值 */
|
||||
maxCostPrice?: number;
|
||||
}
|
||||
|
||||
/** 商品规格过滤条件 */
|
||||
|
||||
@@ -50,21 +50,29 @@ export async function uploadShopLogoApi(file: File) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 精准查询API - 用于数据导入
|
||||
* 获取店铺当月统计信息
|
||||
*/
|
||||
|
||||
/**
|
||||
* 根据名称精准查询店铺
|
||||
*/
|
||||
export async function getShopByNameApi(name: string) {
|
||||
return requestClient.get<ShopVO.Info>(
|
||||
`/ec/shop/find-by-name/${encodeURIComponent(name)}`,
|
||||
export async function getShopCurrentMonthStatisticsApi(id: number) {
|
||||
return requestClient.get<ShopVO.Statistics>(
|
||||
`/ec/shop/statistics/current-month/${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据名称查询店铺
|
||||
* 获取店铺统计信息
|
||||
*/
|
||||
export async function getShopsByNamesApi(names: string[]) {
|
||||
return requestClient.post<ShopVO.Info[]>('/ec/shop/find-by-names', names);
|
||||
export async function getShopStatisticsApi(params: ShopDTO.StatisticsQuery) {
|
||||
return requestClient.post<ShopVO.Statistics>('/ec/shop/statistics', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取店铺商品详细信息
|
||||
*/
|
||||
export async function getShopProductPageApi(
|
||||
params: PageQueryDTO<ShopDTO.ProductFilters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ShopVO.ProductDetail>>(
|
||||
'/ec/shop/products/page',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,4 +30,26 @@ export namespace ShopDTO {
|
||||
/** 平台 */
|
||||
platform?: string;
|
||||
}
|
||||
|
||||
/** 店铺统计查询参数 */
|
||||
export interface StatisticsQuery {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 开始日期 */
|
||||
startDate: string;
|
||||
/** 结束日期 */
|
||||
endDate: string;
|
||||
}
|
||||
|
||||
/** 店铺商品过滤条件 */
|
||||
export interface ProductFilters {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 商品名称(模糊查询) */
|
||||
productName?: string;
|
||||
/** 商品编码(模糊查询) */
|
||||
productCode?: string;
|
||||
/** 统计日期(不传默认为当日) */
|
||||
statDate?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +26,48 @@ export namespace ShopVO {
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
|
||||
/** 店铺统计信息 */
|
||||
export interface Statistics {
|
||||
/** 销售额(商家实收金额总和) */
|
||||
salesAmount: number;
|
||||
/** 订单数 */
|
||||
orderCount: number;
|
||||
/** 客单价(销售额/订单数) */
|
||||
averageOrderValue: number;
|
||||
/** 成本(成本价*数量总和) */
|
||||
costAmount: number;
|
||||
/** 退款金额(已退款订单的实收金额总和) */
|
||||
refundAmount: number;
|
||||
/** 推广费 */
|
||||
promotionFee: number;
|
||||
/** 费比(推广费/销售额) */
|
||||
feeRatio: number;
|
||||
}
|
||||
|
||||
/** 店铺商品详细信息 */
|
||||
export interface ProductDetail {
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 主图URL */
|
||||
mainImage?: string;
|
||||
/** 关联ID */
|
||||
relationId: number;
|
||||
/** 排序 */
|
||||
sortOrder: number;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 销售额(商家实收金额总和) */
|
||||
salesAmount: number;
|
||||
/** 订单数 */
|
||||
orderCount: number;
|
||||
/** 客单价(销售额/订单数) */
|
||||
averageOrderValue: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,6 @@ const routes: RouteRecordRaw[] = [
|
||||
title: '数据导入',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'DataAnalysis',
|
||||
path: '/data/analysis',
|
||||
component: () => import('#/views/ecommerce/data-analysis/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:bar-chart-3',
|
||||
title: '数据分析',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
meta: {
|
||||
icon: 'lucide:store',
|
||||
order: 50,
|
||||
title: '店铺管理',
|
||||
},
|
||||
name: 'Shop',
|
||||
path: '/shop',
|
||||
children: [
|
||||
{
|
||||
name: 'ShopManagement',
|
||||
path: '/shop/shop-management',
|
||||
component: () => import('#/views/shop/shop/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:store',
|
||||
title: '店铺管理',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ProductManagement',
|
||||
path: '/shop/product-management',
|
||||
component: () => import('#/views/shop/product/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:package',
|
||||
title: '商品管理',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'OrderManagement',
|
||||
path: '/shop/order-management',
|
||||
component: () => import('#/views/shop/order/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:shopping-cart',
|
||||
title: '订单管理',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'PromotionFeeManagement',
|
||||
path: '/shop/promotion-fee-management',
|
||||
component: () => import('#/views/shop/promotion-fee/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:credit-card',
|
||||
title: '推广费管理',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ConfigManagement',
|
||||
path: '/shop/config-management',
|
||||
meta: {
|
||||
icon: 'lucide:settings',
|
||||
title: '配置管理',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'OrderStatusConfig',
|
||||
path: '/shop/config-management/order-status',
|
||||
component: () => import('#/views/shop/config/order-status-config/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:list-checks',
|
||||
title: '订单状态类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'PromotionFeeTypeConfig',
|
||||
path: '/shop/config-management/promotion-fee-type',
|
||||
component: () => import('#/views/shop/config/promotion-fee-type-config/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:percent',
|
||||
title: '推广费用类型',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export default routes;
|
||||
+214
-15
@@ -1,9 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
} from '#/api/ecommerce/product-spec/types';
|
||||
import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
@@ -14,11 +20,14 @@ import {
|
||||
InputNumber,
|
||||
message,
|
||||
Select,
|
||||
Spin,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { createOrderApi, updateOrderApi } from '#/api/ecommerce/order';
|
||||
import { getActiveOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getProductSpecPageApi } from '#/api/ecommerce/product-spec';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -63,6 +72,20 @@ const formData = ref<Partial<OrderDTO.Create>>({
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const orderStatusOptions = ref<{ label: string; value: number }[]>([]);
|
||||
|
||||
// 商品选项数据
|
||||
const productOptions = ref<
|
||||
{ label: string; product: ProductVO.Info; value: number }[]
|
||||
>([]);
|
||||
const productLoading = ref(false);
|
||||
const productSearchKeyword = ref('');
|
||||
|
||||
// 规格选项数据
|
||||
const productSpecOptions = ref<
|
||||
{ label: string; spec: ProductSpecVO.Info; value: number }[]
|
||||
>([]);
|
||||
const productSpecLoading = ref(false);
|
||||
const productSpecSearchKeyword = ref('');
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
|
||||
@@ -71,7 +94,7 @@ const rules = {
|
||||
{ required: true, message: '请输入实收金额', trigger: 'blur' },
|
||||
],
|
||||
orderDate: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
productId: [{ required: true, message: '请输入商品ID', trigger: 'blur' }],
|
||||
productId: [{ required: true, message: '请选择商品', trigger: 'change' }],
|
||||
productName: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
|
||||
quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
|
||||
unitPrice: [{ required: true, message: '请输入销售单价', trigger: 'blur' }],
|
||||
@@ -112,8 +135,114 @@ async function fetchOrderStatusOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索商品
|
||||
async function searchProducts(keyword: string) {
|
||||
productSearchKeyword.value = keyword;
|
||||
productLoading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ProductDTO.Filters> = {
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
filters: {
|
||||
name: keyword || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getProductPageApi(params);
|
||||
productOptions.value = data.records.map((product: ProductVO.Info) => ({
|
||||
label: `${product.name}${product.productCode ? ` (${product.productCode})` : ''}`,
|
||||
value: product.id,
|
||||
product,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('搜索商品失败:', error);
|
||||
message.error('搜索商品失败');
|
||||
} finally {
|
||||
productLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索规格
|
||||
async function searchProductSpecs(keyword: string) {
|
||||
if (!formData.value.productId) {
|
||||
productSpecOptions.value = [];
|
||||
return;
|
||||
}
|
||||
productSpecSearchKeyword.value = keyword;
|
||||
productSpecLoading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ProductSpecDTO.Filters> = {
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
filters: {
|
||||
productId: formData.value.productId,
|
||||
name: keyword || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getProductSpecPageApi(params);
|
||||
productSpecOptions.value = data.records.map((spec: ProductSpecVO.Info) => ({
|
||||
label: `${spec.name}${spec.specCode ? ` (${spec.specCode})` : ''}`,
|
||||
value: spec.id,
|
||||
spec,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('搜索规格失败:', error);
|
||||
message.error('搜索规格失败');
|
||||
} finally {
|
||||
productSpecLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理商品选择
|
||||
function handleProductChange(productId: number | undefined) {
|
||||
if (productId) {
|
||||
const selectedProduct = productOptions.value.find(
|
||||
(opt) => opt.value === productId,
|
||||
);
|
||||
if (selectedProduct) {
|
||||
formData.value.productName = selectedProduct.product.name;
|
||||
// 加载该商品的规格列表
|
||||
searchProductSpecs('');
|
||||
}
|
||||
} else {
|
||||
formData.value.productName = '';
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.specName = '';
|
||||
formData.value.costPrice = 0;
|
||||
productSpecOptions.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 处理规格选择
|
||||
function handleProductSpecChange(specId: number | undefined) {
|
||||
if (specId) {
|
||||
const selectedSpec = productSpecOptions.value.find(
|
||||
(opt) => opt.value === specId,
|
||||
);
|
||||
if (selectedSpec) {
|
||||
formData.value.specName = selectedSpec.spec.name;
|
||||
formData.value.costPrice = selectedSpec.spec.costPrice;
|
||||
}
|
||||
} else {
|
||||
formData.value.specName = '';
|
||||
formData.value.costPrice = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 监听商品ID变化,加载规格列表
|
||||
watch(
|
||||
() => formData.value.productId,
|
||||
(newProductId) => {
|
||||
if (newProductId) {
|
||||
searchProductSpecs('');
|
||||
} else {
|
||||
productSpecOptions.value = [];
|
||||
formData.value.productSpecId = undefined;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 打开模态框
|
||||
function open(edit: boolean, record?: OrderVO.Info) {
|
||||
async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
isEdit.value = edit;
|
||||
currentRecord.value = record || null;
|
||||
|
||||
@@ -156,6 +285,41 @@ function open(edit: boolean, record?: OrderVO.Info) {
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
};
|
||||
|
||||
// 如果是编辑模式且有商品ID,加载商品和规格选项
|
||||
if (edit && record?.productId) {
|
||||
await searchProducts(record.productName || '');
|
||||
// 确保选中的商品在选项中
|
||||
if (!productOptions.value.some((opt) => opt.value === record.productId)) {
|
||||
productOptions.value.push({
|
||||
label: record.productName,
|
||||
value: record.productId,
|
||||
product: {
|
||||
id: record.productId,
|
||||
name: record.productName,
|
||||
} as ProductVO.Info,
|
||||
});
|
||||
}
|
||||
if (record.productSpecId) {
|
||||
await searchProductSpecs(record.specName || '');
|
||||
// 确保选中的规格在选项中
|
||||
if (
|
||||
!productSpecOptions.value.some(
|
||||
(opt) => opt.value === record.productSpecId,
|
||||
)
|
||||
) {
|
||||
productSpecOptions.value.push({
|
||||
label: record.specName || '',
|
||||
value: record.productSpecId,
|
||||
spec: {
|
||||
id: record.productSpecId,
|
||||
name: record.specName || '',
|
||||
costPrice: record.costPrice,
|
||||
} as ProductSpecVO.Info,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭模态框
|
||||
@@ -272,22 +436,57 @@ defineExpose({
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="商品ID" name="productId">
|
||||
<InputNumber
|
||||
<Form.Item label="商品" name="productId">
|
||||
<Select
|
||||
v-model:value="formData.productId"
|
||||
placeholder="请输入商品ID"
|
||||
style="width: 100%"
|
||||
:min="1"
|
||||
/>
|
||||
placeholder="请搜索并选择商品"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="productLoading"
|
||||
:options="productOptions"
|
||||
@search="searchProducts"
|
||||
@change="(value) => handleProductChange(value as number)"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="productLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-gray-400">
|
||||
{{ productSearchKeyword ? '未找到商品' : '请输入商品名称搜索' }}
|
||||
</div>
|
||||
</template>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品规格ID" name="productSpecId">
|
||||
<InputNumber
|
||||
<Form.Item label="商品规格" name="productSpecId">
|
||||
<Select
|
||||
v-model:value="formData.productSpecId"
|
||||
placeholder="请输入商品规格ID(可选)"
|
||||
style="width: 100%"
|
||||
:min="1"
|
||||
/>
|
||||
placeholder="请先选择商品,然后搜索规格"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="productSpecLoading"
|
||||
:disabled="!formData.productId"
|
||||
:options="productSpecOptions"
|
||||
@search="searchProductSpecs"
|
||||
@change="(value) => handleProductSpecChange(value as number)"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="productSpecLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-gray-400">
|
||||
{{
|
||||
formData.productId
|
||||
? productSpecSearchKeyword
|
||||
? '未找到规格'
|
||||
: '请输入规格名称搜索'
|
||||
: '请先选择商品'
|
||||
}}
|
||||
</div>
|
||||
</template>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
|
||||
+1
-36
@@ -6,15 +6,7 @@ import { computed, h, onUnmounted, ref, resolveComponent } from 'vue';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Space,
|
||||
Table,
|
||||
} from 'ant-design-vue';
|
||||
import { Button, Form, Input, message, Space, Table } from 'ant-design-vue';
|
||||
|
||||
import { createProductApi, updateProductApi } from '#/api/ecommerce/product';
|
||||
import { uploadImageApi } from '#/api/media/image';
|
||||
@@ -180,10 +172,7 @@ async function handleSubmit() {
|
||||
const updateData: ProductDTO.Update = {
|
||||
name: submitData.name,
|
||||
productCode: submitData.productCode || undefined,
|
||||
specCode: submitData.specCode || undefined,
|
||||
skuCode: submitData.skuCode || undefined,
|
||||
mainImageId: submitData.mainImageId,
|
||||
costPrice: submitData.costPrice,
|
||||
};
|
||||
await updateProductApi(currentProductData.value.id, updateData);
|
||||
message.success('更新成功');
|
||||
@@ -528,30 +517,6 @@ onUnmounted(() => {
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item v-if="isEdit" label="规格编码" name="specCode">
|
||||
<Input v-model:value="formData.specCode" placeholder="请输入规格编码" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item v-if="isEdit" label="商品SKU" name="skuCode">
|
||||
<Input v-model:value="formData.skuCode" placeholder="请输入商品SKU" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
v-if="isEdit"
|
||||
label="成本价"
|
||||
name="costPrice"
|
||||
:rules="[{ required: true, message: '请输入成本价' }]"
|
||||
>
|
||||
<InputNumber
|
||||
v-model:value="formData.costPrice"
|
||||
placeholder="请输入成本价"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.01"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<!-- 规格管理 -->
|
||||
<Form.Item v-if="!isEdit" label="商品规格">
|
||||
<div class="space-y-4">
|
||||
|
||||
+14
-10
@@ -1,5 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
} from '#/api/ecommerce/product-spec/types';
|
||||
import type { ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { h, ref } from 'vue';
|
||||
@@ -21,7 +25,7 @@ import {
|
||||
deleteProductSpecApi,
|
||||
getProductSpecPageApi,
|
||||
updateProductSpecApi,
|
||||
} from '#/api/ecommerce/product';
|
||||
} from '#/api/ecommerce/product-spec';
|
||||
|
||||
interface Emits {
|
||||
(e: 'success'): void;
|
||||
@@ -34,7 +38,7 @@ const currentProduct = ref<null | ProductVO.Info>(null);
|
||||
|
||||
// 响应式数据
|
||||
const specLoading = ref(false);
|
||||
const specList = ref<ProductVO.SpecInfo[]>([]);
|
||||
const specList = ref<ProductSpecVO.Info[]>([]);
|
||||
const specTotal = ref(0);
|
||||
const specCurrent = ref(1);
|
||||
const specPageSize = ref(10);
|
||||
@@ -73,7 +77,7 @@ async function handleSpecSubmit() {
|
||||
if (isEditSpec.value && currentSpecId.value) {
|
||||
await updateProductSpecApi(
|
||||
currentSpecId.value,
|
||||
specFormData.value as ProductDTO.UpdateSpec,
|
||||
specFormData.value as ProductSpecDTO.Update,
|
||||
);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
@@ -82,7 +86,7 @@ async function handleSpecSubmit() {
|
||||
return;
|
||||
}
|
||||
|
||||
const createData: ProductDTO.CreateSpec = {
|
||||
const createData: ProductSpecDTO.Create = {
|
||||
productId: currentProduct.value.id,
|
||||
...specFormData.value,
|
||||
};
|
||||
@@ -149,7 +153,7 @@ const columns = [
|
||||
dataIndex: 'costPrice',
|
||||
key: 'costPrice',
|
||||
width: 120,
|
||||
customRender: ({ record }: { record: ProductVO.SpecInfo }) => {
|
||||
customRender: ({ record }: { record: ProductSpecVO.Info }) => {
|
||||
return `¥${record.costPrice.toFixed(2)}`;
|
||||
},
|
||||
},
|
||||
@@ -164,7 +168,7 @@ const columns = [
|
||||
key: 'action',
|
||||
width: 150,
|
||||
fixed: 'right' as const,
|
||||
customRender: ({ record }: { record: ProductVO.SpecInfo }) => {
|
||||
customRender: ({ record }: { record: ProductSpecVO.Info }) => {
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, [
|
||||
h(
|
||||
Button,
|
||||
@@ -200,7 +204,7 @@ async function fetchSpecList() {
|
||||
|
||||
try {
|
||||
specLoading.value = true;
|
||||
const params: PageQueryDTO<ProductDTO.SpecFilters> = {
|
||||
const params: PageQueryDTO<ProductSpecDTO.Filters> = {
|
||||
page: specCurrent.value,
|
||||
pageSize: specPageSize.value,
|
||||
filters: {
|
||||
@@ -239,7 +243,7 @@ function handleAddSpec() {
|
||||
}
|
||||
|
||||
// 处理编辑规格
|
||||
function handleEditSpec(record: ProductVO.SpecInfo) {
|
||||
function handleEditSpec(record: ProductSpecVO.Info) {
|
||||
isEditSpec.value = true;
|
||||
currentSpecId.value = record.id;
|
||||
specFormData.value = {
|
||||
@@ -252,7 +256,7 @@ function handleEditSpec(record: ProductVO.SpecInfo) {
|
||||
}
|
||||
|
||||
// 处理删除规格
|
||||
async function handleDeleteSpec(record: ProductVO.SpecInfo) {
|
||||
async function handleDeleteSpec(record: ProductSpecVO.Info) {
|
||||
try {
|
||||
await deleteProductSpecApi(record.id);
|
||||
message.success('删除成功');
|
||||
|
||||
@@ -30,12 +30,9 @@ const productGridViewRef = ref<null | { refreshTable: () => void }>(null);
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
id: undefined as number | undefined,
|
||||
name: '',
|
||||
productCode: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
minCostPrice: undefined as number | undefined,
|
||||
maxCostPrice: undefined as number | undefined,
|
||||
});
|
||||
|
||||
// 刷新表格数据
|
||||
|
||||
+13
-62
@@ -27,12 +27,9 @@ defineOptions({ name: 'ProductGridView' });
|
||||
|
||||
const props = defineProps<{
|
||||
searchForm: {
|
||||
maxCostPrice?: number;
|
||||
minCostPrice?: number;
|
||||
id?: number;
|
||||
name: string;
|
||||
productCode: string;
|
||||
skuCode: string;
|
||||
specCode: string;
|
||||
};
|
||||
}>();
|
||||
|
||||
@@ -54,12 +51,9 @@ const scrollContainerRef = ref<HTMLElement | null>(null);
|
||||
|
||||
// 本地搜索表单副本(用于 v-model)
|
||||
const localSearchForm = ref({
|
||||
id: props.searchForm.id,
|
||||
name: props.searchForm.name,
|
||||
productCode: props.searchForm.productCode,
|
||||
specCode: props.searchForm.specCode,
|
||||
skuCode: props.searchForm.skuCode,
|
||||
minCostPrice: props.searchForm.minCostPrice,
|
||||
maxCostPrice: props.searchForm.maxCostPrice,
|
||||
});
|
||||
|
||||
// 监听 props 变化,同步到本地
|
||||
@@ -67,19 +61,13 @@ watch(
|
||||
() => props.searchForm,
|
||||
(newForm) => {
|
||||
if (
|
||||
localSearchForm.value.id !== newForm.id ||
|
||||
localSearchForm.value.name !== newForm.name ||
|
||||
localSearchForm.value.productCode !== newForm.productCode ||
|
||||
localSearchForm.value.specCode !== newForm.specCode ||
|
||||
localSearchForm.value.skuCode !== newForm.skuCode ||
|
||||
localSearchForm.value.minCostPrice !== newForm.minCostPrice ||
|
||||
localSearchForm.value.maxCostPrice !== newForm.maxCostPrice
|
||||
localSearchForm.value.productCode !== newForm.productCode
|
||||
) {
|
||||
localSearchForm.value.id = newForm.id;
|
||||
localSearchForm.value.name = newForm.name;
|
||||
localSearchForm.value.productCode = newForm.productCode;
|
||||
localSearchForm.value.specCode = newForm.specCode;
|
||||
localSearchForm.value.skuCode = newForm.skuCode;
|
||||
localSearchForm.value.minCostPrice = newForm.minCostPrice;
|
||||
localSearchForm.value.maxCostPrice = newForm.maxCostPrice;
|
||||
// 重置分页和列表
|
||||
current.value = 1;
|
||||
productList.value = [];
|
||||
@@ -95,12 +83,9 @@ watch(
|
||||
localSearchForm,
|
||||
(newForm) => {
|
||||
if (
|
||||
props.searchForm.id !== newForm.id ||
|
||||
props.searchForm.name !== newForm.name ||
|
||||
props.searchForm.productCode !== newForm.productCode ||
|
||||
props.searchForm.specCode !== newForm.specCode ||
|
||||
props.searchForm.skuCode !== newForm.skuCode ||
|
||||
props.searchForm.minCostPrice !== newForm.minCostPrice ||
|
||||
props.searchForm.maxCostPrice !== newForm.maxCostPrice
|
||||
props.searchForm.productCode !== newForm.productCode
|
||||
) {
|
||||
emit('update:searchForm', { ...newForm });
|
||||
}
|
||||
@@ -118,12 +103,9 @@ const loadProductList = async (reset = false) => {
|
||||
page: current.value,
|
||||
pageSize: pageSize.value,
|
||||
filters: {
|
||||
id: localSearchForm.value.id,
|
||||
name: localSearchForm.value.name || undefined,
|
||||
productCode: localSearchForm.value.productCode || undefined,
|
||||
specCode: localSearchForm.value.specCode || undefined,
|
||||
skuCode: localSearchForm.value.skuCode || undefined,
|
||||
minCostPrice: localSearchForm.value.minCostPrice,
|
||||
maxCostPrice: localSearchForm.value.maxCostPrice,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -164,10 +146,7 @@ const handleReset = () => {
|
||||
localSearchForm.value = {
|
||||
name: '',
|
||||
productCode: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
minCostPrice: undefined,
|
||||
maxCostPrice: undefined,
|
||||
id: undefined,
|
||||
};
|
||||
handleSearch();
|
||||
};
|
||||
@@ -249,43 +228,15 @@ onUnmounted(() => {
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="规格编码" class="mb-0">
|
||||
<Input
|
||||
v-model:value="localSearchForm.specCode"
|
||||
placeholder="请输入规格编码"
|
||||
<Form.Item label="商品ID" class="mb-0">
|
||||
<InputNumber
|
||||
v-model:value="localSearchForm.id"
|
||||
placeholder="请输入商品ID"
|
||||
style="width: 150px"
|
||||
allow-clear
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="商品SKU" class="mb-0">
|
||||
<Input
|
||||
v-model:value="localSearchForm.skuCode"
|
||||
placeholder="请输入商品SKU"
|
||||
style="width: 150px"
|
||||
allow-clear
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="成本价范围" class="mb-0">
|
||||
<div class="flex items-center gap-2">
|
||||
<InputNumber
|
||||
v-model:value="localSearchForm.minCostPrice"
|
||||
placeholder="最小值"
|
||||
style="width: 100px"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
<span class="text-gray-500">-</span>
|
||||
<InputNumber
|
||||
v-model:value="localSearchForm.maxCostPrice"
|
||||
placeholder="最大值"
|
||||
style="width: 100px"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
<Form.Item class="mb-0">
|
||||
<Space>
|
||||
<Button type="primary" @click="handleSearch">搜索</Button>
|
||||
|
||||
+11
-58
@@ -14,12 +14,9 @@ defineOptions({ name: 'ProductListView' });
|
||||
|
||||
const props = defineProps<{
|
||||
searchForm: {
|
||||
maxCostPrice?: number;
|
||||
minCostPrice?: number;
|
||||
id?: number;
|
||||
name: string;
|
||||
productCode: string;
|
||||
skuCode: string;
|
||||
specCode: string;
|
||||
};
|
||||
}>();
|
||||
|
||||
@@ -35,12 +32,9 @@ const loading = ref(false);
|
||||
|
||||
// 本地搜索表单副本(用于 v-model)
|
||||
const localSearchForm = ref({
|
||||
id: props.searchForm.id,
|
||||
name: props.searchForm.name,
|
||||
productCode: props.searchForm.productCode,
|
||||
specCode: props.searchForm.specCode,
|
||||
skuCode: props.searchForm.skuCode,
|
||||
minCostPrice: props.searchForm.minCostPrice,
|
||||
maxCostPrice: props.searchForm.maxCostPrice,
|
||||
});
|
||||
|
||||
// 监听 props 变化,同步到本地
|
||||
@@ -48,19 +42,13 @@ watch(
|
||||
() => props.searchForm,
|
||||
(newForm) => {
|
||||
if (
|
||||
localSearchForm.value.id !== newForm.id ||
|
||||
localSearchForm.value.name !== newForm.name ||
|
||||
localSearchForm.value.productCode !== newForm.productCode ||
|
||||
localSearchForm.value.specCode !== newForm.specCode ||
|
||||
localSearchForm.value.skuCode !== newForm.skuCode ||
|
||||
localSearchForm.value.minCostPrice !== newForm.minCostPrice ||
|
||||
localSearchForm.value.maxCostPrice !== newForm.maxCostPrice
|
||||
localSearchForm.value.productCode !== newForm.productCode
|
||||
) {
|
||||
localSearchForm.value.id = newForm.id;
|
||||
localSearchForm.value.name = newForm.name;
|
||||
localSearchForm.value.productCode = newForm.productCode;
|
||||
localSearchForm.value.specCode = newForm.specCode;
|
||||
localSearchForm.value.skuCode = newForm.skuCode;
|
||||
localSearchForm.value.minCostPrice = newForm.minCostPrice;
|
||||
localSearchForm.value.maxCostPrice = newForm.maxCostPrice;
|
||||
refreshTable();
|
||||
}
|
||||
},
|
||||
@@ -72,12 +60,9 @@ watch(
|
||||
localSearchForm,
|
||||
(newForm) => {
|
||||
if (
|
||||
props.searchForm.id !== newForm.id ||
|
||||
props.searchForm.name !== newForm.name ||
|
||||
props.searchForm.productCode !== newForm.productCode ||
|
||||
props.searchForm.specCode !== newForm.specCode ||
|
||||
props.searchForm.skuCode !== newForm.skuCode ||
|
||||
props.searchForm.minCostPrice !== newForm.minCostPrice ||
|
||||
props.searchForm.maxCostPrice !== newForm.maxCostPrice
|
||||
props.searchForm.productCode !== newForm.productCode
|
||||
) {
|
||||
emit('update:searchForm', { ...newForm });
|
||||
}
|
||||
@@ -177,12 +162,9 @@ const gridOptions: VxeGridProps<any> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
id: localSearchForm.value.id,
|
||||
name: localSearchForm.value.name || undefined,
|
||||
productCode: localSearchForm.value.productCode || undefined,
|
||||
specCode: localSearchForm.value.specCode || undefined,
|
||||
skuCode: localSearchForm.value.skuCode || undefined,
|
||||
minCostPrice: localSearchForm.value.minCostPrice,
|
||||
maxCostPrice: localSearchForm.value.maxCostPrice,
|
||||
},
|
||||
};
|
||||
const data = await getProductPageApi(params);
|
||||
@@ -224,43 +206,14 @@ const formOptions = computed(() => ({
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规格编码',
|
||||
},
|
||||
fieldName: 'specCode',
|
||||
label: '规格编码',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品SKU',
|
||||
},
|
||||
fieldName: 'skuCode',
|
||||
label: '商品SKU',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '最小值',
|
||||
min: 0,
|
||||
precision: 2,
|
||||
placeholder: '请输入商品ID',
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'minCostPrice',
|
||||
label: '成本价最小值',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '最大值',
|
||||
min: 0,
|
||||
precision: 2,
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'maxCostPrice',
|
||||
label: '成本价最大值',
|
||||
fieldName: 'id',
|
||||
label: '商品ID',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
|
||||
@@ -0,0 +1,367 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Card,
|
||||
Col,
|
||||
DatePicker,
|
||||
Image,
|
||||
message,
|
||||
Row,
|
||||
Space,
|
||||
Statistic,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
getShopProductPageApi,
|
||||
getShopStatisticsApi,
|
||||
} from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'ShopDetails' });
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
// 店铺ID(从路由参数获取)
|
||||
const shopId = computed(() => {
|
||||
const id = route.params.id;
|
||||
return id ? Number(id) : 0;
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const tableLoading = ref(false);
|
||||
const customStats = ref<null | ShopVO.Statistics>(null);
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
dayjs().startOf('month'),
|
||||
dayjs(),
|
||||
]);
|
||||
|
||||
// 格式化金额
|
||||
function formatCurrency(value: number): string {
|
||||
return `¥${value.toLocaleString('zh-CN', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`;
|
||||
}
|
||||
|
||||
// 格式化百分比
|
||||
function formatPercent(value: number): string {
|
||||
return `${(value * 100).toFixed(2)}%`;
|
||||
}
|
||||
|
||||
// 获取自定义日期范围统计信息
|
||||
async function fetchCustomStatistics() {
|
||||
if (!shopId.value || !dateRange.value) return;
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: ShopDTO.StatisticsQuery = {
|
||||
shopId: shopId.value,
|
||||
startDate: dateRange.value[0].format('YYYY-MM-DD'),
|
||||
endDate: dateRange.value[1].format('YYYY-MM-DD'),
|
||||
};
|
||||
const data = await getShopStatisticsApi(params);
|
||||
customStats.value = data;
|
||||
} catch (error) {
|
||||
console.error('获取统计信息失败:', error);
|
||||
message.error('获取统计信息失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理日期范围变化
|
||||
function handleDateRangeChange() {
|
||||
fetchCustomStatistics();
|
||||
}
|
||||
|
||||
// 店铺ID的稳定引用,避免响应式循环
|
||||
const stableShopId = computed(() => {
|
||||
const id = route.params.id;
|
||||
return id ? Number(id) : 0;
|
||||
});
|
||||
|
||||
// VbenVxeGrid 表格配置 - 商品列表
|
||||
const gridOptions: VxeGridProps<ShopVO.ProductDetail> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
width: 80,
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
title: '商品主图',
|
||||
width: 100,
|
||||
align: 'center' as const,
|
||||
slots: { default: 'mainImage' },
|
||||
},
|
||||
{
|
||||
field: 'productName',
|
||||
title: '商品名称',
|
||||
minWidth: 200,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'productCode',
|
||||
title: '商品编码',
|
||||
minWidth: 150,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'salesAmount',
|
||||
title: '销售额',
|
||||
width: 150,
|
||||
align: 'right' as const,
|
||||
formatter: ({ cellValue }) => formatCurrency(cellValue || 0),
|
||||
},
|
||||
{
|
||||
field: 'orderCount',
|
||||
title: '订单数',
|
||||
width: 120,
|
||||
align: 'right' as const,
|
||||
},
|
||||
{
|
||||
field: 'averageOrderValue',
|
||||
title: '客单价',
|
||||
width: 150,
|
||||
align: 'right' as const,
|
||||
formatter: ({ cellValue }) => formatCurrency(cellValue || 0),
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
width: 180,
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
},
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载
|
||||
proxyConfig: {
|
||||
autoLoad: false, // 禁用自动加载,手动控制
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
// 确保 shopId 有值才查询,使用稳定的 shopId 引用
|
||||
const currentShopId = stableShopId.value;
|
||||
if (!currentShopId) {
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
}
|
||||
try {
|
||||
tableLoading.value = true;
|
||||
const params: PageQueryDTO<ShopDTO.ProductFilters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: currentShopId,
|
||||
productName: formValues?.productName || undefined,
|
||||
productCode: formValues?.productCode || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getShopProductPageApi(params);
|
||||
return {
|
||||
items: data.records || [],
|
||||
total: data.total || 0,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取商品列表失败:', error);
|
||||
message.error('获取商品列表失败');
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
} finally {
|
||||
tableLoading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置 - 使用稳定的对象引用
|
||||
const formOptions = {
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品名称',
|
||||
},
|
||||
fieldName: 'productName',
|
||||
label: '商品名称',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码',
|
||||
},
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
};
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions,
|
||||
showSearchForm: true,
|
||||
tableTitle: '商品列表',
|
||||
});
|
||||
|
||||
// 初始化数据
|
||||
onMounted(() => {
|
||||
if (shopId.value) {
|
||||
fetchCustomStatistics();
|
||||
// 手动触发表格加载,确保 shopId 有值
|
||||
setTimeout(() => {
|
||||
if (gridApi && shopId.value) {
|
||||
gridApi.reload();
|
||||
}
|
||||
}, 100);
|
||||
} else {
|
||||
message.error('店铺ID不存在');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="店铺详情" auto-content-height>
|
||||
<!-- 店铺统计信息 -->
|
||||
<Card title="店铺统计信息" class="mb-4" :loading="loading">
|
||||
<div class="mb-4">
|
||||
<Space>
|
||||
<span>选择日期范围:</span>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="dateRange"
|
||||
format="YYYY-MM-DD"
|
||||
@change="handleDateRangeChange"
|
||||
/>
|
||||
</Space>
|
||||
</div>
|
||||
<Row :gutter="16" v-if="customStats">
|
||||
<Col :span="6">
|
||||
<Statistic
|
||||
title="销售额"
|
||||
:value="customStats.salesAmount"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6">
|
||||
<Statistic title="订单数" :value="customStats.orderCount" />
|
||||
</Col>
|
||||
<Col :span="6">
|
||||
<Statistic
|
||||
title="客单价"
|
||||
:value="customStats.averageOrderValue"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6">
|
||||
<Statistic
|
||||
title="成本"
|
||||
:value="customStats.costAmount"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6" class="mt-4">
|
||||
<Statistic
|
||||
title="退款金额"
|
||||
:value="customStats.refundAmount"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6" class="mt-4">
|
||||
<Statistic
|
||||
title="推广费"
|
||||
:value="customStats.promotionFee"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6" class="mt-4">
|
||||
<Statistic
|
||||
title="费比"
|
||||
:value="customStats.feeRatio"
|
||||
:formatter="({ value }) => formatPercent(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
<!-- 商品列表表格 -->
|
||||
<Card title="商品详细信息" :loading="tableLoading">
|
||||
<Grid>
|
||||
<!-- 商品主图列 -->
|
||||
<template #mainImage="{ row }: { row: ShopVO.ProductDetail }">
|
||||
<div
|
||||
v-if="row.mainImage"
|
||||
style="display: flex; justify-content: center; align-items: center"
|
||||
>
|
||||
<Image
|
||||
:src="row.mainImage"
|
||||
:alt="row.productName"
|
||||
:preview="false"
|
||||
style="
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
style="display: flex; justify-content: center; align-items: center"
|
||||
>
|
||||
<span style="color: #999">暂无图片</span>
|
||||
</div>
|
||||
</template>
|
||||
</Grid>
|
||||
</Card>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -4,6 +4,7 @@ import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
@@ -17,6 +18,8 @@ import ShopFormModal from './components/ShopFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'ShopManagement' });
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
// 创建图标组件
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
|
||||
@@ -59,6 +62,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
title: '店铺名称',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
slots: { default: 'name' },
|
||||
},
|
||||
{
|
||||
field: 'platform',
|
||||
@@ -220,6 +224,11 @@ async function handleDelete(record: ShopVO.Info) {
|
||||
function handleModalSuccess() {
|
||||
refreshTable();
|
||||
}
|
||||
|
||||
// 处理查看详情
|
||||
function handleViewDetails(record: ShopVO.Info) {
|
||||
router.push(`/ecom/shop/details/${record.id}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -267,9 +276,22 @@ function handleModalSuccess() {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 店铺名称列 -->
|
||||
<template #name="{ row }: { row: ShopVO.Info }">
|
||||
<a
|
||||
class="text-primary cursor-pointer hover:underline"
|
||||
@click="handleViewDetails(row)"
|
||||
>
|
||||
{{ row.name }}
|
||||
</a>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Button size="small" type="primary" @click="handleViewDetails(row)">
|
||||
查看详情
|
||||
</Button>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个店铺吗?"
|
||||
|
||||
Reference in New Issue
Block a user