x
This commit is contained in:
parent
3f44a436ea
commit
d613b824a2
123
models/asset.go
123
models/asset.go
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -80,11 +81,13 @@ func (ck *JdCookie) Query() string {
|
||||
var pet = make(chan string)
|
||||
var gold = make(chan int64)
|
||||
var egg = make(chan int64)
|
||||
var tyt = make(chan string)
|
||||
go redPacket(cookie, rpc)
|
||||
go initFarm(cookie, fruit)
|
||||
go initPetTown(cookie, pet)
|
||||
go jsGold(cookie, gold)
|
||||
go jxncEgg(cookie, egg)
|
||||
go tytCoupon(cookie, tyt)
|
||||
today := time.Now().Local().Format("2006-01-02")
|
||||
yestoday := time.Now().Local().Add(-time.Hour * 24).Format("2006-01-02")
|
||||
page := 1
|
||||
@ -174,6 +177,7 @@ func (ck *JdCookie) Query() string {
|
||||
gn := <-gold
|
||||
msgs = append(msgs, fmt.Sprintf("极速金币:%d(≈%.2f元)💰", gn, float64(gn)/10000))
|
||||
msgs = append(msgs, fmt.Sprintf("惊喜牧场:%d枚鸡蛋🥚", <-egg))
|
||||
msgs = append(msgs, fmt.Sprintf("推一推券:%s", <-tyt))
|
||||
} else {
|
||||
msgs = append(msgs, []string{
|
||||
"提醒:该账号已过期,请重新登录",
|
||||
@ -582,6 +586,125 @@ func jxncEgg(cookie string, state chan int64) {
|
||||
req.Header("Referer", "https://st.jingxi.com/pingou/jxmc/index.html?nativeConfig=%7B%22immersion%22%3A1%2C%22toColor%22%3A%22%23e62e0f%22%7D&;__mcwvt=sjcp&ptag=7155.9.95")
|
||||
req.Header("Cookie", cookie)
|
||||
data, _ := req.Bytes()
|
||||
|
||||
egg, _ := jsonparser.GetInt(data, "data", "eggcnt")
|
||||
state <- egg
|
||||
}
|
||||
|
||||
func tytCoupon(cookie string, state chan string) {
|
||||
|
||||
type DiscountInfo struct {
|
||||
High string `json:"high"`
|
||||
Info []interface{} `json:"info"`
|
||||
}
|
||||
type ExtInfo struct {
|
||||
Num5 string `json:"5"`
|
||||
Num12 string `json:"12"`
|
||||
Num16 string `json:"16"`
|
||||
Num21 string `json:"21"`
|
||||
Num52 string `json:"52"`
|
||||
Num54 string `json:"54"`
|
||||
Num74 string `json:"74"`
|
||||
BusinessLabel string `json:"business_label"`
|
||||
LimitOrganization string `json:"limit_organization"`
|
||||
UserLabel string `json:"user_label"`
|
||||
}
|
||||
type Useable struct {
|
||||
AreaDesc string `json:"areaDesc"`
|
||||
AreaType int `json:"areaType"`
|
||||
Batchid string `json:"batchid"`
|
||||
BeanNumForPerson int `json:"beanNumForPerson"`
|
||||
BeanNumForPlat int `json:"beanNumForPlat"`
|
||||
BeginTime string `json:"beginTime"`
|
||||
CanBeSell bool `json:"canBeSell"`
|
||||
CanBeShare bool `json:"canBeShare"`
|
||||
CompleteTime string `json:"completeTime"`
|
||||
CouponKind int `json:"couponKind"`
|
||||
CouponStyle int `json:"couponStyle"`
|
||||
CouponTitle string `json:"couponTitle"`
|
||||
Couponid string `json:"couponid"`
|
||||
Coupontype int `json:"coupontype"`
|
||||
CreateTime string `json:"createTime"`
|
||||
Discount string `json:"discount"`
|
||||
DiscountInfo DiscountInfo `json:"discountInfo"`
|
||||
EndTime string `json:"endTime"`
|
||||
ExpireType int `json:"expireType"`
|
||||
ExtInfo ExtInfo `json:"extInfo"`
|
||||
HourCoupon int `json:"hourCoupon"`
|
||||
IsOverlay int `json:"isOverlay"`
|
||||
LimitStr string `json:"limitStr"`
|
||||
LinkStr string `json:"linkStr"`
|
||||
OperateTime string `json:"operateTime"`
|
||||
OrderID string `json:"orderId"`
|
||||
OverlayDesc string `json:"overlayDesc"`
|
||||
PassKey string `json:"passKey"`
|
||||
Pin string `json:"pin"`
|
||||
PlatFormInfo string `json:"platFormInfo"`
|
||||
Platform int `json:"platform"`
|
||||
PlatformDetails []interface{} `json:"platformDetails"`
|
||||
PwdKey string `json:"pwdKey"`
|
||||
Quota string `json:"quota"`
|
||||
SellID string `json:"sellId"`
|
||||
ShareID string `json:"shareId"`
|
||||
ShopID string `json:"shopId"`
|
||||
ShopName string `json:"shopName"`
|
||||
State int `json:"state"`
|
||||
UseTime string `json:"useTime"`
|
||||
VenderID string `json:"venderId"`
|
||||
}
|
||||
type Coupon struct {
|
||||
Curtimestamp int `json:"curtimestamp"`
|
||||
ExpiredCount int `json:"expired_count"`
|
||||
IsHideBaiTiaoInJxWxapp int `json:"isHideBaiTiaoInJxWxapp"`
|
||||
IsHideMailInWxapp int `json:"isHideMailInWxapp"`
|
||||
Useable []Useable `json:"useable"`
|
||||
UseableCount int `json:"useable_count"`
|
||||
UsedCount int `json:"used_count"`
|
||||
}
|
||||
type AutoGenerated struct {
|
||||
Coupon Coupon `json:"coupon"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
ErrorCode int `json:"errorCode"`
|
||||
HasNext int `json:"hasNext"`
|
||||
Jdpin string `json:"jdpin"`
|
||||
State int `json:"state"`
|
||||
Uin string `json:"uin"`
|
||||
}
|
||||
a := AutoGenerated{}
|
||||
req := httplib.Get(`https://m.jingxi.com/activeapi/queryjdcouponlistwithfinance?state=1&wxadd=1&filterswitch=1&_=1629296270692&sceneval=2&g_login_type=1&callback=jsonpCBKB&g_ty=ls`)
|
||||
req.Header("Accept", "*/*")
|
||||
req.Header("Connection", "keep-alive")
|
||||
req.Header("Accept-Encoding", "gzip, deflate, br")
|
||||
req.Header("Cookie", cookie)
|
||||
req.Header("Content-Type", "application/x-www-form-urlencoded")
|
||||
req.Header("Host", "m.jingxi.com")
|
||||
|
||||
req.Header("User-Agent", ua)
|
||||
req.Header("Referer", "https://st.jingxi.com/my/coupon/jx.shtml?sceneval=2&ptag=7155.1.18")
|
||||
data, _ := req.Bytes()
|
||||
res := regexp.MustCompile(`jsonpCBKB[(](.*)\s+[)];}catch`).FindSubmatch(data)
|
||||
rt := "暂无数据"
|
||||
if len(res) > 0 {
|
||||
json.Unmarshal(res[1], &a)
|
||||
num := 0
|
||||
toexp := 0
|
||||
tm := int(time.Now().Unix() * 1000)
|
||||
for _, cp := range a.Coupon.Useable {
|
||||
if strings.Contains(cp.CouponTitle, "推推5.01") {
|
||||
num++
|
||||
if Int(cp.EndTime) < tm {
|
||||
toexp++
|
||||
}
|
||||
}
|
||||
}
|
||||
if num == 0 {
|
||||
rt = "无优惠券"
|
||||
} else {
|
||||
rt = fmt.Sprintf("%d*5元优惠券", num)
|
||||
if toexp > 0 {
|
||||
rt += fmt.Sprintf("(今天将过期%d张)", toexp)
|
||||
}
|
||||
}
|
||||
}
|
||||
state <- rt
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ func initCookie() {
|
||||
}
|
||||
|
||||
func CookieOK(ck *JdCookie) bool {
|
||||
// Egg(fmt.Sprintf("pt_key=%s;pt_pin=%s;", ck.PtKey, ck.PtPin))
|
||||
// tytCoupon(fmt.Sprintf("pt_key=%s;pt_pin=%s;", ck.PtKey, ck.PtPin))
|
||||
if ck == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user