|
@@ -36,6 +36,7 @@ type PushJob struct {
|
|
|
func (p *PushJob) Execute(taskType int) {
|
|
|
p.pushJobLock.Lock()
|
|
|
defer p.pushJobLock.Unlock()
|
|
|
+ logger.Info("开始推送任务。。。", taskType)
|
|
|
p.Move()
|
|
|
p.Push(taskType)
|
|
|
}
|
|
@@ -287,14 +288,32 @@ func (p *PushJob) Push(taskType int) {
|
|
|
}
|
|
|
logger.Info("本次推送任务类型", taskType, "用户的接收方式", u.Id, wxPush, appPush, mailPush, t_wxpush, t_mailpush)
|
|
|
if wxPush == 1 || appPush == 1 || mailPush == 1 {
|
|
|
+ wxPushStatus, appPushStatus, mailPushStatus := 0, 0, 0
|
|
|
//开通订阅推送或邮箱推送的用户,由实时推送修改成九点推送,app推送用list字段,微信和邮箱推送用templist字段
|
|
|
if list != nil && templist != nil {
|
|
|
- p.DealSend(true, 0, appPush, 0, u, &list)
|
|
|
- p.DealSend(false, wxPush, 0, mailPush, u, &templist)
|
|
|
+ _, appPushStatus, _ = p.DealSend(true, 0, appPush, 0, u, &list)
|
|
|
+ wxPushStatus, _, mailPushStatus = p.DealSend(false, wxPush, 0, mailPush, u, &templist)
|
|
|
} else if list != nil {
|
|
|
- p.DealSend(true, wxPush, appPush, mailPush, u, &list)
|
|
|
+ wxPushStatus, appPushStatus, mailPushStatus = p.DealSend(true, wxPush, appPush, mailPush, u, &list)
|
|
|
} else if templist != nil {
|
|
|
- p.DealSend(false, wxPush, 0, mailPush, u, &templist)
|
|
|
+ wxPushStatus, _, mailPushStatus = p.DealSend(false, wxPush, 0, mailPush, u, &templist)
|
|
|
+ }
|
|
|
+ if wxPushStatus == -1 && appPushStatus == -1 && mailPushStatus == -1 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if wxPush == 1 {
|
|
|
+ if wxPushStatus == -1 {
|
|
|
+ wxPush = -1
|
|
|
+ } else {
|
|
|
+ wxPush = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if mailPush == 1 {
|
|
|
+ if mailPushStatus == -1 {
|
|
|
+ mailPush = -1
|
|
|
+ } else {
|
|
|
+ mailPush = 0
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//判断是否要删除数据
|
|
@@ -324,9 +343,9 @@ func (p *PushJob) Push(taskType int) {
|
|
|
}
|
|
|
}
|
|
|
p.pushWait.Wait()
|
|
|
- logger.Info("推送结束。。。")
|
|
|
+ logger.Info("推送任务结束。。。", taskType)
|
|
|
}
|
|
|
-func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *MemberInterest, sl *sortList) {
|
|
|
+func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *MemberInterest, sl *sortList) (wxPushStatus, appPushStatus, mailPushStatus int) {
|
|
|
defer util.Catch()
|
|
|
str := fmt.Sprintf("<div>根据您设置的关键词(%s),给您推送以下信息:</div>", strings.Join(k.OriginalKeys, ";"))
|
|
|
mailContent := ""
|
|
@@ -344,10 +363,10 @@ func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *Member
|
|
|
k2 := *ks.Info
|
|
|
title := strings.Replace(k2["title"].(string), "\n", "", -1)
|
|
|
area := util.ObjToString(k2["area"])
|
|
|
- newTitle := title
|
|
|
- if "A" != area {
|
|
|
- newTitle = fmt.Sprintf("[%s]%s", area, title)
|
|
|
+ if area == "A" {
|
|
|
+ area = "全国"
|
|
|
}
|
|
|
+ newTitle := fmt.Sprintf("[%s]%s", area, title)
|
|
|
if publishTitle[newTitle] {
|
|
|
continue
|
|
|
}
|
|
@@ -380,10 +399,6 @@ func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *Member
|
|
|
mailSid := util.CommonEncodeArticle("mailprivate", util.ObjToString(k2["_id"]))
|
|
|
url := fmt.Sprintf("%s/article/mailprivate/%s.html", SysConfig.JianyuDomain, mailSid)
|
|
|
classArea := "area"
|
|
|
- area := util.ObjToString(k2["area"])
|
|
|
- if area == "A" {
|
|
|
- area = "全国"
|
|
|
- }
|
|
|
classType := "type"
|
|
|
types := util.ObjToString(k2["subtype"])
|
|
|
if types == "" {
|
|
@@ -418,7 +433,7 @@ func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *Member
|
|
|
}
|
|
|
mailContent += fmt.Sprintf(SysConfig.Mail_content, i, url, otitle, classArea, area, classType, types, industryclass, industry, dates)
|
|
|
}
|
|
|
- str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' eid='" + _sid + "' href='" + util.ObjToString(k2["href"]) + "'>" + title + "</a></div>"
|
|
|
+ str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' eid='" + _sid + "' href='" + util.ObjToString(k2["href"]) + "'>[<span class='area'>" + area + "</span>]" + title + "</a></div>"
|
|
|
o_pushinfo[strconv.Itoa(i)] = map[string]interface{}{
|
|
|
"publishtime": k2["publishtime"],
|
|
|
"stype": util.ObjToString(k2["type"]),
|
|
@@ -465,6 +480,7 @@ func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *Member
|
|
|
pushId := putil.SaveSendInfo(k, time.Now(), str, o_pushinfo, matchKey_infoIndex)
|
|
|
if pushId == "" {
|
|
|
logger.Info("保存到cassandra出错", k.S_m_openid, k.A_m_openid, k.Phone)
|
|
|
+ wxPushStatus, appPushStatus, mailPushStatus = -1, -1, -1
|
|
|
return
|
|
|
}
|
|
|
}
|
|
@@ -537,7 +553,12 @@ func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *Member
|
|
|
LastTip = ""
|
|
|
}
|
|
|
//推送微信
|
|
|
- isPushOk = putil.SendWeixin(k, str, Tip1+WXTitle+LastTip, o_pushinfo, matchKey_infoIndex, wxtitle)
|
|
|
+ isPushOk = putil.SendWeixin(k, Tip1+WXTitle+LastTip, o_pushinfo, matchKey_infoIndex, wxtitle)
|
|
|
+ if isPushOk {
|
|
|
+ wxPushStatus = 1
|
|
|
+ } else {
|
|
|
+ wxPushStatus = -1
|
|
|
+ }
|
|
|
}
|
|
|
logger.Info("微信推送", isPushOk, k.S_m_openid, k.RateMode, k.ApplyStatus)
|
|
|
}
|
|
@@ -573,6 +594,11 @@ func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *Member
|
|
|
"otherPushId": k.Opushid,
|
|
|
"jgPushId": k.Jpushid, //极光-推送id
|
|
|
})
|
|
|
+ if isPushOk {
|
|
|
+ appPushStatus = 1
|
|
|
+ } else {
|
|
|
+ appPushStatus = -1
|
|
|
+ }
|
|
|
logger.Info("app推送", isPushOk, k.S_m_openid, k.A_m_openid, k.Phone, k.AppPhoneType, k.Jpushid, k.Opushid, k.RateMode)
|
|
|
}
|
|
|
//发送邮件
|
|
@@ -580,6 +606,11 @@ func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *Member
|
|
|
html := fmt.Sprintf(SysConfig.Mail_html, strings.Replace(strings.Join(k.OriginalKeys, ";"), "+", " ", -1), mailContent)
|
|
|
subject := fmt.Sprintf(SysConfig.Mail_title, "招标")
|
|
|
isPushOk := p.SendMail(k.Email, subject, html, fmdatas)
|
|
|
+ if isPushOk {
|
|
|
+ mailPushStatus = 1
|
|
|
+ } else {
|
|
|
+ mailPushStatus = -1
|
|
|
+ }
|
|
|
logger.Info("发送邮件", isPushOk, k.S_m_openid, k.A_m_openid, k.Phone, k.Email, k.DataExport)
|
|
|
}
|
|
|
if wxPush == 1 || appPush == 1 || (mailPush == 1 && wxPush == 0 && appPush == 0) {
|
|
@@ -592,6 +623,7 @@ func (p *PushJob) DealSend(isSave bool, wxPush, appPush, mailPush int, k *Member
|
|
|
putil.SendPcHelper(map[string]interface{}{"clientCode": openid})
|
|
|
}
|
|
|
}
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
//推送邮件(含附件)
|
|
@@ -605,11 +637,11 @@ func (p *PushJob) SendMail(email, subject, html string, fmdatas []map[string]int
|
|
|
rename = time.Now().Format("2006-01-02") + ".xlsx"
|
|
|
}
|
|
|
}
|
|
|
- gmail := <-Gmails
|
|
|
- defer func() {
|
|
|
- Gmails <- gmail
|
|
|
- }()
|
|
|
- status := mail.GSendMail("剑鱼招标订阅", email, "", "", subject, html, fnamepath, rename, gmail)
|
|
|
+ //gmail := <-Gmails
|
|
|
+ //defer func() {
|
|
|
+ //Gmails <- gmail
|
|
|
+ //}()
|
|
|
+ status := mail.GSendMail("剑鱼招标订阅", email, "", "", subject, html, fnamepath, rename, Gmail)
|
|
|
if fnamepath != "" {
|
|
|
os.Remove(fnamepath)
|
|
|
}
|