33333333333
This commit is contained in:
2
doc/2024-02-13.sql
Normal file
2
doc/2024-02-13.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE `cai_anchor` ADD COLUMN `hidden_status` tinyint NOT NULL DEFAULT 0 COMMENT '是否隐藏状态';
|
||||||
|
ALTER TABLE `cai_pay_trd_config` ADD COLUMN `for_num` tinyint NOT NULL DEFAULT 1 COMMENT '轮训次数';
|
||||||
@@ -90,6 +90,11 @@ public class Anchor implements Serializable{
|
|||||||
*/
|
*/
|
||||||
private LocalDateTime topShowRank;
|
private LocalDateTime topShowRank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐藏状态 开启后则普通用户无法在首页看到,主播自己不受影响,且该用户无法收到接收到通话邀请
|
||||||
|
*/
|
||||||
|
private Integer hiddenStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否允许 发布群发
|
* 是否允许 发布群发
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class PayTrdConfig implements Serializable {
|
|||||||
* 秘钥
|
* 秘钥
|
||||||
*/
|
*/
|
||||||
private String sign;
|
private String sign;
|
||||||
|
private Integer forNum;
|
||||||
|
|
||||||
private String aliProductId;
|
private String aliProductId;
|
||||||
private String wxProductId;
|
private String wxProductId;
|
||||||
|
|||||||
@@ -27,5 +27,7 @@ public class AnchorListQuery {
|
|||||||
@Schema(hidden = true)
|
@Schema(hidden = true)
|
||||||
private Integer onlineStatus;
|
private Integer onlineStatus;
|
||||||
@Schema(hidden = true)
|
@Schema(hidden = true)
|
||||||
|
private boolean hiddenStatusUser = false;
|
||||||
|
@Schema(hidden = true)
|
||||||
private List<Long> ignoreUserIds;
|
private List<Long> ignoreUserIds;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ public class HomeManager {
|
|||||||
pageQuery.resetPageSize();
|
pageQuery.resetPageSize();
|
||||||
query.setOnlineStatus(1);
|
query.setOnlineStatus(1);
|
||||||
query.setOpenVideoStatus(1);
|
query.setOpenVideoStatus(1);
|
||||||
|
Anchor anchor = anchorService.getByUserId(LoginHelper.getUserId());
|
||||||
|
if(anchor != null && anchor.getHiddenStatus() == 1){
|
||||||
|
query.setHiddenStatusUser(true);
|
||||||
|
}
|
||||||
Page<AnchorListVo> page = anchorService.pageAppV2(pageQuery, query);
|
Page<AnchorListVo> page = anchorService.pageAppV2(pageQuery, query);
|
||||||
return page.getRecords();
|
return page.getRecords();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.ruoyi.cai.notice;
|
package com.ruoyi.cai.notice;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.ruoyi.cai.domain.Anchor;
|
||||||
import com.ruoyi.cai.notice.data.ImVideoAttachR;
|
import com.ruoyi.cai.notice.data.ImVideoAttachR;
|
||||||
import com.ruoyi.cai.notice.data.ImVideoR;
|
import com.ruoyi.cai.notice.data.ImVideoR;
|
||||||
import com.ruoyi.cai.notice.data.child.ImVideoAttachData;
|
import com.ruoyi.cai.notice.data.child.ImVideoAttachData;
|
||||||
import com.ruoyi.cai.notice.data.child.ImVideoData;
|
import com.ruoyi.cai.notice.data.child.ImVideoData;
|
||||||
|
import com.ruoyi.cai.service.AnchorService;
|
||||||
|
import com.ruoyi.cai.ws.manager.WsAnchorManager;
|
||||||
import com.ruoyi.yunxin.YunExecutor;
|
import com.ruoyi.yunxin.YunExecutor;
|
||||||
import com.ruoyi.yunxin.Yunxin;
|
import com.ruoyi.yunxin.Yunxin;
|
||||||
import com.ruoyi.cai.notice.enums.CallNoticeEnum;
|
import com.ruoyi.cai.notice.enums.CallNoticeEnum;
|
||||||
@@ -21,12 +24,22 @@ public class YunxinWsServiceV2 {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Yunxin yunxin;
|
private Yunxin yunxin;
|
||||||
|
@Autowired
|
||||||
|
private AnchorService anchorService;
|
||||||
|
@Autowired
|
||||||
|
private WsAnchorManager wsAnchorManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统自定义消息通知主播接听电话
|
* 系统自定义消息通知主播接听电话
|
||||||
*/
|
*/
|
||||||
public void sendCallAsync(Long roomId,Long callId,Long receiverId){
|
public void sendCallAsync(Long roomId,Long callId,Long receiverId){
|
||||||
YunExecutor.YUN_EXECUTOR.execute(() -> {
|
YunExecutor.YUN_EXECUTOR.execute(() -> {
|
||||||
|
// 检查主播是否被特殊标记
|
||||||
|
boolean anchorIsHidden = wsAnchorManager.anchorIsHidden(receiverId);
|
||||||
|
if(anchorIsHidden){
|
||||||
|
log.warn("主播接收到邀请,但是被强制拦截 receiverId={} ", receiverId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ImVideoAttachData data = new ImVideoAttachData();
|
ImVideoAttachData data = new ImVideoAttachData();
|
||||||
data.setRoomid(roomId);
|
data.setRoomid(roomId);
|
||||||
ImVideoAttachR<ImVideoAttachData> res = ImVideoAttachR.ok(data);
|
ImVideoAttachR<ImVideoAttachData> res = ImVideoAttachR.ok(data);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class PayTrdConfigServiceImpl extends ServiceImpl<PayTrdConfigMapper, Pay
|
|||||||
private final static Map<BigDecimal, AtomicLong> ACCOUNT_MAP = new ConcurrentHashMap<>();
|
private final static Map<BigDecimal, AtomicLong> ACCOUNT_MAP = new ConcurrentHashMap<>();
|
||||||
private final static List<PayTrdConfig> PAY_TRD_CONFIG_LIST = new CopyOnWriteArrayList<>();
|
private final static List<PayTrdConfig> PAY_TRD_CONFIG_LIST = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
|
private final static AtomicLong NO_ACCOUNT_FLAG = new AtomicLong(0);
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init(){
|
public void init(){
|
||||||
@@ -78,7 +79,7 @@ public class PayTrdConfigServiceImpl extends ServiceImpl<PayTrdConfigMapper, Pay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(payTrdConfig == null){
|
if(payTrdConfig == null){
|
||||||
payTrdConfig = getConfig(dto.getPrice(),wx);
|
payTrdConfig = getConfigV2(wx);
|
||||||
}
|
}
|
||||||
if(payTrdConfig == null){
|
if(payTrdConfig == null){
|
||||||
throw new ServiceException("未开启支付,请联系客服");
|
throw new ServiceException("未开启支付,请联系客服");
|
||||||
@@ -92,6 +93,43 @@ public class PayTrdConfigServiceImpl extends ServiceImpl<PayTrdConfigMapper, Pay
|
|||||||
return trdPayManager.createOrderAliMerge(dto, payTrdConfig, typeEnum, wx);
|
return trdPayManager.createOrderAliMerge(dto, payTrdConfig, typeEnum, wx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无价格版本
|
||||||
|
* @param wx
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static PayTrdConfig getConfigV2(boolean wx){
|
||||||
|
List<PayTrdConfig> list = new ArrayList<>();
|
||||||
|
for(PayTrdConfig payTrdConfig : PAY_TRD_CONFIG_LIST){
|
||||||
|
if(wx){
|
||||||
|
if(payTrdConfig.getEnableWxStatus() == 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(payTrdConfig.getEnableStatus() == 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(payTrdConfig.getForNum() < 1){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.add(payTrdConfig);
|
||||||
|
}
|
||||||
|
if(list.isEmpty()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Integer totalWeight = list.stream().map(PayTrdConfig::getForNum).reduce(0, Integer::sum);
|
||||||
|
long position = NO_ACCOUNT_FLAG.getAndIncrement();
|
||||||
|
long round = position % totalWeight;
|
||||||
|
for(PayTrdConfig payTrdConfig : list){
|
||||||
|
if(round < payTrdConfig.getForNum()){
|
||||||
|
return payTrdConfig;
|
||||||
|
}
|
||||||
|
round = round - payTrdConfig.getForNum();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private PayTrdConfig getConfig(BigDecimal amount,boolean wx){
|
private PayTrdConfig getConfig(BigDecimal amount,boolean wx){
|
||||||
List<PayTrdConfig> list = new ArrayList<>();
|
List<PayTrdConfig> list = new ArrayList<>();
|
||||||
for(PayTrdConfig payTrdConfig : PAY_TRD_CONFIG_LIST){
|
for(PayTrdConfig payTrdConfig : PAY_TRD_CONFIG_LIST){
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.ruoyi.cai.ws.constant.RoomStatusEnums;
|
|||||||
import com.ruoyi.cai.ws.dto.WsRMsgGen;
|
import com.ruoyi.cai.ws.dto.WsRMsgGen;
|
||||||
import com.ruoyi.cai.ws.handler.AbstractMessageHandle;
|
import com.ruoyi.cai.ws.handler.AbstractMessageHandle;
|
||||||
import com.ruoyi.cai.ws.handler.IMessageHandler;
|
import com.ruoyi.cai.ws.handler.IMessageHandler;
|
||||||
|
import com.ruoyi.cai.ws.manager.WsAnchorManager;
|
||||||
import com.ruoyi.cai.ws.service.RoomService;
|
import com.ruoyi.cai.ws.service.RoomService;
|
||||||
import com.ruoyi.cai.notice.enums.CallNoticeEnum;
|
import com.ruoyi.cai.notice.enums.CallNoticeEnum;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -35,6 +36,8 @@ public class CancelMessageHandler extends AbstractMessageHandle implements IMess
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AnchorService anchorService;
|
private AnchorService anchorService;
|
||||||
|
@Autowired
|
||||||
|
private WsAnchorManager anchorManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOn(Room room, FdCtxData fdCtxData, JSONObject map) {
|
public void processOn(Room room, FdCtxData fdCtxData, JSONObject map) {
|
||||||
@@ -56,7 +59,10 @@ public class CancelMessageHandler extends AbstractMessageHandle implements IMess
|
|||||||
// IM
|
// IM
|
||||||
Long receiverId = room.getReceiverId();
|
Long receiverId = room.getReceiverId();
|
||||||
Long callerId = room.getCallId();
|
Long callerId = room.getCallId();
|
||||||
yunxinWsService.sendToCallNotify(receiverId,callerId, CallNoticeEnum.CLOSE,0L);
|
boolean anchorIsHidden = anchorManager.anchorIsHidden(receiverId);
|
||||||
|
if(!anchorIsHidden){
|
||||||
|
yunxinWsService.sendToCallNotify(receiverId,callerId, CallNoticeEnum.CLOSE,0L);
|
||||||
|
}
|
||||||
// 更新房间状态
|
// 更新房间状态
|
||||||
userCallService.update(Wrappers.lambdaUpdate(UserCall.class)
|
userCallService.update(Wrappers.lambdaUpdate(UserCall.class)
|
||||||
.eq(UserCall::getId,roomId)
|
.eq(UserCall::getId,roomId)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ruoyi.cai.ws.manager;
|
||||||
|
|
||||||
|
import com.ruoyi.cai.domain.Anchor;
|
||||||
|
import com.ruoyi.cai.service.AnchorService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class WsAnchorManager {
|
||||||
|
@Autowired
|
||||||
|
private AnchorService anchorService;
|
||||||
|
|
||||||
|
public boolean anchorIsHidden(Long userId){
|
||||||
|
Anchor anchor = anchorService.getByUserId(userId);
|
||||||
|
if(anchor != null && anchor.getHiddenStatus() == 1){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -106,6 +106,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="query.openVideoStatus != null">
|
<if test="query.openVideoStatus != null">
|
||||||
and t2.open_video_status = #{query.openVideoStatus}
|
and t2.open_video_status = #{query.openVideoStatus}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="!query.hiddenStatusUser">
|
||||||
|
and t2.hidden_status = 0
|
||||||
|
</if>
|
||||||
<if test="query.type != null">
|
<if test="query.type != null">
|
||||||
<if test="query.type == 0">
|
<if test="query.type == 0">
|
||||||
order by t2.top_show_rank desc
|
order by t2.top_show_rank desc
|
||||||
|
|||||||
Reference in New Issue
Block a user