Browse Source

Merge branch 'dev'

yangdamao 2 years ago
parent
commit
0166915591

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/mapper/GoodsCourseTeacherMapper.java

@@ -1,9 +1,11 @@
 package com.zhongzheng.modules.goods.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.goods.bo.GoodsCourseTeacherQueryBo;
 import com.zhongzheng.modules.goods.domain.GoodsCourseTeacher;
 import com.zhongzheng.modules.goods.vo.GoodsCourseTeacherVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -15,4 +17,7 @@ import java.util.List;
  */
 public interface GoodsCourseTeacherMapper extends BaseMapper<GoodsCourseTeacher> {
    List<GoodsCourseTeacherVo> getList(GoodsCourseTeacherQueryBo bo);
+
+   @InterceptorIgnore(tenantLine = "true")
+   void deleteByIdTeanant(@Param("newGoodsId") Long newGoodsId,@Param("newTenantId") Long newTenantId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsCourseTeacherService.java

@@ -49,4 +49,6 @@ public interface IGoodsCourseTeacherService extends IService<GoodsCourseTeacher>
 	 * @return
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+	void deleteByIdTeanant(Long newGoodsId, Long newTenantId);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsCourseTeacherServiceImpl.java

@@ -139,4 +139,9 @@ public class GoodsCourseTeacherServiceImpl extends ServiceImpl<GoodsCourseTeache
         }
         return this.removeByIds(ids);
     }
+
+    @Override
+    public void deleteByIdTeanant(Long newGoodsId, Long newTenantId) {
+        baseMapper.deleteByIdTeanant(newGoodsId, newTenantId);
+    }
 }

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

@@ -42,6 +42,8 @@ import com.zhongzheng.modules.goods.service.*;
 import com.zhongzheng.modules.goods.vo.*;
 import com.zhongzheng.modules.grade.vo.ClassGradeVo;
 import com.zhongzheng.modules.grade.vo.SyncGoodsExport;
+import com.zhongzheng.modules.inform.domain.InformRemind;
+import com.zhongzheng.modules.inform.service.IInformRemindService;
 import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.pay.domain.PayServe;
@@ -239,6 +241,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     @Autowired
     private IPayServeService iPayServeService;
 
+    @Autowired
+    private IInformRemindService iInformRemindService;
+
     @Autowired
     private ISysGoodsCopyRecordService iGoodsCopyRecordService;
 
@@ -1484,6 +1489,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                 //商品课程
                 List<CourseMenuExam> newCourseMenuExamList = new ArrayList<>();
                 disposeGoodsCourse(oldGoodsId,newGoodsId,newTenantId,newCourseMenuExamList,recordList);
+                //课程双师
+                disposeGoodsCourseTeacher(oldGoodsId,newGoodsId,newTenantId);
                 //商品试卷
                 disposeGoodsAttached(oldGoodsId,newGoodsId,newTenantId,recordList);
 
@@ -1561,6 +1568,31 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return true;
     }
 
+    private void disposeGoodsCourseTeacher(Long oldGoodsId, Long newGoodsId, Long newTenantId) {
+        //双师关联
+        goodsCourseTeacherService.deleteByIdTeanant(newGoodsId,newTenantId);
+        List<GoodsCourseTeacher> list = goodsCourseTeacherService
+                .list(new LambdaQueryWrapper<GoodsCourseTeacher>()
+                .eq(GoodsCourseTeacher::getGoodsId, oldGoodsId));
+        if (CollectionUtils.isNotEmpty(list)){
+            for (GoodsCourseTeacher teacher : list) {
+                teacher.setId(null);
+                teacher.setTenantId(newTenantId);
+                teacher.setGoodsId(newGoodsId);
+                if (StringUtils.isNotBlank(teacher.getCourseIds())){
+                    String ids = Arrays.asList(teacher.getCourseIds().split(",")).stream().map(x -> {
+                        Long oid = Long.valueOf(x);
+                        Long newId = getNewId(oid, GoodsCopyEnum.COURSE.getType());
+                        return ObjectUtils.isNotNull(newId)?newId.toString() : "";
+                    }).collect(Collectors.joining(","));
+                    teacher.setCourseIds(ids);
+                }
+            }
+            goodsCourseTeacherService.saveBatch(list);
+        }
+
+    }
+
     private void addSysGoodsRecord(Long oldId,Long newId,Integer type,Long newTenantId,List<SysGoodsCopyRecord> array){
         SysGoodsCopyRecord record = new SysGoodsCopyRecord();
         record.setOldId(oldId);
@@ -3219,6 +3251,17 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
             });
         }
 
+        //通知规则
+        List<InformRemind> informRemindList = iInformRemindService.list();
+        if (CollectionUtils.isNotEmpty(informRemindList)){
+            List<InformRemind> newInformRemind = informRemindList.stream().map(x -> {
+                InformRemind informRemind = BeanUtil.toBean(x, InformRemind.class);
+                informRemind.setId(null);
+                informRemind.setTenantId(newTenantId);
+                return informRemind;
+            }).collect(Collectors.toList());
+            iInformRemindService.saveBatch(newInformRemind);
+        }
         //保存记录
         iSysGoodsCopyRecordService.saveBatch(copyRecordList);
         return true;

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/inform/domain/InformRemind.java

@@ -50,4 +50,6 @@ private static final long serialVersionUID=1L;
     private Integer gzhTpStatus;
     /** 1学员 2教务 */
     private Integer userType;
+
+    private Long tenantId;
 }

+ 4 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsCourseTeacherMapper.xml

@@ -61,4 +61,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             gct.goods_id =  #{goodsId}
         and gct.status = 1
     </select>
+
+    <delete id="deleteByIdTeanant" parameterType="map">
+       delete from goods_course_teacher where goods_id = #{newGoodsId} and tenant_id = #{newTenantId}
+    </delete>
 </mapper>

+ 2 - 3
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml

@@ -707,7 +707,7 @@
             WHERE
                 gc.goods_id = #{goodsId}
               AND cm.type = 1
-              AND cm.`status` = 1 UNION ALL
+              UNION ALL
             SELECT
                 gc.goods_id,
                 gc.sort AS gcSort,
@@ -728,7 +728,7 @@
             WHERE
                 gc.goods_id = #{goodsId}
               AND cm.type = 2
-              AND cm.`status` = 1 UNION ALL
+              UNION ALL
             SELECT
                 gc.goods_id,
                 gc.sort AS gcSort,
@@ -748,7 +748,6 @@
             WHERE
                 gc.goods_id = #{goodsId}
               AND cm.type = 3
-              AND cm.`status` = 1
         ) a
     ORDER BY
         a.gcSort,