From 50272e4e062e7658bd2c531629c083e6dc2aa0dc Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Fri, 13 Sep 2024 18:14:28 +0800 Subject: [PATCH] 1 --- .../main/java/com/hfkj/config/AuthConfig.java | 1 + .../com/hfkj/controller/GoodsController.java | 115 ++++++++++++++ .../com/hfkj/controller/TestController.java | 1 + .../com/hfkj/controller/goodsController.java | 145 ------------------ ...ListModel.java => MorePromotionModel.java} | 2 +- .../hfkj/model/PricePromotionInfoModel.java | 3 +- .../hfkj/service/goods/GoodsDataService.java | 25 +++ .../goods/impl/GoodsDataServiceImpl.java | 121 +++++++++++++++ .../java/com/hfkj/service/pdd/PddService.java | 120 +++++++++------ .../service/sec/SecDictionaryService.java | 10 ++ .../sec/impl/SecDictionaryServiceImpl.java | 14 ++ .../hfkj/service/taobao/TaoBaoService.java | 15 +- 12 files changed, 376 insertions(+), 196 deletions(-) create mode 100644 cweb/src/main/java/com/hfkj/controller/GoodsController.java delete mode 100644 cweb/src/main/java/com/hfkj/controller/goodsController.java rename service/src/main/java/com/hfkj/model/{MorePromotionListModel.java => MorePromotionModel.java} (93%) create mode 100644 service/src/main/java/com/hfkj/service/goods/GoodsDataService.java create mode 100644 service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java diff --git a/cweb/src/main/java/com/hfkj/config/AuthConfig.java b/cweb/src/main/java/com/hfkj/config/AuthConfig.java index 8b06666..5ae37b1 100644 --- a/cweb/src/main/java/com/hfkj/config/AuthConfig.java +++ b/cweb/src/main/java/com/hfkj/config/AuthConfig.java @@ -94,6 +94,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/sms/*") .excludePathPatterns("/client/*") .excludePathPatterns("/test/*") + .excludePathPatterns("/goods/*") ; } 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..6244512 --- /dev/null +++ b/cweb/src/main/java/com/hfkj/controller/GoodsController.java @@ -0,0 +1,115 @@ +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.*; +import com.hfkj.service.goods.GoodsDataService; +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.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Controller +@RequestMapping(value="/goods") +@Api(value="商品") +public class GoodsController { + + private static Logger log = LoggerFactory.getLogger(GoodsController.class); + + @Resource + private GoodsDataService goodsDataService; + + @RequestMapping(value="/goodsList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品列表") + public ResponseData goodsList(@RequestParam(value = "title" , required = false) String title, + @RequestParam(value = "type" , required = true) Integer type, + @RequestParam(value = "pageNo" , required = true) Long pageNo, + @RequestParam(value = "pageSize" , required = true) Long pageSize + ) { + try { + + List goodsList = new ArrayList<>(); + + // 1:淘宝 2:拼多多 + if (type == 1) { + JSONObject jsonObject = TaoBaoService.material(title , pageNo , pageSize); + + if (!jsonObject.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); + } + + goodsList = goodsDataService.goodsModelTaoBaoList(jsonObject); + } else if (type == 2) { + if (pageSize < 10) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "pageSize的取值范围是10-100!"); + } + JSONObject jsonObject = PddService.syncInvoke(title , pageNo , pageSize); + return ResponseMsgUtil.success(jsonObject); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "未知类型!"); + } + return ResponseMsgUtil.success(goodsList); + + + } 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); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/promotion",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "多多进宝推广链接生成") + public ResponseData promotion(@RequestParam(value = "searchId" , required = false) String searchId, + @RequestParam(value = "goodsSign" , required = false) String goodsSign + ) { + try { + + JSONObject object = PddService.authority(); + boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0; + + JSONObject jsonObject = PddService.promotion(searchId , goodsSign , generateAuthorityUrl); + return ResponseMsgUtil.success(jsonObject); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/cweb/src/main/java/com/hfkj/controller/TestController.java b/cweb/src/main/java/com/hfkj/controller/TestController.java index 3510b69..4538037 100644 --- a/cweb/src/main/java/com/hfkj/controller/TestController.java +++ b/cweb/src/main/java/com/hfkj/controller/TestController.java @@ -74,4 +74,5 @@ public class TestController { + } diff --git a/cweb/src/main/java/com/hfkj/controller/goodsController.java b/cweb/src/main/java/com/hfkj/controller/goodsController.java deleted file mode 100644 index d314b06..0000000 --- a/cweb/src/main/java/com/hfkj/controller/goodsController.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.hfkj.controller; - -import com.alibaba.fastjson.JSONArray; -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.*; -import com.hfkj.service.taobao.TaoBaoService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.License; -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.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -@Controller -@RequestMapping(value="/goods") -@Api(value="商品") -public class goodsController { - - private static Logger log = LoggerFactory.getLogger(goodsController.class); - - @RequestMapping(value="/goodsList",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "查询商品列表") - public ResponseData goodsList(@RequestParam(value = "title" , required = false) String title, - @RequestParam(value = "type" , required = true) Integer type, - @RequestParam(value = "pageNo" , required = false) Long pageNo, - @RequestParam(value = "pageSize" , required = false) Long pageSize - ) { - try { - - // 定义数据列表 - List goodsModelList = new ArrayList<>(); - GoodsModel goodsModel; - // 淘客推广信息 - PublishInfoModel publishInfoModel; - // 价格促销信息 - PricePromotionInfoModel pricePromotionInfoModel; - // 基础信息 - GoodsInfoModel goodsInfoModel; - // 商品佣金信息 - IncomeInfoModel incomeInfoModel; - // 更多活动优惠 - MorePromotionListModel morePromotionListModel; - - // 1:淘宝 2:拼多多 -// if (type == 1) { -// 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, "请求失败!"); -// } -// -// JSONArray data = jsonObject.getJSONArray("result_list"); -// -// for (Object o : data) { -// goodsModel = new GoodsModel(); -// JSONObject object = (JSONObject) o; -// JSONObject publish_info = object.getJSONObject("publish_info"); -// JSONObject price_promotion_info = object.getJSONObject("price_promotion_info"); -// JSONObject item_basic_info = object.getJSONObject("item_basic_info"); -// JSONObject income_info = publish_info.getJSONObject("income_info"); -// JSONObject more_promotion_list = price_promotion_info.getJSONObject("more_promotion_list"); -// JSONObject final_promotion_path_list = price_promotion_info.getJSONObject("final_promotion_path_list"); -// -// // 淘客推广信息 -// // 商品佣金信息 -// incomeInfoModel = new IncomeInfoModel(); -// publishInfoModel = new PublishInfoModel(); -// publishInfoModel.setClickUrl(publish_info.getString("click_url")); -// publishInfoModel.setCouponShareUrl(publish_info.getString("coupon_share_url")); -// incomeInfoModel.setCommissionAmount(income_info.getBigDecimal("commission_amount")); -// incomeInfoModel.setCommissionRate(income_info.getString("commission_rate")); -// // 插入商品佣金信息 -// publishInfoModel.setIncomeInfo(incomeInfoModel); -// // 插入淘客推广信息 -// goodsModel.setPublishInfo(publishInfoModel); -// // 商品基础信息 -// goodsInfoModel = new GoodsInfoModel(); -// goodsInfoModel.setIngot(incomeInfoModel.getCommissionAmount().multiply(new BigDecimal(100))); -// goodsInfoModel.setProvCity(item_basic_info.getString("prov_city")); -// goodsInfoModel.setTitle(item_basic_info.getString("title")); -// goodsInfoModel.setPictUrl(item_basic_info.getString("pict_url")); -// goodsInfoModel.setShortTitle(item_basic_info.getString("short_title")); -// String small_images = item_basic_info.getJSONArray("small_images").toString(); -// goodsInfoModel.setSmallImages(JSONObject.parseArray(small_images,String.class)); -// goodsInfoModel.setShopTitle(item_basic_info.getString("shop_title")); -// // 插入商品基础信息 -// goodsModel.setGoodsInfo(goodsInfoModel); -// // 价格促销信息 -// pricePromotionInfoModel = new PricePromotionInfoModel(); -// pricePromotionInfoModel.setReservePrice(price_promotion_info.getBigDecimal("reserve_price")); -// pricePromotionInfoModel.setZkFinalPrice(price_promotion_info.getBigDecimal("zk_final_price")); -// pricePromotionInfoModel.setFinalPromotionPrice(price_promotion_info.getBigDecimal("final_promotion_price")); -// // 更多活动优惠 -// morePromotionListModel = new MorePromotionListModel(); -// morePromotionListModel.setPromotionDesc(more_promotion_list.getString("promotion_desc")); -// morePromotionListModel.setPromotionFee(final_promotion_path_list.getBigDecimal("promotion_fee")); -// } -// -// -// } - return ResponseMsgUtil.success("121"); - - - } 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); - return ResponseMsgUtil.exception(e); - } - } -} diff --git a/service/src/main/java/com/hfkj/model/MorePromotionListModel.java b/service/src/main/java/com/hfkj/model/MorePromotionModel.java similarity index 93% rename from service/src/main/java/com/hfkj/model/MorePromotionListModel.java rename to service/src/main/java/com/hfkj/model/MorePromotionModel.java index b976cf3..21881f0 100644 --- a/service/src/main/java/com/hfkj/model/MorePromotionListModel.java +++ b/service/src/main/java/com/hfkj/model/MorePromotionModel.java @@ -8,7 +8,7 @@ import java.math.BigDecimal; * 更多活动优惠 */ @Data -public class MorePromotionListModel { +public class MorePromotionModel { /** * 优惠名称 */ diff --git a/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java b/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java index 3cc177e..28537a4 100644 --- a/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java +++ b/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java @@ -3,6 +3,7 @@ package com.hfkj.model; import lombok.Data; import java.math.BigDecimal; +import java.util.List; /** * 价格促销信息 @@ -24,6 +25,6 @@ public class PricePromotionInfoModel { /** * 更多活动优惠 */ - MorePromotionListModel morePromotionList; + List morePromotionList; } diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsDataService.java b/service/src/main/java/com/hfkj/service/goods/GoodsDataService.java new file mode 100644 index 0000000..9ad12f2 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/goods/GoodsDataService.java @@ -0,0 +1,25 @@ +package com.hfkj.service.goods; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.model.GoodsModel; + +import java.util.List; + +/** + * @ClassName GoodsDataService + * @Author Sum1Dream + * @Description 商户数据组装 + * @Date 2024/9/13 下午2:40 + **/ +public interface GoodsDataService { + + /** + * @MethodName goodsModelTaoBaoList + * @Description: 淘宝数据整理 + * @param jsonObject + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/13 下午2:41 + */ + List goodsModelTaoBaoList(JSONObject jsonObject); +} diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java new file mode 100644 index 0000000..15c0aa9 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java @@ -0,0 +1,121 @@ +package com.hfkj.service.goods.impl; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hfkj.entity.SecDictionary; +import com.hfkj.model.*; +import com.hfkj.service.goods.GoodsDataService; +import com.hfkj.service.sec.SecDictionaryService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +@Service("goodsDataService") +public class GoodsDataServiceImpl implements GoodsDataService { + + @Resource + private SecDictionaryService secDictionaryService; + + @Override + public List goodsModelTaoBaoList(JSONObject jsonObject) { + + // 定义数据列表 + List goodsModelList = new ArrayList<>(); + GoodsModel goodsModel; + // 淘客推广信息 + PublishInfoModel publishInfoModel; + // 价格促销信息 + PricePromotionInfoModel pricePromotionInfoModel; + // 基础信息 + GoodsInfoModel goodsInfoModel; + // 商品佣金信息 + IncomeInfoModel incomeInfoModel; + // 更多活动优惠 + MorePromotionModel morePromotionModel; + List morePromotionModels; + // 获取元宝的汇率 + SecDictionary dictionary = secDictionaryService.findDictionary("GRADE_EXCHANGE_RATE"); + + JSONArray data = jsonObject.getJSONArray("result_list"); + + for (Object o : data) { + goodsModel = new GoodsModel(); + JSONObject object = (JSONObject) o; + JSONObject publish_info = object.getJSONObject("publish_info"); + JSONObject price_promotion_info = object.getJSONObject("price_promotion_info"); + JSONObject item_basic_info = object.getJSONObject("item_basic_info"); + JSONObject income_info = publish_info.getJSONObject("income_info"); + JSONArray more_promotion_list = price_promotion_info.getJSONArray("more_promotion_list"); + JSONArray final_promotion_path_list = price_promotion_info.getJSONArray("final_promotion_path_list"); + + // 淘客推广信息 + // 商品佣金信息 + incomeInfoModel = new IncomeInfoModel(); + publishInfoModel = new PublishInfoModel(); + publishInfoModel.setClickUrl(publish_info.getString("click_url")); + if (publish_info.getString("coupon_share_url") != null) { + publishInfoModel.setCouponShareUrl("https:" + publish_info.getString("coupon_share_url")); + } + incomeInfoModel.setCommissionAmount(income_info.getBigDecimal("commission_amount")); + incomeInfoModel.setCommissionRate(income_info.getString("commission_rate")); + // 插入商品佣金信息 + publishInfoModel.setIncomeInfo(incomeInfoModel); + // 插入淘客推广信息 + goodsModel.setPublishInfo(publishInfoModel); + // 商品基础信息 + goodsInfoModel = new GoodsInfoModel(); + goodsInfoModel.setIngot(incomeInfoModel.getCommissionAmount().multiply(new BigDecimal(dictionary.getCodeValue()))); + goodsInfoModel.setProvCity(item_basic_info.getString("prov_city")); + goodsInfoModel.setTitle(item_basic_info.getString("title")); + goodsInfoModel.setPictUrl(item_basic_info.getString("pict_url")); + goodsInfoModel.setShortTitle(item_basic_info.getString("short_title")); + String small_images = item_basic_info.getJSONArray("small_images").toString(); + goodsInfoModel.setSmallImages(JSONObject.parseArray(small_images,String.class)); + goodsInfoModel.setShopTitle(item_basic_info.getString("shop_title")); + // 插入商品基础信息 + goodsModel.setGoodsInfo(goodsInfoModel); + // 价格促销信息 + pricePromotionInfoModel = new PricePromotionInfoModel(); + pricePromotionInfoModel.setReservePrice(price_promotion_info.getBigDecimal("reserve_price")); + pricePromotionInfoModel.setZkFinalPrice(price_promotion_info.getBigDecimal("zk_final_price")); + pricePromotionInfoModel.setFinalPromotionPrice(price_promotion_info.getBigDecimal("final_promotion_price")); + // 更多活动优惠 + morePromotionModels = new ArrayList<>(); + if (more_promotion_list != null && !more_promotion_list.isEmpty()) { + for (Object more_promotion : more_promotion_list) { + JSONObject morePromotion = (JSONObject) more_promotion; + morePromotionModel = new MorePromotionModel(); + morePromotionModel.setPromotionDesc(morePromotion.getString("promotion_desc")); + morePromotionModel.setPromotionTitle(morePromotion.getString("promotion_title")); + morePromotionModel.setPromotionStartTime(morePromotion.getString("promotion_start_time")); + morePromotionModel.setPromotionEndTime(morePromotion.getString("promotion_end_time")); + morePromotionModel.setPromotionId(morePromotion.getString("promotion_id")); + morePromotionModels.add(morePromotionModel); + } + } + if (final_promotion_path_list != null && !final_promotion_path_list.isEmpty()) { + for (Object final_promotion : final_promotion_path_list) { + JSONObject morePromotion = (JSONObject) final_promotion; + morePromotionModel = new MorePromotionModel(); + morePromotionModel.setPromotionDesc(morePromotion.getString("promotion_desc")); + morePromotionModel.setPromotionTitle(morePromotion.getString("promotion_title")); + morePromotionModel.setPromotionFee(morePromotion.getBigDecimal("promotion_fee")); + morePromotionModel.setPromotionStartTime(morePromotion.getString("promotion_start_time")); + morePromotionModel.setPromotionEndTime(morePromotion.getString("promotion_end_time")); + morePromotionModel.setPromotionId(morePromotion.getString("promotion_id")); + morePromotionModels.add(morePromotionModel); + + } + } + // 插入更多活动优惠 + pricePromotionInfoModel.setMorePromotionList(morePromotionModels); + goodsModel.setPricePromotionInfo(pricePromotionInfoModel); + goodsModelList.add(goodsModel); + } + + return goodsModelList; + } +} diff --git a/service/src/main/java/com/hfkj/service/pdd/PddService.java b/service/src/main/java/com/hfkj/service/pdd/PddService.java index 62245fe..4a67a5a 100644 --- a/service/src/main/java/com/hfkj/service/pdd/PddService.java +++ b/service/src/main/java/com/hfkj/service/pdd/PddService.java @@ -1,79 +1,111 @@ package com.hfkj.service.pdd; +import com.alibaba.fastjson.JSON; 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.PddDdkGoodsPromotionUrlGenerateRequest; import com.pdd.pop.sdk.http.api.pop.request.PddDdkGoodsSearchRequest; +import com.pdd.pop.sdk.http.api.pop.request.PddDdkMemberAuthorityQueryRequest; +import com.pdd.pop.sdk.http.api.pop.response.PddDdkGoodsPromotionUrlGenerateResponse; import com.pdd.pop.sdk.http.api.pop.response.PddDdkGoodsSearchResponse; + +import com.pdd.pop.sdk.http.api.pop.response.PddDdkMemberAuthorityQueryResponse; 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 { + public static JSONObject syncInvoke(String title , Long pageNo , Long pageSize) throws Exception { - log.info("============ 淘宝请求-START ============="); + log.info("============ 拼多多请求-START ============="); String clientId = "71a050c5d93d4169a237539af44c7c33"; String clientSecret = "b96def667dd28660d09f19ba2e9e9f23d810d563"; PopClient client = new PopHttpClient(clientId, clientSecret); PddDdkGoodsSearchRequest request = new PddDdkGoodsSearchRequest(); - List activityTags = new ArrayList(); - activityTags.add(0); - request.setActivityTags(activityTags); - List blockCatPackages = new ArrayList(); - blockCatPackages.add(0); - request.setBlockCatPackages(blockCatPackages); - List blockCats = new ArrayList(); - blockCats.add(0); - request.setBlockCats(blockCats); - request.setCatId(49L); - request.setCustomParameters("str"); - request.setGoodsImgType(1); - List goodsSignList = new ArrayList(); - goodsSignList.add("str"); - request.setGoodsSignList(goodsSignList); - request.setIsBrandGoods(true); - request.setKeyword("str"); - request.setListId("str"); - request.setMerchantType(1); - List merchantTypeList = new ArrayList(); - merchantTypeList.add(0); - request.setMerchantTypeList(merchantTypeList); - request.setOptId(49L); - request.setPage(1); - request.setPageSize(100); - request.setPid("str"); - List 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.setKeyword(title); + + request.setPage(pageNo.intValue()); + request.setPageSize(pageSize.intValue()); request.setSortType(0); request.setUseCustomized(true); request.setWithCoupon(true); - Map 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 JSONObject.parseObject(JSON.toJSONString(response)); + } - log.info("响应参数:" + JsonUtil.transferToJson(response)); - log.info("============ 淘宝请求-END =============="); - return JsonUtil.transferToJson(response); + + /** + * @MethodName promotion + * @Description: 多多进宝推广链接生成 + * @param searchId + * @return: com.alibaba.fastjson.JSONObject + * @Author: Sum1Dream + * @Date: 2024/9/13 下午5:08 + */ + public static JSONObject promotion(String searchId , String goodsSign , Boolean generateAuthorityUrl) throws Exception { + + log.info("============ 拼多多请求-START ============="); + String clientId = "71a050c5d93d4169a237539af44c7c33"; + String clientSecret = "b96def667dd28660d09f19ba2e9e9f23d810d563"; + PopClient client = new PopHttpClient(clientId, clientSecret); + + PddDdkGoodsPromotionUrlGenerateRequest request = new PddDdkGoodsPromotionUrlGenerateRequest(); + request.setPId("41483885_294044603"); + request.setSearchId(searchId); + List goodsSignList = new ArrayList<>(); + goodsSignList.add(goodsSign); + request.setGoodsSignList(goodsSignList); + request.setGenerateAuthorityUrl(generateAuthorityUrl); + PddDdkGoodsPromotionUrlGenerateResponse response = client.syncInvoke(request); + + log.info("请求接口:" + "promotion"); + log.info("请求参数:" + JSONObject.toJSONString(request)); + log.info("响应参数:" + JsonUtil.transferToJson(response)); + log.info("============ 拼多多请求-END =============="); + return JSONObject.parseObject(JSON.toJSONString(response)); } + + /** + * @MethodName authority + * @Description: 查询是否绑定备案 + * @return: com.alibaba.fastjson.JSONObject + * @Author: Sum1Dream + * @Date: 2024/9/13 下午5:42 + */ + public static JSONObject authority() throws Exception { + + log.info("============ 拼多多请求-START ============="); + String clientId = "71a050c5d93d4169a237539af44c7c33"; + String clientSecret = "b96def667dd28660d09f19ba2e9e9f23d810d563"; + PopClient client = new PopHttpClient(clientId, clientSecret); + + PddDdkMemberAuthorityQueryRequest request = new PddDdkMemberAuthorityQueryRequest(); + request.setPid("41483885_294044603"); + PddDdkMemberAuthorityQueryResponse response = client.syncInvoke(request); + + log.info("请求接口:" + "authority"); + log.info("请求参数:" + JSONObject.toJSONString(request)); + log.info("响应参数:" + JsonUtil.transferToJson(response)); + log.info("============ 拼多多请求-END =============="); + return JSONObject.parseObject(JSON.toJSONString(response)); + + } + + } diff --git a/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java b/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java index 32f0635..09e1df7 100644 --- a/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java +++ b/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java @@ -32,6 +32,16 @@ public interface SecDictionaryService { */ SecDictionary getDictionary(String codeType, String codeValue); + /** + * @MethodName getDictionary + * @Description: + * @param codeType + * @return: com.hfkj.entity.SecDictionary + * @Author: Sum1Dream + * @Date: 2024/9/13 下午2:08 + */ + SecDictionary findDictionary(String codeType); + /** * 刷新缓存 */ diff --git a/service/src/main/java/com/hfkj/service/sec/impl/SecDictionaryServiceImpl.java b/service/src/main/java/com/hfkj/service/sec/impl/SecDictionaryServiceImpl.java index 169967d..0c8492f 100644 --- a/service/src/main/java/com/hfkj/service/sec/impl/SecDictionaryServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/sec/impl/SecDictionaryServiceImpl.java @@ -44,6 +44,8 @@ public class SecDictionaryServiceImpl implements SecDictionaryService { return getDictionary().stream().filter(o -> o.getCodeType().equals(codeType)).collect(Collectors.toList()); } + + @Override public SecDictionary getDictionary(String codeType, String codeValue) { List list = getDictionary().stream() @@ -56,6 +58,18 @@ public class SecDictionaryServiceImpl implements SecDictionaryService { } } + @Override + public SecDictionary findDictionary(String codeType) { + List list = getDictionary().stream() + .filter(o -> o.getCodeType().equals(codeType)) + .collect(Collectors.toList()); + if (!list.isEmpty()) { + return list.get(0); + } else { + return null; + } + } + @Override public List refreshCache() { // 删除缓存 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 089e356..d64ba94 100644 --- a/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java +++ b/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java @@ -1,7 +1,11 @@ package com.hfkj.service.taobao; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.hfkj.entity.SecDictionary; +import com.hfkj.model.*; +import com.hfkj.service.sec.SecDictionaryService; import com.taobao.top.DefaultTopApiClient; import com.taobao.top.TopApiClient; import com.taobao.top.ability375.Ability375; @@ -10,22 +14,23 @@ 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.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 javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.List; 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"; @@ -55,6 +60,7 @@ public class TaoBaoService { TaobaoTbkDgMaterialOptionalUpgradeRequest request = new TaobaoTbkDgMaterialOptionalUpgradeRequest(); request.setQ(title); request.setPageNo(pageNo); + request.setHasCoupon(true); request.setPageSize(pageSize); request.setAdzoneId(115764450446L); @@ -102,7 +108,6 @@ public class TaoBaoService { log.info("============ 淘口令生成--END =============="); return JSONObject.parseObject(JSON.toJSONString(response)); - - } + }