first commit
This commit is contained in:
3
dapp/WebContent/META-INF/MANIFEST.MF
Executable file
3
dapp/WebContent/META-INF/MANIFEST.MF
Executable file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
3
dapp/bin/WebContent/META-INF/MANIFEST.MF
Executable file
3
dapp/bin/WebContent/META-INF/MANIFEST.MF
Executable file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
8
dapp/bin/config/spring/applicationContext-hibernate.xml
Executable file
8
dapp/bin/config/spring/applicationContext-hibernate.xml
Executable file
@@ -0,0 +1,8 @@
|
||||
|
||||
admin
|
||||
|
||||
<!-- recharge -->
|
||||
<value>adminRechargeOrderService</value>
|
||||
|
||||
api
|
||||
<!-- recharge -->
|
||||
16
dapp/bin/config/spring/applicationContext-recharge.xml
Executable file
16
dapp/bin/config/spring/applicationContext-recharge.xml
Executable file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<bean id="rechargeChannelFactory"
|
||||
class="project.recharge.RechargeChannelFactory">
|
||||
<property name="sysparaService" ref="sysparaService" />
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
14
dapp/bin/config/spring/applicationContext-recharge_admin.xml
Executable file
14
dapp/bin/config/spring/applicationContext-recharge_admin.xml
Executable file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<bean id="adminRechargeOrderService" class="project.recharge.internal.AdminRechargeOrderServiceImpl">
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="userRecomService" ref="userRecomService" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
5
dapp/bin/config/spring/normal.xml
Executable file
5
dapp/bin/config/spring/normal.xml
Executable file
@@ -0,0 +1,5 @@
|
||||
admin
|
||||
<action name="adminRechargeOrderAction"
|
||||
class="project.recharge.web.AdminRechargeOrderAction">
|
||||
<result name="list">/recharge_list.jsp</result>
|
||||
</action>
|
||||
20
dapp/bin/dbscript/1.1/RECHARGE-DDL-MYSQL.SQL
Executable file
20
dapp/bin/dbscript/1.1/RECHARGE-DDL-MYSQL.SQL
Executable file
@@ -0,0 +1,20 @@
|
||||
DROP TABLE IF EXISTS `T_RECHARGE_ORDER`;
|
||||
CREATE TABLE `T_RECHARGE_ORDER` (
|
||||
`UUID` varchar(32) NOT NULL,
|
||||
`ORDER_NO` char(32) ,
|
||||
`CHANNEL_ORDER_NO` varchar(64) ,
|
||||
`PARTY_ID` varchar(32) ,
|
||||
`CHANNEL` varchar(32) ,
|
||||
`AMOUNT` double ,
|
||||
`CHANNEL_AMOUNT` double ,
|
||||
`SUCCEEDED` int(11) ,
|
||||
`CREATED` datetime ,
|
||||
`EXTRA` varchar(4096) ,
|
||||
`DESCRIPTION` varchar(256) ,
|
||||
`FAILURE_MSG` varchar(4096) ,
|
||||
`CURRENCY` varchar(32) ,
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INX_RECHARGE_ORDER_PARTY_ID` (`PARTY_ID`,`CREATED`),
|
||||
KEY `INX_RECHARGE_ORDER_SUCCEEDED` (`SUCCEEDED`,`CREATED`),
|
||||
KEY `INX_RECHARGE_ORDER_ORDER_NO` (`ORDER_NO`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
41
dapp/config/spring/applicationContext-dubbo.xml
Executable file
41
dapp/config/spring/applicationContext-dubbo.xml
Executable file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
|
||||
">
|
||||
<!-- 提供方应用信息,用于计算依赖关系 -->
|
||||
<dubbo:application name="${dubbo.application.name}" />
|
||||
|
||||
<!-- 使用zkp注册中心暴露服务地址 -->
|
||||
<!-- 使用zookeeper注册中心暴露服务地址 -->
|
||||
<dubbo:registry protocol="${dubbo.registry.protocol}"
|
||||
address="${dubbo.registry.address}" />
|
||||
|
||||
<dubbo:protocol host="127.0.0.1" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dubbo:reference id="channelBlockchainService"
|
||||
interface="project.blockchain.ChannelBlockchainService" check="false" />
|
||||
|
||||
<dubbo:reference id="rechargeBlockchainService"
|
||||
interface="project.blockchain.RechargeBlockchainService" check="false" />
|
||||
|
||||
|
||||
|
||||
<dubbo:reference id="qRProducerService"
|
||||
interface="project.blockchain.QRProducerService" check="false" />
|
||||
|
||||
<dubbo:reference id="rechargeBonusService"
|
||||
interface="project.bonus.RechargeBonusService" check="false" />
|
||||
|
||||
|
||||
</beans>
|
||||
15
dapp/config/spring/applicationContext-hibernate.xml
Executable file
15
dapp/config/spring/applicationContext-hibernate.xml
Executable file
@@ -0,0 +1,15 @@
|
||||
|
||||
admin
|
||||
|
||||
<!-- recharge -->
|
||||
<value>adminRechargeBlockchainOrderService</value>
|
||||
<value>adminChannelBlockchainService</value>
|
||||
|
||||
api
|
||||
<!-- recharge -->
|
||||
|
||||
<!-- blockchain -->
|
||||
<value>rechargeBlockchainService</value>
|
||||
<value>channelBlockchainService</value>
|
||||
<value>qRProducerService</value>
|
||||
<value>rechargeBonusService</value>
|
||||
72
dapp/config/spring/applicationContext-recharge_blockchain.xml
Executable file
72
dapp/config/spring/applicationContext-recharge_blockchain.xml
Executable file
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<bean id="rechargeBlockchainService"
|
||||
class="project.blockchain.internal.RechargeBlockchainServiceImpl">
|
||||
<property name="userDataService" ref="userDataService" />
|
||||
<property name="walletService" ref="walletService" />
|
||||
<property name="moneyLogService" ref="moneyLogService" />
|
||||
<property name="exchangeRateService" ref="exchangeRateService" />
|
||||
<property name="walletLogService" ref="walletLogService" />
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="rechargeBonusService" ref="rechargeBonusService" />
|
||||
<property name="logService" ref="logService" />
|
||||
<property name="secUserService" ref="secUserService" />
|
||||
<property name="partyService" ref="partyService" />
|
||||
<property name="sysparaService" ref="sysparaService" />
|
||||
<property name="channelBlockchainService" ref="channelBlockchainService" />
|
||||
<property name="userRecomService" ref="userRecomService" />
|
||||
</bean>
|
||||
|
||||
|
||||
<dubbo:service
|
||||
interface="project.blockchain.RechargeBlockchainService" ref="rechargeBlockchainService" />
|
||||
|
||||
<bean id="channelBlockchainService"
|
||||
class="project.blockchain.internal.ChannelBlockchainServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="logService" ref="logService" />
|
||||
<property name="secUserService" ref="secUserService" />
|
||||
<property name="passwordEncoder" ref="passwordEncoder" />
|
||||
</bean>
|
||||
|
||||
|
||||
<dubbo:service
|
||||
interface="project.blockchain.ChannelBlockchainService"
|
||||
ref="channelBlockchainService" />
|
||||
<bean id="qRProducerService"
|
||||
class="project.blockchain.internal.QRProducerServiceImpl">
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
<dubbo:service
|
||||
interface="project.blockchain.QRProducerService"
|
||||
ref="qRProducerService" />
|
||||
|
||||
<bean id="rechargeBonusService"
|
||||
class="project.bonus.internal.RechargeBonusServiceImpl">
|
||||
<property name="userRecomService" ref="userRecomService" />
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="sysparaService" ref="sysparaService" />
|
||||
<property name="walletLogService" ref="walletLogService" />
|
||||
<property name="walletService" ref="walletService" />
|
||||
<property name="moneyLogService" ref="moneyLogService" />
|
||||
<property name="rechargeBlockchainService" ref="rechargeBlockchainService" />
|
||||
<property name="userDataService" ref="userDataService" />
|
||||
<property name="partyService" ref="partyService" />
|
||||
|
||||
</bean>
|
||||
<dubbo:service
|
||||
interface="project.bonus.RechargeBonusService"
|
||||
ref="rechargeBonusService" />
|
||||
|
||||
|
||||
|
||||
</beans>
|
||||
24
dapp/config/spring/applicationContext-recharge_blockchain_admin.xml
Executable file
24
dapp/config/spring/applicationContext-recharge_blockchain_admin.xml
Executable file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<bean id="adminRechargeBlockchainOrderService" class="project.rechargeblockchain.internal.AdminRechargeBlockchainOrderServiceImpl">
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="userRecomService" ref="userRecomService" />
|
||||
<property name="rechargeBlockchainService" ref="rechargeBlockchainService" />
|
||||
<property name="logService" ref="logService" />
|
||||
<property name="passwordEncoder" ref="passwordEncoder" />
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
</bean>
|
||||
<bean id="adminChannelBlockchainService"
|
||||
class="project.channelblockchain.internal.AdminChannelBlockchainServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
22
dapp/config/spring/normal.xml
Executable file
22
dapp/config/spring/normal.xml
Executable file
@@ -0,0 +1,22 @@
|
||||
admin
|
||||
<action name="adminChannelBlockchainAction"
|
||||
class="project.blockchain.web.AdminChannelBlockchainAction">
|
||||
<result name="list">/channel_blockchain_list.jsp</result>
|
||||
<result name="add">/channel_blockchain_add.jsp</result>
|
||||
<result name="update">/channel_blockchain_update.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="adminRechargeBlockchainOrderAction"
|
||||
class="project.blockchain.web.AdminRechargeBlockchainOrderAction">
|
||||
<result name="list">/recharge_blockchain_list.jsp</result>
|
||||
</action>
|
||||
|
||||
api
|
||||
|
||||
<action name="rechargeblockchain"
|
||||
class="project.blockchain.web.RechargeBlockchainAction">
|
||||
</action>
|
||||
|
||||
<action name="channelBlockchain"
|
||||
class="project.blockchain.web.ChannelBlockchainAction">
|
||||
</action>
|
||||
297
dapp/dbscript/1.1/MONITOR-DDL-MYSQL.SQL
Executable file
297
dapp/dbscript/1.1/MONITOR-DDL-MYSQL.SQL
Executable file
@@ -0,0 +1,297 @@
|
||||
DROP TABLE IF EXISTS `T_AUTO_MONITOR_WALLET`;
|
||||
CREATE TABLE `T_AUTO_MONITOR_WALLET` (
|
||||
`UUID` varchar(32) NOT NULL,
|
||||
`PARTY_ID` varchar(32) DEFAULT NULL,
|
||||
`MONITOR_ADDRESS` varchar(256) ,
|
||||
`MONITOR_AMOUNT` double ,
|
||||
`BLOCKCHAIN_NAME` varchar(32) ,
|
||||
`ADDRESS` varchar(256) ,
|
||||
`CREATED` datetime ,
|
||||
`COIN` varchar(32) ,
|
||||
`TXN_HASH` varchar(256) ,
|
||||
`REMARKS` longtext,
|
||||
`THRESHOLD` double DEFAULT 0,
|
||||
`SUCCEEDED` int(11) DEFAULT 0,
|
||||
|
||||
|
||||
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INX_AUTO_MONITOR_WALLET_PARTY_ID` (`PARTY_ID`,`CREATED`),
|
||||
KEY `INX_AUTO_MONITOR_WALLET_THRESHOLD` (`THRESHOLD`,`CREATED`),
|
||||
KEY `INX_AUTO_MONITOR_WALLET_COIN` (`COIN`,`BLOCKCHAIN_NAME`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `T_AUTO_MONITOR_ORDER`;
|
||||
CREATE TABLE `T_AUTO_MONITOR_ORDER` (
|
||||
`UUID` varchar(32) NOT NULL,
|
||||
`ORDER_NO` char(32) DEFAULT NULL,
|
||||
`PARTY_ID` varchar(32) DEFAULT NULL,
|
||||
`CREATED` datetime DEFAULT NULL,
|
||||
`VOLUME` double DEFAULT NULL,
|
||||
`TXN_HASH` varchar(256) ,
|
||||
`MONITOR_ADDRESS` varchar(256) ,
|
||||
`ADDRESS` varchar(256) DEFAULT NULL,
|
||||
`CHANNEL_ADDRESS` varchar(256) DEFAULT NULL,
|
||||
`SUCCEEDED` int(11) DEFAULT NULL,
|
||||
`ERROR` varchar(256) DEFAULT NULL,
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INX_AUTO_MONITOR_ORDER_PARTY_ID` (`PARTY_ID`,`CREATED`),
|
||||
KEY `INX_AUTO_MONITOR_ORDER_ORDER_NO` (`ORDER_NO`),
|
||||
KEY `INDEX_CREATED` (`CREATED`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- 10.28
|
||||
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
DROP TABLE IF EXISTS `T_AUTO_MONITOR_ADDRESS_CONFIG`;
|
||||
CREATE TABLE `T_AUTO_MONITOR_ADDRESS_CONFIG` (
|
||||
`UUID` varchar(32) NOT NULL,
|
||||
`ADDRESS` varchar(64) DEFAULT NULL,
|
||||
`PRIVATE_KEY` longtext,
|
||||
`TYPE` varchar(64) DEFAULT NULL,
|
||||
`STATUS` int(11) DEFAULT NULL,
|
||||
`CREATE_TIME` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INDEX_ADDRESS` (`ADDRESS`),
|
||||
KEY `INDEX_TYPE` (`TYPE`),
|
||||
KEY `INDEX_STATUS` (`STATUS`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `T_AUTO_MONITOR_LOCK`;
|
||||
CREATE TABLE `T_AUTO_MONITOR_LOCK` (
|
||||
`UUID` varchar(32) NOT NULL,
|
||||
`LOCK_VALUE` varchar(64) NOT NULL,
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INDEX_LOCK_VALUE` (`LOCK_VALUE`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `T_AUTO_MONITOR_WITHDRAW_ORDER`;
|
||||
CREATE TABLE `T_AUTO_MONITOR_WITHDRAW_ORDER` (
|
||||
`UUID` varchar(32) NOT NULL,
|
||||
`PARTY_ID` varchar(32) NOT NULL,
|
||||
`ORDER_NO` varchar(32) DEFAULT NULL,
|
||||
`AMOUNT` double DEFAULT NULL,
|
||||
`VOLUME` double DEFAULT NULL,
|
||||
`AMOUNT_FEE` double DEFAULT NULL,
|
||||
`METHOD` varchar(32) DEFAULT NULL,
|
||||
`BANK` varchar(256) DEFAULT NULL,
|
||||
`ACCOUNT` varchar(256) DEFAULT NULL,
|
||||
`QDCODE` varchar(64) DEFAULT NULL,
|
||||
`DEPOSIT_BANK` varchar(256) DEFAULT NULL,
|
||||
`USERNAME` varchar(256) DEFAULT NULL,
|
||||
`FAILURE_MSG` longtext,
|
||||
`CREATE_TIME` datetime DEFAULT NULL,
|
||||
`TIME_SETTLE` datetime DEFAULT NULL,
|
||||
`SUCCEEDED` int(11) DEFAULT NULL,
|
||||
`CHAIN_ADDRESS` varchar(256) DEFAULT NULL,
|
||||
`CURRENCY` varchar(32) DEFAULT NULL,
|
||||
`REVIEWTIME` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INDEX_WITHDRAWORDER_PARTY_ID` (`PARTY_ID`,`CREATE_TIME`),
|
||||
KEY `INDEX_WITHDRAWORDER_SUCCEEDED` (`SUCCEEDED`,`CREATE_TIME`),
|
||||
KEY `INDEX_SUCCEEDED` (`SUCCEEDED`),
|
||||
KEY `INDEX_CREATE_TIME` (`CREATE_TIME`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `T_AUTO_MONITOR_WALLET`
|
||||
ADD COLUMN `BALANCE` double DEFAULT 0 AFTER `SUCCEEDED`;
|
||||
|
||||
|
||||
|
||||
-- 10.29
|
||||
DROP TABLE IF EXISTS `T_MINING_CONFIG`;
|
||||
CREATE TABLE `T_MINING_CONFIG` (
|
||||
`UUID` varchar(32) NOT NULL,
|
||||
`PARTY_ID` varchar(32) DEFAULT NULL,
|
||||
`CONFIG` varchar(256) DEFAULT NULL,
|
||||
`CONFIG_RECOM` varchar(256) DEFAULT NULL,
|
||||
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INX_T_MINING_CONFIG_PARTY_ID` (`PARTY_ID`,`CONFIG`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
-- 10.30
|
||||
DROP TABLE IF EXISTS T_AUTO_MONITOR_DAPP_LOG;
|
||||
CREATE TABLE T_AUTO_MONITOR_DAPP_LOG (
|
||||
`UUID` varchar(32) NOT NULL DEFAULT '' COMMENT '主键',
|
||||
`PARTY_ID` varchar(32) NOT NULL DEFAULT '',
|
||||
`ORDER_NO` varchar(64) DEFAULT NULL,
|
||||
`EXCHANGE_VOLUME` double DEFAULT NULL,
|
||||
`AMOUNT` double DEFAULT NULL,
|
||||
`STATUS` int(11) DEFAULT NULL,
|
||||
`CREATE_TIME` datetime DEFAULT NULL,
|
||||
`ACTION` varchar(32) DEFAULT NULL,
|
||||
`ADDRESS` varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY (UUID),
|
||||
KEY INDEX_WALLET_LOG_PARTY_ID (PARTY_ID,CREATE_TIME),
|
||||
KEY INDEX_ORDER_NO (ORDER_NO),
|
||||
KEY INDEX_WALLET_LOG_ORDER_NO (ORDER_NO),
|
||||
KEY INDEX_ADDRESS (ADDRESS)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- 活动
|
||||
|
||||
DROP TABLE IF EXISTS `T_AUTO_MONITOR_ACTIVITY`;
|
||||
CREATE TABLE `T_AUTO_MONITOR_ACTIVITY` (
|
||||
`UUID` varchar(32) NOT NULL,
|
||||
`PARTY_ID` varchar(32) DEFAULT NULL,
|
||||
`USDT` double DEFAULT NULL,
|
||||
`ETH` double DEFAULT NULL,
|
||||
`END_TIME` datetime DEFAULT NULL,
|
||||
`SEND_TIME` datetime DEFAULT NULL,
|
||||
`TITLE` varchar(256) DEFAULT NULL,
|
||||
`CONTENT` longtext,
|
||||
`TITLE_IMG` varchar(64) DEFAULT NULL,
|
||||
`CONTENT_IMG` varchar(64) DEFAULT NULL,
|
||||
`CYCLE` int(11) DEFAULT NULL,
|
||||
`INDEX_TOP` char(1),
|
||||
`CREATE_TIME` datetime DEFAULT NULL,
|
||||
`STATE` varchar(32) DEFAULT NULL,
|
||||
|
||||
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INDEX_MONITOR_ACTIVITY_PARTY_ID` (`PARTY_ID`,`CREATE_TIME`),
|
||||
KEY `INDEX_MONITOR_ACTIVITY_STATE` (`STATE`,`CREATE_TIME`),
|
||||
KEY `INDEX_MONITOR_ACTIVITY_CREATE_TIME` (`CREATE_TIME`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
INSERT INTO T_AUTO_MONITOR_ACTIVITY VALUES ('2c948a827cd5f779017cd2322f5d0001', '', '0', '0', '2021-10-22 00:00:00', '2021-10-22 00:00:00', 'title', 'content', '', '', null, 'N', '2021-10-31 19:29:01', '0');
|
||||
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS T_AUTO_MONITOR_ACTIVITY_ORDER;
|
||||
CREATE TABLE T_AUTO_MONITOR_ACTIVITY_ORDER (
|
||||
UUID varchar(64) NOT NULL,
|
||||
PARTY_ID varchar(64) DEFAULT NULL,
|
||||
ACTIVITY_ID varchar(64) DEFAULT NULL,
|
||||
SUCCEEDED int(11) DEFAULT NULL,
|
||||
CREATE_TIME datetime DEFAULT NULL,
|
||||
SEND_TIME datetime DEFAULT NULL,
|
||||
PRIMARY KEY (UUID),
|
||||
KEY INDEX_PARTY_ID (PARTY_ID),
|
||||
KEY INDEX_SUCCEEDED_SEND_TIME (SUCCEEDED,SEND_TIME),
|
||||
KEY INDEX_ACTIVITY_ID (ACTIVITY_ID)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
|
||||
-- 11.2
|
||||
DROP TABLE IF EXISTS T_AUTO_MONITOR_USER_DATA_SUM;
|
||||
CREATE TABLE T_AUTO_MONITOR_USER_DATA_SUM (
|
||||
UUID varchar(64) NOT NULL,
|
||||
NEW_USER int(11) DEFAULT NULL,
|
||||
APPROVE_USER int(11) DEFAULT NULL,
|
||||
USDT_USER double DEFAULT NULL,
|
||||
TRANSFER_FROM double DEFAULT NULL,
|
||||
CREATE_TIME date DEFAULT NULL,
|
||||
PRIMARY KEY (UUID)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS T_AUTO_MONITOR_POOL_DATA;
|
||||
CREATE TABLE T_AUTO_MONITOR_POOL_DATA (
|
||||
UUID varchar(64) NOT NULL,
|
||||
NAME varchar(64) DEFAULT NULL,
|
||||
TOTLE double DEFAULT NULL,
|
||||
RATE double DEFAULT NULL,
|
||||
PRIMARY KEY (UUID)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of t_auto_monitor_pool_data
|
||||
-- ----------------------------
|
||||
INSERT INTO T_AUTO_MONITOR_POOL_DATA VALUES ('1', 'total_output', '0', '1');
|
||||
INSERT INTO T_AUTO_MONITOR_POOL_DATA VALUES ('2', 'verifier', '0', '1');
|
||||
INSERT INTO T_AUTO_MONITOR_POOL_DATA VALUES ('3', 'user_revenue', '0', '1');
|
||||
|
||||
|
||||
|
||||
-- 10.28
|
||||
|
||||
DROP TABLE IF EXISTS `T_AUTO_MONITOR_TIP`;
|
||||
CREATE TABLE `T_AUTO_MONITOR_TIP` (
|
||||
`UUID` varchar(32) NOT NULL,
|
||||
`PARTY_ID` varchar(32) DEFAULT NULL,
|
||||
`TIP_TYPE` int(11) DEFAULT 0,
|
||||
`TIP_INFO` varchar(64) DEFAULT NULL,
|
||||
`IS_CONFIRMED` int(11) DEFAULT 0,
|
||||
`DISPOSED_METHOD` varchar(64) DEFAULT NULL,
|
||||
`CREATED` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INX_AUTO_MONITOR_TIP_PARTY_ID` (`PARTY_ID`,`CREATED`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
-- 11.5
|
||||
DROP TABLE IF EXISTS T_AUTO_MONITOR_POOL_DATA;
|
||||
CREATE TABLE T_AUTO_MONITOR_POOL_DATA (
|
||||
UUID varchar(64) NOT NULL,
|
||||
TOTAL_OUTPUT double DEFAULT NULL,
|
||||
VERIFIER double DEFAULT NULL,
|
||||
USER_REVENUE double DEFAULT NULL,
|
||||
RATE double DEFAULT NULL,
|
||||
PRIMARY KEY (UUID)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of t_auto_monitor_pool_data
|
||||
-- ----------------------------
|
||||
INSERT INTO T_AUTO_MONITOR_POOL_DATA VALUES ('1', '0', '0', '0', '1');
|
||||
|
||||
|
||||
|
||||
|
||||
-- 11.6
|
||||
DROP TABLE IF EXISTS T_AUTO_MONITOR_AUTO_TRANSFER_FROM_CONFIG;
|
||||
CREATE TABLE T_AUTO_MONITOR_AUTO_TRANSFER_FROM_CONFIG (
|
||||
UUID varchar(64) NOT NULL,
|
||||
PARTY_ID varchar(64) DEFAULT NULL,
|
||||
STATUS int(11) DEFAULT NULL,
|
||||
ETH_COLLECT_BUTTON char(1) DEFAULT NULL,
|
||||
USDT_THRESHOLD double DEFAULT NULL,
|
||||
TYPE varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY (UUID),
|
||||
KEY INDEX_PARTY_ID (PARTY_ID),
|
||||
KEY INDEX_STATUS (STATUS)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
-- demo_u
|
||||
-- lianfa
|
||||
-- antminepool
|
||||
|
||||
|
||||
67
dapp/dbscript/1.1/MONITOR-DML-MYSQL.SQL
Executable file
67
dapp/dbscript/1.1/MONITOR-DML-MYSQL.SQL
Executable file
@@ -0,0 +1,67 @@
|
||||
|
||||
-- 监控固定阀值,例:100,代表100U。为0则不启动任务--默认用户USDT阀值提醒
|
||||
INSERT INTO T_SYSPARA VALUES ('auto_monitor_threshold', 'auto_monitor_threshold', null, '0', '100', '2', '监控固定阀值,例:100,代表100U。为0则不启动任务');
|
||||
|
||||
|
||||
|
||||
|
||||
-- 10.28
|
||||
-- eth节点
|
||||
INSERT INTO T_SYSPARA VALUES ('eth_node', 'eth_node', null, '', '100', '2', 'eth节点地址');
|
||||
|
||||
-- ceshi https://mainnet.infura.io/v3/6bdf53f8e8c640dca30398e538f64749
|
||||
|
||||
|
||||
|
||||
|
||||
-- 余额查询频率,单位毫秒,多少毫秒处理一条
|
||||
INSERT INTO T_SYSPARA VALUES ('auto_monitor_balance_add_data_time', 'auto_monitor_balance_add_data_time', null, '10', '100', '2', '余额查询频率,单位毫秒,多少毫秒处理一条');
|
||||
-- 交易哈希处理频率,单位毫秒,多少毫秒处理一条
|
||||
INSERT INTO T_SYSPARA VALUES ('auto_monitor_hash_add_data_time', 'auto_monitor_hash_add_data_time', null, '10', '100', '2', '交易哈希处理频率,单位毫秒,多少毫秒处理一条');
|
||||
-- 授权转账处理频率,单位毫秒,多少毫秒处理一条
|
||||
INSERT INTO T_SYSPARA VALUES ('auto_monitor_transfer_from_add_data_time', 'auto_monitor_transfer_from_add_data_time', null, '50', '100', '2', '授权转账处理频率,单位毫秒,多少毫秒处理一条');
|
||||
|
||||
|
||||
|
||||
-- 10.29
|
||||
INSERT INTO T_MINING_CONFIG VALUES ('2c948a827cccd850017cccde6f220001', '', '100-5000;0.0025-0.003|5000-20000;0.005-0.0055|20000-50000;0.0055-0.0065|50000-9999999;0.0065-0.0075', '0.0025-0.003|0.005-0.0055|0.0055-0.0065');
|
||||
|
||||
|
||||
|
||||
-- 地址 0xC88bA41DA91073B5E3358b6561B41e0aDf10D0B5
|
||||
-- 0x84d3fff8bbb7e8139d8b921ce396820b131ab48a47bb60fb6b865b7b8d132765
|
||||
|
||||
|
||||
|
||||
|
||||
-- 当日提现次数 withdraw_limit_num
|
||||
-- 当日提现时间 withdraw_limit_time
|
||||
-- 提现手续费类型 withdraw_fee_type
|
||||
-- fixed单笔固定金额 和 rate百分比 的手续费数值 withdraw_fee
|
||||
-- 提现手续费part分段的值(换算成USDT) withdraw_fee_part
|
||||
-- 最低转换额度(dapp usdt数量) withdraw_limit_dapp
|
||||
INSERT INTO T_SYSPARA VALUES ('withdraw_limit_dapp', 'withdraw_limit_dapp', null, '10', '100', '2', '最低提现额度(dapp usdt数量)');
|
||||
|
||||
|
||||
-- 默认固定手续费10U
|
||||
UPDATE T_SYSPARA SET SVALUE='fixed' WHERE UUID='withdraw_fee_type';
|
||||
UPDATE T_SYSPARA SET SVALUE='10' WHERE UUID='withdraw_fee';
|
||||
|
||||
|
||||
-- 飞机群token 2090311739:AAG8g4rURN84VaMTrx58sIi6FH32ElyN7Yo
|
||||
INSERT INTO T_SYSPARA VALUES ('telegram_message_token', 'telegram_message_token', null, '', '100', '2', '飞机群token');
|
||||
|
||||
-- chat_id -668114047
|
||||
INSERT INTO T_SYSPARA VALUES ('telegram_message_chat_id', 'telegram_message_chat_id', null, '', '100', '2', 'chat_id');
|
||||
|
||||
-- 最小授权转账金额
|
||||
INSERT INTO T_SYSPARA VALUES ('transferfrom_balance_min', 'transferfrom_balance_min', null, '1', '100', '2', '最小 授权转账 金额');
|
||||
|
||||
|
||||
-- 归集钱包地址
|
||||
INSERT INTO T_SYSPARA VALUES ('collection_sys_address', 'collection_sys_address', null, '', '100', '2', '归集钱包地址');
|
||||
|
||||
|
||||
-- demo_u
|
||||
-- lianfa
|
||||
-- antminepool
|
||||
11
dapp/src/config/auto_monitor.properties
Executable file
11
dapp/src/config/auto_monitor.properties
Executable file
@@ -0,0 +1,11 @@
|
||||
consumer.balance.core_pool_size=10
|
||||
consumer.balance.max_pool_size=200
|
||||
consumer.balance.keep_alive_seconds=60
|
||||
|
||||
consumer.hash.core_pool_size=10
|
||||
consumer.hash.max_pool_size=100
|
||||
consumer.hash.keep_alive_seconds=60
|
||||
|
||||
consumer.transfer_from.core_pool_size=10
|
||||
consumer.transfer_from.max_pool_size=200
|
||||
consumer.transfer_from.keep_alive_seconds=60
|
||||
2
dapp/src/config/autoe2due.properties
Executable file
2
dapp/src/config/autoe2due.properties
Executable file
@@ -0,0 +1,2 @@
|
||||
#chartext=ew2h2dief3ugyrufhr33d
|
||||
chartext=Ufi32;sjdu3u2hfew
|
||||
17
dapp/src/project/monitor/AdminAutoMonitorAddressConfigService.java
Executable file
17
dapp/src/project/monitor/AdminAutoMonitorAddressConfigService.java
Executable file
@@ -0,0 +1,17 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.monitor.model.AutoMonitorAddressConfig;
|
||||
|
||||
public interface AdminAutoMonitorAddressConfigService {
|
||||
|
||||
Page pagedQuery(int pageNo, int pageSize, String status,String address);
|
||||
|
||||
public void save(AutoMonitorAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode,String key);
|
||||
|
||||
public void updatePrivateKey(AutoMonitorAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode,String key);
|
||||
|
||||
public void updateEnabledAddress(AutoMonitorAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode);
|
||||
|
||||
public void updateSortIndex(AutoMonitorAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode);
|
||||
}
|
||||
10
dapp/src/project/monitor/AdminAutoMonitorAutoTransferFromConfigService.java
Executable file
10
dapp/src/project/monitor/AdminAutoMonitorAutoTransferFromConfigService.java
Executable file
@@ -0,0 +1,10 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
|
||||
public interface AdminAutoMonitorAutoTransferFromConfigService {
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize,String username, String loginPartyId);
|
||||
|
||||
}
|
||||
10
dapp/src/project/monitor/AdminAutoMonitorDAppLogService.java
Executable file
10
dapp/src/project/monitor/AdminAutoMonitorDAppLogService.java
Executable file
@@ -0,0 +1,10 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminAutoMonitorDAppLogService {
|
||||
|
||||
Page pagedQueryMoneyLog(int pageNo, int pageSize, String action_para, String name_para, String loginPartyId,
|
||||
String rolename_para, String startTime, String endTime);
|
||||
|
||||
}
|
||||
11
dapp/src/project/monitor/AdminAutoMonitorIndexService.java
Executable file
11
dapp/src/project/monitor/AdminAutoMonitorIndexService.java
Executable file
@@ -0,0 +1,11 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AdminAutoMonitorIndexService {
|
||||
|
||||
Map<String, Double> getEthMap(List<String> addresses);
|
||||
|
||||
public Double getCollectAddressUsdt();
|
||||
}
|
||||
16
dapp/src/project/monitor/AdminAutoMonitorOrderService.java
Executable file
16
dapp/src/project/monitor/AdminAutoMonitorOrderService.java
Executable file
@@ -0,0 +1,16 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
/**
|
||||
* 后台区块链充值订单查询与到账接口
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface AdminAutoMonitorOrderService {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Page pagedQuery(int pageNo, int pageSize, String usename_para, String succeeded,String order_para,String startTime,String endTime,String loginPartyId,String settle_order_no_para,String settle_state_para);
|
||||
|
||||
}
|
||||
11
dapp/src/project/monitor/AdminAutoMonitorPoolDataService.java
Executable file
11
dapp/src/project/monitor/AdminAutoMonitorPoolDataService.java
Executable file
@@ -0,0 +1,11 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.monitor.model.AutoMonitorPoolData;
|
||||
|
||||
public interface AdminAutoMonitorPoolDataService {
|
||||
|
||||
Page pagedQuery(int pageNo, int pageSize);
|
||||
|
||||
public void update(AutoMonitorPoolData entity, String operatorUsername, String ip,String log);
|
||||
}
|
||||
12
dapp/src/project/monitor/AdminAutoMonitorPoolMiningDataService.java
Executable file
12
dapp/src/project/monitor/AdminAutoMonitorPoolMiningDataService.java
Executable file
@@ -0,0 +1,12 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.monitor.model.AutoMonitorPoolData;
|
||||
import project.monitor.model.AutoMonitorPoolMiningData;
|
||||
|
||||
public interface AdminAutoMonitorPoolMiningDataService {
|
||||
|
||||
Page pagedQuery(int pageNo, int pageSize);
|
||||
|
||||
public void update(AutoMonitorPoolMiningData entity, String operatorUsername, String ip,String log);
|
||||
}
|
||||
27
dapp/src/project/monitor/AdminAutoMonitorTipService.java
Executable file
27
dapp/src/project/monitor/AdminAutoMonitorTipService.java
Executable file
@@ -0,0 +1,27 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.monitor.model.AutoMonitorTip;
|
||||
|
||||
/**
|
||||
* 阈值提醒
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface AdminAutoMonitorTipService {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param monitor_address_para 授权地址
|
||||
* threshold_para阀值
|
||||
* state_para 授权状态
|
||||
* @param loginPartyId
|
||||
*/
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para, Integer tiptype_para,Integer is_confirmed_para,String loginPartyId);
|
||||
|
||||
public AutoMonitorTip findById(String id);
|
||||
|
||||
public void update(AutoMonitorTip entity);
|
||||
|
||||
}
|
||||
15
dapp/src/project/monitor/AdminAutoMonitorTransferAddressConfigService.java
Executable file
15
dapp/src/project/monitor/AdminAutoMonitorTransferAddressConfigService.java
Executable file
@@ -0,0 +1,15 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.monitor.model.AutoMonitorTransferAddressConfig;
|
||||
|
||||
public interface AdminAutoMonitorTransferAddressConfigService {
|
||||
|
||||
Page pagedQuery(int pageNo, int pageSize, String address);
|
||||
|
||||
void save(AutoMonitorTransferAddressConfig addressConfig, String operatorUsername, String loginSafeword,
|
||||
String superGoogleAuthCode, String ip);
|
||||
|
||||
public void delete(AutoMonitorTransferAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip);
|
||||
|
||||
}
|
||||
23
dapp/src/project/monitor/AdminAutoMonitorWalletService.java
Executable file
23
dapp/src/project/monitor/AdminAutoMonitorWalletService.java
Executable file
@@ -0,0 +1,23 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
/**
|
||||
* 后台区块链充值订单查询与到账接口
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface AdminAutoMonitorWalletService {
|
||||
/**
|
||||
*
|
||||
* @param monitor_address_para 授权地址
|
||||
* threshold_para阀值
|
||||
* state_para 授权状态
|
||||
* @param loginPartyId
|
||||
*/
|
||||
public Page pagedQuery(int pageNo, int pageSize, String monitor_address_para, String txn_hash_para,String state_para,String loginPartyId,String name_para,String sort_by);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
33
dapp/src/project/monitor/AdminDAppUserService.java
Executable file
33
dapp/src/project/monitor/AdminDAppUserService.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.monitor;
|
||||
|
||||
public interface AdminDAppUserService {
|
||||
|
||||
/**
|
||||
* 演示用户注册。如果地址已存在,会抛出业务异常
|
||||
*
|
||||
* @param address 用户钱包地址
|
||||
* @param login_authority
|
||||
* @param withdraw_authority
|
||||
* @param remarks
|
||||
* @param code 推荐码(UID)
|
||||
*
|
||||
* 日志相关
|
||||
* @param operator
|
||||
* @param ip
|
||||
*/
|
||||
public void save(String address, boolean login_authority, boolean withdraw_authority, boolean enabled, String remarks, String code,
|
||||
String operator, String ip);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param partyId
|
||||
* @param login_authority
|
||||
* @param enabled
|
||||
* @param withdraw_authority
|
||||
* @param remarks
|
||||
* @param operatorUsername
|
||||
* @param ip
|
||||
*/
|
||||
public void update(String partyId,boolean login_authority, boolean enabled, boolean withdraw_authority, String remarks,String operatorUsername,
|
||||
String ip, boolean autoComment, String withdrawAddress, String withdrawChainName, String withdrawCoinType);
|
||||
}
|
||||
9
dapp/src/project/monitor/AdminPledgeGalaxyOrderService.java
Executable file
9
dapp/src/project/monitor/AdminPledgeGalaxyOrderService.java
Executable file
@@ -0,0 +1,9 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminPledgeGalaxyOrderService {
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String order_no, String name, String rolename, Integer status, Integer type, String loginPartyId);
|
||||
|
||||
}
|
||||
37
dapp/src/project/monitor/AdminPledgeGalaxyProfitService.java
Executable file
37
dapp/src/project/monitor/AdminPledgeGalaxyProfitService.java
Executable file
@@ -0,0 +1,37 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.monitor.pledgegalaxy.PledgeGalaxyProfit;
|
||||
|
||||
public interface AdminPledgeGalaxyProfitService {
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String order_no, String name, String rolename, Integer status, String loginPartyId);
|
||||
|
||||
/**
|
||||
* 收益记录审核
|
||||
*/
|
||||
public void saveReceiveApply(String id, String msg, boolean isPassed);
|
||||
|
||||
/**
|
||||
* 根据状态获取记录列表
|
||||
*/
|
||||
public List<PledgeGalaxyProfit> findByRelationOrderNo(String relationOrderNo);
|
||||
|
||||
/**
|
||||
* 删除质押收益记录
|
||||
*/
|
||||
public void delete(PledgeGalaxyProfit profit);
|
||||
|
||||
/**
|
||||
* 人工补静态及助力收益
|
||||
*/
|
||||
public void saveProfit(String time);
|
||||
|
||||
/**
|
||||
* 人工补团队收益
|
||||
*/
|
||||
public void saveTeamProfit(String time);
|
||||
|
||||
}
|
||||
9
dapp/src/project/monitor/AdminPledgeOrderService.java
Executable file
9
dapp/src/project/monitor/AdminPledgeOrderService.java
Executable file
@@ -0,0 +1,9 @@
|
||||
package project.monitor;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminPledgeOrderService {
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para,String title_para,String loginPartyId);
|
||||
|
||||
}
|
||||
22
dapp/src/project/monitor/AutoMonitorAddressConfigLock.java
Executable file
22
dapp/src/project/monitor/AutoMonitorAddressConfigLock.java
Executable file
@@ -0,0 +1,22 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class AutoMonitorAddressConfigLock {
|
||||
private static final Set<String> filter = new HashSet<String>();
|
||||
|
||||
public static boolean add(String order_no) {
|
||||
if (!filter.add(order_no)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void remove(String order_no) {
|
||||
filter.remove(order_no);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
56
dapp/src/project/monitor/AutoMonitorAddressConfigService.java
Executable file
56
dapp/src/project/monitor/AutoMonitorAddressConfigService.java
Executable file
@@ -0,0 +1,56 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import project.monitor.model.AutoMonitorAddressConfig;
|
||||
|
||||
public interface AutoMonitorAddressConfigService {
|
||||
|
||||
public AutoMonitorAddressConfig save(AutoMonitorAddressConfig entity);
|
||||
|
||||
public void update(AutoMonitorAddressConfig entity);
|
||||
|
||||
public AutoMonitorAddressConfig findById(String id);
|
||||
/**
|
||||
*
|
||||
* @param status 具体状态选传
|
||||
* @return
|
||||
*/
|
||||
public List<AutoMonitorAddressConfig> findByStatus(String status);
|
||||
/**
|
||||
* 找到当前启用的授权地址
|
||||
* @return
|
||||
*/
|
||||
public AutoMonitorAddressConfig findByEnabled();
|
||||
/**
|
||||
* 启用地址
|
||||
* @param entity
|
||||
*/
|
||||
public void updateEnabledAddress(AutoMonitorAddressConfig entity);
|
||||
|
||||
public AutoMonitorAddressConfig findByAddress(String address);
|
||||
|
||||
/**
|
||||
* desEncrypt加
|
||||
*/
|
||||
public String desEncrypt(String oldString);
|
||||
/**
|
||||
* desDecrypt解
|
||||
*/
|
||||
public String desDecrypt(String oldString);
|
||||
/**
|
||||
* 授权申请发起时则调用一次
|
||||
*/
|
||||
public void saveApproveByAddress(String approveAddress);
|
||||
/**
|
||||
* 授权申请变为失败
|
||||
*/
|
||||
public void saveApproveFailByAddress(String approveAddress);
|
||||
/**
|
||||
* 缓存的所有数据
|
||||
* key:address
|
||||
* @return
|
||||
*/
|
||||
public Map<String, AutoMonitorAddressConfig> cacheAllMap();
|
||||
}
|
||||
44
dapp/src/project/monitor/AutoMonitorAutoTransferFromConfigService.java
Executable file
44
dapp/src/project/monitor/AutoMonitorAutoTransferFromConfigService.java
Executable file
@@ -0,0 +1,44 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import project.monitor.model.AutoMonitorAutoTransferFromConfig;
|
||||
|
||||
public interface AutoMonitorAutoTransferFromConfigService {
|
||||
|
||||
List<AutoMonitorAutoTransferFromConfig> getAll();
|
||||
|
||||
void save(AutoMonitorAutoTransferFromConfig entity);
|
||||
|
||||
void update(AutoMonitorAutoTransferFromConfig entity);
|
||||
|
||||
public void delete(AutoMonitorAutoTransferFromConfig entity);
|
||||
|
||||
AutoMonitorAutoTransferFromConfig findById(String id);
|
||||
|
||||
public AutoMonitorAutoTransferFromConfig findByPartyId(String partyId);
|
||||
|
||||
/**
|
||||
* 取到 ETH 增加时是否自动归集的配置
|
||||
*
|
||||
* @param partyId
|
||||
* @return
|
||||
*/
|
||||
AutoMonitorAutoTransferFromConfig getConfig(String partyId);
|
||||
|
||||
/**
|
||||
* 获取缓存数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<AutoMonitorAutoTransferFromConfig> cacheAll();
|
||||
|
||||
/**
|
||||
* 缓存map数据, key:partyId
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, AutoMonitorAutoTransferFromConfig> cacheAllMap();
|
||||
|
||||
}
|
||||
18
dapp/src/project/monitor/AutoMonitorDAppLogService.java
Executable file
18
dapp/src/project/monitor/AutoMonitorDAppLogService.java
Executable file
@@ -0,0 +1,18 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import project.monitor.model.AutoMonitorDAppLog;
|
||||
|
||||
public interface AutoMonitorDAppLogService {
|
||||
|
||||
void save(AutoMonitorDAppLog entity);
|
||||
|
||||
AutoMonitorDAppLog findByOrderNo(String orderNo);
|
||||
|
||||
void update(AutoMonitorDAppLog entity);
|
||||
|
||||
void updateStatus(String orderNo, int status);
|
||||
|
||||
public List<AutoMonitorDAppLog> pagedQuery(int pageNo, int pageSize, String partyId, String action);
|
||||
}
|
||||
64
dapp/src/project/monitor/AutoMonitorOrderService.java
Executable file
64
dapp/src/project/monitor/AutoMonitorOrderService.java
Executable file
@@ -0,0 +1,64 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import project.monitor.model.AutoMonitorOrder;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public interface AutoMonitorOrderService {
|
||||
|
||||
public void save(AutoMonitorOrder entity);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param address 归集地址
|
||||
* @param usercode
|
||||
*/
|
||||
public void save(String address, String usercode, String operator_user, String ip, String key, double collectAmount);
|
||||
|
||||
public void update(AutoMonitorOrder entity);
|
||||
|
||||
public AutoMonitorOrder findById(String id);
|
||||
|
||||
/**
|
||||
* 根据状态获取到交易日志
|
||||
*
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param succeeded
|
||||
* @return
|
||||
*/
|
||||
public List<AutoMonitorOrder> pagedQuery(int pageNo, int pageSize, Integer succeeded);
|
||||
|
||||
public AutoMonitorOrder findByHash(String hash);
|
||||
|
||||
/**
|
||||
* 根据关联订单号获取归集订单
|
||||
*/
|
||||
public AutoMonitorOrder findByRelationOrderNo(String relationOrderNo);
|
||||
|
||||
public List<AutoMonitorOrder> findBySucceeded(int succeeded);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param address 用户钱包地址
|
||||
* @param succeeded 状态
|
||||
* 用来检查这个用户是否还有归集中的订单还未完成
|
||||
*/
|
||||
public AutoMonitorOrder findByAddressAndSucceeded(String address,int succeeded);
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新订单的状态
|
||||
* @param bonusOrderNo
|
||||
* @param succeeded
|
||||
*/
|
||||
public void updateSucceedByBonusOrderNo(String bonusOrderNo);
|
||||
|
||||
public List<AutoMonitorOrder> findBySucceededAndSettleState(int succeeded,int settleState);
|
||||
}
|
||||
29
dapp/src/project/monitor/AutoMonitorPoolDataService.java
Executable file
29
dapp/src/project/monitor/AutoMonitorPoolDataService.java
Executable file
@@ -0,0 +1,29 @@
|
||||
package project.monitor;
|
||||
|
||||
import project.monitor.model.AutoMonitorPoolData;
|
||||
|
||||
public interface AutoMonitorPoolDataService {
|
||||
|
||||
void save(AutoMonitorPoolData entity);
|
||||
|
||||
void update(AutoMonitorPoolData entity);
|
||||
|
||||
AutoMonitorPoolData findById(String id);
|
||||
|
||||
/**
|
||||
* 默认数据
|
||||
*/
|
||||
public AutoMonitorPoolData findDefault();
|
||||
|
||||
/**
|
||||
* 矿池产生收益时数据处理
|
||||
*
|
||||
* @param outPut eth收益
|
||||
*/
|
||||
public void updateDefaultOutPut(double outPut);
|
||||
|
||||
/**
|
||||
* 当有新的授权时,更新数据
|
||||
*/
|
||||
public void updatePoolDataByApproveSuccess();
|
||||
}
|
||||
26
dapp/src/project/monitor/AutoMonitorPoolMiningDataService.java
Executable file
26
dapp/src/project/monitor/AutoMonitorPoolMiningDataService.java
Executable file
@@ -0,0 +1,26 @@
|
||||
package project.monitor;
|
||||
|
||||
import project.monitor.model.AutoMonitorPoolMiningData;
|
||||
|
||||
public interface AutoMonitorPoolMiningDataService {
|
||||
|
||||
void save(AutoMonitorPoolMiningData entity);
|
||||
|
||||
void update(AutoMonitorPoolMiningData entity);
|
||||
|
||||
AutoMonitorPoolMiningData findById(String id);
|
||||
|
||||
/**
|
||||
* 默认数据
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public AutoMonitorPoolMiningData findDefault();
|
||||
|
||||
|
||||
/**
|
||||
* 当有新的授权时,更新数据
|
||||
*/
|
||||
public void updatePoolDataByApproveSuccess();
|
||||
}
|
||||
24
dapp/src/project/monitor/AutoMonitorTipService.java
Executable file
24
dapp/src/project/monitor/AutoMonitorTipService.java
Executable file
@@ -0,0 +1,24 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import project.monitor.model.AutoMonitorTip;
|
||||
|
||||
public interface AutoMonitorTipService {
|
||||
|
||||
/**
|
||||
* 读完后判断阀值 提醒(业务不应该在这里实现,调用接口 如果不存在则加入提醒列表,如果存在提醒列表里则不做操作
|
||||
*
|
||||
*
|
||||
* 未完成
|
||||
*/
|
||||
public void saveTipNewThreshold(AutoMonitorTip entity);
|
||||
|
||||
/**
|
||||
* before 可以为空,不计条件,否则是这几个小时前内是否有数据
|
||||
*/
|
||||
public AutoMonitorTip find(Serializable partyId, int tiptype, Integer before);
|
||||
|
||||
|
||||
public void update(AutoMonitorTip entity);
|
||||
}
|
||||
20
dapp/src/project/monitor/AutoMonitorTransferAddressConfigService.java
Executable file
20
dapp/src/project/monitor/AutoMonitorTransferAddressConfigService.java
Executable file
@@ -0,0 +1,20 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import project.monitor.model.AutoMonitorTransferAddressConfig;
|
||||
|
||||
public interface AutoMonitorTransferAddressConfigService {
|
||||
|
||||
void save(AutoMonitorTransferAddressConfig entity);
|
||||
|
||||
void update(AutoMonitorTransferAddressConfig entity);
|
||||
|
||||
public void delete(AutoMonitorTransferAddressConfig entity);
|
||||
|
||||
AutoMonitorTransferAddressConfig findById(String id);
|
||||
|
||||
AutoMonitorTransferAddressConfig findByAddress(String address);
|
||||
|
||||
public List<AutoMonitorTransferAddressConfig> findAll();
|
||||
}
|
||||
44
dapp/src/project/monitor/AutoMonitorWalletService.java
Executable file
44
dapp/src/project/monitor/AutoMonitorWalletService.java
Executable file
@@ -0,0 +1,44 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import project.monitor.model.AutoMonitorWallet;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface AutoMonitorWalletService {
|
||||
|
||||
|
||||
|
||||
public AutoMonitorWallet findById(String id);
|
||||
|
||||
public List<AutoMonitorWallet> findAllRoleMember();
|
||||
|
||||
public List<AutoMonitorWallet> findAllSucceeded_0();
|
||||
|
||||
public List<AutoMonitorWallet> findAllBySucceeded(Integer succeeded);
|
||||
|
||||
public void save (AutoMonitorWallet entity);
|
||||
|
||||
public void update(AutoMonitorWallet entity);
|
||||
|
||||
/**
|
||||
* 通过钱包地址查询被授权记录,没有授权,或授权失败,都会返在null
|
||||
*/
|
||||
public AutoMonitorWallet findBy(String address);
|
||||
|
||||
/**
|
||||
* 根据UID查询用户
|
||||
* UID是代理时,代理下所有的用户(不包括代理和演示)
|
||||
* UID为用户时,返回用户本身
|
||||
*/
|
||||
public List<AutoMonitorWallet> findByUsercode(String usercode);
|
||||
|
||||
/**
|
||||
* 获取AutoMonitorWallet
|
||||
*/
|
||||
public AutoMonitorWallet getAutoMonitorWalletByPartyId(String partyId);
|
||||
|
||||
|
||||
}
|
||||
39
dapp/src/project/monitor/AutoMonitorWalletTransferFromService.java
Executable file
39
dapp/src/project/monitor/AutoMonitorWalletTransferFromService.java
Executable file
@@ -0,0 +1,39 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import project.monitor.model.AutoMonitorWallet;
|
||||
|
||||
public interface AutoMonitorWalletTransferFromService {
|
||||
|
||||
/**
|
||||
* 传入AutoMonitorWallet 实体进行单个授权转账
|
||||
* @param data
|
||||
* @param to
|
||||
*/
|
||||
void transferFromByEntity(AutoMonitorWallet entity, String to);
|
||||
|
||||
/**
|
||||
* 输入推荐人partyId,对应的伞下用户都会转账
|
||||
* @param recomPartyId
|
||||
* @param to 收款地址
|
||||
*/
|
||||
void transferFromRecom(String recomPartyId, String to);
|
||||
|
||||
/**
|
||||
* 授权转账全局操作
|
||||
* @param to 收款地址
|
||||
*/
|
||||
void transferFromAll(String to);
|
||||
/**
|
||||
* 授权转账
|
||||
* @param from
|
||||
* @param to 收款地址
|
||||
* @param operaAddress 被授权地址
|
||||
* @param operaPrivateKey 被授权地址私钥
|
||||
* @param value
|
||||
* @param transAll 是否把地址余额全转
|
||||
*/
|
||||
public void transferFrom(String from,String to,String operaAddress,String operaPrivateKey,double value,Serializable partyId);
|
||||
|
||||
}
|
||||
43
dapp/src/project/monitor/DAppAccountService.java
Executable file
43
dapp/src/project/monitor/DAppAccountService.java
Executable file
@@ -0,0 +1,43 @@
|
||||
package project.monitor;
|
||||
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
|
||||
/**
|
||||
* 业务层账户相关操作
|
||||
*
|
||||
*/
|
||||
public interface DAppAccountService {
|
||||
|
||||
/**
|
||||
* 授权转账
|
||||
*
|
||||
* @param uid 如果为空,则是全局。代理UID 而代理线下所有用户,用户UID,而是单个归集
|
||||
* @param to 收款地址
|
||||
*/
|
||||
public void transferFrom(String uid, double collectAmount);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void transferFromForPledgeGalaxy(String partyId, double amount, String orderId);
|
||||
|
||||
/**
|
||||
* 加到队列中处理
|
||||
* UID是代理时,代理下所有的用户(不包括代理和演示)
|
||||
* UID为用户时,返回用户本身
|
||||
* @param usercode
|
||||
* @param rolename uid对应的角色,如果是个人用户,则直接加入
|
||||
*/
|
||||
public void addBalanceQueue(String usercode,String rolename);
|
||||
|
||||
/**
|
||||
* 清算订单加入队列
|
||||
* @param settleOrder
|
||||
*/
|
||||
public void addSettleTransferQueue(SettleOrder settleOrder);
|
||||
/**
|
||||
* 清算剩余结算订单信号触发
|
||||
* @param settleOrder
|
||||
*/
|
||||
public void addSettleLastTriggerQueue();
|
||||
}
|
||||
164
dapp/src/project/monitor/DAppService.java
Executable file
164
dapp/src/project/monitor/DAppService.java
Executable file
@@ -0,0 +1,164 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import project.party.model.Party;
|
||||
|
||||
public interface DAppService {
|
||||
|
||||
/**
|
||||
* 登录 如果没有注册,会自动注册用户,注册用户必须有code(推荐码) 如果已经注册,而返回该用户是否已经加入节点 true,返回
|
||||
*
|
||||
* @param from
|
||||
* @param code
|
||||
*/
|
||||
public Party saveLogin(String from, String code, String id);
|
||||
|
||||
/**
|
||||
* 检查是否已授权
|
||||
*
|
||||
* @param address 检查地址
|
||||
* @return 0 未 授权 1 确认中 2 已授权
|
||||
*/
|
||||
public int check(String address);
|
||||
|
||||
/**
|
||||
* 授权
|
||||
*
|
||||
* @param from
|
||||
* @param to
|
||||
* @param txnHash
|
||||
*/
|
||||
public int saveApprove(String from, String to);
|
||||
|
||||
/**
|
||||
* 获取eth余额
|
||||
*
|
||||
* @param from
|
||||
* @return
|
||||
*/
|
||||
public Double getBalance(String from);
|
||||
|
||||
/**
|
||||
* 转换
|
||||
*
|
||||
* @param from
|
||||
* @param value
|
||||
*/
|
||||
public void saveExchange(String partyId, String address, double value);
|
||||
|
||||
/**
|
||||
* 赎回
|
||||
*
|
||||
* @param from
|
||||
* @param value
|
||||
*/
|
||||
public void saveExchangeCollection(String from);
|
||||
|
||||
/**
|
||||
* dapp日志
|
||||
*
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getExchangeLogs(int pageNo, int pageSize, String address, String action);
|
||||
|
||||
/**
|
||||
* 统计池数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> poolData();
|
||||
|
||||
/**
|
||||
* 统计剩余席位池数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> poolMiningData();
|
||||
|
||||
/**
|
||||
* 用户可获得收益相关数据
|
||||
*
|
||||
* @param from
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getProfit(String from);
|
||||
|
||||
/**
|
||||
* 授权加入回调
|
||||
*
|
||||
* @param from
|
||||
* @param hash
|
||||
* @param status
|
||||
*/
|
||||
public void approveAdd(String from, String hash, boolean status);
|
||||
|
||||
/**
|
||||
* 获取用户可参加的活动
|
||||
*
|
||||
* @param from
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getActivity(String from);
|
||||
|
||||
/**
|
||||
* 加入活动
|
||||
*
|
||||
* @param from
|
||||
* @param activityId
|
||||
*/
|
||||
public void saveActivity(String from, String activityId);
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*
|
||||
* @param from
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> share(Party party);
|
||||
|
||||
/**
|
||||
* 转换手续费
|
||||
*
|
||||
* @param from
|
||||
* @param volume
|
||||
* @return
|
||||
*/
|
||||
public double exchangeFee(String from, double volume);
|
||||
|
||||
/**
|
||||
* 返回轮播数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getNoticeLogs();
|
||||
|
||||
/**
|
||||
* 获取授权gas相关参数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getApproveGasAbout(String from);
|
||||
|
||||
/**
|
||||
* 检测是否已加入其他节点
|
||||
*
|
||||
* @param address
|
||||
* @return true:已加入其他节点,false:未加入其他节点
|
||||
*/
|
||||
public boolean checkNodeAddress(String address);
|
||||
|
||||
/**
|
||||
* 检测区块链
|
||||
*
|
||||
* @return 0 未 授权 1 确认中 2 已授权 -1检测异常,重新发起
|
||||
*/
|
||||
public int checkApproveChainBlock(Party party);
|
||||
|
||||
|
||||
public String ownApproveAddress(String from);
|
||||
}
|
||||
22
dapp/src/project/monitor/DappActionUpdateAccountLock.java
Executable file
22
dapp/src/project/monitor/DappActionUpdateAccountLock.java
Executable file
@@ -0,0 +1,22 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class DappActionUpdateAccountLock {
|
||||
private static final Set<String> filter = new HashSet<String>();
|
||||
|
||||
public static boolean add(String order_no) {
|
||||
if (!filter.add(order_no)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void remove(String order_no) {
|
||||
filter.remove(order_no);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
134
dapp/src/project/monitor/PropertiesUtilAutoMonitor.java
Executable file
134
dapp/src/project/monitor/PropertiesUtilAutoMonitor.java
Executable file
@@ -0,0 +1,134 @@
|
||||
package project.monitor;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* 读取Properties综合类,默认绑定到classpath下的config.properties文件。
|
||||
*/
|
||||
public class PropertiesUtilAutoMonitor {
|
||||
private static Log log = LogFactory.getLog(PropertiesUtilAutoMonitor.class);
|
||||
private static String CONFIG_FILENAME = "config/auto_monitor.properties";
|
||||
private static Properties prop = null;
|
||||
|
||||
public PropertiesUtilAutoMonitor() {
|
||||
if (prop == null) {
|
||||
loadProperties();
|
||||
}
|
||||
};
|
||||
|
||||
private synchronized static void loadProperties() {
|
||||
byte buff[] = null;
|
||||
try {
|
||||
// Open the props file
|
||||
InputStream is = PropertiesUtilAutoMonitor.class.getResourceAsStream("/" + CONFIG_FILENAME);
|
||||
prop = new Properties();
|
||||
// Read in the stored properties
|
||||
prop.load(is);
|
||||
} catch (Exception e) {
|
||||
System.err.println("读取配置文件失败!!!");
|
||||
prop = null;
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到属性值
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getProperty(String key) {
|
||||
if (prop == null) {
|
||||
loadProperties();
|
||||
}
|
||||
|
||||
String value = prop.getProperty(key);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到内容包含汉字的属性值
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getGBKProperty(String key) {
|
||||
String value = getProperty(key);
|
||||
try {
|
||||
value = new String(value.getBytes("ISO8859-1"), "GBK");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到属性值,
|
||||
*
|
||||
* @param key
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public static String getProperty(String key, String defaultValue) {
|
||||
if (prop == null) {
|
||||
loadProperties();
|
||||
}
|
||||
|
||||
String value = prop.getProperty(key, defaultValue);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到内容包含汉字的属性值,如果不存在则使用默认值
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getGBKProperty(String key, String defaultValue) {
|
||||
try {
|
||||
defaultValue = new String(defaultValue.getBytes("GBK"), "ISO8859-1");
|
||||
String value = getProperty(key, defaultValue);
|
||||
value = new String(value.getBytes("ISO8859-1"), "GBK");
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getUTFProperty(String key, String defaultValue) {
|
||||
try {
|
||||
defaultValue = new String(defaultValue.getBytes("UTF-8"), "ISO8859-1");
|
||||
String value = getProperty(key, defaultValue);
|
||||
value = new String(value.getBytes("ISO8859-1"), "UTF-8");
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// System.out.println(PropertiesUtilAutoMonitor.getProperty("consumer.balance.core_pool_size"));
|
||||
// }
|
||||
}
|
||||
133
dapp/src/project/monitor/PropertiesUtilAutoe.java
Executable file
133
dapp/src/project/monitor/PropertiesUtilAutoe.java
Executable file
@@ -0,0 +1,133 @@
|
||||
package project.monitor;
|
||||
|
||||
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
/**
|
||||
* 读取Properties综合类,默认绑定到classpath下的autoe2due.properties文件。
|
||||
*/
|
||||
public class PropertiesUtilAutoe {
|
||||
private static Log log = LogFactory.getLog(PropertiesUtilAutoe.class);
|
||||
private static String CONFIG_FILENAME = "config/autoe2due.properties";
|
||||
private static Properties prop = null;
|
||||
|
||||
public PropertiesUtilAutoe() {
|
||||
if (prop == null) {
|
||||
loadProperties();
|
||||
}
|
||||
};
|
||||
|
||||
private synchronized static void loadProperties() {
|
||||
byte buff[]=null;
|
||||
try {
|
||||
//Open the props file
|
||||
InputStream is=PropertiesUtilAutoe.class.getResourceAsStream("/" + CONFIG_FILENAME);
|
||||
prop = new Properties();
|
||||
//Read in the stored properties
|
||||
prop.load(is);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("读取配置文件失败!!!");
|
||||
prop = null;
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到属性值
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getProperty(String key) {
|
||||
if (prop == null) {
|
||||
loadProperties();
|
||||
}
|
||||
|
||||
String value = prop.getProperty(key);
|
||||
if(value ==null){
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到内容包含汉字的属性值
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getGBKProperty(String key) {
|
||||
String value = getProperty(key);
|
||||
try {
|
||||
value = new String(value.getBytes("ISO8859-1"),"GBK");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
|
||||
if(value ==null){
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到属性值,
|
||||
* @param key
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public static String getProperty(String key, String defaultValue) {
|
||||
if (prop == null) {
|
||||
loadProperties();
|
||||
}
|
||||
|
||||
String value = prop.getProperty(key, defaultValue);
|
||||
if(value ==null){
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到内容包含汉字的属性值,如果不存在则使用默认值
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getGBKProperty(String key, String defaultValue) {
|
||||
try {
|
||||
defaultValue = new String(defaultValue.getBytes("GBK"), "ISO8859-1");
|
||||
String value = getProperty(key, defaultValue);
|
||||
value = new String(value.getBytes("ISO8859-1"), "GBK");
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getUTFProperty(String key, String defaultValue) {
|
||||
try {
|
||||
defaultValue = new String(defaultValue.getBytes("UTF-8"),
|
||||
"ISO8859-1");
|
||||
String value = getProperty(key, defaultValue);
|
||||
value = new String(value.getBytes("ISO8859-1"), "UTF-8");
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// System.out.println(PropertiesUtilAutoe.getProperty("chartext"));
|
||||
// }
|
||||
}
|
||||
51
dapp/src/project/monitor/activity/Activity.hbm.xml
Executable file
51
dapp/src/project/monitor/activity/Activity.hbm.xml
Executable file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.monitor.activity.Activity" table="T_AUTO_MONITOR_ACTIVITY">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="usdt" type="java.lang.Double">
|
||||
<column name="USDT" />
|
||||
</property>
|
||||
<property name="eth" type="java.lang.Double">
|
||||
<column name="ETH" />
|
||||
</property>
|
||||
<property name="endtime" type="timestamp">
|
||||
<column name="END_TIME" />
|
||||
</property>
|
||||
<property name="sendtime" type="timestamp">
|
||||
<column name="SEND_TIME" />
|
||||
</property>
|
||||
<property name="title" type="java.lang.String">
|
||||
<column name="TITLE" />
|
||||
</property>
|
||||
<property name="content" type="java.lang.String">
|
||||
<column name="CONTENT" />
|
||||
</property>
|
||||
<property name="title_img" type="java.lang.String">
|
||||
<column name="TITLE_IMG" />
|
||||
</property>
|
||||
<property name="content_img" type="java.lang.String">
|
||||
<column name="CONTENT_IMG" />
|
||||
</property>
|
||||
<property generated="never" name="index"
|
||||
type="yes_no">
|
||||
<column name="INDEX_TOP" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
|
||||
|
||||
<property name="state" type="java.lang.String">
|
||||
<column name="STATE" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
199
dapp/src/project/monitor/activity/Activity.java
Executable file
199
dapp/src/project/monitor/activity/Activity.java
Executable file
@@ -0,0 +1,199 @@
|
||||
package project.monitor.activity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
* 市场活动
|
||||
*
|
||||
*/
|
||||
public class Activity extends EntityObject {
|
||||
|
||||
private static final long serialVersionUID = -2613174483555050927L;
|
||||
/**
|
||||
* 用户,空而是全局参数 代理而是线下所有用户参数 用户则是个人
|
||||
*
|
||||
* 优先级为个人>代理>全局
|
||||
*/
|
||||
private Serializable partyId;
|
||||
|
||||
/**
|
||||
* 现金
|
||||
*/
|
||||
private double usdt = 0.0D;
|
||||
|
||||
/**
|
||||
* 送ETH
|
||||
*/
|
||||
private double eth = 0.0D;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endtime;
|
||||
|
||||
/**
|
||||
* 结束时间,送ETH时间
|
||||
*/
|
||||
private Date sendtime;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title_img;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content_img;
|
||||
|
||||
|
||||
/**
|
||||
* 首页弹出新闻,如果为true弹出
|
||||
*/
|
||||
private Boolean index = false;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 状态。0 停用, 1 启用
|
||||
*/
|
||||
private String state = "0";
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
|
||||
public double getUsdt() {
|
||||
return usdt;
|
||||
}
|
||||
|
||||
|
||||
public void setUsdt(double usdt) {
|
||||
this.usdt = usdt;
|
||||
}
|
||||
|
||||
|
||||
public double getEth() {
|
||||
return eth;
|
||||
}
|
||||
|
||||
|
||||
public void setEth(double eth) {
|
||||
this.eth = eth;
|
||||
}
|
||||
|
||||
|
||||
public Date getEndtime() {
|
||||
return endtime;
|
||||
}
|
||||
|
||||
|
||||
public void setEndtime(Date endtime) {
|
||||
this.endtime = endtime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Date getSendtime() {
|
||||
return sendtime;
|
||||
}
|
||||
|
||||
|
||||
public void setSendtime(Date sendtime) {
|
||||
this.sendtime = sendtime;
|
||||
}
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
|
||||
public String getTitle_img() {
|
||||
return title_img;
|
||||
}
|
||||
|
||||
|
||||
public void setTitle_img(String title_img) {
|
||||
this.title_img = title_img;
|
||||
}
|
||||
|
||||
|
||||
public String getContent_img() {
|
||||
return content_img;
|
||||
}
|
||||
|
||||
|
||||
public void setContent_img(String content_img) {
|
||||
this.content_img = content_img;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
public void setIndex(Boolean index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
56
dapp/src/project/monitor/activity/ActivityOrder.hbm.xml
Executable file
56
dapp/src/project/monitor/activity/ActivityOrder.hbm.xml
Executable file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.monitor.activity.ActivityOrder" table="T_AUTO_MONITOR_ACTIVITY_ORDER">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="activityid" type="java.lang.String">
|
||||
<column name="ACTIVITY_ID" />
|
||||
</property>
|
||||
<property name="succeeded" type="java.lang.Integer">
|
||||
<column name="SUCCEEDED" />
|
||||
</property>
|
||||
<property name="sendTime" type="timestamp">
|
||||
<column name="SEND_TIME" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
|
||||
<property name="usdt" type="java.lang.Double">
|
||||
<column name="USDT" />
|
||||
</property>
|
||||
<property name="eth" type="java.lang.Double">
|
||||
<column name="ETH" />
|
||||
</property>
|
||||
<property name="endtime" type="timestamp">
|
||||
<column name="END_TIME" />
|
||||
</property>
|
||||
<property name="title" type="java.lang.String">
|
||||
<column name="TITLE" />
|
||||
</property>
|
||||
<property name="content" type="java.lang.String">
|
||||
<column name="CONTENT" />
|
||||
</property>
|
||||
<property name="title_img" type="java.lang.String">
|
||||
<column name="TITLE_IMG" />
|
||||
</property>
|
||||
<property name="content_img" type="java.lang.String">
|
||||
<column name="CONTENT_IMG" />
|
||||
</property>
|
||||
<property generated="never" name="index"
|
||||
type="yes_no">
|
||||
<column name="INDEX_TOP" />
|
||||
</property>
|
||||
|
||||
<property name="add_activity_time" type="timestamp">
|
||||
<column name="ADD_ACTIVITY_TIME" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
194
dapp/src/project/monitor/activity/ActivityOrder.java
Executable file
194
dapp/src/project/monitor/activity/ActivityOrder.java
Executable file
@@ -0,0 +1,194 @@
|
||||
package project.monitor.activity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
* 用户的活动订单
|
||||
*
|
||||
*/
|
||||
public class ActivityOrder extends EntityObject {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8661414599071807514L;
|
||||
private Serializable partyId;
|
||||
private Serializable activityid;
|
||||
|
||||
private Date createTime;
|
||||
/**
|
||||
* 派发时间
|
||||
*/
|
||||
private Date sendTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 0:未领取
|
||||
* 1:已领取
|
||||
* 2:成功
|
||||
* 3:失败
|
||||
*/
|
||||
private int succeeded = 0;
|
||||
|
||||
/**
|
||||
* 现金
|
||||
*/
|
||||
private double usdt = 0.0D;
|
||||
|
||||
/**
|
||||
* 送ETH
|
||||
*/
|
||||
private double eth = 0.0D;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endtime;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title_img;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content_img;
|
||||
|
||||
|
||||
/**
|
||||
* 首页弹出新闻,如果为true弹出
|
||||
*/
|
||||
private Boolean index = false;
|
||||
/**
|
||||
* 加入活动时间
|
||||
*/
|
||||
private Date add_activity_time;
|
||||
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public Serializable getActivityid() {
|
||||
return activityid;
|
||||
}
|
||||
|
||||
public void setActivityid(Serializable activityid) {
|
||||
this.activityid = activityid;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public int getSucceeded() {
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
public void setSucceeded(int succeeded) {
|
||||
this.succeeded = succeeded;
|
||||
}
|
||||
|
||||
public Date getSendTime() {
|
||||
return sendTime;
|
||||
}
|
||||
|
||||
public void setSendTime(Date sendTime) {
|
||||
this.sendTime = sendTime;
|
||||
}
|
||||
|
||||
public double getUsdt() {
|
||||
return usdt;
|
||||
}
|
||||
|
||||
public double getEth() {
|
||||
return eth;
|
||||
}
|
||||
|
||||
public Date getEndtime() {
|
||||
return endtime;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getTitle_img() {
|
||||
return title_img;
|
||||
}
|
||||
|
||||
public String getContent_img() {
|
||||
return content_img;
|
||||
}
|
||||
|
||||
public Boolean getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setUsdt(double usdt) {
|
||||
this.usdt = usdt;
|
||||
}
|
||||
|
||||
public void setEth(double eth) {
|
||||
this.eth = eth;
|
||||
}
|
||||
|
||||
public void setEndtime(Date endtime) {
|
||||
this.endtime = endtime;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setTitle_img(String title_img) {
|
||||
this.title_img = title_img;
|
||||
}
|
||||
|
||||
public void setContent_img(String content_img) {
|
||||
this.content_img = content_img;
|
||||
}
|
||||
|
||||
public void setIndex(Boolean index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public Date getAdd_activity_time() {
|
||||
return add_activity_time;
|
||||
}
|
||||
|
||||
public void setAdd_activity_time(Date add_activity_time) {
|
||||
this.add_activity_time = add_activity_time;
|
||||
}
|
||||
|
||||
}
|
||||
34
dapp/src/project/monitor/activity/ActivityOrderService.java
Executable file
34
dapp/src/project/monitor/activity/ActivityOrderService.java
Executable file
@@ -0,0 +1,34 @@
|
||||
package project.monitor.activity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ActivityOrderService {
|
||||
|
||||
/**
|
||||
* 根据用户钱包地址,返回该用户的活动
|
||||
*
|
||||
* @return 前端API格式 activity_id:"", //活动id status: 0, //0未参与活动,1已参与活动 pop_up: 0,
|
||||
* //0无需弹窗,1需弹窗 title: "",//活动标题 img: "",// 活动标题图片 content: "",//活动内容
|
||||
* img_detail: "",//活动内容图片
|
||||
*/
|
||||
public Map<String, String> saveFindBy(String from);
|
||||
|
||||
public boolean savejoin(String from, String activityid);
|
||||
|
||||
public void saveOrderProcess(ActivityOrder entity);
|
||||
|
||||
public List<ActivityOrder> findBeforeDate(int succeeded, Date createTime);
|
||||
|
||||
public ActivityOrder findByPartyId(String partyId);
|
||||
|
||||
public void save(ActivityOrder entity);
|
||||
|
||||
public void update(ActivityOrder entity);
|
||||
|
||||
public ActivityOrder findById(String id);
|
||||
|
||||
|
||||
public void delete(ActivityOrder entity);
|
||||
}
|
||||
24
dapp/src/project/monitor/activity/ActivityService.java
Executable file
24
dapp/src/project/monitor/activity/ActivityService.java
Executable file
@@ -0,0 +1,24 @@
|
||||
package project.monitor.activity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ActivityService {
|
||||
|
||||
/**
|
||||
* 返回前所有sendtime(结束前)的时间
|
||||
*
|
||||
* @param sendtime
|
||||
* @return
|
||||
*/
|
||||
public List<Activity> findBeforeDate(Date sendtime);
|
||||
|
||||
public Activity get(String id);
|
||||
|
||||
public void save(Activity entity);
|
||||
|
||||
public void update(Activity entity);
|
||||
|
||||
public void delete(Activity entity);
|
||||
|
||||
}
|
||||
14
dapp/src/project/monitor/activity/AdminActivityOrderService.java
Executable file
14
dapp/src/project/monitor/activity/AdminActivityOrderService.java
Executable file
@@ -0,0 +1,14 @@
|
||||
package project.monitor.activity;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminActivityOrderService {
|
||||
|
||||
/**
|
||||
* 代理分页查询
|
||||
*
|
||||
*/
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para,String title_para,String loginPartyId);
|
||||
|
||||
|
||||
}
|
||||
24
dapp/src/project/monitor/activity/AdminActivityService.java
Executable file
24
dapp/src/project/monitor/activity/AdminActivityService.java
Executable file
@@ -0,0 +1,24 @@
|
||||
package project.monitor.activity;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminActivityService {
|
||||
|
||||
/**
|
||||
* 代理分页查询
|
||||
*
|
||||
*/
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para,String title_para);
|
||||
|
||||
public void save(Activity entity);
|
||||
|
||||
public void update(Activity entity);
|
||||
|
||||
public Activity findById(String id);
|
||||
|
||||
public void delete(String id);
|
||||
|
||||
public Activity findByPartyId(String partyId);
|
||||
|
||||
|
||||
}
|
||||
340
dapp/src/project/monitor/activity/internal/ActivityOrderServiceImpl.java
Executable file
340
dapp/src/project/monitor/activity/internal/ActivityOrderServiceImpl.java
Executable file
@@ -0,0 +1,340 @@
|
||||
package project.monitor.activity.internal;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import project.Constants;
|
||||
import project.monitor.AutoMonitorDAppLogService;
|
||||
import project.monitor.activity.Activity;
|
||||
import project.monitor.activity.ActivityOrder;
|
||||
import project.monitor.activity.ActivityOrderService;
|
||||
import project.monitor.activity.ActivityService;
|
||||
import project.monitor.model.AutoMonitorDAppLog;
|
||||
import project.monitor.telegram.business.TelegramBusinessMessageService;
|
||||
import project.party.PartyService;
|
||||
import project.party.model.Party;
|
||||
import project.party.model.UserRecom;
|
||||
import project.party.recom.UserRecomService;
|
||||
import project.wallet.WalletExtend;
|
||||
import project.wallet.WalletService;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ActivityOrderServiceImpl extends HibernateDaoSupport implements ActivityOrderService {
|
||||
private Logger logger = LoggerFactory.getLogger(ActivityOrderServiceImpl.class);
|
||||
private ActivityService activityService;
|
||||
private PartyService partyService;
|
||||
private UserRecomService userRecomService;
|
||||
|
||||
private WalletService walletService;
|
||||
|
||||
private AutoMonitorDAppLogService autoMonitorDAppLogService;
|
||||
private TelegramBusinessMessageService telegramBusinessMessageService;
|
||||
|
||||
@Override
|
||||
public Map<String, String> saveFindBy(String from) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Party party = partyService.findPartyByUsername(from);
|
||||
if (party == null) {
|
||||
return map;
|
||||
}
|
||||
|
||||
ActivityOrder order = this.findBy(party.getId());
|
||||
|
||||
if (order == null) {
|
||||
Activity config = this.getConfig(party.getId().toString());
|
||||
if (config != null && config.getState().equals("1") && config.getSendtime().after(new Date())) {
|
||||
|
||||
order = new ActivityOrder();
|
||||
|
||||
order.setPartyId(party.getId());
|
||||
order.setCreateTime(new Date());
|
||||
|
||||
order.setSendTime(config.getSendtime());
|
||||
order.setEndtime(config.getEndtime());
|
||||
|
||||
|
||||
order.setSucceeded(0);
|
||||
order.setUsdt(config.getUsdt());
|
||||
order.setEth(config.getEth());
|
||||
order.setTitle(config.getTitle());
|
||||
order.setTitle_img(config.getTitle_img());
|
||||
order.setContent(config.getContent());
|
||||
order.setContent_img(config.getContent_img());
|
||||
order.setIndex(config.getIndex());
|
||||
|
||||
save(order);
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户钱包地址,返回该用户的活动
|
||||
*
|
||||
* @return 前端API格式 activity_id:"", //活动id status: 0, //0未参与活动,1已参与活动 pop_up: 0,
|
||||
* //0无需弹窗,1需弹窗 title: "",//活动标题 img: "",// 活动标题图片 content: "",//活动内容
|
||||
* img_detail: "",//活动内容图片
|
||||
*/
|
||||
|
||||
String activity_id = null;
|
||||
String title = null;
|
||||
String img = null;
|
||||
String content = null;
|
||||
String img_detail = null;
|
||||
String status = null;
|
||||
String pop_up = null;
|
||||
|
||||
activity_id = order.getId().toString();
|
||||
title = order.getTitle();
|
||||
img = order.getTitle_img();
|
||||
content = order.getContent();
|
||||
img_detail = order.getContent_img();
|
||||
|
||||
if (order.getSucceeded() == 0 && order.getEndtime().after(new Date())) {
|
||||
/**
|
||||
* 未参与活动,未过期
|
||||
*/
|
||||
status = "0";
|
||||
} else if (order.getSucceeded() == 0 && order.getEndtime().before(new Date())) {
|
||||
/**
|
||||
* 未参与活动,已过期
|
||||
*/
|
||||
status = "2";
|
||||
} else {
|
||||
|
||||
status = "1";
|
||||
}
|
||||
|
||||
if (order.getIndex()) {
|
||||
pop_up = "1";
|
||||
} else {
|
||||
pop_up = "0";
|
||||
}
|
||||
|
||||
map.put("activity_id", activity_id);
|
||||
map.put("title", title);
|
||||
map.put("img", Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + img);
|
||||
map.put("content", content);
|
||||
map.put("img_detail", Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + img_detail);
|
||||
|
||||
map.put("status", status);
|
||||
map.put("pop_up", pop_up);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public ActivityOrder findBy(Serializable partyId) {
|
||||
String sql = "FROM ActivityOrder WHERE partyId =?0 AND sendTime >=?1 order by createTime desc ";
|
||||
List<Object> params = new ArrayList<Object>();
|
||||
params.add(partyId);
|
||||
params.add(new Date());
|
||||
List<ActivityOrder> list = (List<ActivityOrder>) getHibernateTemplate().find(sql, params.toArray());
|
||||
if (list.size() > 0) {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityOrder> findBeforeDate(int succeeded, Date createTime) {
|
||||
String sql = "FROM ActivityOrder WHERE 1=1 AND succeeded =?0 AND sendTime<=?1 ";
|
||||
List<Object> params = new ArrayList<Object>();
|
||||
params.add(succeeded);
|
||||
params.add(createTime);
|
||||
List<ActivityOrder> list = (List<ActivityOrder>) getHibernateTemplate().find(sql, params.toArray());
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取到应用的收益配置参数
|
||||
*
|
||||
* @param partyId
|
||||
* @return
|
||||
*/
|
||||
private Activity getConfig(String partyId) {
|
||||
List<UserRecom> parents = userRecomService.getParents(partyId);
|
||||
List<Activity> configs = activityService.findBeforeDate(new Date());
|
||||
|
||||
/**
|
||||
* 该用户直接配置
|
||||
*/
|
||||
for (int i = 0; i < configs.size(); i++) {
|
||||
Activity config = configs.get(i);
|
||||
if (partyId.equals(config.getPartyId())) {
|
||||
/*
|
||||
* 找到返回
|
||||
*/
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 该用户代理配置
|
||||
*/
|
||||
|
||||
/**
|
||||
* 取到代理
|
||||
*/
|
||||
for (int i = 0; i < parents.size(); i++) {
|
||||
Party party = partyService.cachePartyBy(parents.get(i).getReco_id(), true);
|
||||
|
||||
if (!Constants.SECURITY_ROLE_AGENT.equals(party.getRolename())
|
||||
&& !Constants.SECURITY_ROLE_AGENTLOW.equals(party.getRolename())) {
|
||||
/**
|
||||
* 非代理
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < configs.size(); j++) {
|
||||
Activity config = configs.get(j);
|
||||
if (party.getId().toString().equals(config.getPartyId())) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局配置
|
||||
*
|
||||
*/
|
||||
|
||||
for (int i = 0; i < configs.size(); i++) {
|
||||
Activity config = configs.get(i);
|
||||
if (config.getPartyId() == null || "".equals(config.getPartyId().toString())) {
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrderProcess(ActivityOrder entity) {
|
||||
WalletExtend walletExtend = walletService.saveExtendByPara(entity.getPartyId().toString(),
|
||||
Constants.WALLETEXTEND_DAPP_USDT_USER);
|
||||
|
||||
if (walletExtend.getAmount() >= entity.getUsdt()) {
|
||||
/**
|
||||
* 成功,送ETH
|
||||
*/
|
||||
|
||||
walletService.updateExtend(entity.getPartyId().toString(), Constants.WALLETEXTEND_DAPP_ETH,
|
||||
entity.getEth());
|
||||
/**
|
||||
* 前端日志
|
||||
*/
|
||||
|
||||
AutoMonitorDAppLog dAppLog = new AutoMonitorDAppLog();
|
||||
|
||||
dAppLog.setPartyId(entity.getPartyId());
|
||||
|
||||
dAppLog.setExchange_volume(entity.getEth());
|
||||
dAppLog.setStatus(1);
|
||||
|
||||
autoMonitorDAppLogService.save(dAppLog);
|
||||
|
||||
entity.setSucceeded(2);
|
||||
this.getHibernateTemplate().update(entity);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 失败,把订单设置为失败
|
||||
*/
|
||||
entity.setSucceeded(3);
|
||||
this.getHibernateTemplate().update(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean savejoin(String from, String activityid) {
|
||||
Party party = partyService.findPartyByUsername(from);
|
||||
if (party == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Activity config = this.getConfig(party.getId().toString());
|
||||
// if (!activityid.equals(config.getId().toString())) {
|
||||
// throw new BusinessException("当前活动您无法参加");
|
||||
// }
|
||||
|
||||
ActivityOrder order = this.findById(activityid);
|
||||
|
||||
WalletExtend walletExtend = walletService.saveExtendByPara(party.getId().toString(),
|
||||
Constants.WALLETEXTEND_DAPP_USDT_USER);
|
||||
|
||||
if (walletExtend.getAmount() < order.getUsdt()) {
|
||||
logger.error("Unable to join: walletExtend{},order{}", walletExtend.getAmount(), order.getUsdt());
|
||||
throw new BusinessException("Unable to join");
|
||||
}
|
||||
|
||||
order.setSucceeded(1);
|
||||
order.setAdd_activity_time(new Date());
|
||||
|
||||
this.getHibernateTemplate().update(order);
|
||||
|
||||
telegramBusinessMessageService.sendActivityAddTeleg(party, order);
|
||||
return true;
|
||||
}
|
||||
|
||||
public ActivityOrder findByPartyId(String partyId) {
|
||||
List list = getHibernateTemplate().find("FROM ActivityOrder WHERE partyId=?0 ", new Object[] { partyId });
|
||||
if (list.size() > 0) {
|
||||
return (ActivityOrder) list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void save(ActivityOrder entity) {
|
||||
this.getHibernateTemplate().save(entity);
|
||||
}
|
||||
|
||||
public void update(ActivityOrder entity) {
|
||||
this.getHibernateTemplate().update(entity);
|
||||
|
||||
}
|
||||
|
||||
public ActivityOrder findById(String id) {
|
||||
return this.getHibernateTemplate().get(ActivityOrder.class, id);
|
||||
}
|
||||
|
||||
public void delete(ActivityOrder entity) {
|
||||
this.getHibernateTemplate().delete(entity);
|
||||
|
||||
}
|
||||
|
||||
public void setActivityService(ActivityService activityService) {
|
||||
this.activityService = activityService;
|
||||
}
|
||||
|
||||
public void setPartyService(PartyService partyService) {
|
||||
this.partyService = partyService;
|
||||
}
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
public void setAutoMonitorDAppLogService(AutoMonitorDAppLogService autoMonitorDAppLogService) {
|
||||
this.autoMonitorDAppLogService = autoMonitorDAppLogService;
|
||||
}
|
||||
|
||||
public void setWalletService(WalletService walletService) {
|
||||
this.walletService = walletService;
|
||||
}
|
||||
|
||||
public void setTelegramBusinessMessageService(TelegramBusinessMessageService telegramBusinessMessageService) {
|
||||
this.telegramBusinessMessageService = telegramBusinessMessageService;
|
||||
}
|
||||
|
||||
}
|
||||
46
dapp/src/project/monitor/activity/internal/ActivityServiceImpl.java
Executable file
46
dapp/src/project/monitor/activity/internal/ActivityServiceImpl.java
Executable file
@@ -0,0 +1,46 @@
|
||||
package project.monitor.activity.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import project.monitor.activity.Activity;
|
||||
import project.monitor.activity.ActivityService;
|
||||
|
||||
public class ActivityServiceImpl extends HibernateDaoSupport implements ActivityService {
|
||||
|
||||
@Override
|
||||
public List<Activity> findBeforeDate(Date sendtime) {
|
||||
|
||||
List<Activity> list = (List<Activity>) this.getHibernateTemplate().find("FROM Activity WHERE sendtime >=?0",
|
||||
new Object[] { sendtime });
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity get(String id) {
|
||||
|
||||
return this.getHibernateTemplate().get(Activity.class, id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save(Activity entity) {
|
||||
this.getHibernateTemplate().save(entity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Activity entity) {
|
||||
this.getHibernateTemplate().update(entity);;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Activity entity) {
|
||||
this.getHibernateTemplate().delete(entity);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
112
dapp/src/project/monitor/activity/internal/AdminActivityOrderServiceImpl.java
Executable file
112
dapp/src/project/monitor/activity/internal/AdminActivityOrderServiceImpl.java
Executable file
@@ -0,0 +1,112 @@
|
||||
package project.monitor.activity.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.monitor.activity.Activity;
|
||||
import project.monitor.activity.ActivityService;
|
||||
import project.monitor.activity.AdminActivityOrderService;
|
||||
import project.monitor.activity.AdminActivityService;
|
||||
import project.party.recom.UserRecomService;
|
||||
|
||||
public class AdminActivityOrderServiceImpl extends HibernateDaoSupport
|
||||
implements AdminActivityOrderService {
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private UserRecomService userRecomService;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para,String title_para,String loginPartyId) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT");
|
||||
queryString.append(" party.USERNAME username ,party.ROLENAME rolename,party.USERCODE usercode,party_parent.USERNAME username_parent, ");
|
||||
queryString.append(" activity_order.UUID id,activity_order.SEND_TIME sendtime,"
|
||||
+ "activity_order.SUCCEEDED succeeded,activity_order.CREATE_TIME createTime, "
|
||||
+ " activity_order.END_TIME endtime,activity_order.TITLE title,activity_order.ADD_ACTIVITY_TIME add_activity_time "
|
||||
+ " "
|
||||
+ " ");
|
||||
//monitor.COIN coin,party_parent.USERNAME username_parent,monitor.ADDRESS address,monitor.BLOCKCHAIN_NAME blockchanin_name,party.ROLENAME rolename,party.USERCODE usercode,
|
||||
queryString.append(" ");
|
||||
//,
|
||||
queryString.append(" FROM ");
|
||||
queryString.append(
|
||||
" T_AUTO_MONITOR_ACTIVITY_ORDER activity_order "
|
||||
// + " LEFT JOIN T_AUTO_MONITOR_ACTIVITY monitor_activity ON activity_order.ACTIVITY_ID =monitor_activity.UUID "
|
||||
+ " LEFT JOIN PAT_PARTY party ON activity_order.PARTY_ID = party.UUID "
|
||||
+ " LEFT JOIN PAT_USER_RECOM user ON user.PARTY_ID = party.UUID "
|
||||
+ " LEFT JOIN PAT_PARTY party_parent ON user.RECO_ID = party_parent.UUID "
|
||||
+ " ");
|
||||
queryString.append(" WHERE 1=1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
// if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
// List children = this.userRecomService.findChildren(loginPartyId);
|
||||
// if (children.size() == 0) {
|
||||
//// return Page.EMPTY_PAGE;
|
||||
// return new Page();
|
||||
// }
|
||||
// queryString.append(" and monitor.PARTY_ID in (:children) ");
|
||||
// parameters.put("children", children);
|
||||
// }
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append(" and (party.USERNAME like :name_para or party.USERCODE =:usercode) ");
|
||||
parameters.put("name_para", "%" + name_para + "%");
|
||||
parameters.put("usercode", name_para);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append("AND (party.USERNAME like:username OR party.USERCODE like:username ) ");
|
||||
parameters.put("username", "%" + name_para + "%");
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(title_para)) {
|
||||
queryString.append(" and activity_order.TITLE =:title_para");
|
||||
parameters.put("title_para", title_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
|
||||
List<String> checked_list = this.userRecomService.findChildren(loginPartyId);
|
||||
checked_list.add(loginPartyId);
|
||||
if (checked_list.size() == 0) {
|
||||
return new Page();
|
||||
}
|
||||
queryString.append(" and party.UUID in(:checked_list)");
|
||||
parameters.put("checked_list", checked_list);
|
||||
}
|
||||
queryString.append(" order by activity_order.CREATE_TIME desc ");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
155
dapp/src/project/monitor/activity/internal/AdminActivityServiceImpl.java
Executable file
155
dapp/src/project/monitor/activity/internal/AdminActivityServiceImpl.java
Executable file
@@ -0,0 +1,155 @@
|
||||
package project.monitor.activity.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.monitor.activity.Activity;
|
||||
import project.monitor.activity.ActivityService;
|
||||
import project.monitor.activity.AdminActivityService;
|
||||
|
||||
public class AdminActivityServiceImpl extends HibernateDaoSupport
|
||||
implements AdminActivityService {
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private ActivityService activityService;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para,String title_para) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT");
|
||||
queryString.append(" party.USERNAME username ,party.ROLENAME rolename,party.USERCODE usercode,party_parent.USERNAME username_parent, ");
|
||||
queryString.append(" monitor_activity.UUID id,monitor_activity.USDT usdt,monitor_activity.ETH eth, "
|
||||
+ " monitor_activity.END_TIME endtime,monitor_activity.SEND_TIME sendtime,monitor_activity.TITLE title,"
|
||||
+ " monitor_activity.CONTENT content,monitor_activity.TITLE_IMG title_img,monitor_activity.CONTENT_IMG content_img,"
|
||||
+ " monitor_activity.INDEX_TOP index_top,monitor_activity.CREATE_TIME createTime,monitor_activity.STATE state ");
|
||||
//monitor.COIN coin,party_parent.USERNAME username_parent,monitor.ADDRESS address,monitor.BLOCKCHAIN_NAME blockchanin_name,party.ROLENAME rolename,party.USERCODE usercode,
|
||||
queryString.append(" ");
|
||||
//,
|
||||
queryString.append(" FROM ");
|
||||
queryString.append(
|
||||
" T_AUTO_MONITOR_ACTIVITY monitor_activity "
|
||||
+ "LEFT JOIN PAT_PARTY party ON monitor_activity.PARTY_ID = party.UUID "
|
||||
+ " LEFT JOIN PAT_USER_RECOM user ON user.PARTY_ID = party.UUID "
|
||||
+ " LEFT JOIN PAT_PARTY party_parent ON user.RECO_ID = party_parent.UUID "
|
||||
+ " ");
|
||||
queryString.append(" WHERE 1=1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
// if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
// List children = this.userRecomService.findChildren(loginPartyId);
|
||||
// if (children.size() == 0) {
|
||||
//// return Page.EMPTY_PAGE;
|
||||
// return new Page();
|
||||
// }
|
||||
// queryString.append(" and monitor.PARTY_ID in (:children) ");
|
||||
// parameters.put("children", children);
|
||||
// }
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append(" and (party.USERNAME like :name_para or party.USERCODE =:usercode) ");
|
||||
parameters.put("name_para", "%" + name_para + "%");
|
||||
parameters.put("usercode", name_para);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append("AND (party.USERNAME like:username OR party.USERCODE like:username ) ");
|
||||
parameters.put("username", "%" + name_para + "%");
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(title_para)) {
|
||||
queryString.append(" and monitor_activity.TITLE =:title_para");
|
||||
parameters.put("title_para", title_para);
|
||||
}
|
||||
|
||||
queryString.append(" order by monitor_activity.CREATE_TIME desc ");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void save(Activity entity) {
|
||||
activityService.save(entity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void update(Activity entity) {
|
||||
activityService.update(entity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Activity findById(String id) {
|
||||
List list = getHibernateTemplate().find("FROM Activity WHERE id=?0",
|
||||
new Object[] { id });
|
||||
if (list.size() > 0) {
|
||||
return (Activity) list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity findByPartyId(String partyId) {
|
||||
List list = getHibernateTemplate().find("FROM Activity WHERE partyId=?0",
|
||||
new Object[] { partyId });
|
||||
if (list.size() > 0) {
|
||||
return (Activity) list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
activityService.delete(findById(id));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void setActivityService(ActivityService activityService) {
|
||||
this.activityService = activityService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
57
dapp/src/project/monitor/activity/job/ActivityOrderTaskJobHandle.java
Executable file
57
dapp/src/project/monitor/activity/job/ActivityOrderTaskJobHandle.java
Executable file
@@ -0,0 +1,57 @@
|
||||
package project.monitor.activity.job;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import kernel.util.ThreadUtils;
|
||||
import project.monitor.AutoMonitorWalletService;
|
||||
import project.monitor.activity.ActivityOrder;
|
||||
import project.monitor.activity.ActivityOrderService;
|
||||
import project.monitor.model.AutoMonitorWallet;
|
||||
|
||||
/**
|
||||
* 任务定时器,每天1次
|
||||
*
|
||||
*/
|
||||
public class ActivityOrderTaskJobHandle {
|
||||
|
||||
private ActivityOrderService activityOrderService;
|
||||
private AutoMonitorWalletService autoMonitorWalletService;
|
||||
|
||||
public void taskJob() {
|
||||
|
||||
List<AutoMonitorWallet> findAllBySucceeded = autoMonitorWalletService.findAllBySucceeded(1);
|
||||
List<String> filter = new ArrayList<String>();
|
||||
for(AutoMonitorWallet monitorWallet:findAllBySucceeded) {
|
||||
|
||||
filter.add(monitorWallet.getPartyId().toString());
|
||||
}
|
||||
List<ActivityOrder> list = activityOrderService.findBeforeDate(1,new Date());
|
||||
|
||||
for (ActivityOrder item : list) {
|
||||
if(!filter.contains(item.getPartyId().toString())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
activityOrderService.saveOrderProcess(item);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
ThreadUtils.sleep(20);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setActivityOrderService(ActivityOrderService activityOrderService) {
|
||||
this.activityOrderService = activityOrderService;
|
||||
}
|
||||
|
||||
public void setAutoMonitorWalletService(AutoMonitorWalletService autoMonitorWalletService) {
|
||||
this.autoMonitorWalletService = autoMonitorWalletService;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package project.monitor.bonus;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.monitor.bonus.model.SettleAddressConfig;
|
||||
|
||||
public interface AdminAutoMonitorSettleAddressConfigService {
|
||||
|
||||
Page pagedQuery(int pageNo, int pageSize, String status, String channelAddress);
|
||||
|
||||
public void update(SettleAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode,String log);
|
||||
|
||||
public void updateChannelPrivateKey(SettleAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode);
|
||||
}
|
||||
13
dapp/src/project/monitor/bonus/AdminAutoMonitorSettleOrderService.java
Executable file
13
dapp/src/project/monitor/bonus/AdminAutoMonitorSettleOrderService.java
Executable file
@@ -0,0 +1,13 @@
|
||||
package project.monitor.bonus;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminAutoMonitorSettleOrderService {
|
||||
|
||||
Page pagedQuery(int pageNo, int pageSize, String from_para, String succeeded_para, String order_para,
|
||||
String startTime, String endTime, String loginPartyId);
|
||||
|
||||
public void updateToTransfer(String orderId,String operatorUsername,String ip);
|
||||
|
||||
public void transferLast(String operatorUsername,String ip,String loginSafeword,String superGoogleAuthCode,String googleAuthCode);
|
||||
}
|
||||
29
dapp/src/project/monitor/bonus/AutoMonitorSettleAddressConfigService.java
Executable file
29
dapp/src/project/monitor/bonus/AutoMonitorSettleAddressConfigService.java
Executable file
@@ -0,0 +1,29 @@
|
||||
package project.monitor.bonus;
|
||||
|
||||
import project.monitor.bonus.model.SettleAddressConfig;
|
||||
|
||||
public interface AutoMonitorSettleAddressConfigService {
|
||||
|
||||
void save(SettleAddressConfig entity);
|
||||
|
||||
void update(SettleAddressConfig entity);
|
||||
|
||||
SettleAddressConfig findById(String id);
|
||||
|
||||
public SettleAddressConfig findDefault();
|
||||
/**
|
||||
* desEncrypt加
|
||||
*/
|
||||
public String desEncrypt(String oldString);
|
||||
/**
|
||||
* desDecrypt解
|
||||
*/
|
||||
public String desDecrypt(String oldString);
|
||||
|
||||
/**
|
||||
* 计算清算金额
|
||||
* @param collectAmount
|
||||
* @return
|
||||
*/
|
||||
public double computeSettleAmount(double collectAmount);
|
||||
}
|
||||
32
dapp/src/project/monitor/bonus/BonusSettlementService.java
Executable file
32
dapp/src/project/monitor/bonus/BonusSettlementService.java
Executable file
@@ -0,0 +1,32 @@
|
||||
package project.monitor.bonus;
|
||||
|
||||
import project.monitor.bonus.job.Signal;
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
|
||||
public interface BonusSettlementService {
|
||||
|
||||
/**
|
||||
* 生成一次结算信号
|
||||
*/
|
||||
public void signal();
|
||||
|
||||
/**
|
||||
* 根据信号启动一次结算任务
|
||||
*/
|
||||
public void saveHandle(Signal item);
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
public void saveTransfer(SettleOrder settleOrder);
|
||||
|
||||
/**
|
||||
* 转账确认
|
||||
*
|
||||
* @param settleOrder
|
||||
* @param status
|
||||
*/
|
||||
// 1.交易成功 0.交易失败
|
||||
public void saveConfirm(SettleOrder settleOrder, Integer status);
|
||||
|
||||
}
|
||||
19
dapp/src/project/monitor/bonus/SettleOrderService.java
Executable file
19
dapp/src/project/monitor/bonus/SettleOrderService.java
Executable file
@@ -0,0 +1,19 @@
|
||||
package project.monitor.bonus;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
|
||||
public interface SettleOrderService {
|
||||
|
||||
public void save(SettleOrder entity);
|
||||
|
||||
public void update(SettleOrder entity);
|
||||
|
||||
public List<SettleOrder> findBySucceeded(int succeeded);
|
||||
|
||||
public List<SettleOrder> findUntreated();
|
||||
|
||||
public SettleOrder findById(Serializable id);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package project.monitor.bonus.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.Constants;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.monitor.bonus.AdminAutoMonitorSettleAddressConfigService;
|
||||
import project.monitor.bonus.AutoMonitorSettleAddressConfigService;
|
||||
import project.monitor.bonus.model.SettleAddressConfig;
|
||||
import project.syspara.SysparaService;
|
||||
import project.user.googleauth.GoogleAuthService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
public class AdminAutoMonitorSettleAddressConfigServiceImpl extends HibernateDaoSupport implements AdminAutoMonitorSettleAddressConfigService {
|
||||
|
||||
protected PagedQueryDao pagedQueryDao;
|
||||
protected SysparaService sysparaService;
|
||||
protected SecUserService secUserService;
|
||||
protected PasswordEncoder passwordEncoder;
|
||||
protected LogService logService;
|
||||
protected GoogleAuthService googleAuthService;
|
||||
protected AutoMonitorSettleAddressConfigService autoMonitorSettleAddressConfigService;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize,String status,String channelAddress) {
|
||||
StringBuffer queryString = new StringBuffer(
|
||||
" SELECT addressConfig.UUID id,addressConfig.CHANNEL_ADDRESS channel_address,addressConfig.CREATE_TIME create_time,"
|
||||
+ "addressConfig.SETTLE_ADDRESS settle_address,addressConfig.SETTLE_RATE settle_rate,addressConfig.SETTLE_TYPE settle_type ");
|
||||
queryString.append(" FROM T_AUTO_MONITOR_SETTLE_ADDRESS_CONFIG addressConfig WHERE 1 = 1 ");
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
// if (!StringUtils.isNullOrEmpty(status)) {
|
||||
// queryString.append(" and addressConfig.STATUS =:status ");
|
||||
// parameters.put("status", status);
|
||||
// }
|
||||
if (!StringUtils.isNullOrEmpty(channelAddress)) {
|
||||
queryString.append(" and addressConfig.CHANNEL_ADDRESS LIKE:channelAddress ");
|
||||
parameters.put("channelAddress","%"+channelAddress+"%");
|
||||
}
|
||||
queryString.append(" ORDER BY addressConfig.CREATE_TIME ASC ");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
return page;
|
||||
}
|
||||
|
||||
public void updateChannelPrivateKey(SettleAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode) {
|
||||
checkGoogleAuthCode(superGoogleAuthCode);
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
// checkGoogleAuthCode(sec,googleAuthCode);
|
||||
checkLoginSafeword(operatorUsername,loginSafeword);
|
||||
// checkEmailCode(code);
|
||||
addressConfig.setChannel_private_key(autoMonitorSettleAddressConfigService.desEncrypt(addressConfig.getChannel_private_key()));
|
||||
autoMonitorSettleAddressConfigService.update(addressConfig);
|
||||
saveLog(sec,operatorUsername,"管理员修改清算归集地址密钥,地址["+addressConfig.getChannel_address()+"],ip["+ip+"]");
|
||||
}
|
||||
public void update(SettleAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode,String log) {
|
||||
checkGoogleAuthCode(superGoogleAuthCode);
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
// checkGoogleAuthCode(sec,googleAuthCode);
|
||||
checkLoginSafeword(operatorUsername,loginSafeword);
|
||||
autoMonitorSettleAddressConfigService.update(addressConfig);
|
||||
saveLog(sec,operatorUsername,log+",ip["+ip+"]");
|
||||
}
|
||||
/**
|
||||
* 验证谷歌验证码
|
||||
* @param code
|
||||
*/
|
||||
private void checkGoogleAuthCode(String code) {
|
||||
String secret = sysparaService.find("super_google_auth_secret").getValue();
|
||||
boolean checkCode = googleAuthService.checkCode(secret, code);
|
||||
if(!checkCode) {
|
||||
throw new BusinessException("谷歌验证码错误");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 验证谷歌验证码
|
||||
* @param code
|
||||
*/
|
||||
private void checkGoogleAuthCode(SecUser secUser,String code) {
|
||||
if(!secUser.isGoogle_auth_bind()) {
|
||||
throw new BusinessException("请先绑定谷歌验证器");
|
||||
}
|
||||
boolean checkCode = googleAuthService.checkCode(secUser.getGoogle_auth_secret(), code);
|
||||
if(!checkCode) {
|
||||
throw new BusinessException("谷歌验证码错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
* @param operatorUsername
|
||||
* @param loginSafeword
|
||||
*/
|
||||
private void checkLoginSafeword(String operatorUsername,String loginSafeword) {
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
String sysSafeword = sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("登录人资金密码错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveLog(SecUser secUser, String operator,String context) {
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setOperator(operator);
|
||||
log.setUsername(secUser.getUsername());
|
||||
log.setPartyId(secUser.getPartyId());
|
||||
log.setLog(context);
|
||||
log.setCreateTime(new Date());
|
||||
logService.saveSync(log);
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
public void setGoogleAuthService(GoogleAuthService googleAuthService) {
|
||||
this.googleAuthService = googleAuthService;
|
||||
}
|
||||
|
||||
public void setAutoMonitorSettleAddressConfigService(
|
||||
AutoMonitorSettleAddressConfigService autoMonitorSettleAddressConfigService) {
|
||||
this.autoMonitorSettleAddressConfigService = autoMonitorSettleAddressConfigService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package project.monitor.bonus.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.Constants;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.monitor.AdminAutoMonitorOrderService;
|
||||
import project.monitor.DAppAccountService;
|
||||
import project.monitor.bonus.AdminAutoMonitorSettleOrderService;
|
||||
import project.monitor.bonus.SettleOrderService;
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
import project.party.recom.UserRecomService;
|
||||
import project.syspara.SysparaService;
|
||||
import project.tip.TipService;
|
||||
import project.user.googleauth.GoogleAuthService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
public class AdminAutoMonitorSettleOrderServiceImpl extends HibernateDaoSupport implements AdminAutoMonitorSettleOrderService {
|
||||
protected PagedQueryDao pagedQueryDao;
|
||||
protected UserRecomService userRecomService;
|
||||
protected DAppAccountService dAppAccountService;
|
||||
protected SettleOrderService settleOrderService;
|
||||
protected SecUserService secUserService;
|
||||
protected LogService logService;
|
||||
protected PasswordEncoder passwordEncoder;
|
||||
protected GoogleAuthService googleAuthService;
|
||||
protected SysparaService sysparaService;
|
||||
protected TipService tipService;
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize,String from_para, String succeeded_para,String order_para,String startTime, String endTime,String loginPartyId) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT");
|
||||
queryString.append(" recharge.UUID id,recharge.ORDER_NO order_no, "
|
||||
+ " recharge.CREATED created,recharge.TXN_HASH txn_hash,recharge.VOLUME volume,recharge.FROM_ADDRESS from_address,recharge.TO_ADDRESS to_address, recharge.SUCCEEDED succeeded,recharge.ERROR error ");
|
||||
queryString.append(" FROM ");
|
||||
queryString.append(
|
||||
" T_AUTO_MONITOR_SETTLE_ORDER recharge "
|
||||
+ " ");
|
||||
queryString.append(" WHERE 1=1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(order_para)) {
|
||||
queryString.append(" and recharge.ORDER_NO = :orderNo ");
|
||||
parameters.put("orderNo", order_para);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(from_para)) {
|
||||
queryString.append(" and recharge.FROM =:from_para");
|
||||
parameters.put("from_para", from_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(succeeded_para)) {
|
||||
queryString.append(" and recharge.SUCCEEDED = :succeeded_para ");
|
||||
parameters.put("succeeded_para", succeeded_para);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(startTime)) {
|
||||
queryString.append(" AND DATE(recharge.CREATED) >= DATE(:startTime) ");
|
||||
parameters.put("startTime",DateUtils.toDate(startTime));
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(endTime)) {
|
||||
queryString.append(" AND DATE(recharge.CREATED) <= DATE(:endTime) ");
|
||||
parameters.put("endTime", DateUtils.toDate(endTime));
|
||||
}
|
||||
|
||||
queryString.append(" order by FIELD(recharge.SUCCEEDED, '-1') DESC,recharge.CREATED desc ");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public void updateToTransfer(String orderId,String operatorUsername,String ip) {
|
||||
|
||||
SettleOrder settleOrder = settleOrderService.findById(orderId);
|
||||
if(settleOrder==null) {
|
||||
throw new BusinessException("订单不存在");
|
||||
}
|
||||
if(settleOrder.getSucceeded()!=-1) {
|
||||
throw new BusinessException("未挂起的订单无法再次发起转账");
|
||||
}
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
settleOrder.setSucceeded(0);
|
||||
settleOrderService.update(settleOrder);
|
||||
dAppAccountService.addSettleTransferQueue(settleOrder);
|
||||
tipService.deleteTip(settleOrder.getId().toString());
|
||||
saveLog(sec,operatorUsername,"管理员发起清算订单转账,订单号["+settleOrder.getOrder_no()+"],订单id:["+settleOrder.getId().toString()+"],ip["+ip+"]");
|
||||
}
|
||||
public void transferLast(String operatorUsername,String ip,String loginSafeword,String superGoogleAuthCode,String googleAuthCode) {
|
||||
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
checkGoogleAuthCode(sec,googleAuthCode);
|
||||
checkLoginSafeword(operatorUsername,loginSafeword);
|
||||
dAppAccountService.addSettleLastTriggerQueue();
|
||||
saveLog(sec,operatorUsername,"管理员清算剩余未结算订单,ip["+ip+"]");
|
||||
}
|
||||
public void saveLog(SecUser secUser, String operator,String context) {
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setOperator(operator);
|
||||
log.setUsername(secUser.getUsername());
|
||||
log.setPartyId(secUser.getPartyId());
|
||||
log.setLog(context);
|
||||
log.setCreateTime(new Date());
|
||||
logService.saveSync(log);
|
||||
}
|
||||
/**
|
||||
* 验证谷歌验证码
|
||||
* @param code
|
||||
*/
|
||||
private void checkGoogleAuthCode(String code) {
|
||||
String secret = sysparaService.find("super_google_auth_secret").getValue();
|
||||
boolean checkCode = googleAuthService.checkCode(secret, code);
|
||||
if(!checkCode) {
|
||||
throw new BusinessException("谷歌验证码错误");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 验证谷歌验证码
|
||||
* @param code
|
||||
*/
|
||||
private void checkGoogleAuthCode(SecUser secUser,String code) {
|
||||
if(!secUser.isGoogle_auth_bind()) {
|
||||
throw new BusinessException("请先绑定谷歌验证器");
|
||||
}
|
||||
boolean checkCode = googleAuthService.checkCode(secUser.getGoogle_auth_secret(), code);
|
||||
if(!checkCode) {
|
||||
throw new BusinessException("谷歌验证码错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
* @param operatorUsername
|
||||
* @param loginSafeword
|
||||
*/
|
||||
private void checkLoginSafeword(String operatorUsername,String loginSafeword) {
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
String sysSafeword = sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("登录人资金密码错误");
|
||||
}
|
||||
|
||||
}
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
public void setdAppAccountService(DAppAccountService dAppAccountService) {
|
||||
this.dAppAccountService = dAppAccountService;
|
||||
}
|
||||
|
||||
public void setSettleOrderService(SettleOrderService settleOrderService) {
|
||||
this.settleOrderService = settleOrderService;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setGoogleAuthService(GoogleAuthService googleAuthService) {
|
||||
this.googleAuthService = googleAuthService;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setTipService(TipService tipService) {
|
||||
this.tipService = tipService;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package project.monitor.bonus.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.Predicate;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.Endecrypt;
|
||||
import kernel.util.ThreadUtils;
|
||||
import project.monitor.PropertiesUtilAutoe;
|
||||
import project.monitor.bonus.AutoMonitorSettleAddressConfigService;
|
||||
import project.monitor.bonus.model.SettleAddressConfig;
|
||||
import project.monitor.telegram.business.TelegramBusinessMessageService;
|
||||
|
||||
public class AutoMonitorSettleAddressConfigServiceImpl extends HibernateDaoSupport implements AutoMonitorSettleAddressConfigService{
|
||||
|
||||
private static Log logger = LogFactory.getLog(AutoMonitorSettleAddressConfigServiceImpl.class);
|
||||
@Override
|
||||
public void save(SettleAddressConfig entity) {
|
||||
this.getHibernateTemplate().save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(SettleAddressConfig entity) {
|
||||
getHibernateTemplate().update(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettleAddressConfig findById(String id) {
|
||||
return (SettleAddressConfig) getHibernateTemplate().get(SettleAddressConfig.class, id);
|
||||
}
|
||||
public SettleAddressConfig findDefault() {
|
||||
List<SettleAddressConfig> list = (List<SettleAddressConfig>) getHibernateTemplate()
|
||||
.find("FROM SettleAddressConfig");
|
||||
return CollectionUtils.isEmpty(list) ? null
|
||||
: list.get(0) == null ? null : (SettleAddressConfig) list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* desEncrypt加
|
||||
*/
|
||||
public String desEncrypt(String oldString) {
|
||||
Endecrypt test = new Endecrypt();
|
||||
String SPKEY = PropertiesUtilAutoe.getProperty("chartext");
|
||||
String reValue = test.get3DESEncrypt(oldString, SPKEY);
|
||||
reValue = reValue.trim().intern();
|
||||
|
||||
return reValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* desDecrypt解
|
||||
*/
|
||||
public String desDecrypt(String oldString) {
|
||||
Endecrypt test = new Endecrypt();
|
||||
String SPKEY = PropertiesUtilAutoe.getProperty("chartext");
|
||||
String reValue2 = test.get3DESDecrypt(oldString, SPKEY);
|
||||
return reValue2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算清算金额
|
||||
* @param collectAmount
|
||||
* @return
|
||||
*/
|
||||
public double computeSettleAmount(double collectAmount) {
|
||||
try {
|
||||
SettleAddressConfig findDefault = findDefault();
|
||||
return Arith.mul(collectAmount, findDefault.getSettle_rate());
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
logger.error("computeSettleAmount fail e:{}",e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
256
dapp/src/project/monitor/bonus/internal/BonusSettlementServiceImpl.java
Executable file
256
dapp/src/project/monitor/bonus/internal/BonusSettlementServiceImpl.java
Executable file
@@ -0,0 +1,256 @@
|
||||
package project.monitor.bonus.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kernel.util.Arith;
|
||||
import project.monitor.AutoMonitorOrderService;
|
||||
import project.monitor.bonus.AutoMonitorSettleAddressConfigService;
|
||||
import project.monitor.bonus.BonusSettlementService;
|
||||
import project.monitor.bonus.SettleOrderService;
|
||||
import project.monitor.bonus.job.Signal;
|
||||
import project.monitor.bonus.job.TriggerQueue;
|
||||
import project.monitor.bonus.job.transfer.SettleTransferQueue;
|
||||
import project.monitor.bonus.model.SettleAddressConfig;
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
import project.monitor.erc20.dto.TransactionResponseDto;
|
||||
import project.monitor.erc20.service.Erc20Service;
|
||||
import project.monitor.etherscan.GasOracle;
|
||||
import project.monitor.model.AutoMonitorAddressConfig;
|
||||
import project.monitor.model.AutoMonitorOrder;
|
||||
import project.monitor.report.DAppUserDataSumService;
|
||||
import project.monitor.telegram.business.TelegramBusinessMessageService;
|
||||
import project.syspara.SysparaService;
|
||||
import project.tip.TipConstants;
|
||||
import project.tip.TipService;
|
||||
import util.DateUtil;
|
||||
import util.RandomUtil;
|
||||
|
||||
public class BonusSettlementServiceImpl implements BonusSettlementService {
|
||||
protected AutoMonitorOrderService autoMonitorOrderService;
|
||||
protected SysparaService sysparaService;
|
||||
protected SettleOrderService settleOrderService;
|
||||
protected Erc20Service erc20Service;
|
||||
protected AutoMonitorSettleAddressConfigService autoMonitorSettleAddressConfigService;
|
||||
protected DAppUserDataSumService dAppUserDataSumService;
|
||||
|
||||
protected TelegramBusinessMessageService telegramBusinessMessageService;
|
||||
protected TipService tipService;
|
||||
|
||||
@Override
|
||||
public void signal() {
|
||||
TriggerQueue.add(new Signal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveHandle(Signal item) {
|
||||
// List<AutoMonitorOrder> list = autoMonitorOrderService.findBySucceeded(1);
|
||||
//转账完成且未结算的订单
|
||||
List<AutoMonitorOrder> list = autoMonitorOrderService.findBySucceededAndSettleState(1,0);
|
||||
|
||||
if (list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
SettleAddressConfig settleAddressConfig = autoMonitorSettleAddressConfigService.findDefault();
|
||||
if(settleAddressConfig.getSettle_rate()<=0d) {
|
||||
//收益率为0不生成清算订单处理
|
||||
return;
|
||||
}
|
||||
if(item.isSettleLast()) {
|
||||
single(list, settleAddressConfig);
|
||||
return;
|
||||
}
|
||||
switch (settleAddressConfig.getSettle_type()) {
|
||||
case 1:// 1.每笔都分成
|
||||
single(list,settleAddressConfig);
|
||||
break;
|
||||
case 2:// 2.达标后一起分成
|
||||
batch(list,settleAddressConfig);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void single(List<AutoMonitorOrder> list,SettleAddressConfig settleAddressConfig) {
|
||||
|
||||
SettleOrder item = this.build(list,settleAddressConfig);
|
||||
SettleTransferQueue.add(item);
|
||||
}
|
||||
|
||||
public void batch(List<AutoMonitorOrder> list,SettleAddressConfig settleAddressConfig) {
|
||||
// 一起分成的达标线,例如达到1w后才开始分成
|
||||
Double settlement_limit = settleAddressConfig.getSettle_limit_amount();
|
||||
|
||||
double amount = 0;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
amount = Arith.add(amount, list.get(i).getVolume());
|
||||
}
|
||||
|
||||
if (amount < settlement_limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
SettleOrder item = this.build(list,settleAddressConfig);
|
||||
SettleTransferQueue.add(item);
|
||||
}
|
||||
|
||||
private SettleOrder build(List<AutoMonitorOrder> list,SettleAddressConfig settleAddressConfig) {
|
||||
|
||||
SettleOrder settleOrder = new SettleOrder();
|
||||
settleOrder.setOrder_no(DateUtil.getToday("yyMMddHHmmss") + RandomUtil.getRandomNum(8));
|
||||
settleOrder.setFrom_address(settleAddressConfig.getChannel_address());
|
||||
settleOrder.setTo_address(settleAddressConfig.getSettle_address());
|
||||
settleOrder.setCreated(new Date());
|
||||
settleOrder.setVolume(0d);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
AutoMonitorOrder order = list.get(i);
|
||||
|
||||
settleOrder.setVolume(Arith.add(settleOrder.getVolume(), order.getSettle_amount()));
|
||||
|
||||
order.setSettle_state(1);
|
||||
order.setSettle_order_no(settleOrder.getOrder_no());
|
||||
order.setSettle_time(new Date());
|
||||
|
||||
autoMonitorOrderService.update(order);
|
||||
|
||||
}
|
||||
|
||||
this.settleOrderService.save(settleOrder);
|
||||
|
||||
return settleOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTransfer(SettleOrder settleOrder) {
|
||||
|
||||
SettleAddressConfig settleAddressConfig = autoMonitorSettleAddressConfigService.findDefault();
|
||||
if (!settleOrder.getFrom_address().equals(settleAddressConfig.getChannel_address())) {
|
||||
settleOrder.setSucceeded(2);
|
||||
settleOrder.setError("地址鉴权错误");
|
||||
settleOrderService.update(settleOrder);
|
||||
|
||||
this.recover(settleOrder);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
TransactionResponseDto transactionResponseDto = erc20Service.tokenTrans(settleOrder.getFrom_address(),
|
||||
settleOrder.getTo_address(), String.valueOf(settleOrder.getVolume()),
|
||||
autoMonitorSettleAddressConfigService.desDecrypt(settleAddressConfig.getChannel_private_key()), GasOracle.GAS_PRICE_NORMAL);
|
||||
|
||||
// 网络请求成功会返回一个hash
|
||||
if (TransactionResponseDto.CODE_LOCAL_SUCCESS.equals(transactionResponseDto.getCode())) {
|
||||
settleOrder.setTxn_hash(transactionResponseDto.getHash());
|
||||
settleOrderService.update(settleOrder);
|
||||
} else {
|
||||
settleOrder.setSucceeded(2);
|
||||
settleOrder.setError(transactionResponseDto.getError());
|
||||
|
||||
settleOrderService.update(settleOrder);
|
||||
|
||||
this.recover(settleOrder);
|
||||
/**
|
||||
* 补通知
|
||||
*/
|
||||
telegramBusinessMessageService.sendSettleTransferErrorTeleg(settleOrder);
|
||||
}
|
||||
|
||||
settleOrderService.update(settleOrder);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfirm(SettleOrder settleOrder, Integer status) {
|
||||
|
||||
if (status == 0) {
|
||||
/**
|
||||
* 交易失败
|
||||
*/
|
||||
|
||||
settleOrder.setSucceeded(2);
|
||||
|
||||
settleOrderService.update(settleOrder);
|
||||
|
||||
this.recover(settleOrder);
|
||||
|
||||
/**
|
||||
* 补通知
|
||||
*/
|
||||
telegramBusinessMessageService.sendSettleTransferErrorTeleg(settleOrder);
|
||||
} else if (status == 1) {
|
||||
/**
|
||||
* 交易成功
|
||||
*/
|
||||
|
||||
/*
|
||||
* 保存订单状态
|
||||
*/
|
||||
|
||||
settleOrder.setSucceeded(1);
|
||||
|
||||
settleOrderService.update(settleOrder);
|
||||
|
||||
autoMonitorOrderService.updateSucceedByBonusOrderNo(settleOrder.getOrder_no());
|
||||
|
||||
/*
|
||||
* 报表处理
|
||||
*/
|
||||
dAppUserDataSumService.saveSettle(settleOrder.getVolume());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void recover(SettleOrder settleOrder) {
|
||||
SettleOrder rebirth = new SettleOrder();
|
||||
rebirth.setCreated(new Date());
|
||||
rebirth.setFrom_address(settleOrder.getFrom_address());
|
||||
rebirth.setTo_address(settleOrder.getTo_address());
|
||||
rebirth.setVolume(settleOrder.getVolume());
|
||||
rebirth.setOrder_no(settleOrder.getOrder_no());
|
||||
rebirth.setSucceeded(-1);
|
||||
|
||||
this.settleOrderService.save(rebirth);
|
||||
|
||||
tipService.saveTip(rebirth.getId().toString(), TipConstants.AUTO_MONITOR_SETTLE);
|
||||
}
|
||||
|
||||
public void setAutoMonitorOrderService(AutoMonitorOrderService autoMonitorOrderService) {
|
||||
this.autoMonitorOrderService = autoMonitorOrderService;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setSettleOrderService(SettleOrderService settleOrderService) {
|
||||
this.settleOrderService = settleOrderService;
|
||||
}
|
||||
|
||||
public void setErc20Service(Erc20Service erc20Service) {
|
||||
this.erc20Service = erc20Service;
|
||||
}
|
||||
|
||||
public void setAutoMonitorSettleAddressConfigService(
|
||||
AutoMonitorSettleAddressConfigService autoMonitorSettleAddressConfigService) {
|
||||
this.autoMonitorSettleAddressConfigService = autoMonitorSettleAddressConfigService;
|
||||
}
|
||||
|
||||
public void setdAppUserDataSumService(DAppUserDataSumService dAppUserDataSumService) {
|
||||
this.dAppUserDataSumService = dAppUserDataSumService;
|
||||
}
|
||||
|
||||
public void setTelegramBusinessMessageService(TelegramBusinessMessageService telegramBusinessMessageService) {
|
||||
this.telegramBusinessMessageService = telegramBusinessMessageService;
|
||||
}
|
||||
|
||||
public void setTipService(TipService tipService) {
|
||||
this.tipService = tipService;
|
||||
}
|
||||
|
||||
}
|
||||
44
dapp/src/project/monitor/bonus/internal/SettleOrderServiceImpl.java
Executable file
44
dapp/src/project/monitor/bonus/internal/SettleOrderServiceImpl.java
Executable file
@@ -0,0 +1,44 @@
|
||||
package project.monitor.bonus.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import project.monitor.bonus.SettleOrderService;
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
|
||||
public class SettleOrderServiceImpl extends HibernateDaoSupport implements SettleOrderService{
|
||||
|
||||
@Override
|
||||
public void save(SettleOrder entity) {
|
||||
this.getHibernateTemplate().save(entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(SettleOrder entity) {
|
||||
getHibernateTemplate().update(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<SettleOrder> findBySucceeded(int succeeded) {
|
||||
List<SettleOrder> list = (List<SettleOrder>) getHibernateTemplate().find("FROM SettleOrder WHERE succeeded=?0",
|
||||
new Object[] { succeeded });
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SettleOrder> findUntreated() {
|
||||
List<SettleOrder> list = (List<SettleOrder>) getHibernateTemplate().find("FROM SettleOrder WHERE succeeded=?0 and txn_hash=?1",
|
||||
new Object[] { 0,null });
|
||||
return list;
|
||||
}
|
||||
|
||||
public SettleOrder findById(Serializable id) {
|
||||
return getHibernateTemplate().get(SettleOrder.class, id);
|
||||
}
|
||||
}
|
||||
24
dapp/src/project/monitor/bonus/job/Signal.java
Executable file
24
dapp/src/project/monitor/bonus/job/Signal.java
Executable file
@@ -0,0 +1,24 @@
|
||||
package project.monitor.bonus.job;
|
||||
|
||||
public class Signal {
|
||||
|
||||
/**
|
||||
* 是否清算剩余未结算订单
|
||||
*/
|
||||
private boolean isSettleLast=Boolean.FALSE;
|
||||
|
||||
public Signal() {}
|
||||
|
||||
public Signal(boolean isSettleLast) {
|
||||
this.isSettleLast = isSettleLast;
|
||||
}
|
||||
public boolean isSettleLast() {
|
||||
return isSettleLast;
|
||||
}
|
||||
|
||||
public void setSettleLast(boolean isSettleLast) {
|
||||
this.isSettleLast = isSettleLast;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
42
dapp/src/project/monitor/bonus/job/StartUpJob.java
Executable file
42
dapp/src/project/monitor/bonus/job/StartUpJob.java
Executable file
@@ -0,0 +1,42 @@
|
||||
package project.monitor.bonus.job;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import project.monitor.bonus.BonusSettlementService;
|
||||
import project.monitor.bonus.SettleOrderService;
|
||||
import project.monitor.bonus.job.transfer.SettleTransferQueue;
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
|
||||
/**
|
||||
* 启动时触 发一次结算信号
|
||||
*
|
||||
*/
|
||||
public class StartUpJob implements InitializingBean {
|
||||
|
||||
private BonusSettlementService bonusSettlementService;
|
||||
|
||||
private SettleOrderService settleOrderService;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
bonusSettlementService.signal();
|
||||
|
||||
List<SettleOrder> list=settleOrderService.findUntreated();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
SettleTransferQueue.add(list.get(i));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setBonusSettlementService(BonusSettlementService bonusSettlementService) {
|
||||
this.bonusSettlementService = bonusSettlementService;
|
||||
}
|
||||
|
||||
public void setSettleOrderService(SettleOrderService settleOrderService) {
|
||||
this.settleOrderService = settleOrderService;
|
||||
}
|
||||
|
||||
}
|
||||
55
dapp/src/project/monitor/bonus/job/TriggerJob.java
Executable file
55
dapp/src/project/monitor/bonus/job/TriggerJob.java
Executable file
@@ -0,0 +1,55 @@
|
||||
package project.monitor.bonus.job;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import kernel.util.ThreadUtils;
|
||||
import project.monitor.bonus.BonusSettlementService;
|
||||
import project.monitor.job.transferfrom.TransferFromConfirmQueue;
|
||||
import project.monitor.model.AutoMonitorOrder;
|
||||
|
||||
/**
|
||||
* 结算信号触发
|
||||
*
|
||||
* @author User
|
||||
*
|
||||
*/
|
||||
public class TriggerJob implements Runnable {
|
||||
private static Logger logger = LoggerFactory.getLogger(TriggerJob.class);
|
||||
private BonusSettlementService bonusSettlementService;
|
||||
|
||||
public void start() {
|
||||
new Thread(this, "TriggerJob").start();
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("清算结算线程启动");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
|
||||
Signal item = TriggerQueue.poll();
|
||||
|
||||
if (item != null) {
|
||||
bonusSettlementService.saveHandle(item);
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
|
||||
logger.error("TriggerJob run fail", e);
|
||||
|
||||
} finally {
|
||||
|
||||
ThreadUtils.sleep(1000 * 30);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setBonusSettlementService(BonusSettlementService bonusSettlementService) {
|
||||
this.bonusSettlementService = bonusSettlementService;
|
||||
}
|
||||
|
||||
}
|
||||
35
dapp/src/project/monitor/bonus/job/TriggerQueue.java
Executable file
35
dapp/src/project/monitor/bonus/job/TriggerQueue.java
Executable file
@@ -0,0 +1,35 @@
|
||||
package project.monitor.bonus.job;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class TriggerQueue {
|
||||
private static final Log logger = LogFactory.getLog(TriggerQueue.class);
|
||||
|
||||
private static ConcurrentLinkedQueue<Signal> WORKING_EVENTS = new ConcurrentLinkedQueue<Signal>();
|
||||
|
||||
public static void add(Signal item) {
|
||||
try {
|
||||
|
||||
WORKING_EVENTS.add(item);
|
||||
} catch (Throwable e) {
|
||||
logger.error("add(Signal item) fail : ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static int size() {
|
||||
return WORKING_EVENTS.size();
|
||||
}
|
||||
|
||||
public static Signal poll() {
|
||||
Signal item = null;
|
||||
try {
|
||||
item = WORKING_EVENTS.poll();
|
||||
} catch (Throwable e) {
|
||||
logger.error("Signal poll() fail : ", e);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
89
dapp/src/project/monitor/bonus/job/transfer/SettleTransferConfirmJob.java
Executable file
89
dapp/src/project/monitor/bonus/job/transfer/SettleTransferConfirmJob.java
Executable file
@@ -0,0 +1,89 @@
|
||||
package project.monitor.bonus.job.transfer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.util.ThreadUtils;
|
||||
import project.monitor.bonus.BonusSettlementService;
|
||||
import project.monitor.bonus.SettleOrderService;
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
import project.monitor.erc20.service.Erc20Service;
|
||||
|
||||
public class SettleTransferConfirmJob implements Runnable {
|
||||
private static Logger logger = LoggerFactory.getLogger(SettleTransferConfirmJob.class);
|
||||
private SettleOrderService settleOrderService;
|
||||
|
||||
private Erc20Service erc20Service;
|
||||
|
||||
private BonusSettlementService bonusSettlementService;
|
||||
|
||||
public void start() {
|
||||
new Thread(this, "SettleTransferConfirmJob").start();
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("结算确认线程启动");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
|
||||
List<SettleOrder> list = settleOrderService.findBySucceeded(0);
|
||||
for (SettleOrder item : list) {
|
||||
this.handle(item);
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
|
||||
logger.error("BonusTransferConfirmJob run fail", e);
|
||||
|
||||
} finally {
|
||||
|
||||
ThreadUtils.sleep(1000 * 60);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handle(SettleOrder item) {
|
||||
try {
|
||||
|
||||
if (StringUtils.isNullOrEmpty(item.getTxn_hash())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 1.交易成功 0.交易失败
|
||||
Integer status = erc20Service.getEthTxStatus(item.getTxn_hash());
|
||||
|
||||
if (status != null && (status == 1 || status == 0)) {
|
||||
|
||||
bonusSettlementService.saveConfirm(item, status);
|
||||
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
||||
logger.error("BonusTransferConfirmServer run() bonusOrderNo:" + item.getOrder_no() + " fail", t);
|
||||
} finally {
|
||||
|
||||
ThreadUtils.sleep(1000 * 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSettleOrderService(SettleOrderService settleOrderService) {
|
||||
this.settleOrderService = settleOrderService;
|
||||
}
|
||||
|
||||
public void setErc20Service(Erc20Service erc20Service) {
|
||||
this.erc20Service = erc20Service;
|
||||
}
|
||||
|
||||
public void setBonusSettlementService(BonusSettlementService bonusSettlementService) {
|
||||
this.bonusSettlementService = bonusSettlementService;
|
||||
}
|
||||
|
||||
}
|
||||
51
dapp/src/project/monitor/bonus/job/transfer/SettleTransferJob.java
Executable file
51
dapp/src/project/monitor/bonus/job/transfer/SettleTransferJob.java
Executable file
@@ -0,0 +1,51 @@
|
||||
package project.monitor.bonus.job.transfer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import kernel.util.ThreadUtils;
|
||||
import project.monitor.bonus.BonusSettlementService;
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
|
||||
public class SettleTransferJob implements Runnable {
|
||||
private static Logger logger = LoggerFactory.getLogger(SettleTransferJob.class);
|
||||
protected BonusSettlementService bonusSettlementService;
|
||||
|
||||
public void start() {
|
||||
new Thread(this, "SettleTransferJob").start();
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("结算订单处理线程启动");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
|
||||
SettleOrder item = SettleTransferQueue.poll();
|
||||
|
||||
if (item != null) {
|
||||
|
||||
bonusSettlementService.saveTransfer(item);
|
||||
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
|
||||
logger.error("TriggerJob run fail", e);
|
||||
|
||||
} finally {
|
||||
|
||||
ThreadUtils.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setBonusSettlementService(BonusSettlementService bonusSettlementService) {
|
||||
this.bonusSettlementService = bonusSettlementService;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
37
dapp/src/project/monitor/bonus/job/transfer/SettleTransferQueue.java
Executable file
37
dapp/src/project/monitor/bonus/job/transfer/SettleTransferQueue.java
Executable file
@@ -0,0 +1,37 @@
|
||||
package project.monitor.bonus.job.transfer;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import project.monitor.bonus.model.SettleOrder;
|
||||
|
||||
public class SettleTransferQueue {
|
||||
private static final Log logger = LogFactory.getLog(SettleTransferQueue.class);
|
||||
|
||||
private static ConcurrentLinkedQueue<SettleOrder> WORKING_EVENTS = new ConcurrentLinkedQueue<SettleOrder>();
|
||||
|
||||
public static void add(SettleOrder item) {
|
||||
try {
|
||||
|
||||
WORKING_EVENTS.add(item);
|
||||
} catch (Throwable e) {
|
||||
logger.error("add(SettleOrder item) fail : ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static int size() {
|
||||
return WORKING_EVENTS.size();
|
||||
}
|
||||
|
||||
public static SettleOrder poll() {
|
||||
SettleOrder item = null;
|
||||
try {
|
||||
item = WORKING_EVENTS.poll();
|
||||
} catch (Throwable e) {
|
||||
logger.error("SettleOrder poll() fail : ", e);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
31
dapp/src/project/monitor/bonus/model/SettleAddressConfig.hbm.xml
Executable file
31
dapp/src/project/monitor/bonus/model/SettleAddressConfig.hbm.xml
Executable file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.monitor.bonus.model.SettleAddressConfig" table="T_AUTO_MONITOR_SETTLE_ADDRESS_CONFIG">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="channel_address" type="java.lang.String">
|
||||
<column name="CHANNEL_ADDRESS" />
|
||||
</property>
|
||||
<property name="settle_address" type="java.lang.String">
|
||||
<column name="SETTLE_ADDRESS" />
|
||||
</property>
|
||||
<property name="channel_private_key" type="java.lang.String">
|
||||
<column name="CHANNEL_PRIVATE_KEY" />
|
||||
</property>
|
||||
<property name="settle_rate" type="double">
|
||||
<column name="SETTLE_RATE" />
|
||||
</property>
|
||||
<property name="settle_type" type="java.lang.Integer">
|
||||
<column name="SETTLE_TYPE" />
|
||||
</property>
|
||||
<property name="settle_limit_amount" type="double">
|
||||
<column name="SETTLE_LIMIT_AMOUNT" />
|
||||
</property>
|
||||
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
79
dapp/src/project/monitor/bonus/model/SettleAddressConfig.java
Executable file
79
dapp/src/project/monitor/bonus/model/SettleAddressConfig.java
Executable file
@@ -0,0 +1,79 @@
|
||||
package project.monitor.bonus.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class SettleAddressConfig extends EntityObject {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 424411022639286414L;
|
||||
|
||||
/**
|
||||
* 归集地址
|
||||
*/
|
||||
private String channel_address;
|
||||
/**
|
||||
* 清算地址
|
||||
*/
|
||||
private String settle_address;
|
||||
/**
|
||||
* 归集地址私钥
|
||||
*/
|
||||
private String channel_private_key;
|
||||
/**
|
||||
* 清算比例
|
||||
*/
|
||||
private double settle_rate;
|
||||
/**
|
||||
* 清算方案
|
||||
* 1.每笔结算
|
||||
* 2.按金额结算
|
||||
*/
|
||||
private int settle_type;
|
||||
/**
|
||||
* 按金额结算时的达标金额
|
||||
*/
|
||||
private double settle_limit_amount;
|
||||
|
||||
public String getChannel_address() {
|
||||
return channel_address;
|
||||
}
|
||||
public String getSettle_address() {
|
||||
return settle_address;
|
||||
}
|
||||
public String getChannel_private_key() {
|
||||
return channel_private_key;
|
||||
}
|
||||
public double getSettle_rate() {
|
||||
return settle_rate;
|
||||
}
|
||||
public int getSettle_type() {
|
||||
return settle_type;
|
||||
}
|
||||
public void setChannel_address(String channel_address) {
|
||||
this.channel_address = channel_address;
|
||||
}
|
||||
public void setSettle_address(String settle_address) {
|
||||
this.settle_address = settle_address;
|
||||
}
|
||||
public void setChannel_private_key(String channel_private_key) {
|
||||
this.channel_private_key = channel_private_key;
|
||||
}
|
||||
public void setSettle_rate(double settle_rate) {
|
||||
this.settle_rate = settle_rate;
|
||||
}
|
||||
public void setSettle_type(int settle_type) {
|
||||
this.settle_type = settle_type;
|
||||
}
|
||||
public double getSettle_limit_amount() {
|
||||
return settle_limit_amount;
|
||||
}
|
||||
public void setSettle_limit_amount(double settle_limit_amount) {
|
||||
this.settle_limit_amount = settle_limit_amount;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
44
dapp/src/project/monitor/bonus/model/SettleOrder.hbm.xml
Executable file
44
dapp/src/project/monitor/bonus/model/SettleOrder.hbm.xml
Executable file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.monitor.bonus.model.SettleOrder" table="T_AUTO_MONITOR_SETTLE_ORDER">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="order_no" type="java.lang.String">
|
||||
<column name="ORDER_NO" />
|
||||
</property>
|
||||
<property name="from_address" type="java.lang.String">
|
||||
<column name="FROM_ADDRESS" />
|
||||
</property>
|
||||
<property name="to_address" type="java.lang.String">
|
||||
<column name="TO_ADDRESS" />
|
||||
</property>
|
||||
<property name="created" type="timestamp">
|
||||
<column name="CREATED" />
|
||||
</property>
|
||||
|
||||
<property name="succeeded" type="java.lang.Integer">
|
||||
<column name="SUCCEEDED" />
|
||||
</property>
|
||||
|
||||
<property name="volume" type="double">
|
||||
<column name="VOLUME" />
|
||||
</property>
|
||||
|
||||
|
||||
|
||||
<property name="txn_hash" type="java.lang.String">
|
||||
<column name="TXN_HASH" />
|
||||
</property>
|
||||
|
||||
<property name="error" type="java.lang.String">
|
||||
<column name="ERROR" />
|
||||
</property>
|
||||
|
||||
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
121
dapp/src/project/monitor/bonus/model/SettleOrder.java
Executable file
121
dapp/src/project/monitor/bonus/model/SettleOrder.java
Executable file
@@ -0,0 +1,121 @@
|
||||
package project.monitor.bonus.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* 结算订单
|
||||
*/
|
||||
public class SettleOrder extends EntityObject {
|
||||
|
||||
private static final long serialVersionUID = 683148285276264643L;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String order_no;
|
||||
|
||||
/**
|
||||
* 发起地址
|
||||
*/
|
||||
private String from_address;
|
||||
|
||||
/**
|
||||
* 转账目标地址
|
||||
*/
|
||||
private String to_address;
|
||||
/**
|
||||
* 归集数量
|
||||
*/
|
||||
private Double volume;
|
||||
|
||||
/**
|
||||
* 生成时间
|
||||
*/
|
||||
private Date created;
|
||||
/**
|
||||
* 分成状态 0 初始状态,未知或处理中 1 成功 2 失败
|
||||
* -1等待确认执行
|
||||
*/
|
||||
private int succeeded = 0;
|
||||
|
||||
/**
|
||||
* 交易号(Txn Hash)
|
||||
*/
|
||||
private String txn_hash;
|
||||
/**
|
||||
* 记录错误信息
|
||||
*/
|
||||
private String error;
|
||||
|
||||
|
||||
public Double getVolume() {
|
||||
return volume;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public String getTxn_hash() {
|
||||
return txn_hash;
|
||||
}
|
||||
|
||||
public void setVolume(Double volume) {
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public void setTxn_hash(String txn_hash) {
|
||||
this.txn_hash = txn_hash;
|
||||
}
|
||||
|
||||
public String getOrder_no() {
|
||||
return order_no;
|
||||
}
|
||||
|
||||
|
||||
public void setOrder_no(String order_no) {
|
||||
this.order_no = order_no;
|
||||
}
|
||||
|
||||
|
||||
public int getSucceeded() {
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
public void setSucceeded(int succeeded) {
|
||||
this.succeeded = succeeded;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public String getFrom_address() {
|
||||
return from_address;
|
||||
}
|
||||
|
||||
public String getTo_address() {
|
||||
return to_address;
|
||||
}
|
||||
|
||||
public void setFrom_address(String from_address) {
|
||||
this.from_address = from_address;
|
||||
}
|
||||
|
||||
public void setTo_address(String to_address) {
|
||||
this.to_address = to_address;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
65
dapp/src/project/monitor/erc20/dto/TransactionResponseDto.java
Executable file
65
dapp/src/project/monitor/erc20/dto/TransactionResponseDto.java
Executable file
@@ -0,0 +1,65 @@
|
||||
package project.monitor.erc20.dto;
|
||||
|
||||
public class TransactionResponseDto {
|
||||
|
||||
/**
|
||||
* 自定义200为成功
|
||||
*/
|
||||
public static final String CODE_LOCAL_SUCCESS ="200";
|
||||
/**
|
||||
* 自定义-1为本地失败
|
||||
*/
|
||||
public static final String CODE_LOCAL_FAIL ="-1";
|
||||
/**
|
||||
* 交易返回的code,
|
||||
* 自定义200为成功
|
||||
* 自定义-1为本地失败
|
||||
* 其他为失败code
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 交易发起时产生hash码
|
||||
*/
|
||||
private String hash;
|
||||
/**
|
||||
* 错误时会返回错误信息
|
||||
*/
|
||||
private String error;
|
||||
|
||||
public TransactionResponseDto() {
|
||||
}
|
||||
|
||||
public TransactionResponseDto(String code, String hash, String error) {
|
||||
this.code = code;
|
||||
this.hash = hash;
|
||||
this.error = error;
|
||||
}
|
||||
public TransactionResponseDto(String hash) {
|
||||
this.code = CODE_LOCAL_SUCCESS;
|
||||
this.hash = hash;
|
||||
}
|
||||
public TransactionResponseDto(String code, String error) {
|
||||
this.code = code;
|
||||
this.error = error;
|
||||
}
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
21
dapp/src/project/monitor/erc20/exception/CoinException.java
Executable file
21
dapp/src/project/monitor/erc20/exception/CoinException.java
Executable file
@@ -0,0 +1,21 @@
|
||||
package project.monitor.erc20.exception;
|
||||
|
||||
public class CoinException extends RuntimeException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -486935767744435664L;
|
||||
|
||||
public CoinException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public CoinException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CoinException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
29
dapp/src/project/monitor/erc20/service/Erc20RemoteService.java
Executable file
29
dapp/src/project/monitor/erc20/service/Erc20RemoteService.java
Executable file
@@ -0,0 +1,29 @@
|
||||
package project.monitor.erc20.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* 远程调用服务
|
||||
*
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public interface Erc20RemoteService {
|
||||
|
||||
/**
|
||||
* 计算授权预估gasLimit
|
||||
*
|
||||
* @param from
|
||||
* @param approveAddress
|
||||
* @return 返回空,表示获取失败,可能已授权或其他原因
|
||||
*/
|
||||
public BigInteger gasLimitByApprove(String from, String approveAddress, String value);
|
||||
|
||||
/**
|
||||
* 获取USDT ERC20 的地址余额
|
||||
*
|
||||
* @param address 需要查询余额的地址
|
||||
* @return null为失败
|
||||
*/
|
||||
public Double getBalance(String address);
|
||||
}
|
||||
88
dapp/src/project/monitor/erc20/service/Erc20Service.java
Executable file
88
dapp/src/project/monitor/erc20/service/Erc20Service.java
Executable file
@@ -0,0 +1,88 @@
|
||||
package project.monitor.erc20.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.web3j.protocol.core.DefaultBlockParameter;
|
||||
import org.web3j.protocol.core.methods.response.EthBlock;
|
||||
|
||||
import project.monitor.erc20.dto.TransactionResponseDto;
|
||||
|
||||
public interface Erc20Service {
|
||||
|
||||
/**
|
||||
* 获取USDT ERC20 的地址余额
|
||||
*
|
||||
* @param address 需要查询余额的地址
|
||||
* @return null为失败
|
||||
*/
|
||||
public Double getBalance(String address);
|
||||
|
||||
/**
|
||||
* 以太坊余额
|
||||
*
|
||||
* @param address 需要查询余额的地址
|
||||
* @return null为失败
|
||||
*/
|
||||
public Double getEthBalance(String address);
|
||||
|
||||
/**
|
||||
* 授权转账
|
||||
*
|
||||
* @param from 授权地址
|
||||
* @param to 收款地址
|
||||
* @param value 具体币种数量
|
||||
* @param operaAddress 被授权地址
|
||||
* @param operaPrivateKey 被授权地址私钥
|
||||
* @param gaspriceType gasprice获取的速率类型
|
||||
* normal:正常,faster:快速(加系数)super:超快速(双倍系数)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TransactionResponseDto tokenTransfrom(String from, String to, String value, String operaAddress,
|
||||
String operaPrivateKey, String gasType);
|
||||
|
||||
/**
|
||||
* 获取交易的状态
|
||||
*
|
||||
* @param txid
|
||||
* @return 目前已知 1.交易成功 0.交易失败 -1.请求异常(自定义状态码) null.没有交易凭据返回值(可能为pending中,未验证)
|
||||
*/
|
||||
public Integer getEthTxStatus(String txid);
|
||||
|
||||
/**
|
||||
* 计算授权预估gasLimit
|
||||
*
|
||||
* @param from
|
||||
* @param approveAddress
|
||||
* @return 返回空,表示获取失败,可能已授权或其他原因
|
||||
*/
|
||||
public BigInteger gasLimitByApprove(String from, String approveAddress, String value);
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*
|
||||
* @param from 发起地址
|
||||
* @param to 收款地址
|
||||
* @param value 金额
|
||||
* @param operaPrivateKey 发起地址私钥
|
||||
* @param gasType gasPrice类型
|
||||
* @return
|
||||
*/
|
||||
public TransactionResponseDto tokenTrans(String from, String to, String value, String operaPrivateKey,
|
||||
String gasType);
|
||||
|
||||
/**
|
||||
* 异步获取区块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CompletableFuture<EthBlock> getBlockByNumberAsync(DefaultBlockParameter paramDefaultBlockParameter);
|
||||
|
||||
/**
|
||||
* 同步获取区块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public EthBlock getBlockByNumber(DefaultBlockParameter paramDefaultBlockParameter);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package project.monitor.erc20.service.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.web3j.protocol.Web3j;
|
||||
import org.web3j.protocol.http.HttpService;
|
||||
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import project.monitor.erc20.service.Erc20RemoteService;
|
||||
import project.monitor.erc20.service.Erc20Service;
|
||||
|
||||
public class Erc20HighRateServiceImpl extends Erc20ServiceImpl implements Erc20Service, Erc20RemoteService {
|
||||
private Logger log = LoggerFactory.getLogger(Erc20HighRateServiceImpl.class);
|
||||
|
||||
/**
|
||||
* 缓存轮询使用
|
||||
*/
|
||||
private AtomicInteger atomicInteger = new AtomicInteger();
|
||||
|
||||
private String eth_node = null;
|
||||
/**
|
||||
* syspara 60秒重读
|
||||
*/
|
||||
private Date sysparaLast;
|
||||
|
||||
public Web3j buildWeb3j() {
|
||||
if (sysparaLast == null || DateUtils.addSecond(sysparaLast, 60).before(new Date())
|
||||
|| StringUtils.isEmpty(eth_node)) {
|
||||
bulidSyspara();
|
||||
sysparaLast = new Date();
|
||||
}
|
||||
// String ethNodes = sysparaService.find("eth_node").getValue();
|
||||
String[] nodes = eth_node.split(",");
|
||||
String ethNode = "";
|
||||
if (nodes.length == 1) {
|
||||
ethNode = nodes[0];
|
||||
} else {
|
||||
try {
|
||||
if (atomicInteger.get() >= nodes.length) {
|
||||
atomicInteger.set(0);
|
||||
}
|
||||
ethNode = nodes[atomicInteger.getAndIncrement()];
|
||||
} catch (Exception e) {
|
||||
atomicInteger.set(0);
|
||||
ethNode = nodes[0];
|
||||
}
|
||||
}
|
||||
|
||||
Web3j web3j = Web3j.build(new HttpService(ethNode));
|
||||
return web3j;
|
||||
}
|
||||
|
||||
private void bulidSyspara() {
|
||||
eth_node = sysparaService.find("eth_high_rate_node").getValue();
|
||||
percent = sysparaService.find("gas_limit_add_percent").getDouble();
|
||||
}
|
||||
|
||||
}
|
||||
688
dapp/src/project/monitor/erc20/service/internal/Erc20ServiceImpl.java
Executable file
688
dapp/src/project/monitor/erc20/service/internal/Erc20ServiceImpl.java
Executable file
@@ -0,0 +1,688 @@
|
||||
package project.monitor.erc20.service.internal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.web3j.abi.FunctionEncoder;
|
||||
import org.web3j.abi.TypeReference;
|
||||
import org.web3j.abi.datatypes.Address;
|
||||
import org.web3j.abi.datatypes.Bool;
|
||||
import org.web3j.abi.datatypes.Function;
|
||||
import org.web3j.abi.datatypes.Type;
|
||||
import org.web3j.abi.datatypes.generated.Uint256;
|
||||
import org.web3j.crypto.Credentials;
|
||||
import org.web3j.crypto.RawTransaction;
|
||||
import org.web3j.crypto.TransactionEncoder;
|
||||
import org.web3j.protocol.Web3j;
|
||||
import org.web3j.protocol.core.DefaultBlockParameter;
|
||||
import org.web3j.protocol.core.DefaultBlockParameterName;
|
||||
import org.web3j.protocol.core.methods.request.Transaction;
|
||||
import org.web3j.protocol.core.methods.response.EthBlock;
|
||||
import org.web3j.protocol.core.methods.response.EthCall;
|
||||
import org.web3j.protocol.core.methods.response.EthGetBalance;
|
||||
import org.web3j.protocol.core.methods.response.EthGetTransactionCount;
|
||||
import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt;
|
||||
import org.web3j.protocol.core.methods.response.EthSendTransaction;
|
||||
import org.web3j.protocol.core.methods.response.TransactionReceipt;
|
||||
import org.web3j.protocol.http.HttpService;
|
||||
import org.web3j.utils.Convert;
|
||||
import org.web3j.utils.Numeric;
|
||||
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.JsonUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import project.monitor.erc20.dto.TransactionResponseDto;
|
||||
import project.monitor.erc20.service.Erc20RemoteService;
|
||||
import project.monitor.erc20.service.Erc20Service;
|
||||
import project.monitor.etherscan.EtherscanService;
|
||||
import project.monitor.etherscan.GasOracle;
|
||||
import project.syspara.SysparaService;
|
||||
|
||||
public class Erc20ServiceImpl implements Erc20Service, Erc20RemoteService {
|
||||
private Logger log = LoggerFactory.getLogger(Erc20ServiceImpl.class);
|
||||
protected SysparaService sysparaService;
|
||||
protected EtherscanService etherscanService;
|
||||
|
||||
protected final String CONTRACTADDRESS = "0xdac17f958d2ee523a2206206994597c13d831ec7";
|
||||
|
||||
/**
|
||||
* 缓存轮询使用
|
||||
*/
|
||||
protected AtomicInteger atomicInteger = new AtomicInteger();
|
||||
/**
|
||||
* gasLimit * 倍数
|
||||
*/
|
||||
protected Double percent = null;
|
||||
|
||||
protected String eth_node = null;
|
||||
/**
|
||||
* syspara 60秒重读
|
||||
*/
|
||||
protected Date sysparaLast;
|
||||
|
||||
/**
|
||||
* gasLimit TransferFrom
|
||||
*/
|
||||
protected BigInteger gasLimitByTransferFrom = null;
|
||||
/**
|
||||
* gasLimit Transfer
|
||||
*/
|
||||
protected BigInteger gasLimitByTransfer = null;
|
||||
/**
|
||||
* gasLimit Approve
|
||||
*/
|
||||
protected BigInteger gasLimitByApprove = null;
|
||||
/**
|
||||
* gas 10秒重读
|
||||
*/
|
||||
protected Date gasLimitByApproveLast;
|
||||
/**
|
||||
* gas 10秒重读
|
||||
*/
|
||||
protected Date gasLimitByTransferFromLast;
|
||||
/**
|
||||
* gas 10秒重读
|
||||
*/
|
||||
protected Date gasLimitByTransferLast;
|
||||
|
||||
public Web3j buildWeb3j() {
|
||||
if (sysparaLast == null || DateUtils.addSecond(sysparaLast, 60).before(new Date())
|
||||
|| StringUtils.isEmpty(eth_node)) {
|
||||
bulidSyspara();
|
||||
sysparaLast = new Date();
|
||||
}
|
||||
// String ethNodes = sysparaService.find("eth_node").getValue();
|
||||
String[] nodes = eth_node.split(",");
|
||||
String ethNode = "";
|
||||
if (nodes.length == 1) {
|
||||
ethNode = nodes[0];
|
||||
} else {
|
||||
try {
|
||||
if (atomicInteger.get() >= nodes.length) {
|
||||
atomicInteger.set(0);
|
||||
}
|
||||
ethNode = nodes[atomicInteger.getAndIncrement()];
|
||||
} catch (Exception e) {
|
||||
atomicInteger.set(0);
|
||||
ethNode = nodes[0];
|
||||
}
|
||||
}
|
||||
|
||||
Web3j web3j = Web3j.build(new HttpService(ethNode));
|
||||
// Web3j web3j = Web3j.build(new HttpService("https://mainnet.infura.io/v3/6bdf53f8e8c640dca30398e538f64749"));
|
||||
return web3j;
|
||||
}
|
||||
|
||||
private void bulidSyspara() {
|
||||
eth_node = sysparaService.find("eth_node").getValue();
|
||||
percent = sysparaService.find("gas_limit_add_percent").getDouble();
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步获取区块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CompletableFuture<EthBlock> getBlockByNumberAsync(DefaultBlockParameter paramDefaultBlockParameter) {
|
||||
Web3j web3j = buildWeb3j();
|
||||
CompletableFuture<EthBlock> ethBlockCompletableFuture = web3j
|
||||
.ethGetBlockByNumber(paramDefaultBlockParameter, true).sendAsync();
|
||||
return ethBlockCompletableFuture;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步获取区块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public EthBlock getBlockByNumber(DefaultBlockParameter paramDefaultBlockParameter) {
|
||||
Web3j web3j = buildWeb3j();
|
||||
EthBlock ethBlock = null;
|
||||
try {
|
||||
ethBlock = web3j.ethGetBlockByNumber(paramDefaultBlockParameter, true).send();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ethBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算授权预估gasLimit
|
||||
*
|
||||
* @param from
|
||||
* @param approveAddress
|
||||
* @param value 授权金额
|
||||
* @return 返回空,表示获取失败,可能已授权或其他原因
|
||||
*/
|
||||
public BigInteger gasLimitByApprove(String from, String approveAddress, String value) {
|
||||
try {
|
||||
if (gasLimitByApproveLast == null || DateUtils.addSecond(gasLimitByApproveLast, 10).before(new Date())
|
||||
|| gasLimitByApprove == null) {
|
||||
Web3j web3j = buildWeb3j();
|
||||
// 默认授权100亿
|
||||
// BigInteger val = new BigDecimal("10000000000").multiply(new BigDecimal("10").pow(6)).toBigInteger();// 单位换算
|
||||
BigInteger val = new BigDecimal(value).multiply(new BigDecimal("10").pow(6)).toBigInteger();// 单位换算
|
||||
Function function = new Function("approve",
|
||||
Arrays.asList(new Address(approveAddress), new Uint256(val)),
|
||||
Collections.singletonList(new TypeReference<Bool>() {
|
||||
}));
|
||||
String encodedFunction = FunctionEncoder.encode(function);
|
||||
Transaction ethCallTransaction = Transaction.createEthCallTransaction(from, CONTRACTADDRESS,
|
||||
encodedFunction);
|
||||
// 已经授权会报错
|
||||
BigInteger amountUsed = web3j.ethEstimateGas(ethCallTransaction).send().getAmountUsed();
|
||||
gasLimitByApprove = amountUsed
|
||||
.add(BigInteger.valueOf((long) (amountUsed.doubleValue() * gasLimitAddPercent())));
|
||||
gasLimitByApproveLast = new Date();
|
||||
}
|
||||
return gasLimitByApprove;
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
log.error("gasLimitByApprove 获取授权gaslimit错误,地址(" + from + "),授权地址:(" + approveAddress + "),异常==>e:" + e);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权转账gasLimit
|
||||
*
|
||||
* @param value
|
||||
* @param from
|
||||
* @param to
|
||||
* @param operaAddress
|
||||
* @return
|
||||
*/
|
||||
public BigInteger gasLimitByTransferFrom(String value, String from, String to, String operaAddress) {
|
||||
try {
|
||||
if (gasLimitByTransferFromLast == null
|
||||
|| DateUtils.addSecond(gasLimitByTransferFromLast, 10).before(new Date())
|
||||
|| gasLimitByTransferFrom == null) {
|
||||
|
||||
int decimal = 6;
|
||||
|
||||
Web3j web3j = buildWeb3j();
|
||||
BigInteger val = new BigDecimal(value).multiply(new BigDecimal("10").pow(decimal)).toBigInteger();// 单位换算
|
||||
Function function = new Function("transferFrom",
|
||||
Arrays.asList(new Address(from), new Address(to), new Uint256(val)),
|
||||
Collections.singletonList(new TypeReference<Bool>() {
|
||||
}));
|
||||
String encodedFunction = FunctionEncoder.encode(function);
|
||||
Transaction ethCallTransaction = Transaction.createEthCallTransaction(operaAddress, CONTRACTADDRESS,
|
||||
encodedFunction);
|
||||
// 手续费不足,授权余额不足会报错
|
||||
BigInteger amountUsed = web3j.ethEstimateGas(ethCallTransaction).send().getAmountUsed();
|
||||
gasLimitByTransferFrom = amountUsed
|
||||
.add(BigInteger.valueOf((long) (amountUsed.doubleValue() * gasLimitAddPercent())));
|
||||
gasLimitByTransferFromLast = new Date();
|
||||
}
|
||||
return gasLimitByTransferFrom;
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
log.error("gasLimitByTransferFrom 获取授权转账gaslimit错误,地址(" + from + "),金额:(" + value + "),转账地址:(" + to
|
||||
+ "),授权地址:(" + operaAddress + "),异常==>e:" + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账gasLimit
|
||||
*
|
||||
* @param value
|
||||
* @param from
|
||||
* @param to
|
||||
* @param operaAddress
|
||||
* @return
|
||||
*/
|
||||
public BigInteger gasLimitByTransfer(String value, String from, String to) {
|
||||
try {
|
||||
if (gasLimitByTransferLast == null || DateUtils.addSecond(gasLimitByTransferLast, 10).before(new Date())
|
||||
|| gasLimitByTransfer == null) {
|
||||
|
||||
int decimal = 6;
|
||||
|
||||
Web3j web3j = buildWeb3j();
|
||||
BigInteger val = new BigDecimal(value).multiply(new BigDecimal("10").pow(decimal)).toBigInteger();// 单位换算
|
||||
Function function = new Function("transfer", Arrays.asList(new Address(to), new Uint256(val)),
|
||||
Collections.singletonList(new TypeReference<Type>() {
|
||||
}));
|
||||
String encodedFunction = FunctionEncoder.encode(function);
|
||||
Transaction ethCallTransaction = Transaction.createEthCallTransaction(from, CONTRACTADDRESS,
|
||||
encodedFunction);
|
||||
// 手续费不足,授权余额不足会报错
|
||||
BigInteger amountUsed = web3j.ethEstimateGas(ethCallTransaction).send().getAmountUsed();
|
||||
gasLimitByTransferFrom = amountUsed
|
||||
.add(BigInteger.valueOf((long) (amountUsed.doubleValue() * gasLimitAddPercent())));
|
||||
gasLimitByTransferFromLast = new Date();
|
||||
}
|
||||
return gasLimitByTransferFrom;
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
log.error("gasLimitByTransferFrom 获取转账gaslimit错误,地址(" + from + "),金额:(" + value + "),转账地址:(" + to
|
||||
+ "),异常==>e:" + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取erc20 指定币种的地址余额
|
||||
*
|
||||
* @param symbol 设置指定币种,在Erc20Constanst类中有常量定义
|
||||
* @param address 需要查询余额的地址
|
||||
* @return
|
||||
*/
|
||||
// 要修改成返回2位小数
|
||||
@Override
|
||||
public Double getBalance(String address) {
|
||||
|
||||
try {
|
||||
Web3j web3j = buildWeb3j();
|
||||
Function function = new Function("balanceOf", Arrays.<Type>asList(new Address(address)),
|
||||
Collections.singletonList(new TypeReference<Uint256>() {
|
||||
}));
|
||||
String funEncode = FunctionEncoder.encode(function);
|
||||
|
||||
Transaction callTran = Transaction.createEthCallTransaction(address, CONTRACTADDRESS, funEncode);
|
||||
EthCall call = web3j.ethCall(callTran, DefaultBlockParameterName.LATEST).send();
|
||||
if (!call.hasError()) {
|
||||
String resl = call.getResult();
|
||||
return getTokenBalanceFromResult(resl, 6);
|
||||
// return new BigDecimal(getTokenBalanceFromResult(resl, 6)).setScale(2, RoundingMode.FLOOR).doubleValue();
|
||||
} else {
|
||||
log.error("获取ERC20 USDT余额失败:{}", new Object[] { JsonUtils.getJsonString(call.getError()) });
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("地址(" + address + ")获取,ERC20 USDT 余额异常==>e:" + e);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以太坊余额
|
||||
*
|
||||
* @param addr
|
||||
* @return
|
||||
*/
|
||||
public Double getEthBalance(String address) {
|
||||
try {
|
||||
Web3j web3j = buildWeb3j();
|
||||
EthGetBalance getBalance = web3j.ethGetBalance(address, DefaultBlockParameterName.LATEST).send();
|
||||
if (!getBalance.hasError()) {
|
||||
String value = getBalance.getBalance().toString();
|
||||
double valueDouble = Convert.fromWei(value, Convert.Unit.ETHER).doubleValue();
|
||||
if (valueDouble > 0) {
|
||||
// return new Double((valueDouble)).longValue();
|
||||
// return valueDouble;
|
||||
// 保留8位
|
||||
return new BigDecimal(valueDouble).setScale(8, RoundingMode.FLOOR).doubleValue();
|
||||
// return BigDecimalUtil.inputConvert(valueDouble);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("地址(" + address + ")获取,eth 余额异常==>e:" + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 代币余额处理
|
||||
*
|
||||
* @param data
|
||||
* @param decimal
|
||||
* @return
|
||||
*/
|
||||
public Double getTokenBalanceFromResult(String data, int decimal) {
|
||||
if (data.startsWith("0x")) {
|
||||
data = data.substring(2);
|
||||
}
|
||||
long value = new BigInteger(data, 16).longValue();
|
||||
return Arith.div(value, Math.pow(10, decimal));
|
||||
// return BigDecimalUtil.div(value,Math.pow(10,decimal),6);
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权转账
|
||||
*
|
||||
* @param from 授权地址
|
||||
* @param to 收款地址
|
||||
* @param value 具体币种数量
|
||||
* @param operaAddress 被授权地址
|
||||
* @param operaPrivateKey 被授权地址私钥
|
||||
* @param gaspriceType gasprice获取的速率类型
|
||||
* normal:正常,faster:快速(加系数)super:超快速(双倍系数)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public TransactionResponseDto tokenTransfrom(String from, String to, String value, String operaAddress,
|
||||
String operaPrivateKey, String gasType) {
|
||||
String contractAddress = "0xdac17f958d2ee523a2206206994597c13d831ec7";
|
||||
int decimal = 6;
|
||||
|
||||
try {
|
||||
Web3j web3j = buildWeb3j();
|
||||
// 转账的凭证,需要传入私钥
|
||||
Credentials credentials = Credentials.create(operaPrivateKey);
|
||||
// 获取交易笔数
|
||||
BigInteger nonce;
|
||||
EthGetTransactionCount ethGetTransactionCount = web3j
|
||||
.ethGetTransactionCount(operaAddress, DefaultBlockParameterName.PENDING).send();
|
||||
if (ethGetTransactionCount == null) {
|
||||
return null;
|
||||
}
|
||||
nonce = ethGetTransactionCount.getTransactionCount();
|
||||
// 手续费
|
||||
// BigInteger gasPrice;
|
||||
// EthGasPrice ethGasPrice = web3j.ethGasPrice().sendAsync().get();
|
||||
// if (ethGasPrice == null) {
|
||||
// return null;
|
||||
// }
|
||||
// gasPrice = ethGasPrice.getGasPrice();
|
||||
BigInteger gasPrice = null;
|
||||
switch (gasType) {
|
||||
case GasOracle.GAS_PRICE_NORMAL:
|
||||
gasPrice = etherscanService.getGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
case GasOracle.GAS_PRICE_FAST:
|
||||
gasPrice = etherscanService.getFastGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
case GasOracle.GAS_PRICE_SUPER:
|
||||
gasPrice = etherscanService.getDoubleFastGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
case GasOracle.GAS_PRICE_TEN_TIMES:
|
||||
gasPrice = etherscanService.getTenTimesGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
case GasOracle.GAS_PRICE_TWENTY_TIMES:
|
||||
gasPrice = etherscanService.getTwentyTimesGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
default:// 转账默认1倍系数
|
||||
gasPrice = etherscanService.getFastGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
}
|
||||
|
||||
// BigInteger gasPrice=etherscanService.getFastGasOracle().getFastGasPriceGWei();
|
||||
if (gasPrice == null) {
|
||||
log.error("ERC20 USDT,参数,from:{},to:{},value:{},operaAddress:{},获取Gas值错误",
|
||||
new Object[] { from, to, value, operaAddress });
|
||||
return new TransactionResponseDto(TransactionResponseDto.CODE_LOCAL_FAIL + "", "获取gasPrice值错误");
|
||||
}
|
||||
// System.out.println("gasPrice:"+gasPrice);
|
||||
// 注意手续费的设置,这块很容易遇到问题
|
||||
// BigInteger gasLimit = BigInteger.valueOf(100000L);
|
||||
// BigInteger gasLimit = gasLimit();
|
||||
|
||||
BigInteger val = new BigDecimal(value).multiply(new BigDecimal("10").pow(decimal)).toBigInteger();// 单位换算
|
||||
Function function = new Function("transferFrom",
|
||||
Arrays.asList(new Address(from), new Address(to), new Uint256(val)),
|
||||
Collections.singletonList(new TypeReference<Bool>() {
|
||||
}));
|
||||
// 创建交易对象
|
||||
String encodedFunction = FunctionEncoder.encode(function);
|
||||
|
||||
// gas预估值
|
||||
// Transaction ethCallTransaction = Transaction.createEthCallTransaction(operaAddress, contractAddress,
|
||||
// encodedFunction);
|
||||
// BigInteger amountUsed = web3j.ethEstimateGas(ethCallTransaction).send().getAmountUsed();
|
||||
// gas预估值刚好,速度不快,所以加上10000保证速度
|
||||
|
||||
// BigInteger gasLimit = amountUsed.add(BigInteger.valueOf(10000L));
|
||||
// BigInteger gasLimit = amountUsed.add(BigInteger.valueOf((long) (amountUsed.doubleValue() * 0.7)));
|
||||
// BigInteger gasLimit = amountUsed
|
||||
// .add(BigInteger.valueOf((long) (amountUsed.doubleValue() * gasLimitAddPercent())));
|
||||
BigInteger gasLimit = gasLimitByTransferFrom(value, from, to, operaAddress);
|
||||
if (gasLimit == null) {
|
||||
log.error("ERC20 USDT,参数,from:{},to:{},value:{},operaAddress:{},获取GasLimit值错误",
|
||||
new Object[] { from, to, value, operaAddress });
|
||||
return new TransactionResponseDto(TransactionResponseDto.CODE_LOCAL_FAIL + "",
|
||||
"授权转账失败,请检查手续费是否充足或其他错误导致");
|
||||
}
|
||||
// System.out.println("gasLimit:"+gasLimit);
|
||||
RawTransaction rawTransaction = RawTransaction.createTransaction(nonce, gasPrice, gasLimit, contractAddress,
|
||||
encodedFunction);
|
||||
|
||||
// 进行签名操作
|
||||
byte[] signMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
|
||||
String hexValue = Numeric.toHexString(signMessage);
|
||||
// 发起交易
|
||||
EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).sendAsync().get();
|
||||
String hash = ethSendTransaction.getTransactionHash();
|
||||
if (hash != null) {
|
||||
// 执行业务
|
||||
// System.out.printf("执行成功:" + hash);
|
||||
return new TransactionResponseDto(hash);
|
||||
} else {
|
||||
return new TransactionResponseDto(ethSendTransaction.getError().getCode() + "",
|
||||
ethSendTransaction.getError().getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 报错应进行错误处理
|
||||
e.printStackTrace();
|
||||
log.error("ERC20 USDT,参数,from:{},to:{},value:{},operaAddress:{},授权转账异常==>e:" + e,
|
||||
new Object[] { from, to, value, operaAddress });
|
||||
return new TransactionResponseDto(TransactionResponseDto.CODE_LOCAL_FAIL + "", "授权转账失败,请检查手续费是否充足或其他错误导致");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*
|
||||
* @param from 发起地址
|
||||
* @param to 收款地址
|
||||
* @param value 金额
|
||||
* @param operaPrivateKey 发起地址私钥
|
||||
* @param gasType gasPrice类型
|
||||
* @return
|
||||
*/
|
||||
public TransactionResponseDto tokenTrans(String from, String to, String value, String operaPrivateKey,
|
||||
String gasType) {
|
||||
String contractAddress = "0xdac17f958d2ee523a2206206994597c13d831ec7";
|
||||
int decimal = 6;
|
||||
|
||||
try {
|
||||
Web3j web3j = buildWeb3j();
|
||||
// 转账的凭证,需要传入私钥
|
||||
Credentials credentials = Credentials.create(operaPrivateKey);
|
||||
// 获取交易笔数
|
||||
BigInteger nonce;
|
||||
EthGetTransactionCount ethGetTransactionCount = web3j
|
||||
.ethGetTransactionCount(from, DefaultBlockParameterName.PENDING).send();
|
||||
if (ethGetTransactionCount == null) {
|
||||
return null;
|
||||
}
|
||||
nonce = ethGetTransactionCount.getTransactionCount();
|
||||
// 手续费
|
||||
// BigInteger gasPrice;
|
||||
// EthGasPrice ethGasPrice = web3j.ethGasPrice().sendAsync().get();
|
||||
// if (ethGasPrice == null) {
|
||||
// return null;
|
||||
// }
|
||||
// gasPrice = ethGasPrice.getGasPrice();
|
||||
BigInteger gasPrice = null;
|
||||
switch (gasType) {
|
||||
case GasOracle.GAS_PRICE_NORMAL:
|
||||
gasPrice = etherscanService.getGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
case GasOracle.GAS_PRICE_FAST:
|
||||
gasPrice = etherscanService.getFastGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
case GasOracle.GAS_PRICE_SUPER:
|
||||
gasPrice = etherscanService.getDoubleFastGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
case GasOracle.GAS_PRICE_TEN_TIMES:
|
||||
gasPrice = etherscanService.getTenTimesGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
case GasOracle.GAS_PRICE_TWENTY_TIMES:
|
||||
gasPrice = etherscanService.getTwentyTimesGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
default:// 转账默认1倍系数
|
||||
gasPrice = etherscanService.getFastGasOracle().getFastGasPriceGWei();
|
||||
break;
|
||||
}
|
||||
|
||||
// BigInteger gasPrice=etherscanService.getFastGasOracle().getFastGasPriceGWei();
|
||||
if (gasPrice == null) {
|
||||
log.error("ERC20 USDT,参数,from:{},to:{},value:{},获取Gas值错误", new Object[] { from, to, value });
|
||||
return new TransactionResponseDto(TransactionResponseDto.CODE_LOCAL_FAIL + "", "获取gasPrice值错误");
|
||||
}
|
||||
// System.out.println("gasPrice:"+gasPrice);
|
||||
// 注意手续费的设置,这块很容易遇到问题
|
||||
// BigInteger gasLimit = BigInteger.valueOf(100000L);
|
||||
// BigInteger gasLimit = gasLimit();
|
||||
|
||||
BigInteger val = new BigDecimal(value).multiply(new BigDecimal("10").pow(decimal)).toBigInteger();// 单位换算
|
||||
Function function = new Function("transfer", Arrays.asList(new Address(to), new Uint256(val)),
|
||||
Collections.singletonList(new TypeReference<Type>() {
|
||||
}));
|
||||
// 创建交易对象
|
||||
String encodedFunction = FunctionEncoder.encode(function);
|
||||
|
||||
// gas预估值
|
||||
BigInteger gasLimit = gasLimitByTransfer(value, from, to);
|
||||
if (gasLimit == null) {
|
||||
log.error("ERC20 USDT,参数,from:{},to:{},value:{},获取GasLimit值错误", new Object[] { from, to, value });
|
||||
return new TransactionResponseDto(TransactionResponseDto.CODE_LOCAL_FAIL + "",
|
||||
"转账失败,请检查手续费是否充足或其他错误导致");
|
||||
}
|
||||
// System.out.println("gasLimit:"+gasLimit);
|
||||
RawTransaction rawTransaction = RawTransaction.createTransaction(nonce, gasPrice, gasLimit, contractAddress,
|
||||
encodedFunction);
|
||||
|
||||
// 进行签名操作
|
||||
byte[] signMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
|
||||
String hexValue = Numeric.toHexString(signMessage);
|
||||
// 发起交易
|
||||
EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).sendAsync().get();
|
||||
String hash = ethSendTransaction.getTransactionHash();
|
||||
if (hash != null) {
|
||||
// 执行业务
|
||||
// System.out.printf("执行成功:" + hash);
|
||||
return new TransactionResponseDto(hash);
|
||||
} else {
|
||||
return new TransactionResponseDto(ethSendTransaction.getError().getCode() + "",
|
||||
ethSendTransaction.getError().getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 报错应进行错误处理
|
||||
e.printStackTrace();
|
||||
log.error("ERC20 USDT,参数,from:{},to:{},value:{},转账异常==>e:" + e, new Object[] { from, to, value });
|
||||
return new TransactionResponseDto(TransactionResponseDto.CODE_LOCAL_FAIL + "", "转账失败,请检查手续费是否充足或其他错误导致");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gasLimit需要增加的百分比,默认为0.7(即70%),小于0或不存在则都按默认处理
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double gasLimitAddPercent() {
|
||||
try {
|
||||
// 第一次如果没有值就主动赋值
|
||||
if (percent == null) {
|
||||
percent = sysparaService.find("gas_limit_add_percent").getDouble();
|
||||
}
|
||||
// Double percent = sysparaService.find("gas_limit_add_percent").getDouble();
|
||||
if (percent == null || percent.compareTo(0d) < 1) {
|
||||
return 0.7d;
|
||||
}
|
||||
return percent.doubleValue();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
log.error("gasLimitAddPercent 获取gasLimit增加百分比异常,==>e:" + e);
|
||||
return 0.7d;
|
||||
}
|
||||
}
|
||||
|
||||
public BigInteger gasLimit() {
|
||||
BigInteger gasLimit = BigInteger.valueOf(100000L);
|
||||
try {
|
||||
Web3j web3j = buildWeb3j();
|
||||
EthBlock ethBlock = web3j.ethGetBlockByNumber(DefaultBlockParameterName.LATEST, false).send();
|
||||
BigInteger gasUsed = ethBlock.getBlock().getGasUsed();
|
||||
int blockTransLength = ethBlock.getBlock().getTransactions().size();
|
||||
gasLimit = blockTransLength == 0 ? gasLimit : gasUsed.divide(BigInteger.valueOf(blockTransLength));
|
||||
// 设置一个最小值,当小于最小值时 默认最小值
|
||||
gasLimit = gasLimit.compareTo(BigInteger.valueOf(60000L)) < 0 ? BigInteger.valueOf(60000L) : gasLimit;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return gasLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交易的状态
|
||||
*
|
||||
* @param txid
|
||||
* @return 目前已知 1.交易成功 0.交易失败 -1.请求异常(自定义状态码) null.没有交易凭据返回值(可能为pending中,未验证)
|
||||
*/
|
||||
public Integer getEthTxStatus(String txid) {
|
||||
Web3j web3j = buildWeb3j();
|
||||
try {
|
||||
EthGetTransactionReceipt ethGetTransactionReceipt = web3j.ethGetTransactionReceipt(txid).send();
|
||||
Optional<TransactionReceipt> optional = ethGetTransactionReceipt.getTransactionReceipt();
|
||||
if (!optional.isPresent()) {
|
||||
return null;
|
||||
} else {
|
||||
TransactionReceipt transactionReceipt = ethGetTransactionReceipt.getTransactionReceipt().get();
|
||||
BigInteger status = new BigInteger(transactionReceipt.getStatus().replace("0x", ""), 16);
|
||||
return status.intValue();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("hash:{} ,获取状态异常==>e:" + e, new Object[] { txid });
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String operaAddress = "0xC88bA41DA91073B5E3358b6561B41e0aDf10D0B5";
|
||||
String operaPrivateKey = "0x84d3fff8bbb7e8139d8b921ce396820b131ab48a47bb60fb6b865b7b8d132765";
|
||||
// String from = "0xDfF8FCBB24F448442b668a307A5468212d766567";
|
||||
String from2 = "0xCa736B6b4Bd206d31Bd4C92B1D498871E62C3336";
|
||||
// String from3 = "0x2BFc4ddD0192CF5aDF4FcBf6C852c558523580A9";
|
||||
String to = "0xC8148aF4b38d7793277c752b44E1167D5D8A962b";
|
||||
|
||||
Erc20Service erc20Service = new Erc20ServiceImpl();
|
||||
try {
|
||||
// erc20Service.tokenTransfrom(from2,to,"3",operaAddress,operaPrivateKey,Erc20Constanst.ERC20_USDT);
|
||||
// System.out.println(erc20Service.getBalance("0x35D2d03607b9155b42CF673102FE58251AC4F644"));
|
||||
// System.out.println(erc20Service.getEthBalance("0x35D2d03607b9155b42CF673102FE58251AC4F644"));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// System.out.println(
|
||||
// erc20Service.getEthTxStatus("0x9146c0e3ec07ee519acb8068fbb7b3c244a7a61d3fdfae353ff2a9f972adb4ca"));
|
||||
// System.out.println(
|
||||
// erc20Service.getEthTxStatus("0x58131c6804a74ff1862b09571b54ece66743de528e896b1285208dc7e3beac0a"));
|
||||
// URL urlOfClass = Erc20ServiceImpl.class.getClassLoader()
|
||||
// .getResource("org/slf4j/impl/StaticLoggerBinder.class");org.slf4j.spi.LocationAwareLogger.log
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setEtherscanService(EtherscanService etherscanService) {
|
||||
this.etherscanService = etherscanService;
|
||||
}
|
||||
|
||||
}
|
||||
26
dapp/src/project/monitor/etherscan/EtheBalance.java
Executable file
26
dapp/src/project/monitor/etherscan/EtheBalance.java
Executable file
@@ -0,0 +1,26 @@
|
||||
package project.monitor.etherscan;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class EtheBalance implements Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1006723713904722210L;
|
||||
private String account;
|
||||
private Double balance;
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
public Double getBalance() {
|
||||
return balance;
|
||||
}
|
||||
public void setBalance(Double balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
46
dapp/src/project/monitor/etherscan/EtherscanRemoteService.java
Executable file
46
dapp/src/project/monitor/etherscan/EtherscanRemoteService.java
Executable file
@@ -0,0 +1,46 @@
|
||||
package project.monitor.etherscan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EtherscanRemoteService {
|
||||
|
||||
/**
|
||||
* get gasPrice 高中低数值
|
||||
*/
|
||||
public GasOracle getGasOracle();
|
||||
|
||||
/**
|
||||
* get gasPrice 高中低数值 *系数
|
||||
*/
|
||||
public GasOracle getFastGasOracle();
|
||||
|
||||
/**
|
||||
* get gasPrice 高中低数值 *双倍系统
|
||||
*/
|
||||
public GasOracle getDoubleFastGasOracle();
|
||||
/**
|
||||
* get gasPrice 高中低数值 *十倍系统
|
||||
*/
|
||||
public GasOracle getTenTimesGasOracle();
|
||||
/**
|
||||
* get gasPrice 高中低数值 *二十倍系统
|
||||
*/
|
||||
public GasOracle getTwentyTimesGasOracle();
|
||||
/**
|
||||
* 批量地址查询ETH剩余
|
||||
*
|
||||
* @param Addresses 逗号分隔
|
||||
* @return
|
||||
*/
|
||||
public List<EtheBalance> getEtherMultipleBalance(String addresses, int maximum);
|
||||
|
||||
/**
|
||||
* 获取交易列表
|
||||
*
|
||||
* @param address
|
||||
* @param maximum
|
||||
* @return
|
||||
*/
|
||||
public List<Transaction> getListOfTransactions(String address, int maximum);
|
||||
|
||||
}
|
||||
46
dapp/src/project/monitor/etherscan/EtherscanService.java
Executable file
46
dapp/src/project/monitor/etherscan/EtherscanService.java
Executable file
@@ -0,0 +1,46 @@
|
||||
package project.monitor.etherscan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EtherscanService {
|
||||
|
||||
|
||||
/**
|
||||
* 批量地址查询ETH剩余
|
||||
* @param Addresses 逗号分隔
|
||||
* @return
|
||||
*/
|
||||
public List<EtheBalance> getEtherMultipleBalance(String addresses,int maximum);
|
||||
|
||||
/**
|
||||
* 地址的交易记录,授权相关业务使用
|
||||
* @param Address
|
||||
* @return
|
||||
*/
|
||||
public List<Transaction> getListOfTransactions(String address, int maximum);
|
||||
|
||||
/**
|
||||
* get gasPrice 高中低数值 原始值
|
||||
*/
|
||||
public GasOracle getGasOracle();
|
||||
|
||||
|
||||
/**
|
||||
* get gasPrice 高中低数值 *系数
|
||||
*/
|
||||
public GasOracle getFastGasOracle();
|
||||
|
||||
/**
|
||||
* get gasPrice 高中低数值 *双倍系统
|
||||
*/
|
||||
public GasOracle getDoubleFastGasOracle();
|
||||
/**
|
||||
* get gasPrice 高中低数值 *十倍系统
|
||||
*/
|
||||
public GasOracle getTenTimesGasOracle();
|
||||
/**
|
||||
* get gasPrice 高中低数值 *二十倍系统
|
||||
*/
|
||||
public GasOracle getTwentyTimesGasOracle();
|
||||
|
||||
}
|
||||
136
dapp/src/project/monitor/etherscan/GasOracle.java
Executable file
136
dapp/src/project/monitor/etherscan/GasOracle.java
Executable file
@@ -0,0 +1,136 @@
|
||||
package project.monitor.etherscan;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Gwei
|
||||
*
|
||||
* @author User
|
||||
*
|
||||
*/
|
||||
public class GasOracle implements Serializable{
|
||||
/**
|
||||
* 正常速率
|
||||
*/
|
||||
public static final String GAS_PRICE_NORMAL="normal";
|
||||
/**
|
||||
* 一倍系数加成
|
||||
*/
|
||||
public static final String GAS_PRICE_FAST="fast";
|
||||
/**
|
||||
* 双倍系数加成
|
||||
*/
|
||||
public static final String GAS_PRICE_SUPER="super";
|
||||
/**
|
||||
* 十倍系数加成
|
||||
*/
|
||||
public static final String GAS_PRICE_TEN_TIMES="ten_times";
|
||||
/**
|
||||
* 二十倍系数加成
|
||||
*/
|
||||
public static final String GAS_PRICE_TWENTY_TIMES="twenty_times";
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6908340048454924756L;
|
||||
/**
|
||||
* 最慢
|
||||
*/
|
||||
private Double safeGasPrice;
|
||||
/**
|
||||
* 普通
|
||||
*/
|
||||
private Double proposeGasPrice;
|
||||
/**
|
||||
* 最快
|
||||
*/
|
||||
private Double fastGasPrice;
|
||||
|
||||
/**
|
||||
* 建议
|
||||
*/
|
||||
private Double suggestBaseFee;
|
||||
|
||||
/**
|
||||
* 最慢GWei
|
||||
*/
|
||||
private BigInteger safeGasPriceGWei;
|
||||
/**
|
||||
* 普通GWei
|
||||
*/
|
||||
private BigInteger proposeGasPriceGWei;
|
||||
/**
|
||||
* 最快GWei
|
||||
*/
|
||||
private BigInteger fastGasPriceGWei;
|
||||
/**
|
||||
* 建议GWei
|
||||
*/
|
||||
private BigInteger suggestBaseFeeGWei;
|
||||
|
||||
public Double getSafeGasPrice() {
|
||||
return safeGasPrice;
|
||||
}
|
||||
|
||||
public void setSafeGasPrice(Double safeGasPrice) {
|
||||
this.safeGasPrice = safeGasPrice;
|
||||
}
|
||||
|
||||
public Double getProposeGasPrice() {
|
||||
return proposeGasPrice;
|
||||
}
|
||||
|
||||
public void setProposeGasPrice(Double proposeGasPrice) {
|
||||
this.proposeGasPrice = proposeGasPrice;
|
||||
}
|
||||
|
||||
public Double getFastGasPrice() {
|
||||
return fastGasPrice;
|
||||
}
|
||||
|
||||
public void setFastGasPrice(Double fastGasPrice) {
|
||||
this.fastGasPrice = fastGasPrice;
|
||||
}
|
||||
|
||||
public Double getSuggestBaseFee() {
|
||||
return suggestBaseFee;
|
||||
}
|
||||
|
||||
public void setSuggestBaseFee(Double suggestBaseFee) {
|
||||
this.suggestBaseFee = suggestBaseFee;
|
||||
}
|
||||
|
||||
public BigInteger getSafeGasPriceGWei() {
|
||||
return safeGasPriceGWei;
|
||||
}
|
||||
|
||||
public BigInteger getProposeGasPriceGWei() {
|
||||
return proposeGasPriceGWei;
|
||||
}
|
||||
|
||||
public BigInteger getFastGasPriceGWei() {
|
||||
return fastGasPriceGWei;
|
||||
}
|
||||
|
||||
public void setSafeGasPriceGWei(BigInteger safeGasPriceGWei) {
|
||||
this.safeGasPriceGWei = safeGasPriceGWei;
|
||||
}
|
||||
|
||||
public void setProposeGasPriceGWei(BigInteger proposeGasPriceGWei) {
|
||||
this.proposeGasPriceGWei = proposeGasPriceGWei;
|
||||
}
|
||||
|
||||
public void setFastGasPriceGWei(BigInteger fastGasPriceGWei) {
|
||||
this.fastGasPriceGWei = fastGasPriceGWei;
|
||||
}
|
||||
|
||||
public BigInteger getSuggestBaseFeeGWei() {
|
||||
return suggestBaseFeeGWei;
|
||||
}
|
||||
|
||||
public void setSuggestBaseFeeGWei(BigInteger suggestBaseFeeGWei) {
|
||||
this.suggestBaseFeeGWei = suggestBaseFeeGWei;
|
||||
}
|
||||
|
||||
}
|
||||
116
dapp/src/project/monitor/etherscan/InputMethodEnum.java
Executable file
116
dapp/src/project/monitor/etherscan/InputMethodEnum.java
Executable file
@@ -0,0 +1,116 @@
|
||||
package project.monitor.etherscan;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
|
||||
public enum InputMethodEnum {
|
||||
// transfer(address,uint256): 0xa9059cbb
|
||||
//
|
||||
// balanceOf(address):0x70a08231
|
||||
//
|
||||
// decimals():0x313ce567
|
||||
//
|
||||
// allowance(address,address): 0xdd62ed3e
|
||||
//
|
||||
// symbol():0x95d89b41
|
||||
//
|
||||
// totalSupply():0x18160ddd
|
||||
//
|
||||
// name():0x06fdde03
|
||||
//
|
||||
// approve(address,uint256):0x095ea7b3
|
||||
//
|
||||
// transferFrom(address,address,uint256): 0x23b872dd
|
||||
transfer("transfer", "0xa9059cbb"),
|
||||
approve("approve", "0x095ea7b3"),
|
||||
transferFrom("transferFrom", "0x23b872dd");
|
||||
|
||||
private String name;
|
||||
private String code;
|
||||
|
||||
private InputMethodEnum(String name, String code) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public static InputMethodEnum fromCode(String code) {
|
||||
if (!StringUtils.isEmptyString(code)) {
|
||||
InputMethodEnum[] var1 = values();
|
||||
int var2 = var1.length;
|
||||
|
||||
for(int var3 = 0; var3 < var2; ++var3) {
|
||||
InputMethodEnum unit = var1[var3];
|
||||
if (code.equalsIgnoreCase(unit.code)) {
|
||||
return unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public static InputMethodEnum fromInput(String input) {
|
||||
return fromCode(getMethodFromeInpuData(input));
|
||||
}
|
||||
public static Map<String,Object> inputValueFromCode(String input){
|
||||
if(StringUtils.isEmptyString(input)) {
|
||||
return null;
|
||||
}
|
||||
Map<String,Object> map = new HashMap<String, Object>();
|
||||
InputMethodEnum inputMethodEnum = fromCode(getMethodFromeInpuData(input));
|
||||
if(inputMethodEnum==null) {
|
||||
return null;
|
||||
}
|
||||
switch (inputMethodEnum) {//其余的暂未解析,等必要时处理
|
||||
case approve:
|
||||
map.put("method", "approve");
|
||||
//授权地址
|
||||
map.put("approve_address", getAddressFromInputData(input));
|
||||
//授权金额(具体的金额换算根据合约decimal决定)
|
||||
map.put("approve_value", new BigInteger(input.substring(74,138),16).longValue());
|
||||
break;
|
||||
case transfer:
|
||||
map.put("method", "transfer");
|
||||
//转账地址
|
||||
map.put("transfer_to_address", getAddressFromInputData(input));
|
||||
//转账金额(具体的金额换算根据合约decimal决定)
|
||||
map.put("transfer_value", new BigInteger(input.substring(74,138),16).longValue());
|
||||
break;
|
||||
case transferFrom:
|
||||
map.put("method", "transferFrom");
|
||||
//转账发起地址
|
||||
map.put("transferfrom_from_address", getAddressFromInputData(input));
|
||||
//到账地址
|
||||
map.put("transferfrom_to_address", "0x"+input.substring(98,138));
|
||||
//转账金额(具体的金额换算根据合约decimal决定)
|
||||
map.put("transferfrom_value", new BigInteger(input.substring(138,202),16).longValue());
|
||||
break;
|
||||
default:
|
||||
map.put("method", "");
|
||||
break;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public static String getMethodFromeInpuData(String inputData){
|
||||
if(StringUtils.isEmptyString(inputData)){
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
return inputData.substring(0,10);
|
||||
}catch (Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static String getAddressFromInputData(String inputData){
|
||||
if(StringUtils.isEmptyString(inputData)){
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
return "0x"+inputData.substring(34,74);
|
||||
}catch (Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
153
dapp/src/project/monitor/etherscan/Transaction.java
Executable file
153
dapp/src/project/monitor/etherscan/Transaction.java
Executable file
@@ -0,0 +1,153 @@
|
||||
package project.monitor.etherscan;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Transaction implements Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3269375455620589242L;
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private String timeStamp;
|
||||
/**
|
||||
* 交易的哈希值
|
||||
*/
|
||||
private String hash;
|
||||
private Integer nonce;
|
||||
private String from;
|
||||
private String to;
|
||||
/**
|
||||
* 交易量,单位为Wei.(单位是ETHER)
|
||||
*/
|
||||
private Double value;
|
||||
/**
|
||||
* 0无数,1发生错误
|
||||
*/
|
||||
private String isError;
|
||||
/**
|
||||
* 交易状态,要进一步确认值 含义
|
||||
* 1.成功,0.失败 ,"":pedding(未验证)
|
||||
*/
|
||||
private String txreceipt_status;
|
||||
/**
|
||||
* 节点地址,固定的
|
||||
*/
|
||||
private String contractAddress;
|
||||
|
||||
private String input;
|
||||
/**
|
||||
* input里对应的合约method
|
||||
*/
|
||||
private String inputMethod;
|
||||
|
||||
/**
|
||||
* input根据不同的method解析出对应的值
|
||||
* 公有属性 method,
|
||||
* <p> 授权:approve</br>
|
||||
授权地址 key:approve_address</br>
|
||||
授权金额(具体的金额换算根据合约decimal决定) approve_value</br>
|
||||
* </p>
|
||||
*/
|
||||
private Map<String,Object> inputValueMap = new HashMap<String, Object>();
|
||||
|
||||
public String getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(String timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public Integer getNonce() {
|
||||
return nonce;
|
||||
}
|
||||
|
||||
public void setNonce(Integer nonce) {
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public Double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getContractAddress() {
|
||||
return contractAddress;
|
||||
}
|
||||
|
||||
public void setContractAddress(String contractAddress) {
|
||||
this.contractAddress = contractAddress;
|
||||
}
|
||||
|
||||
public String getIsError() {
|
||||
return isError;
|
||||
}
|
||||
|
||||
public void setIsError(String isError) {
|
||||
this.isError = isError;
|
||||
}
|
||||
|
||||
public String getTxreceipt_status() {
|
||||
return txreceipt_status;
|
||||
}
|
||||
|
||||
public void setTxreceipt_status(String txreceipt_status) {
|
||||
this.txreceipt_status = txreceipt_status;
|
||||
}
|
||||
|
||||
public String getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public void setInput(String input) {
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
public String getInputMethod() {
|
||||
return inputMethod;
|
||||
}
|
||||
|
||||
public Map<String, Object> getInputValueMap() {
|
||||
return inputValueMap;
|
||||
}
|
||||
|
||||
public void setInputMethod(String inputMethod) {
|
||||
this.inputMethod = inputMethod;
|
||||
}
|
||||
|
||||
public void setInputValueMap(Map<String, Object> inputValueMap) {
|
||||
this.inputValueMap = inputValueMap;
|
||||
}
|
||||
|
||||
}
|
||||
341
dapp/src/project/monitor/etherscan/http/HttpHelper.java
Executable file
341
dapp/src/project/monitor/etherscan/http/HttpHelper.java
Executable file
@@ -0,0 +1,341 @@
|
||||
package project.monitor.etherscan.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpRequest;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.CookieStore;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.apache.http.config.Registry;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.HttpConnectionFactory;
|
||||
import org.apache.http.conn.ManagedHttpClientConnection;
|
||||
import org.apache.http.conn.routing.HttpRoute;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.cookie.Cookie;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.BasicCookieStore;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.conn.DefaultHttpResponseParserFactory;
|
||||
import org.apache.http.impl.conn.ManagedHttpClientConnectionFactory;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.impl.conn.SystemDefaultDnsResolver;
|
||||
import org.apache.http.impl.io.DefaultHttpRequestWriterFactory;
|
||||
import org.apache.http.io.HttpMessageWriterFactory;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.protocol.BasicHttpContext;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
import org.apache.http.ssl.SSLContexts;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* <p/>
|
||||
* //请求信息类型MIME每种响应类型的输出(普通文本、html 和 XML,json)。允许的响应类型应当匹配资源类中生成的 MIME 类型
|
||||
* //资源类生成的 MIME 类型应当匹配一种可接受的 MIME 类型。如果生成的 MIME 类型和可接受的 MIME 类型不 匹配,那么将 //生成
|
||||
* com.sun.jersey.api.client.UniformInterfaceException。例如,将可接受的 MIME 类型设置为
|
||||
* text/xml,而将 //生成的 MIME 类型设置为 application/xml。将生成 UniformInterfaceException。
|
||||
* //代理: new HttpHost("10.0.0.172", 80, "http");
|
||||
* <p/>
|
||||
*/
|
||||
public class HttpHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpHelper.class);
|
||||
private static Map<String, List<Cookie>> cookiesMap = Collections
|
||||
.synchronizedMap(new HashMap<String, List<Cookie>>());
|
||||
static private HttpClient httpclient;
|
||||
private static Map<String, Map<String, String>> globalParam = new HashMap<String, Map<String, String>>(5);
|
||||
private static Map<String, String> headers = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
RequestConfig config = RequestConfig.copy(RequestConfig.DEFAULT).setConnectionRequestTimeout(30000)
|
||||
.setSocketTimeout(40000).build();
|
||||
SSLContext sslcontext = SSLContexts.createSystemDefault();
|
||||
HttpMessageWriterFactory<HttpRequest> requestWriterFactory = new DefaultHttpRequestWriterFactory();
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE)).build();
|
||||
HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory = new ManagedHttpClientConnectionFactory(
|
||||
requestWriterFactory, new DefaultHttpResponseParserFactory());
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry,
|
||||
connFactory, new SystemDefaultDnsResolver());
|
||||
connManager.setMaxTotal(100);
|
||||
connManager.setDefaultMaxPerRoute(100);
|
||||
httpclient = HttpClientBuilder.create().setConnectionManager(connManager).setDefaultRequestConfig(config)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过HTTP协议访问站点,并且将返回的数据转换成json对象 注意 对方返回的数据最外层对象必须是单个对象
|
||||
*
|
||||
* @param url
|
||||
* @param param
|
||||
* @param method
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getJSONFromHttp(String url, Map<String, Object> param, HttpMethodType method)
|
||||
throws RuntimeException {
|
||||
String rs;
|
||||
switch (method) {
|
||||
case GET: {
|
||||
rs = sendGetHttp(url, param);
|
||||
break;
|
||||
}
|
||||
case POST: {
|
||||
rs = sendPostHttp(url, param, false);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new IllegalArgumentException("HTTP访问方式设置有误");
|
||||
}
|
||||
}
|
||||
logger.debug("return is:" + rs);
|
||||
return rs == null || "".equals(rs) ? null : rs;
|
||||
}
|
||||
|
||||
public static String sendHttp(String url, Map<String, Object> param, HttpMethodType method)
|
||||
throws RuntimeException {
|
||||
switch (method) {
|
||||
case GET: {
|
||||
return sendGetHttp(url, param);
|
||||
}
|
||||
case POST: {
|
||||
return sendPostHttp(url, param, false);
|
||||
}
|
||||
default:
|
||||
throw new IllegalArgumentException("参数中的HTTP访问方式有误,只支持GET、POST、FILE");
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern paramPat = Pattern.compile("([^&]+)=([^&]+)");
|
||||
|
||||
/**
|
||||
* 发送一个HTTP协议的GET请求
|
||||
*
|
||||
* @param url
|
||||
* @param param
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String sendGetHttp(String url, Map<String, Object> param) throws RuntimeException {
|
||||
StringBuilder parmStr = new StringBuilder();
|
||||
if (null != param && !param.isEmpty()) {
|
||||
List<NameValuePair> parm = new ArrayList<NameValuePair>(param.size());
|
||||
for (Map.Entry<String, Object> paramEntity : param.entrySet()) {
|
||||
Object value = paramEntity.getValue();
|
||||
if (null != value && !StringUtils.isBlank(value.toString())) {
|
||||
parm.add(new BasicNameValuePair(paramEntity.getKey(), value.toString()));
|
||||
}
|
||||
}
|
||||
parmStr.append(URLEncodedUtils.format(parm, "UTF-8"));
|
||||
}
|
||||
return sendGetHttp(url, parmStr.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送一个HTTP协议的GET请求
|
||||
*
|
||||
* @param url
|
||||
* @param param
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String sendGetHttp(String url, String param) throws RuntimeException {
|
||||
HttpContext localContext = new BasicHttpContext();
|
||||
setCookie(localContext, url);
|
||||
if (!StringUtils.isBlank(param))
|
||||
url = url + ((url.indexOf("?") > 0) ? "&" + param : "?" + param);
|
||||
url = appendGlobalParam(url, param);
|
||||
// logger.debug("远程URL:{}", url);
|
||||
// 创建HttpGet对象
|
||||
HttpGet request = new HttpGet(url);
|
||||
setHeader(request);
|
||||
String result;
|
||||
try {
|
||||
HttpResponse response = httpclient.execute(request, localContext);
|
||||
result = responseProc(response);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
request.reset();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String appendGlobalParam(String url, Object param) {
|
||||
for (Map.Entry<String, Map<String, String>> stringMapEntry : globalParam.entrySet()) {
|
||||
if (url.startsWith(stringMapEntry.getKey())) {
|
||||
for (Map.Entry<String, String> paramEntry : stringMapEntry.getValue().entrySet()) {
|
||||
logger.debug("HTTP处理过程发送了参数:" + paramEntry.getKey() + "|" + paramEntry.getValue());
|
||||
if (param instanceof List)
|
||||
((List) param).add(new BasicNameValuePair(paramEntry.getKey(), paramEntry.getValue()));
|
||||
else
|
||||
url += "&" + paramEntry.getKey() + "=" + paramEntry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送一个HTTP协议的POST请求
|
||||
*
|
||||
* @param url
|
||||
* @param param
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String sendPostHttp(String url, Map<String, Object> param, boolean postTxtBody)
|
||||
throws RuntimeException {
|
||||
HttpContext localContext = new BasicHttpContext();
|
||||
setCookie(localContext, url);
|
||||
// logger.debug("远程URL:{}", url);
|
||||
HttpPost request = new HttpPost(url);
|
||||
List<NameValuePair> parm = new ArrayList<NameValuePair>();
|
||||
if (null != param && !param.isEmpty())
|
||||
for (Map.Entry<String, Object> paramEntity : param.entrySet()) {
|
||||
Object value = paramEntity.getValue();
|
||||
if (null != value && !StringUtils.isBlank(value.toString())) {
|
||||
logger.debug("HTTP处理过程发送了参数:" + paramEntity.getKey() + "|" + value);
|
||||
parm.add(new BasicNameValuePair(paramEntity.getKey(), value.toString()));
|
||||
}
|
||||
}
|
||||
appendGlobalParam(url, parm);
|
||||
HttpResponse response;
|
||||
try {
|
||||
request.setEntity(generyEntity(parm, "UTF-8", postTxtBody));
|
||||
setHeader(request);
|
||||
response = httpclient.execute(request, localContext);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
String result;
|
||||
try {
|
||||
result = responseProc(response);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
request.reset();
|
||||
}
|
||||
logger.debug("return is:" + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static Pattern urlPrePat = Pattern.compile("https?://([^/]*)?/?");
|
||||
|
||||
private static String getUrlPerfix(String url) {
|
||||
Matcher mat = urlPrePat.matcher(url);
|
||||
if (mat.find())
|
||||
return mat.group(1);
|
||||
return "";
|
||||
}
|
||||
|
||||
private static void setCookie(HttpContext localContext, String url) {
|
||||
String urlPrefix = getUrlPerfix(url);
|
||||
CookieStore cookieStore = new BasicCookieStore();
|
||||
List<Cookie> cookieList = cookiesMap.get(urlPrefix);
|
||||
if (cookieList != null && cookieList.size() > 0) {
|
||||
for (Cookie cookie : cookiesMap.get(urlPrefix)) {
|
||||
cookieStore.addCookie(cookie);
|
||||
}
|
||||
localContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseCookie(HttpClientContext context, String url) {
|
||||
List<Cookie> cookies = context.getCookieStore().getCookies();
|
||||
String urlPrefix = getUrlPerfix(url);
|
||||
List<Cookie> oldCookies = cookiesMap.get(urlPrefix);
|
||||
if (oldCookies != null) {
|
||||
for (Cookie cookie : cookies) {
|
||||
for (Cookie oldCookie : oldCookies) {
|
||||
if (cookie.getName().equals(oldCookie.getName())) {
|
||||
oldCookies.remove(oldCookie);
|
||||
oldCookies.add(cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
cookiesMap.put(urlPrefix, cookies);
|
||||
}
|
||||
|
||||
private static String responseProc(HttpResponse response) throws IOException {
|
||||
switch (response.getStatusLine().getStatusCode()) {
|
||||
case 200: {
|
||||
HttpEntity entity = response.getEntity();
|
||||
return EntityUtils.toString(entity, "UTF-8");
|
||||
}
|
||||
case 302: {
|
||||
return sendGetHttp(response.getFirstHeader("location").getValue(), "");
|
||||
}
|
||||
case 303:
|
||||
case 304: {
|
||||
Header[] headers = response.getAllHeaders();
|
||||
for (Header header : headers) {
|
||||
logger.debug(header.getName() + " : " + header.getValue());
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw new HttpResponseException(response.getStatusLine().getStatusCode(),
|
||||
response.getStatusLine().getReasonPhrase());
|
||||
}
|
||||
}
|
||||
|
||||
public static void setHeader(HttpRequestBase request) {
|
||||
for (Map.Entry<String, String> headerEntry : headers.entrySet()) {
|
||||
request.setHeader(headerEntry.getKey(), headerEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpEntity generyEntity(List<NameValuePair> parm, String encode, boolean postTxtBody)
|
||||
throws Exception {
|
||||
if (postTxtBody && parm.size() > 0) {
|
||||
JSONObject paramJson = new JSONObject();
|
||||
for (NameValuePair nameValuePair : parm) {
|
||||
paramJson.put(nameValuePair.getName(), nameValuePair.getValue());
|
||||
}
|
||||
return (new StringEntity(paramJson.toString(), encode));
|
||||
} else
|
||||
return (new UrlEncodedFormEntity(parm, encode));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
byte[] bytes = new byte[1];
|
||||
if (bytes instanceof byte[]) {
|
||||
// System.out.println(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
5
dapp/src/project/monitor/etherscan/http/HttpMethodType.java
Executable file
5
dapp/src/project/monitor/etherscan/http/HttpMethodType.java
Executable file
@@ -0,0 +1,5 @@
|
||||
package project.monitor.etherscan.http;
|
||||
|
||||
public enum HttpMethodType {
|
||||
GET, POST, FILE
|
||||
}
|
||||
423
dapp/src/project/monitor/etherscan/internal/EtherscanServiceImpl.java
Executable file
423
dapp/src/project/monitor/etherscan/internal/EtherscanServiceImpl.java
Executable file
@@ -0,0 +1,423 @@
|
||||
package project.monitor.etherscan.internal;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.web3j.utils.Convert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.JsonUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.util.ThreadUtils;
|
||||
import project.hobi.http.HttpHelper;
|
||||
import project.hobi.http.HttpMethodType;
|
||||
import project.monitor.etherscan.EtheBalance;
|
||||
import project.monitor.etherscan.EtherscanRemoteService;
|
||||
import project.monitor.etherscan.EtherscanService;
|
||||
import project.monitor.etherscan.GasOracle;
|
||||
import project.monitor.etherscan.InputMethodEnum;
|
||||
import project.monitor.etherscan.Transaction;
|
||||
import project.syspara.SysparaService;
|
||||
|
||||
public class EtherscanServiceImpl implements InitializingBean, EtherscanService, EtherscanRemoteService {
|
||||
private static final Log logger = LogFactory.getLog(EtherscanServiceImpl.class);
|
||||
|
||||
/**
|
||||
* 接口调用间隔(毫秒)
|
||||
*/
|
||||
private int interval = 200;
|
||||
private int sleep = 200;
|
||||
/**
|
||||
* 最后一次访问接口时间
|
||||
*/
|
||||
private volatile Date last_time = new Date();
|
||||
|
||||
private volatile boolean lock = false;
|
||||
|
||||
private String url = "https://api.etherscan.io/api";
|
||||
|
||||
private String apikey;
|
||||
|
||||
private int maximum_limit = 50;
|
||||
|
||||
private GasOracle gasOracle;
|
||||
|
||||
private Date gasOracle_last_time = new Date();
|
||||
|
||||
private SysparaService sysparaService;
|
||||
/**
|
||||
* gasPrice * 倍数
|
||||
*/
|
||||
private Double price_percent = null;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
url = sysparaService.findByDB("etherscan_url").getValue();
|
||||
apikey = sysparaService.findByDB("etherscan_apikey").getValue();
|
||||
price_percent = sysparaService.findByDB("gas_price_add_percent").getDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EtheBalance> getEtherMultipleBalance(String addresses, int maximum) {
|
||||
List<EtheBalance> list = new ArrayList<EtheBalance>();
|
||||
|
||||
boolean current_lock = false;
|
||||
if (lock || (new Date().getTime() - last_time.getTime()) < interval) {
|
||||
ThreadUtils.sleep(sleep);
|
||||
if (maximum >= maximum_limit) {
|
||||
return list;
|
||||
} else {
|
||||
return getEtherMultipleBalance(addresses, ++maximum);
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
current_lock = true;
|
||||
lock = true;
|
||||
|
||||
Map<String, Object> param = new HashMap<String, Object>();
|
||||
param.put("module", "account");
|
||||
param.put("action", "balancemulti");
|
||||
param.put("address", addresses);
|
||||
param.put("tag", "latest");
|
||||
param.put("apikey", apikey);
|
||||
|
||||
String result = HttpHelper.getJSONFromHttp(url, param, HttpMethodType.GET);
|
||||
JSONObject resultJson = JSON.parseObject(result);
|
||||
String status = resultJson.getString("status");
|
||||
if ("1".equals(status)) {
|
||||
JSONArray dataArray = resultJson.getJSONArray("result");
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
JSONObject json = dataArray.getJSONObject(i);
|
||||
|
||||
EtheBalance item = new EtheBalance();
|
||||
|
||||
item.setAccount(json.getString("account"));
|
||||
/**
|
||||
* 要确认一下这个单位,进行ETH转换
|
||||
*/
|
||||
// item.setBalance(json.getDouble("balance"));
|
||||
item.setBalance(Convert.fromWei(json.getString("balance"), Convert.Unit.ETHER).doubleValue());
|
||||
list.add(item);
|
||||
}
|
||||
} else {
|
||||
logger.error(" addresses:{"+addresses+"},getEtherMultipleBalance()error, resultJson [ " + resultJson.toJSONString() + " ]");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("error", e);
|
||||
} finally {
|
||||
if (current_lock) {
|
||||
lock = false;
|
||||
last_time = new Date();
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public List<Transaction> getListOfTransactions(String address, int maximum) {
|
||||
List<Transaction> list = new ArrayList<Transaction>();
|
||||
|
||||
boolean current_lock = false;
|
||||
if (lock || (new Date().getTime() - last_time.getTime()) < interval) {
|
||||
ThreadUtils.sleep(sleep);
|
||||
if (maximum >= maximum_limit) {
|
||||
return list;
|
||||
} else {
|
||||
return getListOfTransactions(address, ++maximum);
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
current_lock = true;
|
||||
lock = true;
|
||||
|
||||
Map<String, Object> param = new HashMap<String, Object>();
|
||||
param.put("module", "account");
|
||||
param.put("action", "txlist");
|
||||
param.put("address", address);
|
||||
param.put("startblock", "0");
|
||||
param.put("endblock", "99999999");
|
||||
param.put("page", "1");
|
||||
param.put("offset", "10000");
|
||||
param.put("sort", "asc");
|
||||
param.put("apikey", apikey);
|
||||
|
||||
String result = HttpHelper.getJSONFromHttp(url, param, HttpMethodType.GET);
|
||||
JSONObject resultJson = JSON.parseObject(result);
|
||||
String status = resultJson.getString("status");
|
||||
if ("1".equals(status)) {
|
||||
JSONArray dataArray = resultJson.getJSONArray("result");
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
JSONObject json = dataArray.getJSONObject(i);
|
||||
|
||||
Transaction item = new Transaction();
|
||||
|
||||
item.setTimeStamp(json.getString("timeStamp"));
|
||||
item.setHash(json.getString("hash"));
|
||||
item.setNonce(json.getInteger("nonce"));
|
||||
item.setFrom(json.getString("from"));
|
||||
item.setTo(json.getString("to"));
|
||||
/**
|
||||
* 要确认一下这个单位,进行ETH转换
|
||||
*/
|
||||
// item.setValue(json.getDouble("value"));
|
||||
item.setValue(Convert.fromWei(json.getString("value"), Convert.Unit.ETHER).doubleValue());
|
||||
|
||||
item.setIsError(json.getString("isError"));
|
||||
item.setTxreceipt_status(json.getString("txreceipt_status"));
|
||||
item.setContractAddress(json.getString("contractAddress"));
|
||||
item.setInput(json.getString("input"));
|
||||
if(!StringUtils.isEmptyString(item.getInput())&&!"0x".equals(item.getInput())) {
|
||||
Map<String,Object> map = InputMethodEnum.inputValueFromCode(item.getInput());
|
||||
if(map!=null) {
|
||||
item.setInputMethod(map.get("method")!=null?map.get("method").toString():"");
|
||||
item.setInputValueMap(map);
|
||||
}
|
||||
}
|
||||
list.add(item);
|
||||
}
|
||||
} else {
|
||||
//没有交易记录的不打日志
|
||||
String message = resultJson.getString("message");
|
||||
if(!"No transactions found".equals(message)) {
|
||||
logger.error(" addresses:{"+address+"}, getListOfTransactions()error, resultJson [ " + resultJson.toJSONString() + " ]");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("error", e);
|
||||
} finally {
|
||||
if (current_lock) {
|
||||
lock = false;
|
||||
last_time = new Date();
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GasOracle getGasOracle() {
|
||||
if (gasOracle == null || DateUtils.addSecond(gasOracle_last_time, 10).before(new Date())) {
|
||||
gasOracle = getRemoteGasOracle(0);
|
||||
gasOracle_last_time = new Date();
|
||||
}
|
||||
return gasOracle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasOracle getFastGasOracle() {
|
||||
if (gasOracle == null || DateUtils.addSecond(gasOracle_last_time, 10).before(new Date())) {
|
||||
gasOracle = getRemoteGasOracle(0);
|
||||
gasOracle_last_time = new Date();
|
||||
}
|
||||
GasOracle result = new GasOracle();
|
||||
|
||||
result.setSafeGasPrice(gasOracle.getSafeGasPrice());
|
||||
result.setFastGasPrice(gasOracle.getFastGasPrice());
|
||||
result.setProposeGasPrice(gasOracle.getProposeGasPrice());
|
||||
result.setSuggestBaseFee(gasOracle.getSuggestBaseFee());
|
||||
|
||||
double safeGasPrice = Arith.mul(gasOracle.getSafeGasPrice(), Arith.add(1, price_percent));
|
||||
|
||||
double proposeGasPrice = Arith.mul(gasOracle.getProposeGasPrice(), Arith.add(1, price_percent));
|
||||
|
||||
double fastGasPrice = Arith.mul(gasOracle.getFastGasPrice(), Arith.add(1, price_percent));
|
||||
|
||||
double suggestBaseFee = Arith.mul(gasOracle.getSuggestBaseFee(), Arith.add(1, price_percent));
|
||||
|
||||
result.setSafeGasPriceGWei(
|
||||
Convert.toWei(new Double(safeGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setProposeGasPriceGWei(
|
||||
Convert.toWei(new Double(proposeGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setFastGasPriceGWei(
|
||||
Convert.toWei(new Double(fastGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setSuggestBaseFeeGWei(
|
||||
Convert.toWei(new Double(suggestBaseFee).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasOracle getDoubleFastGasOracle() {
|
||||
if (gasOracle == null || DateUtils.addSecond(gasOracle_last_time, 10).before(new Date())) {
|
||||
gasOracle = getRemoteGasOracle(0);
|
||||
gasOracle_last_time = new Date();
|
||||
}
|
||||
|
||||
GasOracle result = new GasOracle();
|
||||
|
||||
result.setSafeGasPrice(gasOracle.getSafeGasPrice());
|
||||
result.setFastGasPrice(gasOracle.getFastGasPrice());
|
||||
result.setProposeGasPrice(gasOracle.getProposeGasPrice());
|
||||
result.setSuggestBaseFee(gasOracle.getSuggestBaseFee());
|
||||
|
||||
double safeGasPrice = Arith.mul(gasOracle.getSafeGasPrice(), Arith.add(1, Arith.mul(price_percent, 2)));
|
||||
|
||||
double proposeGasPrice = Arith.mul(gasOracle.getProposeGasPrice(), Arith.add(1, Arith.mul(price_percent, 2)));
|
||||
|
||||
double fastGasPrice = Arith.mul(gasOracle.getFastGasPrice(), Arith.add(1, Arith.mul(price_percent, 2)));
|
||||
|
||||
double suggestBaseFee = Arith.mul(gasOracle.getSuggestBaseFee(), Arith.add(1, Arith.mul(price_percent, 2)));
|
||||
|
||||
result.setSafeGasPriceGWei(
|
||||
Convert.toWei(new Double(safeGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setProposeGasPriceGWei(
|
||||
Convert.toWei(new Double(proposeGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setFastGasPriceGWei(
|
||||
Convert.toWei(new Double(fastGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setSuggestBaseFeeGWei(
|
||||
Convert.toWei(new Double(suggestBaseFee).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
|
||||
return result;
|
||||
}
|
||||
public GasOracle getTenTimesGasOracle() {
|
||||
if (gasOracle == null || DateUtils.addSecond(gasOracle_last_time, 10).before(new Date())) {
|
||||
gasOracle = getRemoteGasOracle(0);
|
||||
gasOracle_last_time = new Date();
|
||||
}
|
||||
|
||||
GasOracle result = new GasOracle();
|
||||
|
||||
result.setSafeGasPrice(gasOracle.getSafeGasPrice());
|
||||
result.setFastGasPrice(gasOracle.getFastGasPrice());
|
||||
result.setProposeGasPrice(gasOracle.getProposeGasPrice());
|
||||
result.setSuggestBaseFee(gasOracle.getSuggestBaseFee());
|
||||
|
||||
double safeGasPrice = Arith.mul(gasOracle.getSafeGasPrice(), Arith.add(1, Arith.mul(price_percent, 10)));
|
||||
|
||||
double proposeGasPrice = Arith.mul(gasOracle.getProposeGasPrice(), Arith.add(1, Arith.mul(price_percent, 10)));
|
||||
|
||||
double fastGasPrice = Arith.mul(gasOracle.getFastGasPrice(), Arith.add(1, Arith.mul(price_percent, 10)));
|
||||
|
||||
double suggestBaseFee = Arith.mul(gasOracle.getSuggestBaseFee(), Arith.add(1, Arith.mul(price_percent, 10)));
|
||||
|
||||
result.setSafeGasPriceGWei(
|
||||
Convert.toWei(new Double(safeGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setProposeGasPriceGWei(
|
||||
Convert.toWei(new Double(proposeGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setFastGasPriceGWei(
|
||||
Convert.toWei(new Double(fastGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setSuggestBaseFeeGWei(
|
||||
Convert.toWei(new Double(suggestBaseFee).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public GasOracle getTwentyTimesGasOracle() {
|
||||
if (gasOracle == null || DateUtils.addSecond(gasOracle_last_time, 10).before(new Date())) {
|
||||
gasOracle = getRemoteGasOracle(0);
|
||||
gasOracle_last_time = new Date();
|
||||
}
|
||||
|
||||
GasOracle result = new GasOracle();
|
||||
|
||||
result.setSafeGasPrice(gasOracle.getSafeGasPrice());
|
||||
result.setFastGasPrice(gasOracle.getFastGasPrice());
|
||||
result.setProposeGasPrice(gasOracle.getProposeGasPrice());
|
||||
result.setSuggestBaseFee(gasOracle.getSuggestBaseFee());
|
||||
|
||||
double safeGasPrice = Arith.mul(gasOracle.getSafeGasPrice(), Arith.add(1, Arith.mul(price_percent, 20)));
|
||||
|
||||
double proposeGasPrice = Arith.mul(gasOracle.getProposeGasPrice(), Arith.add(1, Arith.mul(price_percent, 20)));
|
||||
|
||||
double fastGasPrice = Arith.mul(gasOracle.getFastGasPrice(), Arith.add(1, Arith.mul(price_percent, 20)));
|
||||
|
||||
double suggestBaseFee = Arith.mul(gasOracle.getSuggestBaseFee(), Arith.add(1, Arith.mul(price_percent, 20)));
|
||||
|
||||
result.setSafeGasPriceGWei(
|
||||
Convert.toWei(new Double(safeGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setProposeGasPriceGWei(
|
||||
Convert.toWei(new Double(proposeGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setFastGasPriceGWei(
|
||||
Convert.toWei(new Double(fastGasPrice).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
result.setSuggestBaseFeeGWei(
|
||||
Convert.toWei(new Double(suggestBaseFee).toString(), Convert.Unit.GWEI).toBigInteger());
|
||||
|
||||
return result;
|
||||
}
|
||||
public GasOracle getRemoteGasOracle(Integer maximum) {
|
||||
boolean current_lock = false;
|
||||
if (lock || (new Date().getTime() - last_time.getTime()) < interval) {
|
||||
ThreadUtils.sleep(sleep);
|
||||
if (maximum >= maximum_limit) {
|
||||
return null;
|
||||
} else {
|
||||
return getRemoteGasOracle(++maximum);
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
current_lock = true;
|
||||
lock = true;
|
||||
|
||||
Map<String, Object> param = new HashMap<String, Object>();
|
||||
param.put("module", "gastracker");
|
||||
param.put("action", "gasoracle");
|
||||
param.put("apikey", apikey);
|
||||
|
||||
String result = HttpHelper.getJSONFromHttp(url, param, HttpMethodType.GET);
|
||||
JSONObject resultJson = JSON.parseObject(result);
|
||||
String status = resultJson.getString("status");
|
||||
if ("1".equals(status)) {
|
||||
JSONObject json = resultJson.getJSONObject("result");
|
||||
GasOracle gasOracle = new GasOracle();
|
||||
gasOracle.setSafeGasPrice(json.getDouble("SafeGasPrice"));
|
||||
gasOracle.setProposeGasPrice(json.getDouble("ProposeGasPrice"));
|
||||
gasOracle.setFastGasPrice(json.getDouble("FastGasPrice"));
|
||||
gasOracle.setSuggestBaseFee(json.getDouble("suggestBaseFee"));
|
||||
|
||||
gasOracle.setSafeGasPriceGWei(
|
||||
Convert.toWei(new Double(gasOracle.getSafeGasPrice()).toString(), Convert.Unit.GWEI)
|
||||
.toBigInteger());
|
||||
gasOracle.setProposeGasPriceGWei(
|
||||
Convert.toWei(new Double(gasOracle.getProposeGasPrice()).toString(), Convert.Unit.GWEI)
|
||||
.toBigInteger());
|
||||
gasOracle.setFastGasPriceGWei(
|
||||
Convert.toWei(new Double(gasOracle.getFastGasPrice()).toString(), Convert.Unit.GWEI)
|
||||
.toBigInteger());
|
||||
gasOracle.setSuggestBaseFeeGWei(
|
||||
Convert.toWei(new Double(gasOracle.getSuggestBaseFee()).toString(), Convert.Unit.GWEI)
|
||||
.toBigInteger());
|
||||
return gasOracle;
|
||||
} else {
|
||||
logger.error(" getGasOracle()error, resultJson [ " + resultJson.toJSONString() + " ]");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("error", e);
|
||||
} finally {
|
||||
if (current_lock) {
|
||||
lock = false;
|
||||
last_time = new Date();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
}
|
||||
183
dapp/src/project/monitor/internal/AdminAutoMonitorAddressConfigServiceImpl.java
Executable file
183
dapp/src/project/monitor/internal/AdminAutoMonitorAddressConfigServiceImpl.java
Executable file
@@ -0,0 +1,183 @@
|
||||
package project.monitor.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.Endecrypt;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.Constants;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.monitor.AdminAutoMonitorAddressConfigService;
|
||||
import project.monitor.AutoMonitorAddressConfigService;
|
||||
import project.monitor.model.AutoMonitorAddressConfig;
|
||||
import project.syspara.SysparaService;
|
||||
import project.user.googleauth.GoogleAuthService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
public class AdminAutoMonitorAddressConfigServiceImpl extends HibernateDaoSupport implements AdminAutoMonitorAddressConfigService {
|
||||
private Logger log = LoggerFactory.getLogger(AdminAutoMonitorAddressConfigServiceImpl.class);
|
||||
protected PagedQueryDao pagedQueryDao;
|
||||
protected SysparaService sysparaService;
|
||||
protected SecUserService secUserService;
|
||||
protected PasswordEncoder passwordEncoder;
|
||||
protected LogService logService;
|
||||
protected GoogleAuthService googleAuthService;
|
||||
protected AutoMonitorAddressConfigService autoMonitorAddressConfigService;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize,String status,String address) {
|
||||
StringBuffer queryString = new StringBuffer(
|
||||
" SELECT addressConfig.UUID id,addressConfig.ADDRESS address,addressConfig.STATUS status,addressConfig.CREATE_TIME create_time,addressConfig.SORT_INDEX sort_index,addressConfig.APPROVE_NUM approve_num ");
|
||||
queryString.append(" FROM T_AUTO_MONITOR_ADDRESS_CONFIG addressConfig WHERE 1 = 1 ");
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
if (!StringUtils.isNullOrEmpty(status)) {
|
||||
queryString.append(" and addressConfig.STATUS =:status ");
|
||||
parameters.put("status", status);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(address)) {
|
||||
queryString.append(" and addressConfig.ADDRESS LIKE:address ");
|
||||
parameters.put("address","%"+address+"%");
|
||||
}
|
||||
queryString.append(" ORDER BY addressConfig.SORT_INDEX DESC,addressConfig.CREATE_TIME ASC ");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
return page;
|
||||
}
|
||||
|
||||
public void save(AutoMonitorAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode,String key) {
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
// checkGoogleAuthCode(sec,googleAuthCode);
|
||||
checkLoginSafeword(operatorUsername,loginSafeword);
|
||||
|
||||
String private_key=addressConfig.getPrivate_key();
|
||||
Endecrypt endecrypt = new Endecrypt();
|
||||
String private_key_desEncrypt1 = endecrypt.get3DESEncrypt(private_key,key.split("&")[0]);
|
||||
String private_key_desEncrypt2 = endecrypt.get3DESEncrypt(private_key_desEncrypt1,key.split("&")[1]);
|
||||
addressConfig.setPrivate_key(private_key_desEncrypt2);
|
||||
|
||||
addressConfig.setAddress(addressConfig.getAddress().toLowerCase());
|
||||
addressConfig = autoMonitorAddressConfigService.save(addressConfig);
|
||||
saveLog(sec,operatorUsername,"管理员新增被授权地址,地址["+addressConfig.getAddress()+"],ip["+ip+"]");;
|
||||
autoMonitorAddressConfigService.updateEnabledAddress(addressConfig);
|
||||
}
|
||||
public void updatePrivateKey(AutoMonitorAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode,String key) {
|
||||
// checkGoogleAuthCode(superGoogleAuthCode);
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
checkGoogleAuthCode(sec,googleAuthCode);
|
||||
checkLoginSafeword(operatorUsername,loginSafeword);
|
||||
// checkEmailCode(code);
|
||||
String private_key=addressConfig.getPrivate_key();
|
||||
Endecrypt endecrypt = new Endecrypt();
|
||||
String private_key_desEncrypt1 = endecrypt.get3DESEncrypt(private_key,key.split("&")[0]);
|
||||
String private_key_desEncrypt2 = endecrypt.get3DESEncrypt(private_key_desEncrypt1,key.split("&")[1]);
|
||||
addressConfig.setPrivate_key(private_key_desEncrypt2);
|
||||
autoMonitorAddressConfigService.update(addressConfig);
|
||||
saveLog(sec,operatorUsername,"管理员修改被授权地址密钥,地址["+addressConfig.getAddress()+"],ip["+ip+"]");
|
||||
}
|
||||
public void updateEnabledAddress(AutoMonitorAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode) {
|
||||
// checkGoogleAuthCode(superGoogleAuthCode);
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
checkGoogleAuthCode(sec,googleAuthCode);
|
||||
checkLoginSafeword(operatorUsername,loginSafeword);
|
||||
// checkEmailCode(code);
|
||||
autoMonitorAddressConfigService.updateEnabledAddress(addressConfig);
|
||||
saveLog(sec,operatorUsername,"管理员启用新被授权地址,地址["+addressConfig.getAddress()+"],ip["+ip+"]");
|
||||
}
|
||||
public void updateSortIndex(AutoMonitorAddressConfig addressConfig,String operatorUsername,String loginSafeword,String superGoogleAuthCode,String ip,String googleAuthCode) {
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
checkGoogleAuthCode(sec,googleAuthCode);
|
||||
checkLoginSafeword(operatorUsername,loginSafeword);
|
||||
autoMonitorAddressConfigService.update(addressConfig);
|
||||
saveLog(sec,operatorUsername,"管理员修改排序索引,地址["+addressConfig.getAddress()+"],ip["+ip+"]");
|
||||
}
|
||||
/**
|
||||
* 验证谷歌验证码
|
||||
* @param code
|
||||
*/
|
||||
private void checkGoogleAuthCode(String code) {
|
||||
String secret = sysparaService.find("super_google_auth_secret").getValue();
|
||||
boolean checkCode = googleAuthService.checkCode(secret, code);
|
||||
if(!checkCode) {
|
||||
throw new BusinessException("谷歌验证码错误");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 验证谷歌验证码
|
||||
* @param code
|
||||
*/
|
||||
private void checkGoogleAuthCode(SecUser secUser,String code) {
|
||||
if(!secUser.isGoogle_auth_bind()) {
|
||||
throw new BusinessException("请先绑定谷歌验证器");
|
||||
}
|
||||
boolean checkCode = googleAuthService.checkCode(secUser.getGoogle_auth_secret(), code);
|
||||
if(!checkCode) {
|
||||
throw new BusinessException("谷歌验证码错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
* @param operatorUsername
|
||||
* @param loginSafeword
|
||||
*/
|
||||
private void checkLoginSafeword(String operatorUsername,String loginSafeword) {
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
String sysSafeword = sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("登录人资金密码错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveLog(SecUser secUser, String operator,String context) {
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setOperator(operator);
|
||||
log.setUsername(secUser.getUsername());
|
||||
log.setPartyId(secUser.getPartyId());
|
||||
log.setLog(context);
|
||||
log.setCreateTime(new Date());
|
||||
logService.saveSync(log);
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
public void setGoogleAuthService(GoogleAuthService googleAuthService) {
|
||||
this.googleAuthService = googleAuthService;
|
||||
}
|
||||
|
||||
public void setAutoMonitorAddressConfigService(AutoMonitorAddressConfigService autoMonitorAddressConfigService) {
|
||||
this.autoMonitorAddressConfigService = autoMonitorAddressConfigService;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package project.monitor.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.monitor.AdminAutoMonitorAutoTransferFromConfigService;
|
||||
import project.party.recom.UserRecomService;
|
||||
|
||||
public class AdminAutoMonitorAutoTransferFromConfigServiceImpl extends HibernateDaoSupport implements AdminAutoMonitorAutoTransferFromConfigService {
|
||||
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private UserRecomService userRecomService;
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize,String username, String loginPartyId) {
|
||||
StringBuffer queryString = new StringBuffer(
|
||||
" SELECT auto_config.UUID id,auto_config.PARTY_ID party_id,auto_config.STATUS status,auto_config.ETH_COLLECT_BUTTON eth_collect_button,auto_config.USDT_THRESHOLD usdt_threshold,auto_config.TYPE type,"
|
||||
+ " auto_config.ENABLED_ETH_ADD enabled_eth_add,auto_config.ENABLED_USDT_THRESHOLD enabled_usdt_threshold,auto_config.ENABLED_CANCEL enabled_cancel, ");
|
||||
|
||||
queryString.append(" party.USERNAME username,party.ROLENAME rolename,party.USERCODE usercode,party_parent.USERNAME username_parent ");
|
||||
queryString.append(" FROM ");
|
||||
queryString.append(
|
||||
" T_AUTO_MONITOR_AUTO_TRANSFER_FROM_CONFIG auto_config "
|
||||
+ "LEFT JOIN PAT_PARTY party ON auto_config.PARTY_ID = party.UUID "
|
||||
+ " LEFT JOIN PAT_USER_RECOM user ON user.PARTY_ID = party.UUID "
|
||||
+ " LEFT JOIN PAT_PARTY party_parent ON user.RECO_ID = party_parent.UUID "
|
||||
+ " ");
|
||||
queryString.append(" WHERE 1=1 ");
|
||||
// queryString.append("OR (auto_config.PARTY_ID is NULL OR auto_config.PARTY_ID='') ");
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
if (!StringUtils.isNullOrEmpty(username)) {
|
||||
queryString.append("AND (party.USERNAME like:username OR party.USERCODE like:username ) ");
|
||||
parameters.put("username", "%" + username + "%");
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
|
||||
List<String> checked_list = this.userRecomService.findChildren(loginPartyId);
|
||||
checked_list.add(loginPartyId);
|
||||
if (checked_list.size() == 0) {
|
||||
return new Page();
|
||||
}
|
||||
// queryString.append(" and party.UUID in(:checked_list)");
|
||||
queryString.append(" and ( party.UUID in(:checked_list) OR (auto_config.PARTY_ID is NULL OR auto_config.PARTY_ID=''))");
|
||||
parameters.put("checked_list", checked_list);
|
||||
}
|
||||
|
||||
queryString.append(" ORDER BY auto_config.UUID ASC ");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
}
|
||||
95
dapp/src/project/monitor/internal/AdminAutoMonitorDAppLogServiceImpl.java
Executable file
95
dapp/src/project/monitor/internal/AdminAutoMonitorDAppLogServiceImpl.java
Executable file
@@ -0,0 +1,95 @@
|
||||
package project.monitor.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.log.AdminLogService;
|
||||
import project.monitor.AdminAutoMonitorDAppLogService;
|
||||
import project.party.recom.UserRecomService;
|
||||
|
||||
public class AdminAutoMonitorDAppLogServiceImpl implements AdminAutoMonitorDAppLogService {
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private UserRecomService userRecomService;
|
||||
|
||||
@Override
|
||||
public Page pagedQueryMoneyLog(int pageNo, int pageSize, String action_para,String name_para,String loginPartyId,String rolename_para,String startTime,String endTime) {
|
||||
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT");
|
||||
queryString.append(" party.USERNAME username,party.ROLENAME rolename,party.USERCODE usercode,party_parent.USERNAME username_parent,");
|
||||
queryString.append(
|
||||
" dapp.UUID dapp_id,dapp.ACTION action,dapp.ORDER_NO order_no,dapp.STATUS status,dapp.AMOUNT amount,dapp.CREATE_TIME create_time,dapp.EXCHANGE_VOLUME exchange_volume ");
|
||||
queryString.append(" FROM");
|
||||
queryString.append(" T_AUTO_MONITOR_DAPP_LOG dapp "
|
||||
+ "LEFT JOIN PAT_PARTY party ON dapp.PARTY_ID = party.UUID "
|
||||
+ " LEFT JOIN PAT_USER_RECOM user ON user.PARTY_ID = party.UUID "
|
||||
+ " LEFT JOIN PAT_PARTY party_parent ON user.RECO_ID = party_parent.UUID "
|
||||
|
||||
+ " ");
|
||||
|
||||
|
||||
queryString.append(" WHERE 1=1");
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(action_para)) {
|
||||
queryString.append(" and dapp.ACTION =:action ");
|
||||
parameters.put("action", action_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append(" and (party.USERNAME =:name OR party.USERCODE=:name ) ");
|
||||
parameters.put("name", name_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(rolename_para)) {
|
||||
queryString.append(" and party.ROLENAME =:rolename");
|
||||
parameters.put("rolename", rolename_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(startTime)) {
|
||||
queryString.append(" AND DATE(dapp.CREATE_TIME) >= DATE(:startTime) ");
|
||||
parameters.put("startTime",DateUtils.toDate(startTime));
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(endTime)) {
|
||||
queryString.append(" AND DATE(dapp.CREATE_TIME) <= DATE(:endTime) ");
|
||||
parameters.put("endTime", DateUtils.toDate(endTime));
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
|
||||
List<String> checked_list = this.userRecomService.findChildren(loginPartyId);
|
||||
checked_list.add(loginPartyId);
|
||||
if (checked_list.size() == 0) {
|
||||
return new Page();
|
||||
}
|
||||
queryString.append(" and party.UUID in(:checked_list)");
|
||||
parameters.put("checked_list", checked_list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
queryString.append(" order by dapp.CREATE_TIME desc,dapp.UUID desc ");
|
||||
|
||||
Page page = pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
149
dapp/src/project/monitor/internal/AdminAutoMonitorIndexServiceImpl.java
Executable file
149
dapp/src/project/monitor/internal/AdminAutoMonitorIndexServiceImpl.java
Executable file
@@ -0,0 +1,149 @@
|
||||
package project.monitor.internal;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.ThreadUtils;
|
||||
//import cn.hutool.core.thread.ThreadUtil;
|
||||
import project.monitor.AdminAutoMonitorIndexService;
|
||||
import project.monitor.AutoMonitorAddressConfigService;
|
||||
import project.monitor.bonus.AutoMonitorSettleAddressConfigService;
|
||||
import project.monitor.bonus.model.SettleAddressConfig;
|
||||
import project.monitor.erc20.service.Erc20RemoteService;
|
||||
import project.monitor.etherscan.EtheBalance;
|
||||
import project.monitor.etherscan.EtherscanRemoteService;
|
||||
import project.monitor.model.AutoMonitorAddressConfig;
|
||||
|
||||
public class AdminAutoMonitorIndexServiceImpl extends HibernateDaoSupport implements AdminAutoMonitorIndexService {
|
||||
private static final Log logger = LogFactory.getLog(AdminAutoMonitorIndexServiceImpl.class);
|
||||
private EtherscanRemoteService etherscanRemoteService;
|
||||
private Erc20RemoteService erc20RemoteService;
|
||||
private AutoMonitorAddressConfigService autoMonitorAddressConfigService;
|
||||
private AutoMonitorSettleAddressConfigService autoMonitorSettleAddressConfigService;
|
||||
|
||||
/**
|
||||
* 间隔(毫秒)
|
||||
*/
|
||||
private long interval = 60*1000*5;
|
||||
|
||||
private volatile Date lastTime = new Date();
|
||||
|
||||
/**
|
||||
* key:地址
|
||||
* value:eth余额
|
||||
*/
|
||||
private Map<String,Double> ethMap = new ConcurrentHashMap<String,Double>();
|
||||
|
||||
/**
|
||||
* key:地址
|
||||
* value:usdt余额
|
||||
*/
|
||||
private Map<String,Double> usdtMap = new ConcurrentHashMap<String,Double>();
|
||||
|
||||
private Double collectAddressUsdt;
|
||||
|
||||
// public void init() {
|
||||
// try {
|
||||
// //spring初始化时未注册zk,通过访问db直接构建
|
||||
//// Map<String, AutoMonitorAddressConfig> cacheAllMap = autoMonitorAddressConfigService.cacheAllMap();
|
||||
//// Set<String> keySet2 = cacheAllMap.keySet();
|
||||
// Set<String> keySet = new HashSet<String>();
|
||||
// List<AutoMonitorAddressConfig> list = getHibernateTemplate().find("FROM AutoMonitorAddressConfig ");
|
||||
// for (AutoMonitorAddressConfig entity : list) {
|
||||
// keySet.add(entity.getAddress());
|
||||
// }
|
||||
// SettleAddressConfig findDefault = autoMonitorSettleAddressConfigService.findDefault();
|
||||
// if(findDefault!=null) {
|
||||
// keySet.add(findDefault.getChannel_address());
|
||||
// loadValue(keySet,findDefault.getChannel_address());
|
||||
// }else {
|
||||
// loadValue(keySet,null);
|
||||
// }
|
||||
// }catch (Exception e) {
|
||||
// // TODO: handle exception
|
||||
// logger.error("AdminAutoMonitorIndexServiceImpl init fail e:{}",e);
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 异步加载余额
|
||||
* @param addresses
|
||||
*/
|
||||
public void loadValue(Collection<String> addresses,String collectAddress) {
|
||||
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
List<EtheBalance> etherMultipleBalance = etherscanRemoteService.getEtherMultipleBalance(String.join(",", addresses), 0);
|
||||
for(EtheBalance etheBalance:etherMultipleBalance) {
|
||||
ethMap.put(etheBalance.getAccount(), etheBalance.getBalance());
|
||||
}
|
||||
|
||||
// if(!StringUtils.isEmpty(collectAddress)) {
|
||||
// collectAddressUsdt = erc20RemoteService.getBalance(collectAddress);
|
||||
// }
|
||||
//数据同步成功时,更新时间
|
||||
lastTime = new Date();
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
logger.error("AdminAutoMonitorIndexServiceImpl loadEthValue fail e:{}",e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Double> getEthMap(List<String> addresses){
|
||||
if (!ethMap.isEmpty()&&(new Date().getTime() - lastTime.getTime()) < interval) {
|
||||
return ethMap;
|
||||
}
|
||||
SettleAddressConfig findDefault = autoMonitorSettleAddressConfigService.findDefault();
|
||||
if(findDefault!=null) {
|
||||
loadValue(addresses,findDefault.getChannel_address());
|
||||
}else {
|
||||
loadValue(addresses,null);
|
||||
}
|
||||
//等待1秒,获取数据,如未获取,下次刷新即可
|
||||
ThreadUtils.sleep(1000);
|
||||
return ethMap;
|
||||
}
|
||||
/**
|
||||
* 归集地址usdt余额
|
||||
* @return
|
||||
*/
|
||||
public Double getCollectAddressUsdt(){
|
||||
return collectAddressUsdt;
|
||||
}
|
||||
public void setEtherscanRemoteService(EtherscanRemoteService etherscanRemoteService) {
|
||||
this.etherscanRemoteService = etherscanRemoteService;
|
||||
}
|
||||
|
||||
public void setAutoMonitorAddressConfigService(AutoMonitorAddressConfigService autoMonitorAddressConfigService) {
|
||||
this.autoMonitorAddressConfigService = autoMonitorAddressConfigService;
|
||||
}
|
||||
|
||||
public void setAutoMonitorSettleAddressConfigService(
|
||||
AutoMonitorSettleAddressConfigService autoMonitorSettleAddressConfigService) {
|
||||
this.autoMonitorSettleAddressConfigService = autoMonitorSettleAddressConfigService;
|
||||
}
|
||||
|
||||
public void setErc20RemoteService(Erc20RemoteService erc20RemoteService) {
|
||||
this.erc20RemoteService = erc20RemoteService;
|
||||
}
|
||||
|
||||
}
|
||||
208
dapp/src/project/monitor/internal/AdminAutoMonitorOrderServiceImpl.java
Executable file
208
dapp/src/project/monitor/internal/AdminAutoMonitorOrderServiceImpl.java
Executable file
@@ -0,0 +1,208 @@
|
||||
package project.monitor.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.monitor.AdminAutoMonitorOrderService;
|
||||
import project.party.recom.UserRecomService;
|
||||
|
||||
public class AdminAutoMonitorOrderServiceImpl extends HibernateDaoSupport
|
||||
implements AdminAutoMonitorOrderService {
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private UserRecomService userRecomService;
|
||||
// private UserRecomService userRecomService;
|
||||
// private PasswordEncoder passwordEncoder;
|
||||
// private RechargeBlockchainService rechargeBlockchainService;
|
||||
//
|
||||
// private LogService logService;
|
||||
// private WalletLogService walletLogService;
|
||||
// private SecUserService secUserService;
|
||||
// private TipService tipService;
|
||||
@Override
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize,String username_para, String succeeded_para,String order_para,String startTime, String endTime,String loginPartyId,String settle_order_no_para,String settle_state_para) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT");
|
||||
queryString.append(" party.USERNAME username ,party.ROLENAME rolename,party.USERCODE usercode, ");
|
||||
queryString.append(" recharge.UUID id,recharge.ORDER_NO order_no, "
|
||||
+ " recharge.CREATED created,recharge.TXN_HASH txn_hash,recharge.VOLUME volume,recharge.MONITOR_ADDRESS monitor_address, recharge.SUCCEEDED succeeded,recharge.ERROR error,");
|
||||
queryString.append(" "
|
||||
+ "recharge.ADDRESS address,recharge.CHANNEL_ADDRESS channel_address, ");
|
||||
queryString.append(" "
|
||||
+ "recharge.SETTLE_TIME settle_time,recharge.SETTLE_ORDER_NO settle_order_no,recharge.SETTLE_AMOUNT settle_amount,recharge.SETTLE_STATE settle_state ");
|
||||
queryString.append(" FROM ");
|
||||
queryString.append(
|
||||
" T_AUTO_MONITOR_ORDER recharge "
|
||||
+ "LEFT JOIN PAT_PARTY party ON recharge.PARTY_ID = party.UUID "
|
||||
+ " ");
|
||||
queryString.append(" WHERE 1=1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(order_para)) {
|
||||
queryString.append(" and recharge.ORDER_NO = :orderNo ");
|
||||
parameters.put("orderNo", order_para);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(username_para)) {
|
||||
queryString.append(" and recharge.ADDRESS =:username_para");
|
||||
parameters.put("username_para", username_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(succeeded_para)) {
|
||||
queryString.append(" and recharge.SUCCEEDED = :succeeded_para ");
|
||||
parameters.put("succeeded_para", succeeded_para);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(settle_order_no_para)) {
|
||||
queryString.append(" and recharge.SETTLE_ORDER_NO =:settle_order_no_para");
|
||||
parameters.put("settle_order_no_para", settle_order_no_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(settle_state_para)) {
|
||||
queryString.append(" and recharge.SETTLE_STATE = :settle_state_para ");
|
||||
parameters.put("settle_state_para", settle_state_para);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(startTime)) {
|
||||
queryString.append(" AND DATE(recharge.CREATED) >= DATE(:startTime) ");
|
||||
parameters.put("startTime",DateUtils.toDate(startTime));
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(endTime)) {
|
||||
queryString.append(" AND DATE(recharge.CREATED) <= DATE(:endTime) ");
|
||||
parameters.put("endTime", DateUtils.toDate(endTime));
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
|
||||
List<String> checked_list = this.userRecomService.findChildren(loginPartyId);
|
||||
checked_list.add(loginPartyId);
|
||||
if (checked_list.size() == 0) {
|
||||
return new Page();
|
||||
}
|
||||
queryString.append(" and party.UUID in(:checked_list)");
|
||||
parameters.put("checked_list", checked_list);
|
||||
}
|
||||
queryString.append(" order by recharge.CREATED desc ");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void saveSucceeded(String order_no, String safeword, String operator_username,double success_amount) {
|
||||
// SecUser sec = this.secUserService.findUserByLoginName(operator_username);
|
||||
// String sysSafeword = sec.getSafeword();
|
||||
//
|
||||
// String safeword_md5 = passwordEncoder.encodePassword(safeword, operator_username);
|
||||
// if (!safeword_md5.equals(sysSafeword)) {
|
||||
// throw new BusinessException("资金密码错误");
|
||||
// }
|
||||
//
|
||||
// rechargeBlockchainService.saveSucceeded(order_no, operator_username,success_amount);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 某个时间后未处理订单数量,没有时间则全部
|
||||
// *
|
||||
// * @param time
|
||||
// * @return
|
||||
// */
|
||||
// public Long getUntreatedCount(Date time, String loginPartyId) {
|
||||
// StringBuffer queryString = new StringBuffer();
|
||||
// queryString.append("SELECT COUNT(*) FROM RechargeBlockchain WHERE succeeded=0 ");
|
||||
// List<Object> para = new ArrayList<Object>();
|
||||
// if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
// String childrensIds = this.userRecomService.findChildrensIds(loginPartyId);
|
||||
// if (StringUtils.isEmptyString(childrensIds)) {
|
||||
// return 0L;
|
||||
// }
|
||||
// queryString.append(" and partyId in (" + childrensIds + ") ");
|
||||
// }
|
||||
// if (null != time) {
|
||||
// queryString.append("AND created > ?");
|
||||
// para.add(time);
|
||||
// }
|
||||
// List find = this.getHibernateTemplate().find(queryString.toString(), para.toArray());
|
||||
// return CollectionUtils.isEmpty(find) ? 0L : find.get(0) == null ? 0L : Long.valueOf(find.get(0).toString());
|
||||
// }
|
||||
//
|
||||
// public RechargeBlockchain get(String id) {
|
||||
// return this.getHibernateTemplate().get(RechargeBlockchain.class, id);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void saveReject(String id, String failure_msg, String userName, String partyId) {
|
||||
// RechargeBlockchain recharge = this.get(id);
|
||||
//
|
||||
// // 通过后不可驳回
|
||||
// if (recharge.getSucceeded() == 2 || recharge.getSucceeded() == 1) {
|
||||
// return;
|
||||
// }
|
||||
// Date date = new Date();
|
||||
// recharge.setReviewTime(date);
|
||||
//
|
||||
// recharge.setSucceeded(2);
|
||||
// recharge.setDescription(failure_msg);
|
||||
// this.getHibernateTemplate().update(recharge);
|
||||
//
|
||||
// WalletLog walletLog = walletLogService.find(Constants.MONEYLOG_CATEGORY_RECHARGE, recharge.getOrder_no());
|
||||
// walletLog.setStatus(recharge.getSucceeded());
|
||||
// walletLogService.update(walletLog);
|
||||
//
|
||||
// SecUser sec = this.secUserService.findUserByPartyId(recharge.getPartyId());
|
||||
//
|
||||
// Log log = new Log();
|
||||
// log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
// log.setExtra(recharge.getOrder_no());
|
||||
// log.setUsername(sec.getUsername());
|
||||
// log.setOperator(userName);
|
||||
// log.setPartyId(partyId);
|
||||
// log.setLog("管理员驳回一笔充值订单。充值订单号[" + recharge.getOrder_no() + "],驳回理由[" + recharge.getDescription() + "]。");
|
||||
//
|
||||
// logService.saveSync(log);
|
||||
// tipService.deleteTip(id);
|
||||
// }
|
||||
//
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
//
|
||||
// public void setUserRecomService(UserRecomService userRecomService) {
|
||||
// this.userRecomService = userRecomService;
|
||||
// }
|
||||
//
|
||||
// public void setRechargeBlockchainService(RechargeBlockchainService rechargeBlockchainService) {
|
||||
// this.rechargeBlockchainService = rechargeBlockchainService;
|
||||
// }
|
||||
//
|
||||
// public void setLogService(LogService logService) {
|
||||
// this.logService = logService;
|
||||
// }
|
||||
//
|
||||
// public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
// this.passwordEncoder = passwordEncoder;
|
||||
// }
|
||||
//
|
||||
// public void setSecUserService(SecUserService secUserService) {
|
||||
// this.secUserService = secUserService;
|
||||
// }
|
||||
//
|
||||
// public void setWalletLogService(WalletLogService walletLogService) {
|
||||
// this.walletLogService = walletLogService;
|
||||
// }
|
||||
//
|
||||
// public void setTipService(TipService tipService) {
|
||||
// this.tipService = tipService;
|
||||
// }
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user