|
|
|
@ -44,7 +44,10 @@ import org.thymeleaf.spring5.SpringTemplateEngine;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -744,71 +747,39 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject checkKycFileStatus(JSONObject client) {
|
|
|
|
|
public JSONObject checkKycFileStatus(JSONObject client, JSONObject account, String sourceType) {
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
boolean lessKycFiles = true;
|
|
|
|
|
JSONObject KycFilesAuth = clientComplianceCompanyMapper.findKycFileComplete(client.getIntValue("client_id"));
|
|
|
|
|
if(KycFilesAuth != null){
|
|
|
|
|
JSONObject kycFilesAuth = clientComplianceCompanyMapper.findKycFileComplete(client.getIntValue("client_id"));
|
|
|
|
|
if(kycFilesAuth != null){
|
|
|
|
|
lessKycFiles = false;
|
|
|
|
|
}
|
|
|
|
|
result.put("client_less_file", lessKycFiles);
|
|
|
|
|
List<JSONObject> clientFiles = clientFilesMapper.findAllClientFile(client.getIntValue("client_id"));
|
|
|
|
|
boolean clientFilesIsLess = false;
|
|
|
|
|
for (int i = 0; i < KYC_FILE_KEYS.length; i++) {
|
|
|
|
|
String fileKey = KYC_FILE_KEYS[i];
|
|
|
|
|
if (clientFiles != null && clientFiles.size() > 0) {
|
|
|
|
|
List<JSONObject> clientFileUrl = clientFiles.stream()
|
|
|
|
|
.filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status") == 0 || fileJson.getIntValue("status") == 2|| fileJson.getIntValue("status") == 3)))
|
|
|
|
|
.sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date")))
|
|
|
|
|
.map(json -> {
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
|
params.put("file_id", json.getString("file_id"));
|
|
|
|
|
params.put("file_value", json.getString("file_value"));
|
|
|
|
|
return params;
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
if (clientFileUrl != null && clientFileUrl.size() > 0) {
|
|
|
|
|
JSONObject fileJson = new JSONObject();
|
|
|
|
|
fileJson.put("key", KYC_PUT_KEYS[i]);
|
|
|
|
|
fileJson.put("name", KYC_FILE_NAMES[i]);
|
|
|
|
|
fileJson.put("file_value", clientFileUrl);
|
|
|
|
|
result.put(fileKey,fileJson);
|
|
|
|
|
} else {
|
|
|
|
|
List<JSONObject> clientBackToFileUrl = clientFiles.stream()
|
|
|
|
|
.filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status") == 1)))
|
|
|
|
|
.sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date")))
|
|
|
|
|
.map(json -> {
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
|
params.put("file_id", json.getString("file_id"));
|
|
|
|
|
params.put("file_value", json.getString("file_value"));
|
|
|
|
|
return params;
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
JSONObject fileJson = new JSONObject();
|
|
|
|
|
fileJson.put("key", KYC_PUT_KEYS[i]);
|
|
|
|
|
fileJson.put("name", KYC_FILE_NAMES[i]);
|
|
|
|
|
if (clientBackToFileUrl != null && clientBackToFileUrl.size() > 0) {
|
|
|
|
|
if ("client_agree_file".equals(fileKey)) {
|
|
|
|
|
List<JSONObject> agreeFile = new ArrayList<>();
|
|
|
|
|
agreeFile.add(clientBackToFileUrl.get(0));
|
|
|
|
|
fileJson.put("file_value", agreeFile);
|
|
|
|
|
}else {
|
|
|
|
|
fileJson.put("file_value", clientBackToFileUrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result.put(fileKey,fileJson);
|
|
|
|
|
}
|
|
|
|
|
if (lessKycFiles || account.containsKey("manager_id")) {
|
|
|
|
|
List<JSONObject> kycFiles = new ArrayList<>();
|
|
|
|
|
if ("client".equals(sourceType.toLowerCase())) {
|
|
|
|
|
kycFiles = clientFilesMapper.findKycClientFileByClient(client.getIntValue("client_id"));
|
|
|
|
|
}else {
|
|
|
|
|
for (int c = 0; c < KYC_FILE_KEYS.length; c++) {
|
|
|
|
|
String key = KYC_FILE_KEYS[c];
|
|
|
|
|
JSONObject fileJson = new JSONObject();
|
|
|
|
|
fileJson.put("key", KYC_PUT_KEYS[c]);
|
|
|
|
|
fileJson.put("name", KYC_FILE_NAMES[c]);
|
|
|
|
|
result.put(key,fileJson);
|
|
|
|
|
}
|
|
|
|
|
kycFiles = clientFilesMapper.findKycClientFileByAudit(client.getIntValue("client_id"));
|
|
|
|
|
}
|
|
|
|
|
for (JSONObject file : kycFiles) {
|
|
|
|
|
result.put(file.getString("file_name"), file.getString("file_value"));
|
|
|
|
|
}
|
|
|
|
|
List<JSONObject> clientFileUrl = kycFiles.stream()
|
|
|
|
|
.filter(json -> ("kyc_utility_bill_file".equals(json.getString("file_name"))))
|
|
|
|
|
.sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date")))
|
|
|
|
|
.map(json -> {
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
|
params.put("file_id", json.getString("file_id"));
|
|
|
|
|
params.put("status", json.getString("status"));
|
|
|
|
|
params.put("file_value", json.getString("file_value"));
|
|
|
|
|
return params;
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
if (clientFileUrl.size() > 0) {
|
|
|
|
|
result.put("kyc_utility_bill_file", clientFileUrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|