|
|
|
@ -2,54 +2,107 @@ package com.hfkj.service.taobao; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hfkj.config.CommonSysConst; |
|
|
|
|
import com.taobao.top.DefaultTopApiClient; |
|
|
|
|
import com.taobao.top.TopApiClient; |
|
|
|
|
import com.taobao.top.ability371.Ability371; |
|
|
|
|
import com.taobao.top.ability371.request.TaobaoTbkItemInfoGetRequest; |
|
|
|
|
import com.taobao.top.ability371.response.TaobaoTbkItemInfoGetResponse; |
|
|
|
|
import com.taobao.top.ability375.Ability375; |
|
|
|
|
import com.taobao.top.ability375.request.TaobaoTbkTpwdCreateRequest; |
|
|
|
|
import com.taobao.top.ability375.response.TaobaoTbkTpwdCreateResponse; |
|
|
|
|
import com.taobao.top.defaultability.Defaultability; |
|
|
|
|
import com.taobao.top.defaultability.domain.TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery; |
|
|
|
|
import com.taobao.top.defaultability.request.TaobaoTbkDgMaterialRecommendRequest; |
|
|
|
|
import com.taobao.top.defaultability.request.TaobaoTbkDgMaterialOptionalUpgradeRequest; |
|
|
|
|
import com.taobao.top.defaultability.request.TaobaoTbkOptimusTouMaterialIdsGetRequest; |
|
|
|
|
import com.taobao.top.defaultability.response.TaobaoTbkDgMaterialOptionalUpgradeResponse; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.taobao.top.defaultability.response.TaobaoTbkOptimusTouMaterialIdsGetResponse; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class TaoBaoService { |
|
|
|
|
|
|
|
|
|
private static Logger log = LoggerFactory.getLogger(TaoBaoService.class); |
|
|
|
|
|
|
|
|
|
private static String appKey = "34807616"; |
|
|
|
|
private static String appsecret = "f04baedca9cd794665dfa04a2fcbfd86"; |
|
|
|
|
private static String url = "https://eco.taobao.com/router/rest"; |
|
|
|
|
|
|
|
|
|
public static JSONObject execute() throws Exception { |
|
|
|
|
|
|
|
|
|
log.info("============ 淘宝请求-START ============="); |
|
|
|
|
String appkey = "34807616"; |
|
|
|
|
String appsecret = "f04baedca9cd794665dfa04a2fcbfd86"; |
|
|
|
|
String url = "http://gw.api.taobao.com/router/rest"; |
|
|
|
|
TopApiClient client = new DefaultTopApiClient(appkey,appsecret,url); |
|
|
|
|
/** |
|
|
|
|
* @MethodName material |
|
|
|
|
* @Description:淘宝客-推广者-物料id列表查询 |
|
|
|
|
* @param title |
|
|
|
|
* @param pageNo |
|
|
|
|
* @param pageSize |
|
|
|
|
* @return: com.alibaba.fastjson.JSONObject |
|
|
|
|
* @Author: Sum1Dream |
|
|
|
|
* @Date: 2024/9/10 下午1:52 |
|
|
|
|
*/ |
|
|
|
|
public static JSONObject material(String title , Long pageNo , Long pageSize) throws Exception { |
|
|
|
|
if (StringUtils.isBlank(title)) { |
|
|
|
|
title = "百货"; |
|
|
|
|
} |
|
|
|
|
log.info("============ 淘宝客-推广者-物料id列表查询-START ============="); |
|
|
|
|
TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url); |
|
|
|
|
Defaultability apiPackage = new Defaultability(client); |
|
|
|
|
// create domain
|
|
|
|
|
TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery taobaoTbkOptimusTouMaterialIdsGetMaterialQuery = new TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery(); |
|
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setPageNo(1L); |
|
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setSubject(1L); |
|
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setMaterialType(1L); |
|
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setPageSize(20L); |
|
|
|
|
|
|
|
|
|
// create request
|
|
|
|
|
TaobaoTbkOptimusTouMaterialIdsGetRequest request = new TaobaoTbkOptimusTouMaterialIdsGetRequest(); |
|
|
|
|
request.setMaterialQuery(taobaoTbkOptimusTouMaterialIdsGetMaterialQuery); |
|
|
|
|
TaobaoTbkDgMaterialOptionalUpgradeRequest request = new TaobaoTbkDgMaterialOptionalUpgradeRequest(); |
|
|
|
|
request.setQ(title); |
|
|
|
|
request.setPageNo(pageNo); |
|
|
|
|
request.setPageSize(pageSize); |
|
|
|
|
request.setAdzoneId(115764450446L); |
|
|
|
|
|
|
|
|
|
request.setUcrowdRankItems(new ArrayList<>()); |
|
|
|
|
|
|
|
|
|
TaobaoTbkDgMaterialOptionalUpgradeResponse response = apiPackage.taobaoTbkDgMaterialOptionalUpgrade(request); |
|
|
|
|
|
|
|
|
|
TaobaoTbkOptimusTouMaterialIdsGetResponse response = apiPackage.taobaoTbkOptimusTouMaterialIdsGet(request); |
|
|
|
|
if(!response.isSuccess()){ |
|
|
|
|
System.out.println(response.getSubMsg()); |
|
|
|
|
} |
|
|
|
|
System.out.println(JSON.toJSONString(response)); |
|
|
|
|
|
|
|
|
|
log.info("============ 淘宝请求-END =============="); |
|
|
|
|
log.info("请求接口:" + "taobaoTbkOptimusTouMaterialIdsGet"); |
|
|
|
|
log.info("请求参数:" + JSONObject.toJSONString(request)); |
|
|
|
|
log.info("响应参数:" + response); |
|
|
|
|
log.info("============ 淘宝客-推广者-物料id列表查询--END =============="); |
|
|
|
|
return JSONObject.parseObject(JSON.toJSONString(response)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @MethodName createCommand |
|
|
|
|
* @Description: 淘口令生成 |
|
|
|
|
* @param clickUrl |
|
|
|
|
* @return: com.alibaba.fastjson.JSONObject |
|
|
|
|
* @Author: Sum1Dream |
|
|
|
|
* @Date: 2024/9/10 下午2:00 |
|
|
|
|
*/ |
|
|
|
|
public static JSONObject createCommand(String clickUrl) throws Exception { |
|
|
|
|
|
|
|
|
|
log.info("============ 淘口令生成-START ============="); |
|
|
|
|
|
|
|
|
|
TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url); |
|
|
|
|
Ability375 apiPackage = new Ability375(client); |
|
|
|
|
// create domain
|
|
|
|
|
|
|
|
|
|
// create request
|
|
|
|
|
TaobaoTbkTpwdCreateRequest request = new TaobaoTbkTpwdCreateRequest(); |
|
|
|
|
request.setUrl(clickUrl); |
|
|
|
|
|
|
|
|
|
TaobaoTbkTpwdCreateResponse response = apiPackage.taobaoTbkTpwdCreate(request); |
|
|
|
|
|
|
|
|
|
log.info("请求接口:" + "taobaoTbkTpwdCreate"); |
|
|
|
|
log.info("请求参数:" + JSONObject.toJSONString(request)); |
|
|
|
|
log.info("响应参数:" + response); |
|
|
|
|
log.info("============ 淘口令生成--END =============="); |
|
|
|
|
return JSONObject.parseObject(JSON.toJSONString(response)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|