租赁系统

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,105 @@
package com.m2pool.lease.constant;
import com.alibaba.cloud.commons.lang.StringUtils;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @Description 币种算法
* @Date 2025/8/18 16:19
* @Author yyb
*/
public class Algorithm {
public static final String GRS_ALGORITHM= "groestl";
public static final String MONA_ALGORITHM= "Lyra2REv2";
public static final String NEXA_ALGORITHM= "NexaPow";
public static final String RXD_ALGORITHM= "Sha512256D";
public static final String DGBQ_ALGORITHM= "DigiByte(Qubit)";
public static final String DGBS_ALGORITHM= "DigiByte(Skein)";
public static final String DGBO_ALGORITHM= "DigiByte(Odocrypt)";
public static final String MONERO_ALGORITHM= "randomx";
public static final String ALPH_ALGORITHM= "Blake3";
public static final String GRS_FULL_NAME= "Groestlcoin";
public static final String MONA_FULL_NAME= "Monacoin";
public static final String NEXA_FULL_NAME= "nexa";
public static final String RXD_FULL_NAME= "Radiant";
public static final String DGBQ_FULL_NAME= "DigiByte(qubit)";
public static final String DGBS_FULL_NAME= "DigiByte(skein)";
public static final String DGBO_FULL_NAME= "DigiByte(odocrypt)";
public static final String MONERO_FULL_NAME= "monero";
public static final String ALPH_FULL_NAME = "Alephium";
private static final Map<String, String> ALGORITHM_MAP;
private static final Map<String, String> COINFLULLNAME_MAP;
static {
HashMap<String, String> map = new HashMap<>();
map.put("grs", GRS_ALGORITHM);
map.put("mona", MONA_ALGORITHM);
map.put("nexa", NEXA_ALGORITHM);
map.put("rxd", RXD_ALGORITHM);
map.put("dgbq", DGBQ_ALGORITHM);
map.put("dgbs", DGBS_ALGORITHM);
map.put("dgbo", DGBO_ALGORITHM);
map.put("monero", MONERO_ALGORITHM);
map.put("alph", ALPH_ALGORITHM);
ALGORITHM_MAP = Collections.unmodifiableMap(map);
HashMap<String, String> mapFullName = new HashMap<>();
mapFullName.put("grs", GRS_FULL_NAME);
mapFullName.put("mona", MONA_FULL_NAME);
mapFullName.put("nexa", NEXA_FULL_NAME);
mapFullName.put("rxd", RXD_FULL_NAME);
mapFullName.put("dgbq", DGBQ_FULL_NAME);
mapFullName.put("dgbs", DGBS_FULL_NAME);
mapFullName.put("dgbo", DGBO_FULL_NAME);
mapFullName.put("monero", MONERO_FULL_NAME);
mapFullName.put("alph", ALPH_FULL_NAME);
COINFLULLNAME_MAP = Collections.unmodifiableMap(mapFullName);
}
/**
* 根据币种名称获取对应的算法
* @param coinName 币种名称,不区分大小写
* @return 对应的每日理论出块数,如果未找到则返回 null
*/
public static String getAlgorithm(String coinName) {
String algorithm = ALGORITHM_MAP.get(coinName.toLowerCase());
if (StringUtils.isEmpty(algorithm)){
return "";
}
return algorithm;
}
public static String getCoinFullName(String coinName) {
String algorithm = COINFLULLNAME_MAP.get(coinName.toLowerCase());
if (StringUtils.isEmpty(algorithm)){
return "";
}
return algorithm;
}
}

View File

@@ -0,0 +1,45 @@
package com.m2pool.lease.constant;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @Description 出块间隔数
* @Date 2025/8/18 16:19
* @Author yyb
*/
public class BlockInterval {
// GRS 出块间隔时间单位s
public static final BigDecimal GRS_BLOCK_INTERVAL = BigDecimal.valueOf(60);
// Mona 出块间隔时间单位s
public static final BigDecimal MONA_BLOCK_INTERVAL = BigDecimal.valueOf(90);
// NEXA 出块间隔时间单位s
public static final BigDecimal NEXA_BLOCK_INTERVAL = BigDecimal.valueOf(120);
// RXD 出块间隔时间单位s
public static final BigDecimal RXD_BLOCK_INTERVAL= BigDecimal.valueOf(300);
private static final Map<String, BigDecimal> BLOCK_MAP;
static {
HashMap<String, BigDecimal> map = new HashMap<>();
map.put("grs", GRS_BLOCK_INTERVAL);
map.put("mona", MONA_BLOCK_INTERVAL);
map.put("nexa", NEXA_BLOCK_INTERVAL);
map.put("rxd", RXD_BLOCK_INTERVAL);
BLOCK_MAP = Collections.unmodifiableMap(map);
}
/**
* 根据币种名称获取对应的每日理论出块数
* @param coinName 币种名称,不区分大小写
* @return 对应的每日理论出块数,如果未找到则返回 null
*/
public static BigDecimal getBlockCountByCoinName(String coinName) {
if (coinName == null) {
return BigDecimal.ZERO;
}
return BLOCK_MAP.get(coinName.toLowerCase());
}
}

