master
wangning 7 years ago
parent 1019f2ef9f
commit fef08a3f58

@ -1,6 +1,5 @@
package au.com.royalpay.payment.manage.system.core.impl; package au.com.royalpay.payment.manage.system.core.impl;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
@ -35,8 +34,6 @@ public class ClientContractServiceImpl implements ClientContractService {
@Resource @Resource
private ClientsContractMapper clientsContractMapper; private ClientsContractMapper clientsContractMapper;
@Resource @Resource
private RetailAppService retailAppService;
@Resource
private ClientRateMapper clientRateMapper; private ClientRateMapper clientRateMapper;
@Override @Override
@ -46,9 +43,15 @@ public class ClientContractServiceImpl implements ClientContractService {
if (client == null) { if (client == null) {
throw new NotFoundException("merchant not found"); throw new NotFoundException("merchant not found");
} }
JSONObject expireInfo = getClientContractExpire(client_id);
if(expireInfo.getBoolean("rate_waring")){
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
return files.get(0);
}
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 ) {
try { try {
clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null); clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null);
} catch (Exception e) { } catch (Exception e) {
@ -59,7 +62,6 @@ public class ClientContractServiceImpl implements ClientContractService {
saveContract(client_id, now); saveContract(client_id, now);
return files.get(0); return files.get(0);
} else { } else {
JSONObject expireInfo = 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")) {
@ -83,13 +85,39 @@ public class ClientContractServiceImpl implements ClientContractService {
} }
@Override @Override
@Transactional
public void confirmSourceAgreement(int client_id) { public void confirmSourceAgreement(int client_id) {
JSONObject file = clientsContractMapper.findByClientId(client_id); JSONObject rateExpire = getClientContractExpire(client_id);
if (file == null) { boolean expire = rateExpire.getBoolean("rate_expire");
boolean waring = rateExpire.getBoolean("rate_waring");
if(!(expire && waring)){
return;
}
JSONObject contract = clientsContractMapper.findByClientId(client_id);
if (contract == null) {
throw new BadRequestException("generate contract first"); throw new BadRequestException("generate contract first");
} }
file.put("has_sign", 1); contract.put("has_sign", 1);
clientsContractMapper.update(file); clientsContractMapper.update(contract);
Date now = new Date();
List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null);
if(expire){
rateInfo.forEach((p)->{
p.remove("client_rate_id");
p.put("create_time",now);
p.put("active_time",now);
p.put("expiry_time",DateUtils.addYears(now,1));
});
}
if(!expire && waring){
rateInfo.forEach((p)->{
p.remove("client_rate_id");
p.put("create_time",now);
p.put("active_time",DateUtils.addYears(p.getDate("active_time"),1));
p.put("expiry_time",DateUtils.addYears(p.getDate("expiry_time"),1));
});
}
} }
@Override @Override
@ -109,17 +137,20 @@ public class ClientContractServiceImpl implements ClientContractService {
} }
List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null); List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null);
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
if (CollectionUtils.isEmpty(rateInfo)) {
result.put("rate_expire", true);
result.put("rate_waring", true);
return result;
}
result.put("rate_expire", false); result.put("rate_expire", false);
result.put("rate_waring", false); result.put("rate_waring", false);
Date now = new Date(); Date now = new Date();
JSONObject contract = clientsContractMapper.findByClientId(client_id); JSONObject contract = clientsContractMapper.findByClientId(client_id);
if(contract!=null && contract.getDate("expiry_date").compareTo(now)>0 && contract.getBoolean("has_sign")){ if (contract != null && contract.getDate("expiry_date").compareTo(now) > 0 && contract.getBoolean("has_sign")) {
return result; return result;
} }
if (CollectionUtils.isEmpty(rateInfo)) {
return result; rateInfo.forEach((p) -> {
}
rateInfo.forEach((p)->{
if (now.compareTo(p.getDate("expiry_time")) > -1) { if (now.compareTo(p.getDate("expiry_time")) > -1) {
result.put("rate_expire", true); result.put("rate_expire", true);
} }

Loading…
Cancel
Save