associate.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/job/main/vip/model"
  5. "go-common/library/database/sql"
  6. "github.com/pkg/errors"
  7. )
  8. const (
  9. _notGrantActOrder = "SELECT id,mid,order_no,product_id,months,panel_type,associate_state,ctime,mtime FROM vip_order_activity_record WHERE associate_state = 0 AND panel_type = ? limit ?;"
  10. )
  11. // NotGrantActOrders not grant activity order.
  12. func (d *Dao) NotGrantActOrders(c context.Context, panelType string, limit int) (res []*model.VipOrderActivityRecord, err error) {
  13. var rows *sql.Rows
  14. if rows, err = d.oldDb.Query(c, _notGrantActOrder, panelType, limit); err != nil {
  15. err = errors.Wrapf(err, "dao associate not grants query (%s,%d)", panelType, limit)
  16. return
  17. }
  18. defer rows.Close()
  19. for rows.Next() {
  20. r := new(model.VipOrderActivityRecord)
  21. if err = rows.Scan(&r.ID, &r.Mid, &r.OrderNo, &r.ProductID, &r.Months, &r.PanelType, &r.AssociateState, &r.Ctime, &r.Mtime); err != nil {
  22. err = errors.Wrapf(err, "dao associate not grants scan (%s,%d)", panelType, limit)
  23. res = nil
  24. return
  25. }
  26. res = append(res, r)
  27. }
  28. err = rows.Err()
  29. return
  30. }