|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
package au.com.royalpay.payment.manage.apps.core.impls;
|
|
|
|
|
package au.com.royalpay.payment.manage.system.core.impl;
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
|
|
|
|
|
import au.com.royalpay.payment.manage.apps.core.AppFileService;
|
|
|
|
|
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.ClientsContractMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
|
import au.com.royalpay.payment.manage.system.core.ClientContractService;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
@ -24,9 +25,9 @@ import java.util.List;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class AppFileServiceImpl implements AppFileService {
|
|
|
|
|
public class ClientContractServiceImpl implements ClientContractService {
|
|
|
|
|
|
|
|
|
|
Logger logger = LoggerFactory.getLogger(AppFileServiceImpl.class);
|
|
|
|
|
Logger logger = LoggerFactory.getLogger(ClientContractServiceImpl.class);
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientFilesMapper clientFilesMapper;
|
|
|
|
|
@Resource
|
|
|
|
@ -35,6 +36,8 @@ public class AppFileServiceImpl implements AppFileService {
|
|
|
|
|
private ClientsContractMapper clientsContractMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private RetailAppService retailAppService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientRateMapper clientRateMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
@ -56,7 +59,7 @@ public class AppFileServiceImpl implements AppFileService {
|
|
|
|
|
saveContract(client_id, now);
|
|
|
|
|
return files.get(0);
|
|
|
|
|
} else {
|
|
|
|
|
JSONObject expireInfo = retailAppService.getClientContractExpire(client_id);
|
|
|
|
|
JSONObject expireInfo = getClientContractExpire(client_id);
|
|
|
|
|
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
|
|
|
|
|
JSONObject file = files.get(0);
|
|
|
|
|
if (expireInfo.getBoolean("rate_expire")) {
|
|
|
|
@ -98,4 +101,32 @@ public class AppFileServiceImpl implements AppFileService {
|
|
|
|
|
return files.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getClientContractExpire(int client_id) {
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(client_id);
|
|
|
|
|
if (client == null) {
|
|
|
|
|
throw new NotFoundException("merchant not found please check ID");
|
|
|
|
|
}
|
|
|
|
|
List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null);
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
result.put("rate_expire", false);
|
|
|
|
|
result.put("rate_waring", false);
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
JSONObject contract = clientsContractMapper.findByClientId(client_id);
|
|
|
|
|
if(contract!=null && contract.getDate("expiry_date").compareTo(now)>0 && contract.getBoolean("has_sign")){
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtils.isEmpty(rateInfo)) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
rateInfo.forEach((p)->{
|
|
|
|
|
if (now.compareTo(p.getDate("expiry_time")) > -1) {
|
|
|
|
|
result.put("rate_expire", true);
|
|
|
|
|
}
|
|
|
|
|
if (DateUtils.addDays(now, 10).compareTo(p.getDate("expiry_time")) > -1) {
|
|
|
|
|
result.put("rate_waring", true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|