作者 陈志颖

fix:合约承接人信息和分红预算

... ... @@ -200,6 +200,8 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
Department: undertakerDomain.Department,
Roles: undertakerDomain.Roles,
UserInfo: undertakerDomain.UserInfo,
UserName: undertakerDomain.UserName,
UserPhone: undertakerDomain.UserPhone,
UserType: undertakerDomain.UserType,
Referrer: referrerDomain,
Salesman: salesmanDomain,
... ...
... ... @@ -76,7 +76,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
if dividendsIncentivesRuleMatched != nil {
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红预算信息详情
undertakerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage
// TODO 使用decimal提高精度
undertakerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage / 100
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.UserId,
... ... @@ -98,7 +99,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
})
// 添加推荐人分红预算信息详情
if undertaker.Referrer != nil {
referrerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.ReferrerPercentage
referrerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.ReferrerPercentage / 100
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
... ... @@ -120,7 +121,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
// 添加关联业务员分红预算信息详情
if undertaker.Salesman != nil {
salesmanDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.SalesmanPercentage
salesmanDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.SalesmanPercentage / 100
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
... ... @@ -163,7 +164,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
// 计算分红
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红退货预算信息详情
undertakerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage
undertakerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage / 100
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.UserId,
... ... @@ -185,7 +186,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
})
// 添加推荐人分红退货预算信息详情
if undertaker.Referrer != nil {
referrerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.ReferrerPercentage
referrerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.ReferrerPercentage / 100
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
... ... @@ -207,7 +208,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
// 添加关联业务员分红退货预算信息详情
if undertaker.Salesman != nil {
salesmanDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.SalesmanPercentage
salesmanDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.SalesmanPercentage / 100
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
... ...
... ... @@ -139,6 +139,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
if referrerEstimated {
return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
} else {
// TODO 使用decimal提高精度
undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.ReferrerPercentage / 100)
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
... ...