|
@@ -111,7 +111,8 @@ public class CouponServiceImpl implements CouponService {
|
|
|
@Override
|
|
|
public ResponseJson<PageInfo<CouponVo>> collarCouponsList(Integer userId, int pageNum, int pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
- List<CouponVo> couponList = couponMapper.findCouponList(userId);
|
|
|
+ Date registerTime = couponMapper.findUserRegisterTime(userId);
|
|
|
+ List<CouponVo> couponList = couponMapper.findCouponList(userId, registerTime);
|
|
|
//剔除超级会员优惠券
|
|
|
List<Integer> vipCoupon = couponMapper.findVipCoupon();
|
|
|
if (couponList != null && couponList.size() > 0) {
|
|
@@ -155,8 +156,10 @@ public class CouponServiceImpl implements CouponService {
|
|
|
if (redemptionCode.getStatus() == 2) {
|
|
|
return ResponseJson.error("兑换码已使用,请更换兑换码进行兑换", null);
|
|
|
}
|
|
|
- CouponVo coupon = couponMapper.getCoupons(redemptionCode.getCouponId());
|
|
|
+ Date registerTime = couponMapper.findUserRegisterTime(redeemCouponsDto.getUserId());
|
|
|
+ CouponVo coupon = couponMapper.getCoupons(redemptionCode.getCouponId(), registerTime);
|
|
|
Date date = new Date();
|
|
|
+ // 判断是否在领取期限内
|
|
|
if (coupon == null || date.compareTo(coupon.getStartDate()) < 0 || date.compareTo(coupon.getEndDate()) > 0) {
|
|
|
return ResponseJson.error("兑换的优惠券已失效", null);
|
|
|
}
|
|
@@ -164,7 +167,6 @@ public class CouponServiceImpl implements CouponService {
|
|
|
return ResponseJson.error("该优惠券属于其他用户,您不能兑换", null);
|
|
|
}
|
|
|
if (coupon.getCouponType() == 4) {
|
|
|
- Date registerTime = couponMapper.findUserRegisterTime(redeemCouponsDto.getUserId());
|
|
|
if (registerTime == null || registerTime.compareTo(coupon.getStartDate()) < 0) {
|
|
|
return ResponseJson.error("该优惠券只供新用户使用,您不能兑换", null);
|
|
|
}
|
|
@@ -179,6 +181,9 @@ public class CouponServiceImpl implements CouponService {
|
|
|
couponClub.setDelFlag("0");
|
|
|
couponMapper.insertCouponClub(couponClub);
|
|
|
couponMapper.updateRedemptionCode(redemptionCode.getId(), couponClub.getId());
|
|
|
+ // 设置使用有效期
|
|
|
+ coupon.setStartDate(new Date());
|
|
|
+ coupon.setEndDate(coupon.getUsePeriod());
|
|
|
return ResponseJson.success(coupon);
|
|
|
}
|
|
|
|
|
@@ -205,8 +210,10 @@ public class CouponServiceImpl implements CouponService {
|
|
|
return ResponseJson.error("商品数据异常", null);
|
|
|
}
|
|
|
List<Integer> vipCoupon = couponMapper.findVipCoupon();
|
|
|
+ // 注册时间
|
|
|
+ Date registerTime = couponMapper.findUserRegisterTime(userId);
|
|
|
//未领取
|
|
|
- List<CouponVo> notCouponList = couponMapper.findCouponList(userId);
|
|
|
+ List<CouponVo> notCouponList = couponMapper.findCouponList(userId, registerTime);
|
|
|
filterCoupon(source, product, notCouponList);
|
|
|
//超级会员优惠券移除
|
|
|
if (notCouponList != null && notCouponList.size() > 0) {
|