View File

@@ -0,0 +1,108 @@
package com.m2pool.lease.constant;
import com.m2pool.lease.dto.ChargeDto;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
/**
* @Description 币种手续费
* @Date 2025/10/23 11:15
* @Author yyb
*/
public enum CoinCharge {
ETH_USDT("ETH","USDT", BigDecimal.valueOf(1), BigDecimal.valueOf(1)),
ETH_ETH("ETH","ETH", BigDecimal.valueOf(0.00005),BigDecimal.valueOf(0.01)),
TRON_USDT("TRON","USDT", BigDecimal.valueOf(1),BigDecimal.valueOf(1)),
TRON_NEXA("TRON","NEXA", BigDecimal.valueOf(1000),BigDecimal.valueOf(0.1));
private final String chain;
/** 币种参数名 */
private final String coin;
/** 手续费 */
private final BigDecimal amount;
/** 费率 */
private final BigDecimal feeRate;
CoinCharge(String chain, String coin, BigDecimal amount, BigDecimal feeRate) {
this.chain = chain;
this.coin = coin;
this.amount = amount;
this.feeRate = feeRate;
}
/**
* 根据 chain 和 coin 查找对应的手续费,未找到则返回 1
* @param chain 链名
* @param coin 币种名
* @return 对应的手续费,未找到返回 1
*/
public static BigDecimal getChargeByChainAndCoin(String chain, String coin) {
for (CoinCharge charge : CoinCharge.values()) {
if (charge.chain.equals(chain) && charge.coin.equals(coin)) {
return charge.amount;
}
}
return BigDecimal.ONE;
}
/**
* 根据 chain 和 coin 查找对应的手续费,未找到则返回 1
* @param chain 链名
* @param coin 币种名
* @return 对应的手续费,未找到返回 1
*/
public static BigDecimal getDeductibleAmountByChainAndCoin(String chain, String coin) {
for (CoinCharge charge : CoinCharge.values()) {
if (charge.chain.equals(chain) && charge.coin.equals(coin)) {
return charge.amount.divide(charge.feeRate, 4, RoundingMode.HALF_UP);
}
}
return BigDecimal.ONE;
}
/**
* 根据 chain 和 coin 找到手续费和费率然后比较totalPrice是否小于 费率/手续费
* @param chain 链名
* @param coin 币种名
* @return 对应的手续费,未找到返回 1
*/
public static BigDecimal getFee(String chain, String coin, BigDecimal totalPrice) {
BigDecimal fee = BigDecimal.ONE;
for (CoinCharge charge : CoinCharge.values()) {
if (charge.chain.equals(chain) && charge.coin.equals(coin)) {
BigDecimal feeRate = charge.feeRate;
BigDecimal deductible= charge.amount.divide(feeRate, 4, RoundingMode.HALF_UP);
if(deductible.compareTo(totalPrice) < 0){
fee = BigDecimal.ZERO;
}else{
fee = charge.amount;
}
}
}
return fee;
}
/**
* 获取枚举类中所有枚举,并封装成 List<ChargeDto>
* @return 包含所有枚举信息的 ChargeDto 列表
*/
public static List<ChargeDto> getAllChargesAsDtoList() {
List<ChargeDto> chargeDtoList = new ArrayList<>();
for (CoinCharge charge : CoinCharge.values()) {
chargeDtoList.add(new ChargeDto(
charge.amount,
charge.chain,
charge.coin,
charge.feeRate
));
}
return chargeDtoList;
}
}

View File

