Browse Source

工单生成提交

WH01243 1 year ago
parent
commit
3bf0e5face
5 changed files with 196 additions and 13 deletions
  1. 10 0
      clueSync/config.go
  2. 12 2
      clueSync/config.json
  3. 138 0
      clueSync/jobutil.go
  4. 22 6
      clueSync/kc.go
  5. 14 5
      clueSync/main.go

+ 10 - 0
clueSync/config.go

@@ -62,6 +62,16 @@ type (
 			MaxIdle     int    `json:"maxidle"`
 			MaxLeftTime int    `json:"maxleft"`
 		} `json:"tiDbPower"`
+		WorderOrder struct {
+			Host        string `json:"host"`
+			Port        int    `json:"port"`
+			Database    string `json:"database"`
+			User        string `json:"user"`
+			Password    string `json:"password"`
+			PollSize    int    `json:"poolsize"`
+			MaxIdle     int    `json:"maxidle"`
+			MaxLeftTime int    `json:"maxleft"`
+		} `json:"workOrder"`
 		BaseService struct {
 			Host        string `json:"host"`
 			Port        int    `json:"port"`

+ 12 - 2
clueSync/config.json

@@ -9,7 +9,7 @@
   "corn_mail": "",
   "lastOrderId": 258784,
   "lastOrderClueId": "2024-05-11 11:12:47",
-  "lastUserId": "644101e58b6d74a60a09aec7",
+  "lastUserId": "2024-05-20 15:40:02",
   "lastId": "664561454b25604f30f5a6df",
   "lastOrderTime": "2023-04-25 00:00:00",
   "lastUserTime": "2023-04-25 00:00:00",
@@ -63,6 +63,16 @@
     "maxidle": 40,
     "maxleft": 40
   },
+  "workOrder": {
+    "host": "192.168.3.14",
+    "port": 4000,
+    "database": "work_order",
+    "user": "root",
+    "password": "=PDT49#80Z!RVv52_z",
+    "poolsize": 20,
+    "maxidle": 40,
+    "maxleft": 40
+  },
   "thirdParty": {
     "host": "192.168.3.14",
     "port": 4000,
@@ -119,7 +129,7 @@
     "UserName": "",
     "password": ""
   },
-  "allocationCap": 5,
+  "allocationCap": 400,
   "warningValue": 350,
   "nameToMail": null,
   "thawDay": 3

+ 138 - 0
clueSync/jobutil.go

@@ -13,6 +13,144 @@ import (
 	"app.yhyue.com/moapp/jybase/mongodb"
 )
 
