This commit is contained in:
2021-12-21 18:03:55 +08:00
parent 0df3603ef2
commit b8d1391bde
12 changed files with 458 additions and 169 deletions

View File

@@ -27,7 +27,7 @@ const (
)
var (
jsonStr = regexp.MustCompile(`{(.*?)}`)
jsonStr = regexp.MustCompile(`{(.*?)}`)
)
type fund struct {
@@ -50,11 +50,22 @@ func (f *fund) Msg() string {
return msg
}
type funds struct {
codes []string
}
func NewFunds(codes ...string) *funds {
return &funds{
codes: codes,
}
}
func FundsMsg(codes ...string) string {
if len(codes) <= 0 {
return ""
}
var msg = "基金定投估值 >>>\n"
//var msg = "基金定投估值 >>>\n"
msg := ""
for _, code := range codes {
fd, err := newFund(code)
if err != nil {
@@ -87,3 +98,17 @@ const msgTemplate = `%s
估算涨幅:(%s) %s%%
`
func (fs *funds) Arg(openid string) map[string]interface{} {
arg := map[string]interface{}{
"touser": openid,
"template_id": "SQXWp3RiYySb2GYG-vMYDsSIm-KZNM9szVpFOryUQGQ",
"data": map[string]interface{}{
"keyword": map[string]interface{}{
"value": FundsMsg(fs.codes...),
"color": "#173177",
},
},
}
return arg
}

View File

@@ -13,11 +13,14 @@
package fund
import (
"fmt"
"stock/wxgzh"
"testing"
)
func Test_Fund(t *testing.T) {
msg := FundsMsg()
fmt.Println(msg)
f := NewFunds("006229", "162412")
err := wxgzh.Send("o-KDV6NbRaanYz55fJuSgyR0qxxU", f)
if err != nil {
t.Error(err)
}
}