| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | 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.ListingStatusEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | |
| | | import com.ruoyi.goods.controller.management.vo.GoodsSkuVO; |
| | | import com.ruoyi.goods.domain.GoodsGroupPurchase; |
| | | import com.ruoyi.goods.domain.GoodsInfoTitleValue; |
| | | import com.ruoyi.goods.domain.MemberGoodsCollection; |
| | | 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.system.api.domain.GoodsSeckill; |
| | | import com.ruoyi.system.api.domain.GoodsSku; |
| | | import com.ruoyi.goods.service.IMemberGoodsCollectionService; |
| | | import com.ruoyi.system.api.domain.*; |
| | | 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 java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.system.api.domain.vo.AuctionGoodsListVO; |
| | | import com.ruoyi.system.api.domain.vo.HomeGoodsSkuListVO; |
| | | import com.ruoyi.system.api.domain.vo.HomeGoodsSkuInfoVO; |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.redisson.api.RLock; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private final GoodsSeckillMapper goodsSeckillMapper; |
| | | private final GoodsGroupPurchaseMapper goodsGroupPurchaseMapper; |
| | | private final RedissonClient redissonClient; |
| | | @Resource |
| | | private GoodsSkuClient goodsSkuClient; |
| | | |
| | | @Resource |
| | | private IMemberGoodsCollectionService iMemberGoodsCollectionService; |
| | | |
| | | |
| | | private static final ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | |
| | | |
| | | LambdaQueryWrapper<GoodsSku> wrapper3= Wrappers.lambdaQuery(); |
| | | wrapper3.eq(GoodsSku::getDelFlag,0); |
| | | wrapper3.eq(GoodsSku::getListingStatus,0); |
| | | wrapper3.like(GoodsSku::getSkuName,homeGoodsSkuDTO.getSkuName()); |
| | | wrapper3.eq(GoodsSku::getSkuName,homeGoodsSkuDTO.getSkuName()); |
| | | wrapper3.eq(GoodsSku::getBrandId,homeGoodsSkuDTO.getBrandId()); |
| | |
| | | if (homeGoodsSkuDTO.getSort()==5){ |
| | | wrapper3.orderByDesc(GoodsSku::getSoldQuantity); |
| | | } |
| | | 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 = LocalDateTime.parse(formattedDate7, formatter); |
| | | wrapper3.gt(GoodsSku::getYears,parseTime7); |
| | | } |
| | | if(homeGoodsSkuDTO.getYear()==3){ |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime newTime7 = now.minusYears(30); |
| | | String formattedDate7 = newTime7.format(formatter); |
| | | LocalDateTime parseTime7 = LocalDateTime.parse(formattedDate7, formatter); |
| | | |
| | | LocalDateTime newTime15 = now.minusYears(15); |
| | | String formattedDate15 = newTime15.format(formatter); |
| | | LocalDateTime parseTime15= LocalDateTime.parse(formattedDate15, formatter); |
| | | wrapper3.gt(GoodsSku::getYears, parseTime15) |
| | | .le(GoodsSku::getYears, parseTime7); |
| | | } |
| | | |
| | | if(homeGoodsSkuDTO.getYear()==3){ |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime newTime7 = now.minusYears(5); |
| | | String formattedDate7 = newTime7.format(formatter); |
| | | LocalDateTime parseTime7 = LocalDateTime.parse(formattedDate7, formatter); |
| | | |
| | | LocalDateTime newTime15 = now.minusYears(15); |
| | | String formattedDate15 = newTime15.format(formatter); |
| | | LocalDateTime parseTime15= LocalDateTime.parse(formattedDate15, formatter); |
| | | wrapper3.ge(GoodsSku::getYears, parseTime7) |
| | | .le(GoodsSku::getYears, parseTime15); |
| | | } |
| | | wrapper3.orderByAsc(GoodsSku::getSortNum); |
| | | Page<GoodsSku> page1 = this.page(page, wrapper3); |
| | | PageDTO<HomeGoodsSkuListVO> articleCommentsVOPageDTO = PageDTO.of(page1, HomeGoodsSkuListVO.class); |
| | | return articleCommentsVOPageDTO; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public HomeGoodsSkuInfoVO getHomeGoodsSkuInfo(HomeGoodsSkuDTO homeGoodsSkuDTO) { |
| | | GoodsSku byId = this.getById(homeGoodsSkuDTO.getGoodsSkuId()); |
| | | 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(); |
| | | GoodsCategory data1 = goodsSkuClient.getCategoryOne(byId.getCategoryId(), SecurityConstants.INNER).getData(); |
| | | GoodsSeries data2 = goodsSkuClient.getSeriesOne(byId.getSeriesId(), SecurityConstants.INNER).getData(); |
| | | GoodsFlavorType data3 = goodsSkuClient.getFlavorTypeOne(byId.getFlavorTypeId(), SecurityConstants.INNER).getData(); |
| | | homeGoodsSkuInfoVO.setBrand(data.getBrandName()); |
| | | homeGoodsSkuInfoVO.setCategory(data1.getCategoryName()); |
| | | homeGoodsSkuInfoVO.setSeries(data2.getSeriesName()); |
| | | homeGoodsSkuInfoVO.setFlavorType(data3.getFlavorTypeName()); |
| | | homeGoodsSkuInfoVO.setPrice(byId.getPrice()); |
| | | homeGoodsSkuInfoVO.setSoldQuantity(byId.getSoldQuantity()); |
| | | homeGoodsSkuInfoVO.setUnit(byId.getUnit()); |
| | | homeGoodsSkuInfoVO.setSpec(byId.getSpec()); |
| | | homeGoodsSkuInfoVO.setSpecUnit(byId.getSpecUnit()); |
| | | homeGoodsSkuInfoVO.setCoverPic(byId.getCoverPic()); |
| | | homeGoodsSkuInfoVO.setAlbum(byId.getAlbum()); |
| | | homeGoodsSkuInfoVO.setDescription(byId.getDescription()); |
| | | homeGoodsSkuInfoVO.setDetail(byId.getDetail()); |
| | | homeGoodsSkuInfoVO.setShareTitle(byId.getShareTitle()); |
| | | homeGoodsSkuInfoVO.setSharePic(byId.getSharePic()); |
| | | |
| | | LambdaQueryWrapper<MemberGoodsCollection> wrapper3= Wrappers.lambdaQuery(); |
| | | wrapper3.eq(MemberGoodsCollection::getDelFlag,0); |
| | | wrapper3.eq(MemberGoodsCollection::getMemberId,homeGoodsSkuDTO.getMemberId()); |
| | | wrapper3.eq(MemberGoodsCollection::getTargetId,homeGoodsSkuDTO.getGoodsSkuId()); |
| | | List<MemberGoodsCollection> list = iMemberGoodsCollectionService.list(wrapper3); |
| | | if (list.size()>0){ |
| | | homeGoodsSkuInfoVO.setIsCollection(2); |
| | | }else{ |
| | | homeGoodsSkuInfoVO.setIsCollection(1); |
| | | } |
| | | LambdaQueryWrapper<GoodsGroupPurchase> queryWrapper1 =new LambdaQueryWrapper<>(); |
| | | queryWrapper1.eq(GoodsGroupPurchase::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES) |
| | | .eq(GoodsGroupPurchase::getGoodsSkuId, byId.getId()); |
| | | GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectOne(queryWrapper1); |
| | | if (goodsGroupPurchase!=null){ |
| | | homeGoodsSkuInfoVO.setIsGoodsGroupPurchase(2); |
| | | }else{ |
| | | homeGoodsSkuInfoVO.setIsGoodsGroupPurchase(1); |
| | | } |
| | | return homeGoodsSkuInfoVO; |
| | | } |
| | | |
| | | private boolean updateGoodsStock(GoodsSku skus, Integer auctionStock) { |
| | | return this.lambdaUpdate() |
| | | .set(skus.getStock() + auctionStock > 0, GoodsSku::getStock, |