diff --git a/cereshop-admin/src/main/java/com/shop/cereshop/admin/page/product/SkuValueParam.java b/cereshop-admin/src/main/java/com/shop/cereshop/admin/page/product/SkuValueParam.java index c04c45a..e11052f 100644 --- a/cereshop-admin/src/main/java/com/shop/cereshop/admin/page/product/SkuValueParam.java +++ b/cereshop-admin/src/main/java/com/shop/cereshop/admin/page/product/SkuValueParam.java @@ -28,7 +28,7 @@ public class SkuValueParam { * 规格值 */ @ApiModelProperty(value = "规格值") - @NotBlank(message = "规格值不能为空") +// @NotBlank(message = "规格值不能为空") private String skuValue; /** diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/NameValue.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/NameValue.java index c098867..00b7130 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/NameValue.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/NameValue.java @@ -5,10 +5,14 @@ */ package com.shop.cereshop.business.param.product; +import com.baomidou.mybatisplus.annotation.TableField; +import com.shop.cereshop.commons.domain.product.CereSkuNameLangInfo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Map; + /** * 商品规格名值数据 */ @@ -38,4 +42,11 @@ public class NameValue { * 是否需要配图 */ private Integer need; + + /** + * 名称Map + */ + @ApiModelProperty(value = "名称Map") + @TableField(exist = false) + private Map langInfoMap; } diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java index 5aabbbd..a0ed6ce 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java @@ -41,7 +41,7 @@ public class ProductSaveParam { * 商品名称 */ @ApiModelProperty(value = "商品名称") - @NotBlank(message = "商品名称不能为空") +// @NotBlank(message = "商品名称不能为空") private String productName; /** diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/SkuValueParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/SkuValueParam.java index 3ae770b..75870dd 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/SkuValueParam.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/SkuValueParam.java @@ -31,7 +31,7 @@ public class SkuValueParam { * 规格值 */ @ApiModelProperty(value = "规格值") - @NotBlank(message = "规格值不能为空") +// @NotBlank(message = "规格值不能为空") private String skuValue; /** diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereProductClassifyServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereProductClassifyServiceImpl.java index 1d5cdb5..2e61039 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereProductClassifyServiceImpl.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereProductClassifyServiceImpl.java @@ -210,9 +210,6 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic private void addOneClassify(CereProductClassify classify, String time, List updates, List updateIds, List langInfoList) throws CoBusinessException{ - if(EmptyUtils.isEmpty(classify.getClassifyName())){ - throw new CoBusinessException(CoReturnFormat.CLASSIFY_NAME_NULL); - } CereProductClassify cereProductClassify=new CereProductClassify(); cereProductClassify.setClassifyId(classify.getClassifyId()); cereProductClassify.setClassifyName(classify.getClassifyName()); @@ -220,10 +217,13 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic cereProductClassify.setClassifyImage(classify.getClassifyImage()); cereProductClassify.setClassifyLevel(IntegerEnum.CLASSIFY_LEVEL_ONE.getCode()); cereProductClassify.setLink(classify.getLink()); - cereProductClassify.setProject(ProjectUtil.DEFAULT_PROJECT); + cereProductClassify.setProject(ContextUtil.getProject()); cereProductClassify.setClassifyHierarchy("-"+classify.getClassifyName()); cereProductClassify.setLangInfoMap(classify.getLangInfoMap()); cereProductClassify.initData(); + if(EmptyUtils.isEmpty(cereProductClassify.getClassifyName())){ + throw new CoBusinessException(CoReturnFormat.CLASSIFY_NAME_NULL); + } if(!EmptyUtils.isLongEmpty(classify.getClassifyId())){ //更新一级类别 cereProductClassify.setUpdateTime(time); @@ -240,7 +240,7 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic for (Map.Entry productClassifyLangInfoEntry : cereProductClassify.getLangInfoMap().entrySet()) { CereProductClassifyLangInfo productClassifyLangInfo = productClassifyLangInfoEntry.getValue(); - productClassifyLangInfo.setClassifyId(classify.getClassifyId()); + productClassifyLangInfo.setClassifyId(cereProductClassify.getClassifyId()); productClassifyLangInfo.setId(null); langInfoList.add(productClassifyLangInfo); } @@ -257,9 +257,6 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic List updateIds, String time, CereProductClassify child,Integer level, List langInfoList) throws CoBusinessException{ - if(EmptyUtils.isEmpty(child.getClassifyName())){ - throw new CoBusinessException(CoReturnFormat.CLASSIFY_NAME_NULL); - } CereProductClassify productClassify=new CereProductClassify(); productClassify.setClassifyId(child.getClassifyId()); productClassify.setClassifyName(child.getClassifyName()); @@ -267,10 +264,13 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic productClassify.setClassifyLevel(level); productClassify.setLink(child.getLink()); productClassify.setClassifyImage(child.getClassifyImage()); - productClassify.setProject(ProjectUtil.DEFAULT_PROJECT); + productClassify.setProject(ContextUtil.getProject()); productClassify.setClassifyHierarchy(parent.getClassifyHierarchy()+"-"+child.getClassifyName()); productClassify.setLangInfoMap(child.getLangInfoMap()); productClassify.initData(); + if(EmptyUtils.isEmpty(productClassify.getClassifyName())){ + throw new CoBusinessException(CoReturnFormat.CLASSIFY_NAME_NULL); + } if(!EmptyUtils.isLongEmpty(child.getClassifyId())){ //更新子级类别 productClassify.setUpdateTime(time); @@ -287,7 +287,7 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic for (Map.Entry productClassifyLangInfoEntry : productClassify.getLangInfoMap().entrySet()) { CereProductClassifyLangInfo productClassifyLangInfo = productClassifyLangInfoEntry.getValue(); - productClassifyLangInfo.setClassifyId(child.getClassifyId()); + productClassifyLangInfo.setClassifyId(productClassify.getClassifyId()); productClassifyLangInfo.setId(null); langInfoList.add(productClassifyLangInfo); } diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java index b80023b..a3e9bce 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java @@ -192,9 +192,23 @@ public class CereShopProductServiceImpl implements CereShopProductService { }else { nameValue.setNeed(IntegerEnum.NO.getCode()); } + Map langInfoMap = new HashMap<>(); + + for (String langKey : a.getLangInfoMap().keySet()) { + CereSkuNameLangInfo skuNameLangInfo = new CereSkuNameLangInfo(); + if(a.getLangInfoMap().containsKey(langKey)){ + skuNameLangInfo.setSkuName(a.getLangInfoMap().get(langKey).getSkuName()); + } + if(value.getLangInfoMap().containsKey(langKey)){ + skuNameLangInfo.setSkuValue(value.getLangInfoMap().get(langKey).getSkuValue()); + } + langInfoMap.put(langKey, skuNameLangInfo); + } + nameValue.setLangInfoMap(langInfoMap); map.put(a.getCode()+"-"+value.getValueCode(),nameValue); }); }); + log.info(new Gson().toJson(map)); //查询当前是否有全部商品且进行中状态的优惠券 List coupons=cereShopCouponService.findAllByShopId(cereShopProduct.getShopId()); if(!EmptyUtils.isEmpty(coupons)){ @@ -1102,7 +1116,8 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereSkuName.setSkuValue(names.get(0).getValues().get(0).getSkuValue()); cereSkuName.setSkuId(cereProductSku.getSkuId()); cereSkuName.setNeed(IntegerEnum.NO.getCode()); - cereSkuNameService.insert(cereSkuName); + cereSkuName.setLangInfoMap(map.values().stream().findFirst().get().getLangInfoMap()); + cereSkuName.initData(ContextUtil.getLanguage()); }else { //多款式 if(!EmptyUtils.isEmpty(sku.getSkuAttrCodeDTOList())){ @@ -1118,6 +1133,10 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereSkuName.setNameCode(a.getCode()); cereSkuName.setValueCode(a.getValueCode()); cereSkuName.setNeed(nameValue.getNeed()); + + cereSkuName.setLangInfoMap(nameValue.getLangInfoMap()); + cereSkuName.initData(ContextUtil.getLanguage()); + return cereSkuName; }else { return null; @@ -1162,6 +1181,8 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereSkuName.setSkuValue(names.get(0).getValues().get(0).getSkuValue()); cereSkuName.setSkuId(cereProductSku.getSkuId()); cereSkuName.setNeed(IntegerEnum.NO.getCode()); + cereSkuName.setLangInfoMap(map.values().stream().findFirst().get().getLangInfoMap()); + cereSkuName.initData(ContextUtil.getLanguage()); cereSkuNameService.insert(cereSkuName); }else { //多款式 @@ -1178,6 +1199,8 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereSkuName.setNameCode(a.getCode()); cereSkuName.setValueCode(a.getValueCode()); cereSkuName.setNeed(nameValue.getNeed()); + cereSkuName.setLangInfoMap(nameValue.getLangInfoMap()); + cereSkuName.initData(ContextUtil.getLanguage()); return cereSkuName; }else { return null;