From 11fe0d4ccbfd61019bd8dea27f2e3f12d7764cba Mon Sep 17 00:00:00 2001 From: jager Date: Thu, 23 Dec 2021 14:01:13 +0800 Subject: [PATCH] m --- cmd/stock/main.go | 23 +++++---- stock/stock.go | 127 +++++++++++++++++++++++----------------------- wxgzh/wxgzh.go | 2 +- 3 files changed, 78 insertions(+), 74 deletions(-) diff --git a/cmd/stock/main.go b/cmd/stock/main.go index b72fc53..40ec226 100644 --- a/cmd/stock/main.go +++ b/cmd/stock/main.go @@ -93,10 +93,12 @@ func main() { return true } codes := u.Codes(true) - stk := fund.NewFundArg(codes...) - err = wxgzh.Send(u.OpenID(), stk) - if err != nil { - logx.Error(err) + for _, code := range codes { + stk := fund.NewFundArg(code) + err = wxgzh.Send(u.OpenID(), stk) + if err != nil { + logx.Error(err) + } } return true }) @@ -160,15 +162,18 @@ func main() { return true } codes := u.Codes(false) - stk, err := stock.GetStocks(codes...) - if err != nil { - logx.Error(err) - } else { - err = wxgzh.Send(u.OpenID(), stk) + for _, code := range codes { + stk, err := stock.GetStocks(code) if err != nil { logx.Error(err) + } else { + err = wxgzh.Send(u.OpenID(), stk) + if err != nil { + logx.Error(err) + } } } + return true }) } diff --git a/stock/stock.go b/stock/stock.go index bea2f00..612ff7b 100644 --- a/stock/stock.go +++ b/stock/stock.go @@ -390,67 +390,66 @@ const msgTemplate = `%s 前五总买单:%s 前五总卖单:%s ` -// -//func (s *stock) Arg(openId string) map[string]interface{} { -// -// arg := map[string]interface{}{ -// "touser": openId, -// "template_id": "L7fOGJURj-1HF4cIpFizCOOiAMqER3PG-pfgn37Dalw", -// -// "data": map[string]interface{}{ -// "first": map[string]interface{}{ -// "value": s.values[0], -// "color": "#173177", -// }, -// "keyword1": map[string]interface{}{ -// "value": fmt.Sprintf("%s %s", s.values[30], s.values[31]), -// "color": "#173177", -// }, -// "keyword2": map[string]interface{}{ -// "value": s.values[2], -// "color": "#173177", -// }, -// "keyword3": map[string]interface{}{ -// "value": s.values[1], -// "color": "#173177", -// }, -// "keyword4": map[string]interface{}{ -// "value": s.values[3], -// "color": "#173177", -// }, -// "keyword5": map[string]interface{}{ -// "value": s.rise(), -// "color": "#173177", -// }, -// "keyword6": map[string]interface{}{ -// "value": s.values[4], -// "color": "#173177", -// }, -// "keyword7": map[string]interface{}{ -// "value": s.values[5], -// "color": "#173177", -// }, -// "keyword8": map[string]interface{}{ -// "value": s.tradingVolume(), -// "color": "#173177", -// }, -// "keyword9": map[string]interface{}{ -// "value": numFormat(s.values[9]), -// "color": "#173177", -// }, -// "keyword10": map[string]interface{}{ -// "value": s.buyCount(), -// "color": "#173177", -// }, -// "keyword11": map[string]interface{}{ -// "value": s.sellCount(), -// "color": "#173177", -// }, -// "remark": map[string]interface{}{ -// "value": "欢迎再次购买!", -// "color": "#173177", -// }, -// }, -// } -// return arg -//} +func (s *stock) Arg(openId string) map[string]interface{} { + + arg := map[string]interface{}{ + "touser": openId, + "template_id": "L7fOGJURj-1HF4cIpFizCOOiAMqER3PG-pfgn37Dalw", + + "data": map[string]interface{}{ + "first": map[string]interface{}{ + "value": s.values[0], + "color": "#173177", + }, + "keyword1": map[string]interface{}{ + "value": fmt.Sprintf("%s %s", s.values[30], s.values[31]), + "color": "#173177", + }, + "keyword2": map[string]interface{}{ + "value": s.values[2], + "color": "#173177", + }, + "keyword3": map[string]interface{}{ + "value": s.values[1], + "color": "#173177", + }, + "keyword4": map[string]interface{}{ + "value": s.values[3], + "color": "#173177", + }, + "keyword5": map[string]interface{}{ + "value": s.rise(), + "color": "#173177", + }, + "keyword6": map[string]interface{}{ + "value": s.values[4], + "color": "#173177", + }, + "keyword7": map[string]interface{}{ + "value": s.values[5], + "color": "#173177", + }, + "keyword8": map[string]interface{}{ + "value": s.tradingVolume(), + "color": "#173177", + }, + "keyword9": map[string]interface{}{ + "value": numFormat(s.values[9]), + "color": "#173177", + }, + "keyword10": map[string]interface{}{ + "value": s.buyCount(), + "color": "#173177", + }, + "keyword11": map[string]interface{}{ + "value": s.sellCount(), + "color": "#173177", + }, + "remark": map[string]interface{}{ + "value": "欢迎再次购买!", + "color": "#173177", + }, + }, + } + return arg +} diff --git a/wxgzh/wxgzh.go b/wxgzh/wxgzh.go index 7e8f5b7..31bf54a 100644 --- a/wxgzh/wxgzh.go +++ b/wxgzh/wxgzh.go @@ -89,7 +89,7 @@ func send(openID string, arg IArg, recall bool) error { msg := arg.Arg(openID) if msg == nil { - return errcode.New(1, "arg == nil") + return nil } resp := &Resp{} err = httpc.RequestWithInterface(httpc.POST, url, httpc.JSON, msg, nil, resp)