|
@@ -29,7 +29,7 @@ var (
|
|
|
func kcSync() {
|
|
|
log.Println("客户成功系统移交定时任务开始")
|
|
|
sql := `select * from dwd_f_userbase_order_info where (payable_money > 0 or (payable_money=0 and ( filter like "%分期付款补充权益%" or filter like "%原订单不支持开通多项权益%" or filter like "%权益码兑换%")))
|
|
|
- and data_spec!="dhy4" and order_status=1 and (refund_status!=1 or refund_status is null ) and vip_starttime<"2099-01-01"
|
|
|
+ and data_spec!="dhy4" and phone not like "9%" and order_status=1 and (refund_status!=1 or refund_status is null ) and vip_starttime<"2099-01-01"
|
|
|
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 order_code="173943424276" `
|
|
|
data := TiDb.SelectBySql(sql)
|
|
@@ -55,6 +55,7 @@ func kcSync() {
|
|
|
continue
|
|
|
}
|
|
|
status := kcJob(v)
|
|
|
+ log.Println("订单进客成打印", orderCode, status)
|
|
|
if status == 0 {
|
|
|
break
|
|
|
}
|
|
@@ -78,7 +79,8 @@ func kcJob(data map[string]interface{}) int {
|
|
|
log.Println(data["order_code"], saleDep, orderPositionId, salesperson)
|
|
|
if clueData == nil || len(*clueData) == 0 {
|
|
|
if saleDep == "销售部" || saleDep == "市场部" {
|
|
|
- return 1
|
|
|
+ log.Println("移交客成缺少基本信息", uId)
|
|
|
+ return 0
|
|
|
}
|
|
|
//创建线索
|
|
|
//原始订单获取
|
|
@@ -137,7 +139,7 @@ func kcJob(data map[string]interface{}) int {
|
|
|
return 0
|
|
|
}
|
|
|
} else {
|
|
|
- return 1
|
|
|
+ return 0
|
|
|
}
|
|
|
}
|
|
|
clueId = common.Int64All((*clueData)["id"])
|
|
@@ -627,7 +629,7 @@ func refundAuto() {
|
|
|
isRenewalProtection := common.IntAll(v["is_renewal_protection"])
|
|
|
clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, "name,phone,company_nature,company_verification,cluename,userid,position_id,uid", "")
|
|
|
if clueData != nil && len(*clueData) > 0 {
|
|
|
- saleId = common.Int64All((*clueData)["position_id"])
|
|
|
+ saleId, _ = FindPositionIdClueId(clueId)
|
|
|
cluename = common.ObjToString((*clueData)["cluename"])
|
|
|
userName = gconv.String((*clueData)["name"])
|
|
|
company_nature = common.IntAll((*clueData)["company_nature"])
|
|
@@ -891,7 +893,7 @@ FROM
|
|
|
FROM dwd_f_crm_personnel_management u2
|
|
|
WHERE u1.position_id = u2.position_id
|
|
|
)
|
|
|
- ORDER BY id desc) b ON a.dept_name LIKE "%电销部%"
|
|
|
+ ORDER BY id desc) b ON a.dept_name LIKE "%销售一部%"
|
|
|
AND a.position_id = b.position_id`)
|
|
|
userData3 := TiDb.SelectBySql(`SELECT
|
|
|
a.position_id,
|
|
@@ -1085,6 +1087,7 @@ func CustomerChange() {
|
|
|
}
|
|
|
return true
|
|
|
}, `select operator_id, clue_id,position_id,old_value,new_value,createtime from dwd_f_crm_clue_change_record where createtime>? and change_type="客户成功经理" order by createtime`, startTime)
|
|
|
+ //}, `select operator_id, clue_id,position_id,old_value,new_value,createtime from dwd_f_crm_clue_change_record where id=? order by createtime`, 21921661)
|
|
|
if len(customMap1) > 0 {
|
|
|
ChangeSendKc(customMap1, 1)
|
|
|
}
|
|
@@ -1124,6 +1127,7 @@ func ChangeSendKc(data map[string][]map[string]interface{}, personType int64) {
|
|
|
}
|
|
|
|
|
|
func ChangeSendSale(data map[int64][]map[string]interface{}, personType int64) {
|
|
|
+ log.Println("客成人员变更", personType, data)
|
|
|
if personType == 1 {
|
|
|
//客户成功经理从空变成有人
|
|
|
for _, v := range data {
|
|
@@ -1186,7 +1190,8 @@ func CustomerChangeHandle(data map[string]interface{}) map[string]interface{} {
|
|
|
}
|
|
|
phone = common.ObjToString((*clueData)["phone"])
|
|
|
userName = gconv.String((*clueData)["name"])
|
|
|
- positionId := gconv.Int64((*clueData)["position_id"])
|
|
|
+ //positionId := gconv.Int64((*clueData)["position_id"])
|
|
|
+ positionId, _ := FindPositionIdClueId(clueId)
|
|
|
clueName = gconv.String((*clueData)["cluename"])
|
|
|
customData := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
@@ -1205,6 +1210,34 @@ func CustomerChangeHandle(data map[string]interface{}) map[string]interface{} {
|
|
|
"companyName": companyName,
|
|
|
}
|
|
|
}
|
|
|
+func FindPositionIdClueId(clueId int64) (int64, string) {
|
|
|
+ querySql := `
|
|
|
+ SELECT
|
|
|
+ b.salesperson,c.position_id
|
|
|
+ FROM
|
|
|
+ dwd_f_crm_clue_info a
|
|
|
+ INNER JOIN dwd_f_userbase_order_info b ON a.id = ?
|
|
|
+ AND a.uid = b.uid
|
|
|
+ AND (
|
|
|
+ b.payable_money > 0
|
|
|
+ OR (
|
|
|
+ b.payable_money = 0
|
|
|
+ AND ( b.filter LIKE "%分期付款补充权益%" OR b.filter LIKE "%原订单不支持开通多项权益%" OR b.filter LIKE "%权益码兑换%" )))
|
|
|
+ AND b.data_spec != "dhy4"
|
|
|
+ AND b.order_status = 1 and b.phone not like "9%"
|
|
|
+ AND ( b.refund_status != 1 OR b.refund_status IS NULL )
|
|
|
+ AND b.vip_starttime < "2099-01-01"
|
|
|
+ AND b.product_type IN ( "大会员", "企业商机管理" )
|
|
|
+ AND ( b.order_change = 0 OR ( b.order_change = 0 AND DATEDIFF( b.vip_endtime, b.vip_starttime )> 90 ) )
|
|
|
+ INNER JOIN dwd_f_crm_personnel_management c on c.ent_id =? and b.salesperson=c.name
|
|
|
+ ORDER BY
|
|
|
+ b.create_time,b.payable_money DESC limit 1`
|
|
|
+ clueData := TiDb.SelectBySql(querySql, clueId, db.EntId)
|
|
|
+ if clueData == nil || len(*clueData) == 0 {
|
|
|
+ return 0, ""
|
|
|
+ }
|
|
|
+ return gconv.Int64((*clueData)[0]["position_id"]), gconv.String((*clueData)[0]["salesperson"])
|
|
|
+}
|
|
|
func refundAutoHistory() {
|
|
|
data := TiDb.Find("dwd_f_crm_clue_autodraw_record", nil, "", "", -1, -1)
|
|
|
if data != nil {
|