Parcourir la source

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

liujunchi il y a 3 ans
Parent
commit
e2694e3530
19 fichiers modifiés avec 360 ajouts et 216 suppressions
  1. 3 4
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/provider/PhoneAuthenticationProvider.java
  2. 7 8
      cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/UserWithdrawalController.java
  3. 43 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/convert/AuthStatusConvert.java
  4. 1 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/convert/TradeStatusConvert.java
  5. 5 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/UserWithdrawalDao.java
  6. 55 65
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/excel/UserWithdrawalExport.java
  7. 19 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomService.java
  8. 6 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserWithdrawalService.java
  9. 13 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseGroupServiceImpl.java
  10. 36 26
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java
  11. 118 69
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java
  12. 2 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java
  13. 23 6
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserWithdrawalServiceImpl.java
  14. 1 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseGroupMapper.xml
  15. 4 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  16. 1 8
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherFreeTimeMapper.xml
  17. 5 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/UserWithdrawalMapper.xml
  18. 4 15
      cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/StudentLiveRoomController.java
  19. 14 8
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherLiveRoomController.java

+ 3 - 4
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/provider/PhoneAuthenticationProvider.java

@@ -49,13 +49,13 @@ public class PhoneAuthenticationProvider extends AbstractAuthenticationProvider
         String smsCode = loginEntity.getSmsCode();
         String phone = loginEntity.getPhone();
         String qrCode = loginEntity.getQrCode();
