wangshan 3 лет назад
Родитель
Сommit
eb76589e91
4 измененных файлов с 59 добавлено и 8 удалено
  1. 4 2
      jyBXBase/entity/db.go
  2. 14 0
      jyBXBase/rpc/etc/db.yaml
  3. 33 5
      jyBXBase/rpc/init/db.go
  4. 8 1
      jyBXBase/rpc/model/newestBidding.go

+ 4 - 2
jyBXBase/entity/db.go

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

+ 14 - 0
jyBXBase/rpc/etc/db.yaml

@@ -13,6 +13,20 @@ mysql:
         password: Topnet123
         maxOpenConns: 5
         maxIdleConns: 5
+    memberPush:
+        dbName: jianyu
+        address: 192.168.3.11:3366
+        userName: root
+        password: Topnet123
+        maxOpenConns: 5
+        maxIdleConns: 5
+    entnichePush:
+        dbName: jianyu
+        address: 192.168.3.11:3366
+        userName: root
+        password: Topnet123
+        maxOpenConns: 5
+        maxIdleConns: 5
 redis:
     addr:
         - other=192.168.3.206:1712

+ 33 - 5
jyBXBase/rpc/init/db.go

@@ -16,11 +16,13 @@ import (
 )
 
 var (
-	MainMysql  *mysql.Mysql
-	PushMysql  *mysql.Mysql
-	Mgo        mongodb.MongodbSim
-	MgoEnt     mongodb.MongodbSim
-	MgoBidding mongodb.MongodbSim
+	MainMysql          *mysql.Mysql
+	PushMysql          *mysql.Mysql
+	BigmemberPushMysql *mysql.Mysql
+	EntnichePushMysql  *mysql.Mysql
+	Mgo                mongodb.MongodbSim
+	MgoEnt             mongodb.MongodbSim
+	MgoBidding         mongodb.MongodbSim
 )
 
 //
@@ -89,6 +91,32 @@ func MysqlInit(em *entity.Mysql) {
 		}
 		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()
+	}
 }
 
 //

+ 8 - 1
jyBXBase/rpc/model/newestBidding.go

@@ -46,7 +46,14 @@ func GetNewestInfo(userId, userType string) *NewestInfo {
 }
 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 := IC.PushMysql.SelectBySql(fmt.Sprintf(findSQL, time.Now().AddDate(0, 0, -7).Unix()))
+	list := &[]map[string]interface{}{}
+	if n.TableName == "pushmember" { //大会员
+		list = IC.BigmemberPushMysql.SelectBySql(fmt.Sprintf(findSQL, time.Now().AddDate(0, 0, -7).Unix()))
+	} else if n.TableName == "pushentniche" { //商机管理
+		list = IC.EntnichePushMysql.SelectBySql(fmt.Sprintf(findSQL, time.Now().AddDate(0, 0, -7).Unix()))
+	} else {
+		list = IC.PushMysql.SelectBySql(fmt.Sprintf(findSQL, time.Now().AddDate(0, 0, -7).Unix()))
+	}
 	if len(*list) > 0 {
 		m := map[string]bool{}
 		es_ids := []string{}