|
|
|
@ -3,28 +3,55 @@ package au.com.royalpay.payment.manage.kyc.core.impls;
|
|
|
|
|
import au.com.royalpay.payment.manage.kyc.bean.KycPartnersQuery;
|
|
|
|
|
import au.com.royalpay.payment.manage.kyc.core.KycManage;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientComplianceCompanyMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.notice.core.MailService;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage;
|
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
|
|
|
|
|
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.thymeleaf.context.Context;
|
|
|
|
|
import org.thymeleaf.spring5.SpringTemplateEngine;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class KycManageImpl implements KycManage {
|
|
|
|
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
@Resource
|
|
|
|
|
private MailService mailService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientMapper clientMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientBDMapper clientBDMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private FinancialBDConfigMapper financialBDConfigMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientComplianceCompanyMapper clientComplianceCompanyMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private SpringTemplateEngine thymeleaf;
|
|
|
|
|
@Resource
|
|
|
|
|
private RoyalThreadPoolExecutor royalThreadPoolExecutor;
|
|
|
|
|
@Resource
|
|
|
|
|
private MpWechatApiProvider mpWechatApiProvider;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject listProgressClients(JSONObject manager, KycPartnersQuery query) {
|
|
|
|
@ -49,6 +76,68 @@ public class KycManageImpl implements KycManage {
|
|
|
|
|
return clientComplianceCompanyMapper.listNeedHelpClients(params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sendNotify(JSONObject complianceInfo) {
|
|
|
|
|
JSONObject client = clientMapper.findClient(complianceInfo.getIntValue("client_id"));
|
|
|
|
|
List<JSONObject> bds = clientBDMapper.listClientBDInfoAvailable(complianceInfo.getIntValue("client_id"), new Date());
|
|
|
|
|
List<String> emails = new ArrayList<>();
|
|
|
|
|
List<String> openIds = new ArrayList<>();
|
|
|
|
|
String bdNames = "";
|
|
|
|
|
for (JSONObject bd : bds) {
|
|
|
|
|
String email = bd.getString("email");
|
|
|
|
|
if (StringUtils.isNotEmpty(email)) {
|
|
|
|
|
emails.add(email);
|
|
|
|
|
bdNames += bd.getString("display_name");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotEmpty(bd.getString("wechat_openid"))) {
|
|
|
|
|
openIds.add(bd.getString("wechat_openid"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Context ctx = new Context();
|
|
|
|
|
ctx.setVariable("img_url", PlatformEnvironment.getEnv().concatUrl("/static/images/royalpay_logo.png"));
|
|
|
|
|
ctx.setVariable("name", bdNames);
|
|
|
|
|
ctx.setVariable("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
ctx.setVariable("contact_person", client.getString("contact_person"));
|
|
|
|
|
ctx.setVariable("contact_phone", client.getString("contact_phone"));
|
|
|
|
|
ctx.setVariable("contact_email", client.getString("contact_email"));
|
|
|
|
|
ctx.setVariable("submit_time", DateFormatUtils.format(complianceInfo.getDate("submit_time"),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
final String content = thymeleaf.process("mail/kyc_email_notice", ctx);
|
|
|
|
|
if (emails.size() > 0) {
|
|
|
|
|
royalThreadPoolExecutor.execute(() -> {
|
|
|
|
|
try {
|
|
|
|
|
mailService.sendEmail("[RoyalPay]商户需要您协助补充KYC材料,请尽快查看", StringUtils.join(emails, ","), "", content);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("邮件发送失败", e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (openIds.size() > 0) {
|
|
|
|
|
for (String openId : openIds) {
|
|
|
|
|
try {
|
|
|
|
|
MpWechatApi mpWechatApi = mpWechatApiProvider.getApiFromOpenId(openId);
|
|
|
|
|
if (mpWechatApi == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String templateId = mpWechatApi.getTemplateId("payment-success-cashier");
|
|
|
|
|
if (templateId == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TemplateMessage message = new TemplateMessage(openId, templateId, null);
|
|
|
|
|
message.put("first", "有新商户需要您协助补充KYC材料,请尽快查看", "#ff0000");
|
|
|
|
|
message.put("keyword1", "KYC认证商户申请协助", "#0000ff");
|
|
|
|
|
message.put("keyword2", client.getString("company_name"), "#000000");
|
|
|
|
|
message.put("keyword3", DateFormatUtils.format(complianceInfo.getDate("submit_time"),"yyyy-MM-dd HH:mm:ss"), "#000000");
|
|
|
|
|
message.put("keyword4", "联系人:" + client.getString("contact_person") + " 电话:" + client.getString("contact_phone"), "#000000");
|
|
|
|
|
message.put("remark", "您可以在后台帮助商户提交材料或填写无法提供材料文件的原因", "#ff0000");
|
|
|
|
|
mpWechatApi.sendTemplateMessage(message);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("cashier message failed", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkManagerPermission(JSONObject manager, JSONObject params, KycPartnersQuery query) {
|
|
|
|
|
if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) {
|
|
|
|
|
JSONObject bdConfig = financialBDConfigMapper.getBdConfig(manager.getString("manager_id"));
|
|
|
|
|