Explorar el Código

Merge branch 'dev'

yangdamao hace 2 años
padre
commit
b8a90e206f

+ 8 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -1422,9 +1422,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                             List<Long> specAttrIds = goodsSpecAttributeService.getIdsByTenant(specIds);
                             if (CollectionUtils.isNotEmpty(specAttrIds)){
                                 goodsSpecAttributeService.deleteByIdsTenant(specAttrIds);
+                                iSysGoodsCopyRecordService.deleteByTenantId(specAttrIds,GoodsCopyEnum.GOODS_SPEC_ATTRIBUTE.getType(),newTenantId);
                                 goodsSpecAttributeRelationService.deleteByTemplateIdTenant(newSpecTemplateId,newTenantId);
                             }
                             goodsSpecService.deleteByIdsTenant(specIds);
+                            iSysGoodsCopyRecordService.deleteByTenantId(specIds,GoodsCopyEnum.GOODS_SPEC.getType(),newTenantId);
                         }
                     }else {
                         //新增
@@ -1453,10 +1455,10 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                                             .eq(GoodsSpecAttribute::getSpecId, oldSpecId));
                             if (CollectionUtils.isNotEmpty(specAttributeList)){
                                 List<GoodsSpecAttribute> collect = specAttributeList.stream().map(attrItem -> {
+                                    attrItem.setOId(attrItem.getSpecAttributeId());
                                     attrItem.setSpecAttributeId(null);
                                     attrItem.setSpecId(item.getSpecId());
                                     attrItem.setTenantId(newTenantId);
-                                    attrItem.setOId(attrItem.getSpecAttributeId());
                                     return attrItem;
                                 }).collect(Collectors.toList());
                                 goodsSpecAttributeService.saveBatch(collect);
@@ -1503,6 +1505,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                 }
             }
 
+            if (CollectionUtils.isNotEmpty(recordList)){
+                //保存记录
+                iSysGoodsCopyRecordService.saveBatch(recordList);
+            }
+
             //规格模板商品重新绑定
             if (CollectionUtils.isNotEmpty(newRelationList)){
                 for (GoodsSpecAttributeRelation relation : newRelationList) {
@@ -1555,10 +1562,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                 goodsSpecAttributeRelationService.saveBatch(newRelationList);
             }
 
-            if (CollectionUtils.isNotEmpty(recordList)){
-                //保存记录
-                iSysGoodsCopyRecordService.saveBatch(recordList);
-            }
             redisCache.deleteObject(key);
         }catch (Exception e){
             //释放

+ 20 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/bo/SysGoodsCopyDelBo.java

@@ -0,0 +1,20 @@
+package com.zhongzheng.modules.system.bo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author yangdamao
+ * @date 2023年01月13日 19:34
+ */
+@Data
+public class SysGoodsCopyDelBo implements Serializable {
+
+    private List<Long> newIds;
+
+    private Integer type;
+
+    private Long tenantId;
+}

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysGoodsCopyRecordMapper.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.system.mapper;
 
 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.system.bo.SysGoodsCopyDelBo;
 import com.zhongzheng.modules.system.domain.SysGoodsCopyRecord;
 import org.apache.ibatis.annotations.Param;
 
@@ -14,4 +15,7 @@ public interface SysGoodsCopyRecordMapper extends BaseMapper<SysGoodsCopyRecord>
 
     @InterceptorIgnore(tenantLine = "true")
     SysGoodsCopyRecord getNewIdByTenant(@Param("oldId") Long oldId, @Param("type") Integer type, @Param("tenantId") Long tenantId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    void deleteByTenantId(SysGoodsCopyDelBo bo);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysGoodsCopyRecordService.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.system.domain.SysGoodsCopyRecord;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 参数配置 服务层
  *
@@ -13,4 +15,7 @@ import org.apache.ibatis.annotations.Param;
 public interface ISysGoodsCopyRecordService extends IService<SysGoodsCopyRecord> {
 
     SysGoodsCopyRecord getNewIdByTenant(Long oldId,Integer type,Long tenantId);
+
+    void deleteByTenantId(List<Long> specAttrIds, Integer type, Long newTenantId);
+
 }

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysGoodsCopyRecordServiceImpl.java

@@ -1,11 +1,14 @@
 package com.zhongzheng.modules.system.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhongzheng.modules.system.bo.SysGoodsCopyDelBo;
 import com.zhongzheng.modules.system.domain.SysGoodsCopyRecord;
 import com.zhongzheng.modules.system.mapper.SysGoodsCopyRecordMapper;
 import com.zhongzheng.modules.system.service.ISysGoodsCopyRecordService;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 参数配置 服务层实现
  *
@@ -18,4 +21,13 @@ public class SysGoodsCopyRecordServiceImpl extends ServiceImpl<SysGoodsCopyRecor
     public SysGoodsCopyRecord getNewIdByTenant(Long oldId, Integer type, Long tenantId) {
        return baseMapper.getNewIdByTenant(oldId, type, tenantId);
     }
+
+    @Override
+    public void deleteByTenantId(List<Long> specAttrIds, Integer type, Long newTenantId) {
+        SysGoodsCopyDelBo bo = new SysGoodsCopyDelBo();
+        bo.setNewIds(specAttrIds);
+        bo.setType(type);
+        bo.setTenantId(newTenantId);
+        baseMapper.deleteByTenantId(bo);
+    }
 }

+ 10 - 0
zhongzheng-system/src/main/resources/mapper/modules/system/SysGoodsCopyRecordMapper.xml

@@ -8,4 +8,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select * from sys_goods_copy_record where old_id = #{oldId} and `type` = #{type} and tenant_id = #{tenantId}
     </select>
 
+    <delete id="deleteByTenantId" parameterType="com.zhongzheng.modules.system.bo.SysGoodsCopyDelBo" >
+        delete from sys_goods_copy_record where `type` = #{type} and tenant_id = #{tenantId}
+        <if test="newIds != null and newIds.size()!=0 ">
+            AND new_id in
+            <foreach collection="newIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </delete>
+
 </mapper>