作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !91
@@ -387,6 +387,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -387,6 +387,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
387 CreatedAt: time.Now(), 387 CreatedAt: time.Now(),
388 DeletedAt: time.Time{}, 388 DeletedAt: time.Time{},
389 UpdatedAt: time.Time{}, 389 UpdatedAt: time.Time{},
  390 + CooperationProjectId: cooperationProject.CooperationProjectId,
390 } 391 }
391 392
392 // 共创合约仓储初始化 393 // 共创合约仓储初始化
@@ -67,6 +67,8 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS @@ -67,6 +67,8 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS
67 res, err = statisticsService.PersonCooperationProjectSharedInfo(contractStatisticsQuery.QueryOptions) 67 res, err = statisticsService.PersonCooperationProjectSharedInfo(contractStatisticsQuery.QueryOptions)
68 case domain_service.PersonCooperationProjectSharedInfoAttachment: 68 case domain_service.PersonCooperationProjectSharedInfoAttachment:
69 res, err = statisticsService.PersonCooperationProjectSharedInfoAttachment(contractStatisticsQuery.QueryOptions) 69 res, err = statisticsService.PersonCooperationProjectSharedInfoAttachment(contractStatisticsQuery.QueryOptions)
  70 + case domain_service.PersonCooperationCompany:
  71 + res, err = statisticsService.PersonCooperationCompany(contractStatisticsQuery.QueryOptions)
70 case domain_service.CreditAccountStatistics: 72 case domain_service.CreditAccountStatistics:
71 res, err = statisticsService.CreditAccountStatistics(contractStatisticsQuery.QueryOptions) 73 res, err = statisticsService.CreditAccountStatistics(contractStatisticsQuery.QueryOptions)
72 case domain_service.RelevantCooperationContractNumbers: 74 case domain_service.RelevantCooperationContractNumbers:
@@ -12,13 +12,13 @@ type GetCreditAccountQuery struct { @@ -12,13 +12,13 @@ type GetCreditAccountQuery struct {
12 // 账期结算单ID 12 // 账期结算单ID
13 CreditAccountId int64 `cname:"账期结算单ID" json:"creditAccountId" valid:"Required"` 13 CreditAccountId int64 `cname:"账期结算单ID" json:"creditAccountId" valid:"Required"`
14 // 公司ID,通过集成REST上下文获取 14 // 公司ID,通过集成REST上下文获取
15 - CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` 15 + CompanyId int64 `cname:"公司ID" json:"companyId"`
16 // 组织机构ID 16 // 组织机构ID
17 - OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"` 17 + OrgId int64 `cname:"组织机构ID" json:"orgId"`
18 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 18 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
19 - UserId int64 `cname:"用户ID" json:"userId" valid:"Required"` 19 + UserId int64 `cname:"用户ID" json:"userId"`
20 // 用户基础数据id 20 // 用户基础数据id
21 - UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"` 21 + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
22 } 22 }
23 23
24 func (getCreditAccountQuery *GetCreditAccountQuery) Valid(validation *validation.Validation) { 24 func (getCreditAccountQuery *GetCreditAccountQuery) Valid(validation *validation.Validation) {
@@ -77,6 +77,8 @@ type CooperationContract struct { @@ -77,6 +77,8 @@ type CooperationContract struct {
77 DeletedAt time.Time `json:"deletedAt"` 77 DeletedAt time.Time `json:"deletedAt"`
78 // 更新时间 78 // 更新时间
79 UpdatedAt time.Time `json:"updatedAt"` 79 UpdatedAt time.Time `json:"updatedAt"`
  80 + // 共创项目编号
  81 + CooperationProjectId int64 `json:"cooperationProjectId"`
80 } 82 }
81 83
82 type CooperationContractRepository interface { 84 type CooperationContractRepository interface {
@@ -175,3 +177,20 @@ func (cooperationContract *CooperationContract) MoneyIncentivesRuleSliceEqualBCE @@ -175,3 +177,20 @@ func (cooperationContract *CooperationContract) MoneyIncentivesRuleSliceEqualBCE
175 } 177 }
176 return true 178 return true
177 } 179 }
  180 +
  181 +func CooperationContractsToProjectIds(contracts []*CooperationContract) []int64 {
  182 + var projectIds = make([]int64, 0)
  183 + for i := range contracts {
  184 + var exist = false
  185 + for j := range projectIds {
  186 + if contracts[i].CooperationProjectId == projectIds[j] {
  187 + exist = true
  188 + break
  189 + }
  190 + }
  191 + if !exist {
  192 + projectIds = append(projectIds, contracts[i].CooperationProjectId)
  193 + }
  194 + }
  195 + return projectIds
  196 +}
