|  |  |  | 
|---|
|  |  |  | package cc.mrbird.febs.vip.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.common.entity.QueryRequest; | 
|---|
|  |  |  | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; | 
|---|
|  |  |  | import cc.mrbird.febs.common.enumerates.OrderStatusEnum; | 
|---|
|  |  |  | import cc.mrbird.febs.common.exception.FebsException; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.MallNewsInfo; | 
|---|
|  |  |  | import cc.mrbird.febs.common.utils.LoginUserUtil; | 
|---|
|  |  |  | import cc.mrbird.febs.common.utils.MallUtils; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.*; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.mapper.*; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.vo.AdminMailGoodsDetailVo; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.vo.AdminMallNewsInfoVo; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.entity.MallVipBenefits; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.entity.MallVipBenefitsDetails; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.entity.MallVipBenefitsRecord; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.entity.MallVipConfig; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.mapper.MallVipBenefitsDetailsMapper; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.mapper.MallVipBenefitsMapper; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.mapper.MallVipBenefitsRecordMapper; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.mapper.MallVipConfigMapper; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.service.IMallVipBenefitsDetailsService; | 
|---|
|  |  |  | import cc.mrbird.febs.vip.service.IMallVipBenefitsService; | 
|---|
|  |  |  | import cn.hutool.core.collection.CollUtil; | 
|---|
|  |  |  | import cn.hutool.core.date.DatePattern; | 
|---|
|  |  |  | import cn.hutool.core.date.DateUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.IdUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.ObjectUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.StrUtil; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.OrderItem; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import lombok.RequiredArgsConstructor; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | 
|---|
|  |  |  | public class MallVipBenefitsServiceImpl extends ServiceImpl<MallVipBenefitsMapper, MallVipBenefits> implements IMallVipBenefitsService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final IMallVipBenefitsDetailsService mallVipBenefitsDetailsService; | 
|---|
|  |  |  | private final MallMemberCouponMapper mallMemberCouponMapper; | 
|---|
|  |  |  | private final MallGoodsCouponMapper mallGoodsCouponMapper; | 
|---|
|  |  |  | private final MallGoodsMapper mallGoodsMapper; | 
|---|
|  |  |  | private final MallAddressInfoMapper mallAddressInfoMapper; | 
|---|
|  |  |  | private final MallOrderInfoMapper mallOrderInfoMapper; | 
|---|
|  |  |  | private final MallOrderItemMapper mallOrderItemMapper; | 
|---|
|  |  |  | private final MallVipBenefitsRecordMapper mallVipBenefitsRecordMapper; | 
|---|
|  |  |  | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; | 
|---|
|  |  |  | private final MallMemberMapper mallMemberMapper; | 
|---|
|  |  |  | private final MallVipConfigMapper mallVipConfigMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IPage<MallVipBenefits> vipBenefitsListInPage(QueryRequest request) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void addVipBenefits(MallVipBenefits mallVipBenefits) { | 
|---|
|  |  |  | if (mallVipBenefits == null) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (CollUtil.isEmpty(mallVipBenefits.getDetails())) { | 
|---|
|  |  |  | throw new FebsException("权益明细不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (CollUtil.isEmpty(mallVipBenefits.getDetails())) { | 
|---|
|  |  |  | //            throw new FebsException("权益明细不能为空"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.baseMapper.insert(mallVipBenefits); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mallVipBenefits.getDetails().forEach(item -> { | 
|---|
|  |  |  | item.setBenefitsId(mallVipBenefits.getId()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | if (CollUtil.isNotEmpty(mallVipBenefits.getDetails())) { | 
|---|
|  |  |  | mallVipBenefits.getDetails().forEach(item -> { | 
|---|
|  |  |  | item.setBenefitsId(mallVipBenefits.getId()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.mallVipBenefitsDetailsService.saveBatch(mallVipBenefits.getDetails()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public void delVipBenefits(Long id) { | 
|---|
|  |  |  | this.baseMapper.deleteById(id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | this.mallVipBenefitsDetailsService.remove(delQuery); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public void editVipBenefits(MallVipBenefits mallVipBenefits) { | 
|---|
|  |  |  | if (mallVipBenefits.getId() == null) { | 
|---|
|  |  |  | throw new FebsException("缺少重要参数"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.baseMapper.updateById(mallVipBenefits); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LambdaQueryWrapper<MallVipBenefitsDetails> delQuery = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | delQuery.eq(MallVipBenefitsDetails::getBenefitsId, mallVipBenefits.getId()); | 
|---|
|  |  |  | this.mallVipBenefitsDetailsService.remove(delQuery); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mallVipBenefits.getDetails().forEach(item -> { | 
|---|
|  |  |  | item.setBenefitsId(mallVipBenefits.getId()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | this.mallVipBenefitsDetailsService.saveBatch(mallVipBenefits.getDetails()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void getBenefits(Long id) { | 
|---|
|  |  |  | MallMember loginUser = LoginUserUtil.getLoginUser(); | 
|---|
|  |  |  | MallMember member = mallMemberMapper.selectById(loginUser.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MallVipBenefitsDetails benefits = mallVipBenefitsDetailsService.getById(id); | 
|---|
|  |  |  | if (benefits == null) { | 
|---|
|  |  |  | throw new FebsException("权益不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (benefits.getIsClick() == 2) { | 
|---|
|  |  |  | throw new FebsException("请联系客服,检查权益设置"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MallVipBenefits vipBenefits = this.baseMapper.selectById(benefits.getBenefitsId()); | 
|---|
|  |  |  | if (vipBenefits == null) { | 
|---|
|  |  |  | throw new FebsException("权益不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MallVipConfig config = mallVipConfigMapper.selectVipConfigByCode(member.getLevel()); | 
|---|
|  |  |  | boolean b = config.getBenefits().stream().anyMatch(item -> { | 
|---|
|  |  |  | return Objects.equals(item.getId(), benefits.getBenefitsId()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | if (!b) { | 
|---|
|  |  |  | throw new FebsException("未达到等级不能领取该权益"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer linkType = benefits.getLinkType(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (vipBenefits.getGainType() == 2) { | 
|---|
|  |  |  | String today = DateUtil.format(new Date(), DatePattern.NORM_DATE_PATTERN); | 
|---|
|  |  |  | boolean isBirthday = member.getBirthday().compareTo(DateUtil.parseDate(today)) == 0; | 
|---|
|  |  |  | if (!isBirthday) { | 
|---|
|  |  |  | throw new FebsException("未达到权益领取条件:未到生日"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (vipBenefits.getGainType() == 3) { | 
|---|
|  |  |  | DataDictionaryCustom data = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.VIP_DATE.getType(), DataDictionaryEnum.VIP_DATE.getCode()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String today = DateUtil.format(new Date(), "MM-dd"); | 
|---|
|  |  |  | if (!StrUtil.equals(data.getValue(), today)) { | 
|---|
|  |  |  | throw new FebsException("未达到权益领取条件:未到会员日"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LambdaQueryWrapper<MallVipBenefitsRecord> recordQuery = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | recordQuery.ge(MallVipBenefitsRecord::getReceiveTime, DateUtil.beginOfDay(new Date())) | 
|---|
|  |  |  | .le(MallVipBenefitsRecord::getReceiveTime, DateUtil.endOfDay(new Date())) | 
|---|
|  |  |  | .eq(MallVipBenefitsRecord::getMemberId, member.getId()) | 
|---|
|  |  |  | .eq(MallVipBenefitsRecord::getBenefitsType, vipBenefits.getGainType()) | 
|---|
|  |  |  | .eq(MallVipBenefitsRecord::getReceiveId, Long.parseLong(benefits.getContent())); | 
|---|
|  |  |  | List<MallVipBenefitsRecord> mallVipBenefitsRecords = mallVipBenefitsRecordMapper.selectList(recordQuery); | 
|---|
|  |  |  | if (CollUtil.isNotEmpty(mallVipBenefitsRecords)) { | 
|---|
|  |  |  | throw new FebsException("已领取过权益"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MallVipBenefitsRecord record = new MallVipBenefitsRecord(); | 
|---|
|  |  |  | record.setBenefitsType(vipBenefits.getGainType()); | 
|---|
|  |  |  | record.setBenefitsName(vipBenefits.getName()); | 
|---|
|  |  |  | record.setReceiveTime(new Date()); | 
|---|
|  |  |  | record.setReceiveType(linkType); | 
|---|
|  |  |  | record.setReceiveId(Long.parseLong(benefits.getContent())); | 
|---|
|  |  |  | record.setMemberId(member.getId()); | 
|---|
|  |  |  | record.setReceiveCnt(1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 商品 | 
|---|
|  |  |  | if (linkType == 2) { | 
|---|
|  |  |  | MallGoods goods = mallGoodsMapper.selectGoodsDetailById(Long.parseLong(benefits.getContent())); | 
|---|
|  |  |  | if (goods == null) { | 
|---|
|  |  |  | throw new FebsException("商品不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LambdaQueryWrapper<MallAddressInfo> query = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | query.eq(MallAddressInfo::getMemberId, member.getId()) | 
|---|
|  |  |  | .eq(MallAddressInfo::getIsDefault, 1) | 
|---|
|  |  |  | .last("limit 1"); | 
|---|
|  |  |  | MallAddressInfo address = mallAddressInfoMapper.selectOne(query); | 
|---|
|  |  |  | if (address == null) { | 
|---|
|  |  |  | throw new FebsException("请设置默认地址"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String orderNo = MallUtils.getOrderNum(); | 
|---|
|  |  |  | MallOrderInfo orderInfo = new MallOrderInfo(); | 
|---|
|  |  |  | orderInfo.setOrderNo(orderNo); | 
|---|
|  |  |  | orderInfo.setOrderTime(new Date()); | 
|---|
|  |  |  | orderInfo.setMemberId(member.getId()); | 
|---|
|  |  |  | orderInfo.setPayTime(new Date()); | 
|---|
|  |  |  | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); | 
|---|
|  |  |  | orderInfo.setOrderType(goods.getGoodsType()); | 
|---|
|  |  |  | orderInfo.setDeliveryType(2); | 
|---|
|  |  |  | orderInfo.setIsFree(1); | 
|---|
|  |  |  | orderInfo.setCarriage(BigDecimal.ZERO); | 
|---|
|  |  |  | orderInfo.setAmount(BigDecimal.ZERO); | 
|---|
|  |  |  | orderInfo.setAddressId(address.getId()); | 
|---|
|  |  |  | orderInfo.setName(address.getName()); | 
|---|
|  |  |  | orderInfo.setPhone(address.getPhone()); | 
|---|
|  |  |  | orderInfo.setIsHome(2); | 
|---|
|  |  |  | orderInfo.setAddress(address.getProvince()+address.getCity()+address.getArea() + address.getAddress()); | 
|---|
|  |  |  | orderInfo.setLatitude(address.getLatitude()); | 
|---|
|  |  |  | orderInfo.setLongitude(address.getLongitude()); | 
|---|
|  |  |  | mallOrderInfoMapper.insert(orderInfo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MallOrderItem orderItem = new MallOrderItem(); | 
|---|
|  |  |  | if (goods.getGoodsType() == 2) { | 
|---|
|  |  |  | orderItem.setAmount(BigDecimal.ZERO); | 
|---|
|  |  |  | orderItem.setCnt(1); | 
|---|
|  |  |  | orderItem.setOrderId(orderInfo.getId()); | 
|---|
|  |  |  | orderItem.setPrice(goods.getScore()); | 
|---|
|  |  |  | orderItem.setGoodsId(goods.getId()); | 
|---|
|  |  |  | orderItem.setGoodsName(goods.getGoodsName()); | 
|---|
|  |  |  | orderItem.setStyleName(goods.getGoodsName()); | 
|---|
|  |  |  | orderItem.setSkuName(goods.getGoodsName()); | 
|---|
|  |  |  | orderItem.setSkuImage(goods.getThumb()); | 
|---|
|  |  |  | orderItem.setState(1); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | MallGoodsSku sku = goods.getStyles().get(0).getSkus().get(0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderItem.setAmount(BigDecimal.ZERO); | 
|---|
|  |  |  | orderItem.setCnt(1); | 
|---|
|  |  |  | orderItem.setOrderId(orderInfo.getId()); | 
|---|
|  |  |  | orderItem.setPrice(sku.getPresentPrice()); | 
|---|
|  |  |  | orderItem.setGoodsId(sku.getGoodsId()); | 
|---|
|  |  |  | orderItem.setGoodsName(goods.getGoodsName()); | 
|---|
|  |  |  | orderItem.setSkuId(sku.getId()); | 
|---|
|  |  |  | orderItem.setState(1); | 
|---|
|  |  |  | orderItem.setStyleName(goods.getStyles().get(0).getName()); | 
|---|
|  |  |  | orderItem.setSkuName(sku.getSkuName()); | 
|---|
|  |  |  | orderItem.setSkuImage(sku.getSkuImage()); | 
|---|
|  |  |  | orderItem.setIsNormal(goods.getIsNormal()); | 
|---|
|  |  |  | orderItem.setCostPrice(sku.getCostPrice()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | record.setReceiveName(goods.getGoodsName()); | 
|---|
|  |  |  | mallOrderItemMapper.insert(orderItem); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 优惠券 | 
|---|
|  |  |  | if (linkType == 3) { | 
|---|
|  |  |  | MallGoodsCoupon coupon = mallGoodsCouponMapper.selectById(Long.parseLong(benefits.getContent())); | 
|---|
|  |  |  | if (coupon == null) { | 
|---|
|  |  |  | throw new FebsException("优惠券"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MallMemberCoupon memberCoupon = new MallMemberCoupon(); | 
|---|
|  |  |  | memberCoupon.setCouponId(coupon.getId()); | 
|---|
|  |  |  | memberCoupon.setCouponName(coupon.getName()); | 
|---|
|  |  |  | memberCoupon.setInviteId(member.getInviteId()); | 
|---|
|  |  |  | memberCoupon.setCouponUuid(IdUtil.simpleUUID()); | 
|---|
|  |  |  | memberCoupon.setState(1); | 
|---|
|  |  |  | memberCoupon.setFromType(2); | 
|---|
|  |  |  | memberCoupon.setExpireTime(DateUtil.offsetDay(DateUtil.date(), coupon.getExpireDay())); | 
|---|
|  |  |  | memberCoupon.setMemberId(member.getId()); | 
|---|
|  |  |  | mallMemberCouponMapper.insert(memberCoupon); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | record.setReceiveName(coupon.getName()); | 
|---|
|  |  |  | record.setStatus(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mallVipBenefitsRecordMapper.insert(record); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void switchBenefitsShow(Long id) { | 
|---|
|  |  |  | MallVipBenefits vipBenefits = this.baseMapper.selectById(id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MallVipBenefits update = new MallVipBenefits(); | 
|---|
|  |  |  | if (vipBenefits.getIsShow() == 1) { | 
|---|
|  |  |  | update.setIsShow(2); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | update.setIsShow(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | update.setId(vipBenefits.getId()); | 
|---|
|  |  |  | this.baseMapper.updateById(update); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> birthdayEvent() { | 
|---|
|  |  |  | MallMember loginUser = LoginUserUtil.getLoginUser(); | 
|---|
|  |  |  | MallMember member = this.mallMemberMapper.selectById(loginUser.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String today = DateUtil.format(new Date(), DatePattern.NORM_DATE_PATTERN); | 
|---|
|  |  |  | boolean isBirthday = member.getBirthday().compareTo(DateUtil.parseDate(today)) == 0; | 
|---|
|  |  |  | if (!isBirthday) { | 
|---|
|  |  |  | return new HashMap<>(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MallVipConfig configList = mallVipConfigMapper.selectVipConfigByCode(member.getLevel()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<MallVipBenefits> benefits = configList.getBenefits().stream().filter(item -> item.getGainType() == 2 && item.getType() != 1).collect(Collectors.toList()); | 
|---|
|  |  |  | if (CollUtil.isEmpty(benefits)) { | 
|---|
|  |  |  | return new HashMap<>(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<String> ids = new ArrayList<>(); | 
|---|
|  |  |  | benefits.forEach(item -> { | 
|---|
|  |  |  | ids.addAll(item.getDetails().stream().filter(detail -> detail.getLinkType() == 2 || detail.getLinkType() == 3).map(MallVipBenefitsDetails::getContent).collect(Collectors.toList())); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LambdaQueryWrapper<MallVipBenefitsRecord> recordQuery = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | recordQuery.in(MallVipBenefitsRecord::getReceiveId, ids) | 
|---|
|  |  |  | .eq(MallVipBenefitsRecord::getMemberId, member.getId()) | 
|---|
|  |  |  | .ge(MallVipBenefitsRecord::getReceiveTime, DateUtil.beginOfDay(new Date())) | 
|---|
|  |  |  | .le(MallVipBenefitsRecord::getReceiveTime, DateUtil.endOfDay(new Date())); | 
|---|
|  |  |  | List<MallVipBenefitsRecord> hasRecieveList = mallVipBenefitsRecordMapper.selectList(recordQuery); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | if (CollUtil.isEmpty(hasRecieveList)) { | 
|---|
|  |  |  | map.put("benefit", benefits.get(0)); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Long> hasIds = hasRecieveList.stream().map(MallVipBenefitsRecord::getReceiveId).collect(Collectors.toList()); | 
|---|
|  |  |  | List<MallVipBenefits> collect1 = benefits.stream().peek(item -> { | 
|---|
|  |  |  | List<MallVipBenefitsDetails> collect = item.getDetails().stream().filter(detail -> (detail.getLinkType() == 2 || detail.getLinkType() == 3) && !hasIds.contains(Long.parseLong(detail.getContent()))).collect(Collectors.toList()); | 
|---|
|  |  |  | item.setDetails(collect); | 
|---|
|  |  |  | }).filter(item -> CollUtil.isNotEmpty(item.getDetails())).collect(Collectors.toList()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (CollUtil.isEmpty(collect1)) { | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | map.put("benefit", collect1.get(0)); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IPage<MallVipBenefitsRecord> findVipBenefitsInPage(MallVipBenefitsRecord record, QueryRequest request) { | 
|---|
|  |  |  | Page<MallVipBenefitsRecord> page = new Page<>(request.getPageNum(), request.getPageSize()); | 
|---|
|  |  |  | return mallVipBenefitsRecordMapper.selectMemberBenefitsRecordInPage(record, page); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|