Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

周箭河 před 5 roky
rodič
revize
89b1ea7d85

+ 14 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CoursesGroupServiceImpl.java

@@ -70,13 +70,11 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
     @Autowired
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     @Autowired
-    private ContractService contractService;
-    @Autowired
-    private TeacherService teacherService;
-    @Autowired
     private ImFeignService imFeignService;
     @Autowired
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+    @Autowired
+    private SysTenantAccountService sysTenantAccountService;
 
     private static final Logger LOGGER = LoggerFactory
             .getLogger(PracticeGroupService.class);
@@ -112,6 +110,10 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
 
         //总课程时长
         Integer totalCourseTime=courseCycleInfo.getCourseCount()*courseCycleInfo.getSingleClassMinutes();
+        SysTenantAccount sysTenantAccount = sysTenantAccountService.get(courseGroup.getTeacherId());
+        if(Objects.isNull(sysTenantAccount)||(sysTenantAccount.getAvailableMinutes()-totalCourseTime)<0){
+            throw new BizException("您的可用课程时长不足");
+        }
 
         Date now=new Date();
         courseGroup.setSingleClassMinutes(courseCycleInfo.getSingleClassMinutes());
@@ -123,7 +125,7 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
             newCourse.setType(CourseSchedule.CourseScheduleType.COMM);
             newCourse.setTeacherId(courseGroup.getTeacherId());
             newCourse.setActualTeacherId(courseGroup.getTeacherId());
-            newCourse.setIsLock(1);
+            newCourse.setIsLock(0);
             newCourse.setStatus(CourseStatusEnum.NOT_START);
             newCourse.setName(courseGroup.getName());
         }
@@ -145,8 +147,7 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
         //创建班级信息
         ClassGroup classGroup = new ClassGroup();
         classGroup.setSubjectIdList(courseGroup.getSubjectId().toString());
-        classGroup.setExpectStudentNum(1);
-        classGroup.setStudentNum(1);
+        classGroup.setExpectStudentNum(courseGroup.getMaxStudentNum());
         classGroup.setName(courseGroup.getName());
         classGroup.setTotalClassTimes(courseCycleInfo.getCourseCount());
         classGroup.setType(ClassGroupTypeEnum.COMM);
@@ -514,6 +515,12 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
         classGroupStudentMapper.setGroupType(GroupType.COMM);
         classGroupStudentMapperDao.insert(classGroupStudentMapper);
 
