作者 陈志颖

fix:修复金额激励预算参与类型错误

... ... @@ -281,8 +281,15 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
cooperationApplicationRepository = value
}
var getCooperationProjectQuerySpecific *query.GetCooperationProjectQuery
if getCooperationProjectQuery.CooperationProjectId != 0 { // 根据ID查询
getCooperationProjectQuerySpecific.CooperationProjectId = getCooperationProjectQuery.CooperationProjectId
} else if getCooperationProjectQuery.CooperationProjectNumber != "" { // 根据编号查询
getCooperationProjectQuerySpecific = getCooperationProjectQuery
}
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuery))
cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuerySpecific))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -306,8 +313,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"user": true,
"companyId": getCooperationProjectQuery.CompanyId,
"orgId": getCooperationProjectQuery.OrgId,
"companyId": cooperationProject.Company.CompanyId,
"orgId": cooperationProject.Org.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -320,8 +327,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"partner": true,
"companyId": getCooperationProjectQuery.CompanyId,
"orgId": getCooperationProjectQuery.OrgId,
"companyId": cooperationProject.Company.CompanyId,
"orgId": cooperationProject.Org.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -337,6 +344,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
// 返回所有员工类型的申请通过人
applicants := make([]*domain.User, 0)
// 获取当前项目的所有申请
if countApplication, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
"cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber,
... ...
... ... @@ -157,6 +157,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
OrderGoodAmount: dividendsEstimate.OrderGoodAmount,
CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
})
settlementAmount = settlementAmount + dividendsEstimate.DividendsAmount
goodAmountCount = goodAmountCount + dividendsEstimate.OrderGoodAmount
... ...
... ... @@ -9,7 +9,7 @@ import (
type DividendsEstimateDetail struct {
DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户)
DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型
DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 1承接人,2推荐人,3关联业务员
DividendsStage int32 `json:"dividendsStage"` // 分红阶段
DividendsAmount float64 `json:"dividendsAmount"` // 分红金额
OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号
... ...
... ... @@ -61,7 +61,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
return nil, err
}
if undertakerEstimated {
return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红")
return nil, fmt.Errorf("承接人 " + undertaker.UserName + " 已分红")
} else {
undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64()
//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
Status: undertaker.Status,
Company: undertaker.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsParticipateType: 1,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
})
... ... @@ -114,7 +114,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsParticipateType: 3,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
})
... ... @@ -122,7 +122,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
}
// 判断关联业务员在当前阶段是否已经分红
// 判断推荐人在当前阶段是否已经分红
if undertaker.Referrer != nil {
referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
"undertakerUid": undertaker.Referrer.UserId,
... ... @@ -133,7 +133,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
return nil, err
}
if referrerEstimated {
return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
return nil, fmt.Errorf("推荐人 " + undertaker.Referrer.UserName + " 已分红")
} else {
undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
... ... @@ -150,7 +150,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
UserPhone: undertaker.Referrer.UserPhone,
Company: undertaker.Referrer.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsParticipateType: 2,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
})
... ...