作者 陈志颖

feat:调整确定金额激励领域服务

@@ -96,23 +96,22 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -96,23 +96,22 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
96 return nil, err 96 return nil, err
97 } 97 }
98 if salesmanEstimated { 98 if salesmanEstimated {
99 - return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红") 99 + return nil, fmt.Errorf("业务员 " + undertaker.Salesman.UserName + " 已分红")
100 } else { 100 } else {
101 - undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (1 - (moneyIncentivesRuleMatched.SalesmanPercentage+moneyIncentivesRuleMatched.ReferrerPercentage)/100) 101 + undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.SalesmanPercentage / 100)
102 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 102 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
103 DividendsUser: &domain.User{ 103 DividendsUser: &domain.User{
104 - UserId: undertaker.UserId,  
105 - UserBaseId: undertaker.UserBaseId,  
106 - Org: undertaker.Org,  
107 - Orgs: undertaker.Orgs,  
108 - Department: undertaker.Department,  
109 - Roles: undertaker.Roles,  
110 - UserInfo: undertaker.UserInfo,  
111 - UserType: undertaker.UserType,  
112 - UserName: undertaker.UserName,  
113 - UserPhone: undertaker.UserPhone,  
114 - Status: undertaker.Status,  
115 - Company: undertaker.Company, 104 + UserId: undertaker.Salesman.UserId,
  105 + UserBaseId: undertaker.Salesman.UserBaseId,
  106 + Org: undertaker.Salesman.Org,
  107 + Orgs: undertaker.Salesman.Orgs,
  108 + Department: undertaker.Salesman.Department,
  109 + Roles: undertaker.Salesman.Roles,
  110 + UserInfo: undertaker.Salesman.UserInfo,
  111 + UserType: undertaker.Salesman.UserType,
  112 + UserName: undertaker.Salesman.UserName,
  113 + UserPhone: undertaker.Salesman.UserPhone,
  114 + Company: undertaker.Salesman.Company,
116 }, 115 },
117 DividendsParticipateType: domain.MONEY_INCENTIVES, 116 DividendsParticipateType: domain.MONEY_INCENTIVES,
118 DividendsStage: stage, 117 DividendsStage: stage,
@@ -120,6 +119,37 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -120,6 +119,37 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
120 }) 119 })
121 } 120 }
122 // 判断关联业务员在当前阶段是否已经分红 121 // 判断关联业务员在当前阶段是否已经分红
  122 + referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
  123 + "undertakerUid": undertaker.Referrer.UserId,
  124 + "companyId": contract.Company.CompanyId,
  125 + "orgId": contract.Org.OrgId,
  126 + })
  127 + if err != nil {
  128 + return nil, err
  129 + }
  130 + if referrerEstimated {
  131 + return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
  132 + } else {
  133 + undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.ReferrerPercentage / 100)
  134 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  135 + DividendsUser: &domain.User{
  136 + UserId: undertaker.Referrer.UserId,
  137 + UserBaseId: undertaker.Referrer.UserBaseId,
  138 + Org: undertaker.Referrer.Org,
  139 + Orgs: undertaker.Referrer.Orgs,
  140 + Department: undertaker.Referrer.Department,
  141 + Roles: undertaker.Referrer.Roles,
  142 + UserInfo: undertaker.Referrer.UserInfo,
  143 + UserType: undertaker.Referrer.UserType,
  144 + UserName: undertaker.Referrer.UserName,
  145 + UserPhone: undertaker.Referrer.UserPhone,
  146 + Company: undertaker.Referrer.Company,
  147 + },
  148 + DividendsParticipateType: domain.MONEY_INCENTIVES,
  149 + DividendsStage: stage,
  150 + DividendsAmount: undertakerDividendsAmount,
  151 + })
  152 + }
123 } 153 }
124 return dividendsEstimateDetails, nil 154 return dividendsEstimateDetails, nil
125 } 155 }