提交 79b61e4c 编写于 作者:  Peijun.zhao's avatar Peijun.zhao

Merge remote-tracking branch 'origin/dev-laowang-20200522' into dev-laowang-20200522

流水线 #25930 已失败 于阶段
in 0 second
......@@ -77,6 +77,28 @@
</exclusions>
</dependency>
<dependency>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-completeness-client</artifactId>
<version>1.0.0.0</version>
<exclusions>
<exclusion>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-service-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>io.springfox</groupId>-->
<!--<artifactId>springfox-swagger2</artifactId>-->
<!--<version>2.8.0</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.springfox</groupId>-->
<!--<artifactId>springfox-swagger-ui</artifactId>-->
<!--<version>2.8.0</version>-->
<!--</dependency>-->
<!--<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
......@@ -112,14 +134,6 @@
</dependency>
<!--zipkin dependencies begin-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>com.pica.cloud.account</groupId>
......@@ -195,6 +209,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-proof-client</artifactId>
......
......@@ -8,7 +8,9 @@ import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.util.IntactUtil;
import com.pica.cloud.account.account.server.util.PICAPSendMsgModel;
import com.pica.cloud.foundation.completeness.client.utils.IntactUtils;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode;
......@@ -44,6 +46,9 @@ public abstract class AccountBaseController extends BaseController {
@Autowired
private PropertiesConfiguration configuration;
@Autowired
private IntactUtil intactUtil;
//从token获取医生ID
public long getDoctorIdByToken() {
try {
......@@ -111,6 +116,9 @@ public abstract class AccountBaseController extends BaseController {
//发送手机短信
public void sendMobileMessage(String mobile, String content, long senderId) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"sendMobileMessage",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"mobile:"+mobile+",content:"+content+",senderId:"+senderId);
String sysCodeStr = super.getSysCode();
int sysCode = 10; //默认移动端
if (StringUtils.isNotBlank(sysCodeStr)) {
......@@ -146,6 +154,8 @@ public abstract class AccountBaseController extends BaseController {
logger.info("sendMobileTo-mobile:{}, senderId-{}",mobile, senderId);
long start = System.currentTimeMillis();
String jsonObj = HttpClientUtil.httpExecute(messageUrl, postData);
intactUtil.sendIntact(batchNo,"sendMobileMessage",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"jsonObj:"+jsonObj);
long end1 = System.currentTimeMillis();
logger.info("sendMobileMessage-send message used {} million seconds", end1-start);
logger.info("sendMobileTo-{}", jsonObj);
......
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSON;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
......@@ -11,6 +12,8 @@ import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.account.account.server.service.CaptchaService;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.account.account.server.util.IntactUtil;
import com.pica.cloud.foundation.completeness.client.utils.IntactUtils;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.entity.PicaException;
......@@ -55,6 +58,8 @@ public class AccountController extends AccountBaseController {
private ICacheClient redisClient;
@Autowired
private AccountUtils accountUtils;
@Autowired
private IntactUtil intactUtil;
@GetMapping("/test")
public String test() {
......@@ -105,18 +110,25 @@ public class AccountController extends AccountBaseController {
@ApiOperation("微信登录")
@PostMapping("/login/wechat")
public PicaResponse<String> wechatLogin(@RequestBody AccountReq req) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"wechatLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"req:"+ JSON.toJSONString(req));
if (StringUtils.isBlank(req.getUnionid())) {
intactUtil.sendIntact(batchNo,"wechatLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"确认unionId");
return PicaResponse.toResponse(null, PicaResultCode.PARAM_IS_INVALID.code(), "缺少unionid");
}
Account account = accountService.getByUnionid(req.getUnionid()); //获取账号信息
if (account == null) {
intactUtil.sendIntact(batchNo,"wechatLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该unionid未绑定云鹊医账号");
return PicaResponse.toResponse(null, PicaResultCode.RESULE_DATA_NONE.code(), "该unionid未绑定云鹊医账号");
}
//已经绑定过云鹊医账号,登录成功,返回token
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
String newToken = this.generateToken(account, deviceType);
intactUtil.sendIntact(batchNo,"wechatLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"req:"+ JSON.toJSONString(req));
return PicaResponse.toResponse(newToken);
}
......@@ -124,16 +136,22 @@ public class AccountController extends AccountBaseController {
@PostMapping("/login")
public PicaResponse<String> login(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone());
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"req:"+ JSON.toJSONString(req));
Account account = accountService.getByMobilePhone(req.getMobilePhone()); //获取账号信息
if (account == null) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"未注册,请验证码登录");
return PicaResponse.toResponse(null, PicaResultCode.RESULE_DATA_NONE.code(), "未注册,请验证码登录");
}
if (StringUtils.isBlank(req.getPassword())) { //验证码登录
req.setFlag("0");
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"校验验证码前的返回,因为验证码可能校验不通过,就直接返回了");
this.checkAuthCode(req); //校验验证码
} else { //密码登录
if (!StringUtils.equals(req.getPassword(), account.getPassword())) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"请输入正确的密码");
return PicaResponse.toResponse(null, PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的密码");
}
}
......@@ -152,6 +170,7 @@ public class AccountController extends AccountBaseController {
//登录成功,清除旧token,生成新token
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
String newToken = this.generateToken(account, deviceType);
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"req:"+ JSON.toJSONString(req));
return PicaResponse.toResponse(newToken);
}
......@@ -160,6 +179,9 @@ public class AccountController extends AccountBaseController {
public PicaResponse<LoginResult> register(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone());
accountUtils.checkRegisterMobilePhoneAndAuthCode(req.getMobilePhone(),req.getFlag(),req.getAuthCode());
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"req:"+ JSON.toJSONString(req));
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
Account account = new Account();
account.setMobilePhone(EncryptUtils.encryptContent(req.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE));
......@@ -184,6 +206,7 @@ public class AccountController extends AccountBaseController {
LoginResult result = new LoginResult();
result.setToken(newToken);
intactUtil.sendIntact(batchNo,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"req:"+ JSON.toJSONString(req));
return PicaResponse.toResponse(result);
}
......@@ -193,6 +216,9 @@ public class AccountController extends AccountBaseController {
public PicaResponse loginRegister(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
this.checkMobilePhone(request.getMobile());
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"entity:"+ JSON.toJSONString(entity));
AccountReq req = new AccountReq();
req.setMobilePhone(request.getMobile());
// 登录或注册,只能使用验证码
......@@ -209,12 +235,15 @@ public class AccountController extends AccountBaseController {
if (response.getData() != null) {
LoginResult result = new LoginResult();
result.setToken(response.getData().toString());
intactUtil.sendIntact(batchNo,"loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"登录成功,返回值:"+ JSON.toJSONString(response.getData()));
return PicaResponse.toResponse(result);
}
return response;
} else {
// 注册
PicaResponse<LoginResult> result = this.register(req);
intactUtil.sendIntact(batchNo,"loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"注册成功,返回值:"+ JSON.toJSONString(result));
return result;
}
}
......@@ -290,6 +319,9 @@ public class AccountController extends AccountBaseController {
//清除旧token,生成新token
private String generateToken(Account account, String deviceType) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"generateToken",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"account:"+ JSON.toJSONString(account)+",deviceType:"+deviceType);
String newToken;
switch (deviceType) { //设备信息
case "1": //pc
......@@ -304,9 +336,15 @@ public class AccountController extends AccountBaseController {
default: //H5
newToken = this.generateH5Token(account);
}
intactUtil.sendIntact(batchNo,"generateToken",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"newToken:"+newToken);
return newToken;
}
public static void main(String[] args) {
JSON.toJSONString(null);
System.out.println("成功");
}
/**
* 旧的注册接口,下个版本可以去掉
* @param req
......
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.configuration.PropertiesConfiguration;
import com.pica.cloud.account.account.server.constants.Constants;
......@@ -13,6 +14,7 @@ import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.*;
import com.pica.cloud.account.account.server.util.*;
import com.pica.cloud.foundation.completeness.client.utils.IntactUtils;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode;
......@@ -56,6 +58,9 @@ public class AutoCodeController extends AccountBaseController {
@Autowired
private PropertiesConfiguration propertiesConfiguration;
@Autowired
private IntactUtil intactUtil;
/*@GetMapping("/ip")
public PicaResponse getIp(HttpServletRequest request) {
......@@ -129,20 +134,28 @@ public class AutoCodeController extends AccountBaseController {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setSourceType(super.getSourceType());
AccountUtils.checkMobilePhone(request.getMobile());
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"getAuthCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"authCodeReq:"+ JSON.toJSONString(authCodeReq)+"req:"+ JSON.toJSONString(req));
if (request.getBizType() != null && request.getBizType().equals(1)) {
logger.info("app-rcValidate-start");
// 调用风控接口
authCodeService.rcValidate(req, request, super.getDeviceInfo(), super.getSourceType());
// 发送短信验证码
processSysCode(request.getMobile(), request.getFlag());
processSysCode(request.getMobile(), request.getFlag(),batchNo);
//接入新旭事务一致性
intactUtil.sendIntact(batchNo,"getAuthCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"authCodeReq:"+ JSON.toJSONString(authCodeReq)+"req:"+ JSON.toJSONString(req));
return PicaResponse.toResponse();
} else {
// 老版本业务(发送短信验证码)
processSysCode(request.getMobile(), request.getFlag());
processSysCode(request.getMobile(), request.getFlag(),batchNo);
// 记录风控数据
authCodeService.recordRcData(req, request, super.getDeviceInfo("device_ip"));
intactUtil.sendIntact(batchNo,"getAuthCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"authCodeReq:"+ JSON.toJSONString(authCodeReq)+"req:"+ JSON.toJSONString(req));
return PicaResponse.toResponse();
}
}
......@@ -158,16 +171,22 @@ public class AutoCodeController extends AccountBaseController {
}
AccountUtils.checkMobilePhone(request.getMobile());
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"getH5AuthCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"entity:"+ JSON.toJSONString(entity)+"req:"+ JSON.toJSONString(req));
// 拼图验证
int recordData = authCodeService.validateJigsawCode(req, request);
// 发送短信验证码
processSysCode(request.getMobile(), request.getFlag());
processSysCode(request.getMobile(), request.getFlag(),batchNo);
if (recordData != -1) {
// 记录风控数据(记录是h5端)
authCodeService.recordRcData(req, request, super.getDeviceInfo("device_ip"));
}
intactUtil.sendIntact(batchNo,"getH5AuthCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"entity:"+ JSON.toJSONString(entity)+"req:"+ JSON.toJSONString(req));
return PicaResponse.toResponse();
}
......@@ -197,6 +216,9 @@ public class AutoCodeController extends AccountBaseController {
return PicaResponse.toResponse(null, PicaResultCode.PARAM_IS_INVALID.code(), "图形验证码错误");
}
this.checkMobilePhone(mobilePhone);
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"getAuthCodeWithCaptcha",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"entity:"+ JSON.toJSONString(entity)+"req:"+ JSON.toJSONString(req));
String authCode = CommonUtil.createValidateCode(); //随机生成验证码
String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!";
//判断账号是否已经存在
......@@ -213,6 +235,9 @@ public class AutoCodeController extends AccountBaseController {
// 记录风控数据
authCodeService.recordRcData(req, request, super.getDeviceInfo("device_ip"));
intactUtil.sendIntact(batchNo,"getAuthCodeWithCaptcha",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"entity:"+ JSON.toJSONString(entity)+"req:"+ JSON.toJSONString(req));
return PicaResponse.toResponse(StringUtils.EMPTY);
}
......@@ -230,11 +255,17 @@ public class AutoCodeController extends AccountBaseController {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setFlag(AccountTypeEnum.SYSCODE_TYPE_WE_CHAT.getCode());
AccountUtils.checkMobilePhone(request.getMobile());
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"getWChatSysCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"entity:"+ JSON.toJSONString(entity));
AccountUnionEntity accountUnionEntity = accountUnionService.selectInfoByUnionId(request.getUnionId());
if (accountUnionEntity != null) {
processSysCode(request.getMobile(), request.getFlag());
processSysCode(request.getMobile(), request.getFlag(),batchNo);
intactUtil.sendIntact(batchNo,"getWChatSysCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"entity:"+ JSON.toJSONString(entity));
return PicaResponse.toResponse();
}
intactUtil.sendIntact(batchNo,"getWChatSysCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"entity:"+ JSON.toJSONString(entity));
throw new AccountException(AccountExceptionEnum.PICA_UNBIND_MOBILE);
}
......@@ -248,7 +279,7 @@ public class AutoCodeController extends AccountBaseController {
* @param mobilePhone
* @param flag
*/
private void processSysCode(String mobilePhone, Integer flag) {
private void processSysCode(String mobilePhone, Integer flag,String batchNo) {
String authCodeKey = this.getAuthCodeKey(mobilePhone, flag.toString());
String authCodeKeySecure = authCodeKey + "-secure";
//如果存在,说明刚刚发送过验证码
......@@ -259,6 +290,7 @@ public class AutoCodeController extends AccountBaseController {
} else {
int remainTime = 59 - (int) (System.currentTimeMillis() - time) / 1000;
if (remainTime > 0) {
intactUtil.sendIntact(batchNo,"processSysCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"请X秒后重试");
throw new AccountException(AccountExceptionEnum.PICA_SYSCODE_RETRY.getCode(),
AccountExceptionEnum.PICA_SYSCODE_RETRY.getMessage().replace("X", String.valueOf(remainTime)));
} else {
......@@ -278,6 +310,9 @@ public class AutoCodeController extends AccountBaseController {
* @param authCodeKeySecure
*/
private void processSendAuthCode(String mobilePhone, Integer flag, String authCodeKeySecure) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"processSendAuthCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"mobilePhone:"+mobilePhone+",flag:"+flag+",authCodeKeySecure:"+authCodeKeySecure);
long start = System.currentTimeMillis();
String authCode = CommonUtil.createValidateCode();
String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!";
......@@ -296,6 +331,8 @@ public class AutoCodeController extends AccountBaseController {
super.sendMobileMessage(mobilePhone, message, senderId);
long end2 = System.currentTimeMillis();
logger.info("processSendAuthCode-2 used {} million seconds", end2-start);
intactUtil.sendIntact(batchNo,"processSendAuthCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"mobilePhone:"+mobilePhone+",flag:"+flag+",authCodeKeySecure:"+authCodeKeySecure);
}
//获取验证码redis key
......
......@@ -2,7 +2,9 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountAppleInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
@Component
public interface AccountAppleInfoMapper {
int insert(AccountAppleInfo record);
......
......@@ -3,9 +3,10 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@Component
public interface AccountInfoDetailMapper {
/**
* 通过电话号码查询账号信息
......
......@@ -2,7 +2,9 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountPatientInfoEntity;
import org.springframework.stereotype.Component;
@Component
public interface AccountPatientInfoMapper {
......
......@@ -2,9 +2,10 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountUnionEntity;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public interface AccountUnionMapper {
/**
......
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountWeChatInfoEntity;
import org.springframework.stereotype.Component;
@Component
public interface AccountWeChatInfoMapper {
/**
......
......@@ -3,7 +3,9 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AgreementLogEntity;
import com.pica.cloud.account.account.server.entity.PProtocolLog;
import org.springframework.stereotype.Component;
@Component
public interface AgreementLogEntityMapper {
int deleteByPrimaryKey(Long id);
......
......@@ -5,9 +5,10 @@ import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.entity.DoctorEntity;
import com.pica.cloud.account.account.server.entity.PICAPDoctor;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@Component
public interface DoctorMapper {
/**
* 获取医生信息
......
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.LogLoginAes;
import org.springframework.stereotype.Component;
@Component
public interface LogLoginAesMapper {
int deleteByPrimaryKey(Integer id);
......
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.LogLoginOnekey;
import org.springframework.stereotype.Component;
@Component
public interface LogLoginOnekeyMapper {
int deleteByPrimaryKey(Integer id);
......
......@@ -2,7 +2,9 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.PUserRole;
import org.springframework.stereotype.Component;
@Component
public interface PUserRoleMapper {
int deleteByPrimaryKey(Integer id);
......
package com.pica.cloud.account.account.server.model;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.LogLoginOnekey;
import com.pica.cloud.account.account.server.entity.MobileDataEntity;
import com.pica.cloud.account.account.server.entity.QueryMobileEntity;
import com.pica.cloud.account.account.server.mapper.LogLoginOnekeyMapper;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.HttpUtil;
import com.pica.cloud.account.account.server.util.MD5;
import com.pica.cloud.account.account.server.util.RSAUtil;
import com.pica.cloud.account.account.server.util.SignUtils;
import com.pica.cloud.account.account.server.util.*;
import com.pica.cloud.foundation.completeness.client.utils.IntactUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -30,6 +28,8 @@ import java.util.Map;
*/
@Component
public class OneClickProcessor {
@Autowired
private IntactUtil intactUtil;
private static final String DEFAULT_ENCRYPT_TYPE = "0";
private Logger logger = LoggerFactory.getLogger(this.getClass());
......@@ -84,7 +84,12 @@ public class OneClickProcessor {
params.put(APPID, appId);
params.put(ENCRYPT_TYPE, encryptType);//可以不传,不传则解密直接使用AES解密
params.put(SIGN, SignUtils.getSign(params, appKey));
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"tokenExchangeMobile.postForm(mobileQueryUrl, params, QueryMobileEntity.class)",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"token:"+token+",appId:"+appId+",SIGN:"+SignUtils.getSign(params, appKey) );
queryMobileEntity = HttpUtil.postForm(mobileQueryUrl, params, QueryMobileEntity.class);
intactUtil.sendIntact(batchNo,"tokenExchangeMobile.postForm(mobileQueryUrl, params, QueryMobileEntity.class)",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"token:"+token+",appId:"+appId+",SIGN:"+SignUtils.getSign(params, appKey) );
if (null != queryMobileEntity) {
logger.info("一键登录token换取手机号结果:{}", queryMobileEntity);
String code = queryMobileEntity.getCode(); //返回码 200000为成功
......
package com.pica.cloud.account.account.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.pica.cloud.account.account.common.req.OCINRequest;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.*;
......@@ -11,10 +12,8 @@ import com.pica.cloud.account.account.server.log.AccountLogUtils;
import com.pica.cloud.account.account.server.mapper.*;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.RegisterService;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.ExecutorServiceUtils;
import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.account.account.server.util.*;
import com.pica.cloud.foundation.completeness.client.utils.IntactUtils;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.redis.ICacheClient;
......@@ -58,6 +57,9 @@ public class RegisterServiceImpl implements RegisterService {
private ICacheClient redisClient;
@Autowired
private IntactUtil intactUtil;
/**
* 1)注册功能:默认未完善信息;
* 2)注册成功后发送mq消息,让别的服务初始化数据;
......@@ -74,6 +76,9 @@ public class RegisterServiceImpl implements RegisterService {
@Override
public LoginResult register(BaseRequest baseRequest,QueryMobileEntity queryMobileEntity) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"baseRequest:"+ JSON.toJSONString(baseRequest)+",queryMobileEntity:"+JSON.toJSONString(queryMobileEntity));
String mobile = baseRequest.getMobile();
//对注册接口做幂等性处理:注册成功,删除缓存,注册失败提示用户
String nxKey = Constants.REPEAT_REGISTER_PREFIX + mobile;
......@@ -147,14 +152,20 @@ public class RegisterServiceImpl implements RegisterService {
processAgreement(userId);
processRoleMap(userId);
redisClient.del(nxKey);
intactUtil.sendIntact(batchNo,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"baseRequest:"+ JSON.toJSONString(baseRequest)+",queryMobileEntity:"+JSON.toJSONString(queryMobileEntity));
return result;
} else {
logger.info("register-account is exists");
intactUtil.sendIntact(batchNo,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该手机号已注册,请直接登录");
throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER);
}
} catch (Exception e) {
//向上抛出异常,让异常处理框架捕获到
logger.error("registerException-" + e.getMessage(), e);
intactUtil.sendIntact(batchNo,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"注册失败");
throw new AccountException(AccountExceptionEnum.PICA_REGISTER_FAIL);
} finally {
//如果在注册过程中抛出异常,就删除redis中的注册标记
......@@ -163,6 +174,8 @@ public class RegisterServiceImpl implements RegisterService {
}
} else {
logger.info("register-nxKey is exists");
intactUtil.sendIntact(batchNo,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该手机号已注册,请直接登录");
throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER);
}
}
......
package com.pica.cloud.account.account.server.util;
import com.pica.cloud.foundation.completeness.client.utils.IntactUtils;
import com.pica.cloud.foundation.completeness.contract.req.LogParamsReq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
/**
* @param <T>
* @author jiao.yu
* @version V1.0
* @Description:
* @date 2020/5/22 16:04
*/
@Service
public class IntactUtil {
private final static Logger logger = LoggerFactory.getLogger(IntactUtil.class);
/**
* 对接新旭事务一致性
* @param batchNo
* @param methodName
* @param status
* @param params
*/
public void sendIntact(String batchNo,String methodName,Integer status,String params){
logger.info("开始事务一致性,参数为:batchNo:"+batchNo+",methodName:"+methodName+",status:"+status+",params:"+params);
LogParamsReq req = new LogParamsReq();
req.setBatchNo(batchNo);
req.setMethodName(methodName);
req.setStatus(status);
req.setParams(params);
IntactUtils.sendIntact(req);
logger.info("结束事务一致性");
}
}
......@@ -3,6 +3,8 @@ package com.pica.cloud.account.account.server.util;
import com.alibaba.fastjson.JSON;
import com.pica.cloud.account.account.server.entity.WeChatEntity;
import com.pica.cloud.account.account.server.entity.WeChatUserInfoEntity;
import com.pica.cloud.foundation.completeness.client.utils.IntactUtils;
import com.pica.cloud.foundation.completeness.contract.req.LogParamsReq;
import com.pica.cloud.foundation.utils.constants.WeChatConstants;
import com.pica.cloud.foundation.utils.utils.JsonUtil;
import com.pica.cloud.foundation.utils.utils.StringUtil;
......@@ -32,7 +34,11 @@ public class WeChatUtils {
private static Logger logger = LoggerFactory.getLogger(WeChatUtils.class);
public static WeChatEntity getAuthorizationInfo(String appId, String appSecret, String code) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
sendIntact(batchNo,"getAuthorizationInfo",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"appId:"+appId+",appSecret:"+appSecret+",code:"+code);
logger.info("网页授权获取access_token: code:{}", code);
String requestUrl = WeChatConstants.AUTH_ACCESS_TOKEN_URL.replace("APPID", appId).replace("SECRET", appSecret).replace("CODE", code);
JSONObject jsonObject = WeChatToolUtil.httpRequest(requestUrl, "GET", null);
......@@ -51,6 +57,8 @@ public class WeChatUtils {
logger.error("获取token失败 errcode:{} errmsg:{}", jsonObject.getInt("errcode"), jsonObject.getString("errmsg"));
}
sendIntact(batchNo,"getAuthorizationInfo",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"appId:"+appId+",appSecret"+appSecret+",code:"+code);
return accessToken;
}
......@@ -114,4 +122,23 @@ public class WeChatUtils {
return user;
}
/**
* 对接新旭事务一致性
* @param batchNo
* @param methodName
* @param status
* @param params
*/
public static void sendIntact(String batchNo,String methodName,Integer status,String params){
logger.info("开始事务一致性,参数为:batchNo:"+batchNo+",methodName:"+methodName+",status:"+status+",params:"+params);
LogParamsReq req = new LogParamsReq();
req.setBatchNo(batchNo);
req.setMethodName(methodName);
req.setStatus(status);
req.setParams(params);
IntactUtils.sendIntact(req);
logger.info("结束事务一致性");
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册