Browse Source

certification/add-autopass 烟台徽章认证自动通过

dev
yinzuomei 3 years ago
parent
commit
9c812a2ca9
  1. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java
  2. 16
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java
  3. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java
  4. 22
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java
  5. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java
  6. 24
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java
  7. 64
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java
  8. 3
      epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml

5
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java

@ -20,4 +20,9 @@ public class BadgeAuditFormDTO implements Serializable {
@NotBlank(message = "审核结果不能为空") @NotBlank(message = "审核结果不能为空")
private String auditStatus; private String auditStatus;
private String auditRemark; private String auditRemark;
/**
* tokenDto.getUserId
*/
private String currentUserId;
} }

16
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java

@ -65,4 +65,20 @@ public class CertificationAddFormDTO implements Serializable {
*/ */
private String code; private String code;
/**
* 是否需要发送站内信
* 您有一条徽章认证消息,%s申请认证%s请审核
* true:发送
* false:不发送
* 微信小程序发送
* 烟台钉钉自动通过默认false不发送
*/
private Boolean sendMsgFlag;
/**
* 自动通过标识
* true:自动通过目前只有烟台这么搞
*/
private Boolean autoPassFlag;
} }

3
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java

@ -152,7 +152,8 @@ public class BadgeController {
@NoRepeatSubmit @NoRepeatSubmit
public Result audit(@LoginUser TokenDto tokenDto, @RequestBody BadgeAuditFormDTO formDTO) { public Result audit(@LoginUser TokenDto tokenDto, @RequestBody BadgeAuditFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO); ValidatorUtils.validateEntity(formDTO);
badgeService.audit(tokenDto, formDTO); formDTO.setCurrentUserId(tokenDto.getUserId());
badgeService.audit(formDTO);
return new Result(); return new Result();
} }

22
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java

@ -1,6 +1,7 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
@ -56,6 +57,27 @@ public class UserBadgeController {
*/ */
@PostMapping("authbadgerecord") @PostMapping("authbadgerecord")
public Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO){ public Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO){
//发送微信站内信
certificationAddFormDTO.setSendMsgFlag(true);
certificationAddFormDTO.setAutoPassFlag(false);
ValidatorUtils.validateEntity(certificationAddFormDTO, CertificationAddFormDTO.CertificationAdd.class);
return userBadgeService.authBadgeRecord(certificationAddFormDTO);
}
/**
* 烟台钉钉居民端应用
*
* @param tokenDto
* @param certificationAddFormDTO
* @return
*/
@NoRepeatSubmit
@PostMapping("certification/add-autopass")
public Result certificationAddAutoPass(@LoginUser TokenDto tokenDto, @RequestBody CertificationAddFormDTO certificationAddFormDTO) {
certificationAddFormDTO.setUserId(tokenDto.getUserId());
certificationAddFormDTO.setSendMsgFlag(false);
// 是否自动通过
certificationAddFormDTO.setAutoPassFlag(true);
ValidatorUtils.validateEntity(certificationAddFormDTO, CertificationAddFormDTO.CertificationAdd.class); ValidatorUtils.validateEntity(certificationAddFormDTO, CertificationAddFormDTO.CertificationAdd.class);
return userBadgeService.authBadgeRecord(certificationAddFormDTO); return userBadgeService.authBadgeRecord(certificationAddFormDTO);
} }

3
epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java

