TASK: video生成成功后添加站内信通知

This commit is contained in:
2025-11-17 16:55:45 +08:00
parent f239c8c02b
commit f36e0488ea
5 changed files with 80 additions and 57 deletions

View File

@@ -87,9 +87,9 @@ public class PaymentTask {
// !!关闭此定时器,改为提前三天站内信提醒!!
// 提前7天向用户发送提醒邮件,每天早上8点执行
// @Scheduled(cron = "0 0 8 * * ?")
public void subscriptionReminder(){
stripeService.subscriptionReminder();
}
// public void subscriptionReminder(){
// stripeService.subscriptionReminder();
// }
// 如果有订阅已创建,但是没有发邮件通知的,需要主动获取回调信息并向用户发送邮件

View File

@@ -29,7 +29,7 @@ public class PoseTransformDTO {
@ApiModelProperty("design结果在collectionSort中的id")
private Long parentId;
@ApiModelProperty("子集中的元素作为父元素")
@ApiModelProperty("子集中的元素作为父元素,用于重新排序")
private Long userLikeSortId;
@ApiModelProperty("是否默认喜欢")

View File

@@ -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);
}

View File

@@ -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;
@@ -2581,7 +2559,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
if (Objects.nonNull(poseTransformDTO.getParentId())
&& !poseTransformDTO.getParentId().equals(0L)) {
return disOrLikePose(poseTransformationId, "like",
poseTransformDTO.getProjectId(), poseTransformDTO.getUserLikeSortId());
poseTransformDTO.getProjectId(), poseTransformDTO.getParentId());
}
return null;
}
@@ -2619,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) {

View File

@@ -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);
}
}