first commit

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

View File

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

View File

@@ -0,0 +1,163 @@
<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="include/pagetop.jsp"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="include/head.jsp"%>
</head>
<body>
<%@ include file="include/loading.jsp"%>
<%@ include file="include/top.jsp"%>
<%@ include file="include/menu_left.jsp"%>
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- START CONTENT -->
<div class="content">
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- START CONTAINER -->
<div class="container-default">
<h3>用户高级认证管理</h3>
<%@ include file="include/alert.jsp"%>
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- START queryForm -->
<s:if test='isResourceAccessible("ADMIN_KYC_HIGH_LEVEL_LIST")'>
<form action="<%=basePath%>normal/adminContractManageAction!list.action"
method="post" id="queryForm">
<s:hidden name="pageNo" id="pageNo"></s:hidden>
</form>
</s:if>
<!-- END queryForm -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="panel panel-default">
<div class="panel-title">
用户高级认证详情
<ul class="panel-tools">
<li><a class="icon minimise-tool"><i
class="fa fa-minus"></i></a></li>
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
</ul>
</div>
<div class="panel-body form-horizontal">
<s:if test='isResourceAccessible("ADMIN_KYC_HIGH_LEVEL_DETAIL")'>
<div class="form-group">
<label class="col-sm-2 control-label form-label">用户</label>
<div class="col-sm-10">
<s:textfield id="username" name="kycHighLevel.username" cssClass="form-control " readOnly="true" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">工作地址</label>
<div class="col-sm-10">
<s:textfield id="work_place" name="kycHighLevel.work_place" cssClass="form-control " readOnly="true" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">家庭地址</label>
<div class="col-sm-10">
<s:textfield id="home_place" name="kycHighLevel.home_place" cssClass="form-control " readOnly="true" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">亲属关系</label>
<div class="col-sm-10">
<s:textfield id="relatives_relation" name="kycHighLevel.relatives_relation" cssClass="form-control " readOnly="true" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">亲属名称</label>
<div class="col-sm-10">
<s:textfield id="relatives_name" name="kycHighLevel.relatives_name" cssClass="form-control " readOnly="true" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">亲属地址</label>
<div class="col-sm-10">
<s:textfield id="relatives_place" name="kycHighLevel.relatives_place" cssClass="form-control " readOnly="true" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">亲属电话</label>
<div class="col-sm-10">
<s:textfield id="relatives_phone" name="kycHighLevel.relatives_phone" cssClass="form-control " readOnly="true" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">认证状态</label>
<div class="col-sm-10">
<label>
<s:if test="kycHighLevel.status==0">未审核</s:if>
<s:if test="kycHighLevel.status==1">审核中</s:if>
<s:if test="kycHighLevel.status==2"><span class="right label label-success">审核通过</span></s:if>
<s:if test="kycHighLevel.status==3">未通过</s:if>
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label form-label">原因</label>
<div class="col-sm-10">
<s:textfield id="msg" name="kycHighLevel.msg" cssClass="form-control " readOnly="true" />
</div>
</div>
</s:if>
</div>
</div>
</div>
</div>
</div>
<!-- END CONTAINER -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<%@ include file="include/footer.jsp"%>
</div>
<!-- End Content -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<%@ include file="include/js.jsp"%>
<script type="text/javascript">
/* $(function(){
var id = $('#futures_id').val();
if(typeof(id)!='undefined'&&id.length>0){
$("#symbol").attr("disabled", "disabled");
}
})
function submit() {
$("#symbol").removeAttr("disabled");
swal({
title : "是否保存?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
document.getElementById("mainForm").submit();
});
} */
</script>
</body>
</html>

View File

@@ -0,0 +1,396 @@
<%@ 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_KYC_HIGH_LEVEL_LIST")'>
<form class="form-horizontal"
action="<%=basePath%>normal/adminKycHighLevelAction!list.action"
method="post" id="queryForm">
<input type="hidden" name="pageNo" id="pageNo"
value="${param.pageNo}">
<s:hidden name="state_para"></s:hidden>
<div class="col-md-12 col-lg-4">
<fieldset>
<div class="control-group">
<div class="controls">
<s:textfield id="name_para" name="name_para"
cssClass="form-control " placeholder="用户名、UID" />
</div>
</div>
</fieldset>
</div>
<div class="col-md-12 col-lg-3">
<fieldset>
<div class="control-group">
<div class="controls">
<s:select id="rolename_para" cssClass="form-control "
name="rolename_para"
list="#{'MEMBER':'正式账号','GUEST':'演示账号'}" listKey="key"
listValue="value" headerKey="" headerValue="所有账号"
value="rolename_para" />
</div>
</div>
</fieldset>
</div>
<!-- <div class="col-md-12 col-lg-2" >
<button type="submit" class="btn btn-default btn-block">查询</button>
</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(1)"> 待审核</a></li>
<li><a href="javascript:setState(2)"> 审核通过</a></li>
<li><a href="javascript:setState(3)"> 未通过</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" var="obj">
<tr>
<td>
<a href="#" onClick="detail('<s:property value="username" />',
'<s:property value="work_place" />',
'<s:property value="home_place" />',
'<s:property value="relatives_place" />',
'<s:property value="msg" />',
'<s:property value="relatives_name" />',
'<s:property value="relatives_relation" />',
'<s:property value="relatives_phone" />')">
<s:property value="username" />
</a>
</td>
<td><s:property value="usercode" /></td>
<%-- <s:if test='isResourceAccessible("ADMIN_KYC_HIGH_LEVEL_DETAIL")'>
<td><a href="<%=basePath%>normal/adminKycHighLevelAction!detail.action?id=<s:property value="id" />" target="_blank"><s:property value="username" /></a></td>
<td><a href="#" onClick="detail('<s:property value="username" />','<s:property value="work_place" />','<s:property value="home_place" />','<s:property value="relatives_place" />','<s:property value="msg" />')"><s:property value="username" /></a></td>
</s:if>
<s:else>
<td><a href="#" onClick="detail(<s:property value="obj"/>)"><s:property value="username" /></a></td>
</s:else> --%>
<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="work_place" /></td> --%>
<%-- <td><s:property value="home_place" /></td> --%>
<td><s:property value="relatives_name" /></td>
<td><s:property value="relatives_relation" /></td>
<%-- <td><s:property value="relatives_place" /></td> --%>
<td><s:property value="relatives_phone" /></td>
<td><s:if test="status==0">未审核</s:if>
<s:if test="status==1">审核中</s:if>
<s:if test="status==2"><span class="right label label-success">审核通过</span></s:if>
<s:if test="status==3">未通过</s:if></td>
<%-- <td><s:property value="msg" /></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">
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<s:if test='isResourceAccessible("ADMIN_KYC_HIGH_LEVEL_SAVEPASSED")'>
<li><a href="javascript:savePassed('<s:property value="partyId" />')">审核通过</a></li>
</s:if>
<s:if test='isResourceAccessible("ADMIN_KYC_HIGH_LEVEL_SAVEFAILED")'>
<li><a href="javascript:saveFailed('<s:property value="partyId" />')">驳回</a></li>
</s:if>
</sec:authorize>
</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"%>
<!-- 模态框Modal -->
<div class="modal fade" id="modal_detail" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content" style="width:725px;">
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" >详细信息</h4>
</div>
<div class="modal-body">
<!-- <div class="" >
用户<input id="modal_username" type="text" name="modal_username"
class="form-control" readonly="true" />
</div> -->
<div class="" >
工作地址<input id="modal_work_place" type="text" name="modal_work_place"
class="form-control" readonly="true"/>
</div>
<div class="" >
家庭地址<input id="modal_home_place" type="text" name="modal_home_place"
class="form-control" readonly="true"/>
</div>
<div class="" >
原因<input id="modal_msg" type="text" name="modal_msg"
class="form-control" readonly="true"/>
</div>
</div>
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">亲属信息</h4>
</div>
<div class="modal-body">
<div class="" >
亲属关系<input id="modal_relatives_relation" type="text" name="modal_relatives_relation"
class="form-control" readonly="true"/>
</div>
<div class="" >
亲属姓名<input id="modal_relatives_name" type="text" name="modal_relatives_name"
class="form-control" readonly="true"/>
</div>
<div class="" >
亲属电话<input id="modal_relatives_phone" type="text" name="modal_relatives_phone"
class="form-control" readonly="true"/>
</div>
<div class="" >
亲属地址<input id="modal_relatives_place" type="text" name="modal_relatives_place"
class="form-control" readonly="true"/>
</div>
</div>
<div class="modal-footer" style="margin-top: 0;">
<button type="button" class="btn "
data-dismiss="modal">关闭</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<s:if test='isResourceAccessible("ADMIN_KYC_HIGH_LEVEL_SAVEPASSED")'>
<form action="<%=basePath%>normal/adminKycHighLevelAction!savePassed.action" method="post" id="savePassed">
<input type="hidden" name="pageNo" id="pageNo" value="${param.pageNo}">
<s:hidden name="name_para" id="name_para"></s:hidden>
<s:hidden name="state_para" id="state_para"></s:hidden>
<s:hidden name="partyId" id="partyId_savePassed"></s:hidden>
</form>
<script type="text/javascript">
function savePassed(partyId) {
$("#partyId_savePassed").val(partyId);
swal({
title : "是否确认审核通过?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
document.getElementById("savePassed").submit();
});
}
</script>
</s:if>
<s:if test='isResourceAccessible("ADMIN_KYC_HIGH_LEVEL_SAVEFAILED")'>
<script type="text/javascript">
function saveFailed_confirm() {
swal({
title : "是否确认驳回?",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
document.getElementById("saveFailed").submit();
});
};
function saveFailed(partyId) {
$("#partyId_saveFailed").val(partyId);
$('#modal_saveFailed').modal("show");
};
</script>
<!-- Modal -->
<div class="modal fade" id="modal_saveFailed" tabindex="-1" role="dialog"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">请输入驳回原因</h4>
</div>
<div class="modal-body">
<form action="<%=basePath%>normal/adminKycHighLevelAction!saveFailed.action" method="post" id="saveFailed">
<s:hidden name="session_token" id="session_token_reject"></s:hidden>
<input type="hidden" name="pageNo" id="pageNo" value="${param.pageNo}">
<s:hidden name="name_para" id="name_para"></s:hidden>
<s:hidden name="state_para" id="state_para"></s:hidden>
<s:hidden name="partyId" id="partyId_saveFailed"></s:hidden>
<s:textarea name="msg" id="msg" cssClass="form-control input-lg" rows="2" cols="10" placeholder="驳回原因"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-default" onclick="saveFailed_confirm()">确认驳回</button>
</div>
</div>
</div>
</div>
</s:if>
</sec:authorize>
<script type="text/javascript">
function setState(state){
document.getElementById("state_para").value=state;
document.getElementById("queryForm").submit();
}
function detail(username,work_place,home_place,relatives_place,msg,relatives_name,relatives_relation,relatives_phone){
// $("#modal_username").val(username);
$("#modal_work_place").val(work_place);
$("#modal_home_place").val(home_place);
$("#modal_relatives_place").val(relatives_place);
$("#modal_relatives_name").val(relatives_name);
$("#modal_relatives_relation").val(relatives_relation);
$("#modal_relatives_phone").val(relatives_phone);
$("#modal_msg").val(msg);
$('#modal_detail').modal("show");
}
</script>
</body>
</html>

396
comm/User/WebContent/kyc_list.jsp Executable file
View File

@@ -0,0 +1,396 @@
<%@ 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_KYC_LIST")'>
<form class="form-horizontal"
action="<%=basePath%>normal/adminKycAction!list.action"
method="post" id="queryForm">
<input type="hidden" name="pageNo" id="pageNo"
value="${param.pageNo}">
<s:hidden name="state_para"></s:hidden>
<div class="col-md-12 col-lg-4">
<fieldset>
<div class="control-group">
<div class="controls">
<s:textfield id="name_para" name="name_para"
cssClass="form-control " placeholder="用户名、UID" />
</div>
</div>
</fieldset>
</div>
<div class="col-md-12 col-lg-3">
<fieldset>
<div class="control-group">
<div class="controls">
<s:select id="rolename_para" cssClass="form-control "
name="rolename_para"
list="#{'MEMBER':'正式账号','GUEST':'演示账号'}" listKey="key"
listValue="value" headerKey="" headerValue="所有账号"
value="rolename_para" />
</div>
</div>
</fieldset>
</div>
<!-- <div class="col-md-12 col-lg-2" >
<button type="submit" class="btn btn-default btn-block">查询</button>
</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(1)"> 待审核</a></li>
<li><a href="javascript:setState(2)"> 审核通过</a></li>
<li><a href="javascript:setState(3)"> 未通过</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>ID名称</td> -->
<!-- <td>证件号码</td> -->
<td>实名姓名</td>
<!-- <td>国籍</td> -->
<!-- <td>证件正面照</td> -->
<!-- <td>证件背面照</td> -->
<!-- <td>手持正面照</td> -->
<td>手机绑定</td>
<td>邮箱绑定</td>
<td>认证状态</td>
<td>原因</td>
<td width="130px"></td>
</tr>
</thead>
<tbody>
<s:iterator value="page.elements" status="stat">
<tr>
<td><a href="#" onClick="detail('<s:property value="name" />','<s:property value="idnumber" />','<s:property value="nationality" />','<s:property value="idimg_1" />','<s:property value="idimg_2" />','<s:property value="idimg_3" />','<s:property value="idname" />')"><s:property value="username" /></a></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="idname" /></td> --%>
<%-- <td><s:property value="idnumber" /></td> --%>
<td><s:property value="name" /></td>
<%-- <td><s:property value="nationality" /></td> --%>
<%-- <td><a href="${basePath}/public/showimg!showImg.action?imagePath=<s:property value="idimg_1" />" target="_blank">查看照片</a></td> --%>
<%-- <td><a href="${basePath}/public/showimg!showImg.action?imagePath=<s:property value="idimg_2" />" target="_blank">查看照片</a></td> --%>
<%-- <td><a href="<s:property value="idimg_1" />" target="_blank">查看照片</a></td> --%>
<%-- <td><a href="<s:property value="idimg_2" />" target="_blank">查看照片</a></td> --%>
<%-- <td><a href="<s:property value="idimg_3" />" target="_blank">查看照片</a></td> --%>
<td><s:property value="phone" /></td>
<td><s:property value="email" /></td>
<td><s:if test="status==0">未审核</s:if>
<s:if test="status==1">审核中</s:if>
<s:if test="status==2"><span class="right label label-success">审核通过</span></s:if>
<s:if test="status==3">未通过</s:if></td>
<td><s:property value="msg" /></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">
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<s:if test='isResourceAccessible("ADMIN_KYC_SAVEPASSED")'>
<li><a href="javascript:savePassed('<s:property value="partyId" />')">审核通过</a></li>
</s:if>
<s:if test='isResourceAccessible("ADMIN_KYC_SAVEFAILED")'>
<li><a href="javascript:saveFailed('<s:property value="partyId" />')">驳回</a></li>
</s:if>
</sec:authorize>
</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 -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- 模态框Modal -->
<div class="modal fade" id="modal_detail" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content" style="width:725px;">
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" >详细信息</h4>
</div>
<div class="modal-body">
<div class="" >
实名姓名<input id="modal_name" type="text" name="modal_name"
class="form-control" readonly="true" />
</div>
<div class="" >
证件名称<input id="modal_idname" type="text" name="modal_idname"
class="form-control" readonly="true"/>
</div>
<div class="" >
证件号码<input id="modal_idnumber" type="text" name="modal_idnumber"
class="form-control" readonly="true"/>
</div>
<div class="" >
国籍<input id="modal_nationality" type="text" name="modal_nationality"
class="form-control" readonly="true"/>
</div>
</div>
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">证件照</h4>
</div>
<div class="modal-body col-md-12">
<div class="col-md-12 col-lg-4" >证件正面照
<a href="#" target="_blank">
<img width="200px" height="200px"
id="modal_idimg_1" name="modal_idimg_1" src=""
/>
</a>
</div>
<div class="col-md-12 col-lg-4" >证件背面照
<a href="#" target="_blank">
<img width="200px" height="200px"
id="modal_idimg_2" name="modal_idimg_2" src=""
/>
</a>
</div>
<div class="col-md-12 col-lg-4" >手持正面照
<a href="#" target="_blank">
<img width="200px" height="200px"
id="modal_idimg_3" name="modal_idimg_3" src=""
/>
</a>
</div>
</div>
<div class="modal-footer" style="margin-top: 0;">
<button type="button" class="btn "
data-dismiss="modal">关闭</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<%@ include file="include/js.jsp"%>
<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN">
<s:if test='isResourceAccessible("ADMIN_KYC_SAVEPASSED")'>
<form action="<%=basePath%>normal/adminKycAction!savePassed.action" method="post" id="savePassed">
<input type="hidden" name="pageNo" id="pageNo" value="${param.pageNo}">
<s:hidden name="name_para" id="name_para"></s:hidden>
<s:hidden name="state_para" id="state_para"></s:hidden>
<s:hidden name="partyId" id="partyId_savePassed"></s:hidden>
</form>
<script type="text/javascript">
function savePassed(partyId) {
$("#partyId_savePassed").val(partyId);
swal({
title : "是否确认审核通过?",
text : "",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
document.getElementById("savePassed").submit();
});
}
</script>
</s:if>
<s:if test='isResourceAccessible("ADMIN_KYC_SAVEFAILED")'>
<script type="text/javascript">
function saveFailed_confirm() {
swal({
title : "是否确认驳回?",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "确认",
closeOnConfirm : false
}, function() {
document.getElementById("saveFailed").submit();
});
};
function saveFailed(partyId) {
$("#partyId_saveFailed").val(partyId);
$('#modal_saveFailed').modal("show");
};
</script>
</s:if>
<!-- Modal -->
<s:if test='isResourceAccessible("ADMIN_KYC_SAVEFAILED")'>
<div class="modal fade" id="modal_saveFailed" tabindex="-1" role="dialog"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">请输入驳回原因</h4>
</div>
<div class="modal-body">
<form action="<%=basePath%>normal/adminKycAction!saveFailed.action" method="post" id="saveFailed">
<s:hidden name="session_token" id="session_token_reject"></s:hidden>
<input type="hidden" name="pageNo" id="pageNo" value="${param.pageNo}">
<s:hidden name="name_para" id="name_para"></s:hidden>
<s:hidden name="state_para" id="state_para"></s:hidden>
<s:hidden name="partyId" id="partyId_saveFailed"></s:hidden>
<s:textarea name="msg" id="msg" cssClass="form-control input-lg" rows="2" cols="10" placeholder="驳回原因"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-default" onclick="saveFailed_confirm()">确认驳回</button>
</div>
</div>
</div>
</div>
</s:if>
</sec:authorize>
<script type="text/javascript">
function setState(state){
document.getElementById("state_para").value=state;
document.getElementById("queryForm").submit();
}
function detail(name,idnumber,nationality,idimg_1,idimg_2,idimg_3,idname){
// $("#id_success").val(id);
$("#modal_name").val(name);
$("#modal_idname").val(idname);
$("#modal_idnumber").val(idnumber);
$("#modal_nationality").val(nationality);
$("#modal_idimg_1").attr("src",idimg_1);
$("#modal_idimg_1").parent().attr("href",idimg_1);
$("#modal_idimg_2").attr("src",idimg_2);
$("#modal_idimg_2").parent().attr("href",idimg_2);
$("#modal_idimg_3").attr("src",idimg_3);
$("#modal_idimg_3").parent().attr("href",idimg_3);
$('#modal_detail').modal("show");
}
</script>
</body>
</html>

View File

@@ -0,0 +1,35 @@
<?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.user.payment.PaymentMethod" table="T_PAYMENT_METHOD">
<id name="id" type="java.lang.String">
<column name="UUID" />
<generator class="uuid.hex" />
</id>
<property name="partyId" type="java.lang.String">
<column name="PARTY_ID" />
</property>
<property name="method" type="java.lang.String">
<column name="METHOD" />
</property>
<property name="account" type="java.lang.String">
<column name="ACCOUNT" />
</property>
<property name="qdcode" type="java.lang.String">
<column name="QDCODE" />
</property>
<property name="bank" type="java.lang.String">
<column name="BANK" />
</property>
<property name="deposit_bank" type="java.lang.String">
<column name="DEPOSIT_BANK" />
</property>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,16 @@
admin
<value>adminKycService</value>
<value>userService</value>
<value>adminKycHighLevelService</value>
<value>adminSystemUserService</value>
<!-- user -->
api
<!-- user -->
<value>paymentMethodService</value>
<value>kycService</value>
<value>tokenService</value>
<value>kycHighLevelService</value>
<value>userService</value>

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
<bean id="paymentMethodService"
class="project.user.payment.internal.PaymentMethodServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="kycService"
class="project.user.kyc.internal.KycServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="kycHighLevelService"
class="project.user.kyc.internal.KycHighLevelServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<dubbo:reference id="identifyingCodeService"
interface="project.user.idcode.IdentifyingCodeService" check="false" />
<dubbo:reference id="identifyingCodeTimeWindow"
interface="project.user.idcode.IdentifyingCodeTimeWindow" check="false" />
<bean id="userService"
class="project.user.internal.UserServiceImpl">
<property name="partyService" ref="partyService" />
<property name="passwordEncoder" ref="passwordEncoder" />
<property name="identifyingCodeTimeWindow"
ref="identifyingCodeTimeWindow" />
<property name="secUserService" ref="secUserService" />
<property name="onlineUserService"
ref="onlineUserService" />
</bean>
<bean id="onlineUserService"
class="project.user.internal.OnlineUserService">
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="tokenService"
class="project.user.token.internal.TokenServiceImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
</beans>

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
<dubbo:reference id="identifyingCodeTimeWindow"
interface="project.user.idcode.IdentifyingCodeTimeWindow" check="false" />
<dubbo:reference id="identifyingCodeTimeWindow"
interface="project.user.idcode.IdentifyingCodeTimeWindow" check="false" />
<bean id="userService"
class="project.user.internal.UserServiceImpl">
<property name="partyService" ref="partyService" />
<property name="passwordEncoder" ref="passwordEncoder" />
<property name="identifyingCodeTimeWindow"
ref="identifyingCodeTimeWindow" />
<property name="secUserService" ref="secUserService" />
<property name="onlineUserTimeWindow"
ref="onlineUserTimeWindow" />
</bean>
<bean id="onlineUserTimeWindow"
class="project.user.internal.OnlineUserTimeWindow">
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="adminKycService"
class=" project.user.kyc.internal.AdminKycServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="partyService" ref="partyService" />
<property name="userRecomService" ref="userRecomService" />
</bean>
<bean id="adminKycHighLevelService"
class=" project.user.kyc.internal.AdminKycHighLevelServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="partyService" ref="partyService" />
<property name="userRecomService" ref="userRecomService" />
</bean>
<bean id="adminSystemUserService"
class="project.admin.interal.AdminSystemUserServiceImpl">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="pagedQueryDao" ref="pagedDao" />
<property name="secUserService" ref="secUserService" />
<!-- <property name="userRecomService" ref="userRecomService" /> -->
</bean>
</beans>

View File

@@ -0,0 +1,55 @@
<?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="userLoadCacheService"
class="project.data.loadcache.UserLoadCacheService">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="redisHandler" ref="redisHandler" />
</bean>
<bean id="identifyingCodeService"
class="project.user.idcode.internal.IdentifyingCodeServiceImpl">
<property name="smsSendService" ref="smsSendService" />
<property name="emailSendService" ref="emailSendService" />
<property name="sysparaService" ref="sysparaService" />
<property name="identifyingCodeTimeWindow"
ref="identifyingCodeTimeWindow" />
<property name="blacklistIpTimeWindow"
ref="blacklistIpTimeWindow" />
<property name="sendCountTimeWindow"
ref="sendCountTimeWindow" />
</bean>
<dubbo:service
interface="project.user.idcode.IdentifyingCodeService"
ref="identifyingCodeService" />
<bean id="identifyingCodeTimeWindow"
class="project.user.idcode.IdentifyingCodeTimeWindow">
</bean>
<bean id="blacklistIpTimeWindow"
class="project.user.idcode.BlacklistIpTimeWindow">
</bean>
<bean id="sendCountTimeWindow"
class="project.user.idcode.SendCountTimeWindow">
</bean>
<dubbo:service
interface="project.user.idcode.IdentifyingCodeTimeWindow"
ref="identifyingCodeTimeWindow" />
<bean id="onlineUserTimeoutTask"
class="project.user.internal.OnlineUserTimeoutTask">
<property name="redisHandler" ref="redisHandler" />
</bean>
</beans>

View File

@@ -0,0 +1,26 @@
admin
<action name="adminKycAction"
class="project.user.kyc.web.AdminKycAction">
<result name="list">/kyc_list.jsp</result>
</action>
<action name="adminKycHighLevelAction"
class="project.user.kyc.web.AdminKycHighLevelAction">
<result name="list">/kyc_highlevel_list.jsp</result>
<result name="detail">/kyc_highlevel_detail.jsp</result>
</action>
api
<action name="paymentmethod"
class="project.user.payment.web.PaymentMethodAction">
</action>
<action name="kyc" class="project.user.kyc.web.KycAction">
</action>
<action name="user" class="project.user.web.UserAction">
</action>
<action name="kychighlevel" class="project.user.kyc.web.KycHighLevelAction">
</action>

View File

