Helius
2021-06-24 7043628d74a26cc09a3735c251567bf36f6219b6
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
@@ -96,14 +96,11 @@
    }
    public Map<String, Object> queryGoodsList(QueryGoodsListDto model) {
        String name = model.getName();
        int delFlag = model.getDelFlag();
        ScoreGoods scoreGoods = new ScoreGoods();
        scoreGoods.setName(name);
        scoreGoods.setDelFlag(Convert.toShort(delFlag));
        String name = model.getName() == null ? "":model.getName();
        int delFlag = model.getDelFlag() == null ? 2:model.getDelFlag();
        PageHelper.startPage(model.getPage(), model.getLimit());
        List<QueryGoodsListVo> maps = scoreGoodsMapper.queryGoodsList(scoreGoods);
        List<QueryGoodsListVo> maps = scoreGoodsMapper.queryGoodsList(name,delFlag);
        PageInfo pageInfo = new PageInfo(maps);
        int count = Convert.toInt(pageInfo.getTotal());
        Map<String, Object> map = new HashMap<>();
@@ -280,4 +277,44 @@
            scoreGoodsMapper.updateByExampleSelective(scoreGoods,exampleGoods);
        }
    }
    public List<ViewGoodsCategoryListVo> viewGoodsCategoryList(ViewGoodsCategoryListDto viewGoodsCategoryListDto) {
        List<ViewGoodsCategoryListVo> maps = new ArrayList<>();
        if(viewGoodsCategoryListDto.getParentId() == 0L){
            maps = scoreGoodsCategoryMapper.viewGoodsCategoryOneList(viewGoodsCategoryListDto.getParentId());
        }else{
            maps = scoreGoodsCategoryMapper.viewGoodsCategoryList();
        }
        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;
    }
}