module_cooperation_statistics.go
5.2 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package allied_creation_cooperation
import (
"encoding/json"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
)
const (
// 合约分红列表查询
SearchContractDividends = "SearchContractDividends"
// 获取分红合约详情
GetContractDividends = "GetContractDividends"
// 分红统计(分红明细)
DividendsStatistics = "DividendsStatistics"
// 企业-商品统计
CooperationGoodsStatistics = "cooperationGoodsStatistics"
// 企业-共创模式统计
CooperationModeStatistics = "CooperationModeStatistics"
// 企业-分红统计
CompanyDividendsStatistics = "CompanyDividendsStatistics"
// 企业、个人 - 分红预算列表
SearchDividendsEstimates = "SearchDividendsEstimates"
// 公司 - 共创用户统计
CompanyCooperationUsersStatistics = "CompanyCooperationUsersStatistics"
//公司 - 共创用户模式统计
CooperationUserModeStatistics = "CooperationUserModeStatistics"
// 公司 - 共创用户分红支付统计
CompanyPaymentHistoryStatistics = "CompanyPaymentHistoryStatistics"
// 个人 - 共创企业统计
CooperationCompanyStatistics = "CooperationCompanyStatistics"
// 个人 - 用户合约统计
PersonCooperationContractStatistics = "PersonCooperationContractStatistics"
// 个人 - 企业支付统计
PersonCompanyPaymentHistoryStatistics = "PersonCompanyPaymentHistoryStatistics"
// 账期结算单统计
CreditAccountStatistics = "CreditAccountStatistics"
// 公司/个人 - 支付历史统计直方图
PaymentHistoryHistogramStatistics = "PaymentHistoryHistogramStatistics"
// 用户相关的项目合约编号列表查询
RelevantCooperationContractNumbers = "RelevantCooperationContractNumbers"
)
// CooperationStatistics 共创统计
func (gateway HttplibAlliedCreationCooperation) CooperationStatistics(action string, queryOptions interface{}) (interface{}, error) {
url := gateway.baseUrL + "/cooperation-statistics"
method := "post"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:共创统计。", map[string]interface{}{
"api": method + ":" + url,
"param": queryOptions,
})
param := map[string]interface{}{
"action": action,
"queryOptions": queryOptions,
}
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求共创统计失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取共创统计失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:共创统计。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析共创统计:%w", err)
}
var data interface{}
err = gateway.GetResponseData(result, &data)
return &data, err
}
// CreditAccountStatistics 账期结算单统计
func (gateway HttplibAlliedCreationCooperation) CreditAccountStatistics(action string, queryOptions interface{}) (*DataCreditAccountStatistics, error) {
url := gateway.baseUrL + "/cooperation-statistics"
method := "post"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:共创统计。", map[string]interface{}{
"api": method + ":" + url,
"param": queryOptions,
})
param := map[string]interface{}{
"action": action,
"queryOptions": queryOptions,
}
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求共创统计失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取共创统计失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:共创统计。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析共创统计:%w", err)
}
var data DataCreditAccountStatistics
err = gateway.GetResponseData(result, &data)
return &data, err
}
// CreditAccountStatistics 账期结算单统计
func (gateway HttplibAlliedCreationCooperation) RelevantCooperationContractNumbers(action string, queryOptions interface{}) ([]string, error) {
url := gateway.baseUrL + "/cooperation-statistics"
method := "post"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:共创统计。", map[string]interface{}{
"api": method + ":" + url,
"param": queryOptions,
})
param := map[string]interface{}{
"action": action,
"queryOptions": queryOptions,
}
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求共创统计失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取共创统计失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:共创统计。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析共创统计:%w", err)
}
var data []string
err = gateway.GetResponseData(result, &data)
return data, err
}