作者 陈志颖

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

@@ -200,6 +200,8 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -200,6 +200,8 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
200 Department: undertakerDomain.Department, 200 Department: undertakerDomain.Department,
201 Roles: undertakerDomain.Roles, 201 Roles: undertakerDomain.Roles,
202 UserInfo: undertakerDomain.UserInfo, 202 UserInfo: undertakerDomain.UserInfo,
  203 + UserName: undertakerDomain.UserName,
  204 + UserPhone: undertakerDomain.UserPhone,
203 UserType: undertakerDomain.UserType, 205 UserType: undertakerDomain.UserType,
204 Referrer: referrerDomain, 206 Referrer: referrerDomain,
205 Salesman: salesmanDomain, 207 Salesman: salesmanDomain,
@@ -76,7 +76,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -76,7 +76,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
76 if dividendsIncentivesRuleMatched != nil { 76 if dividendsIncentivesRuleMatched != nil {
77 for _, undertaker := range cooperationContract.Undertakers { 77 for _, undertaker := range cooperationContract.Undertakers {
78 // 添加承接人分红预算信息详情 78 // 添加承接人分红预算信息详情
79 - undertakerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage 79 + // TODO 使用decimal提高精度
  80 + undertakerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage / 100
80 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 81 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
81 DividendsUser: &domain.User{ 82 DividendsUser: &domain.User{
82 UserId: undertaker.UserId, 83 UserId: undertaker.UserId,
@@ -98,7 +99,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -98,7 +99,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
98 }) 99 })
99 // 添加推荐人分红预算信息详情 100 // 添加推荐人分红预算信息详情
100 if undertaker.Referrer != nil { 101 if undertaker.Referrer != nil {
101 - referrerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.ReferrerPercentage 102 + referrerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.ReferrerPercentage / 100
102 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 103 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
103 DividendsUser: &domain.User{ 104 DividendsUser: &domain.User{
104 UserId: undertaker.Referrer.UserId, 105 UserId: undertaker.Referrer.UserId,
@@ -120,7 +121,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -120,7 +121,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
120 } 121 }
121 // 添加关联业务员分红预算信息详情 122 // 添加关联业务员分红预算信息详情
122 if undertaker.Salesman != nil { 123 if undertaker.Salesman != nil {
123 - salesmanDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.SalesmanPercentage 124 + salesmanDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.SalesmanPercentage / 100
124 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 125 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
125 DividendsUser: &domain.User{ 126 DividendsUser: &domain.User{
126 UserId: undertaker.Salesman.UserId, 127 UserId: undertaker.Salesman.UserId,
@@ -163,7 +164,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -163,7 +164,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
163 // 计算分红 164 // 计算分红
164 for _, undertaker := range cooperationContract.Undertakers { 165 for _, undertaker := range cooperationContract.Undertakers {
165 // 添加承接人分红退货预算信息详情 166 // 添加承接人分红退货预算信息详情
166 - undertakerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage 167 + undertakerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage / 100
167 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 168 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
168 DividendsUser: &domain.User{ 169 DividendsUser: &domain.User{
169 UserId: undertaker.UserId, 170 UserId: undertaker.UserId,
@@ -185,7 +186,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -185,7 +186,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
185 }) 186 })
186 // 添加推荐人分红退货预算信息详情 187 // 添加推荐人分红退货预算信息详情
187 if undertaker.Referrer != nil { 188 if undertaker.Referrer != nil {
188 - referrerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.ReferrerPercentage 189 + referrerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.ReferrerPercentage / 100
189 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 190 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
190 DividendsUser: &domain.User{ 191 DividendsUser: &domain.User{
191 UserId: undertaker.Referrer.UserId, 192 UserId: undertaker.Referrer.UserId,
@@ -207,7 +208,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -207,7 +208,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
207 } 208 }
208 // 添加关联业务员分红退货预算信息详情 209 // 添加关联业务员分红退货预算信息详情
209 if undertaker.Salesman != nil { 210 if undertaker.Salesman != nil {
210 - salesmanDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.SalesmanPercentage 211 + salesmanDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.SalesmanPercentage / 100
211 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 212 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
212 DividendsUser: &domain.User{ 213 DividendsUser: &domain.User{
213 UserId: undertaker.Salesman.UserId, 214 UserId: undertaker.Salesman.UserId,
@@ -139,6 +139,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -139,6 +139,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
139 if referrerEstimated { 139 if referrerEstimated {
140 return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红") 140 return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
141 } else { 141 } else {
  142 + // TODO 使用decimal提高精度
142 undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.ReferrerPercentage / 100) 143 undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.ReferrerPercentage / 100)
143 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 144 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
144 DividendsUser: &domain.User{ 145 DividendsUser: &domain.User{