商品导出
This commit is contained in:
@@ -0,0 +1,173 @@
|
||||
package com.czg.product.dto;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品导出
|
||||
* @author yjjie
|
||||
* @date 2026/1/28 14:30
|
||||
*/
|
||||
@Data
|
||||
public class ProductExportDTO {
|
||||
|
||||
@Data
|
||||
public static class ProductSkuExportDTO {
|
||||
|
||||
@ExcelProperty("条形码")
|
||||
private String barCode;
|
||||
|
||||
@ExcelProperty("原价")
|
||||
private BigDecimal originPrice;
|
||||
|
||||
@ExcelProperty("成本价")
|
||||
private BigDecimal costPrice;
|
||||
|
||||
@ExcelProperty("会员价")
|
||||
private BigDecimal memberPrice;
|
||||
|
||||
@ExcelProperty("售价")
|
||||
private BigDecimal salePrice;
|
||||
|
||||
@ExcelProperty("起售数量")
|
||||
private Integer suitNum;
|
||||
|
||||
@ExcelProperty("规格详情")
|
||||
private String specInfo;
|
||||
|
||||
@ExcelProperty("是否上架")
|
||||
private Integer isGrounding;
|
||||
|
||||
|
||||
@ExcelProperty("规格名称")
|
||||
private String name;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ProductGroupExportDTO {
|
||||
@ExcelProperty("套餐内商品总数")
|
||||
private Integer count;
|
||||
|
||||
@ExcelProperty("套餐选几")
|
||||
private Integer number;
|
||||
|
||||
@ExcelProperty("套餐名称")
|
||||
private String title;
|
||||
|
||||
@ExcelProperty("套餐内商品列表")
|
||||
private List<FoodExportDTO> goods = new ArrayList<>();
|
||||
|
||||
@Data
|
||||
public static class FoodExportDTO {
|
||||
|
||||
@ExcelProperty("商品名称")
|
||||
private String proName;
|
||||
|
||||
@ExcelProperty("规格名称")
|
||||
private String skuName;
|
||||
}
|
||||
}
|
||||
|
||||
@ExcelProperty("商品名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("商品分类名称")
|
||||
private String categoryName;
|
||||
|
||||
@ExcelProperty("条码")
|
||||
private String barCode;
|
||||
|
||||
@ExcelProperty("商品规格名称")
|
||||
private String specFullName;
|
||||
|
||||
@ExcelProperty("售价")
|
||||
private BigDecimal price;
|
||||
@ExcelProperty("会员价")
|
||||
private BigDecimal memberPrice;
|
||||
|
||||
@ExcelProperty("商品单位名称")
|
||||
private String unitName;
|
||||
|
||||
/**
|
||||
* 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
|
||||
*/
|
||||
@ExcelProperty("商品类型")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 套餐类型 0 固定套餐 1可选套餐
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private Integer groupType;
|
||||
@ExcelProperty("套餐类型")
|
||||
private String groupTypeRemark;
|
||||
|
||||
/**
|
||||
* 可用开始时间
|
||||
*/
|
||||
@ExcelProperty("可用开始时间")
|
||||
private LocalTime startTime;
|
||||
/**
|
||||
* 可用结束时间
|
||||
*/
|
||||
@ExcelProperty("可用结束时间")
|
||||
private LocalTime endTime;
|
||||
|
||||
/**
|
||||
* 商品级库存数量
|
||||
*/
|
||||
@ExcelProperty("库存数量")
|
||||
private Integer stockNumber;
|
||||
|
||||
/**
|
||||
* 是否上架
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private Integer isSale;
|
||||
@ExcelProperty("是否上架")
|
||||
private String isSaleRemark;
|
||||
|
||||
|
||||
@ExcelIgnore
|
||||
private List<ProductSkuExportDTO> skuList;
|
||||
|
||||
@ExcelIgnore
|
||||
private List<ProductGroupExportDTO> proGroupVo;
|
||||
|
||||
|
||||
public String getType() {
|
||||
return switch (type) {
|
||||
case "single" -> "单规格商品";
|
||||
case "sku" -> "多规格商品";
|
||||
case "package" -> "套餐商品";
|
||||
case "weight" -> "称重商品";
|
||||
case "coupon" -> "团购券";
|
||||
case null, default -> "未知类型";
|
||||
};
|
||||
}
|
||||
|
||||
public String getGroupTypeRemark() {
|
||||
if (!"package".equals(type)) {
|
||||
return "";
|
||||
}
|
||||
return switch (groupType) {
|
||||
case 0 -> "固定套餐";
|
||||
case 1 -> "可选套餐";
|
||||
case null, default -> "未知类型";
|
||||
};
|
||||
}
|
||||
|
||||
public String getIsSaleRemark() {
|
||||
return switch (isSale) {
|
||||
case 0 -> "下架";
|
||||
case 1 -> "上架";
|
||||
case null, default -> "未知状态";
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.czg.product.service;
|
||||
|
||||
import com.czg.product.dto.ProductDTO;
|
||||
import com.czg.product.dto.RelatedProductDTO;
|
||||
import com.czg.product.entity.Product;
|
||||
import com.czg.product.entity.ProductStockFlow;
|
||||
import com.czg.product.param.*;
|
||||
import com.czg.product.vo.ProductStatisticsVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -34,6 +34,8 @@ public interface ProductService extends IService<Product> {
|
||||
*/
|
||||
List<ProductDTO> getProductList(ProductDTO param);
|
||||
|
||||
void exportProductList(ProductDTO param, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 从缓存里面获取商品列表
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user