Просмотр исходного кода

2018-04-14 代码保存,实现简单鉴权,调整工程依赖功能

wuxw7 лет назад: 8
Родитель
Сommit
3afa34898e

Разница между файлами не показана из-за своего большого размера
+ 261 - 261
CenterService/doc/centerService.docx


+ 55 - 0
CenterService/src/main/java/com/java110/center/dao/ICenterServiceDAO.java

@@ -0,0 +1,55 @@
+package com.java110.center.dao;
+
+import com.java110.common.exception.DAOException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by wuxw on 2018/4/14.
+ */
+public interface ICenterServiceDAO {
+
+    /**
+     * 保存订单信息
+     * @param order 订单信息
+     * @return
+     */
+    public void saveOrder(Map order) throws DAOException;
+
+    /**
+     * 保存属性信息
+     * @param orderAttrs
+     * @return
+     */
+    public void saveOrderAttrs(List<Map> orderAttrs) throws DAOException;
+
+
+    /**
+     * 保存订单项信息
+     * @param business 订单项信息
+     * @return
+     */
+    public void saveBusiness(Map business) throws DAOException;
+
+    /**
+     * 保存属性信息
+     * @param businessAttrs
+     * @return
+     */
+    public void saveBusinessAttrs(List<Map> businessAttrs) throws DAOException;
+
+    /**
+     * 更新订单信息(一般就更新订单状态)
+     * @param order
+     * @throws DAOException
+     */
+    public void updateOrder(Map order) throws DAOException;
+
+    /**
+     * 更新订单项信息(一般就更新订单状态)
+     * @param order
+     * @throws DAOException
+     */
+    public void updateBusiness(Map order) throws DAOException;
+}

+ 119 - 0
CenterService/src/main/java/com/java110/center/dao/impl/CenterServiceDAOImpl.java

@@ -0,0 +1,119 @@
+package com.java110.center.dao.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.center.dao.ICenterServiceDAO;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.exception.DAOException;
+import com.java110.common.log.LoggerEngine;
+import com.java110.core.base.dao.BaseServiceDao;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 中心服务 数据操作类
+ * Created by wuxw on 2018/4/14.
+ */
+@Service("centerServiceDAOImpl")
+@Transactional
+public class CenterServiceDAOImpl extends BaseServiceDao implements ICenterServiceDAO {
+
+    /**
+     * 保存订单信息
+     * @param order 订单信息
+     * @return
+     */
+    @Override
+    public void saveOrder(Map order) throws DAOException{
+
+        LoggerEngine.debug("----【CenterServiceDAOImpl.saveOrder】保存数据入参 : " + JSONObject.toJSONString(order));
+
+        int saveFlag = sqlSessionTemplate.insert("centerServiceDAOImpl.saveOrder",order);
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"保存订单信息失败:"+ JSONObject.toJSONString(order));
+        }
+
+    }
+
+    /**
+     * 保存属性信息
+     * @param orderAttrs
+     * @return
+     */
+    @Override
+    public void saveOrderAttrs(List<Map> orderAttrs) throws DAOException {
+
+        LoggerEngine.debug("----【CenterServiceDAOImpl.saveOrderAttrs】保存数据入参 : " + JSONObject.toJSONString(orderAttrs));
+
+        for(Map orderAttr:orderAttrs){
+            int saveFlag = sqlSessionTemplate.insert("centerServiceDAOImpl.saveOrderAttrs",orderAttr);
+            if(saveFlag < 1){
+                throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"保存订单属性信息失败:"+ JSONObject.toJSONString(orderAttr));
+            }
+        }
+    }
+
+    /**
+     * 保存订单项信息
+     * @param business 订单项信息
+     */
+    @Override
+    public void saveBusiness(Map business) throws DAOException {
+
+        LoggerEngine.debug("----【CenterServiceDAOImpl.saveBusiness】保存数据入参 : " + JSONObject.toJSONString(business));
+
+        int saveFlag = sqlSessionTemplate.insert("centerServiceDAOImpl.saveBusiness",business);
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"保存订单项信息失败:"+ JSONObject.toJSONString(business));
+        }
+    }
+
+    /**
+     * 保存属性信息
+     * @param businessAttrs
+     */
+    @Override
+    public void saveBusinessAttrs(List<Map> businessAttrs) throws DAOException {
+
+        LoggerEngine.debug("----【CenterServiceDAOImpl.saveBusinessAttrs】保存数据入参 : " + JSONObject.toJSONString(businessAttrs));
+
+        for(Map businessAttr:businessAttrs){
+            int saveFlag = sqlSessionTemplate.insert("centerServiceDAOImpl.saveBusinessAttrs",businessAttr);
+            if(saveFlag < 1){
+                throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"保存订单项属性信息失败:"+ JSONObject.toJSONString(businessAttr));
+            }
+        }
+    }
+
+    /**
+     * 更新订单信息(一般就更新订单状态)
+     * @param order
+     * @throws DAOException
+     */
+    @Override
+    public void updateOrder(Map order) throws DAOException {
+        LoggerEngine.debug("----【CenterServiceDAOImpl.updateOrder】保存数据入参 : " + JSONObject.toJSONString(order));
+
+        int saveFlag = sqlSessionTemplate.update("centerServiceDAOImpl.updateOrder",order);
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"更新订单信息失败:"+ JSONObject.toJSONString(order));
+        }
+    }
+
+    /**
+     * 更新订单项信息(一般就更新订单项状态)
+     * @param order
+     * @throws DAOException
+     */
+    @Override
+    public void updateBusiness(Map order) throws DAOException {
+        LoggerEngine.debug("----【CenterServiceDAOImpl.updateBusiness】保存数据入参 : " + JSONObject.toJSONString(order));
+
+        int saveFlag = sqlSessionTemplate.update("centerServiceDAOImpl.updateBusiness",order);
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"更新订单项信息失败:"+ JSONObject.toJSONString(order));
+        }
+    }
+}