@ -169,11 +169,10 @@ public interface BadgeService extends BaseService<BadgeEntity> {
* 审核 * 审核
* @author zhaoqifeng * @author zhaoqifeng
* @date 2020/11/5 11:08 * @date 2020/11/5 11:08
* @param tokenDto
* @param formDTO * @param formDTO
* @return void * @return void
*/ */
void audit(TokenDto tokenDto, BadgeAuditFormDTO formDTO); void audit(BadgeAuditFormDTO formDTO);
void testCache(); void testCache();

24
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java

@ -356,32 +356,30 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp
/** /**
* 审核 * 审核
* *
* @param tokenDto token
* @param formDTO 入参 * @param formDTO 入参
* @return void * @return void
* @author zhaoqifeng * @author zhaoqifeng
* @date 2020/11/5 11:08 * @date 2020/11/5 11:08
*/ */
@Override @Override
public void audit(TokenDto tokenDto, BadgeAuditFormDTO formDTO) { public void audit(BadgeAuditFormDTO formDTO) {
if(BadgeConstant.REJECTED.equals(formDTO.getAuditStatus())) { if(BadgeConstant.REJECTED.equals(formDTO.getAuditStatus())) {
if (StringUtils.isEmpty(formDTO.getAuditRemark())) { if (StringUtils.isEmpty(formDTO.getAuditRemark())) {
throw new ValidateException(EpmetErrorCode.CUSTOMER_VALIDATE_ERROR.getCode(), "驳回理由不能为空"); throw new ValidateException(EpmetErrorCode.CUSTOMER_VALIDATE_ERROR.getCode(), "驳回理由不能为空");
} }
} }
UserBadgeCertificateRecordDTO dto = userBadgeCertificateRecordService.get(formDTO.getRecordId()); UserBadgeCertificateRecordDTO dto = userBadgeCertificateRecordService.get(formDTO.getRecordId());
BadgeDetailResultDTO detail = baseDao.selectDetail(dto.getCustomerId(), dto.getBadgeId());
dto.setAuditStatus(formDTO.getAuditStatus()); dto.setAuditStatus(formDTO.getAuditStatus());
dto.setAuditRemark(formDTO.getAuditRemark()); dto.setAuditRemark(formDTO.getAuditRemark());
dto.setStaffId(tokenDto.getUserId()); dto.setStaffId(formDTO.getCurrentUserId());
dto.setIsLast(BadgeConstant.YES); dto.setIsLast(BadgeConstant.YES);
dto.setAuditTime(new Date()); dto.setAuditTime(new Date());
userBadgeCertificateRecordService.update(dto); userBadgeCertificateRecordService.update(dto);
BadgeDetailResultDTO detail = baseDao.selectDetail(dto.getCustomerId(), dto.getBadgeId());
List<UserMessageFormDTO> msgList = new ArrayList<>(); List<UserMessageFormDTO> msgList = new ArrayList<>();
List<WxSubscribeMessageFormDTO> wxmpMsgList = new ArrayList<>(); List<WxSubscribeMessageFormDTO> wxmpMsgList = new ArrayList<>();
if(BadgeConstant.APPROVED.equals(formDTO.getAuditStatus())) { if(BadgeConstant.APPROVED.equals(formDTO.getAuditStatus())) {
ResiUserBadgeDTO resiUserBadgeDTO = new ResiUserBadgeDTO(); ResiUserBadgeDTO resiUserBadgeDTO = new ResiUserBadgeDTO();
resiUserBadgeDTO.setCustomerId(dto.getCustomerId()); resiUserBadgeDTO.setCustomerId(dto.getCustomerId());
resiUserBadgeDTO.setBadgeId(dto.getBadgeId()); resiUserBadgeDTO.setBadgeId(dto.getBadgeId());
@ -435,12 +433,16 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp
wxmp.setGridId(dto.getGridId()); wxmp.setGridId(dto.getGridId());
wxmpMsgList.add(wxmp); wxmpMsgList.add(wxmp);
} }
messageFeignClient.saveUserMessageList(msgList); if(CollectionUtils.isNotEmpty(msgList)){
log.info("徽章消息,开始推送微信订阅消息"); messageFeignClient.saveUserMessageList(msgList);
Result result = epmetMessageOpenFeignClient.sendWxSubscribeMessage(wxmpMsgList); }
if (!result.success()) { if(CollectionUtils.isNotEmpty(wxmpMsgList)){
log.error("徽章消息,发送微信订阅消息失败" + JSON.toJSONString(result)); log.info("徽章消息,开始推送微信订阅消息");
} Result result = epmetMessageOpenFeignClient.sendWxSubscribeMessage(wxmpMsgList);
if (!result.success()) {
log.error("徽章消息,发送微信订阅消息失败" + JSON.toJSONString(result));
}
}
} }
@Override @Override

64
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java

@ -1,6 +1,7 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.EpmetException;
@ -8,6 +9,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.commons.tools.validator.PhoneValidatorUtils;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.BadgeConstant; import com.epmet.constant.BadgeConstant;
@ -24,6 +26,8 @@ import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgFeignClient; import com.epmet.feign.GovOrgFeignClient;
import com.epmet.redis.UserBadgeRedis; import com.epmet.redis.UserBadgeRedis;
import com.epmet.redis.UserBaseInfoRedis; import com.epmet.redis.UserBaseInfoRedis;
import com.epmet.service.ResiUserBadgeService;
import com.epmet.service.UserBadgeCertificateRecordService;
import com.epmet.service.UserBadgeService; import com.epmet.service.UserBadgeService;
import com.epmet.service.UserBaseInfoService; import com.epmet.service.UserBaseInfoService;
import com.epmet.util.ModuleConstant; import com.epmet.util.ModuleConstant;
@ -275,7 +279,7 @@ public class UserBadgeServiceImpl implements UserBadgeService {
userIds.add(certificationAddFormDTO.getUserId()); userIds.add(certificationAddFormDTO.getUserId());
List<UserBaseInfoResultDTO> userBaseInfoResultDTOS = userBaseInfoService.queryUserBaseInfo(userIds); List<UserBaseInfoResultDTO> userBaseInfoResultDTOS = userBaseInfoService.queryUserBaseInfo(userIds);
if (CollectionUtils.isEmpty(userBaseInfoResultDTOS)) { if (CollectionUtils.isEmpty(userBaseInfoResultDTOS)) {
throw new RenException("查询用户基本信息集合为空......"); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),String.format("查询用户基本信息集合为空,userId:%s",certificationAddFormDTO.getUserId()),"查询用户基本信息异常");
} }
userBadgeDao.updateCertificateRecordIsLast(form.getBadgeId(),form.getUserId()); userBadgeDao.updateCertificateRecordIsLast(form.getBadgeId(),form.getUserId());
form.setGridId(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRegisteredGridId()); form.setGridId(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRegisteredGridId());
@ -283,17 +287,57 @@ public class UserBadgeServiceImpl implements UserBadgeService {
form.setCertificationImg(certificationAddFormDTO.getCertificationImg()); form.setCertificationImg(certificationAddFormDTO.getCertificationImg());
form.setSurname(certificationAddFormDTO.getSurname()); form.setSurname(certificationAddFormDTO.getSurname());
log.info(JSON.toJSONString(form)); log.info(JSON.toJSONString(form));
String recordId=IdWorker.getIdStr();
form.setId(recordId);
userBadgeDao.insertUserBadgeCertificateRecord(form); userBadgeDao.insertUserBadgeCertificateRecord(form);
//TODO 站内信发送 if(certificationAddFormDTO.getSendMsgFlag()){
String badgeName = badgeDao.selectBadgeName(form.getCustomerId(), form.getBadgeId()); //TODO 站内信发送
String s = StringUtils.isBlank(userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict()) ? userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName() : userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()); String badgeName = badgeDao.selectBadgeName(form.getCustomerId(), form.getBadgeId());
String msg = String.format(BadgeConstant.MESSAGE_CONTENT, s, badgeName); String s = StringUtils.isBlank(userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict()) ? userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName() : userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName());
// 记录待审核id,和消息类型 String msg = String.format(BadgeConstant.MESSAGE_CONTENT, s, badgeName);
sendMessage(BadgeConstant.AUTH_TITLE,msg,form.getGridId(),form.getUserId(),form.getCustomerId(), // 记录待审核id,和消息类型
UserMessageTypeConstant.BADGE_AUTH_APPLY, sendMessage(BadgeConstant.AUTH_TITLE,msg,form.getGridId(),form.getUserId(),form.getCustomerId(),
form.getId()); UserMessageTypeConstant.BADGE_AUTH_APPLY,
form.getId());
}
//烟台:徽章认证自动审核通过
if(certificationAddFormDTO.getAutoPassFlag()){
BadgeAuditFormDTO badgeAuditFormDTO=new BadgeAuditFormDTO();
badgeAuditFormDTO.setRecordId(recordId);
//审核状态 approved:审核通过,rejected:审核驳回;auditing:审核中
badgeAuditFormDTO.setAuditStatus(BadgeConstant.APPROVED);
badgeAuditFormDTO.setCurrentUserId("APP_USER");
autoPassBadge(badgeAuditFormDTO);
}
Map resultMap=new HashMap();
resultMap.put("recordId",recordId);
return new Result().ok(resultMap);
}
/**
* 烟台:徽章认证自动审核通过
* @param badgeAuditFormDTO
*/
private void autoPassBadge(BadgeAuditFormDTO badgeAuditFormDTO) {
UserBadgeCertificateRecordDTO dto = SpringContextUtils.getBean(UserBadgeCertificateRecordService.class).get(badgeAuditFormDTO.getRecordId());
dto.setAuditStatus(badgeAuditFormDTO.getAuditStatus());
dto.setAuditRemark(badgeAuditFormDTO.getAuditRemark());
dto.setStaffId(badgeAuditFormDTO.getCurrentUserId());
dto.setIsLast(BadgeConstant.YES);
dto.setAuditTime(new Date());
SpringContextUtils.getBean(UserBadgeCertificateRecordService.class).update(dto);
ResiUserBadgeDTO resiUserBadgeDTO = new ResiUserBadgeDTO();
resiUserBadgeDTO.setCustomerId(dto.getCustomerId());
resiUserBadgeDTO.setBadgeId(dto.getBadgeId());
resiUserBadgeDTO.setGridId(dto.getGridId());
resiUserBadgeDTO.setUserId(dto.getUserId());
resiUserBadgeDTO.setIsOpened(NumConstant.ONE);
resiUserBadgeDTO.setCertificationAutidStatus(dto.getAuditStatus());
SpringContextUtils.getBean(ResiUserBadgeService.class).save(resiUserBadgeDTO);
//更新Redis
userBadgeRedis.pushOrRemoveUserBadge4List(dto.getUserId(),dto.getBadgeId(),dto.getCustomerId());
return new Result();
} }
private void validateParams(CertificationAddFormDTO certificationAddFormDTO, AuthFieldFormDTO authFieldFormDTO) { private void validateParams(CertificationAddFormDTO certificationAddFormDTO, AuthFieldFormDTO authFieldFormDTO) {

3
epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml

@ -171,9 +171,6 @@
<!-- 徽章审核记录表插入 --> <!-- 徽章审核记录表插入 -->
<insert id="insertUserBadgeCertificateRecord" useGeneratedKeys="true" keyColumn="ID" keyProperty="id" parameterType="com.epmet.dto.UserBadgeCertificateRecordDTO"> <insert id="insertUserBadgeCertificateRecord" useGeneratedKeys="true" keyColumn="ID" keyProperty="id" parameterType="com.epmet.dto.UserBadgeCertificateRecordDTO">
<selectKey keyProperty="id" resultType="java.lang.String" order="BEFORE">
select replace(uuid(),'-','') AS ID
</selectKey>
INSERT INTO user_badge_certificate_record ( INSERT INTO user_badge_certificate_record (
ID, ID,
CUSTOMER_ID, CUSTOMER_ID,

Loading…
Cancel
Save