first commit
This commit is contained in:
3
comm/Finance/WebContent/META-INF/MANIFEST.MF
Executable file
3
comm/Finance/WebContent/META-INF/MANIFEST.MF
Executable file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
252
comm/Finance/WebContent/finance_add.jsp
Executable file
252
comm/Finance/WebContent/finance_add.jsp
Executable file
@@ -0,0 +1,252 @@
|
||||
<%@ 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/adminFinanceAction!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>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">
|
||||
新增理财产品
|
||||
<ul class="panel-tools">
|
||||
<li><a class="icon minimise-tool"><i
|
||||
class="fa fa-minus"></i></a></li>
|
||||
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminFinanceAction!add.action"
|
||||
method="post" name="mainForm" id="mainForm">
|
||||
<s:hidden name="id" id="id"></s:hidden>
|
||||
<s:hidden name="img" id="img"></s:hidden>
|
||||
<h5>基础信息</h5>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品名称(简体中文)</label>
|
||||
<div class="col-sm-3">
|
||||
<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-3">
|
||||
<s:textfield id="name_cn" name="name_cn" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品名称(英文)</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="name_en" name="name_en" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品名称(韩语)</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="name_kn" name="name_kn" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品名称(日语)</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="name_jn" name="name_jn" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品图片</label>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<input type="file" id="fileName" name="fileName" onchange="upload();" style="position:absolute;opacity:0;">
|
||||
<label for="fileName">
|
||||
|
||||
<img width="90px" height="90px" id="show_img"
|
||||
|
||||
src="<%=base%>/image/add.png" alt="点击上传图片" />
|
||||
|
||||
</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<h5>交易信息</h5>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">状态</label>
|
||||
<div class="col-sm-3">
|
||||
<div class="input-group">
|
||||
<s:select id="state" cssClass="form-control "
|
||||
name="state" list="#{'0':'停用','1':'启用'}"
|
||||
listKey="key" listValue="value" value="state" />
|
||||
</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="cycle" name="cycle" 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">
|
||||
<div class="input-group">
|
||||
|
||||
<s:textfield id="daily_rate" name="daily_rate" cssClass="form-control " />
|
||||
|
||||
<div class="input-group-addon">--</div>
|
||||
<s:textfield id="daily_rate_max" name="daily_rate_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-3">
|
||||
<div class="input-group">
|
||||
<s:textfield id="today_rate" name="today_rate" 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">
|
||||
<div class="input-group">
|
||||
<s:textfield id="default_ratio" name="default_ratio" 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">
|
||||
<div class="input-group">
|
||||
<s:textfield id="investment_min" name="investment_min" cssClass="form-control " />
|
||||
<div class="input-group-addon">--</div>
|
||||
<s:textfield id="investment_max" name="investment_max" cssClass="form-control " />
|
||||
<div class="input-group-addon">USDT</div>
|
||||
|
||||
</div>
|
||||
</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 submit() {
|
||||
swal({
|
||||
title : "是否保存?",
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
}, function() {
|
||||
document.getElementById("mainForm").submit();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function upload(){
|
||||
var fileReader = new FileReader();
|
||||
var formData = new FormData();
|
||||
var file = document.getElementById('fileName').files[0];
|
||||
formData.append("file", file);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=basePath%>normal/uploadimg!execute.action?random="
|
||||
+ Math.random(),
|
||||
data: formData,
|
||||
dataType: "json",
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success : function(data) {
|
||||
console.log(data);
|
||||
$("#img").val(data.data)
|
||||
var show_img = document.getElementById('show_img');
|
||||
show_img.src="<%=base%>wap/public/showimg!showImg.action?imagePath="+data.data;
|
||||
|
||||
},
|
||||
error : function(XMLHttpRequest, textStatus,
|
||||
errorThrown) {
|
||||
console.log("请求错误");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
177
comm/Finance/WebContent/finance_list.jsp
Executable file
177
comm/Finance/WebContent/finance_list.jsp
Executable file
@@ -0,0 +1,177 @@
|
||||
<%@ 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">
|
||||
|
||||
<form class="form-horizontal" action="<%=basePath%>normal/adminFinanceAction!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="产品名称"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 col-lg-2">
|
||||
<button type="submit" class="btn btn-light btn-block">查询</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<!-- Start Panel -->
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询结果</div>
|
||||
<a href="<%=basePath%>normal/adminFinanceAction!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>周期(天)</td>
|
||||
<td>日利率(%)</td>
|
||||
<td>今日利率(%)</td>
|
||||
<td>违约结算比例(%)</td>
|
||||
<td>投资金额区间(USDT)</td>
|
||||
<td>状态</td>
|
||||
<td width="130px"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<s:iterator value="page.elements" status="stat">
|
||||
<tr>
|
||||
<td><s:property value="name" /></td>
|
||||
<td><s:property value="name_en" /></td>
|
||||
<!-- <td>
|
||||
<a href="<%=base%>wap/public/showimg!showImg.action?imagePath=<s:property value="img" />" target="_blank">查看照片</a>
|
||||
|
||||
</td> -->
|
||||
<td>
|
||||
<img width="40px" height="40px" src="<%=base%>wap/public/showimg!showImg.action?imagePath=<s:property value="img" />" />
|
||||
</td>
|
||||
<td><s:property value="cycle" /></td>
|
||||
<td><s:property value="daily_rate" />--<s:property value="daily_rate_max" /></td>
|
||||
<td><s:property value="today_rate" /></td>
|
||||
<td><s:property value="default_ratio" /></td>
|
||||
<td><s:property value="investment_min" />--<s:property value="investment_max" /></td>
|
||||
<td><s:if test='state=="1"'><span class="right label label-success">启用</span></s:if>
|
||||
<s:if test='state=="0"'>
|
||||
<span class="right label label-danger">停用</span>
|
||||
</s:if></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="<%=basePath%>normal/adminFinanceAction!toUpdate.action?id=<s:property value="id" />">修改</a></li>
|
||||
<!--
|
||||
<li><a href="<%=basePath%>normal/adminFinanceAction!toDelete.action?id=<s:property value="id" />">删除</a></li>
|
||||
-->
|
||||
</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>
|
||||
301
comm/Finance/WebContent/finance_order_list.jsp
Executable file
301
comm/Finance/WebContent/finance_order_list.jsp
Executable file
@@ -0,0 +1,301 @@
|
||||
<%@ 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_FINANCE_ORDER_LIST")'>
|
||||
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminFinanceOrderAction!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:textfield id="finance_para" name="finance_para" cssClass="form-control " placeholder="理财产品名称"/>
|
||||
</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('0')">赎回</a></li>
|
||||
<li><a href="javascript:setState('1')"> 托管中</a></li>
|
||||
<li><a href="javascript:setState('2')">违约</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 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="order_no" /></td> --%>
|
||||
<td><s:property value="finance_name" /></td>
|
||||
<td><s:property value="finance_name_en" /></td>
|
||||
|
||||
<td><fmt:formatNumber value="${amount}" pattern="#0.00" /></td>
|
||||
<td>
|
||||
<s:if test="profit < 0">
|
||||
<span class="right label label-danger"><fmt:formatNumber
|
||||
value="${profit}" pattern="#0.00" /> </span>
|
||||
</s:if>
|
||||
<s:else>
|
||||
<span class="right label label-success"><fmt:formatNumber
|
||||
value="${profit}" pattern="#0.00" /> </span>
|
||||
</s:else>
|
||||
</td>
|
||||
<td><s:date name="create_time" format="YYYY-MM-dd HH:mm:ss " /></td>
|
||||
<td><s:date name="close_time" format="YYYY-MM-dd HH:mm:ss " /></td>
|
||||
|
||||
<td>
|
||||
<s:if test='state=="2"'>
|
||||
<span class="right label label-danger">违约(提前赎回)</span>
|
||||
</s:if>
|
||||
<s:if test='state=="1"'>
|
||||
<span class="right label label-success">托管中</span>
|
||||
</s:if>
|
||||
<s:if test='state=="0"'>
|
||||
赎回
|
||||
</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>
|
||||
<s:if test='state=="1"'>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<s:if test='isResourceAccessible("ADMIN_FINANCE_ORDER_CLOSE")'>
|
||||
<li><a href="javascript:onclose('<s:property value="id" />')">赎回</a></li>
|
||||
</s:if>
|
||||
</ul>
|
||||
</s:if>
|
||||
|
||||
|
||||
|
||||
</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_ADMIN,ROLE_ROOT">
|
||||
<s:if test='isResourceAccessible("ADMIN_FINANCE_ORDER_CLOSE")'>
|
||||
<form action="normal/adminFinanceOrderAction!close.action" method="post"
|
||||
id="onclose">
|
||||
<input type="hidden" name="pageNo" id="pageNo" value="${param.pageNo}">
|
||||
<s:hidden name="id" id="id"></s:hidden>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
function onclose(id) {
|
||||
$("#id").val(id);
|
||||
swal({
|
||||
title : "是否确认赎回?",
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
}, function() {
|
||||
document.getElementById("onclose").submit();
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
</s:if>
|
||||
</sec:authorize>
|
||||
<script type="text/javascript">
|
||||
function setState(state){
|
||||
document.getElementById("status_para").value=state;
|
||||
document.getElementById("queryForm").submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
258
comm/Finance/WebContent/finance_update.jsp
Executable file
258
comm/Finance/WebContent/finance_update.jsp
Executable file
@@ -0,0 +1,258 @@
|
||||
<%@ 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/adminFinanceAction!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>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">
|
||||
修改理财产品
|
||||
<ul class="panel-tools">
|
||||
<li><a class="icon minimise-tool"><i
|
||||
class="fa fa-minus"></i></a></li>
|
||||
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminFinanceAction!update.action"
|
||||
method="post" name="mainForm" id="mainForm">
|
||||
<s:hidden name="id" id="id"></s:hidden>
|
||||
<s:hidden name="img" id="img"></s:hidden>
|
||||
|
||||
<h5>基础信息</h5>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品名称(简体中文)</label>
|
||||
<div class="col-sm-3">
|
||||
<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-3">
|
||||
<s:textfield id="name_cn" name="name_cn" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品名称(英文)</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="name_en" name="name_en" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品名称(韩语)</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="name_kn" name="name_kn" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品名称(日语)</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="name_jn" name="name_jn" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">产品图片</label>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<input type="file" id="fileName" name="fileName" onchange="upload();" style="position:absolute;opacity:0;">
|
||||
<label for="fileName">
|
||||
|
||||
<img width="90px" height="90px" id="show_img"
|
||||
|
||||
src="<%=base%>/image/add.png" alt="点击上传图片" />
|
||||
|
||||
</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<h5>交易信息</h5>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">状态</label>
|
||||
<div class="col-sm-3">
|
||||
<div class="input-group">
|
||||
<s:select id="state" cssClass="form-control "
|
||||
name="state" list="#{'0':'停用','1':'启用'}"
|
||||
listKey="key" listValue="value" value="state" />
|
||||
</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="cycle" name="cycle" 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">
|
||||
<div class="input-group">
|
||||
<s:textfield id="daily_rate" name="daily_rate" cssClass="form-control " />
|
||||
|
||||
<div class="input-group-addon">--</div>
|
||||
<s:textfield id="daily_rate_max" name="daily_rate_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-3">
|
||||
<div class="input-group">
|
||||
<s:textfield id="today_rate" name="today_rate" 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">
|
||||
<div class="input-group">
|
||||
<s:textfield id="default_ratio" name="default_ratio" 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">
|
||||
<div class="input-group">
|
||||
<s:textfield id="investment_min" name="investment_min" cssClass="form-control " />
|
||||
<div class="input-group-addon">--</div>
|
||||
<s:textfield id="investment_max" name="investment_max" cssClass="form-control " />
|
||||
<div class="input-group-addon">USDT</div>
|
||||
|
||||
</div>
|
||||
</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 submit() {
|
||||
swal({
|
||||
title : "是否保存?",
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
}, function() {
|
||||
document.getElementById("mainForm").submit();
|
||||
});
|
||||
|
||||
}
|
||||
//初始化执行一次
|
||||
setTimeout(function() {
|
||||
start();
|
||||
}, 100);
|
||||
function start(){
|
||||
var img = $("#img").val();
|
||||
var show_img = document.getElementById('show_img');
|
||||
show_img.src="<%=base%>wap/public/showimg!showImg.action?imagePath="+img;
|
||||
}
|
||||
|
||||
|
||||
function upload(){
|
||||
var fileReader = new FileReader();
|
||||
var formData = new FormData();
|
||||
var file = document.getElementById('fileName').files[0];
|
||||
formData.append("file", file);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=basePath%>normal/uploadimg!execute.action?random="
|
||||
+ Math.random(),
|
||||
data: formData,
|
||||
dataType: "json",
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success : function(data) {
|
||||
console.log(data);
|
||||
$("#img").val(data.data)
|
||||
var show_img = document.getElementById('show_img');
|
||||
show_img.src="<%=base%>wap/public/showimg!showImg.action?imagePath="+data.data;
|
||||
|
||||
},
|
||||
error : function(XMLHttpRequest, textStatus,
|
||||
errorThrown) {
|
||||
console.log("请求错误");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
35
comm/Finance/config/spring/applicationContext-finance.xml
Executable file
35
comm/Finance/config/spring/applicationContext-finance.xml
Executable file
@@ -0,0 +1,35 @@
|
||||
<?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="financeService"
|
||||
class="project.finance.internal.FinanceServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
<bean id="financeOrderService"
|
||||
class="project.finance.internal.FinanceOrderServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="walletService" ref="walletService" />
|
||||
<property name="moneyLogService" ref="moneyLogService" />
|
||||
<property name="financeService" ref="financeService" />
|
||||
<property name="pagedDao" ref="pagedDao" />
|
||||
<property name="userDataService" ref="userDataService" />
|
||||
<property name="partyService" ref="partyService" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</beans>
|
||||
48
comm/Finance/config/spring/applicationContext-finance_admin.xml
Executable file
48
comm/Finance/config/spring/applicationContext-finance_admin.xml
Executable file
@@ -0,0 +1,48 @@
|
||||
<?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="adminFinanceService"
|
||||
class="project.finance.internal.AdminFinanceServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="adminFinanceOrderService"
|
||||
class="project.finance.internal.AdminFinanceOrderServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="userRecomService" ref="userRecomService" />
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="financeService"
|
||||
class="project.finance.internal.FinanceServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
<bean id="financeOrderService"
|
||||
class="project.finance.internal.FinanceOrderServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="walletService" ref="walletService" />
|
||||
<property name="moneyLogService" ref="moneyLogService" />
|
||||
<property name="financeService" ref="financeService" />
|
||||
<property name="pagedDao" ref="pagedDao" />
|
||||
<property name="userDataService" ref="userDataService" />
|
||||
<property name="partyService" ref="partyService" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</beans>
|
||||
44
comm/Finance/config/spring/applicationContext-finance_data.xml
Executable file
44
comm/Finance/config/spring/applicationContext-finance_data.xml
Executable file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<!-- init-method="init" -->
|
||||
|
||||
<bean id="financeService"
|
||||
class="project.finance.internal.FinanceServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="financeOrderService"
|
||||
class="project.finance.internal.FinanceOrderServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="walletService" ref="walletService" />
|
||||
<property name="moneyLogService" ref="moneyLogService" />
|
||||
<property name="financeService" ref="financeService" />
|
||||
<property name="pagedDao" ref="pagedDao" />
|
||||
<property name="userDataService" ref="userDataService" />
|
||||
<property name="partyService" ref="partyService" />
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="financeLoadCacheService"
|
||||
class="data.loadcache.FinanceLoadCacheService">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
<bean id="financeOrder1DayJob" class="project.finance.job.FinanceOrder1DayJob">
|
||||
<property name="financeOrderService" ref="financeOrderService" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
</beans>
|
||||
14
comm/Finance/config/spring/applicationContext-hibernate.xml
Executable file
14
comm/Finance/config/spring/applicationContext-hibernate.xml
Executable file
@@ -0,0 +1,14 @@
|
||||
admin
|
||||
|
||||
<!-- fincance -->
|
||||
<value>financeService</value>
|
||||
<value>financeOrderService</value>
|
||||
<value>adminFinanceService</value>
|
||||
<value>adminFinanceOrderService</value>
|
||||
|
||||
|
||||
api
|
||||
|
||||
<!-- fincance -->
|
||||
<value>financeService</value>
|
||||
<value>financeOrderService</value>
|
||||
22
comm/Finance/config/spring/normal.xml
Executable file
22
comm/Finance/config/spring/normal.xml
Executable file
@@ -0,0 +1,22 @@
|
||||
admin
|
||||
|
||||
<action name="adminFinanceAction"
|
||||
class="project.finance.web.AdminFinanceAction">
|
||||
<result name="list">/finance_list.jsp</result>
|
||||
<result name="add">/finance_add.jsp</result>
|
||||
<result name="update">/finance_update.jsp</result>
|
||||
</action>
|
||||
<action name="adminFinanceOrderAction"
|
||||
class="project.finance.web.AdminFinanceOrderAction">
|
||||
<result name="holdings">/finance_order_holdings_list.jsp</result>
|
||||
<result name="list">/finance_order_list.jsp</result>
|
||||
</action>
|
||||
|
||||
api
|
||||
|
||||
<action name="finance"
|
||||
class="project.finance.web.FinanceAction">
|
||||
</action>
|
||||
<action name="financeOrder"
|
||||
class="project.finance.web.FinanceOrderAction">
|
||||
</action>
|
||||
53
comm/Finance/dbscript/1.0/FINANCE-DDL-MYSQL.SQL
Executable file
53
comm/Finance/dbscript/1.0/FINANCE-DDL-MYSQL.SQL
Executable file
@@ -0,0 +1,53 @@
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
-- ----------------------------
|
||||
-- Table structure for `T_FINANCE`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `T_FINANCE`;
|
||||
CREATE TABLE `T_FINANCE` (
|
||||
`UUID` varchar(32) CHARACTER SET utf8 NOT NULL,
|
||||
`NAME` varchar(32) DEFAULT NULL,
|
||||
`IMG` varchar(64) DEFAULT NULL,
|
||||
`CYCLE` varchar(32) DEFAULT NULL,
|
||||
`DAILY_RATE` double DEFAULT NULL,
|
||||
`TODAY_RATE` double DEFAULT NULL,
|
||||
`DEFAULT_RATIO` double DEFAULT NULL,
|
||||
`INVESTMENT_MIN` double DEFAULT NULL,
|
||||
`INVESTMENT_MAX` double DEFAULT NULL,
|
||||
`STATE` varchar(32) DEFAULT NULL,
|
||||
|
||||
PRIMARY KEY (`UUID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `T_FINANCE_ORDER`;
|
||||
CREATE TABLE `T_FINANCE_ORDER` (
|
||||
`UUID` varchar(32) CHARACTER SET utf8 NOT NULL,
|
||||
`PARTY_ID` varchar(32) ,
|
||||
`ORDER_NO` varchar(64) ,
|
||||
`FINANCE_ID` varchar(32) ,
|
||||
`CYCLE` int ,
|
||||
`AMOUNT` double ,
|
||||
`EARN_TIME` datetime ,
|
||||
`STOP_TIME` datetime ,
|
||||
`CREATE_TIME` datetime ,
|
||||
`CLOSE_TIME` datetime ,
|
||||
`PROFIT` double ,
|
||||
`STATE` varchar(32) DEFAULT NULL,
|
||||
|
||||
PRIMARY KEY (`UUID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `T_FINANCE`
|
||||
ADD COLUMN `NAME_EN` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `NAME`,
|
||||
ADD COLUMN `NAME_CN` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `NAME_EN`;
|
||||
ALTER TABLE `T_FINANCE`
|
||||
ADD COLUMN `DAILY_RATE_MAX` double NULL DEFAULT 0;
|
||||
|
||||
update T_FINANCE finance set finance.DAILY_RATE_MAX = finance.DAILY_RATE
|
||||
where finance.DAILY_RATE_MAX = 0
|
||||
13
comm/Finance/src/project/finance/AdminFinanceOrderService.java
Executable file
13
comm/Finance/src/project/finance/AdminFinanceOrderService.java
Executable file
@@ -0,0 +1,13 @@
|
||||
package project.finance;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminFinanceOrderService {
|
||||
|
||||
/**
|
||||
* 代理分页查询
|
||||
*
|
||||
*/
|
||||
public Page pagedQuery(int pageNo, int pageSize, String username_para, String finance_para, String status_para,
|
||||
String partyId,String orderNo,String rolename_para);
|
||||
}
|
||||
12
comm/Finance/src/project/finance/AdminFinanceService.java
Executable file
12
comm/Finance/src/project/finance/AdminFinanceService.java
Executable file
@@ -0,0 +1,12 @@
|
||||
package project.finance;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminFinanceService {
|
||||
|
||||
/**
|
||||
* 代理分页查询
|
||||
*
|
||||
*/
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para);
|
||||
}
|
||||
64
comm/Finance/src/project/finance/Finance.hbm.xml
Executable file
64
comm/Finance/src/project/finance/Finance.hbm.xml
Executable file
@@ -0,0 +1,64 @@
|
||||
<?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.finance.Finance" table="T_FINANCE">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
|
||||
<property name="name" type="java.lang.String">
|
||||
<column name="NAME" />
|
||||
</property>
|
||||
<property name="name_en" type="java.lang.String">
|
||||
<column name="NAME_EN" />
|
||||
</property>
|
||||
<property name="name_cn" type="java.lang.String">
|
||||
<column name="NAME_CN" />
|
||||
</property>
|
||||
<property name="name_kn" type="java.lang.String">
|
||||
<column name="NAME_KN" />
|
||||
</property>
|
||||
<property name="name_jn" type="java.lang.String">
|
||||
<column name="NAME_JN" />
|
||||
</property>
|
||||
|
||||
|
||||
<property name="img" type="java.lang.String">
|
||||
<column name="IMG" />
|
||||
</property>
|
||||
|
||||
<property name="cycle" type="java.lang.Integer">
|
||||
<column name="CYCLE" />
|
||||
</property>
|
||||
<property name="daily_rate" type="double">
|
||||
<column name="DAILY_RATE" />
|
||||
</property>
|
||||
<property name="daily_rate_max" type="double">
|
||||
<column name="DAILY_RATE_MAX" />
|
||||
</property>
|
||||
|
||||
|
||||
<property name="today_rate" type="double">
|
||||
<column name="TODAY_RATE" />
|
||||
</property>
|
||||
|
||||
<property name="default_ratio" type="double">
|
||||
<column name="DEFAULT_RATIO" />
|
||||
</property>
|
||||
<property name="investment_min" type="double">
|
||||
<column name="INVESTMENT_MIN" />
|
||||
</property>
|
||||
<property name="investment_max" type="double">
|
||||
<column name="INVESTMENT_MAX" />
|
||||
</property>
|
||||
|
||||
|
||||
|
||||
<property name="state" type="java.lang.String">
|
||||
<column name="STATE" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
191
comm/Finance/src/project/finance/Finance.java
Executable file
191
comm/Finance/src/project/finance/Finance.java
Executable file
@@ -0,0 +1,191 @@
|
||||
package project.finance;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class Finance extends EntityObject {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1639941028310043811L;
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 产品名称英文
|
||||
*/
|
||||
private String name_en;
|
||||
/**
|
||||
* 产品名称繁体
|
||||
*/
|
||||
private String name_cn;
|
||||
/**
|
||||
* 产品名称 韩语
|
||||
*/
|
||||
private String name_kn;
|
||||
/**
|
||||
* 产品名称 日语
|
||||
*/
|
||||
private String name_jn;
|
||||
|
||||
/**
|
||||
* 产品图片
|
||||
*/
|
||||
private String img;
|
||||
/**
|
||||
* 周期-天数
|
||||
*/
|
||||
private int cycle;
|
||||
|
||||
/**
|
||||
* 日利率最低(%)
|
||||
*/
|
||||
private double daily_rate;
|
||||
/**
|
||||
* 日利率最高(%)
|
||||
*/
|
||||
private double daily_rate_max;
|
||||
/**
|
||||
* 今日利率(%)
|
||||
*
|
||||
*/
|
||||
private double today_rate;
|
||||
|
||||
/**
|
||||
* 违约结算比例(%)
|
||||
*/
|
||||
private double default_ratio;
|
||||
|
||||
/**
|
||||
* 投资金额区间(USDT)
|
||||
*/
|
||||
private double investment_min;
|
||||
/**
|
||||
* 投资金额区间(USDT)
|
||||
*/
|
||||
private double investment_max;
|
||||
|
||||
/**
|
||||
* 状态。0 停用, 1 启用
|
||||
*/
|
||||
private String state = "0";
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getImg() {
|
||||
return img;
|
||||
}
|
||||
|
||||
public void setImg(String img) {
|
||||
this.img = img;
|
||||
}
|
||||
|
||||
public int getCycle() {
|
||||
return cycle;
|
||||
}
|
||||
|
||||
public void setCycle(int cycle) {
|
||||
this.cycle = cycle;
|
||||
}
|
||||
|
||||
public void setDaily_rate(int daily_rate) {
|
||||
this.daily_rate = daily_rate;
|
||||
}
|
||||
|
||||
public double getDefault_ratio() {
|
||||
return default_ratio;
|
||||
}
|
||||
|
||||
public void setDefault_ratio(double default_ratio) {
|
||||
this.default_ratio = default_ratio;
|
||||
}
|
||||
|
||||
public double getDaily_rate() {
|
||||
return daily_rate;
|
||||
}
|
||||
|
||||
public void setDaily_rate(double daily_rate) {
|
||||
this.daily_rate = daily_rate;
|
||||
}
|
||||
|
||||
public double getToday_rate() {
|
||||
return today_rate;
|
||||
}
|
||||
|
||||
public void setToday_rate(double today_rate) {
|
||||
this.today_rate = today_rate;
|
||||
}
|
||||
|
||||
public double getInvestment_min() {
|
||||
return investment_min;
|
||||
}
|
||||
|
||||
public void setInvestment_min(double investment_min) {
|
||||
this.investment_min = investment_min;
|
||||
}
|
||||
|
||||
public double getInvestment_max() {
|
||||
return investment_max;
|
||||
}
|
||||
|
||||
public void setInvestment_max(double investment_max) {
|
||||
this.investment_max = investment_max;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getName_en() {
|
||||
return name_en;
|
||||
}
|
||||
|
||||
public void setName_en(String name_en) {
|
||||
this.name_en = name_en;
|
||||
}
|
||||
|
||||
public String getName_cn() {
|
||||
return name_cn;
|
||||
}
|
||||
|
||||
public void setName_cn(String name_cn) {
|
||||
this.name_cn = name_cn;
|
||||
}
|
||||
|
||||
public String getName_kn() {
|
||||
return name_kn;
|
||||
}
|
||||
|
||||
public void setName_kn(String name_kn) {
|
||||
this.name_kn = name_kn;
|
||||
}
|
||||
|
||||
public String getName_jn() {
|
||||
return name_jn;
|
||||
}
|
||||
|
||||
public void setName_jn(String name_jn) {
|
||||
this.name_jn = name_jn;
|
||||
}
|
||||
|
||||
public double getDaily_rate_max() {
|
||||
return daily_rate_max;
|
||||
}
|
||||
|
||||
public void setDaily_rate_max(double daily_rate_max) {
|
||||
this.daily_rate_max = daily_rate_max;
|
||||
}
|
||||
|
||||
}
|
||||
53
comm/Finance/src/project/finance/FinanceOrder.hbm.xml
Executable file
53
comm/Finance/src/project/finance/FinanceOrder.hbm.xml
Executable file
@@ -0,0 +1,53 @@
|
||||
<?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.finance.FinanceOrder" table="T_FINANCE_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="order_no" type="java.lang.String">
|
||||
<column name="ORDER_NO" />
|
||||
</property>
|
||||
<property name="financeId" type="java.lang.String">
|
||||
<column name="FINANCE_ID" />
|
||||
</property>
|
||||
<property name="cycle" type="java.lang.Integer">
|
||||
<column name="CYCLE" />
|
||||
</property>
|
||||
|
||||
<property name="earn_time" type="timestamp">
|
||||
<column name="EARN_TIME" />
|
||||
</property>
|
||||
<property name="stop_time" type="timestamp">
|
||||
<column name="STOP_TIME" />
|
||||
</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="profit" type="double">
|
||||
<column name="PROFIT" />
|
||||
</property>
|
||||
<property name="profit_before" type="double">
|
||||
<column name="PROFIT_BEFORE" />
|
||||
</property>
|
||||
|
||||
|
||||
<property name="amount" type="double">
|
||||
<column name="AMOUNT" />
|
||||
</property>
|
||||
<property name="state" type="java.lang.String">
|
||||
<column name="STATE" />
|
||||
</property>
|
||||
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
313
comm/Finance/src/project/finance/FinanceOrder.java
Executable file
313
comm/Finance/src/project/finance/FinanceOrder.java
Executable file
@@ -0,0 +1,313 @@
|
||||
package project.finance;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class FinanceOrder extends EntityObject {
|
||||
|
||||
private static final long serialVersionUID = -726057340004619294L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Serializable partyId;
|
||||
|
||||
/**
|
||||
* 订单 号
|
||||
*/
|
||||
private String order_no;
|
||||
|
||||
/**
|
||||
* 理财产品名称
|
||||
*/
|
||||
private String financeName;
|
||||
|
||||
/**
|
||||
* 理财产品名称繁体
|
||||
*/
|
||||
private String financeName_cn;
|
||||
|
||||
/**
|
||||
* 理财产品名称英文
|
||||
*/
|
||||
private String financeName_en;
|
||||
|
||||
/**
|
||||
* 理财产品Id
|
||||
*/
|
||||
private String financeId;
|
||||
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private double amount;
|
||||
|
||||
/**
|
||||
* 买入时间
|
||||
*/
|
||||
private Date create_time;
|
||||
/**
|
||||
* 起息时间 从买入时间第二天开始算
|
||||
*/
|
||||
private Date earn_time;
|
||||
|
||||
/**
|
||||
* 截止时间
|
||||
*/
|
||||
private Date stop_time;
|
||||
|
||||
/**
|
||||
* 赎回时间=截止时间+1天
|
||||
*/
|
||||
private Date close_time;
|
||||
|
||||
/**
|
||||
* 收益
|
||||
*/
|
||||
private double profit;
|
||||
/**
|
||||
* 之前或累计收益
|
||||
*/
|
||||
private double profit_before;
|
||||
|
||||
/**
|
||||
* 状态。0.正常赎回, 1 托管中 ,2提前赎回 (违约)3.取消
|
||||
*/
|
||||
private String state = "1";
|
||||
/**
|
||||
* 托管时间,周期
|
||||
*/
|
||||
private int cycle;
|
||||
|
||||
/**
|
||||
* 传回前端数据,数据库不保存
|
||||
*/
|
||||
|
||||
/**
|
||||
* 理财产品图片
|
||||
*/
|
||||
|
||||
private String img;
|
||||
/**
|
||||
* 剩余天数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int days;
|
||||
/**
|
||||
* 赎回时间=截止时间+1天
|
||||
*/
|
||||
private String close_timeStr;
|
||||
/**
|
||||
* 买入时间
|
||||
*/
|
||||
private String create_timeStr;
|
||||
/**
|
||||
* 起息时间 从买入时间第二天开始算
|
||||
*/
|
||||
private String earn_timeStr;
|
||||
|
||||
/**
|
||||
* 截止时间
|
||||
*/
|
||||
private String stop_timeStr;
|
||||
|
||||
/**
|
||||
* 日利率(%)
|
||||
*/
|
||||
private String daily_rate;
|
||||
/**
|
||||
* 预计收益
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private double profit_may;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public String getOrder_no() {
|
||||
return order_no;
|
||||
}
|
||||
|
||||
public void setOrder_no(String order_no) {
|
||||
this.order_no = order_no;
|
||||
}
|
||||
|
||||
public String getFinanceId() {
|
||||
return financeId;
|
||||
}
|
||||
|
||||
public void setFinanceId(String financeId) {
|
||||
this.financeId = financeId;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public Date getCreate_time() {
|
||||
return create_time;
|
||||
}
|
||||
|
||||
public void setCreate_time(Date create_time) {
|
||||
this.create_time = create_time;
|
||||
}
|
||||
|
||||
public Date getClose_time() {
|
||||
return close_time;
|
||||
}
|
||||
|
||||
public void setClose_time(Date close_time) {
|
||||
this.close_time = close_time;
|
||||
}
|
||||
|
||||
public double getProfit() {
|
||||
return profit;
|
||||
}
|
||||
|
||||
public void setProfit(double profit) {
|
||||
this.profit = profit;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void setImg(String img) {
|
||||
this.img = img;
|
||||
}
|
||||
|
||||
public Date getEarn_time() {
|
||||
return earn_time;
|
||||
}
|
||||
|
||||
public void setEarn_time(Date earn_time) {
|
||||
this.earn_time = earn_time;
|
||||
}
|
||||
|
||||
public Date getStop_time() {
|
||||
return stop_time;
|
||||
}
|
||||
|
||||
public void setStop_time(Date stop_time) {
|
||||
this.stop_time = stop_time;
|
||||
}
|
||||
|
||||
public int getCycle() {
|
||||
return cycle;
|
||||
}
|
||||
|
||||
public void setCycle(int cycle) {
|
||||
this.cycle = cycle;
|
||||
}
|
||||
|
||||
public int getDays() {
|
||||
return days;
|
||||
}
|
||||
|
||||
public void setDays(int days) {
|
||||
this.days = days;
|
||||
}
|
||||
|
||||
public String getImg() {
|
||||
return img;
|
||||
}
|
||||
|
||||
public String getClose_timeStr() {
|
||||
return close_timeStr;
|
||||
}
|
||||
|
||||
public void setClose_timeStr(String close_timeStr) {
|
||||
this.close_timeStr = close_timeStr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getCreate_timeStr() {
|
||||
return create_timeStr;
|
||||
}
|
||||
|
||||
public void setCreate_timeStr(String create_timeStr) {
|
||||
this.create_timeStr = create_timeStr;
|
||||
}
|
||||
|
||||
public String getEarn_timeStr() {
|
||||
return earn_timeStr;
|
||||
}
|
||||
|
||||
public void setEarn_timeStr(String earn_timeStr) {
|
||||
this.earn_timeStr = earn_timeStr;
|
||||
}
|
||||
|
||||
public String getStop_timeStr() {
|
||||
return stop_timeStr;
|
||||
}
|
||||
|
||||
public void setStop_timeStr(String stop_timeStr) {
|
||||
this.stop_timeStr = stop_timeStr;
|
||||
}
|
||||
|
||||
public double getProfit_may() {
|
||||
return profit_may;
|
||||
}
|
||||
|
||||
public void setProfit_may(double profit_may) {
|
||||
this.profit_may = profit_may;
|
||||
}
|
||||
|
||||
public String getDaily_rate() {
|
||||
return daily_rate;
|
||||
}
|
||||
|
||||
public void setDaily_rate(String daily_rate) {
|
||||
this.daily_rate = daily_rate;
|
||||
}
|
||||
|
||||
public double getProfit_before() {
|
||||
return profit_before;
|
||||
}
|
||||
|
||||
public void setProfit_before(double profit_before) {
|
||||
this.profit_before = profit_before;
|
||||
}
|
||||
|
||||
public String getFinanceName() {
|
||||
return financeName;
|
||||
}
|
||||
|
||||
public void setFinanceName(String financeName) {
|
||||
this.financeName = financeName;
|
||||
}
|
||||
|
||||
public String getFinanceName_cn() {
|
||||
return financeName_cn;
|
||||
}
|
||||
|
||||
public void setFinanceName_cn(String financeName_cn) {
|
||||
this.financeName_cn = financeName_cn;
|
||||
}
|
||||
|
||||
public String getFinanceName_en() {
|
||||
return financeName_en;
|
||||
}
|
||||
|
||||
public void setFinanceName_en(String financeName_en) {
|
||||
this.financeName_en = financeName_en;
|
||||
}
|
||||
}
|
||||
22
comm/Finance/src/project/finance/FinanceOrderLock.java
Executable file
22
comm/Finance/src/project/finance/FinanceOrderLock.java
Executable file
@@ -0,0 +1,22 @@
|
||||
package project.finance;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class FinanceOrderLock {
|
||||
private static final Set<String> filter = new HashSet<String>();
|
||||
|
||||
public static boolean add(String order_no) {
|
||||
if (!filter.add(order_no)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void remove(String order_no) {
|
||||
filter.remove(order_no);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
65
comm/Finance/src/project/finance/FinanceOrderService.java
Executable file
65
comm/Finance/src/project/finance/FinanceOrderService.java
Executable file
@@ -0,0 +1,65 @@
|
||||
package project.finance;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
/**
|
||||
* 理财产品订单
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface FinanceOrderService {
|
||||
|
||||
/**
|
||||
* 下单
|
||||
*/
|
||||
public void saveCreate(FinanceOrder financeOrder);
|
||||
|
||||
/**
|
||||
* 赎回
|
||||
*/
|
||||
public void saveClose(FinanceOrder financeOrder);
|
||||
|
||||
public void saveClose(FinanceOrder financeOrder, Date systemTime);
|
||||
|
||||
/**
|
||||
* 计算当天收益
|
||||
*/
|
||||
public void addListProfit(FinanceOrder order);
|
||||
|
||||
public void addListProfit(FinanceOrder order,Date systemTime);
|
||||
|
||||
public FinanceOrder findByOrder_no(String order_no);
|
||||
|
||||
/**
|
||||
* 按订单状态查询用户订单
|
||||
*
|
||||
* @param partyId
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
|
||||
public List<FinanceOrder> findByState(String partyId, String state);
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String partyId, String state);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<FinanceOrder> getAllStateBy_1();
|
||||
|
||||
public FinanceOrder findById(String id);
|
||||
|
||||
public void update(FinanceOrder entity);
|
||||
/**
|
||||
* 根据日期获取到当日的购买订单
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public Page pagedQueryByDate(int pageNo, int pageSize, String date);
|
||||
}
|
||||
12
comm/Finance/src/project/finance/FinanceRedisKeys.java
Executable file
12
comm/Finance/src/project/finance/FinanceRedisKeys.java
Executable file
@@ -0,0 +1,12 @@
|
||||
package project.finance;
|
||||
|
||||
public class FinanceRedisKeys {
|
||||
/**
|
||||
* 获取所有的理财产品
|
||||
*/
|
||||
public final static String FINANCE_MAP = "FINANCE_MAP_";
|
||||
/**
|
||||
* 理财产品,id做key
|
||||
*/
|
||||
public final static String FINANCE_ID = "FINANCE_ID_";
|
||||
}
|
||||
25
comm/Finance/src/project/finance/FinanceService.java
Executable file
25
comm/Finance/src/project/finance/FinanceService.java
Executable file
@@ -0,0 +1,25 @@
|
||||
package project.finance;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 理财产品
|
||||
*
|
||||
* @author User
|
||||
*
|
||||
*/
|
||||
public interface FinanceService {
|
||||
|
||||
public void save(Finance finance,String login_safeword,String operaterUsername);
|
||||
|
||||
public void update(Finance finance,String login_safeword,String operaterUsername);
|
||||
|
||||
public Finance findById(String id);
|
||||
|
||||
public void delete(String id,String login_safeword,String operaterUsername);
|
||||
|
||||
public List<Finance> findAll();
|
||||
|
||||
public List<Finance> findAllState_1();
|
||||
|
||||
}
|
||||
44
comm/Finance/src/project/finance/data/loadcache/FinanceLoadCacheService.java
Executable file
44
comm/Finance/src/project/finance/data/loadcache/FinanceLoadCacheService.java
Executable file
@@ -0,0 +1,44 @@
|
||||
package project.finance.data.loadcache;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import project.finance.Finance;
|
||||
import project.finance.FinanceRedisKeys;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
public class FinanceLoadCacheService extends HibernateDaoSupport {
|
||||
private static final Log logger = LogFactory.getLog(FinanceLoadCacheService.class);
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public void loadcache() {
|
||||
load();
|
||||
logger.info("完成Finance数据加载redis");
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM Finance ");
|
||||
List<Finance> list = (List<Finance>)this.getHibernateTemplate().find(queryString.toString());
|
||||
|
||||
Map<String, Finance> cacheMap = new ConcurrentHashMap<String, Finance>();
|
||||
|
||||
for (Finance finance : list) {
|
||||
cacheMap.put(finance.getId().toString(), finance);
|
||||
redisHandler.setSync(FinanceRedisKeys.FINANCE_ID + finance.getId().toString(), finance);
|
||||
}
|
||||
|
||||
redisHandler.setSync(FinanceRedisKeys.FINANCE_MAP, cacheMap);
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
91
comm/Finance/src/project/finance/internal/AdminFinanceOrderServiceImpl.java
Executable file
91
comm/Finance/src/project/finance/internal/AdminFinanceOrderServiceImpl.java
Executable file
@@ -0,0 +1,91 @@
|
||||
package project.finance.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.finance.AdminFinanceOrderService;
|
||||
import project.party.recom.UserRecomService;
|
||||
|
||||
public class AdminFinanceOrderServiceImpl extends HibernateDaoSupport implements AdminFinanceOrderService {
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private UserRecomService userRecomService;
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para, String finance_para, String status_para,
|
||||
String partyId, String orderNo,String rolename_para) {
|
||||
List children = null;
|
||||
if (!StringUtils.isNullOrEmpty(partyId)) {
|
||||
|
||||
children = this.userRecomService.findChildren(partyId);
|
||||
if (children.size() == 0) {
|
||||
return Page.EMPTY_PAGE;
|
||||
}
|
||||
}
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
StringBuffer queryString = new StringBuffer(
|
||||
" SELECT financeOrder.UUID id,financeOrder.ORDER_NO order_no ,financeOrder.FINANCE_ID financeId , ");
|
||||
queryString.append(" financeOrder.AMOUNT amount,financeOrder.CREATE_TIME create_time, ");
|
||||
queryString.append(" financeOrder.CLOSE_TIME close_time,financeOrder.PROFIT profit, ");
|
||||
queryString.append(" financeOrder.STATE state, ");
|
||||
queryString.append(" party.USERNAME username,party.USERCODE usercode,party.ROLENAME rolename, ");
|
||||
queryString.append(" finance.NAME finance_name,finance.NAME_EN finance_name_en, ");
|
||||
queryString.append(" finance.NAME_KN finance_name_kn,finance.NAME_JN finance_name_jn ");
|
||||
queryString.append(" FROM T_FINANCE_ORDER financeOrder ");
|
||||
queryString.append(" LEFT JOIN PAT_PARTY party ON financeOrder.PARTY_ID = party.UUID ");
|
||||
queryString.append(" LEFT JOIN T_FINANCE finance ON finance.UUID = financeOrder.FINANCE_ID ");
|
||||
// if (!StringUtils.isNullOrEmpty(partyId)) {
|
||||
// queryString.append(" LEFT JOIN T_AGENT agent ON financeOrder.PARTY_ID = agent.PARTY_ID ");
|
||||
// }
|
||||
queryString.append(" WHERE 1 = 1 ");
|
||||
if (!StringUtils.isNullOrEmpty(partyId)) {
|
||||
queryString.append(" and financeOrder.PARTY_ID in (:partyId) ");
|
||||
parameters.put("partyId", children);
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(finance_para)) {
|
||||
queryString.append(
|
||||
" and (finance.NAME=:finance_para or finance.NAME_EN =:finance_para or finance.NAME_CN =:finance_para) ");
|
||||
parameters.put("finance_para", finance_para);
|
||||
}
|
||||
// if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
// queryString.append(" and party.USERNAME =:name or party.USERCODE =:usercode ");
|
||||
// parameters.put("name", name_para);
|
||||
// parameters.put("usercode", name_para);
|
||||
// }
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append("AND (party.USERNAME like:username OR party.USERCODE like:username ) ");
|
||||
parameters.put("username", "%" + name_para + "%");
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(status_para)) {
|
||||
queryString.append(" and financeOrder.STATE =:status_para ");
|
||||
parameters.put("status_para", status_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(orderNo)) {
|
||||
queryString.append(" and financeOrder.ORDER_NO = :orderNo ");
|
||||
parameters.put("orderNo", orderNo);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(rolename_para)) {
|
||||
queryString.append(" and party.ROLENAME =:rolename");
|
||||
parameters.put("rolename", rolename_para);
|
||||
}
|
||||
|
||||
queryString.append(" order by financeOrder.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;
|
||||
}
|
||||
}
|
||||
37
comm/Finance/src/project/finance/internal/AdminFinanceServiceImpl.java
Executable file
37
comm/Finance/src/project/finance/internal/AdminFinanceServiceImpl.java
Executable file
@@ -0,0 +1,37 @@
|
||||
package project.finance.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
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.finance.AdminFinanceService;
|
||||
|
||||
public class AdminFinanceServiceImpl extends HibernateDaoSupport implements AdminFinanceService {
|
||||
|
||||
protected PagedQueryDao pagedQueryDao;
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para) {
|
||||
StringBuffer queryString = new StringBuffer(
|
||||
" SELECT finance.UUID id,finance.NAME name,finance.NAME_EN name_en,finance.NAME_CN name_cn,"
|
||||
+ " finance.NAME_KN name_kn,finance.NAME_JN name_jn,finance.IMG img,finance.CYCLE cycle, "
|
||||
+ " finance.DAILY_RATE daily_rate ,finance.DAILY_RATE_MAX daily_rate_max ,finance.TODAY_RATE today_rate ,finance.STATE state,"
|
||||
+ " finance.DEFAULT_RATIO default_ratio ,finance.INVESTMENT_MIN investment_min"
|
||||
+ " ,finance.INVESTMENT_MAX investment_max ");
|
||||
queryString.append(" FROM T_FINANCE finance WHERE 1 = 1 ");
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append(" and finance.NAME like:name ");
|
||||
parameters.put("name", "%" + name_para + "%");
|
||||
}
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
}
|
||||
806
comm/Finance/src/project/finance/internal/FinanceOrderServiceImpl.java
Executable file
806
comm/Finance/src/project/finance/internal/FinanceOrderServiceImpl.java
Executable file
@@ -0,0 +1,806 @@
|
||||
package project.finance.internal;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.Constants;
|
||||
import project.finance.Finance;
|
||||
import project.finance.FinanceOrder;
|
||||
import project.finance.FinanceOrderService;
|
||||
import project.finance.FinanceService;
|
||||
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.user.UserDataService;
|
||||
import project.wallet.Wallet;
|
||||
import project.wallet.WalletService;
|
||||
|
||||
public class FinanceOrderServiceImpl extends HibernateDaoSupport implements FinanceOrderService {
|
||||
protected PagedQueryDao pagedDao;
|
||||
protected WalletService walletService;
|
||||
protected MoneyLogService moneyLogService;
|
||||
protected FinanceService financeService;
|
||||
protected PartyService partyService;
|
||||
protected SysparaService sysparaService;
|
||||
|
||||
protected UserDataService userDataService;
|
||||
protected UserRecomService userRecomService;
|
||||
|
||||
public void saveCreate(FinanceOrder entity) {
|
||||
|
||||
entity.setCreate_time(new Date());
|
||||
|
||||
// 加入周期
|
||||
Finance finance = financeService.findById(entity.getFinanceId());
|
||||
entity.setCycle(finance.getCycle());
|
||||
|
||||
// 买入金额需要在区间内
|
||||
if (entity.getAmount() > finance.getInvestment_max() || entity.getAmount() < finance.getInvestment_min()) {
|
||||
throw new BusinessException("金额错误");
|
||||
|
||||
}
|
||||
|
||||
// 查看余额
|
||||
Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId());
|
||||
double amount_before = wallet.getMoney();
|
||||
if (wallet.getMoney() < entity.getAmount()) {
|
||||
throw new BusinessException("余额不足");
|
||||
}
|
||||
|
||||
// wallet.setMoney(Arith.sub(wallet.getMoney(), entity.getAmount()));
|
||||
// this.walletService.update(wallet);
|
||||
this.walletService.update(wallet.getPartyId().toString(), Arith.sub(0, entity.getAmount()));
|
||||
|
||||
// 起息时间=确认时间加1天
|
||||
Date date = new Date();// 取时间
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(date);
|
||||
// 把日期往后增加一天.整数往后推,负数往前移动
|
||||
calendar.add(calendar.DATE, 1);
|
||||
// 这个时间就是日期往后推一天的结果
|
||||
date = calendar.getTime();
|
||||
entity.setEarn_time(date);
|
||||
|
||||
// 截止时间=起息时间+周期+1
|
||||
int days = (int) Arith.sub(entity.getCycle(), 1);
|
||||
calendar.add(calendar.DATE, days);
|
||||
date = calendar.getTime();
|
||||
entity.setStop_time(date);
|
||||
|
||||
// 默认的赎回时间=截止时间+1
|
||||
calendar.add(calendar.DATE, 1);
|
||||
date = calendar.getTime();
|
||||
entity.setClose_time(date);
|
||||
|
||||
// 保存资金日志
|
||||
MoneyLog moneylog = new MoneyLog();
|
||||
moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
|
||||
moneylog.setAmount_before(amount_before);
|
||||
moneylog.setAmount(Arith.sub(0, entity.getAmount()));
|
||||
moneylog.setAmount_after(Arith.sub(amount_before, entity.getAmount()));
|
||||
moneylog.setLog("购买理财产品,订单号[" + entity.getOrder_no() + "]");
|
||||
moneylog.setPartyId(entity.getPartyId());
|
||||
moneylog.setWallettype(Constants.WALLET);
|
||||
moneylog.setContent_type(Constants.MONEYLOG_FINANCE);
|
||||
|
||||
moneyLogService.save(moneylog);
|
||||
|
||||
this.getHibernateTemplate().save(entity);
|
||||
|
||||
// 购买理财产品后是否需要增加用户提现流水,1不增加,2要增加(coinspace,cqpro,amex,emex)
|
||||
String finance_buy_add_userdata = this.sysparaService.find("finance_buy_add_userdata").getValue();
|
||||
|
||||
// 理财购买后给他增加提现流水限制金额
|
||||
if ("2".equals(finance_buy_add_userdata)) {
|
||||
Party party = this.partyService.cachePartyBy(entity.getPartyId(), false);
|
||||
party.setWithdraw_limit_amount(Arith.add(party.getWithdraw_limit_amount(), entity.getAmount()));
|
||||
partyService.update(party);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveClose(FinanceOrder entity, Date systemTime) {
|
||||
|
||||
double get_amount = Arith.add(entity.getAmount(), entity.getProfit());
|
||||
if (get_amount < 0) {
|
||||
entity.setProfit(Arith.sub(0, entity.getAmount()));
|
||||
get_amount = Arith.add(entity.getAmount(), entity.getProfit());
|
||||
}
|
||||
|
||||
if (get_amount > 0) {
|
||||
Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId());
|
||||
double amount_before = wallet.getMoney();
|
||||
// wallet.setMoney(Arith.add(wallet.getMoney(), get_amount));
|
||||
// this.walletService.update(wallet);
|
||||
this.walletService.update(wallet.getPartyId().toString(), get_amount);
|
||||
/**
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneylog = new MoneyLog();
|
||||
moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
|
||||
moneylog.setAmount_before(amount_before);
|
||||
moneylog.setAmount(Arith.add(0, get_amount));
|
||||
moneylog.setAmount_after(Arith.add(amount_before, get_amount));
|
||||
moneylog.setLog("赎回理财产品,订单号[" + entity.getOrder_no() + "]");
|
||||
moneylog.setPartyId(entity.getPartyId());
|
||||
moneylog.setWallettype(Constants.WALLET);
|
||||
moneylog.setContent_type(Constants.MONEYLOG_FINANCE);
|
||||
moneylog.setCreateTime(systemTime != null ? systemTime : new Date());
|
||||
|
||||
moneyLogService.save(moneylog);
|
||||
|
||||
}
|
||||
|
||||
getHibernateTemplate().update(entity);
|
||||
|
||||
this.userDataService.saveSellFinance(entity);
|
||||
|
||||
}
|
||||
|
||||
public void saveClose(FinanceOrder entity) {
|
||||
double get_amount = Arith.add(entity.getAmount(), entity.getProfit());
|
||||
if (get_amount < 0) {
|
||||
entity.setProfit(Arith.sub(0, entity.getAmount()));
|
||||
get_amount = Arith.add(entity.getAmount(), entity.getProfit());
|
||||
}
|
||||
|
||||
if (get_amount > 0) {
|
||||
Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId());
|
||||
double amount_before = wallet.getMoney();
|
||||
// wallet.setMoney(Arith.add(wallet.getMoney(), get_amount));
|
||||
// this.walletService.update(wallet);
|
||||
this.walletService.update(wallet.getPartyId().toString(), get_amount);
|
||||
/**
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneylog = new MoneyLog();
|
||||
moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
|
||||
moneylog.setAmount_before(amount_before);
|
||||
moneylog.setAmount(Arith.add(0, get_amount));
|
||||
moneylog.setAmount_after(Arith.add(amount_before, get_amount));
|
||||
moneylog.setLog("赎回理财产品,订单号[" + entity.getOrder_no() + "]");
|
||||
moneylog.setPartyId(entity.getPartyId());
|
||||
moneylog.setWallettype(Constants.WALLET);
|
||||
moneylog.setContent_type(Constants.MONEYLOG_FINANCE);
|
||||
moneylog.setCreateTime(new Date());
|
||||
|
||||
moneyLogService.save(moneylog);
|
||||
|
||||
}
|
||||
|
||||
getHibernateTemplate().update(entity);
|
||||
|
||||
this.userDataService.saveSellFinance(entity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FinanceOrder findByOrder_no(String order_no) {
|
||||
List<FinanceOrder> list = (List<FinanceOrder>)getHibernateTemplate().find(" FROM FinanceOrder WHERE order_no = ?0",
|
||||
new Object[] { order_no });
|
||||
if (list.size() > 0)
|
||||
return list.get(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<FinanceOrder> findByState(String partyId, String state) {
|
||||
/**
|
||||
* 如果是查询已赎回的,则将提前赎回和正常赎回的都查出来
|
||||
*/
|
||||
List<FinanceOrder> list;
|
||||
if ("2".equals(state)) {
|
||||
list = (List<FinanceOrder>)getHibernateTemplate().find(" FROM FinanceOrder WHERE partyId =?0 and state = ?1 or state =?2 ",
|
||||
new Object[] { partyId, "0", "2" });
|
||||
}
|
||||
if ("0".equals(state) || "1".equals(state)) {
|
||||
list = (List<FinanceOrder>)getHibernateTemplate().find(" FROM FinanceOrder WHERE state = ?0 and partyId =?1",
|
||||
new Object[] { state, partyId });
|
||||
} else {
|
||||
list = (List<FinanceOrder>)getHibernateTemplate().find(" FROM FinanceOrder WHERE partyId =?0", new Object[] { partyId });
|
||||
}
|
||||
|
||||
if (list.size() > 0)
|
||||
return list;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String partyId, String state) {
|
||||
/**
|
||||
* 如果是查询已赎回的,则将提前赎回和正常赎回的都查出来
|
||||
*/
|
||||
StringBuffer queryString = new StringBuffer("");
|
||||
queryString.append(" FROM FinanceOrder WHERE 1=1 ");
|
||||
Map parameters = new HashMap();
|
||||
queryString.append("AND partyId=:partyId ");
|
||||
parameters.put("partyId", partyId);
|
||||
if (StringUtils.isNotEmpty(state)) {
|
||||
if ("2".equals(state)) {
|
||||
queryString.append(" AND (state =:state_2 OR state =:state_0 )");
|
||||
parameters.put("state_2", "0");
|
||||
parameters.put("state_0", "2");
|
||||
|
||||
} else if ("02".equals(state)) {
|
||||
/**
|
||||
* 兼容其他项目所写,2提前赎回 (违约)
|
||||
*/
|
||||
queryString.append("AND state=:state ");
|
||||
parameters.put("state", "2");
|
||||
} else {
|
||||
queryString.append("AND state=:state ");
|
||||
parameters.put("state", state);
|
||||
}
|
||||
}
|
||||
queryString.append(" order by create_time desc ");
|
||||
|
||||
Page page = this.pagedDao.pagedQueryHql(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据日期获取到当日的购买订单
|
||||
*
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public Page pagedQueryByDate(int pageNo, int pageSize, String date) {
|
||||
/**
|
||||
* 如果是查询已赎回的,则将提前赎回和正常赎回的都查出来
|
||||
*/
|
||||
StringBuffer queryString = new StringBuffer("");
|
||||
queryString.append(" FROM FinanceOrder WHERE 1=1 ");
|
||||
Map parameters = new HashMap();
|
||||
queryString.append("AND DATE(create_time) = DATE(:date) ");
|
||||
parameters.put("date", date);
|
||||
|
||||
queryString.append(" order by create_time asc ");
|
||||
|
||||
Page page = this.pagedDao.pagedQueryHql(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setWalletService(WalletService walletService) {
|
||||
this.walletService = walletService;
|
||||
}
|
||||
|
||||
public void setMoneyLogService(MoneyLogService moneyLogService) {
|
||||
this.moneyLogService = moneyLogService;
|
||||
}
|
||||
|
||||
public void setFinanceService(FinanceService financeService) {
|
||||
this.financeService = financeService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FinanceOrder> getAllStateBy_1() {
|
||||
List<FinanceOrder> list = (List<FinanceOrder>)getHibernateTemplate().find(" FROM FinanceOrder WHERE state = ?0 ", new Object[] { "1" });
|
||||
if (list.size() > 0) {
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addListProfit(FinanceOrder order) {
|
||||
|
||||
/**
|
||||
* 截止时间要大于现在这个时间则计算收益 赎回时间如果小于现在时间则不计算收益
|
||||
*/
|
||||
List<Finance> finances = financeService.findAll();
|
||||
Finance finance = new Finance();
|
||||
Date now_date = new Date();
|
||||
String date_string = DateUtils.format(now_date, DateUtils.DF_yyyyMMdd);
|
||||
|
||||
/**
|
||||
* 现在时间是否大于赎回时间,如果大于等于,则赎回,不计算收益了,并将状态改变为已赎回 只计算年月日
|
||||
*/
|
||||
String order_date = DateUtils.format(order.getClose_time(), DateUtils.DF_yyyyMMdd);
|
||||
String order_earn = DateUtils.format(order.getEarn_time(), DateUtils.DF_yyyyMMdd);
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date date_now = null;
|
||||
Date close_date = null;
|
||||
Date earn_date = null;
|
||||
try {
|
||||
date_now = dateFormat.parse(date_string);
|
||||
close_date = dateFormat.parse(order_date);
|
||||
earn_date = dateFormat.parse(order_earn);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* 理财收益赎回时统一下发1还是每日下发2
|
||||
*/
|
||||
String finance_profit_days = sysparaService.find("finance_profit_days").getValue();
|
||||
|
||||
if ("1".equals(finance_profit_days)) {
|
||||
|
||||
// 如果赎回时间close_date < 现在时间date_now 则 arrive_close > 0
|
||||
int arrive_close = date_now.compareTo(close_date);
|
||||
if (arrive_close >= 0) {
|
||||
order.setState("0");
|
||||
saveClose(order);
|
||||
return;
|
||||
}
|
||||
// 如果起息时间earn_date < 现在时间date_now 则 arrive_close > 0
|
||||
// 起息时间要大于等于今天
|
||||
int arrive_earn = date_now.compareTo(earn_date);
|
||||
if (arrive_earn < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < finances.size(); j++) {
|
||||
finance = finances.get(j);
|
||||
if (finance.getId().equals(order.getFinanceId())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 当日获取的收益
|
||||
*/
|
||||
double today_rate = Arith.mul(finance.getToday_rate(), 0.01);
|
||||
double get_amount = Arith.mul(order.getAmount(), today_rate);
|
||||
order.setProfit(Arith.add(order.getProfit(), get_amount));
|
||||
|
||||
this.getHibernateTemplate().update(order);
|
||||
}
|
||||
|
||||
if ("2".equals(finance_profit_days)) {
|
||||
|
||||
// 如果赎回时间close_date < 现在时间date_now 则 arrive_close > 0
|
||||
int arrive_close = date_now.compareTo(close_date);
|
||||
if (arrive_close >= 0) {
|
||||
order.setState("0");
|
||||
// 自动赎回调用,只返回本金
|
||||
saveClosePrincipal(order);
|
||||
return;
|
||||
}
|
||||
// 如果起息时间earn_date < 现在时间date_now 则 arrive_close > 0
|
||||
/**
|
||||
* 起息时间要大于等于今天
|
||||
*/
|
||||
int arrive_earn = date_now.compareTo(earn_date);
|
||||
if (arrive_earn < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < finances.size(); j++) {
|
||||
finance = finances.get(j);
|
||||
if (finance.getId().equals(order.getFinanceId())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 当日获取的收益
|
||||
*/
|
||||
double today_rate = Arith.mul(finance.getToday_rate(), 0.01);
|
||||
double get_amount = Arith.mul(order.getAmount(), today_rate);
|
||||
|
||||
// 5,0.5,3,0.3,2,0.2
|
||||
String finance_level_profit = sysparaService.find("finance_level_profit").getValue();
|
||||
boolean finance_level_profit_open = StringUtils.isNotEmpty(finance_level_profit);
|
||||
// 判断是否有理财推荐奖励,如果有,需要扣除30%给推荐人
|
||||
String finance_bonus_parameters = "";
|
||||
finance_bonus_parameters = this.sysparaService.find("finance_bonus_parameters").getValue();
|
||||
if ((finance_bonus_parameters != null && !"".equals(finance_bonus_parameters))
|
||||
|| finance_level_profit_open) {
|
||||
String[] finance_bonus_array = StringUtils.isNotEmpty(finance_bonus_parameters)
|
||||
? finance_bonus_parameters.split(",")
|
||||
: new String[] {};
|
||||
List<UserRecom> list_parents = this.userRecomService.getParents(order.getPartyId());
|
||||
|
||||
if (CollectionUtils.isNotEmpty(list_parents)) {
|
||||
|
||||
int loop = 0;
|
||||
for (int i = 0; i < list_parents.size(); i++) {
|
||||
if (finance_level_profit_open) {// 等级奖励只给推荐一人
|
||||
if (loop >= 1) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (loop >= 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Party party_parent = this.partyService.cachePartyBy(list_parents.get(i).getReco_id(), true);
|
||||
if (!Constants.SECURITY_ROLE_MEMBER.equals(party_parent.getRolename())) {
|
||||
continue;
|
||||
}
|
||||
get_amount = Arith.mul(order.getAmount(), today_rate);
|
||||
/**
|
||||
* 增加推荐人理财收益
|
||||
*/
|
||||
double parent_get_money = 0d;
|
||||
if (finance_level_profit_open) {
|
||||
parent_get_money = levelProfit(party_parent.getId().toString(), get_amount,
|
||||
finance_level_profit);
|
||||
} else {
|
||||
double finance_pip_amount = Double.valueOf(finance_bonus_array[loop]);
|
||||
parent_get_money = Arith.mul(get_amount, finance_pip_amount);
|
||||
}
|
||||
if (parent_get_money == 0d) {
|
||||
break;
|
||||
}
|
||||
|
||||
Wallet wallet_parent = walletService.saveWalletByPartyId(party_parent.getId().toString());
|
||||
double amount_before_parent = wallet_parent.getMoney();
|
||||
walletService.update(wallet_parent.getPartyId().toString(), parent_get_money);
|
||||
/**
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneyLog = new MoneyLog();
|
||||
moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
|
||||
moneyLog.setAmount_before(amount_before_parent);
|
||||
moneyLog.setAmount(parent_get_money);
|
||||
moneyLog.setAmount_after(Arith.add(amount_before_parent, parent_get_money));
|
||||
moneyLog.setLog("第" + (i + 1) + "代下级用户,每日理财收益奖励金");
|
||||
moneyLog.setPartyId(party_parent.getId().toString());
|
||||
moneyLog.setWallettype(Constants.WALLET);
|
||||
moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_FINANCE_RECOM_PROFIT);
|
||||
moneyLogService.save(moneyLog);
|
||||
|
||||
loop++;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 理财收益减少百分之30给上级
|
||||
*/
|
||||
if (!finance_level_profit_open) {// 等级奖励则无需扣除本人收益
|
||||
get_amount = Arith.sub(get_amount, Arith.mul(order.getAmount(), 0.3));
|
||||
}
|
||||
}
|
||||
|
||||
Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId());
|
||||
double amount_before = wallet.getMoney();
|
||||
// wallet.setMoney(Arith.add(wallet.getMoney(), get_amount));
|
||||
this.walletService.update(wallet.getPartyId().toString(), get_amount);
|
||||
// this.walletService.update(wallet);
|
||||
/**
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneylog = new MoneyLog();
|
||||
moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
|
||||
moneylog.setAmount_before(amount_before);
|
||||
moneylog.setAmount(Arith.add(0, get_amount));
|
||||
moneylog.setAmount_after(Arith.add(amount_before, get_amount));
|
||||
moneylog.setLog("理财产品每日收益,订单号[" + order.getOrder_no() + "]");
|
||||
moneylog.setPartyId(order.getPartyId());
|
||||
moneylog.setWallettype(Constants.WALLET);
|
||||
moneylog.setContent_type(Constants.MONEYLOG_CONTENT_FINANCE_PROFIT);
|
||||
|
||||
moneyLogService.save(moneylog);
|
||||
|
||||
order.setProfit(Arith.add(order.getProfit(), get_amount));
|
||||
|
||||
this.getHibernateTemplate().update(order);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addListProfit(FinanceOrder order, Date systemTime) {
|
||||
|
||||
/**
|
||||
* 截止时间要大于现在这个时间则计算收益 赎回时间如果小于现在时间则不计算收益
|
||||
*/
|
||||
List<Finance> finances = financeService.findAll();
|
||||
Finance finance = new Finance();
|
||||
Date now_date = systemTime != null ? systemTime : new Date();
|
||||
String date_string = DateUtils.format(now_date, DateUtils.DF_yyyyMMdd);
|
||||
|
||||
/**
|
||||
* 现在时间是否大于赎回时间,如果大于等于,则赎回,不计算收益了,并将状态改变为已赎回 只计算年月日
|
||||
*/
|
||||
String order_date = DateUtils.format(order.getClose_time(), DateUtils.DF_yyyyMMdd);
|
||||
String order_earn = DateUtils.format(order.getEarn_time(), DateUtils.DF_yyyyMMdd);
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date date_now = null;
|
||||
Date close_date = null;
|
||||
Date earn_date = null;
|
||||
try {
|
||||
date_now = dateFormat.parse(date_string);
|
||||
close_date = dateFormat.parse(order_date);
|
||||
earn_date = dateFormat.parse(order_earn);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* 理财收益赎回时统一下发1还是每日下发2
|
||||
*/
|
||||
String finance_profit_days = sysparaService.find("finance_profit_days").getValue();
|
||||
|
||||
/**
|
||||
* 1计算收益,赎回统一发放
|
||||
*/
|
||||
if ("1".equals(finance_profit_days)) {
|
||||
// 如果赎回时间close_date < 现在时间date_now 则 arrive_close > 0
|
||||
int arrive_close = date_now.compareTo(close_date);
|
||||
if (arrive_close >= 0) {
|
||||
order.setState("0");
|
||||
saveClose(order, systemTime);
|
||||
return;
|
||||
}
|
||||
// 如果起息时间earn_date < 现在时间date_now 则 arrive_close > 0
|
||||
/**
|
||||
* 起息时间要大于等于今天
|
||||
*/
|
||||
int arrive_earn = date_now.compareTo(earn_date);
|
||||
if (arrive_earn < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < finances.size(); j++) {
|
||||
finance = finances.get(j);
|
||||
if (finance.getId().equals(order.getFinanceId())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 当日获取的收益
|
||||
*/
|
||||
double today_rate = Arith.mul(finance.getToday_rate(), 0.01);
|
||||
double get_amount = Arith.mul(order.getAmount(), today_rate);
|
||||
|
||||
order.setProfit(Arith.add(order.getProfit(), get_amount));
|
||||
|
||||
this.getHibernateTemplate().update(order);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 2每日下发收益
|
||||
*/
|
||||
if ("2".equals(finance_profit_days)) {
|
||||
|
||||
// 如果赎回时间close_date < 现在时间date_now 则 arrive_close > 0
|
||||
int arrive_close = date_now.compareTo(close_date);
|
||||
if (arrive_close >= 0) {
|
||||
order.setState("0");
|
||||
/**
|
||||
* 自动赎回调用,只返回本金
|
||||
*/
|
||||
saveClosePrincipal(order);
|
||||
return;
|
||||
}
|
||||
// 如果起息时间earn_date < 现在时间date_now 则 arrive_close > 0
|
||||
/**
|
||||
* 起息时间要大于等于今天
|
||||
*/
|
||||
int arrive_earn = date_now.compareTo(earn_date);
|
||||
if (arrive_earn < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < finances.size(); j++) {
|
||||
finance = finances.get(j);
|
||||
if (finance.getId().equals(order.getFinanceId())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当日获取的收益
|
||||
*/
|
||||
|
||||
double today_rate = Arith.mul(finance.getToday_rate(), 0.01);
|
||||
double get_amount = Arith.mul(order.getAmount(), today_rate);
|
||||
|
||||
// 5,0.5,3,0.3,2,0.2
|
||||
String finance_level_profit = sysparaService.find("finance_level_profit").getValue();
|
||||
boolean finance_level_profit_open = StringUtils.isNotEmpty(finance_level_profit);
|
||||
// 判断是否有理财推荐奖励,如果有,需要扣除30%给推荐人
|
||||
String finance_bonus_parameters = "";
|
||||
finance_bonus_parameters = this.sysparaService.find("finance_bonus_parameters").getValue();
|
||||
if ((finance_bonus_parameters != null && !"".equals(finance_bonus_parameters))
|
||||
|| finance_level_profit_open) {
|
||||
String[] finance_bonus_array = StringUtils.isNotEmpty(finance_bonus_parameters)
|
||||
? finance_bonus_parameters.split(",")
|
||||
: new String[] {};
|
||||
List<UserRecom> list_parents = this.userRecomService.getParents(order.getPartyId());
|
||||
|
||||
if (CollectionUtils.isNotEmpty(list_parents)) {
|
||||
|
||||
int loop = 0;
|
||||
for (int i = 0; i < list_parents.size(); i++) {
|
||||
if (finance_level_profit_open) {// 等级奖励只给推荐一人
|
||||
if (loop >= 1) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (loop >= 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Party party_parent = this.partyService.cachePartyBy(list_parents.get(i).getReco_id(), true);
|
||||
if (!Constants.SECURITY_ROLE_MEMBER.equals(party_parent.getRolename())) {
|
||||
continue;
|
||||
}
|
||||
get_amount = Arith.mul(order.getAmount(), today_rate);
|
||||
/**
|
||||
* 增加推荐人理财收益
|
||||
*/
|
||||
double parent_get_money = 0d;
|
||||
if (finance_level_profit_open) {
|
||||
parent_get_money = levelProfit(party_parent.getId().toString(), get_amount,
|
||||
finance_level_profit);
|
||||
} else {
|
||||
double finance_pip_amount = Double.valueOf(finance_bonus_array[loop]);
|
||||
parent_get_money = Arith.mul(get_amount, finance_pip_amount);
|
||||
}
|
||||
if (parent_get_money == 0d) {
|
||||
break;
|
||||
}
|
||||
Wallet wallet_parent = walletService.saveWalletByPartyId(party_parent.getId().toString());
|
||||
double amount_before_parent = wallet_parent.getMoney();
|
||||
walletService.update(wallet_parent.getPartyId().toString(), parent_get_money);
|
||||
/**
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneyLog = new MoneyLog();
|
||||
moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
|
||||
moneyLog.setAmount_before(amount_before_parent);
|
||||
moneyLog.setAmount(parent_get_money);
|
||||
moneyLog.setAmount_after(Arith.add(amount_before_parent, parent_get_money));
|
||||
moneyLog.setLog("第" + (i + 1) + "代下级用户,每日理财收益奖励金");
|
||||
moneyLog.setPartyId(party_parent.getId().toString());
|
||||
moneyLog.setWallettype(Constants.WALLET);
|
||||
moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_FINANCE_RECOM_PROFIT);
|
||||
moneyLog.setCreateTime(systemTime);
|
||||
moneyLogService.save(moneyLog);
|
||||
|
||||
loop++;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 理财收益减少百分之30给上级
|
||||
*/
|
||||
if (finance_level_profit_open) {// 等级奖励则无需扣除本人收益
|
||||
get_amount = Arith.sub(get_amount, Arith.mul(get_amount, 0.3));
|
||||
}
|
||||
}
|
||||
|
||||
Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId());
|
||||
double amount_before = wallet.getMoney();
|
||||
// wallet.setMoney(Arith.add(wallet.getMoney(), get_amount));
|
||||
this.walletService.update(wallet.getPartyId().toString(), get_amount);
|
||||
// this.walletService.update(wallet);
|
||||
/**
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneylog = new MoneyLog();
|
||||
moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
|
||||
moneylog.setAmount_before(amount_before);
|
||||
moneylog.setAmount(Arith.add(0, get_amount));
|
||||
moneylog.setAmount_after(Arith.add(amount_before, get_amount));
|
||||
moneylog.setLog("理财产品每日收益,订单号[" + order.getOrder_no() + "]");
|
||||
moneylog.setPartyId(order.getPartyId());
|
||||
moneylog.setWallettype(Constants.WALLET);
|
||||
moneylog.setContent_type(Constants.MONEYLOG_CONTENT_FINANCE_PROFIT);
|
||||
moneylog.setCreateTime(systemTime);
|
||||
moneyLogService.save(moneylog);
|
||||
order.setProfit(Arith.add(order.getProfit(), get_amount));
|
||||
this.getHibernateTemplate().update(order);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 每日下发收益,自动赎回调用,只返回本金
|
||||
*/
|
||||
public void saveClosePrincipal(FinanceOrder entity) {
|
||||
double get_amount = Arith.add(entity.getAmount(), entity.getProfit_before());
|
||||
if (get_amount < 0) {
|
||||
entity.setProfit(Arith.sub(0, entity.getAmount()));
|
||||
get_amount = Arith.add(entity.getAmount(), entity.getProfit());
|
||||
}
|
||||
|
||||
if (get_amount > 0) {
|
||||
Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId());
|
||||
double amount_before = wallet.getMoney();
|
||||
// wallet.setMoney(Arith.add(wallet.getMoney(), get_amount));
|
||||
// this.walletService.update(wallet);
|
||||
this.walletService.update(wallet.getPartyId().toString(), get_amount);
|
||||
/**
|
||||
* 保存资金日志
|
||||
*/
|
||||
MoneyLog moneylog = new MoneyLog();
|
||||
moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
|
||||
moneylog.setAmount_before(amount_before);
|
||||
moneylog.setAmount(Arith.add(0, get_amount));
|
||||
moneylog.setAmount_after(Arith.add(amount_before, get_amount));
|
||||
moneylog.setLog("赎回理财产品,订单号[" + entity.getOrder_no() + "]");
|
||||
moneylog.setPartyId(entity.getPartyId());
|
||||
moneylog.setWallettype(Constants.WALLET);
|
||||
moneylog.setContent_type(Constants.MONEYLOG_FINANCE);
|
||||
|
||||
moneyLogService.save(moneylog);
|
||||
|
||||
}
|
||||
|
||||
getHibernateTemplate().update(entity);
|
||||
|
||||
this.userDataService.saveSellFinance(entity);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 等级奖励
|
||||
*
|
||||
* @param partyId
|
||||
* @param profit
|
||||
* @return 返回奖励
|
||||
*/
|
||||
public double levelProfit(String partyId, double profit, String finance_level_profit) {
|
||||
// 5,0.5,3,0.3,2,0.2
|
||||
double levelProfitMoney = 0d;
|
||||
if (StringUtils.isEmptyString(finance_level_profit)) {
|
||||
return levelProfitMoney;
|
||||
}
|
||||
List<UserRecom> listRecoms = this.userRecomService.findRecoms(partyId);
|
||||
int recomsNum = listRecoms.size();
|
||||
String[] finance_level_profit_array = finance_level_profit.split(",");
|
||||
|
||||
for (int i = 0; i < finance_level_profit_array.length; i++) {
|
||||
double levelNeed = Double.valueOf(finance_level_profit_array[i]);
|
||||
|
||||
if (recomsNum >= levelNeed) {// 等级满足要求
|
||||
double pipAmount = Double.valueOf(finance_level_profit_array[i + 1]);
|
||||
levelProfitMoney = Arith.mul(profit, pipAmount);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return levelProfitMoney;
|
||||
}
|
||||
|
||||
public FinanceOrder findById(String id) {
|
||||
return (FinanceOrder) getHibernateTemplate().get(FinanceOrder.class, id);
|
||||
}
|
||||
|
||||
public void update(FinanceOrder entity) {
|
||||
getHibernateTemplate().update(entity);
|
||||
}
|
||||
|
||||
public void setPagedDao(PagedQueryDao pagedDao) {
|
||||
this.pagedDao = pagedDao;
|
||||
}
|
||||
|
||||
public void setUserDataService(UserDataService userDataService) {
|
||||
this.userDataService = userDataService;
|
||||
}
|
||||
|
||||
public void setPartyService(PartyService partyService) {
|
||||
this.partyService = partyService;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
}
|
||||
126
comm/Finance/src/project/finance/internal/FinanceServiceImpl.java
Executable file
126
comm/Finance/src/project/finance/internal/FinanceServiceImpl.java
Executable file
@@ -0,0 +1,126 @@
|
||||
package project.finance.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import project.finance.Finance;
|
||||
import project.finance.FinanceRedisKeys;
|
||||
import project.finance.FinanceService;
|
||||
import project.redis.RedisHandler;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
public class FinanceServiceImpl extends HibernateDaoSupport implements FinanceService {
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
private SecUserService secUserService;
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
public void save(Finance entity,String login_safeword,String operaterUsername) {
|
||||
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operaterUsername);
|
||||
String sysSafeword =sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(login_safeword,operaterUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("资金密码错误");
|
||||
}
|
||||
this.getHibernateTemplate().save(entity);
|
||||
redisHandler.setSync(FinanceRedisKeys.FINANCE_ID + entity.getId().toString(), entity);
|
||||
|
||||
Map<String, Finance> cacheMap = (Map<String, Finance>) redisHandler.get(FinanceRedisKeys.FINANCE_MAP);
|
||||
if (cacheMap == null) {
|
||||
cacheMap = new ConcurrentHashMap<String, Finance>();
|
||||
}
|
||||
cacheMap.put(entity.getId().toString(), entity);
|
||||
redisHandler.setSync(FinanceRedisKeys.FINANCE_MAP, cacheMap);
|
||||
|
||||
}
|
||||
|
||||
public void update(Finance entity,String login_safeword,String operaterUsername) {
|
||||
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operaterUsername);
|
||||
String sysSafeword =sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(login_safeword,operaterUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("资金密码错误");
|
||||
}
|
||||
|
||||
getHibernateTemplate().update(entity);
|
||||
redisHandler.setSync(FinanceRedisKeys.FINANCE_ID + entity.getId().toString(), entity);
|
||||
|
||||
Map<String, Finance> cacheMap = (Map<String, Finance>) redisHandler.get(FinanceRedisKeys.FINANCE_MAP);
|
||||
if (cacheMap == null) {
|
||||
cacheMap = new ConcurrentHashMap<String, Finance>();
|
||||
}
|
||||
cacheMap.put(entity.getId().toString(), entity);
|
||||
redisHandler.setSync(FinanceRedisKeys.FINANCE_MAP, cacheMap);
|
||||
|
||||
}
|
||||
|
||||
public void delete(String id,String login_safeword,String operaterUsername) {
|
||||
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operaterUsername);
|
||||
String sysSafeword =sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(login_safeword,operaterUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("资金密码错误");
|
||||
}
|
||||
|
||||
|
||||
Finance entity = findById(id);
|
||||
getHibernateTemplate().delete(entity);
|
||||
redisHandler.remove(FinanceRedisKeys.FINANCE_ID + entity.getId().toString());
|
||||
|
||||
Map<String, Finance> cacheMap = (Map<String, Finance>) redisHandler.get(FinanceRedisKeys.FINANCE_MAP);
|
||||
if (cacheMap != null && !cacheMap.isEmpty()) {
|
||||
cacheMap.remove(entity.getId().toString());
|
||||
redisHandler.setSync(FinanceRedisKeys.FINANCE_MAP, cacheMap);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Finance findById(String id) {
|
||||
return (Finance) redisHandler.get(FinanceRedisKeys.FINANCE_ID + id);
|
||||
}
|
||||
|
||||
public List<Finance> findAll() {
|
||||
Map<String, Finance> cacheMap = (Map<String, Finance>) redisHandler.get(FinanceRedisKeys.FINANCE_MAP);
|
||||
if (cacheMap != null && !cacheMap.isEmpty()) {
|
||||
return new ArrayList<Finance>(cacheMap.values());
|
||||
}
|
||||
return new ArrayList<Finance>();
|
||||
}
|
||||
|
||||
public List<Finance> findAllState_1() {
|
||||
List<Finance> list = (List<Finance>)getHibernateTemplate().find(" FROM Finance WHERE state = ?0", new Object[] { "1" });
|
||||
if (list.size() > 0)
|
||||
return list;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
125
comm/Finance/src/project/finance/job/FinanceOrder1DayJob.java
Executable file
125
comm/Finance/src/project/finance/job/FinanceOrder1DayJob.java
Executable file
@@ -0,0 +1,125 @@
|
||||
package project.finance.job;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.ThreadUtils;
|
||||
import project.finance.FinanceOrder;
|
||||
import project.finance.FinanceOrderLock;
|
||||
import project.finance.FinanceOrderService;
|
||||
import project.log.SysLog;
|
||||
import project.log.SysLogService;
|
||||
|
||||
public class FinanceOrder1DayJob {
|
||||
private static Log logger = LogFactory.getLog(FinanceOrder1DayJob.class);
|
||||
protected FinanceOrderService financeOrderService;
|
||||
protected SysLogService sysLogService;
|
||||
|
||||
public void taskJob() {
|
||||
try {
|
||||
List<FinanceOrder> financeOrder = financeOrderService.getAllStateBy_1();
|
||||
if(financeOrder != null) {
|
||||
for (int i = 0; i < financeOrder.size(); i++) {
|
||||
FinanceOrder order = financeOrder.get(i);
|
||||
boolean lock = false;
|
||||
try {
|
||||
|
||||
if (!FinanceOrderLock.add(order.getOrder_no())) {
|
||||
continue;
|
||||
}
|
||||
lock = true;
|
||||
this.financeOrderService.addListProfit(order);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("FinanceOrder1DayJob order profit fail,orderno:{"+order.getOrder_no()+"},e:", e);
|
||||
} finally {
|
||||
if (lock) {
|
||||
/**
|
||||
* 每秒处理100个订单
|
||||
*/
|
||||
ThreadUtils.sleep(10);
|
||||
FinanceOrderLock.remove(order.getOrder_no());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
logger.info(DateUtils.dateToStr(new Date(), DateUtils.DF_yyyyMMddHHmmss)+" finance profit finished ,count:" + financeOrder.size());
|
||||
}
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("FinanceOrder1DayJob run fail e:", e);
|
||||
SysLog entity = new SysLog();
|
||||
entity.setLevel(SysLog.level_error);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setLog("FinanceOrder1DayJob 理财任务 执行失败 e:"+e);
|
||||
sysLogService.saveAsyn(entity);
|
||||
} finally {
|
||||
/**
|
||||
* 暂停0.1秒
|
||||
*/
|
||||
ThreadUtils.sleep(1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handleData(Date systemTime) {
|
||||
try {
|
||||
List<FinanceOrder> financeOrder = financeOrderService.getAllStateBy_1();
|
||||
if(financeOrder != null) {
|
||||
for (int i = 0; i < financeOrder.size(); i++) {
|
||||
FinanceOrder order = financeOrder.get(i);
|
||||
boolean lock = false;
|
||||
try {
|
||||
|
||||
if (!FinanceOrderLock.add(order.getOrder_no())) {
|
||||
continue;
|
||||
}
|
||||
lock = true;
|
||||
this.financeOrderService.addListProfit(order,systemTime);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("FinanceOrder1DayJob order profit fail,orderno:{"+order.getOrder_no()+"},e:", e);
|
||||
} finally {
|
||||
if (lock) {
|
||||
/**
|
||||
* 每秒处理100个订单
|
||||
*/
|
||||
ThreadUtils.sleep(10);
|
||||
FinanceOrderLock.remove(order.getOrder_no());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
logger.info(DateUtils.dateToStr(new Date(), DateUtils.DF_yyyyMMddHHmmss)+" finance profit finished ,count:" + financeOrder.size());
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("FinanceOrder1DayJob run fail e:", e);
|
||||
SysLog entity = new SysLog();
|
||||
entity.setLevel(SysLog.level_error);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setLog("FinanceOrder1DayJob 理财任务 执行失败 e:"+e);
|
||||
sysLogService.saveAsyn(entity);
|
||||
} finally {
|
||||
/**
|
||||
* 暂停0.1秒
|
||||
*/
|
||||
ThreadUtils.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFinanceOrderService(FinanceOrderService financeOrderService) {
|
||||
this.financeOrderService = financeOrderService;
|
||||
}
|
||||
|
||||
public void setSysLogService(SysLogService sysLogService) {
|
||||
this.sysLogService = sysLogService;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
38
comm/Finance/src/project/finance/job/FinanceOrderCreateRecomJob.java
Executable file
38
comm/Finance/src/project/finance/job/FinanceOrderCreateRecomJob.java
Executable file
@@ -0,0 +1,38 @@
|
||||
package project.finance.job;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
import project.log.SysLog;
|
||||
import project.log.SysLogService;
|
||||
|
||||
public class FinanceOrderCreateRecomJob {
|
||||
private static Logger logger = LoggerFactory.getLogger(FinanceOrderCreateRecomJob.class);
|
||||
protected SysLogService sysLogService;
|
||||
private FinanceOrderCreateRecomService financeOrderCreateRecomService;
|
||||
|
||||
public void taskJob() {
|
||||
try {
|
||||
financeOrderCreateRecomService.computeRecom();
|
||||
} catch (Exception e) {
|
||||
logger.error("FinanceOrderCreateRecomJob run fail e:", e);
|
||||
SysLog entity = new SysLog();
|
||||
entity.setLevel(SysLog.level_error);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setLog("FinanceOrderCreateRecomJob 理财购买奖励任务 执行失败 e:"+e);
|
||||
sysLogService.saveAsyn(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSysLogService(SysLogService sysLogService) {
|
||||
this.sysLogService = sysLogService;
|
||||
}
|
||||
|
||||
public void setFinanceOrderCreateRecomService(FinanceOrderCreateRecomService financeOrderCreateRecomService) {
|
||||
this.financeOrderCreateRecomService = financeOrderCreateRecomService;
|
||||
}
|
||||
|
||||
}
|
||||
8
comm/Finance/src/project/finance/job/FinanceOrderCreateRecomService.java
Executable file
8
comm/Finance/src/project/finance/job/FinanceOrderCreateRecomService.java
Executable file
@@ -0,0 +1,8 @@
|
||||
package project.finance.job;
|
||||
|
||||
public interface FinanceOrderCreateRecomService {
|
||||
/**
|
||||
* 计算前一日购买产品的订单
|
||||
*/
|
||||
public void computeRecom();
|
||||
}
|
||||
155
comm/Finance/src/project/finance/job/FinanceOrderCreateRecomServiceImpl.java
Executable file
155
comm/Finance/src/project/finance/job/FinanceOrderCreateRecomServiceImpl.java
Executable file
@@ -0,0 +1,155 @@
|
||||
package project.finance.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.finance.FinanceOrder;
|
||||
import project.finance.FinanceOrderService;
|
||||
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 FinanceOrderCreateRecomServiceImpl implements FinanceOrderCreateRecomService {
|
||||
|
||||
protected FinanceOrderService financeOrderService;
|
||||
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 finance_buy_bonus_parameters = sysparaService.find("finance_buy_bonus_parameters").getValue();
|
||||
if (StringUtils.isEmptyString(finance_buy_bonus_parameters)) {
|
||||
return;
|
||||
}
|
||||
cacheRecomProfit.clear();
|
||||
int pageSize = 1000;
|
||||
int pageNo = 1;
|
||||
String date = DateUtils.getDateStr(DateUtils.addDate(new Date(), -1));
|
||||
while (true) {
|
||||
Page page = financeOrderService.pagedQueryByDate(pageNo, pageSize, date);
|
||||
List<FinanceOrder> list = (List<FinanceOrder>) page.getElements();
|
||||
if (list.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
for (FinanceOrder order : list) {
|
||||
handleCacheRecom(order, finance_buy_bonus_parameters);
|
||||
}
|
||||
pageNo++;
|
||||
}
|
||||
saveRecomProfit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 购买推荐奖励
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
public void handleCacheRecom(FinanceOrder entity, String finance_buy_bonus_parameters) {
|
||||
List<UserRecom> list_parents = this.userRecomService.getParents(entity.getPartyId());
|
||||
|
||||
if (CollectionUtils.isNotEmpty(list_parents)) {
|
||||
String[] finance_buy_bonus_array = finance_buy_bonus_parameters.split(",");
|
||||
int loop = 0;
|
||||
int loopMax = finance_buy_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(finance_buy_bonus_array[loop - 1]);
|
||||
double get_money = Arith.mul(entity.getAmount(), 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() {
|
||||
System.out.println("===========================================================");
|
||||
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_FINANCE);
|
||||
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_FINANCE_RECOM_PROFIT);
|
||||
moneyLogService.save(moneyLog);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFinanceOrderService(FinanceOrderService financeOrderService) {
|
||||
this.financeOrderService = financeOrderService;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
470
comm/Finance/src/project/finance/web/AdminFinanceAction.java
Executable file
470
comm/Finance/src/project/finance/web/AdminFinanceAction.java
Executable file
@@ -0,0 +1,470 @@
|
||||
package project.finance.web;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.Constants;
|
||||
import project.finance.AdminFinanceService;
|
||||
import project.finance.Finance;
|
||||
import project.finance.FinanceService;
|
||||
import project.log.LogService;
|
||||
import project.party.PartyService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
public class AdminFinanceAction extends PageActionSupport {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3791060223523658395L;
|
||||
|
||||
private static Log logger = LogFactory.getLog(AdminFinanceAction.class);
|
||||
|
||||
protected String name_para;
|
||||
|
||||
protected AdminFinanceService adminFinanceService;
|
||||
|
||||
protected FinanceService financeService;
|
||||
|
||||
protected PartyService partyService;
|
||||
|
||||
protected LogService logService;
|
||||
protected SecUserService secUserService;
|
||||
protected PasswordEncoder passwordEncoder;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 登录人资金密码
|
||||
*/
|
||||
protected String login_safeword;
|
||||
|
||||
protected String id;
|
||||
|
||||
protected String name;
|
||||
protected String name_en;
|
||||
protected String name_cn;
|
||||
protected String name_kn;
|
||||
protected String name_jn;
|
||||
|
||||
protected String img;
|
||||
|
||||
protected int cycle;
|
||||
|
||||
protected double daily_rate;
|
||||
protected double daily_rate_max;
|
||||
|
||||
protected double today_rate;
|
||||
|
||||
protected double default_ratio;
|
||||
|
||||
protected double investment_min;
|
||||
protected double investment_max;
|
||||
|
||||
|
||||
protected String state;
|
||||
|
||||
public String list() {
|
||||
this.pageSize = 300;
|
||||
this.page = this.adminFinanceService.pagedQuery(this.pageNo, this.pageSize, this.name_para);
|
||||
return "list";
|
||||
}
|
||||
|
||||
public String toAdd() {
|
||||
return "add";
|
||||
}
|
||||
|
||||
protected String verification() {
|
||||
if (StringUtils.isEmptyString(this.name))
|
||||
return "请输入产品名称";
|
||||
if (StringUtils.isEmptyString(this.img))
|
||||
return "请上传产品图片";
|
||||
if (this.cycle <= 0) {
|
||||
return "周期不能小于等于0天";
|
||||
}
|
||||
if (this.daily_rate < 0.0D) {
|
||||
return "日利率不能小于0";
|
||||
}
|
||||
if (this.daily_rate_max < 0.0D) {
|
||||
return "日利率不能小于0";
|
||||
}
|
||||
if (this.today_rate < 0.0D) {
|
||||
return "今日利率不能小于0";
|
||||
}
|
||||
if (this.default_ratio < 0.0D) {
|
||||
return "违约结算比例不能小于0";
|
||||
}
|
||||
if (this.investment_min < 0.0D) {
|
||||
return "投资金额区间不能小于0";
|
||||
}
|
||||
if (this.investment_max <= investment_min) {
|
||||
return "投资金额区间错误";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String add() {
|
||||
try {
|
||||
this.error = verification();
|
||||
if (!StringUtils.isNullOrEmpty(this.error))
|
||||
return toAdd();
|
||||
|
||||
if (StringUtils.isNullOrEmpty(this.login_safeword)) {
|
||||
this.error = "请输入登录人资金密码";
|
||||
return toAdd();
|
||||
}
|
||||
// if (this.financeService.findByName(this.name) != null) {
|
||||
// this.error ="产品名称已存在";
|
||||
// return toAdd();
|
||||
// }
|
||||
Finance finance = new Finance();
|
||||
finance.setName(this.name);
|
||||
finance.setName_en(this.name_en);
|
||||
finance.setName_cn(this.name_cn);
|
||||
finance.setName_kn(this.name_kn);
|
||||
finance.setName_jn(this.name_jn);
|
||||
finance.setImg(this.img);
|
||||
finance.setCycle(this.cycle);
|
||||
finance.setDaily_rate(this.daily_rate);
|
||||
finance.setDaily_rate_max(this.daily_rate_max);
|
||||
finance.setToday_rate(this.today_rate);
|
||||
finance.setDefault_ratio(this.default_ratio);
|
||||
finance.setInvestment_min(this.investment_min);
|
||||
finance.setInvestment_max(this.investment_max);
|
||||
finance.setState(this.state);
|
||||
|
||||
this.financeService.save(finance,this.login_safeword,this.getUsername_login());
|
||||
this.message = "操作成功";
|
||||
|
||||
project.log.Log log = new project.log.Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(this.getUsername_login());
|
||||
log.setOperator(this.getUsername_login());
|
||||
log.setLog("管理员手动添加理财产品,ip:["+this.getIp(getRequest())+"]");
|
||||
logService.saveSync(log);
|
||||
|
||||
} 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();
|
||||
}
|
||||
|
||||
protected String verificationUpdate() {
|
||||
if (StringUtils.isEmptyString(this.name))
|
||||
return "请输入产品名称";
|
||||
if (StringUtils.isEmptyString(this.img))
|
||||
return "请上传产品图片";
|
||||
if (this.cycle <= 0) {
|
||||
return "周期不能小于等于0天";
|
||||
}
|
||||
if (this.daily_rate < 0.0D) {
|
||||
return "日利率不能小于0";
|
||||
}
|
||||
if (this.daily_rate_max < 0.0D) {
|
||||
return "日利率不能小于0";
|
||||
}
|
||||
if (this.today_rate < 0.0D) {
|
||||
return "今日利率不能小于0";
|
||||
}
|
||||
if (this.default_ratio < 0.0D) {
|
||||
return "违约结算比例不能小于0";
|
||||
}
|
||||
if (this.investment_min < 0.0D) {
|
||||
return "投资金额区间不能小于0";
|
||||
}
|
||||
if (this.investment_max <= investment_min) {
|
||||
return "投资金额区间错误";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toUpdate() {
|
||||
Finance finance = this.financeService.findById(this.id);
|
||||
this.name = finance.getName();
|
||||
this.name_en = finance.getName_en();
|
||||
this.name_cn = finance.getName_cn();
|
||||
this.name_kn = finance.getName_kn();
|
||||
this.name_jn = finance.getName_jn();
|
||||
this.img = finance.getImg();
|
||||
this.cycle = finance.getCycle();
|
||||
this.daily_rate = finance.getDaily_rate();
|
||||
this.daily_rate_max = finance.getDaily_rate_max();
|
||||
this.today_rate = finance.getToday_rate();
|
||||
this.default_ratio = finance.getDefault_ratio();
|
||||
this.investment_min = finance.getInvestment_min();
|
||||
this.investment_max = finance.getInvestment_max();
|
||||
this.state = finance.getState();
|
||||
|
||||
return "update";
|
||||
}
|
||||
|
||||
public String update() {
|
||||
|
||||
Finance finance = this.financeService.findById(this.id);
|
||||
try {
|
||||
this.error = verificationUpdate();
|
||||
if (!StringUtils.isNullOrEmpty(this.error))
|
||||
return toUpdate();
|
||||
|
||||
if (StringUtils.isNullOrEmpty(this.login_safeword)) {
|
||||
this.error = "请输入登录人资金密码";
|
||||
return toUpdate();
|
||||
}
|
||||
// if (this.financeService.findByName(this.name) != null) {
|
||||
// this.error ="产品名称已存在";
|
||||
// return toAdd();
|
||||
// }
|
||||
finance.setName(this.name);
|
||||
finance.setName_en(this.name_en);
|
||||
finance.setName_cn(this.name_cn);
|
||||
finance.setName_jn(this.name_jn);
|
||||
finance.setName_kn(this.name_kn);
|
||||
finance.setImg(this.img);
|
||||
finance.setCycle(this.cycle);
|
||||
finance.setDaily_rate(this.daily_rate);
|
||||
finance.setDaily_rate_max(this.daily_rate_max);
|
||||
finance.setToday_rate(this.today_rate);
|
||||
finance.setDefault_ratio(this.default_ratio);
|
||||
finance.setInvestment_min(this.investment_min);
|
||||
finance.setInvestment_max(this.investment_max);
|
||||
finance.setState(this.state);
|
||||
this.financeService.update(finance,this.login_safeword,this.getUsername_login());
|
||||
this.message = "操作成功";
|
||||
|
||||
project.log.Log log = new project.log.Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(this.getUsername_login());
|
||||
log.setOperator(this.getUsername_login());
|
||||
log.setLog("管理员手动修改里财产品配置,ip:["+this.getIp(getRequest())+"]");
|
||||
logService.saveSync(log);
|
||||
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 {
|
||||
if (StringUtils.isNullOrEmpty(this.login_safeword)) {
|
||||
this.error = "请输入登录人资金密码";
|
||||
return list();
|
||||
}
|
||||
this.financeService.delete(this.id,this.login_safeword,this.getUsername_login());
|
||||
this.message = "操作成功";
|
||||
|
||||
project.log.Log log = new project.log.Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(this.getUsername_login());
|
||||
log.setOperator(this.getUsername_login());
|
||||
log.setLog("管理员手动删除理财产品,ip:["+this.getIp(getRequest())+"]");
|
||||
logService.saveSync(log);
|
||||
|
||||
return list();
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
return list();
|
||||
} catch (Throwable t) {
|
||||
logger.error("update error ", t);
|
||||
this.error = "程序错误";
|
||||
return list();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
* @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 String getName_para() {
|
||||
return this.name_para;
|
||||
}
|
||||
|
||||
public void setName_para(String name_para) {
|
||||
this.name_para = name_para;
|
||||
}
|
||||
|
||||
public void setAdminFinanceService(AdminFinanceService adminFinanceService) {
|
||||
this.adminFinanceService = adminFinanceService;
|
||||
}
|
||||
|
||||
public void setFinanceService(FinanceService financeService) {
|
||||
this.financeService = financeService;
|
||||
}
|
||||
|
||||
public void setPartyService(PartyService partyService) {
|
||||
this.partyService = partyService;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getImg() {
|
||||
return img;
|
||||
}
|
||||
|
||||
public void setImg(String img) {
|
||||
this.img = img;
|
||||
}
|
||||
|
||||
public int getCycle() {
|
||||
return cycle;
|
||||
}
|
||||
|
||||
public void setCycle(int cycle) {
|
||||
this.cycle = cycle;
|
||||
}
|
||||
|
||||
public double getDaily_rate() {
|
||||
return daily_rate;
|
||||
}
|
||||
|
||||
public void setDaily_rate(double daily_rate) {
|
||||
this.daily_rate = daily_rate;
|
||||
}
|
||||
|
||||
public double getToday_rate() {
|
||||
return today_rate;
|
||||
}
|
||||
|
||||
public void setToday_rate(double today_rate) {
|
||||
this.today_rate = today_rate;
|
||||
}
|
||||
|
||||
public double getDefault_ratio() {
|
||||
return default_ratio;
|
||||
}
|
||||
|
||||
public void setDefault_ratio(double default_ratio) {
|
||||
this.default_ratio = default_ratio;
|
||||
}
|
||||
|
||||
public double getInvestment_min() {
|
||||
return investment_min;
|
||||
}
|
||||
|
||||
public void setInvestment_min(double investment_min) {
|
||||
this.investment_min = investment_min;
|
||||
}
|
||||
|
||||
public double getInvestment_max() {
|
||||
return investment_max;
|
||||
}
|
||||
|
||||
public void setInvestment_max(double investment_max) {
|
||||
this.investment_max = investment_max;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getName_en() {
|
||||
return name_en;
|
||||
}
|
||||
|
||||
public void setName_en(String name_en) {
|
||||
this.name_en = name_en;
|
||||
}
|
||||
|
||||
public String getName_cn() {
|
||||
return name_cn;
|
||||
}
|
||||
|
||||
public void setName_cn(String name_cn) {
|
||||
this.name_cn = name_cn;
|
||||
}
|
||||
|
||||
public String getName_kn() {
|
||||
return name_kn;
|
||||
}
|
||||
|
||||
public void setName_kn(String name_kn) {
|
||||
this.name_kn = name_kn;
|
||||
}
|
||||
|
||||
public String getName_jn() {
|
||||
return name_jn;
|
||||
}
|
||||
|
||||
public void setName_jn(String name_jn) {
|
||||
this.name_jn = name_jn;
|
||||
}
|
||||
|
||||
public double getDaily_rate_max() {
|
||||
return daily_rate_max;
|
||||
}
|
||||
|
||||
public void setDaily_rate_max(double daily_rate_max) {
|
||||
this.daily_rate_max = daily_rate_max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
public String getLogin_safeword() {
|
||||
return login_safeword;
|
||||
}
|
||||
|
||||
public void setLogin_safeword(String login_safeword) {
|
||||
this.login_safeword = login_safeword;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
356
comm/Finance/src/project/finance/web/AdminFinanceOrderAction.java
Executable file
356
comm/Finance/src/project/finance/web/AdminFinanceOrderAction.java
Executable file
@@ -0,0 +1,356 @@
|
||||
package project.finance.web;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
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 org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.ThreadUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.Constants;
|
||||
import project.finance.AdminFinanceOrderService;
|
||||
import project.finance.Finance;
|
||||
import project.finance.FinanceOrder;
|
||||
import project.finance.FinanceOrderLock;
|
||||
import project.finance.FinanceOrderService;
|
||||
import project.finance.FinanceService;
|
||||
import project.finance.job.FinanceOrder1DayJob;
|
||||
import project.log.LogService;
|
||||
import project.party.model.Party;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
import util.DateUtils;
|
||||
|
||||
public class AdminFinanceOrderAction extends PageActionSupport {
|
||||
|
||||
private static final long serialVersionUID = -3572452265421015850L;
|
||||
|
||||
private static Log logger = LogFactory.getLog(AdminFinanceOrderAction.class);
|
||||
|
||||
private String name_para;
|
||||
private String finance_para;
|
||||
private String status_para;
|
||||
private String order_no_para;
|
||||
private String rolename_para;
|
||||
|
||||
protected AdminFinanceOrderService adminFinanceOrderService;
|
||||
|
||||
protected FinanceOrderService financeOrderService;
|
||||
|
||||
protected FinanceService financeService;
|
||||
protected FinanceOrder1DayJob financeOrder1DayJob;
|
||||
|
||||
protected LogService logService;
|
||||
protected SecUserService secUserService;
|
||||
protected PasswordEncoder passwordEncoder;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 登录人资金密码
|
||||
*/
|
||||
protected String login_safeword;
|
||||
|
||||
protected String id;
|
||||
protected String order_no;
|
||||
|
||||
protected String state;
|
||||
|
||||
protected String system_time;
|
||||
|
||||
|
||||
public String list() {
|
||||
this.pageSize = 20;
|
||||
String partyId = getLoginPartyId();
|
||||
this.page = this.adminFinanceOrderService.pagedQuery(this.pageNo, this.pageSize, this.name_para,
|
||||
this.finance_para, this.status_para, partyId,order_no_para,this.rolename_para);
|
||||
|
||||
|
||||
|
||||
|
||||
return "list";
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台赎回
|
||||
*/
|
||||
public String close() {
|
||||
try {
|
||||
|
||||
|
||||
FinanceOrder order = financeOrderService.findById(id);
|
||||
CloseDelayThread lockDelayThread = new CloseDelayThread(id, order.getOrder_no(), financeOrderService);
|
||||
Thread t = new Thread(lockDelayThread);
|
||||
t.start();
|
||||
|
||||
|
||||
SecUser sec_user = this.secUserService.findUserByPartyId(order.getPartyId());
|
||||
|
||||
project.log.Log log = new project.log.Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(sec_user.getUsername());
|
||||
log.setPartyId(sec_user.getPartyId());
|
||||
log.setOperator(this.getUsername_login());
|
||||
log.setLog("管理员手动赎回理财订单,订单号:["+order.getOrder_no()+"],ip:["+this.getIp(getRequest())+"]");
|
||||
logService.saveSync(log);
|
||||
|
||||
this.message = "操作成功";
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
} catch (Exception e) {
|
||||
logger.error("error ", e);
|
||||
this.error = "程序错误";
|
||||
}
|
||||
return list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新线程处理,直接拿到订单锁处理完成后退出
|
||||
*
|
||||
*/
|
||||
public class CloseDelayThread implements Runnable {
|
||||
private String id;
|
||||
private String order_no;
|
||||
private FinanceOrderService financeOrderService;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
while (true) {
|
||||
if (FinanceOrderLock.add(order_no)) {
|
||||
/**
|
||||
* 提前赎回理财产品需要支付违约金
|
||||
*/
|
||||
FinanceOrder order = financeOrderService.findById(id);
|
||||
Finance finance = financeService.findById(order.getFinanceId());
|
||||
if ("1".equals(order.getState())) {
|
||||
/**
|
||||
* 扣除违约金
|
||||
*/
|
||||
Date date_now = new Date();// 取时间
|
||||
double last_days = daysBetween(date_now, order.getStop_time());
|
||||
if (last_days <= 0) {
|
||||
last_days = 1;
|
||||
}
|
||||
double default_ratio = Arith.mul(finance.getDefault_ratio(), 0.01);
|
||||
default_ratio = Arith.mul(default_ratio, last_days);
|
||||
double breach_amount = Arith.mul(order.getAmount(), default_ratio);
|
||||
order.setProfit(Arith.sub(0, breach_amount));
|
||||
order.setState("2");
|
||||
|
||||
this.financeOrderService.saveClose(order);
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 处理完退出
|
||||
*/
|
||||
break;
|
||||
}
|
||||
ThreadUtils.sleep(500);
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("error:", e);
|
||||
} finally {
|
||||
FinanceOrderLock.remove(order_no);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CloseDelayThread(String id, String order_no, FinanceOrderService financeOrderService) {
|
||||
this.id = id;
|
||||
this.order_no = order_no;
|
||||
this.financeOrderService = financeOrderService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String addProfit() {
|
||||
try {
|
||||
if(!"root".equals(this.getUsername_login())) {
|
||||
throw new BusinessException("权限不足");
|
||||
}
|
||||
if(StringUtils.isEmpty(system_time)) {
|
||||
throw new BusinessException("请填入系统时间");
|
||||
}
|
||||
JobDelayThread thread = new JobDelayThread(DateUtils.toDate(system_time, DateUtils.NORMAL_DATE_FORMAT), financeOrder1DayJob);
|
||||
Thread t = new Thread(thread);
|
||||
t.start();
|
||||
this.message = "操作成功";
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
} catch (Exception e) {
|
||||
logger.error("error ", e);
|
||||
this.error = "程序错误";
|
||||
}
|
||||
return list();
|
||||
}
|
||||
|
||||
|
||||
public class JobDelayThread implements Runnable {
|
||||
private FinanceOrder1DayJob financeOrder1DayJob;
|
||||
private Date systemTime;
|
||||
public void run() {
|
||||
financeOrder1DayJob.handleData(systemTime);
|
||||
}
|
||||
|
||||
public JobDelayThread(Date systemTime, FinanceOrder1DayJob financeOrder1DayJob) {
|
||||
this.systemTime = systemTime;
|
||||
this.financeOrder1DayJob = financeOrder1DayJob;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
* @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 String getName_para() {
|
||||
return this.name_para;
|
||||
}
|
||||
|
||||
public void setName_para(String name_para) {
|
||||
this.name_para = name_para;
|
||||
}
|
||||
|
||||
public void setFinanceService(FinanceService financeService) {
|
||||
this.financeService = financeService;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getFinance_para() {
|
||||
return finance_para;
|
||||
}
|
||||
|
||||
public void setFinance_para(String finance_para) {
|
||||
this.finance_para = finance_para;
|
||||
}
|
||||
|
||||
public String getOrder_no() {
|
||||
return order_no;
|
||||
}
|
||||
|
||||
public void setOrder_no(String order_no) {
|
||||
this.order_no = order_no;
|
||||
}
|
||||
|
||||
public void setFinanceOrderService(FinanceOrderService financeOrderService) {
|
||||
this.financeOrderService = financeOrderService;
|
||||
}
|
||||
|
||||
public void setAdminFinanceOrderService(AdminFinanceOrderService adminFinanceOrderService) {
|
||||
this.adminFinanceOrderService = adminFinanceOrderService;
|
||||
}
|
||||
|
||||
public String getStatus_para() {
|
||||
return status_para;
|
||||
}
|
||||
|
||||
public void setStatus_para(String status_para) {
|
||||
this.status_para = status_para;
|
||||
}
|
||||
|
||||
public static int daysBetween(Date smdate, Date bdate) throws ParseException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
smdate = sdf.parse(sdf.format(smdate));
|
||||
bdate = sdf.parse(sdf.format(bdate));
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(smdate);
|
||||
long time1 = cal.getTimeInMillis();
|
||||
cal.setTime(bdate);
|
||||
long time2 = cal.getTimeInMillis();
|
||||
long between_days = (time2 - time1) / (1000 * 3600 * 24);
|
||||
|
||||
return Integer.parseInt(String.valueOf(between_days));
|
||||
}
|
||||
|
||||
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 getRolename_para() {
|
||||
return rolename_para;
|
||||
}
|
||||
|
||||
public void setRolename_para(String rolename_para) {
|
||||
this.rolename_para = rolename_para;
|
||||
}
|
||||
|
||||
public String getSystem_time() {
|
||||
return system_time;
|
||||
}
|
||||
|
||||
public void setFinanceOrder1DayJob(FinanceOrder1DayJob financeOrder1DayJob) {
|
||||
this.financeOrder1DayJob = financeOrder1DayJob;
|
||||
}
|
||||
|
||||
public void setSystem_time(String system_time) {
|
||||
this.system_time = system_time;
|
||||
}
|
||||
|
||||
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
public String getLogin_safeword() {
|
||||
return login_safeword;
|
||||
}
|
||||
|
||||
public void setLogin_safeword(String login_safeword) {
|
||||
this.login_safeword = login_safeword;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
425
comm/Finance/src/project/web/admin/AdminFinanceController.java
Executable file
425
comm/Finance/src/project/web/admin/AdminFinanceController.java
Executable file
@@ -0,0 +1,425 @@
|
||||
package project.web.admin;
|
||||
|
||||
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.security.providers.encoding.PasswordEncoder;
|
||||
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.finance.AdminFinanceService;
|
||||
import project.finance.Finance;
|
||||
import project.finance.FinanceService;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.party.PartyService;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
/**
|
||||
* 理财配置
|
||||
*/
|
||||
@RestController
|
||||
public class AdminFinanceController extends PageActionSupport {
|
||||
|
||||
private Logger logger = LogManager.getLogger(AdminFinanceController.class);
|
||||
|
||||
@Autowired
|
||||
protected AdminFinanceService adminFinanceService;
|
||||
@Autowired
|
||||
protected FinanceService financeService;
|
||||
@Autowired
|
||||
protected PartyService partyService;
|
||||
@Autowired
|
||||
protected LogService logService;
|
||||
@Autowired
|
||||
protected SecUserService secUserService;
|
||||
@Autowired
|
||||
protected PasswordEncoder passwordEncoder;
|
||||
|
||||
private final String action = "/normal/adminFinanceAction!";
|
||||
|
||||
/**
|
||||
* 获取 理财配置 列表
|
||||
*/
|
||||
@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("finance_list");
|
||||
|
||||
try {
|
||||
|
||||
this.checkAndSetPageNo(pageNo);
|
||||
|
||||
this.pageSize = 300;
|
||||
|
||||
this.page = this.adminFinanceService.pagedQuery(this.pageNo, this.pageSize, name_para);
|
||||
|
||||
} 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() {
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("finance_add");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 理财配置
|
||||
*/
|
||||
@RequestMapping(action + "add.action")
|
||||
public ModelAndView add(HttpServletRequest request) {
|
||||
// 产品名称
|
||||
String name = request.getParameter("name");
|
||||
// 产品图片
|
||||
String img = request.getParameter("img");
|
||||
// 周期
|
||||
String cycle = request.getParameter("cycle");
|
||||
// 日利率
|
||||
String daily_rate = request.getParameter("daily_rate");
|
||||
String daily_rate_max = request.getParameter("daily_rate_max");
|
||||
// 今日利率
|
||||
String today_rate = request.getParameter("today_rate");
|
||||
// 违约结算比例
|
||||
String default_ratio = request.getParameter("default_ratio");
|
||||
// 投资金额区间min
|
||||
String investment_min = request.getParameter("investment_min");
|
||||
// 投资金额区间max
|
||||
String investment_max = request.getParameter("investment_max");
|
||||
// 资金密码
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
String name_en = request.getParameter("name_en");
|
||||
String name_cn = request.getParameter("name_cn");
|
||||
String name_kn = request.getParameter("name_kn");
|
||||
String name_jn = request.getParameter("name_jn");
|
||||
String state = request.getParameter("state");
|
||||
|
||||
ModelAndView model = new ModelAndView();
|
||||
model.addObject("name", name);
|
||||
model.addObject("img", img);
|
||||
model.addObject("cycle", cycle);
|
||||
model.addObject("daily_rate", daily_rate);
|
||||
model.addObject("daily_rate_max", daily_rate_max);
|
||||
model.addObject("today_rate", today_rate);
|
||||
model.addObject("default_ratio", default_ratio);
|
||||
model.addObject("investment_min", investment_min);
|
||||
model.addObject("investment_max", investment_max);
|
||||
model.addObject("name_en", name_en);
|
||||
model.addObject("name_cn", name_cn);
|
||||
model.addObject("name_kn", name_kn);
|
||||
model.addObject("name_jn", name_jn);
|
||||
model.addObject("state", state);
|
||||
|
||||
try {
|
||||
|
||||
String error = this.verification(name, img, cycle, daily_rate, daily_rate_max, today_rate,
|
||||
default_ratio, investment_min, investment_max, login_safeword);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
Finance finance = new Finance();
|
||||
finance.setName(name);
|
||||
finance.setName_en(name_en);
|
||||
finance.setName_cn(name_cn);
|
||||
finance.setName_kn(name_kn);
|
||||
finance.setName_jn(name_jn);
|
||||
finance.setImg(img);
|
||||
finance.setCycle(Integer.valueOf(cycle));
|
||||
finance.setDaily_rate(Double.valueOf(daily_rate));
|
||||
finance.setDaily_rate_max(Double.valueOf(daily_rate_max));
|
||||
finance.setToday_rate(Double.valueOf(today_rate));
|
||||
finance.setDefault_ratio(Double.valueOf(default_ratio));
|
||||
finance.setInvestment_min(Double.valueOf(investment_min));
|
||||
finance.setInvestment_max(Double.valueOf(investment_max));
|
||||
finance.setState(state);
|
||||
|
||||
this.financeService.save(finance, login_safeword, this.getUsername_login());
|
||||
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(this.getUsername_login());
|
||||
log.setOperator(this.getUsername_login());
|
||||
log.setLog("管理员手动添加理财配置,ip:["+this.getIp(request)+"]");
|
||||
logService.saveSync(log);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
model.addObject("error", e.getMessage());
|
||||
model.setViewName("finance_add");
|
||||
return model;
|
||||
} catch (Throwable t) {
|
||||
logger.error("UserAction.register error ", t);
|
||||
model.addObject("error", error);
|
||||
model.setViewName("finance_add");
|
||||
return model;
|
||||
}
|
||||
|
||||
model.addObject("message", "操作成功");
|
||||
model.setViewName("redirect:/" + action + "list.action");
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 理财配置 页面
|
||||
*/
|
||||
@RequestMapping(action + "toUpdate.action")
|
||||
public ModelAndView toUpdate(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
Finance finance = this.financeService.findById(id);
|
||||
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("name", finance.getName());
|
||||
modelAndView.addObject("img", finance.getImg());
|
||||
modelAndView.addObject("cycle", finance.getCycle());
|
||||
modelAndView.addObject("daily_rate", finance.getDaily_rate());
|
||||
modelAndView.addObject("daily_rate_max", finance.getDaily_rate_max());
|
||||
modelAndView.addObject("today_rate", finance.getToday_rate());
|
||||
modelAndView.addObject("default_ratio", finance.getDefault_ratio());
|
||||
modelAndView.addObject("investment_min", finance.getInvestment_min());
|
||||
modelAndView.addObject("investment_max", finance.getInvestment_max());
|
||||
modelAndView.addObject("name_en", finance.getName_en());
|
||||
modelAndView.addObject("name_cn", finance.getName_cn());
|
||||
modelAndView.addObject("name_kn", finance.getName_kn());
|
||||
modelAndView.addObject("name_jn", finance.getName_jn());
|
||||
modelAndView.addObject("state", finance.getState());
|
||||
|
||||
} 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("finance_update");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 理财配置
|
||||
*/
|
||||
@RequestMapping(action + "update.action")
|
||||
public ModelAndView update(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
// 产品名称
|
||||
String name = request.getParameter("name");
|
||||
// 产品图片
|
||||
String img = request.getParameter("img");
|
||||
// 周期
|
||||
String cycle = request.getParameter("cycle");
|
||||
// 日利率
|
||||
String daily_rate = request.getParameter("daily_rate");
|
||||
String daily_rate_max = request.getParameter("daily_rate_max");
|
||||
// 今日利率
|
||||
String today_rate = request.getParameter("today_rate");
|
||||
// 违约结算比例
|
||||
String default_ratio = request.getParameter("default_ratio");
|
||||
// 投资金额区间min
|
||||
String investment_min = request.getParameter("investment_min");
|
||||
// 投资金额区间max
|
||||
String investment_max = request.getParameter("investment_max");
|
||||
String name_en = request.getParameter("name_en");
|
||||
String name_cn = request.getParameter("name_cn");
|
||||
String name_kn = request.getParameter("name_kn");
|
||||
String name_jn = request.getParameter("name_jn");
|
||||
String state = request.getParameter("state");
|
||||
// 资金密码
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView model = new ModelAndView();
|
||||
model.addObject("id", id);
|
||||
model.addObject("name", name);
|
||||
model.addObject("img", img);
|
||||
model.addObject("cycle", cycle);
|
||||
model.addObject("daily_rate", daily_rate);
|
||||
model.addObject("daily_rate_max", daily_rate_max);
|
||||
model.addObject("today_rate", today_rate);
|
||||
model.addObject("default_ratio", default_ratio);
|
||||
model.addObject("investment_min", investment_min);
|
||||
model.addObject("investment_max", investment_max);
|
||||
model.addObject("name_en", name_en);
|
||||
model.addObject("name_cn", name_cn);
|
||||
model.addObject("name_kn", name_kn);
|
||||
model.addObject("name_jn", name_jn);
|
||||
model.addObject("state", state);
|
||||
|
||||
try {
|
||||
|
||||
String error = this.verification(name, img, cycle, daily_rate, daily_rate_max, today_rate,
|
||||
default_ratio, investment_min, investment_max, login_safeword);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
Finance finance = this.financeService.findById(id);
|
||||
|
||||
finance.setName(name);
|
||||
finance.setName_en(name_en);
|
||||
finance.setName_cn(name_cn);
|
||||
finance.setName_kn(name_kn);
|
||||
finance.setName_jn(name_jn);
|
||||
finance.setImg(img);
|
||||
finance.setCycle(Integer.valueOf(cycle));
|
||||
finance.setDaily_rate(Double.valueOf(daily_rate));
|
||||
finance.setDaily_rate_max(Double.valueOf(daily_rate_max));
|
||||
finance.setToday_rate(Double.valueOf(today_rate));
|
||||
finance.setDefault_ratio(Double.valueOf(default_ratio));
|
||||
finance.setInvestment_min(Double.valueOf(investment_min));
|
||||
finance.setInvestment_max(Double.valueOf(investment_max));
|
||||
finance.setState(state);
|
||||
|
||||
this.financeService.update(finance, login_safeword, this.getUsername_login());
|
||||
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(this.getUsername_login());
|
||||
log.setOperator(this.getUsername_login());
|
||||
log.setLog("管理员手动修改理财配置,ip:["+this.getIp(getRequest())+"]");
|
||||
logService.saveSync(log);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
model.addObject("error", e.getMessage());
|
||||
model.setViewName("finance_update");
|
||||
return model;
|
||||
} catch (Throwable t) {
|
||||
logger.error("update error ", t);
|
||||
model.addObject("error", "程序错误");
|
||||
model.setViewName("finance_update");
|
||||
return model;
|
||||
}
|
||||
|
||||
model.addObject("message", "操作成功");
|
||||
model.setViewName("redirect:/" + action + "list.action");
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 理财配置
|
||||
*/
|
||||
@RequestMapping(action + "toDelete.action")
|
||||
public ModelAndView toDelete(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
|
||||
try {
|
||||
|
||||
if (StringUtils.isNullOrEmpty(login_safeword)) {
|
||||
throw new BusinessException("请输入登录人资金密码");
|
||||
}
|
||||
|
||||
this.financeService.delete(id, login_safeword, this.getUsername_login());
|
||||
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(this.getUsername_login());
|
||||
log.setOperator(this.getUsername_login());
|
||||
log.setLog("管理员手动删除理财配置,ip:["+this.getIp(getRequest())+"]");
|
||||
logService.saveSync(log);
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
protected String verification(String name, String img, String cycle, String daily_rate, String daily_rate_max, String today_rate,
|
||||
String default_ratio, String investment_min, String investment_max, String login_safeword) {
|
||||
if (StringUtils.isEmptyString(name)) {
|
||||
return "请输入产品名称";
|
||||
}
|
||||
if (StringUtils.isEmptyString(img)) {
|
||||
return "请上传产品图片";
|
||||
}
|
||||
if (StringUtils.isEmptyString(login_safeword)) {
|
||||
return "请输入登录人资金密码";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(cycle)
|
||||
|| !StringUtils.isInteger(cycle)
|
||||
|| Integer.valueOf(cycle) <= 0) {
|
||||
return "周期不能小于等于0天";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(daily_rate)
|
||||
|| !StringUtils.isDouble(daily_rate)
|
||||
|| Double.valueOf(daily_rate) < 0) {
|
||||
return "日利率不能小于0";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(daily_rate_max)
|
||||
|| !StringUtils.isDouble(daily_rate_max)
|
||||
|| Double.valueOf(daily_rate_max) < 0) {
|
||||
return "日利率不能小于0";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(today_rate)
|
||||
|| !StringUtils.isDouble(today_rate)
|
||||
|| Double.valueOf(today_rate) < 0) {
|
||||
return "今日利率不能小于0";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(default_ratio)
|
||||
|| !StringUtils.isDouble(default_ratio)
|
||||
|| Double.valueOf(default_ratio) < 0) {
|
||||
return "违约结算比例不能小于0";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(investment_min)
|
||||
|| !StringUtils.isDouble(investment_min)
|
||||
|| Double.valueOf(investment_min) < 0) {
|
||||
return "投资金额区间不能小于0";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(investment_max)
|
||||
|| !StringUtils.isDouble(investment_max)
|
||||
|| Double.valueOf(investment_max) < 0) {
|
||||
return "投资金额区间不能小于0";
|
||||
}
|
||||
if (Double.valueOf(investment_max) <= Double.valueOf(investment_min)) {
|
||||
return "投资金额区间错误";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
296
comm/Finance/src/project/web/admin/AdminFinanceOrderController.java
Executable file
296
comm/Finance/src/project/web/admin/AdminFinanceOrderController.java
Executable file
@@ -0,0 +1,296 @@
|
||||
package project.web.admin;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
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.ThreadUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.Constants;
|
||||
import project.finance.AdminFinanceOrderService;
|
||||
import project.finance.Finance;
|
||||
import project.finance.FinanceOrder;
|
||||
import project.finance.FinanceOrderLock;
|
||||
import project.finance.FinanceOrderService;
|
||||
import project.finance.FinanceService;
|
||||
import project.finance.job.FinanceOrder1DayJob;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
import util.DateUtils;
|
||||
|
||||
/**
|
||||
* 理财产品订单
|
||||
*/
|
||||
@RestController
|
||||
public class AdminFinanceOrderController extends PageActionSupport {
|
||||
|
||||
private Logger logger = LogManager.getLogger(AdminFinanceOrderController.class);
|
||||
|
||||
@Autowired
|
||||
protected AdminFinanceOrderService adminFinanceOrderService;
|
||||
@Autowired
|
||||
protected FinanceOrderService financeOrderService;
|
||||
@Autowired
|
||||
protected FinanceService financeService;
|
||||
@Autowired
|
||||
protected FinanceOrder1DayJob financeOrder1DayJob;
|
||||
@Autowired
|
||||
protected LogService logService;
|
||||
@Autowired
|
||||
protected SecUserService secUserService;
|
||||
@Autowired
|
||||
protected PasswordEncoder passwordEncoder;
|
||||
|
||||
private final String action = "normal/adminFinanceOrderAction!";
|
||||
|
||||
/**
|
||||
* 获取 理财产品订单 列表
|
||||
*/
|
||||
@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");
|
||||
String finance_para = request.getParameter("finance_para");
|
||||
String status_para = request.getParameter("status_para");
|
||||
String order_no_para = request.getParameter("order_no_para");
|
||||
String rolename_para = request.getParameter("rolename_para");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("finance_order_list");
|
||||
|
||||
try {
|
||||
|
||||
this.checkAndSetPageNo(pageNo);
|
||||
|
||||
this.pageSize = 20;
|
||||
|
||||
String partyId = this.getLoginPartyId();
|
||||
|
||||
this.page = this.adminFinanceOrderService.pagedQuery(this.pageNo, this.pageSize, name_para, finance_para,
|
||||
status_para, partyId, order_no_para, rolename_para);
|
||||
|
||||
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("name_para", name_para);
|
||||
modelAndView.addObject("finance_para", finance_para);
|
||||
modelAndView.addObject("status_para", status_para);
|
||||
modelAndView.addObject("order_no_para", order_no_para);
|
||||
modelAndView.addObject("rolename_para", rolename_para);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台赎回
|
||||
*/
|
||||
@RequestMapping(action + "close.action")
|
||||
public ModelAndView close(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
|
||||
try {
|
||||
|
||||
FinanceOrder order = this.financeOrderService.findById(id);
|
||||
|
||||
CloseDelayThread lockDelayThread = new CloseDelayThread(id, order.getOrder_no(), this.financeService, this.financeOrderService);
|
||||
|
||||
Thread t = new Thread(lockDelayThread);
|
||||
t.start();
|
||||
|
||||
SecUser sec_user = this.secUserService.findUserByPartyId(order.getPartyId());
|
||||
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(sec_user.getUsername());
|
||||
log.setPartyId(sec_user.getPartyId());
|
||||
log.setOperator(this.getUsername_login());
|
||||
log.setLog("管理员手动赎回理财订单,订单号:[" + order.getOrder_no() + "],ip:[" + this.getIp(getRequest()) + "]");
|
||||
logService.saveSync(log);
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 利息重计
|
||||
*/
|
||||
@RequestMapping(action + "addProfit.action")
|
||||
public ModelAndView addProfit(HttpServletRequest request) {
|
||||
String system_time = request.getParameter("system_time");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
|
||||
try {
|
||||
|
||||
if (!"root".equals(this.getUsername_login())) {
|
||||
throw new BusinessException("权限不足");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(system_time)) {
|
||||
throw new BusinessException("请填入系统时间");
|
||||
}
|
||||
|
||||
JobDelayThread thread = new JobDelayThread(DateUtils.toDate(system_time, DateUtils.NORMAL_DATE_FORMAT), this.financeOrder1DayJob);
|
||||
Thread t = new Thread(thread);
|
||||
t.start();
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
public static int daysBetween(Date smdate, Date bdate) throws ParseException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
smdate = sdf.parse(sdf.format(smdate));
|
||||
bdate = sdf.parse(sdf.format(bdate));
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(smdate);
|
||||
long time1 = cal.getTimeInMillis();
|
||||
cal.setTime(bdate);
|
||||
long time2 = cal.getTimeInMillis();
|
||||
long between_days = (time2 - time1) / (1000 * 3600 * 24);
|
||||
return Integer.parseInt(String.valueOf(between_days));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新线程处理,直接拿到订单锁处理完成后退出
|
||||
*/
|
||||
public class CloseDelayThread implements Runnable {
|
||||
private String id;
|
||||
private String order_no;
|
||||
private FinanceService financeService;
|
||||
private FinanceOrderService financeOrderService;
|
||||
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
|
||||
while (true) {
|
||||
|
||||
if (FinanceOrderLock.add(order_no)) {
|
||||
|
||||
// 提前赎回理财产品需要支付违约金
|
||||
FinanceOrder order = this.financeOrderService.findById(id);
|
||||
Finance finance = this.financeService.findById(order.getFinanceId());
|
||||
|
||||
if ("1".equals(order.getState())) {
|
||||
|
||||
// 取时间
|
||||
Date date_now = new Date();
|
||||
|
||||
// 扣除违约金
|
||||
double last_days = daysBetween(date_now, order.getStop_time());
|
||||
if (last_days <= 0) {
|
||||
last_days = 1;
|
||||
}
|
||||
|
||||
double default_ratio = Arith.mul(finance.getDefault_ratio(), 0.01);
|
||||
default_ratio = Arith.mul(default_ratio, last_days);
|
||||
double breach_amount = Arith.mul(order.getAmount(), default_ratio);
|
||||
order.setProfit(Arith.sub(0, breach_amount));
|
||||
order.setState("2");
|
||||
|
||||
this.financeOrderService.saveClose(order);
|
||||
}
|
||||
|
||||
// 处理完退出
|
||||
break;
|
||||
}
|
||||
|
||||
ThreadUtils.sleep(500);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("error:", e);
|
||||
} finally {
|
||||
FinanceOrderLock.remove(order_no);
|
||||
}
|
||||
}
|
||||
|
||||
public CloseDelayThread(String id, String order_no, FinanceService financeService, FinanceOrderService financeOrderService) {
|
||||
this.id = id;
|
||||
this.order_no = order_no;
|
||||
this.financeService = financeService;
|
||||
this.financeOrderService = financeOrderService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class JobDelayThread implements Runnable {
|
||||
private FinanceOrder1DayJob financeOrder1DayJob;
|
||||
private Date systemTime;
|
||||
|
||||
public void run() {
|
||||
this.financeOrder1DayJob.handleData(systemTime);
|
||||
}
|
||||
|
||||
public JobDelayThread(Date systemTime, FinanceOrder1DayJob financeOrder1DayJob) {
|
||||
this.systemTime = systemTime;
|
||||
this.financeOrder1DayJob = financeOrder1DayJob;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
157
comm/Finance/src/project/web/api/FinanceController.java
Executable file
157
comm/Finance/src/project/web/api/FinanceController.java
Executable file
@@ -0,0 +1,157 @@
|
||||
package project.web.api;
|
||||
|
||||
import java.text.ParseException;
|
||||
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.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.ResultObject;
|
||||
import project.Constants;
|
||||
import project.finance.Finance;
|
||||
import project.finance.FinanceService;
|
||||
|
||||
/**
|
||||
* 理财产品
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FinanceController {
|
||||
|
||||
private Logger logger = LogManager.getLogger(FinanceController.class);
|
||||
|
||||
@Autowired
|
||||
protected FinanceService financeService;
|
||||
|
||||
private final String action = "/api/finance!";
|
||||
|
||||
/**
|
||||
* 理财产品列表
|
||||
*/
|
||||
@RequestMapping(action + "list.action")
|
||||
public Object list() {
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
|
||||
try {
|
||||
|
||||
List<Finance> data = this.financeService.findAllState_1();
|
||||
resultObject.setData(bulidData(data));
|
||||
resultObject.setCode("0");
|
||||
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 理财产品详情
|
||||
*/
|
||||
@RequestMapping(action + "get.action")
|
||||
public Object get(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
|
||||
try {
|
||||
|
||||
Finance data = this.financeService.findById(id);
|
||||
if (!StringUtils.isNullOrEmpty(data.getImg())) {
|
||||
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + data.getImg();
|
||||
data.setImg(path);
|
||||
}
|
||||
|
||||
resultObject.setData(data);
|
||||
resultObject.setCode("0");
|
||||
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
protected List<Map<String, Object>> bulidData(List<Finance> finances) throws ParseException {
|
||||
|
||||
List<Map<String, Object>> result_finances = new ArrayList<Map<String, Object>>();
|
||||
|
||||
for (int i = 0; i < finances.size(); i++) {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
Finance finance = finances.get(i);
|
||||
|
||||
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + finance.getImg();
|
||||
map.put("img", path);
|
||||
map.put("id", finance.getId());
|
||||
|
||||
map.put("name", finance.getName());
|
||||
map.put("name_en", finance.getName_en());
|
||||
map.put("name_cn", finance.getName_cn());
|
||||
map.put("name_kn", finance.getName_kn());
|
||||
map.put("name_jn", finance.getName_jn());
|
||||
map.put("cycle", finance.getCycle());
|
||||
map.put("daily_rate", finance.getDaily_rate() + " ~ " + finance.getDaily_rate_max());
|
||||
map.put("daily_rate_max", finance.getDaily_rate_max());
|
||||
map.put("today_rate", finance.getToday_rate());
|
||||
map.put("default_ratio", finance.getDefault_ratio());
|
||||
map.put("investment_min", finance.getInvestment_min());
|
||||
map.put("investment_max", finance.getInvestment_max());
|
||||
map.put("state", finance.getState());
|
||||
|
||||
result_finances.add(map);
|
||||
}
|
||||
|
||||
return result_finances;
|
||||
}
|
||||
|
||||
private Map<String, Object> bulidData(Finance finance) throws ParseException {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + finance.getImg();
|
||||
map.put("img", path);
|
||||
map.put("id", finance.getId());
|
||||
|
||||
map.put("name", finance.getName());
|
||||
map.put("name_en", finance.getName_en());
|
||||
map.put("name_cn", finance.getName_cn());
|
||||
map.put("name_kn", finance.getName_kn());
|
||||
map.put("name_jn", finance.getName_jn());
|
||||
map.put("cycle", finance.getCycle());
|
||||
map.put("daily_rate", finance.getDaily_rate());
|
||||
map.put("daily_rate_max", finance.getDaily_rate_max());
|
||||
map.put("today_rate", finance.getToday_rate());
|
||||
map.put("default_ratio", finance.getDefault_ratio());
|
||||
map.put("investment_min", finance.getInvestment_min());
|
||||
map.put("investment_max", finance.getInvestment_max());
|
||||
map.put("state", finance.getState());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
553
comm/Finance/src/project/web/api/FinanceOrderController.java
Executable file
553
comm/Finance/src/project/web/api/FinanceOrderController.java
Executable file
@@ -0,0 +1,553 @@
|
||||
package project.web.api;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
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.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.Arith;
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.util.ThreadUtils;
|
||||
import kernel.web.BaseAction;
|
||||
import kernel.web.ResultObject;
|
||||
import project.Constants;
|
||||
import project.finance.Finance;
|
||||
import project.finance.FinanceOrder;
|
||||
import project.finance.FinanceOrderLock;
|
||||
import project.finance.FinanceOrderService;
|
||||
import project.finance.FinanceService;
|
||||
import project.party.PartyService;
|
||||
import project.party.model.Party;
|
||||
import util.DateUtil;
|
||||
import util.RandomUtil;
|
||||
|
||||
/**
|
||||
* 理财订单
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FinanceOrderController extends BaseAction {
|
||||
|
||||
private Logger logger = LogManager.getLogger(FinanceOrderController.class);
|
||||
|
||||
@Autowired
|
||||
protected FinanceOrderService financeOrderService;
|
||||
@Autowired
|
||||
protected FinanceService financeService;
|
||||
@Autowired
|
||||
protected PartyService partyService;
|
||||
@Autowired
|
||||
protected SessionTokenService sessionTokenService;
|
||||
|
||||
private final String action = "/api/financeOrder!";
|
||||
|
||||
/**
|
||||
* 托管订单
|
||||
*
|
||||
*/
|
||||
@RequestMapping(action + "list.action")
|
||||
public Object list(HttpServletRequest request) {
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
try {
|
||||
List<FinanceOrder> data = null;
|
||||
String partyId = getLoginPartyId();
|
||||
|
||||
if (StringUtils.isNullOrEmpty(partyId)) {
|
||||
resultObject.setData(data);
|
||||
resultObject.setCode("0");
|
||||
return resultObject;
|
||||
}
|
||||
String page_no = request.getParameter("page_no");
|
||||
int pageNo = 1;
|
||||
if (StringUtils.isNotEmpty(page_no)) {
|
||||
pageNo = Integer.valueOf(page_no);
|
||||
}
|
||||
// 状态。0.正常赎回, 1 托管中 ,2提前赎回 (违约)3.取消
|
||||
String state = request.getParameter("state");
|
||||
data = financeOrderService.pagedQuery(pageNo, 10, partyId, state).getElements();
|
||||
// 如果不为空 则从理财产品中获取日利率 图片
|
||||
if (data == null) {
|
||||
resultObject.setData(data);
|
||||
resultObject.setCode("0");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
List<FinanceOrder> data1 = new ArrayList<>();
|
||||
FinanceOrder order;
|
||||
List<Finance> finances = financeService.findAll();
|
||||
Finance finance = new Finance();
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
order = data.get(i);
|
||||
for (int j = 0; j < finances.size(); j++) {
|
||||
finance = finances.get(j);
|
||||
if (finance.getId().equals(order.getFinanceId())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 取时间
|
||||
Date date_now = new Date();
|
||||
int days = daysBetween(date_now, order.getStop_time());
|
||||
if (days < 0) {
|
||||
days = 0;
|
||||
}
|
||||
order.setFinanceName(finance.getName());
|
||||
order.setFinanceName_cn(finance.getName_cn());
|
||||
order.setFinanceName_en(finance.getName_en());
|
||||
order.setDays(days);
|
||||
order.setClose_timeStr(DateUtils.format(order.getClose_time(), DateUtils.DF_yyyyMMdd));
|
||||
order.setCreate_timeStr(DateUtils.format(order.getCreate_time(), DateUtils.DF_yyyyMMdd));
|
||||
order.setDaily_rate(finance.getDaily_rate() + " ~ " + finance.getDaily_rate_max());
|
||||
data1.add(order);
|
||||
}
|
||||
|
||||
resultObject.setData(data1);
|
||||
resultObject.setCode("0");
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 收益统计
|
||||
*
|
||||
*/
|
||||
@RequestMapping(action + "listSum.action")
|
||||
public Object listSum() {
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
|
||||
try {
|
||||
String partyId = getLoginPartyId();
|
||||
List<FinanceOrder> data = financeOrderService.findByState(partyId, "1");
|
||||
FinanceOrder order;
|
||||
List<Finance> finances = financeService.findAll();
|
||||
Finance finance = new Finance();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
// 金额总数
|
||||
double amount_sum = 0;
|
||||
// 预计今日盈利
|
||||
double today_profit = 0;
|
||||
// 已获收益
|
||||
double aready_profit = 0;
|
||||
// 订单数
|
||||
double order_sum = 0;
|
||||
|
||||
if (data != null) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
order = data.get(i);
|
||||
order_sum = Arith.add(order_sum, 1);
|
||||
amount_sum = Arith.add(amount_sum, order.getAmount());
|
||||
aready_profit = Arith.add(aready_profit, order.getProfit());
|
||||
for (int j = 0; j < finances.size(); j++) {
|
||||
finance = finances.get(j);
|
||||
if (finance.getId().equals(order.getFinanceId())) {
|
||||
double finance_profit = Arith.mul(finance.getDaily_rate(), 0.01);
|
||||
double get_profit = Arith.mul(finance_profit, order.getAmount());
|
||||
today_profit = Arith.add(today_profit, get_profit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("amount_sum", amount_sum);
|
||||
map.put("today_profit", today_profit);
|
||||
map.put("aready_profit", aready_profit);
|
||||
map.put("order_sum", order_sum);
|
||||
resultObject.setData(map);
|
||||
resultObject.setCode("0");
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 理财托管订单-详情
|
||||
*/
|
||||
@RequestMapping(action + "get.action")
|
||||
public Object get(HttpServletRequest request) {
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
try {
|
||||
String order_no = request.getParameter("order_no");
|
||||
FinanceOrder data = financeOrderService.findByOrder_no(order_no);
|
||||
|
||||
// 如果不为空 则从理财产品中获取日利率 图片
|
||||
resultObject.setData(bulidData(data));
|
||||
resultObject.setCode("0");
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建买入理财产品订单
|
||||
*
|
||||
*/
|
||||
@RequestMapping(action + "open.action")
|
||||
public Object open(HttpServletRequest request) {
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
String partyId = this.getLoginPartyId();
|
||||
try {
|
||||
String session_token = request.getParameter("session_token");
|
||||
String financeId = request.getParameter("financeId");
|
||||
String amount = request.getParameter("amount");
|
||||
|
||||
Object object = this.sessionTokenService.cacheGet(session_token);
|
||||
this.sessionTokenService.delete(session_token);
|
||||
if ((object == null) || (!this.getLoginPartyId().equals((String) object))) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("请稍后再试");
|
||||
return resultObject;
|
||||
}
|
||||
Party party = this.partyService.cachePartyBy(partyId, false);
|
||||
if (!party.getEnabled()) {
|
||||
resultObject.setCode("506");
|
||||
resultObject.setMsg(error);
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
FinanceOrder order = new FinanceOrder();
|
||||
order.setPartyId(partyId);
|
||||
order.setFinanceId(financeId);
|
||||
order.setAmount(Double.valueOf(amount));
|
||||
order.setOrder_no(DateUtil.getToday("yyMMddHHmmss") + RandomUtil.getRandomNum(8));
|
||||
order.setState("1");
|
||||
|
||||
this.financeOrderService.saveCreate(order);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("order_no", order.getOrder_no());
|
||||
resultObject.setData(map);
|
||||
resultObject.setCode("0");
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单
|
||||
*
|
||||
*/
|
||||
@RequestMapping(action + "getOpen.action")
|
||||
public Object getOpen(HttpServletRequest request) {
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
try {
|
||||
|
||||
String financeId = request.getParameter("financeId");
|
||||
String amount_temp = request.getParameter("amount");
|
||||
|
||||
Finance finance = financeService.findById(financeId);
|
||||
|
||||
if (StringUtils.isNullOrEmpty(amount_temp)
|
||||
|| !StringUtils.isDouble(amount_temp)
|
||||
|| Double.valueOf(amount_temp) < 0) {
|
||||
throw new BusinessException("金额错误");
|
||||
}
|
||||
|
||||
Double amount = Double.valueOf(amount_temp);
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (finance != null) {
|
||||
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + finance.getImg();
|
||||
map.put("img", path);
|
||||
}
|
||||
|
||||
map.put("finance_name", finance.getName());
|
||||
map.put("finance_name_en", finance.getName_en());
|
||||
map.put("finance_name_cn", finance.getName_cn());
|
||||
map.put("finance_name_kn", finance.getName_kn());
|
||||
map.put("finance_name_jn", finance.getName_jn());
|
||||
map.put("cycle", finance.getCycle());
|
||||
String partyId = getLoginPartyId();
|
||||
if (!StringUtils.isNullOrEmpty(partyId)) {
|
||||
String session_token = sessionTokenService.savePut(partyId);
|
||||
map.put("session_token", session_token);
|
||||
}
|
||||
|
||||
map.put("amount", amount);
|
||||
// 取时间
|
||||
Date date = new Date();
|
||||
|
||||
map.put("create_time", DateUtils.format(date, DateUtils.DF_yyyyMMddHHmmss));
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(date);
|
||||
calendar.add(calendar.DATE, 1);// 把日期往后增加一天.整数往后推
|
||||
date = calendar.getTime(); //
|
||||
|
||||
// 起息时间
|
||||
map.put("earn_time", DateUtils.format(date, DateUtils.DF_yyyyMMdd));
|
||||
calendar.add(calendar.DATE, finance.getCycle());// 把日期往后增加周期.整数往后推
|
||||
date = calendar.getTime();
|
||||
|
||||
// 截止时间
|
||||
map.put("stop_time", DateUtils.format(date, DateUtils.DF_yyyyMMdd));
|
||||
|
||||
// 区间
|
||||
map.put("investment_min", finance.getInvestment_min());
|
||||
map.put("investment_max", finance.getInvestment_max());
|
||||
DecimalFormat df = new DecimalFormat("#.##");
|
||||
map.put("daily_rate", df.format(finance.getDaily_rate()) + "~" + df.format(finance.getDaily_rate_max()));
|
||||
map.put("daily_rate_max", finance.getDaily_rate_max());
|
||||
map.put("financeId", financeId);
|
||||
double rate = Arith.mul(finance.getDaily_rate(), 0.01);
|
||||
double rateMax = Arith.mul(finance.getDaily_rate_max(), 0.01);
|
||||
map.put("profit_may", Arith.mul(amount, Arith.mul(rate, finance.getCycle())) + "~"
|
||||
+ Arith.mul(amount, Arith.mul(rateMax, finance.getCycle())));
|
||||
map.put("order_no", DateUtil.getToday("yyMMddHHmmss") + RandomUtil.getRandomNum(8));
|
||||
|
||||
resultObject.setData(map);
|
||||
resultObject.setCode("0");
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 赎回理财产品订单
|
||||
*
|
||||
*/
|
||||
@RequestMapping(action + "closOrder.action")
|
||||
public Object closOrder(HttpServletRequest request) {
|
||||
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
try {
|
||||
String id = request.getParameter("id");
|
||||
FinanceOrder order = financeOrderService.findById(id);
|
||||
CloseDelayThread lockDelayThread = new CloseDelayThread(id, order.getOrder_no(), financeOrderService);
|
||||
Thread t = new Thread(lockDelayThread);
|
||||
t.start();
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", t);
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新线程处理,直接拿到订单锁处理完成后退出
|
||||
*
|
||||
*/
|
||||
public class CloseDelayThread implements Runnable {
|
||||
private String id;
|
||||
private String order_no;
|
||||
private FinanceOrderService financeOrderService;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
while (true) {
|
||||
if (FinanceOrderLock.add(order_no)) {
|
||||
/**
|
||||
* 提前赎回理财产品需要支付违约金
|
||||
*/
|
||||
FinanceOrder order = financeOrderService.findById(id);
|
||||
Finance finance = financeService.findById(order.getFinanceId());
|
||||
// order.setDays(daysBetween(order.getEarn_time(), order.getStop_time()));
|
||||
if ("1".equals(order.getState())) {
|
||||
/**
|
||||
* 扣除违约金
|
||||
*/
|
||||
Date date_now = new Date();// 取时间
|
||||
double last_days = daysBetween(date_now, order.getStop_time());
|
||||
if (last_days <= 0) {
|
||||
last_days = 1;
|
||||
}
|
||||
double default_ratio = Arith.mul(finance.getDefault_ratio(), 0.01);
|
||||
default_ratio = Arith.mul(default_ratio, last_days);
|
||||
double breach_amount = Arith.mul(order.getAmount(), default_ratio);
|
||||
order.setProfit(Arith.sub(0, breach_amount));
|
||||
order.setState("2");
|
||||
|
||||
this.financeOrderService.saveClose(order);
|
||||
|
||||
}
|
||||
/**
|
||||
* 处理完退出
|
||||
*/
|
||||
break;
|
||||
}
|
||||
ThreadUtils.sleep(500);
|
||||
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
logger.error("error:", t);
|
||||
} finally {
|
||||
FinanceOrderLock.remove(order_no);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CloseDelayThread(String id, String order_no, FinanceOrderService financeOrderService) {
|
||||
this.id = id;
|
||||
this.order_no = order_no;
|
||||
this.financeOrderService = financeOrderService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Map<String, Object> bulidData(FinanceOrder order) throws ParseException {
|
||||
Finance finance = new Finance();
|
||||
finance = financeService.findById(order.getFinanceId());
|
||||
|
||||
DecimalFormat df = new DecimalFormat("#.##");
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("img", Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + finance.getImg());
|
||||
map.put("daily_rate", df.format(finance.getDaily_rate()) + "~" + df.format(finance.getDaily_rate_max()));
|
||||
map.put("daily_rate_max", finance.getDaily_rate_max());
|
||||
map.put("create_timeStr", DateUtils.format(order.getCreate_time(), DateUtils.DF_yyyyMMddHHmmss));
|
||||
map.put("close_timeStr", DateUtils.format(order.getClose_time(), DateUtils.DF_yyyyMMddHHmmss));
|
||||
/**
|
||||
* 此处将截止时间传回
|
||||
*/
|
||||
map.put("stop_timeStr", DateUtils.format(order.getClose_time(), DateUtils.DF_yyyyMMdd));
|
||||
map.put("earn_timeStr", DateUtils.format(order.getEarn_time(), DateUtils.DF_yyyyMMdd));
|
||||
Date date_now = new Date();// 取时间
|
||||
int days = daysBetween(date_now, order.getStop_time());
|
||||
if (days < 0) {
|
||||
days = 0;
|
||||
}
|
||||
map.put("days", days);
|
||||
double rate = Arith.mul(finance.getDaily_rate(), 0.01);
|
||||
double rateMax = Arith.mul(finance.getDaily_rate_max(), 0.01);
|
||||
map.put("profit_may", Arith.mul(order.getAmount(), Arith.mul(rate, finance.getCycle())) + "~"
|
||||
+ Arith.mul(order.getAmount(), Arith.mul(rateMax, finance.getCycle())));
|
||||
map.put("order_no", order.getOrder_no());
|
||||
map.put("amount", order.getAmount());
|
||||
map.put("cycle", order.getCycle());
|
||||
map.put("id", order.getId());
|
||||
map.put("name", finance.getName());
|
||||
map.put("name_en", finance.getName_en());
|
||||
map.put("name_cn", finance.getName_cn());
|
||||
map.put("name_kn", finance.getName_kn());
|
||||
map.put("name_jn", finance.getName_jn());
|
||||
|
||||
map.put("state", order.getState());
|
||||
if ("1".equals(order.getState())) {
|
||||
|
||||
map.put("profit", order.getProfit());
|
||||
|
||||
double rate_order = Arith.mul(finance.getDefault_ratio(), 0.01);
|
||||
double last_days = daysBetween(date_now, order.getStop_time());
|
||||
if (last_days <= 0) {
|
||||
last_days = 1;
|
||||
}
|
||||
double default_amount = 0;
|
||||
default_amount = Arith.mul(order.getAmount(), Arith.mul(rate_order, last_days));
|
||||
map.put("default_amount", default_amount);
|
||||
double principal_amount = Arith.sub(order.getAmount(), default_amount);
|
||||
if (principal_amount < 0) {
|
||||
principal_amount = 0;
|
||||
}
|
||||
map.put("principal_amount", principal_amount);
|
||||
|
||||
}
|
||||
if ("2".equals(order.getState())) {
|
||||
map.put("profit", 0);
|
||||
map.put("default_amount", df.format(Arith.sub(0, order.getProfit())));
|
||||
map.put("principal_amount", df.format(Arith.add(order.getAmount(), order.getProfit())));
|
||||
}
|
||||
if ("0".equals(order.getState())) {
|
||||
map.put("profit", order.getProfit());
|
||||
map.put("default_amount", 0);
|
||||
map.put("principal_amount", df.format(Arith.add(order.getAmount(), order.getProfit())));
|
||||
}
|
||||
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
public static int daysBetween(Date smdate, Date bdate) throws ParseException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
smdate = sdf.parse(sdf.format(smdate));
|
||||
bdate = sdf.parse(sdf.format(bdate));
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(smdate);
|
||||
long time1 = cal.getTimeInMillis();
|
||||
cal.setTime(bdate);
|
||||
long time2 = cal.getTimeInMillis();
|
||||
long between_days = (time2 - time1) / (1000 * 3600 * 24);
|
||||
|
||||
return Integer.parseInt(String.valueOf(between_days));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user