商品模块代码提交
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
package com.czg.product.dto;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 商品SKU
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-16
|
||||
*/
|
||||
@Data
|
||||
public class ProdSkuDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 条形码
|
||||
*/
|
||||
private String barCode;
|
||||
/**
|
||||
* 商品Id
|
||||
*/
|
||||
private Long productId;
|
||||
/**
|
||||
* 原价
|
||||
*/
|
||||
private BigDecimal originPrice;
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
private BigDecimal costPrice;
|
||||
/**
|
||||
* 会员价
|
||||
*/
|
||||
private BigDecimal memberPrice;
|
||||
/**
|
||||
* 售价
|
||||
*/
|
||||
private BigDecimal salePrice;
|
||||
/**
|
||||
* 起售数量
|
||||
*/
|
||||
private Integer suitNum;
|
||||
/**
|
||||
* 规格详情
|
||||
*/
|
||||
private String specInfo;
|
||||
/**
|
||||
* sku图片
|
||||
*/
|
||||
private String coverImg;
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
/**
|
||||
* 销量
|
||||
*/
|
||||
private BigDecimal realSalesNumber;
|
||||
/**
|
||||
* 是否售罄
|
||||
*/
|
||||
private Integer isPauseSale;
|
||||
/**
|
||||
* 是否上架
|
||||
*/
|
||||
private Integer isGrounding;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
/**
|
||||
* 逻辑删除字段 0否 1 删除
|
||||
*/
|
||||
private Integer isDel;
|
||||
|
||||
}
|
||||
@@ -1,50 +1,87 @@
|
||||
package com.czg.product.dto;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.czg.product.vo.ProductGroupVo;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.czg.validator.group.UpdateGroup;
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-10
|
||||
*/
|
||||
* 商品
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-16
|
||||
*/
|
||||
@Data
|
||||
public class ProductDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
@Null(message = "ID必须为空", groups = InsertGroup.class)
|
||||
@NotNull(message = "ID不能为空", groups = UpdateGroup.class)
|
||||
private Long id;
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
private String categoryId;
|
||||
@NotNull(message = "商品分类不能为空", groups = DefaultGroup.class)
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 商品分类名称
|
||||
*/
|
||||
private String categoryName;
|
||||
/**
|
||||
* 商品规格
|
||||
*/
|
||||
private Integer specId;
|
||||
private Long specId;
|
||||
/**
|
||||
* 商品规格名称
|
||||
*/
|
||||
private String specName;
|
||||
/**
|
||||
* 商品规格完整名称
|
||||
*/
|
||||
private String specFullName;
|
||||
/**
|
||||
* 单位Id
|
||||
*/
|
||||
private Integer unitId;
|
||||
private String shopId;
|
||||
@NotNull(message = "商品单位不能为空", groups = DefaultGroup.class)
|
||||
private Long unitId;
|
||||
/**
|
||||
* 商品单位名称
|
||||
*/
|
||||
private String unitName;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@NotBlank(message = "商品名称不能为空", groups = DefaultGroup.class)
|
||||
private String name;
|
||||
/**
|
||||
* 短标题--促销语
|
||||
*/
|
||||
private String shortTitle;
|
||||
/**
|
||||
* 单规格商品 single 多规格商品 sku 套餐商品 package 称重商品 weigh 团购券 coupon
|
||||
* 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
|
||||
*/
|
||||
@NotBlank(message = "商品类型不能为空", groups = DefaultGroup.class)
|
||||
private String type;
|
||||
/**
|
||||
* 0 固定套餐 1可选套餐
|
||||
@@ -53,15 +90,17 @@ public class ProductDTO implements Serializable {
|
||||
/**
|
||||
* 包装费
|
||||
*/
|
||||
@NotNull(message = "打包费不能为空", groups = DefaultGroup.class)
|
||||
private BigDecimal packFee;
|
||||
/**
|
||||
* 商品封面图
|
||||
*/
|
||||
@NotBlank(message = "商品名称不能为空", groups = DefaultGroup.class)
|
||||
private String coverImg;
|
||||
/**
|
||||
* 商品图片(第一张为缩略图,其他为详情)
|
||||
*/
|
||||
private String images;
|
||||
private Object images;
|
||||
/**
|
||||
* 套餐内容
|
||||
*/
|
||||
@@ -73,23 +112,30 @@ public class ProductDTO implements Serializable {
|
||||
/**
|
||||
* 称重 价格/千克
|
||||
*/
|
||||
@NotNull(message = "重量不能为空", groups = DefaultGroup.class)
|
||||
private BigDecimal weight;
|
||||
/**
|
||||
* 是否允许临时改价
|
||||
*/
|
||||
private Integer isTempPrice;
|
||||
@NotNull(message = "是否允许临时改价不能为空", groups = DefaultGroup.class)
|
||||
private Integer isAllowTempModifyPrice;
|
||||
/**
|
||||
* 周 数组 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday'
|
||||
*/
|
||||
@NotBlank(message = "定时上下架周期不能为空", groups = DefaultGroup.class)
|
||||
private String days;
|
||||
/**
|
||||
* 可用开始时间
|
||||
*/
|
||||
private Object startTime;
|
||||
@NotNull(message = "可用开始时间", groups = DefaultGroup.class)
|
||||
@JSONField(format = "HH:mm:ss")
|
||||
private LocalTime startTime;
|
||||
/**
|
||||
* 可用结束时间
|
||||
*/
|
||||
private Object endTime;
|
||||
@NotNull(message = "可用结束时间", groups = DefaultGroup.class)
|
||||
@JSONField(format = "HH:mm:ss")
|
||||
private LocalTime endTime;
|
||||
/**
|
||||
* 规格详情
|
||||
*/
|
||||
@@ -97,14 +143,19 @@ public class ProductDTO implements Serializable {
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@NotNull(message = "排序值不能为空", groups = DefaultGroup.class)
|
||||
@Min(value = 1, message = "排序值不能小于1", groups = DefaultGroup.class)
|
||||
@Max(value = Integer.MAX_VALUE, message = "排序值不能大于" + Integer.MAX_VALUE, groups = DefaultGroup.class)
|
||||
private Integer sort;
|
||||
/**
|
||||
* 是否热销
|
||||
*/
|
||||
@NotNull(message = "是否推荐不能为空", groups = DefaultGroup.class)
|
||||
private Integer isHot;
|
||||
/**
|
||||
* 是否开启库存
|
||||
*/
|
||||
@NotNull(message = "库存开关不能为空", groups = DefaultGroup.class)
|
||||
private Integer isStock;
|
||||
/**
|
||||
* 是否售罄
|
||||
@@ -121,13 +172,20 @@ public class ProductDTO implements Serializable {
|
||||
/**
|
||||
* 是否上架
|
||||
*/
|
||||
@NotNull(message = "是否上架不能为空", groups = DefaultGroup.class)
|
||||
private Integer isSale;
|
||||
/**
|
||||
* 退款是否退回库存
|
||||
*/
|
||||
private Integer isRefundStock;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
/**
|
||||
@@ -135,4 +193,14 @@ public class ProductDTO implements Serializable {
|
||||
*/
|
||||
private Integer isDel;
|
||||
|
||||
/**
|
||||
* 商品规格列表
|
||||
*/
|
||||
private List<ProdSkuDTO> skuList;
|
||||
|
||||
private List<ProductGroupVo> proGroupVo;
|
||||
|
||||
public Object getImages() {
|
||||
return JSON.parseArray(Convert.toStr(images, "[]"));
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,8 @@ public class ShopProdSpecDTO extends TreeNode<ShopProdSpecDTO> implements Serial
|
||||
* 规格级别
|
||||
*/
|
||||
@NotNull(message = "规格级别不能为空", groups = DefaultGroup.class)
|
||||
@Min(value = 1, message = "排序值不能小于1", groups = DefaultGroup.class)
|
||||
@Max(value = 3, message = "排序值不能大于3", groups = DefaultGroup.class)
|
||||
@Min(value = 1, message = "规格级别不能小于1", groups = DefaultGroup.class)
|
||||
@Max(value = 3, message = "规格级别不能大于3", groups = DefaultGroup.class)
|
||||
private Integer level;
|
||||
/**
|
||||
* 排序
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.czg.product.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.keygen.KeyGenerators;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 商品SKU
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-16
|
||||
*/
|
||||
@Data
|
||||
@Table("tb_prod_sku")
|
||||
public class ProdSku implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 条形码
|
||||
*/
|
||||
private String barCode;
|
||||
/**
|
||||
* 商品Id
|
||||
*/
|
||||
private Long productId;
|
||||
/**
|
||||
* 原价
|
||||
*/
|
||||
private BigDecimal originPrice;
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
private BigDecimal costPrice;
|
||||
/**
|
||||
* 会员价
|
||||
*/
|
||||
private BigDecimal memberPrice;
|
||||
/**
|
||||
* 售价
|
||||
*/
|
||||
private BigDecimal salePrice;
|
||||
/**
|
||||
* 起售数量
|
||||
*/
|
||||
private Integer suitNum;
|
||||
/**
|
||||
* 规格详情
|
||||
*/
|
||||
private String specInfo;
|
||||
private String coverImg;
|
||||
private BigDecimal weight;
|
||||
/**
|
||||
* 销量
|
||||
*/
|
||||
private BigDecimal realSalesNumber;
|
||||
/**
|
||||
* 是否售罄
|
||||
*/
|
||||
private Integer isPauseSale;
|
||||
/**
|
||||
* 是否上架
|
||||
*/
|
||||
private Integer isGrounding;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
/**
|
||||
* 逻辑删除字段 0否 1 删除
|
||||
*/
|
||||
private Integer isDel;
|
||||
}
|
||||
@@ -1,20 +1,23 @@
|
||||
package com.czg.product.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.keygen.KeyGenerators;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-10
|
||||
* @since 1.0 2025-02-16
|
||||
*/
|
||||
@Data
|
||||
@Table("tb_product")
|
||||
@@ -26,12 +29,12 @@ public class Product implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
|
||||
private Long id;
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
private String categoryId;
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 商品规格
|
||||
*/
|
||||
@@ -40,6 +43,9 @@ public class Product implements Serializable {
|
||||
* 单位Id
|
||||
*/
|
||||
private Long unitId;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 商品名称
|
||||
@@ -50,7 +56,7 @@ public class Product implements Serializable {
|
||||
*/
|
||||
private String shortTitle;
|
||||
/**
|
||||
* 单规格商品 single 多规格商品 sku 套餐商品 package 称重商品 weigh 团购券 coupon
|
||||
* 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
@@ -84,7 +90,7 @@ public class Product implements Serializable {
|
||||
/**
|
||||
* 是否允许临时改价
|
||||
*/
|
||||
private Integer isTempPrice;
|
||||
private Integer isAllowTempModifyPrice;
|
||||
/**
|
||||
* 周 数组 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday'
|
||||
*/
|
||||
@@ -92,11 +98,11 @@ public class Product implements Serializable {
|
||||
/**
|
||||
* 可用开始时间
|
||||
*/
|
||||
private Object startTime;
|
||||
private LocalTime startTime;
|
||||
/**
|
||||
* 可用结束时间
|
||||
*/
|
||||
private Object endTime;
|
||||
private LocalTime endTime;
|
||||
/**
|
||||
* 规格详情
|
||||
*/
|
||||
@@ -133,7 +139,15 @@ public class Product implements Serializable {
|
||||
* 退款是否退回库存
|
||||
*/
|
||||
private Integer isRefundStock;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
/**
|
||||
* 逻辑删除
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.czg.product.enums;
|
||||
|
||||
/**
|
||||
* 商品类型
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2025-02-16 15:20
|
||||
*/
|
||||
public enum ProductTypeEnum {
|
||||
|
||||
/**
|
||||
* 单规格商品
|
||||
*/
|
||||
SINGLE("single"),
|
||||
|
||||
/**
|
||||
* 多规格商品
|
||||
*/
|
||||
SKU("sku"),
|
||||
|
||||
/**
|
||||
* 套餐商品
|
||||
*/
|
||||
PACKAGE("package"),
|
||||
|
||||
/**
|
||||
* 称重商品
|
||||
*/
|
||||
WEIGHT("weight"),
|
||||
|
||||
/**
|
||||
* coupon
|
||||
*/
|
||||
COUPON("coupon");
|
||||
|
||||
private String value;
|
||||
|
||||
ProductTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.czg.product.service;
|
||||
|
||||
import com.czg.product.dto.ProdSkuDTO;
|
||||
import com.czg.product.entity.ProdSku;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品SKU
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-16
|
||||
*/
|
||||
public interface ProdSkuService extends IService<ProdSku> {
|
||||
Page<ProdSkuDTO> getProdSkuPage(ProdSkuDTO param);
|
||||
|
||||
List<ProdSkuDTO> getProdSkuList(ProdSkuDTO param);
|
||||
|
||||
ProdSkuDTO getProdSkuById(Long id);
|
||||
|
||||
boolean addProdSku(ProdSkuDTO dto);
|
||||
|
||||
boolean deleteProdSku(Long id);
|
||||
|
||||
boolean updateProdSku(ProdSkuDTO dto);
|
||||
|
||||
boolean disableProdSku(Long id);
|
||||
|
||||
boolean enableProdSku(Long id);
|
||||
|
||||
}
|
||||
@@ -1,15 +1,33 @@
|
||||
package com.czg.product.service;
|
||||
|
||||
|
||||
import com.czg.product.dto.ProductDTO;
|
||||
import com.czg.product.entity.Product;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-10
|
||||
* @since 1.0 2025-02-16
|
||||
*/
|
||||
public interface ProductService extends IService<Product> {
|
||||
Page<ProductDTO> getProductPage(ProductDTO param);
|
||||
|
||||
List<ProductDTO> getProductList(ProductDTO param);
|
||||
|
||||
ProductDTO getProductById(Long id);
|
||||
|
||||
boolean addProduct(ProductDTO dto);
|
||||
|
||||
boolean deleteProduct(Long id);
|
||||
|
||||
boolean updateProduct(ProductDTO dto);
|
||||
|
||||
boolean disableProduct(Long id);
|
||||
|
||||
boolean enableProduct(Long id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.czg.product.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ProductGroupVo {
|
||||
|
||||
private Integer count;
|
||||
//选几个
|
||||
private Integer number;
|
||||
//类别
|
||||
private String title;
|
||||
|
||||
//食物
|
||||
private List<Food> goods = new ArrayList<>();
|
||||
|
||||
@Data
|
||||
public static class Food {
|
||||
private Integer proId;
|
||||
private String proName;
|
||||
private Integer skuId;
|
||||
private String skuName;
|
||||
private BigDecimal price;
|
||||
private String number;
|
||||
private String unitName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user