xiaoyong931011
2021-06-24 b8b21ccb301ebc4e0bd199ddfdae920a95245893
gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
@@ -2,6 +2,8 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -11,6 +13,7 @@
import com.xzx.gc.common.utils.MqUtil;
import com.xzx.gc.entity.*;
import com.xzx.gc.model.admin.GoodsCategoryModel;
import com.xzx.gc.model.order.OrderInfoVo;
import com.xzx.gc.shop.dto.*;
import com.xzx.gc.shop.mapper.*;
import com.xzx.gc.shop.vo.*;
@@ -21,10 +24,7 @@
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service
@Transactional
@@ -287,4 +287,34 @@
        }
        return maps;
    }
    public List<GoodsCategoryVo> findCategoryWithChildren() {
        return scoreGoodsCategoryMapper.selectCategoryWithChildren();
    }
    public PageInfo<XcxGoodsListVo> findGoodsListInPage(XcxGoodsListDto xcxGoodsListDto) {
        PageHelper.startPage(xcxGoodsListDto.getPageNo(), xcxGoodsListDto.getPageSize());
        List<XcxGoodsListVo> data = scoreGoodsMapper.selectXcxGoodsList(xcxGoodsListDto);
        return new PageInfo<>(data);
    }
    public XcxGoodsDetailVo findGoodsDetails(Long id) {
        XcxGoodsDetailVo data = scoreGoodsMapper.selectGoodsDetailsById(id);
        XcxGoodsListDto dto = new XcxGoodsListDto();
        dto.setId(id);
        List<XcxGoodsListVo> list = scoreGoodsMapper.selectXcxGoodsList(dto);
        if (CollUtil.isNotEmpty(list)) {
            data.setQuantity(list.get(0).getQuantity());
            data.setStock(list.get(0).getStock());
        }
        if (ScoreGoods.ISQG_YES.equals(data.getIsQg())) {
            Long remain = DateUtil.between(new Date(), data.getQgEndTime(), DateUnit.SECOND, false);
            data.setRemainTime(remain);
        }
        return data;
    }
}