作者 陈志颖

fix:修复创建兑换活动返回倒计时问题

... ... @@ -8,9 +8,10 @@ import (
// 获取兑换现金活动列表
type ListExchangeCashActivityQuery struct {
CompanyId int64 `json:"companyId"` // 公司id
ExchangeCashActivityNameMatch string `json:"exchangeCashActivityNameMatch,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
ExchangeCashActivityNameMatch string `json:"exchangeCashActivityNameMatch,omitempty"` // 活动名称匹配
Deadline string `json:"deadline,omitempty"` // 截止时间筛选
Offset int `json:"offset,omitempty"` // 查询偏移量
Limit int `json:"limit,omitempty"` // 查询限制条目
}
func (listExchangeCashActivityQuery *ListExchangeCashActivityQuery) ValidateQuery() error {
... ...
... ... @@ -264,6 +264,12 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
CreateTime: time.Now(),
}
// 倒计时结束
if t2.Before(t1) {
newActivity.CountDown = 0
}
var exchangeCashActivityRepository domain.ExchangeActivityRepository
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1562,10 +1568,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashPersonById(exportExchang
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//return map[string]interface{}{
// "count": count,
// "people": people,
//}, nil
return people, nil
}
}
... ...
... ... @@ -2,12 +2,11 @@ package repository
import (
"fmt"
"time"
"github.com/go-pg/pg"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
"time"
)
type ExchangeCashActivityRepository struct {
... ... @@ -88,8 +87,16 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i
if exchangeCashActivityNameMatch, ok := queryOptions["exchangeCashActivityNameMatch"]; ok && (exchangeCashActivityNameMatch != "") {
query = query.Where(`exchange_cash_activity.activity_name LIKE ?`, fmt.Sprintf("%%%s%%", exchangeCashActivityNameMatch.(string)))
}
if deadline, ok := queryOptions["exchangeCashActivityDeadline"]; ok && !deadline.(time.Time).IsZero() {
query = query.Where(`exchange_cash_activity.deadline < ?`, deadline)
//if deadline, ok := queryOptions["deadline"]; ok && !deadline.(time.Time).IsZero() {
// query = query.Where(`exchange_cash_activity.deadline > ?`, deadline)
//}
if deadlineStr, ok := queryOptions["deadline"]; ok && (deadlineStr.(string) != "") {
var layout string = "2006-01-02"
deadline, _:= time.Parse(layout, deadlineStr.(string))
var t = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0, time.Local)
query = query.Where(`exchange_cash_activity.deadline > ?`, t)
}
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
... ...
... ... @@ -142,6 +142,8 @@ func (controller *SuMoneyController) ListExchangeActivities () {
listExchangeCashActivityQuery.CompanyId = companyId
exchangeCashActivityNameMatch := controller.GetString("activityNameMatch")
listExchangeCashActivityQuery.ExchangeCashActivityNameMatch = exchangeCashActivityNameMatch
deadline := controller.GetString("deadline")
listExchangeCashActivityQuery.Deadline = deadline
offset, _ := controller.GetInt("offset")
listExchangeCashActivityQuery.Offset = offset
limit, _ := controller.GetInt("limit")
... ...