feat(task): 完善经销商佣金解冻任务功能
- 新增 ShopDealerOrderService 服务注入用于订单状态更新 - 添加 isUnfreeze 和 unfreezeTime 字段到 ShopDealerOrder 实体 - 实现佣金解冻完成后自动更新分销订单状态为"已解冻" - 添加解冻时间记录功能 - 通过统计 flowType 判断佣金解冻完成度避免提前更新状态 - 增加解冻状态更新失败的日志警告
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.gxwebsoft.glt.task;
|
package com.gxwebsoft.glt.task;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.gxwebsoft.common.core.annotation.IgnoreTenant;
|
import com.gxwebsoft.common.core.annotation.IgnoreTenant;
|
||||||
import com.gxwebsoft.glt.entity.GltTicketOrder;
|
import com.gxwebsoft.glt.entity.GltTicketOrder;
|
||||||
import com.gxwebsoft.glt.entity.GltTicketTemplate;
|
import com.gxwebsoft.glt.entity.GltTicketTemplate;
|
||||||
@@ -9,9 +10,11 @@ import com.gxwebsoft.glt.service.GltTicketOrderService;
|
|||||||
import com.gxwebsoft.glt.service.GltTicketTemplateService;
|
import com.gxwebsoft.glt.service.GltTicketTemplateService;
|
||||||
import com.gxwebsoft.glt.service.GltUserTicketService;
|
import com.gxwebsoft.glt.service.GltUserTicketService;
|
||||||
import com.gxwebsoft.shop.entity.ShopDealerCapital;
|
import com.gxwebsoft.shop.entity.ShopDealerCapital;
|
||||||
|
import com.gxwebsoft.shop.entity.ShopDealerOrder;
|
||||||
import com.gxwebsoft.shop.entity.ShopDealerUser;
|
import com.gxwebsoft.shop.entity.ShopDealerUser;
|
||||||
import com.gxwebsoft.shop.entity.ShopOrder;
|
import com.gxwebsoft.shop.entity.ShopOrder;
|
||||||
import com.gxwebsoft.shop.service.ShopDealerCapitalService;
|
import com.gxwebsoft.shop.service.ShopDealerCapitalService;
|
||||||
|
import com.gxwebsoft.shop.service.ShopDealerOrderService;
|
||||||
import com.gxwebsoft.shop.service.ShopDealerUserService;
|
import com.gxwebsoft.shop.service.ShopDealerUserService;
|
||||||
import com.gxwebsoft.shop.service.ShopOrderService;
|
import com.gxwebsoft.shop.service.ShopOrderService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -65,6 +68,9 @@ public class DealerCommissionUnfreeze10584Task {
|
|||||||
@Resource
|
@Resource
|
||||||
private ShopDealerCapitalService shopDealerCapitalService;
|
private ShopDealerCapitalService shopDealerCapitalService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ShopDealerOrderService shopDealerOrderService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ShopDealerUserService shopDealerUserService;
|
private ShopDealerUserService shopDealerUserService;
|
||||||
|
|
||||||
@@ -355,12 +361,56 @@ public class DealerCommissionUnfreeze10584Task {
|
|||||||
marker.setUpdateTime(now);
|
marker.setUpdateTime(now);
|
||||||
shopDealerCapitalService.save(marker);
|
shopDealerCapitalService.save(marker);
|
||||||
|
|
||||||
|
// 佣金全部解冻完成后,将分销订单状态置为“已解冻”(0)。
|
||||||
|
// 以当前任务生成的 flowType=50 marker 数量作为完成度判断,避免提前将订单置为已解冻。
|
||||||
|
setDealerOrderUnfrozenIfCompleted(orderNo, now);
|
||||||
|
|
||||||
log.info("佣金解冻成功 - tenantId={}, orderNo={}, dealerUserId={}, amount={}, capitalId={}",
|
log.info("佣金解冻成功 - tenantId={}, orderNo={}, dealerUserId={}, amount={}, capitalId={}",
|
||||||
TENANT_ID, orderNo, dealerUserId, amount, capitalId);
|
TENANT_ID, orderNo, dealerUserId, amount, capitalId);
|
||||||
return true;
|
return true;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDealerOrderUnfrozenIfCompleted(String orderNo, LocalDateTime now) {
|
||||||
|
if (orderNo == null || orderNo.isBlank()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
long totalCommissions = shopDealerCapitalService.count(
|
||||||
|
new LambdaQueryWrapper<ShopDealerCapital>()
|
||||||
|
.eq(ShopDealerCapital::getTenantId, TENANT_ID)
|
||||||
|
.eq(ShopDealerCapital::getFlowType, 10)
|
||||||
|
.eq(ShopDealerCapital::getOrderNo, orderNo)
|
||||||
|
);
|
||||||
|
if (totalCommissions <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
long unfrozenMarkers = shopDealerCapitalService.count(
|
||||||
|
new LambdaQueryWrapper<ShopDealerCapital>()
|
||||||
|
.eq(ShopDealerCapital::getTenantId, TENANT_ID)
|
||||||
|
.eq(ShopDealerCapital::getFlowType, 50)
|
||||||
|
.eq(ShopDealerCapital::getOrderNo, orderNo)
|
||||||
|
.like(ShopDealerCapital::getComments, "佣金解冻(capitalId=")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (unfrozenMarkers < totalCommissions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean updated = shopDealerOrderService.update(
|
||||||
|
new LambdaUpdateWrapper<ShopDealerOrder>()
|
||||||
|
.eq(ShopDealerOrder::getTenantId, TENANT_ID)
|
||||||
|
.eq(ShopDealerOrder::getOrderNo, orderNo)
|
||||||
|
.set(ShopDealerOrder::getIsUnfreeze, 1)
|
||||||
|
.set(ShopDealerOrder::getUnfreezeTime, now)
|
||||||
|
.set(ShopDealerOrder::getUpdateTime, now)
|
||||||
|
);
|
||||||
|
if (!updated) {
|
||||||
|
log.warn("已完成佣金解冻,但更新分销订单isUnfreeze失败/无记录 - tenantId={}, orderNo={}", TENANT_ID, orderNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String buildUnfreezeMarkerComment(Integer capitalId) {
|
private String buildUnfreezeMarkerComment(Integer capitalId) {
|
||||||
return "佣金解冻(capitalId=" + capitalId + ")";
|
return "佣金解冻(capitalId=" + capitalId + ")";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,9 +120,15 @@ public class ShopDealerOrder implements Serializable {
|
|||||||
@Schema(description = "佣金结算(0未结算 1已结算)")
|
@Schema(description = "佣金结算(0未结算 1已结算)")
|
||||||
private Integer isSettled;
|
private Integer isSettled;
|
||||||
|
|
||||||
|
@Schema(description = "佣金冻结(1解冻中 0已解冻)")
|
||||||
|
private Integer isUnfreeze;
|
||||||
|
|
||||||
@Schema(description = "结算时间")
|
@Schema(description = "结算时间")
|
||||||
private LocalDateTime settleTime;
|
private LocalDateTime settleTime;
|
||||||
|
|
||||||
|
@Schema(description = "解冻时间")
|
||||||
|
private LocalDateTime unfreezeTime;
|
||||||
|
|
||||||
@Schema(description = "备注")
|
@Schema(description = "备注")
|
||||||
private String comments;
|
private String comments;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user