提交 ed0b08d0 编写于 作者: M monomania

1.公众号代码雏形形成 2.需增加图片素材上传调试及调试图文

上级 108c97d6
......@@ -54,7 +54,7 @@ func main() {
//测试分析结果获取及更新
analyService := new(service2.AnalyService)
list := analyService.GetPubDataList("Euro20191206Service", 0, -1)
list := analyService.ListData("Euro20191206Service", 0, -1)
result := &list[0].AnalyResult
analyService.Modify(result)
......
......@@ -14,22 +14,23 @@ LWT=KBjo3NZHBCcMfcnaZ1JXVula6ZKdmthk0DqnddpGOcwxb/d/nr2ULipCnjSsetvzCgwBKwkj7nBL
SERVERID=f35c9b1c268fcc8b58043d36d0dddd26|1575817686|1575815177
[spider]
###matchLevel比赛级别 //0全部,1一级,2足彩,3竞猜,4单场
match_level=0
match_level=4
###执行周期间隔时间
cycle_time=68
[pub]
###执行周期间隔时间
cycle_time=30
[analy]
###推送的主客队选项,
#格式为:时间:选项,时间:选项,时间:选项
#时间只支持设置小时数
#3 只推送主队, 1 只推送平局, 0 只推送客队,-1 全部推送
#示例0-3:-1,4-18:3,19-23:-1,未设置时间段为默认只推送3
team_option=0-3:-1,4-18:3,19-23:3
###使用的算法
###使用的算法,如是推荐到雷速,使用Euro20191212Service,如是推荐到其他平台可暂不使用
al_flag=Euro20191212Service
###处法命中次数
hit_count=3
[leisu]
###执行周期间隔时间
cycle_time=30
###标题模板,为空则使用默认模板.支持格式如下:
#联赛名称{leagueName}
#比赛时间{matchDate}
......
......@@ -4,6 +4,10 @@ import "tesou.io/platform/foot-parent/foot-api/module/analy/pojo"
type AnalyResultVO struct {
pojo.AnalyResult `xorm:"extends"`
/**
联赛名称
*/
LeagueName string
/**
* 主队id
*/
......
package constants
const (
SECTION_NAME = "analy"
)
......@@ -48,9 +48,9 @@ func (this *AnalyService) FindAll() []*entity5.AnalyResult {
4.alName 算法名称,默认为Euro81_616Service ;
5.option 3(只筛选主队),1(只筛选平局),0(只筛选客队)选项
*/
func (this *AnalyService) GetPubDataList(alName string, hitCount int, option int) []*vo.AnalyResultVO {
func (this *AnalyService) ListData(alName string, hitCount int, option int) []*vo.AnalyResultVO {
sql_build := strings.Builder{}
sql_build.WriteString("SELECT ml.`MainTeamId`,ml.`GuestTeamId`,ar.* FROM foot.`t_match_last` ml,foot.`t_analy_result` ar WHERE ml.`Id` = ar.`MatchId` AND ar.`LeisuPubd` IS FALSE AND ar.`MatchDate` > NOW() ")
sql_build.WriteString("SELECT l.`Name` as LeagueName,ml.`MainTeamId`,ml.`GuestTeamId`,ar.* FROM foot.`t_match_last` ml,foot.`t_league` l,foot.`t_analy_result` ar WHERE ml.`LeagueId` = l.`Id` AND ml.`Id` = ar.`MatchId` AND ar.`LeisuPubd` IS FALSE AND ar.`MatchDate` > NOW() ")
if len(alName) > 0 {
sql_build.WriteString(" AND ar.`AlFlag` = '" + alName + "' ")
......
package service
import (
"fmt"
"math"
"reflect"
"strings"
......@@ -24,6 +25,9 @@ func (this *Euro20191212Service) Analy() {
data_list_slice := make([]interface{}, 0)
data_modify_list_slice := make([]interface{}, 0)
for _, v := range matchList {
if strings.EqualFold("沃尔夫斯堡",v.MainTeamId){
fmt.Println("-----------------")
}
stub, result := this.analyStub(v)
if nil == result {
continue
......@@ -46,6 +50,9 @@ func (this *Euro20191212Service) Analy() {
}
func (this *Euro20191212Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult) {
if strings.EqualFold("沃尔夫斯堡",v.MainTeamId){
fmt.Println("-----------------")
}
matchId := v.Id
//声明使用变量
var e616data *entity3.EuroLast
......
package service
import (
"strconv"
"strings"
"tesou.io/platform/foot-parent/foot-api/module/analy/vo"
"tesou.io/platform/foot-parent/foot-core/common/utils"
constants2 "tesou.io/platform/foot-parent/foot-core/module/analy/constants"
"time"
)
/**
发布推荐
*/
type RecommendService struct {
AnalyService
}
/**
###推送的主客队选项,
#格式为:时间:选项,时间:选项,时间:选项
#时间只支持设置小时数
#3 只推送主队, 1 只推送平局, 0 只推送客队,-1 全部推送
#示例0-3:-1,4-19:3,19-23:-1,未设置时间段为默认只推送3
*/
func (this *RecommendService) teamOption() int {
var result int
tempOptionConfig := utils.GetVal(constants2.SECTION_NAME, "team_option")
if len(tempOptionConfig) <= 0 {
//默认返回 主队选项
return 3
}
//当前的小时
currentHour, _ := strconv.Atoi(time.Now().Format("15"))
hourRange_options := strings.Split(tempOptionConfig, ",")
for _, e := range hourRange_options {
h_o := strings.Split(e, ":")
hourRanges := strings.Split(h_o[0], "-")
option, _ := strconv.Atoi(h_o[1])
hourBegin, _ := strconv.Atoi(hourRanges[0])
hourEnd, _ := strconv.Atoi(hourRanges[1])
if hourBegin <= currentHour && currentHour <= hourEnd {
result = option
break;
}
}
return result
}
func (this *RecommendService) ListData() []*vo.AnalyResultVO {
teamOption := this.teamOption()
al_flag := utils.GetVal(constants2.SECTION_NAME, "al_flag")
hit_count_str := utils.GetVal(constants2.SECTION_NAME, "hit_count")
hit_count, _ := strconv.Atoi(hit_count_str)
//获取分析计算出的比赛列表
analyList := this.AnalyService.ListData(al_flag, hit_count, teamOption)
return analyList
}
package constants
const (
SECTION_NAME = "pub"
SECTION_NAME = "leisu"
//登录地址
LOGIN_URL = ""
//比赛信息地址
......
......@@ -20,7 +20,7 @@ import (
发布推荐
*/
type PubService struct {
service.AnalyService
service.RecommendService
MatchPoolService
PubLimitService
PriceService
......@@ -42,49 +42,14 @@ func (this *PubService) CycleTime() int64 {
return result
}
/**
###推送的主客队选项,
#格式为:时间:选项,时间:选项,时间:选项
#时间只支持设置小时数
#3 只推送主队, 1 只推送平局, 0 只推送客队,-1 全部推送
#示例0-3:-1,4-19:3,19-23:-1,未设置时间段为默认只推送3
*/
func (this *PubService) teamOption() int {
var result int
tempOptionConfig := utils.GetVal(constants2.SECTION_NAME, "team_option")
if len(tempOptionConfig) <= 0 {
//默认返回 主队选项
return 3
}
//当前的小时
currentHour, _ := strconv.Atoi(time.Now().Format("15"))
hourRange_options := strings.Split(tempOptionConfig, ",")
for _, e := range hourRange_options {
h_o := strings.Split(e, ":")
hourRanges := strings.Split(h_o[0], "-")
option, _ := strconv.Atoi(h_o[1])
hourBegin, _ := strconv.Atoi(hourRanges[0])
hourEnd, _ := strconv.Atoi(hourRanges[1])
if hourBegin <= currentHour && currentHour <= hourEnd {
result = option
break;
}
}
return result
}
/**
发布北京单场胜负过关
*/
func (this *PubService) PubBJDC() {
teamOption := this.teamOption()
al_flag := utils.GetVal(constants2.SECTION_NAME, "al_flag")
hit_count_str := utils.GetVal(constants2.SECTION_NAME, "hit_count")
hit_count, _ := strconv.Atoi(hit_count_str)
//获取分析计算出的比赛列表
analyList := this.AnalyService.GetPubDataList(al_flag, hit_count, teamOption)
analyList := this.RecommendService.ListData()
if len(analyList) < 1 {
base.Log.Info(fmt.Sprintf("1.当前没有可发布的比赛,发布的TeamOption为%d!!!!", teamOption))
base.Log.Info(fmt.Sprintf("1.当前没有可发布的比赛!!!!"))
return
}
......
package controller
import (
"encoding/json"
"fmt"
_ "github.com/astaxie/beego"
material2 "github.com/silenceper/wechat/material"
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-core/common/base/controller"
"tesou.io/platform/foot-parent/foot-core/module/analy/service"
)
type MaterialController struct {
controller.BaseController
service.RecommendService
}
func (this *MaterialController) AddNews() {
func (this *MaterialController) AddImages() {
material := wc.GetMaterial()
articles := make([]*material2.Article, 0)
for i := 0; i < 5; i++ {
mediaId, url, err := material.AddMaterial(material2.MediaTypeImage, "")
if err != nil {
base.Log.Error(err)
return
}
base.Log.Info(fmt.Sprintf("mediaId is : %v ,url is : %v", mediaId, url))
}
func (this *MaterialController) AddNews() {
listData := this.RecommendService.ListData()
articles := make([]*material2.Article, len(listData))
for _, e := range listData {
bytes, _ := json.Marshal(e)
base.Log.Warn("比赛信息:" + string(bytes))
matchDateStr := e.MatchDate.Format("01月02日15点04分")
article := new(material2.Article)
article.Title = fmt.Sprintf("%v", matchDateStr)
article.Digest = fmt.Sprintf("%v %v vs %v", e.LeagueName, e.MainTeamId, e.GuestTeamId)
//-----
article.ThumbMediaID = ""
//-----
article.ShowCoverPic = 1
//图文消息的原文地址,即点击“阅读原文”后的URL
article.ContentSourceURL = ""
article.Content = string(bytes)
articles = append(articles, article)
}
material := wc.GetMaterial()
mediaId, err := material.AddNews(articles)
if err != nil {
base.Log.Error(err)
......
......@@ -32,6 +32,10 @@ func init() {
}
wc = wechat.NewWechat(config)
}
/**
消息接收处理
*/
func (this *WechatController) Portable() {
// 传入request和responseWriter
server := wc.GetServer(this.Ctx.Request, this.Ctx.ResponseWriter)
......@@ -55,5 +59,3 @@ func (this *WechatController) Portable() {
//发送回复的消息
server.Send()
}
package service
import (
"encoding/json"
"fmt"
"github.com/silenceper/wechat/material"
"github.com/silenceper/wechat/message"
"strings"
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-core/common/base/service/mysql"
"tesou.io/platform/foot-parent/foot-core/module/analy/service"
)
type MessageService struct {
mysql.BaseService
service.RecommendService
}
/**
消息管理
*/
func (this *MessageService) Handle(v message.MixMessage) *message.Reply {
base.Log.Info("请求内容:",v)
base.Log.Info("请求内容:", v)
switch v.MsgType {
//文本消息
case message.MsgTypeText:
//do something
text := message.NewText(v.Content)
return &message.Reply{MsgType: message.MsgTypeText, MsgData: text}
textStr := string(text.Content)
if strings.EqualFold("今日推荐", textStr) || strings.EqualFold("推荐", textStr) {
return this.Today()
} else {
return &message.Reply{MsgType: message.MsgTypeText, MsgData: text}
}
//图片消息
case message.MsgTypeImage:
//do something
......@@ -47,65 +58,30 @@ func (this *MessageService) Handle(v message.MixMessage) *message.Reply {
return nil
//事件推送消息
case message.MsgTypeEvent:
return this.handleMsgTypeEvent(v)
return this.Today()
}
text := message.NewText(v.Content)
return &message.Reply{MsgType: message.MsgTypeText, MsgData: text}
}
/**
事件推送消息
*/
func (this *MessageService) handleMsgTypeEvent(v message.MixMessage) *message.Reply {
switch v.Event {
//EventSubscribe 订阅
case message.EventSubscribe:
//do something
return nil
//取消订阅
case message.EventUnsubscribe:
//do something
return nil
//用户已经关注公众号,则微信会将带场景值扫描事件推送给开发者
case message.EventScan:
//do something
return nil
// 上报地理位置事件
case message.EventLocation:
//do something
return nil
// 点击菜单拉取消息时的事件推送
case message.EventClick:
//do something
return nil
// 点击菜单跳转链接时的事件推送
case message.EventView:
//do something
return nil
// 扫码推事件的事件推送
case message.EventScancodePush:
//do something
return nil
// 扫码推事件且弹出“消息接收中”提示框的事件推送
case message.EventScancodeWaitmsg:
//do something
return nil
// 弹出系统拍照发图的事件推送
case message.EventPicSysphoto:
//do something
return nil
// 弹出拍照或者相册发图的事件推送
case message.EventPicPhotoOrAlbum:
//do something
return nil
// 弹出微信相册发图器的事件推送
case message.EventPicWeixin:
//do something
return nil
// 弹出地理位置选择器的事件推送
case message.EventLocationSelect:
//do something
return nil
func (this *MessageService) Today() *message.Reply {
listData := this.RecommendService.ListData()
articles := make([]*material.Article, len(listData))
for _, e := range listData {
bytes, _ := json.Marshal(e)
base.Log.Warn("比赛信息:" + string(bytes))
matchDateStr := e.MatchDate.Format("01月02日15点04分")
article := new(material.Article)
article.Title = fmt.Sprintf("%v", matchDateStr)
article.Digest = fmt.Sprintf("%v %v vs %v", e.LeagueName, e.MainTeamId, e.GuestTeamId)
//-----
article.ThumbMediaID = ""
//-----
article.ShowCoverPic = 1
//图文消息的原文地址,即点击“阅读原文”后的URL
article.ContentSourceURL = ""
article.Content = string(bytes)
articles = append(articles, article)
}
return nil
return &message.Reply{MsgType: message.MsgTypeNews, MsgData: articles}
}
......@@ -14,6 +14,7 @@ import (
entity2 "tesou.io/platform/foot-parent/foot-api/module/odds/pojo"
"tesou.io/platform/foot-parent/foot-core/module/odds/service"
"tesou.io/platform/foot-parent/foot-spider/module/win007"
"tesou.io/platform/foot-parent/foot-spider/module/win007/down"
)
type AsiaLastProcesser struct {
......@@ -45,7 +46,7 @@ func (this *AsiaLastProcesser) Startup() {
url := strings.Replace(win007.WIN007_ASIAODD_URL_PATTERN, "${matchId}", win007_id, 1)
newSpider = newSpider.AddUrl(url, "html")
}
//newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole())
newSpider.SetThreadnum(1).Run()
}
......
......@@ -14,6 +14,7 @@ import (
"tesou.io/platform/foot-parent/foot-core/module/elem/service"
service2 "tesou.io/platform/foot-parent/foot-core/module/odds/service"
"tesou.io/platform/foot-parent/foot-spider/module/win007"
"tesou.io/platform/foot-parent/foot-spider/module/win007/down"
"time"
)
......@@ -53,7 +54,7 @@ func (this *EuroHisProcesser) Startup() {
newSpider = newSpider.AddUrl(url, "html")
}
}
//newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole())
newSpider.SetThreadnum(1).Run()
}
......
......@@ -7,7 +7,7 @@ import (
"github.com/hu17889/go_spider/core/pipeline"
"github.com/hu17889/go_spider/core/spider"
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-spider/module/win007/down"
"regexp"
"strconv"
"strings"
......@@ -52,7 +52,7 @@ func (this *EuroLastProcesser) Startup() {
url := strings.Replace(win007.WIN007_EUROODD_URL_PATTERN, "${matchId}", win007_id, 1)
newSpider = newSpider.AddUrl(url, "html")
}
//newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole())
newSpider.SetThreadnum(1).Run()
}
......
......@@ -7,6 +7,7 @@ import (
"github.com/hu17889/go_spider/core/pipeline"
"github.com/hu17889/go_spider/core/spider"
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-spider/module/win007/down"
"strings"
"tesou.io/platform/foot-parent/foot-api/module/match/pojo"
......@@ -42,7 +43,7 @@ func (this *MatchAnalyProcesser) Startup() {
url := strings.Replace(win007.WIN007_MATCH_ANALY_URL_PATTERN, "${matchId}", win007_id, 1)
newSpider = newSpider.AddUrl(url, "html")
}
//newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole())
newSpider.SetThreadnum(1).Run()
}
......
......@@ -13,6 +13,7 @@ import (
service2 "tesou.io/platform/foot-parent/foot-core/module/elem/service"
"tesou.io/platform/foot-parent/foot-core/module/match/service"
"tesou.io/platform/foot-parent/foot-spider/module/win007"
"tesou.io/platform/foot-parent/foot-spider/module/win007/down"
"time"
)
......@@ -48,7 +49,7 @@ func (this *MatchPageProcesser) Startup() {
this.MatchlastUrl = this.MatchlastUrl + "?flesh=" + strconv.FormatFloat(rand.Float64(), 'f', -1, 64)
newSpider := spider.NewSpider(GetMatchPageProcesser(), "MatchPageProcesser")
newSpider = newSpider.AddUrl(this.MatchlastUrl, "text")
//newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider.SetDownloader(down.NewMWin007Downloader())
newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole())
newSpider.SetThreadnum(1).Run()
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册