修复sku修改之后清除问题
This commit is contained in:
@ -45,7 +45,7 @@ public class YxStoreProductAttrResultServiceImpl extends BaseServiceImpl<StorePr
|
|||||||
yxStoreProductAttrResult.setResult(JSON.toJSONString(map));
|
yxStoreProductAttrResult.setResult(JSON.toJSONString(map));
|
||||||
yxStoreProductAttrResult.setChangeTime(new Date());
|
yxStoreProductAttrResult.setChangeTime(new Date());
|
||||||
|
|
||||||
Long count = this.count(Wrappers.<YxStoreProductAttrResult>lambdaQuery()
|
long count = this.count(Wrappers.<YxStoreProductAttrResult>lambdaQuery()
|
||||||
.eq(YxStoreProductAttrResult::getProductId,productId));
|
.eq(YxStoreProductAttrResult::getProductId,productId));
|
||||||
if(count > 0) {
|
if(count > 0) {
|
||||||
this.remove(Wrappers.<YxStoreProductAttrResult>lambdaQuery()
|
this.remove(Wrappers.<YxStoreProductAttrResult>lambdaQuery()
|
||||||
|
@ -29,6 +29,7 @@ import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
|||||||
import co.yixiang.modules.product.service.mapper.StoreProductAttrMapper;
|
import co.yixiang.modules.product.service.mapper.StoreProductAttrMapper;
|
||||||
import co.yixiang.modules.product.service.mapper.StoreProductAttrValueMapper;
|
import co.yixiang.modules.product.service.mapper.StoreProductAttrValueMapper;
|
||||||
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo;
|
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -42,6 +43,7 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@ -101,14 +103,23 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
|
|||||||
}
|
}
|
||||||
List<String> stringList = new ArrayList<>(productFormatDto.getDetail().values());
|
List<String> stringList = new ArrayList<>(productFormatDto.getDetail().values());
|
||||||
Collections.sort(stringList);
|
Collections.sort(stringList);
|
||||||
|
YxStoreProductAttrValue oldAttrValue = storeProductAttrValueService.getOne(new LambdaQueryWrapper<YxStoreProductAttrValue>()
|
||||||
|
.eq(YxStoreProductAttrValue::getSku, productFormatDto.getSku())
|
||||||
|
.eq(YxStoreProductAttrValue::getProductId, productId));
|
||||||
|
|
||||||
|
String unique = IdUtil.simpleUUID();
|
||||||
|
if (Objects.nonNull(oldAttrValue)) {
|
||||||
|
unique = oldAttrValue.getUnique();
|
||||||
|
}
|
||||||
|
|
||||||
YxStoreProductAttrValue yxStoreProductAttrValue = YxStoreProductAttrValue.builder()
|
YxStoreProductAttrValue yxStoreProductAttrValue = YxStoreProductAttrValue.builder()
|
||||||
|
.id(Objects.isNull(oldAttrValue) ? null : oldAttrValue.getId())
|
||||||
.productId(productId)
|
.productId(productId)
|
||||||
.sku(StrUtil.join(",",stringList))
|
.sku(StrUtil.join(",",stringList))
|
||||||
.price(BigDecimal.valueOf(productFormatDto.getPrice()))
|
.price(BigDecimal.valueOf(productFormatDto.getPrice()))
|
||||||
.cost(BigDecimal.valueOf(productFormatDto.getCost()))
|
.cost(BigDecimal.valueOf(productFormatDto.getCost()))
|
||||||
.otPrice(BigDecimal.valueOf(productFormatDto.getOtPrice()))
|
.otPrice(BigDecimal.valueOf(productFormatDto.getOtPrice()))
|
||||||
.unique(IdUtil.simpleUUID())
|
.unique(unique)
|
||||||
.image(productFormatDto.getPic())
|
.image(productFormatDto.getPic())
|
||||||
.barCode(productFormatDto.getBarCode())
|
.barCode(productFormatDto.getBarCode())
|
||||||
.weight(BigDecimal.valueOf(productFormatDto.getWeight()))
|
.weight(BigDecimal.valueOf(productFormatDto.getWeight()))
|
||||||
@ -123,7 +134,6 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
|
|||||||
.seckillStock(productFormatDto.getSeckillStock()==null?0:productFormatDto.getSeckillStock())
|
.seckillStock(productFormatDto.getSeckillStock()==null?0:productFormatDto.getSeckillStock())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
valueGroup.add(yxStoreProductAttrValue);
|
valueGroup.add(yxStoreProductAttrValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user