diff --git a/platformapi/pddapi/union.go b/platformapi/pddapi/union.go index 1dbbdeff..3c36068c 100644 --- a/platformapi/pddapi/union.go +++ b/platformapi/pddapi/union.go @@ -4,6 +4,14 @@ import "git.rosy.net.cn/baseapi/utils" const ( cthMediaID = 9180924964 + + resouceTypeSecKill = 4 //限时秒杀 + resouceTypeCharge = 39997 //充值中心, + resouceTypeActChangeLink = 39998 //活动转链, + resouceTypeBYBT = 39996 //百亿补贴, + resouceTypeDQC = 39999 //电器城, + resouceTypeLQZX = 40000 //领券中心, + resouceTypeHCP = 50005 //火车票 ) type GoodsOPidGenerateResult struct { @@ -142,3 +150,58 @@ func (a *API) ActivityOperationList() (activityOperationListResult []*ActivityOp } return activityOperationListResult, err } + +type RpPromURLGenerateResult struct { + ResourceList []struct { + URL string `json:"url"` + Desc string `json:"desc"` + } `json:"resource_list"` + RequestID string `json:"request_id"` +} + +//生成营销工具推广链接 +func (a *API) RpPromURLGenerate(pid string) (rpPromURLGenerateResult *RpPromURLGenerateResult, err error) { + result, err := a.AccessAPI("pdd.ddk.rp.prom.url.generate", false, map[string]interface{}{ + "p_id_list": []string{"\"" + pid + "\""}, + "channel_type": -1, + }) + if err == nil { + utils.Map2StructByJson(result["rp_promotion_url_generate_response"], &rpPromURLGenerateResult, false) + } + return rpPromURLGenerateResult, err +} + +type ResourceURLGenResult struct { + SingleURLList struct { + WeAppPagePath string `json:"we_app_page_path"` + MobileURL string `json:"mobile_url"` + MobileShortURL string `json:"mobile_short_url"` + WeAppWebViewURL string `json:"we_app_web_view_url"` + URL string `json:"url"` + ShortURL string `json:"short_url"` + WeAppWebViewShortURL string `json:"we_app_web_view_short_url"` + } `json:"single_url_list"` + Sign string `json:"sign"` + WeAppInfo struct { + WeAppIconURL string `json:"we_app_icon_url"` + UserName string `json:"user_name"` + PagePath string `json:"page_path"` + SourceDisplayName string `json:"source_display_name"` + Title string `json:"title"` + AppID string `json:"app_id"` + Desc string `json:"desc"` + } `json:"we_app_info"` + RequestID string `json:"request_id"` +} + +//生成频道推广链接 +func (a *API) ResourceURLGen(pid string, resourceType int) (resourceURLGenResult *ResourceURLGenResult, err error) { + result, err := a.AccessAPI("pdd.ddk.resource.url.gen", false, map[string]interface{}{ + "pid": pid, + "resource_type": resourceType, + }) + if err == nil { + utils.Map2StructByJson(result["resource_url_response"], &resourceURLGenResult, false) + } + return resourceURLGenResult, err +} diff --git a/platformapi/pddapi/union_test.go b/platformapi/pddapi/union_test.go index 09cfde62..7a1dcc7e 100644 --- a/platformapi/pddapi/union_test.go +++ b/platformapi/pddapi/union_test.go @@ -20,3 +20,19 @@ func TestActivityOperationList(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } + +func TestRpPromURLGenerate(t *testing.T) { + result, err := api.RpPromURLGenerate("14501219_204919171") + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(result, false)) +} + +func TestResourceURLGen(t *testing.T) { + result, err := api.ResourceURLGen("14501219_204919171", resouceTypeBYBT) + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(result, false)) +}