2026-01-05 15:46:59 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
<mapper namespace="com.m2pool.lease.mapper.LeaseOrderMiningMapper">
|
|
|
|
|
|
|
|
|
|
<!-- 通用查询映射结果 -->
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseOrderMining">
|
|
|
|
|
<id column="id" property="id" />
|
|
|
|
|
<result column="user_id" property="userId" />
|
|
|
|
|
<result column="order_id" property="orderId" />
|
|
|
|
|
<result column="coin" property="coin" />
|
|
|
|
|
<result column="algorithm" property="algorithm" />
|
|
|
|
|
<result column="pool" property="pool" />
|
|
|
|
|
<result column="pool_url" property="poolUrl" />
|
|
|
|
|
<result column="pool_user" property="poolUser" />
|
|
|
|
|
<result column="worker_id" property="workerId" />
|
|
|
|
|
<result column="wallet_address" property="walletAddress" />
|
|
|
|
|
<result column="watch_url" property="watchUrl" />
|
|
|
|
|
<result column="status" property="status" />
|
|
|
|
|
<result column="start_time" property="startTime" />
|
|
|
|
|
<result column="end_time" property="endTime" />
|
|
|
|
|
<result column="del" property="del" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<!-- 通用查询结果列 -->
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
id,user_id, order_id, coin, algorithm, pool, pool_url, pool_user, worker_id, wallet_address, watch_url, status, start_time, end_time, del
|
|
|
|
|
</sql>
|
|
|
|
|
<insert id="insertBatch">
|
|
|
|
|
|
|
|
|
|
INSERT INTO lease_order_mining (
|
|
|
|
|
order_id,
|
|
|
|
|
machine_id,
|
|
|
|
|
order_item_id,
|
|
|
|
|
user_id,
|
|
|
|
|
auth_id,
|
|
|
|
|
coin,
|
|
|
|
|
algorithm,
|
|
|
|
|
pool,
|
|
|
|
|
pool_url,
|
|
|
|
|
pool_user,
|
|
|
|
|
worker_id,
|
|
|
|
|
wallet_address,
|
|
|
|
|
start_time,
|
|
|
|
|
end_time
|
|
|
|
|
)
|
|
|
|
|
VALUES
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(
|
|
|
|
|
#{item.orderId},
|
|
|
|
|
#{item.machineId},
|
|
|
|
|
#{item.orderItemId},
|
|
|
|
|
#{item.userId},
|
|
|
|
|
#{item.authId},
|
|
|
|
|
#{item.coin},
|
|
|
|
|
#{item.algorithm},
|
|
|
|
|
#{item.pool},
|
|
|
|
|
#{item.poolUrl},
|
|
|
|
|
#{item.poolUser},
|
|
|
|
|
#{item.workerId},
|
|
|
|
|
#{item.walletAddress},
|
|
|
|
|
#{item.startTime},
|
|
|
|
|
#{item.endTime})
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
<update id="updateOrderMining">
|
|
|
|
|
UPDATE lease_order_mining
|
2026-01-22 16:01:28 +08:00
|
|
|
SET watch_url = #{clientConfigurationMining.watch_url}
|
2026-01-05 15:46:59 +08:00
|
|
|
WHERE user_id = #{userEmail} AND pool = #{clientConfigurationMining.pool}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<select id="getPurchasedItems" resultType="com.m2pool.lease.dto.v2.PurchasedMachineListDto">
|
2026-01-16 14:46:45 +08:00
|
|
|
select MAX(id) as id,
|
2026-01-05 15:46:59 +08:00
|
|
|
coin,
|
|
|
|
|
algorithm,
|
|
|
|
|
pool,
|
|
|
|
|
pool_url as poolUrl,
|
|
|
|
|
pool_user as poolUser,
|
|
|
|
|
wallet_address as walletAddress,
|
|
|
|
|
watch_url as watchUrl,
|
2026-01-16 14:46:45 +08:00
|
|
|
MAX(end_time) as endTime
|
2026-01-05 15:46:59 +08:00
|
|
|
FROM lease_order_mining
|
|
|
|
|
WHERE auth_id = #{authId}
|
2026-01-16 14:46:45 +08:00
|
|
|
GROUP BY coin,`algorithm`,pool,pool_url,pool_user,wallet_address,watch_url
|
|
|
|
|
ORDER BY endTime DESC
|
2026-01-05 15:46:59 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getPurchasedInfo" resultType="com.m2pool.lease.dto.v2.MiningConfigInfoDto">
|
|
|
|
|
select
|
|
|
|
|
id ,
|
|
|
|
|
coin,
|
|
|
|
|
algorithm,
|
|
|
|
|
pool,
|
|
|
|
|
pool_url as poolUrl,
|
|
|
|
|
pool_user as poolUser,
|
|
|
|
|
wallet_address as walletAddress,
|
|
|
|
|
watch_url as watchUrl
|
|
|
|
|
FROM lease_order_mining
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getRecentlyHashrate" resultType="com.m2pool.lease.dto.v2.MiningHashrateInfoDto">
|
|
|
|
|
SELECT
|
|
|
|
|
t.datetime AS recordTime,
|
|
|
|
|
t.hashrate AS power,
|
|
|
|
|
t.miner
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
2026-01-21 16:46:50 +08:00
|
|
|
sub.datetime,
|
|
|
|
|
sub.hashrate,
|
|
|
|
|
sub.miner,
|
|
|
|
|
@rn := IF(@prev_miner = sub.miner, @rn + 1, 1) AS rn,
|
|
|
|
|
@prev_miner := sub.miner
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
datetime,
|
|
|
|
|
hashrate,
|
|
|
|
|
miner
|
|
|
|
|
FROM `${pool}`
|
2026-01-05 15:46:59 +08:00
|
|
|
WHERE wallet = #{wallet}
|
|
|
|
|
AND coin = #{coin}
|
|
|
|
|
AND miner IN (
|
2026-01-22 16:01:28 +08:00
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
#{item.workerId}
|
|
|
|
|
</foreach>
|
2026-01-05 15:46:59 +08:00
|
|
|
)
|
2026-01-21 16:46:50 +08:00
|
|
|
ORDER BY miner, datetime DESC
|
|
|
|
|
) sub,
|
|
|
|
|
(SELECT @rn := 0, @prev_miner := '') r
|
2026-01-05 15:46:59 +08:00
|
|
|
) t
|
|
|
|
|
WHERE t.rn = 1
|
2026-01-21 16:46:50 +08:00
|
|
|
|
|
|
|
|
-- 开发环境
|
|
|
|
|
<!-- SELECT-->
|
|
|
|
|
<!-- t.datetime AS recordTime,-->
|
|
|
|
|
<!-- t.hashrate AS power,-->
|
|
|
|
|
<!-- t.miner-->
|
|
|
|
|
<!-- FROM (-->
|
|
|
|
|
<!-- SELECT-->
|
|
|
|
|
<!-- datetime,-->
|
|
|
|
|
<!-- hashrate,-->
|
|
|
|
|
<!-- miner,-->
|
|
|
|
|
<!-- ROW_NUMBER() OVER(PARTITION BY miner ORDER BY datetime DESC) as rn-->
|
|
|
|
|
<!-- FROM `${pool}`-->
|
|
|
|
|
<!-- WHERE wallet = #{wallet}-->
|
|
|
|
|
<!-- AND coin = #{coin}-->
|
|
|
|
|
<!-- AND miner IN (-->
|
|
|
|
|
<!-- <foreach collection="list" item="item" separator=",">-->
|
|
|
|
|
<!-- #{item.workerId}-->
|
|
|
|
|
<!-- </foreach>-->
|
|
|
|
|
<!-- )-->
|
|
|
|
|
<!-- ) t-->
|
|
|
|
|
<!-- WHERE t.rn = 1-->
|
2026-01-05 15:46:59 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getRecently24HourHashrate" resultType="com.m2pool.lease.dto.v2.RealHashrateInfoDto">
|
|
|
|
|
SELECT
|
|
|
|
|
hashrate AS power,
|
|
|
|
|
pool_name AS pool,
|
|
|
|
|
wallet AS walletAddress,
|
|
|
|
|
miner AS miner,
|
|
|
|
|
algorithm,
|
|
|
|
|
coin
|
|
|
|
|
FROM
|
|
|
|
|
`${tableName}`
|
|
|
|
|
WHERE
|
|
|
|
|
datetime >= DATE_SUB(#{now}, INTERVAL 24 HOUR) AND (wallet, coin, miner, algorithm) IN (
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(#{item.walletAddress}, #{item.coin}, #{item.workerId}, #{item.algorithm})
|
|
|
|
|
</foreach>
|
|
|
|
|
)
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getMiningInfoByOrderId" resultType="com.m2pool.lease.dto.v2.PurchasedMachineListDto">
|
|
|
|
|
select
|
|
|
|
|
id ,
|
|
|
|
|
order_item_id as orderItemId,
|
|
|
|
|
coin,
|
|
|
|
|
algorithm,
|
|
|
|
|
pool,
|
|
|
|
|
pool_url as poolUrl,
|
|
|
|
|
pool_user as poolUser,
|
|
|
|
|
worker_id as workerId,
|
|
|
|
|
wallet_address as walletAddress,
|
|
|
|
|
watch_url as watchUrl,
|
|
|
|
|
status,
|
|
|
|
|
start_time as startTime,
|
|
|
|
|
end_time as endTime
|
|
|
|
|
FROM lease_order_mining
|
|
|
|
|
WHERE status = 1 and order_item_id in
|
|
|
|
|
<foreach item="item" collection="orderIds" separator="," open="(" close=")">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="checkMiningMinersExist" resultType="com.m2pool.lease.dto.v2.OrderMiningInfoDto">
|
|
|
|
|
select
|
|
|
|
|
worker_id as workerId,
|
|
|
|
|
wallet_address as walletAddress
|
|
|
|
|
FROM lease_order_mining
|
|
|
|
|
WHERE status = 1 AND (
|
|
|
|
|
<foreach collection="list" item="item" separator="OR">
|
|
|
|
|
(`wallet_address` = #{item.walletAddress} AND worker_id = #{item.workerId} )
|
2026-01-21 16:46:50 +08:00
|
|
|
</foreach>)
|
2026-01-05 15:46:59 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getPurchasedMachineInfo" resultType="com.m2pool.lease.dto.v2.PurchasedMachineDto">
|
|
|
|
|
select
|
|
|
|
|
id ,
|
|
|
|
|
worker_id as workerId,
|
|
|
|
|
status,
|
|
|
|
|
start_time as startTime,
|
|
|
|
|
end_time as endTime
|
|
|
|
|
FROM lease_order_mining
|
|
|
|
|
WHERE
|
|
|
|
|
wallet_address = #{info.walletAddress} AND
|
|
|
|
|
pool_user = #{info.poolUser} AND
|
|
|
|
|
pool = #{info.pool} AND
|
|
|
|
|
pool_url = #{info.poolUrl} AND
|
|
|
|
|
coin = #{info.coin} AND
|
2026-01-22 16:01:28 +08:00
|
|
|
`algorithm` = #{info.algorithm} AND status = 1
|
2026-01-05 15:46:59 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</mapper>
|