@@ -49,6 +49,8 @@ type ContractParticipant struct { @@ -49,6 +49,8 @@ type ContractParticipant struct {
49 ContractContent string `json:"contractContent"` 49 ContractContent string `json:"contractContent"`
50 // 支付凭证 50 // 支付凭证
51 PaymentDocument string `json:"paymentDocument"` 51 PaymentDocument string `json:"paymentDocument"`
  52 + // 支付凭证
  53 + PaymentDocuments []*Attachment `json:"paymentDocuments"`
52 // 敏感标识 54 // 敏感标识
53 SensitiveFlag bool `json:"sensitiveFlag"` 55 SensitiveFlag bool `json:"sensitiveFlag"`
54 // 共创合约编号 56 // 共创合约编号
@@ -79,6 +81,7 @@ func NewContractParticipant(u *User, primaryKey string, attachments []*Attachmen @@ -79,6 +81,7 @@ func NewContractParticipant(u *User, primaryKey string, attachments []*Attachmen
79 User: u, 81 User: u,
80 Participant: u.SimpleCopy(), 82 Participant: u.SimpleCopy(),
81 primaryKey: primaryKey, 83 primaryKey: primaryKey,
  84 + PaymentDocuments: make([]*Attachment, 0),
82 } 85 }
83 if len(attachments) > 0 { 86 if len(attachments) > 0 {
84 p.ContractContent = attachments[0].Name 87 p.ContractContent = attachments[0].Name
@@ -91,3 +91,28 @@ func (cooperationProject *CooperationProject) Update(data map[string]interface{} @@ -91,3 +91,28 @@ func (cooperationProject *CooperationProject) Update(data map[string]interface{}
91 cooperationProject.UpdatedAt = time.Now() 91 cooperationProject.UpdatedAt = time.Now()
92 return nil 92 return nil
93 } 93 }
  94 +
  95 +func CooperationProjectsToMap(queryOptions map[string]interface{}, find func(queryOptions map[string]interface{}) (int64, []*CooperationProject, error)) (map[int64]*CooperationProject, error) {
  96 + var result = make(map[int64]*CooperationProject)
  97 + _, projects, err := find(queryOptions)
  98 + if err != nil {
  99 + return nil, err
  100 + }
  101 + for i := range projects {
  102 + result[projects[i].CooperationProjectId] = projects[i]
  103 + }
  104 + return result, nil
  105 +}
  106 +
  107 +func (cooperationProject *CooperationProject) CloneSimple() interface{} {
  108 + var mapResult = map[string]interface{}{
  109 + "cooperationProjectId": cooperationProject.CooperationProjectId,
  110 + "cooperationProjectName": cooperationProject.CooperationProjectName,
  111 + "cooperationProjectDescription": cooperationProject.CooperationProjectDescription,
  112 + "updatedAt": cooperationProject.UpdatedAt.Unix() * 1000,
  113 + }
  114 + if cooperationProject.UpdatedAt.Unix() < 0 {
  115 + mapResult["updatedAt"] = cooperationProject.CreatedAt.Unix() * 1000
  116 + }
  117 + return mapResult
  118 +}
@@ -271,15 +271,6 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfo(quer @@ -271,15 +271,6 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfo(quer
271 key := keyfun(u.CooperationContractNumber, u.Undertaker.UserBaseId) 271 key := keyfun(u.CooperationContractNumber, u.Undertaker.UserBaseId)
272 userSorted = append(userSorted, key) 272 userSorted = append(userSorted, key)
273 mapUser[keyfun(u.CooperationContractNumber, u.Undertaker.UserBaseId)] = domain.NewContractParticipant(u.Undertaker.ToUser(), key, u.Undertaker.ContractAttachment) 273 mapUser[keyfun(u.CooperationContractNumber, u.Undertaker.UserBaseId)] = domain.NewContractParticipant(u.Undertaker.ToUser(), key, u.Undertaker.ContractAttachment)
274 - //if u.Undertaker.Referrer != nil {  
275 - // key = keyfun(u.CooperationContractNumber, u.Undertaker.Referrer.UserBaseId)  
276 - // userSorted = append(userSorted, key)  
277 - // mapUser[keyfun(u.CooperationContractNumber, u.Undertaker.Referrer.UserBaseId)] = domain.NewContractParticipant(u.Undertaker.Referrer.ToUser(), key, u.Undertaker.ContractAttachment)  
278 - //}  
279 - //if u.Undertaker.Salesman != nil {  
280 - // userSorted = append(userSorted, keyfun(u.CooperationContractNumber, u.Undertaker.Salesman.UserBaseId))  
281 - // mapUser[keyfun(u.CooperationContractNumber, u.Undertaker.Salesman.UserBaseId)] = domain.NewContractParticipant(u.Undertaker.Salesman.ToUser(), key, u.Undertaker.ContractAttachment)  
282 - //}  
283 } 274 }
284 275
285 // 2.合约的订单金额 276 // 2.合约的订单金额
@@ -325,10 +316,11 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfo(quer @@ -325,10 +316,11 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfo(quer
325 detail := creditAccounts[i].AccountDetail[j] 316 detail := creditAccounts[i].AccountDetail[j]
326 key := keyfun(detail.CooperationContractNumber, creditAccounts[i].Participator.UserBaseId) 317 key := keyfun(detail.CooperationContractNumber, creditAccounts[i].Participator.UserBaseId)
327 mapCreditAccount[key] = creditAccounts[i] 318 mapCreditAccount[key] = creditAccounts[i]
328 - if v, ok := mapUser[key]; ok && len(v.PaymentDocument) == 0 {  
329 - if len(mapCreditAccount[key].PaymentDocumentAttachments) > 0 { 319 + if v, ok := mapUser[key]; ok {
  320 + if len(v.PaymentDocument) == 0 && len(mapCreditAccount[key].PaymentDocumentAttachments) > 0 {
330 v.PaymentDocument = "查看" 321 v.PaymentDocument = "查看"
331 } 322 }
  323 + v.PaymentDocuments = append(v.PaymentDocuments, creditAccounts[i].PaymentDocumentAttachments...)
332 } 324 }
333 } 325 }
334 } 326 }
@@ -531,3 +523,42 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfoAttac @@ -531,3 +523,42 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfoAttac
531 523
532 return response, nil 524 return response, nil
533 } 525 }
  526 +
  527 +// 个人 - 共创企业
  528 +func (ptr *CooperationStatisticsService) PersonCooperationCompany(queryOptions map[string]interface{}) (interface{}, error) {
  529 + // 参数验证
  530 + var request = struct {
  531 + UserBaseId int64 `json:"userBaseId"`
  532 + }{}
  533 + if err := LoadQueryObject(queryOptions, &request); err != nil {
  534 + return nil, err
  535 + }
  536 + var response = struct {
  537 + OrgIds []int64 `json:"orgIds"`
  538 + }{
  539 + OrgIds: make([]int64, 0),
  540 + }
  541 + undertakerDao, _ := dao.NewCooperationContractUndertakerDao(ptr.transactionContext)
  542 + _, undertakers, _ := undertakerDao.Find(map[string]interface{}{"userBaseId": request.UserBaseId, "offsetLimit": false})
  543 + contractIds := make([]int64, 0)
  544 + if len(undertakers) == 0 {
  545 + return response, nil
  546 + }
  547 + for i := range undertakers {
  548 + contractIds = append(contractIds, undertakers[i].CooperationContractId)
  549 + }
  550 + var mapOrg = make(map[int64]int64)
  551 + contractDao, _ := dao.NewCooperationContractDao(ptr.transactionContext)
  552 + _, contracts, err := contractDao.Find(map[string]interface{}{"cooperationContractIds": contractIds})
  553 + if err != nil {
  554 + return nil, err
  555 + }
  556 + for i := range contracts {
  557 + orgId := contracts[i].Org.OrgId
  558 + if _, ok := mapOrg[orgId]; !ok {
  559 + response.OrgIds = append(response.OrgIds, orgId)
  560 + mapOrg[orgId] = orgId
  561 + }
  562 + }
  563 + return response, nil
  564 +}
