|
|
@@ -16,6 +16,7 @@ import com.cyksj.model.manage.request.ReqGoodsSkuSpec;
|
|
|
import com.cyksj.model.manage.request.ReqGoodsSpecSingle;
|
|
|
import com.cyksj.model.request.CombinationSkuReq;
|
|
|
import com.cyksj.service.mange.CmsGoodsDonSpecService;
|
|
|
+import com.cyksj.service.translations.BackInfoTranslationsFrontService;
|
|
|
import com.cyksj.service.translations.BackInfoTranslationsService;
|
|
|
import com.fasterxml.jackson.databind.JavaType;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@@ -47,6 +48,8 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
|
|
|
|
|
|
private final BackInfoTranslationsService backInfoTranslationsService;
|
|
|
|
|
|
+ private final BackInfoTranslationsFrontService backInfoTranslationsFrontService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
public void insertOrUpdateSkuSpec(ReqGoodsSkuInsert insert, Boolean isUpdate) throws Exception {
|
|
|
@@ -139,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);
|
|
|
@@ -284,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);
|
|
|
@@ -473,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);
|
|
|
}
|
|
|
@@ -488,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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|