作者 陈志颖

fix:修改定时任务

... ... @@ -14,6 +14,7 @@ func main() {
for {
now := time.Now()
next := now.Add(time.Hour * 24)
//next := now.Add(time.Minute * 5)
nextZero := time.Date(next.Year(), next.Month(), next.Day(), 0, 0, 0, 0, next.Location())
dispatchTicker := time.NewTimer(nextZero.Sub(now))
<-dispatchTicker.C
... ...
... ... @@ -34,19 +34,14 @@ func (dao *TaskDao) ListNearThePlannedCompletionTimeTask() ([]*models.Task, erro
// 更新已过期的竞标任务的状态
func (dao *TaskDao) UpdateExpiredPlannedCompletionTimeBidTask() error {
tx := dao.transactionContext.PgTx
var taskModels []*models.Task
currentTime := time.Now()
currentDay := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, time.Now().Location())
query := tx.Model(&taskModels).Relation("RobInfo").Relation("BidInfo").
Set("task.task_type = ", domain.TASK_STATUS_EXPIRED).
Where("task.planned_completion_time > ?", currentDay).
Where(`task.task_type = ?`, domain.TASK_TYPE_BID).
Where(`task.task_status = ?`, domain.TASK_STATUS_UNCLAIMED)
if _, err := query.Update(); err != nil {
return err
}
return nil
tx := dao.transactionContext.PgTx
_, err := tx.Query(
pg.Scan(),
"UPDATE tasks SET task_status = ? WHERE planned_completion_time > ? AND task_type = ? AND task_status = ?",
domain.TASK_STATUS_EXPIRED, currentDay, domain.TASK_TYPE_BID, domain.TASK_STATUS_UNCLAIMED)
return err
}
// 返回接近竞标截止时间的竞标任务
... ...
... ... @@ -65,8 +65,8 @@ func (service *OperationSuMoneyService) Operation(uid int64, operatorUid int64,
recordType = domain.SU_MONEY_TRANSACTION_RECORD_TYPE_DEDUCT
transferSuMoney = 0 - suMoney
}
if operationType == 3 { // 兑换现金
recordType = domain.SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE_CASH
if operationType == 3 { // 兑换
recordType = domain.SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE
transferSuMoney = 0 - suMoney
}
suMoneyTransactionRecord := &domain.SuMoneyTransactionRecord{
... ...
... ... @@ -59,7 +59,10 @@ func (repository *ExchangeCashPersonListRepository) FindById(queryOptions map[st
var exchangeCashListModels []*models.ExchangeCashPersonList
exchangeCashPeople := make([]*domain.ExchangeCashPersonList, 0)
query := tx.Model(&exchangeCashListModels)
if iDs, ok := queryOptions["iDs"]; ok && len(iDs.([]int)) != 0 {
//if iDs, ok := queryOptions["iDs"]; ok && len(iDs.([]int)) != 0 {
// query = query.Where("exchange_cash_person_list.id IN (?)", pg.In(iDs.([]int)) )
//}
if iDs, ok := queryOptions["iDs"]; ok {
query = query.Where("exchange_cash_person_list.id IN (?)", pg.In(iDs.([]int)) )
}
if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
... ...
... ... @@ -70,7 +70,10 @@ func (repository *SuMoneyTransactionRecordRepository) FindById(queryOptions map[
var suMoneyTransactionRecordModels []*models.SuMoneyTransactionRecord
suMoneyTransactionRecords := make([]*domain.SuMoneyTransactionRecord, 0)
query := tx.Model(&suMoneyTransactionRecordModels)
if iDs, ok := queryOptions["iDs"]; ok && len(iDs.([]int)) != 0 {
//if iDs, ok := queryOptions["iDs"]; ok && len(iDs.([]int)) != 0 {
// query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int)))
//}
if iDs, ok := queryOptions["iDs"]; ok {
query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int)))
}
if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
... ...