+ 3 - 1
CenterService/src/main/java/com/java110/center/smo/ICenterServiceSMO.java

@@ -1,5 +1,7 @@
 package com.java110.center.smo;
 
+import com.java110.common.exception.SMOException;
+
 import javax.servlet.http.HttpServletRequest;
 import java.util.Map;
 
@@ -14,5 +16,5 @@ public interface ICenterServiceSMO {
      * @param reqJson 请求报文json
      * @return
      */
-    public String service(String reqJson, Map<String,String> headers) ;
+    public String service(String reqJson, Map<String,String> headers) throws SMOException;
 }

+ 240 - 35
CenterService/src/main/java/com/java110/center/smo/impl/CenterServiceSMOImpl.java

@@ -1,10 +1,14 @@
 package com.java110.center.smo.impl;
 
+import com.java110.center.dao.ICenterServiceDAO;
 import com.java110.common.cache.AppRouteCache;
 import com.java110.center.smo.ICenterServiceSMO;
+import com.java110.common.cache.MappingCache;
+import com.java110.common.constant.MappingConstant;
 import com.java110.common.constant.ResponseConstant;
-import com.java110.common.exception.NoAuthorityException;
+import com.java110.common.exception.*;
 import com.java110.common.factory.DataFlowFactory;
+import com.java110.common.log.LoggerEngine;
 import com.java110.common.util.DateUtil;
 import com.java110.common.util.ResponseTemplateUtil;
 import com.java110.common.util.StringUtil;
@@ -12,10 +16,13 @@ import com.java110.entity.center.AppRoute;
 import com.java110.entity.center.AppService;
 import com.java110.entity.center.Business;
 import com.java110.entity.center.DataFlow;
