|
@@ -2,6 +2,7 @@ package service
|
|
|
|
|
|
import (
|
|
import (
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
"bp.jydev.jianyu360.cn/BaseService/biService/entity"
|
|
"bp.jydev.jianyu360.cn/BaseService/biService/entity"
|
|
"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
|
|
"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
|
|
"database/sql"
|
|
"database/sql"
|
|
@@ -119,17 +120,30 @@ func TransferClue(in *pb.TransferClueReq) (result *pb.BiReply, err error) {
|
|
query["phone"] = in.Phone
|
|
query["phone"] = in.Phone
|
|
}
|
|
}
|
|
orderInfo := entity.JyBiTidb.FindOne("dwd_f_userbase_order_info", query, "", "")
|
|
orderInfo := entity.JyBiTidb.FindOne("dwd_f_userbase_order_info", query, "", "")
|
|
- if orderInfo == nil && len(*orderInfo) == 0 {
|
|
|
|
|
|
+ if orderInfo == nil || len(*orderInfo) == 0 {
|
|
return &pb.BiReply{
|
|
return &pb.BiReply{
|
|
ErrorCode: -1,
|
|
ErrorCode: -1,
|
|
ErrorMsg: "订单编号或手机号不存在",
|
|
ErrorMsg: "订单编号或手机号不存在",
|
|
Data: nil,
|
|
Data: nil,
|
|
}, nil
|
|
}, nil
|
|
}
|
|
}
|
|
|
|
+
|
|
uId = common.ObjToString((*orderInfo)["uid"])
|
|
uId = common.ObjToString((*orderInfo)["uid"])
|
|
company_name := common.ObjToString((*orderInfo)["company_name"])
|
|
company_name := common.ObjToString((*orderInfo)["company_name"])
|
|
starttime := common.ObjToString((*orderInfo)["vip_starttime"])
|
|
starttime := common.ObjToString((*orderInfo)["vip_starttime"])
|
|
endtime := common.ObjToString((*orderInfo)["vip_endtime"])
|
|
endtime := common.ObjToString((*orderInfo)["vip_endtime"])
|
|
|
|
+ t, _ := time.Parse(date.Date_Full_Layout, endtime)
|
|
|
|
+
|
|
|
|
+ isExpired := false // 即将过期
|
|
|
|
+ if time.Now().Unix() > t.Unix()+3*30*24*3600 {
|
|
|
|
+ return &pb.BiReply{
|
|
|
|
+ ErrorCode: 1,
|
|
|
|
+ ErrorMsg: "订单已经过期",
|
|
|
|
+ Data: nil,
|
|
|
|
+ }, nil
|
|
|
|
+ } else if t.Unix() > time.Now().Unix() && time.Now().Unix()+3*30*24*3600 > t.Unix() {
|
|
|
|
+ isExpired = true
|
|
|
|
+ }
|
|
buy_subject := common.IntAll((*orderInfo)["buy_subject"])
|
|
buy_subject := common.IntAll((*orderInfo)["buy_subject"])
|
|
product_type := common.ObjToString((*orderInfo)["product_type"])
|
|
product_type := common.ObjToString((*orderInfo)["product_type"])
|
|
data_spec := common.ObjToString((*orderInfo)["data_spec"])
|
|
data_spec := common.ObjToString((*orderInfo)["data_spec"])
|
|
@@ -189,19 +203,20 @@ func TransferClue(in *pb.TransferClueReq) (result *pb.BiReply, err error) {
|
|
"company_name": company_name,
|
|
"company_name": company_name,
|
|
})
|
|
})
|
|
entity.JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
entity.JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
- "clue_id": clueId,
|
|
|
|
- "position_id": (*csmdata)["position_id"],
|
|
|
|
- "change_type": "成交客户移交",
|
|
|
|
- "new_value": "移交至客户成功组",
|
|
|
|
- "createtime": nowTime,
|
|
|
|
- "BCPCID": common.GetRandom(32),
|
|
|
|
- "operator_id": -1,
|
|
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": (*csmdata)["position_id"],
|
|
|
|
+ "change_type": "成交客户移交",
|
|
|
|
+ "new_value": "移交至客户成功组",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ "change_reason": "根据手机号或者订单号移交线索(接口)",
|
|
})
|
|
})
|
|
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{
|
|
return &pb.BiReply{
|
|
ErrorCode: 0,
|
|
ErrorCode: 0,
|
|
ErrorMsg: "线索移交成功",
|
|
ErrorMsg: "线索移交成功",
|
|
- Data: gconv.Bytes(bson.M{"id": clueId}),
|
|
|
|
|
|
+ Data: gconv.Bytes(bson.M{"id": clueId, "isExpired": isExpired}),
|
|
}, nil
|
|
}, nil
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -232,20 +247,21 @@ func TransferClue(in *pb.TransferClueReq) (result *pb.BiReply, err error) {
|
|
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})
|
|
updateId1 = 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,
|
|
|
|
- "position_id": in.PositionId,
|
|
|
|
- "change_type": "成交客户移交",
|
|
|
|
- "new_value": "移交至客户成功组",
|
|
|
|
- "createtime": nowTime,
|
|
|
|
- "BCPCID": common.GetRandom(32),
|
|
|
|
- "operator_id": -1,
|
|
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": in.PositionId,
|
|
|
|
+ "change_type": "成交客户移交",
|
|
|
|
+ "new_value": "移交至客户成功组",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ "change_reason": "根据手机号或者订单号移交线索(接口)",
|
|
})
|
|
})
|
|
return cId > -1 && ok && updateId1 > -1
|
|
return cId > -1 && ok && updateId1 > -1
|
|
}) {
|
|
}) {
|
|
return &pb.BiReply{
|
|
return &pb.BiReply{
|
|
ErrorCode: 0,
|
|
ErrorCode: 0,
|
|
ErrorMsg: "线索移交成功",
|
|
ErrorMsg: "线索移交成功",
|
|
- Data: gconv.Bytes(bson.M{"id": clueId}),
|
|
|
|
|
|
+ Data: gconv.Bytes(bson.M{"id": clueId, "isExpired": isExpired}),
|
|
}, nil
|
|
}, nil
|
|
} else {
|
|
} else {
|
|
return &pb.BiReply{
|
|
return &pb.BiReply{
|