合并分支 'dev' 到 'test'
Dev 查看合并请求 !59
正在显示
5 个修改的文件
包含
101 行增加
和
2 行删除
| @@ -281,6 +281,16 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -281,6 +281,16 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 281 | cooperationApplicationRepository = value | 281 | cooperationApplicationRepository = value |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | + // 共创合约仓储初始化 | ||
| 285 | + var cooperationContractRepository domain.CooperationContractRepository | ||
| 286 | + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ | ||
| 287 | + "transactionContext": transactionContext, | ||
| 288 | + }); err != nil { | ||
| 289 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 290 | + } else { | ||
| 291 | + cooperationContractRepository = value | ||
| 292 | + } | ||
| 293 | + | ||
| 284 | var getCooperationProjectQuerySpecific *query.GetCooperationProjectQuery | 294 | var getCooperationProjectQuerySpecific *query.GetCooperationProjectQuery |
| 285 | if getCooperationProjectQuery.CooperationProjectId != 0 { // 根据ID查询 | 295 | if getCooperationProjectQuery.CooperationProjectId != 0 { // 根据ID查询 |
| 286 | getCooperationProjectQuerySpecific = &query.GetCooperationProjectQuery{ | 296 | getCooperationProjectQuerySpecific = &query.GetCooperationProjectQuery{ |
| @@ -349,6 +359,43 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -349,6 +359,43 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 349 | undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3) | 359 | undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3) |
| 350 | } | 360 | } |
| 351 | 361 | ||
| 362 | + // TODO 判断项目关联的合约承接人类型 | ||
| 363 | + undertakers := make([]*domain.Undertaker, 0) | ||
| 364 | + if countContracts, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{ | ||
| 365 | + "offsetLimit": false, | ||
| 366 | + }); err != nil { | ||
| 367 | + | ||
| 368 | + } else { | ||
| 369 | + if countContracts > 0 { | ||
| 370 | + for _, cooperationContract := range cooperationContracts { | ||
| 371 | + undertakers = append(undertakers, cooperationContract.Undertakers...) | ||
| 372 | + } | ||
| 373 | + } | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | + var undertakerUserTypes []int32 | ||
| 377 | + for _, undertaker := range undertakers { | ||
| 378 | + undertakerUserTypes = append(undertakerUserTypes, undertaker.UserType) | ||
| 379 | + } | ||
| 380 | + | ||
| 381 | + undertakerUserTypes = utils.RemoveDuplicationInt32(undertakerUserTypes) | ||
| 382 | + | ||
| 383 | + for i, userType := range undertakerUserTypes { | ||
| 384 | + if userType == 1025 { | ||
| 385 | + undertakerUserTypes[i] = 2 | ||
| 386 | + } | ||
| 387 | + } | ||
| 388 | + | ||
| 389 | + if utils.IsContain(undertakerUserTypes, int32(1)) && utils.IsContain(undertakerUserTypes, int32(2)) { | ||
| 390 | + undertakerUserTypes = append(undertakerUserTypes, int32(3)) | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + newUndertakerTypesUncheckedAvailable := utils.Intersect32(undertakerTypesUncheckedAvailable, undertakerUserTypes) | ||
| 394 | + | ||
| 395 | + log.Logger.Info("承接人类型", map[string]interface{}{ | ||
| 396 | + "undertakerUserTypes": undertakerUserTypes, | ||
| 397 | + }) | ||
| 398 | + | ||
| 352 | // 返回所有员工类型的申请通过人 | 399 | // 返回所有员工类型的申请通过人 |
| 353 | applicants := make([]*domain.User, 0) | 400 | applicants := make([]*domain.User, 0) |
| 354 | 401 | ||
| @@ -357,6 +404,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -357,6 +404,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 357 | "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber, | 404 | "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber, |
| 358 | "companyId": cooperationProject.Company.CompanyId, | 405 | "companyId": cooperationProject.Company.CompanyId, |
| 359 | "orgId": cooperationProject.Org.OrgId, | 406 | "orgId": cooperationProject.Org.OrgId, |
| 407 | + "offsetLimit": false, | ||
| 360 | }); err != nil { | 408 | }); err != nil { |
| 361 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 409 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 362 | } else { | 410 | } else { |
| @@ -375,7 +423,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -375,7 +423,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 375 | } | 423 | } |
| 376 | 424 | ||
| 377 | cooperationProjectDto := &dto.CooperationProjectsDto{} | 425 | cooperationProjectDto := &dto.CooperationProjectsDto{} |
| 378 | - if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable, applicants); err != nil { | 426 | + if err := cooperationProjectDto.LoadDto(cooperationProject, nil, newUndertakerTypesUncheckedAvailable, applicants); err != nil { |
| 379 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 427 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 380 | } | 428 | } |
| 381 | if err := transactionContext.CommitTransaction(); err != nil { | 429 | if err := transactionContext.CommitTransaction(); err != nil { |
| @@ -639,6 +687,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro | @@ -639,6 +687,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro | ||
| 639 | } | 687 | } |
| 640 | } | 688 | } |
| 641 | } | 689 | } |
| 690 | + | ||
| 642 | var undertakerTypes []int32 | 691 | var undertakerTypes []int32 |
| 643 | var k1, k2 int32 | 692 | var k1, k2 int32 |
| 644 | if len(applicantTypes) > 0 { | 693 | if len(applicantTypes) > 0 { |
| @@ -654,6 +703,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro | @@ -654,6 +703,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro | ||
| 654 | if k1 != 0 && k2 != 0 { | 703 | if k1 != 0 && k2 != 0 { |
| 655 | undertakerTypes = append(undertakerTypes, 3) | 704 | undertakerTypes = append(undertakerTypes, 3) |
| 656 | } | 705 | } |
| 706 | + | ||
| 657 | // 校验可以修改的承接人(申请人)类型 | 707 | // 校验可以修改的承接人(申请人)类型 |
| 658 | for _, t := range undertakerTypes { | 708 | for _, t := range undertakerTypes { |
| 659 | if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) { | 709 | if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) { |
| @@ -521,6 +521,7 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat | @@ -521,6 +521,7 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat | ||
| 521 | 521 | ||
| 522 | // ConfirmDividendsIncentivesEstimate 确定业绩激励分红预算 | 522 | // ConfirmDividendsIncentivesEstimate 确定业绩激励分红预算 |
| 523 | func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncentivesEstimate(confirmDividendsIncentivesEstimateCommand *command.ConfirmDividendsIncentivesEstimateCommand) (interface{}, error) { | 523 | func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncentivesEstimate(confirmDividendsIncentivesEstimateCommand *command.ConfirmDividendsIncentivesEstimateCommand) (interface{}, error) { |
| 524 | + start := time.Now() // 获取当前时间 | ||
| 524 | if err := confirmDividendsIncentivesEstimateCommand.ValidateCommand(); err != nil { | 525 | if err := confirmDividendsIncentivesEstimateCommand.ValidateCommand(); err != nil { |
| 525 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 526 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| 526 | } | 527 | } |
| @@ -676,10 +677,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -676,10 +677,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 676 | } | 677 | } |
| 677 | 678 | ||
| 678 | var countDividendsEstimate int64 | 679 | var countDividendsEstimate int64 |
| 680 | + | ||
| 679 | for _, orderGood := range orderGoods { | 681 | for _, orderGood := range orderGoods { |
| 680 | dividendsEstimate := &domain.DividendsEstimate{} | 682 | dividendsEstimate := &domain.DividendsEstimate{} |
| 681 | if orderGood.DividendsOrderNumber != "" { // 查询分红订单 | 683 | if orderGood.DividendsOrderNumber != "" { // 查询分红订单 |
| 682 | - // 临时方案 | ||
| 683 | orderGoodsToConfirm := make([]*domain.OrderGood, 0) | 684 | orderGoodsToConfirm := make([]*domain.OrderGood, 0) |
| 684 | orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood) | 685 | orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood) |
| 685 | // 分红订单产品预算 | 686 | // 分红订单产品预算 |
| @@ -957,6 +958,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -957,6 +958,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 957 | failedReasonStr = "无" | 958 | failedReasonStr = "无" |
| 958 | } | 959 | } |
| 959 | 960 | ||
| 961 | + elapsed := time.Since(start) | ||
| 962 | + fmt.Println("该函数执行完成耗时:", elapsed) | ||
| 963 | + | ||
| 960 | return map[string]interface{}{ | 964 | return map[string]interface{}{ |
| 961 | "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr), | 965 | "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr), |
| 962 | }, nil | 966 | }, nil |
不能预览此文件类型
| @@ -144,6 +144,16 @@ func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOp | @@ -144,6 +144,16 @@ func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOp | ||
| 144 | if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { | 144 | if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { |
| 145 | query = query.Where(`A.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) | 145 | query = query.Where(`A.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) |
| 146 | } | 146 | } |
| 147 | + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | ||
| 148 | + query.Where("A.company->>'companyId' = '?'", companyId) | ||
| 149 | + } | ||
| 150 | + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | ||
| 151 | + query.Where("A.org->>'orgId' = '?'", orgId) | ||
| 152 | + } | ||
| 153 | + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 { | ||
| 154 | + newOrgIds := utils.SliceItoa(orgIds.([]int64)) | ||
| 155 | + query.Where("A.org->>'orgId' in (?)", pg.In(newOrgIds)) | ||
| 156 | + } | ||
| 147 | query.Join("JOIN cooperation_contracts AS A ON A.cooperation_contract_number = cooperation_contract_undertaker.cooperation_contract_number") | 157 | query.Join("JOIN cooperation_contracts AS A ON A.cooperation_contract_number = cooperation_contract_undertaker.cooperation_contract_number") |
| 148 | query.Join("JOIN cooperation_modes AS B ON B.cooperation_mode_number = A.cooperation_mode_number") | 158 | query.Join("JOIN cooperation_modes AS B ON B.cooperation_mode_number = A.cooperation_mode_number") |
| 149 | query = query.Order("cooperation_contract_undertaker_id DESC") | 159 | query = query.Order("cooperation_contract_undertaker_id DESC") |
| @@ -30,6 +30,26 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 { | @@ -30,6 +30,26 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 { | ||
| 30 | return intersection | 30 | return intersection |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | +// Intersect32 返回两个数组的交集 | ||
| 34 | +func Intersect32(nums1 []int32, nums2 []int32) []int32 { | ||
| 35 | + if len(nums1) > len(nums2) { | ||
| 36 | + return Intersect32(nums2, nums1) | ||
| 37 | + } | ||
| 38 | + m := map[int32]int32{} | ||
| 39 | + for _, num := range nums1 { | ||
| 40 | + m[num]++ | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + var intersection []int32 | ||
| 44 | + for _, num := range nums2 { | ||
| 45 | + if m[num] > 0 { | ||
| 46 | + intersection = append(intersection, num) | ||
| 47 | + m[num]-- | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + return intersection | ||
| 51 | +} | ||
| 52 | + | ||
| 33 | // Difference 求差集 slice1-并集 | 53 | // Difference 求差集 slice1-并集 |
| 34 | func Difference(slice1, slice2 []int64) []int64 { | 54 | func Difference(slice1, slice2 []int64) []int64 { |
| 35 | m := make(map[int64]int) | 55 | m := make(map[int64]int) |
| @@ -144,6 +164,21 @@ func RemoveDuplicationInt64(arr []int64) []int64 { | @@ -144,6 +164,21 @@ func RemoveDuplicationInt64(arr []int64) []int64 { | ||
| 144 | return arr[:j] | 164 | return arr[:j] |
| 145 | } | 165 | } |
| 146 | 166 | ||
| 167 | +func RemoveDuplicationInt32(arr []int32) []int32 { | ||
| 168 | + set := make(map[int32]struct{}, len(arr)) | ||
| 169 | + j := 0 | ||
| 170 | + for _, v := range arr { | ||
| 171 | + _, ok := set[v] | ||
| 172 | + if ok { | ||
| 173 | + continue | ||
| 174 | + } | ||
| 175 | + set[v] = struct{}{} | ||
| 176 | + arr[j] = v | ||
| 177 | + j++ | ||
| 178 | + } | ||
| 179 | + return arr[:j] | ||
| 180 | +} | ||
| 181 | + | ||
| 147 | // IsContain 判断int32数组是否包含 | 182 | // IsContain 判断int32数组是否包含 |
| 148 | func IsContain(items []int32, item int32) bool { | 183 | func IsContain(items []int32, item int32) bool { |
| 149 | for _, eachItem := range items { | 184 | for _, eachItem := range items { |
-
请 注册 或 登录 后发表评论