袁野 2 months ago
parent 4ddc978edf
commit 31a3989517
  1. BIN
      cweb/lib/pop-sdk-1.18.23-all.jar
  2. BIN
      cweb/lib/taobao-sdk.jar
  3. 14
      cweb/pom.xml
  4. 1
      cweb/src/main/java/com/hfkj/config/AuthConfig.java
  5. 46
      cweb/src/main/java/com/hfkj/controller/TestController.java
  6. 44
      cweb/src/main/resources/dev/logback.xml
  7. BIN
      service/lib/pop-sdk-1.18.23-all.jar
  8. BIN
      service/lib/taobao-sdk.jar
  9. 14
      service/pom.xml
  10. 9
      service/src/main/java/com/hfkj/config/CommonSysConfig.java
  11. 79
      service/src/main/java/com/hfkj/service/pdd/PddService.java
  12. 55
      service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java
  13. 4
      service/src/main/resources/dev/commonConfig.properties

Binary file not shown.

Binary file not shown.

@ -18,6 +18,20 @@
<artifactId>service</artifactId>
<version>PACKT-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>taobao.skd</groupId>
<artifactId>taobao-open-sdk</artifactId>
<scope>system</scope>
<version>1.0.1</version>
<systemPath>${basedir}/lib/taobao-sdk.jar</systemPath>
</dependency>
<dependency>
<groupId>pop.skd</groupId>
<artifactId>pop-open-sdk</artifactId>
<scope>system</scope>
<version>1.0.1</version>
<systemPath>${basedir}/lib/pop-sdk-1.18.23-all.jar</systemPath>
</dependency>
</dependencies>
<build>

@ -93,6 +93,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/common/*")
.excludePathPatterns("/sms/*")
.excludePathPatterns("/client/*")
.excludePathPatterns("/test/*")
;
}

@ -0,0 +1,46 @@
package com.hfkj.controller;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData;
import com.hfkj.service.pdd.PddService;
import com.hfkj.service.taobao.TaoBaoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping(value="/test")
@Api(value="测试")
public class TestController {
private static Logger log = LoggerFactory.getLogger(TestController.class);
@RequestMapping(value="/syncInvoke",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "生成商城-频道推广链接")
public ResponseData syncInvoke() {
try {
return ResponseMsgUtil.success(TaoBaoService.execute());
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -69,4 +69,48 @@
<logger name="com.hfkj" level="ERROR">
<appender-ref ref="errorlog" />
</logger>
<!--淘宝接口 -->
<appender name="TaoBaoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/TaoBaoLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/TaoBaoLog/TaoBaoLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.hfkj.service.taobao.TaoBaoService" level="INFO">
<appender-ref ref="TaoBaoLog" />
</logger>
<!-- 淘宝接口 -->
<!--拼多多接口 -->
<appender name="PddLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/PddLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/PddLog/PddLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.hfkj.service.pdd.PddService" level="INFO">
<appender-ref ref="PddLog" />
</logger>
<!-- 拼多多接口 -->
</configuration>

Binary file not shown.

@ -268,6 +268,20 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>taobao.skd</groupId>
<artifactId>taobao-open-sdk</artifactId>
<scope>system</scope>
<version>1.0.1</version>
<systemPath>${basedir}/lib/taobao-sdk.jar</systemPath>
</dependency>
<dependency>
<groupId>pop.skd</groupId>
<artifactId>pop-open-sdk</artifactId>
<scope>system</scope>
<version>1.0.1</version>
<systemPath>${basedir}/lib/pop-sdk-1.18.23-all.jar</systemPath>
</dependency>
</dependencies>
<build>
<resources>

@ -1,5 +1,6 @@
package com.hfkj.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@ -7,6 +8,14 @@ import org.springframework.stereotype.Component;
@Component("commonSysConfig")
@ConfigurationProperties
@PropertySource("classpath:/commonConfig.properties")
@Data
public class CommonSysConfig {
/**
* 淘宝请求参数
*/
private String taoBaoPostUrl;
private String taoBaoAppKey;
private String taoBaoAppSecret;
}

