|
@@ -13,7 +13,6 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
|
"app.yhyue.com/moapp/jybase/mongodb"
|
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
|
- "github.com/tealeg/xlsx"
|
|
|
)
|
|
|
|
|
|
func kcSync() {
|
|
@@ -97,6 +96,7 @@ func kcJob(data map[string]interface{}) int {
|
|
|
//合力亿捷线索同步
|
|
|
customerData := TiDbData.FindOne("customer", map[string]interface{}{"phone": phone}, "", "")
|
|
|
if customerData != nil {
|
|
|
+ log.Println("移交客成查询到合力亿捷")
|
|
|
status999 := common.ObjToString((*customerData)["status999"]) //线索状态
|
|
|
source := common.ObjToString((*customerData)["source"]) //销售来源
|
|
|
customerNeeds := common.ObjToString((*customerData)["customerNeeds"]) //客户需求
|
|
@@ -167,6 +167,7 @@ func kcJob(data map[string]interface{}) int {
|
|
|
//
|
|
|
entIds := common.IntAll(data["ent_id"])
|
|
|
positionId, name = cAutoDraw(entIds)
|
|
|
+ log.Println("移交客成positionId", positionId, name)
|
|
|
saveMap = map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
"transfertime": nowTime,
|
|
@@ -594,727 +595,30 @@ func ordersClue() {
|
|
|
log.Println("后台订单线索定时任务结束")
|
|
|
}
|
|
|
|
|
|
-func kcHistorySync() {
|
|
|
- filePath := "./无线索的.xlsx"
|
|
|
- // SE := qu.SimpleEncrypt{Key: "topJYBX2019"}
|
|
|
- // log.Println(SE.DecodeString("QltHc2AmagsIUFwVV0dybyZpAwECX0YK"))
|
|
|
- // return
|
|
|
- xlFile, _ := xlsx.OpenFile(filePath)
|
|
|
- //获取行数
|
|
|
- // length := len(xlFile.Sheets[0].Rows)
|
|
|
- //开辟除表头外的行数的数组内存
|
|
|
- // resourceArr := make([]map[string]interface{}, length-1)
|
|
|
- //遍历sheet
|
|
|
- for k, sheet := range xlFile.Sheets {
|
|
|
- if k > 0 {
|
|
|
- break
|
|
|
- }
|
|
|
- //遍历每一行
|
|
|
- for rowIndex, row := range sheet.Rows {
|
|
|
- //跳过第一行表头信息
|
|
|
- if rowIndex == 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
- nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
|
- relationship_building_way := row.Cells[1].Value
|
|
|
- relationship_building_ways := 1
|
|
|
- if relationship_building_way == "个人微信" {
|
|
|
- relationship_building_ways = 2
|
|
|
- } else if relationship_building_way == "企业微信" {
|
|
|
- relationship_building_ways = 3
|
|
|
- }
|
|
|
- training_way := row.Cells[2].Value
|
|
|
- training_ways := 1
|
|
|
- if training_way == "发送使用资料" {
|
|
|
- training_ways = 5
|
|
|
- } else if training_way == "线上一对一" {
|
|
|
- training_ways = 3
|
|
|
- } else if training_way == "线下一对一" {
|
|
|
- training_ways = 4
|
|
|
- }
|
|
|
- inventory_way := row.Cells[3].Value
|
|
|
- inventory_ways := 1
|
|
|
- if inventory_way == "电话盘点" {
|
|
|
- inventory_ways = 3
|
|
|
- } else if inventory_way == "微信盘点" {
|
|
|
- inventory_ways = 2
|
|
|
- }
|
|
|
- service_stage := row.Cells[4].Value
|
|
|
- service_stages := 1
|
|
|
- if service_stage == "断约" {
|
|
|
- service_stages = 2
|
|
|
- } else if service_stage == "续约期" {
|
|
|
- service_stages = 3
|
|
|
- }
|
|
|
- renewal_intention := row.Cells[5].Value
|
|
|
- renewal_intentions := 1
|
|
|
- if renewal_intention == "中" {
|
|
|
- renewal_intentions = 2
|
|
|
- } else if renewal_intention == "高" {
|
|
|
- renewal_intentions = 3
|
|
|
- }
|
|
|
- positive_behavior_reminder := row.Cells[6].Value
|
|
|
- positive_behavior_reminders := ""
|
|
|
- if positive_behavior_reminder != "" {
|
|
|
- positive_behavior_reminders = "1,3"
|
|
|
- }
|
|
|
- // negative_behavior_reminder := ""
|
|
|
- name := row.Cells[13].Value
|
|
|
- // phoneMap := map[string]string{
|
|
|
- // "朱庆伟": "17600755377",
|
|
|
- // "程涵": "15538709520",
|
|
|
- // "张铭铭": "18237530966",
|
|
|
- // }
|
|
|
-
|
|
|
- // company_name := row.Cells[10].Value
|
|
|
- company_address := row.Cells[14].Value
|
|
|
- company_website := row.Cells[15].Value
|
|
|
- service_starttime := row.Cells[16].Value
|
|
|
- service_endtime := row.Cells[17].Value
|
|
|
-
|
|
|
- industry_status := row.Cells[21].Value
|
|
|
- industry_statuss := 1
|
|
|
- if industry_status == "非头部" {
|
|
|
- industry_statuss = 2
|
|
|
- }
|
|
|
- target_customer_type := row.Cells[24].Value
|
|
|
- main_sale_way := row.Cells[25].Value
|
|
|
- main_get_info_way := row.Cells[26].Value
|
|
|
- bid_sales_proportion := row.Cells[27].Value
|
|
|
- continuous_use_judgment := row.Cells[29].Value
|
|
|
- bid_sales_proportions := 1
|
|
|
- continuous_use_judgments := 1
|
|
|
- if bid_sales_proportion == "10%-19%" {
|
|
|
- bid_sales_proportions = 2
|
|
|
- } else if bid_sales_proportion == "20%-49%" {
|
|
|
- bid_sales_proportions = 3
|
|
|
- } else if bid_sales_proportion == "50%-69%" {
|
|
|
- bid_sales_proportions = 4
|
|
|
- } else if bid_sales_proportion == "70%及以上" {
|
|
|
- bid_sales_proportions = 4
|
|
|
- }
|
|
|
- if strings.Contains(continuous_use_judgment, "预计可持续使用。需勤维护") {
|
|
|
- continuous_use_judgments = 2
|
|
|
- } else if strings.Contains(continuous_use_judgment, "需从功能层面提升客户粘性") {
|
|
|
- continuous_use_judgments = 3
|
|
|
- } else if strings.Contains(continuous_use_judgment, "需持续培育") {
|
|
|
- continuous_use_judgments = 4
|
|
|
- }
|
|
|
- is_pre_sales_training := row.Cells[30].Value
|
|
|
- is_pre_sales_trainings := 0
|
|
|
- if is_pre_sales_training == "是" {
|
|
|
- is_pre_sales_trainings = 1
|
|
|
- }
|
|
|
- shpx := row.Cells[31].Value
|
|
|
- if shpx == "否" {
|
|
|
- training_ways = 2
|
|
|
- }
|
|
|
- notes := row.Cells[32].Value
|
|
|
- phone := strings.TrimSpace(row.Cells[11].Value)
|
|
|
- log.Println("PHONE", phone, name, len(phone))
|
|
|
- // if phone != "" && len(phone) == 11 && phoneMap[name] != "" {
|
|
|
- positionId := 0
|
|
|
- if name == "程涵" {
|
|
|
- positionId = 2202735
|
|
|
- } else if name == "张铭铭" {
|
|
|
- positionId = 2202736
|
|
|
- }
|
|
|
- clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
|
- log.Println("clueData", clueData)
|
|
|
- if clueData != nil {
|
|
|
- clueId := common.Int64All((*clueData)["id"])
|
|
|
- log.Println("线索存在", phone, clueId)
|
|
|
- role := row.Cells[18].Value
|
|
|
- business_scope := row.Cells[19].Value
|
|
|
- industry := row.Cells[20].Value
|
|
|
- salesperson_num := row.Cells[22].Value
|
|
|
- salesperson_nums := 1
|
|
|
- if salesperson_num == "10-19" {
|
|
|
- salesperson_nums = 2
|
|
|
- } else if salesperson_num == "20-49" {
|
|
|
- salesperson_nums = 3
|
|
|
- } else if salesperson_num == "50-99" {
|
|
|
- salesperson_nums = 4
|
|
|
- }
|
|
|
- area := row.Cells[23].Value
|
|
|
- areaArr := []string{}
|
|
|
- for _, v := range strings.Split(area, ",") {
|
|
|
- areaArr = append(areaArr, AreaCode[v])
|
|
|
- }
|
|
|
- follow_project_area := ""
|
|
|
- if len(areaArr) > 0 {
|
|
|
- follow_project_area = strings.Join(areaArr, ",")
|
|
|
- }
|
|
|
- customer_demand := row.Cells[28].Value
|
|
|
- updatetime := row.Cells[36].Value
|
|
|
- ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, map[string]interface{}{
|
|
|
- "role": role,
|
|
|
- "business_scope": business_scope,
|
|
|
- "industry": industry,
|
|
|
- "follow_project_area": follow_project_area,
|
|
|
- "customer_demand": customer_demand,
|
|
|
- "updatetime": updatetime,
|
|
|
- "is_transfer": 1,
|
|
|
- "salesperson_num": salesperson_nums,
|
|
|
- })
|
|
|
- if ok {
|
|
|
- entId := "0"
|
|
|
- buy_subject := 1
|
|
|
- company_name := ""
|
|
|
- product := 1
|
|
|
- powerData := TiDb.FindOne("dwd_f_userbase_order_info", map[string]interface{}{"phone": phone}, "", "autoUpdate desc")
|
|
|
- if powerData != nil {
|
|
|
- buy_subject = common.IntAll((*powerData)["buy_subject"])
|
|
|
- if buy_subject == 1 {
|
|
|
- entId = common.ObjToString((*powerData)["userid"])
|
|
|
- } else {
|
|
|
- entId = fmt.Sprint((*powerData)["ent_id"])
|
|
|
- }
|
|
|
- company_name = common.ObjToString((*powerData)["company_name"])
|
|
|
- product_type := common.ObjToString((*powerData)["product_type"])
|
|
|
- data_spec := common.ObjToString((*powerData)["data_spec"])
|
|
|
- productMap := map[string]int{
|
|
|
- "dhy6": 1,
|
|
|
- "dhy7": 2,
|
|
|
- "dhy3": 4,
|
|
|
- "dhy1": 5,
|
|
|
- "dhy2": 6,
|
|
|
- "dhy5": 7,
|
|
|
- "企业商机管理": 8,
|
|
|
- }
|
|
|
- if product_type == "企业商机管理" {
|
|
|
- product = productMap[product_type]
|
|
|
- } else {
|
|
|
- if data_spec == "dhy6" {
|
|
|
- product = 1
|
|
|
- filter := common.ObjToString((*powerData)["filter"])
|
|
|
- filterMap := map[string]interface{}{}
|
|
|
- json.Unmarshal([]byte(filter), &filterMap)
|
|
|
- if len(filterMap) > 0 {
|
|
|
- areaCount := common.IntAll(filterMap["areaCount"])
|
|
|
- if areaCount == 1 {
|
|
|
- product = 3
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- product = productMap[data_spec]
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- cid := TiDb.Insert("dwd_f_csm_customer_info", map[string]interface{}{
|
|
|
- "clue_id": clueId,
|
|
|
- "transfertime": nowTime,
|
|
|
- "position_id": positionId,
|
|
|
- "name": name,
|
|
|
- "service_starttime": service_starttime,
|
|
|
- "service_endtime": service_endtime,
|
|
|
- "ent_id": entId,
|
|
|
- "is_task": 1,
|
|
|
- "tasktime": nowTime,
|
|
|
- "taskstatus": 0,
|
|
|
- "tasksource": "1",
|
|
|
- "is_admin": 1,
|
|
|
- "product_access": product,
|
|
|
- "buy_subject": buy_subject,
|
|
|
- "relationship_building_way": relationship_building_ways,
|
|
|
- "inventory_way": inventory_ways,
|
|
|
- "training_way": training_ways,
|
|
|
- "is_pre_sales_training": is_pre_sales_trainings,
|
|
|
- "service_stage": service_stages,
|
|
|
- "company_name": company_name,
|
|
|
- "renewal_intention": renewal_intentions,
|
|
|
- "positive_behavior_reminder": positive_behavior_reminders,
|
|
|
- "company_address": company_address,
|
|
|
- "company_website": company_website,
|
|
|
- "industry_status": industry_statuss,
|
|
|
- "target_customer_type": target_customer_type,
|
|
|
- "main_sale_way": main_sale_way,
|
|
|
- "main_get_info_way": main_get_info_way,
|
|
|
- // "bid_sales_proportion": bid_sales_proportions,
|
|
|
- // "continuous_use_judgment": continuous_use_judgments,
|
|
|
- "notes": notes,
|
|
|
- })
|
|
|
- if cid > 0 {
|
|
|
- log.Println("保存客户成功", phone)
|
|
|
- } else {
|
|
|
- log.Println("保存客户失败!!!", phone)
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.Println("线索修改失败!!!", phone)
|
|
|
- }
|
|
|
- } else {
|
|
|
- role := row.Cells[18].Value
|
|
|
- business_scope := row.Cells[19].Value
|
|
|
- industry := row.Cells[20].Value
|
|
|
- salesperson_num := row.Cells[22].Value
|
|
|
- salesperson_nums := 1
|
|
|
- if salesperson_num == "10-19" {
|
|
|
- salesperson_nums = 2
|
|
|
- } else if salesperson_num == "20-49" {
|
|
|
- salesperson_nums = 3
|
|
|
- } else if salesperson_num == "50-99" {
|
|
|
- salesperson_nums = 4
|
|
|
- }
|
|
|
- area := row.Cells[23].Value
|
|
|
- areaArr := []string{}
|
|
|
- for _, v := range strings.Split(area, ",") {
|
|
|
- areaArr = append(areaArr, AreaCode[v])
|
|
|
- }
|
|
|
- follow_project_area := ""
|
|
|
- if len(areaArr) > 0 {
|
|
|
- follow_project_area = strings.Join(areaArr, ",")
|
|
|
- }
|
|
|
- customer_demand := row.Cells[28].Value
|
|
|
- entId := "0"
|
|
|
- clueId := int64(0)
|
|
|
- buy_subject := 1
|
|
|
- company_name := ""
|
|
|
- product := 1
|
|
|
- powerData := TiDb.FindOne("dwd_f_userbase_order_info", map[string]interface{}{"phone": phone}, "", "autoUpdate desc")
|
|
|
- if powerData != nil {
|
|
|
- buy_subject = common.IntAll((*powerData)["buy_subject"])
|
|
|
- if buy_subject == 1 {
|
|
|
- entId = common.ObjToString((*powerData)["userid"])
|
|
|
- } else {
|
|
|
- entId = fmt.Sprint((*powerData)["ent_id"])
|
|
|
- }
|
|
|
- company_name = common.ObjToString((*powerData)["company_name"])
|
|
|
- product_type := common.ObjToString((*powerData)["product_type"])
|
|
|
- data_spec := common.ObjToString((*powerData)["data_spec"])
|
|
|
- productMap := map[string]int{
|
|
|
- "dhy6": 1,
|
|
|
- "dhy7": 2,
|
|
|
- "dhy3": 4,
|
|
|
- "dhy1": 5,
|
|
|
- "dhy2": 6,
|
|
|
- "dhy5": 7,
|
|
|
- "企业商机管理": 8,
|
|
|
- }
|
|
|
- if product_type == "企业商机管理" {
|
|
|
- product = productMap[product_type]
|
|
|
- } else {
|
|
|
- if data_spec == "dhy6" {
|
|
|
- product = 1
|
|
|
- filter := common.ObjToString((*powerData)["filter"])
|
|
|
- filterMap := map[string]interface{}{}
|
|
|
- json.Unmarshal([]byte(filter), &filterMap)
|
|
|
- if len(filterMap) > 0 {
|
|
|
- areaCount := common.IntAll(filterMap["areaCount"])
|
|
|
- if areaCount == 1 {
|
|
|
- product = 3
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- product = productMap[data_spec]
|
|
|
- }
|
|
|
- }
|
|
|
- //
|
|
|
- uId := common.ObjToString((*powerData)["uid"])
|
|
|
- userId := common.ObjToString((*powerData)["userid"])
|
|
|
- pay_money := common.IntAll((*powerData)["pay_money"])
|
|
|
- seatNumber, trailstatus := "", ""
|
|
|
- salePositionId := int64(0)
|
|
|
- cluename := common.ObjToString((*powerData)["company_name"])
|
|
|
- salesperson := common.ObjToString((*powerData)["salesperson"])
|
|
|
- if cluename == "" {
|
|
|
- cluename = phone
|
|
|
- }
|
|
|
- if pay_money > 0 {
|
|
|
- trailstatus = "08"
|
|
|
- } else {
|
|
|
- trailstatus = "01"
|
|
|
- }
|
|
|
- saleData := TiDb.FindOne("jy_salesperson_info", map[string]interface{}{"name": salesperson}, "", "")
|
|
|
- if saleData != nil {
|
|
|
- seatNumber = common.ObjToString((*saleData)["seat_number"])
|
|
|
- salePositionId = common.Int64All((*saleData)["position_id"])
|
|
|
- }
|
|
|
- clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
- "userid": userId,
|
|
|
- "uid": uId,
|
|
|
- "seatNumber": seatNumber,
|
|
|
- "position_id": salePositionId,
|
|
|
- "is_assign": 1,
|
|
|
- "comeintime": nowTime,
|
|
|
- "createtime": nowTime,
|
|
|
- "updatetime": nowTime,
|
|
|
- "cluename": cluename,
|
|
|
- "top_cluetype": "4",
|
|
|
- "sub_cluetype": "154",
|
|
|
- "trailstatus": trailstatus,
|
|
|
- "name": phone,
|
|
|
- "phone": phone,
|
|
|
- "comeinsource_private": 2,
|
|
|
- "is_task": 0,
|
|
|
- "taskstatus": 1,
|
|
|
- "role": role,
|
|
|
- "business_scope": business_scope,
|
|
|
- "industry": industry,
|
|
|
- "follow_project_area": follow_project_area,
|
|
|
- "customer_demand": customer_demand,
|
|
|
- "is_transfer": 1,
|
|
|
- "salesperson_num": salesperson_nums,
|
|
|
- })
|
|
|
- //
|
|
|
- }
|
|
|
- TiDb.Insert("dwd_f_csm_customer_info", map[string]interface{}{
|
|
|
- "clue_id": clueId,
|
|
|
- "transfertime": nowTime,
|
|
|
- "position_id": positionId,
|
|
|
- "name": name,
|
|
|
- "service_starttime": service_starttime,
|
|
|
- "service_endtime": service_endtime,
|
|
|
- "ent_id": entId,
|
|
|
- "is_task": 0,
|
|
|
- "tasktime": nil,
|
|
|
- "taskstatus": 1,
|
|
|
- "tasksource": nil,
|
|
|
- "is_admin": 1,
|
|
|
- "product_access": product,
|
|
|
- "buy_subject": buy_subject,
|
|
|
- "relationship_building_way": relationship_building_ways,
|
|
|
- "inventory_way": inventory_ways,
|
|
|
- "training_way": training_ways,
|
|
|
- "is_pre_sales_training": is_pre_sales_trainings,
|
|
|
- "service_stage": service_stages,
|
|
|
- "company_name": company_name,
|
|
|
- "renewal_intention": renewal_intentions,
|
|
|
- "positive_behavior_reminder": positive_behavior_reminders,
|
|
|
- "company_address": company_address,
|
|
|
- "company_website": company_website,
|
|
|
- "industry_status": industry_statuss,
|
|
|
- "target_customer_type": target_customer_type,
|
|
|
- "main_sale_way": main_sale_way,
|
|
|
- "main_get_info_way": main_get_info_way,
|
|
|
- "bid_sales_proportion": bid_sales_proportions,
|
|
|
- "continuous_use_judgment": continuous_use_judgments,
|
|
|
- "notes": notes,
|
|
|
- })
|
|
|
- }
|
|
|
- // } else {
|
|
|
- // log.Println("手机号有问题!!!", phone)
|
|
|
- // row.AddCell().SetValue("手机号有问题!!!")
|
|
|
- // }
|
|
|
- }
|
|
|
- }
|
|
|
- // err := xlFile.Save("./222.xlsx")
|
|
|
- // if err != nil {
|
|
|
- // log.Println("xls error")
|
|
|
- // }
|
|
|
-}
|
|
|
-
|
|
|
-func kcHistorySyncs() {
|
|
|
- filePath := "./有线索的.xlsx"
|
|
|
- // SE := qu.SimpleEncrypt{Key: "topJYBX2019"}
|
|
|
- // log.Println(SE.DecodeString("QltHc2AmagsIUFwVV0dybyZpAwECX0YK"))
|
|
|
- // return
|
|
|
- xlFile, _ := xlsx.OpenFile(filePath)
|
|
|
- //获取行数
|
|
|
- // length := len(xlFile.Sheets[0].Rows)
|
|
|
- //开辟除表头外的行数的数组内存
|
|
|
- // resourceArr := make([]map[string]interface{}, length-1)
|
|
|
- //遍历sheet
|
|
|
- for k, sheet := range xlFile.Sheets {
|
|
|
- if k > 0 {
|
|
|
- break
|
|
|
- }
|
|
|
- //遍历每一行
|
|
|
- for rowIndex, row := range sheet.Rows {
|
|
|
- //跳过第一行表头信息
|
|
|
- if rowIndex == 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
- bid_sales_proportion := row.Cells[2].Value
|
|
|
- continuous_use_judgment := row.Cells[3].Value
|
|
|
- phone := row.Cells[0].Value
|
|
|
- bid_sales_proportions := 1
|
|
|
- continuous_use_judgments := 1
|
|
|
- if bid_sales_proportion == "10%-19%" {
|
|
|
- bid_sales_proportions = 2
|
|
|
- } else if bid_sales_proportion == "20%-49%" {
|
|
|
- bid_sales_proportions = 3
|
|
|
- } else if bid_sales_proportion == "50%-69%" {
|
|
|
- bid_sales_proportions = 4
|
|
|
- } else if bid_sales_proportion == "70%及以上" {
|
|
|
- bid_sales_proportions = 4
|
|
|
- }
|
|
|
- if strings.Contains(continuous_use_judgment, "预计可持续使用。需勤维护") {
|
|
|
- continuous_use_judgments = 2
|
|
|
- } else if strings.Contains(continuous_use_judgment, "需从功能层面提升客户粘性") {
|
|
|
- continuous_use_judgments = 3
|
|
|
- } else if strings.Contains(continuous_use_judgment, "需持续培育") {
|
|
|
- continuous_use_judgments = 4
|
|
|
- }
|
|
|
- if phone != "" {
|
|
|
- clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
|
- if clueData != nil {
|
|
|
- clueId := common.Int64All((*clueData)["id"])
|
|
|
- log.Println("线索存在", phone, clueId)
|
|
|
- salesperson_num := row.Cells[1].Value
|
|
|
- salesperson_nums := 1
|
|
|
- if salesperson_num == "10-19" {
|
|
|
- salesperson_nums = 2
|
|
|
- } else if salesperson_num == "20-49" {
|
|
|
- salesperson_nums = 3
|
|
|
- } else if salesperson_num == "50-99" {
|
|
|
- salesperson_nums = 4
|
|
|
- }
|
|
|
- ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, map[string]interface{}{
|
|
|
- "salesperson_num": salesperson_nums,
|
|
|
- })
|
|
|
- if ok {
|
|
|
- oks := TiDb.Update("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, map[string]interface{}{
|
|
|
- "bid_sales_proportion": bid_sales_proportions,
|
|
|
- "continuous_use_judgment": continuous_use_judgments,
|
|
|
- })
|
|
|
- if oks {
|
|
|
- log.Println("修改客户成功", phone)
|
|
|
- } else {
|
|
|
- log.Println("修改客户失败!!!", phone)
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.Println("线索修改失败!!!", phone)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-func kcVisitSync() {
|
|
|
- filePath := "./222.xlsx"
|
|
|
- // SE := qu.SimpleEncrypt{Key: "topJYBX2019"}
|
|
|
- // log.Println(SE.DecodeString("QltHc2AmagsIUFwVV0dybyZpAwECX0YK"))
|
|
|
- // return
|
|
|
- xlFile, _ := xlsx.OpenFile(filePath)
|
|
|
- //获取行数
|
|
|
- // length := len(xlFile.Sheets[0].Rows)
|
|
|
- //开辟除表头外的行数的数组内存
|
|
|
- // resourceArr := make([]map[string]interface{}, length-1)
|
|
|
- //遍历sheet
|
|
|
- for k, sheet := range xlFile.Sheets {
|
|
|
- if k == 1 {
|
|
|
- //遍历每一行
|
|
|
- for rowIndex, row := range sheet.Rows {
|
|
|
- //跳过第一行表头信息
|
|
|
- if rowIndex == 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
- tasksource := row.Cells[1].Value
|
|
|
- tasksources := 1
|
|
|
- if tasksource == "客户情况盘点" {
|
|
|
- tasksources = 2
|
|
|
- } else if tasksource == "未培训" {
|
|
|
- tasksources = 3
|
|
|
- } else if tasksource == "日常沟通" {
|
|
|
- tasksources = 4
|
|
|
- } else if tasksource == "续约沟通" {
|
|
|
- tasksources = 5
|
|
|
- } else if tasksource == "月度回访" {
|
|
|
- tasksources = 6
|
|
|
- } else if tasksource == "培训首周回访" {
|
|
|
- tasksources = 7
|
|
|
- } else if tasksource == "建联" {
|
|
|
- tasksources = 1
|
|
|
- }
|
|
|
- phone := row.Cells[2].Value
|
|
|
- trail_way := row.Cells[3].Value
|
|
|
- trail_ways := 1
|
|
|
- if trail_way == "电话沟通" {
|
|
|
- trail_ways = 2
|
|
|
- } else if trail_way == "线下面访" {
|
|
|
- trail_ways = 3
|
|
|
- } else if trail_way == "腾讯会议" {
|
|
|
- trail_ways = 4
|
|
|
- }
|
|
|
- content := row.Cells[4].Value
|
|
|
- name := row.Cells[5].Value
|
|
|
- positionId := 0
|
|
|
- if name == "程涵" {
|
|
|
- positionId = 2202735
|
|
|
- } else if name == "张铭铭" {
|
|
|
- positionId = 2202736
|
|
|
- } else {
|
|
|
- positionId = -1
|
|
|
- }
|
|
|
- createtime := row.Cells[6].Value
|
|
|
- clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
|
- if clueData != nil {
|
|
|
- clueId := common.Int64All((*clueData)["id"])
|
|
|
- TiDb.Insert("dwd_f_crm_trail_content", map[string]interface{}{
|
|
|
- "clue_id": clueId,
|
|
|
- "position_id": positionId,
|
|
|
- "operator_id": -1,
|
|
|
- "content": content,
|
|
|
- "createtime": createtime,
|
|
|
- "tasksource": tasksources,
|
|
|
- "trail_way": trail_ways,
|
|
|
- })
|
|
|
- } else {
|
|
|
- row.AddCell().SetValue("没有线索")
|
|
|
- }
|
|
|
- }
|
|
|
- } else if k == 2 {
|
|
|
- //遍历每一行
|
|
|
- for rowIndex, row := range sheet.Rows {
|
|
|
- //跳过第一行表头信息
|
|
|
- if rowIndex == 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
- phone := row.Cells[2].Value
|
|
|
- contact_type := row.Cells[4].Value
|
|
|
- clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
|
- if clueData != nil {
|
|
|
- clueId := common.Int64All((*clueData)["id"])
|
|
|
- TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"contact_type": contact_type})
|
|
|
- } else {
|
|
|
- row.AddCell().SetValue("没有线索")
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- err := xlFile.Save("./333.xlsx")
|
|
|
- if err != nil {
|
|
|
- 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
|
|
|
+ saleId, cluename, company_nature, company_verification, uid := 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", "")
|
|
|
+ clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, "company_nature,company_verification,cluename,userid,position_id,uid", "")
|
|
|
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"])
|
|
|
+ uid = common.ObjToString((*clueData)["uid"])
|
|
|
}
|
|
|
- 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)
|
|
|
+ query1 := fmt.Sprintf(`select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > "%s" and order_status = 1 and pay_money > 0 and uid = "%s"`, nowTime, uid)
|
|
|
+ query2 := fmt.Sprintf(`select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and refund_status in (0,2) and order_status = 1 and pay_money > 0 and uid = "%s"`, uid)
|
|
|
+ log.Println("query1 ", query1)
|
|
|
+ log.Println("query2 ", query2)
|
|
|
+ order2 := TiDb.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{}{
|
|
@@ -1358,9 +662,132 @@ func refundAuto() {
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_csm_customer_info SET is_transfer=1 WHERE clue_id = ?`, clueId)
|
|
|
+ } else {
|
|
|
+ order1 := TiDb.SelectBySql(query1)
|
|
|
+ if order1 == nil || len(*order1) == 0 {
|
|
|
+ isOk := false
|
|
|
+ query3 := fmt.Sprintf(`select vip_endtime from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < "%s" and order_status = 1 and pay_money > 0 and uid = "%s"`, nowTime, uid)
|
|
|
+ log.Println("query3 ", query3)
|
|
|
+ order3 := TiDb.SelectBySql(query3)
|
|
|
+ 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() < 3*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)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
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("自动移交销售定时任务结束")
|
|
|
}
|
|
|
+
|
|
|
+func refundAutoHistory() {
|
|
|
+ data := TiDb.Find("dwd_f_crm_clue_autodraw_record", nil, "", "", -1, -1)
|
|
|
+ if data != nil {
|
|
|
+ for _, v := range *data {
|
|
|
+ seatNumber := common.ObjToString(v["seatNumber"])
|
|
|
+ adata := TiDb.Find("dwd_f_crm_personnel_management", map[string]interface{}{"seat_number": seatNumber}, "", "", -1, -1)
|
|
|
+ if adata != nil {
|
|
|
+ for _, vv := range *adata {
|
|
|
+ if common.IntAll(vv["resign"]) == 0 {
|
|
|
+ position_id := common.Int64All(vv["position_id"])
|
|
|
+ TiDb.Update("dwd_f_crm_clue_autodraw_record", map[string]interface{}{"seatNumber": seatNumber}, map[string]interface{}{"position_id": position_id})
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|