master
ljl 9 months ago
parent 01ed6e46ff
commit 2323b23ebd

@ -0,0 +1,17 @@
package com.ms.biz.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
abstract public class BaseRuntimeException extends RuntimeException {
protected String code;
public BaseRuntimeException() {
super();
}
public BaseRuntimeException(String message) {
super(message);
}
}

@ -0,0 +1,18 @@
package com.ms.biz.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class BindMemberNotExistsException extends BaseRuntimeException {
protected String code = "100501";
public BindMemberNotExistsException() {
super("当前没有绑定的账号信息,请重试");
}
public BindMemberNotExistsException(String message) {
super(message);
}
}

@ -0,0 +1,19 @@
package com.ms.biz.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class BusinessException extends BaseRuntimeException {
protected String code = "100004";
public BusinessException(String message, String code) {
super(message);
this.code = code;
}
public BusinessException(String message) {
super(message);
}
}

@ -8,7 +8,7 @@ import lombok.EqualsAndHashCode;
*/ */
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class DeliveryNotReceivedException extends RuntimeException { public class DeliveryNotReceivedException extends BaseRuntimeException {
private Long shipTimestamp; private Long shipTimestamp;
public DeliveryNotReceivedException(String message, Long shipTimestamp) { public DeliveryNotReceivedException(String message, Long shipTimestamp) {
super(message); super(message);

@ -0,0 +1,18 @@
package com.ms.biz.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class MemberAlreadyUnbindException extends BaseRuntimeException {
protected String code = "100401";
public MemberAlreadyUnbindException() {
super("当前已解绑,无需再次解绑");
}
public MemberAlreadyUnbindException(String message) {
super(message);
}
}

@ -16,6 +16,9 @@ import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam;
import com.ms.biz.dto.openspi.request.UnbindParam; import com.ms.biz.dto.openspi.request.UnbindParam;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData; import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData; import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData;
import com.ms.biz.exception.BindMemberNotExistsException;
import com.ms.biz.exception.BusinessException;
import com.ms.biz.exception.MemberAlreadyUnbindException;
import com.ms.biz.service.DsApiService; import com.ms.biz.service.DsApiService;
import com.ms.biz.service.ShopService; import com.ms.biz.service.ShopService;
import com.ms.biz.bo.ShopBO; import com.ms.biz.bo.ShopBO;
@ -168,8 +171,14 @@ public class ShopServiceImpl implements ShopService {
public void querySupplyPlatformBindName(QuerySupplyPlatformBindNameParam param, QuerySupplyPlatformBindNameData data) { public void querySupplyPlatformBindName(QuerySupplyPlatformBindNameParam param, QuerySupplyPlatformBindNameData data) {
Long shopId = param.getShopId(); Long shopId = param.getShopId();
if (shopId == null || shopId == 0) { if (shopId == null || shopId == 0) {
throw new RuntimeException("店铺ID错误"); throw new BusinessException("参数错误:请检查您的查询参数是否正确", "100500");
}
ShopTo1688DsMember member = shopTo1688DsMemberMapper.getDetailByShopId(shopId);
if (member == null) {
throw new BindMemberNotExistsException();
} }
GetAuthInfoResponseDTO response = dsApiService.getAuthInfo(shopId); GetAuthInfoResponseDTO response = dsApiService.getAuthInfo(shopId);
if (response.isSuccess()) { if (response.isSuccess()) {
data.setBindName(response.getMemberName()); data.setBindName(response.getMemberName());
@ -182,16 +191,16 @@ public class ShopServiceImpl implements ShopService {
public void unbind(UnbindParam param) { public void unbind(UnbindParam param) {
Long shopId = param.getShopId(); Long shopId = param.getShopId();
if (shopId == null || shopId == 0) { if (shopId == null || shopId == 0) {
throw new RuntimeException("店铺ID错误"); throw new BusinessException("参数错误:请检查您的查询参数是否正确", "100400");
} }
ShopTo1688DsMember member = shopTo1688DsMemberMapper.getDetailByShopId(shopId); ShopTo1688DsMember member = shopTo1688DsMemberMapper.getDetailByShopId(shopId);
if (member == null) { if (member == null) {
throw new RuntimeException("该店铺未绑定"); throw new MemberAlreadyUnbindException();
} }
CommonResponseDTO response = dsApiService.delAuthShop(shopId); CommonResponseDTO response = dsApiService.delAuthShop(shopId);
if (!response.isSuccess()) { if (!response.isSuccess()) {
throw new RuntimeException(response.getReason()); throw new BusinessException(response.getReason());
} }
shopTo1688DsMemberMapper.deleteByPrimaryKey(member.getShopTo1688DsMemberId()); shopTo1688DsMemberMapper.deleteByPrimaryKey(member.getShopTo1688DsMemberId());

@ -11,6 +11,7 @@ import com.ms.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.BatchCreateParam; import com.ms.biz.dto.openspi.request.BatchCreateParam;
import com.ms.biz.dto.openspi.response.BatchCreateData; import com.ms.biz.dto.openspi.response.BatchCreateData;
import com.ms.biz.dto.openspi.response.BatchPayData; import com.ms.biz.dto.openspi.response.BatchPayData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.DistributionOrderService; import com.ms.biz.service.DistributionOrderService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -28,6 +29,8 @@ public class BatchCreateService extends SPIBaseService implements ExtensionServi
BatchCreateData data = new BatchCreateData(); BatchCreateData data = new BatchCreateData();
distributionOrderService.batchCreate(param, data); distributionOrderService.batchCreate(param, data);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) { } catch (RuntimeException e) {
log.error("batchCreate error1", e); log.error("batchCreate error1", e);
String message = e.getMessage() == null ? "系统异常" : e.getMessage(); String message = e.getMessage() == null ? "系统异常" : e.getMessage();

@ -11,6 +11,7 @@ import com.ms.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.BatchPayParam; import com.ms.biz.dto.openspi.request.BatchPayParam;
import com.ms.biz.dto.openspi.response.BatchPayData; import com.ms.biz.dto.openspi.response.BatchPayData;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData; import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.DistributionOrderService; import com.ms.biz.service.DistributionOrderService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -28,6 +29,8 @@ public class BatchPayService extends SPIBaseService implements ExtensionServiceH
BatchPayData data = new BatchPayData(); BatchPayData data = new BatchPayData();
distributionOrderService.batchPay(param, data); distributionOrderService.batchPay(param, data);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) { } catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build(); return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) { } catch (Throwable e) {

@ -10,6 +10,7 @@ import com.ms.biz.common.R;
import com.ms.biz.common.SPIBaseService; import com.ms.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.QuerySupplyPlatformAuthParam; import com.ms.biz.dto.openspi.request.QuerySupplyPlatformAuthParam;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData; import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.ShopService; import com.ms.biz.service.ShopService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -27,6 +28,8 @@ public class QuerySupplyPlatformAuthService extends SPIBaseService implements Ex
QuerySupplyPlatformAuthData data = new QuerySupplyPlatformAuthData(); QuerySupplyPlatformAuthData data = new QuerySupplyPlatformAuthData();
shopService.querySupplyPlatformAuth(param, data); shopService.querySupplyPlatformAuth(param, data);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) { } catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build(); return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) { } catch (Throwable e) {

@ -9,6 +9,7 @@ import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.biz.common.SPIBaseService; import com.ms.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam; import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData; import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.ShopService; import com.ms.biz.service.ShopService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -26,6 +27,8 @@ public class QuerySupplyPlatformBindNameService extends SPIBaseService implement
QuerySupplyPlatformBindNameData data = new QuerySupplyPlatformBindNameData(); QuerySupplyPlatformBindNameData data = new QuerySupplyPlatformBindNameData();
shopService.querySupplyPlatformBindName(param, data); shopService.querySupplyPlatformBindName(param, data);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) { } catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build(); return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) { } catch (Throwable e) {

@ -7,10 +7,9 @@ import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService; import com.jinritemai.cloud.base.api.ExtensionService;
import com.jinritemai.cloud.base.api.ExtensionServiceHandler; import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.biz.common.SPIBaseService; 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.request.UnbindParam;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData;
import com.ms.biz.dto.openspi.response.UnbindData; import com.ms.biz.dto.openspi.response.UnbindData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.ShopService; import com.ms.biz.service.ShopService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -28,6 +27,8 @@ public class UnbindService extends SPIBaseService implements ExtensionServiceHan
UnbindData data = new UnbindData(); UnbindData data = new UnbindData();
shopService.unbind(param); shopService.unbind(param);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) { } catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build(); return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) { } catch (Throwable e) {

Loading…
Cancel
Save