Kaynağa Gözat

数据库修改

WH01243 2 yıl önce
ebeveyn
işleme
15859257b8

+ 24 - 26
jyBXBase/entity/db.go

@@ -1,49 +1,47 @@
 package entity
 
 type Mongo struct {
-	Main    *MongoStruct `json:"main,optional"`
-	MgoLog  *MongoStruct `json:"mgoLog,optional"`
-	Ent     *MongoStruct `json:"ent,optional"`
-	Bidding *MongoStruct `json:"bidding,optional"`
+      Main    *MongoStruct `json:"main,optional"`
+      MgoLog  *MongoStruct `json:"mgoLog,optional"`
+      Ent     *MongoStruct `json:"ent,optional"`
+      Bidding *MongoStruct `json:"bidding,optional"`
 }
 
 //
 type MongoStruct struct {
-	Address        string `json:"address"`
-	Size           int    `json:"size"`
-	DbName         string `json:"dbName"`
-	UserName       string `json:"userName,optional"`
-	Password       string `json:"password,optional"`
-	Collection     string `json:"collection,optional"`
-	CollectionBack string `json:"collectionBack,optional"`
-	MaxOpenConns   int    `json:"maxOpenConns,optional"`
-	MaxIdleConns   int    `json:"maxIdleConns,optional"`
+      Address        string `json:"address"`
+      Size           int    `json:"size"`
+      DbName         string `json:"dbName"`
+      UserName       string `json:"userName,optional"`
+      Password       string `json:"password,optional"`
+      Collection     string `json:"collection,optional"`
+      CollectionBack string `json:"collectionBack,optional"`
+      MaxOpenConns   int    `json:"maxOpenConns,optional"`
+      MaxIdleConns   int    `json:"maxIdleConns,optional"`
 }
 
 type Mysql struct {
-	Main         *MysqlStruct `json:"main,optional"`
-	Push         *MysqlStruct `json:"push,optional"`
-	MemberPush   *MysqlStruct `json:"memberPush"`
-	EntnichePush *MysqlStruct `json:"entnichePush"`
+      Main        *MysqlStruct `json:"main,optional"`
+      BaseService *MysqlStruct `json:"baseService,omitempty"`
 }
 
 //mysql
 type MysqlStruct struct {
-	DbName       string `json:"dbName,optional"`
-	Address      string `json:"address,optional"`
-	UserName     string `json:"userName,optional"`
-	Password     string `json:"password,optional"`
-	MaxOpenConns int    `json:"maxOpenConns,optional"`
-	MaxIdleConns int    `json:"maxIdleConns,optional"`
+      DbName       string `json:"dbName,optional"`
+      Address      string `json:"address,optional"`
+      UserName     string `json:"userName,optional"`
+      Password     string `json:"password,optional"`
+      MaxOpenConns int    `json:"maxOpenConns,optional"`
+      MaxIdleConns int    `json:"maxIdleConns,optional"`
 }
 
 //redis
 type RedisStuct struct {
-	Addr []string `json:"addr"`
+      Addr []string `json:"addr"`
 }
 
 //es
 type EsStruct struct {
-	Addr string `json:"addr"`
-	Size int    `json:"size"`
+      Addr string `json:"addr"`
+      Size int    `json:"size"`
 }

+ 4 - 18
jyBXBase/rpc/etc/db.yaml

@@ -6,25 +6,11 @@ mysql:
         password: Topnet123
         maxOpenConns: 5
         maxIdleConns: 5
-    push:
-        dbName: jianyu
-        address: 192.168.3.11:3366
-        userName: root
-        password: Topnet123
-        maxOpenConns: 5
-        maxIdleConns: 5
-    memberPush:
-        dbName: jianyu
-        address: 192.168.3.11:3366
+    baseService:
+        dbName: base_service
+        address: 192.168.3.217:4000
         userName: root
-        password: Topnet123
-        maxOpenConns: 5
-        maxIdleConns: 5
-    entnichePush:
-        dbName: jianyu
-        address: 192.168.3.11:3366
-        userName: root
-        password: Topnet123
+        password: '=PDT49#80Z!RVv52_z'
         maxOpenConns: 5
         maxIdleConns: 5
 redis:

+ 82 - 110
jyBXBase/rpc/init/db.go

@@ -4,135 +4,107 @@
 package init
 
 import (
-	"github.com/zeromicro/go-zero/core/logx"
-	"strings"
+      "github.com/zeromicro/go-zero/core/logx"
+      "strings"
 
-	"jyBXBase/entity"
+      "jyBXBase/entity"
 
-	"app.yhyue.com/moapp/jybase/esv1"
-	"app.yhyue.com/moapp/jybase/mongodb"
-	"app.yhyue.com/moapp/jybase/mysql"
-	"app.yhyue.com/moapp/jybase/redis"
+      "app.yhyue.com/moapp/jybase/esv1"
+      "app.yhyue.com/moapp/jybase/mongodb"
+      "app.yhyue.com/moapp/jybase/mysql"
+      "app.yhyue.com/moapp/jybase/redis"
 )
 
 var (
-	MainMysql          *mysql.Mysql
-	PushMysql          *mysql.Mysql
-	BigmemberPushMysql *mysql.Mysql
-	EntnichePushMysql  *mysql.Mysql
-	Mgo                mongodb.MongodbSim
-	MgoEnt             mongodb.MongodbSim
-	MgoBidding         mongodb.MongodbSim
+      MainMysql        *mysql.Mysql
+      BaseServiceMysql *mysql.Mysql
+      Mgo              mongodb.MongodbSim
+      MgoEnt           mongodb.MongodbSim
+      MgoBidding       mongodb.MongodbSim
 )
 
 //
 func MongoDBInit(em *entity.Mongo) {
-	//初始化 mongodb
-	if em.Main.Address != "" {
-		logx.Info("--初始化 mongodb--")
-		Mgo = mongodb.MongodbSim{
-			MongodbAddr: em.Main.Address,
-			Size:        em.Main.Size,
-			DbName:      em.Main.DbName,
-		}
-		Mgo.InitPool()
-	}
-	//
-	if em.Bidding.Address != "" {
-		logx.Info("--初始化 mongodb bidding--")
-		MgoBidding = mongodb.MongodbSim{
-			MongodbAddr: em.Bidding.Address,
-			Size:        em.Bidding.Size,
-			DbName:      em.Bidding.DbName,
-			UserName:    em.Bidding.UserName,
-			Password:    em.Bidding.Password,
-		}
-		MgoBidding.InitPool()
-	}
-	//
-	if em.Ent.Address != "" {
-		logx.Info("--初始化 mongodb ent--")
-		MgoEnt = mongodb.MongodbSim{
-			MongodbAddr: em.Ent.Address,
-			Size:        em.Ent.Size,
-			DbName:      em.Ent.DbName,
-			UserName:    em.Ent.UserName,
-			Password:    em.Ent.Password,
-		}
-		MgoEnt.InitPool()
-	}
+      //初始化 mongodb
+      if em.Main.Address != "" {
+	  logx.Info("--初始化 mongodb--")
+	  Mgo = mongodb.MongodbSim{
+	        MongodbAddr: em.Main.Address,
+	        Size:        em.Main.Size,
+	        DbName:      em.Main.DbName,
+	  }
+	  Mgo.InitPool()
+      }
+      //
+      if em.Bidding.Address != "" {
+	  logx.Info("--初始化 mongodb bidding--")
+	  MgoBidding = mongodb.MongodbSim{
+	        MongodbAddr: em.Bidding.Address,
+	        Size:        em.Bidding.Size,
+	        DbName:      em.Bidding.DbName,
+	        UserName:    em.Bidding.UserName,
+	        Password:    em.Bidding.Password,
+	  }
+	  MgoBidding.InitPool()
+      }
+      //
+      if em.Ent.Address != "" {
+	  logx.Info("--初始化 mongodb ent--")
+	  MgoEnt = mongodb.MongodbSim{
+	        MongodbAddr: em.Ent.Address,
+	        Size:        em.Ent.Size,
+	        DbName:      em.Ent.DbName,
+	        UserName:    em.Ent.UserName,
+	        Password:    em.Ent.Password,
+	  }
+	  MgoEnt.InitPool()
+      }
 }
 
 //
 func MysqlInit(em *entity.Mysql) {
-	//初始化 mysql-main
-	if em.Main.Address != "" {
-		logx.Info("--初始化 main mysql--")
-		MainMysql = &mysql.Mysql{
-			Address:      em.Main.Address,
-			UserName:     em.Main.UserName,
-			PassWord:     em.Main.Password,
-			DBName:       em.Main.DbName,
-			MaxOpenConns: em.Main.MaxOpenConns,
-			MaxIdleConns: em.Main.MaxIdleConns,
-		}
-		MainMysql.Init()
-	}
-	//初始化 mysql-push
-	if em.Push.Address != "" {
-		logx.Info("--初始化 push mysql--")
-		PushMysql = &mysql.Mysql{
-			Address:      em.Push.Address,
-			UserName:     em.Push.UserName,
-			PassWord:     em.Push.Password,
-			DBName:       em.Push.DbName,
-			MaxOpenConns: em.Push.MaxOpenConns,
-			MaxIdleConns: em.Push.MaxIdleConns,
-		}
-		PushMysql.Init()
-	}
-	//初始化 mysql-大会员
-	if em.MemberPush.Address != "" {
-		logx.Info("--初始化 MemberPush mysql--")
-		BigmemberPushMysql = &mysql.Mysql{
-			Address:      em.MemberPush.Address,
-			UserName:     em.MemberPush.UserName,
-			PassWord:     em.MemberPush.Password,
-			DBName:       em.MemberPush.DbName,
-			MaxOpenConns: em.MemberPush.MaxOpenConns,
-			MaxIdleConns: em.MemberPush.MaxIdleConns,
-		}
-		BigmemberPushMysql.Init()
-	}
-	//初始化 mysql-商机管理
-	if em.EntnichePush.Address != "" {
-		logx.Info("--初始化 EntnichePush mysql--")
-		EntnichePushMysql = &mysql.Mysql{
-			Address:      em.EntnichePush.Address,
-			UserName:     em.EntnichePush.UserName,
-			PassWord:     em.EntnichePush.Password,
-			DBName:       em.EntnichePush.DbName,
-			MaxOpenConns: em.EntnichePush.MaxOpenConns,
-			MaxIdleConns: em.EntnichePush.MaxIdleConns,
-		}
-		EntnichePushMysql.Init()
-	}
+      //初始化 mysql-main
+      if em.Main.Address != "" {
+	  logx.Info("--初始化 main mysql--")
+	  MainMysql = &mysql.Mysql{
+	        Address:      em.Main.Address,
+	        UserName:     em.Main.UserName,
+	        PassWord:     em.Main.Password,
+	        DBName:       em.Main.DbName,
+	        MaxOpenConns: em.Main.MaxOpenConns,
+	        MaxIdleConns: em.Main.MaxIdleConns,
+	  }
+	  MainMysql.Init()
+      }
+      //初始化 mysql-BaseService
+      if em.BaseService.Address != "" {
+	  logx.Info("--初始化 推送 mysql--")
+	  BaseServiceMysql = &mysql.Mysql{
+	        Address:      em.BaseService.Address,
+	        UserName:     em.BaseService.UserName,
+	        PassWord:     em.BaseService.Password,
+	        DBName:       em.BaseService.DbName,
+	        MaxOpenConns: em.BaseService.MaxOpenConns,
+	        MaxIdleConns: em.BaseService.MaxIdleConns,
+	  }
+	  BaseServiceMysql.Init()
+      }
 }
 
 //
 func RedisInit(rm *entity.RedisStuct) {
-	//初始化 redis
-	if len(rm.Addr) > 0 {
-		logx.Info("--初始化 redis--")
-		redis.InitRedisBySize(strings.Join(rm.Addr, ","), 100, 30, 300)
-	}
+      //初始化 redis
+      if len(rm.Addr) > 0 {
+	  logx.Info("--初始化 redis--")
+	  redis.InitRedisBySize(strings.Join(rm.Addr, ","), 100, 30, 300)
+      }
 }
 
 //
 func EsInit(es *entity.EsStruct) {
-	//初始化 elasticsearch
-	if es.Addr != "" {
-		logx.Info("--初始化 elasticsearch--")
-		elastic.InitElasticSize(es.Addr, es.Size)
-	}
+      //初始化 elasticsearch
+      if es.Addr != "" {
+	  logx.Info("--初始化 elasticsearch--")
+	  elastic.InitElasticSize(es.Addr, es.Size)
+      }
 }

