Authored by sailing-PC\sailing

fix

... ... @@ -58,13 +58,13 @@ public class GlobalDefaultExceptionHandler {
}
//如果是业务异常,则返回http 200,并且构造json消息体中错误码&错误内容
if (e instanceof GatewayException || e instanceof ServiceException) {
if (e instanceof GatewayException || e instanceof ServiceException || e instanceof Exception) {
int code;
String desc;
if (e instanceof GatewayException) {
code = ((GatewayException) e).getErrorCode();
desc = ((GatewayException) e).getDesc();
} else { //服务异常,不能直接返回给客户端,必须映射一下
} else if(e instanceof ServiceException) { //服务异常,不能直接返回给客户端,必须映射一下
ServiceException serviceException = (ServiceException) e;
ServiceError serviceError = serviceException.getServiceError();
code = serviceError.getMappingGatewayError().getLeft();
... ... @@ -72,6 +72,9 @@ public class GlobalDefaultExceptionHandler {
if (serviceException.getParams() != null) {
desc = MessageFormat.format(desc, serviceException.getParams());
}
}else {
code = 500;
desc = "服务暂时异常,请稍等";
}
log.warn("service exception happened at:{}, code:{}, desc:{}, uri:{}, request: {}, params is: {}", serviceName, code, desc, request.getRequestURI(), serviceName, params);
... ...
... ... @@ -3,6 +3,8 @@ package com.yohoufo.order.service.impl;
import com.yohoufo.order.service.impl.visitor.AutoCancelCase;
import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase;
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
/**
... ... @@ -11,9 +13,10 @@ import org.springframework.stereotype.Service;
@Service
public class SellerOrderCancelService {
private final Logger logger = LoggerFactory.getLogger(getClass());
public void cancel(UserCancelCase cancelCase){
logger.info("in cancel UserCancelCase {}", cancelCase);
//未支付时
//支付完成,没有买家下单
... ... @@ -23,13 +26,13 @@ public class SellerOrderCancelService {
public void cancel(AutoCancelCase autoCancelCase){
logger.info("in cancel autoCancelCase {}", autoCancelCase);
}
public void cancel(OffShelveCancelCase offShelveCancelCase){
logger.info("in cancel offShelveCancelCase {}", offShelveCancelCase);
}
}
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**
* Created by chenchao on 2018/9/17.
*/
public abstract class AbsSellerOrderCancelCase implements SellerOrderCancelCase{
public abstract class AbsSellerOrderCancelCase<T extends SellerOrderCancelService> implements SellerOrderCancelCase<T>{
private int uid;
... ... @@ -17,7 +17,7 @@ public abstract class AbsSellerOrderCancelCase implements SellerOrderCancelCase{
this.orderCode = orderCode;
}
public abstract void accept(SellerOrderCancelService visitor);
public abstract void accept(T visitor);
public int getUid() {
... ... @@ -27,4 +27,12 @@ public abstract class AbsSellerOrderCancelCase implements SellerOrderCancelCase{
public long getOrderCode() {
return orderCode;
}
@Override
public String toString() {
return "{" +
"uid=" + uid +
", orderCode=" + orderCode +
'}';
}
}
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**未支付 超时取消
* Created by chenchao on 2018/9/17.
*/
public class AutoCancelCase extends AbsSellerOrderCancelCase {
public class AutoCancelCase<T extends SellerOrderCancelService> extends AbsSellerOrderCancelCase<T> {
... ... @@ -14,10 +14,16 @@ public class AutoCancelCase extends AbsSellerOrderCancelCase {
}
@Override
public void accept(SellerOrderCancelService visitor) {
public void accept(T visitor) {
visitor.cancel(this);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("AutoCancelCase{");
sb.append(super.toString());
sb.append('}');
return sb.toString();
}
}
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**skup下架取消
* Created by chenchao on 2018/9/17.
*/
public class OffShelveCancelCase extends AbsSellerOrderCancelCase {
public class OffShelveCancelCase<T extends SellerOrderCancelService> extends AbsSellerOrderCancelCase<T> {
public OffShelveCancelCase(int uid, long orderCode) {
... ... @@ -14,7 +14,15 @@ public class OffShelveCancelCase extends AbsSellerOrderCancelCase {
@Override
public void accept(SellerOrderCancelService visitor) {
public void accept(T visitor) {
visitor.cancel(this);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("OffShelveCancelCase{");
sb.append(super.toString());
sb.append('}');
return sb.toString();
}
}
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**
* Created by chenchao on 2018/9/17.
*/
public interface SellerOrderCancelCase {
public interface SellerOrderCancelCase<T extends SellerOrderCancelService> {
void accept(SellerOrderCancelService visitor);
void accept(T visitor);
}
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**
* Created by chenchao on 2018/9/17.
*/
public class UserCancelCase extends AbsSellerOrderCancelCase {
public class UserCancelCase<T extends SellerOrderCancelService> extends AbsSellerOrderCancelCase<T> {
... ... @@ -14,7 +14,16 @@ public class UserCancelCase extends AbsSellerOrderCancelCase {
}
@Override
public void accept(SellerOrderCancelService visitor) {
public void accept(T visitor) {
visitor.cancel(this);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("UserCancelCase{");
sb.append(super.toString());
sb.append('}');
return sb.toString();
}
}
... ...