Browse Source

test

master
huangjiajun 1 year ago
parent
commit
284bdbd22e
43 changed files with 3555 additions and 193 deletions
  1. +3
    -168
      chain_transfer/chain_transfer.go
  2. +149
    -0
      chain_transfer/svc/svc_kuaishou.go
  3. +1292
    -0
      chain_transfer/svc/svc_turnchain.go
  4. +101
    -0
      chain_transfer/svc/turn_chain.go
  5. +419
    -0
      chain_transfer/turn_chain.go
  6. +55
    -0
      dataoke/dels_content_parse.go
  7. +14
    -0
      db/db_sys_union.go
  8. +19
    -0
      db/offical/db_master_list_cfg.go
  9. +15
    -0
      db/offical/db_user_app_list.go
  10. +9
    -0
      db/offical/model/master_list_cfg.go
  11. +33
    -0
      db/offical/model/user_app_list.go
  12. +1
    -0
      go.mod
  13. +2
    -0
      go.sum
  14. +17
    -0
      jd/api.go
  15. +285
    -0
      jd/client.go
  16. +5
    -0
      jd/convert_url.go
  17. +8
    -0
      jd/errors.go
  18. +15
    -0
      jd/featured.go
  19. +19
    -0
      jd/guess.go
  20. +13
    -0
      jd/jd_zhimeng.go
  21. +88
    -0
      jd/model.go
  22. +13
    -0
      jd/order_track.go
  23. +15
    -0
      jd/recommend.go
  24. +95
    -0
      jd/sdk.go
  25. +101
    -0
      md/kuaishou.go
  26. +98
    -0
      md/md_chain.go
  27. +26
    -0
      md/official_recommend_list.go
  28. +3
    -0
      md/product_detail.go
  29. +1
    -0
      md/provider.go
  30. +26
    -25
      md/tik_tok.go
  31. +1
    -0
      md/url.go
  32. +49
    -0
      pdd/api.go
  33. +13
    -0
      pdd/detail.go
  34. +10
    -0
      pdd/pdd_zhimeng.go
  35. +91
    -0
      pdd/recommend.go
  36. +36
    -0
      tik_tok/svc_tik_tok_convert.go
  37. +33
    -0
      tik_tok/svc_tik_tok_goods.go
  38. +135
    -0
      utils/open_platform.go
  39. +40
    -0
      utils/string.go
  40. +36
    -0
      zhimeng/kuaishou_goods.go
  41. +116
    -0
      zhimeng/pdd_convert_url.go
  42. +1
    -0
      zhimeng/tik_tok_goods.go
  43. +54
    -0
      zhimeng/word_parse.go

+ 3
- 168
chain_transfer/chain_transfer.go View File

@@ -1,17 +1,16 @@
package chain_transfer

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/chain_transfer/svc"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/haodanku"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/taobao"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng"
"fmt"
"github.com/tidwall/gjson"
"strings"
"time"
"xorm.io/xorm"
)

@@ -51,7 +50,7 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {
if tbItemInfo != nil {
args["gid"] = zhios_third_party_utils.AnyToString(tbItemInfo.ItemID)
}
curls, err := ConvertUrl(eg, args)
curls, err := svc.ConvertUrl(eg, args)
if err != nil || curls == nil {
return res
}
@@ -149,7 +148,7 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {

}
if zhios_third_party_utils.InArr(args["provider"], []string{md.PVD_TB, md.PVD_TM}) == false {
curls, err := ConvertUrl(eg, args)
curls, err := svc.ConvertUrl(eg, args)
if err != nil || curls == nil {
return res
}
@@ -167,167 +166,3 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {
}
return res
}

func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, error) {
var (
err error
)
var urls *md.ConvertedUrls
switch args["provider"] {
case md.PVD_TB, md.PVD_TM:
taobaoSdk, err := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]))
if err != nil {
return nil, err
}
tb := taobaoSdk
var promoId = tb.CloudPromoIdWeb
if promoId == "" {
promoId = tb.SharePromoIdWeb
}
var promoId1 string
var taobaoShareId1 string
var IsWxTaobaoAuth bool
fmt.Println(IsWxTaobaoAuth)
if zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]) == 0 {
if tb.AppletIsAuth == "1" {
IsWxTaobaoAuth, taobaoShareId1, promoId1 = taobao.TaobaoRelationPid(eg, args)
if IsWxTaobaoAuth == false {
return nil, err
} else {
promoId = promoId1
}
}
}
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
urls, err = zhimeng.TaobaoConvertUrl(thirdZmAppKeyData.Val,
thirdZmAppSecretData.Val, args["gid"], promoId, tb.UserSID, "", tb.Svc_AK)
if urls != nil {
if taobaoShareId1 != "" {
urls.TbShareId = zhios_third_party_utils.StrToInt64(taobaoShareId1)
}
if promoId1 != "" {
urls.NewPid = promoId1
}
}
case md.PVD_JDS:
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
// 初始化京东配置
pid := args["acc_jd_share_id"]
postData := make(map[string]interface{})
postData["gid"] = args["gid"]
postData["appkey"] = thirdZmAppKeyData.Val
postData["secret_key"] = thirdZmAppSecretData.Val
jdData, err := zhimeng.NewZhiMengJingDongSDK().
SelectFunction("getgoodsinfo").
WithArgs(postData).
Result()
mdData := &md.MoreDetailResponse{}
// to struct
couponUrl := ""
couponPrice := ""
err = jdData.ToStruct(mdData)
if err == nil && mdData != nil && mdData.CouponURL != "" {
couponUrl = mdData.CouponURL
couponPrice = mdData.CouponPrice
}
urls, err = zhimeng.JDConvertUrl(
thirdZmAppKeyData.Val,
thirdZmAppSecretData.Val,
args["gid"],
pid,
couponUrl,
couponPrice,
"")
case md.PVD_TIKTOK, md.PVD_KUAISHOU:
pid := "cloud_" + args["uid"]
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
tikTokArgs := map[string]interface{}{
"appkey": thirdZmAppKeyData.Val,
"secret_key": thirdZmAppSecretData.Val,
"product_url": args["coupon_url"],
"external_info": pid,
}

if args["provider"] == md.PVD_TIKTOK {
tikTokArgs["need_qr_code"] = "0"

tikTokBase, _ := tik_tok.Base(eg, args["master_id"], "")
if zhios_third_party_utils.InArr(tikTokBase.AuthType, []string{"2", "3"}) {
if time.Now().Unix() > 1670055300 {
tikTokArgs["external_info"] = pid + "_" + args["master_id"]
}
urls, err = tik_tok.OwnTikTokUrl(tikTokBase, tikTokArgs)
} else {
tikTokArgs["external_info"] = pid + "_" + args["master_id"]
urls, err = zhimeng.TikTokUrl(tikTokArgs)
}

} else if args["provider"] == md.PVD_KUAISHOU {
tikTokArgs["gid"] = args["gid"]
tikTokArgs["linkType"] = "101"
tikTokArgs["genPoster"] = "0"
tikTokArgs["external_info"] = pid + "_" + args["master_id"]
urls, err = zhimeng.KuaiShouUrl(tikTokArgs)
}
case md.PVD_VIP:
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
// 初始化vip配置
pid := args["master_id"] + "_vip_cloud_" + args["uid"]
openId := args["master_id"] + "_vip_" + args["uid"]
urls, err = zhimeng.VipConvertUrl(
thirdZmAppKeyData.Val,
thirdZmAppSecretData.Val,
args["gid"],
pid,
"", "vendoapi", openId, "1")
case md.PVD_PDD:
pid := args["acc_pdd_self_id"]
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
miniApp := "0"
isShares := "2"
urls, err = zhimeng.PDDConvertUrl(
thirdZmAppKeyData.Val,
thirdZmAppSecretData.Val,
args["gid"],
pid,
"",
miniApp,
"0", isShares)
}
return urls, err
}

+ 149
- 0
chain_transfer/svc/svc_kuaishou.go View File

@@ -0,0 +1,149 @@
package svc

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/kuaishou"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng"
"encoding/json"
"github.com/tidwall/gjson"
"xorm.io/xorm"
)

func KuaiShouKlGoods(eg *xorm.Engine, officialEg *xorm.Engine, dbName string, tikTokArgs map[string]interface{}) *zhimeng.TikTokDetailData {
arg := map[string]interface{}{
"cpsLink": tikTokArgs["content"],
}
param, kuaishouData := GetKuaishouKey(eg, officialEg, dbName)
if kuaishouData["authType"] != "2" {
goods, _ := zhimeng.KuaiShouKlGoods(tikTokArgs)
return goods
}
param["param"] = zhios_third_party_utils.SerializeStr(arg)
data, err := kuaishou.GetKuishouCpsKlGoods(kuaishouData["sign_secret"], param)
goods := gjson.Get(data, "data.itemId").String()
if goods == "" || err != nil {
return nil
}
detail := KuaiShouDetail(eg, officialEg, dbName, map[string]interface{}{"gid": []string{goods}})
return detail
}

func GetKuaishouKey(eg *xorm.Engine, officialEg *xorm.Engine, dbName string) (map[string]string, map[string]string) {
kuaishouData := CommKuaishou(eg, officialEg, dbName)
param := map[string]string{
"appkey": kuaishouData["appkey"],
"access_token": kuaishouData["token"],
}

return param, kuaishouData
}
func KuaiShouDetail(eg *xorm.Engine, officialEg *xorm.Engine, dbName string, tikTokArgs map[string]interface{}) *zhimeng.TikTokDetailData {
arg := map[string]interface{}{
"itemId": []interface{}{tikTokArgs["gid"]},
}
param, kuaishouData := GetKuaishouKey(eg, officialEg, dbName)
if kuaishouData["authType"] != "2" {
goods, _ := zhimeng.KuaiShouDetail(tikTokArgs)
return goods
}
param["param"] = zhios_third_party_utils.SerializeStr(arg)
data, err := kuaishou.GetKuishouCpsGoodsDetail(kuaishouData["sign_secret"], param)
goods := gjson.Get(data, "data").String()
if goods == "" || err != nil {
return nil
}
var list = make([]md.KuaishouGoods, 0)
err = json.Unmarshal([]byte(goods), &list)
if err != nil {
return nil
}
var detail = zhimeng.TikTokDetailData{}
for _, v := range list {
if zhios_third_party_utils.IntToStr(v.GoodsId) == zhios_third_party_utils.AnyToString(tikTokArgs["gid"]) {
detail = CommGoodsDetail(v)
}
}
return &detail
}
func CommGoodsDetail(goods md.KuaishouGoods) zhimeng.TikTokDetailData {
var res = zhimeng.TikTokDetailData{
Commission: zhios_third_party_utils.Float64ToStr(float64(goods.PromotionRate) / 10),
CostPrice: zhios_third_party_utils.Float64ToStr(float64(goods.GoodsPrice) / 100),
GoodsID: zhios_third_party_utils.IntToStr(goods.GoodsId),
GoodsImg: goods.GoodsImageUrl,
GoodsSales: zhios_third_party_utils.IntToStr(goods.SalesTip),
GoodsTitle: goods.GoodsTitle,
Price: zhios_third_party_utils.Float64ToStr(float64(goods.ZkGoodsPrice) / 100),
ShopID: zhios_third_party_utils.IntToStr(goods.MallId),
ShopName: goods.MallName,
}
img, ok := goods.GoodsGalleryUrls.([]interface{})
res.Imgs = make([]string, 0)
if ok {
for _, v := range img {
res.Imgs = append(res.Imgs, zhios_third_party_utils.AnyToString(v))
}
}
detailImg, ok := goods.ItemDescUrls.([]interface{})
res.DetailImgs = make([]string, 0)
if ok {
for _, v := range detailImg {
res.DetailImgs = append(res.DetailImgs, zhios_third_party_utils.AnyToString(v))
}
}
return res
}

