正在显示
18 个修改的文件
包含
177 行增加
和
42 行删除
1 | +package command |
1 | +package command |
1 | +package command |
1 | +package query |
1 | +package query |
1 | +package service |
@@ -199,12 +199,11 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | @@ -199,12 +199,11 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | ||
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | -// TODO 获取系统素币统计 | 202 | +// 系统素币统计 |
203 | func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMoneyStatisticsCommand *command.SystemSuMoneyStatisticsCommand) (interface{}, error) { | 203 | func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMoneyStatisticsCommand *command.SystemSuMoneyStatisticsCommand) (interface{}, error) { |
204 | if err := systemSuMoneyStatisticsCommand.ValidateCommand(); err != nil { | 204 | if err := systemSuMoneyStatisticsCommand.ValidateCommand(); err != nil { |
205 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 205 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
206 | } | 206 | } |
207 | - | ||
208 | transactionContext, err := factory.CreateTransactionContext(nil) | 207 | transactionContext, err := factory.CreateTransactionContext(nil) |
209 | if err != nil { | 208 | if err != nil { |
210 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 209 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -215,7 +214,6 @@ func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMone | @@ -215,7 +214,6 @@ func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMone | ||
215 | defer func() { | 214 | defer func() { |
216 | transactionContext.RollbackTransaction() | 215 | transactionContext.RollbackTransaction() |
217 | }() | 216 | }() |
218 | - | ||
219 | var cashPoolDao *dao.CashPoolDao | 217 | var cashPoolDao *dao.CashPoolDao |
220 | if value, err := factory.CreateCashPoolDao(map[string]interface{}{ | 218 | if value, err := factory.CreateCashPoolDao(map[string]interface{}{ |
221 | "transactionContext": transactionContext, | 219 | "transactionContext": transactionContext, |
@@ -224,23 +222,47 @@ func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMone | @@ -224,23 +222,47 @@ func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMone | ||
224 | } else { | 222 | } else { |
225 | cashPoolDao = value | 223 | cashPoolDao = value |
226 | } | 224 | } |
227 | - | ||
228 | if systemSuMoneyStatistics, err := cashPoolDao.CalculateSystemCash(systemSuMoneyStatisticsCommand.CompanyId); err != nil { | 225 | if systemSuMoneyStatistics, err := cashPoolDao.CalculateSystemCash(systemSuMoneyStatisticsCommand.CompanyId); err != nil { |
229 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 226 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
230 | } else { | 227 | } else { |
231 | if err := transactionContext.CommitTransaction(); err != nil { | 228 | if err := transactionContext.CommitTransaction(); err != nil { |
232 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 229 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
233 | } | 230 | } |
234 | - //systemSuMoneyStatistics["currentSuMoney"] = employee.SuMoney | ||
235 | return systemSuMoneyStatistics, nil | 231 | return systemSuMoneyStatistics, nil |
236 | } | 232 | } |
237 | } | 233 | } |
238 | 234 | ||
239 | -// TODO 获取系统现金统计 | 235 | +// 系统现金统计 |
240 | func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStatisticsCommand *command.SystemCashStatisticsCommand) (interface{}, error) { | 236 | func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStatisticsCommand *command.SystemCashStatisticsCommand) (interface{}, error) { |
241 | - | ||
242 | - | ||
243 | - return nil, nil | 237 | + if err := systemCashStatisticsCommand.ValidateCommand(); err != nil { |
238 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
239 | + } | ||
240 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
241 | + if err != nil { | ||
242 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
243 | + } | ||
244 | + if err := transactionContext.StartTransaction(); err != nil { | ||
245 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
246 | + } | ||
247 | + defer func() { | ||
248 | + transactionContext.RollbackTransaction() | ||
249 | + }() | ||
250 | + var cashPoolDao *dao.CashPoolDao | ||
251 | + if value, err := factory.CreateCashPoolDao(map[string]interface{}{ | ||
252 | + "transactionContext": transactionContext, | ||
253 | + }); err != nil { | ||
254 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
255 | + } else { | ||
256 | + cashPoolDao = value | ||
257 | + } | ||
258 | + if systemCashStatistics, err := cashPoolDao.CalculateSystemCash(systemCashStatisticsCommand.CompanyId); err != nil { | ||
259 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
260 | + } else { | ||
261 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
262 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
263 | + } | ||
264 | + return systemCashStatistics, nil | ||
265 | + } | ||
244 | } | 266 | } |
245 | 267 | ||
246 | func NewStatisticsService(options map[string]interface{}) *StatisticsService { | 268 | func NewStatisticsService(options map[string]interface{}) *StatisticsService { |
@@ -156,15 +156,20 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | @@ -156,15 +156,20 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | ||
156 | transactionContext.RollbackTransaction() | 156 | transactionContext.RollbackTransaction() |
157 | }() | 157 | }() |
158 | 158 | ||
159 | + var timeNow = time.Now() | ||
160 | + var deadline = createExchangeCashActivityCommand.Deadline | ||
161 | + var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local) | ||
162 | + var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0, time.Local) | ||
163 | + | ||
159 | newActivity := &domain.ExchangeCashActivity{ | 164 | newActivity := &domain.ExchangeCashActivity{ |
160 | ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName, | 165 | ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName, |
161 | CompanyId: createExchangeCashActivityCommand.CompanyId, | 166 | CompanyId: createExchangeCashActivityCommand.CompanyId, |
162 | ExchangedCash: 0, | 167 | ExchangedCash: 0, |
163 | ExchangedSuMoney: 0, | 168 | ExchangedSuMoney: 0, |
164 | Deadline: createExchangeCashActivityCommand.Deadline, | 169 | Deadline: createExchangeCashActivityCommand.Deadline, |
165 | - CountDown: 0, | 170 | + CountDown: int64(t2.Sub(t1).Hours() / 24), |
166 | Rate: createExchangeCashActivityCommand.ExchangeRate, | 171 | Rate: createExchangeCashActivityCommand.ExchangeRate, |
167 | - CreateTime: time.Now(), | 172 | + CreateTime: timeNow, |
168 | } | 173 | } |
169 | 174 | ||
170 | var exchangeCashActivityRepository domain.ExchangeActivityRepository | 175 | var exchangeCashActivityRepository domain.ExchangeActivityRepository |
@@ -273,7 +278,6 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA | @@ -273,7 +278,6 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA | ||
273 | if err := getExchangeCashActivityQuery.ValidateQuery(); err != nil { | 278 | if err := getExchangeCashActivityQuery.ValidateQuery(); err != nil { |
274 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 279 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
275 | } | 280 | } |
276 | - | ||
277 | transactionContext, err := factory.CreateTransactionContext(nil) | 281 | transactionContext, err := factory.CreateTransactionContext(nil) |
278 | if err != nil { | 282 | if err != nil { |
279 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 283 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -284,7 +288,6 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA | @@ -284,7 +288,6 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA | ||
284 | defer func() { | 288 | defer func() { |
285 | transactionContext.RollbackTransaction() | 289 | transactionContext.RollbackTransaction() |
286 | }() | 290 | }() |
287 | - | ||
288 | var exchangeCashActivityRepository domain.ExchangeActivityRepository | 291 | var exchangeCashActivityRepository domain.ExchangeActivityRepository |
289 | if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{ | 292 | if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{ |
290 | "transactionContext": transactionContext, | 293 | "transactionContext": transactionContext, |
@@ -340,25 +343,32 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang | @@ -340,25 +343,32 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang | ||
340 | if activity == nil { | 343 | if activity == nil { |
341 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId))) | 344 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId))) |
342 | } | 345 | } |
343 | - if activity == nil { | ||
344 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId))) | ||
345 | - } | ||
346 | if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { | 346 | if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { |
347 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 347 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
348 | } | 348 | } |
349 | if activityUpdated, err := exchangeCashActivityRepository.Save(activity); err != nil { | 349 | if activityUpdated, err := exchangeCashActivityRepository.Save(activity); err != nil { |
350 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 350 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
351 | } else { | 351 | } else { |
352 | + // TODO 更新现金池已兑换素币、已兑换现金值、未兑换素币、未兑换现金值、平均汇率 | ||
353 | + //var cashPoolRepository domain.CashPoolRepository | ||
354 | + //if value, err := factory.CreateCashPoolRepository(map[string]interface{}{ | ||
355 | + // "transactionContext": transactionContext, | ||
356 | + //}); err != nil { | ||
357 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
358 | + //} else { | ||
359 | + // cashPoolRepository = value | ||
360 | + //} | ||
361 | + | ||
362 | + | ||
363 | + | ||
352 | if err := transactionContext.CommitTransaction(); err != nil { | 364 | if err := transactionContext.CommitTransaction(); err != nil { |
353 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 365 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
354 | } | 366 | } |
355 | - // TODO 更新现金池已兑换素币、已兑换现金值、未兑换素币、未兑换现金值、平均汇率 | ||
356 | - | ||
357 | return activityUpdated, nil | 367 | return activityUpdated, nil |
358 | } | 368 | } |
359 | } | 369 | } |
360 | 370 | ||
361 | -// 新建兑换现金人员 | 371 | +// 新增兑换现金人员 |
362 | func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) { | 372 | func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) { |
363 | if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil { | 373 | if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil { |
364 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 374 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -375,15 +385,20 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | @@ -375,15 +385,20 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | ||
375 | transactionContext.RollbackTransaction() | 385 | transactionContext.RollbackTransaction() |
376 | }() | 386 | }() |
377 | 387 | ||
378 | - // TODO 需要判断新增兑换现金人员的素币值是否合理(人员参与兑换的素币不得超过该人员还未兑换的素币总值) | 388 | + var exchangeCashActivityRepository domain.ExchangeActivityRepository |
389 | + activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": createExchangeCashPersonCommand.ExchangeCashActivityId}) | ||
390 | + if err != nil { | ||
391 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
392 | + } | ||
393 | + if activity.Rate == 0 { | ||
394 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string("请设置汇率"))) | ||
395 | + } | ||
379 | 396 | ||
380 | - // TODO 判断活动的汇率是否为空,为空则不允许新建,提示:请设置汇率 | 397 | + // TODO 清单中现金总额超过现金池时创建失败,提示:“已超过投入现金池的未兑换现金” |
381 | 398 | ||
382 | - // TODO 获取参与的兑换活动的汇率,计算已兑换的现金值 | ||
383 | 399 | ||
384 | - // TODO 清单中现金总额超过现金池时创建失败,提示:“已超过投入现金池的未兑换现金” | 400 | + // TODO 新增兑换人员时,判断成员是否存在,判断素币值是否超过本人持有的素币,以手机账号为判断依据 |
385 | 401 | ||
386 | - // TODO 新增兑换人员时,判断成员是否存在,以手机账号为判断依据 | ||
387 | 402 | ||
388 | newPerson := &domain.ExchangeCashPersonList{ | 403 | newPerson := &domain.ExchangeCashPersonList{ |
389 | EmployeeInfo: &domain.EmployeeInfo{ | 404 | EmployeeInfo: &domain.EmployeeInfo{ |
@@ -392,7 +407,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | @@ -392,7 +407,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | ||
392 | }, | 407 | }, |
393 | ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId, | 408 | ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId, |
394 | ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney, | 409 | ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney, |
395 | - | 410 | + ExchangedCash: createExchangeCashPersonCommand.ExchangedSuMoney * activity.Rate, |
396 | } | 411 | } |
397 | 412 | ||
398 | var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository | 413 | var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository |
@@ -406,11 +421,12 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | @@ -406,11 +421,12 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | ||
406 | if person, err := exchangeCashPersonListRepository.Save(newPerson); err != nil { | 421 | if person, err := exchangeCashPersonListRepository.Save(newPerson); err != nil { |
407 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 422 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
408 | } else { | 423 | } else { |
424 | + // TODO 更新活动已兑换素币值、已兑换现金值、兑换汇率 | ||
425 | + | ||
426 | + | ||
409 | if err := transactionContext.CommitTransaction(); err != nil { | 427 | if err := transactionContext.CommitTransaction(); err != nil { |
410 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 428 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
411 | } | 429 | } |
412 | - // TODO 更新活动已兑换素币值、已兑换现金值、兑换汇率 | ||
413 | - | ||
414 | return person, nil | 430 | return person, nil |
415 | } | 431 | } |
416 | } | 432 | } |
@@ -572,13 +588,14 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC | @@ -572,13 +588,14 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC | ||
572 | if personUpdated, err := exchangeCashPersonListRepository.Save(person); err != nil { | 588 | if personUpdated, err := exchangeCashPersonListRepository.Save(person); err != nil { |
573 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 589 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
574 | } else { | 590 | } else { |
575 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
576 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
577 | - } | ||
578 | // TODO 更新个人当前可用素币值,生成素币兑换流水记录(获取更新前的已兑换素币值,判断是扣除还是增加),记录描述:参与素币兑换现金活动(红色表示取活动名称) | 591 | // TODO 更新个人当前可用素币值,生成素币兑换流水记录(获取更新前的已兑换素币值,判断是扣除还是增加),记录描述:参与素币兑换现金活动(红色表示取活动名称) |
579 | 592 | ||
593 | + | ||
580 | // TODO 更新相应兑换活动已兑换素币值、已兑换现金值、兑换汇率 | 594 | // TODO 更新相应兑换活动已兑换素币值、已兑换现金值、兑换汇率 |
581 | 595 | ||
596 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
597 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
598 | + } | ||
582 | return personUpdated, nil | 599 | return personUpdated, nil |
583 | } | 600 | } |
584 | } | 601 | } |
@@ -41,6 +41,8 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * | @@ -41,6 +41,8 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * | ||
41 | if task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription); err != nil { | 41 | if task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription); err != nil { |
42 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 42 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
43 | } else { | 43 | } else { |
44 | + // TODO 增加、扣除素币和个人贡献值关联,兑换物资不与贡献值关联 | ||
45 | + | ||
44 | if err := transactionContext.CommitTransaction(); err != nil { | 46 | if err := transactionContext.CommitTransaction(); err != nil { |
45 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 47 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
46 | } | 48 | } |
@@ -11,7 +11,6 @@ type CashPool struct { | @@ -11,7 +11,6 @@ type CashPool struct { | ||
11 | UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金 | 11 | UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金 |
12 | ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币 | 12 | ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币 |
13 | UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换的素币 | 13 | UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换的素币 |
14 | - //Operator *EmployeeInfo `json:"operator"` // 操作人 | ||
15 | Rate float64 `json:"rate"` // 平均兑换汇率 | 14 | Rate float64 `json:"rate"` // 平均兑换汇率 |
16 | CreateTime time.Time `json:"createTime"` // 现金投入现金池时间 | 15 | CreateTime time.Time `json:"createTime"` // 现金投入现金池时间 |
17 | } | 16 | } |
@@ -21,6 +20,25 @@ type CashPoolRepository interface { | @@ -21,6 +20,25 @@ type CashPoolRepository interface { | ||
21 | Find(queryOptions map[string]interface{}) (int64, []*CashPool, error) | 20 | Find(queryOptions map[string]interface{}) (int64, []*CashPool, error) |
22 | } | 21 | } |
23 | 22 | ||
23 | +func (cashPool *CashPool) Update(data map[string]interface{}) error { | ||
24 | + if exchangedCash, ok := data["exchangedCash"]; ok { | ||
25 | + cashPool.ExchangedCash = exchangedCash.(float64) | ||
26 | + } | ||
27 | + if unExchangeCash, ok := data["unExchangeCash"]; ok { | ||
28 | + cashPool.UnExchangeCash = unExchangeCash.(float64) | ||
29 | + } | ||
30 | + if exchangedSuMoney, ok := data["exchangedSuMoney"]; ok { | ||
31 | + cashPool.ExchangedSuMoney = exchangedSuMoney.(float64) | ||
32 | + } | ||
33 | + if unExchangeSuMoney, ok := data["unExchangeSuMoney"]; ok { | ||
34 | + cashPool.UnExchangeSuMoney = unExchangeSuMoney.(float64) | ||
35 | + } | ||
36 | + if rate, ok := data["rate"]; ok { | ||
37 | + cashPool.Rate = rate.(float64) | ||
38 | + } | ||
39 | + return nil | ||
40 | +} | ||
41 | + | ||
24 | func (cashPool *CashPool) Identity() interface{} { | 42 | func (cashPool *CashPool) Identity() interface{} { |
25 | if cashPool.CashPoolId == 0 { | 43 | if cashPool.CashPoolId == 0 { |
26 | return nil | 44 | return nil |
pkg/domain/list_interval.go
0 → 100644
1 | +package models |
1 | +package repository |
1 | +package controllers | ||
2 | + | ||
3 | +import "github.com/astaxie/beego" | ||
4 | + | ||
5 | +type ListIntervalController struct { | ||
6 | + beego.Controller | ||
7 | +} | ||
8 | + | ||
9 | +// TODO 新增榜单时间段 | ||
10 | +func (controller *ListIntervalController) CreateListInterval() { | ||
11 | + | ||
12 | +} | ||
13 | + | ||
14 | +// TODO 更新榜单时间段 | ||
15 | +func (controller *ListIntervalController) UpdateListInterval() { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +// TODO 获取榜单时间段 | ||
20 | +func (controller *ListIntervalController) GetListInterval() { | ||
21 | + | ||
22 | +} | ||
23 | + | ||
24 | +// TODO 获取榜单时间段列表 | ||
25 | +func (controller *ListIntervalController) ListListInterval() { | ||
26 | + | ||
27 | +} | ||
28 | + | ||
29 | +// TODO 移除榜单时间段 | ||
30 | +func (controller *ListIntervalController) RemoveListInterval() { | ||
31 | + | ||
32 | +} | ||
33 | + |
@@ -73,12 +73,32 @@ func (controller *StatisticsController) PersonNotificationStatistics() { | @@ -73,12 +73,32 @@ func (controller *StatisticsController) PersonNotificationStatistics() { | ||
73 | controller.ServeJSON() | 73 | controller.ServeJSON() |
74 | } | 74 | } |
75 | 75 | ||
76 | -// TODO 系统素币统计 | ||
77 | func (controller *StatisticsController) SystemSuMoneyStatistics() { | 76 | func (controller *StatisticsController) SystemSuMoneyStatistics() { |
78 | - | 77 | + statisticsService := service.NewStatisticsService(nil) |
78 | + systemSuMoneyStatisticsCommand := &command.SystemSuMoneyStatisticsCommand{} | ||
79 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), systemSuMoneyStatisticsCommand) | ||
80 | + data, err := statisticsService.SystemSuMoneyStatistics(systemSuMoneyStatisticsCommand) | ||
81 | + var response utils.JsonResponse | ||
82 | + if err != nil { | ||
83 | + response = utils.ResponseError(controller.Ctx, err) | ||
84 | + } else { | ||
85 | + response = utils.ResponseData(controller.Ctx, data) | ||
86 | + } | ||
87 | + controller.Data["json"] = response | ||
88 | + controller.ServeJSON() | ||
79 | } | 89 | } |
80 | 90 | ||
81 | -// TODO 系统现金统计 | ||
82 | func (controller *StatisticsController) SystemCashStatistics() { | 91 | func (controller *StatisticsController) SystemCashStatistics() { |
83 | - | 92 | + statisticsService := service.NewStatisticsService(nil) |
93 | + systemCashStatisticsCommand := &command.SystemCashStatisticsCommand{} | ||
94 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), systemCashStatisticsCommand) | ||
95 | + data, err := statisticsService.SystemCashStatistics(systemCashStatisticsCommand) | ||
96 | + var response utils.JsonResponse | ||
97 | + if err != nil { | ||
98 | + response = utils.ResponseError(controller.Ctx, err) | ||
99 | + } else { | ||
100 | + response = utils.ResponseData(controller.Ctx, data) | ||
101 | + } | ||
102 | + controller.Data["json"] = response | ||
103 | + controller.ServeJSON() | ||
84 | } | 104 | } |
@@ -359,7 +359,6 @@ func (controller *SuMoneyController) ImportExchangeList () { | @@ -359,7 +359,6 @@ func (controller *SuMoneyController) ImportExchangeList () { | ||
359 | fmt.Println(err) | 359 | fmt.Println(err) |
360 | return | 360 | return |
361 | } | 361 | } |
362 | - // TODO 判断活动汇率是否为空 | ||
363 | 362 | ||
364 | var response utils.JsonResponse | 363 | var response utils.JsonResponse |
365 | dataList := make([]interface{}, 0) | 364 | dataList := make([]interface{}, 0) |
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/astaxie/beego" | ||
5 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego/controllers" | ||
6 | +) | ||
7 | + | ||
8 | +func init() { | ||
9 | + beego.Router("/list-interval/", &controllers.ListIntervalController{}, "Post:CreateListInterval") | ||
10 | + beego.Router("/list-interval/:intervalId", &controllers.ListIntervalController{}, "Put:UpdateListInterval") | ||
11 | + beego.Router("/list-interval/:intervalId", &controllers.ListIntervalController{}, "Get:GetListInterval") | ||
12 | + beego.Router("/list-interval/:intervalId", &controllers.ListIntervalController{}, "Delete:RemoveListInterval") | ||
13 | + beego.Router("/list-interval/", &controllers.ListIntervalController{}, "Get:ListListInterval") | ||
14 | +} |
@@ -23,10 +23,10 @@ func init() { | @@ -23,10 +23,10 @@ func init() { | ||
23 | beego.Router("/cash-pool/activity", &controllers.SuMoneyController{}, "POST:CreateExchangeActivities") // 新增兑换活动 | 23 | beego.Router("/cash-pool/activity", &controllers.SuMoneyController{}, "POST:CreateExchangeActivities") // 新增兑换活动 |
24 | beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeActivities") // 删除兑换活动 | 24 | beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeActivities") // 删除兑换活动 |
25 | 25 | ||
26 | - beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单 | ||
27 | - beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "GET:GetExchangeCashPerson") // 返回素币兑换人员 | ||
28 | - beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单 | ||
29 | - beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单 | ||
30 | - beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeCashPerson") // 删除素币兑换清单 | ||
31 | - beego.Router("/cash-pool/activity/exchange-list/import", &controllers.SuMoneyController{}, "POST:ImportExchangeList") // 导入素币兑换清单 | 26 | + beego.Router("/cash-pool/activity/exchange-listInterval", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单 |
27 | + beego.Router("/cash-pool/activity/exchange-listInterval/:listId", &controllers.SuMoneyController{}, "GET:GetExchangeCashPerson") // 返回素币兑换人员 | ||
28 | + beego.Router("/cash-pool/activity/exchange-listInterval", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单 | ||
29 | + beego.Router("/cash-pool/activity/exchange-listInterval/:listId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单 | ||
30 | + beego.Router("/cash-pool/activity/exchange-listInterval/:listId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeCashPerson") // 删除素币兑换清单 | ||
31 | + beego.Router("/cash-pool/activity/exchange-listInterval/import", &controllers.SuMoneyController{}, "POST:ImportExchangeList") // 导入素币兑换清单 | ||
32 | } | 32 | } |
-
请 注册 或 登录 后发表评论