wangshan hace 4 años
padre
commit
3f608d2252

+ 4 - 0
src/jfw/front/vipsubscribe.go

@@ -164,6 +164,7 @@ func (s *Subscribepay) Introduce() error {
 					isSubscribe := CheckUserIsSubscribe(openid)
 					if isSubscribe {
 						FindUserAndCreateSess(openid, s.Session())
+						userId = util.ObjToString(s.GetSession("userId"))
 					}
 				}
 			}
@@ -175,6 +176,9 @@ func (s *Subscribepay) Introduce() error {
 			return s.Redirect("/swordfish/about")
 		}
 	}
+	if userId == "" {
+		return s.Redirect("/swordfish/about")
+	}
 	m, ok := public.MQFW.FindById("user", userId, `{"o_vipjy":1,"i_vip_status":1}`)
 	if !ok {
 		return s.Redirect("/swordfish/about")

+ 2 - 1
src/jfw/modules/bigmember/src/config.json

@@ -47,5 +47,6 @@
 	},
 	"keyMaxLength":30,
 	"warnMailbox":["wangshan@topnet.net.cn","2308734067@qq.com"],
-	"warnMbTitle":"中标预测失败提醒"
+	"warnMbTitle":"中标预测失败提醒",
+	"dividingTime":1604246400
 }

+ 1 - 0
src/jfw/modules/bigmember/src/config/config.go

@@ -28,6 +28,7 @@ type config struct {
 	KeyMaxLength        int
 	WarnMailbox         []string
 	WarnMbTitle         string
+	DividingTime        int64
 }
 type followConfig struct {
 	Normal int

+ 3 - 3
src/jfw/modules/bigmember/src/filter/sessionfilter.go

@@ -24,8 +24,8 @@ var expertReg = regexp.MustCompile("^/bigmember/(potential|report)/.+$")
 //智慧版
 var wisdomReg = regexp.MustCompile("^/bigmember/(forecast|decision)/.+$")
 
-//试用版
-var trialReg = regexp.MustCompile("^/bigmember/(forecast|decision)/.+$")
+//试用版  中标预测 投标决策分析  潜在竞争对手和潜在客户
+var trialReg = regexp.MustCompile("^/bigmember/(forecast|analysis|potential)/.+$")
 
 //继承过滤器方法
 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
@@ -45,7 +45,7 @@ func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 	} else if status == 3 && wisdomReg.MatchString(req.URL.Path) {
 		R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
 		return false
-	} else if status == 4 && trialReg.MatchString(req.URL.Path) {
+	} else if status == 4 && !trialReg.MatchString(req.URL.Path) {
 		R.ServeJson(w, req, &Result{Error_code_1004, Error_msg_1004, nil})
 		return false
 	}

+ 19 - 4
src/jfw/modules/bigmember/src/service/analysis/decision.go

@@ -4,6 +4,7 @@ package analysis
 import (
 	. "api"
 	"encoding/json"
+	"log"
 	qutil "qfw/util"
 	"regexp"
 )
@@ -12,6 +13,9 @@ type DecParam struct {
 	Area         map[string]interface{}
 	BuyerContent []map[string]interface{}
 	BuyerClass   []string
+	Sid          string
+	Pid          string
+	Pname        string
 }
 
 var regExperts = regexp.MustCompile("^[\\p{Han}]{2,4}$")
