Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -67,27 +67,14 @@ public class GenerateConsumer {
|
||||
} catch (IOException ex) {
|
||||
log.error("手动确认,不返回队列重新消费");
|
||||
}
|
||||
// 2.2 将该消息从取消列表中删除
|
||||
// redisUtil.removeFromSet(cancelSetKey, uniqueId);
|
||||
} else {
|
||||
// GenerateCollectionVO generateCollectionVO = generateService.generateThroughImageText(generateThroughImageTextDTO);
|
||||
try {
|
||||
generateService.generateThroughImageText(generateThroughImageTextDTO);
|
||||
}catch (Exception e){
|
||||
log.error("error message : {}", e.getMessage());
|
||||
}
|
||||
generateService.generateThroughImageText(generateThroughImageTextDTO);
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
||||
/*if (!Objects.isNull(generateCollectionVO)) {
|
||||
HashMap<String, String> generateResult = new HashMap<>();
|
||||
generateResult.put(uniqueId, JSONObject.toJSONString(generateCollectionVO));
|
||||
// 将结果存在redis中 ,为空时不要存
|
||||
redisUtil.addToMap(resultMapKey, generateResult);
|
||||
}*/
|
||||
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
log.error(e.getMsg());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
// channel.basicNack() 为不确认deliveryTag对应的消息,第二个参数是否应用于多消息,第三个参数是否requeue
|
||||
try {
|
||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
||||
@@ -102,7 +89,7 @@ public class GenerateConsumer {
|
||||
}
|
||||
// 将入参和错误信息存入数据库
|
||||
String exceptionMessage = JSONObject.toJSONString(generateThroughImageTextDTO) +
|
||||
" Exception message : " + e.getMsg();
|
||||
" Exception message : " + e.getMessage();
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(String.valueOf(uniqueId), exceptionMessage);
|
||||
// 存redis
|
||||
|
||||
@@ -23,6 +23,10 @@ public class CommonConstant {
|
||||
|
||||
public static final String GENERATE_SLOGAN = "/api/slogan";
|
||||
|
||||
public static final String GENERATE_CANCEL = "/api/generate_cancel/";
|
||||
|
||||
public static final String GENERATE_LOGO_SINGLE_CANCEL = "/api/generate_single_logo_cancel/";
|
||||
|
||||
public static final String PYTHON_PORT_9996 = "9996";
|
||||
|
||||
public static final String PYTHON_PORT_9997 = "9997";
|
||||
|
||||
@@ -7,22 +7,29 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum CreditsEventsEnum {
|
||||
|
||||
// PRICE("price","6"),
|
||||
PRICE("price","0.1"),
|
||||
PRICE("price","6"),
|
||||
// PRICE("price","0.1"),
|
||||
|
||||
// BUY_CREDITS("Buy Credits","600"),
|
||||
BUY_CREDITS("Buy Credits","10"),
|
||||
BUY_CREDITS("Buy Credits","60"),
|
||||
// BUY_CREDITS("Buy Credits","10"),
|
||||
|
||||
INIT("init", "500"),
|
||||
// 每月更新
|
||||
INIT_YEARLY("init_yearly", "6000"),
|
||||
INIT_MONTHLY("init_monthly", "5000"),
|
||||
INIT_TRIAL("init_trial", "100"),
|
||||
INIT_WEEKLY("init_weekly","10000"),
|
||||
|
||||
DAILY_CHECKIN("Daily Check-In", "20"),
|
||||
// SUPER_RESOLUTION("Super Resolution","30"),
|
||||
SUPER_RESOLUTION("Super Resolution","10"),
|
||||
SLOGAN("Slogan","10"),
|
||||
LOGO("Logo","5"),
|
||||
PATTERN("Pattern","5"),
|
||||
MOOD_BOARD("MoodBoard","5"),
|
||||
SKETCH_BOARD("SketchBoard","5"),
|
||||
TO_PRODUCT_IMAGE("ToProductImage","5"),
|
||||
QUESTIONNAIRE("Questionnaire","100"),
|
||||
|
||||
SOCIAL_MEDIA_SHARING("Social Media Sharing","20"),
|
||||
|
||||
// SUPER_RESOLUTION("Super Resolution","300"),
|
||||
SUPER_RESOLUTION("Super Resolution","5"),
|
||||
|
||||
OTHER("Other","10");
|
||||
OTHER("Other","5");
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
"/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl",
|
||||
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify",
|
||||
"/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease",
|
||||
"/api/account/designWorksRegister"
|
||||
"/api/account/designWorksRegister","/api/account/questionnaire"
|
||||
);
|
||||
|
||||
@Override
|
||||
|
||||
26
src/main/java/com/ai/da/common/task/AccountTask.java
Normal file
26
src/main/java/com/ai/da/common/task/AccountTask.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import com.ai.da.service.AccountService;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
public class AccountTask {
|
||||
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
|
||||
/** 每周日晚上刷新 年付用户、月付用户的积分 */
|
||||
// @Scheduled(cron = "59 59 23 ? * SUN")
|
||||
public void refreshCreditsMonthly(){
|
||||
accountService.refreshCreditsWeekly();
|
||||
}
|
||||
|
||||
// todo 多久执行一次?
|
||||
public void getPaidUser(){
|
||||
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
|
||||
accountService.extendValidityForCC();
|
||||
}
|
||||
}
|
||||
@@ -450,6 +450,106 @@ public class SendEmailUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long QUESTIONNAIRE_FEEDBACK_EN_ID = 124151L;
|
||||
private final static Long QUESTIONNAIRE_FEEDBACK_CN_ID = 124156L;
|
||||
public static void questionnaireRelatedNotify(String userName, String email, String language){
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS);
|
||||
req.setDestination(new String[]{email});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
Template template = new Template();
|
||||
String subject = "Thank You for Completing the AiDA System Survey";
|
||||
template.setTemplateID(QUESTIONNAIRE_FEEDBACK_EN_ID);
|
||||
if (language.equals("CN")) {
|
||||
subject = "感谢您完成AiDA系统问卷调查";
|
||||
template.setTemplateID(QUESTIONNAIRE_FEEDBACK_CN_ID);
|
||||
}
|
||||
|
||||
JSONObject parameter = new JSONObject();
|
||||
parameter.put("userName", userName);
|
||||
|
||||
template.setTemplateData(parameter.toJSONString());
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static Long NEW_USER_PAYMENT_NOTIFICATION_EN = 0L;
|
||||
private final static Long NEW_USER_PAYMENT_NOTIFICATION_CN = 0L;
|
||||
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_EN = 0L;
|
||||
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_CN = 0L;
|
||||
|
||||
public static void notificationForPaidUser(String receiverAddress, int emailType, String country){
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
switch (emailType) {
|
||||
// 新用户
|
||||
case 1:
|
||||
subject = "Welcome to AiDA!";
|
||||
if (country.equals("China")) {
|
||||
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_CN);
|
||||
}else {
|
||||
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_EN);
|
||||
}
|
||||
break;
|
||||
// 续费用户
|
||||
case 2:
|
||||
subject = "Account renewal notification";
|
||||
if (country.equals("China")) {
|
||||
template.setTemplateID(RENEWAL_NOTIFICATION_FOR_OLD_USER_CN);
|
||||
}else {
|
||||
template.setTemplateID(RENEWAL_NOTIFICATION_FOR_OLD_USER_EN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
// template.setTemplateData(buildNotificationData(trialOrder, link));
|
||||
}
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Boolean designWorksRegister(String userEmail, String randomVerifyCode) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user