| | |
| | | package com.ruoyi.goods.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.enums.AuctionOrderTypeEnum; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.common.core.enums.MemberVipClassifyEnum; |
| | | import com.ruoyi.common.core.enums.OrderFromEnum; |
| | | import com.ruoyi.common.core.enums.StartStatusEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | |
| | | import com.ruoyi.common.core.utils.page.Checker; |
| | | import com.ruoyi.common.core.utils.page.CollUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.goods.controller.management.dto.GoodsInfoTitleValueDTO; |
| | | import com.ruoyi.goods.controller.management.dto.GoodsSkuDTO; |
| | | import com.ruoyi.goods.controller.management.dto.GoodsSkuQuery; |
| | |
| | | import com.ruoyi.goods.domain.GoodsBrowseRecord; |
| | | import com.ruoyi.goods.domain.GoodsInfoTitleValue; |
| | | import com.ruoyi.goods.domain.MemberGoodsCollection; |
| | | import com.ruoyi.goods.mapper.GoodsGroupPurchaseInfoMapper; |
| | | import com.ruoyi.goods.mapper.GoodsGroupPurchaseMapper; |
| | | import com.ruoyi.goods.mapper.GoodsSeckillMapper; |
| | | import com.ruoyi.goods.mapper.GoodsSkuMapper; |
| | |
| | | import com.ruoyi.goods.service.IGoodsInfoTitleValueService; |
| | | import com.ruoyi.goods.service.IGoodsSkuService; |
| | | import com.ruoyi.goods.service.IMemberGoodsCollectionService; |
| | | import com.ruoyi.system.api.domain.*; |
| | | import com.ruoyi.system.api.domain.AuctionGoods; |
| | | import com.ruoyi.system.api.domain.AuctionSalesroom; |
| | | import com.ruoyi.system.api.domain.AuctionSalesroomGoods; |
| | | import com.ruoyi.system.api.domain.GoodsBrand; |
| | | import com.ruoyi.system.api.domain.GoodsCategory; |
| | | import com.ruoyi.system.api.domain.GoodsFlavorType; |
| | | import com.ruoyi.system.api.domain.GoodsGroupPurchase; |
| | | import com.ruoyi.system.api.domain.GoodsSeckill; |
| | | import com.ruoyi.system.api.domain.GoodsSeries; |
| | | import com.ruoyi.system.api.domain.GoodsSku; |
| | | import com.ruoyi.system.api.domain.Member; |
| | | import com.ruoyi.system.api.domain.Order; |
| | | import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO; |
| | | import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; |
| | | import com.ruoyi.system.api.domain.dto.ListStatusDTO; |
| | | import com.ruoyi.system.api.domain.vo.GoodsInfoTitleValueVO; |
| | | import com.ruoyi.system.api.domain.vo.HomeGoodsSkuInfoVO; |
| | | import com.ruoyi.system.api.domain.vo.HomeGoodsSkuListVO; |
| | | import com.ruoyi.system.api.domain.vo.OrderVO; |
| | | import com.ruoyi.system.api.domain.vo.getHomeGoodsSkuXxiVO; |
| | | import com.ruoyi.system.api.feignClient.AuctionClient; |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | | import com.ruoyi.system.api.feignClient.MemberClient; |
| | | import com.ruoyi.system.api.feignClient.OrderClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private final GoodsSeckillMapper goodsSeckillMapper; |
| | | private final GoodsGroupPurchaseMapper goodsGroupPurchaseMapper; |
| | | private final RedissonClient redissonClient; |
| | | |
| | | private final AuctionClient auctionClient; |
| | | private final GoodsGroupPurchaseInfoMapper goodsGroupPurchaseInfoMapper; |
| | | @Resource |
| | | private IGoodsBrowseRecordService iGoodsBrowseRecordService; |
| | | |
| | |
| | | @Resource |
| | | private IMemberGoodsCollectionService iMemberGoodsCollectionService; |
| | | |
| | | @Resource |
| | | private MemberClient memberClient; |
| | | |
| | | |
| | | private static final ObjectMapper objectMapper = new ObjectMapper(); |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * 保存商品SKU信息。 |
| | |
| | | Page<GoodsSku> page = this.lambdaQuery() |
| | | .select(GoodsSku::getId, GoodsSku::getSkuName, GoodsSku::getPrice, |
| | | GoodsSku::getStock, GoodsSku::getSoldQuantity, GoodsSku::getSortNum, |
| | | GoodsSku::getListingStatus) |
| | | GoodsSku::getListingStatus, GoodsSku::getUnit, GoodsSku::getSpec, |
| | | GoodsSku::getSpecUnit) |
| | | .like(StringUtils.isNotEmpty(query.getSkuName()), GoodsSku::getSkuName, |
| | | query.getSkuName()) |
| | | .eq(StringUtils.isNotNull(query.getListingStatus() |
| | | ), GoodsSku::getListingStatus, query.getListingStatus()) |
| | | .eq(query.getQueryType().equals(1), GoodsSku::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES) |
| | | .gt(query.getQueryType().equals(2), GoodsSku::getStock, 0) |
| | | .gt(query.getQueryType().equals(1) || query.getQueryType().equals(2), |
| | | GoodsSku::getStock, 0) |
| | | .orderByDesc(GoodsSku::getCreateTime) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | return PageDTO.of(page, GoodsSkuVO.class); |
| | |
| | | .eq(GoodsSku::getId, dto.getId()) |
| | | .set(GoodsSku::getListingStatus, dto.getListingStatus()) |
| | | .update(); |
| | | //关联的秒杀商品和团购商品同步下架 |
| | | |
| | | if (dto.getListingStatus().equals(ListingStatusEnum.REMOVED_FROM_THE_SHELF)) { |
| | | // 校验是否有秒杀活动商品 |
| | | Long seckillCount = goodsSeckillMapper.selectCount( |
| | | new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getGoodsSkuId, |
| | | dto.getId()) |
| | | .eq(GoodsSeckill::getStartStatus, StartStatusEnum.STARTED) |
| | | .eq(GoodsSeckill::getListingStatus, ListingStatusEnum.ON_SHELVES)); |
| | | if (seckillCount > 0) { |
| | | throw new ServiceException("该商品有秒杀活动商品正在进行中,不能下架"); |
| | | } |
| | | // 校验是否有团购活动商品 |
| | | Long groupCount = goodsGroupPurchaseMapper.selectCount( |
| | | new LambdaQueryWrapper<GoodsGroupPurchase>().eq( |
| | | GoodsGroupPurchase::getGoodsSkuId, |
| | | dto.getId()) |
| | | .eq(GoodsGroupPurchase::getStartStatus, StartStatusEnum.STARTED) |
| | | .eq(GoodsGroupPurchase::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES)); |
| | | if (groupCount > 0) { |
| | | throw new ServiceException("该商品有团购活动商品正在进行中,不能下架"); |
| | | } |
| | | // 校验是否有拍卖会商品 |
| | | List<AuctionSalesroom> auctionSalesrooms = auctionClient.getAuctionSalesroomBySkuId( |
| | | dto.getId(), SecurityConstants.INNER).getData(); |
| | | if (CollUtils.isNotEmpty(auctionSalesrooms)) { |
| | | throw new ServiceException("该商品有拍卖会商品正在进行中,不能下架"); |
| | | } |
| | | List<AuctionGoods> auctionGoodsList = auctionClient.getAuctionGoodsBySkuId(dto.getId(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (CollUtils.isNotEmpty(auctionGoodsList)) { |
| | | throw new ServiceException("该商品有商品竞价商品正在进行中,不能下架"); |
| | | } |
| | | // 关联的秒杀商品和团购商品同步下架 |
| | | updateGoodsStatus(dto); |
| | | } |
| | | } |
| | |
| | | queryWrapper.eq(GoodsSeckill::getListingStatus, ListingStatusEnum.ON_SHELVES) |
| | | .eq(GoodsSeckill::getGoodsSkuId, dto.getId()); |
| | | List<GoodsSeckill> goodsSeckillList = goodsSeckillMapper.selectList(queryWrapper); |
| | | if (StringUtils.isNotNull(goodsSeckillList)) { |
| | | for (GoodsSeckill goodsSeckill : goodsSeckillList) { |
| | | if (StringUtils.isNotEmpty(goodsSeckillList)) { |
| | | goodsSeckillList = goodsSeckillList.stream().peek(goodsSeckill -> { |
| | | goodsSeckill.setListingStatus(ListingStatusEnum.REMOVED_FROM_THE_SHELF); |
| | | goodsSeckillMapper.updateById(goodsSeckill); |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | goodsSeckillMapper.updateListingStatusBatch( |
| | | ListingStatusEnum.REMOVED_FROM_THE_SHELF.getCode(), goodsSeckillList); |
| | | } |
| | | |
| | | LambdaQueryWrapper<GoodsGroupPurchase> queryWrapper1 =new LambdaQueryWrapper<>(); |
| | | queryWrapper1.eq(GoodsGroupPurchase::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES) |
| | | .eq(GoodsGroupPurchase::getGoodsSkuId, dto.getId()); |
| | | GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectOne(queryWrapper1); |
| | | if (StringUtils.isNotNull(goodsGroupPurchase)) { |
| | | goodsGroupPurchase.setListingStatus(ListingStatusEnum.REMOVED_FROM_THE_SHELF); |
| | | goodsGroupPurchaseMapper.updateById(goodsGroupPurchase); |
| | | List<GoodsGroupPurchase> goodsGroupPurchaseList = goodsGroupPurchaseMapper.selectList( |
| | | queryWrapper1); |
| | | if (CollUtils.isNotEmpty(goodsGroupPurchaseList)) { |
| | | goodsGroupPurchaseList = goodsGroupPurchaseList.stream().peek(goodsGroupPurchase -> { |
| | | goodsGroupPurchase.setListingStatus(ListingStatusEnum.REMOVED_FROM_THE_SHELF); |
| | | }).collect(Collectors.toList()); |
| | | goodsGroupPurchaseMapper.updateListingStatusBatch( |
| | | ListingStatusEnum.REMOVED_FROM_THE_SHELF.getCode(), goodsGroupPurchaseList); |
| | | } |
| | | } |
| | | |
| | |
| | | page.setSize(homeGoodsSkuDTO.getPageSize()); |
| | | page.setCurrent(homeGoodsSkuDTO.getPageCurr()); |
| | | |
| | | LambdaQueryWrapper<GoodsSku> wrapper3= Wrappers.lambdaQuery(); |
| | | wrapper3.eq(GoodsSku::getDelFlag,0); |
| | | wrapper3.eq(GoodsSku::getListingStatus,0); |
| | | if(homeGoodsSkuDTO.getId()!=null){ |
| | | List arr=new ArrayList<>(); |
| | | arr.add(homeGoodsSkuDTO.getId()); |
| | | wrapper3.notIn(GoodsSku::getId,arr); |
| | | LambdaQueryWrapper<GoodsSku> wrapper3 = Wrappers.lambdaQuery(); |
| | | wrapper3.eq(GoodsSku::getListingStatus, 0); |
| | | // if(homeGoodsSkuDTO.getId()!=null){ |
| | | // List arr=new ArrayList<>(); |
| | | // arr.add(homeGoodsSkuDTO.getId()); |
| | | // wrapper3.notIn(GoodsSku::getId,arr); |
| | | // } |
| | | if (homeGoodsSkuDTO.getSkuName() != null && homeGoodsSkuDTO.getSkuName() != "") { |
| | | wrapper3.like(GoodsSku::getSkuName, homeGoodsSkuDTO.getSkuName()); |
| | | } |
| | | if (homeGoodsSkuDTO.getSkuName()!=null&&homeGoodsSkuDTO.getSkuName()!=""){ |
| | | wrapper3.like(GoodsSku::getSkuName,homeGoodsSkuDTO.getSkuName()); |
| | | } |
| | | if (homeGoodsSkuDTO.getGoodsSkuId()!=null){ |
| | | List<Long> id=new ArrayList<>(); |
| | | if (homeGoodsSkuDTO.getGoodsSkuId() != null) { |
| | | List<Long> id = new ArrayList<>(); |
| | | id.add(homeGoodsSkuDTO.getGoodsSkuId()); |
| | | wrapper3.notIn(GoodsSku::getId,id); |
| | | wrapper3.notIn(GoodsSku::getId, id); |
| | | } |
| | | if (homeGoodsSkuDTO.getBrandId()!=null){ |
| | | wrapper3.eq(GoodsSku::getBrandId,homeGoodsSkuDTO.getBrandId()); |
| | | if (homeGoodsSkuDTO.getBrandId() != null) { |
| | | wrapper3.eq(GoodsSku::getBrandId, homeGoodsSkuDTO.getBrandId()); |
| | | } |
| | | if (homeGoodsSkuDTO.getCategoryId()!=null){ |
| | | wrapper3.eq(GoodsSku::getCategoryId,homeGoodsSkuDTO.getCategoryId()); |
| | | if (homeGoodsSkuDTO.getCategoryId() != null) { |
| | | wrapper3.eq(GoodsSku::getCategoryId, homeGoodsSkuDTO.getCategoryId()); |
| | | } |
| | | |
| | | if (homeGoodsSkuDTO.getSeriesId()!=null){ |
| | | wrapper3.eq(GoodsSku::getSeriesId,homeGoodsSkuDTO.getSeriesId()); |
| | | if (homeGoodsSkuDTO.getSeriesId() != null) { |
| | | wrapper3.eq(GoodsSku::getSeriesId, homeGoodsSkuDTO.getSeriesId()); |
| | | } |
| | | if (homeGoodsSkuDTO.getFlavorTypeId()!=null){ |
| | | wrapper3.eq(GoodsSku::getFlavorTypeId,homeGoodsSkuDTO.getFlavorTypeId()); |
| | | if (homeGoodsSkuDTO.getFlavorTypeId() != null) { |
| | | wrapper3.eq(GoodsSku::getFlavorTypeId, homeGoodsSkuDTO.getFlavorTypeId()); |
| | | } |
| | | if (homeGoodsSkuDTO.getSort()==2){ |
| | | if (homeGoodsSkuDTO.getSort() == 2) { |
| | | wrapper3.orderByAsc(GoodsSku::getPrice); |
| | | } |
| | | if (homeGoodsSkuDTO.getSort()==3){ |
| | | if (homeGoodsSkuDTO.getSort() == 3) { |
| | | wrapper3.orderByDesc(GoodsSku::getPrice); |
| | | } |
| | | if (homeGoodsSkuDTO.getSort()==4){ |
| | | if (homeGoodsSkuDTO.getSort() == 4) { |
| | | wrapper3.orderByAsc(GoodsSku::getSoldQuantity); |
| | | } |
| | | if (homeGoodsSkuDTO.getSort()==5){ |
| | | if (homeGoodsSkuDTO.getSort() == 5) { |
| | | wrapper3.orderByDesc(GoodsSku::getSoldQuantity); |
| | | } |
| | | if(homeGoodsSkuDTO.getYear()==2){ |
| | | if (homeGoodsSkuDTO.getYear() == 2) { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime newTime7 = now.minusYears(30); |
| | | String formattedDate7 = newTime7.format(formatter); |
| | | LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay(); |
| | | wrapper3.le(GoodsSku::getYears,parseTime7); |
| | | wrapper3.le(GoodsSku::getYears, DateUtil.format(parseTime7, "yyyy")); |
| | | } |
| | | if(homeGoodsSkuDTO.getYear()==3){ |
| | | if (homeGoodsSkuDTO.getYear() == 3) { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime newTime7 = now.minusYears(30); |
| | |
| | | |
| | | LocalDateTime newTime15 = now.minusYears(15); |
| | | String formattedDate15 = newTime15.format(formatter); |
| | | LocalDateTime parseTime15= LocalDate.parse(formattedDate15).atStartOfDay(); |
| | | wrapper3.le(GoodsSku::getYears, parseTime15) |
| | | .gt(GoodsSku::getYears, parseTime7); |
| | | LocalDateTime parseTime15 = LocalDate.parse(formattedDate15).atStartOfDay(); |
| | | wrapper3.le(GoodsSku::getYears, DateUtil.format(parseTime15, "yyyy")) |
| | | .gt(GoodsSku::getYears, DateUtil.format(parseTime7, "yyyy")); |
| | | } |
| | | |
| | | if(homeGoodsSkuDTO.getYear()==4){ |
| | | if (homeGoodsSkuDTO.getYear() == 4) { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime newTime7 = now.minusYears(5); |
| | |
| | | |
| | | LocalDateTime newTime15 = now.minusYears(15); |
| | | String formattedDate15 = newTime15.format(formatter); |
| | | LocalDateTime parseTime15= LocalDate.parse(formattedDate15).atStartOfDay(); |
| | | wrapper3.le(GoodsSku::getYears, parseTime7) |
| | | .gt(GoodsSku::getYears, parseTime15); |
| | | LocalDateTime parseTime15 = LocalDate.parse(formattedDate15).atStartOfDay(); |
| | | wrapper3.le(GoodsSku::getYears, DateUtil.format(parseTime7, "yyyy")) |
| | | .gt(GoodsSku::getYears, DateUtil.format(parseTime15, "yyyy")); |
| | | } |
| | | |
| | | if(homeGoodsSkuDTO.getYear()==5){ |
| | | if (homeGoodsSkuDTO.getYear() == 5) { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime newTime7 = now.minusYears(1); |
| | | String formattedDate7 = newTime7.format(formatter); |
| | | LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay(); |
| | | |
| | | LocalDateTime newTime15 = now.minusYears(5); |
| | | String formattedDate15 = newTime15.format(formatter); |
| | | LocalDateTime parseTime15= LocalDate.parse(formattedDate15).atStartOfDay(); |
| | | wrapper3.le(GoodsSku::getYears, parseTime7) |
| | | .ge(GoodsSku::getYears, parseTime15); |
| | | LocalDateTime parseTime15 = LocalDate.parse(formattedDate15).atStartOfDay(); |
| | | wrapper3.le(GoodsSku::getYears, DateUtil.format(parseTime7, "yyyy")) |
| | | .ge(GoodsSku::getYears, DateUtil.format(parseTime15, "yyyy")); |
| | | } |
| | | wrapper3.orderByAsc(GoodsSku::getSortNum); |
| | | if (homeGoodsSkuDTO.getSort() == 1) { |
| | | wrapper3.last(" ORDER BY IF(isnull(sort_num),1,0), sort_num ASC,create_time DESC"); |
| | | } else { |
| | | wrapper3.last(",IF(isnull(sort_num),1,0), sort_num DESC,create_time DESC"); |
| | | } |
| | | |
| | | Page<GoodsSku> page1 = this.page(page, wrapper3); |
| | | PageDTO<HomeGoodsSkuListVO> articleCommentsVOPageDTO = PageDTO.of(page1, HomeGoodsSkuListVO.class); |
| | | return articleCommentsVOPageDTO; |
| | | |
| | | if (SecurityUtils.isLogin()) { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | Member member = memberClient.getMemberByUserId(loginUser.getUserid(), |
| | | SecurityConstants.INNER).getData(); |
| | | // 用户已登录 有会员等级 会员等级不为普通用户 则获取会员价格 |
| | | if (Objects.nonNull(member.getVipClassify()) |
| | | && !member.getVipClassify().equals(MemberVipClassifyEnum.NORMAL.getCode())) { |
| | | for (GoodsSku record : page1.getRecords()) { |
| | | // 获取会员价格 |
| | | BigDecimal vipPrice = getVipPrice(record.getId(), member.getVipClassify()); |
| | | record.setPrice(vipPrice); |
| | | } |
| | | } |
| | | } |
| | | return PageDTO.of(page1, HomeGoodsSkuListVO.class); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public HomeGoodsSkuInfoVO getHomeGoodsSkuInfo(HomeGoodsSkuDTO homeGoodsSkuDTO) { |
| | | GoodsSku byId = this.getById(homeGoodsSkuDTO.getGoodsSkuId()); |
| | | if (Objects.isNull(byId)) { |
| | | throw new ServiceException("当前商品已下架"); |
| | | } |
| | | HomeGoodsSkuInfoVO homeGoodsSkuInfoVO=new HomeGoodsSkuInfoVO(); |
| | | homeGoodsSkuInfoVO.setId(byId.getId()); |
| | | homeGoodsSkuInfoVO.setSkuName(byId.getSkuName()); |
| | | homeGoodsSkuInfoVO.setYears(String.valueOf(byId.getYears().getYear())); |
| | | GoodsBrand data = goodsSkuClient.getBrandOne(byId.getBrandId(), SecurityConstants.INNER).getData(); |
| | |
| | | if (data3!=null) { |
| | | homeGoodsSkuInfoVO.setFlavorType(data3.getFlavorTypeName()); |
| | | } |
| | | homeGoodsSkuInfoVO.setPrice(byId.getPrice()); |
| | | homeGoodsSkuInfoVO.setSoldQuantity(byId.getSoldQuantity()); |
| | | homeGoodsSkuInfoVO.setUnit(byId.getUnit()); |
| | | homeGoodsSkuInfoVO.setSpec(byId.getSpec()); |
| | |
| | | homeGoodsSkuInfoVO.setDescription(byId.getDescription()); |
| | | homeGoodsSkuInfoVO.setStock(byId.getStock()); |
| | | homeGoodsSkuInfoVO.setDetail(byId.getDetail()); |
| | | homeGoodsSkuInfoVO.setShareTitle(byId.getShareTitle()); |
| | | homeGoodsSkuInfoVO.setSharePic(byId.getSharePic()); |
| | | |
| | | homeGoodsSkuInfoVO.setPrice(byId.getPrice()); |
| | | if (StringUtils.isBlank(byId.getShareTitle())) { |
| | | homeGoodsSkuInfoVO.setShareTitle(byId.getSkuName()); |
| | | } else { |
| | | homeGoodsSkuInfoVO.setShareTitle(byId.getShareTitle()); |
| | | } |
| | | if (StringUtils.isBlank(byId.getSharePic())) { |
| | | homeGoodsSkuInfoVO.setSharePic(byId.getCoverPic()); |
| | | } else { |
| | | homeGoodsSkuInfoVO.setSharePic(byId.getSharePic()); |
| | | } |
| | | LambdaQueryWrapper<GoodsGroupPurchase> queryWrapper1 =new LambdaQueryWrapper<>(); |
| | | queryWrapper1.eq(GoodsGroupPurchase::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES) |
| | |
| | | .eq(GoodsGroupPurchase::getStartStatus, |
| | | StartStatusEnum.STARTED); |
| | | GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectOne(queryWrapper1); |
| | | log.info("团购商品信息=================》:{}", goodsGroupPurchase); |
| | | if(goodsGroupPurchase!=null){ |
| | | HomeGoodsSkuDTO homeGoodsSkuDTO1 =new HomeGoodsSkuDTO(); |
| | | homeGoodsSkuDTO1.setGoodsSkuId(goodsGroupPurchase.getId()); |
| | | homeGoodsSkuDTO1.setMemberId(homeGoodsSkuDTO.getMemberId()); |
| | | Order data4 = orderClient.getOrderByGroupPurchaseMemberId2(homeGoodsSkuDTO1, SecurityConstants.INNER).getData(); |
| | | if (data4!=null){ |
| | | log.info("关联订单信息=================》:{}", data4); |
| | | homeGoodsSkuInfoVO.setId(goodsGroupPurchase.getId()); |
| | | homeGoodsSkuInfoVO.setIsGoodsGroupPurchase(1); |
| | | if (data4 != null) { |
| | | homeGoodsSkuInfoVO.setIsGoodsGroupPurchase(2); |
| | | }else{ |
| | | homeGoodsSkuInfoVO.setIsGoodsGroupPurchase(1); |
| | | } |
| | | |
| | | }else{ |
| | | log.info( |
| | | "=============================没有查询到团购信息============================="); |
| | | homeGoodsSkuInfoVO.setIsGoodsGroupPurchase(1); |
| | | } |
| | | |
| | | // 获取会员价格 |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | Member member = memberClient.getMemberByUserId(loginUser.getUserid(), |
| | | SecurityConstants.INNER).getData(); |
| | | // 用户已登录 有会员等级 会员等级不为普通用户 则获取会员价格 |
| | | if (SecurityUtils.isLogin() && Objects.nonNull(member.getVipClassify()) |
| | | && !member.getVipClassify().equals(MemberVipClassifyEnum.NORMAL.getCode())) { |
| | | // 获取会员价格 |
| | | BigDecimal vipPrice = getVipPrice(byId.getId(), member.getVipClassify()); |
| | | homeGoodsSkuInfoVO.setPrice(vipPrice); |
| | | } |
| | | |
| | | LambdaQueryWrapper<MemberGoodsCollection> wrapper3= Wrappers.lambdaQuery(); |
| | | wrapper3.eq(MemberGoodsCollection::getDelFlag,0); |
| | |
| | | }else{ |
| | | homeGoodsSkuInfoVO.setIsCollection(1); |
| | | } |
| | | List list1=new ArrayList<>(); |
| | | list1.add(0); |
| | | list1.add(1); |
| | | LambdaQueryWrapper<GoodsGroupPurchase> queryWrapper2 =new LambdaQueryWrapper<>(); |
| | | queryWrapper2.eq(GoodsGroupPurchase::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES) |
| | | .eq(GoodsGroupPurchase::getGoodsSkuId, byId.getId()).in(GoodsGroupPurchase::getStartStatus, list1); |
| | | .eq(GoodsGroupPurchase::getGoodsSkuId, byId.getId()) |
| | | .eq(GoodsGroupPurchase::getStartStatus, StartStatusEnum.STARTED); |
| | | GoodsGroupPurchase goodsGroupPurchase2 = goodsGroupPurchaseMapper.selectOne(queryWrapper2); |
| | | if (goodsGroupPurchase2!=null){ |
| | | homeGoodsSkuInfoVO.setGroupPurchaseGoods(2); |
| | |
| | | wrapper4.ge(GoodsBrowseRecord::getCreateTime, newTime7) |
| | | .le(GoodsBrowseRecord::getCreateTime,now ); |
| | | List<GoodsBrowseRecord> list2 = iGoodsBrowseRecordService.list(wrapper4); |
| | | if (list2.size()==0){ |
| | | if (list2.isEmpty()){ |
| | | GoodsBrowseRecord auctionBrowseRecord=new GoodsBrowseRecord(); |
| | | auctionBrowseRecord.setMemberId(homeGoodsSkuDTO.getMemberId()); |
| | | auctionBrowseRecord.setGoodsSkuId(homeGoodsSkuDTO.getGoodsSkuId()); |
| | |
| | | |
| | | |
| | | return homeGoodsSkuInfoVO; |
| | | } |
| | | |
| | | private BigDecimal getVipPrice(Long goodsSkuId, Integer vipClassify) { |
| | | GoodsSku byId = getById(goodsSkuId); |
| | | BigDecimal price = BigDecimal.ZERO; |
| | | if (MemberVipClassifyEnum.VIP.getCode().equals(vipClassify)) { |
| | | price = byId.getVipPrice(); |
| | | } else if (MemberVipClassifyEnum.SUPER_VIP.getCode().equals(vipClassify)) { |
| | | price = byId.getSuperVipPrice(); |
| | | } |
| | | return price; |
| | | } |
| | | |
| | | @Override |
| | |
| | | goodsSkuVO.setGoodsInfoTitleValueVOList(goodsInfoTitleValueVOList); |
| | | return goodsSkuVO; |
| | | } |
| | | |
| | | @Override |
| | | public void returnStockByOrder(Order order) { |
| | | Long goodsSkuId = null; |
| | | if (order.getOrderFrom().equals(OrderFromEnum.COMMODITY_ORDER)) { |
| | | goodsSkuId = order.getGoodsSkuId(); |
| | | } else if (order.getOrderFrom().equals(OrderFromEnum.SNAP_ORDERS)) { |
| | | GoodsSeckill goodsSeckill = goodsSeckillMapper.selectById(order.getGoodsSkuId()); |
| | | if (Objects.nonNull(goodsSeckill)) { |
| | | goodsSkuId = goodsSeckill.getGoodsSkuId(); |
| | | } |
| | | } else if (order.getOrderFrom().equals(OrderFromEnum.GROUP_PURCHASE_ORDERS)) { |
| | | GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectById( |
| | | order.getGoodsSkuId()); |
| | | if (Objects.nonNull(goodsGroupPurchase)) { |
| | | goodsSkuId = goodsGroupPurchase.getGoodsSkuId(); |
| | | } |
| | | } else if (order.getOrderFrom() |
| | | .equals(OrderFromEnum.AUCTION_ORDERS) && order.getAuctionOrderType() |
| | | .equals(AuctionOrderTypeEnum.REGULAR_ITEMS)) { |
| | | AuctionGoods auctionGoods = auctionClient.getAuctionGoodsId(order.getGoodsSkuId(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (Objects.nonNull(auctionGoods)) { |
| | | goodsSkuId = auctionGoods.getGoodsSkuId(); |
| | | } |
| | | } else if (order.getOrderFrom() |
| | | .equals(OrderFromEnum.AUCTION_ORDERS) && order.getAuctionOrderType() |
| | | .equals(AuctionOrderTypeEnum.AUCTION_ITEMS)) { |
| | | AuctionSalesroomGoods auctionSalesroomGoods = auctionClient.getAuctionSalesroomGoodsById( |
| | | order.getGoodsSkuId(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (Objects.nonNull(auctionSalesroomGoods)) { |
| | | goodsSkuId = auctionSalesroomGoods.getGoodsSkuId(); |
| | | } |
| | | } |
| | | if (Objects.nonNull(goodsSkuId)) { |
| | | updateGoodsStock(goodsSkuId, order.getGoodsQuantity()); |
| | | } |
| | | } |
| | | } |