|
@@ -50,13 +50,14 @@ func GetAllData(w http.ResponseWriter, r *http.Request) {
|
|
|
func CheckUserInfo(access_token string, day, next, all int) (bcheck bool, appid string, d JSON) {
|
|
|
d = JSON{}
|
|
|
//第一层判断token是否失效或格式不对
|
|
|
+ planname := ""
|
|
|
if access_token != "" {
|
|
|
at := RsaDecrypt(access_token)
|
|
|
log.Debug("token:", at)
|
|
|
if at != "" {
|
|
|
tn := time.Now().Unix()
|
|
|
arr := strings.Split(at, ",")
|
|
|
- if len(arr) == 3 { //时间,appid,key
|
|
|
+ if len(arr) == 4 { //时间,appid,key,套餐
|
|
|
t := util.Int64All(arr[0])
|
|
|
des := tn - t
|
|
|
log.Debug("des", des)
|
|
@@ -66,6 +67,7 @@ func CheckUserInfo(access_token string, day, next, all int) (bcheck bool, appid
|
|
|
log.Debug("redis_token", "\t", redis_token, "\t", access_token)
|
|
|
if redis_token != "" && redis_token == access_token { //token验证通过,验证今日次数、总条数、服务时间
|
|
|
bcheck = true
|
|
|
+ planname = arr[3]
|
|
|
} else {
|
|
|
d["code"] = CODE_TOKEN_EXPIRE
|
|
|
d["msg"] = MSG_TOKEN_EXPIRE
|
|
@@ -164,7 +166,14 @@ func CheckUserInfo(access_token string, day, next, all int) (bcheck bool, appid
|
|
|
}
|
|
|
//判断通过
|
|
|
if bcheck { //取数据
|
|
|
- next, infos := getDataByAppid(appid, day, next, all, limittodaykey)
|
|
|
+ pn := planname[:1]
|
|
|
+ var fields map[string]interface{}
|
|
|
+ if pn == "A" {
|
|
|
+ fields = A
|
|
|
+ } else if pn == "B" {
|
|
|
+ fields = B
|
|
|
+ }
|
|
|
+ next, infos := getDataByAppid(appid, day, next, all, limittodaykey, fields)
|
|
|
if all == 1 && next > 0 {
|
|
|
d["next"] = next
|
|
|
}
|
|
@@ -179,7 +188,7 @@ func CheckUserInfo(access_token string, day, next, all int) (bcheck bool, appid
|
|
|
}
|
|
|
|
|
|
//获取数据
|
|
|
-func getDataByAppid(appid string, i_day, next, i_all int, limittodaykey string) (i_next int, infos []map[string]interface{}) {
|
|
|
+func getDataByAppid(appid string, i_day, next, i_all int, limittodaykey string, fields map[string]interface{}) (i_next int, infos []map[string]interface{}) {
|
|
|
query := map[string]interface{}{"appid": appid}
|
|
|
blastid := false
|
|
|
if i_all == 0 { //必须是当天才能使用lastid按顺序取信息
|
|
@@ -201,7 +210,7 @@ func getDataByAppid(appid string, i_day, next, i_all int, limittodaykey string)
|
|
|
|
|
|
log.Debug("query:", query)
|
|
|
i_next = next
|
|
|
- data, bdata := Mgo.Find("usermail", query, `{"_id":1}`, `{"title":1,"detail":1,"publishtime":1,"href":1}`, false, i_next, QUERY_LIMIT)
|
|
|
+ data, bdata := Mgo.Find("usermail", query, `{"_id":1}`, fields, false, i_next, QUERY_LIMIT)
|
|
|
if bdata && data != nil && *data != nil && len(*data) > 0 {
|
|
|
infos = *data
|
|
|
if blastid {
|