func CommKuaishou(eg *xorm.Engine, officialEg *xorm.Engine, dbName string) map[string]string {
kuaishouAppkey := offical.MasterListCfgGetOneData(officialEg, "0", "kuaishou_appkey")
kuaishouAppSecret := offical.MasterListCfgGetOneData(officialEg, "0", "kuaishou_app_secret")
kuaishouSignSecret := offical.MasterListCfgGetOneData(officialEg, "0", "kuaishou_sign_secret")
kuaishouToken := offical.MasterListCfgGetOneData(officialEg, "0", "kuaishou_token")
kuaishouPid := offical.MasterListCfgGetOneData(officialEg, "0", "kuaishou_pid")
puid := AppUserListPuidWithDb(officialEg, dbName)
puidKuaishouAppkey := offical.MasterListCfgGetOneData(officialEg, puid, "kuaishou_appkey")
if puidKuaishouAppkey != "" {
kuaishouAppkey = puidKuaishouAppkey
}
puidKuaishouSignSecret := offical.MasterListCfgGetOneData(officialEg, puid, "kuaishou_sign_secret")
if puidKuaishouSignSecret != "" {
kuaishouSignSecret = puidKuaishouSignSecret
}
puidKuaishouToken := offical.MasterListCfgGetOneData(officialEg, puid, "kuaishou_token")
if puidKuaishouToken != "" {
kuaishouToken = puidKuaishouToken
}
puidKuaishouPid := offical.MasterListCfgGetOneData(officialEg, puid, "kuaishou_pid")
if puidKuaishouPid != "" {
kuaishouPid = puidKuaishouPid
}
cfg, _ := db.SysUnionByKuaishouByUseByAuth(eg, dbName)
authType := ""
pid := kuaishouPid
if cfg != nil && cfg.AuthType == 2 { //自有
authType = zhios_third_party_utils.IntToStr(cfg.AuthType)
kuaishouToken = gjson.Get(cfg.KeyData, "teamAccessToken").String()
pid = gjson.Get(cfg.KeyData, "pid").String()
}
res := map[string]string{
"authType": authType,
"appkey": kuaishouAppkey,
"token": kuaishouToken,
"pid": pid,
"app_secret": kuaishouAppSecret,
"sign_secret": kuaishouSignSecret,
}
return res
}

func AppUserListPuidWithDb(officialEg *xorm.Engine, dbName string) string {
appList := offical.GetUserAppList(officialEg, dbName)
uid := "0"
if appList != nil && appList.Puid > 0 {
uid = zhios_third_party_utils.IntToStr(appList.Puid)
}
return uid
}

+ 1292
- 0
chain_transfer/svc/svc_turnchain.go
File diff suppressed because it is too large
View File


+ 101
- 0
chain_transfer/svc/turn_chain.go View File

@@ -0,0 +1,101 @@
package svc

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"

"fmt"
"strings"
"xorm.io/xorm"
)

func CommTik(eg *xorm.Engine, dbName, url string) map[string]string {
activityId := 0
teamToken := ""
commission := ""
if strings.Contains(url, "ecommerce") {
tikTokBase, _ := tik_tok.Base(eg, dbName, "")
tikTokBase.ExtendTeamTokenMap = GetTikTokTeamTokenEg(eg, dbName, url)
isSet := 0
for _, v1 := range tikTokBase.ExtendTeamTokenMap {
if isSet == 1 {
continue
}
if v1 != "" {
rgs := map[string]string{
"appkey": tikTokBase.ApiTeamAppKey,
"appSecret": tikTokBase.ApiTeamAppSecret,
"acctoken": zhios_third_party_utils.AnyToString(v1),
"activity_url": url,
}
urlMap := tik_tok.ColonelMultiParseActivityUrl(rgs)
if urlMap[url].ActivityId != 0 {
isSet = 1
activityId = urlMap[url].ActivityId
teamToken = zhios_third_party_utils.AnyToString(v1)
commission = zhios_third_party_utils.Float64ToStr(float64(urlMap[url].CommissionRate) / 100)
}
}
}
}
res := map[string]string{
"tik_activity_id": zhios_third_party_utils.IntToStr(activityId),
"tik_team_token": teamToken,
"tik_team_commission": commission,
}
return res
}

func GetTikTokTeamTokenEg(eg *xorm.Engine, dbName, url string) map[string]interface{} {
tmp := map[string]interface{}{}
zhiosOpenSelectionLibraryMasterId := db.SysCfgGetWithDb(eg, dbName, "zhios_open_selection_library_master_id")
if zhiosOpenSelectionLibraryMasterId == "" {
return tmp
}
bizData := map[string]interface{}{
"mid": zhiosOpenSelectionLibraryMasterId,
}
returnData, err := OauthApiReqEg(eg, dbName, url, bizData, "inapi.selection_library.team_info_more", "1.0")
if returnData == nil || err != nil {
return tmp
}
data := returnData.Data.(map[string]interface{})
return data

}
func GetKuaishouTeamTokenEg(eg *xorm.Engine, dbName, url string) map[string]interface{} {
tmp := map[string]interface{}{}
zhiosOpenSelectionLibraryMasterId := db.SysCfgGetWithDb(eg, dbName, "zhios_open_kuaishou_selection_library_master_id")
if zhiosOpenSelectionLibraryMasterId == "" {
return tmp
}
bizData := map[string]interface{}{
"mid": zhiosOpenSelectionLibraryMasterId,
}
returnData, err := OauthApiReqEg(eg, dbName, url, bizData, "inapi.selection_library.kuaishou_team_info_more", "1.0")
if returnData == nil || err != nil {
return tmp
}
data := returnData.Data.(map[string]interface{})
return data

}

func OauthApiReqEg(eg *xorm.Engine, dbName, url string, bizData map[string]interface{}, method, version string) (*zhios_third_party_utils.ReturnDataResp, error) {
openAppKey := db.SysCfgGetWithDb(eg, dbName, "zhios_open_app_key")
openAppSecret := db.SysCfgGetWithDb(eg, dbName, "zhios_open_app_secret")
// 创建请求
openClient, err := zhios_third_party_utils.NewOpenPlatformReqClient(openAppKey, method, version, openAppSecret, bizData)
if err != nil {
return nil, err
}
openClient.Url = url
fmt.Println("return :", openClient.ReturnData)
// 发送请求
err = openClient.SetBizDataToParams().CreateSign().CurlOpen()
if err != nil {
return nil, err
}
return &openClient.ReturnData, nil
}

+ 419
- 0
chain_transfer/turn_chain.go View File

@@ -0,0 +1,419 @@
package chain_transfer

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/chain_transfer/svc"
taoke "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/dataoke"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"fmt"
"github.com/mvdan/xurls"
"regexp"
"strings"
"time"
"xorm.io/xorm"
)

