...
|
...
|
@@ -395,6 +395,7 @@ func (ptr *CooperationStatisticsService) CompanyCooperationProjectContracts(quer |
|
|
// func(ptr *CooperationStatisticsService)
|
|
|
|
|
|
// 个人 - 共创浏览 详情页 - 附件数据
|
|
|
// response,error 有可能同时为空,返回需要判断
|
|
|
func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfoAttachment(queryOptions map[string]interface{}) (interface{}, error) {
|
|
|
// 参数验证
|
|
|
var request = struct {
|
...
|
...
|
@@ -402,16 +403,96 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfoAttac |
|
|
// 用户
|
|
|
UserId int64 `json:"userId" valid:"Required"`
|
|
|
// 项目ID
|
|
|
ProjectId int64 `json:"projectId" valid:"Required"`
|
|
|
ProjectId int64 `json:"cooperationProjectId" valid:"Required"`
|
|
|
// 合约ID
|
|
|
ContractId int64 `json:"contractId" valid:"Required"`
|
|
|
ContractId int64 `json:"cooperationContractId" valid:"Required"`
|
|
|
// 附件类型 1:合约附件 2:支付凭证
|
|
|
AttachType int `json:"attachType" valid:"Required"`
|
|
|
AttachmentType int `json:"attachmentType" valid:"Required"`
|
|
|
}{}
|
|
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
var response = domain.CooperationProjectSharedInfoDto{}
|
|
|
var response = struct {
|
|
|
Attachment *domain.Attachment `json:"attachment"`
|
|
|
UserBaseId int64 `json:"userBaseId"`
|
|
|
}{}
|
|
|
userServiceGateway := service_gateway.NewHttplibUserServiceGateway()
|
|
|
userDetail, e := userServiceGateway.GetUser(0, 0, request.UserId)
|
|
|
if e != nil {
|
|
|
return nil, e
|
|
|
}
|
|
|
request.UserBaseId = userDetail.UserBaseId
|
|
|
response.UserBaseId = userDetail.UserBaseId
|
|
|
switch request.AttachmentType {
|
|
|
case 1:
|
|
|
contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext) // repository.NewCooperationContractRepository(ptr.transactionContext)
|
|
|
contracts, err := contractRepository.FindOne(map[string]interface{}{"cooperationContractId": request.ContractId})
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("合约不存在")
|
|
|
}
|
|
|
undertakerRepository, _ := dao.NewCooperationContractUndertakerDao(ptr.transactionContext)
|
|
|
_, undertakers, err := undertakerRepository.Find(map[string]interface{}{
|
|
|
"userBaseId": request.UserBaseId,
|
|
|
"cooperationContractIds": []int64{contracts.CooperationContractId},
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
for i := range undertakers {
|
|
|
if len(undertakers[i].Undertaker.ContractAttachment) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
response.Attachment = undertakers[i].Undertaker.ContractAttachment[0]
|
|
|
break
|
|
|
}
|
|
|
case 2:
|
|
|
// 0.2 合约数据
|
|
|
contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext) // repository.NewCooperationContractRepository(ptr.transactionContext)
|
|
|
contracts, err := contractRepository.FindOne(map[string]interface{}{"cooperationContractId": request.ContractId})
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("合约不存在")
|
|
|
}
|
|
|
dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
|
|
|
_, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
"orgId": contracts.Org.OrgId,
|
|
|
"companyId": contracts.Company.CompanyId,
|
|
|
"cooperationContractNumber": contracts.CooperationContractNumber,
|
|
|
"isCanceled": false,
|
|
|
"paymentStatus": int32(2),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
var estimateIds []int64
|
|
|
if len(dividendsEstimates) == 0 {
|
|
|
return response, nil
|
|
|
}
|
|
|
for i := range dividendsEstimates {
|
|
|
estimateIds = append(estimateIds, dividendsEstimates[i].DividendsEstimateId)
|
|
|
}
|
|
|
creditAccountRepository, _ := repository.NewCreditAccountRepository(ptr.transactionContext)
|
|
|
_, creditAccount, err := creditAccountRepository.Find(map[string]interface{}{
|
|
|
"userBaseId": request.UserBaseId,
|
|
|
"orgId": contracts.Org.OrgId,
|
|
|
"companyId": contracts.Company.CompanyId,
|
|
|
"dividendsEstimateOrderIds": estimateIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if len(creditAccount) == 0 {
|
|
|
return response, nil
|
|
|
}
|
|
|
for i := range creditAccount {
|
|
|
if len(creditAccount[i].PaymentDocumentAttachments) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
response.Attachment = creditAccount[i].PaymentDocumentAttachments[0] // 获取第一个
|
|
|
break
|
|
|
}
|
|
|
default:
|
|
|
return nil, fmt.Errorf("unkown attachment type %v", request.AttachmentType)
|
|
|
}
|
|
|
|
|
|
return response, nil
|
|
|
} |
...
|
...
|
|