新增1688店铺解绑spi

master
ljl 10 months ago
parent 2a7efea444
commit 01ed6e46ff

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

@ -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<QuerySupplyPlatformBindNameParam> {
@Override
public Class<? extends DoudianOpSpiResponse<?>> getResponseClass() {
return QuerySupplyPlatformAuthResponse.class;
}
}

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

@ -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<UnbindParam> {
@Override
public Class<? extends DoudianOpSpiResponse<?>> getResponseClass() {
return UnbindResponse.class;
}
}

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

@ -0,0 +1,6 @@
package com.ms.biz.dto.openspi.response;
import com.doudian.open.core.DoudianOpSpiResponse;
public class QuerySupplyPlatformBindNameResponse extends DoudianOpSpiResponse<QuerySupplyPlatformBindNameData> {
}

@ -0,0 +1,7 @@
package com.ms.biz.dto.openspi.response;
import lombok.Data;
@Data
public class UnbindData {
}

@ -0,0 +1,7 @@
package com.ms.biz.dto.openspi.response;
import com.doudian.open.core.DoudianOpSpiResponse;
public class UnbindResponse extends DoudianOpSpiResponse<UnbindData> {
}

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

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

@ -166,6 +166,15 @@ public class DsApiServiceImpl implements DsApiService {
return JSON.parseObject(resp, GetAuthShopMemberInfosResponseDTO.class);
}
@Override
public CommonResponseDTO delAuthShop(Long shopId) {
HashMap<String, Object> 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<String, Object> objectToMap(Object obj) {
Map<String, Object> map = new HashMap<>();
Class<?> clazz = obj.getClass();

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

@ -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<QuerySupplyPlatformBindNameParam, JSONObject> {
private ShopService shopService;
@Override
public BaseResponse<JSONObject> handle(BaseRequest<QuerySupplyPlatformBindNameParam> req) {
try {
QuerySupplyPlatformBindNameParam param = req.getData();
QuerySupplyPlatformBindNameData data = new QuerySupplyPlatformBindNameData();
shopService.querySupplyPlatformBindName(param, data);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) {
log.error("querySupplyPlatformBindName error", e);
return BaseResponse.<JSONObject>builder().success(true).message("系统异常").code("100003").build();
}
}
}

@ -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<UnbindParam, JSONObject> {
private ShopService shopService;
@Override
public BaseResponse<JSONObject> handle(BaseRequest<UnbindParam> req) {
try {
UnbindParam param = req.getData();
UnbindData data = new UnbindData();
shopService.unbind(param);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) {
log.error("querySupplyPlatformBindName error", e);
return BaseResponse.<JSONObject>builder().success(true).message("系统异常").code("100003").build();
}
}
}

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

Loading…
Cancel
Save