Explorar o código

feat:权益码 增加天数

wangshan %!s(int64=2) %!d(string=hai) anos
pai
achega
5e822d56b5

+ 2 - 1
src/jfw/modules/subscribepay/src/entity/equityCode.go

@@ -198,7 +198,8 @@ func (e *EquityCode) UseEquityCodeAndAuthority() (m string, flag bool) {
 				// cycleCount 数字长度
 			*/
 			var (
-				area      = &map[string]interface{}{"北京": []string{}} //默认
+				area = &map[string]interface{}{"北京": []string{}} //默认
+				//jyactivities 库 》gift 表 标准天和年和支付订单表 天和年单位相反
 				cycleUnit = func(numType int) int {
 					switch numType {
 					case 1:

+ 336 - 329
src/jfw/modules/subscribepay/src/util/vrew.go

@@ -1,73 +1,73 @@
 package util
 
 import (
-	"encoding/json"
-	"fmt"
-	"log"
-	"strconv"
-	"strings"
-	"time"
+    "encoding/json"
+    "fmt"
+    "log"
+    "strconv"
+    "strings"
+    "time"
 
-	qutil "app.yhyue.com/moapp/jybase/common"
-	. "app.yhyue.com/moapp/jybase/date"
-	"app.yhyue.com/moapp/jybase/encrypt"
-	elastic "app.yhyue.com/moapp/jybase/esv1"
+    qutil "app.yhyue.com/moapp/jybase/common"
+    . "app.yhyue.com/moapp/jybase/date"
+    "app.yhyue.com/moapp/jybase/encrypt"
+    elastic "app.yhyue.com/moapp/jybase/esv1"
 )
 
 /*已选条件--关键词*/
 type ViewKeyWord struct {
-	Keyword  []string `json:"key"`       //关键词
-	Appended []string `json:"appendkey"` //附加词
-	Exclude  []string `json:"notkey"`    //排除词
-	MatchWay int      `json:"matchway"`  //匹配模式
+    Keyword  []string `json:"key"`       //关键词
+    Appended []string `json:"appendkey"` //附加词
+    Exclude  []string `json:"notkey"`    //排除词
+    MatchWay int      `json:"matchway"`  //匹配模式
 }
 
 /*已选条件*/
 type ViewCondition struct {
-	Area       []string      //地区-省份
-	City       []string      //地区-城市
-	Buyerclass []string      //采购行业
-	Keyword    []ViewKeyWord //关键词
-	SelectType string        //筛选(正文 or 标题)
-	Subtype    []string      //信息类型
+    Area       []string      //地区-省份
+    City       []string      //地区-城市
+    Buyerclass []string      //采购行业
+    Keyword    []ViewKeyWord //关键词
+    SelectType string        //筛选(正文 or 标题)
+    Subtype    []string      //信息类型
 }
 
 const (
-	INDEX          = "bidding"
-	TYPE           = "bidding"
-	bidSearch_sort = `{"publishtime":-1}`
-	findfields     = `"title"`
+    INDEX          = "bidding"
+    TYPE           = "bidding"
+    bidSearch_sort = `{"publishtime":-1}`
+    findfields     = `"title"`
 
-	view_maxPageNum = 20
-	view_pageSize   = 50
-	bidSearch_field = `"_id","title","publishtime","toptype","subtype","type","area","buyerclass","budget","bidamount"`
+    view_maxPageNum = 20
+    view_pageSize   = 50
+    bidSearch_field = `"_id","title","publishtime","toptype","subtype","type","area","buyerclass","budget","bidamount"`
 )
 
 func SubViewDatas(userId, allquery string, pageNum int, positionType, entId, entUserId int64) (keys []interface{}, list *[]map[string]interface{}, hasNextPage bool) {
-	if userId == "" {
-		return
-	}
-	sql := GetSqlObjFromId(userId, "", -1, positionType, entId, entUserId)
-	for _, v := range sql.Keyword {
-		var keys_one []string
-		for _, k := range v.Keyword {
-			keys_one = append(keys_one, k)
-		}
-		//dev3.5 附加词也要高亮
-		for _, k := range v.Appended {
-			keys_one = append(keys_one, k)
-		}
-		keys = append(keys, strings.Join(keys_one, "++"))
-	}
-	qstr := GetVIPViewSql(userId, sql)
-	list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, bidSearch_field, (pageNum-1)*view_pageSize, view_pageSize, 0, false)
-	if list != nil {
-		for _, v := range *list {
-			v["_id"] = encrypt.EncodeArticleId2ByCheck(qutil.ObjToString(v["_id"]))
-		}
-	}
-	hasNextPage = list != nil && len(*list) == view_pageSize && pageNum < view_maxPageNum
-	return
+    if userId == "" {
+        return
+    }
+    sql := GetSqlObjFromId(userId, "", -1, positionType, entId, entUserId)
+    for _, v := range sql.Keyword {
+        var keys_one []string
+        for _, k := range v.Keyword {
+            keys_one = append(keys_one, k)
+        }
+        //dev3.5 附加词也要高亮
+        for _, k := range v.Appended {
+            keys_one = append(keys_one, k)
+        }
+        keys = append(keys, strings.Join(keys_one, "++"))
+    }
+    qstr := GetVIPViewSql(userId, sql)
+    list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, bidSearch_field, (pageNum-1)*view_pageSize, view_pageSize, 0, false)
+    if list != nil {
+        for _, v := range *list {
+            v["_id"] = encrypt.EncodeArticleId2ByCheck(qutil.ObjToString(v["_id"]))
+        }
+    }
+    hasNextPage = list != nil && len(*list) == view_pageSize && pageNum < view_maxPageNum
+    return
 }
 
 /*推送结果预览总数
@@ -76,13 +76,13 @@ func SubViewDatas(userId, allquery string, pageNum int, positionType, entId, ent
  *@param index 关键词在分类下的索引位置
  */
 func SubViewDatasCount(userId, item string, index int, positionType, entId, entUserId int64) int64 {
-	sql := GetSqlObjFromId(userId, item, index, positionType, entId, entUserId)
-	if item != "" && index >= 0 && (sql.Keyword == nil || len(sql.Keyword) == 0) {
-		log.Println("推送结果预览总数参数异常,没有找到改组订阅词", item, index)
-		return 0
-	}
-	qstr := GetVIPViewSql(userId, sql)
-	return elastic.Count(INDEX, TYPE, qstr)
+    sql := GetSqlObjFromId(userId, item, index, positionType, entId, entUserId)
+    if item != "" && index >= 0 && (sql.Keyword == nil || len(sql.Keyword) == 0) {
+        log.Println("推送结果预览总数参数异常,没有找到改组订阅词", item, index)
+        return 0
+    }
+    qstr := GetVIPViewSql(userId, sql)
+    return elastic.Count(INDEX, TYPE, qstr)
 }
 
 /*某组关键词-推送结果预览总数
@@ -92,304 +92,311 @@ func SubViewDatasCount(userId, item string, index int, positionType, entId, entU
  *@param matchway 0:精准 1:模糊
  */
 func KeysetViewDatasCount(userId, key, notkey string, matchway int, positionType, entId, entUserId int64) int64 {
-	key = strings.TrimSpace(key)
-	notkey = strings.TrimSpace(notkey)
-	if key == "" {
-		return 0
-	}
-	sql := GetSqlObjFromId(userId, "", -1, positionType, entId, entUserId)
-	viewKeyWords := []ViewKeyWord{}
-	if matchway == 0 {
-		viewKeyWords = append(viewKeyWords, ViewKeyWord{
-			Keyword:  strings.Split(key, " "),
-			Exclude:  strings.Split(notkey, " "),
-			MatchWay: matchway,
-		})
-	} else {
-		for _, v := range strings.Split(key, " ") {
-			viewKeyWords = append(viewKeyWords, ViewKeyWord{
-				Keyword:  []string{v},
-				Exclude:  strings.Split(notkey, " "),
-				MatchWay: matchway,
-			})
-		}
-	}
-	sql.Keyword = viewKeyWords
-	qstr := GetVIPViewSql(userId, sql)
-	return elastic.Count(INDEX, TYPE, qstr)
+    key = strings.TrimSpace(key)
+    notkey = strings.TrimSpace(notkey)
+    if key == "" {
+        return 0
+    }
+    sql := GetSqlObjFromId(userId, "", -1, positionType, entId, entUserId)
+    viewKeyWords := []ViewKeyWord{}
+    if matchway == 0 {
+        viewKeyWords = append(viewKeyWords, ViewKeyWord{
+            Keyword:  strings.Split(key, " "),
+            Exclude:  strings.Split(notkey, " "),
+            MatchWay: matchway,
+        })
+    } else {
+        for _, v := range strings.Split(key, " ") {
+            viewKeyWords = append(viewKeyWords, ViewKeyWord{
+                Keyword:  []string{v},
+                Exclude:  strings.Split(notkey, " "),
+                MatchWay: matchway,
+            })
+        }
+    }
+    sql.Keyword = viewKeyWords
+    qstr := GetVIPViewSql(userId, sql)
+    return elastic.Count(INDEX, TYPE, qstr)
 }
 
 //获取vip订阅预览的查询语句
 func GetVIPViewSql(userId string, scd *ViewCondition) string {
-	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
-	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
-	multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
-	query_bool_must_and := `{"bool":{"must":[%s]%s}}`
+    query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
+    query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
+    multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
+    query_bool_must_and := `{"bool":{"must":[%s]%s}}`
 
-	bools := []string{}
-	musts := []string{}
-	//发布时间最新三个月
-	musts = append(musts, fmt.Sprintf(`{"range":{"publishtime":{"gte":%d}}}`, time.Now().AddDate(0, -3, 0).Unix()))
-	//省份
-	areaCity := []string{}
-	if len(scd.Area) > 0 {
-		areaquery := `{"terms":{"area":[`
-		for k, v := range scd.Area {
-			if k > 0 {
-				areaquery += `,`
-			}
-			areaquery += `"` + v + `"`
-		}
-		areaquery += `]}}`
-		areaCity = append(areaCity, areaquery)
-	}
+    bools := []string{}
+    musts := []string{}
+    //发布时间最新三个月
+    musts = append(musts, fmt.Sprintf(`{"range":{"publishtime":{"gte":%d}}}`, time.Now().AddDate(0, -3, 0).Unix()))
+    //省份
+    areaCity := []string{}
+    if len(scd.Area) > 0 {
+        areaquery := `{"terms":{"area":[`
+        for k, v := range scd.Area {
+            if k > 0 {
+                areaquery += `,`
+            }
+            areaquery += `"` + v + `"`
+        }
+        areaquery += `]}}`
+        areaCity = append(areaCity, areaquery)
+    }
 
-	//城市
-	if len(scd.City) > 0 {
-		areaquery := `{"terms":{"city":[`
-		for k, v := range scd.City {
-			if k > 0 {
-				areaquery += `,`
-			}
-			areaquery += `"` + v + `"`
-		}
-		areaquery += `]}}`
-		areaCity = append(areaCity, areaquery)
-	}
-	if len(areaCity) > 0 {
-		musts = append(musts, fmt.Sprintf(query_bool_should, strings.Join(areaCity, ",")))
-	}
-	if len(scd.Subtype) > 0 {
-		subquery := `{"terms":{"subtype":[`
-		for k, v := range scd.Subtype {
-			if k > 0 {
-				subquery += `,`
-			}
-			subquery += `"` + v + `"`
-		}
-		subquery += `]}}`
-		musts = append(musts, subquery)
-	}
-	if len(scd.Buyerclass) > 0 {
-		Buyerclass := `{"terms":{"buyerclass":[`
-		for k, v := range scd.Buyerclass {
-			if k > 0 {
-				Buyerclass += `,`
-			}
-			Buyerclass += `"` + v + `"`
-		}
-		Buyerclass += `]}}`
-		musts = append(musts, Buyerclass)
-	}
-	boolsNum := 0 //should
-	if len(scd.Keyword) > 0 {
-		boolsNum = 1
-		if scd.SelectType == "" || scd.SelectType == "2" {
-			scd.SelectType = "detail\", \"title"
-		} else {
-			scd.SelectType = "title"
-		}
-		multi_match = fmt.Sprintf(multi_match, "%s", "\""+scd.SelectType+"\"")
+    //城市
+    if len(scd.City) > 0 {
+        areaquery := `{"terms":{"city":[`
+        for k, v := range scd.City {
+            if k > 0 {
+                areaquery += `,`
+            }
+            areaquery += `"` + v + `"`
+        }
+        areaquery += `]}}`
+        areaCity = append(areaCity, areaquery)
+    }
+    if len(areaCity) > 0 {
+        musts = append(musts, fmt.Sprintf(query_bool_should, strings.Join(areaCity, ",")))
+    }
+    if len(scd.Subtype) > 0 {
+        subquery := `{"terms":{"subtype":[`
+        for k, v := range scd.Subtype {
+            if k > 0 {
+                subquery += `,`
+            }
+            subquery += `"` + v + `"`
+        }
+        subquery += `]}}`
+        musts = append(musts, subquery)
+    }
+    if len(scd.Buyerclass) > 0 {
+        Buyerclass := `{"terms":{"buyerclass":[`
+        for k, v := range scd.Buyerclass {
+            if k > 0 {
+                Buyerclass += `,`
+            }
+            Buyerclass += `"` + v + `"`
+        }
+        Buyerclass += `]}}`
+        musts = append(musts, Buyerclass)
+    }
+    boolsNum := 0 //should
+    if len(scd.Keyword) > 0 {
+        boolsNum = 1
+        if scd.SelectType == "" || scd.SelectType == "2" {
+            scd.SelectType = "detail\", \"title"
+        } else {
+            scd.SelectType = "title"
+        }
+        multi_match = fmt.Sprintf(multi_match, "%s", "\""+scd.SelectType+"\"")
 
-		for _, v := range scd.Keyword {
-			shoulds := []string{}
-			must_not := []string{}
-			//附加词
-			for _, vv := range v.Keyword {
-				vv = strings.TrimSpace(vv)
-				if vv == "" {
-					continue
-				}
-				shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vv+"\""))
-			}
+        for _, v := range scd.Keyword {
+            shoulds := []string{}
+            must_not := []string{}
+            //附加词
+            for _, vv := range v.Keyword {
+                vv = strings.TrimSpace(vv)
+                if vv == "" {
+                    continue
+                }
+                shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vv+"\""))
+            }
 
-			for _, vv := range v.Appended {
-				vv = strings.TrimSpace(vv)
-				if vv == "" {
-					continue
-				}
-				shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vv+"\""))
-			}
+            for _, vv := range v.Appended {
+                vv = strings.TrimSpace(vv)
+                if vv == "" {
+                    continue
+                }
+                shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vv+"\""))
+            }
 
