作者 yangfu

Merge branch 'test'

@@ -55,6 +55,8 @@ type ContractParticipant struct { @@ -55,6 +55,8 @@ type ContractParticipant struct {
55 SensitiveFlag bool `json:"sensitiveFlag"` 55 SensitiveFlag bool `json:"sensitiveFlag"`
56 // 共创合约编号 56 // 共创合约编号
57 primaryKey string `json:"key"` 57 primaryKey string `json:"key"`
  58 + // 支付凭证去重
  59 + duplicatePaymentDocuments map[string]struct{}
58 } 60 }
59 61
60 func (u *User) SimpleCopy() map[string]interface{} { 62 func (u *User) SimpleCopy() map[string]interface{} {
@@ -82,12 +84,21 @@ func NewContractParticipant(u *User, primaryKey string, attachments []*Attachmen @@ -82,12 +84,21 @@ func NewContractParticipant(u *User, primaryKey string, attachments []*Attachmen
82 Participant: u.SimpleCopy(), 84 Participant: u.SimpleCopy(),
83 primaryKey: primaryKey, 85 primaryKey: primaryKey,
84 PaymentDocuments: make([]*Attachment, 0), 86 PaymentDocuments: make([]*Attachment, 0),
  87 + duplicatePaymentDocuments: make(map[string]struct{}),
85 } 88 }
86 if len(attachments) > 0 { 89 if len(attachments) > 0 {
87 p.ContractContent = attachments[0].Name 90 p.ContractContent = attachments[0].Name
88 } 91 }
89 return p 92 return p
90 } 93 }
  94 +func (cp *ContractParticipant) AppendAttachments(attachments []*Attachment) {
  95 + for i := range attachments {
  96 + if _, ok := cp.duplicatePaymentDocuments[attachments[i].Url]; !ok {
  97 + cp.duplicatePaymentDocuments[attachments[i].Url] = struct{}{}
  98 + cp.PaymentDocuments = append(cp.PaymentDocuments, attachments[i])
  99 + }
  100 + }
  101 +}
91 102
92 func (cp *ContractParticipant) Complete(userBaseId int64, sensitive bool) *ContractParticipant { 103 func (cp *ContractParticipant) Complete(userBaseId int64, sensitive bool) *ContractParticipant {
93 cp.SensitiveFlag = false 104 cp.SensitiveFlag = false
@@ -320,7 +320,7 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfo(quer @@ -320,7 +320,7 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfo(quer
320 if len(v.PaymentDocument) == 0 && len(mapCreditAccount[key].PaymentDocumentAttachments) > 0 { 320 if len(v.PaymentDocument) == 0 && len(mapCreditAccount[key].PaymentDocumentAttachments) > 0 {
321 v.PaymentDocument = "查看" 321 v.PaymentDocument = "查看"
322 } 322 }
323 - v.PaymentDocuments = append(v.PaymentDocuments, creditAccounts[i].PaymentDocumentAttachments...) 323 + v.AppendAttachments(creditAccounts[i].PaymentDocumentAttachments)
324 } 324 }
325 } 325 }
326 } 326 }
@@ -885,6 +885,7 @@ func (repository *CooperationContractRepository) UpdateOne(cooperationContract * @@ -885,6 +885,7 @@ func (repository *CooperationContractRepository) UpdateOne(cooperationContract *
885 CreatedAt: cooperationContract.CreatedAt, 885 CreatedAt: cooperationContract.CreatedAt,
886 DeletedAt: cooperationContract.DeletedAt, 886 DeletedAt: cooperationContract.DeletedAt,
887 UpdatedAt: time.Now(), 887 UpdatedAt: time.Now(),
  888 + CooperationProjectId: cooperationContract.CooperationProjectId,
888 } 889 }
889 if _, err := tx.Model(cooperationContractModel).WherePK().Update(); err != nil { 890 if _, err := tx.Model(cooperationContractModel).WherePK().Update(); err != nil {
890 return nil, err 891 return nil, err
@@ -915,6 +916,7 @@ func (repository *CooperationContractRepository) UpdateMany(cooperationContracts @@ -915,6 +916,7 @@ func (repository *CooperationContractRepository) UpdateMany(cooperationContracts
915 CreatedAt: cooperationContract.CreatedAt, 916 CreatedAt: cooperationContract.CreatedAt,
916 DeletedAt: cooperationContract.DeletedAt, 917 DeletedAt: cooperationContract.DeletedAt,
917 UpdatedAt: time.Now(), 918 UpdatedAt: time.Now(),
  919 + CooperationProjectId: cooperationContract.CooperationProjectId,
918 }) 920 })
919 } 921 }
920 if _, err := tx.Model(&cooperationContractModels).WherePK().Update(); err != nil { 922 if _, err := tx.Model(&cooperationContractModels).WherePK().Update(); err != nil {