func TurnChain(eg *xorm.Engine, officialEg *xorm.Engine, args map[string]string) md.TCPrase {
dbName := args["master_id"]
var tcPrase md.TCPrase
tcPrase.TurnGoods = make([]md.TurnGoods, 0)
db.UserFindByID(eg, args["uid"])
now := time.Now()
PlatType := ""
args["platType"] = PlatType
user, _ := db.UserFindByID(eg, args["uid"])
userProfile, _ := db.UserProfileFindByID(eg, user.Uid)
if userProfile != nil {
args["acc_taobao_share_id"] = zhios_third_party_utils.Int64ToStr(userProfile.AccTaobaoShareId)
if userProfile.AccJdCloudId == "" {
userProfile.AccJdCloudId = userProfile.AccJdShareId
}
args["acc_jd_share_id"] = userProfile.AccJdCloudId
args["acc_pdd_self_id"] = userProfile.AccPddSelfId
}
//1、识别出对应平台的口令或链接
reqCount := args["content"]
if reqCount == "" {
return tcPrase
}
reqCount = strings.ReplaceAll(reqCount, "\n¥", "¥")
reqCount = strings.ReplaceAll(reqCount, "http", "\nhttp")
reqCounts := reqCount
if strings.Contains(reqCount, "¥") {
reqCounts = ""
splits := strings.Split(reqCount, "¥")
for k, v := range splits {
if k == 0 {
reqCounts += v + "\n¥"
} else if k+1 == len(splits) {
reqCounts += v
} else {
reqCounts += v + "¥"
}
}
}
reqCount = reqCounts
findAllUrl := xurls.Strict.FindAllString(reqCount, -1)
var pvd, goodsId, tklWord string
reg1 := regexp.MustCompile(`¥.*?¥`)
matched := reg1.FindAllStringSubmatch(reqCount, -1)
isTikTok := "0"
if strings.Contains(reqCount, "dou音") || strings.Contains(reqCount, "buydouke") || (strings.Contains(reqCount, "抖音") || strings.Contains(reqCount, "douyin")) && strings.Contains(reqCount, "【") {
isTikTok = "1"
}
split := strings.Split(reqCount, "\n")
reqCount = strings.ReplaceAll(reqCount, "\nhttp", "http")
if isTikTok == "1" {
pvd, goodsId, tklWord, _ := svc.FindTaobaoWord(eg, officialEg, args, reqCount, user)
if goodsId != "" || tklWord != "" {
tcPrase, _ = svc.CommGetGoods(eg, officialEg, args, tcPrase, 1, reqCount, pvd, goodsId, reqCount, tklWord, "0")
}
} else if len(split) > 0 {
for _, v := range split {
if strings.Contains(v, "m.tb") || strings.Contains(reqCount, "taobao.com") || strings.Contains(reqCount, "tmall.com") {
PlatType = "has"
}
if strings.Contains(v, "haohuo.jinritemai.") {
PlatType = "has"

}
if strings.Contains(v, "jd.") {
PlatType = "has"

}
if strings.Contains(v, "pinduoduo.com") || strings.Contains(v, "yangkeduo.com") {
PlatType = "has"

}
if strings.Contains(v, "kaola.com") {
PlatType = "has"

}
if strings.Contains(v, "suning.") {
PlatType = "has"

}
if strings.Contains(v, "vip.") {
PlatType = "has"

}
}
if PlatType == "" {
parse, _ := taoke.DaTaoKeContentParse(args["content"])
//fmt.Println("============1", time.Since(now))
args["platType"] = parse.PlatType
if parse.DataType == "activity" {

}
}
for k, v := range split {
if v == "" {
continue
}
isFirst := 1
if k > 0 && tcPrase.GID != "" {
isFirst = 0
}
if strings.Contains(v, "m.tb") || strings.Contains(reqCount, "taobao.com") || strings.Contains(reqCount, "tmall.com") {
// 淘口令
//fmt.Println(s)
pvd, goodsId, tklWord, _ = svc.FindTaobaoWord(eg, officialEg, args, v, user)
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, pvd, goodsId, v, tklWord, "0")
}
if strings.Contains(v, "haohuo.jinritemai.") {
//https://haohuo.jinritemai.com/ecommerce/trade/detail/index.html?id=3556342393857024570&ins_activity_param=yNAkhfs&origin_type=pc_buyin_group&pick_source=v.6nZos
tikTokBase := svc.CommTik(eg, dbName, v)
url := strings.ReplaceAll(v, "?", "&") + "&"
split := strings.Split(url, "&id=")
if len(split) == 2 {
split1 := strings.Split(split[1], "&")
if len(split1) > 0 {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_TIKTOK, split1[0], v, tklWord, "0")
if zhios_third_party_utils.StrToInt(tikTokBase["tik_activity_id"]) > 0 && strings.Contains(tcPrase.GID, "cid") == false {
tcPrase.GID += "cid" + tikTokBase["tik_activity_id"]
}
}
}
}
if strings.Contains(v, "jd.") {
//只有链接带有.html才会剥离出商品id
if strings.Contains(v, ".html") {
var index int
s1 := v
split := strings.Split(s1, "/")
for i, s := range split {
if strings.Contains(s, ".html") {
index = i
}
}
goodsidStrs := strings.Split(split[index], ".html")
if len(goodsidStrs) > 0 {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_JD, goodsidStrs[0], v, tklWord, "0")
}
} else {
findAllUrl1 := xurls.Strict.FindAllString(v, -1)
for _, v1 := range findAllUrl1 {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_JD, "", v1, tklWord, "0")
}
}
}
if strings.Contains(v, "pinduoduo.com") || strings.Contains(v, "yangkeduo.com") {
split := strings.Split(v, "?")
if len(split) > 1 {
sUrl := strings.Split(split[1], "&")
if len(sUrl) > 0 {
for _, v2 := range sUrl {
if strings.Contains(v2, "goods_id=") {
goods := strings.Split(v2, "=")
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_PDD, goods[1], v, tklWord, "0")
}
}

}
} else {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_PDD, "", v, tklWord, "0")
}
}
if strings.Contains(v, "kaola.com") {
var index int
s1 := v
split := strings.Split(s1, "/")
for i, s := range split {
if strings.Contains(s, ".html") {
index = i
}
}
goodsidStrs := strings.Split(split[index], ".html")
if len(goodsidStrs) > 0 {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_KL, goodsidStrs[0], v, tklWord, "0")
}
return tcPrase
}
if strings.Contains(v, "suning.") {
r, _ := regexp.Compile(`/(\d+)/(\d+).html`)
reg := r.FindStringSubmatch(v)
if len(reg) < 3 {
return tcPrase
}
bytes := []byte(reg[2])
var index int
for i, b := range bytes {
if b != byte(48) {
index = i
break
}
}
i := bytes[index:len(bytes)]
fmt.Println(string(i))
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_SN, string(i), v, tklWord, "0")
}
if strings.Contains(v, "vip.") {
gid := ""
if strings.Contains(v, "goodsId=") {
split := strings.Split(v+"&", "&")
for _, v := range split {
if strings.Contains(v, "goodsId=") {
gid = strings.ReplaceAll(v, "goodsId=", "")
}
}
} else {
var index int
s1 := v
split := strings.Split(s1, "/")
for i, s := range split {
if strings.Contains(s, ".html") {
index = i
}
}
goodsidStrs := strings.Split(split[index], ".html")
if len(goodsidStrs) > 0 {
product := strings.Split(goodsidStrs[0], "-")
gid = product[len(product)-1]
}
}
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_VIP, gid, v, tklWord, "0")
}
newV := strings.ToLower(v)
for i := 0; i < 10; i++ {
newV = strings.ReplaceAll(newV, zhios_third_party_utils.IntToStr(i), "")
}
if strings.Contains(v, "¥") == false && strings.Contains(v, "http") == false {
var numArr = []string{"、", "-", "~", ".", "。", "!", "/", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
for _, v1 := range numArr {
newV = strings.ReplaceAll(newV, v1, "")
}
}
if goodsId == "" && zhios_third_party_utils.IsAllChinese(newV) == false && (PlatType == "taobao" || PlatType == "") {

pvd, goodsId, word, _ := svc.FindTaobaoWord(eg, officialEg, args, v, user)
if goodsId == "" && pvd == "" {
continue
}
url := ""
if zhios_third_party_utils.InArr(pvd, []string{md.PVD_TB, md.PVD_TM}) {
url = v
v = ""
}
if pvd == md.PVD_KUAISHOU {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, pvd, goodsId, v, word, "1")
} else {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, pvd, goodsId, v, url, "0")
}
}
fmt.Println("============"+zhios_third_party_utils.IntToStr(k+3), time.Since(now))

}
fmt.Println("============30", time.Since(now))

} else if matched != nil && len(matched) > 0 {

for k, v := range matched {
isFirst := 1
if k > 0 && tcPrase.GID != "" {
isFirst = 0
}
for _, v1 := range v {
pvd, goodsId, _, _ := svc.FindTaobaoWord(eg, officialEg, args, v1, user)
url := ""
if len(findAllUrl) > 0 {
url = findAllUrl[k]
}
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, pvd, goodsId, url, v1, "1")
}
}
} else if len(findAllUrl) > 0 && isTikTok == "0" {
for k, v := range findAllUrl {
isFirst := 1
if k > 0 && tcPrase.GID != "" {
isFirst = 0
}
if strings.Contains(v, "m.tb") ||
strings.Contains(reqCount, "taobao.com") || strings.Contains(reqCount, "tmall.com") {
// 淘口令
//fmt.Println(s)
pvd, goodsId, tklWord, _ = svc.FindTaobaoWord(eg, officialEg, args, v, user)
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, pvd, goodsId, v, tklWord, "0")
}
if strings.Contains(v, "haohuo.jinritemai.") {
tikTokBase := svc.CommTik(eg, args["master_id"], v)
url := strings.ReplaceAll(v, "?", "&") + "&"
split := strings.Split(url, "&id=")
if len(split) == 2 {
split1 := strings.Split(split[1], "&")
if len(split1) > 0 {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_TIKTOK, split1[0], v, tklWord, "0")
if zhios_third_party_utils.StrToInt(tikTokBase["tik_activity_id"]) > 0 && strings.Contains(tcPrase.GID, "cid") == false {
tcPrase.GID += "cid" + tikTokBase["tik_activity_id"]
}
}
}
}
if strings.Contains(v, "jd.") {
//只有链接带有.html才会剥离出商品id
if strings.Contains(v, ".html") {
var index int
s1 := v
split := strings.Split(s1, "/")
for i, s := range split {
if strings.Contains(s, ".html") {
index = i
}
}
goodsidStrs := strings.Split(split[index], ".html")
if len(goodsidStrs) > 0 {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_JD, goodsidStrs[0], v, tklWord, "0")
}
} else {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_JD, "", v, tklWord, "0")
}
}
if strings.Contains(v, "pinduoduo.com") || strings.Contains(v, "yangkeduo.com") {
split := strings.Split(v, "?")
if len(split) > 1 {
sUrl := strings.Split(split[1], "&")
if len(sUrl) > 0 {
for _, v2 := range sUrl {
if strings.Contains(v2, "goods_id=") {
goods := strings.Split(v2, "=")
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_PDD, goods[1], v, tklWord, "0")
}
}

}
} else {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_PDD, "", v, tklWord, "0")
}
}
if strings.Contains(v, "kaola.com") {
var index int
s1 := v
split := strings.Split(s1, "/")
for i, s := range split {
if strings.Contains(s, ".html") {
index = i
}
}
goodsidStrs := strings.Split(split[index], ".html")
if len(goodsidStrs) > 0 {
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_KL, goodsidStrs[0], v, tklWord, "0")
}
return tcPrase
}
if strings.Contains(v, "suning.") {
r, _ := regexp.Compile(`/(\d+)/(\d+).html`)
reg := r.FindStringSubmatch(v)
if len(reg) < 3 {
return tcPrase
}
bytes := []byte(reg[2])
var index int
for i, b := range bytes {
if b != byte(48) {
index = i
break
}
}
i := bytes[index:len(bytes)]
fmt.Println(string(i))
tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_SN, string(i), v, tklWord, "0")
}
if strings.Contains(v, "vip.") {

gid := ""
if strings.Contains(v, "goodsId=") {
split := strings.Split(v+"&", "&")
for _, v := range split {
if strings.Contains(v, "goodsId=") {
gid = strings.ReplaceAll(v, "goodsId=", "")
}
}
} else {
var index int
s1 := v
split := strings.Split(s1, "/")
for i, s := range split {
if strings.Contains(s, ".html") {
index = i
}
}
goodsidStrs := strings.Split(split[index], ".html")
if len(goodsidStrs) > 0 {
product := strings.Split(goodsidStrs[0], "-")
gid = product[len(product)-1]
}
}

tcPrase, reqCount = svc.CommGetGoods(eg, officialEg, args, tcPrase, isFirst, reqCount, md.PVD_VIP, gid, v, tklWord, "0")
}
}

} else {
pvd, goodsId, tklWord, _ := svc.FindTaobaoWord(eg, officialEg, args, reqCount, user)
if goodsId != "" {
tcPrase, _ = svc.CommGetGoods(eg, officialEg, args, tcPrase, 1, reqCount, pvd, goodsId, "", tklWord, "0")

}
}
return tcPrase
}

+ 55
- 0
dataoke/dels_content_parse.go View File

@@ -0,0 +1,55 @@
package dataoke

import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils/cache"
"encoding/json"
"errors"
"fmt"
"github.com/tidwall/gjson"
)

type ContentParse struct {
ItemId string `json:"itemId"`
ItemLink string `json:"itemLink"`
ItemName string `json:"itemName"`
DataType string `json:"dataType"`
PlatType string `json:"platType"`
MainPic string `json:"mainPic"`
MonthSales interface{} `json:"monthSales"`
OriginalPrice interface{} `json:"originalPrice"`
ActualPrice interface{} `json:"actualPrice"`
CommissionRate interface{} `json:"commissionRate"`
CouponPrice interface{} `json:"coupon_price"`
Url string `json:"url"`
}

func DaTaoKeContentParse(content string) (data ContentParse, err error) {
key := "new_" + content
get, err := cache.GetString(key)
if get == "" || err != nil {
params := map[string]string{
"version": "v1.0.0",
"content": key,
}
resp, err := SendReq("https://openapi.dataoke.com/api/dels/kit/contentParse", params)
if err != nil {
return data, err
}
list := gjson.Get(string(resp), "data").String()
err = json.Unmarshal([]byte(list), &data)
if err != nil {
return data, err
}
if data.DataType != "goods" {
return data, errors.New("不是商品")
}
if data.ItemId != "" {
_, err := cache.SetEx(content, zhios_third_party_utils.SerializeStr(data), 15*86400)
fmt.Println(err)
}
} else {
json.Unmarshal([]byte(get), &data)
}
return data, nil
}

+ 14
- 0
db/db_sys_union.go View File

@@ -123,3 +123,17 @@ func SysUnionById(eg *xorm.Engine, id string) *model.SysUnionSet {
}
return &data
}
func SysUnionByKuaishouByUseByAuth(Db *xorm.Engine, masterId string) (*model.SysUnionSet, error) {
var (
m model.SysUnionSet
)
has, err := Db.Where("provider = 'kuaishou' AND is_use = 1 ").Get(&m)
if err != nil {
return nil, err
}
if !has {
return nil, errors.New("找不到联盟设置")
}

return &m, nil
}

+ 19
- 0
db/offical/db_master_list_cfg.go View File

@@ -0,0 +1,19 @@
package offical

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical/model"
"xorm.io/xorm"
)

func MasterListCfgGetOneData(eg *xorm.Engine, uid, key string) string {
var cfgList model.MasterListCfg
has, err := eg.Where("`k`=? and uid=?", key, uid).Get(&cfgList)
if err != nil {
return ""
}
if has == false {
cfgList = model.MasterListCfg{Uid: uid, K: key}
eg.InsertOne(&cfgList)
}
return cfgList.V
}

+ 15
- 0
db/offical/db_user_app_list.go View File

@@ -0,0 +1,15 @@
package offical

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical/model"
"xorm.io/xorm"
)

func GetUserAppList(eg *xorm.Engine, uid string) *model.UserAppList {
var data model.UserAppList
get, err := eg.Where("uuid=?", uid).Get(&data)
if get == false || err != nil {
return nil
}
return &data
}

+ 9
- 0
db/offical/model/master_list_cfg.go View File

@@ -0,0 +1,9 @@
package model

type MasterListCfg struct {
K string `json:"k" xorm:"not null VARCHAR(255)"`
V string `json:"v" xorm:"TEXT"`
Memo string `json:"memo" xorm:"VARCHAR(255)"`
Uid string `json:"uid" xorm:"comment('0是官方') VARCHAR(255)"`
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
}

