作者 陈志颖

fix:修改定时任务

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