sync.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package dao
  2. import (
  3. "context"
  4. xsql "database/sql"
  5. "go-common/app/job/main/vip/model"
  6. "github.com/pkg/errors"
  7. )
  8. const (
  9. //sync
  10. _syncAddUser = "INSERT INTO vip_user_info(mid,vip_type,vip_pay_type,vip_status,vip_start_time,vip_overdue_time,annual_vip_overdue_time,vip_recent_time,ios_overdue_time,pay_channel_id,ctime,mtime,ver) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"
  11. _syncUpdateUser = "UPDATE vip_user_info SET vip_type=?,vip_pay_type=?,vip_status=?,vip_overdue_time=?,annual_vip_overdue_time=?,vip_recent_time=?,ios_overdue_time=?,pay_channel_id=?,ctime=?,mtime=?,ver=? WHERE mid=? AND ver=?"
  12. )
  13. //SyncAddUser insert vipUserInfo
  14. func (d *Dao) SyncAddUser(c context.Context, r *model.VipUserInfo) (err error) {
  15. if _, err = d.db.Exec(c, _syncAddUser, r.Mid, r.Type, r.PayType, r.Status, r.StartTime, r.OverdueTime, r.AnnualVipOverdueTime, r.RecentTime, r.OverdueTime, r.PayChannelID, r.Ctime, r.Mtime, r.Ver); err != nil {
  16. err = errors.WithStack(err)
  17. }
  18. return
  19. }
  20. //SyncUpdateUser insert vipUserInfo
  21. func (d *Dao) SyncUpdateUser(c context.Context, r *model.VipUserInfo, ver int64) (eff int64, err error) {
  22. var res xsql.Result
  23. if res, err = d.db.Exec(c, _syncUpdateUser, r.Type, r.PayType, r.Status, r.OverdueTime, r.AnnualVipOverdueTime, r.RecentTime, r.IosOverdueTime, r.PayChannelID, r.Ctime, r.Mtime, r.Ver, r.Mid, ver); err != nil {
  24. err = errors.WithStack(err)
  25. return
  26. }
  27. if eff, err = res.RowsAffected(); err != nil {
  28. err = errors.WithStack(err)
  29. }
  30. return
  31. }