he2802 2 tahun lalu
induk
melakukan
983c35e44f

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -1546,6 +1546,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                     //规格属性IDS
                     if (StringUtils.isNotBlank(relation.getSpecAttributeIds())){
                         List<Long> ids = Arrays.asList(relation.getSpecAttributeIds().split(",")).stream().map(x -> Long.valueOf(x)).collect(Collectors.toList());
+                        log.info("规格属性ids:"+JSONArray.toJSONString(ids));
                         List<GoodsSpecAttribute> specAttributeList = goodsSpecAttributeService.listByIds(ids);
                         if (CollectionUtils.isNotEmpty(specAttributeList)){
                             List<Long> newIds = new ArrayList<>();
@@ -1554,6 +1555,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
 //                            GoodsSpecAttribute newSpecAttribute = goodsSpecAttributeService.getSpecAttrByTenant(item.getName(),item.getCreateTime(),newTenantId);
                                 if (ObjectUtils.isNotNull(newId)){
                                     newIds.add(newId);
+                                }else {
+                                    GoodsSpecAttribute newSpecAttribute = goodsSpecAttributeService.getSpecAttrByTenant(item.getName(),item.getCreateTime(),newTenantId);
+                                    if (ObjectUtils.isNotNull(newSpecAttribute)){
+                                        newIds.add(newSpecAttribute.getSpecAttributeId());
+                                    }
                                 }
                             });
                             if (CollectionUtils.isNotEmpty(newIds)){
@@ -1565,6 +1571,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
 
                 goodsSpecAttributeRelationService.saveBatch(newRelationList);
             }
+            log.info("商品复制完成");
 
             redisCache.deleteObject(key);
         }catch (Exception e){