statistics_company.go
4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
"math/rand"
"time"
)
// 企业端统计 【0%】
type CompanyStatisticsService struct {
}
// IndexStatistics TODO:首页统计 (入口页面统计数据)
func (srv CompanyStatisticsService) IndexStatistics(cmd *command.IndexStatisticsCommand) (interface{}, error) {
value := dto.IndexStatistics{}
value.ProjectOverviewStatistics.ContractSum = 20
value.ProjectOverviewStatistics.CooperationUserCount = 5
value.ProjectOverviewStatistics.ProjectSum = 5
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
companyDividendsStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CompanyDividendsStatistics, map[string]interface{}{
"companyId": cmd.Operator.CompanyId,
"orgId": cmd.Operator.OrgId,
"action": 1, //当前月
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
cooperationModeStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CooperationModeStatistics, map[string]interface{}{
"companyId": cmd.Operator.CompanyId,
"orgId": cmd.Operator.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
cooperationGoodsStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CooperationGoodsStatistics, map[string]interface{}{
"companyId": cmd.Operator.CompanyId,
"orgId": cmd.Operator.OrgId,
"rankType": 1, //月榜
"top": 5,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"currentMonthDividendsStatistics": companyDividendsStatistics,
"cooperationModeStatistics": cooperationModeStatistics,
"CooperationGoodsStatistics": cooperationGoodsStatistics,
}, nil
}
// CooperationPersonStatistics TODO:共创人员统计(共创人员明细)
func (srv CompanyStatisticsService) CooperationPersonStatistics(userMenusCommand *command.CooperationPersonStatisticsCommand) (interface{}, error) {
return map[string]interface{}{}, nil
}
// GoodsStatistics TODO:产品统计排行榜 年月榜
func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.GoodsStatisticsCommand) (int64, interface{}, error) {
type rankItem struct {
GoodAmount float64 `json:"goodAmount"`
GoodName string `json:"goodName"`
GoodRatio float64 `json:"goodRatio"`
Rank int `json:"rank"`
}
var items []rankItem
for i := 0; i < 5; i++ {
item := rankItem{
GoodAmount: 2000,
GoodName: fmt.Sprintf("商品%v", rand.Intn(100)),
GoodRatio: 20,
Rank: i + 1,
}
items = append(items, item)
}
return 5, items, nil
}
// CooperationDividendsStatistics TODO:公司共创人员列表(分红支出统计)
func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusCommand *command.CooperationDividendsStatisticsCommand) (int64, interface{}, error) {
type cooperationDividendItem struct {
CooperationTime int64 `json:"cooperationTime"`
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
ActuallyPaidAmount float64 `json:"actuallyPaidAmount"`
UnPaidAmount float64 `json:"unPaidAmount"`
Participator struct {
UserType int `json:"userType"`
UserInfo struct {
// 用户姓名
UserName string `json:"userName,omitempty"`
// 手机号码
UserPhone string `json:"userPhone,omitempty"`
// 头像
//Avatar string `json:"avatar,omitempty"`
// 邮箱
//Email string `json:"email,omitempty"`
} `json:"userInfo"`
} `json:"participator"` // 参与人
}
var results []cooperationDividendItem
for i := 0; i < 5; i++ {
item := cooperationDividendItem{
CooperationTime: time.Now().Unix() * 1000,
DividendsOrderAmount: 6000,
ActuallyPaidAmount: 5000,
UnPaidAmount: 1000,
}
item.Participator.UserInfo.UserName = fmt.Sprintf("用户%v", rand.Intn(100))
results = append(results, item)
}
return 5, results, nil
}