|
@@ -9,7 +9,6 @@ import ( |
|
@@ -9,7 +9,6 @@ import ( |
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
|
12
|
- "strconv"
|
|
|
13
|
"time"
|
12
|
"time"
|
14
|
)
|
13
|
)
|
15
|
|
14
|
|
|
@@ -297,7 +296,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
@@ -297,7 +296,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
297
|
}
|
296
|
}
|
298
|
|
297
|
|
299
|
// 2.合约分红列表
|
298
|
// 2.合约分红列表
|
300
|
- creditAccountRepository, _ := repository.NewCreditAccountRepository(ptr.transactionContext)
|
299
|
+ creditAccountRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
|
301
|
queryOptions["cooperationContractNumber"] = contract.CooperationContractNumber
|
300
|
queryOptions["cooperationContractNumber"] = contract.CooperationContractNumber
|
302
|
_, creditAccounts, err := creditAccountRepository.Find(queryOptions)
|
301
|
_, creditAccounts, err := creditAccountRepository.Find(queryOptions)
|
303
|
if err != nil {
|
302
|
if err != nil {
|
|
@@ -308,11 +307,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
@@ -308,11 +307,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
308
|
var orderGoodIds []int64
|
307
|
var orderGoodIds []int64
|
309
|
for i := range creditAccounts {
|
308
|
for i := range creditAccounts {
|
310
|
a := creditAccounts[i]
|
309
|
a := creditAccounts[i]
|
311
|
- for j := range a.AccountDetail {
|
|
|
312
|
- if a.AccountDetail[j].OrderGoodId > 0 {
|
|
|
313
|
- orderGoodIds = append(orderGoodIds, a.AccountDetail[j].OrderGoodId)
|
|
|
314
|
- }
|
|
|
315
|
- }
|
310
|
+ orderGoodIds = append(orderGoodIds, a.OrderGoodId)
|
316
|
}
|
311
|
}
|
317
|
var mapOrderGoods = make(map[int64]*domain.OrderGood)
|
312
|
var mapOrderGoods = make(map[int64]*domain.OrderGood)
|
318
|
if len(orderGoodIds) > 0 {
|
313
|
if len(orderGoodIds) > 0 {
|
|
@@ -329,35 +324,30 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
@@ -329,35 +324,30 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
329
|
var dividends = make([]interface{}, 0)
|
324
|
var dividends = make([]interface{}, 0)
|
330
|
for i := range creditAccounts {
|
325
|
for i := range creditAccounts {
|
331
|
a := creditAccounts[i]
|
326
|
a := creditAccounts[i]
|
332
|
- for j := range a.AccountDetail {
|
|
|
333
|
- participateType, _ := strconv.Atoi(a.ParticipateType)
|
|
|
334
|
- detail := a.AccountDetail[j]
|
|
|
335
|
- item := map[string]interface{}{
|
|
|
336
|
- "creditAccountId": a.CreditAccountId,
|
|
|
337
|
- "orderGoodName": "",
|
|
|
338
|
- "dividendsType": 0,
|
|
|
339
|
- "dividendsRatio": 0,
|
|
|
340
|
- "dividendsAmount": detail.DividendsAmount,
|
|
|
341
|
- "dividendsUser": map[string]interface{}{
|
|
|
342
|
- "userInfo": a.Participator.UserInfo,
|
|
|
343
|
- "userId": a.Participator.UserId,
|
|
|
344
|
- },
|
|
|
345
|
- "dividendsParticipateType": participateType,
|
|
|
346
|
- "dividendsAccountStatus": a.PaymentStatus,
|
|
|
347
|
- "dividendsEstimateTime": a.CreatedAt.Unix() * 1000,
|
|
|
348
|
- "orderOrReturnedOrderNum": a.CreditAccountOrderNum,
|
|
|
349
|
- }
|
|
|
350
|
- if detail.OrderGoodAmount > 0 {
|
|
|
351
|
- item["dividendsRatio"] = utils.Round(detail.DividendsAmount/detail.OrderGoodAmount*100, 2)
|
|
|
352
|
- }
|
|
|
353
|
- item["dividendsType"] = a.AccountDetail[j].DividendsType
|
|
|
354
|
- if v, ok := mapOrderGoods[detail.OrderGoodId]; ok {
|
|
|
355
|
- item["orderGoodName"] = v.OrderGoodName
|
|
|
356
|
- }
|
|
|
357
|
|
327
|
|
358
|
- dividends = append(dividends, item)
|
328
|
+ participateType := a.DividendsParticipateType
|
|
|
329
|
+ item := map[string]interface{}{
|
|
|
330
|
+ "creditAccountId": a.DividendsEstimateId,
|
|
|
331
|
+ "orderGoodName": "",
|
|
|
332
|
+ "dividendsType": a.DividendsType,
|
|
|
333
|
+ "dividendsRatio": 0,
|
|
|
334
|
+ "dividendsAmount": a.DividendsAmount,
|
|
|
335
|
+ "dividendsUser": map[string]interface{}{
|
|
|
336
|
+ "userInfo": a.DividendsUser.UserInfo,
|
|
|
337
|
+ "userId": a.DividendsUser.UserId,
|
|
|
338
|
+ },
|
|
|
339
|
+ "dividendsParticipateType": participateType,
|
|
|
340
|
+ "dividendsAccountStatus": 0, //TODO:分红状态
|
|
|
341
|
+ "dividendsEstimateTime": a.CreatedAt.Unix() * 1000,
|
|
|
342
|
+ "orderOrReturnedOrderNum": a.DividendsEstimateOrderNumber,
|
359
|
}
|
343
|
}
|
360
|
-
|
344
|
+ if v, ok := mapOrderGoods[a.OrderGoodId]; ok {
|
|
|
345
|
+ item["orderGoodName"] = v.OrderGoodName
|
|
|
346
|
+ if v.OrderGoodAmount > 0 {
|
|
|
347
|
+ item["dividendsRatio"] = utils.Round(a.DividendsAmount/v.OrderGoodAmount*100, 2)
|
|
|
348
|
+ }
|
|
|
349
|
+ }
|
|
|
350
|
+ dividends = append(dividends, item)
|
361
|
}
|
351
|
}
|
362
|
res["dividends"] = dividends
|
352
|
res["dividends"] = dividends
|
363
|
return res, nil
|
353
|
return res, nil
|