汇付支付完成邮件提醒

master
yangkai 6 years ago
parent 495bf22196
commit 28eab9a41a

@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.events.AfterPaymentFinishEvent;
import au.com.royalpay.payment.manage.customers.core.CustomerPaymentInfoService;
import au.com.royalpay.payment.manage.mappers.system.SysCustomerPaymentInfoMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
@ -21,6 +22,8 @@ public class AfterPaymentFinishListener implements ApplicationListener<AfterPaym
private SysCustomerPaymentInfoMapper sysCustomerPaymentInfoMapper;
@Resource
private CustomerPaymentInfoService customerPaymentInfoService;
@Resource
private ClientManager clientManager;
@Override
public void onApplicationEvent(AfterPaymentFinishEvent event) {
@ -48,6 +51,6 @@ public class AfterPaymentFinishListener implements ApplicationListener<AfterPaym
lastOrderInfo.put("bank", extParam.getString("bankId"));
customerPaymentInfoService.save(lastOrderInfo);
}
clientManager.sendHfEmailNotice(order);
}
}

@ -326,4 +326,6 @@ public interface ClientManager {
@Transactional
void switchHfLink(JSONObject manager, String clientMoniker,boolean allow);
void sendHfEmailNotice(JSONObject order);
}

@ -154,13 +154,8 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
@ -1175,6 +1170,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) {
throw new NotFoundException("Client Not Exists");
}
if (channel.equals("hf") && !allow && client.getBoolean("enable_hf_email_notice")) {
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_hf_email_notice", allow));
}
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel.toLowerCase(), allow));
logger.info(manager.getString("display_name") + "(" + manager.getString("manager_id") + ") switched client " + clientMoniker + " channel "
+ channel + " to " + allow);
@ -3754,6 +3752,34 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
@Override
public void sendHfEmailNotice(JSONObject order) {
JSONObject client = clientMapper.findClient(order.getIntValue("client_id"));
JSONObject clientConfig = clientConfigMapper.find(order.getIntValue("client_id"));
if (client == null || clientConfig == null) {
return;
}
if (client.getString("contact_email") == null ||
!clientConfig.getBoolean("enable_hf_email_notice")) {
return;
}
Context ctx = new Context();
ctx.setVariable("img_url", PlatformEnvironment.getEnv().concatUrl("/static/images/royalpay_logo.png"));
ctx.setVariable("name", client.getString("contact_person"));
ctx.setVariable("order_id", order.getString("order_id"));
ctx.setVariable("amount", order.getString("total_amount"));
ctx.setVariable("time", order.getString("create_time"));
final String content = thymeleaf.process( "mail/hf_email_notice", ctx);
new Thread(() -> {
try {
mailService.sendEmail("你刚刚有一笔到账信息", client.getString("contact_email"), "", content);
} catch (Exception ignored) {
logger.error("邮件发送失败", ignored);
}
}).start();
}
@Override
public String getShortLink(String clientMoniker) {
String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/" + clientMoniker + "/jump");

@ -546,4 +546,9 @@ public class PartnerManageController {
clientManager.switchHfLink(manager, clientMoniker, pass.getBooleanValue("allow"));
}
@ManagerMapping(value = "/{clientMoniker}/hf/email_notice", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER})
public void switchHfEmailNotice(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.switchPermission(manager, clientMoniker, "enable_hf_email_notice", pass.getBooleanValue("allow"));
}
}

@ -0,0 +1,31 @@
<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>您有一笔收款信息如下:</p>
<div style="border: 1px #EAEAEA solid;margin-bottom: 5.5%;font-size: 12px;">
<p style="margin-left: 3%;">RoyalPay到账提醒</p>
<ul>
<li style="margin-bottom: 6px;">订单编号:<span style="color: #EE6723;" th:text="${order_id}"></span></li>
<li style="margin-bottom: 6px;">收款金额:<span style="color: #EE6723;" th:text="${amount}"></span></li>
<li style="margin-bottom: 6px;">到账时间:<span style="color: #EE6723;" th:text="${time}"></span></li>
</ul>
</div>
<span>此致</span><br />
<span>RoyalPay</span>
</div>
<div style="height: 3%;background-color: #F2F2F2;margin-top: 6.5%;"></div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@ -1373,7 +1373,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
})
})
};
$scope.init = {jsapi: false, gateway: false, offline: false, refund: false,common_sub_merchant_id:false, channel: {},gateway_alipay_online:false,hf_Link:false};
$scope.init = {jsapi: false, gateway: false, offline: false, refund: false,common_sub_merchant_id:false, channel: {},gateway_alipay_online:false,hf_Link:false,enable_hf_email_notice:false};
$scope.switchCommonSubMerchantId = function () {
if (!$scope.paymentInfo) {
return;
@ -1478,6 +1478,25 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
})
};
$scope.toggleHfEmailNotice = function () {
if (!$scope.paymentInfo) {
return;
}
if (!$scope.init.enable_hf_email_notice) {
$scope.init.enable_hf_email_notice = true;
return;
}
$http.put('/sys/partners/' + $scope.partner.client_moniker + '/hf/email_notice', {allow: $scope.paymentInfo.enable_hf_email_notice}).then(function () {
$scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'Failed to change enable_hf_email_notice permission status',
content: resp.data.message,
type: 'error'
});
})
};
$scope.toggleJsApi = function () {
if (!$scope.paymentInfo) {
return;

@ -331,6 +331,12 @@
&nbsp;&nbsp;<span ng-if="paymentInfo.enable_link">{{paymentInfo.hf_pay_url}}</span>
</div>
</div>
<div class="form-group" ng-if="paymentInfo.enable_hf">
<label class="col-sm-2 control-label">HF Pay Email Notice</label>
<div class="col-sm-10">
<input type="checkbox" ng-model="paymentInfo.enable_hf_email_notice" bs-switch switch-change="toggleHfEmailNotice()">
</div>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save