+ 33
- 0
db/offical/model/user_app_list.go View File

@@ -0,0 +1,33 @@
package model

type UserAppList struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uuid int `json:"uuid" xorm:"not null comment('masterId') INT(10)"`
Uid int `json:"uid" xorm:"not null comment('用户ID') INT(10)"`
AppId int `json:"app_id" xorm:"not null comment('应用ID') INT(10)"`
PlanId string `json:"plan_id" xorm:"not null default '' comment('套餐ID') VARCHAR(100)"`
Expire int `json:"expire" xorm:"not null default 0 comment('过期时间') INT(10)"`
Name string `json:"name" xorm:"not null default '' comment('应用主名称') VARCHAR(32)"`
Icon string `json:"icon" xorm:"not null default '' comment('应用主图标') VARCHAR(250)"`
CreateTime int `json:"create_time" xorm:"not null default 0 comment('初次激活时间') INT(10)"`
RenewTime int `json:"renew_time" xorm:"not null default 0 comment('上次续费时间') INT(10)"`
Domain string `json:"domain" xorm:"not null default '' comment('域名') index VARCHAR(110)"`
DomainAlias string `json:"domain_alias" xorm:"not null default '' comment('域名别名') index VARCHAR(110)"`
Platform string `json:"platform" xorm:"not null default '' comment('平台信息 ios,android,applet') VARCHAR(100)"`
Info string `json:"info" xorm:"comment('平台名称如ios.name.#ddd;') TEXT"`
PayMode int `json:"pay_mode" xorm:"not null default 1 comment('付费模式,0授信,1付款') TINYINT(1)"`
Price float32 `json:"price" xorm:"not null default 0.00 comment('应用价格') FLOAT(10,2)"`
PricePay float32 `json:"price_pay" xorm:"not null default 0.00 comment('实际付款价格') FLOAT(10,2)"`
OfficialPrice float32 `json:"official_price" xorm:"not null default 0.00 comment('应用价格') FLOAT(10,2)"`
OfficialPricePay float32 `json:"official_price_pay" xorm:"not null default 0.00 comment('实际付款价格') FLOAT(10,2)"`
State int `json:"state" xorm:"not null default 0 comment('0未创建,1正常,2停用,3过期') TINYINT(1)"`
DeleteAt int `json:"delete_at" xorm:"not null default 0 TINYINT(1)"`
CustomAndroidCount int `json:"custom_android_count" xorm:"default 0 comment('客户端安卓包名重置次数') INT(11)"`
CustomIosCount int `json:"custom_ios_count" xorm:"default 0 comment('客户端ios包名重置次数') INT(11)"`
StoreAndroidCount int `json:"store_android_count" xorm:"default 0 comment('商家端安卓包名重置次数') INT(11)"`
StoreIosCount int `json:"store_ios_count" xorm:"default 0 comment('商家端ios包名重置次数') INT(11)"`
SmsPlatform string `json:"sms_platform" xorm:"default 'mob' comment('mob ljioe联江') VARCHAR(255)"`
IsClose int `json:"is_close" xorm:"default 0 comment('是否关闭') INT(1)"`
Puid int `json:"puid" xorm:"default 0 comment('') INT(11)"`
StoreRateInfo string `json:"store_rate_info" xorm:"comment('付呗商品进件费率') TEXT"`
}

+ 1
- 0
go.mod View File

@@ -11,6 +11,7 @@ require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/jinzhu/copier v0.3.5
github.com/kr/pretty v0.3.1 // indirect
github.com/mvdan/xurls v1.1.0
github.com/nilorg/sdk v0.0.0-20221104025912-4b6ccb7004d8
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.19.0 // indirect


+ 2
- 0
go.sum View File

@@ -279,6 +279,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mvdan/xurls v1.1.0 h1:OpuDelGQ1R1ueQ6sSryzi6P+1RtBpfQHM8fJwlE45ww=
github.com/mvdan/xurls v1.1.0/go.mod h1:tQlNn3BED8bE/15hnSL2HLkDeLWpNPAwtw7wkEq44oU=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=


+ 17
- 0
jd/api.go View File

@@ -0,0 +1,17 @@
package jd

func init() {
JDAppKey = "444ab671c4d095122916453d09af27fc"
JDAppSecret = "aef3c2745cc44194816d0c89c65b3847"
JDVersion = "1.0"
JDRouter = "https://router.jd.com/api"
// taoke.JDRouter = "https://api.jd.com/routerjson"

}
func send(method string, args map[string]interface{}) ([]byte, error) {
result, err := Execute(method, Arg{"goodsReq": args})
if err != nil {
return nil, err
}
return result.MarshalJSON()
}

+ 285
- 0
jd/client.go View File

@@ -0,0 +1,285 @@
package jd

import (
"bytes"
"crypto/md5"
"crypto/tls"
"encoding/hex"
"encoding/json"
"errors"
"io"
"io/ioutil"
"net/http"
"net/url"
"sort"
"strconv"
"strings"
"time"

"github.com/bitly/go-simplejson"
"github.com/nilorg/sdk/convert"
)

var (
/**公用方法**/
// Session 用户登录授权成功后,TOP颁发给应用的授权信息。当此API的标签上注明:“需要授权”,则此参数必传;“不需要授权”,则此参数不需要传;“可选授权”,则此参数为可选
Session string
// Timeout ...
Timeout time.Duration
// CacheExpiration 缓存过期时间
CacheExpiration = time.Hour

/**淘宝平台信息**/
TaobaoAppKey string
TaobaoAppSecret string
TaobaoRouter string
TaobaoVersion = "2.0"

/**京东平台信息**/
JDAppKey string
JDAppSecret string
JDRouter string
JDVersion = "2.0"

/**拼多多平台信息**/
PDDAppKey string
PDDAppSecret string
PDDRouter string
PDDVersion = "v1.0"

/**考拉海购平台信息**/
KaolaAppKey string
KaolaAppSecret string
KaolaRouter string
KaolaVersion = "1.0"
)

// Arg 参数
type Arg map[string]interface{}

// copyArg 复制参数
func copyArg(srcArgs Arg) Arg {
newArgs := make(Arg)
for key, value := range srcArgs {
newArgs[key] = value
}
return newArgs
}

// newCacheKey 创建缓存Key
func newCacheKey(p Arg) string {
cpArgs := copyArg(p)
delete(cpArgs, "session")
delete(cpArgs, "timestamp")
delete(cpArgs, "sign")

keys := []string{}
for k := range cpArgs {
keys = append(keys, k)
}
// 排序asc
sort.Strings(keys)
// 把所有参数名和参数值串在一起
cacheKeyBuf := new(bytes.Buffer)
for _, k := range keys {
cacheKeyBuf.WriteString(k)
cacheKeyBuf.WriteString("=")
cacheKeyBuf.WriteString(interfaceToString(cpArgs[k]))
}
h := md5.New()
io.Copy(h, cacheKeyBuf)
return hex.EncodeToString(h.Sum(nil))
}

// execute 执行API接口
func execute(p Arg, router string) (bytes []byte, err error) {
err = checkConfig()
if err != nil {
return
}

var req *http.Request
req, err = http.NewRequest("POST", router, strings.NewReader(p.getReqData()))
if err != nil {
return
}
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
httpClient := &http.Client{Transport: tr}
httpClient.Timeout = Timeout
var resp *http.Response
resp, err = httpClient.Do(req)
if err != nil {
return
}

if resp.StatusCode != 200 {
err = errors.New("请求错误:" + strconv.Itoa(resp.StatusCode))
return
}

defer resp.Body.Close()
bytes, err = ioutil.ReadAll(resp.Body)
// fmt.Printf("\n\n\nreq: %v\n\nresp: %v\n\n\n", p.getReqData(), string(bytes))
return
}

// Execute 执行API接口
func Execute(method string, p Arg) (res *simplejson.Json, err error) {
p, r := setReqData(p, method)
var bodyBytes []byte
bodyBytes, err = execute(p, r)
if err != nil {
return
}

return bytesToResult(bodyBytes)
}

func bytesToResult(bytes []byte) (res *simplejson.Json, err error) {
res, err = simplejson.NewJson(bytes)
if err != nil {
return
}
if responseError, ok := res.CheckGet("error_response"); ok {
if subMsg, subOk := responseError.CheckGet("sub_msg"); subOk {
err = errors.New(subMsg.MustString())
} else if zhDesc, descOk := responseError.CheckGet("zh_desc"); descOk {
err = errors.New(zhDesc.MustString())
} else {
err = errors.New(responseError.Get("msg").MustString())
}
res = nil
}
return
}

// ExecuteCache 执行API接口,缓存

// 检查配置
func checkConfig() error {
if TaobaoAppKey == "" && JDAppKey == "" && KaolaAppKey == "" && PDDAppKey == "" {
return errors.New("至少需要设置一个平台参数")
}
return nil
}

//组装参数及添加公共参数
func setReqData(p Arg, method string) (Arg, string) {
platform := strings.Split(method, ".")[0]
router := ""
hh, _ := time.ParseDuration("8h")
loc := time.Now().UTC().Add(hh)
if platform == "taobao" {
//淘宝
p["timestamp"] = strconv.FormatInt(loc.Unix(), 10)
p["partner_id"] = "Blant"
p["app_key"] = TaobaoAppKey
p["v"] = TaobaoVersion
if Session != "" {
p["session"] = Session
}
p["method"] = method
p["format"] = "json"
p["sign_method"] = "md5"
// 设置签名
p["sign"] = getSign(p, TaobaoAppSecret)
router = TaobaoRouter
} else if platform == "jd" {
//京东
param := p
p = Arg{}
p["param_json"] = param
p["app_key"] = JDAppKey
p["v"] = JDVersion
p["timestamp"] = loc.Format("2006-01-02 15:04:05")
p["method"] = method
p["format"] = "json"
p["sign_method"] = "md5"
// 设置签名
p["sign"] = getSign(p, JDAppSecret)
router = JDRouter
} else if platform == "pdd" {
//拼多多
p["type"] = method
p["data_type"] = "json"
p["version"] = PDDVersion
p["client_id"] = PDDAppKey
p["timestamp"] = strconv.FormatInt(loc.Unix(), 10)
// 设置签名
p["sign"] = getSign(p, PDDAppSecret)
router = PDDRouter
} else if platform == "kaola" {
//考拉海购
p["method"] = method
p["v"] = KaolaVersion
p["signMethod"] = "md5"
p["unionId"] = KaolaAppKey
p["timestamp"] = loc.Format("2006-01-02 15:04:05")
// 设置签名
p["sign"] = getSign(p, KaolaAppSecret)
router = KaolaRouter
} else if platform == "suning" {
// TODO 苏宁

} else if platform == "vip" {
// TODO 唯品会
}

return p, router
}

// 获取请求数据
func (p Arg) getReqData() string {
// 公共参数
args := url.Values{}
// 请求参数
for key, val := range p {
args.Set(key, interfaceToString(val))
}
return args.Encode()
}

// 获取签名
func getSign(p Arg, secret string) string {
// 获取Key
var keys []string
for k := range p {
keys = append(keys, k)
}
// 排序asc
sort.Strings(keys)
// 把所有参数名和参数值串在一起
query := bytes.NewBufferString(secret)
for _, k := range keys {
query.WriteString(k)
query.WriteString(interfaceToString(p[k]))
}
query.WriteString(secret)
// 使用MD5加密
h := md5.New()
_, _ = io.Copy(h, query)
// 把二进制转化为大写的十六进制
return strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
}

func interfaceToString(src interface{}) string {
if src == nil {
panic(ErrTypeIsNil)
}
switch src.(type) {
case string:
return src.(string)
case int, int8, int32, int64:
case uint8, uint16, uint32, uint64:
case float32, float64:
return convert.ToString(src)
}
data, err := json.Marshal(src)
if err != nil {
panic(err)
}
return string(data)
}

