Browse Source

权限校验添加

WH01243 2 years ago
parent
commit
aaf31f6f7b

File diff suppressed because it is too large
+ 4 - 5
src/jfw/modules/bigmember/src/config.json


+ 8 - 2
src/jfw/modules/publicapply/src/attachmentdow/service/service.go

@@ -31,11 +31,14 @@ func (u *Dow) SupplyInfoFileDownload() {
 	}
 	r := func() Result {
 		userid := qu.ObjToString(u.GetSession("userId"))
+		baseUserId := qu.Int64All(u.GetSession("base_user_id"))
+		entId := qu.Int64All(u.GetSession("entId"))
+		accountId := qu.Int64All(u.GetSession("accountId"))
 		if userid == "" {
 			return Result{Data: nil, Error_msg: "未登录"}
 		}
 
-		BaseMsg := jy.GetBigVipUserBaseMsg(userid, db.Mysql, db.Mgo)
+		BaseMsg := jy.GetBigVipUserBaseMsg("10000", userid, baseUserId, accountId, entId, config.Config.Etcd.Hosts, config.Config.Etcd.Key)
 		vipStatus := jy.GetVipState(db.Mysql, db.Mgo, userid)
 		isPower := false
 		//大会员下载权限判断
@@ -116,11 +119,14 @@ func (u *Dow) Subdow() {
 	}
 	r := func() Result {
 		userid := qu.ObjToString(u.GetSession("userId"))
+		baseUserId := qu.Int64All(u.GetSession("base_user_id"))
+		entId := qu.Int64All(u.GetSession("entId"))
+		accountId := qu.Int64All(u.GetSession("accountId"))
 		if userid == "" {
 			return Result{Data: nil, Error_msg: "未登录"}
 		}
 
-		BaseMsg := jy.GetBigVipUserBaseMsg(userid, db.Mysql, db.Mgo)
+		BaseMsg := jy.GetBigVipUserBaseMsg("10000", userid, baseUserId, accountId, entId, config.Config.Etcd.Hosts, config.Config.Etcd.Key)
 		vipStatus := jy.GetVipState(db.Mysql, db.Mgo, userid)
 
 		var (

+ 7 - 7
src/jfw/modules/publicapply/src/bidcollection/entity/entity.go

@@ -4,7 +4,6 @@ import (
 	"fmt"
 	"jy/src/jfw/modules/publicapply/src/config"
 	"jy/src/jfw/modules/publicapply/src/db"
-	"jy/src/jfw/modules/publicapply/src/grpc"
 	"log"
 	"strconv"
 	"strings"
@@ -436,22 +435,23 @@ func Power(userid string, baseUserId, entId, accountId int64) (bool, map[string]
 	isVip, isMember, isEnt, privatedata := false, false, false, false
 	vipstatus := 0
 	//isVip, isMember, isEnt, privatedata
-	resp := grpc.PowerCheck.Check("10000", userid, baseUserId, accountId, entId)
+	//resp := grpc.PowerCheck.Check("10000", userid, baseUserId, accountId, entId)
+	resp := jy.GetBigVipUserBaseMsg("10000", userid, baseUserId, accountId, entId, config.Config.Etcd.Key, config.Config.Etcd.Key)
 	if resp != nil {
-		if resp.Vip.Status > 1 {
+		if resp.VipStatus > 1 {
 			vipstatus = 1
 			isVip = true
 		}
-		if resp.Vip.Upgrade > 0 && isVip {
+		if resp.Vip_BuySet.Upgrade > 0 && isVip {
 			vipstatus = 2
 		}
-		if resp.Member.Status > 0 {
+		if resp.Status > 0 {
 			isMember = true
 		}
-		if resp.Entniche.PowerSource != 1 && resp.Entniche.Status == 1 {
+		if resp.EntnicheStatus > 0 {
 			isEnt = true
 		}
-		privatedata = resp.Ent.PrivateGD
+		privatedata = resp.PrivateGD
 	}
 	return isVip || isEnt || isMember, map[string]interface{}{
 		"vip":         vipstatus,

+ 58 - 53
src/jfw/modules/publicapply/src/config.json

@@ -1,57 +1,62 @@
 {
-	"webPort": "828",
-    "mail": [
-        {
-            "addr": "smtp.exmail.qq.com",
-            "port": 465,
-            "pwd": "ue9Rg9Sf4CVtdm5a",
-            "user": "public03@topnet.net.cn"
-        },
-        {
-            "addr": "smtp.exmail.qq.com",
-            "port": 465,
-            "pwd": "ue9Rg9Sf4CVtdm5a",
-            "user": "public03@topnet.net.cn"
-        }
-    ],
-    "industry": "分类综合测试",
-    "frequency":"周-3",
-    "hotWords":["微信"],
-    "defaultEntList": [
-        "744fb1d7cc3561e11c639fcc2ad955c0",
-        "d47dc00fc4453115d4562ab7ce3144c2",
-        "eb1998800775782e1e80e55a325a42ca",
-        "118b315754f688151b1b2b82c2fb7511",
-        "dd049424278d809c5f5ebc1980c254bf",
-        "5e79625afc8952e7123459e9826ed3c1",
-        "372fd29ec10178affd656996ced9480f",
-        "11c4fe5273ab36ee4ee1a5b1a779d543",
-        "66264174942f9e958ee65b98bcd63f1b",
-        "bf2d5bb853e7935d9e8714a34b53cae1",
-        "8945af2c1a25e9138cb64774cf66fa4b",
-        "971ee9b68eb80fc001258d6bd0bbc57a",
-        "8426311c8e40dc50e5583ce686d4d5bc",
-        "434ab2c08bd8b8c84f2946dc9bae3630",
-        "899ba5bb52a17a92bb9b1868fe30cf08",
-        "c882c88dcb108f2445773b0aad030edc",
-        "ddb4a8abeebd2702a64d0aa4e9172e4a",
-        "ea5547e5826dac4253c00901019a31c5",
-        "9ae1bcd5e1c5c24631515a1193073fa5",
-        "4c9a591604f1a3eb74857fc9de35e9ff",
-        "3613232bc702d011232ed57f0027af1c"
-
-    ],
-    "bidSearchOldUserLimit": 1626105600,
-    "attachmentRPC":"192.168.3.206:10082",
-    "followPushRpc": "127.0.0.1:8759",
-    "file_number": 10,
-    "smsServiceRpc":"127.0.0.1:932",
-    "fileSignBool":true,
-    "followCustomer": {
-      "customerNumb": 10,
-      "enterpriseNumb": 500
+  "webPort": "828",
+  "mail": [
+    {
+      "addr": "smtp.exmail.qq.com",
+      "port": 465,
+      "pwd": "ue9Rg9Sf4CVtdm5a",
+      "user": "public03@topnet.net.cn"
     },
-    "tipInfo":{
-    	"box_moving":1670774400
+    {
+      "addr": "smtp.exmail.qq.com",
+      "port": 465,
+      "pwd": "ue9Rg9Sf4CVtdm5a",
+      "user": "public03@topnet.net.cn"
     }
+  ],
+  "industry": "分类综合测试",
+  "frequency": "周-3",
+  "hotWords": [
+    "微信"
+  ],
+  "defaultEntList": [
+    "744fb1d7cc3561e11c639fcc2ad955c0",
+    "d47dc00fc4453115d4562ab7ce3144c2",
+    "eb1998800775782e1e80e55a325a42ca",
+    "118b315754f688151b1b2b82c2fb7511",
+    "dd049424278d809c5f5ebc1980c254bf",
+    "5e79625afc8952e7123459e9826ed3c1",
+    "372fd29ec10178affd656996ced9480f",
+    "11c4fe5273ab36ee4ee1a5b1a779d543",
+    "66264174942f9e958ee65b98bcd63f1b",
+    "bf2d5bb853e7935d9e8714a34b53cae1",
+    "8945af2c1a25e9138cb64774cf66fa4b",
+    "971ee9b68eb80fc001258d6bd0bbc57a",
+    "8426311c8e40dc50e5583ce686d4d5bc",
+    "434ab2c08bd8b8c84f2946dc9bae3630",
+    "899ba5bb52a17a92bb9b1868fe30cf08",
+    "c882c88dcb108f2445773b0aad030edc",
+    "ddb4a8abeebd2702a64d0aa4e9172e4a",
+    "ea5547e5826dac4253c00901019a31c5",
+    "9ae1bcd5e1c5c24631515a1193073fa5",
+    "4c9a591604f1a3eb74857fc9de35e9ff",
+    "3613232bc702d011232ed57f0027af1c"
+  ],
+  "bidSearchOldUserLimit": 1626105600,
+  "attachmentRPC": "192.168.3.206:10082",
+  "followPushRpc": "127.0.0.1:8759",
+  "file_number": 10,
+  "smsServiceRpc": "127.0.0.1:932",
+  "fileSignBool": true,
+  "followCustomer": {
+    "customerNumb": 10,
+    "enterpriseNumb": 500
+  },
+  "tipInfo": {
+    "box_moving": 1670774400
+  },
+  "etcd": {
+    "hosts": "192.168.3.206:27080",
+    "key": "powercheck.rpc"
+  }
 }

+ 0 - 4
src/jfw/modules/publicapply/src/config.yaml

@@ -1,4 +0,0 @@
-etcd:
-  hosts:
-  - 192.168.3.206:2379
-powercheckKey: "powercheck.rpc" #权限校验中台rpc

+ 4 - 0
src/jfw/modules/publicapply/src/config/config.go

@@ -31,6 +31,10 @@ type config struct {
 	}
 	ExhibitionLog string
 	TipInfo       map[string]int64
+	Etcd          struct {
+		Hosts string `json:"hosts"`
+		Key   string `json:"key"`
+	} `json:"etcd"`
 }
 type BidColl struct {
 	PayUserCollLimit      int    //付费用户收藏数量最大限制

+ 10 - 8
src/jfw/modules/publicapply/src/customer/entity/entiy.go

@@ -16,12 +16,14 @@ import (
 )
 
 type CustomerOperation struct {
-	UserId   string `json:"userId"`
-	EntId    int    `json:"entId"`
-	Name     string `json:"name"`
-	Province string `json:"province"`
-	City     string `json:"city"`
-	B        bool   `json:"b"` //true 取关;默认 false 关注。
+	UserId     string `json:"userId"`
+	EntId      int    `json:"entId"`
+	Name       string `json:"name"`
+	Province   string `json:"province"`
+	City       string `json:"city"`
+	B          bool   `json:"b"` //true 取关;默认 false 关注。
+	BaseUserId int64
+	AccountId  int64
 }
 
 func NewCustomerOperation() CustomerOperation {
@@ -94,7 +96,7 @@ func (this *CustomerOperation) CList(pageSize, pageNo, entUserId int, keyword, i
 	}
 
 	//大会员客户关注上限
-	BigMsg := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo)
+	BigMsg := jy.GetBigVipUserBaseMsg("10000", this.UserId, this.BaseUserId, this.AccountId, qu.Int64All(this.EntId), config.Config.Etcd.Hosts, config.Config.Etcd.Key)
 	entVip := jy.GetEntnicheState(this.UserId, db.Mysql, db.Mgo)
 	customerMap := map[string]interface{}{}
 	if entVip.EntnicheStatus > 0 {
@@ -175,7 +177,7 @@ func (this *CustomerOperation) CheckPower() string {
 		msg = "登录异常"
 	} else {
 		//查询是否是大会员
-		if userPower := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo); userPower.Status > 0 {
+		if userPower := jy.GetBigVipUserBaseMsg("10000", this.UserId, this.BaseUserId, this.AccountId, qu.Int64All(this.EntId), config.Config.Etcd.Hosts, config.Config.Etcd.Key); userPower.Status > 0 {
 			count := redis.GetInt(redisName, fmt.Sprintf(redisCountKey, this.UserId))
 			if count < 1 {
 				query := map[string]interface{}{

+ 13 - 2
src/jfw/modules/publicapply/src/customer/service/service.go

@@ -57,6 +57,9 @@ func (this *ServiceStruct) Exclude() {
 // 关注客户列表
 func (this *ServiceStruct) CstList() {
 	userId, _ := this.GetSession("userId").(string)
+	baseUserId := qu.Int64All(this.GetSession("base_user_id"))
+	entId := qu.IntAll(this.GetSession("entId"))
+	accountId := qu.Int64All(this.GetSession("accountId"))
 	defer qu.Catch()
 	r := func() Result {
 		if this.Method() != "POST" {
@@ -64,6 +67,9 @@ func (this *ServiceStruct) CstList() {
 		}
 		cotion := entity.NewCustomerOperation()
 		cotion.UserId = userId
+		cotion.AccountId = accountId
+		cotion.BaseUserId = baseUserId
+		cotion.EntId = entId
 		entUserId := qu.IntAll(this.GetSession("entUserId")) //获取企业id
 		pageSize, _ := this.GetInteger("pagesize")
 		pageNo, _ := this.GetInteger("pageno")
@@ -86,6 +92,9 @@ func (this *ServiceStruct) CstList() {
 // 关注or取关客户
 func (this *ServiceStruct) CstAtt() {
 	userId, _ := this.GetSession("userId").(string)
+	baseUserId := qu.Int64All(this.GetSession("base_user_id"))
+	entId := qu.IntAll(this.GetSession("entId"))
+	accountId := qu.Int64All(this.GetSession("accountId"))
 	defer qu.Catch()
 	r := func() Result {
 		if this.Method() != "POST" {
@@ -101,8 +110,10 @@ func (this *ServiceStruct) CstAtt() {
 			return Result{Data: nil, Error_msg: Error_msg_1003}
 		}
 		cotion.UserId = userId
-		cotion.EntId = qu.IntAll(this.GetSession("entId"))
-
+		cotion.EntId = entId
+		cotion.UserId = userId
+		cotion.AccountId = accountId
+		cotion.BaseUserId = baseUserId
 		msg := cotion.CheckPower()
 		if !cotion.B && msg != "" {
 			return Result{Data: false, Error_msg: msg}

+ 5 - 2
src/jfw/modules/publicapply/src/enterpriseSearch/service/search.go

@@ -1,7 +1,7 @@
 package service
 
 import (
-	"jy/src/jfw/modules/publicapply/src/db"
+	"jy/src/jfw/modules/publicapply/src/config"
 	"jy/src/jfw/modules/publicapply/src/enterpriseSearch/entity"
 	"log"
 
@@ -19,6 +19,9 @@ type EnterpriseSearchAction struct {
 // DoEntSearch 企业搜索
 func (esa *EnterpriseSearchAction) DoEntSearch() {
 	userId, _ := esa.GetSession("userId").(string)
+	baseUserId := qutil.Int64All(esa.GetSession("base_user_id"))
+	entId := qutil.Int64All(esa.GetSession("entId"))
+	accountId := qutil.Int64All(esa.GetSession("accountId"))
 	rData, errMsg := func() (interface{}, error) {
 		entSearch, err := (&entity.EnterpriseSearch{
 			Match:       esa.GetString("match"),
@@ -39,7 +42,7 @@ func (esa *EnterpriseSearchAction) DoEntSearch() {
 			return nil, err
 		}
 		//查询是否是会员
-		if vipData := jy.GetBigVipUserBaseMsg(userId, db.Mysql, db.Mgo); vipData.Status > 0 || vipData.VipStatus > 0 {
+		if vipData := jy.GetBigVipUserBaseMsg("10000", userId, baseUserId, accountId, entId, config.Config.Etcd.Hosts, config.Config.Etcd.Key); vipData.Status > 0 || vipData.VipStatus > 0 {
 			entSearch.IsVip = true
 		}
 		//查询

+ 4 - 8
src/jfw/modules/publicapply/src/go.mod

@@ -4,18 +4,16 @@ go 1.18
 
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20221229074840-790b25997170
-	app.yhyue.com/moapp/jypkg v0.0.0-20221230014931-c9afd45ba90b
-	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230104083033-9639ee8efbe2
+	app.yhyue.com/moapp/jypkg v0.0.0-20230106055658-e5f85a4ffd9c
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
-	github.com/go-xweb/xweb v0.2.1
 	github.com/gogf/gf/v2 v2.0.6
-	github.com/zeromicro/go-zero v1.4.3
 	go.mongodb.org/mongo-driver v1.11.1
 )
 
 require (
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
 	app.yhyue.com/moapp/message v0.0.0-20221202072401-d825fc65512c // indirect
+	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230106052936-bd3ab7edf7a4 // indirect
 	github.com/BurntSushi/toml v0.4.1 // indirect
 	github.com/beorn7/perks v1.0.1 // indirect
 	github.com/cenkalti/backoff/v4 v4.1.3 // indirect
@@ -34,10 +32,8 @@ require (
 	github.com/go-logr/stdr v1.2.2 // indirect
 	github.com/go-redis/redis/v8 v8.11.5 // indirect
 	github.com/go-sql-driver/mysql v1.7.0 // indirect
-	github.com/go-xweb/httpsession v0.0.0-20141220075701-356d3b4d38d6 // indirect
-	github.com/go-xweb/log v0.0.0-20140701090824-270d183ad77e // indirect
-	github.com/go-xweb/uuid v0.0.0-20140604020037-d7dce341f851 // indirect
 	github.com/gogo/protobuf v1.3.2 // indirect
+	github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
 	github.com/golang/mock v1.6.0 // indirect
 	github.com/golang/protobuf v1.5.2 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
@@ -55,7 +51,6 @@ require (
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/klauspost/compress v1.13.6 // indirect
 	github.com/longbridgeapp/sqlparser v0.3.1 // indirect
-	github.com/lunny/csession v0.0.0-20130910075847-fe53c5de3dfd // indirect
 	github.com/mattn/go-colorable v0.1.9 // indirect
 	github.com/mattn/go-isatty v0.0.14 // indirect
 	github.com/mattn/go-runewidth v0.0.13 // indirect
@@ -81,6 +76,7 @@ require (
 	github.com/xdg-go/scram v1.1.1 // indirect
 	github.com/xdg-go/stringprep v1.0.3 // indirect
 	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
+	github.com/zeromicro/go-zero v1.4.3 // indirect
 	go.etcd.io/etcd/api/v3 v3.5.5 // indirect
 	go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
 	go.etcd.io/etcd/client/v3 v3.5.5 // indirect

+ 5 - 15
src/jfw/modules/publicapply/src/go.sum

@@ -4,12 +4,12 @@ app.yhyue.com/moapp/jyPoints v1.1.1/go.mod h1:SvP8p5L3jGrejHiH2LXfgCg/NPlFiKBC5Y
 app.yhyue.com/moapp/jybase v0.0.0-20220427020729-974c1a148186/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20221229074840-790b25997170 h1:gjx6+x7P1Vp/++OyfuEdR3Bcjj4/HrgIaRnE1cMTP3k=
 app.yhyue.com/moapp/jybase v0.0.0-20221229074840-790b25997170/go.mod h1:efAeRPDpJ13JuNODuqtfLlKQSQgCbnUcwGPzhFU5krY=
-app.yhyue.com/moapp/jypkg v0.0.0-20221230014931-c9afd45ba90b h1:RZ/8iz9U+jo1V97Wxm1lIRnp6UzUsM5A0k+pLUXIQug=
-app.yhyue.com/moapp/jypkg v0.0.0-20221230014931-c9afd45ba90b/go.mod h1:R19Q6Q1AOM47lY194ZQ6qdggbjkijDufoDnJndnRrRM=
+app.yhyue.com/moapp/jypkg v0.0.0-20230106055658-e5f85a4ffd9c h1:3tmWsZPTkhmkPJ1fbDLqrklgnooC1DRNwsjxEoMYbwg=
+app.yhyue.com/moapp/jypkg v0.0.0-20230106055658-e5f85a4ffd9c/go.mod h1:7D6zNxrg+Tma3VC43TLu7XPczubl4uJavua89kaFS1Q=
 app.yhyue.com/moapp/message v0.0.0-20221202072401-d825fc65512c h1:CrcvbsXZ4aQkNikBi7FUUQZNnY8hKsNo2LLe/SqeXs8=
 app.yhyue.com/moapp/message v0.0.0-20221202072401-d825fc65512c/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
-bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230104083033-9639ee8efbe2 h1:r5p0O/bktSIGKOFR6FG6npjTmNu+o3WLLp7VN5tc4VI=
-bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230104083033-9639ee8efbe2/go.mod h1:5nimT8GJh46AyfeeDeyRlDQygMlO7TRM8Pwm41Gxemc=
+bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230106052936-bd3ab7edf7a4 h1:Xv1D9avDKeaM5kQTisF/pIt8y7B7yQ/hAxuWEg75LMs=
+bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230106052936-bd3ab7edf7a4/go.mod h1:5nimT8GJh46AyfeeDeyRlDQygMlO7TRM8Pwm41Gxemc=
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
@@ -559,14 +559,6 @@ github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V
 github.com/go-xorm/builder v0.3.4/go.mod h1:KxkQkNN1DpPKTedxXyTQcmH+rXfvk4LZ9SOOBoZBAxw=
 github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
 github.com/go-xorm/xorm v0.7.9/go.mod h1:XiVxrMMIhFkwSkh96BW7PACl7UhLtx2iJIHMdmjh5sQ=
-github.com/go-xweb/httpsession v0.0.0-20141220075701-356d3b4d38d6 h1:DUiWdm3rS8cC96Y0XeVkDeizzEK6X+qiNgXytLVtbkM=
-github.com/go-xweb/httpsession v0.0.0-20141220075701-356d3b4d38d6/go.mod h1:lwPk13GS+i/NK4FkMm68IcJrAwiu+HtjYa1Y4kW59aY=
-github.com/go-xweb/log v0.0.0-20140701090824-270d183ad77e h1:xmffs7hgrWpAOcquZrdlWpAEaAdlI9myaYcUUmhIP7k=
-github.com/go-xweb/log v0.0.0-20140701090824-270d183ad77e/go.mod h1:ASmYUSBf32lWkkNVX/pnOU4MLuUQpFH4qYHvWHt/l0w=
-github.com/go-xweb/uuid v0.0.0-20140604020037-d7dce341f851 h1:D46USD6oGNWzoJ/h5CWaFq3ELLoLoJzllJ03Xh78VYg=
-github.com/go-xweb/uuid v0.0.0-20140604020037-d7dce341f851/go.mod h1:OmDEC58ZYO1Esk+Uy32SB6LWof9lyROl7q76dBFOCWw=
-github.com/go-xweb/xweb v0.2.1 h1:u5t/ttuSfxiIMDTXj/Pouw9C2ASNABWT16JWHyrtdvY=
-github.com/go-xweb/xweb v0.2.1/go.mod h1:vPjYJgfidYAgBKIwiAyKFC1hfczlqsw9rRT8LtwrGew=
 github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
 github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
 github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg=
@@ -603,6 +595,7 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP
 github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
 github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
 github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
+github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
 github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
 github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
@@ -815,8 +808,6 @@ github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
 github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
 github.com/longbridgeapp/sqlparser v0.3.1 h1:iWOZWGIFgQrJRgobLXUNJdvqGRpbVXkyKUKUA5CNJBE=
 github.com/longbridgeapp/sqlparser v0.3.1/go.mod h1:GIHaUq8zvYyHLCLMJJykx1CdM6LHtkUih/QaJXySSx4=
-github.com/lunny/csession v0.0.0-20130910075847-fe53c5de3dfd h1:DXxmBCahjva4Ox4AWOv6pR1Csv33zSj97SaLOElfIsw=
-github.com/lunny/csession v0.0.0-20130910075847-fe53c5de3dfd/go.mod h1:3w9PScemEkJoLw3OYvLWMoD8XRCmXgGwsSpT6pFpJ0g=
 github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
 github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
 github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
@@ -841,7 +832,6 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m
 github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
 github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
 github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
-github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
 github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=

+ 0 - 40
src/jfw/modules/publicapply/src/grpc/powerCheckCenter.go

@@ -1,40 +0,0 @@
-package grpc
-
-import (
-	"bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/pb"
-	"bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/powercheck"
-	"context"
-	"github.com/gogf/gf/v2/frame/g"
-	"github.com/gogf/gf/v2/os/gctx"
-	"github.com/zeromicro/go-zero/core/discov"
-	"github.com/zeromicro/go-zero/zrpc"
-	"log"
-)
-
-var PowerCheck = &powerCheck{}
-
-type powerCheck struct {
-}
-
-func (p *powerCheck) Check(appid, userId string, baseUserId, accountId, entId int64) *pb.CheckResp {
-	var ctx = gctx.New()
-	client, err := zrpc.NewClient(zrpc.RpcClientConf{
-		Etcd: discov.EtcdConf{
-			Hosts: g.Cfg().MustGet(ctx, "etcd.hosts").Strings(),
-			Key:   g.Cfg().MustGet(ctx, "powercheckKey").String(),
-		},
-	})
-	if err != nil {
-		log.Println(err)
-		return nil
-	}
-	defer client.Conn().Close()
-	resp, err := powercheck.NewPowerCheck(client).Check(context.Background(), &pb.CheckReq{
-		Appid:      appid,
-		Userid:     userId,
-		BaseUserId: baseUserId,
-		AccountId:  accountId,
-		EntId:      entId,
-	})
-	return resp
-}

+ 939 - 934
src/jfw/modules/publicapply/src/subscribePush/entity/keyWords.go

@@ -1,1010 +1,1015 @@
 package entity
 
 import (
-        qutil "app.yhyue.com/moapp/jybase/common"
-        "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
-        "fmt"
-        "jy/src/jfw/modules/publicapply/src/db"
-        "jy/src/jfw/modules/publicapply/src/util"
-        "strconv"
-        "strings"
-        "time"
-
-        "go.mongodb.org/mongo-driver/bson"
+	qutil "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"fmt"
+	"jy/src/jfw/modules/publicapply/src/config"
+	"jy/src/jfw/modules/publicapply/src/db"
+	"jy/src/jfw/modules/publicapply/src/util"
+	"strconv"
+	"strings"
+	"time"
+
+	"go.mongodb.org/mongo-driver/bson"
 )
 
 type KeyWordsSet struct {
-        ClassifyIndex string   //分类索引
-        ClassifyName  string   //分类名称
-        KeyWordIndex  string   //关键词索引
-        KeyWordName   string   //关键词名称
-        ActionType    string   //操作类型 SK:保存/修改关键词; DK:删除关键词; SC:保存/修改分类  DC:删除分类
-        AppendKeyWord []string //附加词
-        NotKeyWord    []string //排除词
-        MatchWay      int      // 单个关键词匹配方事 0:精准匹配 1:模糊匹配
-        KeyWordsCount string   //是否是首次添加关键词
-        Type          string   // 大会员/超级订阅
-        UserId        string   //用户id
-        DeleteKey     string   //删除的关键词 json字符串{"0":"1,2","2":"0,3"} key:分类名称索引  value:分类名称下的关键词索引
-        Power         int
-        EntId         int
-        EntUserId     int
+	ClassifyIndex string   //分类索引
+	ClassifyName  string   //分类名称
+	KeyWordIndex  string   //关键词索引
+	KeyWordName   string   //关键词名称
+	ActionType    string   //操作类型 SK:保存/修改关键词; DK:删除关键词; SC:保存/修改分类  DC:删除分类
+	AppendKeyWord []string //附加词
+	NotKeyWord    []string //排除词
+	MatchWay      int      // 单个关键词匹配方事 0:精准匹配 1:模糊匹配
+	KeyWordsCount string   //是否是首次添加关键词
+	Type          string   // 大会员/超级订阅
+	UserId        string   //用户id
+	DeleteKey     string   //删除的关键词 json字符串{"0":"1,2","2":"0,3"} key:分类名称索引  value:分类名称下的关键词索引
+	Power         int
+	EntId         int
+	EntUserId     int
+	BaseUserId    int64
+	AccountId     int64
 }
 
 func (this *KeyWordsSet) UpdateKeyWords() map[string]interface{} {
-        power := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo)
-        if this.Type == "m" && power.Status < 0 {
-                return map[string]interface{}{"flag": false, "msg": "暂无权限"}
-        }
-        types := "o_jy"
-        if this.Type == "m" {
-                types = "o_member_jy"
-        } else if this.Type == "v" {
-                types = "o_vipjy"
-        }
-        //付费用户
-        if this.Type != "f" && (power.Status > 0 || power.VipStatus > 0) {
-                switch this.ActionType {
-                case "SK": //保存/修改关键词
-                        return AddKeyWords(types, this.UserId, this.ClassifyIndex, this.ClassifyName, this.KeyWordIndex, this.KeyWordName, this.KeyWordsCount, this.NotKeyWord, this.AppendKeyWord, this.MatchWay, this.Power, this.EntUserId, this.EntId)
-                case "DK": //删除关键词
-                        return DeleteKeyWords(types, this.DeleteKey, this.UserId, this.Power, this.EntUserId, this.EntId)
-                case "SC": //保存/修改分类
-                        return AddClass(types, this.ClassifyIndex, this.ClassifyName, this.UserId, this.Power, this.EntUserId, this.EntId)
-                case "DC": //删除分类
-                        return DeleteClass(types, this.ClassifyIndex, this.UserId, this.Power, this.EntUserId, this.EntId)
-                case "directSubKWS": //搜索列表直接订阅关键词
-                        return directSubKWS(types, this.KeyWordName, this.UserId, this.Power, this.EntUserId, this.EntId)
-                }
-        } else {
-                this.ClassifyIndex = "0"
-                this.ClassifyName = "未分类"
-                switch this.ActionType {
-                case "SK": //保存/修改关键词
-                        return AddKeyWordsFree(types, this.UserId, this.ClassifyIndex, this.ClassifyName, this.KeyWordIndex, this.KeyWordName, this.KeyWordsCount, this.NotKeyWord, this.AppendKeyWord, this.MatchWay)
-                case "DK": //删除关键词
-                        return DeleteKeyWordsFree(types, this.DeleteKey, this.UserId)
-                case "directSubKWS": //搜索列表直接订阅关键词
-                        return directSubKWSFree(types, this.KeyWordName, this.UserId)
-                }
-        }
-        return map[string]interface{}{"flag": true, "msg": ""}
+	power := jy.GetBigVipUserBaseMsg("10000", this.UserId, this.BaseUserId, this.AccountId, qutil.Int64All(this.EntId), config.Config.Etcd.Hosts, config.Config.Etcd.Key)
+	if this.Type == "m" && power.Status < 0 {
+		return map[string]interface{}{"flag": false, "msg": "暂无权限"}
+	}
+	types := "o_jy"
+	if this.Type == "m" {
+		types = "o_member_jy"
+	} else if this.Type == "v" {
+		types = "o_vipjy"
+	}
+	//付费用户
+	if this.Type != "f" && (power.Status > 0 || power.VipStatus > 0) {
+		switch this.ActionType {
+		case "SK": //保存/修改关键词
+			return AddKeyWords(types, this.UserId, this.ClassifyIndex, this.ClassifyName, this.KeyWordIndex, this.KeyWordName, this.KeyWordsCount, this.NotKeyWord, this.AppendKeyWord, this.MatchWay, this.Power, this.EntUserId, this.EntId)
+		case "DK": //删除关键词
+			return DeleteKeyWords(types, this.DeleteKey, this.UserId, this.Power, this.EntUserId, this.EntId)
+		case "SC": //保存/修改分类
+			return AddClass(types, this.ClassifyIndex, this.ClassifyName, this.UserId, this.Power, this.EntUserId, this.EntId)
+		case "DC": //删除分类
+			return DeleteClass(types, this.ClassifyIndex, this.UserId, this.Power, this.EntUserId, this.EntId)
+		case "directSubKWS": //搜索列表直接订阅关键词
+			return directSubKWS(types, this.KeyWordName, this.UserId, this.Power, this.EntUserId, this.EntId)
+		}
+	} else {
+		this.ClassifyIndex = "0"
+		this.ClassifyName = "未分类"
+		switch this.ActionType {
+		case "SK": //保存/修改关键词
+			return AddKeyWordsFree(types, this.UserId, this.ClassifyIndex, this.ClassifyName, this.KeyWordIndex, this.KeyWordName, this.KeyWordsCount, this.NotKeyWord, this.AppendKeyWord, this.MatchWay)
+		case "DK": //删除关键词
+			return DeleteKeyWordsFree(types, this.DeleteKey, this.UserId)
+		case "directSubKWS": //搜索列表直接订阅关键词
+			return directSubKWSFree(types, this.KeyWordName, this.UserId)
+		}
+	}
+	return map[string]interface{}{"flag": true, "msg": ""}
 }
 
 //
 func directSubKWSFree(updateItems string, keys string, userId string) map[string]interface{} {
-        data, ok := db.Mgo.FindById("user", userId, fmt.Sprintf(`{"%s":1}`, updateItems))
-        var repleat = false
-        var kwsCount = 0
-        if len([]rune(keys)) > 20 {
-                keys = qutil.SubString(keys, 0, 20)
-        }
-        flag := "n"
-        if ok && data != nil && len(*data) > 0 && keys != "" {
-                updateObj, _ := (*data)[updateItems].(map[string]interface{})
-                if updateObj["a_key"] != nil && len(qutil.ObjArrToMapArr(updateObj["a_key"].([]interface{}))) > 0 {
-                        a_key := updateObj["a_key"].([]interface{})
-                        for _, n := range a_key {
-                                ntmp := qutil.ObjToMap(n.(interface{}))
-                                nkey := qutil.ObjArrToStringArr((*ntmp)["key"].([]interface{}))
-                                if strings.Join(nkey, " ") == keys {
-                                        repleat = true
-                                        break
-                                }
-                        }
-                } else {
-                        //无关键词 直接添加
-                        if ok := db.Mgo.UpdateById("user", userId, bson.M{"$set": bson.M{
-                                fmt.Sprintf("%s.a_key", updateItems): bson.A{
-                                        bson.M{
-                                                "key":        bson.A{keys},
-                                                "appendkey":  bson.A{},
-                                                "notkey":     bson.A{},
-                                                "updatetime": time.Now().Unix(),
-                                        },
-                                },
-                                updateItems + ".l_modifydate": time.Now().Unix(),
-                                // updateItems + ".i_newfree":    1, //老免费用户=>新订阅设置页面 20211122
-                        },
-                        }); ok {
-                                flag = "y"
-                        }
-                        return map[string]interface{}{"flag": flag}
-                }
-                if repleat {
-                        flag = "o"
-                } else if kwsCount >= 10 {
-                        flag = "m"
-                } else {
-                        var _key = make(map[string]interface{})
-                        var a_key = make([]map[string]interface{}, 1)
-                        classify_name := "未分类"
-                        _key["key"] = strings.Split(strings.ReplaceAll(keys, " ", ""), " ")
-                        _key["appendkey"] = []string{}
-                        _key["notkey"] = []string{}
-                        _key["updatetime"] = time.Now().Unix()
-                        a_key[0] = _key
-                        if len(a_key) > 0 {
-                                ok := db.Mgo.UpdateById("user", userId, bson.M{
-                                        "$push": bson.M{
-                                                updateItems + ".a_key": bson.M{
-                                                        "$each": a_key,
-                                                },
-                                        },
-                                        "$set": bson.M{
-                                                updateItems + ".l_modifydate": time.Now().Unix(),
-                                                updateItems + ".s_item":       classify_name,
-                                                // updateItems + ".i_newfree":    1, //老免费用户=>新订阅设置页面 20211122
-                                        },
-                                })
-                                if ok {
-                                        flag = "y"
-                                }
-                        }
-                }
-        }
-        if flag == "y" {
-                //清楚缓存
-                jy.ClearBigVipUserPower(userId)
-        }
-        return map[string]interface{}{"flag": flag}
+	data, ok := db.Mgo.FindById("user", userId, fmt.Sprintf(`{"%s":1}`, updateItems))
+	var repleat = false
+	var kwsCount = 0
+	if len([]rune(keys)) > 20 {
+		keys = qutil.SubString(keys, 0, 20)
+	}
+	flag := "n"
+	if ok && data != nil && len(*data) > 0 && keys != "" {
+		updateObj, _ := (*data)[updateItems].(map[string]interface{})
+		if updateObj["a_key"] != nil && len(qutil.ObjArrToMapArr(updateObj["a_key"].([]interface{}))) > 0 {
+			a_key := updateObj["a_key"].([]interface{})
+			for _, n := range a_key {
+				ntmp := qutil.ObjToMap(n.(interface{}))
+				nkey := qutil.ObjArrToStringArr((*ntmp)["key"].([]interface{}))
+				if strings.Join(nkey, " ") == keys {
+					repleat = true
+					break
+				}
+			}
+		} else {
+			//无关键词 直接添加
+			if ok := db.Mgo.UpdateById("user", userId, bson.M{"$set": bson.M{
+				fmt.Sprintf("%s.a_key", updateItems): bson.A{
+					bson.M{
+						"key":        bson.A{keys},
+						"appendkey":  bson.A{},
+						"notkey":     bson.A{},
+						"updatetime": time.Now().Unix(),
+					},
+				},
+				updateItems + ".l_modifydate": time.Now().Unix(),
+				// updateItems + ".i_newfree":    1, //老免费用户=>新订阅设置页面 20211122
+			},
+			}); ok {
+				flag = "y"
+			}
+			return map[string]interface{}{"flag": flag}
+		}
+		if repleat {
+			flag = "o"
+		} else if kwsCount >= 10 {
+			flag = "m"
+		} else {
+			var _key = make(map[string]interface{})
+			var a_key = make([]map[string]interface{}, 1)
+			classify_name := "未分类"
+			_key["key"] = strings.Split(strings.ReplaceAll(keys, " ", ""), " ")
+			_key["appendkey"] = []string{}
+			_key["notkey"] = []string{}
+			_key["updatetime"] = time.Now().Unix()
+			a_key[0] = _key
+			if len(a_key) > 0 {
+				ok := db.Mgo.UpdateById("user", userId, bson.M{
+					"$push": bson.M{
+						updateItems + ".a_key": bson.M{
+							"$each": a_key,
+						},
+					},
+					"$set": bson.M{
+						updateItems + ".l_modifydate": time.Now().Unix(),
+						updateItems + ".s_item":       classify_name,
+						// updateItems + ".i_newfree":    1, //老免费用户=>新订阅设置页面 20211122
+					},
+				})
+				if ok {
+					flag = "y"
+				}
+			}
+		}
+	}
+	if flag == "y" {
+		//清楚缓存
+		jy.ClearBigVipUserPower(userId)
+	}
+	return map[string]interface{}{"flag": flag}
 }
 
 //免费用户删除关键词
 func DeleteKeyWordsFree(types, deletekey, userId string) map[string]interface{} {
-        //免费用户只有一个分类
-        var index = "0"
-        dMap, err := util.JsonToMap(deletekey)
-        newMap, saveData := []interface{}{}, map[string]interface{}{}
-        if err == nil && len(dMap) > 0 {
-                data, ok := db.Mgo.FindById("user", userId, `{"`+types+`":1}`)
-                if data != nil && ok && len(*data) > 0 {
-                        ojy, _ := (*data)[types].(map[string]interface{})
-                        a_key, _ := ojy["a_key"].([]interface{})
-                        if dMap[index] != nil {
-                                keyarrs := qutil.ObjArrToMapArr(a_key)
-                                for kk, vk := range keyarrs {
-                                        if util.IsContain(strings.Split(dMap[index].(string), ","), strconv.Itoa(kk)) {
-                                                continue
-                                        }
-                                        newMap = append(newMap, vk)
-                                }
-                                saveData[types+".a_key"] = newMap
-                        }
-                }
-        }
-        flag := true
-        if len(saveData) > 0 {
-                flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
-                        "$set": saveData,
-                })
-                SetLog(userId, types, 0, 0, 0)
-        }
-        return map[string]interface{}{"flag": flag, "msg": ""}
+	//免费用户只有一个分类
+	var index = "0"
+	dMap, err := util.JsonToMap(deletekey)
+	newMap, saveData := []interface{}{}, map[string]interface{}{}
+	if err == nil && len(dMap) > 0 {
+		data, ok := db.Mgo.FindById("user", userId, `{"`+types+`":1}`)
+		if data != nil && ok && len(*data) > 0 {
+			ojy, _ := (*data)[types].(map[string]interface{})
+			a_key, _ := ojy["a_key"].([]interface{})
+			if dMap[index] != nil {
+				keyarrs := qutil.ObjArrToMapArr(a_key)
+				for kk, vk := range keyarrs {
+					if util.IsContain(strings.Split(dMap[index].(string), ","), strconv.Itoa(kk)) {
+						continue
+					}
+					newMap = append(newMap, vk)
+				}
+				saveData[types+".a_key"] = newMap
+			}
+		}
+	}
+	flag := true
+	if len(saveData) > 0 {
+		flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
+			"$set": saveData,
+		})
+		SetLog(userId, types, 0, 0, 0)
+	}
+	return map[string]interface{}{"flag": flag, "msg": ""}
 }
 
 //免费用户修改 保存关键词
 func AddKeyWordsFree(types, userId, classIndex, className, keywordsIndex, keywordName, keywordCount string, notKeyword, appendKeyword []string, matchWay int) map[string]interface{} {
-        flag := true
-        data, ok := db.Mgo.FindById("user", userId, `{"`+types+`":1}`)
-        saveData := map[string]interface{}{}
-        if ok && data != nil && len(*data) > 0 {
-                a_items := make([]interface{}, 0)
-                ojy, _ := (*data)[types].(map[string]interface{})
-                a_key, errs := ojy["a_key"].([]interface{})
-                if !errs {
-                        db.Mgo.UpdateById("user", userId, map[string]interface{}{
-                                "$set": map[string]interface{}{
-                                        types + ".a_key": []map[string]interface{}{},
-                                        // types + ".i_newfree": 1, //老免费用户=>新订阅设置页面 20211122
-                                },
-                        })
-                }
-                if ki, _ := strconv.Atoi(keywordsIndex); ki > len(a_key) {
-                        keywordsIndex = strconv.Itoa(len(a_key))
-                } else if ki == 0 {
-                        keywordsIndex = strconv.Itoa(ki)
-                }
-                a_items = append(a_items, ojy)
-                //排除词处理 词过长或者为空的情况
-                if len(notKeyword) > 0 {
-                        for i, notval := range notKeyword {
-                                if len([]rune(notval)) > 20 {
-                                        notval = qutil.SubString(notval, 0, 20)
-                                }
-                                if notval == "" {
-                                        notKeyword = append(notKeyword[:i], notKeyword[i+1:]...)
-                                }
-                        }
-                }
-                var _kws []string //关键词
-                for _, kn := range strings.Split(keywordName, " ") {
-                        if kn != "" {
-                                _kws = append(_kws, kn)
-                        }
-                }
-                var _key = make(map[string]interface{})
-                newKws := []string{_kws[0]} //第一个关键词在key中 后边的存入appendkey
-                _key["key"] = newKws
-                _key["appendkey"] = append(appendKeyword, _kws[1:]...)
-                _key["notkey"] = notKeyword
-                _key["matchway"] = matchWay //matchway 0:精准匹配 1:模糊匹配
-                if KeyWordsRepeat(_key, a_items) {
-                        return map[string]interface{}{"flag": false, "msg": "关键词已存在"}
-                } else {
-                        //修改关键词
-                        saveData[types+".s_item"] = className
-                        // saveData[types+".i_newfree"] = 1 //老免费用户=>新订阅设置页面 20211122
-                        saveData[types+".a_key."+keywordsIndex+".key"] = newKws
-                        saveData[types+".a_key."+keywordsIndex+".appendkey"] = append(appendKeyword, _kws[1:]...)
-                        saveData[types+".a_key."+keywordsIndex+".notkey"] = notKeyword
-                        saveData[types+".a_key."+keywordsIndex+".matchway"] = matchWay
-                        saveData[types+".a_key."+keywordsIndex+".updatetime"] = time.Now().Unix()
-                }
-        }
-        if len(saveData) > 0 {
-                if db.Mgo.UpdateById("user", userId, map[string]interface{}{
-                        "$set": saveData,
-                }) {
-                        flag = true
-                        //清楚缓存
-                        jy.ClearBigVipUserPower(userId)
-                }
-                SetLog(userId, types, 0, 0, 0)
-        }
-        return map[string]interface{}{"flag": flag, "msg": ""}
+	flag := true
+	data, ok := db.Mgo.FindById("user", userId, `{"`+types+`":1}`)
+	saveData := map[string]interface{}{}
+	if ok && data != nil && len(*data) > 0 {
+		a_items := make([]interface{}, 0)
+		ojy, _ := (*data)[types].(map[string]interface{})
+		a_key, errs := ojy["a_key"].([]interface{})
+		if !errs {
+			db.Mgo.UpdateById("user", userId, map[string]interface{}{
+				"$set": map[string]interface{}{
+					types + ".a_key": []map[string]interface{}{},
+					// types + ".i_newfree": 1, //老免费用户=>新订阅设置页面 20211122
+				},
+			})
+		}
+		if ki, _ := strconv.Atoi(keywordsIndex); ki > len(a_key) {
+			keywordsIndex = strconv.Itoa(len(a_key))
+		} else if ki == 0 {
+			keywordsIndex = strconv.Itoa(ki)
+		}
+		a_items = append(a_items, ojy)
+		//排除词处理 词过长或者为空的情况
+		if len(notKeyword) > 0 {
+			for i, notval := range notKeyword {
+				if len([]rune(notval)) > 20 {
+					notval = qutil.SubString(notval, 0, 20)
+				}
+				if notval == "" {
+					notKeyword = append(notKeyword[:i], notKeyword[i+1:]...)
+				}
+			}
+		}
+		var _kws []string //关键词
+		for _, kn := range strings.Split(keywordName, " ") {
+			if kn != "" {
+				_kws = append(_kws, kn)
+			}
+		}
+		var _key = make(map[string]interface{})
+		newKws := []string{_kws[0]} //第一个关键词在key中 后边的存入appendkey
+		_key["key"] = newKws
+		_key["appendkey"] = append(appendKeyword, _kws[1:]...)
+		_key["notkey"] = notKeyword
+		_key["matchway"] = matchWay //matchway 0:精准匹配 1:模糊匹配
+		if KeyWordsRepeat(_key, a_items) {
+			return map[string]interface{}{"flag": false, "msg": "关键词已存在"}
+		} else {
+			//修改关键词
+			saveData[types+".s_item"] = className
+			// saveData[types+".i_newfree"] = 1 //老免费用户=>新订阅设置页面 20211122
+			saveData[types+".a_key."+keywordsIndex+".key"] = newKws
+			saveData[types+".a_key."+keywordsIndex+".appendkey"] = append(appendKeyword, _kws[1:]...)
+			saveData[types+".a_key."+keywordsIndex+".notkey"] = notKeyword
+			saveData[types+".a_key."+keywordsIndex+".matchway"] = matchWay
+			saveData[types+".a_key."+keywordsIndex+".updatetime"] = time.Now().Unix()
+		}
+	}
+	if len(saveData) > 0 {
+		if db.Mgo.UpdateById("user", userId, map[string]interface{}{
+			"$set": saveData,
+		}) {
+			flag = true
+			//清楚缓存
+			jy.ClearBigVipUserPower(userId)
+		}
+		SetLog(userId, types, 0, 0, 0)
+	}
+	return map[string]interface{}{"flag": flag, "msg": ""}
 }
 
 //保存/修改关键词
 func AddKeyWords(types, userId, classIndex, className, keywordsIndex, keywordName, keywordCount string, notKeyword, appendKeyword []string, matchWay int, power, entUserId, entId int) map[string]interface{} {
-        flag := true
-        if power != 1 {
-                //个人版
-                data, ok := db.Mgo.FindById("user", userId, `{"`+types+`.a_items":1}`)
-                saveData := map[string]interface{}{}
-                if ok && data != nil && len(*data) > 0 {
-                        ojy, _ := (*data)[types].(map[string]interface{})
-                        a_items, errs := ojy["a_items"].([]interface{})
-                        if !errs {
-                                db.Mgo.UpdateById("user", userId, map[string]interface{}{
-                                        "$set": map[string]interface{}{
-                                                types + ".a_items": []map[string]interface{}{},
-                                        },
-                                })
-                        }
-                        //附加词处理
-                        if len(appendKeyword) > 0 {
-                                for i, addval := range appendKeyword {
-                                        if len([]rune(addval)) > 20 {
-                                                addval = qutil.SubString(addval, 0, 20)
-                                        }
-                                        if addval == "" {
-                                                appendKeyword = append(appendKeyword[:i], appendKeyword[i+1:]...)
-                                        }
-                                }
-                        }
-                        //排除词处理 词过长或者为空的情况
-                        if len(notKeyword) > 0 {
-                                for i, notval := range notKeyword {
-                                        if len([]rune(notval)) > 20 {
-                                                notval = qutil.SubString(notval, 0, 20)
-                                        }
-                                        if notval == "" {
-                                                notKeyword = append(notKeyword[:i], notKeyword[i+1:]...)
-                                        }
-                                }
-                        }
-                        var _kws []string //关键词
-                        for _, kn := range strings.Split(keywordName, " ") {
-                                if kn != "" {
-                                        _kws = append(_kws, kn)
-                                }
-                        }
-                        var _key = make(map[string]interface{})
-                        newKws := []string{_kws[0]} //第一个关键词在key中 后边的存入appendkey
-                        _key["key"] = newKws
-                        _key["appendkey"] = append(appendKeyword, _kws[1:]...)
-                        _key["notkey"] = notKeyword
-                        _key["matchway"] = matchWay //matchway 0:精准匹配 1:模糊匹配
-                        if KeyWordsRepeat(_key, a_items) {
-                                return map[string]interface{}{"flag": false, "msg": "关键词已存在"}
-                        } else {
-                                //修改关键词
-                                saveData[types+".a_items."+classIndex+".s_item"] = className
-                                saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".key"] = newKws
-                                saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".appendkey"] = append(appendKeyword, _kws[1:]...)
-                                saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".notkey"] = notKeyword
-                                saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".matchway"] = matchWay
-                                saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".updatetime"] = time.Now().Unix()
-                        }
-                }
-
-                if len(saveData) > 0 {
-                        flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
-                                "$set": saveData,
-                        })
-                        SetLog(userId, types, power, entUserId, entId)
-                }
-        } else {
-                //企业个人版
-                //先查看有没有关键词
-                types := "o_entniche"
-                query := map[string]interface{}{
-                        "i_userid": entUserId,
-                        "i_entid":  entId,
-                        "i_type":   1,
-                }
-                data, ok := db.Mgo.Find("entniche_rule", query, `{"`+types+`.a_items":1}`, nil, false, -1, -1)
-                saveData := map[string]interface{}{}
-                if !ok || data == nil || len(*data) == 0 {
-                        db.Mgo.Update("entniche_rule", query, map[string]interface{}{
-                                "$set": map[string]interface{}{
-                                        "o_entniche.a_items": []map[string]interface{}{},
-                                        "l_updatetime":       time.Now().Unix(),
-                                }}, true, false)
-                }
-                //entniche_rule有数据
-                ojy, _ := (*data)[0][types].(map[string]interface{})
-                a_items, errs := ojy["a_items"].([]interface{})
-                if !errs {
-                        db.Mgo.Update("entniche_rule", query, map[string]interface{}{
-                                "$set": map[string]interface{}{
-                                        "o_entniche.a_items": []map[string]interface{}{},
-                                }}, true, false)
-                }
-                //附加词处理
-                if len(appendKeyword) > 0 {
-                        for i, addval := range appendKeyword {
-                                if len([]rune(addval)) > 20 {
-                                        addval = qutil.SubString(addval, 0, 20)
-                                }
-                                if addval == "" {
-                                        appendKeyword = append(appendKeyword[:i], appendKeyword[i+1:]...)
-                                }
-                        }
-                }
-                //排除词处理 词过长或者为空的情况
-                if len(notKeyword) > 0 {
-                        for i, notval := range notKeyword {
-                                if len([]rune(notval)) > 20 {
-                                        notval = qutil.SubString(notval, 0, 20)
-                                }
-                                if notval == "" {
-                                        notKeyword = append(notKeyword[:i], notKeyword[i+1:]...)
-                                }
-                        }
-                }
-                var _kws []string //关键词
-                for _, kn := range strings.Split(keywordName, " ") {
-                        if kn != "" {
-                                _kws = append(_kws, kn)
-                        }
-                }
-                var _key = make(map[string]interface{})
-                newKws := []string{_kws[0]} //第一个关键词在key中 后边的存入appendkey
-                _key["key"] = newKws
-                _key["appendkey"] = append(appendKeyword, _kws[1:]...)
-                _key["notkey"] = notKeyword
-                _key["updatetime"] = time.Now().Unix()
-                _key["matchway"] = matchWay //matchway 0:精准匹配 1:模糊匹配
-                if KeyWordsRepeat(_key, a_items) {
-                        return map[string]interface{}{"flag": false, "msg": "关键词已存在"}
-                } else {
-                        //修改关键词
-                        saveData[types+".a_items."+classIndex+".s_item"] = className
-                        saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".key"] = newKws
-                        saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".appendkey"] = append(appendKeyword, _kws[1:]...)
-                        saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".notkey"] = notKeyword
-                        saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".matchway"] = matchWay
-                        saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".updatetime"] = time.Now().Unix()
-                }
-
-                saveData["l_updatetime"] = time.Now().Unix()
-                flag = db.Mgo.Update("entniche_rule", query, map[string]interface{}{
-                        "$set": saveData,
-                }, true, false)
-                SetLog(userId, types, power, entUserId, entId)
-        }
-
-        return map[string]interface{}{"flag": flag, "msg": ""}
+	flag := true
+	if power != 1 {
+		//个人版
+		data, ok := db.Mgo.FindById("user", userId, `{"`+types+`.a_items":1}`)
+		saveData := map[string]interface{}{}
+		if ok && data != nil && len(*data) > 0 {
+			ojy, _ := (*data)[types].(map[string]interface{})
+			a_items, errs := ojy["a_items"].([]interface{})
+			if !errs {
+				db.Mgo.UpdateById("user", userId, map[string]interface{}{
+					"$set": map[string]interface{}{
+						types + ".a_items": []map[string]interface{}{},
+					},
+				})
+			}
+			//附加词处理
+			if len(appendKeyword) > 0 {
+				for i, addval := range appendKeyword {
+					if len([]rune(addval)) > 20 {
+						addval = qutil.SubString(addval, 0, 20)
+					}
+					if addval == "" {
+						appendKeyword = append(appendKeyword[:i], appendKeyword[i+1:]...)
+					}
+				}
+			}
+			//排除词处理 词过长或者为空的情况
+			if len(notKeyword) > 0 {
+				for i, notval := range notKeyword {
+					if len([]rune(notval)) > 20 {
+						notval = qutil.SubString(notval, 0, 20)
+					}
+					if notval == "" {
+						notKeyword = append(notKeyword[:i], notKeyword[i+1:]...)
+					}
+				}
+			}
+			var _kws []string //关键词
+			for _, kn := range strings.Split(keywordName, " ") {
+				if kn != "" {
+					_kws = append(_kws, kn)
+				}
+			}
+			var _key = make(map[string]interface{})
+			newKws := []string{_kws[0]} //第一个关键词在key中 后边的存入appendkey
+			_key["key"] = newKws
+			_key["appendkey"] = append(appendKeyword, _kws[1:]...)
+			_key["notkey"] = notKeyword
+			_key["matchway"] = matchWay //matchway 0:精准匹配 1:模糊匹配
+			if KeyWordsRepeat(_key, a_items) {
+				return map[string]interface{}{"flag": false, "msg": "关键词已存在"}
+			} else {
+				//修改关键词
+				saveData[types+".a_items."+classIndex+".s_item"] = className
+				saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".key"] = newKws
+				saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".appendkey"] = append(appendKeyword, _kws[1:]...)
+				saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".notkey"] = notKeyword
+				saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".matchway"] = matchWay
+				saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".updatetime"] = time.Now().Unix()
+			}
+		}
+
+		if len(saveData) > 0 {
+			flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
+				"$set": saveData,
+			})
+			SetLog(userId, types, power, entUserId, entId)
+		}
+	} else {
+		//企业个人版
+		//先查看有没有关键词
+		types := "o_entniche"
+		query := map[string]interface{}{
+			"i_userid": entUserId,
+			"i_entid":  entId,
+			"i_type":   1,
+		}
+		data, ok := db.Mgo.Find("entniche_rule", query, `{"`+types+`.a_items":1}`, nil, false, -1, -1)
+		saveData := map[string]interface{}{}
+		if !ok || data == nil || len(*data) == 0 {
+			db.Mgo.Update("entniche_rule", query, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"o_entniche.a_items": []map[string]interface{}{},
+					"l_updatetime":       time.Now().Unix(),
+				}}, true, false)
+		}
+		//entniche_rule有数据
+		ojy, _ := (*data)[0][types].(map[string]interface{})
+		a_items, errs := ojy["a_items"].([]interface{})
+		if !errs {
+			db.Mgo.Update("entniche_rule", query, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"o_entniche.a_items": []map[string]interface{}{},
+				}}, true, false)
+		}
+		//附加词处理
+		if len(appendKeyword) > 0 {
+			for i, addval := range appendKeyword {
+				if len([]rune(addval)) > 20 {
+					addval = qutil.SubString(addval, 0, 20)
+				}
+				if addval == "" {
+					appendKeyword = append(appendKeyword[:i], appendKeyword[i+1:]...)
+				}
+			}
+		}
+		//排除词处理 词过长或者为空的情况
+		if len(notKeyword) > 0 {
+			for i, notval := range notKeyword {
+				if len([]rune(notval)) > 20 {
+					notval = qutil.SubString(notval, 0, 20)
+				}
+				if notval == "" {
+					notKeyword = append(notKeyword[:i], notKeyword[i+1:]...)
+				}
+			}
+		}
+		var _kws []string //关键词
+		for _, kn := range strings.Split(keywordName, " ") {
+			if kn != "" {
+				_kws = append(_kws, kn)
+			}
+		}
+		var _key = make(map[string]interface{})
+		newKws := []string{_kws[0]} //第一个关键词在key中 后边的存入appendkey
+		_key["key"] = newKws
+		_key["appendkey"] = append(appendKeyword, _kws[1:]...)
+		_key["notkey"] = notKeyword
+		_key["updatetime"] = time.Now().Unix()
+		_key["matchway"] = matchWay //matchway 0:精准匹配 1:模糊匹配
+		if KeyWordsRepeat(_key, a_items) {
+			return map[string]interface{}{"flag": false, "msg": "关键词已存在"}
+		} else {
+			//修改关键词
+			saveData[types+".a_items."+classIndex+".s_item"] = className
+			saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".key"] = newKws
+			saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".appendkey"] = append(appendKeyword, _kws[1:]...)
+			saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".notkey"] = notKeyword
+			saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".matchway"] = matchWay
+			saveData[types+".a_items."+classIndex+".a_key."+keywordsIndex+".updatetime"] = time.Now().Unix()
+		}
+
+		saveData["l_updatetime"] = time.Now().Unix()
+		flag = db.Mgo.Update("entniche_rule", query, map[string]interface{}{
+			"$set": saveData,
+		}, true, false)
+		SetLog(userId, types, power, entUserId, entId)
+	}
+
+	return map[string]interface{}{"flag": flag, "msg": ""}
 }
 
 //删除关键词可以批量
 func DeleteKeyWords(types, deletekey, userId string, power, entUserId, entId int) map[string]interface{} {
-        flag := true
-        if power != 1 {
-                dMap, err := util.JsonToMap(deletekey)
-                newMap, saveData := []interface{}{}, map[string]interface{}{}
-                if err == nil && len(dMap) > 0 {
-                        data, ok := db.Mgo.FindById("user", userId, `{"`+types+`.a_items":1}`)
-                        if data != nil && ok && len(*data) > 0 {
-                                ojy, _ := (*data)[types].(map[string]interface{})
-                                a_items, _ := ojy["a_items"].([]interface{})
-                                for k, v := range a_items {
-                                        newItems := map[string]interface{}{}
-                                        if dMap[strconv.Itoa(k)] != nil {
-                                                if items, ok := v.(map[string]interface{}); ok && len(items) > 0 {
-                                                        for kk, vv := range items {
-                                                                new_vv := vv
-                                                                new_m := []map[string]interface{}{}
-                                                                if kk == "a_key" {
-                                                                        keyarrs := qutil.ObjArrToMapArr(vv.([]interface{}))
-                                                                        for kk, vk := range keyarrs {
-                                                                                if util.IsContain(strings.Split(dMap[strconv.Itoa(k)].(string), ","), strconv.Itoa(kk)) {
-                                                                                        continue
-                                                                                }
-                                                                                new_m = append(new_m, vk)
-                                                                        }
-                                                                        new_vv = new_m
-                                                                }
-                                                                newItems[kk] = new_vv
-                                                        }
-                                                }
-                                                newMap = append(newMap, newItems)
-                                        } else {
-                                                newMap = append(newMap, v)
-                                        }
-                                }
-                        }
-                        saveData[types+".a_items"] = newMap
-                }
-                if len(saveData) > 0 {
-                        flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
-                                "$set": saveData,
-                        })
-                        SetLog(userId, types, 0, 0, 0)
-                }
-        } else {
-                types := "o_entniche"
-                dMap, err := util.JsonToMap(deletekey)
-                newMap := []interface{}{}
-                query := map[string]interface{}{
-                        "i_userid": entUserId,
-                        "i_entid":  entId,
-                        "i_type":   1,
-                }
-                if err == nil && len(dMap) > 0 {
-                        data, ok := db.Mgo.Find("entniche_rule", query, `{"o_entniche.a_items":1}`, nil, false, -1, -1)
-                        if data == nil || !ok || len(*data) == 0 {
-                                return map[string]interface{}{"flag": flag, "msg": ""}
-                        }
-                        ojy, _ := (*data)[0][types].(map[string]interface{})
-                        a_items, _ := ojy["a_items"].([]interface{})
-                        for k, v := range a_items {
-                                newItems := map[string]interface{}{}
-                                if dMap[strconv.Itoa(k)] != nil {
-                                        if items, ok := v.(map[string]interface{}); ok && len(items) > 0 {
-                                                for kk, vv := range items {
-                                                        new_vv := vv
-                                                        new_m := []map[string]interface{}{}
-                                                        if kk == "a_key" {
-                                                                keyarrs := qutil.ObjArrToMapArr(vv.([]interface{}))
-                                                                for kk, vk := range keyarrs {
-                                                                        if util.IsContain(strings.Split(dMap[strconv.Itoa(k)].(string), ","), strconv.Itoa(kk)) {
-                                                                                continue
-                                                                        }
-                                                                        new_m = append(new_m, vk)
-                                                                }
-                                                                new_vv = new_m
-                                                        }
-                                                        newItems[kk] = new_vv
-                                                }
-                                        }
-                                        newMap = append(newMap, newItems)
-                                } else {
-                                        newMap = append(newMap, v)
-                                }
-                        }
-                }
-
-                if len(newMap) > 0 {
-                        flag = db.Mgo.Update("entniche_rule", query, bson.M{"$set": bson.M{
-                                "l_updatetime":       time.Now().Unix(),
-                                "o_entniche.a_items": newMap,
-                        }}, true, false)
-                        SetLog(userId, types, power, entUserId, entId)
-                }
-
-        }
-        return map[string]interface{}{"flag": flag, "msg": ""}
+	flag := true
+	if power != 1 {
+		dMap, err := util.JsonToMap(deletekey)
+		newMap, saveData := []interface{}{}, map[string]interface{}{}
+		if err == nil && len(dMap) > 0 {
+			data, ok := db.Mgo.FindById("user", userId, `{"`+types+`.a_items":1}`)
+			if data != nil && ok && len(*data) > 0 {
+				ojy, _ := (*data)[types].(map[string]interface{})
+				a_items, _ := ojy["a_items"].([]interface{})
+				for k, v := range a_items {
+					newItems := map[string]interface{}{}
+					if dMap[strconv.Itoa(k)] != nil {
+						if items, ok := v.(map[string]interface{}); ok && len(items) > 0 {
+							for kk, vv := range items {
+								new_vv := vv
+								new_m := []map[string]interface{}{}
+								if kk == "a_key" {
+									keyarrs := qutil.ObjArrToMapArr(vv.([]interface{}))
+									for kk, vk := range keyarrs {
+										if util.IsContain(strings.Split(dMap[strconv.Itoa(k)].(string), ","), strconv.Itoa(kk)) {
+											continue
+										}
+										new_m = append(new_m, vk)
+									}
+									new_vv = new_m
+								}
+								newItems[kk] = new_vv
+							}
+						}
+						newMap = append(newMap, newItems)
+					} else {
+						newMap = append(newMap, v)
+					}
+				}
+			}
+			saveData[types+".a_items"] = newMap
+		}
+		if len(saveData) > 0 {
+			flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
+				"$set": saveData,
+			})
+			SetLog(userId, types, 0, 0, 0)
+		}
+	} else {
+		types := "o_entniche"
+		dMap, err := util.JsonToMap(deletekey)
+		newMap := []interface{}{}
+		query := map[string]interface{}{
+			"i_userid": entUserId,
+			"i_entid":  entId,
+			"i_type":   1,
+		}
+		if err == nil && len(dMap) > 0 {
+			data, ok := db.Mgo.Find("entniche_rule", query, `{"o_entniche.a_items":1}`, nil, false, -1, -1)
+			if data == nil || !ok || len(*data) == 0 {
+				return map[string]interface{}{"flag": flag, "msg": ""}
+			}
+			ojy, _ := (*data)[0][types].(map[string]interface{})
+			a_items, _ := ojy["a_items"].([]interface{})
+			for k, v := range a_items {
+				newItems := map[string]interface{}{}
+				if dMap[strconv.Itoa(k)] != nil {
+					if items, ok := v.(map[string]interface{}); ok && len(items) > 0 {
+						for kk, vv := range items {
+							new_vv := vv
+							new_m := []map[string]interface{}{}
+							if kk == "a_key" {
+								keyarrs := qutil.ObjArrToMapArr(vv.([]interface{}))
+								for kk, vk := range keyarrs {
+									if util.IsContain(strings.Split(dMap[strconv.Itoa(k)].(string), ","), strconv.Itoa(kk)) {
+										continue
+									}
+									new_m = append(new_m, vk)
+								}
+								new_vv = new_m
+							}
+							newItems[kk] = new_vv
+						}
+					}
+					newMap = append(newMap, newItems)
+				} else {
+					newMap = append(newMap, v)
+				}
+			}
+		}
+
+		if len(newMap) > 0 {
+			flag = db.Mgo.Update("entniche_rule", query, bson.M{"$set": bson.M{
+				"l_updatetime":       time.Now().Unix(),
+				"o_entniche.a_items": newMap,
+			}}, true, false)
+			SetLog(userId, types, power, entUserId, entId)
+		}
+
+	}
+	return map[string]interface{}{"flag": flag, "msg": ""}
 }
 
 //删除分类【可以批量删除】
 func DeleteClass(types, classIndex, userId string, power, entUserId, entId int) map[string]interface{} {
-        flag := true
-        if power != 1 {
-                items, saveData := []interface{}{}, map[string]interface{}{}
-                m := map[string]bool{}
-                for _, v := range strings.Split(classIndex, ",") {
-                        m[v] = true
-                }
-                data, ok := db.Mgo.FindById("user", userId, `{"`+types+`.a_items":1}`)
-                if data != nil && ok && len(*data) > 0 {
-                        ojy, _ := (*data)[types].(map[string]interface{})
-                        a_items, _ := ojy["a_items"].([]interface{})
-                        for k, v := range a_items {
-                                if !m[strconv.Itoa(k)] {
-                                        items = append(items, v)
-                                }
-                        }
-                }
-                saveData[types+".a_items"] = items
-
-                if len(saveData) > 0 {
-                        flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
-                                "$set": saveData,
-                        })
-                        SetLog(userId, types, 0, 0, 0)
-                }
-        } else {
-                types := "o_entniche"
-                query := map[string]interface{}{
-                        "i_userid": entUserId,
-                        "i_entid":  entId,
-                        "i_type":   1,
-                }
-                items := []interface{}{}
-                m := map[string]bool{}
-                for _, v := range strings.Split(classIndex, ",") {
-                        m[v] = true
-                }
-                data, ok := db.Mgo.Find("entniche_rule", query, `{"o_entniche.a_items":1}`, nil, false, -1, -1)
-                if data == nil || !ok || len(*data) == 0 {
-                        return map[string]interface{}{"flag": flag, "msg": ""}
-                }
-                ojy, _ := (*data)[0][types].(map[string]interface{})
-                a_items, _ := ojy["a_items"].([]interface{})
-                for k, v := range a_items {
-                        if !m[strconv.Itoa(k)] {
-                                items = append(items, v)
-                        }
-                }
-
-                if len(items) > 0 {
-                        flag = db.Mgo.Update("entniche_rule", query, bson.M{"$set": bson.M{
-                                "l_updatetime":       time.Now().Unix(),
-                                "o_entniche.a_items": items,
-                        }}, true, false)
-                        SetLog(userId, types, power, entUserId, entId)
-                }
-        }
-        return map[string]interface{}{"flag": flag, "msg": ""}
+	flag := true
+	if power != 1 {
+		items, saveData := []interface{}{}, map[string]interface{}{}
+		m := map[string]bool{}
+		for _, v := range strings.Split(classIndex, ",") {
+			m[v] = true
+		}
+		data, ok := db.Mgo.FindById("user", userId, `{"`+types+`.a_items":1}`)
+		if data != nil && ok && len(*data) > 0 {
+			ojy, _ := (*data)[types].(map[string]interface{})
+			a_items, _ := ojy["a_items"].([]interface{})
+			for k, v := range a_items {
+				if !m[strconv.Itoa(k)] {
+					items = append(items, v)
+				}
+			}
+		}
+		saveData[types+".a_items"] = items
+
+		if len(saveData) > 0 {
+			flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
+				"$set": saveData,
+			})
+			SetLog(userId, types, 0, 0, 0)
+		}
+	} else {
+		types := "o_entniche"
+		query := map[string]interface{}{
+			"i_userid": entUserId,
+			"i_entid":  entId,
+			"i_type":   1,
+		}
+		items := []interface{}{}
+		m := map[string]bool{}
+		for _, v := range strings.Split(classIndex, ",") {
+			m[v] = true
+		}
+		data, ok := db.Mgo.Find("entniche_rule", query, `{"o_entniche.a_items":1}`, nil, false, -1, -1)
+		if data == nil || !ok || len(*data) == 0 {
+			return map[string]interface{}{"flag": flag, "msg": ""}
+		}
+		ojy, _ := (*data)[0][types].(map[string]interface{})
+		a_items, _ := ojy["a_items"].([]interface{})
+		for k, v := range a_items {
+			if !m[strconv.Itoa(k)] {
+				items = append(items, v)
+			}
+		}
+
+		if len(items) > 0 {
+			flag = db.Mgo.Update("entniche_rule", query, bson.M{"$set": bson.M{
+				"l_updatetime":       time.Now().Unix(),
+				"o_entniche.a_items": items,
+			}}, true, false)
+			SetLog(userId, types, power, entUserId, entId)
+		}
+	}
+	return map[string]interface{}{"flag": flag, "msg": ""}
 }
 
 //创建分类名
 func AddClass(types, classIndex, className, userId string, power, entUserId, entId int) map[string]interface{} {
-        flag := true
-        if power != 1 {
-                saveData := map[string]interface{}{}
-                data, ok := db.Mgo.FindById("user", userId, `{"`+types+`.a_items":1}`)
-                if data != nil && ok && len(*data) > 0 {
-                        ojy, _ := (*data)[types].(map[string]interface{})
-                        a_items, errs := ojy["a_items"].([]interface{})
-                        //没有该字段创建
-                        if !errs {
-                                db.Mgo.UpdateById("user", userId, map[string]interface{}{
-                                        "$set": map[string]interface{}{
-                                                "" + types + ".a_items": []map[string]interface{}{},
-                                        },
-                                })
-                        }
-                        sitemsArr := []string{} //分类名称数组
-                        for _, av := range a_items {
-                                _av := qutil.ObjToMap(av)
-                                sitemsArr = append(sitemsArr, qutil.ObjToString((*_av)["s_item"]))
-                        }
-                        if util.IsRepeat(append(sitemsArr, className)) {
-                                return map[string]interface{}{"flag": false, "msg": "分类名称重复"}
-                        }
-                        c_lens := strconv.Itoa(len(a_items))
-                        if ci, _ := strconv.Atoi(classIndex); ci < len(a_items)+1 {
-                                if classIndex == "" || c_lens == classIndex { //新增
-                                        classIndex = strconv.Itoa(len(a_items)) //索引
-                                        saveData[types+".a_items."+classIndex+".a_key"] = []map[string]interface{}{}
-                                }
-                                saveData[types+".a_items."+classIndex+".s_item"] = className
-                                saveData[types+".a_items."+classIndex+".updatetime"] = time.Now().Unix()
-                        }
-                }
-
-                if len(saveData) > 0 {
-                        flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
-                                "$set": saveData,
-                        })
-                        SetLog(userId, types, 0, 0, 0)
-                }
-        } else {
-                types := "o_entniche"
-                query := map[string]interface{}{
-                        "i_userid": entUserId,
-                        "i_entid":  entId,
-                        "i_type":   1,
-                }
-                saveData := map[string]interface{}{}
-                data, ok := db.Mgo.Find("entniche_rule", query, `{"o_entniche.a_items":1}`, nil, false, -1, -1)
-                a_items:=[]interface{}{}
-                if data == nil || !ok || len(*data) == 0 {
-                        db.Mgo.Update("entniche_rule", query, map[string]interface{}{
-                                "$set": map[string]interface{}{
-                                        "o_entniche.a_items": []map[string]interface{}{},
-                                        "l_updatetime":       time.Now().Unix(),
-                                }}, true, false)
-
-                }else{
-                        ojy, _ := (*data)[0][types].(map[string]interface{})
-                        a_items, _ = ojy["a_items"].([]interface{})
-                }
-
-                sitemsArr := []string{} //分类名称数组
-                for _, av := range a_items {
-                        _av := qutil.ObjToMap(av)
-                        sitemsArr = append(sitemsArr, qutil.ObjToString((*_av)["s_item"]))
-                }
-                if util.IsRepeat(append(sitemsArr, className)) {
-                        return map[string]interface{}{"flag": false, "msg": "分类名称重复"}
-                }
-                c_lens := strconv.Itoa(len(a_items))
-                if ci, _ := strconv.Atoi(classIndex); ci < len(a_items)+1 {
-                        if classIndex == "" || c_lens == classIndex { //新增
-                                classIndex = strconv.Itoa(len(a_items)) //索引
-                                saveData[types+".a_items."+classIndex+".a_key"] = []map[string]interface{}{}
-                        }
-                        saveData[types+".a_items."+classIndex+".s_item"] = className
-                        saveData[types+".a_items."+classIndex+".updatetime"] = time.Now().Unix()
-
-                }
-                saveData["l_updatetime"] =  time.Now().Unix()
-                if len(saveData) > 0 {
-                        flag = db.Mgo.Update("entniche_rule", query, map[string]interface{}{
-                                "$set": saveData,
-                        }, true, false)
-                        SetLog(userId, types, power, entUserId, entId)
-                }
-        }
-        return map[string]interface{}{"flag": flag, "msg": ""}
+	flag := true
+	if power != 1 {
+		saveData := map[string]interface{}{}
+		data, ok := db.Mgo.FindById("user", userId, `{"`+types+`.a_items":1}`)
+		if data != nil && ok && len(*data) > 0 {
+			ojy, _ := (*data)[types].(map[string]interface{})
+			a_items, errs := ojy["a_items"].([]interface{})
+			//没有该字段创建
+			if !errs {
+				db.Mgo.UpdateById("user", userId, map[string]interface{}{
+					"$set": map[string]interface{}{
+						"" + types + ".a_items": []map[string]interface{}{},
+					},
+				})
+			}
+			sitemsArr := []string{} //分类名称数组
+			for _, av := range a_items {
+				_av := qutil.ObjToMap(av)
+				sitemsArr = append(sitemsArr, qutil.ObjToString((*_av)["s_item"]))
+			}
+			if util.IsRepeat(append(sitemsArr, className)) {
+				return map[string]interface{}{"flag": false, "msg": "分类名称重复"}
+			}
+			c_lens := strconv.Itoa(len(a_items))
+			if ci, _ := strconv.Atoi(classIndex); ci < len(a_items)+1 {
+				if classIndex == "" || c_lens == classIndex { //新增
+					classIndex = strconv.Itoa(len(a_items)) //索引
+					saveData[types+".a_items."+classIndex+".a_key"] = []map[string]interface{}{}
+				}
+				saveData[types+".a_items."+classIndex+".s_item"] = className
+				saveData[types+".a_items."+classIndex+".updatetime"] = time.Now().Unix()
+			}
+		}
+
+		if len(saveData) > 0 {
+			flag = db.Mgo.UpdateById("user", userId, map[string]interface{}{
+				"$set": saveData,
+			})
+			SetLog(userId, types, 0, 0, 0)
+		}
+	} else {
+		types := "o_entniche"
+		query := map[string]interface{}{
+			"i_userid": entUserId,
+			"i_entid":  entId,
+			"i_type":   1,
+		}
+		saveData := map[string]interface{}{}
+		data, ok := db.Mgo.Find("entniche_rule", query, `{"o_entniche.a_items":1}`, nil, false, -1, -1)
+		a_items := []interface{}{}
+		if data == nil || !ok || len(*data) == 0 {
+			db.Mgo.Update("entniche_rule", query, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"o_entniche.a_items": []map[string]interface{}{},
+					"l_updatetime":       time.Now().Unix(),
+				}}, true, false)
+
+		} else {
+			ojy, _ := (*data)[0][types].(map[string]interface{})
+			a_items, _ = ojy["a_items"].([]interface{})
+		}
+
+		sitemsArr := []string{} //分类名称数组
+		for _, av := range a_items {
+			_av := qutil.ObjToMap(av)
+			sitemsArr = append(sitemsArr, qutil.ObjToString((*_av)["s_item"]))
+		}
+		if util.IsRepeat(append(sitemsArr, className)) {
+			return map[string]interface{}{"flag": false, "msg": "分类名称重复"}
+		}
+		c_lens := strconv.Itoa(len(a_items))
+		if ci, _ := strconv.Atoi(classIndex); ci < len(a_items)+1 {
+			if classIndex == "" || c_lens == classIndex { //新增
+				classIndex = strconv.Itoa(len(a_items)) //索引
+				saveData[types+".a_items."+classIndex+".a_key"] = []map[string]interface{}{}
+			}
+			saveData[types+".a_items."+classIndex+".s_item"] = className
+			saveData[types+".a_items."+classIndex+".updatetime"] = time.Now().Unix()
+
+		}
+		saveData["l_updatetime"] = time.Now().Unix()
+		if len(saveData) > 0 {
+			flag = db.Mgo.Update("entniche_rule", query, map[string]interface{}{
+				"$set": saveData,
+			}, true, false)
+			SetLog(userId, types, power, entUserId, entId)
+		}
+	}
+	return map[string]interface{}{"flag": flag, "msg": ""}
 
 }
 
 //关键词判重
 func KeyWordsRepeat(obj map[string]interface{}, aitems []interface{}) bool {
-        // 录入的关键词
-        key, _ := obj["key"].([]string)
-        notkey, _ := obj["notkey"].([]string)
-        matchway, _ := obj["matchway"].(int) //matchway 0:精准匹配 1:模糊匹配
-        appendkey, _ := obj["appendkey"].([]string)
-        if util.IsRepeat(key) || util.IsRepeat(appendkey) {
-                return true
-        }
-        // 录入的关键词
-        for _, v := range aitems {
-                if items, ok := v.(map[string]interface{}); ok && len(items) > 0 {
-                        for kk, vv := range items {
-                                if kk == "a_key" {
-                                        for _, n := range qutil.ObjArrToMapArr(vv.([]interface{})) {
-                                                db_not := []string{}
-                                                db_key := []string{}
-                                                db_append := []string{}
-                                                if n["key"] != nil {
-                                                        db_key = qutil.ObjArrToStringArr(n["key"].([]interface{}))
-                                                }
-                                                if n["notkey"] != nil {
-                                                        db_not = qutil.ObjArrToStringArr(n["notkey"].([]interface{}))
-                                                }
-                                                if n["appendkey"] != nil {
-                                                        db_append = qutil.ObjArrToStringArr(n["appendkey"].([]interface{}))
-                                                }
-                                                if util.StringArrEqual(key, db_key) && util.StringArrEqual(notkey, db_not) && qutil.IntAllDef(n["matchway"], 0) == matchway && util.StringArrEqual(appendkey, db_append) {
-                                                        return true
-                                                }
-                                        }
-                                }
-                        }
-                }
-        }
-        return false
+	// 录入的关键词
+	key, _ := obj["key"].([]string)
+	notkey, _ := obj["notkey"].([]string)
+	matchway, _ := obj["matchway"].(int) //matchway 0:精准匹配 1:模糊匹配
+	appendkey, _ := obj["appendkey"].([]string)
+	if util.IsRepeat(key) || util.IsRepeat(appendkey) {
+		return true
+	}
+	// 录入的关键词
+	for _, v := range aitems {
+		if items, ok := v.(map[string]interface{}); ok && len(items) > 0 {
+			for kk, vv := range items {
+				if kk == "a_key" {
+					for _, n := range qutil.ObjArrToMapArr(vv.([]interface{})) {
+						db_not := []string{}
+						db_key := []string{}
+						db_append := []string{}
+						if n["key"] != nil {
+							db_key = qutil.ObjArrToStringArr(n["key"].([]interface{}))
+						}
+						if n["notkey"] != nil {
+							db_not = qutil.ObjArrToStringArr(n["notkey"].([]interface{}))
+						}
+						if n["appendkey"] != nil {
+							db_append = qutil.ObjArrToStringArr(n["appendkey"].([]interface{}))
+						}
+						if util.StringArrEqual(key, db_key) && util.StringArrEqual(notkey, db_not) && qutil.IntAllDef(n["matchway"], 0) == matchway && util.StringArrEqual(appendkey, db_append) {
+							return true
+						}
+					}
+				}
+			}
+		}
+	}
+	return false
 }
 
 type UpdateOther struct {
-        PageType        string //projectMatch项目匹配  saveSeniorset关键词匹配方式  infoType信息类型
-        Pmindex         int    //1项目匹配开启 0项目匹配关闭
-        InfoTypeArr     string //信息类型
-        Matchtype       int    //1标题匹配 2项目匹配
-        UserId          string
-        Type            string
-        OtherBuyerclass int //其它采购单位
-        Power           int
-        EntId           int
-        EntUserId       int
+	PageType        string //projectMatch项目匹配  saveSeniorset关键词匹配方式  infoType信息类型
+	Pmindex         int    //1项目匹配开启 0项目匹配关闭
+	InfoTypeArr     string //信息类型
+	Matchtype       int    //1标题匹配 2项目匹配
+	UserId          string
+	Type            string
+	OtherBuyerclass int //其它采购单位
+	Power           int
+	EntId           int
+	EntUserId       int
+	BaseUserId      int64
+	AccountId       int64
 }
 
 func (this *UpdateOther) UpdateOther() map[string]interface{} {
-        power := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo)
-        if this.Type == "m" && power.Status < 0 {
-                return map[string]interface{}{"flag": false, "msg": "暂无权限"}
-        }
-        types := "o_jy"
-        if this.Type == "m" {
-                types = "o_member_jy"
-        } else if this.Type == "v" {
-                types = "o_vipjy"
-        }
-        if this.Power == 1 {
-                types = "o_entniche"
-        }
-        setMap := func() map[string]interface{} {
-                switch this.PageType {
-                case "projectMatch": //项目匹配
-                        return UpdateProjectMatch(types, this.Pmindex)
-                case "saveSeniorset": //关键词匹配方式
-                        return UpdateSaveSeniorset(types, this.Matchtype)
-                case "infoType": //信息类型
-                        return UpdateInfoType(types, this.InfoTypeArr)
-                case "other_buyerclass":
-                        return UpdateOtherBuyerClass(types, this.OtherBuyerclass)
-                case "keytip": //关键词升级弹窗提示(一个用户只提示一次)
-                        return UpdateKeyTip(types)
-                }
-                return nil
-        }()
-        flag := true
-        if types == "o_jy" {
-                // setMap["o_jy.i_newfree"] = 1 //老免费用户=>新订阅设置页面 20211122
-        }
-        if setMap != nil {
-                if this.Power == 1 {
-                        query := map[string]interface{}{
-                                "i_userid": this.EntUserId,
-                                "i_entid":  this.EntId,
-                                "i_type":   1,
-                        }
-                        if db.Mgo.Update("entniche_rule", query, map[string]interface{}{
-                                "$set": setMap,
-                        }, true, false) {
-                                flag = true
-                                //清楚缓存
-                                jy.ClearBigVipUserPower(this.UserId)
-                        }
-                        SetLog(this.UserId, types, this.Power, this.EntUserId, this.EntId)
-                } else {
-                        query := map[string]interface{}{
-                                "i_userid": this.EntUserId,
-                                "i_entid":  this.EntId,
-                        }
-                        setMap["l_updatetime"] = time.Now().Unix()
-                        flag = db.Mgo.Update("entniche_rule", query, bson.M{"$set": setMap}, true, false)
-                        if flag {
-                                flag = true
-                                //清楚缓存
-                                jy.ClearBigVipUserPower(this.UserId)
-                        }
-                        SetLog(this.UserId, types, this.Power, this.EntUserId, this.EntId)
-
-                }
-
-        }
-        return map[string]interface{}{"flag": flag, "msg": ""}
+	power := jy.GetBigVipUserBaseMsg("10000", this.UserId, this.BaseUserId, this.AccountId, qutil.Int64All(this.EntId), config.Config.Etcd.Hosts, config.Config.Etcd.Key)
+	if this.Type == "m" && power.Status < 0 {
+		return map[string]interface{}{"flag": false, "msg": "暂无权限"}
+	}
+	types := "o_jy"
+	if this.Type == "m" {
+		types = "o_member_jy"
+	} else if this.Type == "v" {
+		types = "o_vipjy"
+	}
+	if this.Power == 1 {
+		types = "o_entniche"
+	}
+	setMap := func() map[string]interface{} {
+		switch this.PageType {
+		case "projectMatch": //项目匹配
+			return UpdateProjectMatch(types, this.Pmindex)
+		case "saveSeniorset": //关键词匹配方式
+			return UpdateSaveSeniorset(types, this.Matchtype)
+		case "infoType": //信息类型
+			return UpdateInfoType(types, this.InfoTypeArr)
+		case "other_buyerclass":
+			return UpdateOtherBuyerClass(types, this.OtherBuyerclass)
+		case "keytip": //关键词升级弹窗提示(一个用户只提示一次)
+			return UpdateKeyTip(types)
+		}
+		return nil
+	}()
+	flag := true
+	if types == "o_jy" {
+		// setMap["o_jy.i_newfree"] = 1 //老免费用户=>新订阅设置页面 20211122
+	}
+	if setMap != nil {
+		if this.Power == 1 {
+			query := map[string]interface{}{
+				"i_userid": this.EntUserId,
+				"i_entid":  this.EntId,
+				"i_type":   1,
+			}
+			if db.Mgo.Update("entniche_rule", query, map[string]interface{}{
+				"$set": setMap,
+			}, true, false) {
+				flag = true
+				//清楚缓存
+				jy.ClearBigVipUserPower(this.UserId)
+			}
+			SetLog(this.UserId, types, this.Power, this.EntUserId, this.EntId)
+		} else {
+			query := map[string]interface{}{
+				"i_userid": this.EntUserId,
+				"i_entid":  this.EntId,
+			}
+			setMap["l_updatetime"] = time.Now().Unix()
+			flag = db.Mgo.Update("entniche_rule", query, bson.M{"$set": setMap}, true, false)
+			if flag {
+				flag = true
+				//清楚缓存
+				jy.ClearBigVipUserPower(this.UserId)
+			}
+			SetLog(this.UserId, types, this.Power, this.EntUserId, this.EntId)
+
+		}
+
+	}
+	return map[string]interface{}{"flag": flag, "msg": ""}
 }
 
 //
 func UpdateProjectMatch(types string, pmindex int) map[string]interface{} {
-        return map[string]interface{}{
-                types + ".i_projectmatch": pmindex,
-        }
+	return map[string]interface{}{
+		types + ".i_projectmatch": pmindex,
+	}
 }
 
 //
 func UpdateSaveSeniorset(types string, matchtype int) map[string]interface{} {
-        return map[string]interface{}{
-                types + ".i_matchway": matchtype,
-        }
+	return map[string]interface{}{
+		types + ".i_matchway": matchtype,
+	}
 }
 
 //
 func UpdateInfoType(types string, infotype string) map[string]interface{} {
-        if infotype != "" {
-                return map[string]interface{}{
-                        types + ".a_infotype": strings.Split(infotype, ","),
-                }
-        } else {
-                return map[string]interface{}{
-                        types + ".a_infotype": []string{},
-                }
-        }
+	if infotype != "" {
+		return map[string]interface{}{
+			types + ".a_infotype": strings.Split(infotype, ","),
+		}
+	} else {
+		return map[string]interface{}{
+			types + ".a_infotype": []string{},
+		}
+	}
 }
 
 //
 func UpdateOtherBuyerClass(types string, other int) map[string]interface{} {
-        return map[string]interface{}{
-                types + ".i_matchbuyerclass_other": other,
-        }
+	return map[string]interface{}{
+		types + ".i_matchbuyerclass_other": other,
+	}
 }
 
 //UpdateKeyTip 关键词升级提示
 func UpdateKeyTip(types string) map[string]interface{} {
-        return map[string]interface{}{
-                types + ".b_keytip": true,
-        }
+	return map[string]interface{}{
+		types + ".b_keytip": true,
+	}
 }
 
 func directSubKWS(updateItems string, keys string, userId string, power, entUserId, entId int) map[string]interface{} {
-        flag := "n"
-        if power != 1 {
-                data, ok := db.Mgo.FindById("user", userId, fmt.Sprintf(`{"%s":1}`, updateItems))
-                var repleat = false
-                var classify_index = -1
-                var kwsCount = 0
-                if len([]rune(keys)) > 20 {
-                        keys = qutil.SubString(keys, 0, 20)
-                }
-                if ok && data != nil && len(*data) > 0 && keys != "" {
-                        updateObj, _ := (*data)[updateItems].(map[string]interface{})
-                        if updateObj["a_items"] != nil {
-                                a_items := updateObj["a_items"].([]interface{})
-                                for k, v := range a_items {
-                                        tmp := qutil.ObjToMap(v.(map[string]interface{}))
-                                        a_key := (*tmp)["a_key"].([]interface{})
-                                        kwsCount = kwsCount + len(a_key)
-                                        if (*tmp)["s_item"] == "未分类" {
-                                                classify_index = k
-                                        }
-                                        for _, n := range a_key {
-                                                ntmp := qutil.ObjToMap(n.(interface{}))
-                                                nkey := qutil.ObjArrToStringArr((*ntmp)["key"].([]interface{}))
-                                                if strings.Join(nkey, " ") == keys {
-                                                        repleat = true
-                                                        break
-                                                }
-                                        }
-                                        if repleat {
-                                                break
-                                        }
-                                }
-                                if classify_index == -1 {
-                                        classify_index = len(a_items)
-                                }
-                        } else {
-                                //无关键词 直接添加
-                                if ok := db.Mgo.UpdateById("user", userId, bson.M{"$set": bson.M{fmt.Sprintf("%s.a_items", updateItems): bson.A{bson.M{"s_item": "未分类",
-                                        "a_key":        bson.A{bson.M{"key": bson.A{keys}}},
-                                        "l_modifydate": time.Now().Unix()}}}}); ok {
-                                        flag = "y"
-                                }
-                                return map[string]interface{}{"flag": flag}
-                        }
-                        if repleat {
-                                flag = "o"
-                        } else if kwsCount >= 300 {
-                                flag = "m"
-                        } else {
-                                var _key = make(map[string]interface{})
-                                var a_key = make([]map[string]interface{}, 1)
-                                classify_name := "未分类"
-                                _key["key"] = strings.Split(keys, " ")
-                                a_key[0] = _key
-                                if len(a_key) > 0 {
-                                        ok := db.Mgo.UpdateById("user", userId, bson.M{
-                                                "$push": bson.M{
-                                                        updateItems + ".a_items." + strconv.Itoa(classify_index) + ".a_key": bson.M{
-                                                                "$each": a_key,
-                                                        },
-                                                },
-                                                "$set": bson.M{
-                                                        updateItems + ".l_modifydate":                                        time.Now().Unix(),
-                                                        updateItems + ".a_items." + strconv.Itoa(classify_index) + ".s_item": classify_name,
-                                                },
-                                        })
-                                        if ok {
-                                                flag = "y"
-                                        }
-                                }
-                        }
-                }
-        } else {
-                updateItems = "o_entniche"
-                query := map[string]interface{}{
-                        "i_userid": entUserId,
-                        "i_entid":  entId,
-                        "i_type":   1,
-                }
-                data, ok := db.Mgo.Find("entniche_rule", query, `{"o_entniche.a_items":1}`, nil, false, -1, -1)
-                var repleat = false
-                var classify_index = -1
-                var kwsCount = 0
-                if len([]rune(keys)) > 20 {
-                        keys = qutil.SubString(keys, 0, 20)
-                }
-                if ok && data != nil && len(*data) > 0 && keys != "" {
-                        updateObj, _ := (*data)[0]["o_entniche"].(map[string]interface{})
-                        if updateObj["a_items"] != nil {
-                                a_items := updateObj["a_items"].([]interface{})
-                                for k, v := range a_items {
-                                        tmp := qutil.ObjToMap(v.(map[string]interface{}))
-                                        a_key := (*tmp)["a_key"].([]interface{})
-                                        kwsCount = kwsCount + len(a_key)
-                                        if (*tmp)["s_item"] == "未分类" {
-                                                classify_index = k
-                                        }
-                                        for _, n := range a_key {
-                                                ntmp := qutil.ObjToMap(n.(interface{}))
-                                                nkey := qutil.ObjArrToStringArr((*ntmp)["key"].([]interface{}))
-                                                if strings.Join(nkey, " ") == keys {
-                                                        repleat = true
-                                                        break
-                                                }
-                                        }
-                                        if repleat {
-                                                break
-                                        }
-                                }
-                                if classify_index == -1 {
-                                        classify_index = len(a_items)
-                                }
-                        } else {
-                                //无关键词 直接添加
-                                if ok := db.Mgo.Update("entniche_rule", query, bson.M{"$set": bson.M{"o_entniche.a_items": bson.A{bson.M{"s_item": "未分类",
-                                        "a_key":      bson.A{bson.M{"key": bson.A{keys}}},
-                                        "updatetime": time.Now().Unix()}},
-                                        "l_updatetime": time.Now().Unix(),
-                                }}, true, false); ok {
-                                        flag = "y"
-                                }
-                                return map[string]interface{}{"flag": flag}
-                        }
-                        if repleat {
-                                flag = "o"
-                        } else if kwsCount >= 300 {
-                                flag = "m"
-                        } else {
-                                var _key = make(map[string]interface{})
-                                var a_key = make([]map[string]interface{}, 1)
-                                classify_name := "未分类"
-                                _key["key"] = strings.Split(keys, " ")
-                                a_key[0] = _key
-                                if len(a_key) > 0 {
-                                        ok := db.Mgo.Update("entniche_rule", query, bson.M{
-
-                                                "$push": bson.M{
-                                                        updateItems + ".a_items." + strconv.Itoa(classify_index) + ".a_key": bson.M{
-                                                                "$each": a_key,
-                                                        },
-                                                },
-                                                "$set": bson.M{
-                                                        "l_updatetime": time.Now().Unix(),
-                                                        updateItems + ".a_items." + strconv.Itoa(classify_index) + ".s_item":     classify_name,
-                                                        updateItems + ".a_items." + strconv.Itoa(classify_index) + ".updatetime": time.Now().Unix(),
-                                                },
-                                        }, true, false)
-                                        if ok {
-                                                flag = "y"
-                                        }
-                                }
-                        }
-                }
-        }
-        return map[string]interface{}{"flag": flag}
+	flag := "n"
+	if power != 1 {
+		data, ok := db.Mgo.FindById("user", userId, fmt.Sprintf(`{"%s":1}`, updateItems))
+		var repleat = false
+		var classify_index = -1
+		var kwsCount = 0
+		if len([]rune(keys)) > 20 {
+			keys = qutil.SubString(keys, 0, 20)
+		}
+		if ok && data != nil && len(*data) > 0 && keys != "" {
+			updateObj, _ := (*data)[updateItems].(map[string]interface{})
+			if updateObj["a_items"] != nil {
+				a_items := updateObj["a_items"].([]interface{})
+				for k, v := range a_items {
+					tmp := qutil.ObjToMap(v.(map[string]interface{}))
+					a_key := (*tmp)["a_key"].([]interface{})
+					kwsCount = kwsCount + len(a_key)
+					if (*tmp)["s_item"] == "未分类" {
+						classify_index = k
+					}
+					for _, n := range a_key {
+						ntmp := qutil.ObjToMap(n.(interface{}))
+						nkey := qutil.ObjArrToStringArr((*ntmp)["key"].([]interface{}))
+						if strings.Join(nkey, " ") == keys {
+							repleat = true
+							break
+						}
+					}
+					if repleat {
+						break
+					}
+				}
+				if classify_index == -1 {
+					classify_index = len(a_items)
+				}
+			} else {
+				//无关键词 直接添加
+				if ok := db.Mgo.UpdateById("user", userId, bson.M{"$set": bson.M{fmt.Sprintf("%s.a_items", updateItems): bson.A{bson.M{"s_item": "未分类",
+					"a_key":        bson.A{bson.M{"key": bson.A{keys}}},
+					"l_modifydate": time.Now().Unix()}}}}); ok {
+					flag = "y"
+				}
+				return map[string]interface{}{"flag": flag}
+			}
+			if repleat {
+				flag = "o"
+			} else if kwsCount >= 300 {
+				flag = "m"
+			} else {
+				var _key = make(map[string]interface{})
+				var a_key = make([]map[string]interface{}, 1)
+				classify_name := "未分类"
+				_key["key"] = strings.Split(keys, " ")
+				a_key[0] = _key
+				if len(a_key) > 0 {
+					ok := db.Mgo.UpdateById("user", userId, bson.M{
+						"$push": bson.M{
+							updateItems + ".a_items." + strconv.Itoa(classify_index) + ".a_key": bson.M{
+								"$each": a_key,
+							},
+						},
+						"$set": bson.M{
+							updateItems + ".l_modifydate":                                        time.Now().Unix(),
+							updateItems + ".a_items." + strconv.Itoa(classify_index) + ".s_item": classify_name,
+						},
+					})
+					if ok {
+						flag = "y"
+					}
+				}
+			}
+		}
+	} else {
+		updateItems = "o_entniche"
+		query := map[string]interface{}{
+			"i_userid": entUserId,
+			"i_entid":  entId,
+			"i_type":   1,
+		}
+		data, ok := db.Mgo.Find("entniche_rule", query, `{"o_entniche.a_items":1}`, nil, false, -1, -1)
+		var repleat = false
+		var classify_index = -1
+		var kwsCount = 0
+		if len([]rune(keys)) > 20 {
+			keys = qutil.SubString(keys, 0, 20)
+		}
+		if ok && data != nil && len(*data) > 0 && keys != "" {
+			updateObj, _ := (*data)[0]["o_entniche"].(map[string]interface{})
+			if updateObj["a_items"] != nil {
+				a_items := updateObj["a_items"].([]interface{})
+				for k, v := range a_items {
+					tmp := qutil.ObjToMap(v.(map[string]interface{}))
+					a_key := (*tmp)["a_key"].([]interface{})
+					kwsCount = kwsCount + len(a_key)
+					if (*tmp)["s_item"] == "未分类" {
+						classify_index = k
+					}
+					for _, n := range a_key {
+						ntmp := qutil.ObjToMap(n.(interface{}))
+						nkey := qutil.ObjArrToStringArr((*ntmp)["key"].([]interface{}))
+						if strings.Join(nkey, " ") == keys {
+							repleat = true
+							break
+						}
+					}
+					if repleat {
+						break
+					}
+				}
+				if classify_index == -1 {
+					classify_index = len(a_items)
+				}
+			} else {
+				//无关键词 直接添加
+				if ok := db.Mgo.Update("entniche_rule", query, bson.M{"$set": bson.M{"o_entniche.a_items": bson.A{bson.M{"s_item": "未分类",
+					"a_key":      bson.A{bson.M{"key": bson.A{keys}}},
+					"updatetime": time.Now().Unix()}},
+					"l_updatetime": time.Now().Unix(),
+				}}, true, false); ok {
+					flag = "y"
+				}
+				return map[string]interface{}{"flag": flag}
+			}
+			if repleat {
+				flag = "o"
+			} else if kwsCount >= 300 {
+				flag = "m"
+			} else {
+				var _key = make(map[string]interface{})
+				var a_key = make([]map[string]interface{}, 1)
+				classify_name := "未分类"
+				_key["key"] = strings.Split(keys, " ")
+				a_key[0] = _key
+				if len(a_key) > 0 {
+					ok := db.Mgo.Update("entniche_rule", query, bson.M{
+
+						"$push": bson.M{
+							updateItems + ".a_items." + strconv.Itoa(classify_index) + ".a_key": bson.M{
+								"$each": a_key,
+							},
+						},
+						"$set": bson.M{
+							"l_updatetime": time.Now().Unix(),
+							updateItems + ".a_items." + strconv.Itoa(classify_index) + ".s_item":     classify_name,
+							updateItems + ".a_items." + strconv.Itoa(classify_index) + ".updatetime": time.Now().Unix(),
+						},
+					}, true, false)
+					if ok {
+						flag = "y"
+					}
+				}
+			}
+		}
+	}
+	return map[string]interface{}{"flag": flag}
 }
 
 //订阅设置记录
 func SetLog(userid, types string, power, entUserId, entId int) {
-        if power == 1 {
-                query := map[string]interface{}{
-                        "i_userid": entUserId,
-                        "i_entid":  entId,
-                        "i_type":   1,
-                }
-                res, _ := db.Mgo.FindOne("entniche_rule", query)
-                if res != nil && len(*res) > 0 {
-                        (*res)["userid"] = userid
-                        (*res)["type"] = types
-                        (*res)["createtime"] = time.Now().Unix()
-                        db.Mgo_Log.Save("ovipjy_log", res)
-                }
-        } else {
-                if data, ok := db.Mgo.FindById("user", userid, `{"o_vipjy":1,"o_member_jy":1,"o_jy":1}`); len(*data) > 0 && ok && data != nil {
-                        (*data)["userid"] = userid
-                        (*data)["type"] = types
-                        (*data)["createtime"] = time.Now().Unix()
-                        db.Mgo_Log.Save("ovipjy_log", data)
-                }
-        }
+	if power == 1 {
+		query := map[string]interface{}{
+			"i_userid": entUserId,
+			"i_entid":  entId,
+			"i_type":   1,
+		}
+		res, _ := db.Mgo.FindOne("entniche_rule", query)
+		if res != nil && len(*res) > 0 {
+			(*res)["userid"] = userid
+			(*res)["type"] = types
+			(*res)["createtime"] = time.Now().Unix()
+			db.Mgo_Log.Save("ovipjy_log", res)
+		}
+	} else {
+		if data, ok := db.Mgo.FindById("user", userid, `{"o_vipjy":1,"o_member_jy":1,"o_jy":1}`); len(*data) > 0 && ok && data != nil {
+			(*data)["userid"] = userid
+			(*data)["type"] = types
+			(*data)["createtime"] = time.Now().Unix()
+			db.Mgo_Log.Save("ovipjy_log", data)
+		}
+	}
 }

