Explorar el Código

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan hace 5 años
padre
commit
198df84f0e

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/PracticeGroupDao.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.PracticeCourseDto;
 import com.ym.mec.biz.dal.dto.PracticeGroupDto;
 import com.ym.mec.biz.dal.entity.PracticeGroup;
 import org.apache.ibatis.annotations.Param;
@@ -68,4 +69,13 @@ public interface PracticeGroupDao extends com.ym.mec.common.dal.BaseDAO<Long, Pr
      * @return com.ym.mec.biz.dal.entity.PracticeGroup
      */
     PracticeGroup findUserLatestPracticeGroup(@Param("userId") Integer userId);
+
+    /**
+     * @describe 获取用户购买的陪练课
+     * @author Joburgess
+     * @date 2020/2/18
+     * @param userId: 用户编号
+     * @return java.util.List<com.ym.mec.biz.dal.dto.PracticeCourseDto>
+     */
+    List<PracticeCourseDto> findUserBuyPracticeGroups(@Param("userId") Integer userId);
 }

+ 40 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeCourseDto.java

@@ -0,0 +1,40 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.PracticeGroup;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/2/18
+ */
+public class PracticeCourseDto extends PracticeGroup {
+
+    private String teacherName;
+
+    private String avatar;
+
+    private String subjectName;
+
+    public String getTeacherName() {
+        return teacherName;
+    }
+
+    public void setTeacherName(String teacherName) {
+        this.teacherName = teacherName;
+    }
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+}

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

@@ -1,9 +1,6 @@
 package com.ym.mec.biz.service;
 
-import com.ym.mec.biz.dal.dto.CourseScheduleDto;
-import com.ym.mec.biz.dal.dto.PracticeGroupBuyDto;
-import com.ym.mec.biz.dal.dto.PracticeGroupDto;
-import com.ym.mec.biz.dal.dto.SimpleUserDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.PracticeGroup;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
@@ -181,4 +178,13 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
      * @return void
      */
 	void orderCallback(StudentPaymentOrder order);
+
+	/**
+	 * @describe 获取用户历史购买的陪练课
+	 * @author Joburgess
+	 * @date 2020/2/18
+	 * @param userId:
+	 * @return java.util.List<com.ym.mec.biz.dal.dto.PracticeCourseDto>
+	 */
+	List<PracticeCourseDto> findUserHistoryBuyPracticeGroups(Integer userId);
 }

+ 30 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -853,37 +853,37 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             if (Objects.nonNull(teacherFreeTime.getHoliday())) {
                 holiday = DateUtil.normalWeekNumCalendarWeekNumMap.get(teacherFreeTime.getHoliday());
             }
