Эх сурвалжийг харах

wip:提交商机管理用户查询方式

wangkaiyue 3 жил өмнө
parent
commit
25e698a038

+ 26 - 1
db/db.go

@@ -1,6 +1,7 @@
 package db
 
 import (
+	"app.yhyue.com/moapp/jybase/mysql"
 	"github.com/gogf/gf/v2/os/gcfg"
 	"github.com/gogf/gf/v2/os/gctx"
 	"log"
@@ -12,6 +13,7 @@ import (
 var (
 	Mgo_Log *mongodb.MongodbSim
 	Mgo     *mongodb.MongodbSim
+	Mysql   *mysql.Mysql
 )
 
 type MgoConf struct {
@@ -25,6 +27,15 @@ type MgoConf struct {
 	Collection_back string
 }
 
+type MysqlConf struct {
+	DbName       string `json:"dbName"`
+	Address      string `json:"address"`
+	UserName     string `json:"userName"`
+	PassWord     string `json:"passWord"`
+	MaxOpenConns int    `json:"maxOpenConns"`
+	MaxIdleConns int    `json:"maxIdleConns"`
+}
+
 func init() {
 	redis.InitRedis(gcfg.Instance().MustGet(gctx.New(), "databases.redis", "").String())
 	log.Println("初始化 redis")
@@ -54,5 +65,19 @@ func init() {
 		Mgo.InitPool()
 		log.Printf("初始化 mongodb 完成 %+v\n", mgoConf)
 	}
-
+	var mysqlConf MysqlConf
+	if err := gcfg.Instance().MustGet(gctx.New(), "databases.mysql").Scan(&mysqlConf); err == nil {
+		if mysqlConf.Address != "" {
+			log.Println("--初始化 mysql--")
+			Mysql = &mysql.Mysql{
+				Address:      mysqlConf.Address,
+				UserName:     mysqlConf.UserName,
+				PassWord:     mysqlConf.PassWord,
+				DBName:       mysqlConf.DbName,
+				MaxOpenConns: mysqlConf.MaxOpenConns,
+				MaxIdleConns: mysqlConf.MaxIdleConns,
+			}
+			Mysql.Init()
+		}
+	}
 }

+ 9 - 2
etc/config.yaml

@@ -13,7 +13,7 @@ etcd:
 
 #消息队列
 nsq:
-  #address: 192.168.3.207:4150
+  #address: 192.168.3.207:4161
   address: 123.56.53.97:4161
 
 #数据库配置
@@ -35,9 +35,16 @@ databases:
     replSet:
     userName:
     password:
+  mysql:
+    dbName: base_service
+    address: 192.168.3.11:3366
+    userName: root
+    passWord: Topnet123
+    maxOpenConns: 5
+    maxIdleConns: 5
 
 rpc:
-  payrpc: 127.0.0.1:8600
+  payrpc: 192.168.3.206:8601
 
 #其他配置
 newUserAward: #新用户注册奖励

+ 20 - 20
handler/activity/bidderPlan.go

@@ -1,11 +1,11 @@
 package activity
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/go-logger/logger"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/message/db"
 	"app.yhyue.com/moapp/message/handler/award"
-	"app.yhyue.com/moapp/message/rpc"
 	"encoding/json"
 	"fmt"
 	"github.com/gogf/gf/v2/os/gcfg"
@@ -141,10 +141,10 @@ type FreeSubscribe struct {
 
 // MissionsSubscribeQuery 订阅任务
 // status:0 未完成 1 待领取 -1已领取
+// 付费账户直接视为完成任务
 func (BP *BidderPlan) MissionsSubscribeQuery(userId string) (status int) {
-	//非7天超级订阅或存在订阅内容则完成任务
 	finish := func() bool {
-		uData, ok := db.Mgo.FindById("user", userId, `{"o_jy":1,"i_vip_status":1,"i_member_status":1}`)
+		uData, ok := db.Mgo.FindById("user", userId, `{"o_jy":1,"i_vip_status":1,"i_member_status":1,"s_m_phone":1,"s_phone:1"}`)
 		if !ok || uData == nil || len(*uData) == 0 {
 			return false
 		}
@@ -153,27 +153,27 @@ func (BP *BidderPlan) MissionsSubscribeQuery(userId string) (status int) {
 		} else if gconv.Int((*uData)["i_member_status"]) > 0 { //大会员
 			return true
 		}
-		//查询免费订阅是否完成
-		vStatus, err := rpc.GetUserVipBaseMsgByRpc(userId)
-		if err != nil {
+		//查询是否是商机管理用户
+		phone, _ := common.If((*uData)["s_phone"] != nil, (*uData)["s_phone"], (*uData)["s_m_phone"]).(string)
+		if phone != "" {
+			if count := db.Mysql.CountBySql(`SELECT count(1) FROM entniche_user u LEFT JOIN entniche_info i ON u.ent_id=i.id WHERE u.phone=? and u.power=1 and i.status=1`, phone); count > 0 {
+				return true
+			}
+		}
+		//免费用户查询是否完成订阅
+		bytes := gconv.Bytes((*uData)["o_jy"])
+		if bytes == nil || len(bytes) == 0 {
+			return false
+		}
+		freeSub := FreeSubscribe{}
+		if err := json.Unmarshal(bytes, &freeSub); err != nil {
+			logger.Error("MissionsSubscribeQuery 格式化订阅内存出错", err)
 			return false
 		}
-		if vStatus.EntnicheStatus > 0 {
+		if len(freeSub.AKey) > 0 && len(freeSub.OAreaP) > 0 {
 			return true
-		} else {
-			bytes := gconv.Bytes((*uData)["o_jy"])
-			if bytes == nil || len(bytes) == 0 {
-				return false
-			}
-			freeSub := FreeSubscribe{}
-			if err = json.Unmarshal(bytes, &freeSub); err != nil {
-				fmt.Println(err)
-				return false
-			}
-			if len(freeSub.AKey) > 0 && len(freeSub.OAreaP) > 0 {
-				return true
-			}
 		}
+
 		return false
 	}()