fix 红包领取记录
This commit is contained in:
parent
ceb83a8eb4
commit
7feca84930
|
|
@ -43,6 +43,10 @@ func NewRedPacketHistory(db *mongo.Database, c *mongo.Collection) (*RedPacketHis
|
||||||
Keys: bson.D{{"snid", 1}, {"cid", 1}, {"ts", -1}}, // 1 表示升序,-1 表示降序
|
Keys: bson.D{{"snid", 1}, {"cid", 1}, {"ts", -1}}, // 1 表示升序,-1 表示降序
|
||||||
Options: options.Index().SetBackground(true).SetSparse(true), // 后台创建索引,稀疏索引
|
Options: options.Index().SetBackground(true).SetSparse(true), // 后台创建索引,稀疏索引
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Keys: bson.D{{"snid", 1}, {"ts", -1}},
|
||||||
|
Options: options.Index().SetBackground(true).SetSparse(true),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Keys: bson.D{{"cid", 1}}, // 1 表示升序,-1 表示降序
|
Keys: bson.D{{"cid", 1}}, // 1 表示升序,-1 表示降序
|
||||||
Options: options.Index().SetBackground(true).SetSparse(true), // 后台创建索引,稀疏索引
|
Options: options.Index().SetBackground(true).SetSparse(true), // 后台创建索引,稀疏索引
|
||||||
|
|
@ -66,7 +70,10 @@ func NewRedPacketHistory(db *mongo.Database, c *mongo.Collection) (*RedPacketHis
|
||||||
|
|
||||||
func (r *RedPacketHistory) GetHistory(snid int32, cid int64) ([]*modelpkg.RedPacketHistory, error) {
|
func (r *RedPacketHistory) GetHistory(snid int32, cid int64) ([]*modelpkg.RedPacketHistory, error) {
|
||||||
res, err := r.FindMany(context.Background(), func(cols *internal.RedPacketHistoryColumns) interface{} {
|
res, err := r.FindMany(context.Background(), func(cols *internal.RedPacketHistoryColumns) interface{} {
|
||||||
return bson.M{cols.Snid: snid, cols.Cid: cid}
|
if cid > 0 {
|
||||||
|
return bson.M{cols.Snid: snid, cols.Cid: cid}
|
||||||
|
}
|
||||||
|
return bson.M{cols.Snid: snid}
|
||||||
}, func(cols *internal.RedPacketHistoryColumns) *options.FindOptions {
|
}, func(cols *internal.RedPacketHistoryColumns) *options.FindOptions {
|
||||||
return options.Find().SetSort(bson.D{{cols.Ts, -1}}).SetLimit(30)
|
return options.Find().SetSort(bson.D{{cols.Ts, -1}}).SetLimit(30)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue