Bläddra i källkod

Merge branch 'dev2.8.5' of http://192.168.3.207:10080/qmx/jy into dev2.8.5

wangshan 5 år sedan
förälder
incheckning
ca222c652a
43 ändrade filer med 587 tillägg och 402 borttagningar
  1. 1 1
      src/jfw/modules/pushsubscribe/src/match/config.json
  2. 4 1
      src/jfw/modules/pushsubscribe/src/match/job/matchjob.go
  3. BIN
      src/jfw/modules/pushsubscribe/src/match/match
  4. 1 1
      src/jfw/modules/pushsubscribe/src/match/matcher/vipmatch.go
  5. 1 1
      src/jfw/modules/pushsubscribe/src/public/entity.go
  6. 1 1
      src/jfw/modules/pushsubscribe/src/public/util.go
  7. 1 2
      src/jfw/modules/pushsubscribe/src/push/config.json
  8. 2 0
      src/jfw/modules/pushsubscribe/src/push/config/config.go
  9. 2 8
      src/jfw/modules/pushsubscribe/src/push/job/jobs.go
  10. 4 4
      src/jfw/modules/pushsubscribe/src/push/job/movejob.go
  11. 57 82
      src/jfw/modules/pushsubscribe/src/push/job/pushjob.go
  12. 0 61
      src/jfw/modules/pushsubscribe/src/push/job/repairjob.go
  13. 16 7
      src/jfw/modules/pushsubscribe/src/push/main.go
  14. 49 30
      src/jfw/modules/pushsubscribe/src/push/pusher/normalpush.go
  15. 3 3
      src/jfw/modules/pushsubscribe/src/push/pusher/pusher.go
  16. 36 21
      src/jfw/modules/pushsubscribe/src/push/pusher/repairpush.go
  17. 67 23
      src/jfw/modules/pushsubscribe/src/push/pusher/specialpush.go
  18. 6 5
      src/jfw/modules/pushsubscribe/src/push/rpc/rpc.go
  19. 65 26
      src/jfw/modules/pushsubscribe/src/push/util/entity.go
  20. 1 2
      src/jfw/modules/pushsubscribe/src/push/util/rpccall.go
  21. 32 5
      src/jfw/modules/pushsubscribe/src/push/util/util.go
  22. 2 1
      src/jfw/modules/subscribepay/src/a/init.go
  23. 14 11
      src/jfw/modules/subscribepay/src/entity/subscribeVip.go
  24. 52 2
      src/jfw/modules/subscribepay/src/service/orderListDetails.go
  25. 3 3
      src/jfw/modules/subscribepay/src/service/vipRenewUpgrade.go
  26. 1 1
      src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go
  27. 7 4
      src/jfw/modules/subscribepay/src/timetask/timetask.go
  28. 1 1
      src/main.go
  29. BIN
      src/web/staticres/images/mail.png
  30. BIN
      src/web/staticres/images/phone.png
  31. 2 1
      src/web/templates/weixin/dataExport/dataExport_toMyOrder.html
  32. 4 4
      src/web/templates/weixin/email/bind_email.html
  33. 57 11
      src/web/templates/weixin/email/bind_success.html
  34. 26 6
      src/web/templates/weixin/vipsubscribe/choose_area.html
  35. 1 1
      src/web/templates/weixin/vipsubscribe/choose_industry.html
  36. 2 1
      src/web/templates/weixin/vipsubscribe/choose_industry_upgrade.html
  37. 1 1
      src/web/templates/weixin/vipsubscribe/edit_subscribe.html
  38. 17 15
      src/web/templates/weixin/vipsubscribe/renew_pay.html
  39. 1 0
      src/web/templates/weixin/vipsubscribe/trial_info.html
  40. 20 27
      src/web/templates/weixin/vipsubscribe/vip_introduce.html
  41. 1 1
      src/web/templates/weixin/vipsubscribe/vip_pay_success.html
  42. 9 11
      src/web/templates/weixin/vipsubscribe/vip_purchase.html
  43. 17 16
      src/web/templates/weixin/vipsubscribe/vip_upgrade.html

+ 1 - 1
src/jfw/modules/pushsubscribe/src/match/config.json

@@ -4,7 +4,7 @@
 	"redisServers": "pushcache_1=192.168.3.128:5000,pushcache_2_a=192.168.3.128:5001",
 	"maxPushSize": 50,
 	"vipMaxPushSize": 2000,
-	"maxSearch": 50000,
+	"maxSearch": 20000,
 	"mgoAddr": "192.168.3.128:27080",
 	"mgoSize": 10,
 	"testids": ["5d81c5a525ef8723ac0036f9"],

+ 4 - 1
src/jfw/modules/pushsubscribe/src/match/job/matchjob.go

