BUGFIX: 打开佣金计算定时器

This commit is contained in:
2025-11-25 10:10:14 +08:00
parent b9641474ba
commit 94c0e81335
2 changed files with 60 additions and 25 deletions

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;
@@ -82,7 +83,7 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
// 邮件通知审批者
String merchantEmail = "kimwong@code-create.com.hk";
String developer = "xupei3360@163.com";
String[] receiverEmail = {merchantEmail, developer};
String[] receiverEmail = {/*merchantEmail,*/ developer};
SendEmailUtil.affiliateEmailReminder(receiverEmail, new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
}else {
@@ -200,29 +201,69 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
return true;
}
public void editAffiliate(Long id, Float commission, String operationType){
public void editAffiliate(Long id, Float commission, String operationType) {
// 参数验证
if (id == null) {
throw new BusinessException("affiliate.id.cannot.be.null");
}
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);
if (affiliate == null) {
log.warn("未知affiliate id: {}", id); // 使用warn级别更合适
throw new BusinessException("unknown.affiliate");
}
// operationType Active -> 激活 | Inactive -> 关闭 | Delete -> 删除
// 构建更新条件
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)) {
if (operationType.equals("Delete") || operationType.equals("Active") || operationType.equals("Inactive")) {
affiliate.setStatus(operationType);
} else {
throw new BusinessException("unknown.operationType");
}
handleOperationType(affiliate, operationType, updateWrapper);
}
affiliate.setUpdateTime(LocalDateTime.now());
baseMapper.updateById(affiliate);
if (operationType.equals("Delete")) {
baseMapper.deleteById(id);
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");
}
}
@@ -402,7 +443,7 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
String merchantEmail = "kimwong@code-create.com.hk";
String developer = "xupei3360@163.com";
String[] receiverEmail = {merchantEmail, developer};
String[] receiverEmail = {/*merchantEmail,*/ developer};
// 邮件通知
SendEmailUtil.affiliateEmailReminder(receiverEmail, affiliateEmailParamsDTO, "summary");
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), affiliateEmailParamsDTO, "summary");

View File

@@ -369,13 +369,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);