Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
package newactivity
import (
"errors"
"time"
"91porn-server/common/db"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
func BulkStocks(insertSqls []mongo.WriteModel) (err error) {
if len(insertSqls) > 0 {
_, err = collStock(nil).Bulk(insertSqls)
}
return
}
// 嫩模列表
func UpdateStock(t *db.MongoTool, req BuyReq, date time.Time) (giftLeft uint32, location string, err error) {
res := struct {
GiftLeft uint32 `bson:"giftLeft"` //剩余礼物数目
Location string `bson:"location"` //模特地区
}{}
conf := bson.M{
"modelId": req.ModelId,
"date": date,
"soldOut": false,
}
var update bson.M
if req.BuyOut {
update = bson.M{"$set": bson.M{"soldOut": true}}
} else {
conf["giftLeft"] = bson.M{"$gte": req.Quantity}
update = bson.M{"$inc": bson.M{"giftLeft": -req.Quantity}}
}
opts := options.FindOneAndUpdate().SetProjection(bson.M{
"_id": 0,
"giftLeft": 1,
"location": 1,
})
if err = collStock(t).FindOneAndUpdateReturnTiny(&res, conf, update, false, opts); err != nil {
if err == mongo.ErrNoDocuments {
err = errors.New("礼物卖完了😯")
}
}
giftLeft = res.GiftLeft
location = res.Location
return
}