手机号授权: 后台查询及审核功能实现
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
package com.accompany.admin.service.user;
|
||||
|
||||
import com.accompany.admin.service.base.BaseService;
|
||||
import com.accompany.business.model.skillcard.SkillCardAudioVerify;
|
||||
import com.accompany.business.vo.skillcard.SkillCardAuidoVerifyVo;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.model.phone.PhoneAuthApplyRecord;
|
||||
import com.accompany.core.service.common.JedisLockService;
|
||||
import com.accompany.core.service.phone.PhoneAuthApplyRecordService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class PhoneAuthApplyRecordAdiminService extends BaseService {
|
||||
|
||||
@Autowired
|
||||
private PhoneAuthApplyRecordService phoneAuthApplyRecordService;
|
||||
@Autowired
|
||||
private JedisLockService jedisLockService;
|
||||
|
||||
public PageInfo<PhoneAuthApplyRecord> getPageList(Integer pageNumber, Integer pageSize, String phone, String authCode, Date beginTime, Date endTime, Byte status) {
|
||||
PageInfo<PhoneAuthApplyRecord> result = new PageInfo<>();
|
||||
LambdaQueryWrapper<PhoneAuthApplyRecord> queryWrapper = getQueryWrapper(phone, authCode,beginTime,endTime,status);
|
||||
|
||||
PageHelper.startPage(pageNumber, pageSize);
|
||||
List<PhoneAuthApplyRecord> records = phoneAuthApplyRecordService.list(queryWrapper);
|
||||
PageInfo<PhoneAuthApplyRecord> info = new PageInfo<>(records);
|
||||
result.setTotal(info.getTotal());
|
||||
if (CollectionUtils.isEmpty(records)){
|
||||
result.setList(new ArrayList<>());
|
||||
}else{
|
||||
result.setList(records);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<PhoneAuthApplyRecord> getQueryWrapper(String phone, String authCode, Date beginTime, Date endTime, Byte status) {
|
||||
LambdaQueryWrapper<PhoneAuthApplyRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (beginTime != null){
|
||||
queryWrapper.ge(PhoneAuthApplyRecord::getCreateTime, beginTime);
|
||||
}
|
||||
if (endTime != null){
|
||||
queryWrapper.le(PhoneAuthApplyRecord::getCreateTime, endTime);
|
||||
}
|
||||
if (status != null){
|
||||
queryWrapper.eq(PhoneAuthApplyRecord::getStatus, status);
|
||||
}
|
||||
if (StringUtils.isNotBlank(phone)){
|
||||
queryWrapper.eq(PhoneAuthApplyRecord::getPhone, phone);
|
||||
}
|
||||
if (StringUtils.isNotBlank(authCode)){
|
||||
queryWrapper.eq(PhoneAuthApplyRecord::getAuthCode, authCode);
|
||||
}
|
||||
queryWrapper.orderByDesc(PhoneAuthApplyRecord::getCreateTime);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
public int changeStatus(Long id, Byte status, String adminName) {
|
||||
if (status == null || id == null) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
if (status <= 0 || status > 2) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
|
||||
PhoneAuthApplyRecord applyRecord = phoneAuthApplyRecordService.getById(id);
|
||||
String lockeKey = RedisKey.phone_auth_apply_lock.getKey(applyRecord.getPhone());
|
||||
String lockVal = jedisLockService.lock(lockeKey);
|
||||
if (StringUtils.isEmpty(lockVal)) {
|
||||
throw new ServiceException(BusiStatus.SERVER_BUSY);
|
||||
}
|
||||
try {
|
||||
if (applyRecord == null) {
|
||||
throw new ServiceException("该记录不存在或已删除");
|
||||
}
|
||||
if (applyRecord.getStatus() != 0) {
|
||||
throw new ServiceException("该记录已审核!请刷新后重试");
|
||||
}
|
||||
|
||||
PhoneAuthApplyRecord record = phoneAuthApplyRecordService.getById(id);
|
||||
record.setStatus(status);
|
||||
record.setOperator(adminName);
|
||||
record.setUpdateTime(new Date());
|
||||
record.setHasUsed((byte) 0);
|
||||
phoneAuthApplyRecordService.updateById(record);
|
||||
|
||||
// todo 发送短信
|
||||
|
||||
return 1;
|
||||
} finally {
|
||||
jedisLockService.unlock(lockeKey,lockVal);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package com.accompany.admin.controller.user;
|
||||
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.service.user.PhoneAuthApplyRecordAdiminService;
|
||||
import com.accompany.business.dto.SkillCardAuidoVerifyDto;
|
||||
import com.accompany.business.vo.skillcard.SkillCardAuidoVerifyVo;
|
||||
import com.accompany.core.model.phone.PhoneAuthApplyRecord;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/phone/auth/apply")
|
||||
public class PhoneAuthApplyRecordAdminController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private PhoneAuthApplyRecordAdiminService phoneAuthApplyRecordAdiminService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public void list(Integer pageNumber, Integer pageSize,String phone, String authCode, Date beginDate, Date endDate, Byte status){
|
||||
PageInfo<PhoneAuthApplyRecord> voPageInfo = phoneAuthApplyRecordAdiminService.getPageList(pageNumber,pageSize,phone,authCode,beginDate,endDate,status);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("total", voPageInfo.getTotal());
|
||||
jsonObject.put("rows", voPageInfo.getList());
|
||||
writeJson(jsonObject.toJSONString());
|
||||
}
|
||||
|
||||
@RequestMapping("/changeStatus")
|
||||
public void changeStatus(Long id, Byte status){
|
||||
if(id == null || id == 0 || status == null) {
|
||||
writeJson(false, "参数有误");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int result = phoneAuthApplyRecordAdiminService.changeStatus(id, status, getAdminName());
|
||||
if(result>0) {
|
||||
writeJson(true,String.valueOf(result));
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to change dynamic status, Cause by:", e);
|
||||
writeJson(false, e.getMessage());
|
||||
}
|
||||
writeJson(false, "操作失败");
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,298 @@
|
||||
<section class="content">
|
||||
<div class="box box-primary">
|
||||
<div class="box-body">
|
||||
<!-- Content Header (Page header) -->
|
||||
<section class="content-header">
|
||||
<h1 id="itemTitle"></h1>
|
||||
</section>
|
||||
<!-- .content -->
|
||||
<div id="table"></div>
|
||||
<div id="toolbar" style="height: auto;">
|
||||
<form id="searchForm" action="/admin/phone/auth/apply/exportRecord.action" class="col-sm-12" target="_blank">
|
||||
<div class="col-sm-12">
|
||||
<label for="phone" class="col-sm-1 control-label">手机号</label>
|
||||
<div class="col-sm-2"><input type="text" class="form-control" name="phone" id="phone"></div>
|
||||
|
||||
<label for="authCode" class="col-sm-1 control-label">授权码</label>
|
||||
<div class="col-sm-2"><input type="text" class="form-control" name="authCode" id="authCode"></div>
|
||||
|
||||
<label for="status" class="col-sm-1 control-label">授权状态</label>
|
||||
<div class="col-sm-2">
|
||||
<select name="status" id="status" data-btn-class="btn-warning" class="form-control">
|
||||
<option value="" selected="selected">全部</option>
|
||||
<option value="0">待审核</option>
|
||||
<option value="1">通过</option>
|
||||
<option value="2">拒绝</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label class="col-sm-1 control-label">申请时间</label>
|
||||
<div class="col-sm-2"><input type="text" class="form-control" name="beginDate"
|
||||
id="beginDate"></div><span class="col-sm-1">至</span>
|
||||
<div class="col-sm-2"><input type="text" class="form-control" name="endDate" id="endDate"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<div class="col-sm-12">
|
||||
<button id="btnSearch" class="btn btn-default">
|
||||
<i class="glyphicon glyphicon-search"></i>查询
|
||||
</button>
|
||||
<button id="btnReset" class="btn btn-default">
|
||||
<i class="glyphicon glyphicon-remove"></i>重置
|
||||
</button>
|
||||
<button id="exportBtn" class="btn btn-default">
|
||||
<i class="glyphicon glyphicon-remove"></i>导出
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
var picker1 = $("#beginDate").datetimepicker({
|
||||
format: 'yyyy-mm-dd hh:ii:00',
|
||||
autoclose: true,
|
||||
todayBtn: true
|
||||
});
|
||||
var picker2 = $("#endDate").datetimepicker({
|
||||
format: 'yyyy-mm-dd hh:ii:00',
|
||||
autoclose: true,
|
||||
todayBtn: true
|
||||
});
|
||||
// picker1.on('changeDate', function () {
|
||||
// var date = $('#beginDate').datetimepicker('getDate');
|
||||
// picker2.datetimepicker('setStartDate', date);
|
||||
// });
|
||||
// picker2.on('changeDate', function () {
|
||||
// var date = $('#endDate').datetimepicker('getDate');
|
||||
// picker1.datetimepicker('setEndDate', date);
|
||||
// });
|
||||
$(function () {
|
||||
$('#table').bootstrapTable('destroy');
|
||||
setStatusSelectOption();
|
||||
$('#table').bootstrapTable({
|
||||
columns: [
|
||||
|
||||
{field: 'phoneAreaCode', title: '申请区号', align: 'center', width: '5%',
|
||||
formatter: function (val, row, index) {
|
||||
return "+ " + val;
|
||||
}},
|
||||
{field: 'phone', title: '申请手机号', align: 'center', width: '5%'},
|
||||
{field: 'authCode', title: '授权码', align: 'center', width: '5%'},
|
||||
{
|
||||
field: 'status',
|
||||
title: '授权状态',
|
||||
align: 'center',
|
||||
width: '5%',
|
||||
formatter: function (val, row, index) {
|
||||
|
||||
if (val == 1){
|
||||
return "通过";
|
||||
}else if (val == 2){
|
||||
return "拒绝";
|
||||
} else {
|
||||
return "未处理";
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '申请时间',
|
||||
align: 'center',
|
||||
width: '5%',
|
||||
valign: 'middle',
|
||||
formatter: function (val, row, index) {
|
||||
if (val) {
|
||||
var date = new Date(val);
|
||||
return date.format("yyyy-MM-dd hh:mm:ss");
|
||||
} else {
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
},
|
||||
{field: 'remark', title: '备注', align: 'center', width: '5%'},
|
||||
{field: 'operator', title: '操作人', align: 'center', width: '5%'},
|
||||
{
|
||||
field: 'operationTime',
|
||||
title: '更新授权时间',
|
||||
align: 'center',
|
||||
width: '5%',
|
||||
valign: 'middle',
|
||||
formatter: function (val, row, index) {
|
||||
if (val) {
|
||||
var date = new Date(val);
|
||||
return date.format("yyyy-MM-dd hh:mm:ss");
|
||||
} else {
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'id',
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
width: '5%',
|
||||
formatter: function (val, row, index) {
|
||||
var pass = '<button class="btn btn-sm btn-primary opt-pass" data-id=' + val + ' data-status=1>通 过</button>';
|
||||
var noPass = '<button class="btn btn-sm btn-danger opt-not-pass" data-id=' + val + ' data-status=2>不通过</button>';
|
||||
var remark = '<button class="btn btn-sm btn-primary opt-remark" data-id=' + val + ' data-status=3>编辑备注</button>';
|
||||
// var unshelve = '<button class="btn btn-sm btn-danger opt-not-pass" data-id=' + val + ' data-status=5>下 架</button>';
|
||||
if (row.status == 0){
|
||||
return pass + '</br>' + noPass + '</br>' + remark;
|
||||
} else {
|
||||
return remark;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
],
|
||||
cache: false,
|
||||
striped: true,
|
||||
showRefresh: false,
|
||||
pageSize: 10,
|
||||
pagination: true,
|
||||
pageList: [10,20, 50, 100],
|
||||
search: false,
|
||||
sidePagination: "server", //表示服务端请求
|
||||
//设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
|
||||
//设置为limit可以获取limit, offset, search, sort, order
|
||||
queryParamsType: "-",
|
||||
queryParams: function queryParams(params) { //设置查询参数
|
||||
var param = {
|
||||
pageNumber: params.pageNumber,
|
||||
pageSize: params.pageSize,
|
||||
phone: $('#phone').val(),
|
||||
authCode: $('#authCode').val(),
|
||||
status: $('#status').val(),
|
||||
beginDate: $('#beginDate').val(),
|
||||
endDate: $('#endDate').val(),
|
||||
};
|
||||
return param;
|
||||
},
|
||||
toolbar: '#toolbar',
|
||||
url: '/admin/phone/auth/apply/list.action',
|
||||
onLoadSuccess: function () { //加载成功时执行
|
||||
console.log("load success");
|
||||
},
|
||||
onLoadError: function () { //加载失败时执行
|
||||
console.log("load fail");
|
||||
}
|
||||
});
|
||||
|
||||
// 查询刷新
|
||||
$('#btnSearch').on('click', function () {
|
||||
TableHelper.doRefresh('#table');
|
||||
});
|
||||
|
||||
//重置
|
||||
$('#btnReset').on('click', function () {
|
||||
$('#phone').val("");
|
||||
$('#authCode').val("");
|
||||
$('#status').val("");
|
||||
$('#beginDate').val("");
|
||||
$('#endDate').val("");
|
||||
});
|
||||
|
||||
//审核不通过/下架弹框
|
||||
$("#table").on("click", '.opt-not-pass', function () {
|
||||
|
||||
var id = $(this).attr("data-id");
|
||||
var status = $(this).attr("data-status");
|
||||
if(id == 'undefined'){
|
||||
$("#tipMsg").text("id参数有误");
|
||||
$("#tipModal").modal('show');
|
||||
return;
|
||||
}
|
||||
if(status == 'undefined'){
|
||||
$("#tipMsg").text("状态参数有误");
|
||||
$("#tipModal").modal('show');
|
||||
return;
|
||||
}
|
||||
|
||||
var text = "不通过";
|
||||
if (confirm("你确认【"+ text +"】该授权码申请吗?")) {
|
||||
verify(text, id, status);
|
||||
}
|
||||
});
|
||||
|
||||
$("#table").on("click", '.opt-pass', function () {
|
||||
|
||||
var id = $(this).attr("data-id");
|
||||
var status = $(this).attr("data-status");
|
||||
if(id == 'undefined'){
|
||||
$("#tipMsg").text("id参数有误");
|
||||
$("#tipModal").modal('show');
|
||||
return;
|
||||
}
|
||||
if(status == 'undefined'){
|
||||
$("#tipMsg").text("状态参数有误");
|
||||
$("#tipModal").modal('show');
|
||||
return;
|
||||
}
|
||||
var text = "通过";
|
||||
if (confirm("你确认【"+ text +"】该授权码申请吗?")) {
|
||||
verify(text, id, status);
|
||||
}
|
||||
});
|
||||
|
||||
// 导出EXCEL
|
||||
$('#exportBtn').on('click', function () {
|
||||
$("#searchForm").submit();
|
||||
});
|
||||
});
|
||||
//判断空值
|
||||
function isEmpty(data) {
|
||||
if (data == null || data == undefined || data == ""){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//审核
|
||||
function verify(text, id, status){
|
||||
//if (confirm("你确认【"+ text + "】该动态吗?")) {
|
||||
// showLoading();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "/admin/phone/auth/apply/changeStatus.action",
|
||||
data: {
|
||||
audioVerifyId: id,
|
||||
status: status
|
||||
},
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
// hideLoading();
|
||||
// if (status == 2 || status == 5) {
|
||||
// $("#notPassModal").modal('hide');
|
||||
// }
|
||||
if(json.success == 'true'){
|
||||
$("#tipMsg").text("操作成功");
|
||||
$("#tipModal").modal('show');
|
||||
TableHelper.doRefresh("#table");
|
||||
} else {
|
||||
$("#tipMsg").text(json.msg);
|
||||
$("#tipModal").modal('show');
|
||||
}
|
||||
}
|
||||
});
|
||||
//}
|
||||
}
|
||||
|
||||
function setStatusSelectOption(){
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: "/admin/phone/auth/apply/getStatus.action",
|
||||
success: function (json) {
|
||||
if(json != null && json != undefined) {
|
||||
var rows = json;
|
||||
for(var i = 0; i < rows.length; i++) {
|
||||
$('#status').append('<option value="'+rows[i].value+'">'+ rows[i].key +'</option>');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
Reference in New Issue
Block a user