+import com.java110.entity.rule.RuleEntrance;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -26,8 +33,11 @@ import java.util.Map;
 @Transactional
 public class CenterServiceSMOImpl implements ICenterServiceSMO {
 
+    @Autowired
+    ICenterServiceDAO orderServiceDaoImpl;
+
     @Override
-    public String service(String reqJson, Map<String,String> headers) {
+    public String service(String reqJson, Map<String, String> headers) throws SMOException{
 
         DataFlow dataFlow = null;
 
@@ -36,28 +46,55 @@ public class CenterServiceSMOImpl implements ICenterServiceSMO {
             dataFlow = DataFlowFactory.newInstance().builder(reqJson, headers);
             //2.0 加载配置信息
             initConfigData(dataFlow);
-            //2.0 校验 APPID是否有权限操作serviceCode
+            //3.0 校验 APPID是否有权限操作serviceCode
             judgeAuthority(dataFlow);
+            //4.0 调用规则校验
+            ruleValidate(dataFlow);
+            //5.0 保存订单和业务项 c_orders c_order_attrs c_business c_business_attrs
+            saveOrdersAndBusiness(dataFlow);
+            //6.0 调用下游系统
+            invokeBusinessSystem(dataFlow);
 
+        } catch (BusinessException e) {
+            try {
+                //7.0 作废订单和业务项
+                invalidOrderAndBusiness(dataFlow);
+                //8.0 广播作废业务系统订单信息
+                invalidBusinessSystem(dataFlow);
+            } catch (Exception e1) {
+                LoggerEngine.error("作废订单失败", e);
+                //9.0 记录作废失败的单子,人工处理。
+                saveInvalidBusinessError(dataFlow);
+            } finally {
+                return ResponseTemplateUtil.createOrderResponseJson(dataFlow.getTransactionId(),
+                        ResponseConstant.NO_NEED_SIGN, e.getResult().getCode(), e.getMessage());
+            }
 
-        }catch(NoAuthorityException e){
-
+        } catch (OrdersException e) {
             return ResponseTemplateUtil.createOrderResponseJson(dataFlow.getTransactionId(),
-                    ResponseConstant.NO_NEED_SIGN,e.getResult().getCode(),e.getMessage());
-        }catch (Exception e){
+                    ResponseConstant.NO_NEED_SIGN, e.getResult().getCode(), e.getMessage());
+        } catch (RuleException e) {
+            return ResponseTemplateUtil.createOrderResponseJson(dataFlow.getTransactionId(),
+                    ResponseConstant.NO_NEED_SIGN, e.getResult().getCode(), e.getMessage());
+        } catch (NoAuthorityException e) {
+            return ResponseTemplateUtil.createOrderResponseJson(dataFlow.getTransactionId(),
+                    ResponseConstant.NO_NEED_SIGN, e.getResult().getCode(), e.getMessage());
+        } catch (Exception e) {
             return ResponseTemplateUtil.createOrderResponseJson(dataFlow == null
-                            ?ResponseConstant.NO_TRANSACTION_ID
-                            :dataFlow.getTransactionId(),
-                    ResponseConstant.NO_NEED_SIGN,ResponseConstant.RESULT_CODE_INNER_ERROR,"内部异常了:"+e.getMessage()+e.getLocalizedMessage());
-        }finally {
+                            ? ResponseConstant.NO_TRANSACTION_ID
+                            : dataFlow.getTransactionId(),
+                    ResponseConstant.NO_NEED_SIGN, ResponseConstant.RESULT_CODE_INNER_ERROR, "内部异常了:" + e.getMessage() + e.getLocalizedMessage());
+        } finally {
             //这里记录日志
             Date endDate = DateUtil.getCurrentDate();
-            if(dataFlow == null){ //说明异常了
+            if (dataFlow == null) { //说明异常了,不能记录耗时
+
                 return null;
             }
             dataFlow.setEndDate(endDate);
+
             //添加耗时
-            DataFlowFactory.addCostTime(dataFlow,"service","业务处理总耗时",dataFlow.getStartDate(),dataFlow.getEndDate());
+            DataFlowFactory.addCostTime(dataFlow, "service", "业务处理总耗时", dataFlow.getStartDate(), dataFlow.getEndDate());
 
             //这里保存耗时,以及日志
 
@@ -67,59 +104,227 @@ public class CenterServiceSMOImpl implements ICenterServiceSMO {
     }
 
     /**
-     * 初始化配置信息
+     * 2.0初始化配置信息
+     *
      * @param dataFlow
      */
-    private void initConfigData(DataFlow dataFlow){
-
+    private void initConfigData(DataFlow dataFlow) {
+        Date startDate = DateUtil.getCurrentDate();
         //查询配置信息,并将配置信息封装到 dataFlow 对象中
         AppRoute appRoute = AppRouteCache.getAppRoute(dataFlow.getAppId());
 
-        if(appRoute == null){
+        if (appRoute == null) {
+            //添加耗时
+            DataFlowFactory.addCostTime(dataFlow, "initConfigData", "加载配置耗时", startDate);
             throw new RuntimeException("当前没有获取到AppId对应的信息");
         }
         dataFlow.setAppRoute(appRoute);
+        //添加耗时
+        DataFlowFactory.addCostTime(dataFlow, "initConfigData", "加载配置耗时", startDate);
     }
+
     /**
-     * 判断 AppId 是否 有serviceCode权限
+     * 3.0判断 AppId 是否 有serviceCode权限
+     *
      * @param dataFlow
      * @throws RuntimeException
      */
-    private void judgeAuthority(DataFlow dataFlow) throws NoAuthorityException{
-
+    private void judgeAuthority(DataFlow dataFlow) throws NoAuthorityException {
+        Date startDate = DateUtil.getCurrentDate();
 
-        if(StringUtil.isNullOrNone(dataFlow.getAppId()) || dataFlow.getAppRoute() == null){
-            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"appId 为空或不正确");
+        if (StringUtil.isNullOrNone(dataFlow.getAppId()) || dataFlow.getAppRoute() == null) {
+            //添加耗时
+            DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate);
+            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "appId 为空或不正确");
         }
 
-        if(StringUtil.isNullOrNone(dataFlow.getTransactionId())){
-            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"transactionId 不能为空");
+        if (StringUtil.isNullOrNone(dataFlow.getTransactionId())) {
+            //添加耗时
+            DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate);
+            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "transactionId 不能为空");
         }
 
-        if(StringUtil.isNullOrNone(dataFlow.getUserId())){
-            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"userId 不能为空");
+        if (StringUtil.isNullOrNone(dataFlow.getUserId())) {
+            //添加耗时
+            DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate);
+            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "userId 不能为空");
         }
 
-        if(StringUtil.isNullOrNone(dataFlow.getRequestTime()) || DateUtil.judgeDate(dataFlow.getRequestTime(),DateUtil.DATE_FORMATE_STRING_DEFAULT)){
-            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"requestTime 格式不对,遵循yyyyMMddHHmmss格式");
+        if (StringUtil.isNullOrNone(dataFlow.getRequestTime()) || DateUtil.judgeDate(dataFlow.getRequestTime(), DateUtil.DATE_FORMATE_STRING_DEFAULT)) {
+            //添加耗时
+            DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate);
+            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "requestTime 格式不对,遵循yyyyMMddHHmmss格式");
         }
 
-        if(StringUtil.isNullOrNone(dataFlow.getOrderTypeCd())){
-            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"orderTypeCd 不能为空");
+        if (StringUtil.isNullOrNone(dataFlow.getOrderTypeCd())) {
+            //添加耗时
+            DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate);
+            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "orderTypeCd 不能为空");
         }
 
         //判断 AppId 是否有权限操作相应的服务
-        if(dataFlow.getBusinesses() != null && dataFlow.getBusinesses().size() > 0){
-            for (Business business : dataFlow.getBusinesses()){
+        if (dataFlow.getBusinesses() != null && dataFlow.getBusinesses().size() > 0) {
+            for (Business business : dataFlow.getBusinesses()) {
 
-               AppService appService = DataFlowFactory.getService(dataFlow,business.getServiceCode());
+                AppService appService = DataFlowFactory.getService(dataFlow, business.getServiceCode());
 
                 //这里调用缓存 查询缓存信息
-                if(appService == null){
-                    throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"AppId 没有权限访问 serviceCod = "+business.getServiceCode());
+                if (appService == null) {
+                    //添加耗时
+                    DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate);
+                    throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "AppId 没有权限访问 serviceCod = " + business.getServiceCode());
                 }
             }
         }
