This commit is contained in:
lifenlong
2021-08-11 20:15:01 +08:00
7 changed files with 104 additions and 26 deletions

View File

@@ -234,17 +234,18 @@ public enum ResultCode {
/**
* 活动
*/
PROMOTION_GOODS_NOT_EXIT(40001, "当前促销商品不存在!"),
PROMOTION_SAME_ACTIVE_EXIST(40002,"当前时间内已存在同类活动"),
PROMOTION_START_TIME_ERROR(40003,"活动起始时间不能大于活动结束时间"),
PROMOTION_TIME_ERROR(40004,"活动起始时间必须大于当前时间"),
PROMOTION_SAME_ERROR(40005,"当前时间段已存在相同活动!"),
PROMOTION_GOODS_ERROR(40006,"请选择要参与活动的商品"),
PROMOTION_STATUS_END(40007,"当前活动已停止"),
PROMOTION_UPDATE_ERROR(40008,"当前活动已开始/结束,无法编辑!"),
PROMOTION_ACTIVITY_GOODS_ERROR(40009,"当前活动已开始无法添加商品"),
PROMOTION_ACTIVITY_ERROR(40009,"当前促销活动不存在"),
PROMOTION_LOG_EXIST(40010,"活动已参加,已发重复参加"),
PROMOTION_GOODS_NOT_EXIT(40000, "当前促销商品不存在!"),
PROMOTION_SAME_ACTIVE_EXIST(40001, "当前时间内已存在同类活动"),
PROMOTION_START_TIME_ERROR(40002, "活动起始时间不能小于当前时间"),
PROMOTION_END_TIME_ERROR(40003, "活动结束时间不能小于当前时间"),
PROMOTION_TIME_ERROR(40004, "活动起始时间必须大于结束时间"),
PROMOTION_SAME_ERROR(40005, "当前时间段已存在相同活动!"),
PROMOTION_GOODS_ERROR(40006, "请选择要参与活动的商品"),
PROMOTION_STATUS_END(40007, "当前活动已停止"),
PROMOTION_UPDATE_ERROR(40008, "当前活动已开始/结束,无法编辑!"),
PROMOTION_ACTIVITY_GOODS_ERROR(40009, "当前活动已经开始无法添加商品"),
PROMOTION_ACTIVITY_ERROR(400010, "当前促销活动不存在"),
PROMOTION_LOG_EXIST(40011, "活动已参加,已发重复参加"),
/**
* 优惠券

View File

@@ -11,8 +11,9 @@ public enum PayStatusEnum {
/**
* 支付状态
*/
UNPAID("付款"),
PAID("已付款");
UNPAID("付款"),
PAID("已付款"),
CANCEL("已取消");
private final String description;

View File

@@ -35,11 +35,11 @@ public interface RechargeService extends IService<Recharge> {
/**
* 支付成功
*
* @param sn 充值订单编号
* @param receivableNo 流水no
* @param sn 充值订单编号
* @param receivableNo 流水no
* @param paymentMethod 支付方式
*/
void paySuccess(String sn, String receivableNo,String paymentMethod);
void paySuccess(String sn, String receivableNo, String paymentMethod);
/**
* 根据充值订单号查询充值信息
@@ -49,4 +49,11 @@ public interface RechargeService extends IService<Recharge> {
*/
Recharge getRecharge(String sn);
/**
* 充值订单取消
*
* @param sn 充值订单sn
*/
void rechargeOrderCancel(String sn);
}

View File

@@ -77,7 +77,7 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
}
@Override
public void paySuccess(String sn, String receivableNo,String paymentMethod) {
public void paySuccess(String sn, String receivableNo, String paymentMethod) {
//根据sn获取支付账单
Recharge recharge = this.getOne(new QueryWrapper<Recharge>().eq("recharge_sn", sn));
//如果支付账单不为空则进行一下逻辑
@@ -103,4 +103,13 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
throw new ServiceException(ResultCode.ORDER_NOT_EXIST);
}
@Override
public void rechargeOrderCancel(String sn) {
Recharge recharge = this.getOne(new QueryWrapper<Recharge>().eq("recharge_sn", sn));
if (recharge != null) {
recharge.setPayStatus(PayStatusEnum.CANCEL.name());
this.updateById(recharge);
}
}
}

View File

@@ -1,15 +1,13 @@
package cn.lili.modules.promotion.entity.dto;
import cn.lili.mybatis.BaseEntity;
import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum;
import cn.lili.mybatis.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
@@ -34,12 +32,10 @@ public class BasePromotion extends BaseEntity {
@ApiModelProperty(value = "活动名称", required = true)
private String promotionName;
@Min(message = "活动开始时间不能为空", value = 0)
@ApiModelProperty(value = "活动开始时间", required = true)
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@Min(message = "活动结束时间不能为空", value = 0)
@ApiModelProperty(value = "活动结束时间", required = true)
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
@@ -48,6 +44,5 @@ public class BasePromotion extends BaseEntity {
* @see PromotionStatusEnum
*/
@ApiModelProperty(value = "活动状态")
@NotNull(message = "活动状态不能为空")
private String promotionStatus;
}

View File

@@ -297,6 +297,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
*/
private void checkParam(CouponVO coupon) {
//优惠券限制领取数量
if (coupon.getCouponLimitNum() < 0) {
throw new ServiceException(ResultCode.COUPON_LIMIT_NUM_LESS_THAN_0);
}
@@ -304,18 +305,21 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
if (coupon.getPublishNum() != 0 && coupon.getCouponLimitNum() > coupon.getPublishNum()) {
throw new ServiceException(ResultCode.COUPON_LIMIT_GREATER_THAN_PUBLISH);
}
//打折优惠券大于10折
boolean discountCoupon = (coupon.getCouponType().equals(CouponTypeEnum.DISCOUNT.name())
&& (coupon.getCouponDiscount() < 0 && coupon.getCouponDiscount() > 10));
if (discountCoupon) {
throw new ServiceException(ResultCode.COUPON_DISCOUNT_ERROR);
}
//优惠券为固定时间类型
if (coupon.getRangeDayType() != null && coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) {
long nowTime = DateUtil.getDateline() * 1000;
if (coupon.getStartTime().getTime() < nowTime && coupon.getEndTime().getTime() > nowTime) {
throw new ServiceException(ResultCode.PROMOTION_TIME_ERROR);
//固定时间的优惠券不能小于当前时间
if (coupon.getEndTime().getTime() < nowTime) {
throw new ServiceException(ResultCode.PROMOTION_END_TIME_ERROR);
}
//促销通用时间校验
PromotionTools.checkPromotionTime(coupon.getStartTime().getTime(), coupon.getEndTime().getTime());
}