作者 陈志颖

fix:返回兑换现金活动列表重新计算倒计时

@@ -268,9 +268,24 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -268,9 +268,24 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
268 if count, activities, err := exchangeActivityRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashActivityQuery)); err != nil { 268 if count, activities, err := exchangeActivityRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashActivityQuery)); err != nil {
269 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 269 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
270 } else { 270 } else {
271 - // TODO 需要更新兑换活动结束倒计时  
272 -  
273 - 271 + // 更新兑换活动结束倒计时
  272 + for _, activity := range activities {
  273 + var timeNow = time.Now()
  274 + var deadline = activity.Deadline
  275 + var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
  276 + var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0, time.Local)
  277 + updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
  278 + ExchangeCashActivityId: activity.ActivityId,
  279 + CountDown: int64(t2.Sub(t1).Hours() / 24),
  280 + }
  281 + if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil {
  282 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  283 + }
  284 + _, err := exchangeActivityRepository.Save(activity)
  285 + if err != nil {
  286 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  287 + }
  288 + }
274 if err := transactionContext.CommitTransaction(); err != nil { 289 if err := transactionContext.CommitTransaction(); err != nil {
275 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 290 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
276 } 291 }