|
@@ -18,7 +18,7 @@ import (
|
|
|
|
|
|
func kcSync() {
|
|
func kcSync() {
|
|
log.Println("客户成功系统移交定时任务开始")
|
|
log.Println("客户成功系统移交定时任务开始")
|
|
- sql := `select * from dwd_f_userbase_order_info where pay_money > 0 and autoUpdate >= "` + cfg.LastkcTime + `" order by autoUpdate asc`
|
|
|
|
|
|
+ sql := `select * from dwd_f_userbase_order_info where pay_money > 0 and vip_endtime > "` + time.Now().Format(date.Date_Full_Layout) + `" and autoUpdate > "` + cfg.LastkcTime + `" order by autoUpdate asc`
|
|
data := TiDb.SelectBySql(sql)
|
|
data := TiDb.SelectBySql(sql)
|
|
if data != nil && *data != nil && len(*data) > 0 {
|
|
if data != nil && *data != nil && len(*data) > 0 {
|
|
for _, v := range *data {
|
|
for _, v := range *data {
|
|
@@ -26,7 +26,8 @@ func kcSync() {
|
|
data_spec := common.ObjToString(v["data_spec"])
|
|
data_spec := common.ObjToString(v["data_spec"])
|
|
starttime := common.ObjToString(v["vip_starttime"])
|
|
starttime := common.ObjToString(v["vip_starttime"])
|
|
order_status := common.IntAll(v["order_status"])
|
|
order_status := common.IntAll(v["order_status"])
|
|
- if (product_type == "大会员" || product_type == "企业商机管理") && order_status == 1 && data_spec != "dhy4" && !strings.HasPrefix(starttime, "2099") {
|
|
|
|
|
|
+ refund_status := common.IntAll(v["refund_status"])
|
|
|
|
+ if (product_type == "大会员" || product_type == "企业商机管理") && order_status == 1 && data_spec != "dhy4" && !strings.HasPrefix(starttime, "2099") && refund_status != 1 {
|
|
status := kcJob(v)
|
|
status := kcJob(v)
|
|
if status == 0 {
|
|
if status == 0 {
|
|
break
|
|
break
|
|
@@ -45,9 +46,6 @@ func kcJob(data map[string]interface{}) int {
|
|
clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", "")
|
|
clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", "")
|
|
if clueData != nil && len(*clueData) > 0 {
|
|
if clueData != nil && len(*clueData) > 0 {
|
|
clueId = common.Int64All((*clueData)["id"])
|
|
clueId = common.Int64All((*clueData)["id"])
|
|
- if cicount := TiDb.Count("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}); cicount > 0 {
|
|
|
|
- return 1
|
|
|
|
- }
|
|
|
|
starttime := common.ObjToString(data["vip_starttime"])
|
|
starttime := common.ObjToString(data["vip_starttime"])
|
|
endtime := common.ObjToString(data["vip_endtime"])
|
|
endtime := common.ObjToString(data["vip_endtime"])
|
|
// user_role := common.IntAll(data["user_role"])
|
|
// user_role := common.IntAll(data["user_role"])
|
|
@@ -76,6 +74,7 @@ func kcJob(data map[string]interface{}) int {
|
|
starttime = common.ObjToString((*powerData)["starttime"])
|
|
starttime = common.ObjToString((*powerData)["starttime"])
|
|
endtime = common.ObjToString((*powerData)["endtime"])
|
|
endtime = common.ObjToString((*powerData)["endtime"])
|
|
} else {
|
|
} else {
|
|
|
|
+ log.Println("客成移交权限未查到--", phone)
|
|
return 0
|
|
return 0
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -190,45 +189,83 @@ func kcJob(data map[string]interface{}) int {
|
|
"service_stage": 1,
|
|
"service_stage": 1,
|
|
"company_name": company_name,
|
|
"company_name": company_name,
|
|
}
|
|
}
|
|
- cId, ok, updateId1, updateId2, updateId3 := int64(-1), false, int64(-1), int64(-1), int64(-1)
|
|
|
|
- if TiDb.ExecTx("保存客户", func(tx *sql.Tx) bool {
|
|
|
|
- cId = TiDb.InsertByTx(tx, "dwd_f_csm_customer_info", saveMap)
|
|
|
|
- ok = TiDb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
|
|
|
|
- updateId1 = 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,
|
|
|
|
- })
|
|
|
|
- updateId2 = 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,
|
|
|
|
- })
|
|
|
|
- updateId3 = 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": name,
|
|
|
|
- "createtime": nowTime,
|
|
|
|
- "BCPCID": common.GetRandom(32),
|
|
|
|
- "operator_id": -1,
|
|
|
|
- })
|
|
|
|
- return cId > -1 && ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1
|
|
|
|
- }) {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`update dwd_f_csm_customer_autodraw_record set count = count + 1 where name = ?`, name)
|
|
|
|
- log.Println("保存客户成功")
|
|
|
|
|
|
+ if TiDb.Count("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}) > 0 {
|
|
|
|
+ csmdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
|
|
|
|
+ if csmdata != nil && len(*csmdata) > 0 {
|
|
|
|
+ TiDb.Update("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, map[string]interface{}{
|
|
|
|
+ "is_transfer": 0,
|
|
|
|
+ "is_renewal_protection": 0,
|
|
|
|
+ "product_access": product,
|
|
|
|
+ "buy_subject": buy_subject,
|
|
|
|
+ "transfertime": nowTime,
|
|
|
|
+ "service_starttime": starttime,
|
|
|
|
+ "service_endtime": endtime,
|
|
|
|
+ "ent_id": entId,
|
|
|
|
+ "company_name": company_name,
|
|
|
|
+ })
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": (*csmdata)["position_id"],
|
|
|
|
+ "change_type": "成交客户移交",
|
|
|
|
+ "new_value": "移交至客户成功组",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": (*csmdata)["position_id"],
|
|
|
|
+ "change_field": "position_id",
|
|
|
|
+ "change_type": "客户成功经理",
|
|
|
|
+ "old_value": "/",
|
|
|
|
+ "new_value": (*csmdata)["name"],
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- log.Println("保存客户失败!!!", clueId, cId, ok, updateId1, updateId2, updateId3, " 用户信息 ", name, positionId, uId)
|
|
|
|
|
|
+ cId, ok, updateId1, updateId2, updateId3 := int64(-1), false, int64(-1), int64(-1), int64(-1)
|
|
|
|
+ if TiDb.ExecTx("保存客户", func(tx *sql.Tx) bool {
|
|
|
|
+ cId = TiDb.InsertByTx(tx, "dwd_f_csm_customer_info", saveMap)
|
|
|
|
+ ok = TiDb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
|
|
|
|
+ updateId1 = 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,
|
|
|
|
+ })
|
|
|
|
+ updateId2 = 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,
|
|
|
|
+ })
|
|
|
|
+ updateId3 = 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": name,
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ return cId > -1 && ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1
|
|
|
|
+ }) {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`update dwd_f_csm_customer_autodraw_record set count = count + 1 where name = ?`, name)
|
|
|
|
+ log.Println("保存客户成功")
|
|
|
|
+ } else {
|
|
|
|
+ log.Println("保存客户失败!!!", clueId, cId, ok, updateId1, updateId2, updateId3, " 用户信息 ", name, positionId, uId)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return status
|
|
return status
|
|
} else {
|
|
} else {
|
|
@@ -1141,3 +1178,189 @@ func kcVisitSync() {
|
|
log.Println("xls error")
|
|
log.Println("xls error")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func refundAuto() {
|
|
|
|
+ log.Println("自动移交销售定时任务开始")
|
|
|
|
+ nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
|
|
+ TiDb.SelectByBath(100, func(l *[]map[string]interface{}) bool {
|
|
|
|
+ for _, v := range *l {
|
|
|
|
+ saleId, cluename, company_nature, company_verification := int64(0), "", 0, 0
|
|
|
|
+ clueId := common.Int64All(v["clue_id"])
|
|
|
|
+ name := common.ObjToString(v["name"])
|
|
|
|
+ kcposition_id := common.Int64All(v["position_id"])
|
|
|
|
+ isRenewalProtection := common.IntAll(v["is_renewal_protection"])
|
|
|
|
+ phone := ""
|
|
|
|
+
|
|
|
|
+ // if !mongodb.IsObjectIdHex(userId) {
|
|
|
|
+ clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, "company_nature,company_verification,cluename,userid,position_id,phone", "")
|
|
|
|
+ if clueData != nil && len(*clueData) > 0 {
|
|
|
|
+ saleId = common.Int64All((*clueData)["position_id"])
|
|
|
|
+ // userId = common.ObjToString((*clueData)["userid"])
|
|
|
|
+ cluename = common.ObjToString((*clueData)["cluename"])
|
|
|
|
+ company_nature = common.IntAll((*clueData)["company_nature"])
|
|
|
|
+ company_verification = common.IntAll((*clueData)["company_verification"])
|
|
|
|
+ phone = common.ObjToString((*clueData)["phone"])
|
|
|
|
+ }
|
|
|
|
+ query1 := `select id from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > "` + nowTime + `" and order_status = 1 and user_phone = "` + phone + `"`
|
|
|
|
+ query2 := `select id from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and refund_status in (0,2) and order_status = 1 and user_phone = "` + phone + `"`
|
|
|
|
+ // userData := TiDb.SelectBySql("select position_id from dwd_f_userbase_id_mapping where userid = ? and ent_id = ?", userId, entId)
|
|
|
|
+ // if userData != nil && len(*userData) > 0 {
|
|
|
|
+ // positionId = common.Int64All((*userData)[0]["position_id"])
|
|
|
|
+ // query1 = `select id from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > "` + nowTime + `" and order_status = 1 and user_id = "` + fmt.Sprint(positionId) + `"`
|
|
|
|
+ // query2 = `select id from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and refund_status in (0,2) and order_status = 1 and user_id = "` + fmt.Sprint(positionId) + `"`
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ order1 := Mysql.SelectBySql(query1)
|
|
|
|
+ if order1 == nil || len(*order1) == 0 {
|
|
|
|
+ log.Println("query1 ", query1)
|
|
|
|
+ isOk := false
|
|
|
|
+ order3 := Mysql.SelectBySql(`select vip_endtime from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < "` + nowTime + `" and order_status = 1 and user_phone = "` + phone + `"`)
|
|
|
|
+ if order3 != nil && len(*order3) > 0 {
|
|
|
|
+ for _, vv := range *order3 {
|
|
|
|
+ if isRenewalProtection == 1 {
|
|
|
|
+ vip_endtime := common.ObjToString(vv["vip_endtime"])
|
|
|
|
+ vip_endtimes, _ := time.ParseInLocation(date.Date_Full_Layout, vip_endtime, time.Local)
|
|
|
|
+ if time.Now().Unix()-vip_endtimes.Unix() < 30*86400 {
|
|
|
|
+ isOk = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !isOk {
|
|
|
|
+ //全到期了
|
|
|
|
+ if saleId > 0 {
|
|
|
|
+ saleData := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"position_id": saleId, "resign": 0}, "", "")
|
|
|
|
+ if saleData != nil && len(*saleData) > 0 {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET updatetime=?,trailstatus="01",is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0 WHERE id = ?`, nowTime, nowTime, clueId)
|
|
|
|
+ } else {
|
|
|
|
+ if company_nature == 0 && company_verification == 1 && cluename != "" {
|
|
|
|
+ adata := TiDb.Find("dwd_f_crm_clue_info", map[string]interface{}{"cluename": cluename, "is_assign": 1}, "seatNumber,position_id", "", -1, -1)
|
|
|
|
+ if adata != nil && len(*adata) > 0 {
|
|
|
|
+ isOks := false
|
|
|
|
+ for _, vv := range *adata {
|
|
|
|
+ position_ids := common.Int64All(vv["position_id"])
|
|
|
|
+ seatNumber := common.ObjToString(vv["seatNumber"])
|
|
|
|
+ saleDatas := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"position_id": position_ids, "resign": 0}, "", "")
|
|
|
|
+ if saleDatas != nil && len(*saleDatas) > 0 {
|
|
|
|
+ saleId = position_ids
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0 WHERE id = ?`, nowTime, saleId, seatNumber, nowTime, clueId)
|
|
|
|
+ isOks = true
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !isOks {
|
|
|
|
+ sdata := TiDb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id where a.bi_pcode = (SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) and b.role_id = 3`, saleId)
|
|
|
|
+ if sdata != nil && len(*sdata) > 0 {
|
|
|
|
+ saleId = common.Int64All((*sdata)[0]["position_id"])
|
|
|
|
+ seatNumber := common.ObjToString((*sdata)[0]["seat_number"])
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0 WHERE id = ?`, nowTime, saleId, seatNumber, nowTime, clueId)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ sdata := TiDb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id where a.bi_pcode = (SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) and b.role_id = 3`, saleId)
|
|
|
|
+ if sdata != nil && len(*sdata) > 0 {
|
|
|
|
+ saleId = common.Int64All((*sdata)[0]["position_id"])
|
|
|
|
+ seatNumber := common.ObjToString((*sdata)[0]["seat_number"])
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0 WHERE id = ?`, nowTime, saleId, seatNumber, nowTime, clueId)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET updatetime=?,trailstatus="01",top_cluetype="532",sub_cluetype="537",is_transfer=0 WHERE id = ?`, nowTime, clueId)
|
|
|
|
+ }
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": common.If(kcposition_id > 0, kcposition_id, -1),
|
|
|
|
+ "change_type": "基本信息变更",
|
|
|
|
+ "old_value": "成交客户",
|
|
|
|
+ "change_field": "trailstatus",
|
|
|
|
+ "new_value": "商机线索",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": saleId,
|
|
|
|
+ "change_type": "加入任务车",
|
|
|
|
+ "new_value": "线索自动分配-其他-成交客户续约失败",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": common.If(kcposition_id > 0, kcposition_id, -1),
|
|
|
|
+ "change_type": "客户成功经理",
|
|
|
|
+ "change_field": "position_id",
|
|
|
|
+ "old_value": name,
|
|
|
|
+ "new_value": "/",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": saleId,
|
|
|
|
+ "change_type": "移交销售",
|
|
|
|
+ "new_value": "成交客户续费失败,到期自动移交",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_csm_customer_info SET is_transfer=1 WHERE clue_id = ?`, clueId)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ order2 := Mysql.SelectBySql(query2)
|
|
|
|
+ if order2 == nil || len(*order2) == 0 {
|
|
|
|
+ log.Println("query2 ", query2)
|
|
|
|
+ //全退款了
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_assign=0,trailstatus="01",position_id=null,seatNumber=null,updatetime=?,comeintime_open=?,comeinsource_open=1,level_open=3,next_trail_time=null,is_task=null,tasktime=null,taskstatus=null,comeinsource_private=null,tasksource=null,is_transfer=0 WHERE id = ?`, nowTime, nowTime, clueId)
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": common.If(kcposition_id > 0, kcposition_id, -1),
|
|
|
|
+ "change_type": "退回公海",
|
|
|
|
+ "new_value": "成交客户申请退款",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": common.If(kcposition_id > 0, kcposition_id, -1),
|
|
|
|
+ "change_field": "trailstatus",
|
|
|
|
+ "change_type": "基本信息变更",
|
|
|
|
+ "old_value": "成交客户",
|
|
|
|
+ "new_value": "商机线索",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": common.If(kcposition_id > 0, kcposition_id, -1),
|
|
|
|
+ "change_type": "客户成功经理",
|
|
|
|
+ "change_field": "position_id",
|
|
|
|
+ "old_value": name,
|
|
|
|
+ "new_value": "/",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": common.If(kcposition_id > 0, kcposition_id, -1),
|
|
|
|
+ "change_type": "移交销售",
|
|
|
|
+ "new_value": "成交客户申请退款",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_csm_customer_info SET is_transfer=1 WHERE clue_id = ?`, clueId)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
|
|
+ }, `select ent_id,clue_id,position_id,name,is_renewal_protection from dwd_f_csm_customer_info where is_transfer = 0`)
|
|
|
|
+ log.Println("自动移交销售定时任务结束")
|
|
|
|
+}
|