+/*// 电销工单生成
+func rderAcceptance() {
+	sql := fmt.Sprintf(`select * from order_acceptance where is_clue=2 order by propose_time  `)
+	data := Mysql.SelectBySql(sql)
+	if data != nil && len(*data) > 0 {
+		for _, v := range *data {
+			acceptance_no := gconv.String(v["acceptance_no"])
+			childrenArr := WorkOrder.Find("order_acceptance_children", map[string]interface{}{
+				"acceptance_no": acceptance_no,
+			}, "", "", -1, -1)
+			if childrenArr != nil && len(*childrenArr) > 0 {
+				company := ""
+				phone := ""
+				demand := ""
+				for _, v1 := range *childrenArr {
+					if gconv.String(v1["file_name"]) == "公司名称" {
+						company = gconv.String(v1["file_value"])
+					}
+					if gconv.String(v1["file_name"]) == "联系方式" {
+						phone = gconv.String(v1["file_value"])
+					}
+					if gconv.String(v1["file_name"]) == "客户需求" {
+						demand = gconv.String(v1["file_value"])
+					}
+				}
+				WorkDataHandle(company, phone, demand)
+			}
+		}
+	}
+}*/
+/*func WorkDataHandle(company, phone, demand string) bool {
+	positionId, seatNumber, saleNam := AutoDrawPerson(company, phone, demand)
+	uId := ""
+	query := map[string]interface{}{}
+	contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
+	if contactsData != nil && len(*contactsData) > 0 {
+		if common.ObjToString((*contactsData)[0]["baseinfo_id"]) != "" {
+			uId = common.ObjToString((*contactsData)[0]["baseinfo_id"])
+			query["uid"] = uId
+		}
+	}
+	if uId == "" {
+		return false
+	}
+	uCount, _ := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true //查当前线索是否已存在
+	if uCount != nil && len(*uCount) > 0 {
+		positionId := gconv.Int64((*uCount)["position_id"])
+		if positionId == 0 {
+			//线索变更
+		} else {
+			trailstatusl := gconv.String((*uCount)["trailstatusl"])
+			if trailstatusl == "" {
+				//变更销售员
+			} else {
+				//线索变更
+			}
+		}
+	} else {
+		//新增线索
+
+	}
+	return true
+}
+func FindPosition(positionId int64) int64 {
+	//查询两个部门高级管理员
+	//查询两个部门所有人员标识
+	//电销三部
+	userData1 := TiDb.SelectBySql(`SELECT
+	a.position_id,
+	a.name,
+	b.seat_number
+FROM
+	dwd_d_crm_department_level_succbi a
+	INNER JOIN dwd_f_crm_personnel_management b ON a.resign = 0
+	AND a.ent_id = 25917
+	AND a.resign = 0
+	AND a.dept_name LIKE "%销售一部/电销部%"
+	AND a.position_id = b.position_id`)
+	userData3 := TiDb.SelectBySql(`SELECT
+	a.position_id,
+	a.name,
+	b.seat_number
+FROM
+	dwd_d_crm_department_level_succbi a
+	INNER JOIN dwd_f_crm_personnel_management b ON a.resign = 0
+	AND a.ent_id = 25917
+	AND a.resign = 0
+	AND a.dept_name LIKE "%销售三部"
+	AND a.position_id = b.position_id`)
+	if userData3 == nil || len(*userData3) == 0 || userData1 == nil || len(*userData1) == 0 {
+		return 0
+	}
+	administrators1 := map[string]interface{}{}
+	administrators3 := map[string]interface{}{}
+	administrators := map[string]interface{}{}
+	//电销一部
+	positionIdArr1 := []int64{}
+	positionIdArr3 := []int64{}
+	for _, v := range *userData3 {
+		v["type"] = 3
+		personName := gconv.String(v["name"])
+		id := gconv.Int64(v["position_id"])
+		if personName == "孙鹏" {
+			administrators3 = v
+			administrators = v
+		}
+		if id == positionId {
+			administrators = v
+		}
+		positionIdArr3 = append(positionIdArr3, id)
+	}
+	for _, v := range *userData1 {
+		v["type"] = 1
+		personName := gconv.String(v["name"])
+		id := gconv.Int64(v["position_id"])
+		if personName == "沈炳毅" {
+			administrators1 = v
+
+		}
+
+		positionIdArr1 = append(positionIdArr1, id)
+	}
+	if positionId != 0 {
+		positiontype := gconv.Int64(administrators["type"])
+		isBool := false
+		if FindUpperLimit(gconv.String(positionId), "", false) {
+			if positiontype == 1 {
+				administrators1
+			} else {
+				administrators1
+			}
+		} else {
+
+		}
+	}
+
+}
+*/
 // 未支付订单 30分钟一次
 func orders() {
 	//一个小时未支付进入线索 A

+ 22 - 6
clueSync/kc.go

@@ -19,7 +19,22 @@ import (
 
 func kcSync() {
 	log.Println("客户成功系统移交定时任务开始")
-	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`
+	//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`
+	sql := `SELECT
+	* 
+FROM
+	dwd_f_userbase_order_info 
+WHERE
+	uid in ("4b534cf8e67811ed972200163e3214c2","1928dfe0e69611ed972200163e3214c2","9949f6384e5511eebd3a00163e3214c2","9912accee69411ed972200163e3214c2","98de316406b011efbb0e00163e3214c2","d35a5734e69811ed972200163e3214c2","274e8eaae67b11ed972200163e3214c2","937f16bce69411ed972200163e3214c2","8cd465fac48e11eeb38300163e3214c2","a83cb826e68411ed972200163e3214c2","ed9f9ebce69111ed972200163e3214c2","b27abc84e69311ed972200163e3214c2","7e40357ce67d11ed972200163e3214c2","14e1a9d6e68b11ed972200163e3214c2","7ce2192ee69211ed972200163e3214c2","741f3ff2e68711ed972200163e3214c2","b54b3148e69111ed972200163e3214c2","6bd34a0e098811eeb04a00163e3214c2","62c887f0e69a11ed972200163e3214c2","47f24806e67911ed972200163e3214c2","b9929da2e69311ed972200163e3214c2","421a0dace69611ed972200163e3214c2","c9300b46e67011ed972200163e3214c2","0b01efc8e69711ed972200163e3214c2","c796378e05d111efaee600163e3214c2","47fe4f58e69611ed972200163e3214c2","5867d45a3d9811ee829800163e3214c2","c484486ce69a11ed972200163e3214c2","018261e2e67611ed972200163e3214c2","bace9eb8e69911ed972200163e3214c2","c292fc6ce67511ed972200163e3214c2","092c4d12e69011ed972200163e3214c2","49f7912ee67411ed972200163e3214c2","cbe2589ce68111ed972200163e3214c2")
+	AND pay_money > 0 
+	AND vip_endtime > now() 
+	AND product_type IN ( "大会员", "企业商机管理" ) 
+	AND order_status = 1 
+	AND data_spec != "dhy4" 
+	AND refund_status != 1 
+	AND vip_starttime != "2099-01-01 00:00:00"
+
+`
 	data := TiDb.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		for _, v := range *data {
@@ -29,15 +44,16 @@ func kcSync() {
 			order_status := common.IntAll(v["order_status"])
 			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)
-				if status == 0 {
+				kcJob(v)
+				//status := kcJob(v)
+				/*if status == 0 {
 					break
-				}
+				}*/
 			}
-			cfg.LastkcTime = common.ObjToString(v["autoUpdate"])
+			//cfg.LastkcTime = common.ObjToString(v["autoUpdate"])
 		}
 	}
-	common.WriteSysConfig(&cfg)
+	//common.WriteSysConfig(&cfg)
 	log.Println("客户成功系统移交定时任务结束")
 }
 

+ 14 - 5
clueSync/main.go

@@ -20,6 +20,7 @@ var (
 	TiDb         *mysql.Mysql
 	TiDbData     *mysql.Mysql
 	TiDbPower    *mysql.Mysql
+	WorkOrder    *mysql.Mysql
 	ThirdParty   *mysql.Mysql
 	Jyactivities *mysql.Mysql
 	Base         *mysql.Mysql
@@ -79,6 +80,15 @@ func main() {
 		MaxIdleConns: cfg.Jyactivities.MaxIdle,
 	}
 	Jyactivities.Init()
+	WorkOrder = &mysql.Mysql{
+		Address:      cfg.WorderOrder.Host + ":" + fmt.Sprint(cfg.WorderOrder.Port),
+		UserName:     cfg.WorderOrder.User,
+		PassWord:     cfg.WorderOrder.Password,
+		DBName:       cfg.WorderOrder.Database,
+		MaxOpenConns: cfg.WorderOrder.PollSize,
+		MaxIdleConns: cfg.WorderOrder.MaxIdle,
+	}
+	WorkOrder.Init()
 	Mysql = &mysql.Mysql{
 		Address:      cfg.Mysql.Host + ":" + fmt.Sprint(cfg.Mysql.Port),
 		UserName:     cfg.Mysql.User,
@@ -103,10 +113,7 @@ func main() {
 	MgoLog = mongodb.NewMgoWithUser(cfg.MgoLog.Address, cfg.MgoLog.DbName, cfg.MgoLog.User, cfg.MgoLog.Password, cfg.MgoLog.DbSize)
 	MgoQyxy = mongodb.NewMgoWithUser(cfg.MgoQyxy.Address, cfg.MgoQyxy.DbName, cfg.MgoQyxy.User, cfg.MgoQyxy.Password, cfg.MgoQyxy.DbSize)
 	InitArea()
-
-	go kcSync()     //移交客成
-	go refundAuto() //客成移交销售
-	go UpperLimitAutoExitSea(cfg.AllocationCap)
+	//kcSync() //移交客成
 	if *mode == 1 {
 		//30分钟一次
 		a := cron.New()
@@ -186,6 +193,8 @@ func main() {
 		h.Start()
 		select {}
 	} else {
-		refundAutoHistory()
+		//refundAutoHistory()
+		users()
+		saleLeads()
 	}
 }