+ 6 - 8
jyBXBase/rpc/init/init.go

@@ -1,12 +1,10 @@
 package init
 
 import (
-	"flag"
-	_ "github.com/go-sql-driver/mysql"
-	"github.com/zeromicro/go-zero/core/conf"
-	"github.com/zeromicro/go-zero/core/logx"
-	"jyBXBase/entity"
-	"jyBXBase/rpc/internal/config"
+      "flag"
+      _ "github.com/go-sql-driver/mysql"
+      "jyBXBase/entity"
+      "jyBXBase/rpc/internal/config"
 )
 
 var configFile = flag.String("cf", "etc/bxbase.yaml", "the config file")
@@ -22,7 +20,7 @@ var logFile = flag.String("lf", "etc/logs.yaml", "the logs file")
 var logc entity.Logc
 
 func init() {
-	//基本配置
+	/*//基本配置
 	conf.MustLoad(*configFile, &C)
 	//数据库配置
 	conf.MustLoad(*dbFile, &DB)
@@ -46,5 +44,5 @@ func init() {
 			})
 			logx.Info(v, "--日志记录")
 		}
-	}
+	}*/
 }

+ 1 - 1
jyBXBase/rpc/internal/logic/labelactionlogic.go

@@ -155,7 +155,7 @@ func (l *LabelActionLogic) LabelAction(in *bxbase.LabelActionReq) (*bxbase.Label
 				log.Println("updatesql:", updatesql)
 				_, errs := IC.MainMysql.ExecBySql(updatesql, updateValue...)
 				if errs != nil {
-					log.Println("更新、绑定标签失败%s", in.UserId, updateValue)
+					log.Println("更新、绑定标签失败", in.UserId, updateValue)
 				}
 			}
 			if len(insertValue) > 0 {

+ 122 - 0
jyBXBase/rpc/internal/logic/newestbiddinglogic_test.go

@@ -0,0 +1,122 @@
+package logic
+
+import (
+      elastic "app.yhyue.com/moapp/jybase/esv1"
+      "app.yhyue.com/moapp/jybase/mongodb"
+      "app.yhyue.com/moapp/jybase/mysql"
+      "app.yhyue.com/moapp/jybase/redis"
+      "context"
+      "github.com/zeromicro/go-zero/core/logx"
+      "jyBXBase/entity"
+      "jyBXBase/rpc/bxbase"
+      IC "jyBXBase/rpc/init"
+      "jyBXBase/rpc/internal/config"
+      "jyBXBase/rpc/internal/svc"
+      "reflect"
+      "strings"
+      "testing"
+)
+func init() {
+
+      logx.Info("--初始化 mongodb--")
+      IC.Mgo = mongodb.MongodbSim{
+	  MongodbAddr: "192.168.3.206:27080",
+	  Size:        5,
+	  DbName:      "qfw",
+      }
+      IC.Mgo.InitPool()
+      IC.DB = config.Db{Mongo: entity.Mongo{
+	  Bidding: &entity.MongoStruct{
+	        Collection:     "bidding",
+	        CollectionBack: "bidding_back",
+	  },
+      }}
+      IC.DB.Mongo.Bidding.Collection = "bidding_back"
+      //
+      logx.Info("--初始化 mongodb bidding--")
+      IC.MgoBidding = mongodb.MongodbSim{
+	  MongodbAddr: "192.168.3.206:27001",
+	  Size:        5,
+	  DbName:      "qfw_data",
+	  UserName:    "jyDevGroup",
+	  Password:    "jy@DevGroup",
+      }
+      IC.MgoBidding.InitPool()
+
+      logx.Info("--初始化 mysql--")
+      IC.MainMysql = &mysql.Mysql{
+	  Address:      "192.168.3.11:3366",
+	  UserName:     "root",
+	  PassWord:     "Topnet123",
+	  DBName:       "jianyu",
+	  MaxOpenConns: 5,
+	  MaxIdleConns: 5,
+      }
+      IC.MainMysql.Init()
+
+      //初始化 mysql-EntnichePush
+      logx.Info("--初始化 商机管理推送 mysql--")
+      IC.BaseServiceMysql = &mysql.Mysql{
+	  Address:      "192.168.3.217:4000",
+	  UserName:     "root",
+	  PassWord:     "=PDT49#80Z!RVv52_z",
+	  DBName:       "base_service",
+	  MaxOpenConns: 5,
+	  MaxIdleConns: 5,
+      }
+      IC.BaseServiceMysql.Init()
+
+      logx.Info("--初始化 redis--")
+      redis.InitRedisBySize(strings.Join([]string{"other=192.168.3.206:1712", "push=192.168.3.206:1712", "pushcache_1=192.168.3.206:5000", "pushcache_2_a=192.168.3.206:5001", "pushcache_2_b=192.168.3.206:5002"}, ","), 100, 30, 300)
+      //初始化 elasticsearch
+      logx.Info("--初始化 elasticsearch--")
+      elastic.InitElasticSize("http://192.168.3.206:9800", 5)
+}
+
+
+func TestNewestBiddingLogic_NewestBidding(t *testing.T) {
+      type fields struct {
+	  ctx    context.Context
+	  svcCtx *svc.ServiceContext
+	  Logger logx.Logger
+      }
+      type args struct {
+	  in *bxbase.NewestBiddingReq
+      }
+      tests := []struct {
+	  name    string
+	  fields  fields
+	  args    args
+	  want    *bxbase.NewsetBiddingResp
+	  wantErr bool
+      }{
+	  // TODO: Add test cases.
+            {name: "app首页数据",
+                  args: args{
+                  in: &bxbase.NewestBiddingReq{
+		    City: "",
+		    IsSearch:  0,
+		    UserId:    "5e8eb60ae138234b4f91aacf",
+		    AppId:     "10000",
+		    EntUserId: "",
+	        },
+	        }},
+      }
+      for _, tt := range tests {
+	  t.Run(tt.name, func(t *testing.T) {
+	        l := &NewestBiddingLogic{
+		    ctx:    tt.fields.ctx,
+		    svcCtx: tt.fields.svcCtx,
+		    Logger: tt.fields.Logger,
+	        }
+	        got, err := l.NewestBidding(tt.args.in)
+	        if (err != nil) != tt.wantErr {
+		    t.Errorf("NewestBidding() error = %v, wantErr %v", err, tt.wantErr)
+		    return
+	        }
+	        if !reflect.DeepEqual(got, tt.want) {
+		    t.Errorf("NewestBidding() got = %v, want %v", got, tt.want)
+	        }
+	  })
+      }
+}

+ 175 - 176
jyBXBase/rpc/model/newestBidding.go

@@ -1,203 +1,202 @@
 package model
 
 import (
-	MC "app.yhyue.com/moapp/jybase/common"
-	ME "app.yhyue.com/moapp/jybase/encrypt"
-	elastic "app.yhyue.com/moapp/jybase/esv1"
-	"app.yhyue.com/moapp/jybase/mongodb"
-	"app.yhyue.com/moapp/jybase/mysql"
-	"fmt"
-	"github.com/zeromicro/go-zero/core/logx"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"jyBXBase/rpc/bxbase"
-	IC "jyBXBase/rpc/init"
-	"strings"
-	"time"
+      MC "app.yhyue.com/moapp/jybase/common"
+      ME "app.yhyue.com/moapp/jybase/encrypt"
+      elastic "app.yhyue.com/moapp/jybase/esv1"
+      "app.yhyue.com/moapp/jybase/mongodb"
+      "app.yhyue.com/moapp/jybase/mysql"
+      "fmt"
+      "github.com/zeromicro/go-zero/core/logx"
+      "go.mongodb.org/mongo-driver/bson/primitive"
+      "jyBXBase/rpc/bxbase"
+      IC "jyBXBase/rpc/init"
+      "log"
+      "strings"
+      "time"
 )
 
 const (
-	search_index        = "bidding"
-	search_type         = "bidding"
-	mongodb_fields      = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "buyerclass":1,"budget":1,"bidamount":1,"s_winner":1,"bidopentime":1,"buyer":1,"projectname":1,"spidercode":1,"site":1}`
-	query               = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site"],"from":0,"size":%d}`
-	multi_match         = `{"multi_match": {"query": %s,"type": "phrase", "fields": ["title"]}}`
-	query_bool_must     = `{"terms":{"%s":[%s]}}`
-	query_bool_must_and = `{"bool":{"must":[%s],"must_not":[%s]}}`
-	search_field        = `"_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","isValidFile","spidercode","site"`
-	query_city_hkeys    = `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": 1}},"highlight": {"pre_tags": ["<a>"],"post_tags": ["</a>"],"fields": {"title": {"fragment_size": 0,"number_of_fragments": 1}}},"_source":[` + search_field + `],"sort":[{"publishtime":"desc"},{"budget":"desc"}],"from":0,"size":20}`
+      search_index        = "bidding"
+      search_type         = "bidding"
+      mongodb_fields      = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "buyerclass":1,"budget":1,"bidamount":1,"s_winner":1,"bidopentime":1,"buyer":1,"projectname":1,"spidercode":1,"site":1}`
+      query               = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site"],"from":0,"size":%d}`
+      multi_match         = `{"multi_match": {"query": %s,"type": "phrase", "fields": ["title"]}}`
+      query_bool_must     = `{"terms":{"%s":[%s]}}`
+      query_bool_must_and = `{"bool":{"must":[%s],"must_not":[%s]}}`
+      search_field        = `"_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","isValidFile","spidercode","site"`
+      query_city_hkeys    = `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": 1}},"highlight": {"pre_tags": ["<a>"],"post_tags": ["</a>"],"fields": {"title": {"fragment_size": 0,"number_of_fragments": 1}}},"_source":[` + search_field + `],"sort":[{"publishtime":"desc"},{"budget":"desc"}],"from":0,"size":20}`
+      Pushbidding         = "pushbidding"
+      Province            = "province"
 )
 
 type NewestInfo struct {
-	TableName string
-	UserId    string
-	MysqlDb   *mysql.Mysql
+TableName string
+UserId    string
+MysqlDb   *mysql.Mysql
 }
 
 var mysqlTables = map[string]string{
-	"f": "pushsubscribe",
-	"v": "pushsubscribe",
-	"m": "pushmember",
-	"e": "pushentniche",
+      "f": "pushsubscribe",
+      "v": "pushsubscribe",
+      "m": "pushmember",
+      "e": "pushentniche",
 }
 
 func GetNewestInfo(userId, userType string) *NewestInfo {
-	nt := &NewestInfo{
-		UserId:    userId,
-		TableName: mysqlTables[userType],
-		MysqlDb:   IC.PushMysql,
-	}
-	switch userType {
-	case "m":
-		nt.MysqlDb = IC.BigmemberPushMysql
-	case "e":
-		nt.MysqlDb = IC.EntnichePushMysql
-	}
-	return nt
+      nt := &NewestInfo{
+	  UserId:    userId,
+	  TableName: mysqlTables[userType],
+	  MysqlDb:   IC.BaseServiceMysql,
+      }
+      return nt
 }
 func (n *NewestInfo) GetPushHistory() (res []*bxbase.NewestList) {
-	findSQL := "select infoid,matchkeys,attachment_count,budget,bidamount from " + n.TableName + " where userid = '" + n.UserId + "'  and date >= %d order by id desc limit 50"
-	list := n.MysqlDb.SelectBySql(fmt.Sprintf(findSQL, time.Now().AddDate(0, 0, -7).Unix()))
-	if len(*list) > 0 {
-		m := map[string]bool{}
-		es_ids := []string{}
-		infos := map[string]*bxbase.NewestList{}
-		for _, v := range *list {
-			infoId := MC.ObjToString(v["infoid"])
-			if m[infoId] {
-				continue
-			}
-			es_ids = append(es_ids, infoId)
-			m[MC.ObjToString(v["infoid"])] = true
-			//
-			infos[infoId] = &bxbase.NewestList{
-				Id:         ME.EncodeArticleId2ByCheck(MC.ObjToString(v["infoid"])),
-				Matchkeys:  MC.ObjToString(v["matchkeys"]),
-				Budget:     MC.Int64All(v["budget"]),
-				Bidamount:  MC.Int64All(v["bidamount"]),
-				FileExists: MC.Int64All(v["attachment_count"]) > 0,
-			}
-		}
-		if len(es_ids) > 0 {
-			list := elastic.Get(search_index, search_type, fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
-			if list != nil {
-				for _, v := range *list {
-					_id := MC.ObjToString(v["_id"])
-					bn := infos[_id]
-					bn.Title = MC.ObjToString(v["title"])
-					bn.PublishTime = MC.Int64All(v["publishtime"])
-					bn.Subtype = MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string)
-					bn.Area = MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string)
-					bn.Buyerclass = MC.ObjToString(v["buyerclass"])
-					bn.City = MC.ObjToString(v["city"])
-					bn.Industry = MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string)
-					bn.SpiderCode = MC.ObjToString(v["spidercode"])
-					bn.Site = MC.ObjToString(v["site"])
-				}
-			}
-		}
-		//mongodb bidding
-		mgo_ids := []primitive.ObjectID{}
-		for _, v := range es_ids {
-			if infos[v].Title == "" {
-				mgo_ids = append(mgo_ids, mongodb.StringTOBsonId(v))
-			}
-		}
-		if len(mgo_ids) > 0 {
-			list, ok := IC.MgoBidding.Find("bidding", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
-			if ok && *list != nil {
-				for _, v := range *list {
-					_id := mongodb.BsonIdToSId(v["_id"])
-					bn := infos[_id]
-					bn.Title = MC.ObjToString(v["title"])
-					bn.PublishTime = MC.Int64All(v["publishtime"])
-					bn.Subtype = MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string)
-					bn.Area = MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string)
-					bn.Buyerclass = MC.ObjToString(v["buyerclass"])
-					bn.City = MC.ObjToString(v["city"])
-					bn.Industry = MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string)
-					bn.SpiderCode = MC.ObjToString(v["spidercode"])
-					bn.Site = MC.ObjToString(v["site"])
-				}
-			}
-		}
-		//mongodb bidding_back
-		mgo_back_ids := []primitive.ObjectID{}
-		for _, v := range mgo_ids {
-			if infos[mongodb.BsonIdToSId(v)].Title == "" {
-				mgo_back_ids = append(mgo_back_ids, v)
-			}
-		}
-		if len(mgo_back_ids) > 0 {
-			list, ok := IC.MgoBidding.Find("bidding_back", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
-			if ok && *list != nil {
-				for _, v := range *list {
-					_id := mongodb.BsonIdToSId(v["_id"])
-					bn := infos[_id]
-					bn.Title = MC.ObjToString(v["title"])
-					bn.PublishTime = MC.Int64All(v["publishtime"])
-					bn.Subtype = MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string)
-					bn.Area = MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string)
-					bn.Buyerclass = MC.ObjToString(v["buyerclass"])
-					bn.City = MC.ObjToString(v["city"])
-					bn.Industry = MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string)
-					bn.SpiderCode = MC.ObjToString(v["spidercode"])
-					bn.Site = MC.ObjToString(v["site"])
-				}
-			}
-		}
-		//
-		for _, v := range infos {
-			res = append(res, v)
-		}
-	}
-	return
+      findSQL := "select b.infoid,a.matchkeys,b.attachment_count,b.budget,b.bidamount from %s a LEFT JOIN %s b ON a.bidid = b.id LEFT JOIN %s p on b.area=p.id or  b.city=p.id  where a.userid = '%s'  and a.date >= %d order by a.id desc limit 50"
+      findSQL = fmt.Sprintf(findSQL, n.TableName, Pushbidding, Province, n.UserId, time.Now().AddDate(0, 0, -7).Unix())
+      log.Println(findSQL)
+      list := n.MysqlDb.SelectBySql(findSQL)
+      if len(*list) > 0 && list != nil {
+	  m := map[string]bool{}
+	  es_ids := []string{}
+	  infos := map[string]*bxbase.NewestList{}
+	  for _, v := range *list {
+	        infoId := MC.ObjToString(v["infoid"])
+	        if m[infoId] {
+		    continue
+	        }
+	        es_ids = append(es_ids, infoId)
+	        m[MC.ObjToString(v["infoid"])] = true
+	        //
+	        infos[infoId] = &bxbase.NewestList{
+		    Id:         ME.EncodeArticleId2ByCheck(MC.ObjToString(v["infoid"])),
+		    Matchkeys:  MC.ObjToString(v["matchkeys"]),
+		    Budget:     MC.Int64All(v["budget"]),
+		    Bidamount:  MC.Int64All(v["bidamount"]),
+		    FileExists: MC.Int64All(v["attachment_count"]) > 0,
+	        }
+	  }
+	  if len(es_ids) > 0 {
+	        list := elastic.Get(search_index, search_type, fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
+	        if list != nil {
+		    for _, v := range *list {
+			_id := MC.ObjToString(v["_id"])
+			bn := infos[_id]
+			bn.Title = MC.ObjToString(v["title"])
+			bn.PublishTime = MC.Int64All(v["publishtime"])
+			bn.Subtype = MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string)
+			bn.Area = MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string)
+			bn.Buyerclass = MC.ObjToString(v["buyerclass"])
+			bn.City = MC.ObjToString(v["city"])
+			bn.Industry = MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string)
+			bn.SpiderCode = MC.ObjToString(v["spidercode"])
+			bn.Site = MC.ObjToString(v["site"])
+		    }
+	        }
+	  }
+	  //mongodb bidding
+	  mgo_ids := []primitive.ObjectID{}
+	  for _, v := range es_ids {
+	        if infos[v].Title == "" {
+		    mgo_ids = append(mgo_ids, mongodb.StringTOBsonId(v))
+	        }
+	  }
+	  if len(mgo_ids) > 0 {
+	        list, ok := IC.MgoBidding.Find("bidding", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
+	        if ok && *list != nil {
+		    for _, v := range *list {
+			_id := mongodb.BsonIdToSId(v["_id"])
+			bn := infos[_id]
+			bn.Title = MC.ObjToString(v["title"])
+			bn.PublishTime = MC.Int64All(v["publishtime"])
+			bn.Subtype = MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string)
+			bn.Area = MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string)
+			bn.Buyerclass = MC.ObjToString(v["buyerclass"])
+			bn.City = MC.ObjToString(v["city"])
+			bn.Industry = MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string)
+			bn.SpiderCode = MC.ObjToString(v["spidercode"])
+			bn.Site = MC.ObjToString(v["site"])
+		    }
+	        }
+	  }
+	  //mongodb bidding_back
+	  mgo_back_ids := []primitive.ObjectID{}
+	  for _, v := range mgo_ids {
+	        if infos[mongodb.BsonIdToSId(v)].Title == "" {
+		    mgo_back_ids = append(mgo_back_ids, v)
+	        }
+	  }
+	  if len(mgo_back_ids) > 0 {
+	        list, ok := IC.MgoBidding.Find("bidding_back", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
+	        if ok && *list != nil {
+		    for _, v := range *list {
+			_id := mongodb.BsonIdToSId(v["_id"])
+			bn := infos[_id]
+			bn.Title = MC.ObjToString(v["title"])
+			bn.PublishTime = MC.Int64All(v["publishtime"])
+			bn.Subtype = MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string)
+			bn.Area = MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string)
+			bn.Buyerclass = MC.ObjToString(v["buyerclass"])
+			bn.City = MC.ObjToString(v["city"])
+			bn.Industry = MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string)
+			bn.SpiderCode = MC.ObjToString(v["spidercode"])
+			bn.Site = MC.ObjToString(v["site"])
+		    }
+	        }
+	  }
+	  //
+	  for _, v := range infos {
+	        res = append(res, v)
+	  }
+      }
+      return
 }
 
 //根据定位或者搜索历史 查es
 func NewestQuery(city, keys string) (str string) {
-	var musts, bools []string
-	if keys != "" {
-		for _, v := range strings.Split(keys, ",") {
-			keys := strings.Split(v, " ") //历史搜索 空格划分
-			must_tmp := []string{}
-			for _, key := range keys {
-				must_tmp = append(must_tmp, fmt.Sprintf(multi_match, "\""+key+"\""))
-			}
-			bools = append(bools, fmt.Sprintf(query_bool_must_and, strings.Join(must_tmp, ","), ""))
-		}
+      var musts, bools []string
+      if keys != "" {
+	  for _, v := range strings.Split(keys, ",") {
+	        keys := strings.Split(v, " ") //历史搜索 空格划分
+	        must_tmp := []string{}
+	        for _, key := range keys {
+		    must_tmp = append(must_tmp, fmt.Sprintf(multi_match, "\""+key+"\""))
+	        }
+	        bools = append(bools, fmt.Sprintf(query_bool_must_and, strings.Join(must_tmp, ","), ""))
+	  }
 
-	}
-	if city != "" {
-		musts = append(musts, fmt.Sprintf(query_bool_must, "city", `"`+city+`"`))
-	}
-	str = fmt.Sprintf(query_city_hkeys, strings.Join(musts, ","), strings.Join(bools, ","))
-	logx.Info("str:", str)
-	return
+      }
+      if city != "" {
+	  musts = append(musts, fmt.Sprintf(query_bool_must, "city", `"`+city+`"`))
+      }
+      str = fmt.Sprintf(query_city_hkeys, strings.Join(musts, ","), strings.Join(bools, ","))
+      logx.Info("str:", str)
+      return
 }
 
 //es查询
 func NewestES(doSearchStr string) (res []*bxbase.NewestList) {
-	list := elastic.Get(search_index, search_type, doSearchStr)
-	if list != nil && len(*list) > 0 {
-		for _, v := range *list {
-			_id := mongodb.BsonIdToSId(v["_id"])
-			isValidFile, _ := v["isValidFile"].(bool)
-			res = append(res, &bxbase.NewestList{
-				Id:          ME.EncodeArticleId2ByCheck(_id),
-				Title:       MC.ObjToString(v["title"]),
-				Subtype:     MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string),
-				Area:        MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string),
-				Buyerclass:  MC.ObjToString(v["buyerclass"]),
-				City:        MC.ObjToString(v["city"]),
-				Industry:    MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string),
-				Budget:      MC.Int64All(v["budget"]),
-				Bidamount:   MC.Int64All(v["bidamount"]),
-				FileExists:  isValidFile, //附件
-				PublishTime: MC.Int64All(v["publishtime"]),
-				Site:        MC.ObjToString(v["site"]),
-				SpiderCode:  MC.ObjToString(v["spidercode"]),
-			})
-		}
-	}
-	return
+      list := elastic.Get(search_index, search_type, doSearchStr)
+      if list != nil && len(*list) > 0 {
+	  for _, v := range *list {
+	        _id := mongodb.BsonIdToSId(v["_id"])
+	        isValidFile, _ := v["isValidFile"].(bool)
+	        res = append(res, &bxbase.NewestList{
+		    Id:          ME.EncodeArticleId2ByCheck(_id),
+		    Title:       MC.ObjToString(v["title"]),
+		    Subtype:     MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string),
+		    Area:        MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string),
+		    Buyerclass:  MC.ObjToString(v["buyerclass"]),
+		    City:        MC.ObjToString(v["city"]),
+		    Industry:    MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string),
+		    Budget:      MC.Int64All(v["budget"]),
+		    Bidamount:   MC.Int64All(v["bidamount"]),
+		    FileExists:  isValidFile, //附件
+		    PublishTime: MC.Int64All(v["publishtime"]),
+		    Site:        MC.ObjToString(v["site"]),
+		    SpiderCode:  MC.ObjToString(v["spidercode"]),
+	        })
+	  }
+      }
+      return
 }

