浏览代码

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

liujunchi 3 年之前
父节点
当前提交
b1db0d5d26
共有 17 个文件被更改,包括 376 次插入103 次删除
  1. 3 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/SysUserFeignService.java
  2. 6 1
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/fallback/SysUserFeignServiceFallback.java
  3. 20 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java
  4. 9 5
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java
  5. 9 21
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseCalendarEntity.java
  6. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/StudentTotal.java
  7. 14 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/props/HuifuProperties.java
  8. 6 5
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/PaymentSdk.java
  9. 13 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java
  10. 193 47
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java
  11. 3 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java
  12. 31 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherStyleVideoVo.java
  13. 18 4
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  14. 9 4
      cooleshow-user/user-biz/src/main/resources/config/mybatis/StudentMapper.xml
  15. 4 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherStyleVideoMapper.xml
  16. 23 9
      cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/PaymentController.java
  17. 14 3
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/CourseScheduleController.java

+ 3 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/SysUserFeignService.java

@@ -45,4 +45,7 @@ public interface SysUserFeignService {
 
 	@PostMapping(value = "user/realNameAuth")
 	public HttpResponseResult<IdcardInfoExtractor> realNameAuth(@RequestBody RealnameAuthReq realNameAuthDto);
+
+	@PostMapping(value = "user/bindOpenId")
+	HttpResponseResult<Boolean> bindOpenId(@RequestBody SysUser user);
 }

+ 6 - 1
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/fallback/SysUserFeignServiceFallback.java