+ 5
- 0
jd/convert_url.go View File

@@ -0,0 +1,5 @@
package jd

func ConvertUrl() {

}

+ 8
- 0
jd/errors.go View File

@@ -0,0 +1,8 @@
package jd

import "errors"

var (
ErrTypeIsNil = errors.New("类型为Nil")
ErrTypeUnknown = errors.New("未处理到的数据类型")
)

+ 15
- 0
jd/featured.go View File

@@ -0,0 +1,15 @@
package jd

// Featured is 京粉精选商品 https://open.jd.com/home/home#/doc/api?apiCateId=461&apiId=3588&apiName=jd.union.open.goods.jingfen.query
func Featured(r *RequestJD) ([]byte, error) {
method := "jd.union.open.goods.jingfen.query"
args := map[string]interface{}{
"pageIndex": r.PageIndex,
"pageSize": r.PageSize,
// 1-好券商品,2-精选卖场,10-9.9包邮,15-京东配送,22-实时热销榜,23-为你推荐,24-数码家电,25-超市,26-母婴玩具,27-家具日用,28-美妆穿搭,29-医药保健,30-图书文具,31-今日必推,32-京东好物,33-京东秒杀,34-拼购商品,40-高收益榜,41-自营热卖榜,109-新品首发,110-自营,112-京东爆品,125-首购商品,129-高佣榜单,130-视频商品,153-历史最低价商品榜
"eliteId": r.EliteID,
// 排序字段(price:单价, commissionShare:佣金比例, commission:佣金, inOrderCount30DaysSku:sku维度30天引单量,comments:评论数,goodComments:好评数)
"sortName": r.SortName,
}
return send(method, args)
}

+ 19
- 0
jd/guess.go View File

@@ -0,0 +1,19 @@
package jd

// Guess is 猜你喜欢 https://open.jd.com/home/home#/doc/api?apiCateId=461&apiId=5479&apiName=jd.union.open.goods.material.query
func Guess(r *RequestJD) ([]byte, error) {
method := "jd.union.open.goods.material.query"
args := map[string]interface{}{
"pageIndex": r.PageIndex,
"pageSize": r.PageSize,
// 1-好券商品,2-精选卖场,10-9.9包邮,15-京东配送,22-实时热销榜,23-为你推荐,24-数码家电,25-超市,26-母婴玩具,27-家具日用,28-美妆穿搭,29-医药保健,30-图书文具,31-今日必推,32-京东好物,33-京东秒杀,34-拼购商品,40-高收益榜,41-自营热卖榜,109-新品首发,110-自营,112-京东爆品,125-首购商品,129-高佣榜单,130-视频商品,153-历史最低价商品榜
"eliteId": r.EliteID,
// 排序字段(price:单价, commissionShare:佣金比例, commission:佣金, inOrderCount30DaysSku:sku维度30天引单量,comments:评论数,goodComments:好评数)
"sortName": r.SortName,
}
if r.UserIDType != 0 && r.UserID != "" {
args["userIdType"] = r.UserIDType
args["userId"] = r.UserID
}
return send(method, args)
}

+ 13
- 0
jd/jd_zhimeng.go View File

@@ -0,0 +1,13 @@
package jd

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng"
)

// NewZhiMengJingDongSDK is constructor
func NewZhiMengJingDongSDK() *zhimeng.SDK {
jd := &zhimeng.SDK{}
jd.Init(md.PVD_JD)
return jd
}

+ 88
- 0
jd/model.go View File

@@ -0,0 +1,88 @@
package jd

// 1-好券商品,2-精选卖场,10-9.9包邮,15-京东配送,22-实时热销榜,23-为你推荐,24-数码家电,25-超市,26-母婴玩具,27-家具日用,28-美妆穿搭,29-医药保健,30-图书文具,31-今日必推,32-京东好物,33-京东秒杀,34-拼购商品,40-高收益榜,41-自营热卖榜,109-新品首发,110-自营,112-京东爆品,125-首购商品,129-高佣榜单,130-视频商品,153-历史最低价商品榜
// 排序字段(price:单价, commissionShare:佣金比例, commission:佣金, inOrderCount30DaysSku:sku维度30天引单量,comments:评论数,goodComments:好评数)
//RequestJD is 请求 京东sdk的参数
type RequestJD struct {
PageIndex int `json:"page_index"`
PageSize int `json:"page_size"`
EliteID int `json:"elite_id"`
SortName string `json:"sort_name"`
UserIDType int `json:"userid_type"`
UserID string `json:"user_id"`
}

// JDFeaturedResponse is return from taoke.jd
type JDFeaturedResponse struct {
JdUnionOpenGoodsJingfenQueryResponse struct {
Code string `json:"code"`
Result string `json:"result"`
} `json:"jd_union_open_goods_jingfen_query_response"`
}

// JDFeature is jd 精选 for微信
type JDFeature struct {
BrandCode string `json:"brandCode"`
BrandName string `json:"brandName"`
CategoryInfo struct {
Cid1 int `json:"cid1"`
Cid1Name string `json:"cid1Name"`
Cid2 int `json:"cid2"`
Cid2Name string `json:"cid2Name"`
Cid3 int `json:"cid3"`
Cid3Name string `json:"cid3Name"`
} `json:"categoryInfo"`
Comments int `json:"comments"`
CommissionInfo struct {
Commission float64 `json:"commission"`
CommissionShare float64 `json:"commissionShare"`
CouponCommission float64 `json:"couponCommission"`
PlusCommissionShare float64 `json:"plusCommissionShare"`
} `json:"commissionInfo"`
CouponInfo struct {
CouponList []struct {
BindType int `json:"bindType"`
Discount float64 `json:"discount"`
GetEndTime int64 `json:"getEndTime"`
GetStartTime int64 `json:"getStartTime"`
HotValue int `json:"hotValue"`
IsBest int `json:"isBest"`
Link string `json:"link"`
PlatformType int `json:"platformType"`
Quota float64 `json:"quota"`
UseEndTime int64 `json:"useEndTime"`
UseStartTime int64 `json:"useStartTime"`
} `json:"couponList"`
} `json:"couponInfo"`
GoodCommentsShare float64 `json:"goodCommentsShare"`
ImageInfo struct {
ImageList []struct {
URL string `json:"url"`
} `json:"imageList"`
} `json:"imageInfo"`
InOrderCount30Days int `json:"inOrderCount30Days"`
InOrderCount30DaysSku int `json:"inOrderCount30DaysSku"`
IsHot int `json:"isHot"`
MaterialURL string `json:"materialUrl"`
Owner string `json:"owner"`
PinGouInfo struct {
} `json:"pinGouInfo"`
PriceInfo struct {
LowestCouponPrice float64 `json:"lowestCouponPrice"`
LowestPrice float64 `json:"lowestPrice"`
LowestPriceType int `json:"lowestPriceType"`
Price float64 `json:"price"`
} `json:"priceInfo"`
ResourceInfo struct {
EliteID int `json:"eliteId"`
EliteName string `json:"eliteName"`
} `json:"resourceInfo"`
ShopInfo struct {
ShopID int `json:"shopId"`
ShopLevel float64 `json:"shopLevel"`
ShopName string `json:"shopName"`
} `json:"shopInfo"`
SkuID int64 `json:"skuId"`
SkuName string `json:"skuName"`
Spuid int64 `json:"spuid"`
}

+ 13
- 0
jd/order_track.go View File

@@ -0,0 +1,13 @@
package jd

func OrderTrack() {
method := "jd.union.open.order.query"
args := map[string]interface{}{
"pageNo": "1",
"pageSize": "100",
"type": "3",
"key": "",
}
send(method, args)
return
}

+ 15
- 0
jd/recommend.go View File

@@ -0,0 +1,15 @@
package jd

// Recommend is 京东推荐商品https://open.jd.com/home/home#/doc/api?apiCateId=461&apiId=3588&apiName=jd.union.open.goods.jingfen.query
func Recommend(r *RequestJD) ([]byte, error) {
method := "jd.kpl.open.union.search.byelited"
args := map[string]interface{}{
"pageIndex": r.PageIndex,
"pageSize": r.PageSize,
// 1-好券商品,2-超级大卖场,10-9.9专区,22-热销爆品,23-为你推荐,24-数码家电,25-超市,26-母婴玩具,27-家具日用,28-美妆穿搭,29-医药保健,30-图书文具,31-今日必推,32-品牌好货,33-秒杀商品,34-拼购商品,109-新品首发,110-自营,125-首购商品,129-高佣榜单,130-视频商品
"eliteId": r.EliteID,
// 排序字段price:单价, commissionShare:佣金比例, commission:佣金, inOrderCount30DaysSku:sku维度30天引单量,comments:评论数,goodComments:好评数
"sortName": r.SortName,
}
return send(method, args)
}

+ 95
- 0
jd/sdk.go View File

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

import (
"encoding/json"
)

//SDK is sdk for jd
type SDK struct {
response []byte
fmap map[string]func(*RequestJD)
fname string
err error
}

//Init is init sdk
func (s *SDK) Init() {
s.fmap = make(map[string]func(*RequestJD))
}

//SelectFunction is select func
func (s *SDK) SelectFunction(fname string) *SDK {
s.fname = fname
return s
}

//WithArgs is request args
func (s *SDK) WithArgs(args *RequestJD) *SDK {
f := s.fmap[s.fname]
f(args)
return s
}

// Result is func result
func (s *SDK) Result() (*SDK, error) {
return s, s.err
}

// Register is register func
func (s *SDK) Register(name string, f func(*RequestJD)) {
s.fmap[name] = f
}

//ToBytes is return []byte
func (s *SDK) ToBytes() []byte {
return s.response
}

// ToString is return string
func (s *SDK) ToString() string {
return string(s.response)
}

//ToMapInterface is return map[string]interface{}
func (s *SDK) ToMapInterface() map[string]interface{} {
m := make(map[string]interface{})
json.Unmarshal(s.response, &m)
return m
}

// Featured is jd 精选列表
func (s *SDK) Featured(r *RequestJD) {
d, err := Featured(r)
if err != nil {
s.err = err
}
s.response = d
}

// Guess is 猜你喜欢列表
func (s *SDK) Guess(r *RequestJD) {
d, err := Guess(r)
if err != nil {
s.err = err
}
s.response = d
}

// Recommend is 推荐列表
func (s *SDK) Recommend(r *RequestJD) {
d, err := Recommend(r)
if err != nil {
s.err = err
}
s.response = d
}

//NewJDSDK is jingdong sdk
func NewJDSDK() *SDK {
sdk := new(SDK)
sdk.Init()
sdk.Register("featured", sdk.Featured)
sdk.Register("guess", sdk.Guess)
sdk.Register("recommend", sdk.Recommend)
return sdk
}

+ 101
- 0
md/kuaishou.go View File

@@ -0,0 +1,101 @@
package md

