Merge branch 'dev/dev_xp' into dev/3.1_release_merge
This commit is contained in:
@@ -27,4 +27,6 @@ public interface MessageCenterService extends IService<Notification> {
|
||||
void setReadAll(String type);
|
||||
|
||||
void publishSystemNotification(PublishSysNotificationDTO message);
|
||||
|
||||
void videoFinishedMsg(Long userId, String projectName, boolean isSuccess);
|
||||
}
|
||||
|
||||
@@ -37,11 +37,13 @@ public interface StripeService {
|
||||
|
||||
boolean sendEmail(String subscriptionId, String type, String orderNo);
|
||||
|
||||
String getLanguage(String language, String country, String type);
|
||||
|
||||
/*void updateSubscription(String subscriptionId);
|
||||
|
||||
void resume(String subscriptionId);*/
|
||||
|
||||
void subscriptionReminder();
|
||||
// void subscriptionReminder();
|
||||
|
||||
void checkSubscriptionExpiration();
|
||||
|
||||
|
||||
@@ -634,7 +634,7 @@ public class EmailServiceImpl implements EmailService {
|
||||
userTemplate = RENEWAL_USER_CN;
|
||||
}
|
||||
break;
|
||||
case "reminder":
|
||||
/*case "reminder":
|
||||
if (language.equals("ENGLISH")) {
|
||||
userSubject = "[Code-Create] AiDA Subscription Renewal Reminder";
|
||||
userTemplate = RENEWAL_REMINDER_USER_EN;
|
||||
@@ -642,6 +642,30 @@ public class EmailServiceImpl implements EmailService {
|
||||
userSubject = "[Code-Create] AiDA续订提醒";
|
||||
userTemplate = RENEWAL_REMINDER_USER_CN;
|
||||
}
|
||||
break;*/
|
||||
case "reminder_subscriber":
|
||||
if (language.equals("ENGLISH")) {
|
||||
userSubject = "[Code-Create] AiDA Subscription Renewal Reminder";
|
||||
userTemplate = String.valueOf(156072L);
|
||||
} else if (language.equals("CHINESE")){
|
||||
userSubject = "[Code-Create] AiDA续订提醒";
|
||||
userTemplate = String.valueOf(156073L);
|
||||
} else {
|
||||
userSubject = "[Code-Create] AiDA續訂提醒";
|
||||
userTemplate = String.valueOf(156074L);
|
||||
}
|
||||
break;
|
||||
case "reminder_trial":
|
||||
if (language.equals("ENGLISH")) {
|
||||
userSubject = "[Code-Create] AiDA — Free Trial Ending";
|
||||
userTemplate = String.valueOf(156075L);
|
||||
} else if (language.equals("CHINESE")){
|
||||
userSubject = "[Code-Create] AiDA — 免费试用结束提醒";
|
||||
userTemplate = String.valueOf(156076L);
|
||||
} else {
|
||||
userSubject = "[Code-Create] AiDA — 免費試用結束提醒";
|
||||
userTemplate = String.valueOf(156077L);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log.error("unknown subscription email type");
|
||||
@@ -654,7 +678,7 @@ public class EmailServiceImpl implements EmailService {
|
||||
sendEmail(Collections.singletonList(receiverAddress), jsonObject, userTemplate, userSubject, null, null);
|
||||
}
|
||||
// 排除不向商家发送邮件的情况
|
||||
if (!type.equals("reminder")) {
|
||||
if (!type.startsWith("reminder")) {
|
||||
sendEmail(merchantReceiver, jsonObject, merchantTemplate, merchantSubject, null, null);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.volcengine.ark.runtime.model.images.generation.ImagesResponse;
|
||||
import com.volcengine.ark.runtime.service.ArkService;
|
||||
import io.minio.errors.MinioException;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -84,58 +85,35 @@ import static com.ai.da.common.enums.WangXiangTaskStatusEnum.UNKNOWN_W;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> implements GenerateService {
|
||||
|
||||
@Resource
|
||||
private CollectionElementMapper collectionElementMapper;
|
||||
@Resource
|
||||
private GenerateDetailMapper generateDetailMapper;
|
||||
@Resource
|
||||
private LibraryService libraryService;
|
||||
@Resource
|
||||
private PythonService pythonService;
|
||||
@Resource
|
||||
private CollectionElementService collectionElementService;
|
||||
@Resource
|
||||
private CreditsService creditsService;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
@Resource
|
||||
private RabbitMQService rabbitMQService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private GenerateCancelMapper generateCancelMapper;
|
||||
@Resource
|
||||
private SketchReconstructionMapper sketchReconstructionMapper;
|
||||
@Resource
|
||||
private SendRequestUtil sendRequestUtil;
|
||||
@Resource
|
||||
private ProjectService projectService;
|
||||
@Resource
|
||||
private CollectionSortService collectionSortService;
|
||||
@Resource
|
||||
private CloudTaskService cloudTaskService;
|
||||
@Resource
|
||||
private APIGenerateMapper apiGenerateMapper;
|
||||
@Resource
|
||||
private CollectionSortMapper collectionSortMapper;
|
||||
@Resource
|
||||
private SysFileService sysFileService;
|
||||
@Resource
|
||||
private LibraryModelPointService libraryModelPointService;
|
||||
@Resource
|
||||
private PoseTransformationMapper poseTransformationMapper;
|
||||
@Resource
|
||||
private CloudTaskMapper cloudTaskMapper;
|
||||
@Resource
|
||||
private ToProductImageResultMapper toProductImageResultMapper;
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
@Resource
|
||||
private APIGenerateService apiGenerateService;
|
||||
@Resource
|
||||
private UserLikeGroupService userLikeGroupService;
|
||||
private final CollectionElementMapper collectionElementMapper;
|
||||
private final GenerateDetailMapper generateDetailMapper;
|
||||
private final LibraryService libraryService;
|
||||
private final PythonService pythonService;
|
||||
private final CollectionElementService collectionElementService;
|
||||
private final CreditsService creditsService;
|
||||
private final MinioUtil minioUtil;
|
||||
private final RabbitMQService rabbitMQService;
|
||||
private final RedisUtil redisUtil;
|
||||
private final GenerateCancelMapper generateCancelMapper;
|
||||
private final SketchReconstructionMapper sketchReconstructionMapper;
|
||||
private final SendRequestUtil sendRequestUtil;
|
||||
private final ProjectService projectService;
|
||||
private final CollectionSortService collectionSortService;
|
||||
private final CloudTaskService cloudTaskService;
|
||||
private final APIGenerateMapper apiGenerateMapper;
|
||||
private final CollectionSortMapper collectionSortMapper;
|
||||
private final SysFileService sysFileService;
|
||||
private final LibraryModelPointService libraryModelPointService;
|
||||
private final PoseTransformationMapper poseTransformationMapper;
|
||||
private final CloudTaskMapper cloudTaskMapper;
|
||||
private final ToProductImageResultMapper toProductImageResultMapper;
|
||||
private final AccountService accountService;
|
||||
private final APIGenerateService apiGenerateService;
|
||||
private final UserLikeGroupService userLikeGroupService;
|
||||
private final MessageCenterService messageCenterService;
|
||||
|
||||
@Value("${redis.key.orderForGenerate}")
|
||||
private String consumptionOrderKey;
|
||||
@@ -2472,6 +2450,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
}
|
||||
|
||||
public ToProductImageResultVO poseTransform(PoseTransformDTO poseTransformDTO) {
|
||||
// 参数判断
|
||||
handleMotionParams(poseTransformDTO);
|
||||
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Long projectId = poseTransformDTO.getProjectId();
|
||||
String productImage = poseTransformDTO.getProductImage();
|
||||
@@ -2557,11 +2538,28 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
throw new BusinessException("pose.transformation.error", ResultEnum.ERROR.getCode());
|
||||
}
|
||||
|
||||
private void handleMotionParams(PoseTransformDTO poseTransformDTO) {
|
||||
if (Objects.isNull(poseTransformDTO.getMode()) || poseTransformDTO.getMode() == 0) {
|
||||
throw new BusinessException("Mode cannot be empty");
|
||||
}
|
||||
MotionModeEnum motionModeEnum = MotionModeEnum.of(poseTransformDTO.getMode());
|
||||
if (Objects.isNull(motionModeEnum)) {
|
||||
throw new BusinessException("unknown.mode");
|
||||
}
|
||||
if (poseTransformDTO.getMode() == 1 && Objects.isNull(poseTransformDTO.getPoseId())) {
|
||||
throw new BusinessException("Please choose a pose");
|
||||
}
|
||||
if (poseTransformDTO.getMode() == 3 && StringUtil.isNullOrEmpty(poseTransformDTO.getLastFrameProductImage())) {
|
||||
throw new BusinessException("Last frame cannot be empty");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private CollectionSort addPoseTransferLike(PoseTransformDTO poseTransformDTO, Long poseTransformationId) {
|
||||
if (Objects.nonNull(poseTransformDTO.getParentId())
|
||||
&& !poseTransformDTO.getParentId().equals(0L)) {
|
||||
return disOrLikePose(poseTransformationId, "like",
|
||||
poseTransformDTO.getProjectId(), poseTransformDTO.getUserLikeSortId());
|
||||
poseTransformDTO.getProjectId(), poseTransformDTO.getParentId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -2599,6 +2597,12 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
// String uuid = taskId.substring(0, taskId.lastIndexOf("-"));
|
||||
Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(accountId), taskId);
|
||||
if (flag) creditsService.updateChangedCredits(accountId, taskId);
|
||||
|
||||
Project project = projectService.getById(poseTransformation.getProjectId());
|
||||
// 发通知
|
||||
if (Objects.nonNull(project) && !StringUtil.isNullOrEmpty(project.getName())) {
|
||||
messageCenterService.videoFinishedMsg(poseTransformation.getAccountId(), project.getName() , true);
|
||||
}
|
||||
}
|
||||
|
||||
public List<PoseTransformationVO> getPoseTransformationResult(List<String> taskIdList, Long projectId, Boolean like) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.ai.da.mapper.primary.entity.Portfolio;
|
||||
import com.ai.da.mapper.primary.entity.SysNotificationReadStatus;
|
||||
import com.ai.da.model.dto.GetNotificationDTO;
|
||||
import com.ai.da.model.dto.PublishSysNotificationDTO;
|
||||
import com.ai.da.model.enums.Language;
|
||||
import com.ai.da.model.vo.NotificationVO;
|
||||
import com.ai.da.service.AccountService;
|
||||
import com.ai.da.service.MessageCenterService;
|
||||
@@ -97,9 +98,18 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
||||
if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType())) {
|
||||
queryWrapper.eq("type", getNotificationDTO.getType());
|
||||
}
|
||||
if (!getNotificationDTO.getType().equals("system")){
|
||||
queryWrapper.eq("receiver_id", accountId);
|
||||
|
||||
if (getNotificationDTO.getType().equals("system")){
|
||||
queryWrapper.lambda().eq(Notification::getType, "system")
|
||||
.and(wrapper -> wrapper
|
||||
.isNull(Notification::getReceiverId)
|
||||
.or()
|
||||
.eq(Notification::getReceiverId, accountId)
|
||||
);
|
||||
} else {
|
||||
queryWrapper.lambda().eq(Notification::getReceiverId, accountId);
|
||||
}
|
||||
|
||||
Page<Notification> notificationPage = baseMapper.selectPage(new Page<>(getNotificationDTO.getPage(), getNotificationDTO.getSize()), queryWrapper);
|
||||
|
||||
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId);
|
||||
@@ -378,4 +388,31 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
||||
return PageBaseResponse.success(convert);
|
||||
}
|
||||
|
||||
public void videoFinishedMsg(Long userId, String projectName, boolean isSuccess) {
|
||||
Account account = accountService.getById(userId);
|
||||
String language = account.getLanguage();
|
||||
Notification notification = new Notification();
|
||||
notification.setType("system");
|
||||
notification.setReceiverId(userId);
|
||||
if (isSuccess) {
|
||||
if (language.equals(Language.ENGLISH.name())) {
|
||||
notification.setContent("Your video generation task in Project " + projectName + " is ready!");
|
||||
} else {
|
||||
notification.setContent("您在项目 " + projectName + " 中创建的视频生成任务已完成!");
|
||||
}
|
||||
} else {
|
||||
if (language.equals(Language.ENGLISH.name())) {
|
||||
notification.setContent("Your video generation task in Project " + projectName + " has failed.");
|
||||
} else {
|
||||
notification.setContent("视频生成任务失败。");
|
||||
}
|
||||
}
|
||||
|
||||
notification.setIsRead(0);
|
||||
notification.setCreateTime(LocalDateTime.now());
|
||||
|
||||
save(notification);
|
||||
pushMessage("system", userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.ai.da.model.dto.CreateCouponDTO;
|
||||
import com.ai.da.model.dto.ProductPurchaseDTO;
|
||||
import com.ai.da.model.dto.QueryCouponsPageDTO;
|
||||
import com.ai.da.model.dto.SubscriptionEmailParamsDTO;
|
||||
import com.ai.da.model.enums.Language;
|
||||
import com.ai.da.model.vo.CheckCouponsVO;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -1072,7 +1073,7 @@ public class StripeServiceImpl implements StripeService {
|
||||
String key = RedisUtil.SUBSCRIPTION_SENT_EMAIL_TYPE + subscriptionInfo.getId();
|
||||
// 先判断当前订单 这个类型的邮件是否已发送过
|
||||
Boolean elementExistsInSet = redisUtil.isElementExistsInSet(key, type);
|
||||
if (!type.equals("reminder") && !type.equals("cancel") && paymentInfo.getNotified() == 1 && elementExistsInSet){
|
||||
if (!type.startsWith("reminder") && !type.equals("cancel") && paymentInfo.getNotified() == 1 && elementExistsInSet){
|
||||
// 已经邮件通知过,直接返回
|
||||
log.info("不发送邮件,原因:【type为:{},order_no为:{},已经进行邮件通知】", type, orderNo);
|
||||
return true;
|
||||
@@ -1080,7 +1081,7 @@ public class StripeServiceImpl implements StripeService {
|
||||
|
||||
com.ai.da.mapper.primary.entity.Account account = accountMapper.selectById(subscriptionInfo.getAccountId());
|
||||
String userName = account.getUserName();
|
||||
String language = account.getLanguage();
|
||||
String language = getLanguage(account.getLanguage(), account.getCountry(), type);
|
||||
OrderInfo orderByOrderNo = orderInfoService.getOrderByOrderNo(subscriptionInfo.getOrderNo());
|
||||
|
||||
SubscriptionEmailParamsDTO emailParamsDTO = new SubscriptionEmailParamsDTO();
|
||||
@@ -1101,7 +1102,7 @@ public class StripeServiceImpl implements StripeService {
|
||||
if (!b) return false;
|
||||
|
||||
// 邮件通知成功后,更新标志
|
||||
if (!type.equals("reminder") && !type.equals("cancel")){
|
||||
if (!type.startsWith("reminder") && !type.equals("cancel")){
|
||||
PaymentInfo payment = new PaymentInfo();
|
||||
payment.setId(paymentInfo.getId());
|
||||
payment.setNotified(1);
|
||||
@@ -1114,6 +1115,20 @@ public class StripeServiceImpl implements StripeService {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getLanguage(String language, String country, String type) {
|
||||
if (StringUtil.isNullOrEmpty(language)){
|
||||
return Language.ENGLISH.name();
|
||||
} else {
|
||||
if (!StringUtil.isNullOrEmpty(type) && type.startsWith("reminder")
|
||||
&& language.equals(Language.CHINESE_SIMPLIFIED.name())
|
||||
&& !StringUtil.isNullOrEmpty(country)
|
||||
&& (country.equals("Hong Kong, China") || country.equals("Taiwan, China"))) {
|
||||
return "zh-Hant";
|
||||
}
|
||||
return language;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sendEmail(String orderNo){
|
||||
SubscriptionEmailParamsDTO emailParamsDTO = new SubscriptionEmailParamsDTO();
|
||||
OrderInfo orderInfo = orderInfoService.getOrderByOrderNo(orderNo);
|
||||
@@ -1257,9 +1272,10 @@ public class StripeServiceImpl implements StripeService {
|
||||
emailParamsDTO.setNextPayDate(DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodEnd(), "seconds", CommonConstant.TIME_FORMAT_MMM_dd_yyyy));
|
||||
}
|
||||
emailParamsDTO.setRenewalTime(DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodEnd(), "seconds", CommonConstant.TIME_FORMAT_MMM_dd_yyyy));
|
||||
emailParamsDTO.setDays(subscriptionInfo.getType().equals("month") ? "7" : subscriptionInfo.getType().equals("year") ? "14" : "N/A");
|
||||
}
|
||||
|
||||
public void subscriptionReminder(){
|
||||
/*public void subscriptionReminder(){
|
||||
// 提前7天的 00:00:00 和 23:59:59
|
||||
LocalDateTime startOfDay = LocalDateTime.now().plusDays(7).toLocalDate().atStartOfDay();
|
||||
LocalDateTime endOfDay = LocalDateTime.now().plusDays(7).toLocalDate().atTime(23, 59, 59);
|
||||
@@ -1278,7 +1294,7 @@ public class StripeServiceImpl implements StripeService {
|
||||
boolean b = sendEmail(subscriptionInfo.getSubscriptionId(), "reminder", null);
|
||||
if (b) log.info("提前7天向用户 {} 发送续订通知邮件", subscriptionInfo.getAccountId());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public void checkSubscriptionExpiration(){
|
||||
long epochSecond = Instant.now().getEpochSecond();
|
||||
|
||||
Reference in New Issue
Block a user