Jelajahi Sumber

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

liujunchi 3 tahun lalu
induk
melakukan
1c19cdc2d1

+ 1 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/open/UserOrderClient.java

@@ -80,6 +80,7 @@ public class UserOrderClient extends BaseController {
             @PathVariable("payMethod") String payMethod,
             HttpServletRequest request
     ) {
+        //支付回调:openType is ORIGINAL ,paymentClient is STUDENT,payChannel is ali_app,payMethod is executePayment
         log.info("支付回调:openType is {} ,paymentClient is {},payChannel is {},payMethod is {}", openType, client, payChannel, payMethod);
         BaseResult<PaymentCallBack> res = paymentClient.analysisNotice(
                 OpenEnum.valueOf(openType), PaymentClientEnum.valueOf(client),

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

@@ -8,8 +8,10 @@ public class ImRoomMessage extends BaseMessage {
 
     //objectName 类型-观看者退出房间
     public static final String RC_CHATROOM_LEAVE = "RC:Chatroom:Leave";
-    //objectName 类型-观看者数量-该消息只有主播端接
+    //objectName 类型-观看者数量
     public static final String MEMBER_COUNT = "RC:Chatroom:MemberCountUp";
+    //objectName 类型-将所有人强制踢出房间
+    public static final String FORCED_OFFLINE = "RC:ForcedOffline";
 
     /**
      * 消息类型

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

@@ -1626,6 +1626,13 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         if (CollectionUtils.isNotEmpty(userList)) {
             List<CourseScheduleStudentVo> practiceList = userList.stream().filter(s -> s.getType().equals(CourseScheduleEnum.PRACTICE.getCode())).collect(Collectors.toList());
             if (CollectionUtils.isNotEmpty(practiceList)) {//陪练课
+                //校验评价是否存在
+                List<Long> ids = practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList());
+                List<CourseScheduleReplied> replieds = repliedDao.selectList(Wrappers.<CourseScheduleReplied>lambdaQuery().in(CourseScheduleReplied::getCourseScheduleId, ids));
+                if (CollectionUtils.isNotEmpty(replieds)) {
+                    List<Long> courseIds = replieds.stream().map(CourseScheduleReplied::getCourseScheduleId).collect(Collectors.toList());
+                    practiceList = practiceList.stream().filter(s -> !courseIds.contains(s.getCourseId())).collect(Collectors.toList());
+                }
                 //创建课程评论
                 repliedDao.insertBatch(practiceList);
 

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

@@ -253,7 +253,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         this.save(room);
         log.info("createTempLiveRoom>>>>>>room:{}", room.getRoomUid());
         //去融云创建房间及创建房间缓存信息
-        createLiveRoomInfo(room, sysUser);
+        this.createLiveRoomInfo(room, sysUser);
         return roomUid;
     }
 
@@ -263,15 +263,15 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     private void createLiveRoomInfo(LiveRoom room) {
         //查询主讲人信息
         SysUser sysUser = getSysUser(room.getSpeakerId());
-        createLiveRoomInfo(room, sysUser);
+        this.createLiveRoomInfo(room, sysUser);
     }
 
     private void createLiveRoomInfo(LiveRoom room, SysUser sysUser) {
         try {
             //生成主讲人信息
-            createRoomInfoCache(room, sysUser);
+            this.createRoomInfoCache(room, sysUser);
             //去融云创建房间
-            createLiveRoom(room.getRoomUid(), room.getRoomTitle());
+            this.createLiveRoom(room.getRoomUid(), room.getRoomTitle());
         } catch (Exception e) {
             throw new BizException("创建直播间失败!", e.getCause());
         }
@@ -352,7 +352,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             }
             //当前时间 大于 直播间过期时间
             if (now.getTime() >= expiredDate.getTime()) {
-                destroyLiveRoom(room);
+                this.destroyLiveRoom(room);
             }
         });
     }
@@ -366,7 +366,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     @Transactional(rollbackFor = Exception.class)
     public void destroyLiveRoom(String roomUId) {
         LiveRoom liveRoom = this.getOne(Wrappers.<LiveRoom>lambdaQuery().eq(LiveRoom::getRoomUid, roomUId));
-        destroyLiveRoom(liveRoom);
+        this.destroyLiveRoom(liveRoom);
     }
 
     /**
@@ -394,10 +394,23 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             });
         }
         //删除房间
-        ImDestroyLiveRoom(room.getRoomUid());
+        this.ImDestroyLiveRoom(room.getRoomUid());
         //修改房间状态
         room.setLiveState(2);
         this.updateById(room);
+        String speakerIdStr = room.getSpeakerId().toString();
+        //关闭直播间发送消息
+        ImRoomMessage message = new ImRoomMessage();
+        message.setFromUserId(speakerIdStr);
+        message.setToChatroomId(room.getRoomUid());
+        message.setObjectName(ImRoomMessage.FORCED_OFFLINE);
+        message.setContent(speakerIdStr);
+        try {
+            this.publishRoomMessage(message);
+            log.info("destroyLiveRoom>>>> FORCED_OFFLINE : {}", speakerIdStr);
+        } catch (Exception e) {
+            log.error("destroyLiveRoom>>>>  FORCED_OFFLINE {}", e.getMessage());
+        }
     }
 
     /**
@@ -507,7 +520,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             message.setObjectName(ImRoomMessage.RC_CHATROOM_LEAVE);
             message.setContent(userId);
             try {
-                publishRoomMessage(message);
+                this.publishRoomMessage(message);
                 log.info("opsRoom>>>> looker RC_CHATROOM_LEAVE : {}", userJsonStr);
             } catch (Exception e) {
                 log.error("opsRoom>>>>  looker error RC_CHATROOM_LEAVE {}", e.getMessage());
@@ -542,7 +555,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             }
             //查询老师是否有进入过放假,没有则写老师考勤表的进入时间
             if (Objects.isNull(teacherAttendance)) {
-                setTeacherAttendance(Long.parseLong(userIdStr), roomInfo.getCourseGroupId(), roomInfo.getCourseId());
+                this.setTeacherAttendance(Long.parseLong(userIdStr), roomInfo.getCourseGroupId(), roomInfo.getCourseId());
             }
             roomInfoCache.set(roomInfo);
             log.info("opsRoom>>>> join speakerCache {}", JSONObject.toJSONString(roomInfo));
@@ -616,12 +629,12 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      * @param roomUid 房间uid
      */
     public RoomInfoCache speakerJoinRoom(String roomUid) {
-        RoomInfoCache roomInfo = speakerCheckRoomInfo(roomUid);
+        RoomInfoCache roomInfo = this.speakerCheckRoomInfo(roomUid);
         Date now = new Date();
         roomInfo.setSpeakerState(0);
         roomInfo.setJoinRoomTime(now);
         //查询老师是否有进入过,没有则写老师考勤表的进入时间
-        setTeacherAttendance(roomInfo.getSpeakerId(), roomInfo.getCourseGroupId(), roomInfo.getCourseId());
+        this.setTeacherAttendance(roomInfo.getSpeakerId(), roomInfo.getCourseGroupId(), roomInfo.getCourseId());
         //记录当前用户对应的房间uid
         redissonClient.getBucket(LIVE_USER_ROOM.replace(USER_ID, roomInfo.getSpeakerId().toString())).set(roomUid, 2L, TimeUnit.DAYS);
         return roomInfo;
@@ -635,12 +648,12 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      */
     public RoomInfoCache joinRoom(String roomUid, Long userId) {
         //获取进入房间人员信息
-        SysUser sysUser = getSysUser(userId);
+        SysUser sysUser = this.getSysUser(userId);
         //校验信息
-        RoomInfoCache roomInfo = checkStudentRoom(roomUid, sysUser);
+        RoomInfoCache roomInfo = this.checkStudentRoom(roomUid, sysUser);
         Date now = new Date();
         //房间累计用户信息-指只要进入到该房间的用户都要记录
-        RMap<Long, String> roomTotalUser = getTotalUserCache(roomUid);
+        RMap<Long, String> roomTotalUser = this.getTotalUserCache(roomUid);
         //判断是否第一次进房间
         RoomUserInfoCache userInfo;
         if (roomTotalUser.containsKey(userId)) {
@@ -653,7 +666,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             userInfo.setUserName(sysUser.getRealName());
             userInfo.setFirstJoinTime(now);
             //查询学生是否有进入过,没有则写学生考勤表的进入时间
-            setStudentAttendance(userId, roomInfo.getCourseGroupId(), roomInfo.getCourseId());
+            this.setStudentAttendance(userId, roomInfo.getCourseGroupId(), roomInfo.getCourseId());
         }
         userInfo.setDynamicJoinTime(now);
         //用户json信息
@@ -661,7 +674,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         //写入人员缓存
         roomTotalUser.fastPut(userId, userJsonStr);
         //写入在线人员缓存
-        RMap<Long, String> onlineUserCache = getOnlineUserCache(roomUid);
+        RMap<Long, String> onlineUserCache = this.getOnlineUserCache(roomUid);
         onlineUserCache.fastPut(userId, userJsonStr);
         log.info("joinRoom>>>> userInfo: {}", userJsonStr);
         //向直播间发送当前在线人数消息
@@ -782,7 +795,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         message.setContent(sendMap);
         //发送消息
         try {
-            publishRoomMessage(message);
+            this.publishRoomMessage(message);
             log.info("sendOnlineUserCount>>>> message: {}", JSONObject.toJSONString(message));
         } catch (Exception e) {
             log.error("sendOnlineUserCount>>>> error {}", e.getMessage());

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

@@ -205,6 +205,9 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
             } else if (TradeStatusEnum.failed.equals(data.getStatus())) {//支付失败
                 paymentFailedHandle(data, data.getErrMsg());
             }
+        }else if (!userOrderVo.getStatus().equals(OrderStatusEnum.PAID)) {
+            //原路退还
+            orderRefundService.orderFailRefund(data, userOrderVo.getOrderNo(), "订单已超时,金额原路退回");
         }
     }
 

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

@@ -335,7 +335,39 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
                 }
             }
         }
