作者 陈志颖

Merge branch 'dev-chenzhiying' into dev

@@ -281,8 +281,15 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -281,8 +281,15 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
281 cooperationApplicationRepository = value 281 cooperationApplicationRepository = value
282 } 282 }
283 283
  284 + var getCooperationProjectQuerySpecific *query.GetCooperationProjectQuery
  285 + if getCooperationProjectQuery.CooperationProjectId != 0 { // 根据ID查询
  286 + getCooperationProjectQuerySpecific.CooperationProjectId = getCooperationProjectQuery.CooperationProjectId
  287 + } else if getCooperationProjectQuery.CooperationProjectNumber != "" { // 根据编号查询
  288 + getCooperationProjectQuerySpecific = getCooperationProjectQuery
  289 + }
  290 +
284 // 获取共创项目 291 // 获取共创项目
285 - cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuery)) 292 + cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuerySpecific))
286 if err != nil { 293 if err != nil {
287 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 294 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
288 } 295 }
@@ -306,8 +313,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -306,8 +313,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
306 gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ 313 gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
307 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, 314 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
308 "user": true, 315 "user": true,
309 - "companyId": getCooperationProjectQuery.CompanyId,  
310 - "orgId": getCooperationProjectQuery.OrgId, 316 + "companyId": cooperationProject.Company.CompanyId,
  317 + "orgId": cooperationProject.Org.OrgId,
311 }) 318 })
312 if err != nil { 319 if err != nil {
313 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 320 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -320,8 +327,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -320,8 +327,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
320 gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ 327 gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
321 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, 328 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
322 "partner": true, 329 "partner": true,
323 - "companyId": getCooperationProjectQuery.CompanyId,  
324 - "orgId": getCooperationProjectQuery.OrgId, 330 + "companyId": cooperationProject.Company.CompanyId,
  331 + "orgId": cooperationProject.Org.OrgId,
325 }) 332 })
326 if err != nil { 333 if err != nil {
327 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 334 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -337,6 +344,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -337,6 +344,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
337 344
338 // 返回所有员工类型的申请通过人 345 // 返回所有员工类型的申请通过人
339 applicants := make([]*domain.User, 0) 346 applicants := make([]*domain.User, 0)
  347 +
340 // 获取当前项目的所有申请 348 // 获取当前项目的所有申请
341 if countApplication, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{ 349 if countApplication, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
342 "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber, 350 "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber,
@@ -157,6 +157,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred @@ -157,6 +157,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
157 OrderGoodAmount: dividendsEstimate.OrderGoodAmount, 157 OrderGoodAmount: dividendsEstimate.OrderGoodAmount,
158 CooperationContractNumber: dividendsEstimate.CooperationContractNumber, 158 CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
159 }) 159 })
  160 +
160 settlementAmount = settlementAmount + dividendsEstimate.DividendsAmount 161 settlementAmount = settlementAmount + dividendsEstimate.DividendsAmount
161 162
162 goodAmountCount = goodAmountCount + dividendsEstimate.OrderGoodAmount 163 goodAmountCount = goodAmountCount + dividendsEstimate.OrderGoodAmount
@@ -9,7 +9,7 @@ import ( @@ -9,7 +9,7 @@ import (
9 9
10 type DividendsEstimateDetail struct { 10 type DividendsEstimateDetail struct {
11 DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户) 11 DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户)
12 - DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 12 + DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 1承接人,2推荐人,3关联业务员
13 DividendsStage int32 `json:"dividendsStage"` // 分红阶段 13 DividendsStage int32 `json:"dividendsStage"` // 分红阶段
14 DividendsAmount float64 `json:"dividendsAmount"` // 分红金额 14 DividendsAmount float64 `json:"dividendsAmount"` // 分红金额
15 OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号 15 OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号
@@ -61,7 +61,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -61,7 +61,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
61 return nil, err 61 return nil, err
62 } 62 }
63 if undertakerEstimated { 63 if undertakerEstimated {
64 - return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红") 64 + return nil, fmt.Errorf("承接人 " + undertaker.UserName + " 已分红")
65 } else { 65 } else {
66 undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64() 66 undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64()
67 //Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage)).Div(decimal.NewFromFloat(100)))).Float64() 67 //Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage)).Div(decimal.NewFromFloat(100)))).Float64()
@@ -80,7 +80,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -80,7 +80,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
80 Status: undertaker.Status, 80 Status: undertaker.Status,
81 Company: undertaker.Company, 81 Company: undertaker.Company,
82 }, 82 },
83 - DividendsParticipateType: domain.MONEY_INCENTIVES, 83 + DividendsParticipateType: 1,
84 DividendsStage: stage, 84 DividendsStage: stage,
85 DividendsAmount: undertakerDividendsAmount, 85 DividendsAmount: undertakerDividendsAmount,
86 }) 86 })
@@ -114,7 +114,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -114,7 +114,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
114 UserPhone: undertaker.Salesman.UserPhone, 114 UserPhone: undertaker.Salesman.UserPhone,
115 Company: undertaker.Salesman.Company, 115 Company: undertaker.Salesman.Company,
116 }, 116 },
117 - DividendsParticipateType: domain.MONEY_INCENTIVES, 117 + DividendsParticipateType: 3,
118 DividendsStage: stage, 118 DividendsStage: stage,
119 DividendsAmount: undertakerDividendsAmount, 119 DividendsAmount: undertakerDividendsAmount,
120 }) 120 })
@@ -122,7 +122,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -122,7 +122,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
122 122
123 } 123 }
124 124
125 - // 判断关联业务员在当前阶段是否已经分红 125 + // 判断推荐人在当前阶段是否已经分红
126 if undertaker.Referrer != nil { 126 if undertaker.Referrer != nil {
127 referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ 127 referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
128 "undertakerUid": undertaker.Referrer.UserId, 128 "undertakerUid": undertaker.Referrer.UserId,
@@ -133,7 +133,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -133,7 +133,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
133 return nil, err 133 return nil, err
134 } 134 }
135 if referrerEstimated { 135 if referrerEstimated {
136 - return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红") 136 + return nil, fmt.Errorf("推荐人 " + undertaker.Referrer.UserName + " 已分红")
137 } else { 137 } else {
138 undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64() 138 undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
139 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 139 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
@@ -150,7 +150,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -150,7 +150,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
150 UserPhone: undertaker.Referrer.UserPhone, 150 UserPhone: undertaker.Referrer.UserPhone,
151 Company: undertaker.Referrer.Company, 151 Company: undertaker.Referrer.Company,
152 }, 152 },
153 - DividendsParticipateType: domain.MONEY_INCENTIVES, 153 + DividendsParticipateType: 2,
154 DividendsStage: stage, 154 DividendsStage: stage,
155 DividendsAmount: undertakerDividendsAmount, 155 DividendsAmount: undertakerDividendsAmount,
156 }) 156 })