正在显示
1 个修改的文件
包含
25 行增加
和
9 行删除
@@ -288,7 +288,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | @@ -288,7 +288,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang | ||
288 | } | 288 | } |
289 | 289 | ||
290 | // 时间格式化 | 290 | // 时间格式化 |
291 | - var deadline = createExchangeCashActivityCommand.Deadline | 291 | + dd, _ := time.ParseDuration("24h") |
292 | + var deadline = createExchangeCashActivityCommand.Deadline.Add(dd) | ||
292 | var t1 = time.Now() | 293 | var t1 = time.Now() |
293 | var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.UTC) | 294 | var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.UTC) |
294 | 295 | ||
@@ -357,7 +358,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc | @@ -357,7 +358,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc | ||
357 | // 提取兑换现金活动截止时间 | 358 | // 提取兑换现金活动截止时间 |
358 | var deadlines []interface{} | 359 | var deadlines []interface{} |
359 | for _, activity := range activities { | 360 | for _, activity := range activities { |
360 | - tmpTime := activity.Deadline.Format("2006-01-02") | 361 | + tmpTime := activity.Deadline.UTC().Format("2006-01-02") |
361 | if !utils.IsContain(deadlines, tmpTime) { | 362 | if !utils.IsContain(deadlines, tmpTime) { |
362 | deadlines = append(deadlines, tmpTime) | 363 | deadlines = append(deadlines, tmpTime) |
363 | } | 364 | } |
@@ -397,8 +398,6 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma | @@ -397,8 +398,6 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma | ||
397 | exchangeActivityRepository = value | 398 | exchangeActivityRepository = value |
398 | } | 399 | } |
399 | 400 | ||
400 | - //fmt.Printf("查找活动命令:%+v\n", activityCommand) | ||
401 | - | ||
402 | // 查找兑换现金活动 | 401 | // 查找兑换现金活动 |
403 | if count, activities, err := exchangeActivityRepository.Find(tool_funs.SimpleStructToMap(activityCommand)); err != nil { | 402 | if count, activities, err := exchangeActivityRepository.Find(tool_funs.SimpleStructToMap(activityCommand)); err != nil { |
404 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 403 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -407,7 +406,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma | @@ -407,7 +406,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma | ||
407 | var t1 = time.Now() | 406 | var t1 = time.Now() |
408 | var t2 = activity.Deadline | 407 | var t2 = activity.Deadline |
409 | 408 | ||
410 | - // 更新兑换活动命令 | 409 | + // 更新兑换活动倒计时命令 |
411 | updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { | 410 | updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { |
412 | ExchangeCashActivityId: activity.ActivityId, | 411 | ExchangeCashActivityId: activity.ActivityId, |
413 | CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算倒计时 | 412 | CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算倒计时 |
@@ -423,12 +422,12 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma | @@ -423,12 +422,12 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma | ||
423 | updateExchangeCashActivity.Deadline = activity.Deadline | 422 | updateExchangeCashActivity.Deadline = activity.Deadline |
424 | } | 423 | } |
425 | 424 | ||
426 | - // 更新兑换现金活动 | 425 | + // 更新兑换现金活动倒计时 |
427 | if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil { | 426 | if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil { |
428 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 427 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
429 | } | 428 | } |
430 | 429 | ||
431 | - // 保存更新 | 430 | + // 保存兑换现金活动倒计时更新 |
432 | _, err := exchangeActivityRepository.Save(activity) | 431 | _, err := exchangeActivityRepository.Save(activity) |
433 | if err != nil { | 432 | if err != nil { |
434 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 433 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -438,9 +437,26 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma | @@ -438,9 +437,26 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma | ||
438 | if err := transactionContext.CommitTransaction(); err != nil { | 437 | if err := transactionContext.CommitTransaction(); err != nil { |
439 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 438 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
440 | } | 439 | } |
440 | + | ||
441 | + var activitiesFormat []interface{} | ||
442 | + for _, activity := range activities { | ||
443 | + activityFormat := map[string]interface{} { | ||
444 | + "activityId": activity.ActivityId, | ||
445 | + "exchangeActivityName": activity.ExchangeActivityName, | ||
446 | + "companyId": activity.CompanyId, | ||
447 | + "exchangedCash": activity.ExchangedCash, | ||
448 | + "exchangedSuMoney": activity.ExchangedSuMoney, | ||
449 | + "deadline": activity.Deadline.UTC().Format("2006-01-02"), | ||
450 | + "countDown": activity.CountDown, | ||
451 | + "rate": activity.Rate, | ||
452 | + "createTime": activity.CreateTime.UTC(), | ||
453 | + } | ||
454 | + activitiesFormat = append(activitiesFormat, activityFormat) | ||
455 | + } | ||
456 | + | ||
441 | return map[string]interface{}{ | 457 | return map[string]interface{}{ |
442 | "count": count, | 458 | "count": count, |
443 | - "activities": activities, | 459 | + "activities": activitiesFormat, |
444 | }, nil | 460 | }, nil |
445 | } | 461 | } |
446 | } | 462 | } |
@@ -522,7 +538,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas | @@ -522,7 +538,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas | ||
522 | "deadline": activity.Deadline.UnixNano() / 1e6, // 秒级时间戳转换 | 538 | "deadline": activity.Deadline.UnixNano() / 1e6, // 秒级时间戳转换 |
523 | "countDown": activity.CountDown, | 539 | "countDown": activity.CountDown, |
524 | "rate": activity.Rate, | 540 | "rate": activity.Rate, |
525 | - "createTime": activity.CreateTime, | 541 | + "createTime": activity.CreateTime.UTC(), |
526 | } | 542 | } |
527 | activitiesWithTs = append(activitiesWithTs, activityWithTs) | 543 | activitiesWithTs = append(activitiesWithTs, activityWithTs) |
528 | } | 544 | } |
-
请 注册 或 登录 后发表评论