作者 陈志颖

fix:根据合约名称查询金额激励分红

... ... @@ -355,11 +355,43 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
// 校验是否能够取消
if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红/退货冲销
if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
// 自定义查询
queryOptions := make(map[string]interface{})
//参与分红类型,1承接人,2推荐人,3关联业务员
if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
queryOptions = map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
"dividendsParticipateTypes": []int32{2, 3},
"offsetLimit": false,
"dividendsStage": dividendsEstimate.DividendsStage,
"dividendsTypes": []int32{1, 2},
}
} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
queryOptions = map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
}); err2 != nil {
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
"dividendsParticipateTypes": []int32{1, 3},
"offsetLimit": false,
"dividendsStage": dividendsEstimate.DividendsStage,
"dividendsTypes": []int32{1, 2},
}
} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
queryOptions = map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
"dividendsParticipateTypes": []int32{1, 2},
"offsetLimit": false,
"dividendsStage": dividendsEstimate.DividendsStage,
"dividendsTypes": []int32{1, 2},
}
}
if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
} else {
if countRelativeDividendsEstimates > 0 {
... ... @@ -371,11 +403,43 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
}
}
} else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红
if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(map[string]interface{}{
// 自定义查询
queryOptions := make(map[string]interface{})
//参与分红类型,1承接人,2推荐人,3关联业务员
if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
queryOptions = map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
"cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
"dividendsParticipateTypes": []int32{2, 3},
"offsetLimit": false,
"dividendsStage": dividendsEstimate.DividendsStage,
"dividendsType": int32(3),
}
} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
queryOptions = map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
}); err3 != nil {
"cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
"dividendsParticipateTypes": []int32{1, 3},
"offsetLimit": false,
"dividendsStage": dividendsEstimate.DividendsStage,
"dividendsType": int32(3),
}
} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
queryOptions = map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
"cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
"dividendsParticipateTypes": []int32{1, 2},
"offsetLimit": false,
"dividendsStage": dividendsEstimate.DividendsStage,
"dividendsType": int32(3),
}
}
if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(queryOptions); err3 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
} else {
if countRelativeDividendsEstimates > 0 {
... ... @@ -388,6 +452,7 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
}
}
}
// 批量取消分红预算单
if dividendsEstimatesCanceled, errCancel := cancelDividendsEstimateService.CancelEstimate(dividendsEstimateIds, operator); errCancel != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errCancel.Error())
... ... @@ -651,6 +716,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsEstimates := make([]*domain.DividendsEstimate, 0)
// 统计当前企业分红预算单数
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
... ... @@ -658,6 +724,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var countDividendsEstimate int64
for _, orderGood := range orderGoods {
dividendsEstimate := &domain.DividendsEstimate{}
... ...
... ... @@ -150,6 +150,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
"dividendsType": int32(3),
}
}
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
return nil, err2
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
)
type ConfirmDividendsIncentivesEstimateService struct {
... ... @@ -53,6 +54,10 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
// 确认业绩分红预算
var dividendsEstimateDetails []*service.DividendsEstimateDetail
for _, orderGood := range orderGoods {
log.Logger.Info("业绩分红预算产品", map[string]interface{}{
"orderGood": orderGood,
})
// 获取合约
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
"cooperationContractNumber": orderGood.CooperationContractNumber,
... ... @@ -95,6 +100,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
})
continue
} else {
log.Logger.Info("产品相关的合约", map[string]interface{}{
"cooperationContract": cooperationContract,
})
if cooperationContract.Status == 2 {
var orderNumber string
if orderGood.DividendsOrderNumber != "" {
... ...
... ... @@ -30,7 +30,7 @@ type CooperationContractChangeLog struct {
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
}
... ...
... ... @@ -1146,7 +1146,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
}
if cooperationContractName, ok := queryOptions["cooperationContactName"]; ok && cooperationContractName != "" {
if cooperationContractName, ok := queryOptions["cooperationContractName"]; ok && cooperationContractName != "" {
query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName))
}
if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
... ...