type KuaishouOrder struct {
Pcursor string `json:"pcursor"`
OrderView []OrderView `json:"orderView"`
}
type OrderView struct {
Oid int `json:"oid"`
ActivityUserId int `json:"activityUserId"`
ActivityId int `json:"activityId"`
CpsOrderStatus int `json:"cpsOrderStatus"`
OrderCreateTime int64 `json:"orderCreateTime"`
OrderTradeAmount int64 `json:"orderTradeAmount"`
PayAmount int `json:"payAmount"`
RegimentalPromotionRate int `json:"regimentalPromotionRate"`
RegimentalPromotionAmount int `json:"regimentalPromotionAmount"`
CpsOrderProductView []struct {
Oid int64 `json:"oid"`
ItemId int64 `json:"itemId"`
ItemTitle string `json:"itemTitle"`
ItemPrice int64 `json:"itemPrice"`
SellerId int64 `json:"sellerId"`
SellerNickName string `json:"sellerNickName"`
SkuId int `json:"skuId"`
} `json:"cpsOrderProductView"`
CreateTime int64 `json:"createTime"`
UpdateTime int64 `json:"updateTime"`
SendTime int64 `json:"sendTime"`
SendStatus int `json:"sendStatus"`
RecvTime int64 `json:"recvTime"`
PromotionId int `json:"promotionId"`
PromotionNickName string `json:"promotionNickName"`
PromotionType int `json:"promotionType"`
SettlementAmount int `json:"settlementAmount"`
SettlementTime int64 `json:"settlementTime"`
SettlementSuccessTime int64 `json:"settlementSuccessTime"`
BuyerOpenId string `json:"buyerOpenId"`
PromotionKwaiId string `json:"promotionKwaiId"`
ExpendRegimentalSettleAmount int `json:"expendRegimentalSettleAmount"`
ExpendEstimateSettleAmount int `json:"expendEstimateSettleAmount"`
ExpendRegimentalPromotionRate int `json:"expendRegimentalPromotionRate"`
BaseAmount int `json:"baseAmount"`
ShareRateStr string `json:"shareRateStr"`
ExcitationInCome int `json:"excitationInCome"`
ServiceIncome int `json:"serviceIncome"`
SettlementBizType int `json:"settlementBizType"`
FundType int `json:"fundType"`
KwaimoneyUserId int `json:"kwaimoneyUserId"`
KwaimoneyUserNickName string `json:"kwaimoneyUserNickName"`
}

type KuaishouGoods struct {
GoodsId int `json:"goodsId"`
GoodsPrice int `json:"goodsPrice"`
GoodsTitle string `json:"goodsTitle"`
GoodsDesc string `json:"goodsDesc"`
MallId int `json:"mallId"`
MallName string `json:"mallName"`
MallType int `json:"mallType"`
GoodsImageUrl string `json:"goodsImageUrl"`
CategoryId int `json:"categoryId"`
PromotionRate int `json:"promotionRate"`
SalesTip int `json:"salesTip"`
GoodsGalleryUrls interface{} `json:"goodsGalleryUrls"`
PromotionAmount int `json:"promotionAmount"`
ItemDescUrls interface{} `json:"itemDescUrls"`
ExpressId int `json:"expressId"`
ZkGoodsPrice int `json:"zkGoodsPrice"`
}
type KuaishouCpsOrder struct {
Oid int `json:"oid"`
CpsOrderStatus int `json:"cpsOrderStatus"`
OrderCreateTime int `json:"orderCreateTime"`
PayTime int `json:"payTime"`
OrderTradeAmount int `json:"orderTradeAmount"`
CreateTime int64 `json:"createTime"`
UpdateTime int64 `json:"updateTime"`
SettlementSuccessTime int64 `json:"settlementSuccessTime"`
SettlementAmount int `json:"settlementAmount"`
CpsKwaimoneyOrderProductView []struct {
Oid int `json:"oid"`
ItemId int `json:"itemId"`
ItemTitle string `json:"itemTitle"`
ItemPicUrl string `json:"itemPicUrl"`
ItemPrice int `json:"itemPrice"`
SkuDesc string `json:"skuDesc"`
EstimatedIncome int `json:"estimatedIncome"`
CommissionRate int `json:"commissionRate"`
PaymentFee int `json:"paymentFee"`
CpsPid string `json:"cpsPid"`
SellerId int `json:"sellerId"`
SellerNickname string `json:"sellerNickname"`
Num int `json:"num"`
CpsType int `json:"cpsType"`
DistributorId int `json:"distributorId"`
DistributorNickname string `json:"distributorNickname"`
Comments string `json:"comments"`
} `json:"cpsKwaimoneyOrderProductView"`
BaseAmount int `json:"baseAmount"`
ShareRateStr string `json:"shareRateStr"`
}

+ 98
- 0
md/md_chain.go View File

@@ -0,0 +1,98 @@
package md

type TCPrase struct {
Count string `json:"count"` //转链内容
SuccessCount string `json:"success_count"` //转链内容
FailCount string `json:"fail_count"` //转链内容
GID string `json:"gid"` //商品id
GoodsMinImg string `json:"goods_min_img"` //商品小图片
GoodsImg string `json:"goods_img"` //商品图片
GoodsTitle string `json:"goods_title"` //商品标题
Provider string `json:"provider"` //渠道代码
ProviderName string `json:"provider_name"` //渠道名字
GoodsCostPrice string `json:"goods_cost_price"` //原价
Commission string `json:"commission"` //反的价钱
FCommission string `json:"f_commission"` //反的价钱
WlGoodsPrice string `json:"wl_goods_price"` //卷后价
CouponPrice string `json:"coupon_price"` //优惠券价
ShareValue string `json:"share_value"` //分享赚
ProductDetail *ProductDetailResponse `json:"detail_data"` //商品详情
TurnChainLink string `json:"turn_chain_link"` // 转链后的链接
CommissionRate string `json:"commission_rate"`
Tkl string `json:"tkl"` // 淘口令
IsTkl string `json:"is_tkl"` // 淘口令
DownloadLink string `json:"downloadLink"`
InviteCode string `json:"invite_code"`
IsNeedAuth string `json:"is_need_auth"`
PlatType string `json:"plat_type"`
TurnGoods []TurnGoods `json:"turn_goods"`
}
type TurnGoods struct {
GID string `json:"gid"` //商品id
GoodsMinImg string `json:"goods_min_img"` //商品小图片
GoodsImg string `json:"goods_img"` //商品图片
GoodsTitle string `json:"goods_title"` //商品标题
Provider string `json:"provider"` //渠道代码
ProviderName string `json:"provider_name"` //渠道名字
GoodsCostPrice string `json:"goods_cost_price"` //原价
Commission string `json:"commission"` //反的价钱
FCommission string `json:"f_commission"` //反的价钱
WlGoodsPrice string `json:"wl_goods_price"` //卷后价
CouponPrice string `json:"coupon_price"` //优惠券价
ShareValue string `json:"share_value"` //分享赚
ProductDetail *ProductDetailResponse `json:"detail_data"` //商品详情
TurnChainLink string `json:"turn_chain_link"` // 转链后的链接
CommissionRate string `json:"commission_rate"`
Tkl string `json:"tkl"` // 淘口令
IsTkl string `json:"is_tkl"` // 淘口令
Url string `json:"url"`
}

type ItemParseInfo struct {
ItemId string `json:"item_id"` // 商品ID
Title string `json:"title"` // 标题
CategoryId string `json:"category_id"` // 目录ID
CategoryName string `json:"category_name"` // 目录名
Price string `json:"price"` // 价格
PriceOriginal string `json:"price_original"` // 原价
Commission string `json:"commission"` // 可赚取佣金
CommissionRate string `json:"commission_rate"` // 佣金比例
CouponUrl string `json:"coupon_url"` // 优惠券地址
DetailUrl string `json:"detail_url"` // 优惠券地址
APPUrl string `json:"app_url"` // 唤起app地址
CouponPrice float64 `json:"coupon_price"` // 优惠券面值
FinalPrice string `json:"final_price"` // 券后价
EarnPrice string `json:"earn_price"` //立省
Thumbnail string `json:"thumbnail"` // 缩略图
Provider string `json:"provider"` // 供应商
ProviderName string `json:"providerName"` // 供应商名称
GoodsDesc string `json:"goodsDesc"` //描述
GoodsImgList []string `json:"goodsImgList"` //商品多组图片
ImageList []string `json:"imgList"`
Video []interface{} `json:"video"`
InOrderCount string `json:"inOrderCount"`
DetailImgList []string `json:"detailImgList"`
GoodsSales string `json:"goods_sales"`
ShopName string `json:"shop_name"`
Word string `json:"word"`
Param ParamData `json:"param"`
IsNeedChangeUrl string `json:"is_need_change_url"`
Pvd string `json:"pvd"`
IsFav string `json:"is_fav"`
ShareUrlArgs map[string]interface{} `json:"share_url_args"`
FavArgs interface{} `json:"fav_args"`
ActivityId string `json:"activity_id"`
Url string `json:"url"`
NewProvider string `json:"new_provider"`
}
type ParamData struct {
GID string `json:"gid"`
GoodURL string `json:"good_url"`
CouponURL string `json:"coupon_url"`
CouponPrice string `json:"coupon_price"`
ActivityURL string `json:"activity_url"`
IsShare string `json:"is_share"`
IsFree string `json:"is_free"`
IsWxMini string `json:"is_wx_mini"`
Commission string `json:"commission"`
}

+ 26
- 0
md/official_recommend_list.go View File

@@ -0,0 +1,26 @@
package md

// 美团

type OfficialRecommendUrl struct {
Url string // 链接
WxQrcodeUrl string
WxMiniprogramPath string
AppUrl string
Appid string
Id string //小程序原始id
TaobaoWord string
ClickUrl string
Seq string
Title string
Content string
SuccessContent string
}
type ActivityPlatform struct {
ActivityPlatformId string `json:"activity_id"`
MaterialId string `json:"material_id"`
ActivityPlatformUrl string `json:"url"`
}
type KaolaActivityList struct {
Url string `json:"shareLink"`
}

+ 3
- 0
md/product_detail.go View File

