袁野 2 months ago
parent 9ade211a7c
commit c1398ca568
  1. 39
      cweb/src/main/java/com/hfkj/controller/TestController.java
  2. 4
      cweb/src/main/java/com/hfkj/controller/goodsController.java
  3. 4
      service/src/main/java/com/hfkj/model/CouponModel.java
  4. 65
      service/src/main/java/com/hfkj/model/GoodsModel.java
  5. 4
      service/src/main/java/com/hfkj/model/GoodsPriceModel.java
  6. 93
      service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java

@ -17,6 +17,7 @@ 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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@ -27,13 +28,43 @@ public class TestController {
private static Logger log = LoggerFactory.getLogger(TestController.class);
@RequestMapping(value="/syncInvoke",method = RequestMethod.GET)
@RequestMapping(value="/material",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "生成商城-频道推广链接")
public ResponseData syncInvoke() {
@ApiOperation(value = "淘宝客-推广者-物料id列表查询 ")
public ResponseData material(@RequestParam(value = "title" , required = false) String title,
@RequestParam(value = "pageNo" , required = false) Long pageNo,
@RequestParam(value = "pageSize" , required = false) Long pageSize
) {
try {
return ResponseMsgUtil.success(TaoBaoService.execute());
JSONObject jsonObject = TaoBaoService.material(title , pageNo , pageSize);
if (jsonObject.getBoolean("success")) {
return ResponseMsgUtil.success(jsonObject.getJSONArray("result_list"));
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
}
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/createCommand",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "淘口令生成 ")
public ResponseData createCommand(@RequestParam(value = "url" , required = false) String url
) {
try {
JSONObject jsonObject = TaoBaoService.createCommand("https:" + url);
if (jsonObject.getBoolean("success")) {
return ResponseMsgUtil.success(jsonObject.getJSONObject("data"));
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
}
} catch (Exception e) {
log.error("error!",e);

@ -0,0 +1,4 @@
package com.hfkj.controller;
public class goodsController {
}

@ -0,0 +1,4 @@
package com.hfkj.model;
public class CouponModel {
}

@ -0,0 +1,65 @@
package com.hfkj.model;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class GoodsModel {
/**
* 标题
*/
String title;
/**
* 售卖价格
*/
BigDecimal salePrice;
/**
* 原价
*/
BigDecimal originalPrice;
/**
* 优惠券价格
*/
BigDecimal couponPrice;
/**
* 元宝数量
*/
BigDecimal ingot;
/**
* 售卖数量
*/
String saleNum;
/**
* 分类名称
*/
String categoryName;
/**
* 列表图片
*/
String listImg;
/**
* 轮播图列表
*/
List<String> bannerImg;
/**
* 门店名称
*/
String merName;
/**
* 卡券
*/
List<CouponModel> coupons;
/**
* 价格集合
*/
GoodsPriceModel goodsPrice;
}

@ -0,0 +1,4 @@
package com.hfkj.model;
public class GoodsPriceModel {
}

@ -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));
}
}

Loading…
Cancel
Save