+ 532 - 529
src/jfw/modules/publicapply/src/subscribePush/entity/setting.go

@@ -1,608 +1,611 @@
 package entity
 
 import (
-        "app.yhyue.com/moapp/jybase/redis"
-        "jy/src/jfw/modules/publicapply/src/db"
-        "errors"
-        "fmt"
-        "log"
-        qutil "app.yhyue.com/moapp/jybase/common"
-        "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
-        "sort"
-        "strings"
-        "time"
-        "jy/src/jfw/modules/publicapply/src/util"
+	qutil "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/redis"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"errors"
+	"fmt"
+	"jy/src/jfw/modules/publicapply/src/config"
+	"jy/src/jfw/modules/publicapply/src/db"
+	"jy/src/jfw/modules/publicapply/src/util"
+	"log"
+	"sort"
+	"strings"
+	"time"
 )
 
 //订阅设置设置修改
 type SubscribeSet struct {
-        Area      map[string]interface{} //地区
-        Industry  []string               //行业
-        UserId    string                 //用户id
-        Type      string                 //类型
-        EntId     int
-        EntUserId int
+	Area       map[string]interface{} //地区
+	Industry   []string               //行业
+	UserId     string                 //用户id
+	Type       string                 //类型
+	EntId      int
+	EntUserId  int
+	BaseUserId int64
+	AccountId  int64
 }
 
 func (this *SubscribeSet) SetAreaAndIndustry() *FuncResult {
-        area := this.Area
-        industry := this.Industry
-        userId := this.UserId
-        typ := this.Type
-        power := 0
-        if typ == "m" {
-                infoCount := db.Mysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and  product_type like '%大会员%' ", this.EntId)
-                if infoCount > 0 {
-                        power = 1
-                }
-                return memberSet(area, industry, userId, power, this.EntUserId, this.EntId)
-        } else if typ == "v" {
-                infoCount := db.Mysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and  product_type like '%VIP订阅%' ", this.EntId)
-                if infoCount > 0 {
-                        power = 1
-                }
-                return vipSet(area, industry, userId, power, this.EntUserId, this.EntId)
-        } else {
-                return freeSet(area, industry, userId)
-        }
+	area := this.Area
+	industry := this.Industry
+	userId := this.UserId
+	typ := this.Type
+	power := 0
+	if typ == "m" {
+		infoCount := db.Mysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and  product_type like '%大会员%' ", this.EntId)
+		if infoCount > 0 {
+			power = 1
+		}
+		return memberSet(area, industry, userId, power, this.EntUserId, this.EntId)
+	} else if typ == "v" {
+		infoCount := db.Mysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and  product_type like '%VIP订阅%' ", this.EntId)
+		if infoCount > 0 {
+			power = 1
+		}
+		return vipSet(area, industry, userId, power, this.EntUserId, this.EntId)
+	} else {
+		return freeSet(area, industry, userId)
+	}
 }
 
 //
 func freeSet(area map[string]interface{}, industry []string, userId string) *FuncResult {
-        //isfirst:是否第一次设置地区;ppb:是否购买省级订阅包; areacount:省份订阅包购买的省份数量-1:全国 无限制调整
-        isfirst, ppb, areacount := IsCanSet(userId, area)
-        //购买省份订阅包 已调整地区次数
-        ppnum := 0
-        //免费用户购买省份订阅包 按月算
-        ym := fmt.Sprint(time.Now().Year()) + "-" + fmt.Sprint(time.Now().Month())
-        if ppb {
-                ppnum = redis.GetInt(jy.PowerCacheDb, fmt.Sprintf(jy.UserUpdateAreaKey, userId, ym))
-        } else if len(area) == 0 {
-                return &FuncResult{false, errors.New("地区参数异常"), nil}
-        }
-        //免费用户未购买省份订阅包 按年算
-        year := fmt.Sprint(time.Now().Year())
-        //免费用户 已调整地区次数
-        fpnum := redis.GetInt(jy.PowerCacheDb, fmt.Sprintf(jy.UserUpdateAreaKey, userId, year))
-        // log.Println(len(area), "fpnum:", fpnum, "ppnum:", ppnum)
-        //第一次设置地区 || 购买全国  不扣次数
-        var issetredis = areacount > -1 && !isfirst
-        if issetredis {
-                //地区范围判断
-                if areacount+jy.BaseAreaNum < len(area) {
-                        return &FuncResult{false, errors.New("超出地区可设置范围"), nil}
-                }
-                //地区调整次数判断
-                if areacount+jy.BaseAreaNum <= ppnum { //+fpnum
-                        return &FuncResult{false, errors.New(fmt.Sprintf("订阅地区调整次数(%d)已用完", areacount+jy.BaseAreaNum)), nil}
-                }
-        }
-        //清楚缓存
-        jy.ClearBigVipUserPower(userId)
-        if !FreeSubChange(userId, &area, industry, ppb, isfirst) {
-                return &FuncResult{false, errors.New("保存修改出错"), nil}
-        } else if issetredis { //更新调整次数 非全国(第一次 不消耗次数)
-                //优先使用省份订阅包次数
-                // log.Println(areacount, "---", ppnum)
-                // log.Println(jy.BaseAreaNum, "---", fpnum)
-                if ppb {
-                        if areacount+jy.BaseAreaNum > ppnum {
-                                redis.Put(jy.PowerCacheDb, fmt.Sprintf(jy.UserUpdateAreaKey, userId, ym), ppnum+1, 31*24*60*60)
-                        } else {
-                                log.Println(fmt.Sprintf("免费用户购买省份订阅包设置地区 扣除次数异常  userId:%s", userId))
-                        }
-                } else if jy.BaseAreaNum > fpnum {
-                        redis.Put(jy.PowerCacheDb, fmt.Sprintf(jy.UserUpdateAreaKey, userId, year), fpnum+1, 365*24*60*60)
-                } else {
-                        log.Println(fmt.Sprintf("免费用户设置地区 扣除次数异常  userId:%s", userId))
-                }
-        }
-        SetLog(userId, "o_jy", 0, 0, 0)
-        return &FuncResult{true, nil, map[string]interface{}{
-                "doSuccess": true,
-        }}
+	//isfirst:是否第一次设置地区;ppb:是否购买省级订阅包; areacount:省份订阅包购买的省份数量-1:全国 无限制调整
+	isfirst, ppb, areacount := IsCanSet(userId, area)
+	//购买省份订阅包 已调整地区次数
+	ppnum := 0
+	//免费用户购买省份订阅包 按月算
+	ym := fmt.Sprint(time.Now().Year()) + "-" + fmt.Sprint(time.Now().Month())
+	if ppb {
+		ppnum = redis.GetInt(jy.PowerCacheDb, fmt.Sprintf(jy.UserUpdateAreaKey, userId, ym))
+	} else if len(area) == 0 {
+		return &FuncResult{false, errors.New("地区参数异常"), nil}
+	}
+	//免费用户未购买省份订阅包 按年算
+	year := fmt.Sprint(time.Now().Year())
+	//免费用户 已调整地区次数
+	fpnum := redis.GetInt(jy.PowerCacheDb, fmt.Sprintf(jy.UserUpdateAreaKey, userId, year))
+	// log.Println(len(area), "fpnum:", fpnum, "ppnum:", ppnum)
+	//第一次设置地区 || 购买全国  不扣次数
+	var issetredis = areacount > -1 && !isfirst
+	if issetredis {
+		//地区范围判断
+		if areacount+jy.BaseAreaNum < len(area) {
+			return &FuncResult{false, errors.New("超出地区可设置范围"), nil}
+		}
+		//地区调整次数判断
+		if areacount+jy.BaseAreaNum <= ppnum { //+fpnum
+			return &FuncResult{false, errors.New(fmt.Sprintf("订阅地区调整次数(%d)已用完", areacount+jy.BaseAreaNum)), nil}
+		}
+	}
+	//清楚缓存
+	jy.ClearBigVipUserPower(userId)
+	if !FreeSubChange(userId, &area, industry, ppb, isfirst) {
+		return &FuncResult{false, errors.New("保存修改出错"), nil}
+	} else if issetredis { //更新调整次数 非全国(第一次 不消耗次数)
+		//优先使用省份订阅包次数
+		// log.Println(areacount, "---", ppnum)
+		// log.Println(jy.BaseAreaNum, "---", fpnum)
+		if ppb {
+			if areacount+jy.BaseAreaNum > ppnum {
+				redis.Put(jy.PowerCacheDb, fmt.Sprintf(jy.UserUpdateAreaKey, userId, ym), ppnum+1, 31*24*60*60)
+			} else {
+				log.Println(fmt.Sprintf("免费用户购买省份订阅包设置地区 扣除次数异常  userId:%s", userId))
+			}
+		} else if jy.BaseAreaNum > fpnum {
+			redis.Put(jy.PowerCacheDb, fmt.Sprintf(jy.UserUpdateAreaKey, userId, year), fpnum+1, 365*24*60*60)
+		} else {
+			log.Println(fmt.Sprintf("免费用户设置地区 扣除次数异常  userId:%s", userId))
+		}
+	}
+	SetLog(userId, "o_jy", 0, 0, 0)
+	return &FuncResult{true, nil, map[string]interface{}{
+		"doSuccess": true,
+	}}
 }
 
 //免费用户地区调整
 func FreeSubChange(userId string, area *map[string]interface{}, industry []string, ppb, isfirst bool) bool {
-        setMap := map[string]interface{}{"$set": map[string]interface{}{
-                "o_jy.o_area":    area, //设置地区
-                "o_jy.i_newfree": 1,    //老免费用户=>新订阅设置页面 20211122
-        }}
-        if ppb {
-                setMap = map[string]interface{}{"$set": map[string]interface{}{
-                        "o_jy.o_area_p":  area, //设置地区
-                        "o_jy.i_newfree": 1,    //老免费用户=>新订阅设置页面 20211122
-                }}
-        }
-        updateOk := db.Mgo.UpdateById("user", userId, setMap)
-        if !updateOk {
-                return false
-        }
-        return true
+	setMap := map[string]interface{}{"$set": map[string]interface{}{
+		"o_jy.o_area":    area, //设置地区
+		"o_jy.i_newfree": 1,    //老免费用户=>新订阅设置页面 20211122
+	}}
+	if ppb {
+		setMap = map[string]interface{}{"$set": map[string]interface{}{
+			"o_jy.o_area_p":  area, //设置地区
+			"o_jy.i_newfree": 1,    //老免费用户=>新订阅设置页面 20211122
+		}}
+	}
+	updateOk := db.Mgo.UpdateById("user", userId, setMap)
+	if !updateOk {
+		return false
+	}
+	return true
 }
 
 //是否可进行地区调整
 func IsCanSet(userId string, areamap map[string]interface{}) (bool, bool, int) {
-        areacount := 0
-        myarea := []string{}
-        setarea := []string{}
-        myareamap := map[string]interface{}{}
-        mData, ok := db.Mgo.FindById("user", userId, `{"o_jy":1}`)
-        if !ok || len(*mData) == 0 || mData == nil {
-                return false, false, areacount
-        }
-        o_jy, _ := (*mData)["o_jy"].(map[string]interface{})
-        //地区是否完全一致
-        if o_jy["o_area"] != nil {
-                myareamap = *qutil.ObjToMap(o_jy["o_area"])
+	areacount := 0
+	myarea := []string{}
+	setarea := []string{}
+	myareamap := map[string]interface{}{}
+	mData, ok := db.Mgo.FindById("user", userId, `{"o_jy":1}`)
+	if !ok || len(*mData) == 0 || mData == nil {
+		return false, false, areacount
+	}
+	o_jy, _ := (*mData)["o_jy"].(map[string]interface{})
+	//地区是否完全一致
+	if o_jy["o_area"] != nil {
+		myareamap = *qutil.ObjToMap(o_jy["o_area"])
 
-        }
-        //是否购买省份订阅包
-        if o_jy["i_ppstatus"] != nil && qutil.IntAll(o_jy["i_ppstatus"]) > 0 {
-                o_buyset_p, _ := o_jy["o_buyset_p"].(map[string]interface{})
-                areacount = qutil.IntAll(o_buyset_p["areacount"]) //-1 全国无限制
-                myareamap = *qutil.ObjToMap(o_jy["o_area_p"])
-        }
-        myareabool := map[string]bool{}
-        areasize := 0
-        //库中地区
-        for oak, _ := range myareamap {
-                myareabool[oak] = true
-                myarea = append(myarea, oak)
-        }
-        //参数地区
-        for sak, _ := range areamap {
-                if myareabool[sak] {
-                        areasize += 1
-                }
-                setarea = append(setarea, sak)
-        }
-        if areaSort(setarea) == areaSort(myarea) || areasize == len(setarea) {
-                log.Println(setarea, "-地区选择前后一致或地区调整在已选择地区范围内-", myarea)
-                return true, qutil.IntAll(o_jy["i_ppstatus"]) > 0, areacount
-        }
-        // log.Println(areaSort(setarea) == areaSort(myarea), "---areacount:", areacount)
-        return o_jy["o_area"] == nil, qutil.IntAll(o_jy["i_ppstatus"]) > 0, areacount
+	}
+	//是否购买省份订阅包
+	if o_jy["i_ppstatus"] != nil && qutil.IntAll(o_jy["i_ppstatus"]) > 0 {
+		o_buyset_p, _ := o_jy["o_buyset_p"].(map[string]interface{})
+		areacount = qutil.IntAll(o_buyset_p["areacount"]) //-1 全国无限制
+		myareamap = *qutil.ObjToMap(o_jy["o_area_p"])
+	}
+	myareabool := map[string]bool{}
+	areasize := 0
+	//库中地区
+	for oak, _ := range myareamap {
+		myareabool[oak] = true
+		myarea = append(myarea, oak)
+	}
+	//参数地区
+	for sak, _ := range areamap {
+		if myareabool[sak] {
+			areasize += 1
+		}
+		setarea = append(setarea, sak)
+	}
+	if areaSort(setarea) == areaSort(myarea) || areasize == len(setarea) {
+		log.Println(setarea, "-地区选择前后一致或地区调整在已选择地区范围内-", myarea)
+		return true, qutil.IntAll(o_jy["i_ppstatus"]) > 0, areacount
+	}
+	// log.Println(areaSort(setarea) == areaSort(myarea), "---areacount:", areacount)
+	return o_jy["o_area"] == nil, qutil.IntAll(o_jy["i_ppstatus"]) > 0, areacount
 }
 
 //
 func areaSort(area []string) string {
-        sort.Slice(area, func(i, j int) bool {
-                return area[i] < area[j]
-        })
-        return strings.Join(area, ",")
+	sort.Slice(area, func(i, j int) bool {
+		return area[i] < area[j]
+	})
+	return strings.Join(area, ",")
 }
 
 //
 func vipSet(area map[string]interface{}, industry []string, userId string, power, entUserId, entId int) *FuncResult {
-        if len(industry) == 1 && industry[0] == "" {
-                industry = []string{}
-        }
-        rData, oldBuyset, isVip := GetVipDetail(userId)
-        if !isVip {
-                return &FuncResult{false, errors.New("请求异常,非vip状态"), nil}
-        }
-        if power == 1 {
-                query := map[string]interface{}{
-                        "i_userid": entUserId,
-                        "i_entid":  entId,
-                        "i_type":   1,
-                }
-                res, _ := db.Mgo.FindOne("entniche_rule", query)
-                if res != nil && len(*res) > 0 {
-                        rData = qutil.ObjToMap((*res))
-                }
-        }
-        if rData == nil || len(*rData) == 0 {
-                return &FuncResult{false, errors.New("获取信息失败"), nil}
-        }
-        newBuyset := NewBuySet(&area, industry, oldBuyset.Upgrade == 1)
+	if len(industry) == 1 && industry[0] == "" {
+		industry = []string{}
+	}
+	rData, oldBuyset, isVip := GetVipDetail(userId)
+	if !isVip {
+		return &FuncResult{false, errors.New("请求异常,非vip状态"), nil}
+	}
+	if power == 1 {
+		query := map[string]interface{}{
+			"i_userid": entUserId,
+			"i_entid":  entId,
+			"i_type":   1,
+		}
+		res, _ := db.Mgo.FindOne("entniche_rule", query)
+		if res != nil && len(*res) > 0 {
+			rData = qutil.ObjToMap((*res))
+		}
+	}
+	if rData == nil || len(*rData) == 0 {
+		return &FuncResult{false, errors.New("获取信息失败"), nil}
+	}
+	newBuyset := NewBuySet(&area, industry, oldBuyset.Upgrade == 1)
 
-        if needUpgrade := needUpgrade(newBuyset, oldBuyset); needUpgrade {
-                log.Printf("%s 订阅内容超出套餐 %+v area:%v industry:%v", userId, oldBuyset, area, industry)
-                return &FuncResult{false, errors.New("订阅内容超出套餐"), nil}
-        }
-        if power == 1 {
-                if !VipSubChange(userId, qutil.ObjToMap((*rData)["o_entniche"]), &area, industry, power, entUserId, entId) {
-                        return &FuncResult{false, errors.New("保存修改出错"), nil}
-                }
-        } else {
-                if !VipSubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), &area, industry, power, entUserId, entId) {
-                        return &FuncResult{false, errors.New("保存修改出错"), nil}
-                }
-        }
+	if needUpgrade := needUpgrade(newBuyset, oldBuyset); needUpgrade {
+		log.Printf("%s 订阅内容超出套餐 %+v area:%v industry:%v", userId, oldBuyset, area, industry)
+		return &FuncResult{false, errors.New("订阅内容超出套餐"), nil}
+	}
+	if power == 1 {
+		if !VipSubChange(userId, qutil.ObjToMap((*rData)["o_entniche"]), &area, industry, power, entUserId, entId) {
+			return &FuncResult{false, errors.New("保存修改出错"), nil}
+		}
+	} else {
+		if !VipSubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), &area, industry, power, entUserId, entId) {
+			return &FuncResult{false, errors.New("保存修改出错"), nil}
+		}
+	}
 
