作者 陈志颖

fix:分红预算报告

@@ -353,6 +353,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco @@ -353,6 +353,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
353 if creditAccountSaved, err4 := creditAccountRepository.Save(creditAccount); err4 != nil { 353 if creditAccountSaved, err4 := creditAccountRepository.Save(creditAccount); err4 != nil {
354 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error()) 354 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
355 } else { 355 } else {
  356 + // TODO 更新分红预算单结算状态(已支付)
356 if err3 := transactionContext.CommitTransaction(); err3 != nil { 357 if err3 := transactionContext.CommitTransaction(); err3 != nil {
357 return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error()) 358 return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
358 } 359 }
@@ -609,8 +609,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -609,8 +609,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
609 }) 609 })
610 } 610 }
611 611
612 - // 统计分红订单  
613 - var countDividendsOrders int32 612 + // 统计成功预算的分红订单
  613 + var estimateSuccessfullyDividendsOrders map[string]int
  614 +
  615 + // 统计预算失败的分红订单
  616 + var estimateFailedDividendsOrders map[string]int
614 617
615 // 获取订单产品 618 // 获取订单产品
616 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{ 619 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
@@ -730,16 +733,17 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -730,16 +733,17 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
730 log.Logger.Info("新增的分红预算单", map[string]interface{}{ 733 log.Logger.Info("新增的分红预算单", map[string]interface{}{
731 "dividendsEstimates": dividendsEstimates, 734 "dividendsEstimates": dividendsEstimates,
732 }) 735 })
733 -  
734 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil { 736 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
735 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 737 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
736 } else { 738 } else {
737 if err := transactionContext.CommitTransaction(); err != nil { 739 if err := transactionContext.CommitTransaction(); err != nil {
738 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 740 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
739 } 741 }
740 - // TODO 分析成功和失败原因 742 + // 分析成功和失败原因
741 successfullyCount := len(dividendsEstimatesSaved) 743 successfullyCount := len(dividendsEstimatesSaved)
742 - return fmt.Sprintf("已完成%d笔单订单分红预算,生成%d笔单分红预算,%d笔订单分红预算失败,失败原因:%s", countDividendsOrders, successfullyCount, 0, ""), nil 744 + return map[string]interface{}{
  745 + "report": fmt.Sprintf("已完成%d笔单订单分红预算,生成%d笔单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), ""),
  746 + }, nil
743 } 747 }
744 } 748 }
745 } 749 }
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
6 coreDomain "github.com/linmadan/egglib-go/core/domain" 6 coreDomain "github.com/linmadan/egglib-go/core/domain"
7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  8 + "github.com/shopspring/decimal"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
@@ -18,37 +19,62 @@ type ConfirmDividendsIncentivesEstimateService struct { @@ -18,37 +19,62 @@ type ConfirmDividendsIncentivesEstimateService struct {
18 // Confirm 确认业绩分红预算 19 // Confirm 确认业绩分红预算
19 func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood) ([]*service.DividendsEstimateDetail, error) { 20 func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood) ([]*service.DividendsEstimateDetail, error) {
20 var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储 21 var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储
  22 + var cooperationProjectRepository domain.CooperationProjectRepository // 共创项目仓储
21 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 23 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
22 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 24 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
  25 +
23 // 共创合约仓储初始化 26 // 共创合约仓储初始化
24 if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil { 27 if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {
25 return nil, err 28 return nil, err
26 } else { 29 } else {
27 cooperationContractRepository = repo 30 cooperationContractRepository = repo
28 } 31 }
  32 +
  33 + // 共创项目仓储初始化
  34 + if repo, err := repository.NewCooperationProjectRepository(domainService.transactionContext); err != nil {
  35 + return nil, err
  36 + } else {
  37 + cooperationProjectRepository = repo
  38 + }
  39 +
29 // 分红订单仓储初始化 40 // 分红订单仓储初始化
30 if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil { 41 if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil {
31 return nil, err 42 return nil, err
32 } else { 43 } else {
33 dividendsOrderRepository = repo 44 dividendsOrderRepository = repo
34 } 45 }
  46 +
35 // 分红退货单仓储初始化 47 // 分红退货单仓储初始化
36 if repo, err := repository.NewDividendsReturnedOrderRepository(domainService.transactionContext); err != nil { 48 if repo, err := repository.NewDividendsReturnedOrderRepository(domainService.transactionContext); err != nil {
37 return nil, err 49 return nil, err
38 } else { 50 } else {
39 dividendsReturnedOrderRepository = repo 51 dividendsReturnedOrderRepository = repo
40 } 52 }
  53 +
41 // 确认业绩分红预算 54 // 确认业绩分红预算
42 var dividendsEstimateDetails []*service.DividendsEstimateDetail 55 var dividendsEstimateDetails []*service.DividendsEstimateDetail
43 for _, orderGood := range orderGoods { 56 for _, orderGood := range orderGoods {
44 // 获取合约 57 // 获取合约
45 - cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractNumber": orderGood.CooperationContractNumber}) 58 + cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
  59 + "cooperationContractNumber": orderGood.CooperationContractNumber,
  60 + })
46 if err != nil { 61 if err != nil {
47 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 62 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
48 } 63 }
49 if cooperationContract == nil { 64 if cooperationContract == nil {
50 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创合约%s不存在", orderGood.CooperationContractNumber)) 65 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创合约%s不存在", orderGood.CooperationContractNumber))
51 } 66 }
  67 + // TODO 校验合约关联的项目是否已结束
  68 + cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
  69 + "cooperationProjectNumber": cooperationContract.CooperationProjectNumber,
  70 + })
  71 + if err != nil {
  72 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  73 + }
  74 + if cooperationProject == nil {
  75 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", cooperationContract.CooperationProjectNumber))
  76 + }
  77 +
