...
|
...
|
@@ -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;
|
|
|
}
|
|
|
} |
...
|
...
|
|