-        return doOrderRefund(orderRefunds);
+
+        RefundBill refundBill = new RefundBill(orderPayment.getOpenType(),
+                PaymentClientEnum.valueOf(orderPayment.getPaymentClient()), orderPayment.getPayChannel());
+        refundBill.setTradeNo(data.getId());
+        refundBill.setPaymentNo(data.getPaymentNo());
+
+        //单号生成
+        Long billNo = idGeneratorService.generatorId("billNo");
+        refundBill.setRefundNo(billNo.toString());
+
+        refundBill.setOrderAmt(orderPayment.getPayAmt());
+        refundBill.setRefundAmt(orderPayment.getPayAmt());
+        refundBill.setReason(reason);
+
+        BaseResult<RefundBill> refundBillBaseResult = paymentClient.refundPayment(refundBill);
+        log.info("退款返回: {} ", JSONObject.toJSONString(refundBillBaseResult));
+
+        //入退款单表
+        UserOrderRefundBill orderRefundBill = new UserOrderRefundBill();
+        orderRefundBill.setRefundId(orderRefunds.getId());
+        orderRefundBill.setBillNo(billNo.toString());
+        orderRefundBill.setRefundAmt(orderRefunds.getActualAmount());
+        if (refundBillBaseResult.getStatus()) {
+            orderRefundBill.setTransNo(refundBillBaseResult.getData().getId());
+            orderRefundBill.setStatus(TradeStatusEnum.pending);
+        } else {
+            orderRefundBill.setStatus(TradeStatusEnum.failed);
+            orderRefundBill.setPayFailMsg(refundBillBaseResult.getMsg());
+        }
+
+        refundBillService.save(orderRefundBill);
+        updateById(orderRefunds);
+        return HttpResponseResult.succeed(orderRefundBill);
     }
 
 

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

@@ -359,7 +359,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
         search.setStatus(OrderStatusEnum.PAYING.getCode());
         search.setEndTime(LocalDateTime.now().minusMinutes(120));
         //查询待支付中订单
-        List<UserOrderVo> payingOrderList = baseMapper.selectAllList(search);
+        List<UserOrderVo> payingOrderList = baseMapper.selectPendingList(search);
         for (UserOrderVo orderVo : payingOrderList) {
             //取消订单要获取锁,防止在轮询取消时,用户修改订单状态
             boolean b = DistributedLock.of(redissonClient)