|
@@ -40,7 +40,7 @@ func CreateClue(in *pb.CreateCuleReq) (result *pb.BiReply, err error) {
|
|
isGroup, isCommerce := CompanyType(in.Phone) //判断是否集团公司、工商库
|
|
isGroup, isCommerce := CompanyType(in.Phone) //判断是否集团公司、工商库
|
|
clueId := int64(0)
|
|
clueId := int64(0)
|
|
if entity.JyBiTidb.ExecTx("保存线索", func(tx *sql.Tx) bool {
|
|
if entity.JyBiTidb.ExecTx("保存线索", func(tx *sql.Tx) bool {
|
|
- nowTime := time.Now()
|
|
|
|
|
|
+ nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
BCPCID := common.GetRandom(32)
|
|
BCPCID := common.GetRandom(32)
|
|
clueId = entity.JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
|
|
clueId = entity.JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
|
|
"userid": userId,
|
|
"userid": userId,
|
|
@@ -57,7 +57,6 @@ func CreateClue(in *pb.CreateCuleReq) (result *pb.BiReply, err error) {
|
|
"company_nature": isGroup,
|
|
"company_nature": isGroup,
|
|
"company_verification": isCommerce,
|
|
"company_verification": isCommerce,
|
|
"comeintime_open": nowTime,
|
|
"comeintime_open": nowTime,
|
|
- "FREEZE_TIME": nowTime,
|
|
|
|
})
|
|
})
|
|
uodateId1 := entity.JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
uodateId1 := entity.JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
@@ -169,10 +168,16 @@ func TransferClue(in *pb.TransferClueReq) (result *pb.BiReply, err error) {
|
|
if clueData != nil && len(*clueData) > 0 {
|
|
if clueData != nil && len(*clueData) > 0 {
|
|
clueId := (*clueData)["id"]
|
|
clueId := (*clueData)["id"]
|
|
userName := common.ObjToString((*clueData)["name"])
|
|
userName := common.ObjToString((*clueData)["name"])
|
|
- nowTime := time.Now()
|
|
|
|
- if entity.JyBiTidb.Count("dwd_f_csm_customer_info", bson.M{"clue_id": clueId}) > 0 {
|
|
|
|
- csmdata := entity.JyBiTidb.FindOne("dwd_f_csm_customer_info", bson.M{"clue_id": clueId}, "", "")
|
|
|
|
- if csmdata != nil && len(*csmdata) > 0 {
|
|
|
|
|
|
+ nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
|
+ csmdata := entity.JyBiTidb.FindOne("dwd_f_csm_customer_info", bson.M{"clue_id": clueId}, "", "")
|
|
|
|
+ if csmdata != nil && len(*csmdata) > 0 {
|
|
|
|
+ if common.IntAll((*csmdata)["is_transfer"]) == 0 {
|
|
|
|
+ return &pb.BiReply{
|
|
|
|
+ ErrorCode: 0,
|
|
|
|
+ ErrorMsg: "线索已经移交至客成",
|
|
|
|
+ Data: gconv.Bytes(bson.M{"id": clueId}),
|
|
|
|
+ }, nil
|
|
|
|
+ } else {
|
|
entity.JyBiTidb.Update("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, bson.M{
|
|
entity.JyBiTidb.Update("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, bson.M{
|
|
"is_transfer": 0,
|
|
"is_transfer": 0,
|
|
"is_renewal_protection": 0,
|
|
"is_renewal_protection": 0,
|
|
@@ -194,12 +199,12 @@ func TransferClue(in *pb.TransferClueReq) (result *pb.BiReply, err error) {
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
entity.JyBiTidb.Update("dwd_f_crm_clue_info", bson.M{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
|
|
entity.JyBiTidb.Update("dwd_f_crm_clue_info", bson.M{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
|
|
|
|
+ return &pb.BiReply{
|
|
|
|
+ ErrorCode: 0,
|
|
|
|
+ ErrorMsg: "线索移交成功",
|
|
|
|
+ Data: gconv.Bytes(bson.M{"id": clueId}),
|
|
|
|
+ }, nil
|
|
}
|
|
}
|
|
- return &pb.BiReply{
|
|
|
|
- ErrorCode: 0,
|
|
|
|
- ErrorMsg: "线索移交成功",
|
|
|
|
- Data: gconv.Bytes(bson.M{"id": clueId}),
|
|
|
|
- }, nil
|
|
|
|
} else {
|
|
} else {
|
|
saveMap := map[string]interface{}{
|
|
saveMap := map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
@@ -223,11 +228,11 @@ func TransferClue(in *pb.TransferClueReq) (result *pb.BiReply, err error) {
|
|
"service_stage": 1,
|
|
"service_stage": 1,
|
|
"company_name": company_name,
|
|
"company_name": company_name,
|
|
}
|
|
}
|
|
- cId, ok, updateId1, updateId2, updateId3 := int64(-1), false, int64(-1), int64(-1), int64(-1)
|
|
|
|
|
|
+ cId, ok, updateId1 := int64(-1), false, int64(-1)
|
|
if entity.JyBiTidb.ExecTx("保存客户", func(tx *sql.Tx) bool {
|
|
if entity.JyBiTidb.ExecTx("保存客户", func(tx *sql.Tx) bool {
|
|
cId = entity.JyBiTidb.InsertByTx(tx, "dwd_f_csm_customer_info", saveMap)
|
|
cId = entity.JyBiTidb.InsertByTx(tx, "dwd_f_csm_customer_info", saveMap)
|
|
ok = entity.JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
|
|
ok = entity.JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
|
|
- updateId2 = entity.JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
|
|
+ updateId1 = entity.JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
"position_id": in.PositionId,
|
|
"position_id": in.PositionId,
|
|
"change_type": "成交客户移交",
|
|
"change_type": "成交客户移交",
|
|
@@ -236,7 +241,7 @@ func TransferClue(in *pb.TransferClueReq) (result *pb.BiReply, err error) {
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
- return cId > -1 && ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1
|
|
|
|
|
|
+ return cId > -1 && ok && updateId1 > -1
|
|
}) {
|
|
}) {
|
|
return &pb.BiReply{
|
|
return &pb.BiReply{
|
|
ErrorCode: 0,
|
|
ErrorCode: 0,
|
|
@@ -246,7 +251,7 @@ func TransferClue(in *pb.TransferClueReq) (result *pb.BiReply, err error) {
|
|
} else {
|
|
} else {
|
|
return &pb.BiReply{
|
|
return &pb.BiReply{
|
|
ErrorCode: -1,
|
|
ErrorCode: -1,
|
|
- ErrorMsg: "线索查询失败",
|
|
|
|
|
|
+ ErrorMsg: "线索移交失败",
|
|
Data: nil,
|
|
Data: nil,
|
|
}, nil
|
|
}, nil
|
|
}
|
|
}
|