update 部分接口新增返回算力单位

This commit is contained in:
yyb
2026-01-28 15:02:09 +08:00
parent f8d1bdf819
commit 96a49c5813
7 changed files with 65 additions and 2 deletions

View File

@@ -118,6 +118,9 @@ public class OrderInfoDto {
private BigDecimal powerRatio;
@ApiModelProperty(value = "算力单位")
private String unit;
/**
* 订单详情
*/

View File

@@ -101,5 +101,7 @@ public class OrderItemDto {
@ApiModelProperty(value = "实际算力/理论算力 比值")
private BigDecimal powerRatio;
@ApiModelProperty(value = "算力单位")
private String unit;
}

View File

@@ -105,4 +105,15 @@ public interface LeaseOrderMiningMapper extends BaseMapper<LeaseOrderMining> {
*/
@MiningDB
List<RealHashrateInfoDto> getRealTimeHashrate(@Param("tableName") String tableName, @Param("datetime") String datetime, @Param("list") List<RealTimeHashrateQueryDto> list);
/**
* 获取指定时间范围内的算力数据
* @param tableName 表名2miners
* @param startTime 开始时间
* @param endTime 结束时间
* @param list 查询条件列表
* @return 实时算力信息列表
*/
@MiningDB
List<RealHashrateInfoDto> getHashrateInRange(@Param("tableName") String tableName, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("list") List<RealTimeHashrateQueryDto> list);
}

View File

@@ -310,7 +310,26 @@ public class RedisService {
*/
public <T> void deleteCacheMapValue7(final Map<String, String> keyFieldMap) {
keyFieldMap.forEach((key, hKey) -> {
redisTemplate7.opsForHash().delete(key, hKey);
try {
// 先判断 key 是否存在
if (redisTemplate7.hasKey(key)) {
// 检查 key 的类型是否为 Hash
org.springframework.data.redis.core.DataType dataType = redisTemplate7.type(key);
if (dataType == org.springframework.data.redis.core.DataType.HASH) {
// 再判断 hKey 是否存在
if (redisTemplate7.opsForHash().hasKey(key, hKey)) {
redisTemplate7.opsForHash().delete(key, hKey);
}
} else {
System.out.println(String.format("警告: key %s 存在但类型为 %s不是 Hash 类型,跳过删除 hKey %s",
key, dataType, hKey));
}
}
} catch (Exception e) {
System.err.println(String.format("删除 Redis Hash 数据时出错: key=%s, hKey=%s, error=%s",
key, hKey, e.getMessage()));
// 不抛出异常,继续处理下一个
}
});
}

View File

@@ -527,6 +527,8 @@ public class LeaseOrderInfoServiceImpl extends ServiceImpl<LeaseOrderInfoMapper,
.image(leaseOrderItem.getImage())
.numbers(leaseOrderItem.getNumbers())
.type(leaseOrderItem.getType() ? 1 : 0)
//TODO 先默认MH/S
.unit("MH/S")
.build());
// 累加支付金额
@@ -573,6 +575,8 @@ public class LeaseOrderInfoServiceImpl extends ServiceImpl<LeaseOrderInfoMapper,
.totalTheoryPower(BigDecimal.ZERO)
.totalPracticalPower(BigDecimal.ZERO)
.totalPayAmount(BigDecimal.ZERO)
//TODO 先默认MH/S
.unit("MH/S")
.build();
@@ -603,6 +607,8 @@ public class LeaseOrderInfoServiceImpl extends ServiceImpl<LeaseOrderInfoMapper,
.practicalPower(practicalPower)
.powerRatio(powerRatio)
.payAmount(alreadyPayRealAmount)
//TODO 先默认MH/S
.unit("MH/S")
.build());
}
orderInfoDto.setPayCoin(list.get(0).getPayCoin());

View File

@@ -49,7 +49,8 @@
loo.create_time as createTime,
loo.update_time as endTime,
loo.shop_name as shopName,
loo.coin as payCoin
loo.coin as payCoin,
'MH/S' as unit
from lease_order_info loo
<where>
del = 0

View File

@@ -155,6 +155,27 @@
</foreach>
)
</select>
<select id="getHashrateInRange" resultType="com.m2pool.lease.dto.v2.RealHashrateInfoDto">
SELECT
hashrate AS power,
pool_name AS pool,
wallet AS walletAddress,
miner AS miner,
algorithm,
coin,
datetime
FROM
`${tableName}`
WHERE
datetime >= #{startTime}
AND datetime &lt;= #{endTime}
AND (wallet, coin, miner, algorithm) IN (
<foreach collection="list" item="item" separator=",">
(#{item.walletAddress}, #{item.coin}, #{item.miner}, #{item.algorithm})
</foreach>
)
ORDER BY datetime ASC
</select>
<select id="getMiningInfoByOrderId" resultType="com.m2pool.lease.dto.v2.PurchasedMachineListDto">
select
id ,