Skip to content

Commit

Permalink
增加可选一键推送支付结果信息到手机
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Pang committed Jan 18, 2021
1 parent dc4a645 commit 90fd30e
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@
- 秒杀预约后等待抢购
- 定时开始自动抢购
- 抢购过程中浏览器会打开对应works数的窗口,请不要大惊小怪 也不要关闭
- (可选)抢购成功通过微信[一键免费推送消息](https://sre24.com)提醒用户

## 运行环境
- [google浏览器]

## 运行参数
- mtSecKill -sku=100012043978 -num=2 -works=6 -time=09:59:59 -payPwd=xxxx 运行参数 均有默认可以不加
- mtSecKill -sku=100012043978 -num=2 -works=6 -time=09:59:59 -payPwd=xxxx -token=抢购成功微信推送提醒令牌 运行参数 均有默认可以不加
- 新增eid与fp参数 对于无法自动获取到的用户 请手动填入 默认空 会自动获取

token 参数可微信扫码免费登录 https://sre24.com 可以在「设置」页面得到。

## 打赏
要是客官抢到了茅台,心情好,请我喝一杯咖啡好不好:)
![收款二维码](https://github.com/zqjzqj/mtSecKill/blob/master/zqijun.png)
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var payPwd = flag.String("payPwd", "", "支付密码 可不填")
var isFileLog = flag.Bool("isFileLog", false, "是否使用文件记录日志")

func init() {
flag.StringVar(&global.PushToken, "token", "", "一键推送微信提醒令牌 可不填")

flag.Parse()
}

Expand Down
7 changes: 7 additions & 0 deletions global/cfgs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package global


var (
// PushToken sre24.com 一键免费推送消息 令牌
PushToken = ""
)
40 changes: 40 additions & 0 deletions global/notification.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package global

import (
"encoding/json"
"fmt"
"strings"
"time"

"github.com/giant-stone/go/ghttp"
"github.com/giant-stone/go/gutil"

"github.com/zqijzqj/mtSecKill/logs"
)

func NotifyUser(v ...interface{}) {
if PushToken == "" {
return
}

chunks := []string{}
for _, chunk := range v {
chunks = append(chunks, fmt.Sprintf("%v", chunk))
}
msg := strings.Join(chunks, " ")

fullurl := "https://sre24.com/api/v1/push"
rqBody, _ := json.Marshal(&map[string]interface{}{
"token": PushToken,
"msg": msg,
})
rq := ghttp.New().
SetTimeout(time.Second * 3).
SetRequestMethod("POST").
SetUri(fullurl).
SetPostBody(&rqBody)
err := rq.Send()
if gutil.CheckErr(err) {
logs.PrintErr("notify user fail", string(rq.RespBody))
}
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
github.com/chromedp/cdproto v0.0.0-20201204063249-be40c824ad18
github.com/chromedp/chromedp v0.5.4
github.com/giant-stone/go v0.0.0-20201217075953-ae0ac5ecfb4b
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gookit/color v1.3.6
github.com/tidwall/gjson v1.6.7
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ github.com/chromedp/chromedp v0.5.4/go.mod h1:Jl2gvx3U9zl4lS/dMjDVGXX0jZ4qo/vsGr
github.com/chromedp/sysutil v0.0.0-20201009230539-dc95e7e83e8a/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic=
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/giant-stone/go v0.0.0-20201217075953-ae0ac5ecfb4b h1:nki2enK5n+WJDIyExfj89Tx+uMN6/ig0gJZXciw65gU=
github.com/giant-stone/go v0.0.0-20201217075953-ae0ac5ecfb4b/go.mod h1:Qyvj5MG3Dc1v92kCVIHo499C8MObvNge3GW0rFWWCOg=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/gobwas/httphead v0.0.0-20200921212729-da3d93bc3c58 h1:YyrUZvJaU8Q0QsoVo+xLFBgWDTam29PKea6GYmwvSiQ=
github.com/gobwas/httphead v0.0.0-20200921212729-da3d93bc3c58/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
Expand All @@ -18,15 +23,20 @@ github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.4 h1:5eXU1CZhpQdq5kXbKb+sECH5Ia5KiO6CYzIzdlVx6Bs=
github.com/gobwas/ws v1.0.4/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/gookit/color v1.3.6 h1:Rgbazd4JO5AgSTVGS3o0nvaSdwdrS8bzvIXwtK6OiMk=
github.com/gookit/color v1.3.6/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/tidwall/gjson v1.6.7 h1:Mb1M9HZCRWEcXQ8ieJo7auYyyiSux6w9XN3AdTpxJrE=
github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI=
Expand Down
1 change: 1 addition & 0 deletions secKill/jdSecKill.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ func (jsk *jdSecKill) ReqSubmitSecKillOrder(ctx context.Context) error {
jsk.IsOk = true
jsk.IsOkChan <- struct{}{}
logs.PrintlnInfo("抢购成功,订单编号:", r.Get("orderId").String())
global.NotifyUser("抢购成功,订单编号:", r.Get("orderId").String())
} else {
if r.IsObject() || r.IsArray() {
return errors.New("抢购失败:" + r.Raw)
Expand Down

0 comments on commit 90fd30e

Please sign in to comment.