|
@@ -478,17 +478,24 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
if companyName == "" {
|
|
|
companyName = phone
|
|
|
}
|
|
|
- isOK, dataMap := false, map[string]interface{}{
|
|
|
- "cluename": companyName,
|
|
|
- "name": name,
|
|
|
- "phone": phone,
|
|
|
- "position": position,
|
|
|
+ isOK, isOks, dataMap := false, true, map[string]interface{}{
|
|
|
+ "cluename": companyName,
|
|
|
+ "name": name,
|
|
|
+ "phone": phone,
|
|
|
+ "position": position,
|
|
|
+ "clueSource": clueSource,
|
|
|
}
|
|
|
if phone == "" {
|
|
|
- result += "第" + fmt.Sprint(k+2) + "行,“联系方式为空”\n"
|
|
|
+ isOks = false
|
|
|
+ result += "第" + fmt.Sprint(k+2) + "行,“联系方式为空”"
|
|
|
} else {
|
|
|
if !phoneRegexp.MatchString(phone) {
|
|
|
- result += "第" + fmt.Sprint(k+2) + "行,“联系方式格式有误”\n"
|
|
|
+ if !isOks {
|
|
|
+ result += ",“联系方式格式有误”"
|
|
|
+ } else {
|
|
|
+ result += "第" + fmt.Sprint(k+2) + "行,“联系方式格式有误”"
|
|
|
+ }
|
|
|
+ isOks = false
|
|
|
} else {
|
|
|
userData := JyBiTidb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"phone": phone}, "", "")
|
|
|
if userData != nil && len(*userData) > 0 {
|
|
@@ -496,7 +503,12 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
userId := common.ObjToString((*userData)["userid"])
|
|
|
uId := common.ObjToString((*userData)["uid"])
|
|
|
if source == 5 {
|
|
|
- result += "第" + fmt.Sprint(k+2) + "行,“该线索已归属域外”\n"
|
|
|
+ if !isOks {
|
|
|
+ result += ",“该线索已归属域外”"
|
|
|
+ } else {
|
|
|
+ result += "第" + fmt.Sprint(k+2) + "行,“该线索已归属域外”"
|
|
|
+ }
|
|
|
+ isOks = false
|
|
|
} else {
|
|
|
isOK = true
|
|
|
dataMap["userId"] = userId
|
|
@@ -519,11 +531,21 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
}
|
|
|
}
|
|
|
if clueSource == "" {
|
|
|
- result += "第" + fmt.Sprint(k+2) + "行,“销售线索来源为空”\n"
|
|
|
+ if !isOks {
|
|
|
+ result += ",“销售线索来源为空”"
|
|
|
+ } else {
|
|
|
+ result += "第" + fmt.Sprint(k+2) + "行,“销售线索来源为空”"
|
|
|
+ }
|
|
|
+ isOks = false
|
|
|
} else {
|
|
|
sourceData := JyBiTidb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"name": clueSource}, "", "")
|
|
|
if sourceData == nil || len(*sourceData) == 0 {
|
|
|
- result += "第" + fmt.Sprint(k+2) + "行,“销售线索来源不存在”\n"
|
|
|
+ if !isOks {
|
|
|
+ result += ",“销售线索来源不存在”"
|
|
|
+ } else {
|
|
|
+ result += "第" + fmt.Sprint(k+2) + "行,“销售线索来源不存在”"
|
|
|
+ }
|
|
|
+ isOks = false
|
|
|
} else {
|
|
|
isOK = true
|
|
|
code := common.ObjToString((*sourceData)["code"])
|
|
@@ -535,6 +557,9 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
if isOK {
|
|
|
dataArr = append(dataArr, dataMap)
|
|
|
}
|
|
|
+ if !isOks {
|
|
|
+ result += "\n"
|
|
|
+ }
|
|
|
}
|
|
|
if result != "" {
|
|
|
status = -1
|
|
@@ -594,7 +619,24 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
old_cluename := common.ObjToString((*clueData)["cluename"])
|
|
|
old_name := common.ObjToString((*clueData)["name"])
|
|
|
old_position := common.ObjToString((*clueData)["position"])
|
|
|
- positionId := common.ObjToString((*clueData)["position_id"])
|
|
|
+ old_top_cluetype := common.ObjToString((*clueData)["top_cluetype"])
|
|
|
+ old_sub_cluetype := common.ObjToString((*clueData)["sub_cluetype"])
|
|
|
+ top_cluetype := common.ObjToString(v["top_cluetype"])
|
|
|
+ sub_cluetype := common.ObjToString(v["sub_cluetype"])
|
|
|
+ old_topname, old_subname := "", ""
|
|
|
+ if old_top_cluetype != "" {
|
|
|
+ pcodeData := JyBiTidb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_top_cluetype}, "", "")
|
|
|
+ if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
+ old_topname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if old_sub_cluetype != "" {
|
|
|
+ pcodeData := JyBiTidb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_sub_cluetype}, "", "")
|
|
|
+ if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
+ old_subname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ positionId := common.Int64All((*clueData)["position_id"])
|
|
|
batch_imports := ""
|
|
|
if is_assign == 0 {
|
|
|
countOpen++
|
|
@@ -606,8 +648,8 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
updateData := map[string]interface{}{
|
|
|
"batch_import": batch_imports,
|
|
|
"updatetime": nowTime,
|
|
|
- "top_cluetype": v["top_cluetype"],
|
|
|
- "sub_cluetype": v["sub_cluetype"],
|
|
|
+ "top_cluetype": top_cluetype,
|
|
|
+ "sub_cluetype": sub_cluetype,
|
|
|
}
|
|
|
if cluename != "" && cluename != old_cluename {
|
|
|
updateData["cluename"] = cluename
|
|
@@ -616,7 +658,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
"position_id": -1,
|
|
|
"change_field": "cluename",
|
|
|
"change_type": "基本信息变更",
|
|
|
- "old_value": old_cluename,
|
|
|
+ "old_value": common.If(old_cluename == "", "/", old_cluename),
|
|
|
"new_value": cluename,
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
@@ -630,7 +672,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
"position_id": -1,
|
|
|
"change_field": "name",
|
|
|
"change_type": "基本信息变更",
|
|
|
- "old_value": old_name,
|
|
|
+ "old_value": common.If(old_name == "", "/", old_name),
|
|
|
"new_value": name,
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
@@ -644,13 +686,41 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
"position_id": -1,
|
|
|
"change_field": "position",
|
|
|
"change_type": "基本信息变更",
|
|
|
- "old_value": old_position,
|
|
|
+ "old_value": common.If(old_position == "", "/", old_position),
|
|
|
"new_value": position,
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"operator_id": this.PositionId,
|
|
|
})
|
|
|
}
|
|
|
+ if top_cluetype != "" && top_cluetype != old_top_cluetype {
|
|
|
+ updateData["position"] = position
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": -1,
|
|
|
+ "change_field": "top_cluetype",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": common.If(old_topname == "", "/", old_topname),
|
|
|
+ "new_value": "批量导入线索",
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": this.PositionId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if sub_cluetype != "" && sub_cluetype != old_sub_cluetype {
|
|
|
+ updateData["position"] = position
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": -1,
|
|
|
+ "change_field": "sub_cluetype",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": common.If(old_subname == "", "/", old_subname),
|
|
|
+ "new_value": v["clueSource"],
|
|
|
+ "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++
|
|
@@ -677,7 +747,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
"position_id": positionId,
|
|
|
"change_field": "cluename",
|
|
|
"change_type": "基本信息变更",
|
|
|
- "old_value": old_cluename,
|
|
|
+ "old_value": common.If(old_cluename == "", "/", old_cluename),
|
|
|
"new_value": cluename,
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
@@ -691,7 +761,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
"position_id": positionId,
|
|
|
"change_field": "name",
|
|
|
"change_type": "基本信息变更",
|
|
|
- "old_value": old_name,
|
|
|
+ "old_value": common.If(old_name == "", "/", old_name),
|
|
|
"new_value": name,
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
@@ -705,13 +775,41 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
"position_id": positionId,
|
|
|
"change_field": "position",
|
|
|
"change_type": "基本信息变更",
|
|
|
- "old_value": old_position,
|
|
|
+ "old_value": common.If(old_position == "", "/", old_position),
|
|
|
"new_value": position,
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"operator_id": this.PositionId,
|
|
|
})
|
|
|
}
|
|
|
+ if top_cluetype != "" && top_cluetype != old_top_cluetype {
|
|
|
+ updateData["position"] = position
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_field": "top_cluetype",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": common.If(old_topname == "", "/", old_topname),
|
|
|
+ "new_value": "批量导入线索",
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": this.PositionId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if sub_cluetype != "" && sub_cluetype != old_sub_cluetype {
|
|
|
+ updateData["position"] = position
|
|
|
+ JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_field": "sub_cluetype",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": common.If(old_subname == "", "/", old_subname),
|
|
|
+ "new_value": v["clueSource"],
|
|
|
+ "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,
|