租赁系统

This commit is contained in:
yyb
2026-01-05 15:46:59 +08:00
parent 61fa33c27c
commit 5559163b2e
385 changed files with 33178 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
#开发环境
server:
port: 6666
compression:
enabled: true
mime-types: application/json
spring:
#邮箱基本配置
mail:
# 配置在limit_time内用户可以发送limit次验证码
limit: 2 这个是我额外的配置,结合邮箱服务用的
limitTime: 10 这个是我额外的配置
#配置smtp服务主机地址
# sina smtp.sina.cn
# aliyun smtp.aliyun.com
# 163 smtp.163.com 端口号465或994
host: mail.privateemail.com
#发送者邮箱
username: do.not.reply@m2pool.com
#配置密码,注意不是真正的密码,而是刚刚申请到的授权码
# password:
# password: M2202401!
# password: axvm-zfgx-cgcg-qhhu
password: M2202401!
mvc:
pathmatch:
matching-strategy: ant_path_matcher
application:
# 应用名称
name: m2pool-lease
# profiles:
# # 环境配置
# active: test
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 10.168.2.220:8848
namespace: m2_dev
group: m2_dev_group
# server-addr: 127.0.0.1:8808
config:
# 配置中心地址
server-addr: 10.168.2.220:8848
# server-addr: 127.0.0.1:8808
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: m2_dev
group: m2_dev_group
servlet:
multipart:
max-file-size: 2MB
max-request-size: 8MB
netty:
tcp:
client:
port: 2345

View File

@@ -0,0 +1,104 @@
#测试环境
server:
port: 8888
compression:
enabled: true
mime-types: application/json
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
#邮箱基本配置
mail:
# 配置在limit_time内用户可以发送limit次验证码
limit: 2 这个是我额外的配置,结合邮箱服务用的
limitTime: 10 这个是我额外的配置
#配置smtp服务主机地址
# sina smtp.sina.cn
# aliyun smtp.aliyun.com
# 163 smtp.163.com 端口号465或994
host: mail.privateemail.com
#发送者邮箱
username: do.not.reply@m2pool.com
#配置密码,注意不是真正的密码,而是刚刚申请到的授权码
# password:
# password: M2202401!
# password: axvm-zfgx-cgcg-qhhu
password: M2202401!
#端口号
port: 587
# port: 465
#默认的邮件编码为UTF-8
default-encoding: UTF-8
#其他参数
properties:
mail:
#配置SSL 加密工厂
smtp:
ssl:
#本地测试先放开ssl
enable: false
required: false
#开启debug模式这样邮件发送过程的日志会在控制台打印出来方便排查错误
debug: false
socketFactory:
class: javax.net.ssl.SSLSocketFactory
application:
# 应用名称
name: m2pool-lease
# profiles:
# # 环境配置
# active: test
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8808
namespace: m2_test
group: m2_test_group
# server-addr: 127.0.0.1:8808
config:
# 配置中心地址
server-addr: 127.0.0.1:8808
# server-addr: 127.0.0.1:8808
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: m2_test
group: m2_test_group
servlet:
multipart:
max-file-size: 2MB
max-request-size: 8MB
file:
domain: https://test.m2pool.com
path: /var/www/html/web_test
# img: /img
filepath: /home/ubuntu/web
prefix: /statics
client:
# 客户端安装包
download:
client:
windows: /home/ubuntu/web/client/windows
linux: /home/ubuntu/web/client/linux
# 客户端版本号文件名
version: version
netty:
tcp:
client:
port: 2345
image:
prefix: https://test.m2pool.com
myenv:
domain: https://www.m2pool.com
path: /var/www/html/web
img: /img
filepath: /home/ubuntu/prod

View File

@@ -0,0 +1,3 @@
spring:
profiles:
active: dev

View File

@@ -0,0 +1,26 @@
<?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.LeaseAutoAddressMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseAutoAddress">
<id column="id" property="id" />
<result column="address" property="address" />
<result column="status" property="status" />
<result column="from_symbol" property="fromSymbol" />
<result column="from_chain" property="fromChain" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, address, status,from_symbol,from_chain
</sql>
<select id="getOneStatusIsNoUse" resultType="com.m2pool.lease.entity.LeaseAutoAddress">
select address, from_symbol as fromSymbol,from_chain as fromChain from lease_auto_address where status = 0 limit 1
</select>
<select id="getValidAddress" resultType="com.m2pool.lease.dto.UserWalletDataDto">
select address as fromAddress,from_symbol as fromSymbol,from_chain as fromChain from lease_auto_address where status = 1;
</select>
</mapper>

View File

@@ -0,0 +1,46 @@
<?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.LeaseGpuConfigMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseGpuConfig">
<id column="id" property="id" />
<result column="brand" property="brand" />
<result column="name" property="name" />
<result column="status" property="status" />
<result column="memory" property="memory" />
<result column="power_dissipation" property="powerDissipation" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, brand, name, status, memory, power_dissipation, del
</sql>
<insert id="insertOrUpdateBatchByGpuInfo">
insert into lease_gpu_config ( name, algorithm,coin)
values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.model}, #{item.algorithm},'')
</foreach>
ON DUPLICATE KEY UPDATE
name = VALUES(`name`),
`algorithm` = VALUES(`algorithm`),
coin = VALUES(coin)
</insert>
<insert id="insertOrUpdateBatchByEntity">
insert into lease_gpu_config ( name, algorithm, power_dissipation,hashrate,month_income)
values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.name}, #{item.algorithm}, #{item.powerDissipation},#{item.hashrate},#{item.monthIncome})
</foreach>
ON DUPLICATE KEY UPDATE
name = VALUES(`name`),
`algorithm` = VALUES(`algorithm`),
power_dissipation = VALUES(power_dissipation),
hashrate = VALUES(hashrate),
month_income = VALUES(month_income)
</insert>
</mapper>

View File

