|
@@ -395,6 +395,7 @@ func (ptr *CooperationStatisticsService) CompanyCooperationProjectContracts(quer |
|
@@ -395,6 +395,7 @@ func (ptr *CooperationStatisticsService) CompanyCooperationProjectContracts(quer |
395
|
// func(ptr *CooperationStatisticsService)
|
395
|
// func(ptr *CooperationStatisticsService)
|
396
|
|
396
|
|
397
|
// 个人 - 共创浏览 详情页 - 附件数据
|
397
|
// 个人 - 共创浏览 详情页 - 附件数据
|
|
|
398
|
+// response,error 有可能同时为空,返回需要判断
|
398
|
func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfoAttachment(queryOptions map[string]interface{}) (interface{}, error) {
|
399
|
func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfoAttachment(queryOptions map[string]interface{}) (interface{}, error) {
|
399
|
// 参数验证
|
400
|
// 参数验证
|
400
|
var request = struct {
|
401
|
var request = struct {
|
|
@@ -402,16 +403,96 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfoAttac |
|
@@ -402,16 +403,96 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfoAttac |
402
|
// 用户
|
403
|
// 用户
|
403
|
UserId int64 `json:"userId" valid:"Required"`
|
404
|
UserId int64 `json:"userId" valid:"Required"`
|
404
|
// 项目ID
|
405
|
// 项目ID
|
405
|
- ProjectId int64 `json:"projectId" valid:"Required"`
|
406
|
+ ProjectId int64 `json:"cooperationProjectId" valid:"Required"`
|
406
|
// 合约ID
|
407
|
// 合约ID
|
407
|
- ContractId int64 `json:"contractId" valid:"Required"`
|
408
|
+ ContractId int64 `json:"cooperationContractId" valid:"Required"`
|
408
|
// 附件类型 1:合约附件 2:支付凭证
|
409
|
// 附件类型 1:合约附件 2:支付凭证
|
409
|
- AttachType int `json:"attachType" valid:"Required"`
|
410
|
+ AttachmentType int `json:"attachmentType" valid:"Required"`
|
410
|
}{}
|
411
|
}{}
|
411
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
412
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
412
|
return nil, err
|
413
|
return nil, err
|
413
|
}
|
414
|
}
|
414
|
- queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
415
|
- var response = domain.CooperationProjectSharedInfoDto{}
|
415
|
+ var response = struct {
|
|
|
416
|
+ Attachment *domain.Attachment `json:"attachment"`
|
|
|
417
|
+ UserBaseId int64 `json:"userBaseId"`
|
|
|
418
|
+ }{}
|
|
|
419
|
+ userServiceGateway := service_gateway.NewHttplibUserServiceGateway()
|
|
|
420
|
+ userDetail, e := userServiceGateway.GetUser(0, 0, request.UserId)
|
|
|
421
|
+ if e != nil {
|
|
|
422
|
+ return nil, e
|
|
|
423
|
+ }
|
|
|
424
|
+ request.UserBaseId = userDetail.UserBaseId
|
|
|
425
|
+ response.UserBaseId = userDetail.UserBaseId
|
|
|
426
|
+ switch request.AttachmentType {
|
|
|
427
|
+ case 1:
|
|
|
428
|
+ contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext) // repository.NewCooperationContractRepository(ptr.transactionContext)
|
|
|
429
|
+ contracts, err := contractRepository.FindOne(map[string]interface{}{"cooperationContractId": request.ContractId})
|
|
|
430
|
+ if err != nil {
|
|
|
431
|
+ return nil, fmt.Errorf("合约不存在")
|
|
|
432
|
+ }
|
|
|
433
|
+ undertakerRepository, _ := dao.NewCooperationContractUndertakerDao(ptr.transactionContext)
|
|
|
434
|
+ _, undertakers, err := undertakerRepository.Find(map[string]interface{}{
|
|
|
435
|
+ "userBaseId": request.UserBaseId,
|
|
|
436
|
+ "cooperationContractIds": []int64{contracts.CooperationContractId},
|
|
|
437
|
+ })
|
|
|
438
|
+ if err != nil {
|
|
|
439
|
+ return nil, err
|
|
|
440
|
+ }
|
|
|
441
|
+ for i := range undertakers {
|
|
|
442
|
+ if len(undertakers[i].Undertaker.ContractAttachment) == 0 {
|
|
|
443
|
+ continue
|
|
|
444
|
+ }
|
|
|
445
|
+ response.Attachment = undertakers[i].Undertaker.ContractAttachment[0]
|
|
|
446
|
+ break
|
|
|
447
|
+ }
|
|
|
448
|
+ case 2:
|
|
|
449
|
+ // 0.2 合约数据
|
|
|
450
|
+ contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext) // repository.NewCooperationContractRepository(ptr.transactionContext)
|
|
|
451
|
+ contracts, err := contractRepository.FindOne(map[string]interface{}{"cooperationContractId": request.ContractId})
|
|
|
452
|
+ if err != nil {
|
|
|
453
|
+ return nil, fmt.Errorf("合约不存在")
|
|
|
454
|
+ }
|
|
|
455
|
+ dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
|
|
|
456
|
+ _, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
457
|
+ "orgId": contracts.Org.OrgId,
|
|
|
458
|
+ "companyId": contracts.Company.CompanyId,
|
|
|
459
|
+ "cooperationContractNumber": contracts.CooperationContractNumber,
|
|
|
460
|
+ "isCanceled": false,
|
|
|
461
|
+ "paymentStatus": int32(2),
|
|
|
462
|
+ })
|
|
|
463
|
+ if err != nil {
|
|
|
464
|
+ return nil, err
|
|
|
465
|
+ }
|
|
|
466
|
+ var estimateIds []int64
|
|
|
467
|
+ if len(dividendsEstimates) == 0 {
|
|
|
468
|
+ return response, nil
|
|
|
469
|
+ }
|
|
|
470
|
+ for i := range dividendsEstimates {
|
|
|
471
|
+ estimateIds = append(estimateIds, dividendsEstimates[i].DividendsEstimateId)
|
|
|
472
|
+ }
|
|
|
473
|
+ creditAccountRepository, _ := repository.NewCreditAccountRepository(ptr.transactionContext)
|
|
|
474
|
+ _, creditAccount, err := creditAccountRepository.Find(map[string]interface{}{
|
|
|
475
|
+ "userBaseId": request.UserBaseId,
|
|
|
476
|
+ "orgId": contracts.Org.OrgId,
|
|
|
477
|
+ "companyId": contracts.Company.CompanyId,
|
|
|
478
|
+ "dividendsEstimateOrderIds": estimateIds,
|
|
|
479
|
+ })
|
|
|
480
|
+ if err != nil {
|
|
|
481
|
+ return nil, err
|
|
|
482
|
+ }
|
|
|
483
|
+ if len(creditAccount) == 0 {
|
|
|
484
|
+ return response, nil
|
|
|
485
|
+ }
|
|
|
486
|
+ for i := range creditAccount {
|
|
|
487
|
+ if len(creditAccount[i].PaymentDocumentAttachments) == 0 {
|
|
|
488
|
+ continue
|
|
|
489
|
+ }
|
|
|
490
|
+ response.Attachment = creditAccount[i].PaymentDocumentAttachments[0] // 获取第一个
|
|
|
491
|
+ break
|
|
|
492
|
+ }
|
|
|
493
|
+ default:
|
|
|
494
|
+ return nil, fmt.Errorf("unkown attachment type %v", request.AttachmentType)
|
|
|
495
|
+ }
|
|
|
496
|
+
|
416
|
return response, nil
|
497
|
return response, nil
|
417
|
} |
498
|
} |