|
@@ -5,12 +5,14 @@ import (
|
|
|
"fmt"
|
|
|
"log"
|
|
|
qu "qfw/util"
|
|
|
+ gm "qfw/util/mail"
|
|
|
"regexp"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
+ "sync"
|
|
|
"time"
|
|
|
"unicode/utf8"
|
|
|
- "util"
|
|
|
+ . "util"
|
|
|
|
|
|
"github.com/go-xweb/xweb"
|
|
|
"gopkg.in/mgo.v2/bson"
|
|
@@ -22,6 +24,8 @@ var (
|
|
|
emailreg *regexp.Regexp = regexp.MustCompile(`\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}`)
|
|
|
pre *regexp.Regexp = regexp.MustCompile("https://www.jianyu360.com/article/content/")
|
|
|
suf *regexp.Regexp = regexp.MustCompile("(.html).*")
|
|
|
+
|
|
|
+ udptaskmap = &sync.Map{}
|
|
|
)
|
|
|
|
|
|
type Private struct {
|
|
@@ -38,13 +42,13 @@ func (f *Private) Keydatademo(world string) {
|
|
|
if len(destr) > 10 {
|
|
|
ctime := destr[:10]
|
|
|
ctimeint := qu.Int64All(ctime)
|
|
|
- if time.Now().Sub(time.Unix(ctimeint, 0)).Hours()/24 < util.Subday {
|
|
|
- tagfield, _ := util.Mgo.FindOneByField("tags", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_customername": 1})
|
|
|
+ if time.Now().Sub(time.Unix(ctimeint, 0)).Hours()/24 < Subday {
|
|
|
+ tagfield, _ := Mgo.FindOneByField("tags", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_customername": 1})
|
|
|
if (*tagfield) != nil && len(*tagfield) > 0 {
|
|
|
- if qu.Int64All((*tagfield)["i_extfieldstype"]) == util.Standard {
|
|
|
- tmp["fieldtype"] = util.Standardstr
|
|
|
- } else if qu.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
|
|
|
- tmp["fieldtype"] = util.Advancedstr
|
|
|
+ if qu.Int64All((*tagfield)["i_extfieldstype"]) == Standard {
|
|
|
+ tmp["fieldtype"] = Standardstr
|
|
|
+ } else if qu.Int64All((*tagfield)["i_extfieldstype"]) == Advanced {
|
|
|
+ tmp["fieldtype"] = Advancedstr
|
|
|
} else {
|
|
|
f.ServeJson(map[string]string{
|
|
|
"err": "参数失效",
|
|
@@ -53,7 +57,7 @@ func (f *Private) Keydatademo(world string) {
|
|
|
}
|
|
|
tmp["total"] = qu.Int64All((*tagfield)["i_estotal"])
|
|
|
tmp["customername"] = qu.ObjToString((*tagfield)["s_customername"])
|
|
|
- datas, _ := util.Mgo.Find("tagsdata", bson.M{"s_dataid": world}, `{"publishtime":-1}`, nil, false, -1, -1)
|
|
|
+ datas, _ := Mgo.Find("tagsdata", bson.M{"s_dataid": world}, `{"publishtime":-1}`, nil, false, -1, -1)
|
|
|
if (*datas) != nil && len(*datas) > 0 {
|
|
|
matchskey := make(map[string]bool)
|
|
|
rdata := make([]map[string]interface{}, 0)
|
|
@@ -85,7 +89,7 @@ func (f *Private) Keydatademo(world string) {
|
|
|
detail := string([]rune(qu.ObjToString(v["detail"]))[:150])
|
|
|
v["detail"] = detail + "..."
|
|
|
}
|
|
|
- if qu.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
|
|
|
+ if qu.Int64All((*tagfield)["i_extfieldstype"]) == Advanced {
|
|
|
legal_person := strings.TrimSpace(qu.ObjToString(v["legal_person"]))
|
|
|
if utf8.RuneCountInString(legal_person) > 1 {
|
|
|
legal_person := []rune(legal_person)
|
|
@@ -136,8 +140,8 @@ func (f *Private) Keydataoption(world string) {
|
|
|
if err == nil && len(destr) > 10 {
|
|
|
ctime := destr[:10]
|
|
|
ctimeint := qu.Int64All(ctime)
|
|
|
- if time.Now().Sub(time.Unix(ctimeint, 0)).Hours()/24 < util.Subday {
|
|
|
- res, _ := util.Mgo.FindOne("tags", bson.M{"s_dataid": world})
|
|
|
+ if time.Now().Sub(time.Unix(ctimeint, 0)).Hours()/24 < Subday {
|
|
|
+ res, _ := Mgo.FindOne("tags", bson.M{"s_dataid": world})
|
|
|
if nil != res && len(*res) > 0 {
|
|
|
feedback := make(map[string]interface{})
|
|
|
feedback["s_dataid"] = world
|
|
@@ -149,7 +153,7 @@ func (f *Private) Keydataoption(world string) {
|
|
|
|
|
|
tmps := make([]map[string]interface{}, 0)
|
|
|
for _, tt := range tmp["urls"].([]interface{}) {
|
|
|
- ttres, _ := util.Mgo.FindOne("tagsdata", bson.M{"s_jyhref": tt})
|
|
|
+ ttres, _ := Mgo.FindOne("tagsdata", bson.M{"s_jyhref": tt})
|
|
|
if nil != ttres && len(*ttres) > 0 {
|
|
|
tmps = append(tmps, *ttres)
|
|
|
}
|
|
@@ -174,7 +178,7 @@ func (f *Private) Keydataoption(world string) {
|
|
|
keyssort = append(keyssort, v.Key)
|
|
|
}
|
|
|
feedback["o_matchkey"] = keyssort
|
|
|
- pid := util.Mgo.Save("feedback", feedback)
|
|
|
+ pid := Mgo.Save("feedback", feedback)
|
|
|
if len(pid) < 1 {
|
|
|
log.Println("mongo save err")
|
|
|
return
|
|
@@ -191,12 +195,13 @@ func (f *Private) Keydataoption(world string) {
|
|
|
savetmp["s_buyerclass"] = qu.ObjToString(v["buyerclass"])
|
|
|
savetmp["s_subtype"] = qu.ObjToString(v["subtype"])
|
|
|
savetmp["s_purchasing"] = qu.ObjToString(v["s_purchasing"])
|
|
|
- util.Mgo.Save("feedback_info", savetmp)
|
|
|
+ Mgo.Save("feedback_info", savetmp)
|
|
|
}
|
|
|
f.ServeJson(map[string]string{
|
|
|
"code": "1",
|
|
|
"err": "保存成功",
|
|
|
})
|
|
|
+ go sendMail() //发送邮件
|
|
|
return
|
|
|
}
|
|
|
}
|
|
@@ -212,6 +217,9 @@ type keynum struct {
|
|
|
Num int
|
|
|
}
|
|
|
|
|
|
+var gmail *gm.GmailAuth
|
|
|
+
|
|
|
+
|
|
|
func urlToId(url string) string {
|
|
|
url = pre.ReplaceAllString(url, "")
|
|
|
url = suf.ReplaceAllString(url, "")
|
|
@@ -221,7 +229,7 @@ func urlToId(url string) string {
|
|
|
|
|
|
func deletefields(fieldnum int,data *map[string]interface{}) map[string]interface{}{
|
|
|
rdata := make(map[string]interface{})
|
|
|
- one, _ := util.Mgo.FindOne("code_fields", bson.M{})
|
|
|
+ one, _ := Mgo.FindOne("code_fields", bson.M{})
|
|
|
if one != nil && len(*one) > 0 {
|
|
|
for _,v:=range (*one)[fmt.Sprintf("%d",fieldnum)].([]interface{}){
|
|
|
if (*data)[qu.ObjToString(v)]!= nil{
|
|
@@ -231,3 +239,15 @@ func deletefields(fieldnum int,data *map[string]interface{}) map[string]interfac
|
|
|
}
|
|
|
return rdata
|
|
|
}
|
|
|
+
|
|
|
+func sendMail() {
|
|
|
+ gmail = &gm.GmailAuth{
|
|
|
+ SmtpHost: qu.ObjToString(JkMail["host"]),
|
|
|
+ SmtpPort: qu.IntAll(JkMail["port"]),
|
|
|
+ User: qu.ObjToString(JkMail["user"]),
|
|
|
+ Pwd: qu.ObjToString(JkMail["pwd"]),
|
|
|
+ }
|
|
|
+ b := gm.GSendMail("jy@jianyu360.cn", qu.ObjToString(JkMail["to"]), "", "", "反馈消息", "反馈反馈反馈", "", "", gmail)
|
|
|
+ qu.Debug(b)
|
|
|
+}
|
|
|
+
|