|
|
@ -57,10 +57,7 @@ import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
|
|
|
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
|
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
|
|
|
|
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
|
|
|
|
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.*;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PasswordUtils;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.QRCodeUtils;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@ -79,6 +76,7 @@ import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
import org.jsoup.Jsoup;
|
|
|
|
import org.jsoup.Jsoup;
|
|
|
|
import org.jsoup.nodes.Document;
|
|
|
|
import org.jsoup.nodes.Document;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@ -87,6 +85,8 @@ import org.springframework.util.Assert;
|
|
|
|
import org.thymeleaf.context.Context;
|
|
|
|
import org.thymeleaf.context.Context;
|
|
|
|
import org.thymeleaf.spring4.SpringTemplateEngine;
|
|
|
|
import org.thymeleaf.spring4.SpringTemplateEngine;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
import java.math.RoundingMode;
|
|
|
@ -107,6 +107,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -201,6 +202,8 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
private SpringTemplateEngine thymeleaf;
|
|
|
|
private SpringTemplateEngine thymeleaf;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
|
|
private final String CBBANK_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/05/1564972204689_uwZvpTBjtLUMcN8c540xcZvux1Rd3O.pdf";
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private SmsSender smsSender;
|
|
|
|
private SmsSender smsSender;
|
|
|
|
private final String BIND_ACCOUNT_EMAIL_PREFIX = "BIND_ACCOUNT_EMAIL";
|
|
|
|
private final String BIND_ACCOUNT_EMAIL_PREFIX = "BIND_ACCOUNT_EMAIL";
|
|
|
@ -1285,12 +1288,18 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
String father = "<div style=\"padding:0 10px\"></div>";
|
|
|
|
String father = "<div style=\"padding:0 10px\"></div>";
|
|
|
|
String html = doc.body().children().wrap(father).html();
|
|
|
|
String html = doc.body().children().wrap(father).html();
|
|
|
|
// logger.debug("wrapped html---->"+html);
|
|
|
|
// logger.debug("wrapped html---->"+html);
|
|
|
|
res.put("content", doc.html());
|
|
|
|
if (res.getIntValue("type")==2) {
|
|
|
|
|
|
|
|
List<JSONObject> buttons = JSONObject.parseArray(res.getString("buttons"),JSONObject.class);
|
|
|
|
|
|
|
|
res.put("buttons", buttons);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
res.put("content", doc.html());
|
|
|
|
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<JSONObject> getLatestNotice(int client_id) {
|
|
|
|
public List<JSONObject> getLatestNotice(int client_id) {
|
|
|
|
|
|
|
|
JSONObject clientConfig = clientConfigService.find(client_id);
|
|
|
|
JSONObject notice = new JSONObject();
|
|
|
|
JSONObject notice = new JSONObject();
|
|
|
|
JSONObject latestNotice = noticeManage.getLatestWindowNotice(client_id);
|
|
|
|
JSONObject latestNotice = noticeManage.getLatestWindowNotice(client_id);
|
|
|
|
if (latestNotice != null) {
|
|
|
|
if (latestNotice != null) {
|
|
|
@ -1302,12 +1311,70 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
unReadParams.put("client_id", client_id);
|
|
|
|
unReadParams.put("client_id", client_id);
|
|
|
|
unReadParams.put("status", 0);
|
|
|
|
unReadParams.put("status", 0);
|
|
|
|
unReadParams.put("is_to_app", 1);
|
|
|
|
unReadParams.put("is_to_app", 1);
|
|
|
|
|
|
|
|
unReadParams.put("type", 1);
|
|
|
|
int counts = noticePartnerMapper.countNoticePartner(unReadParams);
|
|
|
|
int counts = noticePartnerMapper.countNoticePartner(unReadParams);
|
|
|
|
notice.put("unReadCounts", counts);
|
|
|
|
notice.put("unReadCounts", counts);
|
|
|
|
notice.put("type", "notice");
|
|
|
|
notice.put("type", "notice");
|
|
|
|
List<JSONObject> result = new ArrayList<>();
|
|
|
|
List<JSONObject> result = new ArrayList<>();
|
|
|
|
result.add(notice);
|
|
|
|
result.add(notice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject confirmNotice = new JSONObject();
|
|
|
|
|
|
|
|
JSONObject latestConfirmNotice = noticeManage.getLatestWindowConfirmNotice(client_id);
|
|
|
|
|
|
|
|
if (latestConfirmNotice != null) {
|
|
|
|
|
|
|
|
latestConfirmNotice.put("id", latestConfirmNotice.getString("notice_id"));
|
|
|
|
|
|
|
|
latestConfirmNotice.remove("notice_id");
|
|
|
|
|
|
|
|
List<JSONObject> buttons = JSONObject.parseArray(latestConfirmNotice.getString("buttons"),JSONObject.class);
|
|
|
|
|
|
|
|
latestConfirmNotice.put("buttons", buttons);
|
|
|
|
|
|
|
|
String content = latestConfirmNotice.getString("content");
|
|
|
|
|
|
|
|
if (content.indexOf("%excharge_rate%")>0) {
|
|
|
|
|
|
|
|
JSONObject rate = merchantInfoProvider.clientCurrentRate(client_id, new Date(), "CB_BankPay");
|
|
|
|
|
|
|
|
if (rate != null) {
|
|
|
|
|
|
|
|
content = content.replace("%excharge_rate%", (rate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() + "%"));
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
content = content.replace("%excharge_rate%", "(暂未配置)");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(latestConfirmNotice.getString("aggregate_file"))) {
|
|
|
|
|
|
|
|
JSONObject rate = merchantInfoProvider.clientCurrentRate(client_id, new Date(), "CB_BankPay");
|
|
|
|
|
|
|
|
JSONArray rateInfo = new JSONArray();
|
|
|
|
|
|
|
|
if (rate != null) {
|
|
|
|
|
|
|
|
String cleanDays = "T+" + rate.getIntValue("clean_days");
|
|
|
|
|
|
|
|
String rateValue = rate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN).toPlainString() + "%";
|
|
|
|
|
|
|
|
String EndDate = DateFormatUtils.format(rate.getDate("expiry_date"), "yyyy-MM-dd");
|
|
|
|
|
|
|
|
String[] rateName = {"清算时间", "签约费率", "结束时间"};
|
|
|
|
|
|
|
|
String[] rateKey = {cleanDays, rateValue, EndDate};
|
|
|
|
|
|
|
|
for(int i =0;i<rateName.length;i++){
|
|
|
|
|
|
|
|
JSONObject b = new JSONObject();
|
|
|
|
|
|
|
|
b.put("name",rateName[i]);
|
|
|
|
|
|
|
|
b.put("value",rateKey[i]);
|
|
|
|
|
|
|
|
b.put("type", "string");
|
|
|
|
|
|
|
|
rateInfo.add(b);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clientConfig != null) {
|
|
|
|
|
|
|
|
JSONObject customerSurcharge = new JSONObject();
|
|
|
|
|
|
|
|
customerSurcharge.put("name", "客户支付手续费");
|
|
|
|
|
|
|
|
customerSurcharge.put("value", String.valueOf(clientConfig.getBooleanValue("cbbank_surcharge")));
|
|
|
|
|
|
|
|
customerSurcharge.put("type", "button");
|
|
|
|
|
|
|
|
customerSurcharge.put("method", "PUT");
|
|
|
|
|
|
|
|
customerSurcharge.put("key", "customerSurcharge");
|
|
|
|
|
|
|
|
customerSurcharge.put("link", PlatformEnvironment.getEnv().concatUrl("api/v1.0/retail/app/cbbank_pay/toggleCustomerSurcharge"));
|
|
|
|
|
|
|
|
rateInfo.add(customerSurcharge);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
latestConfirmNotice.put("rate_info", rateInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
latestConfirmNotice.put("content", content);
|
|
|
|
|
|
|
|
confirmNotice.put("data", latestConfirmNotice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
unReadParams.put("type", 2);
|
|
|
|
|
|
|
|
counts = noticePartnerMapper.countNoticePartner(unReadParams);
|
|
|
|
|
|
|
|
confirmNotice.put("unReadCounts", counts);
|
|
|
|
|
|
|
|
confirmNotice.put("type", "confirm_notice");
|
|
|
|
|
|
|
|
result.add(confirmNotice);
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject latestAct = appActService.getLatestWindowNotice();
|
|
|
|
JSONObject latestAct = appActService.getLatestWindowNotice();
|
|
|
|
if (latestAct != null) {
|
|
|
|
if (latestAct != null) {
|
|
|
|
latestAct.put("id", latestAct.getString("act_id"));
|
|
|
|
latestAct.put("id", latestAct.getString("act_id"));
|
|
|
@ -2044,6 +2111,114 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
clientConfigService.update(update);
|
|
|
|
clientConfigService.update(update);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public JSONObject toggleCBBankChannel(JSONObject device,String noticeId) {
|
|
|
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
|
|
|
|
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
|
|
|
|
|
|
|
|
if (PartnerRole.getRole(account.getIntValue("role")) != PartnerRole.ADMIN) {
|
|
|
|
|
|
|
|
throw new BadRequestException("You have no permission");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id"));
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
clientManager.switchChannelPermission(account, client.getString("client_moniker"), "cb_bankpay", true);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
result.put("status", "Fail");
|
|
|
|
|
|
|
|
result.put("message", "开通大额支付渠道失败,失败原因:" + e.getMessage());
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
updateReadStatus(device, noticeId);
|
|
|
|
|
|
|
|
result.put("status", "Success");
|
|
|
|
|
|
|
|
result.put("message", "开通大额支付渠道成功!");
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public JSONObject toggleCBBankCustomerSurcharge(JSONObject device,boolean customerSurcharge) {
|
|
|
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
|
|
|
|
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
|
|
|
|
|
|
|
|
if (PartnerRole.getRole(account.getIntValue("role")) != PartnerRole.ADMIN) {
|
|
|
|
|
|
|
|
throw new BadRequestException("You have no permission");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
clientManager.changeCBBankPaySurcharge(account, customerSurcharge);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
JSONObject clientConfig = clientConfigService.find(device.getIntValue("client_id"));
|
|
|
|
|
|
|
|
result.put("status", "Fail");
|
|
|
|
|
|
|
|
if (customerSurcharge) {
|
|
|
|
|
|
|
|
result.put("message", "开启客户支付手续费失败,失败原因:" + e.getMessage());
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
result.put("message", "关闭客户支付手续费失败,失败原因:" + e.getMessage());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.put("customerSurcharge", String.valueOf(clientConfig.getBooleanValue("cbbank_surcharge")));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.put("status", "Success");
|
|
|
|
|
|
|
|
if (customerSurcharge) {
|
|
|
|
|
|
|
|
result.put("message", "开启客户支付手续费成功!");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
result.put("message", "关闭客户支付手续费成功!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.put("customerSurcharge", String.valueOf(customerSurcharge));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void getCBBankAggregateFile(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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
ServletOutputStream sos = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
sos = httpResponse.getOutputStream();
|
|
|
|
|
|
|
|
PdfUtils pdu = new PdfUtils();
|
|
|
|
|
|
|
|
pdu.setTemplatePdfPath(CBBANK_AGGREGATE_FILE);
|
|
|
|
|
|
|
|
pdu.setPdfTemplate(client);
|
|
|
|
|
|
|
|
File file = new File(client.getString("client_moniker") + "_agreement.pdf");
|
|
|
|
|
|
|
|
ByteArrayOutputStream bos = pdu.templetPdfBos(file);
|
|
|
|
|
|
|
|
sos.write(bos.toByteArray());
|
|
|
|
|
|
|
|
sos.close();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void deleteAccountEmailKey(String codeKey){
|
|
|
|
private void deleteAccountEmailKey(String codeKey){
|
|
|
|
stringRedisTemplate.delete(getUpdateAccountEmailKey(codeKey));
|
|
|
|
stringRedisTemplate.delete(getUpdateAccountEmailKey(codeKey));
|
|
|
|
}
|
|
|
|
}
|
|
|
|