first commit

This commit is contained in:
Ray
2026-02-19 03:37:37 +08:00
commit ccfd8c79a4
2813 changed files with 453657 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View File

@@ -0,0 +1,205 @@
<%@ 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/adminContractManageAction!contractInstallList.action" --%>
action="<%=basePath%>normal/adminContractManageAction!listPara.action"
method="post" id="queryForm">
<s:hidden name="pageNo" id="pageNo"></s:hidden>
<s:hidden name="query_symbol" id="query_symbol"></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">
<s:if test="futuresPara.id!=null">
修改合约参数
</s:if>
<s:else>
新增合约参数
</s:else>
<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>
<p class="ballon color1">交割收益:交割收益计算方式(0~100百分制)。</p>
<div class="panel-body">
<form class="form-horizontal"
action="<%=basePath%>normal/adminContractManageAction!addFutures.action"
method="post" name="mainForm" id="mainForm">
<s:hidden name="futuresPara.id" id="futures_id" ></s:hidden>
<s:hidden name="query_symbol" id="query_symbol"></s:hidden>
<div class="form-group">
<label class="col-sm-2 control-label form-label">合约代码</label>
<div class="col-sm-2">
<s:select id="symbol" cssClass="form-control "
name="futuresPara.symbol" list="symbolMap"
listKey="key" listValue="value"
headerKey="" headerValue="--选择合约产品--" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">时间</label>
<div class="col-sm-2">
<s:textfield id="time_num" name="futuresPara.timeNum" cssClass="form-control " />
</div>
<div class="col-sm-2">
<s:select id="time_unit" cssClass="form-control " style="width: 60px;"
name="futuresPara.timeUnit" list="#{'second':'秒','minute':'分','hour':'时','day':'天'}"
listKey="key" listValue="value" />
</div>
</div>
<%-- <div class="form-group">
<label class="col-sm-2 control-label form-label">交割收益</label>
<div class="col-sm-2">
<div class="input-group">
<s:textfield id="username" name="username" cssClass="form-control " />
<div class="">
<s:select id="enabled" cssClass="form-control input-group-addon" style="width: 60px;"
name="enabled" list="#{'s':'秒','m':'分','h':'时','d':'天'}"
listKey="key" listValue="value" value="enabled" />
</div>
</div>
</div>
</div> --%>
<div class="form-group">
<label class="col-sm-2 control-label form-label">交割收益</label>
<div class="col-sm-3">
<div class="input-group">
<s:textfield id="profit_ratio" name="futuresPara.profit_ratio" cssClass="form-control " />
<div class="input-group-addon">--</div>
<s:textfield id="profit_ratio_max" name="futuresPara.profit_ratio_max" cssClass="form-control " />
<div class="input-group-addon">%</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">最低购买金额</label>
<div class="col-sm-2">
<s:textfield id="unit_amount" name="futuresPara.unit_amount" cssClass="form-control "/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">手续费</label>
<div class="col-sm-2">
<div class="input-group">
<s:textfield id="unit_fee" name="futuresPara.unit_fee" cssClass="form-control " />
<div class="input-group-addon">%</div>
</div>
</div>
</div>
<%-- <div class="form-group">
<label class="col-sm-2 control-label form-label">是否锁定</label>
<div class="col-sm-4">
<s:select id="enabled" cssClass="form-control "
name="enabled" list="#{true:'正常',false:'业务锁定(登录不受影响)'}"
listKey="key" listValue="value" value="enabled" />
</div>
</div>
<div class="form-group">
<label for="input002" class="col-sm-2 control-label form-label">备注</label>
<div class="col-sm-5">
<s:textarea name="remarks" id="remarks"
cssClass="form-control input-lg" rows="3" cols="10" />
</div>
</div> --%>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<a href="javascript:goUrl(<s:property value="pageNo" />)"
class="btn">取消</a> <a href="javascript:submit()"
class="btn btn-default">保存</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- END CONTAINER -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<%@ include file="include/footer.jsp"%>
</div>
<!-- End Content -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<%@ include file="include/js.jsp"%>
<script type="text/javascript">
$(function(){
var id = $('#futures_id').val();
if(typeof(id)!='undefined'&&id.length>0){
$("#symbol").attr("disabled", "disabled");
}
})
function submit() {
$("#symbol").removeAttr("disabled");
swal({
title : "是否保存?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
document.getElementById("mainForm").submit();
});
}
</script>
</body>
</html>

View File

@@ -0,0 +1,151 @@
<%@ 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/adminContractManageAction!list.action"
method="post" id="queryForm">
<s:hidden name="pageNo" id="pageNo"></s:hidden>
<%-- <s:hidden name="name_para" id="name_para"></s:hidden> --%>
<%-- <s:hidden name="rolename_para" id="rolename_para"></s:hidden> --%>
</form>
<!-- END queryForm -->
<div class="row">
<div class="col-md-12">
<!-- Start Panel -->
<div class="panel panel-default">
<div class="panel-title">$名称 合约设置</div>
<a href="javascript:goUrl(<s:property value="pageNo" />)"
class="btn btn-light" style="margin-bottom: 10px"><i
class="fa fa-mail-reply"></i>返回</a>
<a href="<%=basePath%>normal/adminContractManageAction!toAddInstall.action"
class="btn btn-light" style="margin-bottom: 10px"><i
class="fa fa-pencil"></i>新增合约</a>
<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>
<td>最小变动单位</td>
<td>最小变动单位的盈亏金额</td> -->
<!--
<td>市场</td> -->
<td width="130px"></td>
</tr>
</thead>
<tbody>
<tr>
<td>30</td>
<td>秒</td>
<td>20</td>
<td>100</td>
<td>1</td>
<td><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">
<li>
<a href="">修改</a>
</li>
<%-- <li>
<a href="<%=basePath%>normal/adminItemLeverageAction!list.action?itemid=<s:property value="id" />">交易杠杆</a>
</li> --%>
</ul>
</div>
</tr>
<s:iterator value="page.elements" status="stat">
<tr>
<%-- <td><s:property value="name" /></td>
<td><s:property value="symbol" /></td>
<td><s:property value="symbol_data" /></td>
<td><s:property value="unit_amount" /></td>
<td><s:property value="unit_fee" /></td>
<td><s:property value="pips" /></td>
<td><s:property value="pips_amount" /></td> --%>
<!--
<td><s:if test='market=="1"'>币币交易</s:if><s:if test='market=="2"'>合约交易</s:if></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">
<li>
<a href="">修改</a>
</li>
<%--<li>
<a href="<%=basePath%>normal/adminItemLeverageAction!list.action?itemid=<s:property value="id" />">交易杠杆</a>
</li> --%>
</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>

View File

@@ -0,0 +1,275 @@
<%@ 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/adminContractManageAction!list.action"
method="post" id="queryForm">
<s:hidden name="pageNo" id="pageNo"></s:hidden>
<s:hidden name="name_para" id="name_para"></s:hidden>
<s:hidden name="rolename_para" id="rolename_para"></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">
<s:if test="itemId!=null">
修改合约产品
</s:if>
<s:else>
新增合约产品
</s:else>
<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/adminContractManageAction!addContractItem.action"
method="post" name="mainForm" id="mainForm">
<s:hidden name="itemId" id="item_id" ></s:hidden>
<div class="form-group">
<label class="col-sm-2 control-label form-label">合约名称</label>
<div class="col-sm-2">
<s:textfield id="name" name="name" cssClass="form-control " />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">代码</label>
<div class="col-sm-2">
<s:textfield id="symbol" name="symbol" cssClass="form-control " />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">保留精度</label>
<div class="col-sm-2">
<div class="input-group">
<s:textfield id="decimals" name="decimals" cssClass="form-control " />
<div class="input-group-addon">位</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">交易对</label>
<div class="col-sm-3">
<s:textfield id="symbol_data" name="symbol_data" cssClass="form-control " readonly="true" />
</div>
<a href="javascript:chooseSymbol('<s:property value="id" />')"
class="btn btn-light" style="margin-bottom: 10px">交易对选择</a>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<a href="javascript:goUrl(<s:property value="pageNo" />)"
class="btn">取消</a> <a href="javascript:submit()"
class="btn btn-default">保存</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- END CONTAINER -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<%@ include file="include/footer.jsp"%>
</div>
<!-- End Content -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- 模态框 -->
<div class="form-group">
<input type="hidden" name="quote_currency" id="quote_currency" value="">
<!-- <input type="hidden" name="base_currency" id="base_currency" value=""> -->
<%-- <form action="<%=basePath%>normal/adminSymbolsAction!list.action"
method="post" id="succeededForm">
<input type="hidden" name="pageNo" id="pageNo"
value="${param.pageNo}">
<s:hidden name="id" id="id_reset"></s:hidden>
<s:hidden name="name_para" id="name_para"></s:hidden>
<s:hidden name="rolename_para" id="rolename_para"></s:hidden> --%>
<div class="col-sm-2">
<!-- 模态框Modal -->
<div class="modal fade" id="modal_set" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content" style="height:500px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">交易对</h4>
</div>
<%--<div class="modal-body">
<div class="">
<s:textfield id="money_revise" name="money_revise"
cssClass="form-control " />
<span class="help-block">增加请输入正数,扣除请输入负数</span>
</div>
--%>
<div class="modal-body" id="symbols_get" style="height:380px;">
<%@ include file="contract_manage_add_symbols_list.jsp"%>
</div>
<div class="modal-footer" style="margin-top: 0;">
<button type="button" class="btn " data-dismiss="modal" >关闭</button>
<button id="sub" type="submit" class="btn btn-default" onclick="modalConfirm(this)">确认</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
</div>
<!-- </form> -->
</div>
<%@ include file="include/js.jsp"%>
<script type="text/javascript">
function submit() {
swal({
title : "是否保存?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
document.getElementById("mainForm").submit();
});
}
</script>
<script type="text/javascript">
$(function(){
var id = $('#item_id').val();
if(typeof(id)!='undefined'&&id.length>0){
$("#symbol").prop("readOnly",true);
$("#symbol_data").prop("readOnly",true);
}
})
function chooseSymbol(id) {
// $("#id_resetpsw").val(id);
csPage(1);
$('#modal_set').modal("show");
}
</script>
<sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_ROOT">
<form action="<%=basePath%>normal/adminSymbolsAction!reload.action" method="post"
id="reload">
</form>
<script type="text/javascript">
function reload() {
swal({
title : "是否同步远程数据库?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : true
}, function() {
$.ajax({
url:'<%=basePath%>normal/adminContractSymbolsAction!reload.action',
type:'post',
success: function (res) {
// 一旦设置的 dataType 选项,就不再关心 服务端 响应的 Content-Type 了
// 客户端会主观认为服务端返回的就是 JSON 格式的字符串
// console.log(res)
// $(".loading").hide();
$("#symbols_get").html(res);
}
});
// document.getElementById("reload").submit();
});
}
function csPage(pageNo,quoteCurrency,baseCurrency){
var url = $("#csUrl").val();
quoteCurrency = null==quoteCurrency||''==quoteCurrency||typeof(quoteCurrency) == "undefined"?$('#quote_currency').val():quoteCurrency;
baseCurrency = null==baseCurrency||''==baseCurrency||typeof(baseCurrency) == "undefined"?$('#base_currency').val():baseCurrency;
pageNo = Number(pageNo)<=0?1:pageNo;
var data = {"pageNo":pageNo,"quote_currency":quoteCurrency,"base_currency":baseCurrency};
goAjaxUrl(url,data);
// $('#quote_currency').val(quoteCurrency);
// $('#base_currency').val(baseCurrency);
}
function goAjaxUrl(targetUrl,data){
$.ajax({
url:targetUrl,
data:data,
type:'get',
success: function (res) {
// 一旦设置的 dataType 选项,就不再关心 服务端 响应的 Content-Type 了
// 客户端会主观认为服务端返回的就是 JSON 格式的字符串
// console.log(res)
// $(".loading").hide();
$("#symbols_get").html(res);
$('#quote_currency').val(data.quote_currency);
$('#base_currency').val(data.base_currency);
if(null==data.quote_currency||''==data.quote_currency||typeof(data.quote_currency) == "undefined"){
$('.tr_quote:first').attr('style','background:#39ffff;');
}else{
$('#tr_'+data.quote_currency).attr('style','background:#39ffff;');
}
}
});
}
function modalConfirm(e){
$("#symbol_data").val($(".symbolCheck:checked").val());
$(e).prev().click();
}
</script>
</sec:authorize>
</body>
</html>

View File

@@ -0,0 +1,296 @@
<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<div class="">
<%@ 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/adminContractSymbolsAction!list.action"
method="post" id="queryForm">
<input type="hidden" name="pageNo" id="pageNo"
value="${param.pageNo}">
<div class="col-md-12 col-lg-4">
<fieldset>
<div class="control-group">
<div class="controls">
<s:textfield id="quote_currency" name="quote_currency" cssClass="form-control " placeholder="报价币种"/>
</div>
</div>
</fieldset>
</div>
<div class="col-md-12 col-lg-4">
<fieldset>
<div class="control-group">
<div class="controls">
<s:textfield id="base_currency" name="base_currency" cssClass="form-control " placeholder="基础币种"/>
</div>
</div>
</fieldset>
</div>
<div class="col-md-12 col-lg-2">
<button type="button" class="btn btn-light btn-block" onClick="csPage('1')">查询</button>
</div>
</form>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<div class="col-md-12 col-lg-4" style="margin-top: 10px;">
<div class="mailbox clearfix">
<div class="mailbox-menu">
<ul class="menu">
<li>
<button type="button" onclick="reload()" class="btn btn-default ">同步远程数据库</button></li>
</ul>
</div>
</div>
</div>
</sec:authorize>
</div>
</div>
</div>
</div> --%>
<div>
<div class="col-md-3" >
</div>
<div class="control-group col-md-3">
<div class="controls">
<s:textfield id="base_currency" name="base_currency" cssClass="form-control " placeholder="基础币种" value="" onblur="csPage('1')"/>
</div>
<!-- <button type="button" class="btn btn-light btn-block" onClick="csPage('1')">查询</button> -->
</div>
</div>
<!-- END queryForm -->
<div class="row">
<div class="col-md-12">
<!-- Start Panel -->
<!-- <div class="panel panel-default panel-body"> -->
<div class="col-md-3">
<!-- <div class="panel-title">查询结果</div> -->
<div class="panel-body">
<table class="table table-bordered table-striped">
<thead>
<tr>
<!-- <td>交易对</td>
<td>基础币种</td> -->
<td style="text-align: center;">报价币种</td>
<!-- <td></td> -->
<!--<td>报价精度(小数位)</td>
<td>交易对杠杆最大倍数</td>
<td>状态</td>
<td></td> -->
</tr>
</thead>
<tbody>
<s:iterator value="quoteList" status="stat" id="char">
<tr id="tr_<s:property value="char" />" class="tr_quote">
<%-- <td><s:property value="symbol" /></td> --%>
<%-- <td><s:property value="base_currency" /></td> --%>
<td style="padding: 5px;text-align: center;"><a href="javascript:csPage('1','<s:property value="char" />')"><s:property value="char" /></a></td>
<%-- <td><s:property value="price_precision" /></td> --%>
<%-- <td><s:property value="leverage_ratio" /></td> --%>
<%-- <td><s:property value="state" /></td> --%>
<%-- <td>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<div class="btn-group">
<a href="javascript:csPage('1','<s:property value="char" />')"
class="btn btn-light" style="margin-bottom: 10px">查看</a>
<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">
<li><a
href="${basePath}normal/adminItemAction!toAdd.action?symbol_data=<s:property value="symbol" />&symbol=<s:property value="base_currency" />">添加到交易品种</a></li>
</ul>
</div>
</sec:authorize>
</td> --%>
</tr>
</s:iterator>
</tbody>
</table>
<nav>
</div>
</div>
<div class="col-md-9">
<!-- <div class="panel-title">交易对查询结果(默认第一个报价币种)</div> -->
<div class="panel-body ">
<table class="table table-bordered table-striped">
<thead>
<tr>
<td></td>
<td style="text-align: center;">基础币种</td>
<td style="text-align: center;">交易对</td>
<!-- <td>报价币种</td> -->
<!-- <td>报价币种</td>
<td>报价精度(小数位)</td>
<td>交易对杠杆最大倍数</td>
<td>状态</td>
<td></td> -->
</tr>
</thead>
<tbody>
<s:iterator value="page.elements" status="stat">
<tr>
<td style="padding: 5px;text-align: center;">
<!-- <div class="checkbox checkbox-success checkbox-circle"><input type="checkbox" name="choseSymbol" ></input></div> -->
<div class="checkbox checkbox-success checkbox-circle" style="padding-left: 27px;height: 0px;margin-top: 3px;">
<input id="checkbox<s:property value="#stat.index" />" type="checkbox" class="symbolCheck" onClick="checkToRadio(this)" value="<s:property value="symbol" />">
<label for="checkbox<s:property value="#stat.index" />">
</label>
</div>
</td>
<td style="padding: 5px;text-align: center;"><s:property value="base_currency" /></td>
<td style="padding: 5px;text-align: center;"><s:property value="symbol" /></td>
<%-- <td><s:property value="quote_currency" /></td> --%>
<%-- <td><s:property value="price_precision" /></td> --%>
<%-- <td><s:property value="leverage_ratio" /></td> --%>
<%-- <td><s:property value="state" /></td> --%>
<%-- <td>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<div class="btn-group">
<a href=""
class="btn btn-light" style="margin-bottom: 10px">选中</a>
<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">
<li><a
href="${basePath}normal/adminItemAction!toAdd.action?symbol_data=<s:property value="symbol" />&symbol=<s:property value="base_currency" />">添加到交易品种</a></li>
</ul>
</div>
</sec:authorize>
</td> --%>
</tr>
</s:iterator>
</tbody>
</table>
<ul class="pager" style="text-align: right;">
<!-- <li><a href="javascript:csPage('1')">首页</a></li> -->
<li><a href="javascript:csPage('${pageNo-1}')">上一页</a></li>
<li><a href="javascript:csPage('${pageNo+1}')">下一页</a></li>
<%-- <li><a href="javascript:csPage('${1000000}')">尾页</a></li> --%>
</ul>
</div>
</div>
<!-- </div> -->
<!-- End Panel -->
</div>
<!-- right table -->
<%-- <div class="col-md-7">
<!-- 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>
<td>交易对杠杆最大倍数</td>
<td>状态</td>
<td></td> -->
</tr>
</thead>
<tbody>
<s:iterator value="page.elements" status="stat">
<tr>
<td><s:property value="symbol" /></td>
<td><s:property value="base_currency" /></td>
<td><s:property value="quote_currency" /></td>
<td><s:property value="price_precision" /></td>
<td><s:property value="leverage_ratio" /></td>
<td><s:property value="state" /></td>
<td>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<div class="btn-group">
<a href=""
class="btn btn-light" style="margin-bottom: 10px">选中</a>
<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">
<li><a
href="${basePath}normal/adminItemAction!toAdd.action?symbol_data=<s:property value="symbol" />&symbol=<s:property value="base_currency" />">添加到交易品种</a></li>
</ul>
</div>
</sec:authorize>
</td>
</tr>
</s:iterator>
</tbody>
</table>
<ul class="pager" style="text-align: left;">
<li><a href="javascript:csPage('1')">首页</a></li>
<li><a href="javascript:csPage('${pageNo-1}')">上一页</a></li>
<li><a href="javascript:csPage('${pageNo+1}')">下一页</a></li>
<li><a href="javascript:csPage('${1000000}')">尾页</a></li>
</ul>
</div>
</div>
<!-- End Panel -->
</div> --%>
</div>
<input type="hidden" value="${basePath}/normal/adminContractSymbolsAction!list.action" id='csUrl'/>
</div>
<script>
function checkToRadio(e){
className=$(e).attr("class");
console.log();
$("."+className).prop("checked",false);
$(e).prop("checked",true);
}
</script>

View File

@@ -0,0 +1,168 @@
<%@ 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"%>
<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/adminContractManageAction!list.action"
method="post" id="queryForm">
<s:hidden name="pageNo" id="pageNo"></s:hidden>
<div class="col-md-12 col-lg-4">
<fieldset>
<div class="control-group">
<div class="controls">
<s:textfield id="query_symbol" name="para_symbol" cssClass="form-control " placeholder="合约代码"/>
</div>
</div>
</fieldset>
</div>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<div class="col-md-12 col-lg-2">
<button type="submit" class="btn btn-block btn-light">查询</button>
</div>
</sec:authorize>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<!-- Start Panel -->
<div class="panel panel-default">
<div class="panel-title">查询结果</div>
<!-- <a href="<%=basePath%>normal/adminContractManageAction!toAdd.action"
class="btn btn-light" style="margin-bottom: 10px"><i
class="fa fa-pencil"></i>新增</a> -->
<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="contractResult.contractItems" status="stat">
<tr>
<!-- <td><a href="<%=basePath%>normal/adminContractManageAction!list.action?para_symbol=<s:property value="symbol" />"><s:property value="name" /></a></td> -->
<td><s:property value="name" /></td>
<td><s:property value="symbol" /></td>
<td><s:property value="symbol_data" /></td>
<td>
<sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_ROOT">
<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">
<!-- <li>
<a href="<%=basePath%>normal/adminContractManageAction!toAdd.action?itemId=<s:property value="id" />"
class="btn btn-light" style="margin-bottom: 10px">修改</a>
</li>-->
<li>
<a href="<%=basePath%>normal/adminContractManageAction!listPara.action?query_symbol=<s:property value="symbol" />"
>交易参数管理</a>
</li>
</ul>
</div>
</sec:authorize>
</td>
</tr>
</s:iterator>
</tbody>
</table>
<nav>
</div>
</div>
<!-- End Panel -->
</div>
</div>
</div>
<!-- END CONTAINER -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<%@ include file="include/footer.jsp"%>
</div>
<!-- End Content -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<%@ include file="include/js.jsp"%>
</body>
<sec:authorize ifAnyGranted="ROLE_ROOT">
<form action="<%=basePath%>normal/adminItemAction!klineInit.action" method="post"
id="init_data">
<s:hidden name="para_init_symbol" id="para_init_symbol"></s:hidden>
</form>
<script type="text/javascript">
function init_data(symbol) {
swal({
title : "是否初始化K线图数据?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
$("#para_init_symbol").val(symbol);
document.getElementById("init_data").submit();
});
}
</script>
</sec:authorize>
</html>

View File

