gift_time.go 974 Bytes
Newer Older
hujiebin's avatar
1  
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
package main

import (
	"git.hilo.cn/hilo-common/mylogrus"
	"git.hilo.cn/hilo-common/script/mysql"
	"time"
)

type GiftOperate struct {
	ResGiftId          uint64
	GiftN              uint64
	SendUserId         uint64
	ReceiveUserId      uint64
	SendUserDiamond    uint64
	ReceiveUserDiamond uint64
	ReceiveUserBean    uint64
	SceneUid           string
	BagId              uint64
	ID                 uint64    `gorm:"primary_key"`
	CreatedTime        time.Time `gorm:"->"`
	UpdatedTime        time.Time `gorm:"->"`
}

func main() {
	var gift GiftOperate
	if err := mysql.ProdReadOnlyDB.Table("gift_operate_2").Order("id ASC").First(&gift).Error; err != nil {
		mylogrus.MyLog.Errorf("GiftOperateTable fail:%v", err)
		panic("e")
	}
	println(time.Now().Sub(gift.CreatedTime).Hours())
	if !gift.CreatedTime.IsZero() && time.Now().Sub(gift.CreatedTime) >= time.Hour*24*90 && time.Now().Hour() == 10 { // newTable已经过去90天
		println(true)
	} else {
		println(false)
	}
}