手机号授权:后台审核发送短息通知、数据导出功能
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.accompany.admin.service.user;
|
||||
|
||||
import com.accompany.admin.service.base.BaseService;
|
||||
import com.accompany.admin.vo.PhoneAuthApplyRecordExcelVo;
|
||||
import com.accompany.business.model.skillcard.SkillCardAudioVerify;
|
||||
import com.accompany.business.vo.skillcard.SkillCardAuidoVerifyVo;
|
||||
import com.accompany.common.constant.Constant;
|
||||
@@ -10,19 +11,30 @@ 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.SysConfService;
|
||||
import com.accompany.core.service.common.JedisLockService;
|
||||
import com.accompany.core.service.phone.PhoneAuthApplyRecordService;
|
||||
import com.accompany.sms.common.BeanMapper;
|
||||
import com.accompany.sms.config.AliyunSmsConfig;
|
||||
import com.accompany.sms.result.AliyunSmsRet;
|
||||
import com.accompany.sms.service.AliyunSmsService;
|
||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
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 com.google.common.collect.ImmutableMap;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
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.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -32,6 +44,10 @@ public class PhoneAuthApplyRecordAdiminService extends BaseService {
|
||||
private PhoneAuthApplyRecordService phoneAuthApplyRecordService;
|
||||
@Autowired
|
||||
private JedisLockService jedisLockService;
|
||||
@Autowired
|
||||
private AliyunSmsService aliyunSmsService;
|
||||
@Autowired
|
||||
private AliyunSmsConfig aliyunSmsConfig;
|
||||
|
||||
public PageInfo<PhoneAuthApplyRecord> getPageList(Integer pageNumber, Integer pageSize, String phone, String authCode, Date beginTime, Date endTime, Byte status) {
|
||||
PageInfo<PhoneAuthApplyRecord> result = new PageInfo<>();
|
||||
@@ -74,21 +90,22 @@ public class PhoneAuthApplyRecordAdiminService extends BaseService {
|
||||
if (status == null || id == null) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
if (status <= 0 || status > 2) {
|
||||
if (status < 0 || status > 3) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
|
||||
PhoneAuthApplyRecord applyRecord = phoneAuthApplyRecordService.getById(id);
|
||||
if (applyRecord == null) {
|
||||
throw new ServiceException("该记录不存在或已删除");
|
||||
}
|
||||
|
||||
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) {
|
||||
if (applyRecord.getStatus() != Constant.PhoneAuthApplyStatus.wait_audit) {
|
||||
throw new ServiceException("该记录已审核!请刷新后重试");
|
||||
}
|
||||
|
||||
@@ -99,14 +116,50 @@ public class PhoneAuthApplyRecordAdiminService extends BaseService {
|
||||
record.setHasUsed((byte) 0);
|
||||
phoneAuthApplyRecordService.updateById(record);
|
||||
|
||||
// todo 发送短信
|
||||
|
||||
sendSms(record);
|
||||
return 1;
|
||||
} finally {
|
||||
jedisLockService.unlock(lockeKey,lockVal);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSms(PhoneAuthApplyRecord record) {
|
||||
|
||||
Byte status = record.getStatus();
|
||||
|
||||
String templateCode = null;
|
||||
Map<String, Object> param = com.google.common.collect.Maps.newHashMap();
|
||||
String phone = record.getPhone();
|
||||
String phoneAreaCode = record.getPhoneAreaCode();
|
||||
// 区号+手机号
|
||||
String realPhone = phoneAreaCode + phone;
|
||||
// 短信内容显示的手机号
|
||||
String msgPhone = "+" + phoneAreaCode + " " + StringUtils.maskPhone(phoneAreaCode, realPhone);
|
||||
if (Constant.PhoneAuthApplyStatus.pass.equals(status)) {
|
||||
templateCode = aliyunSmsConfig.getAuthSuccessTemplateCode();
|
||||
|
||||
param.put("authorization", record.getAuthCode());
|
||||
}
|
||||
|
||||
if (Constant.PhoneAuthApplyStatus.fail.equals(status)) {
|
||||
templateCode = aliyunSmsConfig.getAuthFailTemplateCode();
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(templateCode)) {
|
||||
logger.info("sendSms");
|
||||
|
||||
AliyunSmsRet aliyunSmsRet = null;
|
||||
try {
|
||||
param.put("number", msgPhone);
|
||||
aliyunSmsRet = aliyunSmsService.sendSms(realPhone, templateCode, aliyunSmsConfig.getSignName(), param);
|
||||
logger.info("sendSmsCode to {},code ={}, response msg:{}", realPhone, templateCode, gson.toJson(aliyunSmsRet));
|
||||
} catch (ClientException e) {
|
||||
logger.error("发送短信出现异常",e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void remark(Long id, String message, String adminName) {
|
||||
PhoneAuthApplyRecord record = phoneAuthApplyRecordService.getById(id);
|
||||
if (record == null) {
|
||||
@@ -116,4 +169,21 @@ public class PhoneAuthApplyRecordAdiminService extends BaseService {
|
||||
record.setOperator(adminName);
|
||||
phoneAuthApplyRecordService.saveOrUpdate(record);
|
||||
}
|
||||
|
||||
public List<PhoneAuthApplyRecordExcelVo> export(String phone, String authCode, Date beginTime, Date endTime, Byte status) {
|
||||
LambdaQueryWrapper<PhoneAuthApplyRecord> queryWrapper = getQueryWrapper(phone, authCode,beginTime,endTime,status);
|
||||
|
||||
List<PhoneAuthApplyRecordExcelVo> vos = new ArrayList<>();
|
||||
List<PhoneAuthApplyRecord> records = phoneAuthApplyRecordService.list(queryWrapper);
|
||||
if (CollectionUtils.isNotEmpty(records)) {
|
||||
for (PhoneAuthApplyRecord record : records) {
|
||||
PhoneAuthApplyRecordExcelVo vo = new PhoneAuthApplyRecordExcelVo();
|
||||
BeanUtils.copyProperties(record,vo);
|
||||
|
||||
vos.add(vo);
|
||||
}
|
||||
}
|
||||
|
||||
return vos;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,31 @@
|
||||
package com.accompany.admin.vo;
|
||||
|
||||
import com.accompany.common.annotation.FieldComment;
|
||||
import com.accompany.core.vo.BaseVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class PhoneAuthApplyRecordExcelVo extends BaseVo {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@FieldComment("id")
|
||||
public Long id;
|
||||
@FieldComment("申请区号")
|
||||
public String phoneAreaCode;
|
||||
@FieldComment("申请手机号")
|
||||
public String phone;
|
||||
@FieldComment("授权码")
|
||||
public String authCode;
|
||||
@FieldComment("授权状态")
|
||||
public Byte status;
|
||||
@FieldComment("申请时间")
|
||||
public Date createTime;
|
||||
@FieldComment("备注")
|
||||
public String remark;
|
||||
@FieldComment("操作人")
|
||||
public String operator;
|
||||
@FieldComment("更新授权时间")
|
||||
public Date updateTime;
|
||||
}
|
@@ -3,17 +3,23 @@ package com.accompany.admin.controller.user;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.service.user.PhoneAuthApplyRecordAdiminService;
|
||||
import com.accompany.admin.util.StringUtil;
|
||||
import com.accompany.admin.vo.PhoneAuthApplyRecordExcelVo;
|
||||
import com.accompany.business.dto.SkillCardAuidoVerifyDto;
|
||||
import com.accompany.business.vo.skillcard.SkillCardAuidoVerifyVo;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.model.phone.PhoneAuthApplyRecord;
|
||||
import com.accompany.core.util.ExcelUtils;
|
||||
import com.accompany.payment.vo.ChargeRecordStatisVo;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/phone/auth/apply")
|
||||
@@ -31,6 +37,15 @@ public class PhoneAuthApplyRecordAdminController extends BaseController {
|
||||
writeJson(jsonObject.toJSONString());
|
||||
}
|
||||
|
||||
@RequestMapping("/exportRecord")
|
||||
public void list(String phone, String authCode, Date beginDate, Date endDate, Byte status, HttpServletResponse response) throws Exception {
|
||||
List<PhoneAuthApplyRecordExcelVo> statisticsList = phoneAuthApplyRecordAdiminService.export(phone,authCode,beginDate,endDate,status);
|
||||
// 设置下载时客户端Excel的名称
|
||||
String filename = "statistics_phone_auth.xls";
|
||||
List<String> fields = Arrays.asList("id","phoneAreaCode","phone","authCode","status","createTime","remark","operator","updateTime");
|
||||
ExcelUtils.exportExcel("手机号授权注册统计数据", filename, fields, statisticsList, response);
|
||||
}
|
||||
|
||||
@RequestMapping("/changeStatus")
|
||||
public void changeStatus(Long id, Byte status){
|
||||
if(id == null || id == 0 || status == null) {
|
||||
|
@@ -165,11 +165,11 @@
|
||||
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-remark=' + row.remark + ' + data-id=' + val + ' data-status=3>编辑备注</button>';
|
||||
var pass = '<button class="btn btn-sm btn-primary opt-pass" data-id=' + val + ' data-status=2>通 过</button>';
|
||||
var noPass = '<button class="btn btn-sm btn-danger opt-not-pass" data-id=' + val + ' data-status=3>不通过</button>';
|
||||
var remark = '<button class="btn btn-sm btn-primary opt-remark" data-remark=' + row.remark + ' + data-id=' + val + ' data-status=4>编辑备注</button>';
|
||||
// var unshelve = '<button class="btn btn-sm btn-danger opt-not-pass" data-id=' + val + ' data-status=5>下 架</button>';
|
||||
if (row.status == 0){
|
||||
if (row.status == 1){
|
||||
return pass + '</br>' + noPass + '</br>' + remark;
|
||||
} else {
|
||||
return remark;
|
||||
|
@@ -38,7 +38,7 @@ public class PhoneAuthApplyRecord implements Serializable {
|
||||
*/
|
||||
private String authCode;
|
||||
/**
|
||||
* 授权码状态 0待审核 1通过 2拒绝
|
||||
* 授权码状态 1待审核 2通过 3拒绝
|
||||
*/
|
||||
private Byte status;
|
||||
/**
|
||||
|
Reference in New Issue
Block a user