@@ -0,0 +1,55 @@
|
||||
package prdcthsomod
|
||||
|
||||
import (
|
||||
"91porn-server/models/commod"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
// PaymentLogBody 商品交易订单请求参数
|
||||
type PaymentLogBody struct {
|
||||
ProductID primitive.ObjectID `bson:"productID" json:"productID" binding:"required" ` //产品id
|
||||
Name string `bson:"name" json:"name" binding:"required" ` //商品名字
|
||||
Amount int64 `bson:"amount" json:"amount" binding:"required"` //成交价格
|
||||
ProductType int `bson:"productType" json:"productType"` //产品类型
|
||||
}
|
||||
|
||||
// ProductHistoryQueryReq 通用查询参数
|
||||
type ProductHistoryQueryReq struct {
|
||||
UID *uint64 `form:"uid" json:"uid,omitempty" bson:"uid"` // 用户id
|
||||
ProductType *commod.ProductType `form:"productType" json:"productType" ` // 产品类型 // 0-会员卡 21-预售卡
|
||||
AdvanceOrderStatus *int `form:"advanceOrderStatus" json:"advanceOrderStatus"` // 预售订单状态 // 2-预付成功 4-尾款支付成功
|
||||
Start *time.Time `form:"start" json:"start"` // 开始时间
|
||||
End *time.Time `form:"end" json:"end"` // 结束时间
|
||||
commod.Page
|
||||
}
|
||||
|
||||
type ProductHistoryQueryResp struct {
|
||||
Total int64 `json:"total"`
|
||||
List []*ProductHistory `json:"list"`
|
||||
}
|
||||
|
||||
func (req *ProductHistoryQueryReq) GetCond() bson.M {
|
||||
cond := bson.M{}
|
||||
if req.UID != nil {
|
||||
cond["uid"] = *req.UID
|
||||
}
|
||||
if req.ProductType != nil {
|
||||
cond["productType"] = *req.ProductType
|
||||
}
|
||||
if req.AdvanceOrderStatus != nil {
|
||||
cond["advanceOrderStatus"] = *req.AdvanceOrderStatus
|
||||
}
|
||||
if req.Start != nil && req.End != nil {
|
||||
cond["createdAt"] = bson.M{"$gte": req.Start, "$lt": req.End}
|
||||
}
|
||||
return cond
|
||||
}
|
||||
|
||||
func (req *ProductHistoryQueryReq) GetOpt() *options.FindOptions {
|
||||
opt := options.Find().SetSkip(req.Skip64()).SetLimit(req.Limit64()).SetSort(bson.D{{Key: "createdAt", Value: -1}})
|
||||
return opt
|
||||
}
|
||||
Reference in New Issue
Block a user