|
|
|
@ -15,6 +15,7 @@ import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
|
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
|
|
|
|
|
import au.com.royalpay.payment.manage.support.sms.SmsSender;
|
|
|
|
|
import au.com.royalpay.payment.manage.system.core.MailGunService;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
|
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
|
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
@ -24,20 +25,29 @@ import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
|
import au.com.royalpay.payment.tools.locale.LocaleSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.PasswordUtils;
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.PdfUtils;
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
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.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.thymeleaf.context.Context;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
@ -47,6 +57,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
import cn.yixblog.platform.http.HttpRequestGenerator;
|
|
|
|
@ -65,14 +76,21 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
@Resource
|
|
|
|
|
private MailService mailService;
|
|
|
|
|
@Resource
|
|
|
|
|
private AttachmentClient attachmentClient;
|
|
|
|
|
@Resource
|
|
|
|
|
private PermissionPartnerManager permissionPartnerManager;
|
|
|
|
|
@Resource
|
|
|
|
|
private SpringTemplateEngine thymeleaf;
|
|
|
|
|
@Resource
|
|
|
|
|
private SysClientLegalPersonMapper sysClientLegalPersonMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientManager clientManager;
|
|
|
|
|
@Resource
|
|
|
|
|
private SignInAccountService signInAccountService;
|
|
|
|
|
@Resource
|
|
|
|
|
private SimpleClientApplyService simpleClientApplyService;
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientAccountMapper clientAccountMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private SysClientPreMapperMapper sysClientPreMapperMapper;
|
|
|
|
@ -95,6 +113,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
private ClientBDMapper clientBDMapper;
|
|
|
|
|
private ThreadPoolExecutor pool = new ThreadPoolExecutor(1, 10, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
|
|
|
|
|
|
private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/09/06/1567741055646_qeWC7kwqEwsJjRHisJSyAjqnB9nnnh.pdf";
|
|
|
|
|
@Resource
|
|
|
|
|
private SmsSender smsSender;
|
|
|
|
|
@Resource
|
|
|
|
@ -158,6 +177,29 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
return registerClientCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String sendOpenSms(String phoneNumber, String nationCode) {
|
|
|
|
|
String reidsCheckCodeKey = getRegisterClientRedisKey(phoneNumber);
|
|
|
|
|
String value = stringRedisTemplate.boundValueOps(reidsCheckCodeKey).get();
|
|
|
|
|
if (StringUtils.isNotEmpty(value)) {
|
|
|
|
|
throw new BadRequestException("SMS has been sent,Please check your messages or try again in 3 minutes.");
|
|
|
|
|
}
|
|
|
|
|
ArrayList<String> param = new ArrayList<>();
|
|
|
|
|
String registerClientCode = RandomStringUtils.random(6, false, true);
|
|
|
|
|
param.add("RoyalPay");
|
|
|
|
|
param.add(registerClientCode);
|
|
|
|
|
String expireMin = "3";
|
|
|
|
|
param.add(expireMin);
|
|
|
|
|
try {
|
|
|
|
|
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, REGISTER_CLIENT_TEMPLID, param, "RoyalPay", "", "");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
throw new ServerErrorException("Phone number is wrong Please try again");
|
|
|
|
|
}
|
|
|
|
|
stringRedisTemplate.boundValueOps(getRegisterClientRedisKey(phoneNumber)).set(registerClientCode, Long.parseLong(expireMin), TimeUnit.MINUTES);
|
|
|
|
|
return registerClientCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sendVerifyEmail(String address, int client_id, String username) {
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(client_id);
|
|
|
|
@ -301,6 +343,87 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JSONObject getPreApplyInfoForAggree(String username ,String clean_days) {
|
|
|
|
|
|
|
|
|
|
JSONObject apply = sysClientPreMapperMapper.findByUserName(username);
|
|
|
|
|
|
|
|
|
|
String address = apply.getString("address").trim();
|
|
|
|
|
if (address.contains(",")) {
|
|
|
|
|
apply.put("address", address.substring(0, address.lastIndexOf(",")).trim());
|
|
|
|
|
apply.put("address_sub", address.substring(address.lastIndexOf(",") + 1).trim());
|
|
|
|
|
}
|
|
|
|
|
apply.put("acn_type", "ABN: (" + apply.getString("abn") + ")");
|
|
|
|
|
apply.put("company_name_acn", apply.getString("company_name") + " (ABN " + apply.getString("abn") + ")");
|
|
|
|
|
apply.put("clean", "T+" + clean_days.trim());
|
|
|
|
|
apply.put("clean_days", clean_days);
|
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
|
JSONObject test = JSONObject.parseObject(sysConfig.getString("sys_apply_rates"));
|
|
|
|
|
|
|
|
|
|
JSONObject rate = test.getJSONObject("t"+clean_days.trim());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apply.put("wechat_rate",rate.getString("Wechat"));
|
|
|
|
|
apply.put("alipay_rate",rate.getString("Alipay"));
|
|
|
|
|
apply.put("alipay_online_rate",rate.getString("AlipayOnline"));
|
|
|
|
|
apply.put("cbbank_rate",rate.getString("CB_Bankpay"));
|
|
|
|
|
apply.put("bestpay_rate",rate.getString("Bestpay"));
|
|
|
|
|
apply.put("jd_rate",rate.getString("JDpay"));
|
|
|
|
|
|
|
|
|
|
JSONObject bankInfo = getBankInfo(apply.getString("bsb_no"));
|
|
|
|
|
apply.put("bank", bankInfo.getString("bank"));
|
|
|
|
|
apply.put("bsb_no", apply.getString("bsb_no"));
|
|
|
|
|
apply.put("account_no", apply.getString("bank_no"));
|
|
|
|
|
apply.put("account_name", apply.getString("bank_name"));
|
|
|
|
|
|
|
|
|
|
String start_date = DateFormatUtils.format(new Date(), "dd/MM/yyyy");
|
|
|
|
|
apply.put("start_date", start_date);
|
|
|
|
|
Date endDate = TimeZoneUtils.nextYearByCurrDay();
|
|
|
|
|
String end_date = DateFormatUtils.format(endDate, "dd/MM/yyyy");
|
|
|
|
|
apply.put("end_date", end_date);
|
|
|
|
|
|
|
|
|
|
apply.put("legal_person", apply.getString("representative_person"));
|
|
|
|
|
apply.put("legal_job_title", apply.getString("representative_job_title"));
|
|
|
|
|
apply.put("legal_phone", apply.getString("representative_phone"));
|
|
|
|
|
apply.put("legal_email", apply.getString("representative_email"));
|
|
|
|
|
|
|
|
|
|
return apply;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getClientAggregateFile(String username, MultipartFile file ,String clean_days) throws IOException{
|
|
|
|
|
JSONObject apply = getPreApplyInfoForAggree(username ,clean_days);
|
|
|
|
|
apply.put("full_name", file.getOriginalFilename());
|
|
|
|
|
BufferedImage img = ImageIO.read(file.getInputStream());
|
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
|
|
ImageIO.write(img, "png", out);
|
|
|
|
|
apply.put("img","data:image/png;base64," + Base64.encodeBase64String(out.toByteArray()));
|
|
|
|
|
|
|
|
|
|
return exportImgAggregateFile(username, apply);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject exportImgAggregateFile(String username, JSONObject apply) throws IOException{
|
|
|
|
|
InputStream stream = null;
|
|
|
|
|
JSONObject contractInfo = new JSONObject();
|
|
|
|
|
try {
|
|
|
|
|
PdfUtils pdu = new PdfUtils();
|
|
|
|
|
pdu.setTemplatePdfPath(IMG_AGGREGATE_FILE);
|
|
|
|
|
pdu.setPdfTemplate(apply);
|
|
|
|
|
File file = new File(username + "_agreement.pdf");
|
|
|
|
|
ByteArrayOutputStream bos = pdu.templetPdfBos(file,"STSong-Light","UniGB-UCS2-H");
|
|
|
|
|
stream = new ByteArrayInputStream(bos.toByteArray());
|
|
|
|
|
JSONObject fileInfo = attachmentClient.uploadFile(stream, username + "_" + System.currentTimeMillis() + "_agreement.pdf", false);
|
|
|
|
|
|
|
|
|
|
contractInfo.put("contract_url",fileInfo.getString("url"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("合同制作出现问题:", e);
|
|
|
|
|
throw new BadRequestException("合同制作出现问题:" + e.getMessage());
|
|
|
|
|
} finally {
|
|
|
|
|
stream.close();
|
|
|
|
|
}
|
|
|
|
|
return contractInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//todo
|
|
|
|
|
private void applyerToClient(String username) {
|
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
@ -343,8 +466,14 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
sysClient.put("suburb", apply.getString("suburb"));
|
|
|
|
|
sysClient.put("state", apply.getString("state"));
|
|
|
|
|
sysClient.put("postcode", apply.getString("postcode"));
|
|
|
|
|
sysClient.put("royalpayindustry", apply.getString("industry"));
|
|
|
|
|
sysClient.put("royalpayindustry", apply.getString("royalpayindustry"));//修改industry成royalpay
|
|
|
|
|
sysClient.put("alipayindustry", apply.getString("alipayindustry"));
|
|
|
|
|
sysClient.put("industry", apply.getString("industry"));//微信支付行业
|
|
|
|
|
sysClient.put("contact_person", apply.getString("contact_person"));
|
|
|
|
|
sysClient.put("contact_job", apply.getString("contact_job"));
|
|
|
|
|
sysClient.put("logo_url", apply.getString("logo_url"));
|
|
|
|
|
sysClient.put("company_website", apply.getString("company_website"));
|
|
|
|
|
sysClient.put("company_photo", apply.getString("company_photo"));
|
|
|
|
|
sysClient.put("contact_email", apply.getString("contact_email"));
|
|
|
|
|
sysClient.put("contact_phone", "+61"+apply.getString("contact_phone"));
|
|
|
|
|
sysClient.put("company_phone", apply.getString("company_phone"));
|
|
|
|
@ -356,7 +485,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
sysClient.put("approve_time", new Date());
|
|
|
|
|
sysClient.put("creator", 0);
|
|
|
|
|
sysClient.put("business_name", apply.getString("short_name"));
|
|
|
|
|
sysClient.put("industry", 331);
|
|
|
|
|
/*sysClient.put("industry", 331);*/
|
|
|
|
|
sysClient.put("merchant_id", subMerchant.getString("merchant_id"));
|
|
|
|
|
sysClient.put("sub_merchant_id", subMerchant.getString("sub_merchant_id"));
|
|
|
|
|
sysClient.put("common_sub_merchant_id", 1);
|
|
|
|
@ -367,6 +496,18 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
sysClient.put("ali_sub_merchant_id", clientMoniker);
|
|
|
|
|
clientMapper.save(sysClient);
|
|
|
|
|
|
|
|
|
|
JSONObject representativeInfo = new JSONObject();
|
|
|
|
|
representativeInfo.put("client_id", sysClient.getIntValue("client_id"));
|
|
|
|
|
representativeInfo.put("representative_person", apply.getString("representative_person"));
|
|
|
|
|
representativeInfo.put("job_title", apply.getString("representative_job_title"));
|
|
|
|
|
representativeInfo.put("phone", apply.getString("representative_phone"));
|
|
|
|
|
representativeInfo.put("email", apply.getString("representative_email"));
|
|
|
|
|
representativeInfo.put("address", apply.getString("registered_address"));
|
|
|
|
|
representativeInfo.put("suburb", apply.getString("registered_suburb"));
|
|
|
|
|
representativeInfo.put("state", apply.getString("registered_state"));
|
|
|
|
|
representativeInfo.put("postcode", apply.getString("registered_postcode"));
|
|
|
|
|
sysClientLegalPersonMapper.save(representativeInfo);
|
|
|
|
|
|
|
|
|
|
JSONObject clientBd = new JSONObject();
|
|
|
|
|
clientBd.put("client_id", sysClient.getIntValue("client_id"));
|
|
|
|
|
clientBd.put("bd_id", followBd.getString("manager_id"));
|
|
|
|
@ -461,6 +602,9 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
};
|
|
|
|
|
pool.execute(task2);
|
|
|
|
|
|
|
|
|
|
//发送开通短信和邮件
|
|
|
|
|
//simpleClientApplyService.sendOpenSms(apply.getString("contact_phone"),"61");
|
|
|
|
|
//clientManager.sendOpenEmail(sysClient,apply.getString("username"),apply.getString("password"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String generateClientMoniker() {
|
|
|
|
|