-        if(StringUtils.isNotEmpty(qrCode) && StringUtils.isEmpty(smsCode)){
+        if (StringUtils.isNotEmpty(qrCode) && StringUtils.isEmpty(smsCode)) {
             // 二维码验证
             boolean b = sysUserService.verifyQrCode(phone, qrCode);
             if (!b) {
                 throw new BadCredentialsException("二维码校验失败");
             }
-        }else{
+        } else {
             // 验证码验证
             boolean b = smsCodeService.verifyValidCode(phone, smsCode, "SMS_VERIFY_CODE_LOGIN");
             if (!b) {
@@ -93,8 +93,7 @@ public class PhoneAuthenticationProvider extends AbstractAuthenticationProvider
             }
 
             if (!userInfo.getSysUser().getUserType().contains(clientId)
-                    && !userInfo.getSysUser().getUserType().contains(loginUserType)) {
-
+                    || (StringUtils.isNotEmpty(loginUserType) && !userInfo.getSysUser().getUserType().contains(loginUserType))) {
                 if (isRegister == false || StringUtils.equals("SYSTEM", clientId)) {
                     throw new LockedException("用户不存在");
                 } else {

+ 7 - 8
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/UserWithdrawalController.java

@@ -6,9 +6,6 @@ import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.excel.UserWithdrawalExport;
 import com.yonge.cooleshow.biz.dal.dto.req.AuthOperaReq;
-import com.yonge.cooleshow.biz.dal.support.DistributedLock;
-import com.yonge.cooleshow.common.enums.CacheNameEnum;
-import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.mybatis.support.PageUtil;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
@@ -16,7 +13,6 @@ import com.yonge.toolset.base.page.PageInfo;
 import com.yonge.toolset.utils.easyexcel.*;
 import io.swagger.annotations.*;
 import org.apache.commons.beanutils.BeanUtils;
-import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -25,12 +21,10 @@ import org.springframework.web.bind.annotation.*;
 import com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo;
 import com.yonge.cooleshow.biz.dal.dto.search.TeacherWithdrawalSearch;
 import com.yonge.cooleshow.biz.dal.service.UserWithdrawalService;
-import springfox.documentation.annotations.ApiIgnore;
 
 import javax.validation.Valid;
 import java.lang.reflect.InvocationTargetException;
 import java.util.*;
-import java.util.concurrent.TimeUnit;
 
 @RestController
 @RequestMapping("/userWithdrawal")
@@ -40,8 +34,7 @@ public class UserWithdrawalController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private UserWithdrawalService userWithdrawalService;
-    @Autowired
-    private RedissonClient redissonClient;
+
     /**
      * 查询单条
      */
@@ -87,6 +80,12 @@ public class UserWithdrawalController extends BaseController {
                 "列表数据");
     }
 
+    @GetMapping("/totalAmount")
+    @ApiOperation(value = "统计金额")
+    @PreAuthorize("@pcs.hasPermissions('userWithdrawal/totalAmount')")
+    public HttpResponseResult<UserWithdrawalVo> totalAmount() {
+        return succeed(userWithdrawalService.totalAmount());
+    }
 
     @PostMapping("/doAuth")
     @ApiOperation(value = "审核", notes = "传入authOperaReq")

+ 43 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/convert/AuthStatusConvert.java

@@ -0,0 +1,43 @@
+package com.yonge.cooleshow.biz.dal.convert;
+
+import com.alibaba.excel.converters.Converter;
+import com.alibaba.excel.enums.CellDataTypeEnum;
+import com.alibaba.excel.metadata.CellData;
+import com.alibaba.excel.metadata.GlobalConfiguration;
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
+import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
+import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/4/15 15:36
+ */
+public class AuthStatusConvert implements Converter<AuthStatusEnum> {
+
+    @Override
+    public Class supportJavaTypeKey() {
+        return CellDataTypeEnum.class;
+    }
+
+    @Override
+    public CellDataTypeEnum supportExcelTypeKey() {
+        return CellDataTypeEnum.STRING;
+    }
+
+    @Override
+    public AuthStatusEnum convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
+        try {
+            return AuthStatusEnum.valueOf(cellData.getStringValue().trim());
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    @Override
+    public CellData convertToExcelData(AuthStatusEnum statusEnum, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
+        if (null != statusEnum) {
+            return new CellData(statusEnum.getName());
+        }
+        return new CellData("异常数据");
+    }
+}

+ 1 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/convert/WithdrawalStatusConvert.java → cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/convert/TradeStatusConvert.java

@@ -5,14 +5,13 @@ import com.alibaba.excel.enums.CellDataTypeEnum;
 import com.alibaba.excel.metadata.CellData;
 import com.alibaba.excel.metadata.GlobalConfiguration;
 import com.alibaba.excel.metadata.property.ExcelContentProperty;
-import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
 
 /**
  * @Author: liweifan
  * @Data: 2022/4/15 15:36
  */
-public class WithdrawalStatusConvert implements Converter<TradeStatusEnum> {
+public class TradeStatusConvert implements Converter<TradeStatusEnum> {
 
     @Override
     public Class supportJavaTypeKey() {

+ 5 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/UserWithdrawalDao.java

@@ -49,5 +49,9 @@ public interface UserWithdrawalDao extends BaseMapper<UserWithdrawal> {
      */
     Integer getNowDayWithdrawalCount(@Param("userId") Long userId);
 
-
+    /**
+     * 统计金额
+     * @return
+     */
+    UserWithdrawalVo totalAmount();
 }

+ 55 - 65
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/excel/UserWithdrawalExport.java

@@ -1,14 +1,11 @@
 package com.yonge.cooleshow.biz.dal.dto.excel;
 
 import com.alibaba.excel.annotation.ExcelProperty;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.yonge.cooleshow.biz.dal.convert.WithdrawalStatusConvert;
+import com.yonge.cooleshow.biz.dal.convert.AuthStatusConvert;
+import com.yonge.cooleshow.biz.dal.convert.TradeStatusConvert;
 import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
-import io.swagger.annotations.ApiModelProperty;
 
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.Date;
 
@@ -17,37 +14,30 @@ import java.util.Date;
  * @Data: 2022/4/15 18:01
  */
 public class UserWithdrawalExport {
-    @NotNull(message = "结算编号不能为空")
     @ExcelProperty(value = "结算编号", index = 0)
     private Long id;
     @ExcelProperty(value = "结算人", index = 1)
     private String	withdrawaUser;
-    @ExcelProperty(value = "结算人编号", index = 2)
-    @NotNull(message = "结算人编号不能为空")
-    private Long userId;
-    @ExcelProperty(value = "开户行", index = 3)
+    @ExcelProperty(value = "结算金额", index = 2)
+    private BigDecimal amount;
+    @ExcelProperty(value = "发起时间", index = 3)
+    private Date createTime;
+    @ExcelProperty(value = "开户行", index = 4)
     private String bankName;
-    @ExcelProperty(value = "银行卡号", index = 4)
+    @ExcelProperty(value = "银行卡号", index = 5)
     private String bankCard;
-    @NotNull(message = "结算金额不能为空")
-    @ExcelProperty(value = "结算金额", index = 5)
-    private BigDecimal amount;
-    @NotNull(message = "平台服务费不能为空")
-    @ExcelProperty(value = "平台服务费", index = 6)
-    private BigDecimal plantformFee;
-    @ExcelProperty(value = "转账金额", index = 7)
+    @ExcelProperty(value = "转账金额(元)", index = 6)
     private BigDecimal actualAmount;
-
-    @NotNull(message = "结算状态不能为空")
-    @ExcelProperty(value = "结算状态 审核中/通过/不通过", index = 8,converter = WithdrawalStatusConvert.class)
-    private TradeStatusEnum status;
-    /*@ExcelProperty(value = "审核原因", index = 9)
-    private String verifyReason;*/
-    @ExcelProperty(value = "银行流水号", index = 9)
-    private String bankFlowNo;
-    /*@NotBlank(message = "签名不能为空")
-    @ExcelProperty(value = "签名", index = 11)
-    private String sign;*/
+    @ExcelProperty(value = "银行流水号", index = 7)
+    private String tradeNo;
+    @ExcelProperty(value = "审核状态", index = 8,converter = AuthStatusConvert.class)
+    private AuthStatusEnum authStatus;
+    @ExcelProperty(value = "转账状态", index = 9,converter = TradeStatusConvert.class)
+    private TradeStatusEnum tradeStatus;
+    @ExcelProperty(value = "审核时间", index = 10)
+    private Date authTime;
+    @ExcelProperty(value = "审核人", index = 11)
+    private String verifyUser;
 
     public Long getId() {
         return id;
@@ -65,12 +55,20 @@ public class UserWithdrawalExport {
         this.withdrawaUser = withdrawaUser;
     }
 
-    public Long getUserId() {
-        return userId;
+    public BigDecimal getAmount() {
+        return amount;
     }
 
-    public void setUserId(Long userId) {
-        this.userId = userId;
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
     }
 
     public String getBankName() {
@@ -89,59 +87,51 @@ public class UserWithdrawalExport {
         this.bankCard = bankCard;
     }
 
-    public BigDecimal getAmount() {
-        return amount;
-    }
-
-    public void setAmount(BigDecimal amount) {
-        this.amount = amount;
+    public BigDecimal getActualAmount() {
+        return actualAmount;
     }
 
-    public BigDecimal getPlantformFee() {
-        return plantformFee;
+    public void setActualAmount(BigDecimal actualAmount) {
+        this.actualAmount = actualAmount;
     }
 
-    public void setPlantformFee(BigDecimal plantformFee) {
-        this.plantformFee = plantformFee;
+    public String getTradeNo() {
+        return tradeNo;
     }
 
-    public BigDecimal getActualAmount() {
-        return actualAmount;
+    public void setTradeNo(String tradeNo) {
+        this.tradeNo = tradeNo;
     }
 
-    public void setActualAmount(BigDecimal actualAmount) {
-        this.actualAmount = actualAmount;
+    public AuthStatusEnum getAuthStatus() {
+        return authStatus;
     }
 
-    public String getBankFlowNo() {
-        return bankFlowNo;
+    public void setAuthStatus(AuthStatusEnum authStatus) {
+        this.authStatus = authStatus;
     }
 
-    public void setBankFlowNo(String bankFlowNo) {
-        this.bankFlowNo = bankFlowNo;
+    public TradeStatusEnum getTradeStatus() {
+        return tradeStatus;
     }
 
-    public TradeStatusEnum getStatus() {
-        return status;
+    public void setTradeStatus(TradeStatusEnum tradeStatus) {
+        this.tradeStatus = tradeStatus;
     }
 
-    public void setStatus(TradeStatusEnum status) {
-        this.status = status;
+    public Date getAuthTime() {
+        return authTime;
     }
 
-    /*public String getVerifyReason() {
-        return verifyReason;
+    public void setAuthTime(Date authTime) {
+        this.authTime = authTime;
     }
 
-    public void setVerifyReason(String verifyReason) {
-        this.verifyReason = verifyReason;
+    public String getVerifyUser() {
+        return verifyUser;
     }
 
-    public String getSign() {
-        return sign;
+    public void setVerifyUser(String verifyUser) {
+        this.verifyUser = verifyUser;
     }
-
-    public void setSign(String sign) {
-        this.sign = sign;
-    }*/
 }

+ 19 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.vo.RoomVo;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 import java.util.Map;
@@ -30,7 +31,16 @@ public interface LiveRoomService extends IService<LiveRoom> {
      *
      * @param roomUid 房间uid
      */
-    RoomVo studentCheckRoomInfo(String roomUid);
+    RoomInfoCache studentCheckRoomInfo(String roomUid);
+
+    /**
+     * 主讲人查询并校验房间信息
+     *
+     * @param roomUid 房间uid
+     * @param userId  主讲人id
+     * @return
+     */
+    RoomInfoCache speakerCheckRoomInfo(String roomUid);
 
     /**
      * 定时任务创建直播间
@@ -43,6 +53,13 @@ public interface LiveRoomService extends IService<LiveRoom> {
     void destroyExpiredLiveRoom();
 
     /**
+     * 手动关闭直播间
+     *
+     * @param roomUId 房间uid
+     */
+    void destroyLiveRoom(String roomUId);
+
+    /**
      * 定时任务-清理过期的房间-陪练课
      */
     void destroyExpiredPracticeRoom();
@@ -74,7 +91,7 @@ public interface LiveRoomService extends IService<LiveRoom> {
      * @param roomUid 房间uid
      * @param userId  主讲人id
      */
-    RoomInfoCache speakerJoinRoom(String roomUid, Long userId);
+    RoomInfoCache speakerJoinRoom(String roomUid);
 
     /**
      * 观看者-进入房间

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserWithdrawalService.java

@@ -99,6 +99,12 @@ public interface UserWithdrawalService extends IService<UserWithdrawal> {
      */
     HttpResponseResult<Boolean> transferAccount(AuthOperaReq authOperaReq, SysUser user);
 
+    /**
+     * 统计金额
+     * @return
+     */
+    UserWithdrawalVo totalAmount();
+
 
     /***
      * 导入

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

@@ -492,6 +492,19 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
                     }
                 }
 
+                //获取老师锁课缓存
+                RMap<Long, List<CourseTimeEntity>> map = getExpireLiveLockTimeCache(teacherId);
+                if (map.isExists()) {
+                    List<CourseTimeEntity> courseTimeCache = map.get(teacherId);
+                    //校验缓存中的时间和当前自动生成的时间有没有重复
+                    checkTime = courseScheduleService.checkCourseTime(courseTimeCache, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime, autoStartDate, autoEndDate);
+                    con.accept(checkTime);
+                    //如果和未来时间冲突则跳过
+                    if (flag.get()) {
+                        continue;
+                    }
+                }
+
                 //将自动生成时间收入集合
                 CourseTimeEntity autoTimeDto = new CourseTimeEntity();
                 autoTimeDto.setStartTime(autoStartDate);

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

@@ -1024,7 +1024,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 
         RLock lock = redissonClient.getLock("teacherId:" + scheduleDto.getTeacherId());
         try {
-            if (lock.tryLock(10,60, TimeUnit.SECONDS)) {
+            if (lock.tryLock(0, 60, TimeUnit.SECONDS)) {
                 return buyPracticeCourseTran(orderReqInfo);
             }
         } catch (InterruptedException e) {
@@ -1251,7 +1251,23 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      * @Date: 2022/4/26
      */
     public List<TeacherSubjectPrice> teacherSubjectPrice(Long teacherId) {
-        return teacherFreeTimeDao.selectPriceByTeacherId(teacherId);
+        TeacherFreeTime teacherFreeTime = teacherFreeTimeDao.selectOne(Wrappers.<TeacherFreeTime>lambdaQuery()
+                .eq(TeacherFreeTime::getTeacherId, teacherId)
+                .eq(TeacherFreeTime::getEnableFlag, 1)
+                .eq(TeacherFreeTime::getDefaultFlag, 1));
+
+        if ((teacherFreeTime.getMonday() == null || teacherFreeTime.getMonday().equals("[]")) &&
+                (teacherFreeTime.getThursday() == null || teacherFreeTime.getThursday().equals("[]")) &&
+                (teacherFreeTime.getWednesday() == null || teacherFreeTime.getWednesday().equals("[]")) &&
+                (teacherFreeTime.getThursday() == null || teacherFreeTime.getThursday().equals("[]")) &&
+                (teacherFreeTime.getFriday() == null || teacherFreeTime.getFriday().equals("[]")) &&
+                (teacherFreeTime.getSaturday() == null || teacherFreeTime.getSaturday().equals("[]")) &&
+                (teacherFreeTime.getSunday() == null || teacherFreeTime.getSunday().equals("[]"))) {
+            return new ArrayList<>();
+        }
+
+        List<TeacherSubjectPrice> list = teacherFreeTimeDao.selectPriceByTeacherId(teacherId);
+        return list;
     }
 
     @Override
@@ -1841,8 +1857,6 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
                 payment.setUserId(studentId);
                 payment.setCourseType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
                 courseScheduleStudentPaymentService.save(payment);
-
-                pianoSend(teacherId, studentId);
             }
         }
 
@@ -1859,6 +1873,13 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
             log.error("琴房课程组id:{},创建群聊失败:{}", courseGroup.getId(), e);
             e.printStackTrace();
         }
+
+        //清除统计缓存
+        for (Long studentId : studentIds) {
+            redissonClient.getBucket(CacheNameEnum.STUDENT_TOTAL.getRedisKey(studentId)).delete();
+            pianoSend(teacherId, studentId);
+        }
+        redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(teacherId)).delete();
     }
 
     /**
@@ -2100,31 +2121,20 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         if (pianoRoomTime == null) {
             throw new BizException("未查到剩余时长");
         }
-        Integer frozenTime = pianoRoomTime.getFrozenTime();
-        Integer remainTime = pianoRoomTime.getRemainTime();
+        Integer frozenTime = pianoRoomTime.getFrozenTime();//冻结时长
+        Integer remainTime = pianoRoomTime.getRemainTime();//剩余时长
 
         String formula = sysConfigService.findConfigValue(SysConfigConstant.PIANO_ROOM_TIME_FORMULA);
-
-        int i = studentIds.size() - paymentList.size();//新人数-原人数
-        if (i > 0) {//加人,扣时长
-            Integer n = (Integer) WrapperUtil.strToFormula(formula, "n", String.valueOf(i + 1));
-            int courseTime = singleCourseTime * n;
-            if (remainTime - courseTime < 0) {
-                throw new BizException("剩余时长不足");
-            }
-            pianoRoomTimeDao.update(null, Wrappers.<PianoRoomTime>lambdaUpdate()
-                    .eq(PianoRoomTime::getTeacherId, teacherId)
-                    .set(PianoRoomTime::getRemainTime, remainTime - courseTime)
-                    .set(PianoRoomTime::getFrozenTime, frozenTime + courseTime));
-        }
-        if (i < 0) {//减人,释放时长
-            Integer n = (Integer) WrapperUtil.strToFormula(formula, "n", String.valueOf(-i + 1));
-            int courseTime = singleCourseTime * n;
-            pianoRoomTimeDao.update(null, Wrappers.<PianoRoomTime>lambdaUpdate()
-                    .eq(PianoRoomTime::getTeacherId, teacherId)
-                    .set(PianoRoomTime::getRemainTime, remainTime + courseTime)
-                    .set(PianoRoomTime::getFrozenTime, frozenTime - courseTime));
+        Integer after = (Integer) WrapperUtil.strToFormula(formula, "n", String.valueOf(studentIds.size() + 1));//变更后
+        Integer before = (Integer) WrapperUtil.strToFormula(formula, "n", String.valueOf(paymentList.size() + 1));//变更前
+        int diffTime = singleCourseTime * (after - before);//人数变更后单课耗时
+        if (remainTime - diffTime < 0) {
+            throw new BizException("剩余时长不足");
         }
+        pianoRoomTimeDao.update(null, Wrappers.<PianoRoomTime>lambdaUpdate()
+                .eq(PianoRoomTime::getTeacherId, teacherId)
+                .set(PianoRoomTime::getRemainTime, remainTime - diffTime)
+                .set(PianoRoomTime::getFrozenTime, frozenTime + diffTime));
 
         //删除原学员
         paymentDao.delete(Wrappers.<CourseScheduleStudentPayment>lambdaQuery().eq(CourseScheduleStudentPayment::getCourseId, courseId));

+ 118 - 69
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java

@@ -14,6 +14,7 @@ import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.support.IMHelper;
 import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
 import com.yonge.cooleshow.biz.dal.vo.RoomVo;
+import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.utils.date.DateUtil;
 import org.apache.commons.collections.CollectionUtils;
@@ -62,6 +63,8 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     @Autowired
     private UserAccountService userAccountService;
     @Autowired
+    private UserOrderService userOrderService;
+    @Autowired
     private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
     @Autowired
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
@@ -110,10 +113,35 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      * @param roomUid 房间uid
      */
     @Override
-    public RoomVo studentCheckRoomInfo(String roomUid) {
-        //校验学生与房间的关系
-        checkStudentRoom(roomUid, getSysUser());
-        return queryRoomInfo(roomUid);
+    public RoomInfoCache studentCheckRoomInfo(String roomUid) {
+        return checkStudentRoom(roomUid, getSysUser());
+    }
+
+    /**
+     * 主讲人查询并校验房间信息
+     *
+     * @param roomUid 房间uid
+     * @param userId  主讲人id
+     * @return
+     */
+    @Override
+    public RoomInfoCache speakerCheckRoomInfo(String roomUid) {
+        Long userId = getSysUser().getId();
+        //校验房间是否存在
+        RBucket<RoomInfoCache> roomInfoCache = redissonClient.getBucket(LIVE_ROOM_INFO.replace(ROOM_UID, roomUid));
+        if (!roomInfoCache.isExists()) {
+            log.error("teacherCheckRoomInfo>>>live not start  roomUid: {} userId:{}", roomUid, userId);
+            throw new BizException("直播还未开始!");
+        }
+        RoomInfoCache roomInfo = roomInfoCache.get();
+        //校验进入房间的是否是该直播间的主讲人
+        if (!roomInfo.getSpeakerId().equals(userId)) {
+            log.error("teacherCheckRoomInfo>>>not speaker  roomUid: {} userId:{}", roomUid, userId);
+            throw new BizException("您不是该直播间的主讲人!");
+        }
+        roomInfo.setLikeNum(getLike(roomUid));
+        roomInfo.setLookNum(getNum.apply(this::getOnlineUserCache, roomUid));
+        return roomInfo;
     }
 
     /**
@@ -185,12 +213,12 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         SysUser sysUser = getSysUser();
         String roomTitle = WrapperUtil.toStr(param, "roomTitle", "房间标题不能为空!");
         String liveRemark = WrapperUtil.toStr(param, "liveRemark", "直播间描述不能为空!");
-        Integer liveTime = WrapperUtil.toInt(param, "liveTime","请选择直播时长!");
+        Integer liveTime = WrapperUtil.toInt(param, "liveTime", "请选择直播时长!");
         Date liveStartTime = new Date();
         Date liveEndTime = DateUtil.addMinutes(liveStartTime, liveTime);
         Long teacherId = sysUser.getId();
         //当前时间有课程则不能开启直播
-        boolean check =  courseScheduleService.checkTeacherCourseTime(teacherId,liveStartTime,liveEndTime);
+        boolean check = courseScheduleService.checkTeacherCourseTime(teacherId, liveStartTime, liveEndTime);
         if (check) {
             //如果当前时间和课程时间有交集则不能开启临时直播
             throw new BizException("当前选择的时间段有课无法开启直播");
@@ -309,43 +337,67 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             Date expiredDate = DateUtil.addMinutes(room.getLiveEndTime(), Integer.parseInt(expiredMinuteStr));
             //当前时间 大于(结束播时间 + 设置的过期分钟数)
             if (now.getTime() >= expiredDate.getTime()) {
-                //删除房间
-                destroyLiveRoom(room.getRoomUid());
-                //查询老师分润表
-                List<CourseScheduleTeacherSalary> salaryList = courseScheduleTeacherSalaryService.list(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
-                        .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
-                );
-                if (CollectionUtils.isEmpty(salaryList)) {
-                    return;
-                }
-                salaryList.forEach(salary -> {
-                    //查询该学生及课程id 对应的支付订单号
-                    CourseScheduleStudentPayment payment = courseScheduleStudentPaymentService.getOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
-                            .eq(CourseScheduleStudentPayment::getCourseId, room.getCourseId())
-                            .eq(CourseScheduleStudentPayment::getUserId, salary.getStudentId())
-                    );
-                    if (Objects.isNull(payment)) {
-                        return;
-                    }
-                    //获取教师课酬写入到金额变更表
-                    UserAccountRecordDto userAccountRecord = new UserAccountRecordDto();
-                    userAccountRecord.setUserId(room.getSpeakerId());
-                    userAccountRecord.setInOrOut(InOrOutEnum.IN);
-                    userAccountRecord.setBizType(AccountBizTypeEnum.LIVE);
-                    userAccountRecord.setBizId(room.getCourseId());
-                    userAccountRecord.setBizName(room.getRoomTitle());
-                    userAccountRecord.setTransAmount(salary.getActualSalary());//扣除手续费后所得金额
-                    userAccountRecord.setOrderNo(payment.getOrderNo());
-                    userAccountService.accountChange(userAccountRecord);
-                    //修改教师课酬状态-已结算
-                    salary.setStatus(TeacherSalaryEnum.COMPLETE.getCode());
-                    courseScheduleTeacherSalaryService.updateById(salary);
-                });
+                destroyLiveRoom(room);
             }
         });
     }
 
     /**
+     * 关闭直播间
+     *
+     * @param roomUId 房间uid
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void destroyLiveRoom(String roomUId) {
+        LiveRoom liveRoom = this.getOne(Wrappers.<LiveRoom>lambdaQuery().eq(LiveRoom::getRoomUid, roomUId));
+        destroyLiveRoom(liveRoom);
+    }
+
+    /**
+     * 关闭直播间
+     *
+     * @param room 房间信息
+     */
+    private void destroyLiveRoom(LiveRoom room) {
+        if (Objects.isNull(room)) {
+            return;
+        }
+        //查询老师分润表
+        List<CourseScheduleTeacherSalary> salaryList = courseScheduleTeacherSalaryService.list(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
+                .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
+        );
+        if (CollectionUtils.isEmpty(salaryList)) {
+            return;
+        }
+        salaryList.forEach(salary -> {
+            //查询该学生及课程id 对应的支付订单号
+            CourseScheduleStudentPayment payment = courseScheduleStudentPaymentService.getOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
+                    .eq(CourseScheduleStudentPayment::getCourseId, room.getCourseId())
+                    .eq(CourseScheduleStudentPayment::getUserId, salary.getStudentId())
+            );
+            if (Objects.isNull(payment)) {
+                return;
+            }
+            //获取教师课酬写入到金额变更表
+            UserAccountRecordDto userAccountRecord = new UserAccountRecordDto();
+            userAccountRecord.setUserId(room.getSpeakerId());
+            userAccountRecord.setInOrOut(InOrOutEnum.IN);
+            userAccountRecord.setBizType(AccountBizTypeEnum.LIVE);
+            userAccountRecord.setBizId(room.getCourseId());
+            userAccountRecord.setBizName(room.getRoomTitle());
+            userAccountRecord.setTransAmount(salary.getActualSalary());//扣除手续费后所得金额
+            userAccountRecord.setOrderNo(payment.getOrderNo());
+            userAccountService.accountChange(userAccountRecord);
+            //修改教师课酬状态-已结算
+            salary.setStatus(TeacherSalaryEnum.COMPLETE.getCode());
+            courseScheduleTeacherSalaryService.updateById(salary);
+        });
+        //删除房间
+        ImDestroyLiveRoom(room.getRoomUid());
+    }
+
+    /**
      * 定时任务-清理过期的房间-陪练课
      */
     public void destroyExpiredPracticeRoom() {
@@ -370,7 +422,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             //当前时间 大于(结束播时间 + 设置的过期分钟数)
             if (now.getTime() >= expiredDate.getTime()) {
                 //删除房间
-                destroyLiveRoom(room.getRoomUid());
+                ImDestroyLiveRoom(room.getRoomUid());
                 //查询老师分润表
                 CourseScheduleTeacherSalary salary = courseScheduleTeacherSalaryService.getOne(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
                         .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
@@ -405,7 +457,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      *
      * @param roomId 房间Uid
      */
-    private void destroyLiveRoom(String roomId) {
+    private void ImDestroyLiveRoom(String roomId) {
         try {
             //删除服务器房间
             List<String> deleteRoomIds = Lists.newArrayList(roomId);
@@ -614,29 +666,16 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      * 主讲人-进入房间
      *
      * @param roomUid 房间uid
-     * @param userId  主讲人id
      */
-    public RoomInfoCache speakerJoinRoom(String roomUid, Long userId) {
-        //校验房间是否存在
-        RBucket<RoomInfoCache> roomInfoCache = redissonClient.getBucket(LIVE_ROOM_INFO.replace(ROOM_UID, roomUid));
-        if (!roomInfoCache.isExists()) {
-            throw new BizException("直播还未开始!");
-        }
-        RoomInfoCache roomInfo = roomInfoCache.get();
+    public RoomInfoCache speakerJoinRoom(String roomUid) {
+        RoomInfoCache roomInfo = speakerCheckRoomInfo(roomUid);
         Date now = new Date();
-        //校验进入房间的是否是该直播间的主讲人
-        if (!roomInfo.getSpeakerId().equals(userId)) {
-            throw new BizException("您不是该直播间的主讲人!");
-        }
         roomInfo.setSpeakerState(0);
         roomInfo.setJoinRoomTime(now);
-        roomInfoCache.set(roomInfo);
         //查询老师是否有进入过,没有则写老师考勤表的进入时间
-        setTeacherAttendance(userId, roomInfo.getCourseGroupId(), roomInfo.getCourseId());
-        roomInfo.setLikeNum(getLike(roomUid));
-        roomInfo.setLookNum(getNum.apply(this::getOnlineUserCache, roomUid));
+        setTeacherAttendance(roomInfo.getSpeakerId(), roomInfo.getCourseGroupId(), roomInfo.getCourseId());
         //记录当前用户对应的房间uid
-        redissonClient.getBucket(LIVE_USER_ROOM.replace(USER_ID, userId.toString())).set(roomUid, 2L, TimeUnit.DAYS);
+        redissonClient.getBucket(LIVE_USER_ROOM.replace(USER_ID, roomInfo.getSpeakerId().toString())).set(roomUid, 2L, TimeUnit.DAYS);
         return roomInfo;
     }
 
@@ -650,8 +689,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         //获取进入房间人员信息
         SysUser sysUser = getSysUser(userId);
         //校验信息
-        RBucket<RoomInfoCache> roomInfoCache = checkStudentRoom(roomUid, sysUser);
-        RoomInfoCache roomInfo = roomInfoCache.get();
+        RoomInfoCache roomInfo = checkStudentRoom(roomUid, sysUser);
         Date now = new Date();
         //房间累计用户信息-指只要进入到该房间的用户都要记录
         RMap<Long, String> roomTotalUser = getTotalUserCache(roomUid);
@@ -678,10 +716,6 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         RMap<Long, String> onlineUserCache = getOnlineUserCache(roomUid);
         onlineUserCache.fastPut(userId, userJsonStr);
         log.info("joinRoom>>>> userInfo: {}", userJsonStr);
-        //刷新当前房间的点赞及观看人数信息
-        roomInfo.setLikeNum(getLike(roomUid));
-        roomInfo.setLookNum(getNum.apply(this::getOnlineUserCache, roomUid));
-        roomInfoCache.set(roomInfo);
         //向直播间发送当前在线人数消息
         this.sendOnlineUserCount(roomUid, userId, onlineUserCache.size());
         log.info("join sendOnlineUserCount>>>> param is null   roomUid: {}  fromUserId:{}  count:{}", roomUid, userId, onlineUserCache.size());
@@ -692,26 +726,41 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     }
 
     //校验学生与房间的关系
-    private RBucket<RoomInfoCache> checkStudentRoom(String roomUid, SysUser sysUser) {
+    private RoomInfoCache checkStudentRoom(String roomUid, SysUser sysUser) {
         //校验房间是否存在
         RBucket<RoomInfoCache> roomInfoCache = redissonClient.getBucket(LIVE_ROOM_INFO.replace(ROOM_UID, roomUid));
         if (!roomInfoCache.isExists()) {
             throw new BizException("直播还未开始!");
         }
         RoomInfoCache roomInfo = roomInfoCache.get();
-        //校验观看者是否可以进入该房间,如果是非临时直播间,则校验是否已经买过课
+        //校验观看者是否买过课,如果是非临时直播间,则校验是否已经买过课
         if (!roomInfo.getRoomType().equals(RoomTypeEnum.TEMP.getCode())) {
             // 查询该学员成功购买课程
-            int count = courseScheduleStudentPaymentService.count(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
+            CourseScheduleStudentPayment studentPayment = courseScheduleStudentPaymentService.getOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
                     .eq(CourseScheduleStudentPayment::getUserId, sysUser.getId())
                     .eq(CourseScheduleStudentPayment::getCourseId, roomInfo.getCourseId())
                     .eq(CourseScheduleStudentPayment::getCourseGroupId, roomInfo.getCourseGroupId())
                     .eq(CourseScheduleStudentPayment::getCourseType, CourseScheduleEnum.LIVE.getCode()));
-            if (count < 0) {
-                throw new BizException("您还未购买课程!");
+            if (Objects.nonNull(studentPayment)) {
+                UserOrderVo detail = userOrderService.detail(studentPayment.getOrderNo(), studentPayment.getUserId());
+                if (Objects.isNull(detail)) {
+                    throw new BizException("您还未购买该课程.");
+                }
+                //不等于已支付的都是异常
+                if (detail.getStatus().equals(OrderStatusEnum.CLOSE) || detail.getStatus().equals(OrderStatusEnum.FAIL)) {
+                    throw new BizException("您还未购买该课程。");
+                }
+                if (detail.getStatus().equals(OrderStatusEnum.WAIT_PAY) || detail.getStatus().equals(OrderStatusEnum.PAYING)) {
+                    throw new BizException("该课程的订单" + detail.getStatus().getMsg() + ",请先支付完成后再上课。");
+                }
+            } else {
+                throw new BizException("您还未购买该课程!");
             }
         }
-        return roomInfoCache;
+        //刷新当前房间的点赞及观看人数信息
+        roomInfo.setLikeNum(getLike(roomUid));
+        roomInfo.setLookNum(getNum.apply(this::getOnlineUserCache, roomUid));
+        return roomInfo;
     }
 
     /**

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

@@ -668,13 +668,13 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
             //清除商家统计缓存
             Long merchId = orderDetailVo.getMerchId();
             if (merchId != null && merchId != 0) {
-                redissonClient.getBucket(CacheNameEnum.TEACHER_SUBJECT_ITEM.getRedisKey(merchId)).delete();
+                //redissonClient.getBucket(CacheNameEnum.TEACHER_SUBJECT_ITEM.getRedisKey(merchId)).delete();
                 redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(merchId)).delete();
             }
         }
         //清除买家统计缓存
         if (ClientEnum.STUDENT.getCode().equals(detail.getPaymentClient())) {
-            redissonClient.getBucket(CacheNameEnum.STUDENT_SUBJECT_ITEM.getRedisKey(detail.getUserId())).delete();
+            //redissonClient.getBucket(CacheNameEnum.STUDENT_SUBJECT_ITEM.getRedisKey(detail.getUserId())).delete();
             redissonClient.getBucket(CacheNameEnum.STUDENT_TOTAL.getRedisKey(detail.getUserId())).delete();
         } else if (ClientEnum.TEACHER.getCode().equals(detail.getPaymentClient())) {
             redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(detail.getUserId())).delete();

+ 23 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserWithdrawalServiceImpl.java

@@ -2,6 +2,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.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dao.SysUserContractRecordDao;
@@ -83,11 +84,11 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
     public IPage<UserWithdrawalVo> selectPage(IPage<UserWithdrawalVo> page, TeacherWithdrawalSearch query) {
         List<UserWithdrawalVo> withdrawalVoList = baseMapper.selectPage(page, query);
         withdrawalVoList.forEach(o -> {
-            if(AuthStatusEnum.DOING.equals(o.getAuthStatus()) || TradeStatusEnum.pending.equals(o.getTradeStatus())){
+            if (AuthStatusEnum.DOING.equals(o.getAuthStatus()) || TradeStatusEnum.pending.equals(o.getTradeStatus())) {
                 o.setWithdrawStatus("DOING");
-            }else if(TradeStatusEnum.succeeded.equals(o.getTradeStatus())){
+            } else if (TradeStatusEnum.succeeded.equals(o.getTradeStatus())) {
                 o.setWithdrawStatus("SUCCESS");
-            }else{
+            } else {
                 o.setWithdrawStatus("FAILED");
             }
             o.setBankCard(ValueUtil.fuzzyBankCard(o.getBankCard()));
@@ -196,6 +197,19 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
     @Transactional(rollbackFor = Exception.class)
     public HttpResponseResult<Boolean> batchAuth(AuthOperaReq authOperaReq, SysUser sysUser) {
         Long[] ids = StringUtil.toLongArray(StringPool.COMMA, authOperaReq.getId());
+        //todo 先判断三方余额是否充足,不足直接抛异常
+        List<UserWithdrawal> userWithdrawals = baseMapper.selectList(Wrappers.<UserWithdrawal>lambdaQuery()
+                .in(UserWithdrawal::getId, ids)
+                .ne(UserWithdrawal::getAuthStatus, AuthStatusEnum.DOING));
+        //总提现金额
+        BigDecimal totalAmount = BigDecimal.ZERO;
+        for (UserWithdrawal withdrawal : userWithdrawals) {
+            if(null != withdrawal.getActualAmount()
+                    && BigDecimal.ZERO.compareTo(withdrawal.getActualAmount())<=0){
+                totalAmount = totalAmount.add(withdrawal.getActualAmount());
+            }
+        }
+
         for (Long id : ids) {
             AuthOperaReq param = new AuthOperaReq();
             param.setId(id.toString());
@@ -228,10 +242,8 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
         build.setUpdateTime(new Date());
         build.setAuthTime(new Date());
 
-        //请求三方
         SysUser withdrawalUser = sysUserService.findUserById(build.getUserId());
         if (authOperaReq.getPass()) {
-            //请求三方接口
             //交易流水号生成
             Long transNo = idGeneratorService.generatorId("withdrawNo");
 
@@ -298,6 +310,11 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
         }
     }
 
+    @Override
+    public UserWithdrawalVo totalAmount() {
+        return baseMapper.totalAmount();
+    }
+
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -350,7 +367,7 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
             userAccountService.accountChange(accountRecordDto);
 
             //发生结算失败通知
-            unpassSend(detail.getUserId(), detail.getPhone(), "结算失败,请重新提交。");
+            unpassSend(detail.getUserId(), detail.getPhone(), callback.getErrorMsg());
         } else {
             return;
         }

+ 1 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseGroupMapper.xml

@@ -952,5 +952,6 @@
                 AND endTime &lt;= #{param.endTime}
             </if>
         </where>
+        GROUP BY courseId
     </select>
 </mapper>

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

@@ -457,6 +457,7 @@
             u.avatar_ AS cover,
             g.subject_id_ AS subjectId,
             b.name_ AS subjectName,
+            ig.id_ AS imGroupId,
             (r.student_replied_ IS NOT NULL) AS studentReplied,
             (r.teacher_replied_ IS NOT NULL) AS teacherReplied
         FROM course_schedule s
@@ -464,6 +465,7 @@
         LEFT JOIN course_group g ON s.course_group_id_ = g.id_
         LEFT JOIN `subject` b ON g.subject_id_ = b.id_
         LEFT JOIN course_schedule_replied r ON s.id_ = r.course_schedule_id_
+        LEFT JOIN im_group ig ON ig.course_group_id_ = g.id_
         WHERE s.lock_=0
         AND s.status_ IN ('ING','NOT_START','COMPLETE')
         AND s.id_ IN
@@ -484,12 +486,14 @@
             g.background_pic_ AS cover,
             g.subject_id_ AS subjectId,
             sb.name_ AS subjectName,
+            ig.id_ AS imGroupId,
             (r.student_replied_ IS NOT NULL) AS studentReplied,
             (r.teacher_replied_ IS NOT NULL) AS teacherReplied
         FROM course_schedule s
         LEFT JOIN course_group g ON s.course_group_id_ = g.id_
         LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
         LEFT JOIN course_schedule_replied r ON s.id_ = r.course_schedule_id_
+        LEFT JOIN im_group ig ON ig.course_group_id_ = g.id_
         WHERE s.lock_=0
         AND s.status_ IN ('ING','NOT_START','COMPLETE')
         AND s.id_ IN

+ 1 - 8
cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherFreeTimeMapper.xml

@@ -107,17 +107,10 @@
             p.subject_name_ AS subjectName,
             p.subject_price_ AS subjectPrice
         FROM teacher_free_time f
-                 LEFT JOIN teacher_subject_price p ON f.id_=p.teacher_free_time_id
+        LEFT JOIN teacher_subject_price p ON f.id_=p.teacher_free_time_id
         WHERE f.teacher_id_=#{teacherId}
         AND f.default_flag_=1
         AND f.enable_flag_=1
-        AND f.monday_ IS NOT NULL
-        AND f.tuesday_ IS NOT NULL
-        AND f.wednesday_ IS NOT NULL
-        AND f.thursday_ IS NOT NULL
-        AND f.friday_ IS NOT NULL
-        AND f.saturday_ IS NOT NULL
-        AND f.sunday_ IS NOT NULL
     </select>
     <select id="getTeacherFreeTime" resultType="com.yonge.cooleshow.biz.dal.entity.TeacherFreeTime">
         SELECT * FROM teacher_free_time WHERE default_flag_=1

+ 5 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserWithdrawalMapper.xml

@@ -143,4 +143,9 @@
           and auth_status_ in ('DOING','PASS') and trade_status_ != 'failed'
         and to_days(create_time_) = to_days(now())
     </select>
+
+    <select id="totalAmount" resultType="com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo">
+        select sum(actual_amount_) as actual_amount_ from user_withdrawal
+        where auth_status_ = 'DOING'
+    </select>
 </mapper>

+ 4 - 15
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/StudentLiveRoomController.java

@@ -5,17 +5,16 @@ import com.alibaba.fastjson.JSONObject;
 import com.yonge.cooleshow.biz.dal.entity.ImUserStateSync;
 import com.yonge.cooleshow.biz.dal.entity.RoomInfoCache;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
-import com.yonge.cooleshow.biz.dal.vo.RoomVo;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
-import io.swagger.annotations.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 直播房间与课程的关系表表(LiveRoom)表控制层
@@ -35,26 +34,16 @@ public class StudentLiveRoomController extends BaseController {
     private LiveRoomService liveRoomService;
 
     /**
-     * 根据房间uid查询房间信息
-     *
-     * @param roomUid 房间uid
-     */
-    @GetMapping("queryRoomInfo")
-    public HttpResponseResult<RoomVo> queryRoomInfo(@RequestParam("roomUid") String roomUid) {
-        return succeed(liveRoomService.queryRoomInfo(roomUid));
-    }
-
-    /**
      * 校验房间信息,及个人信息
      *
      * @param roomUid 房间uid
      */
     @GetMapping("/studentCheckRoomInfo")
-    public HttpResponseResult<RoomVo> studentCheckRoomInfo(@RequestParam("roomUid") String roomUid) {
+    public HttpResponseResult<RoomInfoCache> studentCheckRoomInfo(@RequestParam("roomUid") String roomUid) {
         return succeed(liveRoomService.studentCheckRoomInfo(roomUid));
     }
 
-    @ApiOperation("进入房间")
+    @ApiOperation("观看者-进入房间")
     @GetMapping(value = "/joinRoom")
     public HttpResponseResult<RoomInfoCache> joinRoom(String roomUid, Long userId) {
         return succeed(liveRoomService.joinRoom(roomUid, userId));

+ 14 - 8
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherLiveRoomController.java

@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.yonge.cooleshow.biz.dal.entity.ImUserStateSync;
 import com.yonge.cooleshow.biz.dal.entity.RoomInfoCache;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
-import com.yonge.cooleshow.biz.dal.vo.RoomVo;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import io.swagger.annotations.*;
@@ -39,9 +38,9 @@ public class TeacherLiveRoomController extends BaseController {
      *
      * @param roomUid 房间uid
      */
-    @GetMapping("queryRoomInfo")
-    public HttpResponseResult<RoomVo> queryRoomInfo(@RequestParam("roomUid") String roomUid) {
-        return succeed(liveRoomService.queryRoomInfo(roomUid));
+    @GetMapping("/speakerCheckRoomInfo")
+    public HttpResponseResult<RoomInfoCache> speakerCheckRoomInfo(@RequestParam("roomUid") String roomUid) {
+        return succeed(liveRoomService.speakerCheckRoomInfo(roomUid));
     }
 
     @ApiImplicitParams({
@@ -58,15 +57,15 @@ public class TeacherLiveRoomController extends BaseController {
     @ApiOperation("同步点赞数量")
     @GetMapping("/syncLike")
     public HttpResponseResult<Object> syncLike(@ApiParam(value = "房间uid", required = true) String roomUid,
-                                       @ApiParam(value = "点赞数", required = true) Integer likeNum) {
+                                               @ApiParam(value = "点赞数", required = true) Integer likeNum) {
         liveRoomService.syncLike(roomUid, likeNum);
         return succeed();
     }
 
-    @ApiOperation("进入房间")
+    @ApiOperation("主讲人-进入房间")
     @GetMapping(value = "/speakerJoinRoom")
-    public HttpResponseResult<RoomInfoCache> speakerJoinRoom(String roomUid, Long userId) {
-        return succeed(liveRoomService.speakerJoinRoom(roomUid, userId));
+    public HttpResponseResult<RoomInfoCache> speakerJoinRoom(String roomUid) {
+        return succeed(liveRoomService.speakerJoinRoom(roomUid));
     }
 
     @ApiOperation("定时任务-创建房间-直播间")
@@ -87,6 +86,13 @@ public class TeacherLiveRoomController extends BaseController {
         liveRoomService.destroyExpiredPracticeRoom();
     }
 
+    @ApiOperation("手动关闭直播间")
+    @GetMapping("/destroyLiveRoom")
+    public HttpResponseResult<Object> destroyLiveRoom(@ApiParam(value = "房间uid", required = true) String roomUid) {
+        liveRoomService.destroyLiveRoom(roomUid);
+        return succeed();
+    }
+
     /**
      * 同步融云用户状态变更
      *