Browse Source

修复用户服务主键生成bug,订单服务代码开发

wuxw7 9 years ago
parent
commit
e27de138ab

File diff suppressed because it is too large
+ 983 - 209
.idea/workspace.xml


+ 107 - 2
OrderService/OrderService.iml

@@ -10,6 +10,7 @@
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="service" />
     <orderEntry type="module" module-name="common" />
     <orderEntry type="module" module-name="bean" />
     <orderEntry type="library" name="Maven: com.alibaba:fastjson:1.1.39" level="project" />
@@ -23,10 +24,114 @@
     <orderEntry type="library" name="Maven: ch.qos.logback:logback-access:1.1.3" level="project" />
     <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.3" level="project" />
     <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.3" level="project" />
-    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
     <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
     <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
     <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />
+    <orderEntry type="module" module-name="core" />
+    <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1" level="project" />
+    <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.1.1" level="project" />
+    <orderEntry type="library" name="Maven: org.mybatis:mybatis:3.4.1" level="project" />
+    <orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.3.1" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:1.4.0.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jdbc:8.5.4" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-juli:8.5.4" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.3.2.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.2.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: com.alibaba:druid:1.0.18" level="project" />
+    <orderEntry type="module-library">
+      <library name="Maven: com.alibaba:jconsole:1.8.0">
+        <CLASSES>
+          <root url="jar://F:/software/Java/jdk1.8.0_121/lib/jconsole.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="Maven: com.alibaba:tools:1.8.0">
+        <CLASSES>
+          <root url="jar://F:/software/Java/jdk1.8.0_121/lib/tools.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="library" name="Maven: tk.mybatis:mapper-spring-boot-starter:1.1.0" level="project" />
+    <orderEntry type="library" name="Maven: tk.mybatis:mapper-spring-boot-autoconfigure:1.0.0" level="project" />
+    <orderEntry type="library" name="Maven: tk.mybatis:mapper:3.3.9" level="project" />
+    <orderEntry type="library" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-eureka:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:1.1.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:1.1.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:4.1.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:1.1.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.47" level="project" />
+    <orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.47" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-core:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-eureka-client:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.eureka:eureka-client:1.4.10" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.jettison:jettison:1.3.7" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: stax:stax-api:1.0.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-eventbus:0.3.0" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.archaius:archaius-core:0.7.4" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: javax.ws.rs:jsr311-api:1.1.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.servo:servo-core:0.10.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.servo:servo-internal:0.10.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.jersey:jersey-core:1.19.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.jersey:jersey-client:1.19.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.jersey.contribs:jersey-apache-client4:1.19.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.httpcomponents:httpcore:4.4.5" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.google.inject:guice:4.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: javax.inject:javax.inject:1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: aopalliance:aopalliance:1.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.governator:governator-api:1.12.10" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.eureka:eureka-core:1.4.10" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-core:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.8.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-ec2:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-autoscaling:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-sts:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-route53:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.governator:governator:1.12.10" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.governator:governator-core:1.12.10" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.4.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: javax.xml.stream:stax-api:1.0-2" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:stax2-api:3.1.4" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-archaius:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" />
+    <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
+    <orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-ribbon:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon:2.2.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.ribbon:ribbon-transport:2.2.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.reactivex:rxnetty-contexts:0.4.9" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.reactivex:rxnetty-servo:0.4.9" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.hystrix:hystrix-core:1.5.3" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.hdrhistogram:HdrHistogram:2.1.7" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.reactivex:rxnetty:0.4.9" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-codec-http:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-codec:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-handler:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-common:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-buffer:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport:4.0.27.Final" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-core:2.2.0" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-httpclient:2.2.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-commons-util:0.1.1" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-loadbalancer:2.2.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-statistics:0.1.1" level="project" />
+    <orderEntry type="library" name="Maven: io.reactivex:rxjava:1.1.5" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-eureka:2.2.0" level="project" />
+    <orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.2" level="project" />
+    <orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
+    <orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
+    <orderEntry type="module" module-name="feign" />
+    <orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.39" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
     <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.4.0.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.4.0.RELEASE" level="project" />
