fix client_less_info

master
luoyang 7 years ago
parent a4481c6c0e
commit 94ad879dc5

@ -57,4 +57,6 @@ public interface SignInAccountService {
void deleteClientCodeKey(String codekey); void deleteClientCodeKey(String codekey);
void deleteManagerCodeKey(String codekey); void deleteManagerCodeKey(String codekey);
JSONObject checkAuthFileStatus(JSONObject client);
} }

@ -96,6 +96,7 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
public void init() { public void init() {
tags.add("account"); tags.add("account");
} }
@Override @Override
@Cacheable(value = ":login:managers:", key = "''+#accountId") @Cacheable(value = ":login:managers:", key = "''+#accountId")
public JSONObject getManager(String accountId) { public JSONObject getManager(String accountId) {
@ -159,7 +160,18 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
} }
client.putAll(clientConfigService.find(client_id)); client.putAll(clientConfigService.find(client_id));
client = clientInfoWithNoSecretInfo(client); client = clientInfoWithNoSecretInfo(client);
checkAuthFileStatus(client); client.put("client_less_file", false);
if (client.getIntValue("approve_result") == 2 || client.getIntValue("open_status") == 10) {
List<JSONObject> clientFiles = clientFilesMapper.findAllClientFile(client.getIntValue("client_id"));
if (clientFiles != null && clientFiles.size() > 0) {
String[] fileKeys = {"client_bank_file", "client_company_file", "client_id_file", "client_agree_file"};
for (String fileKey : fileKeys) {
if (clientFiles.stream().noneMatch(fileJson -> fileKey.equals(fileJson.getString("file_name")))) {
client.put("client_less_file", true);
}
}
}
}
if (client.getInteger("parent_client_id") != null) { if (client.getInteger("parent_client_id") != null) {
JSONObject rootPartner = clientManager.getClientInfoIgnoreInvalid(client.getIntValue("parent_client_id")); JSONObject rootPartner = clientManager.getClientInfoIgnoreInvalid(client.getIntValue("parent_client_id"));
rootPartner.putAll(clientConfigService.find(client.getIntValue("parent_client_id"))); rootPartner.putAll(clientConfigService.find(client.getIntValue("parent_client_id")));
@ -619,7 +631,9 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
return RESET_MANAGER_ACCOUNT_PREFIX + codeKey; return RESET_MANAGER_ACCOUNT_PREFIX + codeKey;
} }
private void checkAuthFileStatus(JSONObject client) { public JSONObject checkAuthFileStatus(JSONObject client) {
JSONObject result = new JSONObject();
result.put("client_less_file", false);
if (client.getIntValue("approve_result") == 2 || client.getIntValue("open_status") == 10) { if (client.getIntValue("approve_result") == 2 || client.getIntValue("open_status") == 10) {
List<JSONObject> clientFiles = clientFilesMapper.findAllClientFile(client.getIntValue("client_id")); List<JSONObject> clientFiles = clientFilesMapper.findAllClientFile(client.getIntValue("client_id"));
String[] fileKeys = {"client_bank_file", "client_company_file", "client_id_file", "client_agree_file"}; String[] fileKeys = {"client_bank_file", "client_company_file", "client_id_file", "client_agree_file"};
@ -629,22 +643,34 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
List<JSONObject> resultFile = new ArrayList<>(); List<JSONObject> resultFile = new ArrayList<>();
for (int i = 0; i < fileKeys.length; i++) { for (int i = 0; i < fileKeys.length; i++) {
String fileKey = fileKeys[i]; String fileKey = fileKeys[i];
List<String> clientFileUrl = clientFiles.stream() if (clientFiles != null && clientFiles.size() > 0) {
List<JSONObject> clientFileUrl = clientFiles.stream()
.filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status") == 1 || fileJson.getIntValue("status") == 2))) .filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status") == 1 || fileJson.getIntValue("status") == 2)))
.sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date"))) .sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date")))
.map(json -> json.getString("file_value")) .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()); .collect(Collectors.toList());
if (clientFileUrl != null && clientFileUrl.size() > 0) { if (clientFileUrl != null && clientFileUrl.size() > 0) {
JSONObject fileJson = new JSONObject(); JSONObject fileJson = new JSONObject();
fileJson.put("key", putKeys[i]); fileJson.put("key", putKeys[i]);
fileJson.put("name", fileNames[i]); fileJson.put("name", fileNames[i]);
fileJson.put("file_value", clientFileUrl); fileJson.put("file_value", clientFileUrl);
fileJson.put("file_write", false);
resultFile.add(fileJson); resultFile.add(fileJson);
} else { } else {
List<String> clientBackToFileUrl = clientFiles.stream() List<JSONObject> clientBackToFileUrl = clientFiles.stream()
.filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status")==0 || fileJson.getIntValue("status")==2))) .filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status") == 0 || fileJson.getIntValue("status") == 3)))
.sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date"))) .sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date")))
.map(json -> json.getString("file_value")) .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()); .collect(Collectors.toList());
JSONObject fileJson = new JSONObject(); JSONObject fileJson = new JSONObject();
fileJson.put("key", putKeys[i]); fileJson.put("key", putKeys[i]);
@ -652,16 +678,18 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
if (clientBackToFileUrl != null && clientBackToFileUrl.size() > 0) { if (clientBackToFileUrl != null && clientBackToFileUrl.size() > 0) {
fileJson.put("file_value", clientBackToFileUrl); fileJson.put("file_value", clientBackToFileUrl);
} }
fileJson.put("file_write", true);
resultFile.add(fileJson); resultFile.add(fileJson);
clientFilesIsLess = true; clientFilesIsLess = true;
} }
} }
client.put("greenChannel", 1); result.put("client_less_file", clientFilesIsLess);
client.put("client_less_file", clientFilesIsLess);
if (clientFilesIsLess) { if (clientFilesIsLess) {
client.put("client_files", resultFile); result.put("client_files", resultFile);
}
} }
} }
return result;
} }
} }

Loading…
Cancel
Save