Browse Source

Merge remote-tracking branch 'origin/saas' into saas

zouxuan 3 years ago
parent
commit
2fe7a97046

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/StudentServeService.java

@@ -33,7 +33,7 @@ public interface StudentServeService {
      * @param studentIds:
      * @return int
      */
-    Map<String, Object> checkeIsAssignHomework(Long courseScheduleId, String studentIds, Integer teacherId);
+    Map<String, Object> checkeIsAssignHomework(Long courseScheduleId, String studentIds, Integer teacherId, Integer tenantId);
 
     /**
      * @describe 获取教师应布置课程编号列表

+ 55 - 63
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrderPayOpsServiceImpl.java

@@ -58,6 +58,8 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 
     //tenant 机构开通、续费付款、 cloudTeacherOrder 团练宝激活支付、tenantRecharge 机构充值
     private static final String[] tenantPlatform = {"tenant", "cloudTeacherOrder", "tenantRecharge"};
+    //校验订单状态
+    private static final BiPredicate<Object, DealStatusEnum> predicate = (o, s) -> Objects.nonNull(o) && !DealStatusEnum.ING.equals(s);
 
     @Override
     public Map<String, Object> executePayment(BigDecimal amount, String orderNo, String payChannel, String returnUrl, String orderSubject, String orderBody, String sign, String code, String platform) throws Exception {
@@ -87,21 +89,47 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
         return payment;
     }
 
-    //platform is null 或者 student
-    private Map<String, Object> student(PaymentParam payParam) throws Exception {
-        Map<String, Object> payment;
-        StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(payParam.getOrderNo());
-        if (Objects.isNull(studentPaymentOrder)) {
+    private void checkSing(PaymentParam param) {
+        Map<String, Object> signParams = new LinkedHashMap<>();
+        signParams.put("appId", ConfigInit.appId);
+        signParams.put("amount", param.getAmount().setScale(2, RoundingMode.HALF_UP));
+        signParams.put("orderNo", param.getOrderNo());
+        signParams.put("orderSubject", param.getOrderSubject());
+        signParams.put("orderBody", param.getOrderBody());
+        signParams.put("wxAppId", ConfigInit.wxAppId);
+        String originalStr = JSONObject.toJSONString(signParams);
+        String newSign = DigestUtils.md5DigestAsHex(originalStr.getBytes());
+        if (!newSign.equals(param.getSign())) {
+            log.info("executePayment >>>>>> checkSing : {}", newSign);
+            throw new BizException("请勿非法请求");
+        }
+    }
+
+    //机构开通、续费付款、 团练宝激活支付、机构充值
+    private Map<String, Object> tenantPlatformOrder(PaymentParam payParam) {
+        //查询订单
+        TenantOrderRecord tenantOrderRecord = tenantOrderRecordService.getOne(new WrapperUtil<TenantOrderRecord>()
+                .hasEq("order_no_", payParam.getOrderNo()).queryWrapper());
+        if (Objects.isNull(tenantOrderRecord)) {
             throw new BizException("订单不存在");
         }
-        payParam.setTenantId(studentPaymentOrder.getTenantId());
-        payment = checkOrderAndGetParam(payParam,
-                studentPaymentOrder,
-                StudentPaymentOrder::getStatus,
-                StudentPaymentOrder::getCreateTime,
-                studentPaymentOrder::setTransNo,
-                studentPaymentOrderService::update
-        );
+        if (tenantOrderRecord.getOrderState() != 0) {
+            throw new BizException("订单已处理!");
+        }
+        //获取支付数据
+        Map<String, Object> payment;
+        payParam.setTenantId(tenantOrderRecord.getTenantId());
+        try {
+            payment = checkOrderAndGetParam(payParam,
+                    tenantOrderRecord,
+                    TenantOrderRecord::getEnumOrderState,
+                    TenantOrderRecord::getCreatedTime,
+                    tenantOrderRecord::setTransNo,
+                    tenantOrderRecordService::updateById
+            );
+        } catch (Exception e) {
+            throw new BizException(e.getMessage());
+        }
         return payment;
     }
 
@@ -127,59 +155,24 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
         return payment;
     }
 
-    //机构开通、续费付款、 团练宝激活支付、机构充值
-    private Map<String, Object> tenantPlatformOrder(PaymentParam payParam) {
-        TenantOrderRecord tenantOrderRecord = getTenantOrderRecord(payParam.getOrderNo());
-        if (tenantOrderRecord.getOrderState() != 0) {
-            throw new BizException("订单已处理!");
-        }
-        return checkOrderGetPayment(payParam, tenantOrderRecord);
-    }
-
-    //查询订单
-    private TenantOrderRecord getTenantOrderRecord(String orderNo) {
-        TenantOrderRecord orderRecord = tenantOrderRecordService.getOne(new WrapperUtil<TenantOrderRecord>()
-                .hasEq("order_no_", orderNo).queryWrapper());
-        if (Objects.isNull(orderRecord)) {
-            throw new BizException("订单不存在");
-        }
-        return orderRecord;
-    }
-
-    //获取支付数据
-    private Map<String, Object> checkOrderGetPayment(PaymentParam payParam, TenantOrderRecord tenantOrderRecord) {
+    //platform is null 或者 student
+    private Map<String, Object> student(PaymentParam payParam) throws Exception {
         Map<String, Object> payment;
-        payParam.setTenantId(tenantOrderRecord.getTenantId());
-        try {
-            payment = checkOrderAndGetParam(payParam,
-                    tenantOrderRecord,
-                    TenantOrderRecord::getEnumOrderState,
-                    TenantOrderRecord::getCreatedTime,
-                    tenantOrderRecord::setTransNo,
-                    tenantOrderRecordService::updateById
-            );
-        } catch (Exception e) {
-            throw new BizException(e.getMessage());
+        StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(payParam.getOrderNo());
+        if (Objects.isNull(studentPaymentOrder)) {
+            throw new BizException("订单不存在");
         }
+        payParam.setTenantId(studentPaymentOrder.getTenantId());
+        payment = checkOrderAndGetParam(payParam,
+                studentPaymentOrder,
+                StudentPaymentOrder::getStatus,
+                StudentPaymentOrder::getCreateTime,
+                studentPaymentOrder::setTransNo,
+                studentPaymentOrderService::update
+        );
         return payment;
     }
 
-    private void checkSing(PaymentParam param) {
-        Map<String, Object> signParams = new LinkedHashMap<>();
-        signParams.put("appId", ConfigInit.appId);
-        signParams.put("amount", param.getAmount().setScale(2, RoundingMode.HALF_UP));
-        signParams.put("orderNo", param.getOrderNo());
-        signParams.put("orderSubject", param.getOrderSubject());
-        signParams.put("orderBody", param.getOrderBody());
-        signParams.put("wxAppId", ConfigInit.wxAppId);
-        String originalStr = JSONObject.toJSONString(signParams);
-        String newSign = DigestUtils.md5DigestAsHex(originalStr.getBytes());
-        if (!newSign.equals(param.getSign())) {
-            log.info("executePayment >>>>>> checkSing : {}", newSign);
-            throw new BizException("请勿非法请求");
-        }
-    }
-
     private <T> Map<String, Object> checkOrderAndGetParam(PaymentParam payParam, T clazz,
                                                           Function<T, DealStatusEnum> enumFunc, Function<T, Date> dateFunc,
                                                           Consumer<String> setOption, Consumer<T> action) throws Exception {
@@ -207,7 +200,6 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
     }
 
     private <T> void checkOrderState(T obj, Function<T, DealStatusEnum> func) {
-        BiPredicate<Object, DealStatusEnum> predicate = (o, s) -> Objects.nonNull(o) && !DealStatusEnum.ING.equals(s);
         DealStatusEnum em = func.apply(obj);
         if (predicate.test(obj, em)) {
             String msg = em.equals(DealStatusEnum.SUCCESS) ? "订单已支付,请勿重复支付" : "订单已关闭,不能支付";
@@ -284,7 +276,7 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
                         .divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP);
 
                 StudentPaymentOrder st = (StudentPaymentOrder) clazz;
-                BigDecimal amount = amountTo.apply(st.getActualAmount()).setScale(2, RoundingMode.HALF_UP);
+                BigDecimal amount = amountTo.apply(st.getActualAmount());
 
                 List<Map<String, Object>> divMemberList = new ArrayList<>();
                 // 实时分账

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCourseHomeworkServiceImpl.java

@@ -277,6 +277,8 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
         	return courseHomeworkStudentDetail;
         }
         
+		courseHomeworkStudentDetail.setMusicGroupTrainPlan(musicGroupTrainPlan);
+        
         SysUser sysUser = teacherDao.getUser(userId.intValue());
         courseHomeworkStudentDetail.setStudentId(userId.intValue());
         courseHomeworkStudentDetail.setStudentName(sysUser.getUsername());

+ 29 - 39
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -902,33 +902,23 @@ public class StudentServeServiceImpl implements StudentServeService {
     }
 
     @Override
-    public Map<String, Object> checkeIsAssignHomework(Long courseScheduleId, String studentIdsStr, Integer teacherId) {
+    public Map<String, Object> checkeIsAssignHomework(Long courseScheduleId, String studentIdsStr, Integer teacherId, Integer tenantId) {
         Map<String, Object> result=new HashMap<>();
-
+        
         Set<Long> teacherServeCourseIds = studentServeService.getTeacherServeCourseIds(teacherId);
         if(teacherServeCourseIds.contains(courseScheduleId)){
-            result.put("enableAssignHomework", 1);
+            result.put("enableAssignHomework", 1);//是否要布置作业
         }else{
             result.put("enableAssignHomework", 0);
         }
 
         if(Objects.isNull(courseScheduleId) && Objects.isNull(studentIdsStr)){
-            result.put("isAssignHomework", 0);
+            result.put("isAssignHomework", 0);//是否有布置作业
             return result;
         }
 
-//        String configValue = sysConfigDao.findConfigValue(SysConfigService.HOMEWORK_OPEN_FLAG);
-//        if(StringUtils.isEmpty(configValue)){
-//            configValue = "0";
-//        }
         List<Integer> studentIds=new ArrayList<>();
         if(StringUtils.isNotBlank(studentIdsStr)){
-//            if(configValue.equals("0")){
-//                result.put("memberNum",0);
-//            }else {
-                //获取有会员的学员数
-//                result.put("memberNum", studentDao.getMemberNum(studentIdsStr));
-//            }
             studentIds= Arrays.asList(studentIdsStr.split(",")).stream().map(id->Integer.valueOf(id)).collect(Collectors.toList());
         }
 
@@ -939,21 +929,8 @@ public class StudentServeServiceImpl implements StudentServeService {
             result.put("courseStudentNum", students.size());
             CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleId);
             if(Objects.isNull(courseSchedule)){
-                result.put("isAssignHomework", 0);
-                return result;
+                throw new BizException("课程[{}]信息查询失败", courseScheduleId);
             }
-//            if(configValue.equals("0")){
-//                result.put("memberNum",0);
-//                result.put("courseViewType", CourseViewTypeEnum.COURSE_FEE);
-//            }else {
-//                MusicGroup musicGroup = musicGroupDao.get(courseSchedule.getMusicGroupId());
-//                if(musicGroup != null){
-//                    result.put("courseViewType", musicGroup.getCourseViewType());
-//                }else if(result.get("memberNum") == null){
-//                    Set<Integer> collect = students.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
-//                    result.put("memberNum", studentDao.getMemberNum(StringUtils.join(collect,",")));
-//                }
-//            }
 
             localDate=LocalDateTime.ofInstant(courseSchedule.getClassDate().toInstant(), DateUtil.zoneId).toLocalDate();
             List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseSchedule(courseScheduleId);
@@ -967,17 +944,30 @@ public class StudentServeServiceImpl implements StudentServeService {
         LocalDate monDayDate = localDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
         LocalDate sunDayDate = localDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
 
-        //课后作业
-        Set<Integer> hss = studentCourseHomeworkDao.checkStudentHaveHomeworkInDateRange(monDayDate.toString(), sunDayDate.toString(), studentIds);
-        //课外训练
-        //Set<Integer> ess = extracurricularExercisesReplyDao.checkStudentHaveExercisesInDateRange(monDayDate.toString(), sunDayDate.toString(), studentIds);
-        for (Integer studentId : studentIds) {
-            if(!hss.contains(studentId)){
-                result.put("isAssignHomework", 0);
-                return result;
-            }
-        }
-        result.put("isAssignHomework", 1);
+		if (tenantId == 1) {
+			// 课后作业
+			Set<Integer> hss = studentCourseHomeworkDao.checkStudentHaveHomeworkInDateRange(monDayDate.toString(), sunDayDate.toString(), studentIds);
+			// 课外训练
+			for (Integer studentId : studentIds) {
+				if (!hss.contains(studentId)) {
+					result.put("isAssignHomework", 0);
+					return result;
+				}
+			}
+			result.put("isAssignHomework", 1);
+		} else {
+			if(courseScheduleId != null){
+				List<Long> courseIds = new ArrayList<Long>();
+				courseIds.add(courseScheduleId);
+				
+				List<StudentCourseHomework> courseHomeworkList = studentCourseHomeworkDao.findByCourses(courseIds);
+				if (courseHomeworkList == null || courseHomeworkList.size() == 0) {
+					result.put("isAssignHomework", 0);// 是否有布置作业
+				} else {
+					result.put("isAssignHomework", 1);// 是否有布置作业
+				}
+			}
+		}
         return result;
     }
 

+ 10 - 17
mec-biz/src/main/resources/config/mybatis/CloudTeacherOrderMapper.xml

@@ -392,15 +392,12 @@
 
     <!-- 查询订单记录 -->
     <select id="findRecordCount" resultType="java.lang.Integer">
-        SELECT count(1) FROM cloud_teacher_order cto
-        LEFT JOIN tenant_order_record tor ON tor.id_ = cto.platform_order_id_
+        SELECT count(1) FROM tenant_order_record tor
+        LEFT JOIN cloud_teacher_order cto ON tor.id_ = cto.platform_order_id_
         LEFT JOIN student s ON cto.student_id_ = s.user_id_
         LEFT JOIN sys_user u ON cto.student_id_ = u.id_
-        LEFT JOIN SUBJECT sj ON s.subject_id_list_ = sj.id_
-        LEFT JOIN student_registration sr ON cto.student_id_ = sr.user_id_
         <where>
-            cto.tenant_id_ = #{tenantId} AND cto.status_ = 2 AND tor.order_no_ is not null AND tor.trans_no_ is not null
-            AND tor.order_type_ = 'CLOUD_TEACHER'
+            cto.tenant_id_ = #{tenantId} AND tor.order_type_ = 'CLOUD_TEACHER' AND tor.order_state_ = 1
             <if test="queryCondition != null and queryCondition != ''">
                 AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
             </if>
@@ -427,33 +424,29 @@
                 WHEN 5 THEN '年' ELSE ''
                 END AS typeName,
             cto.time_ AS time,
-            sj.id_ AS subject,
-            sj.name_ AS subjectName,
             u.tenant_id_ AS tenantId,
             u.username_ AS name,
             u.phone_ AS phone,
             tor.order_no_ as orderNo,
             tor.trans_no_ as transNo,
-            tor.created_time_ as orderTime
-        FROM cloud_teacher_order cto
-        LEFT JOIN tenant_order_record tor ON tor.id_ = cto.platform_order_id_
+            tor.created_time_ as orderTime,
+            cto.pay_amount_ as amount
+        FROM tenant_order_record tor
+        LEFT JOIN cloud_teacher_order cto ON tor.id_ = cto.platform_order_id_
         LEFT JOIN student s ON cto.student_id_ = s.user_id_
         LEFT JOIN sys_user u ON cto.student_id_ = u.id_
-        LEFT JOIN subject sj ON s.subject_id_list_ = sj.id_
-        LEFT JOIN student_registration sr ON cto.student_id_ = sr.user_id_
         <where>
-            cto.tenant_id_ = #{tenantId} AND cto.status_ = 2 AND tor.order_no_ is not null AND tor.trans_no_ is not null
-            AND tor.order_type_ = 'CLOUD_TEACHER'
+            cto.tenant_id_ = #{tenantId} AND tor.order_type_ = 'CLOUD_TEACHER' AND tor.order_state_ = 1
             <if test="queryCondition != null and queryCondition != ''">
                 AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
             </if>
             <if test="orderNo != null and orderNo != ''">
                 AND tor.order_no_ LIKE CONCAT('%', #{orderNo}, '%')
             </if>
-            <if test="startTime != null and startTime != ''">
+            <if test="startTime != null">
                 <![CDATA[ AND tor.created_time_ >= #{startTime} ]]>
             </if>
-            <if test="endTime != null and startTime != ''">
+            <if test="endTime != null">
                 <![CDATA[ AND tor.created_time_ <= #{endTime} ]]>
             </if>
         </where>

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

@@ -643,7 +643,7 @@
             AND mg.status_ = 'PROGRESS'
             AND sr.music_group_status_ = 'NORMAL'
             <if test="studentIds!=null and studentIds.size()>0">
-                AND cssp.user_id_ IN
+                AND sr.user_id_ IN
                 <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
                     #{studentId}
                 </foreach>

+ 1 - 1
mec-student/src/main/java/com/ym/mec/student/config/ResourceServerConfig.java

@@ -47,7 +47,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
                 "/musicGroup/getGradeList",
                 "/studentCompetition/get","/musicGroup/preRegister",
                 "/tenantInfo/queryTenantInfoByOrgan/**",
-                "/subject/list",
+                "/subject/list","/tenantApply/add",
                 "/musicEnlightenmentQuestionnaire/addEnlightenmentQuestionnaire", "/musicEnlightenmentQuestionnaire/getUserMusicEnlightenmentQuestionnaire").permitAll().anyRequest().authenticated().and().httpBasic();
     }
 

+ 1 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherCourseHomeworkReplyController.java

@@ -103,7 +103,7 @@ public class TeacherCourseHomeworkReplyController extends BaseController {
         if(Objects.isNull(user)){
             return failed(HttpStatus.FORBIDDEN,"请登录");
         }
-        return succeed(studentServeService.checkeIsAssignHomework(courseScheduleId, studentIds, user.getId()));
+        return succeed(studentServeService.checkeIsAssignHomework(courseScheduleId, studentIds, user.getId(), user.getTenantId()));
     }
 
 }