|
|
@ -2,54 +2,107 @@ package com.hfkj.service.taobao; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.hfkj.config.CommonSysConst; |
|
|
|
|
|
|
|
import com.taobao.top.DefaultTopApiClient; |
|
|
|
import com.taobao.top.DefaultTopApiClient; |
|
|
|
import com.taobao.top.TopApiClient; |
|
|
|
import com.taobao.top.TopApiClient; |
|
|
|
import com.taobao.top.ability371.Ability371; |
|
|
|
import com.taobao.top.ability375.Ability375; |
|
|
|
import com.taobao.top.ability371.request.TaobaoTbkItemInfoGetRequest; |
|
|
|
import com.taobao.top.ability375.request.TaobaoTbkTpwdCreateRequest; |
|
|
|
import com.taobao.top.ability371.response.TaobaoTbkItemInfoGetResponse; |
|
|
|
import com.taobao.top.ability375.response.TaobaoTbkTpwdCreateResponse; |
|
|
|
import com.taobao.top.defaultability.Defaultability; |
|
|
|
import com.taobao.top.defaultability.Defaultability; |
|
|
|
import com.taobao.top.defaultability.domain.TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery; |
|
|
|
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.request.TaobaoTbkOptimusTouMaterialIdsGetRequest; |
|
|
|
|
|
|
|
import com.taobao.top.defaultability.response.TaobaoTbkDgMaterialOptionalUpgradeResponse; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.taobao.top.defaultability.response.TaobaoTbkOptimusTouMaterialIdsGetResponse; |
|
|
|
import com.taobao.top.defaultability.response.TaobaoTbkOptimusTouMaterialIdsGetResponse; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class TaoBaoService { |
|
|
|
public class TaoBaoService { |
|
|
|
|
|
|
|
|
|
|
|
private static Logger log = LoggerFactory.getLogger(TaoBaoService.class); |
|
|
|
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 { |
|
|
|
/** |
|
|
|
|
|
|
|
* @MethodName material |
|
|
|
log.info("============ 淘宝请求-START ============="); |
|
|
|
* @Description:淘宝客-推广者-物料id列表查询 |
|
|
|
String appkey = "34807616"; |
|
|
|
* @param title |
|
|
|
String appsecret = "f04baedca9cd794665dfa04a2fcbfd86"; |
|
|
|
* @param pageNo |
|
|
|
String url = "http://gw.api.taobao.com/router/rest"; |
|
|
|
* @param pageSize |
|
|
|
TopApiClient client = new DefaultTopApiClient(appkey,appsecret,url); |
|
|
|
* @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); |
|
|
|
Defaultability apiPackage = new Defaultability(client); |
|
|
|
// create domain
|
|
|
|
// create domain
|
|
|
|
TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery taobaoTbkOptimusTouMaterialIdsGetMaterialQuery = new TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery(); |
|
|
|
TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery taobaoTbkOptimusTouMaterialIdsGetMaterialQuery = new TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery(); |
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setPageNo(1L); |
|
|
|
|
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setSubject(1L); |
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setSubject(1L); |
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setMaterialType(1L); |
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setMaterialType(1L); |
|
|
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setPageSize(20L); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create request
|
|
|
|
// create request
|
|
|
|
TaobaoTbkOptimusTouMaterialIdsGetRequest request = new TaobaoTbkOptimusTouMaterialIdsGetRequest(); |
|
|
|
TaobaoTbkDgMaterialOptionalUpgradeRequest request = new TaobaoTbkDgMaterialOptionalUpgradeRequest(); |
|
|
|
request.setMaterialQuery(taobaoTbkOptimusTouMaterialIdsGetMaterialQuery); |
|
|
|
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()){ |
|
|
|
if(!response.isSuccess()){ |
|
|
|
System.out.println(response.getSubMsg()); |
|
|
|
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)); |
|
|
|
return JSONObject.parseObject(JSON.toJSONString(response)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|