1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package main
- import (
- "log"
- qu "qfw/util"
- "strings"
- mgoutil "util/mgodb"
- )
- func HistoryTask(name string) {
- log.Println("开始历史任务...")
- //加载一个客户
- customer, _ := MgoTag.Find("euser", map[string]interface{}{"s_name": name, "i_push": 1, "b_delete": false}, nil, nil)
- if len(customer) == 1 {
- c := customer[0]
- customerId := mgoutil.BsonTOStringId(c["_id"])
- customer := qu.ObjToString(c["s_name"]) //客户名称
- appId := qu.ObjToString(c["s_appid"]) //appid
- extends := qu.ObjToString(c["s_extends"]) //扩展信息
- pushModel := qu.IntAll(c["i_pushmodel"]) //推送模式
- cus := &Customer{}
- cus.SaveDataMap = map[string]map[string]interface{}{}
- cus.SaveDataArr = []map[string]interface{}{}
- cus.ID = customerId
- cus.Name = customer
- cus.PushModel = pushModel
- cus.AppId = appId
- for _, v := range strings.Split(extends, ",") {
- if v == "hospitalgrade" {
- cus.IsSearchHosp = true
- } else if v == "enterpise" {
- cus.IsSearchEnps = true
- }
- }
- cus.GetTagRules() //获取客户打标签规则
- cus.GetDepartments("history") //获取客户信息
- //PrintLog(cus) //打印查看初始化的信息
- qu.Debug("customer:", cus.ID, cus.Name, cus.PushModel, cus.AppId, cus.IsTagRule, cus.IsSearchHosp, cus.IsSearchEnps, len(cus.TagRules), len(cus.Departments))
- cus.GetData() //获取数据
- cus.RemoveRepeatData() //数据去重
- cus.AssembelAndSaveData() //组装、保存数据
- } else {
- log.Println("初始化客户信息失败")
- }
- }
|