diff --git a/cweb/src/main/java/com/hfkj/controller/TestController.java b/cweb/src/main/java/com/hfkj/controller/TestController.java index c8dbc08..3510b69 100644 --- a/cweb/src/main/java/com/hfkj/controller/TestController.java +++ b/cweb/src/main/java/com/hfkj/controller/TestController.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); diff --git a/cweb/src/main/java/com/hfkj/controller/goodsController.java b/cweb/src/main/java/com/hfkj/controller/goodsController.java new file mode 100644 index 0000000..adf6ec7 --- /dev/null +++ b/cweb/src/main/java/com/hfkj/controller/goodsController.java @@ -0,0 +1,4 @@ +package com.hfkj.controller; + +public class goodsController { +} diff --git a/service/src/main/java/com/hfkj/model/CouponModel.java b/service/src/main/java/com/hfkj/model/CouponModel.java new file mode 100644 index 0000000..9c6b648 --- /dev/null +++ b/service/src/main/java/com/hfkj/model/CouponModel.java @@ -0,0 +1,4 @@ +package com.hfkj.model; + +public class CouponModel { +} diff --git a/service/src/main/java/com/hfkj/model/GoodsModel.java b/service/src/main/java/com/hfkj/model/GoodsModel.java new file mode 100644 index 0000000..904dcae --- /dev/null +++ b/service/src/main/java/com/hfkj/model/GoodsModel.java @@ -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 bannerImg; + + /** + * 门店名称 + */ + String merName; + + /** + * 卡券 + */ + List coupons; + + /** + * 价格集合 + */ + GoodsPriceModel goodsPrice; + + +} diff --git a/service/src/main/java/com/hfkj/model/GoodsPriceModel.java b/service/src/main/java/com/hfkj/model/GoodsPriceModel.java new file mode 100644 index 0000000..fc6bfd4 --- /dev/null +++ b/service/src/main/java/com/hfkj/model/GoodsPriceModel.java @@ -0,0 +1,4 @@ +package com.hfkj.model; + +public class GoodsPriceModel { +} diff --git a/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java b/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java index 03daa71..089e356 100644 --- a/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java +++ b/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java @@ -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)); + } }