+
+        //检验白名单
+        List<String> whileListIp = dataFlow.getAppRoute().getWhileListIp();
+        if (whileListIp != null && !whileListIp.contains(dataFlow.getIp())) {
+            //添加耗时
+            DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate);
+            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "当前IP被限制不能访问服务");
+        }
+
+        //检查黑名单
+        List<String> backListIp = dataFlow.getAppRoute().getBackListIp();
+        if (backListIp != null && backListIp.contains(dataFlow.getIp())) {
+            //添加耗时
+            DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate);
+            throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "当前IP被限制不能访问服务");
+        }
+        //添加耗时
+        DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate);
+    }
+
+    /**
+     * 4.0规则校验
+     *
+     * @param dataFlow
+     * @throws RuleException
+     */
+    private void ruleValidate(DataFlow dataFlow) throws RuleException {
+        Date startDate = DateUtil.getCurrentDate();
+        try {
+
+            if (MappingConstant.VALUE_OFF.equals(MappingCache.getValue(MappingConstant.KEY_RULE_ON_OFF))
+                    || (MappingCache.getValue(MappingConstant.KEY_NO_NEED_RULE_VALDATE_ORDER) != null
+                    && MappingCache.getValue(MappingConstant.KEY_NO_NEED_RULE_VALDATE_ORDER).contains(dataFlow.getOrderTypeCd()))) {
+                //不做校验
+                //添加耗时
+                DataFlowFactory.addCostTime(dataFlow, "ruleValidate", "规则校验耗时", startDate);
+                return ;
+            }
+
+            //调用规则
+
+        } catch (Exception e) {
+            //添加耗时
+            DataFlowFactory.addCostTime(dataFlow, "ruleValidate", "规则校验耗时", startDate);
+            throw new RuleException(ResponseConstant.RESULT_CODE_RULE_ERROR, "规则校验异常失败:" + e.getMessage());
+        }
+
+        DataFlowFactory.addCostTime(dataFlow, "ruleValidate", "规则校验耗时", startDate);
+
     }
 
+    /**
+     * 5.0 保存订单和业务项 c_orders c_order_attrs c_business c_business_attrs
+     *
+     * @param dataFlow
+     * @throws OrdersException
+     */
+    private void saveOrdersAndBusiness(DataFlow dataFlow) throws OrdersException {
+        Date startDate = DateUtil.getCurrentDate();
+        if(MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null
+                &&MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrderTypeCd())){
+            //不保存订单信息
+            DataFlowFactory.addCostTime(dataFlow, "saveOrdersAndBusiness", "保存订单和业务项耗时", startDate);
+            return ;
+        }
+
+        //1.0 保存 orders信息
+
+
+        //2.0 保存 business信息
+
+
+        DataFlowFactory.addCostTime(dataFlow, "saveOrdersAndBusiness", "保存订单和业务项耗时", startDate);
+    }
+
+    /**
+     * 6.0 调用下游系统
+     *
+     * @param dataFlow
+     * @throws BusinessException
+     */
+    private void invokeBusinessSystem(DataFlow dataFlow) throws BusinessException {
+        Date startDate = DateUtil.getCurrentDate();
+        if(MappingCache.getValue(MappingConstant.KEY_NO_INVOKE_BUSINESS_SYSTEM) != null
+                &&MappingCache.getValue(MappingConstant.KEY_NO_INVOKE_BUSINESS_SYSTEM).contains(dataFlow.getOrderTypeCd())){
+            //不用调用 下游系统的配置(一般不存在这种情况,这里主要是在没有下游系统的情况下测试中心服务用)
+            DataFlowFactory.addCostTime(dataFlow, "invokeBusinessSystem", "调用下游系统耗时", startDate);
+            return ;
+        }
+
+        DataFlowFactory.addCostTime(dataFlow, "invokeBusinessSystem", "调用下游系统耗时", startDate);
+    }
+
+    /**
+     * 7.0 作废订单和业务项
+     *
+     * @param dataFlow
+     */
+    private void invalidOrderAndBusiness(DataFlow dataFlow) {
+        Date startDate = DateUtil.getCurrentDate();
+        if(MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null
+                &&MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrderTypeCd())){
+            //不用作废订单信息
+            DataFlowFactory.addCostTime(dataFlow, "invalidOrderAndBusiness", "作废订单和业务项耗时", startDate);
+            return ;
+        }
+
+        DataFlowFactory.addCostTime(dataFlow, "invalidOrderAndBusiness", "作废订单和业务项耗时", startDate);
+    }
+
+    /**
+     * 8.0 广播作废业务系统订单信息
+     *
+     * @param dataFlow
+     */
+    private void invalidBusinessSystem(DataFlow dataFlow) {
+        Date startDate = DateUtil.getCurrentDate();
+        if(MappingCache.getValue(MappingConstant.KEY_NO_INVALID_BUSINESS_SYSTEM) != null
+                &&MappingCache.getValue(MappingConstant.KEY_NO_INVALID_BUSINESS_SYSTEM).contains(dataFlow.getOrderTypeCd())){
+            //不用调用 下游系统的配置(一般不存在这种情况,这里主要是在没有下游系统的情况下测试中心服务用)
+            DataFlowFactory.addCostTime(dataFlow, "invalidBusinessSystem", "作废业务耗时", startDate);
+            return ;
+        }
+
+
+        DataFlowFactory.addCostTime(dataFlow, "invalidBusinessSystem", "作废业务耗时", startDate);
+    }
+
+    /**
+     * 9.0 记录作废失败的单子,人工处理。
+     *
+     * @param dataFlow
+     */
+    private void saveInvalidBusinessError(DataFlow dataFlow) {
+
+        Date startDate = DateUtil.getCurrentDate();
+
+
+
+        DataFlowFactory.addCostTime(dataFlow, "saveInvalidBusinessError", "保存作废业务失败耗时", startDate);
+
+    }
+
+
+    public ICenterServiceDAO getOrderServiceDaoImpl() {
+        return orderServiceDaoImpl;
+    }
+
+    public void setOrderServiceDaoImpl(ICenterServiceDAO orderServiceDaoImpl) {
+        this.orderServiceDaoImpl = orderServiceDaoImpl;
+    }
 }

