|
@@ -7,7 +7,9 @@ import ( |
|
@@ -7,7 +7,9 @@ import ( |
7
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
7
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
8
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
8
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
|
|
10
|
+ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
|
|
|
12
|
+ "time"
|
11
|
)
|
13
|
)
|
12
|
|
14
|
|
13
|
const (
|
15
|
const (
|
|
@@ -24,6 +26,8 @@ const ( |
|
@@ -24,6 +26,8 @@ const ( |
24
|
CooperationModeStatistics = "CooperationModeStatistics"
|
26
|
CooperationModeStatistics = "CooperationModeStatistics"
|
25
|
// 企业-分红统计
|
27
|
// 企业-分红统计
|
26
|
CompanyDividendsStatistics = "CompanyDividendsStatistics"
|
28
|
CompanyDividendsStatistics = "CompanyDividendsStatistics"
|
|
|
29
|
+ // 企业、个人 - 分红预算列表
|
|
|
30
|
+ SearchDividendsEstimates = "SearchDividendsEstimates"
|
27
|
)
|
31
|
)
|
28
|
|
32
|
|
29
|
// CooperationStatisticsService 共创统计服务
|
33
|
// CooperationStatisticsService 共创统计服务
|
|
@@ -196,7 +200,78 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
@@ -196,7 +200,78 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
196
|
|
200
|
|
197
|
// 分红统计(分红明细)
|
201
|
// 分红统计(分红明细)
|
198
|
func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[string]interface{}) (interface{}, error) {
|
202
|
func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[string]interface{}) (interface{}, error) {
|
199
|
- return nil, nil
|
203
|
+ // 参数验证
|
|
|
204
|
+ var request = struct {
|
|
|
205
|
+ //企业
|
|
|
206
|
+ CompanyId int64 `json:"companyId"`
|
|
|
207
|
+ OrgId int64 `json:"orgId"`
|
|
|
208
|
+ //个人
|
|
|
209
|
+ UserBaseId int64 `json:"userBaseId"`
|
|
|
210
|
+ }{}
|
|
|
211
|
+ if err := LoadQueryObject(queryOptions, &request); err != nil {
|
|
|
212
|
+ return nil, err
|
|
|
213
|
+ }
|
|
|
214
|
+ queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
215
|
+
|
|
|
216
|
+ type response struct {
|
|
|
217
|
+ Total float64 `json:"total"`
|
|
|
218
|
+ Accounting float64 `json:"accounting"`
|
|
|
219
|
+ Accounted float64 `json:"accounted"`
|
|
|
220
|
+ Paid float64 `json:"paid"`
|
|
|
221
|
+ }
|
|
|
222
|
+ creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
|
|
|
223
|
+
|
|
|
224
|
+ var allDividends = &response{}
|
|
|
225
|
+ if err := creditAccountDao.DividendsStatistics(queryOptions, allDividends); err != nil {
|
|
|
226
|
+ return nil, err
|
|
|
227
|
+ }
|
|
|
228
|
+ allDividends.Accounting = allDividends.Total - allDividends.Accounted
|
|
|
229
|
+
|
|
|
230
|
+ var annualDividends = &response{}
|
|
|
231
|
+ queryOptions["beginTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
232
|
+ queryOptions["endTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local).AddDate(1, 0, 0)
|
|
|
233
|
+ if err := creditAccountDao.DividendsStatistics(queryOptions, annualDividends); err != nil {
|
|
|
234
|
+ return nil, err
|
|
|
235
|
+ }
|
|
|
236
|
+ annualDividends.Accounting = annualDividends.Total - annualDividends.Accounted
|
|
|
237
|
+
|
|
|
238
|
+ var quarterDividends = &response{}
|
|
|
239
|
+ queryOptions["beginTime"], queryOptions["endTime"] = quarterBeginEnd()
|
|
|
240
|
+ if err := creditAccountDao.DividendsStatistics(queryOptions, quarterDividends); err != nil {
|
|
|
241
|
+ return nil, err
|
|
|
242
|
+ }
|
|
|
243
|
+ quarterDividends.Accounting = quarterDividends.Total - quarterDividends.Accounted
|
|
|
244
|
+
|
|
|
245
|
+ ret := map[string]interface{}{
|
|
|
246
|
+ "allDividends": allDividends,
|
|
|
247
|
+ "annualDividends": annualDividends,
|
|
|
248
|
+ "quarterDividends": quarterDividends,
|
|
|
249
|
+ }
|
|
|
250
|
+ return ret, nil
|
|
|
251
|
+}
|
|
|
252
|
+
|
|
|
253
|
+func quarterBeginEnd() (time.Time, time.Time) {
|
|
|
254
|
+ y := time.Now().Year()
|
|
|
255
|
+ m := time.Now().Month()
|
|
|
256
|
+ var mBegin, mEnd int
|
|
|
257
|
+ var begin, end time.Time
|
|
|
258
|
+ switch m {
|
|
|
259
|
+ case 4, 5, 6:
|
|
|
260
|
+ mBegin = 4
|
|
|
261
|
+ mEnd = 6
|
|
|
262
|
+ case 7, 8, 9:
|
|
|
263
|
+ mBegin = 7
|
|
|
264
|
+ mEnd = 9
|
|
|
265
|
+ case 10, 11, 12:
|
|
|
266
|
+ mBegin = 10
|
|
|
267
|
+ mEnd = 12
|
|
|
268
|
+ case 1, 2, 3:
|
|
|
269
|
+ mBegin = 1
|
|
|
270
|
+ mEnd = 3
|
|
|
271
|
+ }
|
|
|
272
|
+ begin = time.Date(y, time.Month(mBegin), 1, 0, 0, 0, 0, time.Local)
|
|
|
273
|
+ end = time.Date(y, time.Month(mEnd), 1, 0, 0, 0, 0, time.Local)
|
|
|
274
|
+ return begin, end
|
200
|
}
|
275
|
}
|
201
|
|
276
|
|
202
|
// 分红预算列表
|
277
|
// 分红预算列表
|