@@ -0,0 +1,52 @@
<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!-- Start Panel -->
<div class="panel panel-default">
<div class="panel-title">合约交易参数</div>
<%-- <a href="javascript:goUrl(<s:property value="pageNo" />)" --%>
<!-- class="btn btn-light" style="margin-bottom: 10px"><i -->
<!-- class="fa fa-mail-reply"></i>返回</a> -->
<a href="<%=basePath%>normal/adminContractManageAction!toAddInstall.action"
class="btn btn-light" style="margin-bottom: 10px"><i
class="fa fa-pencil"></i>新增</a>
<div class="panel-body">
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>代码</td>
<td>时间</td>
<td>交割收益(%</td>
<td>每手金额</td>
<td width="130px"></td>
</tr>
</thead>
<tbody>
<s:iterator value="contractResult.futures.elements" status="stat">
<tr>
<td><s:property value="symbol" /></td>
<td><s:property value="timeNum" />(<s:property value="timeUnitCn" />)</td>
<td><s:property value="profit_ratio" /></td>
<td><s:property value="unit_amount" /></td>
<td>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<a href="<%=basePath%>normal/adminContractManageAction!toAddInstall.action?futuresId=<s:property value="id" />"
class="btn btn-light" style="margin-bottom: 10px">修改</a>
</sec:authorize>
</td>
</tr>
</s:iterator>
</tbody>
</table>
<%@ include file="include/page_simple.jsp"%>
<nav>
</div>
</div>
<!-- End Panel -->

View File

@@ -0,0 +1,178 @@
<%@ 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/adminContractManageAction!listPara.action"
method="post" id="queryForm">
<s:hidden name="pageNo" id="pageNo"></s:hidden>
<s:hidden name="query_symbol" id="query_symbol"></s:hidden>
<s:hidden name="rolename_para" id="rolename_para"></s:hidden>
</form>
<!-- END 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/adminContractManageAction!listPara.action"
method="post" id="queryForm">
<s:hidden name="pageNo" id="pageNo"></s:hidden>
<div class="col-md-12 col-lg-4">
<fieldset>
<div class="control-group">
<div class="controls">
<s:textfield id="query_symbol" name="query_symbol" cssClass="form-control " placeholder="代码"/>
</div>
</div>
</fieldset>
</div>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<div class="col-md-12 col-lg-2">
<button type="submit" class="btn btn-block btn-light">查询</button>
</div>
</sec:authorize>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<!-- Start Panel -->
<div class="panel panel-default">
<div class="panel-title">查询结果</div>
<!-- <a href="javascript:goUrl(<s:property value="pageNo" />)"
class="btn btn-light" style="margin-bottom: 10px"><i
class="fa fa-mail-reply"></i>返回</a> -->
<a href="<%=basePath%>normal/adminContractManageAction!toAddInstall.action?query_symbol=<s:property value="query_symbol" />"
class="btn btn-light" style="margin-bottom: 10px"><i
class="fa fa-pencil"></i>新增</a>
<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>
<td width="130px"></td>
</tr>
</thead>
<tbody>
<s:iterator value="contractResult.futures.elements" status="stat">
<tr>
<!--<td><s:property value="name" /></td> -->
<td><s:property value="symbol" /></td>
<td><s:property value="timeNum" />
(
<s:if test='timeUnit=="second"'>秒</s:if>
<s:if test='timeUnit=="minute"'>分</s:if>
<s:if test='timeUnit=="hour"'>时</s:if>
<s:if test='timeUnit=="day"'>天</s:if>
)
</td>
<td>
<s:property value="profit_ratio" />
~
<s:property value="profit_ratio_max"/>
</td>
<td><s:property value="unit_amount" /></td>
<td><s:property value="unit_fee" /></td>
<td>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<a href="<%=basePath%>normal/adminContractManageAction!toAddInstall.action?futuresId=<s:property value="id" />&query_symbol=<s:property value="query_symbol" />"
class="btn btn-light" style="margin-bottom: 10px">修改</a>
</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>
<sec:authorize ifAnyGranted="ROLE_ROOT">
<form action="<%=basePath%>normal/adminItemAction!klineInit.action" method="post"
id="init_data">
<s:hidden name="para_init_symbol" id="para_init_symbol"></s:hidden>
</form>
<script type="text/javascript">
function init_data(symbol) {
swal({
title : "是否初始化K线图数据?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
$("#para_init_symbol").val(symbol);
document.getElementById("init_data").submit();
});
}
</script>
</sec:authorize>
</html>

View File

@@ -0,0 +1,434 @@
<%@ 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_FUTURES_ORDER_LIST")'>
<form class="form-horizontal"
action="<%=basePath%>normal/adminFuturesOrderAction!holdings_list.action"
method="post" id="queryForm">
<s:hidden name="status_para"></s:hidden>
<input type="hidden" name="pageNo" id="pageNo"
value="${param.pageNo}">
<div class="col-md-12 col-lg-3">
<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-3">
<fieldset>
<div class="control-group">
<div class="controls">
<s:textfield id="name_para" name="name_para" cssClass="form-control " placeholder="用户名、UID"/>
</div>
</div>
</fieldset>
</div>
<div class="col-md-12 col-lg-3" >
<fieldset>
<div class="control-group">
<div class="controls">
<s:select id="rolename_para" cssClass="form-control "
name="rolename_para"
list="#{'MEMBER':'正式账号合约','GUEST':'演示账号合约'}" listKey="key"
listValue="value" headerKey="" headerValue="所有合约"
value="rolename_para" />
</div>
</div>
</fieldset>
</div>
<div class="col-md-12 col-lg-2" >
<a class="btn btn-light btn-block" href="javascript:selectValues()">查询</a>
</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>UID</td>
<td>账户类型</td>
<td>品种</td>
<td>操作</td>
<td>合约时间</td>
<!-- <td>剩余金额</td> -->
<!-- <td>用户钱包余额</td> -->
<td>购买金额</td>
<td>购买价</td>
<td>现价</td>
<td>手续费</td>
<td>盈亏</td>
<td>剩余时间</td>
<td>购买时间</td>
<td>交割时间</td>
<td>状态</td>
<!-- <td width="130px"></td> -->
</tr>
</thead>
<tbody id="pageValue">
<s:iterator value="page.elements" status="stat">
<tr>
<td><s:property value="username" /></td>
<td><s:property value="usercode" /></td>
<td><s:if test='rolename=="GUEST"'>
<span class="right label label-warning">演示账号</span>
</s:if>
<s:if test='rolename=="MEMBER"'>
<span class="right label label-success">正式账号</span>
</s:if>
</td>
<td><s:property value="itemname" /></td>
<td><s:if test='offset=="open"'>开</s:if><s:if test='offset=="close"'>平</s:if><s:if test='direction=="buy"'>多</s:if><s:if
test='direction=="sell"'>空</s:if></td>
<td><s:property value="timenum" /></td>
<td><s:property value="volume" /></td>
<td><s:property value="trade_avg_price" /></td>
<td><s:property value="close_avg_price" /></td>
<td><s:property value="fee" /></td>
<td>
<s:if test='profit>=0'>
<span class="right label label-success"><fmt:formatNumber value="${profit}" pattern="#0.00" /></span>
</s:if>
<s:else>
<span class="right label label-danger"><fmt:formatNumber value="${profit}" pattern="#0.00" /></span>
</s:else>
</td>
<td><s:property value="remain_time" /></td>
<td><s:property value="create_time" /></td>
<td><s:property value="settlement_time" /></td>
<td><s:if test='state=="submitted"'>
持仓
</s:if> <s:if test='state=="created"'>
<span class="right label label-success">已平仓</span>
</s:if>
</td>
<%-- <td><s:property value="username" /></td>
<td><s:property value="itemname" /></td>
<td><s:if test='offset=="open"'>开</s:if><s:if test='offset=="close"'>平</s:if><s:if test='direction=="buy"'>多</s:if><s:if
test='direction=="sell"'>空</s:if></td>
<td><s:property value="trade_avg_price" /></td>
<td><span class="right label label-success"><fmt:formatNumber value="${volume*unit_amount}" pattern="#0.00" /></span></td>
<td><fmt:formatNumber value="${money}" pattern="#0.00" /></td>
<td>
<s:if test='state=="submitted"'>
<s:if test="(amount_close+profit+deposit) >=deposit_open">
<span class="right label label-danger"><fmt:formatNumber
value="${amount_close+profit+deposit-deposit_open}" pattern="#0.00" /> </span>
</s:if>
<s:else>
<span class="right label label-success"><fmt:formatNumber
value="${amount_close+profit+deposit-deposit_open}" pattern="#0.00" /> </span>
</s:else>
</s:if>
<s:else>
<s:if test="(amount_close+deposit) >=deposit_open">
<span class="right label label-danger"><fmt:formatNumber
value="${amount_close+deposit-deposit_open}" pattern="#0.00" /> </span>
</s:if>
<s:else>
<span class="right label label-success"><fmt:formatNumber
value="${amount_close+deposit-deposit_open}" pattern="#0.00" /> </span>
</s:else>
</s:else>
</td>
<td>剩余时间</td>
<td><s:if test='state=="submitted"'>
持仓
</s:if> <s:if test='state=="created"'>
<span class="right label label-success">已平仓</span>
</s:if>
</td>
<td>
<sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_ROOT">
<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">
<li><a
href="javascript:onclose('<s:property value="order_no" />')">平仓</a></li>
</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"%>
<script type="text/javascript">
$.fn.datetimepicker.dates['zh'] = {
days : [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" ],
daysShort : [ "日", "一", "二", "三", "四", "五", "六", "日" ],
daysMin : [ "日", "一", "二", "三", "四", "五", "六", "日" ],
months : [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月",
"十月", "十一月", "十二月" ],
monthsShort : [ "一", "二", "三", "四", "五", "六", "七", "八", "九", "十",
"十一", "十二" ],
meridiem : [ "上午", "下午" ],
//suffix: ["st", "nd", "rd", "th"],
today : "今天",
clear : "清空"
};
</script>
<sec:authorize ifAnyGranted="ROLE_ROOT">
<form action="normal/adminFuturesOrderAction!close.action" method="post"
id="onclose">
<input type="hidden" name="pageNo" id="pageNo" value="${param.pageNo}">
<s:hidden name="order_no" id="order_no"></s:hidden>
<s:hidden name="status_para"></s:hidden>
<s:hidden name="start_time"></s:hidden>
<s:hidden name="end_time"></s:hidden>
<s:hidden name="rolename_para"></s:hidden>
</form>
<script type="text/javascript">
function onclose(order_no) {
$("#order_no").val(order_no);
swal({
title : "是否确认平仓?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
document.getElementById("onclose").submit();
});
}
</script>
</sec:authorize>
<script type="text/javascript">
function setState(){
document.getElementById("status_para").value='submitted';
document.getElementById("queryForm").submit();
}
</script>
<s:if test='isResourceAccessible("ADMIN_FUTURES_ORDER_LIST")'>
<script type="text/javascript">
var rolename_para = $("#rolename_para").val();
var name_para = $("#name_para").val();
/*5轮询读取函数*/
setInterval(function() {
getValue();
}, 3000);
function selectValues(){
rolename_para = $("#rolename_para").val();
name_para= $("#name_para").val();
console.log("rolename_para:"+rolename_para+"-----name_para:"+name_para);
getValue();
}
function getValue(){
//var symbol = $("#adjust_symbol").val();
$.ajax({
type: "get",
url: "<%=basePath%>normal/adminFuturesOrderAction!getValue.action?random="
+ Math.random(),
dataType : "json",
data : {
"rolename_para" : rolename_para,
"name_para" : name_para,
"pageNo" : $("#pageNo").val()
},
success : function(data) {
var temp = $.parseJSON(data);
//console.log(temp[0].id);
var str='';
var direction_name='';
var color_text='';
var state_name='';
var role_name='';
for(var i=0;i<temp.length;i++){
if(temp[i].direction=='buy'){
direction_name='多';
}
if(temp[i].direction=='sell'){
direction_name='空';
}
if(temp[i].state=='submitted'){
state_name='持仓';
}
//盈利计算
if(temp[i].profit >= 0){
color_text='<span class="right label label-success">';
}
if(temp[i].profit < 0){
color_text='<span class="right label label-danger">';
}
//角色
if(temp[i].rolename == 'GUEST'){
role_name = '<span class="right label label-warning">演示账号</span>';
}
if(temp[i].rolename == 'MEMBER'){
role_name = '<span class="right label label-success">正式账号</span>';
}
str += '<tr>'
+'<td>'+temp[i].username+'</td>'
+'<td>'+temp[i].usercode+'</td>'
+'<td>'+role_name+'</td>'
+'<td>'+temp[i].itemname+'</td>'
+'<td>'+direction_name+'</td>'
+'<td>'+temp[i].timenum+'</td>'
+'<td>'+temp[i].volume+'</td>'
+'<td>'+temp[i].trade_avg_price+'</td>'
+'<td>'+temp[i].close_avg_price+'</td>'
+'<td>'+temp[i].fee+'</td>'
+'<td> '+color_text+parseFloat(temp[i].profit).toFixed(2)+'</span></td>'
+'<td>'+temp[i].remain_time+'</td>'
+'<td>'+temp[i].create_time+'</td>'
+'<td>'+temp[i].settlement_time+'</td>'
+'<td>'+state_name+'</td>'
+'</tr>';
/* str += '<tr>'
+'<td>'+temp[i].username+'</td>'
+'<td>'+temp[i].itemname+'</td>'
+'<td>'+direction_name+'</td>'
+'<td>'+temp[i].trade_avg_price+'</td>'
+'<td><span class="right label label-success">'+(temp[i].volume*temp[i].unit_amount).toFixed(2)+'</span></td>'
+'<td>'+temp[i].money.toFixed(2)+'</td>'
+'<td> '+color_text+temp[i].profit.toFixed(2)+'</span></td>'
+'<td>剩余时间</td>'
+'<td>'+state_name+'</td>'
+'<td>'
+' <sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_ROOT">'
+' <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">'
+' <li><a'
+' href="javascript:onclose('+temp[0].order_no+')">平仓</a></li>'
+' </ul>'
+' </div>'
+' </sec:authorize>'
+' </td>'
+'</tr>'; */
}
$("#pageValue").html(str);
},
error : function(XMLHttpRequest, textStatus,
errorThrown) {
console.log("请求错误");
}
});
}
</script>
</s:if>
</body>
</html>

View File

@@ -0,0 +1,323 @@
<%@ 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_FUTURES_ORDER_LIST")'>
<form class="form-horizontal"
action="<%=basePath%>normal/adminFuturesOrderAction!list.action"
method="post" id="queryForm">
<s:hidden name="status_para"></s:hidden>
<input type="hidden" name="pageNo" id="pageNo"
value="${param.pageNo}">
<div class="col-md-12 col-lg-3">
<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-3">
<fieldset>
<div class="control-group">
<div class="controls">
<s:textfield id="name_para" name="name_para" cssClass="form-control " placeholder="用户名、UID"/>
</div>
</div>
</fieldset>
</div>
<div class="col-md-12 col-lg-3" >
<fieldset>
<div class="control-group">
<div class="controls">
<s:select id="rolename_para" cssClass="form-control "
name="rolename_para"
list="#{'MEMBER':'正式账号合约','GUEST':'演示账号合约'}" listKey="key"
listValue="value" headerKey="" headerValue="所有合约"
value="rolename_para" />
</div>
</div>
</fieldset>
</div>
<div class="col-md-12 col-lg-2" >
<button type="submit" class="btn btn-light btn-block">查询</button>
</div>
<div class="col-md-12 col-lg-12" style="margin-top: 10px;">
<div class="mailbox clearfix">
<div class="mailbox-menu">
<ul class="menu">
<li><a href="javascript:setState('')"> 全部</a></li>
<li><a href="javascript:setState('submitted')"> 持仓</a></li>
<li><a href="javascript:setState('created')"> 已平仓</a></li>
</ul>
</div>
</div>
</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>UID</td>
<td>账户类型</td>
<td>品种</td>
<td>操作</td>
<td>合约时间</td>
<!-- <td>剩余金额</td> -->
<!-- <td>用户钱包余额</td> -->
<td>购买金额</td>
<td>购买价</td>
<td>结算价</td>
<td>手续费</td>
<td>盈亏</td>
<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="username" /></td>
<td><s:property value="usercode" /></td>
<td><s:if test='rolename=="GUEST"'>
<span class="right label label-warning">演示账号</span>
</s:if>
<s:if test='rolename=="MEMBER"'>
<span class="right label label-success">正式账号</span>
</s:if>
</td>
<td><s:property value="itemname" /></td>
<td><s:if test='offset=="open"'>开</s:if><s:if test='offset=="close"'>平</s:if><s:if test='direction=="buy"'>多</s:if><s:if
test='direction=="sell"'>空</s:if></td>
<td><s:property value="timenum" /></td>
<td><s:property value="volume" /></td>
<td><s:property value="trade_avg_price" /></td>
<td><s:property value="close_avg_price" /></td>
<td><s:property value="fee" /></td>
<td>
<s:if test='profit>=0'>
<span class="right label label-success"><s:property value="profit" /></span>
</s:if>
<s:else>
<span class="right label label-danger"><s:property value="profit" /></span>
</s:else>
</td>
<td><s:property value="create_time" /></td>
<td><s:property value="settlement_time" /></td>
<%-- <td><span class="right label label-success"><fmt:formatNumber value="${volume*unit_amount}" pattern="#0.00" /></span></td>
<td><fmt:formatNumber value="${money}" pattern="#0.00" /></td>
<td>
<s:if test='state=="submitted"'>
<s:if test="(amount_close+profit+deposit) >=deposit_open">
<span class="right label label-danger"><fmt:formatNumber
value="${amount_close+profit+deposit-deposit_open}" pattern="#0.00" /> </span>
</s:if>
<s:else>
<span class="right label label-success"><fmt:formatNumber
value="${amount_close+profit+deposit-deposit_open}" pattern="#0.00" /> </span>
</s:else>
</s:if>
<s:else>
<s:if test="(amount_close+deposit) >=deposit_open">
<span class="right label label-danger"><fmt:formatNumber
value="${amount_close+deposit-deposit_open}" pattern="#0.00" /> </span>
</s:if>
<s:else>
<span class="right label label-success"><fmt:formatNumber
value="${amount_close+deposit-deposit_open}" pattern="#0.00" /> </span>
</s:else>
</s:else>
</td>
<td>剩余时间</td> --%>
<td><s:if test='state=="submitted"'>
持仓
</s:if> <s:if test='state=="created"'>
<span class="right label label-success">已平仓</span>
</s:if> </td>
<%-- <td>
<sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_ROOT">
<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>
</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"%>
<script type="text/javascript">
$.fn.datetimepicker.dates['zh'] = {
days : [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" ],
daysShort : [ "日", "一", "二", "三", "四", "五", "六", "日" ],
daysMin : [ "日", "一", "二", "三", "四", "五", "六", "日" ],
months : [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月",
"十月", "十一月", "十二月" ],
monthsShort : [ "一", "二", "三", "四", "五", "六", "七", "八", "九", "十",
"十一", "十二" ],
meridiem : [ "上午", "下午" ],
//suffix: ["st", "nd", "rd", "th"],
today : "今天",
clear : "清空"
};
$(function() {
$('#start_time').datetimepicker({
format : 'yyyy-mm-dd',
language : 'zh',
weekStart : 1,
todayBtn : 1,
autoclose : 1,
todayHighlight : 1,
startView : 2,
clearBtn : true,
minView : 2
})
$('#end_time').datetimepicker({
format : 'yyyy-mm-dd',
language : 'zh',
weekStart : 1,
todayBtn : 1,
autoclose : 1,
todayHighlight : 1,
startView : 2,
clearBtn : true,
minView : 2
})
});
</script>
<sec:authorize ifAnyGranted="ROLE_ROOT">
<form action="normal/adminFuturesOrderAction!close.action" method="post"
id="onclose">
<input type="hidden" name="pageNo" id="pageNo" value="${param.pageNo}">
<s:hidden name="order_no" id="order_no"></s:hidden>
<s:hidden name="status_para"></s:hidden>
<s:hidden name="start_time"></s:hidden>
<s:hidden name="end_time"></s:hidden>
<s:hidden name="rolename_para"></s:hidden>
</form>
<script type="text/javascript">
function onclose(order_no) {
$("#order_no").val(order_no);
swal({
title : "是否确认平仓?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
document.getElementById("onclose").submit();
});
}
</script>
</sec:authorize>
<script type="text/javascript">
function setState(state){
document.getElementById("status_para").value=state;
document.getElementById("queryForm").submit();
}
</script>
</body>
</html>

View File

@@ -0,0 +1,139 @@
<%@ 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 -->
<s:if test='isResourceAccessible("ADMIN_PROFIT_LOSS_CONFIG_LIST")'>
<form action="<%=basePath%>normal/adminProfitAndLossConfigAction!list.action"
method="post" id="queryForm">
<s:hidden name="pageNo" id="pageNo"></s:hidden>
<s:hidden name="name_para" id="name_para"></s:hidden>
</form>
</s:if>
<!-- 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">
<s:if test='isResourceAccessible("ADMIN_PROFIT_LOSS_CONFIG_ADD")'>
<form class="form-horizontal"
action="<%=basePath%>normal/adminProfitAndLossConfigAction!add.action"
method="post" name="mainForm" id="mainForm">
<s:hidden name="id" id="id"></s:hidden>
<h5>基础信息</h5>
<div class="form-group">
<label class="col-sm-2 control-label form-label">用户名</label>
<div class="col-sm-5">
<s:textfield id="username" name="username" cssClass="form-control " />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">类型</label>
<div class="col-sm-2">
<s:select id="type" cssClass="form-control "
name="type" list="type_map"
listKey="key" listValue="value" value="value" />
</div>
</div>
<div class="form-group">
<label for="input002" class="col-sm-2 control-label form-label">备注</label>
<div class="col-sm-5">
<s:textarea name="remark" id="remark"
cssClass="form-control input-lg" rows="3" cols="10" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<a href="javascript:goUrl(<s:property value="pageNo" />)"
class="btn">取消</a> <a href="javascript:submit()"
class="btn btn-default">保存</a>
</div>
</div>
</form>
</s:if>
</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_PROFIT_LOSS_CONFIG_ADD")'>
<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>

View File

@@ -0,0 +1,181 @@
<%@ 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>
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- START queryForm -->
<%@ include file="include/alert.jsp"%>
<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_PROFIT_LOSS_CONFIG_LIST")'>
<form class="form-horizontal" action="<%=basePath%>normal/adminProfitAndLossConfigAction!list.action" method="post"
id="queryForm">
<input type="hidden" name="pageNo" id="pageNo"
value="${param.pageNo}">
<div class="col-md-12 col-lg-4">
<fieldset>
<div class="control-group">
<div class="controls">
<s:textfield id="name_para" name="name_para" cssClass="form-control " placeholder="用户名、UID"/>
</div>
</div>
</fieldset>
</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>
<s:if test='isResourceAccessible("ADMIN_PROFIT_LOSS_CONFIG_TOADD")'>
<a href="<%=basePath%>normal/adminProfitAndLossConfigAction!toAdd.action" class="btn btn-light"
style="margin-bottom: 10px"><i class="fa fa-pencil"></i>新增</a>
</s:if>
<div class="panel-body">
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>用户名</td>
<td>UID</td>
<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="username" /></td>
<td><s:property value="usercode" /></td>
<td><s:if test='rolename=="GUEST"'>
<span class="right label label-warning">演示账号</span>
</s:if>
<s:if test='rolename=="MEMBER"'>
<span class="right label label-success">正式账号</span>
</s:if>
</td>
<td><s:property value="type" /></td>
<%-- <td><s:if test='type=="1"'>盈利</s:if>
<s:if test='type=="2"'>亏损</s:if>
<s:if test='type=="3"'>买多盈利</s:if>
<s:if test='type=="4"'>买空盈利</s:if> --%>
</td>
<td><s:property value="remark" /></td>
<td>
<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_PROFIT_LOSS_CONFIG_TOUPDATE")'>
<li><a href="<%=basePath%>normal/adminProfitAndLossConfigAction!toUpdate.action?id=<s:property value="id" />">修改</a></li>
</s:if>
<s:if test='isResourceAccessible("ADMIN_PROFIT_LOSS_CONFIG_TODELETE")'>
<li><a href="<%=basePath%>normal/adminProfitAndLossConfigAction!toDelete.action?id=<s:property value="id" />">删除</a></li>
</s:if>
</ul>
</div>
</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"%>
<script src="<%=basePath%>js/bootstrap/bootstrap-treeview.js"></script>
<script>
$(function () {
var data = <s:property value="result" escape='false' />;
console.log(data);
$("#treeview4").treeview({
color: "#428bca",
enableLinks:true,
nodeIcon: "glyphicon glyphicon-user",
data: data,
levels: 4,
});
});
</script>
<script type="text/javascript">
</script>
</body>
</html>

View File

@@ -0,0 +1,139 @@
<%@ 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 -->
<s:if test='isResourceAccessible("ADMIN_PROFIT_LOSS_CONFIG_LIST")'>
<form action="<%=basePath%>normal/adminProfitAndLossConfigAction!list.action"
method="post" id="queryForm">
<s:hidden name="pageNo" id="pageNo"></s:hidden>
<s:hidden name="name_para" id="name_para"></s:hidden>
</form>
</s:if>
<!-- 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">
<s:if test='isResourceAccessible("ADMIN_PROFIT_LOSS_CONFIG_UPDATE")'>
<form class="form-horizontal"
action="<%=basePath%>normal/adminProfitAndLossConfigAction!update.action"
method="post" name="mainForm" id="mainForm">
<s:hidden name="id" id="id"></s:hidden>
<h5>基础信息</h5>
<div class="form-group">
<label class="col-sm-2 control-label form-label">用户名</label>
<div class="col-sm-5">
<s:textfield id="username" name="username" cssClass="form-control " readonly="true" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">类型</label>
<div class="col-sm-2">
<s:select id="type" cssClass="form-control "
name="type" list="type_map"
listKey="key" listValue="value" value="type" />
</div>
</div>
<div class="form-group">
<label for="input002" class="col-sm-2 control-label form-label">备注</label>
<div class="col-sm-5">
<s:textarea name="remark" id="remark"
cssClass="form-control input-lg" rows="3" cols="10" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<a href="javascript:goUrl(<s:property value="pageNo" />)"
class="btn">取消</a> <a href="javascript:submit()"
class="btn btn-default">保存</a>
</div>
</div>
</form>
</s:if>
</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_PROFIT_LOSS_CONFIG_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>

View File

@@ -0,0 +1,39 @@
<?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="futuresParaService"
class="project.futures.internal.FuturesParaServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="futuresOrderService"
class="project.futures.internal.FuturesOrderServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="walletService" ref="walletService" />
<property name="userDataService" ref="userDataService" />
<property name="itemService" ref="itemService" />
<property name="moneyLogService" ref="moneyLogService" />
<property name="futuresParaService" ref="futuresParaService" />
<property name="partyService" ref="partyService" />
<property name="dataService" ref="dataService" />
<property name="profitAndLossConfigService" ref="profitAndLossConfigService" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="profitAndLossConfigService"
class="project.futures.internal.ProfitAndLossConfigServiceImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
</beans>

View File

@@ -0,0 +1,67 @@
<?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="futuresParaService"
class="project.futures.internal.FuturesParaServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="futuresOrderService"
class="project.futures.internal.FuturesOrderServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="walletService" ref="walletService" />
<property name="userDataService" ref="userDataService" />
<property name="itemService" ref="itemService" />
<property name="moneyLogService" ref="moneyLogService" />
<property name="futuresParaService" ref="futuresParaService" />
<property name="partyService" ref="partyService" />
<property name="dataService" ref="dataService" />
<property name="profitAndLossConfigService" ref="profitAndLossConfigService" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="profitAndLossConfigService"
class="project.futures.internal.ProfitAndLossConfigServiceImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="adminFuturesOrderService"
class="project.futures.internal.AdminFuturesOrderServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="userRecomService" ref="userRecomService" />
<property name="futuresOrderService" ref="futuresOrderService" />
</bean>
<bean id="adminFuturesParaService"
class="project.futures.internal.AdminFuturesParaImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="futuresParaService" ref="futuresParaService" />
</bean>
<bean id="adminContractManageService"
class="project.futures.internal.AdminContractManageServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="adminItemService" ref="adminItemService" />
<property name="adminFuturesParaService" ref="adminFuturesParaService" />
</bean>
<bean id="adminProfitAndLossConfigService"
class="project.futures.internal.AdminProfitAndLossConfigServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
</bean>
</beans>

View File

@@ -0,0 +1,61 @@
<?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="futuresLoadCacheService"
class="data.loadcache.FuturesLoadCacheService">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="futuresParaService"
class="project.futures.internal.FuturesParaServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="futuresOrderService"
class="project.futures.internal.FuturesOrderServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="walletService" ref="walletService" />
<property name="userDataService" ref="userDataService" />
<property name="itemService" ref="itemService" />
<property name="moneyLogService" ref="moneyLogService" />
<property name="futuresParaService" ref="futuresParaService" />
<property name="partyService" ref="partyService" />
<property name="dataService" ref="dataService" />
<property name="profitAndLossConfigService" ref="profitAndLossConfigService" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="profitAndLossConfigService"
class="project.futures.internal.ProfitAndLossConfigServiceImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="futuresOrderCalculationService"
class="project.futures.job.FuturesOrderCalculationServiceImpl">
<property name="futuresOrderService"
ref="futuresOrderService" />
</bean>
<bean id="futuresOrderCalculationJob"
class="project.futures.job.FuturesOrderCalculationJob">
<property name="futuresOrderService"
ref="futuresOrderService" />
<property name="futuresOrderCalculationService"
ref="futuresOrderCalculationService" />
</bean>
</beans>

View File

@@ -0,0 +1,16 @@
admin
<!-- futures -->
<value>futuresParaService</value>
<value>futuresOrderService</value>
<value>profitAndLossConfigService</value>
<value>adminFuturesOrderService</value>
<value>adminFuturesParaService</value>
<value>adminContractManageService</value>
<value>adminProfitAndLossConfigService</value>
api
<!-- futures -->
<value>futuresParaService</value>
<value>futuresOrderService</value>
<value>profitAndLossConfigService</value>

View File

@@ -0,0 +1,30 @@
admin
<action name="adminFuturesOrderAction"
class="project.futures.web.AdminFuturesOrderAction">
<result name="list">/futures_order_list.jsp</result>
<result name="result_make" type="json">
<param name="root">result_make</param>
</result>
<result name="holdings">/futures_holdings_list.jsp</result>
</action>
<action name="adminContractManageAction"
class="project.futures.web.AdminContractManageAction">
<result name="list">/contract_manage_list.jsp</result>
<result name="add">/contract_manage_add.jsp</result>
<result name="toAddInstall">/contract_install_add.jsp</result>
<result name="listPara">/contract_para_list.jsp</result>
</action>
<action name="adminProfitAndLossConfigAction"
class="project.futures.web.AdminProfitAndLossConfigAction">
<result name="list">/profit_loss_config_list.jsp</result>
<result name="add">/profit_loss_config_add.jsp</result>
<result name="update">/profit_loss_config_update.jsp</result>
</action>
api
<action name="futuresorder"
class="project.futures.web.FuturesOrderAction">
</action>

View File

@@ -0,0 +1,62 @@
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `T_FUTURES_PARA`
-- ----------------------------
DROP TABLE IF EXISTS `T_FUTURES_PARA`;
CREATE TABLE `T_FUTURES_PARA` (
`UUID` varchar(32) CHARACTER SET utf8 NOT NULL,
`SYMBOL` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`TIMENUM` int(11) DEFAULT NULL,
`TIMEUNIT` varchar(32) DEFAULT NULL,
`UNIT_AMOUNT` double DEFAULT NULL,
`PROFIT_RATIO` double DEFAULT NULL,
`UNIT_FEE` double DEFAULT NULL,
PRIMARY KEY (`UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `T_FUTURES_ORDER`
-- ----------------------------
DROP TABLE IF EXISTS `T_FUTURES_ORDER`;
CREATE TABLE `T_FUTURES_ORDER` (
`UUID` varchar(32) NOT NULL COMMENT '主键',
`PARTY_ID` varchar(32) DEFAULT NULL,
`SYMBOL` varchar(32) DEFAULT NULL COMMENT '代码',
`ORDER_NO` varchar(64) DEFAULT NULL,
`DIRECTION` varchar(32) DEFAULT NULL,
`TIMENUM` int(11) DEFAULT NULL,
`TIMEUNIT` varchar(64) DEFAULT NULL,
`UNIT_AMOUNT` double DEFAULT NULL,
`VOLUME` double DEFAULT NULL,
`FEE` double DEFAULT NULL,
`PROFIT_RATIO` double DEFAULT NULL,
`PROFIT` double DEFAULT NULL,
`TRADE_AVG_PRICE` double DEFAULT NULL,
`CLOSE_AVG_PRICE` double DEFAULT NULL,
`STATE` varchar(32) DEFAULT NULL,
`CREATE_TIME` datetime DEFAULT NULL,
`CLOSE_TIME` datetime DEFAULT NULL,
`SETTLEMENT_TIME` datetime DEFAULT NULL,
PRIMARY KEY (`UUID`),
KEY `INDEX_ORDER_STATUS` (`STATE`,`CREATE_TIME`),
KEY `INDEX_ORDER_ORDER_NO` (`ORDER_NO`),
KEY `INDEX_ORDER_PARTY_ID` (`PARTY_ID`,`STATE`,`DIRECTION`,`CREATE_TIME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `T_FUTURES_PARA`
ADD COLUMN `PROFIT_RATIO_MAX` double NULL DEFAULT 0;
update T_FUTURES_PARA para set para.PROFIT_RATIO_MAX = para.PROFIT_RATIO
where para.PROFIT_RATIO_MAX = 0

View File

@@ -0,0 +1,47 @@
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `T_FUTURES_PARA`
-- ----------------------------
DROP TABLE IF EXISTS `T_FUTURES_PARA`;
CREATE TABLE `T_FUTURES_PARA` (
`UUID` varchar(32) CHARACTER SET utf8 NOT NULL,
`SYMBOL` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`TIMENUM` int(11) DEFAULT NULL,
`TIMEUNIT` varchar(32) DEFAULT NULL,
`UNIT_AMOUNT` double DEFAULT NULL,
`PROFIT_RATIO` double DEFAULT NULL,
`UNIT_FEE` double DEFAULT NULL,
PRIMARY KEY (`UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `T_FUTURES_ORDER`
-- ----------------------------
DROP TABLE IF EXISTS `T_FUTURES_ORDER`;
CREATE TABLE `T_FUTURES_ORDER` (
`UUID` varchar(32) NOT NULL COMMENT '主键',
`PARTY_ID` varchar(32) DEFAULT NULL,
`SYMBOL` varchar(32) DEFAULT NULL COMMENT '代码',
`ORDER_NO` varchar(64) DEFAULT NULL,
`DIRECTION` varchar(32) DEFAULT NULL,
`TIMENUM` int(11) DEFAULT NULL,
`TIMEUNIT` varchar(64) DEFAULT NULL,
`UNIT_AMOUNT` double DEFAULT NULL,
`VOLUME` double DEFAULT NULL,
`FEE` double DEFAULT NULL,
`PROFIT_RATIO` double DEFAULT NULL,
`PROFIT` double DEFAULT NULL,
`TRADE_AVG_PRICE` double DEFAULT NULL,
`CLOSE_AVG_PRICE` double DEFAULT NULL,
`STATE` varchar(32) DEFAULT NULL,
`CREATE_TIME` datetime DEFAULT NULL,
`CLOSE_TIME` datetime DEFAULT NULL,
`SETTLEMENT_TIME` datetime DEFAULT NULL,
PRIMARY KEY (`UUID`),
KEY `INDEX_ORDER_STATUS` (`STATE`,`CREATE_TIME`),
KEY `INDEX_ORDER_ORDER_NO` (`ORDER_NO`),
KEY `INDEX_ORDER_PARTY_ID` (`PARTY_ID`,`STATE`,`DIRECTION`,`CREATE_TIME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@@ -0,0 +1,34 @@
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50519
Source Host : localhost:3306
Source Database : blockchain
Target Server Type : MYSQL
Target Server Version : 50519
File Encoding : 65001
Date: 2020-07-12 11:20:54
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `t_futures_para`
-- ----------------------------
DROP TABLE IF EXISTS `t_futures_para`;
CREATE TABLE `t_futures_para` (
`UUID` varchar(32) CHARACTER SET utf8 NOT NULL,
`SYMBOL` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`TIMENUM` int(11) DEFAULT NULL,
`TIMEUNIT` varchar(32) DEFAULT NULL,
`UNIT_AMOUNT` double DEFAULT NULL,
`PROFIT_RATIO` double DEFAULT NULL,
`UNIT_FEE` double DEFAULT NULL,
PRIMARY KEY (`UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of t_futures_para
-- ----------------------------

View File

@@ -0,0 +1,29 @@
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50519
Source Host : localhost:3306
Source Database : blockchain
Target Server Type : MYSQL
Target Server Version : 50519
File Encoding : 65001
Date: 2020-07-12 11:20:54
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `T_PROFIT_LOSS_CONFIG`
-- ----------------------------
DROP TABLE IF EXISTS `T_PROFIT_LOSS_CONFIG`;
CREATE TABLE `T_PROFIT_LOSS_CONFIG` (
`UUID` varchar(32) NOT NULL COMMENT '主键',
`PARTY_ID` varchar(32) DEFAULT NULL,
`REMARK` varchar(64) DEFAULT NULL,
`TYPE` varchar(32) DEFAULT NULL,
PRIMARY KEY (`UUID`),
KEY `INDEX_ORDER_PARTY_ID` (`PARTY_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@@ -0,0 +1,19 @@
package project.futures;
import java.util.Map;
import kernel.web.Page;
import project.item.model.Item;
public interface AdminContractManageService {
/**
* 添加合约产品
*/
public String addContractItem(Item entity);
public Map<String,String> getFuturesSymbols();
public String addFutures(FuturesPara entity,String ip,String operaUsername,String loginSafeword);
public void deleteFuturesPara(String id,String ip,String operaUsername,String loginSafeword,String superGoogleAuthCode);
}

View File

@@ -0,0 +1,11 @@
package project.futures;
import kernel.web.Page;
public interface AdminFuturesOrderService {
public Page pagedQuery(int pageNo, int pageSize, String state, String rolename, String loginPartyId,
String username,String orderNo,String symbol,String direction,Double volume);
public FuturesOrder get(String id);
}

View File

@@ -0,0 +1,19 @@
package project.futures;
import java.io.Serializable;
import kernel.web.Page;
public interface AdminFuturesParaService {
public Page pagedQuery(int pageNo, int pageSize,String symbol);
public FuturesPara getById(Serializable id);
public void update(FuturesPara source);
public void add(FuturesPara source);
public void delete(FuturesPara source);
}

View File

@@ -0,0 +1,7 @@
package project.futures;
import kernel.web.Page;
public interface AdminProfitAndLossConfigService {
public Page pagedQuery(int paramInt1, int paramInt2, String paramString,String partyId);
}

View File

@@ -0,0 +1,30 @@
package project.futures;
import java.util.HashSet;
import java.util.Set;
public class FuturesLock {
private static final Set<String> filter = new HashSet<String>();
// private static final Set<String> overFilter = new HashSet<String>();
public static boolean add(String order_no) {
if (!filter.add(order_no)) {
return false;
} else {
return true;
}
}
public static void remove(String order_no) {
filter.remove(order_no);
}
// public static boolean addOver(String order_no) {
// if (!overFilter.add(order_no)) {
// return false;
// } else {
// return true;
// }
// }
}

View File

@@ -0,0 +1,72 @@
<?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.futures.FuturesOrder" table="T_FUTURES_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="symbol" type="java.lang.String">
<column name="SYMBOL" />
</property>
<property name="order_no" type="java.lang.String">
<column name="ORDER_NO" />
</property>
<property name="direction" type="java.lang.String">
<column name="DIRECTION" />
</property>
<property name="timeNum" type="java.lang.Integer">
<column name="TIMENUM" />
</property>
<property name="timeUnit" type="java.lang.String">
<column name="TIMEUNIT" />
</property>
<property name="volume" type="double">
<column name="VOLUME" />
</property>
<property name="fee" type="double">
<column name="FEE" />
</property>
<property name="profit_ratio" type="double">
<column name="PROFIT_RATIO" />
</property>
<property name="profit" type="double">
<column name="PROFIT" />
</property>
<property name="trade_avg_price" type="double">
<column name="TRADE_AVG_PRICE" />
</property>
<property name="close_avg_price" type="double">
<column name="CLOSE_AVG_PRICE" />
</property>
<property name="state" type="java.lang.String">
<column name="STATE" />
</property>
<property name="profit_loss" type="java.lang.String">
<column name="PROFIT_LOSS" />
</property>
<property name="create_time" type="timestamp">
<column name="CREATE_TIME" />
</property>
<property name="close_time" type="timestamp">
<column name="CLOSE_TIME" />
</property>
<property name="settlement_time" type="timestamp">
<column name="SETTLEMENT_TIME" />
</property>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,254 @@
package project.futures;
import java.io.Serializable;
import java.util.Date;
import kernel.bo.EntityObject;
public class FuturesOrder extends EntityObject {
public final static String STATE_SUBMITTED = "submitted";
public final static String STATE_CREATED = "created";
/**
* 多仓
*/
public final static String DIRECTION_BUY = "buy";
/**
* 空仓
*/
public final static String DIRECTION_SELL = "sell";
private static final long serialVersionUID = 8847718625460348172L;
private Serializable partyId;
private String symbol;
/**
* 订单 号
*/
private String order_no;
/**
* "buy":买(多) "sell":卖(空)
*/
private String direction;
/**
* 时间
*/
private int timeNum;
/**
* 时间单位
*
*/
private String timeUnit;
// /**
// * 每手金额
// */
// private double unit_amount;
/**
* 委托数量
*/
private Double volume;
/**
* 手续费
*/
private double fee;
/**
* 收益率
*/
private double profit_ratio;
/**
* 收益
*/
private double profit;
/**
* 成交均价(成本)
*/
private Double trade_avg_price;
/**
* 平仓均价
*/
private Double close_avg_price;
/**
* 状态。submitted 已提交(持仓), created 完成(平仓)
*/
private String state = "submitted";
private Date create_time;
/**
* 平仓时间
*/
private Date close_time;
/**
* 结算时间
*/
private Date settlement_time;
/**
* 剩余时间 h:m:s
*/
private String remain_time;
/**
* 购买时控制场控
*/
private String profit_loss;
public Serializable getPartyId() {
return partyId;
}
public void setPartyId(Serializable partyId) {
this.partyId = partyId;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public String getOrder_no() {
return order_no;
}
public void setOrder_no(String order_no) {
this.order_no = order_no;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public double getFee() {
return fee;
}
public void setFee(double fee) {
this.fee = fee;
}
public double getProfit() {
return profit;
}
public void setProfit(double profit) {
this.profit = profit;
}
public Double getTrade_avg_price() {
return trade_avg_price;
}
public void setTrade_avg_price(Double trade_avg_price) {
this.trade_avg_price = trade_avg_price;
}
public Date getCreate_time() {
return create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
// public double getUnit_amount() {
// return unit_amount;
// }
//
// public void setUnit_amount(double unit_amount) {
// this.unit_amount = unit_amount;
// }
public Double getVolume() {
return volume;
}
public void setVolume(Double volume) {
this.volume = volume;
}
public Double getClose_avg_price() {
return close_avg_price;
}
public void setClose_avg_price(Double close_avg_price) {
this.close_avg_price = close_avg_price;
}
public Date getClose_time() {
return close_time;
}
public void setClose_time(Date close_time) {
this.close_time = close_time;
}
public int getTimeNum() {
return timeNum;
}
public void setTimeNum(int timeNum) {
this.timeNum = timeNum;
}
public String getTimeUnit() {
return timeUnit;
}
public void setTimeUnit(String timeUnit) {
this.timeUnit = timeUnit;
}
public double getProfit_ratio() {
return profit_ratio;
}
public void setProfit_ratio(double profit_ratio) {
this.profit_ratio = profit_ratio;
}
public Date getSettlement_time() {
return settlement_time;
}
public void setSettlement_time(Date settlement_time) {
this.settlement_time = settlement_time;
}
public String getRemain_time() {
return remain_time;
}
public void setRemain_time(String remain_time) {
this.remain_time = remain_time;
}
public String getProfit_loss() {
return profit_loss;
}
public void setProfit_loss(String profit_loss) {
this.profit_loss = profit_loss;
}
}

View File

@@ -0,0 +1,10 @@
package project.futures;
import java.util.Map;
public interface FuturesOrderLocalService {
public FuturesOrder cacheByOrderNo(String order_no);
public Map<String, Object> bulidOne(FuturesOrder order);
}

View File

@@ -0,0 +1,88 @@
package project.futures;
import java.util.List;
import java.util.Map;
import kernel.web.Page;
import project.data.model.Realtime;
public interface FuturesOrderService {
/**
* 开仓
*/
public FuturesOrder saveOpen(FuturesOrder futuresOrder, String para_id);
public void saveClose(FuturesOrder order, Realtime realtime);
public void refreshCache(FuturesOrder order, double close);
/**
*
* @return
*/
public List<FuturesOrder> cacheSubmitted();
public FuturesOrder findByOrderNo(String order_no);
public FuturesOrder cacheByOrderNo(String order_no);
public List<Map<String, Object>> bulidData(List<FuturesOrder> list);
public Map<String, Object> bulidOne(FuturesOrder order);
/**
* APP查询订单列表
*
* @return
*/
public Page getPaged(int pageNo, int pageSize, String partyId, String symbol, String type);
/**
* 今日订单
*
* @param partyId
* @return
*/
public List<FuturesOrder> findByPartyIdAndToday(String partyId);
/**
* 修改订单场控
*
* @param orderNo
* @param porfitOrLoss
*/
public String saveOrderPorfitOrLoss(String orderNo, String porfitOrLoss, String operaName);
/**
* 业绩交易奖励
*
* @param partyId
* @param volume 交易金额
*/
public void saveRecomProfit(String partyId, double volume);
/**
* 异步推送计算推荐奖励
*
* @param futuresOrder
*/
public void pushAsynRecom(FuturesOrder futuresOrder);
/**
* 根据日期获取到当日的购买订单
*
* @param pageNo
* @param pageSize
* @param date
* @return
*/
public Page pagedQueryByDate(int pageNo, int pageSize, String date);
/**
* 根据用户批量赎回订单
*
* @param partyId
*/
public void saveCloseAllByPartyId(String partyId);
}

View 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.futures.FuturesPara" table="T_FUTURES_PARA">
<id name="id" type="java.lang.String">
<column name="UUID" />
<generator class="uuid.hex" />
</id>
<property name="symbol" type="java.lang.String">
<column name="SYMBOL" />
</property>
<property name="timeNum" type="java.lang.Integer">
<column name="TIMENUM" />
</property>
<property name="timeUnit" type="java.lang.String">
<column name="TIMEUNIT" />
</property>
<property name="unit_amount" type="double">
<column name="UNIT_AMOUNT" />
</property>
<property name="profit_ratio" type="double">
<column name="PROFIT_RATIO" />
</property>
<property name="unit_fee" type="double">
<column name="UNIT_FEE" />
</property>
<property name="profit_ratio_max" type="double">
<column name="PROFIT_RATIO_MAX" />
</property>
<property name="unit_max_amount" type="double">
<column name="UNIT_MAX_AMOUNT" />
</property>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,144 @@
package project.futures;
import kernel.bo.EntityObject;
public class FuturesPara extends EntityObject {
private static final long serialVersionUID = 8373415549401215805L;
public final static String TIMENUM_SECOND = "second";
public final static String TIMENUM_MINUTE = "minute";
public final static String TIMENUM_HOUR = "hour";
public final static String TIMENUM_DAY = "day";
public enum TIMENUM {
second(TIMENUM_SECOND, ""), minute(TIMENUM_MINUTE, ""), hour(TIMENUM_HOUR, ""), day(TIMENUM_DAY, "");
private String timenum;
private String cn;
TIMENUM(String timenum, String cn) {
this.timenum = timenum;
this.cn = cn;
}
public String getCn() {
return this.cn;
}
public String getTimenum() {
return timenum;
}
}
private String symbol;
private int timeNum;
/**
* 时间单位
*
*/
private String timeUnit;
/**
* 金额 ,字段命令错误,这里是最低购买金额
*/
private double unit_amount;
/**
* 手续费(%),字段命令错误
*/
private double unit_fee;
/**
* 浮动最小收益率
*/
private double profit_ratio;
/**
* 浮动最大收益率
*/
private double profit_ratio_max;
/**
* 时间单位cn
*
*/
private String timeUnitCn;
/**
* 每手最高价格
*/
private double unit_max_amount;
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public int getTimeNum() {
return timeNum;
}
public void setTimeNum(int timeNum) {
this.timeNum = timeNum;
}
public String getTimeUnit() {
return timeUnit;
}
public void setTimeUnit(String timeUnit) {
this.timeUnit = timeUnit;
}
public double getUnit_amount() {
return unit_amount;
}
public void setUnit_amount(double unit_amount) {
this.unit_amount = unit_amount;
}
public double getProfit_ratio() {
return profit_ratio;
}
public void setProfit_ratio(double profit_ratio) {
this.profit_ratio = profit_ratio;
}
public double getUnit_fee() {
return unit_fee;
}
public void setUnit_fee(double unit_fee) {
this.unit_fee = unit_fee;
}
public String getTimeUnitCn() {
return timeUnitCn;
}
public void setTimeUnitCn(String timeUnitCn) {
this.timeUnitCn = timeUnitCn;
}
public double getProfit_ratio_max() {
return profit_ratio_max;
}
public void setProfit_ratio_max(double profit_ratio_max) {
this.profit_ratio_max = profit_ratio_max;
}
public double getUnit_max_amount() {
return unit_max_amount;
}
public void setUnit_max_amount(double unit_max_amount) {
this.unit_max_amount = unit_max_amount;
}
}

View File

@@ -0,0 +1,22 @@
package project.futures;
import java.util.List;
import java.util.Map;
public interface FuturesParaService {
public FuturesPara cacheGet(String id);
public List<FuturesPara> cacheGetBySymbol(String symbol);
public List<FuturesPara> cacheGetBySymbolSort(String symbol);
public Map<String, Object> bulidOne(FuturesPara order);
public void update(FuturesPara source);
public void add(FuturesPara source);
public void delete(FuturesPara source);
}

View File

@@ -0,0 +1,45 @@
package project.futures;
public class FuturesRedisKeys {
/**
* 交割合约参数id做key
*/
public final static String FUTURES_PARA_ID = "FUTURES_PARA_ID_";
/**
* 交割合约参数,查询 map symbol做key
*/
public final static String FUTURES_PARA_SYMBOL = "FUTURES_PARA_SYMBOL_";
/**
* 交割持仓订单orderno做key
*/
public final static String FUTURES_SUBMITTED_ORDERNO = "FUTURES_SUBMITTED_ORDERNO_";
/**
* 交割持仓单所有
*/
// public final static String FUTURES_SUBMITTED_MAP = "FUTURES_SUBMITTED_MAP_";
/**
* 交割场控partyId做key
*/
public final static String FUTURES_PROFIT_LOSS_PARTY_ID = "FUTURES_PROFIT_LOSS_PARTY_ID_";
/**
* 交割推荐奖励 update队列
*/
public final static String FUTURES_RECOM_QUEUE_UPDATE = "FUTURES_RECOM_QUEUE_UPDATE_";
/**
* 永续合约总资产partyid做key
*/
public final static String FUTURES_ASSETS_PARTY_ID = "FUTURES_ASSETS_PARTY_ID_";
/**
* 永续合约总未实现盈利partyid做key
*/
public final static String FUTURES_ASSETS_PROFIT_PARTY_ID = "FUTURES_ASSETS_PROFIT_PARTY_ID_";
}

View File

@@ -0,0 +1,22 @@
<?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.futures.ProfitAndLossConfig" table="T_PROFIT_LOSS_CONFIG">
<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="type" type="java.lang.String">
<column name="TYPE" />
</property>
<property name="remark" type="java.lang.String">
<column name="REMARK" />
</property>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,64 @@
package project.futures;
import java.io.Serializable;
import kernel.bo.EntityObject;
public class ProfitAndLossConfig extends EntityObject {
/**
*
*/
private static final long serialVersionUID = -1367032133017670721L;
/**
* 盈利
*/
public final static String TYPE_PROFIT = "profit";
public final static String TYPE_LOSS = "loss";
public final static String TYPE_BUY_PROFIT = "buy_profit";
public final static String TYPE_SELL_PROFIT = "sell_profit";
/**
* 买多盈利并且买空亏损
*/
public final static String TYPE_BUY_PROFIT_SELL_LOSS = "buy_profit_sell_loss";
/**
* 买空盈利并且买多亏损
*/
public final static String TYPE_SELL_PROFIT_BUY_LOSS = "sell_profit_buy_loss";
private Serializable partyId;
/**
* 见TYPE_* 1 盈利2亏损3 买多盈利4买空盈利
*/
private String type;
/**
* 备注
*/
private String remark;
public Serializable getPartyId() {
return partyId;
}
public void setPartyId(Serializable partyId) {
this.partyId = partyId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

View File

@@ -0,0 +1,23 @@
package project.futures;
import java.io.Serializable;
public interface ProfitAndLossConfigService {
/**
*
* @param entity
* @param username 操作者
*/
public void save(ProfitAndLossConfig entity, String Operater_username);
public void update(ProfitAndLossConfig entity,String Operater_username);
public void delete(String id,String Operater_username);
public ProfitAndLossConfig findById(String id);
public ProfitAndLossConfig findByPartyId(Serializable partyId);
public ProfitAndLossConfig cacheByPartyId(Serializable partyId);
}

View File

@@ -0,0 +1,65 @@
package project.futures.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.ThreadUtils;
import project.futures.FuturesOrderService;
import project.futures.FuturesRedisKeys;
import project.redis.RedisHandler;
public class FuturesRecomConsumeServer {
private static Log logger = LogFactory.getLog(FuturesRecomConsumeServer.class);
private RedisHandler redisHandler;
private FuturesOrderService futuresOrderService;
ExecutorService FAST_THREAD = Executors.newSingleThreadExecutor();
public void start() {
FAST_THREAD.execute(new Runnable() {
@Override
public void run() {
while (true) {
FuturesRecomMessage item = null;
try {
item = (FuturesRecomMessage) redisHandler.poll(FuturesRedisKeys.FUTURES_RECOM_QUEUE_UPDATE);
if (item != null) {
futuresOrderService.saveRecomProfit(item.getPartyId(), item.getVolume());
//事务提交
ThreadUtils.sleep(3000);
}
} catch (Throwable e) {
logger.error("FuturesRecomConsumeServer FAST_THREAD() fail", e);
} finally {
if (item == null) {//无任务则休息三秒
ThreadUtils.sleep(3000);
}
}
}
}
});
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
public void setFuturesOrderService(FuturesOrderService futuresOrderService) {
this.futuresOrderService = futuresOrderService;
}
}

View File

@@ -0,0 +1,21 @@
package project.futures.consumer;
import java.util.HashSet;
import java.util.Set;
public class FuturesRecomLockFilter {
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);
}
}

View File

@@ -0,0 +1,56 @@
package project.futures.consumer;
import java.util.Date;
public class FuturesRecomMessage {
private String orderNo;
private String partyId;
private double volume;
private Date createTime;
public String getOrderNo() {
return orderNo;
}
public String getPartyId() {
return partyId;
}
public double getVolume() {
return volume;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public void setPartyId(String partyId) {
this.partyId = partyId;
}
public void setVolume(double volume) {
this.volume = volume;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public FuturesRecomMessage(String orderNo, String partyId, double volume,Date createTime) {
this.orderNo = orderNo;
this.partyId = partyId;
this.volume = volume;
this.createTime = createTime;
}
public FuturesRecomMessage() {
}
}

View File

@@ -0,0 +1,123 @@
package project.futures.data.loadcache;
import java.util.HashMap;
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 kernel.util.Arith;
import project.contract.ContractRedisKeys;
import project.futures.FuturesOrder;
import project.futures.FuturesPara;
import project.futures.FuturesRedisKeys;
import project.futures.ProfitAndLossConfig;
import project.mall.task.MallOrdersJob;
import project.redis.RedisHandler;
import project.wallet.AssetService;
public class FuturesLoadCacheService extends HibernateDaoSupport {
//private static final Log logger = LogFactory.getLog(FuturesLoadCacheService.class);
protected static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(FuturesLoadCacheService.class);
private RedisHandler redisHandler;
private AssetService assetService;
public void loadcache() {
load();
logger.info("完成FuturesPara数据加载redis");
loadFuturesOrder();
logger.info("完成FuturesOrder数据加载redis");
loadProfitAndLossConfig();
logger.info("完成ProfitAndLossConfig数据加载redis");
}
public void load() {
StringBuffer queryString = new StringBuffer(" FROM FuturesPara ");
List<FuturesPara> list = (List<FuturesPara>) this.getHibernateTemplate().find(queryString.toString());
Map<String, Map<String, FuturesPara>> cacheMap = new ConcurrentHashMap<String, Map<String, FuturesPara>>();
for (FuturesPara para : list) {
if (cacheMap.containsKey(para.getSymbol())) {
Map<String, FuturesPara> map = cacheMap.get(para.getSymbol());
map.put(para.getId().toString(), para);
cacheMap.put(para.getSymbol(), map);
} else {
Map<String, FuturesPara> map = new ConcurrentHashMap<String, FuturesPara>();
map.put(para.getId().toString(), para);
cacheMap.put(para.getSymbol(), map);
}
redisHandler.setSync(FuturesRedisKeys.FUTURES_PARA_ID + para.getId().toString(), para);
}
for (Entry<String, Map<String, FuturesPara>> entry : cacheMap.entrySet()) {
redisHandler.setSync(FuturesRedisKeys.FUTURES_PARA_SYMBOL + entry.getKey(), entry.getValue());
}
}
public void loadFuturesOrder() {
StringBuffer queryString = new StringBuffer(" FROM FuturesOrder where state=?0 ");
List<FuturesOrder> list = (List<FuturesOrder>) this.getHibernateTemplate().find(queryString.toString(),
new Object[] { FuturesOrder.STATE_SUBMITTED });
// Map<String, FuturesOrder> map = new ConcurrentHashMap<String, FuturesOrder>();
// 交割合约:总资产、总未实现盈利
Map<String, Map<String, Double>> futuresAssetsMap = new ConcurrentHashMap<String, Map<String, Double>>();
for (FuturesOrder order : list) {
redisHandler.setSync(FuturesRedisKeys.FUTURES_SUBMITTED_ORDERNO + order.getOrder_no(), order);
// map.put(order.getOrder_no(), order);
// 获取 单个订单 交割合约总资产、总未实现盈利
Map<String, Double> futuresAssetsOrder = this.assetService.getMoneyFuturesByOrder(order);
if (futuresAssetsMap.containsKey(order.getPartyId())) {
Map<String, Double> futuresAssetsOld = futuresAssetsMap.get(order.getPartyId().toString());
if (null == futuresAssetsOld) {
futuresAssetsOld = new HashMap<String, Double>();
futuresAssetsOld.put("money_futures", 0.000D);
futuresAssetsOld.put("money_futures_profit", 0.000D);
}
futuresAssetsOld.put("money_futures", Arith.add(futuresAssetsOld.get("money_futures"), futuresAssetsOrder.get("money_futures")));
futuresAssetsOld.put("money_futures_profit", Arith.add(futuresAssetsOld.get("money_futures_profit"), futuresAssetsOrder.get("money_futures_profit")));
futuresAssetsMap.put(order.getPartyId().toString(), futuresAssetsOld);
} else {
futuresAssetsMap.put(order.getPartyId().toString(), futuresAssetsOrder);
}
}
// redisHandler.setSync(FuturesRedisKeys.FUTURES_SUBMITTED_MAP, map);
for (Entry<String, Map<String, Double>> entry : futuresAssetsMap.entrySet()) {
this.redisHandler.setSync(FuturesRedisKeys.FUTURES_ASSETS_PARTY_ID + entry.getKey(), entry.getValue().get("money_futures"));
this.redisHandler.setSync(FuturesRedisKeys.FUTURES_ASSETS_PROFIT_PARTY_ID + entry.getKey(), entry.getValue().get("money_futures_profit"));
}
}
public void loadProfitAndLossConfig() {
StringBuffer queryString = new StringBuffer(" FROM ProfitAndLossConfig ");
List<ProfitAndLossConfig> list = (List<ProfitAndLossConfig>) this.getHibernateTemplate().find(queryString.toString());
for (ProfitAndLossConfig config : list) {
redisHandler.setSync(FuturesRedisKeys.FUTURES_PROFIT_LOSS_PARTY_ID + config.getPartyId().toString(),
config);
}
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
public void setAssetService(AssetService assetService) {
this.assetService = assetService;
}
}

View File

@@ -0,0 +1,197 @@
package project.futures.internal;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.security.providers.encoding.PasswordEncoder;
import kernel.exception.BusinessException;
import kernel.util.StringUtils;
import kernel.web.PagedQueryDao;
import project.Constants;
import project.futures.AdminContractManageService;
import project.futures.AdminFuturesParaService;
import project.futures.FuturesPara;
import project.item.AdminItemService;
import project.item.model.Item;
import project.log.LogService;
import project.syspara.SysparaService;
import project.user.googleauth.GoogleAuthService;
import security.SecUser;
import security.internal.SecUserService;
public class AdminContractManageServiceImpl extends HibernateDaoSupport implements AdminContractManageService {
private Logger log = LoggerFactory.getLogger(getClass());
private PagedQueryDao pagedQueryDao;
private JdbcTemplate jdbcTemplate;
private AdminItemService adminItemService;
private AdminFuturesParaService adminFuturesParaService;
private SecUserService secUserService;
private LogService logService;
private PasswordEncoder passwordEncoder;
private SysparaService sysparaService;
protected GoogleAuthService googleAuthService;
public Map<String, String> getFuturesSymbols() {
List<String> list = this.adminItemService.getSymbols();
Map<String,String> result = new HashMap<String,String>();
for(String str:list) {
result.put(str, str);
}
return result;
}
public String addContractItem(Item entity) {
if (entity.getId()!=null&&StringUtils.isNotEmpty(entity.getId().toString())) {
Item item = adminItemService.get(entity.getId().toString());
if (null == item) {
log.info("item is null ,id:{}", entity.getId().toString());
return "合约产品不存在";
}
if (null != entity.getDecimals())
item.setDecimals(entity.getDecimals());
item.setName(entity.getName());
this.adminItemService.update(item);
return "";
}
if (this.adminItemService.checkSymbolExit(entity.getSymbol()))
return "合约代码已经存在";
entity.setMarket(Item.DELIVERY_CONTRACT);// 合约
this.adminItemService.save(entity);
return "";
}
public String addFutures(FuturesPara entity,String ip,String operaUsername,String loginSafeword) {
SecUser sec = this.secUserService.findUserByLoginName(operaUsername);
checkLoginSafeword(sec,operaUsername,loginSafeword);
String logContent = "ip:"+ip;
if (entity.getId()!=null && StringUtils.isNotEmpty(entity.getId().toString())) {
FuturesPara futuresById = this.adminFuturesParaService.getById(entity.getId());
if (null == futuresById) {
log.info("futures is null ,id:{}", entity.getId());
return "合约参数不存在";
}
logContent += MessageFormat.format(",管理员修改交割参数,币种:{0},原时间长度:{1},原时间单位:{2},原最低购买金额:{3},原手续费:{4},原浮动最小收益率:{5},原浮动最大收益率:{6}",
futuresById.getSymbol(),futuresById.getTimeNum(),futuresById.getTimeUnit(),futuresById.getUnit_amount(),futuresById.getUnit_fee(),futuresById.getProfit_ratio(),futuresById.getProfit_ratio_max());
BeanUtils.copyProperties(entity, futuresById);// 是否做用户控制
this.adminFuturesParaService.update(futuresById);
logContent += MessageFormat.format(",新时间长度:{0},新时间单位:{1},新最低购买金额:{2},新手续费:{3},新浮动最小收益率:{4},新浮动最大收益率:{5}",
futuresById.getTimeNum(),futuresById.getTimeUnit(),futuresById.getUnit_amount(),futuresById.getUnit_fee(),futuresById.getProfit_ratio(),futuresById.getProfit_ratio_max());
saveLog(sec,operaUsername,logContent);
return "";
}
logContent += MessageFormat.format(",管理员新增交割参数,币种:{0},时间长度:{1},时间单位:{2},最低购买金额:{3},手续费:{4},浮动最小收益率:{5},浮动最大收益率:{6}",
entity.getSymbol(),entity.getTimeNum(),entity.getTimeUnit(),entity.getUnit_amount(),entity.getUnit_fee(),entity.getProfit_ratio(),entity.getProfit_ratio_max());
this.adminFuturesParaService.add(entity);
saveLog(sec,operaUsername,logContent);
return "";
}
public void deleteFuturesPara(String id,String ip,String operaUsername,String loginSafeword,String superGoogleAuthCode) {
checkGoogleAuthCode(superGoogleAuthCode);
SecUser sec = this.secUserService.findUserByLoginName(operaUsername);
checkLoginSafeword(sec,operaUsername,loginSafeword);
FuturesPara entity = this.adminFuturesParaService.getById(id);
if(null == entity ) {
throw new BusinessException("交易参数不存在");
}
String logContent = "ip:"+ip;
logContent += MessageFormat.format(",管理员删除交割参数,币种:{0},时间长度:{1},时间单位:{2},最低购买金额:{3},手续费:{4},浮动最小收益率:{5},浮动最大收益率:{6}",
entity.getSymbol(),entity.getTimeNum(),entity.getTimeUnit(),entity.getUnit_amount(),entity.getUnit_fee(),entity.getProfit_ratio(),entity.getProfit_ratio_max());
this.adminFuturesParaService.delete(entity);
saveLog(sec,operaUsername,logContent);
}
/**
* 验证谷歌验证码
* @param code
*/
private void checkGoogleAuthCode(String code) {
String secret = sysparaService.find("super_google_auth_secret").getValue();
boolean checkCode = googleAuthService.checkCode(secret, code);
if(!checkCode) {
throw new BusinessException("谷歌验证码错误");
}
}
/**
* 验证登录人资金密码
* @param operatorUsername
* @param loginSafeword
*/
protected void checkLoginSafeword(SecUser secUser,String operatorUsername,String loginSafeword) {
// SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
String sysSafeword = secUser.getSafeword();
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
if (!safeword_md5.equals(sysSafeword)) {
throw new BusinessException("登录人资金密码错误");
}
}
public void saveLog(SecUser secUser, String operator,String context) {
project.log.Log log = new project.log.Log();
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
log.setOperator(operator);
log.setUsername(secUser.getUsername());
log.setPartyId(secUser.getPartyId());
log.setLog(context);
log.setCreateTime(new Date());
logService.saveSync(log);
}
public PagedQueryDao getPagedQueryDao() {
return pagedQueryDao;
}
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
this.pagedQueryDao = pagedQueryDao;
}
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplate;
}
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
public AdminItemService getAdminItemService() {
return adminItemService;
}
public void setAdminItemService(AdminItemService adminItemService) {
this.adminItemService = adminItemService;
}
public void setAdminFuturesParaService(AdminFuturesParaService adminFuturesParaService) {
this.adminFuturesParaService = adminFuturesParaService;
}
public void setSecUserService(SecUserService secUserService) {
this.secUserService = secUserService;
}
public void setLogService(LogService logService) {
this.logService = logService;
}
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
public void setSysparaService(SysparaService sysparaService) {
this.sysparaService = sysparaService;
}
public void setGoogleAuthService(GoogleAuthService googleAuthService) {
this.googleAuthService = googleAuthService;
}
}

View File

@@ -0,0 +1,136 @@
package project.futures.internal;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import kernel.util.StringUtils;
import kernel.web.Page;
import kernel.web.PagedQueryDao;
import project.futures.AdminFuturesOrderService;
import project.futures.FuturesOrder;
import project.futures.FuturesOrderService;
import project.futures.FuturesPara;
import project.party.recom.UserRecomService;
public class AdminFuturesOrderServiceImpl extends HibernateDaoSupport implements AdminFuturesOrderService {
private PagedQueryDao pagedQueryDao;
private UserRecomService userRecomService;
private FuturesOrderService futuresOrderService;
public Page pagedQuery(int pageNo, int pageSize, String status, String rolename, String loginPartyId,
String username,String orderNo,String symbol,String direction,Double volume) {
StringBuffer queryString = new StringBuffer("SELECT party.USERCODE usercode,party.ROLENAME rolename,orders.UUID id,orders.SYMBOL symbol,"
+ "orders.ORDER_NO order_no,orders.TRADE_AVG_PRICE trade_avg_price,orders.DIRECTION direction,orders.PROFIT_LOSS profit_loss,"
+ "orders.UNIT_AMOUNT unit_amount,orders.STATE state,FORMAT(orders.FEE,1) fee," + "orders.PROFIT profit,"
+ "FORMAT(orders.VOLUME,1) volume,item.NAME itemname,orders.TIMENUM timenum,orders.TIMEUNIT timeunit,"
+ "orders.CLOSE_AVG_PRICE close_avg_price,DATE_FORMAT(orders.CREATE_TIME,'%Y-%m-%d %H:%i:%s') create_time,DATE_FORMAT(orders.SETTLEMENT_TIME,'%Y-%m-%d %H:%i:%s') settlement_time,");
// queryString.append(" wallet.MONEY money, ");
queryString.append(" party.USERNAME username ");
queryString.append(
" FROM T_FUTURES_ORDER orders LEFT JOIN PAT_PARTY party ON orders.PARTY_ID = party.UUID "
// + "LEFT JOIN T_WALLET wallet ON wallet.PARTY_ID = party.UUID "
+ "LEFT JOIN T_ITEM item ON orders.SYMBOL=item.SYMBOL WHERE 1 = 1 ");
Map parameters = new HashMap();
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
List children = this.userRecomService.findChildren(loginPartyId);
if (children.size() == 0) {
return Page.EMPTY_PAGE;
}
queryString.append(" and orders.PARTY_ID in (:children) ");
parameters.put("children", children);
}
if (!StringUtils.isNullOrEmpty(symbol)) {
queryString.append(" and orders.SYMBOL = :symbol ");
parameters.put("symbol", symbol);
}
if (!StringUtils.isNullOrEmpty(direction)) {
queryString.append(" and orders.DIRECTION = :direction ");
parameters.put("direction", direction);
}
if (volume!=null&&volume>0d) {
queryString.append(" and orders.VOLUME = :volume ");
parameters.put("volume", volume);
}
if (!StringUtils.isNullOrEmpty(status)) {
queryString.append(" and orders.STATE = :status ");
parameters.put("status", status);
}
if (!StringUtils.isNullOrEmpty(rolename)) {
queryString.append(" and party.ROLENAME = :rolename ");
parameters.put("rolename", rolename);
}
// if (!StringUtils.isNullOrEmpty(username)) {
// queryString.append(" and party.username like:username ");
// parameters.put("username", "%"+username+"%");
//
// }
if (!StringUtils.isNullOrEmpty(orderNo)) {
queryString.append(" and orders.ORDER_NO = :orderNo ");
parameters.put("orderNo", orderNo);
}
if (!StringUtils.isNullOrEmpty(username)) {
queryString.append("AND (party.USERNAME like:username OR party.USERCODE like:username ) ");
parameters.put("username","%"+username+"%");
}
queryString.append(" order by orders.CREATE_TIME desc ");
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
//预留对持仓单的处理
handleDatas((List<Map<String,Object>>)page.getElements());
return page;
}
private void handleDatas(List<Map<String,Object>> datas) {
List<FuturesOrder> list = futuresOrderService.cacheSubmitted();
Map<String,FuturesOrder> maps = new HashMap<String,FuturesOrder>();
for(FuturesOrder order:list) {
maps.put(order.getOrder_no(), order);
}
for(Map<String,Object> data:datas) {
String timeUnitCn = FuturesPara.TIMENUM.valueOf(data.get("timeunit").toString()).getCn();
FuturesOrder order = maps.get(data.get("order_no").toString());
if(null!=order) {
data.put("close_avg_price", new BigDecimal(order.getClose_avg_price().toString()).toPlainString());
data.put("profit", new BigDecimal(new Double(order.getProfit()).toString()).toPlainString());
data.put("remain_time", order.getRemain_time());
data.put("profit_loss", order.getProfit_loss());
}else {
data.put("close_avg_price", new BigDecimal(data.get("close_avg_price").toString()).toPlainString());
data.put("profit", new BigDecimal(data.get("profit").toString()).toPlainString());
data.put("remain_time", "0:0:0");
}
data.put("timenum", data.get("timenum").toString()+timeUnitCn);
data.put("trade_avg_price", new BigDecimal(data.get("trade_avg_price").toString()).toPlainString());
}
}
public FuturesOrder get(String id) {
return getHibernateTemplate().get(FuturesOrder.class, id);
}
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
this.pagedQueryDao = pagedQueryDao;
}
public void setUserRecomService(UserRecomService userRecomService) {
this.userRecomService = userRecomService;
}
public void setFuturesOrderService(FuturesOrderService futuresOrderService) {
this.futuresOrderService = futuresOrderService;
}
}

View File

@@ -0,0 +1,87 @@
package project.futures.internal;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import kernel.util.Arith;
import kernel.util.StringUtils;
import kernel.web.Page;
import kernel.web.PagedQueryDao;
import project.futures.AdminFuturesParaService;
import project.futures.FuturesPara;
import project.futures.FuturesParaService;
public class AdminFuturesParaImpl extends HibernateDaoSupport implements AdminFuturesParaService{
private FuturesParaService futuresParaService;
private PagedQueryDao pagedQueryDao;
public Page pagedQuery(int pageNo, int pageSize,String symbol) {
StringBuffer queryString = new StringBuffer(
"SELECT futures.UUID id,"
//+ "item.NAME name,"
+ "futures.SYMBOL symbol,"
+ "futures.TIMENUM timeNum,"
+ "futures.TIMEUNIT timeUnit,futures.UNIT_AMOUNT unit_amount,futures.UNIT_MAX_AMOUNT unit_max_amount,"
+ "futures.UNIT_FEE unit_fee,"
+ "futures.PROFIT_RATIO profit_ratio,futures.PROFIT_RATIO_MAX profit_ratio_max ");
queryString.append(
" FROM T_FUTURES_PARA futures "
//+ "LEFT JOIN T_ITEM item ON "
//+ " item.symbol = futures.symbol "
+ " WHERE 1 = 1 ");
Map<String, Object> parameters = new HashMap();
if (!StringUtils.isNullOrEmpty(symbol)) {
queryString.append(" and "
//+ "( "
+ "futures.SYMBOL = :symbol "
//+ "or item.NAME = :name)"
+ " ");
parameters.put("symbol", symbol);
//parameters.put("name", symbol);
}
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
for(Map<String,Object> map:(List<Map<String,Object>>)page.getElements()) {
map.put("profit_ratio", Arith.mul(new Double(map.get("profit_ratio").toString()),100));
map.put("profit_ratio_max", Arith.mul(new Double(map.get("profit_ratio_max").toString()),100));
map.put("unit_fee", Arith.mul(new Double(map.get("unit_fee").toString()),100));
}
return page;
}
public FuturesPara getById(Serializable id) {
return this.getHibernateTemplate().get(FuturesPara.class, id);
}
public void update(FuturesPara source) {
this.futuresParaService.update(source);
}
public void add(FuturesPara source) {
this.futuresParaService.add(source);
}
public void delete(FuturesPara source) {
this.futuresParaService.delete(source);
}
public void setFuturesParaService(FuturesParaService futuresParaService) {
this.futuresParaService = futuresParaService;
}
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
this.pagedQueryDao = pagedQueryDao;
}
}

View File

@@ -0,0 +1,54 @@
package project.futures.internal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import kernel.util.StringUtils;
import kernel.web.Page;
import kernel.web.PagedQueryDao;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import project.futures.AdminProfitAndLossConfigService;
import project.party.recom.UserRecomService;
public class AdminProfitAndLossConfigServiceImpl extends HibernateDaoSupport implements AdminProfitAndLossConfigService {
private PagedQueryDao pagedQueryDao;
protected UserRecomService userRecomService;
public Page pagedQuery(int pageNo, int pageSize, String name_para,String partyId) {
StringBuffer queryString = new StringBuffer(
"SELECT profit_loss.UUID id,party.USERNAME username,party.USERCODE usercode,party.ROLENAME rolename,profit_loss.REMARK remark,profit_loss.TYPE type ");
queryString.append(
" FROM T_PROFIT_LOSS_CONFIG profit_loss LEFT JOIN PAT_PARTY party ON profit_loss.PARTY_ID = party.UUID WHERE 1 = 1 ");
Map<String, Object> parameters = new HashMap<>();
// if (!StringUtils.isNullOrEmpty(name_para)) {
// queryString.append(" and party.USERNAME like:username ");
// parameters.put("username", "%"+name_para+"%");
// }
if (!StringUtils.isNullOrEmpty(partyId)) {
List children = this.userRecomService.findChildren(partyId);
if (children.size() == 0) {
return Page.EMPTY_PAGE;
}
queryString.append(" and profit_loss.PARTY_ID in (:children) ");
parameters.put("children", children);
}
if (!StringUtils.isNullOrEmpty(name_para)) {
queryString.append("AND (party.USERNAME like:username OR party.USERCODE like:username ) ");
parameters.put("username","%"+name_para+"%");
}
queryString.append(" order by party.CREATE_TIME desc ");
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
return page;
}
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
this.pagedQueryDao = pagedQueryDao;
}
public void setUserRecomService(UserRecomService userRecomService) {
this.userRecomService = userRecomService;
}
}

View File

@@ -0,0 +1,139 @@
package project.futures.internal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import kernel.exception.BusinessException;
import kernel.util.Arith;
import kernel.util.DateUtils;
import kernel.util.StringUtils;
import project.futures.FuturesOrder;
import project.futures.FuturesOrderLocalService;
import project.futures.FuturesPara;
import project.futures.FuturesParaService;
import project.futures.FuturesRedisKeys;
import project.item.ItemService;
import project.item.model.Item;
import project.redis.RedisHandler;
public class FuturesOrderLocalServiceImpl extends HibernateDaoSupport implements FuturesOrderLocalService {
protected ItemService itemService;
protected RedisHandler redisHandler;
protected FuturesParaService futuresParaService;
public FuturesOrder cacheByOrderNo(String order_no) {
FuturesOrder futuresOrder = (FuturesOrder) redisHandler
.get(FuturesRedisKeys.FUTURES_SUBMITTED_ORDERNO + order_no);
// FuturesOrder futuresOrder = cache.get(order_no);
if (null == futuresOrder) {
futuresOrder = findByOrderNo(order_no);
}
return futuresOrder;
}
public FuturesOrder findByOrderNo(String order_no) {
StringBuffer queryString = new StringBuffer(" FROM FuturesOrder where order_no=?0");
List<FuturesOrder> list = (List<FuturesOrder>) getHibernateTemplate().find(queryString.toString(), new Object[] { order_no });
if (list.size() > 0) {
return list.get(0);
}
return null;
}
public Map<String, Object> bulidOne(FuturesOrder order) {
// FuturesOrder order_cache = cache.get(order.getOrder_no());
FuturesOrder order_cache = (FuturesOrder) redisHandler
.get(FuturesRedisKeys.FUTURES_SUBMITTED_ORDERNO + order.getOrder_no());
if (order_cache != null) {
order = order_cache;
}
List<FuturesPara> paras = futuresParaService.cacheGetBySymbol(order.getSymbol());
double ratio_min = 0D;
double ratio_max = 0D;
for (int i = 0; i < paras.size(); i++) {
if (paras.get(i).getTimeUnit().equals(order.getTimeUnit())
&& paras.get(i).getTimeNum() == order.getTimeNum()) {
ratio_min = paras.get(i).getProfit_ratio();
ratio_max = paras.get(i).getProfit_ratio_max();
}
}
Item item = this.itemService.cacheBySymbol(order.getSymbol(), false);
if (item == null) {
throw new BusinessException("参数错误");
}
String decimals = "#.";
for (int i = 0; i < item.getDecimals(); i++) {
decimals = decimals + "#";
}
if (item.getDecimals() == 0) {
decimals = "#";
}
DecimalFormat df_symbol = new DecimalFormat(decimals);
df_symbol.setRoundingMode(RoundingMode.FLOOR);// 向下取整
DecimalFormat df = new DecimalFormat("#.##");
Map<String, Object> map = new HashMap<String, Object>();
map.put("order_no", order.getOrder_no());
map.put("name", item.getName());
map.put("symbol", order.getSymbol());
map.put("open_time", DateUtils.format(order.getCreate_time(), DateUtils.DF_yyyyMMddHHmmss));
if (order.getClose_time() != null) {
map.put("close_time", DateUtils.format(order.getClose_time(), DateUtils.DF_yyyyMMddHHmmss));
} else {
map.put("close_time", "--");
}
map.put("direction", order.getDirection());
map.put("open_price", df_symbol.format(order.getTrade_avg_price()));
map.put("state", order.getState());
map.put("amount", order.getVolume());
map.put("fee", order.getFee());
/**
* 收益
*/
if (order.getProfit() > 0) {
// if ("submitted".equals(order.getState())) {
// map.put("profit", df.format(Arith.mul(order.getVolume(), ratio_min)) + " " + "~ "
// + df.format(Arith.mul(order.getVolume(), ratio_max)));
// } else {
map.put("profit", df.format(order.getProfit()));
// }
map.put("profit_state", "1");
} else {
map.put("profit", df.format(order.getProfit()));
map.put("profit_state", "0");
}
map.put("volume", order.getVolume());
map.put("settlement_time", DateUtils.format(order.getSettlement_time(), DateUtils.DF_yyyyMMddHHmmss));// 交割时间
map.put("close_price", df_symbol.format(order.getClose_avg_price()));
map.put("remain_time", StringUtils.isEmptyString(order.getRemain_time()) ? "0:0:0" : order.getRemain_time());
map.put("time_num", order.getTimeNum());
map.put("time_unit", order.getTimeUnit().substring(0, 1));
return map;
}
public void setItemService(ItemService itemService) {
this.itemService = itemService;
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
public void setFuturesParaService(FuturesParaService futuresParaService) {
this.futuresParaService = futuresParaService;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,148 @@
package project.futures.internal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import kernel.util.Arith;
import kernel.util.DateUtils;
import project.futures.FuturesPara;
import project.futures.FuturesParaService;
import project.futures.FuturesRedisKeys;
import project.redis.RedisHandler;
public class FuturesParaServiceImpl extends HibernateDaoSupport implements FuturesParaService {
private static final Log logger = LogFactory.getLog(FuturesParaServiceImpl.class);
private RedisHandler redisHandler;
@Override
public FuturesPara cacheGet(String id) {
// TODO Auto-generated method stub
return (FuturesPara) redisHandler.get(FuturesRedisKeys.FUTURES_PARA_ID + id);
}
public List<FuturesPara> cacheGetBySymbolSort(String symbol) {
return sortPara(cacheGetBySymbol(symbol));
}
public List<FuturesPara> cacheGetBySymbol(String symbol) {
Map<String, FuturesPara> map = (Map<String, FuturesPara>) redisHandler
.get(FuturesRedisKeys.FUTURES_PARA_SYMBOL + symbol);
if (map != null && !map.isEmpty()) {
return new ArrayList<FuturesPara>(map.values());
}
return new ArrayList<FuturesPara>();
}
private List<FuturesPara> sortPara(List<FuturesPara> list) {
if (CollectionUtils.isEmpty(list))
return list;
// 列表按 smhd 排序
String[] regulation = { FuturesPara.TIMENUM_SECOND, FuturesPara.TIMENUM_MINUTE, FuturesPara.TIMENUM_HOUR,
FuturesPara.TIMENUM_DAY };
final List<String> regulationOrder = Arrays.asList(regulation);
Collections.sort(list, new Comparator<FuturesPara>() {
@Override
public int compare(FuturesPara o1, FuturesPara o2) {
// TODO Auto-generated method stub
int unitSort = regulationOrder.indexOf(o1.getTimeUnit()) - regulationOrder.indexOf(o2.getTimeUnit());
int timeSort = o1.getTimeNum() - o2.getTimeNum();
return unitSort == 0 ? timeSort : unitSort;
}
});
return list;
}
public void add(FuturesPara source) {
if (null == source) {
logger.error("null error,futurepara add fail ");
return;
}
source.setId(this.getHibernateTemplate().save(source));
redisHandler.setSync(FuturesRedisKeys.FUTURES_PARA_ID + source.getId().toString(), source);
Map<String, FuturesPara> map = (Map<String, FuturesPara>) redisHandler
.get(FuturesRedisKeys.FUTURES_PARA_SYMBOL + source.getSymbol());
if (map == null) {
map = new ConcurrentHashMap<String, FuturesPara>();
}
map.put(source.getId().toString(), source);
redisHandler.setSync(FuturesRedisKeys.FUTURES_PARA_SYMBOL + source.getSymbol(), map);
}
public Map<String, Object> bulidOne(FuturesPara para) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("para_id", para.getId().toString());
map.put("symbol", para.getSymbol());
map.put("time_num", para.getTimeNum());
map.put("time_unit", para.getTimeUnit());
map.put("entityVersion", para.getEntityVersion());
map.put("timeUnitCn", para.getTimeUnitCn());
map.put("timestamp", para.getTimestamp());
map.put("now_time", DateUtils.format(new Date(),DateUtils.NORMAL_DATE_FORMAT));
DecimalFormat df = new DecimalFormat("#");
// TMX start voaex
// map.put("profit_ratio", df.format(Arith.mul(para.getProfit_ratio(), 100)));
// TMX end
// if(para.getProfit_ratio() != para.getProfit_ratio_max()) {
map.put("profit_ratio", df.format(Arith.mul(para.getProfit_ratio(), 100)) + "~"
+ df.format(Arith.mul(para.getProfit_ratio_max(), 100)));
// }
map.put("buy_min", para.getUnit_amount());
map.put("unit_fee", para.getUnit_fee());
map.put("buy_max", para.getUnit_max_amount() <= 0 ? null : para.getUnit_max_amount());
return map;
}
public void update(FuturesPara source) {
this.getHibernateTemplate().update(source);
redisHandler.setSync(FuturesRedisKeys.FUTURES_PARA_ID + source.getId().toString(), source);
Map<String, FuturesPara> map = (Map<String, FuturesPara>) redisHandler
.get(FuturesRedisKeys.FUTURES_PARA_SYMBOL + source.getSymbol());
if (map == null) {
map = new ConcurrentHashMap<String, FuturesPara>();
}
map.put(source.getId().toString(), source);
redisHandler.setSync(FuturesRedisKeys.FUTURES_PARA_SYMBOL + source.getSymbol(), map);
}
public void delete(FuturesPara source) {
String id = source.getId().toString();
String symbol = source.getSymbol();
this.getHibernateTemplate().delete(source);
redisHandler.remove(FuturesRedisKeys.FUTURES_PARA_ID + id);
Map<String, FuturesPara> map = (Map<String, FuturesPara>) redisHandler
.get(FuturesRedisKeys.FUTURES_PARA_SYMBOL + symbol);
if (map != null && !map.isEmpty()) {
map.remove(id);
}
redisHandler.setSync(FuturesRedisKeys.FUTURES_PARA_SYMBOL + symbol, map);
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
}

View File

@@ -0,0 +1,161 @@
package project.futures.internal;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import project.Constants;
import project.futures.FuturesRedisKeys;
import project.futures.ProfitAndLossConfig;
import project.futures.ProfitAndLossConfigService;
import project.log.Log;
import project.log.LogService;
import project.party.PartyService;
import project.party.model.Party;
import project.redis.RedisHandler;
public class ProfitAndLossConfigServiceImpl extends HibernateDaoSupport implements ProfitAndLossConfigService {
private RedisHandler redisHandler;
private LogService logService;
private PartyService partyService;
public void save(ProfitAndLossConfig entity, String Operater_username) {
ProfitAndLossConfig profitAndLossConfig = this.findByPartyId(entity.getPartyId());
// 如果存在则更新
if (profitAndLossConfig != null) {
profitAndLossConfig.setRemark(entity.getRemark());
profitAndLossConfig.setType(entity.getType());
getHibernateTemplate().update(profitAndLossConfig);
redisHandler.setSync(
FuturesRedisKeys.FUTURES_PROFIT_LOSS_PARTY_ID + profitAndLossConfig.getPartyId().toString(),
profitAndLossConfig);
} else {
this.getHibernateTemplate().save(entity);
redisHandler.setSync(
FuturesRedisKeys.FUTURES_PROFIT_LOSS_PARTY_ID + entity.getPartyId().toString(),
entity);
}
String type = "";
if("profit".equals(entity.getType())) {
type = "盈利";
}
if("loss".equals(entity.getType())) {
type = "亏损";
}
if("buy_profit".equals(entity.getType())) {
type = "买多盈利";
}
if("sell_profit".equals(entity.getType())) {
type = "买空盈利";
}
if("buy_profit_sell_loss".equals(entity.getType())) {
type = "买多盈利并且买空亏损";
}
if("sell_profit_buy_loss".equals(entity.getType())) {
type = "买空盈利并且买多亏损";
}
Party party = this.partyService.cachePartyBy(entity.getPartyId(), true);
Log log = new Log();
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
log.setOperator(Operater_username);
log.setUsername(party.getUsername());
log.setPartyId(entity.getPartyId());
log.setCreateTime(new Date());
log.setLog("管理员手动添加场控交割状态。操作类型[" + type + "]。");
this.logService.saveSync(log);
}
public void update(ProfitAndLossConfig entity,String Operater_username) {
getHibernateTemplate().update(entity);
redisHandler.setSync(FuturesRedisKeys.FUTURES_PROFIT_LOSS_PARTY_ID + entity.getPartyId().toString(), entity);
String type = "";
if("profit".equals(entity.getType())) {
type = "盈利";
}
if("loss".equals(entity.getType())) {
type = "亏损";
}
if("buy_profit".equals(entity.getType())) {
type = "买多盈利";
}
if("sell_profit".equals(entity.getType())) {
type = "买空盈利";
}
if("buy_profit_sell_loss".equals(entity.getType())) {
type = "买多盈利并且买空亏损";
}
if("sell_profit_buy_loss".equals(entity.getType())) {
type = "买空盈利并且买多亏损";
}
Party party = this.partyService.cachePartyBy(entity.getPartyId(), true);
Log log = new Log();
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
log.setOperator(Operater_username);
log.setUsername(party.getUsername());
log.setPartyId(entity.getPartyId());
log.setCreateTime(new Date());
log.setLog("管理员手动修改场控交割状态。修改后操作类型为[" + type + "]。");
this.logService.saveSync(log);
}
public void delete(String id,String Operater_username) {
ProfitAndLossConfig entity = findById(id);
getHibernateTemplate().delete(entity);
redisHandler.remove(FuturesRedisKeys.FUTURES_PROFIT_LOSS_PARTY_ID + entity.getPartyId().toString());
Party party = this.partyService.cachePartyBy(entity.getPartyId(), true);
Log log = new Log();
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
log.setOperator(Operater_username);
log.setUsername(party.getUsername());
log.setPartyId(entity.getPartyId());
log.setCreateTime(new Date());
log.setLog("管理员手动删除场控交割状态");
this.logService.saveSync(log);
}
public ProfitAndLossConfig findById(String id) {
return (ProfitAndLossConfig) getHibernateTemplate().get(ProfitAndLossConfig.class, id);
}
public ProfitAndLossConfig findByPartyId(Serializable partyId) {
List<ProfitAndLossConfig> list = (List<ProfitAndLossConfig>) getHibernateTemplate().find(" FROM ProfitAndLossConfig WHERE partyId = ?0",
new Object[] { partyId });
if (list.size() > 0)
return list.get(0);
return null;
}
public ProfitAndLossConfig cacheByPartyId(Serializable partyId) {
return (ProfitAndLossConfig) redisHandler
.get(FuturesRedisKeys.FUTURES_PROFIT_LOSS_PARTY_ID + partyId.toString());
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
public void setLogService(LogService logService) {
this.logService = logService;
}
public void setPartyService(PartyService partyService) {
this.partyService = partyService;
}
}

View File

@@ -0,0 +1,118 @@
package project.futures.job;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import kernel.util.ThreadUtils;
//import project.exchange.ExchangeLock;
import project.futures.FuturesLock;
import project.futures.FuturesOrder;
import project.futures.FuturesOrderService;
import project.syspara.SysparaService;
public class FuturesOrderCalculationJob implements Runnable {
private static Log logger = LogFactory.getLog(FuturesOrderCalculationJob.class);
private FuturesOrderService futuresOrderService;
private FuturesOrderCalculationService futuresOrderCalculationService;
private SysparaService sysparaService;
public void run() {
try {
while (true) {
try {
List<FuturesOrder> list = this.futuresOrderService.cacheSubmitted();
//每单处理的时间间隔(毫秒)
int futures_cal_time = sysparaService.find("futures_cal_time").getInteger();
for (int i = 0; i < list.size(); i++) {
FuturesOrder order = list.get(i);
boolean lock = false;
try {
if (!FuturesLock.add(order.getOrder_no())) {
continue;
}
lock = true;
this.futuresOrderCalculationService.saveCalculation(order);
} catch (Throwable e) {
logger.error("error:", e);
} finally {
if (lock) {
if (futures_cal_time>0) {
/**
* 每秒处理30个订单
*/
ThreadUtils.sleep(futures_cal_time);
} else {
/**
* 每秒处理200个订单
*/
ThreadUtils.sleep(5);
}
FuturesLock.remove(order.getOrder_no());
}
}
}
} catch (Throwable e) {
logger.error("run fail", e);
} finally {
/**
* 暂停0.1秒
*/
ThreadUtils.sleep(1000);
}
}
} catch (Throwable e) {
logger.error("run fail", e);
} finally
{
/**
* 暂停0.1秒
*/
ThreadUtils.sleep(1000);
/**
* 重新启动
*/
new Thread(this, "FuturesOrderCalculationJob").start();
if (logger.isInfoEnabled()) {
logger.info("交割合约持仓单盈亏计算线程启动!");
}
}
}
public void start() {
new Thread(this, "FuturesOrderCalculationJob").start();
if (logger.isInfoEnabled()) {
logger.info("交割合约持仓单盈亏计算线程启动!");
}
}
public void setFuturesOrderCalculationService(FuturesOrderCalculationService futuresOrderCalculationService) {
this.futuresOrderCalculationService = futuresOrderCalculationService;
}
public void setFuturesOrderService(FuturesOrderService futuresOrderService) {
this.futuresOrderService = futuresOrderService;
}
public void setSysparaService(SysparaService sysparaService) {
this.sysparaService = sysparaService;
}
}

View File

@@ -0,0 +1,15 @@
package project.futures.job;
import project.futures.FuturesOrder;
/**
* 交割合约盈亏计算
*/
public interface FuturesOrderCalculationService {
/*
* 订单盈亏计算
*/
public void saveCalculation(FuturesOrder order);
}

View File

@@ -0,0 +1,43 @@
package project.futures.job;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import project.data.DataCache;
import project.data.model.Realtime;
import project.futures.FuturesOrder;
import project.futures.FuturesOrderService;
public class FuturesOrderCalculationServiceImpl implements FuturesOrderCalculationService {
private static Log logger = LogFactory.getLog(FuturesOrderCalculationServiceImpl.class);
private FuturesOrderService futuresOrderService;
public void saveCalculation(FuturesOrder order) {
try {
Realtime realtime = DataCache.getRealtime(order.getSymbol());
if (null == realtime) {
return;
}
double close = realtime.getClose();
futuresOrderService.refreshCache(order, close);// 更新订单信息并纪录到缓存
if (order.getSettlement_time().before(new Date())) {
futuresOrderService.saveClose(order, realtime);
}
} catch (Throwable e) {
logger.error("FuturesOrderCalculationServiceImpl run fail", e);
}
}
public void setFuturesOrderService(FuturesOrderService futuresOrderService) {
this.futuresOrderService = futuresOrderService;
}
}

View File

@@ -0,0 +1,37 @@
package project.futures.job;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import project.log.SysLog;
import project.log.SysLogService;
public class FuturesOrderCreateRecomJob {
private static Logger logger = LoggerFactory.getLogger(FuturesOrderCreateRecomJob.class);
protected SysLogService sysLogService;
private FuturesOrderCreateRecomService futuresOrderCreateRecomService;
public void taskJob() {
try {
futuresOrderCreateRecomService.computeRecom();
} catch (Exception e) {
logger.error("FuturesOrderCreateRecomJob run fail e:", e);
SysLog entity = new SysLog();
entity.setLevel(SysLog.level_error);
entity.setCreateTime(new Date());
entity.setLog("FuturesOrderCreateRecomJob 交割购买奖励任务 执行失败 e:" + e);
sysLogService.saveAsyn(entity);
}
}
public void setSysLogService(SysLogService sysLogService) {
this.sysLogService = sysLogService;
}
public void setFuturesOrderCreateRecomService(FuturesOrderCreateRecomService futuresOrderCreateRecomService) {
this.futuresOrderCreateRecomService = futuresOrderCreateRecomService;
}
}

View File

@@ -0,0 +1,8 @@
package project.futures.job;
public interface FuturesOrderCreateRecomService {
/**
* 计算前一日购买产品的订单
*/
public void computeRecom();
}

View File

@@ -0,0 +1,154 @@
package project.futures.job;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.collections.CollectionUtils;
import kernel.util.Arith;
import kernel.util.DateUtils;
import kernel.util.StringUtils;
import kernel.web.Page;
import project.Constants;
import project.futures.FuturesOrder;
import project.futures.FuturesOrderService;
import project.log.MoneyLog;
import project.log.MoneyLogService;
import project.party.PartyService;
import project.party.model.Party;
import project.party.model.UserRecom;
import project.party.recom.UserRecomService;
import project.syspara.SysparaService;
import project.wallet.Wallet;
import project.wallet.WalletService;
public class FuturesOrderCreateRecomServiceImpl implements FuturesOrderCreateRecomService {
protected FuturesOrderService futuresOrderService;
protected SysparaService sysparaService;
protected UserRecomService userRecomService;
protected PartyService partyService;
protected WalletService walletService;
protected MoneyLogService moneyLogService;
/**
* 计算推荐人收益
*/
protected Map<String, Double> cacheRecomProfit = new ConcurrentHashMap<String, Double>();
/**
* 计算前一日购买产品的订单
*/
public void computeRecom() {
String futures_bonus_parameters = sysparaService.find("futures_bonus_parameters").getValue();
if (StringUtils.isEmptyString(futures_bonus_parameters)) {
return;
}
cacheRecomProfit.clear();
int pageSize = 1000;
int pageNo = 1;
String date = DateUtils.getDateStr(DateUtils.addDate(new Date(), -1));
while (true) {
Page page = futuresOrderService.pagedQueryByDate(pageNo, pageSize, date);
List<FuturesOrder> list = (List<FuturesOrder>) page.getElements();
if (list.isEmpty()) {
break;
}
for (FuturesOrder order : list) {
handleCacheRecom(order, futures_bonus_parameters);
}
pageNo++;
}
saveRecomProfit();
}
/**
* 购买推荐奖励
*
* @param entity
*/
public void handleCacheRecom(FuturesOrder entity, String futures_bonus_parameters) {
List<UserRecom> list_parents = this.userRecomService.getParents(entity.getPartyId());
if (CollectionUtils.isNotEmpty(list_parents)) {
String[] futures_bonus_array = futures_bonus_parameters.split(",");
int loop = 0;
int loopMax = futures_bonus_array.length;
for (int i = 0; i < list_parents.size(); i++) {
if (loop >= loopMax) {
break;
}
Party party_parent = this.partyService.cachePartyBy(list_parents.get(i).getReco_id(), true);
if (!Constants.SECURITY_ROLE_MEMBER.equals(party_parent.getRolename())) {
continue;
}
loop++;
double pip_amount = Double.valueOf(futures_bonus_array[loop - 1]);
double get_money = Arith.mul(entity.getVolume(), pip_amount);
if (cacheRecomProfit.containsKey(party_parent.getId().toString())) {
cacheRecomProfit.put(party_parent.getId().toString(),
Arith.add(cacheRecomProfit.get(party_parent.getId().toString()), get_money));
} else {
cacheRecomProfit.put(party_parent.getId().toString(), get_money);
}
}
}
}
public void saveRecomProfit() {
if (cacheRecomProfit.isEmpty()) {
return;
}
for (Entry<String, Double> entry : cacheRecomProfit.entrySet()) {
Wallet wallet_parent = walletService.saveWalletByPartyId(entry.getKey());
double amount_before_parent = wallet_parent.getMoney();
walletService.update(wallet_parent.getPartyId().toString(), entry.getValue());
/**
* 保存资金日志
*/
MoneyLog moneyLog = new MoneyLog();
moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_REWARD);
moneyLog.setAmount_before(amount_before_parent);
moneyLog.setAmount(entry.getValue());
moneyLog.setAmount_after(Arith.add(amount_before_parent, entry.getValue()));
moneyLog.setLog("下级购买交割,佣金奖励");
moneyLog.setPartyId(entry.getKey());
moneyLog.setWallettype(Constants.WALLET);
moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_REWARD);
moneyLogService.save(moneyLog);
}
}
public void setFuturesOrderService(FuturesOrderService futuresOrderService) {
this.futuresOrderService = futuresOrderService;
}
public void setSysparaService(SysparaService sysparaService) {
this.sysparaService = sysparaService;
}
public void setUserRecomService(UserRecomService userRecomService) {
this.userRecomService = userRecomService;
}
public void setPartyService(PartyService partyService) {
this.partyService = partyService;
}
public void setWalletService(WalletService walletService) {
this.walletService = walletService;
}
public void setMoneyLogService(MoneyLogService moneyLogService) {
this.moneyLogService = moneyLogService;
}
public void setCacheRecomProfit(Map<String, Double> cacheRecomProfit) {
this.cacheRecomProfit = cacheRecomProfit;
}
}

View File

@@ -0,0 +1,361 @@
package project.futures.web;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
// import org.apache.struts2.ServletActionContext;
import kernel.exception.BusinessException;
import kernel.util.Arith;
import kernel.util.PropertiesUtil;
import kernel.web.PageActionSupport;
//import project.data.internal.KlineInitService;
import project.futures.AdminContractManageService;
import project.futures.AdminFuturesParaService;
import project.futures.FuturesPara;
import project.futures.FuturesPara.TIMENUM;
//import project.futures.utils.ValidResult;
//import project.futures.utils.ValidationUtil;
import project.item.AdminItemService;
//import project.log.AdminLogService;
import project.item.ItemService;
import project.item.model.Item;
/**
* 合约产品
*
*/
public class AdminContractManageAction extends PageActionSupport {
private static final long serialVersionUID = 1749530978470763030L;
private static final Log logger = LogFactory.getLog(AdminContractManageAction.class);
private AdminContractManageService adminContractManageService;
private AdminItemService adminItemService;
private AdminFuturesParaService adminFuturesParaService;
private ItemService itemService;
// private KlineInitService klineInitService;
private Map<String, Object> contractResult = new HashMap<String, Object>();
/**
* 代码列表
*/
private Map<String, String> symbolMap = new HashMap<String, String>();
private FuturesPara futuresPara = new FuturesPara();
/**
* 查询
*/
private String itemId;
private String futuresId;
private String basePath = PropertiesUtil.getProperty("admin_url");
private String query_symbol;
/**
* 名称
*/
private String name;
/**
* 代码
*/
private String symbol;
/**
* 交易对
*/
private String symbol_data;
/**
* 精度
*/
private Integer decimals;
/**
* 初始化k线图代码
*/
private String para_init_symbol;
private String login_safeword;
private String super_google_auth_code;
// public String list() {
// HttpServletResponse response = ServletActionContext.getResponse();
// response.setContentType("application/json;charset=UTF-8");
// response.setHeader("Access-Control-Allow-Origin", "*");
// response.setHeader("Cache-Control", "no-cache");
//
// this.pageSize = 10;
// contractResult.put("contractItems", this.adminItemService.getItems());
// return "list";
// }
//
// public String listPara() {
// HttpServletResponse response = ServletActionContext.getResponse();
// response.setContentType("application/json;charset=UTF-8");
// response.setHeader("Access-Control-Allow-Origin", "*");
// response.setHeader("Cache-Control", "no-cache");
//
// this.pageSize = 10;
// contractResult.put("futures", adminFuturesParaService.pagedQuery(pageNo, pageSize, query_symbol));
// return "listPara";
// }
//
// public String toAdd() {
// basePath = getPath(ServletActionContext.getRequest());
// if (StringUtils.isNotEmpty(itemId)) {
// Item item = adminItemService.get(itemId);
// this.itemId = item.getId().toString();
// this.name = item.getName();
// this.symbol = item.getSymbol();
// this.decimals = item.getDecimals();
// this.symbol_data = item.getSymbol_data();
// }
// return "add";
// }
private String getPath(HttpServletRequest request) {
return String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), request.getServerPort(),
request.getContextPath());
}
// public String addContractItem() {
// try {
// this.error = verifyItem();
// if (StringUtils.isNotEmpty(this.error))
// return toAdd();
// Item entity = new Item();
// entity.setId(this.itemId);
// entity.setName(name);
// entity.setSymbol(symbol);
// entity.setDecimals(decimals);
// entity.setSymbol_data(symbol_data);
// this.error = adminContractManageService.addContractItem(entity);
// } catch (BusinessException e) {
// this.error = e.getMessage();
// }
// return StringUtils.isNotEmpty(error) ? toAdd() : list();
// }
// public String toAddInstall() {
// basePath = getPath(ServletActionContext.getRequest());
// symbolMap = this.adminContractManageService.getFuturesSymbols();
// if (StringUtils.isNotEmpty(futuresId)) {
// futuresPara = adminFuturesParaService.getById(futuresId);
// if (null == futuresPara) {
// this.error = "交易参数不存在";
// return list();
// }
// futuresPara.setProfit_ratio(Arith.mul(futuresPara.getProfit_ratio(), 100));
// futuresPara.setProfit_ratio_max(Arith.mul(futuresPara.getProfit_ratio_max(), 100));
// futuresPara.setUnit_fee(Arith.mul(futuresPara.getUnit_fee(), 100));
//
// futuresPara.setTimeUnitCn(TIMENUM.valueOf(futuresPara.getTimeUnit()).getCn());
// } else if (StringUtils.isEmpty(verification(futuresPara))) {
// futuresPara.setProfit_ratio(Arith.mul(futuresPara.getProfit_ratio(), 100));
// futuresPara.setProfit_ratio_max(Arith.mul(futuresPara.getProfit_ratio_max(), 100));
// futuresPara.setUnit_fee(Arith.mul(futuresPara.getUnit_fee(), 100));
// }
// return "toAddInstall";
// }
// public String addFutures() {
// try {
// this.error = verification(futuresPara);
// if (StringUtils.isNotEmpty(error))
// return toAddInstall();
//
// // 序列号的id接收会转变为数组
// if (futuresPara != null && futuresPara.getId() != null
// && StringUtils.isNotEmpty(futuresPara.getId().toString()))
// futuresPara.setId(((String[]) futuresPara.getId())[0]);
// futuresPara.setProfit_ratio(Arith.div(futuresPara.getProfit_ratio(), 100));
// futuresPara.setProfit_ratio_max(Arith.div(futuresPara.getProfit_ratio_max(), 100));
// futuresPara.setUnit_fee(Arith.div(futuresPara.getUnit_fee(), 100));
// this.error = adminContractManageService.addFutures(futuresPara, this.getIp(), this.getUsername_login(),
// this.login_safeword);
// this.message = "操作成功";
// } catch (BusinessException e) {
// this.error = e.getMessage();
// } catch (Exception e) {
// this.error = e.getMessage();
// }
// return StringUtils.isNotEmpty(error) ? toAddInstall() : listPara();
// }
//
// public String toDeleteFuturesPara() {
// try {
//// if(!"root".equals(this.getUsername_login())) {
//// throw new BusinessException("权限不足");
//// }
// this.adminContractManageService.deleteFuturesPara(this.futuresId, this.getIp(), this.getUsername_login(),
// this.login_safeword, this.super_google_auth_code);
// this.message = "操作成功";
// } catch (BusinessException e) {
// this.error = e.getMessage();
// } catch (Exception t) {
// logger.error("delete error ", t);
// this.error = "程序错误";
// }
// return listPara();
// }
private String verification(FuturesPara futuresPara) {
if (StringUtils.isEmpty(futuresPara.getSymbol()))
return "请选择合约代码";
if (futuresPara.getTimeNum() < 0)
return "请填写正确的时间";
if (StringUtils.isEmpty(futuresPara.getTimeUnit()))
return "请选择时间单位";
if (futuresPara.getUnit_amount() < 0)
return "请填写正确每手金额";
if (futuresPara.getUnit_fee() < 0)
return "请填写正确手续费";
if (futuresPara.getProfit_ratio() < 0)
return "请填写正确收益率";
if (futuresPara.getUnit_max_amount() != 0 && futuresPara.getUnit_max_amount() < futuresPara.getUnit_amount())
return "最高购买金额需大于最低购买金额";
return null;
}
private String verifyItem() {
if (StringUtils.isEmpty(this.name))
return "合约名称不能为空";
if (StringUtils.isEmpty(this.symbol))
return "代码不能为空";
if (StringUtils.isEmpty(this.symbol_data))
return "请选择交易对";
return null;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public AdminContractManageService getAdminContractManageService() {
return adminContractManageService;
}
public void setAdminContractManageService(AdminContractManageService adminContractManageService) {
this.adminContractManageService = adminContractManageService;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public Map<String, Object> getContractResult() {
return contractResult;
}
public void setContractResult(Map<String, Object> contractResult) {
this.contractResult = contractResult;
}
public AdminItemService getAdminItemService() {
return adminItemService;
}
public void setAdminItemService(AdminItemService adminItemService) {
this.adminItemService = adminItemService;
}
public String getFuturesId() {
return futuresId;
}
public void setFuturesId(String futuresId) {
this.futuresId = futuresId;
}
public AdminFuturesParaService getAdminFuturesParaService() {
return adminFuturesParaService;
}
public void setAdminFuturesParaService(AdminFuturesParaService adminFuturesParaService) {
this.adminFuturesParaService = adminFuturesParaService;
}
public Map<String, String> getSymbolMap() {
return symbolMap;
}
public void setSymbolMap(Map<String, String> symbolMap) {
this.symbolMap = symbolMap;
}
public FuturesPara getFuturesPara() {
return futuresPara;
}
public void setFuturesPara(FuturesPara futuresPara) {
this.futuresPara = futuresPara;
}
public String getQuery_symbol() {
return query_symbol;
}
public void setQuery_symbol(String query_symbol) {
this.query_symbol = query_symbol;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSymbol_data() {
return symbol_data;
}
public void setSymbol_data(String symbol_data) {
this.symbol_data = symbol_data;
}
public Integer getDecimals() {
return decimals;
}
public void setDecimals(Integer decimals) {
this.decimals = decimals;
}
public void setItemService(ItemService itemService) {
this.itemService = itemService;
}
public void setLogin_safeword(String login_safeword) {
this.login_safeword = login_safeword;
}
public void setSuper_google_auth_code(String super_google_auth_code) {
this.super_google_auth_code = super_google_auth_code;
}
}

View File

@@ -0,0 +1,253 @@
package project.futures.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import kernel.exception.BusinessException;
import kernel.util.JsonUtils;
import kernel.web.PageActionSupport;
import project.Constants;
import project.futures.AdminFuturesOrderService;
import project.futures.FuturesOrder;
import project.futures.FuturesOrderService;
import project.item.ItemService;
import project.item.model.Item;
public class AdminFuturesOrderAction extends PageActionSupport {
private static final long serialVersionUID = -2826063509608077114L;
private static Log logger = LogFactory.getLog(AdminFuturesOrderAction.class);
/**
* 所有item
*/
private List<Item> items;
private String symbol;
private String order_no;
/**
* 查询参数
*/
private String rolename_para = Constants.SECURITY_ROLE_MEMBER;
private String name_para;
private String status_para;
private String order_no_para;
private AdminFuturesOrderService adminFuturesOrderService;
private ItemService itemService;
private FuturesOrderService futuresOrderService;
/*
* 页面json返回值
*/
private String result_make;
/**
* 盈利还是亏损
*/
private String profit_loss;
/**
* 币种
*/
private String symbol_para;
/**
* 下单金额
*/
private Double volume_para;
/**
* 方向
*/
private String direction_para;
/**
* 上线币种
*/
private Map<String, String> symbol_map = new HashMap<String, String>();
public String list() {
for(Item item:itemService.cacheGetAll()) {
symbol_map.put(item.getSymbol(), item.getSymbol());
}
this.pageSize = 30;
String loginPartyId = getLoginPartyId();
this.page = this.adminFuturesOrderService.pagedQuery(this.pageNo, this.pageSize, this.status_para,
this.rolename_para, loginPartyId, this.name_para,order_no_para,symbol_para,direction_para,volume_para);
this.items = this.itemService.cacheGetAll();
return "list";
}
public String holdings_list() {
this.pageSize = 30;
String loginPartyId = getLoginPartyId();
this.page = this.adminFuturesOrderService.pagedQuery(this.pageNo, this.pageSize, "submitted",
this.rolename_para, loginPartyId, this.name_para,order_no_para,symbol_para,direction_para,volume_para);
this.items = this.itemService.cacheGetAll();
return "holdings";
}
/**
*
* ajax定时获取表
*/
public String getValue() {
this.pageSize = 30;
String loginPartyId = getLoginPartyId();
this.page = this.adminFuturesOrderService.pagedQuery(this.pageNo, this.pageSize, "submitted",
this.rolename_para, loginPartyId, this.name_para,order_no_para,symbol_para,direction_para,volume_para);
this.items = this.itemService.cacheGetAll();
this.result_make = JsonUtils.getJsonString(this.page.getElements());
return "result_make";
}
/**
* 平仓或撤单
*/
public String close() {
try {
// FuturesOrder order = futuresOrderService.findByOrderNo(order_no);
// this.message = "操作成功";
} catch (BusinessException e) {
this.error = e.getMessage();
} catch (Exception e) {
logger.error("error ", e);
this.error = "程序错误";
}
return list();
}
public String orderProfitLoss() {
try {
this.error = futuresOrderService.saveOrderPorfitOrLoss(order_no, profit_loss,this.getUsername_login());
if(StringUtils.isEmpty(error)) {
this.message = "操作成功";
}
} catch (BusinessException e) {
this.error = e.getMessage();
} catch (Exception e) {
logger.error("error ", e);
this.error = "程序错误";
}
return list();
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public String getOrder_no() {
return order_no;
}
public void setOrder_no(String order_no) {
this.order_no = order_no;
}
public String getRolename_para() {
return rolename_para;
}
public void setRolename_para(String rolename_para) {
this.rolename_para = rolename_para;
}
public List<Item> getItems() {
return items;
}
public String getResult_make() {
return result_make;
}
public void setItemService(ItemService itemService) {
this.itemService = itemService;
}
public void setFuturesOrderService(FuturesOrderService futuresOrderService) {
this.futuresOrderService = futuresOrderService;
}
public String getStatus_para() {
return status_para;
}
public void setStatus_para(String status_para) {
this.status_para = status_para;
}
public void setAdminFuturesOrderService(AdminFuturesOrderService adminFuturesOrderService) {
this.adminFuturesOrderService = adminFuturesOrderService;
}
public String getName_para() {
return name_para;
}
public void setName_para(String name_para) {
this.name_para = name_para;
}
public String getOrder_no_para() {
return order_no_para;
}
public void setOrder_no_para(String order_no_para) {
this.order_no_para = order_no_para;
}
public String getProfit_loss() {
return profit_loss;
}
public void setProfit_loss(String profit_loss) {
this.profit_loss = profit_loss;
}
public String getSymbol_para() {
return symbol_para;
}
public Map<String, String> getSymbol_map() {
return symbol_map;
}
public void setSymbol_para(String symbol_para) {
this.symbol_para = symbol_para;
}
public void setSymbol_map(Map<String, String> symbol_map) {
this.symbol_map = symbol_map;
}
public String getDirection_para() {
return direction_para;
}
public void setDirection_para(String direction_para) {
this.direction_para = direction_para;
}
public Double getVolume_para() {
return volume_para;
}
public void setVolume_para(Double volume_para) {
this.volume_para = volume_para;
}
}

View File

@@ -0,0 +1,377 @@
package project.futures.web;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import kernel.exception.BusinessException;
import kernel.util.StringUtils;
import kernel.web.PageActionSupport;
import project.Constants;
import project.futures.AdminProfitAndLossConfigService;
import project.futures.ProfitAndLossConfig;
import project.futures.ProfitAndLossConfigService;
import project.item.ItemService;
import project.item.model.Item;
import project.log.LogService;
import project.party.PartyService;
import project.party.model.Party;
import project.party.recom.UserRecomService;
import project.syspara.Syspara;
import project.syspara.SysparaService;
public class AdminProfitAndLossConfigAction extends PageActionSupport {
private static final long serialVersionUID = -1876081359521100683L;
private static Log logger = LogFactory.getLog(AdminProfitAndLossConfigAction.class);
private String name_para;
private AdminProfitAndLossConfigService adminProfitAndLossConfigService;
private ProfitAndLossConfigService profitAndLossConfigService;
private UserRecomService userRecomService;
private ItemService itemService;
private PartyService partyService;
private SysparaService sysparaService;
private LogService logService;
private String username;
private String usercode;
private String type = "1";
private String remark;
private String id;
private Map<String, String> type_map = Constants.PROFIT_LOSS_TYPE;
/**
* 上线币种
*/
private Map<String, String> symbol_map = new HashMap<String, String>();
/**
* 币种交割场控类型
*/
private String profit_loss_type;
/**
* 交割场控指定币种
*/
private String profit_loss_symbol;
public String list() {
this.pageSize = 30;
this.page = this.adminProfitAndLossConfigService.pagedQuery(this.pageNo, this.pageSize, this.name_para,
getLoginPartyId());
for (Map<String, Object> map : (List<Map<String, Object>>) page.getElements()) {
map.put("type", type_map.get(map.get("type")));
}
return "list";
}
public String toAdd() {
return "add";
}
private String verification() {
// if (StringUtils.isEmptyString(this.username))
// return "请输入用户名";
if (StringUtils.isEmptyString(this.usercode))
return "请输入用户UID";
return null;
}
public String add() {
try {
this.error = verification();
if (!StringUtils.isNullOrEmpty(this.error))
return toAdd();
// Party party = this.partyService.findPartyByUsername(this.username);
Party party = this.partyService.findPartyByUsercode(this.usercode);
Party party_login = this.partyService.findPartyByUsername(this.getUsername_login());
if (party == null) {
throw new BusinessException("用户不存在");
}
if (party_login != null) {
List<String> childrens = this.userRecomService.findChildren(party_login.getId());
double isChildren = 0;
if (childrens != null) {
for (String children : childrens) {
if (party.getId().equals(children)) {
isChildren = 1;
}
}
}
if (isChildren == 0) {
throw new BusinessException("用户不存在或者不属于登录用户名下");
}
}
ProfitAndLossConfig profitAndLossConfig = new ProfitAndLossConfig();
profitAndLossConfig.setType(this.type);
profitAndLossConfig.setRemark(this.remark);
profitAndLossConfig.setPartyId(party.getId());
this.profitAndLossConfigService.save(profitAndLossConfig, this.getUsername_login());
this.message = "操作成功";
} catch (BusinessException e) {
this.error = e.getMessage();
return toAdd();
} catch (Throwable t) {
logger.error("UserAction.register error ", t);
this.error = "[ERROR] " + t.getMessage();
return toAdd();
}
return list();
}
public String toUpdate() {
ProfitAndLossConfig profitAndLossConfig = this.profitAndLossConfigService.findById(this.id);
Party party = this.partyService.cachePartyBy(profitAndLossConfig.getPartyId(), true);
this.type = profitAndLossConfig.getType();
this.remark = profitAndLossConfig.getRemark();
this.username = party.getUsername();
this.usercode = party.getUsercode();
return "update";
}
public String update() {
ProfitAndLossConfig profitAndLossConfig = this.profitAndLossConfigService.findById(this.id);
try {
Party party = this.partyService.cachePartyBy(profitAndLossConfig.getPartyId(), true);
Party party_login = this.partyService.findPartyByUsername(this.getUsername_login());
if (party == null) {
throw new BusinessException("用户不存在");
}
if (party_login != null) {
List<String> childrens = this.userRecomService.findChildren(party_login.getId());
double isChildren = 0;
if (childrens != null) {
for (String children : childrens) {
if (party.getId().equals(children)) {
isChildren = 1;
}
}
}
if (isChildren == 0) {
throw new BusinessException("用户不存在或者不属于登录用户名下");
}
}
profitAndLossConfig.setRemark(remark);
profitAndLossConfig.setType(this.type);
this.profitAndLossConfigService.update(profitAndLossConfig, this.getUsername_login());
this.message = "操作成功";
return list();
} catch (BusinessException e) {
this.error = e.getMessage();
return "update";
} catch (Throwable t) {
logger.error("update error ", t);
this.error = "程序错误";
return "update";
}
}
public String toDelete() {
try {
ProfitAndLossConfig profitAndLossConfig = this.profitAndLossConfigService.findById(this.id);
Party party = this.partyService.cachePartyBy(profitAndLossConfig.getPartyId(), true);
Party party_login = this.partyService.findPartyByUsername(this.getUsername_login());
if (party == null) {
throw new BusinessException("用户不存在");
}
if (party_login != null) {
List<String> childrens = this.userRecomService.findChildren(party_login.getId());
double isChildren = 0;
if (childrens != null) {
for (String children : childrens) {
if (party.getId().equals(children)) {
isChildren = 1;
}
}
}
if (isChildren == 0) {
throw new BusinessException("用户不存在或者不属于登录用户名下");
}
}
this.profitAndLossConfigService.delete(this.id, this.getUsername_login());
this.message = "操作成功";
return list();
} catch (BusinessException e) {
this.error = e.getMessage();
return list();
} catch (Throwable t) {
logger.error("update error ", t);
this.error = "程序错误";
return list();
}
}
public String toProductProfitLoss() {
profit_loss_symbol = sysparaService.find("profit_loss_symbol").getValue();
profit_loss_type = sysparaService.find("profit_loss_type").getValue();
for(Item item:itemService.cacheGetAll()) {
symbol_map.put(item.getSymbol(), item.getSymbol());
}
return "profitLossProduct";
}
public String updateProductProfitLoss() {
try {
Syspara profit_loss_symbol_sys = sysparaService.find("profit_loss_symbol");
String old_profit_loss_symbol = profit_loss_symbol_sys.getValue();
profit_loss_symbol_sys.setValue(profit_loss_symbol);
sysparaService.update(profit_loss_symbol_sys);
Syspara profit_loss_type_sys = sysparaService.find("profit_loss_type");
String old_profit_loss_type = profit_loss_type_sys.getValue();
profit_loss_type_sys.setValue(profit_loss_type);
sysparaService.update(profit_loss_type_sys);
project.log.Log log = new project.log.Log();
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
log.setOperator(this.getUsername_login());
// log.setUsername(party.getUsername());
// log.setPartyId(entity.getPartyId());
log.setCreateTime(new Date());
log.setLog("管理员手动修改产品交割场控。原场控币种["+old_profit_loss_symbol+"],修改后场控币种为[" + profit_loss_symbol + "]."
+ "原币种交割场控类型["+Constants.PROFIT_LOSS_TYPE.get(old_profit_loss_type)+"],修改后币种交割场控类型["+Constants.PROFIT_LOSS_TYPE.get(profit_loss_type)+"]");
this.logService.saveSync(log);
this.message = "操作成功";
} catch (BusinessException e) {
this.error = e.getMessage();
} catch (Throwable t) {
logger.error("update error ", t);
this.error = "程序错误";
}
return toProductProfitLoss();
}
public String getName_para() {
return this.name_para;
}
public void setName_para(String name_para) {
this.name_para = name_para;
}
public void setAdminProfitAndLossConfigService(AdminProfitAndLossConfigService adminProfitAndLossConfigService) {
this.adminProfitAndLossConfigService = adminProfitAndLossConfigService;
}
public void setProfitAndLossConfigService(ProfitAndLossConfigService profitAndLossConfigService) {
this.profitAndLossConfigService = profitAndLossConfigService;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public String getRemark() {
return this.remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public void setPartyService(PartyService partyService) {
this.partyService = partyService;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Map<String, String> getType_map() {
return type_map;
}
public void setUserRecomService(UserRecomService userRecomService) {
this.userRecomService = userRecomService;
}
public String getUsercode() {
return usercode;
}
public void setUsercode(String usercode) {
this.usercode = usercode;
}
public String getProfit_loss_type() {
return profit_loss_type;
}
public String getProfit_loss_symbol() {
return profit_loss_symbol;
}
public void setProfit_loss_type(String profit_loss_type) {
this.profit_loss_type = profit_loss_type;
}
public void setProfit_loss_symbol(String profit_loss_symbol) {
this.profit_loss_symbol = profit_loss_symbol;
}
public void setItemService(ItemService itemService) {
this.itemService = itemService;
}
public Map<String, String> getSymbol_map() {
return symbol_map;
}
public void setSysparaService(SysparaService sysparaService) {
this.sysparaService = sysparaService;
}
public void setSymbol_map(Map<String, String> symbol_map) {
this.symbol_map = symbol_map;
}
public void setLogService(LogService logService) {
this.logService = logService;
}
}

View File

@@ -0,0 +1,372 @@
package project.futures.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
// import org.apache.struts2.ServletActionContext;
import org.springframework.beans.BeanUtils;
import kernel.exception.BusinessException;
import kernel.sessiontoken.SessionTokenService;
import kernel.util.JsonUtils;
import kernel.util.StringUtils;
import kernel.util.ThreadUtils;
import kernel.web.BaseAction;
import kernel.web.ResultObject;
import project.futures.FuturesLock;
import project.futures.FuturesOrder;
import project.futures.FuturesOrderLocalService;
import project.futures.FuturesOrderService;
import project.futures.FuturesPara;
import project.futures.FuturesParaService;
import project.party.PartyService;
import project.party.model.Party;
import project.wallet.Wallet;
import project.wallet.WalletService;
public class FuturesOrderAction extends BaseAction {
/**
*
*/
private static final long serialVersionUID = -7282461392959209832L;
private static Log logger = LogFactory.getLog(FuturesOrderAction.class);
private String symbol;
/**
* "buy":多 "sell":空
*/
private String direction;
/**
* 委托数量(张)
*/
private double volume;
private String order_no;
private int page_no;
/**
* 交割合约参数
*/
private String para_id;
private WalletService walletService;
private PartyService partyService;
private FuturesOrderService futuresOrderService;
private FuturesOrderLocalService futuresOrderLocalService;
private FuturesParaService futuresParaService;
private Map<String, Object> session = new HashMap<String, Object>();
private String session_token;
private final static Object obj = new Object();
private SessionTokenService sessionTokenService;
/**
* 开仓页面订单类型
*/
private String type;
/**
* 开仓页面参数
*/
// public String openview() throws IOException {
// HttpServletResponse response = ServletActionContext.getResponse();
// response.setContentType("application/json;charset=UTF-8");
// response.setHeader("Access-Control-Allow-Origin", "*");
// ResultObject resultObject = new ResultObject();
// PrintWriter out = response.getWriter();
// try {
// Map<String, Object> data = new HashMap<String, Object>();
//// List<FuturesPara> futuresPara = new ArrayList<FuturesPara>();
//// for (FuturesPara obj : this.futuresParaService.cacheGetBySymbolSort(symbol)) {
//// FuturesPara para = new FuturesPara();
//// BeanUtils.copyProperties(obj, para);
//// para.setProfit_ratio(Arith.mul(para.getProfit_ratio(), 100));// 转换格式显示,
//// }
// List<Map> futuresPara = new ArrayList<Map>();
// for (FuturesPara obj : this.futuresParaService.cacheGetBySymbolSort(symbol)) {
// FuturesPara para = new FuturesPara();
// BeanUtils.copyProperties(obj, para);
// futuresPara.add(this.futuresParaService.bulidOne(para));
// }
//
// data.put("para", futuresPara);
// String partyId = this.getLoginPartyId();
// if (!StringUtils.isNullOrEmpty(partyId) && futuresPara != null) {
// Wallet wallet = walletService.saveWalletByPartyId(this.getLoginPartyId());
// /*
// * 账户剩余资 金
// */
// DecimalFormat df = new DecimalFormat("#");
// data.put("volume", df.format(wallet.getMoney()));
// session_token = sessionTokenService.savePut(partyId);
// data.put("session_token", session_token);
// } else {
// data.put("volume", 0);
// }
//
// 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);
// }
// this.result = JsonUtils.getJsonString(resultObject);
// out.println(this.result);
// return null;
// }
/**
* 开仓
*
*/
// public String open() throws IOException {
// HttpServletResponse response = ServletActionContext.getResponse();
// response.setContentType("application/json;charset=UTF-8");
// response.setHeader("Access-Control-Allow-Origin", "*");
// ResultObject resultObject = new ResultObject();
// resultObject = readSecurityContextFromSession(resultObject);
// PrintWriter out = response.getWriter();
// if (!"0".equals(resultObject.getCode())) {
// this.result = JsonUtils.getJsonString(resultObject);
// out.println(this.result);
// return null;
// }
// String partyId = this.getLoginPartyId();
// boolean lock = false;
// try {
// Map<String, String> data = new HashMap<String, String>();
// if (!FuturesLock.add(partyId)) {
// throw new BusinessException(1, "请稍后再试");
// }
// lock = true;
//
// Object object = this.sessionTokenService.cacheGet(session_token);
// this.sessionTokenService.del(session_token);
// if ((object == null) || (!this.getLoginPartyId().equals((String) object))) {
// resultObject.setCode("1");
// resultObject.setMsg("请稍后再试");
// this.result = JsonUtils.getJsonString(resultObject);
// out.println(this.result);
// return null;
// }
// Party party = this.partyService.cachePartyBy(partyId, false);
// if (!party.getEnabled()) {
// resultObject.setCode("506");
// resultObject.setMsg(error);
// this.result = JsonUtils.getJsonString(resultObject);
// out.println(this.result);
// return null;
// }
//// if (!party.getKyc_authority()) {
//// resultObject.setCode("401");
//// resultObject.setMsg(error);
//// this.result = JsonUtils.getJsonString(resultObject);
//// out.println(this.result);
//// return null;
//// }
// FuturesOrder order = new FuturesOrder();
// order.setPartyId(partyId);
// order.setSymbol(symbol);
// order.setDirection(direction);
// order.setVolume(volume);
//
// order = this.futuresOrderService.saveOpen(order, para_id);
//
//// this.futuresOrderService.pushAsynRecom(order);
// data.put("order_no", order.getOrder_no());
// 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);
// } finally {
// if (lock) {
// ThreadUtils.sleep(100);
// FuturesLock.remove(partyId);
// }
//
// }
// this.result = JsonUtils.getJsonString(resultObject);
// out.println(this.result);
// return null;
// }
/**
* 查询交割持仓列表
*
* @return
* @throws IOException
*/
// public String list() throws IOException {
// HttpServletResponse response = ServletActionContext.getResponse();
// response.setContentType("application/json;charset=UTF-8");
// response.setHeader("Access-Control-Allow-Origin", "*");
// ResultObject resultObject = new ResultObject();
// resultObject = readSecurityContextFromSession(resultObject);
// PrintWriter out = response.getWriter();
// List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
// if (!"0".equals(resultObject.getCode())) {
// resultObject.setCode("0");
// resultObject.setData(data);
// this.result = JsonUtils.getJsonString(resultObject);
// out.println(this.result);
// return null;
// }
//
// try {
// String loginPartyId = this.getLoginPartyId();
// if ("orders".equals(type)) {
// List<FuturesOrder> list = futuresOrderService.cacheSubmitted();
// List<FuturesOrder> result = new LinkedList<FuturesOrder>();
//
// if (StringUtils.isNotEmpty(loginPartyId)) {// 登录才添加到列表
// for (FuturesOrder order : list) {
// if (StringUtils.isNotEmpty(symbol)) {// 有种类,满足登录人和种类 添加
// if (symbol.equals(order.getSymbol()) && loginPartyId.equals(order.getPartyId()))
// result.add(order);
// } else {
// if (loginPartyId.equals(order.getPartyId()))
// result.add(order);
// }
// }
// }
//
// data = futuresOrderService.bulidData(result);
//
// } else if ("hisorders".equals(type)) {
// List<FuturesOrder> list = this.futuresOrderService
// .getPaged(page_no, 10, this.getLoginPartyId(), symbol, type).getElements();
// data = futuresOrderService.bulidData(list);
// }
//
// } catch (Exception e) {
// resultObject.setCode("1");
// resultObject.setMsg("参数错误");
// logger.error("error:", e);
// }
//
// resultObject.setData(data);
// this.result = JsonUtils.getJsonString(resultObject);
// out.println(this.result);
// return null;
// }
//
// /**
// * 查询交割持仓详情
// *
// * @return
// * @throws IOException
// */
// public String get() throws IOException {
// HttpServletResponse response = ServletActionContext.getResponse();
// response.setContentType("application/json;charset=UTF-8");
// response.setHeader("Access-Control-Allow-Origin", "*");
// ResultObject resultObject = new ResultObject();
// resultObject = readSecurityContextFromSession(resultObject);
// PrintWriter out = response.getWriter();
// if (!"0".equals(resultObject.getCode())) {
// resultObject.setCode("0");
// this.result = JsonUtils.getJsonString(resultObject);
// out.println(this.result);
// return null;
// }
//
// try {
//
// FuturesOrder data = this.futuresOrderLocalService.cacheByOrderNo(order_no);
// resultObject.setData(futuresOrderLocalService.bulidOne(data));
// } catch (Exception e) {
// resultObject.setCode("1");
// resultObject.setMsg("参数错误");
// logger.error("error:", e);
// }
//
// this.result = JsonUtils.getJsonString(resultObject);
// out.println(this.result);
// return null;
// }
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public void setOrder_no(String order_no) {
this.order_no = order_no;
}
public void setPage_no(int page_no) {
this.page_no = page_no;
}
public void setDirection(String direction) {
this.direction = direction;
}
public void setPara_id(String para_id) {
this.para_id = para_id;
}
public void setWalletService(WalletService walletService) {
this.walletService = walletService;
}
public void setFuturesOrderService(FuturesOrderService futuresOrderService) {
this.futuresOrderService = futuresOrderService;
}
public void setType(String type) {
this.type = type;
}
public void setFuturesParaService(FuturesParaService futuresParaService) {
this.futuresParaService = futuresParaService;
}
public String getSession_token() {
return session_token;
}
public void setSession_token(String session_token) {
this.session_token = session_token;
}
public void setSession(Map<String, Object> session) {
this.session = session;
}
public void setSessionTokenService(SessionTokenService sessionTokenService) {
this.sessionTokenService = sessionTokenService;
}
public void setPartyService(PartyService partyService) {
this.partyService = partyService;
}
public void setFuturesOrderLocalService(FuturesOrderLocalService futuresOrderLocalService) {
this.futuresOrderLocalService = futuresOrderLocalService;
}
public void setVolume(double volume) {
this.volume = volume;
}
}

View File

@@ -0,0 +1,478 @@
package project.web.admin;
import java.util.ArrayList;
import java.util.HashMap;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import kernel.exception.BusinessException;
import kernel.util.Arith;
import kernel.util.PropertiesUtil;
import kernel.util.StringUtils;
import kernel.web.PageActionSupport;
import project.futures.AdminContractManageService;
import project.futures.AdminFuturesParaService;
import project.futures.FuturesPara;
import project.futures.FuturesPara.TIMENUM;
import project.item.AdminItemService;
import project.item.model.Item;
/**
* 交割合约管理
*/
@RestController
public class AdminContractManageController extends PageActionSupport {
private Logger logger = LogManager.getLogger(AdminContractManageController.class);
@Autowired
private AdminContractManageService adminContractManageService;
@Autowired
private AdminItemService adminItemService;
@Autowired
private AdminFuturesParaService adminFuturesParaService;
// @Autowired
// private ItemService itemService;
private final String action = "normal/adminContractManageAction!";
/**
* 获取 交易对 列表
*/
@RequestMapping(action + "list.action")
public ModelAndView list(HttpServletRequest request) {
String pageNo = request.getParameter("pageNo");
String message = request.getParameter("message");
String error = request.getParameter("error");
String para_symbol = request.getParameter("para_symbol");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("contract_manage_list");
Map<String, Object> contractResult = new HashMap<String, Object>();
try {
this.checkAndSetPageNo(pageNo);
this.pageSize = 10;
List<Item> itemsRet = new ArrayList<Item>();
List<Item> items = this.adminItemService.getItems();
if (StringUtils.isEmptyString(para_symbol)) {
itemsRet = items;
} else {
for (int i = 0; i < items.size(); i++) {
Item item = items.get(i);
if (item.getSymbol().equalsIgnoreCase(para_symbol)) {
itemsRet.add(item);
}
}
}
contractResult.put("contractItems", itemsRet);
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
return modelAndView;
}
modelAndView.addObject("pageNo", this.pageNo);
modelAndView.addObject("pageSize", this.pageSize);
// modelAndView.addObject("page", this.page);
modelAndView.addObject("message", message);
modelAndView.addObject("error", error);
modelAndView.addObject("para_symbol", para_symbol);
modelAndView.addObject("contractResult", contractResult);
return modelAndView;
}
/**
* 获取 交易参数 列表
*/
@RequestMapping(action + "listPara.action")
public ModelAndView listPara(HttpServletRequest request) {
String pageNo = request.getParameter("pageNo");
String message = request.getParameter("message");
String error = request.getParameter("error");
String query_symbol = request.getParameter("query_symbol");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("contract_para_list");
Map<String, Object> contractResult = new HashMap<String, Object>();
try {
this.checkAndSetPageNo(pageNo);
this.pageSize = 10;
contractResult.put("futures", this.adminFuturesParaService.pagedQuery(this.pageNo, this.pageSize, query_symbol));
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
return modelAndView;
}
modelAndView.addObject("pageNo", this.pageNo);
modelAndView.addObject("pageSize", this.pageSize);
// modelAndView.addObject("page", this.page);
modelAndView.addObject("message", message);
modelAndView.addObject("error", error);
modelAndView.addObject("query_symbol", query_symbol);
modelAndView.addObject("contractResult", contractResult);
return modelAndView;
}
// public String toAdd() {
// basePath = getPath(ServletActionContext.getRequest());
// if (StringUtils.isNotEmpty(itemId)) {
// Item item = adminItemService.get(itemId);
// this.itemId = item.getId().toString();
// this.name = item.getName();
// this.symbol = item.getSymbol();
// this.decimals = item.getDecimals();
// this.symbol_data = item.getSymbol_data();
// }
// return "add";
// }
// public String addContractItem() {
// try {
// this.error = verifyItem();
// if (StringUtils.isNotEmpty(this.error))
// return toAdd();
// Item entity = new Item();
// entity.setId(this.itemId);
// entity.setName(name);
// entity.setSymbol(symbol);
// entity.setDecimals(decimals);
// entity.setSymbol_data(symbol_data);
// this.error = adminContractManageService.addContractItem(entity);
// } catch (BusinessException e) {
// this.error = e.getMessage();
// }
// return StringUtils.isNotEmpty(error) ? toAdd() : list();
// }
/**
* 新增/修改 交易参数 页面
*/
@RequestMapping(action + "toAddInstall.action")
public ModelAndView toAddInstall(HttpServletRequest request) {
String futuresId = request.getParameter("futuresId");
String query_symbol = request.getParameter("query_symbol");
ModelAndView modelAndView = new ModelAndView();
try {
String basePath = PropertiesUtil.getProperty("admin_url");
basePath = this.getPath(request);
Map<String, String> symbolMap = new HashMap<String, String>();
symbolMap = this.adminContractManageService.getFuturesSymbols();
FuturesPara futuresPara = new FuturesPara();
if (StringUtils.isNotEmpty(futuresId)) {
// 修改
futuresPara = this.adminFuturesParaService.getById(futuresId);
if (null == futuresPara) {
throw new BusinessException("交易参数不存在");
}
futuresPara.setProfit_ratio(Arith.mul(futuresPara.getProfit_ratio(), 100));
futuresPara.setProfit_ratio_max(Arith.mul(futuresPara.getProfit_ratio_max(), 100));
futuresPara.setUnit_fee(Arith.mul(futuresPara.getUnit_fee(), 100));
futuresPara.setTimeUnitCn(TIMENUM.valueOf(futuresPara.getTimeUnit()).getCn());
modelAndView.addObject("futuresId", futuresId);
modelAndView.addObject("query_symbol", query_symbol);
modelAndView.addObject("symbolMap", symbolMap);
modelAndView.addObject("futuresPara_id", futuresPara.getId());
modelAndView.addObject("futuresPara_symbol", futuresPara.getSymbol());
modelAndView.addObject("futuresPara_timeNum", futuresPara.getTimeNum());
modelAndView.addObject("futuresPara_timeUnit", futuresPara.getTimeUnit());
modelAndView.addObject("futuresPara_profit_ratio", futuresPara.getProfit_ratio());
modelAndView.addObject("futuresPara_profit_ratio_max", futuresPara.getProfit_ratio_max());
modelAndView.addObject("futuresPara_unit_amount", futuresPara.getUnit_amount());
modelAndView.addObject("futuresPara_unit_fee", futuresPara.getUnit_fee());
modelAndView.addObject("futuresPara_timeUnitCn", futuresPara.getTimeUnitCn());
modelAndView.addObject("futuresPara_unit_max_amount", futuresPara.getUnit_max_amount());
} else {
// 新增
if (StringUtils.isEmptyString(query_symbol)) {
throw new BusinessException("请选择合约代码");
}
modelAndView.addObject("futuresId", futuresId);
modelAndView.addObject("query_symbol", query_symbol);
modelAndView.addObject("symbolMap", symbolMap);
}
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
modelAndView.setViewName("redirect:/" + action + "list.action");
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
modelAndView.setViewName("redirect:/" + action + "list.action");
return modelAndView;
}
modelAndView.setViewName("contract_install_add");
return modelAndView;
}
/**
* 新增/修改 交易参数
*/
@RequestMapping(action + "addFutures.action")
public ModelAndView addFutures(HttpServletRequest request) {
String futuresId = request.getParameter("futuresId");
String query_symbol = request.getParameter("query_symbol");
String futuresPara_id = request.getParameter("futuresPara_id");
String futuresPara_symbol = request.getParameter("futuresPara_symbol");
String futuresPara_timeNum = request.getParameter("futuresPara_timeNum");
String futuresPara_timeUnit = request.getParameter("futuresPara_timeUnit");
String futuresPara_profit_ratio = request.getParameter("futuresPara_profit_ratio");
String futuresPara_profit_ratio_max = request.getParameter("futuresPara_profit_ratio_max");
String futuresPara_unit_amount = request.getParameter("futuresPara_unit_amount");
String futuresPara_unit_fee = request.getParameter("futuresPara_unit_fee");
String futuresPara_timeUnitCn = request.getParameter("futuresPara_timeUnitCn");
String futuresPara_unit_max_amount = request.getParameter("futuresPara_unit_max_amount");
String login_safeword = request.getParameter("login_safeword");
ModelAndView modelAndView = new ModelAndView();
Map<String, String> symbolMap = new HashMap<String, String>();
symbolMap = this.adminContractManageService.getFuturesSymbols();
try {
if (StringUtils.isNullOrEmpty(futuresPara_unit_max_amount)) {
futuresPara_unit_max_amount = "0";
}
String error = this.verification(query_symbol, futuresPara_timeNum, futuresPara_timeUnit, futuresPara_unit_amount,
futuresPara_unit_fee, futuresPara_profit_ratio, futuresPara_profit_ratio_max, futuresPara_unit_max_amount);
if (StringUtils.isNotEmpty(error)) {
throw new BusinessException(error);
}
int futuresPara_timeNum_int = Integer.valueOf(futuresPara_timeNum).intValue();
double futuresPara_unit_amount_double = Double.valueOf(futuresPara_unit_amount).doubleValue();
double futuresPara_unit_fee_double = Double.valueOf(futuresPara_unit_fee).doubleValue();
double futuresPara_profit_ratio_double = Double.valueOf(futuresPara_profit_ratio).doubleValue();
double futuresPara_profit_ratio_max_double = Double.valueOf(futuresPara_profit_ratio_max).doubleValue();
double futuresPara_unit_max_amount_double = Double.valueOf(futuresPara_unit_max_amount).doubleValue();
FuturesPara futuresPara = new FuturesPara();
futuresPara.setId(futuresPara_id);
futuresPara.setSymbol(futuresPara_symbol);
futuresPara.setTimeNum(futuresPara_timeNum_int);
futuresPara.setTimeUnit(futuresPara_timeUnit);
futuresPara.setProfit_ratio(Arith.div(futuresPara_profit_ratio_double, 100));
futuresPara.setProfit_ratio_max(Arith.div(futuresPara_profit_ratio_max_double, 100));
futuresPara.setUnit_amount(futuresPara_unit_amount_double);
futuresPara.setUnit_fee(Arith.div(futuresPara_unit_fee_double, 100));
futuresPara.setTimeUnitCn(futuresPara_timeUnitCn);
futuresPara.setUnit_max_amount(futuresPara_unit_max_amount_double);
String error1 = this.adminContractManageService.addFutures(futuresPara, this.getIp(), this.getUsername_login(), login_safeword);
if (StringUtils.isNotEmpty(error1)) {
throw new BusinessException(error1);
}
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
modelAndView.addObject("futuresId", futuresId);
modelAndView.addObject("query_symbol", query_symbol);
modelAndView.addObject("symbolMap", symbolMap);
modelAndView.addObject("futuresPara_id", futuresPara_id);
modelAndView.addObject("futuresPara_symbol", futuresPara_symbol);
modelAndView.addObject("futuresPara_timeNum", futuresPara_timeNum);
modelAndView.addObject("futuresPara_timeUnit", futuresPara_timeUnit);
modelAndView.addObject("futuresPara_profit_ratio", futuresPara_profit_ratio);
modelAndView.addObject("futuresPara_profit_ratio_max", futuresPara_profit_ratio_max);
modelAndView.addObject("futuresPara_unit_amount", futuresPara_unit_amount);
modelAndView.addObject("futuresPara_unit_fee", futuresPara_unit_fee);
modelAndView.addObject("futuresPara_timeUnitCn", futuresPara_timeUnitCn);
modelAndView.addObject("futuresPara_unit_max_amount", futuresPara_unit_max_amount);
modelAndView.setViewName("contract_install_add");
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
modelAndView.addObject("futuresId", futuresId);
modelAndView.addObject("query_symbol", query_symbol);
modelAndView.addObject("symbolMap", symbolMap);
modelAndView.addObject("futuresPara_id", futuresPara_id);
modelAndView.addObject("futuresPara_symbol", futuresPara_symbol);
modelAndView.addObject("futuresPara_timeNum", futuresPara_timeNum);
modelAndView.addObject("futuresPara_timeUnit", futuresPara_timeUnit);
modelAndView.addObject("futuresPara_profit_ratio", futuresPara_profit_ratio);
modelAndView.addObject("futuresPara_profit_ratio_max", futuresPara_profit_ratio_max);
modelAndView.addObject("futuresPara_unit_amount", futuresPara_unit_amount);
modelAndView.addObject("futuresPara_unit_fee", futuresPara_unit_fee);
modelAndView.addObject("futuresPara_timeUnitCn", futuresPara_timeUnitCn);
modelAndView.addObject("futuresPara_unit_max_amount", futuresPara_unit_max_amount);
modelAndView.setViewName("contract_install_add");
return modelAndView;
}
modelAndView.addObject("message", "操作成功");
modelAndView.addObject("query_symbol", query_symbol);
modelAndView.setViewName("redirect:/" + action + "listPara.action");
return modelAndView;
}
/**
* 删除 交易参数
*/
@RequestMapping(action + "toDeleteFuturesPara.action")
public ModelAndView toDeleteFuturesPara(HttpServletRequest request) {
String futuresId = request.getParameter("futuresId");
String login_safeword = request.getParameter("login_safeword");
String super_google_auth_code = request.getParameter("super_google_auth_code");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "listPara.action");
try {
this.adminContractManageService.deleteFuturesPara(futuresId, this.getIp(), this.getUsername_login(), login_safeword, super_google_auth_code);
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
return modelAndView;
}
modelAndView.addObject("message", "操作成功");
return modelAndView;
}
private String verification(String symbol, String timeNum, String timeUnit, String unit_amount, String unit_fee,
String profit_ratio, String profit_ratio_max, String unit_max_amount) {
if (StringUtils.isEmptyString(symbol)) {
return "请选择合约代码";
}
if (StringUtils.isNullOrEmpty(timeNum)) {
return "时间必填";
}
if (!StringUtils.isInteger(timeNum)) {
return "时间不是整数";
}
if (Integer.valueOf(timeNum).intValue() <= 0) {
return "时间不能小于等于0";
}
if (StringUtils.isEmptyString(timeUnit)) {
return "请选择时间单位";
}
if (StringUtils.isNullOrEmpty(unit_amount)) {
return "每手金额必填";
}
if (!StringUtils.isDouble(unit_amount)) {
return "每手金额不是浮点数";
}
if (Double.valueOf(unit_amount).doubleValue() <= 0) {
return "每手金额不能小于等于0";
}
if (StringUtils.isNullOrEmpty(unit_amount)) {
return "手续费必填";
}
if (!StringUtils.isDouble(unit_amount)) {
return "手续费不是浮点数";
}
if (Double.valueOf(unit_amount).doubleValue() <= 0) {
return "手续费不能小于等于0";
}
if (StringUtils.isNullOrEmpty(profit_ratio)) {
return "最小收益率必填";
}
if (!StringUtils.isDouble(profit_ratio)) {
return "最小收益率不是浮点数";
}
if (Double.valueOf(profit_ratio).doubleValue() <= 0) {
return "最小收益率不能小于等于0";
}
if (StringUtils.isNullOrEmpty(profit_ratio_max)) {
return "最大收益率必填";
}
if (!StringUtils.isDouble(profit_ratio_max)) {
return "最大收益率不是浮点数";
}
if (Double.valueOf(profit_ratio_max).doubleValue() <= 0) {
return "最大收益率不能小于等于0";
}
if (StringUtils.isNullOrEmpty(unit_max_amount)) {
return "最高购买金额必填";
}
if (!StringUtils.isDouble(unit_max_amount)) {
return "最高购买金额不是浮点数";
}
// if (Double.valueOf(unit_max_amount).doubleValue() <= 0) {
// return "最高购买金额不能小于等于0";
// }
double unit_amount_double = Double.valueOf(unit_amount).doubleValue();
double unit_max_amount_double = Double.valueOf(unit_max_amount).doubleValue();
if (unit_max_amount_double != 0 && unit_max_amount_double < unit_amount_double) {
return "最高购买金额需大于最低购买金额";
}
return null;
}
// private String verifyItem() {
// if (StringUtils.isEmpty(this.name))
// return "合约名称不能为空";
// if (StringUtils.isEmpty(this.symbol))
// return "代码不能为空";
// if (StringUtils.isEmpty(this.symbol_data))
// return "请选择交易对";
// return null;
// }
private String getPath(HttpServletRequest request) {
return String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath());
}
}

View File

@@ -0,0 +1,297 @@
package project.web.admin;
import java.util.ArrayList;
import java.util.HashMap;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import kernel.exception.BusinessException;
import kernel.util.JsonUtils;
import kernel.util.StringUtils;
import kernel.web.PageActionSupport;
import project.Constants;
import project.futures.AdminFuturesOrderService;
import project.futures.FuturesOrderService;
import project.item.ItemService;
import project.item.model.Item;
/**
* 交割合约单
*/
@RestController
public class AdminFuturesOrderController extends PageActionSupport {
private Logger logger = LogManager.getLogger(AdminFuturesOrderController.class);
@Autowired
private AdminFuturesOrderService adminFuturesOrderService;
@Autowired
private ItemService itemService;
@Autowired
private FuturesOrderService futuresOrderService;
private final String action = "normal/adminFuturesOrderAction!";
/**
* 获取 交割合约单 列表
*
* symbol_para 币种
* direction_para 方向
* volume_para 下单金额
* symbol_map 上线币种
*/
@RequestMapping(action + "list.action")
public ModelAndView list(HttpServletRequest request) {
String pageNo = request.getParameter("pageNo");
String message = request.getParameter("message");
String error = request.getParameter("error");
String status_para = request.getParameter("status_para");
String rolename_para = request.getParameter("rolename_para");
String name_para = request.getParameter("name_para");
String order_no_para = request.getParameter("order_no_para");
String symbol_para = request.getParameter("symbol_para");
String direction_para = request.getParameter("direction_para");
String volume_para = request.getParameter("volume_para");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("futures_order_list");
Map<String, String> symbol_map = new HashMap<String, String>();
try {
List<Item> items = this.itemService.cacheGetAll();
for (Item item : items) {
symbol_map.put(item.getSymbol(), item.getSymbol());
}
this.checkAndSetPageNo(pageNo);
this.pageSize = 30;
Double volume_para_double = null;
if (StringUtils.isNullOrEmpty(volume_para)) {
volume_para_double = null;
} else {
if (!StringUtils.isDouble(volume_para)) {
throw new BusinessException("下单金额不是浮点数");
}
if (Double.valueOf(volume_para).doubleValue() < 0) {
throw new BusinessException("下单金额不能小于0");
}
volume_para_double = Double.valueOf(volume_para).doubleValue();
}
String loginPartyId = this.getLoginPartyId();
this.page = this.adminFuturesOrderService.pagedQuery(this.pageNo, this.pageSize, status_para,
rolename_para, loginPartyId, name_para, order_no_para, symbol_para, direction_para, volume_para_double);
List<Map> list = this.page.getElements();
for (int i = 0; i < list.size(); i++) {
Map map = list.get(i);
if (null == map.get("rolename")) {
map.put("roleNameDesc", "");
} else {
String roleName = map.get("rolename").toString();
map.put("roleNameDesc",
Constants.ROLE_MAP.containsKey(roleName) ? Constants.ROLE_MAP.get(roleName) : roleName);
}
}
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
return modelAndView;
}
modelAndView.addObject("pageNo", this.pageNo);
modelAndView.addObject("pageSize", this.pageSize);
modelAndView.addObject("page", this.page);
modelAndView.addObject("message", message);
modelAndView.addObject("error", error);
modelAndView.addObject("status_para", status_para);
modelAndView.addObject("rolename_para", rolename_para);
modelAndView.addObject("name_para", name_para);
modelAndView.addObject("order_no_para", order_no_para);
modelAndView.addObject("symbol_para", symbol_para);
modelAndView.addObject("direction_para", direction_para);
modelAndView.addObject("volume_para", volume_para);
modelAndView.addObject("symbol_map", symbol_map);
return modelAndView;
}
/**
* 获取 交割合约单 列表
*
* symbol_para 币种
* direction_para 方向
* volume_para 下单金额
*/
@RequestMapping(action + "holdings_list.action")
public ModelAndView holdings_list(HttpServletRequest request) {
String pageNo = request.getParameter("pageNo");
String message = request.getParameter("message");
String error = request.getParameter("error");
String rolename_para = request.getParameter("rolename_para");
String name_para = request.getParameter("name_para");
String order_no_para = request.getParameter("order_no_para");
String symbol_para = request.getParameter("symbol_para");
String direction_para = request.getParameter("direction_para");
String volume_para = request.getParameter("volume_para");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("futures_holdings_list");
try {
this.checkAndSetPageNo(pageNo);
this.pageSize = 30;
if (StringUtils.isNullOrEmpty(volume_para)) {
throw new BusinessException("下单金额必填");
}
if (!StringUtils.isDouble(volume_para)) {
throw new BusinessException("下单金额不是浮点数");
}
if (Double.valueOf(volume_para).doubleValue() <= 0) {
throw new BusinessException("下单金额不能小于等于0");
}
double volume_para_double = Double.valueOf(volume_para).doubleValue();
String loginPartyId = this.getLoginPartyId();
this.page = this.adminFuturesOrderService.pagedQuery(this.pageNo, this.pageSize, "submitted",
rolename_para, loginPartyId, name_para, order_no_para, symbol_para, direction_para, volume_para_double);
List<Map> list = this.page.getElements();
for (int i = 0; i < list.size(); i++) {
Map map = list.get(i);
if (null == map.get("rolename")) {
map.put("roleNameDesc", "");
} else {
String roleName = map.get("rolename").toString();
map.put("roleNameDesc",
Constants.ROLE_MAP.containsKey(roleName) ? Constants.ROLE_MAP.get(roleName) : roleName);
}
}
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
return modelAndView;
}
modelAndView.addObject("pageNo", this.pageNo);
modelAndView.addObject("pageSize", this.pageSize);
modelAndView.addObject("page", this.page);
modelAndView.addObject("message", message);
modelAndView.addObject("error", error);
modelAndView.addObject("rolename_para", rolename_para);
modelAndView.addObject("name_para", name_para);
modelAndView.addObject("order_no_para", order_no_para);
modelAndView.addObject("symbol_para", symbol_para);
modelAndView.addObject("direction_para", direction_para);
modelAndView.addObject("volume_para", volume_para);
return modelAndView;
}
/**
* ajax定时获取表
*
* symbol_para 币种
* direction_para 方向
* volume_para 下单金额
*/
@RequestMapping(action + "getValue.action")
public String getValue(HttpServletRequest request) {
String pageNo = request.getParameter("pageNo");
String rolename_para = request.getParameter("rolename_para");
String name_para = request.getParameter("name_para");
String order_no_para = request.getParameter("order_no_para");
String symbol_para = request.getParameter("symbol_para");
String direction_para = request.getParameter("direction_para");
String volume_para = request.getParameter("volume_para");
try {
this.checkAndSetPageNo(pageNo);
this.pageSize = 30;
if (StringUtils.isNullOrEmpty(volume_para)) {
throw new BusinessException("下单金额必填");
}
if (!StringUtils.isDouble(volume_para)) {
throw new BusinessException("下单金额不是浮点数");
}
if (Double.valueOf(volume_para).doubleValue() <= 0) {
throw new BusinessException("下单金额不能小于等于0");
}
double volume_para_double = Double.valueOf(volume_para).doubleValue();
String loginPartyId = this.getLoginPartyId();
this.page = this.adminFuturesOrderService.pagedQuery(this.pageNo, this.pageSize, "submitted",
rolename_para, loginPartyId, name_para, order_no_para, symbol_para, direction_para, volume_para_double);
} catch (BusinessException e) {
return JsonUtils.getJsonString(new ArrayList());
} catch (Throwable t) {
logger.error(" error ", t);
return JsonUtils.getJsonString(new ArrayList());
}
return JsonUtils.getJsonString(this.page.getElements());
}
/**
* orderProfitLoss
*
* profit_loss 盈利还是亏损
*/
@RequestMapping(action + "orderProfitLoss.action")
public ModelAndView orderProfitLoss(HttpServletRequest request) {
String order_no = request.getParameter("order_no");
String profit_loss = request.getParameter("profit_loss");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
String error = this.futuresOrderService.saveOrderPorfitOrLoss(order_no, profit_loss, this.getUsername_login());
if (StringUtils.isNotEmpty(error)) {
throw new BusinessException(error);
}
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
return modelAndView;
}
modelAndView.addObject("message", "操作成功");
return modelAndView;
}
}

View File

@@ -0,0 +1,403 @@
package project.web.admin;
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.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.Constants;
import project.futures.AdminProfitAndLossConfigService;
import project.futures.ProfitAndLossConfig;
import project.futures.ProfitAndLossConfigService;
import project.item.ItemService;
import project.log.LogService;
import project.party.PartyService;
import project.party.model.Party;
import project.party.recom.UserRecomService;
import project.syspara.SysparaService;
/**
* 交割场控设置
*/
@RestController
public class AdminProfitAndLossConfigController extends PageActionSupport {
private Logger logger = LogManager.getLogger(AdminProfitAndLossConfigController.class);
@Autowired
private AdminProfitAndLossConfigService adminProfitAndLossConfigService;
@Autowired
private ProfitAndLossConfigService profitAndLossConfigService;
@Autowired
private UserRecomService userRecomService;
@Autowired
private ItemService itemService;
@Autowired
private PartyService partyService;
@Autowired
private SysparaService sysparaService;
@Autowired
private LogService logService;
private final String action = "normal/adminProfitAndLossConfigAction!";
/**
* 获取 交割场控设置 列表
*/
@RequestMapping(action + "list.action")
public ModelAndView list(HttpServletRequest request) {
String pageNo = request.getParameter("pageNo");
String message = request.getParameter("message");
String error = request.getParameter("error");
String name_para = request.getParameter("name_para");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("profit_loss_config_list");
Map<String, String> type_map = Constants.PROFIT_LOSS_TYPE;
try {
this.checkAndSetPageNo(pageNo);
this.pageSize = 30;
this.page = this.adminProfitAndLossConfigService.pagedQuery(this.pageNo, this.pageSize, name_para, this.getLoginPartyId());
List<Map> list = this.page.getElements();
for (int i = 0; i < list.size(); i++) {
Map map = list.get(i);
map.put("type", type_map.get(map.get("type")));
if (null == map.get("rolename")) {
map.put("roleNameDesc", "");
} else {
String roleName = map.get("rolename").toString();
map.put("roleNameDesc", Constants.ROLE_MAP.containsKey(roleName) ? Constants.ROLE_MAP.get(roleName) : roleName);
}
}
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
return modelAndView;
}
modelAndView.addObject("pageNo", this.pageNo);
modelAndView.addObject("pageSize", this.pageSize);
modelAndView.addObject("page", this.page);
modelAndView.addObject("message", message);
modelAndView.addObject("error", error);
modelAndView.addObject("name_para", name_para);
return modelAndView;
}
/**
* 新增 交割场控设置 页面
*/
@RequestMapping(action + "toAdd.action")
public ModelAndView toAdd(HttpServletRequest request) {
ModelAndView modelAndView = new ModelAndView();
Map<String, String> type_map = Constants.PROFIT_LOSS_TYPE;
modelAndView.addObject("type_map", type_map);
modelAndView.setViewName("profit_loss_config_add");
return modelAndView;
}
/**
* 新增 交割场控设置
*/
@RequestMapping(action + "add.action")
public ModelAndView add(HttpServletRequest request) {
String usercode = request.getParameter("usercode");
String type = request.getParameter("type");
String remark = request.getParameter("remark");
ModelAndView modelAndView = new ModelAndView();
Map<String, String> type_map = Constants.PROFIT_LOSS_TYPE;
try {
if (StringUtils.isEmptyString(usercode)) {
throw new BusinessException("请输入用户UID");
}
Party party = this.partyService.findPartyByUsercode(usercode);
if (null == party) {
throw new BusinessException("用户不存在");
}
Party party_login = this.partyService.findPartyByUsername(this.getUsername_login());
if (party_login != null) {
List<String> childrens = this.userRecomService.findChildren(party_login.getId());
double isChildren = 0;
if (childrens != null) {
for (String children : childrens) {
if (party.getId().equals(children)) {
isChildren = 1;
}
}
}
if (isChildren == 0) {
throw new BusinessException("用户不存在或者不属于登录用户名下");
}
}
ProfitAndLossConfig profitAndLossConfig = new ProfitAndLossConfig();
profitAndLossConfig.setType(type);
profitAndLossConfig.setRemark(remark);
profitAndLossConfig.setPartyId(party.getId());
this.profitAndLossConfigService.save(profitAndLossConfig, this.getUsername_login());
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
modelAndView.addObject("usercode", usercode);
modelAndView.addObject("type", type);
modelAndView.addObject("remark", remark);
modelAndView.addObject("type_map", type_map);
modelAndView.setViewName("profit_loss_config_add");
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
modelAndView.addObject("usercode", usercode);
modelAndView.addObject("type", type);
modelAndView.addObject("remark", remark);
modelAndView.addObject("type_map", type_map);
modelAndView.setViewName("profit_loss_config_add");
return modelAndView;
}
modelAndView.addObject("message", "操作成功");
modelAndView.setViewName("redirect:/" + action + "list.action");
return modelAndView;
}
/**
* 修改 交割场控设置 页面
*/
@RequestMapping(action + "toUpdate.action")
public ModelAndView toUpdate(HttpServletRequest request) {
String id = request.getParameter("id");
ModelAndView modelAndView = new ModelAndView();
Map<String, String> type_map = Constants.PROFIT_LOSS_TYPE;
try {
ProfitAndLossConfig profitAndLossConfig = this.profitAndLossConfigService.findById(id);
Party party = this.partyService.cachePartyBy(profitAndLossConfig.getPartyId(), true);
modelAndView.addObject("id", id);
modelAndView.addObject("type", profitAndLossConfig.getType());
modelAndView.addObject("remark", profitAndLossConfig.getRemark());
modelAndView.addObject("username", party.getUsername());
modelAndView.addObject("usercode", party.getUsercode());
modelAndView.addObject("type_map", type_map);
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
modelAndView.setViewName("redirect:/" + action + "list.action");
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
modelAndView.setViewName("redirect:/" + action + "list.action");
return modelAndView;
}
modelAndView.setViewName("profit_loss_config_update");
return modelAndView;
}
/**
* 修改 交割场控设置
*/
@RequestMapping(action + "update.action")
public ModelAndView update(HttpServletRequest request) {
String id = request.getParameter("id");
String type = request.getParameter("type");
String remark = request.getParameter("remark");
String username = request.getParameter("username");
String usercode = request.getParameter("usercode");
ModelAndView modelAndView = new ModelAndView();
Map<String, String> type_map = Constants.PROFIT_LOSS_TYPE;
try {
ProfitAndLossConfig profitAndLossConfig = this.profitAndLossConfigService.findById(id);
Party party = this.partyService.cachePartyBy(profitAndLossConfig.getPartyId(), true);
if (null == party) {
throw new BusinessException("用户不存在");
}
Party party_login = this.partyService.findPartyByUsername(this.getUsername_login());
if (party_login != null) {
List<String> childrens = this.userRecomService.findChildren(party_login.getId());
double isChildren = 0;
if (childrens != null) {
for (String children : childrens) {
if (party.getId().equals(children)) {
isChildren = 1;
}
}
}
if (0 == isChildren) {
throw new BusinessException("用户不存在或者不属于登录用户名下");
}
}
profitAndLossConfig.setRemark(remark);
profitAndLossConfig.setType(type);
this.profitAndLossConfigService.update(profitAndLossConfig, this.getUsername_login());
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
modelAndView.addObject("id", id);
modelAndView.addObject("type", type);
modelAndView.addObject("remark", remark);
modelAndView.addObject("username", username);
modelAndView.addObject("usercode", usercode);
modelAndView.addObject("type_map", type_map);
modelAndView.setViewName("profit_loss_config_update");
return modelAndView;
} catch (Throwable t) {
logger.error(" error ", t);
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
modelAndView.addObject("id", id);
modelAndView.addObject("type", type);
modelAndView.addObject("remark", remark);
modelAndView.addObject("username", username);
modelAndView.addObject("usercode", usercode);
modelAndView.addObject("type_map", type_map);
modelAndView.setViewName("profit_loss_config_update");
return modelAndView;
}
modelAndView.addObject("message", "操作成功");
modelAndView.setViewName("redirect:/" + action + "list.action");
return modelAndView;
}
/**
* 删除 交割场控设置
*/
@RequestMapping(action + "toDelete.action")
public ModelAndView toDelete(HttpServletRequest request) {
String id = request.getParameter("id");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
ProfitAndLossConfig profitAndLossConfig = this.profitAndLossConfigService.findById(id);
Party party = this.partyService.cachePartyBy(profitAndLossConfig.getPartyId(), true);
if (null == party) {
throw new BusinessException("用户不存在");
}
Party party_login = this.partyService.findPartyByUsername(this.getUsername_login());
if (party_login != null) {
List<String> childrens = this.userRecomService.findChildren(party_login.getId());
double isChildren = 0;
if (childrens != null) {
for (String children : childrens) {
if (party.getId().equals(children)) {
isChildren = 1;
}
}
}
if (0 == isChildren) {
throw new BusinessException("用户不存在或者不属于登录用户名下");
}
}
this.profitAndLossConfigService.delete(id, this.getUsername_login());
} catch (BusinessException e) {
modelAndView.addObject("error", e.getMessage());
return modelAndView;
} catch (Throwable t) {
logger.error("update error ", t);
modelAndView.addObject("error", "程序错误");
return modelAndView;
}
modelAndView.addObject("message", "操作成功");
return modelAndView;
}
// public String toProductProfitLoss() {
// profit_loss_symbol = sysparaService.find("profit_loss_symbol").getValue();
// profit_loss_type = sysparaService.find("profit_loss_type").getValue();
// for (Item item : itemService.cacheGetAll()) {
// symbol_map.put(item.getSymbol(), item.getSymbol());
// }
// return "profitLossProduct";
// }
// public String updateProductProfitLoss() {
// try {
// Syspara profit_loss_symbol_sys = sysparaService.find("profit_loss_symbol");
// String old_profit_loss_symbol = profit_loss_symbol_sys.getValue();
// profit_loss_symbol_sys.setValue(profit_loss_symbol);
// sysparaService.update(profit_loss_symbol_sys);
//
// Syspara profit_loss_type_sys = sysparaService.find("profit_loss_type");
// String old_profit_loss_type = profit_loss_type_sys.getValue();
// profit_loss_type_sys.setValue(profit_loss_type);
// sysparaService.update(profit_loss_type_sys);
// project.log.Log log = new project.log.Log();
// log.setCategory(Constants.LOG_CATEGORY_OPERATION);
// log.setOperator(this.getUsername_login());
//// log.setUsername(party.getUsername());
//// log.setPartyId(entity.getPartyId());
// log.setCreateTime(new Date());
// log.setLog("管理员手动修改产品交割场控。原场控币种[" + old_profit_loss_symbol + "],修改后场控币种为[" + profit_loss_symbol + "]."
// + "原币种交割场控类型[" + Constants.PROFIT_LOSS_TYPE.get(old_profit_loss_type) + "],修改后币种交割场控类型["
// + Constants.PROFIT_LOSS_TYPE.get(profit_loss_type) + "]");
// this.logService.saveSync(log);
//
// this.message = "操作成功";
// } catch (BusinessException e) {
// this.error = e.getMessage();
// } catch (Throwable t) {
// logger.error("update error ", t);
// this.error = "程序错误";
// }
// return toProductProfitLoss();
// }
}

View File

@@ -0,0 +1,327 @@
package project.web.api;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
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.BeanUtils;
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.sessiontoken.SessionTokenService;
import kernel.util.StringUtils;
import kernel.util.ThreadUtils;
import kernel.web.BaseAction;
import kernel.web.ResultObject;
import project.futures.FuturesLock;
import project.futures.FuturesOrder;
import project.futures.FuturesOrderLocalService;
import project.futures.FuturesOrderService;
import project.futures.FuturesPara;
import project.futures.FuturesParaService;
import project.party.PartyService;
import project.party.model.Party;
import project.wallet.Wallet;
import project.wallet.WalletService;
/**
* 交割合约订单
*/
@RestController
@CrossOrigin
public class FuturesOrderController extends BaseAction {
private Logger logger = LogManager.getLogger(FuturesOrderController.class);
@Autowired
private WalletService walletService;
@Autowired
private PartyService partyService;
@Autowired
private FuturesOrderService futuresOrderService;
@Autowired
private FuturesOrderLocalService futuresOrderLocalService;
@Autowired
private FuturesParaService futuresParaService;
@Autowired
private SessionTokenService sessionTokenService;
private final String action = "/api/futuresOrder!";
/**
* 开仓页面参数
*
* symbol 币种
*/
@RequestMapping(action + "openview.action")
public Object openview(HttpServletRequest request) throws IOException {
String symbol = request.getParameter("symbol");
ResultObject resultObject = new ResultObject();
try {
Map<String, Object> data = new HashMap<String, Object>();
List<Map> futuresPara = new ArrayList<Map>();
for (FuturesPara obj : this.futuresParaService.cacheGetBySymbolSort(symbol)) {
FuturesPara para = new FuturesPara();
BeanUtils.copyProperties(obj, para);
futuresPara.add(this.futuresParaService.bulidOne(para));
}
data.put("para", futuresPara);
String partyId = this.getLoginPartyId();
if (!StringUtils.isNullOrEmpty(partyId) && futuresPara != null) {
Wallet wallet = this.walletService.saveWalletByPartyId(this.getLoginPartyId());
// 账户剩余资金
DecimalFormat df = new DecimalFormat("#");
data.put("amount", df.format(wallet.getMoney()));
String session_token = this.sessionTokenService.savePut(partyId);
data.put("session_token", session_token);
} else {
data.put("amount", 0);
}
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;
}
/**
* 开仓
*
* symbol 币种
* direction "buy":多 "sell":空
* amount 委托数量(张)
* para_id 交割合约参数
*/
@RequestMapping(action + "open.action")
public Object open(HttpServletRequest request) throws IOException {
String session_token = request.getParameter("session_token");
String symbol = request.getParameter("symbol");
String direction = request.getParameter("direction");
String amount = request.getParameter("amount");
String para_id = request.getParameter("para_id");
ResultObject resultObject = new ResultObject();
resultObject = this.readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
String partyId = this.getLoginPartyId();
boolean lock = false;
try {
Map<String, String> data = new HashMap<String, String>();
if (!FuturesLock.add(partyId)) {
throw new BusinessException("请稍后再试");
}
lock = true;
Object object = this.sessionTokenService.cacheGet(session_token);
this.sessionTokenService.delete(session_token);
if (null == object || !this.getLoginPartyId().equals((String) object)) {
throw new BusinessException("请稍后再试");
}
if (StringUtils.isNullOrEmpty(amount)) {
return "委托数量(张)必填";
}
if (!StringUtils.isDouble(amount)) {
return "委托数量(张)不是浮点数";
}
if (Double.valueOf(amount).doubleValue() <= 0) {
return "委托数量(张)不能小于等于0";
}
double amount_double = Double.valueOf(request.getParameter("amount")).doubleValue();
Party party = this.partyService.cachePartyBy(partyId, false);
if (!party.getEnabled()) {
resultObject.setCode("506");
resultObject.setMsg("用户已锁定");
return resultObject;
}
FuturesOrder order = new FuturesOrder();
order.setPartyId(partyId);
order.setSymbol(symbol);
order.setDirection(direction);
order.setVolume(amount_double);
order = this.futuresOrderService.saveOpen(order, para_id);
data.put("order_no", order.getOrder_no());
data.put("open_price", order.getTrade_avg_price().toString());
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);
} finally {
if (lock) {
ThreadUtils.sleep(100);
FuturesLock.remove(partyId);
}
}
return resultObject;
}
/**
* 查询交割持仓列表
*
* page_no 页码
* symbol 币种
* type 开仓页面订单类型
*/
@RequestMapping(action + "list.action")
public Object list(HttpServletRequest request) throws IOException {
String page_no = request.getParameter("page_no");
String symbol = request.getParameter("symbol");
String type = request.getParameter("type");
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
ResultObject resultObject = new ResultObject();
resultObject = this.readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
resultObject.setData(data);
return resultObject;
}
try {
String loginPartyId = this.getLoginPartyId();
if ("orders".equals(type)) {
List<FuturesOrder> list = this.futuresOrderService.cacheSubmitted();
List<FuturesOrder> result = new LinkedList<FuturesOrder>();
if (StringUtils.isNotEmpty(loginPartyId)) {
// 登录才添加到列表
for (FuturesOrder order : list) {
if (StringUtils.isNotEmpty(symbol)) {
// 有种类,满足登录人和种类添加
if (symbol.equals(order.getSymbol()) && loginPartyId.equals(order.getPartyId())) {
result.add(order);
}
} else {
if (loginPartyId.equals(order.getPartyId())) {
result.add(order);
}
}
}
}
data = this.futuresOrderService.bulidData(result);
} else if ("hisorders".equals(type)) {
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<FuturesOrder> list = this.futuresOrderService.getPaged(page_no_int, 10, this.getLoginPartyId(), symbol, type).getElements();
data = this.futuresOrderService.bulidData(list);
}
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;
}
/**
* 查询交割持仓详情
*
* order_no 订单号
*/
@RequestMapping(action + "get.action")
public Object get(HttpServletRequest request) throws IOException {
String order_no = request.getParameter("order_no");
ResultObject resultObject = new ResultObject();
resultObject = this.readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
try {
if (StringUtils.isNullOrEmpty(order_no)) {
logger.info("futuresOrder!get order_no null");
throw new BusinessException("订单不存在");
}
FuturesOrder order = this.futuresOrderLocalService.cacheByOrderNo(order_no);
if (null == order) {
logger.info("futuresOrder!get order_no:" + order_no + ", order null");
throw new BusinessException("订单不存在");
}
resultObject.setData(this.futuresOrderLocalService.bulidOne(order));
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
} catch (Throwable t) {
resultObject.setCode("1");
resultObject.setMsg("程序错误");
logger.error("error:", t);
}
return resultObject;
}
}