作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !74
... ... @@ -651,14 +651,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationProjectRepository = value
}
//var cooperationProjectRepository domain.CooperationProjectRepository
//if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
// "transactionContext": transactionContext,
//}); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// cooperationProjectRepository = value
//}
// 初始化确认业绩激励分红预算领域服务
var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService
... ... @@ -673,45 +673,25 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
})
}
// 查询共创合约
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
"orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, err
} else {
if count > 0 {
for _, cooperationContractFound := range cooperationContractsFound {
cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
}
}
}
log.Logger.Info("查询共创合约", map[string]interface{}{
"cooperationContractsMap": cooperationContractsMap,
})
// 查询共创项目
cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
"orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, err
} else {
if count > 0 {
for _, cooperationProjectFound := range cooperationProjectsFound {
cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound
}
}
}
log.Logger.Info("查询共创项目", map[string]interface{}{
"cooperationProjectsMap": cooperationProjectsMap,
})
//cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
//if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{
// "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
// "orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
// "offsetLimit": false,
//}); err != nil {
// return nil, err
//} else {
// if count > 0 {
// for _, cooperationProjectFound := range cooperationProjectsFound {
// cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound
// }
// }
//}
//
//log.Logger.Info("查询共创项目", map[string]interface{}{
// "cooperationProjectsMap": cooperationProjectsMap,
//})
// 统计成功预算的分红订单
estimateSuccessfullyDividendsOrders := make(map[string]string)
... ... @@ -728,6 +708,34 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
} else {
dividendsEstimates := make([]*domain.DividendsEstimate, 0)
var cooperationContractNumbers []string
// 获取订单产品合约编号
for _, orderGood := range orderGoods {
cooperationContractNumbers = append(cooperationContractNumbers, orderGood.CooperationContractNumber)
}
// 查询共创合约
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
"cooperationContractNumbers": cooperationContractNumbers,
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
"orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, err
} else {
if count > 0 {
for _, cooperationContractFound := range cooperationContractsFound {
cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
}
}
}
log.Logger.Info("查询共创合约", map[string]interface{}{
"cooperationContractsMap": cooperationContractsMap,
})
// 统计当前企业分红预算单数
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
... ... @@ -744,7 +752,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// 分红订单产品预算
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap, cooperationProjectsMap); err != nil {
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap, nil); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
... ... @@ -800,7 +808,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// 分红退货单产品预算
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap, cooperationProjectsMap); err != nil {
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap, nil); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
... ... @@ -871,8 +879,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
// 更新订单产品分红状态
var orderGoodsSaved []*domain.OrderGood
if len(orderGoodSavedIds) > 0 {
// 订单产品ID去重
newOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodSavedIds)
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
"orderGoodIds": orderGoodSavedIds,
"orderGoodIds": newOrderGoodIds,
"offsetLimit": false,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -164,8 +164,10 @@ func (repository *CooperationApplicationRepository) UpdateMany(cooperationApplic
UpdatedAt: time.Now(),
})
}
if _, err := tx.Model(&cooperationApplicationModels).WherePK().Update(); err != nil {
return nil, err
if len(cooperationApplicationModels) > 0 {
if _, err := tx.Model(&cooperationApplicationModels).WherePK().Update(); err != nil {
return nil, err
}
}
return cooperationApplications, nil
}
... ...