|
@@ -5,8 +5,10 @@ import (
|
|
|
"regexp"
|
|
|
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
"github.com/tealeg/xlsx"
|
|
|
)
|
|
|
|
|
@@ -86,3 +88,214 @@ func getSale(name, phone string) (positionId, clueId int64) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func getXlsx() {
|
|
|
+ filePath := "./code1.xlsx"
|
|
|
+ nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
|
+ xlFile, _ := xlsx.OpenFile(filePath)
|
|
|
+ //获取行数
|
|
|
+ // length := len(xlFile.Sheets[0].Rows)
|
|
|
+ //开辟除表头外的行数的数组内存
|
|
|
+ // resourceArr := make([]map[string]interface{}, length-1)
|
|
|
+ //遍历sheet
|
|
|
+ for _, sheet := range xlFile.Sheets {
|
|
|
+ //遍历每一行
|
|
|
+ for rowIndex, row := range sheet.Rows {
|
|
|
+ //跳过第一行表头信息
|
|
|
+ if rowIndex == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ company := row.Cells[1].Value
|
|
|
+ name := row.Cells[2].Value
|
|
|
+ position := row.Cells[3].Value
|
|
|
+ phone := row.Cells[4].Value
|
|
|
+ if phone != "" {
|
|
|
+ data := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ isAssign := common.IntAll((*data)["is_assign"])
|
|
|
+ clueId := common.Int64All((*data)["id"])
|
|
|
+ if isAssign == 1 {
|
|
|
+ //在私海
|
|
|
+ TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{
|
|
|
+ "is_assign": 1,
|
|
|
+ "comeintime": nowTime,
|
|
|
+ "updatetime": nowTime,
|
|
|
+ "top_cluetype": "377",
|
|
|
+ "sub_cluetype": "381",
|
|
|
+ })
|
|
|
+ TiDb.Update("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId}, map[string]interface{}{
|
|
|
+ "comeintime": nowTime,
|
|
|
+ "comeinsource": 2,
|
|
|
+ "is_task": 1,
|
|
|
+ "task_time": nowTime,
|
|
|
+ "tasktime": nowTime,
|
|
|
+ "taskstatus": 0,
|
|
|
+ "tasksource": "线索自动分配-批量导入-6月份获取拟建项目清单留资",
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ //在公海
|
|
|
+ positionId, seatNumber, _, _ := autoDraw("C")
|
|
|
+ TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{
|
|
|
+ "seatNumber": seatNumber,
|
|
|
+ "position_id": positionId,
|
|
|
+ "is_assign": 1,
|
|
|
+ "comeintime": nowTime,
|
|
|
+ "updatetime": nowTime,
|
|
|
+ "trailstatus": "01",
|
|
|
+ "top_cluetype": "377",
|
|
|
+ "sub_cluetype": "381",
|
|
|
+ })
|
|
|
+ TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
|
|
|
+ TiDb.Insert("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": nowTime,
|
|
|
+ "taskstatus": 0,
|
|
|
+ "tasksource": "线索自动分配-批量导入-6月份获取拟建项目清单留资",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //无线索
|
|
|
+ base := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"phone": phone}, "", "")
|
|
|
+ if base != nil && len(*base) > 0 {
|
|
|
+ uId := common.ObjToString((*base)["uid"])
|
|
|
+ userId := common.ObjToString((*base)["userid"])
|
|
|
+ positionId, seatNumber, _, _ := autoDraw("C")
|
|
|
+ clueId := TiDb.Insert("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": common.If(company != "", company, phone),
|
|
|
+ "top_cluetype": "377",
|
|
|
+ "sub_cluetype": "381",
|
|
|
+ "trailstatus": "01",
|
|
|
+ "name": name,
|
|
|
+ "phone": phone,
|
|
|
+ "position": position,
|
|
|
+ })
|
|
|
+ if clueId > -1 {
|
|
|
+ TiDb.Insert("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": "2023-06-12 10:00:00",
|
|
|
+ "taskstatus": 0,
|
|
|
+ "tasksource": "线索自动分配-批量导入-6月份获取拟建项目清单留资",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func getXlsx2() {
|
|
|
+ filePath := "./code2.xlsx"
|
|
|
+ nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
|
+ xlFile, _ := xlsx.OpenFile(filePath)
|
|
|
+ //获取行数
|
|
|
+ // length := len(xlFile.Sheets[0].Rows)
|
|
|
+ //开辟除表头外的行数的数组内存
|
|
|
+ // resourceArr := make([]map[string]interface{}, length-1)
|
|
|
+ //遍历sheet
|
|
|
+ for _, sheet := range xlFile.Sheets {
|
|
|
+ //遍历每一行
|
|
|
+ for rowIndex, row := range sheet.Rows {
|
|
|
+ //跳过第一行表头信息
|
|
|
+ if rowIndex == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ userId := row.Cells[0].Value
|
|
|
+ company := row.Cells[5].Value
|
|
|
+ name := row.Cells[1].Value
|
|
|
+ position := row.Cells[6].Value
|
|
|
+ phone := row.Cells[7].Value
|
|
|
+ positionId, seatNumber := int64(2047781), "8040"
|
|
|
+ if phone != "" {
|
|
|
+ data := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"userid": userId}, "", "")
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ isAssign := common.IntAll((*data)["is_assign"])
|
|
|
+ clueId := common.Int64All((*data)["id"])
|
|
|
+ if isAssign != 1 {
|
|
|
+ //不在私海
|
|
|
+ TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{
|
|
|
+ "seatNumber": seatNumber,
|
|
|
+ "position_id": positionId,
|
|
|
+ "is_assign": 1,
|
|
|
+ "comeintime": nowTime,
|
|
|
+ "updatetime": nowTime,
|
|
|
+ "trailstatus": "01",
|
|
|
+ "top_cluetype": "377",
|
|
|
+ "sub_cluetype": "382",
|
|
|
+ })
|
|
|
+ TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
|
|
|
+ TiDb.Insert("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": nowTime,
|
|
|
+ "taskstatus": 0,
|
|
|
+ "tasksource": "线索自动分配-批量导入-医械厂商线索",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //无线索
|
|
|
+ base := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"userid": userId}, "", "")
|
|
|
+ if base != nil && len(*base) > 0 {
|
|
|
+ uId := common.ObjToString((*base)["uid"])
|
|
|
+ clueId := TiDb.Insert("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": common.If(company != "", company, phone),
|
|
|
+ "top_cluetype": "377",
|
|
|
+ "sub_cluetype": "382",
|
|
|
+ "trailstatus": "01",
|
|
|
+ "name": name,
|
|
|
+ "phone": phone,
|
|
|
+ "position": position,
|
|
|
+ })
|
|
|
+ if clueId > -1 {
|
|
|
+ TiDb.Insert("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": "2023-06-12 10:00:00",
|
|
|
+ "taskstatus": 0,
|
|
|
+ "tasksource": "线索自动分配-批量导入-医械厂商线索",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|