+ 19 - 0
CenterService/src/main/resources/application.yml

@@ -0,0 +1,19 @@
+jedis:
+  pool:
+    config:
+      maxTotal: 100
+      maxIdle: 20
+      maxWaitMillis: 20000
+    host: 127.0.0.1
+    port: 3306
+
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://localhost:8761/eureka/
+server:
+  port: 8001
+spring:
+  application:
+    name: center-service
+

+ 13 - 0
java110-common/src/main/java/com/java110/common/constant/MappingConstant.java

@@ -11,6 +11,19 @@ public class MappingConstant {
 
     public  final static String KEY_LOG_ON_OFF = "LOG_ON_OFF";
     public  final static String KEY_COST_TIME_ON_OFF = "COST_TIME_ON_OFF";
+    public  final static String KEY_RULE_ON_OFF = "RULE_ON_OFF";
     public  final static String VALUE_ON = "ON";
     public  final static String VALUE_OFF = "OFF";
+
+    //不用调用规则校验的配置
+    public  final static String KEY_NO_NEED_RULE_VALDATE_ORDER = "NO_NEED_RULE_VALDATE_ORDER";//Q
+
+    //不用报错订单也订单项信息的配置
+    public  final static String KEY_NO_SAVE_ORDER = "NO_SAVE_ORDER";//Q
+
+    // 不用调用 下游系统的配置(一般不存在这种情况,这里主要是在没有下游系统的情况下测试中心服务用)
+    public  final static String KEY_NO_INVOKE_BUSINESS_SYSTEM = "NO_INVOKE_BUSINESS_SYSTEM";//
+
+    // 不用调用 作废下游系统的配置(一般不存在这种情况,这里主要是在没有下游系统的情况下测试中心服务用)
+    public  final static String KEY_NO_INVALID_BUSINESS_SYSTEM = "NO_INVALID_BUSINESS_SYSTEM";//
 }

+ 2 - 0
java110-common/src/main/java/com/java110/common/constant/ResponseConstant.java

