wangshan 4 年之前
父节点
当前提交
c883b7d606

+ 0 - 73
src/jfw/modules/app/src/app/front/jylog.go

@@ -1,73 +0,0 @@
-package front
-
-/**
-日志文件自动切换,默认保留15天内日志
-**/
-
-import (
-	"log"
-	"os"
-	"path/filepath"
-	"regexp"
-	"time"
-
-	"github.com/go-xweb/xweb"
-	"github.com/robfig/cron"
-)
-
-//日志格式
-var fileReg = regexp.MustCompile("^(\\d{4}_[0-9_]{14})\\.log$")
-
-//当前日志文件句柄
-var LogFile *os.File
-
-//时间格式
-var FMT = "2006_01_02_15_04_05"
-
-//日志目录
-var LogPath = "./jylog"
-
-func init() {
-	os.Mkdir(LogPath, os.ModePerm)
-	//默认保留15天内的日志,-1为永久保留
-	initLog(15)
-}
-
-func initLog(saveDay int) {
-	go logfile()
-	task := cron.New()
-	task.Start()
-	task.AddFunc("0 0 0 * * ?", func() {
-		go logfile()
-		time.Sleep(50 * time.Second)
-		if saveDay > 0 {
-			filepath.Walk(LogPath, func(path string, info os.FileInfo, err error) error {
-				str := fileReg.FindStringSubmatch(info.Name())
-				if len(str) == 2 {
-					t, er := time.ParseInLocation(FMT, str[1], time.Local)
-					if er == nil {
-						if (time.Now().Unix()-t.Unix())/86400 > int64(saveDay) {
-							log.Println("delete log file:", path, os.Remove(path))
-						}
-					}
-				}
-				return nil
-			})
-		}
-	})
-}
-
-//创建并切换输出文件
-func logfile() {
-	now := time.Now().Format(FMT)
-	file, _ := os.Create(LogPath + "/" + now + ".log")
-	log.SetOutput(file)
-	xweb.RootApp().Logger.SetOutput(file)
-	go func(file *os.File) {
-		time.Sleep(5 * time.Second)
-		if LogFile != nil {
-			LogFile.Close()
-		}
-		LogFile = file
-	}(file)
-}

+ 1 - 0
src/jfw/modules/app/src/app/front/login.go

@@ -300,6 +300,7 @@ func (l *Login) Sess(ostr string) error {
 						actionurl = actionurl + "?selectTime=" + selectTime
 						actionurl = actionurl + "?selectTime=" + selectTime
 					}
 					}
 				}
 				}
+				log.Println(l.GetSession("userId"))
 				return l.Redirect(actionurl)
 				return l.Redirect(actionurl)
 			} else {
 			} else {
 				log.Println("解析结果:", str, ",actionurl为空")
 				log.Println("解析结果:", str, ",actionurl为空")

+ 7 - 1
src/jfw/modules/bigmember/src/filter/sessionfilter.go

@@ -24,6 +24,9 @@ var expertReg = regexp.MustCompile("^/bigmember/(potential|report)/.+$")
 //智慧版
 //智慧版
 var wisdomReg = regexp.MustCompile("^/bigmember/(forecast|decision)/.+$")
 var wisdomReg = regexp.MustCompile("^/bigmember/(forecast|decision)/.+$")
 
 
+//试用版
+var trialReg = regexp.MustCompile("^/bigmember/(forecast|decision)/.+$")
+
 //继承过滤器方法
 //继承过滤器方法
 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 	session := l.App.SessionManager.Session(req, w)
 	session := l.App.SessionManager.Session(req, w)
@@ -31,7 +34,7 @@ func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 		return true
 		return true
 	}
 	}
 	userId, _ := session.Get("userId").(string)
 	userId, _ := session.Get("userId").(string)
-	status := util.Power(userId) //1:专家版,2:智慧版,3:商机版,
+	status := util.Power(userId) //1:专家版,2:智慧版,3:商机版,4:试用版
 	if status <= 0 {
 	if status <= 0 {
 		R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
 		R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
 		return false
 		return false
@@ -42,6 +45,9 @@ func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 	} else if status == 3 && wisdomReg.MatchString(req.URL.Path) {
 	} else if status == 3 && wisdomReg.MatchString(req.URL.Path) {
 		R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
 		R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
 		return false
 		return false
+	} else if status == 4 && trialReg.MatchString(req.URL.Path) {
+		R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
+		return false
 	}
 	}
 	return true
 	return true
 }
 }

+ 8 - 0
src/jfw/modules/bigmember/src/service/analysis/forecastwinner.go