@@ -60,7 +165,7 @@
     <orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
-    <orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.3" level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.5.0" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" />

+ 92 - 0
OrderService/README.md

@@ -6,4 +6,96 @@ OrderService模块
 
 1.1.2 订单提交
 
+请求报文格式为:
+{
+    "orderList": {
+        "orderListAttrs": [
+            {
+                "attrCd": "40010026",
+                "name": "购物车流水号",
+                "value": "31201704110009114961"
+            }
+        ],
+        "busiOrder": [
+            {
+                "data": {
+                    "boCust": [
+                        {
+                            "custId": "-1",
+                            "name": "S",
+                            "email": "-52",
+                            "cellphone": "17797173942",
+                            "realName": "wuxw",
+                            "sex": "1",
+                            "password": "123456",
+                            "lanId": "863010",
+                            "custAdress": "青海省西宁市城中区格兰小镇",
+                            "custType": "1",
+                            "openId": "",
+                            "state": "ADD"
+                        },
+                        {
+                            "custId": "123",
+                            "name": "S",
+                            "email": "-52",
+                            "cellphone": "17797173942",
+                            "realName": "wuxw",
+                            "sex": "1",
+                            "password": "123456",
+                            "lanId": "863010",
+                            "custAdress": "青海省西宁市城中区格兰小镇",
+                            "custType": "1",
+                            "openId": "",
+                            "state": "DEL"
+                        }
+                    ],
+                    "boCustAttr": [
+                        {
+                            "custId": "123",
+                            "prodId": "-1",
+                            "attrCd": "123344",
+                            "value": "1",
+                            "state": "ADD"
+                        },
+                        {
+                            "custId": "123",
+                            "prodId": "-1",
+                            "attrCd": "123345",
+                            "value": "1",
+                            "state": "DEL"
+                        }
+                    ]
+                },
+                "busiOrder": {
+                    "name": "新建客户",
+                    "actionTypeCd": "C1",
+                    "actionClassCd": "1",
+                    "status_cd": "S",
+                    "start_dt": "2017-04-11",
+                    "end_dt": "2017-04-12",
+                    "remark": ""
+                },
+                "busiOrderAttrs": [
+                    {
+                        "attrCd": "40010026",
+                        "name": "购物车流水号",
+                        "value": "31201704110009114961"
+                    }
+                ]
+            }
+        ],
+        "orderListInfo": {
+            "transactionId": "1000000200201704113137002690",
+            "channelId": "700212896",
+            "remarks": "",
+            "olId": "-1",
+            "custId": "701008023904",
+            "statusCd": "S",
+            "reqTime": "20170411163709",
+            "extSystemId": "310013698777",
+            "olTypeCd": "15"
+        }
+    }
+}
+
 1.1.3 订单取消

+ 33 - 1
OrderService/pom.xml

@@ -18,9 +18,41 @@
     </properties>
 
     <dependencies>
+
         <dependency>
             <groupId>com.java110</groupId>
-            <artifactId>common</artifactId>
+            <artifactId>service</artifactId>
         </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>2.10</version>
+                <executions>
+                    <execution>
+                        <id>unpack</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>unpack</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>com.java110</groupId>
+                                    <artifactId>config</artifactId>
+                                    <version>${microcommunity.version}</version>
+                                    <type>jar</type>
+                                    <overWrite>true</overWrite>
+                                    <outputDirectory>${project.build.directory}/classes</outputDirectory>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 </project>

+ 174 - 0
OrderService/src/main/java/com/java110/order/rest/OrderServiceRest.java

