|
@@ -0,0 +1,43 @@
|
|
|
+package activeUsers
|
|
|
+
|
|
|
+import (
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
+ "leadGeneration/public"
|
|
|
+ "log"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+const batchNum = 100 //批次插入限制
|
|
|
+
|
|
|
+// SaveBatchGroup 保存批次分组信息
|
|
|
+func SaveBatchGroup(userIds []string, groupType int, groupName, from string) {
|
|
|
+ arrLen := len(userIds)
|
|
|
+ if arrLen == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ now := time.Now().Format(date.Date_Full_Layout)
|
|
|
+ var finalCount int64 = 0
|
|
|
+ for i := 0; i < (arrLen/batchNum)+1; i++ {
|
|
|
+ start := batchNum * i
|
|
|
+ end := (batchNum + 1) * 100
|
|
|
+ if end >= arrLen {
|
|
|
+ end = arrLen
|
|
|
+ }
|
|
|
+ values := make([]interface{}, 0, batchNum)
|
|
|
+ for _, uId := range userIds[start:end] {
|
|
|
+ values = append(values, uId, groupType, groupName, from, now)
|
|
|
+ }
|
|
|
+ if count, _ := public.UserAnalyseDb.InsertBatch("user_leadGeneration_group",
|
|
|
+ []string{"user_mongoid", "group_type", "group_name", "source", "create_time"}, values); count > 0 {
|
|
|
+ finalCount += count
|
|
|
+ } else {
|
|
|
+ log.Printf("[ERROR] SaveBatchGroup index:%d value:%v error\n", i, values)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if common.Int64All(arrLen) == finalCount {
|
|
|
+ log.Printf("[INFO] SaveBatchGroup save %v %s %s total %d finished:%d\n", common.If(groupType > 0, "定制化分析报告", "超前项目"), groupName, from, arrLen, finalCount)
|
|
|
+ } else {
|
|
|
+ log.Printf("[ERROR] SaveBatchGroup save %v %s %s total %d finished:%d\n", common.If(groupType > 0, "定制化分析报告", "超前项目"), groupName, from, arrLen, finalCount)
|
|
|
+ }
|
|
|
+}
|