@@ -47,6 +47,8 @@ const ( @@ -47,6 +47,8 @@ const (
47 PersonCooperationProjectSharedInfo = "PersonCooperationProjectSharedInfo" 47 PersonCooperationProjectSharedInfo = "PersonCooperationProjectSharedInfo"
48 // 个人 - 共创项目共享信息数据 - 附件 48 // 个人 - 共创项目共享信息数据 - 附件
49 PersonCooperationProjectSharedInfoAttachment = "PersonCooperationProjectSharedInfoAttachment" 49 PersonCooperationProjectSharedInfoAttachment = "PersonCooperationProjectSharedInfoAttachment"
  50 + // 个人 - 共创企业
  51 + PersonCooperationCompany = "PersonCooperationCompany"
50 52
51 // 账期结算单统计 53 // 账期结算单统计
52 CreditAccountStatistics = "CreditAccountStatistics" 54 CreditAccountStatistics = "CreditAccountStatistics"
@@ -107,6 +109,18 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma @@ -107,6 +109,18 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma
107 return nil, err 109 return nil, err
108 } 110 }
109 111
  112 + // 1.1 个人返回合约对应的项目
  113 +
  114 + var mapProject = make(map[int64]*domain.CooperationProject)
  115 + var projectIds = domain.CooperationContractsToProjectIds(contracts)
  116 + if request.UserBaseId > 0 && len(projectIds) > 0 {
  117 + cooperationProjectRepository, _ := repository.NewCooperationProjectRepository(ptr.transactionContext)
  118 + mapProject, err = domain.CooperationProjectsToMap(map[string]interface{}{"cooperationProjectIds": projectIds}, cooperationProjectRepository.Find)
  119 + if err != nil {
  120 + return nil, err
  121 + }
  122 + }
  123 +
