|
@@ -107,6 +107,18 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
@@ -107,6 +107,18 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
107
|
return nil, err
|
107
|
return nil, err
|
|
108
|
}
|
108
|
}
|
|
109
|
|
109
|
|
|
|
|
110
|
+ // 1.1 个人返回合约对应的项目
|
|
|
|
111
|
+
|
|
|
|
112
|
+ var mapProject = make(map[int64]*domain.CooperationProject)
|
|
|
|
113
|
+ var projectIds = domain.CooperationContractsToProjectIds(contracts)
|
|
|
|
114
|
+ if request.UserBaseId > 0 && len(projectIds) > 0 {
|
|
|
|
115
|
+ cooperationProjectRepository, _ := repository.NewCooperationProjectRepository(ptr.transactionContext)
|
|
|
|
116
|
+ mapProject, err = domain.CooperationProjectsToMap(map[string]interface{}{"cooperationProjectIds": projectIds}, cooperationProjectRepository.Find)
|
|
|
|
117
|
+ if err != nil {
|
|
|
|
118
|
+ return nil, err
|
|
|
|
119
|
+ }
|
|
|
|
120
|
+ }
|
|
|
|
121
|
+
|
|
110
|
// 2.根据合约查询分红预算
|
122
|
// 2.根据合约查询分红预算
|
|
111
|
orderGoodDao, _ := dao.NewDividendsOrderDao(ptr.transactionContext)
|
123
|
orderGoodDao, _ := dao.NewDividendsOrderDao(ptr.transactionContext)
|
|
112
|
dividendsEstimateDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext)
|
124
|
dividendsEstimateDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext)
|
|
@@ -123,20 +135,12 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
@@ -123,20 +135,12 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
123
|
}
|
135
|
}
|
|
124
|
resultItem.DividendsOrderAmount, _ = orderGoodDao.CalculateGoodOrderAmount(map[string]interface{}{"orgId": request.OrgId, "cooperationContractNumbers": []string{item.CooperationContractNumber}})
|
136
|
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}})
|
137
|
resultItem.DividendsAmount, _ = dividendsEstimateDao.CountDividendsEstimateDividendsAmount(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId, "cooperationContractNumbers": []string{item.CooperationContractNumber}})
|
|
126
|
-
|
138
|
+ if v, ok := mapProject[item.CooperationProjectId]; ok {
|
|
|
|
139
|
+ resultItem.Project = v.CloneSimple()
|
|
|
|
140
|
+ }
|
|
127
|
results = append(results, resultItem)
|
141
|
results = append(results, resultItem)
|
|
128
|
numbers = append(numbers, item.CooperationContractNumber)
|
142
|
numbers = append(numbers, item.CooperationContractNumber)
|
|
129
|
}
|
143
|
}
|
|
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
|
144
|
return results, nil
|
|
141
|
}
|
145
|
}
|
|
142
|
|
146
|
|
|
@@ -273,6 +277,8 @@ type searchContractDividendsResult struct { |
|
@@ -273,6 +277,8 @@ type searchContractDividendsResult struct { |
|
273
|
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
|
277
|
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
|
|
274
|
// 创建时间
|
278
|
// 创建时间
|
|
275
|
CreatedAt int64 `json:"createdAt"`
|
279
|
CreatedAt int64 `json:"createdAt"`
|
|
|
|
280
|
+ // 共创项目数据
|
|
|
|
281
|
+ Project interface{} `json:"project"`
|
|
276
|
}
|
282
|
}
|
|
277
|
|
283
|
|
|
278
|
/*1.2 分红合约详情*/
|
284
|
/*1.2 分红合约详情*/
|
|
@@ -306,7 +312,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
@@ -306,7 +312,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
306
|
if err != nil {
|
312
|
if err != nil {
|
|
307
|
return nil, err
|
313
|
return nil, err
|
|
308
|
}
|
314
|
}
|
|
309
|
- res["cooperationContract"] = map[string]interface{}{
|
315
|
+ mapContract := map[string]interface{}{
|
|
310
|
"cooperationContractDescription": contract.CooperationContractDescription,
|
316
|
"cooperationContractDescription": contract.CooperationContractDescription,
|
|
311
|
"cooperationContractId": contract.CooperationContractId,
|
317
|
"cooperationContractId": contract.CooperationContractId,
|
|
312
|
"cooperationContractName": contract.CooperationContractName,
|
318
|
"cooperationContractName": contract.CooperationContractName,
|
|
@@ -314,21 +320,36 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
@@ -314,21 +320,36 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
314
|
"createdAt": contract.CreatedAt.Unix() * 1000,
|
320
|
"createdAt": contract.CreatedAt.Unix() * 1000,
|
|
315
|
"status": contract.Status,
|
321
|
"status": contract.Status,
|
|
316
|
}
|
322
|
}
|
|
|
|
323
|
+ if request.UserBaseId > 0 {
|
|
|
|
324
|
+ // 1.1.合约第一条合同的附件
|
|
|
|
325
|
+ undertakerRepository, _ := repository.NewCooperationContractUndertakerRepository(ptr.transactionContext)
|
|
|
|
326
|
+ _, undertakers, err := undertakerRepository.Find(map[string]interface{}{"cooperationContractId": contract.CooperationContractId, "userBaseId": request.UserBaseId, "companyId": contract.Company.CompanyId, "orgId": contract.Org.OrgId, "offsetLimit": false})
|
|
|
|
327
|
+ if err != nil {
|
|
|
|
328
|
+ return nil, err
|
|
|
|
329
|
+ }
|
|
|
|
330
|
+ for i := range undertakers {
|
|
|
|
331
|
+ if len(undertakers[i].Undertaker.ContractAttachment) > 0 && len(undertakers[i].Undertaker.ContractAttachment[0].Url) > 0 {
|
|
|
|
332
|
+ mapContract["contractAttachment"] = undertakers[i].Undertaker.ContractAttachment[0]
|
|
|
|
333
|
+ }
|
|
|
|
334
|
+ }
|
|
|
|
335
|
+ }
|
|
|
|
336
|
+
|
|
|
|
337
|
+ res["cooperationContract"] = mapContract
|
|
317
|
|
338
|
|
|
318
|
// 2.合约分红列表
|
339
|
// 2.合约分红列表
|
|
319
|
- creditAccountRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
|
340
|
+ dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
|
|
320
|
queryOptions["cooperationContractNumber"] = contract.CooperationContractNumber
|
341
|
queryOptions["cooperationContractNumber"] = contract.CooperationContractNumber
|
|
321
|
queryOptions["orgId"] = contract.Org.OrgId
|
342
|
queryOptions["orgId"] = contract.Org.OrgId
|
|
322
|
queryOptions["isCanceled"] = false
|
343
|
queryOptions["isCanceled"] = false
|
|
323
|
- _, creditAccounts, err := creditAccountRepository.Find(queryOptions)
|
344
|
+ _, dividendsEstimates, err := dividendsEstimateRepository.Find(queryOptions)
|
|
324
|
if err != nil {
|
345
|
if err != nil {
|
|
325
|
return res, err
|
346
|
return res, err
|
|
326
|
}
|
347
|
}
|
|
327
|
|
348
|
|
|
328
|
// 3.取订单商品列表
|
349
|
// 3.取订单商品列表
|
|
329
|
var orderGoodIds []int64
|
350
|
var orderGoodIds []int64
|
|
330
|
- for i := range creditAccounts {
|
|
|
|
331
|
- a := creditAccounts[i]
|
351
|
+ for i := range dividendsEstimates {
|
|
|
|
352
|
+ a := dividendsEstimates[i]
|
|
332
|
orderGoodIds = append(orderGoodIds, a.OrderGoodId)
|
353
|
orderGoodIds = append(orderGoodIds, a.OrderGoodId)
|
|
333
|
}
|
354
|
}
|
|
334
|
var mapOrderGoods = make(map[int64]*domain.OrderGood)
|
355
|
var mapOrderGoods = make(map[int64]*domain.OrderGood)
|
|
@@ -344,18 +365,18 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
@@ -344,18 +365,18 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
344
|
}
|
365
|
}
|
|
345
|
|
366
|
|
|
346
|
var dividends = make([]interface{}, 0)
|
367
|
var dividends = make([]interface{}, 0)
|
|
347
|
- for i := range creditAccounts {
|
|
|
|
348
|
- a := creditAccounts[i]
|
368
|
+ for i := range dividendsEstimates {
|
|
|
|
369
|
+ a := dividendsEstimates[i]
|
|
349
|
// 个人查看的时候只查看自己的分红明细
|
370
|
// 个人查看的时候只查看自己的分红明细
|
|
350
|
//if request.UserBaseId!=0 && a.DividendsUser.UserBaseId!=request.UserBaseId{
|
371
|
//if request.UserBaseId!=0 && a.DividendsUser.UserBaseId!=request.UserBaseId{
|
|
351
|
// continue
|
372
|
// continue
|
|
352
|
//}
|
373
|
//}
|
|
353
|
item := map[string]interface{}{
|
374
|
item := map[string]interface{}{
|
|
354
|
- "creditAccountId": a.DividendsEstimateId,
|
|
|
|
355
|
- "orderGoodName": "",
|
|
|
|
356
|
- "dividendsType": a.DividendsType,
|
|
|
|
357
|
- "dividendsRatio": 0,
|
|
|
|
358
|
- "dividendsAmount": a.DividendsAmount,
|
375
|
+ "dividendsEstimateId": a.DividendsEstimateId,
|
|
|
|
376
|
+ "orderGoodName": "",
|
|
|
|
377
|
+ "dividendsType": a.DividendsType,
|
|
|
|
378
|
+ "dividendsRatio": 0,
|
|
|
|
379
|
+ "dividendsAmount": a.DividendsAmount,
|
|
359
|
"dividendsUser": map[string]interface{}{
|
380
|
"dividendsUser": map[string]interface{}{
|
|
360
|
"userInfo": a.DividendsUser.UserInfo,
|
381
|
"userInfo": a.DividendsUser.UserInfo,
|
|
361
|
"userId": a.DividendsUser.UserId,
|
382
|
"userId": a.DividendsUser.UserId,
|
|
@@ -364,6 +385,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
@@ -364,6 +385,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
364
|
"dividendsAccountStatus": a.DividendsAccountStatus,
|
385
|
"dividendsAccountStatus": a.DividendsAccountStatus,
|
|
365
|
"dividendsEstimateTime": a.CreatedAt.Unix() * 1000,
|
386
|
"dividendsEstimateTime": a.CreatedAt.Unix() * 1000,
|
|
366
|
"orderOrReturnedOrderNum": a.DividendsEstimateOrderNumber,
|
387
|
"orderOrReturnedOrderNum": a.DividendsEstimateOrderNumber,
|
|
|
|
388
|
+ "creditAccountId": a.CreditAccountId,
|
|
367
|
}
|
389
|
}
|
|
368
|
if a.PaymentStatus == 2 {
|
390
|
if a.PaymentStatus == 2 {
|
|
369
|
item["dividendsAccountStatus"] = 3
|
391
|
item["dividendsAccountStatus"] = 3
|