|
|
@@ -142,7 +142,13 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
|
|
|
spec.setSpecNumber(specNumber);
|
|
|
spec.setSpecMapping(Jsons.toJson(map));
|
|
|
if (!StrUtil.equals(UserPageLanguage.Language.zh_HK.name(), lang)) {
|
|
|
+ //spec
|
|
|
backInfoTranslationsService.saveOrUpdateBackInfoTranslations(BackInfoTranslations.Type.spec, spec.getId(), spec, lang);
|
|
|
+ //sku
|
|
|
+ List<GoodsDonSku> goodsDonSkus = goodsDonSkuMapper.selectList(Wrappers.lambdaQuery(GoodsDonSku.class)
|
|
|
+ .eq(GoodsDonSku::getGoodsId, goods.getId()));
|
|
|
+ resetSkuSpec(goodsDonSkus, spec);
|
|
|
+ goodsDonSkus.stream().forEach(sku -> backInfoTranslationsService.saveOrUpdateBackInfoTranslations(BackInfoTranslations.Type.sku, sku.getId(), sku, lang));
|
|
|
} else {
|
|
|
if (insert.getId() != null) {
|
|
|
this.updateById(spec);
|
|
|
@@ -287,7 +293,7 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
|
|
|
unifiedHandleCombinationSku(combinations, request.getValues(), specValueMap, nodeIdMap, specIdLists, skus);
|
|
|
} else {
|
|
|
ReqGoodsSkuSpec reqGoodsSkuSpec = reqGoodsSkuSpecs.get(0);
|
|
|
- unifiedHandleCombinationSku(combinations,reqGoodsSkuSpec.getValues(),specValueMap, nodeIdMap,specIdLists,skus);
|
|
|
+ unifiedHandleCombinationSku(combinations, reqGoodsSkuSpec.getValues(), specValueMap, nodeIdMap, specIdLists, skus);
|
|
|
}
|
|
|
reqGoodsSkuInsert.setSkus(skus);
|
|
|
skuAppend(reqGoodsSkuInsert, goodsDon);
|
|
|
@@ -454,10 +460,6 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
|
|
|
List<GoodsDonSku> goodsDonSkus = goodsDonSkuMapper.selectList(Wrappers.lambdaQuery(GoodsDonSku.class)
|
|
|
.eq(GoodsDonSku::getGoodsId, goodsId));
|
|
|
|
|
|
- if (!StrUtil.equals(UserPageLanguage.Language.zh_HK.name(), lang)) {
|
|
|
- backInfoTranslationsFrontService.setSkuBackLanguage(goodsDonSkus, lang);
|
|
|
- }
|
|
|
-
|
|
|
goodsDonSkus.forEach(sku -> {
|
|
|
try {
|
|
|
List<Integer> specIdsList = Jsons.parseList(sku.getSpecIds(), Integer.class);
|
|
|
@@ -480,11 +482,7 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
|
|
|
}
|
|
|
}
|
|
|
if (!StrUtil.equals(UserPageLanguage.Language.zh_HK.name(), lang)) {
|
|
|
- GoodsDonSku specValLanguage = new GoodsDonSku();
|
|
|
- specValLanguage.setId(sku.getId());
|
|
|
- specValLanguage.setSpecVal(sku.getSpecVal());
|
|
|
- specValLanguage.setSpecJson(sku.getSpecJson());
|
|
|
- backInfoTranslationsService.saveOrUpdateBackInfoTranslations(BackInfoTranslations.Type.sku, specValLanguage.getId(), specValLanguage, lang);
|
|
|
+
|
|
|
} else {
|
|
|
goodsDonSkuMapper.updateById(sku);
|
|
|
}
|
|
|
@@ -495,4 +493,40 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //多语言设置sku
|
|
|
+ public void resetSkuSpec(List<GoodsDonSku> skus, GoodsDonSpec loveSpec) throws Exception {
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ List<ReqGoodsSpecSingle> specList = null;
|
|
|
+ JavaType type = Jsons.javaType().constructMapType(HashMap.class, Integer.class, ReqGoodsSpecSingle.class);
|
|
|
+ Map<Integer, ReqGoodsSpecSingle> map = Jsons.parseObject(loveSpec.getSpecMapping(), type);
|
|
|
+ int specNumber = loveSpec.getSpecNumber();
|
|
|
+ for (GoodsDonSku sku : skus) {
|
|
|
+ final String specIds = sku.getSpecIds();
|
|
|
+ if (StringUtils.isBlank(specIds)) {
|
|
|
+ throw new RuntimeException("请选择商品的规格.");
|
|
|
+ }
|
|
|
+ int[] ids = Jsons.parseObject(specIds, int[].class);
|
|
|
+
|
|
|
+ // init
|
|
|
+ builder.delete(0, builder.length());
|
|
|
+ if (null == specList) {
|
|
|
+ specList = new ArrayList<>(specNumber);
|
|
|
+ } else {
|
|
|
+ specList.clear();
|
|
|
+ }
|
|
|
+ for (int id : ids) {
|
|
|
+ ReqGoodsSpecSingle single = map.get(id);
|
|
|
+ if (null == single) {
|
|
|
+ throw new RuntimeException("总规格属性id中 不存在 sku中的id.");
|
|
|
+ }
|
|
|
+ builder.append(single.getName()).append(';');
|
|
|
+ specList.add(single);
|
|
|
+ }
|
|
|
+ String specVal = builder.toString();
|
|
|
+ String specJson = Jsons.toJson(specList);
|
|
|
+ sku.setSpecVal(specVal);
|
|
|
+ sku.setSpecJson(specJson);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|