TASK:优化订阅收件人列表创建方式
This commit is contained in:
@@ -17,17 +17,38 @@ import com.tencentcloudapi.ses.v20201002.models.SendEmailRequest;
|
||||
import com.tencentcloudapi.ses.v20201002.models.SendEmailResponse;
|
||||
import com.tencentcloudapi.ses.v20201002.models.Template;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 邮件发送类
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SendEmailUtil {
|
||||
@Value("${merchant.email:}")
|
||||
private String merchantEmailInstance;
|
||||
@Value("${developer.email: xupei@code-create.com.hk}")
|
||||
private String developerEmailInstance;
|
||||
|
||||
private static String merchantEmail;
|
||||
private static String developerEmail;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
merchantEmail = merchantEmailInstance;
|
||||
developerEmail = developerEmailInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 秘钥id
|
||||
*/
|
||||
@@ -765,9 +786,7 @@ public class SendEmailUtil {
|
||||
|
||||
public static boolean subscriptionEmailReminder(String type, SubscriptionEmailParamsDTO subscriptionEmailParamsDTO, String language, String receiverAddress) {
|
||||
try {
|
||||
String merchantEmail = "kimwong@code-create.com.hk";
|
||||
String developer = "xupei3360@163.com";
|
||||
String[] receiverEmail = {/*merchantEmail,*/ developer};
|
||||
String[] receiverEmail = buildMerchantReceiverEmail();
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
@@ -966,9 +985,7 @@ public class SendEmailUtil {
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
String merchantEmail = "kimwong@code-create.com.hk";
|
||||
String developerEmail = "xupei@code-create.com.hk";
|
||||
req.setDestination(new String[]{/*merchantEmail,*/ developerEmail});
|
||||
req.setDestination(buildMerchantReceiverEmail());
|
||||
Template template = new Template();
|
||||
req.setSubject("New Credit Purchase Order");
|
||||
template.setTemplateID(CREDITS_PURCHASE_MERCHANT);
|
||||
@@ -1076,4 +1093,25 @@ public class SendEmailUtil {
|
||||
|
||||
}
|
||||
|
||||
public static String[] buildMerchantReceiverEmail() {
|
||||
List<String> emails = new ArrayList<>();
|
||||
if (!StringUtils.isEmpty(merchantEmail)) {
|
||||
for (String e : merchantEmail.split(",")) {
|
||||
String trimmed = e.trim();
|
||||
if (!trimmed.isEmpty()) {
|
||||
emails.add(trimmed);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(developerEmail)) {
|
||||
for (String e : developerEmail.split(",")) {
|
||||
String trimmed = e.trim();
|
||||
if (!trimmed.isEmpty()) {
|
||||
emails.add(trimmed);
|
||||
}
|
||||
}
|
||||
}
|
||||
return emails.toArray(new String[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import jakarta.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -80,9 +79,7 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
|
||||
affiliate.setPromotionMethod(promotionMethod);
|
||||
baseMapper.insert(affiliate);
|
||||
// 邮件通知审批者
|
||||
String merchantEmail = "kimwong@code-create.com.hk";
|
||||
String developer = "xupei3360@163.com";
|
||||
String[] receiverEmail = {/*merchantEmail,*/ developer};
|
||||
String[] receiverEmail = buildMerchantReceiverEmail();
|
||||
SendEmailUtil.affiliateEmailReminder(receiverEmail, new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
|
||||
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
|
||||
}else {
|
||||
@@ -440,9 +437,7 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
|
||||
affiliateEmailParamsDTO.setUnpaidEarnings(String.valueOf(unpaidCommission));
|
||||
affiliateEmailParamsDTO.setPaidEarnings(String.valueOf(paidCommission));
|
||||
|
||||
String merchantEmail = "kimwong@code-create.com.hk";
|
||||
String developer = "xupei3360@163.com";
|
||||
String[] receiverEmail = {/*merchantEmail,*/ developer};
|
||||
String[] receiverEmail = buildMerchantReceiverEmail();
|
||||
// 邮件通知
|
||||
SendEmailUtil.affiliateEmailReminder(receiverEmail, affiliateEmailParamsDTO, "summary");
|
||||
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), affiliateEmailParamsDTO, "summary");
|
||||
@@ -607,4 +602,8 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
|
||||
coupon.setUnpaidCommission(unpaidCommission);
|
||||
}
|
||||
|
||||
private String[] buildMerchantReceiverEmail() {
|
||||
return SendEmailUtil.buildMerchantReceiverEmail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.ai.da.common.response.ResultEnum;
|
||||
import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.MailUtil;
|
||||
import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.common.utils.SendEmailUtil;
|
||||
import com.ai.da.mapper.primary.AccountMapper;
|
||||
import com.ai.da.mapper.primary.EmailLogMapper;
|
||||
import com.ai.da.mapper.primary.EmailTemplateMapper;
|
||||
@@ -585,9 +586,7 @@ public class EmailServiceImpl implements EmailService {
|
||||
|
||||
public boolean subscriptionEmailReminder(String type, SubscriptionEmailParamsDTO subscriptionEmailParamsDTO, String language, String receiverAddress) {
|
||||
try {
|
||||
String merchantEmail = "kimwong@code-create.com.hk";
|
||||
String developer = "xupei3360@163.com";
|
||||
List<String> merchantReceiver = Arrays.asList(/*merchantEmail,*/ developer);
|
||||
List<String> merchantReceiver = buildMerchantReceiverList();
|
||||
|
||||
String merchantSubject = null;
|
||||
String merchantTemplate = null;
|
||||
@@ -723,15 +722,13 @@ public class EmailServiceImpl implements EmailService {
|
||||
|
||||
private final static String CREDITS_PURCHASE_MERCHANT = "133275_AiDA 积分购买通知-merchant.html";
|
||||
public void creditsPurchaseReminder(String username, String quantity, String amount) {
|
||||
String merchantEmail = "kimwong@code-create.com.hk";
|
||||
String developerEmail = "xupei@code-create.com.hk";
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 设置试用订单相关数据
|
||||
jsonObject.put("username", username);
|
||||
jsonObject.put("quantity", quantity);
|
||||
jsonObject.put("totalFee", amount);
|
||||
|
||||
sendEmail(Arrays.asList(/*merchantEmail,*/ developerEmail), jsonObject, CREDITS_PURCHASE_MERCHANT, "New Credit Purchase Order", null, null);
|
||||
sendEmail(buildMerchantReceiverList(), jsonObject, CREDITS_PURCHASE_MERCHANT, "New Credit Purchase Order", null, null);
|
||||
}
|
||||
|
||||
private final static String COMMON_EXCEPTION_REMINDER = "135279_common-exception-reminder.html";
|
||||
@@ -742,6 +739,10 @@ public class EmailServiceImpl implements EmailService {
|
||||
|
||||
sendEmail(destination, param, COMMON_EXCEPTION_REMINDER, "AiDA发生异常,请及时处理", null, null);
|
||||
}
|
||||
|
||||
private List<String> buildMerchantReceiverList() {
|
||||
return Arrays.asList(SendEmailUtil.buildMerchantReceiverEmail());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ public class StripeSubscriptionServiceImpl implements StripeSubscriptionService
|
||||
.orderByDesc("id")
|
||||
.last("LIMIT 1");
|
||||
if (!type.contains("fail")) {
|
||||
last.in("trade_state", "paid", "COMPLETED");
|
||||
last.in("trade_state", "paid", "COMPLETED", "Refunded");
|
||||
}
|
||||
List<PaymentInfo> infos = paymentInfoMapper.selectList(last);
|
||||
return infos.isEmpty() ? null : infos.getFirst();
|
||||
|
||||
@@ -67,7 +67,7 @@ public class SubscriptionDeletedHandler implements StripeEventHandler {
|
||||
|
||||
// 发送取消订阅通知邮件
|
||||
if (subscriptionInfo.getCancelNotified() == 0) {
|
||||
boolean sent = stripeSubscriptionService.sendSubscriptionEmail(null, "cancel", subscriptionInfo.getOrderNo(), null);
|
||||
boolean sent = stripeSubscriptionService.sendSubscriptionEmail(null, "cancel", subscriptionInfo.getOrderNo(), subscriptionInfo);
|
||||
if (sent) {
|
||||
subscriptionInfo.setCancelNotified((byte) 1);
|
||||
|
||||
|
||||
@@ -181,4 +181,10 @@ file.upload.max.size.video=104857600
|
||||
# 上传任务过期时间(小时)
|
||||
file.upload.task.expiry.hours=24
|
||||
|
||||
global.award.link=https://aida-global-design-awards.com.hk/contestants?id=
|
||||
global.award.link=https://aida-global-design-awards.com.hk/contestants?id=
|
||||
|
||||
# merchant email receivers (comma-separated, multiple supported)
|
||||
# dev/local: developer.email 不配置,使用默认值 xupei3360@163.com
|
||||
# prod: 两个都配置
|
||||
merchant.email=
|
||||
developer.email=xupei@code-create.com.hk,yizhang@aidlab.hk
|
||||
@@ -179,4 +179,9 @@ file.upload.max.size.video=104857600
|
||||
# 上传任务过期时间(小时)
|
||||
file.upload.task.expiry.hours=24
|
||||
|
||||
global.award.link=https://aida-global-design-awards.com.hk/contestants?id=
|
||||
global.award.link=https://aida-global-design-awards.com.hk/contestants?id=
|
||||
|
||||
# merchant email receivers (comma-separated, multiple supported)
|
||||
# prod: includes merchant email
|
||||
merchant.email=kimwong@code-create.com.hk
|
||||
developer.email=xupei3360@163.com
|
||||
@@ -51,47 +51,41 @@
|
||||
a.user_email email,
|
||||
p.payment_type platform,
|
||||
p.payer_total,
|
||||
p.type,
|
||||
CASE
|
||||
WHEN o.title LIKE '%Subscription' THEN 'Subscription'
|
||||
ELSE 'Credits'
|
||||
END AS type,
|
||||
p.payment_method,
|
||||
p.last4,
|
||||
p.country,
|
||||
p.city,
|
||||
p.create_time,
|
||||
CASE
|
||||
|
||||
WHEN p.trade_state IN ( 'paid', 'COMPLETED', 'complete', 'liquidated' ) THEN
|
||||
'Success'
|
||||
WHEN p.trade_state IN ( 'failed', 'expired', 'VOIDED', 'void', 'uncollectible' ) THEN
|
||||
'Fail'
|
||||
WHEN p.trade_state IN ( 'Refunded' ) THEN
|
||||
'Refunded'
|
||||
WHEN p.trade_state IN ('paid', 'COMPLETED', 'complete', 'liquidated') THEN 'Success'
|
||||
WHEN p.trade_state IN ('failed', 'expired', 'VOIDED', 'void', 'uncollectible') THEN 'Fail'
|
||||
WHEN p.trade_state IN ('Refunded') THEN 'Refunded'
|
||||
ELSE 'Pending'
|
||||
END AS status
|
||||
FROM
|
||||
t_payment_info p
|
||||
LEFT JOIN
|
||||
t_order_info o ON p.order_no = o.order_no
|
||||
LEFT JOIN
|
||||
t_account a ON a.id = o.account_id
|
||||
WHERE
|
||||
1 = 1
|
||||
FROM t_payment_info p
|
||||
LEFT JOIN t_order_info o ON p.order_no = o.order_no
|
||||
LEFT JOIN t_account a ON a.id = o.account_id
|
||||
WHERE 1 = 1
|
||||
<if test="paymentType != null and paymentType != ''">
|
||||
AND p.payment_type = #{paymentType}
|
||||
</if>
|
||||
<if test="payerTotal != null and payerTotal != ''">
|
||||
AND p.payer_total = #{payerTotal}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
AND p.type = #{type}
|
||||
</if>
|
||||
<!-- 修复1:删除 type 过滤条件,因为 type 是计算字段 -->
|
||||
<if test="status != null and status != ''">
|
||||
AND
|
||||
CASE
|
||||
WHEN p.trade_state IN ('paid', 'COMPLETED', 'complete', 'liquidated') THEN 'Success'
|
||||
WHEN p.trade_state IN ('failed', 'expired', 'VOIDED', 'void', 'uncollectible') THEN 'Fail'
|
||||
WHEN p.trade_state IN ('Refunded') THEN 'Refunded'
|
||||
ELSE 'Pending'
|
||||
END = #{status}
|
||||
AND (
|
||||
(p.trade_state IN ('paid', 'COMPLETED', 'complete', 'liquidated') AND #{status} = 'Success')
|
||||
OR (p.trade_state IN ('failed', 'expired', 'VOIDED', 'void', 'uncollectible') AND #{status} = 'Fail')
|
||||
OR (p.trade_state IN ('Refunded') AND #{status} = 'Refunded')
|
||||
OR (p.trade_state NOT IN ('paid', 'COMPLETED', 'complete', 'liquidated',
|
||||
'failed', 'expired', 'VOIDED', 'void', 'uncollectible', 'Refunded')
|
||||
AND #{status} = 'Pending')
|
||||
)
|
||||
</if>
|
||||
<if test="country != null and country != ''">
|
||||
AND p.country = #{country}
|
||||
@@ -106,9 +100,8 @@
|
||||
AND a.user_name = #{payer}
|
||||
</if>
|
||||
AND p.transaction_id NOT LIKE 'cs_test%'
|
||||
ORDER BY
|
||||
p.id ${order}
|
||||
LIMIT ${limit} OFFSET ${offset}
|
||||
ORDER BY p.id ${order} <!-- 建议使用白名单校验 -->
|
||||
LIMIT #{limit} OFFSET #{offset} <!-- 修复:改为 #{} -->
|
||||
</select>
|
||||
|
||||
<select id="queryPaymentInfoCount" resultType="java.lang.Long">
|
||||
|
||||
Reference in New Issue
Block a user