diff --git a/app/cfg/cfg_app.go b/app/cfg/cfg_app.go index 232ecdb..a0088d2 100644 --- a/app/cfg/cfg_app.go +++ b/app/cfg/cfg_app.go @@ -17,6 +17,7 @@ type Config struct { ImLogicRpc ImLogicRpcCfg `yaml:"im_logic_rpc"` Local bool MQ MQCfg `yaml:"mq"` + ES ESCfg } type ImBusinessRpcCfg struct { @@ -73,3 +74,9 @@ type MQCfg struct { User string `yaml:"user"` Pwd string `yaml:"pwd"` } + +type ESCfg struct { + Url string `yaml:"url"` + User string `yaml:"user"` + Pwd string `yaml:"pwd"` +} diff --git a/app/cfg/init_cfg.go b/app/cfg/init_cfg.go index 6f1e73a..e6e11c7 100644 --- a/app/cfg/init_cfg.go +++ b/app/cfg/init_cfg.go @@ -17,6 +17,7 @@ var ( RedisPassword string DB *DBCfg MQ *MQCfg + ES *ESCfg Log *LogCfg ) @@ -48,4 +49,5 @@ func InitCfg() { RedisPassword = conf.RedisPassword SrvAddr = conf.SrvAddr MQ = &conf.MQ + ES = &conf.ES } diff --git a/app/cfg/init_es.go b/app/cfg/init_es.go new file mode 100644 index 0000000..6df6371 --- /dev/null +++ b/app/cfg/init_es.go @@ -0,0 +1,12 @@ +package cfg + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "encoding/json" +) + +func InitEs() { + data, _ := json.Marshal(ES) + filePutContents("init_rabbit_es", string(data)) + es.Init(ES.Url, ES.User, ES.Pwd) +} diff --git a/app/hdl/institutional_management/egg_energy/hdl_egg_point.go b/app/hdl/institutional_management/egg_energy/hdl_egg_point.go new file mode 100644 index 0000000..6d35877 --- /dev/null +++ b/app/hdl/institutional_management/egg_energy/hdl_egg_point.go @@ -0,0 +1,247 @@ +package egg_energy + +import ( + "applet/app/db" + "applet/app/e" + md "applet/app/md/institutional_management/egg_energy" + "applet/app/svc/egg_energy" + "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" + md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "github.com/gin-gonic/gin" +) + +// UserEggIndex +// @Summary 制度中心-蛋蛋能量-蛋蛋分管理(着陆页数据) +// @Tags 蛋蛋能量 +// @Description 蛋蛋分管理(着陆页数据) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @param req body md.UserEggIndexReq true "请求参数" +// @Success 200 {object} md.UserEggIndexResp "成功返回" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/institutionalManagement/eggEnergy/eggPoint/statisticsUserEggIndex [POST] +func UserEggIndex(c *gin.Context) { + var req *md.UserEggIndexReq + if err1 := c.ShouldBindJSON(&req); err1 != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) + return + } + var resp md.UserEggIndexResp + var err error + + var esIndexName string + if req.Year == "" && req.Week == "" { + esIndexName, _ = es.GetLatestIndexFromAlias(md2.EggEnergyUserEggScoreEsAlias) + resp.Year, resp.Week = egg_energy.GetYearsAndWeekStr(esIndexName) + } else { + esIndexName = md2.EggEnergyUserEggScoreEsAlias + "_" + req.Year + req.Week + resp.Year, resp.Week = req.Year, req.Week + } + + //统计用户蛋蛋分范围 + resp.StatisticsUserEggScoreValueRange, err = egg_energy.StatisticsUserEggScoreValueRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户蛋蛋分"评比类型"占比 + resp.StatisticsUserEggKindProportion, err = egg_energy.StatisticsUserEggKindProportion(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //查询蛋蛋分系数权重 + eggEnergyUserEggIndexWeightDb := implement.NewEggEnergyUserEggIndexWeightDb(db.Db) + resp.EggEnergyUserEggIndexWeight, _, _ = eggEnergyUserEggIndexWeightDb.EggEnergyUserEggIndexWeightGet() + + resp.YearAndWeekList, err = egg_energy.GetYearsAndWeeks() + if err != nil { + return + } + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + e.OutSuc(c, resp, nil) +} + +// StatisticsUserEggIndex +// @Summary 制度中心-蛋蛋能量-蛋蛋分管理(着陆页数据分析) +// @Tags 蛋蛋能量 +// @Description 蛋蛋分管理(着陆页数据分析) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @param req body md.StatisticsEggPointReq true "请求参数" +// @Success 200 {object} md.StatisticsEggPointResp "成功返回" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/institutionalManagement/eggEnergy/eggPoint/statisticsUserEggIndex [POST] +func StatisticsUserEggIndex(c *gin.Context) { + var req *md.StatisticsEggPointReq + if err1 := c.ShouldBindJSON(&req); err1 != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) + return + } + var resp md.StatisticsEggPointResp + var err error + + var esIndexName string + if req.Year == "" && req.Week == "" { + esIndexName, _ = es.GetLatestIndexFromAlias(md2.EggEnergyUserEggScoreEsAlias) + resp.Year, resp.Week = egg_energy.GetYearsAndWeekStr(esIndexName) + } else { + esIndexName = md2.EggEnergyUserEggScoreEsAlias + "_" + req.Year + req.Week + resp.Year, resp.Week = req.Year, req.Week + } + + //统计用户"ecpm"范围 + resp.StatisticsUserEggEcpmRange, err = egg_energy.StatisticsUserEggEcpmRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"拉新人数"范围 + resp.StatisticsUserEggInviteUserNumsRange, err = egg_energy.StatisticsUserEggInviteUserNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"团队活跃次数"范围 + resp.StatisticsUserEggTeamActivityNumsRange, err = egg_energy.StatisticsUserEggTeamActivityNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"签到次数"范围 + resp.StatisticsUserEggSignInNumsRange, err = egg_energy.StatisticsUserEggSignInNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"发红包次数"范围 + resp.StatisticsUserEggSendRedPackageNumsRange, err = egg_energy.StatisticsUserEggSendRedPackageNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"蛋蛋能量兑换余额数量"范围 + resp.StatisticsUserEggEggEnergyExchangeAccountBalanceRange, err = egg_energy.StatisticsUserEggEggEnergyExchangeAccountBalanceRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"蛋蛋能量兑换余额数量"范围 + resp.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange, err = egg_energy.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"发朋友圈次数"范围 + resp.StatisticsUserEggSendCircleOfFriendNumsRange, err = egg_energy.StatisticsUserEggSendCircleOfFriendNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"论坛评论次数"范围 + resp.StatisticsUserEggForumCommentsNumsRange, err = egg_energy.StatisticsUserEggForumCommentsNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"学院学习次数"范围 + resp.StatisticsUserEggCollegeLearningNumsRange, err = egg_energy.StatisticsUserEggCollegeLearningNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"违规次数"范围 + resp.StatisticsUserEggViolateNumsRange, err = egg_energy.StatisticsUserEggViolateNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"浏览界面次数"范围 + resp.StatisticsUserEggBrowseInterfaceNumsRange, err = egg_energy.StatisticsUserEggBrowseInterfaceNumsRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + //统计用户"个人活跃积分增量值"范围 + resp.StatisticsUserEggPersonAddActivityValueRange, err = egg_energy.StatisticsUserEggPersonAddActivityValueRange(esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + + resp.YearAndWeekList, err = egg_energy.GetYearsAndWeeks() + if err != nil { + return + } + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + } + e.OutSuc(c, resp, nil) +} + +// UserEggFlow +// @Summary 制度中心-蛋蛋能量-蛋蛋分管理(用户数据列表) +// @Tags 蛋蛋能量 +// @Description 蛋蛋分管理(用户数据列表) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @param req body md.UserEggFlowReq true "请求参数" +// @Success 200 {object} md.UserEggFlowReqResp "成功返回" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/institutionalManagement/eggEnergy/eggPoint/userEggFlow [POST] +func UserEggFlow(c *gin.Context) { + var req *md.UserEggFlowReq + if err1 := c.ShouldBindJSON(&req); err1 != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) + return + } + var resp md.UserEggFlowReqResp + var err error + + var esIndexName string + if req.Year == "" && req.Week == "" { + esIndexName, _ = es.GetLatestIndexFromAlias(md2.EggEnergyUserEggScoreEsAlias) + resp.Year, resp.Week = egg_energy.GetYearsAndWeekStr(esIndexName) + } else { + esIndexName = md2.EggEnergyUserEggScoreEsAlias + "_" + req.Year + req.Week + resp.Year, resp.Week = req.Year, req.Week + } + + resp.List, resp.Total, err = egg_energy.QueryElasticsearch(*req, esIndexName) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + resp.Page = req.Page + resp.PageSize = req.PageSize + e.OutSuc(c, resp, nil) +} + +// ManualScore +// @Summary 制度中心-蛋蛋能量-蛋蛋分管理(人工打分) +// @Tags 蛋蛋能量 +// @Description 蛋蛋分管理(人工打分) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @param req body md.ManualScoreReq true "请求参数" +// @Success 200 {string} success "成功返回" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/institutionalManagement/eggEnergy/eggPoint/manualScore [POST] +func ManualScore(c *gin.Context) { + var req *md.ManualScoreReq + if err1 := c.ShouldBindJSON(&req); err1 != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) + return + } + esIndexName, _ := es.GetLatestIndexFromAlias(md2.EggEnergyUserEggScoreEsAlias) + doc, err := es.FirstDoc(esIndexName, req.IndexId) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + if doc == nil { + e.OutErr(c, e.ERR_NO_DATA, "文档记录为空") + return + } + _, err = es.UpdateDoc(esIndexName, req.IndexId, map[string]interface{}{ + "score_value": req.Score, + "score_value_kind": 1, + }) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, "success", nil) +} diff --git a/app/md/institutional_management/egg_energy/md_egg_point.go b/app/md/institutional_management/egg_energy/md_egg_point.go new file mode 100644 index 0000000..ab3827e --- /dev/null +++ b/app/md/institutional_management/egg_energy/md_egg_point.go @@ -0,0 +1,115 @@ +package md + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type StatisticsEggPointReq struct { + Year string `json:"year" example:"年份"` + Week string `json:"week" example:"周份"` +} + +type UserEggIndexReq struct { + Year string `json:"year" example:"年份"` + Week string `json:"week" example:"周份"` +} + +type StatisticsEggPointResp struct { + Year string `json:"year" example:"年份"` + Week string `json:"week" example:"周份"` + YearAndWeekList map[string][]string `json:"year_list"` //年份&&周份列表 + StatisticsUserEggScoreValueRange []map[string]string `json:"statistics_user_egg_score_value_range"` //统计用户蛋蛋分范围 + StatisticsUserEggKindProportion []map[string]interface{} `json:"statistics_user_egg_kind_proportion"` //统计用户蛋蛋分"评比类型"占比 + StatisticsUserEggEcpmRange []map[string]string `json:"statistics_user_egg_ecpm_range"` //统计用户"ecpm"范围 + StatisticsUserEggInviteUserNumsRange []map[string]string `json:"statistics_user_egg_invite_user_nums_range"` //统计用户"拉新人数"范围 + StatisticsUserEggTeamActivityNumsRange []map[string]string `json:"statistics_user_egg_team_activity_nums_range"` //统计用户"团队活跃次数"范围 + StatisticsUserEggSignInNumsRange []map[string]string `json:"statistics_user_egg_sign_in_nums_range"` //统计用户"签到次数"范围 + StatisticsUserEggSendRedPackageNumsRange []map[string]string `json:"statistics_user_egg_send_red_package_nums_range"` //统计用户"发红包次数"范围 + StatisticsUserEggEggEnergyExchangeAccountBalanceRange []map[string]string `json:"statistics_user_egg_egg_energy_exchange_account_balance_range"` //统计用户"蛋蛋能量兑换余额数量"范围 + StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange []map[string]string `json:"statistics_user_egg_account_balance_exchange_egg_energy_nums_range"` //统计用户"余额兑换蛋蛋能量数量"范围 + StatisticsUserEggSendCircleOfFriendNumsRange []map[string]string `json:"statistics_user_egg_send_circle_of_friend_nums_range"` //统计用户"发朋友圈次数"范围 + StatisticsUserEggForumCommentsNumsRange []map[string]string `json:"statistics_user_egg_forum_comments_nums_range"` //统计用户"论坛评论次数"范围 + StatisticsUserEggCollegeLearningNumsRange []map[string]string `json:"statistics_user_egg_college_learning_nums_range"` //统计用户"学院学习次数"范围 + StatisticsUserEggViolateNumsRange []map[string]string `json:"statistics_user_egg_violate_nums_range"` //统计用户"违规次数"范围 + StatisticsUserEggBrowseInterfaceNumsRange []map[string]string `json:"statistics_user_egg_browse_interface_nums_range"` //统计用户"浏览界面次数"范围 + StatisticsUserEggPersonAddActivityValueRange []map[string]string `json:"statistics_user_egg_person_add_activity_value_range"` //统计用户"个人活跃积分增量值"范围 +} + +type UserEggIndexResp struct { + Year string `json:"year" example:"年份"` + Week string `json:"week" example:"周份"` + YearAndWeekList map[string][]string `json:"year_list"` //年份&&周份列表 + StatisticsUserEggScoreValueRange []map[string]string `json:"statistics_user_egg_score_value_range"` //统计用户蛋蛋分范围 + StatisticsUserEggKindProportion []map[string]interface{} `json:"statistics_user_egg_kind_proportion"` //统计用户蛋蛋分"评比类型"占比 + EggEnergyUserEggIndexWeight *model.EggEnergyUserEggIndexWeight `json:"egg_energy_user_egg_index_weight"` //蛋蛋分系数权重 +} + +type UserEggFlowReq struct { + Page int `json:"page,required"` // 页数 + PageSize int `json:"page_size,required"` // 每页大小 + Year string `json:"year" example:"年份"` + Week string `json:"week" example:"周份"` + ScoreValueStart string `json:"score_value_start" example:"蛋蛋分-起始值"` + ScoreValueEnd string `json:"score_value_end" example:"蛋蛋分-结束值"` + ScoreValueKind int `json:"score_value_kind"` //评分类型(0:未知 1:人工 2:系统) + EcpmStart string `json:"ecpm_start" example:"ecpm-起始值"` + EcpmEnd string `json:"ecpm_end" example:"ecpm-结束值"` + InviteUserNumsStart string `json:"invite_user_nums_start" example:"拉新人数-起始值"` + InviteUserNumsEnd string `json:"invite_user_nums_end" example:"拉新人数-结束值"` + TeamActivityNumsStart string `json:"team_activity_nums_start" example:"团队活跃次数-起始值"` + TeamActivityNumsEnd string `json:"team-activity-nums-end" example:"团队活跃次数-结束值"` + SignInNumsStart string `json:"sign_in_nums_start" example:"签到次数-起始值"` + SignInNumsEnd string `json:"sign_in_nums_end" example:"签到次数-结束值"` + ImActivityNumsStart string `json:"im_activity_nums_start" example:"im活跃次数-起始值"` + ImActivityNumsEnd string `json:"im_activity_nums_end" example:"im活跃次数-结束值"` + SendRedPackageNumsStart string `json:"send_red_package_nums_start" example:"发红包次数-起始值"` + SendRedPackageNumsEnd string `json:"send_red_package_nums_end" example:"发红包次数-结束值"` + EggEnergyExchangeAccountBalanceStart string `json:"egg_energy_exchange_account_balance_start" example:"蛋蛋能量兑换余额数量-起始值"` + EggEnergyExchangeAccountBalanceEnd string `json:"egg_energy_exchange_account_balance_end" example:"蛋蛋能量兑换余额数量-结束值"` + AccountBalanceExchangeEggEnergyNumsStart string `json:"account_balance_exchange_egg_energy_nums_start" example:"余额兑换蛋蛋能量数量-起始值"` + AccountBalanceExchangeEggEnergyNumsEnd string `json:"account_balance_exchange_egg_energy_nums_end" example:"余额兑换蛋蛋能量数量-结束值"` + SendCircleOfFriendNumsStart string `json:"send_circle_of_friend_nums_start" example:"发朋友圈次数-起始值"` + SendCircleOfFriendNumsEnd string `json:"send_circle_of_friend_nums_end" example:"发朋友圈次数-结束值"` + ForumCommentsNumsStart string `json:"forum_comments_nums_start" example:"论坛评论次数-起始值"` + ForumCommentsNumsEnd string `json:"forum_comments_nums_end" example:"论坛评论次数-结束值"` + CollegeLearningNumsStart string `json:"college_learning_nums_start" example:"学院学习次数-起始值"` + CollegeLearningNumsEnd string `json:"college_learning_nums_end" example:"学院学习次数-结束值"` + ViolateNumsStart string `json:"violate_nums_start" example:"违规次数-起始值"` + ViolateNumsEnd string `json:"violate_nums_end" example:"违规次数-结束值"` + BrowseInterfaceNumsStart string `json:"browse_interface_nums_start" example:"浏览界面次数-起始值"` + BrowseInterfaceNumsEnd string `json:"browse_interface_nums_end" example:"浏览界面次数-结束值"` + PersonAddActivityValueStart string `json:"person_add_activity_value_start" example:"个人活跃积分-起始值"` + PersonAddActivityValueEnd string `json:"person_add_activity_value_end" example:"个人活跃积分-结束值"` +} + +type ManualScoreReq struct { + IndexId string `json:"index_id,required"` //文档id + Score string `json:"score" example:"分数"` +} + +type UserEggFlowReqResp struct { + Page int `json:"page,required"` // 页数 + PageSize int `json:"page_size,required"` // 每页大小 + Year string `json:"year" example:"年份"` + Week string `json:"week" example:"周份"` + Total int64 `json:"total"` //总数量 + List []UserEggFlowReqRespList `json:"list"` +} + +type UserEggFlowReqRespList struct { + IndexId string `json:"index_id"` //文档id + ScoreValue float64 `json:"score_value"` //蛋蛋分-起始值 + ScoreValueKind int `json:"score_value_kind"` //评分类型(0:未知 1:人工 2:系统) + Ecpm float64 `json:"ecpm"` //ecpm + InviteUserNums int `json:"invite_user_nums"` //拉新人数 + TeamActivityNums int `json:"team_activity_nums"` //团队活跃次数 + SignInNums int `json:"sign_in_nums"` //签到次数 + ImActivityNums int `json:"im_activity_nums"` //im活跃次数 + SendRedPackageNums int `json:"send_red_package_nums"` //发红包次数 + EggEnergyExchangeAccountBalance int `json:"egg_energy_exchange_account_balance"` //蛋蛋能量兑换余额数量 + AccountBalanceExchangeEggEnergyNums int `json:"account_balance_exchange_egg_energy_nums"` //余额兑换蛋蛋能量数量 + SendCircleOfFriendNums int `json:"send_circle_of_friend_nums"` //发朋友圈次数 + ForumCommentsNums int `json:"forum_comments_nums"` //论坛评论次数 + CollegeLearningNums int `json:"college_learning_nums"` //学院学习次数 + ViolateNums int `json:"violate_nums"` //违规次数 + BrowseInterfaceNums int `json:"browse_interface_nums"` //浏览界面次数 + PersonAddActivityValue int `json:"person_add_activity_value"` //个人活跃积分 +} diff --git a/app/router/router.go b/app/router/router.go index 32a9173..a0f24a0 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -129,6 +129,13 @@ func rInstitutionalManagement(r *gin.RouterGroup) { //制度管理 rPlatformRevenue.POST("/platformRevenueList", egg_energy.ListPlatformRevenue) rPlatformRevenue.POST("/platformRevenueAdd", egg_energy.AddPlatformRevenue) } + rEggPoint := rEggEnergy.Group("/eggPoint") + { + rEggPoint.POST("/userEggIndex", egg_energy.UserEggIndex) + rEggPoint.POST("/statisticsUserEggIndex", egg_energy.StatisticsUserEggIndex) + rEggPoint.POST("/userEggFlow", egg_energy.UserEggFlow) + rEggPoint.POST("/manualScore", egg_energy.ManualScore) + } } } diff --git a/app/svc/egg_energy/svc_egg_energy.go b/app/svc/egg_energy/svc_egg_energy.go new file mode 100644 index 0000000..b5791d6 --- /dev/null +++ b/app/svc/egg_energy/svc_egg_energy.go @@ -0,0 +1,1377 @@ +package egg_energy + +import ( + md2 "applet/app/md/institutional_management/egg_energy" + "applet/app/utils" + "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "context" + "encoding/json" + "errors" + "fmt" + "github.com/olivere/elastic/v7" + "strconv" + "strings" +) + +// 查询Elasticsearch并返回结果 +func QueryElasticsearch(req md2.UserEggFlowReq, indexName string) (resp []md2.UserEggFlowReqRespList, total int64, err error) { + // 构建查询条件 + boolQuery := elastic.NewBoolQuery() + + if req.ScoreValueStart != "" && req.ScoreValueEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("score_value").Gte(req.ScoreValueStart).Lte(req.ScoreValueEnd)) + } + if req.EcpmStart != "" && req.EcpmEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("ecpm").Gte(req.EcpmStart).Lte(req.EcpmEnd)) + } + if req.InviteUserNumsStart != "" && req.InviteUserNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("invite_user_nums").Gte(req.InviteUserNumsStart).Lte(req.InviteUserNumsEnd)) + } + if req.TeamActivityNumsStart != "" && req.TeamActivityNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("team_activity_nums").Gte(req.TeamActivityNumsStart).Lte(req.TeamActivityNumsEnd)) + } + if req.SignInNumsStart != "" && req.SignInNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("sign_in_nums").Gte(req.SignInNumsStart).Lte(req.SignInNumsEnd)) + } + if req.ImActivityNumsStart != "" && req.ImActivityNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("im_activity_nums").Gte(req.ImActivityNumsStart).Lte(req.ImActivityNumsEnd)) + } + if req.SendRedPackageNumsStart != "" && req.SendRedPackageNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("send_red_package_nums").Gte(req.SendRedPackageNumsStart).Lte(req.SendRedPackageNumsEnd)) + } + if req.EggEnergyExchangeAccountBalanceStart != "" && req.EggEnergyExchangeAccountBalanceEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("egg_energy_exchange_account_balance").Gte(req.EggEnergyExchangeAccountBalanceStart).Lte(req.EggEnergyExchangeAccountBalanceEnd)) + } + if req.AccountBalanceExchangeEggEnergyNumsStart != "" && req.AccountBalanceExchangeEggEnergyNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("account_balance_exchange_egg_energy_nums").Gte(req.AccountBalanceExchangeEggEnergyNumsStart).Lte(req.AccountBalanceExchangeEggEnergyNumsEnd)) + } + if req.SendCircleOfFriendNumsStart != "" && req.SendCircleOfFriendNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("send_circle_of_friend_nums").Gte(req.SendCircleOfFriendNumsStart).Lte(req.SendCircleOfFriendNumsEnd)) + } + if req.ForumCommentsNumsStart != "" && req.ForumCommentsNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("forum_comments_nums").Gte(req.ForumCommentsNumsStart).Lte(req.ForumCommentsNumsEnd)) + } + if req.CollegeLearningNumsStart != "" && req.CollegeLearningNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("college_learning_nums").Gte(req.CollegeLearningNumsStart).Lte(req.CollegeLearningNumsEnd)) + } + if req.ViolateNumsStart != "" && req.ViolateNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("violate_nums").Gte(req.ViolateNumsStart).Lte(req.ViolateNumsEnd)) + } + if req.BrowseInterfaceNumsStart != "" && req.BrowseInterfaceNumsEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("browse_interface_nums").Gte(req.BrowseInterfaceNumsStart).Lte(req.BrowseInterfaceNumsEnd)) + } + if req.PersonAddActivityValueStart != "" && req.PersonAddActivityValueEnd != "" { + boolQuery = boolQuery.Filter(elastic.NewRangeQuery("person_add_activity_value").Gte(req.PersonAddActivityValueStart).Lte(req.PersonAddActivityValueEnd)) + } + + // 执行查询 + searchResult, err := es.EsClient.Search(). + Index(indexName). + Query(boolQuery). + From((req.Page - 1) * req.PageSize).Size(req.PageSize). + Pretty(true). + Do(context.Background()) + + if err != nil { + return + } + + // 检查是否有结果 + if searchResult.Hits.TotalHits.Value == 0 { + return + } + + // 解析结果 + for _, hit := range searchResult.Hits.Hits { + var doc md2.UserEggFlowReqRespList + err = json.Unmarshal(hit.Source, &doc) + if err != nil { + return + } + resp = append(resp, doc) + } + total = searchResult.Hits.TotalHits.Value + return +} + +// StatisticsUserEggScoreValueRange 统计用户蛋蛋分范围 +func StatisticsUserEggScoreValueRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("score_value") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + newAggs := elastic.NewHistogramAggregation().Field("score_value").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + var tempTotalDocCount int64 + var endStart, endEnd string + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + if bucket.Key <= stdDeviation { + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } else { + bucketValue := bucket.Key + if tempTotalDocCount == 0 { + endStart = utils.Float64ToStr(bucketValue) + } + tempTotalDocCount += bucket.DocCount + endEnd = utils.Float64ToStr(bucketValue) + } + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.AnyToString(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + if tempTotalDocCount > 0 { + temp, _ := Operate(tempTotalDocCount, totalCount) + resp = append(resp, map[string]string{ + "key": endStart + " ~ " + endEnd + " 元", + "value": utils.Float64ToStrPrec10(temp), + }) + } + } + return resp, nil +} + +// StatisticsUserEggKindProportion 统计用户蛋蛋分"评比类型"占比 +func StatisticsUserEggKindProportion(esIndexName string) (result []map[string]interface{}, err error) { + var res *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + aggs := elastic.NewTermsAggregation().Field("score_value_kind") + res, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("terms", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return result, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + agg, _ := res.Aggregations.Terms("terms") + var total float64 + for _, bucket := range agg.Buckets { + var tmp = map[string]interface{}{} + bucketValue := bucket.Key + tmp["key"] = bucketValue + tmp["count"] = bucket.DocCount + switch bucketValue { + case 1: + tmp["name"] = "人工" + break + case 2: + tmp["name"] = "自动" + break + default: + tmp["name"] = "未知" + } + result = append(result, tmp) + total += utils.AnyToFloat64(bucket.DocCount) + } + for _, value := range result { + value["proportion"] = utils.AnyToString(utils.AnyToFloat64(value["count"]) / total) + } + return result, nil +} + +// StatisticsUserEggEcpmRange 统计用户"ecpm"范围 +func StatisticsUserEggEcpmRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("ecpm") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("ecpm").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggInviteUserNumsRange 统计用户"拉新人数"范围 +func StatisticsUserEggInviteUserNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("invite_user_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("invite_user_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggTeamActivityNumsRange 统计用户"团队活跃次数"范围 +func StatisticsUserEggTeamActivityNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("team_activity_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("team_activity_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggSignInNumsRange 统计用户"签到次数"范围 +func StatisticsUserEggSignInNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("sign_in_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("sign_in_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggSendRedPackageNumsRange 统计用户"发红包次数"范围 +func StatisticsUserEggSendRedPackageNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("send_red_package_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("send_red_package_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggEggEnergyExchangeAccountBalanceRange 统计用户"蛋蛋能量兑换余额数量"范围 +func StatisticsUserEggEggEnergyExchangeAccountBalanceRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("account_balance_exchange_egg_energy_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("account_balance_exchange_egg_energy_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange 统计用户"余额兑换蛋蛋能量数量"范围 +func StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("egg_energy_exchange_account_balance") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("egg_energy_exchange_account_balance").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggSendCircleOfFriendNumsRange 统计用户"发朋友圈次数"范围 +func StatisticsUserEggSendCircleOfFriendNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("send_circle_of_friend_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("send_circle_of_friend_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggForumCommentsNumsRange 统计用户"论坛评论次数"范围 +func StatisticsUserEggForumCommentsNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("forum_comments_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("forum_comments_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggCollegeLearningNumsRange 统计用户"学院学习次数"范围 +func StatisticsUserEggCollegeLearningNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("college_learning_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("college_learning_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggViolateNumsRange 统计用户"违规次数"范围 +func StatisticsUserEggViolateNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("violate_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("violate_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggBrowseInterfaceNumsRange 统计用户"浏览界面次数"范围 +func StatisticsUserEggBrowseInterfaceNumsRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("browse_interface_nums") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("browse_interface_nums").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +// StatisticsUserEggPersonAddActivityValueRange 统计用户"个人活跃积分增量值"范围 +func StatisticsUserEggPersonAddActivityValueRange(esIndexName string) (resp []map[string]string, err error) { + resp = []map[string]string{} + var result *elastic.SearchResult + boolQuery := elastic.NewBoolQuery().Must() // 创建bool查询 + + // 1、 创建 extended_stats 高级统计 + aggs := elastic.NewExtendedStatsAggregation().Field("person_add_activity_value") + result, err = es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", aggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + + // 使用Cardinality函数和前面定义的聚合条件名称,查询结果 + agg, found := result.Aggregations.ExtendedStats("result") + if !found { + // 打印结果,注意:这里使用的是取值运算符 + return resp, errors.New("未聚合出数据") + } + + if agg.StdDeviation != nil && *agg.StdDeviation != 0 { + //2、histogram 直方图聚合 + stdDeviation := *agg.StdDeviation //标准平方差 + min := *agg.Min //最小值 + max := *agg.Max //最大值 + avg := *agg.Avg //平均数 + totalCount := agg.Count //总数 + discreteCoefficient := stdDeviation / avg //离散系数 + if stdDeviation < avg { + //TODO::如果标准差相对较小,而平均值较大,离散系数可能会导致较大的间隔,直接使用标准差或其他更合适的值作为间隔。 + discreteCoefficient = stdDeviation + } + newAggs := elastic.NewHistogramAggregation().Field("person_add_activity_value").Interval(discreteCoefficient).ExtendedBounds(min, max) + searchResult, err := es.EsClient.Search(). + Index(esIndexName). + TrackTotalHits(true). + Query(boolQuery). // 设置查询条件 + Aggregation("result", newAggs). // 设置聚合条件,并为聚合条件设置一个名字 + Size(0). // 设置分页参数 - 每页大小,设置为0,代表不返回搜索结果,仅返回聚合分析结果 + Pretty(true). // 返回可读的json格式 + Do(context.Background()) + if err != nil { + return resp, err + } + // 使用Terms函数和前面定义的聚合条件名称,查询结果 + newAgg, found := searchResult.Aggregations.Histogram("result") + if !found { + return resp, errors.New("未聚合出数据") + } + + // 3、组装数据 + var keys []string + var values []int64 + for _, bucket := range newAgg.Buckets { + // 每一个桶都有一个key值,其实就是分组的值,可以理解为SQL的group by值 + bucketValue := bucket.Key + keys = append(keys, utils.Float64ToStr(bucketValue)) + values = append(values, bucket.DocCount) + } + + for k, v := range keys { + value, _ := Operate(values[k], totalCount) + if k+1 == len(keys) { + resp = append(resp, map[string]string{ + "key": v + " ~ " + utils.Float64ToStr(max) + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } else { + resp = append(resp, map[string]string{ + "key": v + " ~ " + keys[k+1] + " 元", + "value": utils.Float64ToStrPrec10(value), + }) + } + } + } + return resp, nil +} + +func GetYearsAndWeeks() (resp map[string][]string, err error) { + // 1、 获取到所有的索引 + indices, err := es.GetIndexFromAlias(md.EggEnergyUserEggScoreEsAlias) + if err != nil { + return nil, err + } + + //2、组装数据 + resp = map[string][]string{} + for _, index := range indices { + // 分割字符串 + parts := strings.Split(index, "_") + + // 提取 2024 和 46 + resp[parts[len(parts)-1][:4]] = append(resp[parts[len(parts)-1][:4]], parts[len(parts)-1][4:]) + } + return +} + +func GetYearsAndWeekStr(esIndexName string) (string, string) { + parts := strings.Split(esIndexName, "_") + return parts[len(parts)-1][:4], parts[len(parts)-1][4:] +} + +// Operate 除运算保留10位小数 +func Operate(num1, num2 int64) (float64, error) { + value, err := strconv.ParseFloat(fmt.Sprintf("%.10f", float64(num1)/float64(num2)), 64) + if err != nil { + return 0, err + } + return value, nil +} diff --git a/app/task/svc/svc_egg_energy_user_egg_score_auto_create_es_index.go b/app/task/svc/svc_egg_energy_user_egg_score_auto_create_es_index.go new file mode 100644 index 0000000..d763b24 --- /dev/null +++ b/app/task/svc/svc_egg_energy_user_egg_score_auto_create_es_index.go @@ -0,0 +1,46 @@ +package svc + +import ( + "applet/app/utils" + "applet/app/utils/logx" + "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "fmt" + "time" +) + +// EggEnergyUserEggScoreAutoCreateEsIndex 蛋蛋能量-自动创建蛋蛋分elasticsearch索引 +func EggEnergyUserEggScoreAutoCreateEsIndex() { + fmt.Println("svc_egg_energy_user_egg_score_auto_create_es_index...") + defer func() { + if err := recover(); err != nil { + fmt.Println(err) + return + } + }() + + now := time.Now() + fmt.Println(now.Hour()) + if !(now.Hour() >= 0 && now.Hour() < 2) { + //TODO::只在凌晨一点 ~ 凌晨 2 点运行 + return + } + + //1、获取当前为本年第几周 + year, week := now.ISOWeek() + esIndex := md.EggEnergyUserEggScoreEsAlias + "_" + utils.IntToStr(year) + utils.IntToStr(week) + nowEsIndex, err := es.GetLatestIndexFromAlias(md.EggEnergyUserEggScoreEsAlias) + if err != nil { + logx.Warn("EggEnergyUserEggScoreAutoCreateEsIndex:::", err) + return + } + + if esIndex != nowEsIndex { + //2、创建新的索引 + err = es.CreateIndexIfNotExists(esIndex, md.EggEnergyUserEggScoreEsMapping) + if err != nil { + logx.Warn("EggEnergyUserEggScoreAutoCreateEsIndex:::", err) + } + } + return +} diff --git a/app/task/svc/utils_test.go b/app/task/svc/utils_test.go new file mode 100644 index 0000000..1aeb7d8 --- /dev/null +++ b/app/task/svc/utils_test.go @@ -0,0 +1,12 @@ +package svc + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "testing" +) + +func TestEggEnergyUserEggScoreAutoCreateEsIndex(t *testing.T) { + es.Init("http://120.55.48.175:9200", "elastic", "fnuo123") + EggEnergyUserEggScoreAutoCreateEsIndex() + //fmt.Printf("esIndex ==> %+v \n\n", index) +} diff --git a/app/utils/convert.go b/app/utils/convert.go index a638d37..bb19d46 100644 --- a/app/utils/convert.go +++ b/app/utils/convert.go @@ -276,6 +276,9 @@ func Float64ToStr(f float64) string { func Float64ToStrPrec1(f float64) string { return strconv.FormatFloat(f, 'f', 1, 64) } +func Float64ToStrPrec10(f float64) string { + return strconv.FormatFloat(f, 'f', 10, 64) +} func Float32ToStr(f float32) string { return Float64ToStr(float64(f)) diff --git a/docs/docs.go b/docs/docs.go index 1adf59f..443661a 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -233,6 +233,147 @@ const docTemplate = `{ } } }, + "/api/institutionalManagement/eggEnergy/eggPoint/manualScore": { + "post": { + "description": "蛋蛋分管理(人工打分)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "蛋蛋能量" + ], + "summary": "制度中心-蛋蛋能量-蛋蛋分管理(人工打分)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.ManualScoreReq" + } + } + ], + "responses": { + "200": { + "description": "成功返回", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/institutionalManagement/eggEnergy/eggPoint/statisticsUserEggIndex": { + "post": { + "description": "蛋蛋分管理(着陆页数据分析)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "蛋蛋能量" + ], + "summary": "制度中心-蛋蛋能量-蛋蛋分管理(着陆页数据分析)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.StatisticsEggPointReq" + } + } + ], + "responses": { + "200": { + "description": "成功返回", + "schema": { + "$ref": "#/definitions/md.StatisticsEggPointResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/institutionalManagement/eggEnergy/eggPoint/userEggFlow": { + "post": { + "description": "蛋蛋分管理(用户数据列表)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "蛋蛋能量" + ], + "summary": "制度中心-蛋蛋能量-蛋蛋分管理(用户数据列表)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UserEggFlowReq" + } + } + ], + "responses": { + "200": { + "description": "成功返回", + "schema": { + "$ref": "#/definitions/md.UserEggFlowReqResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/institutionalManagement/eggEnergy/getBasic": { "get": { "description": "基础设置(获取)", @@ -3074,6 +3215,19 @@ const docTemplate = `{ } } }, + "md.ManualScoreReq": { + "type": "object", + "properties": { + "index_id": { + "description": "文档id", + "type": "string" + }, + "score": { + "type": "string", + "example": "分数" + } + } + }, "md.NewUserRedPackageGetBasicResp": { "type": "object", "properties": { @@ -3478,6 +3632,190 @@ const docTemplate = `{ } } }, + "md.StatisticsEggPointReq": { + "type": "object", + "properties": { + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + } + } + }, + "md.StatisticsEggPointResp": { + "type": "object", + "properties": { + "statistics_user_egg_account_balance_exchange_egg_energy_nums_range": { + "description": "统计用户\"余额兑换蛋蛋能量数量\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_browse_interface_nums_range": { + "description": "统计用户\"浏览界面次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_college_learning_nums_range": { + "description": "统计用户\"学院学习次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_ecpm_range": { + "description": "统计用户\"ecpm\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_egg_energy_exchange_account_balance_range": { + "description": "统计用户\"蛋蛋能量兑换余额数量\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_forum_comments_nums_range": { + "description": "统计用户\"论坛评论次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_invite_user_nums_range": { + "description": "统计用户\"拉新人数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_kind_proportion": { + "description": "统计用户蛋蛋分\"评比类型\"占比", + "type": "array", + "items": { + "type": "object", + "additionalProperties": true + } + }, + "statistics_user_egg_person_add_activity_value_range": { + "description": "统计用户\"个人活跃积分增量值\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_score_value_range": { + "description": "统计用户蛋蛋分范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_send_circle_of_friend_nums_range": { + "description": "统计用户\"发朋友圈次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_send_red_package_nums_range": { + "description": "统计用户\"发红包次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_sign_in_nums_range": { + "description": "统计用户\"签到次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_team_activity_nums_range": { + "description": "统计用户\"团队活跃次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_violate_nums_range": { + "description": "统计用户\"违规次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + }, + "year_list": { + "description": "年份\u0026\u0026周份列表", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, "md.SubUser": { "type": "object", "properties": { @@ -3720,6 +4058,317 @@ const docTemplate = `{ } } }, + "md.UserEggFlowReq": { + "type": "object", + "properties": { + "account_balance_exchange_egg_energy_nums_end": { + "type": "string", + "example": "余额兑换蛋蛋能量数量-结束值" + }, + "account_balance_exchange_egg_energy_nums_start": { + "type": "string", + "example": "余额兑换蛋蛋能量数量-起始值" + }, + "browse_interface_nums_end": { + "type": "string", + "example": "浏览界面次数-结束值" + }, + "browse_interface_nums_start": { + "type": "string", + "example": "浏览界面次数-起始值" + }, + "college_learning_nums_end": { + "type": "string", + "example": "学院学习次数-结束值" + }, + "college_learning_nums_start": { + "type": "string", + "example": "学院学习次数-起始值" + }, + "ecpm_end": { + "type": "string", + "example": "ecpm-结束值" + }, + "ecpm_start": { + "type": "string", + "example": "ecpm-起始值" + }, + "egg_energy_exchange_account_balance_end": { + "type": "string", + "example": "蛋蛋能量兑换余额数量-结束值" + }, + "egg_energy_exchange_account_balance_start": { + "type": "string", + "example": "蛋蛋能量兑换余额数量-起始值" + }, + "forum_comments_nums_end": { + "type": "string", + "example": "论坛评论次数-结束值" + }, + "forum_comments_nums_start": { + "type": "string", + "example": "论坛评论次数-起始值" + }, + "im_activity_nums_end": { + "type": "string", + "example": "im活跃次数-结束值" + }, + "im_activity_nums_start": { + "type": "string", + "example": "im活跃次数-起始值" + }, + "invite_user_nums_end": { + "type": "string", + "example": "拉新人数-结束值" + }, + "invite_user_nums_start": { + "type": "string", + "example": "拉新人数-起始值" + }, + "page": { + "description": "页数", + "type": "integer" + }, + "page_size": { + "description": "每页大小", + "type": "integer" + }, + "person_add_activity_value_end": { + "type": "string", + "example": "个人活跃积分-结束值" + }, + "person_add_activity_value_start": { + "type": "string", + "example": "个人活跃积分-起始值" + }, + "score_value_end": { + "type": "string", + "example": "蛋蛋分-结束值" + }, + "score_value_kind": { + "description": "评分类型(0:未知 1:人工 2:系统)", + "type": "integer" + }, + "score_value_start": { + "type": "string", + "example": "蛋蛋分-起始值" + }, + "send_circle_of_friend_nums_end": { + "type": "string", + "example": "发朋友圈次数-结束值" + }, + "send_circle_of_friend_nums_start": { + "type": "string", + "example": "发朋友圈次数-起始值" + }, + "send_red_package_nums_end": { + "type": "string", + "example": "发红包次数-结束值" + }, + "send_red_package_nums_start": { + "type": "string", + "example": "发红包次数-起始值" + }, + "sign_in_nums_end": { + "type": "string", + "example": "签到次数-结束值" + }, + "sign_in_nums_start": { + "type": "string", + "example": "签到次数-起始值" + }, + "team-activity-nums-end": { + "type": "string", + "example": "团队活跃次数-结束值" + }, + "team_activity_nums_start": { + "type": "string", + "example": "团队活跃次数-起始值" + }, + "violate_nums_end": { + "type": "string", + "example": "违规次数-结束值" + }, + "violate_nums_start": { + "type": "string", + "example": "违规次数-起始值" + }, + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + } + } + }, + "md.UserEggFlowReqResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.UserEggFlowReqRespList" + } + }, + "page": { + "description": "页数", + "type": "integer" + }, + "page_size": { + "description": "每页大小", + "type": "integer" + }, + "total": { + "description": "总数量", + "type": "integer" + }, + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + } + } + }, + "md.UserEggFlowReqRespList": { + "type": "object", + "properties": { + "account_balance_exchange_egg_energy_nums": { + "description": "余额兑换蛋蛋能量数量", + "type": "integer" + }, + "browse_interface_nums": { + "description": "浏览界面次数", + "type": "integer" + }, + "college_learning_nums": { + "description": "学院学习次数", + "type": "integer" + }, + "ecpm": { + "description": "ecpm", + "type": "number" + }, + "egg_energy_exchange_account_balance": { + "description": "蛋蛋能量兑换余额数量", + "type": "integer" + }, + "forum_comments_nums": { + "description": "论坛评论次数", + "type": "integer" + }, + "im_activity_nums": { + "description": "im活跃次数", + "type": "integer" + }, + "index_id": { + "description": "文档id", + "type": "string" + }, + "invite_user_nums": { + "description": "拉新人数", + "type": "integer" + }, + "person_add_activity_value": { + "description": "个人活跃积分", + "type": "integer" + }, + "score_value": { + "description": "蛋蛋分-起始值", + "type": "number" + }, + "score_value_kind": { + "description": "评分类型(0:未知 1:人工 2:系统)", + "type": "integer" + }, + "send_circle_of_friend_nums": { + "description": "发朋友圈次数", + "type": "integer" + }, + "send_red_package_nums": { + "description": "发红包次数", + "type": "integer" + }, + "sign_in_nums": { + "description": "签到次数", + "type": "integer" + }, + "team_activity_nums": { + "description": "团队活跃次数", + "type": "integer" + }, + "violate_nums": { + "description": "违规次数", + "type": "integer" + } + } + }, + "md.UserEggIndexReq": { + "type": "object", + "properties": { + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + } + } + }, + "md.UserEggIndexResp": { + "type": "object", + "properties": { + "egg_energy_user_egg_index_weight": { + "description": "蛋蛋分系数权重", + "allOf": [ + { + "$ref": "#/definitions/model.EggEnergyUserEggIndexWeight" + } + ] + }, + "statistics_user_egg_kind_proportion": { + "description": "统计用户蛋蛋分\"评比类型\"占比", + "type": "array", + "items": { + "type": "object", + "additionalProperties": true + } + }, + "statistics_user_egg_score_value_range": { + "description": "统计用户蛋蛋分范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + }, + "year_list": { + "description": "年份\u0026\u0026周份列表", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, "md.UserVirtualCoinFlow": { "type": "object", "properties": { @@ -3853,6 +4502,62 @@ const docTemplate = `{ "example": "货币类型名称" } } + }, + "model.EggEnergyUserEggIndexWeight": { + "type": "object", + "properties": { + "account_balance_exchange_egg_energy_nums": { + "type": "string" + }, + "browse_interface_nums": { + "type": "string" + }, + "college_learning_nums": { + "type": "string" + }, + "create_at": { + "type": "string" + }, + "ecpm": { + "type": "string" + }, + "egg_energy_exchange_account_balance": { + "type": "string" + }, + "forum_comments_nums": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "im_activity_nums": { + "type": "string" + }, + "invite_user_nums": { + "type": "string" + }, + "person_add_activity_value": { + "type": "string" + }, + "send_circle_of_friend_nums": { + "type": "string" + }, + "send_red_package_nums": { + "type": "string" + }, + "sign_in_nums": { + "type": "string" + }, + "team_activity_nums": { + "type": "string" + }, + "update_at": { + "type": "string" + }, + "violate_nums": { + "type": "string" + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.json b/docs/swagger.json index f1e6e51..4acfaf5 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -226,6 +226,147 @@ } } }, + "/api/institutionalManagement/eggEnergy/eggPoint/manualScore": { + "post": { + "description": "蛋蛋分管理(人工打分)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "蛋蛋能量" + ], + "summary": "制度中心-蛋蛋能量-蛋蛋分管理(人工打分)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.ManualScoreReq" + } + } + ], + "responses": { + "200": { + "description": "成功返回", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/institutionalManagement/eggEnergy/eggPoint/statisticsUserEggIndex": { + "post": { + "description": "蛋蛋分管理(着陆页数据分析)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "蛋蛋能量" + ], + "summary": "制度中心-蛋蛋能量-蛋蛋分管理(着陆页数据分析)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.StatisticsEggPointReq" + } + } + ], + "responses": { + "200": { + "description": "成功返回", + "schema": { + "$ref": "#/definitions/md.StatisticsEggPointResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/institutionalManagement/eggEnergy/eggPoint/userEggFlow": { + "post": { + "description": "蛋蛋分管理(用户数据列表)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "蛋蛋能量" + ], + "summary": "制度中心-蛋蛋能量-蛋蛋分管理(用户数据列表)", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.UserEggFlowReq" + } + } + ], + "responses": { + "200": { + "description": "成功返回", + "schema": { + "$ref": "#/definitions/md.UserEggFlowReqResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/institutionalManagement/eggEnergy/getBasic": { "get": { "description": "基础设置(获取)", @@ -3067,6 +3208,19 @@ } } }, + "md.ManualScoreReq": { + "type": "object", + "properties": { + "index_id": { + "description": "文档id", + "type": "string" + }, + "score": { + "type": "string", + "example": "分数" + } + } + }, "md.NewUserRedPackageGetBasicResp": { "type": "object", "properties": { @@ -3471,6 +3625,190 @@ } } }, + "md.StatisticsEggPointReq": { + "type": "object", + "properties": { + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + } + } + }, + "md.StatisticsEggPointResp": { + "type": "object", + "properties": { + "statistics_user_egg_account_balance_exchange_egg_energy_nums_range": { + "description": "统计用户\"余额兑换蛋蛋能量数量\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_browse_interface_nums_range": { + "description": "统计用户\"浏览界面次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_college_learning_nums_range": { + "description": "统计用户\"学院学习次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_ecpm_range": { + "description": "统计用户\"ecpm\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_egg_energy_exchange_account_balance_range": { + "description": "统计用户\"蛋蛋能量兑换余额数量\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_forum_comments_nums_range": { + "description": "统计用户\"论坛评论次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_invite_user_nums_range": { + "description": "统计用户\"拉新人数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_kind_proportion": { + "description": "统计用户蛋蛋分\"评比类型\"占比", + "type": "array", + "items": { + "type": "object", + "additionalProperties": true + } + }, + "statistics_user_egg_person_add_activity_value_range": { + "description": "统计用户\"个人活跃积分增量值\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_score_value_range": { + "description": "统计用户蛋蛋分范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_send_circle_of_friend_nums_range": { + "description": "统计用户\"发朋友圈次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_send_red_package_nums_range": { + "description": "统计用户\"发红包次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_sign_in_nums_range": { + "description": "统计用户\"签到次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_team_activity_nums_range": { + "description": "统计用户\"团队活跃次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "statistics_user_egg_violate_nums_range": { + "description": "统计用户\"违规次数\"范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + }, + "year_list": { + "description": "年份\u0026\u0026周份列表", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, "md.SubUser": { "type": "object", "properties": { @@ -3713,6 +4051,317 @@ } } }, + "md.UserEggFlowReq": { + "type": "object", + "properties": { + "account_balance_exchange_egg_energy_nums_end": { + "type": "string", + "example": "余额兑换蛋蛋能量数量-结束值" + }, + "account_balance_exchange_egg_energy_nums_start": { + "type": "string", + "example": "余额兑换蛋蛋能量数量-起始值" + }, + "browse_interface_nums_end": { + "type": "string", + "example": "浏览界面次数-结束值" + }, + "browse_interface_nums_start": { + "type": "string", + "example": "浏览界面次数-起始值" + }, + "college_learning_nums_end": { + "type": "string", + "example": "学院学习次数-结束值" + }, + "college_learning_nums_start": { + "type": "string", + "example": "学院学习次数-起始值" + }, + "ecpm_end": { + "type": "string", + "example": "ecpm-结束值" + }, + "ecpm_start": { + "type": "string", + "example": "ecpm-起始值" + }, + "egg_energy_exchange_account_balance_end": { + "type": "string", + "example": "蛋蛋能量兑换余额数量-结束值" + }, + "egg_energy_exchange_account_balance_start": { + "type": "string", + "example": "蛋蛋能量兑换余额数量-起始值" + }, + "forum_comments_nums_end": { + "type": "string", + "example": "论坛评论次数-结束值" + }, + "forum_comments_nums_start": { + "type": "string", + "example": "论坛评论次数-起始值" + }, + "im_activity_nums_end": { + "type": "string", + "example": "im活跃次数-结束值" + }, + "im_activity_nums_start": { + "type": "string", + "example": "im活跃次数-起始值" + }, + "invite_user_nums_end": { + "type": "string", + "example": "拉新人数-结束值" + }, + "invite_user_nums_start": { + "type": "string", + "example": "拉新人数-起始值" + }, + "page": { + "description": "页数", + "type": "integer" + }, + "page_size": { + "description": "每页大小", + "type": "integer" + }, + "person_add_activity_value_end": { + "type": "string", + "example": "个人活跃积分-结束值" + }, + "person_add_activity_value_start": { + "type": "string", + "example": "个人活跃积分-起始值" + }, + "score_value_end": { + "type": "string", + "example": "蛋蛋分-结束值" + }, + "score_value_kind": { + "description": "评分类型(0:未知 1:人工 2:系统)", + "type": "integer" + }, + "score_value_start": { + "type": "string", + "example": "蛋蛋分-起始值" + }, + "send_circle_of_friend_nums_end": { + "type": "string", + "example": "发朋友圈次数-结束值" + }, + "send_circle_of_friend_nums_start": { + "type": "string", + "example": "发朋友圈次数-起始值" + }, + "send_red_package_nums_end": { + "type": "string", + "example": "发红包次数-结束值" + }, + "send_red_package_nums_start": { + "type": "string", + "example": "发红包次数-起始值" + }, + "sign_in_nums_end": { + "type": "string", + "example": "签到次数-结束值" + }, + "sign_in_nums_start": { + "type": "string", + "example": "签到次数-起始值" + }, + "team-activity-nums-end": { + "type": "string", + "example": "团队活跃次数-结束值" + }, + "team_activity_nums_start": { + "type": "string", + "example": "团队活跃次数-起始值" + }, + "violate_nums_end": { + "type": "string", + "example": "违规次数-结束值" + }, + "violate_nums_start": { + "type": "string", + "example": "违规次数-起始值" + }, + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + } + } + }, + "md.UserEggFlowReqResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/md.UserEggFlowReqRespList" + } + }, + "page": { + "description": "页数", + "type": "integer" + }, + "page_size": { + "description": "每页大小", + "type": "integer" + }, + "total": { + "description": "总数量", + "type": "integer" + }, + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + } + } + }, + "md.UserEggFlowReqRespList": { + "type": "object", + "properties": { + "account_balance_exchange_egg_energy_nums": { + "description": "余额兑换蛋蛋能量数量", + "type": "integer" + }, + "browse_interface_nums": { + "description": "浏览界面次数", + "type": "integer" + }, + "college_learning_nums": { + "description": "学院学习次数", + "type": "integer" + }, + "ecpm": { + "description": "ecpm", + "type": "number" + }, + "egg_energy_exchange_account_balance": { + "description": "蛋蛋能量兑换余额数量", + "type": "integer" + }, + "forum_comments_nums": { + "description": "论坛评论次数", + "type": "integer" + }, + "im_activity_nums": { + "description": "im活跃次数", + "type": "integer" + }, + "index_id": { + "description": "文档id", + "type": "string" + }, + "invite_user_nums": { + "description": "拉新人数", + "type": "integer" + }, + "person_add_activity_value": { + "description": "个人活跃积分", + "type": "integer" + }, + "score_value": { + "description": "蛋蛋分-起始值", + "type": "number" + }, + "score_value_kind": { + "description": "评分类型(0:未知 1:人工 2:系统)", + "type": "integer" + }, + "send_circle_of_friend_nums": { + "description": "发朋友圈次数", + "type": "integer" + }, + "send_red_package_nums": { + "description": "发红包次数", + "type": "integer" + }, + "sign_in_nums": { + "description": "签到次数", + "type": "integer" + }, + "team_activity_nums": { + "description": "团队活跃次数", + "type": "integer" + }, + "violate_nums": { + "description": "违规次数", + "type": "integer" + } + } + }, + "md.UserEggIndexReq": { + "type": "object", + "properties": { + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + } + } + }, + "md.UserEggIndexResp": { + "type": "object", + "properties": { + "egg_energy_user_egg_index_weight": { + "description": "蛋蛋分系数权重", + "allOf": [ + { + "$ref": "#/definitions/model.EggEnergyUserEggIndexWeight" + } + ] + }, + "statistics_user_egg_kind_proportion": { + "description": "统计用户蛋蛋分\"评比类型\"占比", + "type": "array", + "items": { + "type": "object", + "additionalProperties": true + } + }, + "statistics_user_egg_score_value_range": { + "description": "统计用户蛋蛋分范围", + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "week": { + "type": "string", + "example": "周份" + }, + "year": { + "type": "string", + "example": "年份" + }, + "year_list": { + "description": "年份\u0026\u0026周份列表", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, "md.UserVirtualCoinFlow": { "type": "object", "properties": { @@ -3846,6 +4495,62 @@ "example": "货币类型名称" } } + }, + "model.EggEnergyUserEggIndexWeight": { + "type": "object", + "properties": { + "account_balance_exchange_egg_energy_nums": { + "type": "string" + }, + "browse_interface_nums": { + "type": "string" + }, + "college_learning_nums": { + "type": "string" + }, + "create_at": { + "type": "string" + }, + "ecpm": { + "type": "string" + }, + "egg_energy_exchange_account_balance": { + "type": "string" + }, + "forum_comments_nums": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "im_activity_nums": { + "type": "string" + }, + "invite_user_nums": { + "type": "string" + }, + "person_add_activity_value": { + "type": "string" + }, + "send_circle_of_friend_nums": { + "type": "string" + }, + "send_red_package_nums": { + "type": "string" + }, + "sign_in_nums": { + "type": "string" + }, + "team_activity_nums": { + "type": "string" + }, + "update_at": { + "type": "string" + }, + "violate_nums": { + "type": "string" + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 80b4245..8f5d0be 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -917,6 +917,15 @@ definitions: token: type: string type: object + md.ManualScoreReq: + properties: + index_id: + description: 文档id + type: string + score: + example: 分数 + type: string + type: object md.NewUserRedPackageGetBasicResp: properties: create_at: @@ -1204,6 +1213,135 @@ definitions: description: 查询用户活跃子节点 ID type: integer type: object + md.StatisticsEggPointReq: + properties: + week: + example: 周份 + type: string + year: + example: 年份 + type: string + type: object + md.StatisticsEggPointResp: + properties: + statistics_user_egg_account_balance_exchange_egg_energy_nums_range: + description: 统计用户"余额兑换蛋蛋能量数量"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_browse_interface_nums_range: + description: 统计用户"浏览界面次数"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_college_learning_nums_range: + description: 统计用户"学院学习次数"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_ecpm_range: + description: 统计用户"ecpm"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_egg_energy_exchange_account_balance_range: + description: 统计用户"蛋蛋能量兑换余额数量"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_forum_comments_nums_range: + description: 统计用户"论坛评论次数"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_invite_user_nums_range: + description: 统计用户"拉新人数"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_kind_proportion: + description: 统计用户蛋蛋分"评比类型"占比 + items: + additionalProperties: true + type: object + type: array + statistics_user_egg_person_add_activity_value_range: + description: 统计用户"个人活跃积分增量值"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_score_value_range: + description: 统计用户蛋蛋分范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_send_circle_of_friend_nums_range: + description: 统计用户"发朋友圈次数"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_send_red_package_nums_range: + description: 统计用户"发红包次数"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_sign_in_nums_range: + description: 统计用户"签到次数"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_team_activity_nums_range: + description: 统计用户"团队活跃次数"范围 + items: + additionalProperties: + type: string + type: object + type: array + statistics_user_egg_violate_nums_range: + description: 统计用户"违规次数"范围 + items: + additionalProperties: + type: string + type: object + type: array + week: + example: 周份 + type: string + year: + example: 年份 + type: string + year_list: + additionalProperties: + items: + type: string + type: array + description: 年份&&周份列表 + type: object + type: object md.SubUser: properties: avatar_url: @@ -1360,6 +1498,232 @@ definitions: - $ref: '#/definitions/md.DailyActivityAnalysisTopData' description: 统计信息 type: object + md.UserEggFlowReq: + properties: + account_balance_exchange_egg_energy_nums_end: + example: 余额兑换蛋蛋能量数量-结束值 + type: string + account_balance_exchange_egg_energy_nums_start: + example: 余额兑换蛋蛋能量数量-起始值 + type: string + browse_interface_nums_end: + example: 浏览界面次数-结束值 + type: string + browse_interface_nums_start: + example: 浏览界面次数-起始值 + type: string + college_learning_nums_end: + example: 学院学习次数-结束值 + type: string + college_learning_nums_start: + example: 学院学习次数-起始值 + type: string + ecpm_end: + example: ecpm-结束值 + type: string + ecpm_start: + example: ecpm-起始值 + type: string + egg_energy_exchange_account_balance_end: + example: 蛋蛋能量兑换余额数量-结束值 + type: string + egg_energy_exchange_account_balance_start: + example: 蛋蛋能量兑换余额数量-起始值 + type: string + forum_comments_nums_end: + example: 论坛评论次数-结束值 + type: string + forum_comments_nums_start: + example: 论坛评论次数-起始值 + type: string + im_activity_nums_end: + example: im活跃次数-结束值 + type: string + im_activity_nums_start: + example: im活跃次数-起始值 + type: string + invite_user_nums_end: + example: 拉新人数-结束值 + type: string + invite_user_nums_start: + example: 拉新人数-起始值 + type: string + page: + description: 页数 + type: integer + page_size: + description: 每页大小 + type: integer + person_add_activity_value_end: + example: 个人活跃积分-结束值 + type: string + person_add_activity_value_start: + example: 个人活跃积分-起始值 + type: string + score_value_end: + example: 蛋蛋分-结束值 + type: string + score_value_kind: + description: 评分类型(0:未知 1:人工 2:系统) + type: integer + score_value_start: + example: 蛋蛋分-起始值 + type: string + send_circle_of_friend_nums_end: + example: 发朋友圈次数-结束值 + type: string + send_circle_of_friend_nums_start: + example: 发朋友圈次数-起始值 + type: string + send_red_package_nums_end: + example: 发红包次数-结束值 + type: string + send_red_package_nums_start: + example: 发红包次数-起始值 + type: string + sign_in_nums_end: + example: 签到次数-结束值 + type: string + sign_in_nums_start: + example: 签到次数-起始值 + type: string + team-activity-nums-end: + example: 团队活跃次数-结束值 + type: string + team_activity_nums_start: + example: 团队活跃次数-起始值 + type: string + violate_nums_end: + example: 违规次数-结束值 + type: string + violate_nums_start: + example: 违规次数-起始值 + type: string + week: + example: 周份 + type: string + year: + example: 年份 + type: string + type: object + md.UserEggFlowReqResp: + properties: + list: + items: + $ref: '#/definitions/md.UserEggFlowReqRespList' + type: array + page: + description: 页数 + type: integer + page_size: + description: 每页大小 + type: integer + total: + description: 总数量 + type: integer + week: + example: 周份 + type: string + year: + example: 年份 + type: string + type: object + md.UserEggFlowReqRespList: + properties: + account_balance_exchange_egg_energy_nums: + description: 余额兑换蛋蛋能量数量 + type: integer + browse_interface_nums: + description: 浏览界面次数 + type: integer + college_learning_nums: + description: 学院学习次数 + type: integer + ecpm: + description: ecpm + type: number + egg_energy_exchange_account_balance: + description: 蛋蛋能量兑换余额数量 + type: integer + forum_comments_nums: + description: 论坛评论次数 + type: integer + im_activity_nums: + description: im活跃次数 + type: integer + index_id: + description: 文档id + type: string + invite_user_nums: + description: 拉新人数 + type: integer + person_add_activity_value: + description: 个人活跃积分 + type: integer + score_value: + description: 蛋蛋分-起始值 + type: number + score_value_kind: + description: 评分类型(0:未知 1:人工 2:系统) + type: integer + send_circle_of_friend_nums: + description: 发朋友圈次数 + type: integer + send_red_package_nums: + description: 发红包次数 + type: integer + sign_in_nums: + description: 签到次数 + type: integer + team_activity_nums: + description: 团队活跃次数 + type: integer + violate_nums: + description: 违规次数 + type: integer + type: object + md.UserEggIndexReq: + properties: + week: + example: 周份 + type: string + year: + example: 年份 + type: string + type: object + md.UserEggIndexResp: + properties: + egg_energy_user_egg_index_weight: + allOf: + - $ref: '#/definitions/model.EggEnergyUserEggIndexWeight' + description: 蛋蛋分系数权重 + statistics_user_egg_kind_proportion: + description: 统计用户蛋蛋分"评比类型"占比 + items: + additionalProperties: true + type: object + type: array + statistics_user_egg_score_value_range: + description: 统计用户蛋蛋分范围 + items: + additionalProperties: + type: string + type: object + type: array + week: + example: 周份 + type: string + year: + example: 年份 + type: string + year_list: + additionalProperties: + items: + type: string + type: array + description: 年份&&周份列表 + type: object + type: object md.UserVirtualCoinFlow: properties: after_amount: @@ -1454,6 +1818,43 @@ definitions: example: 货币类型名称 type: string type: object + model.EggEnergyUserEggIndexWeight: + properties: + account_balance_exchange_egg_energy_nums: + type: string + browse_interface_nums: + type: string + college_learning_nums: + type: string + create_at: + type: string + ecpm: + type: string + egg_energy_exchange_account_balance: + type: string + forum_comments_nums: + type: string + id: + type: integer + im_activity_nums: + type: string + invite_user_nums: + type: string + person_add_activity_value: + type: string + send_circle_of_friend_nums: + type: string + send_red_package_nums: + type: string + sign_in_nums: + type: string + team_activity_nums: + type: string + update_at: + type: string + violate_nums: + type: string + type: object host: localhost:4001 info: contact: @@ -1606,6 +2007,99 @@ paths: summary: 制度中心-动态数据-动态数据流水(获取) tags: - 公排管理 + /api/institutionalManagement/eggEnergy/eggPoint/manualScore: + post: + consumes: + - application/json + description: 蛋蛋分管理(人工打分) + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: req + required: true + schema: + $ref: '#/definitions/md.ManualScoreReq' + produces: + - application/json + responses: + "200": + description: 成功返回 + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 制度中心-蛋蛋能量-蛋蛋分管理(人工打分) + tags: + - 蛋蛋能量 + /api/institutionalManagement/eggEnergy/eggPoint/statisticsUserEggIndex: + post: + consumes: + - application/json + description: 蛋蛋分管理(着陆页数据分析) + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: req + required: true + schema: + $ref: '#/definitions/md.StatisticsEggPointReq' + produces: + - application/json + responses: + "200": + description: 成功返回 + schema: + $ref: '#/definitions/md.StatisticsEggPointResp' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 制度中心-蛋蛋能量-蛋蛋分管理(着陆页数据分析) + tags: + - 蛋蛋能量 + /api/institutionalManagement/eggEnergy/eggPoint/userEggFlow: + post: + consumes: + - application/json + description: 蛋蛋分管理(用户数据列表) + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: req + required: true + schema: + $ref: '#/definitions/md.UserEggFlowReq' + produces: + - application/json + responses: + "200": + description: 成功返回 + schema: + $ref: '#/definitions/md.UserEggFlowReqResp' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 制度中心-蛋蛋能量-蛋蛋分管理(用户数据列表) + tags: + - 蛋蛋能量 /api/institutionalManagement/eggEnergy/getBasic: get: consumes: diff --git a/etc/cfg.yml b/etc/cfg.yml index a144434..1240dec 100644 --- a/etc/cfg.yml +++ b/etc/cfg.yml @@ -38,4 +38,15 @@ mq: host: '116.62.62.35' port: '5672' user: 'zhios' - pwd: 'ZHIoscnfnuo123' \ No newline at end of file + pwd: 'ZHIoscnfnuo123' + + # 连接ElasticSearch + #es: + # url: 'http://zhios-es-53m.public.cn-hangzhou.es-serverless.aliyuncs.com:9200' + # user: 'zhios-es-53m' + # pwd: 'ZHIoscnfnuo123@' + +es: + url: 'http://120.55.48.175:9200' + user: 'elastic' + pwd: 'fnuo123' \ No newline at end of file diff --git a/go.mod b/go.mod index ac28abb..1f107b0 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,11 @@ module applet go 1.19 -//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models +replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models -// -//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules +replace code.fnuoos.com/go_rely_warehouse/zyos_go_es.git => E:\company\go_rely_warehouse\zyos_go_es + +replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules require ( github.com/boombuler/barcode v1.0.1 @@ -37,10 +38,12 @@ require ( require ( code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241115090315-a9a84aba8235 code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.3 + code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20230707081910-52e70aa52998 code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/go-sql-driver/mysql v1.8.1 github.com/gocolly/colly v1.2.0 + github.com/olivere/elastic/v7 v7.0.32 github.com/shopspring/decimal v1.3.1 github.com/tidwall/gjson v1.14.1 ) @@ -82,8 +85,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/onsi/ginkgo v1.16.5 // indirect - github.com/onsi/gomega v1.19.0 // indirect + github.com/nxadm/tail v1.4.8 // indirect github.com/pelletier/go-toml/v2 v2.2.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect diff --git a/main.go b/main.go index c4f1741..7917546 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ func init() { cfg.InitLog() // 日志初始化 cfg.InitCache() // 缓存初始化 cfg.InitMq() // 队列初始化 + cfg.InitEs() //ElasticSearch初始化 if cfg.Debug { // 判断是否是debug if err := db.InitDB(cfg.DB); err != nil { // 主数据库初始化 panic(err)