@@ -0,0 +1,93 @@
|
||||
package commod
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/pageopt"
|
||||
)
|
||||
|
||||
type DiscSeqe struct {
|
||||
DistrictCode string `json:"districtCode" bson:"districtCode"` //商区码
|
||||
PromSeqe string `json:"promSeqe" bson:"promSeqe"` //推广序列
|
||||
}
|
||||
|
||||
func (d *DiscSeqe) String() string {
|
||||
if d.PromSeqe == "" {
|
||||
return d.DistrictCode
|
||||
}
|
||||
return strings.ToUpper(strings.Join([]string{d.DistrictCode, d.PromSeqe}, "-"))
|
||||
}
|
||||
|
||||
func (p *DiscSeqe) From(s string) *DiscSeqe {
|
||||
p.Clean()
|
||||
list := strings.Split(s, "-")
|
||||
if len(list) > 0 {
|
||||
p.DistrictCode = list[0]
|
||||
}
|
||||
if len(list) > 1 {
|
||||
p.PromSeqe = list[1]
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *DiscSeqe) Clean() {
|
||||
p.DistrictCode = ""
|
||||
p.PromSeqe = ""
|
||||
}
|
||||
|
||||
type DiscDoc struct {
|
||||
//商区码和推广序列
|
||||
DiscSeqe `bson:",inline"`
|
||||
//true:是直推用户
|
||||
IsDirect bool `json:"isDirect" bson:"isDirect"`
|
||||
//商区绑定时间
|
||||
DiscBindAt time.Time `bson:"discBindAt"`
|
||||
}
|
||||
|
||||
func NewDiscDoc(discSeqe DiscSeqe, isDirect bool, discBindAt time.Time) DiscDoc {
|
||||
return DiscDoc{
|
||||
discSeqe,
|
||||
isDirect, //直推:推广链接没有推广码, 否则是分裂,
|
||||
discBindAt,
|
||||
}
|
||||
}
|
||||
|
||||
type Matcher = pageopt.Matcher
|
||||
|
||||
// IsDirectMatch
|
||||
type IsDirectMatch struct {
|
||||
IsDirect *bool
|
||||
}
|
||||
|
||||
func (b *IsDirectMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("isDirect", b.IsDirect)
|
||||
}
|
||||
|
||||
// DistrictCodeMatch
|
||||
type DistrictCodeMatch struct {
|
||||
DistrictCode *string
|
||||
}
|
||||
|
||||
func (s *DistrictCodeMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("districtCode", s.DistrictCode)
|
||||
}
|
||||
|
||||
// DistrictCodeInMatch
|
||||
type DistrictCodeInMatch struct {
|
||||
Codes []string
|
||||
}
|
||||
|
||||
func (s *DistrictCodeInMatch) New() Matcher {
|
||||
return pageopt.NewInMatch("districtCode", s.Codes)
|
||||
}
|
||||
|
||||
// DiscBindAtGTEAndLTMatch
|
||||
type DiscBindAtGTEAndLTMatch struct {
|
||||
GTE *time.Time
|
||||
LT *time.Time
|
||||
}
|
||||
|
||||
func (c *DiscBindAtGTEAndLTMatch) New() Matcher {
|
||||
return pageopt.NewGTEAndLTMatch("discBindAt", c.GTE, c.LT)
|
||||
}
|
||||
Reference in New Issue
Block a user