mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
解绑鉴权卡
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -100,31 +101,34 @@ public class PileAuthCardServiceImpl implements IPileAuthCardService {
|
||||
*/
|
||||
@Override
|
||||
public int addAuthCard(PileAuthCardDTO dto) {
|
||||
MemberBasicInfo memberBasicInfo = new MemberBasicInfo();
|
||||
if (dto.getPhoneNumber() == null) {
|
||||
memberBasicInfo.setMemberId(null);
|
||||
memberBasicInfo.setStatus("0"); // 0-待激活
|
||||
}else {
|
||||
// 通过手机号查询memberId
|
||||
memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(dto.getPhoneNumber(), dto.getMerchantId());
|
||||
if (memberBasicInfo == null) {
|
||||
// 为空则说明未查到该用户的注册信息
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_USER_IS_NOT_REGISTER);
|
||||
}
|
||||
memberBasicInfo.setStatus("1"); // 1-正常使用
|
||||
}
|
||||
String logicCard = dto.getLogicCard();
|
||||
// 根据卡号查询数据库
|
||||
PileAuthCard cardInfo = pileAuthCardMapper.selectSomeStatusCardInfo(null, logicCard);
|
||||
if(cardInfo != null) {
|
||||
// 不为空说明此卡已存在
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_HAS_BEEN_BINDING);
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_AUTH_CARD_CODE_EXIST);
|
||||
}
|
||||
|
||||
// 鉴权卡状态 默认 0-待激活
|
||||
String status = Constants.ZERO;
|
||||
String memberId = null;
|
||||
|
||||
if (StringUtils.isNotBlank(dto.getPhoneNumber())) {
|
||||
// 通过手机号查询memberId
|
||||
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(dto.getPhoneNumber(), dto.getMerchantId());
|
||||
if (memberBasicInfo == null) {
|
||||
// 为空则说明未查到该用户的注册信息
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_USER_IS_NOT_REGISTER);
|
||||
}
|
||||
memberId = memberBasicInfo.getMemberId();
|
||||
status = Constants.ONE; // 1-正常使用
|
||||
}
|
||||
|
||||
String secretKey = RandomStringUtils.randomAlphanumeric(8).toUpperCase(Locale.ROOT); // 生成8位数的字母 + 数字随机数
|
||||
PileAuthCard pileAuthCard = PileAuthCard.builder()
|
||||
.logicCard(logicCard)
|
||||
.memberId(memberBasicInfo.getMemberId())
|
||||
.status(memberBasicInfo.getStatus())
|
||||
.memberId(memberId)
|
||||
.status(status)
|
||||
.secretKey(secretKey)
|
||||
.build();
|
||||
return pileAuthCardMapper.insertPileAuthCard(pileAuthCard);
|
||||
|
||||
Reference in New Issue
Block a user