|
@@ -1,79 +1,426 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
+ "database/sql"
|
|
|
+ "fmt"
|
|
|
"log"
|
|
|
-)
|
|
|
+ "time"
|
|
|
|
|
|
-func runJob(mode int) {
|
|
|
- log.Println("定时任务开始")
|
|
|
- orders()
|
|
|
- users()
|
|
|
- saleleads()
|
|
|
- log.Println("定时任务结束")
|
|
|
-}
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
+)
|
|
|
|
|
|
-// 未支付订单
|
|
|
+// 未支付订单 30分钟一次
|
|
|
func orders() {
|
|
|
- //一个小时未支付进入线索
|
|
|
- lastOrderId := 100000
|
|
|
- Mysql.SelectByBath(500, func(l *[]map[string]interface{}) {
|
|
|
- for _, v := range *l {
|
|
|
- groupid := fmt.Sprint(v["groupid"])
|
|
|
- customerid := fmt.Sprint(v["customerid"])
|
|
|
- log.Println(groupid + "_" + customerid)
|
|
|
- dataMap1[groupid+"_"+customerid] = true
|
|
|
- log.Println(len(dataMap1))
|
|
|
- }
|
|
|
- }, `select * from dataexport_order where order_status = 0 and id >= `+lastOrderId)
|
|
|
+ //一个小时未支付进入线索 A
|
|
|
+ log.Println("未支付订单定时任务开始")
|
|
|
+ lastOrderId := cfg.LastOrderId
|
|
|
+ selectTimeStart := time.Unix(time.Now().Unix()-7200, 0).Format("2006-01-02 15:04:05")
|
|
|
+ selectTimeEnd := time.Unix(time.Now().Unix()-3600, 0).Format("2006-01-02 15:04:05")
|
|
|
+ sql := fmt.Sprintf(`select * from dataexport_order where order_status = 0 and product_type in ("大会员","VIP订阅","数据流量包","历史数据") and create_time <= "%s" and create_time >= "%s" and id > %s`, selectTimeEnd, selectTimeStart, fmt.Sprint(lastOrderId))
|
|
|
+ data := Mysql.SelectBySql(sql)
|
|
|
+ if data != nil && *data != nil && len(*data) > 0 {
|
|
|
+ for k, v := range *data {
|
|
|
+ FormatData(v, "orders")
|
|
|
+ if k == len(*data)-1 {
|
|
|
+ lastOrderId = common.IntAll(v["id"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cfg.LastOrderId = lastOrderId
|
|
|
+ log.Println("未支付订单定时任务结束")
|
|
|
}
|
|
|
|
|
|
-// 新注册用户
|
|
|
+// 新注册用户 5分钟一次
|
|
|
func users() {
|
|
|
- //新用户注册后5分钟内进入线索
|
|
|
+ //新用户注册后5分钟内进入线索 C
|
|
|
+ log.Println("新注册用户定时任务开始")
|
|
|
session := Mgo.GetMgoConn()
|
|
|
- lastUserId := ""
|
|
|
- count := 0
|
|
|
+ lastUserId := cfg.LastUserId
|
|
|
defer func() {
|
|
|
Mgo.DestoryMongoConn(session)
|
|
|
}()
|
|
|
query := map[string]interface{}{}
|
|
|
- if LastFlag.LastId != "" {
|
|
|
- query["_id"] = bson.M{"$gt": bson.ObjectIdHex(LastFlag.LastId)}
|
|
|
+ if lastUserId != "" {
|
|
|
+ query["_id"] = map[string]interface{}{"$gt": mongodb.StringTOBsonId(lastUserId)}
|
|
|
}
|
|
|
+ query["_id"] = map[string]interface{}{"$gt": mongodb.StringTOBsonId("63877e000000000000000000"), "$lte": mongodb.StringTOBsonId("63af0b000000000000000000")}
|
|
|
log.Println("query :", query)
|
|
|
-
|
|
|
iter := session.DB(cfg.Mgo.DbName).C("user").Find(&query).Sort("_id").Iter()
|
|
|
thisData := map[string]interface{}{}
|
|
|
|
|
|
for {
|
|
|
if !iter.Next(&thisData) {
|
|
|
+ lastUserId = mongodb.BsonIdToSId(thisData["_id"])
|
|
|
break
|
|
|
}
|
|
|
+ FormatData(thisData, "users")
|
|
|
}
|
|
|
+ cfg.LastUserId = lastUserId
|
|
|
+ log.Println("新注册用户定时任务结束")
|
|
|
}
|
|
|
|
|
|
-// 留资
|
|
|
-func saleleads() {
|
|
|
+// 留资 5分钟一次
|
|
|
+func saleLeads() {
|
|
|
//留资后5分钟内进入线索
|
|
|
- //分为免费留资和付费留资
|
|
|
+ //分为免费留资和付费留资 付费B 免费C
|
|
|
+ log.Println("用户留资定时任务开始")
|
|
|
session := Mgo.GetMgoConn()
|
|
|
- lastId := ""
|
|
|
- count := 0
|
|
|
+ lastId := cfg.LastId
|
|
|
defer func() {
|
|
|
Mgo.DestoryMongoConn(session)
|
|
|
}()
|
|
|
query := map[string]interface{}{}
|
|
|
- if LastFlag.LastId != "" {
|
|
|
- query["_id"] = bson.M{"$gt": bson.ObjectIdHex(LastFlag.LastId)}
|
|
|
+ if lastId != "" {
|
|
|
+ query["_id"] = map[string]interface{}{"$gt": mongodb.StringTOBsonId(lastId)}
|
|
|
}
|
|
|
+ query["_id"] = map[string]interface{}{"$gt": mongodb.StringTOBsonId("63877e000000000000000000"), "$lte": mongodb.StringTOBsonId("63af0b000000000000000000")}
|
|
|
log.Println("query :", query)
|
|
|
|
|
|
- iter := session.DB(cfg.Mgo.DbName).C("saleleads").Find(&query).Sort("_id").Iter()
|
|
|
+ iter := session.DB(cfg.Mgo.DbName).C("saleLeads").Find(&query).Sort("_id").Iter()
|
|
|
thisData := map[string]interface{}{}
|
|
|
|
|
|
for {
|
|
|
if !iter.Next(&thisData) {
|
|
|
+ lastId = mongodb.BsonIdToSId(thisData["_id"])
|
|
|
break
|
|
|
}
|
|
|
+ FormatData(thisData, "saleLeads")
|
|
|
+ }
|
|
|
+ cfg.LastId = lastId
|
|
|
+ log.Println("用户留资定时任务结束")
|
|
|
+}
|
|
|
+
|
|
|
+func FormatData(data map[string]interface{}, item string) {
|
|
|
+ userId, uId, positionId, source, cluename, phone := common.ObjToString(data["user_id"]), "", "", 0, "", ""
|
|
|
+ role, industry, department, position, name, top_cluetype, sub_cluetype, follow_project_area, level := "", "", "", "", "", "", "", "", ""
|
|
|
+ query := map[string]interface{}{}
|
|
|
+ if item == "orders" {
|
|
|
+ if !mongodb.IsObjectIdHex(userId) {
|
|
|
+ positionId = userId
|
|
|
+ userMapping := TiDb.FindOne("dwd_f_userbase_id_mapping", map[string]interface{}{"position_id": userId}, "", "")
|
|
|
+ if userMapping != nil && len(*userMapping) > 0 {
|
|
|
+ userId = common.ObjToString((*userMapping)["userid"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ query["userid"] = userId
|
|
|
+ userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
+ if userInfo != nil && len(*userInfo) > 0 {
|
|
|
+ uId = common.ObjToString((*userInfo)["uid"])
|
|
|
+ source = common.IntAll((*userInfo)["source"])
|
|
|
+ }
|
|
|
+ //cluename --> company_name
|
|
|
+ cluename = common.ObjToString(data["company_name"])
|
|
|
+ phone = common.ObjToString(data["user_phone"])
|
|
|
+ } else if item == "users" {
|
|
|
+ userId = mongodb.BsonIdToSId(data["_id"])
|
|
|
+ //新用户没有uid、source要等5分钟
|
|
|
+ query["userid"] = userId
|
|
|
+ userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
+ if userInfo != nil && len(*userInfo) > 0 {
|
|
|
+ uId = common.ObjToString((*userInfo)["uid"])
|
|
|
+ source = common.IntAll((*userInfo)["source"])
|
|
|
+ }
|
|
|
+ cluename = common.ObjToString(data["s_company"])
|
|
|
+ phone = common.ObjToString(data["s_phone"])
|
|
|
+ if phone == "" {
|
|
|
+ phone = common.ObjToString(data["s_m_phone"])
|
|
|
+ }
|
|
|
+ } else if item == "saleLeads" {
|
|
|
+ userId = common.ObjToString(data["userid"])
|
|
|
+ if !mongodb.IsObjectIdHex(userId) {
|
|
|
+ positionId = userId
|
|
|
+ userMapping := TiDb.FindOne("dwd_f_userbase_id_mapping", map[string]interface{}{"position_id": userId}, "", "")
|
|
|
+ if userMapping != nil && len(*userMapping) > 0 {
|
|
|
+ userId = common.ObjToString((*userMapping)["userid"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ query["userid"] = userId
|
|
|
+ userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
+ if userInfo != nil && len(*userInfo) > 0 {
|
|
|
+ uId = common.ObjToString((*userInfo)["uid"])
|
|
|
+ source = common.IntAll((*userInfo)["source"])
|
|
|
+ }
|
|
|
+ cluename = common.ObjToString(data["company"])
|
|
|
+ phone = common.ObjToString(data["phone"])
|
|
|
+ role = common.ObjToString(data["companyType"])
|
|
|
+ industry = common.ObjToString(data["industry"])
|
|
|
+ department = common.ObjToString(data["branch"])
|
|
|
+ position = common.ObjToString(data["position"])
|
|
|
+ name = common.ObjToString(data["name"])
|
|
|
+ // sourceCode = common.ObjToString(data["source"])
|
|
|
+ }
|
|
|
+ //域外用户和内部用户,不存线索
|
|
|
+ if source == 5 || source == 6 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //不是留资的要查一遍留资
|
|
|
+ if item == "orders" {
|
|
|
+ qid := positionId
|
|
|
+ if qid == "" {
|
|
|
+ qid = userId
|
|
|
+ }
|
|
|
+ saleLeadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"userid": qid}, map[string]interface{}{"_id": -1}, nil, false, 0, 1)
|
|
|
+ if ok && saleLeadsData != nil && len(*saleLeadsData) > 0 {
|
|
|
+ sdata := (*saleLeadsData)[0]
|
|
|
+ role = common.ObjToString(sdata["companyType"])
|
|
|
+ industry = common.ObjToString(sdata["industry"])
|
|
|
+ department = common.ObjToString(sdata["branch"])
|
|
|
+ position = common.ObjToString(sdata["position"])
|
|
|
+ name = common.ObjToString(sdata["name"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //top_cluetype
|
|
|
+ top_cluetype, sub_cluetype, level = getClueType(item, data)
|
|
|
+ //follow_project_area --> follow_project_monitor
|
|
|
+ follow_project_area = getAreaCode(userId)
|
|
|
+ //TODO seatNumber position_id
|
|
|
+ //自动分配规则暂不确定
|
|
|
+ log.Println("data +++", top_cluetype, sub_cluetype, level, follow_project_area)
|
|
|
+ position_id, seatNumber, saleName := autoDraw(level)
|
|
|
+ log.Println("data -------", position_id, seatNumber, saleName)
|
|
|
+ if position_id > 0 && seatNumber != "" {
|
|
|
+ uCount := TiDb.Count("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId})
|
|
|
+ if uCount > 0 {
|
|
|
+ SaveClue(item, userId, uId, top_cluetype, sub_cluetype, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber, position_id)
|
|
|
+ } else {
|
|
|
+ SaveClue(item, userId, uId, top_cluetype, sub_cluetype, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber, position_id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber string, positionId int64) {
|
|
|
+ nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
+ nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
|
|
|
+ // BCPCID := common.GetRandom(32)
|
|
|
+ TiDb.ExecTx("保存线索", func(tx *sql.Tx) bool {
|
|
|
+ //线索
|
|
|
+ clueId := TiDb.InsertByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
+ "userid": userId,
|
|
|
+ "uid": uId,
|
|
|
+ "seatNumber": seatNumber,
|
|
|
+ "position_id": positionId,
|
|
|
+ "is_assign": 1,
|
|
|
+ "comeintime": nowTime,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "updatetime": nowTime,
|
|
|
+ "cluename": cluename,
|
|
|
+ "top_cluetype": top_cluetype,
|
|
|
+ "sub_cluetype": sub_cluetype,
|
|
|
+ "trailstatus": "01",
|
|
|
+ "name": name,
|
|
|
+ "phone": phone,
|
|
|
+ "position": position,
|
|
|
+ "department": department,
|
|
|
+ "industry": industry,
|
|
|
+ "follow_project_area": follow_project_area,
|
|
|
+ "role": role,
|
|
|
+ })
|
|
|
+ //私海 --> 任务车
|
|
|
+ seaId := TiDb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "seatNumber": seatNumber,
|
|
|
+ "position_id": positionId,
|
|
|
+ "comeintime": nowTime,
|
|
|
+ "comeinsource": 2,
|
|
|
+ "is_task": 1,
|
|
|
+ "task_time": nowTime,
|
|
|
+ "tasktime": common.If(item == "users", nowTimes, nowTime),
|
|
|
+ "taskstatus": 0,
|
|
|
+ "tasksource": "线索自动分配" + "-" + top_cluetype + "-" + sub_cluetype,
|
|
|
+ })
|
|
|
+ //变更记录
|
|
|
+ uodateId1 := TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_type": "创建线索",
|
|
|
+ "new_value": "系统自动创建",
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": -1,
|
|
|
+ })
|
|
|
+ uodateId2 := TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_field": "position_id",
|
|
|
+ "change_type": "所属人变更",
|
|
|
+ "old_value": "/",
|
|
|
+ "new_value": saleName,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": -1,
|
|
|
+ })
|
|
|
+ uodateId3 := TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_field": "trailstatus",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "new_value": "新增",
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": -1,
|
|
|
+ })
|
|
|
+ uodateId4 := TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_type": "加入任务车",
|
|
|
+ "new_value": "线索自动分配" + "-" + top_cluetype + "-" + sub_cluetype,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": -1,
|
|
|
+ })
|
|
|
+ return clueId > 0 && seaId > 0 && uodateId1 > 0 && uodateId2 > 0 && uodateId3 > 0 && uodateId4 > 0
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func UpdateClue(item, userId, uId, top_cluetype, sub_cluetype, cluename, name, phone, position, department, industry, follow_project_area, role, seatNumber string, positionId int64) {
|
|
|
+ nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
+ // nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
|
|
|
+ TiDb.ExecTx("更新线索", func(tx *sql.Tx) bool {
|
|
|
+ //线索
|
|
|
+ ok := TiDb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, map[string]interface{}{
|
|
|
+ "seatNumber": seatNumber,
|
|
|
+ "position_id": positionId,
|
|
|
+ "is_assign": 1,
|
|
|
+ "updatetime": nowTime,
|
|
|
+ "cluename": cluename,
|
|
|
+ "top_cluetype": top_cluetype,
|
|
|
+ "sub_cluetype": sub_cluetype,
|
|
|
+ "trailstatus": "01",
|
|
|
+ "name": name,
|
|
|
+ "phone": phone,
|
|
|
+ "position": position,
|
|
|
+ "department": department,
|
|
|
+ "industry": industry,
|
|
|
+ "follow_project_area": follow_project_area,
|
|
|
+ "role": role,
|
|
|
+ })
|
|
|
+ return ok
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func getAreaCode(userId string) (code string) {
|
|
|
+ followData := Base.FindOne("follow_project_monitor", map[string]interface{}{"s_userid": userId}, "", "")
|
|
|
+ if followData != nil && len(*followData) > 0 {
|
|
|
+ infoId := common.ObjToString((*followData)["s_id"])
|
|
|
+ biddingData := Es.GetByIdField("bidding", "bidding", infoId, "")
|
|
|
+ if biddingData != nil && len(*biddingData) > 0 {
|
|
|
+ area := common.ObjToString((*biddingData)["area"])
|
|
|
+ address := common.ObjToString((*biddingData)["city"])
|
|
|
+ if address == "" {
|
|
|
+ address = area
|
|
|
+ }
|
|
|
+ areaData := TiDb.FindOne("d_area_code", map[string]interface{}{"name": address}, "", "")
|
|
|
+ if areaData != nil && len(*areaData) > 0 {
|
|
|
+ code = common.ObjToString((*areaData)["code"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func getClueType(item string, data map[string]interface{}) (pcode, code, level string) {
|
|
|
+ if item == "orders" {
|
|
|
+ productType := common.ObjToString(data["product_type"])
|
|
|
+ pcode = "1"
|
|
|
+ level = "A"
|
|
|
+ if productType == "VIP订阅" {
|
|
|
+ code = "6"
|
|
|
+ } else if productType == "大会员" {
|
|
|
+ code = "7"
|
|
|
+ } else if productType == "数据流量包" {
|
|
|
+ code = "8"
|
|
|
+ } else if productType == "历史数据" {
|
|
|
+ code = "9"
|
|
|
+ }
|
|
|
+ } else if item == "users" {
|
|
|
+ pcode = "4"
|
|
|
+ code = "154"
|
|
|
+ level = "C"
|
|
|
+ } else if item == "saleLeads" {
|
|
|
+ sourceCode := common.ObjToString(data["source"])
|
|
|
+ if sourceCode != "" {
|
|
|
+ codeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"source": sourceCode}, "", "")
|
|
|
+ if codeData != nil && len(*codeData) > 0 {
|
|
|
+ pcode = common.ObjToString((*codeData)["pcode"])
|
|
|
+ code = common.ObjToString((*codeData)["code"])
|
|
|
+ level = common.ObjToString((*codeData)["clue_level"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 获取自动分配的人
|
|
|
+func autoDraw(mode string) (positionId int64, seatNumber, saleName string) {
|
|
|
+ query := `select * from jy_salesperson_info where status = 0 and position != 0`
|
|
|
+ if mode == "A" || mode == "B" {
|
|
|
+ query += ` and is_complete = 1`
|
|
|
+ }
|
|
|
+ data := TiDb.SelectBySql(query)
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ sql := "select * from dwd_f_crm_clue_autodraw_record where clue_level = ?"
|
|
|
+ countData := TiDb.SelectBySql(sql, mode)
|
|
|
+ if countData != nil && len(*countData) > 0 {
|
|
|
+ for _, v := range *data {
|
|
|
+ //判断是否有新员工
|
|
|
+ isOk := false
|
|
|
+ for _, vv := range *countData {
|
|
|
+ if common.ObjToString(v["seatNumber"]) == common.ObjToString(vv["seatNumber"]) {
|
|
|
+ isOk = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //有新员工直接分给新员工
|
|
|
+ if !isOk {
|
|
|
+ seatNumber = common.ObjToString(v["seatNumber"])
|
|
|
+ saleName = common.ObjToString(v["name"])
|
|
|
+ rData := TiDb.FindOne("dwd_f_crm_clue_autodraw_record", map[string]interface{}{"clue_level": mode}, "", "count asc")
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_autodraw_record", map[string]interface{}{
|
|
|
+ "position_id": positionId,
|
|
|
+ "seatNumber": seatNumber,
|
|
|
+ "clue_level": mode,
|
|
|
+ "count": common.Int64All((*rData)["count"]),
|
|
|
+ })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if seatNumber == "" {
|
|
|
+ res := int64(0)
|
|
|
+ for k, v := range *countData {
|
|
|
+ if k == 0 {
|
|
|
+ res = common.Int64All(v["count"])
|
|
|
+ seatNumber = common.ObjToString(v["seatNumber"])
|
|
|
+ } else {
|
|
|
+ if common.Int64All(v["count"]) <= res {
|
|
|
+ res = common.Int64All(v["count"])
|
|
|
+ seatNumber = common.ObjToString(v["seatNumber"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, v := range *data {
|
|
|
+ if seatNumber == common.ObjToString(v["seatNumber"]) {
|
|
|
+ positionId = getPositionId(common.ObjToString(v["phone"]))
|
|
|
+ saleName = common.ObjToString(v["name"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if positionId > 0 {
|
|
|
+ TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where seatNumber = ? and clue_level = ?`, seatNumber, mode)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func getPositionId(phone string) (positionId int64) {
|
|
|
+ userData, ok := Mgo.FindOne("user", map[string]interface{}{"s_phone": phone})
|
|
|
+ if ok && userData != nil && len(*userData) > 0 {
|
|
|
+ userId := common.Int64All((*userData)["base_user_id"])
|
|
|
+ positionData := Base.FindOne("base_position", map[string]interface{}{"type": 1, "ent_id": 25917, "user_id": userId}, "", "") //TODO ent_id
|
|
|
+ if positionData != nil && len(*positionData) > 0 {
|
|
|
+ positionId = common.Int64All((*positionData)["id"])
|
|
|
+ }
|
|
|
}
|
|
|
+ return
|
|
|
}
|