增加提现记录

This commit is contained in:
gong
2026-04-27 14:31:54 +08:00
parent a51728a14b
commit 0b65ae9705
8 changed files with 136 additions and 14 deletions

View File

@@ -279,6 +279,49 @@ func _execDiscSpinningRecord(db *gorm.DB, timeNow string, index int, totalCount
_execDiscSpinningRecord(db, timeNow, index+1, totalCount)
}
func copyCashOut(db *gorm.DB, timeNow time.Time) {
record := &data.CashOut{}
start := timeNow.Format("2006-01-02 15:04:05")
first := db.Model(record).Where("create_at < ?", start).Order("create_at asc").First(record)
if first.RowsAffected == 0 {
fmt.Println("no cash_out data")
return
}
deleteTime := record.CreateAt
db.Debug().Where("create_at >= ?", deleteTime).Delete(&data.CashOutCopy1{})
var totalCount int64 = 0
db.Debug().Model(&data.CashOut{}).Where("create_at >= ?", deleteTime).Count(&totalCount)
_execCashOut(db, start, 0, totalCount)
db.Debug().Where("create_at < ?", start).Delete(&data.CashOut{})
}
func _execCashOut(db *gorm.DB, timeNow string, index int, totalCount int64) {
var records []*data.CashOut
db.Debug().Where("create_at < ?", timeNow).Limit(1000).Offset(index * 1000).Find(&records)
fmt.Printf("index: %d, timeNow: %s ,cash_out count: %d, totalCount: %d\n", index, timeNow, len(records), totalCount)
if len(records) == 0 {
return
}
var copyList []*data.CashOutCopy1
for _, record := range records {
recordCopy := &data.CashOutCopy1{}
CopyStruct(record, recordCopy)
copyList = append(copyList, recordCopy)
}
db.Create(&copyList)
//time.Sleep(1500 * time.Millisecond)
_execCashOut(db, timeNow, index+1, totalCount)
}
// CopyStruct 使用反射复制结构体
func CopyStruct(src, dst interface{}) {
_ = copier.Copy(dst, src)

View File

@@ -24,7 +24,7 @@ func CopyData() {
panic("dbList is nil")
}
timeNow := time.Now().Add(-4 * 24 * time.Hour)
timeNow := time.Now().Add(-5 * 24 * time.Hour)
format := timeNow.Format("2006-01-02")
parse, _ := time.Parse("2006-01-02", format)
@@ -37,12 +37,14 @@ func CopyData() {
time.Sleep(time.Second * 2)
copyUserMoneyDetails(db, parse)
time.Sleep(time.Second * 2)
copyCourseCollect(db, parse)
time.Sleep(time.Second * 2)
copyCourseUser(db, parse)
time.Sleep(time.Second * 2)
//copyCourseCollect(db, parse)
//time.Sleep(time.Second * 2)
//copyCourseUser(db, parse)
//time.Sleep(time.Second * 2)
copyDiscSpinningRecord(db, parse)
time.Sleep(time.Second * 2)
copyCashOut(db, parse)
time.Sleep(time.Second * 2)
}
}