@@ -116,6 +116,8 @@ func (this *Analysis) FWData() {
 				//接收参数
 				//接收参数
 				json.Unmarshal(this.Body(), &getRes)
 				json.Unmarshal(this.Body(), &getRes)
 				if getRes.Type == "" && getRes.Id != "" {
 				if getRes.Type == "" && getRes.Id != "" {
+					//判断是否有中标预测权限
+					go FWPower(userId, getRes)
 					getRes.RedisFKey = redis_forecast_res + userId
 					getRes.RedisFKey = redis_forecast_res + userId
 					getRes.Id = qutil.DecodeArticleId2ByCheck(getRes.Id)[0]
 					getRes.Id = qutil.DecodeArticleId2ByCheck(getRes.Id)[0]
 					if getRes.Infoid != "" {
 					if getRes.Infoid != "" {
@@ -159,6 +161,12 @@ func (this *Analysis) FWData() {
 	this.ServeJson(regMap)
 	this.ServeJson(regMap)
 }
 }
 
 
+//是否有中标预测权限
+func FWPower(userId string, req *util.ForecastS) {
+	log.Println(userId)
+	log.Println(req)
+}
+
 //是否有正在预测或已预测未查看的信息
 //是否有正在预测或已预测未查看的信息
 func isExistsFIng(userId string) (success bool, id string) {
 func isExistsFIng(userId string) (success bool, id string) {
 	rfsExist, _ := redis.Exists("other", redis_forecast_status+userId)
 	rfsExist, _ := redis.Exists("other", redis_forecast_status+userId)

+ 77 - 0
src/jfw/modules/bigmember/src/service/analysis/util.go

@@ -0,0 +1,77 @@
+package analysis
+
+import (
+	"bytes"
+	"crypto/hmac"
+	"crypto/sha1"
+	"encoding/base64"
+	"hash"
+	"io"
+	"log"
+	"net/url"
+	"sort"
+	"strings"
+)
+
+type SignStr struct {
+	Key []string
+	Val []string
+}
+
+var secret = "20202020"
+
+func Signature(param [][]string) (signedStr string) {
+	sgt := &SignStr{[]string{}, []string{}}
+	for k, v := range param {
+		log.Println(k, v)
+		sgt.Key = append(sgt.Key, v[0])
+		sgt.Val = append(sgt.Val, v[1])
+	}
+	sgt.Sort()
+	reqStr := sgt.ToString()
+	str := percentEncode(reqStr)
+	log.Println("str", str)
+	h := hmac.New(func() hash.Hash {
+		return sha1.New()
+	}, []byte(secret))
+	io.WriteString(h, str)
+	signedStr = base64.StdEncoding.EncodeToString(h.Sum(nil))
+	log.Println(signedStr)
+	return
+}
+
+var Sp = strings.Replace
+
+func percentEncode(str string) string {
+	str = url.QueryEscape(str)
+	str = Sp(Sp(Sp(str, "+", "%20", -1), "*", "%2A", -1), "&7E", "~", -1)
+	return str
+}
+
+func (this *SignStr) ToString() string {
+	str := ""
+	for k, v := range this.Key {
+		if k > 0 {
+			str += "&"
+		}
+		str += v + "=" + this.Val[k]
+	}
+	return str
+}
+
+func (this *SignStr) Sort() {
+	sort.Sort(this)
+}
+
+func (this *SignStr) Len() int {
+	return len(this.Val)
+}
+
+func (this *SignStr) Less(i, j int) bool {
+	return bytes.Compare([]byte(this.Key[i]), []byte(this.Key[j])) < 1
+}
+
+func (this *SignStr) Swap(i, j int) {
+	this.Key[i], this.Key[j] = this.Key[j], this.Key[i]
+	this.Val[i], this.Val[j] = this.Val[j], this.Val[i]
+}

+ 3 - 0
src/jfw/modules/subscribepay/src/entity/member.go

@@ -68,6 +68,9 @@ func normal_member(level int, enddate time.Time, userId string, istrial int) {
 		"i_member_starttime": time.Now().Unix(),
 		"i_member_starttime": time.Now().Unix(),
 		"i_member_endtime":   enddate.Unix(),
 		"i_member_endtime":   enddate.Unix(),
 	}
 	}
+	if istrial == 1 {
+		set["i_member_trial"] = 1 //试用标识
+	}
 	util.MQFW.UpdateById("user", userId, map[string]interface{}{
 	util.MQFW.UpdateById("user", userId, map[string]interface{}{
 		"$set": set,
 		"$set": set,
 	})
 	})