@ -0,0 +1,79 @@
package com.hfkj.service.pdd;
import com.alibaba.fastjson.JSONObject;
import com.pdd.pop.sdk.common.util.JsonUtil;
import com.pdd.pop.sdk.http.PopClient;
import com.pdd.pop.sdk.http.PopHttpClient;
import com.pdd.pop.sdk.http.api.pop.request.PddDdkGoodsSearchRequest;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkGoodsSearchResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PddService {
private static Logger log = LoggerFactory.getLogger(PddService.class);
public static String syncInvoke() throws Exception {
log.info("============ 淘宝请求-START =============");
String clientId = "71a050c5d93d4169a237539af44c7c33";
String clientSecret = "b96def667dd28660d09f19ba2e9e9f23d810d563";
PopClient client = new PopHttpClient(clientId, clientSecret);
PddDdkGoodsSearchRequest request = new PddDdkGoodsSearchRequest();
List<Integer> activityTags = new ArrayList<Integer>();
activityTags.add(0);
request.setActivityTags(activityTags);
List<Integer> blockCatPackages = new ArrayList<Integer>();
blockCatPackages.add(0);
request.setBlockCatPackages(blockCatPackages);
List<Integer> blockCats = new ArrayList<Integer>();
blockCats.add(0);
request.setBlockCats(blockCats);
request.setCatId(49L);
request.setCustomParameters("str");
request.setGoodsImgType(1);
List<String> goodsSignList = new ArrayList<String>();
goodsSignList.add("str");
request.setGoodsSignList(goodsSignList);
request.setIsBrandGoods(true);
request.setKeyword("str");
request.setListId("str");
request.setMerchantType(1);
List<Integer> merchantTypeList = new ArrayList<Integer>();
merchantTypeList.add(0);
request.setMerchantTypeList(merchantTypeList);
request.setOptId(49L);
request.setPage(1);
request.setPageSize(100);
request.setPid("str");
List<PddDdkGoodsSearchRequest.RangeListItem> rangeList = new ArrayList<>();
PddDdkGoodsSearchRequest.RangeListItem item = new PddDdkGoodsSearchRequest.RangeListItem();
item.setRangeFrom(0L);
item.setRangeId(0);
item.setRangeTo(0L);
rangeList.add(item);
request.setRangeList(rangeList);
request.setSortType(0);
request.setUseCustomized(true);
request.setWithCoupon(true);
Map<String, String> riskParams = new HashMap<>();
riskParams.put("", "str");
request.setRiskParams(riskParams);
PddDdkGoodsSearchResponse response = client.syncInvoke(request);
log.info("请求接口:" + "syncInvoke");
log.info("请求参数:" + JSONObject.toJSONString(request));
log.info("响应参数:" + JsonUtil.transferToJson(response));
log.info("============ 淘宝请求-END ==============");
return JsonUtil.transferToJson(response);
}
}

@ -0,0 +1,55 @@
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.defaultability.Defaultability;
import com.taobao.top.defaultability.domain.TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery;
import com.taobao.top.defaultability.request.TaobaoTbkDgMaterialRecommendRequest;
import com.taobao.top.defaultability.request.TaobaoTbkOptimusTouMaterialIdsGetRequest;
import com.taobao.top.defaultability.response.TaobaoTbkOptimusTouMaterialIdsGetResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TaoBaoService {
private static Logger log = LoggerFactory.getLogger(TaoBaoService.class);
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);
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);
TaobaoTbkOptimusTouMaterialIdsGetResponse response = apiPackage.taobaoTbkOptimusTouMaterialIdsGet(request);
if(!response.isSuccess()){
System.out.println(response.getSubMsg());
}
System.out.println(JSON.toJSONString(response));
log.info("============ 淘宝请求-END ==============");
return JSONObject.parseObject(JSON.toJSONString(response));
}
}

@ -0,0 +1,4 @@
taoBaoPostUrl = https://eco.taobao.com/router/rest
taoBaoAppKey = 34807616
taoBaoAppSecret = f04baedca9cd794665dfa04a2fcbfd86
Loading…
Cancel
Save