作者 陈志颖

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

... ... @@ -268,9 +268,24 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
if count, activities, err := exchangeActivityRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashActivityQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
// TODO 需要更新兑换活动结束倒计时
// 更新兑换活动结束倒计时
for _, activity := range activities {
var timeNow = time.Now()
var deadline = activity.Deadline
var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0, time.Local)
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
ExchangeCashActivityId: activity.ActivityId,
CountDown: int64(t2.Sub(t1).Hours() / 24),
}
if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
_, err := exchangeActivityRepository.Save(activity)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ...