xuemingyang 3 éve
szülő
commit
29a3aaef1d
1 módosított fájl, 15 hozzáadás és 1 törlés
  1. 15 1
      test/shareToaward_test.go

+ 15 - 1
test/shareToaward_test.go

@@ -3,9 +3,14 @@ package test
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/mongodb"
+	"fmt"
+	"strings"
 	"testing"
+	"time"
 )
 
+const SkTimes = "-" //-默认全部 1653877526-1653877526开始时间-结束时间 开始时间不传默认0结束时间不传默认当前时间 -必加
+
 func Test_Award(t *testing.T) {
 	Mgo := &mongodb.MongodbSim{
 		MongodbAddr: "192.168.3.206:27080",
@@ -28,11 +33,19 @@ func Test_Award(t *testing.T) {
 	}
 	q := map[string]interface{}{}
 	ndatas := []map[string]interface{}{}
+	skTimes := strings.Split(SkTimes, "-")
+	stime := skTimes[0]
+	etime := skTimes[1]
+	fmt.Println(common.Int64All(stime), common.If(common.Int64All(etime) == 0, time.Now().Unix(), common.Int64All(etime)))
 	for _, u := range users {
 		q["$or"] = []map[string]interface{}{
 			{"share_uid": u},
 			{"shared_uid": u},
 		}
+		q["createtime"] = map[string]interface{}{
+			"$gte": common.Int64All(stime),
+			"$lt":  common.If(common.Int64All(etime) == 0, time.Now().Unix(), common.Int64All(etime)),
+		}
 		data, _ := Mgo.Find("user_share", q, `{"createtime":1}`, `{"_id":1,"createtime":1,"shared_uid":1}`, false, 0, 4)
 		if len(*data) > 0 {
 			for _, vv := range *data {
@@ -52,5 +65,6 @@ func Test_Award(t *testing.T) {
 			}
 		}
 	}
-	Mgo.SaveBulk("activity_award", ndatas...)
+	fmt.Println("------------", len(ndatas))
+	//Mgo.SaveBulk("activity_award", ndatas...)
 }