@@ -0,0 +1,78 @@
<?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.LeaseMachineConfigMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseMachineConfig">
<id column="id" property="id" />
<result column="machine_id" property="machineId" />
<result column="brand" property="brand" />
<result column="name" property="name" />
<result column="status" property="status" />
<result column="coin" property="coin" />
<result column="hashrate" property="hashrate" />
<result column="algorithm" property="algorithm" />
<result column="icon" property="icon" />
<result column="unit" property="unit" />
<result column="month_income" property="monthIncome" />
<result column="power_dissipation" property="powerDissipation" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, machine_id, brand, name, status, coin, hashrate, algorithm, icon, unit, month_income, power_dissipation, del
</sql>
<select id="getConfigList" resultType="com.m2pool.lease.dto.v2.MiningConfigSelectDto">
SELECT
DISTINCT
lpc.id as poolId,
lpc.`name` as poolName,
lpc.wallet_mining as walletMining,
lpcc.coin,
lpcc.algorithm,
lpcc.id as coinConfigId,
lpcc.mining_tcp_gpu_url as miningTcpGpuUrl,
lpcc.model_name as modelName,
lpcc.model_fee as modelFee
FROM
lease_pool_coin_config lpcc
JOIN
lease_pool_config lpc
ON lpcc.pool_config_id = lpc.id
WHERE
lpcc.status = 1 AND lpc.status = 1 AND lpcc.coin = #{coin} AND lpcc.algorithm = #{algorithm}
</select>
<select id="getMachineSupportCoinAndAlgorithm" resultType="com.m2pool.lease.dto.v2.CoinAndAlgorithmDto">
SELECT
lpc.coin,
lpc.algorithm,
GROUP_CONCAT(DISTINCT lmc.machine_id ORDER BY lmc.machine_id SEPARATOR ',') AS machineIds
FROM
lease_pool_coin_config lpc
JOIN
lease_machine_config lmc ON lpc.coin = lmc.coin AND lpc.algorithm = lmc.algorithm
WHERE
lpc.status = 1
AND lmc.status = 1
AND lmc.del = 0
<if test="machineIds != null and machineIds.size() > 0">
AND lmc.machine_id IN
<foreach collection="machineIds" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</if>
GROUP BY
lpc.coin, lpc.algorithm
</select>
<select id="getTheoryHashRate" resultType="com.m2pool.lease.dto.v2.MachineHashRateMapDto">
SELECT machine_id as machineId,hashrate as hashRate FROM lease_machine_config
-- TODO 这里最好加个算法,加算法后一一对应
WHERE del = 0 AND (machine_id,coin) IN
<foreach collection="list" item="item" open="(" separator="," close=")">
(#{item.machineId},#{item.coin})
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,471 @@
<?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.LeaseMachineMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseMachine">
<id column="id" property="id" />
<result column="shop_id" property="shopId" />
<result column="type" property="type" />
<result column="max_lease_days" property="maxLeaseDays" />
<result column="sale_state" property="saleState" />
<result column="state" property="state" />
<result column="del" property="del" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="user" property="user" />
<result column="miner" property="miner" />
<result column="sale_numbers" property="saleNumbers" />
<result column="sale_out_numbers" property="saleOutNumbers" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, shop_id, type, single_power, total_power, unit, max_lease_days, price, power_dissipation, sale_state, state, del, create_time, update_time, coin, algorithm, gpu_config_id, user, miner, sale_numbers, sale_out_numbers
</sql>
<select id="getShopIds" resultType="java.lang.Long">
select shop_id from lease_machine where del = 0
</select>
<select id="getExistsMachineShop" resultType="com.m2pool.lease.dto.v2.ShopInfoDto">
SELECT
ls.id AS shopId,
ls.name AS shopName,
ls.image,
ls.description,
ls.sale_number AS saleNumber,
GROUP_CONCAT(DISTINCT sub.type SEPARATOR ',') AS type,
GROUP_CONCAT(DISTINCT sub.coin SEPARATOR ',') AS coin,
GROUP_CONCAT(DISTINCT sub.algorithm SEPARATOR ',') AS algorithm
FROM
lease_shop ls
LEFT JOIN (
SELECT
mm.shop_id,
mm.type,
gpc.coin,
gpc.algorithm
FROM
lease_machine mm
JOIN
lease_machine_config gpc ON mm.id = gpc.machine_id AND mm.online_status = true
) sub ON ls.id = sub.shop_id
WHERE ls.del = false AND ls.id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
<choose>
<when test="coin != null and coin != ''">
AND (sub.coin LIKE CONCAT('%', #{coin}, '%')
<if test="algorithm != null and algorithm != ''">
AND sub.algorithm LIKE CONCAT('%', #{algorithm}, '%')
</if>
)
</when>
<otherwise>
<if test="algorithm != null and algorithm != ''">
AND sub.algorithm LIKE CONCAT('%', #{algorithm}, '%')
</if>
</otherwise>
</choose>
GROUP BY ls.id, ls.name, ls.image, ls.description, ls.sale_number
ORDER BY ls.fee_rate DESC, ls.sale_number DESC
</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>
<select id="getGpuConfigList" resultType="com.m2pool.lease.dto.v2.PowerIncomeInfoDto">
SELECT
coin,
algorithm,
sum(hashrate) as power,
sum(month_income) as monthIncome,
sum(power_dissipation) as powerDissipation,
unit,
machine_id
FROM
lease_machine_config
WHERE
status = true AND machine_id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
group by machine_id,coin, algorithm
</select>
<select id="getShopMachineListForSeller" resultType="com.m2pool.lease.dto.v2.SellerMachineInfoDto">
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>
<select id="getMachinePriceList" resultType="com.m2pool.lease.dto.MachinePayTypeDto">
select
id as payTypeId,
machine_id as productMachineId,
price,
coin,
chain
from lease_machine_price
where
<foreach collection="list" item="item" separator="OR">
(`machine_id` = #{item.id} AND del = false)
</foreach>
</select>
<select id="getShopIdsByMachineIds" resultType="java.lang.Long">
SELECT
DISTINCT shop_id as shopId
FROM
lease_machine
WHERE
id IN
<foreach collection="machineIds" item="machineId" open="(" separator="," close=")">
#{machineId}
</foreach>
</select>
<select id="getMachinesByIds" resultType="com.m2pool.lease.dto.v2.CartMachineInfoDto">
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.version = 1
WHERE
sub.id IN
<foreach collection="machineIds" item="machineId" open="(" separator="," close=")">
#{machineId}
</foreach>
) t
WHERE
rn = 1
</select>
<select id="getCoinAndAlgoList" resultType="com.m2pool.lease.dto.v2.AsicCoinAndAlgoDto">
select
id as coinAndPowerId,
machine_id as productMachineId,
hashrate as theoryPower,
coin,
algorithm,
unit
from lease_machine_config
where
<foreach collection="list" item="item" separator="OR">
(`machine_id` = #{item.id} AND del = false)
</foreach>
</select>
<update id="updateLockState">
UPDATE lease_machine
SET
sale_state = 1,
can_sale_numbers = 0,
sale_out_numbers = 1
WHERE
id IN
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.id}
</foreach>
and sale_state = 0
</update>
<update id="updateLockNumbers">
<foreach collection="list" item="item" separator=";">
UPDATE lease_machine
SET
sale_out_numbers = #{item.saleOutNumbers},
sale_state = CASE WHEN #{item.saleOutNumbers} = sale_numbers THEN 1 ELSE sale_state END,
can_sale_numbers = #{item.canSaleNumbers}
WHERE
id = #{item.id}
AND sale_out_numbers = #{item.lockNumbers}
</foreach>
</update>
<select id="getCoinAndAlgoById" resultType="com.m2pool.lease.dto.v2.MiningConfigDto">
select
id,
coin,
mining_tcp_gpu_url as pool,
algorithm as algo
from lease_pool_coin_config
where
id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="getEffectMachineAndTempMachineList" resultType="com.m2pool.lease.dto.v2.MachineConfigDto">
select
id,
machine_id as machineId,
brand,
name,
memory,
coin,
algorithm,
false as isTemp
from lease_machine_config
where
machine_id = #{machineId}
union all
select
id,
machine_id as machineId,
brand,
name,
memory,
coin,
algorithm,
true as isTemp
from lease_machine_temp_config
where
machine_id = #{machineId}
</select>
<select id="getSupportCoin" resultType="java.lang.String">
SELECT DISTINCT
sc.coin
FROM
lease_mining_software_config sc
JOIN lease_pool_coin_config cc ON sc.coin = cc.coin
AND cc.STATUS = 1
</select>
<select id="getSupportAlgo" resultType="java.lang.String">
SELECT DISTINCT
cc.`algorithm`
FROM
lease_mining_software_config sc
JOIN lease_pool_coin_config cc ON sc.`algorithm` = cc.`algorithm`
AND cc.STATUS = 1 AND sc.coin = #{coin} AND cc.coin = #{coin}
</select>
<select id="checkIsEffect" resultType="com.m2pool.lease.dto.v2.MachineEffectDto">
SELECT
DISTINCT
sub.machine_id as machineId,
true as effect
FROM
(
SELECT
mp.machine_id,
mp.coin,
mp.`algorithm`
FROM
lease_machine_config mp
JOIN lease_mining_software_config sc ON mp.coin = sc.coin
AND mp.`algorithm` = sc.`algorithm`
) sub
JOIN lease_pool_coin_config cc ON sub.coin = cc.coin
AND sub.`algorithm` = cc.`algorithm`
AND cc.STATUS = 1
WHERE
sub.machine_id IN
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</select>
<update id="updateBatchSaleNumbers">
<foreach collection="list" item="item" separator=";">
UPDATE lease_machine
SET
sale_out_numbers = sale_out_numbers - #{item.saleOutNumbers},
can_sale_numbers = can_sale_numbers + #{item.canSaleNumbers}
WHERE
id = #{item.id}
</foreach>
</update>
<select id="checkHasSaleMachineByShopId" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
lease_machine
WHERE
shop_id = #{shopId}
and `sale_state` = 1
and `del` = 0
</select>
</mapper>

View File

@@ -0,0 +1,42 @@
<?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.LeaseMachinePriceMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseMachinePrice">
<id column="id" property="id" />
<result column="machine_id" property="machineId" />
<result column="price" property="price" />
<result column="coin" property="coin" />
<result column="chain" property="chain" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, machine_id, price, coin, chain, del
</sql>
<select id="getMachinePriceByMachineIds" resultType="com.m2pool.lease.dto.MachinePayTypeDto">
select
machine_id as productMachineId,
price as price,
coin as coin,
chain as chain
from lease_machine_price
where
<foreach collection="list" item="item" separator="OR">
(`machine_id` = #{item})
</foreach>
</select>
<select id="getOrderTotalPriceGroupByChainAndCoin" resultType="com.m2pool.lease.entity.LeaseMachinePrice">
select
machine_id as machineId,
price as price
from lease_machine_price
where
<foreach collection="list" item="item" separator="OR">
(`machine_id` = #{item.machineId} AND coin = #{item.coin} AND chain = #{item.chain})
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,93 @@
<?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.LeaseMachineTempConfigMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseMachineTempConfig">
<id column="id" property="id" />
<result column="machine_id" property="machineId" />
<result column="brand" property="brand" />
<result column="name" property="name" />
<result column="memory" property="memory" />
<result column="status" property="status" />
<result column="coin" property="coin" />
<result column="hashrate" property="hashrate" />
<result column="algorithm" property="algorithm" />
<result column="icon" property="icon" />
<result column="unit" property="unit" />
<result column="month_income" property="monthIncome" />
<result column="power_dissipation" property="powerDissipation" />
<result column="del" property="del" />
<result column="effect_time" property="effectTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, machine_id, brand, name, memory, status, coin, hashrate, algorithm, icon, unit, month_income, power_dissipation, del, effect_time
</sql>
<insert id="insertBatch">
INSERT INTO lease_machine_temp_config (
machine_id,
brand,
`name`,
memory,
status,
coin,
hashrate,
algorithm,
icon,
unit,
month_income,
power_dissipation,
effect_time
)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.machineId},
#{item.brand},
#{item.name},
#{item.memory},
#{item.status},
#{item.coin},
#{item.hashrate},
#{item.algorithm},
#{item.icon},
#{item.unit},
#{item.monthIncome},
#{item.powerDissipation},
#{item.effectTime})
</foreach>
</insert>
<insert id="insertBatchByTempList">
INSERT INTO lease_machine_config (
machine_id,
brand,
`name`,
memory,
status,
coin,
hashrate,
algorithm,
icon,
unit,
month_income,
power_dissipation
)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.machineId},
#{item.brand},
#{item.name},
#{item.memory},
#{item.status},
#{item.coin},
#{item.hashrate},
#{item.algorithm},
#{item.icon},
#{item.unit},
#{item.monthIncome},
#{item.powerDissipation})
</foreach>
</insert>
</mapper>

View File

@@ -0,0 +1,56 @@
<?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.LeaseMiningSoftwareConfigMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseMiningSoftwareConfig">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="coin" property="coin" />
<result column="algorithm" property="algorithm" />
<result column="icon" property="icon" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, name, coin, algorithm, icon, del
</sql>
<select id="selectSupportAlgorithm" resultType="com.m2pool.lease.dto.v2.CoinAndAlgorithmDto">
SELECT
sub.coin,
sub.`algorithm`,
sub.isEffect,
lgc.`name` AS model,
lgc.hashrate AS hashRate,
lgc.power_dissipation AS powerDissipation,
lgc.month_income as monthIncome,
IF(lgc.id,FALSE,TRUE) AS isAdd
FROM
(
SELECT DISTINCT
sc.coin,
sc.algorithm,
IF( cc.id, TRUE, FALSE ) AS isEffect
FROM
lease_mining_software_config sc
LEFT JOIN lease_pool_coin_config cc ON sc.coin = cc.coin AND cc.`algorithm` = sc.`algorithm` AND cc.status = 1
WHERE
sc.del = 0
AND sc.name IN
<foreach item="item" index="index" collection="miningsofts" separator="," open="(" close=")">
#{item}
</foreach>
) sub
LEFT JOIN(
SELECT gc.`name`,gc.hashrate,gc.power_dissipation,gc.algorithm,gc.id,gc.month_income FROM
lease_gpu_config gc
WHERE gc.`name` IN
<foreach item="item" index="index" collection="modelList" separator="," open="(" close=")">
#{item}
</foreach>
) lgc ON sub.`algorithm` = lgc.algorithm
</select>
</mapper>

View File

@@ -0,0 +1,33 @@
<?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.LeaseNexaMachineAvgPowerMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseNexaMachineAvgPower">
<id column="id" property="id" />
<result column="user" property="user" />
<result column="miner" property="miner" />
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="real_avg_power" property="realAvgPower" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user, miner, start_time, end_time, real_avg_power
</sql>
<insert id="insertBatchDatas">
insert into lease_nexa_machine_avg_power (user, miner, start_time, end_time, real_avg_power) values
<foreach collection="list" item="item" separator=",">
(#{item.user}, #{item.miner}, #{item.startTime}, #{item.endTime}, #{item.realAvgPower})
</foreach>
ON DUPLICATE KEY UPDATE
`start_time` = VALUES(`start_time`),
`end_time` = VALUES(`end_time`),
`real_avg_power` = VALUES(`real_avg_power`)
</insert>
<select id="selectListByUserAndMiner" resultType="com.m2pool.lease.entity.LeaseNexaMachineAvgPower">
</select>
</mapper>

View File

@@ -0,0 +1,61 @@
<?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.LeaseNexaMachinePowerMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseNexaMachinePower">
<id column="id" property="id" />
<result column="user" property="user" />
<result column="miner" property="miner" />
<result column="date" property="date" />
<result column="accepts" property="accepts" />
<result column="state" property="state" />
<result column="last_submit" property="lastSubmit" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, `user`, miner, `date`, accepts, `state`, last_submit
</sql>
<select id="getMachinePowerInHashRateById" resultType="com.m2pool.lease.entity.LeaseNexaMachinePower">
SELECT
id,
`user`,
miner,
`date`,
accepts,
`state`,
last_submit
FROM
${tableName}
WHERE
`date` = #{pointDate}
AND (
<foreach collection="leaseProductMachines" item="pair" separator="OR">
(`user` = #{pair.user} AND miner = #{pair.miner})
</foreach>
)
</select>
<select id="getMachineThreePower" resultType="com.m2pool.lease.dto.ProductMachineDto">
SELECT
`user`,
miner,
sum(accepts) as computingPower,
max(date) as endTime,
min(date) as startTime
FROM
${coin}_minersv2
WHERE
`date` >= DATE_SUB(now(), INTERVAL 3 DAY)
<if test="leaseProductMachines != null and leaseProductMachines.size() > 0">
AND (
<foreach collection="leaseProductMachines" item="pair" separator="OR">
(`user` = #{pair.user} AND miner = #{pair.miner})
</foreach>
)
</if>
group by `user`, miner
</select>
</mapper>

View File

@@ -0,0 +1,4 @@
<?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.LeaseOrderFeeMapper">
</mapper>

View File

@@ -0,0 +1,95 @@
<?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.LeaseOrderInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseOrderInfo">
<id column="id" property="id" />
<result column="order_number" property="orderNumber" />
<result column="user_id" property="userId" />
<result column="total_price" property="totalPrice" />
<result column="status" property="status" />
<result column="address" property="address" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, order_number, user_id, total_price, status, address, create_time, update_time, del
</sql>
<select id="getOrdersByStatus" resultType="com.m2pool.lease.dto.OrderInfoDto">
select
loo.id,
loo.order_number as orderNumber,
loo.user_id as userId,
loo.total_price as totalPrice,
loo.status,
loo.create_time as createTime,
loo.update_time as endTime,
loo.shop_name as shopName
from lease_order_info loo
<where>
del = 0 and auth_id = #{authId}
<if test="status != null">
and status = #{status}
</if>
</where>
order by create_time desc
</select>
<select id="getOrdersByStatusForSeller" resultType="com.m2pool.lease.dto.OrderInfoDto">
select
loo.id,
loo.order_number as orderNumber,
loo.user_id as userId,
loo.total_price as totalPrice,
loo.status,
loo.create_time as createTime,
loo.update_time as endTime,
loo.shop_name as shopName
from lease_order_info loo
<where>
del = 0
<if test="status != null">
and status = #{status}
</if>
and id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</where>
order by create_time desc
</select>
<select id="getOrderItemsByMachineId" resultType="com.m2pool.lease.entity.LeaseUserOwnedProduct">
select
loo.id as orderItemId,
loo.user as `user`,
loo.miner as miner,
loo.product_machine_id as productMachineId
from lease_order_info loo
where del = 0 and product_machine_id IN
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="getNeedPayOrderList" resultType="com.m2pool.lease.entity.LeaseOrderInfo">
select
id,
order_number as orderNumber,
user_id as userId,
total_price as totalPrice,
status,
create_time as createTime,
auth_id as authId
from lease_order_info
where del = 0 and status = 7
</select>
<select id="getCoinPrice" resultType="java.math.BigDecimal">
select `value` from ${coin}_price order by id desc limit 1
</select>
</mapper>

View File

@@ -0,0 +1,121 @@
<?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.LeaseOrderItemMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseOrderItem">
<id column="id" property="id" />
<result column="order_id" property="orderId" />
<result column="product_id" property="productId" />
<result column="product_machine_id" property="productMachineId" />
<result column="name" property="name" />
<result column="unit" property="unit" />
<result column="image" property="image" />
<result column="quantity" property="quantity" />
<result column="price" property="price" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, order_id, product_id,product_machine_id,`name`, unit, image, quantity, price, create_time, update_time, del
</sql>
<select id="getMachineByOrderStatusIsPayInData" resultType="java.lang.Long">
select product_machine_id AS productMachineId from lease_order_item
where
<foreach collection="list" item="item" separator="OR">
(`order_id` = #{item.orderId} and `shop_id` = #{item.shopId})
</foreach>
</select>
<select id="getOrderIds" resultType="java.lang.Long">
select DISTINCT order_id FROM lease_order_item
WHERE
id IN
<foreach item="id" collection="orderItemIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="getOrderInfoStatus" resultType="com.m2pool.lease.dto.OrderStatusDto">
SELECT
order_id as orderId,
CASE
WHEN SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) > 0 THEN 7
ELSE 8
END as orderInfoStatus
FROM
`lease_order_item`
WHERE
order_id IN
<foreach item="id" collection="orderIds" open="(" separator="," close=")">
#{id}
</foreach>
GROUP BY
order_id;
</select>
<select id="selectOrderInfoIds" resultType="java.lang.Long">
SELECT
DISTINCT order_id
FROM
`lease_order_item`
WHERE
id IN
<foreach item="id" collection="itemIds" open="(" separator="," close=")">
#{id}
</foreach>
GROUP BY
order_id;
</select>
<select id="getNeedUpdateOrderItem" resultType="com.m2pool.lease.entity.LeaseOrderItem">
SELECT
id,
already_pay_real_amount AS alreadyPayRealAmount,
settle_pay_real_amount AS settlePayRealAmount,
del
FROM
`lease_order_item`
WHERE
order_id = #{orderId}
</select>
<select id="getOrderItemByOrderIds" resultType="com.m2pool.lease.entity.LeaseOrderItem">
SELECT
oi.user,
oi.miner,
oi.coin,
oi.from_address AS fromAddress,
oi.from_chain AS fromChain,
oi.from_symbol AS fromSymbol,
oi.address AS address,
oi.chain AS chain,
oi.symbol AS symbol,
COALESCE(prm.status,0) AS status
FROM
`lease_order_item` oi
LEFT JOIN lease_pay_record_message prm ON
oi.from_address = prm.from_address AND oi.from_chain = prm.from_chain AND oi.from_symbol = prm.from_symbol
AND oi.address = prm.to_address AND oi.chain = prm.to_chain AND oi.symbol = prm.to_symbol AND DATE(prm.create_time) = CURRENT_DATE
WHERE
oi.order_id IN
<foreach item="id" collection="orderIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="getOneDayApartOrder" resultType="com.m2pool.lease.dto.v2.OrderTimeInfoDto">
SELECT
id,
machine_id AS machineId,
order_id AS orderId,
order_item_id as orderItemId,
lease_time AS leaseTime,
create_time AS startTime,
price,
numbers
FROM
lease_order_item
WHERE
STATUS = 1
</select>
</mapper>

View File

@@ -0,0 +1,189 @@
<?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
SET watch_url = #{clientConfigurationMining.watchUrl}
WHERE user_id = #{userEmail} AND pool = #{clientConfigurationMining.pool}
</update>
<select id="getPurchasedItems" resultType="com.m2pool.lease.dto.v2.PurchasedMachineListDto">
select
id,
coin,
algorithm,
pool,
pool_url as poolUrl,
pool_user as poolUser,
wallet_address as walletAddress,
watch_url as watchUrl,
end_time
FROM lease_order_mining
WHERE auth_id = #{authId}
GROUP BY wallet_address,pool_user,pool,pool_url,coin,`algorithm`
ORDER BY `status` DESC,end_time DESC
</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
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
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} )
</foreach>
)
</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
`algorithm` = #{info.algorithm}
</select>
</mapper>

View File

@@ -0,0 +1,90 @@
<?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.LeasePayRechargeMessageMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeasePayRechargeMessage">
<id column="id" property="id" />
<result column="address" property="address" />
<result column="amount" property="amount" />
<result column="chain" property="chain" />
<result column="symbol" property="symbol" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="status" property="status" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, address, amount, symbol,`chain`, create_time, update_time, status, del
</sql>
<select id="balanceRechargeList" resultType="com.m2pool.lease.dto.PayRechargeMessageDto">
select id, address, amount, chain as fromChain, symbol as fromSymbol, create_time as createTime, status, tx_hash as txHash
from lease_pay_recharge_message
<where>
(<foreach collection="walletList" item="item" separator="OR">
(address = #{item.fromAddress}
AND `chain` = #{item.fromChain}
AND symbol = #{item.fromSymbol})
</foreach>)
<if test="status != null">
AND status = #{status}
</if>
</where>
</select>
<select id="checkRechargeOperator" resultType="java.lang.Boolean">
SELECT IF(COUNT(*) > 0, true, false) AS has_data
FROM lease_pay_recharge_message
WHERE address = #{fromAddress} AND create_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 MONTH) AND del = 0;
</select>
<select id="checkRechargeOperatorBatch" resultType="com.m2pool.lease.dto.CheckAddressDto">
SELECT DISTINCT address as fromAddress,chain as fromChain,symbol as fromSymbol, true AS hasOperator
FROM lease_pay_recharge_message
WHERE
(<foreach collection="list" item="item" separator="OR">
(address = #{item.fromAddress} AND `chain` = #{item.fromChain} AND symbol = #{item.fromSymbol})
</foreach>)
AND create_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 MONTH) AND del = 0
GROUP BY address,`chain`,symbol;
</select>
<select id="transactionRecord" resultType="com.m2pool.lease.dto.TransactionRecordDto">
select queue_id as queueId,address as fromAddress, amount, chain as fromChain, symbol as fromSymbol, create_time as createTime, status, tx_hash as txHash
from lease_pay_recharge_message
<where>
(<foreach collection="walletList" item="item" separator="OR">
(queue_id = #{item.queueId} AND address = #{item.fromAddress} AND `chain` = #{item.fromChain} AND symbol = #{item.fromSymbol})
</foreach>)
</where>
order by create_time desc
</select>
<select id="getRecentlyTransaction" resultType="com.m2pool.lease.dto.RecentlyTransactionDto">
select
amount as amount,
update_time as updateTime,
1 as type,status
from lease_pay_recharge_message
<where>
(<foreach collection="walletList" item="item" separator="OR">
(queue_id = #{item.queueId} AND address = #{item.fromAddress} AND `chain` = #{item.fromChain} AND symbol = #{item.fromSymbol})
</foreach>)
</where>
order by update_time desc limit 5
</select>
<insert id="saveOrUpdateByIndex">
insert into lease_pay_recharge_message (queue_id,address, amount, chain, symbol, status,tx_hash)
values (#{leasePayRechargeMessage.queueId},#{leasePayRechargeMessage.address},
#{leasePayRechargeMessage.amount}, #{leasePayRechargeMessage.chain},
#{leasePayRechargeMessage.symbol},#{leasePayRechargeMessage.status},#{leasePayRechargeMessage.txHash})
ON DUPLICATE KEY UPDATE
`queue_id` = VALUES(`queue_id`),
`address` = VALUES(`address`),
`amount` = VALUES(`amount`),
`chain` = VALUES(`chain`),
`symbol` = VALUES(`symbol`),
`status` = VALUES(`status`),
`tx_hash` = VALUES(`tx_hash`)
</insert>
</mapper>

View File

@@ -0,0 +1,27 @@
<?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.LeasePayRecordMessageInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeasePayRecordMessage">
<id column="id" property="id" />
<result column="queue_id" property="queueId" />
<result column="from_address" property="fromAddress" />
<result column="to_address" property="toAddress" />
<result column="amount" property="amount" />
<result column="to_chain" property="toChain" />
<result column="to_symbol" property="toSymbol" />
<result column="from_chain" property="fromChain" />
<result column="from_symbol" property="fromSymbol" />
<result column="order_id" property="orderId" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="status" property="status" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, queue_id, from_address, to_address, amount, `to_chain`, to_symbol,from_chain,from_symbol, order_id,create_time, status, del
</sql>
</mapper>

View File

@@ -0,0 +1,145 @@
<?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.LeasePayRecordMessageMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeasePayRecordMessage">
<id column="id" property="id" />
<result column="queue_id" property="queueId" />
<result column="from_address" property="fromAddress" />
<result column="to_address" property="toAddress" />
<result column="amount" property="amount" />
<result column="to_chain" property="toChain" />
<result column="to_symbol" property="toSymbol" />
<result column="from_chain" property="fromChain" />
<result column="from_symbol" property="fromSymbol" />
<result column="order_id" property="orderId" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="status" property="status" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, queue_id, from_address, to_address, amount, `to_chain`, to_symbol,from_chain,from_symbol, order_id,create_time, status, del
</sql>
<select id="checkPayOperator" resultType="java.lang.Boolean">
SELECT IF(COUNT(*) > 0, true, false) AS has_data
FROM lease_pay_record_message
WHERE from_address = #{fromAddress} AND create_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 MONTH) AND del = 0;
</select>
<select id="checkPayOperatorBatch" resultType="com.m2pool.lease.dto.CheckAddressDto">
SELECT DISTINCT from_address as fromAddress,from_chain as fromChain,from_symbol as fromSymbol, true AS hasOperator
FROM lease_pay_record_message
WHERE
(<foreach collection="list" item="item" separator="OR">
(from_address = #{item.fromAddress} AND `from_chain` = #{item.fromChain} AND from_symbol = #{item.fromSymbol})
</foreach>)
AND create_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 MONTH) AND del = 0
GROUP BY from_address, from_chain, from_symbol
UNION
SELECT DISTINCT from_address as fromAddress,from_chain as fromChain,from_symbol as fromSymbol, true AS hasOperator
FROM lease_pay_record_message_info
WHERE
(<foreach collection="list" item="item" separator="OR">
(from_address = #{item.fromAddress} AND `from_chain` = #{item.fromChain} AND from_symbol = #{item.fromSymbol})
</foreach>)
AND create_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 MONTH) AND del = 0
GROUP BY from_address, from_chain, from_symbol
</select>
<select id="balancePayList" resultType="com.m2pool.lease.dto.PayRecordMessageDto">
select
queue_id as queueId,
from_address as fromAddress,
to_address as toAddress,
amount as amount,
real_amount as realAmount,
to_symbol as toSymbol,
to_chain as toChain,
from_symbol as fromSymbol,
from_chain as fromChain,
tx_hash as txHash,
create_time as createTime,
update_time as updateTime,
status as status,
order_number as orderId
from lease_pay_record_message
<where>
(<foreach collection="walletList" item="item" separator="OR">
(
shop_id = #{item.shopId}
AND to_address = #{item.payAddress}
AND `to_chain` = #{item.chain}
AND to_symbol = #{item.payCoin})
</foreach>)
<if test="status != null">
AND status = #{status}
</if>
</where>
order by update_time desc
</select>
<select id="transactionRecord" resultType="com.m2pool.lease.dto.TransactionRecordDto">
select
queue_id as queueId,
from_address as fromAddress,
to_address as toAddress,
amount as amount,
real_amount as realAmount,
block_amount as blockAmount,
to_symbol as toSymbol,
to_chain as toChain,
from_symbol as fromSymbol,
from_chain as fromChain,
tx_hash as txHash,
order_number as orderId,
create_time as createTime,
update_time as updateTime,
status as status
from lease_pay_record_message
<where>
(<foreach collection="walletList" item="item" separator="OR">
(auth_id = #{item.authId} AND from_address = #{item.fromAddress} AND `from_chain` = #{item.fromChain} AND from_symbol = #{item.fromSymbol})
</foreach>)
</where>
order by create_time desc
</select>
<select id="getRecentlyTransaction" resultType="com.m2pool.lease.dto.RecentlyTransactionDto">
select
case when real_amount = 0 then amount else real_amount end as amount,
update_time as updateTime,
0 as type,
status
from lease_pay_record_message
<where>
(<foreach collection="walletList" item="item" separator="OR">
(auth_id = #{item.authId} AND from_address = #{item.fromAddress} AND `from_chain` = #{item.fromChain} AND from_symbol = #{item.fromSymbol})
</foreach>)
</where>
order by update_time desc limit 5
</select>
<select id="getQueueIdByInfoIds" resultType="java.util.Map">
select
DISTINCT order_id as orderId,
queue_id as queueId
from lease_pay_record_message
where order_id in
<foreach item="item" index="index" collection="infoIds" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<update id="updateByTxHash">
update lease_pay_record_message
set
status = #{leasePayRecordMessage.status},
update_time = #{leasePayRecordMessage.updateTime},
tx_hash = #{leasePayRecordMessage.txHash},
block_height = #{leasePayRecordMessage.blockHeight},
real_amount = #{leasePayRecordMessage.realAmount}
where id = #{leasePayRecordMessage.id} and (tx_hash = "" or tx_hash = #{txHash})
</update>
</mapper>

View File

@@ -0,0 +1,128 @@
<?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.LeasePayWithdrawMessageMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeasePayWithdrawMessage">
<id column="id" property="id" />
<result column="queue_id" property="queueId" />
<result column="from_address" property="fromAddress" />
<result column="to_address" property="toAddress" />
<result column="amount" property="amount" />
<result column="from_chain" property="fromChain" />
<result column="from_symbol" property="fromSymbol" />
<result column="to_chain" property="toChain" />
<result column="to_symbol" property="toSymbol" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="status" property="status" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, queue_id, from_address, to_address, amount, from_chain, from_symbol,to_chain,to_symbol, create_time, update_time, status, del
</sql>
<select id="balanceWithdrawList" resultType="com.m2pool.lease.dto.PayWithdrawMessageDto">
SELECT
id,
from_address as fromAddress,
to_address as toAddress,
amount,
from_symbol as fromSymbol,
from_chain as fromChain,
to_symbol as toSymbol,
to_chain as toChain,
create_time as createTime,
update_time as updateTime,
tx_hash as txHash,
status
FROM lease_pay_withdraw_message
<where>
(<foreach collection="walletList" item="item" separator="OR">
(from_address = #{item.fromAddress}
AND `from_chain` = #{item.fromChain}
AND from_symbol = #{item.fromSymbol})
</foreach>)
<if test="status != null">
AND status = #{status}
</if>
</where>
</select>
<select id="checkWithdrawOperator" resultType="java.lang.Boolean">
SELECT IF(COUNT(*) > 0, true, false) AS has_data
FROM lease_pay_withdraw_message
WHERE from_address = #{fromAddress} AND create_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 MONTH) AND del = 0;
</select>
<select id="checkWithdrawOperatorBatch" resultType="com.m2pool.lease.dto.CheckAddressDto">
SELECT DISTINCT from_address as fromAddress,from_chain as fromChain,from_symbol as fromSymbol, true AS hasOperator
FROM lease_pay_withdraw_message
WHERE
(<foreach collection="list" item="item" separator="OR">
(from_address = #{item.fromAddress} AND `from_chain` = #{item.fromChain} AND from_symbol = #{item.fromSymbol})
</foreach>)
AND create_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 MONTH) AND del = 0
GROUP BY from_address, from_chain, from_symbol;
</select>
<select id="transactionRecord" resultType="com.m2pool.lease.dto.TransactionRecordDto">
SELECT
queue_id as queueId,
from_address as fromAddress,
to_address as toAddress,
amount,
from_symbol as fromSymbol,
from_chain as fromChain,
to_symbol as toSymbol,
to_chain as toChain,
create_time as createTime,
update_time as updateTime,
tx_hash as txHash,
status
FROM lease_pay_withdraw_message
<where>
(<foreach collection="walletList" item="item" separator="OR">
(auth_id = #{item.authId}
AND from_address = #{item.fromAddress}
AND `from_chain` = #{item.fromChain}
AND from_symbol = #{item.fromSymbol})
</foreach>)
</where>
order by create_time desc
</select>
<select id="getRecentlyTransaction" resultType="com.m2pool.lease.dto.RecentlyTransactionDto">
select
amount as amount,
update_time as updateTime,
2 as type,
status
from lease_pay_withdraw_message
<where>
(<foreach collection="walletList" item="item" separator="OR">
( auth_id = #{item.authId} AND from_address = #{item.fromAddress} AND `from_chain` = #{item.fromChain} AND from_symbol = #{item.fromSymbol})
</foreach>)
</where>
order by update_time desc limit 5
</select>
<select id="getRecentlyOneData" resultType="java.lang.Integer">
select status from lease_pay_withdraw_message where from_address = #{fromAddress} and `from_chain` = #{chain} order by create_time desc limit 1
</select>
<select id="getSellerWithdrawRecord" resultType="com.m2pool.lease.dto.v2.PayWithdrawSellerRecordDto">
select
id,
from_address as fromAddress,
to_address as toAddress,
amount,
from_symbol as symbol,
from_chain as chain,
create_time as createTime,
update_time as updateTime,
tx_hash as txHash,
status
from lease_pay_withdraw_message
where shop_id = #{shopId}
order by create_time desc
</select>
</mapper>

View File

@@ -0,0 +1,42 @@
<?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.LeasePaymentRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeasePaymentRecord">
<id column="id" property="id" />
<result column="order_id" property="orderId" />
<result column="amount" property="amount" />
<result column="status" property="status" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, order_id, payment_method, amount, status, create_time, update_time, del
</sql>
<update id="updateBatchStatusForOderIdAndShopId">
update lease_payment_record set status = 5
where
status = 6 AND
(<foreach collection="list" item="item" separator="OR">
(`order_id` = #{item.orderId} and `shop_id` = #{item.shopId})
</foreach>)
</update>
<select id="checkPaymentRecordStatus" resultType="com.m2pool.lease.entity.LeasePaymentRecord">
select id,order_id as orderId,shop_id as shopId,status from lease_payment_record
where
<foreach collection="list" item="item" separator="OR">
(`order_id` = #{item.orderId} and `shop_id` = #{item.shopId})
</foreach>
</select>
<select id="getIsPayInData" resultType="com.m2pool.lease.entity.LeasePaymentRecord">
select id,order_id as orderId, shop_id AS shopId,status,amount,pay_amount AS payAmount,pay_address as payAddress from lease_payment_record
where
create_time > DATE_SUB(NOW(),INTERVAL 15 MINUTE) and del = false
</select>
</mapper>

View File

@@ -0,0 +1,21 @@
<?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.LeaseProductIncomeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseProductIncome">
<id column="id" property="id" />
<result column="user_owned_product_id" property="userOwnedProductId" />
<result column="average_income" property="averageIncome" />
<result column="estimated_end_income" property="estimatedEndIncome" />
<result column="current_actual_income" property="currentActualIncome" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_owned_product_id, average_income, estimated_end_income, current_actual_income, create_time, update_time
</sql>
</mapper>

View File

@@ -0,0 +1,303 @@
<?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.LeaseProductMachineMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseProductMachine">
<id column="id" property="id" />
<result column="product_id" property="productId" />
<result column="user" property="user" />
<result column="miner" property="miner" />
<result column="price" property="price" />
<result column="computing_power" property="computingPower" />
<result column="sale_state" property="saleState" />
<result column="state" property="state" />
<result column="del" property="del" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, product_id, user, miner, price, computing_power, state, del, create_time, update_time
</sql>
<update id="updateLockState">
UPDATE lease_product_machine
SET
sale_state = 1
WHERE
id IN
<foreach item="id" collection="machineIds" open="(" separator="," close=")">
#{id}
</foreach>
and sale_state = 0
</update>
<select id="getMachinesByIds" resultType="com.m2pool.lease.dto.ProductMachineDto">
SELECT
lpm.id,
lpm.shop_id as shopId,
lpm.product_id as productId,
lpm.`user`,
lpm.miner,
lpm.price,
lpm.state,
lpm.sale_state as saleState,
lpm.coin,
lpm.unit,
lpm.power_dissipation as powerDissipation,
lpm.theory_power as theoryPower,
lpm.theory_income as theoryIncome,
lp.name,
lp.algorithm,
lpm.del,
lpm.max_lease_days as maxLeaseDays
FROM
lease_product_machine lpm join lease_product lp on lp.id = lpm.product_id
WHERE
lpm.id IN
<foreach item="id" collection="machineIds" open="(" separator="," close=")">
#{id}
</foreach>
order by product_id
</select>
<select id="getUserMinersList" resultType="com.m2pool.lease.dto.UserMinerDto">
select miner_user as `user`,coin from user_miner_account where user = #{userId} and coin = #{coin}
</select>
<select id="getMinerMachines" resultType="com.m2pool.lease.dto.UserMinerDto">
SELECT `user`, miner, sum(mhs * 30 * 60) AS realPower
FROM ${coin}_mhs30m
WHERE `user` = #{user} AND `date` >= DATE_SUB(NOW(), INTERVAL 1 DAY)
GROUP BY `user`, miner
</select>
<select id="getPriceRange" resultType="com.m2pool.lease.dto.PriceDto">
SELECT
MIN(price) AS priceMin,
MAX(price) AS priceMax,
COUNT(*) AS totalMachineNumber
FROM
lease_product_machine
WHERE
product_id = #{productId} and del = 0
</select>
<select id="getRecentlyFiveMinutesData" resultType="com.m2pool.lease.dto.ProductMachineDto">
SELECT
`user`,
miner,
SUM(mhs * 30 * 60) as computingPower
FROM
${coin}_mhs30m
WHERE
`date` >= DATE_SUB(now(), INTERVAL 1 DAY)
<if test="leaseProductMachines != null and leaseProductMachines.size() > 0">
AND (
<foreach collection="leaseProductMachines" item="pair" separator="OR">
(`user` = #{pair.user} AND miner = #{pair.miner})
</foreach>
)
</if>
group by `user`, miner
</select>
<select id="getMinerMachinesIsSale" resultType="java.lang.String">
select miner from lease_product_machine where `user` = #{user} and `coin` = #{coin} and del = 0;
</select>
<insert id="saveOrUpdateBatchs" useGeneratedKeys="true" keyProperty="id">
INSERT INTO lease_product_machine (
shop_id, product_id, user, type, coin, miner, theory_power,
computing_power, theory_income, unit,
power_dissipation, income_rate, cost, price, sale_state,
state, del,max_lease_days
)
VALUES
<foreach item="item" index="index" collection="leaseProductMachines" separator=",">
(
#{item.shopId}, #{item.productId}, #{item.user}, #{item.type}, #{item.coin}, #{item.miner},
#{item.theoryPower}, #{item.computingPower}, #{item.theoryIncome}, #{item.unit}, #{item.powerDissipation}, #{item.incomeRate}, #{item.cost},
#{item.price}, #{item.saleState}, #{item.state}, #{item.del}, #{item.maxLeaseDays}
)
</foreach>
ON DUPLICATE KEY UPDATE
shop_id = VALUES(shop_id),
product_id = VALUES(product_id),
`type` = VALUES(`type`),
theory_power = VALUES(theory_power),
computing_power = VALUES(computing_power),
theory_income = VALUES(theory_income),
unit = VALUES(unit),
power_dissipation = VALUES(power_dissipation),
income_rate = VALUES(income_rate),
cost = VALUES(cost),
price = VALUES(price),
sale_state = VALUES(sale_state),
`state` = VALUES(`state`),
del = VALUES(del),
max_lease_days = VALUES(max_lease_days)
</insert>
<insert id="batchInsertPowers">
INSERT INTO ${coin}_real_power (user,miner,power,`date`)
VALUES
<foreach item="item" index="index" collection="list" separator=",">
(
#{item.user},
#{item.miner},
#{item.computingPower},
now()
)
</foreach>
ON DUPLICATE KEY UPDATE
power = VALUES(power),
`date` = VALUES(`date`)
</insert>
<select id="checkHasSaleMachineByShopId" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
lease_product_machine
WHERE
shop_id = #{shopId}
and `sale_state` = 1
and `del` = 0
</select>
<select id="checkHasSaleMachineByProductId" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
lease_product_machine
WHERE
product_id = #{productId}
and `sale_state` = 1
and `del` = 0
</select>
<select id="getPriceList" resultType="com.m2pool.lease.dto.MachinePayTypeDto">
SELECT
id as payTypeId, product_machine_id as productMachineId, price, coin,chain
FROM
lease_product_machine_price
WHERE
del = false and product_machine_id IN
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="getProductListForShopWalletConfig" resultType="com.m2pool.lease.dto.ProductMachineForWalletConfigDto">
SELECT
lpm.id as productMachineId,
lpm.product_id as productId,
lpm.`user`,
lpm.type,
lpm.miner,
lpm.unit,
lpm.state,
lpm.coin,
lpm.sale_state as saleState,
lpm.theory_power as theoryPower,
lpm.theory_income as theoryIncome,
lpm.power_dissipation as powerDissipation
FROM
lease_product_machine lpm
WHERE
del = false AND lpm.shop_id = #{shopId}
</select>
<select id="getIdsForProductId" resultType="java.lang.Long">
SELECT
id
FROM
lease_product_machine
WHERE
product_id = #{productId}
and `del` = 0
</select>
<select id="getMachinesByPriceAndPowerAndDissipation" resultType="com.m2pool.lease.dto.ProductMachineDto">
SELECT
pm.id,
pm.shop_id as shopId,
pm.product_id as productId,
pm.`user`,
pm.type,
pm.miner,
pm.theory_power as theoryPower,
pm.theory_income as theoryIncome,
pm.unit,
pm.power_dissipation as powerDissipation,
pm.income_rate as incomeRate,
pm.cost,
pm.sale_state as saleState,
pm.state,
pm.del,
pm.max_lease_days as maxLeaseDays,
COALESCE(pmp.price,0) as price,
pm.coin,
pmp.coin as payCoin,
COALESCE(rp.power,0) as computingPower
FROM
lease_product_machine pm
LEFT JOIN lease_product_machine_price pmp
ON pm.id = pmp.product_machine_id AND pmp.coin = #{productMachineVo.coin} AND pmp.chain = #{productMachineVo.chain} AND pmp.del = false
LEFT JOIN ${coin}_real_power rp
ON pm.user = rp.user AND rp.miner = pm.miner
WHERE
pm.del = false AND pm.`state` = 0 AND pm.product_id = #{productMachineVo.id}
<!-- 实际算力范围筛选 -->
<if test="productMachineVo.minPower != 0 or productMachineVo.maxPower != 0">
AND rp.power >= #{productMachineVo.minPower} AND rp.power <![CDATA[<=]]> #{productMachineVo.maxPower}
</if>
<!-- 功耗范围筛选 -->
<if test="productMachineVo.minPowerDissipation != 0 or productMachineVo.maxPowerDissipation != 0">
AND power_dissipation >= #{productMachineVo.minPowerDissipation} AND power_dissipation <![CDATA[<=]]> #{productMachineVo.maxPowerDissipation}
</if>
<!-- 单价范围筛选 -->
<if test="productMachineVo.minPrice != 0 or productMachineVo.maxPrice != 0">
AND pmp.price >= #{productMachineVo.minPrice} AND pmp.price <![CDATA[<=]]> #{productMachineVo.maxPrice}
</if>
<!-- <if test="productMachineVo.priceSort != null">-->
<!-- ORDER BY-->
<!-- <choose>-->
<!-- &lt;!&ndash; 价格排序 &ndash;&gt;-->
<!-- <when test="productMachineVo.priceSort">-->
<!-- pmp.price ASC-->
<!-- </when>-->
<!-- <otherwise>-->
<!-- pmp.price DESC-->
<!-- </otherwise>-->
<!-- </choose>-->
<!-- </if>-->
<!-- <if test="productMachineVo.powerSort != null">-->
<!-- ORDER BY-->
<!-- <choose>-->
<!-- &lt;!&ndash; 实际算力排序 &ndash;&gt;-->
<!-- <when test="productMachineVo.powerSort">-->
<!-- rp.power ASC-->
<!-- </when>-->
<!-- <otherwise>-->
<!-- rp.power DESC-->
<!-- </otherwise>-->
<!-- </choose>-->
<!-- </if>-->
<!-- <if test="productMachineVo.powerDissipationSort != null">-->
<!-- ORDER BY-->
<!-- <choose>-->
<!-- &lt;!&ndash; 功耗排序 &ndash;&gt;-->
<!-- <when test="productMachineVo.powerDissipationSort">-->
<!-- power_dissipation ASC-->
<!-- </when>-->
<!-- <otherwise>-->
<!-- power_dissipation DESC-->
<!-- </otherwise>-->
<!-- </choose>-->
<!-- </if>-->
</select>
<select id="getIdsForShopId" resultType="java.lang.Long">
SELECT
id
FROM
lease_machine
WHERE
shop_id = #{shopId}
and `del` = 0
</select>
</mapper>

View File

@@ -0,0 +1,40 @@
<?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.LeaseProductMachinePriceMapper">
<select id="getOrderTotalPriceGroupByChainAndCoin"
resultType="com.m2pool.lease.entity.LeaseProductMachinePrice">
select
product_machine_id as productMachineId,
price as price
from lease_product_machine_price
where
<foreach collection="list" item="item" separator="OR">
(`product_machine_id` = #{item.machineId} AND coin = #{item.coin} AND chain = #{item.chain})
</foreach>
</select>
<select id="getMachinePriceByMachineIds" resultType="com.m2pool.lease.dto.MachinePayTypeDto">
select
product_machine_id as productMachineId,
price as price,
coin as coin,
chain as chain
from lease_product_machine_price
where
<foreach collection="list" item="item" separator="OR">
(`product_machine_id` = #{item} AND del = false)
</foreach>
</select>
<select id="getPriceByOrderItems" resultType="java.util.Map">
select
product_machine_id as machineId,
price as price
from lease_product_machine_price
where
<foreach collection="list" item="item" separator="OR">
(`product_machine_id` = #{item.productMachineId} AND coin = #{item.symbol} AND chain = #{item.chain})
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,141 @@
<?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.LeaseProductMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseProduct">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="image" property="image" />
<result column="type" property="type" />
<result column="state" property="state" />
<result column="description" property="description" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, `name`, image,`state`,unit, `type`, description, create_time, update_time, del
</sql>
<select id="getCoinNetPower" resultType="java.math.BigDecimal">
select
AVG(`value`)
from
${coin}_net_power
where
`date` >= DATE_SUB(NOW(), INTERVAL 3 DAY)
</select>
<select id="getNetBlocks" resultType="java.math.BigDecimal">
SELECT MAX(height) - MIN(height) FROM ${coin}_net_block WHERE `date` >= DATE_SUB(now(),INTERVAL 3 DAY)
</select>
<select id="getProductList" resultType="com.m2pool.lease.dto.ProductDto">
SELECT
id,
name,
image,
type,
state,
CASE
WHEN max_price = min_price THEN CAST(max_price AS CHAR)
ELSE CONCAT(CAST(min_price AS CHAR), '-', CAST(max_price AS CHAR))
END AS priceRange ,
description,
algorithm,
shop_id AS shopId,
coin_full_name AS coinFullName,
coin
FROM
lease_product
<where>
del = false
<choose>
<when test="coin != null and coin != ''">
<trim prefix="AND (" suffix=")" >
<trim prefix="(" suffix=")" prefixOverrides="OR">
<if test="coin != null and coin != ''">
coin LIKE CONCAT('%', #{coin}, '%')
</if>
<if test="coin != null and coin != ''">
OR coin_full_name LIKE CONCAT('%', #{coin}, '%')
</if>
</trim>
<if test="algorithm != null and algorithm != ''">
AND algorithm LIKE CONCAT('%', #{algorithm}, '%')
</if>
</trim>
</when>
<otherwise>
<if test="algorithm != null and algorithm != ''">
AND algorithm LIKE CONCAT('%', #{algorithm}, '%')
</if>
</otherwise>
</choose>
</where>
</select>
<select id="getProductListForShopAndUserCenter" resultType="com.m2pool.lease.dto.ProductDto">
SELECT
lp.id,
lp.shop_id AS shopId,
lp.name,
lp.image,
lp.type,
lp.state,
lp.description,
lp.algorithm,
lp.shop_id AS shopId,
lp.coin_full_name AS coinFullName,
lp.coin,
lp.sale_number AS saleNumber,
lp.total_machine_number AS totalMachineNumber,
ls.name AS shopName
FROM lease_product lp RIGHT JOIN lease_shop ls ON lp.shop_id = ls.id and ls.state = 1
WHERE lp.del = false
<choose>
<when test="shopId != 0">
AND lp.shop_id = #{shopId}
</when>
<otherwise>
AND lp.state = 0 AND lp.total_machine_number != 0
</otherwise>
</choose>
<choose>
<when test="coin != null and coin != ''">
AND (
(
lp.coin LIKE CONCAT('%', #{coin}, '%')
OR lp.coin_full_name LIKE CONCAT('%', #{coin}, '%')
)
<if test="algorithm != null and algorithm != ''">
AND lp.algorithm LIKE CONCAT('%', #{algorithm}, '%')
</if>
)
</when>
<otherwise>
<if test="algorithm != null and algorithm != ''">
AND lp.algorithm LIKE CONCAT('%', #{algorithm}, '%')
</if>
</otherwise>
</choose>
order by lp.sale_number desc,lp.create_time desc
</select>
<select id="getSupportPayType" resultType="com.m2pool.lease.dto.PayTypeDto">
select pay_coin as coin,chain from lease_shop_config where shop_id = #{shopId} and del = 0;
</select>
<select id="getProductListForShopWalletConfig" resultType="com.m2pool.lease.dto.ProductForWalletConfigDto">
SELECT
id as productId,
name,
image,
state,
description,
algorithm,
coin,
total_machine_number AS totalMachineNumber
FROM
lease_product
WHERE del = false and shop_id = #{shopId}
</select>
</mapper>

View File

@@ -0,0 +1,18 @@
<?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.LeaseShopAddressConfigMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseShopAddressConfig">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="address" property="address" />
<result column="shop_id" property="shopId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id, address, shop_id
</sql>
</mapper>

View File

@@ -0,0 +1,100 @@
<?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.LeaseShopConfigMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseShopConfig">
<id column="id" property="id" />
<result column="shop_id" property="shopId" />
<result column="product_id" property="productId" />
<result column="pay_coin" property="payCoin" />
<result column="pay_type" property="payType" />
<result column="pay_address" property="payAddress" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, shop_id, product_id, pay_coin, pay_type, pay_address, create_time, update_time, del
</sql>
<select id="getChainAndList" resultType="com.m2pool.lease.dto.CoinFullDto">
SELECT chain as chainValue,chain as chainLabel,coin as `coinValue`,coin_full as coinLabel FROM lease_chain_coin_config
<where>
<if test="chain != null">
chain = #{chain}
</if>
</where>
</select>
<select id="getChainAndListForSeller" resultType="com.m2pool.lease.dto.CoinFullDto">
select uwd.pay_coin as coinValue,ccc.coin_full as coinLabel,uwd.chain as chainLabel,uwd.chain as chainValue
from lease_chain_coin_config ccc
JOIN lease_shop_config uwd on ccc.coin = uwd.pay_coin and ccc.`chain` = uwd.chain
where uwd.shop_id = #{shopId} and del = 0
</select>
<select id="getCoinIconByChainAndCoin" resultType="com.m2pool.lease.entity.LeaseShopConfig">
select coin_image as payCoinImage,coin as payCoin,chain from lease_chain_coin_config where `chain` = #{chain}
AND (
<foreach collection="coinList" item="item" separator="OR">
coin = #{item}
</foreach>
)
</select>
<select id="selectShopConfigByShopIdAndSymbolAndChain" resultType="com.m2pool.lease.dto.ShopConfigDelDto">
select shop_id as shopId,pay_address as payAddress,chain,del
from lease_shop_config
where
del = 0 and
(
<foreach collection="list" item="item" separator="OR">
(`shop_id` = #{item.shopId} AND chain = #{item.chain} AND pay_coin = #{item.coin})
</foreach>
)
</select>
<select id="getPayType" resultType="com.m2pool.lease.dto.PayTypeDto">
select chain,pay_coin as coin,pay_coin_image as image,shop_id as shopId
from lease_shop_config
where del = false AND shop_id IN
<foreach item="item" collection="list" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="getShopWalletInfoList" resultType="com.m2pool.lease.dto.v2.ShopWalletInfoDto">
SELECT
id,
shop_id as shopId,
pay_address as payAddress,
chain,
pay_coin as payCoin,
pay_coin_image as image,
balance
FROM
lease_shop_config
WHERE
shop_id = #{shopId} AND del = 0
</select>
<select id="getShopWalletInfo" resultType="com.m2pool.lease.dto.v2.ShopWalletInfoDto">
SELECT
id,
shop_id as shopId,
pay_address as payAddress,
chain,
pay_coin as payCoin,
pay_coin_image as image,
balance
FROM
lease_shop_config
WHERE
shop_id = #{shopId} AND pay_address = #{address} AND pay_coin = #{coin} AND chain = #{chain} AND del = 0
</select>
<update id="updateBalance">
<foreach collection="list" item="item" separator=";">
UPDATE lease_shop_config
SET balance = balance + #{item.realAmount}
WHERE pay_address = #{item.fromAddress} AND pay_coin = #{item.fromSymbol} AND chain = #{item.fromChain} AND del = false
</foreach>
</update>
</mapper>

View File

@@ -0,0 +1,88 @@
<?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.LeaseShopMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseShop">
<id column="id" property="id" />
<result column="user_email" property="userEmail" />
<result column="name" property="name" />
<result column="image" property="image" />
<result column="description" property="description" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_email, name, image, description, create_time, update_time, del
</sql>
<select id="getPayAddressAndPayCoin" resultType="com.m2pool.lease.entity.LeaseShopConfig">
SELECT
`shop_id` as shopId,
`pay_address` as payAddress,
`pay_coin` as payCoin,
`qrcode`,
`chain`
FROM
lease_shop_config
WHERE
del = false AND
<foreach collection="chainAndCoinSet" item="item" separator="OR">
(pay_coin = #{item.coin} AND chain = #{item.chain} AND shop_id = #{item.shopId})
</foreach>
</select>
<select id="getShopWalletInfo" resultType="com.m2pool.lease.dto.PayConfigDto">
SELECT
pay_coin as payCoin,
pay_coin_image as payCoinImage,
chain as payChain
FROM
lease_shop_config
WHERE
shop_id = #{shopId} and del = 0
</select>
<select id="getShopWalletInfoList" resultType="com.m2pool.lease.dto.PayConfigDto">
SELECT
pay_coin as payCoin,
pay_coin_image as payCoinImage,
chain as payChain,
shop_id as shopId
FROM
lease_shop_config
WHERE
shop_id IN
<foreach collection="shopIds" item="shopId" open="(" separator="," close=")">
#{shopId}
</foreach>
and del = 0
</select>
<select id="getShopIdsByMachineIds" resultType="java.lang.Long">
SELECT
DISTINCT shop_id as shopId
FROM
lease_product_machine
WHERE
id IN
<foreach collection="machineIds" item="machineId" open="(" separator="," close=")">
#{machineId}
</foreach>
</select>
<select id="getShopNameMapByIds" resultType="com.m2pool.lease.entity.LeaseShop">
SELECT
id ,
name
FROM
lease_shop
WHERE
id IN
<foreach collection="shopIds" item="shopId" open="(" separator="," close=")">
#{shopId}
</foreach>
and del = 0
</select>
</mapper>

View File

@@ -0,0 +1,36 @@
<?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.LeaseShoppingCartInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseShoppingCartInfo">
<id column="id" property="id" />
<result column="product_id" property="productId" />
<result column="product_machine_id" property="productMachineId" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, cart_id, product_id, product_machine_id, create_time, update_time
</sql>
<select id="getProductAndMachineIds" resultType="com.m2pool.lease.dto.ShoppingCartInfoDto">
select product_machine_id as productMachineId,
product_id as productId,
lease_time as leaseTime
from lease_shopping_cart_info
where user_id = #{userId} and version = #{version}
</select>
<delete id="deleteBatchData">
DELETE FROM lease_shopping_cart_info
WHERE id IN
<foreach item="id" index="index" collection="ids"
open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,18 @@
<?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.LeaseShoppingCartMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseShoppingCart">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id, create_time, update_time
</sql>
</mapper>

View File

@@ -0,0 +1,74 @@
<?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.LeaseUserMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseUser">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="password" property="password" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id, password, create_time, update_time
</sql>
<select id="getGoogleInfoByEmail" resultType="com.m2pool.lease.entity.GoogleInfo">
select
user_id as email,
google_auth secret,
google_status status
from
lease_user
where
user_id = #{email}
limit 1
</select>
<select id="checkSecretIfExist" resultType="java.lang.Boolean">
select COUNT(1) from lease_user where google_auth = #{secret}
</select>
<select id="getUserInfoByEmail" resultType="com.m2pool.lease.vo.v2.UserGoogleAuthInfo">
select
user_id email,
password pwd,
google_auth secret,
google_status status
from
lease_user
where
user_id = #{email}
limit 1
</select>
<select id="checkIfBindByEmail" resultType="java.lang.Integer">
select google_status from lease_user where user_id = #{email} and del = false
</select>
<update id="bingGoogleAuthenticator">
update lease_user
set
google_auth = #{info.secret},
google_status = #{info.status},
update_time = sysdate()
where user_id = #{info.email}
</update>
<update id="closeGoogleAuthenticator">
update lease_user
set
google_auth = '',
google_status = 2
where user_id = #{info.email}
</update>
<update id="openGoogleAuthenticator">
update lease_user
set
google_auth = '',
google_status = 0
where user_id = #{info.email}
</update>
</mapper>

View File

@@ -0,0 +1,109 @@
<?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.LeaseUserOwnedProductMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseUserOwnedProduct">
<id column="id" property="id" />
<result column="address" property="address" />
<result column="product_machine_id" property="productMachineId" />
<result column="order_item_id" property="orderItemId" />
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="purchased_computing_power" property="purchasedComputingPower" />
<result column="status" property="status" />
<result column="type" property="type" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, address, product_machine_id, order_item_id, start_time, end_time, purchased_computing_power, status, type, create_time, update_time, del
</sql>
<select id="getProductMachineIds" resultType="java.lang.Long">
select product_machine_id from lease_user_owned_product
where start_time <![CDATA[<=]]> #{beginOfDay} and end_time > #{beginOfDay}
</select>
<select id="getHourIncomeList" resultType="com.m2pool.lease.dto.HourIncomeDto">
select `user`,miner,income, `usdt_income` from ${coin}_hour_income
where create_time >= #{start} and create_time <![CDATA[<=]]> #{end}
AND (
<foreach collection="list" item="item" separator="OR">
(`user` = #{item.user} and `miner` = #{item.miner})
</foreach>
)
</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`,
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)
VALUES
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item.id}, #{item.settleIncome}, #{item.settleUsdtIncome}, #{item.startTime}, #{item.endTime}
</foreach>
ON DUPLICATE KEY UPDATE
settle_income = VALUES(settle_income),
settle_usdt_income = VALUES(settle_usdt_income),
start_time = VALUES(start_time),
end_time = VALUES(end_time)
</update>
</mapper>

View File

@@ -0,0 +1,119 @@
<?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.LeaseUserWalletDataMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseUserWalletData">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="from_address" property="fromAddress" />
<result column="balance" property="balance" />
<result column="to_address" property="toAddress" />
<result column="from_symbol" property="fromSymbol" />
<result column="from_chain" property="fromChain" />
<result column="to_symbol" property="toSymbol" />
<result column="to_chain" property="toChain" />
<result column="qrcode" property="qrcode" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del" property="del" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id, from_address, balance, to_address, from_symbol, from_chain, to_symbol, to_chain, qrcode, create_time, update_time, del
</sql>
<!-- 根据用户 ID 查询钱包信息 -->
<select id="selectByUserId" resultType="com.m2pool.lease.dto.UserWalletDataDto">
SELECT
id,
user_id as userId,
from_address as fromAddress,
balance,
blocked_balance as blockedBalance,
qrcode,
to_address as toAddress,
from_symbol as fromSymbol,
from_chain as fromChain,
to_symbol as toSymbol,
to_chain as toChain,
create_time as createTime
FROM lease_user_wallet_data
WHERE auth_id = #{authId} AND del = 0
</select>
<select id="getWalletInfoByAddress" resultType="com.m2pool.lease.dto.UserWalletDataDto">
SELECT
id,
user_id as userId,
from_address as fromAddress,
balance,
blocked_balance as blockedBalance,
qrcode,
to_address as toAddress,
from_symbol as fromSymbol,
from_chain as fromChain,
to_symbol as toSymbol,
to_chain as toChain,
create_time as createTime
FROM lease_user_wallet_data
WHERE user_id = #{userId} AND from_symbol = #{symbol} AND from_address = #{address} AND del = 0
</select>
<select id="getWalletInfoByChain" resultType="com.m2pool.lease.dto.UserWalletDataDto">
SELECT
id,
user_id as userId,
from_address as fromAddress,
balance,
blocked_balance as blockedBalance,
qrcode,
to_address as toAddress,
from_symbol as fromSymbol,
from_chain as fromChain,
to_symbol as toSymbol,
to_chain as toChain,
create_time as createTime,
queue_id as queueId
FROM lease_user_wallet_data
WHERE auth_id = #{authId} AND from_chain = #{chain} AND del = 0
</select>
<select id="getWalletForBalanceIsZero" resultType="com.m2pool.lease.entity.LeaseUserWalletData">
SELECT
queue_id as queueId,
from_address as fromAddress,
from_symbol as fromSymbol,
from_chain as fromChain
FROM lease_user_wallet_data
WHERE balance = 0 AND del = 0 AND create_time <![CDATA[ <= ]]> DATE_SUB(NOW(), INTERVAL 6 MONTH) AND
(<foreach collection="list" item="item" separator="OR">
(`from_address` = #{item.fromAddress} AND from_symbol = #{item.fromSymbol} AND from_chain = #{item.fromChain})
</foreach>)
</select>
<select id="selectWalletByChainAndCoinAndUsername" resultType="com.m2pool.lease.entity.LeaseUserWalletData">
SELECT
id,
from_address as fromAddress,
balance,
blocked_balance as blockedBalance,
from_symbol as fromSymbol,
from_chain as fromChain
FROM lease_user_wallet_data
WHERE del = 0 AND auth_id = #{authId} AND (
<foreach collection="list" item="item" separator="OR">
(from_chain = #{item.chain} AND from_symbol = #{item.coin} )
</foreach>
)
</select>
<update id="updateBalanceAndBlockBalance">
<foreach collection="list" item="item" separator=";">
UPDATE lease_user_wallet_data
SET balance = balance - #{item.realAmount},
blocked_balance = blocked_balance - #{item.blockAmount}
WHERE from_address = #{item.fromAddress} AND from_symbol = #{item.fromSymbol} AND from_chain = #{item.fromChain} AND del = false
</foreach>
</update>
</mapper>

View File

@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email code</title>
</head>
<body style="margin:0; padding:0;">
<!-- 合并 th:style 属性 -->
<div class="container" role="region" aria-label="M2POOL Email verification code page" tabindex="0"
th:style="'background-image: url(' + @{${imagePrefix} + '/img/email/bg1.png'} + '); width:100%; max-width:600px; height:auto; min-height:100vh; margin:0 auto; box-sizing:border-box; padding:5%; position:relative; overflow:hidden; background-color:#f5f5f5; background-size:cover; background-repeat:no-repeat; '">
<!-- 顶部品牌标识 -->
<div class="brand" aria-label="M2POOL brand logo" style="width:100%;">
<img th:src= "@{${imagePrefix} + '/img/email/logo.png'}" alt="logo" style="width: 8vw; height: auto; margin-left: 10%; margin-top: 6%;">
</div>
<!-- 中心验证码卡片 -->
<!-- 合并 th:style 属性 -->
<section class="card" aria-label="Verification code card"
th:style="'background-image: url(' + @{${imagePrefix} + '/img/email/daio.png'} + '); width:100%; max-width:320px; height:auto; min-height:250px; margin:0 auto; margin-top:10vh; box-shadow:0 8px 24px rgba(17, 24, 39, 0.10), 0 2px 6px rgba(17, 24, 39, 0.06); position:relative; overflow:hidden; display:block; text-align:center; background-color:#ffffff; background-size:120% auto; background-position:center; background-repeat:no-repeat; border-radius:12px; padding:5%;'">
<!-- 合并 th:style 属性 -->
<p class="notice" th:text="${text}" style="color:rgba(0,0,0,0.7); font-size:18px; margin-top:10%; text-align:center;"></p>
<!-- 合并 th:style 属性 -->
<div class="code-box" aria-live="polite" aria-label="CAPTCHA"
style="position:relative; display:inline-flex; align-items:center; justify-content:center; margin-top:2vh; width:80%; max-width:300px; height:50px; border-radius:12px; background:#ffffff; border:3px solid #651EFE;">
<!-- 合并 th:style 属性 -->
<span class="code-text js-code-text" data-default-code="4MKM6AX" th:text="${code}"
style="font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; font-weight:800; font-size:24px; letter-spacing:0.18em; color:#111827;margin:auto;"></span>
</div>
</section>
<!-- 底部帮助与联系入口 -->
<footer class="page-footer" style="margin-top:18vh; width:100%; height:auto; text-align:center;">
<!-- 合并 th:style 属性 -->
<div class="divider" aria-hidden="true"
style="width:100%; height:3px; background:#DDDDDD; margin:8px 0 20px;"></div>
<!-- 合并 th:style 属性 -->
<p style="margin:0; padding:0; font-size:14px; color:#777777;">
Thank you for choosing M2POOL. Need help?
<a class="contact-link" href="mailto:support@m2pool.com" aria-label="Contact customer service email"
style="color:#111827; font-weight:800; text-decoration:none; border-bottom:2px solid #111827; outline:none;">Please
contact customer service.</a>
</p>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>offline notification</title>
</head>
<body>
<div class="container" role="region" aria-label="M2POOL offline notification" tabindex="0"
th:style="'background-image: url(' + @{${imagePrefix} + '/img/email/bg1.png'} + '); width:100%; max-width:600px; height:auto; min-height:100vh; margin:0 auto; position:relative; overflow:hidden; padding:2%; background-color:#f5f5f5; background-size:cover; background-repeat:no-repeat;box-sizing:border-box;'">
<!-- 顶部品牌标识 -->
<div class="brand" aria-label="M2POOL brand logo">
<img th:src= "@{${imagePrefix} + '/img/email/logo.png'}" alt="logo" style="width:120px; height:auto; margin-left:10%; margin-top:6%;">
</div>
<!-- 中心验证码卡片 -->
<section class="card" aria-label="Offline Notification Card" th:style="'background-image: url(' + @{${imagePrefix} + '/img/email/daio.png'} + ');width:100%; max-width:310px; height:auto; min-height:240px; margin:0 auto; margin-top:10vh; box-shadow:0 8px 24px rgba(17, 24, 39, 0.10), 0 2px 6px rgba(17, 24, 39, 0.06); position:relative; overflow:hidden; padding:44px 40px 36px; text-align:center; background-color:#ffffff; background-size:105% 112%; background-position:center; background-repeat:no-repeat; border-radius:12px;'">
<p class="notice" style="color:rgba(0,0,0,0.8); font-size:18px; margin-bottom:15px;">Your <span class="account-name" th:text="${coin}" style="color:#F94D87; font-weight:900; font-size:20px;"></span> mining account: &nbsp; <span class="account-name" style="color:#F94D87; font-weight:900; font-size:20px;" th:text="${user}"></span> </p>
<p class="notice" style="color:rgba(0,0,0,0.8); font-size:18px; margin-bottom:15px;"> <span class="account-name" th:text="${offOnlineNumbers}" style="color:#F94D87; font-weight:900; font-size:20px;"></span> mining machines are offline!</p>
<p class="notice" style="color:rgba(0,0,0,0.8); font-size:18px;">If your mining rig has been abnormally disconnected, please address it promptly!</p>
</section>
<!-- 底部帮助与联系入口 -->
<footer class="page-footer" style="margin-top:18vh; width:100%; height:auto; text-align:center;">
<div class="divider" aria-hidden="true" style="width:100%; height:3px; background:#DDDDDD; margin:8px 0 20px;"></div>
<p style="margin:0; padding:0; font-size:14px; color:#777777;">
Thank you for choosing M2POOL. Need help?
<a class="contact-link" style="color:#111827; font-weight:800; text-decoration:none; border-bottom:2px solid #111827; outline:none;" href="mailto:support@m2pool.com" aria-label="Contact Customer Service Email">Please contact customer service.</a>
</p>
</footer>
</div>
<script>
</script>
</body>
</html>