@@ -152,7 +152,7 @@ func (m *MatchJob) ToMatch(batchIndex int, matcher Matcher) {
 			"wxpush":        user.WxPush,
 			"apppush":       user.AppPush,
 			"mailpush":      user.MailPush,
-			"pchelperpush":  user.PchelperPush,
+			"pchelperpush":  user.PcHelperPush,
 			"usertype":      user.UserType,
 			"email":         user.Email,
 			"list":          array,
@@ -202,6 +202,9 @@ func (m *MatchJob) LoadBidding(lastId, newId string, lastTime int64) bool {
 	if len(idQuery) > 0 {
 		c_query["_id"] = idQuery
 	}
+	//c_query = map[string]interface{}{
+	//"_id": bson.ObjectIdHex("5da706f7a5cb26b9b778d08a"),
+	//}
 	logger.Info("mongodb query:", c_query)
 	count := mongodb.Count("bidding", c_query)
 	logger.Info("本次数据共", count, "条")

BIN
src/jfw/modules/pushsubscribe/src/match/match


+ 1 - 1
src/jfw/modules/pushsubscribe/src/match/matcher/vipmatch.go

@@ -72,7 +72,7 @@ func (v *VipUser) Match(info *map[string]interface{}) *map[*UserInfo]*MatchUser
 	users := map[*UserInfo]*MatchUser{}
 	for k, _ := range v.Users {
 		if (!v.BuyerclassUsers[""][k] && !v.BuyerclassUsers[buyerclass][k]) ||
-			(!v.AreaUsers[""][k] && !v.AreaUsers[area][k] && !v.AreaUsers[city][k]) ||
+			(!v.AreaUsers[""][k] && !v.AreaUsers[area][k] && !v.CityUsers[city][k]) ||
 			(!v.InfoTypeUsers[""][k] && !v.InfoTypeUsers[toptype][k]) {
 			continue
 		}

+ 1 - 1
src/jfw/modules/pushsubscribe/src/public/entity.go

@@ -16,7 +16,7 @@ type UserInfo struct {
 	WxPush        int                        //是否开启微信推送
 	AppPush       int                        //是否开启app推送
 	MailPush      int                        //是否开启邮箱推送
-	PchelperPush  int                        //是否pc助手推送
+	PcHelperPush  int                        //是否pc助手推送
 	RateMode      int                        //推送时间
 	Email         string                     //邮箱
 	ModifyDate    string                     //修改时间

+ 1 - 1
src/jfw/modules/pushsubscribe/src/public/util.go

@@ -195,7 +195,7 @@ func NewUserInfoByUserColl(temp map[string]interface{}) (user *UserInfo, o_msgse
 		WxPush:       wxpush,
 		AppPush:      apppush,
 		MailPush:     mailpush,
-		PchelperPush: pchelperPush,
+		PcHelperPush: pchelperPush,
 		Email:        email,
 		S_m_openid:   s_m_openid,
 		A_m_openid:   a_m_openid,

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 2
src/jfw/modules/pushsubscribe/src/push/config.json


+ 2 - 0
src/jfw/modules/pushsubscribe/src/push/config/config.go

@@ -16,6 +16,8 @@ type config struct {
 	Mail_content            string      `json:"mail_content"`
 	Mail_html               string      `json:"mail_html"`
 	Mail_title              string      `json:"mail_title"`
+	Mail_according          string      `json:"mail_according"`
+	Vip_mail_according      string      `json:"vip_mail_according"`
 	Mails                   []*pushMail `json:"mails"`
 	MaxPushSize             int         `json:"maxPushSize"`
 	VipMaxPushSize          int         `json:"vipMaxPushSize"`

+ 2 - 8
src/jfw/modules/pushsubscribe/src/push/job/jobs.go

@@ -6,9 +6,8 @@ import (
 )
 
 var Jobs = struct {
-	Move   *MoveJob
-	Push   *PushJob
-	Repair *RepairJob
+	Move *MoveJob
+	Push *PushJob
 }{
 	Move: &MoveJob{
 		moveLock:  &sync.Mutex{},
@@ -23,9 +22,4 @@ var Jobs = struct {
 		wait: &sync.WaitGroup{},
 		lock: &sync.Mutex{},
 	},
-	Repair: &RepairJob{
-		pool: make(chan bool, Config.PushPoolSize),
-		wait: &sync.WaitGroup{},
-		lock: &sync.Mutex{},
-	},
 }

+ 4 - 4
src/jfw/modules/pushsubscribe/src/push/job/movejob.go

@@ -70,7 +70,7 @@ func (m *MoveJob) Execute() {
 					idMap[util.ObjToString((*v.Info)["_id"])] = true
 				}
 				newList := putil.ToSortList(temp["list"])
-				for _, v := range newList {
+				for _, v := range *newList {
 					if idMap[util.ObjToString((*v.Info)["_id"])] {
 						continue
 					}
@@ -157,7 +157,7 @@ func (m *MoveJob) merge(number *int, nowUnix int64, moveUsers map[string]*MoveUs
 				}
 				oldList := putil.ToSortList(data["list"])
 				idMap := map[string]bool{}
-				for _, vv := range oldList {
+				for _, vv := range *oldList {
 					idMap[util.ObjToString((*vv.Info)["_id"])] = true
 				}
 				newList := make(SortList, 0)
@@ -172,14 +172,14 @@ func (m *MoveJob) merge(number *int, nowUnix int64, moveUsers map[string]*MoveUs
 				if pLength == 0 {
 					return
 				}
-				rLength := len(oldList)
+				rLength := len(*oldList)
 				maxPushSize := Config.MaxPushSize
 				if moveUser.isVipUser {
 					maxPushSize = Config.VipMaxPushSize
 				}
 				upSet := map[string]interface{}{}
 				if rLength+pLength > maxPushSize {
-					newList = append(newList, oldList...)
+					newList = append(newList, *oldList...)
 					sort.Sort(newList)
 					setMap["list"] = newList[:maxPushSize]
 					setMap["size"] = maxPushSize

+ 57 - 82
src/jfw/modules/pushsubscribe/src/push/job/pushjob.go

@@ -2,7 +2,6 @@ package job
 
 import (
 	"fmt"
-	"log"
 	"net/http"
 	"os"
 	. "public"
@@ -35,7 +34,6 @@ func init() {
 }
 
 type PushJob struct {
-	taskType                int
 	pool                    chan bool
 	wait                    *sync.WaitGroup
 	lock                    *sync.Mutex
@@ -45,29 +43,39 @@ type PushJob struct {
 
 //taskType 1--一天三次推送 2--九点推送
 func (p *PushJob) Execute(taskType int) {
-	p.startPush(taskType)
-	if taskType == 2 {
-		p.startPush(3)
+	p.lock.Lock()
+	defer p.lock.Unlock()
+	p.beforePush(taskType)
+	//每天九点以后,推送每周每月的用户
+	if taskType == 2 && putil.IsVipTempPushTime() {
+		now := time.Now()
+		if now.Weekday().String() == Config.VipPushWeek { //每周
+			p.beforePush(3)
+		} else if now.Day() == Config.VipPushDay { //每月
+			p.beforePush(4)
+		}
 	}
 }
 
 //开始推送
-func (p *PushJob) startPush(taskType int) {
-	defer util.Catch()
+func (p *PushJob) beforePush(taskType int) {
 	var pusher Pusher
 	if taskType == 1 || taskType == 2 {
 		pusher = &NormalPush{
 			SavePool: make(chan bool, Config.SavePoolSize),
 		}
-	} else if taskType == 3 {
+	} else if taskType == 3 || taskType == 4 || taskType == 5 {
 		pusher = &SpecialPush{}
 	} else {
 		return
 	}
-	p.lock.Lock()
-	defer p.lock.Unlock()
-	p.taskType = taskType
-	logger.Info("推送任务", p.taskType, "开始推送。。。")
+	p.StartPush(pusher, taskType)
+}
+
+//开始推送
+func (p *PushJob) StartPush(pusher Pusher, taskType int) {
+	defer util.Catch()
+	logger.Info("推送任务", taskType, "开始推送。。。")
 	batchIndex := 0
 	startId := ""
 	for {
@@ -78,7 +86,7 @@ func (p *PushJob) startPush(taskType int) {
 			select {
 			case <-time.After(5 * time.Minute):
 				isTake = false
-				logger.Error("推送任务", p.taskType, "推送放入通道超时,", temp["userid"], len(p.minutePushPool), len(p.fastigiumMinutePushPool))
+				logger.Error("推送任务", taskType, "推送放入通道超时,", temp["userid"], len(p.minutePushPool), len(p.fastigiumMinutePushPool))
 				go func() {
 					if Config.TimeoutWarn != "" {
 						if _, err := http.Get(Config.TimeoutWarn); err != nil {
@@ -96,44 +104,15 @@ func (p *PushJob) startPush(taskType int) {
 					}
 					p.wait.Done()
 				}()
-				u := pusher.GetUserInfo(v)
+				u, pushWay := pusher.GetUserInfo(v)
 				if u == nil {
 					return
 				}
-				logger.Info("推送任务", p.taskType, "开始推送用户", "userType", u.UserType, "userId", u.Id, "s_m_openid", u.S_m_openid, "a_m_openid", u.A_m_openid, "phone", u.Phone, "subscribe", u.Subscribe, "applystatus", u.ApplyStatus, "jpushid", u.Jpushid, "opushid", u.Opushid, "phoneType", u.AppPhoneType, "rateMode", u.RateMode, "email", u.Email)
-				wxPush, appPush, mailPush := 0, 0, 0
-				if u.WxPush == 1 {
-					wxPush = 1
-				}
-				if u.AppPush == 1 {
-					appPush = 1
-				}
-				if u.MailPush == 1 {
-					mailPush = 1
-				}
-				logger.Info("推送任务", p.taskType, "用户接收方式", "userId", u.Id, "wxPush", wxPush, "appPush", appPush, "mailPush", mailPush, "pchelperPush", u.PchelperPush)
-				if wxPush != 1 && appPush != 1 && mailPush != 1 {
-					return
-				}
-				list := putil.ToSortList(v["list"])
-				//再对取消关注以及app没有登录的用户进行过滤,但是依然可以进行助手推送
-				if u.Subscribe == 0 {
-					wxPush = 0
+				logger.Info("推送任务", taskType, "开始推送用户", "userType", u.UserType, "userId", u.Id, "s_m_openid", u.S_m_openid, "a_m_openid", u.A_m_openid, "phone", u.Phone, "subscribe", u.Subscribe, "applystatus", u.ApplyStatus, "jpushid", u.Jpushid, "opushid", u.Opushid, "phoneType", u.AppPhoneType, "rateMode", u.RateMode, "email", u.Email, "vipStatus", u.VipStatus)
+				var pushResult *putil.PushResult
+				if pushWay.WxPush || pushWay.AppPush || pushWay.MailPush || pushWay.PcHelperPush {
+					pushResult = p.doPush(pusher, taskType, pushWay, u, putil.ToSortList(v["list"]))
 				}
-				if u.Jpushid == "" && u.Opushid == "" {
-					appPush = 0
-				}
-				if mailPush != 0 {
-					if u.UserType == 0 && u.Subscribe == 0 {
-						mailPush = 0
-					} else if (u.UserType == 1 || u.UserType == 2) && u.Jpushid == "" && u.Opushid == "" {
-						mailPush = 0
-					} else if u.UserType == 5 && u.Subscribe == 0 && u.Jpushid == "" && u.Opushid == "" {
-						mailPush = 0
-					}
-				}
-				pushResult := p.selectPush(pusher, p.taskType, wxPush, appPush, mailPush, u, list)
-				log.Println(pushResult)
 				pusher.AfterPush(pushResult, u, v)
 			}(temp, isTake)
 		}
@@ -142,21 +121,12 @@ func (p *PushJob) startPush(taskType int) {
 		}
 	}
 	p.wait.Wait()
-	logger.Info("推送任务结束。。。", p.taskType)
-}
-
-//满足条件进行推送
-func (p *PushJob) selectPush(pusher Pusher, taskType int, wxPush, appPush, mailPush int, u *UserInfo, list SortList) (pushResult *putil.PushResult) {
-	if wxPush == 1 || appPush == 1 || mailPush == 1 || u.PchelperPush == 1 {
-		pushResult = p.doPush(pusher, taskType, wxPush, appPush, mailPush, u, &list)
-	}
-	return
+	logger.Info("推送任务结束。。。", taskType)
 }
 
 //进入具体推送
-func (p *PushJob) doPush(pusher Pusher, taskType int, wxPush, appPush, mailPush int, u *UserInfo, sl *SortList) (pushResult *putil.PushResult) {
+func (p *PushJob) doPush(pusher Pusher, taskType int, pushWay *putil.PushWay, u *UserInfo, sl *SortList) (pushResult *putil.PushResult) {
 	defer util.Catch()
-	pushResult = &putil.PushResult{}
 	now := time.Now()
 	//限制一分钟最大的推送数量
 	if p.fastigiumMinutePushPool != nil {
@@ -166,32 +136,31 @@ func (p *PushJob) doPush(pusher Pusher, taskType int, wxPush, appPush, mailPush
 	} else if p.minutePushPool != nil {
 		<-p.minutePushPool //正常期
 	}
-	pushParam := pusher.GetPushParam(mailPush, u, sl)
-	if pushParam == nil {
+	pushParam := pusher.GetPushParam(pushWay.MailPush, u, sl)
+	if pushParam.InfosLength == 0 {
 		logger.Info("推送任务", taskType, "没有要推送的数据!", u.Id)
-		return nil
+		return
+	}
+	pushResult = &putil.PushResult{
+		Infos:    pushParam.Infos,
+		PushDate: pushParam.PushDate,
 	}
-	pushResult.Infos = pushParam.Infos
-	pushResult.PushDate = pushParam.PushDate
-	pushResult.IsVipTempSave = pushParam.IsVipTempSave
 	if !pushParam.IsPush {
-		return pushResult
+		return
 	}
 	logger.Info("推送任务", taskType, "开始进行终端推送", u.Id)
-	if pushResult.PushDate > 0 {
-		//pc端助手推送
-		if u.S_m_openid != "" {
-			logger.Info("推送任务", taskType, "开始助手推送", u.Id, "s_m_openid", u.S_m_openid)
-			isPushOk := putil.SendPcHelper(map[string]interface{}{"clientCode": u.S_m_openid})
-			logger.Info("推送任务", taskType, "助手推送结束", isPushOk, u.Id, "s_m_openid", u.S_m_openid)
-		}
-		if u.Phone != "" {
-			logger.Info("推送任务", taskType, "开始助手推送", u.Id, "phone", u.Phone)
-			isPushOk := putil.SendPcHelper(map[string]interface{}{"clientCode": u.Phone})
-			logger.Info("推送任务", taskType, "助手推送结束", isPushOk, u.Id, "phone", u.Phone)
-		}
+	//pc端助手推送
+	if u.S_m_openid != "" {
+		logger.Info("推送任务", taskType, "开始助手推送", u.Id, "s_m_openid", u.S_m_openid)
+		isPushOk := putil.SendPcHelper(map[string]interface{}{"clientCode": u.S_m_openid})
+		logger.Info("推送任务", taskType, "助手推送结束", isPushOk, u.Id, "s_m_openid", u.S_m_openid)
 	}
-	if wxPush == 1 {
+	if u.Phone != "" {
+		logger.Info("推送任务", taskType, "开始助手推送", u.Id, "phone", u.Phone)
+		isPushOk := putil.SendPcHelper(map[string]interface{}{"clientCode": u.Phone})
+		logger.Info("推送任务", taskType, "助手推送结束", isPushOk, u.Id, "phone", u.Phone)
+	}
+	if pushWay.WxPush {
 		logger.Info("推送任务", taskType, "开始微信推送", u.ApplyStatus, u.Id)
 		isPushOk := true
 		if u.ApplyStatus == 1 {
@@ -215,7 +184,7 @@ func (p *PushJob) doPush(pusher Pusher, taskType int, wxPush, appPush, mailPush
 			}
 			LastTipLen := len([]rune(lastTip))
 			wxTitle := Config.VipWxTitle
-			if !pushParam.IsVipUser {
+			if !IsVipUser(u.VipStatus) {
 				wxTitleKeys := strings.Join(u.Keys, ";")
 				if len([]rune(wxTitleKeys)) > 8 {
 					wxTitleKeys = string([]rune(wxTitleKeys)[:8]) + "..."
@@ -269,7 +238,7 @@ func (p *PushJob) doPush(pusher Pusher, taskType int, wxPush, appPush, mailPush
 		}
 		logger.Info("推送任务", taskType, "微信推送结束", u.ApplyStatus, isPushOk, u.Id)
 	}
-	if appPush == 1 {
+	if pushWay.AppPush {
 		logger.Info("推送任务", taskType, "开始app推送", u.Id)
 		descriptAppend := ""
 		if pushParam.InfosLength > 1 {
@@ -301,9 +270,15 @@ func (p *PushJob) doPush(pusher Pusher, taskType int, wxPush, appPush, mailPush
 		logger.Info("推送任务", taskType, "app推送结束", isPushOk, u.Id)
 	}
 	//发送邮件
-	if mailPush == 1 {
+	if pushWay.MailPush {
 		logger.Info("推送任务", taskType, "开始邮箱推送", u.Id)
-		html := fmt.Sprintf(Config.Mail_html, strings.Replace(strings.Join(u.Keys, ";"), "+", " ", -1), pushParam.MailContent)
+		according := ""
+		if IsVipUser(u.VipStatus) {
+			according = Config.Vip_mail_according
+		} else {
+			according = fmt.Sprintf(Config.Mail_according, strings.Replace(strings.Join(u.Keys, ";"), "+", " ", -1))
+		}
+		html := fmt.Sprintf(Config.Mail_html, according, pushParam.MailContent)
 		isPushOk := p.sendMail(u.Email, Config.Mail_title, html, nil)
 		if isPushOk {
 			pushResult.MailStatus = 1

+ 0 - 61
src/jfw/modules/pushsubscribe/src/push/job/repairjob.go

@@ -1,61 +0,0 @@
-package job
-
-import (
-	. "push/pusher"
-	putil "push/util"
-	"qfw/util"
-	"sync"
-
-	"github.com/donnie4w/go-logger/logger"
-)
-
-//补推接口
-type RepairJob struct {
-	pool chan bool
-	wait *sync.WaitGroup
-	lock *sync.Mutex
-}
-
-func (r *RepairJob) Execute(param string) bool {
-	logger.Info("开始补推任务。。。")
-	var pusher Pusher = &RepairPush{}
-	taskType := 0
-	batchIndex := 0
-	startId := ""
-	for {
-		batchIndex++
-		isBreak, users := pusher.OncePushBatch(taskType, batchIndex, &startId)
-		for _, temp := range *users {
-			r.pool <- true
-			r.wait.Add(1)
-			go func(v map[string]interface{}) {
-				defer func() {
-					<-r.pool
-					r.wait.Done()
-				}()
-				u := pusher.GetUserInfo(v)
-				logger.Info("补推任务", "开始推送用户,userid", u.Id, "s_m_openid", u.S_m_openid, "a_m_openid", u.A_m_openid, "phone", u.Phone, "subscribe", u.Subscribe, "applystatus", u.ApplyStatus, "jpushid", u.Jpushid, "opushid", u.Opushid)
-				wxPush, appPush, mailPush := 0, 0, 0
-				wxFail, appFail, mailFail := util.IntAll(v["wxfail"]), util.IntAll(v["appfail"]), util.IntAll(v["mailfail"])
-				if wxFail > 0 {
-					wxPush = 1
-				}
-				if appFail > 0 {
-					appPush = 1
-				}
-				if mailFail > 0 {
-					mailPush = 1
-				}
-				list := putil.ToSortList(v["list"])
-				pushResult := Jobs.Push.selectPush(pusher, taskType, wxPush, appPush, mailPush, u, list)
-				pusher.AfterPush(pushResult, u, v)
-			}(temp)
-		}
-		if isBreak || param != "all" {
-			break
-		}
-	}
-	r.wait.Wait()
-	logger.Info("补推任务结束。。。")
-	return true
-}

+ 16 - 7
src/jfw/modules/pushsubscribe/src/push/main.go

@@ -8,7 +8,8 @@ import (
 	"net/http"
 	"net/rpc"
 	. "push/config"
-	"push/job"
+	. "push/job"
+	. "push/pusher"
 	prpc "push/rpc"
 	"qfw/util/mongodb"
 	"qfw/util/redis"
@@ -17,9 +18,10 @@ import (
 )
 
 func main() {
-	modle := flag.Int("m", 0, "0 定时任务模式推送;1 非定时任务模式推送;2 定时任务模式推送之前先执行-t的任务;")
+	modle := flag.Int("m", 0, "0 定时任务模式推送;1 非定时任务模式推送;2 定时任务模式推送之前先执行-t的任务;3 补推")
 	move := flag.Int("v", 0, "1 优先迁移数据")
-	taskType := flag.Int("t", 1, "1 一天三次推送;2 九点推送")
+	repair := flag.String("r", "", "all 全部;多个用户的话_id逗号分开")
+	taskType := flag.Int("t", 1, "1 一天三次推送;2 九点推送;3 每周;4 每月;5 每周+每月")
 	flag.Parse()
 	logger.SetConsole(false)
 	logger.SetRollingDaily("./logs", "push.log")
@@ -42,14 +44,21 @@ func main() {
 	//
 	log.Println("订阅推送-推送程序启动。。。")
 	if *move == 1 {
-		job.Jobs.Move.Execute()
+		Jobs.Move.Execute()
 	}
 	if *modle == 1 {
-		job.Jobs.Push.Execute(*taskType)
+		Jobs.Push.Execute(*taskType)
 		return
 	} else if *modle == 2 {
-		job.Jobs.Push.Execute(*taskType)
+		Jobs.Push.Execute(*taskType)
+	} else if *modle == 3 {
+		if *repair == "" {
+			log.Println("缺少-r参数")
+		} else {
+			Jobs.Push.StartPush(&RepairPush{Param: *repair}, 0)
+		}
+		return
 	}
-	(&job.TimeTask{}).Run()
+	(&TimeTask{}).Run()
 	<-chan bool(nil)
 }

+ 49 - 30
src/jfw/modules/pushsubscribe/src/push/pusher/normalpush.go

@@ -20,7 +20,7 @@ type NormalPush struct {
 }
 
 //获取需要推送的用户
-func (n *NormalPush) OncePushBatch(taskType, batchIndex int, startId *string, args ...interface{}) (bool, *[]map[string]interface{}) {
+func (n *NormalPush) OncePushBatch(taskType, batchIndex int, startId *string) (bool, *[]map[string]interface{}) {
 	var query map[string]interface{}
 	//根据任务类型,查找ratemode
 	if taskType == 1 {
@@ -51,13 +51,15 @@ func (n *NormalPush) OncePushBatch(taskType, batchIndex int, startId *string, ar
 }
 
 //获取用户缓存信息
-func (n *NormalPush) GetUserInfo(user map[string]interface{}) *UserInfo {
-	return putil.NewUserInfoByPushSpaceColl(user)
+func (n *NormalPush) GetUserInfo(user map[string]interface{}) (*UserInfo, *putil.PushWay) {
+	userInfo := putil.NewUserInfoByPushSpaceColl(user)
+	pushWay := putil.NewPushWay(userInfo)
+	return userInfo, pushWay
 }
 
 //推送以后处理
 func (n *NormalPush) AfterPush(pushResult *putil.PushResult, u *UserInfo, user map[string]interface{}) {
-	if pushResult.PushDate == 0 {
+	if pushResult == nil || pushResult.PushDate == 0 {
 		return
 	}
 	if u.FirstPushTime == 0 {
@@ -69,9 +71,6 @@ func (n *NormalPush) AfterPush(pushResult *putil.PushResult, u *UserInfo, user m
 			},
 		}, false, false)
 	}
-	if pushResult.IsVipTempSave {
-		n.vipTempSave(u.Id, pushResult.PushDate, pushResult.Infos)
-	}
 	//判断是否要删除数据
 	sess := mongodb.GetMgoConn()
 	defer mongodb.DestoryMongoConn(sess)
@@ -81,6 +80,7 @@ func (n *NormalPush) AfterPush(pushResult *putil.PushResult, u *UserInfo, user m
 	}
 	if pushResult.WxStatus == -1 || pushResult.AppStatus == -1 || pushResult.MailStatus == -1 {
 		user["failtime"] = time.Now().Unix()
+		user["createtime"] = pushResult.PushDate
 		user["list"] = pushResult.Infos
 		if pushResult.WxStatus == -1 {
 			user["wxfail"] = 1
@@ -97,14 +97,14 @@ func (n *NormalPush) AfterPush(pushResult *putil.PushResult, u *UserInfo, user m
 		}
 	}
 }
-func (n *NormalPush) GetPushParam(mailPush int, u *UserInfo, sl *SortList) *putil.PushParam {
+func (n *NormalPush) GetPushParam(mailPush bool, u *UserInfo, sl *SortList) *putil.PushParam {
 	dateymd := util.NowFormat(util.Date_yyyyMMdd)
 	dayCountKey := DayCountKey(dateymd, u.Id)
 	onceCountKey := OnceCountKey(dateymd, u.Id)
 	dayCount := redis.GetInt("pushcache_2_a", dayCountKey)
 	pushParam := putil.NewPushParam(true, dayCount, mailPush, u, sl)
-	if pushParam == nil || pushParam.InfosLength == 0 {
-		return nil
+	if pushParam.InfosLength == 0 {
+		return pushParam
 	}
 	redis.Put("pushcache_2_a", dayCountKey, dayCount+pushParam.InfosLength, 86400)
 	redis.Put("pushcache_2_a", onceCountKey, pushParam.InfosLength, 86400)
@@ -115,16 +115,17 @@ func (n *NormalPush) GetPushParam(mailPush int, u *UserInfo, sl *SortList) *puti
 		return pushParam
 	}
 	logger.Info(u.Id, "保存成功", pushParam.PushDate, pushParam.InfosLength)
-	now := time.Now()
-	if pushParam.IsVipUser && (u.RateMode == 3 || u.RateMode == 4) && now.Day() != Config.VipPushDay && now.Weekday().String() != Config.VipPushWeek {
-		pushParam.IsVipTempSave = true
+	if IsVipUser(u.VipStatus) && (u.RateMode == 3 || u.RateMode == 4) && !putil.IsVipTempPushTime() {
 		pushParam.IsPush = false
+		n.vipTempSave(u, pushParam)
+	} else {
+		pushParam.IsPush = true
 	}
 	return pushParam
 }
 
 //保存发送信息
-func (n *NormalPush) save(k *UserInfo, matchInfos []*MatchInfo) int64 {
+func (n *NormalPush) save(u *UserInfo, matchInfos []*MatchInfo) int64 {
 	n.SavePool <- true
 	defer func() {
 		<-n.SavePool
@@ -133,14 +134,26 @@ func (n *NormalPush) save(k *UserInfo, matchInfos []*MatchInfo) int64 {
 		time.Sleep(time.Duration(Config.SaveSleep) * time.Millisecond)
 	}
 	unix := time.Now().Unix()
+	isVipUser := IsVipUser(u.VipStatus)
 	values := []interface{}{}
 	for i := len(matchInfos) - 1; i >= 0; i-- {
 		matchInfo := matchInfos[i]
-		values = append(values, k.Id, util.ObjToString((*matchInfo.Info)["_id"]), unix, strings.Join(matchInfo.Keys, " "), util.ObjToString((*matchInfo.Info)["area"]), util.ObjToString((*matchInfo.Info)["city"]), util.ObjToString((*matchInfo.Info)["buyerclass"]))
+		values = append(values, u.Id, util.ObjToString((*matchInfo.Info)["_id"]), unix, strings.Join(matchInfo.Keys, " "), util.ObjToString((*matchInfo.Info)["area"]), util.ObjToString((*matchInfo.Info)["city"]))
+		if isVipUser {
+			values = append(values, util.ObjToString((*matchInfo.Info)["buyerclass"]))
+		} else {
+			values = append(values, putil.GetSubScopeClass((*matchInfo.Info)["s_subscopeclass"]))
+		}
+	}
+	fields := []string{"userid", "infoid", "date", "matchkeys", "area", "city"}
+	if isVipUser {
+		fields = append(fields, "buyerclass")
+	} else {
+		fields = append(fields, "subscopeclass")
 	}
-	savecount := putil.Mysql.InsertBatch("pushsubscribe", []string{"userid", "infoid", "date", "matchkeys", "area", "city", "buyerclass"}, values)
+	savecount := putil.Mysql.InsertBatch("pushsubscribe", fields, values)
 	if int(savecount) != len(matchInfos) {
-		logger.Error(k.Id, "批量保存有问题", len(matchInfos), savecount)
+		logger.Error(u.Id, "批量保存有问题", len(matchInfos), savecount)
 	}
 	if savecount == 0 {
 		return 0
@@ -149,9 +162,9 @@ func (n *NormalPush) save(k *UserInfo, matchInfos []*MatchInfo) int64 {
 }
 
 //vip 每周 每月推送 暂时保存
-func (n *NormalPush) vipTempSave(userId string, pushdate int64, newList []*MatchInfo) {
-	pLength := len(newList)
-	logger.Info(userId, "开始保存到pushspace_vip表", pLength)
+func (n *NormalPush) vipTempSave(u *UserInfo, pushParam *putil.PushParam) {
+	pLength := len(pushParam.Infos)
+	logger.Info(u.Id, "开始保存到pushspace_vip表", pLength)
 	if pLength == 0 {
 		return
 	}
@@ -159,21 +172,27 @@ func (n *NormalPush) vipTempSave(userId string, pushdate int64, newList []*Match
 	defer mongodb.DestoryMongoConn(sess)
 	var data map[string]interface{}
 	coll := sess.DB(putil.DbName).C("pushspace_vip")
-	coll.Find(map[string]interface{}{"userid": userId}).Select(map[string]interface{}{"size": 1, "list": 1, "date": 1, "userid": 1}).One(&data)
+	coll.Find(map[string]interface{}{
+		"userid":   u.Id,
+		"status":   1,
+		"ratemode": u.RateMode,
+	}).Select(map[string]interface{}{"size": 1, "list": 1, "date": 1, "userid": 1}).One(&data)
 	nowymd := util.NowFormat(util.Date_yyyyMMdd)
 	if data == nil { //批量新增
 		if pLength > Config.MaxPushSize {
-			newList = newList[:Config.MaxPushSize]
+			pushParam.Infos = pushParam.Infos[:Config.MaxPushSize]
 		}
 		err := coll.Insert(map[string]interface{}{
-			"userid":     userId,
+			"userid":     u.Id,
 			"size":       pLength,
-			"list":       newList,
+			"list":       pushParam.Infos,
 			"date":       nowymd,
-			"createtime": pushdate,
+			"createtime": pushParam.PushDate,
+			"status":     1,
+			"ratemode":   u.RateMode,
 		})
 		if err != nil {
-			logger.Error(userId, "保存到pushspace_vip出错", err)
+			logger.Error(u.Id, "保存到pushspace_vip出错", err)
 			return
 		}
 	} else { //批量更新
@@ -190,21 +209,21 @@ func (n *NormalPush) vipTempSave(userId string, pushdate int64, newList []*Match
 			count := Config.MaxPushSize - size
 			if pLength > count {
 				for i := 0; i < count; i++ {
-					oldList = append(oldList, newList[i])
+					oldList = append(oldList, pushParam.Infos[i])
 				}
 				set["list"] = oldList
 			} else { //追加
 				upSet["$pushAll"] = map[string]interface{}{
-					"list": newList,
+					"list": pushParam.Infos,
 				}
 			}
 		}
 		upSet["$set"] = set
 		err := coll.UpdateId(data["_id"], upSet)
 		if err != nil {
-			logger.Error(userId, "更新pushspace_vip出错", err)
+			logger.Error(u.Id, "更新pushspace_vip出错", err)
 			return
 		}
 	}
-	logger.Info(userId, "保存到pushspace_vip表结束", pLength)
+	logger.Info(u.Id, "保存到pushspace_vip表结束", pLength)
 }

+ 3 - 3
src/jfw/modules/pushsubscribe/src/push/pusher/pusher.go

@@ -6,8 +6,8 @@ import (
 )
 
 type Pusher interface {
-	OncePushBatch(taskType, batchIndex int, startId *string, args ...interface{}) (bool, *[]map[string]interface{})
-	GetUserInfo(user map[string]interface{}) *UserInfo
-	GetPushParam(mailPush int, k *UserInfo, sl *SortList) *putil.PushParam
+	OncePushBatch(taskType, batchIndex int, startId *string) (bool, *[]map[string]interface{})
+	GetUserInfo(user map[string]interface{}) (*UserInfo, *putil.PushWay)
+	GetPushParam(mailPush bool, k *UserInfo, sl *SortList) *putil.PushParam
 	AfterPush(pushResult *putil.PushResult, u *UserInfo, user map[string]interface{})
 }

+ 36 - 21
src/jfw/modules/pushsubscribe/src/push/pusher/repairpush.go

@@ -11,13 +11,14 @@ import (
 )
 
 //推送失败,补推
-type RepairPush struct{}
+type RepairPush struct {
+	Param string
+}
 
 //获取需要推送的用户
-func (r *RepairPush) OncePushBatch(taskType, batchIndex int, startId *string, args ...interface{}) (bool, *[]map[string]interface{}) {
-	param := args[0].(string)
+func (r *RepairPush) OncePushBatch(taskType, batchIndex int, startId *string) (bool, *[]map[string]interface{}) {
 	query := map[string]interface{}{}
-	if param == "all" {
+	if r.Param == "all" {
 		if *startId != "" {
 			query["_id"] = map[string]interface{}{
 				"$gt": bson.ObjectIdHex(*startId),
@@ -25,28 +26,41 @@ func (r *RepairPush) OncePushBatch(taskType, batchIndex int, startId *string, ar
 		}
 	} else {
 		ids := []bson.ObjectId{}
-		for _, v := range strings.Split(param, ",") {
+		for _, v := range strings.Split(r.Param, ",") {
 			ids = append(ids, bson.ObjectIdHex(v))
 		}
 		query["_id"] = map[string]interface{}{
 			"$in": ids,
 		}
+		batchIndex = -1
 	}
-	batchIndex = -1
 	return putil.GetPushDatas(taskType, batchIndex, "pushspace_fail", startId, query)
 }
 
 //获取用户缓存信息
-func (r *RepairPush) GetUserInfo(user map[string]interface{}) *UserInfo {
-	return putil.NewUserInfoByPushSpaceColl(user)
+func (r *RepairPush) GetUserInfo(user map[string]interface{}) (*UserInfo, *putil.PushWay) {
+	userInfo := putil.NewUserInfoByPushSpaceColl(user)
+	pushWay := &putil.PushWay{}
+	wxFail, _ := user["wxfail"].(int)
+	appFail, _ := user["appfail"].(int)
+	mailFail, _ := user["mailfail"].(int)
+	if wxFail > 0 {
+		pushWay.WxPush = true
+	}
+	if appFail > 0 {
+		pushWay.AppPush = true
+	}
+	if mailFail > 0 {
+		pushWay.MailPush = true
+	}
+	return userInfo, pushWay
 }
 
 //获取推送参数
-func (r *RepairPush) GetPushParam(mailPush int, u *UserInfo, sl *SortList) *putil.PushParam {
-	pushParam := putil.NewPushParam(true, 0, mailPush, u, sl)
-	if pushParam != nil {
-		pushParam.IsPush = true
-	}
+func (r *RepairPush) GetPushParam(mailPush bool, u *UserInfo, sl *SortList) *putil.PushParam {
+	pushParam := putil.NewPushParam(false, -1, mailPush, u, sl)
+	pushParam.IsPush = true
+	pushParam.PushDate = u.CreateTime
 	return pushParam
 
 }
@@ -55,7 +69,13 @@ func (r *RepairPush) GetPushParam(mailPush int, u *UserInfo, sl *SortList) *puti
 func (r *RepairPush) AfterPush(pushResult *putil.PushResult, u *UserInfo, user map[string]interface{}) {
 	sess := mongodb.GetMgoConn()
 	defer mongodb.DestoryMongoConn(sess)
-	if pushResult.WxStatus == -1 || pushResult.AppStatus == -1 || pushResult.MailStatus == -1 {
+	coll := sess.DB(putil.DbName).C("pushspace_fail")
+	if pushResult == nil || (pushResult.WxStatus != -1 && pushResult.AppStatus != -1 && pushResult.MailStatus != -1) {
+		err := coll.RemoveId(user["_id"])
+		if err != nil {
+			logger.Error(u.Id, "删除pushspace_fail表出错", err)
+		}
+	} else {
 		set := map[string]interface{}{}
 		inc := map[string]interface{}{}
 		if pushResult.WxStatus == -1 {
@@ -79,14 +99,9 @@ func (r *RepairPush) AfterPush(pushResult *putil.PushResult, u *UserInfo, user m
 		if len(set) > 0 {
 			update["$set"] = set
 		}
-		err := sess.DB("qfw").C("pushspace_fail").UpdateId(user["_id"], update)
-		if err != nil {
-			logger.Error("补推任务,update error", err)
-		}
-	} else {
-		err := sess.DB(putil.DbName).C("pushspace_fail").RemoveId(user["_id"])
+		err := coll.UpdateId(user["_id"], update)
 		if err != nil {
-			logger.Error("补推任务,update error", err)
+			logger.Error(u.Id, "更新pushspace_fail表出错", err)
 		}
 	}
 }

+ 67 - 23
src/jfw/modules/pushsubscribe/src/push/pusher/specialpush.go

@@ -5,6 +5,7 @@ import (
 	. "push/config"
 	putil "push/util"
 	"qfw/util/mongodb"
+	"time"
 
 	"github.com/donnie4w/go-logger/logger"
 	"gopkg.in/mgo.v2/bson"
@@ -14,8 +15,22 @@ import (
 type SpecialPush struct{}
 
 //获取需要推送的用户
-func (s *SpecialPush) OncePushBatch(taskType, batchIndex int, startId *string, args ...interface{}) (bool, *[]map[string]interface{}) {
-	query := map[string]interface{}{}
+func (s *SpecialPush) OncePushBatch(taskType, batchIndex int, startId *string) (bool, *[]map[string]interface{}) {
+	query := map[string]interface{}{
+		"status": 1,
+	}
+	if taskType == 3 {
+		query["ratemode"] = 3
+	} else if taskType == 4 {
+		query["ratemode"] = 4
+	} else if taskType == 5 {
+		query["ratemode"] = map[string]interface{}{
+			"$in": []int{4, 5},
+		}
+	} else {
+		logger.Error("taskType error", taskType)
+		return true, nil
+	}
 	if len(Config.TestIds) > 0 {
 		query["userid"] = map[string]interface{}{
 			"$in": Config.TestIds,
@@ -30,43 +45,72 @@ func (s *SpecialPush) OncePushBatch(taskType, batchIndex int, startId *string, a
 }
 
 //获取用户最新信息
-func (s *SpecialPush) GetUserInfo(user map[string]interface{}) *UserInfo {
+func (s *SpecialPush) GetUserInfo(user map[string]interface{}) (*UserInfo, *putil.PushWay) {
 	userId, _ := user["userid"].(string)
-	u := mongodb.FindById("user", userId, UserCollFields)
-	if u == nil || len(*u) == 0 {
-		logger.Error("user表中没有找到该用户信息", userId)
-		return nil
+	rateMode, _ := user["ratemode"].(int)
+	sess := mongodb.GetMgoConn()
+	defer mongodb.DestoryMongoConn(sess)
+	var u map[string]interface{}
+	sess.DB(putil.DbName).C("user").FindId(bson.ObjectIdHex(userId)).One(&u)
+	if u == nil || len(u) == 0 {
+		logger.Error(userId, "user表中没有找到该用户信息")
+		s.deletePushspaceVip(user)
+		return nil, nil
+	}
+	userInfo, _ := NewUserInfoByUserColl(u)
+	if !IsVipUser(userInfo.VipStatus) {
+		logger.Info(userId, "已经不是vip用户了", userInfo.VipStatus)
+		s.deletePushspaceVip(user)
+		return nil, nil
+	}
+	if rateMode != userInfo.RateMode {
+		logger.Info(userId, "用户的推送时间变了", rateMode, userInfo.RateMode)
+		s.deletePushspaceVip(user)
+		return nil, nil
 	}
-	userInfo, _ := NewUserInfoByUserColl(*u)
 	if userInfo != nil {
 		userInfo.Size, _ = user["size"].(int)
 		userInfo.CreateTime, _ = user["createtime"].(int64)
 	}
-	return userInfo
+	pushWay := putil.NewPushWay(userInfo)
+	if !pushWay.WxPush && !pushWay.AppPush && !pushWay.MailPush && !pushWay.PcHelperPush {
+		s.deletePushspaceVip(user)
+		return nil, nil
+	}
+	return userInfo, pushWay
 }
 
-func (s *SpecialPush) GetPushParam(mailPush int, u *UserInfo, sl *SortList) *putil.PushParam {
-	pushParam := putil.NewPushParam(false, 0, mailPush, u, sl)
-	if pushParam != nil {
-		pushParam.IsPush = true
-		pushParam.InfosLength = u.Size
-		pushParam.PushDate = u.CreateTime
-	}
+func (s *SpecialPush) GetPushParam(mailPush bool, u *UserInfo, sl *SortList) *putil.PushParam {
+	pushParam := putil.NewPushParam(false, -1, mailPush, u, sl)
+	pushParam.IsPush = true
+	pushParam.InfosLength = u.Size
+	pushParam.PushDate = u.CreateTime
 	return pushParam
 }
 
 //推送以后处理
 func (s *SpecialPush) AfterPush(pushResult *putil.PushResult, u *UserInfo, user map[string]interface{}) {
-	if pushResult.PushDate == 0 {
-		return
-	}
-	if pushResult.WxStatus == 0 && pushResult.AppStatus == 0 && pushResult.MailStatus == 0 {
-		return
+	if pushResult == nil || (pushResult.WxStatus != -1 && pushResult.AppStatus != -1 && pushResult.MailStatus != -1) {
+		s.deletePushspaceVip(user)
+	} else {
+		sess := mongodb.GetMgoConn()
+		defer mongodb.DestoryMongoConn(sess)
+		err := sess.DB(putil.DbName).C("pushspace_vip").UpdateId(user["_id"], map[string]interface{}{
+			"failtime": time.Now().Unix(),
+			"status":   -1,
+		})
+		if err != nil {
+			logger.Error(u.Id, "更新pushspace_vip数据出错", err)
+		}
 	}
+}
+
+//删除临时表数据
+func (s *SpecialPush) deletePushspaceVip(u map[string]interface{}) {
 	sess := mongodb.GetMgoConn()
 	defer mongodb.DestoryMongoConn(sess)
-	err := sess.DB(putil.DbName).C("pushspace_vip").RemoveId(user["_id"])
+	err := sess.DB(putil.DbName).C("pushspace_vip").RemoveId(u["_id"])
 	if err != nil {
-		logger.Error(u.Id, "删除pushspace_vip数据出错", err)
+		logger.Error(u["userid"], "删除pushspace_vip数据出错", err)
 	}
 }

+ 6 - 5
src/jfw/modules/pushsubscribe/src/push/rpc/rpc.go

@@ -1,7 +1,8 @@
 package rpc
 
 import (
-	"push/job"
+	. "push/job"
+	. "push/pusher"
 
 	"github.com/donnie4w/go-logger/logger"
 )
@@ -12,10 +13,10 @@ type Rpc struct {
 //企明星后台补推rpc接口
 func (p *Rpc) RepairPush(req string, res *string) error {
 	logger.Info("rpc接收到需要补推的请求", req)
-	if job.Jobs.Repair.Execute(req) {
-		*res = "y"
-	} else {
-		*res = "n"
+	var pusher Pusher = &RepairPush{
+		Param: req,
 	}
+	Jobs.Push.StartPush(pusher, 0)
+	*res = "y"
 	return nil
 }

+ 65 - 26
src/jfw/modules/pushsubscribe/src/push/util/entity.go

@@ -6,6 +6,8 @@ import (
 	. "push/config"
 	"qfw/util"
 	"strings"
+
+	"github.com/donnie4w/go-logger/logger"
 )
 
 //推送返回结果
@@ -17,20 +19,63 @@ type PushResult struct {
 	PushDate      int64
 	Infos         []*MatchInfo
 }
+type PushWay struct {
+	WxPush       bool
+	AppPush      bool
+	MailPush     bool
+	PcHelperPush bool
+}
+
+//获取推送方式
+func NewPushWay(u *UserInfo) *PushWay {
+	wxPush, appPush, mailPush := false, false, false
+	if u.WxPush == 1 {
+		wxPush = true
+	}
+	if u.AppPush == 1 {
+		appPush = true
+	}
+	if u.MailPush == 1 {
+		mailPush = true
+	}
+	//再对取消关注以及app没有登录的用户进行过滤,但是依然可以进行助手推送
+	if u.Subscribe == 0 {
+		wxPush = false
+	}
+	if u.Jpushid == "" && u.Opushid == "" {
+		appPush = false
+	}
+	if mailPush {
+		if u.UserType == 0 && u.Subscribe == 0 {
+			mailPush = false
+		} else if (u.UserType == 1 || u.UserType == 2) && u.Jpushid == "" && u.Opushid == "" {
+			mailPush = false
+		} else if u.UserType == 5 && u.Subscribe == 0 && u.Jpushid == "" && u.Opushid == "" {
+			mailPush = false
+		}
+	}
+	pushWay := &PushWay{
+		WxPush:       wxPush,
+		AppPush:      appPush,
+		MailPush:     mailPush,
+		PcHelperPush: u.PcHelperPush == 1,
+	}
+	logger.Info("用户接收方式", "userId", u.Id, "wxPush", pushWay.WxPush, "appPush", pushWay.AppPush, "mailPush", pushWay.MailPush, "pcHelperPush", pushWay.PcHelperPush)
+	return pushWay
+}
+
 type PushParam struct {
-	JpushTitle    string
-	LastInfoDate  int64
-	TitleArray    []string
-	Infos         []*MatchInfo
-	InfosLength   int
-	IsVipUser     bool
-	MailContent   string
-	PushDate      int64
-	IsPush        bool
-	IsVipTempSave bool
+	JpushTitle   string
+	LastInfoDate int64
+	TitleArray   []string
+	Infos        []*MatchInfo
+	InfosLength  int
+	MailContent  string
+	PushDate     int64
+	IsPush       bool
 }
 
-func NewPushParam(isLimit bool, dayCount, mailPush int, u *UserInfo, sl *SortList) *PushParam {
+func NewPushParam(isLimit bool, dayCount int, mailPush bool, u *UserInfo, sl *SortList) *PushParam {
 	mailContent := ""
 	jpushTitle := ""
 	lastInfoDate := int64(0)
@@ -61,20 +106,15 @@ func NewPushParam(isLimit bool, dayCount, mailPush int, u *UserInfo, sl *SortLis
 		}
 		//增加行业的处理
 		industry := ""
-		industryclass := "industry"
-		if k2["s_subscopeclass"] != nil {
-			k2sub := strings.Split(util.ObjToString(k2["s_subscopeclass"]), ",")
-			if len(k2sub) > 0 {
-				industry = k2sub[0]
-				if industry != "" {
-					ss := strings.Split(industry, "_")
-					if len(ss) > 1 {
-						industry = ss[0]
-					}
-				}
-			}
+		industryclass := ""
+		if isVipUser {
+			industryclass = "buyerclass"
+			industry, _ = k2["buyerclass"].(string)
+		} else {
+			industryclass = "subscopeclass"
+			industry = GetSubScopeClass(k2["s_subscopeclass"])
 		}
-		if mailPush == 1 { //关于邮件的处理
+		if mailPush && infosLength <= Config.MaxPushSize { //关于邮件的处理
 			mailSid := util.CommonEncodeArticle("mailprivate", util.ObjToString(k2["_id"]))
 			url := fmt.Sprintf("%s/article/mailprivate/%s.html", Config.JianyuDomain, mailSid)
 			classArea := "area"
@@ -94,7 +134,7 @@ func NewPushParam(isLimit bool, dayCount, mailPush int, u *UserInfo, sl *SortLis
 			dates := util.LongToDate(k2["publishtime"], false)
 			//标题替换
 			otitle := title
-			for _, kw := range u.Keys {
+			for _, kw := range ks.Keys {
 				kws := strings.Split(kw, "+")
 				n := 0
 				otitle2 := otitle
@@ -137,7 +177,6 @@ func NewPushParam(isLimit bool, dayCount, mailPush int, u *UserInfo, sl *SortLis
 		TitleArray:   titleArray,
 		Infos:        infos,
 		InfosLength:  infosLength,
-		IsVipUser:    isVipUser,
 		MailContent:  mailContent,
 	}
 }

+ 1 - 2
src/jfw/modules/pushsubscribe/src/push/util/rpccall.go

@@ -31,14 +31,13 @@ func SendWeixin(k *UserInfo, remark, title string, pushDate int64) bool {
 	if Config.WxSleep > 0 {
 		time.Sleep(time.Duration(Config.WxSleep) * time.Millisecond)
 	}
-	now := time.Now()
 	p := &qrpc.NotifyMsg{
 		Openid:      k.S_m_openid,
 		Title:       title,
 		Remark:      remark,
 		Detail:      Config.WxGroup,
 		Date:        "",
-		Service:     util.FormatDate(&now, util.Date_Short_Layout),
+		Service:     util.NowFormat(util.Date_Short_Layout),
 		Color:       Config.WxColor,
 		DetailColor: Config.WxDetailColor,
 		Url:         Config.JianyuDomain + "/front/sess/" + Se.EncodeString(k.S_m_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",historypush") + "__" + fmt.Sprint(pushDate),

+ 32 - 5
src/jfw/modules/pushsubscribe/src/push/util/util.go

@@ -7,6 +7,7 @@ import (
 	"qfw/util"
 	"qfw/util/mongodb"
 	"sort"
+	"strings"
 	"time"
 
 	"github.com/donnie4w/go-logger/logger"
@@ -20,7 +21,7 @@ func ToObjectIds(ids []string) []bson.ObjectId {
 	}
 	return _ids
 }
-func ToSortList(list interface{}) SortList {
+func ToSortList(list interface{}) *SortList {
 	if list == nil {
 		return nil
 	}
@@ -34,7 +35,7 @@ func ToSortList(list interface{}) SortList {
 		return nil
 	}
 	sort.Sort(sl)
-	return sl
+	return &sl
 }
 
 //控制一分钟最大推送数,均匀调度
@@ -64,7 +65,7 @@ func NewUserInfoByPushSpaceColl(user map[string]interface{}) *UserInfo {
 		WxPush:        util.IntAll(user["wxpush"]),
 		AppPush:       util.IntAll(user["apppush"]),
 		MailPush:      util.IntAll(user["mailpush"]),
-		PchelperPush:  util.IntAll(user["pchelperpush"]),
+		PcHelperPush:  util.IntAll(user["pchelperpush"]),
 		Email:         util.ObjToString(user["email"]),
 		S_m_openid:    util.ObjToString(user["s_m_openid"]),
 		A_m_openid:    util.ObjToString(user["a_m_openid"]),
@@ -83,7 +84,9 @@ func NewUserInfoByPushSpaceColl(user map[string]interface{}) *UserInfo {
 	}
 }
 
-//获取一批次推送的数据
+/*获取一批次推送的数据
+ *batchIndex < 0 不走分批次加载
+ */
 func GetPushDatas(taskType, batchIndex int, collection string, startId *string, query map[string]interface{}) (bool, *[]map[string]interface{}) {
 	logger.Info(taskType, "开始加载第", batchIndex, "批用户", query)
 	sess := mongodb.GetMgoConn()
@@ -101,5 +104,29 @@ func GetPushDatas(taskType, batchIndex int, collection string, startId *string,
 		}
 	}
 	logger.Info(taskType, "第", batchIndex, "批用户加载结束", *startId)
-	return i < Config.PushBatch, &users
+	return batchIndex < 0 || i < Config.PushBatch, &users
+}
+
+//是否是一个月或者一周推送一次的时间
+func IsVipTempPushTime() bool {
+	now := time.Now()
+	return now.Day() == Config.VipPushDay || now.Weekday().String() == Config.VipPushWeek
+}
+
+//获取信息行业
+func GetSubScopeClass(subscopeclass interface{}) string {
+	industry := ""
+	if subscopeclass != nil {
+		k2sub := strings.Split(util.ObjToString(subscopeclass), ",")
+		if len(k2sub) > 0 {
+			industry = k2sub[0]
+			if industry != "" {
+				ss := strings.Split(industry, "_")
+				if len(ss) > 1 {
+					industry = ss[0]
+				}
+			}
+		}
+	}
+	return industry
 }

+ 2 - 1
src/jfw/modules/subscribepay/src/a/init.go

@@ -18,8 +18,9 @@ func init() {
 	xweb.RootApp().AppConfig.EnableHttpCache = false
 	xweb.RootApp().AppConfig.Mode = xweb.Product
 	xweb.RootApp().AppConfig.ReloadTemplates = true
-	xweb.RootApp().AppConfig.SessionTimeout = 30 * time.Minute
+	xweb.RootApp().AppConfig.SessionTimeout = 7 * 24 * time.Hour
 	xweb.RootApp().Logger.SetOutputLevel(1) //输出日志,改为4则不输出任何日志
+	xweb.RootApp().AppConfig.StaticDir = "web/staticres"
 	//
 	xweb.AddRouter("/subscribepay", &service.AfterPay{})
 	xweb.AddRouter("/subscribepay", &service.TrialOrder{})       //试用&订单

+ 14 - 11
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -100,9 +100,9 @@ func (this *vipSubscribeStruct) PayCallBack(param *CallBackParam) bool {
 	} else if vmsg.OrderType == 2 { //续费
 		flag = JyVipSubStruct.RenewSubVip(userid, qutil.ObjToString((*orderdata)["vip_endtime"]))
 	} else if vmsg.OrderType == 3 { //立即升级
-		flag = JyVipSubStruct.UpgradeSubVip(userid, vmsg, qutil.ObjToString((*orderdata)["vip_starttime"]), qutil.ObjToString((*orderdata)["vip_endtime"]), true)
+		flag = JyVipSubStruct.UpgradeSubVip(userid, vmsg, qutil.ObjToString((*orderdata)["vip_endtime"]), true)
 	} else if vmsg.OrderType == 4 || vmsg.OrderType == 5 { //下月升级
-		flag = JyVipSubStruct.UpgradeSubVip(userid, vmsg, qutil.ObjToString((*orderdata)["vip_starttime"]), qutil.ObjToString((*orderdata)["vip_endtime"]), false)
+		flag = JyVipSubStruct.UpgradeSubVip(userid, vmsg, qutil.ObjToString((*orderdata)["vip_endtime"]), false)
 	}
 	//支付成功后 其他未支付vip订阅订单 变为已取消
 	if flag {
@@ -144,16 +144,16 @@ func (this *vipSubscribeStruct) RenewSubVip(userId, endtime string) bool {
 		log.Println("%s格式化日期出错%s\n", userId, endtime)
 		return false
 	}
-	return util.MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{"l_vip_endtime": prepayTime.Unix()}})
+	return util.MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{"l_vip_endtime": prepayTime.Unix(), "i_vip_expire_tip": 0}})
 }
 
 //升级
-func (this *vipSubscribeStruct) UpgradeSubVip(userId string, vmsg VipSimpleMsg, start, end string, isNow bool) bool {
-	startTime, err := time.ParseInLocation(qutil.Date_Full_Layout, start, time.Local)
-	if err != nil {
-		log.Println("%s格式化日期出错%s\n", userId, start)
-		return false
-	}
+func (this *vipSubscribeStruct) UpgradeSubVip(userId string, vmsg VipSimpleMsg, end string, isNow bool) bool {
+	//	startTime, err := time.ParseInLocation(qutil.Date_Full_Layout, start, time.Local)
+	//	if err != nil {
+	//		log.Println("%s格式化日期出错%s\n", userId, start)
+	//		return false
+	//	}
 	endTime, err := time.ParseInLocation(qutil.Date_Full_Layout, end, time.Local)
 	if err != nil {
 		log.Println("%s格式化日期出错%s\n", userId, endTime)
@@ -168,21 +168,24 @@ func (this *vipSubscribeStruct) UpgradeSubVip(userId string, vmsg VipSimpleMsg,
 				"o_vipjy.o_buyset":     buyset,
 				"l_vip_endtime":        endTime.Unix(),
 				"i_vip_status":         2,
+				"i_vip_expire_tip":     0,
 			}})
 	} else {
 		if !util.MQFW.UpdateById("user", userId,
 			bson.M{"$set": bson.M{
-				"l_vip_endtime": endTime.Unix(),
+				"l_vip_endtime":    endTime.Unix(),
+				"i_vip_expire_tip": 0,
 			}}) {
 			log.Printf("%s更新结束%d日期出错\n", userId, endTime.Unix())
 			return false
 		}
+		effectTime := time.Date(time.Now().Year(), time.Now().Month()+1, 1, 0, 0, 0, 0, time.Local)
 		return util.MQFW.Save("vip_upgrade",
 			bson.M{
 				"s_userid":     userId,            //试用设置地区
 				"a_buyerclass": vmsg.Industry,     //试用设置行业
 				"o_area":       vmsg.Area,         //购买内容 城市、省份、行业数量
-				"l_validtime":  startTime.Unix(),  //生效时间
+				"l_validtime":  effectTime.Unix(), //生效时间
 				"l_createtime": time.Now().Unix(), //入库时间
 				"o_buyset":     buyset,            //购买内容数量
 				"i_isvalid":    0,                 //是否已经生效 0-未生效

+ 52 - 2
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -245,8 +245,8 @@ func (o *OrderListDetails) SetEmail() {
 		var email_used = true
 		if email != o.GetSession("EmailBindingVerifyEmail") {
 			//user表里校验邮箱是否被使用  字段待定
-			res, _ := util.MQFW.FindOne("user", bson.M{"email": email})
-			if res != nil && qutil.ObjToString((*res)["email"]) != "" {
+			res, _ := util.MQFW.FindOne("user", bson.M{"s_myemail": email})
+			if res != nil && qutil.ObjToString((*res)["s_myemail"]) != "" {
 				email_used = false
 				o.T["success"] = false
 				o.T["errCode"] = 4
@@ -354,6 +354,26 @@ func (o *OrderListDetails) SetRes(res []map[string]interface{}, queryM map[strin
 	}
 	delete(queryM, "product_type")
 	for _, v := range res {
+		//获取单号 如果是vip 48小时取消
+		order_code := qutil.ObjToString(v["order_code"])
+		create_time_str := qutil.ObjToString(v["create_time"])
+		//创建时间戳
+		create_time, _ := time.ParseInLocation(qutil.Date_Full_Layout, create_time_str, time.Local)
+		//48小时后的时间戳
+		create_time_stamp := create_time.AddDate(0, 0, 2).Unix()
+		//当前时间时间戳
+		now_time_stamp := time.Now().Unix()
+		if create_time_stamp < now_time_stamp && qutil.ObjToString(v["product_type"]) == "VIP订阅" {
+			if v["order_status"] != nil {
+				order_status := qutil.Int64All(v["order_status"])
+				if order_status == 0 {
+					//数据库更改
+					go FortyEightHoursCancel(order_code, create_time_stamp, now_time_stamp)
+					//前端传参更改
+					v["order_status"] = orderStatus_cancel
+				}
+			}
+		}
 		if v["filter_publishtime"] != nil {
 			filter_publishtime := v["filter_publishtime"]
 			if filter_publishtime != nil {
@@ -436,3 +456,33 @@ func getPayTransactionId(payWay, tradeNo string) (transaction_id string) {
 	}
 	return
 }
+
+//检查vip订单是否到期,如果到期 订单取消48h
+func FortyEightHoursCancel(order string, create_time_stamp, now_time_stamp int64) {
+	//查询vip订单条件
+	queryM := map[string]interface{}{
+		"order_code":   order,
+		"product_type": "VIP订阅",
+	}
+	flag := false
+	//order := util.Mysql.FindOne(tableName_order, queryMap, "pay_way,out_trade_no,prepay_time,order_status", "")
+	res := util.Mysql.FindOne(tableName_order, queryM, "id,order_code,create_time,pay_way,out_trade_no,prepay_time,order_status,user_id", "")
+	if res != nil {
+		id := qutil.Int64All((*res)["id"])
+		queryMap := map[string]interface{}{
+			"id":      id,
+			"user_id": qutil.ObjToString((*res)["user_id"]),
+		}
+		//如果超过48小时 取消订单  创建48小时后的时间戳<当前时间戳
+		if create_time_stamp < now_time_stamp {
+			if qutil.IntAll((*res)["order_status"]) == 0 { //未支付状态下 删除订单需要先关闭订单
+				flag = pay.CloseDataExportOrder(qutil.ObjToString((*res)["pay_way"]), qutil.ObjToString((*res)["out_trade_no"]), qutil.ObjToString((*res)["prepay_time"]))
+			} else {
+				flag = true
+			}
+			if flag {
+				flag = util.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -2})
+			}
+		}
+	}
+}

+ 3 - 3
src/jfw/modules/subscribepay/src/service/vipRenewUpgrade.go

@@ -117,15 +117,15 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 		if pay_source == "Upgrade" { //计算升级时间
 			if effect == "now" { //立即生效
 				orderType = 3
-				startTime = time.Now()
+				//				startTime = time.Now()
 			} else { //下月生效
 				orderType = 4
-				startTime = time.Date(time.Now().Year(), time.Now().Month()+1, 1, 0, 0, 0, 0, time.Local)
+				//				startTime = time.Date(time.Now().Year(), time.Now().Month()+1, 1, 0, 0, 0, 0, time.Local)
 			}
 
 		} else { //续费时间
 			orderType = 2 //续费操作
-			startTime = endTime
+			//			startTime = endTime
 		}
 		//		if date_unit == 1 { ///延长时间
 		//			endTime = endTime.AddDate(date_count, 0, 0)

+ 1 - 1
src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go

@@ -114,7 +114,7 @@ func (t *TrialOrder) SendPhoneCaptcha() {
 		}
 		imgcode_sess := qutil.ObjToString(t.GetSession("subvip_trial_imgCode"))
 		if !captcha.VerifyString(imgcode_sess, imgcode_req) || imgcode_req == "" {
-			return false, "验证码不正确"
+			return false, "图形验证码不正确"
 		}
 		//获取上次发送验证码时间
 		lastSend := qutil.Int64All(t.GetSession("subvip_trial_lastSend"))

+ 7 - 4
src/jfw/modules/subscribepay/src/timetask/timetask.go

@@ -92,15 +92,18 @@ func checkIsExpire() {
 			l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
 			i_vip_status := qutil.IntAll(m["i_vip_status"])
 			i_vip_expire_tip := qutil.IntAll(m["i_vip_expire_tip"])
-			if l_vip_endtime < now_unix {
+			if l_vip_endtime <= now_unix {
 				util.MQFW.UpdateById("user", _id, map[string]interface{}{
 					"$set": map[string]interface{}{
 						"i_vip_status":     -i_vip_status,
 						"i_vip_expire_tip": 2,
 					},
 				})
-				log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改到期状态")
-			} else if l_vip_endtime-now_unix <= threeday && i_vip_expire_tip == 0 {
+				for _, pushColl := range []string{"pushspace", "pushspace_temp", "pushspace_vip", "pushspace_fail"} {
+					util.MQFW.Del(pushColl, map[string]interface{}{"userid": _id})
+				}
+				log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改已到期状态")
+			} else if l_vip_endtime-now_unix <= threeday && i_vip_expire_tip != 1 && i_vip_expire_tip != -1 {
 				updateOk := util.MQFW.UpdateById("user", _id, map[string]interface{}{
 					"$set": map[string]interface{}{
 						"i_vip_expire_tip": 1,
@@ -187,7 +190,7 @@ func expireRemind() {
 			if wxPushOk || appPushOk {
 				util.MQFW.UpdateById("user", _id, map[string]interface{}{
 					"$set": map[string]interface{}{
-						"i_vip_expire_tip": 0,
+						"i_vip_expire_tip": -i_vip_expire_tip,
 					},
 				})
 			}

+ 1 - 1
src/main.go

@@ -100,7 +100,7 @@ func initXweb() {
 	xweb.RootApp().AppConfig.Mode = xweb.Product
 	xweb.RootApp().SetConfig("schecm", Sysconfig["agreement"])
 	xweb.RootApp().AppConfig.ReloadTemplates = true
-	xweb.RootApp().AppConfig.SessionTimeout = 30 * time.Minute
+	xweb.RootApp().AppConfig.SessionTimeout = 7 * 24 * time.Hour
 	xweb.RootApp().AppConfig.CacheTemplates = Sysconfig["cacheflag"].(bool)
 	xweb.RootApp().AddTmplVar("Msg", tag.Msg)
 	xweb.RootApp().AddTmplVar("Ad", tag.Ad)

BIN
src/web/staticres/images/mail.png


BIN
src/web/staticres/images/phone.png


+ 2 - 1
src/web/templates/weixin/dataExport/dataExport_toMyOrder.html

@@ -440,7 +440,7 @@
 			function beforeJump(eid,isVipOrder){
 				setSessionStorage();
 				if (isVipOrder=="true"){
-					window.location.href="/front/vipsubscribe/toOrderDetailPage?orderCode="+eid;
+					window.location.href="/weixin/pay/toOrderDetailPage?orderCode="+eid;
 				}else{
 					window.location.href="/weixin/pay/wxToOrderDetail?orderCode="+eid;
 				}
@@ -633,6 +633,7 @@
 					var result = true;
 					$.post("/subscribepay/orderListDetails/myOrder",{"type":typ},function(data){
 							$(".loading_").hide();
+							console.log(data.res)
 							var list=data.res;
 							dataCache =data.res;
 							pageIndex=2;

+ 4 - 4
src/web/templates/weixin/email/bind_email.html

@@ -114,13 +114,13 @@
 								if(data.success){
 									if ($("#bindBtn").text()=="确定"){	//更改绑定
 										sessionStorage.removeItem("send_myemail_"+{{.T.userId}});
-										window.location.replace("/front/wxMyOrder/setSuccess?name=changeEmail"); 
+										window.location.replace("/jyapp/front/myorder/setSuccess?name=changeEmail"); 
 									}else{
 										sessionStorage.removeItem("send_myemail_"+{{.T.userId}});
-										if((param="invoice")&&(orderCode!="")){
-											window.location.replace("/front/wxMyOrder/setSuccess?name=invoice&orderCode="+orderCode); 
+										if((param="invoice")&&(orderCode!=null)){
+											window.location.replace("/jyapp/front/myorder/setSuccess?name=invoice&orderCode="+orderCode); 
 										}else{
-											window.location.replace("/front/wxMyOrder/setSuccess?name=bindEmail"); 
+											window.location.replace("/jyapp/front/myorder/setSuccess?name=bindEmail"); 
 										}
 									}
 								}

+ 57 - 11
src/web/templates/weixin/email/bind_success.html

@@ -1,33 +1,79 @@
 <!DOCTYPE html>
 <html>
 	<head>
-		<meta charset="utf-8">
		<title>绑定成功</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+		<meta charset="utf-8">
+		<title>绑定成功</title>
+		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
 		<link rel="stylesheet" href="{{Msg "seo" "cdn"}}/wxmyemail/css/reset.css?v={{Msg "seo" "version"}}">
 		<link rel="stylesheet" href="{{Msg "seo" "cdn"}}/wxmyemail/css/common.css?v={{Msg "seo" "version"}}">
 		<link rel="stylesheet" href="{{Msg "seo" "cdn"}}/wxmyemail/css/mine.css?v={{Msg "seo" "version"}}"/>   
 		{{include "/common/weixin.html"}}
-		<script src="{{Msg "seo" "cdn"}}/wxswordfish/share.js?v={{Msg "seo" "version"}}"></script>    
+		<script src="{{Msg "seo" "cdn"}}/wxswordfish/share.js?v={{Msg "seo" "version"}}"></script>    
 	</head>
 	<body>
-		<div class="bind_success">
			<div class="success">
				<img src="{{Msg "seo" "cdn"}}/wxmyemail/img/successed.png" >
				<p></p>
			</div>
			<button class="common_btn back">返回 <time class="time">()</time> </button>
		</div>
		<script src="{{Msg "seo" "cdn"}}/wxmyemail/js/zepto.js"></script>
		<script src="{{Msg "seo" "cdn"}}/wxmyemail/js/public.js"></script>
		<script>
			$(function(){
+		<div class="bind_success">
+			<div class="success">
+				<img src="{{Msg "seo" "cdn"}}/wxmyemail/img/successed.png" >
+				<p></p>
+			</div>
+			<button class="common_btn back">返回 <time class="time">()</time> </button>
+		</div>
+		<script src="{{Msg "seo" "cdn"}}/wxmyemail/js/zepto.js"></script>
+		<script src="{{Msg "seo" "cdn"}}/wxmyemail/js/public.js"></script>
+		<script>
+			$(function(){
 				//分享
-				initShare({{.T.signature}},{{.T.openid}},2,"jy_wxmyorder",{{.T.nickname}},{{.T.avatar}});
				
+				initShare({{.T.signature}},{{.T.openid}},2,"jy_wxmyorder",{{.T.nickname}},{{.T.avatar}});
+				
 				let param = getParam('name');//获取url传来的参数 判断显示成功的字幕
-				var orderCode=getParam("orderCode"); //开发票的订单
				console.log(param)
				var time = 6;
				function countDown(){
					if(time == 0){
						$('.time').html('');
+				var orderCode=getParam("orderCode"); //开发票的订单
+				console.log(param)
+				var time = 6;
+				function countDown(){
+					if(time == 0){
+						$('.time').html('');
 						if((param="invoice")&&(orderCode!="")){
-							window.location.replace('/front/vipsubscribe/toOrderDetailPage?orderCode='+orderCode);
+							window.location.replace('/weixin/pay/toOrderDetailPage?orderCode='+orderCode);
 						}else{
 							window.location.replace('/front/wxMyOrder/myEmail');
-						}
					}else{
						$('.time').html('(' + time + ')');
						time--;
						setTimeout(()=>{
							countDown()
						},1000)
					}
				}
				if(param == 'bindEmail'){
					$('.success>p').html('邮箱绑定成功');
					countDown();
				}else if(param == 'bindPhoe'){
					$('.success>p').html('手机号绑定成功');
					countDown();
				}else if(param == 'changeEmail'){
					$('.success>p').html('邮箱更换成功');
					countDown();
				}else if(param == 'choosePhone'){
					$('.success>p').html('手机号更换成功');
					countDown();
				}else if(param =="unbind"){
+						}
+					}else{
+						$('.time').html('(' + time + ')');
+						time--;
+						setTimeout(()=>{
+							countDown()
+						},1000)
+					}
+				}
+				if(param == 'bindEmail'){
+					$('.success>p').html('邮箱绑定成功');
+					countDown();
+				}else if(param == 'bindPhoe'){
+					$('.success>p').html('手机号绑定成功');
+					countDown();
+				}else if(param == 'changeEmail'){
+					$('.success>p').html('邮箱更换成功');
+					countDown();
+				}else if(param == 'choosePhone'){
+					$('.success>p').html('手机号更换成功');
+					countDown();
+				}else if(param =="unbind"){
 					$('.success>p').html('邮箱解绑成功');
 					countDown();
 				}else if(param=="invoice"){
 					$('.success>p').html('邮箱绑定成功');
 					countDown();
-				}
				/* 返回 */
				$('.back').on('click',() =>{
					if((param="invoice")&&(orderCode!="")){
-							window.location.replace('/front/vipsubscribe/toOrderDetailPage?orderCode='+orderCode);
+				}
+				/* 返回 */
+				$('.back').on('click',() =>{
+					if((param="invoice")&&(orderCode!="")){
+							window.location.replace('/weixin/pay/toOrderDetailPage?orderCode='+orderCode);
 						}else{
 							window.location.replace('/front/wxMyOrder/myEmail');
-						}
				})
			})
		</script>
-	{{include "/common/baiducc.html"}}
	</body>
+						}
+				})
+			})
+		</script>
+	{{include "/common/baiducc.html"}}
+	</body>
 </html>

+ 26 - 6
src/web/templates/weixin/vipsubscribe/choose_area.html

@@ -466,7 +466,7 @@
         getResult:function(){   /* 选中结果 */
           //如果选中所有,则转为全国
           if($(".city").length==$(".city.active").length){
-            $(".checkbox.other").trigger("click");
+            $(".checkbox.other").trigger("click");           
             return
           }
           this.selectObj = {};
@@ -477,14 +477,14 @@
           if ($('.other').is(':checked')) {
             // data.push(val)
             data =[{name:val,children:[]}] //全国
+            $(".tips_d_text").slideUp();
           }
           $(".tab_content").find(".city.active:not('[disabled]')").each(function () {
               var length = $(this).parent('.tab_content').find('.city').length; //省份下城市的length
               var activeLeng = $(this).parent('.tab_content').find('.city.active').length; //省份下选中城市的length
               let arr =[];
               // 判断省份下的城市是否等于选中的城市长度,相等就是全部选中
-              if (length == activeLeng) {
-                  $('.tips_btn .tips_d_text').hide()
+              if (length == activeLeng) {                  
                   // data.push($(this).parent('.tab_content').siblings('.tab:not(.whole)').children('.province').text().trim())
                   let province = $(this).parent('.tab_content').siblings('.tab:not(.whole)').children('.province').text().trim();
                   data.push({
@@ -524,14 +524,16 @@
               }
           })
           var html = '';
+          var selectProvince = 0;
+          var selectCityMax = 0;
           for (var i = 0; i < result.length; i++) {
               let children = result[i].children;
               if( children.length >0){
                   // 判断每个省份下选中的城市长度,当大于等于4的时候 弹出"选择全省更划算的弹窗"
                   let childrenArr=[];
-                  if (children.length >= 4 && !this.vipSubisTrial) {
-                      $('.tips_btn .tips_d_text').show()
-                  } 
+                  if(children.length>selectCityMax){
+                    selectCityMax = children.length;
+                  }
                   html += `${result[i].name}(`
                   for(var j = 0;j < children.length;j++){
                       childrenArr.push(children[j].name)
@@ -548,6 +550,8 @@
                   }
                   this.selectObj[result[i].name]=childrenArr;//
               }else{
+                  selectProvince++
+                 
                   if(i !=result.length -1){
                       html += `${result[i].name}、`
                   }else{
@@ -556,6 +560,22 @@
                   this.selectObj[result[i].name]=[];//
               }
           }
+          
+          //提示
+          if(!this.vipSubisTrial){
+            if(selectProvince>9){
+              $('.tips_btn .tips_d_text').text("已选择"+selectProvince+"个省,建议购买“全国”更划算哦~").slideDown()
+            }else{
+              if (selectCityMax > 3) {
+                $('.tips_btn .tips_d_text').text("已选择"+selectCityMax+"个市,建议购买“全省”更划算哦~").slideDown();
+              }else{
+                $(".tips_d_text").slideUp();
+              } 
+            }
+          }
+          
+          
+          
           console.log("this.selectObj:",this.selectObj)
           $('.result_name').append(html)
           AreaChoose.isOpen()

+ 1 - 1
src/web/templates/weixin/vipsubscribe/choose_industry.html

@@ -281,7 +281,7 @@
                 
                 // 显示隐藏优惠tips
                 if (selectedArr.length >= 4 && !vipSubisTrial) {
-                    $('.tips_btn .tips_d_text').slideDown()
+                    $('.tips_btn .tips_d_text').text("已选择"+selectedArr.length+"个行业,建议购买“全部行业”更划算哦~").slideDown()
                 } else {
                     $('.tips_btn .tips_d_text').slideUp()
                 }

+ 2 - 1
src/web/templates/weixin/vipsubscribe/choose_industry_upgrade.html

@@ -291,7 +291,8 @@
                 
                 // 显示隐藏优惠tips
                 if (selectedArr.length >= 4 && !vipSubisTrial) {
-                    $('.tips_btn .tips_d_text').slideDown()
+                	$('.tips_btn .tips_d_text').text("已选择"+selectedArr.length+"个行业,建议购买“全部行业”更划算哦~");
+                    $('.tips_btn .tips_d_text').slideDown();
                 } else {
                     $('.tips_btn .tips_d_text').slideUp()
                 }

+ 1 - 1
src/web/templates/weixin/vipsubscribe/edit_subscribe.html

@@ -114,7 +114,7 @@
           },
           initClick:function(){
             $(".edit_item").on("click",function(){
-               window.location.replace($(this).attr("data_href"));
+               window.location.href=$(this).attr("data_href");
             });
             //提交
           },

+ 17 - 15
src/web/templates/weixin/vipsubscribe/renew_pay.html

@@ -243,20 +243,21 @@
 						setTimeout(function(){
 							window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
 						},500)
-					}else if(r.err_msg == "get_brand_wcpay_request:cancel"){               
-//	                	alert("开发环境【支付跳转完成】")
-		                try{
-//		  					window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
-		                    window.location.reload();
-		                }catch(e){
-		                  alert(e)
-		                }
-	  				}else{
-	                	weui.toast("系统异常,请稍微再试",{
-	                  		duration: 2000,
-	                  		className: 'custom-toast',
-	                	});
-	  				}
+					}	
+//					}else if(r.err_msg == "get_brand_wcpay_request:cancel"){               
+////	                	alert("开发环境【支付跳转完成】")
+//		                try{
+////		  					window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
+////		                    window.location.reload();
+//		                }catch(e){
+//		                  alert(e)
+//		                }
+//	  				}else{
+//	                	weui.toast("系统异常,请稍微再试",{
+//	                  		duration: 2000,
+//	                  		className: 'custom-toast',
+//	                	});
+//	  				}
   				});
   			}   
 		}catch(e){
@@ -539,7 +540,8 @@
 //			    	}
 //			    	$(".item_cycle .label_for").text(dateName);
 //			    }
-			    if(startTime !== "" && endTime !== ""){
+			    if(startTime !== "" && endTime !== "" && startTime !== undefined && endTime !== undefined){
+			    	console.log(startTime)
 			    	var start = startTime.replace(/-/g, ".");
 			    	var end = endTime.replace(/-/g, ".");
 			    	dateHtml = start + " - " + end;

+ 1 - 0
src/web/templates/weixin/vipsubscribe/trial_info.html

@@ -136,6 +136,7 @@
                         className: 'custom-toast',
                       });
                     }
+                    $(".checkCode").attr("src","/subscribepay/trial/captcha?rnd="+Math.random()); //刷新验证码  
                   })
                 }
             })

+ 20 - 27
src/web/templates/weixin/vipsubscribe/vip_introduce.html

@@ -66,20 +66,11 @@
                             <tbody>
                                 <tr>
                                     <td>
-                                        <p class="miantitle">最多<em style="color: #2CB7CA">10</em>组关键词</p>
-                                    </td>
-                                    <td>
-                                        <p class="miantitle">最多<em style="color: #2CB7CA">300</em>组关键词</p>
-                                        <p class="subtitle">更多关键词,招标信息更全面</p>
-                                    </td>  
-                                </tr>
-                                <tr>
-                                    <td>
-                                        <p class="miantitle">每天最多接收<em style="color: #2CB7CA">150</em>条</p>
+                                        <p class="miantitle">匹配单次公告信息</p>
                                     </td>
                                     <td>
-                                        <p class="miantitle">每天最多接收<em style="color: #2CB7CA">2000</em>条</p>
-                                        <p class="subtitle">更多招标信息,重要项目不遗漏</p>
+                                        <p class="miantitle">匹配项目信息</p>
+                                        <p class="subtitle">根据你的订阅,为你推送所匹配项目后续的全部动态</p>
                                     </td>  
                                 </tr>
                                 <tr>
@@ -87,46 +78,48 @@
                                         <p class="miantitle">-</p>
                                     </td>
                                     <td>
-                                        <p class="miantitle">数据周报、月报</p>
-                                        <p class="subtitle">每周、每月推送你的订阅数据统计报告,帮助你全面掌握行业市场动态</p>
+                                        <p class="miantitle">按行业订阅</p>
+                                        <p class="subtitle">不知道如何设置关键词的时候,也可以按行业订阅</p>
                                     </td>  
                                 </tr>
                                 <tr>
                                     <td>
-                                        <p class="miantitle">订阅区域精确到省</p>
+                                        <p class="miantitle">最多<em style="color: #2CB7CA">10</em>组关键词</p>
                                     </td>
                                     <td>
-                                        <p class="miantitle">订阅区域精确到市</p>
-                                        <p class="subtitle">只看你最关注的招标信息</p>
+                                        <p class="miantitle">最多<em style="color: #2CB7CA">300</em>组关键词</p>
+                                        <p class="subtitle">更多关键词,招标信息更全面</p>
                                     </td>  
                                 </tr>
-                                <tr>
+                                 <tr>
                                     <td>
-                                        <p class="miantitle">-</p>
+                                        <p class="miantitle">仅支持标题匹配</p>
                                     </td>
                                     <td>
-                                        <p class="miantitle">按行业订阅</p>
-                                        <p class="subtitle">不知道如何设置关键词的时候,也可以按行业订阅</p>
+                                        <p class="miantitle">支持标题匹配+全文匹配</p>
+                                        <p class="subtitle">关键词匹配标题或全文 任你选</p>
                                     </td>  
                                 </tr>
                                 <tr>
                                     <td>
-                                        <p class="miantitle">仅支持标题匹配</p>
+                                        <p class="miantitle">订阅区域精确到省</p>
                                     </td>
                                     <td>
-                                        <p class="miantitle">支持标题匹配+全文匹配</p>
-                                        <p class="subtitle">关键词匹配标题或全文 任你选</p>
+                                        <p class="miantitle">订阅区域精确到市</p>
+                                        <p class="subtitle">只看你最关注的招标信息</p>
                                     </td>  
                                 </tr>
+                                <!--
                                 <tr>
                                     <td>
-                                        <p class="miantitle">匹配单次公告信息</p>
+                                        <p class="miantitle">-</p>
                                     </td>
                                     <td>
-                                        <p class="miantitle">匹配项目信息</p>
-                                        <p class="subtitle">根据你的订阅,为你推送所匹配项目后续的全部动态</p>
+                                        <p class="miantitle">数据周报、月报</p>
+                                        <p class="subtitle">每周、每月推送你的订阅数据统计报告,帮助你全面掌握行业市场动态</p>
                                     </td>  
                                 </tr>
+                                -->
                             </tbody>
                         </table>
                     </div>

+ 1 - 1
src/web/templates/weixin/vipsubscribe/vip_pay_success.html

@@ -46,7 +46,7 @@
     $(function(){
       //查看订单
       $(".left_btn").on("click",function(){
-        window.location.href ='/front/vipsubscribe/toOrderDetailPage?orderCode='+orderCode
+        window.location.href ='/weixin/pay/toOrderDetailPage?orderCode='+orderCode
       })
       //设置关键词
       $(".right_btn").on("click",function(){

+ 9 - 11
src/web/templates/weixin/vipsubscribe/vip_purchase.html

@@ -304,14 +304,9 @@
   							setTimeout(function(){
   								window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
   							},500)
-  						}else if(r.err_msg == "get_brand_wcpay_request:cancel"){               
-                alert("开发环境【支付跳转完成】")
-                try{
-  								window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
-                }catch(e){
-                  alert(e)
-                }
-  						}else{
+  						}else if(r.err_msg == "get_brand_wcpay_request:cancel"){
+                console.log("支付已取消")
+						  }else{
                 weui.toast("系统异常,请稍微再试",{
                   duration: 2000,
                   className: 'custom-toast',
@@ -422,7 +417,10 @@
             tmp +="个月"
             $("#monthly").prop('checked', true);
             $(".number_box:eq(0)").addClass("active");
-            $("#number_box_month .month_number").text(this.timeSelect[0])
+            $("#number_box_month .month_number").text(this.timeSelect[0]);
+            if (this.timeSelect[0] >= 10) {
+                $('.profit_tips').text("已选择"+this.timeSelect[0]+"个月,建议“按年订阅”更换算哦~").show();
+            }
           }
           $(".info.choose_time").val(tmp);
         },
@@ -537,7 +535,7 @@
               var firstButton = $('#number_box_month button:first')
               var lastButton = $('#number_box_month button:last')
               if (currentNum >= 10) {
-                  $('.profit_tips').show()
+                  $('.profit_tips').text("已选择"+currentNum+"个月,建议“按年订阅”更换算哦~").show()
               } else {
                   $('.profit_tips').hide()
               }
@@ -596,7 +594,7 @@
               // console.log($(this).is(':checked'))
               let isChecked = $(this).is(':checked')
               // 按年订阅默认选择1年 
-              //let val = 1;
+              let val = 1;
               //$('.computed_price').html('¥' + Number(val) * 58)
               if (isChecked) {
                   $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')

+ 17 - 16
src/web/templates/weixin/vipsubscribe/vip_upgrade.html

@@ -341,20 +341,21 @@
 						setTimeout(function(){
 							window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
 						},500)
-					}else if(r.err_msg == "get_brand_wcpay_request:cancel"){               
-//	                	alert("开发环境【支付跳转完成】")
-		                try{
-//		  					window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
-		                	window.location.reload();
-		                }catch(e){
-		                  alert(e)
-		                }
-	  				}else{
-	                	weui.toast("系统异常,请稍微再试",{
-	                  		duration: 2000,
-	                  		className: 'custom-toast',
-	                	});
-	  				}
+					}
+//					}else if(r.err_msg == "get_brand_wcpay_request:cancel"){               
+////	                	alert("开发环境【支付跳转完成】")
+//		                try{
+////		  					window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
+////		                	window.location.reload();
+//		                }catch(e){
+//		                  alert(e)
+//		                }
+//	  				}else{
+//	                	weui.toast("系统异常,请稍微再试",{
+//	                  		duration: 2000,
+//	                  		className: 'custom-toast',
+//	                	});
+//	  				}
   				});
   			}   
 		}catch(e){
@@ -412,7 +413,7 @@
 			var bs = nowYears+"/"+as+"/1";
 			var effects = new Date(bs).getTime() /1000;
 			var a = nowYears+"."+as+".01";
-			$(".notnownow").text(a + " - " + endTime)
+			$(".notnownow").text(a + " - " + endTime.replace(/-/g, "."))
 			if(ends < effects){
 				$(".effect_next").hide();
 //				$(".box").css("height", "2.7rem");
@@ -853,7 +854,7 @@
 			    //
 			    var nowDate = data.now.replace(/-/g, ".");
 			    var a = nowDate+ " - " +endTime;
-			    $(".nownow").text(nowDate+ " - " +endTime)
+			    $(".nownow").text(nowDate+ " - " +endTime.replace(/-/g, "."))
 			    
 			}
         },false);

Vissa filer visades inte eftersom för många filer har ändrats