@@ -0,0 +1,65 @@
package com.m2pool.lease.constant;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
public class DailyBlockOutputConstant {
// GRS 每日理论出块数常量
public static final BigDecimal GRS_BLOCK = BigDecimal.valueOf(1440);
// Mona 每日理论出块数常量
public static final BigDecimal MONA_BLOCK = BigDecimal.valueOf(960);
// DGBS 每日理论出块数常量
public static final BigDecimal DGBS_BLOCK = BigDecimal.valueOf(1180);
// DGBQ 每日理论出块数常量
public static final BigDecimal DGBQ_BLOCK = BigDecimal.valueOf(1180);
// DGBO 每日理论出块数常量
public static final BigDecimal DGBO_BLOCK = BigDecimal.valueOf(1180);
// DGB2_ODO 每日理论出块数常量
public static final BigDecimal DGB2_ODO_BLOCK = BigDecimal.valueOf(720);
// DGB_QUBIT_A10 每日理论出块数常量
public static final BigDecimal DGB_QUBIT_A10_BLOCK = BigDecimal.valueOf(720);
// DGB_SKEIN_A10 每日理论出块数常量
public static final BigDecimal DGB_SKEIN_A10_BLOCK = BigDecimal.valueOf(720);
// DGB_ODO_B20 每日理论出块数常量
public static final BigDecimal DGB_ODO_B20_BLOCK = BigDecimal.valueOf(720);
// NEXA 每日理论出块数常量
public static final BigDecimal NEXA_BLOCK = BigDecimal.valueOf(720);
// RXD 每日理论出块数常量
public static final BigDecimal RXD_BLOCK = BigDecimal.valueOf(288);
// ALPH 每日理论出块数常量
public static final BigDecimal ALPH_BLOCK = BigDecimal.valueOf(5400);
// ENX 每日理论出块数常量
public static final BigDecimal ENX_BLOCK = BigDecimal.valueOf(86400);
private static final Map<String, BigDecimal> BLOCK_MAP;
static {
BLOCK_MAP = new HashMap<>();
BLOCK_MAP.put("grs", GRS_BLOCK);
BLOCK_MAP.put("mona", MONA_BLOCK);
BLOCK_MAP.put("dgbs", DGBS_BLOCK);
BLOCK_MAP.put("dgbq", DGBQ_BLOCK);
BLOCK_MAP.put("dgbo", DGBO_BLOCK);
BLOCK_MAP.put("dgb2_odo", DGB2_ODO_BLOCK);
BLOCK_MAP.put("dgb_qubit_a10", DGB_QUBIT_A10_BLOCK);
BLOCK_MAP.put("dgb_skein_a10", DGB_SKEIN_A10_BLOCK);
BLOCK_MAP.put("dgb_odo_b20", DGB_ODO_B20_BLOCK);
BLOCK_MAP.put("nexa", NEXA_BLOCK);
BLOCK_MAP.put("rxd", RXD_BLOCK);
BLOCK_MAP.put("alph", ALPH_BLOCK);
BLOCK_MAP.put("enx", ENX_BLOCK);
}
/**
* 根据币种名称获取对应的每日理论出块数
* @param coinName 币种名称,不区分大小写
* @return 对应的每日理论出块数,如果未找到则返回 null
*/
public static BigDecimal getBlockCountByCoinName(String coinName) {
if (coinName == null) {
return BigDecimal.ZERO;
}
return BLOCK_MAP.get(coinName.toLowerCase());
}
}

View File

