|
@@ -76,7 +76,7 @@ func WorkDataHandle(company, phone, demand, name, product string, acceptanceData
|
|
if cluename == "" {
|
|
if cluename == "" {
|
|
cluename = phone //没有线索名,手机号代替
|
|
cluename = phone //没有线索名,手机号代替
|
|
}
|
|
}
|
|
- ok, data, saleData := false, map[string]interface{}{}, []map[string]interface{}{}
|
|
|
|
|
|
+ ok, data, saleData, isNewScore := false, map[string]interface{}{}, []map[string]interface{}{}, false
|
|
isGroup, isCommerce := GetCompanyType(cluename, uId)
|
|
isGroup, isCommerce := GetCompanyType(cluename, uId)
|
|
uCount, _ := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true //查当前线索是否已存在
|
|
uCount, _ := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true //查当前线索是否已存在
|
|
if uCount != nil && len(*uCount) > 0 {
|
|
if uCount != nil && len(*uCount) > 0 {
|
|
@@ -119,6 +119,7 @@ func WorkDataHandle(company, phone, demand, name, product string, acceptanceData
|
|
} else {
|
|
} else {
|
|
if positionId == 0 {
|
|
if positionId == 0 {
|
|
//线索变更
|
|
//线索变更
|
|
|
|
+ isNewScore = true
|
|
ok, data, saleData = FindPosition(0, "", gconv.String(acceptanceData["creator_time"]))
|
|
ok, data, saleData = FindPosition(0, "", gconv.String(acceptanceData["creator_time"]))
|
|
if !ok {
|
|
if !ok {
|
|
log.Println(positionId, "用户查询失败")
|
|
log.Println(positionId, "用户查询失败")
|
|
@@ -145,14 +146,15 @@ func WorkDataHandle(company, phone, demand, name, product string, acceptanceData
|
|
if !ok {
|
|
if !ok {
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
+ isNewScore = true
|
|
SaveClue("", "", uId, "5", "169", "新增线索", "主动咨询客服留资客户", cluename, name, gconv.String(data["name"]), phone, "", "", "", "", "", "", gconv.String(data["seat_number"]), gconv.Int64(data["position_id"]), "", "", "", []string{}, "", isGroup, isCommerce, false, demand)
|
|
SaveClue("", "", uId, "5", "169", "新增线索", "主动咨询客服留资客户", cluename, name, gconv.String(data["name"]), phone, "", "", "", "", "", "", gconv.String(data["seat_number"]), gconv.Int64(data["position_id"]), "", "", "", []string{}, "", isGroup, isCommerce, false, demand)
|
|
}
|
|
}
|
|
//工单生成
|
|
//工单生成
|
|
- ok1 := AddOrderWork(acceptanceData, data, product, phone, company)
|
|
|
|
|
|
+ ok1 := AddOrderWork(acceptanceData, data, product, phone, company, isNewScore)
|
|
log.Println("工单创建", ok1, gconv.String(acceptanceData["acceptance_no"]))
|
|
log.Println("工单创建", ok1, gconv.String(acceptanceData["acceptance_no"]))
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
-func AddOrderWork(acceptanceData map[string]interface{}, userData map[string]interface{}, product, phone, company string) bool {
|
|
|
|
|
|
+func AddOrderWork(acceptanceData map[string]interface{}, userData map[string]interface{}, product, phone, company string, isNewScore bool) bool {
|
|
nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
work_order_no := fmt.Sprintf("GD%s%s", time.Now().Format(date.Date_yyyyMMdd), FindNumber("gd"))
|
|
work_order_no := fmt.Sprintf("GD%s%s", time.Now().Format(date.Date_yyyyMMdd), FindNumber("gd"))
|
|
productArr := []string{}
|
|
productArr := []string{}
|
|
@@ -227,6 +229,19 @@ func AddOrderWork(acceptanceData map[string]interface{}, userData map[string]int
|
|
"update_time": common.If(gconv.Int64(userData["orderStatus"]) == 0, nowTime, nil),
|
|
"update_time": common.If(gconv.Int64(userData["orderStatus"]) == 0, nowTime, nil),
|
|
}
|
|
}
|
|
WorkOrder.Insert("approval_record", approvalRecordMap)
|
|
WorkOrder.Insert("approval_record", approvalRecordMap)
|
|
|
|
+ //工单分配记录添加
|
|
|
|
+ if isNewScore {
|
|
|
|
+ orderWorkAllocationRecord := map[string]interface{}{
|
|
|
|
+ "person_name": userData["name"],
|
|
|
|
+ "position_id": userData["position_id"],
|
|
|
|
+ "dept_name": userData["deptName"],
|
|
|
|
+ "dept_id": userData["deptId"],
|
|
|
|
+ "work_order_no": work_order_no,
|
|
|
|
+ "create_time": nowTime,
|
|
|
|
+ "company_dept_numb": common.If(gconv.String(userData["deptName"]) == "销售三部", 3, 1),
|
|
|
|
+ }
|
|
|
|
+ WorkOrder.Insert("order_work_allocation_record", orderWorkAllocationRecord)
|
|
|
|
+ }
|
|
WorkMail(personMap,
|
|
WorkMail(personMap,
|
|
strings.Join(productArr, ","),
|
|
strings.Join(productArr, ","),
|
|
gconv.Int64(common.If(gconv.Int64(userData["orderStatus"]) == 0, 2, 1)),
|
|
gconv.Int64(common.If(gconv.Int64(userData["orderStatus"]) == 0, 2, 1)),
|
|
@@ -322,7 +337,7 @@ func FindNumber(moudle string) string {
|
|
|
|
|
|
// 人员查询
|
|
// 人员查询
|
|
func GetAllocation(proportion1, proportion3 float64, deptCount1, deptCount3 int64, administrators1, administrators3 map[string]interface{}, creatorTime string) map[string]interface{} {
|
|
func GetAllocation(proportion1, proportion3 float64, deptCount1, deptCount3 int64, administrators1, administrators3 map[string]interface{}, creatorTime string) map[string]interface{} {
|
|
- log.Println("分配比例查询", proportion1, proportion3, deptCount1, deptCount3)
|
|
|
|
|
|
+ log.Println("分配比例查询", cfg.AllocationTime, cfg.AllocationRatio, proportion1, proportion3, deptCount1, deptCount3)
|
|
if deptCount1 == 0 {
|
|
if deptCount1 == 0 {
|
|
return administrators1
|
|
return administrators1
|
|
}
|
|
}
|
|
@@ -456,37 +471,19 @@ FROM
|
|
}
|
|
}
|
|
//按照比例分配选择一部还是三部
|
|
//按照比例分配选择一部还是三部
|
|
//一部查询
|
|
//一部查询
|
|
- deptCount1 := CalculateProportion(deptNameMap1)
|
|
|
|
|
|
+ deptCount1 := CalculateProportion(1)
|
|
//三部查询
|
|
//三部查询
|
|
- deptCount3 := CalculateProportion(deptNameMap3)
|
|
|
|
|
|
+ deptCount3 := CalculateProportion(3)
|
|
return true, GetAllocation(proportion1, proportion3, deptCount1, deptCount3, administrators1, administrators3, creatorTime), allData
|
|
return true, GetAllocation(proportion1, proportion3, deptCount1, deptCount3, administrators1, administrators3, creatorTime), allData
|
|
- log.Println("电销信息获取失败", positionId)
|
|
|
|
- return false, map[string]interface{}{}, allData
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-func CalculateProportion(deptNameMap map[string]interface{}) int64 {
|
|
|
|
- deptNameStr := ""
|
|
|
|
- for k := range deptNameMap {
|
|
|
|
- if deptNameStr == "" {
|
|
|
|
- deptNameStr = k
|
|
|
|
- } else {
|
|
|
|
- deptNameStr = fmt.Sprintf("%s,%s", deptNameStr, k)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if deptNameStr == "" {
|
|
|
|
- return int64(0)
|
|
|
|
- }
|
|
|
|
- count := int64(0)
|
|
|
|
- sql := fmt.Sprintf(`SELECT
|
|
|
|
|
|
+func CalculateProportion(deptNumb int64) int64 {
|
|
|
|
+ data := WorkOrder.SelectBySql(`SELECT
|
|
sum(1) as count
|
|
sum(1) as count
|
|
FROM
|
|
FROM
|
|
- order_work a
|
|
|
|
- INNER JOIN approval_record b ON a.creator_time >= "%s"
|
|
|
|
- AND FIND_IN_SET( a.department_no , "%s")
|
|
|
|
- AND a.work_order_no = b.work_order_no
|
|
|
|
- and (b.new_status!= 1 or b.new_status is null )
|
|
|
|
- `, cfg.AllocationTime, deptNameStr)
|
|
|
|
- data := WorkOrder.SelectBySql(sql)
|
|
|
|
|
|
+ order_work_allocation_record where create_time >? and company_dept_numb=? )
|
|
|
|
+ `, cfg.AllocationTime, deptNumb)
|
|
|
|
+ count := int64(0)
|
|
if data != nil && len(*data) > 0 {
|
|
if data != nil && len(*data) > 0 {
|
|
count = gconv.Int64((*data)[0]["count"])
|
|
count = gconv.Int64((*data)[0]["count"])
|
|
}
|
|
}
|