|
@@ -532,7 +532,11 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
})
|
|
|
} else {
|
|
|
for _, v := range dataArr {
|
|
|
- clueData := JyBiTidb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": v["phone"]}, "", "")
|
|
|
+ phone := common.ObjToString(v["phone"])
|
|
|
+ cluename := common.ObjToString(v["cluename"])
|
|
|
+ name := common.ObjToString(v["name"])
|
|
|
+ position := common.ObjToString(v["position"])
|
|
|
+ clueData := JyBiTidb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
|
if clueData == nil || len(*clueData) == 0 {
|
|
|
countAdd++
|
|
|
JyBiTidb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
|
|
@@ -542,21 +546,145 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
"comeintime": nowTime,
|
|
|
"createtime": nowTime,
|
|
|
"updatetime": nowTime,
|
|
|
- "cluename": v["cluename"],
|
|
|
+ "cluename": cluename,
|
|
|
"top_cluetype": v["top_cluetype"],
|
|
|
"sub_cluetype": v["sub_cluetype"],
|
|
|
"trailstatus": "01",
|
|
|
- "name": v["name"],
|
|
|
- "phone": v["phone"],
|
|
|
- "position": v["position"],
|
|
|
+ "name": name,
|
|
|
+ "phone": phone,
|
|
|
+ "position": position,
|
|
|
"batch_import": this.Pcbh,
|
|
|
})
|
|
|
} else {
|
|
|
is_assign := common.IntAll((*clueData)["is_assign"])
|
|
|
+ clueId := common.Int64All((*clueData)["id"])
|
|
|
+ batch_import := common.ObjToString((*clueData)["batch_import"])
|
|
|
+ old_cluename := common.ObjToString((*clueData)["cluename"])
|
|
|
+ old_name := common.ObjToString((*clueData)["name"])
|
|
|
+ old_position := common.ObjToString((*clueData)["position"])
|
|
|
+ positionId := common.ObjToString((*clueData)["position_id"])
|
|
|
+ batch_imports := ""
|
|
|
if is_assign == 0 {
|
|
|
countOpen++
|
|
|
+ if batch_import != "" {
|
|
|
+ batch_imports = batch_import + "," + this.Pcbh
|
|
|
+ } else {
|
|
|
+ batch_imports = this.Pcbh
|
|
|
+ }
|
|
|
+ updateData := map[string]interface{}{
|
|
|
+ "batch_import": batch_imports,
|
|
|
+ "updatetime": nowTime,
|
|
|
+ "top_cluetype": v["top_cluetype"],
|
|
|
+ "sub_cluetype": v["sub_cluetype"],
|
|
|
+ }
|
|
|
+ if cluename != "" && cluename != old_cluename {
|
|
|
+ updateData["cluename"] = cluename
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": -1,
|
|
|
+ "change_field": "cluename",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": old_cluename,
|
|
|
+ "new_value": cluename,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": this.PositionId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if name != "" && name != old_name {
|
|
|
+ updateData["name"] = name
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": -1,
|
|
|
+ "change_field": "name",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": old_name,
|
|
|
+ "new_value": name,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": this.PositionId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if position != "" && position != old_position {
|
|
|
+ updateData["position"] = position
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": -1,
|
|
|
+ "change_field": "position",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": old_position,
|
|
|
+ "new_value": position,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": this.PositionId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
|
|
|
} else if is_assign == 1 {
|
|
|
countPrivate++
|
|
|
+ updateData := map[string]interface{}{
|
|
|
+ "batch_import": batch_imports,
|
|
|
+ "updatetime": nowTime,
|
|
|
+ "top_cluetype": v["top_cluetype"],
|
|
|
+ "sub_cluetype": v["sub_cluetype"],
|
|
|
+ }
|
|
|
+ updateData["is_task"] = 1
|
|
|
+ updateData["task_time"] = nowTime
|
|
|
+ updateData["tasktime"] = nowTime
|
|
|
+ updateData["taskstatus"] = 0
|
|
|
+ updateData["tasksource"] = "线索来源更新客户"
|
|
|
+ if cluename != "" && cluename != old_cluename {
|
|
|
+ updateData["cluename"] = cluename
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_field": "cluename",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": old_cluename,
|
|
|
+ "new_value": cluename,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": this.PositionId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if name != "" && name != old_name {
|
|
|
+ updateData["name"] = name
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_field": "name",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": old_name,
|
|
|
+ "new_value": name,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": this.PositionId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if position != "" && position != old_position {
|
|
|
+ updateData["position"] = position
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_field": "position",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": old_position,
|
|
|
+ "new_value": position,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": this.PositionId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
|
|
|
+ JyBiTidb.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": this.PositionId,
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|