|
@@ -24,6 +24,7 @@ func CreateClue(in *pb.CreateCuleReq) (result *pb.BiReply, err error) {
|
|
|
}, nil
|
|
|
}
|
|
|
uId := common.ObjToString((*info)["baseinfo_id"])
|
|
|
+ userId := ""
|
|
|
clueInfo := entity.JyBiTidb.FindOne("dwd_f_crm_clue_info", bson.M{"uid": uId}, "", "")
|
|
|
if clueInfo == nil || len(*clueInfo) == 0 {
|
|
|
return &pb.BiReply{
|
|
@@ -32,12 +33,17 @@ func CreateClue(in *pb.CreateCuleReq) (result *pb.BiReply, err error) {
|
|
|
Data: nil,
|
|
|
}, nil
|
|
|
}
|
|
|
+ userInfo := entity.JyBiTidb.FindOne("dwd_f_userbase_baseinfo", bson.M{"phone": in.Phone}, "userid", "")
|
|
|
+ if userInfo != nil && len(*userInfo) > 0 {
|
|
|
+ userId = common.ObjToString((*userInfo)["userid"])
|
|
|
+ }
|
|
|
isGroup, isCommerce := CompanyType(in.Phone) //判断是否集团公司、工商库
|
|
|
clueId := int64(0)
|
|
|
if entity.JyBiTidb.ExecTx("保存线索", func(tx *sql.Tx) bool {
|
|
|
nowTime := time.Now()
|
|
|
+ BCPCID := common.GetRandom(32)
|
|
|
clueId = entity.JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
- "userid": in.UserId,
|
|
|
+ "userid": userId,
|
|
|
"uid": uId,
|
|
|
"is_assign": 0,
|
|
|
"createtime": nowTime,
|
|
@@ -59,11 +65,35 @@ func CreateClue(in *pb.CreateCuleReq) (result *pb.BiReply, err error) {
|
|
|
"change_type": "创建线索",
|
|
|
"new_value": "系统自动创建",
|
|
|
"createtime": nowTime,
|
|
|
- "BCPCID": common.GetRandom(32),
|
|
|
+ "BCPCID": BCPCID,
|
|
|
"operator_id": -1,
|
|
|
"change_reason": "根据手机号创建线索(接口)",
|
|
|
})
|
|
|
- return clueId > -1 && uodateId1 > -1
|
|
|
+ uodateId2 := entity.JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "change_field": "top_cluetype",
|
|
|
+ "position_id": -1,
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": "/",
|
|
|
+ "new_value": "新增注册",
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": BCPCID,
|
|
|
+ "operator_id": -1,
|
|
|
+ "change_reason": "根据手机号创建线索(接口)",
|
|
|
+ })
|
|
|
+ uodateId3 := entity.JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "change_field": "sub_cluetype",
|
|
|
+ "position_id": 0,
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": "/",
|
|
|
+ "new_value": "新增注册用户",
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": BCPCID,
|
|
|
+ "operator_id": -1,
|
|
|
+ "change_reason": "根据手机号创建线索(接口)",
|
|
|
+ })
|
|
|
+ return clueId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1
|
|
|
}) {
|
|
|
return &pb.BiReply{
|
|
|
ErrorCode: 0,
|
|
@@ -216,10 +246,11 @@ func TransferClue(in *pb.TransferClueReq) (result *pb.BiReply, err error) {
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ return &pb.BiReply{
|
|
|
+ ErrorCode: -1,
|
|
|
+ ErrorMsg: "线索查询失败",
|
|
|
+ Data: nil,
|
|
|
+ }, nil
|
|
|
}
|
|
|
- return &pb.BiReply{
|
|
|
- ErrorCode: -1,
|
|
|
- ErrorMsg: "线索查询失败",
|
|
|
- Data: nil,
|
|
|
- }, nil
|
|
|
}
|