...
|
...
|
@@ -93,7 +93,7 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
|
var contracts []*domain.CooperationContract
|
|
|
var err error
|
|
|
if request.UserBaseId > 0 {
|
|
|
contracts, err = ptr.getUserContracts(request.UserBaseId, queryOptions)
|
|
|
contracts, err = ptr.getUserContracts(request.OrgId, request.UserBaseId, queryOptions)
|
|
|
} else if request.OrgId > 0 {
|
|
|
queryOptions["orgId"] = request.OrgId
|
|
|
contracts, err = ptr.getCompanyContracts(request.OrgId, request.UserId, queryOptions)
|
...
|
...
|
@@ -103,6 +103,8 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
|
}
|
|
|
|
|
|
// 2.根据合约查询分红预算
|
|
|
orderGoodDao, _ := dao.NewDividendsOrderDao(ptr.transactionContext)
|
|
|
dividendsEstimateDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext)
|
|
|
var numbers []string
|
|
|
var results = make([]*searchContractDividendsResult, 0)
|
|
|
for i := range contracts {
|
...
|
...
|
@@ -114,31 +116,34 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
|
Status: item.Status,
|
|
|
CreatedAt: item.CreatedAt.Unix() * 1000,
|
|
|
}
|
|
|
resultItem.DividendsOrderAmount, _ = orderGoodDao.CalculateGoodOrderAmount(map[string]interface{}{"orgId": request.OrgId, "cooperationContractNumbers": []string{item.CooperationContractNumber}})
|
|
|
resultItem.DividendsAmount, _ = dividendsEstimateDao.CountDividendsEstimateDividendsAmount(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId, "cooperationContractNumbers": []string{item.CooperationContractNumber}})
|
|
|
|
|
|
results = append(results, resultItem)
|
|
|
numbers = append(numbers, item.CooperationContractNumber)
|
|
|
}
|
|
|
mapCreditAccount, err := ptr.getContractsCreditAccount(numbers)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
for i := range results {
|
|
|
if v, ok := mapCreditAccount[results[i].CooperationContractNumber]; ok {
|
|
|
results[i].DividendsAmount = v.SettlementAmount
|
|
|
results[i].DividendsOrderAmount = v.GoodAmountCount
|
|
|
}
|
|
|
}
|
|
|
//mapCreditAccount, err := ptr.getContractsCreditAccount(numbers)
|
|
|
//if err != nil {
|
|
|
// return nil, err
|
|
|
//}
|
|
|
//for i := range results {
|
|
|
// if v, ok := mapCreditAccount[results[i].CooperationContractNumber]; ok {
|
|
|
// results[i].DividendsAmount = v.SettlementAmount
|
|
|
// results[i].DividendsOrderAmount = v.GoodAmountCount
|
|
|
// }
|
|
|
//}
|
|
|
return results, nil
|
|
|
}
|
|
|
|
|
|
// getUserContracts 获取用户的合约列表
|
|
|
//
|
|
|
// p1 p1_desc
|
|
|
func (ptr *CooperationStatisticsService) getUserContracts(userBaseId int64, queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {
|
|
|
func (ptr *CooperationStatisticsService) getUserContracts(orgId, userBaseId int64, queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {
|
|
|
var contracts = make([]*domain.CooperationContract, 0)
|
|
|
if userBaseId == 0 {
|
|
|
return contracts, nil
|
|
|
}
|
|
|
contractNumbers, err := ptr.getRelevantContracts(map[string]interface{}{"userBaseId": userBaseId})
|
|
|
contractNumbers, err := ptr.getRelevantContracts(map[string]interface{}{"orgId": orgId, "userBaseId": userBaseId})
|
|
|
if len(contractNumbers) == 0 {
|
|
|
return contracts, nil
|
|
|
}
|
...
|
...
|
|