205 lines
4.0 KiB
Go
205 lines
4.0 KiB
Go
package rchgordmod
|
|
|
|
import (
|
|
"time"
|
|
|
|
"91porn-server/common/log"
|
|
"91porn-server/common/pageopt"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
)
|
|
|
|
type Matcher = pageopt.Matcher
|
|
|
|
// ChannelMatch
|
|
type ChannelMatch struct {
|
|
Channel *string
|
|
}
|
|
|
|
func (c *ChannelMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("channel", c.Channel)
|
|
}
|
|
|
|
// StatusMatch
|
|
type StatusMatch struct {
|
|
Status *int
|
|
}
|
|
|
|
func (s *StatusMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("status", s.Status)
|
|
}
|
|
|
|
// IDMatch
|
|
type IDMatch = pageopt.IDMatch
|
|
|
|
// UIDMatch
|
|
type UIDMatch = pageopt.UIDMatch
|
|
|
|
// UIDInMatch
|
|
type UIDInMatch = pageopt.UIDInMatch
|
|
|
|
// RechargeTypeMatch
|
|
type RechargeTypeMatch struct {
|
|
RechargeType *string
|
|
}
|
|
|
|
func (s *RechargeTypeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("rechargeType", s.RechargeType)
|
|
}
|
|
|
|
// RechargeTypeINMatch
|
|
type RechargeTypeINMatch struct {
|
|
RechargeTypes []RechType
|
|
}
|
|
|
|
func (s *RechargeTypeINMatch) New() Matcher {
|
|
return pageopt.NewInMatch("rechargeType", s.RechargeTypes)
|
|
}
|
|
|
|
// DistrictCodeMatch
|
|
type DistrictCodeMatch struct {
|
|
DistrictCode *string
|
|
}
|
|
|
|
func (s *DistrictCodeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("districtCode", s.DistrictCode)
|
|
}
|
|
|
|
// PromSeqeMatch
|
|
type PromSeqeMatch struct {
|
|
PromSeqe *string
|
|
}
|
|
|
|
func (s *PromSeqeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("promSeqe", s.PromSeqe)
|
|
}
|
|
|
|
// IsDirectMatch
|
|
type IsDirectMatch struct {
|
|
IsDirect *bool
|
|
}
|
|
|
|
func (b *IsDirectMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("isDirect", b.IsDirect)
|
|
}
|
|
|
|
type DevTypeMatch struct {
|
|
DevType *string
|
|
}
|
|
|
|
func (d *DevTypeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("devType", d.DevType)
|
|
}
|
|
|
|
// StatusInMatch
|
|
type StatusInMatch struct {
|
|
Status []int
|
|
}
|
|
|
|
func (d *StatusInMatch) New() Matcher {
|
|
return pageopt.NewInMatch("status", d.Status)
|
|
}
|
|
|
|
// NotifyStatusMatch
|
|
type NotifyStatusMatch struct {
|
|
NotifyStatus []int
|
|
}
|
|
|
|
func (d *NotifyStatusMatch) New() Matcher {
|
|
return pageopt.NewInMatch("notifyStatus", d.NotifyStatus)
|
|
}
|
|
|
|
// ProgressAtGTEAndLTMatch
|
|
type ProgressAtGTEAndLTMatch struct {
|
|
GTE *time.Time
|
|
LT *time.Time
|
|
}
|
|
|
|
func (s *ProgressAtGTEAndLTMatch) New() Matcher {
|
|
return pageopt.NewGTEAndLTMatch("progressAt", s.GTE, s.LT)
|
|
}
|
|
|
|
// FailureAtGTEAndLTMatch
|
|
type FailureAtGTEAndLTMatch struct {
|
|
GTE *time.Time
|
|
LT *time.Time
|
|
}
|
|
|
|
func (s *FailureAtGTEAndLTMatch) New() Matcher {
|
|
return pageopt.NewGTEAndLTMatch("failureAt", s.GTE, s.LT)
|
|
}
|
|
|
|
// SuccessAtGTEAndLTMatch
|
|
type SuccessAtGTEAndLTMatch struct {
|
|
GTE *time.Time
|
|
LT *time.Time
|
|
}
|
|
|
|
func (s *SuccessAtGTEAndLTMatch) New() Matcher {
|
|
return pageopt.NewGTEAndLTMatch("successAt", s.GTE, s.LT)
|
|
}
|
|
|
|
//PaymentAtGTEAndLTMatch
|
|
//type PaymentAtGTEAndLTMatch struct {
|
|
// GTE *time.Time
|
|
// LT *time.Time
|
|
//}
|
|
//
|
|
//func (s *PaymentAtGTEAndLTMatch) New() Matcher {
|
|
// return pageopt.NewGTEAndLTMatch("paymentAt", s.GTE, s.LT)
|
|
//}
|
|
|
|
// CreatedAtGTEAndLTMatch
|
|
type CreatedAtGTEAndLTMatch = pageopt.CreatedAtGTEAndLTMatch
|
|
|
|
// CreatedAtLTMatch
|
|
type CreatedAtLTMatch = pageopt.CreatedAtLTMatch
|
|
|
|
type Sort = bson.D
|
|
|
|
type M = bson.M
|
|
|
|
var Sort_CreatedAt_n1 = Sort{{Key: "createdAt", Value: -1}}
|
|
|
|
type RechargeOrderSlice []*RechargeOrder
|
|
|
|
func (this RechargeOrderSlice) Map() map[primitive.ObjectID]*RechargeOrder {
|
|
m := map[primitive.ObjectID]*RechargeOrder{}
|
|
for _, v := range this {
|
|
m[v.ID] = v
|
|
}
|
|
return m
|
|
}
|
|
|
|
func List(sort Sort, skip, limit *int64, matchers ...Matcher) (RechargeOrderSlice, error) {
|
|
filter := pageopt.MergeM(matchers)
|
|
opt := (&options.FindOptions{})
|
|
if len(sort) != 0 {
|
|
opt.SetSort(sort)
|
|
}
|
|
if skip != nil {
|
|
opt.SetSkip(*skip)
|
|
}
|
|
if limit != nil {
|
|
opt.SetLimit(*limit)
|
|
}
|
|
list := RechargeOrderSlice{}
|
|
if err := coll(nil).Find(&list, filter, opt); err != nil {
|
|
log.Error("rchgordmod List error", log.E(err))
|
|
return nil, err
|
|
}
|
|
return list, nil
|
|
}
|
|
|
|
func Count(matchers ...Matcher) (int64, error) {
|
|
filter := pageopt.MergeM(matchers)
|
|
count, err := coll(nil).Count(filter)
|
|
if err != nil {
|
|
log.Error("rchgordmod Count error", log.E(err))
|
|
return 0, err
|
|
}
|
|
return count, nil
|
|
}
|