-			//排除词
-			for _, vv := range v.Exclude {
-				vv = strings.TrimSpace(vv)
-				if vv == "" {
-					continue
-				}
-				must_not = append(must_not, fmt.Sprintf(multi_match, "\""+vv+"\""))
-			}
+            //排除词
+            for _, vv := range v.Exclude {
+                vv = strings.TrimSpace(vv)
+                if vv == "" {
+                    continue
+                }
+                must_not = append(must_not, fmt.Sprintf(multi_match, "\""+vv+"\""))
+            }
 
-			//添加
-			if len(shoulds) > 0 {
-				notStr := ""
-				if len(must_not) > 0 {
-					notStr = fmt.Sprintf(`,"must_not":[%s]`, strings.Join(must_not, ","))
-				}
-				bools = append(bools, fmt.Sprintf(query_bool_must_and, strings.Join(shoulds, ","), notStr))
-			}
-		}
-	}
+            //添加
+            if len(shoulds) > 0 {
+                notStr := ""
+                if len(must_not) > 0 {
+                    notStr = fmt.Sprintf(`,"must_not":[%s]`, strings.Join(must_not, ","))
+                }
+                bools = append(bools, fmt.Sprintf(query_bool_must_and, strings.Join(shoulds, ","), notStr))
+            }
+        }
+    }
 
