|
@@ -51,32 +51,31 @@ func (ptr *CooperationStatisticsService) cooperationCompanyStatistics(userBaseId |
|
@@ -51,32 +51,31 @@ func (ptr *CooperationStatisticsService) cooperationCompanyStatistics(userBaseId |
51
|
}
|
51
|
}
|
52
|
|
52
|
|
53
|
// 2.相关合约统计
|
53
|
// 2.相关合约统计
|
54
|
- cooperationContractRelevantRepository, _ := dao.NewCooperationContractUndertakerDao(ptr.transactionContext)
|
|
|
55
|
- cooperationContractCount, _, err := cooperationContractRelevantRepository.Find(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId,
|
|
|
56
|
- "limit": 1})
|
54
|
+ contractInfo, err := ptr.PersonCooperationContractStatistics(map[string]interface{}{
|
|
|
55
|
+ "orgId": orgId,
|
|
|
56
|
+ "userBaseId": userBaseId,
|
|
|
57
|
+ })
|
57
|
if err != nil {
|
58
|
if err != nil {
|
58
|
return nil, err
|
59
|
return nil, err
|
59
|
}
|
60
|
}
|
60
|
-
|
|
|
61
|
- // 3.个人分红统计
|
|
|
62
|
- //creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
|
|
|
63
|
- //var allDividends = &CreditAccountStatisticsResponse{}
|
|
|
64
|
- //if err := creditAccountDao.DividendsStatistics(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId}, allDividends); err != nil {
|
61
|
+ //cooperationContractRelevantRepository, _ := dao.NewCooperationContractUndertakerDao(ptr.transactionContext)
|
|
|
62
|
+ //cooperationContractCount, _, err := cooperationContractRelevantRepository.Find(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId,
|
|
|
63
|
+ // "limit": 100,"distinctColumnContractNumber":1})
|
|
|
64
|
+ //if err != nil {
|
65
|
// return nil, err
|
65
|
// return nil, err
|
66
|
//}
|
66
|
//}
|
67
|
- //allDividends.Accounting = allDividends.Total - allDividends.Accounted
|
|
|
68
|
|
67
|
|
|
|
68
|
+ // 3.个人分红统计
|
69
|
creditAccountDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext)
|
69
|
creditAccountDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext)
|
70
|
var allDividends float64
|
70
|
var allDividends float64
|
71
|
if allDividends, err = creditAccountDao.CountDividendsEstimateDividendsAmount(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId}); err != nil {
|
71
|
if allDividends, err = creditAccountDao.CountDividendsEstimateDividendsAmount(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId}); err != nil {
|
72
|
return nil, err
|
72
|
return nil, err
|
73
|
}
|
73
|
}
|
74
|
- //allDividends.Accounting = allDividends.Total - allDividends.Accounted
|
|
|
75
|
|
74
|
|
76
|
var ret = &cooperationCompanyStatisticsResponse{
|
75
|
var ret = &cooperationCompanyStatisticsResponse{
|
77
|
OrgId: orgId,
|
76
|
OrgId: orgId,
|
78
|
CooperationProjectCount: cooperationProjectCount,
|
77
|
CooperationProjectCount: cooperationProjectCount,
|
79
|
- CooperationContractCount: cooperationContractCount,
|
78
|
+ CooperationContractCount: int64(contractInfo.ContractSum),
|
80
|
DividendsIncome: utils.Round(allDividends, 2),
|
79
|
DividendsIncome: utils.Round(allDividends, 2),
|
81
|
}
|
80
|
}
|
82
|
return ret, nil
|
81
|
return ret, nil
|
|
@@ -96,10 +95,11 @@ type cooperationCompanyStatisticsResponse struct { |
|
@@ -96,10 +95,11 @@ type cooperationCompanyStatisticsResponse struct { |
96
|
}
|
95
|
}
|
97
|
|
96
|
|
98
|
// 个人-用户合约统计
|
97
|
// 个人-用户合约统计
|
99
|
-func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(queryOptions map[string]interface{}) (interface{}, error) {
|
98
|
+func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(queryOptions map[string]interface{}) (*ContractSum, error) {
|
100
|
// 参数验证
|
99
|
// 参数验证
|
101
|
var request = struct {
|
100
|
var request = struct {
|
102
|
UserBaseId int64 `json:"userBaseId" valid:"Required"`
|
101
|
UserBaseId int64 `json:"userBaseId" valid:"Required"`
|
|
|
102
|
+ OrgId int64 `json:"orgId"`
|
103
|
}{}
|
103
|
}{}
|
104
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
104
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
105
|
return nil, err
|
105
|
return nil, err
|
|
@@ -112,10 +112,7 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que |
|
@@ -112,10 +112,7 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que |
112
|
return nil, nil
|
112
|
return nil, nil
|
113
|
}
|
113
|
}
|
114
|
|
114
|
|
115
|
- var response = struct {
|
|
|
116
|
- ContractSum int `json:"contractSum"`
|
|
|
117
|
- ContractStoppedSum int `json:"contractStoppedSum"`
|
|
|
118
|
- }{}
|
115
|
+ var response = &ContractSum{}
|
119
|
if len(contractUndertakers) == 0 {
|
116
|
if len(contractUndertakers) == 0 {
|
120
|
return response, nil
|
117
|
return response, nil
|
121
|
}
|
118
|
}
|
|
@@ -128,6 +125,11 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que |
|
@@ -128,6 +125,11 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que |
128
|
return response, nil
|
125
|
return response, nil
|
129
|
}
|
126
|
}
|
130
|
|
127
|
|
|
|
128
|
+type ContractSum struct {
|
|
|
129
|
+ ContractSum int `json:"contractSum"`
|
|
|
130
|
+ ContractStoppedSum int `json:"contractStoppedSum"`
|
|
|
131
|
+}
|
|
|
132
|
+
|
131
|
func (ptr *CooperationStatisticsService) cooperationContractCount(contractIds []int64, status int) int {
|
133
|
func (ptr *CooperationStatisticsService) cooperationContractCount(contractIds []int64, status int) int {
|
132
|
var total int
|
134
|
var total int
|
133
|
var contract = new(models.CooperationContract)
|
135
|
var contract = new(models.CooperationContract)
|