@@ -31,6 +31,8 @@ public class ResponseConstant {
      */
     public final static String RESULT_CODE_NO_AUTHORITY_ERROR = "1996";
 
+    public final static String RESULT_CODE_RULE_ERROR = "1995";
+
     /**
      * 没有从报文中获取到 请求流水
      */

+ 189 - 0
java110-common/src/main/java/com/java110/common/exception/BusinessException.java

@@ -0,0 +1,189 @@
+package com.java110.common.exception;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * 无权限异常
+ * Created by wuxw on 2018/4/14.
+ */
+public class BusinessException extends RuntimeException {
+
+
+    private Result result;
+    private Throwable cause = this;
+
+    public BusinessException(){}
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param cause  异常堆栈
+     */
+    public BusinessException(Result result, Throwable cause) {
+        super(result.getMsg(), cause);
+        this.result = result;
+    }
+
+    /**
+     * 构造方法
+     * @param code 返回码
+     * @param msg  错误消息
+     */
+    public BusinessException(int code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    public BusinessException(String code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     */
+    public BusinessException(Result result, String detail) {
+        super(result.getMsg() + "," + detail);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     * @param cause  异常堆栈
+     */
+    public BusinessException(Result result, String detail, Throwable cause) {
+        super(result.getMsg() + "," + detail, cause);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param msg	返回消息
+     * @param cause 异常堆栈
+     */
+    public BusinessException(int code, String msg, Throwable cause) {
+        super(msg, cause);
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param cause	异常堆栈
+     */
+    public BusinessException(int code, Throwable cause) {
+        super(cause);
+        String msg = "";
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     *
+     * TODO 简单描述该方法的实现功能(可选).
+     * @see Throwable#getCause()
+     */
+    public synchronized Throwable getCause() {
+        return (cause==this ? super.getCause() : cause);
+    }
+
+
+    /**
+     * 返回异常消息
+     * @return 异常消息
+     */
+    @Override
+    public String getMessage() {
+        return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+    }
+
+    /**
+     * 异常
+     * @return
+     */
+    public String toJsonString() {
+        JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
+        JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");
+
+        if (getResult() != null)
+            exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
+
+        exceptionJsonObj.put("exceptionTrace",getMessage());
+
+        return exceptionJsonObj.toString();
+    }
+    @Override
+    public void printStackTrace(PrintStream ps) {
+        ps.print("<exception>");
+        if (getResult() != null) {
+            ps.print(result.toString());
+        }
+        ps.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(ps);
+        } else {
+            ps.println(this);
+            ps.print("Caused by: ");
+            cause.printStackTrace(ps);
+        }
+        ps.append("</exceptionTrace>");
+        ps.println("</exception>");
+    }
+
+    @Override
+    public void printStackTrace(PrintWriter pw) {
+        pw.print("<exception>");
+        if (getResult() != null) {
+            pw.print(result.toString());
+        }
+        pw.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(pw);
+        } else {
+            pw.println(this);
+            pw.print("Caused by: ");
+            cause.printStackTrace(pw);
+        }
+        pw.append("</exceptionTrace>");
+        pw.println("</exception>");
+    }
+
+    /**
+     * 返回异常值
+     * @return	异常值对象
+     */
+    public Result getResult() {
+        return result;
+    }
+
+    public void setResult(Result result) {
+        this.result = result;
+    }
+
+}

+ 189 - 0
java110-common/src/main/java/com/java110/common/exception/DAOException.java

@@ -0,0 +1,189 @@
+package com.java110.common.exception;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * 无权限异常
+ * Created by wuxw on 2018/4/14.
+ */
+public class DAOException extends RuntimeException {
+
+
+    private Result result;
+    private Throwable cause = this;
+
+    public DAOException(){}
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param cause  异常堆栈
+     */
+    public DAOException(Result result, Throwable cause) {
+        super(result.getMsg(), cause);
+        this.result = result;
+    }
+
+    /**
+     * 构造方法
+     * @param code 返回码
+     * @param msg  错误消息
+     */
+    public DAOException(int code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    public DAOException(String code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     */
+    public DAOException(Result result, String detail) {
+        super(result.getMsg() + "," + detail);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     * @param cause  异常堆栈
+     */
+    public DAOException(Result result, String detail, Throwable cause) {
+        super(result.getMsg() + "," + detail, cause);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param msg	返回消息
+     * @param cause 异常堆栈
+     */
+    public DAOException(int code, String msg, Throwable cause) {
+        super(msg, cause);
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param cause	异常堆栈
+     */
+    public DAOException(int code, Throwable cause) {
+        super(cause);
+        String msg = "";
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     *
+     * TODO 简单描述该方法的实现功能(可选).
+     * @see Throwable#getCause()
+     */
+    public synchronized Throwable getCause() {
+        return (cause==this ? super.getCause() : cause);
+    }
+
+
+    /**
+     * 返回异常消息
+     * @return 异常消息
+     */
+    @Override
+    public String getMessage() {
+        return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+    }
+
+    /**
+     * 异常
+     * @return
+     */
+    public String toJsonString() {
+        JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
+        JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");
+
+        if (getResult() != null)
+            exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
+
+        exceptionJsonObj.put("exceptionTrace",getMessage());
+
+        return exceptionJsonObj.toString();
+    }
+    @Override
+    public void printStackTrace(PrintStream ps) {
+        ps.print("<exception>");
+        if (getResult() != null) {
+            ps.print(result.toString());
+        }
+        ps.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(ps);
+        } else {
+            ps.println(this);
+            ps.print("Caused by: ");
+            cause.printStackTrace(ps);
+        }
+        ps.append("</exceptionTrace>");
+        ps.println("</exception>");
+    }
+
+    @Override
+    public void printStackTrace(PrintWriter pw) {
+        pw.print("<exception>");
+        if (getResult() != null) {
+            pw.print(result.toString());
+        }
+        pw.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(pw);
+        } else {
+            pw.println(this);
+            pw.print("Caused by: ");
+            cause.printStackTrace(pw);
+        }
+        pw.append("</exceptionTrace>");
+        pw.println("</exception>");
+    }
+
+    /**
+     * 返回异常值
+     * @return	异常值对象
+     */
+    public Result getResult() {
+        return result;
+    }
+
+    public void setResult(Result result) {
+        this.result = result;
+    }
+
+}

+ 189 - 0
java110-common/src/main/java/com/java110/common/exception/OrdersException.java

@@ -0,0 +1,189 @@
+package com.java110.common.exception;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * 无权限异常
+ * Created by wuxw on 2018/4/14.
+ */
+public class OrdersException extends RuntimeException {
+
+
+    private Result result;
+    private Throwable cause = this;
+
+    public OrdersException(){}
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param cause  异常堆栈
+     */
+    public OrdersException(Result result, Throwable cause) {
+        super(result.getMsg(), cause);
+        this.result = result;
+    }
+
+    /**
+     * 构造方法
+     * @param code 返回码
+     * @param msg  错误消息
+     */
+    public OrdersException(int code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    public OrdersException(String code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     */
+    public OrdersException(Result result, String detail) {
+        super(result.getMsg() + "," + detail);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     * @param cause  异常堆栈
+     */
+    public OrdersException(Result result, String detail, Throwable cause) {
+        super(result.getMsg() + "," + detail, cause);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param msg	返回消息
+     * @param cause 异常堆栈
+     */
+    public OrdersException(int code, String msg, Throwable cause) {
+        super(msg, cause);
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param cause	异常堆栈
+     */
+    public OrdersException(int code, Throwable cause) {
+        super(cause);
+        String msg = "";
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     *
+     * TODO 简单描述该方法的实现功能(可选).
+     * @see Throwable#getCause()
+     */
+    public synchronized Throwable getCause() {
+        return (cause==this ? super.getCause() : cause);
+    }
+
+
+    /**
+     * 返回异常消息
+     * @return 异常消息
+     */
+    @Override
+    public String getMessage() {
+        return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+    }
+
+    /**
+     * 异常
+     * @return
+     */
+    public String toJsonString() {
+        JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
+        JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");
+
+        if (getResult() != null)
+            exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
+
+        exceptionJsonObj.put("exceptionTrace",getMessage());
+
+        return exceptionJsonObj.toString();
+    }
+    @Override
+    public void printStackTrace(PrintStream ps) {
+        ps.print("<exception>");
+        if (getResult() != null) {
+            ps.print(result.toString());
+        }
+        ps.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(ps);
+        } else {
+            ps.println(this);
+            ps.print("Caused by: ");
+            cause.printStackTrace(ps);
+        }
+        ps.append("</exceptionTrace>");
+        ps.println("</exception>");
+    }
+
+    @Override
+    public void printStackTrace(PrintWriter pw) {
+        pw.print("<exception>");
+        if (getResult() != null) {
+            pw.print(result.toString());
+        }
+        pw.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(pw);
+        } else {
+            pw.println(this);
+            pw.print("Caused by: ");
+            cause.printStackTrace(pw);
+        }
+        pw.append("</exceptionTrace>");
+        pw.println("</exception>");
+    }
+
+    /**
+     * 返回异常值
+     * @return	异常值对象
+     */
+    public Result getResult() {
+        return result;
+    }
+
+    public void setResult(Result result) {
+        this.result = result;
+    }
+
+}

+ 189 - 0
java110-common/src/main/java/com/java110/common/exception/RuleException.java

@@ -0,0 +1,189 @@
+package com.java110.common.exception;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * 无权限异常
+ * Created by wuxw on 2018/4/14.
+ */
+public class RuleException extends RuntimeException {
+
+
+    private Result result;
+    private Throwable cause = this;
+
+    public RuleException(){}
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param cause  异常堆栈
+     */
+    public RuleException(Result result, Throwable cause) {
+        super(result.getMsg(), cause);
+        this.result = result;
+    }
+
+    /**
+     * 构造方法
+     * @param code 返回码
+     * @param msg  错误消息
+     */
+    public RuleException(int code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    public RuleException(String code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     */
+    public RuleException(Result result, String detail) {
+        super(result.getMsg() + "," + detail);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     * @param cause  异常堆栈
+     */
+    public RuleException(Result result, String detail, Throwable cause) {
+        super(result.getMsg() + "," + detail, cause);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param msg	返回消息
+     * @param cause 异常堆栈
+     */
+    public RuleException(int code, String msg, Throwable cause) {
+        super(msg, cause);
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param cause	异常堆栈
+     */
+    public RuleException(int code, Throwable cause) {
+        super(cause);
+        String msg = "";
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     *
+     * TODO 简单描述该方法的实现功能(可选).
+     * @see Throwable#getCause()
+     */
+    public synchronized Throwable getCause() {
+        return (cause==this ? super.getCause() : cause);
+    }
+
+
+    /**
+     * 返回异常消息
+     * @return 异常消息
+     */
+    @Override
+    public String getMessage() {
+        return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+    }
+
+    /**
+     * 异常
+     * @return
+     */
+    public String toJsonString() {
+        JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
+        JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");
+
+        if (getResult() != null)
+            exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
+
+        exceptionJsonObj.put("exceptionTrace",getMessage());
+
+        return exceptionJsonObj.toString();
+    }
+    @Override
+    public void printStackTrace(PrintStream ps) {
+        ps.print("<exception>");
+        if (getResult() != null) {
+            ps.print(result.toString());
+        }
+        ps.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(ps);
+        } else {
+            ps.println(this);
+            ps.print("Caused by: ");
+            cause.printStackTrace(ps);
+        }
+        ps.append("</exceptionTrace>");
+        ps.println("</exception>");
+    }
+
+    @Override
+    public void printStackTrace(PrintWriter pw) {
+        pw.print("<exception>");
+        if (getResult() != null) {
+            pw.print(result.toString());
+        }
+        pw.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(pw);
+        } else {
+            pw.println(this);
+            pw.print("Caused by: ");
+            cause.printStackTrace(pw);
+        }
+        pw.append("</exceptionTrace>");
+        pw.println("</exception>");
+    }
+
+    /**
+     * 返回异常值
+     * @return	异常值对象
+     */
+    public Result getResult() {
+        return result;
+    }
+
+    public void setResult(Result result) {
+        this.result = result;
+    }
+
+}

+ 189 - 0
java110-common/src/main/java/com/java110/common/exception/SMOException.java

@@ -0,0 +1,189 @@
+package com.java110.common.exception;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * 无权限异常
+ * Created by wuxw on 2018/4/14.
+ */
+public class SMOException extends RuntimeException {
+
+
+    private Result result;
+    private Throwable cause = this;
+
+    public SMOException(){}
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param cause  异常堆栈
+     */
+    public SMOException(Result result, Throwable cause) {
+        super(result.getMsg(), cause);
+        this.result = result;
+    }
+
+    /**
+     * 构造方法
+     * @param code 返回码
+     * @param msg  错误消息
+     */
+    public SMOException(int code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    public SMOException(String code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     */
+    public SMOException(Result result, String detail) {
+        super(result.getMsg() + "," + detail);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     * @param cause  异常堆栈
+     */
+    public SMOException(Result result, String detail, Throwable cause) {
+        super(result.getMsg() + "," + detail, cause);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param msg	返回消息
+     * @param cause 异常堆栈
+     */
+    public SMOException(int code, String msg, Throwable cause) {
+        super(msg, cause);
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param cause	异常堆栈
+     */
+    public SMOException(int code, Throwable cause) {
+        super(cause);
+        String msg = "";
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     *
+     * TODO 简单描述该方法的实现功能(可选).
+     * @see Throwable#getCause()
+     */
+    public synchronized Throwable getCause() {
+        return (cause==this ? super.getCause() : cause);
+    }
+
+
+    /**
+     * 返回异常消息
+     * @return 异常消息
+     */
+    @Override
+    public String getMessage() {
+        return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+    }
+
+    /**
+     * 异常
+     * @return
+     */
+    public String toJsonString() {
+        JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
+        JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");
+
+        if (getResult() != null)
+            exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
+
+        exceptionJsonObj.put("exceptionTrace",getMessage());
+
+        return exceptionJsonObj.toString();
+    }
+    @Override
+    public void printStackTrace(PrintStream ps) {
+        ps.print("<exception>");
+        if (getResult() != null) {
+            ps.print(result.toString());
+        }
+        ps.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(ps);
+        } else {
+            ps.println(this);
+            ps.print("Caused by: ");
+            cause.printStackTrace(ps);
+        }
+        ps.append("</exceptionTrace>");
+        ps.println("</exception>");
+    }
+
+    @Override
+    public void printStackTrace(PrintWriter pw) {
+        pw.print("<exception>");
+        if (getResult() != null) {
+            pw.print(result.toString());
+        }
+        pw.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(pw);
+        } else {
+            pw.println(this);
+            pw.print("Caused by: ");
+            cause.printStackTrace(pw);
+        }
+        pw.append("</exceptionTrace>");
+        pw.println("</exception>");
+    }
+
+    /**
+     * 返回异常值
+     * @return	异常值对象
+     */
+    public Result getResult() {
+        return result;
+    }
+
+    public void setResult(Result result) {
+        this.result = result;
+    }
+
+}

+ 17 - 0
java110-common/src/main/java/com/java110/common/factory/DataFlowFactory.java

@@ -23,6 +23,23 @@ public class DataFlowFactory {
         return new DataFlow(DateUtil.getCurrentDate(), ResponseConstant.RESULT_CODE_SUCCESS);
     }
 
+    /**
+     * 添加耗时
+     * @param dataFlow 数据流
+     * @param linksCode 环节编码
+     * @param linksName 环节名称
+     * @param startDate 开始时间
+     * @return
+     */
+    public static DataFlow addCostTime(DataFlow dataFlow, String linksCode, String linksName, Date startDate){
+        if(MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_COST_TIME_ON_OFF))) {
+            DataFlowLinksCost dataFlowLinksCost = new DataFlowLinksCost().builder(linksCode, linksName, startDate, DateUtil.getCurrentDate());
+            dataFlow.addLinksCostDatas(dataFlowLinksCost);
+        }
+        return dataFlow;
+    }
+
+
     /**
      * 添加耗时
      * @param dataFlow 数据流

+ 54 - 0
java110-config/src/main/resources/mapper/center/CenterServiceDAOImplMapper.xml

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="centerServiceDAOImpl">
+
+    <!--保存订单信息 c_orders 中 -->
+    <insert id="saveOrder" parameterType="map">
+        <![CDATA[
+            insert into c_orders(o_id,app_id,ext_transaction_id,user_id,request_time,order_type_cd,remark,status_cd)
+            values(#{oId},#{appId},#{extTransactionId},#{userId},#{requestTime},#{orderTypeCd},#{remark},#{statusCd})
+        ]]>
+    </insert>
+    <!-- 保存属性信息c_orders_attrs 中-->
+    <insert id="saveOrderAttrs" parameterType="map">
+        <![CDATA[
+            insert into c_orders_attrs(o_id,attr_id,spec_cd,value)
+            values(#{oId},#{attrId},#{specCd},#{value})
+        ]]>
+    </insert>
+    <!-- 保存订单项信息 c_business -->
+    <insert id="saveBusiness" parameterType="map">
+        <![CDATA[
+            insert into c_business(b_id,o_id,business_type_cd,remark,status_cd)
+            values(#{bId},#{oId},#{businessTypeCd},#{remark},#{statusCd})
+        ]]>
+    </insert>
+    <!-- 保存属性信息 c_business_attrs -->
+    <insert id="saveBusinessAttrs" parameterType="map">
+        <![CDATA[
+            insert into c_business_attrs(b_id,attr_id,spec_cd,value)
+            values(#{bId},#{attrId},#{specCd},#{value})
+        ]]>
+    </insert>
+    <!-- 更新订单信息(一般就更新订单状态) -->
+    <update id="updateOrder" parameterType="map" >
+        <![CDATA[
+            update c_orders co set
+            co.status_cd=#{statusCd},
+            co.finish_time=#{finishTime}
+            where co.o_id=#{oId}
+         ]]>
+    </update>
+    <!-- 更新订单项信息(一般就更新订单项状态)-->
+    <update id="updateBusiness" parameterType="map">
+        <![CDATA[
+            update c_business cb set
+            cb.status_cd=#{statusCd},
+            cb.finish_time=#{finishTime}
+            where cb.o_id=#{oId}
+         ]]>
+    </update>
+
+</mapper>