|
@@ -701,7 +701,8 @@ func refundAuto() {
|
|
salesEmailData := map[int64][]map[string]interface{}{}
|
|
salesEmailData := map[int64][]map[string]interface{}{}
|
|
TiDb.SelectByBath(100, func(l *[]map[string]interface{}) bool {
|
|
TiDb.SelectByBath(100, func(l *[]map[string]interface{}) bool {
|
|
for _, v := range *l {
|
|
for _, v := range *l {
|
|
- saleId, cluename, company_nature, company_verification, uid, phone, userName := int64(0), "", 0, 0, "", "", ""
|
|
|
|
|
|
+ cluename, company_nature, company_verification, uid, phone, userName, oldSaleId, oldsaleName := "", 0, 0, "", "", "", int64(0), ""
|
|
|
|
+ saleId, newSeatNumber, newPerson := int64(0), "", ""
|
|
clueId := common.Int64All(v["clue_id"])
|
|
clueId := common.Int64All(v["clue_id"])
|
|
company_name := gconv.String(v["company_name"])
|
|
company_name := gconv.String(v["company_name"])
|
|
name := common.ObjToString(v["name"])
|
|
name := common.ObjToString(v["name"])
|
|
@@ -709,7 +710,12 @@ func refundAuto() {
|
|
isRenewalProtection := common.IntAll(v["is_renewal_protection"])
|
|
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", "")
|
|
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 {
|
|
if clueData != nil && len(*clueData) > 0 {
|
|
- saleId, _ = FindPositionIdClueId(clueId)
|
|
|
|
|
|
+ saleId, newPerson, newSeatNumber = FindPositionIdClueId(clueId)
|
|
|
|
+ oldSaleId = common.Int64All((*clueData)["position_id"])
|
|
|
|
+ oldPersonData := FindPersonOne(oldSaleId)
|
|
|
|
+ if oldSaleId != 0 {
|
|
|
|
+ oldsaleName = gconv.String(oldPersonData["name"])
|
|
|
|
+ }
|
|
cluename = common.ObjToString((*clueData)["cluename"])
|
|
cluename = common.ObjToString((*clueData)["cluename"])
|
|
userName = gconv.String((*clueData)["name"])
|
|
userName = gconv.String((*clueData)["name"])
|
|
company_nature = common.IntAll((*clueData)["company_nature"])
|
|
company_nature = common.IntAll((*clueData)["company_nature"])
|
|
@@ -735,20 +741,12 @@ func refundAuto() {
|
|
"remrk": "3天后即将移交",
|
|
"remrk": "3天后即将移交",
|
|
"reason": "成交客户续费失败",
|
|
"reason": "成交客户续费失败",
|
|
})
|
|
})
|
|
- /*salesEmailData[saleId] = append(salesEmailData[saleId], map[string]interface{}{
|
|
|
|
- "company_name": company_name,
|
|
|
|
- "phone": phone,
|
|
|
|
- "userName": userName,
|
|
|
|
- "remrk": "1天后即将移交",
|
|
|
|
- "reason": "成交客户续费失败",
|
|
|
|
- "cluename": cluename,
|
|
|
|
- })*/
|
|
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
- isFull := FindUpperLimit(gconv.String(saleId), "", false)
|
|
|
|
|
|
+ isFull := false
|
|
isAllRefund := false
|
|
isAllRefund := false
|
|
myOrders := TiDb.SelectBySql(`select refund_status from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1 `, uid)
|
|
myOrders := TiDb.SelectBySql(`select refund_status from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1 `, uid)
|
|
if myOrders != nil {
|
|
if myOrders != nil {
|
|
@@ -861,12 +859,7 @@ 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 {
|
|
- //查看一下当前人是否在职
|
|
|
|
- if FindUpperLimit(gconv.String(saleId), "", false) {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0,is_assign=-3,FREEZE_TIME=? WHERE id = ?`, nowTime, nowTime, nowTime, clueId)
|
|
|
|
- } else {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,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)
|
|
@@ -874,15 +867,10 @@ func refundAuto() {
|
|
isOks := false
|
|
isOks := false
|
|
for _, vv := range *adata {
|
|
for _, vv := range *adata {
|
|
position_ids := common.Int64All(vv["position_id"])
|
|
position_ids := common.Int64All(vv["position_id"])
|
|
- seatNumber := common.ObjToString(vv["seatNumber"])
|
|
|
|
|
|
+ newSeatNumber = common.ObjToString(vv["seatNumber"])
|
|
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
|
|
- if isFull {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0,is_assign=-3,FREEZE_TIME=? WHERE id = ?`, nowTime, saleId, seatNumber, nowTime, nowTime, clueId)
|
|
|
|
- } else {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,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
|
|
}
|
|
}
|
|
@@ -894,30 +882,16 @@ 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"])
|
|
|
|
- if isFull {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0,is_assign=-3,FREEZE_TIME=? WHERE id = ?`, nowTime, saleId, seatNumber, nowTime, nowTime, clueId)
|
|
|
|
- } else {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,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)
|
|
|
|
- }
|
|
|
|
|
|
+ newSeatNumber = common.ObjToString((*sdata)[0]["seat_number"])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
sdata := &[]map[string]interface{}{}
|
|
sdata := &[]map[string]interface{}{}
|
|
//查看当前是否属于一部三部
|
|
//查看当前是否属于一部三部
|
|
- userData := TiDb.SelectBySql(`SELECT
|
|
|
|
- b.NAME,
|
|
|
|
- b.position_id,
|
|
|
|
- b.seat_number,
|
|
|
|
- b.role_id,
|
|
|
|
- a.dept_name
|
|
|
|
- FROM
|
|
|
|
- dwd_d_crm_department_level_succbi a
|
|
|
|
- INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = ?
|
|
|
|
- AND a.position_id = b.position_id`, saleId)
|
|
|
|
- if userData != nil && len(*userData) > 0 {
|
|
|
|
- deptName := gconv.String((*userData)[0]["dept_name"])
|
|
|
|
|
|
+ userData := FindPersonOne(saleId)
|
|
|
|
+ if userData != nil {
|
|
|
|
+ deptName := gconv.String(userData["dept_name"])
|
|
if strings.Contains(deptName, "一部") {
|
|
if strings.Contains(deptName, "一部") {
|
|
sdata = TiDb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id where a.bi_pcode = (SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) and b.role_id = 3`, saleId)
|
|
sdata = TiDb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id where a.bi_pcode = (SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) and b.role_id = 3`, saleId)
|
|
if len(*sdata) == 0 {
|
|
if len(*sdata) == 0 {
|
|
@@ -929,21 +903,10 @@ 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"])
|
|
|
|
- if isFull {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0,is_assign=-3,FREEZE_TIME=? WHERE id = ?`, nowTime, saleId, seatNumber, nowTime, nowTime, clueId)
|
|
|
|
- } else {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,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)
|
|
|
|
- }
|
|
|
|
|
|
+ newSeatNumber = common.ObjToString((*sdata)[0]["seat_number"])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- if isFull {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",top_cluetype="532",sub_cluetype="537",is_transfer=0,is_assign=-3,FREEZE_TIME=? WHERE id = ?`, nowTime, nowTime, clueId)
|
|
|
|
- } else {
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",top_cluetype="532",sub_cluetype="537",is_transfer=0 WHERE id = ?`, nowTime, clueId)
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
if kcposition_id > 0 {
|
|
if kcposition_id > 0 {
|
|
mailData[name] = append(mailData[name], map[string]interface{}{
|
|
mailData[name] = append(mailData[name], map[string]interface{}{
|
|
@@ -954,6 +917,7 @@ func refundAuto() {
|
|
"reason": "成交客户续费失败",
|
|
"reason": "成交客户续费失败",
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ isFull = FindUpperLimit(gconv.String(saleId), "", false)
|
|
if saleId > 0 {
|
|
if saleId > 0 {
|
|
salesEmailData[saleId] = append(salesEmailData[saleId], map[string]interface{}{
|
|
salesEmailData[saleId] = append(salesEmailData[saleId], map[string]interface{}{
|
|
"company_name": company_name,
|
|
"company_name": company_name,
|
|
@@ -963,6 +927,51 @@ func refundAuto() {
|
|
"reason": "成交客户续费失败",
|
|
"reason": "成交客户续费失败",
|
|
"cluename": cluename,
|
|
"cluename": cluename,
|
|
})
|
|
})
|
|
|
|
+ if saleId != oldSaleId {
|
|
|
|
+ //新增个人员变更
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": saleId,
|
|
|
|
+ "change_field": "position_id",
|
|
|
|
+ "change_type": "所属人变更",
|
|
|
|
+ "old_value": common.If(oldsaleName != "", oldsaleName, "/"),
|
|
|
|
+ "new_value": common.If(newPerson != "", newPerson, "/"),
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET WHERE id = ?`, nowTime, clueId)
|
|
|
|
+ if isFull {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",position_id=?,seatNumber=?,is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0,is_assign=-3,FREEZE_TIME=? WHERE id = ?`, nowTime, saleId, newSeatNumber, nowTime, nowTime, clueId)
|
|
|
|
+ } else {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,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, newSeatNumber, nowTime, clueId)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if isFull {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",top_cluetype="532",sub_cluetype="537",is_transfer=0,is_assign=-3,FREEZE_TIME=? WHERE id = ?`, nowTime, nowTime, clueId)
|
|
|
|
+ } else {
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",top_cluetype="532",sub_cluetype="537",is_transfer=0,is_assign=0 WHERE id = ?`, nowTime, clueId)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if saleId == 0 {
|
|
|
|
+ //找不到人
|
|
|
|
+ TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_unfollow=0,updatetime=?,trailstatus="01",position_id="",seatNumber="",is_task=1,tasktime=?,top_cluetype="532",sub_cluetype="537",taskstatus=0,tasksource="其他-成交客户续约失败",is_transfer=0,is_assign=0 WHERE id = ?`, nowTime, nowTime, clueId)
|
|
|
|
+ if oldSaleId != 0 {
|
|
|
|
+ //新增个人员变更
|
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": saleId,
|
|
|
|
+ "change_field": "position_id",
|
|
|
|
+ "change_type": "所属人变更",
|
|
|
|
+ "old_value": common.If(oldsaleName != "", oldsaleName, "/"),
|
|
|
|
+ "new_value": common.If(newPerson != "", newPerson, "/"),
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ "SHUOMING": "业绩归属查不到人",
|
|
|
|
+ })
|
|
|
|
+ //再做一个记录变更
|
|
|
|
+ }
|
|
}
|
|
}
|
|
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,
|
|
@@ -975,15 +984,17 @@ func refundAuto() {
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
- 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,
|
|
|
|
- })
|
|
|
|
|
|
+ if saleId > 0 {
|
|
|
|
+ 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.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),
|
|
@@ -1039,7 +1050,7 @@ func refundAuto() {
|
|
}
|
|
}
|
|
return true
|
|
return true
|
|
}, `select ent_id,clue_id,position_id,name,is_renewal_protection,company_name from dwd_f_csm_customer_info where is_transfer = 0`)
|
|
}, `select ent_id,clue_id,position_id,name,is_renewal_protection,company_name from dwd_f_csm_customer_info where is_transfer = 0`)
|
|
- //}, `select ent_id,clue_id,position_id,name,is_renewal_protection,company_name from dwd_f_csm_customer_info where clue_id =1473919`)
|
|
|
|
|
|
+ //}, `select ent_id,clue_id,position_id,name,is_renewal_protection,company_name from dwd_f_csm_customer_info where clue_id =1441420`)
|
|
|
|
|
|
//移交电销提醒
|
|
//移交电销提醒
|
|
for i, v := range mailData {
|
|
for i, v := range mailData {
|
|
@@ -1377,7 +1388,7 @@ func CustomerChangeHandle(data map[string]interface{}) map[string]interface{} {
|
|
phone = common.ObjToString((*clueData)["phone"])
|
|
phone = common.ObjToString((*clueData)["phone"])
|
|
userName = gconv.String((*clueData)["name"])
|
|
userName = gconv.String((*clueData)["name"])
|
|
//positionId := gconv.Int64((*clueData)["position_id"])
|
|
//positionId := gconv.Int64((*clueData)["position_id"])
|
|
- positionId, _ := FindPositionIdClueId(clueId)
|
|
|
|
|
|
+ positionId, _, _ := FindPositionIdClueId(clueId)
|
|
clueName = gconv.String((*clueData)["cluename"])
|
|
clueName = gconv.String((*clueData)["cluename"])
|
|
customData := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{
|
|
customData := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
@@ -1396,13 +1407,15 @@ func CustomerChangeHandle(data map[string]interface{}) map[string]interface{} {
|
|
"companyName": companyName,
|
|
"companyName": companyName,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-func FindPositionIdClueId(clueId int64) (int64, string) {
|
|
|
|
|
|
+
|
|
|
|
+// 查找订单实际业绩归属
|
|
|
|
+func FindPositionIdClueId(clueId int64) (int64, string, string) {
|
|
querySql := `
|
|
querySql := `
|
|
SELECT
|
|
SELECT
|
|
- e.username as salesperson ,c.position_id
|
|
|
|
|
|
+ e.username as salesperson ,c.position_id,f.dept_name,c.seat_number
|
|
FROM
|
|
FROM
|
|
dwd_f_crm_clue_info a
|
|
dwd_f_crm_clue_info a
|
|
- INNER JOIN dwd_f_userbase_order_info b ON a.id = ?
|
|
|
|
|
|
+INNER JOIN dwd_f_userbase_order_info b ON a.id = ?
|
|
AND a.uid = b.uid
|
|
AND a.uid = b.uid
|
|
AND (
|
|
AND (
|
|
b.payable_money > 0
|
|
b.payable_money > 0
|
|
@@ -1418,13 +1431,20 @@ func FindPositionIdClueId(clueId int64) (int64, string) {
|
|
inner JOIN jianyu.order_sale_record d on b.order_code=d.ordercode and d.state=1
|
|
inner JOIN jianyu.order_sale_record d on b.order_code=d.ordercode and d.state=1
|
|
INNER JOIN cadmin.admin_user e on d.saler_Id = e.id
|
|
INNER JOIN cadmin.admin_user e on d.saler_Id = e.id
|
|
INNER JOIN dwd_f_crm_personnel_management c on c.ent_id =? and e.username=c.name
|
|
INNER JOIN dwd_f_crm_personnel_management c on c.ent_id =? and e.username=c.name
|
|
|
|
+ inner join dwd_d_crm_department_level_succbi f on c.position_id=f.position_id
|
|
ORDER BY
|
|
ORDER BY
|
|
- b.vip_endtime desc ,b.payable_money DESC limit 1`
|
|
|
|
|
|
+ b.vip_endtime desc ,b.payable_money DESC `
|
|
clueData := TiDb.SelectBySql(querySql, clueId, db.EntId)
|
|
clueData := TiDb.SelectBySql(querySql, clueId, db.EntId)
|
|
if clueData == nil || len(*clueData) == 0 {
|
|
if clueData == nil || len(*clueData) == 0 {
|
|
- return 0, ""
|
|
|
|
|
|
+ return 0, "", ""
|
|
|
|
+ }
|
|
|
|
+ for _, m := range *clueData {
|
|
|
|
+ deptName := gconv.String(m["dept_name"])
|
|
|
|
+ if strings.Contains(deptName, "一部") || strings.Contains(deptName, "三部") {
|
|
|
|
+ return gconv.Int64(m["position_id"]), gconv.String(m["salesperson"]), gconv.String(m["seat_number"])
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return gconv.Int64((*clueData)[0]["position_id"]), gconv.String((*clueData)[0]["salesperson"])
|
|
|
|
|
|
+ return 0, "", ""
|
|
}
|
|
}
|
|
func refundAutoHistory() {
|
|
func refundAutoHistory() {
|
|
data := TiDb.Find("dwd_f_crm_clue_autodraw_record", nil, "", "", -1, -1)
|
|
data := TiDb.Find("dwd_f_crm_clue_autodraw_record", nil, "", "", -1, -1)
|
|
@@ -1505,9 +1525,7 @@ func PhoneToPositionId(phone string) int64 {
|
|
}
|
|
}
|
|
func kcClue(userId, uId, seatNumber, cluename, top_cluetype, sub_cluetype,
|
|
func kcClue(userId, uId, seatNumber, cluename, top_cluetype, sub_cluetype,
|
|
name, phone, position, sourceCode, industry, follow_project_area,
|
|
name, phone, position, sourceCode, industry, follow_project_area,
|
|
- role, item, subname, topname, remark, demand, department, departments, saleName, source string,
|
|
|
|
- positionId int64, isGroup, isCommerce int,
|
|
|
|
- keywords []string) bool {
|
|
|
|
|
|
+ role, item, subname, topname, remark, demand, department, departments, saleName, source string, positionId int64, isGroup, isCommerce int, keywords []string) bool {
|
|
clueId, uodateId1, uodateId2, uodateId3, uodateId4, uodateId5 := int64(0), int64(0), int64(0), int64(0), int64(0), int64(0)
|
|
clueId, uodateId1, uodateId2, uodateId3, uodateId4, uodateId5 := int64(0), int64(0), int64(0), int64(0), int64(0), int64(0)
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
|
|
nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
|
|
@@ -1780,7 +1798,7 @@ func ExitKcSend(personName string, infoList []map[string]interface{}) {
|
|
|
|
|
|
// 客成邮件 订单信息初始化
|
|
// 客成邮件 订单信息初始化
|
|
func KcOrderFormat(orderCode string, bigmemberService, combo map[int64]string) *OrderInfo {
|
|
func KcOrderFormat(orderCode string, bigmemberService, combo map[int64]string) *OrderInfo {
|
|
- orderData := Mysql.SelectBySql(`SELECT a.id,a.order_code,a.pay_money,a.user_phone,a.vip_starttime,a.vip_endtime,a.product_type,a.filter,a.user_id,a.ent_id,a.company_name,a.create_person,SUM(b.return_money) AS return_money
|
|
|
|
|
|
+ orderData := Mysql.SelectBySql(`SELECT a.id,a.order_code,a.pay_money,a.user_phone,a.vip_starttime,a.vip_endtime,a.product_type,a.filter,a.user_id,a.ent_id,a.company_name,a.create_person,SUM(b.return_money) AS return_money
|
|
FROM jianyu.dataexport_order a
|
|
FROM jianyu.dataexport_order a
|
|
LEFT JOIN return_money_record b ON (a.order_code=b.order_code)
|
|
LEFT JOIN return_money_record b ON (a.order_code=b.order_code)
|
|
WHERE a.order_code=? AND a.order_status=1 AND (a.product_type='大会员' OR a.product_type='大会员-子账号' or a.product_type = "企业商机管理")
|
|
WHERE a.order_code=? AND a.order_status=1 AND (a.product_type='大会员' OR a.product_type='大会员-子账号' or a.product_type = "企业商机管理")
|
|
@@ -1883,3 +1901,19 @@ func SaleMail(positionId int64) string {
|
|
}
|
|
}
|
|
return to
|
|
return to
|
|
}
|
|
}
|
|
|
|
+func FindPersonOne(positionId int64) map[string]interface{} {
|
|
|
|
+ personData := TiDb.SelectBySql(`SELECT
|
|
|
|
+ b.name,
|
|
|
|
+ b.position_id,
|
|
|
|
+ b.seat_number,
|
|
|
|
+ b.role_id,
|
|
|
|
+ a.dept_name
|
|
|
|
+ FROM
|
|
|
|
+ dwd_d_crm_department_level_succbi a
|
|
|
|
+ INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = ?
|
|
|
|
+ AND a.position_id = b.position_id`, positionId)
|
|
|
|
+ if personData == nil || len(*personData) == 0 {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ return (*personData)[0]
|
|
|
|
+}
|