|
@@ -4,6 +4,7 @@ import (
|
|
"database/sql"
|
|
"database/sql"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "github.com/gogf/gf/v2/util/gconv"
|
|
"log"
|
|
"log"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
@@ -425,12 +426,14 @@ func ordersClue() {
|
|
if order_status == 1 && is_backstage_order == 1 && salesperson != "" && !strings.HasPrefix(user_phone, "9") && strings.Contains(product_type_str2, product_type) {
|
|
if order_status == 1 && is_backstage_order == 1 && salesperson != "" && !strings.HasPrefix(user_phone, "9") && strings.Contains(product_type_str2, product_type) {
|
|
//销售部
|
|
//销售部
|
|
query := map[string]interface{}{}
|
|
query := map[string]interface{}{}
|
|
|
|
+ source := ""
|
|
if product_type == "企业商机管理" {
|
|
if product_type == "企业商机管理" {
|
|
query["phone"] = user_phone
|
|
query["phone"] = user_phone
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
uId = common.ObjToString((*userInfo)["uid"])
|
|
uId = common.ObjToString((*userInfo)["uid"])
|
|
userId = common.ObjToString((*userInfo)["userid"])
|
|
userId = common.ObjToString((*userInfo)["userid"])
|
|
|
|
+ source = common.ObjToString((*userInfo)["source"])
|
|
} else {
|
|
} else {
|
|
log.Println("后台订单--未查询到 ", user_phone)
|
|
log.Println("后台订单--未查询到 ", user_phone)
|
|
break
|
|
break
|
|
@@ -449,6 +452,7 @@ func ordersClue() {
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
uId = common.ObjToString((*userInfo)["uid"])
|
|
uId = common.ObjToString((*userInfo)["uid"])
|
|
|
|
+ source = common.ObjToString((*userInfo)["source"])
|
|
} else {
|
|
} else {
|
|
log.Println("后台订单--未查询到 ", query, user_phone)
|
|
log.Println("后台订单--未查询到 ", query, user_phone)
|
|
break
|
|
break
|
|
@@ -534,12 +538,17 @@ func ordersClue() {
|
|
seatNumber = common.ObjToString((*saleData)["seat_number"])
|
|
seatNumber = common.ObjToString((*saleData)["seat_number"])
|
|
positionId = common.Int64All((*saleData)["position_id"])
|
|
positionId = common.Int64All((*saleData)["position_id"])
|
|
}
|
|
}
|
|
|
|
+ is_assign := 1
|
|
|
|
+ if IsFreeze(source, pay_money, gconv.String(positionId)) && (isGroup != 1 && isCommerce == 1) {
|
|
|
|
+ //线索需要冻结
|
|
|
|
+ is_assign = -3
|
|
|
|
+ }
|
|
clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
|
|
clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
|
|
"userid": userId,
|
|
"userid": userId,
|
|
"uid": uId,
|
|
"uid": uId,
|
|
"seatNumber": seatNumber,
|
|
"seatNumber": seatNumber,
|
|
"position_id": positionId,
|
|
"position_id": positionId,
|
|
- "is_assign": 1,
|
|
|
|
|
|
+ "is_assign": is_assign,
|
|
"comeintime": nowTime,
|
|
"comeintime": nowTime,
|
|
"createtime": nowTime,
|
|
"createtime": nowTime,
|
|
"updatetime": nowTime,
|
|
"updatetime": nowTime,
|
|
@@ -554,6 +563,7 @@ func ordersClue() {
|
|
"taskstatus": 0,
|
|
"taskstatus": 0,
|
|
"company_nature": isGroup,
|
|
"company_nature": isGroup,
|
|
"company_verification": isCommerce,
|
|
"company_verification": isCommerce,
|
|
|
|
+ "FREEZE_TIME": common.If(is_assign == -3, nowTime, ""),
|
|
})
|
|
})
|
|
} else if strings.HasPrefix(saleDep, "03") {
|
|
} else if strings.HasPrefix(saleDep, "03") {
|
|
log.Println("市场部订单", saleDep)
|
|
log.Println("市场部订单", saleDep)
|
|
@@ -585,6 +595,28 @@ func ordersClue() {
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
|
|
+ if strings.HasPrefix(saleDep, "01") || strings.HasPrefix(saleDep, "05") {
|
|
|
|
+ if IsFreeze(source, pay_money, gconv.String(positionId)) && (isGroup != 1 && isCommerce == 1) {
|
|
|
|
+ //新增冻结记录
|
|
|
|
+ TiDb.Insert("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,
|
|
|
|
+ })
|
|
|
|
+ //移交失败发送消息
|
|
|
|
+ if IsFreeze(source, pay_money, gconv.String(positionId)) {
|
|
|
|
+ //发送邮件信息
|
|
|
|
+ }
|
|
|
|
+ if isGroup != 1 && isCommerce == 1 {
|
|
|
|
+ //发送邮件信息
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -613,6 +645,7 @@ func refundAuto() {
|
|
company_verification = common.IntAll((*clueData)["company_verification"])
|
|
company_verification = common.IntAll((*clueData)["company_verification"])
|
|
uid = common.ObjToString((*clueData)["uid"])
|
|
uid = common.ObjToString((*clueData)["uid"])
|
|
}
|
|
}
|
|
|
|
+ isFull := FindUpperLimit(gconv.String(saleId), "positionId")
|
|
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)
|
|
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)
|
|
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("query1 ", query1)
|
|
@@ -685,7 +718,11 @@ func refundAuto() {
|
|
if saleId > 0 {
|
|
if saleId > 0 {
|
|
saleData := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"position_id": saleId, "resign": 0}, "", "")
|
|
saleData := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"position_id": saleId, "resign": 0}, "", "")
|
|
if saleData != nil && len(*saleData) > 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)
|
|
|
|
|
|
+ if FindUpperLimit(gconv.String(saleId), "positionId") {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET updatetime=?,trailstatus="01",is_task=0,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0 WHERE id = ?,is_assign=-2,FREEZE_TIME=?`, nowTime, nowTime, clueId, nowTime)
|
|
|
|
+ } else {
|
|
|
|
+ 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 {
|
|
} else {
|
|
if company_nature == 0 && company_verification == 1 && cluename != "" {
|
|
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)
|
|
adata := TiDb.Find("dwd_f_crm_clue_info", map[string]interface{}{"cluename": cluename, "is_assign": 1}, "seatNumber,position_id", "", -1, -1)
|
|
@@ -697,7 +734,11 @@ func refundAuto() {
|
|
saleDatas := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"position_id": position_ids, "resign": 0}, "", "")
|
|
saleDatas := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"position_id": position_ids, "resign": 0}, "", "")
|
|
if saleDatas != nil && len(*saleDatas) > 0 {
|
|
if saleDatas != nil && len(*saleDatas) > 0 {
|
|
saleId = position_ids
|
|
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)
|
|
|
|
|
|
+ if isFull {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=0,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0,is_assign=-2,FREEZE_TIME=? WHERE id = ?`, nowTime, saleId, seatNumber, nowTime, clueId, seatNumber)
|
|
|
|
+ } else {
|
|
|
|
+ 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
|
|
isOks = true
|
|
break
|
|
break
|
|
}
|
|
}
|
|
@@ -707,7 +748,11 @@ func refundAuto() {
|
|
if sdata != nil && len(*sdata) > 0 {
|
|
if sdata != nil && len(*sdata) > 0 {
|
|
saleId = common.Int64All((*sdata)[0]["position_id"])
|
|
saleId = common.Int64All((*sdata)[0]["position_id"])
|
|
seatNumber := common.ObjToString((*sdata)[0]["seat_number"])
|
|
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)
|
|
|
|
|
|
+ if isFull {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=0,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0,is_assign=-2,FREEZE_TIME=? WHERE id = ?`, nowTime, saleId, seatNumber, nowTime, clueId, seatNumber)
|
|
|
|
+ } else {
|
|
|
|
+ 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)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -716,13 +761,19 @@ func refundAuto() {
|
|
if sdata != nil && len(*sdata) > 0 {
|
|
if sdata != nil && len(*sdata) > 0 {
|
|
saleId = common.Int64All((*sdata)[0]["position_id"])
|
|
saleId = common.Int64All((*sdata)[0]["position_id"])
|
|
seatNumber := common.ObjToString((*sdata)[0]["seat_number"])
|
|
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)
|
|
|
|
|
|
+ if isFull {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=0,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0,is_assign=-2,FREEZE_TIME=? WHERE id = ?`, nowTime, saleId, seatNumber, nowTime, clueId, seatNumber)
|
|
|
|
+ } else {
|
|
|
|
+ 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 {
|
|
} 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.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{}{
|
|
TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
"position_id": common.If(kcposition_id > 0, kcposition_id, -1),
|
|
"position_id": common.If(kcposition_id > 0, kcposition_id, -1),
|
|
@@ -764,6 +815,19 @@ func refundAuto() {
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_csm_customer_info SET is_transfer=1 WHERE clue_id = ?`, clueId)
|
|
TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_csm_customer_info SET is_transfer=1 WHERE clue_id = ?`, clueId)
|
|
|
|
+ if isFull {
|
|
|
|
+ //新增冻结记录
|
|
|
|
+ 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)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -791,3 +855,10 @@ func refundAutoHistory() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+func IsFreeze(source string, pay_money int, positionId string) bool {
|
|
|
|
+ if source == "0104" && pay_money == 0 && FindUpperLimit(gconv.String(
|
|
|
|
+ positionId), "positionId") {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+}
|