110 // 2.根据合约查询分红预算 124 // 2.根据合约查询分红预算
111 orderGoodDao, _ := dao.NewDividendsOrderDao(ptr.transactionContext) 125 orderGoodDao, _ := dao.NewDividendsOrderDao(ptr.transactionContext)
112 dividendsEstimateDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext) 126 dividendsEstimateDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext)
@@ -123,20 +137,12 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma @@ -123,20 +137,12 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma
123 } 137 }
124 resultItem.DividendsOrderAmount, _ = orderGoodDao.CalculateGoodOrderAmount(map[string]interface{}{"orgId": request.OrgId, "cooperationContractNumbers": []string{item.CooperationContractNumber}}) 138 resultItem.DividendsOrderAmount, _ = orderGoodDao.CalculateGoodOrderAmount(map[string]interface{}{"orgId": request.OrgId, "cooperationContractNumbers": []string{item.CooperationContractNumber}})
125 resultItem.DividendsAmount, _ = dividendsEstimateDao.CountDividendsEstimateDividendsAmount(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId, "cooperationContractNumbers": []string{item.CooperationContractNumber}}) 139 resultItem.DividendsAmount, _ = dividendsEstimateDao.CountDividendsEstimateDividendsAmount(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId, "cooperationContractNumbers": []string{item.CooperationContractNumber}})
126 - 140 + if v, ok := mapProject[item.CooperationProjectId]; ok {
  141 + resultItem.Project = v.CloneSimple()
  142 + }