@@ -0,0 +1,49 @@
DROP TABLE IF EXISTS `T_PAYMENT_METHOD`;
CREATE TABLE `T_PAYMENT_METHOD` (
`UUID` varchar(32) NOT NULL ,
`PARTY_ID` varchar(32) NOT NULL ,
`METHOD` varchar(32) ,
`BANK` varchar(256) ,
`ACCOUNT` varchar(256) ,
`QDCODE` varchar(64),
`DEPOSIT_BANK` varchar(256) ,
`USERNAME` varchar(256),
PRIMARY KEY (`UUID`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
create index INDEX_PAYMENT_METHOD_PARTY_ID on T_PAYMENT_METHOD (
PARTY_ID
);
DROP TABLE IF EXISTS `T_KYC`;
CREATE TABLE `T_KYC` (
`UUID` varchar(32) NOT NULL ,
`PARTY_ID` varchar(32) NOT NULL ,
`IDNUMBER` varchar(128) ,
`IDNAME` varchar(256) ,
`NAME` varchar(128) ,
`IDIMG_1` varchar(64),
`IDIMG_2` varchar(64),
`STATUS` int(11),
`MSG` varchar(256),
PRIMARY KEY (`UUID`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
create index INDEX_KYC_PARTY_ID on T_KYC (
PARTY_ID
);
DROP TABLE IF EXISTS `T_TOKEN`;
CREATE TABLE `T_TOKEN` (
`UUID` varchar(32) NOT NULL ,
`PARTY_ID` varchar(32) NOT NULL ,
`TOKEN` varchar(128) ,
PRIMARY KEY (`UUID`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
create index INDEX_TOKEN_PARTY_ID on T_TOKEN (
PARTY_ID
);

View File

@@ -0,0 +1,28 @@
/*KYC*/
INSERT INTO `SCT_RESOURCE` (`UUID`, `RES_STRING`, `RES_TYPE`)
VALUES
('URL_ADMIN_KYC_SAVEPASSED', '/normal/adminKycAction!savePassed.action*', 'URL');
/*root管理员*/
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
VALUES
('SECURITY_ROLE_ROOT', 'URL_ADMIN_KYC_SAVEPASSED');
/*admin管理员*/
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
VALUES
('SECURITY_ROLE_ADMIN', 'URL_ADMIN_KYC_SAVEPASSED');
INSERT INTO `SCT_RESOURCE` (`UUID`, `RES_STRING`, `RES_TYPE`)
VALUES
('URL_ADMIN_KYC_SAVEFAILED', '/normal/adminKycAction!saveFailed.action*', 'URL');
/*root管理员*/
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
VALUES
('SECURITY_ROLE_ROOT', 'URL_ADMIN_KYC_SAVEFAILED');
/*admin管理员*/
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
VALUES
('SECURITY_ROLE_ADMIN', 'URL_ADMIN_KYC_SAVEFAILED');

View File

@@ -0,0 +1,45 @@
DROP TABLE IF EXISTS `T_KYC`;
CREATE TABLE `T_KYC` (
`UUID` varchar(32) NOT NULL,
`PARTY_ID` varchar(32) NOT NULL,
`IDNUMBER` varchar(128) DEFAULT NULL,
`IDNAME` varchar(256) DEFAULT NULL,
`NAME` varchar(128) DEFAULT NULL,
`IDIMG_1` varchar(64) DEFAULT NULL,
`IDIMG_2` varchar(64) DEFAULT NULL,
`STATUS` int(11) DEFAULT NULL,
`MSG` varchar(256) DEFAULT NULL,
`NATIONALITY` varchar(64) DEFAULT NULL,
`APPLY_TIME` datetime DEFAULT NULL,
PRIMARY KEY (`UUID`),
KEY `INDEX_KYC_PARTY_ID` (`PARTY_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create index INDEX_KYC_PARTY_ID on T_KYC (
PARTY_ID
);
CREATE TABLE `T_KYC_HIGH_LEVEL` (
`UUID` varchar(32) NOT NULL DEFAULT '',
`PARTY_ID` varchar(32) DEFAULT NULL,
`WORK_PLACE` varchar(256) DEFAULT NULL,
`HOME_PLACE` varchar(256) DEFAULT NULL,
`RELATIVES_RELATION` varchar(32) DEFAULT NULL,
`RELATIVES_NAME` varchar(32) DEFAULT NULL,
`RELATIVES_PLACE` varchar(256) DEFAULT NULL,
`RELATIVES_PHONE` varchar(32) DEFAULT NULL,
`APPLY_TIME` datetime DEFAULT NULL,
`STATUS` int(11) DEFAULT NULL,
`MSG` varchar(256) DEFAULT NULL,
PRIMARY KEY (`UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
create index INDEX_KYC_PARTY_ID on T_KYC_HIGH_LEVEL (
PARTY_ID
);
ALTER TABLE SCT_USER ADD `REMARKS` longtext ;

View File

@@ -0,0 +1,74 @@
package project.event;
import kernel.util.JsonUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import project.event.message.LogoffAccountEvent;
import project.event.model.LogoffAccountInfo;
import project.mall.evaluation.EvaluationService;
/**
* 用户注销账号后,需要同步修改相关的业务数据
* 目前可见受影响的业务数据:
* T_MALL_EVALUATION --- partId, username
* T_TRADER_FOLLOW_USER --- 无记录
* T_CODE_LOG --- userName 无值
* T_LOG --- partId createTime
* T_MESSAGE_USER --- partId 与 targetUserName 不是同一个人 updateTime
* T_ONLINECHAT_MESSAGE --- partId 与 UserName 不是同一个人 createTime
* PAT_PARTY --- 修改 userName email phone
* SCT_USER --- 修改 userName email
* T_CUSTOMER --- username createTime
* T_TIP --- target_username createTime
* T_WITHDRAW_ORDER --- userName 无值
* T_MALL_ORDER_LOG --- userName 无值
* T_AUTO_MONITOR_WITHDRAW_ORDER --- 无记录
* T_AUTO_MONITOR_WITHDRAW_COLLECTION_ORDER --- 无记录
*
*/
public class LogoffAccountEventListener implements ApplicationListener<LogoffAccountEvent> {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private EvaluationService evaluationService;
@Override
public void onApplicationEvent(LogoffAccountEvent event) {
LogoffAccountInfo accountInfo = event.getInfo();
logger.info("监听到用户:" + accountInfo.getPartyId() + " 注销了账号:" + JsonUtils.getJsonString(accountInfo));
try {
syncEvaluation(accountInfo.getPartyId(), accountInfo.getNewAccount());
} catch (Exception e) {
logger.error("用户:" + accountInfo.getPartyId() + " 注销账号后,同步修改订单评论信息报错,用户变更信息为: " + JsonUtils.getJsonString(accountInfo), e);
}
try {
// TODO
} catch (Exception e) {
}
}
/**
* 同步修改订单评论记录里的 userName 字段值
*
* @param partyId
* @param newAccount
*/
private void syncEvaluation(String partyId, String newAccount) {
logger.info("用户:" + partyId + " 注销了账号,准备同步修改订单评论记录中的 uerName 字段值... 新值:" + newAccount);
// TODO
logger.info("用户:" + partyId + " 注销了账号,完成了同步修改订单评论记录中的 uerName 字段值... 新值:" + newAccount);
}
public void setEvaluationService(EvaluationService evaluationService) {
this.evaluationService = evaluationService;
}
}

View File

@@ -0,0 +1,153 @@
package project.event;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import kernel.util.JsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import project.event.message.ModifyUserInfoEvent;
import project.event.model.UserChangeInfo;
import project.mall.evaluation.EvaluationService;
import project.mall.goods.model.Evaluation;
import project.mall.utils.MallPageInfo;
import project.party.PartyService;
import project.redis.RedisHandler;
import project.user.UserService;
import project.user.internal.OnlineUserService;
import project.user.token.TokenService;
import java.util.List;
/**
* 用户修改了关键信息后,需要同步相关的业务数据
* 目前可见受影响的业务数据:
* 1. 订单评论记录里冗余存储了 username 字段值
* 2. ....
*
*/
public class ModifyUserInfoEventListener implements ApplicationListener<ModifyUserInfoEvent> {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private RedisHandler redisHandler;
private PartyService partyService;
private UserService userService;
private OnlineUserService onlineUserService;
private TokenService tokenService;
private EvaluationService evaluationService;
@Override
public void onApplicationEvent(ModifyUserInfoEvent event) {
UserChangeInfo changeInfo = event.getChangeInfo();
logger.info("监听到用户修改了关键信息" + JsonUtils.getJsonString(changeInfo));
try {
String oldUserName = changeInfo.getOldUserName();
String newUserName = changeInfo.getNewUserName();
if (oldUserName == null) {
oldUserName = "";
}
if (newUserName == null) {
newUserName = "";
}
userService.updateSyncUserInfo(changeInfo);
if (!oldUserName.equals(newUserName)) {
// 用户账号发生了改变,删除 token 强制用户重新登录
onlineUserService.del(changeInfo.getPartyId());
tokenService.removeLoginToken(changeInfo.getPartyId());
}
} catch (Exception e) {
logger.error("用户修改个人关键信息后,同步修改用户记录报错,用户变更信息为: " + JsonUtils.getJsonString(changeInfo), e);
}
try {
syncEvaluation(changeInfo);
} catch (Exception e) {
logger.error("用户修改个人关键信息后,同步修改订单评论记录处理报错,用户变更信息为: " + JsonUtils.getJsonString(changeInfo), e);
}
}
/**
* 同步修改订单评论记录里的 userName 字段值
*
* @param changeInfo
*/
private void syncEvaluation(UserChangeInfo changeInfo) {
String oldUserName = changeInfo.getOldUserName();
String newUserName = changeInfo.getNewUserName();
if (oldUserName == null) {
oldUserName = "";
}
if (newUserName == null) {
newUserName = "";
}
if (StrUtil.isBlank(oldUserName) && StrUtil.isBlank(newUserName)) {
// 用户账号没变过
return;
}
if (oldUserName.equals(newUserName)) {
// 用户账号没变过
return;
}
logger.info("用户修改了账号值,准备同步修改订单评论记录中的 uerName 字段值... 原始值:" + oldUserName + ", 新值:" + newUserName);
// 目前的业务处理中,订单评论记录里, userName 字段必定有值
// 用户账号有变更,检查是否存在该用户的评论
if (StrUtil.isNotBlank(oldUserName) && !oldUserName.equals("0")) {
int pageNum = 1;
int pageSize = 100;
String sellerGoodsId = "";
String userName = oldUserName;
String evaluationType = "0";
while (true) {
MallPageInfo pageInfo = evaluationService.listEvaluations(pageNum, pageSize, sellerGoodsId, userName, evaluationType);
pageNum++;
List<Evaluation> pageList = (List<Evaluation>) pageInfo.getElements();
if (CollectionUtil.isEmpty(pageList)) {
break;
}
for (Evaluation oneEntity : pageList) {
oneEntity.setUserName(newUserName);
evaluationService.updateEvaluation(oneEntity);
}
}
}
logger.info("用户修改了账号值:" + oldUserName + " ===> " + newUserName + ",完成订单评论记录中的 uerName 字段值的同步修改");
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
public void setPartyService(PartyService partyService) {
this.partyService = partyService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
public void setOnlineUserService(OnlineUserService onlineUserService) {
this.onlineUserService = onlineUserService;
}
public void setTokenService(TokenService tokenService) {
this.tokenService = tokenService;
}
public void setEvaluationService(EvaluationService evaluationService) {
this.evaluationService = evaluationService;
}
}

View File

@@ -0,0 +1,20 @@
package project.event.message;
import org.springframework.context.ApplicationEvent;
import project.event.model.LogoffAccountInfo;
/**
* 注销账号事件
*/
public class LogoffAccountEvent extends ApplicationEvent {
private LogoffAccountInfo info;
public LogoffAccountEvent(Object source, LogoffAccountInfo info) {
super(source);
this.info = info;
}
public LogoffAccountInfo getInfo() {
return this.info;
}
}

View File

@@ -0,0 +1,18 @@
package project.event.message;
import org.springframework.context.ApplicationEvent;
import project.event.model.UserChangeInfo;
import project.onlinechat.OnlineChatUserMessage;
public class ModifyUserInfoEvent extends ApplicationEvent {
private UserChangeInfo info;
public ModifyUserInfoEvent(Object source, UserChangeInfo info) {
super(source);
this.info = info;
}
public UserChangeInfo getChangeInfo() {
return this.info;
}
}

View File

@@ -0,0 +1,13 @@
package project.event.model;
import lombok.Data;
@Data
public class LogoffAccountInfo {
private String partyId;
private String oriAccount;
private String newAccount;
}

View File

@@ -0,0 +1,130 @@
package project.event.model;
import lombok.Data;
public class UserChangeInfo {
private String partyId;
private String oldPhone;
private String newPhone;
private String oldEmail;
private String newEmail;
// 登录账号
private String oldUserName;
private String newUserName;
// 用户姓名
private String oldName;
private String newName;
// 明文密码
private String password;
// ...... 更多,可根据需要扩展
public static UserChangeInfo create() {
return new UserChangeInfo();
}
public UserChangeInfo withPartyId(String partyId) {
this.partyId = partyId;
return this;
}
public UserChangeInfo withOldPhone(String oldPhone) {
this.oldPhone = oldPhone;
return this;
}
public UserChangeInfo withNewPhone(String newPhone) {
this.newPhone = newPhone;
return this;
}
public UserChangeInfo withOldEmail(String oldEmail) {
this.oldEmail = oldEmail;
return this;
}
public UserChangeInfo withNewEmail(String newEmail) {
this.newEmail = newEmail;
return this;
}
public UserChangeInfo withOldUserName(String oldUserName) {
this.oldUserName = oldUserName;
return this;
}
public UserChangeInfo withNewUserName(String newUserName) {
this.newUserName = newUserName;
return this;
}
public UserChangeInfo withOldName(String oldName) {
this.oldName = oldName;
return this;
}
public UserChangeInfo withNewName(String newName) {
this.newName = newName;
return this;
}
public UserChangeInfo withPassword(String password) {
this.password = password;
return this;
}
public UserChangeInfo check() {
// TODO
return this;
}
// GET 方法系列
public String getPartyId() {
return partyId;
}
public String getOldPhone() {
return oldPhone;
}
public String getNewPhone() {
return newPhone;
}
public String getOldEmail() {
return oldEmail;
}
public String getNewEmail() {
return newEmail;
}
public String getOldName() {
return oldName;
}
public String getNewName() {
return newName;
}
public String getOldUserName() {
return oldUserName;
}
public String getNewUserName() {
return newUserName;
}
public String getPassword() {
return this.password;
}
}

View File

@@ -0,0 +1,20 @@
package project.user;
import java.util.Date;
import kernel.web.Page;
public interface AdminUserSafewordApplyService {
public Page pagedQuery(int pageNo, int pageSize, String name_para, Integer status_para,String rolename_para, String checkedPartyId, Integer operate);
public void savePassed(String id,String operatorUsername,String safeword);
public void saveFailed(String id, String msg);
/**
* 某个时间后未处理数量,没有时间则全部
*/
public Long getUntreatedCount(Date time, String loginPartyId);
}

View File

@@ -0,0 +1,70 @@
package project.user;
import project.party.model.Party;
public interface LocalUserService {
/**
* 注册用户
*/
public void saveRegister(LocalNormalReg reg, String type);
/**
* 手机/邮箱注册(无验证码)
*/
public void saveRegisterNoVerifcode(LocalNormalReg reg, String type);
/**
* 手机/邮箱注册(有验证码)
*/
public void saveRegisterWithVerifcode(LocalNormalReg reg, String type);
/**
* JustShop 使用邮箱和手机号注册 生成单个用户信息
* @param reg
*/
void saveRegisterNoVerifcodeJs(LocalNormalReg reg,String type);
/**
* 承兑商注册
*/
public Party saveRegisterC2cUser(String username, String password, String re_password, String type, String usercode, String ip);
/**
* 注册用户无验证码
*/
public void saveRegisterUsername(LocalNormalReg reg);
/**
* 无验证码注册试用用户
*/
public void saveRegisterUsernameTest(LocalNormalReg reg);
/**
* 获取手机号
*/
public String getPhone(String partyId);
/**
* 保存更新手机号
*/
public void savePhone(String phone, String partyId);
/**
* 获取邮箱号
*/
public String getEmail(String partyId);
/**
* 保存更新邮箱
*/
public void saveEmail(String email, String partyId);
/**
* 获取图片
*/
// public List<ImageQr> findImageByUsercode(String usercode, String image_language, String image_type);
//
// public List<ImageQr> findAndSaveImageByUsercode(String usercode, String image_language, String image_type);
}

View File

@@ -0,0 +1,37 @@
package project.user;
public class UserRedisKeys {
/**
* 用户认证
*/
public final static String KYC_PARTY_ID = "KYC_PARTY_ID_";
/**
* 高级认证
*/
public final static String KYC_HIGHLEVEL_PARTY_ID = "KYC_HIGHLEVEL_PARTY_ID_";
/**
* 支付方式
*/
public final static String PAYMENT_METHOD_ID = "PAYMENT_METHOD_ID_";
public final static String PAYMENT_METHOD_PARTY_ID = "PAYMENT_METHOD_PARTY_ID_";
/**
* token
*/
public final static String TOKEN = "TOKEN_";
public final static String TOKEN_PARTY_ID = "TOKEN_PARTY_ID_";
public final static String PLAT_FROM_TOKEN = "PLAT_FROM_TOKEN_";
public final static String PLAT_FROM_TOKEN_PARTY_ID = "PLAT_FROM_TOKEN_PARTY_ID_";
/**
* 在线用户
*/
public final static String ONLINEUSER_PARTYID = "ONLINEUSER_PARTYID_";
public final static String ONLINEUSER = "ONLINEUSER_";
/**
* 客服聊天列表在线聊天,离线状态设置 在线1离开2离线3
*/
public final static String ONLINE_USER_STATUS_PARTYID = "ONLINE_USER_STATUS_PARTYID:";
}

View File

@@ -0,0 +1,58 @@
<?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.user.UserSafewordApply" table="T_USER_SAFEWORD_APPLY">
<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="idcard_path_front" type="java.lang.String">
<column name="IDCARD_PATH_FRONT" />
</property>
<property name="idcard_path_back" type="java.lang.String">
<column name="IDCARD_PATH_BACK" />
</property>
<property name="idcard_path_hold" type="java.lang.String">
<column name="IDCARD_PATH_HOLD" />
</property>
<property name="operate" type="int">
<column name="OPERATE" />
</property>
<property name="remark" type="java.lang.String">
<column name="REMARK" />
</property>
<property name="safeword" type="java.lang.String">
<column name="SAFEWORD" />
</property>
<property name="status" type="int">
<column name="STATUS" />
</property>
<property name="msg" type="java.lang.String">
<column name="MSG" />
</property>
<property name="apply_time" type="timestamp">
<column name="APPLY_TIME" />
</property>
<property name="create_time" type="timestamp">
<column name="CREATE_TIME" />
</property>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,155 @@
package project.user;
import java.io.Serializable;
import java.util.Date;
import kernel.bo.EntityObject;
public class UserSafewordApply extends EntityObject {
private static final long serialVersionUID = -4196439149608747292L;
/**
* 实名姓名
*/
private Serializable partyId;
/**
* 证件正面照
*/
private String idcard_path_front;
/**
* 证件背面照
*/
private String idcard_path_back;
/**
* 正面手持证件照
*/
private String idcard_path_hold;
/**
* 资金密码
*/
private String safeword;
/**
* 1审核中 2 审核通过,3审核未通过
*/
private int status;
/**
* 审核消息,未通过原因
*/
private String msg;
/**
* 创建时间
*/
private Date create_time;
/**
* 审核时间
*/
private Date apply_time;
/**
* 操作类型
*/
private int operate;
/**
* 备注
*/
private String remark;
public Serializable getPartyId() {
return partyId;
}
public void setPartyId(Serializable partyId) {
this.partyId = partyId;
}
public String getIdcard_path_front() {
return idcard_path_front;
}
public void setIdcard_path_front(String idcard_path_front) {
this.idcard_path_front = idcard_path_front;
}
public String getIdcard_path_back() {
return idcard_path_back;
}
public void setIdcard_path_back(String idcard_path_back) {
this.idcard_path_back = idcard_path_back;
}
public String getIdcard_path_hold() {
return idcard_path_hold;
}
public void setIdcard_path_hold(String idcard_path_hold) {
this.idcard_path_hold = idcard_path_hold;
}
public String getSafeword() {
return safeword;
}
public void setSafeword(String safeword) {
this.safeword = safeword;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Date getCreate_time() {
return create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public Date getApply_time() {
return apply_time;
}
public void setApply_time(Date apply_time) {
this.apply_time = apply_time;
}
public int getOperate() {
return operate;
}
public void setOperate(int operate) {
this.operate = operate;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

View File

@@ -0,0 +1,26 @@
package project.user;
import java.util.List;
import java.util.Map;
public interface UserSafewordApplyService {
public void save(UserSafewordApply entity);
public void update(UserSafewordApply entity);
public void delete(String id);
public UserSafewordApply findById(String id);
public List<UserSafewordApply> findByPartyId(String partyId);
/**
* 人工重置 操作类型 operate: 0/修改资金密码1/取消谷歌绑定2/取消手机绑定3/取消邮箱绑定;
*/
public void saveApply(String partyId, String idcard_path_front, String idcard_path_back, String idcard_path_hold, String safeword,
String safeword_confirm, Integer operate, String remark);
public Map<String, Object> bindOne(UserSafewordApply apply);
}

View File

@@ -0,0 +1,54 @@
package project.user;
import java.util.Map;
import project.event.model.UserChangeInfo;
import security.SecUser;
public interface UserService {
/**
* 登录
*/
public SecUser addLogin(String username, String password);
/**
* 验证码登录
*/
public SecUser addLogin_idcode(String username, String verifcode);
/**
* 退出登录
*/
public void logout(String partyId);
/**
* 图片验证码缓存
*/
public Map<String, String> getImageCodeCache();
/**
* 设置玩家在线
*/
public void online(String partyId);
/**
* 设置玩家下线
*/
public void offline(String partyId);
public void putImageCode(String key, String value);
public String cacheImageCode(String key);
public void cacheRemoveImageCode(String key);
/**
* 用户关键信息修改了,需要同步到 secUser 表
* @param changeInfo
*/
public void updateSyncUserInfo(UserChangeInfo changeInfo);
void updateLogoffAccount(String partyId, String reason);
}

View File

@@ -0,0 +1,33 @@
package project.user.captcha;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
/**
* Geetest滑动图片验证
*/
public interface GeetestService {
/**
* 验证初始化预处理
*/
public HashMap<String, String> preProcess(HashMap<String, String> data);
/**
* 获取版本信息
*/
public String getVersionInfo();
/**
* 服务正常的情况下使用的验证方式,,向gt-server进行二次验证获取验证结果
* 验证结果1/验证成功0/验证失败;
*/
public int enhencedValidateRequest(HashMap<String, String> data) throws UnsupportedEncodingException;
/**
* failback使用的验证方式
* 验证结果1/验证成功0/验证失败;
*/
public int failbackValidateRequest(HashMap<String, String> data);
}

View File

@@ -0,0 +1,456 @@
package project.user.captcha.internal;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import project.user.captcha.GeetestService;
/**
* Geetest滑动图片验证
*/
public class GeetestServiceImpl implements GeetestService {
// SDK版本编号
protected final String verName = "3.3.0";
// SD的语言类型
protected final String sdkLang = "java";
//极验验证API URL
protected final String apiUrl = "http://api.geetest.com";
protected final String baseUrl = "api.geetest.com";
//register url
protected final String registerUrl = "/register.php";
//validate url
protected final String validateUrl = "/validate.php";
/**
* 调试开关,是否输出调试日志
*/
public boolean debugCode = true;
/**
* 验证初始化预处理
* 用captchaID进行注册更新challenge 1/注册成功0/注册失败;
* @throws UnsupportedEncodingException
*/
public HashMap<String, String> preProcess(HashMap<String, String> data) {
try {
String userId = data.get("user_id");
String geetestId = data.get("geetest_id");
String geetestKey = data.get("geetest_key");
String getUrl = this.apiUrl + this.registerUrl + "?";
String param = "gt=" + geetestId;
if (userId != null) {
param = param + "&user_id=" + userId;
}
this.gtlog("GET_URL:" + getUrl + param);
String result_str = this.readContentFromGet(getUrl + param);
this.gtlog("register_result:" + result_str);
if (32 == result_str.length()) {
return this.getSuccessPreProcessRes(this.md5Encode(result_str + geetestKey), geetestId);
} else {
this.gtlog("gtServer register challenge failed");
return this.getFailPreProcessRes(geetestId);
}
} catch (Throwable t) {
this.gtlog(t.toString());
this.gtlog("exception:preProcess api");
}
return null;
}
/**
* 预处理失败后的返回格式串
*/
private HashMap<String, String> getFailPreProcessRes(String geetestId) {
Long rnd1 = Math.round(Math.random() * 100);
Long rnd2 = Math.round(Math.random() * 100);
String md5Str1 = md5Encode(rnd1 + "");
String md5Str2 = md5Encode(rnd2 + "");
String challenge = md5Str1 + md5Str2.substring(0, 2);
HashMap<String, String> ret = new HashMap<String, String>();
ret.put("success", "0");
ret.put("gt", geetestId);
ret.put("challenge", challenge);
return ret;
}
/**
* 预处理成功后的标准串
*/
private HashMap<String, String> getSuccessPreProcessRes(String challenge, String geetestId) {
this.gtlog("challenge:" + challenge);
HashMap<String, String> ret = new HashMap<String, String>();
ret.put("success", "1");
ret.put("gt", geetestId);
ret.put("challenge", challenge);
return ret;
}
/**
* 服务正常的情况下使用的验证方式,,向gt-server进行二次验证获取验证结果
* 验证结果1/验证成功0/验证失败;
*/
public int enhencedValidateRequest(HashMap<String, String> data) throws UnsupportedEncodingException {
String userId = data.get("user_id");
String challenge = data.get("challenge");
String validate = data.get("validate");
String seccode = data.get("seccode");
String geetestKey = data.get("geetest_key");
if (!this.resquestIsLegal(challenge, validate, seccode)) {
return 0;
}
this.gtlog("request legitimate");
String host = baseUrl;
String path = validateUrl;
int port = 80;
String query = String.format("seccode=%s&sdk=%s", seccode,
(this.sdkLang + "_" + this.verName));
String response = "";
if (userId != ""){
query = query + "&user_id=" + userId;
userId = "";
}
this.gtlog(query);
try {
if (validate.length() <= 0) {
return 0;
}
if (!this.checkResultByPrivate(challenge, validate, geetestKey)) {
return 0;
}
this.gtlog("checkResultByPrivate");
response = this.postValidate(host, path, query, port);
this.gtlog("response: " + response);
} catch (Exception e) {
e.printStackTrace();
}
this.gtlog("md5: " + this.md5Encode(seccode));
if (response.equals(this.md5Encode(seccode))) {
return 1;
} else {
return 0;
}
}
/**
* 貌似不是Post方式后面重构时修改名字
*/
protected String postValidate(String host, String path, String data, int port) throws Exception {
String response = "error";
InetAddress addr = InetAddress.getByName(host);
Socket socket = new Socket(addr, port);
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF8"));
wr.write("POST " + path + " HTTP/1.0\r\n");
wr.write("Host: " + host + "\r\n");
wr.write("Content-Type: application/x-www-form-urlencoded\r\n");
wr.write("Content-Length: " + data.length() + "\r\n");
// 以空行作为分割
wr.write("\r\n");
// 发送数据
wr.write(data);
wr.flush();
// 读取返回信息
BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
String line;
while ((line = rd.readLine()) != null) {
response = line;
}
wr.close();
rd.close();
socket.close();
return response;
}
/**
* failback使用的验证方式
* @return 验证结果,1表示验证成功0表示验证失败
*/
public int failbackValidateRequest(HashMap<String, String> data) {
this.gtlog("in failback validate");
String challenge = data.get("challenge");
String validate = data.get("validate");
String seccode = data.get("seccode");
if (!this.resquestIsLegal(challenge, validate, seccode)) {
return 0;
}
this.gtlog("request legitimate");
String[] validateStr = validate.split("_");
String encodeAns = validateStr[0];
String encodeFullBgImgIndex = validateStr[1];
String encodeImgGrpIndex = validateStr[2];
this.gtlog(String.format("encode----challenge:%s--ans:%s,bg_idx:%s,grp_idx:%s",
challenge, encodeAns, encodeFullBgImgIndex, encodeImgGrpIndex));
int decodeAns = this.decodeResponse(challenge, encodeAns);
int decodeFullBgImgIndex = this.decodeResponse(challenge, encodeFullBgImgIndex);
int decodeImgGrpIndex = this.decodeResponse(challenge, encodeImgGrpIndex);
this.gtlog(String.format("decode----ans:%s,bg_idx:%s,grp_idx:%s",
decodeAns, decodeFullBgImgIndex, decodeImgGrpIndex));
int validateResult = this.validateFailImage(decodeAns, decodeFullBgImgIndex, decodeImgGrpIndex);
return validateResult;
}
private int validateFailImage(int ans, int full_bg_index, int img_grp_index) {
// 容差值
final int thread = 3;
String full_bg_name = this.md5Encode(full_bg_index + "").substring(0, 9);
String bg_name = this.md5Encode(img_grp_index + "").substring(10, 19);
String answer_decode = "";
// 通过两个字符串奇数和偶数位拼接产生答案位
for (int i = 0; i < 9; i++) {
if (i % 2 == 0) {
answer_decode += full_bg_name.charAt(i);
} else if (i % 2 == 1) {
answer_decode += bg_name.charAt(i);
} else {
this.gtlog("exception");
}
}
String x_decode = answer_decode.substring(4, answer_decode.length());
// 16 to 10
int x_int = Integer.valueOf(x_decode, 16);
int result = x_int % 200;
if (result < 40) {
result = 40;
}
if (Math.abs(ans - result) <= thread) {
return 1;
} else {
return 0;
}
}
/**
* 解码随机参数
*/
private int decodeResponse(String challenge, String string) {
if (string.length() > 100) {
return 0;
}
int[] shuzi = new int[] { 1, 2, 5, 10, 50 };
String chongfu = "";
HashMap<String, Integer> key = new HashMap<String, Integer>();
int count = 0;
for (int i = 0; i < challenge.length(); i++) {
String item = challenge.charAt(i) + "";
if (chongfu.contains(item) == true) {
continue;
} else {
int value = shuzi[count % 5];
chongfu += item;
count++;
key.put(item, value);
}
}
int res = 0;
for (int j = 0; j < string.length(); j++) {
res += key.get(string.charAt(j) + "");
}
res = res - decodeRandBase(challenge);
return res;
}
/**
* 输入的两位的随机数字,解码出偏移量
*/
private int decodeRandBase(String challenge) {
String base = challenge.substring(32, 34);
ArrayList<Integer> tempArray = new ArrayList<Integer>();
for (int i = 0; i < base.length(); i++) {
char tempChar = base.charAt(i);
Integer tempAscii = (int) (tempChar);
Integer result = (tempAscii > 57) ? (tempAscii - 87) : (tempAscii - 48);
tempArray.add(result);
}
int decodeRes = tempArray.get(0) * 36 + tempArray.get(1);
return decodeRes;
}
/**
* 发送请求,获取服务器返回结果
*/
private String readContentFromGet(String getURL) throws IOException {
URL getUrl = new URL(getURL);
HttpURLConnection connection = (HttpURLConnection) getUrl.openConnection();
// 设置连接主机超时(单位:毫秒)
connection.setConnectTimeout(2000);
// 设置从主机读取数据超时(单位:毫秒)
connection.setReadTimeout(2000);
// 建立与服务器的连接,并未发送数据
connection.connect();
// 发送数据到服务器并使用Reader读取返回的数据
StringBuffer sBuffer = new StringBuffer();
InputStream inStream = null;
byte[] buf = new byte[1024];
inStream = connection.getInputStream();
for (int n; (n = inStream.read(buf)) != -1;) {
sBuffer.append(new String(buf, 0, n, "UTF-8"));
}
inStream.close();
// 断开连接
connection.disconnect();
return sBuffer.toString();
}
/**
* 输出debug信息需要开启debugCode
*/
public void gtlog(String message) {
if (this.debugCode) {
System.out.println("gtlog: " + message);
}
}
/**
* 判断一个表单对象值是否为空
*/
protected boolean objIsEmpty(Object gtObj) {
if (gtObj == null) {
return true;
}
if (gtObj.toString().trim().length() == 0) {
return true;
}
return false;
}
/**
* 检查客户端的请求是否合法,三个只要有一个为空,则判断不合法
*/
private boolean resquestIsLegal(String challenge, String validate, String seccode) {
if (objIsEmpty(challenge)) {
return false;
}
if (objIsEmpty(validate)) {
return false;
}
if (objIsEmpty(seccode)) {
return false;
}
return true;
}
protected boolean checkResultByPrivate(String challenge, String validate, String privateKey) {
String encodeStr = this.md5Encode(privateKey + "geetest" + challenge);
return validate.equals(encodeStr);
}
/**
* md5 加密
*
* @time 2014年7月10日 下午3:30:01
* @param plainText
* @return
*/
private String md5Encode(String plainText) {
String re_md5 = new String();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();
int i;
StringBuffer buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += 256;
if (i < 16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
re_md5 = buf.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return re_md5;
}
/**
* 获取版本信息
*/
public String getVersionInfo() {
return this.verName;
}
}

View File

@@ -0,0 +1,64 @@
package project.user.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.redis.RedisHandler;
import project.user.UserRedisKeys;
import project.user.kyc.Kyc;
import project.user.kyc.KycHighLevel;
import project.user.token.Token;
public class UserLoadCacheService extends HibernateDaoSupport {
private static final Log logger = LogFactory.getLog(UserLoadCacheService.class);
private RedisHandler redisHandler;
public void loadcache() {
loadToken();
loadKyc();
loadKycHighLevel();
logger.info("完成User数据加载redis");
}
public void loadToken() {
StringBuffer queryString = new StringBuffer(" FROM Token ");
List<Token> list = (List<Token>) this.getHibernateTemplate().find(queryString.toString());
for (Token token : list) {
redisHandler.setSync(UserRedisKeys.TOKEN + token.getToken(), token.getPartyId().toString());
redisHandler.setSync(UserRedisKeys.TOKEN_PARTY_ID + token.getPartyId().toString(), token);
}
}
public void loadKyc() {
StringBuffer queryString = new StringBuffer(" FROM Kyc ");
List<Kyc> list = (List<Kyc>) this.getHibernateTemplate().find(queryString.toString());
Map<String, Object> params = new ConcurrentHashMap<String, Object>();
for (Kyc kyc : list) {
params.put(UserRedisKeys.KYC_PARTY_ID + kyc.getPartyId().toString(), kyc);
}
this.redisHandler.setBatchSync(params);
}
public void loadKycHighLevel() {
StringBuffer queryString = new StringBuffer(" FROM KycHighLevel ");
List<KycHighLevel> list = (List<KycHighLevel>) this.getHibernateTemplate().find(queryString.toString());
for (KycHighLevel kycHighLevel : list) {
redisHandler.setSync(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + kycHighLevel.getPartyId().toString(),
kycHighLevel);
}
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
}

View File

@@ -0,0 +1,47 @@
package project.user.googleauth;
import security.SecUser;
public interface GoogleAuthService {
/**
* 用户绑定谷歌验证器
* @param username
*/
public boolean saveGoogleAuthBind(String username,String secret,String code);
/**
* 用户解绑谷歌验证器
* @param username
*/
public void saveGoogleAuthUnBind(String username);
/**
* 验证用户的谷歌验证码
* @param secret
* @param code
* @return
*/
public boolean checkCode(String secret,String code);
/**
* 生成谷歌验证码二维码,并返回地址
* @param username
* @param secret
* @return 二维码地址
*/
public String getGoogleAuthUrl(String username,String secret);
/**
* 校验超级谷歌验证码
*/
public void queryCheckSuperGoogleAuthCode(String code);
/**
* 校验谷歌验证码
*/
public void checkGoogleAuthCode(SecUser secUser,String code);
/**
* 登录时 校验谷歌验证码
*/
public void updateGoogleAuthCodeForLogin(String ip, String operatorUsername, String googleAuthCode, String uri);
}

View File

@@ -0,0 +1,171 @@
package project.user.googleauth.internal;
import java.text.MessageFormat;
import java.util.Date;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import kernel.exception.BusinessException;
import kernel.util.DateUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import project.Constants;
import project.log.Log;
import project.log.LogService;
import project.syspara.SysparaService;
import project.user.QRGenerateService;
import project.user.googleauth.GoogleAuthService;
import security.SecUser;
import security.internal.SecUserService;
import util.GoogleAuthenticator;
@Slf4j
public class GoogleAuthServiceImpl implements GoogleAuthService {
private SysparaService sysparaService;
private SecUserService secUserService;
private QRGenerateService qRGenerateService;
private LogService logService;
private Logger logger = LogManager.getLogger(this.getClass().getName());
/**
* 用户绑定谷歌验证器
* @param username
*/
public boolean saveGoogleAuthBind(String username,String secret,String code) {
if (StringUtils.isEmpty(secret)) {
throw new BusinessException("密匙不能为空");
}
if (StringUtils.isEmpty(code)) {
throw new BusinessException("验证码不能为空");
}
SecUser secUser = secUserService.findUserByLoginName(username);
if (secUser.isGoogle_auth_bind()) {
throw new BusinessException("用户已绑定");
}
boolean checkCode = checkCode(secret,code);
if(checkCode) {
secUser.setGoogle_auth_secret(secret);
secUser.setGoogle_auth_bind(true);
secUserService.update(secUser);
}
return checkCode;
}
/**
* 用户解绑谷歌验证器
* @param username
*/
public void saveGoogleAuthUnBind(String username) {
SecUser secUser = secUserService.findUserByLoginName(username);
if (secUser==null) {
throw new BusinessException("用户不存在");
}
if (!secUser.isGoogle_auth_bind()) {
throw new BusinessException("用户未绑定,无需解绑");
}
secUser.setGoogle_auth_bind(false);
secUserService.update(secUser);
}
/**
* 验证用户的谷歌验证码
* @param username
* @param code
* @return
*/
public boolean checkCode(String secret,String code) {
if (StringUtils.isEmpty(code)) {
throw new BusinessException("验证码不能为空");
}
long t = System.currentTimeMillis();
GoogleAuthenticator ga = new GoogleAuthenticator();
ga.setWindowSize(5); // should give 5 * 30 seconds of grace...
boolean r = ga.check_code(secret, Long.valueOf(code), t);
return r;
}
public String getGoogleAuthUrl(String username,String secret) {
// otpauth://totp/12345678@google_auth_host?secret=U67YQFSJ5ILQJVPJ
String host = sysparaService.find("google_auth_host").getValue();
String content = String.format("otpauth://totp/%s@%s?secret=%s", username,host,secret);
String imageName = username+"@"+host;
String uri = this.qRGenerateService.generate(content,imageName);
logger.info("admin_code_url->>>>" + Constants.ADMIN_URL);
String path = Constants.ADMIN_URL + "/public/showimg!showImg.action?imagePath=" + uri;
logger.info("二维码生成->>>>" + path);
return path;
}
public void queryCheckSuperGoogleAuthCode(String code) {
String secret = sysparaService.find("super_google_auth_secret").getValue();
boolean checkCode = checkCode(secret, code);
if (!checkCode) {
throw new BusinessException("谷歌验证码错误");
}
}
/**
* 校验谷歌验证码
*/
public void checkGoogleAuthCode(SecUser secUser,String code) {
if(!secUser.isGoogle_auth_bind()) {
throw new BusinessException("请先绑定谷歌验证器");
}
boolean checkCode = checkCode(secUser.getGoogle_auth_secret(), code);
if(!checkCode) {
throw new BusinessException("谷歌验证码错误");
}
}
/**
* 登录时 校验谷歌验证码
*/
public void updateGoogleAuthCodeForLogin(String ip, String operatorUsername, String googleAuthCode, String uri) {
SecUser user = secUserService.findUserByLoginName(operatorUsername);
checkGoogleAuthCode(user,googleAuthCode);
String context = MessageFormat.format("user:{0},opera time:{1},opera ip:{2},request uri:{3},"
+ "last login ip:{4},last login time:{5}",
new Object[]{user.getUsername(),DateUtils.dateToStr(new Date(), DateUtils.DF_yyyyMMddHHmmss),ip,uri,
user.getLogin_ip(),DateUtils.dateToStr(user.getLast_loginTime(), DateUtils.DF_yyyyMMddHHmmss)});
if ("root".equals(user.getUsername())) {
context = MessageFormat.format("user:{0},opera time:{1},request uri:{2},"
+ "last login time:{3}",
new Object[]{user.getUsername(),DateUtils.dateToStr(new Date(), DateUtils.DF_yyyyMMddHHmmss),uri,
DateUtils.dateToStr(user.getLast_loginTime(), DateUtils.DF_yyyyMMddHHmmss)});
}
user.setLogin_ip(ip);
user.setLast_loginTime(new Date());
// ip切换相当于重新登录
secUserService.update(user);
this.saveLog(user, operatorUsername, context);
}
public void saveLog(SecUser secUser, String operator,String context) {
Log log = new Log();
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
log.setOperator(operator);
log.setUsername(secUser.getUsername());
log.setPartyId(secUser.getPartyId());
log.setLog(context);
log.setCreateTime(new Date());
logService.saveSync(log);
}
public void setSysparaService(SysparaService sysparaService) {
this.sysparaService = sysparaService;
}
public void setSecUserService(SecUserService secUserService) {
this.secUserService = secUserService;
}
public void setqRGenerateService(QRGenerateService qRGenerateService) {
this.qRGenerateService = qRGenerateService;
}
public void setLogService(LogService logService) {
this.logService = logService;
}
}

View File

@@ -0,0 +1,33 @@
package project.user.idcode;
import org.springframework.beans.factory.InitializingBean;
import kernel.util.TimeWindow;
public class BlacklistIpTimeWindow implements InitializingBean {
private TimeWindow timeWindow = new TimeWindow();
public void afterPropertiesSet() throws Exception {
/**
* 24小时
*/
this.timeWindow.setTimeSize(60 * 60 * 24);
this.timeWindow.start();
}
public String getBlackIp(String key) {
Object authcode = this.timeWindow.findObject(key);
if (authcode != null) {
return String.valueOf(authcode.toString());
}
return null;
}
public void putBlackIp(String key, String ip) {
this.timeWindow.add(key, ip);
}
public void delBlackIp(String key) {
this.timeWindow.remove(key);
}
}

View File

@@ -0,0 +1,15 @@
package project.user.idcode;
/**
* 验证码发送接口
*
*
*/
public interface IdentifyingCodeService {
/**
*
* @param target 邮件或手机号
* @param ip 会根据发送频率封ip
*/
public void addSend(String target, String ip);
}

View File

@@ -0,0 +1,33 @@
package project.user.idcode;
import org.springframework.beans.factory.InitializingBean;
import kernel.util.TimeWindow;
public class IdentifyingCodeTimeWindow implements InitializingBean, IdentifyingCodeTimeWindowService {
private TimeWindow timeWindow = new TimeWindow();
public void afterPropertiesSet() throws Exception {
/**
* 30分钟
*/
this.timeWindow.setTimeSize(60 * 30);
this.timeWindow.start();
}
public String getAuthCode(String key) {
Object authcode = this.timeWindow.findObject(key);
if (authcode != null) {
return String.valueOf(authcode);
}
return null;
}
public void putAuthCode(String key, String authcode) {
this.timeWindow.add(key, authcode);
}
public void delAuthCode(String key) {
this.timeWindow.remove(key);
}
}

View File

@@ -0,0 +1,10 @@
package project.user.idcode;
public interface IdentifyingCodeTimeWindowService {
public String getAuthCode(String key);
public void putAuthCode(String key, String authcode);
public void delAuthCode(String key);
}

View File

@@ -0,0 +1,33 @@
package project.user.idcode;
import org.springframework.beans.factory.InitializingBean;
import kernel.util.TimeWindow;
public class SendCountTimeWindow implements InitializingBean {
private TimeWindow timeWindow = new TimeWindow();
public void afterPropertiesSet() throws Exception {
/**
* 10分钟
*/
this.timeWindow.setTimeSize(60 * 10);
this.timeWindow.start();
}
public String getIpSend(String key) {
Object authcode = this.timeWindow.findObject(key);
if (authcode != null) {
return String.valueOf(authcode.toString());
}
return null;
}
public void putIpSend(String key, String ip) {
this.timeWindow.add(key, ip);
}
public void delIpSend(String key) {
this.timeWindow.remove(key);
}
}

View File

@@ -0,0 +1,211 @@
package project.user.idcode.internal;
import java.text.MessageFormat;
import java.util.Date;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.mysql.cj.util.StringUtils;
import email.EmailSendService;
import project.log.CodeLog;
import project.log.CodeLogService;
import project.syspara.SysParaCode;
import project.syspara.Syspara;
import project.syspara.SysparaService;
import project.user.idcode.BlacklistIpTimeWindow;
import project.user.idcode.IdentifyingCodeService;
import project.user.idcode.IdentifyingCodeTimeWindowService;
import project.user.idcode.SendCountTimeWindow;
import smsbao.SmsSendService;
public class IdentifyingCodeServiceImpl implements IdentifyingCodeService {
private Logger log = LoggerFactory.getLogger(IdentifyingCodeServiceImpl.class);
private SmsSendService smsSendService;
private EmailSendService emailSendService;
private IdentifyingCodeTimeWindowService identifyingCodeTimeWindowService;
private SendCountTimeWindow sendCountTimeWindow;
private BlacklistIpTimeWindow blacklistIpTimeWindow;
private SysparaService sysparaService;
private CodeLogService codeLogService;
private Map<String, Integer> ipCache = new ConcurrentHashMap<String, Integer>();
@Override
public void addSend(String target, String ip) {
String code = null;
if (chcekIp(ip)) {// 被封的ip直接返回 不操作
return;
}
/**
* 短信发送签名
*/
// String smsbao_sign = sysparaService.find("smsbao_sign").getValue();
// 短信发送文本[TEST]code is {0}
String send_code_text = "";
String title = "";
if (target.indexOf("@") == -1) {
// 短信
Syspara contentParam = this.sysparaService.find(SysParaCode.SEND_CODE_TEXT.getCode());
if (contentParam == null || StringUtils.isNullOrEmpty(contentParam.getValue())) {
log.error("send_code_text 未配置");
return;
}
send_code_text = contentParam.getValue();
} else {
// 邮件
Syspara contentParam = this.sysparaService.find(SysParaCode.SEND_EMAIL_CODE_TEXT.getCode());
Syspara titleParam = this.sysparaService.find(SysParaCode.SEND_EMAIL_CODE_TITLE.getCode());
if (contentParam == null || StringUtils.isNullOrEmpty(contentParam.getValue())) {
log.error("send_email_code_text 未配置");
return;
}
send_code_text = contentParam.getValue();
if (titleParam == null || StringUtils.isNullOrEmpty(titleParam.getValue())) {
log.error("send_email_code_title 未配置");
title = "Email captchaCode";
} else {
title = titleParam.getValue();
}
}
/**
* 是否每次发送的code都不一样
*/
boolean send_code_always_new = this.sysparaService.find("send_code_always_new").getBoolean();
Object object = this.identifyingCodeTimeWindowService.getAuthCode(target);
if (object == null || send_code_always_new) {
Random random = new Random();
code = String.valueOf(random.nextInt(999999) % 900000 + 100000);
} else {
code = String.valueOf(object);
}
// log.info(MessageFormat.format("target:{0},code:{1},ip:{2}", target, code, ip));
String content = MessageFormat.format(send_code_text, new Object[] { code });
if (target.indexOf("@") == -1) {
/**
* 发送的短信接口类型 tiantian---天天---smsSendService--->>>>--
* moduyun---摩杜云---smsSingleSender
*/
String send_code_type = this.sysparaService.find("send_code_type").getValue();
if (StringUtils.isNullOrEmpty(send_code_type)) {
log.error("send_code_type 未配置");
return;
}
if ("tiantian".equals(send_code_type)) {
smsSendService.send(target, content);
log.info(MessageFormat.format("tiangtian--target:{0},code:{1},ip:{2}", target, code, ip));
}
// else if ("moduyun".equals(send_code_type)) {
// // -- 摩杜云短信签名的Id--accesskey,secretkey,signId,templateId
// String send_code_moduyun = this.sysparaService.find("send_code_moduyun").getValue();
// String[] send_code_moduyun_parts = send_code_moduyun.split(",");
// List<String> params = new ArrayList<String>();
// params.add(code);
// String strh_code = "";
// strh_code = target.substring(0, 2);
// if ("86".equals(strh_code)) {
// try {
// smsSingleSender.send(0, "86", target.substring(2, target.length()), send_code_moduyun_parts[2],
// send_code_moduyun_parts[3], params, "", send_code_moduyun_parts[0],
// send_code_moduyun_parts[1]);
// log.info(MessageFormat.format("moduyun--target:{0},code:{1},ip:{2}", target, code, ip));
// } catch (Exception e) {
// }
// }
// }
else if ("smsbao".equals(send_code_type)) {
smsSendService.send(target, content);
log.info(MessageFormat.format("smsbao--target:{0},code:{1},ip:{2}", target, code, ip));
}
} else {
/**
* 邮件
*/
emailSendService.sendEmail(target, title, content);
log.info(MessageFormat.format("email--target:{0},code:{1},ip:{2}", target, code, ip));
}
this.identifyingCodeTimeWindowService.putAuthCode(target, code);
System.out.println("获取验证码:" + target + "---" + code);
CodeLog codeLog = new CodeLog();
codeLog.setTarget(target);
codeLog.setLog("发送地址:" + target + ",验证码:" + code + ",ip地址" + ip);
codeLog.setCreateTime(new Date());
codeLogService.saveSync(codeLog);
}
/**
* 返回true:ip已被封 falseip正常
*
* @param ip
* @return
*/
private boolean chcekIp(String ip) {
String check_send_count = sysparaService.find("send_code_check_ip").getValue();
if (!"true".equals(check_send_count))
return false;// 不为1时 未开启直接返回false不做处理
if (blacklistIpTimeWindow.getBlackIp(ip) != null)
return true;// ip被封不发送
if (sendCountTimeWindow.getIpSend(ip) != null) {
Integer count = ipCache.get(ip);
count++;
if (count >= 30) {// 从ip发送第一条开始
blacklistIpTimeWindow.putBlackIp(ip, ip);
ipCache.remove(ip);
sendCountTimeWindow.delIpSend(ip);
return true;
} else {
ipCache.put(ip, count++);
}
} else {
ipCache.put(ip, 1);
sendCountTimeWindow.putIpSend(ip, ip);
}
return false;
}
public void setSmsSendService(SmsSendService smsSendService) {
this.smsSendService = smsSendService;
}
public void setEmailSendService(EmailSendService emailSendService) {
this.emailSendService = emailSendService;
}
// public void setIdentifyingCodeTimeWindow(IdentifyingCodeTimeWindow identifyingCodeTimeWindow) {
// this.identifyingCodeTimeWindow = identifyingCodeTimeWindow;
// }
public void setSysparaService(SysparaService sysparaService) {
this.sysparaService = sysparaService;
}
public void setSendCountTimeWindow(SendCountTimeWindow sendCountTimeWindow) {
this.sendCountTimeWindow = sendCountTimeWindow;
}
public void setBlacklistIpTimeWindow(BlacklistIpTimeWindow blacklistIpTimeWindow) {
this.blacklistIpTimeWindow = blacklistIpTimeWindow;
}
public void setIdentifyingCodeTimeWindowService(IdentifyingCodeTimeWindowService identifyingCodeTimeWindowService) {
this.identifyingCodeTimeWindowService = identifyingCodeTimeWindowService;
}
public void setCodeLogService(CodeLogService codeLogService) {
this.codeLogService = codeLogService;
}
}

View File

@@ -0,0 +1,265 @@
package project.user.internal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
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 org.springframework.security.providers.encoding.PasswordEncoder;
import kernel.exception.BusinessException;
import kernel.util.StringUtils;
import kernel.web.Page;
import kernel.web.PagedQueryDao;
import project.party.PartyService;
import project.party.model.Party;
import project.party.recom.UserRecomService;
import project.tip.TipService;
import project.user.AdminUserSafewordApplyService;
import project.user.UserSafewordApply;
import project.user.UserSafewordApplyService;
import project.user.kyc.Kyc;
import project.user.kyc.KycService;
import security.SecUser;
import security.internal.SecUserService;
public class AdminUserSafewordApplyServiceImpl extends HibernateDaoSupport implements AdminUserSafewordApplyService {
protected PagedQueryDao pagedQueryDao;
protected PartyService partyService;
protected UserRecomService userRecomService;
protected KycService kycService;
protected UserSafewordApplyService userSafewordApplyService;
private PasswordEncoder passwordEncoder;
private SecUserService secUserService;
private TipService tipService;
@Override
public Page pagedQuery(int pageNo, int pageSize, String name_para, Integer status_para, String rolename_para,
String checkedPartyId, Integer operate) {
StringBuffer queryString = new StringBuffer();
queryString.append("SELECT ");
queryString.append(
" party.UUID partyId, party.USERCODE usercode, party.USERNAME username, party.ROLENAME rolename, party.USER_LEVEL user_level, ");
queryString.append(
" kyc.UUID kyc_id, kyc.IDNAME kyc_idname, kyc.NAME kyc_name, kyc.IDIMG_1 kyc_idimg_1, kyc.IDIMG_2 kyc_idimg_2, "
+ " kyc.IDIMG_3 kyc_idimg_3, kyc.STATUS kyc_status, ");
queryString.append(
" apply.UUID id, apply.IDCARD_PATH_FRONT idimg_1, apply.IDCARD_PATH_BACK idimg_2, apply.IDCARD_PATH_HOLD idimg_3, "
+ " apply.MSG msg, apply.STATUS status, apply.CREATE_TIME create_time, apply.OPERATE operate, apply.REMARK remark ");
queryString.append(" FROM T_USER_SAFEWORD_APPLY apply ");
queryString.append(" LEFT JOIN T_KYC kyc ON kyc.PARTY_ID = apply.PARTY_ID ");
queryString.append(" LEFT JOIN PAT_PARTY party ON kyc.PARTY_ID = party.UUID ");
queryString.append(" WHERE 1=1 ");
Map<String, Object> parameters = new HashMap<String, Object>();
if (!StringUtils.isNullOrEmpty(checkedPartyId)) {
List<String> checked_list = this.userRecomService.findChildren(checkedPartyId);
checked_list.add(checkedPartyId);
if (checked_list.size() == 0) {
return Page.EMPTY_PAGE;
}
queryString.append(" AND party.UUID in(:checked_list) ");
parameters.put("checked_list", checked_list);
}
if (status_para != null) {
queryString.append(" AND apply.STATUS = :status_para ");
parameters.put("status_para", status_para);
}
if (!StringUtils.isNullOrEmpty(rolename_para)) {
queryString.append(" AND party.ROLENAME =:rolename ");
parameters.put("rolename", rolename_para);
}
if (!StringUtils.isNullOrEmpty(name_para)) {
queryString.append(" AND ( party.USERNAME like:username OR party.USERCODE like:username ) ");
parameters.put("username", "%" + name_para + "%");
}
if (operate != null) {
queryString.append(" AND apply.OPERATE =:operate ");
parameters.put("operate", operate);
}
queryString.append(" order by apply.CREATE_TIME desc ");
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
return page;
}
@Override
public void savePassed(String id, String operatorUsername, String safeword) {
UserSafewordApply apply = this.userSafewordApplyService.findById(id);
if (null == apply) {
throw new BusinessException("申请不存在,或请刷新重试");
}
if (apply.getStatus() != 1) {
throw new BusinessException("当前申请已处理");
}
if (!Arrays.asList(0, 1, 2, 3).contains(apply.getOperate())) {
throw new BusinessException("操作类型不正确");
}
this.checkLoginSafeword(operatorUsername, safeword);
Kyc kyc = this.kycService.get(apply.getPartyId().toString());
if (null == kyc || kyc.getStatus() != 2) {
throw new BusinessException("认证尚未通过,无法重置");
}
apply.setApply_time(new Date());
apply.setStatus(2);
this.userSafewordApplyService.update(apply);
Party party = this.partyService.cachePartyBy(apply.getPartyId(), false);
// 操作类型 operate: 0/修改资金密码1/取消谷歌绑定2/取消手机绑定3/取消邮箱绑定;
switch (apply.getOperate()) {
case 0:
party.setSafeword(apply.getSafeword());
this.partyService.update(party);
break;
case 1:
SecUser secUser = this.secUserService.findUserByLoginName(party.getUsername());
if (null == secUser) {
throw new BusinessException("用户不存在");
}
if (!secUser.isGoogle_auth_bind()) {
throw new BusinessException("用户未绑定,无需解绑");
}
secUser.setGoogle_auth_bind(false);
this.secUserService.update(secUser);
break;
case 2:
party.setPhone_authority(false);
this.partyService.update(party);
break;
case 3:
party.setEmail_authority(false);
this.partyService.update(party);
break;
}
this.tipService.deleteTip(apply.getId().toString());
}
@Override
public void saveFailed(String id, String msg) {
UserSafewordApply apply = this.userSafewordApplyService.findById(id);
if (null == apply) {
throw new BusinessException("申请不存在,或请刷新重试");
}
if (apply.getStatus() != 1) {
throw new BusinessException("当前申请已处理");
}
Kyc kyc = this.kycService.get(apply.getPartyId().toString());
if (null == kyc || kyc.getStatus() != 2) {
throw new BusinessException("认证尚未通过,无法重置");
}
apply.setApply_time(new Date());
apply.setStatus(3);
apply.setMsg(msg);
this.userSafewordApplyService.update(apply);
this.tipService.deleteTip(apply.getId().toString());
}
/**
* 某个时间后未处理数量,没有时间则全部
*
* @param time
* @return
*/
public Long getUntreatedCount(Date time, String loginPartyId) {
StringBuffer queryString = new StringBuffer();
queryString.append("SELECT COUNT(*) FROM UserSafewordApply WHERE status in(1) ");
List<Object> para = new ArrayList<Object>();
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
String childrensIds = this.userRecomService.findChildrensIds(loginPartyId);
if (StringUtils.isEmptyString(childrensIds)) {
return 0L;
}
queryString.append(" and partyId in (" + childrensIds + ") ");
}
if (null != time) {
queryString.append("AND apply_time > ?0");
para.add(time);
}
List find = this.getHibernateTemplate().find(queryString.toString(), para.toArray());
return CollectionUtils.isEmpty(find) ? 0L : find.get(0) == null ? 0L : Long.valueOf(find.get(0).toString());
}
/**
* 验证登录人资金密码
*
* @param operatorUsername
* @param loginSafeword
*/
private void checkLoginSafeword(String operatorUsername, String loginSafeword) {
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
String sysSafeword = sec.getSafeword();
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
if (!safeword_md5.equals(sysSafeword)) {
throw new BusinessException("登录人资金密码错误");
}
}
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
this.pagedQueryDao = pagedQueryDao;
}
public void setPartyService(PartyService partyService) {
this.partyService = partyService;
}
public void setUserRecomService(UserRecomService userRecomService) {
this.userRecomService = userRecomService;
}
public void setKycService(KycService kycService) {
this.kycService = kycService;
}
public void setUserSafewordApplyService(UserSafewordApplyService userSafewordApplyService) {
this.userSafewordApplyService = userSafewordApplyService;
}
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
public void setSecUserService(SecUserService secUserService) {
this.secUserService = secUserService;
}
public void setTipService(TipService tipService) {
this.tipService = tipService;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,53 @@
package project.user.internal;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import cn.hutool.core.util.StrUtil;
import project.redis.RedisHandler;
import project.user.UserRedisKeys;
public class OnlineUserService {
private RedisHandler redisHandler;
public Date get(String partyId) {
return (Date) redisHandler.get(UserRedisKeys.ONLINEUSER_PARTYID + partyId);
}
public List<String> getAll() {
Map<String, Date> map = (Map<String, Date>) redisHandler.get(UserRedisKeys.ONLINEUSER);
if (map != null && !map.isEmpty()) {
return new ArrayList<String>(map.keySet());
}
return new ArrayList<String>();
}
public void put(String partyId, Date date) {
redisHandler.setSync(UserRedisKeys.ONLINEUSER_PARTYID + partyId, date);
Map<String, Date> map = (Map<String, Date>) redisHandler.get(UserRedisKeys.ONLINEUSER);
if (map == null) {
map = new ConcurrentHashMap<String, Date>();
}
map.put(partyId, date);
redisHandler.setSync(UserRedisKeys.ONLINEUSER, map);
}
public void del(String partyId) {
if (StrUtil.isBlank(partyId) || Objects.equals(partyId, "0")) {
return;
}
redisHandler.remove(UserRedisKeys.ONLINEUSER_PARTYID + partyId);
Map<String, Date> map = (Map<String, Date>) redisHandler.get(UserRedisKeys.ONLINEUSER);
if (map != null && !map.isEmpty()) {
map.remove(partyId);
redisHandler.setSync(UserRedisKeys.ONLINEUSER, map);
}
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
}

View File

@@ -0,0 +1,184 @@
package project.user.internal;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import kernel.http.HttpHelper;
import kernel.util.ImageUtils;
import project.Constants;
import project.syspara.SysparaService;
import project.user.QRGenerateService;
public class QRGenerateServiceImpl implements QRGenerateService {
private SysparaService sysparaService;
@Override
public String generate(String content) {
String image_name = "/qr/" + content + ".png";
content = Constants.WEB_URL + "/register.html?usercode=" + content;
boolean openButton = sysparaService.find("short_url_open_button").getBoolean() ;
if(openButton) {
content = sysparaService.find("agent_qr_url").getValue() + "/register.html?usercode=" + content;
boolean isCn = sysparaService.find("short_url_cn_button").getBoolean() ;
if(isCn) {
content = shortUrlCn(content);
}else {
content = shortUrl(content);
}
}
String filepath = Constants.IMAGES_DIR + image_name;
File file = new File(filepath);
int width = 260;
int height = 260;
String format = "png";
Map hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
try {
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
} catch (Exception e) {
e.printStackTrace();
}
return image_name;
}
public String shortUrl(String longUrl) {
String url = "https://cutt.ly/scripts/shortenUrl.php";
Map<String,Object> param = new HashMap<>();
param.put("url",longUrl);
String s = HttpHelper.sendPostHttp(url, param, false);
return s;
}
public String shortUrlCn(String longUrl) {
String url = "https://www.xyixy.com/api/";
Map<String,Object> param = new HashMap<>();
param.put("url",longUrl);
param.put("key",sysparaService.find("cn_short_url_key").getValue());
String s = HttpHelper.sendGetHttp(url, param);
return s;
}
public String generate(String content,String imgName) {
String image_uri = "/qr/" + imgName + ".png";
String filepath = Constants.IMAGES_DIR + image_uri;
File file = new File(filepath);
// if(file.exists()) {//存在则删了重新建,保证内容最新,不删除则内容不会覆盖
// file.delete();
// file = new File(filepath);
// }
int width = 260;
int height = 260;
String format = "png";
Map hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
try {
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
} catch (Exception e) {
e.printStackTrace();
}
return image_uri;
}
@Override
public String generate185(String content) {
String image_name = "/qr/" + content + "2.png";
content = Constants.WEB_URL + "/register.html?usercode=" + content;
// String image_name = "/qr/" + UUIDGenerator.getUUID() + ".png";
String filepath = Constants.IMAGES_DIR + image_name;
File file = new File(filepath);
int width = 185;
int height = 185;
String format = "png";
Map hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 1);// 二维码空白区域,最小为0也有白边,只是很小,最小是6像素左右
try {
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
} catch (Exception e) {
e.printStackTrace();
}
return image_name;
}
public void generate_poster(String image_name, String usercode) {
String backgroundPath = "";
String smallPath = Constants.IMAGES_DIR + image_name;
String resultPaht = "";
for (int i = 0; i < 5; i++) {
backgroundPath = Constants.IMAGES_DIR + "/poster/poster_" + i + "_zh-CN.png";
resultPaht = Constants.IMAGES_DIR + "/qr/" + usercode + "_poster_" + i + "_zh-CN.png";
ImageUtils.image_usercode(backgroundPath, smallPath, "png", resultPaht);
}
for (int i = 0; i < 5; i++) {
backgroundPath = Constants.IMAGES_DIR + "/poster/poster_" + i + "_CN.png";
resultPaht = Constants.IMAGES_DIR + "/qr/" + usercode + "_poster_" + i + "_CN.png";
ImageUtils.image_usercode(backgroundPath, smallPath, "png", resultPaht);
}
for (int i = 0; i < 5; i++) {
backgroundPath = Constants.IMAGES_DIR + "/poster/poster_" + i + "_en.png";
resultPaht = Constants.IMAGES_DIR + "/qr/" + usercode + "_poster_" + i + "_en.png";
ImageUtils.image_usercode(backgroundPath, smallPath, "png", resultPaht);
}
}
@Override
public String generateWithdraw(String content, String address) {
String image_name = "/qr/" + content + ".png";
String filepath = Constants.IMAGES_DIR + image_name;
File file = new File(filepath);
int width = 260;
int height = 260;
String format = "png";
Map hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
try {
BitMatrix bitMatrix = new MultiFormatWriter().encode(address, BarcodeFormat.QR_CODE, width, height, hints);
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
} catch (Exception e) {
e.printStackTrace();
}
return image_name;
}
public List<Map<String, String>> generate_poster_base64(String image_name, String usercode, String img_language) {
List<Map<String, String>> list_image = new ArrayList<Map<String, String>>();
String backgroundPath = "";
String smallPath = Constants.IMAGES_DIR + image_name;
String resultPaht = "";
for (int i = 0; i < 5; i++) {
backgroundPath = Constants.IMAGES_DIR + "/poster/poster_" + i + "_" + img_language + ".png";
resultPaht = usercode + "_poster_" + i + "_" + img_language;
Map<String, String> map_image = new HashMap<String, String>();
map_image.put(resultPaht, ImageUtils.image_usercodeBase64(backgroundPath, smallPath, "png", resultPaht));
list_image.add(map_image);
}
return list_image;
}
public void setSysparaService(SysparaService sysparaService) {
this.sysparaService = sysparaService;
}
}

View File

@@ -0,0 +1,39 @@
package project.user.internal;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import kernel.util.UUIDGenerator;
import project.Constants;
import project.blockchain.QRProducerService;
public class QRProducerServiceImpl implements QRProducerService {
@Override
public String generate(String content) {
String image_name = "/qr/" + UUIDGenerator.getUUID() + ".png";
String filepath = Constants.IMAGES_DIR + image_name;
File file = new File(filepath);
int width = 691;
int height = 691;
String format = "png";
Map hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
try {
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
} catch (Exception e) {
e.printStackTrace();
}
return image_name;
}
}

View File

@@ -0,0 +1,204 @@
package project.user.internal;
import java.util.Arrays;
import java.util.Date;
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 org.springframework.security.providers.encoding.PasswordEncoder;
import kernel.exception.BusinessException;
import kernel.util.DateUtils;
import kernel.util.StringUtils;
import project.Constants;
import project.tip.TipConstants;
import project.tip.TipService;
import project.user.UserSafewordApply;
import project.user.UserSafewordApplyService;
import project.user.kyc.Kyc;
import project.user.kyc.KycService;
import security.SaltSigureUtils;
import util.Strings;
public class UserSafewordApplyServiceImpl extends HibernateDaoSupport implements UserSafewordApplyService {
private PasswordEncoder passwordEncoder;
private KycService kycService;
private TipService tipService;
public void save(UserSafewordApply entity) {
this.getHibernateTemplate().save(entity);
}
public void update(UserSafewordApply entity) {
getHibernateTemplate().update(entity);
}
public void delete(String id) {
UserSafewordApply entity = findById(id);
getHibernateTemplate().delete(entity);
}
public UserSafewordApply findById(String id) {
return (UserSafewordApply) getHibernateTemplate().get(UserSafewordApply.class, id);
}
public List<UserSafewordApply> findByPartyId(String partyId) {
List<UserSafewordApply> list = (List<UserSafewordApply>) getHibernateTemplate()
.find(" FROM UserSafewordApply WHERE partyId=?0 order by create_time desc", new Object[] { partyId });
return list;
}
/**
* 尚未通过的申请
*/
public UserSafewordApply findByPartyIdNoPass(String partyId, Integer operate) {
List<UserSafewordApply> list = (List<UserSafewordApply>) getHibernateTemplate().find(
" FROM UserSafewordApply WHERE partyId=?0 AND operate=?1 AND status!=2 order by create_time desc",
new Object[] { partyId, operate });
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
/**
* 人工重置 操作类型 operate: 0/修改资金密码1/取消谷歌绑定2/取消手机绑定3/取消邮箱绑定;
*/
public void saveApply(String partyId, String idcard_path_front, String idcard_path_back, String idcard_path_hold, String safeword,
String safeword_confirm, Integer operate, String remark) {
if (null == operate || !Arrays.asList(0, 1, 2, 3).contains(operate)) {
throw new BusinessException("操作类型不正确");
}
// 操作类型 operate: 0/修改资金密码;
if (0 == operate.intValue()) {
if (StringUtils.isEmptyString(safeword)) {
throw new BusinessException("资金密码不能为空");
}
if (safeword.length() != 6 || !Strings.isNumber(safeword)) {
throw new BusinessException("资金密码不符合设定");
}
if (StringUtils.isEmptyString(safeword_confirm)) {
throw new BusinessException("资金密码确认不能为空");
}
if (!safeword.equals(safeword_confirm)) {
throw new BusinessException("两次输入的资金密码不相同");
}
}
// if (StringUtils.isEmptyString(idcard_path_front)) {
// throw new BusinessException("请上传证件照正面");
// }
//
// if (StringUtils.isEmptyString(idcard_path_back)) {
// throw new BusinessException("请上传证件照反面");
// }
//
// if (StringUtils.isEmptyString(idcard_path_hold)) {
// throw new BusinessException("请上传手持证件照");
// }
// // 操作类型 operate: 0/修改资金密码;
// if (0 == operate.intValue()) {
Kyc kyc = this.kycService.get(partyId);
if (null == kyc || kyc.getStatus() != 2) {
throw new BusinessException(401, "实名认证尚未通过,无法重置");
}
// }
UserSafewordApply apply = this.findByPartyIdNoPass(partyId, operate);
if (null == apply) {
apply = new UserSafewordApply();
apply.setCreate_time(new Date());
} else if (apply.getStatus() != 3) {
throw new BusinessException("您的申请之前已提交过");
}
// 操作类型 operate: 0/修改资金密码;
if (0 == operate.intValue()) {
String safewordMd5 = this.passwordEncoder.encodePassword(safeword, SaltSigureUtils.saltfigure);
apply.setSafeword(safewordMd5);
} else {
apply.setSafeword("");
}
apply.setIdcard_path_front(idcard_path_front);
apply.setIdcard_path_back(idcard_path_back);
apply.setIdcard_path_hold(idcard_path_hold);
apply.setOperate(operate);
apply.setRemark(remark);
apply.setPartyId(partyId);
apply.setStatus(1);
if (null == apply.getId()) {
this.save(apply);
} else {
this.update(apply);
}
this.tipService.saveTip(apply.getId().toString(), TipConstants.USER_SAFEWORD_APPLY);
}
public Map<String, Object> bindOne(UserSafewordApply apply) {
Map<String, Object> result = new HashMap<String, Object>();
String idcard_path_front_path = "";
String idcard_path_back_path = "";
String idcard_path_hold_path = "";
if (!StringUtils.isNullOrEmpty(apply.getIdcard_path_front())) {
idcard_path_front_path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath="
+ apply.getIdcard_path_front();
}
result.put("idcard_path_front", apply.getIdcard_path_front());
result.put("idcard_path_front_path", idcard_path_front_path);
if (!StringUtils.isNullOrEmpty(apply.getIdcard_path_back())) {
idcard_path_back_path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath="
+ apply.getIdcard_path_back();
}
result.put("idcard_path_back", apply.getIdcard_path_back());
result.put("idcard_path_back_path", idcard_path_back_path);
if (!StringUtils.isNullOrEmpty(apply.getIdcard_path_hold())) {
idcard_path_hold_path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath="
+ apply.getIdcard_path_hold();
} else {
idcard_path_hold_path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=qr/id_img3.jpg";
}
result.put("idcard_path_hold", apply.getIdcard_path_hold());
result.put("idcard_path_hold_path", idcard_path_hold_path);
result.put("id", apply.getId());
result.put("create_time", DateUtils.format(apply.getCreate_time(), DateUtils.DF_yyyyMMddHHmmss));
result.put("msg", apply.getMsg());
result.put("apply_time", DateUtils.format(apply.getApply_time(), DateUtils.DF_yyyyMMddHHmmss));
result.put("status", apply.getStatus());
result.put("operate", apply.getOperate());
result.put("remark", apply.getRemark());
return result;
}
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
public void setKycService(KycService kycService) {
this.kycService = kycService;
}
public void setTipService(TipService tipService) {
this.tipService = tipService;
}
}

View File

@@ -0,0 +1,367 @@
package project.user.internal;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.providers.encoding.PasswordEncoder;
import kernel.exception.BusinessException;
import kernel.util.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import project.Constants;
import project.event.message.LogoffAccountEvent;
import project.event.model.LogoffAccountInfo;
import project.event.model.UserChangeInfo;
import project.log.Log;
import project.log.LogService;
import project.mall.goods.SellerGoodsService;
import project.mall.seller.FocusSellerService;
import project.mall.seller.SellerService;
import project.mall.seller.model.Seller;
import project.party.PartyRedisKeys;
import project.party.PartyService;
import project.party.model.Party;
import project.redis.RedisHandler;
import project.user.UserRedisKeys;
import project.user.UserService;
import project.user.idcode.IdentifyingCodeTimeWindowService;
import project.user.token.TokenService;
import project.withdraw.Withdraw;
import security.Role;
import security.SecUser;
import security.internal.SecUserService;
import javax.annotation.Resource;
@Slf4j
public class UserServiceImpl implements UserService {
private SecUserService secUserService;
private IdentifyingCodeTimeWindowService identifyingCodeTimeWindowService;
private PasswordEncoder passwordEncoder;
private PartyService partyService;
private OnlineUserService onlineUserService;
private RedisHandler redisHandler;
private SellerService sellerService;
private TokenService tokenService;
private FocusSellerService focusSellerService;
private SellerGoodsService sellerGoodsService;
private LogService logService;
/**
* 图片验证key保证前后一致性
*/
private Map<String, String> imageCodeCache = new ConcurrentHashMap<String, String>();
@Override
public SecUser addLogin(String username, String password) {
SecUser user = secUserService.findUserByLoginName(username);
if (user == null) {
throw new BusinessException("用户不存在");
}
Party party = partyService.cachePartyBy(user.getPartyId(), false);
String[] rolesArrty = new String[] { Constants.SECURITY_ROLE_GUEST, Constants.SECURITY_ROLE_MEMBER, Constants.SECURITY_ROLE_TEST };
if (party == null || !party.getLogin_authority()) {
throw new BusinessException("登录失败");
}
Set<Role> roles = user.getRoles();
boolean find = false;
for (Iterator iterator = roles.iterator(); iterator.hasNext();) {
Role role = (Role) iterator.next();
for (int i = 0; i < rolesArrty.length; i++) {
if (role.getRoleName().equals(rolesArrty[i])) {
find = true;
}
}
}
if (!find) {
throw new BusinessException("登录失败");
}
String password_encoder = passwordEncoder.encodePassword(password, user.getUsername());
if (!password_encoder.equals(user.getPassword())) {
throw new BusinessException("密码不正确");
}
party.setLast_loginTime(new Date());
partyService.update(party);
return user;
}
/**
* 验证码登录
*/
@Override
public SecUser addLogin_idcode(String username, String verifcode) {
SecUser user = secUserService.findUserByLoginName(username);
if (user == null) {
throw new BusinessException("用户名不存在");
}
Party party = partyService.cachePartyBy(user.getPartyId(), false);
String[] rolesArrty = new String[] {};
if (party == null || !party.getLogin_authority()) {
throw new BusinessException("登录失败");
}
Set<Role> roles = user.getRoles();
boolean find = false;
for (Iterator iterator = roles.iterator(); iterator.hasNext();) {
Role role = (Role) iterator.next();
for (int i = 0; i < rolesArrty.length; i++) {
if (role.getRoleName().equals(rolesArrty[i])) {
find = true;
}
}
}
if (!find) {
throw new BusinessException("登录失败");
}
String authcode = this.identifyingCodeTimeWindowService.getAuthCode(username);
if ((authcode == null) || (!authcode.equals(verifcode))) {
throw new BusinessException("登录失败");
}
this.identifyingCodeTimeWindowService.delAuthCode(username);
return user;
}
@Override
public void online(String partyId) {
if (StringUtils.isNullOrEmpty(partyId)) {
return;
}
// 登录时候默认设置在线状态为在线1(离开2离线3)
Map<String, Object> statusParams = new ConcurrentHashMap<String, Object>();
statusParams.put("status",1);
statusParams.put("operateTime",new Date());
redisHandler.setSync(UserRedisKeys.ONLINE_USER_STATUS_PARTYID+partyId,statusParams);
onlineUserService.put(partyId, new Date());
}
@Override
public void offline(String partyId) {
if (StringUtils.isNullOrEmpty(partyId)) {
return;
}
// 将在线标识给移除
onlineUserService.del(partyId);
// 移除token设置重新登录
tokenService.removeLoginToken(partyId);
}
@Override
public void logout(String partyId) {
if (StringUtils.isNullOrEmpty(partyId)) {
return;
}
onlineUserService.del(partyId);
}
public void updateSyncUserInfo(UserChangeInfo changeInfo) {
if (StrUtil.isBlank(changeInfo.getPartyId()) || Objects.equals(changeInfo.getPartyId(), "0")) {
return;
}
SecUser user = secUserService.findUserByPartyId(changeInfo.getPartyId());
if (user == null) {
log.error("syncUserInfo 服务发现 partyId:" + changeInfo.getPartyId() + ", 对应的 user 记录不存在!");
return;
}
boolean changed = false;
String oldUserName = changeInfo.getOldUserName();
String newUserName = changeInfo.getNewUserName();
if (oldUserName == null) {
oldUserName = "";
}
if (newUserName == null) {
newUserName = "";
}
if (!oldUserName.equals(newUserName)) {
// 用户账号发生了改变
if (StrUtil.isBlank(newUserName)) {
throw new BusinessException("错误的参数");
}
if (StrUtil.isBlank(changeInfo.getPassword())) {
throw new BusinessException("未提交密码,修改失败");
}
user.setUsername(newUserName);
// 密文密码也需要更新
String password_encoder = passwordEncoder.encodePassword(changeInfo.getPassword(), newUserName);
user.setPassword(password_encoder);
changed = true;
}
String oldEmail = changeInfo.getOldEmail();
String newEmail = changeInfo.getNewEmail();
if (oldEmail == null) {
oldEmail = "";
}
if (newEmail == null) {
newEmail = "";
}
if (!oldEmail.equals(newEmail)) {
// 用户邮箱发生了改变
user.setEmail(newEmail);
changed = true;
}
if (changed) {
secUserService.update(user);
//更新密码以后记录 操作日志
Log log = new project.log.Log();
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
log.setUsername(user.getUsername());
log.setPartyId(user.getPartyId());
log.setLog("用户[" + user.getUsername()+ "]账号修改,修改前账号名为["+oldUserName+"]");
this.logService.saveSync(log);
}
}
@Override
@Transactional
public void updateLogoffAccount(String partyId, String reason) {
SecUser userEntity = secUserService.findUserByPartyId(partyId);
Party party = partyService.getById(partyId);
String logoffSufix = ":off:" + (System.currentTimeMillis() / 1000L);
String oriAccount = userEntity.getUsername();
String newAccount = oriAccount + logoffSufix;
if (newAccount.length() > 64) {
newAccount = newAccount.substring(0, 64);
}
String newEmail = party.getEmail();
if (StrUtil.isNotBlank(newEmail)) {
newEmail = newEmail + ":off";
if (newEmail.length() > 64) {
newEmail = "";
}
}
String newPhone = party.getPhone();
if (StrUtil.isNotBlank(newPhone)) {
newPhone = newPhone + ":off";
}
//
userEntity.setUsername(newAccount);
userEntity.setEnabled(false);
userEntity.setEmail(newEmail);
userEntity.setRemarks(reason);
secUserService.update(userEntity);
party.setUsername(newAccount);
party.setPhone(newPhone);
party.setEmail(newEmail);
party.setEnabled(false);
partyService.update(party);
// 清掉缓存,可用于支持手动改数据库记录恢复账号
redisHandler.remove(PartyRedisKeys.PARTY_ID + party.getId());
redisHandler.remove(PartyRedisKeys.PARTY_USERNAME + party.getUsername());
redisHandler.remove(PartyRedisKeys.PARTY_USERNAME + oriAccount);
Seller seller = sellerService.getSeller(party.getId().toString());
if (seller != null) {
seller.setStatus(0);
seller.setName(seller.getName() + logoffSufix);
sellerService.updateSeller(seller);
// 删掉所有关注的商铺
focusSellerService.deleteAllFocus(seller.getId().toString());
// 标记其下所有店铺商品状态
sellerGoodsService.deleteAllSellerGoods(seller.getId().toString());
}
// 发布事件,可能其他业务也需要修改相关的字段
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
LogoffAccountInfo info = new LogoffAccountInfo();
info.setPartyId(partyId);
info.setOriAccount(oriAccount);
info.setNewAccount(newAccount);
wac.publishEvent(new LogoffAccountEvent(this, info));
}
public void setSecUserService(SecUserService secUserService) {
this.secUserService = secUserService;
}
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
public void setPartyService(PartyService partyService) {
this.partyService = partyService;
}
public Map<String, String> getImageCodeCache() {
return imageCodeCache;
}
public void putImageCode(String key, String value) {
imageCodeCache.put(key, value);
}
public String cacheImageCode(String key) {
return imageCodeCache.get(key);
}
public void cacheRemoveImageCode(String key) {
imageCodeCache.remove(key);
}
public void setTokenService(TokenService tokenService) {
this.tokenService = tokenService;
}
public void putRandKey(String key, String value) {
imageCodeCache.put(key, value);
}
public IdentifyingCodeTimeWindowService getIdentifyingCodeTimeWindowService() {
return identifyingCodeTimeWindowService;
}
public void setIdentifyingCodeTimeWindowService(IdentifyingCodeTimeWindowService identifyingCodeTimeWindowService) {
this.identifyingCodeTimeWindowService = identifyingCodeTimeWindowService;
}
public void setOnlineUserService(OnlineUserService onlineUserService) {
this.onlineUserService = onlineUserService;
}
public void setSellerService(SellerService sellerService) {
this.sellerService = sellerService;
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
public void setFocusSellerService(FocusSellerService focusSellerService) {
this.focusSellerService = focusSellerService;
}
public void setSellerGoodsService(SellerGoodsService sellerGoodsService) {
this.sellerGoodsService = sellerGoodsService;
}
public void setLogService(LogService logService) {
this.logService = logService;
}
}

View File

@@ -0,0 +1,24 @@
package project.user.kyc;
import java.io.Serializable;
import java.util.Date;
import kernel.web.Page;
public interface AdminKycHighLevelService {
public Page pagedQuery(int pageNo, int pageSize, String name_para, Integer status_para,String rolename_para, String checkedPartyId);
public KycHighLevel findByPartyId(Serializable partyId);
public KycHighLevel findById(Serializable id);
public void savePassed(String partyId);
public void saveFailed(String partyId, String msg);
/**
* 某个时间后未处理数量,没有时间则全部
* @param time
* @return
*/
public Long getUntreatedCount(Date time, String loginPartyId);
}

View File

@@ -0,0 +1,37 @@
package project.user.kyc;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import kernel.web.Page;
public interface AdminKycService {
public Page pagedQuery(int pageNo, int pageSize, String name_para, String status_para,String rolename_para, String checkedPartyId,
String idnumber_para,String email_para,String startTime, String endTime,String sellerName, String username_parent);
public Kyc find(Serializable partyId);
public void savePassed(String partyId);
public void saveFailed(String partyId, String msg);
public void saveFaileds(String partyId, String msg);
public void saveKycPic(String partyId, String imgId, String img);
/**
* 某个时间后未处理数量,没有时间则全部
* @param time
* @return
*/
public Long getUntreatedCount(Date time, String loginPartyId);
/**
* 查询今日新增商铺
* @return
*/
Map findKycSumData();
void updateRemarks(String partyId, String remarks);
}

View File

@@ -0,0 +1,90 @@
<?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.user.kyc.Kyc" table="T_KYC">
<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="idnumber" type="java.lang.String">
<column name="IDNUMBER" />
</property>
<property name="idname" type="java.lang.String">
<column name="IDNAME" />
</property>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<property name="idimg_1" type="java.lang.String">
<column name="IDIMG_1" />
</property>
<property name="idimg_2" type="java.lang.String">
<column name="IDIMG_2" />
</property>
<property name="idimg_3" type="java.lang.String">
<column name="IDIMG_3" />
</property>
<property name="status" type="int">
<column name="STATUS" />
</property>
<property name="msg" type="java.lang.String">
<column name="MSG" />
</property>
<property name="nationality" type="java.lang.String">
<column name="NATIONALITY" />
</property>
<property name="apply_time" type="timestamp">
<column name="APPLY_TIME" />
</property>
<property name="operation_time" type="timestamp">
<column name="OPERATION_TIME" />
</property>
<property name="sex" type="java.lang.String">
<column name="SEX" />
</property>
<property name="borth_date" type="java.lang.String">
<column name="BORTH_DATE" />
</property>
<property name="sellerName" type="java.lang.String">
<column name="SELLER_NAME" />
</property>
<property name="sellerImg" type="java.lang.String">
<column name="SELLER_IMG" />
</property>
<property name="sellerAddress" type="java.lang.String">
<column name="SELLER_ADDRESS" />
</property>
<property name="invitationCode" type="java.lang.String">
<column name="INVITATION_CODE" />
</property>
<property name="signPdfUrl" type="java.lang.String">
<column name="SIGN_PDF_URL" />
</property>
<property name="remark" type="java.lang.String">
<column name="REMARK" />
</property>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,302 @@
package project.user.kyc;
import java.io.Serializable;
import java.util.Date;
import kernel.bo.EntityObject;
/**
*
* 实名认证
*/
public class Kyc extends EntityObject {
private static final long serialVersionUID = 7664064141060377449L;
private Serializable partyId;
/**
* ID名称如身份证等
*/
private String idname;
/**
* 证件号码
*/
private String idnumber;
/**
* 实名姓名
*/
private String name;
/**
* 证件正面照
*/
private String idimg_1;
/**
* 证件背面照
*/
private String idimg_2;
/**
* 正面手持证件照
*/
private String idimg_3;
/**
* 证件正面照文件名
*/
private String idimg_1_path;
/**
* 证件背面照文件名
*/
private String idimg_2_path;
/**
* 手持正面证件照文件名
*/
private String idimg_3_path;
/**
* 手持证件
*/
// private String idimg_3;
/**
* 0已申请未审核 1审核中 2 审核通过,3审核未通过
*/
private int status;
/**
* 审核消息,未通过原因
*
*/
private String msg;
/**
* 国籍
*/
private String nationality;
/**
* 提交时间
*/
private Date apply_time;
/**
* 审核时间
*/
private Date operation_time;
/**
* 性别man:男woman:女
*/
private String sex;
/**
* 出生日期
*/
private String borth_date;
/**
* 店铺名称
*/
private String sellerName;
/**
* 店铺log
*/
private String sellerImg;
/**
* 店铺地址
*/
private String sellerAddress;
/**
* 邀请码
*/
private String invitationCode;
/**
* 用户签名PDF地址
*/
private String signPdfUrl;
/**
* 备注
* @return
*/
private String remark;
public Serializable getPartyId() {
return partyId;
}
public void setPartyId(Serializable partyId) {
this.partyId = partyId;
}
public String getIdname() {
return idname;
}
public void setIdname(String idname) {
this.idname = idname;
}
public String getIdnumber() {
return idnumber;
}
public void setIdnumber(String idnumber) {
this.idnumber = idnumber;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIdimg_1() {
return idimg_1;
}
public void setIdimg_1(String idimg_1) {
this.idimg_1 = idimg_1;
}
public String getIdimg_2() {
return idimg_2;
}
public void setIdimg_2(String idimg_2) {
this.idimg_2 = idimg_2;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public Date getApply_time() {
return apply_time;
}
public void setApply_time(Date apply_time) {
this.apply_time = apply_time;
}
public String getIdimg_1_path() {
return idimg_1_path;
}
public void setIdimg_1_path(String idimg_1_path) {
this.idimg_1_path = idimg_1_path;
}
public String getIdimg_2_path() {
return idimg_2_path;
}
public void setIdimg_2_path(String idimg_2_path) {
this.idimg_2_path = idimg_2_path;
}
public String getIdimg_3() {
return idimg_3;
}
public void setIdimg_3(String idimg_3) {
this.idimg_3 = idimg_3;
}
public String getIdimg_3_path() {
return idimg_3_path;
}
public void setIdimg_3_path(String idimg_3_path) {
this.idimg_3_path = idimg_3_path;
}
public String getSex() {
return sex;
}
public String getBorth_date() {
return borth_date;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setBorth_date(String borth_date) {
this.borth_date = borth_date;
}
public Date getOperation_time() {
return operation_time;
}
public void setOperation_time(Date operation_time) {
this.operation_time = operation_time;
}
public String getSellerName() {
return sellerName;
}
public void setSellerName(String sellerName) {
this.sellerName = sellerName;
}
public String getSellerImg() {
return sellerImg;
}
public void setSellerImg(String sellerImg) {
this.sellerImg = sellerImg;
}
public String getSellerAddress() {
return sellerAddress;
}
public void setSellerAddress(String sellerAddress) {
this.sellerAddress = sellerAddress;
}
public String getInvitationCode() {
return invitationCode;
}
public void setInvitationCode(String invitationCode) {
this.invitationCode = invitationCode;
}
public String getSignPdfUrl() {
return signPdfUrl;
}
public void setSignPdfUrl(String signPdfUrl) {
this.signPdfUrl = signPdfUrl;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

View 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.user.kyc.KycHighLevel" table="T_KYC_HIGH_LEVEL">
<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="work_place" type="java.lang.String">
<column name="WORK_PLACE" />
</property>
<property name="home_place" type="java.lang.String">
<column name="HOME_PLACE" />
</property>
<property name="relatives_relation" type="java.lang.String">
<column name="RELATIVES_RELATION" />
</property>
<property name="relatives_name" type="java.lang.String">
<column name="RELATIVES_NAME" />
</property>
<property name="relatives_place" type="java.lang.String">
<column name="RELATIVES_PLACE" />
</property>
<property name="relatives_phone" type="java.lang.String">
<column name="RELATIVES_PHONE" />
</property>
<property name="status" type="int">
<column name="STATUS" />
</property>
<property name="msg" type="java.lang.String">
<column name="MSG" />
</property>
<property name="apply_time" type="timestamp">
<column name="APPLY_TIME" />
</property>
<property name="operation_time" type="timestamp">
<column name="OPERATION_TIME" />
</property>
<property name="idimg_1" type="java.lang.String">
<column name="IDIMG_1" />
</property>
<property name="idimg_2" type="java.lang.String">
<column name="IDIMG_2" />
</property>
<property name="idimg_3" type="java.lang.String">
<column name="IDIMG_3" />
</property>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,204 @@
package project.user.kyc;
import java.util.Date;
import kernel.bo.EntityObject;
public class KycHighLevel extends EntityObject{
/**
*
*/
private static final long serialVersionUID = 1820111372329385339L;
private String partyId;
/**
* 工作地址
*/
private String work_place;
/**
* 家庭地址
*/
private String home_place;
/**
* 亲属关系
*/
private String relatives_relation;
/**
* 亲属名称
*/
private String relatives_name;
/**
* 亲属地址
*/
private String relatives_place;
/**
* 亲属电话
*/
private String relatives_phone;
/**
* 0已申请未审核 1审核中 2 审核通过,3审核未通过
*/
private int status;
/**
* 审核消息,未通过原因
*
*/
private String msg;
/**
* 申请时间
*/
private Date apply_time;
/**
* 审核时间
*/
private Date operation_time;
private String name;
private String username;
/**
* 证件正面照
*/
private String idimg_1;
/**
* 证件背面照
*/
private String idimg_2;
/**
* 正面手持证件照
*/
private String idimg_3;
/**
* 证件正面照文件名
*/
private String idimg_1_path;
/**
* 证件背面照文件名
*/
private String idimg_2_path;
/**
* 手持正面证件照文件名
*/
private String idimg_3_path;
public String getPartyId() {
return partyId;
}
public void setPartyId(String partyId) {
this.partyId = partyId;
}
public String getWork_place() {
return work_place;
}
public void setWork_place(String work_place) {
this.work_place = work_place;
}
public String getHome_place() {
return home_place;
}
public void setHome_place(String home_place) {
this.home_place = home_place;
}
public String getRelatives_relation() {
return relatives_relation;
}
public void setRelatives_relation(String relatives_relation) {
this.relatives_relation = relatives_relation;
}
public String getRelatives_name() {
return relatives_name;
}
public void setRelatives_name(String relatives_name) {
this.relatives_name = relatives_name;
}
public String getRelatives_place() {
return relatives_place;
}
public void setRelatives_place(String relatives_place) {
this.relatives_place = relatives_place;
}
public String getRelatives_phone() {
return relatives_phone;
}
public void setRelatives_phone(String relatives_phone) {
this.relatives_phone = relatives_phone;
}
public Date getApply_time() {
return apply_time;
}
public void setApply_time(Date apply_time) {
this.apply_time = apply_time;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Date getOperation_time() {
return operation_time;
}
public String getIdimg_1() {
return idimg_1;
}
public String getIdimg_2() {
return idimg_2;
}
public String getIdimg_3() {
return idimg_3;
}
public String getIdimg_1_path() {
return idimg_1_path;
}
public String getIdimg_2_path() {
return idimg_2_path;
}
public String getIdimg_3_path() {
return idimg_3_path;
}
public void setOperation_time(Date operation_time) {
this.operation_time = operation_time;
}
public void setIdimg_1(String idimg_1) {
this.idimg_1 = idimg_1;
}
public void setIdimg_2(String idimg_2) {
this.idimg_2 = idimg_2;
}
public void setIdimg_3(String idimg_3) {
this.idimg_3 = idimg_3;
}
public void setIdimg_1_path(String idimg_1_path) {
this.idimg_1_path = idimg_1_path;
}
public void setIdimg_2_path(String idimg_2_path) {
this.idimg_2_path = idimg_2_path;
}
public void setIdimg_3_path(String idimg_3_path) {
this.idimg_3_path = idimg_3_path;
}
}

View File

@@ -0,0 +1,24 @@
package project.user.kyc;
import kernel.exception.BusinessException;
public interface KycHighLevelService {
public KycHighLevel get(String partyId);
/**
* 申请或修改实名认证
*/
public void save(KycHighLevel entity);
/**
* 验证审核结果
*/
public String checkApplyResult(String partyId) throws BusinessException;
/**
* 删除高级认证
*
* @param partyId
*/
public void delete(String partyId);
}

View File

@@ -0,0 +1,39 @@
package project.user.kyc;
import kernel.exception.BusinessException;
public interface KycService {
public Kyc get(String partyId);
/**
* 申请或修改实名认证
*/
public void save(Kyc entity);
/**
* 验证审核结果
*/
public String checkApplyResult(String partyId) throws BusinessException;
/**
* 审核是否通过
*
* @param partyId
* @return
*/
public boolean isPass(String partyId);
/**
* 删除认证
*
* @param partyId
*/
public void delete(String partyId);
/**
* 更新认证
*
* @param partyId
*/
public void update(String partyId , String signPdfUrl);
}

View File

@@ -0,0 +1,195 @@
package project.user.kyc.internal;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
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.util.StringUtils;
import kernel.web.Page;
import kernel.web.PagedQueryDao;
import project.party.PartyService;
import project.party.model.Party;
import project.party.recom.UserRecomService;
import project.tip.TipService;
import project.user.kyc.AdminKycHighLevelService;
import project.user.kyc.KycHighLevel;
import project.user.kyc.KycHighLevelService;
public class AdminKycHighLevelServiceImpl extends HibernateDaoSupport implements AdminKycHighLevelService {
private static final String KycHighLevel = null;
private PagedQueryDao pagedQueryDao;
private PartyService partyService;
private UserRecomService userRecomService;
private KycHighLevelService kycHighLevelService;
private TipService tipService;
@Override
public Page pagedQuery(int pageNo, int pageSize, String name_para, Integer status_para, String rolename_para,
String checkedPartyId) {
StringBuffer queryString = new StringBuffer();
queryString.append("SELECT");
queryString.append(
" party.UUID partyId,party.USERCODE usercode,party.USERNAME username,party.ROLENAME rolename,");
queryString.append(" kyc.UUID id,kyc.WORK_PLACE work_place,kyc.HOME_PLACE home_place,"
+ "kyc.RELATIVES_RELATION relatives_relation,"
+ "kyc.APPLY_TIME apply_time,kyc.OPERATION_TIME operation_time,"
+ " kyc.IDIMG_1 idimg_1,kyc.IDIMG_2 idimg_2,kyc.IDIMG_3 idimg_3, "
+ "kyc.RELATIVES_NAME relatives_name," + "kyc.RELATIVES_PLACE relatives_place,kyc.STATUS status,"
+ "kyc.MSG msg,kyc.RELATIVES_PHONE relatives_phone,party_parent.USERNAME username_parent ");
queryString.append(" FROM ");
queryString.append(" T_KYC_HIGH_LEVEL kyc LEFT JOIN PAT_PARTY party ON kyc.PARTY_ID = party.UUID ");
queryString.append(" LEFT JOIN PAT_USER_RECOM user ON user.PARTY_ID = party.UUID ");
queryString.append(" LEFT JOIN PAT_PARTY party_parent ON user.RECO_ID = party_parent.UUID ");
queryString.append(" WHERE 1=1 ");
Map<String, Object> parameters = new HashMap<String, Object>();
if (!StringUtils.isNullOrEmpty(checkedPartyId)) {
List<String> checked_list = this.userRecomService.findChildren(checkedPartyId);
checked_list.add(checkedPartyId);
if (checked_list.size() == 0) {
return Page.EMPTY_PAGE;
}
queryString.append(" and party.UUID in(:checked_list) ");
parameters.put("checked_list", checked_list);
}
if (status_para != null) {
queryString.append(" and kyc.STATUS = :status_para ");
parameters.put("status_para", status_para);
}
if (!StringUtils.isNullOrEmpty(rolename_para)) {
queryString.append(" and party.ROLENAME =:rolename");
parameters.put("rolename", rolename_para);
}
if (!StringUtils.isNullOrEmpty(name_para)) {
queryString.append("AND (party.USERNAME like:username OR party.USERCODE like:username ) ");
parameters.put("username", "%" + name_para + "%");
}
queryString.append(" order by kyc.APPLY_TIME desc ");
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
return page;
}
@Override
public KycHighLevel findByPartyId(Serializable partyId) {
List<KycHighLevel> list = (List<project.user.kyc.KycHighLevel>) getHibernateTemplate().find(" FROM KycHighLevel WHERE partyId = ?0",
new Object[] { partyId });
if (list.size() > 0) {
KycHighLevel k = (KycHighLevel) list.get(0);
Party party = partyService.cachePartyBy(k.getPartyId(), true);
k.setUsername(party.getUsername());
return (KycHighLevel) list.get(0);
}
return null;
}
public KycHighLevel findById(Serializable id) {
KycHighLevel kycHighLevel = getHibernateTemplate().get(KycHighLevel.class, id);
if (kycHighLevel != null) {
Party party = partyService.cachePartyBy(kycHighLevel.getPartyId(), true);
kycHighLevel.setUsername(party.getUsername());
return kycHighLevel;
}
return null;
}
@Override
public void savePassed(String partyId) {
KycHighLevel kycHighLevel = findByPartyId(partyId);
if (kycHighLevel != null) {
kycHighLevel.setStatus(2);
// this.getHibernateTemplate().update(kycHighLevel);
kycHighLevelService.save(kycHighLevel);
Party party = partyService.cachePartyBy(partyId, false);
party.setKyc_highlevel_authority(true);
// 获取用户系统等级1/新注册2/邮箱谷歌手机其中有一个已验证3/用户实名认证; 4/用户高级认证;
int userLevelSystem = this.partyService.getUserLevelByAuth(party);
// 十进制个位表示系统级别1/新注册2/邮箱谷歌手机其中有一个已验证3/用户实名认证4/用户高级认证;
// 十进制十位表示自定义级别对应在前端显示为如VIP1 VIP2等级、黄金 白银等级;
// 如级别11表示新注册的前端显示为VIP1
int userLevel = party.getUser_level();
party.setUser_level(((int) Math.floor(userLevel / 10)) * 10 + userLevelSystem);
this.partyService.update(party);
tipService.deleteTip(kycHighLevel.getId().toString());
}
}
@Override
public void saveFailed(String partyId, String msg) {
KycHighLevel kycHighLevel = findByPartyId(partyId);
if (kycHighLevel != null) {
kycHighLevel.setStatus(3);
kycHighLevel.setMsg(msg);
// this.getHibernateTemplate().update(kycHighLevel);
kycHighLevelService.save(kycHighLevel);
Party party = partyService.cachePartyBy(partyId, false);
party.setKyc_highlevel_authority(false);
partyService.update(party);
tipService.deleteTip(kycHighLevel.getId().toString());
}
}
/**
* 某个时间后未处理数量,没有时间则全部
*
* @param time
* @return
*/
public Long getUntreatedCount(Date time, String loginPartyId) {
StringBuffer queryString = new StringBuffer();
queryString.append("SELECT COUNT(*) FROM KycHighLevel WHERE status in(0,1) ");
List<Object> para = new ArrayList<Object>();
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
String childrensIds = this.userRecomService.findChildrensIds(loginPartyId);
if (StringUtils.isEmptyString(childrensIds)) {
return 0L;
}
queryString.append(" and partyId in (" + childrensIds + ") ");
}
if (null != time) {
queryString.append("AND apply_time > ?0");
para.add(time);
}
List find = this.getHibernateTemplate().find(queryString.toString(), para.toArray());
return CollectionUtils.isEmpty(find) ? 0L : find.get(0) == null ? 0L : Long.valueOf(find.get(0).toString());
}
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
this.pagedQueryDao = pagedQueryDao;
}
public void setPartyService(PartyService partyService) {
this.partyService = partyService;
}
public void setUserRecomService(UserRecomService userRecomService) {
this.userRecomService = userRecomService;
}
public void setKycHighLevelService(KycHighLevelService kycHighLevelService) {
this.kycHighLevelService = kycHighLevelService;
}
public void setTipService(TipService tipService) {
this.tipService = tipService;
}
}

View File

@@ -0,0 +1,317 @@
package project.user.kyc.internal;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import kernel.exception.BusinessException;
import kernel.util.DateUtils;
import org.apache.commons.collections.CollectionUtils;
import org.hibernate.query.NativeQuery;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import kernel.util.StringUtils;
import kernel.web.Page;
import kernel.web.PagedQueryDao;
import project.mall.notification.utils.notify.client.NotificationHelperClient;
import project.mall.seller.model.Seller;
import project.party.PartyService;
import project.party.model.Party;
import project.party.recom.UserRecomService;
import project.tip.TipService;
import project.user.kyc.AdminKycService;
import project.user.kyc.Kyc;
import project.user.kyc.KycService;
public class AdminKycServiceImpl extends HibernateDaoSupport implements AdminKycService {
protected PagedQueryDao pagedQueryDao;
protected PartyService partyService;
protected UserRecomService userRecomService;
protected KycService kycService;
protected TipService tipService;
private NotificationHelperClient notificationHelperClient;
@Override
public Page pagedQuery(int pageNo, int pageSize, String name_para, String status_para, String rolename_para,
String checkedPartyId, String idnumber_para, String email_para, String startTime, String endTime, String sellerName, String username_parent) {
StringBuffer queryString = new StringBuffer();
queryString.append("SELECT");
queryString.append(
" party.UUID partyId,party.USERCODE usercode,party.USERNAME username,party.PHONE phone,party.EMAIL email,party.ROLENAME rolename, party.REMARKS remark,");
queryString.append(
" kyc.UUID id,kyc.IDNUMBER idnumber,kyc.IDNAME idname,kyc.NAME name,seller.NAME sellerName,seller.AVATAR sellerImg,seller.SHOP_ADDRESS sellerAddress,"
+ "kyc.IDIMG_1 idimg_1,kyc.IDIMG_2 idimg_2,kyc.IDIMG_3 idimg_3,kyc.APPLY_TIME apply_time,kyc.OPERATION_TIME operation_time, kyc.REMARK remarks,"
+ "kyc.STATUS status,kyc.MSG msg,kyc.nationality nationality ,party_parent.USERNAME username_parent");
queryString.append(" FROM");
queryString.append(" T_KYC kyc LEFT JOIN PAT_PARTY party ON kyc.PARTY_ID = party.UUID ");
queryString.append(" LEFT JOIN PAT_USER_RECOM user ON user.PARTY_ID = party.UUID ");
queryString.append(" LEFT JOIN PAT_PARTY party_parent ON user.RECO_ID = party_parent.UUID ");
queryString.append(" LEFT JOIN T_MALL_SELLER seller ON party.UUID = seller.UUID ");
queryString.append(" WHERE 1=1 ");
Map<String, Object> parameters = new HashMap<String, Object>();
if (!StringUtils.isNullOrEmpty(checkedPartyId)) {
List<String> checked_list = this.userRecomService.findChildren(checkedPartyId);
checked_list.add(checkedPartyId);
if (checked_list.size() == 0) {
return Page.EMPTY_PAGE;
}
queryString.append(" and party.UUID in(:checked_list)");
parameters.put("checked_list", checked_list);
}
if (!StringUtils.isNullOrEmpty(sellerName)) {
queryString.append(" AND trim(replace(seller.`NAME`,' ','')) like:sellerName ");
sellerName = sellerName.replace(" ", "");
parameters.put("sellerName", "%" + sellerName + "%");
}
if (!StringUtils.isNullOrEmpty(username_parent)) {
queryString.append(" AND trim(replace(party_parent.USERNAME,' ','')) like:username_parent ");
username_parent = username_parent.replace(" ", "");
parameters.put("username_parent", "%" + username_parent + "%");
}
if (!StringUtils.isNullOrEmpty(status_para)) {
queryString.append(" and kyc.STATUS = :status_para ");
parameters.put("status_para", status_para);
}
if (!StringUtils.isNullOrEmpty(rolename_para)) {
queryString.append(" and party.ROLENAME =:rolename");
parameters.put("rolename", rolename_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(idnumber_para)) {
queryString.append("AND kyc.IDNUMBER =:idnumber_para ");
parameters.put("idnumber_para", idnumber_para);
}
if (!StringUtils.isNullOrEmpty(email_para)) {
queryString.append("AND (party.PHONE like:email_para OR party.EMAIL like:email_para ) ");
parameters.put("email_para", "%" + email_para + "%");
}
if (!StringUtils.isNullOrEmpty(startTime)) {
queryString.append(" AND DATE(kyc.APPLY_TIME) >= DATE(:startTime) ");
parameters.put("startTime", DateUtils.toDate(startTime));
}
if (!StringUtils.isNullOrEmpty(endTime)) {
queryString.append(" AND DATE(kyc.APPLY_TIME) <= DATE(:endTime) ");
parameters.put("endTime", DateUtils.toDate(endTime));
}
queryString.append(" order by kyc.APPLY_TIME desc ");
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
return page;
}
@Override
public Kyc find(Serializable partyId) {
List<Kyc> list = (List<Kyc>) getHibernateTemplate().find(" FROM Kyc WHERE partyId = ?0", new Object[]{partyId});
if (list.size() > 0) {
return (Kyc) list.get(0);
}
return null;
}
public Seller getSeller(String sellerId) {
return getHibernateTemplate().get(Seller.class, sellerId);
}
@Override
public void savePassed(String partyId) {
Kyc kyc = find(partyId);
if (kyc != null) {
kyc.setStatus(2);
kycService.save(kyc);
// this.getHibernateTemplate().update(kyc);
tipService.deleteTip(kyc.getId().toString());
}
Seller seller = getSeller(partyId);
if (null == seller) {
throw new BusinessException("申请通过失败,店铺信息未初始化");
}
seller.setCreateTime(new Date());
seller.setRecTime(0L);
seller.setStatus(1);
seller.setCreditScore(100);
getHibernateTemplate().update(seller);
Party party = this.partyService.cachePartyBy(partyId, false);
party.setKyc_authority(true);
party.setRoleType(1);
// 获取用户系统等级1/新注册2/邮箱谷歌手机其中有一个已验证3/用户实名认证; 4/用户高级认证;
int userLevelSystem = this.partyService.getUserLevelByAuth(party);
// 十进制个位表示系统级别1/新注册2/邮箱谷歌手机其中有一个已验证3/用户实名认证4/用户高级认证;
// 十进制十位表示自定义级别对应在前端显示为如VIP1 VIP2等级、黄金 白银等级;
// 如级别11表示新注册的前端显示为VIP1
int userLevel = party.getUser_level();
party.setUser_level(((int) Math.floor(userLevel / 10)) * 10 + userLevelSystem);
this.partyService.update(party);
// 通知商家审核结果
try {
notificationHelperClient.notifyStoreAuditByInbox(partyId, 2, seller.getName(), null);
} catch (Exception e) {
logger.error("发送通知消息提醒商家下单事件报错:", e);
}
}
@Override
public void saveFailed(String partyId, String msg) {
Kyc kyc = find(partyId);
if (kyc != null) {
kyc.setStatus(3);
kyc.setMsg(msg);
kycService.save(kyc);
// this.getHibernateTemplate().update(kyc);
tipService.deleteTip(kyc.getId().toString());
}
Seller seller = getSeller(partyId);
if (null == seller) {
throw new BusinessException("申请不通过失败,店铺信息未初始化");
}
Party party = partyService.cachePartyBy(partyId, false);
party.setKyc_authority(false);
partyService.update(party);
// 通知商家审核结果
try {
notificationHelperClient.notifyStoreAuditByInbox(partyId, 3, seller.getName(), msg);
} catch (Exception e) {
logger.error("发送通知消息提醒商家下单事件报错:", e);
}
}
@Override
public void saveFaileds(String partyId, String msg) {
Kyc kyc = find(partyId);
if (kyc != null) {
kyc.setStatus(3);
kyc.setMsg(msg);
kycService.save(kyc);
}
Seller seller = getSeller(partyId);
seller.setRecTime(0L);
seller.setStatus(0);
seller.setCreditScore(0);
getHibernateTemplate().update(seller);
Party party = partyService.cachePartyBy(partyId, false);
party.setKyc_authority(false);
party.setRoleType(0);
partyService.update(party);
// getHibernateTemplate().flush();
}
@Override
public void saveKycPic(String partyId, String imgId, String img) {
Kyc kyc = find(partyId);
if (kyc != null) {
if ("1".equals(imgId)) {
kyc.setIdimg_1(img);
} else if ("2".equals(imgId)) {
kyc.setIdimg_2(img);
} else if ("3".equals(imgId)) {
kyc.setIdimg_3(img);
}
kycService.save(kyc);
}
}
/**
* 某个时间后未处理数量,没有时间则全部
*
* @param time
* @return
*/
public Long getUntreatedCount(Date time, String loginPartyId) {
StringBuffer queryString = new StringBuffer();
queryString.append("SELECT COUNT(*) FROM Kyc WHERE status in(0,1) ");
List<Object> para = new ArrayList<Object>();
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
String childrensIds = this.userRecomService.findChildrensIds(loginPartyId);
if (StringUtils.isEmptyString(childrensIds)) {
return 0L;
}
queryString.append(" and partyId in (" + childrensIds + ") ");
}
if (null != time) {
queryString.append("AND apply_time > ?");
para.add(time);
}
List find = this.getHibernateTemplate().find(queryString.toString(), para.toArray());
return CollectionUtils.isEmpty(find) ? 0L : find.get(0) == null ? 0L : Long.valueOf(find.get(0).toString());
}
public Map<String, Object> findKycSumData() {
Map<String, Object> sumData = new HashMap<>();
StringBuffer sql = new StringBuffer(" SELECT ");
sql.append(" IFNULL(count(k.UUID),0) sellerNum, ");
sql.append(" MAX(k.UUID) id ");
sql.append(" FROM ");
sql.append(" T_KYC k ");
sql.append(" WHERE to_days(k.OPERATION_TIME) = TO_DAYS(now()) AND k.STATUS = 2 ");
NativeQuery<Object[]> nativeQuery = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createNativeQuery(sql.toString());
Object[] results = nativeQuery.getSingleResult();
sumData.put("todaySellerCount", results[0]);
sumData.put("id", results[1]);
StringBuffer queryString = new StringBuffer();
queryString.append("SELECT COUNT(*) FROM Kyc WHERE status = 2 ");
List<Object> para = new ArrayList<Object>();
List seller = this.getHibernateTemplate().find(queryString.toString(), para.toArray());
Long sellerCount = CollectionUtils.isEmpty(seller) ? 0L : seller.get(0) == null ? 0L : Long.valueOf(seller.get(0).toString());
sumData.put("sellerCount", sellerCount);
return sumData;
}
@Override
public void updateRemarks(String partyId, String remarks) {
Kyc kyc = find(partyId);
if (kyc != null) {
if (StringUtils.isNotEmpty(remarks)) {
kyc.setRemark(remarks);
getHibernateTemplate().update(kyc);
}
}
}
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
this.pagedQueryDao = pagedQueryDao;
}
public void setPartyService(PartyService partyService) {
this.partyService = partyService;
}
public void setUserRecomService(UserRecomService userRecomService) {
this.userRecomService = userRecomService;
}
public void setKycService(KycService kycService) {
this.kycService = kycService;
}
public void setTipService(TipService tipService) {
this.tipService = tipService;
}
public void setNotificationHelperClient(NotificationHelperClient notificationHelperClient) {
this.notificationHelperClient = notificationHelperClient;
}
}

View File

@@ -0,0 +1,110 @@
package project.user.kyc.internal;
import java.text.MessageFormat;
import java.util.Date;
import org.springframework.beans.BeanUtils;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import kernel.exception.BusinessException;
import project.redis.RedisHandler;
import project.tip.TipService;
import project.user.UserRedisKeys;
import project.user.kyc.KycHighLevel;
import project.user.kyc.KycHighLevelService;
public class KycHighLevelServiceImpl extends HibernateDaoSupport implements KycHighLevelService {
private RedisHandler redisHandler;
private TipService tipService;
@Override
public KycHighLevel get(String partyId) {
// StringBuffer queryString = new StringBuffer(" FROM KycHighLevel where partyId = ?");
// List<KycHighLevel> list = null;
// list = this.getHibernateTemplate().find(queryString.toString(), new Object[] { partyId });
// if (list.size() > 0) {
// return list.get(0);
// }
KycHighLevel kycHighLevel = (KycHighLevel) redisHandler.get(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + partyId);
if (kycHighLevel != null)
return kycHighLevel;
KycHighLevel obj = new KycHighLevel();
obj.setPartyId(partyId);
return obj;
}
@Override
public void save(KycHighLevel entity) {
KycHighLevel kycHighLevel = get(entity.getPartyId().toString());
if(entity.getStatus()==1) {
entity.setApply_time(new Date());
}else {
entity.setOperation_time(new Date());
}
if (kycHighLevel.getId() == null) {
this.getHibernateTemplate().save(entity);
redisHandler.setSync(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + entity.getPartyId().toString(), entity);
} else {
// entity.setPartyId(kycHighLevel.getPartyId());
entity.setId(kycHighLevel.getId());
BeanUtils.copyProperties(entity, kycHighLevel);
// kycHighLevel.setApply_time(new Date());
this.getHibernateTemplate().merge(kycHighLevel);
redisHandler.setSync(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + kycHighLevel.getPartyId().toString(),
kycHighLevel);
}
// tipService.saveTip(kycHighLevel.getId().toString(), TipConstants.KYC_HIGH_LEVEL);
}
/**
* 验证审核结果
*/
public String checkApplyResult(String partyId) throws BusinessException {
KycHighLevel kycHighLevel = get(partyId);
if (null == kycHighLevel.getId())
return "";
String msg = "";
switch (kycHighLevel.getStatus()) {
case 0:
msg = "已经提交申请,请等待审核";
break;
case 1:
msg = "审核中";
break;
case 2:
msg = "审核已通过";
break;
case 3:
msg = MessageFormat.format("审核未通过,原因:{0}", kycHighLevel.getMsg());
break;
default:
msg = "审核状态异常请联系客服";
break;
}
if (kycHighLevel.getStatus() != 3) {
throw new BusinessException(msg);
} else {
return msg;
}
}
public void delete(String partyId) {
KycHighLevel kycHighLevel = get(partyId);
if (kycHighLevel != null) {
this.getHibernateTemplate().delete(kycHighLevel);
redisHandler.remove(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + partyId);
}
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
public void setTipService(TipService tipService) {
this.tipService = tipService;
}
}

View File

@@ -0,0 +1,175 @@
package project.user.kyc.internal;
import java.text.MessageFormat;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import kernel.exception.BusinessException;
import project.redis.RedisHandler;
import project.user.UserRedisKeys;
import project.user.kyc.Kyc;
import project.user.kyc.KycService;
@Slf4j
public class KycServiceImpl extends HibernateDaoSupport implements KycService {
private RedisHandler redisHandler;
@Override
public Kyc get(String partyId) {
// StringBuffer queryString = new StringBuffer(" FROM Kyc where partyId = ?");
// List<Kyc> list = null;
// list = this.getHibernateTemplate().find(queryString.toString(), new Object[] { partyId });
// if (list.size() > 0) {
// return list.get(0);
// }
Kyc kyc = (Kyc) redisHandler.get(UserRedisKeys.KYC_PARTY_ID + partyId);
if (kyc != null) {
return kyc;
} else {
StringBuffer queryString = new StringBuffer(" FROM Kyc where partyId = ?0 ");
List<Kyc> list = (List<Kyc>) this.getHibernateTemplate().find(queryString.toString(), new Object[]{partyId});
if (list.size() > 0) {
kyc = list.get(0);
}
if (kyc != null) {
redisHandler.setSync(UserRedisKeys.KYC_PARTY_ID + partyId, kyc);
return kyc;
}
}
kyc = new Kyc();
kyc.setPartyId(partyId);
return kyc;
}
@Override
public void save(Kyc entity) {
Kyc kyc = get(entity.getPartyId().toString());
//身份证号可以重复实名 8-4号需求
// List<Kyc> kycs = findByIdNumber(entity.getIdnumber().trim());
// if (kycs != null && entity.getStatus() != 3 && entity.getStatus() != 1) {
// for (Kyc kyc_othde : kycs) {
// if (kyc_othde.getStatus() == 2 && !kyc_othde.getPartyId().equals(entity.getPartyId())) {
// throw new BusinessException("身份证号已实名过!");
// }
// }
//
//// if(kycs.size() == 1 && kyc != null && kyc.getId() != null) {
//// if(!kyc.getId().equals(kycs.get(0).getId()) &&
//// kyc.getIdnumber().equals(kycs.get(0).getIdnumber())) {
//// throw new BusinessException("身份证已实名过!");
//// }
//// }
//// if(kycs.size() > 1 ) {
//// throw new BusinessException("身份证已实名过!");
//// }
// }
if (kyc.getId() == null) {
entity.setApply_time(new Date());
this.getHibernateTemplate().save(entity);
redisHandler.setSync(UserRedisKeys.KYC_PARTY_ID + entity.getPartyId().toString(), entity);
} else {
kyc.setIdnumber(entity.getIdnumber());
kyc.setStatus(entity.getStatus());
kyc.setIdname(entity.getIdname());
kyc.setName(entity.getName());
kyc.setIdimg_1(entity.getIdimg_1());
kyc.setIdimg_2(entity.getIdimg_2());
kyc.setIdimg_3(entity.getIdimg_3());
kyc.setNationality(entity.getNationality());
if (entity.getStatus() == 1) {
kyc.setApply_time(new Date());
} else {
kyc.setOperation_time(new Date());
}
kyc.setMsg(entity.getMsg());
this.getHibernateTemplate().merge(kyc);
entity.setId(kyc.getId());
redisHandler.setSync(UserRedisKeys.KYC_PARTY_ID + kyc.getPartyId().toString(), kyc);
}
}
public void update(String partyId, String signPdfUrl) {
Kyc kyc = get(partyId);
kyc.setSignPdfUrl(signPdfUrl);
log.info("更新商家人认证信息{}", JSONObject.toJSONString(kyc));
this.getHibernateTemplate().merge(kyc);
redisHandler.setSync(UserRedisKeys.KYC_PARTY_ID + kyc.getPartyId().toString(), kyc);
}
/**
* 查询是否有多个实名用户
*
* @return
*/
public List<Kyc> findByIdNumber(String idNumber) {
StringBuffer queryString = new StringBuffer(" FROM Kyc where idnumber = ?0");
List<Kyc> list = (List<Kyc>) this.getHibernateTemplate().find(queryString.toString(), new Object[]{idNumber});
if (list.size() > 0) {
return list;
}
return null;
}
/**
* 验证审核结果
*/
public String checkApplyResult(String partyId) throws BusinessException {
Kyc kyc = get(partyId);
if (null == kyc.getId())
return "";
String msg = "";
switch (kyc.getStatus()) {
case 0:
msg = "已经提交申请,请等待审核";
break;
case 1:
msg = "审核中";
break;
case 2:
msg = "审核已通过";
break;
case 3:
msg = MessageFormat.format("审核未通过,原因:{0}", kyc.getMsg());
break;
default:
msg = "审核状态异常请联系客服";
break;
}
if (kyc.getStatus() != 3) {
throw new BusinessException(msg);
} else {
return msg;
}
}
public boolean isPass(String partyId) {
Kyc kyc = get(partyId);
if (null == kyc)
return Boolean.FALSE;
return kyc.getStatus() == 2;
}
public void delete(String partyId) {
Kyc kyc = get(partyId);
if (kyc != null) {
this.getHibernateTemplate().delete(kyc);
redisHandler.remove(UserRedisKeys.KYC_PARTY_ID + partyId);
}
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
}

View File

@@ -0,0 +1,19 @@
<?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.user.token.Token" table="T_TOKEN">
<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="token" type="java.lang.String">
<column name="TOKEN" />
</property>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,31 @@
package project.user.token;
import java.io.Serializable;
import kernel.bo.EntityObject;
public class Token extends EntityObject{
private static final long serialVersionUID = -5132505045848059321L;
private Serializable partyId;
private String token;
public Serializable getPartyId() {
return partyId;
}
public void setPartyId(Serializable partyId) {
this.partyId = partyId;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
}

View File

@@ -0,0 +1,19 @@
package project.user.token;
public interface TokenService {
public String savePut(String partyId);
public String platFromSavePut(String partyId);
public String cacheGet(String token);
public void delete(String token);
public void removePlatFromToken(String token);
public void removeLoginToken(String partyId);
public Token find(String partyId) ;
}

View File

@@ -0,0 +1,148 @@
package project.user.token.internal;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import kernel.util.StringUtils;
import kernel.util.UUIDGenerator;
import project.redis.RedisHandler;
import project.user.UserRedisKeys;
import project.user.token.Token;
import project.user.token.TokenService;
import util.TokenUtils;
public class TokenServiceImpl extends HibernateDaoSupport implements TokenService {
private Logger logger = LogManager.getLogger(TokenServiceImpl.class);
private RedisHandler redisHandler;
public String savePut(String partyId) {
String uuid = UUIDGenerator.getUUID();
Token token = this.find(partyId);
if (token == null) {
token = new Token();
token.setPartyId(partyId);
}
token.setToken(uuid);
this.getHibernateTemplate().saveOrUpdate(token);
redisHandler.setSync(UserRedisKeys.TOKEN + uuid, partyId);
redisHandler.setSync(UserRedisKeys.TOKEN_PARTY_ID + partyId, token);
return uuid;
}
@Override
public String platFromSavePut(String partyId) {
Token token = new Token();
token.setPartyId(partyId);
String uuid = TokenUtils.token(null, null, false, partyId);
token.setToken(uuid);
redisHandler.setSync(UserRedisKeys.PLAT_FROM_TOKEN + uuid, partyId);
redisHandler.setSync(UserRedisKeys.PLAT_FROM_TOKEN_PARTY_ID + partyId, token);
return uuid;
}
public String cacheGet(String token) {
if (StringUtils.isNullOrEmpty(token)) {
logger.error("cacheGet:token is null");
return null;
}
String partyId;
if (token.length() > 36){
partyId = (String) redisHandler.get(UserRedisKeys.PLAT_FROM_TOKEN + token);
if (StringUtils.isNullOrEmpty(partyId)) {
logger.error("cacheGet:partyId is null, token:" + token);
return null;
}
Token token_redis = (Token) redisHandler.get(UserRedisKeys.PLAT_FROM_TOKEN_PARTY_ID + partyId);
if (null == token_redis) {
logger.error("cacheGet:token_redis is null, token:" + token);
return null;
}
if (!token.equals(token_redis.getToken())) {
logger.error("cacheGet:请求token:{}和token_redis{}不同", token, token_redis.getToken());
// redisHandler.remove(UserRedisKeys.TOKEN + token);
return null;
}
} else {
partyId = (String) redisHandler.get(UserRedisKeys.TOKEN + token);
if (StringUtils.isNullOrEmpty(partyId)) {
logger.error("cacheGet:partyId is null, token:" + token);
return null;
}
Token token_redis = (Token) redisHandler.get(UserRedisKeys.TOKEN_PARTY_ID + partyId);
if (null == token_redis) {
logger.error("cacheGet:token_redis is null, token:" + token);
return null;
}
if (!token.equals(token_redis.getToken())) {
logger.error("cacheGet:请求token:{}和token_redis{}不同", token, token_redis.getToken());
// redisHandler.remove(UserRedisKeys.TOKEN + token);
return null;
}
}
return partyId;
}
public Token find(String partyId) {
return (Token) redisHandler.get(UserRedisKeys.TOKEN_PARTY_ID + partyId);
}
@Override
public void delete(String token) {
if (StringUtils.isNullOrEmpty(token)) {
return;
}
String partyId = cacheGet(token);
if (!StringUtils.isNullOrEmpty(partyId)) {
Token entity = find(partyId);
if (entity != null) {
this.getHibernateTemplate().delete(entity);
}
}
redisHandler.remove(UserRedisKeys.TOKEN + token);
redisHandler.remove(UserRedisKeys.TOKEN_PARTY_ID + partyId);
}
@Override
public void removePlatFromToken(String token) {
if (StringUtils.isNullOrEmpty(token)) {
return;
}
String partyId = cacheGet(token);
redisHandler.remove(UserRedisKeys.PLAT_FROM_TOKEN + token);
redisHandler.remove(UserRedisKeys.PLAT_FROM_TOKEN_PARTY_ID + partyId);
}
public void removeLoginToken(String partyId) {
if (StringUtils.isNullOrEmpty(partyId)) {
return;
}
Token entity = find(partyId);
if (entity != null) {
this.getHibernateTemplate().delete(entity);
redisHandler.remove(UserRedisKeys.TOKEN + entity.getToken());
redisHandler.remove(UserRedisKeys.TOKEN_PARTY_ID + partyId);
}
}
public void setRedisHandler(RedisHandler redisHandler) {
this.redisHandler = redisHandler;
}
}

View File

@@ -0,0 +1,167 @@
//package project.web.admin;
//
//import java.util.HashMap;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.apache.logging.log4j.LogManager;
//import org.apache.logging.log4j.Logger;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import kernel.exception.BusinessException;
//import kernel.util.StringUtils;
//import kernel.web.BaseAction;
//import kernel.web.ResultObject;
//import project.syspara.SysparaService;
//import project.user.captcha.GeetestService;
//
///**
// * Geetest滑动图片验证
// */
//@RestController
//public class AdminGeetestController extends BaseAction {
//
// private Logger logger = LogManager.getLogger(AdminGeetestController.class);
//
// @Autowired
// private GeetestService geetestService;
// @Autowired
// private SysparaService sysparaService;
//
// private final String action = "normal/geetest!";
//
// /**
// * 获取 challenge和captcha_id
// */
// @RequestMapping(action + "getChallengeAndCaptchaid.action")
// public Object getChallengeAndCaptchaid(HttpServletRequest request) {
//
// ResultObject resultObject = new ResultObject();
//
// try {
//
// // 自定义参数,可选择添加
// HashMap<String, String> param = new HashMap<String, String>();
//
// // 网站用户id
// param.put("user_id", "test");
//
// String geetest_id = this.sysparaService.find("geetest_id").getValue();
// String geetest_key = this.sysparaService.find("geetest_key").getValue();
// String new_failback = this.sysparaService.find("geetest_new_failback").getValue();
// if(StringUtils.isEmptyString(geetest_id) || StringUtils.isEmptyString(geetest_key) || StringUtils.isEmptyString(new_failback)) {
// throw new BusinessException("系统参数错误");
// }
//
// param.put("geetest_id", geetest_id);
// param.put("geetest_key", geetest_key);
// param.put("new_failback", new_failback);
//
// HashMap<String, String> retMap = this.geetestService.preProcess(param);
// retMap.put("user_id", param.get("user_id"));
// retMap.put("gt_server_status", retMap.get("success"));
//
// resultObject.setData(retMap);
//
// } catch (BusinessException e) {
// resultObject.setCode("1");
// resultObject.setMsg(e.getMessage());
// } catch (Throwable t) {
// resultObject.setCode("1");
// resultObject.setMsg("程序错误");
// logger.error("error:", t);
// }
//
// return resultObject;
// }
//
// /**
// * 返回验证结果, request表单中必须包含challenge, validate, seccode
// */
// @RequestMapping(action + "verify.action")
// public Object verify(HttpServletRequest request) {
// String challenge = request.getParameter("geetest_challenge");
// String validate = request.getParameter("geetest_validate");
// String seccode = request.getParameter("geetest_seccode");
// String gt_server_status = request.getParameter("gt_server_status");
//// String user_id = request.getParameter("user_id");
//
// ResultObject resultObject = new ResultObject();
//
// try {
//
// if (StringUtils.isEmptyString(challenge)) {
// throw new BusinessException("fail, challenge error.");
// }
// if (StringUtils.isEmptyString(validate)) {
// throw new BusinessException("fail, validate error.");
// }
// if (StringUtils.isEmptyString(seccode)) {
// throw new BusinessException("fail, seccode error.");
// }
// if (StringUtils.isEmptyString(gt_server_status)) {
// throw new BusinessException("fail, gt_server_status error.");
// }
//
// // 自定义参数,可选择添加
// HashMap<String, String> param = new HashMap<String, String>();
//
// // 网站用户id
// param.put("user_id", "test");
//
// param.put("challenge", challenge);
// param.put("validate", validate);
// param.put("seccode", seccode);
//
// String geetest_id = this.sysparaService.find("geetest_id").getValue();
// String geetest_key = this.sysparaService.find("geetest_key").getValue();
// String new_failback = this.sysparaService.find("geetest_new_failback").getValue();
// if (StringUtils.isEmptyString(geetest_id) || StringUtils.isEmptyString(geetest_key) || StringUtils.isEmptyString(new_failback)) {
// throw new BusinessException("系统参数错误");
// }
//
// param.put("geetest_id", geetest_id);
// param.put("geetest_key", geetest_key);
// param.put("new_failback", new_failback);
//
// int gtResult = 0;
// if ("1".equals(gt_server_status)) {
// // gt-server正常向gt-server进行二次验证
// gtResult = this.geetestService.enhencedValidateRequest(param);
// System.out.println(gtResult);
// } else {
// // gt-server非正常情况下进行failback模式验证
// System.out.println("failback:use your own server captcha validate");
// gtResult = this.geetestService.failbackValidateRequest(param);
// System.out.println(gtResult);
// }
//
// HashMap<String, String> retMap = this.geetestService.preProcess(param);
//
// if (1 == gtResult) {
// // 验证成功
// retMap.put("status", "success");
// retMap.put("version", this.geetestService.getVersionInfo());
// } else {
// // 验证失败
// retMap.put("status", "fail");
// retMap.put("version", this.geetestService.getVersionInfo());
// }
//
// resultObject.setData(retMap);
//
// } catch (BusinessException e) {
// resultObject.setCode("1");
// resultObject.setMsg(e.getMessage());
// } catch (Throwable t) {
// resultObject.setCode("1");
// resultObject.setMsg("程序错误");
// logger.error("error:", t);
// }
//
// return resultObject;
// }
//
//}

View File

@@ -0,0 +1,201 @@
package project.web.admin;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import kernel.exception.BusinessException;
import kernel.util.PropertiesUtil;
import kernel.util.StringUtils;
import kernel.web.PageActionSupport;
import project.Constants;
import project.syspara.SysparaService;
import project.user.AdminUserSafewordApplyService;
/**
* 人工重置管理
*/
@RestController
public class AdminUserSafewordApplyController extends PageActionSupport {
private Logger logger = LogManager.getLogger(AdminUserSafewordApplyController.class);
@Autowired
private AdminUserSafewordApplyService adminUserSafewordApplyService;
@Autowired
protected SysparaService sysparaService;
private final String action = "normal/adminUserSafewordApplyAction!";
/**
* 获取 人工重置管理 列表
*/
@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 state_para = request.getParameter("state_para");
String rolename_para = request.getParameter("rolename_para");
String operate = request.getParameter("operate");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("user_safeword_apply_list");
try {
String basePath = PropertiesUtil.getProperty("admin_url");
basePath = this.getPath(request);
this.checkAndSetPageNo(pageNo);
this.pageSize = 20;
Integer state_para_int = null;
if (StringUtils.isNullOrEmpty(state_para)) {
state_para_int = null;
} else {
state_para_int = Integer.valueOf(state_para);
}
Integer operate_int = null;
if (StringUtils.isNullOrEmpty(operate)) {
operate_int = null;
} else {
operate_int = Integer.valueOf(operate);
}
this.page = this.adminUserSafewordApplyService.pagedQuery(this.pageNo, this.pageSize, name_para, state_para_int,
rolename_para, this.getLoginPartyId(), operate_int);
String preImg = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=";
for (Map<String, Object> map : (List<Map<String, Object>>) this.page.getElements()) {
map.put("idimg_1", preImg + map.get("idimg_1").toString());
map.put("idimg_2", preImg + map.get("idimg_2").toString());
if ("".equals(map.get("idimg_3")) || map.get("idimg_3") == null) {
map.put("idimg_3", preImg + "qr/id_img3.jpg");
} else {
map.put("idimg_3", preImg + map.get("idimg_3").toString());
}
map.put("kyc_idimg_1", preImg + map.get("kyc_idimg_1").toString());
map.put("kyc_idimg_2", preImg + map.get("kyc_idimg_2").toString());
if ("".equals(map.get("kyc_idimg_3")) || map.get("kyc_idimg_3") == null) {
map.put("kyc_idimg_3", preImg + "qr/id_img3.jpg");
} else {
map.put("kyc_idimg_3", preImg + map.get("kyc_idimg_3").toString());
}
// 十进制个位表示系统级别1/新注册2/邮箱谷歌手机其中有一个已验证3/用户实名认证4/用户高级认证;
// 十进制十位表示自定义级别对应在前端显示为如VIP1 VIP2等级、黄金 白银等级;
// 如级别11表示新注册的前端显示为VIP1
Integer userLevel = (Integer) map.get("user_level");
if (null == userLevel) {
userLevel = 1;
}
int user_level_system = (int) (userLevel % 10);
map.put("user_level_system", user_level_system);
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("state_para", state_para);
modelAndView.addObject("rolename_para", rolename_para);
modelAndView.addObject("operate", operate);
return modelAndView;
}
/**
* 审核通过
*/
@RequestMapping(action + "savePassed.action")
public ModelAndView savePassed(HttpServletRequest request) {
String id = request.getParameter("id");
String safeword = request.getParameter("safeword");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
this.adminUserSafewordApplyService.savePassed(id, this.getUsername_login(), safeword);
} 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;
}
/**
* 驳回
*/
@RequestMapping(action + "saveFailed.action")
public ModelAndView saveFailed(HttpServletRequest request) {
String id = request.getParameter("id");
String msg = request.getParameter("msg");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
this.adminUserSafewordApplyService.saveFailed(id, msg);
} 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;
}
private String getPath(HttpServletRequest request) {
return String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath());
}
}

View File

@@ -0,0 +1,670 @@
package project.web.admin.googleauth;
import kernel.exception.BusinessException;
import kernel.util.JsonUtils;
import kernel.util.StringUtils;
import kernel.web.PageActionSupport;
import project.Constants;
import project.log.LogService;
import project.syspara.Syspara;
import project.syspara.SysparaService;
import project.user.googleauth.GoogleAuthService;
import security.SecUser;
import security.internal.SecUserService;
import util.GoogleAuthenticator;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
@RestController
public class AdminGoogleAuthController extends PageActionSupport {
private static final Logger logger = LoggerFactory.getLogger(AdminGoogleAuthController.class);
@Autowired
private SysparaService sysparaService;
@Autowired
private SecUserService secUserService;
@Autowired
protected LogService logService;
@Autowired
private GoogleAuthService googleAuthService;
private final String action = "normal/adminGoogleAuthAction!";
/**
* 点击登录名里面的
* 谷歌验证器
*/
@RequestMapping(value = action + "toUpdateLoginGoogleAuth.action")
public ModelAndView toUpdateLoginGoogleAuth(HttpServletRequest request) {
String message = "";
String error = "";
if("admin".equals(this.getUsername_login())) {
this.error = "请联系管理员操作";
try {
this.getResponse().sendRedirect("/admin/normal/indexAction!view.action");
} catch (IOException e) {
e.printStackTrace();
}
}
SecUser secUser = secUserService.findUserByLoginName(this.getUsername_login());
Boolean google_auth_bind = secUser.isGoogle_auth_bind();
ModelAndView model = new ModelAndView();
model.addObject("username", secUser.getUsername());
model.addObject("message", message);
model.addObject("error", error);
model.addObject("google_auth_bind", google_auth_bind);
model.setViewName("google_auth_login");
return model;
}
/**
* 点击登录名里面的
* 谷歌验证器 - 生成密钥
*/
@RequestMapping(value = action + "getLoginSecret.action")
public String getLoginSecret() {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
if("admin".equals(this.getUsername_login())) {
throw new BusinessException("请联系管理员操作");
}
SecUser secUser = secUserService.findUserByLoginName(this.getUsername_login());
// 未绑定
if (!secUser.isGoogle_auth_bind()) {
String secretKey = GoogleAuthenticator.generateSecretKey();
resultMap.put("google_auth_secret", secretKey);
resultMap.put("google_auth_url", googleAuthService.getGoogleAuthUrl(secUser.getUsername(), secretKey));
}else {
throw new BusinessException("已绑定谷歌验证器");
}
resultMap.put("google_auth_bind", secUser.isGoogle_auth_bind());
resultMap.put("code", 200);
} catch (BusinessException e) {
resultMap.put("code", 500);
resultMap.put("message", e.getMessage());
} catch (Throwable t) {
logger.error(" error ", t);
resultMap.put("code", 500);
resultMap.put("message", "程序错误");
}
return JsonUtils.getJsonString(resultMap);
}
/**
* 点击登录名里面的
* 谷歌验证器 - 绑定
*/
@RequestMapping(value = action + "googleLoginAuthBind.action")
public ModelAndView googleLoginAuthBind(HttpServletRequest request) {
String message = "";
String error = "";
try {
String google_auth_secret = request.getParameter("google_auth_secret");
String google_auth_code = request.getParameter("google_auth_code");
//admin只能通过超级签操作
if("admin".equals(this.getUsername_login())) {
throw new BusinessException("请联系管理员操作");
}
boolean checkCode = googleAuthService.saveGoogleAuthBind(this.getUsername_login(),
google_auth_secret, google_auth_code);
if(!checkCode) {
throw new BusinessException("验证码错误,或请刷新二维码重新进行扫描");
}
SecUser secUser = this.secUserService.findUserByLoginName(this.getUsername_login());
saveLog(secUser,this.getUsername_login(),"ip:"+this.getIp()+"谷歌验证器绑定");
message="绑定成功";
} catch (BusinessException e) {
error = e.getMessage();
} catch (Exception e) {
logger.error("error ", e);
error = "程序错误";
}
ModelAndView model = new ModelAndView();
model.addObject("message", message);
model.addObject("error", error);
model.setViewName("redirect:/" + action + "toUpdateLoginGoogleAuth.action");
return model;
}
/**
* 系统配置-超级谷歌验证码
*/
@RequestMapping(value = action + "toUpdateSuperGoogleAuth.action")
public ModelAndView toUpdateSuperGoogleAuth(HttpServletRequest request) {
if(!"root".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
String message = request.getParameter("message");
String error = request.getParameter("error");
Syspara superSecret = this.sysparaService.find("super_google_auth_secret");
boolean google_auth_bind = superSecret != null && !StringUtils.isEmptyString(superSecret.getValue());
ModelAndView model = new ModelAndView();
model.addObject("message", message);
model.addObject("error", error);
model.addObject("google_auth_bind", google_auth_bind);
model.setViewName("google_auth_super");
return model;
}
/**
* 超级谷歌验证码-生成密钥
*/
@RequestMapping(value = action + "getSuperSecret.action")
public String getSuperSecret() {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
if(!"root".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
Syspara superSecret = this.sysparaService.find("super_google_auth_secret");
if(superSecret==null||StringUtils.isEmptyString(superSecret.getValue())) {
// 未绑定则
String secretKey = GoogleAuthenticator.generateSecretKey();
resultMap.put("google_auth_secret", secretKey);
resultMap.put("google_auth_url", googleAuthService.getGoogleAuthUrl("super", secretKey));
}else {
throw new BusinessException("已绑定谷歌验证器");
}
resultMap.put("code", 200);
} catch (BusinessException e) {
resultMap.put("code", 500);
resultMap.put("message", e.getMessage());
} catch (Throwable t) {
logger.error(" error ", t);
resultMap.put("code", 500);
resultMap.put("message", "程序错误");
}
return JsonUtils.getJsonString(resultMap);
}
/**
* 系统配置-超级谷歌验证器-绑定
*/
@RequestMapping(value = action + "superGoogleAuthBind.action")
public ModelAndView superGoogleAuthBind(HttpServletRequest request) {
String message = "";
String error = "";
try {
if(!"root".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
String google_auth_secret = request.getParameter("google_auth_secret");
if (StringUtils.isEmptyString(google_auth_secret)) {
throw new BusinessException("密匙不能为空");
}
String super_google_auth_code = request.getParameter("super_google_auth_code");
if (StringUtils.isEmptyString(super_google_auth_code)) {
throw new BusinessException("超级谷歌验证码不能为空");
}
String super_google_auth_secret = request.getParameter("super_google_auth_secret");
Syspara superSecret = this.sysparaService.find("super_google_auth_secret");
if(superSecret!=null&&!StringUtils.isEmptyString(superSecret.getValue())) {
throw new BusinessException("用户已绑定");
}
boolean checkCode = googleAuthService.checkCode(google_auth_secret, super_google_auth_code);
if(!checkCode) {
throw new BusinessException("验证码错误,或请刷新二维码重新进行扫描");
}
superSecret.setValue(google_auth_secret);
this.sysparaService.update(superSecret);
SecUser secUser = this.secUserService.findUserByLoginName(this.getUsername_login());
saveLog(secUser,this.getUsername_login(),"ip:"+this.getIp()+"谷歌超级验证器绑定");
super_google_auth_code=null;
message="绑定成功";
} catch (BusinessException e) {
error = e.getMessage();
} catch (Exception e) {
logger.error("error ", e);
error = "程序错误";
}
ModelAndView model = new ModelAndView();
model.addObject("message", message);
model.addObject("error", error);
model.setViewName("redirect:/" + action + "toUpdateSuperGoogleAuth.action");
return model;
}
/**
* 超级谷歌验证器-解绑
*/
@RequestMapping(value = action + "superGoogleAuthUnBind.action")
public ModelAndView superGoogleAuthUnBind(HttpServletRequest request) {
String message = "";
String error = "";
try {
if(!"root".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
Syspara superSecret = this.sysparaService.find("super_google_auth_secret");
if(superSecret==null||StringUtils.isEmptyString(superSecret.getValue())) {
throw new BusinessException("用户未绑定,无需解绑");
}
String secert = superSecret.getValue();
String super_google_auth_code = request.getParameter("super_google_auth_code");
if (StringUtils.isNullOrEmpty(super_google_auth_code)) {
throw new BusinessException("超级谷歌验证码不能为空");
}
boolean checkCode = this.googleAuthService.checkCode(secert, super_google_auth_code);
if(!checkCode) {
throw new BusinessException("验证码错误,或请刷新二维码重新进行扫描");
}
superSecret.setValue("");
sysparaService.update(superSecret);
SecUser secUser = this.secUserService.findUserByLoginName(this.getUsername_login());
saveLog(secUser,this.getUsername_login(),"ip:"+this.getIp()+"谷歌超级验证器解绑");
message="解绑成功";
} catch (BusinessException e) {
error = e.getMessage();
} catch (Exception e) {
logger.error("error ", e);
error = "程序错误";
}
ModelAndView model = new ModelAndView();
model.addObject("message", message);
model.addObject("error", error);
model.setViewName("redirect:/" + action + "toUpdateSuperGoogleAuth.action");
return model;
}
/**
* 系统配置-admin谷歌验证器
*/
@RequestMapping(value = action + "toUpdateAdminGoogleAuth.action")
public ModelAndView toUpdateAdminGoogleAuth(HttpServletRequest request) {
String message = request.getParameter("message");
String error = request.getParameter("error");
String google_auth_secret = request.getParameter("google_auth_secret");
String google_auth_url = request.getParameter("google_auth_url");
if(!"root".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
SecUser secUser = secUserService.findUserByLoginName("admin");
boolean google_auth_bind = secUser.isGoogle_auth_bind();
ModelAndView model = new ModelAndView();
model.addObject("message", message);
model.addObject("error", error);
model.addObject("google_auth_secret", google_auth_secret);
model.addObject("google_auth_url", google_auth_url);
model.addObject("google_auth_bind", google_auth_bind + "");
model.setViewName("google_auth_admin");
return model;
}
/**
* admin谷歌验证器-绑定
*/
@RequestMapping(value = action + "adminGoogleAuthBind.action")
public ModelAndView adminGoogleAuthBind(HttpServletRequest request) {
String super_google_auth_code = request.getParameter("super_google_auth_code");
String google_auth_code = request.getParameter("google_auth_code");
String google_auth_secret = request.getParameter("google_auth_secret");
String google_auth_url = request.getParameter("google_auth_url");
String google_auth_bind = request.getParameter("google_auth_bind");
String message = "";
String error = "";
try {
if(!"root".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
Syspara superSecret = this.sysparaService.find("super_google_auth_secret");
if(superSecret==null||StringUtils.isEmptyString(superSecret.getValue())) {
throw new BusinessException("超级验证器尚未设置");
}
boolean checkSuperCode = this.googleAuthService.checkCode(superSecret.getValue(), super_google_auth_code);
if(!checkSuperCode) {
throw new BusinessException("超级验证码错误");
}
boolean checkCode = googleAuthService.saveGoogleAuthBind("admin", google_auth_secret, google_auth_code);
if(!checkCode) {
throw new BusinessException("验证码错误,或请刷新二维码重新进行扫描");
}
SecUser secUser = this.secUserService.findUserByLoginName("admin");
boolean google_auth_bind_bo = secUser.isGoogle_auth_bind();
google_auth_bind = google_auth_bind_bo + "";
saveLog(secUser,this.getUsername_login(),"ip:"+this.getIp()+"admin谷歌验证器绑定");
super_google_auth_code=null;
message="绑定成功";
} catch (BusinessException e) {
error = e.getMessage();
} catch (Exception e) {
logger.error("error ", e);
error = "程序错误";
}
ModelAndView model = new ModelAndView();
model.addObject("message", message);
model.addObject("error", error);
model.addObject("google_auth_secret", google_auth_secret);
model.addObject("google_auth_url", google_auth_url);
model.addObject("google_auth_bind", google_auth_bind);
model.setViewName("redirect:/" + action + "toUpdateAdminGoogleAuth.action");
return model;
}
/**
* admin谷歌验证器-解绑
*/
@RequestMapping(value = action + "adminGoogleAuthUnBind.action")
public ModelAndView adminGoogleAuthUnBind(HttpServletRequest request) {
String message = "";
String error = "";
String super_google_auth_code = request.getParameter("super_google_auth_code");
try {
if(!"root".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
Syspara superSecret = this.sysparaService.find("super_google_auth_secret");
if(superSecret==null || StringUtils.isEmptyString(superSecret.getValue())) {
throw new BusinessException("超级验证器尚未设置");
}
boolean checkCode = this.googleAuthService.checkCode(superSecret.getValue(), super_google_auth_code);
if(!checkCode) {
throw new BusinessException("超级验证码错误");
}
googleAuthService.saveGoogleAuthUnBind("admin");
SecUser secUser = this.secUserService.findUserByLoginName("admin");
saveLog(secUser,this.getUsername_login(),"ip:"+this.getIp()+"admin谷歌验证器解绑");
super_google_auth_code = null;
message = "解绑成功";
} catch (BusinessException e) {
error = e.getMessage();
} catch (Exception e) {
logger.error("error ", e);
error = "程序错误";
}
ModelAndView model = new ModelAndView();
model.addObject("super_google_auth_code", super_google_auth_code);
model.addObject("message", message);
model.addObject("error", error);
model.setViewName("redirect:/" + action + "toUpdateAdminGoogleAuth.action");
return model;
}
/**
* ADMIN谷歌验证器-生成密钥
*/
@RequestMapping(value = action + "getAdminSecret.action")
public String getAdminSecret() {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
if(!"root".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
SecUser secUser = secUserService.findUserByLoginName("admin");
// 未绑定
if (!secUser.isGoogle_auth_bind()) {
String secretKey = GoogleAuthenticator.generateSecretKey();
resultMap.put("google_auth_secret", secretKey);
resultMap.put("google_auth_url", googleAuthService.getGoogleAuthUrl(secUser.getUsername(), secretKey));
}else {
throw new BusinessException("已绑定谷歌验证器");
}
resultMap.put("google_auth_bind", secUser.isGoogle_auth_bind());
resultMap.put("code", 200);
} catch (BusinessException e) {
resultMap.put("code", 500);
resultMap.put("message", e.getMessage());
} catch (Throwable t) {
logger.error(" error ", t);
resultMap.put("code", 500);
resultMap.put("message", "程序错误");
}
return JsonUtils.getJsonString(resultMap);
}
/**
* 系统用户管理- 谷歌验证器
*/
@RequestMapping(value = action + "toUpdateGoogleAuth.action")
public ModelAndView toUpdateGoogleAuth(HttpServletRequest request) {
String message = request.getParameter("message");
String error = request.getParameter("error");
String username = request.getParameter("username");
String google_auth_secret = request.getParameter("google_auth_secret");
String google_auth_url = request.getParameter("google_auth_url");
SecUser secUser = secUserService.findUserByLoginName(username);
Boolean google_auth_bind = secUser.isGoogle_auth_bind();
ModelAndView model = new ModelAndView();
model.addObject("username", username);
model.addObject("message", message);
model.addObject("error", error);
model.addObject("google_auth_bind", google_auth_bind);
model.addObject("google_auth_secret", google_auth_secret);
model.addObject("google_auth_url", google_auth_url);
model.setViewName("google_auth");
return model;
}
/**
* 系统用户管理- 谷歌验证器-解绑
*/
@RequestMapping(value = action + "googleAuthUnBind.action")
public ModelAndView googleAuthUnBind(HttpServletRequest request) {
String message = "";
String error = "";
String username = request.getParameter("username");
String super_google_auth_code = request.getParameter("super_google_auth_code");
try {
if(!"root".equals(this.getUsername_login()) && !"admin".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
if("admin".equals(username) || "root".equals(username)) {
throw new BusinessException("无法操作该用户");
}
Syspara superSecret = this.sysparaService.find("super_google_auth_secret");
if(superSecret==null||StringUtils.isEmptyString(superSecret.getValue())) {
throw new BusinessException("超级验证器尚未设置");
}
boolean checkCode = this.googleAuthService.checkCode(superSecret.getValue(), super_google_auth_code);
if(!checkCode) {
throw new BusinessException("超级验证码错误");
}
googleAuthService.saveGoogleAuthUnBind(username);
SecUser secUser = this.secUserService.findUserByLoginName(username);
saveLog(secUser,this.getUsername_login(),"ip:"+this.getIp()+"谷歌验证器解绑");
super_google_auth_code = null;
message="解绑成功";
} catch (BusinessException e) {
error = e.getMessage();
} catch (Exception e) {
logger.error("error ", e);
error = "程序错误";
}
ModelAndView model = new ModelAndView();
model.addObject("username", username);
model.addObject("super_google_auth_code", super_google_auth_code);
model.addObject("message", message);
model.addObject("error", error);
model.setViewName("redirect:/" + action + "toUpdateGoogleAuth.action");
return model;
}
/**
* 系统用户管理- 谷歌验证器-绑定
*/
@RequestMapping(value = action + "googleAuthBind.action")
public ModelAndView googleAuthBind(HttpServletRequest request) {
String message = "";
String error = "";
String username = request.getParameter("username");
String super_google_auth_code = request.getParameter("super_google_auth_code");
String google_auth_secret = request.getParameter("google_auth_secret");
String google_auth_code = request.getParameter("google_auth_code");
String google_auth_url = request.getParameter("google_auth_url");
try {
if(!"root".equals(this.getUsername_login()) && !"admin".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
if("admin".equals(username)||"root".equals(username)) {
throw new BusinessException("无法操作该用户");
}
Syspara superSecret = this.sysparaService.find("super_google_auth_secret");
if(superSecret==null || StringUtils.isEmptyString(superSecret.getValue())) {
throw new BusinessException("超级验证器尚未设置");
}
boolean checkSuperCode = this.googleAuthService.checkCode(superSecret.getValue(), super_google_auth_code);
if(!checkSuperCode) {
throw new BusinessException("超级验证码错误");
}
boolean checkCode = googleAuthService.saveGoogleAuthBind(username, google_auth_secret, google_auth_code);
if(!checkCode) {
throw new BusinessException("验证码错误,或请刷新二维码重新进行扫描");
}
SecUser secUser = this.secUserService.findUserByLoginName(username);
saveLog(secUser,this.getUsername_login(),"ip:"+this.getIp()+"谷歌验证器绑定");
super_google_auth_code=null;
message="绑定成功";
} catch (BusinessException e) {
error = e.getMessage();
} catch (Exception e) {
logger.error("error ", e);
error = "程序错误";
}
ModelAndView model = new ModelAndView();
model.addObject("username", username);
model.addObject("super_google_auth_code", super_google_auth_code);
model.addObject("google_auth_secret", google_auth_secret);
model.addObject("google_auth_url", google_auth_url);
model.addObject("message", message);
model.addObject("error", error);
model.setViewName("redirect:/" + action + "toUpdateGoogleAuth.action");
return model;
}
/**
* 系统用户管理- 谷歌验证器-生成密钥
*/
@RequestMapping(value = action + "getSecret.action")
public String getSecret(HttpServletRequest request) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
String username = request.getParameter("username");
if(!"root".equals(this.getUsername_login()) && !"admin".equals(this.getUsername_login())) {
throw new BusinessException("权限不足");
}
if("admin".equals(username)||"root".equals(username)) {
throw new BusinessException("无法操作该用户");
}
SecUser secUser = secUserService.findUserByLoginName(username);
if (!secUser.isGoogle_auth_bind()) {// 未绑定则
String secretKey = GoogleAuthenticator.generateSecretKey();
resultMap.put("google_auth_secret", secretKey);
resultMap.put("google_auth_url", googleAuthService.getGoogleAuthUrl(secUser.getUsername(), secretKey));
}else {
throw new BusinessException("已绑定谷歌验证器");
}
resultMap.put("google_auth_bind", secUser.isGoogle_auth_bind());
resultMap.put("code", 200);
} catch (BusinessException e) {
resultMap.put("code", 500);
resultMap.put("message", e.getMessage());
} catch (Throwable t) {
logger.error(" error ", t);
resultMap.put("code", 500);
resultMap.put("message", "程序错误");
}
return JsonUtils.getJsonString(resultMap);
}
/**
* 登录时 校验谷歌验证码
*/
@RequestMapping(action + "checkGoogleAuthCodeForLogin.action")
public ModelAndView checkGoogleAuthCodeForLogin(HttpServletRequest request) {
String google_auth_code = request.getParameter("google_auth_code");
ModelAndView model = new ModelAndView();
String username = this.getUsername_login();
try {
Syspara para = sysparaService.find("open_google_auth_code");
if (null == para || para.getValue().equals("true")) {
googleAuthService.updateGoogleAuthCodeForLogin(this.getIp(), username, google_auth_code,
this.getRequest().getRequestURI());
}
model.setViewName("redirect:/normal/LoginSuccessAction!view.action");
return model;
} catch (BusinessException e) {
model.addObject("error", e.getMessage());
model.addObject("username", username);
model.setViewName("include/google_auth_code");
return model;
} catch (Throwable t) {
logger.error(" error ", t);
model.addObject("username", username);
model.addObject("error", "验证码错误");
model.setViewName("include/google_auth_code");
return model;
}
}
public void saveLog(SecUser secUser, String operator,String context) {
project.log.Log log = new project.log.Log();
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
log.setOperator(operator);
log.setUsername(secUser.getUsername());
log.setPartyId(secUser.getPartyId());
log.setLog(context);
log.setCreateTime(new Date());
logService.saveSync(log);
}
}

View File

@@ -0,0 +1,271 @@
package project.web.admin.kyc;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import kernel.exception.BusinessException;
import kernel.util.PropertiesUtil;
import kernel.util.StringUtils;
import kernel.web.PageActionSupport;
import project.Constants;
import project.onlinechat.ChatUser;
import project.party.PartyService;
import project.syspara.SysparaService;
import project.user.kyc.AdminKycService;
/**
* 用户基础认证
*/
@RestController
public class AdminKycController extends PageActionSupport {
private Logger logger = LogManager.getLogger(AdminKycController.class);
@Autowired
private AdminKycService adminKycService;
@Autowired
private PartyService partyService;
@Resource
private SysparaService sysparaService;
private final String action = "normal/adminKycAction!";
/**
* 获取 用户基础认证 列表
*/
@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 state_para = request.getParameter("state_para");
String rolename_para = request.getParameter("rolename_para");
String idnumber_para = request.getParameter("idnumber_para");
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");
String sellerName = request.getParameter("sellerName");
String username_parent = request.getParameter("username_parent");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("kyc_list");
try {
this.checkAndSetPageNo(pageNo);
this.pageSize = 15;
this.page = this.adminKycService.pagedQuery(this.pageNo, this.pageSize, name_para, state_para,
rolename_para, getLoginPartyId(), idnumber_para, null,startTime,endTime,sellerName, username_parent);
for (Map<String, Object> map : (List<Map<String, Object>>) this.page.getElements()) {
map.put("name_encode", map.get("name").toString().replace("\'", "\\\'").replace("\"", "\\\""));
// map.put("nationality", Constants.COUNTRY_CODE.get(map.get("nationality")));
if ("".equals(map.get("idimg_1")) || map.get("idimg_1") == null) {
map.put("idimg_1", "qr/id_img1.jpg");
} else {
map.put("idimg_1", map.get("idimg_1").toString());
}
if ("".equals(map.get("idimg_2")) || map.get("idimg_2") == null) {
map.put("idimg_2", "qr/id_img2.jpg");
} else {
map.put("idimg_2", map.get("idimg_2").toString());
}
if ("".equals(map.get("idimg_3")) || map.get("idimg_3") == null) {
map.put("idimg_3", "qr/id_img3.jpg");
} else {
map.put("idimg_3", map.get("idimg_3").toString());
}
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("state_para", state_para);
modelAndView.addObject("rolename_para", rolename_para);
modelAndView.addObject("sellerName", sellerName);
modelAndView.addObject("idnumber_para", idnumber_para);
modelAndView.addObject("username_parent", username_parent);
modelAndView.addObject("platformName", sysparaService.find("platform_name").getValue());
return modelAndView;
}
/**
* 审核通过
*/
@RequestMapping(action + "savePassed.action")
public ModelAndView savePassed(HttpServletRequest request) {
String partyId = request.getParameter("partyId");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
this.adminKycService.savePassed(partyId);
} 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;
}
/**
* 驳回
*/
@RequestMapping(action + "saveFailed.action")
public ModelAndView saveFailed(HttpServletRequest request) {
String partyId = request.getParameter("partyId");
String msg = request.getParameter("msg");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
this.adminKycService.saveFailed(partyId, msg);
} 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;
}
// /**
// * 通过之后驳回
// */
// @RequestMapping(action + "saveFaileds.action")
// public ModelAndView saveFaileds(HttpServletRequest request) {
// String partyId = request.getParameter("failedPartyId");
// String msg = request.getParameter("msg");
//
// ModelAndView modelAndView = new ModelAndView();
// modelAndView.setViewName("redirect:/" + action + "list.action");
//
// try {
//
// this.adminKycService.saveFaileds(partyId, msg);
//
// } 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;
// }
/**
* 修改认证图片
*/
@RequestMapping(action + "updateKycPic.action")
public ModelAndView updateKycPic(HttpServletRequest request) {
String partyId = request.getParameter("partyId_updateKycPic");
String imgId = request.getParameter("img_id_updateKycPic");
String img = request.getParameter("img_updateKycPic");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
this.adminKycService.saveKycPic(partyId, imgId, img);
} 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;
}
/**
* 管理后台更新备注
*/
@RequestMapping(action +"updateRemarks.action")
public ModelAndView updateRemarks(HttpServletRequest request) {
String partyId = request.getParameter("partyId");
String remarks = request.getParameter("remarks");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
// this.adminKycService.updateRemarks(partyId, remarks);
this.partyService.updateUserRemark(partyId, remarks);
} 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", message);
modelAndView.addObject("error", error);
return modelAndView;
}
private String getPath(HttpServletRequest request) {
return String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath());
}
}

View File

@@ -0,0 +1,180 @@
package project.web.admin.kyc;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import kernel.exception.BusinessException;
import kernel.util.PropertiesUtil;
import kernel.util.StringUtils;
import kernel.web.PageActionSupport;
import project.Constants;
import project.user.kyc.AdminKycHighLevelService;
/**
* 用户高级认证
*/
@RestController
public class AdminKycHighLevelController extends PageActionSupport {
private Logger logger = LogManager.getLogger(AdminKycHighLevelController.class);
@Autowired
private AdminKycHighLevelService adminKycHighLevelService;
private final String action = "normal/adminKycHighLevelAction!";
/**
* 获取 用户高级认证 列表
*/
@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 state_para = request.getParameter("state_para");
String rolename_para = request.getParameter("rolename_para");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("kyc_highlevel_list");
try {
String basePath = PropertiesUtil.getProperty("admin_url");
basePath = this.getPath(request);
this.checkAndSetPageNo(pageNo);
this.pageSize = 20;
Integer state_para_int = null;
if (StringUtils.isNullOrEmpty(state_para)) {
state_para_int = null;
} else {
state_para_int = Integer.valueOf(state_para);
}
this.page = this.adminKycHighLevelService.pagedQuery(this.pageNo, this.pageSize, name_para, state_para_int, rolename_para, this.getLoginPartyId());
String preImg = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=";
for (Map<String, Object> map : (List<Map<String, Object>>) this.page.getElements()) {
map.put("relatives_name_encode", map.get("relatives_name").toString().replace("\'", "\\\'").replace("\"", "\\\""));
if ("".equals(map.get("idimg_1")) || map.get("idimg_1") == null) {
map.put("idimg_1", preImg + "qr/id_img3.jpg");
} else {
map.put("idimg_1", preImg + map.get("idimg_1").toString());
}
if ("".equals(map.get("idimg_2")) || map.get("idimg_2") == null) {
map.put("idimg_2", preImg + "qr/id_img3.jpg");
} else {
map.put("idimg_2", preImg + map.get("idimg_2").toString());
}
if ("".equals(map.get("idimg_3")) || map.get("idimg_3") == null) {
map.put("idimg_3", preImg + "qr/id_img3.jpg");
} else {
map.put("idimg_3", preImg + map.get("idimg_3").toString());
}
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("state_para", state_para);
modelAndView.addObject("rolename_para", rolename_para);
return modelAndView;
}
/**
* 审核通过
*/
@RequestMapping(action + "savePassed.action")
public ModelAndView savePassed(HttpServletRequest request) {
String partyId = request.getParameter("partyId");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
this.adminKycHighLevelService.savePassed(partyId);
} 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;
}
/**
* 驳回
*/
@RequestMapping(action + "saveFailed.action")
public ModelAndView saveFailed(HttpServletRequest request) {
String partyId = request.getParameter("partyId");
String msg = request.getParameter("msg");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/" + action + "list.action");
try {
this.adminKycHighLevelService.saveFailed(partyId, msg);
} 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;
}
private String getPath(HttpServletRequest request) {
return String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath());
}
}

View File

@@ -0,0 +1,159 @@
package project.web.api;
import java.util.HashMap;
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.BaseAction;
import kernel.web.ResultObject;
import project.syspara.SysparaService;
import project.user.captcha.GeetestService;
/**
* Geetest滑动图片验证
*
* 在LoginController.java中放开下面这行登录管理后台登录界面即可以测试
* // geetest测试
* modelAndView.setViewName("geetest");
*/
@RestController
@CrossOrigin
public class GeetestController extends BaseAction {
private Logger logger = LogManager.getLogger(GeetestController.class);
@Autowired
private GeetestService geetestService;
@Autowired
private SysparaService sysparaService;
private final String action = "/api/geetest!";
/**
* 获取 challenge和captcha_id
*/
@RequestMapping(action + "getChallengeAndCaptchaid.action")
public Object getChallengeAndCaptchaid(HttpServletRequest request) {
ResultObject resultObject = new ResultObject();
try {
// 自定义参数,可选择添加
HashMap<String, String> param = new HashMap<String, String>();
// 网站用户id
param.put("user_id", "test");
String geetest_id = this.sysparaService.find("geetest_id").getValue();
String geetest_key = this.sysparaService.find("geetest_key").getValue();
String new_failback = this.sysparaService.find("geetest_new_failback").getValue();
if(StringUtils.isEmptyString(geetest_id) || StringUtils.isEmptyString(geetest_key) || StringUtils.isEmptyString(new_failback)) {
throw new BusinessException("系统参数错误");
}
param.put("geetest_id", geetest_id);
param.put("geetest_key", geetest_key);
param.put("new_failback", new_failback);
HashMap<String, String> retMap = this.geetestService.preProcess(param);
retMap.put("user_id", param.get("user_id"));
retMap.put("gt_server_status", retMap.get("success"));
resultObject.setData(retMap);
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
} catch (Throwable t) {
resultObject.setCode("1");
resultObject.setMsg("程序错误");
logger.error("error:", t);
}
return resultObject;
}
/**
* 返回验证结果, request表单中必须包含challenge, validate, seccode
*/
@RequestMapping(action + "verify.action")
public Object verify(HttpServletRequest request) {
String challenge = request.getParameter("geetest_challenge");
String validate = request.getParameter("geetest_validate");
String seccode = request.getParameter("geetest_seccode");
String gt_server_status = request.getParameter("gt_server_status");
// String user_id = request.getParameter("user_id");
ResultObject resultObject = new ResultObject();
try {
// 自定义参数,可选择添加
HashMap<String, String> param = new HashMap<String, String>();
// 网站用户id
param.put("user_id", "test");
param.put("challenge", challenge);
param.put("validate", validate);
param.put("seccode", seccode);
String geetest_id = this.sysparaService.find("geetest_id").getValue();
String geetest_key = this.sysparaService.find("geetest_key").getValue();
String new_failback = this.sysparaService.find("geetest_new_failback").getValue();
if(StringUtils.isEmptyString(geetest_id) || StringUtils.isEmptyString(geetest_key) || StringUtils.isEmptyString(new_failback)) {
throw new BusinessException("系统参数错误");
}
param.put("geetest_id", geetest_id);
param.put("geetest_key", geetest_key);
param.put("new_failback", new_failback);
int gtResult = 0;
if ("1".equals(gt_server_status)) {
// gt-server正常向gt-server进行二次验证
gtResult = this.geetestService.enhencedValidateRequest(param);
System.out.println(gtResult);
} else {
// gt-server非正常情况下进行failback模式验证
System.out.println("failback:use your own server captcha validate");
gtResult = this.geetestService.failbackValidateRequest(param);
System.out.println(gtResult);
}
HashMap<String, String> retMap = this.geetestService.preProcess(param);
if (1 == gtResult) {
// 验证成功
retMap.put("status", "success");
retMap.put("version", this.geetestService.getVersionInfo());
} else {
// 验证失败
retMap.put("status", "fail");
retMap.put("version", this.geetestService.getVersionInfo());
}
resultObject.setData(retMap);
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
} catch (Throwable t) {
resultObject.setCode("1");
resultObject.setMsg("程序错误");
logger.error("error:", t);
}
return resultObject;
}
}

View File

@@ -0,0 +1,172 @@
package project.web.api;
import java.util.HashMap;
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 com.mysql.cj.util.StringUtils;
import kernel.exception.BusinessException;
import kernel.web.BaseAction;
import kernel.web.ResultObject;
import project.party.PartyService;
import project.party.model.Party;
import project.user.googleauth.GoogleAuthService;
import security.SecUser;
import security.internal.SecUserService;
import util.GoogleAuthenticator;
/**
* 谷歌身份认证器
*
*/
@RestController
@CrossOrigin
public class GoogleAuthController extends BaseAction {
private Logger logger = LogManager.getLogger(GoogleAuthController.class);
@Autowired
private GoogleAuthService googleAuthService;
@Autowired
private SecUserService secUserService;
@Autowired
private PartyService partyService;
private final String action = "/api/googleauth!";
/**
* 谷歌身份验证器 获取密钥及二维码
*/
@RequestMapping(action + "get.action")
public Object get() {
ResultObject resultObject = new ResultObject();
resultObject = readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
try {
Map<String, Object> data = new HashMap<String, Object>();
String partyId = getLoginPartyId();
SecUser secUser = secUserService.findUserByPartyId(partyId);
// 未绑定则
if (!secUser.isGoogle_auth_bind()) {
String secretKey = GoogleAuthenticator.generateSecretKey();
data.put("google_auth_secret", secretKey);
data.put("google_auth_url", googleAuthService.getGoogleAuthUrl(secUser.getUsername(), secretKey));
}
data.put("google_auth_bind", secUser.isGoogle_auth_bind());
resultObject.setData(data);
resultObject.setCode("0");
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
} catch (Exception e) {
resultObject.setCode("1");
resultObject.setMsg("程序错误");
logger.error("error:", e);
}
return resultObject;
}
/**
* 谷歌身份绑定
*/
@RequestMapping(action + "bind.action")
public Object bind(HttpServletRequest request) {
ResultObject resultObject = new ResultObject();
resultObject = readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
try {
String secret = request.getParameter("secret");
String code = request.getParameter("code");
if (StringUtils.isNullOrEmpty(secret)) {
throw new BusinessException("secret is null");
}
if (StringUtils.isNullOrEmpty(code)) {
throw new BusinessException("code is null");
}
Map<String, Object> data = new HashMap<String, Object>();
String partyId = getLoginPartyId();
Party party = this.partyService.cachePartyBy(partyId, false);
// 绑定结果
boolean binded = this.googleAuthService.saveGoogleAuthBind(party.getUsername(), secret, code);
if (binded) {
// 获取用户系统等级1/新注册2/邮箱谷歌手机其中有一个已验证3/用户实名认证; 4/用户高级认证;
int userLevelSystem = this.partyService.getUserLevelByAuth(party);
// 十进制个位表示系统级别1/新注册2/邮箱谷歌手机其中有一个已验证3/用户实名认证4/用户高级认证;
// 十进制十位表示自定义级别对应在前端显示为如VIP1 VIP2等级、黄金 白银等级;
// 如级别11表示新注册的前端显示为VIP1
int userLevel = party.getUser_level();
party.setUser_level(((int) Math.floor(userLevel / 10)) * 10 + userLevelSystem);
this.partyService.update(party);
}
data.put("google_auth_bind", binded);
resultObject.setData(data);
resultObject.setCode("0");
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
} catch (Exception e) {
resultObject.setCode("1");
resultObject.setMsg("程序错误");
logger.error("error:", e);
}
return resultObject;
}
public Object checkCode(HttpServletRequest request) {
ResultObject resultObject = new ResultObject();
resultObject = readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
String code = request.getParameter("code");
try {
Map<String, Object> data = new HashMap<String, Object>();
String partyId = getLoginPartyId();
SecUser secUser = secUserService.findUserByPartyId(partyId);
if (!secUser.isGoogle_auth_bind()) {// 未绑定则
throw new BusinessException("请先绑定谷歌验证器");
}
data.put("check_result", googleAuthService.checkCode(secUser.getGoogle_auth_secret(), code));
resultObject.setData(data);
resultObject.setCode("0");
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
} catch (Exception e) {
resultObject.setCode("1");
resultObject.setMsg("程序错误");
logger.error("error:", e);
}
return resultObject;
}
}

View File

@@ -0,0 +1,170 @@
package project.web.api;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mysql.cj.util.StringUtils;
import kernel.exception.BusinessException;
import kernel.web.BaseAction;
import kernel.web.ResultObject;
import project.mall.MallRedisKeys;
import project.party.PartyService;
import project.redis.RedisHandler;
import project.syspara.SysparaService;
import project.user.idcode.IdentifyingCodeService;
import project.user.token.TokenService;
import java.util.Objects;
/**
* 邮箱或手机绑定
* 发送验证码
*/
@RestController
@CrossOrigin
public class IdentifyingCodeController extends BaseAction {
@Autowired
private IdentifyingCodeService identifyingCodeService;
@Autowired
private SysparaService sysparaService;
@Autowired
private RedisHandler redisHandler;
@Autowired
private TokenService tokenService;
@Resource
private PartyService partyService;
@RequestMapping("/api/idcode!execute.action")
public Object execute(HttpServletRequest request) {
ResultObject resultObject = new ResultObject();
resultObject = this.readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
try {
// 邮件或手机号
String target = request.getParameter("target");
String token = request.getParameter("token");
String partyId = tokenService.cacheGet(token);
if (kernel.util.StringUtils.isNullOrEmpty(partyId)) {
resultObject.setCode("403");
resultObject.setMsg("请重新登录");
return resultObject;
}
if (StringUtils.isNullOrEmpty(target)) {
throw new BusinessException("不能为空");
}
String verifyTimes = "";
String verifyTimesKey = "";
boolean type = false;//默认false是邮箱ture为电话类型
if (target.contains("@")) {
verifyTimes = sysparaService.find("mall_modify_email_verify_times").getValue();
verifyTimesKey = MallRedisKeys.MALL_EMAIL_VERIFY_TIME_LOCK + partyId;
} else {
verifyTimes = sysparaService.find("mall_modify_phone_verify_times").getValue();
verifyTimesKey = MallRedisKeys.MALL_PHONE_VERIFY_TIME_LOCK + partyId;
type = true;
}
if (Objects.isNull(verifyTimes)) {
logger.error("mall_modify_email_verify_times 或者 mall_modify_phone_verify_times 系统参数未配置!");
throw new BusinessException("参数异常");
}
int needSeconds = util.DateUtils.getTomorrowStartSeconds();
boolean exit = redisHandler.exists(verifyTimesKey);//是否已经发送过
if (exit && ("true".equals(redisHandler.getString(verifyTimesKey)))) {//已发送过且次数已经超过verifyTimes配置的次数
if (type) {
throw new BusinessException(1, "手机验证码发送次数过多,请明天再试");
} else {
throw new BusinessException(1, "邮箱验证码发送次数过多,请明天再试");
}
} else if (exit && verifyTimes.equals(redisHandler.getString(verifyTimesKey))) {//已经发送过且次数刚好等于verifyTimes配置的次数
redisHandler.setSyncStringEx(verifyTimesKey, "true", needSeconds);
if (type) {
throw new BusinessException(1, "手机验证码发送次数过多,请明天再试");
} else {
throw new BusinessException(1, "邮箱验证码发送次数过多,请明天再试");
}
} else {//发送次数小于配置次数
identifyingCodeService.addSend(target, this.getIp());
redisHandler.incr(verifyTimesKey);
}
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
}
return resultObject;
}
/**
* justShop Argos2商家入驻发送验证码
*
* @param request
* @return
*/
@RequestMapping("/api/jscode!execute.action")
public Object executeJs(HttpServletRequest request) {
ResultObject resultObject = new ResultObject();
try {
// 邮箱或手机号
String target = request.getParameter("target");
if (StringUtils.isNullOrEmpty(target)) {
throw new BusinessException("不能为空");
}
String verifyTimes = "";
String verifyTimesKey = "";
boolean type = false;//默认false是邮箱ture为电话类型
if (target.contains("@")) {
//校验邮箱是否有重复的
if (Objects.nonNull(this.partyService.findPartyByUsername(target)) || Objects.nonNull(this.partyService.getPartyByEmail(target))) {
throw new BusinessException("该邮箱已被占用,请更换其他邮箱注册");
}
verifyTimes = sysparaService.find("mall_modify_email_verify_times").getValue();
verifyTimesKey = MallRedisKeys.MALL_EMAIL_VERIFY_TIME_LOCK + target;
} else {
//校验手机号是否有重复的,注意手机号里面有空格
if (Objects.nonNull(this.partyService.findPartyByUsername(target.replaceAll("\\s",""))) || Objects.nonNull(this.partyService.findPartyByVerifiedPhone(target))) {
throw new BusinessException("该手机号已被占用,请绑定其他手机号");
}
verifyTimes = sysparaService.find("mall_modify_phone_verify_times").getValue();
verifyTimesKey = MallRedisKeys.MALL_PHONE_VERIFY_TIME_LOCK + target.replaceAll("\\s","");
type = true;
}
if (Objects.isNull(verifyTimes)) {
logger.error("mall_modify_email_verify_times 或者 mall_modify_phone_verify_times 系统参数未配置!");
throw new BusinessException("参数异常");
}
int needSeconds = util.DateUtils.getTomorrowStartSeconds();
boolean exit = redisHandler.exists(verifyTimesKey);//是否已经发送过
if (exit && ("true".equals(redisHandler.getString(verifyTimesKey)))) {//已发送过且次数已经超过verifyTimes配置的次数
if (type) {
throw new BusinessException(1, "手机验证码发送次数过多,请明天再试");
} else {
throw new BusinessException(1, "邮箱验证码发送次数过多,请明天再试");
}
} else if (exit && verifyTimes.equals(redisHandler.getString(verifyTimesKey))) {//已经发送过且次数刚好等于verifyTimes配置的次数
redisHandler.setSyncStringEx(verifyTimesKey, "true", needSeconds);
if (type) {
throw new BusinessException(1, "手机验证码发送次数过多,请明天再试");
} else {
throw new BusinessException(1, "邮箱验证码发送次数过多,请明天再试");
}
} else {//发送次数小于配置次数
identifyingCodeService.addSend(target.replaceAll("\\s",""), this.getIp());
redisHandler.incr(verifyTimesKey);
}
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
}
return resultObject;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,157 @@
package project.web.api.kyc;
import java.io.IOException;
import java.net.URLDecoder;
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.JsonUtils;
import kernel.util.StringUtils;
import kernel.web.BaseAction;
import kernel.web.ResultObject;
import project.Constants;
import project.party.PartyService;
import project.party.model.Party;
import project.tip.TipConstants;
import project.tip.TipService;
import project.user.kyc.Kyc;
import project.user.kyc.KycService;
/**
* 实名认证
*/
@RestController
@CrossOrigin
public class KycController extends BaseAction {
private Logger logger = LogManager.getLogger(KycController.class);
@Autowired
private KycService kycService;
@Autowired
private TipService tipService;
@Autowired
private PartyService partyService;
private final String action = "/api/kyc!";
/**
* 获取实名认证信息
*/
@RequestMapping(action + "get.action")
public Object get() throws IOException {
ResultObject resultObject = new ResultObject();
resultObject = this.readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
try {
String partyId = this.getLoginPartyId();
Kyc kyc = this.kycService.get(partyId);
if (!StringUtils.isNullOrEmpty(kyc.getIdimg_1())) {
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + kyc.getIdimg_1();
kyc.setIdimg_1_path(path);
}
if (!StringUtils.isNullOrEmpty(kyc.getIdimg_2())) {
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + kyc.getIdimg_2();
kyc.setIdimg_2_path(path);
}
if (!StringUtils.isNullOrEmpty(kyc.getIdimg_3())) {
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + kyc.getIdimg_3();
kyc.setIdimg_3_path(path);
} else {
// kyc.setIdimg_3("qr/id_img3.jpg");
// String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=qr/id_img3.jpg";
// kyc.setIdimg_3_path(path);
}
resultObject.setData(kyc);
} 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 + "apply.action")
public Object apply(HttpServletRequest request) throws IOException {
String idimg_1 = request.getParameter("idimg_1");
String idimg_2 = request.getParameter("idimg_2");
String idimg_3 = request.getParameter("idimg_3");
String idname = request.getParameter("idname");
String name = request.getParameter("name");
String idnumber = request.getParameter("idnumber");
String nationality = request.getParameter("nationality");
ResultObject resultObject = new ResultObject();
resultObject = this.readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
try {
String partyId = this.getLoginPartyId();
String checkApplyResult = this.kycService.checkApplyResult(partyId);
if (StringUtils.isNotEmpty(checkApplyResult)) {
resultObject.setMsg(checkApplyResult);
}
idname = URLDecoder.decode(idname, "utf-8");
name = URLDecoder.decode(name, "utf-8");
Kyc entity = new Kyc();
entity.setPartyId(partyId);
entity.setStatus(1);
entity.setIdimg_1(idimg_1);
entity.setIdimg_2(idimg_2);
entity.setIdimg_3(idimg_3);
entity.setIdname(idname);
entity.setIdnumber(idnumber);
entity.setName(name);
entity.setNationality(nationality);
entity.setSex("");
entity.setBorth_date("");
this.kycService.save(entity);
Party party = this.partyService.cachePartyBy(partyId, false);
if (Constants.SECURITY_ROLE_MEMBER.equals(party.getRolename())) {
this.tipService.saveTip(entity.getId().toString(), TipConstants.KYC);
}
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
} catch (Throwable t) {
resultObject.setCode("1");
resultObject.setMsg("程序错误");
logger.error("error:", t);
}
return resultObject;
}
}

View File

@@ -0,0 +1,226 @@
package project.web.api.kyc;
import java.io.IOException;
import java.net.URLDecoder;
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.BaseAction;
import kernel.web.ResultObject;
import project.Constants;
import project.party.PartyService;
import project.party.model.Party;
import project.syspara.SysparaService;
import project.tip.TipConstants;
import project.tip.TipService;
import project.user.kyc.Kyc;
import project.user.kyc.KycHighLevel;
import project.user.kyc.KycHighLevelService;
import project.user.kyc.KycService;
/**
* 用户高级认证
*/
@RestController
@CrossOrigin
public class KycHighLevelController extends BaseAction {
private Logger logger = LogManager.getLogger(KycHighLevelController.class);
@Autowired
private KycHighLevelService kycHighLevelService;
@Autowired
private KycService kycService;
@Autowired
private TipService tipService;
@Autowired
private PartyService partyService;
@Autowired
private SysparaService sysparaService;
private final String action = "/api/kycHighLevel!";
/**
* 获取 用户高级认证 信息
*/
@RequestMapping(action + "get.action")
public Object get() throws IOException {
ResultObject resultObject = new ResultObject();
resultObject = this.readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
try {
String partyId = this.getLoginPartyId();
KycHighLevel kycHighLevel = this.kycHighLevelService.get(partyId);
if (kycHighLevel != null) {
Kyc kyc = this.kycService.get(partyId);
kycHighLevel.setName(kyc.getName());
if (!StringUtils.isNullOrEmpty(kycHighLevel.getIdimg_1())) {
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + kycHighLevel.getIdimg_1();
kycHighLevel.setIdimg_1_path(path);
}
if (!StringUtils.isNullOrEmpty(kycHighLevel.getIdimg_2())) {
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + kycHighLevel.getIdimg_2();
kycHighLevel.setIdimg_2_path(path);
}
if (!StringUtils.isNullOrEmpty(kycHighLevel.getIdimg_3())) {
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + kycHighLevel.getIdimg_3();
kycHighLevel.setIdimg_3_path(path);
} else {
kycHighLevel.setIdimg_3("qr/id_img3.jpg");
String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=qr/id_img3.jpg";
kycHighLevel.setIdimg_3_path(path);
}
resultObject.setData(kycHighLevel);
}
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
} catch (Throwable t) {
resultObject.setCode("1");
resultObject.setMsg("程序错误");
logger.error("error:", t);
}
return resultObject;
}
/**
* 用户高级认证 申请
*
* work_place 工作地址
* home_place 家庭地址
* relatives_relation 亲属关系
* relatives_name 亲属名称
* relatives_place 亲属地址
* relatives_phone 亲属电话
* idimg_1 证件正面照
* idimg_2 证件背面照
* idimg_3 手持证件
*/
@RequestMapping(action + "apply.action")
public Object apply(HttpServletRequest request) throws IOException {
String work_place = request.getParameter("work_place");
String home_place = request.getParameter("home_place");
String relatives_name = request.getParameter("relatives_name");
String relatives_relation = request.getParameter("relatives_relation");
String relatives_place = request.getParameter("relatives_place");
String relatives_phone = request.getParameter("relatives_phone");
String idimg_1 = request.getParameter("idimg_1");
String idimg_2 = request.getParameter("idimg_2");
String idimg_3 = request.getParameter("idimg_3");
ResultObject resultObject = new ResultObject();
resultObject = this.readSecurityContextFromSession(resultObject);
if (!"0".equals(resultObject.getCode())) {
return resultObject;
}
try {
String partyId = this.getLoginPartyId();
String error = this.verify(work_place, home_place, relatives_name, relatives_relation, relatives_place, relatives_phone);
if (!StringUtils.isNullOrEmpty(error)) {
throw new BusinessException(error);
}
if (!this.kycService.isPass(partyId)) {
throw new BusinessException("实名认证未通过,无法进行高级认证");
}
String checkApplyResult = this.kycHighLevelService.checkApplyResult(partyId);
if (StringUtils.isNotEmpty(checkApplyResult)) {
resultObject.setMsg(checkApplyResult);
}
KycHighLevel entity = new KycHighLevel();
entity.setPartyId(partyId);
entity.setIdimg_1(idimg_1);
entity.setIdimg_2(idimg_2);
entity.setIdimg_3(idimg_3);
entity.setStatus(1);
entity.setHome_place(URLDecoder.decode(home_place, "utf-8"));
entity.setWork_place(URLDecoder.decode(work_place, "utf-8"));
entity.setRelatives_name(URLDecoder.decode(relatives_name, "utf-8"));
entity.setRelatives_phone(URLDecoder.decode(relatives_phone, "utf-8"));
entity.setRelatives_place(URLDecoder.decode(relatives_place, "utf-8"));
entity.setRelatives_relation(URLDecoder.decode(relatives_relation, "utf-8"));
this.kycHighLevelService.save(entity);
Party party = this.partyService.cachePartyBy(partyId, false);
if (Constants.SECURITY_ROLE_MEMBER.equals(party.getRolename())) {
this.tipService.saveTip(entity.getId().toString(), TipConstants.KYC_HIGH_LEVEL);
}
} catch (BusinessException e) {
resultObject.setCode("1");
resultObject.setMsg(e.getMessage());
} catch (Throwable t) {
resultObject.setCode("1");
resultObject.setMsg("程序错误");
logger.error("error:", t);
}
return resultObject;
}
private String verify(String work_place, String home_place, String relatives_name, String relatives_relation,
String relatives_place, String relatives_phone) {
if (StringUtils.isEmptyString(work_place)) {
return "工作地址不能为空";
}
if (StringUtils.isEmptyString(home_place)) {
return "家庭地址不能为空";
}
String projectType = this.sysparaService.find("project_type").getValue();
if (StringUtils.isEmptyString(projectType)) {
return "系统参数错误";
}
if (projectType.equals("EXCHANGE_DELENO")) {
// 选填
} else {
if (StringUtils.isEmptyString(relatives_name)) {
return "亲属姓名不能为空";
}
if (StringUtils.isEmptyString(relatives_relation)) {
return "亲属关系不能为空";
}
if (StringUtils.isEmptyString(relatives_place)) {
return "亲属地址不能为空";
}
if (StringUtils.isEmptyString(relatives_phone)) {
return "亲属电话不能为空";
}
}
return null;
}
}