-	qstr := fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(bools, ","), boolsNum)
-	log.Println(userId, "推送结果预览", qstr)
-	return qstr
+    qstr := fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(bools, ","), boolsNum)
+    log.Println(userId, "推送结果预览", qstr)
+    return qstr
 }
 
 //
 func GetSqlObjFromId(_id, item string, index int, positionType, entId, entUserId int64) *ViewCondition {
-	query := Compatible.Select(_id, `{"o_vipjy":1}`)
-	o_vipjy, _ := (*query)["o_vipjy"].(map[string]interface{})
-	a_items, _ := o_vipjy["a_items"].([]interface{})
-	a_buyerclass, _ := o_vipjy["a_buyerclass"].([]interface{})
-	if len(a_buyerclass) > 0 && qutil.IntAllDef(o_vipjy["i_matchbuyerclass_other"], 1) == 1 && len(a_items) > 0 {
-		a_buyerclass = append(a_buyerclass, "其它")
-	}
-	a_infotype, _ := o_vipjy["a_infotype"].([]interface{})
-	o_area, _ := o_vipjy["o_area"].(map[string]interface{})
-	return &ViewCondition{
-		Keyword:    getKeyWordArrFromDbResult(a_items, item, index),
-		Buyerclass: qutil.ObjArrToStringArr(a_buyerclass),
-		Subtype:    qutil.ObjArrToStringArr(a_infotype),
-		Area:       getStringArrFromDbResult(o_area, 1),
-		City:       getStringArrFromDbResult(o_area, 2),
-		SelectType: strconv.Itoa(qutil.IntAll(o_vipjy["i_matchway"])),
-	}
+    query := Compatible.Select(_id, `{"o_vipjy":1}`)
+    o_vipjy, _ := (*query)["o_vipjy"].(map[string]interface{})
+    a_items, _ := o_vipjy["a_items"].([]interface{})
+    a_buyerclass, _ := o_vipjy["a_buyerclass"].([]interface{})
+    if len(a_buyerclass) > 0 && qutil.IntAllDef(o_vipjy["i_matchbuyerclass_other"], 1) == 1 && len(a_items) > 0 {
+        a_buyerclass = append(a_buyerclass, "其它")
+    }
+    a_infotype, _ := o_vipjy["a_infotype"].([]interface{})
+    o_area, _ := o_vipjy["o_area"].(map[string]interface{})
+    return &ViewCondition{
+        Keyword:    getKeyWordArrFromDbResult(a_items, item, index),
+        Buyerclass: qutil.ObjArrToStringArr(a_buyerclass),
+        Subtype:    qutil.ObjArrToStringArr(a_infotype),
+        Area:       getStringArrFromDbResult(o_area, 1),
+        City:       getStringArrFromDbResult(o_area, 2),
+        SelectType: strconv.Itoa(qutil.IntAll(o_vipjy["i_matchway"])),
+    }
 }
 
 //
 func getStringArrFromDbResult(area map[string]interface{}, i int) (arr []string) {
-	if area == nil {
-		return
-	}
-	var eareArr []string
-	var cityArr []string
-	for k, v := range area {
-		if len(v.([]interface{})) > 0 {
-			cityArr = append(cityArr, qutil.ObjArrToStringArr(v.([]interface{}))...)
-		} else {
-			eareArr = append(eareArr, k)
-		}
-	}
-	if i == 1 {
-		arr = eareArr
-	} else {
-		arr = cityArr
-	}
-	return
+    if area == nil {
+        return
+    }
+    var eareArr []string
+    var cityArr []string
+    for k, v := range area {
+        if len(v.([]interface{})) > 0 {
+            cityArr = append(cityArr, qutil.ObjArrToStringArr(v.([]interface{}))...)
+        } else {
+            eareArr = append(eareArr, k)
+        }
+    }
+    if i == 1 {
+        arr = eareArr
+    } else {
+        arr = cityArr
+    }
+    return
 }
 
 //关键词 附加词 排除词
 func getKeyWordArrFromDbResult(a_items []interface{}, item string, index int) (arr []ViewKeyWord) {
-	if a_items == nil {
-		return
-	}
-	for _, v := range a_items {
-		vm, _ := v.(map[string]interface{})
-		if item != "" && index >= 0 && item != qutil.ObjToString(vm["s_item"]) {
-			continue
-		}
-		kwsArr := vm["a_key"]
-		for i, k := range kwsArr.([]interface{}) {
-			if item != "" && index >= 0 && i != index {
-				continue
-			}
-			kw := ViewKeyWord{}
-			b, e := json.Marshal(k)
-			if e != nil {
-				log.Println(e.Error())
-			}
-			json.Unmarshal(b, &kw)
-			if kw.MatchWay == 1 {
-				for _, kk := range kw.Keyword {
-					arr = append(arr, ViewKeyWord{
-						Keyword: []string{kk},
-						Exclude: kw.Exclude,
-					})
-				}
-				for _, kk := range kw.Appended {
-					arr = append(arr, ViewKeyWord{
-						Keyword: []string{kk},
-						Exclude: kw.Exclude,
-					})
-				}
-			} else {
-				arr = append(arr, kw)
-			}
-		}
-	}
-	return
+    if a_items == nil {
+        return
+    }
+    for _, v := range a_items {
+        vm, _ := v.(map[string]interface{})
+        if item != "" && index >= 0 && item != qutil.ObjToString(vm["s_item"]) {
+            continue
+        }
+        kwsArr := vm["a_key"]
+        for i, k := range kwsArr.([]interface{}) {
+            if item != "" && index >= 0 && i != index {
+                continue
+            }
+            kw := ViewKeyWord{}
+            b, e := json.Marshal(k)
+            if e != nil {
+                log.Println(e.Error())
+            }
+            json.Unmarshal(b, &kw)
+            if kw.MatchWay == 1 {
+                for _, kk := range kw.Keyword {
+                    arr = append(arr, ViewKeyWord{
+                        Keyword: []string{kk},
+                        Exclude: kw.Exclude,
+                    })
+                }
+                for _, kk := range kw.Appended {
+                    arr = append(arr, ViewKeyWord{
+                        Keyword: []string{kk},
+                        Exclude: kw.Exclude,
+                    })
+                }
+            } else {
+                arr = append(arr, kw)
+            }
+        }
+    }
+    return
 }
 
 //初始化vip订阅关键词
 func MergeKws(userId string, positionType, entId, entUserId int64) {
-	defer qutil.Catch()
-	if userId == "" { //11-11 取消此操作
-		return
-	}
-	data := Compatible.Select(userId, `{"o_jy":1,"o_vipjy":1}`)
-	var o_vipjy map[string]interface{}
-	if data != nil && len(*data) > 0 {
-		o_vipjy, _ = (*data)["o_vipjy"].(map[string]interface{})
-		a_items, _ := o_vipjy["a_items"].([]interface{})
-		m := map[string]interface{}{}
-		if a_items == nil { //首次
-			m = map[string]interface{}{"o_vipjy.i_matchway": 1, "o_vipjy.i_ratemode": 1, "o_vipjy.i_wxpush": 1, "o_vipjy.i_apppush": 1, "o_vipjy.a_infotype": []string{}, "o_vipjy.a_items": []string{}, "o_vipjy.l_modifydate": time.Now().Unix()}
-		} else {
-			//免费用户试用超级订阅
-			wxpush := o_vipjy["i_wxpush"]
-			apppush := o_vipjy["i_apppush"]
-			if wxpush == nil && apppush == nil {
-				m = map[string]interface{}{"o_vipjy.i_ratemode": 1, "o_vipjy.i_wxpush": 1, "o_vipjy.i_apppush": 1, "o_vipjy.l_modifydate": time.Now().Unix()}
-			}
-		}
-		Compatible.Update(userId, map[string]interface{}{
-			"$set": m,
-		})
-	}
+    defer qutil.Catch()
+    if userId == "" { //11-11 取消此操作
+        return
+    }
+    data := Compatible.Select(userId, `{"o_jy":1,"o_vipjy":1}`)
+    var o_vipjy map[string]interface{}
+    if data != nil && len(*data) > 0 {
+        o_vipjy, _ = (*data)["o_vipjy"].(map[string]interface{})
+        a_items, _ := o_vipjy["a_items"].([]interface{})
+        m := map[string]interface{}{}
+        if a_items == nil { //首次
+            m = map[string]interface{}{"o_vipjy.i_matchway": 1, "o_vipjy.i_ratemode": 1, "o_vipjy.i_wxpush": 1, "o_vipjy.i_apppush": 1, "o_vipjy.a_infotype": []string{}, "o_vipjy.a_items": []string{}, "o_vipjy.l_modifydate": time.Now().Unix()}
+        } else {
+            //免费用户试用超级订阅
+            wxpush := o_vipjy["i_wxpush"]
+            apppush := o_vipjy["i_apppush"]
+            if wxpush == nil && apppush == nil {
+                m = map[string]interface{}{"o_vipjy.i_ratemode": 1, "o_vipjy.i_wxpush": 1, "o_vipjy.i_apppush": 1, "o_vipjy.l_modifydate": time.Now().Unix()}
+            }
+        }
+        Compatible.Update(userId, map[string]interface{}{
+            "$set": m,
+        })
+    }
 }
 