127 results = append(results, resultItem) 143 results = append(results, resultItem)
128 numbers = append(numbers, item.CooperationContractNumber) 144 numbers = append(numbers, item.CooperationContractNumber)
129 } 145 }
130 - //mapCreditAccount, err := ptr.getContractsCreditAccount(numbers)  
131 - //if err != nil {  
132 - // return nil, err  
133 - //}  
134 - //for i := range results {  
135 - // if v, ok := mapCreditAccount[results[i].CooperationContractNumber]; ok {  
136 - // results[i].DividendsAmount = v.SettlementAmount  
137 - // results[i].DividendsOrderAmount = v.GoodAmountCount  
138 - // }  
139 - //}  
140 return results, nil 146 return results, nil
141 } 147 }
142 148
@@ -273,6 +279,8 @@ type searchContractDividendsResult struct { @@ -273,6 +279,8 @@ type searchContractDividendsResult struct {
273 DividendsOrderAmount float64 `json:"dividendsOrderAmount"` 279 DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
274 // 创建时间 280 // 创建时间
275 CreatedAt int64 `json:"createdAt"` 281 CreatedAt int64 `json:"createdAt"`
  282 + // 共创项目数据
  283 + Project interface{} `json:"project"`
276 } 284 }
277 285
278 /*1.2 分红合约详情*/ 286 /*1.2 分红合约详情*/
@@ -306,7 +314,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s @@ -306,7 +314,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s
306 if err != nil { 314 if err != nil {
307 return nil, err 315 return nil, err
308 } 316 }
309 - res["cooperationContract"] = map[string]interface{}{ 317 + mapContract := map[string]interface{}{
310 "cooperationContractDescription": contract.CooperationContractDescription, 318 "cooperationContractDescription": contract.CooperationContractDescription,
311 "cooperationContractId": contract.CooperationContractId, 319 "cooperationContractId": contract.CooperationContractId,
312 "cooperationContractName": contract.CooperationContractName, 320 "cooperationContractName": contract.CooperationContractName,
@@ -314,21 +322,36 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s @@ -314,21 +322,36 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s
314 "createdAt": contract.CreatedAt.Unix() * 1000, 322 "createdAt": contract.CreatedAt.Unix() * 1000,
315 "status": contract.Status, 323 "status": contract.Status,
316 } 324 }
  325 + if request.UserBaseId > 0 {
  326 + // 1.1.合约第一条合同的附件
  327 + undertakerRepository, _ := repository.NewCooperationContractUndertakerRepository(ptr.transactionContext)
  328 + _, undertakers, err := undertakerRepository.Find(map[string]interface{}{"cooperationContractId": contract.CooperationContractId, "userBaseId": request.UserBaseId, "companyId": contract.Company.CompanyId, "orgId": contract.Org.OrgId, "offsetLimit": false})
  329 + if err != nil {
  330 + return nil, err
  331 + }
  332 + for i := range undertakers {
  333 + if len(undertakers[i].Undertaker.ContractAttachment) > 0 && len(undertakers[i].Undertaker.ContractAttachment[0].Url) > 0 {
  334 + mapContract["contractAttachment"] = undertakers[i].Undertaker.ContractAttachment[0]
  335 + }
  336 + }
  337 + }
  338 +
  339 + res["cooperationContract"] = mapContract
