diff --git a/README.md b/README.md index f443fffc..4eddc5c2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ curl --location --request POST 'localhost:8080/base/cloud/spi' \ --data-raw '{ "appId":"7264840234423027259", "authId":"4463798", -"method":"testSpi", +"method":"getFreightTemplateList", "data":"{\"sourceChannelCode\":\"query_none_less\",\"pageSize\":20,\"pageNo\":1}" }' diff --git a/ms-api/src/main/java/com/ms/api/dto/move/GetFreightTemplateListRequestDTO.java b/ms-api/src/main/java/com/ms/api/dto/move/GetFreightTemplateListRequestDTO.java new file mode 100644 index 00000000..cb6bfdd0 --- /dev/null +++ b/ms-api/src/main/java/com/ms/api/dto/move/GetFreightTemplateListRequestDTO.java @@ -0,0 +1,22 @@ +package com.ms.api.dto.move; + +import lombok.Data; + +/* + * 获取店铺模板 请求参数 + */ +@Data +public class GetFreightTemplateListRequestDTO { + /** + * 运费模板名称,支持模糊搜索(例:模版1) + */ + private String name; + /** + * 分页参数 + */ + private String pageNo; + /** + * 分页参数 + */ + private String pageSize; +} diff --git a/ms-biz/src/main/java/com/ms/api/TestSpiService.java b/ms-biz/src/main/java/com/ms/api/TestSpiService.java index 105682b3..5b080065 100644 --- a/ms-biz/src/main/java/com/ms/api/TestSpiService.java +++ b/ms-biz/src/main/java/com/ms/api/TestSpiService.java @@ -11,6 +11,7 @@ import com.ms.api.common.Ret; import com.ms.api.common.SPIBaseService; import com.ms.api.dto.ItemDTO; import com.ms.api.tool.DsJsonRequestTemplate; +import com.ms.api.tool.SecurityTool; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -32,7 +33,7 @@ public class TestSpiService extends SPIBaseService implements ExtensionServiceHa getAuthCode(); String res = null; HashMap params = new HashMap<>(); - params.put("platformItemId", "1"); + params.put("platformItemId", SecurityTool.encodeByAES("1")); params.put("sourceItemId", "33"); params.put("authCode", authCode); try { diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/GetFreightTemplateList.java b/ms-biz/src/main/java/com/ms/api/spi/move/GetFreightTemplateList.java new file mode 100644 index 00000000..129f769e --- /dev/null +++ b/ms-biz/src/main/java/com/ms/api/spi/move/GetFreightTemplateList.java @@ -0,0 +1,51 @@ +package com.ms.api.spi.move; + +import com.doudian.open.api.freightTemplate_list.data.FreightTemplateListData; +import com.doudian.open.api.freightTemplate_list.param.FreightTemplateListParam; +import com.doudian.open.api.product_isv_getClueList.data.ProductIsvGetClueListData; +import com.doudian.open.api.product_isv_getClueList.param.ProductIsvGetClueListParam; +import com.jinritemai.cloud.base.api.BaseRequest; +import com.jinritemai.cloud.base.api.BaseResponse; +import com.jinritemai.cloud.base.api.ExtensionService; +import com.jinritemai.cloud.base.api.ExtensionServiceHandler; +import com.ms.api.common.R; +import com.ms.api.common.Ret; +import com.ms.api.common.SPIBaseService; +import com.ms.api.dto.move.GetFreightTemplateListRequestDTO; +import com.ms.api.dto.move.GetShopCloudHotProductsRequestDTO; +import com.ms.api.tool.DsJsonRequestTemplate; +import com.ms.api.util.DdRequestUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.HashMap; +import java.util.Map; + +/** + * 获取店铺模板列表 + */ +@ExtensionService("getFreightTemplateList") +@Slf4j +public class GetFreightTemplateList extends SPIBaseService implements ExtensionServiceHandler { + @Override + public BaseResponse handle(BaseRequest req) { + initHandle(req); + // ----参数校验---- + GetFreightTemplateListRequestDTO fields = req.getData(); + + // ----逻辑校验---- + + // ----业务处理---- + FreightTemplateListParam param = new FreightTemplateListParam(); + param.setName(fields.getName()); + param.setPage(fields.getPageNo()); + param.setSize(fields.getPageSize()); + FreightTemplateListData data = DdRequestUtil.FreightTemplateListDataRequest(param); + Map result = new HashMap<>(); + result.put("data", data.getList()); + result.put("total", data.getCount()); + + // ----结果返回---- + return R.ok(Ret.success(result)); + } +} diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/GetShopCloudHotProductsService.java b/ms-biz/src/main/java/com/ms/api/spi/move/GetShopCloudHotProductsService.java index 5ecf5227..8eaf0733 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/move/GetShopCloudHotProductsService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/move/GetShopCloudHotProductsService.java @@ -26,10 +26,6 @@ import java.util.Map; @ExtensionService("getShopCloudHotProducts") @Slf4j public class GetShopCloudHotProductsService extends SPIBaseService implements ExtensionServiceHandler { - - @Autowired - private DsJsonRequestTemplate dsJsonRequestTemplate; - @Override public BaseResponse handle(BaseRequest req) { initHandle(req); diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/SaveBatchMoveTaskService.java b/ms-biz/src/main/java/com/ms/api/spi/move/SaveBatchMoveTaskService.java index 70aa9f38..e214cad7 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/move/SaveBatchMoveTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/move/SaveBatchMoveTaskService.java @@ -1,5 +1,6 @@ package com.ms.api.spi.move; +import com.doudian.open.api.freightTemplate_list.FreightTemplateListRequest; import com.jinritemai.cloud.base.api.BaseRequest; import com.jinritemai.cloud.base.api.BaseResponse; import com.jinritemai.cloud.base.api.ExtensionService; diff --git a/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java b/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java index 6636cd9c..459cb101 100644 --- a/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java +++ b/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java @@ -8,6 +8,10 @@ import com.doudian.open.api.afterSale_Detail.AfterSaleDetailRequest; import com.doudian.open.api.afterSale_Detail.AfterSaleDetailResponse; import com.doudian.open.api.afterSale_Detail.data.AfterSaleDetailData; import com.doudian.open.api.afterSale_Detail.param.AfterSaleDetailParam; +import com.doudian.open.api.freightTemplate_list.FreightTemplateListRequest; +import com.doudian.open.api.freightTemplate_list.FreightTemplateListResponse; +import com.doudian.open.api.freightTemplate_list.data.FreightTemplateListData; +import com.doudian.open.api.freightTemplate_list.param.FreightTemplateListParam; import com.doudian.open.api.order_BatchSearchIndex.OrderBatchSearchIndexRequest; import com.doudian.open.api.order_BatchSearchIndex.OrderBatchSearchIndexResponse; import com.doudian.open.api.order_BatchSearchIndex.data.OrderBatchSearchIndexData; @@ -200,4 +204,21 @@ public class DdRequestUtil { } throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg())); } + + public static FreightTemplateListData FreightTemplateListDataRequest(FreightTemplateListParam param) { + String activeProfile= System.getenv("sys-deploy-env"); + if (!"Prod".equals(activeProfile)){ + AuthThreadLocalUtil.set(AppConst.TEST_SHOP_ID); + } + FreightTemplateListRequest request = new FreightTemplateListRequest(); + request.setParam(param); + log.info("=============Dd请求餐素:{}===================", JSONObject.toJSONString(param)); + FreightTemplateListResponse response = request.execute(); + log.info("=============Dd请求返回:{}===================", JSONObject.toJSONString(response)); + boolean success = CommonTool.checkDdApiRequestIsSuccess(response); + if (success && ObjectUtil.isNotEmpty(response.getData())) { + return response.getData(); + } + throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg())); + } }