123
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
package com.ruoyi.test.business;
|
package com.ruoyi.test.business;
|
||||||
|
|
||||||
|
import com.ruoyi.cai.domain.User;
|
||||||
import com.ruoyi.cai.domain.UserCount;
|
import com.ruoyi.cai.domain.UserCount;
|
||||||
|
import com.ruoyi.cai.im.ImManager;
|
||||||
import com.ruoyi.cai.service.UserCountService;
|
import com.ruoyi.cai.service.UserCountService;
|
||||||
|
import com.ruoyi.cai.service.UserService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -15,6 +18,10 @@ public class UserTest {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserCountService userCountService;
|
private UserCountService userCountService;
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private ImManager imManager;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test(){
|
public void test(){
|
||||||
@@ -23,4 +30,12 @@ public class UserTest {
|
|||||||
userCountService.reset(userCount.getUserId());
|
userCountService.reset(userCount.getUserId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void refreshIm(){
|
||||||
|
List<User> list = userService.list();
|
||||||
|
for (User user : list) {
|
||||||
|
imManager.updateImInfo(user.getId(),user.getAvatar(),user.getNickname());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ import com.ruoyi.common.exception.ServiceException;
|
|||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.common.utils.ip.AddressUtils;
|
|
||||||
import com.ruoyi.system.service.SysLoginService;
|
import com.ruoyi.system.service.SysLoginService;
|
||||||
import com.ruoyi.yunxin.Yunxin;
|
|
||||||
import com.ruoyi.yunxin.client.ImUserClient;
|
import com.ruoyi.yunxin.client.ImUserClient;
|
||||||
import com.ruoyi.yunxin.req.CreateUserReq;
|
import com.ruoyi.yunxin.req.CreateUserReq;
|
||||||
import com.ruoyi.yunxin.req.UpdateTokenReq;
|
import com.ruoyi.yunxin.req.UpdateTokenReq;
|
||||||
@@ -135,21 +133,20 @@ public class CaiLoginManager {
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
awardManager.giveRegisterAsync(user.getId());
|
awardManager.giveRegisterAsync(user.getId());
|
||||||
if(user.getInviteId() != null){
|
if(caiUser.getInviteId() != null){
|
||||||
User finalUser = user;
|
User finalUser = user;
|
||||||
ExecutorConstant.COMMON_EXECUTOR.execute(() -> dealInviteId(finalUser,true));
|
ExecutorConstant.COMMON_EXECUTOR.execute(() -> dealInviteId(finalUser,caiUser.getInviteId(), true));
|
||||||
}
|
}
|
||||||
return login(user);
|
return login(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void dealInviteId(User user, boolean openIgnore){
|
public void dealInviteId(User user, String inviteUserCode, boolean openIgnore){
|
||||||
Long inviteId = user.getInviteId();
|
if(StringUtils.isEmpty(inviteUserCode)){
|
||||||
if(inviteId == null){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
User inviteUser = userService.getById(inviteId);
|
User inviteUser = userService.getByUserCode(inviteUserCode);
|
||||||
if(inviteUser == null){
|
if(inviteUser == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -167,21 +164,24 @@ public class CaiLoginManager {
|
|||||||
if(!sj){
|
if(!sj){
|
||||||
InviteIgnoreData data = new InviteIgnoreData();
|
InviteIgnoreData data = new InviteIgnoreData();
|
||||||
data.setUserId(user.getId());
|
data.setUserId(user.getId());
|
||||||
data.setInviteId(inviteId);
|
data.setInviteId(inviteUserCode);
|
||||||
ignoreDataService.saveIgnoreData(IgnoreDataTypeEnum.INVITE,inviteUser.getId(),data);
|
ignoreDataService.saveIgnoreData(IgnoreDataTypeEnum.INVITE,inviteUser.getId(),data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
userService.update(Wrappers.lambdaUpdate(User.class)
|
||||||
|
.eq(User::getId, user.getId())
|
||||||
|
.eq(User::getInviteId, inviteUser.getId()));
|
||||||
UserInvite check = userInviteService.getByUserId(user.getId());
|
UserInvite check = userInviteService.getByUserId(user.getId());
|
||||||
if(check == null){
|
if(check == null){
|
||||||
UserInvite userInvite = new UserInvite();
|
UserInvite userInvite = new UserInvite();
|
||||||
userInvite.setUserId(user.getId());
|
userInvite.setUserId(user.getId());
|
||||||
userInvite.setInviteId(user.getInviteId());
|
userInvite.setInviteId(inviteUser.getInviteId());
|
||||||
userInviteService.save(userInvite);
|
userInviteService.save(userInvite);
|
||||||
}else{
|
}else{
|
||||||
userInviteService.update(Wrappers.lambdaUpdate(UserInvite.class)
|
userInviteService.update(Wrappers.lambdaUpdate(UserInvite.class)
|
||||||
.eq(UserInvite::getId,check.getId())
|
.eq(UserInvite::getId,check.getId())
|
||||||
.set(UserInvite::getInviteId,user.getInviteId())
|
.set(UserInvite::getInviteId,inviteUser.getInviteId())
|
||||||
.set(UserInvite::getRewardCoinTotal,0L));
|
.set(UserInvite::getRewardCoinTotal,0L));
|
||||||
}
|
}
|
||||||
// 处理工会
|
// 处理工会
|
||||||
@@ -195,7 +195,7 @@ public class CaiLoginManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(union == null){
|
if(union == null){
|
||||||
log.info("邀请人没有工会,无法入会 inviteId={}",inviteId);
|
log.info("邀请人没有工会,无法入会 inviteUserCode={}",inviteUserCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UnionUser checkUnionUser = unionUserService.getByUserId(user.getId());
|
UnionUser checkUnionUser = unionUserService.getByUserId(user.getId());
|
||||||
@@ -262,7 +262,6 @@ public class CaiLoginManager {
|
|||||||
add.setMobile(user.getUsername());
|
add.setMobile(user.getUsername());
|
||||||
add.setGender(GenderEnum.NONE.getCode());
|
add.setGender(GenderEnum.NONE.getCode());
|
||||||
add.setAvatar(GenderEnum.NONE.getDefaultAvatar());
|
add.setAvatar(GenderEnum.NONE.getDefaultAvatar());
|
||||||
add.setInviteId(user.getInviteId());
|
|
||||||
add.setImToken(IdUtil.simpleUUID());
|
add.setImToken(IdUtil.simpleUUID());
|
||||||
userService.save(add);
|
userService.save(add);
|
||||||
CreateUserReq req = new CreateUserReq();
|
CreateUserReq req = new CreateUserReq();
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ public class CaiRegisterUser {
|
|||||||
@NotEmpty(message = "验证码不能为空")
|
@NotEmpty(message = "验证码不能为空")
|
||||||
private String code;
|
private String code;
|
||||||
@Schema(description = "邀请人ID")
|
@Schema(description = "邀请人ID")
|
||||||
private Long inviteId;
|
private String inviteId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import java.time.LocalDateTime;
|
|||||||
public class UserUpdateReq {
|
public class UserUpdateReq {
|
||||||
@Schema(description = "用户ID",hidden = true)
|
@Schema(description = "用户ID",hidden = true)
|
||||||
private Long userId;
|
private Long userId;
|
||||||
@Schema(description = "邀请人ID")
|
@Schema(description = "邀请人用户编号")
|
||||||
private Long inviteId;
|
private String inviteId;
|
||||||
@Schema(description = "城市")
|
@Schema(description = "城市")
|
||||||
private Integer cityId;
|
private Integer cityId;
|
||||||
@Schema(description = "昵称")
|
@Schema(description = "昵称")
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class InviteIgnoreData {
|
public class InviteIgnoreData {
|
||||||
private Long userId;
|
private Long userId;
|
||||||
private Long inviteId;
|
private String inviteId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,15 +24,19 @@ public class ImManager {
|
|||||||
if(userId == null){
|
if(userId == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotBlank(avatar) && StringUtils.isNotBlank(nickname)){
|
if(StringUtils.isBlank(avatar) && StringUtils.isBlank(nickname)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
UpdateUinfoReq uinfoReq = new UpdateUinfoReq();
|
UpdateUinfoReq uinfoReq = new UpdateUinfoReq();
|
||||||
uinfoReq.setAccid(userId+"");
|
uinfoReq.setAccid(userId+"");
|
||||||
if(StringUtils.isNotEmpty(avatar)){
|
if(StringUtils.isNotBlank(avatar)){
|
||||||
|
String icon = avatar;
|
||||||
|
if(!avatar.startsWith("http")){
|
||||||
String cosDomain = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
|
String cosDomain = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
|
||||||
uinfoReq.setIcon(cosDomain + avatar);
|
icon = cosDomain + avatar;
|
||||||
|
}
|
||||||
|
uinfoReq.setIcon(icon);
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotBlank(nickname)){
|
if(StringUtils.isNotBlank(nickname)){
|
||||||
uinfoReq.setName(nickname);
|
uinfoReq.setName(nickname);
|
||||||
|
|||||||
@@ -159,10 +159,6 @@ public class CurrentUserManager {
|
|||||||
updateFlag=true;
|
updateFlag=true;
|
||||||
updateYunxin=true;
|
updateYunxin=true;
|
||||||
}
|
}
|
||||||
if(res.getInviteId() != null && user.getInviteId() != null){
|
|
||||||
update.set(User::getInviteId,res.getInviteId());
|
|
||||||
user.setInviteId(res.getInviteId());
|
|
||||||
}
|
|
||||||
if(res.getBirthday() != null){
|
if(res.getBirthday() != null){
|
||||||
update.set(User::getBirthday,res.getBirthday());
|
update.set(User::getBirthday,res.getBirthday());
|
||||||
update.set(User::getAge, UserUtil.getAge(res.getBirthday()));
|
update.set(User::getAge, UserUtil.getAge(res.getBirthday()));
|
||||||
@@ -211,10 +207,9 @@ public class CurrentUserManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(res.getInviteId() != null && user.getInviteId() != null){
|
|
||||||
ExecutorConstant.COMMON_EXECUTOR.execute(() -> loginManager.dealInviteId(user,false));
|
|
||||||
}
|
}
|
||||||
|
if(res.getInviteId() != null && user.getInviteId() != null){
|
||||||
|
ExecutorConstant.COMMON_EXECUTOR.execute(() -> loginManager.dealInviteId(user, res.getInviteId(),false));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||||||
.eq(User::getId,userId)
|
.eq(User::getId,userId)
|
||||||
.set(User::getInviteId,inviteUser.getId()));
|
.set(User::getInviteId,inviteUser.getId()));
|
||||||
user = this.getById(userId);
|
user = this.getById(userId);
|
||||||
caiLoginManager.dealInviteId(user,false);
|
caiLoginManager.dealInviteId(user,inviteUsercode,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ public class AgreeMessageHandle extends AbstractMessageHandle implements IMessag
|
|||||||
String message = "提示:禁止任何涉黄、任何微信QQ引导到其它平台行为";
|
String message = "提示:禁止任何涉黄、任何微信QQ引导到其它平台行为";
|
||||||
sendToAll(room.getRoomId(), WsRMsgGen.startVideo(room.getRoomId(),0L),WsRMsgGen.sysNotice(message));
|
sendToAll(room.getRoomId(), WsRMsgGen.startVideo(room.getRoomId(),0L),WsRMsgGen.sysNotice(message));
|
||||||
try {
|
try {
|
||||||
Long callTime = roomService.getCallTime(room);
|
Long callCallTime = roomService.canCallTime(room);
|
||||||
sendToAll(room.getRoomId(),WsRMsgGen.canCallTime(callTime));
|
sendToAll(room.getRoomId(),WsRMsgGen.canCallTime(callCallTime));
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("发送可通话时长失败",e);
|
log.error("发送可通话时长失败",e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ public class RoomService {
|
|||||||
long blockAmount = roomData.getPayCoin() + roomData.getPayIncome();
|
long blockAmount = roomData.getPayCoin() + roomData.getPayIncome();
|
||||||
long totalAmount = account.getCoin()+account.getIncomeCoin() + blockAmount;
|
long totalAmount = account.getCoin()+account.getIncomeCoin() + blockAmount;
|
||||||
long totalSecond = (totalAmount / roomData.getCallPrice()) * 60;
|
long totalSecond = (totalAmount / roomData.getCallPrice()) * 60;
|
||||||
|
// log.info("总金额:{}, 锁定金额:{},单价:{},可拨打秒杀:{}",totalAmount, blockAmount, roomData.getCallPrice(), totalSecond);
|
||||||
long useTime = 0;
|
long useTime = 0;
|
||||||
if(roomData.getBeginTime() != null){
|
if(roomData.getBeginTime() != null){
|
||||||
useTime = DateUtil.currentSeconds() - roomData.getBeginTime();
|
useTime = DateUtil.currentSeconds() - roomData.getBeginTime();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class Yunxin {
|
|||||||
public YxDataR<YxCommonR> batchSendToNotice(List<Long> toUid, Object data){
|
public YxDataR<YxCommonR> batchSendToNotice(List<Long> toUid, Object data){
|
||||||
SendBatchMsgReq req = new SendBatchMsgReq();
|
SendBatchMsgReq req = new SendBatchMsgReq();
|
||||||
req.setFromAccid(SYS_NOTICE_ID);
|
req.setFromAccid(SYS_NOTICE_ID);
|
||||||
req.setToAccids(toUid.stream().map(String::valueOf).collect(Collectors.toList()));
|
req.setToAccids(JSON.toJSONString(toUid.stream().map(String::valueOf).collect(Collectors.toList())));
|
||||||
req.setBody(JSON.toJSONString(data));
|
req.setBody(JSON.toJSONString(data));
|
||||||
req.setOption(JSON.toJSONString(new Option()));
|
req.setOption(JSON.toJSONString(new Option()));
|
||||||
req.setType(100);
|
req.setType(100);
|
||||||
@@ -60,7 +60,7 @@ public class Yunxin {
|
|||||||
public YxDataR<YxCommonR> batchSendToNotice(List<Long> toUid, Object body, Option option, YxImTypeEnum type){
|
public YxDataR<YxCommonR> batchSendToNotice(List<Long> toUid, Object body, Option option, YxImTypeEnum type){
|
||||||
SendBatchMsgReq req = new SendBatchMsgReq();
|
SendBatchMsgReq req = new SendBatchMsgReq();
|
||||||
req.setFromAccid(SYS_NOTICE_ID);
|
req.setFromAccid(SYS_NOTICE_ID);
|
||||||
req.setToAccids(toUid.stream().map(String::valueOf).collect(Collectors.toList()));
|
req.setToAccids(JSON.toJSONString(toUid.stream().map(String::valueOf).collect(Collectors.toList())));
|
||||||
req.setBody(JSON.toJSONString(body));
|
req.setBody(JSON.toJSONString(body));
|
||||||
if(option != null){
|
if(option != null){
|
||||||
req.setOption(JSON.toJSONString(new Option()));
|
req.setOption(JSON.toJSONString(new Option()));
|
||||||
@@ -86,7 +86,7 @@ public class Yunxin {
|
|||||||
public YxDataR<YxCommonR> batchSendToTextMessage(Long fromUid, List<Long> toUid, String data){
|
public YxDataR<YxCommonR> batchSendToTextMessage(Long fromUid, List<Long> toUid, String data){
|
||||||
SendBatchMsgReq req = new SendBatchMsgReq();
|
SendBatchMsgReq req = new SendBatchMsgReq();
|
||||||
req.setFromAccid(fromUid+"");
|
req.setFromAccid(fromUid+"");
|
||||||
req.setToAccids(toUid.stream().map(String::valueOf).collect(Collectors.toList()));
|
req.setToAccids(JSON.toJSONString(toUid.stream().map(String::valueOf).collect(Collectors.toList())));
|
||||||
req.setBody(JSON.toJSONString(new YxTextData(data)));
|
req.setBody(JSON.toJSONString(new YxTextData(data)));
|
||||||
return messageClient.sendBatchMsg(req);
|
return messageClient.sendBatchMsg(req);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
public class SendBatchMsgReq {
|
public class SendBatchMsgReq {
|
||||||
private String fromAccid;
|
private String fromAccid;
|
||||||
private List<String> toAccids;
|
private String toAccids;
|
||||||
private int type = 0;
|
private int type = 0;
|
||||||
private String body;
|
private String body;
|
||||||
private String option;
|
private String option;
|
||||||
|
|||||||
Reference in New Issue
Block a user