优惠券时间限制修改
This commit is contained in:
@@ -7,6 +7,7 @@ package co.yixiang.modules.activity.domain;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDomain;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -19,6 +20,7 @@ import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
@@ -60,11 +62,25 @@ public class YxStoreCoupon extends BaseDomain {
|
||||
private BigDecimal useMinPrice;
|
||||
|
||||
|
||||
/** 优惠券有效期限(单位:天) */
|
||||
@NotNull(message = "请输入有效期限")
|
||||
@ApiModelProperty(value = "优惠券有效期限(单位:天)")
|
||||
private Integer couponTime;
|
||||
// /** 优惠券有效期限(单位:天) */
|
||||
// @NotNull(message = "请输入有效期限")
|
||||
// @ApiModelProperty(value = "优惠券有效期限(单位:天)")
|
||||
// private Integer couponTime;
|
||||
|
||||
// /** 优惠券有效期限(单位:天) */
|
||||
// @NotNull(message = "请输入有效期限")
|
||||
// @ApiModelProperty(value = "优惠券有效期限(单位:天;几号到几号)")
|
||||
// private Object useTime;
|
||||
|
||||
/** 优惠券开始使用期限(单位:天) */
|
||||
@NotNull(message = "请输入开始期限")
|
||||
@ApiModelProperty(value = "优惠券使用期限(单位:天)")
|
||||
private Object useStartTime;
|
||||
|
||||
/** 优惠券结束使用期限(单位:天) */
|
||||
@NotNull(message = "请输入有效结束期限")
|
||||
@ApiModelProperty(value = "优惠券失效期限(单位:天)")
|
||||
private Object useEndTime;
|
||||
|
||||
/** 排序 */
|
||||
@ApiModelProperty(value = "排序")
|
||||
|
||||
@@ -68,9 +68,9 @@ public class YxStoreCouponUser extends BaseDomain {
|
||||
private Date endTime;
|
||||
|
||||
|
||||
/** 使用时间 */
|
||||
@ApiModelProperty(value = "使用时间")
|
||||
private Date useTime;
|
||||
// /** 使用时间 */
|
||||
// @ApiModelProperty(value = "使用时间")
|
||||
// private Date useTime;
|
||||
|
||||
|
||||
/** 获取方式 */
|
||||
|
||||
@@ -79,6 +79,7 @@ public class StoreCouponController {
|
||||
if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) {
|
||||
throw new YshopException("优惠券金额不能高于最低消费金额");
|
||||
}
|
||||
//这里需要对优惠券开始使用时间和结束时间进行比较
|
||||
yxStoreCouponService.saveOrUpdate(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
+12
-2
@@ -5,12 +5,14 @@
|
||||
*/
|
||||
package co.yixiang.modules.activity.service.dto;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import co.yixiang.modules.product.domain.YxStoreProduct;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,8 +38,16 @@ public class YxStoreCouponDto implements Serializable {
|
||||
// 最低消费多少金额可用优惠券
|
||||
private BigDecimal useMinPrice;
|
||||
|
||||
// 优惠券有效期限(单位:天)
|
||||
private Integer couponTime;
|
||||
// // 优惠券有效期限(单位:天)
|
||||
// private Integer couponTime;
|
||||
|
||||
// 优惠券有效期开始时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private DateTime useStartTime;
|
||||
|
||||
// 优惠券有效期开始时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private DateTime useEndTime;
|
||||
|
||||
// 排序
|
||||
private Integer sort;
|
||||
|
||||
+3
-1
@@ -85,7 +85,9 @@ public class YxStoreCouponServiceImpl extends BaseServiceImpl<YxStoreCouponMappe
|
||||
map.put("兑换消耗积分值", yxStoreCoupon.getIntegral());
|
||||
map.put("兑换的优惠券面值", yxStoreCoupon.getCouponPrice());
|
||||
map.put("最低消费多少金额可用优惠券", yxStoreCoupon.getUseMinPrice());
|
||||
map.put("优惠券有效期限(单位:天)", yxStoreCoupon.getCouponTime());
|
||||
// map.put("优惠券有效期限(单位:天)", yxStoreCoupon.getCouponTime());
|
||||
map.put("优惠券有效期开始时间(单位:天)", yxStoreCoupon.getUseStartTime());
|
||||
map.put("优惠券有效期结束时间(单位:天)", yxStoreCoupon.getUseEndTime());
|
||||
map.put("排序", yxStoreCoupon.getSort());
|
||||
map.put("状态(0:关闭,1:开启)", yxStoreCoupon.getStatus());
|
||||
list.add(map);
|
||||
|
||||
+11
-5
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package co.yixiang.modules.activity.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.YshopException;
|
||||
@@ -44,6 +45,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Array;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -156,7 +160,6 @@ public class YxStoreCouponUserServiceImpl extends BaseServiceImpl<YxStoreCouponU
|
||||
YxStoreCouponUser couponUser = new YxStoreCouponUser();
|
||||
couponUser.setId((long)id);
|
||||
couponUser.setStatus(1);
|
||||
couponUser.setUseTime(new Date());
|
||||
yxStoreCouponUserMapper.updateById(couponUser);
|
||||
}
|
||||
|
||||
@@ -210,11 +213,14 @@ public class YxStoreCouponUserServiceImpl extends BaseServiceImpl<YxStoreCouponU
|
||||
if(storeCoupon == null) {
|
||||
throw new YshopException("优惠劵不存在");
|
||||
}
|
||||
//现在的日期向后偏移,得到优惠券的使用截止期期
|
||||
// Date now = new Date();
|
||||
// Date endTime = DateUtil.offsetDay(now,storeCoupon.getCouponTime());
|
||||
|
||||
Date now = new Date();
|
||||
|
||||
Date endTime = DateUtil.offsetDay(now,storeCoupon.getCouponTime());
|
||||
|
||||
// //有效期改为时间段,不需要偏移,切割开始日期和截止日期
|
||||
// String[] time=storeCoupon.getUseTime().toString().split(",");
|
||||
// DateTime endTime = new DateTime(time[1]);
|
||||
DateTime endTime =new DateTime(storeCoupon.getUseEndTime().toString());
|
||||
YxStoreCouponUser storeCouponUser = YxStoreCouponUser.builder()
|
||||
.cid(storeCoupon.getId())
|
||||
.uid(uid)
|
||||
|
||||
-1
@@ -1792,7 +1792,6 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
|
||||
if (ObjectUtil.isNotNull(couponUser)) {
|
||||
YxStoreCouponUser storeCouponUser = new YxStoreCouponUser();
|
||||
storeCouponUser.setStatus(CouponEnum.STATUS_0.getValue());
|
||||
storeCouponUser.setUseTime(null);
|
||||
couponUserService.update(storeCouponUser, Wrappers.<YxStoreCouponUser>lambdaQuery()
|
||||
.eq(YxStoreCouponUser::getId, order.getCouponId())
|
||||
.eq(YxStoreCouponUser::getUid, order.getUid()));
|
||||
|
||||
Reference in New Issue
Block a user