作者 陈志颖

feat:分红预算领域服务调整

... ... @@ -372,6 +372,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
_ = transactionContext.RollbackTransaction()
}()
orderGoodIds, _ := utils.SliceAtoi(confirmDividendsIncentivesEstimateCommand.OrderGoodIds)
// 用户REST服务初始化
//var userService service.UserService
//if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
... ... @@ -476,7 +478,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
// 获取订单产品
if _, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(confirmDividendsIncentivesEstimateCommand)); err != nil {
if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
"orderGoodIds": orderGoodIds,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var dividendsEstimates []*domain.DividendsEstimate
... ...
... ... @@ -68,71 +68,73 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
}
// 计算分红
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红预算信息详情
undertakerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage
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.UserName,
UserPhone: undertaker.UserPhone,
Status: undertaker.Status,
Company: undertaker.Company,
},
DividendsParticipateType: domain.UNDERTAKER,
DividendsStage: int32(dividendsIncentivesRuleMatched.DividendsIncentivesStage),
DividendsAmount: undertakerDividendsAmount,
})
// 添加推荐人分红预算信息详情
if undertaker.Referrer != nil {
referrerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.ReferrerPercentage
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: int32(dividendsIncentivesRuleMatched.DividendsIncentivesStage),
DividendsAmount: referrerDividendsAmount,
})
}
// 添加关联业务员分红预算信息详情
if undertaker.Salesman != nil {
salesmanDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.SalesmanPercentage
if dividendsIncentivesRuleMatched != nil {
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红预算信息详情
undertakerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage
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.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.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.UserName,
UserPhone: undertaker.UserPhone,
Status: undertaker.Status,
Company: undertaker.Company,
},
DividendsParticipateType: domain.SALESMAN,
DividendsParticipateType: domain.UNDERTAKER,
DividendsStage: int32(dividendsIncentivesRuleMatched.DividendsIncentivesStage),
DividendsAmount: salesmanDividendsAmount,
DividendsAmount: undertakerDividendsAmount,
})
// 添加推荐人分红预算信息详情
if undertaker.Referrer != nil {
referrerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.ReferrerPercentage
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: int32(dividendsIncentivesRuleMatched.DividendsIncentivesStage),
DividendsAmount: referrerDividendsAmount,
})
}
// 添加关联业务员分红预算信息详情
if undertaker.Salesman != nil {
salesmanDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.SalesmanPercentage
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.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
DividendsParticipateType: domain.SALESMAN,
DividendsStage: int32(dividendsIncentivesRuleMatched.DividendsIncentivesStage),
DividendsAmount: salesmanDividendsAmount,
})
}
}
}
} else if orderGood.DividendsReturnedOrderNumber != "" { // 获取分红退货单
... ...