Authored by sailing-PC\sailing

fix

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