|
@@ -6,7 +6,6 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"io/ioutil"
|
|
|
- "log"
|
|
|
"math"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
@@ -23,6 +22,7 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/es"
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
|
|
|
+ "github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
|
|
|
|
|
const (
|
|
@@ -70,19 +70,19 @@ func ClueImportTtSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
id_new := common.GetMd5String(fmt.Sprintf("%s_%d", common.ObjToString(v["id"]), common.Int64All(v["multipackage_id"])))
|
|
|
v["id_new"] = id_new
|
|
|
if BiService.Count("customer_data_ttzl", map[string]interface{}{"id_new": id_new}) > 0 {
|
|
|
- log.Println("数据重复", id)
|
|
|
+ logx.Info("数据重复", id)
|
|
|
return
|
|
|
}
|
|
|
if dataId := BiService.Insert("customer_data_ttzl", v); dataId > 0 {
|
|
|
if details, ok := CreateEs(v); ok {
|
|
|
BiService.Insert("customer_data_ttzl_gl", map[string]interface{}{"msg_id": dataId, "info_id": id, "details": details, "isHistory": "否"})
|
|
|
atomic.AddInt64(&counts, 1)
|
|
|
- log.Println("es存入成功", id)
|
|
|
+ logx.Info("es存入成功", id)
|
|
|
} else {
|
|
|
- log.Println("es存入失败!!", id)
|
|
|
+ logx.Info("es存入失败!!", id)
|
|
|
}
|
|
|
} else {
|
|
|
- log.Println("tidb存入失败!!", id)
|
|
|
+ logx.Info("tidb存入失败!!", id)
|
|
|
}
|
|
|
}(v)
|
|
|
}
|
|
@@ -107,7 +107,7 @@ func ClueImportTtSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
func CreateEsById(newId string) bool {
|
|
|
data := BiService.FindOne("customer_data_ttzl", map[string]interface{}{"id_new": newId}, "", "")
|
|
|
if data == nil || len(*data) == 0 {
|
|
|
- log.Println("没有找到该数据", newId)
|
|
|
+ logx.Info("没有找到该数据", newId)
|
|
|
return false
|
|
|
}
|
|
|
_, ok := CreateEs(*data)
|
|
@@ -144,7 +144,7 @@ func CreateEs(v map[string]interface{}) (string, bool) {
|
|
|
client.Delete().Index("ttbid").Id(newId).Refresh("true").Do(context.TODO())
|
|
|
_, err := client.Index().Index("ttbid").Id(newId).BodyJson(v).Refresh("true").Do(context.TODO())
|
|
|
if err != nil {
|
|
|
- log.Println("保存到ES出错", err.Error())
|
|
|
+ logx.Info("保存到ES出错", err.Error())
|
|
|
return details, false
|
|
|
} else {
|
|
|
return details, true
|
|
@@ -157,7 +157,7 @@ func DelById(index, id string) bool {
|
|
|
defer esV7.DestoryEsConn(client)
|
|
|
_, err := client.Delete().Index(index).Id(id).Refresh("true").Do(context.TODO())
|
|
|
if err != nil {
|
|
|
- log.Println("删除es出错:", id, err)
|
|
|
+ logx.Info("删除es出错:", id, err)
|
|
|
return false
|
|
|
}
|
|
|
return true
|
|
@@ -214,7 +214,7 @@ func ClueAdd(this *biservice.ClueAddReq, col string) *biservice.AddProjectResp {
|
|
|
bs, err := doGet(url)
|
|
|
if err != nil {
|
|
|
status = -1
|
|
|
- log.Println("调用接口失败")
|
|
|
+ logx.Info("调用接口失败")
|
|
|
} else {
|
|
|
resMap := common.StringToMap(string(bs))
|
|
|
if resMap["success"] != nil && resMap["success"].(bool) {
|
|
@@ -235,7 +235,7 @@ func ClueAdd(this *biservice.ClueAddReq, col string) *biservice.AddProjectResp {
|
|
|
|
|
|
func DistributeClue(this *biservice.DistributeClueReq) *biservice.AddProjectResp {
|
|
|
count, status := DistributeClueSync(this)
|
|
|
- log.Println("分配数量 ", count)
|
|
|
+ logx.Info("分配数量 ", count)
|
|
|
return &biservice.AddProjectResp{
|
|
|
ErrorCode: 0,
|
|
|
Data: &biservice.AddProject{
|
|
@@ -249,7 +249,7 @@ func getToken() string {
|
|
|
url := "https://a1.7x24cc.com/accessToken?account=N000000029739&appid=w4w2ex0bnt1n61or&secret=3c8f7dd04d2c11edb786132b38c4d48a"
|
|
|
bs, err := doGet(url)
|
|
|
if err != nil {
|
|
|
- log.Println("token生成失败", err)
|
|
|
+ logx.Info("token生成失败", err)
|
|
|
return ""
|
|
|
}
|
|
|
tokenMap := common.StringToMap(string(bs))
|
|
@@ -387,7 +387,7 @@ func DistributeClueMore(saleMap map[string]map[string]interface{}, distributedAr
|
|
|
"operator_id": thispositionId,
|
|
|
})
|
|
|
} else {
|
|
|
- log.Println("私海修改失败 ", v, positionId, seatNumber)
|
|
|
+ logx.Info("私海修改失败 ", v, positionId, seatNumber)
|
|
|
}
|
|
|
} else {
|
|
|
updateClue := map[string]interface{}{
|
|
@@ -477,7 +477,7 @@ func DistributeClueMore(saleMap map[string]map[string]interface{}, distributedAr
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
- log.Println("私海插入失败 ", v, positionId, seatNumber)
|
|
|
+ logx.Info("私海插入失败 ", v, positionId, seatNumber)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -488,7 +488,7 @@ func DistributeClueMore(saleMap map[string]map[string]interface{}, distributedAr
|
|
|
|
|
|
func DrawClue(this *biservice.DrawClueReq) *biservice.AddProjectResp {
|
|
|
count, status := DrawClueSync(this)
|
|
|
- log.Println("领取数量 ", count)
|
|
|
+ logx.Info("领取数量 ", count)
|
|
|
return &biservice.AddProjectResp{
|
|
|
ErrorCode: 0,
|
|
|
Data: &biservice.AddProject{
|
|
@@ -524,8 +524,8 @@ func DrawClueSync(this *biservice.DrawClueReq) (int, int) {
|
|
|
counts3 += counts2 - count2
|
|
|
counts2 = count2
|
|
|
}
|
|
|
- log.Println(count1, count2)
|
|
|
- log.Println(counts1, counts2, counts3)
|
|
|
+ logx.Info(count1, count2)
|
|
|
+ logx.Info(counts1, counts2, counts3)
|
|
|
return DrawClues(this.PositionId, counts1, counts2, counts3), 1
|
|
|
} else {
|
|
|
return 0, 2
|
|
@@ -586,13 +586,15 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
|
|
|
drawCount += count
|
|
|
}
|
|
|
//
|
|
|
+ logx.Info("count1,count2,count3 ", count1, count2, count3, drawCount)
|
|
|
if count1 > 0 {
|
|
|
counts, counts1 := 0, 0
|
|
|
for {
|
|
|
- counts1++
|
|
|
+ logx.Info("等级1线索领取", count1, counts1, counts)
|
|
|
data := JyBiTidb.SelectBySql(`SELECT max(c.createTime) as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
|
LEFT JOIN Call_Accounting.voice_record c ON c.CalledNo = a.phone
|
|
|
- WHERE a.level_open = 1 AND a.is_assign = 0 AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit 1`)
|
|
|
+ WHERE a.level_open = 1 AND a.is_assign = 0 AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit ?,1`, counts1)
|
|
|
+ counts1++
|
|
|
if data != nil && len(*data) > 0 {
|
|
|
count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
|
|
|
if count > 0 {
|
|
@@ -605,6 +607,7 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
|
|
|
}
|
|
|
if counts1 > 5*int(count1) {
|
|
|
count2 += count1 - int64(counts)
|
|
|
+ drawCount += int(counts)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
@@ -612,10 +615,11 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
|
|
|
if count2 > 0 {
|
|
|
counts, counts1 := 0, 0
|
|
|
for {
|
|
|
- counts1++
|
|
|
- data := JyBiTidb.SelectBySql(`SELECT max(c.createTime) as ctime,a.id,a.trailstatus FROM dwd_f_crm_clue_info a
|
|
|
+ logx.Info("等级2线索领取", count2, counts1, counts)
|
|
|
+ data := JyBiTidb.SelectBySql(`SELECT max(c.createTime) as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
|
LEFT JOIN Call_Accounting.voice_record c ON c.CalledNo = a.phone
|
|
|
- WHERE a.level_open = 2 AND a.is_assign = 0 AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit 1`)
|
|
|
+ WHERE a.level_open = 2 AND a.is_assign = 0 AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit ?,1`, counts1)
|
|
|
+ counts1++
|
|
|
if data != nil && len(*data) > 0 {
|
|
|
count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
|
|
|
if count > 0 {
|
|
@@ -628,6 +632,7 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
|
|
|
}
|
|
|
if counts1 > 5*int(count2) {
|
|
|
count3 += count2 - int64(counts)
|
|
|
+ drawCount += int(counts)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
@@ -635,10 +640,11 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
|
|
|
if count3 > 0 {
|
|
|
counts, counts1 := 0, 0
|
|
|
for {
|
|
|
- counts1++
|
|
|
- data := JyBiTidb.SelectBySql(`SELECT max(c.createTime) as ctime,a.id,a.trailstatus FROM dwd_f_crm_clue_info a
|
|
|
+ logx.Info("等级3线索领取", count3, counts1, counts)
|
|
|
+ data := JyBiTidb.SelectBySql(`SELECT max(c.createTime) as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
|
LEFT JOIN Call_Accounting.voice_record c ON c.CalledNo = a.phone
|
|
|
- WHERE a.level_open = 3 AND a.is_assign = 0 AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit 1`)
|
|
|
+ WHERE a.level_open = 3 AND a.is_assign = 0 AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit ?,1`, counts1)
|
|
|
+ counts1++
|
|
|
if data != nil && len(*data) > 0 {
|
|
|
count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
|
|
|
if count > 0 {
|
|
@@ -649,6 +655,10 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
|
|
|
drawCount += int(count3)
|
|
|
break
|
|
|
}
|
|
|
+ if counts1 > 5*int(count3) {
|
|
|
+ drawCount += int(counts)
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return drawCount
|
|
@@ -664,6 +674,7 @@ func batchDraw(data []map[string]interface{}, nowTime, seatNumber, name string,
|
|
|
if cdata != nil && len(*cdata) > 0 {
|
|
|
salePositionId := common.Int64All((*cdata)["position_id"])
|
|
|
if pcount := JyBiMysql.Count("dwd_f_crm_personnel_management", map[string]interface{}{"resign": 0, "position_id": salePositionId}); pcount > 0 {
|
|
|
+ logx.Info("当前线索有在职销售 ", clueId, cluename)
|
|
|
return count
|
|
|
} else {
|
|
|
saledata := JyBiMysql.SelectBySql(`SELECT position_id from dwd_d_crm_department_level_succbi WHERE bi_pcode in (SELECT bi_pcode from dwd_d_crm_department_level_succbi WHERE position_id = ?) AND resign = 0`, salePositionId)
|
|
@@ -676,6 +687,7 @@ func batchDraw(data []map[string]interface{}, nowTime, seatNumber, name string,
|
|
|
}
|
|
|
}
|
|
|
if !isOk {
|
|
|
+ logx.Info("当前线索销售离职,只能同部门领取 ", clueId, cluename)
|
|
|
return count
|
|
|
}
|
|
|
}
|
|
@@ -758,10 +770,10 @@ func batchDraw(data []map[string]interface{}, nowTime, seatNumber, name string,
|
|
|
}
|
|
|
return ok1 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > -1 && recordId4 > -1
|
|
|
}) {
|
|
|
- log.Println("领取线索成功")
|
|
|
+ logx.Info("领取线索成功")
|
|
|
count++
|
|
|
} else {
|
|
|
- log.Println("领取线索失败")
|
|
|
+ logx.Info("领取线索失败")
|
|
|
}
|
|
|
}
|
|
|
return count
|
|
@@ -1214,6 +1226,6 @@ func doGet(url string) ([]byte, error) {
|
|
|
defer func() {
|
|
|
_ = resp.Body.Close()
|
|
|
}()
|
|
|
- log.Println(url, "调用结果 ", string(bs))
|
|
|
+ logx.Info(url, "调用结果 ", string(bs))
|
|
|
return bs, nil
|
|
|
}
|