From 01ed6e46ff31d42b42baa4a6a2718d21768d26bf Mon Sep 17 00:00:00 2001 From: ljl Date: Wed, 31 Jan 2024 15:03:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E1688=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E8=A7=A3=E7=BB=91spi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QuerySupplyPlatformBindNameParam.java | 13 +++++++ .../QuerySupplyPlatformBindNameRequest.java | 12 ++++++ .../biz/dto/openspi/request/UnbindParam.java | 13 +++++++ .../dto/openspi/request/UnbindRequest.java | 13 +++++++ .../QuerySupplyPlatformBindNameData.java | 12 ++++++ .../QuerySupplyPlatformBindNameResponse.java | 6 +++ .../biz/dto/openspi/response/UnbindData.java | 7 ++++ .../dto/openspi/response/UnbindResponse.java | 7 ++++ .../java/com/ms/biz/service/DsApiService.java | 1 + .../java/com/ms/biz/service/ShopService.java | 7 ++++ .../ms/biz/service/impl/DsApiServiceImpl.java | 9 +++++ .../ms/biz/service/impl/ShopServiceImpl.java | 38 +++++++++++++++++++ .../QuerySupplyPlatformBindNameService.java | 36 ++++++++++++++++++ .../ms/biz/spi/callback/UnbindService.java | 38 +++++++++++++++++++ .../main/java/com/ms/web/controller/Test.java | 2 +- 15 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 ms-biz/src/main/java/com/ms/biz/dto/openspi/request/QuerySupplyPlatformBindNameParam.java create mode 100644 ms-biz/src/main/java/com/ms/biz/dto/openspi/request/QuerySupplyPlatformBindNameRequest.java create mode 100644 ms-biz/src/main/java/com/ms/biz/dto/openspi/request/UnbindParam.java create mode 100644 ms-biz/src/main/java/com/ms/biz/dto/openspi/request/UnbindRequest.java create mode 100644 ms-biz/src/main/java/com/ms/biz/dto/openspi/response/QuerySupplyPlatformBindNameData.java create mode 100644 ms-biz/src/main/java/com/ms/biz/dto/openspi/response/QuerySupplyPlatformBindNameResponse.java create mode 100644 ms-biz/src/main/java/com/ms/biz/dto/openspi/response/UnbindData.java create mode 100644 ms-biz/src/main/java/com/ms/biz/dto/openspi/response/UnbindResponse.java create mode 100644 ms-biz/src/main/java/com/ms/biz/spi/callback/QuerySupplyPlatformBindNameService.java create mode 100644 ms-biz/src/main/java/com/ms/biz/spi/callback/UnbindService.java diff --git a/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/QuerySupplyPlatformBindNameParam.java b/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/QuerySupplyPlatformBindNameParam.java new file mode 100644 index 0000000..35ad52e --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/QuerySupplyPlatformBindNameParam.java @@ -0,0 +1,13 @@ +package com.ms.biz.dto.openspi.request; + +import com.doudian.open.gson.annotations.SerializedName; +import lombok.Data; + +@Data +public class QuerySupplyPlatformBindNameParam { + @SerializedName("shop_id") + private Long shopId; + + @SerializedName("supply_platform_type") + private Long supplyPlatformType; +} diff --git a/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/QuerySupplyPlatformBindNameRequest.java b/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/QuerySupplyPlatformBindNameRequest.java new file mode 100644 index 0000000..21e3ab4 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/QuerySupplyPlatformBindNameRequest.java @@ -0,0 +1,12 @@ +package com.ms.biz.dto.openspi.request; + +import com.doudian.open.core.DoudianOpSpiRequest; +import com.doudian.open.core.DoudianOpSpiResponse; +import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthResponse; + +public class QuerySupplyPlatformBindNameRequest extends DoudianOpSpiRequest { + @Override + public Class> getResponseClass() { + return QuerySupplyPlatformAuthResponse.class; + } +} diff --git a/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/UnbindParam.java b/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/UnbindParam.java new file mode 100644 index 0000000..f853c2b --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/UnbindParam.java @@ -0,0 +1,13 @@ +package com.ms.biz.dto.openspi.request; + +import com.doudian.open.gson.annotations.SerializedName; +import lombok.Data; + +@Data +public class UnbindParam { + @SerializedName("shop_id") + private Long shopId; + + @SerializedName("supply_platform_type") + private Long supplyPlatformType; +} diff --git a/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/UnbindRequest.java b/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/UnbindRequest.java new file mode 100644 index 0000000..72d38d4 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/dto/openspi/request/UnbindRequest.java @@ -0,0 +1,13 @@ +package com.ms.biz.dto.openspi.request; + +import com.doudian.open.core.DoudianOpSpiRequest; +import com.doudian.open.core.DoudianOpSpiResponse; +import com.ms.biz.dto.openspi.response.UnbindResponse; + +public class UnbindRequest extends DoudianOpSpiRequest { + @Override + public Class> getResponseClass() { + return UnbindResponse.class; + } +} + diff --git a/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/QuerySupplyPlatformBindNameData.java b/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/QuerySupplyPlatformBindNameData.java new file mode 100644 index 0000000..47b7381 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/QuerySupplyPlatformBindNameData.java @@ -0,0 +1,12 @@ +package com.ms.biz.dto.openspi.response; + +import com.alibaba.fastjson.annotation.JSONField; +import com.doudian.open.gson.annotations.SerializedName; +import lombok.Data; + +@Data +public class QuerySupplyPlatformBindNameData { + @JSONField(name = "bind_name") + @SerializedName("bind_name") + private String bindName; +} diff --git a/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/QuerySupplyPlatformBindNameResponse.java b/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/QuerySupplyPlatformBindNameResponse.java new file mode 100644 index 0000000..52d22b2 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/QuerySupplyPlatformBindNameResponse.java @@ -0,0 +1,6 @@ +package com.ms.biz.dto.openspi.response; + +import com.doudian.open.core.DoudianOpSpiResponse; + +public class QuerySupplyPlatformBindNameResponse extends DoudianOpSpiResponse { +} diff --git a/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/UnbindData.java b/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/UnbindData.java new file mode 100644 index 0000000..94f5ca1 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/UnbindData.java @@ -0,0 +1,7 @@ +package com.ms.biz.dto.openspi.response; + +import lombok.Data; + +@Data +public class UnbindData { +} diff --git a/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/UnbindResponse.java b/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/UnbindResponse.java new file mode 100644 index 0000000..9756d60 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/dto/openspi/response/UnbindResponse.java @@ -0,0 +1,7 @@ +package com.ms.biz.dto.openspi.response; + +import com.doudian.open.core.DoudianOpSpiResponse; + +public class UnbindResponse extends DoudianOpSpiResponse { +} + diff --git a/ms-biz/src/main/java/com/ms/biz/service/DsApiService.java b/ms-biz/src/main/java/com/ms/biz/service/DsApiService.java index 01830ae..a676e50 100644 --- a/ms-biz/src/main/java/com/ms/biz/service/DsApiService.java +++ b/ms-biz/src/main/java/com/ms/biz/service/DsApiService.java @@ -26,4 +26,5 @@ public interface DsApiService { GetAuthInfoResponseDTO getAuthInfo(Long shopId); CheckDsAppAuthExpireResponseDTO checkDsAppAuthExpire(Long shopId, String memberId, String authCode); GetAuthShopMemberInfosResponseDTO getAuthShopMemberInfos(Long shopId); + CommonResponseDTO delAuthShop(Long shopId); } diff --git a/ms-biz/src/main/java/com/ms/biz/service/ShopService.java b/ms-biz/src/main/java/com/ms/biz/service/ShopService.java index 69a8cc3..a88da07 100644 --- a/ms-biz/src/main/java/com/ms/biz/service/ShopService.java +++ b/ms-biz/src/main/java/com/ms/biz/service/ShopService.java @@ -4,7 +4,10 @@ import java.util.List; import com.ms.biz.bo.ShopBO; import com.ms.biz.dto.openspi.request.QuerySupplyPlatformAuthParam; +import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam; +import com.ms.biz.dto.openspi.request.UnbindParam; import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData; +import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData; import com.ms.dal.entity.Shop; /** @@ -35,4 +38,8 @@ public interface ShopService { ShopBO getShopInfoByShop(Shop shop); void querySupplyPlatformAuth(QuerySupplyPlatformAuthParam param, QuerySupplyPlatformAuthData data); + + void querySupplyPlatformBindName(QuerySupplyPlatformBindNameParam param, QuerySupplyPlatformBindNameData data); + + void unbind(UnbindParam param); } diff --git a/ms-biz/src/main/java/com/ms/biz/service/impl/DsApiServiceImpl.java b/ms-biz/src/main/java/com/ms/biz/service/impl/DsApiServiceImpl.java index 3d93d63..28109a8 100644 --- a/ms-biz/src/main/java/com/ms/biz/service/impl/DsApiServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/biz/service/impl/DsApiServiceImpl.java @@ -166,6 +166,15 @@ public class DsApiServiceImpl implements DsApiService { return JSON.parseObject(resp, GetAuthShopMemberInfosResponseDTO.class); } + @Override + public CommonResponseDTO delAuthShop(Long shopId) { + HashMap params = new HashMap<>(); + params.put("shopId", SecurityTool.encodeByAES(String.valueOf(shopId))); + params.put("platform", CommonConst.PLATFORM); + String resp = execute("/micro_move/del_auth_shop", params); + return JSON.parseObject(resp, CommonResponseDTO.class); + } + private Map objectToMap(Object obj) { Map map = new HashMap<>(); Class clazz = obj.getClass(); diff --git a/ms-biz/src/main/java/com/ms/biz/service/impl/ShopServiceImpl.java b/ms-biz/src/main/java/com/ms/biz/service/impl/ShopServiceImpl.java index 31b353f..e712153 100644 --- a/ms-biz/src/main/java/com/ms/biz/service/impl/ShopServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/biz/service/impl/ShopServiceImpl.java @@ -9,9 +9,13 @@ import cn.hutool.core.util.ObjectUtil; import com.doudian.open.core.AccessToken; import com.ms.api.dto.dsapi.response.CheckDsAppAuthExpireResponseDTO; import com.ms.api.dto.dsapi.response.CommonResponseDTO; +import com.ms.api.dto.dsapi.response.GetAuthInfoResponseDTO; import com.ms.api.dto.dsapi.response.GetPlatformAuthUrlResponseDTO; import com.ms.biz.dto.openspi.request.QuerySupplyPlatformAuthParam; +import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam; +import com.ms.biz.dto.openspi.request.UnbindParam; import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData; +import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData; import com.ms.biz.service.DsApiService; import com.ms.biz.service.ShopService; import com.ms.biz.bo.ShopBO; @@ -114,6 +118,7 @@ public class ShopServiceImpl implements ShopService { return shopBO; } + @Override public void querySupplyPlatformAuth(QuerySupplyPlatformAuthParam param, QuerySupplyPlatformAuthData data) { Long shopId = param.getShopId(); if (shopId == null || shopId == 0) { @@ -158,6 +163,39 @@ public class ShopServiceImpl implements ShopService { throw new RuntimeException(response.getReason()); } } + + @Override + public void querySupplyPlatformBindName(QuerySupplyPlatformBindNameParam param, QuerySupplyPlatformBindNameData data) { + Long shopId = param.getShopId(); + if (shopId == null || shopId == 0) { + throw new RuntimeException("店铺ID错误"); + } + GetAuthInfoResponseDTO response = dsApiService.getAuthInfo(shopId); + if (response.isSuccess()) { + data.setBindName(response.getMemberName()); + } else { + throw new RuntimeException(response.getReason()); + } + } + + @Override + public void unbind(UnbindParam param) { + Long shopId = param.getShopId(); + if (shopId == null || shopId == 0) { + throw new RuntimeException("店铺ID错误"); + } + ShopTo1688DsMember member = shopTo1688DsMemberMapper.getDetailByShopId(shopId); + if (member == null) { + throw new RuntimeException("该店铺未绑定"); + } + + CommonResponseDTO response = dsApiService.delAuthShop(shopId); + if (!response.isSuccess()) { + throw new RuntimeException(response.getReason()); + } + + shopTo1688DsMemberMapper.deleteByPrimaryKey(member.getShopTo1688DsMemberId()); + } } diff --git a/ms-biz/src/main/java/com/ms/biz/spi/callback/QuerySupplyPlatformBindNameService.java b/ms-biz/src/main/java/com/ms/biz/spi/callback/QuerySupplyPlatformBindNameService.java new file mode 100644 index 0000000..46b72a1 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/spi/callback/QuerySupplyPlatformBindNameService.java @@ -0,0 +1,36 @@ +package com.ms.biz.spi.callback; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +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.biz.common.SPIBaseService; +import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam; +import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData; +import com.ms.biz.service.ShopService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@ExtensionService("querySupplyPlatformBindName") +@Slf4j +@AllArgsConstructor +public class QuerySupplyPlatformBindNameService extends SPIBaseService implements ExtensionServiceHandler { + private ShopService shopService; + + @Override + public BaseResponse handle(BaseRequest req) { + try { + QuerySupplyPlatformBindNameParam param = req.getData(); + QuerySupplyPlatformBindNameData data = new QuerySupplyPlatformBindNameData(); + shopService.querySupplyPlatformBindName(param, data); + return BaseResponse.builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); + } catch (RuntimeException e) { + return BaseResponse.builder().success(true).message(e.getMessage()).code("100003").build(); + } catch (Throwable e) { + log.error("querySupplyPlatformBindName error", e); + return BaseResponse.builder().success(true).message("系统异常").code("100003").build(); + } + } +} diff --git a/ms-biz/src/main/java/com/ms/biz/spi/callback/UnbindService.java b/ms-biz/src/main/java/com/ms/biz/spi/callback/UnbindService.java new file mode 100644 index 0000000..1ba464b --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/spi/callback/UnbindService.java @@ -0,0 +1,38 @@ +package com.ms.biz.spi.callback; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +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.biz.common.SPIBaseService; +import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam; +import com.ms.biz.dto.openspi.request.UnbindParam; +import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData; +import com.ms.biz.dto.openspi.response.UnbindData; +import com.ms.biz.service.ShopService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@ExtensionService("unbind") +@Slf4j +@AllArgsConstructor +public class UnbindService extends SPIBaseService implements ExtensionServiceHandler { + private ShopService shopService; + + @Override + public BaseResponse handle(BaseRequest req) { + try { + UnbindParam param = req.getData(); + UnbindData data = new UnbindData(); + shopService.unbind(param); + return BaseResponse.builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); + } catch (RuntimeException e) { + return BaseResponse.builder().success(true).message(e.getMessage()).code("100003").build(); + } catch (Throwable e) { + log.error("querySupplyPlatformBindName error", e); + return BaseResponse.builder().success(true).message("系统异常").code("100003").build(); + } + } +} diff --git a/ms-web/src/main/java/com/ms/web/controller/Test.java b/ms-web/src/main/java/com/ms/web/controller/Test.java index 0a7d861..090e2f9 100644 --- a/ms-web/src/main/java/com/ms/web/controller/Test.java +++ b/ms-web/src/main/java/com/ms/web/controller/Test.java @@ -205,7 +205,7 @@ public class Test { @RequestMapping("/getAuthInfo") public String getAuthInfo() { // 30459766L - GetAuthInfoResponseDTO responseDTO = dsApiService.getAuthInfo(1111502210L); + GetAuthInfoResponseDTO responseDTO = dsApiService.getAuthInfo(139183158L); System.out.println(responseDTO); return ""; }