fix: 优化收益计算、地址校验和提现逻辑
- 修正收益计算将月收益改为日收益,格式化显示为'(币种)' - 统一NEXA地址校验规则,必须带'nexa:'前缀 - 修复提现金额计算逻辑,改为从余额中减去提现金额和手续费 - 优化SQL查询,使用ROW_NUMBER替代变量排序 - 添加用户权限校验,算力保留两位小数并添加单位字段 - 添加空字符串校验和调试日志输出 - 启用提现队列监听功能
This commit is contained in:
@@ -77,152 +77,61 @@
|
||||
</select>
|
||||
|
||||
<select id="getShopMachineList" resultType="com.m2pool.lease.dto.v2.MachineInfoDto">
|
||||
<!-- SELECT-->
|
||||
<!-- sub.id,-->
|
||||
<!-- sub.host_mac AS hostMac,-->
|
||||
<!-- sub.shop_id as shopId,-->
|
||||
<!-- sub.type,-->
|
||||
<!-- sub.`user`,-->
|
||||
<!-- sub.miner,-->
|
||||
<!-- sub.state,-->
|
||||
<!-- sub.sale_state AS saleState,-->
|
||||
<!-- sub.max_lease_days AS maxLeaseDays,-->
|
||||
<!-- sub.del,-->
|
||||
<!-- sub.power_dissipation as powerDissipation,-->
|
||||
<!-- sub.hashrate as theoryPower,-->
|
||||
<!-- sub.unit,-->
|
||||
<!-- sub.coin,-->
|
||||
<!-- sub.month_income as monthIncome,-->
|
||||
<!-- sub.name as model,-->
|
||||
<!-- sub.algorithm,-->
|
||||
<!-- sub.online_status AS onlineStatus,-->
|
||||
<!-- sub.sale_numbers as saleNumbers,-->
|
||||
<!-- sub.sale_out_numbers as saleOutNumbers,-->
|
||||
<!-- mp.price-->
|
||||
<!-- FROM-->
|
||||
<!-- (-->
|
||||
<!-- SELECT-->
|
||||
<!-- lm.id,-->
|
||||
<!-- lm.host_mac,-->
|
||||
<!-- lm.shop_id,-->
|
||||
<!-- lm.type,-->
|
||||
<!-- lm.`user`,-->
|
||||
<!-- lm.miner,-->
|
||||
<!-- lm.state,-->
|
||||
<!-- lm.sale_state,-->
|
||||
<!-- lm.max_lease_days,-->
|
||||
<!-- lm.del,-->
|
||||
<!-- lm.online_status,-->
|
||||
<!-- lm.sale_numbers,-->
|
||||
<!-- lm.sale_out_numbers,-->
|
||||
<!-- SUM(gpc.power_dissipation) AS power_dissipation,-->
|
||||
<!-- SUM(gpc.hashrate) AS hashrate,-->
|
||||
<!-- SUM(gpc.month_income) AS month_income,-->
|
||||
<!-- gpc.unit,-->
|
||||
<!-- gpc.coin,-->
|
||||
<!-- gpc.name,-->
|
||||
<!-- gpc.algorithm,-->
|
||||
<!-- ROW_NUMBER() OVER (-->
|
||||
<!-- PARTITION BY lm.id-->
|
||||
<!-- ORDER BY SUM(gpc.month_income) DESC-->
|
||||
<!-- ) AS rn-->
|
||||
<!-- FROM-->
|
||||
<!-- lease_machine lm-->
|
||||
<!-- JOIN-->
|
||||
<!-- lease_machine_config gpc ON lm.id = gpc.machine_id AND lm.type = #{shopMachineVo.type} AND lm.shop_id = #{shopMachineVo.shopId} AND lm.online_status = true AND lm.sale_state = 0 AND lm.state = 0-->
|
||||
<!-- GROUP BY lm.id,gpc.coin,gpc.algorithm-->
|
||||
<!-- ) sub-->
|
||||
<!-- LEFT JOIN lease_machine_price mp-->
|
||||
<!-- ON sub.id = mp.machine_id AND mp.coin = #{shopMachineVo.coin} AND mp.chain = #{shopMachineVo.chain} AND mp.del = false AND sub.rn = 1-->
|
||||
<!-- WHERE-->
|
||||
<!-- sub.del = FALSE AND sub.rn = 1-->
|
||||
<!-- <if test="shopMachineVo.minPrice != 0 or shopMachineVo.maxPrice != 0">-->
|
||||
<!-- AND mp.price >= #{shopMachineVo.minPrice} AND mp.price <![CDATA[<=]]> #{shopMachineVo.maxPrice}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="shopMachineVo.keyword != null and shopMachineVo.keyword != ''">-->
|
||||
<!-- AND (sub.coin LIKE CONCAT('%', #{shopMachineVo.keyword}, '%') OR sub.algorithm LIKE CONCAT('%', #{shopMachineVo.keyword}, '%'))-->
|
||||
<!-- </if>-->
|
||||
|
||||
-- 开发环境
|
||||
SELECT
|
||||
sub.id,
|
||||
sub.host_mac AS hostMac,
|
||||
sub.shop_id as shopId,
|
||||
sub.type,
|
||||
sub.`user`,
|
||||
sub.miner,
|
||||
sub.state,
|
||||
sub.sale_state AS saleState,
|
||||
sub.max_lease_days AS maxLeaseDays,
|
||||
sub.del,
|
||||
sub.power_dissipation as powerDissipation,
|
||||
sub.hashrate as theoryPower,
|
||||
sub.unit,
|
||||
sub.coin,
|
||||
sub.month_income as monthIncome,
|
||||
sub.name as model,
|
||||
sub.algorithm,
|
||||
sub.online_status AS onlineStatus,
|
||||
sub.sale_numbers as saleNumbers,
|
||||
sub.sale_out_numbers as saleOutNumbers,
|
||||
mp.price
|
||||
sub.id,
|
||||
sub.host_mac AS hostMac,
|
||||
sub.shop_id as shopId,
|
||||
sub.type,
|
||||
sub.`user`,
|
||||
sub.miner,
|
||||
sub.state,
|
||||
sub.sale_state AS saleState,
|
||||
sub.max_lease_days AS maxLeaseDays,
|
||||
sub.del,
|
||||
sub.power_dissipation as powerDissipation,
|
||||
sub.hashrate as theoryPower,
|
||||
sub.unit,
|
||||
sub.coin,
|
||||
ROUND(sub.month_income, 2) as monthIncome,
|
||||
sub.name as model,
|
||||
sub.algorithm,
|
||||
sub.online_status AS onlineStatus,
|
||||
sub.sale_numbers as saleNumbers,
|
||||
sub.sale_out_numbers as saleOutNumbers,
|
||||
mp.price
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
t.id,
|
||||
t.host_mac,
|
||||
t.shop_id,
|
||||
t.type,
|
||||
t.`user`,
|
||||
t.miner,
|
||||
t.state,
|
||||
t.sale_state,
|
||||
t.max_lease_days,
|
||||
t.del,
|
||||
t.online_status,
|
||||
t.sale_numbers,
|
||||
t.sale_out_numbers,
|
||||
t.power_dissipation,
|
||||
t.hashrate,
|
||||
t.month_income,
|
||||
t.unit,
|
||||
t.coin,
|
||||
t.name,
|
||||
t.algorithm,
|
||||
@rn := IF(@prev_id = t.id, @rn + 1, 1) AS rn,
|
||||
@prev_id := t.id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
lm.id,
|
||||
lm.host_mac,
|
||||
lm.shop_id,
|
||||
lm.type,
|
||||
lm.`user`,
|
||||
lm.miner,
|
||||
lm.state,
|
||||
lm.sale_state,
|
||||
lm.max_lease_days,
|
||||
lm.del,
|
||||
lm.online_status,
|
||||
lm.sale_numbers,
|
||||
lm.sale_out_numbers,
|
||||
SUM(gpc.power_dissipation) AS power_dissipation,
|
||||
SUM(gpc.hashrate) AS hashrate,
|
||||
SUM(gpc.month_income) AS month_income,
|
||||
gpc.unit,
|
||||
gpc.coin,
|
||||
gpc.name,
|
||||
gpc.algorithm
|
||||
FROM
|
||||
lease_machine lm
|
||||
JOIN
|
||||
lease_machine_config gpc ON lm.id = gpc.machine_id AND lm.type = #{shopMachineVo.type} AND lm.shop_id = #{shopMachineVo.shopId} AND lm.online_status = true AND lm.sale_state = 0 AND lm.state = 0
|
||||
GROUP BY lm.id,gpc.coin,gpc.algorithm,gpc.name,gpc.unit
|
||||
ORDER BY lm.id, SUM(gpc.month_income) DESC
|
||||
) t,
|
||||
(SELECT @rn := 0, @prev_id := 0) r
|
||||
) sub
|
||||
SELECT
|
||||
lm.id,
|
||||
lm.host_mac,
|
||||
lm.shop_id,
|
||||
lm.type,
|
||||
lm.`user`,
|
||||
lm.miner,
|
||||
lm.state,
|
||||
lm.sale_state,
|
||||
lm.max_lease_days,
|
||||
lm.del,
|
||||
lm.online_status,
|
||||
lm.sale_numbers,
|
||||
lm.sale_out_numbers,
|
||||
SUM(gpc.power_dissipation) AS power_dissipation,
|
||||
SUM(gpc.hashrate) AS hashrate,
|
||||
SUM(gpc.month_income) AS month_income,
|
||||
gpc.unit,
|
||||
gpc.coin,
|
||||
gpc.name,
|
||||
gpc.algorithm,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY lm.id
|
||||
ORDER BY SUM(gpc.month_income) DESC
|
||||
) AS rn
|
||||
FROM
|
||||
lease_machine lm
|
||||
JOIN
|
||||
lease_machine_config gpc ON lm.id = gpc.machine_id AND lm.type = #{shopMachineVo.type} AND lm.shop_id = #{shopMachineVo.shopId} AND lm.online_status = true AND lm.sale_state = 0 AND lm.state = 0
|
||||
GROUP BY lm.id,gpc.coin,gpc.algorithm
|
||||
) sub
|
||||
LEFT JOIN lease_machine_price mp
|
||||
ON sub.id = mp.machine_id AND mp.coin = #{shopMachineVo.coin} AND mp.chain = #{shopMachineVo.chain} AND mp.del = false AND sub.rn = 1
|
||||
WHERE
|
||||
@@ -279,35 +188,11 @@
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
t.id,
|
||||
t.shop_id,
|
||||
t.type,
|
||||
t.`user`,
|
||||
t.miner,
|
||||
t.state,
|
||||
t.sale_state,
|
||||
t.max_lease_days,
|
||||
t.del,
|
||||
t.online_status,
|
||||
t.sale_numbers,
|
||||
t.sale_out_numbers,
|
||||
t.power_dissipation,
|
||||
t.hashrate,
|
||||
t.unit,
|
||||
t.coin,
|
||||
t.month_income,
|
||||
t.name,
|
||||
t.algorithm,
|
||||
@rn := IF(@prev_id = t.id, @rn + 1, 1) AS rn,
|
||||
@prev_id := t.id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
lm.id,
|
||||
lm.shop_id,
|
||||
lm.type,
|
||||
lm.user,
|
||||
COALESCE(NULLIF(lm.miner, ''), lm.host_mac) as miner,
|
||||
lm.`user`,
|
||||
COALESCE(NULLIF(lm.miner,''),lm.host_mac) as miner,
|
||||
lm.state,
|
||||
lm.sale_state,
|
||||
lm.max_lease_days,
|
||||
@@ -321,81 +206,21 @@
|
||||
gpc.coin,
|
||||
gpc.month_income,
|
||||
gpc.name,
|
||||
gpc.algorithm
|
||||
gpc.algorithm,
|
||||
ROW_NUMBER() OVER (PARTITION BY lm.id ORDER BY gpc.month_income DESC) as rn
|
||||
FROM
|
||||
lease_machine lm
|
||||
JOIN
|
||||
lease_machine_config gpc ON lm.id = gpc.machine_id AND lm.type = #{sellerMachineVo.type} AND lm.shop_id = #{shopId}
|
||||
ORDER BY lm.id, gpc.month_income DESC
|
||||
) t,
|
||||
(SELECT @rn := 0, @prev_id := 0) r
|
||||
) sub
|
||||
where
|
||||
sub.del = false and sub.rn = 1
|
||||
sub.del = false and sub.online_status = 1 and sub.rn = 1
|
||||
<if test="sellerMachineVo.name != null and sellerMachineVo.name != ''">
|
||||
AND sub.name LIKE CONCAT('%', #{sellerMachineVo.name}, '%')
|
||||
</if>
|
||||
<if test="sellerMachineVo.keyword != null and sellerMachineVo.keyword != ''">
|
||||
AND sub.name LIKE CONCAT('%', #{sellerMachineVo.keyword}, '%')
|
||||
</if>
|
||||
|
||||
-- 开发环境
|
||||
<!-- SELECT-->
|
||||
<!-- sub.id,-->
|
||||
<!-- sub.shop_id as shopId,-->
|
||||
<!-- sub.type,-->
|
||||
<!-- sub.`user`,-->
|
||||
<!-- sub.miner,-->
|
||||
<!-- sub.state,-->
|
||||
<!-- sub.sale_state AS saleState,-->
|
||||
<!-- sub.max_lease_days AS maxLeaseDays,-->
|
||||
<!-- sub.del,-->
|
||||
<!-- sub.power_dissipation as powerDissipation,-->
|
||||
<!-- sub.hashrate as theoryPower,-->
|
||||
<!-- sub.unit,-->
|
||||
<!-- sub.coin,-->
|
||||
<!-- sub.month_income as monthIncome,-->
|
||||
<!-- sub.name,-->
|
||||
<!-- sub.algorithm,-->
|
||||
<!-- sub.online_status AS onlineStatus,-->
|
||||
<!-- sub.sale_numbers as saleNumbers,-->
|
||||
<!-- sub.sale_out_numbers as saleOutNumbers-->
|
||||
<!-- FROM-->
|
||||
<!-- (-->
|
||||
<!-- SELECT-->
|
||||
<!-- lm.id,-->
|
||||
<!-- lm.shop_id,-->
|
||||
<!-- lm.type,-->
|
||||
<!-- lm.`user`,-->
|
||||
<!-- lm.miner,-->
|
||||
<!-- lm.state,-->
|
||||
<!-- lm.sale_state,-->
|
||||
<!-- lm.max_lease_days,-->
|
||||
<!-- lm.del,-->
|
||||
<!-- lm.online_status,-->
|
||||
<!-- lm.sale_numbers,-->
|
||||
<!-- lm.sale_out_numbers,-->
|
||||
<!-- gpc.power_dissipation,-->
|
||||
<!-- gpc.hashrate,-->
|
||||
<!-- gpc.unit,-->
|
||||
<!-- gpc.coin,-->
|
||||
<!-- gpc.month_income,-->
|
||||
<!-- gpc.name,-->
|
||||
<!-- gpc.algorithm,-->
|
||||
<!-- ROW_NUMBER() OVER (PARTITION BY lm.id ORDER BY gpc.month_income DESC) as rn-->
|
||||
<!-- FROM-->
|
||||
<!-- lease_machine lm-->
|
||||
<!-- JOIN-->
|
||||
<!-- lease_machine_config gpc ON lm.id = gpc.machine_id AND lm.type = #{sellerMachineVo.type} AND lm.shop_id = #{shopId}-->
|
||||
<!-- ) sub-->
|
||||
<!-- where-->
|
||||
<!-- sub.del = false and sub.rn = 1-->
|
||||
<!-- <if test="sellerMachineVo.name != null and sellerMachineVo.name != ''">-->
|
||||
<!-- AND sub.name LIKE CONCAT('%', #{sellerMachineVo.name}, '%')-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="sellerMachineVo.keyword != null and sellerMachineVo.keyword != ''">-->
|
||||
<!-- AND sub.name LIKE CONCAT('%', #{sellerMachineVo.keyword}, '%')-->
|
||||
<!-- </if>-->
|
||||
</select>
|
||||
|
||||
|
||||
@@ -427,167 +252,71 @@
|
||||
</select>
|
||||
<select id="getMachinesByIds" resultType="com.m2pool.lease.dto.v2.CartMachineInfoDto">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
t.id,
|
||||
t.shop_id AS shopId,
|
||||
t.type,
|
||||
t.`user`,
|
||||
t.miner,
|
||||
t.state,
|
||||
t.sale_state AS saleState,
|
||||
t.max_lease_days AS maxLeaseDays,
|
||||
t.del,
|
||||
t.power_dissipation AS powerDissipation,
|
||||
t.hashrate AS power,
|
||||
t.unit,
|
||||
t.coin,
|
||||
t.month_income AS monthIncome,
|
||||
t.NAME,
|
||||
t.online_status AS onlineStatus,
|
||||
t.can_sale_numbers as canSaleNumbers,
|
||||
t.algorithm,
|
||||
t.cartInfoId,
|
||||
t.numbers,
|
||||
t.lease_time AS leaseTime,
|
||||
@rn := IF(@prev_id = t.id, @rn + 1, 1) AS rn,
|
||||
@prev_id := t.id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
sub.id,
|
||||
sub.shop_id ,
|
||||
sub.shop_id AS shopId,
|
||||
sub.type,
|
||||
sub.`user`,
|
||||
sub.miner,
|
||||
sub.state,
|
||||
sub.sale_state ,
|
||||
sub.max_lease_days ,
|
||||
sub.sale_state AS saleState,
|
||||
sub.max_lease_days AS maxLeaseDays,
|
||||
sub.del,
|
||||
sub.power_dissipation ,
|
||||
sub.hashrate ,
|
||||
sub.power_dissipation AS powerDissipation,
|
||||
sub.hashrate AS power,
|
||||
sub.unit,
|
||||
sub.coin,
|
||||
sub.month_income,
|
||||
sub.month_income AS monthIncome,
|
||||
sub.NAME,
|
||||
sub.online_status ,
|
||||
sub.can_sale_numbers ,
|
||||
sub.online_status AS onlineStatus,
|
||||
sub.can_sale_numbers as canSaleNumbers,
|
||||
sub.algorithm,
|
||||
ci.id AS cartInfoId,
|
||||
ci.numbers,
|
||||
ci.lease_time AS lease_time
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
lm.id,
|
||||
lm.shop_id,
|
||||
lm.type,
|
||||
lm.`user`,
|
||||
lm.miner,
|
||||
lm.state,
|
||||
lm.sale_state,
|
||||
lm.max_lease_days,
|
||||
lm.del,
|
||||
lm.online_status,
|
||||
lm.can_sale_numbers,
|
||||
gpc.power_dissipation AS power_dissipation,
|
||||
gpc.hashrate,
|
||||
gpc.month_income AS month_income,
|
||||
gpc.unit,
|
||||
gpc.coin,
|
||||
gpc.name,
|
||||
gpc.algorithm
|
||||
ci.lease_time AS leaseTime,
|
||||
ROW_NUMBER() OVER ( PARTITION BY sub.id ORDER BY sub.month_income DESC ) AS rn
|
||||
FROM
|
||||
lease_machine lm
|
||||
(
|
||||
SELECT
|
||||
lm.id,
|
||||
lm.shop_id,
|
||||
lm.type,
|
||||
lm.`user`,
|
||||
lm.miner,
|
||||
lm.state,
|
||||
lm.sale_state,
|
||||
lm.max_lease_days,
|
||||
lm.del,
|
||||
lm.online_status,
|
||||
lm.can_sale_numbers,
|
||||
gpc.power_dissipation AS power_dissipation,
|
||||
gpc.hashrate,
|
||||
gpc.month_income AS month_income,
|
||||
gpc.unit,
|
||||
gpc.coin,
|
||||
gpc.NAME,
|
||||
gpc.algorithm
|
||||
FROM
|
||||
lease_machine lm
|
||||
JOIN lease_machine_config gpc ON lm.id = gpc.machine_id AND gpc.status = 1
|
||||
GROUP BY
|
||||
lm.id,
|
||||
gpc.coin,
|
||||
gpc.`algorithm`,gpc.power_dissipation,gpc.hashrate,gpc.month_income, gpc.unit, gpc.name
|
||||
) sub
|
||||
JOIN lease_shopping_cart_info ci ON sub.id = ci.product_machine_id AND ci.user_id = #{userId}
|
||||
AND ci.version = 1
|
||||
WHERE
|
||||
lm.id,
|
||||
gpc.coin,
|
||||
gpc.`algorithm`
|
||||
) sub
|
||||
JOIN lease_shopping_cart_info ci ON sub.id = ci.product_machine_id AND ci.user_id = #{userId}
|
||||
AND ci.version = 1
|
||||
WHERE
|
||||
sub.id IN
|
||||
<foreach collection="machineIds" item="machineId" open="(" separator="," close=")">
|
||||
#{machineId}
|
||||
</foreach>
|
||||
ORDER BY sub.id, sub.month_income DESC
|
||||
) t,
|
||||
(SELECT @rn := 0, @prev_id := 0) r
|
||||
) t
|
||||
WHERE
|
||||
rn = 1
|
||||
|
||||
-- 开发环境
|
||||
<!-- SELECT-->
|
||||
<!-- *-->
|
||||
<!-- FROM-->
|
||||
<!-- (-->
|
||||
<!-- SELECT-->
|
||||
<!-- sub.id,-->
|
||||
<!-- sub.shop_id AS shopId,-->
|
||||
<!-- sub.type,-->
|
||||
<!-- sub.`user`,-->
|
||||
<!-- sub.miner,-->
|
||||
<!-- sub.state,-->
|
||||
<!-- sub.sale_state AS saleState,-->
|
||||
<!-- sub.max_lease_days AS maxLeaseDays,-->
|
||||
<!-- sub.del,-->
|
||||
<!-- sub.power_dissipation AS powerDissipation,-->
|
||||
<!-- sub.hashrate AS power,-->
|
||||
<!-- sub.unit,-->
|
||||
<!-- sub.coin,-->
|
||||
<!-- sub.month_income AS monthIncome,-->
|
||||
<!-- sub.NAME,-->
|
||||
<!-- sub.online_status AS onlineStatus,-->
|
||||
<!-- sub.can_sale_numbers as canSaleNumbers,-->
|
||||
<!-- sub.algorithm,-->
|
||||
<!-- ci.id AS cartInfoId,-->
|
||||
<!-- ci.numbers,-->
|
||||
<!-- ci.lease_time AS leaseTime,-->
|
||||
<!-- ROW_NUMBER() OVER ( PARTITION BY sub.id ORDER BY sub.month_income DESC ) AS rn-->
|
||||
<!-- FROM-->
|
||||
<!-- (-->
|
||||
<!-- SELECT-->
|
||||
<!-- lm.id,-->
|
||||
<!-- lm.shop_id,-->
|
||||
<!-- lm.type,-->
|
||||
<!-- lm.`user`,-->
|
||||
<!-- lm.miner,-->
|
||||
<!-- lm.state,-->
|
||||
<!-- lm.sale_state,-->
|
||||
<!-- lm.max_lease_days,-->
|
||||
<!-- lm.del,-->
|
||||
<!-- lm.online_status,-->
|
||||
<!-- lm.can_sale_numbers,-->
|
||||
<!-- gpc.power_dissipation AS power_dissipation,-->
|
||||
<!-- gpc.hashrate,-->
|
||||
<!-- gpc.month_income AS month_income,-->
|
||||
<!-- gpc.unit,-->
|
||||
<!-- gpc.coin,-->
|
||||
<!-- gpc.NAME,-->
|
||||
<!-- gpc.algorithm-->
|
||||
<!-- FROM-->
|
||||
<!-- lease_machine lm-->
|
||||
<!-- JOIN lease_machine_config gpc ON lm.id = gpc.machine_id AND gpc.status = 1-->
|
||||
<!-- GROUP BY-->
|
||||
<!-- lm.id,-->
|
||||
<!-- gpc.coin,-->
|
||||
<!-- gpc.`algorithm`-->
|
||||
<!-- ) sub-->
|
||||
<!-- JOIN lease_shopping_cart_info ci ON sub.id = ci.product_machine_id AND ci.user_id = #{userId}-->
|
||||
<!-- AND ci.version = 1-->
|
||||
<!-- WHERE-->
|
||||
<!-- sub.id IN-->
|
||||
<!-- <foreach collection="machineIds" item="machineId" open="(" separator="," close=")">-->
|
||||
<!-- #{machineId}-->
|
||||
<!-- </foreach>-->
|
||||
<!-- ) t-->
|
||||
<!-- WHERE-->
|
||||
<!-- rn = 1-->
|
||||
) t
|
||||
WHERE
|
||||
rn = 1
|
||||
</select>
|
||||
<select id="getCoinAndAlgoList" resultType="com.m2pool.lease.dto.v2.AsicCoinAndAlgoDto">
|
||||
select
|
||||
|
||||
@@ -100,54 +100,24 @@
|
||||
SELECT
|
||||
t.datetime AS recordTime,
|
||||
t.hashrate AS power,
|
||||
t.miner
|
||||
t.miner,
|
||||
t.unit
|
||||
FROM (
|
||||
SELECT
|
||||
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}`
|
||||
WHERE wallet = #{wallet}
|
||||
AND coin = #{coin}
|
||||
AND miner IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.workerId}
|
||||
</foreach>
|
||||
)
|
||||
ORDER BY miner, datetime DESC
|
||||
) sub,
|
||||
(SELECT @rn := 0, @prev_miner := '') r
|
||||
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
|
||||
|
||||
-- 开发环境
|
||||
<!-- 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-->
|
||||
</select>
|
||||
<select id="getRecently24HourHashrate" resultType="com.m2pool.lease.dto.v2.RealHashrateInfoDto">
|
||||
SELECT
|
||||
@@ -211,7 +181,7 @@
|
||||
pool = #{info.pool} AND
|
||||
pool_url = #{info.poolUrl} AND
|
||||
coin = #{info.coin} AND
|
||||
`algorithm` = #{info.algorithm} AND status = 1
|
||||
`algorithm` = #{info.algorithm} AND auth_id = #{authId} AND status = 1
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
@@ -38,29 +38,6 @@
|
||||
</select>
|
||||
<select id="getUserMinerPower" resultType="com.m2pool.lease.dto.UserMinerPowerDto">
|
||||
|
||||
<!-- SELECT-->
|
||||
<!-- sub.`user`,-->
|
||||
<!-- sub.`miner`,-->
|
||||
<!-- sub.startTime,-->
|
||||
<!-- sub.power,-->
|
||||
<!-- sub.coin-->
|
||||
<!-- FROM (-->
|
||||
<!-- SELECT-->
|
||||
<!-- `user`,-->
|
||||
<!-- `miner`,-->
|
||||
<!-- `date` as startTime,-->
|
||||
<!-- mhs as power,-->
|
||||
<!-- #{coin} as coin,-->
|
||||
<!-- ROW_NUMBER() OVER (PARTITION BY `user`, `miner` ORDER BY `date` DESC) as rn-->
|
||||
<!-- FROM ${coin}_mhs30m-->
|
||||
<!-- WHERE-->
|
||||
<!-- <foreach collection="list" item="pair" separator="OR">-->
|
||||
<!-- (`user` = #{pair.user} AND miner = #{pair.miner})-->
|
||||
<!-- </foreach>-->
|
||||
<!-- ) sub-->
|
||||
<!-- WHERE sub.rn = 1; TODO 开发环境修改-->
|
||||
|
||||
|
||||
SELECT
|
||||
sub.`user`,
|
||||
sub.`miner`,
|
||||
@@ -69,30 +46,53 @@
|
||||
sub.coin
|
||||
FROM (
|
||||
SELECT
|
||||
t.`user`,
|
||||
t.`miner`,
|
||||
t.`date` as startTime,
|
||||
t.mhs as power,
|
||||
#{coin} as coin,
|
||||
@row_num := IF(@current_user = t.`user` AND @current_miner = t.`miner`, @row_num + 1, 1) as rn,
|
||||
@current_user := t.`user`,
|
||||
@current_miner := t.`miner`
|
||||
FROM (
|
||||
SELECT
|
||||
`user`,
|
||||
`miner`,
|
||||
`date`,
|
||||
mhs
|
||||
`date` as startTime,
|
||||
mhs as power,
|
||||
#{coin} as coin,
|
||||
ROW_NUMBER() OVER (PARTITION BY `user`, `miner` ORDER BY `date` DESC) as rn
|
||||
FROM ${coin}_mhs30m
|
||||
WHERE
|
||||
<foreach collection="list" item="pair" separator="OR">
|
||||
(`user` = #{pair.user} AND miner = #{pair.miner})
|
||||
</foreach>
|
||||
ORDER BY `user`, `miner`, `date` DESC
|
||||
) t
|
||||
JOIN (SELECT @row_num := 0, @current_user := NULL, @current_miner := NULL) vars
|
||||
) sub
|
||||
WHERE sub.rn = 1;
|
||||
|
||||
|
||||
<!-- SELECT-->
|
||||
<!-- sub.`user`,-->
|
||||
<!-- sub.`miner`,-->
|
||||
<!-- sub.startTime,-->
|
||||
<!-- sub.power,-->
|
||||
<!-- sub.coin-->
|
||||
<!-- FROM (-->
|
||||
<!-- SELECT-->
|
||||
<!-- t.`user`,-->
|
||||
<!-- t.`miner`,-->
|
||||
<!-- t.`date` as startTime,-->
|
||||
<!-- t.mhs as power,-->
|
||||
<!-- #{coin} as coin,-->
|
||||
<!-- @row_num := IF(@current_user = t.`user` AND @current_miner = t.`miner`, @row_num + 1, 1) as rn,-->
|
||||
<!-- @current_user := t.`user`,-->
|
||||
<!-- @current_miner := t.`miner`-->
|
||||
<!-- FROM (-->
|
||||
<!-- SELECT-->
|
||||
<!-- `user`,-->
|
||||
<!-- `miner`,-->
|
||||
<!-- `date`,-->
|
||||
<!-- mhs-->
|
||||
<!-- FROM ${coin}_mhs30m-->
|
||||
<!-- WHERE-->
|
||||
<!-- <foreach collection="list" item="pair" separator="OR">-->
|
||||
<!-- (`user` = #{pair.user} AND miner = #{pair.miner})-->
|
||||
<!-- </foreach>-->
|
||||
<!-- ORDER BY `user`, `miner`, `date` DESC-->
|
||||
<!-- ) t-->
|
||||
<!-- JOIN (SELECT @row_num := 0, @current_user := NULL, @current_miner := NULL) vars-->
|
||||
<!-- ) sub-->
|
||||
<!-- WHERE sub.rn = 1;-->
|
||||
</select>
|
||||
<update id="updateBatchIncome">
|
||||
INSERT INTO lease_user_owned_product (id, settle_income, settle_usdt_income,start_time, end_time)
|
||||
|
||||
Reference in New Issue
Block a user