201 lines
4.2 KiB
Go
201 lines
4.2 KiB
Go
package wdordmod
|
|
|
|
import (
|
|
"fmt"
|
|
"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
|
|
|
|
// StatusMatch
|
|
type StatusMatch struct {
|
|
Status *int
|
|
}
|
|
|
|
func (s *StatusMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("status", s.Status)
|
|
}
|
|
|
|
// UIDMatch
|
|
type UIDMatch = pageopt.UIDMatch
|
|
|
|
// WithdrawTypeMatch
|
|
type WithdrawTypeMatch struct {
|
|
WithdrawTypes *WithdrawTypes
|
|
}
|
|
|
|
func (w *WithdrawTypeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("withdrawType", w.WithdrawTypes)
|
|
}
|
|
|
|
// WithdrawTypeNEMatch
|
|
type WithdrawTypeNEMatch struct {
|
|
WithdrawTypes *WithdrawTypes
|
|
}
|
|
|
|
func (w *WithdrawTypeNEMatch) New() Matcher {
|
|
return pageopt.NewNEMatch("withdrawType", w.WithdrawTypes)
|
|
}
|
|
|
|
// PayTypeMatch
|
|
type PayTypeMatch struct {
|
|
PayType *string
|
|
}
|
|
|
|
func (w *PayTypeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("payType", w.PayType)
|
|
}
|
|
|
|
// IDMatch
|
|
type IDMatch struct {
|
|
ID *primitive.ObjectID
|
|
}
|
|
|
|
func (s *IDMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("_id", s.ID)
|
|
}
|
|
|
|
// DistrictCodeMatch
|
|
type DistrictCodeMatch struct {
|
|
DistrictCode *string
|
|
}
|
|
|
|
func (d *DistrictCodeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("districtCode", d.DistrictCode)
|
|
}
|
|
|
|
// PromSeqeMatch
|
|
type PromSeqeMatch struct {
|
|
PromSeqe *string
|
|
}
|
|
|
|
func (s *PromSeqeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("promSeqe", s.PromSeqe)
|
|
}
|
|
|
|
// CheckedAtGTEAndLTMatch 审核时间
|
|
type CheckedAtGTEAndLTMatch struct {
|
|
GTE *time.Time
|
|
LT *time.Time
|
|
}
|
|
|
|
func (c *CheckedAtGTEAndLTMatch) New() Matcher {
|
|
return pageopt.NewGTEAndLTMatch("checkedAt", c.GTE, c.LT)
|
|
}
|
|
|
|
// ProgressAtGTEAndLTMatch 第三方下单成功时间
|
|
type ProgressAtGTEAndLTMatch struct {
|
|
GTE *time.Time
|
|
LT *time.Time
|
|
}
|
|
|
|
func (p *ProgressAtGTEAndLTMatch) New() Matcher {
|
|
return pageopt.NewGTEAndLTMatch("progressAt", p.GTE, p.LT)
|
|
}
|
|
|
|
// FailureAtGTEAndLTMatch 回调失败时间
|
|
type FailureAtGTEAndLTMatch struct {
|
|
GTE *time.Time
|
|
LT *time.Time
|
|
}
|
|
|
|
func (f *FailureAtGTEAndLTMatch) New() Matcher {
|
|
return pageopt.NewGTEAndLTMatch("failureAt", f.GTE, f.LT)
|
|
}
|
|
|
|
// SuccessAtGTEAndLTMatch 回调成功时间
|
|
type SuccessAtGTEAndLTMatch struct {
|
|
GTE *time.Time
|
|
LT *time.Time
|
|
}
|
|
|
|
func (s *SuccessAtGTEAndLTMatch) New() Matcher {
|
|
return pageopt.NewGTEAndLTMatch("successAt", s.GTE, s.LT)
|
|
}
|
|
|
|
// CreatedAtGTEAndLTMatch 提现申请时间
|
|
type CreatedAtGTEAndLTMatch struct {
|
|
GTE *time.Time
|
|
LT *time.Time
|
|
}
|
|
|
|
func (c *CreatedAtGTEAndLTMatch) New() Matcher {
|
|
return pageopt.NewGTEAndLTMatch("createdAt", c.GTE, c.LT)
|
|
}
|
|
|
|
// ReceivedAtGTEAndLTMatch 到账时间 李秋山确认 三方出款时间
|
|
type ReceivedAtGTEAndLTMatch struct {
|
|
GTE *time.Time
|
|
LT *time.Time
|
|
}
|
|
|
|
func (r *ReceivedAtGTEAndLTMatch) New() Matcher {
|
|
return pageopt.NewGTEAndLTMatch("receivedAt", r.GTE, r.LT)
|
|
}
|
|
|
|
// IsDirectMatch
|
|
type IsDirectMatch struct {
|
|
IsDirect *bool
|
|
}
|
|
|
|
func (b *IsDirectMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("isDirect", b.IsDirect)
|
|
}
|
|
|
|
// DeviceTypeMatch
|
|
type DeviceTypeMatch struct {
|
|
DeviceType *string
|
|
}
|
|
|
|
func (d *DeviceTypeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("deviceType", d.DeviceType)
|
|
}
|
|
|
|
type Sort = bson.D
|
|
|
|
var Sort_CreatedAt_n1 = Sort{{Key: "createdAt", Value: -1}}
|
|
|
|
func List(sort Sort, skip, limit *int64, matchers ...Matcher) ([]WithdrawOrder, 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 := []WithdrawOrder{}
|
|
if err := coll(nil).Find(&list, filter, opt); err != nil {
|
|
log.Error(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "List", table, "Find", err),
|
|
log.Any("sort", sort),
|
|
log.Any("skip", skip),
|
|
log.Any("limit", limit),
|
|
log.Any("matchers", matchers),
|
|
)
|
|
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(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "Count", table, "Count", err),
|
|
log.Any("matchers", matchers),
|
|
)
|
|
return 0, err
|
|
}
|
|
return count, nil
|
|
}
|