317 340
318 // 2.合约分红列表 341 // 2.合约分红列表
319 - creditAccountRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext) 342 + dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
320 queryOptions["cooperationContractNumber"] = contract.CooperationContractNumber 343 queryOptions["cooperationContractNumber"] = contract.CooperationContractNumber
321 queryOptions["orgId"] = contract.Org.OrgId 344 queryOptions["orgId"] = contract.Org.OrgId
322 queryOptions["isCanceled"] = false 345 queryOptions["isCanceled"] = false
323 - _, creditAccounts, err := creditAccountRepository.Find(queryOptions) 346 + _, dividendsEstimates, err := dividendsEstimateRepository.Find(queryOptions)
324 if err != nil { 347 if err != nil {
325 return res, err 348 return res, err
326 } 349 }
327 350
328 // 3.取订单商品列表 351 // 3.取订单商品列表
329 var orderGoodIds []int64 352 var orderGoodIds []int64
330 - for i := range creditAccounts {  
331 - a := creditAccounts[i] 353 + for i := range dividendsEstimates {
  354 + a := dividendsEstimates[i]
332 orderGoodIds = append(orderGoodIds, a.OrderGoodId) 355 orderGoodIds = append(orderGoodIds, a.OrderGoodId)
333 } 356 }
334 var mapOrderGoods = make(map[int64]*domain.OrderGood) 357 var mapOrderGoods = make(map[int64]*domain.OrderGood)
@@ -344,14 +367,14 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s @@ -344,14 +367,14 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s
344 } 367 }
345 368
346 var dividends = make([]interface{}, 0) 369 var dividends = make([]interface{}, 0)
347 - for i := range creditAccounts {  
348 - a := creditAccounts[i] 370 + for i := range dividendsEstimates {
  371 + a := dividendsEstimates[i]
349 // 个人查看的时候只查看自己的分红明细 372 // 个人查看的时候只查看自己的分红明细
350 //if request.UserBaseId!=0 && a.DividendsUser.UserBaseId!=request.UserBaseId{ 373 //if request.UserBaseId!=0 && a.DividendsUser.UserBaseId!=request.UserBaseId{
351 // continue 374 // continue
352 //} 375 //}
353 item := map[string]interface{}{ 376 item := map[string]interface{}{
354 - "creditAccountId": a.DividendsEstimateId, 377 + "dividendsEstimateId": a.DividendsEstimateId,
355 "orderGoodName": "", 378 "orderGoodName": "",
356 "dividendsType": a.DividendsType, 379 "dividendsType": a.DividendsType,
357 "dividendsRatio": 0, 380 "dividendsRatio": 0,
@@ -364,6 +387,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s @@ -364,6 +387,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s
364 "dividendsAccountStatus": a.DividendsAccountStatus, 387 "dividendsAccountStatus": a.DividendsAccountStatus,
365 "dividendsEstimateTime": a.CreatedAt.Unix() * 1000, 388 "dividendsEstimateTime": a.CreatedAt.Unix() * 1000,
366 "orderOrReturnedOrderNum": a.DividendsEstimateOrderNumber, 389 "orderOrReturnedOrderNum": a.DividendsEstimateOrderNumber,
  390 + "creditAccountId": a.CreditAccountId,
367 } 391 }
368 if a.PaymentStatus == 2 { 392 if a.PaymentStatus == 2 {
369 item["dividendsAccountStatus"] = 3 393 item["dividendsAccountStatus"] = 3
@@ -43,4 +43,6 @@ type CooperationContract struct { @@ -43,4 +43,6 @@ type CooperationContract struct {
43 DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"` 43 DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
44 // 更新时间 44 // 更新时间
45 UpdatedAt time.Time `comment:"更新时间"` 45 UpdatedAt time.Time `comment:"更新时间"`
  46 + // 共创项目编号
  47 + CooperationProjectId int64 `comment:"共创项目编号"`
46 } 48 }
@@ -134,5 +134,6 @@ func TransformToCooperationContractDomainModelFromPgModels( @@ -134,5 +134,6 @@ func TransformToCooperationContractDomainModelFromPgModels(
134 CreatedAt: cooperationContractModel.CreatedAt, 134 CreatedAt: cooperationContractModel.CreatedAt,
135 DeletedAt: cooperationContractModel.DeletedAt, 135 DeletedAt: cooperationContractModel.DeletedAt,
136 UpdatedAt: cooperationContractModel.UpdatedAt, 136 UpdatedAt: cooperationContractModel.UpdatedAt,
  137 + CooperationProjectId: cooperationContractModel.CooperationProjectId,
137 }, nil 138 }, nil
138 } 139 }
@@ -44,6 +44,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -44,6 +44,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
44 "created_at", 44 "created_at",
45 "deleted_at", 45 "deleted_at",
46 "updated_at", 46 "updated_at",
  47 + "cooperation_project_id",
47 } 48 }
48 insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) 49 insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
49 insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) 50 insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
@@ -78,6 +79,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -78,6 +79,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
78 &cooperationContract.CreatedAt, 79 &cooperationContract.CreatedAt,
79 &cooperationContract.DeletedAt, 80 &cooperationContract.DeletedAt,
80 &cooperationContract.UpdatedAt, 81 &cooperationContract.UpdatedAt,
  82 + &cooperationContract.CooperationProjectId,
