|
@@ -71,10 +71,12 @@ public class CouponFontServiceImpl implements CouponFontService {
|
|
|
CouponUser couponUser = new CouponUser();
|
|
CouponUser couponUser = new CouponUser();
|
|
|
couponUser.setUserId(userId);
|
|
couponUser.setUserId(userId);
|
|
|
couponUser.setCouponId(couponCollectReq.getCouponId());
|
|
couponUser.setCouponId(couponCollectReq.getCouponId());
|
|
|
- //领卷中心
|
|
|
|
|
|
|
+ //领券中心
|
|
|
couponUser.setChannel(CouponUser.Channel.center);
|
|
couponUser.setChannel(CouponUser.Channel.center);
|
|
|
couponUser.setStatus(CouponUser.Status.unused);
|
|
couponUser.setStatus(CouponUser.Status.unused);
|
|
|
couponUser.setCouponActiveId(couponCollectReq.getCouponActiveId());
|
|
couponUser.setCouponActiveId(couponCollectReq.getCouponActiveId());
|
|
|
|
|
+ //优惠券有效时间
|
|
|
|
|
+ updateCouponUserValidTime(couponActive.getCouponId(), couponUser);
|
|
|
try {
|
|
try {
|
|
|
couponUserMapper.insert(couponUser);
|
|
couponUserMapper.insert(couponUser);
|
|
|
} catch (DuplicateKeyException e) {
|
|
} catch (DuplicateKeyException e) {
|
|
@@ -102,6 +104,8 @@ public class CouponFontServiceImpl implements CouponFontService {
|
|
|
couponUser.setChannel(CouponUser.Channel.recommend);
|
|
couponUser.setChannel(CouponUser.Channel.recommend);
|
|
|
couponUser.setStatus(CouponUser.Status.unused);
|
|
couponUser.setStatus(CouponUser.Status.unused);
|
|
|
couponUser.setRecommendId(couponCollectReq.getCouponRecommendId());
|
|
couponUser.setRecommendId(couponCollectReq.getCouponRecommendId());
|
|
|
|
|
+ //优惠券有效时间
|
|
|
|
|
+ updateCouponUserValidTime(couponCollectReq.getCouponId(), couponUser);
|
|
|
try {
|
|
try {
|
|
|
couponUserMapper.insert(couponUser);
|
|
couponUserMapper.insert(couponUser);
|
|
|
} catch (DuplicateKeyException e) {
|
|
} catch (DuplicateKeyException e) {
|
|
@@ -131,6 +135,8 @@ public class CouponFontServiceImpl implements CouponFontService {
|
|
|
couponUser.setChannel(CouponUser.Channel.recommend);
|
|
couponUser.setChannel(CouponUser.Channel.recommend);
|
|
|
couponUser.setStatus(CouponUser.Status.unused);
|
|
couponUser.setStatus(CouponUser.Status.unused);
|
|
|
couponUser.setRecommendId(data.getRecommendId());
|
|
couponUser.setRecommendId(data.getRecommendId());
|
|
|
|
|
+ //优惠券有效时间
|
|
|
|
|
+ updateCouponUserValidTime(data.getCouponId(), couponUser);
|
|
|
try {
|
|
try {
|
|
|
couponUserMapper.insert(couponUser);
|
|
couponUserMapper.insert(couponUser);
|
|
|
} catch (DuplicateKeyException e) {
|
|
} catch (DuplicateKeyException e) {
|
|
@@ -144,10 +150,6 @@ public class CouponFontServiceImpl implements CouponFontService {
|
|
|
public void handleCouponStatus(SearchResult<CouponUserView> search) {
|
|
public void handleCouponStatus(SearchResult<CouponUserView> search) {
|
|
|
DateTime now = DateTime.now();
|
|
DateTime now = DateTime.now();
|
|
|
search.getDataList().forEach(data -> {
|
|
search.getDataList().forEach(data -> {
|
|
|
- if (!data.getIsValidTime()) {
|
|
|
|
|
- data.setValidStartTime(data.getCreatedTime());
|
|
|
|
|
- data.setValidEndTime(DateUtil.offsetDay(data.getValidStartTime(), data.getValidDays()));
|
|
|
|
|
- }
|
|
|
|
|
this.setCouponUserStatus(data, now);
|
|
this.setCouponUserStatus(data, now);
|
|
|
String str = couponSkuMapper.selectGoodsSkuStr(data.getCouponId());
|
|
String str = couponSkuMapper.selectGoodsSkuStr(data.getCouponId());
|
|
|
data.setGoodsSkuStr(str.replaceAll(",", "/").replaceAll(";", ""));
|
|
data.setGoodsSkuStr(str.replaceAll(",", "/").replaceAll(";", ""));
|
|
@@ -155,7 +157,7 @@ public class CouponFontServiceImpl implements CouponFontService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Page<CouponUserView> getAvailableCouponList(Long skuId, Long userId, Boolean isRenew, Long start, Long limit) {
|
|
|
|
|
|
|
+ public Page<CouponUserView> getAvailableCouponList(Long skuId, Long couponId, Long userId, Boolean isRenew, Long start, Long limit) {
|
|
|
DateTime now = DateTime.now();
|
|
DateTime now = DateTime.now();
|
|
|
Long goodsId = null;
|
|
Long goodsId = null;
|
|
|
//实物还是虚物
|
|
//实物还是虚物
|
|
@@ -163,13 +165,9 @@ public class CouponFontServiceImpl implements CouponFontService {
|
|
|
if (goodsDonSkuView.getType() == 2) {
|
|
if (goodsDonSkuView.getType() == 2) {
|
|
|
goodsId = goodsDonSkuView.getGoodsId();
|
|
goodsId = goodsDonSkuView.getGoodsId();
|
|
|
}
|
|
}
|
|
|
- Page<CouponUserView> availableCouponList = couponUserMapper.getAvailableCouponList(skuId, goodsId, userId, isRenew, new Page<>(start, limit));
|
|
|
|
|
|
|
+ Page<CouponUserView> availableCouponList = couponUserMapper.getAvailableCouponList(skuId, couponId, goodsId, userId, isRenew, new Page<>(start, limit));
|
|
|
Optional.ofNullable(availableCouponList).ifPresent(page->{
|
|
Optional.ofNullable(availableCouponList).ifPresent(page->{
|
|
|
page.getRecords().stream().forEach(data->{
|
|
page.getRecords().stream().forEach(data->{
|
|
|
- if (!data.getIsValidTime()) {
|
|
|
|
|
- data.setValidStartTime(data.getCreatedTime());
|
|
|
|
|
- data.setValidEndTime(DateUtil.offsetDay(data.getValidStartTime(), data.getValidDays()));
|
|
|
|
|
- }
|
|
|
|
|
String str = couponSkuMapper.selectGoodsSkuStr(data.getCouponId());
|
|
String str = couponSkuMapper.selectGoodsSkuStr(data.getCouponId());
|
|
|
data.setGoodsSkuStr(str.replaceAll(",", "/").replaceAll(";", ""));
|
|
data.setGoodsSkuStr(str.replaceAll(",", "/").replaceAll(";", ""));
|
|
|
if (!data.getIsAvailable()) {
|
|
if (!data.getIsAvailable()) {
|
|
@@ -257,4 +255,15 @@ public class CouponFontServiceImpl implements CouponFontService {
|
|
|
throw BusinessRuntimeException.getInstance("您已领取该优惠券..");
|
|
throw BusinessRuntimeException.getInstance("您已领取该优惠券..");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void updateCouponUserValidTime(Long couponId, CouponUser couponUser) {
|
|
|
|
|
+ Coupon coupon = couponMapper.selectById(couponId);
|
|
|
|
|
+ if (coupon.getIsValidTime()) {
|
|
|
|
|
+ couponUser.setValidStartTime(coupon.getValidStartTime());
|
|
|
|
|
+ couponUser.setValidEndTime(coupon.getValidEndTime());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ couponUser.setValidStartTime(DateTime.now());
|
|
|
|
|
+ couponUser.setValidEndTime(DateUtil.offsetDay(coupon.getValidStartTime(), coupon.getValidDays()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|