|
@@ -6,11 +6,13 @@ import ( |
|
@@ -6,11 +6,13 @@ import ( |
6
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
6
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
|
9
|
- "time"
|
|
|
10
|
)
|
9
|
)
|
11
|
|
10
|
|
12
|
const (
|
11
|
const (
|
13
|
- ContractDividends = "ContractDividends"
|
12
|
+ // 合约分红列表查询
|
|
|
13
|
+ SearchContractDividends = "SearchContractDividends"
|
|
|
14
|
+ // 获取分红合约详情
|
|
|
15
|
+ GetContractDividends = "GetContractDividends"
|
14
|
)
|
16
|
)
|
15
|
|
17
|
|
16
|
// CooperationStatisticsService 共创统计服务
|
18
|
// CooperationStatisticsService 共创统计服务
|
|
@@ -20,6 +22,8 @@ type CooperationStatisticsService struct { |
|
@@ -20,6 +22,8 @@ type CooperationStatisticsService struct { |
20
|
|
22
|
|
21
|
/***** 1.合约分红模块 *****/
|
23
|
/***** 1.合约分红模块 *****/
|
22
|
|
24
|
|
|
|
25
|
+/*1.1 分红合约搜索*/
|
|
|
26
|
+
|
23
|
// 分红合约搜索
|
27
|
// 分红合约搜索
|
24
|
//
|
28
|
//
|
25
|
// queryOptions 查询参数
|
29
|
// queryOptions 查询参数
|
|
@@ -53,7 +57,7 @@ func (svr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
@@ -53,7 +57,7 @@ func (svr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
53
|
CooperationContractName: item.CooperationContractName,
|
57
|
CooperationContractName: item.CooperationContractName,
|
54
|
CooperationContractNumber: item.CooperationContractNumber,
|
58
|
CooperationContractNumber: item.CooperationContractNumber,
|
55
|
Status: item.Status,
|
59
|
Status: item.Status,
|
56
|
- CreatedAt: item.CreatedAt,
|
60
|
+ CreatedAt: item.CreatedAt.Unix() * 1000,
|
57
|
}
|
61
|
}
|
58
|
results = append(results, resultItem)
|
62
|
results = append(results, resultItem)
|
59
|
numbers = append(numbers, item.CooperationContractNumber)
|
63
|
numbers = append(numbers, item.CooperationContractNumber)
|
|
@@ -109,7 +113,7 @@ func (svr *CooperationStatisticsService) getContractsDividendsEstimate(numbers [ |
|
@@ -109,7 +113,7 @@ func (svr *CooperationStatisticsService) getContractsDividendsEstimate(numbers [ |
109
|
if len(numbers) == 0 {
|
113
|
if len(numbers) == 0 {
|
110
|
return resMap, nil
|
114
|
return resMap, nil
|
111
|
}
|
115
|
}
|
112
|
- _, err := svr.transactionContext.PgDd.Query(estimates, `select cooperation_contract_number,sum(dividends_amount) dividends_amount from dividends_estimates
|
116
|
+ _, err := svr.transactionContext.PgDd.Query(&estimates, `select cooperation_contract_number,sum(dividends_amount) dividends_amount from dividends_estimates
|
113
|
where cooperation_contract_number in (?)
|
117
|
where cooperation_contract_number in (?)
|
114
|
group by cooperation_contract_number
|
118
|
group by cooperation_contract_number
|
115
|
`, pg.In(numbers))
|
119
|
`, pg.In(numbers))
|
|
@@ -137,7 +141,7 @@ type searchContractDividendsResult struct { |
|
@@ -137,7 +141,7 @@ type searchContractDividendsResult struct { |
137
|
// 分红订单金额
|
141
|
// 分红订单金额
|
138
|
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
|
142
|
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
|
139
|
// 创建时间
|
143
|
// 创建时间
|
140
|
- CreatedAt time.Time `json:"createdAt"`
|
144
|
+ CreatedAt int64 `json:"createdAt"`
|
141
|
}
|
145
|
}
|
142
|
|
146
|
|
143
|
func NewCooperationStatisticsService(transactionContext *pgTransaction.TransactionContext) (*CooperationStatisticsService, error) {
|
147
|
func NewCooperationStatisticsService(transactionContext *pgTransaction.TransactionContext) (*CooperationStatisticsService, error) {
|
|
@@ -149,3 +153,43 @@ func NewCooperationStatisticsService(transactionContext *pgTransaction.Transacti |
|
@@ -149,3 +153,43 @@ func NewCooperationStatisticsService(transactionContext *pgTransaction.Transacti |
149
|
}, nil
|
153
|
}, nil
|
150
|
}
|
154
|
}
|
151
|
}
|
155
|
}
|
|
|
156
|
+
|
|
|
157
|
+/*1.2 分红合约详情*/
|
|
|
158
|
+
|
|
|
159
|
+// 分红合约搜索
|
|
|
160
|
+//
|
|
|
161
|
+// queryOptions 查询参数
|
|
|
162
|
+// 按组织
|
|
|
163
|
+// - companyId
|
|
|
164
|
+// - orgId
|
|
|
165
|
+// 按个人
|
|
|
166
|
+// - userBaseId
|
|
|
167
|
+func (svr *CooperationStatisticsService) GetContractDividends(queryOptions map[string]interface{}) (interface{}, error) {
|
|
|
168
|
+ // 1.合约详情
|
|
|
169
|
+ contractRepository, _ := repository.NewCooperationContractRepository(svr.transactionContext)
|
|
|
170
|
+ if _, ok := queryOptions["contractId"]; !ok {
|
|
|
171
|
+ return nil, fmt.Errorf("合约ID(contractId)不能为空")
|
|
|
172
|
+ }
|
|
|
173
|
+ var res = make(map[string]interface{})
|
|
|
174
|
+ contract, err := contractRepository.FindOne(map[string]interface{}{"cooperationContractId": queryOptions["contractId"]})
|
|
|
175
|
+ if err != nil {
|
|
|
176
|
+ return nil, err
|
|
|
177
|
+ }
|
|
|
178
|
+ res["cooperationContract"] = map[string]interface{}{
|
|
|
179
|
+ "cooperationContractDescription": contract.CooperationContractDescription,
|
|
|
180
|
+ "cooperationContractId": contract.CooperationContractId,
|
|
|
181
|
+ "cooperationContractName": contract.CooperationContractName,
|
|
|
182
|
+ "cooperationContractNumber": contract.CooperationContractNumber,
|
|
|
183
|
+ "createdAt": contract.CreatedAt.Unix() * 1000,
|
|
|
184
|
+ "status": contract.Status,
|
|
|
185
|
+ }
|
|
|
186
|
+
|
|
|
187
|
+ // 2.合约分红列表
|
|
|
188
|
+ if _, ok := queryOptions["userBaseId"]; ok {
|
|
|
189
|
+
|
|
|
190
|
+ } else if _, ok := queryOptions["orgId"]; ok {
|
|
|
191
|
+
|
|
|
192
|
+ }
|
|
|
193
|
+ res["dividends"] = []struct{}{}
|
|
|
194
|
+ return res, nil
|
|
|
195
|
+} |