作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !63
... ... @@ -640,6 +640,26 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
dividendsReturnedOrderRepository = value
}
// 共创合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationProjectRepository = value
}
// 初始化确认业绩激励分红预算领域服务
var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService
if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{
... ... @@ -653,6 +673,46 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
})
}
// 查询共创合约
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
"orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, err
} else {
if count > 0 {
for _, cooperationContractFound := range cooperationContractsFound {
cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
}
}
}
log.Logger.Info("查询共创合约", map[string]interface{}{
"cooperationContractsMap": cooperationContractsMap,
})
// 查询共创项目
cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
"orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, err
} else {
if count > 0 {
for _, cooperationProjectFound := range cooperationProjectsFound {
cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound
}
}
}
log.Logger.Info("查询共创项目", map[string]interface{}{
"cooperationProjectsMap": cooperationProjectsMap,
})
// 统计成功预算的分红订单
estimateSuccessfullyDividendsOrders := make(map[string]string)
... ... @@ -684,7 +744,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// 分红订单产品预算
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil {
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap, cooperationProjectsMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
... ... @@ -740,7 +800,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// 分红退货单产品预算
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil {
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap, cooperationProjectsMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
... ...
... ... @@ -907,6 +907,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
DividendsReturnedOrderNumber: "",
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodExpense: orderGood.OrderGoodExpense,
OrderGoodDividendsStatus: int32(1),
OrgId: importDividendsOrderCommand.OrgId,
CompanyId: importDividendsOrderCommand.CompanyId,
CreatedAt: time.Now(),
... ...
... ... @@ -43,5 +43,5 @@ func (DividendsEstimateDetail *DividendsEstimateDetail) GenerateSpecificDividend
type ConfirmDividendsIncentivesEstimateService interface {
coreDomain.DomainEventPublisher
Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64) ([]*DividendsEstimateDetail, error)
Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64, cooperationContractsMap map[string]*domain.CooperationContract, cooperationProjectsMap map[string]*domain.CooperationProject) ([]*DividendsEstimateDetail, error)
}
... ...
... ... @@ -20,7 +20,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储
//var cooperationContactRepository domain.CooperationContractRepository // 合约仓储
// 分红预算单仓储初始化
if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil {
... ... @@ -50,16 +49,10 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
orderGoodRepository = repo
}
// 共创合约仓储初始化
//if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {
// return nil, err
//} else {
// cooperationContactRepository = repo
//}
// 获取分红预算单
if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
"dividendsEstimateIds": dividendsEstimateIds,
"offsetLimit": false,
}); err != nil {
return nil, err
} else {
... ... @@ -154,6 +147,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"dividendsOrderNumbers": orderNums,
"offsetLimit": false,
}); err4 != nil {
return nil, err4
} else {
... ... @@ -193,6 +187,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
"orderGoodIds": orderGoodIds,
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -216,6 +211,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"dividendsReturnedOrderNumbers": returnedOrderNums,
"offsetLimit": false,
}); err5 != nil {
return nil, err5
} else {
... ... @@ -256,6 +252,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
"orderGoodIds": orderGoodIds,
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -8,7 +8,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
)
type ConfirmDividendsIncentivesEstimateService struct {
... ... @@ -17,26 +16,10 @@ type ConfirmDividendsIncentivesEstimateService struct {
}
// Confirm 确认业绩分红预算
func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64) ([]*service.DividendsEstimateDetail, error) {
var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储
var cooperationProjectRepository domain.CooperationProjectRepository // 共创项目仓储
func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64, cooperationContractsMap map[string]*domain.CooperationContract, cooperationProjectsMap map[string]*domain.CooperationProject) ([]*service.DividendsEstimateDetail, error) {
var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
// 共创合约仓储初始化
if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {
return nil, err
} else {
cooperationContractRepository = repo
}
// 共创项目仓储初始化
if repo, err := repository.NewCooperationProjectRepository(domainService.transactionContext); err != nil {
return nil, err
} else {
cooperationProjectRepository = repo
}
// 分红订单仓储初始化
if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil {
return nil, err
... ... @@ -51,29 +34,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
dividendsReturnedOrderRepository = repo
}
// 查询共创合约
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
"companyId": companyId,
"orgId": orgId,
"offsetLimit": false,
}); err != nil {
return nil, err
} else {
if count > 0 {
for _, cooperationContractFound := range cooperationContractsFound {
cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
}
}
}
// 确认业绩分红预算
var dividendsEstimateDetails []*service.DividendsEstimateDetail
for _, orderGood := range orderGoods {
log.Logger.Info("业绩分红预算产品", map[string]interface{}{
"orderGood": orderGood,
})
if orderGood.CooperationContractNumber == "" {
var orderNumber string
if orderGood.DividendsOrderNumber != "" {
... ... @@ -93,9 +56,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
continue
}
var cooperationContract *domain.CooperationContract
// 获取合约
var cooperationContract *domain.CooperationContract
if _, ok := cooperationContractsMap[orderGood.CooperationContractNumber]; !ok {
var orderNumber string
if orderGood.DividendsOrderNumber != "" {
... ... @@ -115,52 +77,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
continue
} else {
cooperationContract = cooperationContractsMap[orderGood.CooperationContractNumber]
}
//cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
// "cooperationContractNumber": orderGood.CooperationContractNumber,
// "companyId": orderGood.CompanyId,
// "orgId": orderGood.OrgId,
//})
//if err != nil {
// var orderNumber string
// if orderGood.DividendsOrderNumber != "" {
// orderNumber = orderGood.DividendsOrderNumber
// } else {
// orderNumber = orderGood.DividendsReturnedOrderNumber
// }
// dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
// DividendsUser: nil,
// DividendsParticipateType: 0,
// DividendsStage: 0,
// DividendsAmount: 0,
// OrderOrReturnedOrderNumber: orderNumber,
// IsSuccessfully: false,
// Reason: "共创合约错误",
// })
// continue
//}
if cooperationContract == nil {
var orderNumber string
if orderGood.DividendsOrderNumber != "" {
orderNumber = orderGood.DividendsOrderNumber
} else {
orderNumber = orderGood.DividendsReturnedOrderNumber
}
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderNumber,
IsSuccessfully: false,
Reason: "共创合约" + orderGood.CooperationContractNumber + "不存在",
})
continue
} else {
log.Logger.Info("产品相关的合约", map[string]interface{}{
"cooperationContract": cooperationContract,
})
if cooperationContract.Status == 2 {
var orderNumber string
if orderGood.DividendsOrderNumber != "" {
... ... @@ -181,49 +97,24 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
}
// 获取共创项目
if cooperationContract.CooperationProjectNumber != "" {
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
"cooperationProjectNumber": cooperationContract.CooperationProjectNumber,
"companyId": cooperationContract.Company.CompanyId,
"orgId": cooperationContract.Org.OrgId,
})
if err != nil {
var orderNumber string
if orderGood.DividendsOrderNumber != "" {
orderNumber = orderGood.DividendsOrderNumber
} else {
orderNumber = orderGood.DividendsReturnedOrderNumber
}
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderNumber,
IsSuccessfully: false,
Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "查询错误",
})
continue
}
if cooperationProject == nil {
var orderNumber string
if orderGood.DividendsOrderNumber != "" {
orderNumber = orderGood.DividendsOrderNumber
} else {
orderNumber = orderGood.DividendsReturnedOrderNumber
}
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderNumber,
IsSuccessfully: false,
Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "已结束或不存在",
})
continue
// 判断共创项目是否存在
if _, ok := cooperationProjectsMap[cooperationContract.CooperationProjectNumber]; !ok {
var orderNumber string
if orderGood.DividendsOrderNumber != "" {
orderNumber = orderGood.DividendsOrderNumber
} else {
orderNumber = orderGood.DividendsReturnedOrderNumber
}
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderNumber,
IsSuccessfully: false,
Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "已结束或不存在",
})
continue
}
if orderGood.DividendsOrderNumber != "" { // 获取分红订单
... ... @@ -408,95 +299,109 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
}
// 计算分红
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红退货预算信息详情
if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 {
undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.UserId,
UserBaseId: undertaker.UserBaseId,
Org: undertaker.Org,
Orgs: undertaker.Orgs,
Department: undertaker.Department,
Roles: undertaker.Roles,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
UserName: undertaker.UserInfo.UserName,
UserPhone: undertaker.UserPhone,
Status: undertaker.Status,
Company: undertaker.Company,
},
DividendsParticipateType: domain.UNDERTAKER,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: -undertakerDividendsAmount,
OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
})
}
// 添加推荐人分红退货预算信息详情
if undertaker.Referrer != nil {
if dividendsIncentivesRuleMatched.ReferrerPercentage > 0 {
referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
if len(cooperationContract.Undertakers) <= 0 {
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
IsSuccessfully: false,
Reason: "合约承接人不存在",
})
continue
} else {
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红退货预算信息详情
if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 {
undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
UserBaseId: undertaker.Referrer.UserBaseId,
Org: undertaker.Referrer.Org,
Orgs: undertaker.Referrer.Orgs,
Department: undertaker.Referrer.Department,
Roles: undertaker.Referrer.Roles,
UserInfo: undertaker.Referrer.UserInfo,
UserType: undertaker.Referrer.UserType,
UserName: undertaker.Referrer.UserName,
UserPhone: undertaker.Referrer.UserPhone,
Company: undertaker.Referrer.Company,
UserId: undertaker.UserId,
UserBaseId: undertaker.UserBaseId,
Org: undertaker.Org,
Orgs: undertaker.Orgs,
Department: undertaker.Department,
Roles: undertaker.Roles,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
UserName: undertaker.UserInfo.UserName,
UserPhone: undertaker.UserPhone,
Status: undertaker.Status,
Company: undertaker.Company,
},
DividendsParticipateType: domain.REFERRER,
DividendsParticipateType: domain.UNDERTAKER,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: -referrerDividendsAmount,
DividendsAmount: -undertakerDividendsAmount,
OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
})
}
}
// 添加关联业务员分红退货预算信息详情
if undertaker.Salesman != nil {
if dividendsIncentivesRuleMatched.SalesmanPercentage > 0 {
salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
UserBaseId: undertaker.Salesman.UserBaseId,
Org: undertaker.Salesman.Org,
Orgs: undertaker.Salesman.Orgs,
Department: undertaker.Salesman.Department,
Roles: undertaker.Salesman.Roles,
UserInfo: undertaker.Salesman.UserInfo,
UserType: undertaker.Salesman.UserType,
UserName: undertaker.Salesman.UserInfo.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
DividendsParticipateType: domain.SALESMAN,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: -salesmanDividendsAmount,
OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
})
// 添加推荐人分红退货预算信息详情
if undertaker.Referrer != nil {
if dividendsIncentivesRuleMatched.ReferrerPercentage > 0 {
referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
UserBaseId: undertaker.Referrer.UserBaseId,
Org: undertaker.Referrer.Org,
Orgs: undertaker.Referrer.Orgs,
Department: undertaker.Referrer.Department,
Roles: undertaker.Referrer.Roles,
UserInfo: undertaker.Referrer.UserInfo,
UserType: undertaker.Referrer.UserType,
UserName: undertaker.Referrer.UserName,
UserPhone: undertaker.Referrer.UserPhone,
Company: undertaker.Referrer.Company,
},
DividendsParticipateType: domain.REFERRER,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: -referrerDividendsAmount,
OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
})
}
}
// 添加关联业务员分红退货预算信息详情
if undertaker.Salesman != nil {
if dividendsIncentivesRuleMatched.SalesmanPercentage > 0 {
salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
UserBaseId: undertaker.Salesman.UserBaseId,
Org: undertaker.Salesman.Org,
Orgs: undertaker.Salesman.Orgs,
Department: undertaker.Salesman.Department,
Roles: undertaker.Salesman.Roles,
UserInfo: undertaker.Salesman.UserInfo,
UserType: undertaker.Salesman.UserType,
UserName: undertaker.Salesman.UserInfo.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
DividendsParticipateType: domain.SALESMAN,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: -salesmanDividendsAmount,
OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
})
}
}
}
}
}
}
return dividendsEstimateDetails, nil
}
... ...