@@ -0,0 +1,174 @@
+package com.java110.order.rest;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.log.LoggerEngine;
+import com.java110.common.util.ProtocolUtil;
+import com.java110.core.base.controller.BaseController;
+import com.java110.order.smo.IOrderServiceSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 订单服务 提供类
+ *
+ * 主要提供订单相关服务
+ * Created by wuxw on 2017/4/11.
+ */
+@RestController
+public class OrderServiceRest extends BaseController {
+
+
+    @Autowired
+    IOrderServiceSMO iOrderServiceSMO;
+
+
+    /**
+     * 查询订单信息
+     * @param orderInfo
+     * @return
+     */
+    public String queryOrder(@RequestParam("orderInfo") String orderInfo) {
+
+        try {
+
+        }catch (Exception e){
+
+        }finally {
+            return "";
+        }
+    }
+
+    /**
+     * 订单统一处理接口
+     * 接口协议
+     * {
+     "orderList": {
+     "orderListAttrs": [
+     {
+     "attrCd": "40010026",
+     "name": "购物车流水号",
+     "value": "31201704110009114961"
+     }
+     ],"busiOrder": [
+     {
+
+     "data": {
+     "boCust": [
+     {
+     "custId": "-1",
+     "name": "S",
+     "email": "-52",
+     "cellphone": "17797173942",
+     "realName": "wuxw",
+     "sex": "1",
+     "password": "123456",
+     "lanId": "863010",
+     "custAdress": "青海省西宁市城中区格兰小镇",
+     "custType": "1",
+     "openId": "",
+     "state": "ADD"
+     },
+     {
+     "custId": "123",
+     "name": "S",
+     "email": "-52",
+     "cellphone": "17797173942",
+     "realName": "wuxw",
+     "sex": "1",
+     "password": "123456",
+     "lanId": "863010",
+     "custAdress": "青海省西宁市城中区格兰小镇",
+     "custType": "1",
+     "openId": "",
+     "state": "DEL"
+     }
+     ],
+     "boCustAttr": [
+     {
+     "custId": "123",
+     "prodId": "-1",
+     "attrCd": "123344",
+     "value": "1",
+     "state": "ADD"
+     },
+     {
+     "custId": "123",
+     "prodId": "-1",
+     "attrCd": "123345",
+     "value": "1",
+     "state": "DEL"
+     }
+     ]
+     },
+     "busiOrder": {
+     "name": "新建客户",
+     "actionTypeCd": "C1",
+     "actionClassCd": "1",
+     "status_cd": "S",
+     "start_dt": "2017-04-11",
+     "end_dt": "2017-04-12",
+     "remark": ""
+     },
+     "busiOrderAttrs": [
+     {
+     "attrCd": "40010026",
+     "name": "购物车流水号",
+     "value": "31201704110009114961"
+     }
+     ]
+     }
+
+     ],
+     "orderListInfo": {
+     "transactionId": "1000000200201704113137002690",
+     "channelId": "700212896",
+     "remarks": "",
+     "olId": "-1",
+     "custId": "701008023904",
+     "statusCd": "S",
+     "reqTime": "20170411163709",
+     "extSystemId": "310013698777",
+     "olTypeCd": "15"
+     }
+     }
+     }
+     * @param orderInfo
+     * @return
+     */
+    public String soOrderService(@RequestParam("orderInfo") String orderInfo){
+
+        LoggerEngine.debug("soOrderService入参:" + orderInfo);
+        String resultUserInfo = null;
+
+        JSONObject reqOrderJSON = null;
+
+        try{
+
+            reqOrderJSON = this.simpleValidateJSON(orderInfo);
+
+            if(reqOrderJSON == null || !reqOrderJSON.containsKey("orderList")){
+                throw new IllegalArgumentException("请求参数为空 reqOrderJSON :"+reqOrderJSON);
+            }
+
+            resultUserInfo = iOrderServiceSMO.orderDispatch(reqOrderJSON.getJSONObject("orderList"));
+
+        }catch (Exception e){
+            LoggerEngine.error("订单受理出现异常:", e);
+            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"订单受理出现异常,"+e,null);
+        }finally {
+            return resultUserInfo;
+        }
+
+
+    }
+
+
+    public IOrderServiceSMO getiOrderServiceSMO() {
+        return iOrderServiceSMO;
+    }
+
+    public void setiOrderServiceSMO(IOrderServiceSMO iOrderServiceSMO) {
+        this.iOrderServiceSMO = iOrderServiceSMO;
+    }
+}

+ 23 - 0
OrderService/src/main/java/com/java110/order/smo/IOrderServiceSMO.java

