Commit 21b47823 by lixian7

解绑接口调整

parent 92b90256
......@@ -10,10 +10,7 @@ import com.hikcreate.edl.pub.web.mobile.infra.core.Result.ResultGenerator;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.BodyDecryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.ResponseEncryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BindInfoQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BindInfoReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BindSmsValidReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.UnBindReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.*;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BindInfoQueryRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BindInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ResultList;
......@@ -106,6 +103,26 @@ public class BindInfoControlller extends BaseController {
}
/**
* 车辆解绑发送短信(后台操作)
* @param req
* @return
*/
@PostMapping( "admin/unbind" )
public Result adminUnbind(@RequestBody @Validated AdminUnbindReq req ) {
return null;
}
/**
* 车辆解绑短信验证(后台操作)
* @param req
* @return
*/
@PostMapping( "admin/unbind/smsValid" )
public Result adminUnbindSmsValid(@RequestBody @Validated AdminUnbindSmsValidReq req) {
return null;
}
/**
* 绑定信息查询接口
*
* @param query
......
......@@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.common.distributed.lock.annotation.DistributedLock;
import com.hikcreate.edl.common.sdk.util.VerifyCodeUtil;
import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.ResultCode;
......@@ -26,6 +27,7 @@ import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.par
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.response.VehicleRes;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.SmsFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.CheckVerifyCodeMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendVerifyCodeMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pvt_service_drivinglicense.DrivingLicenseQrFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pvt_service_drivinglicense.request.IdCardMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pvt_service_drivinglicense.response.DlQrRes;
......@@ -118,7 +120,6 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
@Override
@Transactional(rollbackFor = Exception.class)
@DistributedLock(key = "'park:extend:lock:bind:userId:'+#info.userId+':timestamp:'+#info.timestamp", expireTime =
3000, waitTime = 2000, retryTimes = 50)
public Result bind(ParkBindInfo info) {
......@@ -191,7 +192,6 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
return ResultGenerator.fail(ResultCode.CAR_HAVE_BIND);
}
// info.setUnqId(unqIdUtil.getUnqId());
// info.setGmtBindTime(new Date());
// bindCache.insert(info);
......@@ -203,6 +203,13 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
log.error("绑定异常:{}", e.getMessage());
return ResultGenerator.fail(StatusCode.SYSTEM_ERROR);
}
//发送验证码
SendVerifyCodeMicReq sendMicReq = new SendVerifyCodeMicReq();
sendMicReq.setPhone(info.getOwnerPhone());
sendMicReq.setVerifyCode(VerifyCodeUtil.getCode());
sendMicReq.setTemplateCode("PARK_BIND_VEHICLE");
smsFeign.sendVerifyCode(sendMicReq).fallback();
return ResultGenerator.success();
}
......@@ -213,21 +220,40 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result bindSmsValid( BindSmsValidReq req ) {
//获取缓存信息
String key = bindKeyPrefix.concat(req.getPhone()).concat("-").concat(req.getOwnerPhone());
try {
objectMapper.readValue(redisTemplate.opsForValue().get(key), ParkBindInfo.class);
//获取缓存信息
String key = bindKeyPrefix.concat(req.getPhone()).concat("-").concat(req.getOwnerPhone());
String bindInfoStr = redisTemplate.opsForValue().get(key);
if( StrUtil.isBlank(bindInfoStr) ) {
log.error("车辆绑定短信验证失败:未发起车辆绑定");
return ResultGenerator.fail(StatusCode.BUSINESS_ERROR.getCode(), "请先调车辆绑定接口");
}
ParkBindInfo bindInfo = objectMapper.readValue(bindInfoStr, ParkBindInfo.class);
//验证短信
CheckVerifyCodeMicReq checkVerifyCodeMicReq = new CheckVerifyCodeMicReq();
checkVerifyCodeMicReq.setPhone(req.getOwnerPhone())
.setVerifyCode(req.getSmsCode()).setTemplateCode("PARK_BIND_VEHICLE");
long resultCode = smsFeign.checkVerifyCode(checkVerifyCodeMicReq).fallback().getCode();
if( StatusCode.SUCCESS.getCode()!=resultCode) {
log.error("车辆绑定短信验证失败:验证码不正确");
return ResultGenerator.fail(StatusCode.PARAM_ERROR.getCode(), "验证码不正确");
}
//绑定信息入库
bindInfo.setUnqId(unqIdUtil.getUnqId());
bindInfo.setGmtBindTime(new Date());
if(!bindCache.insert(bindInfo)) {
log.error("车辆绑定短信验证失败:绑定信息入库失败");
return ResultGenerator.fail(StatusCode.SYSTEM_ERROR);
}
return ResultGenerator.success(new BindInfoRes(bindInfo.getUnqId()));
} catch ( JsonProcessingException e ) {
log.error("车辆绑定短信验证异常:{}",e.getMessage());
return ResultGenerator.fail(StatusCode.SYSTEM_ERROR);
}
//验证短信
CheckVerifyCodeMicReq checkVerifyCodeMicReq = new CheckVerifyCodeMicReq();
checkVerifyCodeMicReq.setPhone(req.getOwnerPhone())
.setVerifyCode(req.getSmsCode()).setTemplateCode("");
smsFeign.checkVerifyCode(checkVerifyCodeMicReq);
return null;
}
/**
......
package com.hikcreate.edl.pub.web.mobile.infra.model.param.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author lixian
* @description
* @date 2020/7/20 18:19
**/
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class AdminUnbindReq {
/**
* 客户id
*/
@NotBlank(message = "客户唯一编码不能为空")
private String userId;
/**
* 用户车辆绑定唯一编号
*/
@NotBlank(message = "用户车辆绑定唯一编号不能为空")
private String unqId;
/**
* 时间戳
*/
@NotNull(message = "时间戳不能为空")
private Long timestamp;
}
package com.hikcreate.edl.pub.web.mobile.infra.model.param.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author lixian
* @description
* @date 2020/7/20 18:36
**/
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class AdminUnbindSmsValidReq {
/**
* 用户车辆绑定唯一编号
*/
@NotBlank(message = "用户车辆绑定唯一编号不能为空")
private String unqId;
/**
* 验证码
*/
@NotBlank(message = "验证码不能为空")
private String smsCode;
/**
* 时间戳
*/
@NotNull(message = "时间戳不能为空")
private Long timestamp;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment