|
|
|
@ -42,6 +42,7 @@ import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
|
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
|
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.refund.RefundService;
|
|
|
|
|
import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.DeviceSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMessage;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMsgSender;
|
|
|
|
@ -67,6 +68,7 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
|
|
|
|
|
|
import com.github.qcloudsms.httpclient.HTTPException;
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
|
|
@ -82,12 +84,12 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.thymeleaf.context.Context;
|
|
|
|
|
import org.thymeleaf.spring4.SpringTemplateEngine;
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
@ -107,6 +109,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
@ -201,8 +204,11 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
@Resource
|
|
|
|
|
private SpringTemplateEngine thymeleaf;
|
|
|
|
|
@Resource
|
|
|
|
|
private AttachmentClient attachmentClient;
|
|
|
|
|
@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";
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private SmsSender smsSender;
|
|
|
|
@ -2201,6 +2207,97 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
exportAggregateFile(client, httpResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getSourceAggregateFile(JSONObject device, HttpServletResponse httpResponse) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
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"));
|
|
|
|
|
}
|
|
|
|
|
exportAggregateFile(client, httpResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getClientAggregateFile(JSONObject device, MultipartFile file) throws IOException{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
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"));
|
|
|
|
|
}
|
|
|
|
|
BufferedImage img = ImageIO.read(file.getInputStream());
|
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
|
|
ImageIO.write(img, "png", out);
|
|
|
|
|
client.put("img","data:image/png;base64," + Base64.encodeBase64String(out.toByteArray()));
|
|
|
|
|
return exportImgAggregateFile(client);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject exportImgAggregateFile(JSONObject client) throws IOException{
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
InputStream stream = null;
|
|
|
|
|
try {
|
|
|
|
|
PdfUtils pdu = new PdfUtils();
|
|
|
|
|
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());
|
|
|
|
|
result = attachmentClient.uploadFile(stream, client.getString("client_moniker") + "_agreement.pdf", false);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("合同制作出现问题:", e);
|
|
|
|
|
} finally {
|
|
|
|
|
stream.close();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void exportAggregateFile(JSONObject client, HttpServletResponse httpResponse) {
|
|
|
|
|
httpResponse.setContentType("application/pdf");
|
|
|
|
|
httpResponse.setHeader("content-disposition", "attachment;filename=" + client.getString("client_moniker") + "_AGREEMENT_" + new Date() + ".pdf");
|
|
|
|
|