@@ -65,6 +65,7 @@ type DetailResponse struct {

// MoreDetailResponse is for response detail
type MoreDetailResponse struct {
ClickUrl string `json:"click_url"`
GID string `json:"gid"`
GoodsImg string `json:"goods_img"`
GoodsTitle string `json:"goods_title"`
@@ -162,6 +163,8 @@ type PlatformCss struct {

// ProductDetailResponse productdetail
type ProductDetailResponse struct {
ClickUrl string `json:"click_url"`
IsNull string `json:"is_null"`
IsCanBuy string `json:"is_can_buy"` //是否能购买
IsShowCouponList string `json:"is_show_coupon_list"` //是否展示优惠券弹出
UserCouponAmount string `json:"user_coupon_amount"` //优惠券额度


+ 1
- 0
md/provider.go View File

@@ -18,6 +18,7 @@ const (
PVD_STARBUCKS = "starbucks"
PVD_MCDONALD = "mcdonald"
PVD_NAYUKI = "nayuki"
PVD_TIKTOKLIFE = "tikTok_life"
PVD_BURGERKING = "burger_king"
PVD_HEYTEA = "heytea"
PVD_PIZZA = "pizza"


+ 26
- 25
md/tik_tok.go View File

@@ -1,29 +1,30 @@
package md

type TikTokBase struct {
AuthType string `json:"auth_type"`
LiveAuthType string `json:"live_auth_type"`
ApiGoodsAppKey string `json:"api_goods_app_key"`
ApiGoodsAppSecret string `json:"api_goods_app_secret"`
ApiTeamAppKey string `json:"api_team_app_key"`
ApiTeamAppSecret string `json:"api_team_app_secret"`
ApiLiveAppKey string `json:"api_live_app_key"`
ApiLiveAppSecret string `json:"api_live_app_secret"`
GoodsAccessToken string `json:"goods_access_token"`
LiveAccessToken string `json:"live_access_token"`
TeamAccessToken string `json:"team_access_token"`
GoodsPid string `json:"goods_pid"`
LivePid string `json:"live_pid"`
SysApiGoodsAppKey string `json:"sys_api_goods_app_key"`
SysApiGoodsAppSecret string `json:"sys_api_goods_app_secret"`
SysApiTeamAppKey string `json:"sys_api_team_app_key"`
SysApiTeamAppSecret string `json:"sys_api_team_app_secret"`
SysApiLiveAppKey string `json:"sys_api_live_app_key"`
SysApiLiveAppSecret string `json:"sys_api_live_app_secret"`
SysGoodsAccessToken string `json:"sys_goods_access_token"`
SysLiveAccessToken string `json:"sys_live_access_token"`
SysGoodsPid string `json:"sys_goods_pid"`
SysLivePid string `json:"sys_live_pid"`
AuthSubjectType string `json:"auth_subject_type"`
LiveAuthSubjectType string `json:"live_auth_subject_type"`
AuthType string `json:"auth_type"`
LiveAuthType string `json:"live_auth_type"`
ApiGoodsAppKey string `json:"api_goods_app_key"`
ApiGoodsAppSecret string `json:"api_goods_app_secret"`
ApiTeamAppKey string `json:"api_team_app_key"`
ApiTeamAppSecret string `json:"api_team_app_secret"`
ApiLiveAppKey string `json:"api_live_app_key"`
ApiLiveAppSecret string `json:"api_live_app_secret"`
GoodsAccessToken string `json:"goods_access_token"`
LiveAccessToken string `json:"live_access_token"`
TeamAccessToken string `json:"team_access_token"`
GoodsPid string `json:"goods_pid"`
LivePid string `json:"live_pid"`
SysApiGoodsAppKey string `json:"sys_api_goods_app_key"`
SysApiGoodsAppSecret string `json:"sys_api_goods_app_secret"`
SysApiTeamAppKey string `json:"sys_api_team_app_key"`
SysApiTeamAppSecret string `json:"sys_api_team_app_secret"`
SysApiLiveAppKey string `json:"sys_api_live_app_key"`
SysApiLiveAppSecret string `json:"sys_api_live_app_secret"`
SysGoodsAccessToken string `json:"sys_goods_access_token"`
SysLiveAccessToken string `json:"sys_live_access_token"`
SysGoodsPid string `json:"sys_goods_pid"`
SysLivePid string `json:"sys_live_pid"`
AuthSubjectType string `json:"auth_subject_type"`
LiveAuthSubjectType string `json:"live_auth_subject_type"`
ExtendTeamTokenMap map[string]interface{} `json:"extend_team_token_map"`
}

+ 1
- 0
md/url.go View File

@@ -9,6 +9,7 @@ type ExtraData struct {
// 转链后链接
type ConvertedUrls struct {
ItemId string `json:"item_id"`
ItemUrl string `json:"item_url"`
NumGoodsId string `json:"num_goods_id"`
URL string `json:"url"` // 短链接
ShortenURL string `json:"open_app_url"` // 会打开app的长链接


+ 49
- 0
pdd/api.go View File

@@ -0,0 +1,49 @@
package pdd

import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"sort"
"strings"
"time"
)

var (
PDD_HOST = "http://gw-api.pinduoduo.com/api/router"
PDD_AK = "43eed45f20d94fbf828744a77a45e3e2"
PDD_SK = "6ccdd6614f804ed8b0e23c2721be857da3a04b5b"
PDD_CS = "4ee672167e1ee51aa3a9ea864d33629a230a114c"
)

func send(args map[string]interface{}, method string) ([]byte, error) {
args["timestamp"] = zhios_third_party_utils.Int64ToStr(time.Now().UnixNano() / 1e6)
args["data_type"] = "JSON"
args["client_id"] = PDD_AK
args["type"] = method
args["sign"] = sign(args, PDD_CS)
bargs, err := json.Marshal(args)
if err != nil {
return nil, err
}
return zhios_third_party_utils.CurlPost(PDD_HOST, bargs, nil)
}

func sign(m map[string]interface{}, sk string) string {
// key sort
keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)
str := ""
for _, k := range keys {
switch m[k].(type) {
case int:
str += k + zhios_third_party_utils.IntToStr(m[k].(int))
case string:
str += k + m[k].(string)
}
}
str = sk + str + sk
return strings.ToUpper(zhios_third_party_utils.Md5(str))
}

+ 13
- 0
pdd/detail.go View File

@@ -0,0 +1,13 @@
package pdd

// 多多进宝API
// https://open.pinduoduo.com/application/document/api?id=pdd.ddk.goods.recommend.get
//func Detail() {
// method := "pdd.ddk.goods.recommend.get"
// args := map[string]interface{}{
// "channel_type": "", // 非必填, 0-1.9包邮, 1-今日爆款, 2-品牌清仓,3-相似商品推荐,4-猜你喜欢,5-实时热销,6-实时收益,7-今日畅销,8-高佣榜单,默认1
// "limit": 400, // 非必填, 请求数量;默认值 : 400
// "offset": 400, // 非必填, 从多少位置开始请求;默认值 : 0,offset需是limit的整数倍,仅支持整页翻页
// //"list_id": "", // 非必填,翻页时建议填写前页返回的list_id值
// }
//}

+ 10
- 0
pdd/pdd_zhimeng.go View File

@@ -0,0 +1,10 @@
package pdd

import "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng"

// NewZhiMengJingDongSDK is constructor
func NewZhiMengPDDSDK() *zhimeng.SDK {
pdd := &zhimeng.SDK{}
pdd.Init("pdd")
return pdd
}

+ 91
- 0
pdd/recommend.go View File

@@ -0,0 +1,91 @@
package pdd

import (
"encoding/json"
)

type PddRecommendItem struct {
CouponRemainQuantity int `json:"coupon_remain_quantity"`
PromotionRate int `json:"promotion_rate"`
CatIds []int `json:"cat_ids"`
CouponMinOrderAmount int `json:"coupon_min_order_amount"`
MallID int `json:"mall_id"`
MallName string `json:"mall_name"`
CouponTotalQuantity int `json:"coupon_total_quantity"`
MerchantType string `json:"merchant_type"`
LgstTxt string `json:"lgst_txt"`
GoodsName string `json:"goods_name"`
SalesTip string `json:"sales_tip"`
GoodsID string `json:"goods_sign"`
DescTxt string `json:"desc_txt"`
PredictPromotionRate int `json:"predict_promotion_rate"`
GoodsDesc string `json:"goods_desc"`
OptName string `json:"opt_name"`
GoodsThumbnailURL string `json:"goods_thumbnail_url"`
OptID string `json:"opt_id"`
OptIds []int `json:"opt_ids"`
SearchID string `json:"search_id"`
GoodsImageURL string `json:"goods_image_url"`
HasCoupon bool `json:"has_coupon"`
MinNormalPrice float64 `json:"min_normal_price"`
ServTxt string `json:"serv_txt"`
CouponStartTime int `json:"coupon_start_time"`
MinGroupPrice float64 `json:"min_group_price"`
CouponDiscount int `json:"coupon_discount"`
CouponEndTime int `json:"coupon_end_time"`
}
type PddRecommend struct {
GoodsBasicDetailResponse struct {
Total int `json:"total"`
ListID string `json:"list_id"`
List []PddRecommendItem `json:"list"`
RequestID string `json:"request_id"`
SearchID string `json:"search_id"`
} `json:"goods_basic_detail_response"`
}

// 多多进宝API
// https://open.pinduoduo.com/application/document/api?id=pdd.ddk.goods.recommend.get
func Recommend(page, size, id, gid, cid string) (*PddRecommend, error) {
method := "pdd.ddk.goods.recommend.get"
args := map[string]interface{}{
//"channel_type": id, // 非必填, 0-1.9包邮, 1-今日爆款, 2-品牌清仓,3-相似商品推荐,4-猜你喜欢,5-实时热销,6-实时收益,7-今日畅销,8-高佣榜单,默认1
"limit": size, // 非必填, 请求数量;默认值 : 400
"offset": page, // 非必填, 从多少位置开始请求;默认值 : 0,offset需是limit的整数倍,仅支持整页翻页
//"list_id": "", // 非必填,翻页时建议填写前页返回的list_id值
}
//fmt.Println(gid)
if id != "" {
args["channel_type"] = id
}
if gid != "" {
args["goods_ids"] = []string{gid}
args["channel_type"] = "3"
}
if cid != "" {
//20100-百货,20200-母婴,20300-食品,20400-女装,20500-电器,20600-鞋包,20700-内衣,20800-美妆,20900-男装,21000-水果,21100-家纺,21200-文具,21300-运动,21400-虚拟,21500-汽车,21600-家装,21700-家具,21800-医药;
args["cat_id"] = cid
args["channel_type"] = "4"
}
// fmt.Println(args)
data, err := send(args, method)
if err != nil {
return nil, err
}
// fmt.Println(string(data))
r := new(PddRecommend)
if err := json.Unmarshal(data, &r); err != nil {
return nil, err
}
return r, nil
}

// 爆款排行商品接口
//func Hot() {
// method := "pdd.ddk.top.goods.list.query"
// args := map[string]interface{}{
// "limit": 400, // 非必填, 请求数量;默认值 : 400
// "offset": 400, // 非必填, 从多少位置开始请求;默认值 : 0,offset需是limit的整数倍,仅支持整页翻页
// "sort_type": "", // 非必填, 1-实时热销榜;2-实时收益榜
// }
//}

+ 36
- 0
tik_tok/svc_tik_tok_convert.go View File

@@ -180,3 +180,39 @@ func OwnTikTokUrl(tikTokBase *md.TikTokBase, tikTokArgs map[string]interface{})
H5Url: url["share_link"],
}, nil
}
func OwnTikTokActUrl(tikTokBase *md.TikTokBase, tikTokArgs map[string]interface{}) (*md.ConvertedUrls, error) {
args := map[string]string{
"appkey": tikTokBase.ApiGoodsAppKey,
"appSecret": tikTokBase.ApiGoodsAppSecret,
"activity_id": zhios_third_party_utils.AnyToString(tikTokArgs["activity_id"]),
"mix_activity_id": zhios_third_party_utils.AnyToString(tikTokArgs["mix_activity_id"]),
"need_qr_code": zhios_third_party_utils.AnyToString(tikTokArgs["need_qr_code"]),
"external_info": zhios_third_party_utils.AnyToString(tikTokArgs["external_info"]),
"pid": tikTokBase.GoodsPid,
"acctoken": tikTokBase.GoodsAccessToken,
}
fmt.Println("抖音", args)
var url map[string]string
var err string
if tikTokBase.AuthSubjectType == "DouKe" {
args["material_id"] = zhios_third_party_utils.AnyToString(tikTokArgs["material_id"])
url, err = DkActConvertUrl(args)
} else {
url, err = ActConvertUrl(args)
}
//url, err = tik_tok.ActConvertUrl(args)

if err != "" {
return nil, errors.New(err)
}
content, _ := php2go.Base64Decode(url["content"])
return &md.ConvertedUrls{
URL: url["deeplink"],
ShortenURL: url["deeplink"],
NoOpenAppURL: url["deeplink"],
AppURL: url["deeplink"],
ClickUrl: url["deeplink"],
QrcodeUrl: url["qr_code"],
Content: content,
}, nil
}

+ 33
- 0
tik_tok/svc_tik_tok_goods.go View File

@@ -3,8 +3,10 @@ package tik_tok
import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng"
"encoding/json"
"fmt"
"github.com/jinzhu/copier"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"strings"
@@ -280,3 +282,34 @@ func CommGoodsDetail(goods TikTokGoodsLm) TikTokGoods {
return tmp

}
func OwnTikTokGoodsKlNew(tikTokBase *md.TikTokBase, tikTokArgs map[string]interface{}) (*zhimeng.TikTokDetailData, error) {
args := map[string]string{
"appkey": tikTokBase.ApiGoodsAppKey,
"appSecret": tikTokBase.ApiGoodsAppSecret,
"content": php2go.Base64Encode(tikTokArgs["content"].(string)),
"acctoken": tikTokBase.SysGoodsAccessToken,
}
for k, v := range args {
if v == "<nil>" {
args[k] = ""
}
}
var data = zhimeng.TikTokDetailData{}
goods := GetKlGoodsNew(args)
if goods.ActivityId != "" {
data.ActivityId = goods.ActivityId
return &data, nil
}

if goods.GoodsID == "" {
return nil, nil
}
err := copier.Copy(&data, goods)
if err != nil {
return nil, nil
}
if zhios_third_party_utils.StrToFloat64(data.YhqPrice) > 0 {
data.Price = data.CostPrice
}
return &data, nil
}

+ 135
- 0
utils/open_platform.go View File

@@ -0,0 +1,135 @@
package zhios_third_party_utils

import (
"encoding/json"
"errors"
"fmt"
"sort"
"time"
)

// 调用开放平台的封装
type OpenPlatformReqClient struct {
AppKey string
AppSecret string
Method string
Version string
Timestamp string
Nonce string
Url string
Sign string
BizData map[string]interface{}
params map[string]string
ReturnData ReturnDataResp
}

type ReturnDataResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}

func NewOpenPlatformReqClient(appKey, method, version, appSecret string, bizData map[string]interface{}) (*OpenPlatformReqClient, error) {
if appKey == "" || appSecret == "" || method == "" || version == "" {
return nil, errors.New("appKey,method,version not allow empty")
}
nowStr := AnyToString(time.Now().Unix())
nonce := UUIDString()
return &OpenPlatformReqClient{
AppKey: appKey,
AppSecret: appSecret,
Method: method,
Version: version,
Nonce: nonce,
Timestamp: nowStr,
params: map[string]string{"app_key": appKey, "method": method, "version": version, "timestamp": nowStr, "nonce": nonce},
BizData: bizData,
}, nil
}

func (client *OpenPlatformReqClient) CurlOpen() error {
if client.params == nil {
return errors.New("params not allow empty")
}
url := client.Url + "/api/open/gw"
fmt.Printf("%#v\n", string(Serialize(client.params)))
resp, err := CurlPost(url, Serialize(client.params), nil)
if err != nil {
return err
}
err = json.Unmarshal(resp, &client.ReturnData)
if err != nil {
return err
}
return nil
}

/*func (client *OpenPlatformReqClient) CreateParams() *OpenPlatformReqClient {
client.params["timestamp"] = client.Timestamp
client.params["nonce"] = client.Nonce
//client.params["biz_data"] = SerializeStr(client.BizData)
return client
}*/

func (client *OpenPlatformReqClient) SetBizDataToParams() *OpenPlatformReqClient {
client.params["biz_data"] = SerializeStr(client.BizData)
return client
}

func (client *OpenPlatformReqClient) SetParams(key, value string) *OpenPlatformReqClient {
client.params[key] = value
return client
}

func (client *OpenPlatformReqClient) GetParams(key string) string {
return client.params[key]
}

func (client *OpenPlatformReqClient) CreateSign() *OpenPlatformReqClient {
/*if client.BizData != nil {
for key := range client.BizData {
client.params[key] = AnyToString2(client.BizData[key])
}
}*/
var keys []string
for key := range client.params {
keys = append(keys, key)
}
sort.Strings(keys)
str := ""
for _, key := range keys {
str += fmt.Sprintf("%v=%v&", key, client.params[key])
}
str = client.AppSecret + str[:len(str)-1] + client.AppSecret
fmt.Printf("sign: %s\n", str)
client.Sign = Md5(str)
client.params["sign"] = client.Sign
if client.BizData != nil {
for key := range client.BizData {
if _, ok := client.params[key]; ok {
delete(client.params, key)
}
}
}
return client
}

func (client *OpenPlatformReqClient) VerifySign(sign string) bool {
if sign == "" || client.Sign == "" {
return false
}
if client.Sign == sign {
return true
}
return false
}

func (client *OpenPlatformReqClient) ResetNonce() *OpenPlatformReqClient {
client.Nonce = UUIDString()
return client
}

func (client *OpenPlatformReqClient) ResetTimestamp() *OpenPlatformReqClient {
client.Timestamp = AnyToString(time.Now().Unix())
return client
}

+ 40
- 0
utils/string.go View File

@@ -5,9 +5,12 @@ import (
"github.com/syyongx/php2go"
"math/rand"
"reflect"
"regexp"
"sort"
"strings"
"time"
"unicode"
"unicode/utf8"
)

func Implode(glue string, args ...interface{}) string {
@@ -36,6 +39,43 @@ func InArrToInt(target int, str_array []int) bool {
return false
}

//是否有中文
func IsChineseChar(str string) bool {
for _, r := range str {
if unicode.Is(unicode.Scripts["Han"], r) || (regexp.MustCompile("[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]").MatchString(string(r))) {
return true
}
}
return false
}

func FilterEmoji(content string) string {
new_content := ""
for _, value := range content {
_, size := utf8.DecodeRuneInString(string(value))
if size <= 3 {
new_content += string(value)
}
}
return new_content
}
func IsAllChinese(str string) bool {
str = FilterEmoji(str)

arr := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "/", ":"}
for _, v := range arr {
str = strings.ReplaceAll(str, v, "")
}
strNew := str
for _, c := range strNew {
if !unicode.Is(unicode.Scripts["Han"], c) {
return false
}
}
return true

}

//把数组的值放到key里
func ArrayColumn(array interface{}, key string) (result map[string]interface{}, err error) {
result = make(map[string]interface{})


+ 36
- 0
zhimeng/kuaishou_goods.go View File

@@ -56,3 +56,39 @@ func KuaiShouGoods(tikTokArgs map[string]interface{}) []map[string]string {
}
return goods
}
func KuaiShouKlGoods(tikTokArgs map[string]interface{}) (*TikTokDetailData, error) {
args := map[string]interface{}{
"appkey": tikTokArgs["appkey"],
"secret_key": tikTokArgs["secret_key"],
"content": tikTokArgs["content"],
}
resp, err := Send("kuaishou", "getKlGoods", args)
if err != nil {
return nil, err
}
var tmp struct {
Data TikTokDetailData `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
return &tmp.Data, nil
}
func KuaiShouDetail(tikTokArgs map[string]interface{}) (*TikTokDetailData, error) {
args := map[string]interface{}{
"appkey": tikTokArgs["appkey"],
"secret_key": tikTokArgs["secret_key"],
"id": tikTokArgs["gid"],
}
resp, err := Send("kuaishou", "getGoodsDetail", args)
if err != nil {
return nil, err
}
var tmp struct {
Data TikTokDetailData `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
return &tmp.Data, nil
}

+ 116
- 0
zhimeng/pdd_convert_url.go View File

@@ -2,6 +2,7 @@ package zhimeng

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"fmt"
)
@@ -48,3 +49,118 @@ func PDDConvertUrl(ak, sk, itemId, promoId, couponPrice, isWxMini, isBindUrl, is
CommissionRate: couponPrice,
}, nil
}

//生成多多进宝频道推广
func PDDActivityConvertUrl(ak, sk, resourceType, pid, promoId, url string, isShare int) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": ak,
"secret_key": sk,
"resource_type": resourceType,
"pid": pid,
"url": url,
"custom_parameters": promoId,
"is_share": zhios_third_party_utils.IntToStr(isShare),
}
//generate_authority_url_onoff 0不会调授权链接 1会先跳授权链接
fmt.Println("拼多多:", args)

