feat(payment): 支付宝转账集成邮件通知
parent
e09584800a
commit
e44f6b8a0f
|
@ -0,0 +1,6 @@
|
|||
# 发件人(必须正确,否则发送失败)
|
||||
from = 2119157836@qq.com
|
||||
# 密码(注意,某些邮箱需要为SMTP服务单独设置授权码)
|
||||
pass = wetaiadftmidejab
|
||||
# 使用SSL安全连接
|
||||
sslEnable = true
|
|
@ -1,18 +1,6 @@
|
|||
package com.mcwl.memberCenter;
|
||||
|
||||
import com.mcwl.McWlApplication;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.memberCenter.consumer.EmptyPointsRemindConsumer;
|
||||
import com.mcwl.memberCenter.service.MemberLevelService;
|
||||
import com.mcwl.memberCenter.service.MemberService;
|
||||
import com.mcwl.memberCenter.task.UserMemberTask;
|
||||
import com.mcwl.web.controller.memberCenter.MemberController;
|
||||
import com.mcwl.web.controller.memberCenter.MemberLevelController;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
|
||||
public class MemberCenterTest {
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.mcwl.pay.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.extra.mail.MailUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
|
@ -45,6 +47,7 @@ import org.springframework.stereotype.Component;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -205,8 +208,8 @@ public class AliPayServiceImpl implements AliPayService {
|
|||
/**
|
||||
* 支付宝转账方法
|
||||
*
|
||||
* @param outBizNo 外部业务单号
|
||||
* @param amount 转账金额
|
||||
* @param outBizNo 外部业务单号
|
||||
* @param amount 转账金额
|
||||
* @return 返回支付宝转账响应的内容
|
||||
*/
|
||||
@Override
|
||||
|
@ -240,36 +243,32 @@ public class AliPayServiceImpl implements AliPayService {
|
|||
// 设置转账业务的标题
|
||||
model.setOrderTitle("提现");
|
||||
|
||||
// 设置收款方信息
|
||||
|
||||
// 查询用户支付宝账户
|
||||
SysUserPayAccount sysUserPayAccount = sysUserPayAccountService
|
||||
.lambdaQuery()
|
||||
.eq(SysUserPayAccount::getUserId, userId)
|
||||
.eq(SysUserPayAccount::getType, 0)
|
||||
.one();
|
||||
if ( Objects.isNull(sysUserPayAccount)) {
|
||||
if (Objects.isNull(sysUserPayAccount)) {
|
||||
return AjaxResult.error("请先绑定支付宝账号");
|
||||
}
|
||||
|
||||
// 收款方信息
|
||||
Participant payeeInfo = new Participant();
|
||||
payeeInfo.setIdentity(sysUserPayAccount.getOpenId());
|
||||
payeeInfo.setIdentityType("ALIPAY_USER_ID");
|
||||
model.setPayeeInfo(payeeInfo);
|
||||
|
||||
// 设置业务备注
|
||||
// model.setRemark("201905代发");
|
||||
|
||||
// 设置转账业务请求的扩展参数
|
||||
// model.setBusinessParams("{\"payer_show_name_use_alias\":\"true\"}");
|
||||
|
||||
request.setBizModel(model);
|
||||
AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request);
|
||||
System.out.println(response.getBody());
|
||||
|
||||
if (response.getCode().equals("40004")) {
|
||||
|
||||
// TODO 余额不足,发送邮件提现
|
||||
if (response.getSubCode().equals("PAYER_BALANCE_NOT_ENOUGH")) {
|
||||
// 账户余额不足,发送邮件通知
|
||||
ArrayList<String> tos = CollUtil.newArrayList("2119157836@qq.com");
|
||||
|
||||
String content = String.format("账户余额不足:用户%s提现%s", sysUser.getUserName(), amount);
|
||||
MailUtil.send(tos, "上海辰风互娱", content, false);
|
||||
return AjaxResult.error("系统繁忙,请稍后重试");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue