huangjiajun 2 semanas atrás
pai
commit
fe1c01ee18
2 arquivos alterados com 176 adições e 0 exclusões
  1. +81
    -0
      chanxuanTikTok/api.go
  2. +95
    -0
      chanxuanTikTok/md.go

+ 81
- 0
chanxuanTikTok/api.go Ver arquivo

@@ -0,0 +1,81 @@
package chanxuanTikTok

import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"fmt"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"strings"
"time"
)

const url = "https://open-api.chanmama.com"

// https://xifld533us.feishu.cn/wiki/wikcnKRYjreG0wr59f1ZrRQ3T7b
func GetGoods(acctoken string, args map[string]string) []ChanxuanTikTokGoods {
send, _ := Send("/jx/v1/partner/product/getGoodsPage", acctoken, args)
var list = make([]ChanxuanTikTokGoods, 0)
str := gjson.Get(send, "data.list").String()
json.Unmarshal([]byte(str), &list)
return list
}
func GetGoodsDetail(acctoken string, args map[string]string) ChanxuanTikTokGoodsDetail {
//goods_id
send, _ := Send("/jx/v1/partner/product/jxGoodsDetails", acctoken, args)
var list ChanxuanTikTokGoodsDetail
str := gjson.Get(send, "data").String()
json.Unmarshal([]byte(str), &list)
return list
}
func GetGoodsUrl(acctoken, userId string, args map[string]string) ChanxuanTikTokGoodsUrl {
//goods_id
args["user_id"] = userId
send, _ := SendPost("/jx/v1/partner/dklive/shareProductLink", acctoken, args)
var list ChanxuanTikTokGoodsUrl
str := gjson.Get(send, "data.data").String()
json.Unmarshal([]byte(str), &list)
return list
}
func GetOrder(acctoken, userId string, args map[string]string) []ChanxuanTikTokOrder {
//goods_id
args["user_id"] = userId
send, _ := Send("/jx/v1/partner/dklive/qryDKOrders", acctoken, args)
var list []ChanxuanTikTokOrder
str := gjson.Get(send, "data.data").String()
json.Unmarshal([]byte(str), &list)
return list
}
func GetToken(appId, secret string) string {
args := map[string]string{
"app_id": appId,
"timestamp": zhios_third_party_utils.Int64ToStr(time.Now().Unix()),
}
str := "app_id=" + appId + "&timestamp=" + args["timestamp"] + "&secret=" + secret
sign := zhios_third_party_utils.Md5(str)
args["sign"] = strings.ToUpper(sign)
post, err := zhios_third_party_utils.CurlPost(url+"/auth/token/get", zhios_third_party_utils.SerializeStr(args), nil)
fmt.Println(string(post))
fmt.Println(err)
//{"code":0,"message":"success","data":{"access_token":"1cd6b495-fa72-e7f8-bcf9-41aa17a49652","expires_in":7200,"expires_in_v2":1729075821}}
return gjson.Get(string(post), "data").String()
}
func Send(router, acctoken string, args map[string]string) (string, error) {
urlStr := url + router + "?access_token=" + acctoken
for k, v := range args {
urlStr += "&" + k + "=" + php2go.URLEncode(v)
}
post, err := zhios_third_party_utils.CurlGet(urlStr, nil)
fmt.Println(urlStr)
fmt.Println(string(post))
fmt.Println(err)
return string(post), err
}
func SendPost(router, acctoken string, args map[string]string) (string, error) {
urlStr := url + router
args["access_token"] = acctoken
post, err := zhios_third_party_utils.CurlPost(urlStr, zhios_third_party_utils.SerializeStr(args), nil)
fmt.Println(string(post))
fmt.Println(err)
return string(post), err
}

+ 95
- 0
chanxuanTikTok/md.go Ver arquivo

@@ -0,0 +1,95 @@
package chanxuanTikTok

type ChanxuanTikTokGoods struct {
Title string `json:"title"`
Cover string `json:"cover"`
Price int `json:"price"`
OriginPrice int `json:"origin_price"`
CosRatio int `json:"cos_ratio"`
Sales int `json:"sales"`
DetailUrl string `json:"detail_url"`
ProductId string `json:"product_id"`
KolCosRatio int `json:"kol_cos_ratio"`
ActivityCosRatio int `json:"activity_cos_ratio"`
ShopName string `json:"shop_name"`
ActivityId int `json:"activity_id"`
CategoryName string `json:"category_name"`
}
type ChanxuanTikTokGoodsUrl struct {
DkPassword string `json:"dk_password"`
DkCode_img string `json:"dk_code_img"`
DyDeeplink string `json:"dy_deeplink"`
DySharelink string `json:"dy_sharelink"`
}
type ChanxuanTikTokOrder struct {
CommissionRate int `json:"commission_rate"`
CxServiceRate int `json:"cx_service_rate"`
EstimatedCommission int `json:"estimated_commission"`
EstimatedTechServiceFee int `json:"estimated_tech_service_fee"`
FlowPoint string `json:"flow_point"`
ItemNum int `json:"item_num"`
OrderId string `json:"order_id"`
PaySuccessTime string `json:"pay_success_time"`
ProductId string `json:"product_id"`
ProductImg string `json:"product_img"`
ProductName string `json:"product_name"`
RealCommission int `json:"real_commission"`
RefundTime interface{} `json:"refund_time"`
SettleTime interface{} `json:"settle_time"`
SettledTechServiceFee int `json:"settled_tech_service_fee"`
ShopId int `json:"shop_id"`
TotalPayAmount int `json:"total_pay_amount"`
UpdateTime string `json:"update_time"`
VipMsg string `json:"vip_msg"`
}
type ChanxuanTikTokGoodsDetail struct {
ActivityCosRatio int `json:"activity_cos_ratio"`
AwemeList []string `json:"aweme_list"`
AwemesInfo []struct {
AwemeId string `json:"aweme_id"`
AwemeCover string `json:"aweme_cover"`
AwemeUrl string `json:"aweme_url"`
} `json:"awemes_info"`
BrandCode string `json:"brand_code"`
Category string `json:"category"`
CosRatio int `json:"cos_ratio"`
Cover string `json:"cover"`
DescLevel int `json:"desc_level"`
DescScore int `json:"desc_score"`
DetailImages []string `json:"detail_images"`
DetailUrl string `json:"detail_url"`
ExprLevel int `json:"expr_level"`
ExprScore int `json:"expr_score"`
Gain string `json:"gain"`
Images []string `json:"images"`
KolCosRatio int `json:"kol_cos_ratio"`
OriginPrice float64 `json:"origin_price"`
PostLevel int `json:"post_level"`
PostScore float64 `json:"post_score"`
Price float64 `json:"price"`
ProductId int64 `json:"product_id"`
PromotionEndTime string `json:"promotion_end_time"`
PromotionStartTime string `json:"promotion_start_time"`
Sales int `json:"sales"`
SellPoint string `json:"sell_point"`
ServLevel int `json:"serv_level"`
ServScore float64 `json:"serv_score"`
ShopIcon string `json:"shop_icon"`
ShopId int `json:"shop_id"`
ShopName string `json:"shop_name"`
Skus struct {
Field1 struct {
EffectivePrice int `json:"effective_price"`
Price int `json:"price"`
StockNum int `json:"stock_num"`
} `json:"1801560319889520"`
} `json:"skus"`
Spec []struct {
Name string `json:"name"`
SpecItems []struct {
Id string `json:"id"`
Name string `json:"name"`
} `json:"spec_items"`
} `json:"spec"`
Title string `json:"title"`
}

Carregando…
Cancelar
Salvar