|
|
|
@ -206,9 +206,11 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
@Resource
|
|
|
|
|
private AttachmentClient attachmentClient;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientBankAccountMapper clientBankAccountMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
private final String CBBANK_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/05/1564972204689_uwZvpTBjtLUMcN8c540xcZvux1Rd3O.pdf";
|
|
|
|
|
private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/16/1565936989217_WDSAGRKhBHTD6s6HGcZPeirOXCyzbn.pdf";
|
|
|
|
|
private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/22/1566440384256_R7Jc3cl5JPZsmVznKffzStwVMELwsl.pdf";
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private SmsSender smsSender;
|
|
|
|
@ -2204,7 +2206,7 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
client.put("bank_account_number", bankAccount.getString("account_no"));
|
|
|
|
|
client.put("bank_account_name", bankAccount.getString("account_name"));
|
|
|
|
|
}
|
|
|
|
|
exportAggregateFile(client, httpResponse);
|
|
|
|
|
exportCBBankAggregateFile(client, httpResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -2220,32 +2222,69 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id"));
|
|
|
|
|
client.put("now", DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
|
|
|
|
|
String clientName = "";
|
|
|
|
|
clientName = client.getString("business_name");
|
|
|
|
|
if (StringUtils.isNotBlank(client.getString("acn"))) {
|
|
|
|
|
clientName += "(" + client.getString("acn") + ")";
|
|
|
|
|
client.put("client_acn", client.getString("acn"));
|
|
|
|
|
}
|
|
|
|
|
client.put("client_name", clientName);
|
|
|
|
|
client.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
|
client.put("client_phone", client.getString("contact_phone"));
|
|
|
|
|
client.put("client_email", client.getString("contact_email"));
|
|
|
|
|
client.put("client_address", (client.getString("address") + "\n" + client.getString("suburb") + ' ' + client.getString("state") + ' ' + client.getString("postcode")));
|
|
|
|
|
JSONObject rate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay");
|
|
|
|
|
if (rate != null) {
|
|
|
|
|
client.put("client_rate", (rate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN).toPlainString() + "%"));
|
|
|
|
|
int cleanDays = rate.getIntValue("clean_days");
|
|
|
|
|
client.put("clean_days", ("T+" + cleanDays));
|
|
|
|
|
client.put("days", cleanDays);
|
|
|
|
|
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") + ")");
|
|
|
|
|
}
|
|
|
|
|
JSONObject bankAccount = clientManager.getBankAccountByClientId(client.getIntValue("client_id"));
|
|
|
|
|
if (bankAccount != null) {
|
|
|
|
|
client.put("bank_name", bankAccount.getString("bank"));
|
|
|
|
|
client.put("bank_country", bankAccount.getString("city"));
|
|
|
|
|
client.put("bank_account_number", bankAccount.getString("account_no"));
|
|
|
|
|
client.put("bank_account_name", bankAccount.getString("account_name"));
|
|
|
|
|
|
|
|
|
|
JSONObject weChatRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Wechat");
|
|
|
|
|
if (weChatRate == null) {
|
|
|
|
|
throw new BadRequestException("The Partner's Rate is not config!");
|
|
|
|
|
}
|
|
|
|
|
client.put("wechat_rate", weChatRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
client.put("clean", "T+" + weChatRate.getString("clean_days"));
|
|
|
|
|
client.put("clean_days", weChatRate.getString("clean_days"));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
JSONObject alipayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Alipay");
|
|
|
|
|
if (alipayRate != null) {
|
|
|
|
|
client.put("alipay_rate", alipayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject bestPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Bestpay");
|
|
|
|
|
if (bestPayRate != null) {
|
|
|
|
|
client.put("bestpay_rate", bestPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject jdRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "jd");
|
|
|
|
|
if (jdRate != null) {
|
|
|
|
|
client.put("jd_rate", jdRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject alipayOnlineRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "AlipayOnline");
|
|
|
|
|
if (alipayOnlineRate != null) {
|
|
|
|
|
client.put("alipay_online_rate", alipayOnlineRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject cbBankPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay");
|
|
|
|
|
if (cbBankPayRate != null) {
|
|
|
|
|
client.put("cbbank_rate", cbBankPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
throw new BadRequestException("Merchant Rate Not Configure");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject bankAccount = getBankAccountByClientId(client.getIntValue("client_id"));
|
|
|
|
|
if (bankAccount == null || bankAccount.size() <= 0) {
|
|
|
|
|
throw new BadRequestException("The Partner's Account is not config!");
|
|
|
|
|
}
|
|
|
|
|
client.put("bank", bankAccount.getString("bank"));
|
|
|
|
|
client.put("bsb_no", bankAccount.getString("bsb_no"));
|
|
|
|
|
client.put("account_no", bankAccount.getString("account_no"));
|
|
|
|
|
client.put("account_name", bankAccount.getString("account_name"));
|
|
|
|
|
String start_date = DateFormatUtils.format(new Date(), "dd/MM/yyyy");
|
|
|
|
|
client.put("start_date", start_date);
|
|
|
|
|
Date endDate = TimeZoneUtils.nextYearByCurrDay();
|
|
|
|
|
String end_date = DateFormatUtils.format(endDate, "dd/MM/yyyy");
|
|
|
|
|
client.put("end_date", end_date);
|
|
|
|
|
return exportClientAggregateFile(client);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2253,34 +2292,75 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
public JSONObject getClientAggregateFile(JSONObject device, MultipartFile file) throws IOException{
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
|
if (StringUtils.isBlank(file.getOriginalFilename())) {
|
|
|
|
|
throw new BadRequestException("Please Enter Full Name");
|
|
|
|
|
}
|
|
|
|
|
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id"));
|
|
|
|
|
client.put("now", DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
|
|
|
|
|
String clientName = "";
|
|
|
|
|
clientName = client.getString("business_name");
|
|
|
|
|
if (StringUtils.isNotBlank(client.getString("acn"))) {
|
|
|
|
|
clientName += "(" + client.getString("acn") + ")";
|
|
|
|
|
client.put("client_acn", client.getString("acn"));
|
|
|
|
|
}
|
|
|
|
|
client.put("client_name", clientName);
|
|
|
|
|
client.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
|
client.put("client_phone", client.getString("contact_phone"));
|
|
|
|
|
client.put("client_email", client.getString("contact_email"));
|
|
|
|
|
client.put("client_address", (client.getString("address") + "\n" + client.getString("suburb") + ' ' + client.getString("state") + ' ' + client.getString("postcode")));
|
|
|
|
|
JSONObject rate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay");
|
|
|
|
|
if (rate != null) {
|
|
|
|
|
client.put("client_rate", (rate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN).toPlainString() + "%"));
|
|
|
|
|
int cleanDays = rate.getIntValue("clean_days");
|
|
|
|
|
client.put("clean_days", ("T+" + cleanDays));
|
|
|
|
|
client.put("days", cleanDays);
|
|
|
|
|
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") + ")");
|
|
|
|
|
}
|
|
|
|
|
JSONObject bankAccount = clientManager.getBankAccountByClientId(client.getIntValue("client_id"));
|
|
|
|
|
if (bankAccount != null) {
|
|
|
|
|
client.put("bank_name", bankAccount.getString("bank"));
|
|
|
|
|
client.put("bank_country", bankAccount.getString("city"));
|
|
|
|
|
client.put("bank_account_number", bankAccount.getString("account_no"));
|
|
|
|
|
client.put("bank_account_name", bankAccount.getString("account_name"));
|
|
|
|
|
|
|
|
|
|
JSONObject weChatRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Wechat");
|
|
|
|
|
if (weChatRate == null) {
|
|
|
|
|
throw new BadRequestException("The Partner's Rate is not config!");
|
|
|
|
|
}
|
|
|
|
|
client.put("wechat_rate", weChatRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
client.put("clean", "T+" + weChatRate.getString("clean_days"));
|
|
|
|
|
client.put("clean_days", weChatRate.getString("clean_days"));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
JSONObject alipayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Alipay");
|
|
|
|
|
if (alipayRate != null) {
|
|
|
|
|
client.put("alipay_rate", alipayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject bestPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Bestpay");
|
|
|
|
|
if (bestPayRate != null) {
|
|
|
|
|
client.put("bestpay_rate", bestPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject jdRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "jd");
|
|
|
|
|
if (jdRate != null) {
|
|
|
|
|
client.put("jd_rate", jdRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject alipayOnlineRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "AlipayOnline");
|
|
|
|
|
if (alipayOnlineRate != null) {
|
|
|
|
|
client.put("alipay_online_rate", alipayOnlineRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject cbBankPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay");
|
|
|
|
|
if (cbBankPayRate != null) {
|
|
|
|
|
client.put("cbbank_rate", cbBankPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
throw new BadRequestException("Merchant Rate Not Configure");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject bankAccount = getBankAccountByClientId(client.getIntValue("client_id"));
|
|
|
|
|
if (bankAccount == null || bankAccount.size() <= 0) {
|
|
|
|
|
throw new BadRequestException("The Partner's Account is not config!");
|
|
|
|
|
}
|
|
|
|
|
client.put("bank", bankAccount.getString("bank"));
|
|
|
|
|
client.put("bsb_no", bankAccount.getString("bsb_no"));
|
|
|
|
|
client.put("account_no", bankAccount.getString("account_no"));
|
|
|
|
|
client.put("account_name", bankAccount.getString("account_name"));
|
|
|
|
|
String start_date = DateFormatUtils.format(new Date(), "dd/MM/yyyy");
|
|
|
|
|
client.put("start_date", start_date);
|
|
|
|
|
Date endDate = TimeZoneUtils.nextYearByCurrDay();
|
|
|
|
|
String end_date = DateFormatUtils.format(endDate, "dd/MM/yyyy");
|
|
|
|
|
client.put("end_date", end_date);
|
|
|
|
|
client.put("full_name", file.getOriginalFilename());
|
|
|
|
|
BufferedImage img = ImageIO.read(file.getInputStream());
|
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
|
|
ImageIO.write(img, "png", out);
|
|
|
|
@ -2313,7 +2393,7 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id"));
|
|
|
|
|
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
|
|
|
|
|
clientManager.commitAuthFilesToCompliance(client.getString("client_moniker"), account);
|
|
|
|
|
clientManager.commitAuthFilesToCompliance(client.getString("client_moniker"), account,"App");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject exportImgAggregateFile(JSONObject account, JSONObject client) throws IOException{
|
|
|
|
@ -2324,9 +2404,9 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
pdu.setTemplatePdfPath(IMG_AGGREGATE_FILE);
|
|
|
|
|
pdu.setPdfTemplate(client);
|
|
|
|
|
File file = new File(client.getString("client_moniker") + "_agreement.pdf");
|
|
|
|
|
ByteArrayOutputStream bos = pdu.templetPdfBos(file);
|
|
|
|
|
ByteArrayOutputStream bos = pdu.templetPdfBos(file,"STSong-Light","UniGB-UCS2-H");
|
|
|
|
|
stream = new ByteArrayInputStream(bos.toByteArray());
|
|
|
|
|
JSONObject fileInfo = attachmentClient.uploadFile(stream, client.getString("client_moniker") + "_agreement.pdf", false);
|
|
|
|
|
JSONObject fileInfo = attachmentClient.uploadFile(stream, client.getString("client_moniker") + "_" + System.currentTimeMillis() + "_agreement.pdf", false);
|
|
|
|
|
ClientAuthFilesInfo clientAuthFilesInfo = new ClientAuthFilesInfo();
|
|
|
|
|
clientAuthFilesInfo.setFile_agreement_info(fileInfo.getString("url"));
|
|
|
|
|
clientAuthFilesInfo.setFile_apply_info(null);
|
|
|
|
@ -2343,7 +2423,7 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void exportAggregateFile(JSONObject client, HttpServletResponse httpResponse) {
|
|
|
|
|
private void exportCBBankAggregateFile(JSONObject client, HttpServletResponse httpResponse) {
|
|
|
|
|
httpResponse.setContentType("application/pdf");
|
|
|
|
|
httpResponse.setHeader("content-disposition", "attachment;filename=" + client.getString("client_moniker") + "_AGREEMENT_" + new Date() + ".pdf");
|
|
|
|
|
ServletOutputStream sos = null;
|
|
|
|
@ -2366,12 +2446,12 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
try {
|
|
|
|
|
PdfUtils pdu = new PdfUtils();
|
|
|
|
|
pdu.setTemplatePdfPath(CBBANK_AGGREGATE_FILE);
|
|
|
|
|
pdu.setTemplatePdfPath(IMG_AGGREGATE_FILE);
|
|
|
|
|
pdu.setPdfTemplate(client);
|
|
|
|
|
File file = new File(client.getString("client_moniker") + "_agreement.pdf");
|
|
|
|
|
ByteArrayOutputStream bos = pdu.templetPdfBos(file);
|
|
|
|
|
stream = new ByteArrayInputStream(bos.toByteArray());
|
|
|
|
|
JSONObject fileInfo = attachmentClient.uploadFile(stream, client.getString("client_moniker") + "_agreement_source.pdf", false);
|
|
|
|
|
JSONObject fileInfo = attachmentClient.uploadFile(stream, client.getString("client_moniker") + "_" + System.currentTimeMillis() + "_agreement_source.pdf", false);
|
|
|
|
|
result.put("file_value", fileInfo.getString("url"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BadRequestException("获取合同文件失败");
|
|
|
|
@ -2395,4 +2475,8 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
return BIND_ACCOUNT_PHONE_PREFIX+codeKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject getBankAccountByClientId(int client_id) {
|
|
|
|
|
List<JSONObject> list = clientBankAccountMapper.clientBankAccounts(client_id);
|
|
|
|
|
return list.isEmpty() ? new JSONObject() : list.get(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|