作者 陈志颖

feat:阶段和承接人列表

... ... @@ -1172,7 +1172,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType && cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 1.激励类型变更
// 业绩分红-->金额激励
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原业绩分红激励规则
var dividendsIncentivesRuleOriginal string
... ... @@ -1203,7 +1202,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 金额激励-->业绩分红
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原金额激励规则
var moneyIncentivesRuleOriginal string
for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
... ... @@ -1214,7 +1212,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
}
moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
// 变更后的业绩分红激励规则
var dividendsIncentivesRuleChanged string
for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
... ... @@ -1226,7 +1223,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
}
dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleChanged + "】"
// 拼接规则变更
incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleOriginalTmp
} else { // 2.激励规则变更
... ... @@ -1235,7 +1231,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 业绩分红-->业绩分红
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原业绩分红激励规则
var dividendsIncentivesRuleOriginal string
for _, dividendsIncentivesRule := range cooperationContractFound.DividendsIncentivesRules {
... ... @@ -1247,7 +1242,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
}
dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
// 变更后的业绩分红激励规则
var dividendsIncentivesRuleChanged string
for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
... ... @@ -1259,7 +1253,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
}
dividendsIncentivesRuleChangedTmp := "【" + dividendsIncentivesRuleChanged + "】"
// 拼接规则变更
incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleChangedTmp
}
... ... @@ -1267,7 +1260,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
if !cooperationContract.MoneyIncentivesRuleSliceEqualBCE(cooperationContractFound.MoneyIncentivesRules, cooperationContractSaved.MoneyIncentivesRules) {
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原金额激励规则
var moneyIncentivesRuleOriginal string
for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
... ... @@ -1278,7 +1270,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
}
moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
// 变更后的激励规则
var moneyIncentivesRuleChanged string
for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
... ... @@ -1289,7 +1280,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
}
moneyIncentivesRuleChangedTmp := "【" + moneyIncentivesRuleChanged + "】"
// 拼接规则变更
incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleChangedTmp
}
... ...
... ... @@ -290,6 +290,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3)
}
// TODO 返回所有员工类型的申请通过人
cooperationProjectDto := &dto.CooperationProjectsDto{}
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -31,8 +31,7 @@ type MoneyIncentivesEstimateDto struct {
StageAndUndertaker []*StageAndUndertaker `json:"stageAndUndertaker"`
}
func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error {
// TODO 阶段承接人数据聚合
func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract, stageAndUndertaker []*StageAndUndertaker) error {
dto.CooperationContractId = contract.CooperationContractId
dto.CooperationContractNumber = contract.CooperationContractNumber
dto.CooperationContractName = contract.CooperationContractName
... ... @@ -40,9 +39,6 @@ func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContr
dto.Department = contract.Department
dto.CooperationContractSponsorName = contract.CooperationContractSponsor.UserName
dto.CreatedAt = contract.CreatedAt
dto.StageAndUndertaker = append(dto.StageAndUndertaker, &StageAndUndertaker{
Stage: 0,
Undertakers: nil,
})
dto.StageAndUndertaker = stageAndUndertaker
return nil
}
... ...
... ... @@ -148,13 +148,11 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listMoneyIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
// TODO 判断承接人是否已分红
// 数据传输对象
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
for _, cooperationContract := range cooperationContracts {
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, nil); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
... ... @@ -1354,6 +1352,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
... ... @@ -1363,6 +1362,10 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
} else {
cooperationContractRepository = value
}
// TODO 阶段承接人列表
stageAndUndertaker := make([]*dto.StageAndUndertaker, 0)
// 查找共创合约
searchMoneyIncentivesEstimateQuery.IncentivesType = 2
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil {
... ... @@ -1370,8 +1373,13 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
} else {
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
for _, cooperationContract := range cooperationContracts {
// TODO 判断承接人是否已分红
//for _, undertaker := range cooperationContract.Undertakers {
//
//}
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
... ...