正在显示
8 个修改的文件
包含
53 行增加
和
2 行删除
@@ -225,6 +225,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | @@ -225,6 +225,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | ||
225 | // 变更分红预算单结算状态 | 225 | // 变更分红预算单结算状态 |
226 | for i, _ := range dividendsEstimates { | 226 | for i, _ := range dividendsEstimates { |
227 | dividendsEstimates[i].DividendsAccountStatus = 2 | 227 | dividendsEstimates[i].DividendsAccountStatus = 2 |
228 | + dividendsEstimates[i].CreditAccountId = creditAccount.CreditAccountId | ||
228 | } | 229 | } |
229 | _, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimates) | 230 | _, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimates) |
230 | if err3 != nil { | 231 | if err3 != nil { |
@@ -47,6 +47,8 @@ type ContractParticipant struct { | @@ -47,6 +47,8 @@ type ContractParticipant struct { | ||
47 | DividendsAmount float64 `json:"dividendsAmount"` | 47 | DividendsAmount float64 `json:"dividendsAmount"` |
48 | // 合同内容 | 48 | // 合同内容 |
49 | ContractContent string `json:"contractContent"` | 49 | ContractContent string `json:"contractContent"` |
50 | + // 支付凭证 | ||
51 | + PaymentDocument string `json:"paymentDocument"` | ||
50 | // 敏感标识 | 52 | // 敏感标识 |
51 | SensitiveFlag bool `json:"sensitiveFlag"` | 53 | SensitiveFlag bool `json:"sensitiveFlag"` |
52 | // 共创合约编号 | 54 | // 共创合约编号 |
@@ -71,6 +71,8 @@ type DividendsEstimate struct { | @@ -71,6 +71,8 @@ type DividendsEstimate struct { | ||
71 | OrderGoodId int64 `json:"orderGoodId"` | 71 | OrderGoodId int64 `json:"orderGoodId"` |
72 | // 订单产品金额 | 72 | // 订单产品金额 |
73 | OrderGoodAmount float64 `json:"orderGoodAmount"` | 73 | OrderGoodAmount float64 `json:"orderGoodAmount"` |
74 | + // 账期结算Id | ||
75 | + CreditAccountId int64 `json:"creditAccountId"` | ||
74 | } | 76 | } |
75 | 77 | ||
76 | type DividendsEstimateRepository interface { | 78 | type DividendsEstimateRepository interface { |
@@ -289,14 +289,47 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfo(quer | @@ -289,14 +289,47 @@ func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfo(quer | ||
289 | }) | 289 | }) |
290 | 290 | ||
291 | // 3.计算合约用户的分红预算金额 | 291 | // 3.计算合约用户的分红预算金额 |
292 | + var mapCreditAccount = make(map[string]*domain.CreditAccount) | ||
293 | + var creditAccountIds = make([]int64, 0) | ||
292 | dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext) | 294 | dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext) |
293 | - _, dividends, err := dividendsEstimateRepository.Find(map[string]interface{}{"cooperationContractNumbers": contractNumbers, "companyId": project.Company.CompanyId, "orgId": project.Org.OrgId, "dividendsAccountStatus": int32(1), "offsetLimit": false}) | 295 | + _, dividends, err := dividendsEstimateRepository.Find(map[string]interface{}{"cooperationContractNumbers": contractNumbers, "companyId": project.Company.CompanyId, "orgId": project.Org.OrgId, "isCanceled": false, "offsetLimit": false}) |
296 | + if err != nil { | ||
297 | + return nil, err | ||
298 | + } | ||
294 | for i := range dividends { | 299 | for i := range dividends { |
295 | d := dividends[i] | 300 | d := dividends[i] |
296 | key := keyfun(d.CooperationContractNumber, d.DividendsUser.UserBaseId) | 301 | key := keyfun(d.CooperationContractNumber, d.DividendsUser.UserBaseId) |
297 | if v, ok := mapUser[key]; ok { | 302 | if v, ok := mapUser[key]; ok { |
298 | v.DividendsAmount += d.DividendsAmount | 303 | v.DividendsAmount += d.DividendsAmount |
299 | } | 304 | } |
305 | + if d.PaymentStatus == 2 && d.CreditAccountId != 0 { | ||
306 | + creditAccountIds = append(creditAccountIds, d.CreditAccountId) | ||
307 | + } | ||
308 | + } | ||
309 | + // 3.1 用户账期结算记录 - 查询是否有支付凭证 | ||
310 | + if len(creditAccountIds) > 0 { | ||
311 | + creditAccountRepository, _ := repository.NewCreditAccountRepository(ptr.transactionContext) | ||
312 | + _, creditAccounts, err := creditAccountRepository.Find(map[string]interface{}{ | ||
313 | + "creditAccountIds": creditAccountIds, | ||
314 | + }) | ||
315 | + if err != nil { | ||
316 | + return nil, err | ||
317 | + } | ||
318 | + for i := range creditAccounts { | ||
319 | + if len(creditAccounts[i].PaymentDocumentAttachments) == 0 { | ||
320 | + continue | ||
321 | + } | ||
322 | + for j := range creditAccounts[i].AccountDetail { | ||
323 | + detail := creditAccounts[i].AccountDetail[j] | ||
324 | + key := keyfun(detail.CooperationContractNumber, creditAccounts[i].Participator.UserBaseId) | ||
325 | + mapCreditAccount[key] = creditAccounts[i] | ||
326 | + if v, ok := mapUser[key]; ok && len(v.PaymentDocument) == 0 { | ||
327 | + if len(mapCreditAccount[key].PaymentDocumentAttachments) > 0 { | ||
328 | + v.PaymentDocument = "查看" | ||
329 | + } | ||
330 | + } | ||
331 | + } | ||
332 | + } | ||
300 | } | 333 | } |
301 | 334 | ||
302 | for _, v := range mapUser { | 335 | for _, v := range mapUser { |
@@ -55,4 +55,6 @@ type DividendsEstimate struct { | @@ -55,4 +55,6 @@ type DividendsEstimate struct { | ||
55 | DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"` | 55 | DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"` |
56 | // 更新时间 | 56 | // 更新时间 |
57 | UpdatedAt time.Time `comment:"更新时间"` | 57 | UpdatedAt time.Time `comment:"更新时间"` |
58 | + // 账期结算Id | ||
59 | + CreditAccountId int64 `comment:"creditAccountId"` | ||
58 | } | 60 | } |
@@ -33,5 +33,6 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel | @@ -33,5 +33,6 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel | ||
33 | CreatedAt: dividendsEstimateModel.CreatedAt, | 33 | CreatedAt: dividendsEstimateModel.CreatedAt, |
34 | DeletedAt: dividendsEstimateModel.DeletedAt, | 34 | DeletedAt: dividendsEstimateModel.DeletedAt, |
35 | UpdatedAt: dividendsEstimateModel.UpdatedAt, | 35 | UpdatedAt: dividendsEstimateModel.UpdatedAt, |
36 | + CreditAccountId: dividendsEstimateModel.CreditAccountId, | ||
36 | }, nil | 37 | }, nil |
37 | } | 38 | } |
@@ -199,8 +199,12 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac | @@ -199,8 +199,12 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac | ||
199 | var creditAccountModels []*models.CreditAccount | 199 | var creditAccountModels []*models.CreditAccount |
200 | creditAccounts := make([]*domain.CreditAccount, 0) | 200 | creditAccounts := make([]*domain.CreditAccount, 0) |
201 | query := sqlbuilder.BuildQuery(tx.Model(&creditAccountModels), queryOptions) | 201 | query := sqlbuilder.BuildQuery(tx.Model(&creditAccountModels), queryOptions) |
202 | + if creditAccountIds, ok := queryOptions["creditAccountIds"]; ok && len(creditAccountIds.([]int64)) > 0 { | ||
203 | + newCreditAccountIds := utils.SliceItoa(creditAccountIds.([]int64)) | ||
204 | + query.Where("credit_account_id in (?)", pg.In(newCreditAccountIds)) | ||
205 | + } | ||
202 | if creditAccountOrderNum, ok := queryOptions["creditAccountOrderNum"]; ok && creditAccountOrderNum != "" { | 206 | if creditAccountOrderNum, ok := queryOptions["creditAccountOrderNum"]; ok && creditAccountOrderNum != "" { |
203 | - query.Where("credit_account_order_num ilike ?", fmt.Sprintf("%%%s%%", creditAccountOrderNum)) | 207 | + query.Where("credit_account_order_num like ?", fmt.Sprintf("%%%s%%", creditAccountOrderNum)) |
204 | } | 208 | } |
205 | if participatorName, ok := queryOptions["participatorName"]; ok && participatorName != "" { | 209 | if participatorName, ok := queryOptions["participatorName"]; ok && participatorName != "" { |
206 | query.Where(`(credit_account.participator->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", participatorName)) | 210 | query.Where(`(credit_account.participator->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", participatorName)) |
@@ -50,6 +50,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -50,6 +50,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
50 | "deleted_at", | 50 | "deleted_at", |
51 | "updated_at", | 51 | "updated_at", |
52 | "cooperation_contract_undertaker_id", | 52 | "cooperation_contract_undertaker_id", |
53 | + "credit_account_id", | ||
53 | } | 54 | } |
54 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) | 55 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) |
55 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) | 56 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) |
@@ -90,6 +91,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -90,6 +91,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
90 | ÷ndsEstimate.DeletedAt, | 91 | ÷ndsEstimate.DeletedAt, |
91 | ÷ndsEstimate.UpdatedAt, | 92 | ÷ndsEstimate.UpdatedAt, |
92 | ÷ndsEstimate.CooperationContractUndertakerId, | 93 | ÷ndsEstimate.CooperationContractUndertakerId, |
94 | + ÷ndsEstimate.CreditAccountId, | ||
93 | ), | 95 | ), |
94 | fmt.Sprintf("INSERT INTO dividends_estimates (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), | 96 | fmt.Sprintf("INSERT INTO dividends_estimates (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), |
95 | dividendsEstimate.DividendsEstimateId, | 97 | dividendsEstimate.DividendsEstimateId, |
@@ -116,6 +118,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -116,6 +118,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
116 | nil, | 118 | nil, |
117 | dividendsEstimate.UpdatedAt, | 119 | dividendsEstimate.UpdatedAt, |
118 | dividendsEstimate.CooperationContractUndertakerId, | 120 | dividendsEstimate.CooperationContractUndertakerId, |
121 | + dividendsEstimate.CreditAccountId, | ||
119 | ); err != nil { | 122 | ); err != nil { |
120 | return dividendsEstimate, err | 123 | return dividendsEstimate, err |
121 | } | 124 | } |
@@ -146,6 +149,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -146,6 +149,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
146 | ÷ndsEstimate.DeletedAt, | 149 | ÷ndsEstimate.DeletedAt, |
147 | ÷ndsEstimate.UpdatedAt, | 150 | ÷ndsEstimate.UpdatedAt, |
148 | ÷ndsEstimate.CooperationContractUndertakerId, | 151 | ÷ndsEstimate.CooperationContractUndertakerId, |
152 | + dividendsEstimate.CreditAccountId, | ||
149 | ), | 153 | ), |
150 | fmt.Sprintf("UPDATE dividends_estimates SET %s WHERE dividends_estimate_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), | 154 | fmt.Sprintf("UPDATE dividends_estimates SET %s WHERE dividends_estimate_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), |
151 | dividendsEstimate.DividendsEstimateId, | 155 | dividendsEstimate.DividendsEstimateId, |
@@ -172,6 +176,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -172,6 +176,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
172 | nil, | 176 | nil, |
173 | dividendsEstimate.UpdatedAt, | 177 | dividendsEstimate.UpdatedAt, |
174 | dividendsEstimate.CooperationContractUndertakerId, | 178 | dividendsEstimate.CooperationContractUndertakerId, |
179 | + dividendsEstimate.CreditAccountId, | ||
175 | dividendsEstimate.Identify(), | 180 | dividendsEstimate.Identify(), |
176 | ); err != nil { | 181 | ); err != nil { |
177 | return dividendsEstimate, err | 182 | return dividendsEstimate, err |
@@ -266,6 +271,7 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* | @@ -266,6 +271,7 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* | ||
266 | DeletedAt: dividendsEstimate.DeletedAt, | 271 | DeletedAt: dividendsEstimate.DeletedAt, |
267 | UpdatedAt: time.Now(), | 272 | UpdatedAt: time.Now(), |
268 | CooperationContractUndertakerId: dividendsEstimate.CooperationContractUndertakerId, | 273 | CooperationContractUndertakerId: dividendsEstimate.CooperationContractUndertakerId, |
274 | + CreditAccountId: dividendsEstimate.CreditAccountId, | ||
269 | }) | 275 | }) |
270 | } | 276 | } |
271 | if _, err := tx.Model(÷ndsEstimateModels).WherePK().Update(); err != nil { | 277 | if _, err := tx.Model(÷ndsEstimateModels).WherePK().Update(); err != nil { |
-
请 注册 或 登录 后发表评论