update m2pool 新增注销账号功能

This commit is contained in:
yyb
2025-12-30 09:53:41 +08:00
parent b210b114d5
commit 1e7c2099bf
29 changed files with 418 additions and 43 deletions

View File

@@ -39,6 +39,8 @@ public interface PoolMapper {
public List<PowerLineDto> getHourPoolPowerList(@Param("table") String table);
public List<PowerLineDto> getHourNetPowerList(@Param("table") String table);
BigDecimal getCurrentCoinPrice(@Param("table") String table);
public List<BlockInfoDto> getGRSBlockInfoList();
public List<BlockInfoDto> getMonaBlockInfoList();

View File

@@ -22,6 +22,9 @@ import com.m2pool.pool.utils.EnumUtils;
import com.m2pool.pool.utils.NodeRpc;
import com.m2pool.pool.utils.PowerUnitUtils;
import com.m2pool.pool.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -33,7 +36,6 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@@ -41,6 +43,7 @@ import java.util.stream.Collectors;
* @Date 2024/6/14 14:29
* @Author dy
*/
@Slf4j
@Service
public class PoolServiceImpl implements PoolService {
@@ -182,6 +185,7 @@ public class PoolServiceImpl implements PoolService {
public AjaxResult getPoolPower(CoinVo vo) {
Pools pool = (Pools) EnumUtils.get(Pools.class, vo.getCoin());
if(StringUtils.isNull(pool)){
return AjaxResult.error("参数错误,未能根据当前参数获取到数据");
}
@@ -189,13 +193,12 @@ public class PoolServiceImpl implements PoolService {
if(StringUtils.isBlank(vo.getInterval())){
return AjaxResult.error("缺失参数:interval");
}
PageHelper.clearPage();
List<PowerLineDto> priceList = poolMapper.getHourPoolPowerList(pool.getCoin());
int scale = PoolProfitScale.getScaleByCoin(pool.getCoin());
PowerLineDto powerLineDto = priceList.stream()
.filter(e -> e.getDate().after(DateUtils.toDate(LocalDateTime.now().toLocalDate().atStartOfDay())))
.max(Comparator.comparing(PowerLineDto::getPrice)).orElse(new PowerLineDto());
BigDecimal currentCoinPrice = poolMapper.getCurrentCoinPrice(pool.getCoin());
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
// 获取当前日期
@@ -221,19 +224,17 @@ public class PoolServiceImpl implements PoolService {
//数据补零
list = fillMissingOnlineData(list,oneDayAgo,currentDate,powerUnit.getUnit(),30);
//通过全网算力接口 获取到的时间段价格补充到矿池算力接口的价格中
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
list.forEach(e -> priceList.stream().anyMatch(p ->{
if( p.getDate().equals(e.getDate())){
e.setPrice(p.getPrice());
}
return false;
}));
List<PowerLineDto> collect = list.stream().peek(e -> {
if (e.getPrice() == 0) {
e.setPrice(powerLineDto.getPrice());
e.setPrice(currentCoinPrice.doubleValue());
}
}).collect(Collectors.toList());
return AjaxResult.success(collect);
}else if ("1d".equals(vo.getInterval())){
@@ -268,7 +269,7 @@ public class PoolServiceImpl implements PoolService {
list = changeUnit(powerUnit, list, pool,BigDecimal.valueOf(1000 * 1000));
list = fillMissingOnlineData(list,oneMonthAgo,currentDate,powerUnit.getUnit(),24*60);
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
list.forEach(e -> priceList.stream().anyMatch(p ->{
if( p.getDate().equals(e.getDate())){
e.setPrice(p.getPrice());
}
@@ -276,7 +277,7 @@ public class PoolServiceImpl implements PoolService {
}));
List<PowerLineDto> collect = list.stream().peek(e -> {
if (e.getPrice() == 0) {
e.setPrice(powerLineDto.getPrice());
e.setPrice(currentCoinPrice.doubleValue());
}
}).collect(Collectors.toList());
return AjaxResult.success(collect);
@@ -423,7 +424,7 @@ public class PoolServiceImpl implements PoolService {
List<PowerLineDto> list = poolMapper.getHourNetPowerList(pool.getCoin());
PowerLineDto powerLineDto = list.stream()
.max(Comparator.comparing(PowerLineDto::getPrice)).orElse(new PowerLineDto());
.max(Comparator.comparing(PowerLineDto::getDate)).orElse(new PowerLineDto());
list = list.stream().peek(e -> {
if (e.getPrice() == 0) {
@@ -541,7 +542,7 @@ public class PoolServiceImpl implements PoolService {
}
else {
BlockInfo info = redisService.getCacheObject(pool.getCoin() + "_block");
System.out.println("yyb-redis key"+ pool.getCoin() + "_block" +"查询结果"+ info);
System.out.println("redis key"+ pool.getCoin() + "_block" +"查询结果"+ info);
if(StringUtils.isNull(info)){
if(!"enx".equals(pool.getCoin()) && !"alph".equals(pool.getCoin())){
//
@@ -736,7 +737,7 @@ public class PoolServiceImpl implements PoolService {
List<MinerDataDto> list = poolMapper.getHourMinerDataList(vo.getCoin()+"_mhsv2",nowStr);
if(list.size() > 0){
if(!list.isEmpty()){
List<MinerDataDto> offlineList = new ArrayList<>();
list.stream().forEach(e -> {
if(StringUtils.isNotNull(e.getMhs())){

View File

@@ -504,7 +504,7 @@ public class NodeRpc{
JSONObject jsonObject = JSON.parseObject(result);
JSONObject jsonObject1 = JSON.parseObject(result1);
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
System.out.println("yyb-全网算力grs"+netPower);
System.out.println("全网算力grs"+netPower);
long height = jsonObject.getLongValue("height");
blockInfo.setHeight(height);
@@ -589,7 +589,7 @@ public class NodeRpc{
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
System.out.println("yyb-全网算力mona"+netPower);
System.out.println("全网算力mona"+netPower);
if(StringUtils.isNotNull(difficulty)){
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
@@ -669,7 +669,7 @@ public class NodeRpc{
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
System.out.println("yyb-全网算力rxd"+netPower);
System.out.println("全网算力rxd"+netPower);
if(StringUtils.isNotNull(difficulty)){
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
@@ -1039,7 +1039,6 @@ public class NodeRpc{
qBlockInfo.setPower(qNetwork);
map.put("dgbq",qBlockInfo);
}
System.out.println("存储的数据"+map);
return map;
}

View File

@@ -75,3 +75,8 @@ myenv:
path: /var/www/html/web_test
img: /img
filepath: /home/ubuntu/web
#mybatis:
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

View File

@@ -62,13 +62,13 @@
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>

View File

@@ -375,11 +375,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getHourPoolPowerList" resultType="com.m2pool.pool.dto.PowerLineDto">
select
p.date `date`,
COALESCE(p.value,0) price,
COALESCE(np.value,0) pv
COALESCE(p.value,0) price
from
${table}_price p
left join ${table}_net_power np on p.date = np.date
where p.date >= DATE_SUB(NOW(), INTERVAL 35 DAY)
</select>
<select id="getHourNetPowerList" resultType="com.m2pool.pool.dto.PowerLineDto">
@@ -1048,6 +1047,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{i.user}
</foreach>
</select>
<select id="getCurrentCoinPrice" resultType="java.math.BigDecimal">
select `value` from ${table}_price order by id DESC LIMIT 1;
</select>
</mapper>