-        SetLog(userId, "o_vipjy", power, entUserId, entId)
-        return &FuncResult{true, nil, map[string]interface{}{
-                "doSuccess": true,
-        }}
+	SetLog(userId, "o_vipjy", power, entUserId, entId)
+	return &FuncResult{true, nil, map[string]interface{}{
+		"doSuccess": true,
+	}}
 }
 
 //大会员订阅设置
-func memberSet(area map[string]interface{}, industry []string, userId string, power, entUserId, entId int) *FuncResult {
-        if data := jy.GetBigVipUserBaseMsg(userId, db.Mysql, db.Mgo); data.Status <= 0 {
-                return &FuncResult{false, errors.New("请求异常,非大会员状态"), nil}
-        }
-        if len(industry) == 1 && industry[0] == "" {
-                industry = []string{}
-        }
-        if !MemberSubChange(userId, &area, industry, power, entUserId, entId) {
-                return &FuncResult{false, errors.New("保存修改出错"), nil}
-        }
-        SetLog(userId, "o_member_jy", power, entUserId, entId)
-        return &FuncResult{true, nil, map[string]interface{}{
-                "doSuccess": true,
-        }}
+func memberSet(area map[string]interface{}, industry []string, userId string, power, entUserId, entId, baseUserId, accountId int) *FuncResult {
+	if data := jy.GetBigVipUserBaseMsg("10000", userId, qutil.Int64All(baseUserId), qutil.Int64All(accountId), qutil.Int64All(entId), config.Config.Etcd.Key, config.Config.Etcd.Key); data.Status <= 0 {
+		return &FuncResult{false, errors.New("请求异常,非大会员状态"), nil}
+	}
+	if len(industry) == 1 && industry[0] == "" {
+		industry = []string{}
+	}
+	if !MemberSubChange(userId, &area, industry, power, entUserId, entId) {
+		return &FuncResult{false, errors.New("保存修改出错"), nil}
+	}
+	SetLog(userId, "o_member_jy", power, entUserId, entId)
+	return &FuncResult{true, nil, map[string]interface{}{
+		"doSuccess": true,
+	}}
 }
 
 //购买内容
 type SubvipBuySet struct {
-        Upgrade         int   `json:"upgrade"`         //是否是升级版;1是 其他不是
-        AreaCount       int   `json:"areacount"`       //-1 全国  >0 省份数量
-        NewCitys        []int `json:"newcitys"`        //城市数量(新)
-        BuyerclassCount int   `json:"buyerclasscount"` //行业数
+	Upgrade         int   `json:"upgrade"`         //是否是升级版;1是 其他不是
+	AreaCount       int   `json:"areacount"`       //-1 全国  >0 省份数量
+	NewCitys        []int `json:"newcitys"`        //城市数量(新)
+	BuyerclassCount int   `json:"buyerclasscount"` //行业数
 }
 
 //获取省份,城市,行业购买内容
 //[省份,城市,行业]
 func GetVipDetail(userId string) (*map[string]interface{}, *SubvipBuySet, bool) {
-        mData, ok := db.Mgo.FindById("user", userId, `{"o_vipjy":1,"i_vip_status":1,"l_vip_endtime":1,"l_vip_starttime":1,"isread":1}`)
-        if !ok || len(*mData) == 0 || mData == nil {
-                return nil, nil, false
-        }
-        //是否处于vip状态
-        vipStatus := qutil.IntAll((*mData)["i_vip_status"])
-        tmp := qutil.ObjToMap((*qutil.ObjToMap((*mData)["o_vipjy"]))["o_buyset"])
+	mData, ok := db.Mgo.FindById("user", userId, `{"o_vipjy":1,"i_vip_status":1,"l_vip_endtime":1,"l_vip_starttime":1,"isread":1}`)
+	if !ok || len(*mData) == 0 || mData == nil {
+		return nil, nil, false
+	}
+	//是否处于vip状态
+	vipStatus := qutil.IntAll((*mData)["i_vip_status"])
+	tmp := qutil.ObjToMap((*qutil.ObjToMap((*mData)["o_vipjy"]))["o_buyset"])
 
-        newCity, ok := (*tmp)["newcitys"].([]interface{})
+	newCity, ok := (*tmp)["newcitys"].([]interface{})
 
-        return mData, &SubvipBuySet{
-                qutil.IntAll((*tmp)["upgrade"]),
-                qutil.IntAll((*tmp)["areacount"]),
-                util.ConfirmIntArr(newCity),
-                qutil.IntAll((*tmp)["buyerclasscount"]),
-        }, vipStatus > 0
+	return mData, &SubvipBuySet{
+		qutil.IntAll((*tmp)["upgrade"]),
+		qutil.IntAll((*tmp)["areacount"]),
+		util.ConfirmIntArr(newCity),
+		qutil.IntAll((*tmp)["buyerclasscount"]),
+	}, vipStatus > 0
 }
 
 var SubVipPrice subVipPrice
 
 func init() {
-        qutil.ReadConfig("./subvip_price.json", &SubVipPrice)
+	qutil.ReadConfig("./subvip_price.json", &SubVipPrice)
 }
 
 //价格表
 type subVipPrice struct {
-        Old struct {
-                Month struct {
-                        OneCity_oneBuyerClass     int `json:"oneCity_oneBuyerClass"`     //一个城市一个行业
-                        OneCity_allBuyerClass     int `json:"oneCity_allBuyerClass"`     //一个城市全部行业
-                        OneProvince_oneBuyerClass int `json:"oneProvince_oneBuyerClass"` //一个省份一个行业
-                        OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
-                        AllProvince_oneBuyerClass int `json:"allProvince_oneBuyerClass"` //全国一个行业
-                        AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
-                } `json:"month"`
-                Year struct {
-                        OneCity_oneBuyerClass     int `json:"oneCity_oneBuyerClass"`     //一个城市一个行业
-                        OneCity_allBuyerClass     int `json:"oneCity_allBuyerClass"`     //一个城市全部行业
-                        OneProvince_oneBuyerClass int `json:"oneProvince_oneBuyerClass"` //一个省份一个行业
-                        OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
-                        AllProvince_oneBuyerClass int `json:"allProvince_oneBuyerClass"` //全国一个行业
-                        AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
-                } `json:"year"`
-                CityPrice          int `json:"cityPrice"`          //单个城市价格
-                ProvincePrice      int `json:"provincePrice"`      //单个省份价格
-                BuyerClassPrice    int `json:"buyerClassPrice"`    //单个行业价格
-                CityMaxCount       int `json:"cityMaxCount"`       //单个省份城市可计价最大数量
-                ProvinceMaxCount   int `json:"provinceMaxCount"`   //所有地区中省份可计价最大数量
-                BuyerClassMaxCount int `json:"buyerClassMaxCount"` //行业价格可计价最大数量
-                MonthMaxCount      int `json:"monthMaxCount"`      //月份可计价最大数量
-        } `json:"old"`
-        New struct {
-                Month struct {
-                        OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
-                        AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
-                } `json:"month"`
-                Quarter struct {
-                        OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
-                        AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
-                } `json:"quarter"`
-                Year struct {
-                        OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
-                        AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
-                } `json:"year"`
-                ProvincePrice    int `json:"provincePrice"`    //单个省份价格
-                ProvinceMaxCount int `json:"provinceMaxCount"` //所有地区中省份可计价最大数量
-                MonthMaxCount    int `json:"monthMaxCount"`    //月份可计价最大数量
-        } `json:"new"`
-        Discount float64 `json:"discount"` //折扣(测试使用)
+	Old struct {
+		Month struct {
+			OneCity_oneBuyerClass     int `json:"oneCity_oneBuyerClass"`     //一个城市一个行业
+			OneCity_allBuyerClass     int `json:"oneCity_allBuyerClass"`     //一个城市全部行业
+			OneProvince_oneBuyerClass int `json:"oneProvince_oneBuyerClass"` //一个省份一个行业
+			OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
+			AllProvince_oneBuyerClass int `json:"allProvince_oneBuyerClass"` //全国一个行业
+			AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
+		} `json:"month"`
+		Year struct {
+			OneCity_oneBuyerClass     int `json:"oneCity_oneBuyerClass"`     //一个城市一个行业
+			OneCity_allBuyerClass     int `json:"oneCity_allBuyerClass"`     //一个城市全部行业
+			OneProvince_oneBuyerClass int `json:"oneProvince_oneBuyerClass"` //一个省份一个行业
+			OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
+			AllProvince_oneBuyerClass int `json:"allProvince_oneBuyerClass"` //全国一个行业
+			AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
+		} `json:"year"`
+		CityPrice          int `json:"cityPrice"`          //单个城市价格
+		ProvincePrice      int `json:"provincePrice"`      //单个省份价格
+		BuyerClassPrice    int `json:"buyerClassPrice"`    //单个行业价格
+		CityMaxCount       int `json:"cityMaxCount"`       //单个省份城市可计价最大数量
+		ProvinceMaxCount   int `json:"provinceMaxCount"`   //所有地区中省份可计价最大数量
+		BuyerClassMaxCount int `json:"buyerClassMaxCount"` //行业价格可计价最大数量
+		MonthMaxCount      int `json:"monthMaxCount"`      //月份可计价最大数量
+	} `json:"old"`
+	New struct {
+		Month struct {
+			OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
+			AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
+		} `json:"month"`
+		Quarter struct {
+			OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
+			AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
+		} `json:"quarter"`
+		Year struct {
+			OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
+			AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
+		} `json:"year"`
+		ProvincePrice    int `json:"provincePrice"`    //单个省份价格
+		ProvinceMaxCount int `json:"provinceMaxCount"` //所有地区中省份可计价最大数量
+		MonthMaxCount    int `json:"monthMaxCount"`    //月份可计价最大数量
+	} `json:"new"`
+	Discount float64 `json:"discount"` //折扣(测试使用)
 }
 
 //超级订阅获取购买项
 func NewBuySet(area *map[string]interface{}, industry []string, isUpgrade bool) *SubvipBuySet {
-        pCount := -1
-        citys := []int{}
-        if area != nil {
-                if (*area)["全国"] != nil {
-                        area = &map[string]interface{}{}
-                } else if pCount_tmp := qutil.IntAll((*area)["areacount"]); pCount_tmp > 0 {
-                        pCount = pCount_tmp
-                }
-        }
-        buyset := SubvipBuySet{}
-        if !isUpgrade {
-                buyset.Upgrade = 0 //升级版超级订阅标识
-                if len(*area) > 0 {
-                        pCount = 0
-                        for _, v := range *area {
-                                tmp := v.([]interface{})
-                                if len(tmp) == 0 || len(tmp) > SubVipPrice.Old.CityMaxCount { //省份
-                                        pCount++
-                                } else { //城市
-                                        citys = append(citys, len(tmp))
-                                }
-                        }
-                        //省份数量自动转换全国
-                        if pCount > SubVipPrice.Old.ProvinceMaxCount {
-                                pCount = -1
-                                citys = []int{}
-                        }
-                }
-                buyset.NewCitys = citys
-                buyset.AreaCount = pCount //地区
-                //行业数量自动转换全行业
-                buyset.BuyerclassCount = len(industry)
-                if len(industry) > SubVipPrice.Old.BuyerClassMaxCount || len(industry) == 0 {
-                        buyset.BuyerclassCount = -1
-                }
-        } else {
-                buyset.Upgrade = 1 //升级版超级订阅标识
-                if len(*area) > 0 {
-                        pCount = len(*area)
-                        //省份数量自动转换全国
-                        if pCount > SubVipPrice.New.ProvinceMaxCount {
-                                pCount = -1
-                        }
-                } else {
-                        buyset.AreaCount = -1 //全国
-                }
-                buyset.AreaCount = pCount   //地区
-                buyset.NewCitys = citys     //城市,4.4改版不支持购买城市
-                buyset.BuyerclassCount = -1 //行业,4.4改版只能购买全行业
-        }
-        return &buyset
+	pCount := -1
+	citys := []int{}
+	if area != nil {
+		if (*area)["全国"] != nil {
+			area = &map[string]interface{}{}
+		} else if pCount_tmp := qutil.IntAll((*area)["areacount"]); pCount_tmp > 0 {
+			pCount = pCount_tmp
+		}
+	}
+	buyset := SubvipBuySet{}
+	if !isUpgrade {
+		buyset.Upgrade = 0 //升级版超级订阅标识
+		if len(*area) > 0 {
+			pCount = 0
+			for _, v := range *area {
+				tmp := v.([]interface{})
+				if len(tmp) == 0 || len(tmp) > SubVipPrice.Old.CityMaxCount { //省份
+					pCount++
+				} else { //城市
+					citys = append(citys, len(tmp))
+				}
+			}
+			//省份数量自动转换全国
+			if pCount > SubVipPrice.Old.ProvinceMaxCount {
+				pCount = -1
+				citys = []int{}
+			}
+		}
+		buyset.NewCitys = citys
+		buyset.AreaCount = pCount //地区
+		//行业数量自动转换全行业
+		buyset.BuyerclassCount = len(industry)
+		if len(industry) > SubVipPrice.Old.BuyerClassMaxCount || len(industry) == 0 {
+			buyset.BuyerclassCount = -1
+		}
+	} else {
+		buyset.Upgrade = 1 //升级版超级订阅标识
+		if len(*area) > 0 {
+			pCount = len(*area)
+			//省份数量自动转换全国
+			if pCount > SubVipPrice.New.ProvinceMaxCount {
+				pCount = -1
+			}
+		} else {
+			buyset.AreaCount = -1 //全国
+		}
+		buyset.AreaCount = pCount   //地区
+		buyset.NewCitys = citys     //城市,4.4改版不支持购买城市
+		buyset.BuyerclassCount = -1 //行业,4.4改版只能购买全行业
+	}
+	return &buyset
 }
 
 //是否需要升级
 func needUpgrade(newBuySet, oldBuySet *SubvipBuySet) bool {
-        if newBuySet.Upgrade != 1 { //旧版本订阅是否需要升级校验
-                BuyerclassUpgrade, AreaNeedUpgrade := false, false
-                UpgradeBuyset := &SubvipBuySet{
-                        oldBuySet.Upgrade,
-                        oldBuySet.AreaCount,
-                        oldBuySet.NewCitys,
-                        oldBuySet.BuyerclassCount,
-                }
-                //比较行业
-                if oldBuySet.BuyerclassCount != -1 {
-                        //若当前买的不是全行业,并且当前行业数量小于新行业数量时
-                        if oldBuySet.BuyerclassCount < newBuySet.BuyerclassCount || newBuySet.BuyerclassCount == -1 {
-                                BuyerclassUpgrade = true
-                                //计算升级后的buySet
-                                UpgradeBuyset.BuyerclassCount = newBuySet.BuyerclassCount
-                        }
-                }
-                //比较地区
-                if oldBuySet.AreaCount != -1 {
-                        if newBuySet.AreaCount == -1 { //升级为全国
-                                UpgradeBuyset.AreaCount = newBuySet.AreaCount
-                                UpgradeBuyset.NewCitys = newBuySet.NewCitys
-                                AreaNeedUpgrade = true
-                        } else {
-                                oldCitysBuyOne, oldCitysBuyTwo := 0, 0
-                                newCitysBuyOne, newCitysBuyTwo := 0, 0
-                                oldCopy := []int{} //复制(防止影响原数组)
-                                for _, v := range oldBuySet.NewCitys {
-                                        if v == 1 {
-                                                oldCitysBuyOne++
-                                        } else {
-                                                oldCitysBuyTwo++
-                                        }
-                                        oldCopy = append(oldCopy, v)
-                                }
-                                UpgradeBuyset.NewCitys = oldCopy
-                                for _, v := range newBuySet.NewCitys {
-                                        if v == 1 {
-                                                newCitysBuyOne++
-                                        } else {
-                                                newCitysBuyTwo++
-                                        }
-                                }
+	if newBuySet.Upgrade != 1 { //旧版本订阅是否需要升级校验
+		BuyerclassUpgrade, AreaNeedUpgrade := false, false
+		UpgradeBuyset := &SubvipBuySet{
+			oldBuySet.Upgrade,
+			oldBuySet.AreaCount,
+			oldBuySet.NewCitys,
+			oldBuySet.BuyerclassCount,
+		}
+		//比较行业
+		if oldBuySet.BuyerclassCount != -1 {
+			//若当前买的不是全行业,并且当前行业数量小于新行业数量时
+			if oldBuySet.BuyerclassCount < newBuySet.BuyerclassCount || newBuySet.BuyerclassCount == -1 {
+				BuyerclassUpgrade = true
+				//计算升级后的buySet
+				UpgradeBuyset.BuyerclassCount = newBuySet.BuyerclassCount
+			}
+		}
+		//比较地区
+		if oldBuySet.AreaCount != -1 {
+			if newBuySet.AreaCount == -1 { //升级为全国
+				UpgradeBuyset.AreaCount = newBuySet.AreaCount
+				UpgradeBuyset.NewCitys = newBuySet.NewCitys
+				AreaNeedUpgrade = true
+			} else {
+				oldCitysBuyOne, oldCitysBuyTwo := 0, 0
+				newCitysBuyOne, newCitysBuyTwo := 0, 0
+				oldCopy := []int{} //复制(防止影响原数组)
+				for _, v := range oldBuySet.NewCitys {
+					if v == 1 {
+						oldCitysBuyOne++
+					} else {
+						oldCitysBuyTwo++
+					}
+					oldCopy = append(oldCopy, v)
+				}
+				UpgradeBuyset.NewCitys = oldCopy
+				for _, v := range newBuySet.NewCitys {
+					if v == 1 {
+						newCitysBuyOne++
+					} else {
+						newCitysBuyTwo++
+					}
+				}
 
-                                p_Diff := newBuySet.AreaCount - oldBuySet.AreaCount
-                                c_1_diff := newCitysBuyOne - oldCitysBuyOne
-                                c_2_diff := newCitysBuyTwo - oldCitysBuyTwo
+				p_Diff := newBuySet.AreaCount - oldBuySet.AreaCount
+				c_1_diff := newCitysBuyOne - oldCitysBuyOne
+				c_2_diff := newCitysBuyTwo - oldCitysBuyTwo
 
-                                if p_Diff > 0 {
-                                        UpgradeBuyset.AreaCount = newBuySet.AreaCount
-                                }
+				if p_Diff > 0 {
+					UpgradeBuyset.AreaCount = newBuySet.AreaCount
+				}
 
-                                if p_Diff > 0 || p_Diff+c_2_diff > 0 || p_Diff+c_2_diff+c_1_diff > 0 {
-                                        //有多余未使用名额保留
-                                        if p_Diff+c_2_diff+c_1_diff < 0 {
-                                                if c_1_diff < 0 && p_Diff+c_2_diff >= 0 {
-                                                        c_1_diff = -(p_Diff + c_2_diff)
-                                                }
-                                                if c_2_diff < 0 && p_Diff+c_1_diff >= 0 {
-                                                        c_2_diff = -(p_Diff + c_1_diff)
-                                                }
-                                        }
+				if p_Diff > 0 || p_Diff+c_2_diff > 0 || p_Diff+c_2_diff+c_1_diff > 0 {
+					//有多余未使用名额保留
+					if p_Diff+c_2_diff+c_1_diff < 0 {
+						if c_1_diff < 0 && p_Diff+c_2_diff >= 0 {
+							c_1_diff = -(p_Diff + c_2_diff)
+						}
+						if c_2_diff < 0 && p_Diff+c_1_diff >= 0 {
+							c_2_diff = -(p_Diff + c_1_diff)
+						}
+					}
 
-                                        //需要升级
-                                        AreaNeedUpgrade = true
-                                        //计算升级后的buySet
-                                        if p_Diff < 0 { //有剩余省份未使用
-                                                if c_2_diff > 0 {
-                                                        c_2_diff += p_Diff //转移给两个市使用
-                                                } else {
-                                                        c_1_diff += p_Diff //转移给一个市使用
-                                                }
-                                        } else { //省份数量增加
-                                                UpgradeBuyset.AreaCount = newBuySet.AreaCount
-                                        }
-                                        del_2_flag, del_1_flag := 0, 0 //被占用
-                                        if c_2_diff < 0 {              //有两个城市的名额未使用完
-                                                if p_Diff > 0 {
-                                                        //转移给一个省使用
-                                                        if c_2_diff+p_Diff > 0 {
-                                                                del_2_flag += -c_2_diff
-                                                                c_2_diff = 0
-                                                                //p_Diff -= -c_2_diff;
-                                                        } else {
-                                                                c_2_diff += p_Diff
-                                                                del_2_flag += p_Diff
-                                                                //p_Diff = 0
-                                                        }
-                                                }
-                                                if c_1_diff > 0 && c_2_diff < 0 { //转移给一个市使用
-                                                        c_1_diff += c_2_diff
-                                                }
-                                        }
-                                        if c_1_diff < 0 { //有一个城市的名额未使用完
-                                                if p_Diff > 0 {
-                                                        if c_1_diff+p_Diff > 0 {
-                                                                del_1_flag += -c_1_diff
-                                                                c_1_diff = 0
-                                                                //p_Diff -= -c_1_diff
-                                                        } else {
-                                                                c_1_diff += p_Diff
-                                                                del_1_flag += p_Diff
-                                                                //p_Diff = 0
-                                                        }
-                                                }
-                                                if c_2_diff > 0 && c_1_diff < 0 {
-                                                        if c_1_diff+c_2_diff > 0 {
-                                                                del_1_flag += -c_1_diff
-                                                                c_1_diff = 0
-                                                                //c_2_diff -= -c_1_diff;
-                                                        } else {
-                                                                c_1_diff += c_2_diff
-                                                                del_1_flag += c_2_diff
-                                                                //c_2_diff = 0
-                                                        }
-                                                }
-                                        }
-                                        //删除顶替
-                                        log.Println("start", UpgradeBuyset.NewCitys, del_2_flag, del_1_flag)
-                                        index_flag := 0
-                                        for del_2_flag > 0 || del_1_flag > 0 {
-                                                valueFlag := UpgradeBuyset.NewCitys[index_flag]
-                                                if del_2_flag > 0 && valueFlag == 2 {
-                                                        UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys[:index_flag], UpgradeBuyset.NewCitys[index_flag+1:]...)
-                                                        del_2_flag--
-                                                        continue
-                                                } else if del_1_flag > 0 && valueFlag == 1 {
-                                                        UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys[:index_flag], UpgradeBuyset.NewCitys[index_flag+1:]...)
-                                                        del_1_flag--
-                                                        continue
-                                                }
-                                                index_flag++
-                                        }
-                                        log.Println("end", UpgradeBuyset.NewCitys, c_2_diff, c_1_diff)
-                                        //增加新增
-                                        for i := c_2_diff; i > 0; i-- { //添加购买两个市数量
-                                                UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys, 2)
-                                        }
+					//需要升级
+					AreaNeedUpgrade = true
+					//计算升级后的buySet
+					if p_Diff < 0 { //有剩余省份未使用
+						if c_2_diff > 0 {
+							c_2_diff += p_Diff //转移给两个市使用
+						} else {
+							c_1_diff += p_Diff //转移给一个市使用
+						}
+					} else { //省份数量增加
+						UpgradeBuyset.AreaCount = newBuySet.AreaCount
+					}
+					del_2_flag, del_1_flag := 0, 0 //被占用
+					if c_2_diff < 0 {              //有两个城市的名额未使用完
+						if p_Diff > 0 {
+							//转移给一个省使用
+							if c_2_diff+p_Diff > 0 {
+								del_2_flag += -c_2_diff
+								c_2_diff = 0
+								//p_Diff -= -c_2_diff;
+							} else {
+								c_2_diff += p_Diff
+								del_2_flag += p_Diff
+								//p_Diff = 0
+							}
+						}
+						if c_1_diff > 0 && c_2_diff < 0 { //转移给一个市使用
+							c_1_diff += c_2_diff
+						}
+					}
+					if c_1_diff < 0 { //有一个城市的名额未使用完
+						if p_Diff > 0 {
+							if c_1_diff+p_Diff > 0 {
+								del_1_flag += -c_1_diff
+								c_1_diff = 0
+								//p_Diff -= -c_1_diff
+							} else {
+								c_1_diff += p_Diff
+								del_1_flag += p_Diff
+								//p_Diff = 0
+							}
+						}
+						if c_2_diff > 0 && c_1_diff < 0 {
+							if c_1_diff+c_2_diff > 0 {
+								del_1_flag += -c_1_diff
+								c_1_diff = 0
+								//c_2_diff -= -c_1_diff;
+							} else {
+								c_1_diff += c_2_diff
+								del_1_flag += c_2_diff
+								//c_2_diff = 0
+							}
+						}
+					}
+					//删除顶替
+					log.Println("start", UpgradeBuyset.NewCitys, del_2_flag, del_1_flag)
+					index_flag := 0
+					for del_2_flag > 0 || del_1_flag > 0 {
+						valueFlag := UpgradeBuyset.NewCitys[index_flag]
+						if del_2_flag > 0 && valueFlag == 2 {
+							UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys[:index_flag], UpgradeBuyset.NewCitys[index_flag+1:]...)
+							del_2_flag--
+							continue
+						} else if del_1_flag > 0 && valueFlag == 1 {
+							UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys[:index_flag], UpgradeBuyset.NewCitys[index_flag+1:]...)
+							del_1_flag--
+							continue
+						}
+						index_flag++
+					}
+					log.Println("end", UpgradeBuyset.NewCitys, c_2_diff, c_1_diff)
+					//增加新增
+					for i := c_2_diff; i > 0; i-- { //添加购买两个市数量
+						UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys, 2)
+					}
 
-                                        for i := c_1_diff; i > 0; i-- { //添加购买一个市数量
-                                                UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys, 1)
-                                        }
-                                } else {
-                                        //不需要升级
-                                        AreaNeedUpgrade = false
-                                }
-                        }
-                }
-                if BuyerclassUpgrade || AreaNeedUpgrade {
-                        return true
-                } else {
-                        return false
-                }
-        } else {
-                //return newBuySet.AreaCount == -1 || newBuySet.AreaCount > oldBuySet.AreaCount
-                if oldBuySet.AreaCount != -1 {
-                        return newBuySet.AreaCount == -1 || newBuySet.AreaCount > oldBuySet.AreaCount
-                } else {
-                        return false
-                }
-        }
+					for i := c_1_diff; i > 0; i-- { //添加购买一个市数量
+						UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys, 1)
+					}
+				} else {
+					//不需要升级
+					AreaNeedUpgrade = false
+				}
+			}
+		}
+		if BuyerclassUpgrade || AreaNeedUpgrade {
+			return true
+		} else {
+			return false
+		}
+	} else {
+		//return newBuySet.AreaCount == -1 || newBuySet.AreaCount > oldBuySet.AreaCount
+		if oldBuySet.AreaCount != -1 {
+			return newBuySet.AreaCount == -1 || newBuySet.AreaCount > oldBuySet.AreaCount
+		} else {
+			return false
+		}
+	}
 }
 
 //超级订阅 订阅修改
 func VipSubChange(userId string, oldVip, areaNew *map[string]interface{}, industryNew []string, power, entUserId, entId int) bool {
-        updateOk := false
-        if power == 1 {
-                query := map[string]interface{}{
-                        "i_userid": entUserId,
-                        "i_entid":  entId,
-                        "i_type":   1,
-                }
-                updateOk = db.Mgo.Update("entniche_rule", query,
-                        map[string]interface{}{"$set": map[string]interface{}{
-                                "o_entniche.o_area":       areaNew,     //设置地区
-                                "o_entniche.a_buyerclass": industryNew, //设置行业
-                                "l_updatetime":            time.Now().Unix(),
-                        }}, true, false)
-        } else {
-                updateOk = db.Mgo.UpdateById("user", userId,
-                        map[string]interface{}{"$set": map[string]interface{}{
-                                "o_vipjy.o_area":       areaNew,     //设置地区
-                                "o_vipjy.a_buyerclass": industryNew, //设置行业
-                        }})
-        }
-        if !updateOk {
-                return false
-        } else {
-                //保存修改日志
-                go func() {
-                        db.Mgo_Log.Save("subvip_edit_log", map[string]interface{}{
-                                "s_userid":         userId,
-                                "o_area_old":       (*oldVip)["o_area"],
-                                "a_buyerclass_old": (*oldVip)["a_buyerclass"],
-                                "o_area":           areaNew,
-                                "a_buyerclass":     industryNew,
-                                "l_changeTime":     time.Now().Unix(),
-                        })
-                }()
-        }
-        return true
+	updateOk := false
+	if power == 1 {
+		query := map[string]interface{}{
+			"i_userid": entUserId,
+			"i_entid":  entId,
+			"i_type":   1,
+		}
+		updateOk = db.Mgo.Update("entniche_rule", query,
+			map[string]interface{}{"$set": map[string]interface{}{
+				"o_entniche.o_area":       areaNew,     //设置地区
+				"o_entniche.a_buyerclass": industryNew, //设置行业
+				"l_updatetime":            time.Now().Unix(),
+			}}, true, false)
+	} else {
+		updateOk = db.Mgo.UpdateById("user", userId,
+			map[string]interface{}{"$set": map[string]interface{}{
+				"o_vipjy.o_area":       areaNew,     //设置地区
+				"o_vipjy.a_buyerclass": industryNew, //设置行业
+			}})
+	}
+	if !updateOk {
+		return false
+	} else {
+		//保存修改日志
+		go func() {
+			db.Mgo_Log.Save("subvip_edit_log", map[string]interface{}{
+				"s_userid":         userId,
+				"o_area_old":       (*oldVip)["o_area"],
+				"a_buyerclass_old": (*oldVip)["a_buyerclass"],
+				"o_area":           areaNew,
+				"a_buyerclass":     industryNew,
+				"l_changeTime":     time.Now().Unix(),
+			})
+		}()
+	}
+	return true
 }
 
 //超级订阅 订阅修改
 func MemberSubChange(userId string, areaNew *map[string]interface{}, industryNew []string, power, entUserId, entId int) bool {
-        if power == 1 {
-                query := map[string]interface{}{
-                        "i_userid": entUserId,
-                        "i_entid":  entId,
-                        "i_type":   1,
-                }
-                if updateOk := db.Mgo.Update("entniche_rule", query,
-                        map[string]interface{}{"$set": map[string]interface{}{
-                                "o_entniche.o_area":       areaNew,     //设置地区
-                                "o_entniche.a_buyerclass": industryNew, //设置行业
-                                "l_updatetime":            time.Now().Unix(),
-                        }}, true, false); !updateOk {
-                        return false
-                }
-        } else {
-                if updateOk := db.Mgo.UpdateById("user", userId,
-                        map[string]interface{}{"$set": map[string]interface{}{
-                                "o_member_jy.o_area":       areaNew,     //设置地区
-                                "o_member_jy.a_buyerclass": industryNew, //设置行业
-                        }}); !updateOk {
-                        return false
-                }
-        }
+	if power == 1 {
+		query := map[string]interface{}{
+			"i_userid": entUserId,
+			"i_entid":  entId,
+			"i_type":   1,
+		}
+		if updateOk := db.Mgo.Update("entniche_rule", query,
+			map[string]interface{}{"$set": map[string]interface{}{
+				"o_entniche.o_area":       areaNew,     //设置地区
+				"o_entniche.a_buyerclass": industryNew, //设置行业
+				"l_updatetime":            time.Now().Unix(),
+			}}, true, false); !updateOk {
+			return false
+		}
+	} else {
+		if updateOk := db.Mgo.UpdateById("user", userId,
+			map[string]interface{}{"$set": map[string]interface{}{
+				"o_member_jy.o_area":       areaNew,     //设置地区
+				"o_member_jy.a_buyerclass": industryNew, //设置行业
+			}}); !updateOk {
+			return false
+		}
+	}
 
-        return true
+	return true
 }

