liujs 3 years ago
parent
commit
d2ca15bc0e
100 changed files with 20045 additions and 0 deletions
  1. 3 0
      .gitignore
  2. 35 0
      .gitlab-ci.yml
  3. 9 0
      Dockerfile
  4. 4 0
      express-main/README.md
  5. BIN
      express-main/pdf/small_table.pdf
  6. 774 0
      express-main/pom.xml
  7. 123 0
      express-main/src/main/java/cn/haliaeetus/constants/AlipayConfig.java
  8. 755 0
      express-main/src/main/java/cn/haliaeetus/constants/Constants.java
  9. 29 0
      express-main/src/main/java/cn/haliaeetus/constants/DBMonitorConfig.java
  10. 20 0
      express-main/src/main/java/cn/haliaeetus/constants/EmailConfig.java
  11. 38 0
      express-main/src/main/java/cn/haliaeetus/constants/ExpressAccountConstants.java
  12. 194 0
      express-main/src/main/java/cn/haliaeetus/constants/MapConstants.java
  13. 176 0
      express-main/src/main/java/cn/haliaeetus/constants/SMSConfig.java
  14. 273 0
      express-main/src/main/java/cn/haliaeetus/controller/CacheController.java
  15. 65 0
      express-main/src/main/java/cn/haliaeetus/controller/HomeController.java
  16. 62 0
      express-main/src/main/java/cn/haliaeetus/controller/SignReturnController.java
  17. 296 0
      express-main/src/main/java/cn/haliaeetus/controller/TestController.java
  18. 103 0
      express-main/src/main/java/cn/haliaeetus/controller/alipay/AlipayNotifyController.java
  19. 78 0
      express-main/src/main/java/cn/haliaeetus/controller/app2/AppGetContactNumberAction.java
  20. 48 0
      express-main/src/main/java/cn/haliaeetus/controller/app2/AppGetPositionAction.java
  21. 119 0
      express-main/src/main/java/cn/haliaeetus/controller/app2/AppPhoneFromExpAction.java
  22. 39 0
      express-main/src/main/java/cn/haliaeetus/controller/app2/AppSendBackController.java
  23. 60 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppContentController.java
  24. 173 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppDeliveryScanBatchTwoController.java
  25. 1097 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppDispatchController.java
  26. 397 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppForgetPasswordController.java
  27. 94 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppGetStorePhoneController.java
  28. 1551 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppQueryAction.java
  29. 184 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppRegiestController.java
  30. 148 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppRetentionController.java
  31. 995 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppSendEmailController.java
  32. 343 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppSettingController.java
  33. 203 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppShelfController.java
  34. 520 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppSignOptActionController.java
  35. 49 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppStaffController.java
  36. 164 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppStatiscsAction.java
  37. 549 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppStoreInController.java
  38. 74 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppUploadController.java
  39. 81 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppVersionController.java
  40. 127 0
      express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppWhiteListController.java
  41. 66 0
      express-main/src/main/java/cn/haliaeetus/controller/baishi/BaishiServiceController.java
  42. 202 0
      express-main/src/main/java/cn/haliaeetus/controller/common/CommonExpressAPIController.java
  43. 213 0
      express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderDTO.java
  44. 41 0
      express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderModifyDTO.java
  45. 65 0
      express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderPackageDTO.java
  46. 122 0
      express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderReturnDTO.java
  47. 51 0
      express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderStatusDTO.java
  48. 31 0
      express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrdersDTO.java
  49. 31 0
      express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrdersReturnDTO.java
  50. 76 0
      express-main/src/main/java/cn/haliaeetus/controller/common/dto/StoreInfoDTO.java
  51. 55 0
      express-main/src/main/java/cn/haliaeetus/controller/common/response/BaseJsonResponse.java
  52. 48 0
      express-main/src/main/java/cn/haliaeetus/controller/common/response/StoreListJsonResponse.java
  53. 55 0
      express-main/src/main/java/cn/haliaeetus/controller/common/response/SubmitOrdersJsonResponse.java
  54. 238 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/DangdangAPIController.java
  55. 76 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/MenDianInStorageDTO.java
  56. 210 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderDTO.java
  57. 73 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderErrorDTO.java
  58. 63 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderErrorListDTO.java
  59. 120 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderStatusFeedbackDTO.java
  60. 76 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderTraceLogFeekbackDTO.java
  61. 65 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/ZongZhanInStorageDTO.java
  62. 65 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/ZongZhanOutStorageDTO.java
  63. 239 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/invoker/DangdangAPIInvoker.java
  64. 60 0
      express-main/src/main/java/cn/haliaeetus/controller/dangdang/response/SubmitOrdersJsonResponse.java
  65. 353 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/AppLoginController.java
  66. 210 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/AppRechargeController.java
  67. 78 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/AppUpdateController.java
  68. 229 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/AppWeiXinController.java
  69. 307 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/ArrivalController.java
  70. 364 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/CompleteController.java
  71. 269 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/DeliveryActionController.java
  72. 71 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/DeliveryRemindController.java
  73. 272 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/DispatchController.java
  74. 172 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/GetAllExpController.java
  75. 302 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/GetAllStoreShelfController.java
  76. 264 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/LeaveController.java
  77. 242 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/SmsCenterController.java
  78. 325 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/StoreInController.java
  79. 40 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/StoreInfoController.java
  80. 147 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/StoreOutController.java
  81. 51 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/StoreStaffController.java
  82. 159 0
      express-main/src/main/java/cn/haliaeetus/controller/deviceapi/TakePadController.java
  83. 621 0
      express-main/src/main/java/cn/haliaeetus/controller/graduate/GraduateController.java
  84. 329 0
      express-main/src/main/java/cn/haliaeetus/controller/graduate/ReceivedPayController.java
  85. 478 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/GraduationController.java
  86. 162 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/alipay/AliPayHelper.java
  87. 46 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/alipay/config/AlipayConfig.java
  88. 28 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/alipay/factory/AlipayClientFactory.java
  89. 38 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/HttpResponseDto.java
  90. 193 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/HttpUtil.java
  91. 46 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/MD5Util.java
  92. 37 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/ParseXMLUtils.java
  93. 291 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/TenpayUtil.java
  94. 291 0
      express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/WeChatProxy.java
  95. 164 0
      express-main/src/main/java/cn/haliaeetus/controller/htky/invoker/HtkyAPIInvoker.java
  96. 36 0
      express-main/src/main/java/cn/haliaeetus/controller/jhy/JhyPhoneController.java
  97. 255 0
      express-main/src/main/java/cn/haliaeetus/controller/lanjian/ElePrintController.java
  98. 101 0
      express-main/src/main/java/cn/haliaeetus/controller/lanjian/shunfeng/SFConstants.java
  99. 601 0
      express-main/src/main/java/cn/haliaeetus/controller/lanjian/shunfeng/SFPrintUtil.java
  100. 80 0
      express-main/src/main/java/cn/haliaeetus/controller/lanjian/shunfeng/bean/common/Body.java

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+express-main/.idea/
+*.iml
+express-main/target/

+ 35 - 0
.gitlab-ci.yml

@@ -0,0 +1,35 @@
+# 定义流水线阶段,在这里我们分为打包、检查运行环境、部署三个阶段,分别为:package/check-env/deploy
+stages:
+  - package
+  - build_image
+  - push_image
+
+# 定义所需变量
+variables:
+  FILE_NAME: Phoenix.war
+  CONTAINER_NAME: phoenix
+
+# 打包项目公共阶段
+步骤1:打包项目:
+  stage: package
+  only:
+    refs:
+      - dev
+  tags:
+    - maven
+  script:
+    - mvn clean package -f express-main/pom.xml -Dmaven.test.skip=true -P dev
+  artifacts:
+    paths:
+      - express-main/target/$FILE_NAME
+
+步骤2:制作镜像:
+  stage: build_image
+  only:
+    refs:
+      - dev
+  tags:
+    - docker-env
+  script:
+    - sudo docker build -t $CI_PROJECT_NAME:$CI_COMMIT_REF_NAME .
+    - sudo docker stop $CONTAINER_NAME || true && sudo docker rm $CONTAINER_NAME || true && sudo docker run --name $CONTAINER_NAME -d -p 8080:8080 $CI_PROJECT_NAME:$CI_COMMIT_REF_NAME

+ 9 - 0
Dockerfile

@@ -0,0 +1,9 @@
+FROM tomcat:8.5.41-jre8-alpine
+
+ENV TZ='Asia/Shanghai'
+
+RUN rm -rf /usr/local/tomcat/webapps/*
+
+ADD express-main/target/Phoenix.war /usr/local/tomcat/webapps/ROOT.war
+
+CMD ["catalina.sh", "run"]

+ 4 - 0
express-main/README.md

@@ -0,0 +1,4 @@
+## express
+
+快递
+

BIN
express-main/pdf/small_table.pdf


+ 774 - 0
express-main/pom.xml

@@ -0,0 +1,774 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>cn.haliaeetus.jisu</groupId>
+	<artifactId>fengzhan-express</artifactId>
+	<version>1.1.0-SNAPSHOT</version>
+	<packaging>war</packaging>
+
+	<name>fengzhan-express</name>
+	<url>http://maven.apache.org</url>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<spring.version>4.1.9.RELEASE</spring.version>
+	</properties>
+
+    <repositories>
+<!--        <repository>-->
+<!--            <id>rdc-releases</id>-->
+<!--            <url>https://packages.aliyun.com/maven/repository/2016267-release-e2oMD6/</url>-->
+<!--        </repository>-->
+<!--        <repository>-->
+<!--            <id>rdc-snapshots</id>-->
+<!--            <url>https://packages.aliyun.com/maven/repository/2016267-snapshot-mOX6cH/</url>-->
+<!--        </repository>-->
+    </repositories>
+
+    <dependencies>
+        <!-- commons -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+            <version>1.3</version>
+        </dependency>
+
+        <!-- http client -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+        </dependency>
+
+        <dependency>
+            <groupId>net.sf.ezmorph</groupId>
+            <artifactId>ezmorph</artifactId>
+            <version>1.0.6</version>
+        </dependency>
+        <!-- json -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.1.36</version>
+        </dependency>
+
+        <!-- json -->
+        <dependency>
+            <groupId>com.json.lib.2.4.jdk15</groupId>
+            <artifactId>json-lib-2.4-jdk15</artifactId>
+            <version>2.4</version>
+        </dependency>
+        <!-- xml -->
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.3.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.thoughtworks.xstream</groupId>
+            <artifactId>xstream</artifactId>
+            <version>1.4.7</version>
+        </dependency>
+
+        <!-- db -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>5.1.30</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis-spring</artifactId>
+            <version>1.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis</artifactId>
+            <version>3.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-dbcp</groupId>
+            <artifactId>commons-dbcp</artifactId>
+            <version>1.3</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>17.0-rc2</version>
+        </dependency>
+        <!-- aop -->
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjweaver</artifactId>
+            <version>1.8.3</version>
+        </dependency>
+
+
+        <!-- common web -->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>3.0.1</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jstl</artifactId>
+            <version>1.2</version>
+        </dependency>
+        <!--<dependency>
+            <groupId>javax</groupId>
+            <artifactId>javaee-api</artifactId>
+            <version>6.0</version>
+            <scope>provided</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax</groupId>
+                    <artifactId>javaee-web-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>-->
+
+        <!-- spring3 -->
+        <!-- mvc framework -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-webmvc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aop</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.5</version>
+            <scope>test</scope>
+        </dependency>
+        <!-- 日期操作尽量用joda库。SimpleDateFormat有同步问题,commons-lang里的api又不好用 -->
+        <dependency>
+            <groupId>joda-time</groupId>
+            <artifactId>joda-time</artifactId>
+            <version>2.2</version>
+        </dependency>
+        <!-- log依赖slf4j,远离log选型纠葛。各项目依需要使用logback或log4j <dependency> <groupId>cn.haliaeetus</groupId>
+            <artifactId>log4j</artifactId> <version>1.0</version> </dependency> -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.0.13</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-beanutils</groupId>
+            <artifactId>commons-beanutils</artifactId>
+            <version>1.9.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.2.2</version>
+        </dependency>
+
+        <!-- memcached <dependency> <groupId>cn.haliaeetus</groupId> <artifactId>gaia_persistence</artifactId>
+            <version>1.0.3</version> </dependency> -->
+        <dependency>
+            <groupId>commons-pool</groupId>
+            <artifactId>commons-pool</artifactId>
+            <version>1.6</version>
+        </dependency>
+
+        <!-- <dependency> <groupId>cn.haliaeetus</groupId> <artifactId>java_memcached</artifactId>
+            <version>2.6.6</version> </dependency> -->
+
+        <!-- excel导出 -->
+        <dependency>
+            <groupId>jexcelapi</groupId>
+            <artifactId>jxl</artifactId>
+            <version>2.6</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>core</artifactId>
+            <version>3.1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.stuxuhai</groupId>
+            <artifactId>jpinyin</artifactId>
+            <version>1.0</version>
+        </dependency>
+
+        <!-- Apache POI -->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>3.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-excelant</artifactId>
+            <version>3.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>3.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml-schemas</artifactId>
+            <version>3.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-scratchpad</artifactId>
+            <version>3.8</version>
+        </dependency>
+
+        <!-- zookeeper -->
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-framework</artifactId>
+            <version>2.7.1</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>log4j</artifactId>
+                    <groupId>log4j</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-recipes</artifactId>
+            <version>2.7.1</version>
+        </dependency>
+
+        <!-- 令牌桶实现包 -->
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>18.0</version>
+        </dependency>
+
+        <!-- zookeeper end -->
+
+        <!-- <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId>
+            <version>1.16.2</version> <scope>provided</scope> </dependency> -->
+
+        <!-- mybatis shard -->
+        <!-- <dependency> <groupId>org.shardbatis</groupId> <artifactId>shardbatis</artifactId>
+            <version>2.0.0B</version> </dependency> -->
+        <!-- <dependency> <groupId>cn.haliaeetus</groupId> <artifactId>yunda_api</artifactId>
+            <version>1.6</version> </dependency> <dependency> <groupId>cn.haliaeetus</groupId>
+            <artifactId>trace-order-api</artifactId> <version>1.4-SNAPSHOT</version>
+            </dependency> -->
+        <dependency>
+            <groupId>com.gs</groupId>
+            <artifactId>dubbo</artifactId>
+            <version>2.5.3</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!--dubbo注册中心-->
+        <dependency>
+            <groupId>org.apache.zookeeper</groupId>
+            <artifactId>zookeeper</artifactId>
+            <version>3.4.6</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>slf4j-api</artifactId>
+                    <groupId>org.slf4j</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>slf4j-log4j12</artifactId>
+                    <groupId>org.slf4j</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>log4j</artifactId>
+                    <groupId>log4j</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <!--zookeeper客户端-->
+        <dependency>
+            <groupId>com.github.sgroschupf</groupId>
+            <artifactId>zkclient</artifactId>
+            <version>0.1</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>zookeeper</artifactId>
+                    <groupId>org.apache.zookeeper</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>log4j</artifactId>
+                    <groupId>log4j</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>zookeeper</artifactId>
+                    <groupId>org.apache.zookeeper</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <!--dubbo 需要依赖的,不然会报错-->
+        <dependency>
+            <groupId>org.javassist</groupId>
+            <artifactId>javassist</artifactId>
+            <version>3.20.0-GA</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itextpdf</artifactId>
+            <version>5.5.7</version>
+        </dependency>
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itext-asian</artifactId>
+            <version>5.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.jpush.api</groupId>
+            <artifactId>jpush-client</artifactId>
+            <version>3.2.8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-api</artifactId>
+            <version>1.2.7</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>geronimo-javamail_1.4_spec</artifactId>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-dom</artifactId>
+            <version>1.2.7</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>geronimo-javamail_1.4_spec</artifactId>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-impl</artifactId>
+            <version>1.2.7</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>geronimo-javamail_1.4_spec</artifactId>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-adb</artifactId>
+            <version>1.4.1</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>mail</artifactId>
+                    <groupId>javax.mail</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>geronimo-javamail_1.4_spec</artifactId>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent-java12</artifactId>
+            <version>3.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>jdom</groupId>
+            <artifactId>jdom</artifactId>
+            <version>1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alipay</groupId>
+            <artifactId>alipay-sdk</artifactId>
+            <version>20170725114550</version>
+        </dependency>
+
+        <!-- Redis客户端 -->
+        <dependency>
+            <groupId>redis.clients</groupId>
+            <artifactId>jedis</artifactId>
+            <version>2.9.0</version>
+        </dependency>
+
+        <!-- 标签打印机 -->
+        <!-- https://mvnrepository.com/artifact/com.sun.jna/jna -->
+        <dependency>
+            <groupId>com.sun.jna</groupId>
+            <artifactId>jna</artifactId>
+            <version>3.0.9</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.10</version>
+        </dependency>
+
+        <!-- 11https://mvnrepository.com/artifact/org.apache.httpcomponents/fluent-hc -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>fluent-hc</artifactId>
+            <version>4.5.2</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.2</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.barcode4j</groupId>
+            <artifactId>barcode4j</artifactId>
+            <version>2.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>net.sf.barcode4j</groupId>
+            <artifactId>barcode4j-light</artifactId>
+            <version>2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jbarcode</groupId>
+            <artifactId>JBarcode</artifactId>
+            <version>0.2.8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.csource</groupId>
+            <artifactId>fastdfs-client-java</artifactId>
+            <version>1.27</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.jfinal</groupId>
+            <artifactId>jfinal-weixin</artifactId>
+            <version>1.9</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>core</artifactId>
+            <version>3.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>javase</artifactId>
+            <version>3.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.jfinal</groupId>
+            <artifactId>jfinal</artifactId>
+            <version>3.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.opendoor</groupId>
+            <artifactId>opendoor</artifactId>
+            <version>3.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jms</artifactId>
+            <version>4.0.4.RELEASE</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>spring-core</artifactId>
+                    <groupId>org.springframework</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>xbean-spring</artifactId>
+            <version>3.16</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>commons-logging</artifactId>
+                    <groupId>commons-logging</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>com.bs</groupId>
+            <artifactId>wx-api</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>3.11.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context-support</artifactId>
+            <version>4.2.6.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.mail</groupId>
+            <artifactId>mail</artifactId>
+            <version>1.4.7</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.xuxueli</groupId>
+            <artifactId>xxl-job-core</artifactId>
+            <version>1.9.1</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/com.alipay.sdk/alipay-sdk-java -->
+        <dependency>
+            <groupId>com.alipay.sdk</groupId>
+            <artifactId>alipay-sdk-java</artifactId>
+            <version>3.6.0.ALL</version>
+        </dependency>
+
+        <!-- 阿里云AMQP -->
+        <dependency>
+            <groupId>org.springframework.amqp</groupId>
+            <artifactId>spring-rabbit</artifactId>
+            <version>1.6.1.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.mq-amqp</groupId>
+            <artifactId>mq-amqp-client</artifactId>
+            <version>1.0.5</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>Phoenix</finalName>
+
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.xml</include>
+                    <include>**/*.pdf</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>src/main/resources/${package.environment}</directory>
+                <includes>
+                    <include>*.properties</include>
+                    <include>*.xml</include>
+                    <include>*.conf</include>
+                    <include>*.pdf</include>
+                    <include>*.p12</include>
+                </includes>
+            </resource>
+
+        </resources>
+        <!-- <testResources> <testResource> <directory>src/test/resources</directory>
+            </testResource> </testResources> -->
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.0</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <!-- Source attach plugin -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>3.0.1</version>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.mortbay.jetty</groupId>
+                <artifactId>jetty-maven-plugin</artifactId>
+                <version>8.1.16.v20140903</version>
+                <configuration>
+                    <connectors>
+                        <connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
+                            <port>8888</port>
+                        </connector>
+                    </connectors>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>3.1.0</version>
+                <configuration>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>3.0.2</version>
+                <executions>
+                    <execution>
+                        <id>my-jar</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>api</classifier>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <configuration>
+                    <packagingExcludes>WEB-INF/lib/geronimo-javamail_1.4_spec-1.2.jar</packagingExcludes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.mybatis.generator</groupId>
+                <artifactId>mybatis-generator-maven-plugin</artifactId>
+                <version>1.3.2</version>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>pro</id>
+            <properties>
+                <package.environment>pro</package.environment>
+            </properties>
+        </profile>
+        <profile>
+            <id>dev</id>
+            <properties>
+                <package.environment>dev</package.environment>
+            </properties>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+        </profile>
+    </profiles>
+
+    <organization>
+        <name>haliaeetus</name>
+        <url>www.haliaeetus.cn</url>
+    </organization>
+</project>

+ 123 - 0
express-main/src/main/java/cn/haliaeetus/constants/AlipayConfig.java

@@ -0,0 +1,123 @@
+package cn.haliaeetus.constants;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * 支付宝配置工具类
+ *
+ */
+public class AlipayConfig {
+	
+	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("alipay", Locale.CHINA);
+	
+	// --- 支付宝新老版本通用配置 ---
+	/**
+	 * 支付宝商户私钥
+	 */
+	public static String getAlipayPrivateKey() {
+		return RESOURCE_BUNDLE.getString("alipay.privateKey");
+	}
+
+	/**
+	 * 支付宝公钥
+	 */
+	public static String getAlipayPublicKey() {
+		return RESOURCE_BUNDLE.getString("alipay.publicKey");
+	}
+
+	/**
+	 * 请求使用的编码格式
+	 */
+	public static String getAlipayCharset() {
+		return RESOURCE_BUNDLE.getString("alipay.charset");
+	}
+
+	/**
+	 * 商户生成签名字符串所使用的签名算法类型
+	 */
+	public static String getAlipaySignType() {
+		return RESOURCE_BUNDLE.getString("alipay.sign.type");
+	}
+
+	/**
+	 * 支付宝服务器主动通知商户服务器里指定的页面http/https路径
+	 */
+	public static String getAlipayNotifyurl() {
+		return RESOURCE_BUNDLE.getString("alipay.notifyurl");
+	}
+
+	/**
+	 * 该笔订单允许的最晚付款时间,逾期将关闭交易
+	 */
+	public static String getAlipayTimeoutExpress() {
+		return RESOURCE_BUNDLE.getString("alipay.timeout.express");
+	}
+
+	// --- 支付宝老版本配置 ---
+	/**
+	 * 接口名称
+	 */
+	public static String getAlipayPayService() {
+		return RESOURCE_BUNDLE.getString("alipay.pay.service");
+	}
+
+	/**
+	 * 签约的支付宝账号对应的支付宝唯一用户号。以2088开头的16位纯数字组成。
+	 */
+	public static String getAlipayPartner() {
+		return RESOURCE_BUNDLE.getString("alipay.partner");
+	}
+	
+	/**
+	 * 支付类型
+	 */
+	public static String getAlipayPaymentType() {
+		return RESOURCE_BUNDLE.getString("alipay.payment.type");
+	}
+
+	/**
+	 * 卖家支付宝账号
+	 */
+	public static String getAlipaySellerId() {
+		return RESOURCE_BUNDLE.getString("alipay.sellerId");
+	}
+
+	// --- 支付宝新版本配置 ---
+	/**
+	 * 支付宝分配给开发者的应用ID
+	 */
+	public static String getAlipayAppID() {
+		return RESOURCE_BUNDLE.getString("alipay.appID");
+	}
+	
+	/**
+	 * 商家和支付宝签约的产品码
+	 */
+	public static String getAlipayProductCode() {
+		return RESOURCE_BUNDLE.getString("alipay.product.code");
+	}
+	
+	/**
+	 * 接口名称2.0
+	 */
+	public static String getAlipayPayMethod() {
+		return RESOURCE_BUNDLE.getString("alipay.pay.method");
+	}
+	
+	/**
+	 * 调用的接口版本,固定为:1.0
+	 */
+	public static String getAlipayVersion() {
+		return RESOURCE_BUNDLE.getString("alipay.version");
+	}
+
+	/**
+	 *
+	 * @return 支付主题
+	 */
+	public static String getAlipaySubject() {
+		return RESOURCE_BUNDLE.getString("alipay.subject");
+	}
+
+}

+ 755 - 0
express-main/src/main/java/cn/haliaeetus/constants/Constants.java

@@ -0,0 +1,755 @@
+package cn.haliaeetus.constants;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+
+/**
+ * <p>
+ * 常量类
+ * </p>
+ *
+ * @author sqj
+ * @version 1.0
+ * @since 1.0
+ */
+public class Constants {
+    /**
+     * 是
+     */
+    public static final int YES = 1;
+    /**
+     * 否
+     */
+    public static final int NO = 0;
+    
+    // ------门店状态------
+    /**
+     * 未开
+     */
+    public static final int STORE_STATUS_NOT_OPEN = 0;
+    /**
+     * 已开
+     */
+    public static final int STORE_STATUS_OPENED = 1;
+    /**
+     * 废弃
+     */
+    public static final int STORE_STATUS_ABANDONED = 2;
+
+    // ------业务类型------
+    /**
+     * 揽件
+     */
+    public static final int BUSINESS_TYPE_RECEIVED = 1;
+    /**
+     * 派件
+     */
+    public static final int BUSINESS_TYPE_DELIVERY = 2;
+
+    // ----派件订单信息完善类型类型----
+    /**
+     * 快递
+     */
+    public static final int ORDER_FILL_TYPE_EXPRESS = 1;
+    /**
+     * 门店
+     */
+    public static final int ORDER_FILL_TYPE_STORE = 2;
+    /**
+     * 菜鸟
+     */
+    public static final int ORDER_FILL_TYPE_CAI_NIAO = 3;
+    /**
+     * P2P Access
+     */
+    public static final int ORDER_FILL_TYPE_P2PA = 4;
+
+    // ----派件订单派送类型----
+    /**
+     * 自提
+     */
+    public static final String ORDER_SEND_TYPE_ZT = "ZI";
+    /**
+     * 配送
+     */
+    public static final String ORDER_SEND_TYPE_PS = "PS";
+    /**
+     * P2P
+     */
+    public static final String ORDER_SEND_TYPE_P2P = "P2P";
+
+    // ----派件订单状态----
+    /**
+     * 未到货
+     */
+    public static final int ORDER_STATUS_AFLOAT = 120;
+    /**
+     * 待入库
+     */
+    public static final int ORDER_STATUS_WAIT_IN_STORE = 245;
+    /**
+     * 已入库
+     */
+    public static final int ORDER_STATUS_STORED = 122;
+    /**
+     * 外出配送已分配
+     */
+    public static final int ORDER_STATUS_DISPATCHING = 124;
+    /**
+     * 麦客配送中
+     */
+    public static final int ORDER_STATUS_MAIKE_DISPATCHING = 125;
+    /**
+     * 已完成
+     */
+    public static final int ORDER_STATUS_COMPLETE = 126;
+    /**
+     * 离库
+     */
+    public static final int ORDER_STATUS_LEAVE_STORE = 246;
+    /**
+     * 拒收离库
+     */
+    public static final int ORDER_STATUS_REJECT_LEAVE_STORE = 130;
+    /**
+     * 拒收在库
+     */
+    public static final int ORDER_STATUS_REJECT_PICK_UP = 128;
+
+    /**
+     *   滞留状态
+     */
+    public static final int ORDER_STATUS_REJECT_RETENTION = 225;
+
+    // ----客户端类型----
+    /**
+     * 门店
+     */
+    public static final int CLIENT_TYPE_STORE = 1;
+    /**
+     * 巴枪
+     */
+    public static final int CLIENT_TYPE_BA_QIANG = 2;
+    /**
+     * App
+     */
+    public static final int CLIENT_TYPE_APP = 3;
+    /**
+     * BS
+     */
+    public static final int CLIENT_TYPE_BS = 4;
+    /**
+     * 门店精简版
+     */
+    public static final int CLIENT_TYPE_STORE_LITE = 5;
+    /**
+     * BS2.0
+     */
+    public static final int CLIENT_TYPE_BS_2 = 6;
+    /**
+     * 门店精简版2.0
+     */
+    public static final int CLIENT_TYPE_STORE_LITE_2 = 7;
+
+    // ----客户支付类型----
+    /**
+     * 在线支付
+     */
+    public static final int CUST_PAY_TYPE_ONLINE = 169;
+    /**
+     * 货到付款
+     */
+    public static final int CUST_PAY_TYPE_DELIVERY = 170;
+    /**
+     * 银行电汇
+     */
+    public static final int CUST_PAY_TYPE_BANK = 171;
+    /**
+     * 现金支付
+     */
+    public static final int CUST_PAY_TYPE_CASH = 212;
+    /**
+     * 支付宝支付
+     */
+    public static final int CUST_PAY_TYPE_ZFB = 213;
+    /**
+     * 微信支付
+     */
+    public static final int CUST_PAY_TYPE_WX = 214;
+
+    // ----支付类型----
+    /**
+     * 未支付
+     */
+    public static final int PAY_TYPE_NOT_PAY = 129;
+    /**
+     * 在线支付
+     */
+    public static final int PAY_TYPE_ONLINE = 130;
+    /**
+     * 现金支付
+     */
+    public static final int PAY_TYPE_CASH = 131;
+    /**
+     * POS刷卡支付
+     */
+    public static final int PAY_TYPE_POS = 132;
+
+    // ----快递类型----
+    /**
+     * 韵达
+     */
+    public static final int EXPRESS_TYPE_YD = 17;
+    /**
+     * 顺丰
+     */
+    public static final int EXPRESS_TYPE_SF = 18;
+    /**
+     * 联邦
+     */
+    public static final int EXPRESS_TYPE_FEDEX = 19;
+    /**
+     * 易讯
+     */
+    public static final int EXPRESS_TYPE_YX = 67;
+    /**
+     * 当当
+     */
+    public static final int EXPRESS_TYPE_DD = 186;
+    /**
+     * 中通
+     */
+    public static final int EXPRESS_TYPE_ZT = 187;
+    /**
+     * 圆通
+     */
+    public static final int EXPRESS_TYPE_YT = 202;
+    /**
+     * 蘑菇街
+     */
+    public static final int EXPRESS_TYPE_MGJ = 204;
+    /**
+     * 汇通
+     */
+    public static final int EXPRESS_TYPE_HTKY = 223;
+    /**
+     * 一米鲜
+     */
+    public static final int EXPRESS_TYPE_XIAN = 256;
+    /**
+     * 佰颂物联商城
+     */
+    public static final int EXPRESS_TYPE_RETA = 260;
+    /**
+     * 苏宁
+     */
+    public static final int EXPRESS_TYPE_SUNING = 203;
+    /**
+     * 如风达
+     */
+    public static final int EXPRESS_TYPE_RUFENGDA = 271;
+    /**
+     * 邮政特快专递
+     */
+    public static final int EXPRESS_TYPE_YOUZHENG_EMS = 243;
+    /**
+     * 邮政小包
+     */
+    public static final int EXPRESS_TYPE_YOUZHENG_PSP = 244;
+
+    // ----派件出库类型----
+    /**
+     * 自提出库
+     */
+    public static final int OUTSTORE_TYPE_SELF = 189;
+    /**
+     * 外出配送
+     */
+    public static final int OUTSTORE_TYPE_DISPATCH = 190;
+
+    // ----派件信息模板类型----
+    /**
+     * 短信
+     */
+    public static final int MSG_TYPE_SMS = 1;
+    /**
+     * 微信
+     */
+    public static final int MSG_TYPE_WEIXIN = 2;
+    /**
+     * app
+     */
+    public static final int MSG_TYPE_APP = 3;
+
+    /**
+     * 门店默认最早营业时间
+     */
+    public static final String STORE_DEFAULT_START_BUSINESS_TIME = "09:00";
+    /**
+     * 门店默认最晚营业时间
+     */
+    public static final String STORE_DEFAULT_END_BUSINESS_TIME = "19:00";
+
+    // ----派件业务代码----
+    /**
+     * 派件入库
+     */
+    public static final String BUSS_CODE_DELIVERY_IN_STORE = "DELIVERY_IN_STORE";
+    /**
+     * 派件外出配送
+     */
+    public static final String BUSS_CODE_DELIVERY_DISPATCHING = "DELIVERY_DISPATCHING";
+    /**
+     * 派件返库
+     */
+    public static final String BUSS_CODE_DELIVERY_RETURN = "DELIVERY_RETURN";
+    /**
+     * 派件取件完成
+     */
+    public static final String BUSS_CODE_DELIVERY_TAKE_COMPLETE = "DELIVERY_TAKE_COMPLETE";
+    /**
+     * 派件货架转移
+     */
+    public static final String BUSS_CODE_DELIVERY_SHELF_CHANGE = "DELIVERY_SHELF_CHANGE";
+    /**
+     * 派件滞留
+     */
+    public static final String BUSS_CODE_DELIVERY_DETAIN = "DELIVERY_DETAIN";
+
+    // ----未妥投原因----
+    /**
+     * 收方客户要求自取
+     */
+    public static final int REJECT_REASON_OUTRETRUN_1 = 1;
+    /**
+     * 电话关机|无法接通|不接
+     */
+    public static final int REJECT_REASON_OUTRETRUN_2 = 2;
+    /**
+     * 电话异常(停机|空号|暂停服务)
+     */
+    public static final int REJECT_REASON_OUTRETRUN_3 = 3;
+    /**
+     * 单标地址无人
+     */
+    public static final int REJECT_REASON_OUTRETRUN_4 = 4;
+    /**
+     * 客户要求更改派送时间
+     */
+    public static final int REJECT_REASON_OUTRETRUN_5 = 5;
+    /**
+     * 单标地址超范围
+     */
+    public static final int REJECT_REASON_OUTRETRUN_6 = 6;
+    /**
+     * 电话与联系人不符
+     */
+    public static final int REJECT_REASON_OUTRETRUN_7 = 7;
+    /**
+     * 包裹的件数未全部到齐,无法派送
+     */
+    public static final int REJECT_REASON_OUTRETRUN_8 = 8;
+    /**
+     * 其他原因(备注:需要手动输入原因)
+     */
+    public static final int REJECT_REASON_OUTRETRUN_9 = 99;
+
+    /**
+     * 客户拒收
+     */
+    public static final int REJECT_REASON_OUTREJECTION_1 = 10;
+    /**
+     * 包裹已破损
+     */
+    public static final int REJECT_REASON_OUTREJECTION_2 = 11;
+    /**
+     * 客户拒付运费
+     */
+    public static final int REJECT_REASON_OUTREJECTION_3 = 12;
+    /**
+     * 客户拒付代收货款
+     */
+    public static final int REJECT_REASON_OUTREJECTION_4 = 13;
+    
+    // ------短信发送方式
+    /**
+     * 自动发送
+     */
+    public static final int SMS_SEND_TYPE_AUTO = 1;
+    
+    /**
+     * 手动发送
+     */
+    public static final int SMS_SEND_TYPE_HAND = 2;
+
+    // ------短信发送状态------
+    /**
+     * 已发送
+     */
+    public static final int SMS_SEND_STATUS_SEND = 0;
+    /**
+     * 成功
+     */
+    public static final int SMS_SEND_STATUS_SUCCESS = 1;
+    /**
+     * 失败
+     */
+    public static final int SMS_SEND_STATUS_FAIL = 2;
+    /**
+     * 无结果
+     */
+    public static final int SMS_SEND_STATUS_UNKNOWN = 3;
+
+    // ------问题类型-------
+    /**
+     * 无问题
+     */
+    public static final int PROBLEM_TYPE_DEFUAL = 0;
+    /**
+     * 拒收
+     */
+    public static final int PROBLEM_TYPE_REFUSE = 1;
+    /**
+     * 问题件
+     */
+    public static final int PROBLEM_TYPE_PROBLEM = 2;
+    
+    // ------揽件类型------
+    /**
+     * 门店揽件
+     */
+    public static final int RECEIVED_TYPE_SELF = 147;
+    /**
+     * 外出揽件
+     */
+    public static final int RECEIVED_TYPE_OUT = 148;
+
+    // ------揽件包裹类型------
+    /**
+     * 国内件
+     */
+    public static final int RECEIVED_PACKAGE_TYPE_DOMESTIC = 1;
+    /**
+     * 国际件
+     */
+    public static final int RECEIVED_PACKAGE_TYPE_INTERNATIONAL = 2;
+    /**
+     * 电商退货
+     */
+    public static final int RECEIVED_PACKAGE_TYPE_RETURN_GOOD = 3;
+
+
+    // ------揽件状态------
+    /**
+     * 待揽件
+     */
+    public static final int RECEIVED_STATUS_WAIT_RECEIVE = 141;
+    /**
+     * 已取消
+     */
+    public static final int RECEIVED_STATUS_CANCELED = 142;
+    /**
+     * 未处理
+     */
+    public static final int RECEIVED_STATUS_NO_PRINT = 144;
+    /**
+     * 已处理
+     */
+    public static final int RECEIVED_STATUS_PRINTED = 145;
+    /**
+     * 已作废
+     */
+    public static final int RECEIVED_STATUS_INVALID = 146;
+
+    // ------揽件微信支付状态------
+    /**
+     * 未支付
+     */
+    public static final int RECEIVED_WECHAT_UNPAY = -1;
+    /**
+     * 支付失败
+     */
+    public static final int RECEIVED_WECHAT_PAYFAIL = 0;
+    /**
+     * 支付成功
+     */
+    public static final int RECEIVED_WECHAT_PAYSUCC = 1;
+
+    // ----第三方推送状态----
+    /**
+     * 待推送
+     */
+    public static final int THIRD_PROPELL_STATUS_1 = 141;
+    /**
+     * 推送中
+     */
+    public static final int THIRD_PROPELL_STATUS_2 = 142;
+    /**
+     * 推送失败
+     */
+    public static final int THIRD_PROPELL_STATUS_3 = 143;
+    /**
+     * 推送成功
+     */
+    public static final int THIRD_PROPELL_STATUS_4 = 144;
+
+    // ----揽件包装类型----
+    /**
+     * 一号箱
+     */
+    public static final int RECEIVED_PACK_TYPE_1_BOX = 149;
+    /**
+     * 二号箱
+     */
+    public static final int RECEIVED_PACK_TYPE_2_BOX = 150;
+    /**
+     * 三号箱
+     */
+    public static final int RECEIVED_PACK_TYPE_3_BOX = 151;
+    /**
+     * 四号箱
+     */
+    public static final int RECEIVED_PACK_TYPE_4_BOX = 152;
+    /**
+     * 五号箱
+     */
+    public static final int RECEIVED_PACK_TYPE_5_BOX = 153;
+    /**
+     * 六号箱
+     */
+    public static final int RECEIVED_PACK_TYPE_6_BOX = 154;
+    /**
+     * 信封
+     */
+    public static final int RECEIVED_PACK_TYPE_ENVELOPE = 166;
+    /**
+     * 防水袋
+     */
+    public static final int RECEIVED_PACK_TYPE_PACKAGE = 167;
+    /**
+     * 信封(联邦)
+     */
+    public static final int RECEIVED_PACK_TYPE_FEDEX_ENVELOPE = 155;
+    /**
+     * 自带包装(联邦)
+     */
+    public static final int RECEIVED_PACK_TYPE_FEDEX_YOUR_PACKAGE = 156;
+    /**
+     * 防水袋(联邦)
+     */
+    public static final int RECEIVED_PACK_TYPE_FEDEX_PACK_ENVELOPE = 185;
+    /**
+     * 汇通塑料袋
+     */
+    public static final int RECEIVED_PACK_TYPE_HTKYPLASTICBAG = 227;
+    /**
+     * 汇通文件袋
+     */
+    public static final int RECEIVED_PACK_TYPE_HTKYFOLDER = 228;
+    /**
+     * 汇通蛇皮袋
+     */
+    public static final int RECEIVED_PACK_TYPE_HTKYNYLONPOLYBAG = 239;
+    /**
+     * 圆通塑料袋
+     */
+    public static final int RECEIVED_PACK_TYPE_YTPLASTICBAG = 229;
+    /**
+     * 圆通文件袋
+     */
+    public static final int RECEIVED_PACK_TYPE_YTFOLDER = 230;
+    /**
+     * 圆通蛇皮袋
+     */
+    public static final int RECEIVED_PACK_TYPE_YTNYLONPOLYBAG = 240;
+    /**
+     * 中通塑料袋
+     */
+    public static final int RECEIVED_PACK_TYPE_ZTPLASTICBAG = 231;
+    /**
+     * 中通文件袋
+     */
+    public static final int RECEIVED_PACK_TYPE_ZTFOLDER = 232;
+    /**
+     * 中通蛇皮袋
+     */
+    public static final int RECEIVED_PACK_TYPE_ZTNYLONPOLYBAG = 241;
+
+    // ----揽件支付类型----
+    /**
+     * 寄方付
+     */
+    public static final int RECEIVED_PAY_TYPE_SENDER = 161;
+    /**
+     * 收方付
+     */
+    public static final int RECEIVED_PAY_TYPE_RECIPIENT = 162;
+    /**
+     * 第三方付
+     */
+    public static final int RECEIVED_PAY_TYPE_THIRD_PARTY = 163;
+    /**
+     * 寄方付月结
+     */
+    public static final int RECEIVED_PAY_TYPE_SENDER_SSTATEMENT = 164;
+    /**
+     * 汇通现金支付
+     */
+    public static final int RECEIVED_PAY_TYPE_HTKYCASH = 233;
+    /**
+     * 汇通到付
+     */
+    public static final int RECEIVED_PAY_TYPE_HTKYRECIPIENT = 234;
+    /**
+     * 圆通现金支付
+     */
+    public static final int RECEIVED_PAY_TYPE_YTCASH = 235;
+    /**
+     * 圆通到付
+     */
+    public static final int RECEIVED_PAY_TYPE_YTRECIPIENT = 236;
+    /**
+     * 中通现金支付
+     */
+    public static final int RECEIVED_PAY_TYPE_ZTCASH = 237;
+    /**
+     * 中通到付
+     */
+    public static final int RECEIVED_PAY_TYPE_ZTRECIPIENT = 238;
+    
+    public static final String EXPRESS_LOGO_URL = "http://7xngb1.com2.z0.glb.qiniucdn.com/express%.png";
+    
+    /**
+     * 短信服务,1表示“快鸽”
+     */
+    public static final int SMS_SERVICE_KUAIGE = 1;
+    /**
+     * 短信服务,2表示“大汉三通”
+     */
+    public static final int SMS_SERVICE_DAHAN = 2;
+    /**
+     * 短信服务,3表示“尚通科技”
+     */
+    public static final int SMS_SERVICE_SHANGTONG = 3;
+    /**
+     * 短信服务,4表示“云信”
+     */
+    public static final int SMS_SERVICE_YUNXIN = 4;
+    
+    /**
+     * 短信服务,5表示“流驿”
+     */
+    public static final int SMS_SERVICE_LIUYI = 5;
+    
+    /**
+     * 短信服务,6表示“奇点云”
+     */
+    public static final int SMS_SERVICE_QIDIAN = 6;
+
+    /**
+     * 短信服务,7表示“无锡”
+     */
+    public static final int SMS_SERVICE_WUXI = 7;
+
+    public static final int SMS_SERVICE_CMPP = 8;
+    
+    /**
+     * 淘宝订单无需完善手机号,数据库中写的默认手机号
+     */
+    public static final String DEFAULT_MOBILE_KB = "99999999999";
+    
+    /**
+     * SEND_SMS_OF_KB(快宝发送短信编码)
+     */
+    public static final String SEND_SMS_OF_KB = "SEND_SMS_OF_KB";
+    
+    /**
+     * SEND_SMS_OF_DH(大汉三通发送短信编码)
+     */
+    public static final String SEND_SMS_OF_DH = "SEND_SMS_OF_DH";
+    
+    // ----支付相关----
+    /**
+     * 支付参数:标题
+     */
+    public static final String PAY_PARAM_SUBJECT = "熊猫驿站-充值";
+    
+    /**
+     * 支付参数:商品描述
+     */
+    public static final String PAY_PARAM_BODY = "熊猫驿站-充值";
+    
+    /**
+	 * 支付宝订单状态
+	 */
+    public static final String ALIPAY_TRADE_WAIT_CREATE = "TRADE_WAIT_CREATE"; // 交易未创建
+	public static final String ALIPAY_WAIT_BUYER_PAY = "WAIT_BUYER_PAY"; // 交易创建
+	public static final String ALIPAY_TRADE_SUCCESS = "TRADE_SUCCESS"; // 支付成功
+    public static final String ALIPAY_TRADE_FINISHED = "TRADE_FINISHED"; // 交易成功
+    public static final String ALIPAY_TRADE_CLOSED = "TRADE_CLOSED"; // 交易关闭
+	public static final Map<String, Integer> ALIPAY_TRADE_STATUS_MAP = new HashMap<String, Integer>();
+    static {
+    	ALIPAY_TRADE_STATUS_MAP.put(ALIPAY_TRADE_WAIT_CREATE, 0);
+    	ALIPAY_TRADE_STATUS_MAP.put(ALIPAY_WAIT_BUYER_PAY, 1);
+    	ALIPAY_TRADE_STATUS_MAP.put(ALIPAY_TRADE_SUCCESS, 2);
+    	ALIPAY_TRADE_STATUS_MAP.put(ALIPAY_TRADE_FINISHED, 3);
+    	ALIPAY_TRADE_STATUS_MAP.put(ALIPAY_TRADE_CLOSED, 4);
+    }
+    /**
+	 * 支付宝订订单退款状态
+	 */
+    public static final String ALIPAY_TRADE_REFUND_SUCCESS = "REFUND_SUCCESS"; // 交易未创建
+    
+	/**
+	 * 消费短信的业务(10:自提入库)
+	 */
+	public static final int SMS_CONSUME_BUSINESS_INSTORE = 10;
+	/**
+	 * 消费短信的业务(10:直接入库)
+	 */
+	public static final int SMS_CONSUME_BUSINESS_DISPATCH = 20;
+
+	/**
+	 * 消费短信的业务(30:包裹转移)
+	 */
+	public static final int SMS_CONSUME_BUSINESS_PACKAGE = 30;
+
+	/**
+	 * 消费短信的业务(40:货架转移)
+	 */
+	public static final int SMS_CONSUME_BUSINESS_SHELF = 40;
+
+	/**
+	 * 消费短信的业务(50:滞留件催取)
+	 */
+	public static final int SMS_CONSUME_BUSINESS_REMIND = 50;
+
+	/**
+	 * 消费短信的业务(60:完善散单)
+	 */
+	public static final int SMS_CONSUME_BUSINESS_COMPLETE = 60;
+	/**
+	 * 消费短信的业务(70:重发入库信息)
+	 */
+	public static final int SMS_CONSUME_BUSINESS_RESEND_INSTORE = 70;
+	/**
+	 * 消费短信的业务(80:失败短信负消费)
+	 */
+	public static final int SMS_CONSUME_BUSINESS_FAIL_SMS =80;
+    /**
+     *   文件地址
+     */
+    public static final String  FASTDFS_CLIENT_SERVER = ResourceBundle.getBundle("fastdfs-client", Locale.CHINA).getString("fastdfs.tracker_http");
+    /**
+     * 订单代签
+     */
+    public static final int REPLACE_SIGN = 4;
+
+    /**
+     * 订单签收
+     */
+    public static final int SIGNING = 2;
+}

+ 29 - 0
express-main/src/main/java/cn/haliaeetus/constants/DBMonitorConfig.java

@@ -0,0 +1,29 @@
+package cn.haliaeetus.constants;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * @author sunjj
+ * @version 1.0.0
+ * @ClassName DBMonitorConfig.java
+ * @Description
+ * @createTime 2019年08月05日 13:48:00
+ */
+public class DBMonitorConfig {
+    private static final ResourceBundle MONITOR_BUNDLE = ResourceBundle.getBundle("dbmonitor", Locale.CHINA);
+
+    public static String getDeliverySaveUrl(){
+        return MONITOR_BUNDLE.getString("monitor.delivery.save");
+    }
+
+    public static String getDeliverySearchUrl(){
+        return MONITOR_BUNDLE.getString("monitor.delivery.search");
+    }
+
+    public static String getDeliveryUpdateUrl(){
+        return MONITOR_BUNDLE.getString("monitor.delivery.update");
+    }
+
+
+}

+ 20 - 0
express-main/src/main/java/cn/haliaeetus/constants/EmailConfig.java

@@ -0,0 +1,20 @@
+package cn.haliaeetus.constants;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Created by Administrator on 2019/2/22 0022.
+ */
+public class EmailConfig {
+    private static final ResourceBundle RESOURCE_MAIL = ResourceBundle.getBundle("email", Locale.CHINA);
+    public static String getEmailAccount() {
+        return RESOURCE_MAIL.getString("email.senderAccount");
+    }
+    public static String getEmailPassword() {
+        return RESOURCE_MAIL.getString("email.senderPassword");
+    }
+    public static String getEmailName() {
+        return RESOURCE_MAIL.getString("email.senderName");
+    }
+}

+ 38 - 0
express-main/src/main/java/cn/haliaeetus/constants/ExpressAccountConstants.java

@@ -0,0 +1,38 @@
+package cn.haliaeetus.constants;
+
+/**
+ * @author sunjj
+ * @version 1.0.0
+ * @ClassName ExpressAccountConstants.java
+ * @Description TODO
+ * @createTime 2019年11月28日 10:25:00
+ */
+public class ExpressAccountConstants {
+
+    /**
+     * 扣费节点 - 1:入库
+     */
+    public static final byte DEDUCTION_NODE_STORAGE = 1;
+
+    /**
+     * 扣费节点 - 2:出库
+     */
+    public static final byte DEDUCTION_NODE_COMPLETE = 2;
+
+    /**
+     * 消费记录类型 - 1:扣款
+     */
+    public static final int CONSUME_TYPE_DEDUCTION = 1;
+
+    /**
+     * 消费记录类型 - 2:退款
+     */
+    public static final int CONSUME_TYPE_REFUND = 2;
+
+    /**
+     * 消费记录类型 - 3:合并计算
+     */
+    public static final int CONSUME_TYPE_MERGE = 3;
+
+
+}

+ 194 - 0
express-main/src/main/java/cn/haliaeetus/constants/MapConstants.java

@@ -0,0 +1,194 @@
+package cn.haliaeetus.constants;
+
+import static cn.haliaeetus.constants.Constants.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MapConstants {
+    public static Map<String, Integer> receivedPackTypeFedexRevMap = new HashMap<>();
+    public static Map<String, Integer> receivedPackTypeRevMap = new HashMap<>();
+    public static Map<String, Integer> receivedPayTypeRevMap = new HashMap<>();
+    public static Map<String, String> LYSMSErrorCodeMsg = new HashMap<>();
+    public static Map<String, String> QDSMSErrorCodeMsg = new HashMap<>();
+    public static Map<String, String> WXSMSErrorCodeMsg = new HashMap<>();
+
+    static {
+        receivedPackTypeFedexRevMap.put("ENVELOPE", RECEIVED_PACK_TYPE_FEDEX_ENVELOPE);
+        receivedPackTypeFedexRevMap.put("YOUR_PACKAGE", RECEIVED_PACK_TYPE_FEDEX_YOUR_PACKAGE);
+        receivedPackTypeFedexRevMap.put("PACK_ENVELOPE", RECEIVED_PACK_TYPE_FEDEX_PACK_ENVELOPE);
+
+        receivedPackTypeRevMap.put("1_BOX", RECEIVED_PACK_TYPE_1_BOX);
+        receivedPackTypeRevMap.put("2_BOX", RECEIVED_PACK_TYPE_2_BOX);
+        receivedPackTypeRevMap.put("3_BOX", RECEIVED_PACK_TYPE_3_BOX);
+        receivedPackTypeRevMap.put("4_BOX", RECEIVED_PACK_TYPE_4_BOX);
+        receivedPackTypeRevMap.put("5_BOX", RECEIVED_PACK_TYPE_5_BOX);
+        receivedPackTypeRevMap.put("6_BOX", RECEIVED_PACK_TYPE_6_BOX);
+        receivedPackTypeRevMap.put("ENVELOPE", RECEIVED_PACK_TYPE_ENVELOPE);
+        receivedPackTypeRevMap.put("PACKAGE", RECEIVED_PACK_TYPE_PACKAGE);
+        receivedPackTypeRevMap.put("HTKYPLASTICBAG", RECEIVED_PACK_TYPE_HTKYPLASTICBAG);
+        receivedPackTypeRevMap.put("HTKYFOLDER", RECEIVED_PACK_TYPE_HTKYFOLDER);
+        receivedPackTypeRevMap.put("HTKYNYLONPOLYBAG", RECEIVED_PACK_TYPE_HTKYNYLONPOLYBAG);
+        receivedPackTypeRevMap.put("YTPLASTICBAG", RECEIVED_PACK_TYPE_YTPLASTICBAG);
+        receivedPackTypeRevMap.put("YTFOLDER", RECEIVED_PACK_TYPE_YTFOLDER);
+        receivedPackTypeRevMap.put("YTNYLONPOLYBAG", RECEIVED_PACK_TYPE_YTNYLONPOLYBAG);
+        receivedPackTypeRevMap.put("ZTPLASTICBAG", RECEIVED_PACK_TYPE_ZTPLASTICBAG);
+        receivedPackTypeRevMap.put("ZTFOLDER", RECEIVED_PACK_TYPE_ZTFOLDER);
+        receivedPackTypeRevMap.put("ZTNYLONPOLYBAG", RECEIVED_PACK_TYPE_ZTNYLONPOLYBAG);
+
+        receivedPayTypeRevMap.put("SENDER", RECEIVED_PAY_TYPE_SENDER);
+        receivedPayTypeRevMap.put("RECIPIENT", RECEIVED_PAY_TYPE_RECIPIENT);
+        receivedPayTypeRevMap.put("THIRD_PARTY", RECEIVED_PAY_TYPE_THIRD_PARTY);
+        receivedPayTypeRevMap.put("SENDER_SSTATEMENT", RECEIVED_PAY_TYPE_SENDER_SSTATEMENT);
+        receivedPayTypeRevMap.put("HTKYCASH", RECEIVED_PAY_TYPE_HTKYCASH);
+        receivedPayTypeRevMap.put("HTKYRECIPIENT", RECEIVED_PAY_TYPE_HTKYRECIPIENT);
+        receivedPayTypeRevMap.put("YTCASH", RECEIVED_PAY_TYPE_YTCASH);
+        receivedPayTypeRevMap.put("YTRECIPIENT", RECEIVED_PAY_TYPE_YTRECIPIENT);
+        receivedPayTypeRevMap.put("ZTCASH", RECEIVED_PAY_TYPE_ZTCASH);
+        receivedPayTypeRevMap.put("ZTRECIPIENT", RECEIVED_PAY_TYPE_ZTRECIPIENT);
+        
+        LYSMSErrorCodeMsg.put("9002","未知命令");
+        LYSMSErrorCodeMsg.put("9012","短信消息内容错误");
+        LYSMSErrorCodeMsg.put("9013","目标地址错误");
+        LYSMSErrorCodeMsg.put("9014","短信内容太长");
+        LYSMSErrorCodeMsg.put("9015","路由错误");
+        LYSMSErrorCodeMsg.put("9016","没有下发网关");
+        LYSMSErrorCodeMsg.put("9017","定时时间错误");
+        LYSMSErrorCodeMsg.put("9018","有效时间错误");
+        LYSMSErrorCodeMsg.put("9019","无法拆分或者拆分错误");
+        LYSMSErrorCodeMsg.put("9020","号码段错误");
+        LYSMSErrorCodeMsg.put("9021","消息编号错误,这个和PacketIndex参数有关");
+        LYSMSErrorCodeMsg.put("9022","用户不能发长短信(EsmClass错误)");
+        LYSMSErrorCodeMsg.put("9023","ProtocolID错误");
+        LYSMSErrorCodeMsg.put("9024","结构错误,一般是指长短信");
+        LYSMSErrorCodeMsg.put("9025","短信编码错误");
+        LYSMSErrorCodeMsg.put("9026","内容不是长短信");
+        LYSMSErrorCodeMsg.put("9027","签名不对");
+        LYSMSErrorCodeMsg.put("9028","目标网关不支持长短信");
+        LYSMSErrorCodeMsg.put("9029","路由拦截");
+        LYSMSErrorCodeMsg.put("9030","目标地址(手机号)太多");
+        LYSMSErrorCodeMsg.put("9031","目标地址(手机号)太少");
+        LYSMSErrorCodeMsg.put("9032","发送速度太快");
+        LYSMSErrorCodeMsg.put("9101","验证失败,一般和用户名/密码/IP地址相关");
+        LYSMSErrorCodeMsg.put("9102","没有填写用户名");
+        LYSMSErrorCodeMsg.put("9103","名字没找到");
+        LYSMSErrorCodeMsg.put("9104","IP地址不对");
+        LYSMSErrorCodeMsg.put("9105","超过最大连接数,就是tcp连接数,http也是一样的");
+        LYSMSErrorCodeMsg.put("9106","协议版本错误");
+        LYSMSErrorCodeMsg.put("9107","帐号无效,比如过期/禁用");
+        LYSMSErrorCodeMsg.put("9902","网关无此能力");
+        LYSMSErrorCodeMsg.put("9903","二进制数据太长了;如网关没有特别说明,一般不能超过140,");
+        LYSMSErrorCodeMsg.put("9904","网关不支持EsmClass字段,或等同字段");
+        LYSMSErrorCodeMsg.put("9905","网关不支持ProtocolID字段,或等同字段");
+        LYSMSErrorCodeMsg.put("9906","网关不支持UDHI字段,或等同字段");
+        LYSMSErrorCodeMsg.put("9907","网关支持Letter字段发送,但短信记录没有letter");
+        LYSMSErrorCodeMsg.put("9908","网关不存在");
+        LYSMSErrorCodeMsg.put("9909","网关没有应答");
+        LYSMSErrorCodeMsg.put("9910","网关不支持该短信编码");
+        LYSMSErrorCodeMsg.put("9911","区域错误");
+        LYSMSErrorCodeMsg.put("9401","计费错误");
+        LYSMSErrorCodeMsg.put("9402","非法内容");
+        LYSMSErrorCodeMsg.put("9403","黑名单");
+        LYSMSErrorCodeMsg.put("9405","Api帐号丢失");
+        LYSMSErrorCodeMsg.put("9406","配置拒绝,就是帐号设置了拒绝标记");
+        LYSMSErrorCodeMsg.put("9407","帐号没有生成时间,这个属于非法帐号");
+        LYSMSErrorCodeMsg.put("9408","消息超时,超过短信或帐号或系统设置的生存时间");
+        LYSMSErrorCodeMsg.put("9409","由约束规则拒绝");
+        LYSMSErrorCodeMsg.put("9410","状态报告超时");
+        LYSMSErrorCodeMsg.put("9412","帐号无效");
+        LYSMSErrorCodeMsg.put("9413","重发拦截");
+        LYSMSErrorCodeMsg.put("9414","转发时丢弃,比如该通道已经废弃");
+        LYSMSErrorCodeMsg.put("9415","人工审核失败");
+        LYSMSErrorCodeMsg.put("9416","可能是诈骗信息");
+        LYSMSErrorCodeMsg.put("9417","不匹配模板");
+        LYSMSErrorCodeMsg.put("9418","拒绝审核(审核功能可能关闭)");
+        LYSMSErrorCodeMsg.put("9419","超过该手机号码的日发送次数限制");
+        LYSMSErrorCodeMsg.put("9501","非法目标地址,即手机号");
+        LYSMSErrorCodeMsg.put("9502","消息无法投入队列");
+
+
+        
+        QDSMSErrorCodeMsg.put("9002","未知命令");
+        QDSMSErrorCodeMsg.put("9012","短信消息内容错误");
+        QDSMSErrorCodeMsg.put("9013","目标地址错误");
+        QDSMSErrorCodeMsg.put("9014","短信内容太长");
+        QDSMSErrorCodeMsg.put("9015","路由错误");
+        QDSMSErrorCodeMsg.put("9016","没有下发网关");
+        QDSMSErrorCodeMsg.put("9017","定时时间错误");
+        QDSMSErrorCodeMsg.put("9018","有效时间错误");
+        QDSMSErrorCodeMsg.put("9019","无法拆分或者拆分错误");
+        QDSMSErrorCodeMsg.put("9020","号码段错误");
+        QDSMSErrorCodeMsg.put("9021","消息编号错误,这个和PacketIndex参数有关");
+        QDSMSErrorCodeMsg.put("9022","用户不能发长短信(EsmClass错误)");
+        QDSMSErrorCodeMsg.put("9023","ProtocolID错误");
+        QDSMSErrorCodeMsg.put("9024","结构错误,一般是指长短信");
+        QDSMSErrorCodeMsg.put("9025","短信编码错误");
+        QDSMSErrorCodeMsg.put("9026","内容不是长短信");
+        QDSMSErrorCodeMsg.put("9027","签名不对");
+        QDSMSErrorCodeMsg.put("9028","目标网关不支持长短信");
+        QDSMSErrorCodeMsg.put("9029","路由拦截");
+        QDSMSErrorCodeMsg.put("9030","目标地址(手机号)太多");
+        QDSMSErrorCodeMsg.put("9031","目标地址(手机号)太少");
+        QDSMSErrorCodeMsg.put("9032","发送速度太快");
+        QDSMSErrorCodeMsg.put("9101","验证失败,一般和用户名/密码/IP地址相关");
+        QDSMSErrorCodeMsg.put("9102","没有填写用户名");
+        QDSMSErrorCodeMsg.put("9103","名字没找到");
+        QDSMSErrorCodeMsg.put("9104","IP地址不对");
+        QDSMSErrorCodeMsg.put("9105","超过最大连接数,就是tcp连接数,http也是一样的");
+        QDSMSErrorCodeMsg.put("9106","协议版本错误");
+        QDSMSErrorCodeMsg.put("9107","帐号无效,比如过期/禁用");
+        QDSMSErrorCodeMsg.put("9902","网关无此能力");
+        QDSMSErrorCodeMsg.put("9903","二进制数据太长了;如网关没有特别说明,一般不能超过140,");
+        QDSMSErrorCodeMsg.put("9904","网关不支持EsmClass字段,或等同字段");
+        QDSMSErrorCodeMsg.put("9905","网关不支持ProtocolID字段,或等同字段");
+        QDSMSErrorCodeMsg.put("9906","网关不支持UDHI字段,或等同字段");
+        QDSMSErrorCodeMsg.put("9907","网关支持Letter字段发送,但短信记录没有letter");
+        QDSMSErrorCodeMsg.put("9908","网关不存在");
+        QDSMSErrorCodeMsg.put("9909","网关没有应答");
+        QDSMSErrorCodeMsg.put("9910","网关不支持该短信编码");
+        QDSMSErrorCodeMsg.put("9911","区域错误");
+        QDSMSErrorCodeMsg.put("9401","计费错误");
+        QDSMSErrorCodeMsg.put("9402","非法内容");
+        QDSMSErrorCodeMsg.put("9403","黑名单");
+        QDSMSErrorCodeMsg.put("9405","Api帐号丢失");
+        QDSMSErrorCodeMsg.put("9406","配置拒绝,就是帐号设置了拒绝标记");
+        QDSMSErrorCodeMsg.put("9407","帐号没有生成时间,这个属于非法帐号");
+        QDSMSErrorCodeMsg.put("9408","消息超时,超过短信或帐号或系统设置的生存时间");
+        QDSMSErrorCodeMsg.put("9409","由约束规则拒绝");
+        QDSMSErrorCodeMsg.put("9410","状态报告超时");
+        QDSMSErrorCodeMsg.put("9412","帐号无效");
+        QDSMSErrorCodeMsg.put("9413","重发拦截");
+        QDSMSErrorCodeMsg.put("9414","转发时丢弃,比如该通道已经废弃");
+        QDSMSErrorCodeMsg.put("9415","人工审核失败");
+        QDSMSErrorCodeMsg.put("9416","可能是诈骗信息");
+        QDSMSErrorCodeMsg.put("9417","不匹配模板");
+        QDSMSErrorCodeMsg.put("9418","拒绝审核(审核功能可能关闭)");
+        QDSMSErrorCodeMsg.put("9419","超过该手机号码的日发送次数限制");
+        QDSMSErrorCodeMsg.put("9501","非法目标地址,即手机号");
+        QDSMSErrorCodeMsg.put("9502","消息无法投入队列");
+
+
+        WXSMSErrorCodeMsg.put("0","成功");
+        WXSMSErrorCodeMsg.put("1001","userId不能为空");
+        WXSMSErrorCodeMsg.put("1002","用户不合法");
+        WXSMSErrorCodeMsg.put("1003","ip不能为空");
+        WXSMSErrorCodeMsg.put("1004","ip校验失败");
+        WXSMSErrorCodeMsg.put("1005","md5password不能为空");
+        WXSMSErrorCodeMsg.put("1006","md5password错误");
+        WXSMSErrorCodeMsg.put("1007","action不能为空");
+        WXSMSErrorCodeMsg.put("1008","手机号码不能为空或者手机号码位数不正确");
+        WXSMSErrorCodeMsg.put("1009","扩展必须为数字");
+        WXSMSErrorCodeMsg.put("10010","自带msgid不是长整形或者超过长整型的表数范围");
+        WXSMSErrorCodeMsg.put("10011","内容为空");
+        WXSMSErrorCodeMsg.put("10012","内容含关键字");
+        WXSMSErrorCodeMsg.put("10013","内容超过最大长度670");
+        WXSMSErrorCodeMsg.put("10014","签名超长或为空,签名最长为16, 内容以【 开头");
+        WXSMSErrorCodeMsg.put("10015","action参数错误");
+        WXSMSErrorCodeMsg.put("10016","余额不足");
+        WXSMSErrorCodeMsg.put("10017","账号已禁用");
+        WXSMSErrorCodeMsg.put("10018","该用户此时间段禁止提交");
+        WXSMSErrorCodeMsg.put("10019","不允许主动获取和主动推送同时调用");
+        WXSMSErrorCodeMsg.put("10020","短信格式错误(JSON解析错误或手机号都不合法)");
+        WXSMSErrorCodeMsg.put("10021","短信打包超过500条");
+    }
+}

+ 176 - 0
express-main/src/main/java/cn/haliaeetus/constants/SMSConfig.java

@@ -0,0 +1,176 @@
+package cn.haliaeetus.constants;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * 短信配置工具类
+ * @author sqj
+ *
+ */
+public class SMSConfig {
+	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("sms", Locale.CHINA);
+	
+	public static String getBSSendSmsUrl(){
+		return RESOURCE_BUNDLE.getString("bs.delivery.smsConfig.sendSmsUrl");
+	}
+	
+	// 新版门店系统回写短信状态URL
+	public static String getLpDeliverySmsConfigRptStatusUrl(){
+		return RESOURCE_BUNDLE.getString("lp.delivery.smsConfig.rptStautUrl");
+	}
+	
+	// 麦客信系统回写短信状态URL
+	public static String getMkxDeliverySmsConfigRptStatusUrl(){
+		return RESOURCE_BUNDLE.getString("mkx.delivery.smsConfig.rptStautUrl");
+	}
+	
+	// 云信短信对接
+	public static String getYunXinSmsSendUrl() {
+		return RESOURCE_BUNDLE.getString("yunxin.sms.send.url");
+	}
+	public static String getYunXinSmsReportUrl() {
+		return RESOURCE_BUNDLE.getString("yunxin.sms.report.url");
+	}
+	public static String getYunXinSmsBalanceUrl() {
+		return RESOURCE_BUNDLE.getString("yunxin.sms.balance.url");
+	}
+	public static String getYunXinSmsUserCode() {
+		return RESOURCE_BUNDLE.getString("yunxin.sms.userCode");
+	}
+	public static String getYunXinSmsUserPass() {
+		return RESOURCE_BUNDLE.getString("yunxin.sms.userPass");
+	}
+	public static String getYunXinSmsStoreid() {
+		return RESOURCE_BUNDLE.getString("yunxin.sms.storeid");
+	}
+	
+	// 快鸽短信对接
+	public static String getKuaigeSmsSendUrl() {
+		return RESOURCE_BUNDLE.getString("kuaige.sms.send.url");
+	}
+	public static String getKuaigeSmsReportUrl() {
+		return RESOURCE_BUNDLE.getString("kuaige.sms.report.url");
+	}
+	public static String getKuaigeSmsUserid() {
+		return RESOURCE_BUNDLE.getString("kuaige.sms.userid");
+	}
+	public static String getKuaigeSmsAccount() {
+		return RESOURCE_BUNDLE.getString("kuaige.sms.account");
+	}
+	public static String getKuaigeSmsPassword() {
+		return RESOURCE_BUNDLE.getString("kuaige.sms.password");
+	}
+	public static String getKuaigeSmsStoreid() {
+		return RESOURCE_BUNDLE.getString("kuaige.sms.storeid");
+	}
+	
+	// 快宝短信对接
+	public static String getKuaibaoApiUrl() {
+		return RESOURCE_BUNDLE.getString("kuaibao.api.url");
+	}
+	public static String getKuaibaoApiAppId() {
+		return RESOURCE_BUNDLE.getString("kuaibao.api.app.id");
+	}
+	public static String getKuaibaoApiNameCheck() {
+		return RESOURCE_BUNDLE.getString("kuaibao.api.name.check");
+	}
+	public static String getKuaibaoApiNameSend() {
+		return RESOURCE_BUNDLE.getString("kuaibao.api.name.send");
+	}
+	public static String getKuaibaoApiAppKey() {
+		return RESOURCE_BUNDLE.getString("kuaibao.api.app.key");
+	}
+	
+	// 大汉三通短信对接
+	public static String getDahanSmsSendUrl() {
+		return RESOURCE_BUNDLE.getString("dahan.sms.send.url");
+	}
+	public static String getDahanSmsReportUrl() {
+		return RESOURCE_BUNDLE.getString("dahan.sms.report.url");
+	}
+	public static String getDahanSmsBalanceUrl() {
+		return RESOURCE_BUNDLE.getString("dahan.sms.balance.url");
+	}
+	public static String getDahanSmsAccount() {
+		return RESOURCE_BUNDLE.getString("dahan.sms.account");
+	}
+	public static String getDahanSmsPassword() {
+		return RESOURCE_BUNDLE.getString("dahan.sms.password");
+	}
+	public static String getDahanSmsSign() {
+		return RESOURCE_BUNDLE.getString("dahan.sms.sign");
+	}
+	public static String getDahanSmsSubcode() {
+		return RESOURCE_BUNDLE.getString("dahan.sms.subcode");
+	}
+	
+	//流驿短信平台
+	public static String getLiuyiSmsSendUrl(){
+		return RESOURCE_BUNDLE.getString("liuyi.sms.send.url");
+	}
+	
+	public static String getLiuyiSmsUserName(){
+		return RESOURCE_BUNDLE.getString("liuyi.sms.username");
+	}
+	
+	public static String getLiuyiSmsPassword(){
+		return RESOURCE_BUNDLE.getString("liuyi.sms.password");
+	}
+	
+	public static String getLiuyiSmsSign(){
+		return RESOURCE_BUNDLE.getString("liuyi.sms.sign");
+	}
+	
+	//奇点云短信平台
+	public static String getQiDianSmsSendUrl(){
+		return RESOURCE_BUNDLE.getString("qidian.sms.send.url");
+	}
+	
+	public static String getQiDianSmsPrivateKey(){
+		return RESOURCE_BUNDLE.getString("qidian.sms.privateKey");
+	}
+	
+	public static String getQiDianSmsServerKey(){
+		return RESOURCE_BUNDLE.getString("qidian.sms.serverKey");
+	}
+	
+	public static String getQiDianSmsSign(){
+		return RESOURCE_BUNDLE.getString("qidian.sms.sign");
+	}
+	public static String getQiDianTempCode(){
+		return RESOURCE_BUNDLE.getString("qidian.sms.tempCode");
+	}
+
+
+
+	//无锡短信平台
+	public static String getWuXiSmsSendUrl(){
+		return RESOURCE_BUNDLE.getString("wuxi.sms.send.url");
+	}
+
+	public static String getWuXiSmsUserName(){
+		return RESOURCE_BUNDLE.getString("wuxi.sms.username");
+	}
+
+	public static String getWuXiSmsPassword(){
+		return RESOURCE_BUNDLE.getString("wuxi.sms.password");
+	}
+
+	public static String getWuXiSmsSign(){
+		return RESOURCE_BUNDLE.getString("wuxi.sms.sign");
+	}
+
+
+	public static String getCmppSmsSendUrl(){
+		return RESOURCE_BUNDLE.getString("cmpp.sms.send.url");
+	}
+
+	public static String getCmppSmsUserName(){
+		return RESOURCE_BUNDLE.getString("cmpp.sms.username");
+	}
+
+	public static String getCmppSmsPassword(){
+		return RESOURCE_BUNDLE.getString("cmpp.sms.password");
+	}
+}

+ 273 - 0
express-main/src/main/java/cn/haliaeetus/controller/CacheController.java

@@ -0,0 +1,273 @@
+package cn.haliaeetus.controller;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import cn.haliaeetus.entity.Area;
+import cn.haliaeetus.entity.City;
+import cn.haliaeetus.entity.ExpressType;
+import cn.haliaeetus.entity.Province;
+import cn.haliaeetus.entity.Store;
+import cn.haliaeetus.entity.StoreShelf;
+import cn.haliaeetus.entity.TypeLibrary;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.base.log.Logger;
+import cn.haliaeetus.framework.toolkit.CacheTool;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.StoreShelfService;
+import cn.haliaeetus.service.TypeLibraryService;
+import cn.haliaeetus.service.UserService;
+
+/**
+ * 刷新memcached
+ * @author liutianyuan
+ *
+ */
+@Controller
+public class CacheController extends BaseController {
+	private static final String KEY = "1e8981c0-549f-11e7-af4e-d017c29416e3";
+	private static final Logger LOG = Logger.getInstance(CacheController.class);
+	
+	@Autowired
+	private UserService userSrvice;
+	
+	@Autowired 
+	private BasicInfoService basicInfoService;
+	
+	@Autowired
+	private TypeLibraryService typeLibraryService;
+	
+	@Autowired
+	private StoreShelfService storeShelfService;
+	
+	
+	/**
+	 * 外部系统修改门店信息后调用,刷新门店缓存
+	 */
+	@RequestMapping(value = "/sys/edit_store", method = {RequestMethod.GET, RequestMethod.POST})
+	@ResponseBody
+	public String editStoreDatacache(@RequestParam("key") String key, @RequestParam("storeId") int storeId) {
+		if(StringUtils.hasText(key) && KEY.equals(key)) { 
+			LOG.record("外部系统调用,刷新store缓存:" + storeId);
+			CacheTool cacheTool = CacheTool.initStore();
+			Map<Integer, Store> storeMap = basicInfoService.getAllStore();
+			if(storeMap != null && storeMap.containsKey(storeId)){
+				Store store = storeMap.get(storeId);
+				cacheTool.saveBean(storeId + "", store);
+				LOG.record("外部系统调用,刷新store缓存,调用成功:"  + storeId);
+				return "{code:\"0\",msg:\"成功\"}";
+			}
+			LOG.record("外部系统调用,刷新store缓存,调用失败:"  + storeId);
+			return "{code:\"-1\",msg:\"失败\"}";
+		}
+		LOG.record("外部系统调用,刷新store缓存,调用失败:"  + storeId);
+		return "{code:\"-1\",msg:\"失败\"}";
+	}
+	
+	
+	/**
+	 * 外部系统删除门店信息后调用,删除门店缓存
+	 */
+	@RequestMapping(value = "/sys/del_store", method = {RequestMethod.GET, RequestMethod.POST})
+	@ResponseBody
+	public String delStoreDatacache(@RequestParam("key") String key, @RequestParam("storeId") int storeId) {
+		if(StringUtils.hasText(key) && KEY.equals(key)) { 
+			LOG.record("外部系统调用,删除store缓存:" + storeId);
+			CacheTool cacheTool = CacheTool.initStore();
+			cacheTool.saveBean(storeId + "", null);
+			LOG.record("外部系统调用,删除store缓存,调用成功:"  + storeId);
+			return "{code:\"0\",msg:\"成功\"}";
+		}
+		LOG.record("外部系统调用,刷新store缓存,调用失败:"  + storeId);
+		return "{code:\"-1\",msg:\"失败\"}";
+	}
+	
+	/**
+	 * 初始化memcached
+	 * @param key
+	 * @return
+	 */
+	@RequestMapping(value = "/reload_datacache", method = {RequestMethod.GET, RequestMethod.POST})
+	@ResponseBody
+	public String reloadDatacache(@RequestParam("key") String key) {
+		if(StringUtils.hasText(key) && KEY.equals(key)) {
+			LOG.record("MC数据预热start");
+//			initStoreInfo();
+//			initExpressInfo();
+			initTypeLibrary();
+			initUser();
+			initStoreShelf();
+//			initProvinceCityArea();
+			LOG.record("MC数据预热完毕");
+			
+			return "{code:\"0\",msg:\"成功\"}";
+		}
+		return "{code:\"-1\",msg:\"失败\"}";
+		
+	}
+	
+	/**
+	 * user缓存
+	 * userId->User
+	 */
+	private void initUser(){
+		LOG.record("user数据预热start");
+		List<User> userList = userSrvice.getAllUser();
+		LOG.record("读取数据完毕,开始存入缓存");
+		CacheTool cacheTool = CacheTool.initUser();
+		for(User user : userList){
+			String userId = user.getUserId();
+			LOG.record(user.getUserId() + user.getUserName() );
+			
+			cacheTool.saveBean(userId, user);
+		}
+		LOG.record("user预热完毕,总数量:" + userList.size());
+
+	}
+	
+	/**
+	 * 门店缓存,过期时间1天
+	 * storeId->Store
+	 */
+	private void initStoreInfo(){
+		LOG.record("store数据预热start");
+		Map<Integer, Store> storeMap = basicInfoService.getAllStore();
+		List<Store> storeList = new ArrayList<Store>();
+		LOG.record("读取数据完毕,开始存入缓存");
+		CacheTool cacheTool = CacheTool.initStore();
+		for(Store store : storeMap.values()){
+			storeList.add(store);
+			int storeId = store.getId();
+			LOG.record(store.getId() + store.getName() + store.getDispatchIds() + ":" + store.getReceiveIds());
+			//过期时间1天
+//			cacheTool.saveBeanWithExpTime(storeId + "", store, 60*60*24);
+			cacheTool.saveBean(storeId + "", store);
+		}
+		cacheTool.saveBean("0", storeList);
+		LOG.record("store预热完毕,总数量:" + storeMap.size());
+
+	}
+	
+	/**
+	 * 快递缓存
+	 * expId->ExpressType
+	 * 0->Map<Integer, ExpressType>
+	 */
+	private void initExpressInfo(){
+		LOG.record("express数据预热start");
+		Map<Integer, ExpressType> expressMap = basicInfoService.getAllExpress();
+		LOG.record("读取数据完毕,开始存入缓存");
+		CacheTool cacheTool = CacheTool.initExpress();
+		for(ExpressType exp : expressMap.values()){
+			int expId = exp.getExpId();
+			LOG.record(exp.getExpId() + exp.getExpName() + exp.getExpShortName() + exp.getIsDel() + exp.getType());
+			
+			cacheTool.saveBean(expId + "", exp);
+		}
+		//缓存所有快递
+		cacheTool.saveBean(0 + "", expressMap);
+		LOG.record("express预热完毕,总数量:" + expressMap.size());
+
+	}
+	
+	/**
+	 * typeLibrary缓存
+	 * type->List<TypeLibrary>
+	 */
+	private void initTypeLibrary(){
+		LOG.record("TypeLibrary数据预热start");
+		Map<String, List<TypeLibrary>> typeLibraryMap = typeLibraryService.getAllTypeLibrary();
+		LOG.record("读取数据完毕,开始存入缓存");
+		CacheTool cacheTool = CacheTool.initTypeLibrary();
+		Iterator<Entry<String, List<TypeLibrary>>>  iter = typeLibraryMap.entrySet().iterator();
+		while(iter.hasNext()){
+			Map.Entry<String, List<TypeLibrary>> entry = iter.next();
+			String key = entry.getKey();
+			List<TypeLibrary> value = entry.getValue();
+			cacheTool.saveBean(key, value);
+		}
+		LOG.record("TypeLibrary预热完毕,总数量:" + typeLibraryMap.size());
+
+	}
+	
+	/**
+	 * 货架缓存
+	 * shelfId->StoreShelf
+	 * storeId->List<StoreShelf>
+	 */
+	private void initStoreShelf(){
+		LOG.record("货架数据预热start");
+		List<StoreShelf> shelfList = storeShelfService.getAll();
+		Map<Integer, List<StoreShelf>> storeShelfMap = new HashMap<Integer, List<StoreShelf>>();
+		LOG.record("读取数据完毕,开始存入缓存");
+		CacheTool cacheTool = CacheTool.initShelf();
+		for(StoreShelf shelf : shelfList){
+			//按shelfId缓存
+			cacheTool.saveBean(shelf.getId() + "", shelf);
+			int storeId = shelf.getStoreId();
+			if(storeShelfMap.containsKey(storeId)){
+				List<StoreShelf> storeShelfList = storeShelfMap.get(storeId);
+				if(storeShelfList != null){
+					storeShelfList.add(shelf);
+				}
+			}else{
+				List<StoreShelf> storeShelfList = new ArrayList<StoreShelf>();
+				storeShelfList.add(shelf);
+				storeShelfMap.put(storeId, storeShelfList);
+			}
+			
+		}
+		//按storeId缓存
+		cacheTool = CacheTool.initStoreShelf();
+		Iterator<Entry<Integer, List<StoreShelf>>> iter = storeShelfMap.entrySet().iterator();
+		while(iter.hasNext()){
+			Entry<Integer, List<StoreShelf>> entry = iter.next();
+			cacheTool.saveBean(entry.getKey() + "", entry.getValue());
+		}
+		
+		LOG.record("货架预热完毕,总数量:" + shelfList.size());
+	}
+	
+	/**
+	 * 省份缓存
+	 * shelfId->StoreShelf
+	 * storeId->List<StoreShelf>
+	 */
+	private void initProvinceCityArea(){
+		LOG.record("省份数据预热start");
+		List<Province> privinceList = basicInfoService.getProvinceRemoteService();
+		LOG.record("读取数据完毕,开始存入缓存");
+		CacheTool provinceCacheTool = CacheTool.initProvince();
+		provinceCacheTool.saveBean("0", privinceList);
+		LOG.record("省份数据预热完毕,总数量:" + privinceList.size());
+		
+		CacheTool cityCacheTool = CacheTool.initCity();
+		CacheTool areaCacheTool = CacheTool.initArea();
+		for (Province province: privinceList) {
+			LOG.record(province.getName() + "城市数据预热start");
+			List<City> cityList = basicInfoService.getCityRemoteService(province.getId());
+			cityCacheTool.saveBean(province.getId() + "", cityList);
+			LOG.record(province.getName() + "城市数据预热完毕,总数量:" + cityList.size());
+			
+			for (City city : cityList) {
+				LOG.record(city.getName() + "地区数据预热start");
+				List<Area> areaList = basicInfoService.getAreaRemoteService(city.getId());
+				areaCacheTool.saveBean(city.getId() + "", areaList);
+				LOG.record(city.getName() + "地区数据预热完毕,总数量:" + areaList.size());
+			}
+		}
+	}
+}

+ 65 - 0
express-main/src/main/java/cn/haliaeetus/controller/HomeController.java

@@ -0,0 +1,65 @@
+package cn.haliaeetus.controller;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONException;
+import com.alibaba.fastjson.JSONObject;
+
+import cn.haliaeetus.entity.DemoEntity;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.base.log.Logger;
+import cn.haliaeetus.service.DemoService;
+
+@Controller
+@RequestMapping("/demo")
+public class HomeController extends BaseController{
+	private static final Logger LOG = Logger.getInstance(HomeController.class);
+
+	@Autowired
+	private DemoService demoService;
+	
+	@RequestMapping(value = "/user/get", method = {RequestMethod.GET, RequestMethod.POST})
+	public @ResponseBody Object getUserInfo(@RequestParam("content") String content) {
+		LOG.record("demo接口调用,请求数据:" + content);
+		Map<String, Object> response = new HashMap<String, Object>();
+		try {
+			JSONObject user = JSON.parseObject(content);
+			
+			String userId = user.getString("userId");
+			
+			
+			DemoEntity entity = demoService.getById(userId);
+			
+			response.put("userName", entity.getUserName());
+			response.put("password", entity.getPassword());
+			LOG.record("demo接口调用成功," + response);
+		} catch (JSONException ex) {
+			LOG.record(ex.getMessage());
+		}
+		return response;
+	}
+	
+	  
+    @RequestMapping("/home/index")
+    public Object index(HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException {
+        
+        return new ModelAndView("demo", _.asMap("user", "man"));
+        
+    }
+}

+ 62 - 0
express-main/src/main/java/cn/haliaeetus/controller/SignReturnController.java

@@ -0,0 +1,62 @@
+package cn.haliaeetus.controller;
+
+import cn.haliaeetus.framework.util.OkHttpUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @ClassName SignReturnController
+ * @Description TODO
+ * @Author kael
+ * @Date 2019/9/12 0012 下午 13:38
+ * @Version 1.0
+ **/
+@RestController
+@Slf4j
+public class SignReturnController {
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    /**
+     * 签收回传查询
+     * @param deliveryFilter
+     * @return
+     */
+    @RequestMapping(value ="/v1/delivery/app/querySignReturn", method = {RequestMethod.POST})
+    @ResponseBody
+    public Object querySignReturn(@RequestBody String json) throws Exception {
+        log.info("kael-------------------------->:"+json);
+        String url=basicInfoService.getConfigurationByCode("gp-exp-server-url").getOValue1();
+        return OkHttpUtil.postJson(url+"/v1/delivery/app/querySignReturn",json);
+    }
+
+    /**
+     * 签收回传通过id
+     * @param deliveryFilter
+     * @return
+     */
+    @RequestMapping(value ="/v1/delivery/app/signReturn", method = {RequestMethod.POST})
+    @ResponseBody
+    public Object signReturnById(@RequestBody String json) throws Exception {
+        log.info("kael-------------------------->:"+json);
+        String url=basicInfoService.getConfigurationByCode("gp-exp-server-url").getOValue1();
+        return OkHttpUtil.postJson(url+"/v1/delivery/app/signReturn",json);
+    }
+
+    /**
+     * 获取签收回传状态
+     * @param filter
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value ="/v1/type/app/getType", method = {RequestMethod.POST})
+    @ResponseBody
+    public Object getType(@RequestBody String json) throws Exception {
+        log.info("kael-------------------------->:"+json);
+        String url=basicInfoService.getConfigurationByCode("gp-exp-server-url").getOValue1();
+        return OkHttpUtil.postJson(url+"/v1/type/app/getType",json);
+    }
+}

+ 296 - 0
express-main/src/main/java/cn/haliaeetus/controller/TestController.java

@@ -0,0 +1,296 @@
+package cn.haliaeetus.controller;
+
+import cn.haliaeetus.controller.baishi.BaishiServiceController;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.controller.yunda.YundaServiceController;
+import cn.haliaeetus.controller.zhongtong.ZhongtongServiceController;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.Store;
+import cn.haliaeetus.entity.UpdateBestLogisticsBean;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.OkHttpUtil;
+import cn.haliaeetus.jobs.DBUtil;
+import cn.haliaeetus.service.AccessLimitService;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.ExpsSignBackService;
+import cn.haliaeetus.service.impl.SMSSendRabbitPushServiceImpl;
+import cn.haliaeetus.util.Baishi.BaishiUpdStatusReqEntity;
+import cn.haliaeetus.util.Yunda.YundaReqEntity;
+import com.jfinal.weixin.sdk.utils.JsonUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Controller
+@RequestMapping("/test")
+public class TestController extends BaseController {
+
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private SMSSendRabbitPushServiceImpl smsSendRabbitPushService;
+
+    @RequestMapping("/ddddd")
+    public Object pdd(){
+        String time =String.valueOf(30000);
+        String smsSendQueues="hhhhhhhh";
+//        smsSendRabbitPushService.rabbitMQPush(time,smsSendQueues);
+        return buildJson(0,"请求成功");
+
+    }
+
+
+
+    @RequestMapping(value = "/changeSignStatus")
+    @ResponseBody
+    public String changeSignStatus(HttpServletRequest request) throws Exception {
+        User user = requireLogin(request);
+        String expCode=request.getParameter("expCode");
+        int comFlag=1;//1百世2韵达3中通
+        String result="";
+        if(comFlag==1){
+            BaishiUpdStatusReqEntity entity=new BaishiUpdStatusReqEntity();
+            result=BaishiServiceController.updBillStatus(entity);
+            //TODO 判断result成功失败,如果成功则更新deliver_${storeId}表中的签收标识字段(根据user和expCode查询到要更改的数据)
+        }else if(comFlag==2){
+            YundaReqEntity yundaReqEntity=new YundaReqEntity();
+            result=YundaServiceController.yundaReceiveInfo(yundaReqEntity);
+            //TODO 判断result成功失败,如果成功则更新deliver_${storeId}表中的签收标识字段(根据user和expCode查询到要更改的数据)
+        }else{
+            String data="";
+            result=ZhongtongServiceController.getTraceInfo(data);
+            //TODO 判断result成功失败,如果成功则更新deliver_${storeId}表中的签收标识字段(根据user和expCode查询到要更改的数据)
+        }
+        return "";
+    }
+
+    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    @Autowired
+    private AccessLimitService accessLimitService;
+
+    @RequestMapping("/accessLimit")
+    @ResponseBody
+    public String accessLimit(){
+        //尝试获取令牌
+        if(accessLimitService.tryAcquire()){
+            //模拟业务执行500毫秒
+            try {
+                Thread.sleep(500);
+            }catch (InterruptedException e){
+                e.printStackTrace();
+            }
+            return "aceess success [" + sdf.format(new Date()) + "]";
+        }else{
+            return "aceess limit [" + sdf.format(new Date()) + "]";
+        }
+    }
+
+    private ExpsSignBackService expsSignBackService;
+
+    @RequestMapping(value = "/delivery")
+    @ResponseBody
+    public Object delivery() throws Exception {
+        Integer[] storeList = new Integer[]{200108,
+                200111,
+                10013,
+                200168,
+                200041,
+                200082,
+                200183,
+                200188,
+                200040,
+                200039,
+                200189,
+                200063,
+                200191,
+                200193,
+                200195,
+                200197};
+        List<Delivery> deliverys = new ArrayList<>();
+        Map<String,String> map = new HashMap<>();
+        for (Integer storeId:storeList) {
+            DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+            String subSql = "and expid = '202' and status = '126' and returnSignStatus = '0' and createtime > '2019-08-14 09:00:00'";
+            qc.setSubSql(subSql);
+            deliverys = deliveryService.getDelivery(qc);
+            if (deliverys.isEmpty()) {
+                continue;
+            }
+            for (Delivery delivery : deliverys) {
+                try {
+                    expsSignBackService.signBack(delivery.getExpId(), delivery.getExpcode(), delivery.getUserPhone(), storeId, "out", (delivery.getShelfId() == null ? "" : delivery.getShelfId()) + "", delivery.getShelfCode());
+                }catch(Exception e){
+                    e.printStackTrace();
+                }
+            }
+        }
+        return map;
+    }
+
+    public String signBackBest(String expCode, String telPhone, Store store, int returnSignFlag){
+        String url=basicInfoService.getConfigurationByCode("baishiSignBackUrl").getOValue1();
+//                    Store store=basicInfoService.getStoreById(user.getStoreId());
+        UpdateBestLogisticsBean bestPram = new UpdateBestLogisticsBean();
+        bestPram.setBillCode(expCode);
+        bestPram.setOperator("BESTEXP");
+        bestPram.setTransactionCode(UUID.randomUUID().toString());//交易号,标记各状态消息所属的投递流程,全局唯一,建议使用UUID或(服务商编码+本地唯一串)
+        //1、同一单号在一次入库(S01)、出库(S02)、异常状态(S03\04)的推送时,交易号唯一相同;
+        //2、同一单号二次入库时,交易号可以进行变更
+        bestPram.setServiceProviderCode("fengzhan");//百世提供
+        bestPram.setServiceSiteCode(store.getId().toString());//客户自定义
+        bestPram.setStatus(returnSignFlag==3?"S01":"S02");
+        bestPram.setRemark("");
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date=new Date();
+        bestPram.setRequestTime(df.format(date));
+        try{
+            log.info("param................."+ JsonUtils.toJson(bestPram));
+            String res= OkHttpUtil.postJson(url,bestPram);
+            log.info("res..............................."+res);
+            if(res.indexOf("处理成功")>0){
+                DeliveryQueryCondition qc1 = new DeliveryQueryCondition(store.getId());
+                Delivery delivery=new Delivery();
+                delivery.setRemark("");
+                qc1.setEntity(delivery);
+                log.info("sssssssssssss");
+                qc1.setSignFlag(returnSignFlag+"");
+                qc1.setReturnSignStatus(returnSignFlag);
+                qc1.setUserPhone(telPhone.trim());
+                qc1.setExp_code(expCode);
+                boolean result = deliveryService.update(qc1);
+                log.info("sssssssssssss"+result);
+                return "true";
+            }else{
+                DeliveryQueryCondition qc1 = new DeliveryQueryCondition(store.getId());
+                Delivery delivery=new Delivery();
+                delivery.setRemark(res.substring(res.length()-20,res.length()-2));
+                qc1.setEntity(delivery);
+                log.info("sssssssssssss");
+                qc1.setSignFlag((returnSignFlag+1)+"");
+                qc1.setReturnSignStatus(returnSignFlag+1);
+                qc1.setUserPhone(telPhone.trim());
+                qc1.setExp_code(expCode);
+                boolean result = deliveryService.update(qc1);
+                log.info("sssssssssssss"+result);
+                return "res.substring(res.length()-20,res.length()-2)";
+            }
+        }catch (Exception e){
+            log.error(e.getMessage());
+            DeliveryQueryCondition qc1 = new DeliveryQueryCondition(store.getId());
+            Delivery delivery=new Delivery();
+            delivery.setRemark(e.getMessage()==null?"NULL":e.getMessage().substring(0,30));
+            qc1.setEntity(delivery);
+            qc1.setSignFlag((returnSignFlag+1)+"");
+            qc1.setReturnSignStatus(returnSignFlag+1);
+            qc1.setUserPhone(telPhone.trim());
+            qc1.setExp_code(expCode);
+            boolean result = deliveryService.update(qc1);
+            log.info("sssssssssssss"+result);
+            return e.getMessage()==null?"NULL":e.getMessage().substring(0,30);
+        }
+    }
+
+    public List<Store> getRemoteStoreList(int storeId){
+        List<Store> storeList=new ArrayList<>();
+        try{
+            Connection connection = null;
+            PreparedStatement pstm = null;
+            try{
+                Class.forName("com.mysql.jdbc.Driver");
+                connection = DBUtil.getJeesiteConnection();
+                connection.setAutoCommit(false);
+                String sql = "select a.id,a.name ,a.short_name,a.owner,a.phone,a.take_express_phone,a.province_id,a.province_name,a.city_id,a.city_name," +
+                        "a.area_id,a.area_name,a.college_id,a.college_name,a.address,a.short_address," +
+                        "a.start_time,a.end_time,a.receive_ids,a.dispatch_ids ,a.isp2p,a.operate_type,a.status," +
+                        "a.isprinter,a.longitude,a.latitude,a.appid,a.appsecret,a.msgtempid,a.signtempid,a.domain,a.opendoor,sendexpress,a.advertisingUrl,a.advertisingMsg,a.yjmsgtempid,a.auditStatus, a.isOpenSignBack, a.expId_address, a.backup_phone, a.township_id, a.township FROM ex_store a ";
+                pstm = connection.prepareStatement(sql);
+                ResultSet rs=pstm.executeQuery();
+                while(rs.next()){
+                    Store store=new Store();
+                    store.setId(rs.getInt(1));
+                    store.setName(rs.getString(2));
+                    store.setShortName(rs.getString(3));
+                    store.setOwner(rs.getString(4));
+                    store.setPhone(rs.getString(5));
+                    store.setTakeExpressPhone(rs.getString(6));
+                    store.setProvinceId(rs.getInt(7));
+                    store.setProvinceName(rs.getString(8));
+                    store.setCityId(rs.getLong(9));
+                    store.setCityName(rs.getString(10));
+                    store.setAreaId(rs.getLong(11));
+                    store.setAreaName(rs.getString(12));
+                    store.setCollegeId(rs.getInt(13));
+                    store.setCollegeName(rs.getString(14));
+                    store.setAddress(rs.getString(15));
+                    store.setShortAddress(rs.getString(16));
+                    store.setStartTime(rs.getString(17));
+                    store.setEndTime(rs.getString(18));
+                    store.setReceiveIds(rs.getString(19));
+                    store.setDispatchIds(rs.getString(20));
+                    store.setIsP2p(rs.getInt(21));
+                    store.setOperate_type(rs.getInt(22));
+                    store.setStatus(rs.getInt(23));
+                    store.setIsPrinter(rs.getString(24));
+                    store.setLongitude(rs.getString(25));
+                    store.setLatitude(rs.getString(26));
+                    store.setAppid(rs.getString(27));
+                    store.setAppsecret(rs.getString(28));
+                    store.setMsgtempid(rs.getString(29));
+                    store.setSigntempid(rs.getString(30));
+                    store.setDomain(rs.getString(31));
+                    store.setOpendoor(rs.getString(32));
+                    store.setSendexpress(rs.getString(33));
+                    store.setAdvertisingUrl(rs.getString(34));
+                    store.setAdvertisingMsg(rs.getString(35));
+                    store.setYjmsgtempid(rs.getString(36));
+                    store.setAuditStatus(rs.getInt(37));
+                    store.setIsOpenSignBack(rs.getBoolean(38));
+                    store.setExpIdAddress(rs.getString(39));
+                    store.setBackupPhone(rs.getString(40));
+                    store.setTownshipId(rs.getLong(41));
+                    store.setTownship(rs.getString(42));
+                    storeList.add(store);
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+                throw new RuntimeException(e);
+            }finally {
+                if (pstm != null) {
+                    try {
+                        pstm.close();
+                    } catch (SQLException e) {
+                        e.printStackTrace();
+                        throw new RuntimeException(e);
+                    }
+                }
+                if (connection != null) {
+                    try {
+                        connection.close();
+                    } catch (SQLException e) {
+                        e.printStackTrace();
+                        throw new RuntimeException(e);
+                    }
+                }
+            }
+        }catch (Exception e){
+            e.getStackTrace();
+        }
+        return storeList;
+    }
+}

+ 103 - 0
express-main/src/main/java/cn/haliaeetus/controller/alipay/AlipayNotifyController.java

@@ -0,0 +1,103 @@
+package cn.haliaeetus.controller.alipay;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import cn.haliaeetus.constants.AlipayConfig;
+import cn.haliaeetus.entity.PaymentLog;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.alipay.util.AlipayNotify;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.PaymentLogService;
+
+@Controller
+public class AlipayNotifyController extends BaseController {
+	
+	private static final Logger LOG = LoggerFactory.getLogger(AlipayNotifyController.class);
+	
+	@Autowired
+	private PaymentLogService paymentLogService;
+
+	/**
+	 * 支付宝交易异步通知
+	 */
+	@RequestMapping(value = "/services/notify/alipayNotify.action", method = { RequestMethod.POST})
+	@ResponseBody
+	public String alipayNotify(HttpServletRequest request) {
+		
+		if (AlipayNotify.verify(getParams(request))) {
+			// 商户订单号
+			String	outTradeNo = request.getParameter("out_trade_no");
+			// 支付宝交易号
+			String tradeNo = request.getParameter("trade_no");
+			// 订单金额
+			String totalFee = request.getParameter("total_fee");
+			// 交易状态
+			String tradeStatus = request.getParameter("trade_status");
+			// 卖家支付宝账号
+			String sellerEmail = request.getParameter("seller_email");
+			// 卖家支付宝账号
+			String sellerId = request.getParameter("seller_id");
+			// 退款状态
+			String refundStatus = request.getParameter("refund_status");
+			
+			PaymentLog paymentLog = paymentLogService.getByOutTradeNo(outTradeNo);
+			boolean isValid = true;
+			if (paymentLog == null) {
+				LOG.info(_.f("%s is not lpmd trade no.", outTradeNo));
+				isValid = false;
+			} else {
+				if (paymentLog.getTotalAmount().compareTo(new BigDecimal(totalFee)) != 0) {
+					LOG.info(_.f("invalid total_fee, out_trad_no: [%s], total_fee: [%s].", outTradeNo, totalFee));
+					isValid = false;
+				}
+			}
+			if (!AlipayConfig.getAlipaySellerId().equals(sellerEmail)) {
+				LOG.info(_.f("invalid seller_email, out_trad_no: [%s], seller_email: [%s].", outTradeNo, sellerEmail));
+				isValid = false;
+			}
+			
+			if (!AlipayConfig.getAlipayPartner().equals(sellerId)) {
+				LOG.info(_.f("invalid seller_id, out_trad_no: [%s], seller_id: [%s].", outTradeNo, sellerId));
+				isValid = false;
+			}
+			
+			if (isValid) {
+				paymentLogService.savePaymentResult(paymentLog, tradeStatus, refundStatus, tradeNo);
+			}
+		} else {
+			LOG.info("alipay verify fail.");
+		}
+		return "success";
+	}
+	
+	private Map<String, String> getParams(HttpServletRequest request) {
+		Map<String, String> params = new HashMap<String, String>();
+		Map<String, String[]> requestParams = request.getParameterMap();
+		for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext();) {
+			String name = (String) iter.next();
+			String[] values = (String[]) requestParams.get(name);
+			String valueStr = "";
+			for (int i = 0; i < values.length; i++) {
+				valueStr = (i == values.length - 1) ? valueStr + values[i]
+						: valueStr + values[i] + ",";
+			}
+			// 乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
+			// valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
+			params.put(name, valueStr);
+		}
+		return params;
+	}
+}

+ 78 - 0
express-main/src/main/java/cn/haliaeetus/controller/app2/AppGetContactNumberAction.java

@@ -0,0 +1,78 @@
+package cn.haliaeetus.controller.app2;
+
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.enums.SMSErrorCodeEnum;
+import cn.haliaeetus.controller.web.enums.StatusCodeEnum;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.dao.UserDao;
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.entity.dto.DeliveryDto;
+import cn.haliaeetus.entity.dto.QueryPageDto;
+import cn.haliaeetus.entity.jspo.JDeliveryDto;
+import cn.haliaeetus.entity.jspo.JsonMsg;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.toolkit.PagedList;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.framework.util.HttpUtil;
+import cn.haliaeetus.service.*;
+import cn.haliaeetus.service.rsync.ConsumeRecordService;
+import com.google.gson.JsonObject;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static cn.haliaeetus.framework._.*;
+
+/**   查询 发送短信
+ * Created by Administrator on 2018/12/12 0012.
+ *  APP首页查询类
+ */
+@Controller
+public class AppGetContactNumberAction extends BaseController{
+    @Autowired
+    private ExStoreService exStoreService;
+
+
+
+
+    @RequestMapping(value = {"/app/api/v2/getContactNumber"})
+    @ResponseBody
+    public Object getContactNumber(HttpServletRequest request, HttpServletResponse response, @RequestBody StoreContactNumber storeContactNumber){
+
+        List<StoreContactNumberInformation> storeContactNumberInformations=new ArrayList<>();
+        Integer storeId = storeContactNumber.getStoreId();
+        String createTime = storeContactNumber.getCreateTime();
+        String phoneLogo = storeContactNumber.getPhoneLogo();
+        List<ContactNumber> contactNumberList = storeContactNumber.getContactNumberList();
+        for (ContactNumber contactNumber : contactNumberList) {
+            StoreContactNumberInformation storeContactNumberInformation=new StoreContactNumberInformation();
+            storeContactNumberInformation.setStoreId(storeId);
+            storeContactNumberInformation.setCreateTime(createTime);
+            storeContactNumberInformation.setPhoneLogo(phoneLogo);
+            storeContactNumberInformation.setContactName(contactNumber.getContactName());
+            storeContactNumberInformation.setContactPhone(contactNumber.getContactPhone());
+            storeContactNumberInformations.add(storeContactNumberInformation);
+        }
+        try {
+            exStoreService.insertContactNumber(storeContactNumberInformations);
+        }catch (Exception e){
+            log.info("获取地理位置失败原因:"+e.getMessage());
+        }
+        return buildJson(0,"请求成功!");
+    }
+
+}

+ 48 - 0
express-main/src/main/java/cn/haliaeetus/controller/app2/AppGetPositionAction.java

@@ -0,0 +1,48 @@
+package cn.haliaeetus.controller.app2;
+
+
+import cn.haliaeetus.dao.UserDao;
+import cn.haliaeetus.dao.store.IExStoreDao;
+import cn.haliaeetus.entity.AppGetPositionBean;
+import cn.haliaeetus.entity.ExpressType;
+import cn.haliaeetus.entity.StoreContactNumber;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.*;
+import cn.haliaeetus.service.rsync.ConsumeRecordService;
+import com.google.gson.JsonObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**   查询 发送短信
+ * Created by Administrator on 2018/12/12 0012.
+ *  APP首页查询类
+ */
+@Controller
+public class AppGetPositionAction extends BaseController{
+    @Autowired
+    private IExStoreDao iExStoreDao;
+
+    @RequestMapping(value = {"/app/api/v2/getPhonePosition"})
+    @ResponseBody
+    public Object getContactNumber(HttpServletRequest request, HttpServletResponse response,
+                                   @RequestBody AppGetPositionBean appGetPositionBean){
+
+        try {
+            Integer integer = iExStoreDao.insertPhonePosition(appGetPositionBean);
+        }catch (Exception e){
+            log.info("获取地理位置失败原因:"+e.getMessage());
+        }
+        return buildJson(0,"请求成功!");
+    }
+
+}

+ 119 - 0
express-main/src/main/java/cn/haliaeetus/controller/app2/AppPhoneFromExpAction.java

@@ -0,0 +1,119 @@
+package cn.haliaeetus.controller.app2;
+
+
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.sms.entity.kuaibao.ExpressConvertEnum;
+import cn.haliaeetus.framework.util.OkHttpUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.ExStoreService;
+import cn.haliaeetus.util.pdd.OrderQueryInfo;
+import cn.haliaeetus.util.pdd.OrderQueryResponse;
+import cn.haliaeetus.util.pdd.PddGetSysParam;
+import cn.haliaeetus.util.pdd.enums.PddExpressEnum;
+import com.alibaba.fastjson.JSON;
+import com.google.common.base.Strings;
+import com.google.gson.Gson;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+
+/**   查询 发送短信
+ * Created by Administrator on 2018/12/12 0012.
+ *  APP首页查询类
+ */
+@Controller
+public class AppPhoneFromExpAction extends BaseController{
+    @Autowired
+    private ExStoreService exStoreService;
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @RequestMapping(value = {"/app/api/v2/getPhoneFromExp"})
+    @ResponseBody
+    public Object getPhoneFromExp(HttpServletRequest request, HttpServletResponse response, @RequestBody GetPhoneFromExpBean getPhoneFromExpBean){
+        try {
+            PddGetSysParam pddGetSysParam = new PddGetSysParam().invoke(basicInfoService);
+            //如果拼多多的系统参数存在为空的则直接调用快递公司手机号查询
+            log.info("查询手机号是否查看pdd:"+!pddGetSysParam.isFale());
+            if(pddGetSysParam.isFale()){
+                return expressGetPhone(getPhoneFromExpBean);
+            }
+            String res = postPddQueryPhone(getPhoneFromExpBean, pddGetSysParam.getUrl(), pddGetSysParam.getPddUrl(), pddGetSysParam.getPartnerId(), pddGetSysParam.getSecret());
+            log.info("kael-------拼多多通过手机号码查询订单返回参数:"+res);
+            if(!Strings.isNullOrEmpty(res)){
+                OrderQueryResponse orderQueryResponse = new Gson().fromJson(res,OrderQueryResponse.class);
+                if(orderQueryResponse.isSuccess()&&orderQueryResponse.getResult().compareTo(1)==0){
+                    return new Gson().toJson(PhoneFromExpResponse.builder()
+                            .refunt(true).build().invoke(orderQueryResponse.getPhoneNum(),"PDD"));
+                }else{
+                    return expressGetPhone(getPhoneFromExpBean);
+                }
+            }else{
+                return expressGetPhone(getPhoneFromExpBean);
+            }
+        }catch (Exception e){
+            log.info(e.getMessage());
+        }
+        return new Gson().toJson(PhoneFromExpResponse.builder()
+                .refunt(false).build().invoke("获取失败!",""));
+    }
+
+    /**
+     * 拼多多通过手机号码查询订单接口
+     * @param getPhoneFromExpBean
+     * @param url
+     * @param pddUrl
+     * @param partnerId
+     * @param secret
+     * @return
+     * @throws Exception
+     */
+    private String postPddQueryPhone(@RequestBody GetPhoneFromExpBean getPhoneFromExpBean, String url, String pddUrl, String partnerId, String secret) throws Exception {
+        OrderQueryInfo orderQueryInfo = OrderQueryInfo.builder()
+                .companyCode(partnerId)
+                .cabCode(getPhoneFromExpBean.getStoreId())
+                .expressCode(PddExpressEnum.of(getPhoneFromExpBean.getExpId()).getBrand())
+                .mailNo(getPhoneFromExpBean.getExpCode())
+                .siteType(2)
+                .build();
+        orderQueryInfo.setApiName(pddUrl+"/express/order/"+partnerId+"/query");
+        orderQueryInfo.setPartner_id(partnerId);
+        orderQueryInfo.setSecret(secret);
+        log.info("kael-------拼多多通过手机号码查询订单传入参数:"+new Gson().toJson(orderQueryInfo));
+        return OkHttpUtil.postJson(url+"/pddPhoneQuery", orderQueryInfo);
+    }
+
+    private String expressGetPhone(@RequestBody GetPhoneFromExpBean getPhoneFromExpBean) throws Exception {
+        switch(getPhoneFromExpBean.getExpId()) {
+            case 272:
+                return shentongGetPhone(getPhoneFromExpBean.getExpCode());
+            default:
+                break;
+        }
+        return new Gson().toJson(PhoneFromExpResponse.builder()
+                .refunt(false).build().invoke("获取失败!",""));
+    }
+
+    public String shentongGetPhone(String expCode) throws Exception{
+        String url=basicInfoService.getConfigurationByCode("shentongGetPhoneUrl").getOValue1();
+//        String url="http://localhost:8089/logistics/shentongGetPhone";
+        StGetPhoneParam stGetPhoneParam = new StGetPhoneParam();
+        stGetPhoneParam.setAppid(basicInfoService.getConfigurationByCode("shentongGetPhoneAppId").getOValue1());
+        stGetPhoneParam.setKey(basicInfoService.getConfigurationByCode("shentongGetPhoneKey").getOValue1());
+        stGetPhoneParam.setWaybillNo(expCode);
+        stGetPhoneParam.setTimestamp(System.currentTimeMillis()+"");
+        stGetPhoneParam.setNonce(UUID.randomUUID().toString());
+        String res = OkHttpUtil.postJson(url, stGetPhoneParam);
+        Map map = JSON.parseObject(res,HashMap.class);
+        return new Gson().toJson(PhoneFromExpResponse.builder()
+                .refunt(true).build().invoke(map.get("consigneePhone").toString(),""));
+    }
+
+}

+ 39 - 0
express-main/src/main/java/cn/haliaeetus/controller/app2/AppSendBackController.java

@@ -0,0 +1,39 @@
+package cn.haliaeetus.controller.app2;
+
+import cn.haliaeetus.entity.SendBackReason;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.SendBackReasonService;
+import com.alibaba.fastjson.JSON;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+/**
+ * 退件原因相关
+ */
+@Controller
+public class AppSendBackController extends BaseController {
+
+    @Autowired
+    private SendBackReasonService sendBackReasonService;
+
+
+    /**
+     * 获取退件原因列表
+     *
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = {"/app/api/v2/getSendBackReason"}, method = RequestMethod.POST)
+    @ResponseBody
+    public Object getSendBackReason(HttpServletRequest request) {
+        List<SendBackReason> list = sendBackReasonService.getForDIC();
+        // 去除值为null的数据
+        return buildJson(0, "请求成功!", JSON.parseArray(JSON.toJSONString(list)));
+    }
+}

+ 60 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppContentController.java

@@ -0,0 +1,60 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.entity.dto.ContentDto;
+import cn.haliaeetus.entity.jspo.JCountDto;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.toolkit.redis.JedisClient;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.service.ContentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.sql.Timestamp;
+import java.util.Date;
+
+/** 用户反馈类
+ * Created by Administrator on 2019/1/14 0014.
+ */
+@Controller
+public class AppContentController extends BaseController {
+    @Autowired
+    private ContentService contentService;
+    @RequestMapping(value = "/app/userContent")
+    @ResponseBody
+    public Object saveContentOne(HttpServletRequest request, @RequestParam(defaultValue = "")String conment){
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1,"用户未登录");
+        }
+        if(_.isEmpty(conment)){
+            return buildJson(-1,"内容不能为空");
+        }
+        if(conment.length() > 150){
+            return buildJson(-1,"输入内容限制150字以内");
+        }
+        //查询当日提交的次数
+        Date date = new Date();
+        String beginTime = DateUtil.today().toString("yyyy-MM-dd").trim() + " 00:00:00";
+        long count = contentService.getContentCount(user.getStoreId(), Timestamp.valueOf(beginTime),date);
+        if(count > 10){
+            return buildJson(-1,"短时间操作次数太多");
+        }
+        ContentDto contentDto = new ContentDto();
+        contentDto.setUserId(user.getUserId());
+        contentDto.setStoreId(user.getStoreId());
+        contentDto.setUserName(user.getUserName());
+        contentDto.setCreateTime(date);
+        contentDto.setContent(conment);
+        long result = contentService.saveContent(contentDto);
+        if(result > 0){
+            return buildJson(0,"保存成功");
+        }
+        return buildJson(-1,"保存失败");
+    }
+}

+ 173 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppDeliveryScanBatchTwoController.java

@@ -0,0 +1,173 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.entity.BarCode;
+import cn.haliaeetus.entity.OperationData;
+import cn.haliaeetus.entity.OperationDataDetail;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.service.XiaoBaiService;
+import cn.haliaeetus.util.DesEncryptDecryptUtil;
+import cn.haliaeetus.util.RSAEncryptUtil;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Created by Administrator on 2019/1/10 0010.
+ */
+@Controller
+public class AppDeliveryScanBatchTwoController extends BaseController{
+  @Autowired
+    private XiaoBaiService xiaoBaiService;
+
+    //保存共配
+    @RequestMapping(value = "/app/saveDeliveryScanBatch")
+    @ResponseBody
+    public Object saveDeliveryScanBatch(@RequestParam(defaultValue = "") String data,@RequestParam(defaultValue = "")String publicKey)throws Exception{
+        if(null == data || "".equals(data) || null == publicKey || "".equals(publicKey)){
+            return buildJson(-1, "参数错误");
+        }
+        JsonNode jsonNode = JsonUtil.parse(RSAEncryptUtil.decrypt(data,publicKey));
+        if (jsonNode == null) {
+          return buildJson(-1, "参数错误");
+        }
+        OperationData operationData = new OperationData();
+        JsonNode usercodeNode = jsonNode.findValue("usercode");
+        if(usercodeNode != null){
+            operationData.setUsercode(usercodeNode.asText());
+        }
+        JsonNode totalNode = jsonNode.findValue("total");
+        if(totalNode != null){
+            operationData.setTotal(totalNode.asInt());
+        }
+       JsonNode recordsNodes = jsonNode.findValue("records");
+        List<OperationDataDetail> records = new ArrayList<OperationDataDetail>();
+        if(recordsNodes != null){
+            Iterator<JsonNode> itRecores = recordsNodes.iterator();
+            while (itRecores.hasNext()){
+                JsonNode recordsNode = itRecores.next();
+                OperationDataDetail operationDataDetail = new OperationDataDetail();
+                JsonNode recordIdNode = recordsNode.findValue("id");
+                if(null != recordIdNode){
+                    operationDataDetail.setId(recordIdNode.asInt());
+                }
+                JsonNode waybill_noNode = recordsNode.findValue("waybill_no");
+                if(null != waybill_noNode){
+                    operationDataDetail.setWaybill_no(waybill_noNode.asText());
+                }
+                JsonNode weightNode = recordsNode.findValue("weight");
+                if(null != weightNode){
+                    operationDataDetail.setWeight(weightNode.asDouble());
+                }
+                JsonNode sendercodeNode = recordsNode.findValue("sendercode");
+                if(null != sendercodeNode){
+                    operationDataDetail.setSendercode(sendercodeNode.asText());
+                }
+                JsonNode sendernameNode = recordsNode.findValue("sendername");
+                if(null != sendernameNode){
+                    operationDataDetail.setSendername(sendernameNode.asText());
+                }
+                JsonNode sendertelNode = recordsNode.findValue("sendertel");
+                if(null != sendertelNode){
+                    operationDataDetail.setSendertel(sendertelNode.asText());
+                }
+                JsonNode senderaddressNode = recordsNode.findValue("senderaddress");
+                if(null != senderaddressNode){
+                    operationDataDetail.setSenderaddress(senderaddressNode.asText());
+                }
+                JsonNode receivercodeNode = recordsNode.findValue("receivercode");
+                if(null != receivercodeNode){
+                    operationDataDetail.setReceivercode(receivercodeNode.asText());
+                }
+                JsonNode receivernameNode = recordsNode.findValue("receivername");
+                if(null != receivernameNode){
+                    operationDataDetail.setReceivername(receivernameNode.asText());
+                }
+                JsonNode receivertelNode = recordsNode.findValue("receivertel");
+                if(null != receivertelNode){
+                    operationDataDetail.setReceivertel(receivertelNode.asText());
+                }
+                JsonNode receiveraddressNode = recordsNode.findValue("receiveraddress");
+                if(null != receiveraddressNode){
+                    operationDataDetail.setReceiveraddress(receiveraddressNode.asText());
+                }
+                JsonNode receiverprovinceNode = recordsNode.findValue("receiverprovince");
+                if(null != receiverprovinceNode){
+                    operationDataDetail.setReceiverprovince(receiverprovinceNode.asText());
+                }
+                JsonNode receivercityNode = recordsNode.findValue("receivercity");
+                if(null != receivercityNode){
+                    operationDataDetail.setReceivercity(receivercityNode.asText());
+                }
+                JsonNode receiverdistrictNode = recordsNode.findValue("receiverdistrict");
+                if(null != receiverdistrictNode){
+                    operationDataDetail.setReceiverdistrict(receiverdistrictNode.asText());
+                }
+                JsonNode inputdtmNode = recordsNode.findValue("inputdtm");
+                if(null != inputdtmNode){
+                    operationDataDetail.setInputdtm(inputdtmNode.asText());
+                }
+                JsonNode operatoridNode = recordsNode.findValue("operatorid");
+                if(null != operatoridNode){
+                    operationDataDetail.setOperatorid(operatoridNode.asText());
+                }
+                JsonNode operatorNode = recordsNode.findValue("operator");
+                if(null != operatorNode){
+                    operationDataDetail.setOperator(operatorNode.asText());
+                }
+                JsonNode orgstationidNode = recordsNode.findValue("orgstationid");
+                if(null != orgstationidNode){
+                    operationDataDetail.setOrgstationid(orgstationidNode.asText());
+                }
+                JsonNode orgstationnameNode = recordsNode.findValue("orgstationname");
+                if(null != orgstationnameNode){
+                    operationDataDetail.setOrgstationname(orgstationnameNode.asText());
+                }
+                JsonNode picurlNode = recordsNode.findValue("picurl");
+                if(null != picurlNode){
+                    operationDataDetail.setPicurl(picurlNode.asText());
+                }
+                JsonNode seqnoNode = recordsNode.findValue("seqno");
+                if(null != seqnoNode){
+                    operationDataDetail.setSeqno(seqnoNode.asText());
+                }
+                JsonNode shelfcodeNode = recordsNode.findValue("shelfcode");
+                if(null != shelfcodeNode){
+                    operationDataDetail.setShelfcode(shelfcodeNode.asText());
+                }
+                JsonNode barcodelistNode = recordsNode.findValue("barcodelist");
+                List<BarCode> barcodelist = new ArrayList<BarCode>();
+                if(null != barcodelistNode){
+                    Iterator<JsonNode> barcodelists = barcodelistNode.iterator();
+                    while (barcodelists.hasNext()){
+                        JsonNode barCodesNote = barcodelists.next();
+                        BarCode barCode = new BarCode();
+                        if(null != barCodesNote){
+                            JsonNode typeNote = barCodesNote.findValue("type");
+                            if(null != typeNote ){
+                                barCode.setType(typeNote.asText());
+                            }
+                            JsonNode codeNote = barCodesNote.findValue("code");
+                            if(null != codeNote ){
+                                barCode.setCode(codeNote.asText());
+                            }
+                        }
+                        barcodelist.add(barCode);
+                    }
+                    operationDataDetail.setBarcodelist(barcodelist);
+                }
+                records.add(operationDataDetail);
+            }
+        }
+        operationData.setRecords(records);
+        return xiaoBaiService.saveDeliveryScanBatch(operationData,1);
+    }
+}

+ 1097 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppDispatchController.java

@@ -0,0 +1,1097 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.store.entity.TemplateData;
+import cn.haliaeetus.controller.store.entity.WxTemplate;
+import cn.haliaeetus.controller.store.helper.DeliveryInfo;
+import cn.haliaeetus.controller.store.helper.DeliveryMsgSendHelper;
+import cn.haliaeetus.controller.store.helper.StoreAPIHelper;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.dao.DeliveryDao;
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.entity.dto.DeliveryDto;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.rabbit.DirectRabbitConfig;
+import cn.haliaeetus.framework.sms.entity.SendBackReasonEnum;
+import cn.haliaeetus.framework.sms.entity.kuaibao.ExpressConvertEnum;
+import cn.haliaeetus.framework.toolkit.MyExecutor;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.framework.util.OkHttpUtil;
+import cn.haliaeetus.framework.util.StringUtil;
+import cn.haliaeetus.service.*;
+import cn.haliaeetus.service.impl.SMSSendRabbitPushServiceImpl;
+import com.alibaba.fastjson.JSON;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.jfinal.weixin.sdk.utils.JsonUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 派送,退回,签收
+ * Created by Administrator on 2018/12/21 0021.
+ */
+@Controller
+public class AppDispatchController extends BaseController {
+    private static final MyExecutor executor = MyExecutor.instance();
+    @Autowired
+    private DeliveryService deliveryService;
+    @Autowired
+    private ExpsSignBackService expsSignBackService;
+    @Autowired
+    private FjDeliveryService fjDeliveryService;
+
+    @Autowired
+    private StoreStaffService staffService;
+
+    @Autowired
+    private StoreAPIHelper storeAPIHelper;
+
+    @Autowired
+    private DeliveryNoArriveService noArriveService;
+
+    @Autowired
+    private DeliveryStatusService statusService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private TypeLibraryService typeLibraryService;
+
+    @Autowired
+    private DeliveryMsgSendHelper messageSendHelper;
+
+    @Autowired
+    private DeliveryScanBatchService scanBatchService;
+
+    @Autowired
+    private DeliveryDao deliveryDao;
+
+    @Autowired
+    private SmsRecordService smsRecordService;
+
+    @Autowired
+    private WxTemplateService wxTemplateService;
+
+    @Autowired
+    private WhiteListService whiteListService;
+
+    @Autowired
+    private SendBackReasonService sendBackReasonService;
+
+    @Autowired
+    private SendBackDeliveryService sendBackDeliveryService;
+
+    @Autowired
+    private SMSSendRabbitPushServiceImpl smsSendRabbitPushService;
+
+    //派送
+    @RequestMapping("/app/device/dispatch")
+    @ResponseBody
+    public Object appDispatch(HttpServletRequest request,
+                              @RequestParam(defaultValue = "") String expCodes,
+                              HttpServletResponse response) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null) return buildJson(1, "用户未登录");
+        String strStaffId = request.getParameter("staffId");
+        if (null == strStaffId || "".equals(strStaffId)) {
+            return buildJson(-1, "未选择快递员");
+        }
+        Integer staffId = Integer.parseInt(strStaffId);
+        if (null == expCodes || "".equals(expCodes)) return buildJson(-1, "面单号错误");
+
+        JsonArray array = new JsonArray();
+        List<DeliveryInfo> deliveryInfoList = new ArrayList<DeliveryInfo>();
+        String[] StrExpcode = expCodes.split(",");
+        for (String expCode : StrExpcode) {
+            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expCode);
+            Delivery delivery = new Delivery();
+            try {
+                if (expCode.length() < 10) {
+                    dataObj.addProperty("reason", "面单号非法");
+                    dataObj.addProperty("code", "-1");
+                    array.add(dataObj);
+                    continue;
+                }
+                //
+                expCode = expCode.trim();
+
+                //根据面单号查询
+                DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+                //查3个月以内
+                String endTime = DateUtil.today().toString("yyyy-MM-dd").trim() + " 23:59:59";
+                String beginTime = getSpecifiedDaybefore().trim() + " 00:00:00";
+                qc.setBeginTime(Timestamp.valueOf(beginTime));
+                qc.setEndTime(Timestamp.valueOf(endTime));
+                qc.setCreateTime(beginTime, endTime);
+                qc.setOrderField("createTime");
+                qc.setOrder("desc");
+            /*String subSql =  "and (expcode = '" + expCode + "'" + ")";
+            qc.setSubSql(subSql);*/
+                qc.setExpcode(expCode);
+                qc.setSmsStatus(3);
+                List<Delivery> deliverys = deliveryService.getDelivery(qc);
+                if (deliverys.size() < 1) {
+                    dataObj.addProperty("reason", "订单不在库");
+                    dataObj.addProperty("code", "-1");
+                    array.add(dataObj);
+                    continue;
+                }
+                delivery = deliverys.get(0);
+           /* Delivery delivery = deliveryService.getByExpCode(user.getStoreId(),expCode);
+            if(null == delivery){
+                return buildJson(-1, "面单号不存在");
+            }*/
+                String userPhone = "";
+                // 分拣中心快递类型
+//            if (expId == Integer.MAX_VALUE) {
+                List<FjDelivery> fjDeliveryList = fjDeliveryService.getByExpCode(user.getStoreId(), expCode);
+//                if (fjDeliveryList == null || fjDeliveryList.isEmpty()) {
+//                    dataObj1.addProperty("reason", "没有分拣");
+//                    array.add(dataObj1);
+//                    continue;
+//                }
+                if (null == fjDeliveryList || fjDeliveryList.isEmpty()) {
+                    if (fjDeliveryList.size() > 1) {
+                        dataObj.addProperty("reason", "分拣单号重复");
+                        dataObj.addProperty("code", "-1");
+                        array.add(dataObj);
+                        continue;
+                    }
+                    userPhone = "";
+                }
+           /* else {
+                userPhone = fjDeliveryList.get(0).getTelphone();
+            }*/
+                userPhone = delivery.getUserPhone();
+                int expId = delivery.getExpId();
+//            }
+
+                if (delivery.getStatus().intValue() == Constants.ORDER_STATUS_LEAVE_STORE) {
+                    throw new NullPointerException("订单已离库");
+                }
+                DeliveryInfo deliveryInfo = deliveryService.dispatchAppDelivery(user, expCode, expId, staffId, "", userPhone, Constants
+                        .CLIENT_TYPE_STORE_LITE_2, delivery.getShelfCode());
+                deliveryInfoList.add(deliveryInfo);
+                //同步一条数据到到件表中
+                List<DeliveryScanBatch> scanBatches = scanBatchService.getByCondition(user.getStoreId(), expCode, null, null, null, null);
+                if (scanBatches != null && scanBatches.size() > 0) {
+                    //更新下车表里的快递公司、取货码、货架号
+                    DeliveryScanBatch deliveryScanBatch = scanBatches.get(0);
+                    DeliveryScanBatch dsb = new DeliveryScanBatch();
+                    dsb.setStoreId(deliveryScanBatch.getStoreId());
+                    dsb.setExpCode(deliveryScanBatch.getExpCode());
+//                deliveryScanBatch.setExpId(Integer.getInteger(expressId));
+                    dsb.setExpId(expId);
+                    scanBatchService.updateByStoreAndExpCode(dsb);
+                } else {
+                    DeliveryScanBatch scanBatch = new DeliveryScanBatch();
+                    scanBatch.setExpCode(expCode);
+                    scanBatch.setRevexpCode(StringUtil.stringReverse(expCode));
+                    scanBatch.setExpId(expId);
+                    scanBatch.setBatchNumber(0);
+                    scanBatch.setStoreId(user.getStoreId());
+                    scanBatch.setOperatorId(1);
+                    scanBatch.setCreateTime(new Date());
+                    scanBatch.setUserName("");
+                    scanBatch.setUserPhone(userPhone);
+                    scanBatch.setRevuserPhone(StringUtil.stringReverse(userPhone));
+                    scanBatch.setChargeMoney(null);
+                    scanBatch.setOcrStatus("0");
+                    scanBatch.setOcrAmount("0");
+                    scanBatch.setShelfCode("");
+                    scanBatchService.insert(scanBatch);
+                }
+                dataObj.addProperty("code", "0");
+                dataObj.addProperty("reason", "订单派送成功");
+                array.add(dataObj);
+            } catch (Exception e) {
+                switch (delivery.getStatus()) {
+                    case Constants.ORDER_STATUS_LEAVE_STORE:
+                        dataObj.addProperty("code", "-2");//退回
+                        break;
+                    case Constants.ORDER_STATUS_DISPATCHING:
+                        dataObj.addProperty("code", "-3");//派送中
+                        break;
+                    default:
+                        dataObj.addProperty("code", "-5");
+                }
+                dataObj.addProperty("reason", e.getMessage());
+                array.add(dataObj);
+            }
+/*
+            //判断0代表入库时生成签收,1代表出库时生成签收
+            if(user.getSignFlag()==0){
+                // 新入库
+                DeliveryQueryCondition dqc = new  DeliveryQueryCondition(user.getStoreId());
+                dqc.setExp_code(expCode);
+                dqc.setStoreId(user.getStoreId());
+
+                deliveryDao.updateStoreOut(dqc);
+            }*/
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "请求成功");
+        object.add("expInfo", array);
+
+       /* // 短信发送方式为付费模式
+        if ((user.getIsSmsFree() == null || user.getIsSmsFree() != Constants.YES) && _.isNotEmpty(deliveryInfoList)) {
+            messageSendHelper.asyncSendMsgAndDeduct(deliveryInfoList, user, Constants.SMS_CONSUME_BUSINESS_DISPATCH);
+        }*/
+
+        return object.toString();
+    }
+
+    //退回
+    @RequestMapping("/app/device/leave")
+    @ResponseBody
+    public Object appLeaveDelivery(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(request.getParameter("data"));
+        if (jsonNode == null) return buildJson(-1, "请求数据有误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        while (it.hasNext()) {
+            JsonNode expInfo = it.next();
+            JsonNode staffIdNode = expInfo.findValue("staffId");
+            int staffId = 0;
+            if (staffIdNode != null) {
+                staffId = staffIdNode.asInt();
+            }
+            //int staffId = expInfo.findValue("staffId").asInt();
+            String expCode = expInfo.findValue("expCode").asText();
+
+           /* if (staffId == 0 || _.isEmpty(expCode)) {
+                continue;
+            }
+*/
+            Delivery delivery = null;
+            int expId = 0;
+            JsonNode expIdNode = expInfo.findValue("expId");
+            if (expIdNode != null) expId = expIdNode.asInt();
+            if (expId <= 0) {
+                Object obj = handleRepeatDelivery(expCode, user.getStoreId());
+                if (obj instanceof Delivery) delivery = (Delivery) obj;
+                if (obj instanceof JsonObject) {
+                    array.add((JsonElement) obj);
+                    continue;
+                }
+            } else {
+                delivery = deliveryService.getByTuple(user.getStoreId(), expId, expCode);
+            }
+
+            if (delivery == null) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("code", -1);
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "单号不存在或单号不在库");
+                array.add(dataObj);
+                continue;
+            }
+
+            if (delivery.getStatus() == Constants.ORDER_STATUS_COMPLETE) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("code", -2);
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "已出库");
+                array.add(dataObj);
+                continue;
+            }
+
+            // 忽略已离库
+            if (delivery.getStatus() == Constants.ORDER_STATUS_LEAVE_STORE || delivery.getStatus() == Constants
+                    .ORDER_STATUS_REJECT_LEAVE_STORE) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("code", -3);
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "已离库");
+                array.add(dataObj);
+                continue;
+            }
+            String staffName = "无";
+            if (0 != staffId) {
+                StoreStaff staff = staffService.getById(staffId);
+                if (staff == null) {
+                    JsonObject dataObj = new JsonObject();
+                    dataObj.addProperty("code", -4);
+                    dataObj.addProperty("expCode", expCode);
+                    dataObj.addProperty("reason", "派送员不存在");
+                    array.add(dataObj);
+                    continue;
+                }
+                staffName = staff.getName();
+            }
+            String reason = expInfo.findValue("reason") != null ? expInfo.findValue("reason").asText() : "";
+            String reasonDes = expInfo.findValue("reasonDes") != null ? expInfo.findValue("reasonDes").asText() : "";
+
+            // 拒收离库
+            int status = delivery.getProblemType() == Constants.PROBLEM_TYPE_REFUSE ? Constants
+                    .ORDER_STATUS_REJECT_LEAVE_STORE : Constants.ORDER_STATUS_LEAVE_STORE;
+            if (status != delivery.getStatus()) {
+
+
+                Delivery entity = new Delivery();
+                entity.setStatus(status);
+                entity.setStatusTime(new Date());
+                entity.setRemark(reasonDes);
+
+                // 获取退件原因 start add by 20190712
+                JsonNode reasonIdNode = expInfo.findValue("sendBackReasonId");
+                int reasonId = 0;
+                if (reasonIdNode != null) {
+                    reasonId = reasonIdNode.asInt();
+                    String reasonName = sendBackReasonService.getReasonById(reasonId);
+                    entity.setSendBackReason(reasonName);
+                }
+                // 获取退件原因 end add by 20190712
+
+                //es出库条件修改 2019-08-20
+                entity.setUploadDtm(new Date());
+                entity.setStoreId(delivery.getStoreId());
+                DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+                qc.setEntity(entity);
+                qc.setId(delivery.getId());
+                deliveryService.update(qc);
+
+                // 添加一条退件记录 start add by 20190712
+                if (reasonId != 0) {
+                    SendBackDelivery sendBackDelivery = new SendBackDelivery();
+                    sendBackDelivery.setStoreId(user.getStoreId());
+                    sendBackDelivery.setDeliveryId(delivery.getId());
+                    sendBackDelivery.setSendBackReasonId(reasonId);
+                    sendBackDeliveryService.save(sendBackDelivery);
+                }
+                // 添加一条退件记录 start add by 20190712
+
+                DeliveryStatus deliveryStatus = addStatusHistory(user.getStoreId(), staffName, delivery.getId()
+                        , status, delivery.getStatus(), reason, reasonDes);
+                storeAPIHelper.asyncSubmitDataQueue(delivery, deliveryStatus);
+                // 2019-12-30 中通添加退回接口
+                if(ExpressConvertEnum.EXP_ZT.getExpressId() == delivery.getExpId()){
+                    expsSignBackService.signBack(delivery.getExpId(), expCode, delivery.getUserPhone(), user.getStoreId(),"return",delivery.getShelfId()+"", delivery.getShelfCode(),delivery.getPlatform(), String.valueOf(reasonId));
+                }
+                //2020-06-28 百世添加退回接口
+                if(ExpressConvertEnum.EXP_HT.getExpressId() == delivery.getExpId() && reasonId != 0){
+                    String logisticsUrl = "http://logistics.fengzhan100.com/logistics/bestExpSign";
+                    OkHttpUtil.postJson(logisticsUrl,BaseBizData.builder()
+                            .billCode(delivery.getExpcode())
+                            .operator("BESTEXP")
+                            .transactionCode(UUID.randomUUID().toString())
+                            .serviceProviderCode("fengzhan")
+                            .serviceSiteCode(user.getStoreId().toString())
+                            .status(SendBackReasonEnum.getDescByReasonId(reasonId))
+                            .requestTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                            .remark("").build());
+                }
+                JsonObject jsonObject = new JsonObject();
+                jsonObject.addProperty("code", 0);
+                jsonObject.addProperty("expCode", expCode);
+                jsonObject.addProperty("reason", "成功添加到退回");
+                array.add(jsonObject);
+            }
+        }
+
+        JsonObject object = new JsonObject();
+
+        object.addProperty("code", 0);
+        object.addProperty("msg", "请求成功");
+        object.add("expInfo", array);
+        return object.toString();
+    }
+
+    /**
+     * 拒收/问题件扫描
+     *
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    @RequestMapping(value = "/app/device/return")
+    @ResponseBody
+    public Object appDeliveryReturn(HttpServletRequest request) throws IOException {
+        User user = getUserFromParam(request);
+        if (user == null) return buildJson(1, "用户未登录");
+
+        String data = request.getParameter("data");
+        if (_.isEmpty(data)) return buildJson(-1, "参数错误");
+
+        JsonNode jsonNode = JsonUtil.parse(data);
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        while (it.hasNext()) {
+            JsonNode node = it.next();
+            int reason = node.findValue("reason").asInt();
+            String expCode = node.findValue("expCode").asText();
+
+            if (_.isEmpty(expCode)) {
+                return buildJson(-1, "单号不存在");
+            }
+
+            JsonNode expIdNode = node.findValue("expId");
+            int expId = expIdNode == null ? 0 : expIdNode.asInt();
+            if (expId == 0) {
+                DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+
+                ArrayList<Integer> statusList = new ArrayList<>();
+                statusList.add(Constants.ORDER_STATUS_STORED);
+                statusList.add(Constants.ORDER_STATUS_MAIKE_DISPATCHING);
+                statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+                statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+                qc.setStatusStr(statusList);
+
+                qc.setExpcode(expCode);
+                qc.setIsdel(0);
+                List<Delivery> deliveryList = deliveryService.getDelivery(qc);
+                if (deliveryList != null && deliveryList.size() > 1) {
+                    JsonObject dataObj = new JsonObject();
+                    dataObj.addProperty("expCode", expCode);
+                    dataObj.addProperty("reason", "单号重复");
+
+                    JsonArray expArray = new JsonArray();
+                    for (Delivery deli : deliveryList) {
+                        JsonObject obj = new JsonObject();
+                        obj.addProperty("expId", deli.getExpId());
+                        ExpressType express = basicInfoService.getExpressById(deli.getExpId());
+                        obj.addProperty("expName", express.getExpName());
+                        expArray.add(obj);
+                    }
+                    dataObj.addProperty("data", expArray.toString());
+
+                    array.add(dataObj);
+                }
+            }
+
+            try {
+                deliveryService.refuseDelivery(user.getStoreId(), 0, expCode, expId, reason, Constants.CLIENT_TYPE_STORE_LITE_2, user.getUserName());
+            } catch (Exception e) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", e.getMessage());
+                array.add(dataObj);
+            }
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.add("expInfo", array);
+
+        return object.toString();
+    }
+
+    //峰站签收多了一步调用签收回传
+    @RequestMapping(value = "/app/device/signflagfz")
+    @ResponseBody
+    public Object appDeliverySignflagfz(HttpServletRequest request
+            , @RequestParam(defaultValue = "") String expCodes  //选中的面单号
+    ) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null) return buildJson(1, "用户未登录");
+        int storeId = user.getStoreId();
+        if ("".equals(expCodes)) {
+            return buildJson(-1, "参数错误");
+        }
+        String[] expCodeStr = expCodes.split(",");
+        JsonArray array = new JsonArray();
+        for (String expcode : expCodeStr) {
+            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expcode);
+            try {
+                DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+                //查3个月以内
+                String endTime = DateUtil.today().toString("yyyy-MM-dd").trim()+" 23:59:59";
+                String beginTime = getOneMonthbefore().trim() + " 00:00:00";//2019-7-12 出库时间修改到3个月前
+                qc.setBeginTime(Timestamp.valueOf(beginTime));
+                qc.setEndTime(Timestamp.valueOf(endTime));
+                qc.setCreateTime(beginTime, endTime);
+                qc.setOrderField("createTime");
+                qc.setOrder("desc");
+                qc.setExpcode(expcode);
+                ArrayList<Integer> statusList = new ArrayList<Integer>();
+                statusList.add(Constants.ORDER_STATUS_STORED);
+                statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+                statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+                statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+                qc.setStatusStr(statusList);
+                qc.setSmsStatus(3);//查询全部
+
+                List<DeliveryDto> deliveryList = deliveryService.getDeliveryDto(qc);
+
+                if (deliveryList == null || deliveryList.size() < 1) {
+                    throw new NullPointerException("单号不存在或已出库");
+                }
+                // 如果同一单号存在多条记录时,需要回到网页进行选择
+                if (deliveryList.size() > 1) {
+                    throw new NullPointerException("存在单号重复");
+                }
+                DeliveryDto deliveryDto = deliveryList.get(0);
+                Delivery delivery = deliveryDto.getDelivery();
+                Delivery entity = new Delivery();
+                entity.setStatus(Constants.ORDER_STATUS_COMPLETE);
+                entity.setStatusTime(new Date());
+                entity.setMoney(0);
+                entity.setPayType(Constants.PAY_TYPE_ONLINE);
+                entity.setDeliveryUname(user.getUserName());
+
+                //es出库条件修改 2019-08-09
+                entity.setUploadDtm(new Date());
+                entity.setStoreId(delivery.getStoreId());
+                DeliveryQueryCondition qc1 = new DeliveryQueryCondition(storeId);
+                qc1.setEntity(entity);
+                qc1.setId(delivery.getId());
+                qc1.setSignFlag("1");
+                deliveryService.update(qc1);
+                /*DeliveryQueryCondition dqc = new  DeliveryQueryCondition(user.getStoreId());
+                dqc.setExp_code(expcode);
+                dqc.setStoreId(user.getStoreId());
+                deliveryDao.updateStoreOut(dqc);*/
+                dataObj.addProperty("code", 0);
+                dataObj.addProperty("reason", "签收成功");
+
+                log.info("chukutuotou::::::::::::::" + delivery.getExpId());
+                //add 2019/03/19
+                expsSignBackService.signBack(delivery.getExpId(), delivery.getExpcode(), delivery.getUserPhone(), user.getStoreId(), "out", null, null,delivery.getPlatform());
+                wxSignMsgRemind(storeId, delivery);
+
+
+            } catch (Exception e) {
+                dataObj.addProperty("code", -1);
+                dataObj.addProperty("reason", e.getMessage());
+            } finally {
+                array.add(dataObj);
+            }
+        }
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "请求成功");
+        object.add("expInfo", array);
+        return object.toString();
+    }
+
+    private void wxSignMsgRemind(int storeId, Delivery delivery) {
+        Map<String, Object> param = new HashMap<>(2);
+        param.put("storeId",storeId);
+        param.put("delivery",delivery);
+        //发送mq
+        String info=new Gson().toJson(param);
+        smsSendRabbitPushService.rabbitMQAllPush(DirectRabbitConfig.WECHAT_EXCHANGE,DirectRabbitConfig.WECHAT_KEY,info);
+
+    }
+
+    //峰站签收多了一步调用签收回传,解决快递单号重复导致签收失败的问题接口
+    @RequestMapping(value = "/app/device/signflagfzrepeat")
+    @ResponseBody
+    public Object appDeliverySignflagfz(HttpServletRequest request
+    ) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null) return buildJson(1, "用户未登录");
+        int storeId = user.getStoreId();
+        //获取前台传过来的data数据
+        String data = request.getParameter("data");
+        if(_.isEmpty(data))  return buildJson(-1,"参数错误");
+        //将data数据转化格式
+        JsonNode jsonNode = JsonUtil.parse(data);
+        if (null == jsonNode)  return buildJson(-1,"参数错误");
+        //创建jsonArray
+        JsonArray array = new JsonArray();
+
+        //创建JsonNode迭代器
+        Iterator<JsonNode> it = jsonNode.iterator();
+        //迭代读取JsonNode的数据并取出来
+        while (it.hasNext()){
+            JsonObject dataObj = new JsonObject();
+            JsonNode node = it.next();
+            Integer expId = node.findValue("expId").asInt();
+            String expcode = node.findValue("expCode").asText();
+            try {
+                DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+                //查3个月以内
+                String endTime = DateUtil.today().toString("yyyy-MM-dd").trim()+" 23:59:59";
+                String beginTime = getOneMonthbefore().trim() + " 00:00:00";//2019-7-12 出库时间修改到3个月前
+                qc.setBeginTime(Timestamp.valueOf(beginTime));
+                qc.setEndTime(Timestamp.valueOf(endTime));
+                qc.setCreateTime(beginTime, endTime);
+                qc.setOrderField("createTime");
+                qc.setOrder("desc");
+                qc.setExpcode(expcode);
+                qc.setExpId(expId);
+                ArrayList<Integer> statusList = new ArrayList<Integer>();
+                statusList.add(Constants.ORDER_STATUS_STORED);
+                statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+                statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+                statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+                qc.setStatusStr(statusList);
+                qc.setSmsStatus(3);//查询全部
+
+                List<DeliveryDto> deliveryList = deliveryService.getDeliveryDto(qc);
+
+                if (deliveryList == null || deliveryList.size() < 1) {
+                    throw new NullPointerException("单号不存在或已出库");
+                }
+                // 如果同一单号存在多条记录时,需要回到网页进行选择
+                if (deliveryList.size() > 1) {
+                    throw new NullPointerException("存在单号重复");
+                }
+                DeliveryDto deliveryDto = deliveryList.get(0);
+                Delivery delivery = deliveryDto.getDelivery();
+                Delivery entity = new Delivery();
+                entity.setStatus(Constants.ORDER_STATUS_COMPLETE);
+                entity.setStatusTime(new Date());
+                entity.setMoney(0);
+                entity.setPayType(Constants.PAY_TYPE_ONLINE);
+                entity.setDeliveryUname(user.getUserName());
+
+                //es出库条件修改 2019-08-20
+                entity.setUploadDtm(new Date());
+                entity.setStoreId(delivery.getStoreId());
+                DeliveryQueryCondition qc1 = new DeliveryQueryCondition(storeId);
+                qc1.setEntity(entity);
+                qc1.setId(delivery.getId());
+                qc1.setSignFlag("1");
+                deliveryService.update(qc1);
+
+                dataObj.addProperty("code", 0);
+                dataObj.addProperty("reason", "签收成功");
+
+                log.info("chukutuotou::::::::::::::" + delivery.getExpId());
+                //add 2019/03/19
+                expsSignBackService.signBack(delivery.getExpId(), delivery.getExpcode(), delivery.getUserPhone(), user.getStoreId(), "out", null, null,delivery.getPlatform());
+
+
+                //微信签收消息提醒
+                //根据店铺id查询当前店铺的白名单客户
+                wxSignMsgRemind(storeId, delivery);
+
+            } catch (Exception e) {
+                dataObj.addProperty("code", -1);
+                dataObj.addProperty("reason", e.getMessage());
+            } finally {
+                array.add(dataObj);
+            }
+        }
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "请求成功");
+        object.add("expInfo", array);
+        return object.toString();
+    }
+
+    @RequestMapping(value = "/app/device/signflagByHaiKang")
+    @ResponseBody
+    public Object haikangDeliverySignflag(HttpServletRequest request, HttpServletResponse response, @RequestBody HaiKangOutboundBean haiKangOutboundBean) throws Exception {
+        int storeId = Integer.parseInt(haiKangOutboundBean.getStoreId());
+        String expcode = haiKangOutboundBean.getExpCode();
+        ResultInfoBean<Map> resultInfoBean = new ResultInfoBean();
+        Map<String,Integer> pickup = new HashMap<>(16);
+        try {
+            DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+            //查3个月以内
+            String endTime = DateUtil.today().toString("yyyy-MM-dd").trim() + " 23:59:59";
+            String beginTime = getOneMonthbefore().trim() + " 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(beginTime));
+            qc.setEndTime(Timestamp.valueOf(endTime));
+            qc.setCreateTime(beginTime, endTime);
+            qc.setOrderField("createTime");
+            qc.setOrder("desc");
+            qc.setExpcode(expcode);
+            ArrayList<Integer> statusList = new ArrayList<Integer>();
+            statusList.add(Constants.ORDER_STATUS_STORED);
+            statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+            statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+            statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+            qc.setStatusStr(statusList);
+            qc.setSmsStatus(3);//查询全部
+            List<DeliveryDto> deliveryList = deliveryService.getDeliveryDto(qc);
+
+            if (deliveryList == null || deliveryList.size() < 1) {
+                resultInfoBean.setResultCode("01");
+                resultInfoBean.setResultMessage("单号不存在");
+                return JSON.toJSONString(resultInfoBean);
+            }
+            // 如果同一单号存在多条记录时,需要回到网页进行选择
+            if (deliveryList.size() > 1) {
+                resultInfoBean.setResultCode("01");
+                resultInfoBean.setResultMessage("存在单号重复");
+                return JSON.toJSONString(resultInfoBean);
+            }
+            DeliveryDto deliveryDto = deliveryList.get(0);
+            Delivery delivery = deliveryDto.getDelivery();
+            Delivery entity = new Delivery();
+            entity.setStatus(Constants.ORDER_STATUS_COMPLETE);
+            entity.setStatusTime(new Date());
+            entity.setMoney(0);
+            entity.setPayType(Constants.PAY_TYPE_ONLINE);
+
+            entity.setUploadDtm(new Date());
+            entity.setStoreId(delivery.getStoreId());
+            DeliveryQueryCondition qc1 = new DeliveryQueryCondition(storeId);
+            qc1.setEntity(entity);
+            qc1.setId(delivery.getId());
+            qc1.setSignFlag("1");
+            deliveryService.update(qc1);
+
+            expsSignBackService.signBack(delivery.getExpId(), delivery.getExpcode(), delivery.getUserPhone(), storeId, "out", String.valueOf(delivery.getShelfId()), delivery.getShelfCode(), delivery.getPlatform());
+            pickup.merge(delivery.getUserPhone(), 1, Integer::sum);
+
+            Map<String, Object> result = new HashMap<>();
+            Long aLong = this.countInStore(storeId, delivery.getUserPhone());
+            result.put("count", aLong);
+            if (aLong > 0) {
+                List<Map<String, Object>> deliverysInStore = this.getDeliverysInStore(storeId, delivery.getUserPhone());
+                result.put("list", deliverysInStore);
+            }
+            resultInfoBean.setData(result);
+        } catch (Exception e) {
+            resultInfoBean.setResultCode("99");
+            resultInfoBean.setResultMessage("系统错误");
+            return JSON.toJSONString(resultInfoBean);
+        }
+        resultInfoBean.setResultCode("00");
+        resultInfoBean.setResultMessage("处理成功");
+        deliveryService.pickupSign(pickup);
+        return JSON.toJSONString(resultInfoBean);
+    }
+
+    /**
+     * 根据手机号查询在库数量
+     */
+    private Long countInStore(Integer storeId, String userPhone){
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+        // 查3个月以内
+        String endTime = DateUtil.today().toString("yyyy-MM-dd").trim() + " 23:59:59";
+        String beginTime = getOneMonthbefore().trim() + " 00:00:00";
+        qc.setBeginTime(Timestamp.valueOf(beginTime));
+        qc.setEndTime(Timestamp.valueOf(endTime));
+        qc.setCreateTime(beginTime, endTime);
+        qc.setUserPhone(userPhone);
+        // qc.setOrderField("createTime");
+        // qc.setOrder("desc");
+        ArrayList<Integer> statusList = new ArrayList<Integer>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+        qc.setStatusStr(statusList);
+        qc.setSmsStatus(3);//查询全部
+        return deliveryService.count(qc);
+    }
+
+    /**
+     * 根据手机号查询所有在库单
+     */
+    private List<Map<String, Object>> getDeliverysInStore(Integer storeId, String userPhone) {
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+        // 查3个月以内
+        String endTime = DateUtil.today().toString("yyyy-MM-dd").trim() + " 23:59:59";
+        String beginTime = getOneMonthbefore().trim() + " 00:00:00";
+        qc.setBeginTime(Timestamp.valueOf(beginTime));
+        qc.setEndTime(Timestamp.valueOf(endTime));
+        qc.setCreateTime(beginTime, endTime);
+        qc.setUserPhone(userPhone);
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        ArrayList<Integer> statusList = new ArrayList<Integer>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+        qc.setStatusStr(statusList);
+        qc.setSmsStatus(3);//查询全部
+        List<DeliveryDto> deliveryDtos = deliveryService.getDeliveryDto(qc);
+        List<Map<String, Object>> collect = deliveryDtos.stream().map(item -> {
+
+            Delivery delivery = item.getDelivery();
+            StoreShelf shelf = item.getShelf();
+            Map<String, Object> result = new HashMap<>();
+            result.put("expcode", delivery.getExpcode());
+            result.put("shelfCode", shelf.getShelfName() + "-" + delivery.getShelfCode());
+            result.put("userPhone", delivery.getUserPhone());
+            result.put("createTime", DateUtil.timestampFormat(delivery.getCreateTime()));
+            return result;
+        }).collect(Collectors.toList());
+        return collect;
+    }
+
+    @RequestMapping(value = "/app/device/signflag")
+    @ResponseBody
+    public Object appDeliverySignflag(HttpServletRequest request
+            , @RequestParam(defaultValue = "") String expCodes  //选中的面单号
+    ) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null) return buildJson(1, "用户未登录");
+        int storeId = user.getStoreId();
+        if ("".equals(expCodes)) {
+            return buildJson(-1, "参数错误");
+        }
+        String[] expCodeStr = expCodes.split(",");
+        JsonArray array = new JsonArray();
+        for (String expcode : expCodeStr) {
+            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expcode);
+            try {
+                DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+                //查3个月以内
+                String endTime = DateUtil.today().toString("yyyy-MM-dd").trim() + " 23:59:59";
+                String beginTime = getOneMonthbefore().trim() + " 00:00:00";
+                qc.setBeginTime(Timestamp.valueOf(beginTime));
+                qc.setEndTime(Timestamp.valueOf(endTime));
+                qc.setCreateTime(beginTime, endTime);
+                qc.setOrderField("createTime");
+                qc.setOrder("desc");
+                qc.setExpcode(expcode);
+                ArrayList<Integer> statusList = new ArrayList<Integer>();
+                statusList.add(Constants.ORDER_STATUS_STORED);
+                statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+                statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+                statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+                qc.setStatusStr(statusList);
+                qc.setSmsStatus(3);//查询全部
+                List<DeliveryDto> deliveryList = deliveryService.getDeliveryDto(qc);
+
+                if (deliveryList == null || deliveryList.size() < 1) {
+                    throw new NullPointerException("单号不存在");
+                }
+                // 如果同一单号存在多条记录时,需要回到网页进行选择
+                if (deliveryList.size() > 1) {
+                    throw new NullPointerException("存在单号重复");
+                }
+                DeliveryDto deliveryDto = deliveryList.get(0);
+                Delivery delivery = deliveryDto.getDelivery();
+                Delivery entity = new Delivery();
+                entity.setStatus(Constants.ORDER_STATUS_COMPLETE);
+                entity.setStatusTime(new Date());
+                entity.setMoney(0);
+                entity.setPayType(Constants.PAY_TYPE_ONLINE);
+                entity.setDeliveryUname(user.getUserName());
+                DeliveryQueryCondition qc1 = new DeliveryQueryCondition(storeId);
+                qc1.setEntity(entity);
+                qc1.setId(delivery.getId());
+                qc1.setSignFlag("1");
+                deliveryService.update(qc1);
+                /*DeliveryQueryCondition dqc = new  DeliveryQueryCondition(user.getStoreId());
+                dqc.setExp_code(expcode);
+                dqc.setStoreId(user.getStoreId());
+                deliveryDao.updateStoreOut(dqc);*/
+
+                dataObj.addProperty("code", 0);
+                dataObj.addProperty("reason", "签收成功");
+                expsSignBackService.signBack(delivery.getExpId(), delivery.getExpcode(), delivery.getUserPhone(), user.getStoreId(), "out", null, null);
+            } catch (Exception e) {
+                dataObj.addProperty("code", -1);
+                dataObj.addProperty("reason", e.getMessage());
+            } finally {
+                array.add(dataObj);
+            }
+        }
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "请求成功");
+        object.add("expInfo", array);
+        return object.toString();
+    }
+
+    /**
+     * 添加状态流转记录
+     */
+    private DeliveryStatus addStatusHistory(int storeId, String staffName, int deliveryId, int status
+            , int preStatus, String reason, String reasonDec) {
+        DeliveryStatus deliveryStatus = new DeliveryStatus();
+        deliveryStatus.setDeliveryId(deliveryId);
+        deliveryStatus.setProcessStaff(staffName);
+        deliveryStatus.setSource(Constants.CLIENT_TYPE_STORE_LITE_2);
+        deliveryStatus.setStatus(status);
+        deliveryStatus.setPreStatus(preStatus);
+        deliveryStatus.setUpdateTime(new Date());
+        deliveryStatus.setReasonCode(reason);
+        deliveryStatus.setRemark(reasonDec);
+        statusService.insert(storeId, deliveryStatus);
+        return deliveryStatus;
+    }
+
+    /**
+     * 处理单号重复的快递
+     *
+     * @param expCode
+     * @param storeId
+     * @return 单子不存在返回null, 仅一单返回Delivery, 大于一单返回错误数据的JsonObject
+     * @throws java.sql.SQLException
+     */
+    private Object handleRepeatDelivery(String expCode, int storeId) {
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+
+        ArrayList<Integer> statusList = new ArrayList<>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+        statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+        qc.setStatusStr(statusList);
+
+        qc.setExpcode(expCode);
+        List<Delivery> deliveryList = deliveryService.getDelivery(qc);
+        if (deliveryList != null && !deliveryList.isEmpty()) {
+
+            if (deliveryList.size() == 1) {
+                return deliveryList.get(0);
+            }
+
+            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expCode);
+            dataObj.addProperty("reason", "单号重复");
+
+            JsonArray expArray = new JsonArray();
+            for (Delivery deli : deliveryList) {
+                JsonObject data = new JsonObject();
+                data.addProperty("expId", deli.getExpId());
+                ExpressType express = basicInfoService.getExpressById(deli.getExpId());
+                if (null != express) {
+                    data.addProperty("expName", express.getExpName());
+                }
+                // data.addProperty("expName", express.getExpName());
+                expArray.add(data);
+            }
+            dataObj.addProperty("data", expArray.toString());
+
+            return dataObj;
+        }
+        return null;
+    }
+
+    private String getSpecifiedDaybefore() {
+        Calendar c = Calendar.getInstance();
+        c.setTime(new Date());
+        int day = c.get(Calendar.DATE);
+        c.set(Calendar.MONTH, -2);
+
+        String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+
+    private static String getOneMonthbefore(){
+        Calendar c = Calendar.getInstance();
+        c.add(Calendar.MONTH,-3);
+
+        String dayAfter=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+
+    private WxResBean getWxResBean(Delivery delivery, WxTemplate wxTemplate2) {
+        String url = basicInfoService.getConfigurationByCode("sendWxSignMsgUrl").getOValue1();
+        WxResBean wxResBean = null;
+        try {
+            log.info("param................." + JsonUtils.toJson(wxTemplate2));
+            Long beginTime = System.currentTimeMillis();
+            String res = OkHttpUtil.postJson(url, wxTemplate2);
+            Long endTime = System.currentTimeMillis();
+            log.info("res..............................." + res);
+            wxResBean = JSON.parseObject(res, WxResBean.class);
+        } catch (Exception e) {
+            log.error(_.f("微信发送消息失败,订单信息:%s,异常信息:%s.", delivery, e.getMessage()));
+        }
+        return wxResBean;
+    }
+
+    private WxTemplate getTemplate(int storeId, Delivery delivery, List<WxTemplateEntity> wxTemplateEntityList, String userPhone) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Store store = basicInfoService.getStoreById(storeId);
+        WxTemplate wxTemplate = new WxTemplate();
+        wxTemplate.setStore_id(String.valueOf(storeId));
+        wxTemplate.setMobile_number(Long.valueOf(delivery.getUserPhone()));
+        wxTemplate.setTemplate_id(wxTemplateEntityList.get(0).getMsgtempid());
+        wxTemplate.setTouser("");
+        Map<String, TemplateData> data = new HashMap<String, TemplateData>();
+
+        TemplateData templateData = new TemplateData();
+        templateData.setValue("尊敬的客户,你的快递已被签收。");
+        data.put("first", templateData);
+
+        for (WxTemplateEntity wxTemplateEntity : wxTemplateEntityList) {
+            try {
+                log.info("wxTemplateEntity:::::::::::::::::::::" + JsonUtil.format(wxTemplateEntity));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            if (wxTemplateEntity.getValue().equals("tel")) {
+                TemplateData template = new TemplateData();
+                template.setValue(store.getPhone());
+                data.put(wxTemplateEntity.getKey(), template);
+            }
+            if (wxTemplateEntity.getValue().equals("address")) {
+                TemplateData template = new TemplateData();
+//                String[] aa2=msg.split("已到");
+//                String[] bb2=aa2[1].split(",");
+//                template.setValue(bb2[0]);
+                data.put(wxTemplateEntity.getKey(), template);
+            }
+            if (wxTemplateEntity.getValue().equals("time")) {
+                TemplateData template = new TemplateData();
+                template.setValue(sdf.format(new Date()));
+                data.put(wxTemplateEntity.getKey(), template);
+            }
+            //TODO
+            if (wxTemplateEntity.getValue().equals("company")) {
+                TemplateData template = new TemplateData();
+                int expId = delivery.getExpId();
+                List<ExpressType> allExps = basicInfoService.getExpressByStoreId(storeId).get(1);
+                String expName = "";
+                for (ExpressType expressType : allExps) {
+                    if (expId == expressType.getExpId()) {
+                        expName = expressType.getExpName();
+                        break;
+                    }
+                }
+                template.setValue(expName);
+                data.put(wxTemplateEntity.getKey(), template);
+            }
+            if (wxTemplateEntity.getValue().equals("expcode")) {
+                TemplateData template = new TemplateData();
+                template.setValue(delivery.getExpcode());
+                data.put(wxTemplateEntity.getKey(), template);
+            }
+            if (wxTemplateEntity.getValue().equals("pwd")) {
+                TemplateData template = new TemplateData();
+                template.setValue(delivery.getShelfCode());
+                data.put(wxTemplateEntity.getKey(), template);
+            }
+
+        }
+
+        TemplateData templateData6 = new TemplateData();
+        templateData6.setValue("如有疑问请联系: " + store.getTakeExpressPhone());
+        data.put("remark", templateData6);
+
+        wxTemplate.setData(data);
+        return wxTemplate;
+    }
+
+}

+ 397 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppForgetPasswordController.java

@@ -0,0 +1,397 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.constants.EmailConfig;
+import cn.haliaeetus.controller.web.querycondition.UserQueryCondition;
+import cn.haliaeetus.entity.DeliveryMsgTemplateConfig;
+import cn.haliaeetus.entity.SmsRecord;
+import cn.haliaeetus.entity.Store;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.base.digt.Md5Util;
+import cn.haliaeetus.framework.sms.SMSHelper;
+import cn.haliaeetus.framework.toolkit.CacheTool;
+import cn.haliaeetus.framework.toolkit.redis.JedisClient;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryMsgTemplateConfigService;
+import cn.haliaeetus.service.SmsRecordService;
+import cn.haliaeetus.service.UserService;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.commons.beanutils.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.Random;
+
+/** 忘记密码,密码找回,修改密码,用户注册发送验证码
+ * Created by Administrator on 2019/1/3 0003.
+ */
+@Controller
+public class AppForgetPasswordController extends BaseController{
+    @Autowired
+    JedisClient jedis;
+
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private DeliveryMsgTemplateConfigService deliveryMsgTemplateConfigService;
+    @Autowired
+    private SmsRecordService smsRecordService;
+    @Autowired
+    private BasicInfoService basicService;
+    private final String CODETEXT = "你本次找回密码的验证码是:";
+    private final String CODETEXTFRONT = ",此验证码两分钟内有效,为保证信息安全请勿告诉他人。";
+    private final String REGIEST_CODETEXT = "你本次注册的验证码是:";
+    private final String CODE_KEY = "FGPASSWORD";
+    private final String REGIST_CODE_KEY = "REGISTCODE";
+    //找回密码发送短信用
+    @RequestMapping(value = "/app/forgetPassword" )
+    @ResponseBody
+    public Object appForgetPassword(HttpServletRequest request,
+                                     @RequestParam(defaultValue = "") String userPhone
+                                    ) throws SQLException, IOException {
+        if("".equals(userPhone)){
+            return buildJson(-1,"未输入电话号码");
+        }
+        //根据电话号码查询用户是否存在
+       User user =  userService.getUserById(userPhone);
+       if(null == user){
+            return buildJson(-1,"该账号未注册");
+        }
+        String res="";
+        String comSign = "【" + EmailConfig.getEmailName() + "】";
+        String code = getAppCode();
+        SmsRecord smsRecord = new SmsRecord();
+        String context =  CODETEXT + code + CODETEXTFRONT;
+        JsonNode jsonNode = null;
+        try {
+            // res  = SMSHelper.sendSMS_WX(comSign,user.getTelPhone(),context,"");
+            jsonNode = JsonUtil.parse(res);
+        } catch (Exception e) {
+            return buildJson(-1,"发送失败");
+        }
+        //发送成功存入缓存
+        saveCacheCode(userPhone,CODE_KEY,code);
+        if (jsonNode != null) {
+            String smsRecordMsgid = jsonNode.findValue("msgid").asText();
+            smsRecord.setIsmgid("WX" + smsRecordMsgid);
+        }
+        //存入短信表
+        smsRecord.setStatus(Constants.SMS_SEND_STATUS_SUCCESS);
+        smsRecord.setResultInfo("无锡平台短信发送成功");
+        smsRecord.setCreatetime(new Date());
+        smsRecord.setContent(context);
+        smsRecordService.save(smsRecord);
+        return buildJson(0,"请联系管理员");
+    }
+
+    //发送注册短信验证码
+    @RequestMapping(value = "/app/regist/sendsms" )
+    @ResponseBody
+    public Object appSendRegistSms(HttpServletRequest request,
+                                    @RequestParam(defaultValue = "") String userPhone
+    )  {
+        if("".equals(userPhone)){
+            return buildJson(-1,"未输入电话号码");
+        }
+        //根据电话号码查询用户是否存在
+        User user =  userService.getUserById(userPhone);
+        if(null != user){
+            return buildJson(-1,"该电话号码已经注册");
+        }
+        String res="";
+        String comSign = "【" + EmailConfig.getEmailName() + "】";
+        String cacheCode = getCachecode(userPhone,REGIST_CODE_KEY);
+        if(_.isNotEmpty(cacheCode)){
+            return buildJson(-1,"验证码已发送");
+        }
+        String code = getAppCode();
+
+        SmsRecord smsRecord = new SmsRecord();
+        String context = REGIEST_CODETEXT + code + CODETEXTFRONT;
+        JsonNode jsonNode = null;
+        try {
+            // res  = SMSHelper.sendSMS_WX(comSign,userPhone,context,"");
+            jsonNode = JsonUtil.parse(res);
+        } catch (Exception e) {
+            return buildJson(-1,"发送失败");
+        }
+        //发送成功存入缓存
+        saveCacheCode(userPhone,REGIST_CODE_KEY,code);
+        if (jsonNode != null) {
+            String smsRecordMsgid = jsonNode.findValue("msgid").asText();
+            smsRecord.setIsmgid("WX" + smsRecordMsgid);
+        }
+        //存入短信表
+        smsRecord.setStatus(Constants.SMS_SEND_STATUS_SUCCESS);
+        smsRecord.setResultInfo("无锡平台短信发送成功");
+        smsRecord.setCreatetime(new Date());
+        smsRecord.setContent(context);
+        smsRecordService.save(smsRecord);
+        return buildJson(0,"请联系管理员");
+    }
+
+    //找回密码验证验证码
+    @RequestMapping(value = "/app/changePassword" )
+    @ResponseBody
+    public Object changePassword(HttpServletRequest request,
+                                 @RequestParam(defaultValue = "") String userPhone,
+                                 @RequestParam(defaultValue = "") String cheekCode,
+                                 @RequestParam(defaultValue = "") String newPassword){
+        if("".equals(userPhone)){
+            return buildJson(-1,"未输入电话号码");
+        }
+        if("".equals(cheekCode)){
+            return buildJson(-1,"未输入验证码");
+        }
+        if("".equals(newPassword)){
+            return buildJson(-1,"未输入新密码");
+        }
+        if(newPassword.length()<6){
+            return buildJson(-1,"密码长度应该不少于6位");
+        }
+         User user =  userService.getUserById(userPhone);
+        if(null == user){
+            return buildJson(-1,"该电话号码未注册");
+        }
+        //获取验证码验证
+        String oldCode =  getCachecode(userPhone,CODE_KEY);
+        if(null == oldCode){
+            return buildJson(-1,"验证码过期");
+        }
+        if(!oldCode.equals(cheekCode)){
+            return buildJson(-1,"验证码错误");
+        }
+        UserQueryCondition qc = new UserQueryCondition();
+        user.setPassword(Md5Util.md5AsLowerHex(newPassword));
+        qc.setUserId(user.getUserId());
+        qc.setEntity(user);
+        //修改密码
+        userService.updateUser(qc);
+        return buildJson(0,"密码重置成功");
+    }
+
+    //注册验证码验证
+    @RequestMapping(value = "/app/regist/code" )
+    @ResponseBody
+    public Object regiestCode(HttpServletRequest request,
+                                 @RequestParam(defaultValue = "") String userPhone,
+                                 @RequestParam(defaultValue = "") String cheekCode){
+        if("".equals(userPhone)){
+            return buildJson(-1,"未输入电话号码");
+        }
+        if("".equals(cheekCode)){
+            return buildJson(-1,"未输入验证码");
+        }
+        User user =  userService.getUserById(userPhone);
+        if(null != user){
+            return buildJson(-1,"该电话号码已经注册");
+        }
+        //获取验证码验证
+        String oldCode =  getCachecode(userPhone,REGIST_CODE_KEY);
+        if(null == oldCode){
+            return buildJson(-1,"验证码过期");
+        }
+        if(!oldCode.equals(cheekCode)){
+            return buildJson(-1,"验证码错误");
+        }
+        return buildJson(0,"验证成功");
+    }
+
+
+    //修改密码
+    @RequestMapping(value = "/app/amentPassword" )
+    @ResponseBody
+    public Object amentPassword(HttpServletRequest request,
+                                 @RequestParam(defaultValue = "") String oldPassword,
+                                 @RequestParam(defaultValue = "") String newPassword){
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1,"用户未登录");
+        }
+        if("".equals(oldPassword)){
+            return buildJson(-1,"未输入旧密码");
+        }
+        if(newPassword.length()<6){
+            return buildJson(-1,"密码长度应该不少于6位");
+        }
+        if(!Md5Util.md5AsLowerHex(oldPassword).equals(user.getPassword())){
+            return buildJson(-1,"输入的旧密码错误");
+        }
+        UserQueryCondition qc = new UserQueryCondition();
+        user.setPassword(Md5Util.md5AsLowerHex(newPassword));
+        qc.setUserId(user.getUserId());
+        qc.setEntity(user);
+        //修改密码
+        userService.updateUser(qc);
+        return buildJson(0,"密码修改成功");
+    }
+    //修改个人信息 头像 长地址
+    @RequestMapping(value = "/app/changeUserMessage" )
+    @ResponseBody
+    public Object changeMessage(HttpServletRequest request,
+                                @RequestParam(defaultValue = "") String conment,
+                                @RequestParam(defaultValue = "-1") int type){
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1,"用户未登录");
+        }
+        if(null == conment || "".equals(conment)){
+            return buildJson(-1,"未输入修改内容");
+        }
+        if(type == -1){
+            return buildJson(-1,"参数错误");
+        }
+        if(type == 1){
+            UserQueryCondition qc = new UserQueryCondition();
+            String phoneLogo = conment.substring(Constants.FASTDFS_CLIENT_SERVER.length());
+            user.setPhoneLogo(phoneLogo);
+            qc.setUserId(user.getUserId());
+            qc.setEntity(user);
+            //修改密码
+            userService.updateUser(qc);
+            return buildJson(0,"修改成功");
+        }else if(type == 2){
+            UserQueryCondition qc = new UserQueryCondition();
+            user.setUserMail(conment);
+            qc.setUserId(user.getUserId());
+            qc.setEntity(user);
+            userService.updateUser(qc);
+            return buildJson(0,"修改成功");
+        }else if(type == 3){
+            Store store = basicService.getStoreById(user.getStoreId());
+            store.setAddress(conment);
+            boolean isSuccess = basicService.updateShotrAddress(store);
+            // 同步成功后,删除门店缓存
+            if (isSuccess) {
+                CacheTool cacheTool = CacheTool.initStore();
+                Store store1 = basicService.getStoreById(user.getStoreId());
+                cacheTool.saveBean(user.getStoreId() + "", store1);
+                log.info("门店信息更新,删除store缓存,门店ID:" + user.getStoreId());
+            }
+            return buildJson(0,"修改成功");
+        }
+        return buildJson(-1,"修改失败");
+    }
+    //修改门店信息,营业时间,短地址,客服电话
+    @RequestMapping(value = "/app/changeStoreMessage" )
+    @ResponseBody
+    public Object changeStoreMessage(HttpServletRequest request,
+                                @RequestParam(defaultValue = "0") int configId,
+                                @RequestParam(defaultValue = "") String shortAddress,
+                                @RequestParam(defaultValue = "") String startTime,
+                                @RequestParam(defaultValue = "") String endTime,
+                                @RequestParam(defaultValue = "") String takeExpressPhone) throws InvocationTargetException, IllegalAccessException {
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1,"用户未登录");
+        }
+        if(null != shortAddress || !"".equals(shortAddress) || null != takeExpressPhone || !"".equals(takeExpressPhone)){
+            if (null != shortAddress && !"".equals(shortAddress) && shortAddress.length() > 20 || !_.isPhoneNum(takeExpressPhone)) {
+                return buildJson(-1, "非法参数~");
+            }
+            UserQueryCondition condition = new UserQueryCondition();
+            condition.setUserId(user.getUserId());
+            user.setShortAddress(shortAddress);
+           /* if (!isEmpty(takeExpressPhone)) {
+                user.setTelPhone(takeExpressPhone);
+            }*/
+            condition.setEntity(user);
+            userService.updateUser(condition);
+        }
+        //add 2018-03-19 同步更新fhm
+		/*if(isNumeric(user.getUserId())){
+			updateSendType(user.getSmsSendType(),user.getUserId());
+		}else{
+			updateSendType(user.getSmsSendType(),user.getUserName());
+		}*/
+        //修改短地址时才会操作
+        if(null != shortAddress && !"".equals(shortAddress)){
+            // 配置信息 BS短信模板
+            DeliveryMsgTemplateConfig msgTemplateConfig = new DeliveryMsgTemplateConfig();
+            msgTemplateConfig.setId(configId);
+            msgTemplateConfig.setStoreId(user.getStoreId());
+            msgTemplateConfig.setType(Constants.MSG_TYPE_SMS);
+            msgTemplateConfig.setStoreAddress(shortAddress);
+
+            // 巴枪短信模板
+            DeliveryMsgTemplateConfig msgTemplateConfig2 = deliveryMsgTemplateConfigService.getMsgTemplateConfig(user.getStoreId(), Constants.CLIENT_TYPE_STORE_LITE_2, Constants.MSG_TYPE_SMS);
+            if (msgTemplateConfig2 == null) {
+                msgTemplateConfig2 = new DeliveryMsgTemplateConfig();
+            }
+            msgTemplateConfig2.setStoreAddress(msgTemplateConfig.getStoreAddress());
+            if (configId > 0) {
+                msgTemplateConfig.setUpdateTime(new Date());
+                deliveryMsgTemplateConfigService.updateById(msgTemplateConfig);
+
+                msgTemplateConfig2.setUpdateTime(new Date());
+                deliveryMsgTemplateConfigService.updateById(msgTemplateConfig2);
+            } else {
+                msgTemplateConfig.setClientType(Constants.CLIENT_TYPE_BS_2);
+                msgTemplateConfig.setContainsTakeCode(1);
+                msgTemplateConfig.setCreateTime(new Date());
+                deliveryMsgTemplateConfigService.save(msgTemplateConfig);
+
+                if (msgTemplateConfig2 != null) {
+                    BeanUtils.copyProperties(msgTemplateConfig2, msgTemplateConfig);
+                    msgTemplateConfig2.setClientType(Constants.CLIENT_TYPE_STORE_LITE_2);
+                    deliveryMsgTemplateConfigService.save(msgTemplateConfig2);
+                }
+            }
+        }
+
+        // 同步usercenter
+        Store store = basicService.getStoreById(user.getStoreId());
+        if(null != startTime && !"".equals(startTime)){
+            store.setStartTime(startTime);
+        }
+        if(null != endTime && !"".equals(endTime)){
+            store.setEndTime(endTime);
+        }
+        store.setUpdateTime(new Date());
+        if(null != shortAddress && !"".equals(shortAddress)){
+            store.setShortAddress(shortAddress);
+        }
+        if(null != takeExpressPhone && !"".equals(takeExpressPhone)){
+            store.setTakeExpressPhone(takeExpressPhone);
+        }
+        boolean isSuccess = basicService.update(store);
+        // 同步成功后,删除门店缓存
+        if (isSuccess) {
+            CacheTool cacheTool = CacheTool.initStore();
+            Store store1 = basicService.getStoreById(user.getStoreId());
+            cacheTool.saveBean(user.getStoreId() + "", store1);
+            log.info("门店信息更新,删除store缓存,门店ID:" + user.getStoreId());
+        }
+
+        return buildJson(0, "操作成功");
+    }
+    //在缓存中保存验证码
+    private void saveCacheCode(String userPhone,String codeKey, String code) {
+        jedis.set(codeKey + userPhone,code,120);
+    }
+    //在缓存中取验证码
+    private String getCachecode(String userPhone,String codekey) {
+        return  jedis.get(codekey + userPhone);
+    }
+    //生成6为数的验证码
+    private String getAppCode() {
+        int n = 6;
+        StringBuilder code = new StringBuilder();
+        Random ran = new Random();
+        for (int i = 0; i < n; i++) {
+            code.append(Integer.valueOf(ran.nextInt(10)).toString());
+        }
+        return code.toString();
+    }
+}

+ 94 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppGetStorePhoneController.java

@@ -0,0 +1,94 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.toolkit.CacheTool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+
+/** 获取门店电话号码
+ * Created by Administrator on 2019/2/25 0025.
+ */
+@Controller
+public class AppGetStorePhoneController extends BaseController{
+    private static final Logger log = LoggerFactory
+            .getLogger(AppGetStorePhoneController.class);
+
+    @RequestMapping(value = "/app/getStorePhone")
+    public synchronized void queryStoreAllPhone(HttpServletRequest request,HttpServletResponse response)  {
+       User user = getUserFromParam(request);
+        if(user == null){
+            log.info("登录超时");
+        }
+        File file = createXml(user.getStoreId());
+        FileInputStream  fis= null;
+        OutputStream out = null;
+        response.setContentType("xml");
+        response.setCharacterEncoding("utf-8");
+        try {
+            fis =  new FileInputStream(file);
+            byte[] b = new byte[fis.available()];
+            fis.read(b);
+            out = response.getOutputStream();
+            out.write(b);
+            out.flush();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }finally {
+            try {
+                out.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * 生成xml方法
+     */
+    private File createXml(int storeId){
+        File file = new File("phones.xml");
+        try {
+            // 1、生成一个根节点
+            Element phone = new Element("phones");
+            // 3、生成一个document对象
+            Document document = new Document(phone);
+
+            Element body = new Element("phone");
+            CacheTool cacheTool = CacheTool.initPhone();
+            String phones = cacheTool.getString(storeId + "");
+            if(null != phones){
+                body.setText(phones);
+            }else {
+                body.setText("\"\"");
+            }
+
+            phone.addContent(body);
+
+            Format format = Format.getCompactFormat();
+            // 设置换行Tab或空格
+            format.setIndent("	");
+            format.setEncoding("UTF-8");
+
+            // 4、创建XMLOutputter的对象
+            XMLOutputter outputer = new XMLOutputter(format);
+            // 5、利用outputer将document转换成xml文档
+            outputer.output(document, new FileOutputStream(file));
+
+           log.info("生成phones.xml成功");
+        } catch (Exception e) {
+            log.info("生成phones.xml失败");
+        }
+        return file;
+    }
+}

+ 1551 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppQueryAction.java

@@ -0,0 +1,1551 @@
+package cn.haliaeetus.controller.appdevapi;
+
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.enums.SMSErrorCodeEnum;
+import cn.haliaeetus.controller.web.enums.StatusCodeEnum;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.dao.UserDao;
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.entity.dto.DeliveryDto;
+import cn.haliaeetus.entity.dto.QueryPageDto;
+import cn.haliaeetus.entity.dto.QueryPageSubDto;
+import cn.haliaeetus.entity.esdto.ESDeliveryQueryCondition;
+import cn.haliaeetus.entity.jspo.JDeliveryDto;
+import cn.haliaeetus.entity.jspo.JsonMsg;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.toolkit.PagedList;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.framework.util.HttpUtil;
+import cn.haliaeetus.service.*;
+import cn.haliaeetus.service.rsync.ConsumeRecordService;
+import com.google.gson.JsonObject;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static cn.haliaeetus.framework._.*;
+
+/**
+ * 查询 发送短信
+ * Created by Administrator on 2018/12/12 0012.
+ * APP首页查询类
+ */
+@Controller
+public class AppQueryAction extends BaseController {
+    @Autowired
+    private BasicInfoService basicInfoService;
+    @Autowired
+    private StoreStaffService storeStaffService;
+    @Autowired
+    private StatService statService;
+    @Autowired
+    private DeliveryService deliveryService;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private DeliveryScanBatchService scanBatchService;
+    @Autowired
+    private TypeLibraryService typeLibraryService;
+
+
+    @Autowired
+    private UserDao userDao;
+
+    @Autowired
+    private SmsRecordService smsRecordService;
+
+    @Autowired
+    private ConsumeRecordService consumeRecordService;
+
+
+    @Autowired
+    private WhiteListService whiteListService;
+
+    private static List<ExpressType> expressList = new ArrayList<>();
+
+
+    @RequestMapping(value = {"/app/api/v1/appquery"})
+    @ResponseBody
+    public Object appQuery(HttpServletRequest request) throws Exception,
+            ParseException {
+        User user = getUserFromParam(request);
+        /*String md5Pwd = Md5Util.md5AsLowerHex(password);
+        User user = userService.getUserByIdAndPwd(userId, md5Pwd);*/
+        //根据时间和用户id查询这天的数据
+        if (null == user) {
+            return buildJson(1, "用户未登录");
+        }
+        int storeId = user.getStoreId();
+        Store store = basicInfoService.getStoreById(storeId);
+        /*List<Integer> deliveryExpList = formatIds(store.getDispatchIds(), ",");
+        for(Integer a:deliveryExpList){
+            List<ExpressType> tmp=getRemoteExpressList(a);
+            if(tmp!=null){
+                expressList.add(tmp.get(0));
+            }
+        }*/
+        List<ExpressType> expressList = basicInfoService.getAllExpressList();
+        //获取首页当日实时统计
+        JsonObject data = new JsonObject();
+        data.addProperty("today_instore", getTodayIn(storeId)); // 今日入库
+        data.addProperty("all_instore", getSignStatusCount(storeId)); // 未签收
+        data.addProperty("smsBalance", user.getSmsBalance());//余额*/
+        /*data.addProperty("today_instore", 5); // 今日入库
+        data.addProperty("all_instore", 3); // 未签收
+        data.addProperty("smsBalance",255);//余额*/
+        String beginTime1 = DateUtil.today().toString("yyyy-MM-dd");
+        String endTime1 = DateUtil.today().toString("yyyy-MM-dd");
+        String time1 = beginTime1.trim() + " 00:00:00";
+        String time2 = endTime1.trim() + " 23:59:59";
+
+        //TODO add2019-04-04 today_todo
+        DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
+        qc.setExpId(0);
+        qc.setShelfId(0);
+        qc.setCreateTime(time1, time2);
+        ArrayList<Integer> statusList = new ArrayList<>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        qc.setStatusStr(statusList);
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        String subSql = " and userPhone = '' ";
+        qc.setSubSql(subSql);
+        qc.setP(1);
+        qc.setBegin(0);
+        qc.setPageSize(10000);
+        QueryPageDto pageDto = deliveryService.getQueryPageDto(qc, expressList);
+        PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
+        if (deliveryPagedList != null && deliveryPagedList.getItems() != null) {
+            data.addProperty("today_todo", deliveryPagedList.getItems().size());
+        } else {
+            data.addProperty("today_todo", 0);
+        }
+        //未通知 短信未发送
+        Integer notice = this.getNotSendAmount(storeId, expressList, time1, time2, -1);
+        data.addProperty("notice", notice);
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("code", 0);
+        jsonObject.addProperty("msg", "");
+        jsonObject.add("data", data);
+        return jsonObject.toString();
+    }
+
+    @RequestMapping(value = {"/app/api/v1/querytest"})
+    @ResponseBody
+    public Object query() {
+        Map reqMap = new HashMap();
+        reqMap.put("_haliaeetus_userId_", "15355426462");
+        reqMap.put("_haliaeetus_web_", "f9445af5eb6e86353cc2a7cf0b621126");
+        reqMap.put("p", "1");
+        reqMap.put("pageSize", "20");
+        reqMap.put("beginTime", "2019-06-04");
+        reqMap.put("endTime", "2019-06-04");
+        reqMap.put("type", "ALL");
+        reqMap.put("smsStatus", "0");
+        reqMap.put("queryType", "1");
+        reqMap.put("pageType", "1");
+        String url = "http://87.fengzhan100.com/app/api/v1/query";
+        String res = HttpUtil.post(url, reqMap);
+        return res;
+    }
+
+    //返回参数   快递 是否签收 用户手机号  面单号 取货码 入库时间 签收时间 是否通知   未通知 成功数 失败数 通知数
+    //首页搜索查询
+    @Autowired
+    private AccessLimitService accessLimitService;
+
+    @RequestMapping(value = {"/app/api/v1/query/old"})
+    @ResponseBody
+    public Object query(HttpServletRequest request,
+                        @RequestParam(defaultValue = "1") String p,//第几页
+                        @RequestParam(defaultValue = "20") String pageSize,//每页多少
+                        @RequestParam(defaultValue = "") String beginTime,//查询入库开始时间
+                        @RequestParam(defaultValue = "") String endTime,//查询入库结束时间
+                        @RequestParam(defaultValue = "ALL") String type,//All全部  未入库,已到库,已出库
+                        @RequestParam(defaultValue = "0") String expId,//快递公司,手机号
+                        @RequestParam(defaultValue = "0") String shelfId,//
+                        @RequestParam(defaultValue = "") String smsType,//通知类型短信或者微信
+                        @RequestParam(defaultValue = "-2") String smsStatus,//通知状态
+                        @RequestParam(defaultValue = "") String expcode,
+                        @RequestParam(defaultValue = "1") String queryType,//查询类型1面单号
+                        @RequestParam(defaultValue = "-1") String search,
+                        @RequestParam(defaultValue = "-1") String pageType,//页面访问类型
+                        @RequestParam(defaultValue = "-1") String requestSign,//解决查询结果出错的
+                        @RequestParam(defaultValue = "-1") String sort) throws SQLException,
+            ParseException {
+
+        if (!accessLimitService.tryAcquire()) {
+            return buildJson(1, "");
+        }
+//        Map reqMap = new HashMap();
+        String userId = request.getParameter(COOKIE_USERID);
+        StoreReqLimit storeReqLimit = basicInfoService.getStoreReqLimitByUserId(userId + "query");
+        if (storeReqLimit.getIsLimitFlag()) {
+            return buildJson(1, "");
+        }
+//        String password = request.getParameter(COOKIE_KEY);
+//        reqMap.put("_haliaeetus_userId_",userId);
+//        reqMap.put("_haliaeetus_web_",password);
+//        reqMap.put("p",p);
+//        reqMap.put("pageSize",pageSize);
+//        reqMap.put("beginTime",beginTime);
+//        reqMap.put("endTime",endTime);
+//        reqMap.put("type",type);
+//        reqMap.put("expId",expId);
+//        reqMap.put("shelfId",shelfId);
+//        reqMap.put("smsType",smsType);
+//        reqMap.put("smsStatus",smsStatus);
+//        reqMap.put("expcode",expcode);
+//        reqMap.put("queryType",queryType);
+//        reqMap.put("search",search);
+//        reqMap.put("pageType",pageType);
+//        reqMap.put("sort",sort);
+//        String searchPhoenixTestIP=basicInfoService.getConfigurationByCode("searchPhoenixTestIP").getOValue1();
+//        String url1 = "http://"+searchPhoenixTestIP+"/app/api/v1/query";
+//        String res = HttpUtil.post(url1,reqMap);
+//        return res;
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+        int storeId = user.getStoreId();
+        long now = System.currentTimeMillis();
+        int p1 = Integer.parseInt(p);
+        p1 = max(1, p1);
+        int begin = (p1 - 1) * Integer.parseInt(pageSize);
+
+        DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
+        //分页不是默认值就设值
+        if (Integer.parseInt(pageSize) != 20) {
+            qc.setPageSize(Integer.parseInt(pageSize));
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        /*if(!smsStatus.equals("3")){*/
+        Date date = new Date();
+        if (null == beginTime || "".equals(beginTime)) {
+            beginTime = sdf.format(date);
+        }
+        if (null == endTime || "".equals(endTime)) {
+            endTime = sdf.format(date);
+        }
+        /*}*/
+
+        //判断今天、近一月
+        String time1 = "";
+        if (!beginTime.equals("")) {
+            time1 = beginTime.trim() + " 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(time1));
+        }
+        String time2 = "";
+        if (!endTime.equals("")) {
+            time2 = endTime.trim() + " 23:59:59";
+            qc.setEndTime(Timestamp.valueOf(time2));
+        }
+        endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);
+        // 封装查询条件
+        List<Integer> statusList = new ArrayList<Integer>();
+        qc.setP(p1);
+        qc.setBegin(begin);
+        if (smsType.equals("短信") || smsType.equals("1")) {
+            qc.setSmsType(1);
+        } else if (smsType.equals("微信") || smsType.equals("2")) {
+            qc.setSmsType(2);
+        } else {
+            qc.setSmsType(0);//0为查询全部
+        }
+        qc.setSmsStatus(Integer.valueOf(smsStatus));//通知状态
+        //状态和类型没处理
+        switch (type) {
+            case "ALL": // 全部
+                qc.setCreateTime(beginTime, endTime);
+                break;
+            case "NOSTORE": // 未到貨
+                qc.setCreateTime(beginTime, endTime);
+                // qc.setShelfId(0);
+                break;
+            case "WAITINSTORE": // 待入庫
+                //statusList.add(Constants.ORDER_STATUS_WAIT_IN_STORE);
+                //qc.setStatusStr(statusList);
+                qc.setCreateTime(beginTime, endTime);
+                break;
+            case "INSTORE": // 已入库
+                statusList.add(Constants.ORDER_STATUS_STORED);
+                statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+                qc.setStatusStr(statusList);
+                break;
+            case "OUTSTORE": // 已出库
+                statusList.add(Constants.ORDER_STATUS_COMPLETE);
+                qc.setStatusStr(statusList);
+                break;
+            case "ALLDISPATCH":// 所有派送中
+                statusList.add(Constants.ORDER_STATUS_MAIKE_DISPATCHING);
+                statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+                qc.setStatusStr(statusList);
+                break;
+            case "DISPATCH": // 派送中
+                statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+                qc.setStatusStr(statusList);
+                break;
+            case "MKDISPATCH": // 麦客配送中
+                statusList.add(Constants.ORDER_STATUS_MAIKE_DISPATCHING);
+                qc.setStatusStr(statusList);
+                break;
+            case "LEAVESTORE": // 离库
+                statusList.add(Constants.ORDER_STATUS_LEAVE_STORE);
+                statusList.add(Constants.ORDER_STATUS_REJECT_LEAVE_STORE);
+                qc.setStatusStr(statusList);
+                break;
+            case "ALLINSTORE": // 总在库
+                String todayt = DateUtil.today().toString("yyyy-MM-dd");
+                String tomorrowt = DateUtil.addDay(todayt, "yyyy-MM-dd", 1);
+//			String before10dayst = DateUtil.addDay(todayt, "yyyy-MM-dd", -10);
+                statusList.add(Constants.ORDER_STATUS_STORED);
+                statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+                statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+                qc.setStatusStr(statusList);
+//			qc.setCreateTime(before10dayst, tomorrowt);
+                qc.setCreateTime(beginTime, endTime);
+                qc.setBeginTime(sdf.parse(beginTime));
+                qc.setEndTime(sdf.parse(endTime));
+                break;
+            case "WHITELIST":// 白名单
+                qc.setIswhite(1);
+                qc.setCreateTime(beginTime, endTime);
+                break;
+            case "INDEX":
+                beginTime = DateUtil.addMonth(beginTime, "yyyy-MM-dd", -1);
+                qc.setCreateTime(beginTime, endTime);
+                break;
+        }
+        if (!"ALLINSTORE".equals(type) && !"ALLDISPATCH".equals(type)
+                && !"ALL".equals(type) && !"INDEX".equals(type)
+                && !"WHITELIST".equals(type) && !"NOSTORE".equals(type)) {
+            qc.setStatusTime(beginTime, endTime);
+        }
+
+        String subSql = "";
+        if (!"WHITELIST".equals(type)) {
+            subSql = getSubSql(expcode, Integer.valueOf(queryType));
+        }
+
+        if (!subSql.equals("")) {
+            qc.setSubSql(subSql);
+        }
+
+        //根据店铺id查询当前店铺的白名单客户
+        List<WhiteList> list = whiteListService.getByStoreId(user.getStoreId());
+        Map map = new HashMap();
+        for (WhiteList white : list) {
+            map.put(white.getUsermobile(), white);
+        }
+
+        qc.setExpId(Integer.valueOf(expId));
+        qc.setShelfId(Integer.valueOf(shelfId));
+
+        QueryPageDto pageDto = null;
+        QueryPageSubDto pageSubDto = null;
+        JsonMsg jsonMsg = JsonMsg.getSuccess();
+        if (Integer.valueOf(smsStatus) != -2) {
+            qc.setSmsStatus(Integer.valueOf(smsStatus));
+            qc.setOrderField("createTime");
+            qc.setOrder("desc");
+            subSql = getSubSql(expcode, Integer.valueOf(queryType));
+//		if (!subSql.equals("")) {
+//			qc.setSubSql(subSql);
+//		}
+            //subSql +=  " and userPhone > ''  and odeliveryType<>'PS' ";
+            if (null == search || search.equals("-1") || "".equals(search)) {
+                subSql += " and userPhone > '' ";
+            }
+            qc.setSubSql(subSql);
+
+
+            qc.setPageSize(Integer.parseInt(pageSize));
+            List<Integer> statusList1 = new ArrayList<Integer>();
+            if ("1".equals(pageType)) {
+                //只查在库单子
+                statusList1.add(122);
+                //滞留
+                statusList1.add(124);
+                statusList1.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+                statusList1.add(Constants.ORDER_STATUS_COMPLETE);
+                statusList1.add(Constants.ORDER_STATUS_LEAVE_STORE);
+            } else if (!"3".equals(smsStatus)) {
+                //只查在库单子
+                statusList1.add(122);
+                //滞留
+                statusList1.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+            } else {
+                //只查在库单子
+                statusList1.add(122);
+                //滞留
+                statusList1.add(124);
+                statusList1.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+            }
+            //只查在库单子
+//            statusList1.add(122);
+            //statusList.add(126);
+//            statusList1.add(124);
+            //滞留
+//            statusList1.add(Constants.ORDER_STATUS_REJECT_RETENTION );
+            //已完成的
+            if (null != search && search.equals("0")) {
+                statusList1.add(Constants.ORDER_STATUS_COMPLETE);
+                statusList1.add(Constants.ORDER_STATUS_LEAVE_STORE);
+            }
+            qc.setStatusStr(statusList1);
+            pageSubDto = deliveryService.appGetSmsFail4Page(qc);
+            pageDtos(pageSubDto);
+            jsonMsg.add("list", getJDeliveryDto(pageSubDto.getPageList(), map, pageType));
+            jsonMsg.add("curPage", pageSubDto.getPageList().getCurPage());
+            jsonMsg.add("totalPages", pageSubDto.getPageList().getTotalPages());
+            //总条数
+            jsonMsg.add("totalCount", pageSubDto.getPageList().getTotal());
+            int noTice = pageSubDto.getNoTice();
+            int scuessTice = pageSubDto.getScuessTice();
+            int fileTice = pageSubDto.getFileTice();
+            jsonMsg.add("noTice", noTice);
+//            jsonMsg.add("noTice",getJDeliveryDto(pageSubDto.getPageList(),map).size());
+            jsonMsg.add("scuessTice", scuessTice);
+            jsonMsg.add("fileTice", fileTice);
+            jsonMsg.add("sendTice", scuessTice + fileTice);//已发送
+        } else {
+            if ("NOSTORE".equals(type)) {
+                // 未到货逻辑
+                subSql = getNoArriveSubSql(expcode, Integer.valueOf(queryType));
+                qc.setSubSql(subSql);
+                pageDto = deliveryService.getNoArrive4Page(qc);
+                jsonMsg.add("list", getJDeliveryDto(pageDto.getPageList(), map, pageType));
+                jsonMsg.add("curPage", pageDto.getPageList().getCurPage());
+                jsonMsg.add("totalPages", pageDto.getPageList().getTotalPages());
+                //总条数
+                jsonMsg.add("totalCount", pageDto.getPageList().getTotal());
+                //jdto.setjDeliveryDto(getJDeliveryDto(pageDto.getPageList()));
+                // request.setAttribute("pages", pageDto.getPageList());
+            } else if ("WAITINSTORE".equals(type)) {
+                // 待入库,下车扫描
+                subSql = getNoArriveSubSql(expcode, Integer.valueOf(queryType));
+                qc.setSubSql(subSql);
+                pageDto = deliveryService.getWaitInStore4Page(qc);
+                jsonMsg.add("list", getJDeliveryDto(pageDto.getPageList(), map, pageType));
+                jsonMsg.add("curPage", pageDto.getPageList().getCurPage());
+                jsonMsg.add("totalPages", pageDto.getPageList().getTotalPages());
+                //总条数
+                jsonMsg.add("totalCount", pageDto.getPageList().getTotal());
+                //jdto.setjDeliveryDto(getJDeliveryDto(pageDto.getPageList()));
+                //request.setAttribute("pages", pageDto.getPageList());
+            } else {
+
+                qc.setOrderField("createTime");
+                qc.setOrder("desc");
+                switch (Integer.valueOf(sort)) {
+                    case 0:
+                        qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
+                        qc.setOrder("asc");
+                        // sqlEnd = " order by (d.shelfCode+0)";
+                        break;
+                    case 1:
+                        // sqlEnd = " order by (d.shelfCode+0) desc";
+                        qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
+                        qc.setOrder("desc");
+                        break;
+                }
+
+                pageDto = deliveryService.getQueryPageDto(qc);
+                pageDtos(pageDto);
+                jsonMsg.add("list", getJDeliveryDto(pageDto.getPageList(), map, pageType));
+                jsonMsg.add("curPage", pageDto.getPageList().getCurPage());
+                jsonMsg.add("totalPages", pageDto.getPageList().getTotalPages());
+                //总条数
+                jsonMsg.add("totalCount", pageDto.getPageList().getTotal());
+                // jdto.setjDeliveryDto(getJDeliveryDto(pageDto.getPageList()));
+                //  request.setAttribute("pages", pageDto.getPageList());
+            }
+            jsonMsg.add("noTice", 0);
+            jsonMsg.add("scuessTice", 0);
+            jsonMsg.add("fileTice", 0);
+            jsonMsg.add("sendTice", 0);//已发送*/
+        }
+        jsonMsg.add("requestSign", requestSign);
+        log.info("bs2.sql.delivery.query.time:"
+                + (int) (System.currentTimeMillis() - now));
+        log.info("bs2.sql.delivery.query.storeid:" + storeId);
+        return jsonMsg;
+    }
+
+    /**
+     * 根据查询条件发送短信
+     */
+    @RequestMapping(value = {"/app/api/v1/querySmsSend"})
+    @ResponseBody
+    public Object querySmsSend(HttpServletRequest request,
+                               @RequestParam(defaultValue = "") String beginTime,//查询入库开始时间
+                               @RequestParam(defaultValue = "") String endTime,//查询入库结束时间
+                               @RequestParam(defaultValue = "1") String smsType,//通知类型短信或者微信
+                               @RequestParam(defaultValue = "-1") String smsStatus,//通知状态
+                               @RequestParam(defaultValue = "") String expcode,
+                               @RequestParam(defaultValue = "1") String queryType,//查询类型1面单号
+                               @RequestParam(defaultValue = "-1") String sort) throws SQLException,
+            ParseException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+        int storeId = user.getStoreId();
+        long now = System.currentTimeMillis();
+        DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = new Date();
+        if (null == beginTime || "".equals(beginTime)) {
+            beginTime = sdf.format(date);
+        }
+        if (null == endTime || "".equals(endTime)) {
+            endTime = sdf.format(date);
+        }
+        //判断今天、近一月
+        String time1 = "";
+        if (!beginTime.equals("")) {
+            time1 = beginTime.trim() + " 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(time1));
+        }
+        String time2 = "";
+        if (!endTime.equals("")) {
+            time2 = endTime.trim() + " 23:59:59";
+            qc.setEndTime(Timestamp.valueOf(time2));
+        }
+        endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);
+        // 封装查询条件
+        List<Integer> statusList = new ArrayList<Integer>();
+
+//        qc.setSmsType(Integer.valueOf(smsType));//通知类型
+        qc.setSmsStatus(Integer.valueOf(smsStatus));//通知状态
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+
+        //状态和类型没处理
+        qc.setCreateTime(beginTime, endTime);
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+        qc.setStatusStr(statusList);
+        if (null == smsStatus || "".equals(smsStatus)) {
+            qc.setSmsStatus(-1);
+        }
+        qc.setSmsStatus(Integer.valueOf(smsStatus));
+        //qc.setSignStatus("0");
+        String subSql = " and userPhone > ''  and odeliveryType<>'PS' ";
+      /*  if(null != queryType){
+            String querySubSql = getSubSql(expcode,Integer.parseInt(queryType));
+            if(!"".equals(querySubSql)){
+                subSql += querySubSql;
+            }
+        }*/
+        qc.setSubSql(subSql);
+        String result = deliveryService.appGetSendSmsdeliveryIds(qc);
+        if (null == result || "".equals(result)) {
+            return buildJson(-1, "没有可发送短信单号");
+        }
+        String[] ids = result.split(",");
+        //发送短信
+        if ((user.getIsSmsFree() == null || user.getIsSmsFree() == Constants.NO)) {
+            int size = ids.length;
+            BigDecimal consume = calConsume(user.getSmsPrice(), size);
+            if ((user.getSmsBalance() == null || user.getSmsBalance().compareTo(consume) <= 0)) {
+                return buildJson(66, "余额不足,请先充值");
+            }
+        }
+        try {
+            /*deliveryService.resendAllSmsBatch(user, ids);*/
+            deliveryService.resendAllSms4app(user, ids);
+        } catch (Exception e) {
+            return buildJson(-1, "发送失败");
+        }
+        JsonMsg jsonMsg = JsonMsg.getSuccess();
+        jsonMsg.setMsg("发送成功");
+        jsonMsg.add("result", result);
+        return jsonMsg;
+    }
+
+    private BigDecimal calConsume(BigDecimal smsPrice, int smsCount) {
+        if (smsPrice == null) {
+            return BigDecimal.ZERO;
+        }
+        return smsPrice.multiply(new BigDecimal(smsCount));
+    }
+
+    /**
+     * 完善散单
+     */
+    @RequestMapping("/app/api/v1/complete")
+    @ResponseBody
+    public Object appComplete(HttpServletRequest request,
+                              @RequestParam(defaultValue = "1") String p,
+                              @RequestParam(defaultValue = "20") String pageSize,
+                              @RequestParam(defaultValue = "") String beginTime,
+                              @RequestParam(defaultValue = "") String endTime,
+                              @RequestParam(defaultValue = "UNCOMPLETE") String type,
+                              @RequestParam(defaultValue = "0") int expId,
+                              @RequestParam(defaultValue = "0") int shelfId,
+                              @RequestParam(defaultValue = "") String expcode,
+                              @RequestParam(defaultValue = "1") int queryType,
+                              @RequestParam(defaultValue = "ALL") String odeliverytype,
+                              @RequestParam(defaultValue = "-1") int offset,
+                              @RequestParam(defaultValue = "-1") int sort) throws SQLException,
+            ParseException {
+        User user = getUserFromParam(request);
+        int storeId = user.getStoreId();
+        int p2 = max(1, Integer.parseInt(p));
+        int begin = (p2 - 1) * Integer.parseInt(pageSize);
+
+        DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
+        //判断今天、近一月
+        if (!beginTime.equals("")) {
+            String time = beginTime.trim() + " 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(time));
+        }
+        if (!endTime.equals("")) {
+            String time = endTime.trim() + " 23:59:59";
+            qc.setEndTime(Timestamp.valueOf(time));
+        }
+
+        if (offset == -1) {
+            if (isEmpty(beginTime))
+                beginTime = DateUtil.today().toString("yyyy-MM-dd");
+            if (isEmpty(endTime))
+                endTime = DateUtil.today().toString("yyyy-MM-dd");
+
+            endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);
+        } else {
+            String today = DateUtil.today().toString("yyyy-MM-dd");
+            beginTime = DateUtil.addDay(today, "yyyy-MM-dd", -offset);
+            endTime = DateUtil.addDay(today, "yyyy-MM-dd", 1);
+        }
+
+        // 封装查询条件
+
+        qc.setP(Integer.parseInt(p));
+        qc.setBegin(begin);
+
+        String subSql = getSubSql(expcode, queryType);
+
+        //queryTye = 2表示根据手机号模糊查询,以下逻辑可优化
+        if (!"ALL".equals(type)) {
+            switch (type) {
+                case "UNCOMPLETE": // 未完善
+                    subSql += " and userPhone = '' ";
+                    break;
+                case "COMPLETED": // 已完善
+                    subSql += " and  userPhone > '' ";
+                    break;
+            }
+        }
+
+        if (!subSql.equals("")) {
+            qc.setSubSql(subSql);
+        }
+
+        if (!"ALL".equals(odeliverytype)) {
+            if ("PS".equals(odeliverytype)) {
+                qc.setOdeliveryType(odeliverytype);
+            } else {
+                qc.setOdeliveryType("ZI','P2P");
+            }
+
+        }
+
+        qc.setExpId(expId);
+        qc.setShelfId(shelfId);
+
+        qc.setCreateTime(beginTime, endTime);
+
+        ArrayList<Integer> statusList = new ArrayList<>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+//        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        qc.setStatusStr(statusList);
+
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        switch (sort) {
+            case 0:
+                qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
+                qc.setOrder("asc");
+                break;
+            case 1:
+                qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
+                qc.setOrder("desc");
+                break;
+        }
+
+        QueryPageDto pageDto = deliveryService.getQueryPageDto(qc);
+
+
+        for (DeliveryDto d : pageDto.getPageList().getItems()) {
+            List<DeliveryScanBatch> deliveryScanBatches = scanBatchService.getByCondition(d.getDelivery().getStoreId(), d.getDelivery().getExpcode(), d.getDelivery().getExpId(), null, null, null);
+            if (d.getDelivery().getUserPhone() != null) {
+                if (deliveryScanBatches.size() > 0 && "2".equals(deliveryScanBatches.get(0).getOcrStatus())) {
+                    StringBuilder number = new StringBuilder(d.getDelivery().getUserPhone());
+                    if (org.apache.commons.lang.StringUtils.isEmpty(d.getDelivery().getUserPhone()) || org.apache.commons.lang.StringUtils.isBlank(d.getDelivery().getUserPhone())) {
+                        number.append("");
+                    } else {
+                        number.replace(3, 10, "*******");
+                    }//number.replace(3, 10, "*******");
+                    d.getDelivery().setUserPhone(number.toString());
+                }
+            }
+        }
+
+        PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
+        //货架
+        List<StoreShelf> storeShelfs = pageDto.getStoreShelfs();
+
+        //根据店铺id查询当前店铺的白名单客户
+        List<WhiteList> list = whiteListService.getByStoreId(user.getStoreId());
+        Map map = new HashMap();
+        for (WhiteList white : list) {
+            map.put(white.getUsermobile(), white);
+        }
+
+        JsonMsg jsonMsg = JsonMsg.getSuccess();
+        jsonMsg.add("list", getJDeliveryDto(deliveryPagedList, map, "-1"));
+        jsonMsg.add("shelfList", storeShelfs);
+        jsonMsg.add("curPage", pageDto.getPageList().getCurPage());
+        jsonMsg.add("totalPages", pageDto.getPageList().getTotalPages());
+
+        return jsonMsg;
+    }
+
+    /**
+     * 根据id查询单条
+     */
+    @RequestMapping("/app/api/v1/queryOne")
+    @ResponseBody
+    public Object appQueryOne(HttpServletRequest request,
+                              @RequestParam(defaultValue = "") String deliveryId) throws SQLException,
+            ParseException {
+        User user = getUserFromParam(request);
+        if (null == user) {
+            return buildJson(1, "用户未登录");
+        }
+        if (null == deliveryId || "".equals(deliveryId)) {
+            return buildJson(-1, "快件id错误");
+        }
+        DeliveryDto deliveryDto = deliveryService.getByIdDeliveryDto(user.getStoreId(), Integer.parseInt(deliveryId));
+        if (null == deliveryDto) {
+            return buildJson(-1, "快件不存在");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        JDeliveryDto jdo = new JDeliveryDto();
+        Delivery delivery = deliveryDto.getDelivery();
+        List<ExpressType> expressTypes = basicInfoService.getAllExpressMapMemcached();
+        for (ExpressType expressType : expressTypes) {
+            if (expressType.getId().intValue() == delivery.getExpId().intValue()) {
+                jdo.setExpId(expressType.getExpId());
+                jdo.setExpName(expressType.getExpName());
+                break;
+            }
+        }
+        if (null != delivery.getCreateTime() && !"".equals(delivery.getCreateTime())) {
+            jdo.setCreateTime(sdf.format(delivery.getCreateTime()));
+        }
+        jdo.setId(delivery.getId());
+        jdo.setExpcode(delivery.getExpcode());
+        jdo.setShelfCode(delivery.getShelfCode());
+        if (null != delivery.getSignDtm() && !"".equals(delivery.getSignDtm())) {
+            jdo.setSignDtm(sdf.format(delivery.getSignDtm()));
+        }
+        jdo.setStatus(delivery.getStatus());
+        jdo.setUserPhone(delivery.getUserPhone());
+        jdo.setSmsStatus(deliveryDto.getSmsStatus());
+        jdo.setShelfId(delivery.getShelfId());
+        jdo.setDeliveryUid(delivery.getDeliveryUid());
+        jdo.setDeliveryUname(delivery.getDeliveryUname());
+        if (null != delivery.getUploadDtm() && !"".equals(delivery.getUploadDtm())) {
+            jdo.setUploadDtm(sdf.format(delivery.getUploadDtm()));
+        }
+        JsonMsg jsonMsg = JsonMsg.getSuccess();
+        jsonMsg.add("deliveryInfo", jdo);
+        return jsonMsg;
+    }
+
+    private List<Integer> formatIds(String ids, String separator) {
+        List<Integer> idList = new ArrayList<Integer>();
+
+        String[] idStringArray = StringUtils.split(ids, separator);
+        for (String idString : idStringArray) {
+            idList.add(Integer.parseInt(idString));
+        }
+
+        return idList;
+    }
+
+    public int getTodayIn(int storeId) throws Exception {
+        String beginTime1 = DateUtil.today().toString("yyyy-MM-dd");
+        String endTime1 = DateUtil.today().toString("yyyy-MM-dd");
+        String time1 = beginTime1.trim() + " 00:00:00";
+        String time2 = endTime1.trim() + " 23:59:59";
+        endTime1 = DateUtil.addDay(endTime1, "yyyy-MM-dd", 1);
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        qc.setBeginTime(formatter.parse(time1));
+        qc.setEndTime(formatter.parse(time2));
+        qc.setExpId(0);
+        qc.setShelfId(0);
+        qc.setCreateTime(beginTime1, endTime1);
+        ArrayList<Integer> statusList = new ArrayList<>();
+		/*statusList.add(Constants.ORDER_STATUS_COMPLETE);
+		qc.setStatusStr(statusList);*/
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+		/*String subSql = " and userPhone = '' ";
+		qc.setSubSql(subSql);*/
+        qc.setP(1);
+        qc.setBegin(0);
+        qc.setPageSize(20);
+     /*  QueryPageDto pageDto = deliveryService.getQueryPageDto(qc,expressList);
+        PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
+        if(deliveryPagedList!=null){
+            return Integer.parseInt(String.valueOf(pageDto.getPageList().getTotal()));
+        }else{
+            return  0;
+        }*/
+        return (int) deliveryService.getCount(qc);
+    }
+
+    private DeliveryQueryCondition getDeliveryQueryCondition(int storeId) {
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+        qc.setPageSize(20);
+        return qc;
+    }
+
+    //获取自提在库
+    public int getAllInstore(int storeId) throws Exception {
+        int p = 1;
+        int pageSize = 20;
+        String type = "ALLINSTORE";
+        int expId = 0;
+        int shelfId = 0;
+        String expcode = "";
+        int queryType = 2;
+        int offset = -1;
+        int sort = -1;
+
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar cale = Calendar.getInstance();
+        cale.add(Calendar.MONTH, 0);
+        cale.set(Calendar.DAY_OF_MONTH, 1);
+        String beginTime = format.format(new Date());
+        String endTime = DateUtil.today().toString("yyyy-MM-dd");
+
+        long now = System.currentTimeMillis();
+        p = max(1, p);
+        int begin = (p - 1) * pageSize;
+
+        DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
+        //判断今天、近一月
+        if (!beginTime.equals("")) {
+            String time = beginTime.trim() + " 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(time));
+        }
+        if (!endTime.equals("")) {
+            String time = endTime.trim() + " 23:59:59";
+            qc.setEndTime(Timestamp.valueOf(time));
+        }
+
+
+        if (offset == -1) {
+            if (isEmpty(beginTime))
+                beginTime = DateUtil.today().toString("yyyy-MM-dd");
+            if (isEmpty(endTime))
+                endTime = DateUtil.today().toString("yyyy-MM-dd");
+
+            endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);
+        } else {
+            String today = DateUtil.today().toString("yyyy-MM-dd");
+            beginTime = DateUtil.addDay(today, "yyyy-MM-dd", -offset);
+            endTime = DateUtil.addDay(today, "yyyy-MM-dd", 1);
+        }
+
+        // 封装查询条件
+        List<Integer> statusList = new ArrayList<Integer>();
+        qc.setP(p);
+        qc.setBegin(begin);
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        qc.setStatusStr(statusList);
+        qc.setCreateTime(beginTime, endTime);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        qc.setBeginTime(sdf.parse(beginTime));
+        qc.setEndTime(sdf.parse(endTime));
+
+
+        if (!"ALLINSTORE".equals(type) && !"ALLDISPATCH".equals(type)
+                && !"ALL".equals(type) && !"INDEX".equals(type)
+                && !"WHITELIST".equals(type) && !"NOSTORE".equals(type)) {
+            qc.setStatusTime(beginTime, endTime);
+        }
+
+        String subSql = "";
+        if (!"WHITELIST".equals(type)) {
+            subSql = getSubSql(expcode, queryType);
+        }
+
+        if (!subSql.equals("")) {
+            qc.setSubSql(subSql);
+        }
+
+        qc.setExpId(expId);
+        qc.setShelfId(shelfId);
+
+        QueryPageDto pageDto = null;
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        pageDto = deliveryService.getQueryPageDto(qc);
+        if (pageDto.getPageList() != null) {
+            return Integer.parseInt(String.valueOf(pageDto.getPageList().getTotal()));
+        } else {
+            return 0;
+        }
+    }
+
+    private String getSubSql(String expcode, int queryType) {
+        String subSql = "";
+        if (null == expcode || "".equals(expcode)) {
+            return subSql;
+        }
+        String strRev = cn.haliaeetus.framework.util.StringUtil.stringReverse(expcode);
+        if (isNotEmpty(expcode)) {
+            if (queryType == 1) {
+                subSql += " and revexpCode like '" + strRev + "%'";
+            } else if (queryType == 2) {
+                subSql += " and revuserPhone like '" + strRev
+                        + "%'";
+            } else if (queryType == 3) {
+                subSql += " and shelfCode = '" + expcode + "'";
+            } else if (queryType == 4) {
+                subSql += " and userName = '" + expcode + "'";
+            }
+
+        }
+        return subSql;
+    }
+
+    //查询短信
+    private int getNotSendAmount(int storeId, List<ExpressType> expressList, String beginTime, String endTime, int type) throws ParseException {
+        int p = 1;
+        int pageSize = 20000;
+        int begin = (p - 1) * pageSize;
+        DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
+        qc.setP(p);
+        qc.setBegin(begin);
+
+        qc.setSmsStatus(type);
+
+        qc.setExpId(0);
+        qc.setShelfId(0);
+        qc.setBeginTime(Timestamp.valueOf(beginTime));
+        qc.setEndTime(Timestamp.valueOf(endTime));
+        qc.setCreateTime(beginTime, endTime);
+
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        // String subSql = getSubSql("", 1);
+//		if (!subSql.equals("")) {
+//			qc.setSubSql(subSql);
+//		}
+        String subSql = " and userPhone > ''";
+        qc.setSubSql(subSql);
+
+        qc.setPageSize(pageSize);
+        List<Integer> statusList = new ArrayList<Integer>();
+        //只查在库单子
+        statusList.add(122);
+        statusList.add(124);
+        statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+        //只查有手机号的单子
+        qc.setStatusStr(statusList);
+        QueryPageDto pageDto = deliveryService.getSmsFail4Page(qc, expressList);
+        PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
+        //统计未未通知数据
+        int count = 0;
+        //根据店铺id查询当前店铺的白名单客户
+        List<WhiteList> list = whiteListService.getByStoreId(storeId);
+        Map map = new HashMap();
+        for (WhiteList white : list) {
+            map.put(white.getUsermobile(), white);
+        }
+        List<DeliveryDto> items = deliveryPagedList.getItems();
+        for (DeliveryDto item : items) {
+            if (map.get(item.getDelivery().getUserPhone()) != null) {
+                continue;
+            } else {
+                count++;
+//                jdo.setSmsStatus(d1.getSmsStatus());
+            }
+        }
+//        return deliveryPagedList.getItems().size();
+        return count;
+    }
+
+    private String getNoArriveSubSql(String expcode, int queryType) {
+
+        String strRev = cn.haliaeetus.framework.util.StringUtil.stringReverse(expcode);
+        String subSql = "";
+        if (isNotEmpty(expcode)) {
+            if (queryType == 1) {
+                subSql += " and (expCode like '" + expcode + "%' or revexpCode like '" + strRev + "%')";
+            } else if (queryType == 2) {
+                subSql += " and (userPhone like '" + expcode + "%' or revuserPhone like '" + strRev
+                        + "%')";
+            } else if (queryType == 4) {
+                subSql += " and userName = '" + expcode + "'";
+            }
+
+        }
+        return subSql;
+
+    }
+
+    public List<JDeliveryDto> getJDeliveryDto(PagedList<DeliveryDto> d, Map map, String pageType) {
+        List<JDeliveryDto> jdos = new ArrayList<JDeliveryDto>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        List<DeliveryDto> dto1 = d.getItems();
+        for (DeliveryDto d1 : dto1) {
+            JDeliveryDto jdo = new JDeliveryDto();
+            ExpressType exp = d1.getExpress();
+            Delivery d2 = d1.getDelivery();
+            //判断是否有白名单用户,存在直接跳过不显示
+            /*if(map.get(d2.getUserPhone()) != null){
+                continue;
+            }else{*/
+            //判断是否有白名单用户,存在直接跳过不显示
+            if (map.get(d2.getUserPhone()) != null) {
+                //判断是否是未通知接口,不显示白名单用户
+                if (Integer.parseInt(pageType) == -1) {
+                    continue;
+                }
+                //白名单用户状态为3,不发送短信
+                jdo.setSmsStatus(3);
+                jdo.setIsSendSMS(1);
+            } else {
+                jdo.setSmsStatus(d1.getSmsStatus());
+                if (d2.getStatus() == 122 || d2.getStatus() == 225) {
+                    jdo.setIsSendSMS(0);
+                } else {
+                    jdo.setIsSendSMS(1);
+                }
+            }
+
+            jdo.setId(d2.getId());
+            jdo.setExpcode(d2.getExpcode());
+            jdo.setExpId(exp.getExpId());
+            jdo.setShelfCode(d2.getShelfCode());
+            if (null != d2.getSignDtm() && !"".equals(d2.getSignDtm())) {
+                jdo.setSignDtm(sdf.format(d2.getSignDtm()));
+            }
+            jdo.setExpName(exp.getExpName());
+            jdo.setStatus(d2.getStatus());
+            jdo.setUserPhone(d2.getUserPhone());
+            /*jdo.setSmsStatus(d1.getSmsStatus());*/
+            jdo.setShelfId(d2.getShelfId());
+            jdo.setDeliveryUid(d2.getDeliveryUid());
+            jdo.setDeliveryUname(d2.getDeliveryUname());
+            jdo.setShelfName(d1.getShelf().getShelfName());
+            jdo.setSendBackReason(d2.getSendBackReason());
+            if (null != d2.getUploadDtm() && !"".equals(d2.getUploadDtm())) {
+                jdo.setUploadDtm(sdf.format(d2.getUploadDtm()));
+            }
+            if (null != d2.getCreateTime() && !"".equals(d2.getCreateTime())) {
+                jdo.setCreateTime(sdf.format(d2.getCreateTime()));
+            }
+            if (null != d2.getSignDtm() && !"".equals(d2.getSignDtm())) {
+                jdo.setSignDtm(sdf.format(d2.getSignDtm()));
+            }
+            if (null != d1.getResultInfo() && !"".equals(d1.getResultInfo())) {
+                switch (d1.getSmsStatus()) {
+                    case 1:
+                        jdo.setResultInfo("");
+                        break;
+                    case 2:
+                        jdo.setResultInfo(SMSErrorCodeEnum.of(d1.getResultInfo()));
+                        break;
+                    default:
+                        jdo.setResultInfo("");
+                }
+            } else {
+                jdo.setResultInfo("");
+            }
+            jdo.setReturnSignStatus(StatusCodeEnum.of(d1.getDelivery().getReturnSignStatus()));
+            if (null == d1.getSendSuccessType()) {
+                jdo.setSendSuccessType(0);
+            } else {
+                jdo.setSendSuccessType(d1.getSendSuccessType());
+            }
+
+
+            jdos.add(jdo);
+
+        }
+        return jdos;
+    }
+
+    public void pageDtos(QueryPageDto pageDto) {
+        for (DeliveryDto d : pageDto.getPageList().getItems()) {
+            List<DeliveryScanBatch> deliveryScanBatches = scanBatchService.getByCondition(d.getDelivery().getStoreId(), d.getDelivery().getExpcode(), d.getDelivery().getExpId(), null, null, null);
+            if (d.getDelivery().getUserPhone() != null) {
+                if (deliveryScanBatches.size() > 0 && "2".equals(deliveryScanBatches.get(0).getOcrStatus())) {
+                    StringBuilder number = new StringBuilder(d.getDelivery().getUserPhone());
+                    if (org.apache.commons.lang.StringUtils.isEmpty(d.getDelivery().getUserPhone()) || org.apache.commons.lang.StringUtils.isBlank(d.getDelivery().getUserPhone())) {
+                        number.append("");
+                    } else {
+                        number.replace(3, 10, "*******");
+                    }
+                    //number.replace(3, 10, "*******");
+                    d.getDelivery().setUserPhone(number.toString());
+                }
+            }
+        }
+    }
+
+    private String getSpecifiedDayAfter(String specifiedDay) {
+        Calendar c = Calendar.getInstance();
+        Date date = null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        c.setTime(date);
+        int day = c.get(Calendar.DATE);
+        c.set(Calendar.DATE, day + 1);
+
+        String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+
+    private long getSignStatusCount(int storeId) throws ParseException {
+        String beginTime1 = DateUtil.today().toString("yyyy-MM-dd");
+        String endTime1 = DateUtil.today().toString("yyyy-MM-dd");
+        String time1 = beginTime1.trim() + " 00:00:00";
+        String time2 = endTime1.trim() + " 23:59:59";
+        endTime1 = DateUtil.addDay(endTime1, "yyyy-MM-dd", 1);
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        qc.setBeginTime(formatter.parse(time1));
+        qc.setEndTime(formatter.parse(time2));
+        qc.setCreateTime(beginTime1, endTime1);
+        //qc.setSignStatus("0");
+        //update 20190411 防止申通代签之类的状态查询不到
+        qc.setSignStatus(null);
+        ArrayList<Integer> statusList = new ArrayList<>();
+        statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+        //statusList.add(Constants.ORDER_STATUS_COMPLETE);
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+        statusList.add(Constants.ORDER_STATUS_MAIKE_DISPATCHING);
+        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        qc.setStatusStr(statusList);
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        long count = deliveryService.getCount(qc);
+        return count;
+    }
+
+    //查询短信
+    private Map<Integer, Integer> smsCountMap(int storeId, List<ExpressType> expressList, String beginTime, String endTime) throws ParseException {
+        int p = 1;
+        int pageSize = 20000;
+        int begin = (p - 1) * pageSize;
+        DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        qc.setP(p);
+        qc.setBegin(begin);
+
+        qc.setExpId(0);
+        qc.setShelfId(0);
+        qc.setBeginTime(Timestamp.valueOf(beginTime));
+        qc.setEndTime(Timestamp.valueOf(endTime));
+        qc.setCreateTime(beginTime, endTime);
+
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        String subSql = getSubSql("", 1);
+//		if (!subSql.equals("")) {
+//			qc.setSubSql(subSql);
+//		}
+        // subSql +=  " and userPhone > ''  and odeliveryType<>'PS' ";
+        subSql += " and userPhone > ''";
+        qc.setSubSql(subSql);
+
+
+        qc.setPageSize(pageSize);
+        List<Integer> statusList = new ArrayList<Integer>();
+        //只查在库单子
+        statusList.add(122);
+        statusList.add(124);
+        statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+        //只查有手机号的单子
+        qc.setStatusStr(statusList);
+        Map<Integer, Integer> smsCountMap = deliveryService.getSmsFailCount(qc, expressList);
+        return smsCountMap;
+    }
+
+
+    /*@RequestMapping(value = {"/chargeBack"})
+    @ResponseBody
+    public Object chargeBack(HttpServletRequest request,@RequestParam(defaultValue = "")String param) throws Exception{
+        User user = userService.getUserById(request.getParameter(COOKIE_USERID));
+        if(null == user){
+            return buildJson(1,"用户未登录");
+        }
+        Date nowDate=new Date();
+        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
+        Calendar calendar = Calendar.getInstance();
+        if(null==param||"".equals(param)){
+            calendar.setTime(nowDate);
+        }else{
+            calendar.setTime(sdf.parse(param));
+        }
+        calendar.add(Calendar.DATE, -1); //得到前一天
+        Date date = calendar.getTime();
+        String yestedayDate=sdf.format(date);
+        String beginTime=yestedayDate.trim()+" 00:00:00";
+        String endTime = yestedayDate.trim()+" 23:59:59";
+
+        *//*List<User> users=userDao.getAllUser();*//*
+
+     *//*User user = getUserFromParam(request);*//*
+     *//*for (User user : users) {*//*
+            //判断是否有失败返额记录
+            List<ConsumeRecord> chargeRecord = consumeRecordService.getChargeRecord(user.getStoreId(), beginTime);
+            if (chargeRecord.size() == 0) {
+
+                //根据门店Id查询当天的返还金额
+                BigDecimal nowBalance = smsRecordService.getChargeCount(user.getStoreId(), beginTime, endTime, user.getSmsPrice());
+
+                ConsumeRecord consumeRecord = new ConsumeRecord();
+                consumeRecord.setConsumeFlag("5");//0代表ocr,1代表短信//2代表充值//5代表发送短信失败返还
+                *//*consumeRecord.setSmsId(String.valueOf(smsRecord.getId()));*//*
+                log.info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++开始插入消费记录表");
+                consumeRecord.setSmsId("");
+                consumeRecord.setOcrId("");
+                consumeRecord.setStoreId(user.getStoreId());
+                consumeRecord.setExpcode("");
+                consumeRecord.setExpId(0);
+                consumeRecord.setCreateTime(new Date());
+                consumeRecord.setConsumeStatus("1");//消费失败,余额不够发送短信
+                consumeRecord.setOperatorId(BigDecimal.valueOf(Long.valueOf(user.getUserId())));
+                consumeRecord.setPreBalance(user.getSmsBalance());
+                consumeRecord.setAftBalance(user.getSmsBalance().add(nowBalance));
+                consumeRecord.setNowAmount(nowBalance);
+                consumeRecordService.save(consumeRecord);
+
+                UserQueryCondition condition = new UserQueryCondition();
+                condition.setUserId(user.getUserId());
+                user.setSmsBalance(user.getSmsBalance().add(nowBalance));
+                log.info("AMOUNT::::::::" + user.getSmsBalance());
+                condition.setEntity(user);
+                userService.updateUser(condition);
+                //add 2019-04-022
+                CacheTool cacheTool = CacheTool.initUser();
+                cacheTool.saveBean(user.getUserId(), user);
+            } else {
+                log.info("SSSSSSSSSSSSSSS:昨天失败短信已经返现");
+                return "SUCCESS";
+//            }
+        }
+        return  "SUCCESS";
+    }
+*/
+
+    @RequestMapping(value = {"/app/api/v1/query"})
+    @ResponseBody
+    public Object queryFromES(HttpServletRequest request, HttpServletResponse response,
+                              @RequestParam(defaultValue = "1") String p,//第几页
+                              @RequestParam(defaultValue = "20") String pageSize,//每页多少
+                              @RequestParam(defaultValue = "") String beginTime,//查询入库开始时间
+                              @RequestParam(defaultValue = "") String endTime,//查询入库结束时间
+                              @RequestParam(defaultValue = "ALL") String type,//All全部  未入库,已到库,已出库
+                              @RequestParam(defaultValue = "0") String expId,//快递公司,手机号
+                              @RequestParam(defaultValue = "0") String shelfId,//
+                              @RequestParam(defaultValue = "") String smsType,//通知类型短信或者微信
+                              @RequestParam(defaultValue = "-2") String smsStatus,//通知状态
+                              @RequestParam(defaultValue = "") String expcode,
+                              @RequestParam(defaultValue = "1") String queryType,//查询类型1面单号
+                              @RequestParam(defaultValue = "-1") String search,
+                              @RequestParam(defaultValue = "-1") String pageType,//页面访问类型
+                              @RequestParam(defaultValue = "-1") String requestSign,//解决查询结果出错的
+                              @RequestParam(defaultValue = "-1") String sort) throws SQLException,
+            ParseException {
+
+        if (!accessLimitService.tryAcquire()) {
+            return buildJson(1, "");
+        }
+        String userId = request.getParameter(COOKIE_USERID);
+        StoreReqLimit storeReqLimit = basicInfoService.getStoreReqLimitByUserId(userId + "query");
+        if (storeReqLimit.getIsLimitFlag()) {
+            return buildJson(1, "");
+        }
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        // 获取门店id并封装进查询条件
+        int storeId = user.getStoreId();
+
+        // 用于封装查询条件
+        ESDeliveryQueryCondition condition = new ESDeliveryQueryCondition();
+        // 设置门店id
+        condition.setStoreId(storeId);
+
+        // 设置分页
+        int p1 = Integer.parseInt(p);
+        p1 = max(1, p1);
+        int begin = (p1 - 1) * Integer.parseInt(pageSize);
+        condition.setP(p1);
+        condition.setBegin(begin);
+        condition.setPageSize(Integer.parseInt(pageSize));
+
+        // 设置日期查询条件
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = new Date();
+
+        if (null == beginTime || "".equals(beginTime.trim())) {
+            beginTime = sdf.format(date);
+        }
+        condition.setBeginTime(sdf.parse(beginTime.trim()));
+
+        if (null == endTime || "".equals(endTime.trim())) {
+            endTime = sdf.format(date);
+        }
+        condition.setEndTime(sdf.parse(DateUtil.addDay(endTime, "yyyy-MM-dd", 1)));
+
+        if ("短信".equals(smsType) || "1".equals(smsType)) {
+            condition.setSendSuccessType(new int[]{1});
+        } else if ("微信".equals(smsType) || "2".equals(smsType)) {
+            condition.setSendSuccessType(new int[]{2});
+        }
+
+        // condition.setExpId(Integer.valueOf(expId));
+        // condition.setShelfId(Integer.valueOf(shelfId));
+
+        // 判断是依据面单号/用户手机/取件码查询
+        switch (Integer.valueOf(queryType)) {
+            case 1:
+                condition.setExpcode(expcode);
+                break;
+            case 2:
+                condition.setUserPhone(expcode);
+                break;
+            case 3:
+                condition.setShelfCode(expcode);
+                break;
+            default:
+        }
+        // 未通知
+        if ("-1".equals(pageType)) {
+            // 只查在库,滞留单子
+            condition.setStatus(new int[]{Constants.ORDER_STATUS_STORED,Constants.ORDER_STATUS_REJECT_RETENTION});
+        // 快件查询 and 通知管理
+        } else {
+            condition.setStatus(new int[] {
+                    Constants.ORDER_STATUS_STORED, Constants.ORDER_STATUS_DISPATCHING,
+                    Constants.ORDER_STATUS_REJECT_RETENTION, Constants.ORDER_STATUS_COMPLETE,
+                    Constants.ORDER_STATUS_LEAVE_STORE});
+        }
+
+        // 判断是否是未通知接口,不显示白名单用户
+        if(null != pageType && ("-1".equals(pageType) || "1".equals(pageType))){
+            condition.setWhiteUser(false);
+        }
+
+        if (Integer.valueOf(smsStatus) != -2 && Integer.valueOf(smsStatus) != 3) {
+            // "0": 已通知-包含发送成功的和发送失败的,1:发送成功,2:发送失败
+            if ("0".equals(smsStatus)) {
+                condition.setSmsStatus(new int[]{1, 2});
+            } else {
+                condition.setSmsStatus(new int[]{Integer.parseInt(smsStatus)});
+            }
+        }
+
+        JsonMsg jsonMsg = deliveryService.queryDeliveries(condition);
+        if(null == jsonMsg){
+            try {
+                return newQuery(request,p,pageSize,beginTime,endTime,type,expId,shelfId,smsType,smsStatus,expcode,queryType,search,pageType,requestSign,sort);
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+        jsonMsg.add("requestSign", requestSign);
+        return jsonMsg;
+    }
+
+    /**
+     * @throws
+     * @description
+     * @author sunjj
+     * @updateTime
+     */
+    @RequestMapping(value = {"/app/api/v1/query/new"})
+    @ResponseBody
+    public Object newQuery(HttpServletRequest request,
+                           @RequestParam(defaultValue = "1") String p,//第几页
+                           @RequestParam(defaultValue = "20") String pageSize,//每页多少
+                           @RequestParam(defaultValue = "") String beginTime,//查询入库开始时间
+                           @RequestParam(defaultValue = "") String endTime,//查询入库结束时间
+                           @RequestParam(defaultValue = "ALL") String type,//All全部  未入库,已到库,已出库
+                           @RequestParam(defaultValue = "0") String expId,//快递公司,手机号
+                           @RequestParam(defaultValue = "0") String shelfId,//
+                           @RequestParam(defaultValue = "") String smsType,//通知类型短信或者微信
+                           @RequestParam(defaultValue = "-2") String smsStatus,//通知状态
+                           @RequestParam(defaultValue = "") String expcode,
+                           @RequestParam(defaultValue = "1") String queryType,//查询类型1面单号
+                           @RequestParam(defaultValue = "-1") String search,
+                           @RequestParam(defaultValue = "-1") String pageType,//页面访问类型
+                           @RequestParam(defaultValue = "-1") String requestSign,//解决查询结果出错的
+                           @RequestParam(defaultValue = "-1") String sort) throws SQLException,
+            ParseException {
+        if (!accessLimitService.tryAcquire()) {
+            return buildJson(1, "");
+        }
+        String userId = request.getParameter(COOKIE_USERID);
+        StoreReqLimit storeReqLimit = basicInfoService.getStoreReqLimitByUserId(userId + "query");
+        if (storeReqLimit.getIsLimitFlag()) {
+            return buildJson(1, "");
+        }
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        int storeId = user.getStoreId();
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+
+        // 计算分页条件
+        int page = max(1, Integer.parseInt(p));
+        int pageCount = Integer.parseInt(pageSize);
+        int begin = (page - 1) * Integer.parseInt(pageSize);
+        qc.setP(page);
+        qc.setBegin(begin);
+        qc.setPageSize(pageCount);
+
+        // 计算查询时间
+        String pattern = "yyyy-MM-dd";
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        Date date = new Date();
+
+        Date beginDate = null;
+        if (null == beginTime || "".equals(beginTime)) {
+            beginTime = sdf.format(date);
+        }
+        beginDate = Timestamp.valueOf(beginTime + " 00:00:00");
+
+        Date endDate = null;
+        if (null == endTime || "".equals(endTime)) {
+            endTime = sdf.format(date);
+        }
+        try {
+            endTime = DateUtil.addDay(endTime, pattern, 1);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        endDate = Timestamp.valueOf(endTime + " 00:00:00");
+
+        qc.setBeginTime(beginDate);
+        qc.setEndTime(endDate);
+
+        if ("短信".equals(smsType) || "1".equals(smsType)) {
+            qc.setSmsType(1);
+        } else if ("微信".equals(smsType) || "2".equals(smsType)) {
+            qc.setSmsType(2);
+        }
+
+        if (!"-2".equals(smsStatus) && !"3".equals(smsStatus)) {
+            qc.setSmsStatus(Integer.valueOf(smsStatus));
+        } else {
+            qc.setSmsStatus(3);
+        }
+
+        //状态和类型没处理
+        List<Integer> statusList = new ArrayList<>();
+
+        // 未通知
+        if ("-1".equals(pageType)) {
+            //只查在库单子
+            statusList.add(Constants.ORDER_STATUS_STORED);
+            //滞留
+            statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+
+            // 快件查询 and 通知管理
+        } else {
+            //只查在库单子
+            statusList.add(Constants.ORDER_STATUS_STORED);
+            //滞留
+            statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+            statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+            statusList.add(Constants.ORDER_STATUS_COMPLETE);
+            statusList.add(Constants.ORDER_STATUS_LEAVE_STORE);
+        }
+        qc.setStatusStr(statusList);
+
+        if (isNotEmpty(expcode)) {
+            int len = expcode.length();
+            switch (queryType) {
+                // 根据面单号查询
+                case "1":
+                    if (len > 7) {
+                        qc.setExpcode(expcode);
+                    } else if (len > 4) {
+                        qc.setRevexpCode(expcode.substring(len - 4));
+                    } else {
+                        qc.setRevexpCode(expcode);
+                    }
+                    break;
+                // 根据用户手机号查询
+                case "2":
+                    if (len == 11) {
+                        qc.setUserPhone(expcode);
+                    } else if (expcode.length() > 4) {
+                        qc.setRevuserPhone(expcode.substring(len - 4));
+                    } else {
+                        qc.setRevuserPhone(expcode);
+                    }
+                    break;
+                // 根据取件码查询
+                case "3":
+                    qc.setShelfCode(expcode);
+                    break;
+                case "4":
+                    qc.setUserName(expcode);
+                default:
+            }
+        }
+
+        // 判断是否是未通知接口,不显示白名单用户
+        if (null != pageType && !"".equals(pageType) && (Integer.parseInt(pageType) == -1 || Integer.parseInt(pageType) == 1)) {
+            qc.setIswhite(1);
+        }
+
+        JsonMsg jsonMsg = deliveryService.queryDeliveries(qc, pageType);
+        jsonMsg.add("requestSign", requestSign);
+        return jsonMsg;
+    }
+}

+ 184 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppRegiestController.java

@@ -0,0 +1,184 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.controller.web.querycondition.UserQueryCondition;
+import cn.haliaeetus.entity.ExStore;
+import cn.haliaeetus.entity.Store;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.base.digt.Md5Util;
+import cn.haliaeetus.framework.toolkit.CacheTool;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.ExStoreService;
+import cn.haliaeetus.service.UserService;
+import cn.haliaeetus.util.MD5;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mail.MailParseException;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by Administrator on 2019/3/7 0007.
+ */
+@Controller
+public class AppRegiestController extends BaseController {
+    @Autowired
+    private ExStoreService exStoreService;
+
+    @Autowired
+    private BasicInfoService basicService;
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+
+    @RequestMapping(value = "/app/regist/saveregiest")
+    @ResponseBody
+    public Object saveRegiestMessage(HttpServletRequest request,
+                                     @RequestParam(defaultValue = "") String userPhone,
+                                     @RequestParam(defaultValue = "") String password,
+                                     @RequestParam(defaultValue = "") String storeName,
+                                     @RequestParam(defaultValue = "") String detailAddress,//详细地址
+                                     @RequestParam(defaultValue = "") String province,//省
+                                     @RequestParam(defaultValue = "") String city,//市
+                                     @RequestParam(defaultValue = "") String area,//区
+                                     @RequestParam(defaultValue = "") String comSign,//短信签名
+                                     @RequestParam(defaultValue = "") String shortAddress,//短地址
+                                     @RequestParam(defaultValue = "") String startTime,
+                                     @RequestParam(defaultValue = "") String endTime,
+                                     @RequestParam(defaultValue = "") String takeExpressPhone //联系电话
+                                      ) throws IOException {
+        if(_.isEmpty(userPhone) || _.isEmpty(password) || _.isEmpty(storeName) || _.isEmpty(detailAddress) || _.isEmpty(province) || _.isEmpty(city) || _.isEmpty(area) ||  _.isEmpty(comSign) || _.isEmpty(shortAddress) || _.isEmpty(startTime) || _.isEmpty(endTime) || _.isEmpty(takeExpressPhone)){
+            return buildJson(-1,"信息不完善");
+        }
+        //封装store 25
+        ExStore exStore = new ExStore();
+        exStore.setName(storeName);
+        exStore.setPhone(userPhone);
+        exStore.setShortName(storeName);
+        exStore.setOwner(storeName);
+        exStore.setStartTime(startTime);
+        exStore.setEndTime(endTime);
+        exStore.setProvince_id(1);
+        exStore.setProvinceName(province);
+        exStore.setCity_id(1);
+        exStore.setCityName(city);
+        exStore.setArea_id(0);
+        exStore.setAreaName(area);
+        exStore.setShortAddress(shortAddress);
+        exStore.setAddress(detailAddress);
+        exStore.setReceiveIds("202,187,272,17,18,223,243,244,273,274,275,276,277,279,280,282,285,287,288,289,290,291,292,19,293,294");
+        exStore.setDispatchIds("202,187,272,17,18,223,243,244,273,274,275,276,277,279,280,282,285,287,288,289,290,291,292,19,293,294,999");
+        exStore.setIs_P2p(0);
+        exStore.setOperateType(0);
+        exStore.setStatus_id(0);
+        exStore.setIsPrinter("1");
+        exStore.setLongitude("1");
+        exStore.setLatitude("");
+        exStore.setAppid("wxad5e9912d18f747b");
+        exStore.setAppsecret("6879cac74e55110fe3596916c3633485");
+        exStore.setMsgtempid("L8Lfe0LaapohHbANNUVGWg4LOXXQ3tNvToG5iMLaPBw");
+        exStore.setTakeExpressPhone(takeExpressPhone);
+        exStore.setAuditStatus(0);
+        //获取对应后台域名
+        String domain=basicInfoService.getConfigurationByCode("domain").getOValue1();
+        exStore.setDomain(domain);
+        //获取广告url,包裹到店公众消息需要跳转的地址
+        String advertisingUrl = basicInfoService.getConfigurationByCode("advertisingUrl").getOValue1();
+        exStore.setAdvertisingUrl(advertisingUrl);
+        //封装user
+        User user = new User();
+        //status -1时表示审核中 -2表示失败  0和1都是成功
+        user.setStatus(0);
+        user.setUserId(userPhone);
+        user.setTelPhone(userPhone);
+        user.setUserName(storeName);
+        user.setPassword(Md5Util.md5AsLowerHex(password));
+        user.setComSign("【" + comSign + "】");
+        user.setShortAddress(shortAddress);
+        user.setRole_id("d7fe9d0a302f46ffa6210f3057e88efd");
+        user.setSmsBalance(BigDecimal.valueOf(Double.valueOf("0.26")));
+        boolean result = exStoreService.saveStoreAndUser(user,exStore);
+        if(result){
+            return buildJson(0,"提交成功");
+        }
+        return buildJson(-1,"提交失败");
+    }
+
+
+    @RequestMapping(value = "/app/editAuditStore")
+    @ResponseBody
+    public Object editAuditStore(HttpServletRequest request,
+                                     @RequestParam(defaultValue = "") String userPhone,
+                                     @RequestParam(defaultValue = "") String storeName,
+                                     @RequestParam(defaultValue = "") String detailAddress,//详细地址
+                                     @RequestParam(defaultValue = "") String province,//省
+                                     @RequestParam(defaultValue = "") String city,//市
+                                     @RequestParam(defaultValue = "") String area,//区
+                                     @RequestParam(defaultValue = "") String comSign,//短信签名
+                                     @RequestParam(defaultValue = "") String shortAddress,//短地址
+                                     @RequestParam(defaultValue = "") String startTime,
+                                     @RequestParam(defaultValue = "") String endTime,
+                                     @RequestParam(defaultValue = "") String takeExpressPhone //联系电话
+    ) throws IOException {
+        if(_.isEmpty(userPhone)  || _.isEmpty(storeName) || _.isEmpty(detailAddress) || _.isEmpty(province) || _.isEmpty(city) || _.isEmpty(area) ||  _.isEmpty(comSign) || _.isEmpty(shortAddress) || _.isEmpty(startTime) || _.isEmpty(endTime) || _.isEmpty(takeExpressPhone)){
+            return buildJson(-1,"信息不完善");
+        }
+       try {
+           //封装store 25
+           ExStore exStore = new ExStore();
+           exStore.setName(storeName);
+           exStore.setPhone(userPhone);
+           exStore.setShortName(storeName);
+           exStore.setOwner(storeName);
+           exStore.setStartTime(startTime);
+           exStore.setEndTime(endTime);
+           exStore.setProvinceName(province);
+           exStore.setCityName(city);
+           exStore.setAreaName(area);
+           exStore.setShortAddress(shortAddress);
+           exStore.setAddress(detailAddress);
+           exStore.setTakeExpressPhone(takeExpressPhone);
+           int i=exStoreService.updateStoreByPhone(exStore);
+
+           User user1= userService.getUserByIdAndStorePwd(userPhone,null);
+           if (i > 0) {
+               CacheTool cacheTool = CacheTool.initStore();
+               Store store = basicService.getStoreById(Integer.valueOf(user1.getStoreId()));
+               store.setAuditStatus(0);
+               cacheTool.saveBean(String.valueOf(store.getId()), store);
+           }
+           //封装user
+           User user=new User();
+           user.setShortAddress(shortAddress);
+           user.setComSign("【" + comSign + "】");
+           UserQueryCondition condition=new UserQueryCondition();
+           condition.setEntity(user);
+           condition.setUserId(userPhone);
+           userService.updateUser(condition);//user内部自动更新缓存
+/*
+           if (j > 0) {
+               CacheTool cacheTool = CacheTool.initUser();
+               User user = userDao.getUserById(userId);
+               cacheTool.saveBean(String.valueOf(user.getId()), user);
+           }*/
+
+       }catch (Exception e){
+           return buildJson(-1,"提交失败");
+       }
+
+        return buildJson(0,"提交成功");
+    }
+}

+ 148 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppRetentionController.java

@@ -0,0 +1,148 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.dao.DeliveryDao;
+import cn.haliaeetus.dao.UserDao;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.DeliveryStatus;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.entity.dto.DeliveryDto;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.DeliveryStatusService;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/** 滞留
+ * Created by Administrator on 2019/1/18 0018.
+ */
+@Controller
+public class AppRetentionController extends BaseController{
+    @Autowired
+    private UserDao userDAO;
+    @Autowired
+    private DeliveryService deliveryService;
+    @Autowired
+    private DeliveryStatusService statusService;
+    @Autowired
+    private DeliveryDao deliveryDao;
+    //滞留
+    @RequestMapping(value = "/app/retention")
+    @ResponseBody
+    public Object appDeliveryRetention(HttpServletRequest request
+            , @RequestParam(defaultValue = "")String expCodes  //选中的面单号
+    ) {
+        User user = getUserFromParam(request);
+        if (user == null) return buildJson(1, "用户未登录");
+        int storeId  = user.getStoreId();
+        if("".equals(expCodes)){
+            return buildJson(-1, "参数错误");
+        }
+
+        //user = userDAO.getUserByIdAndPwd(user.getUserId(), null);
+        String[] expCodeStr = expCodes.split(",");
+        JsonArray array = new JsonArray();
+        for (String expcode: expCodeStr) {
+            DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+            String endTime = DateUtil.today().toString("yyyy-MM-dd").trim()+" 23:59:59";
+            String beginTime = getSpecifiedDaybefore().trim() + " 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(beginTime));
+            qc.setEndTime(Timestamp.valueOf(endTime));
+            qc.setCreateTime(beginTime,endTime);
+            qc.setOrderField("createTime");
+            qc.setOrder("desc");
+            qc.setExpcode(expcode);
+            ArrayList<Integer> statusList = new ArrayList<Integer>();
+            statusList.add(Constants.ORDER_STATUS_STORED);
+            statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+            statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+            statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+            qc.setStatusStr(statusList);
+//            qc.setSignStatus("0");
+            qc.setSmsStatus(3);//查询全部
+            List<DeliveryDto> deliveryList = deliveryService.getDeliveryDto(qc);
+            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expcode);
+            Delivery delivery = new Delivery();
+            try{
+                if (deliveryList == null || deliveryList.size() < 1) {
+                   throw  new NullPointerException("面单号不存在或不在库");
+                }
+                // 如果同一单号存在多条记录时,需要回到网页进行选择
+                if (deliveryList.size() > 1) {
+                  throw  new NullPointerException("存在重复单号");
+                }
+                DeliveryDto deliveryDto = deliveryList.get(0);
+                delivery = deliveryDto.getDelivery();
+                if(delivery.getStatus() != null && delivery.getStatus().intValue() == Constants.ORDER_STATUS_REJECT_RETENTION ){
+                   throw  new NullPointerException("订单已经是滞留件");
+                }
+                Delivery entity = new Delivery();
+                entity.setStatus(Constants.ORDER_STATUS_REJECT_RETENTION);
+                entity.setOdeliveryType(Constants.ORDER_SEND_TYPE_ZT);
+                entity.setStatusTime(new Date());
+                entity.setMoney(0);
+                entity.setPayType(Constants.PAY_TYPE_ONLINE);
+
+                //es出库条件修改 2019-08-20
+                entity.setUploadDtm(new Date());
+                entity.setStoreId(delivery.getStoreId());
+                DeliveryQueryCondition qc1 = new DeliveryQueryCondition(storeId);
+                qc1.setEntity(entity);
+                qc1.setId(delivery.getId());
+                boolean result = deliveryService.update(qc1);
+                //添加状态更改记录
+                //int insert(int storeId, DeliveryStatus deliveryStatus);
+                DeliveryStatus deliveryStatus = new DeliveryStatus();
+                deliveryStatus.setDeliveryId(delivery.getId());
+                deliveryStatus.setStatus(Constants.ORDER_STATUS_REJECT_RETENTION);
+                deliveryStatus.setUpdateTime(new Date());
+                deliveryStatus.setStoreId(user.getStoreId());
+                deliveryStatus.setPreStatus(delivery.getStatus());
+                if(delivery.getDeliveryUname() != null && !"".equals(delivery.getDeliveryUname())){
+                    deliveryStatus.setProcessStaff(delivery.getDeliveryUname());
+                }else {
+                    deliveryStatus.setProcessStaff("无");
+                }
+                deliveryStatus.setSource(Constants.CLIENT_TYPE_BS_2);
+                statusService.insert(user.getStoreId(),deliveryStatus);
+                dataObj.addProperty("code", "0");
+                dataObj.addProperty("reason", "订单添加滞留成功");
+            } catch (Exception e) {
+                dataObj.addProperty("code", "-1");
+                dataObj.addProperty("reason", e.getMessage());
+            }finally {
+                array.add(dataObj);
+            }
+        }
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "请求成功");
+        object.add("expInfo", array);
+        return object.toString();
+    }
+    private String getSpecifiedDaybefore(){
+        Calendar c = Calendar.getInstance();
+        c.setTime(new Date());
+        int day=c.get(Calendar.DATE);
+        c.set(Calendar.MONTH,-2);
+
+        String dayAfter=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+}

+ 995 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppSendEmailController.java

@@ -0,0 +1,995 @@
+package cn.haliaeetus.controller.appdevapi;
+
+
+import cn.haliaeetus.constants.EmailConfig;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.ExportQueue;
+import cn.haliaeetus.entity.PurchaseRecordSearch;
+import cn.haliaeetus.entity.SmsPurchaseRecord;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.entity.dto.ConsumeListDto;
+import cn.haliaeetus.entity.jspo.JCountDto;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.rabbit.DirectRabbitConfig;
+import cn.haliaeetus.framework.toolkit.PagedList;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.PurchaseRecordService;
+import cn.haliaeetus.service.StatService;
+import cn.haliaeetus.service.impl.SMSSendRabbitPushServiceImpl;
+import cn.haliaeetus.service.rsync.ConsumeRecordService;
+import com.alibaba.fastjson.JSON;
+import com.sun.mail.util.MailSSLSocketFactory;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.mail.javamail.JavaMailSenderImpl;
+import org.springframework.mail.javamail.MimeMessageHelper;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import sun.misc.BASE64Encoder;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.mail.*;
+import javax.mail.internet.*;
+import javax.mail.util.ByteArrayDataSource;
+import javax.servlet.http.HttpServletRequest;
+import java.io.*;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/* 发送邮件,入库统计信息邮件,充值邮件,消费统计邮件
+ * Created by Administrator on 2019/1/7 0007.
+ */
+@Controller
+public class AppSendEmailController extends BaseController{
+    @Autowired
+    private DeliveryService deliveryService;
+    @Autowired
+    private StatService statService;
+    @Autowired
+    private ConsumeRecordService consumeRecordService;
+    @Autowired
+    private PurchaseRecordService purchaseRecordService;
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private SMSSendRabbitPushServiceImpl smsSendRabbitPushService;
+
+    private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+    private  SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM");
+    private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+
+    //统计信息明细导出
+    @ResponseBody
+    @RequestMapping("/app/getAttachmentMange")
+    public Object getAttachment(HttpServletRequest request,
+                                @RequestParam(defaultValue = "1") String currentPage,//默认查全部快递
+                                @RequestParam(defaultValue = "10") String pageSize,
+                                @RequestParam(defaultValue = "") String expId,//默认查全部快递
+                                @RequestParam(defaultValue = "") String beginTime,
+                                @RequestParam(defaultValue = "") String endTime
+    ) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+        String email = user.getUserMail();
+        if(null == email || "".equals(email)){
+            return buildJson(-1, "邮箱未完善");
+        }
+        /*DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        if (!"".equals(expId)) {
+            qc.setExp_Id(expId);
+        }
+        String mailEndTime = "";
+        Date date = new Date();
+            //根据开始时间和结束时间得到一个时间字符串数组
+           // List<String> dataStr = new ArrayList<String>();
+            if (null == beginTime || "".equals(beginTime)) {//开始是今天,结束是明天
+                beginTime = formatter.format(date);
+            } else {
+                Date beginTime1 = formatter.parse(beginTime);
+                beginTime = formatter.format(beginTime1);
+                if (null == endTime || "".equals(endTime)) {
+                    mailEndTime = formatter.format(date);
+                    endTime = getSpecifiedDayAfter(formatter.format(date));
+                }else{
+                    mailEndTime = endTime;
+                    Date endTime1 = formatter.parse(endTime);
+                    endTime = getSpecifiedDayAfter(formatter.format(endTime1));
+                }
+            }
+            if (null == endTime || "".equals(endTime)) {
+                mailEndTime = formatter.format(date);
+                endTime = getSpecifiedDayAfter(formatter.format(date));
+            }
+            String beginTime1 = beginTime + " 00:00:00";
+            String endTime1 = endTime + " 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(beginTime1));
+            qc.setEndTime(Timestamp.valueOf(endTime1));
+            qc.setCreateTime(beginTime1,endTime1);
+            qc.setOrderField("createTime");
+            qc.setOrder("ASC");*/
+//            List<Delivery> deliverys =  deliveryService.getDelivery(qc);
+        //合作快递列表
+//           List<ExpressType> expressTypes = basicInfoService.getAllExpressMapMemcached();
+
+        String path = request.getSession().getServletContext().getRealPath("WEB-INF/excel/status.xls");
+        if (!"".equalsIgnoreCase(email)) {
+            //推送Mq消息
+            ExportQueue exportQueue = new ExportQueue();
+            /*exportQueue.setDeliverys(deliverys);
+            exportQueue.setExpressTypes(expressTypes);*/
+//            exportQueue.setQc(qc);
+            exportQueue.setExpId(expId);
+            exportQueue.setEmail(email);
+            exportQueue.setUser(user);
+            exportQueue.setPath(path);
+            exportQueue.setBeginTime(beginTime);
+            exportQueue.setEndTime(endTime);
+//            return buildJson(0, "发送成功");
+            String info = JSON.toJSONString(exportQueue);
+            log.info("推送前的时间:"+new Date());
+            long begin=System.currentTimeMillis();
+//            exportPushService.push(exportQueues);
+//            String info=new Gson().toJson(exportQueues);
+            smsSendRabbitPushService.rabbitMQAllPush(DirectRabbitConfig.EMAIL_EXCHANGE,DirectRabbitConfig.EMAIL_KEY,info);
+
+            long end=System.currentTimeMillis();
+            long dddd=end-begin;
+            log.info("推送后时间:"+new Date()+"-------------------花费的时间:"+dddd);
+        }
+        return buildJson(0,"发送成功");
+//            flag = sendMail(email, is,context,xslName,"入库统计数据导出");
+        /*}
+
+                    FileInputStream template = new FileInputStream(path);
+                    // 如果是xlsx,2007,用XSSF,如果是xls,2003,用HSSF
+                    // 一个Excel文件的层次:Excel文件-> 工作表-> 行-> 单元格 对应到POI中,为:workbook-> sheet-> row-> cell
+                    HSSFWorkbook workBook=new HSSFWorkbook(template);
+                    // 获取第一个sheet页
+                    HSSFSheet sheet=workBook.getSheetAt(0);
+
+                    *//******************************设置表头*****************************//*
+                    //String sheetTitle = "入库统计表";
+                    // 单元格合并
+                    // 四个参数分别是:起始行,起始列,结束行,结束列
+                   //sheet.addMergedRegion(new CellRangeAddress(0,0,2,10));
+                    List<String> columns = new ArrayList<String>();
+                    columns.add("序号");
+                    columns.add("运单号");
+                    columns.add("入库日期");
+                    columns.add("快递公司");
+                    columns.add("状态");
+                    columns.add("最后操作时间");
+
+                    // 创建表头并赋值
+                    HSSFRow rowTitle = sheet.createRow(0);
+                    HSSFCell cellTitle = rowTitle.createCell(0);
+                  //  cellTitle.setCellValue(sheetTitle);
+                    int rowTitlenum = 0;
+                    for (String colstr: columns) {
+                        rowTitle.createCell(rowTitlenum).setCellValue(colstr);
+                        rowTitlenum += 1;
+                    }
+                    // 创建剧中样式
+                    HSSFCellStyle cellStyle = workBook.createCellStyle();
+                    // 垂直居中
+                    cellStyle.setAlignment(HSSFCellStyle.VERTICAL_CENTER);
+                    // 水平居中
+                    cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+                    // 创建字体
+                    HSSFFont cellFont = workBook.createFont();
+                    cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+                    cellFont.setFontHeight((short) 250);
+                    cellStyle.setFont(cellFont);
+                    cellTitle.setCellStyle(cellStyle);
+                    //sheet.addCell(new Label(i, 0, columns.get(i), wcf));
+                    *//**********************遍历作为邮件的附件***********************//*
+                    // 行号下标,从0开始
+                    InputStream is = null;
+                    int rowIndex = 0 ;
+                    for(int j=0;j<deliverys.size();j++) {
+                        rowIndex++;
+                        // 创建行
+                        HSSFRow row = sheet.createRow(rowIndex);
+                        row.createCell(0).setCellValue(j + 1);
+                        if (null != deliverys.get(j).getExpcode()) {
+                            row.createCell(1).setCellValue(deliverys.get(j).getExpcode());
+                        } else {
+                            row.createCell(1).setCellValue("");
+                        }
+                        if (null != deliverys.get(j).getCreateTime()) {
+                            row.createCell(2).setCellValue(formatter.format(deliverys.get(j).getCreateTime()));
+                        } else {
+                            row.createCell(2).setCellValue("");
+                        }
+
+                        if (null != deliverys.get(j).getExpId()) {
+                            for(int n = 0 ; n< expressTypes.size() ; n++){
+                                if(deliverys.get(j).getExpId().intValue() == expressTypes.get(n).getExpId()){
+                                    row.createCell(3).setCellValue(expressTypes.get(n).getExpName());
+                                    break;
+                                }
+                            }
+                        } else {
+                            row.createCell(3).setCellValue("");
+                        }
+                        if(null != deliverys.get(j).getStatus()){
+                            switch (deliverys.get(j).getStatus().intValue()){
+                              case Constants.ORDER_STATUS_DISPATCHING : row.createCell(4).setCellValue("派送中");
+                                break;
+                               case Constants.ORDER_STATUS_REJECT_RETENTION : row.createCell(4).setCellValue("滞留");
+                                break;
+                                case Constants.ORDER_STATUS_LEAVE_STORE : row.createCell(4).setCellValue("退回");
+                                break;
+                                case Constants.ORDER_STATUS_COMPLETE : row.createCell(4).setCellValue("已完成");
+                                break;
+                                default:row.createCell(4).setCellValue("在库");
+                                break;
+                            }
+                        }else {
+                            row.createCell(4).setCellValue(" ");
+                        }
+
+                        //签收
+                        if (null != deliverys.get(j).getStatus() && deliverys.get(j).getSignStatus().intValue() == 1) {
+                            row.createCell(4).setCellValue("签收");
+                        }
+
+                        if (null != deliverys.get(j).getStatusTime()&&deliverys.get(j).getStatusTime()!=deliverys.get(j).getCreateTime()) {
+                            row.createCell(5).setCellValue(sdfTime.format(deliverys.get(j).getStatusTime()));
+                        } else {
+                            row.createCell(5).setCellValue("");
+                        }
+        }
+        *//***********************准备邮件并发送**********************//*
+//                    workBook.write(out);
+       ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        workBook.write(baos);
+        baos.flush();
+        byte[] bt = baos.toByteArray();
+        is = new ByteArrayInputStream(bt, 0, bt.length);
+        baos.close();
+        Boolean flag = false;
+        String xslName = "入库统计数据"  + user.getStoreId() + format.format(date) + getTwoCode();
+        String context = beginTime + "到" +mailEndTime + "的入库统计信息";
+        if (!"".equalsIgnoreCase(email)) {
+            //推送Mq消息
+            ExportQueue exportQueue=new ExportQueue();
+            exportQueue.setEmail(email);
+            exportQueue.setIs(is);
+            exportQueue.setContext(context);
+            exportQueue.setXslName(xslName);
+            String exportQueues=JSON.toJSONString(exportQueue);
+            exportPushService.push(exportQueues);
+            flag = sendMail(email, is,context,xslName,"入库统计数据导出");
+        }
+//        if(flag){
+            return buildJson(0,"发送成功");
+      *//*  }
+        return buildJson(-1,"发送失败");*/
+
+    }
+
+    //消费信息导出
+    @ResponseBody
+    @RequestMapping("/app/getCommentMange")
+    public Object getComuntMent(HttpServletRequest request,
+                                @RequestParam(defaultValue = "") String mouth,//月
+                                @RequestParam(defaultValue = "") String consumeFlag//消费类型
+    ) throws Exception {
+        return buildJson(1, "系统升级中!");
+//        User user = getUserFromParam(request);
+//        if (user == null) {
+//            return buildJson(1, "用户未登录");
+//        }
+//        String email = user.getUserMail();
+//        if(null == email || "".equals(email)){
+//            return buildJson(-1, "邮箱未完善");
+//        }
+//        Date date = new Date();
+//        String beginTime = "";
+//        String endTime = "";
+//        if("".equals(mouth)){//本月
+//            beginTime = dft.format(date);
+//            mouth = beginTime;
+//        }else{
+//            Date mouthDate = dft.parse(mouth.toString());
+//            beginTime = dft.format(mouthDate);
+//        }
+//        endTime = getPreMonth(beginTime);
+//        beginTime = beginTime + "-01";
+//        endTime = endTime + "-01";
+//        // 封装查询条件
+//        List<ConsumeListDto> consumeList=new ArrayList<>();
+//        /*user.setStoreId(1);*/
+//        if (isEmpty(consumeFlag)){
+//            consumeList = consumeRecordService.getAllConsumeList4app(beginTime,endTime,String.valueOf(user.getStoreId()));
+//        }else{
+//            consumeList = consumeRecordService.getConsumeList4app(consumeFlag,beginTime,endTime,String.valueOf(user.getStoreId()));
+//        }
+//        Collections.sort(consumeList, new Comparator<ConsumeListDto>() {
+//            @Override
+//            public int compare(ConsumeListDto o1, ConsumeListDto o2) {
+//                if(o1.getCreateTime().getTime() > o2.getCreateTime().getTime()){
+//                    return -1;
+//                }else if(o1.getCreateTime().getTime() > o2.getCreateTime().getTime()){
+//                    return 1;
+//                }else {
+//                    return 0;
+//                }
+//            }
+//        });
+//        int totalConsumeCount = 0;
+//        BigDecimal totalConsumeAmount = BigDecimal.ZERO;
+//        for (ConsumeListDto consumeListDto:consumeList) {
+//            totalConsumeCount += consumeListDto.getConsumeCount();
+//            BigDecimal amount =BigDecimal.ZERO;
+//            if(consumeListDto.getConsumeAmount()==null){
+//                amount=BigDecimal.ZERO;
+//            }else{
+//                amount=BigDecimal.valueOf(Double.valueOf(consumeListDto.getConsumeAmount()));
+//            }
+//
+//            totalConsumeAmount = totalConsumeAmount.add(amount);
+//        }
+//        int totalCount = consumeList.size();
+//        ConsumeListDto consumeDto = new ConsumeListDto();
+//        consumeDto.setConsumeAmount(totalConsumeAmount.toString());
+//        consumeDto.setConsumeCount(totalConsumeCount);
+//        consumeDto.setConsumeFlag("-1");
+//        consumeList.add(consumeDto);
+//        String path = request.getSession().getServletContext().getRealPath("WEB-INF/excel/status.xls");
+//        FileInputStream template = new FileInputStream(path);
+//        // 如果是xlsx,2007,用XSSF,如果是xls,2003,用HSSF
+//        // 一个Excel文件的层次:Excel文件-> 工作表-> 行-> 单元格 对应到POI中,为:workbook-> sheet-> row-> cell
+//        HSSFWorkbook workBook=new HSSFWorkbook(template);
+//        // 获取第一个sheet页
+//        HSSFSheet sheet=workBook.getSheetAt(0);
+//        List<String> columns = new ArrayList<String>();
+//        columns.add("序号");
+//        columns.add("日期");
+//        columns.add("通知类型");
+//        columns.add("使用条数");
+//        columns.add("消费金额");
+//        // 创建表头并赋值
+//        HSSFRow rowTitle = sheet.createRow(0);
+//        HSSFCell cellTitle = rowTitle.createCell(0);
+//        //  cellTitle.setCellValue(sheetTitle);
+//        int rowTitlenum = 0;
+//        for (String colstr: columns) {
+//            rowTitle.createCell(rowTitlenum).setCellValue(colstr);
+//            rowTitlenum += 1;
+//        }
+//        // 创建剧中样式
+//        HSSFCellStyle cellStyle = workBook.createCellStyle();
+//        // 垂直居中
+//        cellStyle.setAlignment(HSSFCellStyle.VERTICAL_CENTER);
+//        // 水平居中
+//        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+//        // 创建字体
+//        HSSFFont cellFont = workBook.createFont();
+//        cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+//        cellFont.setFontHeight((short) 250);
+//        cellStyle.setFont(cellFont);
+//        cellTitle.setCellStyle(cellStyle);
+//        //sheet.addCell(new Label(i, 0, columns.get(i), wcf));
+//        /**********************遍历作为邮件的附件***********************/
+//        // 行号下标,从0开始
+//        InputStream is = null;
+//        int rowIndex = 0 ;
+//        for(int j=0;j<consumeList.size();j++) {
+//            rowIndex++;
+//            // 创建行
+//            HSSFRow row = sheet.createRow(rowIndex);
+//            row.createCell(0).setCellValue(j + 1);
+//            if (null != consumeList.get(j).getCreateTime()) {
+//                Date createDate = consumeList.get(j).getCreateTime();
+//                row.createCell(1).setCellValue(formatter.format(createDate));
+//            } else {
+//                row.createCell(1).setCellValue("");
+//            }
+//            if (null != consumeList.get(j).getConsumeFlag()) {
+//                String consumStr = consumeList.get(j).getConsumeFlag();
+//                if(consumStr.equals("1")){
+//                    row.createCell(2).setCellValue("短信消费");
+//                }else if(consumStr.equals("0")){
+//                    row.createCell(2).setCellValue("OCR识别");
+//                }else if(consumStr.equals("-1")){
+//                    row.createCell(2).setCellValue("合计");
+//                }
+//            } else {
+//                row.createCell(2).setCellValue("");
+//            }
+//            row.createCell(3).setCellValue(consumeList.get(j).getConsumeCount());
+//            if (null != consumeList.get(j).getConsumeAmount()) {
+//                String conSumeStr = consumeList.get(j).getConsumeAmount();
+//                /*String intNumber = conSumeStr.substring(0,conSumeStr.indexOf("."));
+//                if((conSumeStr.length() - intNumber.length()) < 3){
+//                    conSumeStr += "00000";
+//                }
+//                String value=conSumeStr.substring(0,intNumber.length()+3);*/
+//                Double d= Double.parseDouble(conSumeStr);
+//                DecimalFormat df = new DecimalFormat("0.000");
+//                String s = df.format(d);
+//                row.createCell(4).setCellValue(s);
+//            } else {
+//                row.createCell(4).setCellValue("0");
+//            }
+//        }
+//        /***********************准备邮件并发送**********************/
+////                    workBook.write(out);
+//        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+//        workBook.write(baos);
+//        baos.flush();
+//        byte[] bt = baos.toByteArray();
+//        is = new ByteArrayInputStream(bt, 0, bt.length);
+//        baos.close();
+//        Boolean flag = false;
+//        String context = mouth + "月的消费信息";
+//        String xslName = "消费统计数据"  + user.getStoreId() + format.format(date) + getTwoCode();
+//        if (!"".equalsIgnoreCase(email)) {
+//            flag = sendMail(email, is,context,xslName,"消费统计数据导出");
+//        }
+//        if(flag){
+//            return buildJson(0,"发送成功");
+//        }
+//        return buildJson(-1,"发送失败");
+    }
+
+    //充值信息导出
+    @RequestMapping("/app/getPurchaseRecord")
+    @ResponseBody
+    public Object operate(HttpServletRequest request,
+                          @RequestParam(defaultValue = "") String mouth,
+                          @RequestParam(defaultValue = "-1") int offset) throws Exception {
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1, "用户未登录");
+        }
+        String email = user.getUserMail();
+        if(null == email || "".equals(email)){
+            return buildJson(-1, "邮箱未完善");
+        }
+        String outTradeNo = null;
+        if(request.getParameter("outTradeNo")!=null&& StringUtils.isNotBlank(request.getParameter("outTradeNo"))){
+            outTradeNo=request.getParameter("outTradeNo");
+        }
+        String payStatus = null;
+        if(request.getParameter("payStatus")!=null&& StringUtils.isNotBlank(request.getParameter("payStatus"))){
+            payStatus=request.getParameter("payStatus");
+        }
+        Date date = new Date();
+        String beginTime1 = "";
+        String endTime1 = "";
+        if("".equals(mouth)){//本月
+            beginTime1 = dft.format(date);
+            mouth = beginTime1;
+        }else{
+            Date mouthDate = dft.parse(mouth.toString());
+            beginTime1 = dft.format(mouthDate);
+        }
+        endTime1 = getPreMonth(beginTime1);
+        beginTime1 = beginTime1 + "-01";
+        endTime1 = endTime1 + "-01";
+        Date beginTime=null;
+        Date endTime=null;
+        beginTime=formatter.parse(beginTime1);
+        endTime= formatter.parse(endTime1);
+        DeliveryQueryCondition qc  = new DeliveryQueryCondition(user.getStoreId());
+        qc.setBeginTime(beginTime);
+        qc.setEndTime(endTime);
+        /*Date beginTime=null;
+        DeliveryQueryCondition qc  = new DeliveryQueryCondition(user.getStoreId());
+        if(request.getParameter("beginTime")!=null&&StringUtils.isNotBlank(request.getParameter("beginTime"))) {
+            beginTime=df.parse(request.getParameter("beginTime"));
+            qc.setBeginTime(beginTime);
+        }
+        Date endTime=null;
+        if(request.getParameter("endTime")!=null&&StringUtils.isNotBlank(request.getParameter("endTime"))){
+            endTime= df.parse(request.getParameter("endTime"));
+            qc.setEndTime(endTime);
+        }*/
+        String payWay = null;
+        if(request.getParameter("payWay")!=null&& StringUtils.isNotBlank(request.getParameter("payWay"))){
+            payWay=request.getParameter("payWay");
+        }
+        PurchaseRecordSearch doCondition = new PurchaseRecordSearch();
+        doCondition.setStoreId(user.getStoreId());
+        doCondition.setOutTradeNo(outTradeNo);
+        doCondition.setBeginTime(beginTime);
+        doCondition.setEndTime(endTime);
+        doCondition.setPayWay(payWay);
+        doCondition.setPayStatus(payStatus);
+        PagedList<SmsPurchaseRecord> dataPagedList= null;
+        // dataPagedList=purchaseRecordService.getDetail(doCondition,1, p, size);
+        //合计信息
+        BigDecimal totalAmount = BigDecimal.ZERO;
+        List<SmsPurchaseRecord> totalList = purchaseRecordService.getTotalList(doCondition,1, 0, 0);
+        for (SmsPurchaseRecord purchaseRecord:totalList) {
+            //BigDecimal amount = BigDecimal.valueOf(Double.valueOf(consumeListDto.getConsumeAmount()));
+            totalAmount = totalAmount.add(purchaseRecord.getAmount());
+        }
+        SmsPurchaseRecord smsPurchaseRecord = new SmsPurchaseRecord();
+        smsPurchaseRecord.setPayWay(-1);
+        smsPurchaseRecord.setAmount(totalAmount);
+        smsPurchaseRecord.setPayStatus(-1);
+        totalList.add(smsPurchaseRecord);
+        String path = request.getSession().getServletContext().getRealPath("WEB-INF/excel/status.xls");
+        FileInputStream template = new FileInputStream(path);
+        // 如果是xlsx,2007,用XSSF,如果是xls,2003,用HSSF
+        // 一个Excel文件的层次:Excel文件-> 工作表-> 行-> 单元格 对应到POI中,为:workbook-> sheet-> row-> cell
+        HSSFWorkbook workBook=new HSSFWorkbook(template);
+        // 获取第一个sheet页
+        HSSFSheet sheet=workBook.getSheetAt(0);
+        List<String> columns = new ArrayList<String>();
+        columns.add("序号");
+        columns.add("日期");
+        columns.add("充值方式");
+        columns.add("充值状态");
+        columns.add("充值金额");
+        // 创建表头并赋值
+        HSSFRow rowTitle = sheet.createRow(0);
+        HSSFCell cellTitle = rowTitle.createCell(0);
+        //  cellTitle.setCellValue(sheetTitle);
+        int rowTitlenum = 0;
+        for (String colstr: columns) {
+            rowTitle.createCell(rowTitlenum).setCellValue(colstr);
+            rowTitlenum += 1;
+        }
+        // 创建剧中样式
+        HSSFCellStyle cellStyle = workBook.createCellStyle();
+        // 垂直居中
+        cellStyle.setAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 水平居中
+        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 创建字体
+        HSSFFont cellFont = workBook.createFont();
+        cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+        cellFont.setFontHeight((short) 250);
+        cellStyle.setFont(cellFont);
+        cellTitle.setCellStyle(cellStyle);
+        //sheet.addCell(new Label(i, 0, columns.get(i), wcf));
+        /**********************遍历作为邮件的附件***********************/
+        // 行号下标,从0开始
+        InputStream is = null;
+        int rowIndex = 0 ;
+        for(int j=0;j<totalList.size();j++) {
+            rowIndex++;
+            // 创建行
+            HSSFRow row = sheet.createRow(rowIndex);
+            row.createCell(0).setCellValue(j + 1);
+            if (null != totalList.get(j).getOptTime()) {
+                Date createDate = totalList.get(j).getOptTime();
+                row.createCell(1).setCellValue(formatter.format(createDate));
+            } else {
+                row.createCell(1).setCellValue("");
+            }
+            int numPay = totalList.get(j).getPayWay();
+            switch (numPay){
+                case 1:  row.createCell(2).setCellValue("支付宝");
+                    break;
+                case 2:  row.createCell(2).setCellValue("微信");
+                    break;
+                case 3:  row.createCell(2).setCellValue("赠送");
+                    break;
+                case 4:  row.createCell(2).setCellValue("线下充值");
+                    break;
+                case -1:  row.createCell(2).setCellValue("总计");
+                    break;
+            }
+            int payStatusNum = totalList.get(j).getPayStatus();
+            if(payStatusNum == 1){
+                row.createCell(3).setCellValue("成功");
+            }else if(payStatusNum == 0){
+                row.createCell(3).setCellValue("失败");
+            }else if(payStatusNum == -1){
+                row.createCell(3).setCellValue("");
+            }
+            if (null != totalList.get(j).getAmount()) {
+                String conSumeStr = totalList.get(j).getAmount().toString();
+                String intNumber = conSumeStr.substring(0,conSumeStr.indexOf("."));
+                if((conSumeStr.length() - intNumber.length()) < 3){
+                    conSumeStr += "00000";
+                }
+                row.createCell(4).setCellValue(conSumeStr.substring(0,intNumber.length()+3));
+            } else {
+                row.createCell(4).setCellValue("");
+            }
+        }
+        /***********************准备邮件并发送**********************/
+//                    workBook.write(out);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        workBook.write(baos);
+        baos.flush();
+        byte[] bt = baos.toByteArray();
+        is = new ByteArrayInputStream(bt, 0, bt.length);
+        baos.close();
+        Boolean flag = false;
+        String context = mouth + "月的充值信息";
+        String xslName = "充值统计数据"  + user.getStoreId() + format.format(date) + getTwoCode();
+        if (!"".equalsIgnoreCase(email)) {
+            flag = sendMail(email, is,context,xslName,"充值统计数据导出");
+        }
+        if(flag){
+            return buildJson(0,"发送成功");
+        }
+        return buildJson(-1,"发送失败");
+    }
+
+    //统计信息导出
+    @ResponseBody
+    @RequestMapping("/app/getAttachmentMangeCopy")
+    public Object getAttachmentCopy(HttpServletRequest request,
+                                    @RequestParam(defaultValue = "1") String currentPage,//默认查全部快递
+                                    @RequestParam(defaultValue = "10") String pageSize,
+                                    @RequestParam(defaultValue = "") String expId,//默认查全部快递
+                                    @RequestParam(defaultValue = "") String beginTime,
+                                    @RequestParam(defaultValue = "") String endTime
+    ) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+        String email = user.getUserMail();
+        if(null == email || "".equals(email)){
+            return buildJson(-1, "邮箱未完善");
+        }
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        if (!"".equals(expId)) {
+            qc.setExp_Id(expId);
+        }
+        String mailEndTime = "";
+        Date date = new Date();
+        //根据开始时间和结束时间得到一个时间字符串数组
+        List<String> dataStr = new ArrayList<String>();
+        if (null == beginTime || "".equals(beginTime)) {//开始是今天,结束是明天
+            beginTime = formatter.format(date);
+        } else {
+            Date beginTime1 = formatter.parse(beginTime);
+            beginTime = formatter.format(beginTime1);
+            if (null == endTime || "".equals(endTime)) {
+                mailEndTime = formatter.format(date);
+                endTime = getSpecifiedDayAfter(formatter.format(date));
+            }else{
+                mailEndTime = endTime;
+                Date endTime1 = formatter.parse(endTime);
+                endTime = getSpecifiedDayAfter(formatter.format(endTime1));
+            }
+        }
+        if (null == endTime || "".equals(endTime)) {
+            mailEndTime = formatter.format(date);
+            endTime = getSpecifiedDayAfter(formatter.format(date));
+        }
+        dataStr = getTime(beginTime, endTime, dataStr);
+        //开始时间和结束时间不为null
+        qc.setCreateTime(beginTime, endTime);
+        List<JCountDto> result =  statService.getTotalList(qc,dataStr,currentPage,pageSize);
+        String path = request.getSession().getServletContext().getRealPath("WEB-INF/excel/status.xls");
+        FileInputStream template = new FileInputStream(path);
+        // 如果是xlsx,2007,用XSSF,如果是xls,2003,用HSSF
+        // 一个Excel文件的层次:Excel文件-> 工作表-> 行-> 单元格 对应到POI中,为:workbook-> sheet-> row-> cell
+        HSSFWorkbook workBook=new HSSFWorkbook(template);
+        // 获取第一个sheet页
+        HSSFSheet sheet=workBook.getSheetAt(0);
+
+        /******************************设置表头*****************************/
+        //String sheetTitle = "入库统计表";
+        // 单元格合并
+        // 四个参数分别是:起始行,起始列,结束行,结束列
+        //sheet.addMergedRegion(new CellRangeAddress(0,0,2,10));
+        List<String> columns = new ArrayList<String>();
+        columns.add("序号");
+        columns.add("日期");
+        columns.add("快递公司");
+        columns.add("入库量");
+        columns.add("签收量");
+        columns.add("派送中");
+        columns.add("滞留量");
+        columns.add("退回量");
+        // 创建表头并赋值
+        HSSFRow rowTitle = sheet.createRow(0);
+        HSSFCell cellTitle = rowTitle.createCell(0);
+        //  cellTitle.setCellValue(sheetTitle);
+        int rowTitlenum = 0;
+        for (String colstr: columns) {
+            rowTitle.createCell(rowTitlenum).setCellValue(colstr);
+            rowTitlenum += 1;
+        }
+        // 创建剧中样式
+        HSSFCellStyle cellStyle = workBook.createCellStyle();
+        // 垂直居中
+        cellStyle.setAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 水平居中
+        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 创建字体
+        HSSFFont cellFont = workBook.createFont();
+        cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+        cellFont.setFontHeight((short) 250);
+        cellStyle.setFont(cellFont);
+        cellTitle.setCellStyle(cellStyle);
+        //sheet.addCell(new Label(i, 0, columns.get(i), wcf));
+        /**********************遍历作为邮件的附件***********************/
+        // 行号下标,从0开始
+        InputStream is = null;
+        int rowIndex = 0 ;
+        for(int j=0;j<result.size();j++) {
+            rowIndex++;
+            // 创建行
+            HSSFRow row = sheet.createRow(rowIndex);
+            row.createCell(0).setCellValue(j + 1);
+            if (null != result.get(j).getQueryDate()) {
+                row.createCell(1).setCellValue(result.get(j).getQueryDate());
+            } else {
+                row.createCell(1).setCellValue("");
+            }
+            if (null != result.get(j).getExpName()) {
+                row.createCell(2).setCellValue(result.get(j).getExpName());
+            } else {
+                row.createCell(2).setCellValue("");
+            }
+            if (null != result.get(j).getStorgeCount()) {
+                row.createCell(3).setCellValue(result.get(j).getStorgeCount());
+            } else {
+                row.createCell(3).setCellValue("");
+            }
+            if (null != result.get(j).getSignCount()) {
+                row.createCell(4).setCellValue(result.get(j).getSignCount());
+            } else {
+                row.createCell(4).setCellValue("");
+            }
+            if (null != result.get(j).getDispatchCount()) {
+                row.createCell(5).setCellValue(result.get(j).getDispatchCount());
+            } else {
+                row.createCell(5).setCellValue("");
+            }
+            if (null != result.get(j).getResidenceCount()) {
+                row.createCell(6).setCellValue(result.get(j).getResidenceCount());
+            } else {
+                row.createCell(6).setCellValue("");
+            }
+
+            if (null != result.get(j).getReturnCount()) {
+                row.createCell(7).setCellValue(result.get(j).getReturnCount());
+            } else {
+                row.createCell(7).setCellValue("");
+            }
+        }
+        /***********************准备邮件并发送**********************/
+//                    workBook.write(out);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        workBook.write(baos);
+        baos.flush();
+        byte[] bt = baos.toByteArray();
+        is = new ByteArrayInputStream(bt, 0, bt.length);
+        baos.close();
+        Boolean flag = false;
+        String xslName = "入库统计数据"  + user.getStoreId() + format.format(date) + getTwoCode();
+        String context = beginTime + "到" +mailEndTime + "的入库统计信息";
+        if (!"".equalsIgnoreCase(email)) {
+            flag = sendMail(email, is,context,xslName,"入库统计数据导出");
+
+        }
+        if(flag){
+            return buildJson(0,"发送成功");
+        }
+        return buildJson(-1,"发送失败");
+    }
+
+
+    public boolean sendMail(String toMail, InputStream is, String context, String xslName,String mailInfo) {
+        //发件人账户名
+        String senderAccount = EmailConfig.getEmailAccount();
+        //发件人账户密码
+        String senderPassword = EmailConfig.getEmailPassword();
+        System.setProperty("mail.mime.splitlongparameters", "false");
+        System.setProperty("mail.mime.charset", "GB18030");
+        boolean isFlag = false;
+        Properties props = new Properties();
+        MailSSLSocketFactory sf = null;
+
+        try {
+            sf = new MailSSLSocketFactory();
+            sf.setTrustAllHosts(true);
+            props.put("mail.smtp.ssl.enable", "true");
+            props.put("mail.smtp.ssl.socketFactory", sf);
+            props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
+            props.setProperty("mail.smtp.auth", "true");
+            props.setProperty("mail.transport.protocol", "smtp");
+            props.setProperty("mail.smtp.host", "SMTP.QQ.COM");
+            Session session = Session.getInstance(props);
+            session.setDebug(true);
+            MimeMessage message = new MimeMessage(session);
+            BASE64Encoder enc = new BASE64Encoder();
+            //String subject = new String("佰颂物流文件导出".getBytes("GB18030"), Charset.defaultCharset());
+            // String subject = new String(enc.encode(mailInfo.getBytes("GB18030")));
+            message.setSubject(MimeUtility.encodeText(mailInfo, "GB18030", "B"));
+            //message.setSubject("=?GB18030?B?" + enc.encode(subject.getBytes()) + "?=");
+            // message.setFrom(new InternetAddress(senderAddress));
+            String nick="";
+            try {
+                nick=MimeUtility.encodeText(EmailConfig.getEmailName());
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            message.setFrom(new InternetAddress(nick+" <"+senderAccount+">"));
+            Transport transport = session.getTransport("smtp");
+            transport.connect(senderAccount, senderPassword);
+            message.addRecipient(Message.RecipientType.TO, new InternetAddress(toMail));
+            message.addHeader("charset", "GB18030");
+            Multipart multipart = new MimeMultipart();
+            BodyPart contentPart = new MimeBodyPart();
+            contentPart.setContent(context, "text/html;charset=GB18030");
+            multipart.addBodyPart(contentPart);
+            MimeBodyPart fileBody = new MimeBodyPart();
+            DataSource source = new ByteArrayDataSource(is, "application/msexcel");
+            fileBody.setDataHandler(new DataHandler(source));
+            String fileName = xslName + ".xls";
+            fileBody.setFileName(MimeUtility.encodeText(fileName, "GB18030", "B"));
+            multipart.addBodyPart(fileBody);
+            message.setContent(multipart);
+            message.setSentDate(new Date());
+            message.saveChanges();
+            transport.sendMessage(message, message.getAllRecipients());
+            transport.close();
+            isFlag = true;
+        } catch (Exception var18) {
+            var18.printStackTrace();
+            isFlag = false;
+        }
+
+        return isFlag;
+    }
+
+    private String getSpecifiedDayAfter(String specifiedDay){
+        Calendar c = Calendar.getInstance();
+        Date date=null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        c.setTime(date);
+        int day=c.get(Calendar.DATE);
+        c.set(Calendar.DATE,day+1);
+
+        String dayAfter=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+    private List<String> getTime(String beginTime,String endTime,List<String> list) throws Exception {
+        Boolean flag = true;
+        while (flag){
+            list.add(beginTime);
+            Date beginTime1 = formatter.parse(beginTime);
+            Date endTime1 = formatter.parse(endTime);
+            beginTime = getSpecifiedDayAfter(formatter.format((beginTime1)));
+            if(beginTime.equals(endTime) || beginTime1.after(endTime1)){
+                flag = false;
+            }
+        }
+        return list;
+    }
+    private List<ConsumeListDto> appGetConsumeListDto(List<ConsumeListDto> resultDtoList, int currentPage, int pageSize) {
+        int count = resultDtoList.size();
+        int begin = (currentPage - 1) * pageSize;
+        int end = begin + pageSize;
+        if (count > end) {
+            return resultDtoList.subList(begin, end);
+        }
+
+        if (count > begin) {
+            return resultDtoList.subList(begin, count);
+        }
+
+        return resultDtoList.subList(0,0);
+    }
+
+    private String getPreMonth(String mouth) {
+        Calendar cal = Calendar.getInstance();
+        Date date = null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM").parse(mouth);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        cal.setTime(date);
+        cal.add(cal.MONTH, 1);
+        String preMonth = dft.format(cal.getTime());
+        return preMonth;
+    }
+
+    //生成2为随机数
+    private String getTwoCode() {
+        int n = 2;
+        StringBuilder code = new StringBuilder();
+        Random ran = new Random();
+        for (int i = 0; i < n; i++) {
+            code.append(Integer.valueOf(ran.nextInt(10)).toString());
+        }
+        return code.toString();
+    }
+    //充值信息导出
+    @RequestMapping("/app/getPurchaseRecord1")
+    @ResponseBody
+    public Object operate1(HttpServletRequest request,
+                           @RequestParam(defaultValue = "") String mouth,
+                           @RequestParam(defaultValue = "-1") int offset) throws Exception {
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1, "用户未登录");
+        }
+        String email = user.getUserMail();
+        if(null == email || "".equals(email)){
+            return buildJson(-1, "邮箱未完善");
+        }
+        String path = request.getSession().getServletContext().getRealPath("WEB-INF/excel/status.xls");
+        //String path = "E:/status.xls";
+        FileInputStream template = new FileInputStream(path);
+        // 如果是xlsx,2007,用XSSF,如果是xls,2003,用HSSF
+        // 一个Excel文件的层次:Excel文件-> 工作表-> 行-> 单元格 对应到POI中,为:workbook-> sheet-> row-> cell
+        HSSFWorkbook workBook=new HSSFWorkbook(template);
+        // 获取第一个sheet页
+        HSSFSheet sheet=workBook.getSheetAt(0);
+
+        /******************************设置表头*****************************/
+        String sheetTitle = "nihao";
+        // 单元格合并
+        // 四个参数分别是:起始行,起始列,结束行,结束列
+        sheet.addMergedRegion(new CellRangeAddress(0,0,2,10));
+        // 创建表头并赋值
+        HSSFRow rowTitle = sheet.createRow(0);
+        HSSFCell cellTitle = rowTitle.createCell(0);
+        cellTitle.setCellValue(sheetTitle);
+
+        // 创建剧中样式
+        HSSFCellStyle cellStyle = workBook.createCellStyle();
+        // 垂直居中
+        cellStyle.setAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 水平居中
+        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 创建字体
+        HSSFFont cellFont = workBook.createFont();
+        cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+        cellFont.setFontHeight((short) 300);
+        cellStyle.setFont(cellFont);
+        cellTitle.setCellStyle(cellStyle);
+
+
+
+        /***********************准备邮件并发送**********************/
+
+        Properties props = new Properties();
+        JavaMailSenderImpl sender = new JavaMailSenderImpl();
+        props.put("mail.smtp.auth", "true");
+        sender.setHost("smtp.qq.com");
+        sender.setUsername("464602809@qq.com");
+        sender.setPassword("kfawcdojnkncbhai");
+        sender.setJavaMailProperties(props);
+
+
+
+        MimeMessage message = sender.createMimeMessage();
+        MimeMessageHelper helper = new MimeMessageHelper(message, true,"utf-8");
+        helper.setFrom("464602809@qq.com");
+        helper.setTo("780200375@qq.com");
+        helper.setSubject("添加附件");
+        helper.setText("xx....!");
+
+        FileSystemResource file = new FileSystemResource(new File(path));
+        helper.addAttachment("a.jpg", file);
+
+        sender.send(message);
+        return buildJson(0,"发送成功");
+    }
+}

+ 343 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppSettingController.java

@@ -0,0 +1,343 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.store.helper.DeliveryMsgSendHelper;
+import cn.haliaeetus.controller.web.SettingAction;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.entity.dto.ConsumeListDto;
+import cn.haliaeetus.entity.jspo.JsonMsg;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.toolkit.PagedList;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.service.*;
+import cn.haliaeetus.service.rsync.ConsumeRecordService;
+import com.google.gson.JsonObject;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.sql.SQLException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static cn.haliaeetus.framework._.isEmpty;
+import static cn.haliaeetus.framework.util.StringUtil.trimToEmpty;
+
+/** 充值信息查询
+ * Created by Administrator on 2018/12/29 0029.
+ */
+@Controller
+public class AppSettingController extends BaseController{
+    private static final Logger log = LoggerFactory.getLogger(SettingAction.class);
+    @Autowired
+    private PurchaseRecordService purchaseRecordService;
+    @Autowired
+    private BasicInfoService basicService;
+    @Autowired
+    private DeliveryMsgTemplateConfigService deliveryMsgTemplateConfigService;
+
+    @Autowired
+    private ConsumeRecordService consumeRecordService;
+
+    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+    private  SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM");
+    // 个人中心
+    @RequestMapping("/app/setsmsconfig")
+    @ResponseBody
+    public Object setsmsconfig(HttpServletRequest request) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null){
+         return buildJson(1, "用户未登录");
+        }
+        Store store = basicService.getStoreById(user.getStoreId());
+        log.info("store:{}", store);
+
+        DeliveryMsgTemplateConfig smsConfig = deliveryMsgTemplateConfigService
+                .getMsgTemplateConfig(user.getStoreId(), 6, 1);
+        log.info("storeSMSConfig:{}", smsConfig);
+
+        Integer configId = 0;
+        Integer containsShelf = 1;
+        String shortAddress = "";
+        if (smsConfig != null) {
+            configId = smsConfig.getId() == null ? 0 : smsConfig.getId();
+            containsShelf = smsConfig.getContainsShelf() == null ? 1
+                    : smsConfig.getContainsShelf();
+            shortAddress = smsConfig.getStoreAddress();
+        }
+
+        // 门店短地址默认取短信配置表,为空则取门店信息表
+        if (isEmpty(shortAddress) && store !=null) {
+            shortAddress = trimToEmpty(store.getShortAddress());
+        }
+
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("code",0);
+        jsonObject.addProperty("msg","请求成功");
+        JsonObject result = new JsonObject();
+        result.addProperty("configId", configId);
+        result.addProperty("shortName",store.getShortName());
+        result.addProperty("takeExpressPhone",user.getUserId());
+        //result.addProperty("takeExpressPhone",store.getTakeExpressPhone());
+        result.addProperty("phoneLogo",Constants.FASTDFS_CLIENT_SERVER + user.getPhoneLogo());
+        result.addProperty("address",store.getAddress());
+        result.addProperty("shortAddress",shortAddress);
+        result.addProperty("startTime",store.getStartTime());
+        result.addProperty("endTime",store.getEndTime());
+        result.addProperty("userId",user.getUserId());
+        result.addProperty("email",user.getUserMail());
+        result.addProperty("userName",user.getUserName());
+        jsonObject.add("data",result);
+        return  jsonObject.toString();
+    }
+    //消费记录查询
+    @RequestMapping("/app/consumeList")
+    @ResponseBody
+    public Object consumeList(HttpServletRequest request,
+                              @RequestParam(defaultValue = "") String currentPage,
+                              @RequestParam(defaultValue = "") String pageSize,
+                              @RequestParam(defaultValue = "") String mouth,
+                              @RequestParam(defaultValue = "") String consumeFlag) throws SQLException, ParseException {
+        return buildJson(1, "系统升级中!");
+//        User user = getUserFromParam(request);
+//        if(null == user){
+//            return buildJson(1, "用户未登录");
+//        }
+//        if("".equals(currentPage)){
+//            currentPage = "1";
+//        }
+//        if("".equals(pageSize)){
+//            pageSize = "10";
+//        }
+//        Date date = new Date();
+//        String beginTime = "";
+//        String endTime = "";
+//        if("".equals(mouth)){//本月
+//            beginTime = dft.format(date);
+//        }else{
+//            Date mouthDate = dft.parse(mouth.toString());
+//            beginTime = dft.format(mouthDate);
+//        }
+//        endTime = getPreMonth(beginTime);
+//        beginTime = beginTime + "-01";
+//        endTime = endTime + "-01";
+//       /* if (isEmpty(beginTime))
+//            beginTime = DateUtil.today().toString("yyyy-MM-dd");
+//        if (isEmpty(endTime))
+//            endTime = DateUtil.today().toString("yyyy-MM-dd");
+//
+//        endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);*/
+//        int p = Integer.parseInt(currentPage);
+//        int s = Integer.parseInt(pageSize);
+//        // 封装查询条件
+//        List<ConsumeListDto> consumeList=new ArrayList<>();
+//		/*user.setStoreId(1);*/
+//        if (isEmpty(consumeFlag)){
+//            consumeList = consumeRecordService.getAllConsumeList4app(beginTime,endTime,String.valueOf(user.getStoreId()));
+//        }else{
+//            consumeList = consumeRecordService.getConsumeList4app(consumeFlag,beginTime,endTime,String.valueOf(user.getStoreId()));
+//        }
+//        for(ConsumeListDto consumeListDto:consumeList){
+//            if(consumeListDto.getConsumeAmount()==null){
+//                consumeListDto.setConsumeAmount("0");
+//            }
+//        }
+//        Collections.sort(consumeList, new Comparator<ConsumeListDto>() {
+//            @Override
+//            public int compare(ConsumeListDto o1, ConsumeListDto o2) {
+//               if(o1.getCreateTime().getTime() > o2.getCreateTime().getTime()){
+//                   return -1;
+//               }else if(o1.getCreateTime().getTime() > o2.getCreateTime().getTime()){
+//                   return 1;
+//               }else {
+//                   return 0;
+//               }
+//            }
+//        });
+//        int totalConsumeCount = 0;
+//        BigDecimal totalConsumeAmount = BigDecimal.ZERO;
+//        for (ConsumeListDto consumeListDto:consumeList) {
+//            totalConsumeCount += consumeListDto.getConsumeCount();
+//            BigDecimal amount = BigDecimal.valueOf(Double.valueOf(consumeListDto.getConsumeAmount()));
+//            totalConsumeAmount = totalConsumeAmount.add(amount);
+//        }
+//        int totalCount = consumeList.size();
+//        int totalPage = (totalCount - 1)/s +1;
+//        consumeList = appGetConsumeListDto(consumeList,p,s);
+//        JsonMsg jsonMsg = JsonMsg.getSuccess();
+//        jsonMsg.add("totalCount",totalCount);
+//        jsonMsg.add("consumeList",consumeList);
+//        jsonMsg.add("currentPage",p);
+//        jsonMsg.add("totalPage",totalPage);
+//        jsonMsg.add("totalConsumeCount",totalConsumeCount);
+//        jsonMsg.add("totalConsumeAmount",totalConsumeAmount.toString());
+//        return jsonMsg;
+    }
+    //充值记录
+    @RequestMapping("/app/purchaseRecord")
+    @ResponseBody
+    public Object operate(HttpServletRequest request,
+                          @RequestParam(defaultValue = "") String currentPage,
+                          @RequestParam(defaultValue = "") String pageSize,
+                          @RequestParam(defaultValue = "") String mouth,
+                          @RequestParam(defaultValue = "-1") int offset) throws Exception {
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1, "用户未登录");
+        }
+        if("".equals(currentPage)){
+            currentPage = "1";
+        }
+        if("".equals(pageSize)){
+            pageSize = "10";
+        }
+        int p = Integer.parseInt(currentPage);
+        int size = Integer.parseInt(pageSize);
+        String outTradeNo = null;
+        if(request.getParameter("outTradeNo")!=null&& StringUtils.isNotBlank(request.getParameter("outTradeNo"))){
+            outTradeNo=request.getParameter("outTradeNo");
+        }
+        String payStatus = null;
+        if(request.getParameter("payStatus")!=null&& StringUtils.isNotBlank(request.getParameter("payStatus"))){
+            payStatus=request.getParameter("payStatus");
+        }
+        Date date = new Date();
+        String beginTime1 = "";
+        String endTime1 = "";
+        if("".equals(mouth)){//本月
+            beginTime1 = dft.format(date);
+        }else{
+            Date mouthDate = dft.parse(mouth.toString());
+            beginTime1 = dft.format(mouthDate);
+        }
+        endTime1 = getPreMonth(beginTime1);
+        beginTime1 = beginTime1 + "-01";
+        endTime1 = endTime1 + "-01";
+        Date beginTime=null;
+        Date endTime=null;
+        beginTime=df.parse(beginTime1);
+        endTime= df.parse(endTime1);
+        DeliveryQueryCondition qc  = new DeliveryQueryCondition(user.getStoreId());
+        qc.setBeginTime(beginTime);
+        qc.setEndTime(endTime);
+        /*Date beginTime=null;
+        DeliveryQueryCondition qc  = new DeliveryQueryCondition(user.getStoreId());
+        if(request.getParameter("beginTime")!=null&&StringUtils.isNotBlank(request.getParameter("beginTime"))) {
+            beginTime=df.parse(request.getParameter("beginTime"));
+            qc.setBeginTime(beginTime);
+        }
+        Date endTime=null;
+        if(request.getParameter("endTime")!=null&&StringUtils.isNotBlank(request.getParameter("endTime"))){
+            endTime= df.parse(request.getParameter("endTime"));
+            qc.setEndTime(endTime);
+        }*/
+        String payWay = null;
+        if(request.getParameter("payWay")!=null&& StringUtils.isNotBlank(request.getParameter("payWay"))){
+            payWay=request.getParameter("payWay");
+        }
+        PurchaseRecordSearch doCondition = new PurchaseRecordSearch();
+        doCondition.setStoreId(user.getStoreId());
+        doCondition.setOutTradeNo(outTradeNo);
+        doCondition.setBeginTime(beginTime);
+        doCondition.setEndTime(endTime);
+        doCondition.setPayWay(payWay);
+        doCondition.setPayStatus(payStatus);
+        PagedList<SmsPurchaseRecord> dataPagedList= null;
+        dataPagedList=purchaseRecordService.getDetail(doCondition,1, p, size);
+        //合计信息
+        BigDecimal totalAmount = BigDecimal.ZERO;
+        List<SmsPurchaseRecord> totalList = purchaseRecordService.getTotalList(doCondition,1, p, size);
+        for (SmsPurchaseRecord purchaseRecord:totalList) {
+            //BigDecimal amount = BigDecimal.valueOf(Double.valueOf(consumeListDto.getConsumeAmount()));
+            totalAmount = totalAmount.add(purchaseRecord.getAmount());
+        }
+        JsonMsg jsonMsg = JsonMsg.getSuccess();
+        jsonMsg.add("totalCount",totalList.size());
+        jsonMsg.add("pageList",dataPagedList.items);
+        jsonMsg.add("totalAmount",totalAmount.toString());
+        jsonMsg.add("currentPage",dataPagedList.getCurPage());
+        jsonMsg.add("totalPage",dataPagedList.getTotalPages());
+        return jsonMsg;
+    }
+
+    private String getPreMonth(String mouth) {
+        Calendar cal = Calendar.getInstance();
+        Date date = null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM").parse(mouth);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        cal.setTime(date);
+        cal.add(cal.MONTH, 1);
+        String preMonth = dft.format(cal.getTime());
+        return preMonth;
+    }
+
+    private void createViewList(List<ExpressType> dispatchExpressList, List<StoreReceivedExpress> receivedExpList,
+                                String storeAddress, String storePhone, List<StoreReceivedExpress> viewList) {
+        Map<Integer, StoreReceivedExpress> receivedExpMap = getReceivedExpMap(receivedExpList);
+        StoreReceivedExpress temp = null;
+        for (ExpressType expressType : dispatchExpressList) {
+            if(expressType == null){
+                continue;
+            }
+            if (receivedExpMap.containsKey(expressType.getExpId())) {
+                viewList.add(receivedExpMap.get(expressType.getExpId()));
+            } else {
+                temp = new StoreReceivedExpress();
+                temp.setExpId(expressType.getExpId());
+                temp.setPhone(storePhone);
+                temp.setAddress(storeAddress);
+                temp.setIsUseStoreAddress(Constants.YES);
+                viewList.add(temp);
+            }
+        }
+    }
+
+    private Map<Integer, StoreReceivedExpress> getReceivedExpMap(List<StoreReceivedExpress> receivedExpList) {
+        Map<Integer, StoreReceivedExpress> receivedExpMap = new HashMap<Integer, StoreReceivedExpress>();
+        if (_.isNotEmpty(receivedExpList)) {
+            for (StoreReceivedExpress receivedExp : receivedExpList) {
+                receivedExpMap.put(receivedExp.getExpId(), receivedExp);
+            }
+        }
+        return receivedExpMap;
+    }
+    private List<String> generateTimeOptionsOfSMSConfig() {
+        List<String> options = new ArrayList<>();
+        for (int i = 0; i < 48; i++) {
+            String hour = (i / 2 < 10) ? ("0" + i / 2) : ("" + i / 2);
+            String minute = (i % 2 * 30 == 0) ? "00" : "30";
+            String option = hour + ":" + minute;
+            options.add(option);
+        }
+        return options;
+    }
+
+    private List<ConsumeListDto> appGetConsumeListDto(List<ConsumeListDto> resultDtoList, int currentPage, int pageSize) {
+        int count = resultDtoList.size();
+        int begin = (currentPage - 1) * pageSize;
+        int end = begin + pageSize;
+        if (count > end) {
+            return resultDtoList.subList(begin, end);
+        }
+
+        if (count > begin) {
+            return resultDtoList.subList(begin, count);
+        }
+
+        return resultDtoList.subList(0,0);
+    }
+}

+ 203 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppShelfController.java

@@ -0,0 +1,203 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.controller.store.helper.DeliveryMsgSendHelper;
+import cn.haliaeetus.controller.web.querycondition.UserQueryCondition;
+import cn.haliaeetus.entity.DeliveryMsgTemplateConfig;
+import cn.haliaeetus.entity.StoreShelf;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.DeliveryMsgTemplateConfigService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.StoreShelfService;
+import cn.haliaeetus.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**  货架管理
+ * Created by Administrator on 2019/1/3 0003.
+ */
+@Controller
+public class AppShelfController extends BaseController{
+    @Autowired
+    private StoreShelfService storeShelfService;
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private DeliveryMsgTemplateConfigService deliveryMsgTemplateConfigService;
+
+    //预先生成编码,仅仅供预览
+    @RequestMapping(value = "/app/newBarCode" )
+    @ResponseBody
+    public Object appBuildNewBarCode(HttpServletRequest request)
+            throws SQLException {
+        Map<String, Object> map = new HashMap<String, Object>();
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+        String barCodeString = "";
+        barCodeString = storeShelfService.getBarCode(user.getStoreId(), false);
+        map.put("code", 0);
+        map.put("msg", "获取成功");
+        map.put("barCode", barCodeString);
+        return map;
+    }
+//新增或编辑货架保存
+    @RequestMapping({ "/app/shelfSave" })
+    @ResponseBody
+    // {"shelfId":shelfId,"shelfName":shelfName}
+    public Object appShelfSave(HttpServletRequest request,
+                            @RequestParam(defaultValue = "0") int shelfId,
+                            @RequestParam(defaultValue = "") String shelfName,
+                            @RequestParam(defaultValue = "") String shlfBarCode,
+                            @RequestParam(defaultValue = "") String shelfAddress,
+                            @RequestParam(defaultValue = "") String shelfTelephone)
+            throws SQLException, IOException {
+
+        User user = getUserFromParam(request);
+
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        if (_.isEmpty(shelfName)) {
+            return buildJson(-1, "参数错误");
+        }
+
+        StoreShelf shelf = new StoreShelf();
+        shelf.setShelfName(shelfName);
+        shelf.setShelfAddress(shelfAddress);
+        shelf.setShelfTelephone(shelfTelephone);
+        HashMap<String, Object> map = new HashMap<String, Object>();
+
+        List<StoreShelf> shelfList = storeShelfService
+                .getByStoreIdAndShelfName(shelfId, user.getStoreId(), shelfName);
+
+        long succ = 0;
+
+        if (shelfId == 0) {
+            if (shelfList.size() == 0) {
+                succ = storeShelfService.insert(user.getStoreId(), shelf);
+                map.put("operate", "add");
+            } else {
+                map.put("code", -1);
+                map.put("msg", "货架名称已存在");
+                return map;
+            }
+        } else {
+            if (shelfList.size() == 0) {
+                Date time = new Date(System.currentTimeMillis());
+                shelf = storeShelfService.getById(shelfId);
+                shelf.setShelfName(shelfName);
+                shelf.setId(shelfId);
+                shelf.setTime(time);
+                shelf.setShelfAddress(shelfAddress);
+                shelf.setShelfTelephone(shelfTelephone);
+                succ = storeShelfService.update(shelf);
+                map.put("operate", "edit");
+            } else {
+                map.put("code", -1);
+                map.put("msg", "货架名称已存在");
+                return map;
+            }
+        }
+        if (succ > 0) {
+            map.put("code", 0);
+            map.put("msg", "新增或编辑货架成功~");
+            return map;
+        } else {
+            map.put("code", -1);
+            map.put("msg", "新增或编辑货架出错");
+            return map;
+        }
+    }
+    @RequestMapping({ "/app/shelfDel" })
+    @ResponseBody
+    // {"shelfId":shelfId}
+    public Object appShelfDel(HttpServletRequest request,
+                           @RequestParam(defaultValue = "0") int shelfId) throws SQLException {
+
+        User user = getUserFromParam(request);
+        HashMap<String, Object> map = new HashMap<String, Object>();
+
+        if (user == null) {
+          return  buildJson(1, "用户未登录");
+        }
+
+        long packageNum = storeShelfService.countPackageNum(user.getStoreId(),
+                shelfId);
+
+        if (packageNum > 0) {
+            return buildJson(-1, "货架上有包裹不能删除~");
+        }
+
+        long count = storeShelfService.countShelfInUse(user.getStoreId());
+        if (count <= 1){
+            return buildJson(-1, "最后一个货架不能删除~");
+        }
+
+        Date time = new Date(System.currentTimeMillis());
+        StoreShelf shelf = storeShelfService.getById(shelfId);
+        shelf.setIsdel(1);
+        shelf.setId(shelfId);
+        shelf.setTime(time);
+        int succ = storeShelfService.update(shelf);
+        if (succ > 0) {
+            return buildJson(0, "删除成功~");
+        }
+        return buildJson(-1, "删除货架出错~");
+    }
+
+
+
+    //取件码方式0自增  1运单号后四位
+    @RequestMapping({ "/app/appShelfCodeConfig" })
+    @ResponseBody
+    public Object appShelfCodeConfig(HttpServletRequest request,
+                               @RequestParam(defaultValue = "0") String codeType) throws SQLException {
+
+        User user = getUserFromParam(request);
+
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        if (_.isEmpty(codeType)) {
+            return buildJson(-1, "参数错误");
+        }
+
+        UserQueryCondition condition = new UserQueryCondition();
+        condition.setUserId(user.getUserId());
+
+        if ("1".equals(codeType)) {// 后四位编号 必须要货架号 1有货架
+            user.setCodeType(1);
+            condition.setEntity(user);
+            userService.updateUser(condition);
+            DeliveryMsgTemplateConfig msgTemplateConfig = new DeliveryMsgTemplateConfig();
+            msgTemplateConfig.setStoreId(user.getStoreId());
+            msgTemplateConfig.setContainsShelf(1);
+            msgTemplateConfig.setUpdateTime(new Date());
+            deliveryMsgTemplateConfigService.updateByStoreIdClientType(msgTemplateConfig);
+        } else {
+            user.setCodeType(0);
+            condition.setEntity(user);
+            userService.updateUser(condition);
+        }
+
+        return buildJson(0, "操作成功");
+    }
+}

+ 520 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppSignOptActionController.java

@@ -0,0 +1,520 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.controller.web.SignOptAction;
+import cn.haliaeetus.controller.web.enums.SMSErrorCodeEnum;
+import cn.haliaeetus.controller.web.enums.StatusCodeEnum;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.entity.dto.DeliveryDto;
+import cn.haliaeetus.entity.dto.QueryPageDto;
+import cn.haliaeetus.entity.esdto.ESDeliveryQueryCondition;
+import cn.haliaeetus.entity.jspo.JDeliveryDto;
+import cn.haliaeetus.entity.jspo.JsonMsg;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.base.log.Logger;
+import cn.haliaeetus.framework.toolkit.CacheTool;
+import cn.haliaeetus.framework.toolkit.PagedList;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.service.*;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static cn.haliaeetus.framework._.isNotEmpty;
+import static cn.haliaeetus.framework._.max;
+
+/**   未签收查询
+ * Created by Administrator on 2019/1/2 0002.
+ */
+@Controller
+public class AppSignOptActionController extends BaseController {
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private NoticeService noticeService;
+
+    @Autowired
+    private DeliveryScanBatchService scanBatchService;
+    @Autowired
+    private StoreShelfService shelfService;
+
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @Autowired
+    private DeliveryStatusService statusService;
+
+    @Autowired
+    private WhiteListService whiteListService;
+
+    private static final Logger LOG = Logger.getInstance(SignOptAction.class);
+
+/*    private static final String fhmUrl = APIConfig.gefhmUrl();
+    private static final String fhmMenuUrl = APIConfig.gefhmMenuUrl();*/
+
+    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    SimpleDateFormat sdf1= new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
+
+    @Autowired
+    private AccessLimitService accessLimitService;
+    @RequestMapping("/app/search/old")
+    @ResponseBody
+    public Object appSearch(HttpServletRequest request,
+                            @RequestParam(defaultValue = "") String currentPage,
+                            @RequestParam(defaultValue = "") String pageSize,
+                            @RequestParam(defaultValue = "0") String signStatus,
+                            @RequestParam(defaultValue = "ALL") String type,
+                            @RequestParam(defaultValue = "1") String queryType,//查询类型默认1面单号
+                            @RequestParam(defaultValue = "3") String smsStatus,  //短信通知状态
+                            @RequestParam(defaultValue = "") String statusType     //状态
+                             ) throws SQLException, ParseException {
+        if(!accessLimitService.tryAcquire()){
+            return buildJson(1, "");
+        }
+        StoreReqLimit storeReqLimit = basicInfoService.getStoreReqLimitByUserId(request.getParameter(COOKIE_USERID)+"search");
+        if (storeReqLimit.getIsLimitFlag()){
+            return buildJson(1, "");
+        }
+//        Map searchMap=new HashMap();
+//        searchMap.put("_haliaeetus_userId_",request.getParameter(COOKIE_USERID));
+//        searchMap.put("_haliaeetus_web_",request.getParameter(COOKIE_KEY));
+//        searchMap.put("currentPage",currentPage);
+//        searchMap.put("pageSize",pageSize);
+//        searchMap.put("signStatus",signStatus);
+//        searchMap.put("type",type);
+//        searchMap.put("queryType",queryType);
+//        searchMap.put("smsStatus",smsStatus);
+//        searchMap.put("statusType",statusType);
+//        searchMap.put("beginTime",request.getParameter("beginTime"));
+//        searchMap.put("endTime",request.getParameter("endTime"));
+//        searchMap.put("exp_code",request.getParameter("exp_code"));
+//        searchMap.put("expId",request.getParameter("expId"));
+//        String searchPhoenixTestIP=basicInfoService.getConfigurationByCode("searchPhoenixTestIP").getOValue1();
+//        String url2 = "http://"+searchPhoenixTestIP+"/app/search";
+//        String res = HttpUtil.post(url2, searchMap);
+//        return res;
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1, "用户未登录");
+        }
+        if("".equals(currentPage)){
+            currentPage = "1";
+        }
+        if("".equals(pageSize)){
+            pageSize = "10";
+        }
+
+        int p = Integer.parseInt(currentPage);
+        int size = Integer.parseInt(pageSize);
+        p = max(1,p );
+        int begin = (p - 1) * size;
+        Date beginTime=null;
+        if(request.getParameter("beginTime")!=null&& StringUtils.isNotBlank(request.getParameter("beginTime"))) {
+            beginTime=df.parse(request.getParameter("beginTime"));
+        }
+        Date endTime=null;
+        if(request.getParameter("endTime")!=null&&StringUtils.isNotBlank(request.getParameter("endTime"))){
+            endTime= df.parse(request.getParameter("endTime"));
+        }
+
+       /* String signStatus= null;
+        if(request.getParameter("signStatus")!=null&& StringUtils.isNotBlank(request.getParameter("signStatus"))){
+            signStatus=request.getParameter("signStatus");
+        }*/
+        String exp_code=null;
+        if(request.getParameter("exp_code")!=null&&StringUtils.isNotBlank(request.getParameter("exp_code"))) {
+            exp_code=request.getParameter("exp_code");
+        }
+
+        String expId=null;
+        if(request.getParameter("expId")!=null&&StringUtils.isNotBlank(request.getParameter("expId"))) {
+            expId=request.getParameter("expId");
+        }
+        if(expId == null ||expId.equals("null")){
+            expId=null;
+        }
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        qc.setP(p);
+        qc.setBegin(begin);
+        qc.setPageSize(size);
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        if("0".equals(signStatus)){//查询未签收
+            qc.setSignStatus(null);
+        }
+
+        qc.setSmsStatus(Integer.parseInt(smsStatus));
+        String subSql = " and (status != 246 and status !=126)";
+        if (null != exp_code && !"".equals(exp_code)) {
+            subSql += getSubSql(exp_code, Integer.valueOf(queryType));
+        }
+        qc.setSubSql(subSql);
+        Date beginTimed = null;
+        Date endTimed = null;
+        String dateStr1 = "";
+        String dateStr2 = "";
+        if(beginTime!=null){
+            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+            dateStr1 = sdf.format(beginTime);
+            beginTimed = Timestamp.valueOf(dateStr1);
+            qc.setBeginTime(beginTimed);
+        }
+        if(endTime!=null){
+            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd 23:59:59");
+            dateStr2 = sdf.format(endTime);
+            endTimed = Timestamp.valueOf(dateStr2);
+            qc.setEndTime(endTimed);
+        }
+        qc.setCreateTime(dateStr1,dateStr2);
+       /* if(exp_code!=null) {
+            qc.setExp_code(exp_code);
+        }*/
+        if(expId!=null) {
+            qc.setExp_Id(expId);
+        }
+        Store store = basicInfoService.getStoreById(user.getStoreId());
+       /* String odeliveryType = "ZI";
+        if (store!=null && store.getIsP2p() == 1) {
+            odeliveryType = "P2P";
+        }
+        qc.setOdeliveryType(odeliveryType);*/
+        List<Integer> statusList = new ArrayList<Integer>();
+        if(!"".equals(statusType)){
+            statusList.add(Integer.parseInt(statusType));
+            qc.setStatusStr(statusList);
+        }
+
+        //根据店铺id查询当前店铺的白名单客户
+        List<WhiteList> list = whiteListService.getByStoreId(user.getStoreId());
+        Map map = new HashMap();
+        for(WhiteList white : list){
+            map.put(white.getUsermobile() , white);
+        }
+
+      /*  Map<Integer, List<ExpressType>> allExpress = basicInfoService.getExpressByStoreId(user.getStoreId());
+        List<StoreShelf> shelfs = shelfService.getByStoreId(user.getStoreId());*/
+        QueryPageDto pageDto = null;
+        if("".equals(smsStatus) || "3".equals(smsStatus)){
+            pageDto = deliveryService.getQueryPageDto(qc);
+        }else {//失败和未签收
+            pageDto = deliveryService.appGetSmsFail4Page(qc);
+        }
+        pageDtos(pageDto);
+        JsonMsg jsonMsg = JsonMsg.getSuccess();
+        jsonMsg.add("list",getJDeliveryDto(pageDto.getPageList(),map));
+        jsonMsg.add("curPage",pageDto.getPageList().getCurPage());
+        jsonMsg.add("totalPages",pageDto.getPageList().getTotalPages());
+        //总条数
+        jsonMsg.add("totalCount",pageDto.getPageList().getTotal());
+        //request.setAttribute("deliveryList", deliveryInfos);
+        // map.put("date",deliveryInfos);
+        return jsonMsg;
+    }
+    private static Map<Integer, StoreShelf> shelfToMap(List<StoreShelf> shelfs) {
+        Map<Integer, StoreShelf> storeShelfMap = new HashMap<>();
+
+        if (shelfs != null) {
+            for (StoreShelf shelf : shelfs) {
+                storeShelfMap.put(shelf.getId(), shelf);
+            }
+        }
+
+        StoreShelf deliveryShelf = new StoreShelf();
+        deliveryShelf.setId(-2);
+        deliveryShelf.setShelfName("派送中");
+        storeShelfMap.put(-2, deliveryShelf);
+        return storeShelfMap;
+    }
+
+    private Map<Integer, List<DeliveryStatus>> statusToMap(int storeId, List<Delivery> deliveries) {
+        Map<Integer, List<DeliveryStatus>> statusMap = new HashMap<>();
+
+        if(deliveries==null || deliveries.isEmpty()) return statusMap;
+
+        StringBuilder ids = new StringBuilder();
+        for (int i = 0, len = deliveries.size(); i < len; i++) {
+            ids.append(deliveries.get(i).getId());
+            if (i < (len - 1)) {
+                ids.append(",");
+            }
+        }
+        List<DeliveryStatus> statusList = statusService.getStatusListByDeliveryIds(storeId, ids.toString());
+        for (DeliveryStatus status : statusList) {
+            ArrayList<DeliveryStatus> array = new ArrayList<>();
+            array.add(status);
+            statusMap.put(status.getDeliveryId(), array);
+        }
+
+        return statusMap;
+    }
+
+    private Map<Integer, ExpressType> expressToMap(List<ExpressType> expressTypes) {
+        Map<Integer, ExpressType> expressTypeMap = new HashMap<>();
+
+        if (expressTypes != null) {
+            for (ExpressType express : expressTypes) {
+                if(express != null){
+                    expressTypeMap.put(express.getExpId(), express);
+                }
+            }
+        }
+        return expressTypeMap;
+    }
+
+    public List<JDeliveryDto> getJDeliveryDto(PagedList<DeliveryDto> d,Map map){
+
+        List<JDeliveryDto> jdos = new ArrayList<JDeliveryDto>();
+        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        List<DeliveryDto> dto1 = d.getItems();
+
+        for (DeliveryDto d1:dto1) {
+            JDeliveryDto jdo = new JDeliveryDto();
+            ExpressType exp =  d1.getExpress();
+            Delivery d2 = d1.getDelivery();
+            if(null != d2.getCreateTime() && !"".equals(d2.getCreateTime())){
+                jdo.setCreateTime(sdf.format(d2.getCreateTime()));
+            }
+            if(null != d2.getStatusTime()){
+                jdo.setStatusTime(sdf.format(d2.getStatusTime()));
+            }
+            /*//判断是否有白名单用户,存在直接跳过不显示
+            if(map.get(d2.getUserPhone()) != null){
+                //白名单用户状态为3,不发送短信
+                jdo.setSmsStatus(3);
+            }else{
+                jdo.setSmsStatus(d1.getSmsStatus());
+            }*/
+            //判断是否有白名单用户,存在直接跳过不显示
+            if(map.get(d2.getUserPhone()) != null){
+                /*//判断是否是未通知接口,不显示白名单用户
+                if(Integer.parseInt(pageType)==-1){
+                    continue;
+                }*/
+                //白名单用户状态为3,不发送短信
+                jdo.setSmsStatus(3);
+                jdo.setIsSendSMS(1);
+            }else{
+                jdo.setSmsStatus(d1.getSmsStatus());
+                if(d2.getStatus() ==122 || d2.getStatus() == 225){
+                    jdo.setIsSendSMS(0);
+                }else{
+                    jdo.setIsSendSMS(1);
+                }
+            }
+            jdo.setId(d2.getId());
+            jdo.setExpcode(d2.getExpcode());
+            jdo.setExpId(exp.getExpId());
+            jdo.setShelfCode(d2.getShelfCode());
+            if(null != d2.getSignDtm() && !"".equals(d2.getSignDtm())){
+                jdo.setSignDtm(sdf.format(d2.getSignDtm()));
+            }
+            jdo.setExpName(exp.getExpName());
+            jdo.setStatus(d2.getStatus());
+            jdo.setUserPhone(d2.getUserPhone());
+            jdo.setShelfId(d2.getShelfId());
+            jdo.setDeliveryUid(d2.getDeliveryUid());
+            jdo.setDeliveryUname(d2.getDeliveryUname());
+            jdo.setShelfName(d1.getShelf().getShelfName());
+            if(null != d2.getUploadDtm() && !"".equals(d2.getUploadDtm())){
+                jdo.setUploadDtm(sdf.format(d2.getUploadDtm()));
+            }
+
+            if(null!=d1.getResultInfo()&&!"".equals(d1.getResultInfo())) {
+                switch (d1.getSmsStatus()) {
+                    case 1:
+                        jdo.setResultInfo("");
+                        break;
+                    case 2:
+                        jdo.setResultInfo(SMSErrorCodeEnum.of(d1.getResultInfo()));
+                        break;
+                    default:jdo.setResultInfo("");
+                }
+            }else{
+                jdo.setResultInfo("");
+            }
+            jdo.setReturnSignStatus(StatusCodeEnum.of(d1.getDelivery().getReturnSignStatus()));
+
+            if(null==d1.getSendSuccessType()){
+                jdo.setSendSuccessType(0);
+            }else {
+                jdo.setSendSuccessType(d1.getSendSuccessType());
+            }
+
+            jdos.add(jdo);
+
+            }
+        return jdos;
+    }
+    public void pageDtos(QueryPageDto pageDto){
+        for(DeliveryDto d:pageDto.getPageList().getItems()){
+            List<DeliveryScanBatch> deliveryScanBatches =scanBatchService.getByCondition(d.getDelivery().getStoreId(),d.getDelivery().getExpcode(),d.getDelivery().getExpId(),null,null,null);
+            if(d.getDelivery().getUserPhone()!=null) {
+                if (deliveryScanBatches.size() > 0 && "2".equals(deliveryScanBatches.get(0).getOcrStatus())) {
+                    StringBuilder number = new StringBuilder(d.getDelivery().getUserPhone());
+                    if (org.apache.commons.lang.StringUtils.isEmpty(d.getDelivery().getUserPhone())|| org.apache.commons.lang.StringUtils.isBlank(d.getDelivery().getUserPhone()))
+                    {
+                        number.append("");
+                    }else {
+                        number.replace(3, 10, "*******");
+                    }
+                    //number.replace(3, 10, "*******");
+                    d.getDelivery().setUserPhone(number.toString());
+                }
+            }
+        }
+    }
+    private String getSubSql(String expcode, int queryType) {
+        String subSql = "";
+        String strRev =cn.haliaeetus.framework.util.StringUtil.stringReverse(expcode);
+        if (isNotEmpty(expcode)) {
+            if(queryType == 1){
+                subSql += " and revexpCode like '" + strRev + "%'";
+            }else if(queryType == 2){
+                subSql += " and revuserPhone like '" + strRev + "%'";
+            }else if(queryType == 3){
+                subSql += " and shelfCode = '" + expcode + "'";
+            }else if(queryType == 4){
+                subSql += " and userName = '" + expcode + "'";
+            }
+
+        }
+        return subSql;
+    }
+
+
+    @RequestMapping("/app/search")
+    @ResponseBody
+    public Object newAppSearch(HttpServletRequest request, HttpServletResponse response,
+                            @RequestParam(defaultValue = "1") String currentPage,
+                            @RequestParam(defaultValue = "20") String pageSize,
+                            @RequestParam(defaultValue = "0") String signStatus,
+                            @RequestParam(defaultValue = "ALL") String type,
+                            @RequestParam(defaultValue = "1") String queryType, // 查询类型默认1面单号
+                            @RequestParam(defaultValue = "3") String smsStatus, // 短信通知状态
+                            @RequestParam(defaultValue = "") String statusType  // 状态
+    ) throws ParseException {
+        if(!accessLimitService.tryAcquire()){
+            return buildJson(1, "");
+        }
+        StoreReqLimit storeReqLimit = basicInfoService.getStoreReqLimitByUserId(request.getParameter(COOKIE_USERID)+"search");
+        if (storeReqLimit.getIsLimitFlag()){
+            return buildJson(1, "");
+        }
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1, "用户未登录");
+        }
+        Integer storeId = user.getStoreId();
+        // 封装查询条件
+        ESDeliveryQueryCondition condition = new ESDeliveryQueryCondition();
+        condition.setStoreId(storeId);
+        condition.setNotStatus(new int[]{246, 126});
+
+        int p = Integer.parseInt(currentPage);
+        int size = Integer.parseInt(pageSize);
+        p = max(1,p );
+        int begin = (p - 1) * size;
+
+        condition.setP(p);
+        condition.setPageSize(size);
+        condition.setBegin(begin);
+        condition.setOrderField("createTime");
+        condition.setOrder("desc");
+
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        String beginTime;
+        if(null != (beginTime = request.getParameter("beginTime")) && StringUtils.isNotBlank(beginTime)){
+            condition.setBeginTime(format.parse(beginTime));
+        }
+
+        String endTime;
+        if(null != (endTime = request.getParameter("endTime")) && StringUtils.isNotBlank(endTime)){
+            condition.setEndTime(format.parse(DateUtil.addDay(endTime, "yyyy-MM-dd", 1)));
+        }
+
+        String expCode;
+        if(null != (expCode = request.getParameter("exp_code")) && StringUtils.isNotBlank(expCode)){
+            switch (queryType){
+                case "1":
+                    condition.setExpcode(expCode);
+                    break;
+                case "2":
+                    condition.setUserPhone(expCode);
+                    break;
+                case "3":
+                    condition.setShelfCode(expCode);
+                    break;
+                default:
+            }
+        }
+
+        String expId;
+        if(null != (expId = request.getParameter("expId")) && StringUtils.isNotBlank(expId) && !"null".equals(expId)) {
+            condition.setExpId(Integer.valueOf(expId));
+        }
+
+        if(!"".equals(smsStatus) && !"3".equals(smsStatus)){
+            if("0".equals(smsStatus)){
+                condition.setSmsStatus(new int[]{1, 2});
+            } else {
+                condition.setSmsStatus(new int[]{Integer.parseInt(smsStatus)});
+            }
+        }
+        CacheTool cacheTool = CacheTool.initDeliveryStatusTool();
+        Set<byte[]> keys = cacheTool.getKeys();
+        List<Integer> ids = new ArrayList<>();
+        if(null != keys && keys.size()>0){
+            for(byte[] b : keys){
+                String key = new String(b);
+                String status = cacheTool.getStringByFullKey(key);
+                if("246".equals(status) || "126".equals(status)){
+                    try{
+                        Integer id = Integer.valueOf(key.split(":")[2]);
+                        ids.add(id);
+                    }catch (NumberFormatException e){
+                    }
+                }
+            }
+        }
+
+        if(null != ids && ids.size() > 0){
+            int[] notIds = new int[ids.size()];
+            for(int i =0; i < ids.size(); i++){
+                notIds[i] = ids.get(0);
+            }
+            condition.setNotIds(notIds);
+        }
+
+        if(!"".equals(statusType)){
+            condition.setStatus(new int[]{Integer.parseInt(statusType)});
+        }
+
+        JsonMsg jsonMsg = deliveryService.queryDeliveries(condition);
+        if(null == jsonMsg){
+            try {
+                return appSearch(request, currentPage, pageSize, signStatus, type, queryType, smsStatus, statusType);
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+        return jsonMsg;
+    }
+
+}

+ 49 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppStaffController.java

@@ -0,0 +1,49 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.entity.StoreStaff;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.StoreStaffService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
+/**  快递员管理
+ * Created by Administrator on 2018/12/21 0021.
+ */
+@Controller
+public class AppStaffController extends BaseController{
+    @Autowired
+    private StoreStaffService staffService;
+    @RequestMapping("/app/store/saveStaffs")
+    @ResponseBody
+    public Object saveStaffs(HttpServletRequest request) throws IOException, SQLException {
+        User user = getUserFromParam(request);
+        if (user == null) return buildJson(1, "用户未登录");
+        String userName = request.getParameter("username");
+        String userMobile = request.getParameter("usermobile");
+        if(null == userName || "".equals(userName) || null == userMobile || "".equals(userMobile)){
+            return buildJson(-1, "未输入业务员名字或电话号码~");
+        }
+        List<StoreStaff> storeStaffs = staffService.getByStoreId(user.getStoreId());
+        for (StoreStaff storeStaff:storeStaffs) {
+            if(userMobile.equals(storeStaff.getMobile())){
+                return buildJson(-1, "电话号码重复~");
+            }
+        }
+        StoreStaff staff = new StoreStaff();
+        staff.setMobile(userMobile);
+        staff.setName(userName);
+        staff.setCreateTime(new Date());
+        staff.setStoreId(user.getStoreId());
+        long staffid = staffService.insert(staff);
+        return buildSingleEleJson(0, "新增成功", staffid).toString();
+    }
+}

+ 164 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppStatiscsAction.java

@@ -0,0 +1,164 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.dao.ReceivedDao;
+import cn.haliaeetus.entity.BaseStat;
+import cn.haliaeetus.entity.ExpressType;
+import cn.haliaeetus.entity.Stat;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.entity.jspo.JCountDto;
+import cn.haliaeetus.entity.jspo.JsonMsg;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.service.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static cn.haliaeetus.framework._.isEmpty;
+
+/**  入库统计信息查询
+ * Created by Administrator on 2018/12/21 0021.
+ */
+@Controller
+public class AppStatiscsAction extends BaseController {
+    @Autowired
+    private StatService statService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+
+    @Autowired
+    private StoreShelfService shelfService;
+    @Autowired
+    private TypeLibraryService typeLibraryService;
+
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @Autowired
+    private ReceivedDao receiveDao;
+
+    private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+    private  SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM");
+
+    @RequestMapping(value = "/app/v1/day_statistics")
+    @ResponseBody
+    public Object todayStatistics(HttpServletRequest request,
+                                  @RequestParam(defaultValue = "1") String currentPage,//默认查全部快递
+                                  @RequestParam(defaultValue = "10") String pageSize,
+                                  @RequestParam(defaultValue = "") String expId,//默认查全部快递
+                                  @RequestParam(defaultValue = "") String beginTime,
+                                  @RequestParam(defaultValue = "") String endTime,
+                                  @RequestParam(defaultValue = "") String mouth,
+                                  @RequestParam(defaultValue = "0") int type//0按日期查,1按快递公司统计,2按月查
+                                  ) throws Exception {
+        long now = System.currentTimeMillis();
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        if (!"".equals(expId)) {
+            qc.setExp_Id(expId);
+        }
+        JsonMsg result = JsonMsg.getSuccess();
+        Date date = new Date();
+        if(type == 0 || type == 1) {
+            //根据开始时间和结束时间得到一个时间字符串数组
+            List<String> dataStr = new ArrayList<String>();
+            if ("".equals(beginTime)) {//开始是今天,结束是明天
+                beginTime = formatter.format(date);
+            } else {
+                Date beginTime1 = formatter.parse(beginTime);
+                beginTime = formatter.format(beginTime1);
+                if ("".equals(endTime)) {
+                    endTime = getSpecifiedDayAfter(formatter.format(date));
+                }else{
+                    Date endTime1 = formatter.parse(endTime);
+                    endTime = getSpecifiedDayAfter(formatter.format(endTime1));
+                }
+            }
+            if ("".equals(endTime)) {
+                endTime = getSpecifiedDayAfter(formatter.format(date));
+            }
+            dataStr = getTime(beginTime, endTime, dataStr);
+            //开始时间和结束时间不为null
+            qc.setCreateTime(beginTime, endTime);
+             result =  statService.getByCountList(qc,dataStr,currentPage,pageSize);
+        }else if(type == 2){//按月统计
+            if("".equals(mouth)){//本月
+                beginTime = dft.format(date);
+            }else{
+                Date mouthDate = dft.parse(mouth.toString());
+                beginTime = dft.format(mouthDate);
+            }
+            endTime = getPreMonth(beginTime);
+            String beginTime1 = beginTime + "-01";
+            endTime = endTime + "-01";
+            qc.setCreateTime(beginTime1,endTime);
+            result =  statService.getByCountMouthList(qc,beginTime);
+        }
+
+       // getStat(request, expId, beginTime, endTime, offset, true);
+
+        return result;
+
+    }
+
+    private List<String> getTime(String beginTime,String endTime,List<String> list) throws Exception {
+        Boolean flag = true;
+        while (flag){
+            list.add(beginTime);
+            Date beginTime1 = formatter.parse(beginTime);
+            Date endTime1 = formatter.parse(endTime);
+            beginTime = getSpecifiedDayAfter(formatter.format((beginTime1)));
+            if(beginTime.equals(endTime) || beginTime1.after(endTime1)){
+                flag = false;
+            }
+        }
+        return list;
+    }
+
+    private String getPreMonth(String mouth) {
+        Calendar cal = Calendar.getInstance();
+        Date date = null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM").parse(mouth);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        cal.setTime(date);
+        cal.add(cal.MONTH, 1);
+        String preMonth = dft.format(cal.getTime());
+        return preMonth;
+    }
+
+    private String getSpecifiedDayAfter(String specifiedDay){
+        Calendar c = Calendar.getInstance();
+        Date date=null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        c.setTime(date);
+        int day=c.get(Calendar.DATE);
+        c.set(Calendar.DATE,day+1);
+
+        String dayAfter=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+
+    }

+ 549 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppStoreInController.java

@@ -0,0 +1,549 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.store.helper.DeliveryInfo;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.controller.web.querycondition.UserQueryCondition;
+import cn.haliaeetus.dao.UserDao;
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.entity.dto.PhoneLibDto;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.toolkit.CacheTool;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.framework.util.HttpUtil;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.framework.util.StringUtil;
+import cn.haliaeetus.service.*;
+import cn.haliaeetus.service.impl.PhoneLibPushServiceImpl;
+import com.alibaba.fastjson.JSON;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.base.Strings;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**  入库扫描
+ * Created by Administrator on 2018/12/21 0021.
+ */
+@Controller
+public class AppStoreInController extends BaseController{
+    @Autowired
+    private DeliveryService deliveryService;
+    @Autowired
+    private StoreShelfService shelfService;
+    @Autowired
+    private StoreStaffService staffService;
+    @Autowired
+    private PhoneLibPushServiceImpl phoneLibPushService;
+    @Autowired
+    private DeliveryScanBatchService scanBatchService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private WhiteListService whiteListService;
+    @Autowired
+    private ExpsSignBackService expsSignBackService;
+    @Autowired
+    private UserDao userDao;
+
+
+    //入库
+    @RequestMapping("/app/device/onShelfScan")
+    @ResponseBody
+    public Object AppOnShelfScan(HttpServletRequest request, HttpServletResponse response) throws SQLException,
+            IOException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        //查看门店的所以白名单用户
+        List<WhiteList> list = whiteListService.getByStoreId(user.getStoreId());
+        Map map = new HashMap();
+        for(WhiteList white : list){
+            map.put(white.getUsermobile() , white);
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(request.getParameter("data"));
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        List<DeliveryInfo> deliveryInfoList = new ArrayList<DeliveryInfo>();
+        while (it.hasNext()) {
+            JsonNode expInfo = it.next();
+
+            int expId = expInfo.findValue("expId").asInt();
+            String expCode = expInfo.findValue("expCode").asText();
+            int shelfId = expInfo.findValue("shelfId").asInt();
+            String telPhone = "";
+            telPhone = expInfo.findValue("telPhone").asText();
+            String shelfCode = null;
+            JsonNode codeNode = expInfo.findValue("shelfCode");
+            if (codeNode != null) shelfCode = codeNode.asText();
+
+//            String whiteIsDel=request.getParameter("whiteIsInbound");
+            String whiteIsDel="";
+            if (expInfo.findValue("whiteIsInbound") != null){
+                whiteIsDel=expInfo.findValue("whiteIsInbound").asText();
+            }
+            /*if("no".equals(whiteIsDel)){
+                return buildJson(3, "白名单用户不入库清空信息");
+            }*/
+
+            Boolean whiteUser = false;
+            if(map.get(telPhone)!=null && !"yes".equals(whiteIsDel)){
+                return buildJson(2, "白名单用户是否入库");
+            }else if(map.get(telPhone)!=null && "yes".equals(whiteIsDel)){
+                whiteUser = true;
+            }
+
+            if(expId < 0){
+                return buildJson(-1, "未选择快递公司");
+            }
+            if(shelfId == 0){
+                return buildJson(-1, "未选择货架");
+            }
+            if(_.isEmpty(expCode)){
+                return buildJson(-1, "取货码未输入");
+            }
+            if(_.isEmpty(shelfCode)){
+                return buildJson(-1, "面单号未输入");
+            }
+            expCode = expCode.trim();
+
+            //根据面单号或者取货码
+            DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+            //查7天以内
+            String endTime = DateUtil.today().toString("yyyy-MM-dd");
+            String endTime1 = endTime.trim()+" 23:59:59";
+            //String beginTime = getSpecifiedDaybefore(endTime);
+            //update 2019/03/22 查询一个月内的数据
+            String beginTime = getBeginDate();
+            String beginTime1 = beginTime.trim() + " 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(beginTime1));
+            qc.setEndTime(Timestamp.valueOf(endTime1));
+            qc.setCreateTime(beginTime1,endTime1);
+
+            String subSql =  "and (expcode = '" + expCode + "'" + "or shelfCode = '" + shelfCode + "')";
+            qc.setSubSql(subSql);
+
+            List<Delivery> deliverys =  deliveryService.getDelivery(qc);
+            Delivery delivery = null;
+            if(deliverys.size() > 0){
+                for (int i = 0 ;i< deliverys.size();i++){
+                    delivery = deliverys.get(i);
+                    if(delivery.getExpcode().equals(expCode)){
+                        return buildJson(-1,"面单号重复");
+                    }
+                    if(user.getCodeType().intValue()==0){
+                        if(delivery.getExpId().intValue() == expId){
+                            return buildJson(-1,"取货码重复");
+                        }
+                    }
+                }
+            }
+
+            JsonObject obj = inStore(user, expId, expCode, shelfId, shelfCode, deliveryInfoList,telPhone, whiteUser);
+            expsSignBackService.signBack(expId, expCode, telPhone, user.getStoreId(),"in",shelfId+"", shelfCode);
+            if (obj != null) array.add(obj);
+            //add 2019/02/25
+            PhoneLibDto phoneLibDto=new PhoneLibDto();
+            phoneLibDto.setCreateTime(new Date());
+            phoneLibDto.setStoreId(user.getStoreId());
+            phoneLibDto.setPhones(telPhone);
+            String wxMessage= JSON.toJSONString(phoneLibDto);
+      /*iTemplateMessageApi.sendTemplateMessage(wxMessage);*/
+
+            phoneLibPushService.push(wxMessage);
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.add("expInfo", array);
+
+        return object.toString();
+    }
+
+    //入库取货码可以重复
+    @RequestMapping("/app/device/onShelfScanf")
+    @ResponseBody
+    public Object AppOnShelfScanCopy(HttpServletRequest request, HttpServletResponse response) throws SQLException,
+            IOException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        //查看门店的所以白名单用户
+        List<WhiteList> list = whiteListService.getByStoreId(user.getStoreId());
+        Map map = new HashMap();
+        for(WhiteList white : list){
+            map.put(white.getUsermobile() , white);
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(request.getParameter("data"));
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        List<DeliveryInfo> deliveryInfoList = new ArrayList<DeliveryInfo>();
+        while (it.hasNext()) {
+            log.info("ssssssssssssssssssssssssssssss:::::::::::::::::::::::::");
+            JsonNode expInfo = it.next();
+            int expId = expInfo.findValue("expId").asInt();
+            String expCode = expInfo.findValue("expCode").asText();
+            int shelfId = expInfo.findValue("shelfId").asInt();
+            String telPhone = "";
+            telPhone = expInfo.findValue("telPhone").asText();
+            String shelfCode = null;
+            JsonNode codeNode = expInfo.findValue("shelfCode");
+
+            String whiteIsDel="";
+            if (expInfo.findValue("whiteIsInbound") != null){
+                whiteIsDel=expInfo.findValue("whiteIsInbound").asText();
+            }
+            log.info("whiteIsDel:::::::::::::::::::::::::"+whiteIsDel);
+            /*if("no".equals(whiteIsDel)){
+                return buildJson(3, "白名单用户不入库清空信息");
+            }*/
+
+            Boolean whiteUser = false;
+            if(map.get(telPhone)!=null && !"yes".equals(whiteIsDel)){
+                log.info(":::::::::::::::::::::::::::dddddddddddddddddddddd");
+                return buildJson(2, "白名单用户是否入库");
+            } else if(map.get(telPhone)!=null && "yes".equals(whiteIsDel)){
+                whiteUser = true;
+            }
+
+            if (codeNode != null) shelfCode = codeNode.asText();
+            if(expId < 0){
+                return buildJson(-1, "未选择快递公司");
+            }
+            if(shelfId == 0){
+                return buildJson(-1, "未选择货架");
+            }
+            if(_.isEmpty(shelfCode)){
+                return buildJson(-1, "取货码未输入");
+            }
+            if(_.isEmpty(expCode)){
+                return buildJson(-1, "面单号未输入");
+            }
+            expCode = expCode.trim();
+            CacheTool cacheTool = new CacheTool("inDelivery:count");
+            String stringKey = cacheTool.getStringKey(expId+"_"+expCode+"_"+shelfId+"_"+shelfCode);
+            if(!Strings.isNullOrEmpty(stringKey)){
+                return buildJson(-1,"面单号重复");
+            }
+            cacheTool.setStringandDatakey(expId+"_"+expCode+"_"+shelfId+"_"+shelfCode,"0",3600);
+            // 去掉查重操作,update于20190729修改人kael
+//            //根据面单号或者取货码
+//            DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+//            //查7天以内
+//            String endTime = DateUtil.today().toString("yyyy-MM-dd");
+//            String endTime1 = endTime.trim()+" 23:59:59";
+//            //String beginTime = getSpecifiedDaybefore(endTime);
+//            //update 2019/03/22 查询一个月内的数据
+//            String beginTime = getSpecifiedDaybefore(endTime);//修改为一周内的数据(蜂站)
+//            String beginTime1 = beginTime.trim() + " 00:00:00";
+//            qc.setBeginTime(Timestamp.valueOf(beginTime1));
+//            qc.setEndTime(Timestamp.valueOf(endTime1));
+//            qc.setCreateTime(beginTime1,endTime1);
+//            String subSql =  "and (expcode = '" + expCode + "'" + "or shelfCode = '" + shelfCode + "')";
+//            qc.setSubSql(subSql);
+//            List<Delivery> deliverys =  deliveryService.getDelivery(qc);
+//            if(deliverys.size() > 0){
+//                for (int i = 0 ;i< deliverys.size();i++){
+//                    Delivery delivery = deliverys.get(i);
+//                    if(delivery.getExpcode().equals(expCode)){
+//                        return buildJson(-1,"面单号重复");
+//                    }
+//                    /*if(user.getCodeType().intValue()==0){
+//                        if(delivery.getExpId().intValue() == expId){
+//                            return buildJson(-1,"取货码重复");
+//                        }
+//                    }*/
+//                }
+//            }
+            //add 2019/03/19
+            String platform = "";
+            if(expInfo.findValue("platform") != null){
+                platform = expInfo.findValue("platform").asText();
+            }
+            JsonObject obj = inStore(user, expId, expCode, shelfId, shelfCode, deliveryInfoList,telPhone, whiteUser,platform);
+            expsSignBackService.signBack(expId, expCode, telPhone, user.getStoreId(),"in",shelfId+"", shelfCode,platform);
+            if (obj != null) array.add(obj);
+            //add 2019/02/25
+            PhoneLibDto phoneLibDto=new PhoneLibDto();
+            phoneLibDto.setCreateTime(new Date());
+            phoneLibDto.setStoreId(user.getStoreId());
+            phoneLibDto.setPhones(telPhone.trim());
+            String wxMessage= JSON.toJSONString(phoneLibDto);
+      /*iTemplateMessageApi.sendTemplateMessage(wxMessage);*/
+
+            phoneLibPushService.push(wxMessage);
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.add("expInfo", array);
+
+        //短信自动发送开关
+        if(user.getSmsSendType() != null && user.getSmsSendType() != Constants.SMS_SEND_TYPE_HAND){
+            String res = "";
+            try{
+                Map<String, String> headers = new HashMap<String, String>();
+                headers.put("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
+                headers.put("imei", "sendSmsChannel");
+                headers.put("appVersion", "1.3.02");
+                Map reqMap = new HashMap();
+                reqMap.put("_haliaeetus_userId_",user.getUserId());
+                reqMap.put("_haliaeetus_web_",user.getPassword());
+                reqMap.put("deliveryIds",deliveryInfoList.get(0).getDelivery().getId()+"");
+                String url = basicInfoService.getConfigurationByCode("sendSmsUrl").getOValue1();
+                res = HttpUtil.postMap(url,headers,reqMap);
+            }catch (Exception e){
+                log.info("自动发送短信失败!--"+res);
+            }
+        }
+//        // 短信发送方式为自动发送并且为付费模式
+//        if (user.getSmsSendType() == null || user.getSmsSendType() == Constants.SMS_SEND_TYPE_AUTO) {
+//            if ((user.getIsSmsFree() == null || user.getIsSmsFree() != Constants.YES) && _.isNotEmpty(deliveryInfoList)) {
+//                messageSendHelper.asyncSendMsgAndDeduct(deliveryInfoList, user, Constants.SMS_CONSUME_BUSINESS_INSTORE);
+//            }
+//        }
+        return object.toString();
+    }
+
+    //入库取货码可以重复
+    @RequestMapping("/app/device/onShelfScanByHaiKang")
+    @ResponseBody
+    public Object HaiKangOnShelfScanCopy(HttpServletRequest request, HttpServletResponse response, @RequestBody HaiKangStorageBean haiKangStorageBean) throws SQLException,
+            IOException {
+       log.info("获取的对象信息:"+haiKangStorageBean);
+        int expId =Integer.parseInt(haiKangStorageBean.getExpId());
+        int storeId = Integer.parseInt(haiKangStorageBean.getStoreId());
+        String expCode = haiKangStorageBean.getExpCode();
+        int shelfId =  Integer.parseInt(haiKangStorageBean.getShelfId());
+        String shelfCode = haiKangStorageBean.getShelfCode();
+        String telPhone = haiKangStorageBean.getTelPhone();
+        String whiteIsInbound = haiKangStorageBean.getWhiteIsInbound();
+        //获取用户信息
+        UserQueryCondition userQueryCondition=new UserQueryCondition();
+        userQueryCondition.setStoreId(storeId);
+        User user = userDao.getUsers(userQueryCondition).get(0);
+
+        ResultInfoBean resultInfoBean = new ResultInfoBean();
+        List<DeliveryInfo> deliveryInfoList = new ArrayList<DeliveryInfo>();
+
+        try {
+            if (expId < 0) {
+                resultInfoBean.setResultCode("01");
+                resultInfoBean.setResultMessage("未选择快递公司");
+                return JSON.toJSONString(resultInfoBean);
+            }
+            if (shelfId == 0) {
+                resultInfoBean.setResultCode("01");
+                resultInfoBean.setResultMessage("未选择货架");
+                return JSON.toJSONString(resultInfoBean);
+            }
+            if (_.isEmpty(shelfCode)) {
+                resultInfoBean.setResultCode("01");
+                resultInfoBean.setResultMessage("取货码未输入");
+                return JSON.toJSONString(resultInfoBean);
+            }
+            if (_.isEmpty(expCode)) {
+                resultInfoBean.setResultCode("01");
+                resultInfoBean.setResultMessage("面单号未输入");
+                return JSON.toJSONString(resultInfoBean);
+            }
+            int iswhite = 0;
+            if (whiteIsInbound.equals("yes")) {
+                iswhite = 1;
+            }
+            expCode = expCode.trim();
+
+            //根据面单号或者取货码
+            DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+            //查7天以内
+            String endTime = DateUtil.today().toString("yyyy-MM-dd");
+            String endTime1 = endTime.trim() + " 23:59:59";
+            // 修改为一周内的数据(蜂站)
+            String beginTime = getSpecifiedDaybefore(endTime);
+            String beginTime1 = beginTime.trim() + " 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(beginTime1));
+            qc.setEndTime(Timestamp.valueOf(endTime1));
+            qc.setCreateTime(beginTime1, endTime1);
+            String subSql = "and (expcode = '" + expCode + "'" + "or shelfCode = '" + shelfCode + "')";
+            qc.setSubSql(subSql);
+            List<Delivery> deliverys = deliveryService.getDelivery(qc);
+            if (deliverys.size() > 0) {
+                for (int i = 0; i < deliverys.size(); i++) {
+                    Delivery delivery = deliverys.get(i);
+                    if (delivery.getExpcode().equals(expCode)) {
+                        resultInfoBean.setResultCode("01");
+                        resultInfoBean.setResultMessage("面单号重复");
+                        return JSON.toJSONString(resultInfoBean);
+                    }
+                }
+            }
+            JsonObject obj = inStore(user, expId, expCode, shelfId, shelfCode, deliveryInfoList, telPhone, false);
+            //add 2019/03/19
+            expsSignBackService.signBack(expId, expCode, telPhone, user.getStoreId(), "in",shelfId+"", shelfCode);
+//            if (obj != null) array.add(obj);
+            //add 2019/02/25
+            PhoneLibDto phoneLibDto = new PhoneLibDto();
+            phoneLibDto.setCreateTime(new Date());
+            phoneLibDto.setStoreId(user.getStoreId());
+            phoneLibDto.setPhones(telPhone.trim());
+            String wxMessage = JSON.toJSONString(phoneLibDto);
+            /*iTemplateMessageApi.sendTemplateMessage(wxMessage);*/
+
+            phoneLibPushService.push(wxMessage);
+
+        }catch (Exception e){
+            resultInfoBean.setResultCode("99");
+            resultInfoBean.setResultMessage("系统错误");
+            return JSON.toJSONString(resultInfoBean);
+        }
+
+        resultInfoBean.setResultCode("00");
+        resultInfoBean.setResultMessage("处理成功");
+        return JSON.toJSONString(resultInfoBean);
+    }
+
+    private JsonObject inStore(User user, int expId, String expCode, int shelfId, String shelfCode, List<DeliveryInfo> deliveryInfoList,String telPhone, Boolean whiteUser){
+        return this.inStore(user,expId,expCode,shelfId,shelfCode,deliveryInfoList,telPhone,whiteUser,"");
+    }
+
+    private JsonObject inStore(User user, int expId, String expCode, int shelfId, String shelfCode, List<DeliveryInfo> deliveryInfoList,String telPhone, Boolean whiteUser,String platform){
+        JsonObject dataObj = new JsonObject();
+        Integer storeId = user.getStoreId();
+        StoreShelf storeShelf = shelfService.getById(shelfId);
+        if (storeShelf == null) {
+
+            dataObj.addProperty("expCode", expCode);
+            dataObj.addProperty("reason", "货架不存在");
+            return dataObj;
+        }
+
+    /*    String userPhone = "";
+        // 分拣中心快递类型
+        //2018-03-15所有都会去查询电话号码
+//        if (expId == Integer.MAX_VALUE) {
+//            JsonObject dataObj = new JsonObject();
+        dataObj.addProperty("expCode", expCode);
+
+        List<FjDelivery> fjDeliveryList = fjDeliveryService.getByExpCode(storeId, expCode);
+//            if (fjDeliveryList == null || fjDeliveryList.isEmpty()) {
+//                dataObj.addProperty("reason", "没有分拣");
+//                return dataObj;
+//            }
+        if (null==fjDeliveryList||fjDeliveryList.isEmpty()) {
+            if (fjDeliveryList.size() > 1) {
+                dataObj.addProperty("reason", "分拣单号重复");
+                return dataObj;
+            }
+            userPhone ="";
+        }else {
+            userPhone = fjDeliveryList.get(0).getTelphone();
+        }
+        if (expId == Integer.MAX_VALUE){
+            expId = fjDeliveryList.get(0).getExpId();
+        }
+//        }*/
+
+        DeliveryInfo deliveryInfo = null;
+        try {
+            deliveryInfo = deliveryService.instoreDelivery(user, expCode, expId, shelfCode, shelfId, "", telPhone,
+                    Constants.CLIENT_TYPE_STORE_LITE_2, whiteUser,platform);
+            deliveryInfoList.add(deliveryInfo);
+            Delivery d = deliveryInfo.getDelivery();
+            dataObj.addProperty("id", d.getId());
+            dataObj.addProperty("userPhone", d!=null?d.getUserPhone():"");
+
+            List<DeliveryScanBatch> scanBatches=scanBatchService.getByCondition(storeId, expCode, null, null,null,null);
+            if(scanBatches!=null&&scanBatches.size()>0){
+                //更新下车表里的快递公司、取货码、货架号
+                DeliveryScanBatch deliveryScanBatch = scanBatches.get(0);
+                DeliveryScanBatch dsb = new DeliveryScanBatch();
+                dsb.setStoreId(deliveryScanBatch.getStoreId());
+                dsb.setExpCode(deliveryScanBatch.getExpCode());
+//                deliveryScanBatch.setExpId(Integer.getInteger(expressId));
+                try{
+                    dsb.setExpId(new Integer(expId));}
+                catch (Exception e){
+
+                }
+                scanBatchService.updateByStoreAndExpCode(dsb);
+            }else{
+                DeliveryScanBatch scanBatch=new DeliveryScanBatch();
+                scanBatch.setExpCode(expCode);
+                scanBatch.setRevexpCode(StringUtil.stringReverse(expCode));
+                scanBatch.setExpId(expId);
+                scanBatch.setBatchNumber(0);
+                scanBatch.setStoreId(user.getStoreId());
+                scanBatch.setOperatorId(1);
+                scanBatch.setCreateTime(new Date());
+                scanBatch.setUserName("");
+                scanBatch.setUserPhone(telPhone);
+                scanBatch.setRevuserPhone(StringUtil.stringReverse(telPhone));
+                scanBatch.setChargeMoney(null);
+                scanBatch.setOcrStatus("0");
+                scanBatch.setOcrAmount("0");
+                scanBatch.setShelfCode("");
+                scanBatchService.insert(scanBatch);
+            }
+
+        } catch (Exception e) {
+//            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expCode);
+            dataObj.addProperty("reason", e.getMessage());
+            return dataObj;
+        }
+
+        return dataObj;
+    }
+    private String getSpecifiedDaybefore(String specifiedDay){
+        Calendar c = Calendar.getInstance();
+        Date date=null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        c.setTime(date);
+        int day=c.get(Calendar.DATE);
+        c.set(Calendar.DATE,day-6);
+
+        String dayAfter=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+
+
+    private static String getBeginDate(){
+        Calendar c = Calendar.getInstance();
+        c.add(Calendar.MONTH,-1);
+
+        String dayAfter=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+}

+ 74 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppUploadController.java

@@ -0,0 +1,74 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.entity.jspo.JsonMsg;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.util.FastDFS.FastDFSClient;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**  文件上传
+ * Created by Administrator on 2019/1/9 0009.
+ */
+@Controller
+public class AppUploadController  extends BaseController{
+
+    @RequestMapping(value = "/app/imgUpload")
+    @ResponseBody
+    public synchronized Object imgUpload(@RequestParam MultipartFile file ,HttpServletRequest request) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1,"用户未登录");
+        }
+        if(!file.isEmpty()) {
+           /* String message = System.currentTimeMillis() + file.getOriginalFilename();//现在的文件名是时间戳加原文件名,出现图片相同时,读取不出来的bug
+            String realPath = request.getSession().getServletContext().getRealPath("/upload/");//将文件保存在当前工程下的一个upload文件*/
+
+            //上传到文件服务器
+            FastDFSClient fastDFSClient = new FastDFSClient();
+            String FDSfilePath = fastDFSClient.uploadFile(file.getBytes(),"png");
+            JsonMsg result =JsonMsg.getSuccess();
+            if(FDSfilePath != null && !"".equals(FDSfilePath)){
+                return result.add("imgpath", Constants.FASTDFS_CLIENT_SERVER + FDSfilePath);
+            }
+        }
+        return buildJson(-1,"上传失败");
+    }
+
+    @RequestMapping(value = "/app/imgDown")
+    public synchronized void imgDown(@RequestParam String  imgPath,HttpServletRequest request,HttpServletResponse response) throws IOException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            log.info("登陆超时~");
+        }
+        response.setContentType("img/png");
+        response.setCharacterEncoding("utf-8");
+        //WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
+        //ServletContext servletContext =    webApplicationContext.getServletContext();
+        //String path =  servletContext.getRealPath("Wopop_files/1.png");
+        //文件服务器
+        FastDFSClient fastDFSClient = new FastDFSClient();
+
+		/*byte[] imgbytes = fastDFSClient.download_bytes("group1/M00/00/02/wKgBolpn7XCAK55oAAAXoA9fMac209.png");*/
+        String path = imgPath.substring(Constants.FASTDFS_CLIENT_SERVER.length());
+        byte[] imgbytes = fastDFSClient.download_bytes(path);
+        FileInputStream fis = null;
+        //File file = new File(path);
+        //fis =  new FileInputStream(file);
+        //byte[] b = new byte[fis.available()];
+        //fis.read(imgbytes);
+        OutputStream out = response.getOutputStream();
+        out.write(imgbytes);
+        out.flush();
+    }
+}

+ 81 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppVersionController.java

@@ -0,0 +1,81 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.entity.Version;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.service.VersionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+
+/** APP版本类
+ * Created by daipy on 2019/1/14 0014.
+ */
+@Controller
+public class AppVersionController extends BaseController {
+    @Autowired
+    private VersionService versionService;
+
+
+    @RequestMapping(value = "/app/saveVersionDetail")
+    @ResponseBody
+    public Object saveVersionDetail(HttpServletRequest request, @RequestParam(defaultValue = "")String username,
+                                    @RequestParam(defaultValue = "")String password,
+                                    @RequestParam(defaultValue = "")String is_update,
+                                    @RequestParam(defaultValue = "")BigDecimal versionCode,
+                                    @RequestParam(defaultValue = "")String versionName,
+                                    @RequestParam(defaultValue = "")String target_size,
+                                    @RequestParam(defaultValue = "")String apkUrl,
+                                    @RequestParam(defaultValue = "")String update_log,
+                                    @RequestParam(defaultValue = "")String forceUpgrade,
+                                    @RequestParam(defaultValue = "")String btn_color,
+                                    @RequestParam(defaultValue = "")String img_url){
+
+        try{
+            Version version =new Version();
+            version.setIs_update(is_update);
+            if(versionCode!=null){
+                //&&StringUtils.isNotEmpty(versionCode)
+//                version.setVersionCode(Integer.valueOf(versionCode));
+                version.setVersionCode(versionCode);
+            }
+            version.setVersionName(versionName);
+            version.setTarget_size(target_size);
+            version.setApkUrl(apkUrl);
+            version.setUpdate_log(update_log);
+            version.setForceUpgrade(forceUpgrade);
+            version.setBtn_color(btn_color);
+            version.setImg_url(img_url);
+            versionService.saveVersionDetail(version);
+            return buildJson(0,"保存成功");
+        }catch (Exception e){
+            return buildJson(-1,"保存失败");
+        }
+    }
+
+
+    @RequestMapping(value = "/app/getVersionDetail")
+    @ResponseBody
+    public Object getVersionDetail(HttpServletRequest request){
+        Map map=new HashMap();
+        try {
+            Version version=versionService.getVersionDetail();
+            map.put("code",0);
+            map.put("msg","成功");
+            map.put("data",JsonUtil.format(version));
+            return map;
+        }catch (Exception e){
+            map.put("code",-1);
+            map.put("msg","请求失败");
+            map.put("data",e.getMessage());
+            return map;
+        }
+    }
+}

+ 127 - 0
express-main/src/main/java/cn/haliaeetus/controller/appdevapi/AppWhiteListController.java

@@ -0,0 +1,127 @@
+package cn.haliaeetus.controller.appdevapi;
+
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.entity.WhiteList;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.WhiteListService;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * 白名单设置
+ */
+@Controller
+public class AppWhiteListController extends BaseController {
+    @Autowired
+    private WhiteListService whiteListService;
+
+    //白名单保存
+    @RequestMapping(value = "/app/whiteList")
+    @ResponseBody
+    public Object whiteList(HttpServletRequest request,
+                            @RequestParam(defaultValue = "0") long id,
+                            @RequestParam(defaultValue = "") String wusername,
+                            @RequestParam(defaultValue = "") String wusermobile,
+                            @RequestParam(defaultValue = "") String address,
+                            @RequestParam(defaultValue = "") String remark,
+                            @RequestParam(defaultValue = "") String type,
+                            @RequestParam(defaultValue = "") String oldphone)
+    throws Exception{
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(-1, "登录超时,请重新登录~");
+        }
+        List<WhiteList> list = whiteListService.getByPhoneStoreId(wusermobile,
+                user.getStoreId());
+
+        WhiteList white = new WhiteList();
+        white.setStoreid(user.getStoreId());
+        white.setUsermobile(wusermobile);
+        white.setUsername(wusername);
+        white.setAddress(address);
+        white.setRemark(remark);
+
+        if ("save".equals(type)) {
+            if (list.size() > 0) {
+                return buildJson(-1,"电话已存在");
+            } else {
+                long i = whiteListService.saveWhiteList(white);
+                if(i > 0){
+                    return buildJson(0,"保存成功");
+                }
+                return buildJson(-1,"保存失败");
+            }
+        } else {
+            if (list.size() > 1) {
+                return buildJson(-1,"电话已存在");
+            } else {
+                white.setId((int) id);
+                int i = whiteListService.updateWhiteList(white);
+                if(i > 0){
+                    return buildJson(0,"保存成功");
+                }
+                return buildJson(-1,"保存失败");
+            }
+        }
+
+
+    }
+
+    //查询白名单
+    @RequestMapping("/app/white/list")
+    @ResponseBody
+    public Object list(HttpServletRequest request) throws SQLException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(-1, "登录超时,请重新登录~");
+        }
+        JsonObject object = new JsonObject();
+
+            List<WhiteList> list = whiteListService.getByStoreId(user.getStoreId());
+            JsonArray array = new JsonArray();
+            for (WhiteList whiteList : list) {
+                array.add(whiteList.toJson());
+            }
+            object.addProperty("code",0);
+            object.addProperty("msg", "");
+            object.add("whiteList", array);
+            return object.toString();
+    }
+
+    // 白名单删除
+    @RequestMapping("/app/white/delete")
+    @ResponseBody
+    public Object delete(HttpServletRequest request,
+                       @RequestParam(defaultValue = "0") long id,
+                       @RequestParam(defaultValue = "") String phone) throws SQLException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(-1, "登录超时,请重新登录~");
+        }
+        int i = whiteListService.deleteWhiteList(user.getStoreId(), phone);
+
+        JsonObject jsonObject = new JsonObject();
+        /*this.list(request);
+        return new ModelAndView("/white/list");*/
+        if(i > 0){
+            jsonObject.addProperty("code",0);
+            jsonObject.addProperty("msg","请求成功");
+            return  jsonObject.toString();
+        }
+        jsonObject.addProperty("code",-1);
+        jsonObject.addProperty("msg","请求失败");
+        return  jsonObject.toString();
+    }
+
+
+
+}

+ 66 - 0
express-main/src/main/java/cn/haliaeetus/controller/baishi/BaishiServiceController.java

@@ -0,0 +1,66 @@
+package cn.haliaeetus.controller.baishi;
+
+import cn.haliaeetus.util.BaishiUpdStatusUtil;
+import cn.haliaeetus.util.BaishiUtil;
+import cn.haliaeetus.util.Tools;
+import com.alibaba.fastjson.JSONObject;
+import cn.haliaeetus.util.Baishi.*;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.List;
+
+/**
+ * Created by Administrator on 2017/11/2.
+ */
+@Controller
+@RequestMapping(value = "/importSend")
+public class BaishiServiceController {
+
+
+    @RequestMapping(value = "/serviceInfoSyn")
+    @ResponseBody
+    public String serviceInfoSyn(@RequestBody BaishiReqEntity baishiReqEntity) throws Exception {
+
+        List list = baishiReqEntity.getCabinetinfolist();
+
+        String result = BaishiUtil.cancelCodes(list);
+
+        BaishiRespEntity respEntity = JSONObject.parseObject(result, BaishiRespEntity.class);
+        if (respEntity != null) {
+            if (Tools.isEmpty(respEntity.getCode())) {
+
+                boolean success = respEntity.getSuccess();
+                if (success) {
+
+                } else {
+                    List<Errorinfolist> errorinfolist = respEntity.getErrorinfolist();
+                    for (int i = 0; i < errorinfolist.size(); i++) {
+                        Errorinfolist errorInfo = errorinfolist.get(i);
+                        errorInfo.getCabinetCode();
+                        errorInfo.getCabinetSpCode();
+                        errorInfo.getErrorCode();
+                    }
+                }
+            } else {
+                String code = respEntity.getCode();
+                String reason = respEntity.getReason();
+            }
+        }
+
+        return result;
+    }
+
+    @RequestMapping(value = "/updBillStatus")
+    @ResponseBody
+    public static String updBillStatus(@RequestBody BaishiUpdStatusReqEntity baishiUpdStatusReqEntity) throws Exception {
+
+        String result = BaishiUpdStatusUtil.cancelCodes(baishiUpdStatusReqEntity);
+
+        BaishiRespUpdStatusEntity baishiRespUpdStatusEntity = JSONObject.parseObject(result, BaishiRespUpdStatusEntity.class);
+
+        return result;
+    }
+}

+ 202 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/CommonExpressAPIController.java

@@ -0,0 +1,202 @@
+package cn.haliaeetus.controller.common;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONException;
+
+import cn.haliaeetus.controller.common.dto.OrderDTO;
+import cn.haliaeetus.controller.common.dto.OrdersDTO;
+import cn.haliaeetus.controller.common.dto.StoreInfoDTO;
+import cn.haliaeetus.controller.common.response.BaseJsonResponse;
+import cn.haliaeetus.controller.common.response.StoreListJsonResponse;
+import cn.haliaeetus.controller.common.response.SubmitOrdersJsonResponse;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.DeliveryNoArrive;
+import cn.haliaeetus.entity.Store;
+import cn.haliaeetus.entity.StoreExpressDeveloper;
+import cn.haliaeetus.exception.APIBusinessException;
+import cn.haliaeetus.framework.base.log.Logger;
+import cn.haliaeetus.framework.util.ComputeUtil;
+import cn.haliaeetus.framework.util.EncryptionUtil;
+import cn.haliaeetus.framework.util.StringUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryNoArriveService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.StoreExpressDeveloperService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>通用快递接口Controller</p>
+ *
+ * @author sqj
+ * @version 1.0
+ * @since 1.0
+ */
+@Controller
+public class CommonExpressAPIController {
+    private static final Logger LOG = Logger.getInstance(CommonExpressAPIController.class);
+
+    private static final int RESPONSE_CODE_SUCCESS = 100;
+
+    private static final int RESPONSE_CODE_UNAUTHORIZED = 101;
+
+    private static final int RESPONSE_CODE_PARAM_ERROR = 102;
+
+    private static final int RESPONSE_CODE_INVALID_DATA = 103;
+
+    @Autowired
+    private DeliveryNoArriveService deliveryNoArriveService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private StoreExpressDeveloperService expressDeveloperService;
+
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @RequestMapping(value = "/express/orders", method = {RequestMethod.GET, RequestMethod.POST})
+    public
+    @ResponseBody
+    BaseJsonResponse dispatch(@RequestParam("fn") String fn,
+                              @RequestParam("appname") String appName,
+                              @RequestParam("appkey") String appToken,
+                              @RequestParam("apptime") String appTime,
+                              @RequestParam("appdata") String appData) {
+        try {
+            // 验证参数
+            if (!StringUtils.hasText(fn) || !StringUtils.hasText(appName) ||
+                    !StringUtils.hasText(appToken) || !StringUtils.hasText(appTime)) {
+                throw new APIBusinessException(RESPONSE_CODE_PARAM_ERROR, "第三方快递接口调用,请求参数错误");
+            }
+
+            StoreExpressDeveloper developer = expressDeveloperService.getByAppName(appName);
+            if (developer == null) {
+                throw new APIBusinessException(RESPONSE_CODE_UNAUTHORIZED, "第三方快递接口调用,未授权的appname:" + appName);
+            }
+
+            // 验证接口调用合法性
+            String token = EncryptionUtil.MD5(developer.getAppName() + developer.getAppKey() + appTime);
+            if (!appToken.equals(token)) {
+                throw new APIBusinessException(RESPONSE_CODE_UNAUTHORIZED, "第三方快递接口调用,未授权的请求");
+            }
+
+            appData = URLDecoder.decode(appData, "UTF-8");
+
+            if ("store.list.get".equals(fn)) {
+                return getStoreInfoList();
+            } else if ("order.arrival.set".equals(fn)) {
+                OrdersDTO ordersDTO = JSON.parseObject(appData, OrdersDTO.class);
+                return submitOrders(ordersDTO.getOrders(), developer.getExpressType());
+            }
+        } catch (APIBusinessException ex) {
+            ex.printStackTrace();
+            return new BaseJsonResponse(ex.getCode(), ex.getMessage());
+        } catch (JSONException ex) {
+            APIBusinessException apiBusinessException = new APIBusinessException(RESPONSE_CODE_INVALID_DATA,
+                    "第三方快递接口调用,数据格式错误", ex);
+            apiBusinessException.printStackTrace();
+            return new BaseJsonResponse(apiBusinessException.getCode(), apiBusinessException.getMessage());
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return new BaseJsonResponse(RESPONSE_CODE_SUCCESS, "成功");
+    }
+
+    /**
+     * 获取门店信息
+     */
+    private StoreListJsonResponse getStoreInfoList() {
+        List<Store> stores = basicInfoService.getAllStoreFromMemcached();
+
+        List<StoreInfoDTO> storeDTOs = new ArrayList<>();
+        for (Store store : stores) {
+            storeDTOs.add(parseStoreInfoToStoreInfoDTO(store));
+        }
+
+        return new StoreListJsonResponse(100, "成功", storeDTOs);
+    }
+
+    /**
+     * 将门店信息转换为DTO
+     */
+    private StoreInfoDTO parseStoreInfoToStoreInfoDTO(Store storeInfo) {
+        StoreInfoDTO dto = new StoreInfoDTO();
+        dto.setSaddress(storeInfo.getAddress());
+        dto.setSarea(storeInfo.getProvinceId() + " " + storeInfo.getCityId() + " " + storeInfo.getAreaId());
+        dto.setSid(storeInfo.getId());
+        dto.setSname(storeInfo.getName());
+        dto.setSphone(storeInfo.getPhone());
+        return dto;
+    }
+
+    /**
+     * 提交派件订单
+     */
+    private SubmitOrdersJsonResponse submitOrders(List<OrderDTO> orderDTOList, int expressType) {
+        SubmitOrdersJsonResponse jsonResponse = new SubmitOrdersJsonResponse(100, "成功");
+        jsonResponse.setOsnList(new ArrayList<String>());
+        jsonResponse.setErrOsnList(new ArrayList<String>());
+
+        for (OrderDTO orderDTO : orderDTOList) {
+            parseAndSave(orderDTO, expressType, jsonResponse.getOsnList(), jsonResponse.getErrOsnList());
+        }
+
+        return jsonResponse;
+    }
+
+    private void parseAndSave(OrderDTO orderDTO, int expressType, List<String> osnList, List<String> errOsnList) {
+        if (!StringUtils.hasText(orderDTO.getOsn()) || orderDTO.getSid() <= 0 ||
+                !StringUtils.hasText(orderDTO.getUname()) || !StringUtils.hasText(orderDTO.getUphone()) ||
+                !StringUtils.hasText(orderDTO.getOarea()) || !StringUtils.hasText(orderDTO.getOaddress()) ||
+                !StringUtils.hasText(orderDTO.getOpaytype()) ||
+                orderDTO.getOpackagelist() == null || orderDTO.getOpackagelist().size() == 0) {
+            errOsnList.add(orderDTO.getOsn());
+            LOG.record("第三方订单提交失败,订单数据格式错误:" + orderDTO);
+            return;
+        }
+
+        if (basicInfoService.getStoreById(orderDTO.getSid()) == null) {
+            errOsnList.add(orderDTO.getOsn());
+            LOG.record("第三方订单提交失败,订单门店ID错误:" + orderDTO);
+            return;
+        }
+
+        // 若订单数据已存在
+        Delivery delivery = deliveryService.getByTuple(orderDTO.getSid(), expressType, orderDTO.getOsn());
+        if (delivery != null) {
+            osnList.add(orderDTO.getOsn());
+            LOG.record("第三方订单提交重复:" + orderDTO);
+            return;
+        }
+
+        DeliveryNoArrive deliveryNoArrive = new DeliveryNoArrive();
+        deliveryNoArrive.setStoreid(orderDTO.getSid());
+        deliveryNoArrive.setExpid(expressType);
+        deliveryNoArrive.setExpcode(orderDTO.getOsn());
+        deliveryNoArrive.setUsername(orderDTO.getUname());
+        deliveryNoArrive.setUserphone(orderDTO.getUphone().trim());
+        deliveryNoArrive.setAddress(orderDTO.getOaddress());
+        deliveryNoArrive.setChargemoney(ComputeUtil.parseToInt(orderDTO.getOchargemoney()));
+        deliveryNoArrive.setRemark("每日优鲜订单提交");
+        deliveryNoArrive.setRevexpCode(StringUtil.stringReverse(orderDTO.getOsn()));
+        deliveryNoArrive.setRevuserPhone(StringUtil.stringReverse(orderDTO.getUphone().trim()));
+        deliveryNoArrive.setCreatetime(new Date());
+        deliveryNoArriveService.insert(deliveryNoArrive);
+
+        osnList.add(orderDTO.getOsn());
+    }
+}

+ 213 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderDTO.java

@@ -0,0 +1,213 @@
+/**
+ * @FileName: XhmDeliveryDTO.java
+ * @Package cn.haliaeetus.api.xhm.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-9 上午11:34:52
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.dto;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>订单DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrderDTO {
+	private String osn; // 订单唯一编号
+	
+	private int sid; // 门店ID
+	
+	private String uname; // 用户姓名
+	
+	private String uphone; // 用户手机号或电话
+	
+	private String oarea; // 订单所在地区(省 市 区 街道)
+	
+	private String oaddress; // 配送详细地址
+	
+	private double oweight; // 订单重量,单位:公斤
+	
+	private double ovolume; // 订单体积,单位:立方米
+	
+	private String opaytype; // 订单支付方式
+	
+	private double opaymoney; // 订单支付金额
+	
+	private int oischarge; // 订单是否代收费,1:是,0:否
+	
+	private double ochargemoney; // 订单代收费金额,无代收费可为0
+	
+	private int osource; // 来源,1:PC端、2:移动端
+	
+	private int oisunpack; // 是否能拆包,0:否、1:是
+	
+	private int oischeck; // 是否能抽检,0:否、1:是
+	
+	private List<OrderPackageDTO> opackagelist; // 订单包裹列表
+	
+	private List<OrderStatusDTO> ostatuslist; // 订单历史状态信息列表
+	
+	private Date otime; // 订单生成时间
+
+	public String getOsn() {
+		return osn;
+	}
+
+	public void setOsn(String osn) {
+		this.osn = osn;
+	}
+
+	public int getSid() {
+		return sid;
+	}
+
+	public void setSid(int sid) {
+		this.sid = sid;
+	}
+
+	public String getUname() {
+		return uname;
+	}
+
+	public void setUname(String uname) {
+		this.uname = uname;
+	}
+
+	public String getUphone() {
+		return uphone;
+	}
+
+	public void setUphone(String uphone) {
+		this.uphone = uphone;
+	}
+
+	public String getOarea() {
+		return oarea;
+	}
+
+	public void setOarea(String oarea) {
+		this.oarea = oarea;
+	}
+
+	public String getOaddress() {
+		return oaddress;
+	}
+
+	public void setOaddress(String oaddress) {
+		this.oaddress = oaddress;
+	}
+
+	public double getOweight() {
+		return oweight;
+	}
+
+	public void setOweight(double oweight) {
+		this.oweight = oweight;
+	}
+
+	public double getOvolume() {
+		return ovolume;
+	}
+
+	public void setOvolume(double ovolume) {
+		this.ovolume = ovolume;
+	}
+
+	public String getOpaytype() {
+		return opaytype;
+	}
+
+	public void setOpaytype(String opaytype) {
+		this.opaytype = opaytype;
+	}
+
+	public double getOpaymoney() {
+		return opaymoney;
+	}
+
+	public void setOpaymoney(double opaymoney) {
+		this.opaymoney = opaymoney;
+	}
+
+	public int getOischarge() {
+		return oischarge;
+	}
+
+	public void setOischarge(int oischarge) {
+		this.oischarge = oischarge;
+	}
+
+	public double getOchargemoney() {
+		return ochargemoney;
+	}
+
+	public void setOchargemoney(double ochargemoney) {
+		this.ochargemoney = ochargemoney;
+	}
+
+	public List<OrderPackageDTO> getOpackagelist() {
+		return opackagelist;
+	}
+
+	public void setOpackagelist(List<OrderPackageDTO> opackagelist) {
+		this.opackagelist = opackagelist;
+	}
+
+	public List<OrderStatusDTO> getOstatuslist() {
+		return ostatuslist;
+	}
+
+	public void setOstatuslist(List<OrderStatusDTO> ostatuslist) {
+		this.ostatuslist = ostatuslist;
+	}
+
+	public Date getOtime() {
+		return otime;
+	}
+
+	public void setOtime(Date otime) {
+		this.otime = otime;
+	}
+
+	public int getOsource() {
+		return osource;
+	}
+
+	public void setOsource(int osource) {
+		this.osource = osource;
+	}
+
+	public int getOisunpack() {
+		return oisunpack;
+	}
+
+	public void setOisunpack(int oisunpack) {
+		this.oisunpack = oisunpack;
+	}
+
+	public int getOischeck() {
+		return oischeck;
+	}
+
+	public void setOischeck(int oischeck) {
+		this.oischeck = oischeck;
+	}
+
+	@Override
+	public String toString() {
+		return "OrderDTO [osn=" + osn + ", sid=" + sid + ", uname=" + uname
+				+ ", uphone=" + uphone + ", oarea=" + oarea + ", oaddress="
+				+ oaddress + ", oweight=" + oweight + ", ovolume=" + ovolume
+				+ ", opaytype=" + opaytype + ", opaymoney=" + opaymoney
+				+ ", oischarge=" + oischarge + ", ochargemoney=" + ochargemoney
+				+ ", opackagelist=" + opackagelist + ", ostatuslist="
+				+ ostatuslist + ", otime=" + otime + "]";
+	}
+}

+ 41 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderModifyDTO.java

@@ -0,0 +1,41 @@
+/**
+ * @FileName: XhmDeliveryDTO.java
+ * @Package cn.haliaeetus.api.xhm.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-9 上午11:34:52
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.dto;
+
+/**
+ * 订单修改DTO
+ * @author sqj
+ */
+public class OrderModifyDTO {
+	private String osn; // 订单号
+	
+	private String psn; // 包裹号
+
+	public String getOsn() {
+		return osn;
+	}
+
+	public void setOsn(String osn) {
+		this.osn = osn;
+	}
+
+	public String getPsn() {
+		return psn;
+	}
+
+	public void setPsn(String psn) {
+		this.psn = psn;
+	}
+
+	@Override
+	public String toString() {
+		return "OrderModifyDTO [osn=" + osn + ", psn=" + psn + "]";
+	}
+}

+ 65 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderPackageDTO.java

@@ -0,0 +1,65 @@
+/**
+ * @FileName: OrderPackageDTO.java
+ * @Package cn.haliaeetus.api.xhm.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-10 下午6:00:19
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.dto;
+
+/**
+ * <p>小红帽订单包裹DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrderPackageDTO {
+	private String psn; // 包裹唯一编号
+	
+	private double pweight; // 包裹重量,单位:公斤
+	
+	private double pvolume; // 包裹体积,单位:立方米
+	
+	private double pmoney; // 包裹价格
+
+	public String getPsn() {
+		return psn;
+	}
+
+	public void setPsn(String psn) {
+		this.psn = psn;
+	}
+
+	public double getPweight() {
+		return pweight;
+	}
+
+	public void setPweight(double pweight) {
+		this.pweight = pweight;
+	}
+
+	public double getPvolume() {
+		return pvolume;
+	}
+
+	public void setPvolume(double pvolume) {
+		this.pvolume = pvolume;
+	}
+
+	public double getPmoney() {
+		return pmoney;
+	}
+
+	public void setPmoney(double pmoney) {
+		this.pmoney = pmoney;
+	}
+
+	@Override
+	public String toString() {
+		return "OrderPackageDTO [psn=" + psn + ", pweight=" + pweight
+				+ ", pvolume=" + pvolume + ", pmoney=" + pmoney + "]";
+	}
+}

+ 122 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderReturnDTO.java

@@ -0,0 +1,122 @@
+/**
+ * @FileName: XhmDeliveryDTO.java
+ * @Package cn.haliaeetus.api.xhm.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-9 上午11:34:52
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.dto;
+
+import java.util.Date;
+
+/**
+ * <p>小红帽退换货订单DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrderReturnDTO extends OrderDTO {
+	private String chgosn; // 退换货订单号
+	
+	private String returnproname; // 退货商品名称
+	
+	private int returnpronum; // 退货商品数量
+	
+	private String returnpaytype; // 退款支付方式
+	
+	private double returnmoney; // 应退金额
+	
+	private String returntype; // 退换类型
+	
+	private int isvisit; // 是否上门取件,0:否,1:是
+	
+	private Date returntime; // 退货时间
+
+	public String getChgosn() {
+		return chgosn;
+	}
+
+	public void setChgosn(String chgosn) {
+		this.chgosn = chgosn;
+	}
+
+	public String getReturnproname() {
+		return returnproname;
+	}
+
+	public void setReturnproname(String returnproname) {
+		this.returnproname = returnproname;
+	}
+
+	public int getReturnpronum() {
+		return returnpronum;
+	}
+
+	public void setReturnpronum(int returnpronum) {
+		this.returnpronum = returnpronum;
+	}
+
+	public String getReturnpaytype() {
+		return returnpaytype;
+	}
+
+	public void setReturnpaytype(String returnpaytype) {
+		this.returnpaytype = returnpaytype;
+	}
+
+	public double getReturnmoney() {
+		return returnmoney;
+	}
+
+	public void setReturnmoney(double returnmoney) {
+		this.returnmoney = returnmoney;
+	}
+
+	public int getIsvisit() {
+		return isvisit;
+	}
+
+	public void setIsvisit(int isvisit) {
+		this.isvisit = isvisit;
+	}
+
+	public Date getReturntime() {
+		return returntime;
+	}
+
+	public void setReturntime(Date returntime) {
+		this.returntime = returntime;
+	}
+
+	public String getReturntype() {
+		return returntype;
+	}
+
+	public void setReturntype(String returntype) {
+		this.returntype = returntype;
+	}
+
+	@Override
+	public String toString() {
+		return "OrderReturnDTO [chgosn=" + chgosn + ", returnproname="
+				+ returnproname + ", returnpronum=" + returnpronum
+				+ ", returnpaytype=" + returnpaytype + ", returnmoney="
+				+ returnmoney + ", returntype=" + returntype + ", isvisit="
+				+ isvisit + ", returntime=" + returntime + ", getOsn()="
+				+ getOsn() + ", getSid()=" + getSid() + ", getUname()="
+				+ getUname() + ", getUphone()=" + getUphone() + ", getOarea()="
+				+ getOarea() + ", getOaddress()=" + getOaddress()
+				+ ", getOweight()=" + getOweight() + ", getOvolume()="
+				+ getOvolume() + ", getOpaytype()=" + getOpaytype()
+				+ ", getOpaymoney()=" + getOpaymoney() + ", getOischarge()="
+				+ getOischarge() + ", getOchargemoney()=" + getOchargemoney()
+				+ ", getOpackagelist()=" + getOpackagelist()
+				+ ", getOstatuslist()=" + getOstatuslist() + ", getOtime()="
+				+ getOtime() + ", toString()=" + super.toString()
+				+ ", getClass()=" + getClass() + ", hashCode()=" + hashCode()
+				+ "]";
+	}
+}

+ 51 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrderStatusDTO.java

@@ -0,0 +1,51 @@
+/**
+ * @FileName: OrderStatusDTO.java
+ * @Package cn.haliaeetus.api.xhm.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-10 下午6:04:18
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.dto;
+
+import java.util.Date;
+
+/**
+ * <p>小红帽订单状态DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrderStatusDTO {
+	private String ostatus; // 订单状态名称,如:在途、已发货等
+	
+	private Date otime; // 订单状态产生时间
+	
+	private String oremark; // 订单状态生成描述
+
+	public String getOstatus() {
+		return ostatus;
+	}
+
+	public void setOstatus(String ostatus) {
+		this.ostatus = ostatus;
+	}
+
+	public Date getOtime() {
+		return otime;
+	}
+
+	public void setOtime(Date otime) {
+		this.otime = otime;
+	}
+
+	public String getOremark() {
+		return oremark;
+	}
+
+	public void setOremark(String oremark) {
+		this.oremark = oremark;
+	}
+}

+ 31 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrdersDTO.java

@@ -0,0 +1,31 @@
+/**
+ * @FileName: XhmDeliveryDTO.java
+ * @Package cn.haliaeetus.api.xhm.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-9 上午11:34:52
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.dto;
+
+import java.util.List;
+
+/**
+ * <p>订单列表DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrdersDTO {
+	private List<OrderDTO> orders;
+
+	public List<OrderDTO> getOrders() {
+		return orders;
+	}
+
+	public void setOrders(List<OrderDTO> orders) {
+		this.orders = orders;
+	}
+}

+ 31 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/dto/OrdersReturnDTO.java

@@ -0,0 +1,31 @@
+/**
+ * @FileName: XhmDeliveryDTO.java
+ * @Package cn.haliaeetus.api.xhm.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-9 上午11:34:52
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.dto;
+
+import java.util.List;
+
+/**
+ * <p>小红帽退换货订单列表DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrdersReturnDTO {
+	private List<OrderReturnDTO> returnorders;
+
+	public List<OrderReturnDTO> getReturnorders() {
+		return returnorders;
+	}
+
+	public void setReturnorders(List<OrderReturnDTO> returnorders) {
+		this.returnorders = returnorders;
+	}
+}

+ 76 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/dto/StoreInfoDTO.java

@@ -0,0 +1,76 @@
+/**
+ * @FileName: XhmStoreInfoDTO.java
+ * @Package cn.haliaeetus.api.xhm.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-9 下午3:48:33
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * <p>门店信息DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class StoreInfoDTO {
+	@JsonProperty(value = "Sid")
+	private int sid; // 门店ID
+	
+	@JsonProperty(value = "SName")
+	private String sname; // 门店名称
+	
+	@JsonProperty(value = "SArea")
+	private String sarea; // 门店所在地区(格式:省 市 区)
+	
+	@JsonProperty(value = "SAddress")
+	private String saddress; // 门店详细地址
+	
+	@JsonProperty(value = "SPhone")
+	private String sphone; // 门店联系电话
+
+	public int getSid() {
+		return sid;
+	}
+
+	public void setSid(int sid) {
+		this.sid = sid;
+	}
+
+	public String getSname() {
+		return sname;
+	}
+
+	public void setSname(String sname) {
+		this.sname = sname;
+	}
+
+	public String getSarea() {
+		return sarea;
+	}
+
+	public void setSarea(String sarea) {
+		this.sarea = sarea;
+	}
+
+	public String getSaddress() {
+		return saddress;
+	}
+
+	public void setSaddress(String saddress) {
+		this.saddress = saddress;
+	}
+
+	public String getSphone() {
+		return sphone;
+	}
+
+	public void setSphone(String sphone) {
+		this.sphone = sphone;
+	}
+}

+ 55 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/response/BaseJsonResponse.java

@@ -0,0 +1,55 @@
+/**
+ * @FileName: JSONMessage.java
+ * @Package cn.haliaeetus.site.cgi.entity
+ * 
+ * @author Administrator
+ * @created 2014-1-21 上午9:36:32
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.response;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * JSON响应对象实体
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class BaseJsonResponse implements Serializable {
+	private static final long serialVersionUID = 7374977881514798445L;
+	
+	@JsonProperty(value = "Code")
+	private long code; // 状态码,0:成功,其他失败
+	
+	@JsonProperty(value = "Msg")
+	private String msg; // 提示信息
+	
+	public BaseJsonResponse() {
+	}
+	
+	public BaseJsonResponse(long code, String msg) {
+		this.code = code;
+		this.msg = msg;
+	}
+
+	public long getCode() {
+		return code;
+	}
+
+	public void setCode(long code) {
+		this.code = code;
+	}
+
+	public String getMsg() {
+		return msg;
+	}
+
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+}

+ 48 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/response/StoreListJsonResponse.java

@@ -0,0 +1,48 @@
+/**
+ * @FileName: JSONMessage.java
+ * @Package cn.haliaeetus.site.cgi.entity
+ * 
+ * @author Administrator
+ * @created 2014-1-21 上午9:36:32
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.response;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import cn.haliaeetus.controller.common.dto.StoreInfoDTO;
+
+/**
+ * JSON响应对象实体
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class StoreListJsonResponse extends BaseJsonResponse implements Serializable {
+	private static final long serialVersionUID = 7374977881514798445L;
+	
+	@JsonProperty(value = "Stores")
+	private List<StoreInfoDTO> stores = new ArrayList<StoreInfoDTO>(); // 门店数据
+	
+	public StoreListJsonResponse() {
+	}
+	
+	public StoreListJsonResponse(long code, String msg, List<StoreInfoDTO> stores) {
+		super(code, msg);
+		this.stores = stores;
+	}
+
+	public List<StoreInfoDTO> getStores() {
+		return stores;
+	}
+
+	public void setStores(List<StoreInfoDTO> stores) {
+		this.stores = stores;
+	}
+}

+ 55 - 0
express-main/src/main/java/cn/haliaeetus/controller/common/response/SubmitOrdersJsonResponse.java

@@ -0,0 +1,55 @@
+/**
+ * @FileName: JSONMessage.java
+ * @Package cn.haliaeetus.site.cgi.entity
+ * 
+ * @author Administrator
+ * @created 2014-1-21 上午9:36:32
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.common.response;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * 提交订单JSON响应对象实体
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class SubmitOrdersJsonResponse extends BaseJsonResponse implements Serializable {
+	private static final long serialVersionUID = 7374977881514798445L;
+	
+	@JsonProperty(value = "OSNList")
+	private List<String> osnList; // 成功订单编码列表
+	
+	@JsonProperty(value = "Err_OSNList")
+	private List<String> errOsnList; // 失败订单编码列表
+	
+	public SubmitOrdersJsonResponse() {
+	}
+	
+	public SubmitOrdersJsonResponse(long code, String msg) {
+		super(code, msg);
+	}
+
+	public List<String> getOsnList() {
+		return osnList;
+	}
+
+	public void setOsnList(List<String> osnList) {
+		this.osnList = osnList;
+	}
+
+	public List<String> getErrOsnList() {
+		return errOsnList;
+	}
+
+	public void setErrOsnList(List<String> errOsnList) {
+		this.errOsnList = errOsnList;
+	}
+}

+ 238 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/DangdangAPIController.java

@@ -0,0 +1,238 @@
+package cn.haliaeetus.controller.dangdang;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONException;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.dangdang.dto.OrderDTO;
+import cn.haliaeetus.controller.dangdang.dto.OrderErrorDTO;
+import cn.haliaeetus.controller.dangdang.response.SubmitOrdersJsonResponse;
+import cn.haliaeetus.controller.store.helper.DeliveryMsgSendHelper;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.DeliveryNoArrive;
+import cn.haliaeetus.entity.DeliveryStatus;
+import cn.haliaeetus.exception.APIBusinessException;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.log.Logger;
+import cn.haliaeetus.framework.util.ComputeUtil;
+import cn.haliaeetus.framework.util.RegexUtil;
+import cn.haliaeetus.framework.util.StringUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryNoArriveService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.DeliveryStatusService;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>当当接口Controller</p>
+ *
+ * @author sqj
+ * @version 1.0
+ * @since 1.0
+ */
+@Controller
+public class DangdangAPIController {
+    private static final Logger LOG = Logger.getInstance(DangdangAPIController.class);
+
+    private static final int RESPONSE_CODE_SUCCESS = 0;
+    private static final int RESPONSE_CODE_FAIL = 21;
+    private static final int RESPONSE_CODE_PARAM_ERROR = 11;
+
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @Autowired
+    private DeliveryStatusService deliveryStatusService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private DeliveryNoArriveService deliveryNoArriveService;
+
+    @Autowired
+    private DeliveryMsgSendHelper msgSendHelper;
+
+    @RequestMapping(value = "/expressopen_dd.ashx", method = {RequestMethod.GET, RequestMethod.POST})
+    public
+    @ResponseBody
+    SubmitOrdersJsonResponse submitOrders(@RequestParam("express_id") String expressId,
+                                          @RequestParam("request_time") String requestTime,
+                                          @RequestParam("token") String token,
+                                          @RequestParam("order_list") String orderList) {
+        List<OrderErrorDTO> errorList;
+        try {
+            // 验证参数
+            if (_.isEmpty(expressId) || _.isEmpty(requestTime) || _.isEmpty(token) || _.isEmpty(orderList)) {
+                throw new APIBusinessException(RESPONSE_CODE_PARAM_ERROR, "当当订单提交接口调用失败,参数不能为空");
+            }
+
+            List<OrderDTO> orderDTOList = JSON.parseArray(orderList, OrderDTO.class);
+            errorList = doSubmitOrders(orderDTOList);
+        } catch (APIBusinessException ex) {
+            ex.printStackTrace();
+            return new SubmitOrdersJsonResponse(ex.getCode());
+        } catch (JSONException ex) {
+            APIBusinessException apiBusinessException = new APIBusinessException(RESPONSE_CODE_PARAM_ERROR,
+                    "当当订单提交接口调用失败,订单数据格式错误:" + orderList, ex);
+            apiBusinessException.printStackTrace();
+            return new SubmitOrdersJsonResponse(apiBusinessException.getCode());
+        }
+        // 0:全部接收/撤回成功,21:全部或部分接收/撤回失败
+        return new SubmitOrdersJsonResponse(errorList.size() == 0 ? RESPONSE_CODE_SUCCESS : RESPONSE_CODE_FAIL, errorList);
+    }
+
+    /**
+     * 提交订单
+     */
+    private List<OrderErrorDTO> doSubmitOrders(List<OrderDTO> orderDTOList) {
+        List<OrderErrorDTO> orderErrorList = new ArrayList<>();
+        List<DeliveryNoArrive> deliveryNoArriveList = new ArrayList<>();
+
+        for (OrderDTO orderDTO : orderDTOList) {
+            Object obj = handleOrderDTO(orderDTO);
+            if (obj != null && obj instanceof OrderErrorDTO) { // 订单信息错误
+                orderErrorList.add((OrderErrorDTO) obj);
+            } else if (obj instanceof DeliveryNoArrive) {
+                deliveryNoArriveList.add((DeliveryNoArrive) obj);
+            }
+        }
+
+        if (deliveryNoArriveList.size() > 0) {
+            for (DeliveryNoArrive deliveryNoArrive : deliveryNoArriveList) {
+                deliveryNoArriveService.insert(deliveryNoArrive);
+                LOG.record("当当订单提交成功,订单信息:" + deliveryNoArrive);
+            }
+        }
+        return orderErrorList;
+    }
+
+    /**
+     * 将订单DTO转换为派件订单
+     */
+    private Object handleOrderDTO(OrderDTO orderDTO) {
+        if (_.isEmpty(orderDTO.getOrderId())) {
+            LOG.record("当当订单提交失败,订单编码错误,订单信息:" + orderDTO);
+            return null;
+        }
+
+        // 订单信息有误,包括必须字段缺失、类型错误等
+        if (orderDTO.getSelfServiceId() <= 0) {
+            LOG.record("当当订单提交失败,门店ID错误,订单信息:" + orderDTO);
+            return new OrderErrorDTO(orderDTO.getOrderId(), 101);
+        }
+
+        if (basicInfoService.getStoreById(orderDTO.getSelfServiceId()) == null) {
+            LOG.record("当当订单提交失败,门店ID不存在,订单信息:" + orderDTO);
+            return null;
+        }
+
+        // 若订单数据已存在,更新订单信息
+        DeliveryQueryCondition queryCondition = new DeliveryQueryCondition(orderDTO.getSelfServiceId());
+        queryCondition.setExpcode(orderDTO.getOrderId());
+        queryCondition.setExpId(Constants.EXPRESS_TYPE_DD);
+        List<Delivery> deliveries = deliveryService.getDelivery(queryCondition);
+
+        if (_.isNotEmpty(deliveries)) {
+            Delivery oldDelivery = deliveries.get(0);
+
+            DeliveryQueryCondition updateCondition = new DeliveryQueryCondition(orderDTO.getSelfServiceId());
+            updateCondition.setId(oldDelivery.getId());
+
+            Delivery entity = new Delivery();
+            entity.setUserAddress(_.trimToNull(orderDTO.getRcvAddress()));
+            entity.setRemark(_.trimToNull(orderDTO.getCustMessage()));
+            entity.setUserName(_.trimToNull(orderDTO.getRcvName()));
+            entity.setUserPhone(_.trimToNull(initMobilephone(orderDTO)));
+            entity.setMoney(ComputeUtil.parseToInt(orderDTO.getShouldReceivePayment()));
+            entity.setIscharge(ComputeUtil.parseToInt(orderDTO.getShouldReceivePayment()) > 0 ? Constants.YES : Constants.NO);
+            entity.setChargeMoney(ComputeUtil.parseToInt(orderDTO.getShouldReceivePayment()));
+            updateCondition.setEntity(entity);
+            deliveryService.update(updateCondition);
+            LOG.record("当当订单更新,订单信息:" + orderDTO);
+
+            sendMsg(oldDelivery, orderDTO);
+            return null;
+        }
+
+        DeliveryNoArrive deliveryNoArrive = new DeliveryNoArrive();
+        deliveryNoArrive.setCreatetime(new Date());
+        deliveryNoArrive.setChargemoney(ComputeUtil.parseToInt(orderDTO.getShouldReceivePayment()));
+        deliveryNoArrive.setExpcode(orderDTO.getOrderId());
+        deliveryNoArrive.setExpid(Constants.EXPRESS_TYPE_DD);
+        deliveryNoArrive.setRemark("当当提交订单");
+        deliveryNoArrive.setStoreid(orderDTO.getSelfServiceId());
+        deliveryNoArrive.setUsername(_.trimToEmpty(orderDTO.getRcvName()));
+        String userPhone = initMobilephone(orderDTO);
+        deliveryNoArrive.setUserphone(userPhone);
+        deliveryNoArrive.setAddress(_.trimToEmpty(orderDTO.getRcvAddress()));
+        deliveryNoArrive.setRevexpCode(StringUtil.stringReverse(orderDTO.getOrderId()));
+        deliveryNoArrive.setRevuserPhone(StringUtil.stringReverse(userPhone));
+        return deliveryNoArrive;
+    }
+
+    private void sendMsg(Delivery oldDelivery, OrderDTO orderDTO) {
+        try {
+            Delivery delivery = new Delivery();
+            BeanUtils.copyProperties(delivery, oldDelivery);
+            delivery.setExpcode(orderDTO.getOrderId());
+            delivery.setUserName(_.trimToEmpty(orderDTO.getRcvName()));
+            delivery.setUserAddress(_.trimToEmpty(orderDTO.getRcvAddress()));
+            delivery.setUserPhone(initMobilephone(orderDTO));
+            delivery.setPayType(orderDTO.getPayWay());
+            delivery.setMoney(ComputeUtil.parseToInt(orderDTO.getShouldReceivePayment()));
+            delivery.setIscharge(ComputeUtil.parseToInt(orderDTO.getShouldReceivePayment()) > 0 ? Constants.YES : Constants.NO);
+            delivery.setChargeMoney(ComputeUtil.parseToInt(orderDTO.getShouldReceivePayment()));
+            delivery.setStoreId(orderDTO.getSelfServiceId());
+            delivery.setRemark(_.trimToEmpty(orderDTO.getCustMessage()));
+            delivery.setFillType(Constants.ORDER_FILL_TYPE_EXPRESS);
+
+            DeliveryStatus oldDeliveryStatus = deliveryStatusService.getEarliestStatusOfDelivery(oldDelivery.getStoreId(),
+                    oldDelivery.getId(), Constants.ORDER_STATUS_STORED);
+            if (oldDeliveryStatus == null) {
+                return;
+            }
+
+            DeliveryStatus deliveryStatus = new DeliveryStatus();
+            deliveryStatus.setDeliveryId(delivery.getId());
+            deliveryStatus.setPreStatus(oldDelivery.getStatus());
+            deliveryStatus.setStatus(oldDelivery.getStatus());
+            deliveryStatus.setSource(oldDeliveryStatus.getSource());
+            deliveryStatus.setUpdateTime(new Date());
+
+            msgSendHelper.asyncSendMsg(delivery, deliveryStatus, oldDelivery);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    private String initMobilephone(OrderDTO orderDTO) {
+        if (orderDTO == null) {
+            return "";
+        }
+
+        String mobilephone = orderDTO.getRcvMobileTel();
+        if (_.isEmpty(mobilephone)) {
+            String phone = orderDTO.getRcvFixTel();
+            if (RegexUtil.isValidPhoneNumberCN(phone)) {
+                mobilephone = phone.trim();
+            } else {
+                mobilephone = "";
+            }
+        }
+
+        return mobilephone;
+    }
+}

+ 76 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/MenDianInStorageDTO.java

@@ -0,0 +1,76 @@
+/**
+ * @FileName: OrderSubmitStatusDTO.java
+ * @Package cn.haliaeetus.api.dangdang.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-14 下午5:29:03
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+/**
+ * <p>门店入库DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class MenDianInStorageDTO {
+	@JSONField(name = "express_id")
+	private String expressId; // 快递公司ID,由当当分配
+	
+	@JSONField(name = "order_id")
+	private String orderId; // 订单ID
+	
+	@JSONField(name = "self_service_id")
+	private String selfServiceId; // 门店ID
+	
+	@JSONField(name = "in_storage_date")
+	private String inStorageDate; // 入库时间,格式:yyyy-MM-dd HH:mm:ss
+	
+	@JSONField(name = "operator")
+	private String operator; // 操作人
+
+	public String getExpressId() {
+		return expressId;
+	}
+
+	public void setExpressId(String expressId) {
+		this.expressId = expressId;
+	}
+
+	public String getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(String orderId) {
+		this.orderId = orderId;
+	}
+
+	public String getSelfServiceId() {
+		return selfServiceId;
+	}
+
+	public void setSelfServiceId(String selfServiceId) {
+		this.selfServiceId = selfServiceId;
+	}
+
+	public String getInStorageDate() {
+		return inStorageDate;
+	}
+
+	public void setInStorageDate(String inStorageDate) {
+		this.inStorageDate = inStorageDate;
+	}
+
+	public String getOperator() {
+		return operator;
+	}
+
+	public void setOperator(String operator) {
+		this.operator = operator;
+	}
+}

+ 210 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderDTO.java

@@ -0,0 +1,210 @@
+/**
+ * @FileName: OrderDTO.java
+ * @Package cn.haliaeetus.api.dangdang.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-14 下午5:39:16
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+/**
+ * <p>当当订单DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrderDTO {
+	@JSONField(name = "order_id")
+	private String orderId; // 运单号
+	
+	@JSONField(name = "rcv_name")
+	private String rcvName; // 收货人
+	
+	@JSONField(name = "rcv_province")
+	private String rcvProvince; // 省
+	
+	@JSONField(name = "rcv_city")
+	private String rcvCity; // 市
+	
+	@JSONField(name = "rcv_town")
+	private String rcvTown; // 区
+	
+	@JSONField(name = "rcv_address")
+	private String rcvAddress; // 收件地区
+	
+	@JSONField(name = "rcv_zip")
+	private String rcvZip; // 收件人邮编
+	
+	@JSONField(name = "rcv_fix_tel")
+	private String rcvFixTel; // 收件人电话
+	
+	@JSONField(name = "rcv_mobile_tel")
+	private String rcvMobileTel; // 收件人手机
+	
+	@JSONField(name = "pay_way")
+	private int payWay; // 支付方式
+	
+	@JSONField(name = "should_receive_payment")
+	private double shouldReceivePayment; // 应收款
+	
+	@JSONField(name = "cust_message")
+	private String custMessage; // 客户留言
+	
+	@JSONField(name = "package_num")
+	private int packageNum; // 件数
+	
+	@JSONField(name = "is_expensive")
+	private int isExpensive; // 是否为贵重物品,0:否,1:是
+	
+	@JSONField(name = "is_multi_package")
+	private int isMultiPackage; // 是否一单多件,0:否,1:是
+	
+	@JSONField(name = "self_service_id")
+	private int selfServiceId; // 自提点ID
+
+	public String getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(String orderId) {
+		this.orderId = orderId;
+	}
+
+	public String getRcvName() {
+		return rcvName;
+	}
+
+	public void setRcvName(String rcvName) {
+		this.rcvName = rcvName;
+	}
+
+	public String getRcvProvince() {
+		return rcvProvince;
+	}
+
+	public void setRcvProvince(String rcvProvince) {
+		this.rcvProvince = rcvProvince;
+	}
+
+	public String getRcvCity() {
+		return rcvCity;
+	}
+
+	public void setRcvCity(String rcvCity) {
+		this.rcvCity = rcvCity;
+	}
+
+	public String getRcvTown() {
+		return rcvTown;
+	}
+
+	public void setRcvTown(String rcvTown) {
+		this.rcvTown = rcvTown;
+	}
+
+	public String getRcvAddress() {
+		return rcvAddress;
+	}
+
+	public void setRcvAddress(String rcvAddress) {
+		this.rcvAddress = rcvAddress;
+	}
+
+	public String getRcvZip() {
+		return rcvZip;
+	}
+
+	public void setRcvZip(String rcvZip) {
+		this.rcvZip = rcvZip;
+	}
+
+	public String getRcvFixTel() {
+		return rcvFixTel;
+	}
+
+	public void setRcvFixTel(String rcvFixTel) {
+		this.rcvFixTel = rcvFixTel;
+	}
+
+	public String getRcvMobileTel() {
+		return rcvMobileTel;
+	}
+
+	public void setRcvMobileTel(String rcvMobileTel) {
+		this.rcvMobileTel = rcvMobileTel;
+	}
+
+	public int getPayWay() {
+		return payWay;
+	}
+
+	public void setPayWay(int payWay) {
+		this.payWay = payWay;
+	}
+
+	public double getShouldReceivePayment() {
+		return shouldReceivePayment;
+	}
+
+	public void setShouldReceivePayment(double shouldReceivePayment) {
+		this.shouldReceivePayment = shouldReceivePayment;
+	}
+
+	public String getCustMessage() {
+		return custMessage;
+	}
+
+	public void setCustMessage(String custMessage) {
+		this.custMessage = custMessage;
+	}
+
+	public int getPackageNum() {
+		return packageNum;
+	}
+
+	public void setPackageNum(int packageNum) {
+		this.packageNum = packageNum;
+	}
+
+	public int getIsExpensive() {
+		return isExpensive;
+	}
+
+	public void setIsExpensive(int isExpensive) {
+		this.isExpensive = isExpensive;
+	}
+
+	public int getIsMultiPackage() {
+		return isMultiPackage;
+	}
+
+	public void setIsMultiPackage(int isMultiPackage) {
+		this.isMultiPackage = isMultiPackage;
+	}
+
+	public int getSelfServiceId() {
+		return selfServiceId;
+	}
+
+	public void setSelfServiceId(int selfServiceId) {
+		this.selfServiceId = selfServiceId;
+	}
+
+	@Override
+	public String toString() {
+		return "OrderDTO [orderId=" + orderId + ", rcvName=" + rcvName
+				+ ", rcvProvince=" + rcvProvince + ", rcvCity=" + rcvCity
+				+ ", rcvTown=" + rcvTown + ", rcvAddress=" + rcvAddress
+				+ ", rcvZip=" + rcvZip + ", rcvFixTel=" + rcvFixTel
+				+ ", rcvMobileTel=" + rcvMobileTel + ", payWay=" + payWay
+				+ ", shouldReceivePayment=" + shouldReceivePayment
+				+ ", custMessage=" + custMessage + ", packageNum=" + packageNum
+				+ ", isExpensive=" + isExpensive + ", isMultiPackage="
+				+ isMultiPackage + ", selfServiceId=" + selfServiceId + "]";
+	}
+}

+ 73 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderErrorDTO.java

@@ -0,0 +1,73 @@
+/**
+ * @FileName: OrderSubmitStatusDTO.java
+ * @Package cn.haliaeetus.api.dangdang.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-14 下午5:29:03
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * <p>当当订单提交错误DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrderErrorDTO {
+	@JSONField(name = "order_id")
+	@JsonProperty(value = "order_id")
+	private String orderId; // 订单ID
+	
+	/*
+	 * 错误码
+	 * 0:处理成功
+	 * 5:插入记录失败
+	 * 11:快递公司不能为空
+	 * 12:入库时间不能为空
+	 * 13:运单号不能为空
+	 * 301:运单号不存在
+	 * 302:运单存在差异
+	 * 303:总站入库运单状态错误
+	 * 304:自提点运单状态错误
+	 * 400:order_id推送次数超过10次,禁止插入
+	 */
+	@JSONField(name = "errorCode")
+	@JsonProperty(value = "errorCode")
+	private int errorCode;
+	
+	public OrderErrorDTO() {
+	}
+
+	public OrderErrorDTO(String orderId, int errorCode) {
+		this.orderId = orderId;
+		this.errorCode = errorCode;
+	}
+
+	public String getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(String orderId) {
+		this.orderId = orderId;
+	}
+
+	public int getErrorCode() {
+		return errorCode;
+	}
+
+	public void setErrorCode(int errorCode) {
+		this.errorCode = errorCode;
+	}
+
+	@Override
+	public String toString() {
+		return "OrderErrorDTO [orderId=" + orderId + ", errorCode=" + errorCode
+				+ "]";
+	}
+}

+ 63 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderErrorListDTO.java

@@ -0,0 +1,63 @@
+/**
+ * @FileName: OrderSubmitStatusDTO.java
+ * @Package cn.haliaeetus.api.dangdang.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-14 下午5:29:03
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+/**
+ * <p>当当订单提交错误DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrderErrorListDTO {
+	@JSONField(name = "error_list")
+	@JsonProperty(value = "error_list")
+	private List<OrderErrorDTO> errorList; // 订单错误列表
+	
+	/*
+	 * 错误码
+	 * 0:成功
+	 * 1:请求参数不能为空
+	 * 2:加密内容不能为空
+	 * 3:数字签名不能为空
+	 * 4:验签失败
+	 * 5:其他原因
+	 */
+	@JSONField(name = "errorCode")
+	@JsonProperty(value = "errorCode")
+	private int errorCode;
+
+	public List<OrderErrorDTO> getErrorList() {
+		return errorList;
+	}
+
+	public void setErrorList(List<OrderErrorDTO> errorList) {
+		this.errorList = errorList;
+	}
+
+	public int getErrorCode() {
+		return errorCode;
+	}
+
+	public void setErrorCode(int errorCode) {
+		this.errorCode = errorCode;
+	}
+
+	@Override
+	public String toString() {
+		return "OrderErrorListDTO [errorList=" + errorList + ", errorCode="
+				+ errorCode + "]";
+	}
+}

+ 120 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderStatusFeedbackDTO.java

@@ -0,0 +1,120 @@
+/**
+ * @FileName: OrderSubmitStatusDTO.java
+ * @Package cn.haliaeetus.api.dangdang.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-14 下午5:29:03
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+/**
+ * <p>门店订单状态反馈DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrderStatusFeedbackDTO {
+	@JSONField(name = "express_id")
+	private String expressId; // 快递公司ID,由当当分配
+	
+	@JSONField(name = "self_service_id")
+	private String selfServiceId; // 门店ID
+	
+	@JSONField(name = "order_id")
+	private String orderId; // 订单ID
+	
+	@JSONField(name = "sign_date")
+	private String signDate; // 签收时间
+	
+	@JSONField(name = "sign_person")
+	private String signPerson; // 签收人
+	
+	@JSONField(name = "order_status")
+	private String orderStatus; // 订单状态
+	
+	@JSONField(name = "reason_id")
+	private String reasonId; // 原因
+	
+	@JSONField(name = "remark")
+	private String remark; // 备注
+	
+	@JSONField(name = "operator")
+	private String operator; // 操作人
+
+	public String getExpressId() {
+		return expressId;
+	}
+
+	public void setExpressId(String expressId) {
+		this.expressId = expressId;
+	}
+
+	public String getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(String orderId) {
+		this.orderId = orderId;
+	}
+
+	public String getSelfServiceId() {
+		return selfServiceId;
+	}
+
+	public void setSelfServiceId(String selfServiceId) {
+		this.selfServiceId = selfServiceId;
+	}
+
+	public String getSignDate() {
+		return signDate;
+	}
+
+	public void setSignDate(String signDate) {
+		this.signDate = signDate;
+	}
+
+	public String getSignPerson() {
+		return signPerson;
+	}
+
+	public void setSignPerson(String signPerson) {
+		this.signPerson = signPerson;
+	}
+
+	public String getOrderStatus() {
+		return orderStatus;
+	}
+
+	public void setOrderStatus(String orderStatus) {
+		this.orderStatus = orderStatus;
+	}
+
+	public String getReasonId() {
+		return reasonId;
+	}
+
+	public void setReasonId(String reasonId) {
+		this.reasonId = reasonId;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public String getOperator() {
+		return operator;
+	}
+
+	public void setOperator(String operator) {
+		this.operator = operator;
+	}
+}

+ 76 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/OrderTraceLogFeekbackDTO.java

@@ -0,0 +1,76 @@
+/**
+ * @FileName: OrderSubmitStatusDTO.java
+ * @Package cn.haliaeetus.api.dangdang.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-14 下午5:29:03
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+/**
+ * <p>门店订单操作日志反馈DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class OrderTraceLogFeekbackDTO {
+	@JSONField(name = "express_id")
+	private String expressId; // 快递公司ID,由当当分配
+	
+	@JSONField(name = "order_id")
+	private String orderId; // 订单ID
+	
+	@JSONField(name = "trans_log")
+	private String transLog; // 日志内容
+	
+	@JSONField(name = "log_time")
+	private String logTime; // 日志时间
+	
+	@JSONField(name = "operator")
+	private String operator; // 操作人
+
+	public String getExpressId() {
+		return expressId;
+	}
+
+	public void setExpressId(String expressId) {
+		this.expressId = expressId;
+	}
+
+	public String getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(String orderId) {
+		this.orderId = orderId;
+	}
+
+	public String getTransLog() {
+		return transLog;
+	}
+
+	public void setTransLog(String transLog) {
+		this.transLog = transLog;
+	}
+
+	public String getLogTime() {
+		return logTime;
+	}
+
+	public void setLogTime(String logTime) {
+		this.logTime = logTime;
+	}
+
+	public String getOperator() {
+		return operator;
+	}
+
+	public void setOperator(String operator) {
+		this.operator = operator;
+	}
+}

+ 65 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/ZongZhanInStorageDTO.java

@@ -0,0 +1,65 @@
+/**
+ * @FileName: OrderSubmitStatusDTO.java
+ * @Package cn.haliaeetus.api.dangdang.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-14 下午5:29:03
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+/**
+ * <p>总站入库DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class ZongZhanInStorageDTO {
+	@JSONField(name = "express_id")
+	private String expressId; // 快递公司ID,由当当分配
+	
+	@JSONField(name = "order_id")
+	private String orderId; // 订单ID
+	
+	@JSONField(name = "in_storage_date")
+	private String inStorageDate; // 入库时间,格式:yyyy-MM-dd HH:mm:ss
+	
+	@JSONField(name = "operator")
+	private String operator; // 操作人
+
+	public String getExpressId() {
+		return expressId;
+	}
+
+	public void setExpressId(String expressId) {
+		this.expressId = expressId;
+	}
+
+	public String getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(String orderId) {
+		this.orderId = orderId;
+	}
+
+	public String getInStorageDate() {
+		return inStorageDate;
+	}
+
+	public void setInStorageDate(String inStorageDate) {
+		this.inStorageDate = inStorageDate;
+	}
+
+	public String getOperator() {
+		return operator;
+	}
+
+	public void setOperator(String operator) {
+		this.operator = operator;
+	}
+}

+ 65 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/dto/ZongZhanOutStorageDTO.java

@@ -0,0 +1,65 @@
+/**
+ * @FileName: OrderSubmitStatusDTO.java
+ * @Package cn.haliaeetus.api.dangdang.dto
+ * 
+ * @author Administrator
+ * @created 2014-4-14 下午5:29:03
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+/**
+ * <p>总站入库DTO</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class ZongZhanOutStorageDTO {
+	@JSONField(name = "express_id")
+	private String expressId; // 快递公司ID,由当当分配
+	
+	@JSONField(name = "order_id")
+	private String orderId; // 订单ID
+	
+	@JSONField(name = "out_storage_date")
+	private String outStorageDate; // 出库时间,格式:yyyy-MM-dd HH:mm:ss
+	
+	@JSONField(name = "operator")
+	private String operator; // 操作人
+
+	public String getExpressId() {
+		return expressId;
+	}
+
+	public void setExpressId(String expressId) {
+		this.expressId = expressId;
+	}
+
+	public String getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(String orderId) {
+		this.orderId = orderId;
+	}
+
+	public String getOutStorageDate() {
+		return outStorageDate;
+	}
+
+	public void setOutStorageDate(String outStorageDate) {
+		this.outStorageDate = outStorageDate;
+	}
+
+	public String getOperator() {
+		return operator;
+	}
+
+	public void setOperator(String operator) {
+		this.operator = operator;
+	}
+}

+ 239 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/invoker/DangdangAPIInvoker.java

@@ -0,0 +1,239 @@
+/**
+ * @author Administrator
+ * @created 2014-4-9 上午11:18:32
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.invoker;
+
+import org.springframework.stereotype.Component;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.util.APIUtil;
+import cn.haliaeetus.framework.util.DateUtil;
+
+import java.util.Date;
+
+/**
+ * <p>当当API调用器</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+@Component
+public class DangdangAPIInvoker {
+	// ------订单状态------
+	/**
+	 * 配送成功
+	 */
+	public static final String ORDER_STATUS_DISPATCH_SUCCESS = "101";
+	/**
+	 * 配送在途
+	 */
+	public static final String ORDER_STATUS_DISPATCHING = "102";
+	/**
+	 * 配送失败
+	 */
+	public static final String ORDER_STATUS_DISPATCH_FAIL = "103";
+	
+	// ------配送失败原因------
+	/**
+	 * 订单丢失
+	 */
+	public static final String REASON_OF_FAIL_ORDER_LOST = "101";
+	/**
+	 * 订单破损
+	 */
+	public static final String REASON_OF_FAIL_ORDER_BROKEN = "102";
+	/**
+	 * 客户拒收
+	 */
+	public static final String REASON_OF_FAIL_ORDER_REFUSE_RECEIVE = "103";
+	/**
+	 * 安排退货
+	 */
+	public static final String REASON_OF_FAIL_ORDER_RETURN = "104";
+	/**
+	 * 超出配送范围
+	 */
+	public static final String REASON_OF_FAIL_ORDER_OUT_OF_DISPATCH_RANGE = "105";
+	/**
+	 * 当当要求退货
+	 */
+	public static final String REASON_OF_FAIL_ORDER_RETURNED_BY_DD = "106";
+	/**
+	 * 查无此人
+	 */
+	public static final String REASON_OF_FAIL_ORDER_RECEIVER_UNKNOWN = "107";
+	/**
+	 * 地址不详/错误
+	 */
+	public static final String REASON_OF_FAIL_ORDER_ADDRESS_UNKNOWN = "108";
+	/**
+	 * 联系不上
+	 */
+	public static final String REASON_OF_FAIL_ORDER_RECEIVER_CAN_NOT_CONTACT = "109";
+	/**
+	 * 其他失败原因
+	 */
+	public static final String REASON_OF_FAIL_OTHER = "199";
+	
+	// ------配送在途原因------
+	/**
+	 * 联系不上
+	 */
+	public static final String REASON_OF_AFLOAT_ORDER_RECEIVER_CAN_NOT_CONTACT = "201";
+	/**
+	 * 客户推迟收货
+	 */
+	public static final String REASON_OF_AFLOAT_ORDER_DELAY_RECEIVE = "202";
+	/**
+	 * 订单滞留
+	 */
+	public static final String REASON_OF_AFLOAT_ORDER_RETENTION = "203";
+	/**
+	 * 客户改地址
+	 */
+	public static final String REASON_OF_AFLOAT_ORDER_ADDRESS_CHANGE = "204";
+	/**
+	 * 不可抗力延缓送达
+	 */
+	public static final String REASON_OF_AFLOAT_ORDER_DELAY_HAS_NO_CHOICE = "205";
+	/**
+	 * 中转延误
+	 */
+	public static final String REASON_OF_AFLOAT_ORDER_TRANSFER_DELAY = "206";
+	/**
+	 * 分拣错误
+	 */
+	public static final String REASON_OF_AFLOAT_ORDER_PICK_WRONG = "207";
+	/**
+	 * 电话地址错误
+	 */
+	public static final String REASON_OF_AFLOAT_ORDER_PHONE_OR_ADDRESS_UNKNOWN = "208";
+	/**
+	 * 其他原因
+	 */
+	public static final String REASON_OF_AFLOAT_ORDER_OTHER = "209";
+	
+	
+	/**
+	 * 模拟总站入库
+	 */
+	public static String prepareInStorage(String orderCode, String storehouseCode, Date time) {
+		StringBuilder data = new StringBuilder();
+		String timeStr = DateUtil.timestampFormat(time);
+		String requestTime = String.valueOf(time.getTime() / 1000);
+		data.append("request_time").append("=").append(requestTime).append("&");
+		data.append("token").append("=").append(APIUtil.generateTokenOfDangdang(requestTime, storehouseCode)).append("&");
+		data.append("data").append("=").append("[{");
+		data.append("\"order_id\"").append(":\"").append(orderCode).append("\",");
+		data.append("\"express_id\"").append(":\"").append(storehouseCode).append("\",");
+		data.append("\"in_storage_date\"").append(":\"").append(timeStr).append("\",");
+		data.append("\"operator\"").append(":\"").append("共配操作系统").append("\"");
+		data.append("}]");
+		return data.toString();
+	}
+	
+	/**
+	 * 模拟总站出库
+	 */
+	public static String prepareOutStorage(String orderCode, String storehouseCode, Date time) {
+		StringBuilder data = new StringBuilder();
+		String timeStr = DateUtil.timestampFormat(time);
+		String requestTime = String.valueOf(time.getTime() / 1000);
+		data.append("request_time").append("=").append(requestTime).append("&");
+		data.append("token").append("=").append(APIUtil.generateTokenOfDangdang(requestTime, storehouseCode)).append("&");
+		data.append("data").append("=").append("[{");
+		data.append("\"order_id\"").append(":\"").append(orderCode).append("\",");
+		data.append("\"express_id\"").append(":\"").append(storehouseCode).append("\",");
+		data.append("\"out_storage_date\"").append(":\"").append(timeStr).append("\",");
+		data.append("\"operator\"").append(":\"").append("共配操作系统").append("\"");
+		data.append("}]");
+		return data.toString();
+	}
+	
+	/**
+	 * 门店入库数据准备
+	 * @param orderCode 订单单号
+	 * @param storeId 门店ID
+	 */
+	public static String prepareStoreInStorage(String orderCode, int storeId, String storehouseCode, Date time) {
+		StringBuilder data = new StringBuilder();
+		String timeStr = DateUtil.timestampFormat(time);
+		String requestTime = String.valueOf(time.getTime() / 1000);
+		data.append("request_time").append("=").append(requestTime).append("&");
+		data.append("token").append("=").append(APIUtil.generateTokenOfDangdang(requestTime, storehouseCode)).append("&");
+		data.append("data").append("=").append("[{");
+		data.append("\"express_id\"").append(":\"").append(storehouseCode).append("\",");
+		data.append("\"in_storage_date\"").append(":\"").append(timeStr).append("\",");
+		data.append("\"operator\"").append(":\"").append("共配操作系统").append("\",");
+		data.append("\"order_id\"").append(":\"").append(orderCode).append("\",");
+		data.append("\"self_service_id\"").append(":\"").append(storeId).append("\"");
+		data.append("}]");
+		return data.toString();
+	}
+	
+	/**
+	 * 门店订单状态反馈数据准备
+	 */
+	public static String prepareOrderStatusFeedback(String orderCode, int storeId, String orderStatus, String reason, 
+			String operator, String remark, String storehouseCode, Date time) {
+		StringBuilder data = new StringBuilder();
+		String timeStr = DateUtil.timestampFormat(time);
+		String requestTime = String.valueOf(time.getTime() / 1000);
+		data.append("request_time").append("=").append(requestTime).append("&");
+		data.append("token").append("=").append(APIUtil.generateTokenOfDangdang(requestTime, storehouseCode)).append("&");
+		data.append("data").append("=").append("[{");
+		data.append("\"express_id\"").append(":\"").append(storehouseCode).append("\",");
+		data.append("\"operator\"").append(":\"").append(operator).append("\",");
+		data.append("\"order_id\"").append(":\"").append(orderCode).append("\",");
+		data.append("\"order_status\"").append(":\"").append(orderStatus).append("\",");
+		data.append("\"reason_id\"").append(":\"").append(reason).append("\",");
+		data.append("\"remark\"").append(":\"").append(remark).append("\",");
+		data.append("\"self_service_id\"").append(":\"").append(storeId).append("\",");
+		data.append("\"sign_date\"").append(":\"").append(timeStr).append("\",");
+		data.append("\"sign_person\"").append(":\"").append("本人签收").append("\"");
+		data.append("}]");
+		return data.toString();
+	}
+	
+	/**
+	 * 门店订单操作跟踪日志反馈数据准备
+	 * @param orderCode 订单单号
+	 * @param orderStatus 订单状态
+	 * @param logTime 日志记录时间
+	 * @param operator 操作人员
+	 */
+	public static String prepareOrderTraceLogFeekback(String orderCode, int orderStatus, String operator, String storehouseCode, String logTime) {
+		StringBuilder data = new StringBuilder();
+		String requestTime = String.valueOf(DateUtil.formatTimestampToLong(logTime) / 1000);
+		data.append("request_time").append("=").append(requestTime).append("&");
+		data.append("token").append("=").append(APIUtil.generateTokenOfDangdang(requestTime, storehouseCode)).append("&");
+		data.append("data").append("=").append("[{");
+		data.append("\"express_id\"").append(":\"").append(storehouseCode).append("\",");
+		data.append("\"order_id\"").append(":\"").append(orderCode).append("\",");
+		data.append("\"operator\"").append(":\"").append(operator).append("\",");
+		data.append("\"log_time\"").append(":\"").append(logTime).append("\",");
+		
+		// 日志内容
+		data.append("\"trans_log\"").append(":\"");
+		switch (orderStatus) {
+		case Constants.ORDER_STATUS_STORED:
+			data.append("订单已到达,已入库");
+			break;
+		case Constants.ORDER_STATUS_COMPLETE:
+			data.append("订单已配送成功,客户已签收");
+			break;
+		case Constants.ORDER_STATUS_REJECT_PICK_UP:
+			data.append("订单配送失败(失败原因:其他)");
+			break;
+		default:
+			data.append("");
+		}
+		data.append("\"");
+		data.append("}]");
+		return data.toString();
+	}
+}

+ 60 - 0
express-main/src/main/java/cn/haliaeetus/controller/dangdang/response/SubmitOrdersJsonResponse.java

@@ -0,0 +1,60 @@
+/**
+ * @FileName: SubmitOrdersJsonResponse.java
+ * @Package cn.haliaeetus.api.dangdang.response
+ * 
+ * @author Administrator
+ * @created 2014-4-14 下午5:23:26
+ * 
+ * Copyright 2013-2050 佰颂物联 版权所有
+ */
+package cn.haliaeetus.controller.dangdang.response;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import cn.haliaeetus.controller.dangdang.dto.OrderErrorDTO;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>当当订单提交接口,JSON响应实体</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+public class SubmitOrdersJsonResponse {
+	@JsonProperty(value = "error_code")
+	private int errorCode; // 错误码
+	
+	@JsonProperty(value = "error_list")
+	private List<OrderErrorDTO> errorList = new ArrayList<OrderErrorDTO>(); // 订单提交状态列表
+	
+	public SubmitOrdersJsonResponse() {
+	}
+	
+	public SubmitOrdersJsonResponse(int errorCode) {
+		this.errorCode = errorCode;
+	}
+
+	public SubmitOrdersJsonResponse(int errorCode, List<OrderErrorDTO> errorList) {
+		this.errorCode = errorCode;
+		this.errorList = errorList;
+	}
+
+	public int getErrorCode() {
+		return errorCode;
+	}
+
+	public void setErrorCode(int errorCode) {
+		this.errorCode = errorCode;
+	}
+
+	public List<OrderErrorDTO> getErrorList() {
+		return errorList;
+	}
+
+	public void setErrorList(List<OrderErrorDTO> errorList) {
+		this.errorList = errorList;
+	}
+}

File diff suppressed because it is too large
+ 353 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/AppLoginController.java


+ 210 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/AppRechargeController.java

@@ -0,0 +1,210 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import cn.haliaeetus.constants.AlipayConfig;
+import cn.haliaeetus.entity.SmsPurchaseRecord;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.service.PaymentLogService;
+import cn.haliaeetus.service.SmsRecordService;
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.AlipayClient;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.domain.AlipayTradeAppPayModel;
+import com.alipay.api.request.AlipayTradeAppPayRequest;
+import com.alipay.api.response.AlipayTradeAppPayResponse;
+import com.google.gson.JsonObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.UUID;
+
+import static cn.haliaeetus.controller.graduation.alipay.config.AlipayConfig.FORMAT;
+import static cn.haliaeetus.util.AlipayConfig.gatewayUrl;
+import static cn.haliaeetus.util.AlipayConfig.sign_type;
+
+@Controller
+@RequestMapping("/device/recharge")
+public class AppRechargeController extends BaseController {
+
+	@Autowired
+	private PaymentLogService paymentLogService;
+
+	@Autowired
+	private SmsRecordService smsRecordService;
+
+	/**
+	 * 充值订单生成
+	 */
+	@RequestMapping(value = "", method = { RequestMethod.POST})
+	@ResponseBody
+	public Object recharge(HttpServletRequest request, HttpServletResponse response) {
+
+		User user = getUserFromParam(request);
+
+		if (user == null) {
+			return buildJson(1, "用户未登录");
+		}
+
+
+		int channel = _.toInt(request.getParameter("channel"));
+		String amount = request.getParameter("amount");
+		if (channel == -1) return buildJson(-1, "请选择支付方式");
+		if (_.isEmpty(amount)) return buildJson(-1, "请选择或填写充值金额");
+
+		// 生成订单号并保存支付订单日志
+		Date now = new Date();
+		String outTradeNo = getOutTradeNo(user.getStoreId() + "", now.getTime());
+		int result = paymentLogService.savePaymentLog(channel, amount, user, outTradeNo, now);
+		if (result != 1) return buildJson(-1, "订单提交失败,请稍后重试");
+
+		//保存SmsPurchaseRecord
+		SmsPurchaseRecord record=new SmsPurchaseRecord();
+		record.setRecordId(get32UUID());
+		record.setAmount(BigDecimal.valueOf(Double.valueOf(amount)));
+		record.setOperator(user.getUserId());
+		record.setOptTime(new Date());
+		record.setOutTradeNo(outTradeNo);
+		record.setPayStatus(0);//待支付
+		record.setPayWay(1);//支付宝
+		record.setSmsNumber(1);
+		record.setTradeNo("");
+		record.setId(1);
+		record.setStoreId(user.getStoreId());
+		smsRecordService.savePurchaseRecord(record);
+
+	/*// 构造支付参数
+		JsonObject obj = new JsonObject();
+		obj.addProperty("code", 0);
+		obj.addProperty("outTradeNo", outTradeNo);
+		String payParam = AlipayHelper.getAlipayParam(outTradeNo, amount, Constants.PAY_PARAM_SUBJECT, user.getUserId());
+		obj.addProperty("data", payParam);
+		return obj.toString();*/
+
+		//实例化客户端
+		AlipayClient alipayClient = new DefaultAlipayClient(gatewayUrl, AlipayConfig.getAlipayAppID(), AlipayConfig.getAlipayPrivateKey(), FORMAT, AlipayConfig.getAlipayCharset(), AlipayConfig.getAlipayPublicKey(), sign_type);
+		//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
+		AlipayTradeAppPayRequest appPayRequest = new AlipayTradeAppPayRequest();
+		//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
+		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+		model.setBody(user.getUserId());
+		model.setSubject(AlipayConfig.getAlipaySubject());
+		model.setOutTradeNo(outTradeNo);
+		model.setTimeoutExpress(AlipayConfig.getAlipayTimeoutExpress());
+		model.setTotalAmount(amount);
+		model.setProductCode(AlipayConfig.getAlipayProductCode());
+		appPayRequest.setBizModel(model);
+		appPayRequest.setNotifyUrl(AlipayConfig.getAlipayNotifyurl());
+		AlipayTradeAppPayResponse appPayResponse = null ;
+		try {
+			//这里和普通的接口调用不同,使用的是sdkExecute
+			appPayResponse = alipayClient.sdkExecute(appPayRequest);
+		} catch (AlipayApiException e) {
+			e.printStackTrace();
+		}
+		JsonObject obj = new JsonObject();
+		obj.addProperty("code", 0);
+		obj.addProperty("outTradeNo", outTradeNo);
+		obj.addProperty("data", appPayResponse.getBody());
+		return obj.toString();
+	}
+
+	/**
+	 * 充值订单生成
+	 */
+	@RequestMapping(value = "/toAlipay", method = { RequestMethod.POST})
+	@ResponseBody
+	public Object appRecharge(HttpServletRequest request, HttpServletResponse response) {
+
+		User user = getUserFromParam(request);
+		if (user == null) {
+			return buildJson(1, "用户未登录");
+		}
+
+		int channel = _.toInt(request.getParameter("channel"));
+		String amount = request.getParameter("amount");
+		if (channel == -1) return buildJson(-1, "请选择支付方式");
+		if (_.isEmpty(amount)) return buildJson(-1, "请选择或填写充值金额");
+
+		// 生成订单号并保存支付订单日志
+		Date now = new Date();
+		String outTradeNo = getOutTradeNo(user.getStoreId() + "", now.getTime());
+		int result = paymentLogService.savePaymentLog(channel, amount, user, outTradeNo, now);
+		if (result != 1) return buildJson(-1, "订单提交失败,请稍后重试");
+
+		//保存SmsPurchaseRecord
+		SmsPurchaseRecord record=new SmsPurchaseRecord();
+		record.setRecordId(get32UUID());
+		record.setAmount(BigDecimal.valueOf(Double.valueOf(amount)));
+		record.setOperator(user.getUserId());
+		record.setOptTime(new Date());
+		record.setOutTradeNo(outTradeNo);
+		record.setPayStatus(0);//待支付
+		record.setPayWay(1);//支付宝
+		record.setSmsNumber(1);
+		record.setTradeNo("");
+		record.setId(1);
+		record.setStoreId(user.getStoreId());
+		smsRecordService.savePurchaseRecord(record);
+
+		//实例化客户端
+		AlipayClient alipayClient = new DefaultAlipayClient(gatewayUrl, AlipayConfig.getAlipayAppID(), AlipayConfig.getAlipayPrivateKey(), FORMAT, AlipayConfig.getAlipayCharset(), AlipayConfig.getAlipayPublicKey(), sign_type);
+		//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
+		AlipayTradeAppPayRequest appPayRequest = new AlipayTradeAppPayRequest();
+	//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
+		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+		model.setBody(user.getUserId());
+		model.setSubject(AlipayConfig.getAlipaySubject());
+		model.setOutTradeNo(outTradeNo);
+		model.setTimeoutExpress(AlipayConfig.getAlipayTimeoutExpress());
+		model.setTotalAmount(amount);
+		model.setProductCode(AlipayConfig.getAlipayProductCode());
+		appPayRequest.setBizModel(model);
+		appPayRequest.setNotifyUrl(AlipayConfig.getAlipayNotifyurl());
+		AlipayTradeAppPayResponse appPayResponse = null ;
+		try {
+			//这里和普通的接口调用不同,使用的是sdkExecute
+			appPayResponse = alipayClient.sdkExecute(appPayRequest);
+		} catch (AlipayApiException e) {
+			e.printStackTrace();
+		}
+		JsonObject obj = new JsonObject();
+		obj.addProperty("code", 0);
+		obj.addProperty("outTradeNo", outTradeNo);
+		obj.addProperty("data", appPayResponse.getBody());
+		return obj.toString();
+
+	}
+
+	/**
+	 * 根据时间和用户ID生成订单号
+	 * @param storeId
+	 * @param time
+	 * @return
+	 */
+	private String getOutTradeNo(String storeId, long time) {
+		String tradeTime = DateUtil.format(time, "yyyyMMddHHmmssSSS");
+		int len = storeId.length();
+		if (len < 6) {
+			for (int i = 0; i < 6 - len; i++) {
+				storeId = "0" + storeId;
+			}
+		}
+		return tradeTime.substring(0, 14) + storeId + tradeTime.substring(14);
+	}
+
+
+	public static String get32UUID() {
+		String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
+		return uuid;
+	}
+
+}

+ 78 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/AppUpdateController.java

@@ -0,0 +1,78 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.entity.AppUpdate;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.AppUpdateService;
+
+/**
+ * 取货平板接口
+ */
+@Controller
+public class AppUpdateController extends BaseController {
+
+    private static final Logger log = LoggerFactory.getLogger(AppUpdateController.class);
+
+    @Autowired
+    private AppUpdateService appUpdateService;
+
+    @RequestMapping("/device/appUpdate")
+    @ResponseBody
+    public Object appUpdate(HttpServletRequest request, HttpServletResponse response) throws SQLException {
+        log.info("AppUpdateController.appUpdate.start");
+        long now = System.currentTimeMillis();
+        User user = getUserFromParam(request);
+        // final User user=User.getById("xm00001");
+//        if (user == null) {
+//            user = getFromCookie(request);
+//            // return buildJson(1, "用户未登录");
+//            if (user == null) {
+//                log.info("TakePadController.takeDelivery.nologin");
+//                log.info("bs2.balance.deviceTakeDelivery.time:" + (int) (System.currentTimeMillis() - now));
+//                return buildJson(1, "用户未登录");
+//            }
+//        }
+        
+        String type = request.getParameter("app_type");
+        if(_.isEmpty(type)){
+        	return buildJson(-1, "type为空");
+        }
+
+        Map<String,String> paramMap = new HashMap<String,String>();
+        paramMap.put("appType", type);
+        AppUpdate appUpdate = appUpdateService.getAppUpdate(paramMap);
+        if (appUpdate == null) {
+            log.info("bs2.AppUpdateController.appUpdate.time:" + (int) (System.currentTimeMillis() - now));
+            return buildJson(-2, "没有升级包");
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("app_type", appUpdate.getAppType());
+        object.addProperty("version_code", appUpdate.getVersionCode());
+        object.addProperty("version_name", appUpdate.getVersionName());
+        object.addProperty("upd_conent", appUpdate.getUpdateContent());
+        object.addProperty("is_must", appUpdate.getIsMust());
+        object.addProperty("url", appUpdate.getUrl());
+        log.info("bs2.AppUpdateController.appUpdate.time:" + (int) (System.currentTimeMillis() - now));
+//        log.info("bs2.AppUpdateController.appUpdate.storeid:" + user.getStoreId());
+        return object.toString();
+    }
+
+}

+ 229 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/AppWeiXinController.java

@@ -0,0 +1,229 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import cn.haliaeetus.entity.SmsPurchaseRecord;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.service.PaymentLogService;
+import cn.haliaeetus.service.SmsRecordService;
+import cn.haliaeetus.util.BaishiUtil;
+import cn.haliaeetus.util.MD5Util;
+import cn.haliaeetus.util.WeiXinPayConfig;
+import cn.haliaeetus.util.XMLUtil4jdom;
+import com.google.gson.JsonObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.security.MessageDigest;
+import java.util.*;
+
+@Controller
+@RequestMapping("/device")
+public class AppWeiXinController extends BaseController {
+	
+	@Autowired
+	private PaymentLogService paymentLogService;
+
+	@Autowired
+	private SmsRecordService smsRecordService;
+
+	/**
+	 * 充值订单生成
+	 */
+	@RequestMapping(value = "weiXinPay", method = { RequestMethod.POST})
+	@ResponseBody
+	public Object recharge(HttpServletRequest request, HttpServletResponse response)throws Exception {
+		
+		User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+		
+		int channel = _.toInt(request.getParameter("channel"));
+		String amount = request.getParameter("amount");
+		if (channel == -1) return buildJson(-1, "请选择支付方式");
+		if (_.isEmpty(amount)) return buildJson(-1, "请选择或填写充值金额");
+        long currentTimeMillis = System.currentTimeMillis();//生成时间戳
+        long second = currentTimeMillis / 1000L;//(转换成秒)
+        String timeStamp = String.valueOf(second).substring(0, 10); //截取前10位
+		BigDecimal bAmount = BigDecimal.valueOf(Double.valueOf(amount));
+		BigDecimal bigd = new BigDecimal("100");
+		int requestAmout = bAmount.multiply(bigd).intValue();
+		// 生成订单号并保存支付订单日志
+		Date now = new Date();
+		String outTradeNo = getOutTradeNo(user.getStoreId() + "", now.getTime());
+		String nonce_str= get32UUID();
+        SortedMap<Object, Object> parameters = new TreeMap<Object, Object>();
+        parameters.put("appid", WeiXinPayConfig.getWeiXinAppid());
+        parameters.put("body", WeiXinPayConfig.getWeiXinBody());
+        parameters.put("mch_id", WeiXinPayConfig.getWeiXinPartnerid());
+        parameters.put("nonce_str", nonce_str);
+
+        parameters.put("notify_url", WeiXinPayConfig.getWeiXinNotifyurl());
+        parameters.put("out_trade_no", outTradeNo);
+        parameters.put("total_fee", String.valueOf(requestAmout));
+        parameters.put("trade_type", "APP");
+		String requestStr=getRequestXml(parameters);
+        String prePayXml = new String(requestStr.getBytes("UTF-8"), "ISO-8859-1");
+        String result = BaishiUtil.postJson("https://api.mch.weixin.qq.com/pay/unifiedorder", prePayXml);
+		Map map = XMLUtil4jdom.doXMLParse(result);
+
+
+		//保存SmsPurchaseRecord
+		SmsPurchaseRecord record=new SmsPurchaseRecord();
+		record.setRecordId(get32UUID());
+		record.setAmount(bAmount);
+		record.setOperator(user.getUserId());
+		record.setOptTime(new Date());
+		record.setOutTradeNo(outTradeNo);
+		record.setPayStatus(0);//待支付
+		record.setPayWay(2);//
+		record.setSmsNumber(1);
+		record.setTradeNo("");
+		record.setId(1);
+		record.setStoreId(user.getStoreId());
+		smsRecordService.savePurchaseRecord(record);
+
+		// 构造支付参数
+		JsonObject obj = new JsonObject();
+		obj.addProperty("code", 0);
+		obj.addProperty("outTradeNo", outTradeNo);
+		JsonObject jsonObject = new JsonObject();
+        String returnsign = createSign("UTF-8",parameters);
+		jsonObject.addProperty("sign",returnsign);
+        //jsonObject.addProperty("sign",(String)map.get("sign"));
+		jsonObject.addProperty("timestamp",timeStamp);
+		jsonObject.addProperty("partnerid",WeiXinPayConfig.getWeiXinPartnerid());
+
+        jsonObject.addProperty("nonceStr",nonce_str);
+        jsonObject.addProperty("partnerid",WeiXinPayConfig.getWeiXinPartnerid());
+		/*Map dataMap=new HashMap();
+		dataMap.put("sign",map.get("sign"));
+		dataMap.put("timestamp",System.currentTimeMillis());
+		dataMap.put("partnerid","1503433081");//固定值类似appID
+		dataMap.put("nonceStr",map.get("nonce_str"));*/
+		if(map.get("prepay_id")!=null){
+            jsonObject.addProperty("prepay_id",(String)map.get("prepay_id"));
+		}else{
+            jsonObject.addProperty("prepayId",(String)map.get("sign=WXPay"));
+		}
+
+		//JSONObject json = JSONObject.fromObject(dataMap);
+		obj.add("data", jsonObject);
+        SortedMap tmpMap=new TreeMap();
+        tmpMap.put("appid", WeiXinPayConfig.getWeiXinAppid());
+        tmpMap.put("partnerid",WeiXinPayConfig.getWeiXinPartnerid());
+        tmpMap.put("prepayid",(String)map.get("prepay_id"));
+        tmpMap.put("noncestr",nonce_str);
+        tmpMap.put("timestamp",timeStamp);
+        tmpMap.put("package","Sign=WXPay");
+        String newSign=createSign("UTF-8",tmpMap);
+		obj.addProperty("newSign",newSign);
+		//obj.add("data",json);
+
+		return obj.toString();
+	}
+	
+	/**
+	 * 根据时间和用户ID生成订单号
+	 * @param storeId
+	 * @param time
+	 * @return
+	 */
+	private String getOutTradeNo(String storeId, long time) {
+		String tradeTime = DateUtil.format(time, "yyyyMMddHHmmssSSS");
+		int len = storeId.length();
+		if (len < 6) {
+			for (int i = 0; i < 6 - len; i++) {
+				storeId = "0" + storeId;
+			}
+		}
+		return tradeTime.substring(0, 14) + storeId + tradeTime.substring(14);
+	}
+
+
+	public static String get32UUID() {
+		String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
+		return uuid;
+	}
+
+
+
+	public static String getRequestXml(SortedMap<Object, Object> parameters) {
+
+		//String signed = createSign("UTF-8", parameters);createSign1
+        String signed = createSign("UTF-8",parameters);
+		//参数xml化
+		parameters.put("sign", signed);
+
+
+		StringBuffer sb = new StringBuffer();
+		sb.append("<xml>");
+		Set es = parameters.entrySet();
+		Iterator it = es.iterator();
+		while (it.hasNext()) {
+			Map.Entry entry = (Map.Entry) it.next();
+			String key = (String) entry.getKey();
+			String value = (String) entry.getValue();
+			/*if ("attach".equalsIgnoreCase(key) || "body".equalsIgnoreCase(key) || "sign".equalsIgnoreCase(key)) {
+				sb.append("<" + key + ">" + "<![CDATA[" + value + "]]></" + key + ">");
+			} else {
+				sb.append("<" + key + ">" + value + "</" + key + ">");
+			}*/
+			sb.append("<" + key + ">" + value + "</" + key + ">");
+		}
+		sb.append("</xml>");
+		return sb.toString();
+	}
+
+    //定义签名,微信根据参数字段的ASCII码值进行排序 加密签名,故使用SortMap进行参数排序
+    public static String createSign(String characterEncoding,SortedMap<Object,Object> parameters){
+        StringBuffer sb = new StringBuffer();
+        Set es = parameters.entrySet();
+        Iterator it = es.iterator();
+        while(it.hasNext()) {
+            Map.Entry entry = (Map.Entry)it.next();
+            String k = (String)entry.getKey();
+            Object v = entry.getValue();
+            if(null != v && !"".equals(v)
+                    && !"sign".equals(k) && !"key".equals(k)) {
+                sb.append(k + "=" + v + "&");
+            }
+        }
+        String Key = WeiXinPayConfig.getWeiXinKey();
+        sb.append("key=" + Key);//最后加密时添加商户密钥,由于key值放在最后,所以不用添加到SortMap里面去,单独处理,编码方式采用UTF-8
+        String sign = MD5Util.MD5Encode(sb.toString(), characterEncoding).toUpperCase();
+        //String sign = getMessageDigest(sb.toString().getBytes()).toUpperCase();
+        return sign;
+    }
+
+    /**
+     * MD5加密算法
+     */
+    public final static String getMessageDigest(byte[] buffer) {
+        char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+        try {
+            MessageDigest mdTemp = MessageDigest.getInstance("MD5");
+            mdTemp.update(buffer);
+            byte[] md = mdTemp.digest();
+            int j = md.length;
+            char str[] = new char[j * 2];
+            int k = 0;
+            for (int i = 0; i < j; i++) {
+                byte byte0 = md[i];
+                str[k++] = hexDigits[byte0 >>> 4 & 0xf];
+                str[k++] = hexDigits[byte0 & 0xf];
+            }
+            return new String(str);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+}

+ 307 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/ArrivalController.java

@@ -0,0 +1,307 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.http.entity.StringEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.util.APIConfig;
+import cn.haliaeetus.entity.ArrivalSignature;
+import cn.haliaeetus.entity.DeliveryNoArrive;
+import cn.haliaeetus.entity.DeliveryScanBatch;
+import cn.haliaeetus.entity.DeliveryStatus;
+import cn.haliaeetus.entity.StoreStaff;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.base.digt.Base64;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.framework.util.HttpUtil;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.framework.util.StringUtil;
+import cn.haliaeetus.service.DeliveryNoArriveService;
+import cn.haliaeetus.service.DeliveryScanBatchService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.DeliveryStatusService;
+import cn.haliaeetus.service.StoreStaffService;
+
+
+@Controller
+public class ArrivalController extends BaseController {
+    private static final Logger log = LoggerFactory.getLogger(ArrivalController.class);
+    @Autowired
+    private DeliveryService deliveryService;
+    @Autowired
+    private DeliveryStatusService deliveryStatusService;
+    @Autowired
+    private StoreStaffService storeStaffService;
+    @Autowired
+    private DeliveryScanBatchService scanBatchService;
+    @Autowired
+    private DeliveryNoArriveService noArriveService;
+
+    /**
+     * 添加状态流转记录
+     *
+     * @param user
+     * @param staff
+     * @param status
+     * @throws java.sql.SQLException
+     */
+    private void addDeliverStatus(User user, StoreStaff staff, int deliveryId, int status, int preStatus) {
+        DeliveryStatus deliveryStatus = new DeliveryStatus();
+        deliveryStatus.setDeliveryId(deliveryId);
+        deliveryStatus.setProcessStaff(staff.getName());
+        deliveryStatus.setReasonCode("0");
+        deliveryStatus.setRemark("");
+        deliveryStatus.setSource(Constants.CLIENT_TYPE_STORE_LITE_2);
+        deliveryStatus.setStatus(status);
+        deliveryStatus.setPreStatus(preStatus);
+        deliveryStatus.setUpdateTime(new Date());
+
+        deliveryStatusService.insert(user.getStoreId(), deliveryStatus);
+    }
+
+    /**
+     * 下车扫描接口
+     */
+    @RequestMapping("/device/arrival")
+    @ResponseBody
+    public Object arrivalDelivery(HttpServletRequest request, HttpServletResponse response) throws IOException,
+            ParseException {
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(request.getParameter("data"));
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        while (it.hasNext()) {
+            JsonNode expInfo = it.next();
+
+            int expId = expInfo.findValue("expId").asInt();
+            String expCode = expInfo.findValue("expCode").asText();
+            int staffId = expInfo.findValue("staffId").asInt();
+            int batchNumber = expInfo.findValue("batchNumber").asInt();
+            log.debug("expId=" + expId + ",expCode=" + expCode + ",staffId=" + staffId + ",batchNumber=" + batchNumber);
+
+            if (expId == 0 || _.isEmpty(expCode)) {
+                continue;
+            }
+
+            StoreStaff staff = storeStaffService.getById(staffId);
+            if (staff == null) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "派送员不存在");
+                array.add(dataObj);
+                continue;
+            }
+
+            //检查是否已经做过下车扫描
+            String beginTime = DateUtil.today().toString("yyyy-MM-dd");
+            String endTime = DateUtil.addDay(beginTime, "yyyy-MM-dd", 1);
+            DeliveryScanBatch batchDelivery = scanBatchService.getByTuple(user.getStoreId(), expCode, expId, DateUtil
+                    .formatDateToLong(beginTime), DateUtil.formatDateToLong(endTime));
+            if (batchDelivery != null) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "已下车扫描");
+                array.add(dataObj);
+                continue;
+            }
+
+            //顺丰和当当的订单, 尝试从未到货表自动完善
+            String userPhone = "";
+            String userName = "";
+            int chargeMoney = 0;
+            DeliveryNoArrive noArrive = noArriveService.getByTuple(expId, expCode);
+            if (noArrive != null) {
+                userPhone = noArrive.getUserphone();
+                userName = noArrive.getUsername();
+                chargeMoney = noArrive.getChargemoney();
+            }
+
+            //插入下车扫描记录
+            DeliveryScanBatch scanBatch = new DeliveryScanBatch();
+            scanBatch.setExpCode(expCode);
+            scanBatch.setRevexpCode(StringUtil.stringReverse(expCode));
+            scanBatch.setExpId(expId);
+            scanBatch.setBatchNumber(batchNumber);
+            scanBatch.setStoreId(user.getStoreId());
+            scanBatch.setOperatorId(staffId);
+            scanBatch.setCreateTime(new Date());
+            scanBatch.setUserName(userName);
+            scanBatch.setUserPhone(userPhone);
+            scanBatch.setRevuserPhone(StringUtil.stringReverse(userPhone));
+            scanBatch.setChargeMoney(chargeMoney);
+            scanBatchService.insert(scanBatch);
+            log.debug("生成待入库订单成功");
+
+            //删除未到货记录, 下车扫描不删除未到货记录
+            //noArriveService.deleteByTuple(user.getStoreId(), expId, expCode);
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.add("expInfo", array);
+
+        return object.toString();
+    }
+
+    @RequestMapping("/device/maxBatchNumber")
+    @ResponseBody
+    public Object getManBatchNumber(HttpServletRequest request, HttpServletResponse response) {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        long maxBatchNumber = scanBatchService.getMaxBatchNumber(user.getStoreId(), System.currentTimeMillis());
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.addProperty("maxBatchNumber", maxBatchNumber == -1 ? 0 : maxBatchNumber);
+
+        return object.toString();
+    }
+    
+    @RequestMapping("/device/uploadSignature")
+    @ResponseBody
+    public Object uploadSignature(HttpServletRequest request, HttpServletResponse response
+    		,@RequestParam MultipartFile file) {
+    	log.info("uploadSignature.RequestURI=[{}] params=[{}]", request.getRequestURI(),request.getParameterMap());
+    	JsonObject object = new JsonObject();
+    	try{
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+         Integer expId = Integer.valueOf(request.getParameter("expID"));
+         Integer batchNum = Integer.valueOf(request.getParameter("batchNum"));
+         Integer submitNum = Integer.valueOf(request.getParameter("submitNum"));
+         Integer storeId = Integer.valueOf(request.getParameter("shopID"));
+         
+         
+         String url = uploadQn(file.getInputStream());
+         log.info("uploadSignature.url:::"+url);
+//         OutputStream out = new FileOutputStream("/Users/lijm/aaaa/" + fileName);
+//         byte[] buffer = new byte[1024];
+//         int length = -1;
+//         while ((length = is.read(buffer)) != -1) {
+//             out.write(buffer, 0, length);
+//         }
+//  
+//         is.close();
+//         out.close();
+         
+         if(_.isNotEmpty(url)){
+        	 ArrivalSignature signature = new ArrivalSignature();
+        	
+        	 signature.setExpId(expId);
+        	 signature.setBatchNumber(batchNum);
+        	 signature.setSubmitNum(submitNum);
+        	 signature.setStoreId(storeId);
+        	 signature.setSignUrl(url);
+        	 
+        	 signature.setCreateTime(new Date());
+        	 signature.setUpdateTime(new Date());
+        	 signature.setIsDel(0);
+        	 
+        	 scanBatchService.saveSignature(signature);
+        	 
+        	 object.addProperty("code", 0);
+             object.addProperty("msg", "");
+         }else{
+        	 object.addProperty("code", -2);
+             object.addProperty("msg", "上传图片异常");
+         }
+        
+        
+    	}catch(Exception e){
+    		log.error("uploadSignature.error:",e);
+    		object.addProperty("code", -1);
+            object.addProperty("msg", "server error!");
+    	}
+
+        return object.toString();
+    }
+    /*
+     * 暂时没有
+     */
+    @Deprecated
+	private InputStream parseReq(HttpServletRequest request) throws Exception {
+		// TODO Auto-generated method stub
+		InputStream is = null;
+		FileItemFactory factory = new DiskFileItemFactory();
+		ServletFileUpload upload = new ServletFileUpload(factory);
+		upload.setHeaderEncoding("UTF-8");
+		List<FileItem> items = upload.parseRequest(request);
+		if(items!=null&&items.size()>0){
+			Iterator itr = items.iterator();
+			while (itr.hasNext()) {
+				FileItem item = (FileItem) itr.next();
+				if(!item.isFormField()){
+					is = item.getInputStream();
+				}
+			}
+		}
+		return is;
+	}
+
+	private String uploadQn(InputStream inputStream) throws Exception {
+		// TODO Auto-generated method stub
+		String url = APIConfig.getImageUploadQingniu();
+		
+		JsonObject jObject = new JsonObject();
+		jObject.addProperty("data", "image/jpeg;base64,"+Base64.encode(input2byte(inputStream)));
+		StringEntity se = new StringEntity(jObject.toString());
+		String result = HttpUtil.doPost(url, se);
+		JsonNode uploadResultJsonNode = JsonUtil.parse(result);
+		log.info("uploadQn.uploadResultJsonNode::" + uploadResultJsonNode.toString());
+		return uploadResultJsonNode.findValue("url")!=null?uploadResultJsonNode.findValue("url").asText():null;
+	}
+	
+	private byte[] input2byte(InputStream inStream)  
+            throws IOException {  
+        ByteArrayOutputStream swapStream = new ByteArrayOutputStream();  
+        byte[] buff = new byte[100];  
+        int rc = 0;  
+        while ((rc = inStream.read(buff, 0, 100)) > 0) {  
+            swapStream.write(buff, 0, rc);  
+        }  
+        byte[] in2b = swapStream.toByteArray();  
+        return in2b;  
+    }  
+}

+ 364 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/CompleteController.java

@@ -0,0 +1,364 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.util.APIConfig;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.DeliveryScanBatch;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.entity.dto.PhoneLibDto;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.toolkit.CacheTool;
+import cn.haliaeetus.framework.util.HttpUtil;
+import cn.haliaeetus.service.*;
+import cn.haliaeetus.service.impl.PhoneLibPushServiceImpl;
+import com.alibaba.fastjson.JSON;
+import org.apache.commons.beanutils.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@Controller
+public class CompleteController extends BaseController {
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @Autowired
+    private FjDeliveryService fjDeliveryService;
+
+    @Autowired
+    private DeliveryStatusService deliveryStatusService;
+
+    @Autowired
+    private DeliveryScanBatchService scanBatchService;
+
+    @Autowired
+    private PhoneLibPushServiceImpl phoneLibPushService;
+
+    @Autowired
+    private ExpsSignBackService expsSignBackService;
+
+    @RequestMapping("/apk8/complete")
+    @ResponseBody
+    public Object completeInfo(HttpServletRequest request
+    		    , @RequestParam(defaultValue = "0") int expId
+    		    , @RequestParam(defaultValue = "") String telPhone
+    		    , @RequestParam(defaultValue = "") String userName
+    		    , @RequestParam(defaultValue = "") String address
+    		    , @RequestParam(defaultValue = "0") String chargeMoney) throws SQLException, InvocationTargetException, IllegalAccessException {
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+
+        if (expId == 0) throw new IllegalArgumentException("非法参数~");
+
+        Delivery delivery = deliveryService.getById(user.getStoreId(), expId);
+        if (delivery == null) throw new IllegalArgumentException("订单不存在");
+
+        Delivery entity = new Delivery();
+        BeanUtils.copyProperties(entity, delivery);
+
+        if (_.isNotEmpty(telPhone)) {
+            entity.setUserPhone(telPhone);
+        }
+
+        if (_.isNotEmpty(userName)) {
+            entity.setUserName(userName);
+        }
+
+        if (_.isNotEmpty(address)) {
+            entity.setUserAddress(address);
+        }
+        
+        if (_.isNotEmpty(chargeMoney)) {
+            entity.setChargeMoney(Integer.valueOf(chargeMoney));
+        }
+
+        try{
+            String url= APIConfig.getXxUrl();
+            Map<String, String> params = new HashMap<String, String>();
+            params.put("mob", telPhone);
+            params.put("siduanma", user.getSiduanma());
+            String result = HttpUtil.post(url, params);
+        }catch (Exception e){
+            e.getStackTrace();
+        }
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        qc.setEntity(entity);
+        qc.setId(delivery.getId());
+        boolean succ = deliveryService.update(qc);
+
+        DeliveryScanBatch deliveryScanBatch=new DeliveryScanBatch();
+        deliveryScanBatch.setStoreId(user.getStoreId());
+        deliveryScanBatch.setExpCode(entity.getExpcode());
+        deliveryScanBatch.setUserPhone(telPhone);
+        scanBatchService.updateByStoreAndExpCode(deliveryScanBatch);
+
+
+        if (succ) {
+           /* DeliveryStatus deliveryStatus = null;
+            DeliveryStatusQueryCondition statusQC = new DeliveryStatusQueryCondition(user.getStoreId());
+            List<Integer> deliveryIds = new ArrayList<>();
+            deliveryIds.add(delivery.getId());
+            statusQC.setDeliveryIds(deliveryIds);
+            statusQC.setOrderField("id");
+            statusQC.setOrder("desc");
+            List<DeliveryStatus> deliveryStatusList = deliveryStatusService.getDeliveryStatus(statusQC);
+
+            if (deliveryStatusList != null && deliveryStatusList.size() != 0) {
+                deliveryStatus = deliveryStatusList.get(0);
+            }
+
+            // 短信发送方式为自动发送时,发送入库短信
+            if (user.getSmsSendType() == null || user.getSmsSendType() == Constants.SMS_SEND_TYPE_AUTO) {
+            	// 发送短信(短信计费方式为免费模式)
+				if (user.getIsSmsFree() != null && user.getIsSmsFree() == Constants.YES) {
+					deliveryMsgSendHelper.asyncSendMsg(entity, deliveryStatus, delivery);
+				}
+				
+				// 发送短信(短信计费方式为付费模式)
+				if (user.getIsSmsFree() == null || user.getIsSmsFree() != Constants.YES) {
+					List<DeliveryInfo> deliveryInfoList = new ArrayList<DeliveryInfo>();
+					deliveryInfoList.add(new DeliveryInfo(entity, deliveryStatus, delivery));
+					deliveryMsgSendHelper.asyncSendMsgAndDeduct(deliveryInfoList, user, Constants.SMS_CONSUME_BUSINESS_COMPLETE);
+				}
+            }
+
+            if(entity!=null && _.isNotEmpty(entity.getUserPhone())){
+            	deliveryService.callOrderService(entity);
+            }*/
+            //add 2019/02/25
+            PhoneLibDto phoneLibDto=new PhoneLibDto();
+            phoneLibDto.setCreateTime(new Date());
+            phoneLibDto.setStoreId(user.getStoreId());
+            phoneLibDto.setPhones(telPhone);
+            String wxMessage= JSON.toJSONString(phoneLibDto);
+      /*iTemplateMessageApi.sendTemplateMessage(wxMessage);*/
+
+            phoneLibPushService.push(wxMessage);
+            return buildJson(0, "更新成功~");
+        }
+        return buildJson(-1, "更新出错~");
+    }
+
+    @RequestMapping("/apk7/complete")
+    @ResponseBody
+    public Object deprecatedCompleteInfo(HttpServletRequest request
+    		    , @RequestParam(defaultValue = "0") int expId
+    		    , @RequestParam(defaultValue = "") String telPhone
+    		    , @RequestParam(defaultValue = "") String userName
+    		    , @RequestParam(defaultValue = "") String address
+    		    , @RequestParam(defaultValue = "0") String chargeMoney) throws SQLException, InvocationTargetException, IllegalAccessException {
+    	return buildJson(-1, "系统已停用,请退出APP升级!");
+    }
+
+    //expId快递id  expCode面单号 shelfCode取件码
+    @RequestMapping(value = "/app/apk8/complete")
+    @ResponseBody
+    public Object appCompleteInfo(HttpServletRequest request
+            , @RequestParam(defaultValue = "") String expTypeId
+            , @RequestParam(defaultValue = "0") int expId
+            , @RequestParam(defaultValue = "") String telPhone
+            , @RequestParam(defaultValue = "") String userName
+            , @RequestParam(defaultValue = "") String address
+            , @RequestParam(defaultValue = "0") String chargeMoney
+            , @RequestParam(defaultValue = "") String expCode
+            , @RequestParam(defaultValue = "") String shelfCode) throws SQLException, InvocationTargetException, IllegalAccessException {
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        if("".equals(telPhone)){
+            return buildJson(-1, "未输入电话号码");
+        }
+        if(null != shelfCode && shelfCode.length()>9 ){
+           return  buildJson(-1, "取件码不能大于9位");
+        }
+        //if ("".equals(shelfCode)) throw new IllegalArgumentException("非法参数~");
+        if (expId == 0 && "".equals(shelfCode)) throw new IllegalArgumentException("非法参数~");
+        Delivery delivery = new Delivery();
+        if(expId != 0){
+            delivery = deliveryService.getById(user.getStoreId(), expId);
+        }else{
+            delivery = deliveryService.getShelfCode(user.getStoreId(), shelfCode);
+        }
+
+        if (delivery == null) return buildJson(-2, "订单不存在");
+
+        Delivery entity = new Delivery();
+        BeanUtils.copyProperties(entity, delivery);
+        if(null != expCode && !"".equals(expCode)){
+            entity.setExpcode(expCode);
+            entity.setRevexpCode(cn.haliaeetus.framework.util.StringUtil.stringReverse(expCode));
+            String vagueExpCode;
+            if(expCode.length() < 4){
+                vagueExpCode = expCode;
+            }else {
+                vagueExpCode = expCode.substring(expCode.length()- 4,expCode.length());
+            }
+            entity.setVagueExpCode(vagueExpCode);
+        }
+        if(null != shelfCode && !"".equals(shelfCode)){
+            entity.setShelfCode(shelfCode);
+            entity.setRevshelfCode(cn.haliaeetus.framework.util.StringUtil.stringReverse(shelfCode));
+        }
+        if (_.isNotEmpty(telPhone)) {
+            entity.setUserPhone(telPhone);
+            entity.setRevuserPhone(cn.haliaeetus.framework.util.StringUtil.stringReverse(telPhone));
+            String vagueUserPhone;
+            if(telPhone.length() < 4){
+                vagueUserPhone = telPhone;
+            }else {
+                vagueUserPhone = telPhone.substring(telPhone.length()- 4,telPhone.length());
+            }
+            entity.setVagueUserPhone(vagueUserPhone);
+        }
+
+        if (_.isNotEmpty(userName)) {
+            entity.setUserName(userName);
+        }
+
+        if (_.isNotEmpty(address)) {
+            entity.setUserAddress(address);
+        }
+
+        if (_.isNotEmpty(chargeMoney)) {
+            entity.setChargeMoney(Integer.valueOf(chargeMoney));
+        }
+        if(null != expTypeId && !"".equals(expTypeId)){
+            entity.setExpId(Integer.parseInt(expTypeId));
+        }
+        entity.setStoreId(delivery.getStoreId());
+        entity.setCreateTime(delivery.getCreateTime());
+        entity.setStatusTime(delivery.getStatusTime());
+        entity.setStatus(delivery.getStatus());
+        entity.setOdeliveryType(delivery.getOdeliveryType());
+        entity.setSignStatus(delivery.getSignStatus());
+        entity.setSignDtm(delivery.getSignDtm());
+        entity.setUploadDtm(delivery.getUploadDtm());
+        entity.setSignStatus(delivery.getSignStatus());
+
+        if(entity.getExpId() != delivery.getExpId() || entity.getExpcode() != delivery.getExpcode() || entity.getUserPhone() != delivery.getUserPhone() || entity.getShelfCode() != delivery.getShelfCode()){
+            //延时发送短信入库时,这条快递又被编辑了,将入库的那条快递短信的key删除,避免发送两条消息
+            //入库即发短信时编辑快递信息就将key给删除,点击发送通知时可以立即发送短信
+            String flagKey=delivery.getExpId()+"_"+delivery.getExpcode()+"_"+delivery.getUserPhone()+"_"+delivery.getStoreId();
+            CacheTool cacheTool=CacheTool.initSMSFlag();
+            //cacheTool.setStringKey(flagKey,null);
+            cacheTool.del(flagKey);
+            //快递内容编辑后,将smsStatus修改为-1,点击发送通知时发送短信
+            entity.setSmsStatus(-1);
+        }
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        qc.setEntity(entity);
+        qc.setId(delivery.getId());
+        //根据StoreId,expCode,expId删除备份表delivery表数据,重新插入更改后的表
+        deliveryService.deleteDeliveryRepeatData(user.getStoreId(),delivery.getExpcode(),delivery.getExpId());
+
+        boolean succ = deliveryService.updateCompete(qc);
+
+
+        if(delivery.getExpcode()!=expCode || delivery.getExpId() !=Integer.parseInt(expTypeId)){
+            expsSignBackService.signBack(Integer.parseInt(expTypeId), expCode , telPhone,user.getStoreId(),"in",delivery.getShelfId()+"",delivery.getShelfCode());
+        }
+
+        DeliveryScanBatch deliveryScanBatch=new DeliveryScanBatch();
+        deliveryScanBatch.setStoreId(user.getStoreId());
+        deliveryScanBatch.setExpCode(entity.getExpcode());
+        deliveryScanBatch.setUserPhone(telPhone);
+        scanBatchService.updateByStoreAndExpCode(deliveryScanBatch);
+        fjDeliveryService.saveTelphone(user.getStoreId(),telPhone,delivery.getExpcode());
+        if (succ) {
+            //add 2019/02/25
+            PhoneLibDto phoneLibDto=new PhoneLibDto();
+            phoneLibDto.setCreateTime(new Date());
+            phoneLibDto.setStoreId(user.getStoreId());
+            phoneLibDto.setPhones(telPhone);
+            String wxMessage= JSON.toJSONString(phoneLibDto);
+      /*iTemplateMessageApi.sendTemplateMessage(wxMessage);*/
+
+            phoneLibPushService.push(wxMessage);
+            return buildJson(0, "更新成功~");
+        }
+        return buildJson(-1, "更新出错~");
+    }
+
+
+    //deliveryId 快件id  telPhone 要修改的电话号码
+    @RequestMapping(value = "/app/apk8/saveTelPhone")
+    @ResponseBody
+    public Object appChangePhoneInfo(HttpServletRequest request
+            , @RequestParam(defaultValue = "") String telPhone
+            , @RequestParam(defaultValue = "") String deliveryId) throws SQLException, InvocationTargetException, IllegalAccessException {
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        if("".equals(telPhone)){
+            return buildJson(-1, "未输入电话号码");
+        }
+        if(null == deliveryId || "".equals(deliveryId)){
+            return buildJson(-1,"未输入订单编号");
+        }
+        Delivery delivery = deliveryService.getById(user.getStoreId(), Integer.parseInt(deliveryId));
+        if (delivery == null){
+            return buildJson(-1, "订单不存在");
+        }
+        if(delivery.getStatus().intValue() == Constants.ORDER_STATUS_COMPLETE || delivery.getSignStatus().intValue() == 1){
+            return buildJson(-1,"订单已完成");
+        }
+        Delivery entity = new Delivery();
+        BeanUtils.copyProperties(entity, delivery);
+        entity.setId(delivery.getId());
+        entity.setUserPhone(telPhone);
+        try{
+            String url= APIConfig.getXxUrl();
+            Map<String, String> params = new HashMap<String, String>();
+            params.put("mob", telPhone);
+            params.put("siduanma", user.getSiduanma());
+            String result = HttpUtil.post(url, params);
+        }catch (Exception e){
+            e.getStackTrace();
+        }
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        qc.setEntity(entity);
+        qc.setId(delivery.getId());
+        boolean succ = deliveryService.update(qc);
+
+        DeliveryScanBatch deliveryScanBatch=new DeliveryScanBatch();
+        deliveryScanBatch.setStoreId(user.getStoreId());
+        deliveryScanBatch.setExpCode(entity.getExpcode());
+        deliveryScanBatch.setUserPhone(telPhone);
+        scanBatchService.updateByStoreAndExpCode(deliveryScanBatch);
+        fjDeliveryService.saveTelphone(user.getStoreId(),telPhone,delivery.getExpcode());
+        if (succ) {
+            //add 2019/02/25
+            PhoneLibDto phoneLibDto=new PhoneLibDto();
+            phoneLibDto.setCreateTime(new Date());
+            phoneLibDto.setStoreId(user.getStoreId());
+            phoneLibDto.setPhones(telPhone);
+            String wxMessage= JSON.toJSONString(phoneLibDto);
+      /*iTemplateMessageApi.sendTemplateMessage(wxMessage);*/
+
+            phoneLibPushService.push(wxMessage);
+            return buildJson(0, "更新成功~");
+        }
+        return buildJson(-1, "更新出错~");
+    }
+}

+ 269 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/DeliveryActionController.java

@@ -0,0 +1,269 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.ExpressType;
+import cn.haliaeetus.entity.StoreShelf;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.framework.util.StringUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.StoreShelfService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.sql.SQLException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Controller
+public class DeliveryActionController extends BaseController {
+
+    @Autowired
+    private DeliveryService deliveryService;
+    @Autowired
+    private BasicInfoService infoService;
+    @Autowired
+    private StoreShelfService shelfService;
+
+    /**
+     * 订单修改
+     */
+    @RequestMapping("/device/deliveryEdit")
+    @ResponseBody
+    public Object editDelivery(HttpServletRequest request, HttpServletResponse response) {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        String userPhone = request.getParameter("userPhone");
+        String price = request.getParameter("price");
+        String expCode = request.getParameter("expCode");
+        String expIdstr = request.getParameter("expId");
+        int expId = _.toInt(expIdstr);
+
+        if (_.isEmpty(expCode)) {
+            return buildJson(-1, "没有面单号");
+        }
+
+        Delivery delivery = deliveryService.getByTuple(user.getStoreId(), expId, expCode);
+
+        int money = _.isEmpty(price) ? delivery.getChargeMoney() : _.toInt(price);
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        Delivery entity = new Delivery();
+        entity.setUserPhone(userPhone);
+        entity.setChargeMoney(money);
+        qc.setEntity(entity);
+        qc.setId(delivery.getId());
+        deliveryService.update(qc);
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        return object.toString();
+
+    }
+
+    /**
+     * 订单详情查询
+     */
+    @RequestMapping("/device/deliveryDetail")
+    @ResponseBody
+    public Object deliveryDetail(HttpServletRequest request, HttpServletResponse response) throws ParseException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        String expcode = request.getParameter("expCode");
+        if (_.isEmpty(expcode)) {
+            return buildJson(-1, "没有面单号");
+        }
+
+        String today = DateUtil.today().toString("yyyy-MM-dd");
+        String beginTime = DateUtil.addDay(today, "yyyy-MM-dd", -30);
+        String endTime = DateUtil.addDay(today, "yyyy-MM-dd", 1);
+
+        String subSql = " AND createTime>='" + beginTime + "' AND createTime<='" + endTime + "'";
+
+        String strRev = StringUtil.stringReverse(expcode);
+        if (_.isChineseChar(expcode)) {
+            subSql += " and userName='" + expcode + "'";
+        } else if (expcode.length() <= 6) {
+            subSql += " and (shelfCode ='" + expcode + "' or userPhone like '" + expcode + "%' or revuserPhone " +
+                    "like '" + strRev + "%' or expcode like '" + expcode + "%' or revexpCode like '" + strRev +
+                    "%')";
+        } else if (expcode.length() > 6 && expcode.length() < 11) {
+            subSql += " and (userPhone like '" + expcode + "%' or revuserPhone like '" + strRev + "%' or " +
+                    "expcode like '" + expcode + "%' or revexpCode like '" + strRev + "%')";
+        } else {
+            subSql += " and (expcode = '" + expcode + "' or userPhone = '" + expcode + "')";
+        }
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        qc.setSubSql(subSql);
+        qc.setOrderField("status asc,");
+        qc.setOrder("createTime desc");
+        List<Delivery> deliveryList = deliveryService.getDelivery(qc);
+        List<StoreShelf> shelfs = shelfService.getByStoreId(user.getStoreId());
+        List<ExpressType> explist = infoService.getExpressByStoreId(user.getStoreId()).get(1);
+
+        JsonObject object = new JsonObject();
+        JsonArray dJsonObject = new JsonArray();
+        if (deliveryList.isEmpty()) {
+            object.addProperty("code", -2);
+            object.addProperty("msg", "面单不存在");
+        } else {
+            object.addProperty("code", 0);
+            object.addProperty("msg", "");
+
+            for (Delivery d : deliveryList) {
+                JsonObject jsonObject = new JsonObject();
+                jsonObject.addProperty("expId", d.getExpId());
+                jsonObject.addProperty("expcode", d.getExpcode());
+                jsonObject.addProperty("instoreTime", DateUtil.timestampFormat(d.getCreateTime()));
+                jsonObject.addProperty("userPhone", _.trimToEmpty(d.getUserPhone()));
+                jsonObject.addProperty("chargeMoney", _.parseMoney(d.getChargeMoney()));
+                jsonObject.addProperty("status", d.getStatus());
+                jsonObject.addProperty("shelfCode", d.getShelfCode());
+                jsonObject.addProperty("id", d.getId());
+
+                for(ExpressType express: explist){
+                    if(d.getExpId()!=null && d.getExpId().intValue()==express.getExpId()){
+                        jsonObject.addProperty("expName", express.getExpName());
+                    }
+                }
+
+                for(StoreShelf shelf: shelfs){
+                    if(d.getShelfId()!=null && d.getShelfId().intValue() == shelf.getId().intValue()){
+                        jsonObject.addProperty("shelfName", shelf.getShelfName());
+                    }
+                }
+
+                dJsonObject.add(jsonObject);
+            }
+        }
+
+        object.add("data", dJsonObject);
+        return object.toString();
+
+    }
+
+    /**
+     * 获取货架上所有订单
+     */
+    @RequestMapping("/app/shelfDelivery")
+    @ResponseBody
+    public Object getShelfDeliverys(HttpServletRequest request, @RequestParam(defaultValue = "0") int shelfId) throws SQLException, ParseException {
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        JsonObject result = new JsonObject();
+        result.addProperty("code", 0);
+        result.addProperty("msg", "");
+
+        JsonArray array = new JsonArray();
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        qc.setUserPhone("");
+        qc.setShelfId(shelfId);
+        qc.setIsdel(0);
+        String today = DateUtil.today().toString("yyyy-MM-dd");
+        String endTime = DateUtil.addDay(today, "yyyy-MM-dd", 1);
+        String beginTime = DateUtil.addDay(today, "yyyy-MM-dd", -3);
+        qc.setStatusTime(beginTime,endTime);
+
+        ArrayList<Integer> statusList = new ArrayList<Integer>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+//        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        qc.setStatusStr(statusList);
+        //排序
+        qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
+		qc.setOrder("asc");
+        List<Delivery> deliveryList = deliveryService.getDelivery(qc);
+        List<ExpressType> expressList = infoService.getExpressByStoreId(user.getStoreId()).get(1);
+        Map<Integer, ExpressType> expressMap = new HashMap<Integer, ExpressType>();
+        for (ExpressType expressItem : expressList) {
+            expressMap.put(expressItem.getExpId(), expressItem);
+        }
+
+        for (Delivery delivery : deliveryList) {
+            JsonObject json = new JsonObject();
+            json.addProperty("id",delivery.getId());
+            json.addProperty("expId",delivery.getExpId());
+            json.addProperty("expcode",delivery.getExpcode());
+            json.addProperty("shelfId",delivery.getShelfId());
+            json.addProperty("shelfCode",delivery.getShelfCode());
+
+            ExpressType express = expressMap.get(delivery.getExpId());
+            json.addProperty("expName",express.getExpName());
+            json.addProperty("isModify",express.getType());
+
+            array.add(json);
+        }
+
+        result.add("data", array);
+        return result.toString();
+
+    }
+
+    /**
+     * 获取所有包含散单的货架和散单数
+     */
+    @RequestMapping("/app/shelf")
+    @ResponseBody
+    public Object getShelf(HttpServletRequest request) throws Exception {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        JsonObject result = new JsonObject();
+        result.addProperty("code", 0);
+        result.addProperty("msg", "");
+
+        JsonArray array = new JsonArray();
+        Map<String,Object> paramMap = new HashMap<String,Object>();
+        String today = DateUtil.today().toString("yyyy-MM-dd");
+        String endTime = DateUtil.addDay(today, "yyyy-MM-dd", 1);
+        String beginTime = DateUtil.addDay(today, "yyyy-MM-dd", -3);
+       
+        paramMap.put("beginTime", beginTime);
+        paramMap.put("endTime", endTime);
+        paramMap.put("storeId", user.getStoreId());
+        
+        List<Map<String, Object>> list = deliveryService.getDeliveryCountAndShelf(paramMap);
+        for (Map<String, Object> entry : list) {
+            JsonObject one = new JsonObject();
+            one.addProperty("cnt", Integer.parseInt(entry.get("deliveryCount")+""));
+            one.addProperty("shelfId", Integer.parseInt(entry.get("shelfId")+""));
+            one.addProperty("shelfName", (String)entry.get("shelfName"));
+            one.addProperty("barcode", (String)entry.get("barcode"));
+            array.add(one);
+        }
+        result.add("data", array);
+        return result.toString();
+    }
+}

+ 71 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/DeliveryRemindController.java

@@ -0,0 +1,71 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import cn.haliaeetus.controller.store.helper.DeliveryMsgSendHelper;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.entity.dto.DeliveryDto;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.service.InventoryService;
+
+@Controller
+public class DeliveryRemindController extends BaseController {
+    
+    @Autowired
+	private InventoryService inventoryService;
+    
+    @Autowired
+	private DeliveryMsgSendHelper smsSendHelper;
+
+    @RequestMapping("/device/deliveryRemind")
+    @ResponseBody
+	public Object remindDelivery(HttpServletRequest request,
+			HttpServletResponse response) throws Exception {
+
+		User user = getUserFromParam(request);
+		if (user == null) {
+			return buildJson(1, "用户未登录");
+		}
+		JsonNode jsonNode = JsonUtil.parse(request.getParameter("data"));
+		if (jsonNode == null) return buildJson(-1, "参数错误");
+
+		Iterator<JsonNode> it = jsonNode.iterator();
+		while (it.hasNext()) {
+			JsonNode expInfo = it.next();
+			String expCode = expInfo.findValue("expCode").asText();
+			if (_.isEmpty(expCode)) {
+				continue;
+			}
+			List<DeliveryDto> deliveryList = inventoryService.getRemindStrandedList(5, 0, 0, expCode, -1, user.getStoreId());
+
+			if (_.isEmpty(deliveryList)) {
+				return buildJson(-1, "订单不存在、不在库或者滞留时间不到2小时");
+			}
+
+			boolean isSmsSend = false;
+			for (DeliveryDto deliveryDto : deliveryList) {
+				if (deliveryDto.getStrandedSmsAgain() == 1) {
+					isSmsSend = true;
+					smsSendHelper.asyncSendStrandedMsg(deliveryDto.getDelivery(), user);
+				}
+			}
+			if (!isSmsSend) {
+				return buildJson(-1, "滞留件短信一天只能发送一次,不可重复发送!");
+			}
+		}
+		return buildJson(0, "成功");
+	}
+}

+ 272 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/DispatchController.java

@@ -0,0 +1,272 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import cn.haliaeetus.dao.DeliveryDao;
+import cn.haliaeetus.framework.util.StringUtil;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.store.helper.DeliveryInfo;
+import cn.haliaeetus.controller.store.helper.DeliveryMsgSendHelper;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.service.*;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+@Controller
+public class DispatchController extends BaseController {
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @Autowired
+    private FjDeliveryService fjDeliveryService;
+
+    @Autowired
+    private StoreStaffService staffService;
+
+    @Autowired
+    private DeliveryNoArriveService noArriveService;
+
+    @Autowired
+    private DeliveryStatusService statusService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private TypeLibraryService typeLibraryService;
+    
+    @Autowired
+   	private DeliveryMsgSendHelper messageSendHelper;
+
+    @Autowired
+    private DeliveryScanBatchService scanBatchService;
+
+    @Autowired
+    private DeliveryDao deliveryDao;
+
+    @RequestMapping("/device/dispatch")
+    @ResponseBody
+    public Object dispatch(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        User user = getUserFromParam(request);
+        if (user == null) return buildJson(1, "用户未登录");
+
+        String data = request.getParameter("data");
+        if (_.isEmpty(data)) return buildJson(-1, "参数错误");
+        JsonNode jsonNode = JsonUtil.parse(data);
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        List<DeliveryInfo> deliveryInfoList = new ArrayList<DeliveryInfo>();
+        while (it.hasNext()) {
+            JsonNode node = it.next();
+            int staffId = node.findValue("staffId").asInt();
+            String expCode = node.findValue("expCode").asText();
+            long expId = node.findValue("expId").asLong();
+
+            if (_.isEmpty(expCode) || expId == 0) {
+                return buildJson(-1, "参数错误");
+            }
+
+            if (expCode.length() < 10) {
+                return buildJson(-1, "单号非法");
+            }
+
+            String userPhone = "";
+            // 分拣中心快递类型
+//            if (expId == Integer.MAX_VALUE) {
+            JsonObject dataObj1 = new JsonObject();
+            dataObj1.addProperty("expCode", expCode);
+
+            List<FjDelivery> fjDeliveryList = fjDeliveryService.getByExpCode(user.getStoreId(), expCode);
+//                if (fjDeliveryList == null || fjDeliveryList.isEmpty()) {
+//                    dataObj1.addProperty("reason", "没有分拣");
+//                    array.add(dataObj1);
+//                    continue;
+//                }
+            if (null==fjDeliveryList||fjDeliveryList.isEmpty())
+            {
+                if (fjDeliveryList.size() > 1) {
+                    dataObj1.addProperty("reason", "分拣单号重复");
+                    array.add(dataObj1);
+                    continue;
+                }
+                userPhone="";
+             }else {
+                userPhone = fjDeliveryList.get(0).getTelphone();
+            }
+                if (expId == Integer.MAX_VALUE){
+                expId = fjDeliveryList.get(0).getExpId();
+            }
+//            }
+            
+            try {
+            	DeliveryInfo deliveryInfo = deliveryService.dispatchDelivery(user, expCode, (int)expId, staffId, "", userPhone, Constants
+                        .CLIENT_TYPE_STORE_LITE_2);
+            	deliveryInfoList.add(deliveryInfo);
+                //同步一条数据到到件表中
+                List<DeliveryScanBatch> scanBatches=scanBatchService.getByCondition(user.getStoreId(), expCode, null, null,null,null);
+                if(scanBatches!=null&&scanBatches.size()>0){
+                    //更新下车表里的快递公司、取货码、货架号
+                    DeliveryScanBatch deliveryScanBatch = scanBatches.get(0);
+                    DeliveryScanBatch dsb = new DeliveryScanBatch();
+                    dsb.setStoreId(deliveryScanBatch.getStoreId());
+                    dsb.setExpCode(deliveryScanBatch.getExpCode());
+//                deliveryScanBatch.setExpId(Integer.getInteger(expressId));
+
+                    try{
+                        dsb.setExpId(node.findValue("expId").asInt());
+                    }
+                    catch (Exception e){
+
+                    }
+                    scanBatchService.updateByStoreAndExpCode(dsb);
+                }else{
+                    DeliveryScanBatch scanBatch=new DeliveryScanBatch();
+                    scanBatch.setExpCode(expCode);
+                    scanBatch.setRevexpCode(StringUtil.stringReverse(expCode));
+                    scanBatch.setExpId((int) expId);
+                    scanBatch.setBatchNumber(0);
+                    scanBatch.setStoreId(user.getStoreId());
+                    scanBatch.setOperatorId(1);
+                    scanBatch.setCreateTime(new Date());
+                    scanBatch.setUserName("");
+                    scanBatch.setUserPhone(userPhone);
+                    scanBatch.setRevuserPhone(StringUtil.stringReverse(userPhone));
+                    scanBatch.setChargeMoney(null);
+                    scanBatch.setOcrStatus("0");
+                    scanBatch.setOcrAmount("0");
+                    scanBatch.setShelfCode("");
+                    scanBatchService.insert(scanBatch);
+                }
+            } catch (Exception e) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", e.getMessage());
+                array.add(dataObj);
+            }
+
+            //判断0代表入库时生成签收,1代表出库时生成签收
+            if(user.getSignFlag()==0){
+                // 新入库
+                DeliveryQueryCondition dqc = new  DeliveryQueryCondition(user.getStoreId());
+                dqc.setExp_code(expCode);
+                dqc.setStoreId(user.getStoreId());
+
+                deliveryDao.updateStoreOut(dqc);
+            }
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.add("expInfo", array);
+        
+        // 短信发送方式为付费模式
+        if ((user.getIsSmsFree() == null || user.getIsSmsFree() != Constants.YES) && _.isNotEmpty(deliveryInfoList)) {
+			messageSendHelper.asyncSendMsgAndDeduct(deliveryInfoList, user, Constants.SMS_CONSUME_BUSINESS_DISPATCH);
+		}
+
+        return object.toString();
+    }
+
+    /**
+     * 拒收/问题件扫描
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    @RequestMapping("/device/return")
+    @ResponseBody
+    public Object deliveryReturn(HttpServletRequest request) throws IOException {
+        User user = getUserFromParam(request);
+        if (user == null) return buildJson(1, "用户未登录");
+
+        String data = request.getParameter("data");
+        if (_.isEmpty(data)) return buildJson(-1, "参数错误");
+
+        JsonNode jsonNode = JsonUtil.parse(data);
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        while (it.hasNext()) {
+            JsonNode node = it.next();
+            int reason = node.findValue("reason").asInt();
+            String expCode = node.findValue("expCode").asText();
+
+            if (_.isEmpty(expCode)) {
+                return buildJson(-1, "单号不存在");
+            }
+
+            JsonNode expIdNode = node.findValue("expId");
+            int expId = expIdNode == null ? 0 : expIdNode.asInt();
+            if (expId == 0) {
+                DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+
+                ArrayList<Integer> statusList = new ArrayList<>();
+                statusList.add(Constants.ORDER_STATUS_STORED);
+                statusList.add(Constants.ORDER_STATUS_MAIKE_DISPATCHING);
+                statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+                statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+                qc.setStatusStr(statusList);
+
+                qc.setExpcode(expCode);
+                qc.setIsdel(0);
+                List<Delivery> deliveryList = deliveryService.getDelivery(qc);
+                if (deliveryList != null && deliveryList.size()>1) {
+                    JsonObject dataObj = new JsonObject();
+                    dataObj.addProperty("expCode", expCode);
+                    dataObj.addProperty("reason", "单号重复");
+
+                    JsonArray expArray = new JsonArray();
+                    for (Delivery deli : deliveryList) {
+                        JsonObject obj = new JsonObject();
+                        obj.addProperty("expId", deli.getExpId());
+                        ExpressType express = basicInfoService.getExpressById(deli.getExpId());
+                        obj.addProperty("expName", express.getExpName());
+                        expArray.add(obj);
+                    }
+                    dataObj.addProperty("data", expArray.toString());
+
+                    array.add(dataObj);
+                }
+            }
+
+            try {
+                deliveryService.refuseDelivery(user.getStoreId(), 0,expCode,expId, reason, Constants.CLIENT_TYPE_STORE_LITE_2, user.getUserName());
+            } catch (Exception e) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", e.getMessage());
+                array.add(dataObj);
+            }
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.add("expInfo", array);
+
+        return object.toString();
+    }
+
+}

+ 172 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/GetAllExpController.java

@@ -0,0 +1,172 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import cn.haliaeetus.entity.Store;
+import cn.haliaeetus.framework.toolkit.CacheTool;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.entity.ExpressType;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.BasicInfoService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+
+
+@Controller
+public class GetAllExpController extends BaseController {
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+
+	@RequestMapping("/device/expresslist")
+	@ResponseBody
+	public Object getAllExpCom(HttpServletRequest request, HttpServletResponse response) {
+		
+		User user = getUserFromParam(request);
+		if( user == null ){
+			return buildJson(1,"用户未登录");
+		}
+		
+		List<ExpressType> allExps = basicInfoService.getExpressByStoreId(user.getStoreId()).get(1);
+
+		//添加分拣中心快递类型
+		ExpressType fjExp = new ExpressType();
+		fjExp.setExpId(Integer.MAX_VALUE);
+		fjExp.setExpName("分拣中心");
+		allExps.add(0,fjExp);
+		
+		JsonObject object = new JsonObject();
+		object.addProperty("code",0);
+		object.addProperty("msg", "");
+		
+		JsonArray array = new JsonArray();
+		
+		for (ExpressType e : allExps) {
+			array.add(e.toJson());
+		}
+		
+		object.add("expInfo", array);
+	
+		return object.toString();
+	}
+	//获取合作快递
+	@RequestMapping("/app/device/expresslist")
+	@ResponseBody
+	public Object getAppAllExpCom(HttpServletRequest request, HttpServletResponse response) {
+
+		User user = getUserFromParam(request);
+		if( user == null ){
+			return buildJson(1,"用户未登录");
+		}
+
+		List<ExpressType> allExps = basicInfoService.getExpressByStoreId(user.getStoreId()).get(1);
+
+		/*//添加分拣中心快递类型
+		ExpressType fjExp = new ExpressType();
+		fjExp.setExpId(Integer.MAX_VALUE);
+		fjExp.setExpName("分拣中心");
+		allExps.add(0,fjExp);*/
+		Collections.sort(allExps, new Comparator<ExpressType>() {
+			@Override
+			public int compare(ExpressType o1, ExpressType o2) {
+				if(o1.getSort() > o2.getSort()){
+					return 1;
+				}else if(o1.getSort() < o2.getSort()){
+					return -1;
+				}else {
+					return 0;
+				}
+			}
+		});
+		JsonObject object = new JsonObject();
+		object.addProperty("code",0);
+		object.addProperty("msg", "");
+
+		JsonArray array = new JsonArray();
+
+		for (ExpressType e : allExps) {
+			JsonObject jsonObject = new JsonObject();
+			jsonObject.addProperty("expId", e.getExpId());
+			jsonObject.addProperty("expName", e.getExpName());
+			jsonObject.addProperty("expImage", e.getExpImage());
+			jsonObject.addProperty("sort", e.getSort());
+			array.add(jsonObject);
+		}
+
+		object.add("expInfo", array);
+
+		return object.toString();
+	}
+	@RequestMapping("/app/device/allExpresslist")
+	@ResponseBody
+	public Object getAppAllExpress(HttpServletRequest request, HttpServletResponse response) {
+
+		User user = getUserFromParam(request);
+		if( user == null ){
+			return buildJson(1,"用户未登录");
+		}
+		List<ExpressType> allExps = basicInfoService.getAllExpressMapMemcached();
+		if(null == allExps || allExps.size() < 1){
+			return buildJson(-1,"没有快递");
+		}
+		Collections.sort(allExps, new Comparator<ExpressType>() {
+			@Override
+			public int compare(ExpressType o1, ExpressType o2) {
+				if(o1.getSort() > o2.getSort()){
+					return 1;
+				}else if(o1.getSort() < o2.getSort()){
+					return -1;
+				}else {
+					return 0;
+				}
+			}
+		});
+		JsonObject object = new JsonObject();
+		object.addProperty("code",0);
+		object.addProperty("msg", "");
+
+		JsonArray array = new JsonArray();
+
+		for (ExpressType e : allExps) {
+			JsonObject jsonObject = new JsonObject();
+			jsonObject.addProperty("expId", e.getExpId());
+			jsonObject.addProperty("expName", e.getExpName());
+			jsonObject.addProperty("expImage", e.getExpImage());
+			jsonObject.addProperty("sort", e.getSort());
+			array.add(jsonObject);
+		}
+		object.add("expInfo", array);
+
+		return object.toString();
+	}
+
+	@RequestMapping("/app/device/saveDispatchIds")
+	@ResponseBody
+	public Object saveDispatchIds(HttpServletRequest request, HttpServletResponse response,
+								  @RequestParam(defaultValue = "")String dispathchIds) {
+		User user = getUserFromParam(request);
+		if( user == null ){
+			return buildJson(1,"用户未登录");
+		}
+		Store store = basicInfoService.getStoreById(user.getStoreId());
+		store.setDispatchIds(dispathchIds);
+		int result = basicInfoService.saveDispathchIds(store);
+		if(result > 0){
+			CacheTool cacheTool = CacheTool.initStore();
+			Store store1 = basicInfoService.getStoreById(user.getStoreId());
+			cacheTool.saveBean(user.getStoreId() + "", store1);
+			log.info("门店信息更新,删除store缓存,门店ID:" + user.getStoreId());
+			return buildJson(0,"更改成功");
+		}
+		return buildJson(-1,"更改失败");
+	}
+}

+ 302 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/GetAllStoreShelfController.java

@@ -0,0 +1,302 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.DeliveryScanBatch;
+import cn.haliaeetus.entity.dto.DeliveryDto;
+import cn.haliaeetus.entity.dto.QueryPageDto;
+import cn.haliaeetus.entity.jspo.JShelfDto;
+import cn.haliaeetus.entity.jspo.JsonMsg;
+import cn.haliaeetus.framework.toolkit.PagedList;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.service.DeliveryScanBatchService;
+import cn.haliaeetus.service.DeliveryService;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.entity.StoreShelf;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.StoreShelfService;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import static cn.haliaeetus.framework._.isEmpty;
+
+import static cn.haliaeetus.framework._.max;
+
+
+@Controller
+public class GetAllStoreShelfController extends BaseController {
+    @Autowired
+    private StoreShelfService shelfService;
+    @Autowired
+    private DeliveryService deliveryService;
+    @Autowired
+    private DeliveryScanBatchService scanBatchService;
+    @RequestMapping("/device/shelflist")
+    @ResponseBody
+    public Object getAllShelfList(HttpServletRequest request, HttpServletResponse response,
+                                  @RequestParam(defaultValue = "") String beginTime,
+                                  @RequestParam(defaultValue = "") String endTime) throws SQLException,
+            ParseException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+        int storeId = user.getStoreId();
+        //List<StoreShelf> shelfs = shelfService.getByStoreId(storeId);
+        //完善散单数量
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+       /* //判断今天、近一月
+        Date date = new Date();
+        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
+        String time = sdf.format(date);
+        qc.setBeginTime(Timestamp.valueOf(time.trim()+" 00:00:00"));
+        qc.setBeginTime(Timestamp.valueOf(time.trim()+" 23:59:59"));
+        String  beginTime = DateUtil.today().toString("yyyy-MM-dd");
+        String endTime = DateUtil.today().toString("yyyy-MM-dd");
+        qc.setCreateTime(beginTime, endTime);
+        ArrayList<Integer> statusList = new ArrayList<>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+//        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        qc.setStatusStr(statusList);
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");*/
+        int p = 1;
+        int pageSize = 20000;
+        p = max(1, p);
+        int begin = (p - 1) * pageSize;
+        int offset = -1;
+        int sort = -1;
+        String type = "UNCOMPLETE";
+        String odeliverytype = "ALL";
+        int expId = 0;
+        int shelfId = 0;
+        //判断今天、近一月
+        qc.setPageSize(pageSize);
+        if(!beginTime.equals("")){
+            String time = beginTime.trim()+" 00:00:00";
+            qc.setBeginTime(Timestamp.valueOf(time));
+        }
+        if(!endTime.equals("")){
+            String time = endTime.trim()+" 23:59:59";
+            qc.setEndTime(Timestamp.valueOf(time));
+        }
+        if (offset == -1) {
+            if (isEmpty(beginTime))
+                beginTime = DateUtil.today().toString("yyyy-MM-dd");
+            if (isEmpty(endTime))
+                endTime = DateUtil.today().toString("yyyy-MM-dd");
+
+            endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);
+        } else {
+            String today = DateUtil.today().toString("yyyy-MM-dd");
+            beginTime = DateUtil.addDay(today, "yyyy-MM-dd", -offset);
+            endTime = DateUtil.addDay(today, "yyyy-MM-dd", 1);
+        }
+
+        String subSql = "";
+        // 封装查询条件
+
+        qc.setP(p);
+        qc.setBegin(begin);
+        if (!"ALL".equals(type)) {
+            switch (type) {
+                case "UNCOMPLETE": // 未完善
+                    subSql += " and userPhone = '' ";
+                    break;
+                case "COMPLETED": // 已完善
+                    subSql += " and  userPhone > '' ";
+                    break;
+            }
+        }
+
+        if (!subSql.equals("")) {
+            qc.setSubSql(subSql);
+        }
+        //queryTye = 2表示根据手机号模糊查询,以下逻辑可优化
+
+        if (!"ALL".equals(odeliverytype)) {
+            if("PS".equals(odeliverytype)){
+                qc.setOdeliveryType(odeliverytype);
+            }else{
+                qc.setOdeliveryType("ZI','P2P");
+            }
+
+        }
+
+        qc.setExpId(expId);
+        qc.setShelfId(shelfId);
+
+        qc.setCreateTime(beginTime, endTime);
+
+        ArrayList<Integer> statusList = new ArrayList<>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+//        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        qc.setStatusStr(statusList);
+
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        switch (sort) {
+            case 0:
+                qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
+                qc.setOrder("asc");
+                break;
+            case 1:
+                qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
+                qc.setOrder("desc");
+                break;
+        }
+
+        QueryPageDto pageDto = deliveryService.getQueryPageDto(qc);
+
+        for(DeliveryDto d:pageDto.getPageList().getItems()){
+            List<DeliveryScanBatch> deliveryScanBatches =scanBatchService.getByCondition(d.getDelivery().getStoreId(),d.getDelivery().getExpcode(),d.getDelivery().getExpId(),null,null,null);
+            if(d.getDelivery().getUserPhone()!=null) {
+                if (deliveryScanBatches.size() > 0 && "2".equals(deliveryScanBatches.get(0).getOcrStatus())) {
+                    StringBuilder number = new StringBuilder(d.getDelivery().getUserPhone());
+                    if (StringUtils.isEmpty(d.getDelivery().getUserPhone())||StringUtils.isBlank(d.getDelivery().getUserPhone()))
+                    {
+                        number.append("");
+                    }else {
+                        number.replace(3, 10, "*******");
+                    }//number.replace(3, 10, "*******");
+                    d.getDelivery().setUserPhone(number.toString());
+                }
+            }
+        }
+        List<StoreShelf> shelfs = pageDto.getStoreShelfs();
+        List<JShelfDto> jShelfDtos = new ArrayList<JShelfDto>();
+        PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
+        for (StoreShelf s:shelfs) {
+            JShelfDto jShelfDto = new JShelfDto();
+            Integer count = 0;
+           for (DeliveryDto d:deliveryPagedList.getItems()) {
+               Delivery d2 =  d.getDelivery();
+               if(s.getId().intValue() == d2.getShelfId().intValue()){
+                   count++;
+               }
+           }
+           jShelfDto.setId(s.getId());
+           jShelfDto.setShelfName(s.getShelfName());
+           jShelfDto.setShelfCount(count);
+           jShelfDtos.add(jShelfDto);
+        }
+        JsonMsg jsonMsg = JsonMsg.getSuccess();
+        jsonMsg.add("list",jShelfDtos);
+        /*
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+
+        JsonArray array = new JsonArray();
+
+        if(shelfs!=null){
+            for (StoreShelf e : shelfs) {
+                array.add(e.toJson());
+            }
+        }
+
+        object.add("shelflist", array);
+*/
+        return jsonMsg;
+    }
+    //获取货架列表
+    @RequestMapping("/device/getShelflist")
+    @ResponseBody
+    public Object getShelfList(HttpServletRequest request, HttpServletResponse response) throws SQLException,
+            ParseException {
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1,"用户未登录");
+        }
+        List<StoreShelf> shelfs = shelfService.getByStoreId(user.getStoreId());
+        List<JShelfDto> jShelfDtos = new ArrayList<JShelfDto>();
+        for (StoreShelf s: shelfs) {
+            JShelfDto jShelfDto = new JShelfDto();
+            jShelfDto.setId(s.getId());
+            jShelfDto.setShelfName(s.getShelfName());
+            jShelfDto.setShelfCount(0);
+            jShelfDto.setBarCode(s.getBarCode());
+            jShelfDtos.add(jShelfDto);
+        }
+        JsonMsg jsonMsg = JsonMsg.getSuccess();
+        jsonMsg.add("list",jShelfDtos);
+        return jsonMsg;
+    }
+
+    //获取货架以及货架上的快件数量
+    @RequestMapping("/device/getAllShelflist")
+    @ResponseBody
+    public Object getAllShelfList(HttpServletRequest request, HttpServletResponse response) throws SQLException,
+            ParseException {
+        User user = getUserFromParam(request);
+        if(null == user){
+            return buildJson(1,"用户未登录");
+        }
+        List<StoreShelf> shelfs = shelfService.getByStoreId(user.getStoreId());
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        //查在库和滞留的
+        List<Integer> statusList = new ArrayList<Integer>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
+        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        qc.setStatusStr(statusList);
+        qc.setIsdel(0);
+       /* //查时间一个月的
+        String endTime = DateUtil.today().toString("yyyy-MM-dd");
+        String endTime1 = endTime.trim()+" 23:59:59";
+        String beginTime = getMouthbefore(endTime);
+        String beginTime1 = beginTime.trim() + " 00:00:00";
+        qc.setBeginTime(Timestamp.valueOf(beginTime1));
+        qc.setEndTime(Timestamp.valueOf(endTime1));
+        qc.setCreateTime(beginTime1,endTime1);*/
+        List<JShelfDto> result =  deliveryService.getShelfCount(qc);
+        for (StoreShelf s: shelfs) {
+            for (JShelfDto jShelfDto: result) {
+                if(jShelfDto.getId().intValue() == s.getId().intValue()){
+                    s.setShelfCount(jShelfDto.getShelfCount());
+                }
+            }
+
+        }
+        JsonMsg jsonMsg = JsonMsg.getSuccess();
+        jsonMsg.add("list",shelfs);
+        return jsonMsg;
+    }
+
+    private String getMouthbefore(String specifiedDay){
+        Calendar c = Calendar.getInstance();
+        Date date=null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        c.setTime(date);
+        int day=c.get(Calendar.DATE);
+        c.set(Calendar.DATE,day-30);
+
+        String dayAfter=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+}

+ 264 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/LeaveController.java

@@ -0,0 +1,264 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.store.helper.StoreAPIHelper;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.CompletePic;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.DeliveryStatus;
+import cn.haliaeetus.entity.ExpressType;
+import cn.haliaeetus.entity.StoreStaff;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.DeliveryStatusService;
+import cn.haliaeetus.service.StoreStaffService;
+import cn.haliaeetus.service.TypeLibraryService;
+
+@Controller
+public class LeaveController extends BaseController {
+	private static final Logger log = LoggerFactory.getLogger(LeaveController.class);
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @Autowired
+    private StoreStaffService staffService;
+
+    @Autowired
+    private DeliveryStatusService statusService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private TypeLibraryService typeLibraryService;
+    
+    @Autowired
+	private StoreAPIHelper storeAPIHelper;
+    
+    @RequestMapping("/api/bs/saveCompletePic")
+    @ResponseBody
+    public Object saveCompletePic(HttpServletRequest request, HttpServletResponse response){
+    	
+    	JsonObject result = new JsonObject();
+    	int storeId = 0;
+    	int expId = 0;
+    	String expCode = "";
+    	String picUrl = "";
+    	
+    	try{
+    		storeId = Integer.valueOf(request.getParameter("storeId"));
+            expId = Integer.valueOf(request.getParameter("expId"));
+        	expCode = request.getParameter("expCode");
+        	picUrl = request.getParameter("picUrl");
+        	CompletePic pic = new CompletePic();
+        	pic.setStoreId(storeId);
+        	pic.setExpId(expId);
+        	pic.setExpCode(expCode);
+        	pic.setPicUrl(picUrl);
+        	pic.setCreateTime(new Date());
+        	pic.setUpdateTime(new Date());
+        	statusService.saveCompletePic(pic);
+        	result.addProperty("code", 0);
+        	result.addProperty("msg", "SUCCESS");
+    	}catch(Exception e){
+    		
+    		result.addProperty("code", -1);
+        	result.addProperty("msg", "ERROR");
+        	log.error("api.bs.saveCompletePic:::expCode{}",new Object[]{expCode},e);
+    	}
+    	
+    	
+    	return result.toString();
+    }
+    
+
+    @RequestMapping("/device/leave")
+    @ResponseBody
+    public Object leaveDelivery(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(request.getParameter("data"));
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        while (it.hasNext()) {
+            JsonNode expInfo = it.next();
+
+            int staffId = expInfo.findValue("staffId").asInt();
+            String expCode = expInfo.findValue("expCode").asText();
+
+            if (staffId == 0 || _.isEmpty(expCode)) {
+                continue;
+            }
+
+            Delivery delivery = null;
+            int expId = 0;
+            JsonNode expIdNode = expInfo.findValue("expId");
+            if (expIdNode != null) expId = expIdNode.asInt();
+            if (expId <= 0) {
+                Object obj = handleRepeatDelivery(expCode, user.getStoreId());
+                if (obj instanceof Delivery) delivery = (Delivery) obj;
+                if (obj instanceof JsonObject) {
+                    array.add((JsonElement) obj);
+                    continue;
+                }
+            } else {
+                delivery = deliveryService.getByTuple(user.getStoreId(), expId, expCode);
+            }
+
+            if (delivery == null) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "单号不存在");
+                array.add(dataObj);
+                continue;
+            }
+
+            if (delivery.getStatus() == Constants.ORDER_STATUS_COMPLETE) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "已出库");
+                array.add(dataObj);
+                continue;
+            }
+
+            // 忽略已离库
+            if (delivery.getStatus() == Constants.ORDER_STATUS_LEAVE_STORE || delivery.getStatus() == Constants
+                    .ORDER_STATUS_REJECT_LEAVE_STORE) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "已离库");
+                array.add(dataObj);
+                continue;
+            }
+
+            StoreStaff staff = staffService.getById(staffId);
+            if (staff == null) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "派送员不存在");
+                array.add(dataObj);
+                continue;
+            }
+            String reason = expInfo.findValue("reason")!=null?expInfo.findValue("reason").asText():"";
+            String reasonDes = expInfo.findValue("reasonDes")!=null?expInfo.findValue("reasonDes").asText():"";
+            // 拒收离库
+            int status = delivery.getProblemType() == Constants.PROBLEM_TYPE_REFUSE ? Constants
+                    .ORDER_STATUS_REJECT_LEAVE_STORE : Constants.ORDER_STATUS_LEAVE_STORE;
+
+            if (status != delivery.getStatus()) {
+                Delivery entity = new Delivery();
+                entity.setStatus(status);
+                entity.setStatusTime(new Date());
+                entity.setRemark(reasonDes);
+                DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+                qc.setEntity(entity);
+                qc.setId(delivery.getId());
+                deliveryService.update(qc);
+
+                DeliveryStatus deliveryStatus = addStatusHistory(user.getStoreId(), staff.getName(), delivery.getId()
+                		, status, delivery.getStatus(), reason, reasonDes);
+                storeAPIHelper.asyncSubmitDataQueue(delivery, deliveryStatus);
+            }
+
+        }
+
+        JsonObject object = new JsonObject();
+
+        object.addProperty("code", 0);
+        object.addProperty("msg", "成功");
+        object.add("expInfo", array);
+        return object.toString();
+    }
+
+    /**
+     * 处理单号重复的快递
+     *
+     * @param expCode
+     * @param storeId
+     * @return 单子不存在返回null, 仅一单返回Delivery, 大于一单返回错误数据的JsonObject
+     * @throws java.sql.SQLException
+     */
+    private Object handleRepeatDelivery(String expCode, int storeId) {
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+
+        ArrayList<Integer> statusList = new ArrayList<>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+        qc.setStatusStr(statusList);
+
+        qc.setExpcode(expCode);
+        List<Delivery> deliveryList = deliveryService.getDelivery(qc);
+        if (deliveryList != null && !deliveryList.isEmpty()) {
+
+            if (deliveryList.size() == 1) {
+                return deliveryList.get(0);
+            }
+
+            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expCode);
+            dataObj.addProperty("reason", "单号重复");
+
+            JsonArray expArray = new JsonArray();
+            for (Delivery deli : deliveryList) {
+                JsonObject data = new JsonObject();
+                data.addProperty("expId", deli.getExpId());
+                ExpressType express = basicInfoService.getExpressById(deli.getExpId());
+                data.addProperty("expName", express.getExpName());
+                expArray.add(data);
+            }
+            dataObj.addProperty("data", expArray.toString());
+
+            return dataObj;
+        }
+        return null;
+    }
+
+    /**
+     * 添加状态流转记录
+     */
+    private DeliveryStatus addStatusHistory(int storeId, String staffName, int deliveryId, int status
+    		, int preStatus, String reason, String reasonDec) {
+        DeliveryStatus deliveryStatus = new DeliveryStatus();
+        deliveryStatus.setDeliveryId(deliveryId);
+        deliveryStatus.setProcessStaff(staffName);
+        deliveryStatus.setSource(Constants.CLIENT_TYPE_STORE_LITE_2);
+        deliveryStatus.setStatus(status);
+        deliveryStatus.setPreStatus(preStatus);
+        deliveryStatus.setUpdateTime(new Date());
+        deliveryStatus.setReasonCode(reason);
+        deliveryStatus.setRemark(reasonDec);
+        statusService.insert(storeId, deliveryStatus);
+        return deliveryStatus;
+    }
+}

+ 242 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/SmsCenterController.java

@@ -0,0 +1,242 @@
+package cn.haliaeetus.controller.deviceapi;
+
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.entity.dto.DeliveryDto;
+import cn.haliaeetus.entity.dto.QueryPageDto;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.toolkit.PagedList;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.SmsRecordService;
+import cn.haliaeetus.service.StoreShelfService;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONException;
+import net.sf.json.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+@Controller
+public class SmsCenterController extends BaseController {
+
+    @Autowired
+    private SmsRecordService smsRecordService;
+    @Autowired
+    private BasicInfoService infoService;
+    @Autowired
+    private StoreShelfService shelfService;
+
+    @Autowired
+    private DeliveryService deliveryService;
+
+    /**
+     * 短信中心查询
+     */
+    @RequestMapping("/device/smsCenter")
+    @ResponseBody
+    public Object smsCenter(HttpServletRequest request, HttpServletResponse response) throws ParseException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        String createTime = request.getParameter("createTime");
+        String status = request.getParameter("status");
+
+        String beginTime = createTime+" 00:00:00";
+        String endTime = createTime+" 23:59:59";
+
+        DeliveryQueryCondition qc = getDeliveryQueryCondition(user.getStoreId());
+        qc.setBeginTime(Timestamp.valueOf(beginTime));
+        qc.setEndTime(Timestamp.valueOf(endTime));
+
+        int pageSize=200;
+        int begin = (1 - 1) * pageSize;
+
+        qc.setP(1);
+        qc.setBegin(begin);
+
+        if(status.equals("全部")){
+            status="3";
+        }else if(status.equals("待发送")){
+            status="-1";
+        }else if(status.equals("发送失败")){
+            status="2";
+        }
+        qc.setSmsStatus(Integer.parseInt(status));
+        qc.setCreateTime(beginTime, endTime);
+
+        qc.setOrderField("createTime");
+        qc.setOrder("desc");
+        String subSql = "";
+        subSql +=  " and userPhone > ''  and odeliveryType<>'PS' ";
+        qc.setSubSql(subSql);
+
+        qc.setPageSize(pageSize);
+        List<Integer> statusList = new ArrayList<Integer>();
+        //只查在库单子
+        statusList.add(122);
+        //只查有手机号的单子
+        qc.setStatusStr(statusList);
+
+        QueryPageDto pageDto = deliveryService.getSmsFail4Page(qc);
+        PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
+
+        JsonObject object = new JsonObject();
+        JsonArray dJsonObject = new JsonArray();
+        if (deliveryPagedList.total==0) {
+            object.addProperty("code", -2);
+            object.addProperty("msg", "今日短信不存在");
+        } else {
+            object.addProperty("code", 0);
+            object.addProperty("msg", "");
+
+            for (int i=0;i<deliveryPagedList.total;i++) {
+                JsonObject jsonObject = new JsonObject();
+                jsonObject.addProperty("expId", deliveryPagedList.getItems().get(i).getDelivery().getExpId());
+                jsonObject.addProperty("expcode", deliveryPagedList.getItems().get(i).getDelivery().getExpcode());
+                jsonObject.addProperty("instoreTime", DateUtil.timestampFormat(deliveryPagedList.getItems().get(i).getDelivery().getCreateTime()));
+                jsonObject.addProperty("userPhone", _.trimToEmpty(deliveryPagedList.getItems().get(i).getDelivery().getUserPhone()));
+                jsonObject.addProperty("status", deliveryPagedList.getItems().get(i).getSmsStatus());
+                jsonObject.addProperty("id", deliveryPagedList.getItems().get(i).getDelivery().getId());
+                jsonObject.addProperty("storeId", user.getStoreId());
+
+                dJsonObject.add(jsonObject);
+            }
+        }
+
+        object.add("data", dJsonObject);
+        return object.toString();
+
+        //beginTime=format.format(beginTime);
+        //endTime=format.format(endTime);
+        /*if(status.equals("全部")){
+            status="-1";
+        }else if(status.equals("待发送")){
+            status="0";
+        }else if(status.equals("发送失败")){
+            status="2";
+        }
+
+        List<SmsRecord> smsRecordList = smsRecordService.getSmsCenterList(user.getStoreId(), Timestamp.valueOf(beginTime),Timestamp.valueOf(endTime),Integer.parseInt(status));
+
+        JsonObject object = new JsonObject();
+        JsonArray dJsonObject = new JsonArray();
+        if (smsRecordList.isEmpty()) {
+            object.addProperty("code", -2);
+            object.addProperty("msg", "今日短信不存在");
+        } else {
+            object.addProperty("code", 0);
+            object.addProperty("msg", "");
+
+            for (SmsRecord d : smsRecordList) {
+                JsonObject jsonObject = new JsonObject();
+                jsonObject.addProperty("expId", d.getExpid());
+                jsonObject.addProperty("expcode", d.getExpcode());
+                jsonObject.addProperty("instoreTime", DateUtil.timestampFormat(d.getCreatetime()));
+                jsonObject.addProperty("userPhone", _.trimToEmpty(d.getTelphone()));
+                jsonObject.addProperty("status", d.getStatus());
+                jsonObject.addProperty("id", d.getId());
+                jsonObject.addProperty("storeId", user.getStoreId());
+
+                dJsonObject.add(jsonObject);
+            }
+        }
+
+        object.add("data", dJsonObject);
+        return object.toString();*/
+
+    }
+
+
+    private DeliveryQueryCondition getDeliveryQueryCondition(int storeId) {
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
+        qc.setPageSize(20);
+        return qc;
+    }
+
+    /**
+     * 短信失败页面重发短信处理
+     *
+     * @param request 请求
+     * @return 处理结果
+     */
+    @RequestMapping("/device/reSendSms")
+    @ResponseBody
+    public Object reSendSMS(HttpServletRequest request, HttpServletResponse response) throws ParseException{
+        JsonObject object = new JsonObject();
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+        String deliveryIds="";
+        String jsonString = request.getParameter("data");
+        if(jsonString!=null && jsonString!=""){
+            JSONArray array = JSONArray.fromObject(jsonString);
+            for(int i=0;i<array.size();i++){
+                try {
+                    JSONObject job = array.getJSONObject(i);
+                    int id = job.getInt("id");
+                    deliveryIds = deliveryIds + "," +String.valueOf(id);
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                }
+            }
+
+        }
+
+        if (_.isEmpty(deliveryIds)) {
+            return buildJson(1, "请选择订单");
+        }
+
+        deliveryIds = deliveryIds.substring(1);
+        String[] ids = deliveryIds.split(",");
+
+        if ((user.getIsSmsFree() == null || user.getIsSmsFree() == Constants.NO)) {
+            int size = ids.length;
+            BigDecimal consume = calConsume(user.getSmsPrice(), size);
+            if((user.getSmsBalance() == null || user.getSmsBalance().compareTo(consume) <= 0)) {
+                object.addProperty("code", -1);
+                object.addProperty("msg", "发送失败");
+                return object.toString();
+            }
+        }
+        try {
+            deliveryService.resendSmsBatch(user, ids);
+            object.addProperty("code", 0);
+            object.addProperty("msg", "发送成功");
+        } catch (Exception e) {
+            buildJson(-1, "发送失败");
+        }
+
+        return object.toString();
+    }
+
+
+    private BigDecimal calConsume(BigDecimal smsPrice, int smsCount) {
+        if (smsPrice == null) {
+            return BigDecimal.ZERO;
+        }
+        return smsPrice.multiply(new BigDecimal(smsCount));
+    }
+
+}

+ 325 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/StoreInController.java

@@ -0,0 +1,325 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.framework.util.StringUtil;
+import cn.haliaeetus.service.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.store.helper.DeliveryInfo;
+import cn.haliaeetus.controller.store.helper.DeliveryMsgSendHelper;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.JsonUtil;
+
+@Controller
+public class StoreInController extends BaseController {
+    @Autowired
+    private DeliveryService deliveryService;
+    @Autowired
+    private StoreShelfService shelfService;
+    @Autowired
+    private FjDeliveryService fjDeliveryService;
+    @Autowired
+    private BasicInfoService basicInfoService;
+    @Autowired
+    private DeliveryStatusService statusService;
+    @Autowired
+   	private DeliveryMsgSendHelper messageSendHelper;
+    @Autowired
+    private DeliveryScanBatchService scanBatchService;
+
+    @RequestMapping("/device/onShelfScan")
+    @ResponseBody
+    public Object onShelfScan(HttpServletRequest request, HttpServletResponse response) throws SQLException,
+            IOException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(request.getParameter("data"));
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        List<DeliveryInfo> deliveryInfoList = new ArrayList<DeliveryInfo>();
+        while (it.hasNext()) {
+            JsonNode expInfo = it.next();
+
+            int expId = expInfo.findValue("expId").asInt();
+            String expCode = expInfo.findValue("expCode").asText();
+            int shelfId = expInfo.findValue("shelfId").asInt();
+
+            String shelfCode = null;
+            JsonNode codeNode = expInfo.findValue("shelfCode");
+            if (codeNode != null) shelfCode = codeNode.asText();
+
+            if (expId < 0 || shelfId == 0 || _.isEmpty(expCode)) {
+                continue;
+            }
+
+            expCode = expCode.trim();
+
+            JsonObject obj = inStore(user, expId, expCode, shelfId, shelfCode, deliveryInfoList);
+            if (obj != null) array.add(obj);
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.add("expInfo", array);
+        
+        // 短信发送方式为自动发送并且为付费模式
+        if (user.getSmsSendType() == null || user.getSmsSendType() == Constants.SMS_SEND_TYPE_AUTO) {
+			if ((user.getIsSmsFree() == null || user.getIsSmsFree() != Constants.YES) && _.isNotEmpty(deliveryInfoList)) {
+				messageSendHelper.asyncSendMsgAndDeduct(deliveryInfoList, user, Constants.SMS_CONSUME_BUSINESS_INSTORE);
+			}
+		}
+        return object.toString();
+    }
+
+    @RequestMapping("/device/shelfLeft")
+    @ResponseBody
+    public Object leftShelf(HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        String shelfIdString = request.getParameter("shelfId");
+        int shelfId = _.toInt(shelfIdString);
+        if (_.isEmpty(shelfIdString)) {
+            return buildJson(-1, "货架Id为空");
+        }
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        qc.setShelfId(shelfId);
+        ArrayList<Integer> statusList = new ArrayList<Integer>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+        qc.setStatusStr(statusList);
+        
+        List<Delivery> deliveries = deliveryService.getDelivery(qc);
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+
+        JsonArray array = new JsonArray();
+        for (Delivery d : deliveries) {
+            array.add(d.toJson());
+        }
+
+        object.add("expInfo", array);
+        return object.toString();
+    }
+
+    @RequestMapping("/device/transfer")
+    @ResponseBody
+    public Object removeDelivery(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(request.getParameter("data"));
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        while (it.hasNext()) {
+            JsonNode expInfo = it.next();
+            int isSendSms = (expInfo.findValue("isSendSms") == null) ? 0 : expInfo.findValue("isSendSms").asInt();
+            int shelfId = expInfo.findValue("shelfId").asInt();
+            String expCode = expInfo.findValue("expCode").asText();
+
+            if (_.isEmpty(expCode) || shelfId == 0) {
+                continue;
+            }
+
+            int expId = 0;
+            JsonNode expIdNode = expInfo.findValue("expId");
+            if (expIdNode != null) expId = expIdNode.asInt();
+
+            JsonObject obj = transferShelf(user, shelfId, expId, expCode, isSendSms);
+            if (obj != null) array.add(obj);
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.add("expInfo", array);
+        return object.toString();
+    }
+
+    /**
+     * 自提入库
+     */
+    private JsonObject inStore(User user, int expId, String expCode, int shelfId, String shelfCode, List<DeliveryInfo> deliveryInfoList) {
+    	JsonObject dataObj = new JsonObject();
+        Integer storeId = user.getStoreId();
+        StoreShelf storeShelf = shelfService.getById(shelfId);
+        if (storeShelf == null) {
+            
+            dataObj.addProperty("expCode", expCode);
+            dataObj.addProperty("reason", "货架不存在");
+            return dataObj;
+        }
+
+        String userPhone = "";
+        // 分拣中心快递类型
+        //2018-03-15所有都会去查询电话号码
+//        if (expId == Integer.MAX_VALUE) {
+//            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expCode);
+
+            List<FjDelivery> fjDeliveryList = fjDeliveryService.getByExpCode(storeId, expCode);
+//            if (fjDeliveryList == null || fjDeliveryList.isEmpty()) {
+//                dataObj.addProperty("reason", "没有分拣");
+//                return dataObj;
+//            }
+        if (null==fjDeliveryList||fjDeliveryList.isEmpty()) {
+            if (fjDeliveryList.size() > 1) {
+                dataObj.addProperty("reason", "分拣单号重复");
+                return dataObj;
+            }
+            userPhone ="";
+        }else {
+            userPhone = fjDeliveryList.get(0).getTelphone();
+        }
+            if (expId == Integer.MAX_VALUE){
+            expId = fjDeliveryList.get(0).getExpId();
+        }
+//        }
+        
+        DeliveryInfo deliveryInfo = null;
+        try {
+        	deliveryInfo = deliveryService.instoreDelivery(user, expCode, expId, shelfCode, shelfId, "", userPhone,
+                    Constants.CLIENT_TYPE_STORE_LITE_2, false);
+        	deliveryInfoList.add(deliveryInfo);
+        	Delivery d = deliveryInfo.getDelivery();
+            dataObj.addProperty("id", d.getId());
+            dataObj.addProperty("userPhone", d!=null?d.getUserPhone():"");
+
+            List<DeliveryScanBatch> scanBatches=scanBatchService.getByCondition(storeId, expCode, null, null,null,null);
+            if(scanBatches!=null&&scanBatches.size()>0){
+                //更新下车表里的快递公司、取货码、货架号
+                DeliveryScanBatch deliveryScanBatch = scanBatches.get(0);
+                DeliveryScanBatch dsb = new DeliveryScanBatch();
+                dsb.setStoreId(deliveryScanBatch.getStoreId());
+                dsb.setExpCode(deliveryScanBatch.getExpCode());
+//                deliveryScanBatch.setExpId(Integer.getInteger(expressId));
+                try{
+                    dsb.setExpId(new Integer(expId));}
+                catch (Exception e){
+
+                }
+                scanBatchService.updateByStoreAndExpCode(dsb);
+            }else{
+                DeliveryScanBatch scanBatch=new DeliveryScanBatch();
+                scanBatch.setExpCode(expCode);
+                scanBatch.setRevexpCode(StringUtil.stringReverse(expCode));
+                scanBatch.setExpId(expId);
+                scanBatch.setBatchNumber(0);
+                scanBatch.setStoreId(user.getStoreId());
+                scanBatch.setOperatorId(1);
+                scanBatch.setCreateTime(new Date());
+                scanBatch.setUserName("");
+                scanBatch.setUserPhone(userPhone);
+                scanBatch.setRevuserPhone(StringUtil.stringReverse(userPhone));
+                scanBatch.setChargeMoney(null);
+                scanBatch.setOcrStatus("0");
+                scanBatch.setOcrAmount("0");
+                scanBatch.setShelfCode("");
+                scanBatchService.insert(scanBatch);
+            }
+
+        } catch (Exception e) {
+//            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expCode);
+            dataObj.addProperty("reason", e.getMessage());
+            return dataObj;
+        }
+        
+        return dataObj;
+    }
+
+    /**
+     * 货架转移/派送返库
+     *
+     * @param user
+     */
+    public JsonObject transferShelf(User user, int shelfId, int expId, String expCode, int isSendSms) {
+    	Delivery oldDelivery = null;
+        if (expId == 0) {
+            DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+
+//            ArrayList<Integer> statusList = new ArrayList<>();
+//            statusList.add(Constants.ORDER_STATUS_STORED);
+//            statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+//            statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+//            qc.setStatusStr(statusList);
+
+            qc.setExpcode(expCode);
+            qc.setIsdel(0);
+            List<Delivery> deliveryList = deliveryService.getDelivery(qc);
+            if (_.isEmpty(deliveryList)) {
+            	 JsonObject dataObj = new JsonObject();
+                 dataObj.addProperty("expCode", expCode);
+                 dataObj.addProperty("reason", "单号不存在");
+                 return dataObj;
+            }
+            
+            if (deliveryList.size() > 1) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", "单号重复");
+
+                JsonArray expArray = new JsonArray();
+                for (Delivery deli : deliveryList) {
+                    JsonObject obj = new JsonObject();
+                    obj.addProperty("expId", deli.getExpId());
+                    ExpressType express = basicInfoService.getExpressById(deli.getExpId());
+                    obj.addProperty("expName", express.getExpName());
+                    expArray.add(obj);
+                }
+                dataObj.addProperty("data", expArray.toString());
+
+                return dataObj;
+            } 
+            
+            oldDelivery = deliveryList.get(0);
+        }
+
+        try {
+//            deliveryService.refuseDelivery(user.getStoreId(), shelfId, expCode, expId, 0, Constants.CLIENT_TYPE_STORE_LITE_2);
+        	deliveryService.transferOrPsInstore(user, oldDelivery, shelfId, isSendSms, Constants.CLIENT_TYPE_STORE_LITE_2);
+        } catch (Exception e) {
+            JsonObject dataObj = new JsonObject();
+            dataObj.addProperty("expCode", expCode);
+            dataObj.addProperty("reason", e.getMessage());
+            return dataObj;
+        }
+
+        return null;
+    }
+}

+ 40 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/StoreInfoController.java

@@ -0,0 +1,40 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework.base.controller.BaseController;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.sql.SQLException;
+
+
+@Controller
+public class StoreInfoController extends BaseController {
+
+	@RequestMapping("/device/storeInfo")
+	@ResponseBody
+	public Object getStoreInfo(HttpServletRequest request, HttpServletResponse response) throws SQLException {
+		
+		User user = getUserFromParam(request);
+		if( user == null ){
+			return buildJson(1,"用户未登录");
+		}
+		
+		JsonObject object = new JsonObject();
+		object.addProperty("code",0);
+		object.addProperty("msg", "");
+		object.addProperty("codeType", user.getCodeType());
+		object.addProperty("smsSendType", user.getSmsSendType());
+		object.addProperty("isSmsFree", user.getIsSmsFree());
+		object.addProperty("smsBalance", user.getSmsBalance());
+		object.addProperty("smsPrice", user.getSmsPrice());
+	
+		return object.toString();	
+	}
+}

+ 147 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/StoreOutController.java

@@ -0,0 +1,147 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import cn.haliaeetus.dao.DeliveryDao;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.ExpressType;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.P2pService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+@Controller
+public class StoreOutController extends BaseController {
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private P2pService p2pService;
+
+    @Autowired
+    private DeliveryDao deliveryDao;
+
+    @RequestMapping("/device/export")
+    @ResponseBody
+    public Object exportDelivery(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "用户未登录");
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(request.getParameter("data"));
+        if (jsonNode == null) return buildJson(-1, "参数错误");
+
+        JsonArray array = new JsonArray();
+        Iterator<JsonNode> it = jsonNode.iterator();
+        while (it.hasNext()) {
+            JsonNode expInfo = it.next();
+
+            int staffId = expInfo.findValue("staffId").asInt();
+            String expCode = expInfo.findValue("expCode").asText();
+
+            if (staffId == 0 || _.isEmpty(expCode)) {
+                continue;
+            }
+
+            int expId = 0;
+            JsonNode expIdNode = expInfo.findValue("expId");
+            if (expIdNode != null) expId = expIdNode.asInt();
+            if (expId <= 0) {
+                DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+                qc.setExpcode(expCode);
+
+                ArrayList<Integer> statusList = new ArrayList<>();
+                statusList.add(Constants.ORDER_STATUS_STORED);
+                statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
+                statusList.add(Constants.ORDER_STATUS_DISPATCHING);
+                statusList.add(Constants.ORDER_STATUS_MAIKE_DISPATCHING);
+                qc.setStatusStr(statusList);
+
+                qc.setIsdel(0);
+                List<Delivery> deliveryList = deliveryService.getDelivery(qc);
+                if (deliveryList != null) {
+                    if (deliveryList.size()>1) {
+                        JsonObject dataObj = new JsonObject();
+                        dataObj.addProperty("expCode", expCode);
+                        dataObj.addProperty("reason", "单号重复");
+
+                        JsonArray expArray = new JsonArray();
+                        for (Delivery deli : deliveryList) {
+                            JsonObject data = new JsonObject();
+                            data.addProperty("expId", deli.getExpId());
+                            ExpressType express = basicInfoService.getExpressById(deli.getExpId());
+                            data.addProperty("expName", express.getExpName());
+                            expArray.add(data);
+                        }
+                        dataObj.addProperty("data", expArray.toString());
+
+                        array.add(dataObj);
+                        continue;
+                    } else if (deliveryList.size() == 1) {
+                        expId = deliveryList.get(0).getExpId();
+                    }
+                }
+            }
+
+            try {
+                Delivery delivery = deliveryService.outStoreDelivery(user.getStoreId(),expId,expCode,staffId, Constants.CLIENT_TYPE_STORE_LITE_2);
+                //巴枪出库,调p2p接口取消麦客任务
+                // p2pService.p2pRequest(user.getStoreId(), expId, expCode, "post");  P2P干掉
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("expId", expId);
+                ExpressType express = basicInfoService.getExpressById(expId);
+                dataObj.addProperty("expName", express.getExpName());
+                dataObj.addProperty("userPhone", delivery.getUserPhone() == null ? "" : delivery.getUserPhone());
+                array.add(dataObj);
+            } catch (Exception e) {
+                JsonObject dataObj = new JsonObject();
+                dataObj.addProperty("expCode", expCode);
+                dataObj.addProperty("reason", e.getMessage());
+                array.add(dataObj);
+            }
+
+            //判断0代表入库时生成签收,1代表出库时生成签收
+            if(user.getSignFlag()==1){
+                // 新入库
+                DeliveryQueryCondition dqc = new  DeliveryQueryCondition(user.getStoreId());
+                dqc.setExp_code(expCode);
+                dqc.setStoreId(user.getStoreId());
+
+                deliveryDao.updateStoreOut(dqc);
+            }
+        }
+
+        JsonObject object = new JsonObject();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+        object.add("expInfo", array);
+
+        return object.toString();
+    }
+}

+ 51 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/StoreStaffController.java

@@ -0,0 +1,51 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.entity.StoreStaff;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.service.StoreStaffService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+
+@Controller
+public class StoreStaffController extends BaseController {
+
+    @Autowired
+    private StoreStaffService staffService;
+
+    @RequestMapping("/device/storeStaff")
+	@ResponseBody
+	public Object getStoreStaff(HttpServletRequest request, HttpServletResponse response) {
+		
+		User user = getUserFromParam(request);
+		if( user == null ){
+			return buildJson(1,"用户未登录");
+		}
+		
+		List<StoreStaff> allStoreStaffs = staffService.getByStoreId(user.getStoreId());
+		JsonObject object = new JsonObject();
+		object.addProperty("code",0);
+		object.addProperty("msg", "");
+		
+		JsonArray array = new JsonArray();
+		
+		for (StoreStaff e : allStoreStaffs) {
+			array.add(e.toJson());
+		}
+		
+		object.add("deliveryStaff", array);
+	
+		return object.toString();
+	}
+}

+ 159 - 0
express-main/src/main/java/cn/haliaeetus/controller/deviceapi/TakePadController.java

@@ -0,0 +1,159 @@
+package cn.haliaeetus.controller.deviceapi;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.entity.StoreShelf;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.toolkit.MyExecutor;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryService;
+import cn.haliaeetus.service.PrinterService;
+import cn.haliaeetus.service.StoreShelfService;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 取货平板接口
+ */
+@Controller
+public class TakePadController extends BaseController {
+
+    private static final Logger log = LoggerFactory.getLogger(TakePadController.class);
+
+    @Autowired
+    private DeliveryService deliveryService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private PrinterService printerService;
+
+    @Autowired
+    private StoreShelfService shelfService;
+
+    @RequestMapping("/device/takeDelivery")
+    @ResponseBody
+    public Object takeDelivery(HttpServletRequest request, HttpServletResponse response) throws SQLException {
+        log.info("TakePadController.takeDelivery.start");
+        long now = System.currentTimeMillis();
+        User user = getUserFromParam(request);
+        // final User user=User.getById("xm00001");
+        if (user == null) {
+            user = getFromCookie(request);
+            // return buildJson(1, "用户未登录");
+            if (user == null) {
+                log.info("TakePadController.takeDelivery.nologin");
+                log.info("bs2.balance.deviceTakeDelivery.time:" + (int) (System.currentTimeMillis() - now));
+                return buildJson(1, "用户未登录");
+            }
+        }
+        
+        String userPhone = request.getParameter("userPhone");
+        String shelfCode = request.getParameter("shelfCode");
+        String expCode = request.getParameter("expCode");
+        
+        if (_.isEmpty(userPhone) && _.isEmpty(shelfCode) && _.isEmpty(expCode)) {
+            log.info("bs2.balance.deviceTakeDelivery.time:" + (int) (System.currentTimeMillis() - now));
+            return buildJson(1, "手机号码、取货码或者单号为空");
+        }
+
+
+        JsonObject object = new JsonObject();
+        JsonArray array = new JsonArray();
+        object.addProperty("code", 0);
+        object.addProperty("msg", "");
+
+        DeliveryQueryCondition qc = new DeliveryQueryCondition(user.getStoreId());
+        
+        if(_.isNotEmpty(userPhone)){
+        	qc.setUserPhone(userPhone);
+        }else if(_.isNotEmpty(shelfCode)){
+        	qc.setShelfCode(shelfCode);
+        }else if(_.isNotEmpty(expCode)){
+        	qc.setExpcode(expCode);
+        }
+        
+        ArrayList<Integer> statusList = new ArrayList<Integer>();
+        statusList.add(Constants.ORDER_STATUS_STORED);
+        qc.setStatusStr(statusList);
+        List<Delivery> deliveryList = deliveryService.getDelivery(qc);
+        if (deliveryList == null) {
+            log.info("bs2.balance.deviceTakeDelivery.time:" + (int) (System.currentTimeMillis() - now));
+            return object.toString();
+        }
+
+        int i = 0;
+        final StringBuffer ids = new StringBuffer();
+        int size = deliveryList.size();
+        for (Delivery delivery : deliveryList) {
+            if (delivery.getShelfId() == 0) {
+                continue;
+            }
+            array.add(toJson(delivery));
+            ids.append(delivery.getId());
+            if (i < (size - 1)) {
+                ids.append(",");
+            }
+            i++;
+        }
+        object.add("expInfo", array);
+
+        // 调用打印任务
+        final String userid = user.getUserId();
+        if (ids.length() > 0) {
+            MyExecutor.instance().submit("device.takePad", new Runnable() {
+                public void run() {
+                printerService.pushPrint(ids.toString(), 0, userid);
+                }
+            });
+        }
+
+        log.info("bs2.balance.deviceTakeDelivery.time:" + (int) (System.currentTimeMillis() - now));
+        log.info("bs2.balance.deviceTakeDelivery.storeid:" + user.getStoreId());
+        return object.toString();
+    }
+
+    private JsonElement toJson(Delivery delivery) {
+        JsonObject jsonObject = new JsonObject();
+
+        jsonObject.addProperty("expId", delivery.getExpId());
+        jsonObject.addProperty("expCode", delivery.getExpcode());
+
+        jsonObject.addProperty("shelfId", delivery.getShelfId());
+        jsonObject.addProperty("shelfCode", delivery.getShelfCode());
+
+        StoreShelf storeShelf = shelfService.getById(delivery.getShelfId());
+        jsonObject.addProperty("shelfName", storeShelf==null?"":storeShelf.getShelfName());
+
+        /*try {
+            ExpressType express = basicInfoService.getExpressById(delivery.getExpId());
+            if (express != null) jsonObject.addProperty("expName", _.trimToEmpty(express.getExpName()));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }*/
+
+        jsonObject.addProperty("userName", _.trimToEmpty(delivery.getUserName()));
+        jsonObject.addProperty("userPhone", _.trimToEmpty(delivery.getUserPhone()));
+
+        return jsonObject;
+    }
+}

+ 621 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduate/GraduateController.java

@@ -0,0 +1,621 @@
+package cn.haliaeetus.controller.graduate;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.controller.util.APIConfig;
+import cn.haliaeetus.controller.web.helper.ReceivedWechatPayHelper;
+import cn.haliaeetus.entity.ExpressType;
+import cn.haliaeetus.entity.GraduateRule;
+import cn.haliaeetus.entity.ReceivedAppointment;
+import cn.haliaeetus.entity.ReceivedWechat;
+import cn.haliaeetus.entity.Store;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.base.crawler.Crawler;
+import cn.haliaeetus.framework.base.digt.EscapeUtil;
+import cn.haliaeetus.framework.base.log.Logger;
+import cn.haliaeetus.framework.util.ComputeUtil;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.framework.util.SMSUtil;
+import cn.haliaeetus.framework.util.ServletUtils;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.GraduateRuleService;
+import cn.haliaeetus.service.ReceivedAppointmentService;
+import jxl.SheetSettings;
+import jxl.Workbook;
+import jxl.format.Alignment;
+import jxl.format.Colour;
+import jxl.format.VerticalAlignment;
+import jxl.write.Label;
+import jxl.write.WritableCellFormat;
+import jxl.write.WritableFont;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
+
+@Controller
+@RequestMapping("/graduate")
+public class GraduateController extends BaseController {
+    private static final Logger LOG = Logger.getInstance(GraduateController.class);
+
+    public static final String WX_APP_ID = "wx35a8b3f8507f4ea6";
+    public static final String COOKIE_OPEN_ID = "haliaeetus_open_id";
+    public static final String COOKIE_STORE_ID = "graduate_store_id";
+    @Autowired
+    private GraduateRuleService graduateRuleService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private ReceivedAppointmentService appointmentService;
+
+    @Autowired
+    private ReceivedWechatPayHelper wechatPayHelper;
+    
+    
+    
+
+    @RequestMapping("/index")
+    public Object index(HttpServletRequest request, HttpServletResponse response,//
+                        @RequestParam(defaultValue = "0") int storeid) {
+        GraduateRule rule = graduateRuleService.getByStoreId(storeid);
+        if (rule != null) {
+            request.setAttribute("collegeName", rule.getCollegeName());
+            request.setAttribute("storeId", rule.getStoreId());
+        }
+        return "graduate/b_index";
+    }
+
+
+    @RequestMapping("/select_college")
+    public Object selectSchool(HttpServletRequest request,HttpServletResponse response) {
+        List<GraduateRule> rule = graduateRuleService.getCollage();
+        Map<String,List<String>> collegeMap = new LinkedHashMap<>();
+        for (GraduateRule r : rule) {
+            if(!collegeMap.containsKey(r.getCityName())){
+                ArrayList collegeList = new ArrayList<>();
+                JsonObject obj = new JsonObject();
+                obj.addProperty("storeId",r.getStoreId());
+                obj.addProperty("collegeName",r.getCollegeName());
+                collegeList.add(obj);
+                collegeMap.put(r.getCityName(),collegeList);
+            }else{
+                List<String> collegeList = collegeMap.get(r.getCityName());
+                JsonObject obj = new JsonObject();
+                obj.addProperty("storeId",r.getStoreId());
+                obj.addProperty("collegeName",r.getCollegeName());
+                collegeList.add(obj.toString());
+            }
+        }
+
+        request.setAttribute("collegeMap", collegeMap);
+
+        return "graduate/b_college";
+    }
+
+    @RequestMapping("/appointment")
+    @ResponseBody
+    public Object appointment(HttpServletRequest request,HttpServletResponse response,//
+                              @RequestParam(defaultValue = "0") int s) throws Exception {
+        GraduateRule graduateRule = graduateRuleService.getByStoreId(s);
+
+        if(graduateRule==null) {
+            return buildJson(-1,"请先选择学校");
+        }
+
+        Date today = new Date();
+        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
+        Date startTime = graduateRule.getAppointmentStartTime();
+        if(format.format(today).compareTo(format.format(startTime))<0) {
+            return buildJson(-3,"预约还没有开始,开始时间: "+ DateUtil.dateFormatCN(startTime));
+        }
+
+        Date endTime = graduateRule.getAppointmentEndTime();
+        endTime.setHours(15);
+        endTime.setMinutes(0);
+        endTime.setSeconds(0);
+        if(format.format(today).compareTo(format.format(endTime))>0) {
+            return buildJson(-3,"来晚啦, 预约已经结束了~");
+        }
+
+        if (graduateRule.getCurrCount() >= graduateRule.getLimitCount()) {
+            return buildJson(-3,"来晚啦, 预约名额已满了~");
+        }
+
+        //获取openid
+        String openId = ServletUtils.getCookie(request, COOKIE_OPEN_ID);
+        ServletUtils.clearCookie(response, COOKIE_OPEN_ID, "/", "..haliaeetus.cn");
+        log.info("graduate.appointment openId at cookie:" + openId);
+
+        //如果cookie中没有openid, 通过appid调用微信授权接口获取openid
+        if(openId == null) {
+            String urlmall = EscapeUtil.encUtf8("http://weixin..haliaeetus.cn/oauth/redirect");
+            String redirect_uri = APIConfig.getWechatPayShareUrlOfGraduate()+"?storeid=" + s + "&o=t";
+            JsonObject params = new JsonObject();
+            params.addProperty("url", redirect_uri);
+            params.addProperty("type", "base");
+            String state = EscapeUtil.encUtf8(params.toString());
+            String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + WX_APP_ID + "&redirect_uri=" +
+                    urlmall + "&response_type=code&scope=snsapi_base&state="+state+"#wechat_redirect";
+            return buildJson(-2, "没有openid",url);
+        }
+
+        //获取用户信息
+        int userId = basicInfoService.getUserIdByWxOpenId(openId);
+        if (userId == 0) {
+            ServletUtils.setCookie(response, COOKIE_STORE_ID, s+"");
+            return buildJson(-2, "用户未绑定","/graduate/bind");
+        }
+
+        ReceivedAppointment appointment = appointmentService.getByUserId(userId);
+        if (appointment != null) {
+            Map<String, Object> data = new HashMap<>();
+            data.put("collegeName", appointment.getCollegeName());
+            data.put("userId", userId);
+            return buildJson(-4, "用户已预约", data);
+        }
+
+        log.info("校验和绑定通过, 开始预支付.");
+        String payResult = wechatPayHelper.payReceivedAppointmentOrder(openId, userId, graduateRule.getCollegeName(), getIp(request));
+        if (_.isEmpty(payResult)) {
+            return buildJson(-1, "预支付失败");
+        }
+
+        JsonNode resultNode = JsonUtil.parse(payResult);
+        if (resultNode == null) {
+            return buildJson(-1, "预支付失败");
+        }
+
+        int code = resultNode.findValue("code") == null ? 0 : resultNode.findValue("code").asInt();
+        if (code != 0) {
+            return buildJson(-1, "预支付失败");
+        }
+
+        JsonNode dataNode = resultNode.get("data");
+
+        Map<String, Object> data = new HashMap<>();
+        data.put("collegeName", graduateRule.getCollegeName());
+        data.put("userId", userId);
+        data.put("prePayData", dataNode);
+        return buildJson(0, "预支付成功", data);
+    }
+
+    @RequestMapping("/appointmentSuccess")
+    public Object appointmentSuccess(HttpServletRequest request, //
+                                     @RequestParam(defaultValue = "0") int userid,
+                                     @RequestParam(defaultValue = "") String collegename) throws Exception {
+        Map<String, String> userInfo = basicInfoService.getUserInfoById(userid);
+
+        String mobilephone = userInfo.get("mobilePhone");
+        ReceivedAppointment appointment = appointmentService.getByMobilephone(mobilephone);
+        request.setAttribute("appointment", appointment);
+
+        GraduateRule graduateRule = graduateRuleService.getByCollegeName(collegename);
+        request.setAttribute("rule", graduateRule);
+
+        request.setAttribute("msg", "预约成功啦!");
+        return "graduate/b_yueSucc";
+    }
+
+    @RequestMapping(value = "/checkAppointment", method = {RequestMethod.GET, RequestMethod.POST})
+    @ResponseBody
+    public Object checkAppointment(@RequestParam(defaultValue = "") int userId) throws Exception {
+        ReceivedAppointment appointment = appointmentService.getByUserId(userId);
+        if (appointment == null) {
+            return buildJson(-1, "未预约");
+        } else {
+            return buildJson(0, "已预约");
+        }
+    }
+
+    @RequestMapping("/wx_shared")
+    @ResponseBody
+    public Object appointmentSuccess(HttpServletRequest request,@RequestParam(defaultValue = "") String url) {
+        log.debug("wx_shared, wechatjsapi config url = "+url);
+        JsonObject json = new JsonObject();
+        json.addProperty("jsAPIConfig", getWechatJSAPIConfig(url).toString());
+        json.addProperty("shareURL", APIConfig.getWechatPayShareUrlOfGraduate());
+        return json.toString();
+    }
+
+
+    private JSONObject getWechatJSAPIConfig(String shareURL) {
+        JSONObject jsonParams = new JSONObject();
+        jsonParams.put("url", shareURL);
+
+        String url = APIConfig.getWechatJSAPIConfigUrl();
+        Pair<Integer, String> result = Crawler.of("wechat.jsapi.config", 300, 5000).post(url, jsonParams.toString(), _.charsetUtf8);
+        LOG.record(_.f("Get wechat js api config, URL: %s, Params: %s, Response: [%s, %s].", url, jsonParams, result.getLeft(), result.getRight()));
+
+        JSONObject jsonResp = JSON.parseObject(result.getRight());
+        if (jsonResp == null) {
+            return null;
+        }
+
+        Integer code = jsonResp.getInteger("code");
+        if (code == null || code != 0) {
+            return null;
+        }
+
+        JSONObject jsonData = jsonResp.getJSONObject("data");
+        if (jsonData == null) {
+            return null;
+        }
+        return jsonData;
+    }
+
+    @RequestMapping("/appointment_failed")
+    public Object appointmentFailed(HttpServletRequest request) {
+        return "graduate/b_yueFailed";
+    }
+
+    @RequestMapping("/wx_notify")
+    @ResponseBody
+    public Object wxnotify(HttpServletRequest request) throws Exception {
+        String data = getDataFromRequest(request);
+        log.debug("Received appointment wechat pay notify, data: {}.", data);
+
+        if (_.isEmpty(data)) {
+            return buildErrJson("Empty request data.");
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(data);
+        String payStatus = jsonNode.findValue("payStatus").asText();
+        if (!"TRADE_SUCCESS".equals(payStatus)) {
+            return buildErrJson("Empty transactionId.");
+        }
+
+        String outId = jsonNode.findValue("outId").asText();
+        int userId = Integer.parseInt(outId.split(",")[0]);
+        String collegeName = outId.split(",")[1];
+
+        Map<String, String> userInfo = basicInfoService.getUserInfoById(userId);
+        String mobilephone = userInfo.get("mobilePhone");
+
+        //更新预约个数
+        GraduateRule graduateRule = graduateRuleService.getByCollegeName(collegeName);
+        graduateRule.setCurrCount(graduateRule.getCurrCount() + 1);
+        graduateRuleService.update(graduateRule);
+
+        //预约
+        ReceivedAppointment appointment = new ReceivedAppointment();
+        appointment.setUserId(userId);
+        appointment.setCollegeName(graduateRule.getCollegeName());
+        appointment.setMobilephone(mobilephone);
+        appointment.setWechatUsername("");
+        appointment.setWechatPayId(0);
+        appointmentService.save(appointment);
+
+        return buildJson(0, "Success");
+    }
+
+    @RequestMapping("/bind")
+    public Object bind(HttpServletRequest request){
+        return "graduate/b_bind";
+    }
+
+    @RequestMapping("/send_smsCode")
+    @ResponseBody
+    public Object sendSmsCode(HttpServletRequest request,//
+                             @RequestParam(defaultValue = "") String telphone) throws IOException {
+        if(_.isEmpty(telphone)){
+            return buildErrJson(-1, "参数错误");
+        }
+
+        String smsCode = basicInfoService.getSmsCode(telphone);
+        log.info("graduate.getSmsCode return :" + smsCode);
+
+        String content = "欢迎参加佰颂物联毕业季.免费寄活动,您获取到的验证码为:"+smsCode+"【佰颂物联】";
+        String result = SMSUtil.sendSMSText(telphone, content, "graduate", SMSUtil.CHANNEL_BF);
+        log.info("graduate.sendSmsCode return :" + result);
+
+        return buildJson(0, "成功");
+    }
+
+    @RequestMapping("/check_smsCode")
+    @ResponseBody
+    public Object checkSmsCode(HttpServletRequest request,//
+                               @RequestParam(defaultValue = "") String smsCode, //
+                             @RequestParam(defaultValue = "") String telphone) throws IOException {
+        if(_.isEmpty(telphone) || _.isEmpty(smsCode)){
+            return buildJson(-1, "参数错误");
+        }
+
+        boolean succ = basicInfoService.checkSmsCode(telphone, smsCode);
+        if(succ){
+            return buildJson(0, "成功");
+        }
+        return buildJson(-1, "短信校验失败");
+    }
+
+    @RequestMapping("/bind_phone")
+    public void bindPhone(HttpServletRequest request, HttpServletResponse response, //
+                            @RequestParam(defaultValue = "") String telphone) throws IOException {
+        String urlmall = EscapeUtil.encUtf8("http://weixin..haliaeetus.cn/oauth/redirect");
+
+        String basePath = request.getScheme()+"://"+request.getServerName();
+        String redirect_uri = basePath+"/graduate/b_n?t="+telphone;
+        log.info("绑定用户, 访问微信授权, redirect_uri : " + redirect_uri);
+
+        JsonObject params = new JsonObject();
+        params.addProperty("url", redirect_uri);
+        params.addProperty("type", "user_info");
+        String state = EscapeUtil.encUtf8(params.toString());
+
+        String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + WX_APP_ID + "&redirect_uri=" +
+                urlmall + "&response_type=code&scope=snsapi_userinfo&state="+state+"#wechat_redirect";
+        //response.sendRedirect(url);
+        log.info("跳转微信授权页面, url : " + url + " , stateLength=" + state.length());
+
+        response.sendRedirect(url);
+    }
+
+    @RequestMapping("/b_n")
+    public Object bindNotify(HttpServletRequest request, HttpServletResponse response, //
+                            @RequestParam(defaultValue = "") String nickname, //
+                            @RequestParam(defaultValue = "") String headimgurl, //
+                            @RequestParam(defaultValue = "") String sex, //
+                            @RequestParam(defaultValue = "") String t) throws IOException {
+
+        String openId = ServletUtils.getCookie(request, COOKIE_OPEN_ID);
+        ServletUtils.clearCookie(response, COOKIE_OPEN_ID, "/", "..haliaeetus.cn");
+
+        // --------------- 预绑定 ------------------ //
+        int storeId = _.toInt(ServletUtils.getCookie(request, COOKIE_STORE_ID));
+        ServletUtils.clearCookie(response, COOKIE_STORE_ID);
+
+        GraduateRule graduateRule = graduateRuleService.getByStoreId(storeId);
+        Store store = basicInfoService.getStoreById(storeId);
+        int userId = basicInfoService.userInit4wx(openId, nickname, sex, headimgurl);
+        log.info("预绑定用户, userid=" + userId+", storeId="+store.getCollegeId()+", telphone="+t);
+
+        // --------------- 绑定用户 ------------------- //
+        userId = basicInfoService.userBind4wx(openId, t, store.getCollegeId(), "0", "");
+        if(userId<=0){
+            log.error("绑定用户, userid : " + userId);
+        }else{
+            log.info("绑定用户成功, userid : " + userId);
+            request.setAttribute("bind_succ", true);
+        }
+
+        request.setAttribute("collegeName", graduateRule.getCollegeName());
+        request.setAttribute("storeId", storeId);
+        return "graduate/b_index";
+    }
+    @RequestMapping("/statlist")
+	public Object statlist(HttpServletRequest request) {
+		User user = requireLogin(request);
+		request.setAttribute("startDate",DateUtil.dateFormat(new Date()));
+		request.setAttribute("endDate",DateUtil.dateFormat(new Date()));
+		if (user == null) {
+			return "redirect:/login";
+		}
+		return "graduate/statlist";
+	}
+
+	@RequestMapping("/export")
+	@ResponseBody
+	public Object export(
+			HttpServletRequest request,
+			HttpServletResponse response,
+			@RequestParam(defaultValue = "") String type, //
+			@RequestParam(defaultValue = "") String startDate,
+			@RequestParam(defaultValue = "") String endDate,
+			@RequestParam(defaultValue = "") int  storeId
+			) {
+		User user = requireLogin(request);
+		if (user == null)
+			return buildJson(-1, "登录超时,请重新登录~");
+		if ("1".equals(type)) {// 导出预约量
+			List<GraduateRule> rules = graduateRuleService.getCollage();
+			List<String> columns = new ArrayList<String>();
+			columns.add("序号");
+			columns.add("城市");
+			columns.add("学校名称");
+			columns.add("门店代码");
+			columns.add("已预约量");
+			columns.add("预约限额");
+			columns.add("活动开始时间");
+			columns.add("活动结束时间");
+			List<String[]> cellList = new ArrayList<>();
+			int index = 1;
+			for (GraduateRule rule : rules) {
+				String[] cells = new String[] { String.valueOf(index++),
+						rule.getCityName(), rule.getCollegeName(),
+						String.valueOf(rule.getStoreId()),
+						String.valueOf(rule.getCurrCount()),
+						String.valueOf(rule.getLimitCount()),
+						DateUtil.dateFormat(rule.getActivityStartTime()),
+						DateUtil.dateFormat(rule.getActivityEndTime())
+						
+				};
+				cellList.add(cells);
+			}
+			exporExcel(response, "预约量导出.xls", cellList, "预约量导出", columns);
+
+		} else if ("2".equals(type)) {// 导出明细
+			if(storeId>0){
+				startDate=DateUtil.dateFormat(new Date());
+				endDate=DateUtil.dateFormat(new Date());
+			}
+			Map<Integer, Store> storeMap = basicInfoService.getAllStore();
+			Map<Integer, ExpressType> expMap = basicInfoService.getAllExpress();
+			
+			List<ReceivedWechat> wechats = graduateRuleService
+					.getReceivedByWechat(startDate, endDate,storeId);
+			List<String> columns = new ArrayList<String>();
+			columns.add("序号");
+			columns.add("学校");
+			columns.add("门店");
+			columns.add("目的城市");
+			columns.add("快递公司名称");
+			columns.add("运单号");
+			columns.add("手机号");
+			columns.add("重量(kg)");
+			columns.add("应付金额");
+			columns.add("优惠金额");
+			columns.add("实付金额");
+			columns.add("交易时间");
+
+			List<String[]> cellList = new ArrayList<>();
+			int index = 1;
+			for (ReceivedWechat wechat : wechats) {
+				Store store = storeMap.get(wechat.getStoreId());
+				ExpressType exp = expMap.get(wechat.getExpid());
+				String expName="";
+				if(exp!=null){
+					expName=_.isEmpty(exp.getExpName())?"":exp.getExpName();
+				}
+				String storeName="";
+				if(store!=null){
+					storeName=_.isEmpty(store.getName())?"":store.getName();
+				}
+				String[] cells = new String[] {
+						String.valueOf(index++),
+						wechat.getCollege_name(),
+						storeName,
+						wechat.getProvinceName(),
+						expName,
+						wechat.getExpcode(),
+						wechat.getMobilephone(),
+						wechat.getWeight(),
+						String.valueOf(ComputeUtil.parseToDouble(wechat
+								.getMoney())),
+						String.valueOf(ComputeUtil.parseToDouble(wechat
+								.getPromotionMoney())),
+						String.valueOf(ComputeUtil.parseToDouble(wechat
+								.getPayMoney())),
+						DateUtil.timestampFormat(wechat.getCreateTime()) };
+				cellList.add(cells);
+			}
+			exporExcel(response, "揽件明细导出.xls",
+					cellList, "揽件明细导出", columns);
+
+		}
+		return buildJson(0, "导出完成");
+	}
+
+	/**
+	 * 导出滞留件信息
+	 */
+	private static void exporExcel(HttpServletResponse response,
+			String filename, List<String[]> cellList, String sheetName,
+			List<String> columns) {
+		WritableWorkbook book = null;
+		OutputStream os = null;
+		try {
+			response.reset();
+			os = response.getOutputStream();
+			// 调用上面的方法、生成Excel文件
+			response.setContentType("application/vnd.ms-excel");
+			response.setHeader("Content-Disposition", "attachment;filename="
+					+ new String(filename.getBytes("utf-8"), "iso8859-1"));
+			book = Workbook.createWorkbook(os);
+			// 生成名为“第一页”的工作表,参数0表示这是第一页
+			WritableSheet ws = book.createSheet(sheetName, 0);
+			SheetSettings ss = ws.getSettings();
+			ss.setVerticalFreeze(1); // 设置行冻结表头
+
+			WritableFont font1 = new WritableFont(
+					WritableFont.createFont("微软雅黑"), 10, WritableFont.BOLD);
+			WritableFont font2 = new WritableFont(
+					WritableFont.createFont("微软雅黑"), 9, WritableFont.NO_BOLD);
+			WritableCellFormat wcf = new WritableCellFormat(font1);
+			WritableCellFormat wcf2 = new WritableCellFormat(font2);
+			WritableCellFormat wcf3 = new WritableCellFormat(font2);// 设置样式,字体
+
+			// wcf2.setBackground(Colour.LIGHT_ORANGE);
+			wcf.setAlignment(Alignment.CENTRE); // 平行居中
+			wcf.setVerticalAlignment(VerticalAlignment.CENTRE); // 垂直居中
+			wcf3.setAlignment(Alignment.CENTRE); // 平行居中
+			wcf3.setVerticalAlignment(VerticalAlignment.CENTRE); // 垂直居中
+			wcf3.setBackground(Colour.LIGHT_ORANGE);
+			wcf2.setAlignment(Alignment.CENTRE); // 平行居中
+			wcf2.setVerticalAlignment(VerticalAlignment.CENTRE); // 垂直居中
+
+			wcf.setAlignment(Alignment.CENTRE);
+
+			// 判断一下表头数组是否有数据
+			if (columns != null && columns.size() > 0) {
+
+				// 循环写入表头
+				for (int i = 0; i < columns.size(); i++) {
+					ws.addCell(new Label(i, 0, columns.get(i), wcf));
+				}
+				int conut = 1;
+				for (String[] cells : cellList) { // 循环一个list里面的数据到excel中
+					int index = 0;
+					for (String cell : cells) {
+						ws.addCell(new Label(index++, conut, cell, wcf2));
+					}
+					/*
+					 * ws.addCell(new Label(0,
+					 * conut,deliveryList.get(i).getExpress().getExpName(),
+					 * wcf2)); ws.addCell(new Label(1, conut,
+					 * deliveryList.get(i).getDelivery().getExpcode(), wcf2));
+					 * String
+					 * userName=deliveryList.get(i).getDelivery().getUserName
+					 * ()==
+					 * null?"":deliveryList.get(i).getDelivery().getUserName();
+					 * ws.addCell(new Label(2, conut, userName+ " " +
+					 * deliveryList.get(i).getDelivery().getUserPhone(), wcf2));
+					 * ws.addCell(new Label(3,
+					 * conut,(double)deliveryList.get(i).
+					 * getDelivery().getChargeMoney()/100+"", wcf2));
+					 * ws.addCell(new Label(4, conut,
+					 * deliveryList.get(i).getDelivery().getRemark(),wcf2));
+					 */
+					ws.setRowView(conut, 370); // 设置第一行的高度
+					conut++;
+				}
+			}
+			// 写入数据并关闭文件
+			book.write();
+			os.flush();
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				if (book != null) {
+					book.close();
+				}
+				if (os != null) {
+					// 关闭流
+					os.close();
+					os = null;
+				}
+				response.flushBuffer();
+			} catch (Exception e) {
+
+			}
+		}
+	}
+    
+    
+}

+ 329 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduate/ReceivedPayController.java

@@ -0,0 +1,329 @@
+package cn.haliaeetus.controller.graduate;
+
+import com.alibaba.fastjson.JSON;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.github.stuxuhai.jpinyin.PinyinHelper;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.web.helper.ReceivedWechatPayHelper;
+import cn.haliaeetus.entity.*;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.util.ComputeUtil;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.framework.util.JsonUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.GraduateRuleService;
+import cn.haliaeetus.service.ReceivedAppointmentService;
+import cn.haliaeetus.service.ReceivedWechatPayService;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Controller
+public class ReceivedPayController extends BaseController {
+    @Autowired
+    private ReceivedWechatPayService receivedWechatPayService;
+
+    @Autowired
+    private BasicInfoService basicInfoService;
+
+    @Autowired
+    private ReceivedAppointmentService receivedAppointmentService;
+
+    @Autowired
+    private ReceivedWechatPayHelper receivedWechatPayHelper;
+
+    @Autowired
+    private GraduateRuleService graduateRuleService;
+
+    @RequestMapping("/biyeji")
+    public String initWechatpay(HttpServletRequest request) throws Exception {
+        User user = getFromCookie(request);
+        if (user == null) {
+            return "login_page";
+        }
+
+        GraduateRule rule = graduateRuleService.getByStoreId(user.getStoreId());
+        if (rule == null) {
+            request.setAttribute("msg", "门店未开通毕业季活动~");
+            return "graduate/error";
+        }
+
+        // 快递信息
+        List<ExpressType> storeExpress = new ArrayList<>();
+        Map<Integer, List<ExpressType>> storeExpressMap = basicInfoService.getExpressByStoreId(user.getStoreId());
+        if (_.isNotEmpty(storeExpressMap)) {
+            storeExpress = storeExpressMap.get(2);
+        }
+        request.setAttribute("expresses", storeExpress);
+
+        // 省份信息
+        List<Province> provinces = basicInfoService.getProvinceRemoteService();
+        request.setAttribute("provinces", JSON.toJSONString(generateProvinceVOList(provinces)));
+
+        return "graduate/received";
+    }
+
+    private List<Map<String, String>> generateProvinceVOList(List<Province> provinces) {
+        List<Map<String, String>> provinceVOList = new ArrayList<>();
+        if (_.isNotEmpty(provinces)) {
+            for (Province province : provinces) {
+                Map<String, String> provinceVO = new HashMap<>();
+                provinceVO.put("name", province.getName());
+                provinceVO.put("pinyin", PinyinHelper.getShortPinyin(province.getName()));
+                provinceVOList.add(provinceVO);
+            }
+        }
+        return provinceVOList;
+    }
+
+    @RequestMapping("/biyeji/paylist")
+    public String loadPayList(HttpServletRequest request) throws Exception {
+        User user = requireLogin(request);
+        request.setAttribute("user", user);
+
+        List<ReceivedWechatPay> receivedWechatPayList = receivedWechatPayService.getTodayTopN(user.getStoreId(), 10);
+        List<Map<String, String>> receivedVOList = generateReceivedVOList(user.getStoreId(), receivedWechatPayList);
+
+        request.setAttribute("list", receivedVOList);
+        request.setAttribute("countData", calcCountData(receivedVOList));
+        return "graduate/pay_list";
+    }
+
+    private Map<String, Object> calcCountData(List<Map<String, String>> receivedVOList) {
+        Map<String, Object> countData = new HashMap<>();
+        countData.put("total", receivedVOList.size());
+
+        double money = 0;
+        for (Map<String, String> receivedVO : receivedVOList) {
+            try {
+                money += Double.parseDouble(_.trimToEmpty(receivedVO.get("payMoney")));
+            } catch (NumberFormatException ex) {
+                ex.printStackTrace();
+            }
+        }
+        countData.put("money", money);
+
+        return countData;
+    }
+
+    @RequestMapping("/biyeji/queryAppointment")
+    public @ResponseBody Object queryAppointment(HttpServletRequest request,
+                                   @RequestParam(defaultValue = "") String mobilephone) throws Exception {
+        User user = requireLogin(request);
+        if (user == null) {
+            return buildJson(-1, "登录超时");
+        }
+        if (_.isEmpty(mobilephone)) {
+            return buildJson(-1, "参数错误");
+        }
+
+        // 预约信息
+        ReceivedAppointment receivedAppointment = receivedAppointmentService.getByMobilephone(mobilephone);
+        if (receivedAppointment == null) {
+            return buildJson(-1, "未查询到预约信息");
+        }
+
+        // 支付信息
+        Integer payId = receivedAppointment.getWechatPayId();
+        if (payId == null) {
+            payId = 0;
+        }
+        ReceivedWechatPay receivedWechatPay = receivedWechatPayService.getById(payId);
+
+        // 快递信息
+        List<ExpressType> storeExpTypes = new ArrayList<>();
+        if (receivedWechatPay != null) {
+            Map<Integer, List<ExpressType>> storeExpressMap = basicInfoService.getExpressByStoreId(user.getStoreId());
+            if (_.isNotEmpty(storeExpressMap)) {
+                storeExpTypes = storeExpressMap.get(2);
+            }
+        }
+
+        Map<String, String> receivedVO = generateReceivedVO(receivedAppointment, receivedWechatPay, storeExpTypes);
+        return buildJson(0, "成功", receivedVO);
+    }
+
+    private List<Map<String, String>> generateReceivedVOList(int storeId, List<ReceivedWechatPay> receivedWechatPayList) {
+        List<Map<String, String>> receivedVOList = new ArrayList<>();
+        if (_.isNotEmpty(receivedWechatPayList)) {
+            // 快递信息
+            List<ExpressType> expTypes = new ArrayList<>();
+            Map<Integer, List<ExpressType>> expTypesMap = basicInfoService.getExpressByStoreId(storeId);
+            if (_.isNotEmpty(expTypesMap)) {
+                expTypes = expTypesMap.get(2);
+            }
+
+            List<ReceivedAppointment> receivedAppointmentList = receivedAppointmentService.getByReceivedWechatPayIds(receivedWechatPayList);
+            for (ReceivedWechatPay receivedWechatPay : receivedWechatPayList) {
+                // 查询是否有关联的预约记录
+                ReceivedAppointment receivedAppointment = null;
+                if (_.isNotEmpty(receivedAppointmentList)) {
+                    for (ReceivedAppointment appointment : receivedAppointmentList) {
+                        if (appointment.getWechatPayId().equals(receivedWechatPay.getId())) {
+                            receivedAppointment = appointment;
+                        }
+                    }
+                }
+
+                receivedVOList.add(generateReceivedVO(receivedAppointment, receivedWechatPay, expTypes));
+            }
+        }
+        return receivedVOList;
+    }
+
+    private Map<String, String> generateReceivedVO(ReceivedAppointment receivedAppointment,
+                                                   ReceivedWechatPay receivedWechatPay,
+                                                   List<ExpressType> storeExpTypes) {
+        Map<String, String> vo = new HashMap<>();
+
+        if (receivedAppointment != null) {
+            vo.put("appointmentId", receivedAppointment.getId() + "");
+            vo.put("collegeName", receivedAppointment.getCollegeName());
+            vo.put("wechatUsername", receivedAppointment.getWechatUsername());
+            vo.put("mobilephone", receivedAppointment.getMobilephone());
+        } else {
+            vo.put("appointmentId", 0 + "");
+            vo.put("collegeName", "");
+            vo.put("wechatUsername", "");
+            vo.put("mobilephone", "");
+        }
+
+        if (receivedWechatPay != null) {
+            vo.put("expId", receivedWechatPay.getExpId() + "");
+
+            String expName = "";
+            for (ExpressType expType : storeExpTypes) {
+                if (expType.getExpId() == receivedWechatPay.getExpId()) {
+                    expName = expType.getExpName();
+                }
+            }
+            vo.put("expName", expName);
+
+            vo.put("expCode", receivedWechatPay.getExpCode());
+            vo.put("weight", receivedWechatPay.getWeight() + "");
+            vo.put("provinceName", receivedWechatPay.getProvinceName());
+            vo.put("money", ComputeUtil.parseToDouble(receivedWechatPay.getMoney()) + "");
+            vo.put("promotionMoney", ComputeUtil.parseToDouble(receivedWechatPay.getPromotionMoney()) + "");
+            vo.put("payMoney", ComputeUtil.parseToDouble(receivedWechatPay.getPayMoney()) + "");
+            vo.put("serialNumber", receivedWechatPay.getSerialNumber());
+            vo.put("tradeTime", DateUtil.timestampFormat(receivedWechatPay.getTradeTime()));
+            vo.put("payStatus", ObjectUtils.equals(receivedWechatPay.getPayStatus(), Constants.RECEIVED_WECHAT_PAYSUCC) + "");
+        } else {
+            vo.put("expId", "");
+            vo.put("expName", "");
+            vo.put("expCode", "");
+            vo.put("weight", "");
+            vo.put("provinceName", "");
+            vo.put("money", "");
+            vo.put("promotionMoney", "");
+            vo.put("payMoney", "");
+            vo.put("serialNumber", "");
+            vo.put("tradeTime", "");
+            vo.put("payStatus", "false");
+        }
+        return vo;
+    }
+
+    @RequestMapping(value = "/biyeji/createQRcode", method = RequestMethod.POST)
+    @ResponseBody
+    public Object createQRcode(HttpServletRequest request,
+                               @RequestParam(defaultValue = "0") int appointmentId,
+                               @RequestParam(defaultValue = "0") int expId,
+                               @RequestParam(defaultValue = "") String expcode,
+                               @RequestParam(defaultValue = "0.0") double weight,
+                               @RequestParam(defaultValue = "") String provinceName,
+                               @RequestParam(defaultValue = "0.0") double money,
+                               @RequestParam(defaultValue = "0.0") double promotionMoney,
+                               @RequestParam(defaultValue = "0.0") double payMoney) throws Exception {
+        User user = getFromCookie(request);
+        if (user == null) {
+            return buildJson(-1, "登录超时");
+        }
+        if (expId <= 0 || _.isEmpty(expcode)) {
+            return buildJson(-1, "参数错误");
+        }
+
+        ExpressType expType = basicInfoService.getExpressById(expId);
+        if (expType == null) {
+            return buildJson(-1, "快递ID错误");
+        }
+
+        // 支付信息
+        ReceivedWechatPay receivedWechatPay = receivedWechatPayService.get(user.getStoreId(), expId, expcode);
+        if (receivedWechatPay == null) {
+            receivedWechatPay = new ReceivedWechatPay();
+            receivedWechatPay.setStoreId(user.getStoreId());
+            receivedWechatPay.setExpId(expId);
+            receivedWechatPay.setExpCode(expcode);
+            receivedWechatPay.setWeight(weight);
+            receivedWechatPay.setProvinceName(provinceName);
+            receivedWechatPay.setMoney(ComputeUtil.parseToInt(money));
+            receivedWechatPay.setPromotionMoney(ComputeUtil.parseToInt(promotionMoney));
+            receivedWechatPay.setPayMoney(ComputeUtil.parseToInt(payMoney));
+            receivedWechatPayService.save(receivedWechatPay);
+        } else {
+            if (receivedWechatPay.getPayStatus() == Constants.RECEIVED_WECHAT_PAYSUCC) {
+                return buildJson(-1, "面单号已使用,请更换其他面单号");
+            }
+
+            receivedWechatPay.setWeight(weight);
+            receivedWechatPay.setProvinceName(provinceName);
+            receivedWechatPay.setMoney(ComputeUtil.parseToInt(money));
+            receivedWechatPay.setPromotionMoney(ComputeUtil.parseToInt(promotionMoney));
+            receivedWechatPay.setPayMoney(ComputeUtil.parseToInt(payMoney));
+            receivedWechatPayService.updateById(receivedWechatPay);
+
+            // 若该支付信息未支付,且和其他预约信息关联过,则解除关联
+            ReceivedAppointment appointment = receivedAppointmentService.getByWechatPayId(receivedWechatPay.getId());
+            if (appointment != null && ObjectUtils.notEqual(appointment.getId(), appointmentId)) {
+                appointment.setWechatPayId(0);
+                receivedAppointmentService.updateById(appointment);
+            }
+        }
+
+        // 关联预约信息和揽件支付信息
+        if (appointmentId > 0) {
+            ReceivedAppointment appointment = new ReceivedAppointment();
+            appointment.setId(appointmentId);
+            appointment.setWechatPayId(receivedWechatPay.getId());
+            receivedAppointmentService.updateById(appointment);
+        }
+
+        // 调用支付系统
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("expName", expType.getExpName());
+        map.put("expCode", expcode);
+        map.put("money", ComputeUtil.parseToInt(payMoney));
+        map.put("payId", receivedWechatPay.getId());
+
+        String result = receivedWechatPayHelper.payReceivedOrder(map, getIp(request));
+        if (result == null || _.isEmpty(result)) {
+            return buildJson(-1, "失败");
+        }
+
+        JsonNode jsonNode = JsonUtil.parse(result);
+        if (jsonNode.findValue("code").asInt() == 0) {
+            JsonNode dataJsonNode = JsonUtil.parse(jsonNode.findValue("data").toString());
+            String url = dataJsonNode.findValue("codeUrl").textValue();
+            HashMap<String, Object> returnMap = new HashMap<>();
+            returnMap.put("code", 0);
+            returnMap.put("msg", "成功");
+            returnMap.put("data", url);
+            return returnMap;
+        }
+        return buildJson(jsonNode.findValue("code").asInt(), jsonNode.findValue("msg").toString());
+    }
+}

+ 478 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/GraduationController.java

@@ -0,0 +1,478 @@
+package cn.haliaeetus.controller.graduation;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.controller.graduation.alipay.AliPayHelper;
+import cn.haliaeetus.controller.graduation.wecharhelper.HttpResponseDto;
+import cn.haliaeetus.controller.graduation.wecharhelper.ParseXMLUtils;
+import cn.haliaeetus.controller.graduation.wecharhelper.WeChatProxy;
+import cn.haliaeetus.controller.util.APIConfig;
+import cn.haliaeetus.entity.GraduateExpPrice;
+import cn.haliaeetus.entity.GraduateReceived;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.base.log.Logger;
+import cn.haliaeetus.framework.util.HttpUtil;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.GraduateExpPriceService;
+import cn.haliaeetus.service.GraduateReceivedService;
+
+@Controller
+@RequestMapping("/device/graduation")
+public class GraduationController extends BaseController {
+	
+	private static final Logger log = Logger.getInstance(GraduationController.class);
+    
+    @Autowired
+    private GraduateExpPriceService graduateExpPriceService;
+    
+    @Autowired
+    private GraduateReceivedService graduateReceivedService;
+    
+    @Autowired
+    private WeChatProxy weChatProxy;
+
+
+    @RequestMapping("/getInitInfo")
+    @ResponseBody
+    public Object getInitInfo(HttpServletRequest request, HttpServletResponse response) {
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        
+        // 获取快递品牌、始发地、目的地信息
+        List<Map<String, Object>> initInfoList = graduateExpPriceService.getInitInfo();
+        JsonObject result = new JsonObject();
+		JsonArray expInfo = new JsonArray();
+		JsonArray jProvinceInfo = new JsonArray();
+		JsonArray dProvinceInfo = new JsonArray();
+		result.addProperty("code", 0);
+		
+		if (_.isNotEmpty(initInfoList)) {
+			for (Map<String, Object> map : initInfoList) {
+				int type = ((Long)map.get("type")).intValue();
+				JsonObject json = new JsonObject();
+				switch(type) {
+				case 1:
+					json.addProperty("expressName", (String) map.get("name"));
+					expInfo.add(json);
+					break;
+				case 2:
+					json.addProperty("jProvinceName", (String) map.get("name"));
+					jProvinceInfo.add(json);
+					break;
+				case 3:
+					json.addProperty("dProvinceName", (String) map.get("name"));
+					dProvinceInfo.add(json);
+					break;
+				default:
+					break;
+				}
+			}
+		}
+        result.add("expInfo", expInfo);
+        result.add("jProvinceInfo", jProvinceInfo);
+        result.add("dProvinceInfo", dProvinceInfo);
+        return result.toString();
+    }
+    
+    @RequestMapping("/getExpPrice")
+    @ResponseBody
+    public Object getExpPrice(HttpServletRequest request, HttpServletResponse response) {
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        
+        String expressName = request.getParameter("expressName");
+        String jProvinceName = request.getParameter("jProvinceName");
+        String dProvinceName = request.getParameter("dProvinceName");
+        
+        // 根据快递公司、始发地、目的地获取快递价格信息
+        JsonObject result = new JsonObject();
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("expressName", expressName);
+        params.put("jProvinceName", jProvinceName);
+        params.put("dProvinceName", dProvinceName);
+        GraduateExpPrice graduateExpPrice = graduateExpPriceService.getGraduateExpPrice(params);
+        result.addProperty("code", 0);
+        result.addProperty("data", "");
+        if (graduateExpPrice != null) {
+        	result.add("data", graduateExpPrice.toJson());
+        }
+        return result.toString();
+    }
+    
+    @RequestMapping("/is1YaoOrder")
+    @ResponseBody
+    public Object is1YaoOrder(HttpServletRequest request, HttpServletResponse response) {
+
+        User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        
+        String yaoNo = request.getParameter("yaoNo");
+        if (_.isEmpty(yaoNo)) return buildJson(-1, "参数错误");
+        
+        // 调用1药网接口验证是否是1药网订单
+        int status = request1Yao(yaoNo);
+        if(status == -1) {
+        	return buildJson(-1, "验证1药网订单失败,请稍后重试");
+        }
+        
+        // 检查验证结果
+        JsonObject result = new JsonObject();
+        result.addProperty("code", 0);
+        if (status == 2) {
+        	result.addProperty("subCode", -1);
+        	result.addProperty("msg", "非1医药网订单,不满足优惠条件");
+        	return result.toString();
+        }
+        
+        if (status == 0) {
+        	result.addProperty("subCode", -1);
+        	result.addProperty("msg", "无效1药网订单,不满足优惠条件");
+        	return result.toString();
+        }
+        
+        // 验证为有效订单后,需要验证是否已经参加过优惠活动
+        if(graduateReceivedService.isYaoNoUsed(yaoNo)){
+        	result.addProperty("subCode", -1);
+        	result.addProperty("msg", "此1药网订单已经参加过优惠活动,不能再次优惠");
+        	return result.toString();
+        }
+        
+        result.addProperty("subCode", 0);
+    	result.addProperty("msg", "符合优惠条件,优惠30元");
+        return result.toString();
+    }
+    
+    private int request1Yao(String yaoNo) {
+    	
+    	Map<String, String> params = new HashMap<String, String>();
+    	params.put("token", APIConfig.get1YaoRequestToken());
+    	params.put("orderid", yaoNo);
+    	String response = HttpUtil.get(APIConfig.get1YaoRequestUrl(), params);
+    	
+    	JSONObject json = null;
+        try {
+            json = JSONObject.parseObject(response);
+        } catch (Exception e) {
+            return -1;
+        }
+        
+        if (json == null) {
+            return -1;
+        }
+        
+    	return json.getIntValue("status");
+    }
+    
+    /**
+     * 创建并支付
+     * @param request
+     * @param graduateReceived
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/createAndPay", method = { RequestMethod.POST, RequestMethod.GET })
+	@ResponseBody
+	public Object createAndPay(HttpServletRequest request, GraduateReceived graduateReceived) throws Exception {
+    	log.info("createAndPay start--:" + graduateReceived.toString());
+    	User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        //验证参数
+        String authCode = graduateReceived.getAuthCode();
+        graduateReceived.setTradeStatus(0);
+        graduateReceived.setStoreId(user.getStoreId());
+        graduateReceived.setUserid(user.getUserId());
+        try {
+        	
+        	int i = graduateReceivedService.createGraduateReceived(graduateReceived);
+        	if(i != 1){
+        		return buildJson(-1, "创建揽件单失败!");
+        	}
+        } catch (Exception e) {
+        	return buildJson(-1, "面单号已使用!");
+        }
+        
+        String outTradeNo = this.graduateReceivedService.getTradeNo(graduateReceived.getId(),false);
+        graduateReceived = graduateReceivedService.getGraduateReceivedById(graduateReceived.getId());
+        graduateReceived.setOutTradeNo(outTradeNo);
+        graduateReceivedService.updateGraduateReceived(graduateReceived);
+        
+        
+        JsonObject result = new JsonObject();
+        result.addProperty("code", 0);
+        result.addProperty("payCode", 0);
+        result.addProperty("orderId", graduateReceived.getId());
+        
+        String tradeNo = "";
+        String msg = "";
+        boolean paySuccess = false;
+        if(graduateReceived.getPayType() == 2){
+        	Map<String,String> resultMap = weChatProxy.payAndcancel(outTradeNo, authCode, graduateReceived.getPayMoney().toString());
+        	if("true".equals(resultMap.get("paySuccess"))){
+        		paySuccess = true;
+        	}
+        	if(resultMap.get("tradeNo") != null){
+        	   tradeNo = resultMap.get("tradeNo");
+        	}
+        	if(resultMap.get("msg") != null){
+        		msg = resultMap.get("msg");
+         	}
+        }else if(graduateReceived.getPayType() == 1){
+        	Map<String,String> resultMap = AliPayHelper.payAndcancel(outTradeNo, authCode, graduateReceived.getPayMoney().toString(), user.getUserId(), user.getUserId());
+        	if("true".equals(resultMap.get("paySuccess"))){
+        		paySuccess = true;
+        	}
+        	if(resultMap.get("tradeNo") != null){
+        	   tradeNo = resultMap.get("tradeNo");
+        	}
+        	if(resultMap.get("msg") != null){
+        		msg = resultMap.get("msg");
+         	}
+        }else{
+        	result.addProperty("payCode", -1);
+        	result.addProperty("msg",  "选择支付失败!");
+        	return result.toString();
+        }
+        
+        graduateReceived = graduateReceivedService.getGraduateReceivedById(graduateReceived.getId());
+        graduateReceived.setTradeNo(tradeNo);
+        if(paySuccess){
+        	graduateReceived.setTradeStatus(1);
+        }else{
+        	result.addProperty("payCode", -1);
+        	graduateReceived.setFailMsg(msg);
+        	graduateReceived.setTradeStatus(2);
+        }
+        result.addProperty("msg", msg);
+        graduateReceivedService.updateGraduateReceived(graduateReceived);
+        log.info("createAndPay end--:" + graduateReceived.toString());
+        return result.toString();
+    }
+    /**
+     * 重新支付
+     * @param request
+     * @param graduateReceived
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/rePay", method = { RequestMethod.POST, RequestMethod.GET })
+	@ResponseBody
+	public Object rePay(HttpServletRequest request, GraduateReceived graduateReceived) throws Exception {
+    	log.info("rePay start--:" + graduateReceived.toString());
+    	User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        //验证参数
+        String authCode = graduateReceived.getAuthCode();
+        GraduateReceived old = graduateReceivedService.getGraduateReceivedById(graduateReceived.getId());
+        if(old == null || old.getTradeStatus() == 1){
+        	 return buildJson(-1, "未找到揽件单或揽件单已支付!");
+        }
+        String outTradeNo = this.graduateReceivedService.getTradeNo(graduateReceived.getId(),true);
+        old.setOutTradeNo(outTradeNo);
+        old.setTradeStatus(0);
+        int i = graduateReceivedService.updateGraduateReceivedRePay(old);
+        
+        if(i != 1){
+        	return buildJson(-1, "未找到揽件单或揽件单已支付!");
+        }
+        
+        JsonObject result = new JsonObject();
+        result.addProperty("code", 0);
+        result.addProperty("payCode", 0);
+        result.addProperty("orderId", graduateReceived.getId());
+        
+        String tradeNo = "";
+        String msg = "";
+        boolean paySuccess = false;
+        if(graduateReceived.getPayType() == 2){
+        	Map<String,String> resultMap = weChatProxy.payAndcancel(outTradeNo, authCode, old.getPayMoney().toString());
+        	if("true".equals(resultMap.get("paySuccess"))){
+        		paySuccess = true;
+        	}
+        	if(resultMap.get("tradeNo") != null){
+        	   tradeNo = resultMap.get("tradeNo");
+        	}
+        	if(resultMap.get("msg") != null){
+        		msg = resultMap.get("msg");
+         	}
+        }else if(graduateReceived.getPayType() == 1){
+        	Map<String,String> resultMap = AliPayHelper.payAndcancel(outTradeNo, authCode, old.getPayMoney().toString(), user.getUserId(), user.getUserId());
+        	if("true".equals(resultMap.get("paySuccess"))){
+        		paySuccess = true;
+        	}
+        	if(resultMap.get("tradeNo") != null){
+        	   tradeNo = resultMap.get("tradeNo");
+        	}
+        	if(resultMap.get("msg") != null){
+        		msg = resultMap.get("msg");
+         	}
+        }else{
+        	result.addProperty("payCode", -1);
+        	result.addProperty("msg",  "选择支付失败!");
+        	return result.toString();
+        }
+        
+        graduateReceived = graduateReceivedService.getGraduateReceivedById(graduateReceived.getId());
+        graduateReceived.setTradeNo(tradeNo);
+        if(paySuccess){
+        	graduateReceived.setTradeStatus(1);
+        }else{
+        	result.addProperty("payCode", -1);
+        	graduateReceived.setFailMsg(msg);
+        	graduateReceived.setTradeStatus(2);
+        }
+        result.addProperty("msg", msg);
+        
+        graduateReceivedService.updateGraduateReceived(graduateReceived);
+        log.info("rePay end--:" + graduateReceived.toString());
+    	return result.toString();
+    }
+    
+    /**
+     * 查询近两天数据,或通过运单查询
+     * @param request
+     * @param response
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/selectStoreTwoDayData", method = { RequestMethod.POST, RequestMethod.GET })
+	@ResponseBody
+	public Object selectStoreTwoDayData(HttpServletRequest request, HttpServletResponse response) throws Exception {
+    	User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        JsonObject result = new JsonObject();
+        result.addProperty("code", 0);
+        
+        GraduateReceived graduateReceived = new GraduateReceived();
+        graduateReceived.setStoreId(user.getStoreId());
+        String expressCode = request.getParameter("expressCode");
+        if(expressCode != null && !"".equals(expressCode.trim())){
+        	graduateReceived.setExpressCode(expressCode);
+        }
+        List<GraduateReceived> list = graduateReceivedService.selectStoreTwoDayData(graduateReceived); 
+        return buildRetJson(0, "success", list);
+    }
+    
+    /**
+     * 查询订单详情
+     * @param request
+     * @param response
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/showOrderInfo", method = { RequestMethod.POST, RequestMethod.GET })
+	@ResponseBody
+	public Object showOrderInfo(HttpServletRequest request, HttpServletResponse response) throws Exception {
+    	User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        String orderId = request.getParameter("orderId");
+        if(orderId == null || "".equals(orderId.trim())){
+        	 return buildJson(-1, "请选择相应的揽件");
+        }
+        Integer id = 0;
+        try {
+			id = Integer.parseInt(orderId);
+		} catch (Exception e) {
+			 return buildJson(-1, "请选择正确的揽件");
+		}
+        GraduateReceived gr = graduateReceivedService.getGraduateReceivedById(id);
+        
+        return buildJson(0, "success",gr);
+    }
+    
+    /**
+     * 撤销微信订单
+     * @param request
+     * @param response
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/reverseWxPay", method = { RequestMethod.POST, RequestMethod.GET })
+	@ResponseBody
+	public Object reverseWxPay(HttpServletRequest request, HttpServletResponse response) throws Exception {
+    	User user = getUserFromParam(request);
+        if (user == null) {
+            return buildJson(1, "登录超时");
+        }
+        String out_trade_no = request.getParameter("out_trade_no");
+        if(out_trade_no == null || "".equals(out_trade_no.trim())){
+        	 return buildJson(-1, "请选择相应的撤销微信订单");
+        }
+    	HttpResponseDto hrd = weChatProxy.reverse(out_trade_no);
+    	log.error("------------" + hrd.toString() + user.toString(),null);
+        
+        return buildJson(0, "success",hrd);
+    }
+    
+    private HttpResponseDto getOneHttpResponseDto(boolean sof){
+    	HttpResponseDto hrd = new HttpResponseDto();
+    	String temp = "";
+    	if(sof){
+    		temp = "<xml><return_code><![CDATA[SUCCESS]]></return_code>"+
+    				"<return_msg><![CDATA[OK]]></return_msg>"+
+					"<appid><![CDATA[wxd888b8a9c5763733]]></appid>"+
+					"<mch_id><![CDATA[1232715501]]></mch_id>"+
+					"<nonce_str><![CDATA[jOhoxueycqxNQBOl]]></nonce_str>"+
+					"<sign><![CDATA[ECB8968D24947238DE7A692820B7F47D]]></sign>"+
+					"<result_code><![CDATA[SUCCESS]]></result_code>"+
+					"<openid><![CDATA[oTS2xjupswFaAn5t_Jwhqu3Fq7BQ]]></openid>"+
+					"<is_subscribe><![CDATA[N]]></is_subscribe>"+
+					"<trade_type><![CDATA[MICROPAY]]></trade_type>"+
+					"<bank_type><![CDATA[CFT]]></bank_type>"+
+					"<total_fee>1</total_fee>"+
+					"<fee_type><![CDATA[CNY]]></fee_type>"+
+					"<transaction_id><![CDATA[4006612001201606137206442262]]></transaction_id>"+
+					"<out_trade_no><![CDATA[2016061316111210823]]></out_trade_no>"+
+					"<attach><![CDATA[]]></attach>"+
+					"<time_end><![CDATA[20160613161130]]></time_end>"+
+					"<cash_fee>1</cash_fee>"+
+					"</xml>";
+    	}else{
+    		temp = "<xml><return_code><![CDATA[SUCCESS]]></return_code>"+
+    		"<return_msg><![CDATA[OK]]></return_msg>"+
+    		"<appid><![CDATA[wxd888b8a9c5763733]]></appid>"+
+    		"<mch_id><![CDATA[1232715501]]></mch_id>"+
+    		"<nonce_str><![CDATA[EeQovavXSIDVFRxo]]></nonce_str>"+
+    		"<sign><![CDATA[7D3435961C5FB064A423B082304FBD32]]></sign>"+
+    		"<result_code><![CDATA[FAIL]]></result_code>"+
+    		"<err_code><![CDATA[AUTH_CODE_INVALID]]></err_code>"+
+    		"<err_code_des><![CDATA[请扫描微信支付被扫条码/二维码]]></err_code_des>"+
+    		"</xml>";
+    	}
+    	hrd.setData(temp);
+    	return hrd;
+    }
+    
+}

+ 162 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/alipay/AliPayHelper.java

@@ -0,0 +1,162 @@
+package cn.haliaeetus.controller.graduation.alipay;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.request.AlipayTradeCancelRequest;
+import com.alipay.api.request.AlipayTradePayRequest;
+import com.alipay.api.request.AlipayTradeQueryRequest;
+import com.alipay.api.response.AlipayTradeCancelResponse;
+import com.alipay.api.response.AlipayTradePayResponse;
+import com.alipay.api.response.AlipayTradeQueryResponse;
+import com.google.gson.JsonObject;
+
+import cn.haliaeetus.controller.graduation.alipay.factory.AlipayClientFactory;
+
+/**
+ * 支付宝支付工具类
+ * 
+ * @author Guolinzhao
+ *
+ */
+public class AliPayHelper {
+	
+	/**
+	 * 订单标题
+	 */
+	private static final String ALIPAY_SUBJECT = "路朴-毕业季";
+
+	/**
+	  * 统一交易支付(条码支付)
+	  * 
+	  * @param out_trade_no 商户订单号
+	  * @param auth_code 支付授权码
+	  * @param total_amount 订单总金额
+	  * @param oprator_id 商户操作员编号
+	  * @param store_id 商户门店编号
+	  * @return
+	  * @throws AlipayApiException 请处理异常
+	  */
+	public static AlipayTradePayResponse pay(String out_trade_no, String auth_code, String total_amount, String oprator_id, String store_id)
+	        throws AlipayApiException {
+	    AlipayTradePayRequest request = new AlipayTradePayRequest();
+	    
+	    // 生产请求支付宝参数
+	    JsonObject json = new JsonObject();
+	    json.addProperty("out_trade_no", out_trade_no);
+	    json.addProperty("scene", "bar_code");
+		json.addProperty("auth_code", auth_code);
+		json.addProperty("subject", ALIPAY_SUBJECT);
+		json.addProperty("total_amount", total_amount);
+		json.addProperty("operator_id", oprator_id);
+		json.addProperty("store_id", store_id);
+	    request.setBizContent(json.toString());
+	    
+	    return AlipayClientFactory.getAlipayClientInstance().execute(request);
+	}
+	
+	/**
+	  * 统一交易支付(条码支付)支付中状态等待
+	  * 
+	  * @param out_trade_no 商户订单号
+	  * @param auth_code 支付授权码
+	  * @param total_amount 订单总金额
+	  * @param oprator_id 商户操作员编号
+	  * @param store_id 商户门店编号
+	  * @return
+	  * @throws AlipayApiException 请处理异常
+	  */
+	public static Map<String,String> payAndcancel(String out_trade_no, String auth_code, String total_amount, String oprator_id, String store_id) throws AlipayApiException{
+		Map<String,String> map = new HashMap<String,String>();
+		AlipayTradePayResponse atpr = AliPayHelper.pay(out_trade_no, auth_code, total_amount, oprator_id, store_id);
+		map.put("paySuccess", "false");
+    	if(atpr != null && atpr.isSuccess()){
+    		if (atpr.getCode().equals("10000")) {
+    			map.put("paySuccess", "true");
+    			map.put("tradeNo", atpr.getTradeNo());
+    			map.put("msg", "SUCCESS");
+    		}else if(atpr != null && atpr.getCode().equals("10003")){
+    			map.put("tradeNo", atpr.getTradeNo());
+    			boolean needloop = true;
+    			int i = 0;
+    			try {
+					while(needloop){
+						i++;
+						if(i > 3){
+							needloop=false;
+							AlipayTradeCancelResponse atcr = AliPayHelper.cancel(out_trade_no);
+							if(atcr != null){
+								if("close".equals(atcr.getAction())){
+									map.put("msg", "支付失败,本次支付已撤销!");
+								}else{
+									map.put("msg", "支付失败,本次支付已撤销并退款!");
+								}
+							}else{
+								map.put("msg", "支付失败,撤销操作未成功!");
+							}
+							break;
+						}
+						Thread.sleep(5000);
+						AlipayTradeQueryResponse rtqr = AliPayHelper.query(out_trade_no);
+						if(rtqr != null){
+							if("TRADE_CLOSED".equals(rtqr.getTradeStatus()) || "TRADE_FINISHED".equals(rtqr.getTradeStatus())){
+								map.put("msg", "支付失败,本次支付已撤销或关闭!");
+								needloop=false;
+				    			break;
+							}else if("TRADE_SUCCESS".equals(rtqr.getTradeStatus())){
+								map.put("paySuccess", "true");
+				    			map.put("msg", "SUCCESS");
+				    			needloop=false;
+				    			break;
+							}
+						}
+					}
+				} catch (InterruptedException e) {
+				}
+    			
+    		}else{
+    			map.put("msg", atpr.getSubMsg());
+    		}
+    	} else {
+    		map.put("msg", atpr.getSubMsg());
+    	}
+    	return map;
+	}
+	
+	/**
+	  * 查询订单
+	  * @param out_trade_no 订单支付时传入的商户订单号
+	  * @return
+	  * @throws AlipayApiException 请处理异常
+	  */
+	public static AlipayTradeQueryResponse query(String out_trade_no)
+	        throws AlipayApiException {
+	    AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
+	    
+	    // 生产请求支付宝参数
+	    JsonObject json = new JsonObject();
+	    json.addProperty("out_trade_no", out_trade_no);
+	    request.setBizContent(json.toString());
+	    
+	    return AlipayClientFactory.getAlipayClientInstance().execute(request);
+	}
+	
+	/**
+	  * 撤销订单
+	  * @param out_trade_no 订单支付时传入的商户订单号
+	  * @return
+	  * @throws AlipayApiException 请异常处理
+	  */
+	public static AlipayTradeCancelResponse cancel(String out_trade_no)
+	        throws AlipayApiException {
+	    AlipayTradeCancelRequest request = new AlipayTradeCancelRequest();
+	    
+	    // 生产请求支付宝参数
+	    JsonObject json = new JsonObject();
+	    json.addProperty("out_trade_no", out_trade_no);
+	    request.setBizContent(json.toString());
+	    
+	    return AlipayClientFactory.getAlipayClientInstance().execute(request);
+	}
+}

+ 46 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/alipay/config/AlipayConfig.java

@@ -0,0 +1,46 @@
+package cn.haliaeetus.controller.graduation.alipay.config;
+
+import org.springframework.beans.factory.annotation.Value;
+
+/**
+ * 支付宝支付相关配置类
+ * 
+ * @author Guolinzhao
+ *
+ */
+public class AlipayConfig {
+
+	/**
+	 * 开发者应用私钥。java配置PKCS8格式,PHP/.Net语言配置rsa_private_key.pem文件中原始私钥。
+	 */
+	@Value("#{config['alipay.privateKey']}")
+    public static final String RSA_RRIVATE_KEY = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKYQjsBkfyco1uQ1HUquUw/g11QdHPIGlDvtWR77jlp9Nlc+ZKQXIwIPJJmBcNNohafPiE6kQ++5Ykemq7yC9r41FrwHVm8LzfaqdjOfaaJFC66RzTo7ugiSYdOJIX9rZvvCrYow4aSbyP4mjmSgUmJ20gAXIiBWheGI9h6pCVTvAgMBAAECgYAa/woV4MCC/zKf+rp+T4SVSjn3JJx2A/fJHjakwMRNlZll6XC29EPuq8OJaO+MjqtbsnM4RZ/9sqd1enTkum2eDz2KR8wmR2Mo9AM/N6jzFhdGbdkk/73TJ4yxKfPZkfrRYvEEh3Qkews5XdqiYH7Ba87FunmXOIbIdjSw5F7U8QJBAM7CcvQ6a9SQgAcOTAqdO7Blps5oJjez0HyM7+wVd33qGMX2BeLNqaT21OCf9e22BcQ0qG4FOL97ZL7CIOzfCSMCQQDNnQ4sL1RlMjW7q33JLTe/gbwYLYD85F2JaZvM+8yU0C9OvZWwuRsiRYlQNy9tbfDkZafKMUnEjQjmh3CdLM/FAkEAzYhGtbmNj5TFcD4qITMELuod03l85Ep/qhCAP/NnAWhAkCls2HUResdT/qeE1XTobo7aD+Ro8RA8qdRY3p8oeQJBAKrQWA7S/wzW6pbPQD9aJl8de1KmsurlGOPobXucj/fs//AtRec70FPnaszOG8OQOzizTvKFgeAcvpEtYZvht3UCQEE6MJpMShw0LrPWfwNXjuuiCi9h31sfuyxDL2honId2ailucHJGCk7rsgReuhviqDCooOUfBaHjRzu4pYPWLHY=";
+	
+    /**
+     * 接口请求网关。当面付支付、查询、退款、撤销接口中为固定值
+     */
+	@Value("#{config['alipay.gateway']}")
+    public static final String URL = "https://openapi.alipay.com/gateway.do";
+	
+    /**
+     * 商户应用APPID,只要您的应用中包含当面付接口且是开通状态,就可以用此应用对应的appid。开发者可登录开放平台-管理中心-对应应用中查看
+     */
+	@Value("#{config['alipay.appID']}")
+    public static final String APPID = "2015120100897681";
+	
+    /**
+     * 编码字符集。默认 utf-8
+     */
+    public static final String CHARSET = "utf-8";
+    
+    /**
+     * 返回格式。默认json
+     */
+    public static final String FORMAT = "json";
+    
+    /**
+     * 支付宝公钥,用于获取同步返回信息后进行验证,验证是否是支付宝发送的信息。
+     */
+    @Value("#{config['alipay.publicKey']}")
+    public static final String ALIPAY_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDI6d306Q8fIfCOaTXyiUeJHkrIvYISRcc73s3vF1ZT7XN8RNPwJxo8pWaJMmvyTn9N4HQ632qJBVHf8sxHi/fEsraprwCtzvzQETrNRwVxLO5jVmRGi60j8Ue1efIlzPXV9je9mkjzOmdssymZkh2QhUrCmZYI/FCEa3/cNMW0QIDAQAB";
+}

+ 28 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/alipay/factory/AlipayClientFactory.java

@@ -0,0 +1,28 @@
+package cn.haliaeetus.controller.graduation.alipay.factory;
+
+
+import com.alipay.api.AlipayClient;
+import com.alipay.api.DefaultAlipayClient;
+
+import cn.haliaeetus.controller.graduation.alipay.config.AlipayConfig;
+
+/**
+ * 支付宝客户端工厂类
+ * 
+ * @author Guolinzhao
+ *
+ */
+public class AlipayClientFactory {
+	
+    /**
+     * SDK 公共请求类,包含公共请求参数,以及封装了签名与验签,开发者无需关注签名与验签
+     */
+    private static final AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_RRIVATE_KEY, AlipayConfig.FORMAT,
+            AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY);
+    
+    
+    public static AlipayClient getAlipayClientInstance() {
+        return client;
+    }
+}
+

+ 38 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/HttpResponseDto.java

@@ -0,0 +1,38 @@
+package cn.haliaeetus.controller.graduation.wecharhelper;
+
+public class HttpResponseDto {
+	private int code;
+	private String message;
+	private String data;
+
+	public int getCode() {
+		return code;
+	}
+
+	public void setCode(int code) {
+		this.code = code;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public String getData() {
+		return data;
+	}
+
+	public void setData(String data) {
+		this.data = data;
+	}
+
+	@Override
+	public String toString() {		
+		return  "code : " + code +",message :" +message +",data :" +data;
+	}
+
+	 
+}

+ 193 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/HttpUtil.java

@@ -0,0 +1,193 @@
+package cn.haliaeetus.controller.graduation.wecharhelper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+public class HttpUtil {
+	private static final Log logger = LogFactory.getLog(HttpUtil.class);
+
+	public static HttpResponseDto post(String url, String data) {
+		HttpResponseDto result = new HttpResponseDto();
+		HttpClient client = new DefaultHttpClient();
+		HttpPost post = new HttpPost(url);
+		post.addHeader("Connection", "keep-alive");
+		post.addHeader("Accept", "*/*");
+		post.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+		post.addHeader("Host", "api.mch.weixin.qq.com");
+		post.addHeader("X-Requested-With", "XMLHttpRequest");
+		post.addHeader("Cache-Control", "max-age=0");
+		post.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
+		try {
+			StringEntity entity = null;
+			try {
+				entity = new StringEntity(data, "UTF-8");
+			} catch (UnsupportedEncodingException e) {
+				logger.error(e.getMessage());
+				logger.error(e.getStackTrace());
+			}
+			post.setEntity(entity);
+			HttpResponse response = client.execute(post);
+			if (response.getStatusLine().getStatusCode() == 200) {
+				String strResponse = EntityUtils.toString(response.getEntity(), "UTF-8");
+				result.setData(strResponse);
+				result.setCode(1);
+				result.setMessage("succeed");
+			} else {
+				String strResponse = String.format("errorCode:%s", response.getStatusLine().getStatusCode());
+				result.setData("");
+				result.setCode(0);
+				result.setMessage(strResponse);
+			}
+		} catch (ClientProtocolException e) {
+			String strResponse = String.format("%s:%s", "error", e.getMessage());
+			result.setData("");
+			result.setCode(0);
+			result.setMessage(strResponse);
+		} catch (IOException e) {
+			String strResponse = String.format("%s:%s", "error", e.getMessage());
+			result.setData("");
+			result.setCode(0);
+			result.setMessage(strResponse);
+		}
+		return result;
+	}
+	
+	public static HttpResponseDto get(String url) {
+		HttpResponseDto result = new HttpResponseDto();
+		HttpClient client = new DefaultHttpClient();
+		HttpGet get = new HttpGet(url);
+		get.addHeader("Content-Type", "application/x-www-form-urlencoded");
+		try {
+			HttpResponse response = client.execute(get);
+			if (response.getStatusLine().getStatusCode() == 200) {
+				String strResponse = EntityUtils.toString(response.getEntity());
+				result.setData(strResponse);
+				result.setCode(1);
+				result.setMessage("succeed");
+			} else {
+				String strResponse = String.format("errorCode:%s", response.getStatusLine().getStatusCode());
+				result.setData("");
+				result.setCode(0);
+				result.setMessage(strResponse);
+			}
+		} catch (ClientProtocolException e) {
+			String strResponse = String.format("%s:%s", "error", e.getMessage());
+			result.setData("");
+			result.setCode(0);
+			result.setMessage(strResponse);
+		} catch (IOException e) {
+			String strResponse = String.format("%s:%s", "error", e.getMessage());
+			result.setData("");
+			result.setCode(0);
+			result.setMessage(strResponse);
+		}
+		return result;
+	}
+	
+	public static HttpResponseDto postsecurity(String url, String data) {
+		HttpResponseDto result = new HttpResponseDto();
+		try {
+		 KeyStore keyStore  = KeyStore.getInstance("PKCS12");
+	        FileInputStream instream = new FileInputStream(new File(HttpUtil.class.getClassLoader().getResource("1225003702.p12").getPath()));
+	        try {
+	            keyStore.load(instream, "1225003702".toCharArray());
+	        } finally {
+	            instream.close();
+	        }
+	        // Trust own CA and all self-signed certs
+	        SSLContext sslcontext = SSLContexts.custom()
+				        .loadKeyMaterial(keyStore, "1225003702".toCharArray())
+				        .build();
+	        // Allow TLSv1 protocol only
+	        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
+	                sslcontext,
+	                new String[] { "TLSv1" },
+	                null,
+	                SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+	        CloseableHttpClient httpclient = HttpClients.custom()
+	                .setSSLSocketFactory(sslsf)
+	                .build();
+		HttpPost post = new HttpPost(url);
+		post.addHeader("Connection", "keep-alive");
+		post.addHeader("Accept", "*/*");
+		post.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+		post.addHeader("Host", "api.mch.weixin.qq.com");
+		post.addHeader("X-Requested-With", "XMLHttpRequest");
+		post.addHeader("Cache-Control", "max-age=0");
+		post.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
+		
+			StringEntity entity = null;
+			try {
+				entity = new StringEntity(data, "UTF-8");
+			} catch (UnsupportedEncodingException e) {
+				logger.error(e.getMessage());
+				logger.error(e.getStackTrace());
+			}
+			post.setEntity(entity);
+			HttpResponse response = httpclient.execute(post);
+			if (response.getStatusLine().getStatusCode() == 200) {
+				String strResponse = EntityUtils.toString(response.getEntity(), "UTF-8");
+				result.setData(strResponse);
+				result.setCode(1);
+				result.setMessage("succeed");
+			} else {
+				String strResponse = String.format("errorCode:%s", response.getStatusLine().getStatusCode());
+				result.setData("");
+				result.setCode(0);
+				result.setMessage(strResponse);
+			}
+		} catch (ClientProtocolException e) {
+			String strResponse = String.format("%s:%s", "error", e.getMessage());
+			result.setData("");
+			result.setCode(0);
+			result.setMessage(strResponse);
+		} catch (IOException e) {
+			String strResponse = String.format("%s:%s", "error", e.getMessage());
+			result.setData("");
+			result.setCode(0);
+			result.setMessage(strResponse);
+		} catch (KeyStoreException e) {
+			String strResponse = String.format("%s:%s", "error", e.getMessage());
+			result.setData("");
+			result.setCode(0);
+			result.setMessage(strResponse);
+		} catch (NoSuchAlgorithmException | CertificateException e) {
+			String strResponse = String.format("%s:%s", "error", e.getMessage());
+			result.setData("");
+			result.setCode(0);
+			result.setMessage(strResponse);
+		} catch (KeyManagementException | UnrecoverableKeyException e) {
+			String strResponse = String.format("%s:%s", "error", e.getMessage());
+			result.setData("");
+			result.setCode(0);
+			result.setMessage(strResponse);
+		}
+		return result;
+	}
+	
+}

+ 46 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/MD5Util.java

@@ -0,0 +1,46 @@
+package cn.haliaeetus.controller.graduation.wecharhelper;
+
+
+
+
+import java.security.MessageDigest;
+
+public class MD5Util {
+
+	private static String byteArrayToHexString(byte b[]) {
+		StringBuffer resultSb = new StringBuffer();
+		for (int i = 0; i < b.length; i++)
+			resultSb.append(byteToHexString(b[i]));
+
+		return resultSb.toString();
+	}
+
+	private static String byteToHexString(byte b) {
+		int n = b;
+		if (n < 0)
+			n += 256;
+		int d1 = n / 16;
+		int d2 = n % 16;
+		return hexDigits[d1] + hexDigits[d2];
+	}
+
+	public static String MD5Encode(String origin, String charsetname) {
+		String resultString = null;
+		try {
+			resultString = new String(origin);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+			if (charsetname == null || "".equals(charsetname))
+				resultString = byteArrayToHexString(md.digest(resultString
+						.getBytes()));
+			else
+				resultString = byteArrayToHexString(md.digest(resultString
+						.getBytes(charsetname)));
+		} catch (Exception exception) {
+		}
+		return resultString;
+	}
+
+	private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
+			"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
+
+}

+ 37 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/ParseXMLUtils.java

@@ -0,0 +1,37 @@
+package cn.haliaeetus.controller.graduation.wecharhelper;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.xml.sax.InputSource;
+
+
+public class ParseXMLUtils {
+	public static Map<String, String> parseXML(String xml)  
+            throws JDOMException, IOException {  
+        /** *用于存放节点的信息** */  
+        Map<String, String> map = new HashMap<String, String>();  
+        /** *创建一个新的字符串*** */  
+        StringReader xmlReader = new StringReader(xml);  
+        /** **创建新的输入源SAX 解析器将使用 InputSource 对象来确定如何读取 XML 输入 */  
+        InputSource xmlSource = new InputSource(xmlReader);  
+        /** *创建一个SAXBuilder* */  
+        SAXBuilder builder = new SAXBuilder();  
+        /** *通过输入源SAX构造一个Document** */  
+        org.jdom.Document doc = builder.build(xmlSource);  
+        /** *获得根节点** */  
+        org.jdom.Element elt = doc.getRootElement();  
+        /** *获得body节点下面的所有子节点*** */  
+        List<org.jdom.Element> child = elt.getChildren();  
+        /** *遍历出body节点下面所有的子节点,节点名称和内容用put到map* */  
+        for (org.jdom.Element childEle : child) {  
+            map.put(childEle.getName(), childEle.getText());  
+        }  
+        return map;  
+    }  
+}

+ 291 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/TenpayUtil.java

@@ -0,0 +1,291 @@
+package cn.haliaeetus.controller.graduation.wecharhelper;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+
+
+public class TenpayUtil {
+	
+	private static Object Server;
+	private static String QRfromGoogle;
+
+	/**
+	 * 把对象转换成字符串
+	 * @param obj
+	 * @return String 转换成字符串,若对象为null,则返回空字符串.
+	 */
+	public static String toString(Object obj) {
+		if(obj == null)
+			return "";
+		
+		return obj.toString();
+	}
+	/**
+	 * 获取随机字符串
+	 * @return
+	 */
+	public static String getNonceStr() {
+		// 随机数
+		String currTime = getCurrTime();
+		// 8位日期
+		String strTime = currTime.substring(8, currTime.length());
+		// 四位随机数
+		String strRandom = TenpayUtil.buildRandom(4) + "";
+		// 10位序列号,可以自行调整。
+		return strTime + strRandom;
+	}
+	
+	/**
+	 * 元转换成分
+	 * @param money
+	 * @return
+	 */
+	public static String getMoney(String amount) {
+		if(amount==null){
+			return "";
+		}
+		// 金额转化为分为单位
+		String currency =  amount.replaceAll("\\$|\\¥|\\,", "");  //处理包含, ¥ 或者$的金额  
+        int index = currency.indexOf(".");  
+        int length = currency.length();  
+        Long amLong = 0l;  
+        if(index == -1){  
+            amLong = Long.valueOf(currency+"00");  
+        }else if(length - index >= 3){  
+            amLong = Long.valueOf((currency.substring(0, index+3)).replace(".", ""));  
+        }else if(length - index == 2){  
+            amLong = Long.valueOf((currency.substring(0, index+2)).replace(".", "")+0);  
+        }else{  
+            amLong = Long.valueOf((currency.substring(0, index+1)).replace(".", "")+"00");  
+        }  
+        return amLong.toString(); 
+	}
+	
+	/**
+	 * 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。
+	 */
+	public static String createSign(SortedMap<String, String> packageParams,String key) {
+		StringBuffer sb = new StringBuffer();
+		Set es = packageParams.entrySet();
+		Iterator it = es.iterator();
+		while (it.hasNext()) {
+			Map.Entry entry = (Map.Entry) it.next();
+			String k = (String) entry.getKey();
+			String v = (String) entry.getValue();
+			if (null != v && !"".equals(v) && !"sign".equals(k)
+					&& !"key".equals(k)) {
+				sb.append(k + "=" + v + "&");
+			}
+		}
+		sb.append("key=" + key);
+		String sign = MD5Util.MD5Encode(sb.toString(), "UTF-8")
+				.toUpperCase();
+		return sign;
+
+	}
+	
+	/**
+	 * 把对象转换为int数值.
+	 * 
+	 * @param obj
+	 *            包含数字的对象.
+	 * @return int 转换后的数值,对不能转换的对象返回0。
+	 */
+	public static int toInt(Object obj) {
+		int a = 0;
+		try {
+			if (obj != null)
+				a = Integer.parseInt(obj.toString());
+		} catch (Exception e) {
+
+		}
+		return a;
+	}
+	
+	/**
+	 * 获取当前时间 yyyyMMddHHmmss
+	 * @return String
+	 */ 
+	public static String getCurrTime() {
+		Date now = new Date();
+		SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+		String s = outFormat.format(now);
+		return s;
+	}
+	
+	/**
+	 * 获取当前日期 yyyyMMdd
+	 * @param date
+	 * @return String
+	 */
+	public static String formatDate(Date date) {
+		SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
+		String strDate = formatter.format(date);
+		return strDate;
+	}
+	
+	/**
+	 * 取出一个指定长度大小的随机正整数.
+	 * 
+	 * @param length
+	 *            int 设定所取出随机数的长度。length小于11
+	 * @return int 返回生成的随机数。
+	 */
+	public static int buildRandom(int length) {
+		int num = 1;
+		double random = Math.random();
+		if (random < 0.1) {
+			random = random + 0.1;
+		}
+		for (int i = 0; i < length; i++) {
+			num = num * 10;
+		}
+		return (int) ((random * num));
+	}
+	
+	
+	public  static String URLencode(String content){
+		
+		String URLencode;
+		
+		URLencode= replace(Server.equals(content), "+", "%20");
+		
+		return URLencode;
+	}
+	private static String replace(boolean equals, String string, String string2) {
+		
+		return null;
+	}
+
+	/**
+	 * 获取unix时间,从1970-01-01 00:00:00开始的秒数
+	 * @param date
+	 * @return long
+	 */
+	public static long getUnixTime(Date date) {
+		if( null == date ) {
+			return 0;
+		}
+		
+		return date.getTime()/1000;
+	}
+	
+	 public static String QRfromGoogle(String chl)
+	    {
+	        int widhtHeight = 300;
+	        String EC_level = "L";
+	        int margin = 0;
+	        String QRfromGoogle;
+	        chl = URLencode(chl);
+	        
+	        QRfromGoogle = "http://chart.apis.google.com/chart?chs=" + widhtHeight + "x" + widhtHeight + "&cht=qr&chld=" + EC_level + "|" + margin + "&chl=" + chl;
+	       
+	        return QRfromGoogle;
+	    }
+
+	/**
+	 * 时间转换成字符串
+	 * @param date 时间
+	 * @param formatType 格式化类型
+	 * @return String
+	 */
+	public static String date2String(Date date, String formatType) {
+		SimpleDateFormat sdf = new SimpleDateFormat(formatType);
+		return sdf.format(date);
+	}
+	
+	/**
+	 * 解析xml,返回第一级元素键值对。如果第一级元素有子节点,则此节点的值是子节点的xml数据。
+	 * @param strxml
+	 * @return
+	 * @throws JDOMException
+	 * @throws IOException
+	 */
+	public static Map doXMLParse(String strxml) throws Exception {
+		if(null == strxml || "".equals(strxml)) {
+			return null;
+		}
+		
+		Map m = new HashMap();
+		InputStream in = String2Inputstream(strxml);
+		SAXBuilder builder = new SAXBuilder();
+		Document doc = builder.build(in);
+		Element root = doc.getRootElement();
+		List list = root.getChildren();
+		Iterator it = list.iterator();
+		while(it.hasNext()) {
+			Element e = (Element) it.next();
+			String k = e.getName();
+			String v = "";
+			List children = e.getChildren();
+			if(children.isEmpty()) {
+				v = e.getTextNormalize();
+			} else {
+				v = getChildrenText(children);
+			}
+			
+			m.put(k, v);
+		}
+		
+		//关闭流
+		in.close();
+		
+		return m;
+	}
+	/**
+	 * 获取子结点的xml
+	 * @param children
+	 * @return String
+	 */
+	public static String getChildrenText(List children) {
+		StringBuffer sb = new StringBuffer();
+		if(!children.isEmpty()) {
+			Iterator it = children.iterator();
+			while(it.hasNext()) {
+				Element e = (Element) it.next();
+				String name = e.getName();
+				String value = e.getTextNormalize();
+				List list = e.getChildren();
+				sb.append("<" + name + ">");
+				if(!list.isEmpty()) {
+					sb.append(getChildrenText(list));
+				}
+				sb.append(value);
+				sb.append("</" + name + ">");
+			}
+		}
+		
+		return sb.toString();
+	}
+  public static InputStream String2Inputstream(String str) {
+		return new ByteArrayInputStream(str.getBytes());
+	}
+	
+}
+	
+	
+
+
+
+
+
+
+
+
+
+

+ 291 - 0
express-main/src/main/java/cn/haliaeetus/controller/graduation/wecharhelper/WeChatProxy.java

@@ -0,0 +1,291 @@
+package cn.haliaeetus.controller.graduation.wecharhelper;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class WeChatProxy {
+	private  Log logger = LogFactory.getLog(this.getClass());
+	
+	@Value("#{config['wechat.appID']}")
+	private  String appID;
+	@Value("#{config['wechat.appsecret']}")
+	private  String appsecret;
+	@Value("#{config['wechat.partner']}")
+	private  String partner;
+	@Value("#{config['wechat.partnerkey']}")
+	private  String partnerKey;
+	@Value("#{config['wechat.openId']}")
+	private  String openId;
+	@Value("#{config['wechat.notifyurl']}")
+	private  String notifyUrl;
+	@Value("#{config['wechat.qrpay.gateway']}")
+	private  String prPaygateWay;
+	@Value("#{config['wechat.barpay.gateway']}")
+	private  String barPaygateWay;
+	@Value("#{config['wechat.query.gateway']}")
+	private  String querygateWay;
+	@Value("#{config['wechat.reverse.gateway']}")
+	private  String reverseGateWay;
+	//商品描述
+	private  String body = "路朴-毕业季";
+	
+	/**
+	 * 微信二维码支付
+	 * @param out_trade_no 商户订单号
+	 * @param total_amount 付款金额
+	 * @param subject 订单名称
+	 * @author liuqiang@haliaeetus.cn
+	 * @date 2015年12月6日
+	 * @version 1.0
+	 * @return 
+	 */
+	public HttpResponseDto qrPay(String out_trade_no,String total_amount) {
+		if(StringUtils.isBlank(out_trade_no) 
+				|| StringUtils.isBlank(total_amount)) {
+			logger.error("IllegalArgumentException#WeChatProxy");
+			return null;
+		}
+		//交易类型
+		String trade_type = "NATIVE";
+		// 随机字符串
+		String nonce_str = TenpayUtil.getNonceStr();
+		//订单金额 转换为分
+		String totalFee = TenpayUtil.getMoney(total_amount);
+		//获取机器IP地址
+		String spbill_create_ip = getLocalIp();
+		SortedMap<String, String> packageParams = new TreeMap<String, String>();
+		packageParams.put("appid", appID);
+		packageParams.put("mch_id", partner);
+		packageParams.put("nonce_str", nonce_str);
+		packageParams.put("body", body);
+		packageParams.put("out_trade_no", out_trade_no);
+		packageParams.put("total_fee", totalFee);
+		packageParams.put("spbill_create_ip", spbill_create_ip);
+		packageParams.put("notify_url", notifyUrl);
+		packageParams.put("trade_type", trade_type);
+		//生成签名
+		String sign = TenpayUtil.createSign(packageParams,partnerKey);
+		String xml = "<xml>" + "<appid>" + appID + "</appid>" + "<mch_id>"
+				+ partner + "</mch_id>" + "<nonce_str>" + nonce_str
+				+ "</nonce_str>" + "<sign>" + sign + "</sign>"
+				+ "<body><![CDATA[" + body + "]]></body>" 
+				+ "<out_trade_no>" + out_trade_no
+				+ "</out_trade_no>"
+				+ "<total_fee>" + totalFee + "</total_fee>"
+				+ "<spbill_create_ip>" + spbill_create_ip
+				+ "</spbill_create_ip>" + "<notify_url>" + notifyUrl
+				+ "</notify_url>" + "<trade_type>" + trade_type
+				+ "</trade_type>" + "</xml>";
+		return  HttpUtil.post(prPaygateWay, xml);
+	}
+	
+	/**
+	 * 微信条码下单支付
+	 * @param out_trade_no  商户订单号
+	 * @param auth_code  付款条码
+	 * @param total_amount 付款金额
+	 * @author liuqiang@haliaeetus.cn
+	 * @date 2015年12月7日
+	 * @version 1.0
+	 * @return
+	 */
+	public HttpResponseDto barPay(String out_trade_no, String auth_code, String total_amount){
+		if(StringUtils.isBlank(out_trade_no) 
+			|| StringUtils.isBlank(auth_code) 
+			|| StringUtils.isBlank(total_amount)) {
+				logger.error("IllegalArgumentException#WeChatProxy");
+				return null;
+		}
+		// 随机字符串
+		String nonce_str = TenpayUtil.getNonceStr();
+		//订单金额 转换为分
+		String totalFee = TenpayUtil.getMoney(total_amount);
+		//获取机器IP地址
+		String spbill_create_ip = getLocalIp();
+		SortedMap<String, String> packageParams = new TreeMap<String, String>();
+		packageParams.put("appid", appID);
+		packageParams.put("mch_id", partner);
+		packageParams.put("nonce_str", nonce_str);
+		packageParams.put("body", body);
+		packageParams.put("out_trade_no", out_trade_no);
+		packageParams.put("total_fee", totalFee);
+		packageParams.put("spbill_create_ip", spbill_create_ip);
+		packageParams.put("auth_code", auth_code);
+		//生成签名
+		String sign = TenpayUtil.createSign(packageParams,partnerKey);
+		String xml = "<xml>" + "<appid>" + appID + "</appid>" + "<mch_id>"
+				+ partner + "</mch_id>" + "<nonce_str>" + nonce_str
+				+ "</nonce_str>" + "<sign>" + sign + "</sign>"
+				+ "<body><![CDATA[" + body + "]]></body>" 
+				+ "<out_trade_no>" + out_trade_no
+				+ "</out_trade_no>"
+				+ "<total_fee>" + totalFee + "</total_fee>"
+				+ "<spbill_create_ip>" + spbill_create_ip
+				+ "</spbill_create_ip><auth_code>"
+				+	auth_code+"</auth_code>"  + "</xml>";
+		return  HttpUtil.post(barPaygateWay, xml);
+	}
+	
+	/**
+	 * 微信订单查询
+	 * @param out_trade_no 商户订单号
+	 * @author liuqiang@haliaeetus.cn
+	 * @date 2015年12月11日
+	 * @version 1.0
+	 * @return 
+	 */
+	public HttpResponseDto query(String out_trade_no) {
+		if(StringUtils.isBlank(out_trade_no)) {
+			logger.error("IllegalArgumentException#WeChatProxy");
+			return null;
+		}
+		// 随机字符串
+		String nonce_str = TenpayUtil.getNonceStr();
+		SortedMap<String, String> packageParams = new TreeMap<String, String>();
+		packageParams.put("appid", appID);
+		packageParams.put("mch_id", partner);
+		packageParams.put("nonce_str", nonce_str);
+		packageParams.put("out_trade_no", out_trade_no);
+		//生成签名
+		String sign = TenpayUtil.createSign(packageParams,partnerKey);
+		String xml = "<xml>" + "<appid>" + appID + "</appid>" + "<mch_id>"
+				+ partner + "</mch_id>" + "<nonce_str>" + nonce_str
+				+ "</nonce_str>" + "<sign>" + sign + "</sign>"
+				+ "<out_trade_no>" + out_trade_no
+				+ "</out_trade_no>"
+				+ "</xml>";
+		return  HttpUtil.post(querygateWay, xml);
+	}
+	/**
+	 * 撤销支付
+	 * @param out_trade_no
+	 * @return
+	 */
+	public HttpResponseDto reverse(String out_trade_no) {
+		if(StringUtils.isBlank(out_trade_no)) {
+			logger.error("IllegalArgumentException#WeChatProxy");
+			return null;
+		}
+		// 随机字符串
+		String nonce_str = TenpayUtil.getNonceStr();
+		SortedMap<String, String> packageParams = new TreeMap<String, String>();
+		packageParams.put("appid", appID);
+		packageParams.put("mch_id", partner);
+		packageParams.put("nonce_str", nonce_str);
+		packageParams.put("out_trade_no", out_trade_no);
+		//生成签名
+		String sign = TenpayUtil.createSign(packageParams,partnerKey);
+		String xml = "<xml>" 
+				+ "<appid>" + appID + "</appid>" 
+				+ "<mch_id>" + partner + "</mch_id>" 
+				+ "<nonce_str>" + nonce_str + "</nonce_str>" 
+				+ "<out_trade_no>" + out_trade_no + "</out_trade_no>"
+				+ "<sign>" + sign + "</sign>"
+				+ "</xml>";
+		return  HttpUtil.postsecurity(reverseGateWay, xml);
+	}
+	
+	private String getLocalIp() {
+		String spbill_create_ip;
+		try {
+			spbill_create_ip = InetAddress.getLocalHost().getHostAddress();
+		} catch (Exception e) {
+		logger.error("get spbill_create_ip error#" + e);
+		spbill_create_ip = "101.200.139.76";
+		} 
+		return spbill_create_ip;
+	}
+
+	@Override
+	public String toString() {
+		return "WeChatProxy [logger=" + logger + ", appID=" + appID + ", appsecret=" + appsecret + ", partner="
+				+ partner + ", partnerKey=" + partnerKey + ", openId=" + openId + ", notifyUrl=" + notifyUrl
+				+ ", prPaygateWay=" + prPaygateWay + ", barPaygateWay=" + barPaygateWay + ", querygateWay="
+				+ querygateWay + ", body=" + body + "]";
+	}
+	/**
+	 * 支付,如果失败则撤单
+	 * @param out_trade_no
+	 * @param auth_code
+	 * @param total_amount
+	 * @return
+	 */
+	public  Map<String,String> payAndcancel(String out_trade_no, String auth_code, String total_amount){
+		Map<String,String> map = new HashMap<String,String>();
+		HttpResponseDto hrd = this.barPay(out_trade_no, auth_code, total_amount);
+		logger.error(hrd.toString());
+		map.put("paySuccess", "false");
+		Map<String, String> resultMap = null;
+		try {
+			resultMap = ParseXMLUtils.parseXML(hrd.getData());
+		} catch (Exception e1) {
+		}
+    	if(resultMap.get("result_code") != null && "SUCCESS".equals(resultMap.get("result_code"))){
+    		map.put("paySuccess", "true");
+			map.put("tradeNo", resultMap.get("transaction_id"));
+			map.put("msg", "SUCCESS");
+    	}else if(resultMap.get("result_code") != null && "FAIL".equals(resultMap.get("result_code"))
+    			&& ("SYSTEMERROR".equals(resultMap.get("err_code")) 
+    					|| "BANKERROR".equals(resultMap.get("err_code")) 
+    					|| "USERPAYING".equals(resultMap.get("err_code")))){
+    		map.put("tradeNo", resultMap.get("transaction_id"));
+    		boolean needloop = true;
+			int i = 0;
+			try {
+				while(needloop){
+					i++;
+					if(i > 3){
+						needloop=false;
+						HttpResponseDto reverseHrd = this.reverse(out_trade_no);
+						logger.error(reverseHrd.toString());
+						Map<String, String> reverseMap = ParseXMLUtils.parseXML(reverseHrd.getData());
+						if(reverseMap != null){
+							if(reverseMap.get("result_code") != null && "SUCCESS".equals(reverseMap.get("result_code"))){
+								map.put("msg", "支付失败,本次支付已撤销并退款!");
+							}else{
+								map.put("msg", "支付失败,撤销操作未成功!");
+							}
+						}else{
+							map.put("msg", "支付失败,撤销操作未成功!");
+						}
+						break;
+					}
+					Thread.sleep(5000);
+					HttpResponseDto queryHrd = this.query(out_trade_no);
+					logger.error(queryHrd.toString());
+					Map<String, String> queryMap = ParseXMLUtils.parseXML(queryHrd.getData());
+					if(queryMap != null && queryMap.get("result_code") != null && "SUCCESS".equals(queryMap.get("result_code"))){
+						map.put("tradeNo", queryMap.get("transaction_id"));
+						if("REFUND".equals(queryMap.get("trade_state")) || "CLOSED".equals(queryMap.get("trade_state")) 
+								|| "REVOKED".equals(queryMap.get("trade_state"))){
+							map.put("msg", "支付失败,本次支付已撤销或关闭!");
+							needloop=false;
+			    			break;
+						}else if("SUCCESS".equals(queryMap.get("trade_state"))){
+							map.put("paySuccess", "true");
+			    			map.put("msg", "SUCCESS");
+			    			needloop=false;
+			    			break;
+						}
+					}
+				}
+			}catch (Exception e) {
+			}
+    		
+    	}else{
+    		map.put("msg", "支付失败");
+    	}
+    	return map;
+	}
+	
+}

+ 164 - 0
express-main/src/main/java/cn/haliaeetus/controller/htky/invoker/HtkyAPIInvoker.java

@@ -0,0 +1,164 @@
+package cn.haliaeetus.controller.htky.invoker;
+
+import com.alibaba.fastjson.JSONObject;
+import com.thoughtworks.xstream.core.util.Base64Encoder;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.util.APIConfig;
+import cn.haliaeetus.entity.Delivery;
+import cn.haliaeetus.framework.util.DateUtil;
+import cn.haliaeetus.util.DeliveryUtil;
+
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.security.MessageDigest;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * <p>汇通API调用器</p>
+ * 
+ * @author sqj
+ * @since 1.0
+ * @version 1.0
+ */
+@Component
+public class HtkyAPIInvoker {
+	/**
+	 * 派件订单状态反馈
+	 */
+	public static String prepareDeliveryStatusFeekback(Delivery delivery) throws Exception {
+		if (delivery == null) {
+			return "";
+		}
+		String code = delivery.getExpcode();
+		if (!StringUtils.hasText(code)) {
+			return "";
+		}
+		
+		Integer storeId = delivery.getStoreId();
+		if (storeId == null || storeId <= 0) {
+			return "";
+		}
+		
+		DeliveryStatus status = getDeliveryStatus(delivery);
+		if (DeliveryStatus.NULL.equals(status)) {
+			return "";
+		}
+		
+		JSONObject obj = new JSONObject();
+		obj.put("serviceProviderCode", APIConfig.getHtkyServiceProviderCode());
+		obj.put("requestTime", DateUtil.timestampFormat(new Date()));
+		obj.put("operator", "BESTEXP");
+		obj.put("transactionCode", generateTransactionCode(APIConfig.getHtkyServiceProviderCode(), code));
+		obj.put("billCode", code);
+		obj.put("status", status.getValue());
+		obj.put("remark", status.getRemark());
+		obj.put("serviceSiteCode", generateServiceSiteCode(storeId));
+		
+		String requestData = obj.toJSONString();
+		
+		Map<String, String> params = new HashMap<>();
+		params.put("partnerID", APIConfig.getHtkyPartnerId());
+		params.put("serviceType", "UpdateStatusByMailNo");
+		params.put("bizData", requestData);
+		params.put("digest", generateSign(requestData + APIConfig.getHtkyPartnerKey()));
+		
+		return JSONObject.toJSONString(params);
+	}
+	
+	private static String generateServiceSiteCode(int storeId) {
+		if (storeId <= 0) {
+			return "";
+		}
+		
+		String prefix = "XM";
+		
+		String zeros = "";
+		int count = 7 - (storeId + "").length() - prefix.length();
+		for (int i = 0; i < count; i++) {
+			zeros += "0";
+		}
+		
+		return prefix + zeros + storeId;
+	}
+	
+	/**
+	 * 生成签名
+	 */
+	private static String generateSign(String requestData) throws Exception {
+		if (!StringUtils.hasText(requestData)) {
+			return "";
+		}
+		
+		MessageDigest md = MessageDigest.getInstance("MD5");
+		md.update(requestData.getBytes("UTF-8"));
+		byte[] bytes = md.digest();
+		return new Base64Encoder().encode(bytes);
+	}
+	
+	/**
+	 * 生成交易号
+	 * @throws Exception
+	 */
+	private static String generateTransactionCode(String serviceProviderCode, String billCode) throws Exception {
+		if (!StringUtils.hasText(serviceProviderCode) || !StringUtils.hasText(billCode)) {
+			return "";
+		}
+		
+		return serviceProviderCode + "-" + UUID.nameUUIDFromBytes(billCode.getBytes("UTF-8"));
+	}
+	
+	private static DeliveryStatus getDeliveryStatus(Delivery delivery) {
+		if (delivery.getStatus() == Constants.ORDER_STATUS_STORED) {
+			return DeliveryStatus.ARRIVAL;
+		} else if (delivery.getStatus() == Constants.ORDER_STATUS_COMPLETE) {
+			return DeliveryStatus.TAKEN;
+		} else if (delivery.getStatus() == Constants.ORDER_STATUS_REJECT_PICK_UP) {
+			int rejectReason = DeliveryUtil.getRejectReasonByShortName(delivery.getProblemCode());
+			
+			if (rejectReason == Constants.REJECT_REASON_OUTRETRUN_2 ||
+				rejectReason == Constants.REJECT_REASON_OUTRETRUN_3 ||
+				rejectReason == Constants.REJECT_REASON_OUTRETRUN_4 ||
+				rejectReason == Constants.REJECT_REASON_OUTRETRUN_7) {
+				return DeliveryStatus.NOBODY_TAKE;
+			}
+			
+			if (rejectReason == Constants.REJECT_REASON_OUTREJECTION_1 ||
+				rejectReason == Constants.REJECT_REASON_OUTREJECTION_2 ||
+				rejectReason == Constants.REJECT_REASON_OUTREJECTION_3 ||
+				rejectReason == Constants.REJECT_REASON_OUTREJECTION_4) {
+				return DeliveryStatus.REJECT_TAKE;
+			}
+		}
+		
+		return DeliveryStatus.NULL;
+	}
+	
+	private enum DeliveryStatus {
+		ARRIVAL("S01", "快递员已投递包裹至快递柜"),
+		TAKEN("S02", "收件人已取货"),
+		NOBODY_TAKE("S03", "包裹无人收取快递员退回包裹"),
+		REJECT_TAKE("S04", "用户拒收快递员退回包裹"),
+		NULL("", "");
+		
+		private String value;
+		private String remark;
+		
+		private DeliveryStatus(String value, String remark) {
+			this.value = value;
+			this.remark = remark;
+		}
+
+		public String getValue() {
+			return value;
+		}
+
+		public String getRemark() {
+			return remark;
+		}
+	}
+}

+ 36 - 0
express-main/src/main/java/cn/haliaeetus/controller/jhy/JhyPhoneController.java

@@ -0,0 +1,36 @@
+package cn.haliaeetus.controller.jhy;
+
+import cn.haliaeetus.entity.store.ResultBean;
+import cn.haliaeetus.service.jhy.JhyPhoneService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * @ClassName jhyPhoneController
+ * @Description TODO
+ * @Author kael
+ * @Date 2019/8/5 0005 上午 10:55
+ * @Version 1.0
+ **/
+@Controller
+@RequestMapping(value = "/jhy/phone")
+public class JhyPhoneController {
+
+    @Autowired
+    private JhyPhoneService jhyPhoneService;
+
+    /**
+     * 新增电话号码
+     * @param json
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/add", method = {RequestMethod.POST})
+    @ResponseBody
+    public ResultBean<Boolean> addPhone(String json) throws Exception{
+        return new ResultBean<Boolean>(jhyPhoneService.insertSelective(json));
+    }
+}

+ 255 - 0
express-main/src/main/java/cn/haliaeetus/controller/lanjian/ElePrintController.java

@@ -0,0 +1,255 @@
+package cn.haliaeetus.controller.lanjian;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.lanjian.shunfeng.SFConstants;
+import cn.haliaeetus.controller.lanjian.shunfeng.SFPrintUtil;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.response.OrderResponse;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.response.Response;
+import cn.haliaeetus.controller.lanjian.yuantong.YTOPrintUtil;
+import cn.haliaeetus.controller.web.helper.ReceivedHelper;
+import cn.haliaeetus.entity.DeliveryMsgTemplateConfig;
+import cn.haliaeetus.entity.Received;
+import cn.haliaeetus.entity.SfBillDevInfo;
+import cn.haliaeetus.entity.SfBillOrderInfo;
+import cn.haliaeetus.entity.Store;
+import cn.haliaeetus.entity.StoreReceivedExpress;
+import cn.haliaeetus.entity.User;
+import cn.haliaeetus.entity.YtBillDevInfo;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.base.controller.BaseController;
+import cn.haliaeetus.framework.base.log.Logger;
+import cn.haliaeetus.service.BasicInfoService;
+import cn.haliaeetus.service.DeliveryMsgTemplateConfigService;
+import cn.haliaeetus.service.DevInfoService;
+import cn.haliaeetus.service.ReceivedService;
+import cn.haliaeetus.service.SfBillOrderInfoService;
+import cn.haliaeetus.service.StoreReceivedExpressService;
+
+/**
+ * 打印面单服务接口
+ * 
+ * @author Xs
+ */
+@Controller
+public class ElePrintController extends BaseController{
+	
+	@Autowired
+    private BasicInfoService basicInfoService;
+	
+	@Autowired
+	private ReceivedService receivedService;
+	
+	@Autowired
+	private DevInfoService devInfoService;
+	
+	@Autowired
+	private ReceivedHelper receivedHelper;
+	
+	@Autowired
+	private StoreReceivedExpressService storeReceivedExpressService;
+	
+	@Autowired
+	private DeliveryMsgTemplateConfigService deliveryMsgTemplateConfigService;
+	
+	@Autowired
+	private SfBillOrderInfoService sfBillOrderInfoService;
+	
+	private static final Logger LOG = Logger.getInstance(ElePrintController.class);
+	
+	@RequestMapping("/lanjian/eleprint")
+	public String eleprint(HttpServletRequest request, HttpServletResponse response) {	
+		String id = request.getParameter("id");
+		request.setAttribute("id", id);
+		return "received/eletemplate/print_eletemplate";
+	}
+	
+	@RequestMapping("/lanjian/print")
+	public String print(HttpServletRequest request, HttpServletResponse response) {
+		
+		User user = getFromCookie(request);
+		if (user == null) {
+			request.setAttribute("msg", "登录超时");
+			return "error";
+		}
+		
+		//根据id获取揽件信息
+		String id = request.getParameter("id");
+		String expCode = null;
+		if(_.isNotEmpty(id)){
+			try{
+				Received received = receivedService.getById(Integer.valueOf(id));
+				if(received!=null){
+					Store store = basicInfoService.getStoreById(received.getStoreid());
+					if(store==null){
+						request.setAttribute("msg", "门店信息错误");
+						return "error";
+					}
+					if(received.getExpid()==Constants.EXPRESS_TYPE_YT){
+						YtBillDevInfo devInfo = devInfoService.getYtBillDevInfo(store.getProvinceId());
+						if(devInfo == null){
+							devInfo = devInfoService.getYtBillDevInfo(0);
+						}
+						expCode = YTOPrintUtil.printBill(devInfo, received, store, request, response);
+						if(_.isNotEmpty(expCode)){
+							received.setExpcode(expCode);
+							receivedService.updateById(received);
+							receivedHelper.queryExp100Delivery(received);  // 调用快递100接口
+							receivedHelper.sendReceivedWeixin(received); // 发送微信
+						}else{
+							request.setAttribute("msg", "获取单号失败");
+							return "error";
+						}
+					} else if(received.getExpid()==Constants.EXPRESS_TYPE_SF) {
+						
+						if (_.isEmpty(store.getIsPrinter()) || "0".equals(store.getIsPrinter()) || "1".equals(store.getIsPrinter())) {
+							request.setAttribute("msg", "该门店未配置热敏打印机");
+							return "error";
+						}
+						
+						SfBillDevInfo devInfo = devInfoService.getSfBillDevInfo(received.getStoreid());
+						if(devInfo == null){
+							request.setAttribute("msg", "未获取到该门店的顺丰电子运单配置信息");
+							return "error";
+						}
+						
+						String storeAddress = getStoreAddress(user, received, store);
+						SfBillOrderInfo sfBillOrderInfo = sfBillOrderInfoService.getSfBillOrderInfo(received.getId());
+						
+						// 存在下订单记录时,校验是否需要重新向顺丰下订单生成电子运单号
+						if (sfBillOrderInfo != null) {
+							String verifyXml = SFPrintUtil.getOrderServiceRequestXml(received, devInfo, store, storeAddress, sfBillOrderInfo.getOrderId());
+							String verifyCode = SFPrintUtil.getVerifyCode(verifyXml, devInfo.getCheckword());
+							
+							// 不需要重新下订单,直接打印
+							if (verifyXml.equals(sfBillOrderInfo.getXmlData()) && verifyCode.equals(sfBillOrderInfo.getVerifyCode())) {
+								
+								if (_.isEmpty(received.getExpcode()) || !received.getExpcode().equals(sfBillOrderInfo.getExpcode())) {
+									// 更新单号
+									received.setExpcode(sfBillOrderInfo.getExpcode());
+									receivedService.updateById(received);
+								}
+								
+								// 生成电子面单PDF
+								SFPrintUtil.print(request, response, received, devInfo, sfBillOrderInfo, store, storeAddress);
+								return null;
+							}
+						}
+						
+						// 生成请求顺丰下订单(不含筛单)接口的xml报文和校验码
+						String orderId = getOrderId(received);
+						String requestXml = SFPrintUtil.getOrderServiceRequestXml(received, devInfo, store, storeAddress, orderId);
+						String requestVerifyCode = SFPrintUtil.getVerifyCode(requestXml, devInfo.getCheckword());
+						
+						// 请求顺丰下订单(不含筛单)接口
+						Response postResponse = SFPrintUtil.postSF(requestXml, requestVerifyCode, devInfo);
+						if (postResponse != null ) {
+							if (SFConstants.RESPONSE_OK.equals(postResponse.getHead())) {
+								OrderResponse orderResponse = postResponse.getBody().getOrderResponse();
+								
+								// 更新单号
+								expCode = orderResponse.getMailno();
+								received.setExpcode(expCode);
+								receivedService.updateById(received);
+								
+								// 保存向顺丰下订单记录
+								SfBillOrderInfo orderInfo = new SfBillOrderInfo();
+								orderInfo.setReceivedId(received.getId());
+								orderInfo.setOrderId(orderId);
+								orderInfo.setExpcode(expCode);
+								orderInfo.setOriginCode(orderResponse.getOrigincode());
+								orderInfo.setDestCode(orderResponse.getDestcode());
+								orderInfo.setXmlData(requestXml);
+								orderInfo.setVerifyCode(requestVerifyCode);
+								sfBillOrderInfoService.save(orderInfo);
+								
+								// 生成电子面单PDF
+								SFPrintUtil.print(request, response, received, devInfo, orderInfo, store, storeAddress);
+								
+								// 调用快递100接口、发送微信
+								receivedHelper.queryExp100Delivery(received);
+								receivedHelper.sendReceivedWeixin(received);
+								
+							} else {
+								request.setAttribute("msg", "获取单号失败");
+								LOG.record(_.f("获取单号失败,失败原因:%s,揽件信息:[%s]",  postResponse.getError().getMsg(), received));
+								return "error";
+							}
+						} else {
+							LOG.record(_.f("顺丰服务未返回响应信息,揽件信息:[%s]", received));
+							request.setAttribute("msg", "顺丰电子面单服务异常,请稍后重试 !");
+							return "error";
+						}
+						
+					} else{
+						request.setAttribute("msg", "此快递不支持电子面单打印!");
+						return "error";
+					}
+				}else{
+					request.setAttribute("msg", "揽件不存在");
+					return "error";
+				}
+			}catch(Exception e){
+				e.printStackTrace();
+				request.setAttribute("msg", "服务异常");
+				return "error";
+			}
+		}else{
+			request.setAttribute("msg", "参数错误");
+			return "error";
+		}
+		
+		return null;
+	}
+	
+	/**
+	 * 获取寄件地址
+	 * 
+	 * @param user 登录用户
+	 * @param received 揽件信息
+	 * @param store 门店信息
+	 * @return 寄件地址
+	 */
+	private String getStoreAddress (User user, Received received, Store store) {
+		String storeAddress = StringUtils.EMPTY;
+		List<StoreReceivedExpress> list = storeReceivedExpressService.getExpressByStoreIdExpId(user.getStoreId(), received.getExpid());
+		StoreReceivedExpress storeReceivedExpress = null;
+		if (_.isNotEmpty(list)) {
+			storeReceivedExpress = list.get(0);
+		}
+		
+		if (storeReceivedExpress == null || _.isEmpty(storeReceivedExpress.getAddress())) {
+			DeliveryMsgTemplateConfig smsConfig = deliveryMsgTemplateConfigService
+					.getMsgTemplateConfig(user.getStoreId(), 6, 1);
+			
+			if (smsConfig != null && _.isNotEmpty(smsConfig.getStoreAddress())) {
+				storeAddress = smsConfig.getStoreAddress();
+			}
+			if (_.isEmpty(storeAddress)) {
+				storeAddress = store.getShortAddress();
+			}
+		} else {
+			storeAddress = storeReceivedExpress.getAddress();
+		}
+		return storeAddress;
+	}
+	
+	/**
+	 * 生成订单号
+	 * 
+	 * @param received 揽件信息
+	 * @return 订单号
+	 */
+	private String getOrderId(Received received) {
+		return received.getId() + "" + System.currentTimeMillis();
+	}
+}

+ 101 - 0
express-main/src/main/java/cn/haliaeetus/controller/lanjian/shunfeng/SFConstants.java

@@ -0,0 +1,101 @@
+package cn.haliaeetus.controller.lanjian.shunfeng;
+
+/**
+ * 顺丰电子面单对接常量类
+ * 
+ * @author Guolz
+ *
+ */
+public class SFConstants {
+
+	
+	/**
+	 * 下订单接口服务名
+	 */
+	public static final String ORDER_SERVICE = "OrderService";
+	
+	/**
+	 * 路由查询接口服务名
+	 */
+	public static final String ROUTE_SERVICE = "RouteService";
+	
+	/**
+	 * 路由推送接口服务名
+	 */
+	public static final String ROUTE_PUSH_SERVICE = "RoutePushService";
+	
+	/**
+	 * 增值服务-代收货款
+	 */
+	public static final String ADDED_SERVICE_COD = "COD";
+	
+	/**
+	 * 增值服务-保价
+	 */
+	public static final String ADDED_SERVICE_INSURE = "INSURE";
+	
+	/**
+	 * 增值服务-签收短信通知
+	 */
+	public static final String ADDED_SERVICE_MSG = "MSG";
+	
+	/**
+	 * 增值服务-包装服务
+	 */
+	public static final String ADDED_SERVICE_PKFEE = "PKFEE";
+	
+	/**
+	 * 增值服务-特殊保价
+	 */
+	public static final String ADDED_SERVICE_SINSURE = "SINSURE";
+	
+	/**
+	 * 增值服务-特殊配送
+	 */
+	public static final String ADDED_SERVICE_SDELIVERY = "SDELIVERY";
+	
+	/**
+	 * 增值服务-特殊增值服务
+	 */
+	public static final String ADDED_SERVICE_SADDSERVICE = "SADDSERVICE";
+	
+	/**
+	 * 增值服务-定时派送
+	 */
+	public static final String ADDED_SERVICE_TDELIVERY = "TDELIVERY";
+	
+	/**
+	 * 增值服务-电商加急
+	 */
+	public static final String ADDED_SERVICE_URGENT = "URGENT";
+	
+	/**
+	 * 要求返回顺丰运单号
+	 */
+	public static final String GEN_BILL_NO = "1";
+	
+	/**
+	 * 付款方式:寄方付
+	 */
+	public static final String PAY_METHOD_J = "1";
+	
+	/**
+	 * 付款方式:到方付
+	 */
+	public static final String PAY_METHOD_D = "2";
+	
+	/**
+	 * 付款方式:第三方付
+	 */
+	public static final String PAY_METHOD_T = "3";
+	
+	/**
+	 * 响应结果:OK
+	 */
+	public static final String RESPONSE_OK = "OK";
+	
+	/**
+	 * 响应结果:ERR
+	 */
+	public static final String RESPONSE_ERR = "ERR";
+}

+ 601 - 0
express-main/src/main/java/cn/haliaeetus/controller/lanjian/shunfeng/SFPrintUtil.java

@@ -0,0 +1,601 @@
+package cn.haliaeetus.controller.lanjian.shunfeng;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.Consts;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.message.BasicNameValuePair;
+
+import sun.misc.BASE64Encoder;
+
+import com.itextpdf.text.Image;
+import com.itextpdf.text.pdf.AcroFields;
+import com.itextpdf.text.pdf.Barcode128;
+import com.itextpdf.text.pdf.PdfContentByte;
+import com.itextpdf.text.pdf.PdfReader;
+import com.itextpdf.text.pdf.PdfStamper;
+
+import cn.haliaeetus.constants.Constants;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.common.Body;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.request.AddedService;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.request.Cargo;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.request.Order;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.request.Request;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.request.RouteRequest;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.response.Response;
+import cn.haliaeetus.controller.lanjian.yuantong.util.XmlUtil;
+import cn.haliaeetus.entity.Received;
+import cn.haliaeetus.entity.SfBillDevInfo;
+import cn.haliaeetus.entity.SfBillOrderInfo;
+import cn.haliaeetus.entity.Store;
+import cn.haliaeetus.framework._;
+import cn.haliaeetus.framework.util.ComputeUtil;
+import cn.haliaeetus.framework.util.HttpUtil;
+
+/**
+ * 打印面单服务接口
+ * 
+ * @author Xs
+ */
+public class SFPrintUtil {
+	
+	/**
+	 * 生成请求下订单(不含筛单)接口xml报文
+	 * 
+	 * @param received 揽件信息
+	 * @param devInfo 顺丰商务开发信息
+	 * @param store 门店信息
+	 * @param storeAddress 寄件地址
+	 * @param orderId 订单号
+	 * @return xml报文
+	 */
+	public static String getOrderServiceRequestXml(Received received, SfBillDevInfo devInfo, Store store, String storeAddress, String orderId) {
+		Request request = new Request();
+		request.setHead(devInfo.getAccessCode());  // 对接编码
+		request.setService(SFConstants.ORDER_SERVICE); // 下订单接口服务名
+		
+		// 设置请求订单信息
+		Order order = new Order();
+		order.setOrderid(orderId); // 订单号
+		order.setIsGenBillNo(SFConstants.GEN_BILL_NO); // 要求顺丰返回运单号
+		order.setjCompany(received.getConsignorName()); // 寄件方公司名(使用寄件人姓名)
+		order.setjContact(received.getConsignorName()); // 寄件人
+		order.setjTel(received.getConsignorPhone()); // 寄件人电话
+		order.setjMobile(received.getConsignorPhone()); // 寄件人手机
+		order.setjProvince(store.getProvinceName()); // 寄件方所在省份
+		order.setjCity(store.getCityName()); // 寄件方所在城市
+		order.setjCounty(store.getAreaName()); // 寄件方所在县区
+		order.setjAddress(storeAddress); // 寄件地址
+		order.setdCompany(received.getConsigneeName()); // 到件方公司名(使用收件人姓名)
+		order.setdContact(received.getConsigneeName()); // 收件人
+		order.setdTel(received.getConsigneePhone()); // 收件人电话
+		order.setdMobile(received.getConsigneePhone()); // 收件人手机
+		order.setdProvince(received.getProvinceName() == null ? "" : received.getProvinceName().replace("市", "")); // 到件方所在省份
+		order.setdCity(received.getCityName() == null ? "" : received.getCityName()); // 到件方所在城市
+		order.setdCounty(received.getAreaName() == null ? "" : received.getAreaName()); // 到件方所在区县
+		order.setdAddress(received.getConsigneeAddress()); // 到件方详细地址
+		order.setCustid(devInfo.getCustid()); // 顺丰月结卡号
+		order.setPayMethod(SFConstants.PAY_METHOD_J); // 跟顺丰结算采用寄付月结
+		order.setExpressType(String.valueOf(received.getSfExpressType())); // 快件产品类别
+		order.setParcelQuantity("1"); // 默认1个包裹
+		
+		// 货物信息(托寄物)
+		List<Cargo> cargoList = new ArrayList<Cargo>();
+		Cargo cargo1 = new Cargo();
+		cargo1.setName(received.getShipment());
+		cargoList.add(cargo1);
+		order.setCargoList(cargoList);
+		
+		// 增值服务
+		List<AddedService> addedServiceList = getAddedServiceList(devInfo.getAddService(), received);
+		if (_.isNotEmpty(addedServiceList)) {
+			order.setAddedServiceList(addedServiceList);
+		}
+		
+		// 请求体Body设置
+		Body body = new Body();
+		body.setOrder(order);
+		request.setBody(body);
+		return XmlUtil.convertToXml(request, _.utf8, false);
+	}
+	
+	/**
+	 * 生成请求路由查询接口xml报文
+	 * 
+	 * @param expcode 顺丰单号
+	 * @param devInfo 顺丰商务开发信息
+	 * @param methodType 路由查询类别
+	 * @return xml报文
+	 */
+	public static String getRouteServiceRequestXml(String expcode, SfBillDevInfo devInfo) {
+		Request request = new Request();
+		request.setHead(devInfo.getAccessCode());  // 对接编码
+		request.setService(SFConstants.ROUTE_SERVICE); // 下订单接口服务名
+		
+		// 设置请求订单信息
+		RouteRequest routeRequest = new RouteRequest();
+		routeRequest.setTrackingNumber(expcode);
+		
+		// 请求体Body设置
+		Body body = new Body();
+		body.setRouteRequest(routeRequest);
+		request.setBody(body);
+		return XmlUtil.convertToXml(request, _.utf8, false);
+	}
+	
+	public static void main(String[] args) throws IOException {
+		SfBillDevInfo devInfo = new SfBillDevInfo();
+		devInfo.setAccessCode("MSKWHCM");
+		devInfo.setCheckword("OFSGCN0aF2wC");
+		devInfo.setUrl("http://218.17.248.244:11080/bsp-oisp/sfexpressService");
+		String expcode = "444502371052";
+		String requestXml = getRouteServiceRequestXml(expcode, devInfo);
+		String verifyCode = getVerifyCode(requestXml, devInfo.getCheckword());
+		Response response = postSF(requestXml, verifyCode, devInfo);
+	}
+	
+	/**
+	 * 向顺丰接口发送请求
+	 * 
+	 * @param xml 请求的xml报文
+	 * @param checkword 对接密钥
+	 * @return 校验码
+	 * @throws IOException 
+	 */
+	public static Response postSF(String xml, String verifyCode, SfBillDevInfo devInfo) throws IOException {
+		List<NameValuePair> params = new ArrayList<>();
+		params.add(new BasicNameValuePair("xml", xml));
+		params.add(new BasicNameValuePair("verifyCode", verifyCode));
+		UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(params, Consts.UTF_8);
+		String response = HttpUtil.doPost(devInfo.getUrl(), formEntity);
+		
+		return XmlUtil.convertToJavaBean(response, Response.class);
+	}
+	
+	/**
+	 * 生成电子面单输出流
+	 * 
+	 * @param request 请求信息
+	 * @param response 响应信息
+	 * @param received 揽件信息
+ 	 * @param devInfo 顺丰电子面单开发信息
+	 * @param sfBillOrdeinfo 顺风电子面单信息
+	 * @param store 门店信息
+	 * @param storeAddress 寄件地址
+	 */
+	public static void print(HttpServletRequest request, HttpServletResponse response, Received received,
+				SfBillDevInfo devInfo, SfBillOrderInfo sfBillOrdeinfo, Store store, String storeAddress) {
+			PdfStamper ps = null;
+			InputStream is = null;
+			PdfReader pdfReader = null;
+			ServletOutputStream out = null;
+			try {
+				
+				// 电子运单pdf模板路径
+				String templatePath = request.getSession().getServletContext().getRealPath("/") + "eleTemplate/sf/";
+				is = new FileInputStream(new File(templatePath + "sf_ele_template.pdf"));
+				pdfReader = new PdfReader(is);
+				ByteArrayOutputStream bos = new ByteArrayOutputStream();
+				ps = new PdfStamper(pdfReader, bos);
+				out = response.getOutputStream();
+	
+				AcroFields s = ps.getAcroFields();
+				
+				// 顺丰特惠(陆运)需打印陆运标识
+				if (received.getSfExpressType() != null && received.getSfExpressType() == 2) {
+					s.setField("landMark", "E"); // 个性化提示区:陆运、电商特惠标打印“E”,电商业务打印“D”
+				}
+				s.setField("expressType", ExpressTypeEnum.getValue(received.getSfExpressType())); // 快递产品类型
+				s.setField("desCode", sfBillOrdeinfo.getDestCode());
+				s.setField("consigneeArea", handleArea(received.getProvinceName(), received.getCityName(), received.getAreaName(), false)); // 收件人省,市,区
+				s.setField("consigneeAddrName", handleConsineeInfo(received.getConsigneeAddress(), received.getConsigneeName(), received.getConsigneePhone()));
+				
+				// 保费
+				if (received.getProtectprice() > 0) {
+					s.setField("protectPrice", formatNum(received.getProtectprice()));
+					s.setField("protectPriceWorth", getInsuredVal(received));
+				}
+				
+				// 包装费
+				if (received.getPackprice() > 0) {
+					s.setField("packPrice", formatNum(received.getPackprice()));
+				}
+				s.setField("payType", PayTypeEnum.getValue(devInfo.getPayMethod())); // 付款方式
+				s.setField("payAccountNo", devInfo.getCustid()); // 月结账号
+				s.setField("actualWeight", formatNum(received.getWeight(), "kg")); // 实际重量
+				s.setField("chargeWeight", formatNum(received.getWeight(), "kg")); // 计费重量
+				if (received.getType() == Constants.RECEIVED_TYPE_SELF) {
+					s.setField("selfSend", "(自寄)");
+				}
+//				s.setField("freightPrice", formatNum(received.getFreightprice(), "元")); // 运费(运费由收派员手动填写)
+//				s.setField("totalCost[0]", formatNum(received.getPrice(), "元")); // 费用合计(费用合计由收派员手动填写)
+				s.setField("consignorInfo[0]", handleConsinorInfo(store.getProvinceName(), store.getCityName(), store.getAreaName(), storeAddress, received.getConsignorName(), received.getConsignorPhone()));
+				s.setField("originalCode", sfBillOrdeinfo.getOriginCode());
+				s.setField("consignorInfo[1]", handleConsinorInfo(store.getProvinceName(), store.getCityName(), store.getAreaName(), storeAddress, received.getConsignorName(), received.getConsignorPhone()));
+				
+				s.setField("consigneeInfo", handleConsineeInfo(received.getProvinceName(), received.getCityName(), received.getAreaName(), received.getConsigneeAddress(), received.getConsigneeName(), received.getConsigneePhone()));
+				s.setField("shipment", received.getShipment()); // 托寄物
+//				s.setField("totalCost[1]", formatNum(received.getPrice(), "元")); // 费用合计(费用合计由收派员手动填写)
+				
+				// TODO 不确定字段
+//				s.setField("orderId", sfBillOrdeinfo.getOrderId()); // 订单号
+//				s.setField("remark", "备注"); // 备注
+//				s.setField("busType", "COD"); // 个性化提示区:COD标识代收款业务,POD表示签单返回业务
+//				s.setField("selfPick", "(自取)"); // 客户同意快件自取
+//				s.setField("codMoney", "¥3000.5元");  // 代收货款
+				
+				Barcode128 barcode128 = new Barcode128();
+				barcode128.setCode(sfBillOrdeinfo.getExpcode());
+				barcode128.setFont(null);
+				PdfContentByte over = ps.getOverContent(1);
+				Image gif = barcode128.createImageWithBarcode(over, null, null);
+				gif.setDpi(10, 200);
+				gif.setBorderWidth(100);
+				gif.scaleAbsolute(128, 33);// 设置图片长宽
+				gif.setAbsolutePosition(33, 346); // 设置图片定位点
+				over.addImage(gif);
+				s.setField("expcode[0]", handleExpCode(sfBillOrdeinfo.getExpcode()));
+				
+				Barcode128 barcode1281 = new Barcode128();
+				barcode1281.setCode(sfBillOrdeinfo.getExpcode());
+				barcode1281.setFont(null);
+				Image gif1 = barcode128.createImageWithBarcode(over, null, null);
+				gif1.setDpi(10, 200);
+				gif1.setBorderWidth(100);
+				gif1.scaleAbsolute(129, 28);// 设置图片长宽
+				gif1.setAbsolutePosition(139, 138); // 设置图片定位点
+				over.addImage(gif1);
+				s.setField("expcode[1]", handleExpCode(sfBillOrdeinfo.getExpcode()));
+				
+				Image logo = Image.getInstance(templatePath + "logo.png");
+				logo.setDpi(100, 200);
+				logo.setBorderWidth(100);
+				logo.scaleAbsolute(56, 20);// 设置图片长宽
+				logo.setAbsolutePosition(10, 148); // 设置图片定位点
+				over.addImage(logo);
+				
+				Image telImage = Image.getInstance(templatePath + "95338_1008-17.png");
+				telImage.setDpi(100, 200);
+				telImage.setBorderWidth(100);
+				telImage.scaleAbsolute(58, 20);// 设置图片长宽
+				telImage.setAbsolutePosition(68, 148); // 设置图片定位点
+				over.addImage(telImage);
+				
+				// 设置为true/false在点击生成的pdf文档的填充域时有区别
+				ps.setFormFlattening(true);
+				ps.close();
+				out.write(bos.toByteArray());
+				out.flush();
+			} catch (Exception e) {
+				e.printStackTrace();
+			} finally {
+				try {
+					is.close();
+					pdfReader.close();
+					out.close();
+				} catch (Exception e) {
+					e.printStackTrace();
+					ps = null;
+					is = null;
+					pdfReader = null;
+					out = null;
+				}
+			}
+		}
+
+	/**
+	 * 先进行MD5编码,再进行Base64编码
+	 * 
+	 * @param str 待编码字符串
+	 * @return 编码后字符串
+	 */
+	public static String md5EncryptAndBase64(String str) {
+		return encodeBase64(md5Encrypt(str));
+	}
+
+	/**
+	 * 生成校验码
+	 * 
+	 * @param xml 请求的xml报文
+	 * @param checkword 对接密钥
+	 * @return 校验码
+	 */
+	public static String getVerifyCode(String xml, String checkword) {
+		return md5EncryptAndBase64(xml + checkword);
+	}
+	
+	/**
+	 * 生成请求报文中的增值服务信息
+	 * 
+	 * @param addedServiceStr 增值服务
+	 * @param received 揽件信息
+	 * @return 请求报文中的增值服务信息
+	 */
+	private static List<AddedService> getAddedServiceList(String addedServiceStr, Received received) {
+		if (_.isNotEmpty(addedServiceStr)) {
+			List<AddedService> addedServiceList = new ArrayList<AddedService>();
+			String[] addedServiceArr = addedServiceStr.split(",");
+			if (addedServiceArr != null && addedServiceArr.length > 0) {
+				for (String addedServiceS : addedServiceArr) {
+					AddedService addedService = getAddedService(addedServiceS, received);
+					if (addedService != null) {
+						addedServiceList.add(addedService);
+					}
+				}
+				return addedServiceList;
+			}
+		}
+		return null;
+	}
+	
+	/**
+	 * 生成请求报文中的增值服务信息
+	 * 
+	 * @param addedServiceS 增值服务名
+	 * @param received 揽件信息
+	 * @return 请求报文中的增值服务信息
+	 */
+	private static AddedService getAddedService(String addedServiceS, Received received) {
+		AddedService addedService = null;
+		if (_.isNotEmpty(addedServiceS)) {
+			switch(addedServiceS) {
+			case SFConstants.ADDED_SERVICE_COD:
+				break;
+			case SFConstants.ADDED_SERVICE_INSURE:
+				if (received.getProtectprice() > 0) {
+					addedService = createAddedService(addedServiceS, getInsuredVal(received), null);
+				}
+				break;
+			case SFConstants.ADDED_SERVICE_MSG:
+				break;
+			case SFConstants.ADDED_SERVICE_PKFEE:
+				if (received.getPackprice() > 0) {
+					addedService = createAddedService(addedServiceS, getPackFee(received), null);
+				}
+				break;
+			case SFConstants.ADDED_SERVICE_SINSURE:
+				break;
+			case SFConstants.ADDED_SERVICE_SDELIVERY:
+				break;
+			case SFConstants.ADDED_SERVICE_SADDSERVICE:
+				break;
+			case SFConstants.ADDED_SERVICE_TDELIVERY:
+				break;
+			case SFConstants.ADDED_SERVICE_URGENT:
+				break;
+			default:
+				break;
+			}
+		}
+		return addedService;
+	}
+	
+	/**
+	 * 生成请求报文中的增值服务信息
+	 * 
+	 * @param name 增值服务名
+	 * @param value 增值服务扩展属性
+	 * @param value1 增值服务扩展属性
+	 * @return 请求报文中的增值服务信息
+	 */
+	private static AddedService createAddedService(String name, String value, String value1) {
+		AddedService addedService = new AddedService();
+		addedService.setName(name);
+		addedService.setValue(value);
+		addedService.setValue1(value1);
+		return addedService;
+	}
+	
+	private static String getInsuredVal(Received received) {
+		return String.valueOf(received.getProtectprice() * 2);
+	}
+	
+	private static String getPackFee(Received received) {
+		return String.valueOf(ComputeUtil.parseToDouble(received.getPackprice()));
+	}
+	
+	/**
+	 * 将数字转换为不带单位的字符串
+	 * 
+	 * @param num 数字
+	 * @return 不带单位的字符串
+	 */
+	private static String formatNum(Integer num) {
+		if (num != null) {
+			return String.valueOf(num / 100);
+		}
+		return "";
+	}
+	
+	/**
+	 * 将数字转换为带单位的字符串
+	 * 
+	 * @param num 数字
+	 * @param unit 单位
+	 * @return 带单位的字符串
+	 */
+	private static String formatNum(Object num, String unit) {
+		if (num != null) {
+			return String.valueOf(Long.parseLong(String.valueOf(num)) / 100) + unit;
+		}
+		return "";
+	}
+
+	/**
+	 * 格式化收件人省市区(省,市,区)
+	 * 
+	 * @param provinceName 省
+	 * @param cityName 市
+	 * @param areaName 区/县
+	 * @return 省,市,区
+	 */
+	private static String handleArea(String provinceName, String cityName, String areaName, boolean isLastCommaNeed) {
+		if (isLastCommaNeed) {
+			return new StringBuilder().append(provinceName).append(",").append(cityName).append(",").append(areaName).append(",").toString();
+		}
+		return new StringBuilder().append(provinceName).append(",").append(cityName).append(",").append(areaName).toString();
+	}
+	
+	/**
+	 * 格式化顺丰电子面单单号为每三位加一个空格(例:123456789012 格式化后为 123 456 789 012)
+	 * 
+	 * @param expCode 顺丰电子面单单号
+	 * @return 格式化后的单号
+	 */
+	private static String handleExpCode(String expCode) {
+		String expCodeFormat = "";
+		if (_.isNotEmpty(expCode)) {
+			int size = ((expCode.length()) % 3 == 0) ? ((expCode.length()) / 3):((expCode.length()) / 3 + 1);
+			for(int i = 0; i < size; i++){
+			    int endIndex = (i + 1) * 3;
+			    if((i + 1) == size){
+			         endIndex = expCode.length();
+			    }
+			    if(i == 0){
+			    	expCodeFormat += expCode.substring(i, endIndex);
+			    }else{
+			    	expCodeFormat += " " + expCode.substring(i * 3, endIndex);
+			    }
+			}
+		}
+		return expCodeFormat;
+	}
+	
+	/**
+	 * 根据寄件信息拼接电子面单上的寄件信息
+	 * 
+	 * @param provinceName 省
+	 * @param cityName 市
+	 * @param areaName 区/县
+	 * @param detailAddress 详细地址
+	 * @param consignorName 寄件人姓名
+	 * @param consignorPhone 寄件人电话
+	 * @return
+	 */
+	private static String handleConsinorInfo(String provinceName,
+			String cityName, String areaName, String detailAddress,
+			String consignorName, String consignorPhone) {
+		return new StringBuilder().append(handleArea(provinceName, cityName, areaName, true))
+				.append(System.getProperty("line.separator")).append(detailAddress)
+				.append(System.getProperty("line.separator")).append(consignorName).append("   ").append(consignorPhone).toString();
+	}
+	
+	/**
+	 * 根据收件信息拼接电子面单上的收件信息
+	 * 
+	 * @param provinceName 省
+	 * @param cityName 市
+	 * @param areaName 区/县
+	 * @param detailAddress 详细地址
+	 * @param consignorName 收件人姓名
+	 * @param consignorPhone 收件人电话
+	 */
+	private static String handleConsineeInfo(String detailAddress, String consigneeName, String consigneePhone) {
+		return new StringBuilder().append(detailAddress).append(System.getProperty("line.separator")).append(consigneeName).append("    ").append(consigneePhone).toString();
+	}
+	
+	/**
+	 * 根据收件信息拼接电子面单上的收件信息
+	 * 
+	 * @param provinceName 省
+	 * @param cityName 市
+	 * @param areaName 区/县
+	 * @param detailAddress 详细地址
+	 * @param consignorName 收件人姓名
+	 * @param consignorPhone 收件人电话
+	 */
+	private static String handleConsineeInfo(String provinceName,
+			String cityName, String areaName, String detailAddress,
+			String consigneeName, String consigneePhone) {
+		return new StringBuilder().append(handleArea(provinceName, cityName, areaName, true))
+				.append(detailAddress).append(System.getProperty("line.separator"))
+				.append(consigneeName).append("   ").append(consigneePhone).toString();
+	}
+
+	private static byte[] md5Encrypt(String encryptStr) {
+		try {
+			MessageDigest md5 = MessageDigest.getInstance("MD5");
+			md5.update(encryptStr.getBytes(_.utf8));
+			return md5.digest();
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	private static String encodeBase64(byte[] b) {
+		sun.misc.BASE64Encoder base64Encode = new BASE64Encoder();
+		String str = base64Encode.encode(b);
+		return str;
+	}
+	
+	/**
+     * 快递产品类型枚举
+     *
+     * @author guolz
+     */
+    private enum ExpressTypeEnum {
+    	BIAOZHUN(1, "标准快递"),
+        SF_TEHUI(2, "顺丰特惠"),
+        DIANSHANG_TEHUI(3, "电商特惠"),
+        DIANSHANG_SUPEI(7, "电商速配"),
+        QUANQIUSHUN(19, "全球顺"),
+        UNDEFINE(-1, "");
+
+    	private String value;
+    	private int code;
+    	
+    	private ExpressTypeEnum(int code, String value) {
+    		this.value = value;
+    		this.code = code;
+    	}
+    	
+    	public static String getValue(int code) {
+    		for (ExpressTypeEnum expressType : ExpressTypeEnum.values()) {
+    			if (expressType.code == code) {
+    				return expressType.value;
+    			}
+    		}
+    		return UNDEFINE.value;
+    	}
+    }
+    
+    /**
+     * 付款方式枚举
+     *
+     * @author guolz
+     */
+    private enum PayTypeEnum {
+    	JIFU(1, "寄付月结"),
+    	THIRD_PAY(2, "寄付月结、转第三方付"),
+        UNDEFINE(-1, "");
+
+    	private String value;
+    	private int code;
+    	
+    	private PayTypeEnum(int code, String value) {
+    		this.value = value;
+    		this.code = code;
+    	}
+    	
+    	public static String getValue(int code) {
+    		for (PayTypeEnum payType : PayTypeEnum.values()) {
+    			if (payType.code == code) {
+    				return payType.value;
+    			}
+    		}
+    		return UNDEFINE.value;
+    	}
+    }
+}

+ 80 - 0
express-main/src/main/java/cn/haliaeetus/controller/lanjian/shunfeng/bean/common/Body.java

@@ -0,0 +1,80 @@
+package cn.haliaeetus.controller.lanjian.shunfeng.bean.common;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.request.Extra;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.request.Order;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.request.RouteRequest;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.response.OrderResponse;
+import cn.haliaeetus.controller.lanjian.shunfeng.bean.response.RouteResponse;
+
+/**
+ * 顺丰电子面单Request
+ * @author guolz
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Body {
+	
+	/** 订单信息 */
+	@XmlElement(name="Order")
+	private Order order;
+	
+	/** 扩展信息 */
+	@XmlElement(name="Extra")
+	private Extra extra;
+	
+	/** 订单筛选接口响应信息 */
+	@XmlElement(name="OrderResponse")
+	private OrderResponse orderResponse;
+	
+	/** 路由查询接口请求信息 */
+	@XmlElement(name="RouteRequest")
+	private RouteRequest routeRequest;
+	
+	/** 路由查询接口响应信息 */
+	@XmlElement(name="RouteResponse")
+	private RouteResponse routeResponse;
+
+	public Order getOrder() {
+		return order;
+	}
+
+	public void setOrder(Order order) {
+		this.order = order;
+	}
+
+	public Extra getExtra() {
+		return extra;
+	}
+
+	public void setExtra(Extra extra) {
+		this.extra = extra;
+	}
+
+	public OrderResponse getOrderResponse() {
+		return orderResponse;
+	}
+
+	public void setOrderResponse(OrderResponse orderResponse) {
+		this.orderResponse = orderResponse;
+	}
+
+	public RouteRequest getRouteRequest() {
+		return routeRequest;
+	}
+
+	public void setRouteRequest(RouteRequest routeRequest) {
+		this.routeRequest = routeRequest;
+	}
+
+	public RouteResponse getRouteResponse() {
+		return routeResponse;
+	}
+
+	public void setRouteResponse(RouteResponse routeResponse) {
+		this.routeResponse = routeResponse;
+	}
+}

Some files were not shown because too many files changed in this diff