@@ -44,7 +44,7 @@ public class SysUserFeignServiceFallback implements SysUserFeignService {
 
 	@Override
 	public HttpResponseResult<Boolean> updateSysUser(SysUser user) {
-		return null;
+		return HttpResponseResult.failed("请求失败");
 	}
 
 	@Override
@@ -56,4 +56,9 @@ public class SysUserFeignServiceFallback implements SysUserFeignService {
 	public HttpResponseResult<IdcardInfoExtractor> realNameAuth(RealnameAuthReq realNameAuthDto) {
 		return null;
 	}
+
+	@Override
+	public HttpResponseResult<Boolean> bindOpenId(SysUser user) {
+		return HttpResponseResult.failed("请求失败");
+	}
 }

+ 20 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java

@@ -488,4 +488,24 @@ public class UserController extends BaseController {
         sysUserService.submitSetDetail(setReq, user.getId());
         return succeed(sysUserService.getSetDetail(user.getId()));
     }
+
+    @PostMapping(value = "/bindOpenId")
+    public HttpResponseResult<Boolean> bindOpenId(@RequestBody SysUser param) {
+        AuthUser authUser = SecurityUtils.getUser();
+        if (authUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        SysUser user = sysUserService.get(authUser.getUserId());
+        if (user == null || null == user.getId()) {
+            return failed("用户不存在");
+        }
+        user.setWechatId(
+                StringUtil.isEmpty(param.getWechatId()) ? user.getWxOpenid() : param.getWechatId()
+        );
+        user.setQqOpenid(
+                StringUtil.isEmpty(param.getQqOpenid()) ? user.getQqOpenid() : param.getQqOpenid()
+        );
+        sysUserService.update(user);
+        return HttpResponseResult.succeed(true);
+    }
 }

+ 9 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java

@@ -42,12 +42,16 @@ public interface CourseScheduleDao extends BaseMapper<CourseSchedule> {
     List<StudentTotalVo> queryStudentTotal();
 
     /**
-     * 根据学生id查询大于当前时间并未开始的课程
-     *
-     * @param studentId 学生id
-     * @param classDate 年月日
+     * 根据学生id查询课程
+     * @param param 传入参数
+     *              <p> - studentId 学生id
+     *              <p> - status 课程状态 NOT_START未开始 ING进行中 COMPLETE已完成
+     *              <p> - classDate  年月日
+     *              <p> - startClassDate 开始时间-年月日
+     *              <p> - endClassDate 结束时间-年月日
+     *              <p> - greaterDate 上课时间大于该时间-年月日时分秒
      */
-    List<CourseSchedule> queryStudentCourse(@Param("studentId") Long studentId, @Param("classDate") String classDate);
+    List<CourseSchedule> queryStudentCourse(@Param("param") Map<String, Object> param);
 
     /**
      * 查询老师直播课程

+ 9 - 21
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseCalendarEntity.java

@@ -19,16 +19,15 @@ public class CourseCalendarEntity implements Serializable {
     @ApiModelProperty(value = "是否是节假日  0:不是 1是")
     private Integer holiday;
 
+    @ApiModelProperty(value = "是否跳过节假日  0:不跳过 1跳过")
+    private Integer skipHoliday;
+
     @ApiModelProperty(value = "当日课程是否排满  0:未满 1满")
     private Integer fullCourse;
 
     @ApiModelProperty(value = "当日课程时间-满课或跳过节假日的无数据")
     private List<CourseTimeEntity> courseTime;
 
-    public static CourseCalendarEntity build() {
-        return new CourseCalendarEntity();
-    }
-
     public String getDate() {
         return date;
     }
@@ -37,11 +36,6 @@ public class CourseCalendarEntity implements Serializable {
         this.date = date;
     }
 
-    public CourseCalendarEntity date(String date) {
-        this.date = date;
-        return this;
-    }
-
     public Integer getHoliday() {
         return holiday;
     }
@@ -50,10 +44,6 @@ public class CourseCalendarEntity implements Serializable {
         this.holiday = holiday;
     }
 
-    public CourseCalendarEntity holiday(Integer holiday) {
-        this.holiday = holiday;
-        return this;
-    }
 
     public Integer getFullCourse() {
         return fullCourse;
@@ -63,11 +53,6 @@ public class CourseCalendarEntity implements Serializable {
         this.fullCourse = fullCourse;
     }
 
-    public CourseCalendarEntity fullCourse(Integer fullCourse) {
-        this.fullCourse = fullCourse;
-        return this;
-    }
-
     public List<CourseTimeEntity> getCourseTime() {
         return courseTime;
     }
@@ -76,8 +61,11 @@ public class CourseCalendarEntity implements Serializable {
         this.courseTime = courseTime;
     }
 
-    public CourseCalendarEntity courseTime(List<CourseTimeEntity> courseTime) {
-        this.courseTime = courseTime;
-        return this;
+    public Integer getSkipHoliday() {
+        return skipHoliday;
+    }
+
+    public void setSkipHoliday(Integer skipHoliday) {
+        this.skipHoliday = skipHoliday;
     }
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/StudentTotal.java

@@ -20,7 +20,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 public class StudentTotal implements Serializable {
 	private static final long serialVersionUID = 1L;
     @ApiModelProperty("对应user表用户编号 ")
-    @TableId(value = "user_id_", type = IdType.AUTO)
+    @TableId(value = "user_id_")
     private Long userId;
     @ApiModelProperty("累计练习天数 ")
 	@TableField(value = "exercise_days_")

+ 14 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/props/HuifuProperties.java

@@ -34,6 +34,12 @@ public class HuifuProperties {
      */
     private String rsaPrivateKey;
     /***
+     * 付款成功回调地址
+     * @author liweifan
+     * @updateTime 2022/3/31 11:24
+     */
+    private String notifyUrl;
+    /***
      * 微信appid
      * @author liweifan
      * @updateTime 2022/3/31 11:24
@@ -93,4 +99,12 @@ public class HuifuProperties {
     public void setWxSecret(String wxSecret) {
         this.wxSecret = wxSecret;
     }
+
+    public String getNotifyUrl() {
+        return notifyUrl;
+    }
+
+    public void setNotifyUrl(String notifyUrl) {
+        this.notifyUrl = notifyUrl;
+    }
 }

+ 6 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/PaymentSdk.java

@@ -14,6 +14,7 @@ import com.yonge.cooleshow.common.exception.BizException;
 import com.yonge.toolset.thirdparty.exception.ThirdpartyException;
 import com.yonge.toolset.utils.collection.MapUtil;
 import com.yonge.toolset.utils.http.HttpUtil;
+import com.yonge.toolset.utils.string.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
@@ -139,7 +140,8 @@ public class PaymentSdk {
      * @updateTime 2022/4/8 15:49
      * @return: java.lang.Object
      */
-    public HttpResponseResult<Map<String, Object>> getOpenId(String js_code) {
+    public HttpResponseResult<Map<String, String>> getOpenId(String js_code) {
+        log.info("微信[获取用户openId] Req:{}", js_code);
         Map<String, Object> param = new HashMap<>();
         param.put("appid", HuifuConfiguration.getHuifuProperties().getWxAppid());
         param.put("secret", HuifuConfiguration.getHuifuProperties().getWxSecret());
@@ -149,13 +151,12 @@ public class PaymentSdk {
         try {
             String res = HttpUtil.get("https://api.weixin.qq.com/sns/jscode2session", param);
             JSONObject jsonObject = JSONObject.parseObject(res);
-
+            log.info("微信[获取用户openId] Res:{}", jsonObject.toJSONString());
             String errcode = jsonObject.getString("errcode");
-            if("0".equals(errcode)){
-                Map<String, Object> resMap = new HashMap<>();
+            if(StringUtil.isEmpty(errcode) || "0".equals(errcode)){
+                Map<String, String> resMap = new HashMap<>();
                 resMap.put("openid", jsonObject.getString("openid"));
                 resMap.put("session_key", jsonObject.getString("session_key"));
-                resMap.put("unionid", jsonObject.getString("unionid"));
                 return HttpResponseResult.succeed(resMap);
             }else{
                 return HttpResponseResult.failed(jsonObject.getString("errmsg"));

+ 13 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java

@@ -120,6 +120,19 @@ public interface CourseScheduleService extends IService<CourseSchedule> {
      */
     List<CourseCalendarEntity> createLiveCourseCalendar(Map<String, Object> param);
 
+    /**
+     * 生成陪练课日历-用于学生购买指定老师陪练课
+     *
+     * @param param 传入参数
+     *              <p> - teacherId 老师id
+     *              <p> - studentId 学生id
+     *              <p> - year 年
+     *              <p> - month 月
+     *              <p> - day 日
+     * @return 返回传入时间当月每日的剩余时间段
+     */
+    List<CourseCalendarEntity> createPracticeCourseCalender(Map<String, Object> param);
+
     IPage<MyCourseVo> myCourse(IPage<MyCourseVo> page, MyCourseSearch search);
 }
 

+ 193 - 47
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -1,26 +1,25 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
-import com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch;
-import com.yonge.cooleshow.biz.dal.vo.MyCourseVo;
-import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao;
-import com.yonge.cooleshow.biz.dal.entity.CourseCalendarEntity;
-import com.yonge.cooleshow.biz.dal.entity.CourseSchedule;
-import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
-import com.yonge.cooleshow.biz.dal.entity.HolidaysFestivals;
+import com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch;
+import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
 import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
 import com.yonge.cooleshow.biz.dal.service.HolidaysFestivalsService;
 import com.yonge.cooleshow.biz.dal.service.SysConfigService;
+import com.yonge.cooleshow.biz.dal.service.TeacherFreeTimeService;
 import com.yonge.cooleshow.biz.dal.support.PageUtil;
 import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
+import com.yonge.cooleshow.biz.dal.vo.MyCourseVo;
 import com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.exception.BizException;
 import com.yonge.cooleshow.common.page.PageInfo;
 import com.yonge.toolset.utils.date.DateUtil;
@@ -37,6 +36,7 @@ import javax.validation.Valid;
 import java.time.LocalDate;
 import java.time.temporal.TemporalAdjusters;
 import java.util.*;
+import java.util.function.BiConsumer;
 import java.util.function.Function;
 
 /**
@@ -57,6 +57,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
     private HolidaysFestivalsService holidaysFestivalsService;
     @Autowired
     private SysConfigService sysConfigService;
+    @Autowired
+    private TeacherFreeTimeService teacherFreeTimeService;
 
     @Override
     public CourseScheduleDao getDao() {
@@ -108,7 +110,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         //获取日期-目前上课没有跨天情况
         String ymd = DateUtil.format(startTime, DateUtil.DEFAULT_PATTERN);
         //查询大于当前时间并未开始的课程
-        List<CourseSchedule> list = baseMapper.queryStudentCourse(studentId, ymd);
+        Map<String, Object> param = new HashMap<>();
+        param.put("studentId", studentId);
+        param.put("greaterDate", new Date());
+        param.put("classDate", ymd);
+        param.put("status", CourseScheduleEnum.NOT_START.getCode());
+        List<CourseSchedule> list = baseMapper.queryStudentCourse(param);
         return checkCourseTime(list, CourseSchedule::getStartTime, CourseSchedule::getEndTime, startTime, endTime);
     }
 
@@ -155,8 +162,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      * @param endTime      新增课程结束时间
      * @return true 有交集 false 没有交集
      */
-    public <T> boolean checkCourseTime(List<T> list, Function<T, Date> startTimeFun, Function<T, Date> endTimeFun,
-                                       Date startTime, Date endTime) {
+    public <T> boolean checkCourseTime(List<T> list, Function<T, Date> startTimeFun, Function<T, Date> endTimeFun, Date startTime, Date endTime) {
         WrapperUtil.checkObj(startTime, "开始时间不能为空!");
         WrapperUtil.checkObj(endTime, "结束时间不能为空!");
         // 如果没有课程,直接返回false
@@ -241,12 +247,25 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
         //获取老师的课程  key:日期-年月日 value:课程时间-开始时间,结束时间
         Map<String, List<CourseTimeEntity>> nowCourseMap = getTeacherCourseTime(teacherId, firstDay.toString(), lastDay.toString());
-        //储存节假日数据,避免重复查询
-        Map<Integer, List<String>> holidayMap = new HashMap<>();
         //生成日历数据
         List<CourseCalendarEntity> courseCalendarEntities = generateCourseData(firstDay, lastDay, singleCourseMinutes);
+        //对比课程数据,筛选出空余的课程时间
+        opsCourseCalendarData(nowCourseMap, courseCalendarEntities, 0);
+        return courseCalendarEntities;
+    }
+
+    /**
+     * 对比课程数据,筛选出空余的课程时间
+     *
+     * @param nowCourseMap           现有课程
+     * @param courseCalendarEntities 课程时间日历
+     * @param skipHoliday            是否跳过节假日  0:不跳过 1跳过
+     */
+    private void opsCourseCalendarData(Map<String, List<CourseTimeEntity>> nowCourseMap, List<CourseCalendarEntity> courseCalendarEntities, Integer skipHoliday) {
+        //储存节假日数据,避免重复查询
+        Map<Integer, List<String>> holidayMap = new HashMap<>();
         courseCalendarEntities.forEach(calendarEntity -> {
-            //获取课程数据,并剔除交集时间段数据,
+            //获取课程数据,并剔除交集时间段数据
             List<CourseTimeEntity> nowCourse = nowCourseMap.get(calendarEntity.getDate());
             if (CollectionUtils.isEmpty(nowCourse)) {
                 //当日没课
@@ -280,9 +299,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
                     });
             //是否是节假日  0:不是 1是
             calendarEntity.setHoliday(holiday.contains(calendarEntity.getDate()) ? 1 : 0);
+            calendarEntity.setSkipHoliday(skipHoliday);//直播课日历只展示节假日 不跳过节假日
         });
-
-        return courseCalendarEntities;
     }
 
     /**
@@ -300,23 +318,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
                 .ge(CourseSchedule::getClassDate, startDate)
                 .le(CourseSchedule::getClassDate, endDate)
         );
-        //老师课程 key:日期-年月日  value:课程
-        Map<String, List<CourseTimeEntity>> nowCourse = new HashMap<>();
-        if (CollectionUtils.isNotEmpty(courseList)) {
-            WrapperUtil.groupList(courseList, CourseSchedule::getClassDate)
-                    .forEach((k, v) -> {
-                                List<CourseTimeEntity> value = new ArrayList<>();
-                                v.forEach(course -> {
-                                    CourseTimeEntity courseTimeEntity = new CourseTimeEntity();
-                                    courseTimeEntity.setStartTime(course.getStartTime());
-                                    courseTimeEntity.setEndTime(course.getEndTime());
-                                    value.add(courseTimeEntity);
-                                });
-                                nowCourse.put(DateUtil.dateToString(k), value);
-                            }
-                    );
-        }
-        return nowCourse;
+        return getCourseListMap(courseList);
     }
 
     /**
@@ -348,14 +350,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
             List<CourseTimeEntity> times = new ArrayList<>();
             //获取当前日期
             entity.setDate(firstDay.toString());
-            int finalAddDay = addDay;
-            dayTime.forEach(time -> {
-                CourseTimeEntity courseTimeEntity = new CourseTimeEntity();
-                courseTimeEntity.setStartTime(DateUtil.addDays(time.getStartTime(), finalAddDay));
-                courseTimeEntity.setEndTime(DateUtil.addDays(time.getEndTime(), finalAddDay));
-                times.add(courseTimeEntity);
-            });
-            entity.courseTime(times);
+            //将每日上课时间时间添加到日历中
+            opsCourseDayTime(addDay, entity, times, dayTime);
             list.add(entity);
             firstDay = firstDay.plusDays(1L);
             addDay++;
@@ -411,18 +407,168 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
     }
 
     /**
-     * 生成陪练课日历
+     * 生成陪练课日历-用于学生购买指定老师陪练课
+     *
+     * @param param 传入参数
+     *              <p> - teacherId 老师id
+     *              <p> - studentId 学生id
+     *              <p> - year 年
+     *              <p> - month 月
+     *              <p> - day 日
+     * @return 返回传入时间当月每日的剩余时间段
      */
-    public void generatePracticeCourseCalender() {
-        //todo 注意:如果是陪练课的日历需要查询老师设置的陪练课时间有哪些,不能直接根据时间段来
-        //获取周 int value = calendarDay.getDayOfWeek().getValue();
+    public List<CourseCalendarEntity> createPracticeCourseCalender(Map<String, Object> param) {
+        //校验数据
+        Long teacherId = WrapperUtil.toLong(param, "teacherId", "老师id不能为空!");
+        Long studentId = WrapperUtil.toLong(param, "teacherId", "学生id不能为空!");
+        Integer year = WrapperUtil.toInt(param, "year", "日历的时间年份不能为空!");
+        Integer month = WrapperUtil.toInt(param, "month", "日历的时间月份不能为空!");
+        Integer day = WrapperUtil.toInt(param, "month", "日历的时间日期不能为空!");
+
+        //传入的日期+1天开始
+        LocalDate firstDay = LocalDate.of(year, month, day).plusDays(1L);
+        //根据firstDay计算出该月的最后一天
+        LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
+        //查询老师陪练课设置
+        TeacherFreeTime teacherTime = teacherFreeTimeService.getOne(Wrappers.<TeacherFreeTime>lambdaQuery()
+                .eq(TeacherFreeTime::getDefaultFlag, true)
+                .eq(TeacherFreeTime::getTeacherId, teacherId)
+        );
+        Optional.ofNullable(teacherTime).orElseThrow(() -> new BizException("未查询到老师陪练课设置!"));
+        //根据老师设置的陪练课时间生成当月日历
+        List<CourseCalendarEntity> courseCalendarEntities = generatePracticeCalendar(teacherTime, firstDay, lastDay);
+        //查询老师及当前学生的课时
+        Map<String, List<CourseTimeEntity>> nowCourseMap = getAllPracticeCourseTime(teacherId, studentId, firstDay.toString(), lastDay.toString());
+        //和生成的日历对比,筛选出空余的课程时间
+        opsCourseCalendarData(nowCourseMap, courseCalendarEntities, teacherTime.getSkipHolidayFlag() ? 1 : 0);
+        return courseCalendarEntities;
     }
 
-    private SysUser getSysUser() {
-        return Optional.ofNullable(sysUserFeignService.queryUserInfo())
-                .orElseThrow(() -> new BizException("用户不存在"));
+    /**
+     * 生成老师陪练课日历
+     * <p>陪练课的日历需要查询老师设置的陪练课时间,根据设置的时间来生成日历
+     */
+    private List<CourseCalendarEntity> generatePracticeCalendar(TeacherFreeTime teacherTime, LocalDate firstDay, LocalDate lastDay) {
+        //将老师设置的陪练课时间结构化   key::数字周几 1~7  value:具体的时间 开始时间-结束时间
+        Map<Integer, List<CourseTimeEntity>> teacherPracticeTime = getTeacherPracticeTime(teacherTime);
+        //每日日期数据
+        List<CourseCalendarEntity> list = new ArrayList<>();
+        //添加的天数
+        int addDay = 0;
+        //获取每日日期数据
+        while (firstDay.isBefore(lastDay) || firstDay.isEqual(lastDay)) {
+            CourseCalendarEntity entity = new CourseCalendarEntity();
+            List<CourseTimeEntity> times = new ArrayList<>();
+            //获取当前日期
+            entity.setDate(firstDay.toString());
+            //获取当前日期周几
+            int weekNum = firstDay.getDayOfWeek().getValue();
+            List<CourseTimeEntity> timeEntities = teacherPracticeTime.get(weekNum);
+            if (CollectionUtils.isNotEmpty(timeEntities)) {
+                //将每日上课时间时间添加到日历中
+                opsCourseDayTime(addDay, entity, times, timeEntities);
+            }
+            list.add(entity);
+            firstDay = firstDay.plusDays(1L);
+            addDay++;
+        }
+        return list;
     }
 
+    /**
+     * 将每日上课时间时间添加到日历中
+     *
+     * @param addDay       添加的天数
+     * @param entity       实体数据
+     * @param times        课程数据集合
+     * @param timeEntities 每日上课时间集合
+     */
+    private void opsCourseDayTime(int addDay, CourseCalendarEntity entity, List<CourseTimeEntity> times, List<CourseTimeEntity> timeEntities) {
+        timeEntities.forEach(time -> {
+            CourseTimeEntity courseTimeEntity = new CourseTimeEntity();
+            courseTimeEntity.setStartTime(DateUtil.addDays(time.getStartTime(), addDay));
+            courseTimeEntity.setEndTime(DateUtil.addDays(time.getEndTime(), addDay));
+            times.add(courseTimeEntity);
+        });
+        entity.setCourseTime(times);
+    }
+
+    /**
+     * 将老师设置的陪练课时间结构化
+     *
+     * @return key::数字周几 1~7  value:具体的时间 开始时间-结束时间
+     */
+    private Map<Integer, List<CourseTimeEntity>> getTeacherPracticeTime(TeacherFreeTime teacherTime) {
+        Map<Integer, List<CourseTimeEntity>> teacherPracticeTime = new HashMap<>();
+        //将老师设置的陪练课时间放入map中
+        BiConsumer<String, Integer> timeCon = (timeStr, weekNum) -> {
+            if (StringUtils.isBlank(timeStr)) {
+                return;
+            }
+            List<CourseTimeEntity> timeEntityList = new ArrayList<>(JSONObject.parseArray(timeStr, CourseTimeEntity.class));
+            teacherPracticeTime.put(weekNum, timeEntityList);
+        };
+        timeCon.accept(teacherTime.getMonday(), 1);
+        timeCon.accept(teacherTime.getTuesday(), 2);
+        timeCon.accept(teacherTime.getWednesday(), 3);
+        timeCon.accept(teacherTime.getThursday(), 4);
+        timeCon.accept(teacherTime.getFriday(), 5);
+        timeCon.accept(teacherTime.getSaturday(), 6);
+        timeCon.accept(teacherTime.getSunday(), 7);
+        return teacherPracticeTime;
+    }
+
+    /**
+     * 查询老师及当前学生的课时
+     *
+     * @param teacherId 老师id
+     * @param studentId 学员id
+     */
+    private Map<String, List<CourseTimeEntity>> getAllPracticeCourseTime(Long teacherId, Long studentId, String startDate, String endDate) {
+        //查询该老师指定时间段的课程
+        List<CourseSchedule> courseList = this.list(Wrappers.<CourseSchedule>lambdaQuery()
+                .eq(CourseSchedule::getTeacherId, teacherId)
+                .ge(CourseSchedule::getClassDate, startDate)
+                .le(CourseSchedule::getClassDate, endDate)
+        );
+        if (CollectionUtils.isEmpty(courseList)) {
+            courseList = new ArrayList<>();
+        }
+        //查询学生的课程
+        Map<String, Object> param = new HashMap<>();
+        param.put("studentId", studentId);
+        param.put("startClassDate", startDate);
+        param.put("endClassDate", endDate);
+        List<CourseSchedule> studentCourse = baseMapper.queryStudentCourse(param);
+        //将数据合并
+        if (CollectionUtils.isNotEmpty(studentCourse)) {
+            courseList.addAll(studentCourse);
+        }
+        return getCourseListMap(courseList);
+    }
+
+    private Map<String, List<CourseTimeEntity>> getCourseListMap(List<CourseSchedule> courseList) {
+        //key:课程日期-年月日  value:课程
+        Map<String, List<CourseTimeEntity>> nowCourse = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(courseList)) {
+            WrapperUtil.groupList(courseList, CourseSchedule::getClassDate)
+                    .forEach((k, v) -> {
+                        List<CourseTimeEntity> value = new ArrayList<>();
+                        v.forEach(course -> {
+                            CourseTimeEntity courseTimeEntity = new CourseTimeEntity();
+                            courseTimeEntity.setStartTime(course.getStartTime());
+                            courseTimeEntity.setEndTime(course.getEndTime());
+                            value.add(courseTimeEntity);
+                        });
+                        nowCourse.put(DateUtil.dateToString(k), value);
+                    });
+        }
+        return nowCourse;
+    }
+
+    private SysUser getSysUser() {
+        return Optional.ofNullable(sysUserFeignService.queryUserInfo()).orElseThrow(() -> new BizException("用户不存在"));
+    }
 
     /**
      * @Description: 老师端-首页-我的课程-陪练课

+ 3 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java

@@ -3,6 +3,7 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yonge.cooleshow.biz.dal.config.HuifuConfiguration;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.biz.dal.dto.req.OrderPayReq;
 import com.yonge.cooleshow.biz.dal.dto.req.OrderReq;
@@ -164,8 +165,8 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
         deviceInfo.setDevice_ip(payReq.getIpAddress());
 
         paymentReq.setDevice_info(deviceInfo);
-        //todo 异步通知地址
-        //paymentReq.setNotify_url("异步通知地址");
+        //异步通知地址
+        paymentReq.setNotify_url(HuifuConfiguration.getHuifuProperties().getNotifyUrl());
 
         if (PayChannelEnum.wx_lite.equals(payReq.getPayChannel())) {
             Map<String, Object> expend = new HashMap<>();

+ 31 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherStyleVideoVo.java

@@ -1,7 +1,9 @@
 package com.yonge.cooleshow.biz.dal.vo;
 
 import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
+import com.yonge.cooleshow.biz.dal.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 
 /**
  * @Author: liweifan
@@ -9,5 +11,34 @@ import io.swagger.annotations.ApiModel;
  */
 @ApiModel(value = "TeacherStyleVideoVo对象", description = "老师风采信息")
 public class TeacherStyleVideoVo extends TeacherStyleVideo {
+    @ApiModelProperty(value = "是否直播 0否 1是")
+    private YesOrNoEnum liveFlag;
+    @ApiModelProperty("头像地址")
+    private String avatar;
+    @ApiModelProperty("老师昵称")
+    private String username;
 
+    public YesOrNoEnum getLiveFlag() {
+        return liveFlag;
+    }
+
+    public void setLiveFlag(YesOrNoEnum liveFlag) {
+        this.liveFlag = liveFlag;
+    }
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
 }

+ 18 - 4
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -91,10 +91,24 @@
                b.updated_time_
         from course_schedule_student_payment as a
                  left join course_schedule as b on a.course_id_ = b.id_
-        where b.start_time_ > now()
-          and b.class_date_ = #{classDate}
-          and b.status_ = 'NOT_START'
-          and a.user_id_ = #{studentId}
+        <where>
+            a.user_id_ = #{param.studentId}
+            <if test="param.greaterDate != null">
+                AND <![CDATA[ b.start_time_ > #{param.greaterDate} ]]>
+            </if>
+            <if test="param.startClassDate != null">
+                AND <![CDATA[ b.class_date_  >= #{param.startClassDate} ]]>
+            </if>
+            <if test="param.endClassDate != null">
+                AND <![CDATA[ b.class_date_  <= #{param.endClassDate} ]]>
+            </if>
+            <if test="param.classDate != null">
+                AND b.class_date_ = #{param.classDate}
+            </if>
+            <if test="param.status != null">
+                AND b.status_ = #{param.status}
+            </if>
+        </where>
         order by b.start_time_ desc
     </select>
 

+ 9 - 4
cooleshow-user/user-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -33,13 +33,18 @@
         SELECT
             <include refid="baseColumns"/>,
             u.avatar_ as avatar,
+            u.real_name_ as realName,
+            u.id_card_no_ as idCardNo,
             u.username_ as username,
             u.gender_ as gender,
             u.birthdate_ as birthdate,
+            TIMESTAMPDIFF(YEAR, u.birthdate_, CURDATE()) as age,
             u.phone_ as phone,
-            !isnull(u.id_card_no_) as isReal,
-            u.real_name_ as realName,
-            id_card_no_ as idCardNo
+            !isnull(birthdate_) as isReal,
+            (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,
+            (
+            SELECT GROUP_CONCAT(name_) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
+            ) as subjectName
         FROM student t
         left join sys_user u on t.user_id_ = u.id_
         where t.user_id_ = #{userId}
@@ -54,7 +59,7 @@
             TIMESTAMPDIFF(YEAR, u.birthdate_, CURDATE()) as age,
             u.phone_ as phone,
             !isnull(birthdate_) as isReal,
-            (membership_end_time_ > now()) as isVip,
+            (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,
             (
             SELECT GROUP_CONCAT(name_) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
             ) as subjectName

+ 4 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherStyleVideoMapper.xml

@@ -43,7 +43,10 @@
 
 	<select id="stylePage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherStyleVideoVo">
 		SELECT
-			<include refid="baseColumns"/>
+			<include refid="baseColumns"/>,
+			ta.live_flag_ as liveFlag,
+			u.avatar,
+			u.username
 		FROM teacher_style_video t
 		LEFT JOIN teacher a on t.user_id_ = a.user_id_
 		LEFT JOIN sys_user u on t.user_id_ = u.id_

+ 23 - 9
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/PaymentController.java

@@ -2,12 +2,17 @@ package com.yonge.cooleshow.student.controller;
 
 import com.huifu.adapay.core.AdapayCore;
 import com.huifu.adapay.core.util.AdapaySign;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.sdk.PaymentSdk;
+import com.yonge.cooleshow.biz.dal.service.EmployeeService;
 import com.yonge.cooleshow.biz.dal.service.UserOrderService;
+import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.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.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -20,17 +25,15 @@ import java.util.Map;
 @RestController
 @RequestMapping("/payment")
 @Api(value = "付款接口", tags = "付款接口")
-public class PaymentController {
+public class PaymentController extends BaseController {
     @Autowired
     private PaymentSdk paymentSdk;
     @Autowired
     private UserOrderService userOrderService;
-
-/*    @ApiOperation(value = "订单付款")
-    @PostMapping("/orderPay")
-    public HttpResponseResult<Map<String, Object>> orderPay(@RequestBody PaymentReq param) {
-        return HttpResponseResult.succeed(paymentSdk.executePayment(param));
-    }*/
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private EmployeeService employeeService;
 
     @ApiOperation(value = "查询付款单")
     @GetMapping("/queryPayment")
@@ -40,8 +43,19 @@ public class PaymentController {
 
     @ApiOperation(value = "微信支付获取openid")
     @GetMapping("/getOpenId")
-    public HttpResponseResult<Map<String, Object>> getOpenId(String js_code) {
-        return paymentSdk.getOpenId(js_code);
+    public HttpResponseResult<Map<String, String>> getOpenId(String js_code) {
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || null == user.getId()) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        HttpResponseResult<Map<String, String>> responseResult = paymentSdk.getOpenId(js_code);
+        if(responseResult.getStatus()){
+            Map<String, String> data = responseResult.getData();
+            //绑定到用户表
+            user.setWechatId(data.get("openid"));
+            sysUserFeignService.bindOpenId(user);
+        }
+        return responseResult;
     }
 
     /***

+ 14 - 3
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/CourseScheduleController.java

@@ -5,13 +5,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch;
-import com.yonge.cooleshow.biz.dal.dto.search.VideoLessonGroupSearch;
 import com.yonge.cooleshow.biz.dal.entity.CourseCalendarEntity;
 import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
 import com.yonge.cooleshow.biz.dal.support.PageUtil;
 import com.yonge.cooleshow.biz.dal.vo.MyCourseVo;
 import com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo;
-import com.yonge.cooleshow.biz.dal.vo.VideoLessonGroupVo;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.page.PageInfo;
@@ -70,10 +68,23 @@ public class CourseScheduleController extends BaseController {
     })
     @ApiOperation("直播课创建时的日历数据")
     @PostMapping("/createLiveCourseCalendar")
-    public HttpResponseResult<List<CourseCalendarEntity>> createLiveCourseCalendar(Map<String, Object> param) {
+    public HttpResponseResult<List<CourseCalendarEntity>> createLiveCourseCalendar(@RequestBody Map<String, Object> param) {
         return succeed(courseScheduleService.createLiveCourseCalendar(param));
     }
 
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "teacherId", dataType = "Long", value = "老师id"),
+            @ApiImplicitParam(name = "studentId", dataType = "Long", value = "学生id"),
+            @ApiImplicitParam(name = "year", dataType = "Integer", value = "年"),
+            @ApiImplicitParam(name = "month", dataType = "Integer", value = "月"),
+            @ApiImplicitParam(name = "day", dataType = "Integer", value = "日"),
+    })
+    @ApiOperation("陪练课日历-用于学生购买指定老师陪练课")
+    @PostMapping("/createPracticeCourseCalendar")
+    public HttpResponseResult<List<CourseCalendarEntity>> generatePracticeCourseCalender(@RequestBody Map<String, Object> param) {
+        return succeed(courseScheduleService.createPracticeCourseCalender(param));
+    }
+
     @ApiOperation("老师端-首页-我的课程-陪练课")
     @PostMapping("/myCourse")
     public HttpResponseResult<PageInfo<MyCourseVo>> myCourse(@RequestBody MyCourseSearch search) {