From 1c8eca02dd3f6e46526beb03abfaa827077f16b0 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 4 Nov 2020 15:38:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=BE=BD=E7=AB=A0=E8=AE=A4?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badege/controller/BadgeController.java | 16 ++++ .../modules/badege/service/BadgeService.java | 10 +++ .../badege/service/impl/BadgeServiceImpl.java | 17 ++++ .../dto/UserBadgeCertificateRecordDTO.java | 44 +++++++++++ .../epmet/dto/form/BadgeSendCodeFormDTO.java | 22 ++++++ .../dto/form/CertificationAddFormDTO.java | 67 ++++++++++++++++ .../epmet/feign/EpmetUserOpenFeignClient.java | 3 + .../EpmetUserOpenFeignClientFallback.java | 5 ++ .../epmet/controller/UserBadgeController.java | 28 +++++++ .../main/java/com/epmet/dao/UserBadgeDao.java | 18 +++++ .../java/com/epmet/redis/UserBadgeRedis.java | 15 ++++ .../com/epmet/service/UserBadgeService.java | 20 +++++ .../service/impl/UserBadgeServiceImpl.java | 79 ++++++++++++++++++- .../main/resources/mapper/UserBadgeDao.xml | 59 ++++++++++++++ 14 files changed, 401 insertions(+), 2 deletions(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java index fe519e7cbb..8d70e5d097 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.modules.badege.service.BadgeService; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.resi.mine.dto.from.OperListFormDTO; import com.epmet.resi.mine.dto.result.BadgeListResultDTO; import com.epmet.resi.mine.dto.result.OperListResultDTO; @@ -52,4 +53,19 @@ public class BadgeController { return new Result>().ok(badgeService.getOperList(tokenDto,operListFormDTO)); } + /** + * @Description 个人中心-提交徽章认证 + * @Param tokenDto + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 11:16 上午 + */ + @PostMapping("certification/add") + public Result certificationAdd(@LoginUser TokenDto tokenDto,@RequestBody CertificationAddFormDTO certificationAddFormDTO){ + ValidatorUtils.validateEntity(certificationAddFormDTO, CertificationAddFormDTO.CertificationAdd.class); + badgeService.certificationAdd(tokenDto,certificationAddFormDTO); + return new Result(); + } + + } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java index fe1d1c140e..6d020bc286 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java @@ -2,6 +2,7 @@ package com.epmet.modules.badege.service; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.resi.mine.dto.from.OperListFormDTO; import com.epmet.resi.mine.dto.result.BadgeListResultDTO; import com.epmet.resi.mine.dto.result.OperListResultDTO; @@ -30,4 +31,13 @@ public interface BadgeService { */ List getOperList(TokenDto tokenDto,OperListFormDTO operListFormDTO); + /** + * @Description 个人中心-提交徽章认证 + * @Param tokenDto + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 11:16 上午 + */ + void certificationAdd(TokenDto tokenDto, CertificationAddFormDTO certificationAddFormDTO); + } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java index 6e1d3ae1e9..259ffc23ae 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java @@ -11,6 +11,7 @@ import com.epmet.dto.result.UserOperListResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.modules.badege.service.BadgeService; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.resi.mine.dto.from.OperListFormDTO; import com.epmet.resi.mine.dto.result.BadgeListResultDTO; import com.epmet.resi.mine.dto.result.OperListResultDTO; @@ -75,4 +76,20 @@ public class BadgeServiceImpl implements BadgeService { List result = ConvertUtils.sourceToTarget(listResult.getData(), OperListResultDTO.class); return result; } + + /** + * @Description 个人中心-提交徽章认证 + * @Param tokenDto + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 11:16 上午 + */ + @Override + public void certificationAdd(TokenDto tokenDto, CertificationAddFormDTO certificationAddFormDTO) { + certificationAddFormDTO.setUserId(tokenDto.getUserId()); + Result result = epmetUserOpenFeignClient.authBadgeRecord(certificationAddFormDTO); + if (!result.success()){ + throw new RenException("提交徽章认证失败......"); + } + } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java new file mode 100644 index 0000000000..a398d6f2cc --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java @@ -0,0 +1,44 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Author zxc + * @DateTime 2020/11/4 1:46 下午 + */ +@Data +public class UserBadgeCertificateRecordDTO implements Serializable { + + private static final long serialVersionUID = 3207509834642386145L; + + private String customerId; + private String gridId; + private String userId; + private String badgeId; + private String surname; + private String name; + private String idNum; + private String certificationImg; + private String remark; + private String auditStatus; + private String auditRemark; + private String staffId; + private Date auditTime; + private String isLast; + private String delFlag; + private Integer revision; + private String createdBy; + private String updatedBy; + + public UserBadgeCertificateRecordDTO() { + this.auditStatus = "auditing"; + this.isLast = "yes"; + this.delFlag = "0"; + this.revision = 0; + this.createdBy = "APP_USER"; + this.updatedBy = "APP_USER"; + } +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java new file mode 100644 index 0000000000..14cb3c3333 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/4 3:11 下午 + */ +@Data +public class BadgeSendCodeFormDTO implements Serializable { + + private static final long serialVersionUID = -3926070129364657241L; + + public interface BadgeSendCode{} + + @NotBlank(message = "手机号不能为空", groups = {BadgeSendCode.class}) + private String mobile; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java new file mode 100644 index 0000000000..76583e9559 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java @@ -0,0 +1,67 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/4 11:05 上午 + */ +@Data +public class CertificationAddFormDTO implements Serializable { + + private static final long serialVersionUID = 1330773325803513330L; + + public interface CertificationAdd{} + + private String userId; + + /** + * 客户ID + */ + @NotBlank(message = "客户ID不能为空",groups = {CertificationAdd.class}) + private String customerId; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 手机号 + */ + private String mobile; + + /** + * 姓 + */ + private String subName; + + /** + * 名 + */ + private String name; + + /** + * 身份证号 + */ + private String idCard; + + /** + * 认证证件图片url + */ + private String certificate; + + /** + * 认证说明 + */ + private String remark; + + /** + * 验证码 + */ + private String code; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 8ab0fd12b2..f356eb8b1a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -355,4 +355,7 @@ public interface EpmetUserOpenFeignClient { */ @PostMapping("/epmetuser/badge/badgeoperlist") Result> selectOperList(@RequestBody UserOperListFormDTO userOperListFormDTO); + + @PostMapping("/epmetuser/badge/authbadgerecord") + Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index aa5db5968a..789acb75f4 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -235,4 +235,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result> selectOperList(UserOperListFormDTO userOperListFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectOperList", userOperListFormDTO); } + + @Override + public Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "authBadgeRecord", certificationAddFormDTO); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java index 5b8f9d46e6..f29179b551 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java @@ -1,6 +1,9 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.BadgeSendCodeFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.dto.form.UserBadgeListFormDTO; import com.epmet.dto.form.UserOperListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; @@ -47,4 +50,29 @@ public class UserBadgeController { return new Result>().ok(userBadgeService.selectOperList(userOperListFormDTO)); } + /** + * @Description 个人中心-提交徽章认证 + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 1:36 下午 + */ + @PostMapping("authbadgerecord") + public Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO){ + userBadgeService.authBadgeRecord(certificationAddFormDTO); + return new Result(); + } + + /** + * @Description 发送验证码 + * @Param badgeSendCodeFormDTO + * @author zxc + * @date 2020/11/4 3:14 下午 + */ + @PostMapping("badgesendcode") + public Result badgeSendCode(@RequestBody BadgeSendCodeFormDTO badgeSendCodeFormDTO){ + ValidatorUtils.validateEntity(badgeSendCodeFormDTO, BadgeSendCodeFormDTO.BadgeSendCode.class); + userBadgeService.badgeSendCode(badgeSendCodeFormDTO); + return new Result(); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java index 65eec9d1ac..fececff9d8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java @@ -1,5 +1,6 @@ package com.epmet.dao; +import com.epmet.dto.UserBadgeCertificateRecordDTO; import com.epmet.dto.form.UserBadgeListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; @@ -47,4 +48,21 @@ public interface UserBadgeDao { */ List selectBadgeByUserId(@Param("userId")String userId); + /** + * @Description 用户认证徽章记录表插入 + * @Param userBadgeCertificateRecordDTO + * @author zxc + * @date 2020/11/4 2:13 下午 + */ + void insertUserBadgeCertificateRecord(UserBadgeCertificateRecordDTO userBadgeCertificateRecordDTO); + + /** + * @Description 更新认证徽章记录最新 + * @Param badgeId + * @Param userId + * @author zxc + * @date 2020/11/4 2:16 下午 + */ + void updateCertificateRecordIsLast(@Param("badgeId")String badgeId,@Param("userId")String userId); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java index 727c467e12..1b209e7dee 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java @@ -1,6 +1,8 @@ package com.epmet.redis; import com.alibaba.fastjson.JSON; +import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.BadgeConstant; @@ -12,6 +14,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static com.epmet.commons.tools.redis.RedisUtils.MINUTE_THIRTY_EXPIRE; + /** * @Author zxc * @DateTime 2020/11/3 2:21 下午 @@ -44,4 +48,15 @@ public class UserBadgeRedis { redisUtils.hSet(BadgeConstant.BADGE_KEY+customerId,BadgeConstant.BADGE, JSON.toJSON(userBadge).toString(),-1); } + public void saveBadgeSmsCode(String mobile, String smsCode) { + String smsCodeKey = "epmet:smsCode:badge:" + mobile; + redisUtils.set(smsCodeKey, smsCode, MINUTE_THIRTY_EXPIRE); + } + + public String getBadgeSmsCode(String mobile) { + String smsCodeKey = "epmet:smsCode:badge:" + mobile; + String smsCode = (String) redisUtils.get(smsCodeKey); + return smsCode; + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java index fe5737a2d3..79334d2960 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java @@ -1,9 +1,13 @@ package com.epmet.service; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.BadgeSendCodeFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.dto.form.UserBadgeListFormDTO; import com.epmet.dto.form.UserOperListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -29,4 +33,20 @@ public interface UserBadgeService { */ List selectOperList(UserOperListFormDTO userOperListFormDTO); + /** + * @Description 个人中心-提交徽章认证 + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 1:36 下午 + */ + Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO); + + /** + * @Description 发送验证码 + * @Param badgeSendCodeFormDTO + * @author zxc + * @date 2020/11/4 3:14 下午 + */ + void badgeSendCode(BadgeSendCodeFormDTO badgeSendCodeFormDTO); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index 261f7e7bdc..33ddb19b00 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -2,16 +2,27 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.constant.BadgeConstant; +import com.epmet.constant.SmsTemplateConstant; import com.epmet.dao.UserBadgeDao; -import com.epmet.dto.form.UserBadgeListFormDTO; -import com.epmet.dto.form.UserOperListFormDTO; +import com.epmet.dto.UserBadgeCertificateRecordDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.SendVerificationCodeResultDTO; import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.dto.result.UserOperListResultDTO; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.redis.UserBadgeRedis; +import com.epmet.service.CustomerStaffService; import com.epmet.service.UserBadgeService; +import com.epmet.service.UserBaseInfoService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -34,6 +45,12 @@ public class UserBadgeServiceImpl implements UserBadgeService { private UserBadgeDao userBadgeDao; @Autowired private UserBadgeRedis userBadgeRedis; + @Autowired + private UserBaseInfoService userBaseInfoService; + @Autowired + private CustomerStaffService customerStaffService; + @Autowired + private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; /** * @Description 查询已经点亮的徽章 @@ -123,4 +140,62 @@ public class UserBadgeServiceImpl implements UserBadgeService { }); return userOperListResultDTOS; } + + /** + * @Description 个人中心-提交徽章认证 + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 1:36 下午 + */ + @Override + public Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO) { + if (StringUtils.isNotBlank(certificationAddFormDTO.getMobile())){ + String smsCode = userBadgeRedis.getBadgeSmsCode(certificationAddFormDTO.getMobile()); + if (!StringUtils.isNotBlank(smsCode)){ + return new Result().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); + } + } + UserBadgeCertificateRecordDTO form = ConvertUtils.sourceToTarget(certificationAddFormDTO, UserBadgeCertificateRecordDTO.class); + List userIds = new ArrayList<>(); + userIds.add(certificationAddFormDTO.getUserId()); + List userBaseInfoResultDTOS = userBaseInfoService.queryUserBaseInfo(userIds); + if (CollectionUtils.isEmpty(userBaseInfoResultDTOS)){ + throw new RenException("查询用户基本信息集合为空......"); + } + userBadgeDao.updateCertificateRecordIsLast(form.getBadgeId(),form.getUserId()); + form.setGridId(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRegisteredGridId()); + form.setIdNum(certificationAddFormDTO.getIdCard()); + form.setCertificationImg(certificationAddFormDTO.getCertificate()); + form.setSurname(certificationAddFormDTO.getSubName()); + userBadgeDao.insertUserBadgeCertificateRecord(form); + return new Result(); + } + + /** + * @Description 发送验证码 + * @Param badgeSendCodeFormDTO + * @author zxc + * @date 2020/11/4 3:14 下午 + */ + @Override + public void badgeSendCode(BadgeSendCodeFormDTO badgeSendCodeFormDTO) { + //1、校验手机号是否符合规范 + if (!PhoneValidatorUtils.isMobile(badgeSendCodeFormDTO.getMobile())) { + log.error(String.format("发送短信验证码异常,手机号[%s],code[%s],msg[%s]", badgeSendCodeFormDTO.getMobile(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg())); + throw new RenException(EpmetErrorCode.ERROR_PHONE.getCode()); + } + //3、发送短信验证码 + SendVerificationCodeFormDTO sendVerificationCodeFormDTO=new SendVerificationCodeFormDTO(); + sendVerificationCodeFormDTO.setMobile(badgeSendCodeFormDTO.getMobile()); + sendVerificationCodeFormDTO.setAliyunTemplateCode(SmsTemplateConstant.LGOIN_CONFIRM); + Result smsCodeResult=epmetMessageOpenFeignClient.sendVerificationCode(sendVerificationCodeFormDTO); + if (!smsCodeResult.success()) { + log.error(String.format("发送短信验证码异常,手机号[%s],code[%s],msg[%s]", badgeSendCodeFormDTO.getMobile(), smsCodeResult.getCode(), smsCodeResult.getMsg())); + throw new RenException(smsCodeResult.getCode()); + } + //4、保存短信验证码(删除现有短信验证码、将新的短信验证码存入Redis) + userBadgeRedis.saveBadgeSmsCode(badgeSendCodeFormDTO.getMobile(),smsCodeResult.getData().getCode()); + log.info(String.format("发送短信验证码成功,手机号[%s]", badgeSendCodeFormDTO.getMobile())); + } + } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml index b9bcbad998..b6c688b331 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml @@ -3,6 +3,15 @@ + + + UPDATE user_badge_certificate_record + SET is_last = 'no' + WHERE DEL_FLAG = '0' + AND BADGE_ID = #{badgeId} + AND USER_ID = #{userId} + + + + + INSERT INTO user_badge_certificate_record ( + ID, + CUSTOMER_ID, + GRID_ID, + USER_ID, + BADGE_ID, + SURNAME, + NAME, + ID_NUM, + CERTIFICATION_IMG, + REMAEK, + AUDIT_STATUS, + AUDIT_REMARK, + STAFF_ID, + AUDIT_TIME, + IS_LAST, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME + ) + VALUES + ( + REPLACE ( UUID(), '-', '' ), + #{customerId}, + #{gridId}, + #{userId}, + #{badgeId}, + #{surname}, + #{name}, + #{idNum}, + #{certificationImg}, + #{remark}, + #{auditStatus}, + #{auditRemark}, + #{staffId}, + #{auditTime}, + #{isLast}, + #{delFlag}, + #{revision}, + #{createdBy}, + NOW(), + #{updatedBy}, + NOW() + ) +