正在显示
3 个修改的文件
包含
43 行增加
和
13 行删除
@@ -318,13 +318,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | @@ -318,13 +318,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | ||
318 | } | 318 | } |
319 | 319 | ||
320 | // 时间格式化 | 320 | // 时间格式化 |
321 | - dd, _ := time.ParseDuration("24h") | 321 | + //dd, _ := time.ParseDuration("24h") |
322 | //var deadline = createExchangeCashActivityCommand.Deadline.Add(dd) | 322 | //var deadline = createExchangeCashActivityCommand.Deadline.Add(dd) |
323 | //var deadline = createExchangeCashActivityCommand.Deadline | 323 | //var deadline = createExchangeCashActivityCommand.Deadline |
324 | - todayZero, _ := time.ParseInLocation("2006-01-02", createExchangeCashActivityCommand.Deadline, time.Local) | ||
325 | - deadline := todayZero.Add(dd) | 324 | + deadline, _ := time.ParseInLocation("2006-01-02", createExchangeCashActivityCommand.Deadline, time.Local) |
325 | + //deadline := todayZero.Add(dd) | ||
326 | var t1 = time.Now().Local() | 326 | var t1 = time.Now().Local() |
327 | - var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0 - 1, time.Local) | 327 | + var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local) |
328 | + | ||
329 | + fmt.Print(t2, "\n") | ||
328 | 330 | ||
329 | // 获取该公司所有兑换现金活动 | 331 | // 获取该公司所有兑换现金活动 |
330 | if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{ | 332 | if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{ |
@@ -334,7 +336,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | @@ -334,7 +336,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | ||
334 | } else { | 336 | } else { |
335 | for _, activity := range activities { | 337 | for _, activity := range activities { |
336 | //if t2.Format("2006-01-02") == activity.Deadline.UTC().Format("2006-01-02") { | 338 | //if t2.Format("2006-01-02") == activity.Deadline.UTC().Format("2006-01-02") { |
337 | - if t2.Format("2006-01-02") == activity.Deadline.Format("2006-01-02") { | 339 | + if t2.Format("2006-01-02") == activity.Deadline.Local().Format("2006-01-02") { |
338 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合") | 340 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合") |
339 | } | 341 | } |
340 | } | 342 | } |
@@ -550,13 +552,13 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas | @@ -550,13 +552,13 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas | ||
550 | } else { | 552 | } else { |
551 | for _, activity := range activities { | 553 | for _, activity := range activities { |
552 | var t1 = time.Now().Local() | 554 | var t1 = time.Now().Local() |
553 | - var t2 = activity.Deadline | 555 | + var t2 = activity.Deadline.Local() |
554 | 556 | ||
555 | // 更新兑换现金活动倒计时命令 | 557 | // 更新兑换现金活动倒计时命令 |
556 | updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { | 558 | updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { |
557 | ExchangeCashActivityId: activity.ActivityId, | 559 | ExchangeCashActivityId: activity.ActivityId, |
558 | CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 重新计算活动倒计时 | 560 | CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 重新计算活动倒计时 |
559 | - Deadline: activity.Deadline, | 561 | + Deadline: activity.Deadline.Local(), |
560 | ExchangedSuMoney: activity.ExchangedSuMoney, | 562 | ExchangedSuMoney: activity.ExchangedSuMoney, |
561 | ExchangedCash: activity.ExchangedCash, | 563 | ExchangedCash: activity.ExchangedCash, |
562 | ExchangeRate: activity.Rate, | 564 | ExchangeRate: activity.Rate, |
1 | package utils | 1 | package utils |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "encoding/json" | ||
4 | "fmt" | 5 | "fmt" |
5 | "time" | 6 | "time" |
6 | ) | 7 | ) |
@@ -48,3 +49,18 @@ func (l LocalDate) MarshalJSON() ([]byte, error) { | @@ -48,3 +49,18 @@ func (l LocalDate) MarshalJSON() ([]byte, error) { | ||
48 | stamp := fmt.Sprintf("\"%s\"", time.Time(l).Format("2006-01-02")) | 49 | stamp := fmt.Sprintf("\"%s\"", time.Time(l).Format("2006-01-02")) |
49 | return []byte(stamp), nil | 50 | return []byte(stamp), nil |
50 | } | 51 | } |
52 | + | ||
53 | +func JsonToMap(jsonStr string) (map[string]string, error) { | ||
54 | + m := make(map[string]string) | ||
55 | + err := json.Unmarshal([]byte(jsonStr), &m) | ||
56 | + if err != nil { | ||
57 | + fmt.Printf("Unmarshal with error: %+v\n", err) | ||
58 | + return nil, err | ||
59 | + } | ||
60 | + | ||
61 | + for k, v := range m { | ||
62 | + fmt.Printf("%v: %v\n", k, v) | ||
63 | + } | ||
64 | + | ||
65 | + return m, nil | ||
66 | +} |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "github.com/360EntSecGroup-Skylar/excelize/v2" | 6 | "github.com/360EntSecGroup-Skylar/excelize/v2" |
7 | "github.com/astaxie/beego" | 7 | "github.com/astaxie/beego" |
8 | "github.com/linmadan/egglib-go/web/beego/utils" | 8 | "github.com/linmadan/egglib-go/web/beego/utils" |
9 | + utils_tool "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils" | ||
9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command" | 10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command" |
10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query" | 11 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query" |
11 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service" | 12 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service" |
@@ -395,8 +396,19 @@ func (controller *SuMoneyController) ExchangeCashListRanking() { | @@ -395,8 +396,19 @@ func (controller *SuMoneyController) ExchangeCashListRanking() { | ||
395 | func (controller *SuMoneyController) ImportExchangeList () { | 396 | func (controller *SuMoneyController) ImportExchangeList () { |
396 | cashPoolService := service.NewCashPoolService(nil) | 397 | cashPoolService := service.NewCashPoolService(nil) |
397 | createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} | 398 | createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} |
398 | - activityId, _ := controller.GetInt64("activityId") | ||
399 | - operator, _ := controller.GetInt64("operator") | 399 | + //activityId, _ := controller.GetInt64("activityId") |
400 | + //operator, _ := controller.GetInt64("operator") | ||
401 | + whereStr := controller.GetString("where") | ||
402 | + where, err := utils_tool.JsonToMap(whereStr) | ||
403 | + | ||
404 | + //var jsonBlob = []byte(whereStr) | ||
405 | + //type Where struct { | ||
406 | + // ActivityId string | ||
407 | + // Uid string | ||
408 | + //} | ||
409 | + //var where Where | ||
410 | + //err := json.Unmarshal(jsonBlob, where) | ||
411 | + //fmt.Print(where, "\n") | ||
400 | file, h, _ := controller.GetFile("file") | 412 | file, h, _ := controller.GetFile("file") |
401 | 413 | ||
402 | // 错误信息返回 | 414 | // 错误信息返回 |
@@ -471,14 +483,14 @@ func (controller *SuMoneyController) ImportExchangeList () { | @@ -471,14 +483,14 @@ func (controller *SuMoneyController) ImportExchangeList () { | ||
471 | // 新增成功计数 | 483 | // 新增成功计数 |
472 | var successDataCount int64 | 484 | var successDataCount int64 |
473 | 485 | ||
474 | - fmt.Print(len(rows), "\n") | 486 | + //fmt.Print(len(rows), "\n") |
475 | 487 | ||
476 | for i, row := range rows { | 488 | for i, row := range rows { |
477 | - fmt.Printf("Row Number:%d, Row: %+v\n, Row Length: %d\n", i, row, len(row)) | 489 | + //fmt.Printf("Row Number:%d, Row: %+v\n, Row Length: %d\n", i, row, len(row)) |
478 | if i > 2 && len(row) > 1 { | 490 | if i > 2 && len(row) > 1 { |
479 | // 创建兑换清单命令 | 491 | // 创建兑换清单命令 |
480 | - createExchangeCashPersonCommand.ExchangeCashActivityId = activityId | ||
481 | - createExchangeCashPersonCommand.Operator = operator | 492 | + createExchangeCashPersonCommand.ExchangeCashActivityId ,err = strconv.ParseInt(where["activityId"], 10, 64) |
493 | + createExchangeCashPersonCommand.Operator, err = strconv.ParseInt(where["uid"], 10, 64) | ||
482 | createExchangeCashPersonCommand.PersonName = row[0] | 494 | createExchangeCashPersonCommand.PersonName = row[0] |
483 | createExchangeCashPersonCommand.PersonAccount = row[1] | 495 | createExchangeCashPersonCommand.PersonAccount = row[1] |
484 | r2, _ := strconv.ParseFloat(row[2], 64) | 496 | r2, _ := strconv.ParseFloat(row[2], 64) |
-
请 注册 或 登录 后发表评论