From 34f2977c2dc250284c61b1195e1295465cbebbb2 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Tue, 29 Jun 2021 15:06:43 +0800 Subject: [PATCH] 20210628 集物员审核 --- gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java | 44 +++++++++++++++++++++++++++++++++----------- 1 files changed, 33 insertions(+), 11 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 b8408e6..d66a17b 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,5 +1,6 @@ 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.DateUnit; @@ -68,7 +69,7 @@ scoreGoodsCategory.setParentId(model.getParentId()); scoreGoodsCategory.setCreatedBy(model.getCreatedBy()); scoreGoodsCategory.setCreatedTime(model.getCreatedTime()); - scoreGoodsCategoryMapper.insert(scoreGoodsCategory); + scoreGoodsCategoryMapper.insertSelective(scoreGoodsCategory); return scoreGoodsCategory.getId(); } @@ -116,15 +117,15 @@ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ScoreGoods scoreGoods = objectMapper.convertValue(model, ScoreGoods.class); scoreGoods.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG)); - scoreGoodsMapper.insert(scoreGoods); + scoreGoodsMapper.insertSelective(scoreGoods); //样式信息 - List<ScoreGoodsStyleDto> scoreGoodsStyleDtos = model.getScoreGoodsStyleDtos(); + List<ScoreGoodsStyleDto> scoreGoodsStyleDtos = model.getScoreGoodsStyles(); if(CollUtil.isNotEmpty(scoreGoodsStyleDtos)){ for(ScoreGoodsStyleDto scoreGoodsStyleDto : scoreGoodsStyleDtos){ ScoreGoodsStyle scoreGoodsStyle = objectMapper.convertValue(scoreGoodsStyleDto, ScoreGoodsStyle.class); scoreGoodsStyle.setGoodsId(scoreGoods.getId()); scoreGoodsStyle.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG)); - scoreGoodsStyleMapper.insert(scoreGoodsStyle); + scoreGoodsStyleMapper.insertSelective(scoreGoodsStyle); //规格信息 List<ScoreGoodsSkuDto> scoreGoodsSkuDtos = scoreGoodsStyleDto.getScoreGoodsSkus(); if(CollUtil.isNotEmpty(scoreGoodsSkuDtos)){ @@ -133,7 +134,7 @@ scoreGoodsSku.setGoodsId(scoreGoods.getId()); scoreGoodsSku.setStyleId(scoreGoodsStyle.getId()); scoreGoodsSku.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG)); - scoreGoodsSkuMapper.insert(scoreGoodsSku); + scoreGoodsSkuMapper.insertSelective(scoreGoodsSku); } } } @@ -184,6 +185,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 +210,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); //轮播图 @@ -223,24 +226,36 @@ scoreGoodsImages.setImageUrl(goodImage); scoreGoodsImages.setGoodsId(scoreGoods.getId()); scoreGoodsImages.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG)); - scoreGoodsImagesMapper.insert(scoreGoodsImages); + scoreGoodsImagesMapper.insertSelective(scoreGoodsImages); } } List<ScoreGoodsStyleDto> scoreGoodsStyleDtos = model.getScoreGoodsStyles(); if(CollUtil.isNotEmpty(scoreGoodsStyleDtos)){ + Example exampleStyle = new Example(ScoreGoodsStyle.class); + Example.Criteria criteriaStyle = exampleStyle.createCriteria(); + criteriaStyle.andEqualTo("goodsId",scoreGoods.getId()); + scoreGoodsStyleMapper.deleteByExample(exampleImages); + + Example exampleSku = new Example(ScoreGoodsSku.class); + Example.Criteria criteriaSku = exampleSku.createCriteria(); + criteriaSku.andEqualTo("goodsId",scoreGoods.getId()); + scoreGoodsSkuMapper.deleteByExample(exampleImages); + for(ScoreGoodsStyleDto scoreGoodsStyleDto : scoreGoodsStyleDtos){ ScoreGoodsStyle scoreGoodsStyle = new ScoreGoodsStyle(); scoreGoodsStyle.setId(scoreGoodsStyleDto.getId()); scoreGoodsStyle.setName(scoreGoodsStyleDto.getName()); scoreGoodsStyle.setGoodsId(scoreGoods.getId()); - scoreGoodsStyleMapper.updateByPrimaryKeySelective(scoreGoodsStyle); + scoreGoodsStyleMapper.insertSelective(scoreGoodsStyle); //规格 List<ScoreGoodsSkuDto> scoreGoodsSkuDtos = scoreGoodsStyleDto.getScoreGoodsSkus(); if(CollUtil.isNotEmpty(scoreGoodsSkuDtos)){ for(ScoreGoodsSkuDto scoreGoodsSkuDto : scoreGoodsSkuDtos){ ScoreGoodsSku scoreGoodsSku = objectMapper.convertValue(scoreGoodsSkuDto, ScoreGoodsSku.class); - scoreGoodsSkuMapper.updateByPrimaryKey(scoreGoodsSku); + scoreGoodsSku.setGoodsId(scoreGoods.getId()); + scoreGoodsSku.setStyleId(scoreGoodsStyle.getId()); + scoreGoodsSkuMapper.insertSelective(scoreGoodsSku); } } } @@ -271,6 +286,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); @@ -314,8 +331,13 @@ } 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; } -- Gitblit v1.9.1