Bladeren bron

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
Joburgess 4 jaren geleden
bovenliggende
commit
e0ac573ec7

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java

@@ -156,8 +156,16 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
 
     /**
      * 根据id获取商品和分类
+     *
      * @param goodsIds
      * @return
      */
     List<Goods> getGoodiesAndCate(@Param("goodsIds") List<Integer> goodsIds);
+
+    /**
+     * 根据子商品获取所有包含的子商品的父商品(全部状态)
+     *
+     * @return
+     */
+    List<Goods> getGoodsByBaseGoodsId(@Param("goodsId") Integer goodsId);
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentInstrumentDao.java

@@ -47,4 +47,12 @@ public interface StudentInstrumentDao extends BaseDAO<Long, StudentInstrument> {
      * @return
      */
     StudentInstrument getStudentInstrument(@Param("studentId") Integer studentId, @Param("goodsId") Integer goodsId);
+
+    /**
+     * 获取用户已购买乐保的商品的记录
+     *
+     * @param startTime
+     * @return
+     */
+    List<StudentInstrument> getOldStudentInstrument(@Param("startTime") Date startTime, @Param("goodsIds") List<Integer> goodsIds);
 }

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentInstrumentService.java

@@ -72,4 +72,7 @@ public interface StudentInstrumentService extends BaseService<Long, StudentInstr
      */
     StudentInstrument getStudentInstrument(Integer studentId,Integer goodsId);
 
+
+    Boolean addOldStudentInstrument();
+
 }

+ 1 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -999,9 +999,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         Set<Integer> roleIds = new HashSet<>(1);
         roleIds.add(SysUserRole.SECTION_MANAGER);
-        Set<Integer> integers = musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId());
-        integers.add(musicGroup.getEducationalTeacherId());
-        sysMessageService.batchSeoMessage(integers, MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(), musicGroup.getName());
+        sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(), musicGroup.getName());
 
     }
 

+ 42 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dao.GoodsDao;
 import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
 import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
@@ -14,6 +15,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.date.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -53,6 +55,8 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
     private GoodsCategoryService goodsCategoryService;
     @Autowired
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+    @Autowired
+    private GoodsDao goodsDao;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -371,7 +375,43 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
     }
 
     @Override
-    public StudentInstrument getStudentInstrument(Integer studentId,Integer goodsId) {
-        return studentInstrumentDao.getStudentInstrument(studentId,goodsId);
+    public StudentInstrument getStudentInstrument(Integer studentId, Integer goodsId) {
+        return studentInstrumentDao.getStudentInstrument(studentId, goodsId);
+    }
+
+    @Override
+    public Boolean addOldStudentInstrument() {
+        Date startTime = null;
+        Date nowDate = new Date();
+        StudentInstrument studentInstrument = studentInstrumentDao.getStudentInstrument(2094765, 60);
+        if (studentInstrument != null) {
+            startTime = DateUtil.addMinutes(nowDate, -15);
+        }
+        List<Goods> goodies = goodsDao.getGoodsByBaseGoodsId(76);
+        List<Integer> goodsIds = goodies.stream().map(Goods::getId).collect(Collectors.toList());
+        List<StudentInstrument> oldStudentInstruments = studentInstrumentDao.getOldStudentInstrument(startTime,goodsIds);
+        for (StudentInstrument oldStudentInstrument : oldStudentInstruments) {
+            oldStudentInstrument.setChangeOrderId(oldStudentInstrument.getOrderId());
+            if (oldStudentInstrument.getEndTime().compareTo(nowDate) > 0) {
+                oldStudentInstrument.setStatus(1);
+            } else {
+                oldStudentInstrument.setStatus(0);
+            }
+            StudentInstrument has = studentInstrumentDao.getStudentInstrument(oldStudentInstrument.getStudentId(), oldStudentInstrument.getGoodsId());
+            if (has == null) {
+                studentInstrumentDao.insert(oldStudentInstrument);
+                continue;
+            }
+            oldStudentInstrument.setId(has.getId());
+            if (has.getEndTime() == null) {
+                studentInstrumentDao.update(oldStudentInstrument);
+                continue;
+            }
+            if (has.getEndTime().compareTo(oldStudentInstrument.getEndTime()) >= 0) {
+                continue;
+            }
+            studentInstrumentDao.update(oldStudentInstrument);
+        }
+        return true;
     }
 }