+        List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findByClassGroup(classGroup.getId());
+        if(!CollectionUtils.isEmpty(classGroupStudents)&&classGroupStudents.size()==classGroup.getExpectStudentNum()){
+            coursesGroup.setStatus(GroupStatusEnum.NORMAL);
+            coursesGroupDao.update(coursesGroup);
+        }
+
         List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
         List<CourseSchedule> groupNotStartCourses = courseScheduleDao.findGroupNotStartCourses(order.getMusicGroupId(), GroupType.COMM);
         if(CollectionUtils.isEmpty(groupNotStartCourses)){

+ 3 - 2
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -435,8 +435,8 @@
         </where>
     </select>
     <select id="findGroupStudents" resultMap="ClassGroupStudentMapper">
-        SELECT * FROM class_group_student_mapper
-        WHERE
+        SELECT * FROM class_group_student_mapper cgsm
+        <where>
             <if test="groupType!=null">
                 AND cgsm.group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
@@ -449,5 +449,6 @@
             <if test="status!=null">
                 AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
+        </where>
     </select>
 </mapper>

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

@@ -187,7 +187,7 @@
 			LEFT JOIN course_schedule cs ON ch.course_schedule_id_=cs.id_
 			LEFT JOIN course_schedule_teacher_salary csts ON ch.course_schedule_id_=csts.course_schedule_id_
 			LEFT JOIN class_group cg ON ch.class_group_id_=cg.id_
-			LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
+			LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_ AND cs.group_type_='MUSIC'
 			WHERE
 			(cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
 			AND csts.user_id_=#{userId}

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

@@ -231,7 +231,7 @@
 
     <select id="findByRole" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
         SELECT
-          su.id_ userId,
+          DISTINCT su.id_ userId,
           su.real_name_ userName,
           su.avatar_ avatar
         FROM
@@ -246,7 +246,7 @@
     </select>
     <select id="findByIds" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
         SELECT su.id_ userId,su.real_name_ userName
-        FROM sys_user
+        FROM sys_user su
         WHERE id_ IN
         <foreach collection="userIds" item="userId" separator="," open="(" close=")">
             #{userId}

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

@@ -116,8 +116,8 @@
         </selectKey>
         -->
         INSERT INTO practice_group
-        (id_,name_,subject_id_,user_id_,student_id_,single_class_minutes_,organ_id_,courses_start_date_,courses_expire_date_,create_time_,update_time_,memo_,buy_months_,drill_times_on_week_,drill_times_json_,group_status_,be_renew_group_id_)
-        VALUES(#{id},#{name},#{subjectId},#{userId},#{studentId},#{singleClassMinutes},#{organId},#{coursesStartDate},#{coursesExpireDate},NOW(),NOW(),#{memo},#{buyMonths},#{drillTimesOnWeek},#{drillTimesJson},#{groupStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{beRenewGroupId})
+        (id_,name_,subject_id_,user_id_,student_id_,single_class_minutes_,organ_id_,courses_start_date_,courses_expire_date_,create_time_,update_time_,memo_,buy_months_,drill_times_on_week_,drill_times_json_,group_status_,be_renew_group_id_,educational_teacher_id_)
+        VALUES(#{id},#{name},#{subjectId},#{userId},#{studentId},#{singleClassMinutes},#{organId},#{coursesStartDate},#{coursesExpireDate},NOW(),NOW(),#{memo},#{buyMonths},#{drillTimesOnWeek},#{drillTimesJson},#{groupStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{beRenewGroupId},#{educationalTeacherId})
     </insert>
 
     <select id="getUserFreePracticeGroup" resultMap="PracticeGroup">

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

@@ -253,7 +253,7 @@
             <if test="studentId!=null">
                 AND cssp.user_id_ = #{studentId}
             </if>
-            <if test="courseStatus != null">
+            <if test="courseStatus != null and courseStatus != ''">
                 AND cs.status_ = #{courseStatus}
             </if>
             <if test="classGroupType!=null">

+ 43 - 0
mec-student/src/main/java/com/ym/mec/student/controller/CourseGroupController.java

@@ -0,0 +1,43 @@
+package com.ym.mec.student.controller;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.service.CoursesGroupService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Objects;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/3/8
+ */
+@Api(tags = "对外课程组服务")
+@RequestMapping("courseGroup")
+@RestController
+public class CourseGroupController extends BaseController {
+
+    @Autowired
+    private CoursesGroupService coursesGroupService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+
+    @ApiOperation(value = "购买课程组")
+    @PostMapping("/buyCourseGroup")
+    public HttpResponseResult buyCourseGroup(Long courseGroupId, boolean isUseBalancePayment){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(Objects.isNull(sysUser)){
+            return failed(HttpStatus.FORBIDDEN,"请登录");
+        }
+        return coursesGroupService.buyCourseGroup(sysUser.getId(), courseGroupId, isUseBalancePayment);
+    }
+
+}

+ 1 - 1
mec-student/src/main/resources/bootstrap-test.properties

@@ -1,7 +1,7 @@
 #\u6307\u5b9a\u5f00\u53d1\u73af\u5883
 #spring.profiles.active=dev
 #\u670d\u52a1\u5668\u5730\u5740
-spring.cloud.nacos.config.server-addr=47.96.85.100:8848
+spring.cloud.nacos.config.server-addr=47.99.212.176:8848
 #\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
 spring.cloud.nacos.config.namespace=02105743-16b8-46ab-87df-2aca0f3dbca3
 #\u6307\u5b9a\u914d\u7f6e\u7fa4\u7ec4 --\u5982\u679c\u662fPublic\u547d\u540d\u7a7a\u95f4 \u5219\u53ef\u4ee5\u7701\u7565\u7fa4\u7ec4\u914d\u7f6e