master
wangning 7 years ago
parent 4cbbc04a2e
commit dc5651cdee

@ -255,6 +255,8 @@ public interface ClientManager {
void getAggregateAgreeFile(String clientMoniker, JSONObject manager,boolean renewal) throws Exception;
void getNewAggregateAgreeFile(String clientMoniker, JSONObject manager,boolean renewal) throws Exception;
void temporaryExportPdf(String clientMoniker, JSONObject manager, HttpServletResponse httpResponse) throws Exception;
void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile,boolean renewal);

@ -1914,7 +1914,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
// }
// });
JSONObject weChatRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Wechat");
if (weChatRate == null) {
throw new BadRequestException("The Partner's Rate is not config!");
@ -1974,6 +1973,74 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
@Override
@Transactional
public void getNewAggregateAgreeFile(String clientMoniker, JSONObject manager, boolean renewal) throws Exception {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
String address = client.getString("address").trim();
if (address.contains(",")) {
client.put("address", address.substring(0, address.lastIndexOf(",")).trim());
client.put("address_sub", address.substring(address.lastIndexOf(",") + 1).trim());
}
if (client.getString("acn") != null && !client.getString("acn").equals("")) {
client.put("acn_type", "ACN: (" + client.getString("acn") + ")");
client.put("company_name_acn", client.getString("company_name") + " (ACN " + client.getString("acn") + ")");
} else {
client.put("acn_type", "ABN: (" + client.getString("abn") + ")");
client.put("company_name_acn", client.getString("company_name") + " (ABN " + client.getString("abn") + ")");
}
List<JSONObject> clientRate = clientRateMapper.latestConfig(client.getIntValue("client_id"), null);
if (CollectionUtils.isEmpty(clientRate)) {
throw new BadRequestException("The Partner's Rate is not config!");
}
clientRate.forEach((p) -> {
String rate_name = p.getString("rate_name");
if ("Wechat".equals(rate_name)) {
client.put("wechat_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
client.put("clean", "T+" + p.getString("clean_days"));
client.put("clean_days", p.getString("clean_days"));
} else if ("Alipay".equals(rate_name)) {
client.put("alipay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
} else if ("Bestpay".equals(rate_name)) {
client.put("bestpay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
} else if ("jd".equals(rate_name)) {
client.put("jd_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
} else if ("AlipayOnline".equals(rate_name)) {
client.put("alipay_online_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}
});
JSONObject account = getBankAccountByClientId(client.getIntValue("client_id"));
if (account == null || account.size() <= 0) {
throw new BadRequestException("The Partner's Account is not config!");
}
client.put("bank", account.getString("bank"));
client.put("bsb_no", account.getString("bsb_no"));
client.put("account_no", account.getString("account_no"));
client.put("account_name", account.getString("account_name"));
String start_date = DateFormatUtils.format(new Date(), "dd/MM/yyyy");
client.put("start_date", start_date);
PdfUtils pdu = new PdfUtils();
pdu.setTemplatePdfPath(aggregateAgreetemplatePdfPath);
pdu.setPdfTemplate(client);
try {
File file = new File(clientMoniker + "_agreement.pdf");
ByteArrayOutputStream bos = pdu.templetPdfBos(file);
InputStream stream = new ByteArrayInputStream(bos.toByteArray());
JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker + "_" + System.currentTimeMillis() + "_agreement.pdf", false);
if (fileRes != null) {
importAgreeFile(clientMoniker, manager, fileRes.getString("url"), renewal);
}
stream.close();
} catch (Exception e) {
logger.error("合同制作出现问题:", e);
}
}
@Override
public void temporaryExportPdf(String clientMoniker, JSONObject manager, HttpServletResponse httpResponse) throws Exception {
httpResponse.setContentType("application/pdf");
@ -3178,25 +3245,35 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
JSONObject account = clientAccountMapper.findById(account_id);
boolean expire = result.getBoolean("rate_expire");
boolean waring = result.getBoolean("rate_waring");
boolean old_contract = result.getBoolean("old_contract");
if (PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) {
result.put("is_ordinary", true);
if (!expire && waring) {
String[] key = { result.getString("expire_days") };
result.put("contract_info", editContractOrdinaryWaring(key, messageSource.getMessage("sys.contract.ordinary.waring", null, RequestEnvironment.getLocale())));
result.put("contract_info",
editContractOrdinaryWaring(key, messageSource.getMessage("sys.contract.ordinary.waring", null, RequestEnvironment.getLocale())));
}
if (expire) {
result.put("contract_info", messageSource.getMessage("sys.contract.ordinary.info", null, RequestEnvironment.getLocale()));
}
return result;
if (old_contract) {
result.put("contract_info", messageSource.getMessage("contract.old.waring", null, RequestEnvironment.getLocale()));
}
} else {
result.put("is_ordinary", false);
if (!expire && waring) {
String[] key = { result.getString("expire_days") };
result.put("contract_info", editContractOrdinaryWaring(key,messageSource.getMessage("sys.contract.waring", null, RequestEnvironment.getLocale())));
result.put("contract_info",
editContractOrdinaryWaring(key, messageSource.getMessage("sys.contract.waring", null, RequestEnvironment.getLocale())));
}
if (expire) {
result.put("contract_info", messageSource.getMessage("sys.contract.info", null, RequestEnvironment.getLocale()));
}
if (old_contract) {
result.put("contract_info", messageSource.getMessage("contract.old.waring", null, RequestEnvironment.getLocale()));
}
}
JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id"), "pc");
if (file != null) {
result.put("file_url", file.getString("file_value"));
@ -3204,7 +3281,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
result.put("file_url", "");
}
return result;
}
}
@ -3213,6 +3289,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return "";
}
for (int i = 0; i < key.length; i++) {
if (key[i] == null) {
return "";
}
sourceStr = sourceStr.replace("{" + i + "}", key[i]);
}
return sourceStr;

@ -54,9 +54,9 @@ public class ClientContractServiceImpl implements ClientContractService {
JSONObject expireInfo = getClientContractExpire(client_id);
JSONObject contract = clientsContractMapper.findByClientId(client_id);
Date now = new Date();
if (expireInfo.getBoolean("rate_waring") && (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0)) {
if ((expireInfo.getBoolean("rate_waring")||expireInfo.getBoolean("old_contract")) && (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0)) {
try {
clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null,true);
clientManager.getNewAggregateAgreeFile(client.getString("client_moniker"), null, true);
} catch (Exception e) {
logger.info("App generate PDF failed");
throw new ServerErrorException("System error");
@ -100,6 +100,7 @@ public class ClientContractServiceImpl implements ClientContractService {
JSONObject rateExpire = getClientContractExpire(client_id);
boolean expire = rateExpire.getBoolean("rate_expire");
boolean waring = rateExpire.getBoolean("rate_waring");
boolean old_contract = rateExpire.getBoolean("old_contract");
JSONObject contract = clientsContractMapper.findByClientId(client_id);
if (contract == null) {
throw new BadRequestException("generate contract first");
@ -117,7 +118,7 @@ public class ClientContractServiceImpl implements ClientContractService {
contract.put("signatory", account.getString("display_name"));
clientsContractMapper.update(contract);
List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null);
if(expire){
if (expire || old_contract) {
rateInfo.forEach((p) -> {
p.remove("client_rate_id");
p.put("create_time", now);
@ -129,7 +130,7 @@ public class ClientContractServiceImpl implements ClientContractService {
clientRateMapper.saveRate(p);
});
}
if(!expire && waring){
if (!expire && waring && !old_contract) {
rateInfo.forEach((p) -> {
p.remove("client_rate_id");
p.put("create_time", now);
@ -167,6 +168,7 @@ public class ClientContractServiceImpl implements ClientContractService {
if (sysconfig != null && !sysconfig.getBoolean("sys_new_contract_on")) {
return defaultResult;
}
List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null);
JSONObject result = new JSONObject();
if (CollectionUtils.isEmpty(rateInfo)) {
@ -176,12 +178,13 @@ public class ClientContractServiceImpl implements ClientContractService {
}
result.put("rate_expire", false);
result.put("rate_waring", false);
result.put("old_contract", 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;
}
int waringDays = sysConfigManager.getSysConfig().getIntValue("rate_warning_days");
int waringDays = sysconfig.getIntValue("rate_warning_days");
Map<String, JSONObject> filterMap = new HashMap<>();
rateInfo.forEach((p) -> {
String key = p.getString("rate_name");
@ -195,8 +198,6 @@ public class ClientContractServiceImpl implements ClientContractService {
}
});
for (JSONObject p : filterMap.values()) {
if (now.compareTo(DateUtils.addDays(p.getDate("expiry_time"), 1)) > -1) {
result.put("rate_expire", true);
@ -212,7 +213,19 @@ public class ClientContractServiceImpl implements ClientContractService {
result.put("rate_waring", true);
}
}
if(!result.getBoolean("rate_waring") && !result.getBoolean("rate_expire")){
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
if (CollectionUtils.isEmpty(files)) {
result.put("old_contract", true);
result.put("rate_waring", true);
} else {
JSONObject file = files.get(0);
if (sysconfig.getDate("sys_new_contract_time").compareTo(file.getDate("last_update_date")) > 0 || (contract!=null && !contract.getBoolean("has_sign"))) {
result.put("old_contract", true);
result.put("rate_waring", true);
}
}
}
return result;
}

@ -1,6 +1,6 @@
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.schema-name=royalpay_production
spring.datasource.host=192.168.0.49:3306
spring.datasource.host=192.168.99.100:3306
spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=root

@ -1,6 +1,6 @@
server.port=5000
spring.profiles.active=dev,alipay,bestpay,jd,wechat
spring.profiles.active=local,alipay,bestpay,jd,wechat
env.company=RoyalPay
@ -18,8 +18,8 @@ spring.datasource.max-idle=150
spring.datasource.max-wait=3000
spring.datasource.filters=stat,wall,log4j
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.host=192.168.99.100
spring.redis.port=32768
spring.redis.database=1
mybatis.autosql.default-dialect=mysql

@ -105,6 +105,6 @@ sys.contract.ordinary.info=Dear merchant, your service contract with ROYALPAY ha
sys.contract.ordinary.waring=Dear merchant, your service contract with ROYALPAY expires in {0} days. In order not to affect your normal use, please contact your supervisor or use your administrator account as soon as possible in order to renew your service contract.
sys.contract.waring=Dear merchant, your service contract with ROYALPAY is due to expire in {0} days. In order not to affect your normal use, please see the latest service agreement for renewal.
sys.contract.info=Dear merchant, your service contract with ROYALPAY has expired. Please check the latest service agreement to renew your contract so as not to affect your normal use.
contract.old.waring=Dear Valued Merchants to ensure we comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST. This will result in contractual changes to your agreement,please read it carefully.
sys.mondelay.cancel.waring=Are you sure to quit this activity?

@ -99,5 +99,5 @@ sys.contract.ordinary.info=尊敬的商户您与ROYALPAY的服务合同已到
sys.contract.ordinary.waring=尊敬的商户您与ROYALPAY的服务合同还有{0}天到期,为了不影响您的正常使用,请尽快联系您的主管或使用管理员账户登录以便进行服务续约
sys.contract.waring=尊敬的商户您与ROYALPAY的服务合同还有{0}天到期,为了不影响您的正常使用,请查看最新服务协议进行续约。
sys.contract.info=尊敬的商户您与ROYALPAY的服务合同已到期为了不影响您的正常使用请查看最新服务协议进行续约。
contract.old.waring=尊敬的商户RoyalPay于近期正式收到澳洲监管机构的通知应澳大利亚税务局ATO的要求进行了合同上GST部分的相应调整。请仔细阅读合同条款并确认。
sys.mondelay.cancel.waring=是否确认退出活动
Loading…
Cancel
Save