81 ), 83 ),
82 fmt.Sprintf("INSERT INTO cooperation_contracts (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), 84 fmt.Sprintf("INSERT INTO cooperation_contracts (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
83 cooperationContract.CooperationContractId, 85 cooperationContract.CooperationContractId,
@@ -98,6 +100,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -98,6 +100,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
98 cooperationContract.CreatedAt, 100 cooperationContract.CreatedAt,
99 nil, 101 nil,
100 cooperationContract.UpdatedAt, 102 cooperationContract.UpdatedAt,
  103 + cooperationContract.CooperationProjectId,
101 ); err != nil { 104 ); err != nil {
102 return cooperationContract, err 105 return cooperationContract, err
103 } 106 }
@@ -277,6 +280,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -277,6 +280,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
277 &cooperationContract.CreatedAt, 280 &cooperationContract.CreatedAt,
278 &cooperationContract.DeletedAt, 281 &cooperationContract.DeletedAt,
279 &cooperationContract.UpdatedAt, 282 &cooperationContract.UpdatedAt,
  283 + &cooperationContract.CooperationProjectId,
280 ), 284 ),
281 fmt.Sprintf("UPDATE cooperation_contracts SET %s WHERE cooperation_contract_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), 285 fmt.Sprintf("UPDATE cooperation_contracts SET %s WHERE cooperation_contract_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
282 cooperationContract.CooperationContractId, 286 cooperationContract.CooperationContractId,
@@ -297,6 +301,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -297,6 +301,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
297 cooperationContract.CreatedAt, 301 cooperationContract.CreatedAt,
298 nil, 302 nil,
299 cooperationContract.UpdatedAt, 303 cooperationContract.UpdatedAt,
  304 + cooperationContract.CooperationProjectId,
300 cooperationContract.Identify(), 305 cooperationContract.Identify(),
301 ); err != nil { 306 ); err != nil {
302 return cooperationContract, err 307 return cooperationContract, err
@@ -183,6 +183,9 @@ func (repository *CooperationContractUndertakerRepository) Find(queryOptions map @@ -183,6 +183,9 @@ func (repository *CooperationContractUndertakerRepository) Find(queryOptions map
183 var cooperationContractUndertakerModels []*models.CooperationContractUndertaker 183 var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
184 cooperationContractUndertakers := make([]*domain.CooperationContractUndertaker, 0) 184 cooperationContractUndertakers := make([]*domain.CooperationContractUndertaker, 0)
185 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractUndertakerModels), queryOptions) 185 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractUndertakerModels), queryOptions)
  186 + if cooperationContractId, ok := queryOptions["cooperationContractId"]; ok && cooperationContractId.(int64) != 0 {
  187 + query.Where("cooperation_contract_id = ? ", cooperationContractId)
  188 + }
186 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { 189 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
187 query.Where("company->>'companyId' = '?'", companyId) 190 query.Where("company->>'companyId' = '?'", companyId)
188 } 191 }