+ 6 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -23,7 +23,6 @@ import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.page.NoClassMusicStudentQueryInfo;
-import com.ym.mec.biz.event.source.GroupEventSource;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.im.WebFeignService;
@@ -770,6 +769,12 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public void insertStudent(String studentIds, String oldMusicGroupId, String newMusicGroupId, Map<Integer, List<MusicGroupPaymentCalenderStudentDetail>> collect) {
+        //获取欠费学员列表
+        List<Integer> studentIdList = Arrays.asList(studentIds.split(",")).stream().mapToInt(idStr -> Integer.valueOf(idStr)).boxed().collect(Collectors.toList());
+        List<Integer> noPaymentUserIds = musicGroupPaymentCalenderDetailDao.queryNoPaymentUserIds(newMusicGroupId,studentIdList);
+        if(noPaymentUserIds.size() > 0){
+            throw new BizException("操作失败:有欠费的学员不允许创建缴费");
+        }
         SysUser sysUser1 = sysUserFeignService.queryUserInfo();
         //获取旧乐团学员注册信息
         List<StudentRegistration> studentRegistrations = studentRegistrationDao.queryByUserIdsAndMusicGroupId(studentIds, oldMusicGroupId);

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -428,4 +428,9 @@
             #{goodsId}
         </foreach>
     </select>
+
+    <!-- 根据子商品获取所有包含的子商品的父商品(全部状态)-->
+    <select id="getGoodsByBaseGoodsId" resultMap="Goods">
+        SELECT * FROM goods WHERE FIND_IN_SET(#{goodsId}, complement_goods_id_list_)
+    </select>
 </mapper>

+ 2 - 4
mec-biz/src/main/resources/config/mybatis/StudentAttendanceMapper.xml

@@ -507,10 +507,8 @@
         <include refid="findStudentAttendanceSql"/>
         GROUP BY cssp.id_
         ORDER BY
-        <if test="courseScheduleId != null and orderFlag == 1">
-            <if test="courseScheduleId != null or (search != null and search != '')">
-                status_ DESC,visitFlag,
-            </if>
+        <if test="orderFlag == 1 and search != null and search != ''">
+            status_ DESC,visitFlag,cssp.id_,
         </if>
         CONCAT(cs.class_date_, ' ', cs.start_class_time_) ASC
         <include refid="global.limit"/>

+ 45 - 2
mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml

@@ -164,7 +164,8 @@
    <![CDATA[
         UPDATE student_instrument
         SET status_ = 0
-        WHERE end_time_ <= NOW()
+        WHERE status_ = 1
+          AND end_time_ <= NOW()
         ]]>
     </update>
     <select id="getListByEndTime" resultMap="StudentInstrument">
@@ -183,7 +184,49 @@
     </select>
 
     <select id="getStudentInstrument" resultMap="StudentInstrument">
-        SELECT * FROM student_instrument WHERE student_id_ = #{studentId} AND goods_id_ = #{goodsId} AND del_flag_ = 0
+        SELECT *
+        FROM student_instrument
+        WHERE student_id_ = #{studentId}
+          AND goods_id_ = #{goodsId}
+          AND del_flag_ = 0
+        ORDER BY id_ DESC
+        LIMIT 1
+    </select>
+
+    <select id="getOldStudentInstrument" resultMap="StudentInstrument">
+        SELECT spo.user_id_ student_id_,
+        spo.organ_id_,
+        g.id_ goods_id_,
+        g.goods_category_id_,
+        gc.name_ goods_category_name_,
+        g.name_ goods_name_,
+        g.brand_ goods_brand_,
+        g.specification_,
+        g.image_ goods_img_,
+        spo.create_time_ start_time_,
+        DATE_ADD(spo.create_time_, INTERVAL 1 YEAR) end_time_,
+        spo.id_ order_id_
+        FROM student_payment_order_detail spod
+        LEFT JOIN student_payment_order spo ON spo.id_ = spod.payment_order_id_
+        LEFT JOIN student_payment_order_detail spod2 ON spod2.payment_order_id_ = spo.id_
+        LEFT JOIN goods g ON g.id_ = spod2.goods_id_list_
+        LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
+        WHERE spo.status_ = 'SUCCESS'
+        AND spod2.type_ = 'MUSICAL'
+        AND (
+        <if test="goodsIds != null and goodsIds.size() != 0">
+            spod.goods_id_list_ IN
+            <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
+                #{goodsId}
+            </foreach>
+            OR
+        </if>
+        FIND_IN_SET('76', spod.goods_id_list_)
+        )
+        <if test="startTime != null ">
+            AND spo.pay_time_ >= #{startTime}
+        </if>
+        ORDER BY spo.create_time_ ASC
     </select>
 
 </mapper>

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/TeacherAttendanceMapper.xml

@@ -312,6 +312,9 @@
             <if test="organId != null and organId != ''">
                 AND FIND_IN_SET(cs.organ_id_,#{organId})
             </if>
+            <if test="teacherId != null">
+                AND ta.teacher_id_ = #{teacherId}
+            </if>
             <if test="teacherAttendanceId != null and teacherAttendanceId != ''">
                 AND FIND_IN_SET(ta.id_,#{teacherAttendanceId})
             </if>

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -169,4 +169,8 @@ public interface TaskRemoteService {
 	 */
 	@GetMapping("task/updateGrade")
 	void updateGrade();
+
+	//乐保历史数据处理
+	@GetMapping("task/maintenanceOldDateAdd")
+	void maintenanceOldDateAdd();
 }

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -210,4 +210,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
     public void maintenanceNotice() {
 		logger.info("乐保到期提醒推送失败");
     }
+
+    @Override
+    public void maintenanceOldDateAdd() {
+		logger.info("乐保历史数据处理失败");
+    }
 }

+ 19 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/MaintenanceOldDataAddTask.java

@@ -0,0 +1,19 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MaintenanceOldDataAddTask extends BaseTask {
+
+	@Autowired
+	private TaskRemoteService taskRemoteService;
+
+	@Override
+	public void execute() throws TaskException {
+		taskRemoteService.maintenanceOldDateAdd();
+	}
+}

+ 6 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -354,4 +354,10 @@ public class TaskController extends BaseController {
 	public void updateGrade(){
 		studentService.updateGrade();
 	}
+
+	//乐保历史数据处理
+	@GetMapping("/maintenanceOldDateAdd")
+	public void maintenanceOldDateAdd(){
+		studentInstrumentService.addOldStudentInstrument();
+	}
 }