123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package entity
- import (
- "log"
- . "online_datasync/config"
- . "online_datasync/db"
- . "app.yhyue.com/moapp/jybase/date"
- )
- var (
- User_prize *user_prize
- )
- type user_prize struct {
- }
- func (u *user_prize) TableName() string {
- return "user_prize"
- }
- //
- func (u *user_prize) SaveFields() []string {
- return []string{"id", "userId", "prizeId", "validityDates", "beginDate", "endDate", "useDate", "prizeType", "appId", "lotteryId", "createTime", "name", "full", "reduce", "userName", "orderCode", "timestamp"}
- }
- //
- func (u *user_prize) Run(start_unix, end_unix int64, start_layout, end_layout string) {
- TimeTask.User_prize_id = sync_add(Mysql_From_Jyactivities, u.TableName(), u.SaveFields(), TimeTask.User_prize_id, nil)
- if start_unix > 0 {
- u.update(start_layout, end_layout)
- }
- }
- //
- func (u *user_prize) update(start_layout, end_layout string) {
- log.Println("开始同步更新", u.TableName(), "表 。。。")
- index := 0
- array := [][]interface{}{}
- fields := []string{"prizeType", "timestamp"}
- Mysql_From_Jyactivities.SelectByBath(Config.SelectBathSize, func(l *[]map[string]interface{}) {
- for _, v := range *l {
- index++
- array = append(array, []interface{}{v["prizeType"], NowFormat(Date_Full_Layout)})
- if index%Config.UpdateBathSize == 0 {
- log.Println("同步更新", u.TableName(), "表", index)
- Mysql_Main.UpdateBath(u.TableName(), fields, array)
- array = [][]interface{}{}
- }
- }
- }, `select prizeType from user_prize where useDate>=? and useDate<?`, start_layout, end_layout)
- if len(array) > 0 {
- Mysql_Main.UpdateBath(u.TableName(), fields, array)
- array = [][]interface{}{}
- }
- log.Println("同步更新", u.TableName(), "表结束。。。", index)
- }
|