mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 绑定鉴权卡
This commit is contained in:
@@ -59,7 +59,7 @@ public class AuthCardController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 用户绑定鉴权卡
|
||||
* 用户绑定鉴权卡-小程序
|
||||
* http://localhost:8080/uniapp/authCard/bindAuthCard
|
||||
* @param dto
|
||||
* @return
|
||||
|
||||
@@ -143,7 +143,7 @@ public class MemberController extends BaseController {
|
||||
String memberToken = memberService.wechatLogin(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("memberToken", memberToken));
|
||||
} catch (Exception e) {
|
||||
logger.error("微信登录异常 param:{}", JSON.toJSONString(dto), e);
|
||||
logger.error("支付宝登录异常 param:{}", JSON.toJSONString(dto), e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_WECHAT_LOGIN_ERROR);
|
||||
}
|
||||
return response;
|
||||
@@ -393,7 +393,7 @@ public class MemberController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 用户绑定鉴权卡接口
|
||||
* 用户绑定鉴权卡接口-小程序
|
||||
* http://localhost:8080/uniapp/member/memberBindingCard
|
||||
*
|
||||
* @param dto
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.MemberBasicInfo;
|
||||
import com.jsowell.pile.domain.PileAuthCard;
|
||||
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||
import com.jsowell.pile.mapper.PileAuthCardMapper;
|
||||
import com.jsowell.pile.service.MemberBasicInfoService;
|
||||
@@ -259,27 +260,31 @@ public class PileAuthCardServiceImpl implements PileAuthCardService {
|
||||
*/
|
||||
@Override
|
||||
public int bindAuthCard(PileAuthCardDTO dto) {
|
||||
String phoneNumber = dto.getPhoneNumber();
|
||||
// 通过运营商id获取一级运营商id
|
||||
String firstLevelMerchantId = pileMerchantInfoService.getFirstLevelMerchantIdByMerchantId(dto.getMerchantId());
|
||||
// 判断此用户是否已注册小程序账号
|
||||
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(phoneNumber, firstLevelMerchantId);
|
||||
if (memberBasicInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_USER_IS_NOT_REGISTER);
|
||||
// 判断当前鉴权卡是否被绑定过
|
||||
PileAuthCard pileAuthCardInfo = selectCardInfoByLogicCard(dto.getLogicCard());
|
||||
if (pileAuthCardInfo == null){
|
||||
// 为空说明没查到此卡信息
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_HAS_NO_INFO);
|
||||
}
|
||||
// 判断此卡是否已被绑定
|
||||
PileAuthCard pileAuthCard = selectCardInfoByLogicCard(dto.getLogicCard());
|
||||
if (!StringUtils.equals(pileAuthCard.getStatus(), "0")) { // 0-待激活
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_STATUS_ANOMALY);
|
||||
if (StringUtils.isNotBlank(pileAuthCardInfo.getMemberId())) {
|
||||
// memberId 不为空,说明此卡已被绑定
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_HAS_BEEN_BINDING);
|
||||
}
|
||||
// 验证密钥
|
||||
if (!StringUtils.equals(dto.getSecretKey(), pileAuthCard.getSecretKey())) {
|
||||
if (!StringUtils.equalsIgnoreCase(pileAuthCardInfo.getSecretKey(), dto.getSecretKey())) {
|
||||
// 密钥不一致,不能绑定
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_SECRET_KEY_NOT_SAME);
|
||||
}
|
||||
// 绑定操作
|
||||
pileAuthCard.setMemberId(dto.getMemberId());
|
||||
pileAuthCard.setStatus("1");
|
||||
return updatePileAuthCard(pileAuthCard);
|
||||
if (!StringUtils.equals(pileAuthCardInfo.getStatus(), Constants.ZERO)) {
|
||||
// 鉴权卡不是待激活状态 0-待激活
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_STATUS_ANOMALY);
|
||||
}
|
||||
PileAuthCard authCard = PileAuthCard.builder()
|
||||
.id(pileAuthCardInfo.getId())
|
||||
.memberId(dto.getMemberId())
|
||||
.status(Constants.ONE) // 1-正常使用
|
||||
.updateBy(dto.getMemberId())
|
||||
.build();
|
||||
return updatePileAuthCard(authCard);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user