Browse Source

1、陪练课调整
2、付费陪练课可预约时间调整

Joburgess 5 years ago
parent
commit
55e3273095

+ 10 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleEvaluateDao.java

@@ -1,13 +1,10 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.dto.PracticeGroupsDto;
-import com.ym.mec.biz.dal.entity.ClassGroup;
 import com.ym.mec.biz.dal.entity.CourseScheduleEvaluate;
-import com.ym.mec.biz.dal.entity.TeacherCourseStatistics;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
-import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -26,4 +23,13 @@ public interface CourseScheduleEvaluateDao extends BaseDAO<Long, CourseScheduleE
     List<PracticeGroupsDto> getOrganPracticeGroups();
 
     List<PracticeGroupsDto> getOrganMoney();
-}
+
+    /**
+     * @describe 推送指定时间及之前的未推送的报告
+     * @author Joburgess
+     * @date 2020/2/28
+     * @param expiredDate:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseScheduleEvaluate>
+     */
+    List<CourseScheduleEvaluate> findExpiredDateBeforeReport(@Param("expiredDate")Date expiredDate);
+}

+ 11 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseScheduleEvaluate.java

@@ -43,6 +43,16 @@ public class CourseScheduleEvaluate {
     @ApiModelProperty(value = "总分钟数")
     private Integer totalMinutes;
 
+    private Integer isPushed;
+
+    public Integer getIsPushed() {
+        return isPushed;
+    }
+
+    public void setIsPushed(Integer isPushed) {
+        this.isPushed = isPushed;
+    }
+
     public Long getId() {
         return id;
     }
@@ -154,4 +164,4 @@ public class CourseScheduleEvaluate {
     public void setTotalMinutes(Integer totalMinutes) {
         this.totalMinutes = totalMinutes;
     }
-}
+}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java

@@ -242,4 +242,14 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
 	 * @return void
 	 */
 	HttpResponseResult cancelWaitPayOrder(Integer userId, Integer groupId);
+
+	/**
+	 * @describe 推送练习报告
+	 * @author Joburgess
+	 * @date 2020/2/28
+	 * @param expiredDate: 报告的截至时间
+	 * @param pushType: 推送类型:JIGUANG、SMS、ALL
+	 * @return void
+	 */
+	void pushStudyReport(Date expiredDate,String pushType);
 }

+ 56 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -25,6 +25,7 @@ import com.ym.mec.im.ImFeignService;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+import com.ym.mec.util.http.HttpUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -115,6 +116,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     private ContractService contractService;
     @Autowired
     private PracticeLessonApplyDao practiceLessonApplyDao;
+    @Autowired
+    private CourseScheduleEvaluateDao courseScheduleEvaluateDao;
 
     private static Map<Integer, Map<Integer, List<Integer>>> schoolSubjectTeachersMap;
 
@@ -3250,8 +3253,14 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             return BaseController.failed(HttpStatus.FAILED_DEPENDENCY, "该课程组已失效,请重新购买");
         }
 
+        String orderNo=idGeneratorService.generatorId("payment") + "";
+
+        newOrder.setOrderNo(orderNo);
         newOrder.setActualAmount(newOrder.getExpectAmount());
+        newOrder.setMerNos(null);
         newOrder.setBalancePaymentAmount(new BigDecimal(0));
+        newOrder.setComAmount(null);
+        newOrder.setPerAmount(null);
         newOrder.setStatus(DealStatusEnum.ING);
         newOrder.setVersion(0);
         studentPaymentOrderService.insert(newOrder);
@@ -3290,7 +3299,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             }
         }
 
-        String orderNo=idGeneratorService.generatorId("payment") + "";
         String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
         Map<String, BigDecimal> classFee = new HashMap<>();
         classFee.put("course",newOrder.getActualAmount());
@@ -3312,7 +3320,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
             Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
             newOrder.setStatus(DealStatusEnum.ING);
-            newOrder.setOrderNo(orderNo);
             newOrder.setOrganId(practiceGroup.getOrganId());
             newOrder.setComAmount(routingFee.get("COM"));
             newOrder.setPerAmount(routingFee.get("PER"));
@@ -3371,4 +3378,51 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         }
         return BaseController.succeed();
     }
