正在显示
10 个修改的文件
包含
163 行增加
和
25 行删除
@@ -3,10 +3,15 @@ package command | @@ -3,10 +3,15 @@ package command | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "github.com/astaxie/beego/validation" | 5 | "github.com/astaxie/beego/validation" |
6 | + "time" | ||
6 | ) | 7 | ) |
7 | 8 | ||
8 | type SearchExchangeCashActivityCommand struct { | 9 | type SearchExchangeCashActivityCommand struct { |
9 | - ActivityName string `json:"activityName"` // 兑换现金活动名称 | 10 | + ActivityNameMatch string `json:"activityNameMatch"` // 兑换现金活动名称 |
11 | + CompanyId int64 `json:"companyId"` // 公司id | ||
12 | + Deadline time.Time `json:"deadline,omitempty"` // 截止时间筛选 | ||
13 | + Offset int `json:"offset,omitempty"` // 查询偏移量 | ||
14 | + Limit int `json:"limit,omitempty"` // 查询限制条目 | ||
10 | } | 15 | } |
11 | 16 | ||
12 | func (searchExchangeCashActivityCommand *SearchExchangeCashActivityCommand) ValidateCommand() error { | 17 | func (searchExchangeCashActivityCommand *SearchExchangeCashActivityCommand) ValidateCommand() error { |
@@ -8,8 +8,8 @@ import ( | @@ -8,8 +8,8 @@ import ( | ||
8 | // 获取兑换现金活动列表 | 8 | // 获取兑换现金活动列表 |
9 | type ListExchangeCashActivityQuery struct { | 9 | type ListExchangeCashActivityQuery struct { |
10 | CompanyId int64 `json:"companyId"` // 公司id | 10 | CompanyId int64 `json:"companyId"` // 公司id |
11 | - ExchangeCashActivityNameMatch string `json:"exchangeCashActivityNameMatch,omitempty"` // 活动名称匹配 | ||
12 | - Deadline string `json:"deadline,omitempty"` // 截止时间筛选 | 11 | + ActivityNameMatch string `json:"activityNameMatch,omitempty"` // 活动名称匹配 |
12 | + //Deadline time.Time `json:"deadline,omitempty"` // 截止时间筛选 | ||
13 | Offset int `json:"offset,omitempty"` // 查询偏移量 | 13 | Offset int `json:"offset,omitempty"` // 查询偏移量 |
14 | Limit int `json:"limit,omitempty"` // 查询限制条目 | 14 | Limit int `json:"limit,omitempty"` // 查询限制条目 |
15 | } | 15 | } |
@@ -277,7 +277,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | @@ -277,7 +277,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | ||
277 | var timeNow = time.Now() | 277 | var timeNow = time.Now() |
278 | var deadline = createExchangeCashActivityCommand.Deadline | 278 | var deadline = createExchangeCashActivityCommand.Deadline |
279 | var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local) | 279 | var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local) |
280 | - var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0, time.Local) | 280 | + var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local) |
281 | 281 | ||
282 | newActivity := &domain.ExchangeCashActivity{ | 282 | newActivity := &domain.ExchangeCashActivity{ |
283 | ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName, | 283 | ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName, |
@@ -285,7 +285,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | @@ -285,7 +285,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | ||
285 | ExchangedCash: 0, | 285 | ExchangedCash: 0, |
286 | ExchangedSuMoney: 0, | 286 | ExchangedSuMoney: 0, |
287 | //Deadline: time.Date(deadline.Year(), deadline.Month(), deadline.Day(), deadline.Hour(), deadline.Minute(), deadline.Second(), 0, time.Local), | 287 | //Deadline: time.Date(deadline.Year(), deadline.Month(), deadline.Day(), deadline.Hour(), deadline.Minute(), deadline.Second(), 0, time.Local), |
288 | - Deadline: createExchangeCashActivityCommand.Deadline, | 288 | + Deadline: deadline, |
289 | CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算活动截止倒计时 | 289 | CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算活动截止倒计时 |
290 | Rate: createExchangeCashActivityCommand.ExchangeRate, | 290 | Rate: createExchangeCashActivityCommand.ExchangeRate, |
291 | CreateTime: time.Now(), | 291 | CreateTime: time.Now(), |
@@ -349,7 +349,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc | @@ -349,7 +349,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc | ||
349 | 349 | ||
350 | var deadlines []interface{} | 350 | var deadlines []interface{} |
351 | for _, activity := range activities { | 351 | for _, activity := range activities { |
352 | - deadlines = append(deadlines, activity.Deadline.Format("2006-01-02")) | 352 | + deadlines = append(deadlines, activity.Deadline) |
353 | } | 353 | } |
354 | 354 | ||
355 | if len(deadlines) == 0 { | 355 | if len(deadlines) == 0 { |
@@ -362,6 +362,71 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc | @@ -362,6 +362,71 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc | ||
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | +// 搜索兑换现金活动 | ||
366 | +func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityCommand *command.SearchExchangeCashActivityCommand) (interface{}, error) { | ||
367 | + if err := activityCommand.ValidateCommand(); err != nil { | ||
368 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
369 | + } | ||
370 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
371 | + if err != nil { | ||
372 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
373 | + } | ||
374 | + if err := transactionContext.StartTransaction(); err != nil { | ||
375 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
376 | + } | ||
377 | + defer func() { | ||
378 | + transactionContext.RollbackTransaction() | ||
379 | + }() | ||
380 | + | ||
381 | + var exchangeActivityRepository domain.ExchangeActivityRepository | ||
382 | + if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{ | ||
383 | + "transactionContext": transactionContext, | ||
384 | + }); err != nil { | ||
385 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
386 | + } else { | ||
387 | + exchangeActivityRepository = value | ||
388 | + } | ||
389 | + | ||
390 | + if count, activities, err := exchangeActivityRepository.Find(tool_funs.SimpleStructToMap(activityCommand)); err != nil { | ||
391 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
392 | + } else { | ||
393 | + for _, activity := range activities { | ||
394 | + var t1 = time.Now() | ||
395 | + var t2 = activity.Deadline | ||
396 | + | ||
397 | + updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { | ||
398 | + ExchangeCashActivityId: activity.ActivityId, | ||
399 | + CountDown: int64(t2.Sub(t1).Hours() / 24), | ||
400 | + Deadline: activity.Deadline, | ||
401 | + } | ||
402 | + | ||
403 | + // 倒计时结束 | ||
404 | + if t2.Before(t1) { | ||
405 | + updateExchangeCashActivity.CountDown = 0 | ||
406 | + updateExchangeCashActivity.Deadline = activity.Deadline | ||
407 | + } | ||
408 | + | ||
409 | + if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil { | ||
410 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
411 | + } | ||
412 | + | ||
413 | + _, err := exchangeActivityRepository.Save(activity) | ||
414 | + if err != nil { | ||
415 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
416 | + } | ||
417 | + } | ||
418 | + | ||
419 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
420 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
421 | + } | ||
422 | + | ||
423 | + return map[string]interface{}{ | ||
424 | + "count": count, | ||
425 | + "activities": activities, | ||
426 | + }, nil | ||
427 | + } | ||
428 | +} | ||
429 | + | ||
365 | // 返回兑换现金活动列表 | 430 | // 返回兑换现金活动列表 |
366 | func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) { | 431 | func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) { |
367 | if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil { | 432 | if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil { |
@@ -391,10 +456,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas | @@ -391,10 +456,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas | ||
391 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 456 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
392 | } else { | 457 | } else { |
393 | for _, activity := range activities { | 458 | for _, activity := range activities { |
394 | - var timeNow = time.Now() | ||
395 | - var deadline = activity.Deadline | ||
396 | - var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local) | ||
397 | - var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0, time.Local) | 459 | + //var timeNow = time.Now() |
460 | + //var deadline = activity.Deadline | ||
461 | + //var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local) | ||
462 | + //var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local) | ||
463 | + var t1 = time.Now() | ||
464 | + var t2 = activity.Deadline | ||
398 | 465 | ||
399 | updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { | 466 | updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { |
400 | ExchangeCashActivityId: activity.ActivityId, | 467 | ExchangeCashActivityId: activity.ActivityId, |
@@ -108,6 +108,7 @@ type TaskStatus interface { | @@ -108,6 +108,7 @@ type TaskStatus interface { | ||
108 | RejectReceiver(task *Task) error | 108 | RejectReceiver(task *Task) error |
109 | } | 109 | } |
110 | 110 | ||
111 | +// 待发布的任务 | ||
111 | type UnReleasedStatus struct{} | 112 | type UnReleasedStatus struct{} |
112 | 113 | ||
113 | func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error { | 114 | func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error { |
@@ -433,6 +434,7 @@ func (status *UnderwayStatus) RejectReceiver(task *Task) error { | @@ -433,6 +434,7 @@ func (status *UnderwayStatus) RejectReceiver(task *Task) error { | ||
433 | return nil | 434 | return nil |
434 | } | 435 | } |
435 | 436 | ||
437 | +// 代验收的任务 | ||
436 | type UnAcceptanceStatus struct{} | 438 | type UnAcceptanceStatus struct{} |
437 | 439 | ||
438 | func (status *UnAcceptanceStatus) Update(task *Task, data map[string]interface{}) error { | 440 | func (status *UnAcceptanceStatus) Update(task *Task, data map[string]interface{}) error { |
@@ -580,6 +582,7 @@ func (status *ClosedStatus) RejectReceiver(task *Task) error { | @@ -580,6 +582,7 @@ func (status *ClosedStatus) RejectReceiver(task *Task) error { | ||
580 | return fmt.Errorf("已关闭的任务不允许驳回任务领取人") | 582 | return fmt.Errorf("已关闭的任务不允许驳回任务领取人") |
581 | } | 583 | } |
582 | 584 | ||
585 | +// 待确认任务 | ||
583 | type UnConfirmedStatus struct{} | 586 | type UnConfirmedStatus struct{} |
584 | 587 | ||
585 | func (status *UnConfirmedStatus) Update(task *Task, data map[string]interface{}) error { | 588 | func (status *UnConfirmedStatus) Update(task *Task, data map[string]interface{}) error { |
@@ -635,6 +638,49 @@ func (status *UnConfirmedStatus) RejectReceiver(task *Task) error { | @@ -635,6 +638,49 @@ func (status *UnConfirmedStatus) RejectReceiver(task *Task) error { | ||
635 | return nil | 638 | return nil |
636 | } | 639 | } |
637 | 640 | ||
641 | +// TODO 已过期任务 | ||
642 | +type ExpiredStatus struct{} | ||
643 | + | ||
644 | +func (status ExpiredStatus) Update(task *Task, data map[string]interface{}) error { | ||
645 | + panic("implement me") | ||
646 | +} | ||
647 | + | ||
648 | +func (status ExpiredStatus) Release(task *Task) error { | ||
649 | + panic("implement me") | ||
650 | +} | ||
651 | + | ||
652 | +func (status ExpiredStatus) Rob(task *Task, receiver *EmployeeInfo) error { | ||
653 | + panic("implement me") | ||
654 | +} | ||
655 | + | ||
656 | +func (status ExpiredStatus) Bib(task *Task, bidder *EmployeeInfo) error { | ||
657 | + panic("implement me") | ||
658 | +} | ||
659 | + | ||
660 | +func (status ExpiredStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error { | ||
661 | + panic("implement me") | ||
662 | +} | ||
663 | + | ||
664 | +func (status ExpiredStatus) ApplyComplete(task *Task) error { | ||
665 | + panic("implement me") | ||
666 | +} | ||
667 | + | ||
668 | +func (status ExpiredStatus) Off(task *Task) error { | ||
669 | + panic("implement me") | ||
670 | +} | ||
671 | + | ||
672 | +func (status ExpiredStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | ||
673 | + panic("implement me") | ||
674 | +} | ||
675 | + | ||
676 | +func (status ExpiredStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error { | ||
677 | + panic("implement me") | ||
678 | +} | ||
679 | + | ||
680 | +func (status ExpiredStatus) RejectReceiver(task *Task) error { | ||
681 | + panic("implement me") | ||
682 | +} | ||
683 | + | ||
638 | type TaskRepository interface { | 684 | type TaskRepository interface { |
639 | Save(task *Task) (*Task, error) | 685 | Save(task *Task) (*Task, error) |
640 | Remove(task *Task) (*Task, error) | 686 | Remove(task *Task) (*Task, error) |
@@ -41,7 +41,8 @@ func (dao *TaskDao) UpdateExpiredPlannedCompletionTimeBidTask() error { | @@ -41,7 +41,8 @@ func (dao *TaskDao) UpdateExpiredPlannedCompletionTimeBidTask() error { | ||
41 | query := tx.Model(&taskModels).Relation("RobInfo").Relation("BidInfo"). | 41 | query := tx.Model(&taskModels).Relation("RobInfo").Relation("BidInfo"). |
42 | Set("task.task_type = ", domain.TASK_STATUS_EXPIRED). | 42 | Set("task.task_type = ", domain.TASK_STATUS_EXPIRED). |
43 | Where("task.planned_completion_time > ?", currentDay). | 43 | Where("task.planned_completion_time > ?", currentDay). |
44 | - Where(`task.task_type =?`, domain.TASK_TYPE_BID) | 44 | + Where(`task.task_type = ?`, domain.TASK_TYPE_BID). |
45 | + Where(`task.task_status = ?`, domain.TASK_STATUS_UNCLAIMED) | ||
45 | if _, err := query.Update(); err != nil { | 46 | if _, err := query.Update(); err != nil { |
46 | return err | 47 | return err |
47 | } | 48 | } |
@@ -84,19 +84,20 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i | @@ -84,19 +84,20 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i | ||
84 | if companyId, ok := queryOptions["companyId"]; ok { | 84 | if companyId, ok := queryOptions["companyId"]; ok { |
85 | query = query.Where(`exchange_cash_activity.company_id = ?`, companyId) | 85 | query = query.Where(`exchange_cash_activity.company_id = ?`, companyId) |
86 | } | 86 | } |
87 | - if exchangeCashActivityNameMatch, ok := queryOptions["exchangeCashActivityNameMatch"]; ok && (exchangeCashActivityNameMatch != "") { | ||
88 | - query = query.Where(`exchange_cash_activity.activity_name LIKE ?`, fmt.Sprintf("%%%s%%", exchangeCashActivityNameMatch.(string))) | 87 | + if activityNameMatch, ok := queryOptions["activityNameMatch"]; ok && (activityNameMatch != "") { |
88 | + query = query.Where(`exchange_cash_activity.activity_name LIKE ?`, fmt.Sprintf("%%%s%%", activityNameMatch.(string))) | ||
89 | } | 89 | } |
90 | - | ||
91 | //if deadline, ok := queryOptions["deadline"]; ok && !deadline.(time.Time).IsZero() { | 90 | //if deadline, ok := queryOptions["deadline"]; ok && !deadline.(time.Time).IsZero() { |
92 | // query = query.Where(`exchange_cash_activity.deadline > ?`, deadline) | 91 | // query = query.Where(`exchange_cash_activity.deadline > ?`, deadline) |
93 | //} | 92 | //} |
94 | - | ||
95 | - if deadlineStr, ok := queryOptions["deadline"]; ok && (deadlineStr.(string) != "") { | ||
96 | - var layout string = "2006-01-02" | ||
97 | - deadline, _:= time.Parse(layout, deadlineStr.(string)) | ||
98 | - var t = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0, time.Local) | ||
99 | - query = query.Where(`exchange_cash_activity.deadline > ?`, t) | 93 | + if deadline, ok := queryOptions["deadline"]; ok && !deadline.(time.Time).IsZero() { |
94 | + //var layout string = "2006-01-02" | ||
95 | + ////deadline, _:= time.Parse(layout, deadlineStr.(string)) | ||
96 | + //deadline, _:= time.ParseInLocation(layout, deadlineStr.(string), time.Local) | ||
97 | + //fmt.Print(deadline, "\n") | ||
98 | + //var t = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0, time.Local) | ||
99 | + //fmt.Print(t, "\n") | ||
100 | + query = query.Where(`exchange_cash_activity.deadline > ?`, deadline) | ||
100 | } | 101 | } |
101 | if offset, ok := queryOptions["offset"]; ok { | 102 | if offset, ok := queryOptions["offset"]; ok { |
102 | offset := offset.(int) | 103 | offset := offset.(int) |
@@ -71,7 +71,7 @@ func (repository *SuMoneyTransactionRecordRepository) FindById(queryOptions map[ | @@ -71,7 +71,7 @@ func (repository *SuMoneyTransactionRecordRepository) FindById(queryOptions map[ | ||
71 | suMoneyTransactionRecords := make([]*domain.SuMoneyTransactionRecord, 0) | 71 | suMoneyTransactionRecords := make([]*domain.SuMoneyTransactionRecord, 0) |
72 | query := tx.Model(&suMoneyTransactionRecordModels) | 72 | query := tx.Model(&suMoneyTransactionRecordModels) |
73 | if iDs, ok := queryOptions["iDs"]; ok && len(iDs.([]int)) != 0 { | 73 | if iDs, ok := queryOptions["iDs"]; ok && len(iDs.([]int)) != 0 { |
74 | - query = query.Where("su_money_transaction_record.id IN (?)", pg.In(iDs.([]int))) | 74 | + query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int))) |
75 | } | 75 | } |
76 | if count, err := query.Order("id DESC").SelectAndCount(); err != nil { | 76 | if count, err := query.Order("id DESC").SelectAndCount(); err != nil { |
77 | return 0, suMoneyTransactionRecords, err | 77 | return 0, suMoneyTransactionRecords, err |
@@ -317,6 +317,9 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model | @@ -317,6 +317,9 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model | ||
317 | case domain.TASK_STATUS_UNCONFIRMED: | 317 | case domain.TASK_STATUS_UNCONFIRMED: |
318 | currentStatus = &domain.UnConfirmedStatus{} | 318 | currentStatus = &domain.UnConfirmedStatus{} |
319 | break | 319 | break |
320 | + case domain.TASK_STATUS_EXPIRED: | ||
321 | + currentStatus = &domain.ExpiredStatus{} | ||
322 | + break | ||
320 | } | 323 | } |
321 | return &domain.Task{ | 324 | return &domain.Task{ |
322 | TaskId: taskModel.Id, | 325 | TaskId: taskModel.Id, |
@@ -138,7 +138,6 @@ func (controller *SuMoneyController) CashInput() { | @@ -138,7 +138,6 @@ func (controller *SuMoneyController) CashInput() { | ||
138 | func (controller *SuMoneyController) GetCashPool() { | 138 | func (controller *SuMoneyController) GetCashPool() { |
139 | cashPoolService := service.NewCashPoolService(nil) | 139 | cashPoolService := service.NewCashPoolService(nil) |
140 | getCashPoolQuery := &query.GetCashPoolQuery{} | 140 | getCashPoolQuery := &query.GetCashPoolQuery{} |
141 | - //json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), getCashPoolQuery) | ||
142 | companyId, _ := controller.GetInt64("companyId") | 141 | companyId, _ := controller.GetInt64("companyId") |
143 | getCashPoolQuery.CompanyId = companyId | 142 | getCashPoolQuery.CompanyId = companyId |
144 | data, err := cashPoolService.GetCashPool(getCashPoolQuery) | 143 | data, err := cashPoolService.GetCashPool(getCashPoolQuery) |
@@ -152,6 +151,22 @@ func (controller *SuMoneyController) GetCashPool() { | @@ -152,6 +151,22 @@ func (controller *SuMoneyController) GetCashPool() { | ||
152 | controller.ServeJSON() | 151 | controller.ServeJSON() |
153 | } | 152 | } |
154 | 153 | ||
154 | +// 搜索返回兑换活动列表 | ||
155 | +func (controller *SuMoneyController) SearchExchangeActivities () { | ||
156 | + cashPoolService := service.NewCashPoolService(nil) | ||
157 | + searchExchangeCashActivityCommand := &command.SearchExchangeCashActivityCommand{} | ||
158 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), searchExchangeCashActivityCommand) | ||
159 | + data, err := cashPoolService.SearchExchangeCashActivity(searchExchangeCashActivityCommand) | ||
160 | + var response utils.JsonResponse | ||
161 | + if err != nil { | ||
162 | + response = utils.ResponseError(controller.Ctx, err) | ||
163 | + } else { | ||
164 | + response = utils.ResponseData(controller.Ctx, data) | ||
165 | + } | ||
166 | + controller.Data["json"] = response | ||
167 | + controller.ServeJSON() | ||
168 | +} | ||
169 | + | ||
155 | // 返回兑换活动列表 | 170 | // 返回兑换活动列表 |
156 | func (controller *SuMoneyController) ListExchangeActivities () { | 171 | func (controller *SuMoneyController) ListExchangeActivities () { |
157 | cashPoolService := service.NewCashPoolService(nil) | 172 | cashPoolService := service.NewCashPoolService(nil) |
@@ -159,9 +174,7 @@ func (controller *SuMoneyController) ListExchangeActivities () { | @@ -159,9 +174,7 @@ func (controller *SuMoneyController) ListExchangeActivities () { | ||
159 | companyId, _ := controller.GetInt64("companyId") | 174 | companyId, _ := controller.GetInt64("companyId") |
160 | listExchangeCashActivityQuery.CompanyId = companyId | 175 | listExchangeCashActivityQuery.CompanyId = companyId |
161 | exchangeCashActivityNameMatch := controller.GetString("activityNameMatch") | 176 | exchangeCashActivityNameMatch := controller.GetString("activityNameMatch") |
162 | - listExchangeCashActivityQuery.ExchangeCashActivityNameMatch = exchangeCashActivityNameMatch | ||
163 | - deadline := controller.GetString("deadline") | ||
164 | - listExchangeCashActivityQuery.Deadline = deadline | 177 | + listExchangeCashActivityQuery.ActivityNameMatch = exchangeCashActivityNameMatch |
165 | offset, _ := controller.GetInt("offset") | 178 | offset, _ := controller.GetInt("offset") |
166 | listExchangeCashActivityQuery.Offset = offset | 179 | listExchangeCashActivityQuery.Offset = offset |
167 | limit, _ := controller.GetInt("limit") | 180 | limit, _ := controller.GetInt("limit") |
@@ -629,6 +642,7 @@ func (controller *SuMoneyController) ExportSuMoneyTransactionRecord() { | @@ -629,6 +642,7 @@ func (controller *SuMoneyController) ExportSuMoneyTransactionRecord() { | ||
629 | case float64: | 642 | case float64: |
630 | f.SetCellValue("Sheet1", sheetPosition, vv.(float64)) | 643 | f.SetCellValue("Sheet1", sheetPosition, vv.(float64)) |
631 | break | 644 | break |
645 | + // TODO 时间类型和格式转换 | ||
632 | case time.Time: | 646 | case time.Time: |
633 | f.SetCellValue("Sheet1", sheetPosition, vv) | 647 | f.SetCellValue("Sheet1", sheetPosition, vv) |
634 | break | 648 | break |
@@ -27,6 +27,7 @@ func init() { | @@ -27,6 +27,7 @@ func init() { | ||
27 | beego.Router("/cash-pool/activity", &controllers.SuMoneyController{}, "Post:CreateExchangeActivities") // 新增兑换活动 | 27 | beego.Router("/cash-pool/activity", &controllers.SuMoneyController{}, "Post:CreateExchangeActivities") // 新增兑换活动 |
28 | beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "Delete:RemoveExchangeActivities") // 删除兑换活动 | 28 | beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "Delete:RemoveExchangeActivities") // 删除兑换活动 |
29 | beego.Router("/cash-pool/activity/deadline-list", &controllers.SuMoneyController{}, "Get:ListDeadline") // 返回兑换活动截止时间列表 | 29 | beego.Router("/cash-pool/activity/deadline-list", &controllers.SuMoneyController{}, "Get:ListDeadline") // 返回兑换活动截止时间列表 |
30 | + beego.Router("/cash-pool/activity/search-activity", &controllers.SuMoneyController{}, "Post:SearchExchangeActivities") // 搜索兑换活动列表 | ||
30 | 31 | ||
31 | /********************************************素币兑换清单*************************************/ | 32 | /********************************************素币兑换清单*************************************/ |
32 | beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "Get:ListExchangeList") // 返回素币兑换清单 | 33 | beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "Get:ListExchangeList") // 返回素币兑换清单 |
-
请 注册 或 登录 后发表评论