@@ -0,0 +1,47 @@
package com.m2pool.lease.constant;
import com.m2pool.lease.netty.message.GpuMessage;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Description 币种算法
* @Date 2025/8/18 16:19
* @Author yyb
*/
public class GpuBrand {
private static final String NVIDIA= "NVIDIA";
private static final String AMD= "ADM";
private static final String APPLE= "APPLE";
private static final String INTEL= "INTEL";
private static final List<String> BRAND_LIST;
static {
BRAND_LIST = new ArrayList<>();
BRAND_LIST.add(NVIDIA);
BRAND_LIST.add(AMD);
BRAND_LIST.add(APPLE);
BRAND_LIST.add(INTEL);
}
public static List<String> trimBrand(List<String> targetList) {
return targetList.stream()
.map(model -> {
for (String brand : BRAND_LIST) {
if (model.contains(brand)) {
return model.replace(brand, "").trim();
}
}
return model.trim();
})
.collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,55 @@
package com.m2pool.lease.constant;
/**
* @Description 普通订单状态
* @Date 2025/9/3 16:19
* @Author yyb
*/
public enum OrderStatus {
PENDING_PAYMENT(0, "待支付"),
FULLY_PAID(1, "(全部)已支付"),
CANCELLED(2, "已取消"),
AFTER_SALES(3, "售后状态"),
REFUNDED(4, "已退款"),
PAYMENT_TIMEOUT(5, "支付已超时"),
PAYMENT_IN_PROGRESS(6, "支付中"),
PARTIALLY_PAID(10, "部分已支付");
private final int code;
private final String description;
OrderStatus(int code, String description) {
this.code = code;
this.description = description;
}
/**
* 获取订单状态编码
* @return 订单状态编码
*/
public int getCode() {
return code;
}
/**
* 获取订单状态描述
* @return 订单状态描述
*/
public String getDescription() {
return description;
}
/**
* 根据编码获取对应的订单状态枚举
* @param code 订单状态编码
* @return 订单状态枚举,如果未找到则返回 null
*/
public static OrderStatus getByCode(int code) {
for (OrderStatus status : OrderStatus.values()) {
if (status.getCode() == code) {
return status;
}
}
return null;
}
}

View File

@@ -0,0 +1,53 @@
package com.m2pool.lease.constant;
/**
* @Description 支付订单状态
* @Date 2025/9/3 16:19
* @Author yyb
*/
public enum PaymentStatus {
PAYMENT_FAILED(0, "支付失败"),
PAYMENT_SUCCESS_FULL(1, "支付成功--全部货款已支付"),
PENDING_PAYMENT(2, "待支付"),
PAYMENT_TIMEOUT(5, "支付已超时"),
PAYMENT_IN_PROGRESS(6, "支付中"),
PAYMENT_SUCCESS_PARTIAL(10, "支付成功--已支付部分货款");
private final int code;
private final String description;
PaymentStatus(int code, String description) {
this.code = code;
this.description = description;
}
/**
* 获取支付状态编码
* @return 支付状态编码
*/
public int getCode() {
return code;
}
/**
* 获取支付状态描述
* @return 支付状态描述
*/
public String getDescription() {
return description;
}
/**
* 根据编码获取对应的支付状态枚举
* @param code 支付状态编码
* @return 支付状态枚举,如果未找到则返回 null
*/
public static PaymentStatus getByCode(int code) {
for (PaymentStatus status : PaymentStatus.values()) {
if (status.getCode() == code) {
return status;
}
}
return null;
}
}

View File

@@ -0,0 +1,44 @@
package com.m2pool.lease.constant;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @Description 单位换算
* @Date 2025/8/18 16:19
* @Author yyb
*/
public class PowerUnit {
public static final String KH_UNIT = "KH/S";
public static final String MH_UNIT = "MH/S";
public static final String GH_UNIT = "GH/S";
public static final String TH_UNIT = "TH/S";
public static final String PH_UNIT = "PH/S";
private static final Map<String, BigDecimal> UNIT_MAP;
static {
HashMap<String, BigDecimal> map = new HashMap<>();
map.put(KH_UNIT, BigDecimal.valueOf(1000));
map.put(MH_UNIT, BigDecimal.valueOf(1000 * 1000));
map.put(GH_UNIT, BigDecimal.valueOf(1000L * 1000 * 1000));
map.put(TH_UNIT, BigDecimal.valueOf(1000L * 1000 * 1000 * 1000 ));
map.put(PH_UNIT, BigDecimal.valueOf(1000L * 1000 * 1000 * 1000 * 1000));
UNIT_MAP = Collections.unmodifiableMap(map);
}
public static BigDecimal getPower(String unit) {
if (unit == null) {
return BigDecimal.ZERO;
}
return UNIT_MAP.get(unit);
}
}

View File

@@ -0,0 +1,156 @@
package com.m2pool.lease.constant;
/**
* @Description 常量信息
* @Date 2024/6/11 18:13
* @Author dy
*/
public class RabbitmqConstant {
/**
* 矿池代理消息队列
*/
public static final String POOL_PROXY_QUEUE_NAME = "pool.proxy.queue";
/**
* 矿池代理消息correlationData(用于生成者手动ack)
*/
public static final String POOL_PROXY_CORRELATION = "pool.proxy.message";
/**
* 订单超时消息 交换机
*/
public static final String ORDER_OVERTIME_EXCHANGE_NAME = "order.overtime.exchange";
/**
* 订单超时消息 路由键
*/
public static final String ORDER_OVERTIME_ROUTING_KEY = "order.overtime.routing.key";
/**
*
* 订单超时消息 队列
*/
public static final String ORDER_OVERTIME_QUEUE_NAME = "order.overtime.queue";
/**
* 订单超时消息correlationData(用于生成者手动ack)
*/
public static final String ORDER_OVERTIME_CORRELATION= "order.overtime.message";
/**
* 死信 队列
*/
public static final String DEAD_LETTER_QUEUE_NAME = "dead.letter.queue";
/**
* 死信 交换机
*/
public static final String DEAD_LETTER_EXCHANGE_NAME = "dead.letter.exchange";
/**
* 死信 路由键
*/
public static final String DEAD_LETTER_ROUTING_KEY = "dead.letter.routing.key";
//----------------定义支付相关队列------------------------
/**
* 支付模块 交换机
*/
public static final String PAY_EXCHANGE = "pay.exchange";
/**
* 支付 消息队列
*/
public static final String PAY_AUTO_QUEUE = "pay.auto.queue";
/**
* 支付 路由键
*/
public static final String PAY_AUTO_ROUTING_KEY = "pay.auto.routing.key";
/**
* 支付 返回消息消息队列
*/
public static final String PAY_AUTO_RETURN_QUEUE = "pay.auto.return.queue";
/**
* 支付 返回消息路由键
*/
public static final String PAY_AUTO_RETURN_ROUTING_KEY = "pay.auto.return.routing.key";
/**
* 余额充值 消息队列
*/
public static final String PAY_RECHARGE_QUEUE = "pay.recharge.queue";
/**
* 余额充值 路由键
*
*/
public static final String PAY_RECHARGE_ROUTING_KEY = "pay.recharge.routing.key";
/**
* 余额充值 返回信息消息队列
*/
public static final String PAY_RECHARGE_RETURN_QUEUE = "pay.recharge.return.queue";
/**
* 余额充值 返回信息路由键
*
*/
public static final String PAY_RECHARGE_RETURN_ROUTING_KEY = "pay.recharge.return.routing.key";
/**
* 余额提现 消息队列
*/
public static final String PAY_WITHDRAW_QUEUE = "pay.withdraw.queue";
/**
* 余额提现 路由键
*
*/
public static final String PAY_WITHDRAW_ROUTING_KEY = "pay.withdraw.routing.key";
/**
* 余额提现 返回信息消息队列
*/
public static final String PAY_WITHDRAW_RETURN_QUEUE = "pay.withdraw.return.queue";
/**
* 余额提现 返回信息路由键
*
*/
public static final String PAY_WITHDRAW_RETURN_ROUTING_KEY = "pay.withdraw.return.routing.key";
/**
* 钱包删除 信息消息队列
*/
public static final String DELETE_WALLET_QUEUE = "pay.remove.queue";
/**
* 钱包删除 信息路由键
*
*/
public static final String DELETE_WALLET_ROUTING_KEY = "pay.remove.routing.key";
/**
* 钱包删除 返回信息消息队列
*/
public static final String DELETE_WALLET_RETURN_QUEUE = "pay.remove.return.queue";
/**
* 钱包删除 返回信息路由键
*
*/
public static final String DELETE_WALLET_RETURN_ROUTING_KEY = "pay.remove.return.routing.key";
//----------------定义支付相关队列------------------------
}

View File

@@ -0,0 +1,92 @@
package com.m2pool.lease.constant;
/**
* @Description 常量信息
* @Date 2024/6/11 18:13
* @Author dy
*/
public class ResponseConstant {
/**
* 成功标记
*/
public static final Integer SUCCESS = 200;
/**
* 失败标记
*/
public static final Integer FAIL = 500;
/**
* 登录成功状态
*/
public static final String LOGIN_SUCCESS_STATUS = "0";
/**
* 登录失败状态
*/
public static final String LOGIN_FAIL_STATUS = "1";
/**
* 登录成功
*/
public static final String LOGIN_SUCCESS = "Success";
/**
* 注销
*/
public static final String LOGOUT = "Logout";
/**
* 注册
*/
public static final String REGISTER = "Register";
/**
* 登录失败
*/
public static final String LOGIN_FAIL = "Error";
/**
* 当前记录起始索引
*/
public static final String PAGE_NUM = "pageNum";
/**
* 每页显示记录数
*/
public static final String PAGE_SIZE = "pageSize";
/**
* 排序列
*/
public static final String ORDER_BY_COLUMN = "orderByColumn";
/**
* 排序的方向 "desc" 或者 "asc".
*/
public static final String IS_ASC = "isAsc";
/**
* 验证码 redis key
*/
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
/**
* 验证码有效期(分钟)
*/
public static final long CAPTCHA_EXPIRATION = 2;
/**
* 参数管理 cache key
*/
public static final String SYS_CONFIG_KEY = "sys_config:";
/**
* 资源映射路径 前缀
*/
public static final String RESOURCE_PREFIX = "/profile";
}