Commit 88b3b5b1 by wuwenlong

coupon expired task dev;

user coupon opt;
parent caae8b82
......@@ -38,14 +38,8 @@ public class SConsumerCouponController extends BaseController {
// @PreAuthorize("@ss.hasPermi('system:coupon:list')")
@GetMapping("/list")
public TableDataInfo list( String useStatus) {
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
if(StringUtils.isNotBlank(useStatus)){
sConsumerCoupon.setUseStatus(Integer.valueOf(useStatus));
}
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sConsumerCoupon.setConsumerId(user.getId());
startPage();
List<SConsumerCoupon> list = sConsumerCouponService.selectSConsumerCouponList(sConsumerCoupon);
List<SConsumerCoupon> list = sConsumerCouponService.listByUseStatus(Integer.valueOf(useStatus));
return getDataTable(list);
}
......
......@@ -19,8 +19,7 @@ import share.system.service.ISStoreService;
import share.system.service.QPService;
import share.system.service.impl.QPServiceImpl;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Component("couponRetryTask")
......@@ -78,5 +77,18 @@ public class CouponRetryTask {
sConsumerCouponService.updateById(sConsumerCoupon);
}
});
LambdaQueryWrapper<SConsumerCoupon> consumerCouponWrapper = new LambdaQueryWrapper<>();
consumerCouponWrapper.eq(SConsumerCoupon::getUseStatus,UserStatusEnum.UNUSED.getCode());
List<SConsumerCoupon> sConsumerCoupons = sConsumerCouponService.list(consumerCouponWrapper);
List<SConsumerCoupon> expiredSConsumerCounpons = Optional.ofNullable(sConsumerCoupons).orElse(new ArrayList<>()).stream().filter(item -> {
if(item.getEndDate().compareTo(new Date()) < 0){
item.setUseStatus(UserStatusEnum.EXPIRED.getCode());
return true;
}
return false;
}).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(expiredSConsumerCounpons)){
sConsumerCouponService.updateBatchById(expiredSConsumerCounpons);
}
}
}
......@@ -28,6 +28,13 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
* @return 优惠券领取记录集合
*/
public List<SConsumerCoupon> selectSConsumerCouponList(SConsumerCoupon sConsumerCoupon);
/**
* 查询优惠券领取记录列表
*
* @param useStatus 优惠券领取记录
* @return 优惠券领取记录集合
*/
public List<SConsumerCoupon> listByUseStatus(Integer useStatus);
/**
* 新增优惠券领取记录
......
......@@ -2,9 +2,7 @@ package share.system.service.impl;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;
......@@ -73,12 +71,6 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
List<SConsumerCoupon> sConsumerCoupons = baseMapper.selectSConsumerCouponList(sConsumerCoupon);
sConsumerCoupons.forEach(item -> {
if (item.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
if (item.getEndDate().compareTo(new Date()) < 0) {
item.setUseStatus(UserStatusEnum.EXPIRED.getCode());
baseMapper.updateSConsumerCoupon(item);
}
}
List<SConsumer> list = sConsumerService.list();
if (list.stream().filter(obj -> obj.getId().equals(item.getConsumerId())).findFirst().isPresent()) {
item.setPhone(list.stream().filter(obj -> obj.getId().equals(item.getConsumerId())).findFirst().get().getPhone());
......@@ -91,6 +83,17 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
return sConsumerCoupons;
}
@Override
public List<SConsumerCoupon> listByUseStatus(Integer useStatus) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<SConsumerCoupon>();
queryWrapper.eq(SConsumerCoupon::getConsumerId,user.getId());
queryWrapper.eq(SConsumerCoupon::getUseStatus,useStatus);
queryWrapper.orderByDesc(SConsumerCoupon::getCreateTime);
List<SConsumerCoupon> sConsumerCoupons = baseMapper.selectList(queryWrapper);
return sConsumerCoupons;
}
/**
* 新增优惠券领取记录
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment