分享相关代码 注释掉

优惠券 管理端重写 使用的地方 注释
This commit is contained in:
2025-09-11 16:10:38 +08:00
parent 65ba0e18ce
commit 35d257bc56
23 changed files with 1292 additions and 91 deletions

View File

@@ -1,23 +1,23 @@
package com.czg.account.service;
import com.czg.account.dto.ShopShareDTO;
import com.czg.account.vo.ShopShareRecordVO;
import com.czg.account.vo.ShopShareVO;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import com.czg.account.entity.ShopShare;
/**
* 店铺分享 服务层。
*
* @author zs
* @since 2025-03-05
*/
public interface ShopShareService extends IService<ShopShare> {
ShopShareVO get(Long shopId);
Boolean add(Long shopId, ShopShareDTO shopShareDTO);
Page<ShopShareRecordVO> recordPage(Long shopId, String key, Integer status);
}
//package com.czg.account.service;
//
//import com.czg.account.dto.ShopShareDTO;
//import com.czg.account.vo.ShopShareRecordVO;
//import com.czg.account.vo.ShopShareVO;
//import com.mybatisflex.core.paginate.Page;
//import com.mybatisflex.core.service.IService;
//import com.czg.account.entity.ShopShare;
//
///**
// * 店铺分享 服务层。
// *
// * @author zs
// * @since 2025-03-05
// */
//public interface ShopShareService extends IService<ShopShare> {
//
// ShopShareVO get(Long shopId);
//
// Boolean add(Long shopId, ShopShareDTO shopShareDTO);
//
// Page<ShopShareRecordVO> recordPage(Long shopId, String key, Integer status);
//}

View File

@@ -0,0 +1,285 @@
package com.czg.market.dto;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Time;
import java.time.LocalDateTime;
import com.alibaba.fastjson2.annotation.JSONField;
import java.io.Serial;
import java.util.Objects;
import com.czg.validator.group.DefaultGroup;
import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 优惠券信息表 实体类。
*
* @author ww
* @since 2025-09-11
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ShopCouponDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 自增主键
*/
@Null(message = "ID必须为空", groups = InsertGroup.class)
@NotNull(message = "ID不能为空", groups = UpdateGroup.class)
private Long id;
/**
* 店铺ID
*/
private Long shopId;
/**
* 同步Id
*/
private Long syncId;
/**
* 优惠券类型1-满减券2-商品兑换券3-折扣券4-第二件半价券5-消费送券6-买一送一券7-固定价格券8-免配送费券
*/
private Integer couponType;
/**
* 券名称
*/
@NotBlank(message = "券名称不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private String title;
/**
* 可用门店类型all-所有门店custom-指定门店
*/
private String useShopType;
/**
* 可用门店
*/
private String useShops;
/**
* 可使用类型:堂食/自取/配送/快递
*/
private String useType;
/**
* 有效期类型fixed固定时间custom自定义时间
*/
@NotBlank(message = "有效期类型不能为空" ,groups = {InsertGroup.class, UpdateGroup.class})
private String validType;
/**
* 有效期(天)
*/
private Integer validDays;
/**
* 有效期开始时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime validStartTime;
/**
* 有效期结束时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime validEndTime;
/**
* 隔天生效
*/
private Integer daysToTakeEffect;
/**
* 可用周期,如:周一,周二,周三,周四,周五,周六,周七
*/
private String useDays;
/**
* 可用时间段类型all-全时段custom-指定时段
*/
@NotBlank(message = "可用时间段类型不能为空" ,groups = {InsertGroup.class, UpdateGroup.class})
private String useTimeType;
/**
* 可用开始时间
*/
private Time useStartTime;
/**
* 可用结束时间
*/
private Time useEndTime;
/**
* 发放设置:不可自行领取/no可领取/yes
*/
@NotBlank(message = "发放设置不能为空" ,groups = {InsertGroup.class, UpdateGroup.class})
private String getType;
/**
* 用户领取方式
*/
private String getMode;
/**
* 总发放数量,-10086为不限量
*/
private Integer giveNum;
/**
* 可领取用户:全部/all新用户一次/new仅会员/vip
*/
@NotBlank(message = "可领取用户不能为空" ,groups = {InsertGroup.class, UpdateGroup.class})
private String getUserType;
/**
* 每人领取限量,-10086为不限量
*/
private Integer getLimit;
/**
* 每人每日使用限量,-10086为不限量
*/
private Integer useLimit;
/**
* 与限时折扣同享0-否1-是
*/
private Integer discountShare;
/**
* 与会员价同享0-否1-是
*/
private Integer vipPriceShare;
/**
* 附加规则说明
*/
private String ruleDetails;
/**
* 状态0-禁用1-启用
*/
private Integer status;
/**
* 已使用数量
*/
private Integer useNum;
/**
* 剩余数量
*/
private Integer leftNum;
/**
* 指定门槛商品
*/
private String foods;
/**
* 使用门槛:满多少金额
*/
private BigDecimal fullAmount;
/**
* 使用门槛:减多少金额
*/
private BigDecimal discountAmount;
/**
* 折扣%
*/
private Integer discountRate;
/**
* 可抵扣最大金额 元
*/
private BigDecimal maxDiscountAmount;
/**
* 使用规则price_asc-价格低到高price_desc-高到低
*/
private String useRule;
/**
* 抵扣数量
*/
private Integer discountNum;
/**
* 与其它优惠共享0-否1-是
*/
private Integer otherCouponShare;
/**
* 创建时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/**
* 更新时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
/**
* 根据优惠券类型执行不同的校验规则
*/
@AssertTrue(message = "优惠券参数校验失败", groups = {InsertGroup.class, UpdateGroup.class})
public boolean validateByCouponType() {
// 确保优惠券类型不为空(虽然已有@NotNull注解但这里做双重保障
if (couponType == null) {
return false;
}
// 满减券(1)校验
if (couponType == 1) {
// 校验指定门槛商品不为空且不为空字符串
// if (foods == null || foods.trim().isEmpty()) {
// return false;
// }
// 校验满多少和减多少金额
return fullAmount != null && discountAmount != null;
}
// 折扣券(3)校验
if (couponType == 3) {
// 校验折扣率、满多少可用和最大抵扣金额
return discountRate != null && discountRate > 0 && discountRate <= 100
&& fullAmount != null && maxDiscountAmount != null;
}
// 第二件半价券(4)、买一送一券(6)、商品兑换券(2)校验
if (couponType == 2 || couponType == 4 || couponType == 6) {
// 校验可用商品不为空且不为空字符串
if (foods == null || foods.trim().isEmpty()) {
return false;
}
// 校验使用规则不为空
return useRule != null && !useRule.trim().isEmpty();
}
// 其他类型优惠券暂不做特殊校验返回true
return true;
}
}

