first commit
This commit is contained in:
3
comm/Wallet/WebContent/META-INF/MANIFEST.MF
Executable file
3
comm/Wallet/WebContent/META-INF/MANIFEST.MF
Executable file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
142
comm/Wallet/WebContent/exchangerate_list.jsp
Executable file
142
comm/Wallet/WebContent/exchangerate_list.jsp
Executable file
@@ -0,0 +1,142 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>货币汇率配置</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询条件</div>
|
||||
<div class="panel-body">
|
||||
<s:if test='isResourceAccessible("ADMIN_EXCHANGE_RATE_LIST")'>
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminExchangeRateAction!list.action"
|
||||
method="post" id="queryForm">
|
||||
<input type="hidden" name="pageNo" id="pageNo"
|
||||
value="${param.pageNo}">
|
||||
<div class="col-md-12 col-lg-6">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<s:textfield id="currency" name="currency"
|
||||
cssClass="form-control " placeholder="货币代码" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div class="col-md-12 col-lg-2" >
|
||||
<button type="submit" class="btn btn-default btn-block">查询</button>
|
||||
</div> -->
|
||||
<div class="col-md-12 col-lg-2">
|
||||
<button type="submit" class="btn btn-light btn-block">查询</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</s:if>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- Start Panel -->
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询结果</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>货币</td>
|
||||
<td>汇入汇出</td>
|
||||
<td>汇率</td>
|
||||
<td width="130px"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<s:iterator value="page.elements" status="stat">
|
||||
<tr>
|
||||
<td><s:property value="name" />(<s:property value="currency" />)</td>
|
||||
<td><s:if test='out_or_in=="in"'>汇入</s:if><s:if test='out_or_in=="out"'>汇出</s:if></td>
|
||||
<td><s:property value="rata" /></td>
|
||||
|
||||
<td>
|
||||
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-light">操作</button>
|
||||
<button type="button" class="btn btn-light dropdown-toggle"
|
||||
data-toggle="dropdown" aria-expanded="false">
|
||||
<span class="caret"></span> <span class="sr-only">Toggle
|
||||
Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<s:if test='isResourceAccessible("ADMIN_EXCHANGE_RATE_TOUPDATE")'>
|
||||
<li><a
|
||||
href="<%=basePath%>normal/adminExchangeRateAction!toUpdate.action?id=<s:property value="id" />">修改</a></li>
|
||||
</s:if>
|
||||
</ul>
|
||||
</div>
|
||||
</sec:authorize>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</s:iterator>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<%@ include file="include/page_simple.jsp"%>
|
||||
<nav>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- End Panel -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
109
comm/Wallet/WebContent/exchangerate_update.jsp
Executable file
109
comm/Wallet/WebContent/exchangerate_update.jsp
Executable file
@@ -0,0 +1,109 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>货币汇率配置</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<form action="<%=basePath%>normal/adminExchangeRateAction!list.action" method="post" id="queryForm">
|
||||
<s:hidden name="pageNo" id="pageNo"></s:hidden>
|
||||
</form>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">
|
||||
修改货币汇率
|
||||
<ul class="panel-tools">
|
||||
<li><a class="icon minimise-tool"><i
|
||||
class="fa fa-minus"></i></a></li>
|
||||
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" action="<%=basePath%>normal/adminExchangeRateAction!update.action" method="post" name="mainForm" id="mainForm">
|
||||
<s:hidden name="id" id="id"></s:hidden>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">汇率</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="rata" name="rata" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<s:if test='isResourceAccessible("ADMIN_EXCHANGE_RATE_UPDATE")'>
|
||||
<a href="javascript:goUrl(<s:property value="pageNo" />)" class="btn">取消</a> <a
|
||||
href="javascript:submit()" class="btn btn-default">保存</a>
|
||||
</s:if>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
<s:if test='isResourceAccessible("ADMIN_EXCHANGE_RATE_UPDATE")'>
|
||||
<script type="text/javascript">
|
||||
function submit(){
|
||||
swal({
|
||||
title : "是否保存?",
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
}, function() {
|
||||
document.getElementById("mainForm").submit();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</s:if>
|
||||
</body>
|
||||
</html>
|
||||
131
comm/Wallet/WebContent/recharge_list.jsp
Executable file
131
comm/Wallet/WebContent/recharge_list.jsp
Executable file
@@ -0,0 +1,131 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>充值</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询条件</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminRechargeOrderAction!list.action"
|
||||
method="post" id="queryForm">
|
||||
<input type="hidden" name="pageNo" id="pageNo"
|
||||
value="${param.pageNo}">
|
||||
<div class="col-md-12 col-lg-6">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<s:textfield id="order_no_para" name="order_no_para"
|
||||
cssClass="form-control " placeholder="用户名" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-12 col-lg-2" >
|
||||
<button type="submit" class="btn btn-default btn-block">查询</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- Start Panel -->
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询结果</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<td>用户</td>
|
||||
<td>订单号</td>
|
||||
<td>充值金额</td>
|
||||
<td>币种</td>
|
||||
<td>状态</td>
|
||||
<td>时间</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<s:iterator value="page.elements" status="stat">
|
||||
<tr>
|
||||
<td><s:property value="username" /></td>
|
||||
<td><s:property value="order_no" /></td>
|
||||
<td><fmt:formatNumber value="${amount}" pattern="#0.00" /></td>
|
||||
<td><s:property value="currency" /></td>
|
||||
<td><s:if test="succeeded==0">未支付</s:if>
|
||||
<s:if test="succeeded==1"><span class="right label label-success">支付成功</span></s:if><s:if test="succeeded==2">失败</s:if></td>
|
||||
<td><s:date name="created" format="yyyy-MM-dd HH:mm:ss " /></td>
|
||||
</tr>
|
||||
</s:iterator>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<%@ include file="include/page_simple.jsp"%>
|
||||
<nav>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- End Panel -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
3
comm/Wallet/bin/WebContent/META-INF/MANIFEST.MF
Executable file
3
comm/Wallet/bin/WebContent/META-INF/MANIFEST.MF
Executable file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
80
comm/Wallet/bin/build/classes/applicationContext-wallet.xml
Executable file
80
comm/Wallet/bin/build/classes/applicationContext-wallet.xml
Executable file
@@ -0,0 +1,80 @@
|
||||
<?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="walletService" class="project.wallet.internal.WalletServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
</bean>
|
||||
<dubbo:service interface="project.wallet.WalletService" ref="walletService"/>
|
||||
<!-- userDataService在产品实现 -->
|
||||
<bean id="rechargeOrderService" class="project.wallet.recharge.internal.RechargeOrderServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedDao" ref="pagedDao" />
|
||||
<property name="walletService" ref="walletService" />
|
||||
<property name="walletUserDataService" ref="userDataService" />
|
||||
</bean>
|
||||
|
||||
<dubbo:service interface="project.wallet.recharge.RechargeOrderService" ref="rechargeOrderService"/>
|
||||
|
||||
<bean id="fhtotoRechargeService" class="project.wallet.recharge.fhtoto.FhtotoRechargeServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="rechargeOrderService" ref="rechargeOrderService" />
|
||||
</bean>
|
||||
|
||||
<bean id="fhtotoQueryService" class="project.wallet.recharge.fhtoto.FhtotoQueryServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="rechargeOrderService" ref="rechargeOrderService" />
|
||||
</bean>
|
||||
|
||||
<!-- -->
|
||||
<bean id="tftRechargeService" class="project.wallet.recharge.tft.TftRechargeServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="rechargeOrderService" ref="rechargeOrderService" />
|
||||
<property name="partyService" ref="partyService" />
|
||||
</bean>
|
||||
|
||||
<bean id="tftQueryService" class="project.wallet.recharge.tft.TftQueryServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="tftRechargeService" ref="tftRechargeService" />
|
||||
</bean>
|
||||
|
||||
<bean id="rechargeQueryTask" class="project.wallet.recharge.task.QueryTask">
|
||||
<property name="tftQueryService" ref="tftQueryService" />
|
||||
<property name="rechargeOrderService" ref="rechargeOrderService" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="tftBackNotifyAction" class="project.wallet.recharge.tft.web.BackNotifyAction"
|
||||
scope="prototype">
|
||||
<property name="withdrawOrderService" ref="withdrawOrderService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="tffOfflineWithdrawAction" class="project.wallet.withdraw.Offline.web.TffOfflineWithdrawAction"
|
||||
scope="prototype">
|
||||
<property name="offlineWithdrawService" ref="offlineWithdrawService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="tffPreTradeAction" class="project.wallet.recharge.tft.web.PreTradeAction"
|
||||
scope="prototype">
|
||||
<property name="tftRechargeService" ref="tftRechargeService"/>
|
||||
<property name="partyService" ref="partyService" />
|
||||
</bean>
|
||||
<bean id="tffWangGuanAction" class="project.wallet.recharge.tft.web.WangGuanAction"
|
||||
scope="prototype">
|
||||
<property name="tftRechargeService" ref="tftRechargeService"/>
|
||||
</bean>
|
||||
<bean id="tffSaoMaAction" class="project.wallet.recharge.tft.web.SaoMaAction"
|
||||
scope="prototype">
|
||||
<property name="tftRechargeService" ref="tftRechargeService"/>
|
||||
<property name="twoDimensionCodeContentService" ref="twoDimensionCodeContentService"/>
|
||||
</bean>
|
||||
|
||||
<!-- userDataService在产品实现 -->
|
||||
<dubbo:service interface="project.wallet.WalletUserDataService" ref="userDataService"/>
|
||||
|
||||
</beans>
|
||||
44
comm/Wallet/bin/build/classes/applicationContext-wallet_admin.xml
Executable file
44
comm/Wallet/bin/build/classes/applicationContext-wallet_admin.xml
Executable file
@@ -0,0 +1,44 @@
|
||||
<?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 ">
|
||||
|
||||
<!-- Service -->
|
||||
<bean id="adminWithdrawOrderService"
|
||||
class="project.wallet.withdraw.internal.AdminWithdrawOrderServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedDao" ref="pagedDao" />
|
||||
<property name="walletUserDataService" ref="walletUserDataService" />
|
||||
<property name="userRecomService" ref="userRecomService" />
|
||||
<property name="namedParameterJdbcTemplate" ref="namedParameterJdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
<bean id="adminRechargeOrderService"
|
||||
class="project.wallet.recharge.internal.AdminRechargeOrderServiceImpl">
|
||||
<property name="pagedDao" ref="pagedDao" />
|
||||
<property name="userRecomService" ref="userRecomService" />
|
||||
<property name="namedParameterJdbcTemplate" ref="namedParameterJdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
<!-- dubbo -->
|
||||
<dubbo:reference id="walletUserDataService"
|
||||
interface="project.wallet.WalletUserDataService" check="false" />
|
||||
<dubbo:reference id="walletService"
|
||||
interface="project.wallet.WalletService" check="false" />
|
||||
|
||||
<!-- Action -->
|
||||
<bean id="adminWithdrawOrderAction"
|
||||
class="project.wallet.withdraw.web.AdminWithdrawOrderAction"
|
||||
scope="prototype">
|
||||
<property name="adminWithdrawOrderService" ref="adminWithdrawOrderService" />
|
||||
</bean>
|
||||
|
||||
<bean id="adminRechargeOrderAction" class="project.wallet.recharge.web.AdminRechargeOrderAction"
|
||||
scope="prototype">
|
||||
<property name="adminRechargeOrderService" ref="adminRechargeOrderService" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
14
comm/Wallet/bin/build/classes/hibernate
Executable file
14
comm/Wallet/bin/build/classes/hibernate
Executable file
@@ -0,0 +1,14 @@
|
||||
#admin
|
||||
|
||||
<!-- wallet -->
|
||||
<value>adminWithdrawOrderService</value>
|
||||
<value>adminRechargeOrderService</value>
|
||||
|
||||
#ROOT
|
||||
<!-- wallet -->
|
||||
<value>walletService</value>
|
||||
<value>rechargeOrderService</value>
|
||||
<value>fhtotoRechargeService</value>
|
||||
<value>fhtotoQueryService</value>
|
||||
<value>tftRechargeService</value>
|
||||
<value>tftQueryService</value>
|
||||
65
comm/Wallet/bin/build/classes/normal.xml
Executable file
65
comm/Wallet/bin/build/classes/normal.xml
Executable file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
<struts>
|
||||
<package name="normal" namespace="/normal" extends="root">
|
||||
<result-types>
|
||||
<result-type name="json" class="org.apache.struts2.json.JSONResult" />
|
||||
</result-types>
|
||||
<interceptors>
|
||||
<interceptor name="json"
|
||||
class="org.apache.struts2.json.JSONInterceptor" />
|
||||
</interceptors>
|
||||
<!-- wallet admin -->
|
||||
<!-- 提现管理 -->
|
||||
<action name="adminWithdrawOrderAction" class="project.wallet.withdraw.web.AdminWithdrawOrderAction" method="execute">
|
||||
<result name="view">/admin_withdraw_order_list.jsp</result>
|
||||
</action>
|
||||
<!-- 充值订单管理 -->
|
||||
<action name="adminRechargeOrderAction" class="project.wallet.recharge.web.AdminRechargeOrderAction">
|
||||
<result name="view">/admin_recharge_order_list.jsp</result>
|
||||
</action>
|
||||
|
||||
<!-- wallet ROOT -->
|
||||
<!--fhtoto支付 -->
|
||||
<action name="fhtotoPayAction" class="project.wallet.recharge.fhtoto.web.PayAction">
|
||||
<result name="view">/wallet_recharge_fhoto.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="fhtotoPayAction" class="project.wallet.recharge.fhtoto.web.PayAction">
|
||||
<result name="view">/wallet_recharge_fhoto.jsp</result>
|
||||
</action>
|
||||
|
||||
<!--tft支付 -->
|
||||
<action name="tftWangGuanAction" class="project.wallet.recharge.tft.web.WangGuanAction">
|
||||
<result name="view">/wallet_recharge_tft.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="saoMaAction" class="project.wallet.recharge.tft.web.SaoMaAction">
|
||||
<result name="view">/wallet_recharge_tft.jsp</result>
|
||||
<result name="qrimages">/wallet_recharge_tft_QR.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="tftPreTradeAction" class="project.wallet.recharge.tft.web.PreTradeAction">
|
||||
<result name="view">/wallet_recharge_tft.jsp</result>
|
||||
<result name="makeResult" type="json">
|
||||
<param name="root">makeResult</param>
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<!--提现订单查询 -->
|
||||
<action name="withdrawOrderAction" class="project.wallet.withdraw.web.WithdrawOrderAction">
|
||||
<result name="withdraw_log_data">/wallet_withdraw_list_data.jsp</result>
|
||||
<result name="withdraw_log">/wallet_withdraw_list.jsp</result>
|
||||
</action>
|
||||
<!--提现 -->
|
||||
|
||||
|
||||
<action name="rechargeLogAction" class="project.wallet.recharge.web.RechargeLogAction">
|
||||
<result name="recharge_log_data">/wallet_recharge_list_data.jsp</result>
|
||||
<result name="recharge_log">/wallet_recharge_list.jsp</result>
|
||||
</action>
|
||||
|
||||
</package>
|
||||
</struts>
|
||||
18
comm/Wallet/bin/build/classes/project/wallet/mapping/Wallet.hbm.xml
Executable file
18
comm/Wallet/bin/build/classes/project/wallet/mapping/Wallet.hbm.xml
Executable file
@@ -0,0 +1,18 @@
|
||||
<?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.wallet.Wallet" table="T_WALLET">
|
||||
<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="money" type="double">
|
||||
<column name="MONEY" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
26
comm/Wallet/bin/build/classes/project/wallet/mapping/WalletExtend.hbm.xml
Executable file
26
comm/Wallet/bin/build/classes/project/wallet/mapping/WalletExtend.hbm.xml
Executable file
@@ -0,0 +1,26 @@
|
||||
<?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.wallet.WalletExtend" table="T_WALLET_EXTEND">
|
||||
<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="tenantId" type="java.lang.String">
|
||||
<column name="TENANT_ID" />
|
||||
</property>
|
||||
<property name="wallettype" type="java.lang.String">
|
||||
<column name="WALLETTYPE" />
|
||||
</property>
|
||||
<property name="amount" type="double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="wallettypeName" type="java.lang.String">
|
||||
<column name="WALLETTYPE_NAME" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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.wallet.recharge.fhtoto.FhtotoBackNotify" table="T_FHTOTO_BACKNOTIFY">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="return_code" type="java.lang.String">
|
||||
<column name="RETURN_CODE" />
|
||||
</property>
|
||||
|
||||
<property name="return_msg" column="RETURN_MSG" type="java.lang.String"></property>
|
||||
|
||||
<property name="result_code" type="java.lang.String">
|
||||
<column name="RESULT_CODE" />
|
||||
</property>
|
||||
<property name="pay_type" column="PAY_TYPE" type="java.lang.String"></property>
|
||||
|
||||
<property name="service_id" type="java.lang.String">
|
||||
<column name="SERVICE_ID" />
|
||||
</property>
|
||||
<property name="userid" type="java.lang.String">
|
||||
<column name="USERID" />
|
||||
</property>
|
||||
<property name="userpwd" type="java.lang.String">
|
||||
<column name="USERPWD" />
|
||||
</property>
|
||||
<property name="terminal_time" type="java.lang.String">
|
||||
<column name="TERMINAL_TIME" />
|
||||
</property>
|
||||
<property name="total_fee" type="java.lang.String">
|
||||
<column name="TOTAL_FEE" />
|
||||
</property>
|
||||
<property name="end_time" column="END_TIME" type="java.lang.String"></property>
|
||||
|
||||
|
||||
<property name="out_trade_no" type="java.lang.String">
|
||||
<column name="OUT_TRADE_NO" />
|
||||
</property>
|
||||
<property name="channel_trade_no" type="java.lang.String">
|
||||
<column name="CHANNEL_TRADE_NO" />
|
||||
</property>
|
||||
<property name="attach" type="java.lang.String">
|
||||
<column name="ATTACH" />
|
||||
</property>
|
||||
<property name="down_data" type="java.lang.String">
|
||||
<column name="DOWN_DATA" />
|
||||
</property>
|
||||
<property name="key_sign" type="java.lang.String">
|
||||
<column name="KEY_SIGN" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
<property name="local_msg" type="java.lang.String">
|
||||
<column name="LOCAL_MSG" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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.wallet.recharge.RechargeOrder" table="T_RECHARGE_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="channel" column="CHANNEL" type="java.lang.String"></property>
|
||||
|
||||
<property name="amount" type="double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="currency" column="CURRENCY" type="java.lang.String"></property>
|
||||
|
||||
<property name="amountSettle" type="double">
|
||||
<column name="AMOUNT_SETTLE" />
|
||||
</property>
|
||||
<property name="orderNo" type="java.lang.String">
|
||||
<column name="ORDER_NO" />
|
||||
</property>
|
||||
<property name="clientIp" type="java.lang.String">
|
||||
<column name="CLIENT_IP" />
|
||||
</property>
|
||||
<property name="extra" type="java.lang.String">
|
||||
<column name="EXTRA" />
|
||||
</property>
|
||||
<property name="timePaid" type="timestamp">
|
||||
<column name="TIME_PAID" />
|
||||
</property>
|
||||
<property name="timeExpire" type="timestamp">
|
||||
<column name="TIME_EXPIRE" />
|
||||
</property>
|
||||
<property name="payState" column="PAY_STATE" type="int"></property>
|
||||
|
||||
|
||||
<property name="timeSettle" type="timestamp">
|
||||
<column name="TIME_SETTLE" />
|
||||
</property>
|
||||
<property name="transactionNo" type="java.lang.String">
|
||||
<column name="TRANSACTION_NO" />
|
||||
</property>
|
||||
<property name="failureCode" type="java.lang.String">
|
||||
<column name="FAILURE_CODE" />
|
||||
</property>
|
||||
<property name="failureMsg" type="java.lang.String">
|
||||
<column name="FAILURE_MSG" />
|
||||
</property>
|
||||
<property name="description" type="java.lang.String">
|
||||
<column name="DESCRIPTION" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
<property name="updateTime" type="timestamp">
|
||||
<column name="UPDATE_TIME" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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.wallet.withdraw.WithdrawOrder" table="T_WITHDRAW_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="channel" column="CHANNEL" type="java.lang.String"></property>
|
||||
|
||||
<property name="amount" type="double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="bankCode" type="java.lang.String">
|
||||
<column name="BANK_CODE" />
|
||||
</property>
|
||||
<property name="bankCardNo" type="java.lang.String">
|
||||
<column name="BANK_CARD_NO" />
|
||||
</property>
|
||||
<property name="bankAccount" type="java.lang.String">
|
||||
<column name="BANK_ACCOUNT" />
|
||||
</property>
|
||||
|
||||
<property name="currency" column="CURRENCY" type="java.lang.String"></property>
|
||||
|
||||
<property name="orderNo" type="java.lang.String">
|
||||
<column name="ORDER_NO" />
|
||||
</property>
|
||||
<property name="clientIp" type="java.lang.String">
|
||||
<column name="CLIENT_IP" />
|
||||
</property>
|
||||
|
||||
<property name="state" column="STATE" type="int"></property>
|
||||
|
||||
<property name="failureCode" type="java.lang.String">
|
||||
<column name="FAILURE_CODE" />
|
||||
</property>
|
||||
<property name="failureMsg" type="java.lang.String">
|
||||
<column name="FAILURE_MSG" />
|
||||
</property>
|
||||
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
<property name="updateTime" type="timestamp">
|
||||
<column name="UPDATE_TIME" />
|
||||
</property>
|
||||
<property name="iDNumber" type="java.lang.String">
|
||||
<column name="IDNUMBER" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
17
comm/Wallet/bin/src/project/wallet/Wallet.hbm.xml
Executable file
17
comm/Wallet/bin/src/project/wallet/Wallet.hbm.xml
Executable file
@@ -0,0 +1,17 @@
|
||||
<?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.wallet.Wallet" table="T_WALLET">
|
||||
<id name="id" type="java.lang.String" >
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String" update="false">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="money" type="java.lang.Double">
|
||||
<column name="MONEY" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
21
comm/Wallet/bin/src/project/wallet/WalletExtend.hbm.xml
Executable file
21
comm/Wallet/bin/src/project/wallet/WalletExtend.hbm.xml
Executable file
@@ -0,0 +1,21 @@
|
||||
<?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.wallet.WalletExtend" table="T_WALLET_EXTEND">
|
||||
<id name="id" type="java.lang.String" >
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String" update="false">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="wallettype" type="java.lang.String" update="false">
|
||||
<column name="WALLETTYPE" />
|
||||
</property>
|
||||
<property name="amount" type="java.lang.Double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
23
comm/Wallet/bin/src/project/wallet/rate/ExchangeRate.hbm.xml
Executable file
23
comm/Wallet/bin/src/project/wallet/rate/ExchangeRate.hbm.xml
Executable file
@@ -0,0 +1,23 @@
|
||||
<?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.wallet.rate.ExchangeRate" table="T_EXCHANGE_RATE">
|
||||
<id name="id" type="java.lang.String" >
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="out_or_in" type="java.lang.String" update="false">
|
||||
<column name="OUT_OR_IN" />
|
||||
</property>
|
||||
<property name="rata" type="java.lang.Double">
|
||||
<column name="RATA" />
|
||||
</property>
|
||||
<property name="currency" type="java.lang.String" update="false">
|
||||
<column name="CURRENCY" />
|
||||
</property>
|
||||
<property name="name" type="java.lang.String" update="false">
|
||||
<column name="NAME" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
54
comm/Wallet/bin/src/project/wallet/withdraw/Withdraw.hbm.xml
Executable file
54
comm/Wallet/bin/src/project/wallet/withdraw/Withdraw.hbm.xml
Executable file
@@ -0,0 +1,54 @@
|
||||
<?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.wallet.withdraw.Withdraw" table="T_WITHDRAW_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="amount" type="double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="amount_fee" type="double">
|
||||
<column name="AMOUNT_FEE" />
|
||||
</property>
|
||||
|
||||
<property name="succeeded" type="java.lang.Integer">
|
||||
<column name="SUCCEEDED" />
|
||||
</property>
|
||||
|
||||
<property name="failure_msg" type="java.lang.String">
|
||||
<column name="FAILURE_MSG" />
|
||||
</property>
|
||||
|
||||
<property name="order_no" type="java.lang.String">
|
||||
<column name="ORDER_NO" />
|
||||
</property>
|
||||
|
||||
<property name="bank_code" type="java.lang.String">
|
||||
<column name="BANK_CODE" />
|
||||
</property>
|
||||
<property name="card_no" type="java.lang.String">
|
||||
<column name="CARD_NO" />
|
||||
</property>
|
||||
<property name="bank_account" type="java.lang.String">
|
||||
<column name="BANK_ACCOUNT" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
|
||||
<property name="channel" type="java.lang.String">
|
||||
<column name="CHANNEL" />
|
||||
</property>
|
||||
|
||||
<property name="address" type="java.lang.String">
|
||||
<column name="ADDRESS" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
80
comm/Wallet/build/classes/applicationContext-wallet.xml
Executable file
80
comm/Wallet/build/classes/applicationContext-wallet.xml
Executable file
@@ -0,0 +1,80 @@
|
||||
<?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="walletService" class="project.wallet.internal.WalletServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
</bean>
|
||||
<dubbo:service interface="project.wallet.WalletService" ref="walletService"/>
|
||||
<!-- userDataService在产品实现 -->
|
||||
<bean id="rechargeOrderService" class="project.wallet.recharge.internal.RechargeOrderServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedDao" ref="pagedDao" />
|
||||
<property name="walletService" ref="walletService" />
|
||||
<property name="walletUserDataService" ref="userDataService" />
|
||||
</bean>
|
||||
|
||||
<dubbo:service interface="project.wallet.recharge.RechargeOrderService" ref="rechargeOrderService"/>
|
||||
|
||||
<bean id="fhtotoRechargeService" class="project.wallet.recharge.fhtoto.FhtotoRechargeServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="rechargeOrderService" ref="rechargeOrderService" />
|
||||
</bean>
|
||||
|
||||
<bean id="fhtotoQueryService" class="project.wallet.recharge.fhtoto.FhtotoQueryServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="rechargeOrderService" ref="rechargeOrderService" />
|
||||
</bean>
|
||||
|
||||
<!-- -->
|
||||
<bean id="tftRechargeService" class="project.wallet.recharge.tft.TftRechargeServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="rechargeOrderService" ref="rechargeOrderService" />
|
||||
<property name="partyService" ref="partyService" />
|
||||
</bean>
|
||||
|
||||
<bean id="tftQueryService" class="project.wallet.recharge.tft.TftQueryServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="tftRechargeService" ref="tftRechargeService" />
|
||||
</bean>
|
||||
|
||||
<bean id="rechargeQueryTask" class="project.wallet.recharge.task.QueryTask">
|
||||
<property name="tftQueryService" ref="tftQueryService" />
|
||||
<property name="rechargeOrderService" ref="rechargeOrderService" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="tftBackNotifyAction" class="project.wallet.recharge.tft.web.BackNotifyAction"
|
||||
scope="prototype">
|
||||
<property name="withdrawOrderService" ref="withdrawOrderService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="tffOfflineWithdrawAction" class="project.wallet.withdraw.Offline.web.TffOfflineWithdrawAction"
|
||||
scope="prototype">
|
||||
<property name="offlineWithdrawService" ref="offlineWithdrawService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="tffPreTradeAction" class="project.wallet.recharge.tft.web.PreTradeAction"
|
||||
scope="prototype">
|
||||
<property name="tftRechargeService" ref="tftRechargeService"/>
|
||||
<property name="partyService" ref="partyService" />
|
||||
</bean>
|
||||
<bean id="tffWangGuanAction" class="project.wallet.recharge.tft.web.WangGuanAction"
|
||||
scope="prototype">
|
||||
<property name="tftRechargeService" ref="tftRechargeService"/>
|
||||
</bean>
|
||||
<bean id="tffSaoMaAction" class="project.wallet.recharge.tft.web.SaoMaAction"
|
||||
scope="prototype">
|
||||
<property name="tftRechargeService" ref="tftRechargeService"/>
|
||||
<property name="twoDimensionCodeContentService" ref="twoDimensionCodeContentService"/>
|
||||
</bean>
|
||||
|
||||
<!-- userDataService在产品实现 -->
|
||||
<dubbo:service interface="project.wallet.WalletUserDataService" ref="userDataService"/>
|
||||
|
||||
</beans>
|
||||
44
comm/Wallet/build/classes/applicationContext-wallet_admin.xml
Executable file
44
comm/Wallet/build/classes/applicationContext-wallet_admin.xml
Executable file
@@ -0,0 +1,44 @@
|
||||
<?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 ">
|
||||
|
||||
<!-- Service -->
|
||||
<bean id="adminWithdrawOrderService"
|
||||
class="project.wallet.withdraw.internal.AdminWithdrawOrderServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedDao" ref="pagedDao" />
|
||||
<property name="walletUserDataService" ref="walletUserDataService" />
|
||||
<property name="userRecomService" ref="userRecomService" />
|
||||
<property name="namedParameterJdbcTemplate" ref="namedParameterJdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
<bean id="adminRechargeOrderService"
|
||||
class="project.wallet.recharge.internal.AdminRechargeOrderServiceImpl">
|
||||
<property name="pagedDao" ref="pagedDao" />
|
||||
<property name="userRecomService" ref="userRecomService" />
|
||||
<property name="namedParameterJdbcTemplate" ref="namedParameterJdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
<!-- dubbo -->
|
||||
<dubbo:reference id="walletUserDataService"
|
||||
interface="project.wallet.WalletUserDataService" check="false" />
|
||||
<dubbo:reference id="walletService"
|
||||
interface="project.wallet.WalletService" check="false" />
|
||||
|
||||
<!-- Action -->
|
||||
<bean id="adminWithdrawOrderAction"
|
||||
class="project.wallet.withdraw.web.AdminWithdrawOrderAction"
|
||||
scope="prototype">
|
||||
<property name="adminWithdrawOrderService" ref="adminWithdrawOrderService" />
|
||||
</bean>
|
||||
|
||||
<bean id="adminRechargeOrderAction" class="project.wallet.recharge.web.AdminRechargeOrderAction"
|
||||
scope="prototype">
|
||||
<property name="adminRechargeOrderService" ref="adminRechargeOrderService" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
14
comm/Wallet/build/classes/hibernate
Executable file
14
comm/Wallet/build/classes/hibernate
Executable file
@@ -0,0 +1,14 @@
|
||||
#admin
|
||||
|
||||
<!-- wallet -->
|
||||
<value>adminWithdrawOrderService</value>
|
||||
<value>adminRechargeOrderService</value>
|
||||
|
||||
#ROOT
|
||||
<!-- wallet -->
|
||||
<value>walletService</value>
|
||||
<value>rechargeOrderService</value>
|
||||
<value>fhtotoRechargeService</value>
|
||||
<value>fhtotoQueryService</value>
|
||||
<value>tftRechargeService</value>
|
||||
<value>tftQueryService</value>
|
||||
65
comm/Wallet/build/classes/normal.xml
Executable file
65
comm/Wallet/build/classes/normal.xml
Executable file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
<struts>
|
||||
<package name="normal" namespace="/normal" extends="root">
|
||||
<result-types>
|
||||
<result-type name="json" class="org.apache.struts2.json.JSONResult" />
|
||||
</result-types>
|
||||
<interceptors>
|
||||
<interceptor name="json"
|
||||
class="org.apache.struts2.json.JSONInterceptor" />
|
||||
</interceptors>
|
||||
<!-- wallet admin -->
|
||||
<!-- 提现管理 -->
|
||||
<action name="adminWithdrawOrderAction" class="project.wallet.withdraw.web.AdminWithdrawOrderAction" method="execute">
|
||||
<result name="view">/admin_withdraw_order_list.jsp</result>
|
||||
</action>
|
||||
<!-- 充值订单管理 -->
|
||||
<action name="adminRechargeOrderAction" class="project.wallet.recharge.web.AdminRechargeOrderAction">
|
||||
<result name="view">/admin_recharge_order_list.jsp</result>
|
||||
</action>
|
||||
|
||||
<!-- wallet ROOT -->
|
||||
<!--fhtoto支付 -->
|
||||
<action name="fhtotoPayAction" class="project.wallet.recharge.fhtoto.web.PayAction">
|
||||
<result name="view">/wallet_recharge_fhoto.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="fhtotoPayAction" class="project.wallet.recharge.fhtoto.web.PayAction">
|
||||
<result name="view">/wallet_recharge_fhoto.jsp</result>
|
||||
</action>
|
||||
|
||||
<!--tft支付 -->
|
||||
<action name="tftWangGuanAction" class="project.wallet.recharge.tft.web.WangGuanAction">
|
||||
<result name="view">/wallet_recharge_tft.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="saoMaAction" class="project.wallet.recharge.tft.web.SaoMaAction">
|
||||
<result name="view">/wallet_recharge_tft.jsp</result>
|
||||
<result name="qrimages">/wallet_recharge_tft_QR.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="tftPreTradeAction" class="project.wallet.recharge.tft.web.PreTradeAction">
|
||||
<result name="view">/wallet_recharge_tft.jsp</result>
|
||||
<result name="makeResult" type="json">
|
||||
<param name="root">makeResult</param>
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<!--提现订单查询 -->
|
||||
<action name="withdrawOrderAction" class="project.wallet.withdraw.web.WithdrawOrderAction">
|
||||
<result name="withdraw_log_data">/wallet_withdraw_list_data.jsp</result>
|
||||
<result name="withdraw_log">/wallet_withdraw_list.jsp</result>
|
||||
</action>
|
||||
<!--提现 -->
|
||||
|
||||
|
||||
<action name="rechargeLogAction" class="project.wallet.recharge.web.RechargeLogAction">
|
||||
<result name="recharge_log_data">/wallet_recharge_list_data.jsp</result>
|
||||
<result name="recharge_log">/wallet_recharge_list.jsp</result>
|
||||
</action>
|
||||
|
||||
</package>
|
||||
</struts>
|
||||
18
comm/Wallet/build/classes/project/wallet/mapping/Wallet.hbm.xml
Executable file
18
comm/Wallet/build/classes/project/wallet/mapping/Wallet.hbm.xml
Executable file
@@ -0,0 +1,18 @@
|
||||
<?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.wallet.Wallet" table="T_WALLET">
|
||||
<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="money" type="double">
|
||||
<column name="MONEY" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
26
comm/Wallet/build/classes/project/wallet/mapping/WalletExtend.hbm.xml
Executable file
26
comm/Wallet/build/classes/project/wallet/mapping/WalletExtend.hbm.xml
Executable file
@@ -0,0 +1,26 @@
|
||||
<?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.wallet.WalletExtend" table="T_WALLET_EXTEND">
|
||||
<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="tenantId" type="java.lang.String">
|
||||
<column name="TENANT_ID" />
|
||||
</property>
|
||||
<property name="wallettype" type="java.lang.String">
|
||||
<column name="WALLETTYPE" />
|
||||
</property>
|
||||
<property name="amount" type="double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="wallettypeName" type="java.lang.String">
|
||||
<column name="WALLETTYPE_NAME" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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.wallet.recharge.fhtoto.FhtotoBackNotify" table="T_FHTOTO_BACKNOTIFY">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="return_code" type="java.lang.String">
|
||||
<column name="RETURN_CODE" />
|
||||
</property>
|
||||
|
||||
<property name="return_msg" column="RETURN_MSG" type="java.lang.String"></property>
|
||||
|
||||
<property name="result_code" type="java.lang.String">
|
||||
<column name="RESULT_CODE" />
|
||||
</property>
|
||||
<property name="pay_type" column="PAY_TYPE" type="java.lang.String"></property>
|
||||
|
||||
<property name="service_id" type="java.lang.String">
|
||||
<column name="SERVICE_ID" />
|
||||
</property>
|
||||
<property name="userid" type="java.lang.String">
|
||||
<column name="USERID" />
|
||||
</property>
|
||||
<property name="userpwd" type="java.lang.String">
|
||||
<column name="USERPWD" />
|
||||
</property>
|
||||
<property name="terminal_time" type="java.lang.String">
|
||||
<column name="TERMINAL_TIME" />
|
||||
</property>
|
||||
<property name="total_fee" type="java.lang.String">
|
||||
<column name="TOTAL_FEE" />
|
||||
</property>
|
||||
<property name="end_time" column="END_TIME" type="java.lang.String"></property>
|
||||
|
||||
|
||||
<property name="out_trade_no" type="java.lang.String">
|
||||
<column name="OUT_TRADE_NO" />
|
||||
</property>
|
||||
<property name="channel_trade_no" type="java.lang.String">
|
||||
<column name="CHANNEL_TRADE_NO" />
|
||||
</property>
|
||||
<property name="attach" type="java.lang.String">
|
||||
<column name="ATTACH" />
|
||||
</property>
|
||||
<property name="down_data" type="java.lang.String">
|
||||
<column name="DOWN_DATA" />
|
||||
</property>
|
||||
<property name="key_sign" type="java.lang.String">
|
||||
<column name="KEY_SIGN" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
<property name="local_msg" type="java.lang.String">
|
||||
<column name="LOCAL_MSG" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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.wallet.recharge.RechargeOrder" table="T_RECHARGE_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="channel" column="CHANNEL" type="java.lang.String"></property>
|
||||
|
||||
<property name="amount" type="double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="currency" column="CURRENCY" type="java.lang.String"></property>
|
||||
|
||||
<property name="amountSettle" type="double">
|
||||
<column name="AMOUNT_SETTLE" />
|
||||
</property>
|
||||
<property name="orderNo" type="java.lang.String">
|
||||
<column name="ORDER_NO" />
|
||||
</property>
|
||||
<property name="clientIp" type="java.lang.String">
|
||||
<column name="CLIENT_IP" />
|
||||
</property>
|
||||
<property name="extra" type="java.lang.String">
|
||||
<column name="EXTRA" />
|
||||
</property>
|
||||
<property name="timePaid" type="timestamp">
|
||||
<column name="TIME_PAID" />
|
||||
</property>
|
||||
<property name="timeExpire" type="timestamp">
|
||||
<column name="TIME_EXPIRE" />
|
||||
</property>
|
||||
<property name="payState" column="PAY_STATE" type="int"></property>
|
||||
|
||||
|
||||
<property name="timeSettle" type="timestamp">
|
||||
<column name="TIME_SETTLE" />
|
||||
</property>
|
||||
<property name="transactionNo" type="java.lang.String">
|
||||
<column name="TRANSACTION_NO" />
|
||||
</property>
|
||||
<property name="failureCode" type="java.lang.String">
|
||||
<column name="FAILURE_CODE" />
|
||||
</property>
|
||||
<property name="failureMsg" type="java.lang.String">
|
||||
<column name="FAILURE_MSG" />
|
||||
</property>
|
||||
<property name="description" type="java.lang.String">
|
||||
<column name="DESCRIPTION" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
<property name="updateTime" type="timestamp">
|
||||
<column name="UPDATE_TIME" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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.wallet.withdraw.WithdrawOrder" table="T_WITHDRAW_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="channel" column="CHANNEL" type="java.lang.String"></property>
|
||||
|
||||
<property name="amount" type="double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="bankCode" type="java.lang.String">
|
||||
<column name="BANK_CODE" />
|
||||
</property>
|
||||
<property name="bankCardNo" type="java.lang.String">
|
||||
<column name="BANK_CARD_NO" />
|
||||
</property>
|
||||
<property name="bankAccount" type="java.lang.String">
|
||||
<column name="BANK_ACCOUNT" />
|
||||
</property>
|
||||
|
||||
<property name="currency" column="CURRENCY" type="java.lang.String"></property>
|
||||
|
||||
<property name="orderNo" type="java.lang.String">
|
||||
<column name="ORDER_NO" />
|
||||
</property>
|
||||
<property name="clientIp" type="java.lang.String">
|
||||
<column name="CLIENT_IP" />
|
||||
</property>
|
||||
|
||||
<property name="state" column="STATE" type="int"></property>
|
||||
|
||||
<property name="failureCode" type="java.lang.String">
|
||||
<column name="FAILURE_CODE" />
|
||||
</property>
|
||||
<property name="failureMsg" type="java.lang.String">
|
||||
<column name="FAILURE_MSG" />
|
||||
</property>
|
||||
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
<property name="updateTime" type="timestamp">
|
||||
<column name="UPDATE_TIME" />
|
||||
</property>
|
||||
<property name="iDNumber" type="java.lang.String">
|
||||
<column name="IDNUMBER" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
15
comm/Wallet/build/classes/wallet.properties
Executable file
15
comm/Wallet/build/classes/wallet.properties
Executable file
@@ -0,0 +1,15 @@
|
||||
fhtoto_userid=
|
||||
fhtoto_userpwd=
|
||||
fhtoto_pay_url=http://pay.fhtoto.com/api.php/pay/pay
|
||||
fhtoto_notify_url=
|
||||
fhtoto_redirect_url=
|
||||
fhtoto_query_url=http://pay.fhtoto.com/api.php/pay/query
|
||||
|
||||
|
||||
tft_userid=10016970
|
||||
tft_userpwd=gqtorICyOFcKKyp%2FYAZLyvv5ZdfUD6ihTZboVNDYGcbAO5Jg9v8h6FCULlGgH0sS70cyO7ZrqxoY%2F%2BKhBk3eCzSKm353ZSuN
|
||||
tft_datakey=48b08d68a9084c53adbabdb6ddd422ed
|
||||
tft_dcpay_url=http://pos.gzdcdata.com/dcpay
|
||||
tft_notify_url=
|
||||
tft_query_url=http://pay.fhtoto.com/api.php/pay/query
|
||||
|
||||
13
comm/Wallet/config/spring/applicationContext-hibernate.xml
Executable file
13
comm/Wallet/config/spring/applicationContext-hibernate.xml
Executable file
@@ -0,0 +1,13 @@
|
||||
|
||||
admin
|
||||
<!-- wallet -->
|
||||
<value>walletService</value>
|
||||
<value>walletLogService</value>
|
||||
<value>exchangeRateService</value>
|
||||
|
||||
api
|
||||
<!-- wallet -->
|
||||
<value>walletService</value>
|
||||
<value>walletLogService</value>
|
||||
<value>exchangeRateService</value>
|
||||
<value>userRateConfigService</value>
|
||||
33
comm/Wallet/config/spring/applicationContext-wallet.xml
Executable file
33
comm/Wallet/config/spring/applicationContext-wallet.xml
Executable file
@@ -0,0 +1,33 @@
|
||||
<?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="walletService" class="project.wallet.internal.WalletServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="namedParameterJdbcTemplate" ref="namedParameterJdbcTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="walletLogService" class="project.wallet.internal.WalletLogServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="exchangeRateService" class="project.wallet.rate.internal.ExchangeRateServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
<bean id="userRateConfigService" class="project.wallet.rate.internal.UserRateConfigServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="exchangeRateService" ref="exchangeRateService" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
</beans>
|
||||
29
comm/Wallet/config/spring/applicationContext-wallet_admin.xml
Executable file
29
comm/Wallet/config/spring/applicationContext-wallet_admin.xml
Executable file
@@ -0,0 +1,29 @@
|
||||
<?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 ">
|
||||
|
||||
<!-- Service -->
|
||||
|
||||
<bean id="walletService" class="project.wallet.internal.WalletServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="walletLogService" class="project.wallet.internal.WalletLogServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="exchangeRateService" class="project.wallet.rate.internal.ExchangeRateServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
</beans>
|
||||
73
comm/Wallet/config/spring/applicationContext-wallet_data.xml
Executable file
73
comm/Wallet/config/spring/applicationContext-wallet_data.xml
Executable file
@@ -0,0 +1,73 @@
|
||||
<?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 ">
|
||||
|
||||
<!-- init-method="init" -->
|
||||
|
||||
<bean id="walletService" class="project.wallet.internal.WalletServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="namedParameterJdbcTemplate" ref="namedParameterJdbcTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
<bean id="walletService" class="project.wallet.internal.WalletServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="namedParameterJdbcTemplate" ref="namedParameterJdbcTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="walletLogService" class="project.wallet.internal.WalletLogServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="exchangeRateService" class="project.wallet.rate.internal.ExchangeRateServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="walletLoadCacheService"
|
||||
class="data.loadcache.WalletLoadCacheService">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
<bean id="walletLogLoadCacheService"
|
||||
class="data.loadcache.WalletLogLoadCacheService">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
<bean id="exchangeRateLoadCacheService"
|
||||
class="data.loadcache.ExchangeRateLoadCacheService">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
<bean id="userRateConfigLoadCacheService"
|
||||
class="data.loadcache.UserRateConfigLoadCacheService">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="walletDao" class="project.wallet.consumer.WalletDaoImpl">
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
<bean id="walletConsumeServer" class="project.wallet.consumer.WalletConsumeServer">
|
||||
<property name="walletDao" ref="walletDao" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="walletExtendConsumeServer" class="project.wallet.consumer.WalletExtendConsumeServer">
|
||||
<property name="walletDao" ref="walletDao" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
18
comm/Wallet/config/spring/normal.xml
Executable file
18
comm/Wallet/config/spring/normal.xml
Executable file
@@ -0,0 +1,18 @@
|
||||
|
||||
admin
|
||||
|
||||
<action name="adminExchangeRateAction"
|
||||
class="project.wallet.rate.web.AdminExchangeRateAction">
|
||||
<result name="list">/exchangerate_list.jsp</result>
|
||||
<result name="update">/exchangerate_update.jsp</result>
|
||||
</action>
|
||||
|
||||
api
|
||||
<action name="exchangerate"
|
||||
class="project.wallet.rate.web.ExchangeRateAction">
|
||||
</action>
|
||||
<action name="exchangerateuserconfig"
|
||||
class="project.wallet.rate.web.ExchangeRateUserConfigAction">
|
||||
</action>
|
||||
<action name="wallet" class="project.wallet.web.WalletAction">
|
||||
</action>
|
||||
2
comm/Wallet/config/wallet.properties
Executable file
2
comm/Wallet/config/wallet.properties
Executable file
@@ -0,0 +1,2 @@
|
||||
wallet_rate_currency=USD
|
||||
out_or_in=in
|
||||
40
comm/Wallet/dbscript/1.0/WALLET-DDL-MYSQL.SQL
Executable file
40
comm/Wallet/dbscript/1.0/WALLET-DDL-MYSQL.SQL
Executable file
@@ -0,0 +1,40 @@
|
||||
-- ----------------------------
|
||||
-- Table structure for t_wallet
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `T_WALLET`;
|
||||
CREATE TABLE `T_WALLET` (
|
||||
`UUID` varchar(32) NOT NULL DEFAULT '' COMMENT '主键',
|
||||
`PARTY_ID` varchar(32) NOT NULL DEFAULT '',
|
||||
`MONEY` double NOT NULL DEFAULT '0.00' COMMENT '现金/美元',
|
||||
|
||||
PRIMARY KEY (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
create index INDEX_WALLET_PARTY_ID on T_WALLET (
|
||||
PARTY_ID
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of t_wallet
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for t_wallet_extend
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `T_WALLET_EXTEND`;
|
||||
CREATE TABLE `T_WALLET_EXTEND` (
|
||||
`UUID` varchar(32) NOT NULL DEFAULT '' COMMENT '主键',
|
||||
`PARTY_ID` varchar(32) NOT NULL DEFAULT '',
|
||||
`TENANT_ID` varchar(32) NOT NULL DEFAULT '' COMMENT '租户 的PATTYID',
|
||||
`WALLETTYPE` varchar(16) NOT NULL DEFAULT '' COMMENT '类型',
|
||||
`WALLETTYPE_NAME` varchar(64) NOT NULL DEFAULT '' COMMENT '类型名称',
|
||||
`AMOUNT` double NOT NULL DEFAULT '0.00' COMMENT '金额',
|
||||
PRIMARY KEY (`UUID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
create index INDEX_WALLET_EXTEND_PARTY_ID on T_WALLET_EXTEND (
|
||||
PARTY_ID,WALLETTYPE
|
||||
);
|
||||
|
||||
|
||||
|
||||
46
comm/Wallet/dbscript/1.1/WALLET-DDL-MYSQL.SQL
Executable file
46
comm/Wallet/dbscript/1.1/WALLET-DDL-MYSQL.SQL
Executable file
@@ -0,0 +1,46 @@
|
||||
-- ----------------------------
|
||||
-- Table structure for t_wallet
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `T_EXCHANGE_RATE`;
|
||||
CREATE TABLE `T_EXCHANGE_RATE` (
|
||||
`UUID` varchar(32) NOT NULL DEFAULT '' COMMENT '主键',
|
||||
`OUT_OR_IN` varchar(32) ,
|
||||
`RATA` double ,
|
||||
`CURRENCY` varchar(32) ,
|
||||
`NAME` varchar(64) ,
|
||||
`CURRENCY_SYMBOL` varchar(32) ,
|
||||
PRIMARY KEY (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
create index INDEX_EXCHANGE_OUT_OR_IN on T_EXCHANGE_RATE (
|
||||
OUT_OR_IN
|
||||
);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `T_WALLET_LOG`;
|
||||
CREATE TABLE `T_WALLET_LOG` (
|
||||
`UUID` varchar(32) NOT NULL DEFAULT '' COMMENT '主键',
|
||||
`PARTY_ID` varchar(32) NOT NULL DEFAULT '',
|
||||
`ORDER_NO` varchar(64) ,
|
||||
`AMOUNT` double ,
|
||||
`STATUS` int ,
|
||||
`CREATE_TIME` datetime ,
|
||||
`CATEGORY` varchar(32) ,
|
||||
PRIMARY KEY (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
create index INDEX_WALLET_LOG_PARTY_ID on T_WALLET_LOG (
|
||||
PARTY_ID,CREATE_TIME
|
||||
);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `T_USER_RATE_CONFIG`;
|
||||
CREATE TABLE `t_user_rate_config` (
|
||||
`UUID` varchar(64) NOT NULL,
|
||||
`OUT_OR_IN` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`CURRENCY` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`PARTY_ID` varchar(32) DEFAULT NULL,
|
||||
PRIMARY KEY (`UUID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
9
comm/Wallet/dbscript/1.1/WALLET-DML-MYSQL.SQL
Executable file
9
comm/Wallet/dbscript/1.1/WALLET-DML-MYSQL.SQL
Executable file
@@ -0,0 +1,9 @@
|
||||
INSERT INTO `SCT_RESOURCE` (`UUID`, `RES_STRING`, `RES_TYPE`)
|
||||
VALUES
|
||||
('URL_ADMIN_EXCHANGERATE_UPDATE', '/normal/AdminExchangeRateAction!update.action*', 'URL');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ROOT', 'URL_ADMIN_EXCHANGERATE_UPDATE');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ADMIN', 'URL_ADMIN_EXCHANGERATE_UPDATE');
|
||||
34
comm/Wallet/dbscript/2.1/WALLET-DDL-MYSQL.SQL
Executable file
34
comm/Wallet/dbscript/2.1/WALLET-DDL-MYSQL.SQL
Executable file
@@ -0,0 +1,34 @@
|
||||
-- ----------------------------
|
||||
-- Table structure for t_wallet
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `T_EXCHANGE_RATE`;
|
||||
CREATE TABLE `T_EXCHANGE_RATE` (
|
||||
`UUID` varchar(32) NOT NULL DEFAULT '' COMMENT '主键',
|
||||
`OUT_OR_IN` varchar(32) ,
|
||||
`RATA` double ,
|
||||
`CURRENCY` varchar(32) ,
|
||||
`NAME` varchar(64) ,
|
||||
`CURRENCY_SYMBOL` varchar(32) ,
|
||||
PRIMARY KEY (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
create index INDEX_EXCHANGE_OUT_OR_IN on T_EXCHANGE_RATE (
|
||||
OUT_OR_IN
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `t_user_rate_config`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `T_USER_RATE_CONFIG`;
|
||||
CREATE TABLE `T_USER_RATE_CONFIG` (
|
||||
`UUID` varchar(64) NOT NULL,
|
||||
`OUT_OR_IN` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`CURRENCY` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`PARTY_ID` varchar(32) DEFAULT NULL,
|
||||
PRIMARY KEY (`UUID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
create index INDEX_ORDER_NO on T_WALLET_LOG (
|
||||
ORDER_NO
|
||||
);
|
||||
19
comm/Wallet/dbscript/2.1/WALLET-DML-MYSQL.SQL
Executable file
19
comm/Wallet/dbscript/2.1/WALLET-DML-MYSQL.SQL
Executable file
@@ -0,0 +1,19 @@
|
||||
-- ----------------------------
|
||||
-- Records of t_exchange_rate
|
||||
-- ----------------------------
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = '¥' WHERE UUID='CNY_in';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = '¥' WHERE UUID='CNY_out';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = '€' WHERE UUID='EUR_in';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = '€' WHERE UUID='EUR_out';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = 'HK$' WHERE UUID='HKD_in';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = 'HK$' WHERE UUID='HKD_out';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = 'M$' WHERE UUID='MYR_in';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = 'M$' WHERE UUID='MYR_out';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = 'S$' WHERE UUID='SGD_in';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = 'S$' WHERE UUID='SGD_out';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = '฿' WHERE UUID='THB_in';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = '฿' WHERE UUID='THB_out';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = 'NT' WHERE UUID='TWD_in';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = 'NT' WHERE UUID='TWD_out';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = '$' WHERE UUID='USD_in';
|
||||
UPDATE T_EXCHANGE_RATE SET CURRENCY_SYMBOL = '$' WHERE UUID='USD_out';
|
||||
1
comm/Wallet/src/config/wallet.properties
Executable file
1
comm/Wallet/src/config/wallet.properties
Executable file
@@ -0,0 +1 @@
|
||||
user_default_currency=CNY
|
||||
119
comm/Wallet/src/data/loadcache/WalletLoadCacheService.java
Executable file
119
comm/Wallet/src/data/loadcache/WalletLoadCacheService.java
Executable file
@@ -0,0 +1,119 @@
|
||||
package data.loadcache;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
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 project.RedisKeys;
|
||||
|
||||
|
||||
import project.redis.RedisHandler;
|
||||
import project.wallet.Wallet;
|
||||
import project.wallet.WalletExtend;
|
||||
import project.wallet.WalletLog;
|
||||
import project.wallet.WalletRedisKeys;
|
||||
import project.wallet.rate.ExchangeRate;
|
||||
import project.wallet.rate.UserRateConfig;
|
||||
|
||||
public class WalletLoadCacheService extends HibernateDaoSupport {
|
||||
private static final Log logger = LogFactory.getLog(WalletLoadCacheService.class);
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public void loadcache() {
|
||||
// loadWallet();
|
||||
logger.info("完成Wallet数据加载redis");
|
||||
|
||||
//loadWalletExtend();
|
||||
//logger.info("完成WalletExtend数据加载redis");
|
||||
|
||||
//loadExchangeRate();
|
||||
//logger.info("完成ExchangeRate数据加载redis");
|
||||
//loadUserRateConfig();
|
||||
//logger.info("完成UserRateConfig数据加载redis");
|
||||
//loadWalletLog();
|
||||
//logger.info("完成WalletLog数据加载redis");
|
||||
}
|
||||
|
||||
public void loadWallet() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM Wallet ");
|
||||
List<Wallet> list = (List<Wallet>) this.getHibernateTemplate().find(queryString.toString());
|
||||
Map<String, Object> params = new ConcurrentHashMap<String, Object>();
|
||||
for (Wallet wallet : list) {
|
||||
params.put(WalletRedisKeys.WALLET_PARTY_ID + wallet.getPartyId().toString(), wallet);
|
||||
}
|
||||
|
||||
redisHandler.setBatchSync(params);
|
||||
}
|
||||
|
||||
public void loadWalletExtend() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM WalletExtend ");
|
||||
List<WalletExtend> list = (List<WalletExtend>) this.getHibernateTemplate().find(queryString.toString());
|
||||
Map<String, Object> params = new ConcurrentHashMap<String, Object>();
|
||||
for (WalletExtend walletExtend : list) {
|
||||
params.put(
|
||||
WalletRedisKeys.WALLET_EXTEND_PARTY_ID + walletExtend.getPartyId() + walletExtend.getWallettype(),
|
||||
walletExtend);
|
||||
}
|
||||
|
||||
redisHandler.setBatchSync(params);
|
||||
}
|
||||
|
||||
public void loadExchangeRate() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM ExchangeRate ");
|
||||
List<ExchangeRate> list = (List<ExchangeRate>) this.getHibernateTemplate().find(queryString.toString());
|
||||
|
||||
Map<String, Map<String, ExchangeRate>> cacheMap = new ConcurrentHashMap<String, Map<String, ExchangeRate>>();
|
||||
|
||||
for (ExchangeRate exchangeRate : list) {
|
||||
if (cacheMap.containsKey(exchangeRate.getOut_or_in())) {
|
||||
Map<String, ExchangeRate> map = cacheMap.get(exchangeRate.getOut_or_in());
|
||||
map.put(exchangeRate.getCurrency(), exchangeRate);
|
||||
cacheMap.put(exchangeRate.getOut_or_in(), map);
|
||||
} else {
|
||||
Map<String, ExchangeRate> map = new ConcurrentHashMap<String, ExchangeRate>();
|
||||
map.put(exchangeRate.getCurrency(), exchangeRate);
|
||||
cacheMap.put(exchangeRate.getOut_or_in(), map);
|
||||
}
|
||||
redisHandler.setSync(RedisKeys.EXCHANGE_RATE_ID + exchangeRate.getId().toString(), exchangeRate);
|
||||
redisHandler.setSync(RedisKeys.EXCHANGE_RATE_CURRENCY + exchangeRate.getCurrency(), exchangeRate);
|
||||
}
|
||||
|
||||
for (Entry<String, Map<String, ExchangeRate>> entry : cacheMap.entrySet()) {
|
||||
redisHandler.setSync(RedisKeys.EXCHANGE_RATE_OUTORIN + entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUserRateConfig() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM UserRateConfig ");
|
||||
List<UserRateConfig> list = (List<UserRateConfig>) this.getHibernateTemplate().find(queryString.toString());
|
||||
Map<String, Object> params = new ConcurrentHashMap<String, Object>();
|
||||
for (UserRateConfig config : list) {
|
||||
params.put(RedisKeys.USER_RATE_CONFIG_PARTY_ID + config.getPartyId().toString(), config);
|
||||
// redisHandler.setSync(RedisKeys.USER_RATE_CONFIG_PARTY_ID + config.getPartyId().toString(), config);
|
||||
}
|
||||
redisHandler.setBatchSync(params);
|
||||
}
|
||||
|
||||
public void loadWalletLog() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM WalletLog ");
|
||||
List<WalletLog> list = (List<WalletLog>) this.getHibernateTemplate().find(queryString.toString());
|
||||
|
||||
Map<String, Object> params = new ConcurrentHashMap<String, Object>();
|
||||
for (WalletLog walletLog : list) {
|
||||
params.put(RedisKeys.WALLET_LOG_ORDERNO + walletLog.getOrder_no(), walletLog);
|
||||
// redisHandler.setSync(RedisKeys.WALLET_LOG_ORDERNO + walletLog.getOrder_no(), walletLog);
|
||||
}
|
||||
redisHandler.setBatchSync(params);
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
17
comm/Wallet/src/project/wallet/.hbm2.xml
Executable file
17
comm/Wallet/src/project/wallet/.hbm2.xml
Executable file
@@ -0,0 +1,17 @@
|
||||
<?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.wallet.Wallet" table="T_WALLET">
|
||||
<id name="id" type="java.lang.String" >
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String" update="false">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="money" type="java.lang.Double">
|
||||
<column name="MONEY" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
66
comm/Wallet/src/project/wallet/AssetService.java
Executable file
66
comm/Wallet/src/project/wallet/AssetService.java
Executable file
@@ -0,0 +1,66 @@
|
||||
package project.wallet;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import project.contract.ContractOrder;
|
||||
import project.data.model.Realtime;
|
||||
import project.futures.FuturesOrder;
|
||||
|
||||
/**
|
||||
* 钱包
|
||||
*/
|
||||
public interface AssetService {
|
||||
|
||||
/**
|
||||
* 获取其他拓展钱包币种的余额
|
||||
*/
|
||||
public Map<String, Object> getMoneyAll(Serializable partyId);
|
||||
|
||||
/**
|
||||
* 获取其他拓展钱包币种的余额
|
||||
*/
|
||||
public double getMoneyCoin(Serializable partyId, List<Realtime> realtimeall, List<String> list_symbol);
|
||||
|
||||
/**
|
||||
* 理财资产 = 用户托管订单金额+盈亏金额
|
||||
*/
|
||||
public double getMoneyFinance(Serializable partyId, List<Realtime> realtimeall);
|
||||
|
||||
/**
|
||||
* 矿机资产 = 用户托管订单金额+盈亏金额
|
||||
*/
|
||||
public double getMoneyMiner(Serializable partyId, List<Realtime> realtimeall);
|
||||
|
||||
/**
|
||||
* 所有限价 永续委托单 = 开仓数量 * 每手价格
|
||||
*/
|
||||
public double getMoneyContractApply(Serializable partyId);
|
||||
|
||||
/*
|
||||
* 获取 所有订单 永续合约总资产、总保证金、总未实现盈利
|
||||
*/
|
||||
public Map<String, Object> getMoneyContract(Serializable partyId);
|
||||
|
||||
/*
|
||||
* 获取 单个订单 永续合约总资产、总保证金、总未实现盈利
|
||||
*/
|
||||
public Map<String, Double> getMoneyContractByOrder(ContractOrder order);
|
||||
|
||||
/*
|
||||
* 获取 所有订单 交割合约总资产、总未实现盈利
|
||||
*/
|
||||
public Map<String, Object> getMoneyFutures(Serializable partyId);
|
||||
|
||||
/*
|
||||
* 获取 单个订单 交割合约总资产、总未实现盈利
|
||||
*/
|
||||
public Map<String, Double> getMoneyFuturesByOrder(FuturesOrder order);
|
||||
|
||||
/**
|
||||
* 币币交易限价单
|
||||
*/
|
||||
public double getMoneyexchangeApplyOrders(Serializable partyId, List<Realtime> realtimeall);
|
||||
|
||||
}
|
||||
133
comm/Wallet/src/project/wallet/PropertiesUtilWallet.java
Executable file
133
comm/Wallet/src/project/wallet/PropertiesUtilWallet.java
Executable file
@@ -0,0 +1,133 @@
|
||||
package project.wallet;
|
||||
|
||||
|
||||
|
||||
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 PropertiesUtilWallet {
|
||||
private static Log log = LogFactory.getLog(PropertiesUtilWallet.class);
|
||||
private static String CONFIG_FILENAME = "config/wallet.properties";
|
||||
private static Properties prop = null;
|
||||
|
||||
public PropertiesUtilWallet() {
|
||||
if (prop == null) {
|
||||
loadProperties();
|
||||
}
|
||||
};
|
||||
|
||||
private synchronized static void loadProperties() {
|
||||
byte buff[]=null;
|
||||
try {
|
||||
//Open the props file
|
||||
InputStream is=PropertiesUtilWallet.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(PropertiesUtilWallet.getProperty("mail.username"));
|
||||
}
|
||||
}
|
||||
31
comm/Wallet/src/project/wallet/Wallet.hbm.xml
Executable file
31
comm/Wallet/src/project/wallet/Wallet.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.wallet.Wallet" table="T_WALLET">
|
||||
<id name="id" type="java.lang.String" >
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String" update="false">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="money" type="java.lang.Double">
|
||||
<column name="MONEY" />
|
||||
</property>
|
||||
<property name="rebate" type="java.lang.Double">
|
||||
<column name="REBATE" />
|
||||
</property>
|
||||
<property name="rechargeCommission" type="java.lang.Double">
|
||||
<column name="RECHARGE_COMMISSION" />
|
||||
</property>
|
||||
<property name="frozenState" type="int">
|
||||
<column name="FROZEN_STATE" />
|
||||
</property>
|
||||
<property name="moneyAfterFrozen" type="java.lang.Double">
|
||||
<column name="MONEY_AFTER_FROZEN" />
|
||||
</property>
|
||||
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
85
comm/Wallet/src/project/wallet/Wallet.java
Executable file
85
comm/Wallet/src/project/wallet/Wallet.java
Executable file
@@ -0,0 +1,85 @@
|
||||
package project.wallet;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
* 钱包
|
||||
*
|
||||
*/
|
||||
public class Wallet extends EntityObject {
|
||||
|
||||
private static final long serialVersionUID = 7522745589282180818L;
|
||||
|
||||
private Serializable partyId;
|
||||
/**
|
||||
* 现金
|
||||
*/
|
||||
private Double money = 0.0D;
|
||||
|
||||
private Double rebate = 0.0D;
|
||||
|
||||
/**
|
||||
* 累计充值提成,注意:此为一个用于提示的字段,不可用于提现
|
||||
*/
|
||||
private Double rechargeCommission = 0.0;
|
||||
|
||||
/** 2023-10-24 新增需求,冻结以后返佣等加钱操作不可用于采购,只有新充值金额可以用于采购
|
||||
* 冻结后的充值金额
|
||||
*/
|
||||
private double moneyAfterFrozen = 0.0D ;
|
||||
|
||||
/**
|
||||
* 冻结状态 默认0-未冻结,1-已冻结
|
||||
*/
|
||||
private int frozenState = 0 ;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return this.partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public Double getMoney() {
|
||||
return this.money;
|
||||
}
|
||||
|
||||
public void setMoney(Double money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public Double getRebate() {
|
||||
return rebate;
|
||||
}
|
||||
|
||||
public void setRebate(Double rebate) {
|
||||
this.rebate = rebate;
|
||||
}
|
||||
|
||||
public Double getRechargeCommission() {
|
||||
return rechargeCommission;
|
||||
}
|
||||
|
||||
public void setRechargeCommission(Double rechargeCommission) {
|
||||
this.rechargeCommission = rechargeCommission;
|
||||
}
|
||||
|
||||
public double getMoneyAfterFrozen() {
|
||||
return moneyAfterFrozen;
|
||||
}
|
||||
|
||||
public void setMoneyAfterFrozen(double moneyAfterFrozen) {
|
||||
this.moneyAfterFrozen = moneyAfterFrozen;
|
||||
}
|
||||
|
||||
public int getFrozenState() {
|
||||
return frozenState;
|
||||
}
|
||||
|
||||
public void setFrozenState(int frozenState) {
|
||||
this.frozenState = frozenState;
|
||||
}
|
||||
}
|
||||
18
comm/Wallet/src/project/wallet/WalletDay.hbm.xml
Executable file
18
comm/Wallet/src/project/wallet/WalletDay.hbm.xml
Executable file
@@ -0,0 +1,18 @@
|
||||
<?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.wallet.WalletDay" table="T_WALLET_DAY">
|
||||
<id name="id" type="java.lang.String" >
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="amount" type="java.lang.Double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
42
comm/Wallet/src/project/wallet/WalletDay.java
Executable file
42
comm/Wallet/src/project/wallet/WalletDay.java
Executable file
@@ -0,0 +1,42 @@
|
||||
package project.wallet;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 用户钱包 每日统计
|
||||
*
|
||||
*/
|
||||
public class WalletDay extends EntityObject {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 8800518972776269909L;
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private double amount = 0.0D;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
|
||||
public double getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
20
comm/Wallet/src/project/wallet/WalletExtend.hbm.xml
Executable file
20
comm/Wallet/src/project/wallet/WalletExtend.hbm.xml
Executable file
@@ -0,0 +1,20 @@
|
||||
<?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.wallet.WalletExtend" table="T_WALLET_EXTEND">
|
||||
<id name="id" type="java.lang.String" >
|
||||
<column name="UUID" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String" update="false">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="wallettype" type="java.lang.String" update="false">
|
||||
<column name="WALLETTYPE" />
|
||||
</property>
|
||||
<property name="amount" type="java.lang.Double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
57
comm/Wallet/src/project/wallet/WalletExtend.java
Executable file
57
comm/Wallet/src/project/wallet/WalletExtend.java
Executable file
@@ -0,0 +1,57 @@
|
||||
package project.wallet;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
* 钱包扩展
|
||||
*
|
||||
*/
|
||||
public class WalletExtend extends EntityObject {
|
||||
private static final long serialVersionUID = -926374250240199976L;
|
||||
private Serializable partyId;
|
||||
/**
|
||||
* 币种,见Constants定义
|
||||
*/
|
||||
private String wallettype;
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private double amount = 0.0D;
|
||||
|
||||
private String name;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return this.partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public String getWallettype() {
|
||||
return this.wallettype;
|
||||
}
|
||||
|
||||
public void setWallettype(String wallettype) {
|
||||
this.wallettype = wallettype;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
36
comm/Wallet/src/project/wallet/WalletLog.hbm.xml
Executable file
36
comm/Wallet/src/project/wallet/WalletLog.hbm.xml
Executable file
@@ -0,0 +1,36 @@
|
||||
<?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.wallet.WalletLog" table="T_WALLET_LOG">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String"
|
||||
update="false">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="category" type="java.lang.String" update="false">
|
||||
<column name="CATEGORY" />
|
||||
</property>
|
||||
<property name="order_no" type="java.lang.String" update="false">
|
||||
<column name="ORDER_NO" />
|
||||
</property>
|
||||
<property name="status" type="int" update="true">
|
||||
<column name="STATUS" />
|
||||
</property>
|
||||
<property name="amount" type="java.lang.Double" update="false">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="usdtAmount" type="java.lang.Double" update="true">
|
||||
<column name="USDT_AMOUNT" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp" update="false">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
<property name="wallettype" type="java.lang.String" update="false">
|
||||
<column name="WALLETTYPE" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
112
comm/Wallet/src/project/wallet/WalletLog.java
Executable file
112
comm/Wallet/src/project/wallet/WalletLog.java
Executable file
@@ -0,0 +1,112 @@
|
||||
package project.wallet;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
/**
|
||||
* 充提记录
|
||||
*
|
||||
*/
|
||||
public class WalletLog extends EntityObject {
|
||||
private static final long serialVersionUID = 5914244062518608589L;
|
||||
|
||||
private Serializable partyId;
|
||||
|
||||
private String order_no;
|
||||
|
||||
// 原始充值金额,注意:不一定都是 USDT 单位,需要根据 wallettype 执行换算
|
||||
private double amount = 0.0D;
|
||||
|
||||
// 如上:换算成 USDT 的金额
|
||||
private double usdtAmount = 0.0D;
|
||||
|
||||
/**
|
||||
* 资金账变类型,
|
||||
* project.Constants(line:214-250)
|
||||
*/
|
||||
private String category;
|
||||
|
||||
private int status;
|
||||
|
||||
// 创建时间
|
||||
private Date createTime;
|
||||
|
||||
private String createTimeStr;
|
||||
/**
|
||||
* 交易币种,保持交易时的币种
|
||||
*/
|
||||
private String wallettype;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public String getOrder_no() {
|
||||
return order_no;
|
||||
}
|
||||
|
||||
public void setOrder_no(String order_no) {
|
||||
this.order_no = order_no;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getCreateTimeStr() {
|
||||
return createTimeStr;
|
||||
}
|
||||
|
||||
public void setCreateTimeStr(String createTimeStr) {
|
||||
this.createTimeStr = createTimeStr;
|
||||
}
|
||||
|
||||
public String getWallettype() {
|
||||
return wallettype;
|
||||
}
|
||||
|
||||
public void setWallettype(String wallettype) {
|
||||
this.wallettype = wallettype;
|
||||
}
|
||||
|
||||
public double getUsdtAmount() {
|
||||
return usdtAmount;
|
||||
}
|
||||
|
||||
public void setUsdtAmount(double usdtAmount) {
|
||||
this.usdtAmount = usdtAmount;
|
||||
}
|
||||
}
|
||||
206
comm/Wallet/src/project/wallet/WalletLogService.java
Executable file
206
comm/Wallet/src/project/wallet/WalletLogService.java
Executable file
@@ -0,0 +1,206 @@
|
||||
package project.wallet;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.wallet.dto.RechargePartyResultDTO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 充提记录
|
||||
*
|
||||
*/
|
||||
public interface WalletLogService {
|
||||
|
||||
public void save(WalletLog entity);
|
||||
|
||||
public WalletLog find(String category, String order_no);
|
||||
|
||||
WalletLog findById(String id);
|
||||
|
||||
public void update(WalletLog entity);
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String partyId, String category, String order_no_null);
|
||||
|
||||
public Page pagedQueryWithdraw(int pageNo, int pageSize, String partyId, String order_no_null);
|
||||
|
||||
public Page pagedQueryRecharge(int pageNo, int pageSize, String partyId, String order_no_null);
|
||||
|
||||
public Page pagedQueryRecords(int pageNo, int pageSize, String partyId, String category);
|
||||
|
||||
public WalletLog find(String order_no);
|
||||
|
||||
/**
|
||||
* 根据订单去更新日志状态
|
||||
*
|
||||
* @param orderNo
|
||||
* @param status
|
||||
*/
|
||||
public void updateStatus(String orderNo, int status);
|
||||
|
||||
double getComputeRechargeAmount(String partyId);
|
||||
|
||||
List<WalletLog> getAll();
|
||||
|
||||
/**
|
||||
* 统计指定用户累计有效充值金额
|
||||
*
|
||||
* @param partyIdList
|
||||
* @param limitAmount
|
||||
* @return
|
||||
*/
|
||||
Map<String, Double> getComputeRechargeAmount(List<String> partyIdList, double limitAmount);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计充值人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
Integer getCountWithdrawByDay(String startTime , String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计充值人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
Integer getCacheCountWithdrawByDay(String startTime , String endTime);
|
||||
|
||||
/**
|
||||
* 根据时间统计提现人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
Integer getCountRechargeByDay(String startTime , String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计提现人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
Integer getCacheCountRechargeByDay(String startTime , String endTime);
|
||||
|
||||
/**
|
||||
* 根据时间统计订单返佣金额
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计订单返佣金额
|
||||
*/
|
||||
|
||||
Map<String, Object> getTotalProfitByDay(String startTime , String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计订单返佣金额
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计订单返佣金额
|
||||
*/
|
||||
|
||||
Map<String, Object> getCacheTotalProfitByDay(String startTime , String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计提现金额
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计提现金额
|
||||
*/
|
||||
|
||||
Map<String, Object> getSumWithdrawByDay(String startTime , String endTime);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计提现金额
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计提现金额
|
||||
*/
|
||||
|
||||
Map<String, Object> getCacheSumWithdrawByDay(String startTime , String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计充值金额,店铺ID
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计充值金额
|
||||
*/
|
||||
|
||||
Map<String, Object> getSumRechargeByDay(String startTime , String endTime , List<String> sellerIds);
|
||||
|
||||
/**
|
||||
* 根据时间统计充值金额,店铺ID
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计充值金额
|
||||
*/
|
||||
|
||||
Map<String, Object> getCacheSumRechargeByDay(String startTime , String endTime , List<String> sellerIds);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计新充值人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计新提现人数
|
||||
*/
|
||||
RechargePartyResultDTO getNewRechargeByDay(String startTime, String endTime) ;
|
||||
|
||||
/**
|
||||
* 根据时间统计新充值人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计新提现人数
|
||||
*/
|
||||
RechargePartyResultDTO getCacheNewRechargeByDay(String startTime, String endTime) ;
|
||||
|
||||
/**
|
||||
* 根据时间统计新提现人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计新提现人数
|
||||
*/
|
||||
RechargePartyResultDTO getNewWithdrawByDay(String startTime, String endTime) ;
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计新提现人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计新提现人数
|
||||
*/
|
||||
RechargePartyResultDTO getCacheNewWithdrawByDay(String startTime, String endTime) ;
|
||||
|
||||
/**
|
||||
* 提取指定用户自指定时间以来的第一笔有效充值记录
|
||||
*
|
||||
* @param partyId
|
||||
* @param limitTime
|
||||
* @return
|
||||
*/
|
||||
WalletLog getFirstRechargeLogInTimeRange(String partyId, Date limitTime);
|
||||
|
||||
}
|
||||
16
comm/Wallet/src/project/wallet/WalletRedisKeys.java
Executable file
16
comm/Wallet/src/project/wallet/WalletRedisKeys.java
Executable file
@@ -0,0 +1,16 @@
|
||||
package project.wallet;
|
||||
|
||||
public class WalletRedisKeys {
|
||||
public final static String WALLET_PARTY_ID = "WALLET_PARTY_ID_";
|
||||
/**
|
||||
* wallet update队列
|
||||
*/
|
||||
public final static String WALLET_QUEUE_UPDATE = "WALLET_QUEUE_UPDATE_";
|
||||
|
||||
public final static String WALLET_EXTEND_PARTY_ID = "WALLET_EXTEND_PARTY_ID_";
|
||||
|
||||
/**
|
||||
* wallet_extend update队列
|
||||
*/
|
||||
public final static String WALLET_EXTEND_QUEUE_UPDATE = "WALLET_EXTEND_QUEUE_UPDATE_";
|
||||
}
|
||||
66
comm/Wallet/src/project/wallet/WalletService.java
Executable file
66
comm/Wallet/src/project/wallet/WalletService.java
Executable file
@@ -0,0 +1,66 @@
|
||||
package project.wallet;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 钱包
|
||||
*/
|
||||
public interface WalletService {
|
||||
|
||||
Wallet selectOne(String partyId);
|
||||
|
||||
public Wallet saveWalletByPartyId(Serializable partyId);
|
||||
|
||||
public void save(Wallet wallet);
|
||||
|
||||
public void update(Wallet wallet);
|
||||
|
||||
public void update(String partyId, double amount);
|
||||
|
||||
public void updateMoeny(String partyId, double amount);
|
||||
|
||||
|
||||
//冻结金额后 用户资金余额
|
||||
|
||||
public void update(String partyId, double amount, double rebate);
|
||||
|
||||
void update(String partyId, double amount, double rebate, double rechargeCommission);
|
||||
|
||||
|
||||
double selectTotalIncome(String partyId);
|
||||
|
||||
public WalletExtend saveExtendByPara(Serializable partyId, String wallettype);
|
||||
|
||||
public List<WalletExtend> findExtend(Serializable partyId);
|
||||
|
||||
public List<WalletExtend> findExtend(Serializable partyId, List<String> list_symbol);
|
||||
|
||||
public void save(WalletExtend walletExtend);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param partyId
|
||||
* @param walletType
|
||||
* @param amount修改的金额
|
||||
*/
|
||||
public void updateExtend(String partyId, String walletType, double amount);
|
||||
|
||||
// public WalletExtend findExtendByPara(Serializable partyId, String wallettype);
|
||||
|
||||
/**
|
||||
* 转账给其他用户 出款方 byPartyId 收款方Uid toPartyId 手续费数量
|
||||
*/
|
||||
public void updateTransfer_wallet(String byPartyId, String safeword, String toPartyId, String coin, double amount,
|
||||
double fee_amount);
|
||||
|
||||
public List<WalletExtend> findAllWalletExtend();
|
||||
|
||||
public List<Wallet> findAllWallet();
|
||||
|
||||
public WalletExtend getInvestPoint(String partyId);
|
||||
|
||||
public void updateInvestPoint(String partyId,int addPoint);
|
||||
|
||||
public Double getInvestPointBuyPartyId(String partyId);
|
||||
}
|
||||
144
comm/Wallet/src/project/wallet/consumer/WalletConsumeServer.java
Executable file
144
comm/Wallet/src/project/wallet/consumer/WalletConsumeServer.java
Executable file
@@ -0,0 +1,144 @@
|
||||
package project.wallet.consumer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import kernel.util.JsonUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.ThreadUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import project.redis.RedisHandler;
|
||||
import project.wallet.WalletRedisKeys;
|
||||
|
||||
public class WalletConsumeServer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(WalletConsumeServer.class);
|
||||
|
||||
private volatile static Map<String, Date> lastTime = new ConcurrentHashMap<String, Date>();
|
||||
|
||||
private static ConcurrentLinkedQueue<WalletMessage> WORKING_SLOW = new ConcurrentLinkedQueue<WalletMessage>();
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
private WalletDao walletDao;
|
||||
|
||||
ExecutorService FAST_THREAD = Executors.newSingleThreadExecutor();
|
||||
|
||||
ExecutorService SLOW_THREAD = Executors.newSingleThreadExecutor();
|
||||
|
||||
public void start() {
|
||||
FAST_THREAD.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
WalletMessage item = null;
|
||||
boolean lock = false;
|
||||
try {
|
||||
item = (WalletMessage) redisHandler.poll(WalletRedisKeys.WALLET_QUEUE_UPDATE);
|
||||
|
||||
if (item != null) {
|
||||
if (!WalletLockFilter.add(item.getPartyId().toString())) {
|
||||
WORKING_SLOW.add(item);
|
||||
continue;
|
||||
}
|
||||
lock = true;
|
||||
if (lastTime.containsKey(item.getPartyId().toString())) {
|
||||
long millis = DateUtils.calcTimeBetweenInMillis(
|
||||
lastTime.get(item.getPartyId().toString()), new Date());
|
||||
if (millis >= 100) {
|
||||
lastTime.put(item.getPartyId().toString(), new Date());
|
||||
logger.info("------> WalletConsumeServer.run1 为用户:{} 累加账户余额:{}", item.getPartyId(), item.getMoney());
|
||||
walletDao.update(item);
|
||||
} else {// 进入慢队列
|
||||
WORKING_SLOW.add(item);
|
||||
}
|
||||
} else {
|
||||
lastTime.put(item.getPartyId().toString(), new Date());
|
||||
logger.info("------> WalletConsumeServer.run2 为用户:{} 累加账户余额:{}", item.getPartyId(), item.getMoney());
|
||||
walletDao.update(item);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("------> WalletConsumeServer FAST_THREAD() fail", e);
|
||||
|
||||
} finally {
|
||||
if (item == null) {
|
||||
ThreadUtils.sleep(100);
|
||||
}
|
||||
if (lock) {
|
||||
WalletLockFilter.remove(item.getPartyId().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
SLOW_THREAD.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
WalletMessage item = null;
|
||||
boolean lock = false;
|
||||
try {
|
||||
item = WORKING_SLOW.poll();
|
||||
|
||||
if (item != null) {
|
||||
if (!WalletLockFilter.add(item.getPartyId().toString())) {
|
||||
logger.info("------> WalletConsumeServer.run3 账户变更信息再次放入 SLOW 队列:{}", JsonUtils.bean2Json(item));
|
||||
WORKING_SLOW.add(item);
|
||||
continue;
|
||||
}
|
||||
lock = true;
|
||||
if (lastTime.containsKey(item.getPartyId().toString())) {
|
||||
long millis = DateUtils.calcTimeBetweenInMillis(
|
||||
lastTime.get(item.getPartyId().toString()), new Date());
|
||||
if (millis >= 100) {// 超过100毫秒则执行一次
|
||||
lastTime.put(item.getPartyId().toString(), new Date());
|
||||
logger.info("------> WalletConsumeServer.run4 为用户:{} 累加账户余额:{}", item.getPartyId(), item.getMoney());
|
||||
walletDao.update(item);
|
||||
} else {// 重新进入慢队列,等待下次运行
|
||||
WORKING_SLOW.add(item);
|
||||
logger.info("------> WalletConsumeServer.run5 账户变更信息再次放入 SLOW 队列:{}", JsonUtils.bean2Json(item));
|
||||
}
|
||||
} else {
|
||||
lastTime.put(item.getPartyId().toString(), new Date());
|
||||
logger.info("------> WalletConsumeServer.run6 为用户:{} 累加账户余额:{}", item.getPartyId(), item.getMoney());
|
||||
walletDao.update(item);
|
||||
}
|
||||
} else {
|
||||
ThreadUtils.sleep(100);
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("WalletConsumeServer SLOW_THREAD.execute() fail", e);
|
||||
} finally {
|
||||
ThreadUtils.sleep(100);
|
||||
if (lock) {
|
||||
WalletLockFilter.remove(item.getPartyId().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setWalletDao(WalletDao walletDao) {
|
||||
this.walletDao = walletDao;
|
||||
}
|
||||
|
||||
}
|
||||
8
comm/Wallet/src/project/wallet/consumer/WalletDao.java
Executable file
8
comm/Wallet/src/project/wallet/consumer/WalletDao.java
Executable file
@@ -0,0 +1,8 @@
|
||||
package project.wallet.consumer;
|
||||
|
||||
public interface WalletDao {
|
||||
|
||||
public void update(WalletMessage walletMessage);
|
||||
|
||||
public void update(WalletExtendMessage walletExtendMessage);
|
||||
}
|
||||
57
comm/Wallet/src/project/wallet/consumer/WalletDaoImpl.java
Executable file
57
comm/Wallet/src/project/wallet/consumer/WalletDaoImpl.java
Executable file
@@ -0,0 +1,57 @@
|
||||
package project.wallet.consumer;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
public class WalletDaoImpl implements WalletDao {
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
public void update(final WalletMessage walletMessage) {
|
||||
String sql = "UPDATE T_WALLET SET MONEY=ROUND(MONEY+?,8),REBATE=ROUND(REBATE+?,8),RECHARGE_COMMISSION=ROUND(RECHARGE_COMMISSION+?,8) WHERE PARTY_ID=?";
|
||||
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||
ps.setDouble(1, walletMessage.getMoney());
|
||||
ps.setDouble(2, walletMessage.getRebate());
|
||||
ps.setDouble(3, walletMessage.getRechargeCommission());
|
||||
ps.setString(4, walletMessage.getPartyId().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final WalletExtendMessage walletExtendMessage) {
|
||||
String sql = "UPDATE T_WALLET_EXTEND SET AMOUNT=ROUND(AMOUNT+?,8) WHERE PARTY_ID=? AND WALLETTYPE=? ";
|
||||
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||
ps.setDouble(1, walletExtendMessage.getVolumn());
|
||||
ps.setString(2, walletExtendMessage.getPartyId().toString());
|
||||
ps.setString(3, walletExtendMessage.getWalletType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
137
comm/Wallet/src/project/wallet/consumer/WalletExtendConsumeServer.java
Executable file
137
comm/Wallet/src/project/wallet/consumer/WalletExtendConsumeServer.java
Executable file
@@ -0,0 +1,137 @@
|
||||
package project.wallet.consumer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.ThreadUtils;
|
||||
import project.redis.RedisHandler;
|
||||
import project.wallet.WalletRedisKeys;
|
||||
|
||||
public class WalletExtendConsumeServer {
|
||||
private static Log logger = LogFactory.getLog(WalletExtendConsumeServer.class);
|
||||
private volatile static Map<String, Date> lastTime = new ConcurrentHashMap<String, Date>();
|
||||
|
||||
private static ConcurrentLinkedQueue<WalletExtendMessage> WORKING_SLOW = new ConcurrentLinkedQueue<WalletExtendMessage>();
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
private WalletDao walletDao;
|
||||
|
||||
ExecutorService FAST_THREAD = Executors.newSingleThreadExecutor();
|
||||
|
||||
ExecutorService SLOW_THREAD = Executors.newSingleThreadExecutor();
|
||||
|
||||
public void start() {
|
||||
FAST_THREAD.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
WalletExtendMessage item = null;
|
||||
boolean lock = false;
|
||||
try {
|
||||
item = (WalletExtendMessage) redisHandler.poll(WalletRedisKeys.WALLET_EXTEND_QUEUE_UPDATE);
|
||||
|
||||
if (item != null) {
|
||||
if (!WalletLockFilter.add(item.getPartyId().toString() + item.getWalletType())) {
|
||||
WORKING_SLOW.add(item);
|
||||
continue;
|
||||
}
|
||||
lock = true;
|
||||
if (lastTime.containsKey(item.getPartyId().toString())) {
|
||||
long millis = DateUtils.calcTimeBetweenInMillis(
|
||||
lastTime.get(item.getPartyId().toString()), new Date());
|
||||
if (millis >= 100) {
|
||||
lastTime.put(item.getPartyId().toString(), new Date());
|
||||
walletDao.update(item);
|
||||
} else {// 进入慢队列
|
||||
WORKING_SLOW.add(item);
|
||||
}
|
||||
|
||||
} else {
|
||||
lastTime.put(item.getPartyId().toString(), new Date());
|
||||
walletDao.update(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("WalletConsumeServer FAST_THREAD() fail", e);
|
||||
|
||||
} finally {
|
||||
if (item == null) {
|
||||
ThreadUtils.sleep(100);
|
||||
}
|
||||
if (lock) {
|
||||
WalletLockFilter.remove(item.getPartyId().toString() + item.getWalletType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
SLOW_THREAD.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
WalletExtendMessage item = null;
|
||||
boolean lock = false;
|
||||
try {
|
||||
item = WORKING_SLOW.poll();
|
||||
|
||||
if (item != null) {
|
||||
if (!WalletLockFilter.add(item.getPartyId().toString() + item.getWalletType())) {
|
||||
WORKING_SLOW.add(item);
|
||||
continue;
|
||||
}
|
||||
lock = true;
|
||||
if (lastTime.containsKey(item.getPartyId().toString())) {
|
||||
long millis = DateUtils.calcTimeBetweenInMillis(
|
||||
lastTime.get(item.getPartyId().toString()), new Date());
|
||||
if (millis >= 100) {// 超过500毫秒则执行一次
|
||||
lastTime.put(item.getPartyId().toString(), new Date());
|
||||
walletDao.update(item);
|
||||
} else {// 重新进入慢队列,等待下次运行
|
||||
WORKING_SLOW.add(item);
|
||||
}
|
||||
} else {
|
||||
lastTime.put(item.getPartyId().toString(), new Date());
|
||||
walletDao.update(item);
|
||||
}
|
||||
|
||||
} else {
|
||||
ThreadUtils.sleep(100);
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("SmsServer taskExecutor.execute() fail", e);
|
||||
|
||||
} finally {
|
||||
ThreadUtils.sleep(100);
|
||||
if (lock) {
|
||||
WalletLockFilter.remove(item.getPartyId().toString() + item.getWalletType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setWalletDao(WalletDao walletDao) {
|
||||
this.walletDao = walletDao;
|
||||
}
|
||||
|
||||
}
|
||||
62
comm/Wallet/src/project/wallet/consumer/WalletExtendMessage.java
Executable file
62
comm/Wallet/src/project/wallet/consumer/WalletExtendMessage.java
Executable file
@@ -0,0 +1,62 @@
|
||||
package project.wallet.consumer;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WalletExtendMessage implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2239789461218349202L;
|
||||
|
||||
/**
|
||||
* 无参构造函数
|
||||
*/
|
||||
public WalletExtendMessage() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
*/
|
||||
public WalletExtendMessage(Serializable partyId, String walletType, double volumn) {
|
||||
this.partyId = partyId;
|
||||
this.volumn = volumn;
|
||||
this.walletType = walletType;
|
||||
}
|
||||
|
||||
private Serializable partyId;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private double volumn = 0.0D;
|
||||
/**
|
||||
* 币种类型
|
||||
*/
|
||||
private String walletType;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public double getVolumn() {
|
||||
return volumn;
|
||||
}
|
||||
|
||||
public String getWalletType() {
|
||||
return walletType;
|
||||
}
|
||||
|
||||
public void setVolumn(double volumn) {
|
||||
this.volumn = volumn;
|
||||
}
|
||||
|
||||
public void setWalletType(String walletType) {
|
||||
this.walletType = walletType;
|
||||
}
|
||||
|
||||
}
|
||||
21
comm/Wallet/src/project/wallet/consumer/WalletLockFilter.java
Executable file
21
comm/Wallet/src/project/wallet/consumer/WalletLockFilter.java
Executable file
@@ -0,0 +1,21 @@
|
||||
package project.wallet.consumer;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class WalletLockFilter {
|
||||
private static final Set<String> filter = new HashSet<String>();
|
||||
|
||||
public static boolean add(String target) {
|
||||
if (!filter.add(target)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void remove(String target) {
|
||||
filter.remove(target);
|
||||
}
|
||||
|
||||
}
|
||||
72
comm/Wallet/src/project/wallet/consumer/WalletMessage.java
Executable file
72
comm/Wallet/src/project/wallet/consumer/WalletMessage.java
Executable file
@@ -0,0 +1,72 @@
|
||||
package project.wallet.consumer;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WalletMessage implements Serializable {
|
||||
private static final long serialVersionUID = 2239789461218349202L;
|
||||
|
||||
/**
|
||||
* 无参构造函数
|
||||
*/
|
||||
public WalletMessage() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param partyId
|
||||
* @param money
|
||||
*/
|
||||
public WalletMessage(Serializable partyId, double money) {
|
||||
this.partyId = partyId;
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
private Serializable partyId;
|
||||
/**
|
||||
* 现金
|
||||
*/
|
||||
private double money = 0.0D;
|
||||
|
||||
/**
|
||||
* 返水
|
||||
*/
|
||||
private double rebate = 0.0D;
|
||||
|
||||
/**
|
||||
* 充值时业务员提成
|
||||
*/
|
||||
private double rechargeCommission = 0.0D;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public double getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(double money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public double getRebate() {
|
||||
return rebate;
|
||||
}
|
||||
|
||||
public void setRebate(double rebate) {
|
||||
this.rebate = rebate;
|
||||
}
|
||||
|
||||
public double getRechargeCommission() {
|
||||
return rechargeCommission;
|
||||
}
|
||||
|
||||
public void setRechargeCommission(double rechargeCommission) {
|
||||
this.rechargeCommission = rechargeCommission;
|
||||
}
|
||||
}
|
||||
21
comm/Wallet/src/project/wallet/dto/PartySumDataDTO.java
Executable file
21
comm/Wallet/src/project/wallet/dto/PartySumDataDTO.java
Executable file
@@ -0,0 +1,21 @@
|
||||
package project.wallet.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author axing
|
||||
* @since 2023/8/15
|
||||
**/
|
||||
@Data
|
||||
public class PartySumDataDTO implements Serializable {
|
||||
|
||||
private Double totalRecharge;
|
||||
|
||||
private Double totalWithdraw;
|
||||
|
||||
private Integer rechargeNum;
|
||||
|
||||
private Integer withdrawNum;
|
||||
}
|
||||
15
comm/Wallet/src/project/wallet/dto/RechargePartyDTO.java
Executable file
15
comm/Wallet/src/project/wallet/dto/RechargePartyDTO.java
Executable file
@@ -0,0 +1,15 @@
|
||||
package project.wallet.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Data
|
||||
public class RechargePartyDTO implements Serializable {
|
||||
|
||||
private Double amount;
|
||||
|
||||
private String sellerId;
|
||||
|
||||
}
|
||||
14
comm/Wallet/src/project/wallet/dto/RechargePartyResultDTO.java
Executable file
14
comm/Wallet/src/project/wallet/dto/RechargePartyResultDTO.java
Executable file
@@ -0,0 +1,14 @@
|
||||
package project.wallet.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Data
|
||||
public class RechargePartyResultDTO implements Serializable {
|
||||
|
||||
private Integer number;
|
||||
|
||||
private String amount;
|
||||
}
|
||||
583
comm/Wallet/src/project/wallet/internal/AssetServiceImpl.java
Executable file
583
comm/Wallet/src/project/wallet/internal/AssetServiceImpl.java
Executable file
@@ -0,0 +1,583 @@
|
||||
package project.wallet.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.StringUtils;
|
||||
import project.contract.ContractApplyOrder;
|
||||
import project.contract.ContractApplyOrderService;
|
||||
import project.contract.ContractOrder;
|
||||
import project.contract.ContractOrderService;
|
||||
import project.contract.ContractRedisKeys;
|
||||
import project.data.DataService;
|
||||
import project.data.model.Realtime;
|
||||
import project.exchange.ExchangeApplyOrder;
|
||||
import project.exchange.ExchangeApplyOrderService;
|
||||
import project.finance.FinanceOrder;
|
||||
import project.finance.FinanceOrderService;
|
||||
import project.futures.FuturesOrder;
|
||||
import project.futures.FuturesOrderService;
|
||||
import project.futures.FuturesRedisKeys;
|
||||
import project.item.ItemService;
|
||||
import project.item.model.Item;
|
||||
import project.miner.MinerOrderService;
|
||||
import project.miner.MinerRedisKeys;
|
||||
import project.miner.model.MinerOrder;
|
||||
import project.redis.RedisHandler;
|
||||
import project.syspara.SysparaService;
|
||||
import project.wallet.AssetService;
|
||||
import project.wallet.Wallet;
|
||||
import project.wallet.WalletExtend;
|
||||
import project.wallet.WalletService;
|
||||
|
||||
public class AssetServiceImpl extends HibernateDaoSupport implements AssetService {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(AssetServiceImpl.class);
|
||||
|
||||
private ContractOrderService contractOrderService;
|
||||
private ContractApplyOrderService contractApplyOrderService;
|
||||
private WalletService walletService;
|
||||
private DataService dataService;
|
||||
private FinanceOrderService financeOrderService;
|
||||
private MinerOrderService minerOrderService;
|
||||
private FuturesOrderService futuresOrderService;
|
||||
private ExchangeApplyOrderService exchangeApplyOrderService;
|
||||
private SysparaService sysparaService;
|
||||
private ItemService itemService;
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public Map<String, Object> getMoneyAll(Serializable partyId) {
|
||||
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
DecimalFormat df2 = new DecimalFormat("#.##");
|
||||
|
||||
double money = 0;
|
||||
double money_wallet = 0;
|
||||
double money_coin = 0;
|
||||
double money_all_coin = 0;
|
||||
double money_finance = 0;
|
||||
double money_miner = 0;
|
||||
double money_contractApply = 0;
|
||||
double money_contract = 0;
|
||||
double money_contract_deposit = 0;
|
||||
double money_contract_profit = 0;
|
||||
double money_futures = 0;
|
||||
double money_futures_profit = 0;
|
||||
|
||||
// 先获取一次所有币种的数据来计算
|
||||
String data_symbol = "";
|
||||
List<String> list_symbol = new ArrayList<String>();
|
||||
|
||||
List<Item> list_items = this.itemService.cacheGetByMarket("");
|
||||
for (int i = 0; i < list_items.size(); i++) {
|
||||
Item items = list_items.get(i);
|
||||
list_symbol.add(items.getSymbol());
|
||||
if (i != 0) {
|
||||
data_symbol = data_symbol + "," + items.getSymbol();
|
||||
} else {
|
||||
data_symbol = items.getSymbol();
|
||||
}
|
||||
}
|
||||
|
||||
List<Realtime> realtime_all = this.dataService.realtime(data_symbol);
|
||||
if (realtime_all.size() <= 0) {
|
||||
throw new BusinessException("系统错误,请稍后重试");
|
||||
}
|
||||
|
||||
// usdt余额
|
||||
Wallet wallet = new Wallet();
|
||||
if (!"".equals(partyId) && partyId != null) {
|
||||
wallet = this.walletService.saveWalletByPartyId(partyId);
|
||||
}
|
||||
|
||||
money = wallet.getMoney();
|
||||
// 钱包USDT
|
||||
money_wallet = wallet.getMoney();
|
||||
// 币余额
|
||||
money_coin = this.getMoneyCoin(partyId, realtime_all, list_symbol);
|
||||
money = money + money_coin;
|
||||
// 钱包USDT+币余额
|
||||
money_all_coin = money;
|
||||
// 理财
|
||||
money_finance = this.getMoneyFinance(partyId, realtime_all);
|
||||
money = money + money_finance;
|
||||
// 矿机
|
||||
money_miner = this.getMoneyMiner(partyId, realtime_all);
|
||||
// money_miner_redis = this.getMoneyMinerRedis(partyId, realtime_all);
|
||||
money = money + money_miner;
|
||||
// 永续委托
|
||||
money_contractApply = this.getMoneyContractApply(partyId);
|
||||
money = money + money_contractApply;
|
||||
|
||||
Map<String, Object> moneys_contract = this.getMoneyContract(partyId);
|
||||
// Map<String, Object> moneys_contract_redis = this.getMoneyContractRedis(partyId);
|
||||
// 永续
|
||||
money_contract = (Double) moneys_contract.get("money_contract");
|
||||
// 永续总保证金
|
||||
money_contract_deposit = (Double) moneys_contract.get("money_contract_deposit");
|
||||
// 永续总未实现盈亏
|
||||
money_contract_profit = (Double) moneys_contract.get("money_contract_profit");
|
||||
|
||||
money = money + money_contract;
|
||||
|
||||
Map<String, Object> moneys_futures = this.getMoneyFutures(partyId);
|
||||
// Map<String, Object> moneys_futures_redis = this.getMoneyFuturesRedis(partyId);
|
||||
// 交割
|
||||
money_futures = (Double) moneys_futures.get("money_futures");
|
||||
// 交割未实现盈亏
|
||||
money_futures_profit = (Double) moneys_futures.get("money_futures_profit");
|
||||
|
||||
money = money + money_futures;
|
||||
|
||||
// 币币交易
|
||||
money = money + this.getMoneyexchangeApplyOrders(partyId, realtime_all);
|
||||
|
||||
data.put("total", df2.format(money));
|
||||
data.put("money_wallet", df2.format(money_wallet));
|
||||
data.put("money_coin", df2.format(money_coin));
|
||||
data.put("money_all_coin", df2.format(money_all_coin));
|
||||
data.put("money_miner", df2.format(money_miner));
|
||||
data.put("money_finance", df2.format(money_finance));
|
||||
data.put("money_contract", df2.format(Arith.add(money_contract, money_contractApply)));
|
||||
data.put("money_contract_deposit", df2.format(money_contract_deposit));
|
||||
data.put("money_contract_profit", df2.format(money_contract_profit));
|
||||
data.put("money_futures", df2.format(money_futures));
|
||||
data.put("money_futures_profit", df2.format(money_futures_profit));
|
||||
// data.put("money_miner_redis", df2.format(money_miner_redis));
|
||||
// data.put("moneys_contract_redis", df2.format(moneys_contract_redis));
|
||||
// data.put("moneys_futures_redis", df2.format(moneys_futures_redis));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public double getMoneyCoin(Serializable partyId, List<Realtime> realtime_all, List<String> list_symbol) {
|
||||
double money_coin = 0;
|
||||
|
||||
List<WalletExtend> walletExtends = this.walletService.findExtend(partyId, list_symbol);
|
||||
WalletExtend walletExtend = new WalletExtend();
|
||||
if (realtime_all.size() <= 0) {
|
||||
|
||||
String data_symbol = "";
|
||||
|
||||
for (int i = 0; i < walletExtends.size(); i++) {
|
||||
walletExtend = walletExtends.get(i);
|
||||
if (walletExtend.getAmount() > 0) {
|
||||
if (i != 0) {
|
||||
data_symbol = data_symbol + "," + walletExtend.getWallettype();
|
||||
} else {
|
||||
data_symbol = walletExtend.getWallettype();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
walletExtend = new WalletExtend();
|
||||
|
||||
realtime_all = this.dataService.realtime(data_symbol);
|
||||
if (realtime_all.size() <= 0) {
|
||||
throw new BusinessException("系统错误,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
Realtime realtime = null;
|
||||
|
||||
// 如果2个相同,则说明用户所有币账户已经生成 .toUpperCase()/
|
||||
if (walletExtends != null && walletExtends.size() != 0) {
|
||||
|
||||
for (int i = 0; i < walletExtends.size(); i++) {
|
||||
if (null == walletExtends.get(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
walletExtend = walletExtends.get(i);
|
||||
if (walletExtend.getAmount() > 0) {
|
||||
realtime = null;
|
||||
|
||||
for (Realtime real : realtime_all) {
|
||||
if (real.getSymbol().equals(walletExtend.getWallettype().toLowerCase())) {
|
||||
realtime = real;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (realtime != null) {
|
||||
money_coin = Arith.add(money_coin, Arith.mul(realtime.getClose(), walletExtend.getAmount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return money_coin;
|
||||
}
|
||||
|
||||
public double getMoneyFinance(Serializable partyId, List<Realtime> realtimeall) {
|
||||
double money_finance = 0;
|
||||
List<FinanceOrder> financeOrders = financeOrderService.findByState(partyId.toString(), "1");
|
||||
String finance_profit_symbol = sysparaService.find("finance_profit_symbol").getValue();
|
||||
if (financeOrders != null) {
|
||||
Realtime realtime = null;
|
||||
if (!"".equals(finance_profit_symbol) && finance_profit_symbol != null && finance_profit_symbol != "usdt") {
|
||||
realtime = new Realtime();
|
||||
|
||||
if (realtimeall.size() <= 0) {
|
||||
List<Realtime> realtime_list = this.dataService.realtime(finance_profit_symbol);
|
||||
|
||||
if (realtime_list.size() > 0) {
|
||||
realtime = realtime_list.get(0);
|
||||
} else {
|
||||
throw new BusinessException("系统错误,请稍后重试");
|
||||
}
|
||||
} else {
|
||||
for (Realtime real : realtimeall) {
|
||||
if (real.getSymbol().equals(finance_profit_symbol)) {
|
||||
realtime = real;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (FinanceOrder order : financeOrders) {
|
||||
double amount = 0;
|
||||
if (!"".equals(finance_profit_symbol) && finance_profit_symbol != null
|
||||
&& finance_profit_symbol != "usdt") {
|
||||
amount = Arith.mul(order.getAmount(), realtime.getClose());
|
||||
} else {
|
||||
amount = order.getAmount();
|
||||
}
|
||||
money_finance = Arith.add(amount, money_finance);
|
||||
}
|
||||
}
|
||||
return money_finance;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取 所有订单 矿机总资产 redis
|
||||
*/
|
||||
public double getMoneyMinerRedis(Serializable partyId, List<Realtime> realtimeall) {
|
||||
|
||||
Double minerAssets = (Double) this.redisHandler.get(MinerRedisKeys.MINER_ASSETS_PARTY_ID + partyId.toString());
|
||||
double money_miner = null == minerAssets ? 0.000D : minerAssets;
|
||||
|
||||
String minerBuySymbol = this.sysparaService.find("miner_buy_symbol").getValue();
|
||||
if (!StringUtils.isEmptyString(minerBuySymbol)) {
|
||||
Realtime realtime = new Realtime();
|
||||
|
||||
if (realtimeall.size() <= 0) {
|
||||
List<Realtime> realtime_list = this.dataService.realtime(minerBuySymbol);
|
||||
|
||||
if (realtime_list.size() > 0) {
|
||||
realtime = realtime_list.get(0);
|
||||
} else {
|
||||
throw new BusinessException("系统错误,请稍后重试");
|
||||
}
|
||||
} else {
|
||||
for (Realtime real : realtimeall) {
|
||||
if (real.getSymbol().equals(minerBuySymbol)) {
|
||||
realtime = real;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double minerBuyClose = realtime.getClose();
|
||||
money_miner = Arith.mul(money_miner, minerBuyClose);
|
||||
}
|
||||
|
||||
return money_miner;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取 所有订单 矿机总资产
|
||||
*/
|
||||
public double getMoneyMiner(Serializable partyId, List<Realtime> realtimeall) {
|
||||
double money_miner = 0;
|
||||
List<MinerOrder> minerOrders = minerOrderService.findByState(partyId.toString(), "1");
|
||||
if (minerOrders != null) {
|
||||
for (MinerOrder order : minerOrders) {
|
||||
double amount = Arith.add(order.getAmount(), 0);
|
||||
money_miner = Arith.add(amount, money_miner);
|
||||
}
|
||||
String minerBuySymbol = sysparaService.find("miner_buy_symbol").getValue();
|
||||
if (!StringUtils.isEmptyString(minerBuySymbol)) {
|
||||
Realtime realtime = new Realtime();
|
||||
|
||||
if (realtimeall.size() <= 0) {
|
||||
List<Realtime> realtime_list = this.dataService.realtime(minerBuySymbol);
|
||||
|
||||
if (realtime_list.size() > 0) {
|
||||
realtime = realtime_list.get(0);
|
||||
} else {
|
||||
throw new BusinessException("系统错误,请稍后重试");
|
||||
}
|
||||
} else {
|
||||
for (Realtime real : realtimeall) {
|
||||
if (real.getSymbol().equals(minerBuySymbol)) {
|
||||
realtime = real;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
double minerBuyClose = realtime.getClose();
|
||||
money_miner = Arith.mul(money_miner, minerBuyClose);
|
||||
}
|
||||
}
|
||||
|
||||
return money_miner;
|
||||
}
|
||||
|
||||
public double getMoneyContractApply(Serializable partyId) {
|
||||
double money_contractApply = 0;
|
||||
|
||||
List<ContractApplyOrder> contractApplyOrders = this.contractApplyOrderService.findSubmitted(partyId.toString(), "", "", "");
|
||||
if (contractApplyOrders != null) {
|
||||
|
||||
for (ContractApplyOrder order : contractApplyOrders) {
|
||||
double amount = Arith.mul(order.getVolume_open(), order.getUnit_amount());
|
||||
money_contractApply = Arith.add(amount, money_contractApply);
|
||||
}
|
||||
}
|
||||
|
||||
return money_contractApply;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取 所有订单 永续合约总资产、总保证金、总未实现盈利 redis
|
||||
*/
|
||||
public Map<String, Object> getMoneyContractRedis(Serializable partyId) {
|
||||
|
||||
Double contractAssets = (Double) this.redisHandler.get(ContractRedisKeys.CONTRACT_ASSETS_PARTY_ID + partyId.toString());
|
||||
Double contractAssetsDeposit = (Double) this.redisHandler.get(ContractRedisKeys.CONTRACT_ASSETS_DEPOSIT_PARTY_ID + partyId.toString());
|
||||
Double contractAssetsProfit = (Double) this.redisHandler.get(ContractRedisKeys.CONTRACT_ASSETS_PROFIT_PARTY_ID + partyId.toString());
|
||||
|
||||
Map<String, Object> moneys_contract = new HashMap<String, Object>();
|
||||
moneys_contract.put("money_contract", null == contractAssets ? 0.000D : contractAssets);
|
||||
moneys_contract.put("money_contract_deposit", null == contractAssetsDeposit ? 0.000D : contractAssetsDeposit);
|
||||
moneys_contract.put("money_contract_profit", null == contractAssetsProfit ? 0.000D : contractAssetsProfit);
|
||||
|
||||
return moneys_contract;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取 所有订单 永续合约总资产、总保证金、总未实现盈利
|
||||
*/
|
||||
public Map<String, Object> getMoneyContract(Serializable partyId) {
|
||||
double money_contract = 0;
|
||||
double money_contract_deposit = 0;
|
||||
double money_contract_profit = 0;
|
||||
|
||||
List<ContractOrder> contractOrders = this.contractOrderService.findSubmitted(partyId.toString(), "", "");
|
||||
if (contractOrders != null) {
|
||||
|
||||
for (ContractOrder order : contractOrders) {
|
||||
double order_volume = 1;
|
||||
|
||||
if (order.getLever_rate() != null && order.getLever_rate() != 0) {
|
||||
order_volume = Arith.div(order.getVolume_open(), order.getLever_rate());
|
||||
} else {
|
||||
order_volume = order.getVolume_open();
|
||||
}
|
||||
|
||||
double amount = Arith.add(Arith.mul(order_volume, order.getUnit_amount()), order.getProfit());
|
||||
money_contract = Arith.add(amount, money_contract);
|
||||
money_contract_deposit = Arith.add(order.getDeposit(), money_contract_deposit);
|
||||
money_contract_profit = Arith.add(order.getProfit(), money_contract_profit);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> moneys_contract = new HashMap<String, Object>();
|
||||
moneys_contract.put("money_contract", money_contract);
|
||||
moneys_contract.put("money_contract_deposit", money_contract_deposit);
|
||||
moneys_contract.put("money_contract_profit", money_contract_profit);
|
||||
|
||||
return moneys_contract;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取 单个订单 永续合约总资产、总保证金、总未实现盈利
|
||||
*/
|
||||
public Map<String, Double> getMoneyContractByOrder(ContractOrder order) {
|
||||
Map<String, Double> moneys_contract = new HashMap<String, Double>();
|
||||
|
||||
if (null == order) {
|
||||
moneys_contract.put("money_contract", 0.000D);
|
||||
moneys_contract.put("money_contract_deposit", 0.000D);
|
||||
moneys_contract.put("money_contract_profit", 0.000D);
|
||||
return moneys_contract;
|
||||
}
|
||||
|
||||
double order_volume = 1;
|
||||
|
||||
if (order.getLever_rate() != null && order.getLever_rate() != 0) {
|
||||
order_volume = Arith.div(order.getVolume_open(), order.getLever_rate());
|
||||
} else {
|
||||
order_volume = order.getVolume_open();
|
||||
}
|
||||
|
||||
double money_contract = Arith.add(Arith.mul(order_volume, order.getUnit_amount()), order.getProfit());
|
||||
double money_contract_deposit = order.getDeposit();
|
||||
double money_contract_profit = order.getProfit();
|
||||
|
||||
moneys_contract.put("money_contract", money_contract);
|
||||
moneys_contract.put("money_contract_deposit", money_contract_deposit);
|
||||
moneys_contract.put("money_contract_profit", money_contract_profit);
|
||||
return moneys_contract;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取 所有订单 交割合约总资产、总未实现盈利 redis
|
||||
*/
|
||||
public Map<String, Object> getMoneyFuturesRedis(Serializable partyId) {
|
||||
|
||||
Double futuresAssets = (Double) this.redisHandler.get(FuturesRedisKeys.FUTURES_ASSETS_PARTY_ID + partyId.toString());
|
||||
Double futuresAssetsProfit = (Double) this.redisHandler.get(FuturesRedisKeys.FUTURES_ASSETS_PROFIT_PARTY_ID + partyId.toString());
|
||||
|
||||
Map<String, Object> moneys_futures = new HashMap<String, Object>();
|
||||
moneys_futures.put("money_futures", null == futuresAssets ? 0.000D : futuresAssets);
|
||||
moneys_futures.put("money_futures_profit", null == futuresAssetsProfit ? 0.000D : futuresAssetsProfit);
|
||||
|
||||
return moneys_futures;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取 所有订单 交割合约总资产、总未实现盈利
|
||||
*/
|
||||
public Map<String, Object> getMoneyFutures(Serializable partyId) {
|
||||
double money_futures = 0;
|
||||
double money_futures_profit = 0;
|
||||
|
||||
List<FuturesOrder> futuresOrders = this.futuresOrderService.cacheSubmitted();
|
||||
if (futuresOrders != null) {
|
||||
|
||||
for (FuturesOrder order : futuresOrders) {
|
||||
if (partyId.equals(order.getPartyId().toString())) {
|
||||
money_futures = Arith.add(order.getVolume(), money_futures);
|
||||
money_futures_profit = Arith.add(order.getProfit(), money_futures_profit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> moneys_futures = new HashMap<String, Object>();
|
||||
moneys_futures.put("money_futures", money_futures);
|
||||
moneys_futures.put("money_futures_profit", money_futures_profit);
|
||||
|
||||
return moneys_futures;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取 单个订单 交割合约总资产、总未实现盈利
|
||||
*/
|
||||
public Map<String, Double> getMoneyFuturesByOrder(FuturesOrder order) {
|
||||
Map<String, Double> moneys_futures = new HashMap<String, Double>();
|
||||
|
||||
if (null == order) {
|
||||
moneys_futures.put("money_futures", 0.000D);
|
||||
moneys_futures.put("money_futures_profit", 0.000D);
|
||||
return moneys_futures;
|
||||
}
|
||||
|
||||
double money_futures = order.getVolume();
|
||||
double money_futures_profit = order.getProfit();
|
||||
|
||||
moneys_futures.put("money_futures", money_futures);
|
||||
moneys_futures.put("money_futures_profit", money_futures_profit);
|
||||
return moneys_futures;
|
||||
}
|
||||
|
||||
public double getMoneyexchangeApplyOrders(Serializable partyId, List<Realtime> realtimeall) {
|
||||
double moneyExchange = 0;
|
||||
|
||||
List<ExchangeApplyOrder> exchangeApplyOrders = this.exchangeApplyOrderService.findSubmitted();
|
||||
|
||||
if (exchangeApplyOrders != null) {
|
||||
|
||||
for (ExchangeApplyOrder order : exchangeApplyOrders) {
|
||||
|
||||
if (partyId.equals(order.getPartyId().toString())) {
|
||||
|
||||
if ("open".equals(order.getOffset())) {
|
||||
moneyExchange = Arith.add(moneyExchange, order.getVolume());
|
||||
}
|
||||
|
||||
if ("close".equals(order.getOffset())) {
|
||||
Realtime realtime = new Realtime();
|
||||
|
||||
if (realtimeall.size() <= 0) {
|
||||
List<Realtime> realtime_list = this.dataService.realtime(order.getSymbol());
|
||||
|
||||
if (realtime_list.size() > 0) {
|
||||
realtime = realtime_list.get(0);
|
||||
} else {
|
||||
throw new BusinessException("系统错误,请稍后重试");
|
||||
}
|
||||
} else {
|
||||
for (Realtime real : realtimeall) {
|
||||
if (real.getSymbol().equals(order.getSymbol())) {
|
||||
realtime = real;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
moneyExchange = Arith.add(moneyExchange, Arith.mul(order.getVolume(), realtime.getClose()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return moneyExchange;
|
||||
}
|
||||
|
||||
public void setContractOrderService(ContractOrderService contractOrderService) {
|
||||
this.contractOrderService = contractOrderService;
|
||||
}
|
||||
|
||||
public void setContractApplyOrderService(ContractApplyOrderService contractApplyOrderService) {
|
||||
this.contractApplyOrderService = contractApplyOrderService;
|
||||
}
|
||||
|
||||
public void setWalletService(WalletService walletService) {
|
||||
this.walletService = walletService;
|
||||
}
|
||||
|
||||
public void setDataService(DataService dataService) {
|
||||
this.dataService = dataService;
|
||||
}
|
||||
|
||||
public void setFinanceOrderService(FinanceOrderService financeOrderService) {
|
||||
this.financeOrderService = financeOrderService;
|
||||
}
|
||||
|
||||
public void setMinerOrderService(MinerOrderService minerOrderService) {
|
||||
this.minerOrderService = minerOrderService;
|
||||
}
|
||||
|
||||
public void setFuturesOrderService(FuturesOrderService futuresOrderService) {
|
||||
this.futuresOrderService = futuresOrderService;
|
||||
}
|
||||
|
||||
public void setExchangeApplyOrderService(ExchangeApplyOrderService exchangeApplyOrderService) {
|
||||
this.exchangeApplyOrderService = exchangeApplyOrderService;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setItemService(ItemService itemService) {
|
||||
this.itemService = itemService;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
786
comm/Wallet/src/project/wallet/internal/WalletLogServiceImpl.java
Executable file
786
comm/Wallet/src/project/wallet/internal/WalletLogServiceImpl.java
Executable file
@@ -0,0 +1,786 @@
|
||||
package project.wallet.internal;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import kernel.cache.LocalCachePool;
|
||||
import kernel.constants.LocalCacheBucketKey;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.criterion.DetachedCriteria;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Property;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import project.Constants;
|
||||
import project.RedisKeys;
|
||||
import project.redis.RedisHandler;
|
||||
import project.user.kyc.KycHighLevel;
|
||||
import project.wallet.Wallet;
|
||||
import project.wallet.WalletLog;
|
||||
import project.wallet.WalletLogService;
|
||||
import project.wallet.dto.RechargePartyDTO;
|
||||
import project.wallet.dto.RechargePartyResultDTO;
|
||||
import util.cache.CacheOperation;
|
||||
import util.concurrent.gofun.core.FunParams;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.DoubleStream;
|
||||
|
||||
public class WalletLogServiceImpl extends HibernateDaoSupport implements WalletLogService {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(WalletLogServiceImpl.class);
|
||||
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private RedisHandler redisHandler;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
public void save(WalletLog entity) {
|
||||
entity.setCreateTime(new Date());
|
||||
getHibernateTemplate().save(entity);
|
||||
redisHandler.setSync(RedisKeys.WALLET_LOG_ORDERNO + entity.getOrder_no(), entity);
|
||||
// getHibernateTemplate().flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WalletLog find(String category, String order_no) {
|
||||
return find(order_no);
|
||||
}
|
||||
|
||||
|
||||
private Object[] today() {
|
||||
LocalDateTime start = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
|
||||
LocalDateTime end = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
|
||||
return new Object[]{
|
||||
Date.from(start.atZone(ZoneId.systemDefault()).toInstant()),
|
||||
Date.from(end.atZone(ZoneId.systemDefault()).toInstant())
|
||||
};
|
||||
}
|
||||
|
||||
public WalletLog findById(String id) {
|
||||
WalletLog entity = getHibernateTemplate().get(WalletLog.class, id);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public WalletLog find(String order_no) {
|
||||
if (StringUtils.isBlank(order_no)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
WalletLog walletLog = (WalletLog) redisHandler.get(RedisKeys.WALLET_LOG_ORDERNO + order_no);
|
||||
if (walletLog != null) {
|
||||
return walletLog;
|
||||
}
|
||||
|
||||
DetachedCriteria query = DetachedCriteria.forClass(WalletLog.class);
|
||||
query.add(Property.forName("order_no").eq(order_no.trim()));
|
||||
|
||||
List<WalletLog> list = (List<WalletLog>) getHibernateTemplate().findByCriteria(query, 0, 1);
|
||||
if (list == null || list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
walletLog = list.get(0);
|
||||
|
||||
redisHandler.setSync(RedisKeys.WALLET_LOG_ORDERNO + walletLog.getOrder_no(), walletLog);
|
||||
return walletLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(WalletLog entity) {
|
||||
this.getHibernateTemplate().update(entity);
|
||||
redisHandler.setSync(RedisKeys.WALLET_LOG_ORDERNO + entity.getOrder_no(), entity);
|
||||
|
||||
}
|
||||
|
||||
public void updateStatus(String orderNo, int status) {
|
||||
// 日志状态更新
|
||||
WalletLog walletLog = this.find(orderNo);
|
||||
if (null == walletLog) {
|
||||
log.error("walletLog is not exist,order_no:{}", orderNo);
|
||||
} else {
|
||||
walletLog.setStatus(status);
|
||||
this.update(walletLog);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String partyId, String category, String order_no_null) {
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
StringBuffer queryString = new StringBuffer("SELECT ");
|
||||
queryString.append(
|
||||
"log.WALLETTYPE AS wallettype,log.AMOUNT AS amount,log.USDT_AMOUNT as usdtAmount,log.STATUS AS status,DATE_FORMAT(log.CREATE_TIME,'%Y-%m-%d %H:%i:%S') as createTimeStr, ");
|
||||
queryString.append("withdraw.FAILURE_MSG AS withdraw_failure_msg,"
|
||||
+ " recharge.DESCRIPTION AS recharge_failure_msg,log.ORDER_NO order_no ");
|
||||
queryString.append("FROM T_WALLET_LOG AS log ");
|
||||
queryString.append("LEFT JOIN T_WITHDRAW_ORDER AS withdraw ON withdraw.ORDER_NO = log.ORDER_NO ");
|
||||
queryString.append("LEFT JOIN T_RECHARGE_BLOCKCHAIN_ORDER AS recharge ON recharge.ORDER_NO = log.ORDER_NO ");
|
||||
|
||||
queryString.append("WHERE 1=1 ");
|
||||
queryString.append(" and log.PARTY_ID = :partyId ");
|
||||
parameters.put("partyId", partyId);
|
||||
|
||||
if (StringUtils.isNotEmpty(category)) {
|
||||
queryString.append(" and log.CATEGORY = :category ");
|
||||
parameters.put("category", category);
|
||||
}
|
||||
if ("1".equals(order_no_null)) {
|
||||
queryString.append(" and log.ORDER_NO is not null and log.ORDER_NO !='' ");
|
||||
}
|
||||
queryString.append(" order by log.CREATE_TIME desc ");
|
||||
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page pagedQueryWithdraw(int pageNo, int pageSize, String partyId, String order_no_null) {
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
parameters.put("partyId", partyId);
|
||||
parameters.put("category", "withdraw");
|
||||
|
||||
StringBuffer queryString = new StringBuffer("SELECT ");
|
||||
|
||||
queryString.append(
|
||||
" log.ORDER_NO AS order_no, log.WALLETTYPE AS coin, withdraw.AMOUNT AS amount, withdraw.ARRIVAL_AMOUNT AS arrivalAmount, "
|
||||
+ " withdraw.SUCCEEDED AS state, DATE_FORMAT(log.CREATE_TIME,'%Y-%m-%d %H:%i:%S') as createTime, ");
|
||||
queryString.append(" withdraw.AMOUNT_FEE AS fee, withdraw.CHAIN_ADDRESS AS 'to', withdraw.FAILURE_MSG AS failure_msg, withdraw.TX AS tx, "
|
||||
+ " withdraw.VOLUME AS volume, withdraw.METHOD AS coin_blockchain, DATE_FORMAT(withdraw.REVIEWTIME,'%Y-%m-%d %H:%i:%S') as reviewTime, "
|
||||
+ " withdraw.bank as bank, withdraw.account as bankCardNo, withdraw.username as bankUserName, "
|
||||
+ " withdraw.ROUTING_NUM as routingNum, withdraw.ACCOUNT_ADDRESS accountAddress, withdraw.BANK_ADDRESS AS bankAddress,withdraw.COUNTRY_NAME as countryName ");
|
||||
queryString.append("FROM T_WALLET_LOG AS log ");
|
||||
queryString.append("LEFT JOIN T_WITHDRAW_ORDER AS withdraw ON withdraw.ORDER_NO = log.ORDER_NO ");
|
||||
queryString.append("WHERE 1=1 ");
|
||||
queryString.append(" and log.PARTY_ID = :partyId ");
|
||||
queryString.append(" and log.CATEGORY = :category ");
|
||||
|
||||
if ("1".equals(order_no_null)) {
|
||||
queryString.append(" and log.ORDER_NO is not null and log.ORDER_NO !='' ");
|
||||
}
|
||||
queryString.append(" order by log.CREATE_TIME desc ");
|
||||
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
StringBuffer countSql = new StringBuffer("SELECT count(*) ");
|
||||
countSql.append("FROM T_WALLET_LOG AS log ");
|
||||
countSql.append("LEFT JOIN T_WITHDRAW_ORDER AS withdraw ON withdraw.ORDER_NO = log.ORDER_NO ");
|
||||
countSql.append("WHERE log.PARTY_ID = '").append(partyId).append("' ");
|
||||
countSql.append(" and log.CATEGORY = '").append("withdraw").append("' ");
|
||||
if ("1".equals(order_no_null)) {
|
||||
countSql.append(" and log.ORDER_NO is not null and log.ORDER_NO !='' ");
|
||||
}
|
||||
int total = this.jdbcTemplate.queryForObject(countSql.toString(), Integer.class);
|
||||
page.setTotalElements(total);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page pagedQueryRecharge(int pageNo, int pageSize, String partyId, String order_no_null) {
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
StringBuffer queryString = new StringBuffer("SELECT ");
|
||||
queryString.append(
|
||||
"log.ORDER_NO AS order_no, log.WALLETTYPE AS coin, recharge.AMOUNT AS amount, recharge.SUCCEEDED AS state, DATE_FORMAT(log.CREATE_TIME,'%Y-%m-%d %H:%i:%S') as createTime, ");
|
||||
queryString.append("recharge.DESCRIPTION AS failure_msg, recharge.TX AS hash, recharge.ADDRESS AS address, recharge.CHANNEL_ADDRESS AS channel_address, recharge.CHANNEL_AMOUNT AS volume, recharge.IMG img, ");
|
||||
queryString.append("recharge.COIN AS symbol, recharge.BLOCKCHAIN_NAME AS blockchain_name, recharge.TX AS tx, DATE_FORMAT(recharge.REVIEWTIME,'%Y-%m-%d %H:%i:%S') as reviewTime ");
|
||||
|
||||
queryString.append("FROM T_WALLET_LOG AS log ");
|
||||
queryString.append("LEFT JOIN T_RECHARGE_BLOCKCHAIN_ORDER AS recharge ON recharge.ORDER_NO = log.ORDER_NO ");
|
||||
|
||||
queryString.append("WHERE case when recharge.ORDER_NO is null then '' else recharge.ORDER_NO > '' end ");
|
||||
queryString.append(" and log.PARTY_ID = :partyId ");
|
||||
parameters.put("partyId", partyId);
|
||||
|
||||
queryString.append(" and log.CATEGORY = :category ");
|
||||
parameters.put("category", "recharge");
|
||||
|
||||
if ("1".equals(order_no_null)) {
|
||||
queryString.append(" and case when log.ORDER_NO is null then '' else log.ORDER_NO > '' end ");
|
||||
}
|
||||
|
||||
queryString.append(" order by log.CREATE_TIME desc ");
|
||||
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
StringBuffer countSql = new StringBuffer("SELECT count(*) ");
|
||||
countSql.append("FROM T_WALLET_LOG AS log ");
|
||||
countSql.append("LEFT JOIN T_RECHARGE_BLOCKCHAIN_ORDER AS recharge ON recharge.ORDER_NO = log.ORDER_NO ");
|
||||
countSql.append("WHERE case when recharge.ORDER_NO is null then '' else recharge.ORDER_NO > '' end ");
|
||||
countSql.append(" and log.PARTY_ID = '").append(partyId).append("' ");
|
||||
countSql.append(" and log.CATEGORY = '").append("recharge").append("' ");
|
||||
if ("1".equals(order_no_null)) {
|
||||
countSql.append(" and case when log.ORDER_NO is null then '' else log.ORDER_NO > '' end ");
|
||||
}
|
||||
|
||||
int total = this.jdbcTemplate.queryForObject(countSql.toString(), Integer.class);
|
||||
page.setTotalElements(total);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page pagedQueryRecords(int pageNo, int pageSize, String partyId, String category) {
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
StringBuffer queryString = new StringBuffer("SELECT ");
|
||||
|
||||
queryString.append(
|
||||
"log.CATEGORY AS category, log.WALLETTYPE AS wallet_type, log.AMOUNT AS amount, log.USDT_AMOUNT AS usdtAmount, log.STATUS AS status, log.ORDER_NO order_no, DATE_FORMAT(log.CREATE_TIME,'%Y-%m-%d %H:%i:%S') as createTimeStr, ");
|
||||
queryString.append("withdraw.FAILURE_MSG AS withdraw_failure_msg, recharge.DESCRIPTION AS recharge_failure_msg ");
|
||||
|
||||
queryString.append("FROM T_WALLET_LOG AS log ");
|
||||
queryString.append("LEFT JOIN T_WITHDRAW_ORDER AS withdraw ON withdraw.ORDER_NO = log.ORDER_NO ");
|
||||
queryString.append("LEFT JOIN T_RECHARGE_BLOCKCHAIN_ORDER AS recharge ON recharge.ORDER_NO = log.ORDER_NO ");
|
||||
|
||||
queryString.append("WHERE 1=1 ");
|
||||
|
||||
queryString.append(" and log.ORDER_NO is not null and log.ORDER_NO != '' ");
|
||||
|
||||
queryString.append(" and log.PARTY_ID = :partyId ");
|
||||
parameters.put("partyId", partyId);
|
||||
|
||||
if (StringUtils.isNotEmpty(category)) {
|
||||
queryString.append(" and log.CATEGORY = :category ");
|
||||
parameters.put("category", category);
|
||||
}
|
||||
|
||||
queryString.append(" and log.STATUS = :status ");
|
||||
parameters.put("status", 1);
|
||||
|
||||
queryString.append(" order by log.CREATE_TIME desc ");
|
||||
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
return page;
|
||||
}
|
||||
|
||||
public double getComputeRechargeAmount(String partyId) {
|
||||
String sql = "select IFNULL(sum(AMOUNT), 0) as amount from T_MONEY_LOG where PARTY_ID = ? and CONTENT_TYPE=? ";
|
||||
return jdbcTemplate.queryForObject(sql, Double.class, partyId, Constants.MONEYLOG_CATEGORY_RECHARGE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量统计指定用户累计充值金额
|
||||
*
|
||||
* @param partyIdList
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Double> getComputeRechargeAmount(List<String> partyIdList, double limitAmount) {
|
||||
Map<String, Double> rechargeAmountMap = new HashMap();
|
||||
if (CollectionUtil.isEmpty(partyIdList)) {
|
||||
return rechargeAmountMap;
|
||||
}
|
||||
|
||||
StringBuffer partyIdsBuf = new StringBuffer();
|
||||
for (String onePartyId : partyIdList) {
|
||||
partyIdsBuf.append("'").append(onePartyId.trim()).append("',");
|
||||
}
|
||||
partyIdsBuf.deleteCharAt(partyIdsBuf.length() - 1);
|
||||
|
||||
// String sql = "select PARTY_ID as partyId, IFNULL(sum(AMOUNT), 0) as amount " +
|
||||
// " FROM T_MONEY_LOG " +
|
||||
// " WHERE PARTY_ID in (" + partyIdsBuf.toString() + ") AND CATEGORY=? " +
|
||||
// " GROUP BY PARTY_ID ";
|
||||
// if (limitAmount > 0) {
|
||||
// sql = sql + " having amount >= " + limitAmount + " ";
|
||||
// }
|
||||
|
||||
String sql = "SELECT " +
|
||||
" PARTY_ID AS partyId, " +
|
||||
" IFNULL( STORE_MONEY_RECHARGE_ACC, 0 ) AS amount " +
|
||||
" FROM " +
|
||||
" T_MALL_USER_METRICS " +
|
||||
" WHERE " +
|
||||
" PARTY_ID IN ("+ partyIdsBuf.toString() +")";
|
||||
if(limitAmount>0){
|
||||
sql =sql + " AND STORE_MONEY_RECHARGE_ACC >= "+limitAmount;
|
||||
}
|
||||
|
||||
List list = this.jdbcTemplate.queryForList(sql/*, Constants.MONEYLOG_CATEGORY_RECHARGE*/);
|
||||
|
||||
Iterator iterable = list.iterator();
|
||||
while (iterable.hasNext()) {
|
||||
Map rowMap = (Map) iterable.next();
|
||||
String partyId = (String) rowMap.getOrDefault("partyId", "");
|
||||
Double totalAmount = (Double) rowMap.getOrDefault("amount", "0.0");
|
||||
|
||||
rechargeAmountMap.put(partyId, totalAmount);
|
||||
}
|
||||
|
||||
return rechargeAmountMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间统计充值人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
public Integer getCountRechargeByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
Cache<String, Integer> cacheResult = LocalCachePool.buildCache(LocalCacheBucketKey.CountRechargeByDay, 20, 300, null);
|
||||
|
||||
String key = this.getKey(startTime, endTime, LocalCacheBucketKey.CountRechargeByDay);
|
||||
|
||||
Integer cacheresults = cacheResult.getIfPresent(key);
|
||||
|
||||
if (Objects.nonNull(cacheresults)) {
|
||||
return cacheresults;
|
||||
}
|
||||
|
||||
countSql.append("select IFNULL(SUM(t1.count),0) from (select count(1) as count from T_RECHARGE_BLOCKCHAIN_ORDER where SUCCEEDED = 1 ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND CREATED >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND CREATED <= ? ");
|
||||
}
|
||||
|
||||
countSql.append("GROUP BY PARTY_ID) t1 ");
|
||||
|
||||
Integer result = jdbcTemplate.queryForObject(countSql.toString(), params.toArray(), Integer.class);
|
||||
|
||||
if (Objects.nonNull(result)) {
|
||||
cacheResult.put(key, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getCacheCountRechargeByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.CountRechargeByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam().set("walletLogService", this);
|
||||
|
||||
Integer result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
WalletLogService partyService = params.get("walletLogService").getAs(WalletLogService.class);
|
||||
Integer getResult = partyService.getCountRechargeByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getTotalProfitByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder("select CAST(SUM(IFNULL(AMOUNT,0)) AS DECIMAL (19, 2)) as profit from T_MONEY_LOG where CONTENT_TYPE = 'order-income' ");
|
||||
countSql.append(" and PARTY_ID IN (SELECT UUID FROM PAT_PARTY where ROLENAME <> 'GUEST') ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND CREATE_TIME >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND CREATE_TIME <= ? ");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> results = jdbcTemplate.queryForList(countSql.toString(), params.toArray());
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(results)) {
|
||||
|
||||
for (Map<String, Object> data : results) {
|
||||
resultMap.put("profit", Objects.isNull(data.get("profit")) ? 0 : data.get("profit"));
|
||||
}
|
||||
|
||||
BigDecimal result = new BigDecimal(String.valueOf(resultMap.get("profit"))).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
resultMap.put("profit", result);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getCacheTotalProfitByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.TotalProfitByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam().set("walletLogService", this);
|
||||
|
||||
Map<String, Object> result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
WalletLogService partyService = params.get("walletLogService").getAs(WalletLogService.class);
|
||||
Map<String, Object> getResult = partyService.getTotalProfitByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> getSumWithdrawByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder("select CAST(SUM(IFNULL(AMOUNT,0)) AS DECIMAL (19, 3)) as withdraw from T_WITHDRAW_ORDER where ");
|
||||
countSql.append(" PARTY_ID IN (SELECT UUID FROM PAT_PARTY where ROLENAME <> 'GUEST') and SUCCEEDED = 1 ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND CREATE_TIME >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND CREATE_TIME <= ? ");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> results = jdbcTemplate.queryForList(countSql.toString(), params.toArray());
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(results)) {
|
||||
|
||||
for (Map<String, Object> data : results) {
|
||||
resultMap.put("withdraw", Objects.isNull(data.get("withdraw")) ? 0 : data.get("withdraw"));
|
||||
}
|
||||
|
||||
BigDecimal result = new BigDecimal(String.valueOf(resultMap.get("withdraw"))).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
|
||||
resultMap.put("withdraw", result);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getCacheSumWithdrawByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.SumWithdrawByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam().set("walletLogService", this);
|
||||
|
||||
Map<String, Object> result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
WalletLogService partyService = params.get("walletLogService").getAs(WalletLogService.class);
|
||||
Map<String, Object> getResult = partyService.getSumWithdrawByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSumRechargeByDay(String startTime, String endTime, List<String> sellerIds) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder("select CAST(SUM(IFNULL(AMOUNT,0)) AS DECIMAL (19, 3)) as recharge from T_RECHARGE_BLOCKCHAIN_ORDER where ");
|
||||
countSql.append(" PARTY_ID IN (SELECT UUID FROM PAT_PARTY where ROLENAME <> 'GUEST') and SUCCEEDED = 1 ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND CREATED >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND CREATED <= ? ");
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(sellerIds)) {
|
||||
params.add(sellerIds);
|
||||
countSql.append("AND PARTY_ID in ? ");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> results = jdbcTemplate.queryForList(countSql.toString(), params.toArray());
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(results)) {
|
||||
|
||||
for (Map<String, Object> data : results) {
|
||||
resultMap.put("recharge", Objects.isNull(data.get("recharge")) ? 0 : data.get("recharge"));
|
||||
}
|
||||
|
||||
BigDecimal result = new BigDecimal(String.valueOf(resultMap.get("recharge"))).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
|
||||
resultMap.put("recharge", result);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getCacheSumRechargeByDay(String startTime, String endTime, List<String> sellerIds) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.SumRechargeByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam().set("walletLogService", this);
|
||||
|
||||
Map<String, Object> result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
WalletLogService partyService = params.get("walletLogService").getAs(WalletLogService.class);
|
||||
Map<String, Object> getResult = partyService.getSumRechargeByDay(startTime, endTime, null);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计提现人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
public Integer getCountWithdrawByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
|
||||
countSql.append("select IFNULL(SUM(t1.count),0) from (select count(1) as count from T_WITHDRAW_ORDER where SUCCEEDED = 1 ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND CREATE_TIME >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND CREATE_TIME <= ? ");
|
||||
}
|
||||
|
||||
countSql.append("GROUP BY PARTY_ID) t1 ");
|
||||
|
||||
Integer result = jdbcTemplate.queryForObject(countSql.toString(), params.toArray(), Integer.class);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCacheCountWithdrawByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.CountWithdrawByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam()
|
||||
.set("walletLogService", this);
|
||||
|
||||
// 基于一个缓存上次执行结果的组件进行数据统计方法的调用,如果上次缓存结果满足条件,则优先使用缓存结果,否则,触发真实的统计执行
|
||||
// 执行结果缓存 1 个小时
|
||||
Integer result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
WalletLogService partyService = params.get("walletLogService").getAs(WalletLogService.class);
|
||||
Integer getResult = partyService.getCountWithdrawByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计新充值人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计新提现人数
|
||||
*/
|
||||
public RechargePartyResultDTO getNewRechargeByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
countSql.append("select PARTY_ID as sellerId, AMOUNT from T_RECHARGE_BLOCKCHAIN_ORDER where SUCCEEDED = 1 and PARTY_ID ");
|
||||
|
||||
countSql.append("in (select UUID from PAT_PARTY where 1= 1 and ROLENAME <> 'GUEST' ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND CREATE_TIME >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND CREATE_TIME <= ? ");
|
||||
}
|
||||
|
||||
countSql.append(")");
|
||||
|
||||
List<RechargePartyDTO> results = jdbcTemplate.query(countSql.toString(), new BeanPropertyRowMapper<>(RechargePartyDTO.class), params.toArray());
|
||||
|
||||
RechargePartyResultDTO rechargePartyResultDTO = new RechargePartyResultDTO();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(results)) {
|
||||
Map<String, List<RechargePartyDTO>> collect = results.stream().collect(Collectors.groupingBy(RechargePartyDTO::getSellerId));
|
||||
rechargePartyResultDTO.setNumber(collect.keySet().size());
|
||||
Double amounts = results.stream().flatMapToDouble(value -> DoubleStream.of(value.getAmount())).sum();
|
||||
rechargePartyResultDTO.setAmount(String.valueOf(amounts));
|
||||
}
|
||||
|
||||
return rechargePartyResultDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RechargePartyResultDTO getCacheNewRechargeByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.NewRechargeByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam()
|
||||
.set("walletLogService", this);
|
||||
|
||||
// 基于一个缓存上次执行结果的组件进行数据统计方法的调用,如果上次缓存结果满足条件,则优先使用缓存结果,否则,触发真实的统计执行
|
||||
// 执行结果缓存 1 个小时
|
||||
RechargePartyResultDTO result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
WalletLogService partyService = params.get("walletLogService").getAs(WalletLogService.class);
|
||||
RechargePartyResultDTO getResult = partyService.getNewRechargeByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计新提现人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计新提现人数
|
||||
*/
|
||||
public RechargePartyResultDTO getNewWithdrawByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
countSql.append("select PARTY_ID sellerId , AMOUNT from T_WITHDRAW_ORDER where SUCCEEDED = 1 and PARTY_ID ");
|
||||
|
||||
countSql.append("in (select UUID from PAT_PARTY where 1= 1 and ROLENAME <> 'GUEST' ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND CREATE_TIME >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND CREATE_TIME <= ? ");
|
||||
}
|
||||
|
||||
countSql.append(")");
|
||||
|
||||
List<RechargePartyDTO> results = jdbcTemplate.query(countSql.toString(), new BeanPropertyRowMapper<>(RechargePartyDTO.class), params.toArray());
|
||||
|
||||
RechargePartyResultDTO rechargePartyResultDTO = new RechargePartyResultDTO();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(results)) {
|
||||
Map<String, List<RechargePartyDTO>> collect = results.stream().collect(Collectors.groupingBy(RechargePartyDTO::getSellerId));
|
||||
rechargePartyResultDTO.setNumber(collect.keySet().size());
|
||||
Double amounts = results.stream().flatMapToDouble(value -> DoubleStream.of(value.getAmount())).sum();
|
||||
rechargePartyResultDTO.setAmount(String.valueOf(amounts));
|
||||
}
|
||||
|
||||
return rechargePartyResultDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RechargePartyResultDTO getCacheNewWithdrawByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.NewWithdrawByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam()
|
||||
.set("walletLogService", this);
|
||||
|
||||
// 基于一个缓存上次执行结果的组件进行数据统计方法的调用,如果上次缓存结果满足条件,则优先使用缓存结果,否则,触发真实的统计执行
|
||||
// 执行结果缓存 1 个小时
|
||||
RechargePartyResultDTO result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
WalletLogService partyService = params.get("walletLogService").getAs(WalletLogService.class);
|
||||
RechargePartyResultDTO getResult = partyService.getNewWithdrawByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<WalletLog> getAll() {
|
||||
return (List<WalletLog>) this.getHibernateTemplate().find(" FROM WalletLog ");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量统计指定用户累计充值金额
|
||||
*
|
||||
* @param partyId
|
||||
* @param limitTime
|
||||
* @return
|
||||
*/
|
||||
public WalletLog getFirstRechargeLogInTimeRange(String partyId, Date limitTime) {
|
||||
DetachedCriteria criteria = DetachedCriteria.forClass(WalletLog.class);
|
||||
criteria.add(Property.forName("partyId").eq(partyId));
|
||||
criteria.add(Property.forName("status").eq(1));
|
||||
criteria.add(Property.forName("createTime").ge(limitTime));
|
||||
criteria.add(Property.forName("category").eq(Constants.MONEYLOG_CATEGORY_RECHARGE));
|
||||
|
||||
criteria.addOrder(Order.asc("createTime"));
|
||||
|
||||
try {
|
||||
List<WalletLog> wallets = (List<WalletLog>) getHibernateTemplate().findByCriteria(criteria);
|
||||
if (CollectionUtils.isEmpty(wallets)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return wallets.get(0);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
|
||||
private String getKey(String fromTime, String toTime, String key) {
|
||||
String from = fromTime.replace("-", "")
|
||||
.replace(":", "")
|
||||
.replace("000000", "")
|
||||
.replace(" ", "");
|
||||
|
||||
String to = toTime.replace("-", "")
|
||||
.replace(":", "")
|
||||
.replace("000000", "")
|
||||
.replace(" ", "");
|
||||
|
||||
String funKey = key + ":" + from + "-" + to;
|
||||
|
||||
return funKey;
|
||||
}
|
||||
}
|
||||
640
comm/Wallet/src/project/wallet/internal/WalletServiceImpl.java
Executable file
640
comm/Wallet/src/project/wallet/internal/WalletServiceImpl.java
Executable file
@@ -0,0 +1,640 @@
|
||||
package project.wallet.internal;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.util.ThreadUtils;
|
||||
import kernel.util.UUIDGenerator;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.hibernate.criterion.DetachedCriteria;
|
||||
import org.hibernate.criterion.Property;
|
||||
import org.hibernate.transform.Transformers;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import project.Constants;
|
||||
import project.data.DataService;
|
||||
import project.data.model.Realtime;
|
||||
import project.log.MoneyLog;
|
||||
import project.log.MoneyLogService;
|
||||
import project.party.PartyService;
|
||||
import project.party.model.Party;
|
||||
import project.redis.RedisHandler;
|
||||
import project.syspara.SysparaService;
|
||||
import project.user.UserDataService;
|
||||
import project.wallet.Wallet;
|
||||
import project.wallet.WalletExtend;
|
||||
import project.wallet.WalletRedisKeys;
|
||||
import project.wallet.WalletService;
|
||||
import project.wallet.consumer.WalletExtendMessage;
|
||||
import project.wallet.consumer.WalletMessage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
public class WalletServiceImpl extends HibernateDaoSupport implements WalletService {
|
||||
private Logger log = LoggerFactory.getLogger(WalletServiceImpl.class);
|
||||
private PartyService partyService;
|
||||
private MoneyLogService moneyLogService;
|
||||
private RedisHandler redisHandler;
|
||||
private DataService dataService;
|
||||
private SysparaService sysparaService;
|
||||
private UserDataService userDataService;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
public Wallet selectOne(String partyId) {
|
||||
// String sql = "SELECT * FROM T_WALLET WHERE PARTY_ID = :partyId";
|
||||
// MapSqlParameterSource parameter = new MapSqlParameterSource();
|
||||
// parameter.addValue("partyId", partyId);
|
||||
// NamedParameterJdbcTemplate parameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
|
||||
// List<Wallet> wallets = parameterJdbcTemplate.query(sql, parameter, new RowMapper<Wallet>() {
|
||||
// @Override
|
||||
// public Wallet mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
// Wallet wallet = new Wallet();
|
||||
// wallet.setId(rs.getString("UUID"));
|
||||
// wallet.setPartyId(rs.getString("PARTY_ID"));
|
||||
// wallet.setRebate(rs.getDouble("REBATE"));
|
||||
// wallet.setMoney(rs.getDouble("MONEY"));
|
||||
// wallet.setEntityVersion(0);
|
||||
// return wallet;
|
||||
// }
|
||||
// });
|
||||
DetachedCriteria criteria = DetachedCriteria.forClass(Wallet.class);
|
||||
criteria.add(Property.forName("partyId").eq(partyId));
|
||||
try {
|
||||
List<Wallet> wallets = (List<Wallet>) getHibernateTemplate().findByCriteria(criteria);
|
||||
if (CollectionUtils.isEmpty(wallets)) {
|
||||
return null;
|
||||
}
|
||||
if (wallets.size() > 1) {
|
||||
log.error("用户出现非法钱包");
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(wallets)) {
|
||||
this.redisHandler.setSync(WalletRedisKeys.WALLET_PARTY_ID + partyId, wallets.get(0));
|
||||
return wallets.get(0);
|
||||
}
|
||||
return null;
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wallet saveWalletByPartyId(Serializable partyId) {
|
||||
Wallet wallet = null;
|
||||
try {//这里大量测试时会偶现异常,这里改为捕获异常,让程序继续执行,并重新获取一次钱包
|
||||
wallet = selectOne(partyId.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("钱包获取失败,并重试", e);
|
||||
}
|
||||
if (wallet != null) {
|
||||
return wallet;
|
||||
} else {
|
||||
wallet = new Wallet();
|
||||
wallet.setPartyId(partyId);
|
||||
save(wallet);
|
||||
return wallet;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Wallet entity) {
|
||||
Wallet existWallet = findWalletByPartyId(entity);
|
||||
if (existWallet == null) {
|
||||
entity.setTimestamp(new Date());
|
||||
try {
|
||||
getHibernateTemplate().save(entity);
|
||||
// getHibernateTemplate().flush();
|
||||
} catch (Exception e) {
|
||||
// 防止并发创建
|
||||
// 并发场景下会出现主键冲突,如果不执行 clear 方法,以下的 get 获取的将不是数据库里的数据,而是前面 save 到 hibernate 缓存里的数据
|
||||
// getHibernateTemplate().clear();
|
||||
existWallet = findWalletByPartyId(entity);
|
||||
if (existWallet == null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BeanUtils.copyProperties(existWallet, entity);
|
||||
// entity = existWallet;
|
||||
}
|
||||
|
||||
redisHandler.setSync(WalletRedisKeys.WALLET_PARTY_ID + entity.getPartyId().toString(), entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Wallet entity) {
|
||||
Wallet existWallet = findWalletByPartyId(entity);
|
||||
if (existWallet == null) {
|
||||
entity.setTimestamp(new Date());
|
||||
try {
|
||||
getHibernateTemplate().save(entity);
|
||||
// getHibernateTemplate().flush();
|
||||
} catch (Exception e) {
|
||||
// 防止并发创建
|
||||
// 并发场景下会出现主键冲突,如果不执行 clear 方法,以下的 get 获取的将不是数据库里的数据,而是前面 save 到 hibernate 缓存里的数据
|
||||
// getHibernateTemplate().clear();
|
||||
existWallet = findWalletByPartyId(entity);
|
||||
if (existWallet == null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
getHibernateTemplate().merge(entity);
|
||||
}
|
||||
|
||||
redisHandler.setSync(WalletRedisKeys.WALLET_PARTY_ID + entity.getPartyId().toString(), entity);
|
||||
}
|
||||
|
||||
private Wallet findWalletByPartyId(Wallet entity) {
|
||||
DetachedCriteria criteria = DetachedCriteria.forClass(Wallet.class);
|
||||
criteria.add(Property.forName("partyId").eq(entity.getPartyId().toString()));
|
||||
try {
|
||||
List<Wallet> wallets = (List<Wallet>) getHibernateTemplate().findByCriteria(criteria);
|
||||
if (CollectionUtils.isEmpty(wallets)) {
|
||||
return null;
|
||||
}
|
||||
if (wallets.size() > 1) {
|
||||
log.error("用户出现非法钱包");
|
||||
}
|
||||
return wallets.get(0);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String partyId, double amount) {
|
||||
Wallet wallet = saveWalletByPartyId(partyId);
|
||||
if (wallet.getFrozenState()==0) {
|
||||
wallet.setMoney(Arith.roundDown(Arith.add(wallet.getMoney(), amount),2));
|
||||
}else {
|
||||
wallet.setMoneyAfterFrozen(Arith.roundDown(Arith.add(wallet.getMoneyAfterFrozen(), amount),2));
|
||||
}
|
||||
|
||||
// 此处不要执行持久化处理,因为 WalletConsumeServer 方法会以异步方式从 redis 中读取 WALLET_QUEUE_UPDATE 资金变更队列中的
|
||||
// 数据来单线程模式执行每笔变更记录,刷新钱包余额。
|
||||
//getHibernateTemplate().save(wallet);
|
||||
//getHibernateTemplate().flush();
|
||||
log.info("----> WalletServiceImpl.update 更新用户:{} 的钱包余额为:{}", partyId, wallet.getMoney());
|
||||
getHibernateTemplate().merge(wallet);
|
||||
redisHandler.setSync(WalletRedisKeys.WALLET_PARTY_ID + wallet.getPartyId().toString(), wallet);
|
||||
// redisHandler.pushAsyn(WalletRedisKeys.WALLET_QUEUE_UPDATE, new WalletMessage(partyId, amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMoeny(String partyId, double amount) {
|
||||
Wallet wallet = saveWalletByPartyId(partyId);
|
||||
wallet.setMoney(Arith.roundDown(Arith.add(wallet.getMoney(), amount),2));
|
||||
|
||||
// 此处不要执行持久化处理,因为 WalletConsumeServer 方法会以异步方式从 redis 中读取 WALLET_QUEUE_UPDATE 资金变更队列中的
|
||||
// 数据来单线程模式执行每笔变更记录,刷新钱包余额。
|
||||
//getHibernateTemplate().save(wallet);
|
||||
//getHibernateTemplate().flush();
|
||||
log.info("----> WalletServiceImpl.update 更新用户:{} 的钱包余额为:{}", partyId, wallet.getMoney());
|
||||
getHibernateTemplate().merge(wallet);
|
||||
redisHandler.setSync(WalletRedisKeys.WALLET_PARTY_ID + wallet.getPartyId().toString(), wallet);
|
||||
// redisHandler.pushAsyn(WalletRedisKeys.WALLET_QUEUE_UPDATE, new WalletMessage(partyId, amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String partyId, double amount, double rebate) {
|
||||
Wallet wallet = saveWalletByPartyId(partyId);
|
||||
wallet.setMoney(Arith.roundDown(Arith.add(wallet.getMoney(), amount),2));
|
||||
wallet.setRebate(Arith.add(wallet.getRebate(), rebate));
|
||||
getHibernateTemplate().merge(wallet);
|
||||
redisHandler.setSync(WalletRedisKeys.WALLET_PARTY_ID + wallet.getPartyId().toString(), wallet);
|
||||
// WalletMessage updateMsg = new WalletMessage(partyId, amount);
|
||||
// updateMsg.setRebate(rebate);
|
||||
// redisHandler.pushAsyn(WalletRedisKeys.WALLET_QUEUE_UPDATE, updateMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String partyId, double amount, double rebate, double rechargeCommission) {
|
||||
Wallet wallet = saveWalletByPartyId(partyId);
|
||||
|
||||
if(wallet.getFrozenState() == 1){
|
||||
wallet.setMoneyAfterFrozen(Arith.roundDown(Arith.add(wallet.getMoneyAfterFrozen(), amount),2));
|
||||
} else if (wallet.getFrozenState() == 0){
|
||||
wallet.setMoney(Arith.roundDown(Arith.add(wallet.getMoney(), amount),2));
|
||||
}
|
||||
|
||||
wallet.setRebate(Arith.add(wallet.getRebate(), rebate));
|
||||
wallet.setRechargeCommission(Arith.add(wallet.getRechargeCommission(), rechargeCommission));
|
||||
getHibernateTemplate().merge(wallet);
|
||||
redisHandler.setSync(WalletRedisKeys.WALLET_PARTY_ID + wallet.getPartyId().toString(), wallet);
|
||||
// WalletMessage updateMsg = new WalletMessage(partyId, amount);
|
||||
// updateMsg.setRebate(rebate);
|
||||
// updateMsg.setRechargeCommission(rechargeCommission);
|
||||
// redisHandler.pushAsyn(WalletRedisKeys.WALLET_QUEUE_UPDATE, updateMsg);
|
||||
}
|
||||
|
||||
|
||||
public double selectTotalIncome(String partyId) {
|
||||
String sql = "SELECT SUM(REBATE) FROM T_MALL_REBATE WHERE PARTY_ID = '" + partyId + "'";
|
||||
Double value = this.jdbcTemplate.queryForObject(sql, Double.class);
|
||||
return null == value ? 0.0D : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WalletExtend saveExtendByPara(Serializable partyId, String wallettype) {
|
||||
if (StringUtils.isEmptyString(wallettype) || partyId == null || StringUtils.isEmptyString(partyId.toString())) {
|
||||
log.error("saveExtendByPara fail,partyId:{},wallettype:{}", new Object[]{partyId, wallettype});
|
||||
throw new RuntimeException("更新钱包失败,请联系客服");
|
||||
}
|
||||
WalletExtend walletExtend = (WalletExtend) redisHandler
|
||||
.get(WalletRedisKeys.WALLET_EXTEND_PARTY_ID + partyId.toString() + wallettype);
|
||||
if (walletExtend != null) {
|
||||
return walletExtend;
|
||||
}
|
||||
walletExtend = new WalletExtend();
|
||||
walletExtend.setPartyId(partyId);
|
||||
walletExtend.setWallettype(wallettype);
|
||||
save(walletExtend);
|
||||
|
||||
ThreadUtils.sleep(10);
|
||||
|
||||
return walletExtend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(WalletExtend entity) {
|
||||
entity.setId(UUIDGenerator.getUUID());
|
||||
final String sql = "INSERT INTO T_WALLET_EXTEND(UUID,PARTY_ID,WALLETTYPE,AMOUNT) VALUES('" + entity.getId().toString() + "','" + entity.getPartyId().toString() + "','" + entity.getWallettype() + "','0')";
|
||||
FutureTask<Object> future = new FutureTask<Object>(new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
int update = jdbcTemplate.update(sql);
|
||||
return update;
|
||||
}
|
||||
});
|
||||
Thread thread = new Thread(future);
|
||||
thread.start();
|
||||
try {
|
||||
future.get();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
throw new BusinessException("create WalletExtend fail,partyId:{" + entity.getPartyId().toString() + "},symbol:{" + entity.getWallettype() + "}");
|
||||
}
|
||||
|
||||
|
||||
// getHibernateTemplate().save(entity);
|
||||
|
||||
redisHandler.setSync(
|
||||
WalletRedisKeys.WALLET_EXTEND_PARTY_ID + entity.getPartyId().toString() + entity.getWallettype(),
|
||||
entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExtend(String partyId, String walletType, double amount) {
|
||||
WalletExtend walletExtend = (WalletExtend) redisHandler
|
||||
.get(WalletRedisKeys.WALLET_EXTEND_PARTY_ID + partyId.toString() + walletType);
|
||||
|
||||
if (walletExtend == null) {
|
||||
walletExtend = this.saveExtendByPara(partyId, walletType);
|
||||
}
|
||||
|
||||
// TODO 待验证
|
||||
getHibernateTemplate().evict(walletExtend);
|
||||
|
||||
walletExtend.setAmount(Arith.add(walletExtend.getAmount(), amount));
|
||||
|
||||
redisHandler.setSync(WalletRedisKeys.WALLET_EXTEND_PARTY_ID + partyId.toString() + walletType, walletExtend);
|
||||
|
||||
redisHandler.pushAsyn(WalletRedisKeys.WALLET_EXTEND_QUEUE_UPDATE,
|
||||
new WalletExtendMessage(partyId, walletType, amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WalletExtend> findExtend(Serializable partyId) {
|
||||
// List<String> list = (List<String>) this.getHibernateTemplate().find("SELECT wallettype FROM WalletExtend WHERE partyId=?0");
|
||||
List<String> list = (List<String>) this.getHibernateTemplate()
|
||||
.find("SELECT wallettype FROM WalletExtend WHERE partyId=?0", partyId);
|
||||
List<String> keys = new LinkedList<String>();
|
||||
for (String key : list) {
|
||||
keys.add(WalletRedisKeys.WALLET_EXTEND_PARTY_ID + partyId.toString() + key);
|
||||
}
|
||||
Object[] objects = redisHandler.getList(keys.toArray(new String[0]));
|
||||
if (objects != null && objects.length > 0) {
|
||||
List<WalletExtend> result = new ArrayList<WalletExtend>();
|
||||
for (Object obj : objects) {
|
||||
result.add((WalletExtend) obj);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return new ArrayList<WalletExtend>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WalletExtend> findExtend(Serializable partyId, List<String> list_symbol) {
|
||||
|
||||
List<String> keys = new LinkedList<String>();
|
||||
for (String key : list_symbol) {
|
||||
keys.add(WalletRedisKeys.WALLET_EXTEND_PARTY_ID + partyId.toString() + key);
|
||||
}
|
||||
Object[] objects = redisHandler.getList(keys.toArray(new String[0]));
|
||||
if (objects != null && objects.length > 0) {
|
||||
List<WalletExtend> result = new ArrayList<WalletExtend>();
|
||||
for (Object obj : objects) {
|
||||
if (obj != null)
|
||||
result.add((WalletExtend) obj);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return new ArrayList<WalletExtend>();
|
||||
}
|
||||
|
||||
// public Wallet findWalletByPartyId(Serializable partyId) {
|
||||
//// return this.saveWalletByPartyId(partyId);
|
||||
// return (Wallet) redisHandler.get(WalletRedisKeys.WALLET_PARTY_ID + partyId.toString());
|
||||
// }
|
||||
|
||||
// public WalletExtend findExtendByPara(Serializable partyId, String wallettype) {// 用户转账
|
||||
// return this.saveExtendByPara(partyId, wallettype);
|
||||
// }
|
||||
|
||||
public void updateTransfer_wallet(String byPartyId, String safeword, String toPartyId, String coin, double amount,
|
||||
double fee_amount) {
|
||||
|
||||
if ("false".equals(this.sysparaService.find("transfer_wallet_open").getValue())) {
|
||||
throw new BusinessException(1, "无权限");
|
||||
}
|
||||
|
||||
/**
|
||||
* 实际到账
|
||||
*/
|
||||
|
||||
double get_amount = Arith.sub(amount, fee_amount);
|
||||
/**
|
||||
* 币种改小写
|
||||
*/
|
||||
coin = coin.toLowerCase();
|
||||
|
||||
/**
|
||||
* 转账方
|
||||
*/
|
||||
Party byParty = this.partyService.cachePartyBy(byPartyId, false);
|
||||
String giftMoneyLog = "";
|
||||
if (byParty.getGift_money_flag()) {
|
||||
giftMoneyLog = "赠送金额";
|
||||
}
|
||||
/**
|
||||
* 正式用户才有转账权限
|
||||
*/
|
||||
if (!Constants.SECURITY_ROLE_MEMBER.equals(byParty.getRolename())) {
|
||||
throw new BusinessException(1, "无权限");
|
||||
}
|
||||
if (!byParty.getEnabled()) {
|
||||
throw new BusinessException(506, "无权限");
|
||||
}
|
||||
|
||||
/**
|
||||
* 收款方
|
||||
*/
|
||||
Party toParty = this.partyService.cachePartyBy(toPartyId, false);
|
||||
if (toParty == null || toParty.getId().toString().equals(byParty.getId().toString())) {
|
||||
throw new BusinessException(1, "收款方输入错误");
|
||||
}
|
||||
/*
|
||||
* 转出金额,usdt计价
|
||||
*/
|
||||
double outAmountToUsdt = amount;
|
||||
/*
|
||||
* 转入金额,usdt计价
|
||||
*/
|
||||
double inAmountToUsdt = get_amount;
|
||||
if ("usdt".equals(coin) || "USDT".equals(coin)) {
|
||||
/**
|
||||
* 转账方
|
||||
*/
|
||||
Wallet walletBy = saveWalletByPartyId(byPartyId);
|
||||
|
||||
if (walletBy.getMoney() < amount) {
|
||||
throw new BusinessException(1, "余额不足");
|
||||
}
|
||||
|
||||
double walletBy_before_amount = walletBy.getMoney();
|
||||
// walletBy.setMoney(Arith.sub(walletBy.getMoney(), amount));
|
||||
|
||||
/*
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneyLog = new MoneyLog();
|
||||
moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
|
||||
moneyLog.setAmount_before(walletBy_before_amount);
|
||||
moneyLog.setAmount(Arith.sub(0, amount));
|
||||
moneyLog.setAmount_after(Arith.sub(walletBy.getMoney(), amount));
|
||||
|
||||
moneyLog.setLog("用户手动转账" + giftMoneyLog + "给" + toParty.getUsername());
|
||||
moneyLog.setPartyId(byPartyId);
|
||||
moneyLog.setWallettype(Constants.WALLET);
|
||||
moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_WITHDRAW);
|
||||
moneyLogService.save(moneyLog);
|
||||
|
||||
update(walletBy.getPartyId().toString(), Arith.sub(0, amount));
|
||||
|
||||
/**
|
||||
* 收款方 获得金额
|
||||
*/
|
||||
|
||||
Wallet walletTo = saveWalletByPartyId(toPartyId);
|
||||
|
||||
double walletTo_before_amount = walletTo.getMoney();
|
||||
// walletTo.setMoney(Arith.add(walletTo.getMoney(), get_amount));
|
||||
|
||||
/*
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneyLogto = new MoneyLog();
|
||||
moneyLogto.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
|
||||
moneyLogto.setAmount_before(walletTo_before_amount);
|
||||
moneyLogto.setAmount(get_amount);
|
||||
moneyLogto.setAmount_after(Arith.add(walletTo.getMoney(), get_amount));
|
||||
|
||||
moneyLogto.setLog("收到" + byParty.getUsername() + giftMoneyLog + "的转账");
|
||||
moneyLogto.setPartyId(toPartyId);
|
||||
moneyLogto.setWallettype(Constants.WALLET);
|
||||
moneyLogto.setContent_type(Constants.MONEYLOG_CONTENT_RECHARGE);
|
||||
moneyLogService.save(moneyLogto);
|
||||
|
||||
// update(walletTo);
|
||||
update(walletTo.getPartyId().toString(), get_amount);
|
||||
|
||||
/**
|
||||
* 充值到账后给他增加提现流水限制金额
|
||||
*/
|
||||
toParty.setWithdraw_limit_amount(Arith.add(toParty.getWithdraw_limit_amount(), get_amount));
|
||||
partyService.update(toParty);
|
||||
} else {
|
||||
|
||||
/**
|
||||
* 转账方
|
||||
*/
|
||||
WalletExtend walletBy = saveExtendByPara(byPartyId, coin);
|
||||
|
||||
if (walletBy.getAmount() < amount) {
|
||||
throw new BusinessException(1, "余额不足");
|
||||
}
|
||||
|
||||
double walletBy_before_amount = walletBy.getAmount();
|
||||
// walletBy.setAmount(Arith.sub(walletBy.getAmount(), amount));
|
||||
|
||||
/*
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneyLog = new MoneyLog();
|
||||
moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
|
||||
moneyLog.setAmount_before(walletBy_before_amount);
|
||||
moneyLog.setAmount(Arith.sub(0, amount));
|
||||
moneyLog.setAmount_after(Arith.sub(walletBy.getAmount(), amount));
|
||||
|
||||
moneyLog.setLog("用户手动转账" + giftMoneyLog + "给" + toParty.getUsername());
|
||||
// moneyLog.setExtra(withdraw.getOrder_no());
|
||||
moneyLog.setPartyId(byPartyId);
|
||||
moneyLog.setWallettype(coin);
|
||||
moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_WITHDRAW);
|
||||
moneyLogService.save(moneyLog);
|
||||
|
||||
// update(walletBy);
|
||||
updateExtend(walletBy.getPartyId().toString(), coin, Arith.sub(0, amount));
|
||||
/**
|
||||
* 收款方 获得金额
|
||||
*/
|
||||
|
||||
WalletExtend walletTo = saveExtendByPara(toPartyId, coin);
|
||||
|
||||
double walletTo_before_amount = walletTo.getAmount();
|
||||
// walletTo.setAmount(Arith.add(walletTo.getAmount(), get_amount));
|
||||
|
||||
/*
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneyLogto = new MoneyLog();
|
||||
moneyLogto.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
|
||||
moneyLogto.setAmount_before(walletTo_before_amount);
|
||||
moneyLogto.setAmount(get_amount);
|
||||
moneyLogto.setAmount_after(Arith.add(walletTo.getAmount(), get_amount));
|
||||
|
||||
moneyLogto.setLog("收到" + byParty.getUsername() + giftMoneyLog + "的转账");
|
||||
// moneyLog.setExtra(withdraw.getOrder_no());
|
||||
moneyLogto.setPartyId(toPartyId);
|
||||
moneyLogto.setWallettype(coin);
|
||||
moneyLogto.setContent_type(Constants.MONEYLOG_CONTENT_RECHARGE);
|
||||
moneyLogService.save(moneyLogto);
|
||||
|
||||
List<Realtime> realtime_list = this.dataService.realtime(coin);
|
||||
Realtime realtime = null;
|
||||
if (realtime_list.size() > 0) {
|
||||
realtime = realtime_list.get(0);
|
||||
} else {
|
||||
throw new BusinessException("系统错误,请稍后重试");
|
||||
}
|
||||
outAmountToUsdt = Arith.mul(amount, realtime.getClose());
|
||||
inAmountToUsdt = Arith.mul(get_amount, realtime.getClose());
|
||||
/**
|
||||
* 充值到账后给他增加提现流水限制金额
|
||||
*/
|
||||
toParty.setWithdraw_limit_amount(
|
||||
Arith.add(toParty.getWithdraw_limit_amount(), Arith.mul(get_amount, realtime.getClose())));
|
||||
partyService.update(toParty);
|
||||
|
||||
updateExtend(walletTo.getPartyId().toString(), coin, get_amount);
|
||||
|
||||
}
|
||||
userDataService.saveTransferMoneyHandle(byPartyId, toPartyId, outAmountToUsdt, inAmountToUsdt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WalletExtend> findAllWalletExtend() {
|
||||
return (List<WalletExtend>) this.getHibernateTemplate().find(" FROM WalletExtend ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Wallet> findAllWallet() {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Wallet> list = getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(
|
||||
"SELECT w.MONEY money FROM T_WALLET w LEFT JOIN PAT_PARTY p ON w.PARTY_ID = p.UUID WHERE p.ROLENAME = 'MEMBER'")
|
||||
.addScalar("money")
|
||||
.setResultTransformer(Transformers.aliasToBean(Wallet.class)).list();
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WalletExtend getInvestPoint(String partyId) {
|
||||
return this.getHibernateTemplate().get(WalletExtend.class, partyId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateInvestPoint(String partyId, int addPoint) {
|
||||
WalletExtend walletExtend = getInvestPoint(partyId);
|
||||
if (walletExtend == null) {
|
||||
walletExtend = new WalletExtend();
|
||||
walletExtend.setId(partyId);
|
||||
walletExtend.setPartyId(partyId);
|
||||
walletExtend.setAmount(addPoint);
|
||||
walletExtend.setWallettype("POINT");
|
||||
this.getHibernateTemplate().save(walletExtend);
|
||||
return;
|
||||
}
|
||||
Double amount = walletExtend.getAmount();
|
||||
walletExtend.setAmount(amount.intValue() + addPoint);
|
||||
this.getHibernateTemplate().update(walletExtend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getInvestPointBuyPartyId(String partyId) {
|
||||
WalletExtend walletExtend = getInvestPoint(partyId);
|
||||
if (walletExtend == null) {
|
||||
return 0D;
|
||||
}
|
||||
return walletExtend.getAmount();
|
||||
}
|
||||
|
||||
public void setPartyService(PartyService partyService) {
|
||||
this.partyService = partyService;
|
||||
}
|
||||
|
||||
public void setMoneyLogService(MoneyLogService moneyLogService) {
|
||||
this.moneyLogService = moneyLogService;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setDataService(DataService dataService) {
|
||||
this.dataService = dataService;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setUserDataService(UserDataService userDataService) {
|
||||
this.userDataService = userDataService;
|
||||
}
|
||||
|
||||
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
46
comm/Wallet/src/project/wallet/rate/ExchangeRate.hbm.xml
Executable file
46
comm/Wallet/src/project/wallet/rate/ExchangeRate.hbm.xml
Executable file
@@ -0,0 +1,46 @@
|
||||
<?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.wallet.rate.ExchangeRate" table="T_EXCHANGE_RATE">
|
||||
<id name="id" type="java.lang.String" >
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="out_or_in" type="java.lang.String" update="false">
|
||||
<column name="OUT_OR_IN" />
|
||||
</property>
|
||||
<property name="rata" type="java.lang.Double">
|
||||
<column name="RATA" />
|
||||
</property>
|
||||
<property name="currency" type="java.lang.String" update="false">
|
||||
<column name="CURRENCY" />
|
||||
</property>
|
||||
<property name="name" type="java.lang.String" update="false">
|
||||
<column name="NAME" />
|
||||
</property>
|
||||
<property name="currency_symbol" type="java.lang.String" update="false">
|
||||
<column name="CURRENCY_SYMBOL" />
|
||||
</property>
|
||||
|
||||
<property name="status" type="java.lang.Integer">
|
||||
<column name="STATUS" />
|
||||
</property>
|
||||
|
||||
<property name="sort" type="int">
|
||||
<column name="SORT" />
|
||||
</property>
|
||||
|
||||
<property name="excMin" type="java.lang.Double">
|
||||
<column name="EXC_MIN" />
|
||||
</property>
|
||||
|
||||
<property name="excMax" type="java.lang.Double">
|
||||
<column name="EXC_MAX" />
|
||||
</property>
|
||||
|
||||
<property name="iconImg" type="java.lang.String">
|
||||
<column name="ICON_IMG" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
64
comm/Wallet/src/project/wallet/rate/ExchangeRate.java
Executable file
64
comm/Wallet/src/project/wallet/rate/ExchangeRate.java
Executable file
@@ -0,0 +1,64 @@
|
||||
package project.wallet.rate;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* 货币汇率。Wallet汇WalletExtend或WalletExtend汇Wallet的汇率值
|
||||
*/
|
||||
@Data
|
||||
public class ExchangeRate extends EntityObject {
|
||||
|
||||
public static final String IN = "in";
|
||||
public static final String OUT = "out";
|
||||
|
||||
private static final long serialVersionUID = 5591037881881001013L;
|
||||
/**
|
||||
* out兑出 in 兑入
|
||||
*/
|
||||
private String out_or_in;
|
||||
/**
|
||||
* 汇率
|
||||
*/
|
||||
private double rata;
|
||||
|
||||
/**
|
||||
* 货币,见Constants定义
|
||||
*/
|
||||
private String currency;
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 货币符号
|
||||
*/
|
||||
private String currency_symbol;
|
||||
|
||||
/**
|
||||
* 状态:0-启用 1-禁用
|
||||
*/
|
||||
private int status;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private int sort;
|
||||
|
||||
/**
|
||||
* 最小兑换
|
||||
*/
|
||||
private double excMin;
|
||||
|
||||
/**
|
||||
* 最大兑换
|
||||
*/
|
||||
private double excMax;
|
||||
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
private String iconImg;
|
||||
|
||||
|
||||
}
|
||||
38
comm/Wallet/src/project/wallet/rate/ExchangeRateService.java
Executable file
38
comm/Wallet/src/project/wallet/rate/ExchangeRateService.java
Executable file
@@ -0,0 +1,38 @@
|
||||
package project.wallet.rate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.invest.goods.model.Useraddress;
|
||||
import project.invest.project.model.ExchangeOrder;
|
||||
import project.user.kyc.Kyc;
|
||||
|
||||
public interface ExchangeRateService {
|
||||
|
||||
|
||||
public ExchangeRate findById(String id);
|
||||
|
||||
List<ExchangeRate> listExchangeRates(int pageNum, int pageSize);
|
||||
|
||||
|
||||
List<ExchangeOrder> listExchangeRecords(String partyId,int pageNum, int pageSize);
|
||||
|
||||
String updateExchange(String partyId, ExchangeRate exchangeRate, double usdt, Kyc kyc,String bankName, String bankAccount);
|
||||
|
||||
void savePaymentMethod(String partyId,int use, int payType,String bankName,String bankAccount, Kyc kyc);
|
||||
|
||||
void updatePaymentMethod(String id,String partyId,int use,String bankName,String bankAccount);
|
||||
|
||||
void removePaymentMethod(String id);
|
||||
|
||||
List<PaymentMethod> listPaymentMethod(String partyId);
|
||||
|
||||
PaymentMethod getDefaultPaymentMethod(String partyId);
|
||||
|
||||
public ExchangeRate get(String id);
|
||||
|
||||
public void update(ExchangeRate entity);
|
||||
|
||||
Page pagedQuery(int pageNo, int pageSize, String name, String startTime, String endTime, Integer status);
|
||||
}
|
||||
41
comm/Wallet/src/project/wallet/rate/PaymentMethod.hbm.xml
Executable file
41
comm/Wallet/src/project/wallet/rate/PaymentMethod.hbm.xml
Executable file
@@ -0,0 +1,41 @@
|
||||
<?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.wallet.rate.PaymentMethod" table="T_PAYMENT_METHOD">
|
||||
|
||||
<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="payType" type="java.lang.Integer">
|
||||
<column name="PAY_TYPE" />
|
||||
</property>
|
||||
|
||||
<property name="realName" type="java.lang.String">
|
||||
<column name="REAL_NAME" />
|
||||
</property>
|
||||
|
||||
<property name="bankName" type="java.lang.String">
|
||||
<column name="BANK_NAME" />
|
||||
</property>
|
||||
|
||||
<property name="bankAccount" type="java.lang.String">
|
||||
<column name="BANK_ACCOUNT" />
|
||||
</property>
|
||||
|
||||
<property name="status" type="java.lang.Integer">
|
||||
<column name="STATUS" />
|
||||
</property>
|
||||
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
45
comm/Wallet/src/project/wallet/rate/PaymentMethod.java
Executable file
45
comm/Wallet/src/project/wallet/rate/PaymentMethod.java
Executable file
@@ -0,0 +1,45 @@
|
||||
package project.wallet.rate;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@Data
|
||||
public class PaymentMethod extends EntityObject {
|
||||
|
||||
private static final long serialVersionUID = -6658527079884278L;
|
||||
|
||||
/**
|
||||
* 会员ID
|
||||
*/
|
||||
private String partyId;
|
||||
|
||||
/**
|
||||
* 0=银行卡
|
||||
*/
|
||||
private int payType;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 开户行名称
|
||||
*/
|
||||
private String bankName;
|
||||
|
||||
/**
|
||||
* 卡号
|
||||
*/
|
||||
private String bankAccount;
|
||||
|
||||
/**
|
||||
* 1=默认
|
||||
*/
|
||||
private int status;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
||||
18
comm/Wallet/src/project/wallet/rate/UserRateConfig.hbm.xml
Executable file
18
comm/Wallet/src/project/wallet/rate/UserRateConfig.hbm.xml
Executable file
@@ -0,0 +1,18 @@
|
||||
<?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.wallet.rate.UserRateConfig" table="T_USER_RATE_CONFIG">
|
||||
<id name="id" type="java.lang.String" >
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String"
|
||||
update="false">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="currency" type="java.lang.String">
|
||||
<column name="CURRENCY" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
39
comm/Wallet/src/project/wallet/rate/UserRateConfig.java
Executable file
39
comm/Wallet/src/project/wallet/rate/UserRateConfig.java
Executable file
@@ -0,0 +1,39 @@
|
||||
package project.wallet.rate;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
* 用户汇率配置
|
||||
*
|
||||
* @author User
|
||||
*
|
||||
*/
|
||||
public class UserRateConfig extends EntityObject {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Serializable partyId;
|
||||
|
||||
/**
|
||||
* 货币,见Constants定义
|
||||
*/
|
||||
private String currency;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
}
|
||||
18
comm/Wallet/src/project/wallet/rate/UserRateConfigService.java
Executable file
18
comm/Wallet/src/project/wallet/rate/UserRateConfigService.java
Executable file
@@ -0,0 +1,18 @@
|
||||
package project.wallet.rate;
|
||||
|
||||
/**
|
||||
*
|
||||
*用户汇率配置
|
||||
*/
|
||||
public interface UserRateConfigService {
|
||||
|
||||
public void update(String rateId, String partyId);
|
||||
|
||||
public UserRateConfig getByPartyId(String partyId);
|
||||
|
||||
/**
|
||||
* 查询用户计价方式,如果没有配置,则返回默认的计价方式
|
||||
*/
|
||||
public ExchangeRate findUserConfig(String partyId);
|
||||
|
||||
}
|
||||
265
comm/Wallet/src/project/wallet/rate/internal/ExchangeRateServiceImpl.java
Executable file
265
comm/Wallet/src/project/wallet/rate/internal/ExchangeRateServiceImpl.java
Executable file
@@ -0,0 +1,265 @@
|
||||
package project.wallet.rate.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.DateUtils;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.*;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.Constants;
|
||||
import project.RedisKeys;
|
||||
import project.invest.goods.model.Useraddress;
|
||||
import project.invest.project.model.ExchangeOrder;
|
||||
import project.invest.project.model.Project;
|
||||
import project.log.MoneyLog;
|
||||
import project.log.MoneyLogService;
|
||||
import project.party.PartyService;
|
||||
import project.redis.RedisHandler;
|
||||
import project.user.kyc.Kyc;
|
||||
import project.user.kyc.KycService;
|
||||
import project.wallet.Wallet;
|
||||
import project.wallet.WalletService;
|
||||
import project.wallet.rate.ExchangeRate;
|
||||
import project.wallet.rate.ExchangeRateService;
|
||||
import project.wallet.rate.PaymentMethod;
|
||||
|
||||
public class ExchangeRateServiceImpl extends HibernateDaoSupport implements ExchangeRateService {
|
||||
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
private WalletService walletService;
|
||||
|
||||
private MoneyLogService moneyLogService;
|
||||
|
||||
private PartyService partyService;
|
||||
|
||||
private KycService kycService;
|
||||
|
||||
@Override
|
||||
public ExchangeRate findById(String id) {
|
||||
return this.getHibernateTemplate().get(ExchangeRate.class, id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ExchangeRate> listExchangeRates(int pageNum, int pageSize) {
|
||||
DetachedCriteria query = DetachedCriteria.forClass(ExchangeRate.class);
|
||||
query.add( Property.forName("status").eq(0) );
|
||||
query.addOrder(Order.asc("sort"));
|
||||
return (List<ExchangeRate>) getHibernateTemplate().findByCriteria(query,(pageNum-1)*pageSize,pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExchangeOrder> listExchangeRecords(String partyId, int pageNum, int pageSize) {
|
||||
DetachedCriteria query = DetachedCriteria.forClass(ExchangeOrder.class);
|
||||
query.add( Property.forName("partyId").eq(partyId) );
|
||||
query.addOrder(Order.desc("createTime"));
|
||||
return (List<ExchangeOrder>) getHibernateTemplate().findByCriteria(query,(pageNum-1)*pageSize,pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updateExchange(String partyId, ExchangeRate exchangeRate, double amount, Kyc kyc ,String bankName, String bankAccount) {
|
||||
Wallet wallet = walletService.saveWalletByPartyId(partyId);
|
||||
double amount_before = wallet.getMoney();
|
||||
if(amount>amount_before){
|
||||
throw new BusinessException("余额不足");
|
||||
}
|
||||
|
||||
wallet.setMoney(Arith.roundDown(Arith.sub(wallet.getMoney(), amount),2));
|
||||
|
||||
walletService.update(wallet);
|
||||
|
||||
|
||||
ExchangeOrder orders = new ExchangeOrder();
|
||||
orders.setPartyId(partyId);
|
||||
orders.setSymbol("USDT");
|
||||
orders.setSymbolValue(amount);
|
||||
orders.setOrderPriceType(exchangeRate.getCurrency());
|
||||
orders.setOrderPriceAmount(Arith.mul(amount,exchangeRate.getRata()));
|
||||
orders.setStaus(0);
|
||||
orders.setCreateTime(new Date());
|
||||
orders.setRealAmount(Arith.mul(amount,exchangeRate.getRata()));
|
||||
orders.setPayType(0);
|
||||
orders.setRata(exchangeRate.getRata());
|
||||
orders.setBankName(bankName);
|
||||
orders.setBankAccount(bankAccount);
|
||||
orders.setCurrency_symbol(exchangeRate.getCurrency_symbol());
|
||||
orders.setRata(exchangeRate.getRata());
|
||||
this.getHibernateTemplate().save(orders);
|
||||
|
||||
MoneyLog moneyLog = new MoneyLog();
|
||||
moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
|
||||
moneyLog.setAmount_before(amount_before);
|
||||
moneyLog.setAmount(Arith.sub(0, amount));
|
||||
moneyLog.setAmount_after(wallet.getMoney());
|
||||
|
||||
moneyLog.setLog("otc兑换[" + orders.getId() + "]");
|
||||
moneyLog.setPartyId(partyId);
|
||||
moneyLog.setWallettype(Constants.WALLET);
|
||||
moneyLog.setContent_type(Constants.MONEYLOG_CONTNET_OTC_IN);
|
||||
|
||||
moneyLogService.save(moneyLog);
|
||||
|
||||
return orders.getId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name, String startTime, String endTime, Integer status) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append(" SELECT * FROM T_EXCHANGE_RATE where 1 = 1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap();
|
||||
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
queryString.append(" AND NAME=:name ");
|
||||
parameters.put("name", name);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(startTime)) {
|
||||
queryString.append(" AND DATE(CREATE_TIME) >= DATE(:startTime) ");
|
||||
parameters.put("startTime", DateUtils.toDate(startTime));
|
||||
}
|
||||
if (-2 != status) {
|
||||
queryString.append(" and STATUS =:status");
|
||||
parameters.put("status", status);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(endTime)) {
|
||||
queryString.append(" AND DATE(CREATE_TIME) <= DATE(:endTime) ");
|
||||
parameters.put("endTime", DateUtils.toDate(endTime));
|
||||
}
|
||||
queryString.append(" ORDER BY UUID desc");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ExchangeRate entity) {
|
||||
this.getHibernateTemplate().update(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ExchangeRate get(String id) {
|
||||
return (ExchangeRate) redisHandler.get(RedisKeys.EXCHANGE_RATE_ID + id);
|
||||
// return this.getHibernateTemplate().get(ExchangeRate.class, id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void savePaymentMethod(String partyId, int use, int payType, String bankName, String bankAccount, Kyc kyc) {
|
||||
|
||||
List<PaymentMethod> list = listPaymentMethod(partyId);
|
||||
if(list.size()>5){
|
||||
throw new BusinessException("卡号达上限");
|
||||
}
|
||||
|
||||
if(use==1){
|
||||
for(PaymentMethod b: listPaymentMethod(partyId)){
|
||||
if(b.getStatus()==1){
|
||||
b.setStatus(0);
|
||||
getHibernateTemplate().update(b);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
PaymentMethod addRess = new PaymentMethod();
|
||||
addRess.setPartyId(partyId);
|
||||
addRess.setPayType(payType);
|
||||
addRess.setStatus(use);
|
||||
addRess.setBankName(bankName);
|
||||
addRess.setBankAccount(bankAccount);
|
||||
addRess.setStatus(use);
|
||||
addRess.setCreateTime(new Date());
|
||||
addRess.setRealName(kyc.getName());
|
||||
getHibernateTemplate().save(addRess);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePaymentMethod(String id, String partyId, int use, String bankName, String bankAccount) {
|
||||
PaymentMethod addRess = this.getHibernateTemplate().get(PaymentMethod.class, id);
|
||||
if(addRess==null||!partyId.equals(addRess.getPartyId())){
|
||||
return;
|
||||
}
|
||||
addRess.setStatus(use);
|
||||
addRess.setBankName(bankName);
|
||||
addRess.setBankAccount(bankAccount);
|
||||
this.getHibernateTemplate().update(addRess);
|
||||
if(use==1){
|
||||
for(PaymentMethod b: listPaymentMethod(partyId)){
|
||||
if(id.equals(b.getId())){
|
||||
continue;
|
||||
}
|
||||
b.setStatus(0);
|
||||
getHibernateTemplate().update(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePaymentMethod(String id) {
|
||||
PaymentMethod address = this.getHibernateTemplate().get(PaymentMethod.class, id);
|
||||
if(address==null){
|
||||
return;
|
||||
}
|
||||
getHibernateTemplate().delete(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentMethod> listPaymentMethod(String partyId) {
|
||||
DetachedCriteria query = DetachedCriteria.forClass(PaymentMethod.class);
|
||||
query.add( Property.forName("partyId").eq(partyId) );
|
||||
query.addOrder(Order.desc("createTime"));
|
||||
return (List<PaymentMethod>) getHibernateTemplate().findByCriteria(query,0,10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentMethod getDefaultPaymentMethod(String partyId) {
|
||||
DetachedCriteria query = DetachedCriteria.forClass(PaymentMethod.class);
|
||||
query.add( Property.forName("partyId").eq(partyId) );
|
||||
query.add( Property.forName("status").eq(1) );
|
||||
List l = getHibernateTemplate().findByCriteria(query,0,1);
|
||||
if(l.size()>0){
|
||||
return (PaymentMethod) l.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setWalletService(WalletService walletService) {
|
||||
this.walletService = walletService;
|
||||
}
|
||||
|
||||
public void setMoneyLogService(MoneyLogService moneyLogService) {
|
||||
this.moneyLogService = moneyLogService;
|
||||
}
|
||||
|
||||
public void setPartyService(PartyService partyService) {
|
||||
this.partyService = partyService;
|
||||
}
|
||||
|
||||
public void setKycService(KycService kycService) {
|
||||
this.kycService = kycService;
|
||||
}
|
||||
}
|
||||
75
comm/Wallet/src/project/wallet/rate/internal/UserRateConfigServiceImpl.java
Executable file
75
comm/Wallet/src/project/wallet/rate/internal/UserRateConfigServiceImpl.java
Executable file
@@ -0,0 +1,75 @@
|
||||
package project.wallet.rate.internal;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import project.RedisKeys;
|
||||
import project.redis.RedisHandler;
|
||||
import project.wallet.PropertiesUtilWallet;
|
||||
import project.wallet.rate.ExchangeRate;
|
||||
import project.wallet.rate.ExchangeRateService;
|
||||
import project.wallet.rate.UserRateConfig;
|
||||
import project.wallet.rate.UserRateConfigService;
|
||||
|
||||
public class UserRateConfigServiceImpl extends HibernateDaoSupport implements UserRateConfigService {
|
||||
|
||||
private ExchangeRateService exchangeRateService;
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public void update(String rateId, String partyId) {
|
||||
ExchangeRate exchangeRate = exchangeRateService.get(rateId);
|
||||
if (null == exchangeRate) {
|
||||
logger.error(String.format("rate is null,rateId:{%s}", rateId));
|
||||
throw new BusinessException("rate is null");
|
||||
}
|
||||
UserRateConfig userConfig = this.getByPartyId(partyId);
|
||||
if (userConfig == null) {
|
||||
userConfig = new UserRateConfig();
|
||||
userConfig.setPartyId(partyId);
|
||||
}
|
||||
userConfig.setCurrency(exchangeRate.getCurrency());
|
||||
|
||||
this.getHibernateTemplate().saveOrUpdate(userConfig);
|
||||
redisHandler.setSync(RedisKeys.USER_RATE_CONFIG_PARTY_ID + partyId, userConfig);
|
||||
}
|
||||
|
||||
public UserRateConfig getByPartyId(String partyId) {
|
||||
return (UserRateConfig) redisHandler.get(RedisKeys.USER_RATE_CONFIG_PARTY_ID + partyId);
|
||||
// List<UserRateConfig> userConfigList = this.getHibernateTemplate().find("FROM UserRateConfig WHERE partyId=?",
|
||||
// partyId);
|
||||
// if (!CollectionUtils.isEmpty(userConfigList))
|
||||
// return userConfigList.get(0);
|
||||
// return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExchangeRate findUserConfig(String partyId) {
|
||||
ExchangeRate exchangeRate = null;
|
||||
|
||||
String user_default_currency = "USD";
|
||||
// if (StringUtils.isNullOrEmpty(partyId)) {
|
||||
// exchangeRate = exchangeRateService.findBy(ExchangeRate.IN, user_default_currency);
|
||||
//
|
||||
// } else {
|
||||
// UserRateConfig userRateConfig = this.getByPartyId(partyId);
|
||||
// if (userRateConfig == null) {
|
||||
// exchangeRate = exchangeRateService.findBy(ExchangeRate.IN, user_default_currency);
|
||||
// } else {
|
||||
// exchangeRate = exchangeRateService.findBy(ExchangeRate.IN, userRateConfig.getCurrency());
|
||||
// }
|
||||
// }
|
||||
|
||||
return exchangeRate;
|
||||
}
|
||||
|
||||
public void setExchangeRateService(ExchangeRateService exchangeRateService) {
|
||||
this.exchangeRateService = exchangeRateService;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
107
comm/Wallet/src/project/web/admin/AdminExchangeRateController.java
Executable file
107
comm/Wallet/src/project/web/admin/AdminExchangeRateController.java
Executable file
@@ -0,0 +1,107 @@
|
||||
package project.web.admin;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.wallet.rate.ExchangeRate;
|
||||
import project.wallet.rate.ExchangeRateService;
|
||||
|
||||
/**
|
||||
* 货币汇率配置
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
public class AdminExchangeRateController extends PageActionSupport {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AdminExchangeRateController.class);
|
||||
|
||||
@Autowired
|
||||
private ExchangeRateService exchangeRateService;
|
||||
|
||||
private final String action = "normal/adminExchangeRateAction!";
|
||||
|
||||
/**
|
||||
* 货币汇率配置-列表
|
||||
*/
|
||||
@RequestMapping(action + "list.action")
|
||||
public ModelAndView list(HttpServletRequest request) {
|
||||
String message = request.getParameter("message");
|
||||
String error = request.getParameter("error");
|
||||
this.checkAndSetPageNo(request.getParameter("pageNo"));
|
||||
String name = request.getParameter("name");
|
||||
String startTime = request.getParameter("startTime");
|
||||
String endTime = request.getParameter("endTime");
|
||||
Integer status = request.getParameter("status") == null ? -2 : Integer.parseInt(request.getParameter("status"));
|
||||
this.pageSize = 10;
|
||||
this.page = this.exchangeRateService.pagedQuery(this.pageNo, this.pageSize, name,startTime, endTime, status);
|
||||
ModelAndView model = new ModelAndView();
|
||||
model.addObject("pageNo", this.pageNo);
|
||||
model.addObject("pageSize", this.pageSize);
|
||||
model.addObject("page", this.page);
|
||||
model.addObject("message", message);
|
||||
model.addObject("error", error);
|
||||
model.setViewName("exchangerate_list");
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 货币汇率配置-更新
|
||||
*/
|
||||
@RequestMapping(action + "toUpdate.action")
|
||||
public ModelAndView toUpdate(HttpServletRequest request) {
|
||||
String message = request.getParameter("message");
|
||||
String error = request.getParameter("error");
|
||||
String id = request.getParameter("id");
|
||||
ExchangeRate exchangeRate = this.exchangeRateService.findById(id);
|
||||
|
||||
ModelAndView model = new ModelAndView();
|
||||
model.addObject("message", message);
|
||||
model.addObject("error", error);
|
||||
model.addObject("exchangeRate", exchangeRate);
|
||||
model.setViewName("exchangerate_update");
|
||||
return model;
|
||||
}
|
||||
|
||||
@RequestMapping(action + "update.action")
|
||||
public ModelAndView update(HttpServletRequest request, ExchangeRate exchangeRate) {
|
||||
if (exchangeRate.getRata() <= 0) {
|
||||
throw new BusinessException("汇率错误");
|
||||
}
|
||||
|
||||
ModelAndView model = new ModelAndView();
|
||||
try {
|
||||
String id = request.getParameter("id");
|
||||
ExchangeRate bean = exchangeRateService.findById(id);
|
||||
bean.setRata(exchangeRate.getRata());
|
||||
bean.setSort(exchangeRate.getSort());
|
||||
bean.setExcMax(exchangeRate.getExcMax());
|
||||
bean.setExcMin(exchangeRate.getExcMin());
|
||||
bean.setStatus(exchangeRate.getStatus());
|
||||
bean.setIconImg(exchangeRate.getIconImg());
|
||||
exchangeRateService.update(bean);
|
||||
} catch (BusinessException e) {
|
||||
model.addObject("error", e.getMessage());
|
||||
model.addObject("exchangeRate", exchangeRate);
|
||||
model.setViewName("exchangerate_update");
|
||||
return model;
|
||||
} catch (Throwable t) {
|
||||
logger.error("update error ", t);
|
||||
model.addObject("error", "程序错误");
|
||||
model.addObject("exchangeRate", exchangeRate);
|
||||
model.setViewName("exchangerate_update");
|
||||
}
|
||||
model.addObject("message", "操作成功");
|
||||
model.setViewName("redirect:/" + action + "list.action");
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
251
comm/Wallet/src/project/web/api/ExchangeRateController.java
Executable file
251
comm/Wallet/src/project/web/api/ExchangeRateController.java
Executable file
@@ -0,0 +1,251 @@
|
||||
package project.web.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.PageInfo;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.BaseAction;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import kernel.web.ResultObject;
|
||||
import project.Constants;
|
||||
import project.invest.InvestRedisKeys;
|
||||
import project.invest.project.model.ExchangeOrder;
|
||||
import project.invest.project.model.InvestRebate;
|
||||
import project.invest.project.model.Project;
|
||||
import project.invest.project.model.ProjectLang;
|
||||
import project.tip.TipConstants;
|
||||
import project.tip.TipService;
|
||||
import project.user.kyc.Kyc;
|
||||
import project.user.kyc.KycService;
|
||||
import project.wallet.Wallet;
|
||||
import project.wallet.WalletService;
|
||||
import project.wallet.rate.ExchangeRate;
|
||||
import project.wallet.rate.ExchangeRateService;
|
||||
import project.wallet.rate.PaymentMethod;
|
||||
import util.DateUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class ExchangeRateController extends BaseAction {
|
||||
|
||||
private static Log logger = LogFactory.getLog(ExchangeRateController.class);
|
||||
|
||||
@Resource
|
||||
private ExchangeRateService exchangeRateService;
|
||||
|
||||
@Resource
|
||||
private WalletService walletService;
|
||||
|
||||
@Resource
|
||||
protected KycService kycService;
|
||||
|
||||
@Resource
|
||||
private TipService tipService;
|
||||
|
||||
private final String action = "api/exchangerate!";
|
||||
|
||||
@PostMapping(action+"list.action")
|
||||
public Object list(HttpServletRequest request) throws IOException {
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
PageInfo pageInfo = getPageInfo(request);
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for(ExchangeRate er : exchangeRateService.listExchangeRates(pageInfo.getPageNum(),pageInfo.getPageSize())){
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("id", er.getId().toString());
|
||||
o.put("currency", er.getCurrency());
|
||||
o.put("currency_symbol", er.getCurrency_symbol());
|
||||
o.put("iconImg", er.getIconImg());
|
||||
o.put("rata", er.getRata());
|
||||
o.put("excMin", er.getExcMin());
|
||||
o.put("excMax", er.getExcMax());
|
||||
jsonArray.add(o);
|
||||
}
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("pageInfo", pageInfo);
|
||||
object.put("pageList", jsonArray);
|
||||
resultObject.setData(object);
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 汇率
|
||||
*/
|
||||
@PostMapping(action+"get.action")
|
||||
public Object get(HttpServletRequest request) throws IOException {
|
||||
ResultObject resultObject = new ResultObject();
|
||||
|
||||
String partyId = this.getLoginPartyId();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
try {
|
||||
String id = request.getParameter("id");
|
||||
ExchangeRate exchangeRate = exchangeRateService.findById(id);
|
||||
Wallet wallet = walletService.saveWalletByPartyId(partyId);
|
||||
double balance = wallet.getMoney();
|
||||
data.put("currency", exchangeRate.getCurrency());
|
||||
data.put("currency_symbol", exchangeRate.getCurrency_symbol());
|
||||
data.put("rata", exchangeRate.getRata());
|
||||
data.put("excMin", exchangeRate.getExcMin());
|
||||
data.put("excMax", exchangeRate.getExcMax());
|
||||
data.put("balance", balance);
|
||||
|
||||
data.put("payType", "-1");
|
||||
data.put("bankName", "");
|
||||
data.put("bankAccount", "");
|
||||
|
||||
PaymentMethod pm = exchangeRateService.getDefaultPaymentMethod(partyId);
|
||||
if(pm!=null){
|
||||
data.put("payType", pm.getPayType());
|
||||
data.put("bankName", pm.getBankName());
|
||||
data.put("bankAccount", pm.getBankAccount());
|
||||
}
|
||||
resultObject.setData(data);
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", e);
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 汇率
|
||||
*/
|
||||
@PostMapping(action+"exchange.action")
|
||||
public Object exchange(HttpServletRequest request) throws IOException {
|
||||
ResultObject resultObject = new ResultObject();
|
||||
|
||||
String partyId = this.getLoginPartyId();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
try {
|
||||
String id = request.getParameter("id");
|
||||
|
||||
double usdt = Double.parseDouble(request.getParameter("usdt"));
|
||||
usdt = Arith.roundDown(usdt,2);
|
||||
|
||||
if(usdt<=0||usdt>99999999){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("输入金额高于最大出售");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
String bankName = request.getParameter("bankName");
|
||||
|
||||
if(StringUtils.isEmptyString(bankName)){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("开户行不能为空");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
String bankAccount = request.getParameter("bankAccount");
|
||||
|
||||
if(StringUtils.isEmptyString(bankAccount)){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("卡号不能为空");
|
||||
return resultObject;
|
||||
}
|
||||
ExchangeRate exchangeRate = exchangeRateService.findById(id);
|
||||
|
||||
|
||||
double cny = Arith.mul(usdt,exchangeRate.getRata());
|
||||
|
||||
if(cny>exchangeRate.getExcMax()){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("输入金额高于最大出售");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
if(cny<exchangeRate.getExcMin()){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("输入金额低于最小出售");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
Kyc kyc = this.kycService.get(partyId);
|
||||
if (null == kyc ) {
|
||||
resultObject.setCode("800");
|
||||
resultObject.setMsg("尚未KYC认证");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
if ( kyc.getStatus() != 2) {
|
||||
resultObject.setCode("801");
|
||||
resultObject.setMsg("KYC认证尚未通过");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
String idTip = exchangeRateService.updateExchange(partyId,exchangeRate,usdt,kyc,bankName,bankAccount);
|
||||
resultObject.setData(data);
|
||||
|
||||
tipService.saveTip(idTip, TipConstants.EXCHANGE_ORDER);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", e);
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 兑换记录
|
||||
* @return
|
||||
*/
|
||||
@PostMapping( action+"records.action")
|
||||
public Object projectIncomeList(HttpServletRequest request){
|
||||
ResultObject resultObject = readSecurityContextFromSession(new ResultObject());
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
PageInfo pageInfo = getPageInfo(request);
|
||||
String partyId = this.getLoginPartyId();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for(ExchangeOrder pl : exchangeRateService.listExchangeRecords(partyId,pageInfo.getPageNum(),pageInfo.getPageSize())){
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("id", pl.getId());
|
||||
o.put("symbol", pl.getSymbol());
|
||||
o.put("symbolValue",pl.getSymbolValue());
|
||||
o.put("rata", pl.getRata());
|
||||
o.put("realAmount", pl.getRealAmount());
|
||||
o.put("status", pl.getStaus());
|
||||
o.put("currency_symbol", pl.getCurrency_symbol());
|
||||
o.put("createTime", DateUtils.getLongDate(pl.getCreateTime()));
|
||||
o.put("orderPriceType", pl.getOrderPriceType());
|
||||
o.put("orderPriceAmount", pl.getOrderPriceAmount());
|
||||
o.put("payType", pl.getPayType());
|
||||
o.put("bankName", pl.getBankName());
|
||||
o.put("bankAccount", pl.getBankAccount());
|
||||
jsonArray.add(o);
|
||||
}
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("pageInfo", pageInfo);
|
||||
object.put("pageList", jsonArray);
|
||||
resultObject.setData(object);
|
||||
return resultObject;
|
||||
}
|
||||
}
|
||||
96
comm/Wallet/src/project/web/api/ExchangeRateUserConfigController.java
Executable file
96
comm/Wallet/src/project/web/api/ExchangeRateUserConfigController.java
Executable file
@@ -0,0 +1,96 @@
|
||||
package project.web.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.mysql.cj.util.StringUtils;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.web.BaseAction;
|
||||
import kernel.web.ResultObject;
|
||||
import project.wallet.rate.ExchangeRate;
|
||||
import project.wallet.rate.UserRateConfigService;
|
||||
|
||||
/**
|
||||
* API 计价方式
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class ExchangeRateUserConfigController extends BaseAction {
|
||||
|
||||
private static Log logger = LogFactory.getLog(ExchangeRateUserConfigController.class);
|
||||
|
||||
@Autowired
|
||||
private UserRateConfigService userRateConfigService;
|
||||
|
||||
private final String action = "api/exchangerateuserconfig!";
|
||||
|
||||
/**
|
||||
* 设置计价方式
|
||||
*/
|
||||
@RequestMapping(action + "userSetRate.action")
|
||||
public Object userSetRate(HttpServletRequest request) throws IOException {
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
String partyId = this.getLoginPartyId();
|
||||
try {
|
||||
String rateId = request.getParameter("rateId");
|
||||
if (StringUtils.isNullOrEmpty(rateId)) {
|
||||
throw new BusinessException("rateId is null");
|
||||
}
|
||||
this.userRateConfigService.update(rateId, partyId);
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", e);
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 汇率
|
||||
*/
|
||||
@RequestMapping(action + "get.action")
|
||||
public Object get() throws IOException {
|
||||
ResultObject resultObject = new ResultObject();
|
||||
|
||||
String partyId = this.getLoginPartyId();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
try {
|
||||
ExchangeRate exchangeRate = this.userRateConfigService.findUserConfig(partyId);
|
||||
data.put("currency", exchangeRate.getCurrency());
|
||||
data.put("name", exchangeRate.getName());
|
||||
data.put("currency_symbol", exchangeRate.getCurrency_symbol());
|
||||
data.put("rate", exchangeRate.getRata());
|
||||
resultObject.setData(data);
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", e);
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
}
|
||||
210
comm/Wallet/src/project/web/api/PaymentMethodController.java
Executable file
210
comm/Wallet/src/project/web/api/PaymentMethodController.java
Executable file
@@ -0,0 +1,210 @@
|
||||
package project.web.api;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.BaseAction;
|
||||
import kernel.web.ResultObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import project.invest.goods.GoodsService;
|
||||
import project.invest.goods.model.Useraddress;
|
||||
import project.user.kyc.Kyc;
|
||||
import project.user.kyc.KycService;
|
||||
import project.wallet.rate.ExchangeRateService;
|
||||
import project.wallet.rate.PaymentMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class PaymentMethodController extends BaseAction {
|
||||
|
||||
|
||||
@Resource
|
||||
private ExchangeRateService exchangeRateService;
|
||||
|
||||
private static Log logger = LogFactory.getLog(PaymentMethodController.class);
|
||||
|
||||
@Resource
|
||||
protected KycService kycService;
|
||||
|
||||
private final String action = "/api/p-method!";
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @return
|
||||
*/
|
||||
@PostMapping( action+"add.action")
|
||||
public Object add(HttpServletRequest request){
|
||||
ResultObject resultObject = readSecurityContextFromSession(new ResultObject());
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
String partyId = this.getLoginPartyId();
|
||||
int payType = 0;
|
||||
String use = request.getParameter("use");
|
||||
int isUse = 0;
|
||||
if(use!=null){
|
||||
isUse = Integer.parseInt(use);
|
||||
}
|
||||
String bankName = request.getParameter("bankName");
|
||||
|
||||
if(StringUtils.isEmptyString(bankName)){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("开户行不能为空");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
String bankAccount = request.getParameter("bankAccount");
|
||||
|
||||
if(StringUtils.isEmptyString(bankAccount)){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("卡号不能为空");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
Kyc kyc = this.kycService.get(partyId);
|
||||
if (null == kyc ) {
|
||||
resultObject.setCode("800");
|
||||
resultObject.setMsg("尚未KYC认证");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
if ( kyc.getStatus() != 2) {
|
||||
resultObject.setCode("801");
|
||||
resultObject.setMsg("KYC认证尚未通过");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
try {
|
||||
exchangeRateService.savePaymentMethod(partyId,isUse,payType,bankName,bankAccount,kyc);
|
||||
}catch (BusinessException e){
|
||||
e.printStackTrace();
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
return resultObject;
|
||||
}catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("添加失败");
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @return
|
||||
*/
|
||||
@PostMapping( action+"edit.action")
|
||||
public Object edit(HttpServletRequest request){
|
||||
ResultObject resultObject = readSecurityContextFromSession(new ResultObject());
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
String id = request.getParameter("id");
|
||||
if(StringUtils.isEmptyString(id)){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("非法请求");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
String partyId = this.getLoginPartyId();
|
||||
|
||||
String use = request.getParameter("use");
|
||||
int isUse = 0;
|
||||
if(use!=null){
|
||||
isUse = Integer.parseInt(use);
|
||||
}
|
||||
String bankName = request.getParameter("bankName");
|
||||
|
||||
if(StringUtils.isEmptyString(bankName)){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("开户行不能为空");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
String bankAccount = request.getParameter("bankAccount");
|
||||
|
||||
if(StringUtils.isEmptyString(bankAccount)){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("卡号不能为空");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
exchangeRateService.updatePaymentMethod(id,partyId,isUse,bankName,bankAccount);
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @return
|
||||
*/
|
||||
@PostMapping( action+"del.action")
|
||||
public Object del(HttpServletRequest request){
|
||||
ResultObject resultObject = readSecurityContextFromSession(new ResultObject());
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
String id = request.getParameter("id");
|
||||
if(StringUtils.isEmptyString(id)){
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("非法请求");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
try {
|
||||
exchangeRateService.removePaymentMethod(id);
|
||||
}catch (BusinessException e){
|
||||
e.printStackTrace();
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
return resultObject;
|
||||
}catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("删除失败");
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表地址
|
||||
* @return
|
||||
*/
|
||||
@PostMapping( action+"list.action")
|
||||
public Object list(){
|
||||
ResultObject resultObject = readSecurityContextFromSession(new ResultObject());
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
String partyId = this.getLoginPartyId();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for(PaymentMethod address: exchangeRateService.listPaymentMethod(partyId)){
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("id", address.getId().toString());
|
||||
o.put("use", address.getStatus());
|
||||
o.put("payType", address.getPayType());
|
||||
o.put("realName", address.getRealName());
|
||||
o.put("bankName", address.getBankName());
|
||||
o.put("bankAccount", address.getBankAccount());
|
||||
jsonArray.add(o);
|
||||
}
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("pageList", jsonArray);
|
||||
resultObject.setData(object);
|
||||
return resultObject;
|
||||
}
|
||||
}
|
||||
534
comm/Wallet/src/project/web/api/WalletController.java
Executable file
534
comm/Wallet/src/project/web/api/WalletController.java
Executable file
@@ -0,0 +1,534 @@
|
||||
package project.web.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.BaseAction;
|
||||
import kernel.web.ResultObject;
|
||||
import project.Constants;
|
||||
import project.data.DataService;
|
||||
import project.data.model.Realtime;
|
||||
import project.item.ItemService;
|
||||
import project.item.model.Item;
|
||||
import project.wallet.Wallet;
|
||||
import project.wallet.WalletExtend;
|
||||
import project.wallet.WalletLogService;
|
||||
import project.wallet.WalletService;
|
||||
|
||||
/**
|
||||
* 钱包
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class WalletController extends BaseAction {
|
||||
|
||||
private Logger logger = LogManager.getLogger(WalletController.class);
|
||||
|
||||
@Autowired
|
||||
protected WalletService walletService;
|
||||
@Autowired
|
||||
protected ItemService itemService;
|
||||
@Autowired
|
||||
private DataService dataService;
|
||||
@Autowired
|
||||
protected WalletLogService walletLogService;
|
||||
|
||||
private final String action = "/api/wallet!";
|
||||
|
||||
/**
|
||||
* 钱包账户资产(usdt、btc、eth)
|
||||
*/
|
||||
@RequestMapping(action + "get.action")
|
||||
public Object get(HttpServletRequest request) throws IOException {
|
||||
return getWalletExtends(request, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱包账户资产(所有币种)
|
||||
*/
|
||||
@RequestMapping(action + "getAll.action")
|
||||
public Object getAll(HttpServletRequest request) throws IOException {
|
||||
return getWalletExtends(request, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* all:true/获取全部;false/获取usdt、btc、eth;
|
||||
*/
|
||||
public Object getWalletExtends(HttpServletRequest request, boolean all) throws IOException {
|
||||
String symbol = request.getParameter("symbol");
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
|
||||
try {
|
||||
|
||||
Map<String, Object> mapRet = new LinkedHashMap<String, Object>();
|
||||
|
||||
DecimalFormat df2 = new DecimalFormat("#.########");
|
||||
// 向下取整
|
||||
df2.setRoundingMode(RoundingMode.FLOOR);
|
||||
|
||||
String partyId = this.getLoginPartyId();
|
||||
Wallet usdt = null;
|
||||
if (StringUtils.isNotEmpty(partyId)) {
|
||||
usdt = this.walletService.saveWalletByPartyId(partyId);
|
||||
}
|
||||
|
||||
if (null == usdt) {
|
||||
usdt = new Wallet();
|
||||
usdt.setMoney(0.0);
|
||||
mapRet.put("usdt", usdt.getMoney());
|
||||
} else {
|
||||
DecimalFormat df = new DecimalFormat("#.##");
|
||||
df.setRoundingMode(RoundingMode.FLOOR);
|
||||
usdt.setMoney(Arith.roundDown(Double.valueOf(df.format(usdt.getMoney())),2));
|
||||
mapRet.put("usdt", usdt.getMoney());
|
||||
}
|
||||
|
||||
// 其他币账户
|
||||
List<Item> list_it = this.itemService.cacheGetByMarket("");
|
||||
List<String> list_symbol = new ArrayList<String>();
|
||||
|
||||
if (!StringUtils.isNotEmpty(symbol)) {
|
||||
// symbol为空,获取所有的
|
||||
for (int i = 0; i < list_it.size(); i++) {
|
||||
Item items = list_it.get(i);
|
||||
list_symbol.add(items.getSymbol());
|
||||
}
|
||||
} else {
|
||||
List<String> symbolList = Arrays.asList(symbol.split(","));
|
||||
for (int i = 0; i < list_it.size(); i++) {
|
||||
Item items = list_it.get(i);
|
||||
// 只添加所有币种和参数symbol都有的
|
||||
if (symbolList.contains(items.getSymbol())) {
|
||||
list_symbol.add(items.getSymbol());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Item> items = this.itemService.cacheGetAll();
|
||||
// 按id排序
|
||||
Collections.sort(items, new Comparator<Item>() {
|
||||
@Override
|
||||
public int compare(Item arg0, Item arg1) {
|
||||
return arg0.getId().toString().compareTo(arg1.getId().toString());
|
||||
}
|
||||
});
|
||||
|
||||
Map<String, Item> itemMap = new HashMap<String, Item>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
itemMap.put(items.get(i).getSymbol(), items.get(i));
|
||||
}
|
||||
|
||||
List<WalletExtend> walletExtends = null;
|
||||
if (StringUtils.isNotEmpty(partyId)) {
|
||||
|
||||
// // symbols大写列表
|
||||
// List<String> list_symbol_uppercase = new ArrayList<String>();
|
||||
// for (int i = 0; i < list_symbol.size(); i++) {
|
||||
// list_symbol_uppercase.add(list_symbol.get(i).toUpperCase());
|
||||
// }
|
||||
|
||||
walletExtends = this.walletService.findExtend(partyId, list_symbol);
|
||||
}
|
||||
|
||||
if (null == walletExtends) {
|
||||
walletExtends = new ArrayList<WalletExtend>();
|
||||
}
|
||||
|
||||
List<WalletExtend> walletExtendsRet = new ArrayList<WalletExtend>();
|
||||
|
||||
int temp = 0;
|
||||
for (int i = 0; i < list_symbol.size(); i++) {
|
||||
|
||||
for (int j = 0; j < walletExtends.size(); j++) {
|
||||
|
||||
WalletExtend walletExtend = walletExtends.get(j);
|
||||
if (walletExtend.getWallettype().equals(list_symbol.get(i))) {
|
||||
walletExtend.setAmount(Double.valueOf(df2.format(walletExtend.getAmount())));
|
||||
walletExtendsRet.add(walletExtend);
|
||||
temp = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == temp) {
|
||||
WalletExtend walletExtend = new WalletExtend();
|
||||
if (StringUtils.isNotEmpty(partyId)) {
|
||||
walletExtend.setPartyId(partyId);
|
||||
}
|
||||
walletExtend.setWallettype(list_symbol.get(i));
|
||||
walletExtend.setAmount(0);
|
||||
walletExtend.setName(itemMap.get(list_symbol.get(i)).getName());
|
||||
walletExtendsRet.add(walletExtend);
|
||||
}
|
||||
|
||||
temp = 0;
|
||||
}
|
||||
|
||||
String symbolsStr = "";
|
||||
for (int i = 0; i < list_symbol.size(); i++) {
|
||||
if (i != 0) {
|
||||
symbolsStr = symbolsStr + "," + list_symbol.get(i);
|
||||
} else {
|
||||
symbolsStr = list_symbol.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
List<Realtime> realtime_all = this.dataService.realtime(symbolsStr);
|
||||
if (realtime_all.size() <= 0) {
|
||||
// throw new BusinessException("系统错误,请稍后重试");
|
||||
}
|
||||
|
||||
Map<String, Realtime> realtimeMap = new HashMap<String, Realtime>();
|
||||
for (int i = 0; i < realtime_all.size(); i++) {
|
||||
realtimeMap.put(realtime_all.get(i).getSymbol(), realtime_all.get(i));
|
||||
}
|
||||
|
||||
List<Map<String, Object>> extendsList = new ArrayList<Map<String,Object>>();
|
||||
for (int i = 0; i < walletExtendsRet.size(); i++) {
|
||||
|
||||
if (false == all) {
|
||||
// 只要btc、eth
|
||||
if (!walletExtendsRet.get(i).getWallettype().equals("btc")
|
||||
&& !walletExtendsRet.get(i).getWallettype().equals("eth")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("name", walletExtendsRet.get(i).getName());
|
||||
map.put("symbol", walletExtendsRet.get(i).getWallettype());
|
||||
map.put("volume", walletExtendsRet.get(i).getAmount());
|
||||
|
||||
Realtime rt = realtimeMap.get(walletExtendsRet.get(i).getWallettype());
|
||||
if (null != rt) {
|
||||
map.put("usdt", Arith.mul(rt.getClose(), walletExtendsRet.get(i).getAmount()));
|
||||
} else {
|
||||
map.put("usdt", 0);
|
||||
}
|
||||
|
||||
extendsList.add(map);
|
||||
}
|
||||
|
||||
if (!StringUtils.isNotEmpty(symbol) || symbol.contains("usdt")) {
|
||||
// 添加usdt到列表最前面
|
||||
Map<String, Object> mapUsdt = new HashMap<String, Object>();
|
||||
mapUsdt.put("name", "USDT/USDT");
|
||||
mapUsdt.put("symbol", "usdt");
|
||||
mapUsdt.put("volume", mapRet.get("usdt"));
|
||||
mapUsdt.put("usdt", mapRet.get("usdt"));
|
||||
extendsList.add(0, mapUsdt);
|
||||
}
|
||||
|
||||
mapRet.put("extends", extendsList);
|
||||
|
||||
resultObject.setData(mapRet);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱包日志 充值category=recharge;提现category=withdraw;
|
||||
*/
|
||||
@RequestMapping(action + "logs.action")
|
||||
public Object logs(HttpServletRequest request) throws IOException {
|
||||
String page_no = request.getParameter("page_no");
|
||||
String category = request.getParameter("category");
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = this.readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if (StringUtils.isNullOrEmpty(page_no)) {
|
||||
page_no = "1";
|
||||
}
|
||||
if (!StringUtils.isInteger(page_no)) {
|
||||
throw new BusinessException("页码不是整数");
|
||||
}
|
||||
if (Integer.valueOf(page_no).intValue() <= 0) {
|
||||
throw new BusinessException("页码不能小于等于0");
|
||||
}
|
||||
|
||||
int page_no_int = Integer.valueOf(page_no).intValue();
|
||||
|
||||
List<Map<String, Object>> data = this.walletLogService.pagedQuery(page_no_int, 10, this.getLoginPartyId(), category, "1").getElements();
|
||||
for (Map<String, Object> log : data) {
|
||||
|
||||
if (null == log.get("wallettype") || !StringUtils.isNotEmpty(log.get("wallettype").toString()))
|
||||
log.put("wallettype", Constants.WALLET);
|
||||
else {
|
||||
log.put("wallettype", log.get("wallettype").toString().toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
resultObject.setData(data);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱包历史记录
|
||||
*/
|
||||
@RequestMapping(action + "records.action")
|
||||
public Object records(HttpServletRequest request) throws IOException {
|
||||
// 页码
|
||||
String page_no = request.getParameter("page_no");
|
||||
/**
|
||||
* 资金账变类型,
|
||||
* project.Constants(line:214-250)
|
||||
*/
|
||||
String category = request.getParameter("category");
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = this.readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if (StringUtils.isNullOrEmpty(page_no)) {
|
||||
page_no = "1";
|
||||
}
|
||||
if (!StringUtils.isInteger(page_no)) {
|
||||
throw new BusinessException("页码不是整数");
|
||||
}
|
||||
if (Integer.valueOf(page_no).intValue() <= 0) {
|
||||
throw new BusinessException("页码不能小于等于0");
|
||||
}
|
||||
|
||||
int page_no_int = Integer.valueOf(page_no).intValue();
|
||||
|
||||
List<Map<String, Object>> data = this.walletLogService.pagedQueryRecords(page_no_int, 10, this.getLoginPartyId(),
|
||||
category).getElements();
|
||||
for (Map<String, Object> log : data) {
|
||||
|
||||
if (null == log.get("wallet_type") || !StringUtils.isNotEmpty(log.get("wallet_type").toString()))
|
||||
log.put("wallet_type", Constants.WALLET);
|
||||
else {
|
||||
log.put("wallet_type", log.get("wallet_type").toString().toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
resultObject.setData(data);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取币种钱包
|
||||
*/
|
||||
@RequestMapping(action + "list.action")
|
||||
public Object list(HttpServletRequest request) {
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = this.readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
|
||||
Wallet usdt = null;
|
||||
String partyId = this.getLoginPartyId();
|
||||
if (StringUtils.isNotEmpty(partyId)) {
|
||||
usdt = this.walletService.saveWalletByPartyId(partyId);
|
||||
}
|
||||
|
||||
DecimalFormat df2 = new DecimalFormat("#.########");
|
||||
// 向下取整
|
||||
df2.setRoundingMode(RoundingMode.FLOOR);
|
||||
if (null == usdt) {
|
||||
usdt = new Wallet();
|
||||
usdt.setMoney(0.0);
|
||||
map.put("USDT", usdt);
|
||||
} else {
|
||||
DecimalFormat df = new DecimalFormat("#.##");
|
||||
df.setRoundingMode(RoundingMode.FLOOR);
|
||||
usdt.setMoney(Arith.roundDown(Double.valueOf(df.format(usdt.getMoney())),2));
|
||||
map.put("USDT", usdt);
|
||||
}
|
||||
|
||||
// 其他币账户
|
||||
List<Item> list_it = this.itemService.cacheGetByMarket("");
|
||||
List<String> list_symbol = new ArrayList<String>();
|
||||
for (int i = 0; i < list_it.size(); i++) {
|
||||
Item items = list_it.get(i);
|
||||
list_symbol.add(items.getSymbol());
|
||||
}
|
||||
|
||||
List<Item> items = this.itemService.cacheGetAll();
|
||||
Collections.sort(items, new Comparator<Item>() {
|
||||
// 按id排序
|
||||
@Override
|
||||
public int compare(Item arg0, Item arg1) {
|
||||
return arg0.getId().toString().compareTo(arg1.getId().toString());
|
||||
}
|
||||
});
|
||||
|
||||
List<WalletExtend> walletExtends = null;
|
||||
if (StringUtils.isNotEmpty(partyId)) {
|
||||
walletExtends = this.walletService.findExtend(partyId, list_symbol);
|
||||
}
|
||||
|
||||
WalletExtend walletExtend = new WalletExtend();
|
||||
|
||||
// 如果是空
|
||||
if (null == walletExtends) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
walletExtend.setWallettype(items.get(i).getSymbol().toUpperCase());
|
||||
walletExtend.setAmount(0);
|
||||
map.put(walletExtend.getWallettype().toUpperCase(), walletExtend);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果不为空且2个相同
|
||||
if (walletExtends != null && walletExtends.size() == items.size()) {
|
||||
|
||||
for (int i = 0; i < walletExtends.size(); i++) {
|
||||
if (null == walletExtends.get(i)) {
|
||||
continue;
|
||||
}
|
||||
walletExtend = walletExtends.get(i);
|
||||
usdt.setMoney(Arith.roundDown(Double.valueOf(df2.format(usdt.getMoney())),2));
|
||||
walletExtend.setAmount(Double.valueOf(df2.format(walletExtend.getAmount())));
|
||||
|
||||
map.put(walletExtend.getWallettype().toUpperCase(), walletExtend);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果不为空 且数据库里的少于币种
|
||||
int temp = 0;
|
||||
if (walletExtends != null && walletExtends.size() < items.size()) {
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
|
||||
for (int j = 0; j < walletExtends.size(); j++) {
|
||||
|
||||
walletExtend = walletExtends.get(j);
|
||||
if (walletExtend.getWallettype().equals(items.get(i).getSymbol())) {
|
||||
walletExtend.setAmount(Double.valueOf(df2.format(walletExtend.getAmount())));
|
||||
|
||||
map.put(walletExtend.getWallettype().toUpperCase(), walletExtend);
|
||||
temp = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == temp) {
|
||||
walletExtend = new WalletExtend();
|
||||
walletExtend.setWallettype(items.get(i).getSymbol());
|
||||
walletExtend.setAmount(0);
|
||||
|
||||
map.put(walletExtend.getWallettype().toUpperCase(), walletExtend);
|
||||
} else {
|
||||
temp = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resultObject.setData(map);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取usdt余额
|
||||
*
|
||||
*/
|
||||
@RequestMapping(action + "getUsdt.action")
|
||||
public Object getUsdt(HttpServletRequest request) {
|
||||
ResultObject resultObject = new ResultObject();
|
||||
// usdt余额
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
String partyId = this.getLoginPartyId();
|
||||
// String partyId = "ff8080818604394d01860767e945005c";
|
||||
if (null == partyId || partyId.equals("")){
|
||||
resultObject.setCode("403");
|
||||
resultObject.setMsg("登录过期,请重新登录");
|
||||
return resultObject;
|
||||
}
|
||||
//DecimalFormat df2 = new DecimalFormat("#.##");
|
||||
// 向下取整
|
||||
//df2.setRoundingMode(RoundingMode.FLOOR);
|
||||
Wallet wallet = this.walletService.selectOne(partyId);
|
||||
if (null != wallet){
|
||||
double money = wallet.getMoney();
|
||||
double frozenMoney = wallet.getMoneyAfterFrozen();
|
||||
// 账户剩余资金
|
||||
if(wallet.getFrozenState()==0){
|
||||
data.put("money", Arith.round(money,2));
|
||||
data.put("frozenMoney", Arith.round(frozenMoney,2));
|
||||
}else if (wallet.getFrozenState()==1){
|
||||
data.put("money", Arith.round(frozenMoney,2));
|
||||
data.put("frozenMoney", Arith.round(money,2));
|
||||
}
|
||||
data.put("rebate", Arith.round(wallet.getRebate(),2));
|
||||
}
|
||||
resultObject.setData(data);
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user