@@ -0,0 +1,23 @@
+package com.java110.order.smo;
+
+import com.alibaba.fastjson.JSONObject;
+
+/**
+ * 订单服务业务处理接口
+ *
+ * 订单受理
+ * Created by wuxw on 2017/4/11.
+ */
+public interface IOrderServiceSMO {
+
+    /**
+     * 订单调度,
+     * 根据订单类型 调用不同服务 处理
+     * @param orderInfo
+     * @return
+     * @throws Exception
+     */
+    public String orderDispatch(JSONObject orderInfo) throws Exception;
+
+
+}

+ 62 - 0
OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java

@@ -0,0 +1,62 @@
+package com.java110.order.smo.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.util.ProtocolUtil;
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.entity.order.OrderList;
+import com.java110.feign.base.IPrimaryKeyService;
+import com.java110.order.smo.IOrderServiceSMO;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 订单服务业务逻辑处理实现类
+ * Created by wuxw on 2017/4/11.
+ */
+@Service("orderServiceSMOImpl")
+public class OrderServiceSMOImpl extends BaseServiceSMO implements IOrderServiceSMO {
+
+    @Autowired
+    IPrimaryKeyService iPrimaryKeyService;
+
+    /**
+     * 订单调度
+     * @param orderInfo 订单信息
+     * @return 订单处理接口
+     * @throws Exception
+     */
+    @Override
+    public String orderDispatch(JSONObject orderInfo) throws Exception {
+
+        //1.0 购物车信息校验处理,走订单受理必须要有购物车信息和订单项信息
+        if(!orderInfo.containsKey("orderListInfo") || !orderInfo.containsKey("busiOrder")){
+            throw  new IllegalArgumentException("请求报文中没有购物车相关信息[orderListInfo]或订单项相关信息[busiOrder],请检查报文:"+orderInfo);
+        }
+
+        JSONObject orderListTmp = orderInfo.getJSONObject("orderListInfo");
+
+        OrderList orderList = JSONObject.parseObject(orderListTmp.toJSONString(),OrderList.class);
+
+        String olId = orderList.getOlId();
+        //生成olId
+        if(StringUtils.isBlank(olId) || olId.startsWith("-") ){
+            olId = this.queryPrimaryKey(iPrimaryKeyService,"OL_ID");
+            orderList.setOlId(olId);
+        }
+
+
+
+
+        return null;
+    }
+
+    public IPrimaryKeyService getiPrimaryKeyService() {
+        return iPrimaryKeyService;
+    }
+
+    public void setiPrimaryKeyService(IPrimaryKeyService iPrimaryKeyService) {
+        this.iPrimaryKeyService = iPrimaryKeyService;
+    }
+}

+ 44 - 5
UserService/src/main/java/com/java110/user/smo/impl/UserServiceSMOImpl.java

@@ -18,7 +18,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 用户服务信息管理业务信息实现
@@ -88,6 +90,9 @@ public class UserServiceSMOImpl extends BaseServiceSMO implements IUserServiceSM
 
         JSONObject resultInfo = null;
 
+        //存放生成的custId 主键为 custId-1 71000010100
+        Map custIdKey = new HashMap();
+
         if (userInfoJson == null){
             throw new IllegalArgumentException("soUserService 入参 为空"+userInfoJson);
         }
@@ -96,7 +101,7 @@ public class UserServiceSMOImpl extends BaseServiceSMO implements IUserServiceSM
                 JSONArray boCusts = userInfoJson.getJSONArray("boCust");
                 JSONObject boCustObj = new JSONObject();
                 boCustObj.put("boCust",boCusts);
