Merge branch 'master' of https://gitee.com/beijing_hongye_huicheng/lilishop
This commit is contained in:
commit
e1ec2b9b27
@ -0,0 +1,61 @@
|
||||
package cn.lili.timetask.handler.impl.order;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
|
||||
import cn.lili.modules.order.trade.entity.dos.Recharge;
|
||||
import cn.lili.modules.order.trade.service.RechargeService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.OrderSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.timetask.handler.EveryMinuteExecute;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 充值订单自动取消(每分钟执行)
|
||||
*
|
||||
* @author zhuhai
|
||||
* @since 2021/3/11
|
||||
**/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RechargeOrderTaskExecute implements EveryMinuteExecute {
|
||||
/**
|
||||
* 充值
|
||||
*/
|
||||
@Autowired
|
||||
private RechargeService rechargeService;
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Setting setting = settingService.get(SettingEnum.ORDER_SETTING.name());
|
||||
OrderSetting orderSetting = JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class);
|
||||
if (orderSetting != null && orderSetting.getAutoCancel() != null) {
|
||||
//充值订单自动取消时间 = 当前时间 - 自动取消时间分钟数
|
||||
DateTime cancelTime = DateUtil.offsetMinute(DateUtil.date(), -orderSetting.getAutoCancel());
|
||||
LambdaQueryWrapper<Recharge> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Recharge::getPayStatus, PayStatusEnum.UNPAID.name());
|
||||
//充值订单创建时间 <= 订单自动取消时间
|
||||
queryWrapper.le(Recharge::getCreateTime, cancelTime);
|
||||
List<Recharge> list = rechargeService.list(queryWrapper);
|
||||
List<String> cancelSnList = list.stream().map(Recharge::getRechargeSn).collect(Collectors.toList());
|
||||
for (String sn : cancelSnList) {
|
||||
rechargeService.rechargeOrderCancel(sn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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, "活动已参加,已发重复参加"),
|
||||
|
||||
/**
|
||||
* 优惠券
|
||||
|
@ -11,8 +11,9 @@ public enum PayStatusEnum {
|
||||
/**
|
||||
* 支付状态
|
||||
*/
|
||||
UNPAID("未付款"),
|
||||
PAID("已付款");
|
||||
UNPAID("待付款"),
|
||||
PAID("已付款"),
|
||||
CANCEL("已取消");
|
||||
|
||||
private final String description;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user