|
|
@ -6,6 +6,8 @@ import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
@ -14,6 +16,7 @@ import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -37,6 +40,9 @@ public class AppFileServiceImpl implements AppFileService {
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public JSONObject getOrGenerateSourceAgreement(int client_id) {
|
|
|
|
public JSONObject getOrGenerateSourceAgreement(int client_id) {
|
|
|
|
JSONObject client = clientManager.getClientInfo(client_id);
|
|
|
|
JSONObject client = clientManager.getClientInfo(client_id);
|
|
|
|
|
|
|
|
if (client == null) {
|
|
|
|
|
|
|
|
throw new NotFoundException("merchant not found");
|
|
|
|
|
|
|
|
}
|
|
|
|
JSONObject contract = clientsContractMapper.findByClientId(client_id);
|
|
|
|
JSONObject contract = clientsContractMapper.findByClientId(client_id);
|
|
|
|
Date now = new Date();
|
|
|
|
Date now = new Date();
|
|
|
|
if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) {
|
|
|
|
if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) {
|
|
|
@ -44,18 +50,20 @@ public class AppFileServiceImpl implements AppFileService {
|
|
|
|
clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null);
|
|
|
|
clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.info("App generate PDF failed");
|
|
|
|
logger.info("App generate PDF failed");
|
|
|
|
|
|
|
|
throw new ServerErrorException("System error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
|
|
|
|
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
|
|
|
|
saveContract(client_id, now);
|
|
|
|
saveContract(client_id, now);
|
|
|
|
return files.get(0);
|
|
|
|
return files.get(0);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
JSONObject expireInfo = retailAppService.getClientRateExpire(client_id);
|
|
|
|
JSONObject expireInfo = retailAppService.getClientContractExpire(client_id);
|
|
|
|
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
|
|
|
|
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
|
|
|
|
JSONObject file = files.get(0);
|
|
|
|
JSONObject file = files.get(0);
|
|
|
|
if (expireInfo.getBoolean("rate_expire")) {
|
|
|
|
if (expireInfo.getBoolean("rate_expire")) {
|
|
|
|
file.put("last_update_date",now);
|
|
|
|
contract.put("create_time", now);
|
|
|
|
|
|
|
|
contract.put("expiry_date", DateUtils.addYears(now, 1));
|
|
|
|
|
|
|
|
clientsContractMapper.update(contract);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clientFilesMapper.update(file);
|
|
|
|
|
|
|
|
return file;
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -81,4 +89,13 @@ public class AppFileServiceImpl implements AppFileService {
|
|
|
|
clientsContractMapper.update(file);
|
|
|
|
clientsContractMapper.update(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public JSONObject getSourceAgreement(int client_id) {
|
|
|
|
|
|
|
|
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(files)) {
|
|
|
|
|
|
|
|
throw new NotFoundException("Contract not generated");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return files.get(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|