|
@@ -4,7 +4,6 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
|
elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
- "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
"app.yhyue.com/moapp/jypkg/ent/util"
|
|
|
"app.yhyue.com/moapp/jypkg/public"
|
|
|
MC "bp.jydev.jianyu360.cn/CRM/application/api/common"
|
|
@@ -32,7 +31,6 @@ type EmPloyService struct{}
|
|
|
func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) []map[string]interface{} {
|
|
|
data := []map[string]interface{}{}
|
|
|
for _, v := range strings.Split(in.IdArr, ",") {
|
|
|
- vint := int64(0)
|
|
|
table, findKey, employKey, source := EmployKeyFormat(in.EmployType)
|
|
|
id := ""
|
|
|
id = IdFormat(v, in.EmployType)
|
|
@@ -44,46 +42,51 @@ func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) []map[string
|
|
|
"id": v,
|
|
|
}
|
|
|
//有收录情况
|
|
|
- summaryMap := SummaryFormat(in.PositionId)
|
|
|
+ //summaryMap := SummaryFormat(in.PositionId)
|
|
|
//vint = mongodb.StringTOBsonId(id).Timestamp().Unix()
|
|
|
- vint = extractNumbers(id)
|
|
|
- valueMap["isEmploy"] = summaryMap[in.EmployType].Contains(uint32(vint))
|
|
|
+ //vint = extractNumbers(id)
|
|
|
+ //valueMap["isEmploy"] = summaryMap[in.EmployType].Contains(uint32(vint))
|
|
|
+ employData := MC.CrmMysql.FindOne(table, map[string]interface{}{
|
|
|
+ employKey: id,
|
|
|
+ "position_id": in.PositionId,
|
|
|
+ "source": source,
|
|
|
+ }, "", "")
|
|
|
+ if employData != nil && len(*employData) > 0 {
|
|
|
+ valueMap["isIgnore"] = common.If(common.Int64All((*employData)["is_ignore"]) == 1, true, false)
|
|
|
+ valueMap["isEmploy"] = common.If(common.Int64All((*employData)["status"]) == 1, true, false)
|
|
|
+ } else {
|
|
|
+ valueMap["isIgnore"] = false
|
|
|
+ valueMap["isEmploy"] = false
|
|
|
+ }
|
|
|
+
|
|
|
if len(strings.Split(in.IdArr, ",")) == 1 {
|
|
|
//列表查询
|
|
|
//是否忽略处理
|
|
|
- employData := MC.CrmMysql.FindOne(table, map[string]interface{}{
|
|
|
- employKey: id,
|
|
|
+ //客户数量
|
|
|
+ customCount := MC.CrmMysql.Count(entity.CUSTOM, map[string]interface{}{
|
|
|
+ findKey: id,
|
|
|
"position_id": in.PositionId,
|
|
|
- "source": source,
|
|
|
- }, "", "")
|
|
|
- if employData != nil && len(*employData) > 0 {
|
|
|
- valueMap["isIgnore"] = common.If(common.Int64All((*employData)["is_ignore"]) == 1, true, false)
|
|
|
- //客户数量
|
|
|
- customCount := MC.CrmMysql.Count(entity.CUSTOM, map[string]interface{}{
|
|
|
- findKey: id,
|
|
|
- "position_id": in.PositionId,
|
|
|
+ })
|
|
|
+ valueMap["customCount"] = customCount
|
|
|
+ if in.EmployType == 1 || in.EmployType == 4 {
|
|
|
+ //销售线索数量
|
|
|
+ clueCount := MC.CrmMysql.Count(entity.SALE_CLUE, map[string]interface{}{
|
|
|
+ "employ_info_id": id,
|
|
|
+ "position_id": in.PositionId,
|
|
|
})
|
|
|
- valueMap["customCount"] = customCount
|
|
|
- if in.EmployType == 1 || in.EmployType == 4 {
|
|
|
- //销售线索数量
|
|
|
- clueCount := MC.CrmMysql.Count(entity.SALE_CLUE, map[string]interface{}{
|
|
|
- "employ_info_id": id,
|
|
|
- "position_id": in.PositionId,
|
|
|
- })
|
|
|
- valueMap["clueCount"] = clueCount
|
|
|
- //销售机会数量
|
|
|
- chanceCount := MC.CrmMysql.Count(entity.SALE_CHANCE, map[string]interface{}{
|
|
|
- "employ_info_id": id,
|
|
|
- "position_id": in.PositionId,
|
|
|
- })
|
|
|
- valueMap["chanceCount"] = chanceCount
|
|
|
- }
|
|
|
- } else {
|
|
|
- valueMap["chanceCount"] = 0
|
|
|
- valueMap["clueCount"] = 0
|
|
|
- valueMap["isIgnore"] = false
|
|
|
- valueMap["customCount"] = 0
|
|
|
+ valueMap["clueCount"] = clueCount
|
|
|
+ //销售机会数量
|
|
|
+ chanceCount := MC.CrmMysql.Count(entity.SALE_CHANCE, map[string]interface{}{
|
|
|
+ "employ_info_id": id,
|
|
|
+ "position_id": in.PositionId,
|
|
|
+ })
|
|
|
+ valueMap["chanceCount"] = chanceCount
|
|
|
}
|
|
|
+ } else {
|
|
|
+ valueMap["chanceCount"] = 0
|
|
|
+ valueMap["clueCount"] = 0
|
|
|
+ valueMap["isIgnore"] = false
|
|
|
+ valueMap["customCount"] = 0
|
|
|
}
|
|
|
data = append(data, valueMap)
|
|
|
}
|
|
@@ -94,9 +97,8 @@ func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) []map[string
|
|
|
func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) bool {
|
|
|
//收录汇总表
|
|
|
table, _, employKey, source := EmployKeyFormat(in.EmployType)
|
|
|
- summaryMap := SummaryFormat(in.PositionId)
|
|
|
+ //summaryMap := SummaryFormat(in.PositionId)
|
|
|
return MC.CrmMysql.ExecTx("收录操作", func(tx *sql.Tx) bool {
|
|
|
- fool := false
|
|
|
for _, v1 := range strings.Split(in.IdArr, ",") {
|
|
|
//id转中文
|
|
|
id := ""
|
|
@@ -141,21 +143,21 @@ func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) bool {
|
|
|
log.Println(v1, id, in.EmployType, "取消收录失败")
|
|
|
}
|
|
|
}
|
|
|
- //收录汇总表处理
|
|
|
+ /*//收录汇总表处理
|
|
|
vint := extractNumbers(id)
|
|
|
if in.IsEmploy {
|
|
|
summaryMap[in.EmployType].Add(uint32(vint))
|
|
|
} else {
|
|
|
summaryMap[in.EmployType].Remove(uint32(vint))
|
|
|
- }
|
|
|
- fool = true
|
|
|
+ }*/
|
|
|
+ //fool = true
|
|
|
}
|
|
|
- if fool {
|
|
|
+ /*if fool {
|
|
|
return SummarySave(tx, in.PositionId, summaryMap)
|
|
|
} else {
|
|
|
return false
|
|
|
- }
|
|
|
-
|
|
|
+ }*/
|
|
|
+ return true
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -208,12 +210,7 @@ func InfoFind(id string, employType int64) map[string]interface{} {
|
|
|
obj = *aobj
|
|
|
}
|
|
|
if ok && obj != nil && len(obj) > 0 {
|
|
|
- titleTmp := common.ObjToString(obj["title"])
|
|
|
- if len([]rune(titleTmp)) > 100 {
|
|
|
- titleTmp = string([]rune(titleTmp)[:100]) + "..."
|
|
|
- }
|
|
|
- titleTmp = public.ClearHtml.ReplaceAllString(titleTmp, "")
|
|
|
- data["title"] = titleTmp
|
|
|
+ data["title"] = common.ObjToString(obj["title"])
|
|
|
data["city"] = obj["city"]
|
|
|
data["area"] = obj["area"]
|
|
|
data["subtype"] = obj["subtype"]
|
|
@@ -257,6 +254,8 @@ func InfoFind(id string, employType int64) map[string]interface{} {
|
|
|
data["create_time"] = time.Now().Format(date.Date_Full_Layout)
|
|
|
return data
|
|
|
}
|
|
|
+
|
|
|
+// 通过采购单位名称获取id
|
|
|
func getBuyerIdByName(buyeName string) (buyerId string) {
|
|
|
r := elastic.Get(BuyerIndex, BuyerType, fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"buyer_name":"%s"}}]}},"size":1,"_source":["city","id"]}`, buyeName))
|
|
|
if r == nil || len(*r) == 0 {
|
|
@@ -265,6 +264,8 @@ func getBuyerIdByName(buyeName string) (buyerId string) {
|
|
|
buyerId, _ = (*r)[0]["_id"].(string)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// id解密
|
|
|
func IdFormat(encryptionId string, employType int64) string {
|
|
|
decryptId := ""
|
|
|
switch employType {
|
|
@@ -282,6 +283,8 @@ func IdFormat(encryptionId string, employType int64) string {
|
|
|
}
|
|
|
return decryptId
|
|
|
}
|
|
|
+
|
|
|
+// 汇总表处理
|
|
|
func SummaryFormat(positionId int64) map[int64]*roaring.Bitmap {
|
|
|
byte1 := []byte{}
|
|
|
byte2 := []byte{}
|
|
@@ -311,6 +314,8 @@ func SummaryFormat(positionId int64) map[int64]*roaring.Bitmap {
|
|
|
data[4] = rb4
|
|
|
return data
|
|
|
}
|
|
|
+
|
|
|
+// 汇总表保存
|
|
|
func SummarySave(tx *sql.Tx, positionId int64, data map[int64]*roaring.Bitmap) bool {
|
|
|
employSummaryData := MC.CrmMysql.FindOne(entity.EMPLOY_SUMMARY, map[string]interface{}{
|
|
|
"position_id": positionId,
|
|
@@ -420,13 +425,12 @@ func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
|
|
|
for _, person := range in.Person {
|
|
|
personMap[person.PositionId] = PersonSmmary{
|
|
|
EntUserId: person.EntUserId,
|
|
|
- Summary: SummaryFormat(person.PositionId),
|
|
|
+ //Summary: SummaryFormat(person.PositionId),
|
|
|
}
|
|
|
}
|
|
|
//分发数据处理
|
|
|
infoMap := map[string]map[string]interface{}{}
|
|
|
for positionId, personSmmary := range personMap {
|
|
|
- fool := false
|
|
|
for _, v := range strings.Split(in.EmployIdArr, ",") {
|
|
|
VMap := map[string]interface{}{}
|
|
|
if infoMap[v] == nil {
|
|
@@ -472,17 +476,18 @@ func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
|
|
|
VMap["ent_user_id"] = personSmmary.EntUserId
|
|
|
VMap["position_id"] = positionId
|
|
|
ok := MC.CrmMysql.InsertByTx(tx, entity.EMPLOY_INFO, VMap)
|
|
|
- if ok > 0 {
|
|
|
+ return ok > 0
|
|
|
+ /*if ok > 0 {
|
|
|
employType := common.If(common.Int64All(VMap["source"]) == 1, 1, 4)
|
|
|
personSmmary.Summary[common.Int64All(employType)].Add(uint32(mongodb.StringTOBsonId(common.InterfaceToStr(VMap["source_id"])).Timestamp().Unix()))
|
|
|
fool = true
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
- if fool {
|
|
|
+ /*if fool {
|
|
|
if !SummarySave(tx, positionId, personSmmary.Summary) {
|
|
|
return false
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
}
|
|
|
return true
|