|
@@ -1,16 +1,9 @@
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
- "app.yhyue.com/moapp/jybase/common"
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
- "app.yhyue.com/moapp/jybase/log"
|
|
|
- "app.yhyue.com/moapp/jybase/mail"
|
|
|
"cmplatform/util"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
- "go.mongodb.org/mongo-driver/bson"
|
|
|
- "go.uber.org/zap"
|
|
|
"io"
|
|
|
"net/http"
|
|
|
"regexp"
|
|
@@ -18,6 +11,14 @@ import (
|
|
|
"strings"
|
|
|
"time"
|
|
|
"unicode/utf8"
|
|
|
+
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
+ "app.yhyue.com/moapp/jybase/log"
|
|
|
+ "app.yhyue.com/moapp/jybase/mail"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
+ "go.uber.org/zap"
|
|
|
)
|
|
|
|
|
|
var (
|
|
@@ -36,127 +37,127 @@ type Private struct {
|
|
|
|
|
|
func (f *Private) Keydatademo(world string) {
|
|
|
tmp := make(map[string]interface{})
|
|
|
- destr := encrypt.SE.DecodeString(world)
|
|
|
+ // destr := encrypt.SE.DecodeString(world)
|
|
|
typeStr := f.GetString("type")
|
|
|
|
|
|
- log.Debug(destr)
|
|
|
- if len(destr) > 10 {
|
|
|
- // ctime := destr[:10]
|
|
|
- // ctimeint := common.Int64All(ctime)
|
|
|
- // if time.Now().Sub(time.Unix(ctimeint, 0)).Hours()/24 < Subday {
|
|
|
- var tagfield *map[string]interface{}
|
|
|
- if typeStr == "private" {
|
|
|
- tagfield, _ = util.Mgo.FindOneByField("cuserdepartrule", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_userid": 1})
|
|
|
- customer, _ := util.Mgo.FindById("cuser", common.ObjToString((*tagfield)["s_userid"]), bson.M{"s_name": 1})
|
|
|
- (*tagfield)["s_customer"] = (*customer)["s_name"]
|
|
|
+ // log.Debug(destr)
|
|
|
+ // if len(destr) > 10 {
|
|
|
+ // ctime := destr[:10]
|
|
|
+ // ctimeint := common.Int64All(ctime)
|
|
|
+ // if time.Now().Sub(time.Unix(ctimeint, 0)).Hours()/24 < Subday {
|
|
|
+ var tagfield *map[string]interface{}
|
|
|
+ if typeStr == "private" {
|
|
|
+ tagfield, _ = util.Mgo.FindOneByField("cuserdepartrule", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_userid": 1})
|
|
|
+ customer, _ := util.Mgo.FindById("cuser", common.ObjToString((*tagfield)["s_userid"]), bson.M{"s_name": 1})
|
|
|
+ (*tagfield)["s_customer"] = (*customer)["s_name"]
|
|
|
+ } else {
|
|
|
+ tagfield, _ = util.Mgo.FindOneByField("tags_common", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_customer": 1})
|
|
|
+ }
|
|
|
+ if (*tagfield) != nil && len(*tagfield) > 0 {
|
|
|
+ if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Standard {
|
|
|
+ tmp["fieldtype"] = util.Standardstr
|
|
|
+ } else if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
|
|
|
+ tmp["fieldtype"] = util.Advancedstr
|
|
|
} else {
|
|
|
- tagfield, _ = util.Mgo.FindOneByField("tags_common", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_customer": 1})
|
|
|
+ f.ServeJson(map[string]string{
|
|
|
+ "err": "参数失效",
|
|
|
+ })
|
|
|
+ return
|
|
|
}
|
|
|
- if (*tagfield) != nil && len(*tagfield) > 0 {
|
|
|
- if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Standard {
|
|
|
- tmp["fieldtype"] = util.Standardstr
|
|
|
- } else if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
|
|
|
- tmp["fieldtype"] = util.Advancedstr
|
|
|
- } else {
|
|
|
- f.ServeJson(map[string]string{
|
|
|
- "err": "参数失效",
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- tmp["total"] = common.Int64All((*tagfield)["i_estotal"])
|
|
|
- tmp["customername"] = common.ObjToString((*tagfield)["s_customer"])
|
|
|
- datas, _ := util.Mgo.Find("tagsdata", bson.M{"s_dataid": world, "esIndex": util.TotalIndex}, `{"publishtime":-1}`, nil, false, -1, -1)
|
|
|
- if (*datas) != nil && len(*datas) > 0 {
|
|
|
- matchskey := make(map[string]bool)
|
|
|
- matchsprovince := make(map[string]bool)
|
|
|
- matchscity := make(map[string]bool)
|
|
|
- rdata := make([]map[string]interface{}, 0)
|
|
|
- for _, v := range *datas {
|
|
|
- for _, mv := range strings.Split(common.ObjToString(v["s_matchkey"]), ",") {
|
|
|
- matchskey[mv] = true
|
|
|
- }
|
|
|
- if v["area"] != nil {
|
|
|
- matchsprovince[common.ObjToString(v["area"])] = true
|
|
|
- }
|
|
|
- if v["city"] != nil {
|
|
|
- matchscity[common.ObjToString(v["city"])] = true
|
|
|
- }
|
|
|
- delete(v, "_id")
|
|
|
- delete(v, "s_dataid")
|
|
|
- delete(v, "i_createtime")
|
|
|
+ tmp["total"] = common.Int64All((*tagfield)["i_estotal"])
|
|
|
+ tmp["customername"] = common.ObjToString((*tagfield)["s_customer"])
|
|
|
+ datas, _ := util.Mgo.Find("tagsdata", bson.M{"s_dataid": world, "esIndex": util.TotalIndex}, `{"publishtime":-1}`, nil, false, -1, -1)
|
|
|
+ if (*datas) != nil && len(*datas) > 0 {
|
|
|
+ matchskey := make(map[string]bool)
|
|
|
+ matchsprovince := make(map[string]bool)
|
|
|
+ matchscity := make(map[string]bool)
|
|
|
+ rdata := make([]map[string]interface{}, 0)
|
|
|
+ for _, v := range *datas {
|
|
|
+ for _, mv := range strings.Split(common.ObjToString(v["s_matchkey"]), ",") {
|
|
|
+ matchskey[mv] = true
|
|
|
+ }
|
|
|
+ if v["area"] != nil {
|
|
|
+ matchsprovince[common.ObjToString(v["area"])] = true
|
|
|
+ }
|
|
|
+ if v["city"] != nil {
|
|
|
+ matchscity[common.ObjToString(v["city"])] = true
|
|
|
+ }
|
|
|
+ delete(v, "_id")
|
|
|
+ delete(v, "s_dataid")
|
|
|
+ delete(v, "i_createtime")
|
|
|
|
|
|
- if v["bidamount"] != nil {
|
|
|
- v["bidamount"] = common.Float64All(fmt.Sprintf("%f", common.Float64All(v["bidamount"])/10000))
|
|
|
- }
|
|
|
- if v["budget"] != nil {
|
|
|
- v["budget"] = common.Float64All(fmt.Sprintf("%f", common.Float64All(v["budget"])/10000))
|
|
|
- }
|
|
|
- if v["publishtime"] != nil {
|
|
|
- v["publishtime"] = time.Unix(common.Int64All(v["publishtime"]), 0).Format("2006-01-02")
|
|
|
- }
|
|
|
- if v["bidopentime"] != nil {
|
|
|
- v["bidopentime"] = time.Unix(common.Int64All(v["bidopentime"]), 0).Format("2006-01-02")
|
|
|
- }
|
|
|
- if utf8.RuneCountInString(common.ObjToString(v["title"])) > 60 {
|
|
|
- title := string([]rune(common.ObjToString(v["title"]))[:60])
|
|
|
- v["title"] = title + "..."
|
|
|
- }
|
|
|
- if utf8.RuneCountInString(common.ObjToString(v["detail"])) > 150 {
|
|
|
- detail := string([]rune(common.ObjToString(v["detail"]))[:150])
|
|
|
- v["detail"] = detail + "..."
|
|
|
+ if v["bidamount"] != nil {
|
|
|
+ v["bidamount"] = common.Float64All(fmt.Sprintf("%f", common.Float64All(v["bidamount"])/10000))
|
|
|
+ }
|
|
|
+ if v["budget"] != nil {
|
|
|
+ v["budget"] = common.Float64All(fmt.Sprintf("%f", common.Float64All(v["budget"])/10000))
|
|
|
+ }
|
|
|
+ if v["publishtime"] != nil {
|
|
|
+ v["publishtime"] = time.Unix(common.Int64All(v["publishtime"]), 0).Format("2006-01-02")
|
|
|
+ }
|
|
|
+ if v["bidopentime"] != nil {
|
|
|
+ v["bidopentime"] = time.Unix(common.Int64All(v["bidopentime"]), 0).Format("2006-01-02")
|
|
|
+ }
|
|
|
+ if utf8.RuneCountInString(common.ObjToString(v["title"])) > 60 {
|
|
|
+ title := string([]rune(common.ObjToString(v["title"]))[:60])
|
|
|
+ v["title"] = title + "..."
|
|
|
+ }
|
|
|
+ if utf8.RuneCountInString(common.ObjToString(v["detail"])) > 150 {
|
|
|
+ detail := string([]rune(common.ObjToString(v["detail"]))[:150])
|
|
|
+ v["detail"] = detail + "..."
|
|
|
+ }
|
|
|
+ if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
|
|
|
+ legal_person := strings.TrimSpace(common.ObjToString(v["legal_person"]))
|
|
|
+ if utf8.RuneCountInString(legal_person) > 1 {
|
|
|
+ legal_person := []rune(legal_person)
|
|
|
+ v["legal_person"] = string(legal_person[:1]) + "**"
|
|
|
}
|
|
|
- if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
|
|
|
- legal_person := strings.TrimSpace(common.ObjToString(v["legal_person"]))
|
|
|
- if utf8.RuneCountInString(legal_person) > 1 {
|
|
|
- legal_person := []rune(legal_person)
|
|
|
- v["legal_person"] = string(legal_person[:1]) + "**"
|
|
|
- }
|
|
|
|
|
|
- cemail := strings.TrimSpace(common.ObjToString(v["company_email"]))
|
|
|
- if emailreg.MatchString(cemail) {
|
|
|
- v["company_email"] = "********" + cemail[strings.Index(cemail, "@"):]
|
|
|
- } else {
|
|
|
- v["company_email"] = ""
|
|
|
- }
|
|
|
- company_phone := strings.TrimSpace(common.ObjToString(v["company_phone"]))
|
|
|
- if telreg.MatchString(company_phone) || phonereg.MatchString(company_phone) {
|
|
|
- company_phone = company_phone[:len(company_phone)-5] + "****"
|
|
|
- v["company_phone"] = company_phone
|
|
|
- } else {
|
|
|
- v["company_phone"] = ""
|
|
|
- }
|
|
|
+ cemail := strings.TrimSpace(common.ObjToString(v["company_email"]))
|
|
|
+ if emailreg.MatchString(cemail) {
|
|
|
+ v["company_email"] = "********" + cemail[strings.Index(cemail, "@"):]
|
|
|
+ } else {
|
|
|
+ v["company_email"] = ""
|
|
|
}
|
|
|
- deletefields(common.IntAll((*tagfield)["i_extfieldstype"]), &v)
|
|
|
- rdata = append(rdata, v)
|
|
|
- }
|
|
|
- tmp["keylist"] = []string{}
|
|
|
- for k := range matchskey {
|
|
|
- if k == "" {
|
|
|
- continue
|
|
|
+ company_phone := strings.TrimSpace(common.ObjToString(v["company_phone"]))
|
|
|
+ if telreg.MatchString(company_phone) || phonereg.MatchString(company_phone) {
|
|
|
+ company_phone = company_phone[:len(company_phone)-5] + "****"
|
|
|
+ v["company_phone"] = company_phone
|
|
|
+ } else {
|
|
|
+ v["company_phone"] = ""
|
|
|
}
|
|
|
- tmp["keylist"] = append(tmp["keylist"].([]string), k)
|
|
|
}
|
|
|
- tmp["provincelist"] = []string{}
|
|
|
- for k := range matchsprovince {
|
|
|
- if k == "" {
|
|
|
- continue
|
|
|
- }
|
|
|
- tmp["provincelist"] = append(tmp["provincelist"].([]string), k)
|
|
|
+ deletefields(common.IntAll((*tagfield)["i_extfieldstype"]), &v)
|
|
|
+ rdata = append(rdata, v)
|
|
|
+ }
|
|
|
+ tmp["keylist"] = []string{}
|
|
|
+ for k := range matchskey {
|
|
|
+ if k == "" {
|
|
|
+ continue
|
|
|
}
|
|
|
- tmp["citylist"] = []string{}
|
|
|
- for k := range matchscity {
|
|
|
- if k == "" {
|
|
|
- continue
|
|
|
- }
|
|
|
- tmp["citylist"] = append(tmp["citylist"].([]string), k)
|
|
|
+ tmp["keylist"] = append(tmp["keylist"].([]string), k)
|
|
|
+ }
|
|
|
+ tmp["provincelist"] = []string{}
|
|
|
+ for k := range matchsprovince {
|
|
|
+ if k == "" {
|
|
|
+ continue
|
|
|
}
|
|
|
- tmp["data"] = rdata
|
|
|
- f.ServeJson(tmp)
|
|
|
- return
|
|
|
+ tmp["provincelist"] = append(tmp["provincelist"].([]string), k)
|
|
|
+ }
|
|
|
+ tmp["citylist"] = []string{}
|
|
|
+ for k := range matchscity {
|
|
|
+ if k == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmp["citylist"] = append(tmp["citylist"].([]string), k)
|
|
|
}
|
|
|
+ tmp["data"] = rdata
|
|
|
+ f.ServeJson(tmp)
|
|
|
+ return
|
|
|
}
|
|
|
- // }
|
|
|
}
|
|
|
+ // }
|
|
|
+ // }
|
|
|
f.ServeJson(map[string]string{
|
|
|
"err": "参数失效",
|
|
|
})
|