Browse Source

Merge remote-tracking branch 'origin/master'

weifanli 3 years ago
parent
commit
90a5c5e438

+ 5 - 5
cooleshow-cms/src/main/java/com/yonge/cooleshow/cms/controller/NewsController.java

@@ -32,7 +32,7 @@ import javax.validation.Valid;
 
 @RestController
 @RequestMapping("news")
-@Api(tags = "资讯/广告/闪页/轮播图服务")
+@Api(tags = "资讯/广告/闪页/轮播图/乐理服务")
 public class NewsController extends BaseController {
 
 	@Autowired
@@ -41,7 +41,7 @@ public class NewsController extends BaseController {
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
 
-	@ApiOperation(value = "资讯/广告/闪页/轮播图 列表分页查询", httpMethod="POST", consumes="application/json", produces="application/json")
+	@ApiOperation(value = "资讯/广告/闪页/轮播图/乐理 列表分页查询", httpMethod="POST", consumes="application/json", produces="application/json")
 	@PostMapping(value = "/page",  consumes="application/json", produces="application/json")
 	public HttpResponseResult<PageInfo<SysNewsInformationDto>> getList(@Valid @RequestBody NewsInformationQueryInfo queryInfo) {
 		
@@ -51,7 +51,7 @@ public class NewsController extends BaseController {
 	}
 
 
-	@ApiOperation("查询资讯/广告/闪页/轮播图 详情")
+	@ApiOperation("查询资讯/广告/闪页/轮播图/乐理 详情")
 	@ApiImplicitParam(name = "id", value = "资讯ID编号", required = true, dataType = "Long", paramType = "path")
 	@GetMapping(value = "/query/{id}")
 	public HttpResponseResult<SysNewsInformationDto> query(@PathVariable Long id) {
@@ -59,7 +59,7 @@ public class NewsController extends BaseController {
 		return succeed(sysNewsInformationService.queryById(id));
 	}
 
-	@ApiOperation(value = "新增资讯/广告/闪页/轮播图 ", httpMethod="POST", consumes="application/json", produces="application/json")
+	@ApiOperation(value = "新增资讯/广告/闪页/轮播图/乐理 ", httpMethod="POST", consumes="application/json", produces="application/json")
 	@PostMapping(value = "/add",  consumes="application/json", produces="application/json")
 	@AuditLogAnnotation(operateName = "资讯新增",interfaceURL = "news/add")
 	// @PreAuthorize("@pcs.hasPermissions('news/add')")
@@ -144,7 +144,7 @@ public class NewsController extends BaseController {
 		return succeed();
 	}
 
-	@ApiOperation(value = "更新资讯/广告/闪页/轮播图 ", httpMethod="POST", consumes="application/json", produces="application/json")
+	@ApiOperation(value = "更新资讯/广告/闪页/轮播图/乐理 ", httpMethod="POST", consumes="application/json", produces="application/json")
 	@PostMapping(value = "/update",  consumes="application/json", produces="application/json")
 	@AuditLogAnnotation(operateName = "资讯更新",interfaceURL = "news/update")
 	// @PreAuthorize("@pcs.hasPermissions('news/update')")

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java

@@ -203,5 +203,7 @@ public interface CourseScheduleDao extends BaseMapper<CourseSchedule> {
 
     //查询老师声部价格
     BigDecimal selectPrice(@Param("teacherId") Long teacherId, @Param("subjectId") Long subjectId);
+
+    List<CourseSchedule> selectSchedule(Integer courseId);
 }
 

+ 10 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/StudentMusicSheetOrderSearch.java

@@ -46,6 +46,9 @@ public class StudentMusicSheetOrderSearch extends QueryInfo {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date endTime;
 
+    @ApiModelProperty(value = "订单状态 WAIT_PAY 待支付 PAYING 支付中  PAID 已付款 CLOSE 已关闭", hidden = true)
+    private YesOrNoEnum orderStatus = YesOrNoEnum.YES;
+
     @ApiModelProperty(value = "假删除 0 : 未删除 1:已删除", hidden = true)
     private Boolean delFlag = false;
 
@@ -116,4 +119,11 @@ public class StudentMusicSheetOrderSearch extends QueryInfo {
         this.delFlag = delFlag;
     }
 
+    public YesOrNoEnum getOrderStatus() {
+        return orderStatus;
+    }
+
+    public void setOrderStatus(YesOrNoEnum orderStatus) {
+        this.orderStatus = orderStatus;
+    }
 }

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

@@ -184,7 +184,7 @@ public interface CourseScheduleService extends IService<CourseSchedule> {
 
     void buyPracticeCourseFailed(UserOrderDetailVo orderParam);
 
-    void courseAdjust(CourseAdjustVo adjustVo);
+    void courseAdjust(CourseAdjustVo adjustVo,Long teacherId);
 
     StudentHomePage queryLiveAndVideo(Long studentId, Long teacherId, YesOrNoEnum appAuditVersion);
 

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

@@ -33,6 +33,7 @@ import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.base.page.PageInfo;
 import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
 import com.yonge.toolset.utils.date.DateUtil;
+import com.yonge.toolset.utils.obj.ObjectUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.redisson.api.RMap;
@@ -53,6 +54,8 @@ import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
+import static com.yonge.cooleshow.biz.dal.support.WrapperUtil.inInterSection;
+
 /**
  * 老师课程表(CourseSchedule)表服务实现类
  *
@@ -881,11 +884,11 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         if (dateList.size() != courseNum) {
             throw new BizException("课程数与课时数不符");
         }
-        BigDecimal price=baseMapper.selectPrice(scheduleDto.getTeacherId(), scheduleDto.getSubjectId());//老师设置声部价格
+        BigDecimal price = baseMapper.selectPrice(scheduleDto.getTeacherId(), scheduleDto.getSubjectId());//老师设置声部价格
         BigDecimal decimal = new BigDecimal(courseNum);//选购课程节数
         BigDecimal multiply = price.multiply(decimal);//预计总价
-        if (multiply.compareTo(scheduleDto.getCoursePrice())!=0){
-            throw new BizException("价格异常。预计价格:{},实际价格:{}",multiply,scheduleDto.getCoursePrice());
+        if (multiply.compareTo(scheduleDto.getCoursePrice()) != 0) {
+            throw new BizException("价格异常。预计价格:{},实际价格:{}", multiply, scheduleDto.getCoursePrice());
         }
 
         //批量检查老师课时在数据库是否重复
@@ -1039,7 +1042,52 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      * @Date: 2022/4/21
      */
     @Override
-    public void courseAdjust(CourseAdjustVo adjustVo) {
+    public void courseAdjust(CourseAdjustVo adjustVo, Long teacherId) {
+        Integer courseId = adjustVo.getCourseId();
+        Date classDate = adjustVo.getClassDate();
+        Date startTime = adjustVo.getStartTime();
+        Date endTime = adjustVo.getEndTime();
+        Date now = new Date();
+        //校验时间是否为未来时刻
+        if (classDate.before(now) || startTime.before(now) || endTime.before(now)) {
+            throw new BizException("时间不正确");
+        }
+
+        //校验课程是否存在
+        CourseSchedule schedule = baseMapper.selectOne(Wrappers.<CourseSchedule>lambdaQuery()
+                .eq(CourseSchedule::getId, courseId)
+                .eq(CourseSchedule::getLock, 1)
+                .eq(CourseSchedule::getStatus, CourseScheduleEnum.NOT_START)
+                .eq(CourseSchedule::getType, CourseScheduleEnum.PRACTICE));
+        if (ObjectUtil.isEmpty(schedule)) {
+            throw new BizException("课程不存在");
+        }
+
+        //查询是否有人购买
+        CourseScheduleStudentPayment studentPayment = paymentDao.selectOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
+                .eq(CourseScheduleStudentPayment::getCourseId, courseId)
+                .eq(CourseScheduleStudentPayment::getCourseType, CourseScheduleEnum.PRACTICE));
+        if (ObjectUtil.isEmpty(studentPayment)) {
+            throw new BizException("课程无人购买");
+        }
+
+        //批量检查老师课时在数据库是否重复
+        List<CourseSchedule> scheduleList = this.list(Wrappers.<CourseSchedule>lambdaQuery()
+                .eq(CourseSchedule::getTeacherId, teacherId)
+                .in(CourseSchedule::getStatus, Lists.newArrayList(CourseScheduleEnum.NOT_START.getCode(), CourseScheduleEnum.ING.getCode())));
+        for (CourseSchedule courseSchedule : scheduleList) {
+            if (inInterSection(startTime, endTime, courseSchedule.getStartTime(), courseSchedule.getEndTime(), true)) {
+                throw new BizException("老师排课冲突,课程id:{}", courseSchedule.getId());
+            }
+        }
+        //批量检查学生课时在数据库是否重复
+        List<CourseSchedule> studentList = baseMapper.selectSchedule(courseId);
+        for (CourseSchedule courseSchedule : studentList) {
+            if (inInterSection(startTime, endTime, courseSchedule.getStartTime(), courseSchedule.getEndTime(), true)) {
+                throw new BizException("学生排课冲突,课程id:{}", courseSchedule.getId());
+            }
+        }
+
         baseMapper.courseAdjust(adjustVo);
     }
 

+ 16 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java

@@ -187,7 +187,22 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao,MusicSheet>
 
     @Override
     public IPage<MusicSheetVo> selectStudentPage(IPage<MusicSheetVo> page, StudentMusicSheetSearch query) {
-        return page.setRecords(baseMapper.selectStudentMusicPage(page, query));
+        IPage<MusicSheetVo> musicSheetVoIPage = page.setRecords(baseMapper.selectStudentMusicPage(page, query));
+        List<MusicSheetVo> records = musicSheetVoIPage.getRecords();
+        if (query.getStudentId() != null) {
+            StudentVo studentVo = studentService.detail(query.getStudentId());
+            if (studentVo == null) {
+                return musicSheetVoIPage;
+            }
+            for (MusicSheetVo record : records) {
+                if (ChargeTypeEnum.VIP.getCode().equals(record.getChargeType().getCode())
+                        && YesOrNoEnum.YES.getCode().equals(studentVo.getIsVip().getCode())) {
+                    record.setPlay(YesOrNoEnum.YES);
+                }
+            }
+        }
+        return musicSheetVoIPage;
+
     }
 
     @Override

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetVo.java

@@ -29,6 +29,9 @@ public class MusicSheetVo extends MusicSheet {
     @ApiModelProperty("收藏 0:否,1:是")
     private YesOrNoEnum favorite;
 
+    @ApiModelProperty("是否购买/VIP(0:否,1:是) ")
+    private YesOrNoEnum play;
+
     public String getAddName() {
         return addName;
     }
@@ -68,4 +71,12 @@ public class MusicSheetVo extends MusicSheet {
     public void setFavorite(YesOrNoEnum favorite) {
         this.favorite = favorite;
     }
+
+    public YesOrNoEnum getPlay() {
+        return play;
+    }
+
+    public void setPlay(YesOrNoEnum play) {
+        this.play = play;
+    }
 }

+ 9 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -698,4 +698,12 @@
         AND p.subject_id_=#{subjectId}
         AND t.default_flag_=1
     </select>
-</mapper>
+    <select id="selectSchedule" resultType="com.yonge.cooleshow.biz.dal.entity.CourseSchedule"
+            parameterType="java.lang.Integer">
+        SELECT * FROM course_schedule
+        WHERE id_ IN (
+            SELECT course_id_ FROM course_schedule_student_payment
+            WHERE user_id_=(SELECT user_id_ FROM course_schedule_student_payment WHERE course_id_=200 AND course_type_='PRACTICE')
+        )
+    </select>
+</mapper>

+ 8 - 3
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml

@@ -240,10 +240,17 @@
         where find_in_set(s.id_,t.music_subject_)  and s.del_flag_ = 0) as subjectNames
         <if test="param.studentId != null">
             ,if(mf.id_ is not null,1,0) as favorite
+            ,case when mspr.id_ is not null then 1
+                when t.charge_type_ = 'FREE' then 1
+                else 0 end as play
         </if>
         from music_sheet t
         left join sys_user su on t.create_by_ = su.id_
         <if test="param.studentId != null">
+            left join music_sheet_purchase_record mspr
+                on mspr.music_sheet_id_ = t.id_
+                and mspr.student_id_ = #{param.studentId}
+                and order_status_ = 'PAID'
             left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.studentId}
         </if>
         <where>
@@ -337,9 +344,7 @@
         from music_sheet_purchase_record mspr
         left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
         <where>
-            <if test="param.orderStatus != null">
-                and mspr.order_status_ = #{param.orderStatus}
-            </if>
+            mspr.order_status_ = 'PAID'
             <if test="param.idAndName != null and param.idAndName != ''">
                 and (ms.id_ like concat('%',#{param.idAndName} ,'%')
                     or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))

+ 5 - 1
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherCourseScheduleController.java

@@ -132,7 +132,11 @@ public class TeacherCourseScheduleController extends BaseController {
     @ApiOperation(value = "老师端-课表-日历-调课")
     @PostMapping("/courseAdjust")
     public HttpResponseResult<Object> courseAdjust(@Validated @RequestBody CourseAdjustVo adjustVo) {
-        courseScheduleService.courseAdjust(adjustVo);
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || null == user.getId()) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        courseScheduleService.courseAdjust(adjustVo,user.getId());
         return succeed();
     }
 

+ 44 - 9
toolset/utils/src/main/java/com/yonge/toolset/utils/date/DateUtil.java

@@ -950,6 +950,41 @@ public class DateUtil {
 	}
 
 	/**
+	 * 将字符串转换为指定格式的日期 yyyy-MM-dd HH:mm:ss
+	 *
+	 * @param dateStr
+	 * @return
+	 */
+	public static Date strToDate(String dateStr) {
+		Date date = null;
+		try {
+			SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", DEFAULT_LOCALE);
+			date = simpleDateFormat.parse(dateStr);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		return date;
+	}
+
+	/**
+	 * 是否大于当前时间
+	 * @param dateStr
+	 * @return
+	 */
+	public static boolean afterNow(String dateStr){
+		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		Date date = null;
+		Date now = null;
+		try {
+			date = format.parse(dateStr);
+			now = new Date();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return date.after(now);
+	}
+
+	/**
 	 * 时间转字符串
 	 * @param date
 	 * @return
@@ -1016,15 +1051,15 @@ public class DateUtil {
 		calendar.set(Calendar.SECOND, 59);
 		return calendar.getTime();
 	}
-	
-	public static Date formatHMSToZero(Date date) {    
-        Calendar cal = Calendar.getInstance();  
-        cal.setTime(date);  
-        cal.set(Calendar.HOUR_OF_DAY, 0);  
-        cal.set(Calendar.MINUTE, 0);  
-        cal.set(Calendar.SECOND, 0);  
-        cal.set(Calendar.MILLISECOND, 0);  
-        return cal.getTime(); 
+
+	public static Date formatHMSToZero(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        return cal.getTime();
     }
 
 	/**