+ 1 - 0
jyBXSubscribe/api/bxsubscribe.api

@@ -27,6 +27,7 @@ type (
 		Price      string `json:"price,optional"`
 		FileExists string `json:"fileExists,optional"`
 		UserType   string `path:"userType,default=fType,options=fType|vType|mType|eType"` //fType:普通用户;vType:超级订阅用户;mType:大会员用户;eType:商机管理用户;
+		NewUserId  int64  `header:"newUserId"`
 	}
 	//
 	someInfoReq {

+ 2 - 4
jyBXSubscribe/entity/db.go

@@ -21,10 +21,8 @@ type MongoStruct struct {
 
 //
 type Mysql struct {
-	Main         *MysqlStruct `json:"main,omitempty"`
-	Push         *MysqlStruct `json:"push,omitempty"`
-	MemberPush   *MysqlStruct `json:"memberPush,omitempty"`
-	EntnichePush *MysqlStruct `json:"entnichePush,omitempty"`
+	Main        *MysqlStruct `json:"main,omitempty"`
+	BaseService *MysqlStruct `json:"baseService,omitempty"`
 }
 
 //mysql

+ 1 - 0
jyBXSubscribe/rpc/bxsubscribe.proto

@@ -21,6 +21,7 @@ message SubscribeInfosReq {
   string  fileExists = 15;
   string  entUserId = 16;
   string deptId = 17;
+  string newUserId = 18;
 }
 
 message SubscribeInfosResp {

+ 4 - 18
jyBXSubscribe/rpc/etc/db.yaml

@@ -6,25 +6,11 @@ mysql:
         password: Topnet123
         maxOpenConns: 5
         maxIdleConns: 5
-    push:
-        dbName: jianyu
-        address: 192.168.3.11:3366
-        userName: root
-        password: Topnet123
-        maxOpenConns: 5
-        maxIdleConns: 5
-    memberPush:
-        dbName: jianyu
-        address: 192.168.3.11:3366
+    baseService:
+        dbName: base_service
+        address: 192.168.3.217:4000
         userName: root
-        password: Topnet123
-        maxOpenConns: 5
-        maxIdleConns: 5
-    entnichePush:
-        dbName: jianyu
-        address: 192.168.3.11:3366
-        userName: root
-        password: Topnet123
+        password: '=PDT49#80Z!RVv52_z'
         maxOpenConns: 5
         maxIdleConns: 5
 redis:

+ 69 - 97
jyBXSubscribe/rpc/init/db.go

@@ -4,122 +4,94 @@
 package init
 
 import (
-	"github.com/zeromicro/go-zero/core/logx"
-	"strings"
+    "github.com/zeromicro/go-zero/core/logx"
+    "strings"
 
-	"jyBXSubscribe/entity"
+    "jyBXSubscribe/entity"
 
-	"app.yhyue.com/moapp/jybase/esv1"
-	"app.yhyue.com/moapp/jybase/mongodb"
-	"app.yhyue.com/moapp/jybase/mysql"
-	"app.yhyue.com/moapp/jybase/redis"
+    "app.yhyue.com/moapp/jybase/esv1"
+    "app.yhyue.com/moapp/jybase/mongodb"
+    "app.yhyue.com/moapp/jybase/mysql"
+    "app.yhyue.com/moapp/jybase/redis"
 )
 
 var (
-	MainMysql         *mysql.Mysql
-	PushMysql         *mysql.Mysql
-	MemberPushMysql   *mysql.Mysql
-	EntnichePushMysql *mysql.Mysql
-	Mgo               mongodb.MongodbSim
-	MgoBidding        mongodb.MongodbSim
+    MainMysql         *mysql.Mysql
+    BaseServiceMysql  *mysql.Mysql
+    Mgo               mongodb.MongodbSim
+    MgoBidding        mongodb.MongodbSim
 )
 
 //
 func MongoDBInit(em *entity.Mongo) {
-	//初始化 mongodb
-	if em.Main.Address != "" {
-		logx.Info("--初始化 mongodb--")
-		Mgo = mongodb.MongodbSim{
-			MongodbAddr: em.Main.Address,
-			Size:        em.Main.Size,
-			DbName:      em.Main.DbName,
-		}
-		Mgo.InitPool()
-	}
-	//
-	if em.Bidding.Address != "" {
-		logx.Info("--初始化 mongodb bidding--")
-		MgoBidding = mongodb.MongodbSim{
-			MongodbAddr: em.Bidding.Address,
-			Size:        em.Bidding.Size,
-			DbName:      em.Bidding.DbName,
-			UserName:    em.Bidding.UserName,
-			Password:    em.Bidding.Password,
-		}
-		MgoBidding.InitPool()
-	}
+    //初始化 mongodb
+    if em.Main.Address != "" {
+        logx.Info("--初始化 mongodb--")
+        Mgo = mongodb.MongodbSim{
+	  MongodbAddr: em.Main.Address,
+	  Size:        em.Main.Size,
+	  DbName:      em.Main.DbName,
+        }
+        Mgo.InitPool()
+    }
+    //
+    if em.Bidding.Address != "" {
+        logx.Info("--初始化 mongodb bidding--")
+        MgoBidding = mongodb.MongodbSim{
+	  MongodbAddr: em.Bidding.Address,
+	  Size:        em.Bidding.Size,
+	  DbName:      em.Bidding.DbName,
+	  UserName:    em.Bidding.UserName,
+	  Password:    em.Bidding.Password,
+        }
+        MgoBidding.InitPool()
+    }
 }
 
 //
 func MysqlInit(mm *entity.Mysql) {
-	//初始化 mysql-main
-	if mm.Main.Address != "" {
-		logx.Info("--初始化 mysql--")
-		MainMysql = &mysql.Mysql{
-			Address:      mm.Main.Address,
-			UserName:     mm.Main.UserName,
-			PassWord:     mm.Main.Password,
-			DBName:       mm.Main.DbName,
-			MaxOpenConns: mm.Main.MaxOpenConns,
-			MaxIdleConns: mm.Main.MaxIdleConns,
-		}
-		MainMysql.Init()
-	}
-	//初始化 mysql-Push
-	if mm.Push.Address != "" {
-		logx.Info("--初始化 push mysql--")
-		PushMysql = &mysql.Mysql{
-			Address:      mm.Push.Address,
-			UserName:     mm.Push.UserName,
-			PassWord:     mm.Push.Password,
-			DBName:       mm.Push.DbName,
-			MaxOpenConns: mm.Push.MaxOpenConns,
-			MaxIdleConns: mm.Push.MaxIdleConns,
-		}
-		PushMysql.Init()
-	}
-	//初始化 mysql-main
-	if mm.MemberPush.Address != "" {
-		logx.Info("--初始化 大会员推送 mysql--")
-		MemberPushMysql = &mysql.Mysql{
-			Address:      mm.MemberPush.Address,
-			UserName:     mm.MemberPush.UserName,
-			PassWord:     mm.MemberPush.Password,
-			DBName:       mm.MemberPush.DbName,
-			MaxOpenConns: mm.MemberPush.MaxOpenConns,
-			MaxIdleConns: mm.MemberPush.MaxIdleConns,
-		}
-		MemberPushMysql.Init()
-	}
-	//初始化 mysql-EntnichePush
-	if mm.EntnichePush.Address != "" {
-		logx.Info("--初始化 商机管理推送 mysql--")
-		EntnichePushMysql = &mysql.Mysql{
-			Address:      mm.EntnichePush.Address,
-			UserName:     mm.EntnichePush.UserName,
-			PassWord:     mm.EntnichePush.Password,
-			DBName:       mm.EntnichePush.DbName,
-			MaxOpenConns: mm.EntnichePush.MaxOpenConns,
-			MaxIdleConns: mm.EntnichePush.MaxIdleConns,
-		}
-		EntnichePushMysql.Init()
-	}
+    //初始化 mysql-main
+    if mm.Main.Address != "" {
+        logx.Info("--初始化 mysql--")
+        MainMysql = &mysql.Mysql{
+	  Address:      mm.Main.Address,
+	  UserName:     mm.Main.UserName,
+	  PassWord:     mm.Main.Password,
+	  DBName:       mm.Main.DbName,
+	  MaxOpenConns: mm.Main.MaxOpenConns,
+	  MaxIdleConns: mm.Main.MaxIdleConns,
+        }
+        MainMysql.Init()
+    }
+    //初始化 mysql-BaseService
+    if mm.BaseService.Address != "" {
+        logx.Info("--初始化 推送 mysql--")
+        BaseServiceMysql = &mysql.Mysql{
+	  Address:      mm.BaseService.Address,
+	  UserName:     mm.BaseService.UserName,
+	  PassWord:     mm.BaseService.Password,
+	  DBName:       mm.BaseService.DbName,
+	  MaxOpenConns: mm.BaseService.MaxOpenConns,
+	  MaxIdleConns: mm.BaseService.MaxIdleConns,
+        }
+        BaseServiceMysql.Init()
+    }
 }
 
 //
 func RedisInit(rm *entity.RedisStuct) {
-	//初始化 redis
-	if len(rm.Addr) > 0 {
-		logx.Info("--初始化 redis--")
-		redis.InitRedisBySize(strings.Join(rm.Addr, ","), 100, 30, 300)
-	}
+    //初始化 redis
+    if len(rm.Addr) > 0 {
+        logx.Info("--初始化 redis--")
+        redis.InitRedisBySize(strings.Join(rm.Addr, ","), 100, 30, 300)
+    }
 }
 
 //
 func EsInit(es *entity.EsStruct) {
-	//初始化 elasticsearch
-	if es.Addr != "" {
-		logx.Info("--初始化 elasticsearch--")
-		elastic.InitElasticSize(es.Addr, es.Size)
-	}
+    //初始化 elasticsearch
+    if es.Addr != "" {
+        logx.Info("--初始化 elasticsearch--")
+        elastic.InitElasticSize(es.Addr, es.Size)
+    }
 }

+ 33 - 33
jyBXSubscribe/rpc/init/init.go

@@ -1,12 +1,10 @@
 package init
 
 import (
-	"flag"
-	_ "github.com/go-sql-driver/mysql"
-	"github.com/zeromicro/go-zero/core/conf"
-	"github.com/zeromicro/go-zero/core/logx"
-	"jyBXSubscribe/entity"
-	"jyBXSubscribe/rpc/internal/config"
+      "flag"
+      _ "github.com/go-sql-driver/mysql"
+      "jyBXSubscribe/entity"
+      "jyBXSubscribe/rpc/internal/config"
 )
 
 var configF = flag.String("cf", "etc/bxsubscribe.yaml", "the config file")
@@ -22,32 +20,34 @@ var DB config.Db
 var logFile = flag.String("lf", "etc/logs.yaml", "the log file")
 var logc entity.Logc
 
+
+
 func init() {
-	//初始化基本配置
-	conf.MustLoad(*configF, &C)
-	//初始化数据库配置
-	conf.MustLoad(*dbFile, &DB)
-	//初始mongodb
-	MongoDBInit(&DB.Mongo)
-	//初始化msyql
-	MysqlInit(&DB.Mysql)
-	//初始redis
-	RedisInit(&DB.Redis)
-	//初始es
-	EsInit(&DB.Es)
-	//初始化日志信息
-	conf.MustLoad(*logFile, &logc)
-	if len(logc.Level) > 0 {
-		for _, v := range logc.Level {
-			logx.MustSetup(logx.LogConf{
-				Mode:     logc.Mode,
-				Path:     logc.Path,
-				Level:    v,
-				KeepDays: logc.KeepDays,
-			})
-			logx.Info(v, "--日志记录")
-		}
-	}
-	//
-	PushMapping.Init()
+      /*//初始化基本配置
+          conf.MustLoad(*configF, &C)
+          //初始化数据库配置
+          conf.MustLoad(*dbFile, &DB)
+          //初始mongodb
+          MongoDBInit(&DB.Mongo)
+          //初始化msyql
+          MysqlInit(&DB.Mysql)
+          //初始redis
+          RedisInit(&DB.Redis)
+          //初始es
+          EsInit(&DB.Es)
+          //初始化日志信息
+          conf.MustLoad(*logFile, &logc)
+          if len(logc.Level) > 0 {
+              for _, v := range logc.Level {
+      	  logx.MustSetup(logx.LogConf{
+      	      Mode:     logc.Mode,
+      	      Path:     logc.Path,
+      	      Level:    v,
+      	      KeepDays: logc.KeepDays,
+      	  })
+      	  logx.Info(v, "--日志记录")
+              }
+          }
+          //
+          PushMapping.Init(BaseServiceMysql)*/
 }

+ 0 - 76
jyBXSubscribe/rpc/init/pushMapping.go

@@ -1,76 +0,0 @@
-package init
-
-import (
-	"app.yhyue.com/moapp/jybase/common"
-	"log"
-)
-
-var PushMapping = &pushMapping{}
-
-type pushMapping struct {
-	Area          map[string]int
-	City          map[string]int
-	Toptype       map[string]int
-	Subtype       map[string]int
-	Buyerclass    map[string]int
-	Subscopeclass map[string]int
-}
-
-//推送数据 在mysql中 信息类型和地区等存的对应id;查询的时候需进行转化;
-func (p *pushMapping) Init() {
-	infotype := PushMysql.SelectBySql("select id,type,name from infotype")
-	p.Toptype = map[string]int{}
-	p.Subtype = map[string]int{}
-	p.Buyerclass = map[string]int{}
-	p.Subscopeclass = map[string]int{}
-	if infotype != nil && len(*infotype) > 0 {
-		for _, v := range *infotype {
-			id := common.IntAll(v["id"])
-			tp := common.IntAll(v["type"])
-			name := common.ObjToString(v["name"])
-			if tp == 1 {
-				p.Toptype[name] = id
-			} else if tp == 2 {
-				p.Subtype[name] = id
-			} else if tp == 3 {
-				p.Buyerclass[name] = id
-			} else if tp == 4 {
-				p.Subscopeclass[name] = id
-			}
-		}
-		if len(p.Toptype) == 0 {
-			log.Fatalln("PushMapping Toptype Init Error")
-		}
-		if len(p.Subtype) == 0 {
-			log.Fatalln("PushMapping Subtype Init Error")
-		}
-		if len(p.Buyerclass) == 0 {
-			log.Fatalln("PushMapping Buyerclass Init Error")
-		}
-		if len(p.Subscopeclass) == 0 {
-			log.Fatalln("PushMapping Subscopeclass Init Error")
-		}
-	}
-	//
-	p.Area = map[string]int{}
-	p.City = map[string]int{}
-	province := PushMysql.SelectBySql("select id,level,name from province")
-	if province != nil && len(*province) > 0 {
-		for _, v := range *province {
-			id := common.IntAll(v["id"])
-			level := common.IntAll(v["level"])
-			name := common.ObjToString(v["name"])
-			if level == 1 {
-				p.Area[name] = id
-			} else if level == 2 {
-				p.City[name] = id
-			}
-		}
-		if len(p.Area) == 0 {
-			log.Fatalln("PushMapping Area Init Error")
-		}
-		if len(p.City) == 0 {
-			log.Fatalln("PushMapping City Init Error")
-		}
-	}
-}

+ 76 - 0
jyBXSubscribe/rpc/init/pushmapping.go

@@ -0,0 +1,76 @@
+package init
+
+import (
+    util "app.yhyue.com/moapp/jybase/common"
+    "app.yhyue.com/moapp/jybase/mysql"
+    "log"
+)
+
+var PushMapping = &pushMapping{}
+
+type pushMapping struct {
+    Area          map[string]int
+    City          map[string]int
+    Toptype       map[string]int
+    Subtype       map[string]int
+    Buyerclass    map[string]int
+    Subscopeclass map[string]int
+}
+
+func (p *pushMapping) Init(Mysql *mysql.Mysql) {
+    infotype := Mysql.SelectBySql("select id,type,name from infotype")
+    p.Toptype = map[string]int{}
+    p.Subtype = map[string]int{}
+    p.Buyerclass = map[string]int{}
+    p.Subscopeclass = map[string]int{}
+    if infotype != nil && len(*infotype) > 0 {
+        for _, v := range *infotype {
+	  id := util.IntAll(v["id"])
+	  tp := util.IntAll(v["type"])
+	  name := util.ObjToString(v["name"])
+	  if tp == 1 {
+	      p.Toptype[name] = id
+	  } else if tp == 2 {
+	      p.Subtype[name] = id
+	  } else if tp == 3 {
+	      p.Buyerclass[name] = id
+	  } else if tp == 4 {
+	      p.Subscopeclass[name] = id
+	  }
+        }
+        if len(p.Toptype) == 0 {
+	  log.Fatalln("PushMapping Toptype Init Error")
+        }
+        if len(p.Subtype) == 0 {
+	  log.Fatalln("PushMapping Subtype Init Error")
+        }
+        if len(p.Buyerclass) == 0 {
+	  log.Fatalln("PushMapping Buyerclass Init Error")
+        }
+        if len(p.Subscopeclass) == 0 {
+	  log.Fatalln("PushMapping Subscopeclass Init Error")
+        }
+    }
+    //
+    p.Area = map[string]int{}
+    p.City = map[string]int{}
+    province := Mysql.SelectBySql("select id,level,name from province")
+    if province != nil && len(*province) > 0 {
+        for _, v := range *province {
+	  id := util.IntAll(v["id"])
+	  level := util.IntAll(v["level"])
+	  name := util.ObjToString(v["name"])
+	  if level == 1 {
+	      p.Area[name] = id
+	  } else if level == 2 {
+	      p.City[name] = id
+	  }
+        }
+        if len(p.Area) == 0 {
+	  log.Fatalln("PushMapping Area Init Error")
+        }
+        if len(p.City) == 0 {
+	  log.Fatalln("PushMapping City Init Error")
+        }
+    }
+}

+ 141 - 0
jyBXSubscribe/rpc/internal/logic/getsublistlogic_test.go

@@ -0,0 +1,141 @@
+package logic
+
+import (
+	elastic "app.yhyue.com/moapp/jybase/esv1"
+	"app.yhyue.com/moapp/jybase/mongodb"
+	"app.yhyue.com/moapp/jybase/mysql"
+	"app.yhyue.com/moapp/jybase/redis"
+	"context"
+	"github.com/zeromicro/go-zero/core/logx"
+	"jyBXSubscribe/entity"
+	IC "jyBXSubscribe/rpc/init"
+	"jyBXSubscribe/rpc/internal/config"
+	"jyBXSubscribe/rpc/internal/svc"
+	"jyBXSubscribe/rpc/type/bxsubscribe"
+	"log"
+	"reflect"
+	"strings"
+	"testing"
+)
+
+func init() {
+
+	logx.Info("--初始化 mongodb--")
+	IC.Mgo = mongodb.MongodbSim{
+		MongodbAddr: "192.168.3.206:27080",
+		Size:        5,
+		DbName:      "qfw",
+	}
+	IC.Mgo.InitPool()
+	IC.DB = config.Db{Mongo: entity.Mongo{
+		Bidding: &entity.MongoStruct{
+			Collection:     "bidding",
+			CollectionBack: "bidding_back",
+		},
+	}}
+	IC.DB.Mongo.Bidding.Collection = "bidding_back"
+	//
+	logx.Info("--初始化 mongodb bidding--")
+	IC.MgoBidding = mongodb.MongodbSim{
+		MongodbAddr: "192.168.3.206:27001",
+		Size:        5,
+		DbName:      "qfw_data",
+		UserName:    "jyDevGroup",
+		Password:    "jy@DevGroup",
+	}
+	IC.MgoBidding.InitPool()
+
+	logx.Info("--初始化 mysql--")
+	IC.MainMysql = &mysql.Mysql{
+		Address:      "192.168.3.11:3366",
+		UserName:     "root",
+		PassWord:     "Topnet123",
+		DBName:       "jianyu",
+		MaxOpenConns: 5,
+		MaxIdleConns: 5,
+	}
+	IC.MainMysql.Init()
+
+	//初始化 mysql-EntnichePush
+	logx.Info("--初始化 商机管理推送 mysql--")
+	IC.BaseServiceMysql = &mysql.Mysql{
+		Address:      "192.168.3.217:4000",
+		UserName:     "root",
+		PassWord:     "=PDT49#80Z!RVv52_z",
+		DBName:       "base_service",
+		MaxOpenConns: 5,
+		MaxIdleConns: 5,
+	}
+	IC.BaseServiceMysql.Init()
+
+	logx.Info("--初始化 redis--")
+	redis.InitRedisBySize(strings.Join([]string{"other=192.168.3.206:1712", "push=192.168.3.206:1712", "pushcache_1=192.168.3.206:5000", "pushcache_2_a=192.168.3.206:5001", "pushcache_2_b=192.168.3.206:5002"}, ","), 100, 30, 300)
+	//初始化 elasticsearch
+	logx.Info("--初始化 elasticsearch--")
+	elastic.InitElasticSize("http://192.168.3.206:9800", 5)
+}
+
+func TestGetSubListLogic_GetSubList(t *testing.T) {
+	type fields struct {
+		ctx    context.Context
+		svcCtx *svc.ServiceContext
+		Logger logx.Logger
+	}
+	type args struct {
+		in *bxsubscribe.SubscribeInfosReq
+	}
+	tests := []struct {
+		name    string
+		fields  fields
+		args    args
+		want    *bxsubscribe.SubscribeInfosResp
+		wantErr bool
+	}{
+		// TODO: Add test cases.
+		{
+			name:   "推送记录查看",
+			fields: fields{},
+			args: args{
+				in: &bxsubscribe.SubscribeInfosReq{
+					PageNum:    1,
+					PageSize:   20,
+					SelectTime: "",
+					Area:       "",
+					City:       "",
+					Industry:   "",
+					BuyerClass: "",
+					KeyWords:   "",
+					Subtype:    "",
+					UserType:   "mType",
+					UserId:     "5e8eb60ae138234b4f91aacf",
+					EntId:      "1111",
+					AppId:      "10000",
+					Price:      "",
+					FileExists: "",
+					EntUserId:  "",
+					DeptId:     "1111",
+				},
+			},
+			want:    nil,
+			wantErr: true,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			l := &GetSubListLogic{
+				ctx:    tt.fields.ctx,
+				svcCtx: tt.fields.svcCtx,
+				Logger: tt.fields.Logger,
+			}
+			got, err := l.GetSubList(tt.args.in)
+			log.Println(got)
+			if (err != nil) != tt.wantErr {
+				t.Errorf("GetSubList() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("GetSubList() got = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}

+ 2 - 1
jyBXSubscribe/rpc/internal/logic/getsubsomeinfologic.go

@@ -60,7 +60,8 @@ func (l *GetSubSomeInfoLogic) GetSubSomeInfo(in *bxsubscribe.SomeInfoReq) (*bxsu
 			t, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
 			today_1 := t.Unix()
 			today_2 := t.AddDate(0, 0, 1).Unix()
-			if IC.PushMysql.CountBySql("select count(1) as count from pushsubscribe where isvip =1 and userid =? and buyerclass=?  and (date between ? and ? )", in.UserId, 93, today_1, today_2) > 0 {
+			//错误
+			if IC.BaseServiceMysql.CountBySql("select count(1) as count from pushsubscribe where isvip =1 and userid =? and buyerclass=?  and (date between ? and ? )", in.UserId, 93, today_1, today_2) > 0 {
 				resp.Data.OtherFlag = true
 			}
 		} else {

+ 131 - 75
jyBXSubscribe/rpc/model/push.go

@@ -8,6 +8,7 @@ import (
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"app.yhyue.com/moapp/jybase/redis"
+	"database/sql"
 	"encoding/json"
 	"fmt"
 	"github.com/zeromicro/go-zero/core/logx"
@@ -34,6 +35,15 @@ const (
 	MemberFlag   = "mType"
 	EntnicheFlag = "eType"
 	oneDay       = 24 * 60 * 60
+	Pushbidding  = "pushbidding"
+	Province     = "province"
+)
+
+var (
+	buildingInsertCollKey  = []string{"infoid", "area", "city", "buyerclass", "toptype", "subtype", "subscopeclass", "budget", "bidamount", "attachment_count", "publishtime"}
+	ennicheInsertCollKey   = []string{"entid", "deptid", "userid", "bidid", "matchkeys", "date"}
+	subscribeInsertCollKey = []string{"userid", "bidid", "matchkeys", "date"}
+	memberInsertCollKey    = []string{"userid", "bidid", "matchkeys", "date"}
 )
 
 var aboutDbMsg map[string]*AboutDbMsg = map[string]*AboutDbMsg{
@@ -67,26 +77,26 @@ type PushCa struct {
 
 //查询参数
 type SubPushQueryParam struct {
-	Mgo_bidding   mongodb.MongodbSim //
-	Bidding       string             //
-	Bidding_back  string             //
-	PushMysql     *mysql.Mysql       //
-	UserId        string             //用户id
-	PageNum       int                //页面
-	PageSize      int                //每页数量
-	SelectTime    string             //时间
-	Area          string             //区域
-	City          string             //城市
-	Buyerclass    string             //采购单位行业
-	Subtype       string             //信息类型 二级分类
-	Subscopeclass string             //信息行业
-	Key           string             //订阅词
-	Export        bool               //导出
-	EntId         string             //企业id
-	Price         string             //价格
-	FileExists    string             //是否有附件;默认全部;1:有附件;-1:无附件
-	EntUserId     string             //商机管理用户id
-	DeptId        string             //商机管理用户部门id
+	Mgo_bidding      mongodb.MongodbSim //
+	Bidding          string             //
+	Bidding_back     string             //
+	UserId           string             //用户id
+	PageNum          int                //页面
+	PageSize         int                //每页数量
+	SelectTime       string             //时间
+	Area             string             //区域
+	City             string             //城市
+	Buyerclass       string             //采购单位行业
+	Subtype          string             //信息类型 二级分类
+	Subscopeclass    string             //信息行业
+	Key              string             //订阅词
+	Export           bool               //导出
+	EntId            string             //企业id
+	Price            string             //价格
+	FileExists       string             //是否有附件;默认全部;1:有附件;-1:无附件
+	EntUserId        string             //商机管理用户id
+	DeptId           string             //商机管理用户部门id
+	BaseServiceMysql *mysql.Mysql
 }
 
 func (spqp *SubPushQueryParam) IsEmpty() bool {
@@ -289,14 +299,14 @@ func (s *subscribePush) Datas(spqp *SubPushQueryParam) (hasNextPage bool, total
 
 //
 func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, endtime int64, size int, isLimit bool) (result []*bxsubscribe.SubscribeInfo, count int64) {
-	querys := []string{fmt.Sprintf("userid='%s'", common.If(s.ModuleFlag == "eType", spqp.EntUserId, spqp.UserId))}
+	querys := []string{fmt.Sprintf("a.userid='%s'", common.If(s.ModuleFlag == "eType", spqp.EntUserId, spqp.UserId))}
 	//时间
 	if starttime > 0 && endtime > 0 {
-		querys = append(querys, fmt.Sprintf("date>=%d and date<=%d", starttime, endtime))
+		querys = append(querys, fmt.Sprintf("a.date>=%d and date<=%d", starttime, endtime))
 	} else if starttime > 0 && endtime == 0 {
-		querys = append(querys, fmt.Sprintf("date>=%d", starttime))
+		querys = append(querys, fmt.Sprintf("a.date>=%d", starttime))
 	} else if starttime == 0 && endtime > 0 {
-		querys = append(querys, fmt.Sprintf("date<=%d", endtime))
+		querys = append(querys, fmt.Sprintf("a.date<=%d", endtime))
 	}
 	if spqp.Area != "" || spqp.City != "" {
 		var sqlAreaCity = ""
@@ -313,7 +323,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			city = append(city, "9999")
 		}
 		if len(city) > 0 {
-			sqlAreaCity = fmt.Sprintf("city in (%s)", strings.Join(city, ","))
+			sqlAreaCity = fmt.Sprintf("p.city in (%s)", strings.Join(city, ","))
 		}
 		//区域
 		var sqlArea = ""
@@ -329,7 +339,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			area = append(area, "9999")
 		}
 		if len(area) > 0 {
-			sqlArea = fmt.Sprintf("area in (%s)", strings.Join(area, ","))
+			sqlArea = fmt.Sprintf("p.area in (%s)", strings.Join(area, ","))
 		}
 		if sqlAreaCity != "" && sqlArea != "" {
 			sqlAreaCity = "( " + sqlAreaCity + " or " + sqlArea + " )"
@@ -350,7 +360,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			buyerclass = append(buyerclass, "9999")
 		}
 		if len(buyerclass) > 0 {
-			querys = append(querys, fmt.Sprintf("buyerclass in (%s)", strings.Join(buyerclass, ",")))
+			querys = append(querys, fmt.Sprintf("b.buyerclass in (%s)", strings.Join(buyerclass, ",")))
 		}
 	}
 	//信息类型
@@ -363,14 +373,14 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			subtype = append(subtype, "9999")
 		}
 		if len(subtype) > 0 {
-			querys = append(querys, fmt.Sprintf("subtype in (%s)", strings.Join(subtype, ",")))
+			querys = append(querys, fmt.Sprintf("b.subtype in (%s)", strings.Join(subtype, ",")))
 		}
 	}
 	//信息行业
 	if spqp.Subscopeclass != "" {
 		find_in_set := []string{}
 		for _, v := range strings.Split(spqp.Subscopeclass, ",") {
-			find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%d',subscopeclass)", IC.PushMapping.Subscopeclass[v]))
+			find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%d',b.subscopeclass)", IC.PushMapping.Subscopeclass[v]))
 		}
 		if len(find_in_set) == 1 {
 			querys = append(querys, find_in_set[0])
@@ -382,7 +392,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 	if spqp.Key != "" {
 		find_in_set := []string{}
 		for _, v := range strings.Split(spqp.Key, ",") {
-			find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(matchkeys,'+',','),' ',','))", v))
+			find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(a.matchkeys,'+',','),' ',','))", v))
 		}
 		if len(find_in_set) == 1 {
 			querys = append(querys, find_in_set[0])
@@ -396,27 +406,28 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 		minPrice := common.Int64All(common.Float64All(minPriceStr) * 10000) //换成元
 		maxPrice := common.Int64All(common.Float64All(maxPriceStr) * 10000) //换成元
 		if minPriceStr != "" && maxPriceStr != "" {
-			querys = append(querys, fmt.Sprintf("((bidamount>=%d and bidamount<=%d) or (budget>=%d and budget<=%d and bidamount is null))", minPrice, maxPrice, minPrice, maxPrice))
+			querys = append(querys, fmt.Sprintf("((b.bidamount>=%d and b.bidamount<=%d) or (b.budget>=%d and b.budget<=%d and b.bidamount is null))", minPrice, maxPrice, minPrice, maxPrice))
 		} else if minPriceStr != "" {
-			querys = append(querys, fmt.Sprintf("(bidamount>=%d  or (budget>=%d and bidamount is null))", minPrice, minPrice))
+			querys = append(querys, fmt.Sprintf("(b.bidamount>=%d  or (b.budget>=%d and b.bidamount is null))", minPrice, minPrice))
 		} else if maxPriceStr != "" {
-			querys = append(querys, fmt.Sprintf("( bidamount<=%d or (budget<=%d and bidamount is null))", maxPrice, maxPrice))
+			querys = append(querys, fmt.Sprintf("(b.bidamount<=%d or (b.budget<=%d and b.bidamount is null))", maxPrice, maxPrice))
 		}
 	}
 	//附件
 	if spqp.FileExists != "" {
 		if spqp.FileExists == "1" {
-			querys = append(querys, fmt.Sprintf("attachment_count is not null"))
+			querys = append(querys, fmt.Sprintf("b.attachment_count is not null"))
 		} else if spqp.FileExists == "-1" {
-			querys = append(querys, fmt.Sprintf("attachment_count is null"))
+			querys = append(querys, fmt.Sprintf("b.attachment_count is null"))
 		}
 	}
-	searchSql := fmt.Sprintf(" from %s where %s order by id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "))
+	searchSql := fmt.Sprintf(" from %s  a LEFT JOIN %s b ON a.bidid = b.id LEFT JOIN %s p on b.area=p.id or  b.city=p.id where %s"+
+		" order by a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Pushbidding, Province, strings.Join(querys, " and "))
 	fmt.Println("searchSql", searchSql)
 	//查询总数
-	count = spqp.PushMysql.CountBySql(fmt.Sprintf("select count(id)" + searchSql))
+	count = spqp.BaseServiceMysql.CountBySql(fmt.Sprintf("select count(a.id)" + searchSql))
 	logx.Info("count:", count, "---", s.ModuleFlag)
-	findSql := "select id,date,infoid,isvisit,matchkeys,type"
+	findSql := "select a.id,a.date,b.infoid,a.isvisit,a.matchkeys,a.type"
 	if s.ModuleFlag != MemberFlag && s.ModuleFlag != EntnicheFlag {
 		findSql += ",isvip"
 	}
@@ -427,7 +438,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 	}
 
 	logx.Info(spqp.UserId, "subscribePush query sql:", findSql)
-	list := spqp.PushMysql.SelectBySql(findSql)
+	list := spqp.BaseServiceMysql.SelectBySql(findSql)
 	if list != nil && len(*list) > 0 {
 		pushCas := s.GetJyPushs(*list)
 		result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas)
@@ -757,10 +768,10 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam) (hasNextPage bool,
 	return
 }
 
-//
+//保存推送表
 func (s *subscribePush) listManager(spqp *SubPushQueryParam, list []map[string]interface{}, keyword []ViewKeyWord, ccount int) (resultList []*bxsubscribe.SubscribeInfo) {
 	t2 := time.Now()
-	now := time.Now()
+	now := date.NowFormat(date.Date_Full_Layout)
 	var (
 		wg = &sync.WaitGroup{}
 		wc = make(chan bool, ccount)
@@ -775,36 +786,49 @@ func (s *subscribePush) listManager(spqp *SubPushQueryParam, list []map[string]i
 			}()
 			redisKey := fmt.Sprintf("pushinfo_%s_%s", spqp.UserId, common.ObjToString(v["_id"]))
 			title := strings.Replace(common.ObjToString(v["title"]), "\n", "", -1)
-			var myInsert = make(map[string]interface{})
-			myInsert["userid"] = spqp.UserId
-			myInsert["infoid"] = common.ObjToString(v["_id"])
-			myInsert["date"] = now.Unix()
-			matchkeys := getKeys(title, keyword)
-			myInsert["matchkeys"] = strings.Join(matchkeys, " ")
+			var pushInsert = []interface{}{}
+			//招投标信息表
+			var buildingInsert = []interface{}{}
+			infoid := ""
+			area := ""
+			city := ""
+			subtype := ""
+			toptype := ""
+			buyerclass := ""
+			attachment_count := ""
+			bidamount := "0"
+			budget := "0"
+			subscopeClass := ""
+			infoid = common.InterfaceToStr(v["_id"])
 			if v["area"] != nil {
-				myInsert["area"] = common.If(common.ObjToString(v["area"]) == "A", 0, common.If(IC.PushMapping.Area[common.ObjToString(v["area"])] > 0, IC.PushMapping.Area[common.ObjToString(v["area"])], 0).(int)).(int)
+				area = common.InterfaceToStr(common.If(common.ObjToString(v["area"]) == "A", 0, common.If(IC.PushMapping.Area[common.ObjToString(v["area"])] > 0, IC.PushMapping.Area[common.ObjToString(v["area"])], 0)))
+			}
+
+			publishtime := ""
+			if v["publishtime"] != nil {
+				publishtime = time.Unix(common.Int64All(v["publishtime"]), 0).Format(date.Date_Full_Layout)
 			}
 			if v["city"] != nil {
-				myInsert["city"] = common.If(IC.PushMapping.City[common.ObjToString(v["city"])] > 0, IC.PushMapping.City[common.ObjToString(v["city"])], 0).(int)
+				city = common.InterfaceToStr(common.If(IC.PushMapping.City[common.ObjToString(v["city"])] > 0, IC.PushMapping.City[common.ObjToString(v["city"])], 0))
 			}
 			if v["subtype"] != nil {
-				myInsert["subtype"] = common.If(IC.PushMapping.Subtype[common.ObjToString(v["subtype"])] > 0, IC.PushMapping.Subtype[common.ObjToString(v["subtype"])], 0).(int)
+				subtype = common.InterfaceToStr(common.If(IC.PushMapping.Subtype[common.ObjToString(v["subtype"])] > 0, IC.PushMapping.Subtype[common.ObjToString(v["subtype"])], 0))
 			}
 			if v["toptype"] != nil {
-				myInsert["toptype"] = common.If(IC.PushMapping.Toptype[common.ObjToString(v["toptype"])] > 0, IC.PushMapping.Toptype[common.ObjToString(v["toptype"])], 0).(int)
+				toptype = common.InterfaceToStr(common.If(IC.PushMapping.Toptype[common.ObjToString(v["toptype"])] > 0, IC.PushMapping.Toptype[common.ObjToString(v["toptype"])], 0))
 			}
 			if v["buyerclass"] != nil {
-				myInsert["buyerclass"] = common.If(IC.PushMapping.Buyerclass[common.ObjToString(v["buyerclass"])] > 0, IC.PushMapping.Buyerclass[common.ObjToString(v["buyerclass"])], 0).(int)
+				buyerclass = common.InterfaceToStr(common.If(IC.PushMapping.Buyerclass[common.ObjToString(v["buyerclass"])] > 0, IC.PushMapping.Buyerclass[common.ObjToString(v["buyerclass"])], 0))
 			}
 			if v["isValidFile"] != nil {
 				isValidFile, _ := v["isValidFile"].(bool)
-				myInsert["attachment_count"] = common.If(isValidFile, 1, 0).(int) //附件 :检索库 只有附件字段,无法识别附件数量 暂定为1;为识别有附件
+				attachment_count = common.InterfaceToStr(common.If(isValidFile, 1, 0)) //附件 :检索库 只有附件字段,无法识别附件数量 暂定为1;为识别有附件
 			}
 			if v["bidamount"] != nil {
-				myInsert["bidamount"] = common.Int64All(v["bidamount"])
+				bidamount = common.InterfaceToStr(v["bidamount"])
 			}
 			if v["budget"] != nil {
-				myInsert["budget"] = common.Int64All(v["budget"])
+				budget = common.InterfaceToStr(v["budget"])
 			}
 			if s_subscopeclass := common.ObjToString(v["s_subscopeclass"]); s_subscopeclass != "" {
 				subscopeclass := []string{}
@@ -814,27 +838,57 @@ func (s *subscribePush) listManager(spqp *SubPushQueryParam, list []map[string]i
 					}
 				}
 				if len(subscopeclass) > 0 {
-					myInsert["subscopeclass"] = strings.Join(subscopeclass, ",")
+					subscopeClass = strings.Join(subscopeclass, ",")
 				}
 			}
-			//商机管理用户
-			if s.ModuleFlag == "s" {
-				myInsert["userid"] = spqp.EntUserId
-				myInsert["entid"] = spqp.EntId
-				myInsert["deptid"] = spqp.DeptId
-			}
-			//保存推送表
-			id := spqp.PushMysql.Insert(aboutDbMsg[s.ModuleFlag].MysqlTable, myInsert)
-			if id > 0 {
-				redis.Put("pushcache_2_a", redisKey, 1, 86400)
-				resultList = append(resultList, s.InfoFormat(&PushCa{
-					InfoId:     common.ObjToString(v["_id"]),
-					Date:       now.Unix(),
-					Index:      id,
-					Keys:       matchkeys,
-					FileExists: v["filetext"] != nil,
-				}, &v))
-			}
+			buildingInsert = append(buildingInsert, infoid, area, city, buyerclass, toptype, subtype, subscopeClass, budget, bidamount, attachment_count, publishtime)
+			spqp.BaseServiceMysql.ExecTx("推送记录保存", func(tx *sql.Tx) bool {
+				id1, id2 := spqp.BaseServiceMysql.InsertIgnoreBatchByTx(tx, Pushbidding, buildingInsertCollKey, buildingInsert)
+				log.Println(id1, id2)
+				if id1 == 0 {
+					//有历史记录,需要查询信息id
+					data := spqp.BaseServiceMysql.FindOne(Pushbidding, map[string]interface{}{
+						"infoid": infoid,
+					}, "id", "")
+					if data != nil {
+						id2 = common.Int64All((*data)["id"])
+					} else {
+						return false
+					}
+				}
+				//推送记录
+				userid := spqp.UserId
+				matchkeys := getKeys(title, keyword)
+				matchkey := strings.Join(matchkeys, " ")
+				entid := spqp.EntId
+				entUserId := spqp.EntUserId
+				deptid := spqp.DeptId
+				id := int64(0)
+				switch s.ModuleFlag {
+				case "eType":
+					pushInsert = append(pushInsert, entid, deptid, entUserId, common.InterfaceToStr(id2), matchkey, now)
+					id, _ = spqp.BaseServiceMysql.InsertIgnoreBatch(aboutDbMsg[s.ModuleFlag].MysqlTable, ennicheInsertCollKey, pushInsert)
+				case "mType":
+					pushInsert = append(pushInsert, userid, common.InterfaceToStr(id2), matchkey, now)
+					id, _ = spqp.BaseServiceMysql.InsertIgnoreBatch(aboutDbMsg[s.ModuleFlag].MysqlTable, memberInsertCollKey, pushInsert)
+				default:
+					pushInsert = append(pushInsert, userid, common.InterfaceToStr(id2), matchkey, now)
+					id, _ = spqp.BaseServiceMysql.InsertIgnoreBatch(aboutDbMsg[s.ModuleFlag].MysqlTable, subscribeInsertCollKey, pushInsert)
+
+				}
+				if id > 0 {
+					return true
+					redis.Put("pushcache_2_a", redisKey, 1, 86400)
+					resultList = append(resultList, s.InfoFormat(&PushCa{
+						InfoId:     common.ObjToString(v["_id"]),
+						Date:       time.Now().Unix(),
+						Index:      id,
+						Keys:       matchkeys,
+						FileExists: v["filetext"] != nil,
+					}, &v))
+				}
+				return false
+			})
 		}(v)
 	}
 	wg.Wait()
@@ -874,7 +928,7 @@ func (s *subscribePush) getDefaultDatasSQL(bsp *ViewCondition) (str string) {
 	bools := []string{}
 	musts := []string{}
 	//发布时间最新7天
-	musts = append(musts, fmt.Sprintf(bidTime, time.Now().AddDate(0, 0, -7).Unix()))
+	musts = append(musts, fmt.Sprintf(bidTime, time.Now().AddDate(0, 0, -365).Unix()))
 	//省份
 	areaCity := []string{}
 	if len(bsp.Area) > 0 {
@@ -1083,6 +1137,8 @@ func (s *subscribePush) getUserInfo(spqp *SubPushQueryParam) (vc *ViewCondition)
 		vc.Size = IC.C.DefaulCount.Free
 		vc.Keyword = getKeyWordArrFromDbResultByFree(tmpInfo.Items, "", -1)
 	}
+	vc.Size = 10
+
 	return
 }