作者 陈志颖

fix:修改更新活动时倒计时计算

@@ -485,6 +485,12 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA @@ -485,6 +485,12 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
485 Deadline: activity.Deadline, 485 Deadline: activity.Deadline,
486 } 486 }
487 487
  488 + // 倒计时结束
  489 + if t2.Before(t1) {
  490 + updateExchangeCashActivity.CountDown = 0
  491 + updateExchangeCashActivity.Deadline = activity.Deadline
  492 + }
  493 +
488 if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil { 494 if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil {
489 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 495 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
490 } 496 }
@@ -681,6 +687,20 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -681,6 +687,20 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
681 updateExchangeCashActivityCommand.ExchangedCash = updateExchangeCashActivityCommand.ExchangeRate * activity.ExchangedSuMoney 687 updateExchangeCashActivityCommand.ExchangedCash = updateExchangeCashActivityCommand.ExchangeRate * activity.ExchangedSuMoney
682 } 688 }
683 689
  690 + var timeNow = time.Now()
  691 + var deadline = updateExchangeCashActivityCommand.Deadline
  692 + var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
  693 + var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0, time.Local)
  694 +
  695 + // 计算倒计时
  696 + updateExchangeCashActivityCommand.CountDown = int64(t2.Sub(t1).Hours() / 24)
  697 +
  698 + // 倒计时结束
  699 + if t2.Before(t1) {
  700 + updateExchangeCashActivityCommand.CountDown = 0
  701 + updateExchangeCashActivityCommand.Deadline = activity.Deadline
  702 + }
  703 +
684 if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 704 if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
685 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 705 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
686 } 706 }