BUGFIX: 打开佣金计算定时器
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.ai.da.service.impl;
|
package com.ai.da.service.impl;
|
||||||
|
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
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.constant.CommonConstant;
|
||||||
import com.ai.da.common.context.UserContext;
|
import com.ai.da.common.context.UserContext;
|
||||||
import com.ai.da.common.response.PageBaseResponse;
|
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 merchantEmail = "kimwong@code-create.com.hk";
|
||||||
String developer = "xupei3360@163.com";
|
String developer = "xupei3360@163.com";
|
||||||
String[] receiverEmail = {merchantEmail, developer};
|
String[] receiverEmail = {/*merchantEmail,*/ developer};
|
||||||
SendEmailUtil.affiliateEmailReminder(receiverEmail, new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
|
SendEmailUtil.affiliateEmailReminder(receiverEmail, new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
|
||||||
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
|
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
|
||||||
}else {
|
}else {
|
||||||
@@ -200,29 +201,69 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
|
|||||||
return true;
|
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);
|
Affiliate affiliate = baseMapper.selectById(id);
|
||||||
if (Objects.isNull(affiliate)){
|
if (affiliate == null) {
|
||||||
log.info("未知affiliate id :{}", id);
|
log.warn("未知affiliate id: {}", id); // 使用warn级别更合适
|
||||||
throw new BusinessException("unknown affiliate");
|
throw new BusinessException("unknown.affiliate");
|
||||||
}
|
|
||||||
if (!Objects.equals(affiliate.getCommissionPercent(), commission)){
|
|
||||||
affiliate.setCommissionPercent(commission);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 (!StringUtil.isNullOrEmpty(operationType)) {
|
||||||
if (operationType.equals("Delete") || operationType.equals("Active") || operationType.equals("Inactive")) {
|
handleOperationType(affiliate, operationType, updateWrapper);
|
||||||
affiliate.setStatus(operationType);
|
|
||||||
} else {
|
|
||||||
throw new BusinessException("unknown.operationType");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
affiliate.setUpdateTime(LocalDateTime.now());
|
|
||||||
baseMapper.updateById(affiliate);
|
|
||||||
|
|
||||||
if (operationType.equals("Delete")) {
|
return updateWrapper;
|
||||||
baseMapper.deleteById(id);
|
}
|
||||||
|
|
||||||
|
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 merchantEmail = "kimwong@code-create.com.hk";
|
||||||
String developer = "xupei3360@163.com";
|
String developer = "xupei3360@163.com";
|
||||||
String[] receiverEmail = {merchantEmail, developer};
|
String[] receiverEmail = {/*merchantEmail,*/ developer};
|
||||||
// 邮件通知
|
// 邮件通知
|
||||||
SendEmailUtil.affiliateEmailReminder(receiverEmail, affiliateEmailParamsDTO, "summary");
|
SendEmailUtil.affiliateEmailReminder(receiverEmail, affiliateEmailParamsDTO, "summary");
|
||||||
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), affiliateEmailParamsDTO, "summary");
|
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), affiliateEmailParamsDTO, "summary");
|
||||||
|
|||||||
@@ -369,13 +369,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
if (!detail.getType().equals("Body")) {
|
if (!detail.getType().equals("Body")) {
|
||||||
designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(0));
|
designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(0));
|
||||||
designItemDetail.setUndividedLayerWithSinglePrint(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(1));
|
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());
|
designItemDetail.setPartialDesign(Objects.isNull(detail.getPrint()) ? null : detail.getPrint().getPartial());
|
||||||
designItemDetails.add(designItemDetail);
|
designItemDetails.add(designItemDetail);
|
||||||
|
|||||||
Reference in New Issue
Block a user