-            if(Objects.nonNull(teacherFreeTime.getMonday())){
+            if(StringUtils.isNotBlank(teacherFreeTime.getMonday())){
                 teacherFreeTimes.put(String.valueOf(Calendar.MONDAY), JSON.parseArray(teacherFreeTime.getMonday()));
             }else{
                 disableApplyWeekDay.add(Calendar.MONDAY);
             }
-            if(Objects.nonNull(teacherFreeTime.getTuesday())){
+            if(StringUtils.isNotBlank(teacherFreeTime.getTuesday())){
                 teacherFreeTimes.put(String.valueOf(Calendar.TUESDAY), JSON.parseArray(teacherFreeTime.getTuesday()));
             }else{
                 disableApplyWeekDay.add(Calendar.TUESDAY);
             }
-            if(Objects.nonNull(teacherFreeTime.getWednesday())){
+            if(StringUtils.isNotBlank(teacherFreeTime.getWednesday())){
                 teacherFreeTimes.put(String.valueOf(Calendar.WEDNESDAY), JSON.parseArray(teacherFreeTime.getWednesday()));
             }else{
                 disableApplyWeekDay.add(Calendar.WEDNESDAY);
             }
-            if(Objects.nonNull(teacherFreeTime.getThursday())){
+            if(StringUtils.isNotBlank(teacherFreeTime.getThursday())){
                 teacherFreeTimes.put(String.valueOf(Calendar.THURSDAY), JSON.parseArray(teacherFreeTime.getThursday()));
             }else{
                 disableApplyWeekDay.add(Calendar.THURSDAY);
             }
-            if(Objects.nonNull(teacherFreeTime.getFriday())){
+            if(StringUtils.isNotBlank(teacherFreeTime.getFriday())){
                 teacherFreeTimes.put(String.valueOf(Calendar.FRIDAY), JSON.parseArray(teacherFreeTime.getFriday()));
             }else{
                 disableApplyWeekDay.add(Calendar.FRIDAY);
             }
-            if(Objects.nonNull(teacherFreeTime.getSaturday())){
+            if(StringUtils.isNotBlank(teacherFreeTime.getSaturday())){
                 teacherFreeTimes.put(String.valueOf(Calendar.SATURDAY), JSON.parseArray(teacherFreeTime.getSaturday()));
             }else{
                 disableApplyWeekDay.add(Calendar.SATURDAY);
             }
-            if(Objects.nonNull(teacherFreeTime.getSunday())){
+            if(StringUtils.isNotBlank(teacherFreeTime.getSunday())){
                 teacherFreeTimes.put(String.valueOf(Calendar.SUNDAY), JSON.parseArray(teacherFreeTime.getSunday()));
             }else{
                 disableApplyWeekDay.add(Calendar.SUNDAY);
@@ -1126,7 +1126,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             calendar.setTime(enableApplyDate);
 
             int dayOfWeek=calendar.get(Calendar.DAY_OF_WEEK);
-            if(disableApplyWeekDay.contains(disableApplyWeekDay)){
+            if(disableApplyWeekDay.contains(dayOfWeek)){
                 continue;
             }
             JSONArray teacherWeekDayFreeTimes = teacherFreeTimes.getJSONArray(String.valueOf(dayOfWeek));
@@ -2817,4 +2817,26 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
         sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
     }
+
+    @Override
+    public List<PracticeCourseDto> findUserHistoryBuyPracticeGroups(Integer userId) {
+        List<PracticeCourseDto> userPracticeGroups = practiceGroupDao.findUserBuyPracticeGroups(userId);
+        SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
+        Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
+        for (PracticeCourseDto userPracticeGroup : userPracticeGroups) {
+            JSONArray coursesArry=new JSONArray();
+            JSONObject courseJson=JSON.parseObject(userPracticeGroup.getDrillTimesJson());
+            for (String weekNumStr : courseJson.keySet()) {
+                JSONObject newCourseJson=new JSONObject();
+                newCourseJson.put("weekName",DateUtil.weekNumNormalWeekNameMap.get(Integer.parseInt(weekNumStr)));
+                LocalTime courseStartTime=LocalTime.parse(courseJson.getString(weekNumStr),DateUtil.timeFormatter);
+                LocalTime courseEndTime=courseStartTime.plusMinutes(practiceCourseMinutes);
+                newCourseJson.put("startTime",courseStartTime.format(DateUtil.timeFormatter));
+                newCourseJson.put("endTime",courseEndTime.format(DateUtil.timeFormatter));
+                coursesArry.add(newCourseJson);
+            }
+            userPracticeGroup.setDrillTimesJson(coursesArry.toJSONString());
+        }
+        return userPracticeGroups;
+    }
 }

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

@@ -24,6 +24,12 @@
 		<result column="drill_times_json_" property="drillTimesJson" />
 	</resultMap>
 
+	<resultMap id="PracticeCourseDto" type="com.ym.mec.biz.dal.dto.PracticeCourseDto" extends="PracticeGroup">
+		<result property="teacherName" column="real_name_"/>
+		<result property="avatar" column="avatar_"/>
+		<result property="subjectName" column="subject_name_"/>
+	</resultMap>
+
 	<resultMap type="com.ym.mec.biz.dal.dto.PracticeGroupDto" id="PracticeGroupDto">
 		<result column="id_" property="id" />
 		<result column="name_" property="name" />
@@ -102,10 +108,24 @@
 	</select>
 
     <select id="findUserLatestPracticeGroup" resultMap="PracticeGroup">
-		SELECT * FROM practice_group WHERE student_id_=#{userId} ORDER BY create_time_ DESC LIMIT 1;
+		SELECT * FROM practice_group WHERE student_id_=#{userId} AND buy_months_ IS NOT NULL ORDER BY create_time_ DESC LIMIT 1;
+	</select>
+
+	<select id="findUserBuyPracticeGroups" resultMap="PracticeCourseDto">
+		SELECT
+			pg.*,
+			su.real_name_,
+			su.avatar_,
+			s.name_ subject_name_
+		FROM
+			practice_group pg
+			LEFT JOIN sys_user su ON pg.user_id_ = su.id_
+			LEFT JOIN `subject` s ON pg.subject_id_ = s.id_
+		WHERE
+			student_id_=#{userId}
 	</select>
 
-    <sql id="practiceGroupQueryCondition">
+	<sql id="practiceGroupQueryCondition">
 		<where>
 			<if test="search!=null and search!=''">
 				AND (pg.name_ LIKE CONCAT('%',#{search},'%') OR pg.id_= #{search})

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

@@ -146,7 +146,17 @@ public class PracticeGroupController extends BaseController {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
         practiceGroupBuyParams.setStudentId(sysUser.getId());
-        return succeed(practiceGroupService.findUserLatestPracticeGroup(sysUser.getId()));
+        return succeed(practiceGroupService.buyPracticeGroup(practiceGroupBuyParams));
+    }
+
+    @ApiOperation("获取用户历史购买的陪练课")
+    @GetMapping(value = "/findUserHistoryBuyPracticeGroups")
+    public HttpResponseResult findUserHistoryBuyPracticeGroups(){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        return succeed(practiceGroupService.findUserHistoryBuyPracticeGroups(sysUser.getId()));
     }
 
 }

+ 9 - 0
mec-util/src/main/java/com/ym/mec/util/date/DateUtil.java

@@ -141,6 +141,7 @@ public class DateUtil {
 
 	public static Map<Object,Integer> normalWeekNumCalendarWeekNumMap=new HashMap<>();
 	public static Map<Object,Integer> calendarWeekNumNormalWeekNumMap=new HashMap<>();
+	public static Map<Integer,String> weekNumNormalWeekNameMap=new HashMap<>();
 
 	static {
 		normalWeekNumCalendarWeekNumMap.put(1,Calendar.MONDAY);
@@ -182,6 +183,14 @@ public class DateUtil {
 		calendarWeekNumNormalWeekNumMap.put(Calendar.FRIDAY,5);
 		calendarWeekNumNormalWeekNumMap.put(Calendar.SATURDAY,6);
 		calendarWeekNumNormalWeekNumMap.put(Calendar.SUNDAY,7);
+
+		weekNumNormalWeekNameMap.put(1,"周一");
+		weekNumNormalWeekNameMap.put(2,"周二");
+		weekNumNormalWeekNameMap.put(3,"周三");
+		weekNumNormalWeekNameMap.put(4,"周四");
+		weekNumNormalWeekNameMap.put(5,"周五");
+		weekNumNormalWeekNameMap.put(6,"周六");
+		weekNumNormalWeekNameMap.put(7,"周日");
 	}
 
 	// ~ 方法 ////////////////////////////////////////////////////////////////