From 5a02b62b3b2b3663b89a1fb8be0c3f6ac1eb1d3f Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 29 Jun 2021 17:54:48 +0800 Subject: [PATCH] fix --- gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 52 insertions(+), 4 deletions(-) diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java b/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java index cb0ee15..089e010 100644 --- a/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java +++ b/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java @@ -1,10 +1,13 @@ package com.xzx.gc.shop.service; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.pagehelper.PageHelper; @@ -41,6 +44,8 @@ ScoreGoodsImagesMapper scoreGoodsImagesMapper; @Resource ScoreGoodsStyleMapper scoreGoodsStyleMapper; + @Resource + ScoreGoodsSearchMapper scoreGoodsSearchMapper; @Autowired private MqUtil mqUtil; @@ -184,6 +189,7 @@ ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); viewGoodsVo = objectMapper.convertValue(scoreGoods, ViewGoodsVo.class); +// viewGoodsVo.setCreateTime(scoreGoods.getCreatedTime().toString()); //轮播图 List<String> goodsImages = scoreGoodsImagesMapper.selectScoreGoodsImagesByGoodsId(id); viewGoodsVo.setGoodsImages(goodsImages); @@ -208,7 +214,8 @@ public void updateGoods(UpdateGoodsDto model) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - ScoreGoods scoreGoods = objectMapper.convertValue(model, ScoreGoods.class); +// ScoreGoods scoreGoods = objectMapper.convertValue(model, ScoreGoods.class); + ScoreGoods scoreGoods = BeanUtil.copyProperties(model, ScoreGoods.class); scoreGoodsMapper.updateByPrimaryKey(scoreGoods); //轮播图 @@ -250,6 +257,8 @@ if(CollUtil.isNotEmpty(scoreGoodsSkuDtos)){ for(ScoreGoodsSkuDto scoreGoodsSkuDto : scoreGoodsSkuDtos){ ScoreGoodsSku scoreGoodsSku = objectMapper.convertValue(scoreGoodsSkuDto, ScoreGoodsSku.class); + scoreGoodsSku.setGoodsId(scoreGoods.getId()); + scoreGoodsSku.setStyleId(scoreGoodsStyle.getId()); scoreGoodsSkuMapper.insertSelective(scoreGoodsSku); } } @@ -281,6 +290,8 @@ }else{ ScoreGoods scoreGoods = new ScoreGoods(); scoreGoods.setIsQg(ScoreGoods.ISQG_NO); + scoreGoods.setQgEndTime(null); + scoreGoods.setQgStartTime(null); Example exampleGoods = new Example(ScoreGoods.class); Example.Criteria criteriaGoods = exampleGoods.createCriteria(); criteriaGoods.andEqualTo("id",id); @@ -306,7 +317,20 @@ PageHelper.startPage(xcxGoodsListDto.getPageNo(), xcxGoodsListDto.getPageSize()); List<XcxGoodsListVo> data = scoreGoodsMapper.selectXcxGoodsList(xcxGoodsListDto); - + if(StrUtil.isNotEmpty(xcxGoodsListDto.getName())){ + Example exampleSearch = new Example(ScoreGoodsSearch.class); + Example.Criteria criteriaSearch = exampleSearch.createCriteria(); + criteriaSearch.andEqualTo("contents",xcxGoodsListDto.getName()); + criteriaSearch.andEqualTo("userId",xcxGoodsListDto.getUserId()); + List<ScoreGoodsSearch> scoreGoodsSearches = scoreGoodsSearchMapper.selectByExample(exampleSearch); + if(CollUtil.isEmpty(scoreGoodsSearches)){ + ScoreGoodsSearch scoreGoodsSearch = new ScoreGoodsSearch(); + scoreGoodsSearch.setUserId(xcxGoodsListDto.getUserId()); + scoreGoodsSearch.setContents(xcxGoodsListDto.getName()); + scoreGoodsSearch.setCreatedTime(new Date()); + scoreGoodsSearchMapper.insert(scoreGoodsSearch); + } + } return new PageInfo<>(data); } @@ -324,9 +348,33 @@ } if (ScoreGoods.ISQG_YES.equals(data.getIsQg())) { - Long remain = DateUtil.between(new Date(), data.getQgEndTime(), DateUnit.SECOND, false); - data.setRemainTime(remain); + if (new Date().before(data.getQgStartTime())) { + data.setIsStartQg(2); + } else { + data.setIsStartQg(1); + Long remain = DateUtil.between(new Date(), data.getQgEndTime(), DateUnit.SECOND, false); + data.setRemainTime(remain); + } } return data; } + + public List<GoodsSearchVo> goodsSearch(GoodsSearchDto goodsSearchDto) { + return scoreGoodsSearchMapper.goodsSearch(goodsSearchDto); + } + + public void delGoodsSearch(Long id, String userId) { + Example exampleSearch = new Example(ScoreGoodsSearch.class); + Example.Criteria criteriaSearch = exampleSearch.createCriteria(); + criteriaSearch.andEqualTo("id",id); + criteriaSearch.andEqualTo("userId",userId); + scoreGoodsSearchMapper.deleteByExample(exampleSearch); + } + + public void delAllSearch(String userId) { + Example exampleSearch = new Example(ScoreGoodsSearch.class); + Example.Criteria criteriaSearch = exampleSearch.createCriteria(); + criteriaSearch.andEqualTo("userId",userId); + scoreGoodsSearchMapper.deleteByExample(exampleSearch); + } } -- Gitblit v1.9.1