-                String returnSaveBoCust = this.soBoCust(boCustObj.toJSONString());
+                String returnSaveBoCust = this.soBoCust(boCustObj.toJSONString(),custIdKey);
 
                 if(!ProtocolUtil.validateReturnJson(returnSaveBoCust,paramJson)){
 
@@ -111,6 +116,13 @@ public class UserServiceSMOImpl extends BaseServiceSMO implements IUserServiceSM
             if(userInfoJson.containsKey("boCustAttr")){
 
                 JSONArray boCustAttrs = userInfoJson.getJSONArray("boCustAttr");
+                //首先对custId 进行处理
+                if(custIdKey != null && custIdKey.size() > 0 ){
+                    for(int boCustAttrIndex = 0 ; boCustAttrIndex < boCustAttrs.size();boCustAttrIndex++){
+                       JSONObject boCustAttr = boCustAttrs.getJSONObject(boCustAttrIndex);
+                       boCustAttr.put("custId",custIdKey.get("custId"+boCustAttr.getString("custId")));
+                    }
+                }
                 JSONObject boCustAttrObj = new JSONObject();
                 boCustAttrObj.put("boCustAttr",boCustAttrs);
                 String returnSaveBoCustAttr = soBoCustAttr(boCustAttrObj.toJSONString());
@@ -139,6 +151,25 @@ public class UserServiceSMOImpl extends BaseServiceSMO implements IUserServiceSM
      * @throws Exception
      */
     public String soBoCust(String boCusts) throws Exception{
+        return soBoCust(boCusts,null);
+    }
+
+    /**
+     * 将生成的custId 封装在map中返回
+     * ...
+     * custIdKey.put("custId-1","710020404040");
+     *
+     * ...
+     *
+     * key 为 custId 加原前的值
+     *
+     * custIdKey 如果为空不做处理
+     * @param boCusts 客户信息
+     * @param custIdKey custIdKeymap
+     * @return
+     * @throws Exception
+     */
+    public String soBoCust(String boCusts,Map custIdKey) throws Exception{
         // 将 jsonArray 转为list<BoCust> 对象
         JSONObject jsonObject = JSONObject.parseObject(boCusts);
 
@@ -154,10 +185,10 @@ public class UserServiceSMOImpl extends BaseServiceSMO implements IUserServiceSM
         for(BoCust boCust : boCustList){
 //        for(int boCustIndex = 0 ; boCustIndex < boCustList.size();boCustIndex++){
 //            BoCust boCust = boCustList.get(boCustIndex);
-            int custId = NumberUtils.toInt(boCust.getBoId(),-1);
+            String custId = boCust.getBoId();
             //如果客户ID小于0 ,则自己生成客户ID,这个只有在有 主键生成服务时使用,否则为了防止出错,需要前段调用时需要生成custId
-            if(custId < 0 ){
-                JSONObject data = new JSONObject();
+            if(StringUtils.isBlank(custId) || custId.startsWith("-") ){
+                /*JSONObject data = new JSONObject();
                 data.put("type","CUST_ID");
                 //要求接口返回 {"RESULT_CODE":"0000","RESULT_INFO":{"user_id":"7020170411000041"},"RESULT_MSG":"成功"}
                 String custIdJSONStr = iPrimaryKeyService.queryPrimaryKey(data.toJSONString());
@@ -167,10 +198,17 @@ public class UserServiceSMOImpl extends BaseServiceSMO implements IUserServiceSM
                         && custIdJSONTmp.containsKey("RESULT_INFO")){
                     //从接口生成custId
                     custId = NumberUtils.toInt(custIdJSONTmp.getJSONObject("RESULT_INFO").getString("CUST_ID"),-1);
+                }*/
+
+                custId = this.queryPrimaryKey(iPrimaryKeyService,"CUST_ID");
+
+                //将 新生成的custId保存至 map中 custId-1 custId-2 主键方式存入
+                if(custIdKey != null){
+                    custIdKey.put("custId"+boCust.getCustId(),custId);
                 }
             }
 
-            boCust.setCustId(custId+"");
+            boCust.setCustId(custId);
 
             //保存数据至 bo_cust 表中
             int saveBoCustFlag = iUserServiceDao.saveDataToBoCust(boCust);
@@ -219,6 +257,7 @@ public class UserServiceSMOImpl extends BaseServiceSMO implements IUserServiceSM
             }
 
             custIds +=","+custId;
+
         }
 
         //去除第一个逗号

+ 58 - 0
UserService/src/test/java/com/java110/user/CustIdTest.java

@@ -0,0 +1,58 @@
+package com.java110.user;
+
+import com.java110.entity.user.BoCust;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Created by wuxw on 2017/4/11.
+ */
+public class CustIdTest extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public CustIdTest(String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+
+    public void testCustId(){
+        String oldCustId = "-600405001201704120001";
+
+        int targetId = NumberUtils.toInt(oldCustId,0);
+
+        System.out.printf("targetId : " + targetId);
+
+        if(StringUtils.isBlank(oldCustId) || oldCustId.startsWith("-") ){
+            System.out.printf(" oldCustId " + oldCustId);
+        }
+
+
+    }
+}

BIN
UserService/target/classes/com/java110/user/smo/impl/UserServiceSMOImpl.class


BIN
UserService/target/test-classes/com/java110/user/CustIdTest.class


BIN
bean/target/classes/com/java110/entity/user/BoCustAttr.class


+ 1 - 1
config/db/orders.db

@@ -8,7 +8,7 @@ create table order_list(
 
     custId  varchar(20) not null comment '客户ID,对应客户表cust',
 
-    olTypeCD  varchar(10) not null comment '购物车类型,网站 1 微信 2 APP 3 对应 order_list_type',
+    olTypeCd  varchar(10) not null comment '购物车类型,网站 1 微信 2 APP 3 对应 order_list_type',
 
      extSystemId  varchar(20) not null comment '对应外部系统 关联ID,方便维护',
 

+ 1 - 0
core/core.iml

@@ -27,6 +27,7 @@
     <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
     <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
     <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />
+    <orderEntry type="module" module-name="feign" scope="PROVIDED" />
     <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1" level="project" />
     <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.1.1" level="project" />
     <orderEntry type="library" name="Maven: org.mybatis:mybatis:3.4.1" level="project" />

+ 5 - 0
core/pom.xml

@@ -22,6 +22,11 @@
             <groupId>com.java110</groupId>
             <artifactId>common</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>feign</artifactId>
+            <scope>provided</scope>
+        </dependency>
 
         <dependency>
             <groupId>org.mybatis.spring.boot</groupId>

+ 32 - 0
core/src/main/java/com/java110/core/base/smo/BaseServiceSMO.java

@@ -4,7 +4,10 @@ package com.java110.core.base.smo;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.common.log.LoggerEngine;
+import com.java110.common.util.ProtocolUtil;
 import com.java110.core.base.AppBase;
+import com.java110.feign.base.IPrimaryKeyService;
+import org.apache.commons.lang3.math.NumberUtils;
 
 import java.util.List;
 import java.util.Map;
@@ -18,6 +21,35 @@ import java.util.Map;
 public class BaseServiceSMO extends AppBase {
 
 
+    /**
+     * 主键生成
+     * @param iPrimaryKeyService 主键生成服务对象
+     * @param type 主键类型 如 OL_ID , CUST_ID
+     * @return
+     * @throws Exception
+     */
+    protected String queryPrimaryKey(IPrimaryKeyService iPrimaryKeyService,String type) throws Exception{
+        JSONObject data = new JSONObject();
+        data.put("type",type);
+        //生成的ID
+        String targetId = "-1";
+        //要求接口返回 {"RESULT_CODE":"0000","RESULT_INFO":{"user_id":"7020170411000041"},"RESULT_MSG":"成功"}
+        String custIdJSONStr = iPrimaryKeyService.queryPrimaryKey(data.toJSONString());
+        JSONObject custIdJSONTmp = JSONObject.parseObject(custIdJSONStr);
+        if(custIdJSONTmp.containsKey("RESULT_CODE")
+                && ProtocolUtil.RETURN_MSG_SUCCESS.equals(custIdJSONTmp.getString("RESULT_CODE"))
+                && custIdJSONTmp.containsKey("RESULT_INFO")){
+            //从接口生成olId
+            targetId =  custIdJSONTmp.getJSONObject("RESULT_INFO").getString(type);
+        }
+        if("-1".equals(targetId)) {
+            throw new RuntimeException("调用主键生成服务服务失败," + custIdJSONStr);
+        }
+
+        return targetId;
+    }
+
+
 
 
 

BIN
core/target/classes/com/java110/core/base/smo/BaseServiceSMO.class