-//m 月 超过一年传12+n月 如14; endtime 当前周期结束时间戳 int64 ;val -   1:年 2:月 4:季度
-func GetDATE(val int, m int, endtime int64) (_endtime time.Time) {
-	//一年12个月
-	if val == 1 {
-		m = m * 12
-	}
-	//一个季度3个月
-	if val == 4 {
-		m = m * 3
-	}
-	endFormat := FormatDateByInt64(&endtime, Date_Short_Layout)
-	date_y, _ := strconv.Atoi(strings.Split(endFormat, "-")[0])
-	date_m, _ := strconv.Atoi(strings.Split(endFormat, "-")[1])
-	date_d, _ := strconv.Atoi(strings.Split(endFormat, "-")[2])
-	if date_m+m > 12 {
-		date_y = date_y + (date_m+m-1)/12
-		date_m = date_m + m - 12*((date_m+m-1)/12)
-	} else {
-		date_m = date_m + m
-	}
-	mstr := strconv.Itoa(date_m)
-	if date_m < 10 {
-		mstr = "0" + mstr
-	}
-	_date := strconv.Itoa(date_y) + "-" + mstr + "-01"
-	p, _ := time.ParseInLocation(Date_Short_Layout, _date, time.Local)
-	date := time.Unix(p.Unix(), 0).AddDate(0, 1, -1)
-	thisD, _ := strconv.Atoi(strings.Split(FormatDate(&date, Date_Short_Layout), "-")[2])
-	dstr := "01"
-	if thisD < date_d {
-		dstr = strconv.Itoa(thisD)
-		if thisD < 10 {
-			dstr = "0" + strconv.Itoa(thisD)
-		}
-	} else {
-		dstr = strconv.Itoa(date_d)
-		if date_d < 10 {
-			dstr = "0" + strconv.Itoa(date_d)
-		}
-	}
-	_date = strconv.Itoa(date_y) + "-" + mstr + "-" + dstr + " 23:59:59"
-	lastDate, _ := time.ParseInLocation(Date_Full_Layout, _date, time.Local)
-	return lastDate
+// GetDATE m 月 超过一年传12+n月 如14; endTime 当前周期结束时间戳 int64 ;val -   1:年 2:月 4:季度
+func GetDATE(val int, m int, endTime int64) (tt time.Time) {
+    //天
+    if val == 3 {
+        //结束日期 按照 自然日 算 (例:11.11开通 11.17 23.59.59结束)
+        endTime = endTime + int64(m*24*60*60) - 1
+        tt = time.Unix(endTime, 0)
+        return
+    }
+    //一年12个月
+    if val == 1 {
+        m = m * 12
+    }
+    //一个季度3个月
+    if val == 4 {
+        m = m * 3
+    }
+    endFormat := FormatDateByInt64(&endTime, Date_Short_Layout)
+    date_y, _ := strconv.Atoi(strings.Split(endFormat, "-")[0])
+    date_m, _ := strconv.Atoi(strings.Split(endFormat, "-")[1])
+    date_d, _ := strconv.Atoi(strings.Split(endFormat, "-")[2])
+    if date_m+m > 12 {
+        date_y = date_y + (date_m+m-1)/12
+        date_m = date_m + m - 12*((date_m+m-1)/12)
+    } else {
+        date_m = date_m + m
+    }
+    mstr := strconv.Itoa(date_m)
+    if date_m < 10 {
+        mstr = "0" + mstr
+    }
+    _date := strconv.Itoa(date_y) + "-" + mstr + "-01"
+    p, _ := time.ParseInLocation(Date_Short_Layout, _date, time.Local)
+    date := time.Unix(p.Unix(), 0).AddDate(0, 1, -1)
+    thisD, _ := strconv.Atoi(strings.Split(FormatDate(&date, Date_Short_Layout), "-")[2])
+    dstr := "01"
+    if thisD < date_d {
+        dstr = strconv.Itoa(thisD)
+        if thisD < 10 {
+            dstr = "0" + strconv.Itoa(thisD)
+        }
+    } else {
+        dstr = strconv.Itoa(date_d)
+        if date_d < 10 {
+            dstr = "0" + strconv.Itoa(date_d)
+        }
+    }
+    _date = strconv.Itoa(date_y) + "-" + mstr + "-" + dstr + " 23:59:59"
+    tt, _ = time.ParseInLocation(Date_Full_Layout, _date, time.Local)
+    return
 }