52 if orderGood.DividendsOrderNumber != "" { 78 if orderGood.DividendsOrderNumber != "" {
53 // 获取分红订单 79 // 获取分红订单
54 dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{ 80 dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{
@@ -78,8 +104,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -78,8 +104,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
78 if dividendsIncentivesRuleMatched != nil { 104 if dividendsIncentivesRuleMatched != nil {
79 for _, undertaker := range cooperationContract.Undertakers { 105 for _, undertaker := range cooperationContract.Undertakers {
80 // 添加承接人分红预算信息详情 106 // 添加承接人分红预算信息详情
81 - // TODO 使用decimal提高精度  
82 - undertakerDividendsAmount := orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage / 100 107 + undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
83 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 108 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
84 DividendsUser: &domain.User{ 109 DividendsUser: &domain.User{
85 UserId: undertaker.UserId, 110 UserId: undertaker.UserId,
@@ -101,7 +126,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -101,7 +126,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
101 }) 126 })
102 // 添加推荐人分红预算信息详情 127 // 添加推荐人分红预算信息详情
103 if undertaker.Referrer != nil { 128 if undertaker.Referrer != nil {
104 - referrerDividendsAmount := orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.ReferrerPercentage / 100 129 + referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
105 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 130 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
106 DividendsUser: &domain.User{ 131 DividendsUser: &domain.User{
107 UserId: undertaker.Referrer.UserId, 132 UserId: undertaker.Referrer.UserId,
@@ -123,7 +148,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -123,7 +148,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
123 } 148 }
124 // 添加关联业务员分红预算信息详情 149 // 添加关联业务员分红预算信息详情
125 if undertaker.Salesman != nil { 150 if undertaker.Salesman != nil {
126 - salesmanDividendsAmount := orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.SalesmanPercentage / 100 151 + salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
127 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 152 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
128 DividendsUser: &domain.User{ 153 DividendsUser: &domain.User{
129 UserId: undertaker.Salesman.UserId, 154 UserId: undertaker.Salesman.UserId,
@@ -166,7 +191,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -166,7 +191,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
166 // 计算分红 191 // 计算分红
167 for _, undertaker := range cooperationContract.Undertakers { 192 for _, undertaker := range cooperationContract.Undertakers {
168 // 添加承接人分红退货预算信息详情 193 // 添加承接人分红退货预算信息详情
169 - undertakerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage / 100 194 + undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
170 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 195 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
171 DividendsUser: &domain.User{ 196 DividendsUser: &domain.User{
172 UserId: undertaker.UserId, 197 UserId: undertaker.UserId,
@@ -184,11 +209,11 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -184,11 +209,11 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
184 }, 209 },
185 DividendsParticipateType: domain.UNDERTAKER, 210 DividendsParticipateType: domain.UNDERTAKER,
186 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, 211 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
187 - DividendsAmount: undertakerDividendsAmount, 212 + DividendsAmount: -undertakerDividendsAmount,
188 }) 213 })
189 // 添加推荐人分红退货预算信息详情 214 // 添加推荐人分红退货预算信息详情
190 if undertaker.Referrer != nil { 215 if undertaker.Referrer != nil {
191 - referrerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.ReferrerPercentage / 100 216 + referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
192 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 217 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
193 DividendsUser: &domain.User{ 218 DividendsUser: &domain.User{
194 UserId: undertaker.Referrer.UserId, 219 UserId: undertaker.Referrer.UserId,
@@ -205,12 +230,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -205,12 +230,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
205 }, 230 },
206 DividendsParticipateType: domain.REFERRER, 231 DividendsParticipateType: domain.REFERRER,
207 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, 232 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
208 - DividendsAmount: referrerDividendsAmount, 233 + DividendsAmount: -referrerDividendsAmount,
209 }) 234 })
210 } 235 }
211 // 添加关联业务员分红退货预算信息详情 236 // 添加关联业务员分红退货预算信息详情
212 if undertaker.Salesman != nil { 237 if undertaker.Salesman != nil {
213 - salesmanDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.SalesmanPercentage / 100 238 + salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
214 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 239 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
215 DividendsUser: &domain.User{ 240 DividendsUser: &domain.User{
216 UserId: undertaker.Salesman.UserId, 241 UserId: undertaker.Salesman.UserId,
@@ -227,7 +252,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -227,7 +252,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
227 }, 252 },
228 DividendsParticipateType: domain.SALESMAN, 253 DividendsParticipateType: domain.SALESMAN,
229 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, 254 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
230 - DividendsAmount: salesmanDividendsAmount, 255 + DividendsAmount: -salesmanDividendsAmount,
231 }) 256 })
232 } 257 }
233 } 258 }
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "fmt" 4 "fmt"
5 coreDomain "github.com/linmadan/egglib-go/core/domain" 5 coreDomain "github.com/linmadan/egglib-go/core/domain"
6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  7 + "github.com/shopspring/decimal"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
@@ -68,7 +69,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -68,7 +69,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
68 if undertakerEstimated { 69 if undertakerEstimated {
69 return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红") 70 return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红")
70 } else { 71 } else {
71 - undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (1 - (moneyIncentivesRuleMatched.SalesmanPercentage+moneyIncentivesRuleMatched.ReferrerPercentage)/100) 72 + undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage))).Div(decimal.NewFromFloat(100))).Float64()
72 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 73 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
73 DividendsUser: &domain.User{ 74 DividendsUser: &domain.User{
74 UserId: undertaker.UserId, 75 UserId: undertaker.UserId,
@@ -103,7 +104,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -103,7 +104,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
103 if salesmanEstimated { 104 if salesmanEstimated {
104 return nil, fmt.Errorf("业务员 " + undertaker.Salesman.UserName + " 已分红") 105 return nil, fmt.Errorf("业务员 " + undertaker.Salesman.UserName + " 已分红")
105 } else { 106 } else {
106 - undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.SalesmanPercentage / 100) 107 + undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
107 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 108 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
108 DividendsUser: &domain.User{ 109 DividendsUser: &domain.User{
109 UserId: undertaker.Salesman.UserId, 110 UserId: undertaker.Salesman.UserId,
@@ -139,8 +140,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -139,8 +140,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
139 if referrerEstimated { 140 if referrerEstimated {
140 return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红") 141 return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
141 } else { 142 } else {
142 - // TODO 使用decimal提高精度  
143 - undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.ReferrerPercentage / 100) 143 + undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
144 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 144 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
145 DividendsUser: &domain.User{ 145 DividendsUser: &domain.User{
146 UserId: undertaker.Referrer.UserId, 146 UserId: undertaker.Referrer.UserId,
@@ -211,6 +211,12 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] @@ -211,6 +211,12 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string]
211 if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" { 211 if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
212 query.Where("cooperation_project.cooperation_project_number = ?", cooperationProjectNumber) 212 query.Where("cooperation_project.cooperation_project_number = ?", cooperationProjectNumber)
213 } 213 }
  214 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  215 + query.Where("company->>'companyId' = '?'", companyId)
  216 + }
  217 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  218 + query.Where("org->>'orgId' = '?'", orgId)
  219 + }
214 if cooperationProjectId, ok := queryOptions["cooperationProjectId"]; ok && cooperationProjectId.(int64) != 0 { 220 if cooperationProjectId, ok := queryOptions["cooperationProjectId"]; ok && cooperationProjectId.(int64) != 0 {
215 query.Where("cooperation_project.cooperation_project_id = ?", cooperationProjectId) 221 query.Where("cooperation_project.cooperation_project_id = ?", cooperationProjectId)
216 } 222 }
@@ -112,7 +112,7 @@ func (controller *CooperationContractController) SearchCooperationContract() { @@ -112,7 +112,7 @@ func (controller *CooperationContractController) SearchCooperationContract() {
112 _ = controller.Unmarshal(searchCooperationContractQuery) 112 _ = controller.Unmarshal(searchCooperationContractQuery)
113 header := controller.GetRequestHeader(controller.Ctx) 113 header := controller.GetRequestHeader(controller.Ctx)
114 searchCooperationContractQuery.CompanyId = header.CompanyId 114 searchCooperationContractQuery.CompanyId = header.CompanyId
115 - searchCooperationContractQuery.OrgId = header.OrgId 115 + //searchCooperationContractQuery.OrgId = header.OrgId
116 searchCooperationContractQuery.UserId = header.UserId 116 searchCooperationContractQuery.UserId = header.UserId
117 searchCooperationContractQuery.UserBaseId = header.UserBaseId 117 searchCooperationContractQuery.UserBaseId = header.UserBaseId
118 data, err := cooperationContractService.SearchCooperationContract(searchCooperationContractQuery) 118 data, err := cooperationContractService.SearchCooperationContract(searchCooperationContractQuery)