|
@@ -4,6 +4,7 @@ import (
|
|
"database/sql"
|
|
"database/sql"
|
|
"fmt"
|
|
"fmt"
|
|
"log"
|
|
"log"
|
|
|
|
+ "strings"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
@@ -293,26 +294,35 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
|
|
|
func UpdateClue(data map[string]interface{}, saleData []map[string]interface{}, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber string, positionId int64) {
|
|
func UpdateClue(data map[string]interface{}, saleData []map[string]interface{}, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber string, positionId int64) {
|
|
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")
|
|
//trailstatus = 无意向 为变更线索状态
|
|
//trailstatus = 无意向 为变更线索状态
|
|
//没有变更所属人查任务车,有车不变
|
|
//没有变更所属人查任务车,有车不变
|
|
trailstatus := common.ObjToString(data["trailstatus"])
|
|
trailstatus := common.ObjToString(data["trailstatus"])
|
|
clueId := common.Int64All(data["id"])
|
|
clueId := common.Int64All(data["id"])
|
|
is_assign := common.IntAll(data["is_assign"])
|
|
is_assign := common.IntAll(data["is_assign"])
|
|
- oldsaleName, oldTaskTime, taskTime := "", "", ""
|
|
|
|
|
|
+ oldsaleName, oldTaskTime, taskTime, is_task, taskstatus := "", "", "", 0, 0
|
|
//已在任务车的判断任务时间
|
|
//已在任务车的判断任务时间
|
|
privateData := TiDb.FindOne("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId}, "", "")
|
|
privateData := TiDb.FindOne("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId}, "", "")
|
|
if privateData != nil && len(*privateData) > 0 {
|
|
if privateData != nil && len(*privateData) > 0 {
|
|
oldTaskTime = common.ObjToString((*privateData)["tasktime"])
|
|
oldTaskTime = common.ObjToString((*privateData)["tasktime"])
|
|
|
|
+ is_task = common.IntAll(data["is_task"])
|
|
|
|
+ taskstatus = common.IntAll(data["taskstatus"])
|
|
}
|
|
}
|
|
- if oldTaskTime != "" {
|
|
|
|
- t1, err := time.Parse("2006-01-02 15:04:05", oldTaskTime)
|
|
|
|
- if err == nil && time.Now().Before(t1) {
|
|
|
|
- taskTime = nowTime
|
|
|
|
- } else {
|
|
|
|
- taskTime = oldTaskTime
|
|
|
|
|
|
+ if taskstatus == 1 || is_task == 0 {
|
|
|
|
+ taskTime = common.ObjToString(common.If(item != "users", nowTime, nowTimes))
|
|
|
|
+ } else {
|
|
|
|
+ if is_task == 1 {
|
|
|
|
+ if oldTaskTime != "" {
|
|
|
|
+ t1, err := time.Parse("2006-01-02 15:04:05", oldTaskTime)
|
|
|
|
+ if err == nil && time.Now().Before(t1) {
|
|
|
|
+ taskTime = nowTime
|
|
|
|
+ } else {
|
|
|
|
+ taskTime = oldTaskTime
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
clueUpdateData := map[string]interface{}{
|
|
clueUpdateData := map[string]interface{}{
|
|
"is_assign": 1,
|
|
"is_assign": 1,
|
|
"updatetime": nowTime,
|
|
"updatetime": nowTime,
|
|
@@ -533,13 +543,23 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
})
|
|
})
|
|
}
|
|
}
|
|
if old_follow_project_area != follow_project_area {
|
|
if old_follow_project_area != follow_project_area {
|
|
|
|
+ old_area, old_area_arr := "", []string{}
|
|
|
|
+ new_area, new_area_arr := "", []string{}
|
|
|
|
+ for _, v := range strings.Split(old_follow_project_area, ",") {
|
|
|
|
+ old_area_arr = append(old_area_arr, CodeArea[v])
|
|
|
|
+ }
|
|
|
|
+ for _, v := range strings.Split(follow_project_area, ",") {
|
|
|
|
+ new_area_arr = append(new_area_arr, CodeArea[v])
|
|
|
|
+ }
|
|
|
|
+ old_area = strings.Join(old_area_arr, ",")
|
|
|
|
+ new_area = strings.Join(new_area_arr, ",")
|
|
updateId10 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId10 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
"position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
"position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
"change_field": "follow_project_area",
|
|
"change_field": "follow_project_area",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
- "old_value": common.If(old_follow_project_area != "", old_follow_project_area, "/"),
|
|
|
|
- "new_value": common.If(follow_project_area != "", follow_project_area, "/"),
|
|
|
|
|
|
+ "old_value": common.If(old_area != "", old_area, "/"),
|
|
|
|
+ "new_value": common.If(new_area != "", new_area, "/"),
|
|
"createtime": nowTime,
|
|
"createtime": nowTime,
|
|
"BCPCID": BCPCID,
|
|
"BCPCID": BCPCID,
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
@@ -602,22 +622,40 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
}
|
|
}
|
|
|
|
|
|
func getAreaCode(userId string) (code string) {
|
|
func getAreaCode(userId string) (code string) {
|
|
- followData := Base.FindOne("follow_project_monitor", map[string]interface{}{"s_userid": userId}, "", "")
|
|
|
|
|
|
+ followData := Base.Find("follow_project_monitor", map[string]interface{}{"s_userid": userId}, "", "", -1, -1)
|
|
|
|
+ sidArr := []string{}
|
|
if followData != nil && len(*followData) > 0 {
|
|
if followData != nil && len(*followData) > 0 {
|
|
- infoId := common.ObjToString((*followData)["s_id"])
|
|
|
|
- biddingData := Es.GetByIdField("bidding", "bidding", infoId, "")
|
|
|
|
|
|
+ for _, v := range *followData {
|
|
|
|
+ infoId := common.ObjToString(v["s_id"])
|
|
|
|
+ sidArr = append(sidArr, infoId)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if len(sidArr) > 0 {
|
|
|
|
+ query := `{"query": {"bool": {"must": [{"terms": {"_id": ["%s"]}}],"must_not": [],"should": []}}}`
|
|
|
|
+ query = fmt.Sprintf(query, strings.Join(sidArr, `","`))
|
|
|
|
+ biddingData := Es.Get("bidding", "bidding", query)
|
|
if biddingData != nil && len(*biddingData) > 0 {
|
|
if biddingData != nil && len(*biddingData) > 0 {
|
|
- area := common.ObjToString((*biddingData)["area"])
|
|
|
|
- address := common.ObjToString((*biddingData)["city"])
|
|
|
|
- if address == "" {
|
|
|
|
- address = area
|
|
|
|
|
|
+ codeMap := map[string]string{}
|
|
|
|
+ codeArr := []string{}
|
|
|
|
+ for _, v := range *biddingData {
|
|
|
|
+ area := common.ObjToString(v["area"])
|
|
|
|
+ address := common.ObjToString(v["city"])
|
|
|
|
+ if address == "" {
|
|
|
|
+ address = area
|
|
|
|
+ }
|
|
|
|
+ codeMap[address] = AreaCode[address]
|
|
|
|
+ }
|
|
|
|
+ if len(codeMap) > 0 {
|
|
|
|
+ for _, v := range codeMap {
|
|
|
|
+ codeArr = append(codeArr, v)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- areaData := TiDb.FindOne("d_area_code", map[string]interface{}{"name": address}, "", "")
|
|
|
|
- if areaData != nil && len(*areaData) > 0 {
|
|
|
|
- code = common.ObjToString((*areaData)["code"])
|
|
|
|
|
|
+ if len(codeArr) > 0 {
|
|
|
|
+ code = strings.Join(codeArr, ",")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ log.Println("code ", code)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|