|
@@ -2,333 +2,333 @@
|
|
package front
|
|
package front
|
|
|
|
|
|
import (
|
|
import (
|
|
- "fmt"
|
|
|
|
- . "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
|
- utils "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
|
- "jy/src/jfw/modules/app/src/jfw/config"
|
|
|
|
- "net/url"
|
|
|
|
- "regexp"
|
|
|
|
- "strconv"
|
|
|
|
- "strings"
|
|
|
|
|
|
+ "fmt"
|
|
|
|
+ . "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
|
+ utils "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
|
+ "jy/src/jfw/modules/app/src/jfw/config"
|
|
|
|
+ "net/url"
|
|
|
|
+ "regexp"
|
|
|
|
+ "strconv"
|
|
|
|
+ "strings"
|
|
|
|
|
|
- util "app.yhyue.com/moapp/jybase/common"
|
|
|
|
- . "app.yhyue.com/moapp/jybase/date"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
- // "sync"
|
|
|
|
- "time"
|
|
|
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
|
+ . "app.yhyue.com/moapp/jybase/date"
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
+ // "sync"
|
|
|
|
+ "time"
|
|
)
|
|
)
|
|
|
|
|
|
// WxKeyset 进入订阅词设置
|
|
// WxKeyset 进入订阅词设置
|
|
func (m *Front) WxKeyset(tpl string) error {
|
|
func (m *Front) WxKeyset(tpl string) error {
|
|
- defer util.Catch()
|
|
|
|
- userid := util.ObjToString(m.GetSession("userId"))
|
|
|
|
- surprise := m.GetSession("surprise")
|
|
|
|
- if tpl == "index" && isInTSguide(userid, m.Session()) { //仅免费用户跳转向导页面
|
|
|
|
- return m.Redirect("/jyapp/tenderSubscribe/guide?url=" + url.QueryEscape(m.Request.RequestURI))
|
|
|
|
- }
|
|
|
|
- //到新订阅设置
|
|
|
|
- vipMsg := jy.GetBigVipUserBaseMsg(m.Session(), *config.Middleground)
|
|
|
|
- if vipMsg.IsUpgrade {
|
|
|
|
- return m.Redirect("/jyapp/vipsubscribe/toSubVipSetPage")
|
|
|
|
- }
|
|
|
|
- if tpl == "seniorset" {
|
|
|
|
- data := utils.Compatible.Select(userid, `{"o_jy":1}`)
|
|
|
|
- if data != nil && len(*data) > 0 {
|
|
|
|
- o_jy, _ := (*data)["o_jy"].(map[string]interface{})
|
|
|
|
- a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
|
- if len(a_key) > 0 {
|
|
|
|
- m.T["haskeyword"] = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ userid := util.ObjToString(m.GetSession("userId"))
|
|
|
|
+ surprise := m.GetSession("surprise")
|
|
|
|
+ if tpl == "index" && isInTSguide(userid, m.Session()) {
|
|
|
|
+ return m.Redirect("/jy_mobile/subscribe/guide?url=" + url.QueryEscape(m.Request.RequestURI))
|
|
|
|
+ }
|
|
|
|
+ //到新订阅设置
|
|
|
|
+ vipMsg := jy.GetBigVipUserBaseMsg(m.Session(), *config.Middleground)
|
|
|
|
+ if vipMsg.IsUpgrade {
|
|
|
|
+ return m.Redirect("/jyapp/vipsubscribe/toSubVipSetPage")
|
|
|
|
+ }
|
|
|
|
+ if tpl == "seniorset" {
|
|
|
|
+ data := utils.Compatible.Select(userid, `{"o_jy":1}`)
|
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
|
+ o_jy, _ := (*data)["o_jy"].(map[string]interface{})
|
|
|
|
+ a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
|
+ if len(a_key) > 0 {
|
|
|
|
+ m.T["haskeyword"] = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- userId, _ := m.GetSession("userId").(string)
|
|
|
|
- s_surprise := ""
|
|
|
|
- if tpl == "index" || tpl == "filterset" {
|
|
|
|
- data := utils.Compatible.Select(userId, `{"o_jy":1}`)
|
|
|
|
- var o_jy map[string]interface{}
|
|
|
|
- if data != nil && len(*data) > 0 {
|
|
|
|
- o_jy, _ = (*data)["o_jy"].(map[string]interface{})
|
|
|
|
- s_surprise = util.ObjToString(o_jy["s_surprise"])
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- m.T["s_surprise"] = s_surprise
|
|
|
|
- m.T["surprise"] = surprise
|
|
|
|
- if tpl == "index" {
|
|
|
|
- m.T["isIosExam"], m.T["isIosExamPhone"], _, _ = IosExamInfo(m.Action, false, false)
|
|
|
|
- }
|
|
|
|
- return m.Render("/weixin/wxkeyset/"+tpl+".html", &m.T)
|
|
|
|
|
|
+ }
|
|
|
|
+ userId, _ := m.GetSession("userId").(string)
|
|
|
|
+ s_surprise := ""
|
|
|
|
+ if tpl == "index" || tpl == "filterset" {
|
|
|
|
+ data := utils.Compatible.Select(userId, `{"o_jy":1}`)
|
|
|
|
+ var o_jy map[string]interface{}
|
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
|
+ o_jy, _ = (*data)["o_jy"].(map[string]interface{})
|
|
|
|
+ s_surprise = util.ObjToString(o_jy["s_surprise"])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ m.T["s_surprise"] = s_surprise
|
|
|
|
+ m.T["surprise"] = surprise
|
|
|
|
+ if tpl == "index" {
|
|
|
|
+ m.T["isIosExam"], m.T["isIosExamPhone"], _, _ = IosExamInfo(m.Action, false, false)
|
|
|
|
+ }
|
|
|
|
+ return m.Render("/weixin/wxkeyset/"+tpl+".html", &m.T)
|
|
}
|
|
}
|
|
|
|
|
|
-//ajax各种请求
|
|
|
|
|
|
+// ajax各种请求
|
|
func (m *Front) WxKeysetAjaxReq() {
|
|
func (m *Front) WxKeysetAjaxReq() {
|
|
- defer util.Catch()
|
|
|
|
- userId, _ := m.GetSession("userId").(string)
|
|
|
|
- if userId == "" {
|
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
|
- "flag": false,
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- //增加锁,防止map读写
|
|
|
|
- // lock, _ := m.Session().Get("Lock").(*sync.Mutex)
|
|
|
|
- // lock.Lock()
|
|
|
|
- // defer lock.Unlock()
|
|
|
|
- reqType := m.GetString("reqType")
|
|
|
|
- if reqType == "getKeyset" { //获取高级设置
|
|
|
|
- data := utils.Compatible.Select(userId, `{"o_jy":1,"l_registedate":1}`)
|
|
|
|
- var o_jy map[string]interface{}
|
|
|
|
- if data != nil && len(*data) > 0 {
|
|
|
|
- o_jy, _ = (*data)["o_jy"].(map[string]interface{})
|
|
|
|
- o_jy["i_new"] = NewUserByVIP(data)
|
|
|
|
- a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
|
- m.SetSession("o_jy_a_key", a_key)
|
|
|
|
- }
|
|
|
|
- m.ServeJson(o_jy)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- /*******************以下是修改操作******************/
|
|
|
|
- index := ""
|
|
|
|
- saveData := make(map[string]interface{})
|
|
|
|
- if reqType == "saveKeyWords" { //保存关键词
|
|
|
|
- a_key, _ := m.GetSession("o_jy_a_key").([]interface{})
|
|
|
|
- keyWords := m.GetSlice("keyWords")
|
|
|
|
- indexs := m.GetSlice("indexs")
|
|
|
|
- var keyMaps []map[string]interface{}
|
|
|
|
- //给删除的关键词加上标识
|
|
|
|
- a_keycopy := make([]map[string]interface{}, len(a_key))
|
|
|
|
- //复制
|
|
|
|
- for k, v := range a_key {
|
|
|
|
- key := v.(map[string]interface{})
|
|
|
|
- keycopy := map[string]interface{}{}
|
|
|
|
- for k1, v1 := range key {
|
|
|
|
- keycopy[k1] = v1
|
|
|
|
- }
|
|
|
|
- isExists := false
|
|
|
|
- for _, i := range indexs {
|
|
|
|
- if k == util.IntAll(i) {
|
|
|
|
- isExists = true
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //isExists =false已经被删除
|
|
|
|
- keycopy["flag"] = !isExists
|
|
|
|
- a_keycopy[k] = keycopy
|
|
|
|
- }
|
|
|
|
- for k, v := range keyWords {
|
|
|
|
- if strings.Trim(v, " ") == "" {
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- if k >= 10 {
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- index := util.IntAll(indexs[k])
|
|
|
|
- key := map[string]interface{}{}
|
|
|
|
- if index < len(a_keycopy) {
|
|
|
|
- key = a_keycopy[index]
|
|
|
|
- flag, _ := key["flag"].(bool)
|
|
|
|
- if flag {
|
|
|
|
- key = map[string]interface{}{}
|
|
|
|
- } else {
|
|
|
|
- delete(key, "flag")
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- keys := processKeyword(v)
|
|
|
|
- if keys != nil {
|
|
|
|
- key["key"] = keys
|
|
|
|
- if len(key) > 0 {
|
|
|
|
- keyMaps = append(keyMaps, key)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- saveData["o_jy.a_key"] = keyMaps
|
|
|
|
- } else if reqType == "saveArea" { //保存信息范围
|
|
|
|
- index = m.GetString("index")
|
|
|
|
- saveData["o_jy.a_key."+index+".area"] = m.GetSlice("area")
|
|
|
|
- } else if reqType == "saveInfotype" { //保存信息类型
|
|
|
|
- index = m.GetString("index")
|
|
|
|
- saveData["o_jy.a_key."+index+".infotype"] = m.GetSlice("infotype")
|
|
|
|
- } else if reqType == "saveNotkey" { //保存排除关键词
|
|
|
|
- index = m.GetString("index")
|
|
|
|
- notkey := m.GetSlice("notkey")
|
|
|
|
- if len(notkey) > 10 {
|
|
|
|
- notkey = notkey[0:10]
|
|
|
|
- }
|
|
|
|
- for k, v := range notkey {
|
|
|
|
- notkey[k] = strings.Replace(v, " ", "", -1)
|
|
|
|
- }
|
|
|
|
- saveData["o_jy.a_key."+index+".notkey"] = notkey
|
|
|
|
- } else if reqType == "saveSeniorset" { //保存高级设置
|
|
|
|
- //推送频率:1实时 2每日一推 3自定义时间
|
|
|
|
- ratemode, _ := m.GetInteger("ratemode")
|
|
|
|
- if ratemode != 2 && ratemode != 3 {
|
|
|
|
- ratemode = 1
|
|
|
|
- }
|
|
|
|
- saveData["o_jy.i_ratemode"] = ratemode
|
|
|
|
- apppush, _ := m.GetInteger("apppush")
|
|
|
|
- mailpush, _ := m.GetInteger("mailpush")
|
|
|
|
- if apppush == 0 && mailpush == 0 {
|
|
|
|
- apppush = 1
|
|
|
|
- }
|
|
|
|
- if ratemode == 3 {
|
|
|
|
- saveData["o_jy.i_rmstart"], _ = m.GetInteger("rmstart")
|
|
|
|
- saveData["o_jy.i_rmend"], _ = m.GetInteger("rmend")
|
|
|
|
- }
|
|
|
|
- saveData["o_jy.s_email"] = strings.Trim(m.GetString("email"), " ")
|
|
|
|
- saveData["o_jy.i_apppush"] = apppush
|
|
|
|
- saveData["o_jy.i_mailpush"] = mailpush
|
|
|
|
- } else if reqType == "delKeysWord" { //
|
|
|
|
- index = m.GetString("index")
|
|
|
|
- var keyMaps = []map[string]interface{}{}
|
|
|
|
- a_key, _ := m.GetSession("o_jy_a_key").([]interface{})
|
|
|
|
- for k, v := range a_key {
|
|
|
|
- if k != util.IntAll(index) {
|
|
|
|
- keyMaps = append(keyMaps, v.(map[string]interface{}))
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- saveData["o_jy.a_key"] = keyMaps
|
|
|
|
- } else if reqType == "setSurp" {
|
|
|
|
- saveData["o_jy.s_surprise"] = "A"
|
|
|
|
- m.SetSession("surprise", "A")
|
|
|
|
- } else if reqType == "saveKeyWordsNew" { //保存 or 修改 整个订阅词接口
|
|
|
|
- index = m.GetString("index")
|
|
|
|
- indexInt := util.IntAll(index)
|
|
|
|
- area := m.GetSlice("area")
|
|
|
|
- infotype := m.GetSlice("infotype")
|
|
|
|
- notkey := m.GetSlice("notkey")
|
|
|
|
- keyWords := m.GetString("keyWords")
|
|
|
|
- a_key, a_key_ok := m.GetSession("o_jy_a_key").([]interface{})
|
|
|
|
- if len(notkey) > 10 {
|
|
|
|
- notkey = notkey[0:10]
|
|
|
|
- }
|
|
|
|
- for k, v := range notkey {
|
|
|
|
- notkey[k] = strings.Replace(v, " ", "", -1)
|
|
|
|
- }
|
|
|
|
- keys := processKeyword(keyWords)
|
|
|
|
- if keys == nil || indexInt >= 10 {
|
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
|
- "flag": false,
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- saveKey := map[string]interface{}{
|
|
|
|
- "key": []string{keys[0]},
|
|
|
|
- "area": fliterEmptyArr(area),
|
|
|
|
- "notkey": fliterEmptyArr(notkey),
|
|
|
|
- "infotype": fliterEmptyArr(infotype),
|
|
|
|
- }
|
|
|
|
- var optime time.Time
|
|
|
|
- var regtime int64
|
|
|
|
- if rd := utils.Compatible.Select(userId, `{"o_jy":1,"l_registedate":1}`); rd != nil && len(*rd) > 0 {
|
|
|
|
- //获取活动上线时间
|
|
|
|
- optimalTime, _ := config.Sysconfig["optimalTime"].(string)
|
|
|
|
- optime, _ = time.ParseInLocation(Date_Full_Layout, optimalTime, time.Local)
|
|
|
|
- regtime, _ = (*rd)["l_registedate"].(int64)
|
|
|
|
- if ojy, _ := (*rd)["o_jy"].(map[string]interface{}); len(ojy) > 0 {
|
|
|
|
- if ojy["i_new"] == nil {
|
|
|
|
- if time.Unix(regtime, 0).After(optime) {
|
|
|
|
- saveData["o_jy.i_new"] = 1
|
|
|
|
- } else {
|
|
|
|
- saveData["o_jy.i_new"] = 0
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if ojy["a_key"] != nil {
|
|
|
|
- ak, _ := ojy["a_key"].([]interface{})
|
|
|
|
- if len(ak) > indexInt {
|
|
|
|
- if akmap, _ := ak[indexInt].(map[string]interface{}); akmap["from"] != nil {
|
|
|
|
- saveKey["from"] = akmap["from"]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if !a_key_ok && indexInt == 0 { //第一次新增
|
|
|
|
- index = ""
|
|
|
|
- saveData["o_jy.a_key"] = []map[string]interface{}{saveKey}
|
|
|
|
- if time.Unix(regtime, 0).Before(optime) {
|
|
|
|
- saveData["o_jy.i_new"] = 1
|
|
|
|
- }
|
|
|
|
- } else { //修改新增
|
|
|
|
- if indexInt > len(a_key) {
|
|
|
|
- indexInt = len(a_key)
|
|
|
|
- }
|
|
|
|
- saveData[fmt.Sprintf("o_jy.a_key.%d", indexInt)] = saveKey
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //修改操作
|
|
|
|
- var flag bool
|
|
|
|
- if len(saveData) > 0 {
|
|
|
|
- saveData["o_jy.l_modifydate"] = time.Now().Unix()
|
|
|
|
- if index == "" {
|
|
|
|
- flag = utils.Compatible.Update(userId, map[string]interface{}{
|
|
|
|
- "$set": saveData,
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- if intIndex, e := strconv.Atoi(index); e == nil && intIndex >= 0 && intIndex < 10 {
|
|
|
|
- flag = utils.Compatible.Update(userId, map[string]interface{}{
|
|
|
|
- "$set": saveData,
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
|
- "flag": flag,
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ userId, _ := m.GetSession("userId").(string)
|
|
|
|
+ if userId == "" {
|
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
|
+ "flag": false,
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //增加锁,防止map读写
|
|
|
|
+ // lock, _ := m.Session().Get("Lock").(*sync.Mutex)
|
|
|
|
+ // lock.Lock()
|
|
|
|
+ // defer lock.Unlock()
|
|
|
|
+ reqType := m.GetString("reqType")
|
|
|
|
+ if reqType == "getKeyset" { //获取高级设置
|
|
|
|
+ data := utils.Compatible.Select(userId, `{"o_jy":1,"l_registedate":1}`)
|
|
|
|
+ var o_jy map[string]interface{}
|
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
|
+ o_jy, _ = (*data)["o_jy"].(map[string]interface{})
|
|
|
|
+ o_jy["i_new"] = NewUserByVIP(data)
|
|
|
|
+ a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
|
+ m.SetSession("o_jy_a_key", a_key)
|
|
|
|
+ }
|
|
|
|
+ m.ServeJson(o_jy)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ /*******************以下是修改操作******************/
|
|
|
|
+ index := ""
|
|
|
|
+ saveData := make(map[string]interface{})
|
|
|
|
+ if reqType == "saveKeyWords" { //保存关键词
|
|
|
|
+ a_key, _ := m.GetSession("o_jy_a_key").([]interface{})
|
|
|
|
+ keyWords := m.GetSlice("keyWords")
|
|
|
|
+ indexs := m.GetSlice("indexs")
|
|
|
|
+ var keyMaps []map[string]interface{}
|
|
|
|
+ //给删除的关键词加上标识
|
|
|
|
+ a_keycopy := make([]map[string]interface{}, len(a_key))
|
|
|
|
+ //复制
|
|
|
|
+ for k, v := range a_key {
|
|
|
|
+ key := v.(map[string]interface{})
|
|
|
|
+ keycopy := map[string]interface{}{}
|
|
|
|
+ for k1, v1 := range key {
|
|
|
|
+ keycopy[k1] = v1
|
|
|
|
+ }
|
|
|
|
+ isExists := false
|
|
|
|
+ for _, i := range indexs {
|
|
|
|
+ if k == util.IntAll(i) {
|
|
|
|
+ isExists = true
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //isExists =false已经被删除
|
|
|
|
+ keycopy["flag"] = !isExists
|
|
|
|
+ a_keycopy[k] = keycopy
|
|
|
|
+ }
|
|
|
|
+ for k, v := range keyWords {
|
|
|
|
+ if strings.Trim(v, " ") == "" {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ if k >= 10 {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ index := util.IntAll(indexs[k])
|
|
|
|
+ key := map[string]interface{}{}
|
|
|
|
+ if index < len(a_keycopy) {
|
|
|
|
+ key = a_keycopy[index]
|
|
|
|
+ flag, _ := key["flag"].(bool)
|
|
|
|
+ if flag {
|
|
|
|
+ key = map[string]interface{}{}
|
|
|
|
+ } else {
|
|
|
|
+ delete(key, "flag")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ keys := processKeyword(v)
|
|
|
|
+ if keys != nil {
|
|
|
|
+ key["key"] = keys
|
|
|
|
+ if len(key) > 0 {
|
|
|
|
+ keyMaps = append(keyMaps, key)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ saveData["o_jy.a_key"] = keyMaps
|
|
|
|
+ } else if reqType == "saveArea" { //保存信息范围
|
|
|
|
+ index = m.GetString("index")
|
|
|
|
+ saveData["o_jy.a_key."+index+".area"] = m.GetSlice("area")
|
|
|
|
+ } else if reqType == "saveInfotype" { //保存信息类型
|
|
|
|
+ index = m.GetString("index")
|
|
|
|
+ saveData["o_jy.a_key."+index+".infotype"] = m.GetSlice("infotype")
|
|
|
|
+ } else if reqType == "saveNotkey" { //保存排除关键词
|
|
|
|
+ index = m.GetString("index")
|
|
|
|
+ notkey := m.GetSlice("notkey")
|
|
|
|
+ if len(notkey) > 10 {
|
|
|
|
+ notkey = notkey[0:10]
|
|
|
|
+ }
|
|
|
|
+ for k, v := range notkey {
|
|
|
|
+ notkey[k] = strings.Replace(v, " ", "", -1)
|
|
|
|
+ }
|
|
|
|
+ saveData["o_jy.a_key."+index+".notkey"] = notkey
|
|
|
|
+ } else if reqType == "saveSeniorset" { //保存高级设置
|
|
|
|
+ //推送频率:1实时 2每日一推 3自定义时间
|
|
|
|
+ ratemode, _ := m.GetInteger("ratemode")
|
|
|
|
+ if ratemode != 2 && ratemode != 3 {
|
|
|
|
+ ratemode = 1
|
|
|
|
+ }
|
|
|
|
+ saveData["o_jy.i_ratemode"] = ratemode
|
|
|
|
+ apppush, _ := m.GetInteger("apppush")
|
|
|
|
+ mailpush, _ := m.GetInteger("mailpush")
|
|
|
|
+ if apppush == 0 && mailpush == 0 {
|
|
|
|
+ apppush = 1
|
|
|
|
+ }
|
|
|
|
+ if ratemode == 3 {
|
|
|
|
+ saveData["o_jy.i_rmstart"], _ = m.GetInteger("rmstart")
|
|
|
|
+ saveData["o_jy.i_rmend"], _ = m.GetInteger("rmend")
|
|
|
|
+ }
|
|
|
|
+ saveData["o_jy.s_email"] = strings.Trim(m.GetString("email"), " ")
|
|
|
|
+ saveData["o_jy.i_apppush"] = apppush
|
|
|
|
+ saveData["o_jy.i_mailpush"] = mailpush
|
|
|
|
+ } else if reqType == "delKeysWord" { //
|
|
|
|
+ index = m.GetString("index")
|
|
|
|
+ var keyMaps = []map[string]interface{}{}
|
|
|
|
+ a_key, _ := m.GetSession("o_jy_a_key").([]interface{})
|
|
|
|
+ for k, v := range a_key {
|
|
|
|
+ if k != util.IntAll(index) {
|
|
|
|
+ keyMaps = append(keyMaps, v.(map[string]interface{}))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ saveData["o_jy.a_key"] = keyMaps
|
|
|
|
+ } else if reqType == "setSurp" {
|
|
|
|
+ saveData["o_jy.s_surprise"] = "A"
|
|
|
|
+ m.SetSession("surprise", "A")
|
|
|
|
+ } else if reqType == "saveKeyWordsNew" { //保存 or 修改 整个订阅词接口
|
|
|
|
+ index = m.GetString("index")
|
|
|
|
+ indexInt := util.IntAll(index)
|
|
|
|
+ area := m.GetSlice("area")
|
|
|
|
+ infotype := m.GetSlice("infotype")
|
|
|
|
+ notkey := m.GetSlice("notkey")
|
|
|
|
+ keyWords := m.GetString("keyWords")
|
|
|
|
+ a_key, a_key_ok := m.GetSession("o_jy_a_key").([]interface{})
|
|
|
|
+ if len(notkey) > 10 {
|
|
|
|
+ notkey = notkey[0:10]
|
|
|
|
+ }
|
|
|
|
+ for k, v := range notkey {
|
|
|
|
+ notkey[k] = strings.Replace(v, " ", "", -1)
|
|
|
|
+ }
|
|
|
|
+ keys := processKeyword(keyWords)
|
|
|
|
+ if keys == nil || indexInt >= 10 {
|
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
|
+ "flag": false,
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ saveKey := map[string]interface{}{
|
|
|
|
+ "key": []string{keys[0]},
|
|
|
|
+ "area": fliterEmptyArr(area),
|
|
|
|
+ "notkey": fliterEmptyArr(notkey),
|
|
|
|
+ "infotype": fliterEmptyArr(infotype),
|
|
|
|
+ }
|
|
|
|
+ var optime time.Time
|
|
|
|
+ var regtime int64
|
|
|
|
+ if rd := utils.Compatible.Select(userId, `{"o_jy":1,"l_registedate":1}`); rd != nil && len(*rd) > 0 {
|
|
|
|
+ //获取活动上线时间
|
|
|
|
+ optimalTime, _ := config.Sysconfig["optimalTime"].(string)
|
|
|
|
+ optime, _ = time.ParseInLocation(Date_Full_Layout, optimalTime, time.Local)
|
|
|
|
+ regtime, _ = (*rd)["l_registedate"].(int64)
|
|
|
|
+ if ojy, _ := (*rd)["o_jy"].(map[string]interface{}); len(ojy) > 0 {
|
|
|
|
+ if ojy["i_new"] == nil {
|
|
|
|
+ if time.Unix(regtime, 0).After(optime) {
|
|
|
|
+ saveData["o_jy.i_new"] = 1
|
|
|
|
+ } else {
|
|
|
|
+ saveData["o_jy.i_new"] = 0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ojy["a_key"] != nil {
|
|
|
|
+ ak, _ := ojy["a_key"].([]interface{})
|
|
|
|
+ if len(ak) > indexInt {
|
|
|
|
+ if akmap, _ := ak[indexInt].(map[string]interface{}); akmap["from"] != nil {
|
|
|
|
+ saveKey["from"] = akmap["from"]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !a_key_ok && indexInt == 0 { //第一次新增
|
|
|
|
+ index = ""
|
|
|
|
+ saveData["o_jy.a_key"] = []map[string]interface{}{saveKey}
|
|
|
|
+ if time.Unix(regtime, 0).Before(optime) {
|
|
|
|
+ saveData["o_jy.i_new"] = 1
|
|
|
|
+ }
|
|
|
|
+ } else { //修改新增
|
|
|
|
+ if indexInt > len(a_key) {
|
|
|
|
+ indexInt = len(a_key)
|
|
|
|
+ }
|
|
|
|
+ saveData[fmt.Sprintf("o_jy.a_key.%d", indexInt)] = saveKey
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //修改操作
|
|
|
|
+ var flag bool
|
|
|
|
+ if len(saveData) > 0 {
|
|
|
|
+ saveData["o_jy.l_modifydate"] = time.Now().Unix()
|
|
|
|
+ if index == "" {
|
|
|
|
+ flag = utils.Compatible.Update(userId, map[string]interface{}{
|
|
|
|
+ "$set": saveData,
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ if intIndex, e := strconv.Atoi(index); e == nil && intIndex >= 0 && intIndex < 10 {
|
|
|
|
+ flag = utils.Compatible.Update(userId, map[string]interface{}{
|
|
|
|
+ "$set": saveData,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
|
+ "flag": flag,
|
|
|
|
+ })
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
-//过滤[""]数组
|
|
|
|
|
|
+// 过滤[""]数组
|
|
func fliterEmptyArr(beforeArr []string) []string {
|
|
func fliterEmptyArr(beforeArr []string) []string {
|
|
- afterArr := []string{}
|
|
|
|
- for _, v := range beforeArr {
|
|
|
|
- if v == "" {
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- afterArr = append(afterArr, v)
|
|
|
|
- }
|
|
|
|
- return afterArr
|
|
|
|
|
|
+ afterArr := []string{}
|
|
|
|
+ for _, v := range beforeArr {
|
|
|
|
+ if v == "" {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ afterArr = append(afterArr, v)
|
|
|
|
+ }
|
|
|
|
+ return afterArr
|
|
}
|
|
}
|
|
|
|
|
|
-//高级设置
|
|
|
|
|
|
+// 高级设置
|
|
func (m *Front) WxKeysetSeniorset() error {
|
|
func (m *Front) WxKeysetSeniorset() error {
|
|
- return m.Render("/weixin/wxkeyset/seniorset.html")
|
|
|
|
|
|
+ return m.Render("/weixin/wxkeyset/seniorset.html")
|
|
}
|
|
}
|
|
|
|
|
|
-//高级设置
|
|
|
|
|
|
+// 高级设置
|
|
func (m *Front) WxKeysetFilterset() error {
|
|
func (m *Front) WxKeysetFilterset() error {
|
|
- return m.Render("/weixin/wxkeyset/filterset.html")
|
|
|
|
|
|
+ return m.Render("/weixin/wxkeyset/filterset.html")
|
|
}
|
|
}
|
|
|
|
|
|
-//保存入库之前,处理订阅的关键词
|
|
|
|
|
|
+// 保存入库之前,处理订阅的关键词
|
|
func processKeyword(keyword string) []string {
|
|
func processKeyword(keyword string) []string {
|
|
- keywordReg := regexp.MustCompile("([\\s\u3000\u2003\u00a0+,,])+")
|
|
|
|
- spaceReg := regexp.MustCompile("\\s+")
|
|
|
|
- keyword = keywordReg.ReplaceAllString(keyword, " ")
|
|
|
|
- keyword = spaceReg.ReplaceAllString(keyword, " ")
|
|
|
|
- keyword = strings.Trim(keyword, " ")
|
|
|
|
- if keyword == "" {
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
- return strings.Split(keyword, " ")
|
|
|
|
|
|
+ keywordReg := regexp.MustCompile("([\\s\u3000\u2003\u00a0+,,])+")
|
|
|
|
+ spaceReg := regexp.MustCompile("\\s+")
|
|
|
|
+ keyword = keywordReg.ReplaceAllString(keyword, " ")
|
|
|
|
+ keyword = spaceReg.ReplaceAllString(keyword, " ")
|
|
|
|
+ keyword = strings.Trim(keyword, " ")
|
|
|
|
+ if keyword == "" {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ return strings.Split(keyword, " ")
|
|
}
|
|
}
|
|
|
|
|
|
-//超级订阅优化,免费订阅判断新老用户 1:新用户 0:老用户
|
|
|
|
|
|
+// 超级订阅优化,免费订阅判断新老用户 1:新用户 0:老用户
|
|
func NewUserByVIP(mData *map[string]interface{}) int {
|
|
func NewUserByVIP(mData *map[string]interface{}) int {
|
|
- if len(*mData) == 0 || mData == nil {
|
|
|
|
- return 1
|
|
|
|
- }
|
|
|
|
- ojy, _ := (*mData)["o_jy"].(map[string]interface{})
|
|
|
|
- if len(ojy) > 0 {
|
|
|
|
- if ojy["i_new"] != nil {
|
|
|
|
- return util.IntAllDef(ojy["i_new"], 1)
|
|
|
|
- }
|
|
|
|
- optimalTime, _ := config.Sysconfig["optimalTime"].(string)
|
|
|
|
- optime, _ := time.ParseInLocation(Date_Full_Layout, optimalTime, time.Local)
|
|
|
|
- regtime, _ := (*mData)["l_registedate"].(int64)
|
|
|
|
- //如果a_key 存在 即为老用户
|
|
|
|
- if (ojy["a_key"] == nil && time.Unix(regtime, 0).Before(optime)) || (time.Unix(regtime, 0).After(optime)) {
|
|
|
|
- return 1
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return 0
|
|
|
|
|
|
+ if len(*mData) == 0 || mData == nil {
|
|
|
|
+ return 1
|
|
|
|
+ }
|
|
|
|
+ ojy, _ := (*mData)["o_jy"].(map[string]interface{})
|
|
|
|
+ if len(ojy) > 0 {
|
|
|
|
+ if ojy["i_new"] != nil {
|
|
|
|
+ return util.IntAllDef(ojy["i_new"], 1)
|
|
|
|
+ }
|
|
|
|
+ optimalTime, _ := config.Sysconfig["optimalTime"].(string)
|
|
|
|
+ optime, _ := time.ParseInLocation(Date_Full_Layout, optimalTime, time.Local)
|
|
|
|
+ regtime, _ := (*mData)["l_registedate"].(int64)
|
|
|
|
+ //如果a_key 存在 即为老用户
|
|
|
|
+ if (ojy["a_key"] == nil && time.Unix(regtime, 0).Before(optime)) || (time.Unix(regtime, 0).After(optime)) {
|
|
|
|
+ return 1
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return 0
|
|
}
|
|
}
|