@@ -29,6 +33,9 @@ func (this *Analysis) DecInfo() {
 		var buyerClass = []string{}                   //采购单位行业
 		var area = map[string]interface{}{}           //地区
 		var buyerContent = []map[string]interface{}{} //采购内容
+		var pid = ""                                  //项目id
+		var sid = ""                                  //项目招标信息id
+		var pname = ""                                //项目名称
 		//接受前端参数
 		getRes := new(DecParam)
 		if string(this.Body()) != "" {
@@ -38,11 +45,20 @@ func (this *Analysis) DecInfo() {
 			area = getRes.Area                 //区域
 			buyerClass = getRes.BuyerClass     //客户类型(采购单位行业)
 			buyerContent = getRes.BuyerContent //采购内容(一个功能一个新名字 其实就是订阅关键词)
+			pid = getRes.Pid
+			pname = getRes.Pname
+			sid = getRes.Sid
 		}
+		log.Println(pid, "----")
 		// log.Println(buyerClass, area, buyerContent)
-		if len(buyerContent) > 0 {
-			decQuery := DecQuery(area, buyerClass, buyerContent)
-			regMap.Data = getDecInfo(decQuery)
+		if sid != "" && pname != "" && len(buyerContent) > 0 {
+			userId, _ := this.GetSession("userId").(string)
+			//试用用户投标决策权限
+			ai := AnalysisPower("project", userId, pname, sid)
+			if ai > 0 {
+				decQuery := DecQuery(area, buyerClass, buyerContent)
+				regMap.Data = getDecInfo(decQuery)
+			}
 		} else {
 			regMap.Error_code = Error_code_1002
 			regMap.Error_msg = Error_msg_1002
@@ -56,7 +72,6 @@ func (this *Analysis) DecInfo() {
 
 //投标决策分析
 func getDecInfo(decQuery string) map[string]interface{} {
-	// devQuery := ""
 	aggs, res := GetAggs(P_INDEX, P_TYPE, decQuery)
 	if res != nil && len(res) > 0 {
 		res = Sequence(res)

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

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

+ 78 - 0
src/jfw/modules/bigmember/src/service/analysis/power.go

@@ -0,0 +1,78 @@
+package analysis
+
+import (
+	. "config"
+	"db"
+	"log"
+	"qfw/util/redis"
+)
+
+var f_0 = 0 //查询错误或者没有权限
+var f_1 = 1 //是已预测或决策过的项目
+var f_2 = 2 //未预测或未决策且有权限
+var f_3 = 3 //非试用用户或是最早一批购买大会员的用户
+
+func AnalysisPower(atype, userId, pname, sid string) int {
+	userInfo, ok := db.Mgo.FindById("user", userId, nil)
+	i_member_status, _ := (*userInfo)["i_member_status"].(int)
+	if !ok || userInfo != nil || len(*userInfo) > 0 {
+		return f_0
+	}
+	if atype == "project" {
+		//投标决策分析
+		if i_member_status != 4 { //非试用用户
+			return f_3
+		}
+		//查看是否决策过的项目
+		base64Key := GetBase64Key(userId, pname, sid)
+		log.Println("base64key:", base64Key)
+		isExists, ok := redis.Exists("other", "decision_trial_"+userId)
+		if ok == nil && isExists {
+			return f_1
+		}
+		//查看是否决策项目次数
+		bamount := getBAmountInfo(userId)
+		if bamount == nil {
+			return f_0
+		}
+		decision_count, _ := bamount["decision_count"].(int)
+		if decision_count > 0 {
+			return f_2
+		}
+	} else if atype == "winner" {
+		//中标预测
+		starttime, _ := (*userInfo)["i_member_starttime"].(int64)
+		if starttime != 0 && starttime < Config.DividingTime {
+			return f_3
+		}
+		//查看是否预测过此项目
+		//forecastw_histroy  用户中标预测记录
+		base64Key := GetBase64Key(userId, pname, sid)
+		fhistorys, ok := db.Mgo.FindOne("forecastw_histroy", map[string]interface{}{
+			"s_userid": userId,
+			"s_key":    base64Key,
+		})
+		if ok && fhistorys != nil && len(*fhistorys) > 0 {
+			return f_1
+		}
+		//是否剩余预测权限
+		bamount := getBAmountInfo(userId)
+		if bamount == nil {
+			return f_0
+		}
+		decision_count, _ := bamount["forecastwinner_count"].(int)
+		if decision_count > 0 {
+			return f_2
+		}
+	}
+	return f_0
+}
+
+//获取mysql 大会员权限信息
+func getBAmountInfo(userId string) map[string]interface{} {
+	info := db.Mysql.SelectBySql("SELECT * FROM bigmember_amount a WHERE a.user_id = '" + userId + "' AND a.is_ing = 1")
+	if info != nil && len(*info) > 0 {
+		return (*info)[0]
+	}
+	return nil
+}

+ 6 - 1
src/jfw/modules/bigmember/src/service/analysis/util.go

@@ -20,7 +20,12 @@ type SignStr struct {
 
 var secret = "20202020"
 
-func Signature(param [][]string) (signedStr string) {
+func GetBase64Key(userId, pname, sid string) (signedStr string) {
+	var param = [][]string{
+		[]string{"userId", userId},
+		[]string{"pname", pname},
+		[]string{"sid", sid},
+	}
 	sgt := &SignStr{[]string{}, []string{}}
 	for k, v := range param {
 		log.Println(k, v)

+ 6 - 0
src/jfw/modules/subscribepay/src/config/config.go

@@ -118,6 +118,12 @@ type entnicheConfig struct {
 
 type memberConfig struct {
 	Price map[string]float64
+	Power struct {
+		Formal_fwinner  int //大会员正式用户中标预测项目数量
+		Trial_fwinner   int //大会员试用用户中标预测项目数量
+		Trial_dproject  int //大会员试用用户投标决策分析项目数量
+		Trial_potential int //大会员试用用户潜在客户|竞争对手获取信息条数
+	}
 }
 
 var Config *config

+ 6 - 5
src/jfw/modules/subscribepay/src/entity/member.go

@@ -1,6 +1,7 @@
 package entity
 
 import (
+	"config"
 	"database/sql"
 	"encoding/json"
 	"log"
@@ -58,8 +59,6 @@ func (m *memberStruct) PayCallBack(param *CallBackParam) bool {
 }
 
 //
-var forecastwinner_count = 3
-var decision_count = 7
 var bigmember_amount = "bigmember_amount"
 
 func normal_member(level int, enddate time.Time, userId string, istrial int) {
@@ -86,14 +85,16 @@ func normal_member(level int, enddate time.Time, userId string, istrial int) {
 			"user_id":                   userId,
 			"createtime":                qutil.NowFormat(qutil.Date_Full_Layout),
 			"updatetime":                qutil.NowFormat(qutil.Date_Full_Layout),
-			"forecastwinner_count":      200,
+			"forecastwinner_count":      config.MemberConfig.Power.Formal_fwinner,
 			"forecastwinner_used_count": 0,
+			"potential_rival_count":     config.MemberConfig.Power.Trial_potential,
+			"potential_customer_count":  config.MemberConfig.Power.Trial_potential,
 			"decision_count":            0,
 			"is_ing":                    1,
 		}
 		if istrial == 1 {
-			insert["forecastwinner_count"] = forecastwinner_count
-			insert["decision_count"] = decision_count
+			insert["forecastwinner_count"] = config.MemberConfig.Power.Trial_fwinner //中标预测
+			insert["decision_count"] = config.MemberConfig.Power.Trial_dproject      //投标决策
 		}
 		bmat := util.Mysql.InsertByTx(tx, bigmember_amount, insert)
 		return bmat > 0 && update_b

+ 6 - 0
src/jfw/modules/subscribepay/src/member.json

@@ -3,5 +3,11 @@
 		"1":2199900,
 		"2":1599900,
 		"3": 599900
+	},
+	"power":{
+		"formal_fwinner":200,
+		"trial_fwinner":3,
+		"trial_dproject":10,
+		"trial_potential":7
 	}
 }