View File

@@ -0,0 +1,233 @@
package com.czg.market.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Time;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 优惠券信息表 实体类。
*
* @author ww
* @since 2025-09-11
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_shop_coupon")
public class ShopCoupon implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 自增主键
*/
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 店铺ID
*/
private Long shopId;
/**
* 同步Id
*/
private Long syncId;
/**
* 优惠券类型1-满减券2-商品兑换券3-折扣券4-第二件半价券5-消费送券6-买一送一券7-固定价格券8-免配送费券
*/
private Integer couponType;
/**
* 券名称
*/
private String title;
/**
* 可用门店类型all-所有门店custom-指定门店
*/
private String useShopType;
/**
* 可用门店
*/
private String useShops;
/**
* 可使用类型:堂食/自取/配送/快递
*/
private String useType;
/**
* 有效期类型fixed固定时间custom自定义时间
*/
private String validType;
/**
* 有效期(天)
*/
private Integer validDays;
/**
* 有效期开始时间
*/
private LocalDateTime validStartTime;
/**
* 有效期结束时间
*/
private LocalDateTime validEndTime;
/**
* 隔天生效
*/
private Integer daysToTakeEffect;
/**
* 可用周期,如:周一,周二,周三,周四,周五,周六,周七
*/
private String useDays;
/**
* 可用时间段类型all-全时段custom-指定时段
*/
private String useTimeType;
/**
* 可用开始时间
*/
private Time useStartTime;
/**
* 可用结束时间
*/
private Time useEndTime;
/**
* 发放设置:不可自行领取/no可领取/yes
*/
private String getType;
/**
* 用户领取方式
*/
private String getMode;
/**
* 总发放数量,-10086为不限量
*/
private Integer giveNum;
/**
* 可领取用户:全部/all新用户一次/new仅会员/vip
*/
private String getUserType;
/**
* 每人领取限量,-10086为不限量
*/
private Integer getLimit;
/**
* 每人每日使用限量,-10086为不限量
*/
private Integer useLimit;
/**
* 与限时折扣同享0-否1-是
*/
private Integer discountShare;
/**
* 与会员价同享0-否1-是
*/
private Integer vipPriceShare;
/**
* 附加规则说明
*/
private String ruleDetails;
/**
* 状态0-禁用1-启用
*/
private Integer status;
/**
* 已使用数量
*/
private Integer useNum;
/**
* 剩余数量
*/
private Integer leftNum;
/**
* 指定门槛商品
*/
private String foods;
/**
* 使用门槛:满多少金额
*/
private BigDecimal fullAmount;
/**
* 使用门槛:减多少金额
*/
private BigDecimal discountAmount;
/**
* 折扣%
*/
private Integer discountRate;
/**
* 可抵扣最大金额 元
*/
private BigDecimal maxDiscountAmount;
/**
* 使用规则price_asc-价格低到高price_desc-高到低
*/
private String useRule;
/**
* 抵扣数量
*/
private Integer discountNum;
/**
* 与其它优惠共享0-否1-是
*/
private Integer otherCouponShare;
/**
* 创建时间
*/
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
/**
* 更新时间
*/
@Column(onInsertValue = "now()", onUpdateValue = "now()")
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,22 @@
package com.czg.market.service;
import com.czg.market.dto.ShopCouponDTO;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import com.czg.market.entity.ShopCoupon;
/**
* 优惠券信息表 服务层。
*
* @author ww
* @since 2025-09-11
*/
public interface ShopCouponService extends IService<ShopCoupon> {
Page<ShopCouponDTO> getCouponPage(ShopCouponDTO param);
ShopCouponDTO getCouponById(Long id);
void addCoupon(ShopCouponDTO param);
void updateCouponById(ShopCouponDTO param);
void deleteCoupon(Long id);
}

View File

@@ -85,4 +85,10 @@ public interface ShopSyncService {
* @param vendorId 供应商Id
*/
void syncVendorBySourceShop(Long sourceShopId, Long vendorId, Long sysUserId);
/**
* 同步优惠券
* @param type 1 新增 2 修改 3 删除
*/
void syncCouponBySourceShop(Long sourceShopId, Long couponId, Integer type);
}