add 商户申请BD帮助后,邮件推送、微信推送

master
luoyang 5 years ago
parent 6daa0cf640
commit 97effc720b

@ -13,4 +13,6 @@ public interface KycManage {
List<JSONObject> listNeedHelpClients(JSONObject manager, KycPartnersQuery query); List<JSONObject> listNeedHelpClients(JSONObject manager, KycPartnersQuery query);
void sendNotify(JSONObject complianceInfo);
} }

@ -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.bean.KycPartnersQuery;
import au.com.royalpay.payment.manage.kyc.core.KycManage; 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.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.ClientComplianceCompanyMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper; 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.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; 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.springframework.stereotype.Service;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
public class KycManageImpl implements KycManage { public class KycManageImpl implements KycManage {
private Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private MailService mailService;
@Resource @Resource
private ClientMapper clientMapper; private ClientMapper clientMapper;
@Resource @Resource
private ClientBDMapper clientBDMapper;
@Resource
private FinancialBDConfigMapper financialBDConfigMapper; private FinancialBDConfigMapper financialBDConfigMapper;
@Resource @Resource
private ClientComplianceCompanyMapper clientComplianceCompanyMapper; private ClientComplianceCompanyMapper clientComplianceCompanyMapper;
@Resource
private SpringTemplateEngine thymeleaf;
@Resource
private RoyalThreadPoolExecutor royalThreadPoolExecutor;
@Resource
private MpWechatApiProvider mpWechatApiProvider;
@Override @Override
public JSONObject listProgressClients(JSONObject manager, KycPartnersQuery query) { public JSONObject listProgressClients(JSONObject manager, KycPartnersQuery query) {
@ -49,6 +76,68 @@ public class KycManageImpl implements KycManage {
return clientComplianceCompanyMapper.listNeedHelpClients(params); 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) { private void checkManagerPermission(JSONObject manager, JSONObject params, KycPartnersQuery query) {
if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) { if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) {
JSONObject bdConfig = financialBDConfigMapper.getBdConfig(manager.getString("manager_id")); JSONObject bdConfig = financialBDConfigMapper.getBdConfig(manager.getString("manager_id"));

@ -19,13 +19,7 @@
c.source as client_source,c.refuse_remark,a.* FROM client_authfile_compliance a INNER JOIN sys_clients c on c.client_id = a.client_id c.source as client_source,c.refuse_remark,a.* FROM client_authfile_compliance a INNER JOIN sys_clients c on c.client_id = a.client_id
<where> <where>
and a.type = 2 and a.type = 2
and a.need_help = 1 and a.status = 9
<if test="client_moniker!=null">
and c.client_moniker = #{client_moniker}
</if>
<if test="status!=null">
and a.status = #{status}
</if>
<if test="bd_user!=null"> <if test="bd_user!=null">
INNER JOIN sys_client_bd d ON a.client_id = d.client_id AND d.bd_id = #{bd_user} and INNER JOIN sys_client_bd d ON a.client_id = d.client_id AND d.bd_id = #{bd_user} and
date(d.start_date)&lt;= date(now()) and (d.end_date is null or date(d.end_date)&gt;= date(now())) and date(d.start_date)&lt;= date(now()) and (d.end_date is null or date(d.end_date)&gt;= date(now())) and
@ -47,6 +41,8 @@
c.source as client_source,a.* FROM client_authfile_compliance a INNER JOIN sys_clients c on c.client_id = a.client_id c.source as client_source,a.* FROM client_authfile_compliance a INNER JOIN sys_clients c on c.client_id = a.client_id
<where> <where>
and a.type = 2 and a.type = 2
and a.status != 9
and a.status != 2
<if test="client_moniker!=null"> <if test="client_moniker!=null">
and c.client_moniker = #{client_moniker} and c.client_moniker = #{client_moniker}
</if> </if>

@ -0,0 +1,28 @@
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>
<body>
<div style="width: 91%;border: 1px #F2F2F2 solid;margin: 0 auto; ">
<div style="height: 3%;background-color: #F2F2F2;"></div>
<div style="text-align: center;margin-top: 2.5%;">
<img th:src="${img_url}"/>
</div>
<div style="width: 80.3%;margin: 0 auto;">
<p>您好,<span th:text="${name}"></span></p>
<p>商户:<span th:text="${client_moniker}"></span>需要您协助上传KYC材料。(申请时间:<span th:text="${submit_time}"></span>)</p>
<p>请尽快联系商户,您可以帮助商户提交材料或填写无法提供材料文件的原因。</p>
<p>商户联系人:<span th:text="${contact_person}"></span></p>
<p>联系电话:<span th:text="${contact_phone}"></span></p>
<p>邮箱:<span th:text="${contact_email}"></span></p>
<span>此致</span><br />
<span>RoyalPay</span>
</div>
<div style="height: 3%;background-color: #F2F2F2;margin-top: 6.5%;"></div>
</div>
</body>
</html>
Loading…
Cancel
Save