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

feat:p718搜索赠送抽奖机会

fuwencai 3 сар өмнө
parent
commit
f53de99f36

+ 2 - 0
jyBXCore/rpc/etc/bxcore.yaml

@@ -83,3 +83,5 @@ PurchaseCode: ygzc_cgxx
 PurchaseDiffSwitch: false
 SearchLimit: 10
 SubjectLimit: 3
+Nsq: 192.168.3.240:4260
+NsqTopic: jy_event

+ 6 - 0
jyBXCore/rpc/etc/db.yaml

@@ -44,6 +44,12 @@ mongo:
         collectionChange: bidding_back
         userName: ""
         password: ""
+    mgoLog:
+      address: 192.168.3.206:27090
+      size: 5
+      dbName: qfw
+      userName: admin
+      password: "123456"
 esNoLogin:
     addr: http://172.20.45.129:9206,http://172.20.45.130:9306
     size: 50

+ 12 - 0
jyBXCore/rpc/init/db.go

@@ -19,6 +19,7 @@ var (
 	BaseMysql  *mysql.Mysql
 	BiMysql    *mysql.Mysql
 	Mgo        mongodb.MongodbSim
+	MgoLog     mongodb.MongodbSim
 	MgoBidding mongodb.MongodbSim //标讯详情等(第一版没用)
 	NoLoginEs  Es
 	FreeEs     Es
@@ -47,6 +48,17 @@ func MongoDBInit(em *entity.Mongo) {
 		}
 		MgoBidding.InitPool()
 	}
+	if em.MgoLog.Address != "" {
+		log.Println("--初始化 mongodb log--")
+		MgoLog = mongodb.MongodbSim{
+			MongodbAddr: em.MgoLog.Address,
+			Size:        em.MgoLog.Size,
+			DbName:      em.MgoLog.DbName,
+			UserName:    em.MgoLog.UserName,
+			Password:    em.MgoLog.Password,
+		}
+		MgoLog.InitPool()
+	}
 }
 
 func MysqlInit(mm *entity.Mysql) {

+ 2 - 0
jyBXCore/rpc/internal/config/config.go

@@ -72,6 +72,8 @@ type Config struct {
 	PurchaseDiffSwitch bool  //付费和免费查询区分开关
 	SearchLimit        int64 //搜索数大于条数查询标的物数
 	SubjectLimit       int64 //标的物大于条数展示广告推荐
+	Nsq                string
+	NsqTopic           string
 }
 type Db struct {
 	Mysql     entity.Mysql      `json:"mysql"`

+ 33 - 0
jyBXCore/rpc/internal/logic/getsearchlistlogic.go

@@ -2,10 +2,13 @@ package logic
 
 import (
 	MC "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/redis"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/init"
 	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/service"
 	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/util"
 	"context"
+	"fmt"
 	"strings"
 	"time"
 
@@ -30,6 +33,12 @@ func NewGetSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Get
 	}
 }
 
+const (
+	TaskActiveId             = 16
+	TaskActivityCacheKey     = "activity_day_task_%v_%v_%v"
+	TaskActivityCacheTimeout = 60 * 60 * 3
+)
+
 // GetSearchList 标讯搜索结果列表数据
 func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.SearchResp, error) {
 	defer MC.Catch()
@@ -140,6 +149,30 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 			ErrMsg:  "",
 			ErrCode: 0,
 		}, nil
+	} else {
+		if in.UserId != "" {
+			key := fmt.Sprintf(TaskActivityCacheKey, in.PositionId, TaskActiveId, 3)
+			if exist, _ := redis.Exists("other", key); !exist {
+				redis.Put("other", key, 1, TaskActivityCacheTimeout)
+				nsqNode := jy.Jyweb_node2
+				if in.Platform == "WX" {
+					nsqNode = jy.Jywx_node1
+				} else if in.Platform == "APP" || in.Platform == "H5" {
+					nsqNode = jy.Jyapp_node1
+				}
+				err := jy.Publish(IC.MgoLog, IC.C.Nsq, IC.C.NsqTopic, "lottery_draw_task", in.UserId, nsqNode, map[string]interface{}{
+					"phone":      in.Phone,
+					"userId":     in.UserId,
+					"mgoUserId":  in.MgoUserId,
+					"positionId": in.PositionId,
+					"activeId":   TaskActiveId,
+					"taskInfoId": 3,
+				})
+				if err != nil {
+					log.Println("nsq队列写入失败-->", err, "lottery_draw_task", 3, in.UserId)
+				}
+			}
+		}
 	}
 	//异常付费用户  参数不是免费fType,但是又不是付费用户;还有一种是未登录用户 稍后处理
 	if in.UserType != "fType" && !in.IsPay {