update nexa 收益计算器问题
This commit is contained in:
parent
4fad507896
commit
315079e5d1
|
@ -62,4 +62,7 @@ public class ChatRoomDto {
|
|||
*/
|
||||
@ApiModelProperty(value = "聊天发起者id :一般为游客或登录用户", example = "1")
|
||||
private String selfEmail;
|
||||
|
||||
@ApiModelProperty(value = "客服是否在线", example = "true")
|
||||
private boolean customerIsOnline;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,6 @@ public class WebsocketChannelInterceptor implements ChannelInterceptor {
|
|||
maxConnectionsLimit();
|
||||
//根据客服端ip + 用户类型限制连接数
|
||||
ipLimit(accessor,type,email);
|
||||
|
||||
//链接请求头中用户信息存入stomp中
|
||||
mha.setUser(new StompPrincipal(email,type,true));
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.m2pool.chat.service.ChatRoomService;
|
|||
import com.m2pool.chat.vo.CharRoomVo;
|
||||
import com.m2pool.chat.vo.RoomPageVo;
|
||||
import com.m2pool.chat.vo.RoomVo;
|
||||
import com.m2pool.chat.vo.UserMessageVo;
|
||||
import com.m2pool.common.core.Result.R;
|
||||
import com.m2pool.common.core.constant.HttpStatus;
|
||||
import com.m2pool.common.core.utils.PageUtils;
|
||||
|
@ -73,6 +74,7 @@ public class ChatRoomServiceImpl extends ServiceImpl<ChatRoomMapper, ChatRoom> i
|
|||
return rspData;
|
||||
}
|
||||
|
||||
private static final String EMAIL_REGEX = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,}$";
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
|
@ -81,6 +83,11 @@ public class ChatRoomServiceImpl extends ServiceImpl<ChatRoomMapper, ChatRoom> i
|
|||
String userEmail = roomVo.getEmail();
|
||||
ChatRoomDto roomByUserEmail = chatRoomMapper.findRoomByUserEmail(userEmail);
|
||||
if(roomByUserEmail != null){
|
||||
if (checkOnline(roomByUserEmail.getUserEmail())) {
|
||||
roomByUserEmail.setCustomerIsOnline(true);
|
||||
} else{
|
||||
roomByUserEmail.setCustomerIsOnline(false);
|
||||
}
|
||||
return R.success(roomByUserEmail);
|
||||
}
|
||||
|
||||
|
@ -91,14 +98,36 @@ public class ChatRoomServiceImpl extends ServiceImpl<ChatRoomMapper, ChatRoom> i
|
|||
}
|
||||
Random random = new Random();
|
||||
SysUser sysUser = data.get(random.nextInt(data.size()));
|
||||
ChatRoom build = ChatRoom.builder().userOneEmail(userEmail).userTwoEmail(sysUser.getEmail()).build();
|
||||
data.removeIf(datum -> !checkOnline(datum.getEmail()));
|
||||
boolean customerIsOnline = false;
|
||||
if (!data.isEmpty()){
|
||||
sysUser = data.get(random.nextInt(data.size()));
|
||||
customerIsOnline = true;
|
||||
}
|
||||
ChatRoom build = ChatRoom.builder()
|
||||
.userOneEmail(userEmail)
|
||||
.userTwoEmail(sysUser.getEmail())
|
||||
.build();
|
||||
int insert = chatRoomMapper.insert(build);
|
||||
if (insert > 0){
|
||||
return R.success(ChatRoomDto.builder().id(build.getId()).selfEmail(userEmail).userEmail(build.getUserTwoEmail()).build());
|
||||
return R.success(ChatRoomDto.builder()
|
||||
.id(build.getId())
|
||||
.selfEmail(userEmail)
|
||||
.customerIsOnline(customerIsOnline)
|
||||
.userEmail(build.getUserTwoEmail()).build());
|
||||
}
|
||||
return R.fail("聊天室不存在,并且创建聊天室失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否在线
|
||||
* @return
|
||||
*/
|
||||
private boolean checkOnline(String email){
|
||||
return userRegistry.getUsers().stream()
|
||||
.anyMatch(user -> user.getName().equals(email));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<String> updateRoom(CharRoomVo charRoomVo) {
|
||||
int i = chatRoomMapper.updateById(ChatRoom.builder().id(charRoomVo.getId()).flag(charRoomVo.getFlag()).build());
|
||||
|
|
|
@ -64,7 +64,7 @@ public class StompServiceImpl implements StompService {
|
|||
ChatRoom chatRoom = chatRoomMapper.selectOne(new LambdaQueryWrapper<ChatRoom>()
|
||||
.eq(ChatRoom::getUserOneEmail,userMessageVo.getEmail())
|
||||
.eq(ChatRoom::getUserTwoEmail,principal.getName()));
|
||||
System.out.println("发送消息,聊天室id"+userMessageVo.getRoomId()+"发送者邮箱"+principal.getName()+"接受者邮箱"+userMessageVo.getEmail());
|
||||
|
||||
build.setRoomId(userMessageVo.getRoomId());
|
||||
int serviceReadNum = chatRoom != null ? chatRoom.getClientReadNum() : 0;
|
||||
build.setClientReadNum( serviceReadNum+ 1);
|
||||
|
@ -78,11 +78,12 @@ public class StompServiceImpl implements StompService {
|
|||
//}else{
|
||||
// handleImage(userMessageVo.getEmail()+principal.getName(),userMessageVo.getContent());
|
||||
//}
|
||||
|
||||
Long id = executeTran(principal, userMessageVo, chatRoom);
|
||||
System.out.println("发送消息,聊天室id"+userMessageVo.getRoomId()+"发送者邮箱"+principal.getName()+"接受者邮箱"+userMessageVo.getEmail()+"消息id"+id);
|
||||
//多端情况下,需要把消息发送给自己
|
||||
build.setId(id);
|
||||
messagingTemplate.convertAndSendToUser(principal.getName(), Destination.QUEUE_CUSTOMER + "/" + principal.getName(),build);
|
||||
messagingTemplate.convertAndSendToUser(userMessageVo.getEmail(), Destination.QUEUE_USER + "/" + userMessageVo.getEmail(),build);
|
||||
executeTran(principal, userMessageVo, chatRoom);
|
||||
return AjaxResult.success("成功");
|
||||
}
|
||||
|
||||
|
@ -106,11 +107,13 @@ public class StompServiceImpl implements StompService {
|
|||
//}else{
|
||||
// handleImage(userMessageVo.getEmail()+principal.getName(),userMessageVo.getContent());
|
||||
//}
|
||||
|
||||
Long id = executeTran(principal, userMessageVo, chatRoom);
|
||||
System.out.println("发送消息,聊天室id"+userMessageVo.getRoomId()+"发送者邮箱"+principal.getName()+"接受者邮箱"+userMessageVo.getEmail()+"消息id"+id);
|
||||
// 多端情况下,需要把消息发送给
|
||||
build.setId(id);
|
||||
messagingTemplate.convertAndSendToUser(principal.getName(), Destination.QUEUE_USER + "/" + principal.getName(),build);
|
||||
messagingTemplate.convertAndSendToUser(userMessageVo.getEmail(), Destination.QUEUE_CUSTOMER + "/" + userMessageVo.getEmail(),build);
|
||||
executeTran(principal, userMessageVo, chatRoom);
|
||||
|
||||
return AjaxResult.success("成功");
|
||||
}
|
||||
/**
|
||||
|
@ -150,14 +153,15 @@ public class StompServiceImpl implements StompService {
|
|||
* @param userMessageVo
|
||||
* @param chatRoom
|
||||
*/
|
||||
private void executeTran(StompPrincipal principal, UserMessageVo userMessageVo, ChatRoom chatRoom){
|
||||
private Long executeTran(StompPrincipal principal, UserMessageVo userMessageVo, ChatRoom chatRoom){
|
||||
final Long[] id = {0L};
|
||||
// 消息存储
|
||||
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
try {
|
||||
// 插入消息并获取 ID
|
||||
insertMessage(principal,userMessageVo);
|
||||
id[0] = insertMessage(principal, userMessageVo);
|
||||
//聊天室,已读未读数量,更新。
|
||||
updateRoom(chatRoom,principal.getType());
|
||||
} catch (Exception e) {
|
||||
|
@ -167,6 +171,7 @@ public class StompServiceImpl implements StompService {
|
|||
}
|
||||
}
|
||||
});
|
||||
return id[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -434,7 +434,7 @@ public class PoolServiceImpl implements PoolService {
|
|||
}
|
||||
else {
|
||||
BlockInfo info = redisService.getCacheObject(pool.getCoin() + "_block");
|
||||
|
||||
System.out.println("yyb-redis key"+ pool.getCoin() + "_block" +"查询结果"+ info);
|
||||
if(StringUtils.isNull(info)){
|
||||
if(!"enx".equals(pool.getCoin()) && !"alph".equals(pool.getCoin())){
|
||||
//
|
||||
|
|
|
@ -84,7 +84,6 @@ public class NodeTask {
|
|||
@Scheduled(cron = "0 0/1 * * * ?")
|
||||
public void NEXABlockInfoToRedis(){
|
||||
BlockInfo blockInfo = NodeRpc.getBlock("nexa");
|
||||
|
||||
int count = 0;
|
||||
while (StringUtils.isNull(blockInfo)){
|
||||
if(count >= 3){
|
||||
|
|
|
@ -239,7 +239,9 @@ public class NodeRpc{
|
|||
}
|
||||
|
||||
String[] params = {nowHeight,"2"};
|
||||
Object[] statsParams = {Convert.toLong(nowHeight)};
|
||||
String result = getResult(coin, "getmininginfo", params);
|
||||
String result2 = getResultTest(coin, "getblockstats", statsParams);
|
||||
BlockInfo blockInfo = new BlockInfo();
|
||||
|
||||
if(StringUtils.isBlank(result)){
|
||||
|
@ -253,11 +255,16 @@ public class NodeRpc{
|
|||
}
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
JSONObject statsJs = JSON.parseObject(result2);
|
||||
long height = jsonObject.getLongValue("blocks");
|
||||
blockInfo.setHeight(height);
|
||||
|
||||
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
||||
|
||||
BigDecimal subsidy = statsJs.getBigDecimal("subsidy");
|
||||
if(StringUtils.isNull(subsidy)) {
|
||||
System.out.println("subsidy获取结果为空");
|
||||
return blockInfo;
|
||||
}
|
||||
if(StringUtils.isNotNull(difficulty)){
|
||||
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||
|
@ -294,7 +301,7 @@ public class NodeRpc{
|
|||
// }
|
||||
//});
|
||||
|
||||
blockInfo.setReward(BigDecimal.valueOf(reward[0]));
|
||||
blockInfo.setReward(subsidy);
|
||||
blockInfo.setFees(BigDecimal.valueOf(fees[0]));
|
||||
blockInfo.setProfit(blockInfo.getReward().subtract(blockInfo.getFees()));
|
||||
System.out.println("blockInfo信息rpc"+blockInfo);
|
||||
|
|
Loading…
Reference in New Issue