|
@@ -98,6 +98,86 @@ func (srv PersonStatisticsService) IndexStatistics(cmd *command.IndexStatisticsC |
|
@@ -98,6 +98,86 @@ func (srv PersonStatisticsService) IndexStatistics(cmd *command.IndexStatisticsC |
98
|
}, nil
|
98
|
}, nil
|
99
|
}
|
99
|
}
|
100
|
|
100
|
|
|
|
101
|
+// IndexStatistics 个人端 - 首页统计 (入口页面统计数据)
|
|
|
102
|
+func (srv PersonStatisticsService) IndexStatisticsV2(cmd *command.IndexStatisticsCommand) (interface{}, error) {
|
|
|
103
|
+ gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
|
|
|
104
|
+ cmd.Operator)
|
|
|
105
|
+
|
|
|
106
|
+ // 1.项目概览统计
|
|
|
107
|
+ contractStatisticsResult, err := gateway.CooperationStatistics(allied_creation_cooperation.PersonCooperationContractStatistics, map[string]interface{}{
|
|
|
108
|
+ "userBaseId": cmd.Operator.UserBaseId,
|
|
|
109
|
+ })
|
|
|
110
|
+ if err != nil {
|
|
|
111
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
112
|
+ }
|
|
|
113
|
+ type contractStatistics struct {
|
|
|
114
|
+ ContractSum int `json:"contractSum"`
|
|
|
115
|
+ ContractStoppedSum int `json:"contractStoppedSum"`
|
|
|
116
|
+ }
|
|
|
117
|
+ var cs = &contractStatistics{}
|
|
|
118
|
+ if err := json.UnmarshalFromString(json.MarshalToString(contractStatisticsResult), cs); err != nil {
|
|
|
119
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
120
|
+ }
|
|
|
121
|
+
|
|
|
122
|
+ var response = struct {
|
|
|
123
|
+ OrgIds []int `json:"orgIds"`
|
|
|
124
|
+ }{}
|
|
|
125
|
+ err = gateway.CooperationStatisticsWithObject(allied_creation_cooperation.PersonCooperationCompany, map[string]interface{}{
|
|
|
126
|
+ "userBaseId": cmd.Operator.UserBaseId,
|
|
|
127
|
+ }, &response)
|
|
|
128
|
+ if err != nil {
|
|
|
129
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
130
|
+ }
|
|
|
131
|
+ var overview = map[string]interface{}{
|
|
|
132
|
+ "contractSum": cs.ContractSum, //总合约数
|
|
|
133
|
+ "contractStoppedSum": cs.ContractStoppedSum, //停止的合约数
|
|
|
134
|
+ "companySum": len(response.OrgIds), //共创企业数
|
|
|
135
|
+ }
|
|
|
136
|
+ year, month, _ := time.Now().Date()
|
|
|
137
|
+ beginTime := time.Date(year, month, 1, 0, 0, 0, 0, time.Local)
|
|
|
138
|
+ endTime := beginTime.AddDate(0, 1, 0)
|
|
|
139
|
+ // 2.本月分红统计 - 个人
|
|
|
140
|
+ unPaidResult, err := gateway.CooperationStatistics(allied_creation_cooperation.CreditAccountStatistics, map[string]interface{}{
|
|
|
141
|
+ "userBaseId": cmd.Operator.UserBaseId,
|
|
|
142
|
+ "beginTime": beginTime,
|
|
|
143
|
+ "endTime": endTime,
|
|
|
144
|
+ })
|
|
|
145
|
+ if err != nil {
|
|
|
146
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
147
|
+ }
|
|
|
148
|
+ type AnnualDividend struct {
|
|
|
149
|
+ Total float64 `json:"total"`
|
|
|
150
|
+ Accounting float64 `json:"accounting"`
|
|
|
151
|
+ Accounted float64 `json:"accounted"`
|
|
|
152
|
+ Paid float64 `json:"paid"`
|
|
|
153
|
+ Unpaid float64 `json:"unpaid"`
|
|
|
154
|
+ }
|
|
|
155
|
+ var annualUnPaidDividend = &AnnualDividend{}
|
|
|
156
|
+ if err := json.UnmarshalFromString(json.MarshalToString(unPaidResult), annualUnPaidDividend); err != nil {
|
|
|
157
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
158
|
+ }
|
|
|
159
|
+ // 2.本月分红统计 - 个人
|
|
|
160
|
+ paymentResult, err := gateway.CooperationStatistics(allied_creation_cooperation.CreditAccountStatistics, map[string]interface{}{
|
|
|
161
|
+ "userBaseId": cmd.Operator.UserBaseId,
|
|
|
162
|
+ "paymentBeginTime": beginTime,
|
|
|
163
|
+ "paymentEndTime": endTime,
|
|
|
164
|
+ })
|
|
|
165
|
+ var annualPaymentDividend = &AnnualDividend{}
|
|
|
166
|
+ if err := json.UnmarshalFromString(json.MarshalToString(paymentResult), annualPaymentDividend); err != nil {
|
|
|
167
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
168
|
+ }
|
|
|
169
|
+ dividendStatistics := map[string]interface{}{
|
|
|
170
|
+ "dividendAmount": annualPaymentDividend.Paid + annualUnPaidDividend.Unpaid, // 分红金额 annualDividend.Total
|
|
|
171
|
+ "paidAmount": annualPaymentDividend.Paid, // 已支付
|
|
|
172
|
+ "unPaidAmount": annualUnPaidDividend.Unpaid, // 未支付
|
|
|
173
|
+ }
|
|
|
174
|
+
|
|
|
175
|
+ return map[string]interface{}{
|
|
|
176
|
+ "overview": overview,
|
|
|
177
|
+ "dividendStatistics": dividendStatistics,
|
|
|
178
|
+ }, nil
|
|
|
179
|
+}
|
|
|
180
|
+
|
101
|
// CompanyStatistics 共创用户-共创企业统计
|
181
|
// CompanyStatistics 共创用户-共创企业统计
|
102
|
func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPersonStatisticsCommand) (interface{}, error) {
|
182
|
func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPersonStatisticsCommand) (interface{}, error) {
|
103
|
|
183
|
|
|
@@ -235,20 +315,19 @@ func (srv PersonStatisticsService) CompanyStatisticsV2(cmd *command.CooperationP |
|
@@ -235,20 +315,19 @@ func (srv PersonStatisticsService) CompanyStatisticsV2(cmd *command.CooperationP |
235
|
if cooperationCompanyStatisticsResponses[j].OrgId == int64(companyList[i]) {
|
315
|
if cooperationCompanyStatisticsResponses[j].OrgId == int64(companyList[i]) {
|
236
|
orgData, err := gatewayUser.OrgGet(allied_creation_user.ReqOrgGet{
|
316
|
orgData, err := gatewayUser.OrgGet(allied_creation_user.ReqOrgGet{
|
237
|
OrgId: companyList[i],
|
317
|
OrgId: companyList[i],
|
|
|
318
|
+ FetchFlag: 1,
|
238
|
})
|
319
|
})
|
239
|
if err != nil {
|
320
|
if err != nil {
|
240
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
321
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
241
|
}
|
322
|
}
|
242
|
- //orgData,err:= gatewayUser.CompanyGet(allied_creation_user.ReqCompanyGet{
|
|
|
243
|
- // OrgId: companyList[i],
|
|
|
244
|
- //})
|
|
|
245
|
- if err != nil {
|
|
|
246
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
323
|
+ var companyLog string
|
|
|
324
|
+ if orgData.Company != nil {
|
|
|
325
|
+ companyLog = orgData.Company.Logo
|
247
|
}
|
326
|
}
|
248
|
cooperationCompanyStatisticsResponses[j].Company = domain.Company{
|
327
|
cooperationCompanyStatisticsResponses[j].Company = domain.Company{
|
249
|
CompanyID: orgData.OrgID,
|
328
|
CompanyID: orgData.OrgID,
|
250
|
CompanyName: orgData.OrgName,
|
329
|
CompanyName: orgData.OrgName,
|
251
|
- //Logo: user.Company.Logo,
|
330
|
+ Logo: companyLog,
|
252
|
}
|
331
|
}
|
253
|
values = append(values, cooperationCompanyStatisticsResponses[j])
|
332
|
values = append(values, cooperationCompanyStatisticsResponses[j])
|
254
|
}
|
333
|
}
|