记得上下班打卡 | git大法好,push需谨慎

Commit fdb270b9 authored by jiangxiulong's avatar jiangxiulong

Merge remote-tracking branch 'origin/pre' into pre

parents ffd6d7df 83432373
......@@ -8,6 +8,7 @@ import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.candy.constant.CandyRedisConst;
import com.liquidnet.service.candy.dto.CandyCommonCouponBasicDto;
import com.liquidnet.service.candy.dto.CandyCouponCodeDto;
import com.liquidnet.service.candy.dto.CandyUserCouponBasicDto;
import com.liquidnet.service.candy.entity.CandyCommonCoupon;
import com.liquidnet.service.candy.entity.CandyCoupon;
import com.liquidnet.service.candy.entity.CandyCouponCode;
......@@ -30,6 +31,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* <p>
......@@ -59,6 +61,8 @@ public class CandyCouponDueTaskController {
@Autowired
private PlatformCandyUserCouponService platformCandyUserCouponService;
private static final String OPERATOR_CHECK = "CHECK";
/**
* <p>
* 兑换类
......@@ -80,7 +84,7 @@ public class CandyCouponDueTaskController {
AtomicInteger pl = new AtomicInteger();
int remainCount = totalCount;
int num = 0, pSize = 1000;
log.info("券到期检查处理:兑换码[到期总记录数:{}] >>> BEGIN BEGIN BEGIN", totalCount);
log.info("券到期检查处理:兑换码[到期总记录数:{}] >>> BEGIN BEGIN BEGIN", totalCount);
ArrayList<CandyCouponCode> updateCouponCodeList = ObjectUtil.getCandyCouponCodeArrayList();
couponCodeQueryWrapper.select(CandyCouponCode::getMid, CandyCouponCode::getCcode);
......@@ -89,7 +93,7 @@ public class CandyCouponDueTaskController {
updateCouponCodeList.clear();
LambdaQueryWrapper<CandyCouponCode> couponCodeLambdaQueryWrapper = couponCodeQueryWrapper.clone();
String lastLimitSql = "LIMIT " + (num * pSize) + "," + pSize;
String lastLimitSql = "LIMIT " + 0 + "," + pSize;
couponCodeLambdaQueryWrapper.last(lastLimitSql);
List<CandyCouponCode> couponCodeList = platformCandyCouponCodeService.list(couponCodeLambdaQueryWrapper);
......@@ -98,12 +102,13 @@ public class CandyCouponDueTaskController {
CandyCouponCode couponCode = couponCodeList.get(i);
couponCode.setState(3);
couponCode.setOperator(OPERATOR_CHECK);
couponCode.setUpdatedAt(now);
updateCouponCodeList.add(couponCode);
}
if (!CollectionUtils.isEmpty(couponCodeList)) {
if (!CollectionUtils.isEmpty(updateCouponCodeList)) {
if (platformCandyCouponCodeService.updateBatchById(updateCouponCodeList, updateCouponCodeList.size())) {
updateCouponCodeList.forEach(r -> {
String ccKey = CandyRedisConst.BASIC_COUPON_CODE.concat(r.getCcode());
......@@ -123,9 +128,9 @@ public class CandyCouponDueTaskController {
num++;
remainCount -= pSize;
log.info("券到期检查处理中:兑换码[到期总记录数:{},单次处理:{},剩余处理数:{}]", totalCount, lastLimitSql, remainCount);
log.info("券到期检查处理中:兑换码[到期总记录数:{},单次处理:{},剩余处理数:{}]", totalCount, lastLimitSql, remainCount);
}
log.info("券到期检查处理:兑换码[到期总记录数:{},处理总数:{}] >>> END END END", totalCount, pl.get());
log.info("券到期检查处理:兑换码[到期总记录数:{},处理总数:{}] >>> END END END", totalCount, pl.get());
return ResponseDto.success();
}
......@@ -167,7 +172,7 @@ public class CandyCouponDueTaskController {
couponQueryWrapper.orderByAsc(CandyCoupon::getMid);
while (remainCount > 0) {
LambdaQueryWrapper<CandyCoupon> couponLambdaQueryWrapper = couponQueryWrapper.clone();
String lastLimitSql = "LIMIT " + (num * pSize) + "," + pSize;
String lastLimitSql = "LIMIT " + 0 + "," + pSize;
couponLambdaQueryWrapper.last(lastLimitSql);
List<CandyCoupon> couponList = platformCandyCouponService.list(couponLambdaQueryWrapper);
......@@ -178,7 +183,7 @@ public class CandyCouponDueTaskController {
List<CandyCommonCoupon> inCommonCouponList = commonCouponIdToListMap.get(coupon.getCouponId());
inCommonCouponList.forEach(r -> {
r.setState(3);
r.setOperator("system");
r.setOperator(OPERATOR_CHECK);
r.setUpdatedAt(now);
updateCommonCouponList.add(r);
......@@ -238,8 +243,62 @@ public class CandyCouponDueTaskController {
int num = 0, pSize = 1000;
log.info("券到期检查处理:私有券[到期总记录数:{}] >>> BEGIN BEGIN BEGIN", totalCount);
ArrayList<CandyUserCoupon> candyUserCouponArrayList = ObjectUtil.getCandyUserCouponArrayList();
ArrayList<CandyUserCoupon> updateUserCouponList = ObjectUtil.getCandyUserCouponArrayList();
userCouponQueryWrapper.select(CandyUserCoupon::getMid, CandyUserCoupon::getUcouponId);
userCouponQueryWrapper.orderByAsc(CandyUserCoupon::getMid);
while (remainCount > 0) {
updateUserCouponList.clear();
LambdaQueryWrapper<CandyUserCoupon> userCouponLambdaQueryWrapper = userCouponQueryWrapper.clone();
String lastLimitSql = "LIMIT " + 0 + "," + pSize;
userCouponLambdaQueryWrapper.last(lastLimitSql);
List<CandyUserCoupon> userCouponList = platformCandyUserCouponService.list(userCouponLambdaQueryWrapper);
int listSize = CollectionUtils.isEmpty(userCouponList) ? -1 : userCouponList.size();
for (int i = 0; i < listSize; i++) {
CandyUserCoupon userCoupon = userCouponList.get(i);
userCoupon.setState(3);
userCoupon.setOperator(OPERATOR_CHECK);
userCoupon.setUpdatedAt(now);
updateUserCouponList.add(userCoupon);
}
if (!CollectionUtils.isEmpty(updateUserCouponList)) {
if (platformCandyUserCouponService.updateBatchById(updateUserCouponList, updateUserCouponList.size())) {
// 需要更新的用户券记录按UID分组处理
Map<String, List<CandyUserCoupon>> userCouponListByUidMap = updateUserCouponList.stream().collect(Collectors.groupingBy(CandyUserCoupon::getUid));
userCouponListByUidMap.forEach((uid, updateUserCouponListByUid) -> {
String uckey = CandyRedisConst.BASIC_USER_COUPON.concat(uid);
List<CandyUserCouponBasicDto> vos = (List<CandyUserCouponBasicDto>) redisUtil.get(uckey);
if (!CollectionUtils.isEmpty(vos)) {
updateUserCouponListByUid.forEach(r -> {
int idx = IntStream.range(0, vos.size())
.filter(i -> vos.get(i).getUcouponId().equals(r.getUcouponId()))
.findFirst().orElse(-1);
if (idx != -1) {
CandyUserCouponBasicDto dto = vos.get(idx);
dto.setState(3);
vos.set(idx, dto);
}
pl.getAndIncrement();
});
redisUtil.set(uckey, vos);
}
});
} else {
throw new LiquidnetServiceException("-1", String.format("券到期处理失败[updateUserCouponList.size=%s]", updateUserCouponList.size()));
}
}
num++;
remainCount -= pSize;
log.info("券到期检查处理中:私有券[到期总记录数:{},单次处理:{},剩余处理数:{}]", totalCount, lastLimitSql, remainCount);
}
log.info("券到期检查处理:私有券[到期总记录数:{},处理总数:{}] >>> END END END", totalCount, pl.get());
return ResponseDto.success();
}
}
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