fix agentService

This commit is contained in:
liangzai 2025-06-09 18:37:39 +08:00
parent c6a79e300c
commit 524c94de7c

View File

@ -290,26 +290,29 @@ func (l *AgentService) CommissionCost(ctx context.Context, descendantId int64, A
if agentMembershipConfigModel.PriceIncreaseAmount.Valid { if agentMembershipConfigModel.PriceIncreaseAmount.Valid {
// 拥有则查看该上级设定的成本 // 拥有则查看该上级设定的成本
agentMembershipUserConfigModel, findAgentMembershipUserConfigModelErr := l.AgentMembershipUserConfigModel.FindOneByAgentIdProductId(ctx, AncestorId, productID) agentMembershipUserConfigModel, findAgentMembershipUserConfigModelErr := l.AgentMembershipUserConfigModel.FindOneByAgentIdProductId(ctx, AncestorId, productID)
if findAgentMembershipUserConfigModelErr != nil { if findAgentMembershipUserConfigModelErr != nil && !errors.Is(findAgentMembershipUserConfigModelErr, model.ErrNotFound) {
return 0, findAgentMembershipUserConfigModelErr return 0, findAgentMembershipUserConfigModelErr
} }
if agentMembershipUserConfigModel != nil {
deductCostAmount := agentMembershipUserConfigModel.PriceIncreaseAmount
deductCostAmount := agentMembershipUserConfigModel.PriceIncreaseAmount agentCommissionDeductionModel := model.AgentCommissionDeduction{
AgentId: AncestorId,
DeductedAgentId: descendantId,
Amount: deductCostAmount,
Type: model.AgentDeductionTypeCost,
ProductId: productID,
}
agentCommissionDeductionModel := model.AgentCommissionDeduction{ _, insertAgentCommissionDeductionModelErr := l.AgentCommissionDeductionModel.Insert(ctx, session, &agentCommissionDeductionModel)
AgentId: AncestorId, if insertAgentCommissionDeductionModelErr != nil {
DeductedAgentId: descendantId, return 0, insertAgentCommissionDeductionModelErr
Amount: deductCostAmount, }
Type: model.AgentDeductionTypeCost,
ProductId: productID, return deductCostAmount, nil
} else {
return 0, nil
} }
_, insertAgentCommissionDeductionModelErr := l.AgentCommissionDeductionModel.Insert(ctx, session, &agentCommissionDeductionModel)
if insertAgentCommissionDeductionModelErr != nil {
return 0, insertAgentCommissionDeductionModelErr
}
return deductCostAmount, nil
} }
return 0, nil return 0, nil
} }