Authored by mali

Merge branch 'master' into test6.9.13

... ... @@ -135,36 +135,36 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{
List<Coupon> coupons = couponMapper.selectByCondition(req);
// 只获取使用记录
Map<Integer, UserCouponNum> sendNumMap = null;
Map<Integer, UserCouponNum> useNumMap = null;
if (CollectionUtils.isNotEmpty(coupons)){
List<Integer> couponIdList = coupons.stream().map(Coupon::getId).collect(Collectors.toList());
List<UserCouponNum> sendNumList = userCouponMapper.selectByCouponIds(couponIdList);
LOGGER.info("sendNumList is {}", sendNumList);
sendNumMap = sendNumList.stream().collect(Collectors.toMap(UserCouponNum::getCouponId, Function.identity(), (k1,k2)->k2));
List<UserCouponNum> useNumList = userCouponMapper.selectByCouponIdsAndStatus(couponIdList);
LOGGER.info("useNumList is {}", useNumList);
useNumMap = useNumList.stream().collect(Collectors.toMap(UserCouponNum::getCouponId, Function.identity(), (k1,k2)->k2));
}
// Map<Integer, UserCouponNum> sendNumMap = null;
// Map<Integer, UserCouponNum> useNumMap = null;
// if (CollectionUtils.isNotEmpty(coupons)){
// List<Integer> couponIdList = coupons.stream().map(Coupon::getId).collect(Collectors.toList());
// List<UserCouponNum> sendNumList = userCouponMapper.selectByCouponIds(couponIdList);
// LOGGER.info("sendNumList is {}", sendNumList);
// sendNumMap = sendNumList.stream().collect(Collectors.toMap(UserCouponNum::getCouponId, Function.identity(), (k1,k2)->k2));
// List<UserCouponNum> useNumList = userCouponMapper.selectByCouponIdsAndStatus(couponIdList);
// LOGGER.info("useNumList is {}", useNumList);
// useNumMap = useNumList.stream().collect(Collectors.toMap(UserCouponNum::getCouponId, Function.identity(), (k1,k2)->k2));
// }
List<CouponQueryResp> couponQueryResps = initCouponQueryResps(coupons,req.getCurTime());
if (MapUtils.isNotEmpty(sendNumMap) || MapUtils.isNotEmpty(useNumMap)) {
Map<Integer, UserCouponNum> finalSendNumMap = sendNumMap;
Map<Integer, UserCouponNum> finalUseNumMap = useNumMap;
couponQueryResps = couponQueryResps.stream().map(x->{
if (MapUtils.isNotEmpty(finalSendNumMap)){
x.setSendNum(finalSendNumMap.get(x.getId()) == null ? 0 :finalSendNumMap.get(x.getId()).getCnt());
}
if (MapUtils.isNotEmpty(finalUseNumMap)){
x.setUseNum(finalUseNumMap.get(x.getId()) == null ? 0 : finalUseNumMap.get(x.getId()).getCnt());
}
return x;
}).collect(Collectors.toList());
}
// if (MapUtils.isNotEmpty(sendNumMap) || MapUtils.isNotEmpty(useNumMap)) {
// Map<Integer, UserCouponNum> finalSendNumMap = sendNumMap;
// Map<Integer, UserCouponNum> finalUseNumMap = useNumMap;
// couponQueryResps = couponQueryResps.stream().map(x->{
//
// if (MapUtils.isNotEmpty(finalSendNumMap)){
// x.setSendNum(finalSendNumMap.get(x.getId()) == null ? 0 :finalSendNumMap.get(x.getId()).getCnt());
// }
//
// if (MapUtils.isNotEmpty(finalUseNumMap)){
// x.setUseNum(finalUseNumMap.get(x.getId()) == null ? 0 : finalUseNumMap.get(x.getId()).getCnt());
// }
//
// return x;
// }).collect(Collectors.toList());
// }
jsonObject.put("coupons",couponQueryResps);
return new ApiResponse.ApiResponseBuilder().data(jsonObject).build();
... ...