Merge remote-tracking branch 'origin/dev/dev_xp' into dev/dev_xp

This commit is contained in:
2025-12-01 16:02:20 +08:00
15 changed files with 113 additions and 37 deletions

View File

@@ -203,7 +203,8 @@ public class MyTaskScheduler {
}
}
}
// @Scheduled(cron = "0 0 9 * * ?")
@Scheduled(cron = "0 0 9 * * ?")
public void sendTrialOrderExcelToManagements() {
// 获取前一天日期
LocalDate yesterday = LocalDate.now().minusDays(1);

View File

@@ -0,0 +1,9 @@
package com.ai.da.common.constant;
public class AffiliateConstants {
public static final String STATUS_ACTIVE = "Active";
public static final String STATUS_INACTIVE = "Inactive";
public static final String STATUS_DELETE = "Delete";
public static final Integer DELETED = 1;
public static final Integer NOT_DELETED = 0;
}

View File

@@ -38,7 +38,7 @@ public class AccountTask {
}
// 每天凌晨0点执行一次
// @Scheduled(cron = "0 0 0 * * ?")
@Scheduled(cron = "0 0 0 * * ?")
public void cancelActivityBenefits() {
// 1、查询当前所有参与了活动且过期的用户
List<Account> accountList = accountService.getExpiredUserBySystemUser(4);

View File

@@ -100,9 +100,9 @@ public class GenerateTask {
// 万相 -> pose transformation 补偿 当前任务执行完后5分钟再执行一次不会出现任务重叠的情况
@Scheduled(fixedDelay = 5 * 60 * 1000)
public void wxCompensationMechanism(){
log.info("=====万相补偿获取结果开始=====");
List<APIGenerate> apiGenerates = apiGenerateService.getPendingTaskByStatus("wx");
if (apiGenerates != null && !apiGenerates.isEmpty()){
log.info("=====万相补偿获取结果开始=====");
for (APIGenerate apiGenerate : apiGenerates){
String taskId = apiGenerate.getTaskId();
PoseTransformation poseTransformation = poseTransformationMapper.selectOne(new QueryWrapper<PoseTransformation>().eq("unique_id", taskId));

View File

@@ -104,12 +104,12 @@ public class PaymentTask {
}
// 定时同步(每分钟一次)
// @Scheduled(fixedRate = 60000)
@Scheduled(fixedRate = 60000)
public void syncLinkViewCountToDB(){
affiliateService.syncLinkViewCountToDB();
}
// @Scheduled(cron = "0 0 8 28-31 * ?")
// @Scheduled(cron = "0 0 8 28-31 * ?")
public void commissionSummaryReminder(){
// 每个月末的最后一天的早上八点执行
LocalDate today = LocalDate.now();
@@ -120,7 +120,7 @@ public class PaymentTask {
}
}
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
public void calcCouponsCommission(){
log.info("优惠券佣金计算定时器");
affiliateService.calcCouponsCommission();

View File

@@ -7,6 +7,7 @@ import com.ai.da.mapper.primary.entity.Account;
import com.ai.da.mapper.primary.entity.SubscriptionInfo;
import com.ai.da.service.StripeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -45,6 +46,11 @@ public class SubscriptionReminderTask {
log.warn("未知的订阅类型: {}", subscriptionInfo.getType());
continue;
}
String emailType = subscriptionInfo.getStatus().equals("active") ? "reminder_subscriber" : subscriptionInfo.getStatus().equals("canceled") ? "reminder_expire" : null;
if (StringUtil.isNullOrEmpty(emailType)) {
log.warn("未知订阅状态:{}", subscriptionInfo.getStatus());
continue;
}
boolean success = stripeService.sendEmail(subscriptionInfo.getSubscriptionId(), "reminder_subscriber", null);
if (success) {
@@ -78,7 +84,7 @@ public class SubscriptionReminderTask {
QueryWrapper<SubscriptionInfo> qw = new QueryWrapper<>();
qw.ge("current_period_end", startTimestamp);
qw.lt("current_period_end", endTimestamp);
qw.eq("status", "active");
// qw.eq("status", "active");
qw.eq("subscription_type", subscriptionType);
return subscriptionInfoMapper.selectList(qw);

View File

@@ -840,6 +840,18 @@ public class SendEmailUtil {
templateUser.setTemplateID(156074L);
}
break;
case "reminder_expire":
if (language.equals("ENGLISH")) {
user.setSubject("[Code-Create] AiDA account is about to expire");
templateUser.setTemplateID(156749L);
} else if (language.equals("CHINESE")){
user.setSubject("[Code-Create] 您的AiDA账号即将到期");
templateUser.setTemplateID(156750L);
} else {
user.setSubject("[Code-Create] 您的AiDA帳號即將到期");
templateUser.setTemplateID(156751L);
}
break;
case "reminder_trial":
if (language.equals("ENGLISH")) {
user.setSubject("[Code-Create] AiDA — Free Trial Ending");

View File

@@ -313,8 +313,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
setEduAdminToExpire(account);
} else {
toVisitor(account);
return;
// throw new BusinessException("user.expired");
// return;
throw new BusinessException("account.expired", ResultEnum.PROMPT.getCode());
}
}
}
@@ -2499,8 +2499,15 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
if (Objects.nonNull(subAccount) && personAccRole.contains(subAccount.getSystemUser())) {
log.info("将用户{} 加入组织{}", addSubAccountDTO.getUserEmail(), adminAcc.getOrganizationName());
subAccount.setUserName(addSubAccountDTO.getUserName());
if (!StringUtil.isNullOrEmpty(addSubAccountDTO.getUserPassword()))
if (!StringUtil.isNullOrEmpty(addSubAccountDTO.getUserPassword())){
subAccount.setUserPassword(addSubAccountDTO.getUserPassword());
}
// 判断当前账号的有效期是否与管理员同步
if (subAccount.getValidEndTime() < adminAcc.getValidEndTime()){
subAccount.setValidEndTime(adminAcc.getValidEndTime());
}
subAccount.setSystemUser(subUserRole);
subAccount.setOrganizationName(adminAcc.getOrganizationName());
subAccount.setParentId(adminAcc.getId());

View File

@@ -1,6 +1,7 @@
package com.ai.da.service.impl;
import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.constant.AffiliateConstants;
import com.ai.da.common.constant.CommonConstant;
import com.ai.da.common.context.UserContext;
import com.ai.da.common.response.PageBaseResponse;
@@ -202,29 +203,70 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
return true;
}
public void editAffiliate(Long id, Float commission, String operationType){
Affiliate affiliate = baseMapper.selectById(id);
if (Objects.isNull(affiliate)){
log.info("未知affiliate id :{}", id);
throw new BusinessException("unknown affiliate");
}
if (!Objects.equals(affiliate.getCommissionPercent(), commission)){
affiliate.setCommissionPercent(commission);
public void editAffiliate(Long id, Float commission, String operationType) {
// 参数验证
if (id == null) {
throw new BusinessException("affiliate.id.cannot.be.null");
}
// operationType Active -> 激活 | Inactive -> 关闭 | Delete -> 删除
if (!StringUtil.isNullOrEmpty(operationType)) {
if (operationType.equals("Delete")) {
baseMapper.deleteById(id);
return;
} else if (operationType.equals("Active") || operationType.equals("Inactive")) {
affiliate.setStatus(operationType);
} else {
throw new BusinessException("unknown.operationType");
}
Affiliate affiliate = baseMapper.selectById(id);
if (affiliate == null) {
log.warn("未知affiliate id: {}", id); // 使用warn级别更合适
throw new BusinessException("unknown.affiliate");
}
// 构建更新条件
UpdateWrapper<Affiliate> updateWrapper = buildUpdateWrapper(affiliate, commission, operationType);
baseMapper.update(null, updateWrapper);
}
private UpdateWrapper<Affiliate> buildUpdateWrapper(Affiliate affiliate, Float commission, String operationType) {
UpdateWrapper<Affiliate> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda()
.eq(Affiliate::getId, affiliate.getId())
.set(Affiliate::getUpdateTime, LocalDateTime.now());
// 处理佣金更新
handleCommissionUpdate(affiliate, commission, updateWrapper);
// 处理操作类型
if (!StringUtil.isNullOrEmpty(operationType)) {
handleOperationType(affiliate, operationType, updateWrapper);
}
return updateWrapper;
}
private void handleCommissionUpdate(Affiliate affiliate, Float commission,
UpdateWrapper<Affiliate> updateWrapper) {
if (commission != null && !Objects.equals(affiliate.getCommissionPercent(), commission)) {
updateWrapper.lambda().set(Affiliate::getCommissionPercent, commission);
}
}
private void handleOperationType(Affiliate affiliate, String operationType,
UpdateWrapper<Affiliate> updateWrapper) {
switch (operationType) {
case AffiliateConstants.STATUS_DELETE:
updateWrapper.lambda()
.set(Affiliate::getStatus, AffiliateConstants.STATUS_DELETE)
.set(Affiliate::getIsDeleted, AffiliateConstants.DELETED);
break;
case AffiliateConstants.STATUS_ACTIVE:
case AffiliateConstants.STATUS_INACTIVE:
updateWrapper.lambda().set(Affiliate::getStatus, operationType);
// 激活时生成链接
if (AffiliateConstants.STATUS_ACTIVE.equals(operationType) &&
StringUtil.isNullOrEmpty(affiliate.getLink())) {
updateWrapper.lambda().set(Affiliate::getLink,
CommonConstant.AFFILIATE_LINK + affiliate.getId());
}
break;
default:
throw new BusinessException("unknown.operationType");
}
affiliate.setUpdateTime(LocalDateTime.now());
baseMapper.updateById(affiliate);
}
// 定时计算佣金

View File

@@ -427,13 +427,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (!detail.getType().equals("Body")) {
designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(0));
designItemDetail.setUndividedLayerWithSinglePrint(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(1));
}
// 印花存储在design_item_detail_print表中 这里还要存吗?
// DesignPythonItemPrint printObject = detail.getPrintToPython();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
// 当有多个印花后返回的printObject太长导致存储到数据库时报错
// designItemDetail.setPrintJson(JSON.toJSONString(printObject));
designItemDetail.setPartialDesign(Objects.isNull(detail.getPrint()) ? null : detail.getPrint().getPartial());
designItemDetails.add(designItemDetail);

View File

@@ -732,7 +732,7 @@ public class EmailServiceImpl implements EmailService {
jsonObject.put("quantity", quantity);
jsonObject.put("totalFee", amount);
sendEmail(Arrays.asList(/*merchantEmail,*/developerEmail), jsonObject, CREDITS_PURCHASE_MERCHANT, "New Credit Purchase Order", null, null);
sendEmail(Arrays.asList(/*merchantEmail,*/ developerEmail), jsonObject, CREDITS_PURCHASE_MERCHANT, "New Credit Purchase Order", null, null);
}
private final static String COMMON_EXCEPTION_REMINDER = "135279_common-exception-reminder.html";

View File

@@ -171,6 +171,7 @@ public class StripeServiceImpl implements StripeService {
String orderId = orderInfo.getOrderNo();
// Alipay - Not supported when using Checkout in subscription mode or setup mode.
if (payType.equals("recurring")){
sessionBuilder.setMode(SessionCreateParams.Mode.SUBSCRIPTION);
sessionBuilder.setSubscriptionData(SessionCreateParams.SubscriptionData.builder().setDescription("AiDA - " + orderId).build());

View File

@@ -37,6 +37,7 @@
<if test="affiliateId != null">
AND f.id = #{affiliateId}
</if>
AND f.is_deleted = 0
</where>
<choose>
<when test="sortField != null and sortField != ''">
@@ -83,6 +84,7 @@
AND f.id = #{affiliateId}
</if>
</where>
AND f.is_deleted = 0
</select>
<select id="selectAllAffiliateUsername" resultType="java.util.Map">

View File

@@ -204,6 +204,7 @@ hsv.value.cannot.exceed.the.maximum.of.8=hsv value cannot exceed the maximum of
the.workspaceName.already.exists=A workspace with this name already exists.
unable.to.delete.the.workspace.you.are.currently.using=The workspace you are currently using cannot be deleted. Please select another workspace before trying to delete.
classificationName.already.exists=The label name you've entered already exists. Please enter a different label name to avoid duplication.
account.expired=Your subscription has expired, and your account has been reset to a visitor account. Please log in again from the [Individual] entry. If you have any questions, please contact us at info@code-create.com.hk
# Warnings:
# 用来提醒用户可能会导致不良后果的操作,但不一定是错误。用户需要认真考虑是否继续当前操作。

View File

@@ -222,6 +222,7 @@ generate.interface.error=生成接口出现错误。(请稍后再试。如果
chat-bot.interface.exception=聊天机器人接口出现错误。请稍后再试。如果问题持续请联系我们的help@aida.com.hk
compose-layer.interface.exception=图层合并时出现问题。请稍后再试。如果问题持续请联系我们的help@aida.com.hk
cloth-classification.interface.exception=获取服装类别时出现问题。请稍后再试。如果问题持续请联系我们的help@aida.com.hk
account.expired=您的订阅已过期,账号已被重置为访客身份,请从【个人账号】入口重新登录。如有疑问,请联系 info@code-create.com.hk。
# 多语言返回
OVERALL=整体