Authored by qinchao

Merge branch 'dev_authorize' into dev

... ... @@ -19,9 +19,9 @@ public class UserAuthorizeHistory {
//银联返回内容
private String responseContent;
private Integer createTime;
private long createTime;
private Integer updateTime;
private long updateTime;
public Integer getId() {
return id;
... ... @@ -79,19 +79,19 @@ public class UserAuthorizeHistory {
this.responseContent = responseContent;
}
public Integer getCreateTime() {
public long getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public Integer getUpdateTime() {
public long getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
public void setUpdateTime(long updateTime) {
this.updateTime = updateTime;
}
}
... ...
... ... @@ -16,9 +16,9 @@ public class UserAuthorizeInfo {
private String certNo;
private String certName;
private Integer createTime;
private long createTime;
private Integer updateTime;
private long updateTime;
public Integer getId() {
return id;
... ... @@ -68,19 +68,19 @@ public class UserAuthorizeInfo {
this.certName = certName;
}
public Integer getCreateTime() {
public long getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public Integer getUpdateTime() {
public long getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
public void setUpdateTime(long updateTime) {
this.updateTime = updateTime;
}
}
... ...
... ... @@ -16,6 +16,9 @@ public class AuthorizeResultRespVO extends BaseBO {
//认证的姓名
private String name;
//创建时间
private long createTime;
public int getUid() {
return uid;
}
... ... @@ -55,4 +58,12 @@ public class AuthorizeResultRespVO extends BaseBO {
public void setName(String name) {
this.name = name;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
}
... ...
... ... @@ -30,6 +30,7 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Random;
import java.util.concurrent.ExecutorService;
... ... @@ -86,6 +87,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
result.setCardNo(info.getCardNo());
result.setCertNo(info.getCertNo());
result.setName(info.getCertName());
result.setCreateTime(info.getCreateTime());
}else{
result.setAuthorizeFlag(false);
}
... ... @@ -118,6 +120,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
int responseCode=responseEntity.getStatusCodeValue();
String responseContent=String.valueOf(responseEntity.getBody());
ApiResponse apiResponse=new ApiResponse(400,responseContent,null);
long ts=getLocalDateTime().toEpochSecond(ZoneOffset.of("+8"));
if(responseCode==200){
UserAuthorizeInfo userAuthorizeInfo =new UserAuthorizeInfo();
try{
... ... @@ -126,6 +129,8 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
userAuthorizeInfo.setCardNo(cardNo);
userAuthorizeInfo.setCertNo(certNo);
userAuthorizeInfo.setCertName(name);
userAuthorizeInfo.setCreateTime(ts);
userAuthorizeInfo.setUpdateTime(ts);
userAuthorizeInfoDao.insert(userAuthorizeInfo);
apiResponse.setCode(200);
... ... @@ -139,7 +144,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
}
//访问银联接口记录日志
recordHistory(uid,cardNo,certNo,name,responseCode,responseContent);
recordHistory(uid,cardNo,certNo,name,responseCode,responseContent,ts);
return apiResponse;
}
... ... @@ -221,7 +226,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
/**
* 无论成功还是失败,都把访问记录日志表
*/
private void recordHistory(int uid,String cardNo,String certNo,String name,int responseCode,String responseContent){
private void recordHistory(int uid,String cardNo,String certNo,String name,int responseCode,String responseContent,long ts){
UserAuthorizeHistory history=new UserAuthorizeHistory();
history.setUid(uid);
history.setCardNo(cardNo);
... ... @@ -229,7 +234,8 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
history.setCertName(name);
history.setResponseCode(responseCode);
history.setResponseContent(responseContent);
history.setCreateTime(ts);
history.setUpdateTime(ts);
//最后记录日志 ,异步
executeService.execute(()->{
try{
... ... @@ -251,8 +257,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
String appId="2c909a515499b76b01549a01d2730000";
String appKey="keyqinchao";
//当前时间戳 ,要求格式 yyyyMMddHHmmss
LocalDateTime now=LocalDateTime.now();
String timestamp=df.format(now);
String timestamp=getLocalDateTime().format(df);
//随机的正整数,不超过128位
int nonce = (new Random()).nextInt(100000);
... ... @@ -276,4 +281,8 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
return sb.toString();
}
private LocalDateTime getLocalDateTime(){
LocalDateTime now=LocalDateTime.now();
return now;
}
}
... ...