resp, err := Send("pdd", "get_main_theme_url", args)
if err != nil {
return nil, err
}
var tmp struct {
Data struct {
URL string `json:"url"`
OpenAppURL string `json:"open_app_url"`
NoOpenAppURL string `json:"no_open_app_url"`
SchemaURL string `json:"schema_url"`
PagePath string `json:"page_path"`
} `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
return &md.ConvertedUrls{
URL: tmp.Data.URL,
ShortenURL: tmp.Data.NoOpenAppURL,
NoOpenAppURL: tmp.Data.OpenAppURL,
AppURL: tmp.Data.SchemaURL,
WeChatMiniURL: tmp.Data.PagePath,
}, nil
}

//生成商城-频道推广链接
func PDDActivityStoreConvertUrl(ak, sk, resourceType, pid, promoId, url string, isShare int) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": ak,
"secret_key": sk,
"channel_type": resourceType,
"pid": pid,
"custom_parameters": promoId,
"is_share": zhios_third_party_utils.IntToStr(isShare),
}
//generate_authority_url_onoff 0不会调授权链接 1会先跳授权链接
fmt.Println("拼多多:", args)

resp, err := Send("pdd", "get_prom_url", args)
if err != nil {
return nil, err
}
var tmp struct {
Data struct {
URL string `json:"url"`
OpenAppURL string `json:"open_app_url"`
NoOpenAppURL string `json:"no_open_app_url"`
SchemaURL string `json:"schema_url"`
PagePath string `json:"page_path"`
} `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
return &md.ConvertedUrls{
URL: tmp.Data.URL,
ShortenURL: tmp.Data.NoOpenAppURL,
NoOpenAppURL: tmp.Data.OpenAppURL,
AppURL: tmp.Data.SchemaURL,
WeChatMiniURL: tmp.Data.PagePath,
}, nil
}

//生成营销工具推广链接
func PDDActivitySaleConvertUrl(ak, sk, resourceType, pid, promoId, url string, isShare int) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": ak,
"secret_key": sk,
"channel_type": resourceType,
"pid": pid,
"custom_parameters": promoId,
"is_share": zhios_third_party_utils.IntToStr(isShare),
}
//generate_authority_url_onoff 0不会调授权链接 1会先跳授权链接
fmt.Println("拼多多:", args)

resp, err := Send("pdd", "get_rp_url", args)
if err != nil {
return nil, err
}
var tmp struct {
Data struct {
URL string `json:"url"`
OpenAppURL string `json:"open_app_url"`
NoOpenAppURL string `json:"no_open_app_url"`
SchemaURL string `json:"schema_url"`
PagePath string `json:"page_path"`
} `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
return &md.ConvertedUrls{
URL: tmp.Data.URL,
ShortenURL: tmp.Data.NoOpenAppURL,
NoOpenAppURL: tmp.Data.OpenAppURL,
AppURL: tmp.Data.SchemaURL,
WeChatMiniURL: tmp.Data.PagePath,
}, nil
}

+ 1
- 0
zhimeng/tik_tok_goods.go View File

@@ -62,6 +62,7 @@ type TikTokDetailData struct {
Imgs []string `json:"imgs"`
DetailImgs []string `json:"detail_imgs"`
ShopTotalScore interface{} `json:"shop_total_score"`
ActivityId string `json:"activity_id"`
}
type ShopTotalScore struct {
LogisticsScore struct {


+ 54
- 0
zhimeng/word_parse.go View File

@@ -0,0 +1,54 @@
package zhimeng

import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"errors"
)

// 搜索提示关键字
func SearchTips(s string) ([]string, error) {
res, err := Send("tb_keyword", "index", map[string]interface{}{"keyword": s})
if err != nil {
return nil, err
}
tmp := struct {
Success int `json:"success,omitempty"`
Msg string `json:"msg,omitempty"`
Data []string `json:"data,omitempty"`
}{}
err = json.Unmarshal(res, &tmp)
if err != nil {
return nil, err
}
if tmp.Success != StatusSuc {
return nil, errors.New(tmp.Msg)
}
return tmp.Data, nil
}

// 解析淘口令, 成功返回产品goods_ID,失败返回空字符串
func WordParse(ak, sk, pid, s, sid, tbAppKey string) struct {
Gid string `json:"gid"`
} {
resp, err := Send("agent_tb", "tkl_gid", map[string]interface{}{
"appkey": ak,
"secret_key": sk,
"session": sid,
"keyword": s,
"pid": pid,
"tb_app_key": tbAppKey,
})
if err != nil {
return struct {
Gid string `json:"gid"`
}{}
}
var tmp struct {
Data struct {
Gid string `json:"gid"`
} `json:"data"`
}
zhios_third_party_utils.Unserialize(resp, &tmp)
return tmp.Data
}

Loading…
Cancel
Save