Browse Source

配置文件切割、小程序用户处理

WH01243 1 năm trước cách đây
mục cha
commit
9583e3a017

+ 1 - 1
clueSync/autoTask.go

@@ -372,7 +372,7 @@ func GetPositionName(seatNumber string) string {
 
 func Thaw() {
 	//3个工作日查询
-	k := cfg.ThawDay
+	k := db.ThawDay
 	nowTime := time.Now()
 	for {
 		if k == 0 {

+ 37 - 37
clueSync/config.go

@@ -8,31 +8,33 @@ import (
 
 type (
 	Config struct {
-		CornExp1           string `json:"cornexp1"`
-		CornExp2           string `json:"cornexp2"`
-		CornExp3           string `json:"cornexp3"`
-		CornExp4           string `json:"cornexp4"`
-		CornExp5           string `json:"cornexp5"`
-		CornExp6           string `json:"cornexp6"`
-		CornExp7           string `json:"cornexp7"`
-		CornMail           string `json:"corn_mail"`
-		LastOrderId        int    `json:"lastOrderId"`
-		LastOrderClueId    string `json:"lastOrderClueId"`
-		LastUserId         string `json:"lastUserId"`
-		LastId             string `json:"lastId"`
-		LastOrderTime      string `json:"lastOrderTime"`
-		LastUserTime       string `json:"lastUserTime"`
-		LastSubscribeId    string `json:"lastSubscribeId"`
-		LastMessageTime    string `json:"lastMessageTime"`
-		LastkcTime         string `json:"lastkcTime"`
-		LastEverythingTime string `json:"lastEverythingTime"`
-		LastEventRegTime   string `json:"lastEventRegTime"`
-		LastReadClueTime   string `json:"lastReadClueTime"`
-		XlsxNum            string `json:"xlsxNum"`
-		CountLimit         int64  `json:"countLimit"`
-		RegTimes           int    `json:"regTimes"`
-		RedisServer        string `json:"redisServer"`
-		TiDb               struct {
+		LastOrderId        int     `json:"lastOrderId"`
+		LastOrderClueId    string  `json:"lastOrderClueId"`
+		LastUserId         string  `json:"lastUserId"`
+		LastId             string  `json:"lastId"`
+		LastOrderTime      string  `json:"lastOrderTime"`
+		LastUserTime       string  `json:"lastUserTime"`
+		LastSubscribeId    string  `json:"lastSubscribeId"`
+		LastMessageTime    string  `json:"lastMessageTime"`
+		LastkcTime         string  `json:"lastkcTime"`
+		LastEverythingTime string  `json:"lastEverythingTime"`
+		LastEventRegTime   string  `json:"lastEventRegTime"`
+		LastReadClueTime   string  `json:"lastReadClueTime"`
+		BigSaleTime        int64   `json:"bigSaleTime"`
+		BigOrderTime       string  `json:"bigOrderTime"`
+		MarketSaleTime     int64   `json:"marketSaleTime"`
+		AllocationTime     string  `json:"allocationTime"`
+		AllocationRatio    float64 `json:"allocationRatio"`
+	}
+	DB struct {
+		CornExp1 string `json:"cornexp1"`
+		CornExp2 string `json:"cornexp2"`
+		CornExp3 string `json:"cornexp3"`
+		CornExp4 string `json:"cornexp4"`
+		CornExp5 string `json:"cornexp5"`
+		CornExp6 string `json:"cornexp6"`
+		CornExp7 string `json:"cornexp7"`
+		TiDb     struct {
 			Host        string `json:"host"`
 			Port        int    `json:"port"`
 			Database    string `json:"database"`
@@ -138,18 +140,16 @@ type (
 			UserName string `json:"user	Name"`
 			Password string `json:"password"`
 		} `json:"es"`
-		AllocationCap   int64             `json:"allocationCap"`
-		WarningValue    int64             `json:"warningValue"`
-		NameToMail      map[string]string `json:"nameToMail"`
-		ThawDay         int64             `json:"thawDay"`
-		ProductArr      []string          `json:"productArr"`
-		LoopType        int64             `json:"loopType"`
-		BigSaleTime     int64             `json:"bigSaleTime"`
-		BigOrderTime    string            `json:"bigOrderTime"`
-		MarketSaleTime  int64             `json:"marketSaleTime"`
-		MarketSaleMail  string            `json:"marketSaleMail"`
-		AllocationTime  string            `json:"allocationTime"`
-		AllocationRatio float64           `json:"allocationRatio"`
+		ProductArr     []string          `json:"productArr"`
+		RedisServer    string            `json:"redisServer"`
+		MarketSaleMail string            `json:"marketSaleMail"`
+		AllocationCap  int64             `json:"allocationCap"`
+		WarningValue   int64             `json:"warningValue"`
+		CornMail       string            `json:"corn_mail"`
+		RegTimes       int               `json:"regTimes"`
+		NameToMail     map[string]string `json:"nameToMail"`
+		ThawDay        int64             `json:"thawDay"`
+		LoopType       int64             `json:"loopType"`
 	}
 )
 

+ 1 - 151
clueSync/config.json

@@ -1,151 +1 @@
-{
-  "cornexp1": "0 */30 * * * ?",
-  "cornexp2": "0 */5 9,10,11,12,13,14,15,16,17 * * ?",
-  "cornexp3": "0 30 8 * * ?",
-  "cornexp4": "0 0 0 */1 * ? ",
-  "cornexp5": "0 */5 * * * ?",
-  "cornexp6": "0 */10 * * * ?",
-  "cornexp7": "0 */10 * * * ?",
-  "corn_mail": "",
-  "lastOrderId": 258784,
-  "lastOrderClueId": "2024-05-11 11:12:47",
-  "lastUserId": "2024-05-20 15:40:02",
-  "lastId": "664561454b25604f30f5a6df",
-  "lastOrderTime": "2023-04-25 00:00:00",
-  "lastUserTime": "2023-04-25 00:00:00",
-  "lastSubscribeId": "645470af172d9e8dcc5c507a",
-  "lastMessageTime": "2024-05-16 13:50:07",
-  "lastkcTime": "",
-  "lastEverythingTime": "",
-  "lastEventRegTime": "",
-  "lastReadClueTime": "",
-  "xlsxNum": "1",
-  "countLimit": 1000,
-  "regTimes": 7,
-  "redisServer": "bidx=192.168.3.206:1712,newother=192.168.3.149:1712",
-  "tiDb": {
-    "host": "192.168.3.149",
-    "port": 4000,
-    "database": "jianyu_subjectdb_test",
-    "user": "datagroup",
-    "password": "Dgrpdb#2024@36",
-    "poolsize": 20,
-    "maxidle": 40,
-    "maxleft": 40
-  },
-  "tiDbData": {
-    "host": "192.168.3.149",
-    "port": 4000,
-    "database": "Call_Accounting",
-    "user": "datagroup",
-    "password": "Dgrpdb#2024@36",
-    "poolsize": 20,
-    "maxidle": 40,
-    "maxleft": 40
-  },
-  "tiDbPower": {
-    "host": "192.168.3.149",
-    "port": 4000,
-    "database": "jianyu_subjectdb_test",
-    "user": "datagroup",
-    "password": "Dgrpdb#2024@36",
-    "poolsize": 20,
-    "maxidle": 40,
-    "maxleft": 40
-  },
-  "workOrder": {
-    "host": "192.168.3.14",
-    "port": 4000,
-    "database": "work_order",
-    "user": "root",
-    "password": "=PDT49#80Z!RVv52_z",
-    "poolsize": 20,
-    "maxidle": 40,
-    "maxleft": 40
-  },
-  "baseService": {
-    "host": "192.168.3.14",
-    "port": 4000,
-    "database": "base_service",
-    "user": "root",
-    "password": "=PDT49#80Z!RVv52_z",
-    "poolsize": 20,
-    "maxidle": 40,
-    "maxleft": 40
-  },
-  "thirdParty": {
-    "host": "192.168.3.14",
-    "port": 4000,
-    "database": "thirdparty",
-    "user": "root",
-    "password": "=PDT49#80Z!RVv52_z",
-    "poolsize": 20,
-    "maxidle": 40,
-    "maxleft": 40
-  },
-  "jyactivities": {
-    "host": "",
-    "port": 0,
-    "database": "",
-    "user": "",
-    "password": "",
-    "poolsize": 0,
-    "maxidle": 0,
-    "maxleft": 0
-  },
-  "mysql": {
-    "host": "192.168.3.14",
-    "port": 4000,
-    "database": "jianyu",
-    "user": "root",
-    "password": "=PDT49#80Z!RVv52_z",
-    "poolsize": 20,
-    "maxidle": 40,
-    "maxleft": 40
-  },
-  "mgo": {
-    "address": "192.168.3.206:27080",
-    "dbName": "qfw",
-    "dbSize": 20
-  },
-  "mgoLog": {
-    "address": "192.168.3.206:27090",
-    "dbName": "qfw",
-    "dbSize": 20,
-    "user": "admin",
-    "password": "123456"
-  },
-  "mgoQyxy": {
-    "address": "192.168.3.206:27002",
-    "dbName": "mixdata",
-    "dbSize": 20,
-    "user": "jyDevGroup",
-    "password": "jy@DevGroup"
-  },
-  "es": {
-    "address": "http://192.168.3.206:9800",
-    "dbSize": 20,
-    "version": "v7",
-    "UserName": "",
-    "password": ""
-  },
-  "allocationCap": 500,
-  "warningValue": 350,
-  "nameToMail": null,
-  "thawDay": 3,
-  "productArr": [
-    "数据流量包",
-    "结构化数据",
-    "API接口",
-    "广告服务",
-    "物业专版",
-    "市场分析报告"
-  ],
-  "loopType": 1,
-  "bigSaleTime": 1718241923,
-  "bigOrderTime": "2024-06-12 17:01:39",
-  "marketSaleTime": 1708160200,
-  "marketSaleMail": "wanghao@jianyu360.com",
-  "allocationTime": "2024-07-01 14:59:37",
-  "allocationRatio": 2
-}
+{"lastOrderId":258784,"lastOrderClueId":"2024-05-25 02:23:21","lastUserId":"2024-05-20 15:40:02","lastId":"668c9fdbd1f99a10cd641691","lastOrderTime":"2023-04-25 00:00:00","lastUserTime":"2024-07-09 11:54:02","lastSubscribeId":"645470af172d9e8dcc5c507a","lastMessageTime":"2024-06-20 17:54:18","lastkcTime":"","lastEverythingTime":"","lastEventRegTime":"","lastReadClueTime":"","bigSaleTime":1718241923,"bigOrderTime":"2024-06-12 17:01:39","marketSaleTime":1708160200,"allocationTime":"2024-07-01 14:59:37","allocationRatio":2}

+ 1 - 1
clueSync/everything.go

@@ -693,7 +693,7 @@ func marketCustomer() {
 			row.AddCell().SetString(gconv.Time(gconv.Int64(v["createtime"])).Format(date.Date_Full_Layout))
 			//增加客户需求
 		}
-		email := cfg.MarketSaleMail
+		email := db.MarketSaleMail
 		dir := "./xlsx/" + fileName + ".xlsx"
 		err := xf.Save(dir)
 		if err != nil {

+ 15 - 4
clueSync/jobutil.go

@@ -608,7 +608,7 @@ func saleLeads() {
 		query["_id"] = map[string]interface{}{"$gt": mongodb.StringTOBsonId(lastId)}
 	}
 	log.Println("query :", query)
-	iter := session.DB(cfg.Mgo.DbName).C("saleLeads").Find(&query).Sort("_id").Iter()
+	iter := session.DB(db.Mgo.DbName).C("saleLeads").Find(&query).Sort("_id").Iter()
 	thisData := map[string]interface{}{}
 	for {
 		if !iter.Next(&thisData) {
@@ -658,13 +658,24 @@ func userbase() {
 	log.Println("userbase定时任务开始")
 	selectTimeEnd := time.Unix(time.Now().Unix()-1800, 0).Format("2006-01-02 15:04:05")
 	sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where updatetime > "%s" and source != "0105" and source != "0104" and source != "0103" and source != "0102"`, selectTimeEnd)
-	//sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where id='11927183'`)
 	data := TiDb.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		for _, v := range *data {
 			phone := common.ObjToString(v["phone"])
 			uId := common.ObjToString(v["uid"])
 			userId := common.ObjToString(v["userid"])
+			if userId != "" {
+				//判断用户是否有小程序切使用过剑鱼其他产品
+				uData, ok := Mgo.FindOne("user", map[string]interface{}{"_id": mongodb.StringTOBsonId(user_id)})
+				if ok && uData != nil {
+					s_platform := gconv.String((*uData)["s_platform"])
+					login_positionid := gconv.Int64((*uData)["login_positionid"])
+					if s_platform == "xcx" && login_positionid == 0 {
+						log.Println(phone, uId, userId, "用户是否有小程序且未使用过剑鱼其他产品")
+						continue
+					}
+				}
+			}
 			registedate := common.ObjToString(v["l_registedate"])
 			name := common.ObjToString(v["name"])
 			nowTime := time.Now().Format(date.Date_Full_Layout)
@@ -689,7 +700,7 @@ func userbase() {
 						count := TiDb.CountBySql("select count(1) as count from dwd_f_crm_clue_info where uid = ?", uId)
 						log.Println("userbase uid 线索数量 ", count)
 						log.Println("userbase uid 注册时间 ", registedates)
-						if time.Now().Unix()-registedates.Unix() > int64(cfg.RegTimes)*86400 {
+						if time.Now().Unix()-registedates.Unix() > int64(db.RegTimes)*86400 {
 							if count == 0 {
 								// TiDb.Insert("dwd_f_crm_open_sea", map[string]interface{}{
 								// 	"clue_id":      clueId,
@@ -1091,7 +1102,7 @@ func FindUpperLimit(positionId string, level string, isAdd bool) bool {
 		return false
 	}
 	isFull := false
-	isFull = TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1   and trailstatus != '08'  `, positionId) >= cfg.AllocationCap
+	isFull = TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1   and trailstatus != '08'  `, positionId) >= db.AllocationCap
 	if isFull && isAdd && level != "" {
 		TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where position_id = ? and clue_level = ?`, positionId, level)
 	}

+ 66 - 63
clueSync/main.go

@@ -16,6 +16,7 @@ import (
 
 var (
 	cfg          = new(Config)
+	db           = new(DB)
 	Mysql        *mysql.Mysql
 	TiDb         *mysql.Mysql
 	TiDbData     *mysql.Mysql
@@ -35,89 +36,91 @@ func main() {
 	flag.Parse()
 	common.ReadConfig(&cfg)
 	log.Println("cfg ", cfg)
+	common.ReadConfig("./db.json", &db)
+	log.Println("db ", db)
 	TiDb = &mysql.Mysql{
-		Address:      cfg.TiDb.Host + ":" + fmt.Sprint(cfg.TiDb.Port),
-		UserName:     cfg.TiDb.User,
-		PassWord:     cfg.TiDb.Password,
-		DBName:       cfg.TiDb.Database,
-		MaxOpenConns: cfg.TiDb.PollSize,
-		MaxIdleConns: cfg.TiDb.MaxIdle,
+		Address:      db.TiDb.Host + ":" + fmt.Sprint(db.TiDb.Port),
+		UserName:     db.TiDb.User,
+		PassWord:     db.TiDb.Password,
+		DBName:       db.TiDb.Database,
+		MaxOpenConns: db.TiDb.PollSize,
+		MaxIdleConns: db.TiDb.MaxIdle,
 	}
 	TiDb.Init()
 	TiDbData = &mysql.Mysql{
-		Address:      cfg.TiDbData.Host + ":" + fmt.Sprint(cfg.TiDbData.Port),
-		UserName:     cfg.TiDbData.User,
-		PassWord:     cfg.TiDbData.Password,
-		DBName:       cfg.TiDbData.Database,
-		MaxOpenConns: cfg.TiDbData.PollSize,
-		MaxIdleConns: cfg.TiDbData.MaxIdle,
+		Address:      db.TiDbData.Host + ":" + fmt.Sprint(db.TiDbData.Port),
+		UserName:     db.TiDbData.User,
+		PassWord:     db.TiDbData.Password,
+		DBName:       db.TiDbData.Database,
+		MaxOpenConns: db.TiDbData.PollSize,
+		MaxIdleConns: db.TiDbData.MaxIdle,
 	}
 	TiDbData.Init()
 	TiDbPower = &mysql.Mysql{
-		Address:      cfg.TiDbPower.Host + ":" + fmt.Sprint(cfg.TiDbPower.Port),
-		UserName:     cfg.TiDbPower.User,
-		PassWord:     cfg.TiDbPower.Password,
-		DBName:       cfg.TiDbPower.Database,
-		MaxOpenConns: cfg.TiDbPower.PollSize,
-		MaxIdleConns: cfg.TiDbPower.MaxIdle,
+		Address:      db.TiDbPower.Host + ":" + fmt.Sprint(db.TiDbPower.Port),
+		UserName:     db.TiDbPower.User,
+		PassWord:     db.TiDbPower.Password,
+		DBName:       db.TiDbPower.Database,
+		MaxOpenConns: db.TiDbPower.PollSize,
+		MaxIdleConns: db.TiDbPower.MaxIdle,
 	}
 	TiDbPower.Init()
 	ThirdParty = &mysql.Mysql{
-		Address:      cfg.ThirdParty.Host + ":" + fmt.Sprint(cfg.ThirdParty.Port),
-		UserName:     cfg.ThirdParty.User,
-		PassWord:     cfg.ThirdParty.Password,
-		DBName:       cfg.ThirdParty.Database,
-		MaxOpenConns: cfg.ThirdParty.PollSize,
-		MaxIdleConns: cfg.ThirdParty.MaxIdle,
+		Address:      db.ThirdParty.Host + ":" + fmt.Sprint(db.ThirdParty.Port),
+		UserName:     db.ThirdParty.User,
+		PassWord:     db.ThirdParty.Password,
+		DBName:       db.ThirdParty.Database,
+		MaxOpenConns: db.ThirdParty.PollSize,
+		MaxIdleConns: db.ThirdParty.MaxIdle,
 	}
 	ThirdParty.Init()
 	Jyactivities = &mysql.Mysql{
-		Address:      cfg.Jyactivities.Host + ":" + fmt.Sprint(cfg.Jyactivities.Port),
-		UserName:     cfg.Jyactivities.User,
-		PassWord:     cfg.Jyactivities.Password,
-		DBName:       cfg.Jyactivities.Database,
-		MaxOpenConns: cfg.Jyactivities.PollSize,
-		MaxIdleConns: cfg.Jyactivities.MaxIdle,
+		Address:      db.Jyactivities.Host + ":" + fmt.Sprint(db.Jyactivities.Port),
+		UserName:     db.Jyactivities.User,
+		PassWord:     db.Jyactivities.Password,
+		DBName:       db.Jyactivities.Database,
+		MaxOpenConns: db.Jyactivities.PollSize,
+		MaxIdleConns: db.Jyactivities.MaxIdle,
 	}
 	Jyactivities.Init()
 	WorkOrder = &mysql.Mysql{
-		Address:      cfg.WorderOrder.Host + ":" + fmt.Sprint(cfg.WorderOrder.Port),
-		UserName:     cfg.WorderOrder.User,
-		PassWord:     cfg.WorderOrder.Password,
-		DBName:       cfg.WorderOrder.Database,
-		MaxOpenConns: cfg.WorderOrder.PollSize,
-		MaxIdleConns: cfg.WorderOrder.MaxIdle,
+		Address:      db.WorderOrder.Host + ":" + fmt.Sprint(db.WorderOrder.Port),
+		UserName:     db.WorderOrder.User,
+		PassWord:     db.WorderOrder.Password,
+		DBName:       db.WorderOrder.Database,
+		MaxOpenConns: db.WorderOrder.PollSize,
+		MaxIdleConns: db.WorderOrder.MaxIdle,
 	}
 	WorkOrder.Init()
 	Mysql = &mysql.Mysql{
-		Address:      cfg.Mysql.Host + ":" + fmt.Sprint(cfg.Mysql.Port),
-		UserName:     cfg.Mysql.User,
-		PassWord:     cfg.Mysql.Password,
-		DBName:       cfg.Mysql.Database,
-		MaxOpenConns: cfg.Mysql.PollSize,
-		MaxIdleConns: cfg.Mysql.MaxIdle,
+		Address:      db.Mysql.Host + ":" + fmt.Sprint(db.Mysql.Port),
+		UserName:     db.Mysql.User,
+		PassWord:     db.Mysql.Password,
+		DBName:       db.Mysql.Database,
+		MaxOpenConns: db.Mysql.PollSize,
+		MaxIdleConns: db.Mysql.MaxIdle,
 	}
 	Mysql.Init()
 	Base = &mysql.Mysql{
-		Address:      cfg.BaseService.Host + ":" + fmt.Sprint(cfg.BaseService.Port),
-		UserName:     cfg.BaseService.User,
-		PassWord:     cfg.BaseService.Password,
-		DBName:       cfg.BaseService.Database,
-		MaxOpenConns: cfg.BaseService.PollSize,
-		MaxIdleConns: cfg.BaseService.MaxIdle,
+		Address:      db.BaseService.Host + ":" + fmt.Sprint(db.BaseService.Port),
+		UserName:     db.BaseService.User,
+		PassWord:     db.BaseService.Password,
+		DBName:       db.BaseService.Database,
+		MaxOpenConns: db.BaseService.PollSize,
+		MaxIdleConns: db.BaseService.MaxIdle,
 	}
 	Base.Init()
-	Es = elastic.NewEs(cfg.Es.Version, cfg.Es.Address, cfg.Es.DbSize, cfg.Es.UserName, cfg.Es.Password)
-	redis.InitRedis(cfg.RedisServer)
-	Mgo = mongodb.NewMgo(cfg.Mgo.Address, cfg.Mgo.DbName, cfg.Mgo.DbSize)
-	MgoLog = mongodb.NewMgoWithUser(cfg.MgoLog.Address, cfg.MgoLog.DbName, cfg.MgoLog.User, cfg.MgoLog.Password, cfg.MgoLog.DbSize)
-	MgoQyxy = mongodb.NewMgoWithUser(cfg.MgoQyxy.Address, cfg.MgoQyxy.DbName, cfg.MgoQyxy.User, cfg.MgoQyxy.Password, cfg.MgoQyxy.DbSize)
+	Es = elastic.NewEs(db.Es.Version, db.Es.Address, db.Es.DbSize, db.Es.UserName, db.Es.Password)
+	redis.InitRedis(db.RedisServer)
+	Mgo = mongodb.NewMgo(db.Mgo.Address, db.Mgo.DbName, db.Mgo.DbSize)
+	MgoLog = mongodb.NewMgoWithUser(db.MgoLog.Address, db.MgoLog.DbName, db.MgoLog.User, db.MgoLog.Password, db.MgoLog.DbSize)
+	MgoQyxy = mongodb.NewMgoWithUser(db.MgoQyxy.Address, db.MgoQyxy.DbName, db.MgoQyxy.User, db.MgoQyxy.Password, db.MgoQyxy.DbSize)
 	InitArea()
-	InitProduct(cfg.ProductArr)
+	InitProduct(db.ProductArr)
 	if *mode == 1 {
 		//30分钟一次
 		a := cron.New()
-		a.AddFunc(cfg.CornExp1, func() {
+		a.AddFunc(db.CornExp1, func() {
 			orders()      //未支付订单
 			messageSync() //聊天记录进线索
 			userbase()    //新绑定手机号进线索
@@ -125,7 +128,7 @@ func main() {
 		a.Start()
 		//5分钟一次
 		b := cron.New()
-		b.AddFunc(cfg.CornExp2, func() {
+		b.AddFunc(db.CornExp2, func() {
 			users()          //新注册用户进线索
 			saleLeads()      //留资进线索
 			eventReg()       //渠道
@@ -135,7 +138,7 @@ func main() {
 		b.Start()
 		//每天8点30
 		c := cron.New()
-		c.AddFunc(cfg.CornExp3, func() {
+		c.AddFunc(db.CornExp3, func() {
 			users()     //新注册用户进线索
 			saleLeads() //留资进线索
 		})
@@ -143,14 +146,14 @@ func main() {
 		// 一天一次
 		// tagAllSync()
 		d := cron.New()
-		d.AddFunc(cfg.CornExp4, func() {
+		d.AddFunc(db.CornExp4, func() {
 			tagAllSync() //用户标签
 		})
 		d.Start()
 		// 5分钟一次
 		go ordersClue() //后台订单进线索
 		e := cron.New()
-		e.AddFunc(cfg.CornExp5, func() {
+		e.AddFunc(db.CornExp5, func() {
 			go everythingSync() //渠道
 			go ordersClue()     //后台订单进线索
 			go kcSync()         //移交客成
@@ -162,14 +165,14 @@ func main() {
 		e.Start()
 		//5分钟一次
 		f := cron.New()
-		f.AddFunc(cfg.CornExp6, func() {
+		f.AddFunc(db.CornExp6, func() {
 			subscribeAddSync() //订阅增量
 			rderAcceptance()   //工单生成
 		})
 		f.Start()
 		//自动进入任务车 1天一次
 		g := cron.New()
-		g.AddFunc(cfg.CornExp7, func() {
+		g.AddFunc(db.CornExp7, func() {
 			readClue()   //读取中间表进线索
 			refundAuto() //客成移交销售
 			autoTask()   //超时未跟进加入任务车
@@ -184,13 +187,13 @@ func main() {
 		WarningDm() // 部门
 		log.Println("个人/部门邮件告警查询结束")
 		h := cron.New()
-		h.AddFunc(cfg.CornMail, func() {
+		h.AddFunc(db.CornMail, func() {
 			log.Println("个人邮件告警查询开始")
 			WarningPerl() // 个人
 			log.Println("部门邮件告警查询开始")
 			WarningDm() // 部门
 			log.Println("个人/部门邮件告警查询结束")
-			UpperLimitAutoExitSea(cfg.AllocationCap)
+			UpperLimitAutoExitSea(db.AllocationCap)
 		})
 		h.Start()
 		select {}

+ 18 - 18
clueSync/sendMail.go

@@ -41,15 +41,15 @@ func WarningPerl() {
 			sendFlag2 := common.IntAll(m["flag_2"]) //上限邮件发送
 			posid := common.Int64All(m["position_id"])
 			count := TiDb.CountBySql(sql, posid)
-			if count >= cfg.AllocationCap && sendFlag2 == 0 {
+			if count >= db.AllocationCap && sendFlag2 == 0 {
 				ExceedLimitByPp(posid) // 发上限邮件
 				_, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail | (1 << 1)"), posid)
-			} else if count >= cfg.WarningValue && sendFlag1 == 0 && sendFlag2 == 0 {
+			} else if count >= db.WarningValue && sendFlag1 == 0 && sendFlag2 == 0 {
 				WillWarningByPp(posid) // 发预警邮件
 				_, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail | (1 << 0)"), posid)
-			} else if sendFlag1 == 1 && count < cfg.WarningValue { // 已发邮件
+			} else if sendFlag1 == 1 && count < db.WarningValue { // 已发邮件
 				_, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail & ~(1 << 0)"), posid)
-			} else if sendFlag2 == 1 && count < cfg.AllocationCap { // 已发邮件
+			} else if sendFlag2 == 1 && count < db.AllocationCap { // 已发邮件
 				_, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail & ~(1 << 1)"), posid)
 			}
 		}
@@ -66,12 +66,12 @@ func WarningDm() {
 	for _, m := range *dm {
 		d1 := common.ObjToString(m["dept_name"])
 		send1, send2 := true, true // 预警,上限 发送标记
-		info := TiDb.SelectBySql(dmInfoCount, d1, cfg.WarningValue)
+		info := TiDb.SelectBySql(dmInfoCount, d1, db.WarningValue)
 		if info != nil && len(*info) > 0 {
 			send = false
 			send1 = false
 		}
-		info1 := TiDb.SelectBySql(dmInfoCount, d1, cfg.AllocationCap)
+		info1 := TiDb.SelectBySql(dmInfoCount, d1, db.AllocationCap)
 		if info1 != nil && len(*info1) > 0 {
 			send2 = false
 		}
@@ -164,7 +164,7 @@ func WillWarningByPp(posid int64) {
 		return
 	}
 	toCc = getCc(posid)
-	content = fmt.Sprintf(content, cfg.WarningValue, cfg.AllocationCap)
+	content = fmt.Sprintf(content, db.WarningValue, db.AllocationCap)
 	sendInfo(toMail, toCc, title, content)
 }
 
@@ -207,7 +207,7 @@ func WillWarningByDm(dname, to string, toCc []string) {
 	title := "“%s”私海线索即将达到上限通知"
 	content := "“%s”的所有参与线索分配的电销人员,私海线索都已达到%d条(不包含成交客户),即将达到私海线索上限%d条(不包含成交客户),请及时通知电销人员将无需跟进的线索退回公海,以避免无法接收新线索。"
 	title = fmt.Sprintf(title, dname)
-	content = fmt.Sprintf(content, dname, cfg.WarningValue, cfg.AllocationCap)
+	content = fmt.Sprintf(content, dname, db.WarningValue, db.AllocationCap)
 	sendInfo(to, strings.Join(toCc, ","), title, content)
 }
 
@@ -223,7 +223,7 @@ func WillWarningByAll() {
 			to = append(to, m3)
 		}
 	}
-	content = fmt.Sprintf(content, cfg.WarningValue)
+	content = fmt.Sprintf(content, db.WarningValue)
 	sendInfo(strings.Join(to, ","), "", title, content)
 }
 
@@ -236,7 +236,7 @@ func ExceedLimitByPp(posid int64) {
 
 	toMail := ""
 	toCc := ""
-	content = fmt.Sprintf(content, cfg.AllocationCap)
+	content = fmt.Sprintf(content, db.AllocationCap)
 	info := TiDb.SelectBySql(selfMail, posid)
 	if info != nil && len(*info) > 0 {
 		toMail = getMailAds(common.ObjToString((*info)[0]["mail"]), common.ObjToString((*info)[0]["name"]))
@@ -256,7 +256,7 @@ func ExceedLimitByDm(dname, to string, toCc []string) {
 	title := "“%s”私海线索已达到上限通知"
 	content := "“%s”的所有参与线索分配的电销人员,私海线索都已达到私海线索上限%d条(不包含成交客户),当前无法接收新线索,请及时通知电销人员将无需跟进的线索退回公海"
 	title = fmt.Sprintf(title, dname)
-	content = fmt.Sprintf(content, dname, cfg.AllocationCap)
+	content = fmt.Sprintf(content, dname, db.AllocationCap)
 	sendInfo(to, strings.Join(toCc, ","), title, content)
 }
 
@@ -285,7 +285,7 @@ func AutoReleaseNots() {
 		}
 	}
 	toCc = append(toCc, getMailAds("shenbingyi@topnet.net.cn", "沈炳毅"))
-	sendInfo(strings.Join(to, ","), strings.Join(toCc, ","), title, fmt.Sprintf(content, cfg.AllocationCap))
+	sendInfo(strings.Join(to, ","), strings.Join(toCc, ","), title, fmt.Sprintf(content, db.AllocationCap))
 }
 
 // @Author jianghan
@@ -313,7 +313,7 @@ func CantBeAssignedNots() {
 		}
 	}
 	toCc = append(toCc, getMailAds("shenbingyi@topnet.net.cn", "沈炳毅"))
-	sendInfo(strings.Join(to, ","), strings.Join(toCc, ","), title, fmt.Sprintf(content, cfg.AllocationCap))
+	sendInfo(strings.Join(to, ","), strings.Join(toCc, ","), title, fmt.Sprintf(content, db.AllocationCap))
 }
 
 // @Author jianghan
@@ -326,7 +326,7 @@ func HandOverFail(posid int64, ent string) {
 	toMail := ""
 	toCc := ""
 	info := TiDb.SelectBySql(selfMail, posid)
-	content = fmt.Sprintf(content, cfg.AllocationCap, cfg.AllocationCap, ent, cfg.ThawDay)
+	content = fmt.Sprintf(content, db.AllocationCap, db.AllocationCap, ent, db.ThawDay)
 	if info != nil && len(*info) > 0 {
 		toMail = getMailAds(common.ObjToString((*info)[0]["mail"]), common.ObjToString((*info)[0]["name"]))
 	}
@@ -347,7 +347,7 @@ func OrderCreateFail(posid int64, bname string) {
 
 	toMail := ""
 	toCc := ""
-	content = fmt.Sprintf(content, cfg.AllocationCap, cfg.AllocationCap, bname, cfg.ThawDay)
+	content = fmt.Sprintf(content, db.AllocationCap, db.AllocationCap, bname, db.ThawDay)
 	info := TiDb.SelectBySql(selfMail, posid)
 	if info != nil && len(*info) > 0 {
 		toMail = getMailAds(common.ObjToString((*info)[0]["mail"]), common.ObjToString((*info)[0]["name"]))
@@ -369,7 +369,7 @@ func AssFail(posid int64, ent, iname string) {
 
 	toMail := ""
 	toCc := ""
-	content = fmt.Sprintf(content, cfg.AllocationCap, ent, iname)
+	content = fmt.Sprintf(content, db.AllocationCap, ent, iname)
 	info := TiDb.SelectBySql(selfMail, posid)
 	if info != nil && len(*info) > 0 {
 		toMail = getMailAds(common.ObjToString((*info)[0]["mail"]), common.ObjToString((*info)[0]["name"]))
@@ -445,8 +445,8 @@ func getCc(posid int64) (to string) {
 // @Date 2024/5/13
 func getMailAds(mail, name string) string {
 	log.Println("getMailAds", name, mail)
-	if cfg.NameToMail != nil && len(cfg.NameToMail) > 0 {
-		return cfg.NameToMail[name]
+	if db.NameToMail != nil && len(db.NameToMail) > 0 {
+		return db.NameToMail[name]
 	} else {
 		return mail
 	}

+ 1 - 1
clueSync/subscribe.go

@@ -24,7 +24,7 @@ func subscribeAddSync() {
 	// query["_id"] = mongodb.StringTOBsonId("64473e36c572141d78ec7a03")
 	log.Println("query :", query)
 
-	iter := session.DB(cfg.MgoLog.DbName).C("ovipjy_log").Find(&query).Sort("_id").Iter()
+	iter := session.DB(db.MgoLog.DbName).C("ovipjy_log").Find(&query).Sort("_id").Iter()
 	thisData := map[string]interface{}{}
 
 	for {

+ 1 - 1
clueSync/subscribeAll.go

@@ -17,7 +17,7 @@ func subscribeAllSync() {
 		Mgo.DestoryMongoConn(session)
 	}()
 	query := map[string]interface{}{}
-	iter := session.DB(cfg.Mgo.DbName).C("user").Find(&query).Sort("_id").Iter()
+	iter := session.DB(db.Mgo.DbName).C("user").Find(&query).Sort("_id").Iter()
 	thisData := map[string]interface{}{}
 
 	for {