mitao
2024-08-16 d7dc4db8d005a58f51d21d35147317762a16373f
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSkuServiceImpl.java
@@ -1,5 +1,6 @@
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;
@@ -388,7 +389,7 @@
            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){
            LocalDateTime now = LocalDateTime.now();
@@ -400,8 +401,8 @@
            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);
            wrapper3.le(GoodsSku::getYears, DateUtil.format(parseTime15, "yyyy"))
                    .gt(GoodsSku::getYears, DateUtil.format(parseTime7, "yyyy"));
        }
        if(homeGoodsSkuDTO.getYear()==4){
@@ -414,8 +415,8 @@
            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);
            wrapper3.le(GoodsSku::getYears, DateUtil.format(parseTime7, "yyyy"))
                    .gt(GoodsSku::getYears, DateUtil.format(parseTime15, "yyyy"));
        }
        if(homeGoodsSkuDTO.getYear()==5){
@@ -424,12 +425,11 @@
            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);
            wrapper3.le(GoodsSku::getYears, DateUtil.format(parseTime7, "yyyy"))
                    .ge(GoodsSku::getYears, DateUtil.format(parseTime15, "yyyy"));
        }
        if (homeGoodsSkuDTO.getSort()==1){
            wrapper3.last(" ORDER BY IF(isnull(sort_num),1,0), sort_num DESC,create_time DESC");
@@ -448,7 +448,6 @@
    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();
@@ -487,18 +486,21 @@
                .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);
        }