+ 5 - 2
src/jfw/modules/publicapply/src/subscribePush/service/pushList.go

@@ -38,19 +38,22 @@ func (sp *SubscribePush) VipSwitch() {
 		if userId == "" {
 			return nil, fmt.Errorf("未登录")
 		}
+		baseUserId := util.Int64All(sp.GetSession("base_user_id"))
+		entId := util.Int64All(sp.GetSession("entId"))
+		accountId := util.Int64All(sp.GetSession("accountId"))
 		switchOk := false
 		vt := sp.GetString("vt")
 		if vt == "" {
 			vt = jy.SwitchService.GetEntniche(sp.Session(), db.Mgo, db.Mysql)
 		} else if vt == jy.SubVipFlag {
-			vipMsg := jy.GetBigVipUserBaseMsg(userId, db.Mysql, db.Mgo)
+			vipMsg := jy.GetBigVipUserBaseMsg("10000", userId, baseUserId, accountId, entId, config.Config.Etcd.Hosts, config.Config.Etcd.Key)
 			if vipMsg.VipStatus <= 0 {
 				return nil, fmt.Errorf("未购买超级订阅")
 			}
 			sp.SetSession(jy.SwitchService.SessionKey, jy.SwitchService.Vip)
 			switchOk = true
 		} else if vt == jy.MemberFlag {
-			vipMsg := jy.GetBigVipUserBaseMsg(userId, db.Mysql, db.Mgo)
+			vipMsg := jy.GetBigVipUserBaseMsg("10000", userId, baseUserId, accountId, entId, config.Config.Etcd.Hosts, config.Config.Etcd.Key)
 			if vipMsg.Status <= 0 {
 				return nil, fmt.Errorf("未购买大会员")
 			}

+ 103 - 93
src/jfw/modules/publicapply/src/subscribePush/service/subscribe.go

@@ -1,108 +1,118 @@
 package service
 
 import (
-        qutil "app.yhyue.com/moapp/jybase/common"
-        "app.yhyue.com/moapp/jybase/go-xweb/xweb"
-        "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
-        "jy/src/jfw/modules/publicapply/src/db"
-        "jy/src/jfw/modules/publicapply/src/subscribePush/entity"
-        "log"
-        "strings"
+	qutil "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"jy/src/jfw/modules/publicapply/src/db"
+	"jy/src/jfw/modules/publicapply/src/subscribePush/entity"
+	"log"
+	"strings"
 )
 
 type Subscribe struct {
-        *xweb.Action
-        update      xweb.Mapper `xweb:"/subscribe/update"`      //订阅修改
-        setUserInfo xweb.Mapper `xweb:"/subscribe/setUserInfo"` //各种修改【关键词、关键词匹配方式、信息类型、项目匹配】
+	*xweb.Action
+	update      xweb.Mapper `xweb:"/subscribe/update"`      //订阅修改
+	setUserInfo xweb.Mapper `xweb:"/subscribe/setUserInfo"` //各种修改【关键词、关键词匹配方式、信息类型、项目匹配】
 }
 
 // 大会员、超级订阅订阅修改
 func (s *Subscribe) Update() {
-        userId := qutil.ObjToString(s.GetSession("userId"))
-        ent_id := qutil.IntAll(s.GetSession("entId"))
-        entUserId := qutil.IntAll(s.GetSession("entUserId"))
-        vSwitch := s.GetString("vSwitch")
-        if vSwitch == "" {
-                vSwitch = jy.SwitchService.Get(s.Session(), db.Mgo) //v:vip m:member
-        }
-        sub := &entity.SubscribeSet{
-                Area:      *qutil.ObjToMap(s.GetString("area")),
-                Industry:  strings.Split(s.GetString("industry"), ","),
-                UserId:    userId,
-                Type:      vSwitch,
-                EntId:     ent_id,
-                EntUserId: entUserId,
-        }
-        r := sub.SetAreaAndIndustry()
-        if r.Err != nil {
-                log.Printf("%s SaveChange err:%v\n", userId, r.Err.Error())
-        }
-        s.ServeJson(r.Format())
+	userId := qutil.ObjToString(s.GetSession("userId"))
+	ent_id := qutil.IntAll(s.GetSession("entId"))
+	entUserId := qutil.IntAll(s.GetSession("entUserId"))
+	baseUserId := qutil.Int64All(s.GetSession("base_user_id"))
+	accountId := qutil.Int64All(s.GetSession("accountId"))
+	vSwitch := s.GetString("vSwitch")
+	if vSwitch == "" {
+		vSwitch = jy.SwitchService.Get(s.Session(), db.Mgo) //v:vip m:member
+	}
+	sub := &entity.SubscribeSet{
+		Area:       *qutil.ObjToMap(s.GetString("area")),
+		Industry:   strings.Split(s.GetString("industry"), ","),
+		UserId:     userId,
+		Type:       vSwitch,
+		EntId:      ent_id,
+		EntUserId:  entUserId,
+		AccountId:  accountId,
+		BaseUserId: baseUserId,
+	}
+	r := sub.SetAreaAndIndustry()
+	if r.Err != nil {
+		log.Printf("%s SaveChange err:%v\n", userId, r.Err.Error())
+	}
+	s.ServeJson(r.Format())
 }
 
 //关键词、关键词匹配方式、信息类型、项目匹配
 func (s *Subscribe) SetUserInfo() {
-        r := map[string]interface{}{}
-        userId := qutil.ObjToString(s.GetSession("userId"))
-        entId := qutil.IntAll(s.GetSession("entId"))
-        entUserId := qutil.IntAll(s.GetSession("entUserId"))
-        vSwitch := s.GetString("vSwitch")
-        if vSwitch == "" {
-                vSwitch = jy.SwitchService.Get(s.Session(), db.Mgo) //v:vip m:member "":free
-        }
-        //判断是否有权限
-        power := 0
-        if entId > 0 {
-                if vSwitch == "v" {
-                        infoCount := db.Mysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and  product_type like '%VIP订阅%' ", entId)
-                        if infoCount > 0 {
-                                power = 1
-                        }
-                } else if vSwitch == "m" {
-                        infoCount := db.Mysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and  product_type like '%大会员%' ", entId)
-                        if infoCount > 0 {
-                                power = 1
-                        }
-                }
-        }
-        if pageType := s.GetString("pageType"); pageType == "keyWords" {
-                //
-                match_way, _ := s.GetInteger("match_way")
-                sub := &entity.KeyWordsSet{
-                        ClassifyIndex: s.GetString("classify_index"),
-                        ClassifyName:  strings.Trim(s.GetString("classify_name"), ""),
-                        KeyWordIndex:  s.GetString("kws_index"),
-                        KeyWordName:   strings.Trim(s.GetString("kws_name"), ""),
-                        ActionType:    s.GetString("actionType"),
-                        AppendKeyWord: s.GetSlice("addition_kws"),
-                        NotKeyWord:    s.GetSlice("not_kws"),
-                        MatchWay:      match_way,
-                        KeyWordsCount: s.GetString("kwscount"),
-                        Type:          vSwitch,
-                        UserId:        userId,
-                        DeleteKey:     s.GetString("delete_key"),
-                        Power:         power,
-                        EntUserId:     entUserId,
-                        EntId:         entId,
-                }
-                r = sub.UpdateKeyWords()
-        } else {
-                pmindex, _ := s.GetInteger("pmindex")
-                matchtype, _ := s.GetInteger("matchtype")
-                other, _ := s.GetInteger("other")
-                uo := &entity.UpdateOther{
-                        PageType:        s.GetString("pageType"),
-                        Pmindex:         pmindex,
-                        InfoTypeArr:     s.GetString("infoTypeArr"),
-                        Matchtype:       matchtype,
-                        UserId:          userId,
-                        Type:            vSwitch,
-                        OtherBuyerclass: other,
-                        Power:           power,
-                        EntUserId:       entUserId,
-                        EntId:           entId,
-                }
-                r = uo.UpdateOther()
-        }
-        s.ServeJson(r)
+	r := map[string]interface{}{}
+	userId := qutil.ObjToString(s.GetSession("userId"))
+	entId := qutil.IntAll(s.GetSession("entId"))
+	entUserId := qutil.IntAll(s.GetSession("entUserId"))
+	baseUserId := qutil.Int64All(s.GetSession("base_user_id"))
+	accountId := qutil.Int64All(s.GetSession("accountId"))
+	vSwitch := s.GetString("vSwitch")
+	if vSwitch == "" {
+		vSwitch = jy.SwitchService.Get(s.Session(), db.Mgo) //v:vip m:member "":free
+	}
+	//判断是否有权限
+	power := 0
+	if entId > 0 {
+		if vSwitch == "v" {
+			infoCount := db.Mysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and  product_type like '%VIP订阅%' ", entId)
+			if infoCount > 0 {
+				power = 1
+			}
+		} else if vSwitch == "m" {
+			infoCount := db.Mysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and  product_type like '%大会员%' ", entId)
+			if infoCount > 0 {
+				power = 1
+			}
+		}
+	}
+	if pageType := s.GetString("pageType"); pageType == "keyWords" {
+		//
+		match_way, _ := s.GetInteger("match_way")
+		sub := &entity.KeyWordsSet{
+			ClassifyIndex: s.GetString("classify_index"),
+			ClassifyName:  strings.Trim(s.GetString("classify_name"), ""),
+			KeyWordIndex:  s.GetString("kws_index"),
+			KeyWordName:   strings.Trim(s.GetString("kws_name"), ""),
+			ActionType:    s.GetString("actionType"),
+			AppendKeyWord: s.GetSlice("addition_kws"),
+			NotKeyWord:    s.GetSlice("not_kws"),
+			MatchWay:      match_way,
+			KeyWordsCount: s.GetString("kwscount"),
+			Type:          vSwitch,
+			UserId:        userId,
+			DeleteKey:     s.GetString("delete_key"),
+			Power:         power,
+			EntUserId:     entUserId,
+			EntId:         entId,
+			AccountId:     accountId,
+			BaseUserId:    baseUserId,
+		}
+		r = sub.UpdateKeyWords()
+	} else {
+		pmindex, _ := s.GetInteger("pmindex")
+		matchtype, _ := s.GetInteger("matchtype")
+		other, _ := s.GetInteger("other")
+		uo := &entity.UpdateOther{
+			PageType:        s.GetString("pageType"),
+			Pmindex:         pmindex,
+			InfoTypeArr:     s.GetString("infoTypeArr"),
+			Matchtype:       matchtype,
+			UserId:          userId,
+			Type:            vSwitch,
+			OtherBuyerclass: other,
+			Power:           power,
+			EntUserId:       entUserId,
+			EntId:           entId,
+			AccountId:       accountId,
+			BaseUserId:      baseUserId,
+		}
+		r = uo.UpdateOther()
+	}
+	s.ServeJson(r)
 }

+ 20 - 14
src/jfw/modules/publicapply/src/userbase/entity/entity.go

@@ -18,9 +18,12 @@ import (
 )
 
 type UserInfo struct {
-	UserId   string //用户id
-	Platform string //平台 PC WX APP
-	Names    string //功能名称
+	UserId     string //用户id
+	Platform   string //平台 PC WX APP
+	Names      string //功能名称
+	BaseUserId int64
+	AccountId  int64
+	EntId      int64
 }
 
 type FuncNames struct {
@@ -29,11 +32,11 @@ type FuncNames struct {
 	Img  string `json:"img"`
 }
 
-func NewUserInfo(userId, platform, names string) *UserInfo {
+func NewUserInfo(userId, platform, names string, baseUserId, accountId, entId int64) *UserInfo {
 	if platform == "" {
 		platform = "PC"
 	}
-	return &UserInfo{userId, platform, names}
+	return &UserInfo{userId, platform, names, baseUserId, accountId, entId}
 }
 
 //保存
@@ -45,7 +48,7 @@ func (this *UserInfo) SaveNameByUserId() bool {
 	var namesarr = []string{}
 	if this.Names != "" {
 		for _, v := range strings.Split(this.Names, ",") {
-			if !ChargeMap[v] || IsPower(v, this.UserId) {
+			if !ChargeMap[v] || IsPower(v, this.UserId, this.BaseUserId, this.AccountId, this.EntId) {
 				namesarr = append(namesarr, v)
 			}
 		}
@@ -91,7 +94,7 @@ func (this *UserInfo) GetNameByUserId() (fns []*FuncNames) {
 	} else {
 		for _, v := range BaseFuncInfo.CommonFunctions {
 			if v.Isbase {
-				if v.Name == "订阅管理" && !IsPower(v.Name, this.UserId) {
+				if v.Name == "订阅管理" && !IsPower(v.Name, this.UserId, this.BaseUserId, this.AccountId, this.EntId) {
 					continue
 				}
 				fns = append(fns, &FuncNames{
@@ -114,7 +117,7 @@ var ChargeMap = map[string]bool{}
 func (this *UserInfo) AllNames() (fns []*FuncNames) {
 	for _, v := range BaseFuncInfo.CommonFunctions {
 		ChargeMap[v.Name] = v.Charge
-		if !v.Charge || IsPower(v.Name, this.UserId) {
+		if !v.Charge || IsPower(v.Name, this.UserId, this.BaseUserId, this.AccountId, this.EntId) {
 			fns = append(fns, &FuncNames{
 				Name: v.Name,
 				Url:  thisByPlat(this.Platform, "url", &v),
@@ -154,8 +157,8 @@ func thisByPlat(platform, name string, bcv *initjson.BaseFunc) (res string) {
 }
 
 //查看是否有使用此功能的权限
-func IsPower(name, userId string) (b bool) {
-	BigPower := jy.GetBigVipUserBaseMsg(userId, db.Mysql, db.Mgo)
+func IsPower(name, userId string, baseUserId, accountId, entId int64) (b bool) {
+	BigPower := jy.GetBigVipUserBaseMsg("10000", userId, baseUserId, accountId, entId, config.Config.Etcd.Hosts, config.Config.Etcd.Key)
 	if BigPower.Status > 0 {
 		switch name {
 		case "企业情报监控":
@@ -266,9 +269,12 @@ func SellerTokenDecrypt(token string) (uId, sName string, sid int, desc map[stri
 
 //用户一次性弹窗信息集合
 type TipInfoStruct struct {
-	UserId  string
-	DoType  string
-	TipName string
+	UserId     string
+	DoType     string
+	TipName    string
+	BaseUserId int64
+	AccountId  int64
+	EntId      int64
 }
 
 //
@@ -295,7 +301,7 @@ func (this *TipInfoStruct) GetTipInfo() (flag bool) {
 	} else { //查询是否提示弹框
 		//判断是否严重用户注册时间
 		if config.Config.TipInfo[this.TipName] > 0 {
-			userBase := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo)
+			userBase := jy.GetBigVipUserBaseMsg("10000", this.UserId, this.BaseUserId, this.AccountId, util.Int64All(this.EntId), config.Config.Etcd.Hosts, config.Config.Etcd.Key)
 			//此时间点后注册的新用户
 			if userBase.Registedate > config.Config.TipInfo[this.TipName] {
 				return true

+ 7 - 4
src/jfw/modules/publicapply/src/userbase/entity/menu.go

@@ -5,11 +5,14 @@ import (
 )
 
 type MenuInfoStruct struct {
-	UserId string `json:"userId"`
+	UserId     string `json:"userId"`
+	BaseUserId int64  `json:"baseUserId"`
+	EntId      int64  `json:"entId"`
+	AccountId  int64  `json:"accountId"`
 }
 
-func NewMenuInfo(userId string) *MenuInfoStruct {
-	return &MenuInfoStruct{userId}
+func NewMenuInfo(userId string, baseUserId, accountId, entId int64) *MenuInfoStruct {
+	return &MenuInfoStruct{userId, baseUserId, accountId, entId}
 }
 
 //大会员菜单
@@ -25,7 +28,7 @@ func (this *MenuInfoStruct) GetMenuInfo() (menus []*initjson.MenuLevel) {
 				Isusable: mv.Isusable,
 			}
 			if !msll.Isusable {
-				if IsPower(msll.Name, this.UserId) {
+				if IsPower(msll.Name, this.UserId, this.BaseUserId, this.AccountId, this.EntId) {
 					msll.Isusable = true
 				} else {
 					//子账号 隐藏订阅管理

+ 26 - 8
src/jfw/modules/publicapply/src/userbase/service/service.go

@@ -11,15 +11,18 @@ import (
 //大会员菜单
 func (this *ServiceStruct) BigmemberMenu() {
 	userId, _ := this.GetSession("userId").(string)
+	baseUserId := qu.Int64All(this.GetSession("base_user_id"))
+	entId := qu.Int64All(this.GetSession("entId"))
+	accountId := qu.Int64All(this.GetSession("accountId"))
 	defer qu.Catch()
 	r := func() Result {
 		if this.Method() != "POST" {
 			return Result{Data: nil, Error_msg: Error_msg_1005}
 		}
-		if !entity.IsPower("", userId) {
+		if !entity.IsPower("", userId, baseUserId, accountId, entId) {
 			return Result{Data: nil, Error_msg: Error_msg_1004}
 		}
-		newMenu := entity.NewMenuInfo(userId)
+		newMenu := entity.NewMenuInfo(userId, baseUserId, accountId, entId)
 		return Result{Data: newMenu.GetMenuInfo()}
 	}()
 	this.ServeJson(r)
@@ -30,13 +33,16 @@ func (this *ServiceStruct) AllFunctions() {
 	userId, _ := this.GetSession("userId").(string)
 	defer qu.Catch()
 	r := func() Result {
+		baseUserId := qu.Int64All(this.GetSession("base_user_id"))
+		entId := qu.Int64All(this.GetSession("entId"))
+		accountId := qu.Int64All(this.GetSession("accountId"))
 		if this.Method() != "POST" {
 			return Result{Data: nil, Error_msg: Error_msg_1005}
 		}
-		if !entity.IsPower("", userId) {
+		if !entity.IsPower("", userId, baseUserId, accountId, entId) {
 			return Result{Data: nil, Error_msg: Error_msg_1004}
 		}
-		newFN := entity.NewUserInfo(userId, "", "")
+		newFN := entity.NewUserInfo(userId, "", "", baseUserId, accountId, entId)
 		return Result{Data: newFN.AllNames()}
 	}()
 	this.ServeJson(r)
@@ -47,15 +53,18 @@ func (this *ServiceStruct) SaveFunctions() {
 	userId, _ := this.GetSession("userId").(string)
 	defer qu.Catch()
 	r := func() Result {
+		baseUserId := qu.Int64All(this.GetSession("base_user_id"))
+		entId := qu.Int64All(this.GetSession("entId"))
+		accountId := qu.Int64All(this.GetSession("accountId"))
 		if this.Method() != "POST" {
 			return Result{Data: nil, Error_msg: Error_msg_1005}
 		}
 		names := this.GetString("names")
-		if !entity.IsPower("", userId) {
+		if !entity.IsPower("", userId, baseUserId, accountId, entId) {
 			return Result{Data: nil, Error_msg: Error_msg_1004}
 		}
 		platform := this.GetString("platform")
-		newFN := entity.NewUserInfo(userId, platform, names)
+		newFN := entity.NewUserInfo(userId, platform, names, baseUserId, accountId, entId)
 		return Result{Data: newFN.SaveNameByUserId()}
 	}()
 	this.ServeJson(r)
@@ -66,14 +75,17 @@ func (this *ServiceStruct) UbFunctions() {
 	userId, _ := this.GetSession("userId").(string)
 	defer qu.Catch()
 	r := func() Result {
+		baseUserId := qu.Int64All(this.GetSession("base_user_id"))
+		entId := qu.Int64All(this.GetSession("entId"))
+		accountId := qu.Int64All(this.GetSession("accountId"))
 		if this.Method() != "POST" {
 			return Result{Data: nil, Error_msg: Error_msg_1005}
 		}
-		if !entity.IsPower("", userId) {
+		if !entity.IsPower("", userId, baseUserId, accountId, entId) {
 			return Result{Data: nil, Error_msg: Error_msg_1004}
 		}
 		platform := this.GetString("platform")
-		newFN := entity.NewUserInfo(userId, platform, "")
+		newFN := entity.NewUserInfo(userId, platform, "", baseUserId, accountId, entId)
 		return Result{Data: newFN.GetNameByUserId()}
 	}()
 	this.ServeJson(r)
@@ -108,6 +120,9 @@ func (this *ServiceStruct) TipInfo() {
 	userId, _ := this.GetSession("userId").(string)
 	defer qu.Catch()
 	r := func() Result {
+		baseUserId := qu.Int64All(this.GetSession("base_user_id"))
+		entId := qu.Int64All(this.GetSession("entId"))
+		accountId := qu.Int64All(this.GetSession("accountId"))
 		if this.Method() != "POST" {
 			return Result{Data: nil, Error_msg: Error_msg_1005}
 		}
@@ -115,6 +130,9 @@ func (this *ServiceStruct) TipInfo() {
 		if tipInfo.TipName == "" {
 			return Result{Data: nil, Error_msg: Error_msg_1002}
 		}
+		tipInfo.EntId = entId
+		tipInfo.AccountId = accountId
+		tipInfo.BaseUserId = baseUserId
 		return Result{Data: tipInfo.GetTipInfo()}
 	}()
 	this.ServeJson(r)

Some files were not shown because too many files changed in this diff