+
+    @Override
+    public void pushStudyReport(Date expiredDate, String pushType) {
+        if(Objects.isNull(expiredDate)){
+            throw new BizException("请指定推送报告的截至日期");
+        }
+
+        if(StringUtils.isBlank(pushType)){
+            throw new BizException("请指定推送类型:JIGUANG、SMS、ALL");
+        }
+
+        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+
+        List<CourseScheduleEvaluate> reports = courseScheduleEvaluateDao.findExpiredDateBeforeReport(expiredDate);
+
+        for (CourseScheduleEvaluate report : reports) {
+            PracticeGroup userFreePracticeGroup = practiceGroupDao.get(report.getId());
+            ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(userFreePracticeGroup.getId().toString(), GroupType.PRACTICE.getCode());
+
+            CourseScheduleEvaluate courseScheduleEvaluate = courseScheduleEvaluateDao.findByClassGroupId(classGroup.getId());
+            if(Objects.isNull(courseScheduleEvaluate)){
+                throw new BizException("未生成课程报告");
+            }
+
+            String pushUrl = baseApiUrl + "/#/reportDetail?classGroupId=" + classGroup.getId();
+
+            String smsUrl = baseApiUrl + "/#/transfer?url=http://mstudev.dayaedu.com&hash=reportDetail&classGroupId=" + classGroup.getId();
+
+            SysUser student = sysUserFeignService.queryUserById(userFreePracticeGroup.getStudentId());
+
+            if(pushType.equals("ALL")||pushType.equals("JIGUANG")){
+                Map<Integer, String> userMap = new HashMap<>();
+                userMap.put(userFreePracticeGroup.getStudentId(), userFreePracticeGroup.getStudentId().toString());
+                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PRACTICE_COMPLETED_STUDY_REPORT,
+                        userMap, null, 0, "5?" + pushUrl, "STUDENT", pushUrl);
+            }
+
+            if(pushType.equals("ALL")||pushType.equals("SMS")){
+                Map<Integer, String> userPhoneMap = new HashMap<>();
+                userPhoneMap.put(userFreePracticeGroup.getStudentId(), student.getPhone());
+                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.YIMEI, MessageTypeEnum.PRACTICE_COMPLETED_STUDY_REPORT,
+                        userPhoneMap, null, 0, null, "STUDENT", HttpUtil.getSortUrl(smsUrl));
+            }
+            report.setIsPushed(1);
+            courseScheduleEvaluateDao.update(report);
+        }
+    }
 }

+ 11 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleEvaluateMapper.xml

@@ -12,6 +12,7 @@
         <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
         <result column="student_id_" jdbcType="INTEGER" property="studentId"/>
         <result column="subject_name_" jdbcType="VARCHAR" property="subjectName"/>
+        <result column="is_pushed_" jdbcType="INTEGER" property="isPushed"/>
     </resultMap>
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate" useGeneratedKeys="true"
             keyColumn="id" keyProperty="id">
@@ -23,6 +24,10 @@
                 #{createTime,jdbcType=TIMESTAMP})
     </insert>
 
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate">
+        update course_schedule_evaluate set is_pushed_=#{isPushed} where id_=#{id}
+    </update>
+
     <select id="findByClassGroupId" resultMap="CourseScheduleEvaluate">
         SELECT cse.*, s.name_ subject_name_, pg.student_id_
         FROM course_schedule_evaluate cse
@@ -98,4 +103,9 @@
         WHERE group_type_='PRACTICE' AND status_='SUCCESS'
         GROUP BY organ_id_
     </select>
-</mapper>
+    <select id="findExpiredDateBeforeReport" resultMap="CourseScheduleEvaluate">
+      SELECT * FROM course_schedule_evaluate
+      WHERE DATE_FORMATE(create_time_, '%Y-%m-%d') &lt;= DATE_FORMATE(#{expiredDate}, '%Y-%m-%d')
+      AND (is_pushed_ = 0 OR is_pushed_ IS NULL)
+    </select>
+</mapper>

+ 11 - 0
mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java

@@ -248,6 +248,17 @@ public class PracticeGroupController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation("陪练课完成报告推送")
+    @GetMapping(value = "/pushStudyReport")
+    public HttpResponseResult pushStudyReport(Date expiredDate, String pushType){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        practiceGroupService.pushStudyReport(expiredDate,pushType);
+        return succeed();
+    }
+
     @ApiOperation("检测用户是否存在待支付的课程组订单")
     @GetMapping(value = "/checkExistWaitPayOrder")
     public HttpResponseResult checkExistWaitPayOrder(){