Browse Source

app代码提交

liujiankang 7 years ago
parent
commit
5114e92b9d
100 changed files with 9867 additions and 0 deletions
  1. 37 0
      iamberry-common-parent/iamberry-common-tool/.classpath
  2. 36 0
      iamberry-common-parent/iamberry-common-tool/.project
  3. 6 0
      iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.core.resources.prefs
  4. 13 0
      iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.jdt.core.prefs
  5. 4 0
      iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.m2e.core.prefs
  6. 6 0
      iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.wst.common.component
  7. 5 0
      iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.wst.common.project.facet.core.xml
  8. 69 0
      iamberry-common-parent/iamberry-common-tool/pom.xml
  9. 42 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/APIStatus.java
  10. 27 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/Constants.java
  11. 48 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/ImberryConfig.java
  12. 95 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/Response.java
  13. 59 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/ResponseHeader.java
  14. 174 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/des/MD5.java
  15. 88 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/AddressDTO.java
  16. 132 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/TuyaDTO.java
  17. 79 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/TuyaHistoryListDTO.java
  18. 94 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/TuyaHistoryRawDTO.java
  19. 74 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/TuyaHistoryResultDTO.java
  20. 66 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/log/RatFWLogger.java
  21. 242 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/AES.java
  22. 106 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/Des.java
  23. 65 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/HttpUtility.java
  24. 57 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/JsonParseUtil.java
  25. 62 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/MD5.java
  26. 60 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/Paginator.java
  27. 37 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/Result.java
  28. 246 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/TuyaConnector.java
  29. 51 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/TuyaMD5Util.java
  30. 137 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/WebJsonTokenUtil.java
  31. 146 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/verify/ValidateUtil.java
  32. 45 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/verify/ValidatorInterface.java
  33. 36 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/cache/CacheFactory.java
  34. 84 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/cache/LocalCache.java
  35. 166 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/autiXSS/AntiXSS.java
  36. 124 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/autiXSS/XSSHandler.java
  37. 113 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/file/FileType.java
  38. 211 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/file/FileUtils.java
  39. 221 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/file/ImageUtils.java
  40. 35 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/file/UploadResultBean.java
  41. 40 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/AddrUtil.java
  42. 229 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/DataSourceManager.java
  43. 755 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/DateTimeUtil.java
  44. 191 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/GetWxOrderno.java
  45. 685 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/HttpClient431Util.java
  46. 229 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ImageUtils.java
  47. 33 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/IpAddressUtil.java
  48. 37 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/MD5Util.java
  49. 79 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/MessageUtil.java
  50. 245 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/MoneyUtils.java
  51. 22 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/MyX509TrustManager.java
  52. 261 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/NameUtils.java
  53. 99 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ObjectExcelView.java
  54. 34 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/OrderNOUtil.java
  55. 103 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/PropertiesUtils.java
  56. 34 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/QQFace.java
  57. 211 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/RequestHandler.java
  58. 97 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ResponseJson.java
  59. 134 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ResultInfo.java
  60. 89 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/Sha1Util.java
  61. 220 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/SignUtil.java
  62. 66 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/StaticInfo.java
  63. 61 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/StrUtils.java
  64. 179 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/TenpayUtil.java
  65. 175 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/TextFilterUtil.java
  66. 156 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ToolsUtils.java
  67. 23 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/UUIDGenerator.java
  68. 153 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidateUtil.java
  69. 47 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidationResult.java
  70. 53 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidationUtils.java
  71. 45 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidatorInterface.java
  72. 124 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidatorUtil.java
  73. 157 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidatorUtil2Map.java
  74. 84 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/WxPayDto.java
  75. 233 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/WxPayResult.java
  76. 272 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/WxPayUtil.java
  77. 84 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/WxPrepayIdErrorResult.java
  78. 149 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/loadResultUtil.java
  79. 70 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/HostInfo.java
  80. 60 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/SpringContextHolder.java
  81. 41 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/StartZK.java
  82. 143 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/ZookeeperFactory.java
  83. 248 0
      iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/ZookeeperQueue.java
  84. 17 0
      iamberry-common-parent/iamberry-common-tool/src/main/resources/iamberry-app-service-config.properties
  85. 2 0
      iamberry-common-parent/iamberry-common-tool/src/main/resources/zk.properties
  86. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/APIStatus.class
  87. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/Constants.class
  88. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/ImberryConfig.class
  89. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/Response.class
  90. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/ResponseHeader.class
  91. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/des/MD5.class
  92. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/AddressDTO.class
  93. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/TuyaDTO.class
  94. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/TuyaHistoryListDTO.class
  95. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/TuyaHistoryRawDTO.class
  96. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/TuyaHistoryResultDTO.class
  97. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/log/RatFWLogger.class
  98. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/util/AES.class
  99. BIN
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/util/Des.class
  100. 0 0
      iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/util/HttpUtility.class

+ 37 - 0
iamberry-common-parent/iamberry-common-tool/.classpath

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+		<attributes>
+			<attribute name="owner.project.facets" value="java"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

+ 36 - 0
iamberry-common-parent/iamberry-common-tool/.project

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>iamberry-common-tool</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+	</natures>
+</projectDescription>

+ 6 - 0
iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.core.resources.prefs

@@ -0,0 +1,6 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
+encoding/<project>=UTF-8

+ 13 - 0
iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,13 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=do not generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.8

+ 4 - 0
iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.m2e.core.prefs

@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

+ 6 - 0
iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.wst.common.component

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
+    <wb-module deploy-name="iamberry-common-tool">
+        <wb-resource deploy-path="/" source-path="/src/main/java"/>
+        <wb-resource deploy-path="/" source-path="/src/main/resources"/>
+    </wb-module>
+</project-modules>

+ 5 - 0
iamberry-common-parent/iamberry-common-tool/.settings/org.eclipse.wst.common.project.facet.core.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+  <installed facet="jst.utility" version="1.0"/>
+  <installed facet="java" version="1.7"/>
+</faceted-project>

+ 69 - 0
iamberry-common-parent/iamberry-common-tool/pom.xml

@@ -0,0 +1,69 @@
+<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>
+	
+	<!-- 父类定义 -->
+	<parent>
+		<groupId>com.iamberry</groupId>
+		<artifactId>iamberry-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	
+	<!-- 工具类本身并不依赖其他模块 -->
+	<artifactId>iamberry-common-tool</artifactId>
+	
+	<!-- 依赖 -->
+	<dependencies>
+		<dependency>
+			<groupId>com.iamberry</groupId>
+			<artifactId>iamberry-common-config</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.elasticsearch</groupId>
+		    <artifactId>elasticsearch</artifactId>
+		    <version>2.4.1</version>
+		</dependency>
+		<dependency>
+		    <groupId>com.google.guava</groupId>
+		    <artifactId>guava</artifactId>
+		    <version>18.0</version>
+		</dependency>
+		<!-- activemq 
+		<dependency>
+			<groupId>org.apache.activemq</groupId>
+			<artifactId>activemq-all</artifactId>
+			<version>5.9.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.activemq</groupId>
+			<artifactId>activemq-pool</artifactId>
+			<version>5.9.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-jms</artifactId>
+			<version>4.1.7.RELEASE</version>
+		</dependency>-->
+		
+        <!-- JWT -->
+        <dependency>
+		    <groupId>com.auth0</groupId>
+		    <artifactId>java-jwt</artifactId>
+		    <version>2.2.1</version>
+		</dependency>
+	</dependencies>
+	<build>
+    <plugins>
+        <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <version>2.3.2</version>
+            <configuration>
+              <source>1.8</source>
+              <target>1.8</target>
+            </configuration>
+      </plugin>
+    </plugins>
+ </build>
+</project>

+ 42 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/APIStatus.java

@@ -0,0 +1,42 @@
+package com.iamberry.app.config;
+
+public enum APIStatus {
+	SUCCESS(1000, "success"),
+
+	FAILURE(2000, "failure"),
+	USER_NOT_EXIST(2001, "user not exist"),
+	ERROR_REGISTER(2010, "user already exist"),
+	INSERT_DUPLICATE(2011, "insert repeat"),
+	ERROR_CODE(2101,"verificationCode is wrong"),
+	CODE_TIMEOUT(2102,"verificationCode is overdue"),
+	AUTHENTICATION_ERROR(2012,"authentication_error"),
+	USER_FROZEN_ERROR(2013,"this account is frozen"),
+	INVALID_PARAMETER(2020,"invalid_parameter"),
+	INVALID_TOKEN(2100,"Invalid token"),
+	ERROR_OLDPASSWORD(2200,"old password is wrong"),
+	NOT_FOUND(4010,"not_found"),
+	
+	WARN_CART_FULL(4100,"cart was full"),
+	INTERNAL_SERVER_ERROR(3010,"internal_server_error"),
+	POINTS_NOT_AVALIABLE(5001,"points not avaliable"),
+	AMOUNT_NOT_AVALIABLE(5011,"amount not avaliable"),
+	BARCODE_NOT_FOUND(5020,"barcode not found"),
+	;
+	
+	private int status;
+	private String message;
+
+	private APIStatus(int status, String message) {
+		this.status = status;
+		this.message = message;
+	}
+
+	public int getStatus() {
+		return status;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+}

+ 27 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/Constants.java

@@ -0,0 +1,27 @@
+package com.iamberry.app.config;
+
+public interface Constants {
+	// 正则表达式:验证手机号
+	public static final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
+	// 正则表达式:验证邮箱
+	public static final String REGEX_EMAIL = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
+	// 正则表达式:验证身份证
+	public static final String REGEX_ID_CARD = "(^\\d{18}$)|(^\\d{15}$)";
+
+	public static final String USER_SESSION_KEY = "user-session-key";
+
+	public static final int DEFAULT_PAGE_SIZE = 10;
+
+	public static final String SMS_RETURNCODE = "code";
+
+	public static final int USER_STATUS_DEFAULT = 0;
+	public static final String USER_NOW_INIT = "NOW_INIT";
+	public static final String USER_SAVE_TEL = "SAVE_TEL";
+	public static final String USER_ACTIVE = "active";
+	public static final String USER_INACTIVE = "inactive";
+	public static final String TUYA_DEFAULT_PASS = "iamberry123";
+	
+	public static final String MILK_POWDER_APPROVED = "approved";
+	public static final String MILK_POWDER_NOT_APPROVED = "not_approved";
+	
+}

+ 48 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/ImberryConfig.java

@@ -0,0 +1,48 @@
+package com.iamberry.app.config;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+public class ImberryConfig {
+
+	public static String SMS_USERNAME = "";
+	public static String SMS_PASSWORD = "";
+	public static String SMS_TEXT = "";
+	public static String SMS_URL = "";
+	public static String SINA_IP_URL = "";
+	public static String MASTERSECRET="";
+	public static String APPKEY="";
+	public static String CDN_URL="";
+	public static String BASE_URL=""; //头像前缀
+	
+	public static String INTER_SMS_URL=""; //地址
+	public static String INTER_SMS_TEXT=""; //文字
+	public static String INTER_SMS_KEY=""; //云片key
+
+	static {
+		Properties pro = new Properties();
+		InputStream in = ImberryConfig.class.getClassLoader().getResourceAsStream("iamberry-app-service-config.properties");
+		try {
+			pro.load(in);
+			SMS_USERNAME = pro.getProperty("SMS_USERNAME");
+			SMS_PASSWORD = pro.getProperty("SMS_PASSWORD");
+			SMS_TEXT = pro.getProperty("SMS_TEXT");
+			SMS_URL = pro.getProperty("SMS_URL");
+			SINA_IP_URL = pro.getProperty("SINA_IP_URL");
+			MASTERSECRET=pro.getProperty("master_secret");
+			APPKEY=pro.getProperty("appkey");
+			CDN_URL=pro.getProperty("cdnUrl");
+			BASE_URL=pro.getProperty("base_url");
+			INTER_SMS_URL=pro.getProperty("INTER_SMS_URL");
+			INTER_SMS_TEXT=pro.getProperty("INTER_SMS_TEXT");
+			INTER_SMS_KEY=pro.getProperty("INTER_SMS_KEY");
+			
+			
+			
+			System.out.println("这里需要打印"+BASE_URL);
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+}

+ 95 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/Response.java

@@ -0,0 +1,95 @@
+package com.iamberry.app.config;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class Response implements Serializable {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -1497535410510537697L;
+
+	private static final ObjectMapper mapper = new ObjectMapper();
+	private ResponseHeader header;
+	private Object data;
+
+	public Response(ResponseHeader header) {
+		this(header, null);
+	}
+
+	public Response(ResponseHeader header, Object data) {
+		super();
+		this.header = header;
+		this.data = data;
+	}
+
+	public ResponseHeader getHeader() {
+		return header;
+	}
+
+	public Response setHeader(ResponseHeader header) {
+		this.header = header;
+		return this;
+	}
+
+	public Object getData() {
+		return data;
+	}
+
+	public Response setData(Object data) {
+		this.data = data;
+		return this;
+	}
+
+	public Response setData(Object data, int result_count) {
+		this.data = data;
+		this.header.setResult_count(result_count);
+		return this;
+	}
+
+	@Override
+	public String toString() {
+		try {
+			return mapper.writeValueAsString(this);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return "";
+		}
+	}
+
+	
+	/** 
+	* @Description: 将对象转为Map。注意方法名不能为getXxx,否则在将对象进行Json转换时,该get方法也会被默认调用。 
+	* @param @return  
+	* @return Map<String,Object>   
+	* @throws 
+	*/
+	public Map<String, Object> toMap() {
+		Map<String, Object> map = new HashMap<String, Object>();
+		map.put("header", header);
+		map.put("data", data);
+		return map;
+	}
+
+	public static final Response AUTHENTICATION_ERROR = new Response(new ResponseHeader(APIStatus.AUTHENTICATION_ERROR));
+	public static final Response SERVER_INTERNAL_ERROR = new Response(new ResponseHeader(APIStatus.INTERNAL_SERVER_ERROR));
+	public static final Response INVALID_PARMS = new Response(new ResponseHeader(APIStatus.INVALID_PARAMETER));
+	public static final Response ERROR_REGISTER = new Response(new ResponseHeader(APIStatus.ERROR_REGISTER));
+	public static final Response INSERT_DUPLICATE = new Response(new ResponseHeader(APIStatus.INSERT_DUPLICATE));
+	public static final Response SUCCESS = new Response(new ResponseHeader(APIStatus.SUCCESS));
+	public static final Response FAILURE = new Response(new ResponseHeader(APIStatus.FAILURE));
+	public static final Response ERROR_CODE = new Response(new ResponseHeader(APIStatus.ERROR_CODE));
+	public static final Response CODE_TIMEOUT = new Response(new ResponseHeader(APIStatus.CODE_TIMEOUT));
+	public static final Response NOT_FOUND = new Response(new ResponseHeader(APIStatus.NOT_FOUND));
+	public static final Response INVALID_TOKEN = new Response(new ResponseHeader(APIStatus.INVALID_TOKEN));
+	public static final Response ERROR_OLDPASSWORD = new Response(new ResponseHeader(APIStatus.ERROR_OLDPASSWORD));
+	public static final Response WARN_CART_FULL = new Response(new ResponseHeader(APIStatus.WARN_CART_FULL));
+	public static final Response USER_NOT_EXIST = new Response(new ResponseHeader(APIStatus.USER_NOT_EXIST));
+	public static final Response USER_FROZEN_ERROR = new Response(new ResponseHeader(APIStatus.USER_FROZEN_ERROR));
+	public static final Response POINTS_NOT_AVALIABLE = new Response(new ResponseHeader(APIStatus.POINTS_NOT_AVALIABLE));
+	public static final Response AMOUNT_NOT_AVALIABLE = new Response(new ResponseHeader(APIStatus.AMOUNT_NOT_AVALIABLE));
+	public static final Response BARCODE_NOT_FOUND = new Response(new ResponseHeader(APIStatus.BARCODE_NOT_FOUND));
+}

+ 59 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/config/ResponseHeader.java

@@ -0,0 +1,59 @@
+package com.iamberry.app.config;
+
+import java.io.Serializable;
+
+public class ResponseHeader implements Serializable {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -6484300066753075795L;
+	private int status;
+	private String message;
+	private int result_count;
+
+	public ResponseHeader() {
+
+	}
+
+	public ResponseHeader(APIStatus status) {
+		this(status.getStatus(), status.getMessage(), -1);
+	}
+
+	/**
+	 * Constructor
+	 * @param status
+	 * @param message
+	 * @param result_count
+	 */
+	public ResponseHeader(int status, String message, int result_count) {
+		super();
+		this.status = status;
+		this.message = message;
+		this.result_count = result_count;
+	}
+
+	public int getStatus() {
+		return status;
+	}
+
+	public void setStatus(int status) {
+		this.status = status;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public int getResult_count() {
+		return result_count;
+	}
+
+	public void setResult_count(int result_count) {
+		this.result_count = result_count;
+	}
+
+}

+ 174 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/des/MD5.java

@@ -0,0 +1,174 @@
+package com.iamberry.app.tool.des;
+
+import java.security.Key;
+import java.security.MessageDigest;
+import java.security.Security;
+
+import javax.crypto.Cipher;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.iamberry.app.tool.log.RatFWLogger;
+
+/**
+ * MD5处理类
+ * 注意:
+ * 	1、在加密是不许要创建对象,但是在解密时必须创建对象
+ * 	2、如果在加密时使用的秘钥和解密时使用的秘钥不符合,那么解析不正确,抛出异常:javax.crypto.BadPaddingException
+ * @author 何秀刚
+ */
+@Component
+public class MD5 {
+
+	@Autowired
+	private RatFWLogger ratFWLogger;
+	// md5字符数组
+	private char[] chars = { '0', '1', '2', '3', '4', '5', '6', '7',
+			'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+	/**
+	 * 将一个字符串转换为32位的字符串
+	 */
+	public String stringToMD5(String src) throws Exception {
+		StringBuffer md5Str = new StringBuffer();
+
+		byte[] bytes = src.getBytes();
+		MessageDigest digest = MessageDigest.getInstance("MD5");
+		byte[] newBytes = digest.digest(bytes);
+		for (byte b : newBytes) {
+			md5Str.append(chars[b >> 4 & 0x0F]);
+			md5Str.append(chars[b & 0x0F]);
+		}
+		return md5Str.toString();
+	}
+
+	/** 字符串默认键值 */
+	public static String strDefaultKey = "RATFWMD5";
+
+	/** 加密工具 */
+	public Cipher encryptCipher = null;
+
+	/** 解密工具 */
+	public Cipher decryptCipher = null;
+
+	/**
+	 * 将byte数组转换为表示16进制值的字符串, 如:byte[]{8,18}转换为:0813, 和public byte[]
+	 * hexStr2ByteArr(String strIn) 互为可逆的转换过程
+	 */
+	public String byteArr2HexStr(byte[] arrB) throws Exception {
+		int iLen = arrB.length;
+		// 每个byte用两个字符才能表示,所以字符串的长度是数组长度的两倍
+		StringBuffer sb = new StringBuffer(iLen * 2);
+		for (int i = 0; i < iLen; i++) {
+			int intTmp = arrB[i];
+			// 把负数转换为正数
+			while (intTmp < 0) {
+				intTmp = intTmp + 256;
+			}
+			// 小于0F的数需要在前面补0
+			if (intTmp < 16) {
+				sb.append("0");
+			}
+			sb.append(Integer.toString(intTmp, 16));
+		}
+		return sb.toString();
+	}
+
+	/**
+	 * 将表示16进制值的字符串转换为byte数组, 和public String byteArr2HexStr(byte[] arrB)
+	 * 互为可逆的转换过程
+	 */
+	public byte[] hexStr2ByteArr(String strIn) throws Exception {
+		byte[] arrB = strIn.getBytes();
+		int iLen = arrB.length;
+
+		// 两个字符表示一个字节,所以字节数组长度是字符串长度除以2
+		byte[] arrOut = new byte[iLen / 2];
+		for (int i = 0; i < iLen; i = i + 2) {
+			String strTmp = new String(arrB, i, 2);
+			arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16);
+		}
+		return arrOut;
+	}
+
+	/**
+	 * 默认构造方法,使用默认密钥
+	 * 
+	 * @throws Exception
+	 */
+	public MD5() {
+		this(strDefaultKey);
+	}
+
+	/**
+	 * 指定密钥构造方法
+	 * 
+	 * @param strKey
+	 *            指定的密钥
+	 * @throws Exception
+	 */
+	public MD5(String strKey) {
+		try {
+			Security.addProvider(new com.sun.crypto.provider.SunJCE());
+			Key key = getKey(strKey.getBytes());
+			encryptCipher = Cipher.getInstance("DES");
+			encryptCipher.init(Cipher.ENCRYPT_MODE, key);
+			decryptCipher = Cipher.getInstance("DES");
+			decryptCipher.init(Cipher.DECRYPT_MODE, key);
+		} catch (Exception e) {
+		}
+	}
+
+	/**
+	 * 加密字节数组
+	 */
+	public byte[] encrypt(byte[] arrB) throws Exception {
+		return encryptCipher.doFinal(arrB);
+	}
+
+	/**
+	 * 加密字符串
+	 */
+	public String encrypt(String strIn) throws Exception {
+		try {
+			return byteArr2HexStr(encrypt(strIn.getBytes())).toUpperCase();
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	/**
+	 * 解密字节数组
+	 */
+	public byte[] decrypt(byte[] arrB) throws Exception {
+		return decryptCipher.doFinal(arrB);
+	}
+
+	/**
+	 * 解密字符串
+	 */
+	public String decrypt(String strIn) throws Exception {
+		try {
+			return new String(decrypt(hexStr2ByteArr(strIn)));
+		} catch (Exception e) {
+			ratFWLogger.debug("加密和解密字符串不匹配:", e.getMessage());
+			return "INLONGADMD5";
+		}
+	}
+
+	/**
+	 * 从指定字符串生成密钥,密钥所需的字节数组长度为8位 不足8位时后面补0,超出8位只取前8位
+	 */
+	private Key getKey(byte[] arrBTmp) throws Exception {
+		// 创建一个空的8位字节数组(默认值为0)
+		byte[] arrB = new byte[8];
+		// 将原始字节数组转换为8位
+		for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) {
+			arrB[i] = arrBTmp[i];
+		}
+		// 生成密钥
+		Key key = new javax.crypto.spec.SecretKeySpec(arrB, "DES");
+		return key;
+	}
+}

+ 88 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/AddressDTO.java

@@ -0,0 +1,88 @@
+package com.iamberry.app.tool.dto;
+
+/** 
+ * @author North 
+ * @date 2016年3月1日 下午12:10:56 
+ * @version V1.0
+ */
+public class AddressDTO {
+	private String province;
+	private String city;
+	private String district;
+	private String address;
+	private String name;
+	private String phone;
+	private int defaultAddress;
+
+	public AddressDTO() {
+		super();
+	}
+
+	public AddressDTO(String province, String city, String district, String address, String name, String phone, int defaultAddress) {
+		super();
+		this.province = province;
+		this.city = city;
+		this.district = district;
+		this.address = address;
+		this.name = name;
+		this.phone = phone;
+		this.defaultAddress = defaultAddress;
+	}
+
+	public String getProvince() {
+		return province;
+	}
+
+	public void setProvince(String province) {
+		this.province = province;
+	}
+
+	public String getCity() {
+		return city;
+	}
+
+	public void setCity(String city) {
+		this.city = city;
+	}
+
+	public String getDistrict() {
+		return district;
+	}
+
+	public void setDistrict(String district) {
+		this.district = district;
+	}
+
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getPhone() {
+		return phone;
+	}
+
+	public void setPhone(String phone) {
+		this.phone = phone;
+	}
+
+	public int getDefaultAddress() {
+		return defaultAddress;
+	}
+
+	public void setDefaultAddress(int defaultAddress) {
+		this.defaultAddress = defaultAddress;
+	}
+
+}

+ 132 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/TuyaDTO.java

@@ -0,0 +1,132 @@
+package com.iamberry.app.tool.dto;
+
+public class TuyaDTO {
+	private String ApiVersion;
+	private String Lang = "zh-Hans";
+	private String Deviceid;
+	private String AppVersion;
+	private String Ttid;
+	private String Os;
+	private String ClientId;
+	private String Api;
+	private String T;
+	private String Session;
+	private String Data;
+
+	private String HashKey;
+	private Boolean OpenSign = true;
+	private String Sign;
+
+	public String getApiVersion() {
+		return ApiVersion;
+	}
+
+	public void setApiVersion(String apiVersion) {
+		ApiVersion = apiVersion;
+	}
+
+	public String getLang() {
+		return Lang;
+	}
+
+	public void setLang(String lang) {
+		Lang = lang;
+	}
+
+	public String getDeviceid() {
+		return Deviceid;
+	}
+
+	public void setDeviceid(String deviceid) {
+		Deviceid = deviceid;
+	}
+
+	public String getAppVersion() {
+		return AppVersion;
+	}
+
+	public void setAppVersion(String appVersion) {
+		AppVersion = appVersion;
+	}
+
+	public String getTtid() {
+		return Ttid;
+	}
+
+	public void setTtid(String ttid) {
+		Ttid = ttid;
+	}
+
+	public String getOs() {
+		return Os;
+	}
+
+	public void setOs(String os) {
+		Os = os;
+	}
+
+	public String getClientId() {
+		return ClientId;
+	}
+
+	public void setClientId(String clientId) {
+		ClientId = clientId;
+	}
+
+	public String getApi() {
+		return Api;
+	}
+
+	public void setApi(String api) {
+		Api = api;
+	}
+
+	public String getT() {
+		return T;
+	}
+
+	public void setT(String t) {
+		T = t;
+	}
+
+	public String getSession() {
+		return Session;
+	}
+
+	public void setSession(String session) {
+		Session = session;
+	}
+
+	public String getData() {
+		return Data;
+	}
+
+	public void setData(String data) {
+		Data = data;
+	}
+
+	public String getHashKey() {
+		return HashKey;
+	}
+
+	public void setHashKey(String hashKey) {
+		HashKey = hashKey;
+	}
+
+	public Boolean getOpenSign() {
+		return OpenSign;
+	}
+
+	public void setOpenSign(Boolean openSign) {
+		OpenSign = openSign;
+	}
+
+	public String getSign() {
+		return Sign;
+	}
+
+	public void setSign(String sign) {
+		Sign = sign;
+	}
+
+}

+ 79 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/TuyaHistoryListDTO.java

@@ -0,0 +1,79 @@
+package com.iamberry.app.tool.dto;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({ "time", "dpId", "value", "devId" })
+public class TuyaHistoryListDTO {
+
+	@JsonProperty("time")
+	private Long time;
+	@JsonProperty("dpId")
+	private Integer dpId;
+	@JsonProperty("value")
+	private String value;
+	@JsonProperty("devId")
+	private String devId;
+	@JsonIgnore
+	private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+	@JsonProperty("time")
+	public Long getTime() {
+		return time;
+	}
+
+	@JsonProperty("time")
+	public void setTime(Long time) {
+		this.time = time;
+	}
+
+	@JsonProperty("dpId")
+	public Integer getDpId() {
+		return dpId;
+	}
+
+	@JsonProperty("dpId")
+	public void setDpId(Integer dpId) {
+		this.dpId = dpId;
+	}
+
+	@JsonProperty("value")
+	public String getValue() {
+		return value;
+	}
+
+	@JsonProperty("value")
+	public void setValue(String value) {
+		this.value = value;
+	}
+
+	@JsonProperty("devId")
+	public String getDevId() {
+		return devId;
+	}
+
+	@JsonProperty("devId")
+	public void setDevId(String devId) {
+		this.devId = devId;
+	}
+
+	@JsonAnyGetter
+	public Map<String, Object> getAdditionalProperties() {
+		return this.additionalProperties;
+	}
+
+	@JsonAnySetter
+	public void setAdditionalProperty(String name, Object value) {
+		this.additionalProperties.put(name, value);
+	}
+
+}

+ 94 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/TuyaHistoryRawDTO.java

@@ -0,0 +1,94 @@
+package com.iamberry.app.tool.dto;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({ "result", "status", "success" })
+public class TuyaHistoryRawDTO {
+
+	@JsonProperty("result")
+	private TuyaHistoryResultDTO result;
+	@JsonProperty("status")
+	private String status;
+	@JsonProperty("success")
+	private Boolean success;
+	@JsonIgnore
+	private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+	/**
+	 *
+	 * @return The result
+	 */
+	@JsonProperty("result")
+	public TuyaHistoryResultDTO getResult() {
+		return result;
+	}
+
+	/**
+	 *
+	 * @param result
+	 *            The result
+	 */
+	@JsonProperty("result")
+	public void setResult(TuyaHistoryResultDTO result) {
+		this.result = result;
+	}
+
+	/**
+	 *
+	 * @return The status
+	 */
+	@JsonProperty("status")
+	public String getStatus() {
+		return status;
+	}
+
+	/**
+	 *
+	 * @param status
+	 *            The status
+	 */
+	@JsonProperty("status")
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	/**
+	 *
+	 * @return The success
+	 */
+	@JsonProperty("success")
+	public Boolean getSuccess() {
+		return success;
+	}
+
+	/**
+	 *
+	 * @param success
+	 *            The success
+	 */
+	@JsonProperty("success")
+	public void setSuccess(Boolean success) {
+		this.success = success;
+	}
+
+	@JsonAnyGetter
+	public Map<String, Object> getAdditionalProperties() {
+		return this.additionalProperties;
+	}
+
+	@JsonAnySetter
+	public void setAdditionalProperty(String name, Object value) {
+		this.additionalProperties.put(name, value);
+	}
+
+}

+ 74 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/dto/TuyaHistoryResultDTO.java

@@ -0,0 +1,74 @@
+package com.iamberry.app.tool.dto;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({ "nextOffset", "list" })
+public class TuyaHistoryResultDTO {
+
+	@JsonProperty("nextOffset")
+	private String nextOffset;
+	@JsonProperty("list")
+	private java.util.List<TuyaHistoryListDTO> list = new ArrayList<TuyaHistoryListDTO>();
+	@JsonIgnore
+	private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+	/**
+	 *
+	 * @return The nextOffset
+	 */
+	@JsonProperty("nextOffset")
+	public String getNextOffset() {
+		return nextOffset;
+	}
+
+	/**
+	 *
+	 * @param nextOffset
+	 *            The nextOffset
+	 */
+	@JsonProperty("nextOffset")
+	public void setNextOffset(String nextOffset) {
+		this.nextOffset = nextOffset;
+	}
+
+	/**
+	 *
+	 * @return The list
+	 */
+	@JsonProperty("list")
+	public java.util.List<TuyaHistoryListDTO> getList() {
+		return list;
+	}
+
+	/**
+	 *
+	 * @param list
+	 *            The list
+	 */
+	@JsonProperty("list")
+	public void setList(java.util.List<TuyaHistoryListDTO> list) {
+		this.list = list;
+	}
+
+	@JsonAnyGetter
+	public Map<String, Object> getAdditionalProperties() {
+		return this.additionalProperties;
+	}
+
+	@JsonAnySetter
+	public void setAdditionalProperty(String name, Object value) {
+		this.additionalProperties.put(name, value);
+	}
+
+}

+ 66 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/log/RatFWLogger.java

@@ -0,0 +1,66 @@
+package com.iamberry.app.tool.log;
+
+import org.apache.log4j.Logger;
+
+/**
+ * desc:平台日志
+ */
+public class RatFWLogger {	
+	
+	private static String delimiter = " >> ";
+	
+	private Logger logger = null;
+	
+	private String appId;
+
+	public RatFWLogger() {
+		System.out.println("Ok");
+	}
+	
+	public RatFWLogger(String appId) {
+		this.appId = appId;
+		logger = Logger.getLogger(appId);
+	}
+	
+	/** 通过Spring IoC注入 
+	 * @param 应用系统ID
+	 **/
+	public void setAppId(String appId) {
+		this.appId = appId;
+		logger = Logger.getLogger(appId);		
+	}	
+	
+	public void info(String msg) {
+		info(null, msg);
+	}
+	
+	public void info(Object sender, String msg) {
+		if(logger.isInfoEnabled())
+			logger.info(buildMessage(sender,msg));
+	}
+	
+	public void debug(Object sender, String msg) {
+		if(logger.isDebugEnabled())
+			logger.debug(buildMessage(sender, msg));
+	}
+	
+	public void warn(Object sender, String msg) {
+		logger.warn(buildMessage(sender, msg));
+	}
+	
+	public void error(Object sender, String msg)
+	{	
+		logger.error(buildMessage(sender, msg));
+	}
+	
+	private String buildMessage(Object sender, String message) {
+		StringBuffer msg = new StringBuffer();
+		if(sender == null)
+			msg.append(appId);			
+		else
+			msg.append(sender.getClass().getName());		 
+		msg.append(delimiter).append(message);
+		return msg.toString();
+	}	
+	
+}

+ 242 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/AES.java

@@ -0,0 +1,242 @@
+package com.iamberry.app.tool.util;
+
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.apache.commons.codec.binary.Base64;
+
+public class AES {
+
+	private static final String key = "7dm9b2n79dzugnzu";
+	private static final String initVector = "jp5xi3ycqtzbqldv";
+
+	public static String encrypt(String value) {
+		try {
+			// 使用CBC模式,需要一个向量iv,可增加加密算法的强度 
+			IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+			
+			// 采用AES加密算法加密后的密钥
+			SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
+
+			// "算法/模式/补码方式"0102030405060708
+			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
+			
+			//使用加密模式初始化 密钥
+			cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
+
+			byte[] encrypted = cipher.doFinal(value.getBytes());
+
+			// 此处使用BASE64做转码功能,同时能起到2次加密的作用。
+			return Base64.encodeBase64String(encrypted);
+		} catch (Exception ex) {
+			ex.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 使用CBC加密密匙,生成AES加密
+	 * @param value
+	 * @param key
+	 * @return
+	 * @author 献
+	 * @Time   2016年12月5日
+	 */
+	public static String encryptCBC(String value, String key, String initVector) {
+		try {
+			// 使用CBC模式,需要一个向量iv,可增加加密算法的强度 
+			IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+			
+			// 采用AES加密算法加密后的密钥
+			SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
+
+			// "算法/模式/补码方式"0102030405060708
+			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
+			
+			//使用加密模式初始化 密钥
+			cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
+
+			byte[] encrypted = cipher.doFinal(value.getBytes());
+
+			// 此处使用BASE64做转码功能,同时能起到2次加密的作用。
+			return Base64.encodeBase64String(encrypted);
+		} catch (Exception ex) {
+			ex.printStackTrace();
+		}
+		return null;
+	}
+	
+	/**
+	 * 解密
+	 * @param encrypted
+	 * @param key
+	 * @return
+	 * @author 献
+	 * @Time   2016年12月5日
+	 */
+	public static String decryptCBC(String encrypted, String key, String initVector) {
+		try {
+			IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+			SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
+
+			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
+			cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
+
+			byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
+
+			return new String(original);
+		} catch (Exception ex) {
+			ex.printStackTrace();
+		}
+		return null;
+	}
+	
+	/**
+	 * 更加指定的内容密匙加密
+	 * @param content
+	 * @param password
+	 * @return
+	 * @author 献
+	 * @Time   2016年12月5日
+	 */
+	public static String encrypt(String content, String password) {
+		try {
+			// 采用AES加密算法加密后的密钥
+			KeyGenerator kgen = KeyGenerator.getInstance("AES");
+			kgen.init(128, new SecureRandom(password.getBytes()));
+			SecretKeySpec key = new SecretKeySpec(kgen.generateKey().getEncoded(), "AES");
+			
+			// 创建密码器,用于加密解密,默认ECB mode
+			Cipher cipher = Cipher.getInstance("AES");
+			
+			// 初始化密码器
+			cipher.init(Cipher.ENCRYPT_MODE, key);
+			
+			// 加密
+			byte[] result = cipher.doFinal(content.getBytes("UTF-8"));
+			
+			// 将byte数组转换16进制
+			return byte2hex(result);
+		} catch (NoSuchAlgorithmException e) {
+			e.printStackTrace();
+		} catch (NoSuchPaddingException e) {
+			e.printStackTrace();
+		} catch (InvalidKeyException e) {
+			e.printStackTrace();
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		} catch (IllegalBlockSizeException e) {
+			e.printStackTrace();
+		} catch (BadPaddingException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public static String decrypt(String encrypted) {
+		try {
+			IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+			SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
+
+			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
+			cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
+
+			byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
+
+			return new String(original);
+		} catch (Exception ex) {
+			ex.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * byte[] 转 字符串
+	 * 
+	 * @param b
+	 * @return
+	 */
+	public static String byte2hex(byte[] b) {
+		String hs = "";
+		String stmp = "";
+		for (int n = 0; n < b.length; n++) {
+			stmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
+			if (stmp.length() == 1)
+				hs = hs + "0" + stmp;
+			else
+				hs = hs + stmp;
+		}
+		return hs.toUpperCase();
+	}
+
+	/**
+	 * 解密
+	 * 
+	 * @param content
+	 *            待解密内容
+	 * @param password
+	 *            解密密钥
+	 * @return
+	 */
+	public static String decrypt(String content, String password) {
+		try {
+			KeyGenerator kgen = KeyGenerator.getInstance("AES");
+			kgen.init(128, new SecureRandom(password.getBytes()));
+			SecretKey secretKey = kgen.generateKey();
+			byte[] enCodeFormat = secretKey.getEncoded();
+			SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");
+			Cipher cipher = Cipher.getInstance("AES");// 创建密码器
+			cipher.init(Cipher.DECRYPT_MODE, key);// 初始化
+			byte[] result = cipher.doFinal(parseHexStr2Byte(content));
+			return new String(result, "UTF-8"); // 加密
+		} catch (NoSuchAlgorithmException e) {
+			e.printStackTrace();
+		} catch (NoSuchPaddingException e) {
+			e.printStackTrace();
+		} catch (InvalidKeyException e) {
+			e.printStackTrace();
+		} catch (IllegalBlockSizeException e) {
+			e.printStackTrace();
+		} catch (BadPaddingException e) {
+			e.printStackTrace();
+		} catch (UnsupportedEncodingException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 将16进制转换为二进制
+	 * 
+	 * @param hexStr
+	 * @return
+	 */
+	public static byte[] parseHexStr2Byte(String hexStr) {
+		if (hexStr.length() < 1)
+			return null;
+		byte[] result = new byte[hexStr.length() / 2];
+		for (int i = 0; i < hexStr.length() / 2; i++) {
+			int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
+			int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
+			result[i] = (byte) (high * 16 + low);
+		}
+		return result;
+	}
+
+	public static void main(String[] args) throws UnsupportedEncodingException {
+		System.out.println(AES.decrypt("MzQ4OXw5OWE0c3k3djc4fDE0ODExNjM0OTk0NDU="));
+	}
+}

+ 106 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/Des.java

@@ -0,0 +1,106 @@
+package com.iamberry.app.tool.util;
+
+import java.security.SecureRandom;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DESKeySpec;
+
+public class Des {
+
+	private static final String defaultKey = "oxbix123";
+
+	public static void main(String[] args) throws Exception {
+
+		// 待加密内容
+		String str = "测试内容";
+		// 密码,长度要是8的倍数
+		String key = "aaaabaaa";
+		byte[] result = Des.desCrypto(str.getBytes(), key);
+		System.out.println("加密后内容为:" + result);
+		// 直接将如上内容解密
+		try {
+			byte[] decryResult = Des.decrypt(result, key);
+			System.out.println("加密后内容为:" + new String(decryResult));
+		} catch (Exception e1) {
+			e1.printStackTrace();
+		}
+
+	}
+
+	public static byte[] desCrypto(byte[] datasource) {
+		try {
+			SecureRandom random = new SecureRandom();
+			DESKeySpec desKey = new DESKeySpec(defaultKey.getBytes());
+			// 创建一个密匙工厂,然后用它把DESKeySpec转换成
+			SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
+			SecretKey securekey = keyFactory.generateSecret(desKey);
+			// Cipher对象实际完成加密操作
+			Cipher cipher = Cipher.getInstance("DES");
+			// 用密匙初始化Cipher对象
+			cipher.init(Cipher.ENCRYPT_MODE, securekey, random);
+			// 现在,获取数据并加密
+			// 正式执行加密操作
+			return cipher.doFinal(datasource);
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public static byte[] desCrypto(byte[] datasource, String key) {
+		try {
+			SecureRandom random = new SecureRandom();
+			DESKeySpec desKey = new DESKeySpec(key.getBytes());
+			// 创建一个密匙工厂,然后用它把DESKeySpec转换成
+			SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
+			SecretKey securekey = keyFactory.generateSecret(desKey);
+			// Cipher对象实际完成加密操作
+			Cipher cipher = Cipher.getInstance("DES");
+			// 用密匙初始化Cipher对象
+			cipher.init(Cipher.ENCRYPT_MODE, securekey, random);
+			// 现在,获取数据并加密
+			// 正式执行加密操作
+			return cipher.doFinal(datasource);
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public static byte[] decrypt(byte[] src) throws Exception {
+		// DES算法要求有一个可信任的随机数源
+		SecureRandom random = new SecureRandom();
+		// 创建一个DESKeySpec对象
+		DESKeySpec desKey = new DESKeySpec(defaultKey.getBytes());
+		// 创建一个密匙工厂
+		SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
+		// 将DESKeySpec对象转换成SecretKey对象
+		SecretKey securekey = keyFactory.generateSecret(desKey);
+		// Cipher对象实际完成解密操作
+		Cipher cipher = Cipher.getInstance("DES");
+		// 用密匙初始化Cipher对象
+		cipher.init(Cipher.DECRYPT_MODE, securekey, random);
+		// 真正开始解密操作
+		return cipher.doFinal(src);
+	}
+
+	public static byte[] decrypt(byte[] src, String key) throws Exception {
+		// DES算法要求有一个可信任的随机数源
+		SecureRandom random = new SecureRandom();
+		// 创建一个DESKeySpec对象
+		DESKeySpec desKey = new DESKeySpec(key.getBytes());
+		// 创建一个密匙工厂
+		SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
+		// 将DESKeySpec对象转换成SecretKey对象
+		SecretKey securekey = keyFactory.generateSecret(desKey);
+		// Cipher对象实际完成解密操作
+		Cipher cipher = Cipher.getInstance("DES");
+		// 用密匙初始化Cipher对象
+		cipher.init(Cipher.DECRYPT_MODE, securekey, random);
+		// 真正开始解密操作
+		return cipher.doFinal(src);
+	}
+
+}

+ 65 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/HttpUtility.java

@@ -0,0 +1,65 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.iamberry.app.tool.util;
+
+import java.io.IOException;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.ParseException;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+/**
+ * 
+ * @author Sikandar A.A
+ */
+public class HttpUtility {
+
+	public static String httpsPost(String url, HttpEntity data) throws ParseException, IOException {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpPost httpost = new HttpPost(url);
+		// 设置请求和传输超时时间
+		RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build();
+		httpost.setConfig(requestConfig);
+		httpost.setEntity(data);
+		try {
+			CloseableHttpResponse response = httpClient.execute(httpost);
+			httpost.reset();
+			HttpEntity entity = response.getEntity();
+			if (entity != null) {
+				String result = EntityUtils.toString(entity);
+				response.close();
+				return result;
+			}
+			return null;
+		} finally {
+			httpClient.close();
+		}
+	}
+
+	public static String httpsGet(String url) throws ParseException, IOException {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpGet httpget = new HttpGet(url);
+		try {
+			CloseableHttpResponse response = httpClient.execute(httpget);
+			HttpEntity entity = response.getEntity();
+			if (entity != null) {
+				String result = EntityUtils.toString(entity,"utf-8");
+				response.close();
+				return result;
+			}
+			return null;
+		} finally {
+			httpClient.close();
+		}
+	}
+
+}

+ 57 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/JsonParseUtil.java

@@ -0,0 +1,57 @@
+package com.iamberry.app.tool.util;
+
+import java.util.Collection;
+import java.util.List;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.iamberry.app.tool.dto.AddressDTO;
+
+/** 
+ * @author North 
+ * @date 2016年3月1日 上午11:32:06 
+ * @version V1.0
+ */
+public class JsonParseUtil {
+
+	static ObjectMapper om = new ObjectMapper();
+
+	public static Object parseObject(String json, Class<?> clz) {
+		try {
+			return om.readValue(json, clz);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public static Collection<?> parseList(String json, TypeReference<?> reference) {
+		try {
+			return om.readValue(json, reference);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+	
+	public static Object parseAddress(String json) {
+		try {
+			return om.readValue(json, AddressDTO.class);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	
+
+	public static List<AddressDTO> parseAddressList(String json) {
+		try {
+			return om.readValue(json, new TypeReference<List<AddressDTO>>() {
+			});
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+}

+ 62 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/MD5.java

@@ -0,0 +1,62 @@
+package com.iamberry.app.tool.util;
+
+import java.security.MessageDigest;
+
+public class MD5 {
+	private final static String[] hexDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
+
+	/**
+	 * 转换字节数组为16进制字串
+	 * 
+	 * @param b
+	 *            字节数组
+	 * @return 16进制字串
+	 */
+	public static String byteArrayToHexString(byte[] b) {
+		StringBuilder resultSb = new StringBuilder();
+		for (byte aB : b) {
+			resultSb.append(byteToHexString(aB));
+		}
+		return resultSb.toString();
+	}
+
+	/**
+	 * 转换byte到16进制
+	 * 
+	 * @param b
+	 *            要转换的byte
+	 * @return 16进制格式
+	 */
+	private static String byteToHexString(byte b) {
+		int n = b;
+		if (n < 0) {
+			n = 256 + n;
+		}
+		int d1 = n / 16;
+		int d2 = n % 16;
+		return hexDigits[d1] + hexDigits[d2];
+	}
+
+	/**
+	 * MD5编码
+	 * 
+	 * @param origin
+	 *            原始字符串
+	 * @return 经过MD5加密之后的结果
+	 */
+	public static String md5(String origin) {
+		String resultString = null;
+		try {
+			resultString = origin;
+			MessageDigest md = MessageDigest.getInstance("MD5");
+			resultString = byteArrayToHexString(md.digest(resultString.getBytes("utf-8")));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return resultString;
+	}
+	
+	public static void main(String[] args) {
+		System.out.println(md5("pv1700"));
+	}
+}

+ 60 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/Paginator.java

@@ -0,0 +1,60 @@
+package com.iamberry.app.tool.util;
+
+/** 
+ * @author North 
+ * @date 2016年2月26日 下午5:24:07 
+ * @version V1.0
+ */
+public class Paginator {
+
+	private int pageSize;
+	private int rowCounts;
+	private int offset;
+	private int rows;
+
+	public Paginator(int pageSize, int rowCounts) {
+		super();
+		this.pageSize = pageSize;
+		this.rowCounts = rowCounts;
+
+		if (this.rowCounts >= this.pageSize) {
+			this.offset = this.rowCounts - this.pageSize;
+			this.rows = this.pageSize;
+		} else {
+			this.offset = 0;
+			this.rows = this.rowCounts;
+		}
+	}
+
+	public static Builder newBuilder() {
+		return new Builder();
+	}
+
+	public int getOffset() {
+		return offset;
+	}
+
+	public int getRows() {
+		return rows;
+	}
+
+	public static class Builder {
+		private int pageSize;
+		private int rowCounts;
+
+		public Builder setPageSize(int pageSize) {
+			this.pageSize = pageSize;
+			return this;
+		}
+
+		public Builder setRowCounts(int rowCounts) {
+			this.rowCounts = rowCounts;
+			return this;
+		}
+
+		public Paginator build() {
+			return new Paginator(pageSize, rowCounts);
+		}
+
+	}
+}

+ 37 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/Result.java

@@ -0,0 +1,37 @@
+package com.iamberry.app.tool.util;
+
+public class Result {
+
+	private Integer resultcode;
+	private String taskcode;
+	private String errordescription;
+
+	public Result() {
+		super();
+	}
+
+	public Integer getResultcode() {
+		return resultcode;
+	}
+
+	public void setResultcode(Integer resultcode) {
+		this.resultcode = resultcode;
+	}
+
+	public String getTaskcode() {
+		return taskcode;
+	}
+
+	public void setTaskcode(String taskcode) {
+		this.taskcode = taskcode;
+	}
+
+	public String getErrordescription() {
+		return errordescription;
+	}
+
+	public void setErrordescription(String errordescription) {
+		this.errordescription = errordescription;
+	}
+
+}

+ 246 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/TuyaConnector.java

@@ -0,0 +1,246 @@
+package com.iamberry.app.tool.util;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeMap;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.iamberry.app.tool.dto.TuyaDTO;
+import com.iamberry.app.tool.dto.TuyaHistoryRawDTO;
+import com.iamberry.app.tool.dto.TuyaHistoryResultDTO;
+
+public class TuyaConnector {
+
+	private final static String CLIENT_ID = "5kkyurvvtt58bbuxueee";
+	private final static String SECRET_KEY = "rhj6na6u3y6uhy6qrbb3944mg5uqqpbb";
+	//调试环境
+	// private final static String DOMAIN_NAME = "https://a1.mb.cn.wgine.com/api.json";
+
+	// 生产环境
+	private final static String DOMAIN_NAME = "https://a1.mb.airtakeapp.com/api.json";
+
+	// 国外环境
+//	 private final static String DOMAIN_NAME = "https://a1.tuyaus.com/api.json";
+	
+	// 国外环境
+//	private final static String DOMAIN_NAME = "https://a1.tuyaus.com/api.json";
+
+	public static void TuyaSyncConnect(String encryptUsername, String userCode) {
+		String areacode = "86";
+		
+		if(encryptUsername.indexOf(",") != -1){
+			areacode = StringUtils.substringBefore(encryptUsername, ",");
+			encryptUsername = StringUtils.substringAfter(encryptUsername, ",");
+		}
+		
+		userCode = TuyaMD5Util.getMD5(userCode);
+		TuyaDTO tuyaDTO = setTuyaDTO();
+
+		tuyaDTO.setApi("tuya.cloud.user.uid.sync");
+		tuyaDTO.setData("{\"countryCode\":\""+areacode+"\",\"uid\":\"" + encryptUsername + "\",\"passwd\":\"" + userCode + "\"}");
+
+		String s = getSign(tuyaDTO, SECRET_KEY);
+		String sign = TuyaMD5Util.getMD5(s.getBytes());
+
+		String url = DOMAIN_NAME + "?a=" + tuyaDTO.getApi() + "&appVersion=" + tuyaDTO.getAppVersion() + "&clientId="
+				+ CLIENT_ID + "&deviceId=" + tuyaDTO.getDeviceid() + "&lang=" + tuyaDTO.getLang() + "&os="
+				+ tuyaDTO.getOs() + "&postData=" + tuyaDTO.getData() + "&sid=" + tuyaDTO.getSession() + "&time="
+				+ tuyaDTO.getT() + "&ttid=" + tuyaDTO.getTtid() + "&v=" + tuyaDTO.getApiVersion() + "&sign=" + sign;	
+		System.out.println("涂鸦请求数据:" + url);
+		try {
+			trustAllHttpsCertificates();
+			HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+				public boolean verify(String hostname, SSLSession session) {
+					// System.out.println("Warning: URL Host: " + hostname + "
+					// vs. " + session.getPeerHost());
+					return true;
+				}
+			});
+			System.out.println("涂鸦返回数据:" + sendPost(url));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+	}
+
+	public static TuyaHistoryResultDTO TuyaHistoryConnect(long startTime, long endTime, String offset, int limit) {
+		ObjectMapper mapper = new ObjectMapper();
+		TuyaHistoryRawDTO tuyaData = null;
+		TuyaDTO tuyaDTO = setTuyaDTO();
+
+		tuyaDTO.setApi("tuya.cloud.dp.history.get");
+		tuyaDTO.setData("{\"productId\":\"" + "4Ic6GgKI0vUG65Jd" + "\",\"dpId\":\"" + 12 + "\",\"startTime\":"
+				+ startTime + ",\"endTime\":" + endTime + ",\"offset\":\"" + offset + "\",\"limit\":" + limit + "}");
+
+		String s = getSign(tuyaDTO, SECRET_KEY);
+		String sign = TuyaMD5Util.getMD5(s.getBytes());
+
+		String url = DOMAIN_NAME + "?a=" + tuyaDTO.getApi() + "&appVersion=" + tuyaDTO.getAppVersion() + "&clientId="
+				+ CLIENT_ID + "&deviceId=" + tuyaDTO.getDeviceid() + "&lang=" + tuyaDTO.getLang() + "&os="
+				+ tuyaDTO.getOs() + "&postData=" + tuyaDTO.getData() + "&sid=" + tuyaDTO.getSession() + "&time="
+				+ tuyaDTO.getT() + "&ttid=" + tuyaDTO.getTtid() + "&v=" + tuyaDTO.getApiVersion() + "&sign=" + sign;
+
+		try {
+			trustAllHttpsCertificates();
+			HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+				public boolean verify(String hostname, SSLSession session) {
+					// System.out.println("Warning: URL Host: " + hostname + "
+					// vs. " + session.getPeerHost());
+					return true;
+				}
+			});
+
+			tuyaData = mapper.readValue(sendPost(url), TuyaHistoryRawDTO.class);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return tuyaData != null ? tuyaData.getResult() : null;
+	}
+
+	private static TuyaDTO setTuyaDTO() {
+		TuyaDTO tuyaDTO = new TuyaDTO();
+		tuyaDTO.setApiVersion("1.0");
+		tuyaDTO.setLang("cn");
+		tuyaDTO.setDeviceid("cloud");
+		tuyaDTO.setAppVersion("1.0");
+		tuyaDTO.setTtid("ios");
+		tuyaDTO.setOs("ios");
+		tuyaDTO.setClientId(CLIENT_ID);
+
+		tuyaDTO.setT(String.valueOf(System.currentTimeMillis() / 1000));
+		tuyaDTO.setSession("abcededdddd");
+		return tuyaDTO;
+	}
+
+	private static TreeMap<String, String> paramsBuild(TuyaDTO tuyaDTO) {
+		TreeMap<String, String> params = new TreeMap<String, String>();
+		params.put("a", tuyaDTO.getApi());
+		params.put("v", tuyaDTO.getApiVersion());
+		params.put("lang", tuyaDTO.getLang());
+		params.put("deviceId", tuyaDTO.getDeviceid());
+		params.put("appVersion", tuyaDTO.getAppVersion());
+		params.put("ttid", tuyaDTO.getTtid());
+		params.put("os", tuyaDTO.getOs());
+		params.put("clientId", tuyaDTO.getClientId());
+		params.put("time", tuyaDTO.getT());
+		if (StringUtils.isNotBlank(tuyaDTO.getSession())) {
+			params.put("sid", tuyaDTO.getSession());
+		}
+		if (StringUtils.isNotBlank(tuyaDTO.getData())) {
+			params.put("postData", tuyaDTO.getData());
+		}
+		return params;
+	}
+
+	private static String signAssembly(TreeMap<String, String> params, String secretKey) {
+		StringBuilder str = new StringBuilder();
+		str.append(secretKey);
+		Set<String> keySet = params.keySet();
+		Iterator<String> iter = keySet.iterator();
+		while (iter.hasNext()) {
+			String key = iter.next();
+			if (StringUtils.isBlank(params.get(key))) {
+				continue;
+			}
+			str.append(key);
+			str.append("=");
+			str.append(params.get(key));
+			str.append("|");
+		}
+		String strValue = str.toString();
+		strValue = strValue.substring(0, (strValue.length() - 1));
+		// System.out.println(strValue);
+		return strValue;
+	}
+
+	private static String getSign(TuyaDTO tuyaDTO, String secretKey) {
+		TreeMap<String, String> params = paramsBuild(tuyaDTO);
+		String signString = signAssembly(params, secretKey);
+		return signString;
+	}
+
+	public static boolean signValidate(TuyaDTO tuyaDTO) {
+		String secretKey = tuyaDTO.getHashKey();
+		String signString = getSign(tuyaDTO, secretKey);
+		String sign = TuyaMD5Util.getMD5(signString.getBytes());
+		if (tuyaDTO.getOpenSign() && !sign.equals(tuyaDTO.getSign().trim())) {
+			return false;
+		}
+		return true;
+	}
+
+	private static String sendPost(String url) throws Exception {
+		// 处理+号
+		URL obj = new URL(url.replace("+", "%2B"));
+
+		HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
+
+		con.setRequestMethod("POST");
+		con.setRequestProperty("Content-Type", "application/json");
+		con.setRequestProperty("accept", "*/*");
+		con.setRequestProperty("connection", "Keep-Alive");
+
+		con.setDoOutput(true);
+		con.setDoInput(true);
+
+		int responseCode = con.getResponseCode();
+
+		BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
+		String inputLine;
+		StringBuffer response = new StringBuffer();
+
+		while ((inputLine = in.readLine()) != null) {
+			response.append(inputLine);
+		}
+		in.close();
+
+		// System.out.println("\nSending 'POST' request to URL : " + url);
+		// System.out.println("Response Code : " + responseCode);
+		// System.out.println("response: " + response.toString());
+
+		return response.toString();
+	}
+
+	private static void trustAllHttpsCertificates() throws Exception {
+		javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
+		javax.net.ssl.TrustManager tm = new miTM();
+		trustAllCerts[0] = tm;
+		javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
+		sc.init(null, trustAllCerts, null);
+		javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+	}
+
+	static class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
+		public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+			return null;
+		}
+
+		public boolean isServerTrusted(java.security.cert.X509Certificate[] certs) {
+			return true;
+		}
+
+		public boolean isClientTrusted(java.security.cert.X509Certificate[] certs) {
+			return true;
+		}
+
+		public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
+				throws java.security.cert.CertificateException {
+			return;
+		}
+
+		public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
+				throws java.security.cert.CertificateException {
+			return;
+		}
+	}
+
+}

+ 51 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/TuyaMD5Util.java

@@ -0,0 +1,51 @@
+package com.iamberry.app.tool.util;
+import java.security.MessageDigest;
+
+public class TuyaMD5Util {
+
+	public static String getMD5(byte[] source) {
+		String s = null;
+		char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+		try {
+			MessageDigest md = MessageDigest.getInstance("MD5");
+			md.update(source);
+			byte tmp[] = md.digest(); // MD5 的计算结果是一个 128 位的长整数,
+			// 用字节表示就是 16 个字节
+			char str[] = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符,
+			// 所以表示成 16 进制需要 32 个字符
+			int k = 0; // 表示转换结果中对应的字符位置
+			for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节
+				// 转换成 16 进制字符的转换
+				byte byte0 = tmp[i]; // 取第 i 个字节
+				str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换,
+				// >>> 为逻辑右移,将符号位一起右移
+				str[k++] = hexDigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换
+			}
+			s = new String(str); // 换后的结果转换为字符串
+
+		} catch (Exception e) {
+
+		}
+		return s;
+	}
+
+	public static String getMD5(String inputStr) {
+        return getMD5(inputStr.getBytes());
+//		String md5Str = inputStr;
+//		if (inputStr != null) {
+//			MessageDigest md;
+//			try {
+//				md = MessageDigest.getInstance("MD5");
+//				md.update(inputStr.getBytes());
+//				BigInteger hash = new BigInteger(1, md.digest());
+//				md5Str = hash.toString(16);
+//				if ((md5Str.length() % 2) != 0) {
+//					md5Str = "0" + md5Str;
+//				}
+//			} catch (NoSuchAlgorithmException e) {
+//				logger.error("error message", e);
+//			}
+//		}
+//		return md5Str;
+	}
+}

+ 137 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/tool/util/WebJsonTokenUtil.java

@@ -0,0 +1,137 @@
+package com.iamberry.app.tool.util;
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SignatureException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.auth0.jwt.JWTSigner;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.JWTVerifyException;
+/**
+ * @company	深圳爱贝源科技有限公司
+ * @website www.iamberry.com
+ * @author 	献
+ * @tel		18271840547
+ * @date	2016年11月15日
+ * @explain	使用JWT完成用户Token生成
+ */
+public class WebJsonTokenUtil {
+	
+	/**
+	 * 发行者
+	 */
+	private static final String issuer = "http://app.iamberry.com/";
+	/**
+	 * 校验点
+	 */
+	private static final String verifierURL = "http://app.iamberry.com/user/verifer";
+	/**
+	 * 密匙
+	 */
+	private static final String secret = "sasdf2312ljwuio02u3roij}_+@#_IFJLKAJ";
+	
+	/**
+	 * 签名使用的工具
+	 */
+	private static final JWTSigner signer = new JWTSigner(secret);
+	
+	/**
+	 * 校验使用的工具
+	 */
+	public static final JWTVerifier verifier = new JWTVerifier(secret);
+	
+	/**
+	 * 更加用户id,获取用户Token
+	 * @param userid
+	 * @return
+	 */
+	public static String getToken(Integer userid) {
+		// 当前时间
+		long iat = System.currentTimeMillis() / 1000L;
+		// 过期时间,设置为三天以后,需要重新获取token
+		long exp = iat + 259200L;
+		// 创建对象
+		HashMap<String, Object> claims = new HashMap<String, Object>();
+		claims.put("iss", issuer);
+		claims.put("exp", exp);
+		claims.put("iat", iat);
+		claims.put("verifierURL", verifierURL);
+		claims.put("userid", AES.encrypt(userid.toString()));
+		String jsonToken = signer.sign(claims);
+		return jsonToken;
+	}
+	
+	/**
+	 * return:
+	 * 	1:token过期,失效
+	 * 	2:token正常
+	 * @param userToken
+	 * @return
+	 */
+	public static Map<String, Object> verifier(String userToken) {
+		Map<String, Object> claims = null;
+		try {
+			// 解析TOKEN
+			claims = verifier.verify(userToken);
+		} catch (InvalidKeyException e) {
+			// 无效的键
+			Map<String, Object> error = new HashMap<String, Object>();
+			error.put("status", 1);
+			error.put("message", "Key error");
+			return error;
+		} catch (NoSuchAlgorithmException e) {
+			// 没有这样的算法
+			Map<String, Object> error = new HashMap<String, Object>();
+			error.put("status", 1);
+			error.put("message", "No Such Algorithm");
+			return error;
+		} catch (IllegalStateException e) {
+			// 非法状态
+			Map<String, Object> error = new HashMap<String, Object>();
+			error.put("status", 1);
+			error.put("message", "Illegal State");
+			return error;
+		} catch (SignatureException e) {
+			// 签名有误
+			Map<String, Object> error = new HashMap<String, Object>();
+			error.put("status", 1);
+			error.put("message", "Signature State Error");
+			return error;
+		} catch (IOException e) {
+			Map<String, Object> error = new HashMap<String, Object>();
+			error.put("status", 1);
+			error.put("message", "IO Exception");
+			return error;
+		} catch (JWTVerifyException e) {
+			Map<String, Object> error = new HashMap<String, Object>();
+			error.put("status", 1);
+			error.put("message", e.getMessage());
+			return error;
+		}
+		
+		// 解析userid
+		String temp = AES.decrypt(claims.get("userid").toString());
+		if (StringUtils.isEmpty(temp)) {
+			Map<String, Object> error = new HashMap<String, Object>();
+			error.put("status", 1);
+			error.put("message", "Data has been tampered with");
+			return error;
+		}
+		// 重新定义ID
+		claims.put("userid", temp);
+
+		claims.put("status", 2);
+		claims.put("message", "SUCCESS");
+		return claims;
+	}
+	
+
+	public static void main(String[] args) {
+		System.out.println(getToken(1));
+		System.out.println(verifier("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vYXBwLmlhbWJlcnJ5LmNvbS8iLCJleHAiOjE0Nzk0NjM2ODAsImlhdCI6MTQ3OTIwNDQ4MCwidXNlcmlkIjoiQldadmkxR0dXODYxOUpveU5tcnh1QT09In0.G8QGFzlu27D5BXdHDrnRFqgcv5cxYG2--KO9CI-A7Mk"));
+	}
+}

+ 146 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/verify/ValidateUtil.java

@@ -0,0 +1,146 @@
+package com.iamberry.app.verify;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+/**
+ * @author 何秀刚
+ * Class Description: 校验规则
+ * Create Date:2016年5月3日
+ * Update Date:2016年5月3日
+ */
+public class ValidateUtil {
+
+    /**
+     * 6~16位字符,至少包含数字、大写字母、小写字母、符号中的两种
+     * http://www.docin.com/p-835484940.html
+     * @param value
+     * @return
+     */
+    public static boolean checkPwd(String value) {
+        return value.matches("(?!^[0-9]+$)(?!^[A-Z]+$)(?!^[a-z]+$)(?!^[^A-z0-9]+$)^.{6,16}");
+    }
+
+    /**
+     * 验证交易密码
+     * @param value
+     * @return
+     */
+    public static boolean checkTradePwd(String value) {
+        return value.matches("[0-9]{6}");
+    }
+
+    public static boolean checkEmail(String value, int length) {
+        return value.matches("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")
+                && value.length() <= length;
+    }
+
+    /**
+     * 检查电话输入 是否正确
+     * 正确格 式 012-87654321、0123-87654321、0123-7654321
+     * @param value
+     * @return
+     */
+    public static boolean checkTel(String value) {
+        return value.matches("\\d{4}-\\d{8}|\\d{4}-\\d{7}|\\d(3)-\\d(8)");
+    }
+
+    /**
+     * 检查手机输入 是否正确
+     *
+     * @param value
+     * @return
+     */
+    public static boolean checkMobile(String value) {
+        return value.matches("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
+    }
+
+    /**
+     * 检查字符串是 否含有HTML标签
+     * @param value
+     * @return
+     */
+
+    public static boolean checkHtmlTag(String value) {
+        return value.matches("<(\\S*?)[^>]*>.*?</\\1>|<.*? />");
+    }
+
+    /**
+     * 检查URL是 否合法
+     * @param value
+     * @return
+     */
+    public static boolean checkURL(String value) {
+        return value.matches("[a-zA-z]+://[^\\s]*");
+    }
+
+    /**
+     * 检查IP是否 合法
+     * @param value
+     * @return
+     */
+    public static boolean checkIP(String value) {
+        return value.matches("\\d{1,3}+\\.\\d{1,3}+\\.\\d{1,3}+\\.\\d{1,3}");
+    }
+
+    /**
+     * 检查QQ是否 合法,必须是数字,且首位不能为0,最长15位
+     * @param value
+     * @return
+     */
+
+    public static boolean checkQQ(String value) {
+        return value.matches("[1-9][0-9]{4,13}");
+    }
+
+    /**
+     * 检查邮编是否 合法
+     * @param value
+     * @return
+     */
+    public static boolean checkPostCode(String value) {
+        return value.matches("[1-9]\\d{5}(?!\\d)");
+    }
+
+    /**
+     * 检查身份证是 否合法,15位或18位
+     * @param number
+     * @return
+     */
+    public static boolean checkIDCard(String number)
+    {
+        String rgx = "^\\d{15}|^\\d{17}([0-9]|X|x)$";
+
+        return isCorrect(rgx, number);
+    }
+
+    //正则验证
+    public static boolean isCorrect(String rgx, String res)
+    {
+        Pattern p = Pattern.compile(rgx);
+
+        Matcher m = p.matcher(res);
+
+        return m.matches();
+    }
+    /**
+     * 检查输入是否 超出规定长度
+     * Java教程:http://www.javaweb.cc
+     * @param length
+     * @param value
+     * @return
+     */
+    public static boolean checkLength(String value, int length) {
+        return ((value == null || "".equals(value.trim())) ? 0 : value.length()) <= length;
+    }
+
+    /**
+     * 检查是否为空 字符串,空:true,不空:false
+     *
+     * @param value
+     * @return
+     */
+    public static boolean checkNull(String value) {
+        return value == null || "".equals(value.trim());
+    }
+
+}

+ 45 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/app/verify/ValidatorInterface.java

@@ -0,0 +1,45 @@
+package com.iamberry.app.verify;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+/**
+ * @author 何秀刚
+ * Introduction to the : 校验的注解标识
+ * create date: 2016年1月12日
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface ValidatorInterface {
+	
+	/**
+	 * 校验当前字段和指定字段是否一致
+	 * @return
+	 */
+	String equalsOtherField() default "";
+	
+	/**
+	 * 效验是否为空
+	 * @return
+	 */
+	String isNotNull() default "true";
+	
+	/**
+	 * 校验某个字段是否复合传输的规则
+	 * @return
+	 */
+	String validatorIsRule() default "";
+	
+	/**
+	 * 校验字符串长度
+	 */
+	int [] fieldLengthScope() default {-1, -1};
+	
+	/**
+	 * 是否启用本注解, true启动,false不启用
+	 */
+	boolean isEnable() default false;
+	
+}

+ 36 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/cache/CacheFactory.java

@@ -0,0 +1,36 @@
+package com.iamberry.cache;
+/**
+ * @company	深圳爱贝源科技有限公司
+ * @website www.iamberry.com
+ * @author 	献
+ * @tel		18271840547
+ * @date	2016年9月5日
+ * @explain	本地缓存工具类
+ */
+public class CacheFactory <K, V> {
+
+	/**
+	 * 创建足够缓存2000个数据的对象
+	 */
+	private LocalCache<K, V> localCache = new LocalCache<K, V>(1000);
+	
+	/**
+	 * 缓存数据到本地实现中,如果已经存在未k的数据,将使用v覆盖以前的数据value
+	 * @param k 缓存的key
+	 * @param v 缓存的value
+	 * @author 	献
+	 */
+	public void put(K k, V v) {
+		localCache.put(k, v);
+	}
+	
+	/**
+	 * 获取已经缓存的对象,如果不存在,返回为null
+	 * @param 缓存的key
+	 * @return 缓存的value
+	 * @author 	献
+	 */
+	public V get(K k) {
+		return localCache.get(k);
+	}
+}

+ 84 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/cache/LocalCache.java

@@ -0,0 +1,84 @@
+package com.iamberry.cache;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentHashMap;
+/**
+ * @company	深圳爱贝源科技有限公司
+ * @website www.iamberry.com
+ * @author 	献
+ * @tel		18271840547
+ * @date	2016年9月5日
+ * @explain	缓存实现,模拟JVM实现,多线程下是安全的
+ */
+public final class LocalCache<K, V> {
+
+	/**
+	 * 总大小
+	 */
+    private final int size;
+
+    /**
+     * 对象的分配区域
+     */
+    private final Map<K,V> eden;
+
+    /**
+     * 如果eden区域分配完毕,那么将数据分配到longterm,使用WeakHashMap维护数据
+     */
+    private final Map<K,V> longterm;
+
+    /**
+     * 构造参数,初始化一个默认大小的map,保证缓存的高效性
+     * @param size
+     */
+    public LocalCache(int size) {
+        this.size = size;
+        this.eden = new ConcurrentHashMap<>(size);
+        this.longterm = new WeakHashMap<>(size);
+    }
+
+    /**
+     * 获取存储的值,线程安全
+     * @param k key值
+     * @return 缓存的值
+     */
+    public V get(K k) {
+    	// 首先在新生代获取
+        V v = this.eden.get(k);
+        if (v == null) {
+        	// 如果没有在新生代,去longterm获取
+            synchronized (longterm) {
+                v = this.longterm.get(k);
+            }
+            
+            // 如果数据不为空,将数据put到eden区,缓存数据
+            if (v != null) {
+                this.eden.put(k, v);
+            }
+        }
+        return v;
+    }
+
+    /**
+     * 将一个数据put到缓存中
+     * @param k
+     * @param v
+     */
+    public void put(K k, V v) {
+    	
+    	// 判断是否eden区是否存在数据
+        if (this.eden.size() >= size) {
+        	
+        	// 如果eden去分配完毕,那么僵数据copy到longterm去
+            synchronized (longterm) {
+                this.longterm.putAll(this.eden);
+            }
+            
+            // 清空eden数据
+            this.eden.clear();
+        }
+        
+        // 将数据分配在eden区
+        this.eden.put(k, v);
+    }
+}

File diff suppressed because it is too large
+ 166 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/autiXSS/AntiXSS.java


+ 124 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/autiXSS/XSSHandler.java

@@ -0,0 +1,124 @@
+package com.iamberry.wechat.autiXSS;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+
+
+/**
+ * @author 何秀刚
+ * Class Description: xss处理
+ * Create Date:2016年5月4日
+ * Update Date:2016年5月4日
+ */
+public class XSSHandler {
+	private static boolean escapeHTML = false;
+	private static boolean escapeJavaScript = false;
+	private static boolean escapeSQL = false;
+
+	public static void setHandType(boolean escapeHTML, boolean escapeJavaScript,
+								   boolean escapeSQL) {
+		XSSHandler.escapeHTML = escapeHTML;
+		XSSHandler.escapeJavaScript = escapeJavaScript;
+		XSSHandler.escapeSQL = escapeSQL;
+	}
+
+	/**
+	 * 创建时间: 2013-10-17 上午10:28:49
+	 * 参数: 
+	 * 返回值: String
+	 * 方法描述 : 根据设置的转义类型进行非法字符转义
+	 */
+	public static String handler(String content) {
+		if (!StringUtils.isEmpty(content)) {
+			if (escapeHTML)
+				content = StringEscapeUtils.escapeHtml(content);
+			if (escapeJavaScript)
+				content = StringEscapeUtils.escapeJavaScript(content);
+			if (escapeSQL)
+				content = StringEscapeUtils.escapeSql(content);
+
+		}
+		return content;
+	}
+
+	public static String handle(String content, boolean escapeHTML,
+								boolean escapeJavaScript, boolean escapeSQL) {
+		if (!StringUtils.isEmpty(content)) {
+			if (escapeSQL)
+				content = StringEscapeUtils.escapeSql(content);
+			if (escapeJavaScript)
+				content = StringEscapeUtils.escapeJavaScript(content);
+			if (escapeHTML)
+				content = StringEscapeUtils.escapeHtml(content);
+
+			// 还原中文
+			content = decodeUnicode(content);
+		}
+		return content;
+	}
+
+	public static String decodeUnicode(String content) {
+		char aChar;
+		int len = content.length();
+		StringBuffer outBuffer = new StringBuffer(len);
+		for (int x = 0; x < len; ) {
+			aChar = content.charAt(x++);
+			if (aChar == '\\') {
+				aChar = content.charAt(x++);
+				if (aChar == 'u') {
+					int value = 0;
+					for (int i = 0; i < 4; i++) {
+						aChar = content.charAt(x++);
+						switch (aChar) {
+							case '0':
+							case '1':
+							case '2':
+							case '3':
+							case '4':
+							case '5':
+							case '6':
+							case '7':
+							case '8':
+							case '9':
+								value = (value << 4) + aChar - '0';
+								break;
+							case 'a':
+							case 'b':
+							case 'c':
+							case 'd':
+							case 'e':
+							case 'f':
+								value = (value << 4) + 10 + aChar - 'a';
+								break;
+							case 'A':
+							case 'B':
+							case 'C':
+							case 'D':
+							case 'E':
+							case 'F':
+								value = (value << 4) + 10 + aChar - 'A';
+								break;
+							default:
+								throw new IllegalArgumentException("Malformed encoding.");
+						}
+					}
+					outBuffer.append((char) value);
+				} else {
+					if (aChar == 't') {
+						aChar = '\t';
+					} else if (aChar == 'r') {
+						aChar = '\r';
+					} else if (aChar == 'n') {
+						aChar = '\n';
+					} else if (aChar == 'f') {
+						aChar = '\f';
+					}
+					outBuffer.append(aChar);
+				}
+			} else {
+				outBuffer.append(aChar);
+			}
+		}
+		return outBuffer.toString();
+	}
+}

+ 113 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/file/FileType.java

@@ -0,0 +1,113 @@
+package com.iamberry.wechat.file;
+/**
+ * @company	深圳爱贝源科技有限公司
+ * @website www.iamberry.com
+ * @author 	献
+ * @tel		18271840547
+ * @date	2016年10月13日
+ * @explain	文件类型之魔数(文件开头,上传文件时,建议使用此验证文件类型,勿相信后缀名)
+ */
+public enum FileType {
+	/**
+	 * JPEG
+	 */
+	JPEG("FFD8FF", "JPEG"),
+	
+	/**
+	 * PNG
+	 */
+	PNG("89504E47", "PNG"),
+	
+	/**
+	 * GIF
+	 */
+	GIF("47494638", "GIF"),
+	
+	/**
+	 * TIFF
+	 */
+	TIFF("49492A00", "TIFF"),
+	
+	/**
+	 * Windows Bitmap
+	 */
+	BMP("424D", "BMP"),
+	
+	/**
+	 * CAD
+	 */
+	DWG("41433130", "DWG"),
+	
+	/**
+	 * Adobe Photoshop
+	 */
+	PSD("38425053", "PSD"),
+	
+	/**
+	 * XML
+	 */
+	XML("3C3F786D6C", "XML"),
+	
+	/**
+	 * HTML
+	 */
+	HTML("68746D6C3E", "HTML"),
+	
+	/**
+	 * Adobe Acrobat
+	 */
+	PDF("255044462D312E", "PDF"),
+	
+	/**
+	 * ZIP
+	 */
+	ZIP("504B0304", "ZIP"),
+	
+	/**
+	 * RAR
+	 */
+	RAR("52617221", "RAR"),
+	
+	/**
+	 * Wave
+	 */
+	WAV("57415645", "WAV"),
+	
+	/**
+	 * AVI
+	 */
+	AVI("41564920", "AVI"),
+	
+	/**
+	 * TXT
+	 */
+	TXT("3132302E37", "TXT");
+	
+	// 文件模数
+	private String value = "";
+	
+	// 模数对应后缀
+	private String suffix;
+	
+	private FileType(String value, String suffix) {
+		this.value = value;
+		this.suffix = suffix;
+	}
+	
+	public String getSuffix() {
+		return suffix;
+	}
+
+	public void setSuffix(String suffix) {
+		this.suffix = suffix;
+	}
+
+	public String getValue() {
+		return value;
+	}
+	
+	public void setValue(String value) {
+		this.value = value;
+	}
+	
+}

+ 211 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/file/FileUtils.java

@@ -0,0 +1,211 @@
+package com.iamberry.wechat.file;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.servlet.ServletContext;
+
+import org.springframework.web.multipart.MultipartFile;
+
+import sun.misc.BASE64Decoder;
+
+import com.iamberry.wechat.tools.DateTimeUtil;
+/**
+ * @company	深圳爱贝源科技有限公司
+ * @website www.iamberry.com
+ * @author 	献
+ * @tel		18271840547
+ * @date	2016年10月13日
+ * @explain	上传文件工具类
+ */
+public class FileUtils {
+	
+	/**
+	 * 保存文件到项目根目录下指定路径
+	 * @param servletContext 使用request.getServletContext() 获取<br>
+	 * @param file           文件路径<br>
+	 * @param savePathStr    项目根目录下路,必须以'/'结尾,如:'/aa/bb/cc/'<br>
+	 * @return               返回UploadResultBean<br>
+	 * @throws Exception     异常
+	 */
+	public static UploadResultBean saveFile(ServletContext servletContext, MultipartFile file, String savePathStr) {
+		
+		// 检查&获取原文件名称
+		if (file.getOriginalFilename() == null || file.isEmpty()) {
+			return null;
+		}
+		String imageName = file.getOriginalFilename();
+		if (imageName == null || imageName.isEmpty()) {
+			return null;
+		}
+
+		// 返回对象
+		UploadResultBean bean = new UploadResultBean();
+		bean.setUploadFileName(imageName);
+
+		// 获取文件后缀
+		FileType fileType = null;
+		boolean isTxt = false;
+		if (!isTxt) {
+			try {
+				fileType = getType(file.getInputStream());
+			} catch (IOException e1) {
+				e1.printStackTrace();
+			}
+			if (fileType == null) {
+				return null;
+			}
+		} else {
+			fileType = FileType.TXT;
+		}
+		
+		// 文件名称
+		StringBuilder fileName = new StringBuilder();
+		fileName.append(DateTimeUtil.format(new Date(), "yyMMddHHmmss")).append(byte2hex(createRandomByte())).append(".").append(fileType.getSuffix());
+		bean.setSaveFileName(fileName.toString());
+		bean.setSaveFilePath(savePathStr + fileName.toString());
+		// URL路径
+		String savePath = servletContext.getRealPath(savePathStr);
+		// 文件系统路径
+		savePath = savePath + File.separator + fileName.toString();
+		try {
+			org.apache.commons.io.FileUtils.writeByteArrayToFile(new File(savePath), file.getBytes());
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		// 关闭相关流对象
+		return bean;
+	}
+	
+	/**
+	 * 读取文件头,这里需要注意的是,每个文件的魔数的长度都不相同,由此使用startWith
+	 * @param filePath
+	 * @return
+	 * @throws Exception
+	 */
+	public static String getFileHeader(InputStream inputStream) throws Exception {
+		byte [] b = new byte[28];
+		inputStream.read(b, 0, 28);
+		// 此处可以不关,但是掉用方,必须关闭流对象
+		inputStream.close();
+		return byte2hex(b);
+	}
+	
+	/** 
+     * java字节码转字符串 
+     * @param b 
+     * @return 
+     */
+    public static String byte2hex(byte[] b) { //一个字节的数,
+        // 转成16进制字符串
+        String hs = "";
+        String tmp = "";
+        for (int n = 0; n < b.length; n++) {
+            //整数转成十六进制表示
+            tmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
+            if (tmp.length() == 1) {
+                hs = hs + "0" + tmp;
+            } else {
+                hs = hs + tmp;
+            }
+        }
+        tmp = null;
+        return hs;
+    }
+	
+	/**
+	 * 判断文件类型
+	 * @throws Exception 
+	 */
+	public static FileType getType(InputStream inputStream) {
+		String fileHead = null;
+		try {
+			fileHead = getFileHeader(inputStream);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		if (fileHead == null || fileHead.length() == 0) {
+			return null;
+		}
+		// 大写,因为在我们的FileType中,全部使用了大写
+		fileHead = fileHead.toUpperCase();
+		FileType [] fileTypes = FileType.values();
+		for (FileType fileType : fileTypes) {
+			if (fileHead.startsWith(fileType.getValue())) {
+				return fileType;
+			}
+		}
+		return null;
+	}
+	
+
+	public static String getType(String fileHead) {
+		FileType [] fileTypes = FileType.values();
+		for (FileType fileType : fileTypes) {
+			if (fileHead.startsWith(fileType.getValue())) {
+				return fileType.getSuffix();
+			}
+		}
+		return null;
+	}
+	
+	public static boolean generateImage(String imgStr, String imgFilePath) throws IOException {  
+		// Base64解码  
+		byte[] bytes = new BASE64Decoder().decodeBuffer(imgStr);
+		for (int i = 0; i < bytes.length; ++i) {  
+			if (bytes[i] < 0) {
+				// 调整异常数据  
+				bytes[i] += 256;  
+			}  
+		}  
+		// 生成图片 
+		File file = new File(imgFilePath);
+		org.apache.commons.io.FileUtils.writeByteArrayToFile(file, bytes);
+		return true;  
+	}
+	
+	private static SecureRandom random = null;
+	static {
+		try {
+			random = SecureRandom.getInstance("SHA1PRNG");
+		} catch (NoSuchAlgorithmException e) {
+		}
+	}
+	/**
+	 * 创建一个安全的随机数组byte[]
+	 * 
+	 * @return
+	 */
+	private static byte[] createRandomByte() {
+		try {
+			byte[] bytes = new byte[1024 / 8];
+			random.nextBytes(bytes);
+			int count = 10;
+			byte[] seed = random.generateSeed(count);
+			random = SecureRandom.getInstance("SHA1PRNG");
+			random.setSeed(seed);
+			SecureRandom random2 = SecureRandom.getInstance("SHA1PRNG");
+			random2.setSeed(seed);
+			return seed;
+		} catch (Exception e) {
+			return UUID.randomUUID().toString().getBytes();
+		}
+	}
+
+	/**
+	 * 获取一个安全的token
+	 * 
+	 * @return
+	 */
+	public static String getToken() {
+		return byte2hex(createRandomByte());
+	}
+}

+ 221 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/file/ImageUtils.java

@@ -0,0 +1,221 @@
+package com.iamberry.wechat.file;
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.geom.AffineTransform;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import com.iamberry.wechat.tools.NameUtils;
+import com.mortennobel.imagescaling.ResampleFilters;
+import com.mortennobel.imagescaling.ResampleOp;
+
+/**
+ * 图片工具类, 图片水印,文字水印,缩放,补白等 <br>
+ * 注意: 如果上传了图片,一定要使用此类对图片进行水印,防止恶意图片,或者对图片进行缩放
+ * @author 何秀刚
+ */
+public final class ImageUtils {
+    
+    private ImageUtils(){}
+    /**
+	 * 添加图片水印, 后期可以将图片水印居于右下角
+	 * @param targetImg 目标图片路径,如:C://myPictrue//1.jpg
+	 * @param waterImg  水印图片路径,如:C://myPictrue//logo.png
+	 * @param x 水印图片距离目标图片左侧的偏移量,如果x<0, 则在正中间
+	 * @param y 水印图片距离目标图片上侧的偏移量,如果y<0, 则在正中间
+	 * @param alpha 透明度(0.0 -- 1.0, 0.0为完全透明,1.0为完全不透明)
+	*/
+    public final static void pressImage(String targetImg, String waterImg, int x, int y, float alpha) {
+            try {
+                File file = new File(targetImg);
+                Image image = ImageIO.read(file);
+                int width = image.getWidth(null);
+                int height = image.getHeight(null);
+                BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+                Graphics2D g = bufferedImage.createGraphics();
+                g.drawImage(image, 0, 0, width, height, null);
+            
+                Image waterImage = ImageIO.read(new File(waterImg));    // 水印文件
+                int width_1 = waterImage.getWidth(null);
+                int height_1 = waterImage.getHeight(null);
+                g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
+                
+                int widthDiff = width - width_1;
+                int heightDiff = height - height_1;
+                if(x < 0){
+                    x = widthDiff / 2;
+                }else if(x > widthDiff){
+                    x = widthDiff;
+                }
+                if(y < 0){
+                    y = heightDiff / 2;
+                }else if(y > heightDiff){
+                    y = heightDiff;
+                }
+                g.drawImage(waterImage, x, y, width_1, height_1, null); // 水印文件结束
+                g.dispose();
+                ImageIO.write(bufferedImage, NameUtils.PICTRUE_FORMATE_JPG, file);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+    }
+
+    /**
+     * 添加文字水印
+     * @param targetImg 目标图片路径,如:C://myPictrue//1.jpg
+     * @param pressText 水印文字, 如:中国证券网
+     * @param x 水印文字距离目标图片左侧的偏移量,如果x<0, 则在正中间
+     * @param y 水印文字距离目标图片上侧的偏移量,如果y<0, 则在正中间
+     */
+    public static void press(String targetImg, String srcImg, String pressText, int x, int y, int imgx, int imgy) {
+        try {
+        	
+        	String fontName = "宋体";
+        	int fontStyle = Font.BOLD;
+        	int fontSize = 25;
+        	Color color = Color.RED;
+        	float alpha = 1;
+        	
+        	/**
+        	 * 水印文字
+        	 */
+            File file = new File(targetImg);
+            Image image = ImageIO.read(file);
+            int width = image.getWidth(null);
+            int height = image.getHeight(null);
+            BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+            Graphics2D g = bufferedImage.createGraphics();
+            g.drawImage(image, 0, 0, width, height, null);
+            g.setFont(new Font(fontName, fontStyle, fontSize));
+            g.setColor(color);
+            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
+            
+            int width_1 = fontSize * getLength(pressText);
+            int height_1 = fontSize;
+            int widthDiff = width - width_1;
+            int heightDiff = height - height_1;
+            if(x < 0){
+                x = widthDiff / 2;
+            }else if(x > widthDiff){
+                x = widthDiff;
+            }
+            if(y < 0){
+                y = heightDiff / 2;
+            }else if(y > heightDiff){
+                y = heightDiff;
+            }
+            g.drawString(pressText, x, y + height_1);
+            
+            /**
+             * 水印图片
+             */
+            Image tarImage = ImageIO.read(new File(srcImg));
+            g.drawImage(tarImage, imgx, imgy, tarImage.getWidth(null), tarImage.getHeight(null), null); // 水印文件结束
+            
+            g.dispose();
+            ImageIO.write(bufferedImage, targetImg.substring(targetImg.lastIndexOf(".") + 1), file);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+    /**
+     * 获取字符长度,一个汉字作为 1 个字符, 一个英文字母作为 0.5 个字符
+     * @param text
+     * @return 字符长度,如:text="中国",返回 2;text="test",返回 2;text="中国ABC",返回 4.
+     */
+    public static int getLength(String text) {
+        int textLength = text.length();
+        int length = textLength;
+        for (int i = 0; i < textLength; i++) {
+            if (String.valueOf(text.charAt(i)).getBytes().length > 1) {
+                length++;
+            }
+        }
+        return (length % 2 == 0) ? length / 2 : length / 2 + 1;
+    }
+
+    /**
+     * 图片缩放
+     * @param filePath 图片路径
+     * @param height 高度
+     * @param width 宽度
+     * @param bb 比例不对时是否需要补白
+     */
+    public static void resize(String filePath, int height, int width, boolean bb) {
+        try {
+            double ratio = 0; //缩放比例    
+            File f = new File(filePath);   
+            BufferedImage bi = ImageIO.read(f);   
+            Image itemp = bi.getScaledInstance(width, height, BufferedImage.SCALE_SMOOTH);   
+            //计算比例   
+            if ((bi.getHeight() > height) || (bi.getWidth() > width)) {   
+                if (bi.getHeight() > bi.getWidth()) {   
+                    ratio = (new Integer(height)).doubleValue() / bi.getHeight();   
+                } else {   
+                    ratio = (new Integer(width)).doubleValue() / bi.getWidth();   
+                }   
+                AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(ratio, ratio), null);   
+                itemp = op.filter(bi, null);   
+            }   
+            if (bb) {   
+                BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);   
+                Graphics2D g = image.createGraphics();   
+                g.setColor(Color.white);   
+                g.fillRect(0, 0, width, height);   
+                if (width == itemp.getWidth(null))   
+                    g.drawImage(itemp, 0, (height - itemp.getHeight(null)) / 2, itemp.getWidth(null), itemp.getHeight(null), Color.white, null);   
+                else  
+                    g.drawImage(itemp, (width - itemp.getWidth(null)) / 2, 0, itemp.getWidth(null), itemp.getHeight(null), Color.white, null);   
+                g.dispose();   
+                itemp = image;   
+            }
+            ImageIO.write((BufferedImage) itemp, "jpg", f);   
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    
+    /**
+     * 修改图片大小类, 默认修改为0.6, 凡是设计上传文件的地方,必须使用!
+     * @param srcFilePath 图片资源位置
+     * @return
+     */
+    public static boolean reSize(String srcFilePath) {
+    	try {
+    		File file = new File(srcFilePath );
+			BufferedImage sourceImage = ImageIO.read(file);
+            int newwidth = (int) (sourceImage.getWidth() * 0.99);
+            double newheight = (int) sourceImage.getHeight() * 0.99;
+            ResampleOp resizeOp = new ResampleOp(newwidth, (int) newheight);
+            resizeOp.setFilter(ResampleFilters.getTriangleFilter());
+            BufferedImage resizedImage = resizeOp.filter(sourceImage, null);
+            ImageIO.write(resizedImage, srcFilePath.substring(srcFilePath.lastIndexOf(".") + 1), file);
+            return true;
+        } catch (Exception e) {
+        	return false;
+        }
+    }
+    public static boolean reSize(String srcFilePath, double width, double height) {
+    	try {
+    		File file = new File(srcFilePath );
+			BufferedImage sourceImage = ImageIO.read(file);
+            int newwidth = (int) (sourceImage.getWidth() * width);
+            double newheight = (int) sourceImage.getHeight() * height;
+            ResampleOp resizeOp = new ResampleOp(newwidth, (int) newheight);
+            resizeOp.setFilter(ResampleFilters.getTriangleFilter());
+            BufferedImage resizedImage = resizeOp.filter(sourceImage, null);
+            ImageIO.write(resizedImage, srcFilePath.substring(srcFilePath.lastIndexOf(".") + 1), file);
+            return true;
+        } catch (Exception e) {
+        	return false;
+        }
+    }
+}

+ 35 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/file/UploadResultBean.java

@@ -0,0 +1,35 @@
+package com.iamberry.wechat.file;
+
+public class UploadResultBean {
+	//上传前的文件名称
+	private String uploadFileName;
+	//保存的文件名称
+	private String saveFileName;
+	//保存的路径(包括文件名称),相对于项目根目录
+	private String saveFilePath;
+	
+	public String getUploadFileName() {
+		return uploadFileName;
+	}
+	public void setUploadFileName(String uploadFileName) {
+		this.uploadFileName = uploadFileName;
+	}
+	public String getSaveFileName() {
+		return saveFileName;
+	}
+	public void setSaveFileName(String saveFileName) {
+		this.saveFileName = saveFileName;
+	}
+	public String getSaveFilePath() {
+		return saveFilePath;
+	}
+	public void setSaveFilePath(String saveFilePath) {
+		this.saveFilePath = saveFilePath;
+	}
+	@Override
+	public String toString() {
+		return "UploadResultBean [uploadFileName=" + uploadFileName
+				+ ", saveFileName=" + saveFileName + ", saveFilePath="
+				+ saveFilePath + "]";
+	}
+}

+ 40 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/AddrUtil.java

@@ -0,0 +1,40 @@
+package com.iamberry.wechat.tools;
+
+import java.util.TreeMap;
+
+public class AddrUtil {
+
+	public static String getAddress(String url, String access_token){
+		String nonceStr = Sha1Util.getNonceStr(); 
+		String timestamp = Sha1Util.getTimeStamp();
+		TreeMap<String, String> signatureParams = new TreeMap<String, String>();
+		signatureParams.put("noncestr", nonceStr);
+		signatureParams.put("appid", NameUtils.appId);
+		signatureParams.put("timestamp", timestamp);
+		signatureParams.put("url", url);//当前页面链接
+		signatureParams.put("accesstoken", access_token);//网页授权得到
+		String s1 = TenpayUtil.getKeyValue(signatureParams);
+		
+		System.out.println(s1);
+		
+		String addrSign = Sha1Util.getSha2(s1);
+		String json = "{\"nonceStr\":\"%s\",\"appId\":\"%s\",\"timeStamp\":\"%s\",\"addrSign\":\"%s\"}";
+		json = String.format(json, nonceStr, NameUtils.appId, timestamp, addrSign);
+		return json;
+	}
+	
+	public static void main(String[] args) {
+		TreeMap<String, String> signatureParams = new TreeMap<String, String>();
+		signatureParams.put("noncestr", "123456");
+		signatureParams.put("appid", "wx17ef1eaef46752cb");
+		signatureParams.put("timestamp", "1384841012");
+		signatureParams.put("url", "http://open.weixin.qq.com/");//当前页面链接
+		signatureParams.put("accesstoken", "OezXcEiiBSKSxW0eoylIeBFk1b8VbNtfWALJ5g6aMgZHaqZwK4euEskSn78Qd5pLsfQtuMdgmhajVM5QDm24W8X3tJ18kz5mhmkUcI3RoLm7qGgh1cEnCHejWQo8s5L3VvsFAdawhFxUuLmgh5FRA");//网页授权得到
+		String s1 = TenpayUtil.getKeyValue(signatureParams);
+		System.out.println(s1);
+		String addrSign = Sha1Util.getSha1(s1);
+		String json = "{\"nonceStr\":\"%s\",\"appId\":\"%s\",\"timeStamp\":\"%s\",\"addrSign\":\"%s\"}";
+		json = String.format(json, "123456", "wx17ef1eaef46752cb", "1384841012", addrSign);
+		System.out.println(json);
+	}
+}

+ 229 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/DataSourceManager.java

@@ -0,0 +1,229 @@
+package com.iamberry.wechat.tools;
+
+import java.io.IOException;
+import java.util.Properties;
+
+
+/**
+ * description : 加载jdbc的配置文件 
+ * @author 何秀刚
+ * create date:2016年3月23日
+ */
+public class DataSourceManager {
+	
+	
+	private String jdbcDriver; // driver.class
+
+	private String jdbcUserName; // 用户名
+	
+	private String jdbcPassword; // 密码
+	
+	private String jdbcUrl; // url
+	
+	private Integer minPoolSize = 5; // 数据库连接处最小保持连接数,默认为5
+	
+	private Integer maxPoolSize = 100; // 数据库连接最多保持连接数,默认为15, 保证系统还有活跃链接50
+	
+	private Integer initialPoolSize = 3; // 初始化连接池数据,默认为3,在minPoolSize-maxPoolSize之间取值
+	
+	private Integer maxIdleTime = 0; // 最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。默认值: 0
+	
+	private Integer checkoutTimeout = 0;// 当连接池连接耗尽时,客户端调用getConnection()后等待获取新连接的时间,超时后将抛出SQLException,如设为0则无限期等待。单位毫秒。默认: 0
+	
+	private Integer acquireIncrement = 3; // 当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。默认值: 3
+	
+	private Integer acquireRetryAttempts = 30; // 定义在从数据库获取新连接失败后重复尝试的次数。默认值: 30 ;小于等于0表示无限次
+	
+	private Integer acquireRetryDelay = 1000; // 重新尝试的时间间隔,默认为:1000毫秒
+	
+	private Boolean autoCommitOnClose = false; // 关闭连接时,是否提交未提交的事务,默认为false,即关闭连接,回滚未提交的事务
+	
+	private String automaticTestTable = "tb_ratfw_table_text"; // c3p0将建一张名为Test的空表,并使用其自带的查询语句进行测试。如果定义了这个参数那么属性preferredTestQuery将被忽略。你不能在这张Test表上进行任何操作,它将只供c3p0测试使用。默认值: null
+	
+	private Boolean breakAfterAcquireFailure = false; // 如果为false,则获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常,但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭。默认: false
+	
+	private Integer idleConnectionTestPeriod = 0; // 每60秒检查所有连接池中的空闲连接。默认值: 0,不检查 
+	
+	private Integer maxStatements = 0; // c3p0全局的PreparedStatements缓存的大小。如果maxStatements与maxStatementsPerConnection均为0,则缓存不生效,只要有一个不为0,则语句的缓存就能生效。如果默认值: 0
+	
+	private Integer maxStatementsPerConnection = 0; // maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。默认值: 0
+	
+	public Integer getMinPoolSize() {
+		return minPoolSize;
+	}
+
+	public void setMinPoolSize(Integer minPoolSize) {
+		if (minPoolSize != null)
+			this.minPoolSize = minPoolSize;
+	}
+
+	public Integer getMaxPoolSize() {
+		return maxPoolSize;
+	}
+
+	public void setMaxPoolSize(Integer maxPoolSize) {
+		if (maxPoolSize != null)
+			this.maxPoolSize = maxPoolSize;
+	}
+
+	public Integer getInitialPoolSize() {
+		return initialPoolSize;
+	}
+
+	public void setInitialPoolSize(Integer initialPoolSize) {
+		if (initialPoolSize != null)
+			this.initialPoolSize = initialPoolSize;
+	}
+
+	public Integer getMaxIdleTime() {
+		return maxIdleTime;
+	}
+
+	public void setMaxIdleTime(Integer maxIdleTime) {
+		if (maxIdleTime != null)
+			this.maxIdleTime = maxIdleTime;
+	}
+
+	public Integer getCheckoutTimeout() {
+		return checkoutTimeout;
+	}
+
+	public void setCheckoutTimeout(Integer checkoutTimeout) {
+		if (checkoutTimeout != null)
+			this.checkoutTimeout = checkoutTimeout;
+	}
+
+	public Integer getAcquireIncrement() {
+		return acquireIncrement;
+	}
+
+	public void setAcquireIncrement(Integer acquireIncrement) {
+		if (acquireIncrement != null)
+			this.acquireIncrement = acquireIncrement;
+	}
+
+	public Integer getAcquireRetryAttempts() {
+		return acquireRetryAttempts;
+	}
+
+	public void setAcquireRetryAttempts(Integer acquireRetryAttempts) {
+		if (acquireRetryAttempts != null)
+			this.acquireRetryAttempts = acquireRetryAttempts;
+	}
+
+	public Integer getAcquireRetryDelay() {
+		return acquireRetryDelay;
+	}
+
+	public void setAcquireRetryDelay(Integer acquireRetryDelay) {
+		if (acquireRetryDelay != null)
+			this.acquireRetryDelay = acquireRetryDelay;
+	}
+
+	public boolean isAutoCommitOnClose() {
+		return autoCommitOnClose;
+	}
+
+	public void setAutoCommitOnClose(Boolean autoCommitOnClose) {
+		if (autoCommitOnClose != null)
+			this.autoCommitOnClose = autoCommitOnClose;
+	}
+
+	public String getAutomaticTestTable() {
+		return automaticTestTable;
+	}
+
+	public void setAutomaticTestTable(String automaticTestTable) {
+		if (automaticTestTable != null && !automaticTestTable.isEmpty())
+			this.automaticTestTable = automaticTestTable;
+	}
+
+	public boolean isBreakAfterAcquireFailure() {
+		return breakAfterAcquireFailure;
+	}
+
+	public void setBreakAfterAcquireFailure(Boolean breakAfterAcquireFailure) {
+		if (breakAfterAcquireFailure != null)
+			this.breakAfterAcquireFailure = breakAfterAcquireFailure;
+	}
+
+	public Integer getIdleConnectionTestPeriod() {
+		return idleConnectionTestPeriod;
+	}
+
+	public void setIdleConnectionTestPeriod(Integer idleConnectionTestPeriod) {
+		if(idleConnectionTestPeriod != null)
+			this.idleConnectionTestPeriod = idleConnectionTestPeriod;
+	}
+
+	public Integer getMaxStatements() {
+		return maxStatements;
+	}
+
+	public void setMaxStatements(Integer maxStatements) {
+		if (maxStatements != null)
+			this.maxStatements = maxStatements;
+	}
+
+	public Integer getMaxStatementsPerConnection() {
+		return maxStatementsPerConnection;
+	}
+
+	public void setMaxStatementsPerConnection(Integer maxStatementsPerConnection) {
+		if (maxStatementsPerConnection != null)
+			this.maxStatementsPerConnection = maxStatementsPerConnection;
+	}
+
+	public String getJdbcDriver() {
+		return jdbcDriver;
+	}
+
+	
+	
+
+	public void setJdbcDriver(String jdbcDriver) {
+		this.jdbcDriver = jdbcDriver;
+	}
+
+	public String getJdbcUserName() {
+		return jdbcUserName;
+	}
+
+	public void setJdbcUserName(String jdbcUserName) {
+		this.jdbcUserName = jdbcUserName;
+	}
+
+	public String getJdbcPassword() {
+		return jdbcPassword;
+	}
+
+	public void setJdbcPassword(String jdbcPassword) {
+		this.jdbcPassword = jdbcPassword;
+	}
+
+	public String getJdbcUrl() {
+		return jdbcUrl;
+	}
+
+	public void setJdbcUrl(String jdbcUrl) {
+		this.jdbcUrl = jdbcUrl;
+	}
+
+
+	public DataSourceManager () {
+		Properties prop = new Properties();
+		try {
+			prop.load(this.getClass().getClassLoader().getResourceAsStream("jdbc.properties"));
+			jdbcDriver = prop.getProperty("jdbc.driver");
+			jdbcPassword = prop.getProperty("jdbc.password");
+			jdbcUserName = prop.getProperty("jdbc.username");
+			jdbcUrl = prop.getProperty("jdbc.url");
+		} catch (IOException e) {
+			// TODO Auto-generated catch blockr
+			jdbcDriver = "com.mysql.jdbc.Driver";
+			jdbcPassword = "acoolrat";
+			jdbcUserName = "root";
+			jdbcUrl = "jdbc:mysql://120.25.79.106:3306/ratfw?useUnicode=true&amp;characterEncoding=UTF-8&amp;allowMultiQueries=true";
+		}
+	}
+}

+ 755 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/DateTimeUtil.java

@@ -0,0 +1,755 @@
+package com.iamberry.wechat.tools;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+/**
+ * 
+ * @author 何秀刚
+ * Class Description:日期转换工具类
+ * Create Date:2016年5月5日
+ * Update Date:2016年5月5日
+ */
+public class DateTimeUtil {
+	public static String defaultSimpleFormater = "yyyy-MM-dd HH:mm:ss";
+
+	/**
+	 * @param day 天数(如果day数为负数,说明是此日期前的天数)
+	 * @param day
+	 * @return
+	 */
+	public static Calendar getRecentDay(int day){
+		Date date=new Date();
+		Calendar c = Calendar.getInstance();
+	    c.setTime(date);
+	    c.add(Calendar.DAY_OF_YEAR, day);
+	    return c;
+	}
+	
+	/**
+	 * mon 天数(如果mon数为负数,说明是此日期前的天数)
+	 * @param mon
+	 * @return
+	 */
+	public static Calendar getLastMon(int mon){
+		Date date=new Date();
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(date);
+		cal.add(Calendar.MONTH, mon);
+		return cal;
+	}
+
+    public static String yyyyMMDDFormat(){
+        SimpleDateFormat sdf = new SimpleDateFormat(NameUtils.DATE_FORMAT);
+        return sdf.format(new Date());
+    }
+
+    public static String timeFormat(){
+        SimpleDateFormat sdf = new SimpleDateFormat(NameUtils.TIME_FORMAT);
+        return sdf.format(new Date());
+    }
+
+    /**
+     * 获取一天的开始时间   先转换成 yyyy-MM-dd 这样的字串就只保留了天数,再转成long 类型的时间戳
+     *  本来想 time / (24*3600*1000) *24*3600*1000 这样就能把一天的时间里的多的那部分去掉,但是不知道为什么通过这样的方式总是取出来的时间是 当天的八点,如果在计算后的时间减掉
+     *  八小时 时间改变之后却又无法控制,暂时没有找到比较好的方法.
+     */
+    public static long  getDayStartTime(long time) throws ParseException{
+        Date date = new Date(time);
+        String fmt = "yyyy-MM-dd";
+        SimpleDateFormat sdf = new SimpleDateFormat(fmt);
+        return sdf.parse(sdf.format(date)).getTime();
+    }
+
+    public static Long getNowTime() {
+        Calendar todayStart = Calendar.getInstance();
+        return todayStart.getTime().getTime();
+    }
+
+    public static boolean isToday(Date date){
+        String dateStr = format(date,"yyyy-MM-dd");
+        String today = format(new Date(), "yyyy-MM-dd");
+
+        return today.equals(dateStr);
+    }
+
+    public static Date getDayBegin() throws ParseException {
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.set(Calendar.HOUR_OF_DAY, 0);
+        todayStart.set(Calendar.MINUTE, 0);
+        todayStart.set(Calendar.SECOND, 0);
+        return new Date(todayStart.getTime().getTime());
+    }
+
+    public static Date getDayEnd() throws ParseException {
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.set(Calendar.HOUR_OF_DAY, 23);
+        todayStart.set(Calendar.MINUTE, 59);
+        todayStart.set(Calendar.SECOND, 59);
+        return new Date(todayStart.getTime().getTime());
+    }
+
+    public static Long getDayBegin(String date) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat(NameUtils.DATE_FORMAT);
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.setTime(sdf.parse(date));
+        todayStart.set(Calendar.HOUR_OF_DAY, 0);
+        todayStart.set(Calendar.MINUTE, 0);
+        todayStart.set(Calendar.SECOND, 0);
+        return todayStart.getTime().getTime();
+    }
+
+    public static Long getDayEnd(String date) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat(NameUtils.DATE_FORMAT);
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.setTime(sdf.parse(date));
+        todayStart.set(Calendar.HOUR_OF_DAY, 23);
+        todayStart.set(Calendar.MINUTE, 59);
+        todayStart.set(Calendar.SECOND, 59);
+        return todayStart.getTime().getTime();
+    }
+
+    public static Long getDayBegin(Date date) throws ParseException {
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.setTime(date);
+        todayStart.set(Calendar.HOUR_OF_DAY, 0);
+        todayStart.set(Calendar.MINUTE, 0);
+        todayStart.set(Calendar.SECOND, 0);
+        return todayStart.getTime().getTime();
+    }
+
+    public static Date getDayBeginDate(Date date) throws ParseException {
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.setTime(date);
+        todayStart.set(Calendar.HOUR_OF_DAY, 0);
+        todayStart.set(Calendar.MINUTE, 0);
+        todayStart.set(Calendar.SECOND, 0);
+        return todayStart.getTime();
+    }
+
+    public static int between(Date beginDate,Date endDate){
+        long beginTime = beginDate.getTime();
+        long endTime = endDate.getTime();
+        long value = (endTime - beginTime) / (1000 * 60 * 60 * 24) + 1;
+        return (int)value;
+    }
+
+    public static Long getDayEnd(Date date) throws ParseException {
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.setTime(date);
+        todayStart.set(Calendar.HOUR_OF_DAY, 23);
+        todayStart.set(Calendar.MINUTE, 59);
+        todayStart.set(Calendar.SECOND, 59);
+        return todayStart.getTime().getTime();
+    }
+
+    public static Long getTodayBegin(){
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.set(Calendar.HOUR_OF_DAY, 0);
+        todayStart.set(Calendar.MINUTE, 0);
+        todayStart.set(Calendar.SECOND, 0);
+        return todayStart.getTime().getTime();
+    }
+
+    public static Long getTodayEndTime(){
+        Calendar yesEnd = Calendar.getInstance();
+        yesEnd.set(Calendar.HOUR_OF_DAY, 23);
+        yesEnd.set(Calendar.MINUTE, 59);
+        yesEnd.set(Calendar.SECOND, 59);
+        return yesEnd.getTime().getTime();
+    }
+
+    public static Long getYesterdayStartTime(){
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.add(Calendar.DATE, -1);
+        todayStart.set(Calendar.HOUR_OF_DAY, 0);
+        todayStart.set(Calendar.MINUTE, 0);
+        todayStart.set(Calendar.SECOND, 0);
+        return todayStart.getTime().getTime();
+    }
+
+    public static Long getYesterdayEndTime(){
+        Calendar yesEnd = Calendar.getInstance();
+        yesEnd.add(Calendar.DATE, -1);
+        yesEnd.set(Calendar.HOUR_OF_DAY, 23);
+        yesEnd.set(Calendar.MINUTE, 59);
+        yesEnd.set(Calendar.SECOND, 59);
+        return yesEnd.getTime().getTime();
+    }
+
+    public static int getMinute24(long time) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(time);
+
+        int hour = calendar.get(Calendar.HOUR_OF_DAY);
+        int minutes = calendar.get(Calendar.MINUTE);
+
+        return hour*60+minutes;
+
+    }
+
+    /**
+     * 把某种格式的字串时间转换成long类型
+     * @param
+     * @return
+     * @throws ParseException
+     */
+    public static long   pasreStringToLong(String date,String fmt) throws ParseException{
+        String fmtdefault = "yyyy-MM-dd HH:mm";
+        SimpleDateFormat sdf = null;
+        if(fmt==null || fmt.equals("")){
+            sdf = new SimpleDateFormat(fmtdefault);
+        }else{
+            sdf = new SimpleDateFormat(fmt);
+        }
+        return sdf.parse(date).getTime();
+    }
+
+    /**
+     * 默认简单日期字符串
+     */
+    public static String getDefaultSimpleFormater() {
+        return defaultSimpleFormater;
+    }
+
+    /**
+     * 设置默认简单日期格式字符串
+     * @param defaultFormatString
+     */
+    public static void setDefaultSimpleFormater(String defaultFormatString) {
+        DateTimeUtil.defaultSimpleFormater = defaultFormatString;
+    }
+
+    /**
+     * 格式化日期
+     *
+     * @param date
+     * @param formatString
+     * @return
+     */
+    public static String format(Date date, String formatString) {
+        SimpleDateFormat df = new SimpleDateFormat(formatString);
+        return df.format(date);
+    }
+
+    /**
+     * 格式化日期(使用默认格式)
+     *
+     * @param date
+     * @return
+     */
+    public static String format(Date date) {
+        return format(date, defaultSimpleFormater);
+    }
+
+    /**
+     * 转换成日期
+     *
+     * @param dateString
+     * @param formatString
+     * @return
+     */
+    public static Date parse(String dateString, String formatString) {
+        SimpleDateFormat df = new SimpleDateFormat(formatString);
+        try {
+            return df.parse(dateString);
+        } catch (ParseException e) {
+            return null;
+        }
+    }
+
+    /**
+     * 转换成日期(使用默认格式)
+     *
+     * @param dateString
+     * @return
+     */
+    public static Date parse(String dateString) {
+        return parse(dateString, defaultSimpleFormater);
+    }
+
+    /**
+     * 昨天
+     *
+     * @return
+     */
+    public static Date yesterday() {
+        return addDay(-1);
+    }
+
+    /**
+     * 明天
+     *
+     * @return
+     */
+    public static Date tomorrow() {
+        return addDay(1);
+    }
+
+    /**
+     * 现在
+     *
+     * @return
+     */
+    public static Date now() {
+        return new Date(System.currentTimeMillis());
+    }
+
+    /**
+     * 按日加
+     *
+     * @param value
+     * @return
+     */
+    public static Date addDay(int value) {
+        Calendar now = Calendar.getInstance();
+        now.add(Calendar.DAY_OF_YEAR, value);
+        return now.getTime();
+    }
+
+    /**
+     * 按日加,指定日期
+     *
+     * @param date
+     * @param value
+     * @return
+     */
+    public static Date addDay(Date date, int value) {
+        Calendar now = Calendar.getInstance();
+        now.setTime(date);
+        now.add(Calendar.DAY_OF_YEAR, value);
+        return now.getTime();
+    }
+
+    /**
+     * 按月加
+     *
+     * @param value
+     * @return
+     */
+    public static Date addMonth(int value) {
+        Calendar now = Calendar.getInstance();
+        now.add(Calendar.MONTH, value);
+        return now.getTime();
+    }
+
+    /**
+     * 按月加,指定日期
+     *
+     * @param date
+     * @param value
+     * @return
+     */
+    public static Date addMonth(Date date, int value) {
+        Calendar now = Calendar.getInstance();
+        now.setTime(date);
+        now.add(Calendar.MONTH, value);
+        return now.getTime();
+    }
+
+    /**
+     * 按年加
+     *
+     * @param value
+     * @return
+     */
+    public static Date addYear(int value) {
+        Calendar now = Calendar.getInstance();
+        now.add(Calendar.YEAR, value);
+        return now.getTime();
+    }
+
+    /**
+     * 按年加,指定日期
+     *
+     * @param date
+     * @param value
+     * @return
+     */
+    public static Date addYear(Date date, int value) {
+        Calendar now = Calendar.getInstance();
+        now.setTime(date);
+        now.add(Calendar.YEAR, value);
+        return now.getTime();
+    }
+
+    /**
+     * 按小时加
+     *
+     * @param value
+     * @return
+     */
+    public static Date addHour(int value) {
+        Calendar now = Calendar.getInstance();
+        now.add(Calendar.HOUR_OF_DAY, value);
+        return now.getTime();
+    }
+
+    /**
+     * 按小时加,指定日期
+     *
+     * @param date
+     * @param value
+     * @return
+     */
+    public static Date addHour(Date date, int value) {
+        Calendar now = Calendar.getInstance();
+        now.setTime(date);
+        now.add(Calendar.HOUR_OF_DAY, value);
+        return now.getTime();
+    }
+
+    /**
+     * 按分钟加
+     *
+     * @param value
+     * @return
+     */
+    public static Date addMinute(int value) {
+        Calendar now = Calendar.getInstance();
+        now.add(Calendar.MINUTE, value);
+        return now.getTime();
+    }
+
+    /**
+     * 按分钟加,指定日期
+     *
+     * @param date
+     * @param value
+     * @return
+     */
+    public static Date addMinute(Date date, int value) {
+        Calendar now = Calendar.getInstance();
+        now.setTime(date);
+        now.add(Calendar.MINUTE, value);
+        return now.getTime();
+    }
+
+    /**
+     * 年份
+     *
+     * @return
+     */
+    public static int year() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.YEAR);
+    }
+
+    /**
+     * 月份
+     *
+     * @return
+     */
+    public static int month() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.MONTH);
+    }
+
+    /**
+     * 日(号)
+     *
+     * @return
+     */
+    public static int day() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.DAY_OF_MONTH);
+    }
+
+    /**
+     * 小时(点)
+     *
+     * @return
+     */
+    public static int hour() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.HOUR);
+    }
+
+    /**
+     * 分钟
+     *
+     * @return
+     */
+    public static int minute() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.MINUTE);
+    }
+
+    /**
+     * 秒
+     *
+     * @return
+     */
+    public static int second() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.SECOND);
+    }
+
+    /**
+     * 星期几(礼拜几)
+     *
+     * @return
+     */
+    public static int weekday() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.DAY_OF_WEEK) - 1;
+    }
+
+    /**
+     * 是上午吗?
+     *
+     * @return
+     */
+    public static boolean isAm() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.AM_PM) == 0;
+    }
+
+    /**
+     * 是下午吗?
+     *
+     * @return
+     */
+    public static boolean isPm() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.AM_PM) == 1;
+    }
+
+    /**
+
+     * @return 当前的时间戳 yyyy-MM-dd HH:mm:ss
+
+     */
+    public static String getNowUnix() {
+
+        return dateTimeToUnix(new Date());
+
+    }
+
+    /**
+     *  获取时间戳
+     * @param date
+     *      需要转化时间戳的时间
+     * @return 时间戳
+     */
+    public static String dateTimeToUnix(Date date) {
+
+        return Long.toString(date.getTime());
+
+    }
+
+    /**
+     *  获取格式化时间字符串
+     *
+     * @return 格式化时间字符串
+     */
+    public static String formatNow() {
+        return DateTimeUtil.format(DateTimeUtil.now());
+    }
+
+    /**
+     *  获取格式化时间字符串
+     * @return 格式化时间字符串
+     */
+    public static String formatToday() {
+        return DateTimeUtil.format(DateTimeUtil.now(),NameUtils.DATE_FORMAT);
+    }
+
+    public static Timestamp getCurrentTimestamp() {
+        Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+        return currentTime;
+    }
+
+    /**
+     *  将日期转换成当前月份1号的日期
+     *
+     * @return 当前月的1号所对应的日期
+     */
+    public static Date coverToHourDate(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeInMillis(date.getTime());
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        return new Date(cal.getTimeInMillis());
+    }
+
+    /**
+     *  将日期转换成当前月份1号的日期
+     *
+     * @return 当前月的1号所对应的日期
+     */
+    public static Date getFirstDayOfYear(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(new Date());
+        // hour_of_day
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.set(Calendar.MONTH, date.getMonth());
+//        cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH));
+        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
+        return new Date(cal.getTimeInMillis());
+    }
+    
+    public static Date getLastDayOfYear(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(new Date());
+//        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.HOUR, 23);
+        cal.set(Calendar.MINUTE, 59);
+        cal.set(Calendar.SECOND, 59);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.set(Calendar.MONTH, date.getMonth());
+//        cal.set(Calendar.MONTH, cal.getActualMaximum(Calendar.MONTH));
+        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+        return new Date(cal.getTimeInMillis());
+    }
+
+    /**
+     * 创建时间: 2013-6-17 上午10:42:59
+     * 创建人:cutter.li
+     * 参数: 把从db中取出来的sql的是时间转换成date的时间
+     * 返回值: Date
+     * 方法描述 :
+     */
+    public static Date transforFromSqlToUtilDate(java.sql.Date sqlDate) {
+
+        if (null != sqlDate) {
+            return new Date(sqlDate.getTime());
+        }
+
+        return null;
+    }
+
+    /**
+     * 方法描述 :把应用系统的时间转换成sql的时间
+     */
+    public static java.sql.Date transforFromUtilToSqlDate(Date utilDate) {
+
+        if (null != utilDate) {
+            return new java.sql.Date(utilDate.getTime());
+        }
+
+        return null;
+    }
+
+    public static Date getLastWeekStart() {
+        Calendar cal = Calendar.getInstance();
+        int n = -2;
+        cal.add(Calendar.DATE, n*7);
+        cal.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
+        return cal.getTime();
+    }
+
+    public static Date getLastWeekEnd() {
+        Calendar cal = Calendar.getInstance();
+        int n = -1;
+        cal.add(Calendar.DATE, n*7);
+        cal.set(Calendar.DAY_OF_WEEK,Calendar.SUNDAY);
+        return cal.getTime();
+    }
+    
+    /** 
+     * 两个时间相差距离多少天多少小时多少分多少秒 
+     * @param Date1
+     * @param Date2
+     * @return String 返回值为:xx天xx小时xx分xx秒 
+     */  
+    public static String getDistanceTime(Date one, Date two) {  
+        long day = 0;  
+        long hour = 0;  
+        long min = 0;  
+//        long sec = 0;  
+        try {  
+            long time1 = one.getTime();  
+            long time2 = two.getTime();  
+            long diff ;  
+            if(time1<time2) {  
+                diff = time2 - time1;  
+            } else {  
+                diff = time1 - time2;  
+            }  
+            day = diff / (24 * 60 * 60 * 1000);  
+            hour = (diff / (60 * 60 * 1000) - day * 24);  
+            min = ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60);  
+           // sec = (diff/1000-day*24*60*60-hour*60*60-min*60);  
+        } catch (Exception e) {  
+            e.printStackTrace();  
+        }  
+        //return day + "天" + hour + "小时" + min + "分" + sec + "秒";  
+        return day + "天" + hour + "小时" + min + "分";
+    }
+    
+    
+    /** 
+     * 两个时间相差距离多少分钟
+     * @param Date1
+     * @param Date2
+     * @return long 返回值为:分钟数
+     */  
+    public static long getDiffTimeMinutes(Date one, Date two) {  
+     
+        long min = 0;  
+//        long sec = 0;  
+        try {  
+            long time1 = one.getTime();  
+            long time2 = two.getTime();  
+            long diff ;  
+            if(time1<time2) {  
+                diff = time2 - time1;  
+            } else {  
+                diff = time1 - time2;  
+            }  
+            min = ((diff / (60 * 1000)));  
+           // sec = (diff/1000-day*24*60*60-hour*60*60-min*60);  
+        } catch (Exception e) {  
+            e.printStackTrace();  
+        }  
+        //return day + "天" + hour + "小时" + min + "分" + sec + "秒";  
+        return  min;
+    }
+    
+    /** 
+     * 两个时间相差距离多少毫秒数
+     * @param Date1
+     * @param Date2
+     * @return String 返回值为:多少毫秒的字符串
+     */  
+    public static String getDistanceTime2(Date nowDate, Date endDate) { 
+    	 
+             long time1 = nowDate.getTime();  
+             long time2 = endDate.getTime();  
+             long diff ;  
+             diff = time2 - time1;
+            /* if(time1<time2) {  
+                 diff = time2 - time1;  
+             } else {  
+                 diff = time1 - time2;  
+             }  */
+    	return String.valueOf(diff);
+    }
+    
+    /** 
+     * 两个时间相差距离多少毫秒数
+     * @param Date1
+     * @param Date2
+     * @return String 返回值为:多少毫秒的字符串
+     */  
+    public static String getDistanceTimeMilli(Date nowDate, Date endDate) { 
+    	 
+             long time1 = nowDate.getTime();  
+             long time2 = endDate.getTime();  
+             long diff ;  
+             diff = time2 - time1;
+            /* if(time1<time2) {  
+                 diff = time2 - time1;  
+             } else {  
+                 diff = time1 - time2;  
+             }  */
+    	return String.valueOf(diff);
+    }
+}

+ 191 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/GetWxOrderno.java

@@ -0,0 +1,191 @@
+package com.iamberry.wechat.tools;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class GetWxOrderno {
+
+  /**
+   *description:获取预支付id
+   */
+  public static Object getPayNo(String url,String xmlParam){
+	try {
+		
+
+System.out.println("getPayNo start....");
+		
+		String jsonStr = HttpClient431Util.doPostContent(xmlParam, "application/json", url);
+		//判断
+	    if(jsonStr.indexOf("FAIL")!=-1){
+	    	WxPrepayIdErrorResult errorResult = (WxPrepayIdErrorResult) MessageUtil.xmlToBean(jsonStr, WxPrepayIdErrorResult.class);
+	    	
+System.out.println("getPayNo errorResult...." + jsonStr);
+	    	
+	    	return errorResult;
+	    }
+	    Map map = doXMLParse(jsonStr);
+	    String prepay_id  = (String) map.get("prepay_id");
+
+System.out.println("getPayNo end....");
+	    
+	    return prepay_id;
+	} catch (Exception e1) {
+		// TODO Auto-generated catch block
+		e1.printStackTrace();
+	}
+	return null;
+	/*  //创建连接
+	  DefaultHttpClient client = new DefaultHttpClient();
+	  //参数
+	  client.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
+	  ///请求方式
+	  HttpPost httpost= HttpClientConnectionManager.getPostMethod(url);
+	  //接受预支付id
+	  String prepay_id = "";
+     try {
+    	 //参数赋值
+		 httpost.setEntity(new StringEntity(xmlParam, "UTF-8"));
+		 //执行POST请求
+		 HttpResponse response = httpclient.execute(httpost);
+		 //解析执行接口
+	     String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8");
+	     
+	     //判断
+	    if(jsonStr.indexOf("FAIL")!=-1){
+	    	
+	    	WxPrepayIdErrorResult errorResult = (WxPrepayIdErrorResult) MessageUtil.xmlToBean(jsonStr, WxPrepayIdErrorResult.class);
+	    	return errorResult;
+	    }
+	    Map map = doXMLParse(jsonStr);
+	    prepay_id  = (String) map.get("prepay_id");
+	} catch (Exception e) {
+		e.printStackTrace();
+	}
+	return prepay_id;*/
+  }
+  
+  /**
+   *description:获取扫码支付连接
+   *@param url
+   *@param xmlParam
+   *@return
+   * @author ex_yangxiaoyi
+   * @see
+   */
+  public static String getCodeUrl(String url,String xmlParam){
+	String code_url = null;
+	try {
+		String jsonStr = HttpClient431Util.doPostContent(xmlParam, "JSON", url);
+		if(jsonStr.indexOf("FAIL")!=-1){
+	    	return code_url;
+	    }
+	    Map map = doXMLParse(jsonStr);
+	    code_url  = (String) map.get("code_url");
+	} catch (Exception e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	}
+	return code_url;
+	  /*
+	 DefaultHttpClient client = new DefaultHttpClient();
+	 client.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
+	 HttpPost httpost= HttpClientConnectionManager.getPostMethod(url);
+	 String code_url = "";
+     try {
+		 httpost.setEntity(new StringEntity(xmlParam, "UTF-8"));
+		 HttpResponse response = httpclient.execute(httpost);
+	     String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8");
+	    if(jsonStr.indexOf("FAIL")!=-1){
+	    	return code_url;
+	    }
+	    Map map = doXMLParse(jsonStr);
+	    code_url  = (String) map.get("code_url");
+	} catch (Exception e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	}
+	return code_url;*/
+  }
+  
+  
+  /**
+	 * 解析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);
+		}
+		
+		//关闭io
+		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());
+	}
+  
+}

+ 685 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/HttpClient431Util.java

@@ -0,0 +1,685 @@
+package com.iamberry.wechat.tools;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+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 java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+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.SSLContextBuilder;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.apache.log4j.Logger;
+
+import com.alibaba.dubbo.common.json.JSONObject;
+import com.google.common.base.Strings;
+
+/**
+ * @author 何秀刚
+ * Class Description:http请求封装
+ * Create Date:2016年5月3日
+ * Update Date:2016年5月3日
+ */
+public class HttpClient431Util {
+    protected static final Logger log = Logger.getLogger(HttpClient431Util.class);
+
+    private static final RequestConfig config;
+
+    /**
+     * 用于单向加密的POST请求的缓存connection
+     */
+    public static CloseableHttpClient singleSSLConnection = null;
+    
+    /**
+     * 用于缓存双向加密的请求的Connection,通用
+     */
+    public static CloseableHttpClient dualSSLConnectionJKS;
+    
+    /**
+     * 用于缓存双向加密的请求的Connection by Key,微信支付使用的
+     */
+    public static CloseableHttpClient dualSSLConnectionByKey;
+
+    static {
+        config = RequestConfig.custom().setConnectTimeout(5000).setSocketTimeout(5000).build();
+    }
+
+    public static String doGet( Map<String, String> params,String url,String cookie) throws Exception{
+        return doGet(params,url,NameUtils.DEFAULT_SEND_CHARSET,NameUtils.DEFAULT_RES_CHARSET,cookie);
+    }
+
+    public static String doGet( Map<String, String> params,String url) throws Exception{
+        return doGet(params,url,NameUtils.DEFAULT_SEND_CHARSET,NameUtils.DEFAULT_RES_CHARSET,"");
+    }
+    public static String doPost(Map<String, String> params,String url) throws Exception{
+        return doPost(params,url,NameUtils.DEFAULT_SEND_CHARSET,NameUtils.DEFAULT_RES_CHARSET);
+    }
+    public static String doDualSSLPost(Map<String, String> params,String url,String keyStorePath,String keyStorePass) throws Exception{
+        return doDualSSLPost(params, url, NameUtils.DEFAULT_SEND_CHARSET, NameUtils.DEFAULT_RES_CHARSET, keyStorePath, keyStorePass);
+    }
+    public static String doPostContent(String dataContent,String contentType,String contentCharset,String resCharset,String url) throws Exception{
+        CloseableHttpClient httpClient = getSingleSSLConnection();
+        CloseableHttpResponse response = null;
+        if(StringUtils.isBlank(url)){
+            return null;
+        }
+        try {
+            HttpPost httpPost = new HttpPost(url);
+
+            httpPost.addHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+            httpPost.addHeader("Content-Type", contentType);
+            httpPost.addHeader("Connection" , "close");
+            HttpEntity reqentity = new StringEntity(dataContent, ContentType.create(contentType, contentCharset) );
+            httpPost.setEntity(reqentity);
+
+            response = httpClient.execute(httpPost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode != 200) {
+                httpPost.abort();
+                throw new Exception("HttpClient,error status code :" + statusCode);
+            }
+            HttpEntity entity = response.getEntity();
+            String result = null;
+            if (entity != null){
+                result = EntityUtils.toString(entity, resCharset==null?NameUtils.DEFAULT_RES_CHARSET:resCharset);
+            }
+            EntityUtils.consume(entity);
+
+            return result;
+        } catch (Exception e) {
+            throw new Exception(e);
+        } finally{
+            if(response!=null)
+                try {
+                    response.close();
+                } catch (IOException e) {
+                }
+        }
+    }
+
+    public static String doPostContent(String dataContent,String contentType,String url) throws Exception{
+        CloseableHttpClient httpClient = getSingleSSLConnection();
+        CloseableHttpResponse response = null;
+        if(StringUtils.isBlank(url)){
+            return null;
+        }
+        try {
+            HttpPost httpPost = new HttpPost(url);
+
+            httpPost.addHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+            httpPost.addHeader("Content-Type", contentType);
+            httpPost.addHeader("Connection" , "close");
+            HttpEntity reqentity = new StringEntity(dataContent, ContentType.create(contentType, NameUtils.DEFAULT_RES_CHARSET) );
+            httpPost.setEntity(reqentity);
+
+            response = httpClient.execute(httpPost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode != 200) {
+                httpPost.abort();
+                throw new Exception("HttpClient,error status code :" + statusCode);
+            }
+            HttpEntity entity = response.getEntity();
+            String result = null;
+            if (entity != null){
+                result = EntityUtils.toString(entity, NameUtils.DEFAULT_RES_CHARSET);
+            }
+            EntityUtils.consume(entity);
+
+            return result;
+        } catch (Exception e) {
+            throw new Exception(e);
+        } finally{
+            if(response!=null)
+                try {
+                    response.close();
+                } catch (IOException e) {
+                }
+        }
+    }
+    /**
+     * HTTP Get 获取内容
+     * @param params 请求的参数
+     * @param url  请求的url地址 ?之前的地址
+     * @param reqCharset    编码格式
+     * @param resCharset    编码格式
+     * @return    页面内容
+     * @throws Exception 
+     */
+    public static String doGet(Map<String,String> params,String url,String reqCharset,String resCharset,String cookie) throws Exception{
+        CloseableHttpClient httpClient = getSingleSSLConnection();
+        CloseableHttpResponse response = null;
+        if(StringUtils.isBlank(url)){
+            return null;
+        }
+        try {
+            if(params != null && !params.isEmpty()){
+                List<NameValuePair> pairs = new ArrayList<NameValuePair>(params.size());
+                for(Map.Entry<String,String> entry : params.entrySet()){
+                    String value = entry.getValue();
+                    if(value != null){
+                        pairs.add(new BasicNameValuePair(entry.getKey(),value));
+                    }
+                }
+                url += "?" + EntityUtils.toString(new UrlEncodedFormEntity(pairs, reqCharset==null?NameUtils.DEFAULT_SEND_CHARSET:reqCharset));
+            }
+            HttpGet httpGet = new HttpGet(url);
+            httpGet.addHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+            httpGet.addHeader("Connection" , "close");
+            if (!Strings.isNullOrEmpty(cookie)){
+                httpGet.setHeader("Cookie", cookie);
+            }
+
+            response = httpClient.execute(httpGet);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode != 200) {
+                httpGet.abort();
+                throw new Exception("HttpClient,error status code :" + statusCode);
+            }
+            HttpEntity entity = response.getEntity();
+            String result = null;
+            if (entity != null){
+                result = EntityUtils.toString(entity, resCharset==null ? NameUtils.DEFAULT_RES_CHARSET:resCharset);
+            }
+            EntityUtils.consume(entity);
+            response.close();
+            return result;
+        } catch (Exception e) {
+            throw new Exception(e);
+        } finally{
+            if(response!=null)
+                try {
+                    response.close();
+                } catch (IOException e) {
+                	e.printStackTrace();
+                }
+        }
+    }
+    
+    /**
+     * 下载远程文件
+     * @param url
+     * @param path
+     * @return
+     * @throws Exception
+     */
+    public static boolean downloadFile(String url, String path) throws Exception {
+
+        CloseableHttpClient httpClient = getSingleSSLConnection();
+        CloseableHttpResponse response = null;
+        if(StringUtils.isBlank(url)){
+            return false;
+        }
+        try {
+            HttpGet httpGet = new HttpGet(url);
+            httpGet.addHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36");
+            httpGet.addHeader("Connection" , "close");
+            response = httpClient.execute(httpGet);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode != 200) {
+                httpGet.abort();
+                throw new Exception("HttpClient,error status code :" + statusCode);
+            }
+            byte[] data = EntityUtils.toByteArray(response.getEntity()); 
+            try {
+            	// 保存文件
+            	FileUtils.writeByteArrayToFile(new File(path), data);
+            } catch (Exception e) {  
+                log.error("save File Error, path = " + path + ",url=" + url, e);  
+            } finally {  
+                try {
+                } catch (Exception e) {
+                    log.error("finally BufferedOutputStream shutdown close", e);  
+                }  
+            }  
+            EntityUtils.consume(response.getEntity());
+            response.close();
+            return true;
+        } catch (Exception e) {
+        	log.error("htt client error.", e);  
+        } finally{
+            if(response!=null)
+                try {
+                    response.close();
+                } catch (IOException e) {
+                }
+        }
+        return false;
+    }
+
+    /**
+     * HTTP Post 获取内容
+     * @param params 请求的参数
+     * @param url  请求的url地址 ?之前的地址
+     * @param reqCharset    编码格式
+     * @param resCharset    编码格式
+     * @return    页面内容
+     */
+    public static String doPost(Map<String,String> params,String url,String reqCharset,String resCharset) throws Exception{
+        CloseableHttpClient httpClient = getSingleSSLConnection();
+        CloseableHttpResponse response = null;
+        if(StringUtils.isBlank(url)){
+            return null;
+        }
+        try {
+            List<NameValuePair> pairs = null;
+            if(params != null && !params.isEmpty()){
+                pairs = new ArrayList<NameValuePair>(params.size());
+                for(Map.Entry<String,String> entry : params.entrySet()){
+                    String value = entry.getValue();
+                    if(value != null){
+                        pairs.add(new BasicNameValuePair(entry.getKey(),value));
+                    }
+                }
+            }
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.addHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+            httpPost.addHeader("Connection" , "close");
+            if(pairs != null && pairs.size() > 0){
+                httpPost.setEntity(new UrlEncodedFormEntity(pairs,reqCharset==null?NameUtils.DEFAULT_SEND_CHARSET:reqCharset));
+            }
+            response = httpClient.execute(httpPost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode != 200) {
+                httpPost.abort();
+                throw new Exception("HttpClient,error status code :" + statusCode);
+            }
+            HttpEntity entity = response.getEntity();
+            String result = null;
+            if (entity != null){
+                result = EntityUtils.toString(entity, resCharset==null?NameUtils.DEFAULT_RES_CHARSET:resCharset);
+            }
+            EntityUtils.consume(entity);
+            response.close();
+            return result;
+        }
+        catch (Exception e) {
+            throw e;
+        }finally{
+            if(response!=null)
+                try {
+                    response.close();
+                } catch (IOException e) {
+                }
+        }
+    }
+
+    /**
+     * HTTP Post 获取内容
+     * @param params 请求的参数
+     * @param url  请求的url地址 ?之前的地址
+     * @param reqCharset    编码格式
+     * @param resCharset    编码格式
+     * @return    页面内容
+     */
+    public static String doPost(Map<String,String> params,String url,String reqCharset,String resCharset,String contentType) throws Exception{
+        CloseableHttpClient httpClient = getSingleSSLConnection();
+        CloseableHttpResponse response = null;
+        if(StringUtils.isBlank(url)){
+            return null;
+        }
+        try {
+            List<NameValuePair> pairs = null;
+            if(params != null && !params.isEmpty()){
+                pairs = new ArrayList<NameValuePair>(params.size());
+                for(Map.Entry<String,String> entry : params.entrySet()){
+                    String value = entry.getValue();
+                    if(value != null){
+                        pairs.add(new BasicNameValuePair(entry.getKey(),value));
+                    }
+                }
+            }
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.addHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+            httpPost.addHeader("Content-Type",contentType);
+            httpPost.addHeader("Connection" , "close");
+            if(pairs != null && pairs.size() > 0){
+                httpPost.setEntity(new UrlEncodedFormEntity(pairs,reqCharset==null?NameUtils.DEFAULT_SEND_CHARSET:reqCharset));
+            }
+            response = httpClient.execute(httpPost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode != 200) {
+                httpPost.abort();
+                throw new Exception("HttpClient,error status code :" + statusCode);
+            }
+            HttpEntity entity = response.getEntity();
+            String result = null;
+            if (entity != null){
+                result = EntityUtils.toString(entity, resCharset==null?NameUtils.DEFAULT_RES_CHARSET:resCharset);
+            }
+            EntityUtils.consume(entity);
+            response.close();
+            return result;
+        } catch (Exception e) {
+            throw new Exception(e);
+        } finally{
+            if(response!=null)
+                try {
+                    response.close();
+                } catch (IOException e) {
+                }
+        }
+    }
+
+    public static String doPost(JSONObject jsonObject, String url, String resCharset) throws Exception{
+        CloseableHttpClient httpClient = getSingleSSLConnection();
+        CloseableHttpResponse response = null;
+        if(StringUtils.isBlank(url)){
+            return null;
+        }
+        try {
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.addHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+            httpPost.addHeader("Content-Type","JSON");
+            httpPost.addHeader("Connection" , "close");
+            StringEntity myEntity = new StringEntity(jsonObject.toString(), "UTF-8");
+            httpPost.setEntity(myEntity);
+            response = httpClient.execute(httpPost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode != 200) {
+                httpPost.abort();
+                throw new Exception("HttpClient,error status code :" + statusCode);
+            }
+            HttpEntity entity = response.getEntity();
+            String result = null;
+            if (entity != null){
+                result = EntityUtils.toString(entity, resCharset==null?NameUtils.DEFAULT_RES_CHARSET:resCharset);
+            }
+            EntityUtils.consume(entity);
+            response.close();
+            return result;
+        } catch (Exception e) {
+            throw new Exception(e);
+        } finally{
+            if(response!=null)
+                try {
+                    response.close();
+                } catch (IOException e) {
+                }
+        }
+    }
+
+    /**
+     * HTTP Post 获取内容
+     * @param params 请求的参数
+     * @param url  请求的url地址 ?之前的地址
+     * @param reqCharset    编码格式
+     * @param resCharset    编码格式
+     * @return    页面内容
+     * @throws Exception 
+     */
+    public static String doDualSSLPost(Map<String,String> params,String url,String reqCharset,String resCharset,String keyStorePath,String keyStorePass) throws Exception{
+        CloseableHttpClient httpClient = getDualSSLConnection(keyStorePath,keyStorePass);
+        CloseableHttpResponse response = null;
+        if(StringUtils.isBlank(url)){
+            return null;
+        }
+        try {
+            List<NameValuePair> pairs = null;
+            if(params != null && !params.isEmpty()){
+                pairs = new ArrayList<NameValuePair>(params.size());
+                for(Map.Entry<String,String> entry : params.entrySet()){
+                    String value = entry.getValue();
+                    if(value != null){
+                        pairs.add(new BasicNameValuePair(entry.getKey(),value));
+                    }
+                }
+            }
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.addHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+            httpPost.addHeader("Connection" , "close");
+            if(pairs != null && pairs.size() > 0){
+                httpPost.setEntity(new UrlEncodedFormEntity(pairs,reqCharset==null?NameUtils.DEFAULT_SEND_CHARSET:reqCharset));
+            }
+            response = httpClient.execute(httpPost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode != 200) {
+                httpPost.abort();
+                throw new Exception("HttpClient,error status code :" + statusCode);
+            }
+            HttpEntity entity = response.getEntity();
+            String result = null;
+            if (entity != null){
+                result = EntityUtils.toString(entity, resCharset==null?NameUtils.DEFAULT_RES_CHARSET:resCharset);
+            }
+            EntityUtils.consume(entity);
+            response.close();
+            return result;
+        } catch (Exception e) {
+            throw new Exception(e);
+        } finally{
+            if(response!=null)
+                try {
+                    response.close();
+                } catch (IOException e) {
+                }
+        }
+    }
+    
+    /**
+     * 创建双向ssl的连接
+     * @param keyStorePath
+     * @param keyStorePass
+     * @return
+     * @throws Exception
+     */
+    private static CloseableHttpClient getDualSSLConnection(String keyStorePath,String keyStorePass) throws Exception{
+    	
+    	if (HttpClient431Util.dualSSLConnectionJKS != null) {
+    		return HttpClient431Util.dualSSLConnectionJKS;
+    	}
+    	
+        CloseableHttpClient httpClient = null;
+        try {
+            File file = new File(keyStorePath);
+            URL sslJksUrl = file.toURI().toURL();
+            KeyStore keyStore  = KeyStore.getInstance("jks");
+            InputStream is = null;
+            try {
+                is = sslJksUrl.openStream();
+                keyStore.load(is, keyStorePass != null ? keyStorePass.toCharArray(): null);
+            } finally {
+                if (is != null) is.close();
+            }
+            SSLContext sslContext = new SSLContextBuilder().loadKeyMaterial(keyStore, keyStorePass != null ? keyStorePass.toCharArray(): null)
+                    .loadTrustMaterial(null,new TrustStrategy() {
+                        @Override
+                        public boolean isTrusted(X509Certificate[] paramArrayOfX509Certificate, String paramString) throws CertificateException {return true;}
+                    })
+                    .build();
+            SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext,SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+            httpClient =  HttpClients.custom().setSSLSocketFactory(sslsf).setDefaultRequestConfig(config).build();
+            HttpClient431Util.dualSSLConnectionJKS = httpClient;
+            return httpClient;
+        } catch (Exception e) {
+            throw new Exception(e);
+        }
+    }
+    
+
+    /**
+     * 创建双向ssl的连接
+     * @param keyStorePath
+     * @param keyStorePass
+     * @return
+     * @throws Exception
+     */
+    private static CloseableHttpClient getSendDualSSLConnection(String keyStorePath,String keyStorePass) throws Exception{
+    	if (HttpClient431Util.dualSSLConnectionByKey != null) {
+    		return HttpClient431Util.dualSSLConnectionByKey;
+    	}
+        CloseableHttpClient httpClient = null;
+        try {
+            InputStream is = null;
+            try {
+                is = StaticInfo.sslJksUrl.openStream();
+                StaticInfo.keyStore.load(is, keyStorePass != null ? keyStorePass.toCharArray(): null);
+            } finally {
+                if (is != null) is.close();
+            }
+            SSLContext sslContext = new SSLContextBuilder().loadKeyMaterial(StaticInfo.keyStore, keyStorePass != null ? keyStorePass.toCharArray(): null)
+                    .loadTrustMaterial(null,new TrustStrategy() {
+                        @Override
+                        public boolean isTrusted(X509Certificate[] paramArrayOfX509Certificate, String paramString) throws CertificateException {return true;}
+                    }).build();
+            SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext,SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+            httpClient =  HttpClients.custom().setSSLSocketFactory(sslsf).setDefaultRequestConfig(config).build();
+            HttpClient431Util.dualSSLConnectionByKey = httpClient;
+            return httpClient;
+        } catch (Exception e) {
+            throw new Exception(e);
+        }
+    }
+
+    /**
+     * 获取一个SSL加密的socket
+     */
+    public static CloseableHttpClient getHttpClient() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException, UnrecoverableKeyException {
+    	KeyStore keyStore = KeyStore.getInstance("PKCS12");
+		InputStream instream = MoneyUtils.class.getResourceAsStream("/apiclient_cert.p12");
+		try {
+			keyStore.load(instream, NameUtils.KEYSTORE_PASSWORD.toCharArray());// 这里写密码..默认是你的MCHID
+		} finally {
+			instream.close();
+		}
+		SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, NameUtils.KEYSTORE_PASSWORD.toCharArray()).build();
+		SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] { "TLSv1" }, null, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+		return HttpClients.custom().setSSLSocketFactory(sslsf).setDefaultRequestConfig(config).build();
+    }
+    
+
+    /**
+     * HTTP Post 获取内容
+     * @param params 请求的参数
+     * @param url  请求的url地址 ?之前的地址
+     * @param reqCharset    编码格式
+     * @param resCharset    编码格式
+     * @return    页面内容
+     */
+    public static String doSendWechatRedPack(Map<String, Object> params,String url,String reqCharset,String resCharset,String contentType) throws Exception{
+        CloseableHttpClient httpClient = getSendDualSSLConnection(StaticInfo.getResourcekey(), NameUtils.KEYSTORE_PASSWORD);
+        CloseableHttpResponse response = null;
+        if(StringUtils.isBlank(url)){
+            return null;
+        }
+        try {
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.addHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+            httpPost.addHeader("Content-Type",contentType);
+            httpPost.addHeader("Connection" , "close");
+            httpPost.setEntity(new StringEntity(MoneyUtils.createXML(params), "UTF-8"));
+            response = httpClient.execute(httpPost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode != 200) {
+                httpPost.abort();
+                throw new Exception("HttpClient,error status code :" + statusCode);
+            }
+            HttpEntity entity = response.getEntity();
+            String result = null;
+            if (entity != null){
+                result = EntityUtils.toString(entity, resCharset==null?NameUtils.DEFAULT_RES_CHARSET:resCharset);
+            }
+            EntityUtils.consume(entity);
+            response.close();
+            return result;
+        } catch (Exception e) {
+            throw new Exception(e);
+        } finally{
+            if(response!=null)
+	            try {
+	                response.close();
+	            } catch (IOException e) {
+	            }
+        }
+    }
+    
+    /**
+     * 创建单向ssl的连接
+     * @return
+     * @throws Exception
+     */
+    private static CloseableHttpClient getSingleSSLConnection() throws Exception{
+    	if (singleSSLConnection != null) {
+    		return singleSSLConnection;
+    	}
+        CloseableHttpClient httpClient = null;
+        try {
+            SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null,new TrustStrategy() {
+                @Override
+                public boolean isTrusted(X509Certificate[] paramArrayOfX509Certificate, String paramString) throws CertificateException {
+                	return true;
+                }
+            }).build();
+            SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
+            httpClient =  HttpClients.custom().setSSLSocketFactory(sslsf).setDefaultRequestConfig(config).build();
+            HttpClient431Util.singleSSLConnection = httpClient;
+            return httpClient;
+        } catch (Exception e) {
+            throw new Exception(e);
+        }
+
+    }
+
+    public static String sendXmlData(String url,Map<String,String> params) throws Exception{
+        HttpClient client = HttpClients.createDefault();
+//      client.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS,true);
+        List<NameValuePair> pairs = null;
+        if(params != null && !params.isEmpty()){
+            pairs = new ArrayList<NameValuePair>(params.size());
+            for(Map.Entry<String,String> entry : params.entrySet()){
+                String value = entry.getValue();
+                if(value != null){
+                    pairs.add(new BasicNameValuePair(entry.getKey(),value));
+                }
+            }
+        }
+        HttpPost post = new HttpPost(url);
+
+        post.setHeader("Content-Type","text/xml;charset=GB2312");
+        post.setEntity(new UrlEncodedFormEntity(pairs,"GB2312"));
+        HttpResponse response = client.execute(post);
+        Integer code = response.getStatusLine().getStatusCode();
+        if(code == 200){
+            String result = EntityUtils.toString(response.getEntity(), "GB18030");
+            EntityUtils.consume(response.getEntity());
+            post.abort();
+            return result;
+        }
+        return "";
+    }
+
+    public static void main(String[] args) throws Exception {
+    	long start = System.currentTimeMillis();
+    	boolean b = downloadFile("https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQHT8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xLzgwamFXRURsc3AzTE1pQnoxbUFfAAIEkhQsVwMEAAAAAA%3D%3D", "D://abcdefgj.png");
+    	long end = System.currentTimeMillis();
+    	System.out.println(b + "," + (end - start));
+    }
+}

+ 229 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ImageUtils.java

@@ -0,0 +1,229 @@
+package com.iamberry.wechat.tools;
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.geom.AffineTransform;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import com.mortennobel.imagescaling.ResampleFilters;
+import com.mortennobel.imagescaling.ResampleOp;
+
+/**
+ * 图片工具类, 图片水印,文字水印,缩放,补白等 <br>
+ * 注意: 如果上传了图片,一定要使用此类对图片进行水印,防止恶意图片,或者对图片进行缩放
+ * @author 何秀刚
+ */
+public final class ImageUtils {
+    
+    private ImageUtils(){}
+    /**
+	 * 添加图片水印, 后期可以将图片水印居于右下角
+	 * @param targetImg 目标图片路径,如:C://myPictrue//1.jpg
+	 * @param waterImg  水印图片路径,如:C://myPictrue//logo.png
+	 * @param x 水印图片距离目标图片左侧的偏移量,如果x<0, 则在正中间
+	 * @param y 水印图片距离目标图片上侧的偏移量,如果y<0, 则在正中间
+	 * @param alpha 透明度(0.0 -- 1.0, 0.0为完全透明,1.0为完全不透明)
+	*/
+    public final static void pressImage(String targetImg, String waterImg, int x, int y, float alpha) {
+            try {
+                File file = new File(targetImg);
+                Image image = ImageIO.read(file);
+                int width = image.getWidth(null);
+                int height = image.getHeight(null);
+                BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+                Graphics2D g = bufferedImage.createGraphics();
+                g.drawImage(image, 0, 0, width, height, null);
+            
+                Image waterImage = ImageIO.read(new File(waterImg));    // 水印文件
+                int width_1 = waterImage.getWidth(null);
+                int height_1 = waterImage.getHeight(null);
+                g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
+                
+                int widthDiff = width - width_1;
+                int heightDiff = height - height_1;
+                if(x < 0){
+                    x = widthDiff / 2;
+                }else if(x > widthDiff){
+                    x = widthDiff;
+                }
+                if(y < 0){
+                    y = heightDiff / 2;
+                }else if(y > heightDiff){
+                    y = heightDiff;
+                }
+                g.drawImage(waterImage, x, y, width_1, height_1, null); // 水印文件结束
+                g.dispose();
+                ImageIO.write(bufferedImage, NameUtils.PICTRUE_FORMATE_JPG, file);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+    }
+
+    /**
+     * 添加文字水印
+     * @param targetImg 目标图片路径,如:C://myPictrue//1.jpg
+     * @param pressText 水印文字, 如:中国证券网
+     * @param x 水印文字距离目标图片左侧的偏移量,如果x<0, 则在正中间
+     * @param y 水印文字距离目标图片上侧的偏移量,如果y<0, 则在正中间
+     */
+    public static void press(String targetImg, String srcImg, String pressText, int x, int y, int imgx, int imgy) {
+        try {
+        	
+        	String fontName = "宋体";
+        	int fontStyle = Font.BOLD;
+        	int fontSize = 25;
+        	Color color = Color.RED;
+        	float alpha = 1;
+        	
+        	/**
+        	 * 水印文字
+        	 */
+            File file = new File(targetImg);
+            Image image = ImageIO.read(file);
+            int width = image.getWidth(null);
+            int height = image.getHeight(null);
+            BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+            Graphics2D g = bufferedImage.createGraphics();
+            g.drawImage(image, 0, 0, width, height, null);
+            g.setFont(new Font(fontName, fontStyle, fontSize));
+            g.setColor(color);
+            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
+            
+            int width_1 = fontSize * getLength(pressText);
+            int height_1 = fontSize;
+            int widthDiff = width - width_1;
+            int heightDiff = height - height_1;
+            if(x < 0){
+                x = widthDiff / 2;
+            }else if(x > widthDiff){
+                x = widthDiff;
+            }
+            if(y < 0){
+                y = heightDiff / 2;
+            }else if(y > heightDiff){
+                y = heightDiff;
+            }
+            g.drawString(pressText, x, y + height_1);
+            
+            /**
+             * 水印图片
+             */
+            Image tarImage = ImageIO.read(new File(srcImg));
+            g.drawImage(tarImage, imgx, imgy, tarImage.getWidth(null), tarImage.getHeight(null), null); // 水印文件结束
+            
+            g.dispose();
+            ImageIO.write(bufferedImage, targetImg.substring(targetImg.lastIndexOf(".") + 1), file);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+    /**
+     * 获取字符长度,一个汉字作为 1 个字符, 一个英文字母作为 0.5 个字符
+     * @param text
+     * @return 字符长度,如:text="中国",返回 2;text="test",返回 2;text="中国ABC",返回 4.
+     */
+    public static int getLength(String text) {
+        int textLength = text.length();
+        int length = textLength;
+        for (int i = 0; i < textLength; i++) {
+            if (String.valueOf(text.charAt(i)).getBytes().length > 1) {
+                length++;
+            }
+        }
+        return (length % 2 == 0) ? length / 2 : length / 2 + 1;
+    }
+
+    /**
+     * 图片缩放
+     * @param filePath 图片路径
+     * @param height 高度
+     * @param width 宽度
+     * @param bb 比例不对时是否需要补白
+     */
+    public static void resize(String filePath, int height, int width, boolean bb) {
+        try {
+            double ratio = 0; //缩放比例    
+            File f = new File(filePath);   
+            BufferedImage bi = ImageIO.read(f);   
+            Image itemp = bi.getScaledInstance(width, height, BufferedImage.SCALE_SMOOTH);   
+            //计算比例   
+            if ((bi.getHeight() > height) || (bi.getWidth() > width)) {   
+                if (bi.getHeight() > bi.getWidth()) {   
+                    ratio = (new Integer(height)).doubleValue() / bi.getHeight();   
+                } else {   
+                    ratio = (new Integer(width)).doubleValue() / bi.getWidth();   
+                }   
+                AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(ratio, ratio), null);   
+                itemp = op.filter(bi, null);   
+            }   
+            if (bb) {   
+                BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);   
+                Graphics2D g = image.createGraphics();   
+                g.setColor(Color.white);   
+                g.fillRect(0, 0, width, height);   
+                if (width == itemp.getWidth(null))   
+                    g.drawImage(itemp, 0, (height - itemp.getHeight(null)) / 2, itemp.getWidth(null), itemp.getHeight(null), Color.white, null);   
+                else  
+                    g.drawImage(itemp, (width - itemp.getWidth(null)) / 2, 0, itemp.getWidth(null), itemp.getHeight(null), Color.white, null);   
+                g.dispose();   
+                itemp = image;   
+            }
+            ImageIO.write((BufferedImage) itemp, "jpg", f);   
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    
+    /**
+     * 修改图片大小类, 默认修改为0.6, 凡是设计上传文件的地方,必须使用!
+     * @param srcFilePath 图片资源位置
+     * @return
+     */
+    public static boolean reSize(String srcFilePath) {
+    	try {
+    		File file = new File(srcFilePath );
+			BufferedImage sourceImage = ImageIO.read(file);
+            int newwidth = (int) (sourceImage.getWidth() * 0.99);
+            double newheight = (int) sourceImage.getHeight() * 0.99;
+            ResampleOp resizeOp = new ResampleOp(newwidth, (int) newheight);
+            resizeOp.setFilter(ResampleFilters.getTriangleFilter());
+            BufferedImage resizedImage = resizeOp.filter(sourceImage, null);
+            ImageIO.write(resizedImage, srcFilePath.substring(srcFilePath.lastIndexOf(".") + 1), file);
+            return true;
+        } catch (Exception e) {
+        	return false;
+        }
+    }
+    public static boolean reSize(String srcFilePath, double width, double height) {
+    	try {
+    		File file = new File(srcFilePath );
+			BufferedImage sourceImage = ImageIO.read(file);
+            int newwidth = (int) (sourceImage.getWidth() * width);
+            double newheight = (int) sourceImage.getHeight() * height;
+            ResampleOp resizeOp = new ResampleOp(newwidth, (int) newheight);
+            resizeOp.setFilter(ResampleFilters.getTriangleFilter());
+            BufferedImage resizedImage = resizeOp.filter(sourceImage, null);
+            ImageIO.write(resizedImage, srcFilePath.substring(srcFilePath.lastIndexOf(".") + 1), file);
+            return true;
+        } catch (Exception e) {
+        	return false;
+        }
+    }
+    public static void main(String[] args) throws IOException {
+    	long l = System.currentTimeMillis();
+//    	reSize("D://abcdefgj1.jpg", 0.5, 0.5);
+//    	pressImage("D://Test.jpg", "D://test111.jpg", 350, 500, 1);
+    	// 设置水印
+    	press("D://Test.jpg", "D://test111.jpg", "深圳爱贝源科技有限公司", 350, 100, 350, 500);
+    	System.out.println(System.currentTimeMillis() - l);
+        // resize("C://pic//4.jpg", 1000, 500, true);
+    }
+}

+ 33 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/IpAddressUtil.java

@@ -0,0 +1,33 @@
+package com.iamberry.wechat.tools;
+
+import javax.servlet.http.HttpServletRequest;
+/**
+ * @author:何秀刚
+ * @description: ip地址工具类
+ * @createDate:2016年5月26日
+ */
+public class IpAddressUtil {
+
+
+	/**
+	 * 获取ip地址, 若多级代理,第一个IP为客户端真实IP,多个IP按照','分割
+	 * @param request
+	 * @return
+	 */
+	public static String getIpAddr(HttpServletRequest request) {
+		String ip = request.getHeader("x-forwarded-for");
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+			ip = request.getHeader("Proxy-Client-IP");
+		}
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+			ip = request.getHeader("WL-Proxy-Client-IP");
+		}
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+			ip = request.getRemoteAddr();
+		}
+		if (ip != null && ip.indexOf(",") != -1) {
+			ip = ip.split(",")[0];
+		}
+		return ip;
+	}
+}

+ 37 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/MD5Util.java

@@ -0,0 +1,37 @@
+package com.iamberry.wechat.tools;
+import java.security.MessageDigest;
+/**
+ * description : 微信红包MD5加密类
+ * @author 何秀刚
+ * create date:2016年3月10日
+ */
+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" };
+}

+ 79 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/MessageUtil.java

@@ -0,0 +1,79 @@
+package com.iamberry.wechat.tools;
+
+import java.io.IOException;
+
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.DomDriver;
+
+
+public class MessageUtil {
+	private final static XStream stream = new XStream(new DomDriver());
+	
+	/**
+	 * 将一个XML格式的字符串转换为Java对象
+	 * @param xml
+	 * @param classT
+	 * @return
+	 * @throws ClassNotFoundException
+	 * @throws IllegalAccessException 
+	 * @throws InstantiationException 
+	 */
+	public static <T> Object xmlToBean(String xml, Class<T> classT) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+		//创建XStream对象
+//		XStream stream = new XStream(new DomDriver());
+		//替换XML中的所有xml标签
+		xml = xml.replaceAll("xml", classT.getName().toString());
+		//通过Java反射创建对象
+		Object object = classT.newInstance();
+		//解析
+		object = stream.fromXML(xml, object);
+		//返回
+		return object;
+	}
+	
+	/**
+	 * 将一个对象转换为一个XML格式的字符串
+	 * @param object
+	 * @return
+	 */
+	public static String beanToXML(Object object) {
+		stream.alias("xml", object.getClass());
+		return stream.toXML(object);
+	}
+	
+	/**
+	 * 转换JSON格式字符串为Bean
+	 * @param json
+	 * @param object
+	 * @return
+	 * @throws IllegalAccessException 
+	 * @throws InstantiationException 
+	 */
+	@SuppressWarnings("unchecked")
+	public static Object jsonToBean(String json, @SuppressWarnings("rawtypes") Class classType) throws InstantiationException, IllegalAccessException {
+		Gson gson = new Gson();
+		//JsonElement root = gson.toJsonTree(str);
+		Object object = classType.newInstance();
+		object = gson.fromJson(json, classType);
+		return object;
+	}
+	
+	/**
+	 * 将一个Object对象转换为一个String字符串
+	 * @param object
+	 * @return
+	 * @throws IOException 
+	 * @throws JsonMappingException 
+	 * @throws JsonGenerationException 
+	 */
+	public static String objectToString(Object object) throws JsonGenerationException, JsonMappingException, IOException {
+		// 对象转换字符串
+		ObjectMapper objectMapper = new ObjectMapper();
+		String resultStr = objectMapper.writeValueAsString(object);
+		return resultStr;
+	}
+}

+ 245 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/MoneyUtils.java

@@ -0,0 +1,245 @@
+package com.iamberry.wechat.tools;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.nio.charset.Charset;
+import java.security.KeyStore;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import javax.net.ssl.SSLContext;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+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.HttpClients;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
+import org.apache.http.util.CharArrayBuffer;
+import org.apache.http.util.EntityUtils;
+import org.springframework.stereotype.Component;
+
+/**
+ * description : 微信红包工具类
+ * 
+ * @author 何秀刚 create date:2016年3月10日
+ */
+@Component
+public class MoneyUtils {
+	public static String appid = NameUtils.appId;// 应用ID
+	public static String appsecret = NameUtils.appSecret;// 应用密钥
+	public static String partner = NameUtils.partner;// 微信支付商户号
+	public static String partnerkey = NameUtils.partnerkey;// 财付通初始密码
+	public static String charset = NameUtils.charset;
+
+	/**
+	 * 随机16为数值
+	 * 
+	 * @return
+	 */
+	public String buildRandom() {
+		String currTime = TenpayUtil.getCurrTime();
+		String strTime = currTime.substring(8, currTime.length());
+		int num = 1;
+		double random = Math.random();
+		if (random < 0.1) {
+			random = random + 0.1;
+		}
+		for (int i = 0; i < 4; i++) {
+			num = num * 10;
+		}
+		return (int) ((random * num)) + strTime;
+	}
+
+	/**
+	 * 获取ip
+	 * 
+	 * @param request
+	 * @return
+	 */
+	public String getIpAddr(HttpServletRequest request) {
+		String ip = request.getHeader("x-forwarded-for");
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+			ip = request.getHeader("PRoxy-Client-IP");
+		}
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+			ip = request.getHeader("WL-Proxy-Client-IP");
+		}
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+			ip = request.getRemoteAddr();
+		}
+		if (null == ip) {
+			ip = "";
+		}
+		if (StringUtils.isNotEmpty(ip)) {
+			String[] ipArr = ip.split(",");
+			if (ipArr.length > 1) {
+				ip = ipArr[0];
+			}
+		}
+		return ip;
+	}
+
+	/**
+	 * 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。 sign
+	 */
+	public String createSign(Map<String, Object> map) {
+		SortedMap<String, String> packageParams = new TreeMap<String, String>();
+		for (Map.Entry<String, Object> m : map.entrySet()) {
+			packageParams.put(m.getKey(), m.getValue().toString());
+		}
+		StringBuffer sb = new StringBuffer();
+		Set<?> es = packageParams.entrySet();
+		Iterator<?> it = es.iterator();
+		while (it.hasNext()) {
+			@SuppressWarnings("rawtypes")
+			Map.Entry entry = (Map.Entry) it.next();
+			String k = (String) entry.getKey();
+			String v = (String) entry.getValue();
+			if (!StringUtils.isEmpty(v) && !"sign".equals(k)
+					&& !"key".equals(k)) {
+				sb.append(k + "=" + v + "&");
+			}
+		}
+		sb.append("key=" + partnerkey);
+		String sign = MD5Util.MD5Encode(sb.toString(), charset).toUpperCase();
+		return sign;
+	}
+
+	/**
+	 * 获取订单号
+	 */
+	public String getOrderNo() {
+		String order = partner
+				+ new SimpleDateFormat("yyyyMMdd").format(new Date());
+		Random r = new Random();
+		for (int i = 0; i < 10; i++) {
+			order += r.nextInt(9);
+		}
+		return order;
+	}
+	
+
+	/**
+	 * 发生微信红包
+	 */
+	public String doSendMoney(String url, Map<String, Object> data) throws Exception {
+		try {
+			return HttpClient431Util.doSendWechatRedPack(data, url, null, null, null);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	/**
+	 * 发生微信红包
+	 */
+	public String doSendMoney(String url, String data) throws Exception {
+		KeyStore keyStore = KeyStore.getInstance("PKCS12");
+		// FileInputStream instream = new FileInputStream(new
+		// File(KEYSTORE_FILE));//P12文件目录
+		InputStream instream = MoneyUtils.class.getResourceAsStream("/apiclient_cert.p12");
+		try {
+			keyStore.load(instream, NameUtils.KEYSTORE_PASSWORD.toCharArray());// 这里写密码..默认是你的MCHID
+		} finally {
+			instream.close();
+		}
+		// Trust own CA and all self-signed certs
+		SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, NameUtils.KEYSTORE_PASSWORD.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();
+		try {
+			HttpPost httpost = new HttpPost(url); // 设置响应头信息
+			httpost.addHeader("Connection", "keep-alive");
+			httpost.addHeader("Accept", "*/*");
+			httpost.addHeader("Content-Type",
+					"application/x-www-form-urlencoded; charset=UTF-8");
+			httpost.addHeader("Host", "api.mch.weixin.qq.com");
+			httpost.addHeader("X-Requested-With", "XMLHttpRequest");
+			httpost.addHeader("Cache-Control", "max-age=0");
+			httpost.addHeader("User-Agent",
+					"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
+			httpost.setEntity(new StringEntity(data, "UTF-8"));
+			CloseableHttpResponse response = httpclient.execute(httpost);
+			try {
+				HttpEntity entity = response.getEntity();
+				String jsonStr = toStringInfo(response.getEntity(), "UTF-8");
+				// 微信返回的报文时GBK,直接使用httpcore解析乱码
+				// String jsonStr =
+				// EntityUtils.toString(response.getEntity(),"UTF-8");
+				EntityUtils.consume(entity);
+				return jsonStr;
+			} finally {
+				response.close();
+			}
+		} finally {
+			httpclient.close();
+		}
+	}
+
+	private String toStringInfo(HttpEntity entity, String defaultCharset)
+			throws Exception, IOException {
+		final InputStream instream = entity.getContent();
+		if (instream == null) {
+			return null;
+		}
+		try {
+			Args.check(entity.getContentLength() <= Integer.MAX_VALUE,
+					"HTTP entity too large to be buffered in memory");
+			int i = (int) entity.getContentLength();
+			if (i < 0) {
+				i = 4096;
+			}
+			Charset charset = null;
+			if (charset == null) {
+				charset = Charset.forName(defaultCharset);
+			}
+			if (charset == null) {
+				charset = HTTP.DEF_CONTENT_CHARSET;
+			}
+			final Reader reader = new InputStreamReader(instream, charset);
+			final CharArrayBuffer buffer = new CharArrayBuffer(i);
+			final char[] tmp = new char[1024];
+			int l;
+			while ((l = reader.read(tmp)) != -1) {
+				buffer.append(tmp, 0, l);
+			}
+			return buffer.toString();
+		} finally {
+			instream.close();
+		}
+	}
+
+	public static String createXML(Map<String, Object> map) {
+		String xml = "<xml>";
+		Set<String> set = map.keySet();
+		Iterator<String> i = set.iterator();
+		while (i.hasNext()) {
+			String str = i.next();
+			xml += "<" + str + ">" + "<![CDATA[" + map.get(str) + "]]>" + "</"
+					+ str + ">";
+		}
+		xml += "</xml>";
+		return xml;
+	}
+}

+ 22 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/MyX509TrustManager.java

@@ -0,0 +1,22 @@
+package com.iamberry.wechat.tools;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import javax.net.ssl.X509TrustManager;
+
+/**
+ * 证书信任管理器(用于https请求)
+ * @author fzh
+ */
+public class MyX509TrustManager implements X509TrustManager {
+
+	public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+	}
+
+	public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+	}
+
+	public X509Certificate[] getAcceptedIssuers() {
+		return null;
+	}
+}

+ 261 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/NameUtils.java

@@ -0,0 +1,261 @@
+package com.iamberry.wechat.tools;
+/**
+ * 本类保存所有常见、常用名称,如登陆用户在session中的名称,验证码在session中的名称
+ * 慎重修改!
+ * @author 何秀刚
+ */
+public class NameUtils {
+	// 验证码session中保存的名称
+	public static final String VERIFYCODE_NAME = "verifyCode";
+	// 会员登陆成功过后session中保存的名称
+	public static final String LOGIN_USER_NAME = "loginUser";
+	// 超级管理员登陆成功后session中保存的名称
+	public static final String ADMIN_LOGIN_NAME = "admin";
+	// 二级管理员登陆成功后色素死哦你中保存的名称
+	public static final String ADMINCHILD_LOGIN_NAME = "adminChild";
+	// 线上试用订单ID前缀
+	public static final String ETC_ORDER_PREFIX = "1102";
+	// 线下试用订单ID前缀
+	public static final String ORDER_ID = "1310";
+	/** path root */
+	public static final String PATH_ROOT = "http://test.iamberry.com";
+//	public static final String PATH_ROOT = "http://h5.iamberry.com";
+	/** 微信端会员 */
+	public static final String WECHAT_MEMBER_ROOT = "/member"; // 微信端会员根目录
+	public static final String WECHAT_MEMBER_INDEX = "/index"; // 会员首页
+	public static final String WECHAT_MEMBER_INDEX_RES = "wechat/member/user_index"; // 资源位置
+	public static final String WECHAT_MEMBER_URL_INDEX = "/member/index"; // URL
+	public static final String WECHAT_MEMBER_1 = "wechat/member/user_index_1";
+	public static final String WECHAT_MEMBER_QRCODE = "/qrcode";
+	public static final String WECHAT_MEMBER_QRCODE_RES = "wechat/member/user_qrcode";
+	public static final String WECHAT_MEMBER_QRCODE_INDEX = "/member/qrcode";
+	public static final String WECHAT_MEMBER_LEVEL = "/ascensionMemberLevelJSON";
+	public static final String WECHAT_MEMBER_HELP = "/help";
+	public static final String WECHAT_MEMBER_HELP_RES = "wechat/member/user_help";
+	public static final String WECHAT_MEMBER_USERINFO = "/userinfoUI";
+	public static final String WECHAT_MEMBER_USERINFO_RES = "wechat/member/user_info";
+	public static final String WECHAT_MEMBER_UPDATE_USERINFO = "/updateUserInfoJSON";
+	public static final String WECHAT_QRCODE_SHARE = "/share/{userId}";
+	public static final String WECHAT_QRCODE_SHARE_RES = "wechat/member/user_qrcode";
+	public static final String PLACE_CODE_PREFIX = "CODE";
+	public static final String WECHAT_BACK_URL = PATH_ROOT + "/iamberry/wechatBack";
+	public static final String WECHAT_ORDER_BACK = PATH_ROOT + "/iamberry/callback/orderPayBack";
+	public static final String redirectUrl = "redirectUrl";
+	public static final String redirectUrl_index = "redirect:/wechat/index";
+	public static final String WECHAT_DRP_BACK = PATH_ROOT + "/iamberry/callback/drpPayBack";
+	public static final String WECHAT_PRODUCT_SHARE_URL = PATH_ROOT + "/iamberry/wechat/product/sharePorductDesc";
+	public static final String WECHAT_MEMBER_SHARE_URL = PATH_ROOT + "/iamberry/wechat/member/showQrcode";
+	public static final String WECHAT_MEMBER_SHARE_QRCODE = PATH_ROOT + "/iamberry/wechat/member/showQrcode";
+	public static final String WECHAT_MEMBER_PROXY_QRCODE = PATH_ROOT + "/iamberry/wechat/drp/share2WM";
+	public static final String WECHAT_DRP_SHARE_URL = PATH_ROOT + "/iamberry/wechat/drp/share2WM";
+	public static final String WECHAT_DEFAULT_QRCODE = PATH_ROOT + "/iamberry/common/images/default_qrcode.png";
+	public static final String WECHAT_DEFAULT_WATERMARK = "/common/images/default_watermark.png";
+	/** 商城所有的今天页面 */
+	public static final String WECHAT_SHOP_WITHDRAW_APPLY = "/WEB-INF/views/wechat/tixian_apply.html"; // 积分提现
+	public static final String WECHAT_SHOP_WITHDRAW_APPLY_CASH = "/WEB-INF/views/wechat/tixian_apply_cash.html"; // 现金提现
+	public static final String WECHAT_SHOP_WITHDRAW_APPLY_CASH_SUCCESS = "/WEB-INF/views/wechat/tixian_cash_success.html"; // 现金提现申请成功页面
+
+	public static final String WECHAT_SHOP_PRODUCT_DESC_PAGE = "/WEB-INF/views/wechat/chanpin_details.html"; // 产品详情
+	public static final String WECHAT_SHOP_PRODUCT_LIST_PAGE = "/WEB-INF/views/wechat/chanpin_list.html"; // 产品列表
+	public static final String WECHAT_SHOP_INDEX = "/WEB-INF/views/wechat/index.html"; // 首页
+	public static final String WECHAT_SHOP_VIDEO = "/WEB-INF/views/wechat/iamberry_video.html"; // 首页
+	public static final String WECHAT_SHOP_MEMGER_INDEX = "/WEB-INF/views/wechat/daili_2wm.html"; // 二维码
+	public static final String WECHAT_SHOP_CART_INDEX = "/WEB-INF/views/wechat/shopping_cart.html"; // 购物车
+	public static final String WECHAT_SHOP_ORDER_PAY = "/WEB-INF/views/wechat/clearing.html"; // 支付页面
+	public static final String WECHAT_SHOP_ORDER_PAY_SUCCESS = "/WEB-INF/views/wechat/pay_win.html"; // 支付成功页面
+	
+	public static final String WECHAT_SHOP_ORDER_GOORDERINFO = "/WEB-INF/views/wechat/order_details.html";//去订单详情页面
+	public static final String WECHAT_SHOP_ORDER_GOORDERLIST = "/WEB-INF/views/wechat/order_list.html";//去订单列表页
+	public static final String WECHAT_SHOP_PRODUCT_LIST = "/WEB-INF/views/wechat/chanpin_list.html";
+	
+	public static final String WECHAT_CASH_LOG_LIST = "/WEB-INF/views/wechat/cash_log.html";
+	public static final String WECHAT_WITHDRAW_CASH_LOG_LIST = "/WEB-INF/views/wechat/tixian_log_cash.html";
+	
+	//分销
+	public static final String WECHAT_SHOP_FENXIAO_INDEX="/WEB-INF/views/wechat/drp/indexPage";  //分销首页
+	public static final String WECHAT_SHOP_FENXIAO_ORDERLIST="/WEB-INF/views/wechat/fenxiao_fahuo_log.html";  //分销列表页
+	public static final String WECHAT_SHOP_FENXIAO_PAYORDERPAGE="/WEB-INF/views/wechat/fenxiao_clearing.html";  //分销订货支付页面
+	
+	//大转盘页面
+	public static final String WECHAT_GO_ZHUANPAN = "/WEB-INF/views/wechat/zhuanpan.html";
+	public static final String WECHAT_GO_PRIZE_LOG = "/WEB-INF/views/wechat/wheel_log.html";
+	public static final String WECHAT_GO_LUCK_DRAW = "/WEB-INF/views/wechat/share_zhuanpan.html";
+	// 允许的URL连接
+	public static final String XSS_HANDLER_LOCALHOST_URL = "https://localhost:";
+//	public static final String XSS_HANDLER_OUT_URL = "https://h5.iamberry.com:";
+	public static final String XSS_HANDLER_OUT_URL = "https://test.iamberry.com:";
+	
+	/**
+	 * 百胜订单信息
+	 */
+	public static final String app_nick = "openapi";
+	public static final String app_key = "8888";
+	public static final String app_secret = "8888";
+	public static final String efast_base_url = "http://121.199.165.244/efast_test/efast_api/webservice/web/index.php";
+//	public static final String efast_base_url = "http://121.199.165.244/efast/efast_api/webservice/web/index.php";
+	public static final String order_field = "order_sn,deal_code,order_status,shipping_status,pay_status,process_status,is_send,is_locked,is_separate,consignee,address,zipcode,tel,mobile,shipping_name,pay_name,invoice_no,order_amount ,money_paid,user_id ,orders.goods_sn,orders.goods_name,orders.goods_number,orders.goods_price,orders.goods_barcode,orders.payment_ft,pay_time,to_buyer,postscript,order_amount,user_nick,money_paid,shipping_fee";
+
+	/**App 绑定下载 **/
+	public static final String BINDINGDOWNLOD="/WEB-INF/views/other/index.html";
+	
+	public static final int OT_NONE = 0, OT_WRITER = 1, OT_STREAM = 2;
+	
+	public static final String WECHAT_INDEX_FORWARD = "/WEB-INF/views/wechat/index.html";
+	
+	public static final String DATE_FORMAT = "yyyy-MM-dd";
+	public static final String TIME_FORMAT = "HH:mm:ss";
+	public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+	public static final String DATE_TIME_FORMAT1 = "yyyy/MM/dd HH:mm:ss";
+	public static final String DATE_TIME_FORMAT2 = "yyyy年MM月dd日 HH:mm";
+	
+	/**图片格式:JPG*/
+	public static final String PICTRUE_FORMATE_JPG = "jpg";
+
+	public static final String signatureSimple = "userAgent=%s&userIp=%s&token=%s&timestamp=%s&sessionId=%s";
+	
+	/** 16进制字符集 */
+	public static final char HEX_DIGITS[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+	
+    public static final String DEFAULT_SEND_CHARSET = "UTF-8";
+
+    public static final String DEFAULT_RES_CHARSET = "UTF-8";
+	
+	//*********************  WXPublicNo.java begin  *************/
+    //description : 微信公众号的一些基本信息	 @author 何秀刚 	create date:2016年3月10日
+    
+//    /**
+//	 * 测试账号信息:爱贝源科技
+	 
+	public final static String pubNo = "gh_63843ac1ca52";// 微信号
+	public final static String appId = "wxd995fb95b97ece1b";// 应用ID
+	public final static String token = "weixin";// token
+	public final static String appSecret = "34922854462fba23cf54ce859349fcf4";// 应用密钥
+	public final static String partner = "1347735301";// 微信支付商户号
+//     */
+    
+	/** 公众号账户信息:爱贝源 */
+	/*
+	public final static String pubNo = "gh_487d0dbf8e30";// 微信号
+	public final static String appId = "wx09aa7519c4e5b360";// 应用ID
+	public final static String token = "weixin";// token
+	public final static String appSecret = "c006d5a6af80b5291265a1364fd17edc";// 应用密钥
+	public final static String partner = "1340351501";// 微信支付商户号
+	*/
+//	
+//	/** 公众号商户信息 */
+//	public final static String partner = "1340351501";// 微信支付商户号
+	public final static String partnerkey = "8a90e3ab0e2db7772f5f64e7edwechat";// 财付通初始密码
+	public final static String charset = "UTF-8"; // 支付编码
+	public final static String KEYSTORE_FILE = "E:/apiclient_cert.p12"; // 支付API安全文件FILE位置,但是现在保存到/resource/apiclient_cert.p12
+	public final static String KEYSTORE_PASSWORD = partner; // 支付API安全文件密码
+	public final static String ipAddress = "120.76.152.52"; // ip地址
+	
+	/** 微信支付回掉url接口 */
+	public final static String ORDER_PAY_BACK_URL = NameUtils.PATH_ROOT + "/iamberry/cart/payBack"; // 销售订单支付成功后回调地址
+	public final static String ONLINE_TRIAL_BACK_URL = NameUtils.PATH_ROOT + "/iamberry/trial/back"; // 线上试用订单支付成功后的回调地址
+	public final static String ONNLINE_TRIAL_BACK_URL = NameUtils.PATH_ROOT + "/iamberry/trial/onnlineBack"; // 线下使用订单,微信支付成功后的回调地址
+	
+	/** 微信授权获取用户的openid */
+	public final static String GET_OPENID_DEAL_URL = NameUtils.PATH_ROOT + "/iamberry/dealOpenId";
+	
+	/** 发起微信支付的url地址 */
+	// 下面两类,需要单独设置微信支付发起的权限URL
+	public final static String CHECKOUT_TOPAY_URL = NameUtils.PATH_ROOT + "/iamberry/cart/toCheckOutUI/*"; // 结算页面发起微信支付
+	public final static String ORDER_INFO_DESC_TOPAY_URL = NameUtils.PATH_ROOT + "/iamberry/cart/orderDescUI/*"; // 订单详情页面中发起微信支付
+	// 下面三类可以使用一个微信支付权限URL
+	public final static String ONLINE_TRIAL_TOPAY_URL = NameUtils.PATH_ROOT + "/iamberry/trial/index"; // 线上试用订单页面,发起微信支付请求
+	public final static String ONLINE_TRIAL_ORDER_INFO_DESC_TOPAY_URL = NameUtils.PATH_ROOT + "/iamberry/trial/trialEtcOrderUI?order=*";// 线上试用订单详细界面中发起微信支付请求
+	public final static String ONNLINE_TRIAL_ORDER_TOPAY_URL = NameUtils.PATH_ROOT + "/iamberry/trial/toOnnlinePayUI"; // 线下使用订单,线上付款,发起微信支付请求url
+	
+	/** 微信共享地址回调 */
+	public final static String TOCHECKOUT_ADDR_URL = NameUtils.PATH_ROOT + "/iamberr/wechat/cart/settlement/"; // 结算页面的微信收货地址url
+	public final static String TRIAL_ADDR_URL = NameUtils.PATH_ROOT + "/iamberry/trial/index"; // 线上试用的微信共享地址
+	
+	/** 微信图片的url */
+	public final static String IMAGE_BASE_URL = NameUtils.PATH_ROOT;
+	
+	/** 官网  */
+	public final static String WWW_INDEX = "http://www.iamberry.com";
+	
+	/** 线下订单付款前缀 */
+	public final static String OFFLINE_ORDER_PREFIX = "9900123";
+	
+	/** 产品图片保存位置 */
+	public final static String GOODS_SAVE_PATH = "/common/images/uploadimages/";
+	
+	/** 微信会员码起始数量 */
+	public final static int MEMBER_NUM = 888888;
+	
+	/** 试用到期时间 */
+	public final static Long TRIAL_DATE = 2592000000L;
+	
+	/** 替换的图片 */
+	public final static String REPLACE_SECURITY_IMAGE = "http://192.168.1.129:8080/iamberry/common/images/security.jpg";
+	
+	//*********************  WXPublicNo.java end  *************/
+	
+	
+	////***************** WeixnUtil  begin ***********************//////////
+	// 获取access_token的接口地址(GET) 限200次/天
+	public final static String access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
+	// 获取jsapi_ticket的接口地址(GET)
+	public static String jsapi_ticket_url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi";
+	// 菜单创建(POST) 限100次/天
+	public static String menu_create_url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN";
+	// 根据access_token换取二维码ticket
+	public static String get_token_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN";
+	// 二维码图片链接
+	public static String show_qrcode_url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=";
+	// 临时二维码
+	public static String QR_SCENE = "{\"expire_seconds\": %s, \"action_name\": \"QR_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": %s}}}";
+	//  永久二维码
+	public static String QR_LIMIT_STR_SCENE = "{\"action_name\": \"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"%s\"}}}";
+	// 获取用户信息
+	public static String userinfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID";
+	// 网页授权获取access_token
+	public static String oauth2_getToken_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
+	// 网页授权获取user_info
+	public static String oauth2_getUserInfo_url = "https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN";
+	// 引导授权链接
+	public static String oauth2_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect";
+
+	//***************** WeixnUtil  end ***********************//////////
+	
+	//***************** VerifyCodeUtil begin ******************/////////
+	/** 
+     * 验证码类型为仅数字,即0~9 
+     */  
+    public static final int TYPE_NUM_ONLY = 0;  
+  
+    /** 
+     * 验证码类型为仅字母,即大小写字母混合 
+     */  
+    public static final int TYPE_LETTER_ONLY = 1;  
+  
+    /** 
+     * 验证码类型为数字和大小写字母混合 
+     */  
+    public static final int TYPE_ALL_MIXED = 2;  
+  
+    /** 
+     * 验证码类型为数字和大写字母混合 
+     */  
+    public static final int TYPE_NUM_UPPER = 3;  
+  
+    /** 
+     * 验证码类型为数字和小写字母混合 
+     */  
+    public static final int TYPE_NUM_LOWER = 4;  
+  
+    /** 
+     * 验证码类型为仅大写字母 
+     */  
+    public static final int TYPE_UPPER_ONLY = 5;  
+  
+    /** 
+     * 验证码类型为仅小写字母 
+     */  
+    public static final int TYPE_LOWER_ONLY = 6;  
+    
+  //***************** VerifyCodeUtil end ******************/////////
+}

+ 99 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ObjectExcelView.java

@@ -0,0 +1,99 @@
+package com.iamberry.wechat.tools;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFFont;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.springframework.web.servlet.view.document.AbstractExcelView;
+
+/**
+ * 导入到EXCEL
+ * @author Administrator
+ */
+public class ObjectExcelView extends AbstractExcelView{
+
+	/**
+	 * model参数为:
+	 * 	fileName: 下载的文件名称
+	 * 	titles:  excel的文件标题
+	 * 	varList: 文件内容
+	 */
+	@SuppressWarnings("unchecked")
+	@Override
+	protected void buildExcelDocument(Map<String, Object> model,
+			HSSFWorkbook workbook, HttpServletRequest request,
+			HttpServletResponse response) throws Exception {
+		// TODO Auto-generated method stub
+		
+		// 准备文件名
+		Date date = new Date();
+		StringBuffer filename = new StringBuffer("iamberry-");
+		String modelFileName = model.get("fileName").toString();
+		filename.append(DateTimeUtil.format(date, "yyyyMMddHHmmss-")).append(modelFileName == null ? "default" : modelFileName);
+		// 工作薄对象
+		HSSFSheet sheet;
+		HSSFCell cell;
+		sheet = workbook.createSheet("iamberry-sheet");
+		
+		// 设置返回内容
+		response.setContentType("application/octet-stream");
+		response.setHeader("Content-Disposition", "attachment;filename="+new String((filename.toString()).getBytes("UTF-8"), "ISO-8859-1")+".xls");
+		
+		// 标题内容
+		List<String> titles = (List<String>) model.get("titles");
+		int len = titles.size();
+		
+		// 标题样式
+		HSSFCellStyle headerStyle = workbook.createCellStyle();
+		headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+		headerStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+		HSSFFont headerFont = workbook.createFont();	//标题字体
+		headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+		headerFont.setFontHeightInPoints((short)11);
+		headerStyle.setFont(headerFont);
+		short width = 20,height=25*20;
+		sheet.setDefaultColumnWidth(width);
+		
+		// 设置标题
+		for(int i=0; i<len; i++){
+			String title = titles.get(i);
+			cell = getCell(sheet, 0, i);
+			cell.setCellStyle(headerStyle);
+			setText(cell,title);
+		}
+		// 标题的高度
+		sheet.getRow(0).setHeight(height);
+		
+		//内容样式
+		HSSFCellStyle contentStyle = workbook.createCellStyle();
+		contentStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+		
+		// 设置内容
+		List<List<Object>> varList = (List<List<Object>>) model.get("varList");
+		
+		int row = 1; // 行数,第一行被标题占据,所以从第二行开始
+		for (List<Object> list : varList) {
+			
+			int col = 0;// 当前行的列数
+			for (Object object : list) {
+				//			          工作薄对象          行         列
+				cell = getCell(sheet, row, col);
+				cell.setCellStyle(contentStyle);
+				setText(cell,StrUtils.checkStr(object));
+				
+				col ++; // 列迭代
+			}
+			
+			row ++; // 行迭代
+		}
+	}
+
+}

+ 34 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/OrderNOUtil.java

@@ -0,0 +1,34 @@
+package com.iamberry.wechat.tools;
+
+import java.util.Date;
+import java.util.Random;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * 订单工具类
+ * @author Administrator
+ */
+@Component
+public class OrderNOUtil {
+	private static char[] chars = {
+		'G', 'I', 'J', 'K', 'L', 'M', 'N', 'U', 'V', 'W', 'Y', 'Z',
+		'P', 'Q', 'A', 'B', 'C', 'D', 'E', 'F', 'R', 'S', 'T' 
+		};
+	public static Random random = new Random();
+	/**
+	 * 产生一个订单编号
+	 * @param id :为当前订单所属 用户id
+	 */
+	public String createOrderCode(Integer id) {
+		StringBuilder code = new StringBuilder();
+		//产生基本数据
+		code = code.append(StaticInfo.dateFormat.format(new Date()));
+		//避免同一秒内,操作多次
+		code.append(chars[random.nextInt(chars.length)]);
+		//避免多用户操作
+		code.append(id);
+		code.append(chars[random.nextInt(chars.length)]);
+		return code.toString();
+	}
+}

+ 103 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/PropertiesUtils.java

@@ -0,0 +1,103 @@
+package com.iamberry.wechat.tools;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.servlet.ServletContext;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.springframework.web.context.ContextLoader;
+import org.springframework.web.context.WebApplicationContext;
+/**
+ *		description: 读写配置文件工具
+ * 	   		@author: 张应真
+ *	    @createDate: 2016年6月13日
+ */
+public class PropertiesUtils {
+//	private static final String PATH = "config.properties";
+//	private static final String OUTPATH = "/WEB-INF/classes/ResultInfo.properties";
+
+	/**
+	 *  根据key读取value
+	 * @param in
+	 * @param key
+	 * @return
+	 */
+	public static String readValue(InputStream in, String key) {
+		Properties props = new Properties();
+		try {
+	//		InputStream in = new BufferedInputStream(new FileInputStream(filePath));
+			props.load(in);
+			String value = props.getProperty(key);
+			System.out.println("key:"+key +"====================="+ "value:"+value);
+			return value;
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	/**
+	 *  读取properties的全部信息
+	 * @param in
+	 * @return
+	 */
+	@SuppressWarnings("unchecked")
+	public static Map<String,String>readProperties(InputStream in) {
+		Properties props = new Properties();
+		Map<String, String> map=new HashedMap();
+		try {
+		//	InputStream in = new BufferedInputStream(new FileInputStream(path));
+			props.load(in);
+			Enumeration en = props.propertyNames();
+			while (en.hasMoreElements()) {
+				String key = (String) en.nextElement();
+				String Property = props.getProperty(key);
+				map.put(key, Property);
+			//	System.out.println(key +"-----"+ Property);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return map;
+	}
+
+	/**
+	 *  写入properties信息
+	 * @param outpath
+	 * @param parameterName
+	 * @param parameterValue
+	 */
+	public static void writeProperties(String outpath, String parameterName,String parameterValue) {
+		Properties prop = new Properties();
+		try {
+			//获取ResultInfo.properties路径
+//			WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();    
+//	        ServletContext servletContext = webApplicationContext.getServletContext(); 
+//	        InputStream in=servletContext.getResourceAsStream(outpath);
+			 InputStream in =new FileInputStream(outpath);
+			// 从输入流中读取属性列表(键和元素对)
+			prop.load(in);
+			// 调用 Hashtable 的方法 put。使用 getProperty 方法提供并行性。
+			// 强制要求为属性的键和值使用字符串。返回值是 Hashtable 调用 put 的结果。
+			OutputStream fos = new FileOutputStream(outpath);
+			prop.setProperty(parameterName, parameterValue);
+			// 以适合使用 load 方法加载到 Properties 表中的格式,
+			// 将此 Properties 表中的属性列表(键和元素对)写入输出流
+			prop.store(fos, "Update '" + parameterName + "' value '"+ parameterValue+"'");
+		} catch (IOException e) {
+			e.printStackTrace();
+			System.err.println("路径: " + outpath + "----键:"+ parameterName + "----值:");
+		}
+	}
+
+//	public static void main(String[] args) {
+//
+//	}
+}

File diff suppressed because it is too large
+ 34 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/QQFace.java


+ 211 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/RequestHandler.java

@@ -0,0 +1,211 @@
+package com.iamberry.wechat.tools;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.springframework.stereotype.Component;
+
+
+
+/*
+ '微信支付服务器签名支付请求请求类
+ '============================================================================
+ 'api说明
+ 'init(app_id, app_secret, partner_key, app_key);
+ '初始化函数,默认给一些参数赋值,如cmdno,date等
+ 'setKey(key_)'设置商户密钥
+ 'getLasterrCode(),获取错误信息
+ 'GetToken();获取Token
+ 'getTokenReal();Token过期后实时获取Token
+ 'createMd5Sign(signParams);生成Md5签名
+ 'genPackage(packageParams);获取package
+ 'createSHA1Sign(signParams);创建签名SHA1
+ 'sendPrepay(packageParams);提交预支付ID
+ 'getDebugInfo(),获取debug信息
+ '============================================================================
+ '*/
+@Component
+public class RequestHandler {
+	/** Token获取网关地址地址 */
+	private String tokenUrl;
+	/** 预支付网关url地址 */
+	private String gateUrl;
+	/** 查询支付通知网关URL */
+	private String notifyUrl;
+	/** 商户参数 */
+	private String appid;
+	private String appkey;
+	private String partnerkey;
+	private String appsecret;
+	private String key;
+	/** 请求的参数*/
+	private SortedMap parameters;
+	/** Token */
+	private String Token;
+	private String charset;
+	/** debug信息 */
+	private String debugInfo;
+	private String last_errcode;
+
+	private HttpServletRequest request;
+
+	private HttpServletResponse response;
+	public RequestHandler(HttpServletRequest request,
+			HttpServletResponse response) {
+		this.last_errcode = "0";
+		this.request = request;
+		this.response = response;
+		//this.charset = "GBK";
+		this.charset = "UTF-8";
+		this.parameters = new TreeMap();
+		// 验证notify支付订单网关
+		notifyUrl = "https://gw.tenpay.com/gateway/simpleverifynotifyid.xml";
+		
+	}
+	public RequestHandler() {
+		this.last_errcode = "0";
+		this.request = null;
+		this.response = null;
+		//this.charset = "GBK";
+		this.charset = "UTF-8";
+		this.parameters = new TreeMap();
+		// 验证notify支付订单网关
+		notifyUrl = "https://gw.tenpay.com/gateway/simpleverifynotifyid.xml";
+	}
+	public void init(String app_id, String app_secret,	String partner_key) {
+		this.last_errcode = "0";
+		this.Token = "token_";
+		this.debugInfo = "";
+		this.appid = app_id;
+		this.partnerkey = partner_key;
+		this.appsecret = app_secret;
+		this.key = partner_key;
+	}
+	public void init() {
+	}
+	public String getLasterrCode() {
+		return last_errcode;
+	}
+	public String getGateUrl() {
+		return gateUrl;
+	}
+	public String getParameter(String parameter) {
+		String s = (String) this.parameters.get(parameter);
+		return (null == s) ? "" : s;
+	}
+	//设置密钥
+	public void setKey(String key) {
+		this.partnerkey = key;
+	}
+	//设置微信密钥
+	public void  setAppKey(String key){
+		this.appkey = key;
+	}
+	
+	// 特殊字符处理
+	public String UrlEncode(String src) throws UnsupportedEncodingException {
+		return URLEncoder.encode(src, this.charset).replace("+", "%20");
+	}
+
+	// 获取package的签名包
+	public String genPackage(SortedMap<String, String> packageParams)
+			throws UnsupportedEncodingException {
+		String sign = createSign(packageParams);
+
+		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();
+			sb.append(k + "=" + UrlEncode(v) + "&");
+		}
+		String packageValue = sb.append("sign=" + sign).toString();
+		return packageValue;
+	}
+	public String createSign(SortedMap<String, String> packageParams) {
+		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=" + this.getKey());
+		String sign = MD5Util.MD5Encode(sb.toString(), this.charset)
+				.toUpperCase();
+		return sign;
+
+	}
+	/**
+	 * 创建package签名
+	 */
+	public boolean createMd5Sign(String signParams) {
+		StringBuffer sb = new StringBuffer();
+		Set es = this.parameters.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 (!"sign".equals(k) && null != v && !"".equals(v)) {
+				sb.append(k + "=" + v + "&");
+			}
+		}
+		// 算出摘要
+		String enc = TenpayUtil.getCharacterEncoding(this.request,
+				this.response);
+		String sign = MD5Util.MD5Encode(sb.toString(), enc).toLowerCase();
+		String tenpaySign = this.getParameter("sign").toLowerCase();
+		// debug信息
+		this.setDebugInfo(sb.toString() + " => sign:" + sign + " tenpaySign:" + tenpaySign);
+		return tenpaySign.equals(sign);
+	}
+    //输出XML
+   public String parseXML() {
+	   StringBuffer sb = new StringBuffer();
+       sb.append("<xml>");
+       Set es = this.parameters.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) && !"appkey".equals(k)) {
+				
+				sb.append("<" + k +">" + getParameter(k) + "</" + k + ">\n");
+			}
+		}
+       sb.append("</xml>");
+		return sb.toString();
+	}
+	/**
+	 * 设置debug信息
+	 */
+	protected void setDebugInfo(String debugInfo) {
+		this.debugInfo = debugInfo;
+	}
+	public void setPartnerkey(String partnerkey) {
+		this.partnerkey = partnerkey;
+	}
+	public String getDebugInfo() {
+		return debugInfo;
+	}
+	public String getKey() {
+		return key;
+	}
+}

+ 97 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ResponseJson.java

@@ -0,0 +1,97 @@
+package com.iamberry.wechat.tools;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @company	深圳爱贝源科技有限公司
+ * @website www.iamberry.com
+ * @author 	献
+ * @tel		18271840547
+ * @date	2016年9月5日
+ * @explain	返回数据的json格式封装
+ */
+public class ResponseJson implements Serializable {
+	
+	private static final long serialVersionUID = -8905563601242066596L;
+
+	private int resultCode = 200;			// 请求code
+	
+	private String resultMsg = "SUCCESS";	// 请求code描述
+	
+	private Integer returnCode;				// 业务结果
+	
+	private Map<String, Object> message;	// 返回的结果信息
+	
+	public ResponseJson(int resultCode, String resultMsg, Integer returnCode) {
+		this.resultCode = resultCode;
+		this.resultMsg = resultMsg;
+		this.returnCode = returnCode;
+	}
+	
+	public ResponseJson() {
+	}
+
+	public int getResultCode() {
+		return resultCode;
+	}
+
+	public void setResultCode(int resultCode) {
+		this.resultCode = resultCode;
+	}
+
+	public String getResultMsg() {
+		return resultMsg;
+	}
+
+	public void setResultMsg(String resultMsg) {
+		this.resultMsg = resultMsg;
+	}
+
+	public Integer getReturnCode() {
+		return returnCode;
+	}
+
+	public void setReturnCode(Integer returnCode) {
+		this.returnCode = returnCode;
+	}
+
+	public Map<String, Object> getReturnMsg() {
+		return message;
+	}
+
+	public void setReturnMsg(Map<String, Object> returnMsg) {
+		this.message = returnMsg;
+	}
+	
+	/**
+	 * 添加返回结果 returnMsg='value'结果
+	 * @param key
+	 * @param value
+	 */
+	public void addResponseKeyValue(String value) {
+		if (this.message == null) {
+			message = new HashMap<String, Object>();
+		}
+		this.message.put("returnMsg", value);
+	}
+
+	/**
+	 * 添加返回结果 key='value'结果
+	 * @param key
+	 * @param value
+	 */
+	public void addResponseKeyValue(String Key, Object value) {
+		if (this.message == null) {
+			message = new HashMap<String, Object>();
+		}
+		this.message.put(Key, value);
+	}
+
+	@Override
+	public String toString() {
+		String s = super.toString();
+		return s;
+	}
+}

+ 134 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ResultInfo.java

@@ -0,0 +1,134 @@
+package com.iamberry.wechat.tools;
+
+/**
+ * @description 存储静态变量的
+ * @author 欧阳明
+ * @date 2016-4-19
+ */
+public class ResultInfo {
+
+	public  static String SUCCESSINFO="操作成功!";
+	public  static String ERRORINFO="操作失败";
+	public  static String SUCCESSCODE="200";
+	public  static String ERRORCODE="500";
+	
+	public static String drpBookAthorNoEnough="分销商订货权限不足";
+	public static String getMoneyconditionGT = "提现金额必须大于";
+	public static String getMoneyconditionLT = ",小于";
+	
+	public static int getMoneyLimitDown=10000;
+	public static int getMoneyLimitTop=1000000000;
+	
+	public  static String getMoneyLimitError="";
+	public  static String getMoneyCountError="";
+
+	public  static String loginOutError = "";
+	public  static String paramFormatError = "";
+	public  static String withdrawCountOutError = "";
+	public  static String cartEmptyError = "";
+	public  static String integralOutError = "";
+	public  static String userIntegralOutError = "";
+	public  static String userMoneyOutError = "";
+	public  static String integralOutOrderMeonyError = "";
+	public  static String userNoDrpError = "";
+	
+	public static  String APPLY_AGAIN = "";
+	public static  String APPLY_EXIST = "";
+	public static  String APPLY_OPENID_IS_NULL = "";
+	public static  String APPLY_ORDER_IS_NULL = "";
+	
+	public  static String repeatNameError="";
+	public  static String lostMemberInfo="";
+	
+	public  static String initPorxySuccessPrifix = "";										//	初始化代理商信息openid成功前缀
+	public  static String initPorxySuccessSuffix = "";										// 初始化代理商信息哦瓶内的成功后缀
+	public  static String initPorxyErrorByCodeError = "";									// 激活码错误
+	public  static String initPorxyErrorByUseInit = "";										// 已经激活
+	public  static String initPorxyErrorByUseBuild = "";									// 多次绑定
+	public  static String initPorxyErrorByCodeWrong = "";									// 激活码错误
+	public  static String subDefaultResponseText = "";										// 关注时默认回复文字内容 
+	public  static String messageDefaultResponseText = "";									// 用户发送消息时的文本处理
+	public  static String messageIsNullResponseText = "";									// 用户发送信息为空时的回复文本
+	public  static String imageMessageResponseText= "";										// 接受图片信息回复文本
+	public  static String locationMessageResponseText = "";									// 地理位置信息
+	public  static String linkMessageResponseText = "";										// 连接信息
+	public  static String videoMessageResponseText = "";									// 音频信息
+	public  static String tryCatchDefaultResponseText = "";									// 异常时回复信息
+	public static String rebateOrderText = "";												//定时任务返利模板
+	
+	public static String QRCODE_IMAGE = "/common/qrcode_images";		//下载二维码图片保存路径
+	
+	public static String DRP_INDEX_PAGE = "http://h5.iamberry.com/iamberry/wechat/drp/indexPage";
+	
+	
+	//测试环境
+		// 商城首页,,,
+		public static String INDEX_PAGE = "http://test.iamberry.com/iamberry/wechat/index";
+		// 订单发货的界面
+		public static String PAGE_SHIPMENT = "http://test.iamberry.com/iamberry/pay/goOrderInfo?orderId=";
+		//收益退回的界面
+		public static String TUIHUI_SHIPMENT = "http://test.iamberry.com/iamberry/wechat/agentWechat/reback";
+		//订单即将过期提醒
+		public static String ORDER_GUOQI = "http://test.iamberry.com/iamberry/pay/goOrderList";
+		//测试环境
+		public static String rewards_template_id="ji1cu0TBpo8inMB2lVv3IdyNoFo5aBfSKDiGAuX28v8";//返现到账通知模版id
+		public static String Income_template_id="3oJmW0XWy47RSdLwgjj1Iy2hs8JIivq-WWVPsWPAMMI";//收入提醒模版id
+		public static String Shipment_template_id="744KA1PdB1I5PzRcjtxqbEz5t2bp8vdsi4I2ytW1rbE";//发货提醒模版id
+		public static String Order_template_id="K58fJRkIy0ELcbKvrpxwt4K_zXUbprYKM4fWVgHwjro";//订单未支付模版id
+	
+	// 返现到账通知消息模版
+	public static String REWARDSREMINDTEMP =  "{'first':{'color':'#173177','value':'firstValueIamberry'}, order:{'color':'#173177','value':'orderValueIamberry'}, 'money':{'color':'#173177', 'value':'moneyValueIamberry'}, 'remark':{'color':'#173177','value':'remarkValueIamberry'}}";
+	
+	// 包裹通知
+	public static String ORDERPACKAGETEMP = "{'first':{'color':'#173177', 'value':'firstValueOrder'}, 'order_id':{'color':'#173177','value':'orderIdValueOrder'}, 'package_id':{'color':'#173177','value':'orderValuePackageId'}, 'remark':{'color':'#173177', 'value':'orderRemarkValue'}}";
+	
+	//账户变更通知
+	public static String INCOMEREMINDTEMP = "{'first':{'color':'#173177','value':'firstValueIamberry'}, 'account':{'color':'#173177','value':'accountValueIamberry'}, 'time':{'color':'#173177', 'value':'timeValueIamberry'}, 'type':{'color':'#173177','value':'typeValueIamberry'},'remark':{'color':'#173177','value':'remarkValueIamberry'}}";
+	
+	//订单未支付(5分钟)通知
+	public static String ORDERWEIZHIFU = "{'first':{'color':'#173177','value':'firstValueIamberry'}, 'ordertape':{'color':'#173177','value':'ordertapeValue'}, 'ordeID':{'color':'#173177', 'value':'ordeIDVALUE'},'remark':{'color':'#173177','value':'remarkValueIamberry'}}";
+		
+	
+	//微信模板消息提示语
+	public static final String REWARDSWILLMESSAGE = "尊敬的客户您好~您有新的返现即将入账~";
+	public static final String REWARDSHASMESSAGE  = "您有新的返现已入账~";
+	public static final String SHIPMENTMESSAGE  = "您的订单已发货~";
+	public static final String INTOSHOP = ""; //点击进入商城查看-->>
+	public static final String INCOMEAGREEMESSAGE = "您的提现已审核通过~已入账~";
+	public static final String INCOMEREJECTMESSAGE = "您的提现申请被拒绝~已经返回您的金额~";
+	public static final String NEXTUSERTUIHUOMESSAGE = "您的下线已退货~";
+	public static final String ORDERGUOQI = "您有订单未支付~";
+
+	
+	// 凡是下线关注时的回复语
+	public static String FOLLOW_REPLY_MESSAGE_TEXT = "恭喜您,已获得购买冲奶机优惠40元资格!";
+	
+	// 凡是下线关注时的回复语是否为图片,true:图片,false,文本
+	public static boolean FOLLOW_REPLY_MESSAGE_IS_IMAGE_TEXT = false;
+	public static String imagePath = "common/share_images/up";				//上传分享图片存放路径
+	public static String defautImagePath = "common/shop/images/logo_head.png";			//默认爱贝源logo图片路径
+	
+	
+	//购物车活动
+	public static String ISSHOW="是";											//是否需要在页面显示
+	public static String CARTDESC="京东众筹价¥399,快快点我前往!";											//活动描述
+	public static String CART_URL="http://z.jd.com/project/details/53631.html?from=jr_search&type=0";											//跳转路径
+
+	//购物值
+	public static String NO_ENOUGH_FOR_PAY="账户余额不足";
+	public static String Pay_SUCCESS="支付成功";
+	public static String COUPON_OUTOFDATE="优惠券过期";
+	public static String COUPON_INVALID="优惠券无效";
+	public static String COUPON_CONSUME_NO_ENOUGH="消费额度不足,优惠券无法使用";
+
+	public static String ORDERID_PRIFIX = "***";
+	public static String COUPONITEMSTATUS_NORMAL = "normal";
+	public static String COUPONITEMSTATUS_PASSED = "passed";
+	
+	//分享语
+	public static String shareOne="这个产品,作为新手爸爸,还是很喜欢的,真心觉得很方便,就这几天的使用给点建议,如果APP数据报表再直观点,这个产品就完美了,希望官方能改进,这么牛的产品还是值得推荐和分享的。";
+	public static String shareTwo="养娃不易啊!这产品应该早点出来,之前给宝宝冲奶都是跟老公猜拳决定的,谁输谁去,现在他都抢着冲奶,父爱泛滥了,哈哈,这个冲奶机真的好用哦,关键还不贵,强烈推荐!";
+	public static String shareThree="工作忙的很,宝宝一直是老人带,看到冲奶机时她还不让买呢,作为儿女,就是想给她减轻点负担,结果她用后连连夸赞,说用冲奶机给娃冲奶确实方便,还好我没省这点钱,话说回来,我们这么辛苦赚钱是为了啥,不就是为了给家人更好的生活吗?几百块就能解决大问题,多值啊!";
+	
+
+}

+ 89 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/Sha1Util.java

@@ -0,0 +1,89 @@
+package com.iamberry.wechat.tools;
+
+
+
+
+import java.security.MessageDigest;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.SortedMap;
+public class Sha1Util {
+
+	public static String getNonceStr() {
+		Random random = new Random();
+		return MD5Util.MD5Encode(String.valueOf(random.nextInt(10000)), "UTF-8");
+	}
+	public static String getTimeStamp() {
+		return String.valueOf(System.currentTimeMillis() / 1000);
+	}
+	
+   //创建签名SHA1
+	public static String createSHA1Sign(SortedMap<String, String> signParams) throws Exception {
+		StringBuffer sb = new StringBuffer();
+		Set es = signParams.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();
+			sb.append(k + "=" + v + "&");
+		}
+		String params = sb.substring(0, sb.lastIndexOf("&"));
+		return getSha1(params);
+	}
+	//Sha1签名
+	public static String getSha1(String str) {
+		if (str == null || str.length() == 0) {
+			return null;
+		}
+		char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+				'a', 'b', 'c', 'd', 'e', 'f' };
+
+		try {
+			MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
+			mdTemp.update(str.getBytes("GBK"));
+
+			byte[] md = mdTemp.digest();
+			int j = md.length;
+			char buf[] = new char[j * 2];
+			int k = 0;
+			for (int i = 0; i < j; i++) {
+				byte byte0 = md[i];
+				buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
+				buf[k++] = hexDigits[byte0 & 0xf];
+			}
+			return new String(buf);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+	
+	//Sha1签名
+		public static String getSha2(String str) {
+			if (str == null || str.length() == 0) {
+				return null;
+			}
+			char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+					'a', 'b', 'c', 'd', 'e', 'f' };
+
+			try {
+				MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
+				mdTemp.update(str.getBytes("utf-8"));
+
+				byte[] md = mdTemp.digest();
+				int j = md.length;
+				char buf[] = new char[j * 2];
+				int k = 0;
+				for (int i = 0; i < j; i++) {
+					byte byte0 = md[i];
+					buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
+					buf[k++] = hexDigits[byte0 & 0xf];
+				}
+				return new String(buf);
+			} catch (Exception e) {
+				return null;
+			}
+		}
+}

+ 220 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/SignUtil.java

@@ -0,0 +1,220 @@
+package com.iamberry.wechat.tools;
+
+import java.io.ByteArrayOutputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * 请求校验工具类
+ * @author fzh
+ */
+public class SignUtil{
+	
+	/**
+	 * 验证签名
+	 * @param signature
+	 * @param timestamp
+	 * @param nonce
+	 * @return
+	 */
+	public static boolean checkSignature(String signature, String timestamp, String nonce, String token) {
+		String[] arr = new String[] { token, timestamp, nonce };
+		// 将token、timestamp、nonce三个参数进行字典序排序
+		Arrays.sort(arr);
+		StringBuilder content = new StringBuilder();
+		for (int i = 0; i < arr.length; i++) {
+			content.append(arr[i]);
+		}
+		MessageDigest md = null;
+		String tmpStr = null;
+
+		try {
+			md = MessageDigest.getInstance("SHA-1");
+			// 将三个参数字符串拼接成一个字符串进行sha1加密
+			byte[] digest = md.digest(content.toString().getBytes());
+			tmpStr = byteToStr(digest);
+		} catch (NoSuchAlgorithmException e) {
+			e.printStackTrace();
+		}
+
+		content = null;
+		// 将sha1加密后的字符串可与signature对比,标识该请求来源于微信
+		return tmpStr != null ? tmpStr.equals(signature.toUpperCase()) : false;
+	}
+
+	/**
+	 * md5加密
+	 * @param string
+	 */
+	public static String md5(String string){
+		String tmpStr = null;
+		MessageDigest md = null;
+		try {
+			md = MessageDigest.getInstance("SHA-1");
+			byte[] digest = md.digest(string.getBytes());
+			tmpStr = byteToStr(digest);
+		} catch (NoSuchAlgorithmException e) {
+			e.printStackTrace();
+		}
+		return tmpStr;
+	}
+	
+	/**
+	 * 参数按字典序排序
+	 * @param params
+	 * @return
+	 */
+	public static String sortParams(Object... params){
+		Arrays.sort(params);
+		StringBuilder content = new StringBuilder();
+		for (int i = 0; i < params.length; i++) {
+			content.append(params[i]).append(i==params.length-1?"=%s":"=%s&");
+		}
+		return content.toString();
+	}
+	
+	/**
+	 * 获取随机字串(16位)
+	 * @return
+	 */
+	public static String getNonceStr(){
+		String nonce_str = "";
+	    String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+	    int maxPos = chars.length();
+	    for (int i = 0; i < 16; i++){
+	       nonce_str += chars.charAt((int) Math.floor(Math.random() * maxPos));
+	    }
+	    return nonce_str;
+	}
+
+	/**
+	 * 获取时间戳
+	 * @return
+	 */
+	public static String getTimeStamp() {
+		return String.valueOf(System.currentTimeMillis() / 1000);
+	}
+	
+	/**
+	 * 将字节数组转换为十六进制字符串
+	 * @param byteArray
+	 * @return
+	 */
+	private static String byteToStr(byte[] byteArray) {
+		String strDigest = "";
+		for (int i = 0; i < byteArray.length; i++) {
+			strDigest += byteToHexStr(byteArray[i]);
+		}
+		return strDigest;
+	}
+
+	/**
+	 * 将字节转换为十六进制字符串
+	 * @param mByte
+	 * @return
+	 */
+	private static String byteToHexStr(byte mByte) {
+		char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+		char[] tempArr = new char[2];
+		tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
+		tempArr[1] = Digit[mByte & 0X0F];
+
+		String s = new String(tempArr);
+		return s;
+	}
+	
+	/*
+	* 16进制数字字符集
+	*/
+	private static String hexString = "0123456789ABCDEF"; //此处不可随意改动
+	
+	/*
+	* 将字符串编码成16进制数字 
+	*/
+	public static String encode(String str) {
+	   // 根据默认编码获取字节数组
+	   byte[] bytes = str.getBytes();
+	   StringBuilder sb = new StringBuilder(bytes.length * 2);
+	   // 将字节数组中每个字节拆解成2位16进制整数
+	   for (int i = 0; i < bytes.length; i++) {
+		    sb.append(hexString.charAt((bytes[i] & 0xf0) >> 4));
+		    sb.append(hexString.charAt((bytes[i] & 0x0f) >> 0));
+	   }
+	   return sb.toString();
+	}
+
+	/*
+	* 将16进制数字解码成字符串
+    */
+	public static String decode(String bytes) {
+	   ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length() / 2);
+	   // 将每2位16进制整数组装成一个字节
+	   for (int i = 0; i < bytes.length(); i += 2){
+		   baos.write((hexString.indexOf(bytes.charAt(i)) << 4 | hexString.indexOf(bytes.charAt(i + 1))));
+	   }
+	   return new String(baos.toByteArray());
+	}
+	
+	public static void main(String[] args) {
+		String string1 = "appid=%s&auth_code=%s&body=%s&device_info=%s&mch_id=%s&nonce_str=%s&out_trade_no=%s&spbill_create_ip=%s&total_fee=%s&key=%s";
+		String appid = "", auth_code = "", 
+				body = "", //商品描述
+				device_info = "", //设备号
+				mch_id = "", //商户号
+				nonce_str = "",
+				out_trade_no = "", //商户订单号
+				spbill_create_ip = "", //终端IP
+				total_fee = "", //总金额
+				key = "";
+		string1 = String.format(string1, appid, auth_code, body, device_info, mch_id, nonce_str, out_trade_no, spbill_create_ip, total_fee);
+		
+		String sign = MD5Util.MD5Encode(string1, "utf-8").toUpperCase();
+		System.out.println(sign);
+		
+		SortedMap<Object,Object> parameters = new TreeMap<Object,Object>();
+		parameters.put("appid", appid);
+		parameters.put("mch_id", mch_id);
+		parameters.put("nonce_str", nonce_str);
+		parameters.put("body", "LEO测试");
+		parameters.put("out_trade_no", out_trade_no);
+		parameters.put("total_fee", total_fee);
+		parameters.put("spbill_create_ip",spbill_create_ip);
+		parameters.put("notify_url", "");
+		parameters.put("trade_type", "JSAPI");
+		parameters.put("openid", "o7W6yt9DUOBpjEYogs4by1hD_OQE");
+		parameters.put("sign", sign);
+		String xml = getRequestXml(parameters);
+	}
+	
+	/**
+     * @Description:将请求参数转换为xml格式的string
+     * @param parameters  请求参数
+     * @return
+     */
+    @SuppressWarnings("rawtypes")
+	public static String getRequestXml(SortedMap<Object,Object> parameters){
+        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 k = (String)entry.getKey();
+            String v = (String)entry.getValue();
+            if ("attach".equalsIgnoreCase(k)||"body".equalsIgnoreCase(k)||"sign".equalsIgnoreCase(k)) {
+                sb.append("<"+k+">"+"<![CDATA["+v+"]]></"+k+">");
+            }else {
+                sb.append("<"+k+">"+v+"</"+k+">");
+            }
+        }
+        sb.append("</xml>");
+        return sb.toString();
+    }
+}
+

+ 66 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/StaticInfo.java

@@ -0,0 +1,66 @@
+package com.iamberry.wechat.tools;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.text.SimpleDateFormat;
+import java.util.regex.Pattern;
+
+import org.springframework.core.io.ClassPathResource;
+
+import com.iamberry.app.tool.des.MD5;
+
+/**
+ * @description 用于存放静态变量
+ * @author 欧阳明
+ * @date 2016-4-20
+ */
+public class StaticInfo {
+
+	public final static String SevenDay="7Day";
+	public final static String SixMon="6Mon";
+	public final static String Year="Year";
+	public static final MD5 md5 = new MD5("product5");
+	public static final MD5 orderIdMD5 = new MD5();
+	public final static String endDateC=" 23:59:59";
+	public final static Pattern pattern = Pattern.compile("[0-9]*");
+	public final static SimpleDateFormat dateFormat = new SimpleDateFormat("MMddHHmmss"); 
+	
+	/**
+	 *
+	 * 加载双向加密SSL KeyStory文件位置
+	 * 
+	 */
+	public static String resourceKey = "F:\\爱贝源-工作安排\\code\\iamberry\\build\\classes\\apiclient_cert.p12";	// 文件位置
+	public static File file = new File(getResourcekey());	// 保存文件
+	public static URL sslJksUrl = null;	// URL
+	public static KeyStore keyStore  = null; // key
+    static {
+    	try {
+			sslJksUrl = file.toURI().toURL();
+			keyStore = KeyStore.getInstance("PKCS12");
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+    }
+	public static String getResourcekey() {
+		if (resourceKey == null) {
+			ClassPathResource resource = new ClassPathResource("apiclient_cert.p12");
+			try {
+				resourceKey = URLDecoder.decode(resource.getFile().getAbsolutePath(), "UTF-8");
+			} catch (UnsupportedEncodingException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		return resourceKey;
+	}
+}

+ 61 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/StrUtils.java

@@ -0,0 +1,61 @@
+package com.iamberry.wechat.tools;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URLDecoder;
+import java.util.UUID;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 字符串工具类
+ * @author 穆再兴
+ * @author Administrator
+ *
+ */
+public class StrUtils {
+	public static String checkStr(Object obj){
+		if(obj == null){
+			return "";
+		}
+		return obj.toString();
+	}
+	
+	/**
+	 * 用流的方式获取post请求的参数字符串
+	 * create date 2016年6月1日
+	 * @author 穆再兴
+	 * @param req
+	 * @return
+	 */
+	public static String getPostParamsStr(HttpServletRequest req){
+		BufferedReader br = null;
+        String line = null;
+        StringBuffer sb = new StringBuffer();
+        String postParams = "";
+		try {
+			req.setCharacterEncoding("UTF-8");
+			br = new BufferedReader(new InputStreamReader(req.getInputStream()));
+			while ((line = br.readLine()) != null) {
+				line = URLDecoder.decode(line,"UTF-8");
+				sb.append(line);
+			}
+			postParams = sb.toString();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return postParams;
+	}
+	
+	/**
+	 * 获取 uuid字符串<32 位 >
+	 * @return
+	 */
+	public static synchronized String getUUID(){
+	    UUID uuid=UUID.randomUUID();
+	    String str = uuid.toString(); 
+	    String uuidStr=str.replace("-", "");
+	    return uuidStr;
+	}
+}

+ 179 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/TenpayUtil.java

@@ -0,0 +1,179 @@
+package com.iamberry.wechat.tools;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.SortedMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+public class TenpayUtil {
+	
+	private static Object Server;
+	@SuppressWarnings("unused")
+	private static String QRfromGoogle;
+
+	/**
+	 * 把对象转换成字符串
+	 * @param obj
+	 * @return String 转换成字符串,若对象为null,则返回空字符串.
+	 */
+	public static String toString(Object obj) {
+		if(obj == null)
+			return "";
+		
+		return obj.toString();
+	}
+	
+	/**
+	 * 把对象转换为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));
+	}
+	
+	/**
+	 * 获取编码字符集
+	 * @param request
+	 * @param response
+	 * @return String
+	 */
+
+	public static String getCharacterEncoding(HttpServletRequest request,
+			HttpServletResponse response) {
+		
+		if(null == request || null == response) {
+			return "gbk";
+		}
+		
+		String enc = request.getCharacterEncoding();
+		if(null == enc || "".equals(enc)) {
+			enc = response.getCharacterEncoding();
+		}
+		
+		if(null == enc || "".equals(enc)) {
+			enc = "gbk";
+		}
+		
+		return enc;
+	}
+	
+	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);
+	}
+	
+	/**
+	 * 根据字典排序后的SortMap参数按照key=value的格式生成
+	 * @param signParams
+	 * @return
+	 */
+	public static String getKeyValue(SortedMap<String, String> signParams) {
+		StringBuffer sb = new StringBuffer();
+		for (Map.Entry<String, String> entry : signParams.entrySet()) {
+			if (entry.getValue() != null || !entry.getValue().isEmpty()) {//不为空的参数才参与签名
+				sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&");				
+			}
+		}
+		String params = null;
+		if (sb.length() > 0) {
+			params = sb.substring(0, sb.lastIndexOf("&"));
+		}
+		return params;
+	}
+	
+	
+}

+ 175 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/TextFilterUtil.java

@@ -0,0 +1,175 @@
+package com.iamberry.wechat.tools;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.springframework.stereotype.Component;
+
+
+@Component("textFilterUtil")
+public class TextFilterUtil {
+
+	//默认编码格式
+	  private static final String ENCODING = "utf-8";
+	  //敏感词库的路径
+	  private static final InputStream in = TextFilterUtil.class.getClassLoader().getResourceAsStream("keyWords.txt");
+	 /* private static final InputStream in2 =new FileInputStream(new File("D:/sensitive/keyWords.txt"));
+	  InputStreamReader lw=new InputStreamReader("D:/sensitive/keyWords.txt",ENCODING);*/
+	 /*try{
+		 InputStream in2 = new FileInputStream("D:\\demo.txt");//读取文件的数据。
+	 }catch(Exception ex){
+		 
+	 }*/
+	  
+	  //脏字库
+	  private static Set<Character> sensitiveCharSet = null;
+	  //敏感词库
+	  private static Set<String> sensitiveWordSet = null;
+	  /**
+	   * 初始化敏感词库
+	   */
+	  private static void init() {
+	    //初始化容器
+	    sensitiveCharSet = new HashSet<>();
+	    sensitiveWordSet = new HashSet<>();
+	    //读取文件 创建敏感词库
+	    readSensitiveWords();
+	  }
+	  /**
+	   * 读取本地的敏感词文件
+	   *
+	   * @return
+	   */
+	  public static void readSensitiveWords() {
+		  if(sensitiveWordSet!=null){
+			  return;
+		  }
+	    BufferedReader reader = null;
+	    sensitiveWordSet=new HashSet();
+	    sensitiveCharSet=new HashSet();
+	    try {
+	      //reader = new BufferedReader(new InputStreamReader(new FileInputStream("E:\\KeyWords.txt"), "utf-8"));
+	      reader = new BufferedReader(new InputStreamReader(in, "utf-8"));
+	      String line;
+	      while ((line = reader.readLine()) != null) {
+	        String word = line.trim();
+	       // System.out.println("nn:"+word);
+	        String[] aa = word.split("\\|");
+	        if(aa.length>0){
+	        	 for(String st:aa){
+	 	        	sensitiveWordSet.add(st);
+	 	        }
+	        }
+	        for (Character c : word.toCharArray()) {
+	        	if(c.equals("|")){
+	        		continue;
+	        	}
+	          sensitiveCharSet.add(c);
+	        }
+	      }
+	    } catch (UnsupportedEncodingException e) {
+	      System.out.println("敏感词库文件转码失败!");
+	    } catch (FileNotFoundException e) {
+	    	System.out.println("敏感词库文件不存在!");
+	    } catch (IOException e) {
+	    	System.out.println("敏感词库文件读取失败!");
+	    } finally {
+	      if (reader != null) {
+	        try {
+	          reader.close();
+	        } catch (IOException e) {
+	          e.printStackTrace();
+	        }
+	        reader = null;
+	      }
+	    }
+	    return;
+	  }
+	  /**
+	   * 检查敏感词
+	   *
+	   * @return
+	   */
+	  public static List<String> checkSensitiveWord(String text) {
+	    if (sensitiveWordSet == null || sensitiveCharSet == null) {
+	      init();
+	    }
+	    List<String> sensitiveWords = new ArrayList<>();
+	    for (int i = 0; i < text.length(); i++) {
+	      Character word = text.charAt(i);
+	      if (!sensitiveCharSet.contains(word)) {
+	        continue;
+	      }
+	      int j = i;
+	      while (j < text.length()) {
+	        if (!sensitiveCharSet.contains(word)) {
+	          break;
+	        }
+	        String key = text.substring(i, j + 1);
+	        if (sensitiveWordSet.contains(key)) {
+	          sensitiveWords.add(key);
+	        }
+	        j++;
+	      }
+	    }
+	    return sensitiveWords;
+	  }
+	
+	  /**
+	   * 替换敏感词为**
+	   *
+	   * @return
+	   */
+	  public static String checkAndReplaceSensitiveWord(String text) {
+	    if (sensitiveWordSet == null || sensitiveCharSet == null) {
+	      init();
+	    }
+
+	    for (int i = 0; i < text.length(); i++) {
+	      Character word = text.charAt(i);
+	      if (!sensitiveCharSet.contains(word)) {
+	        continue;
+	      }
+	      int j = i;
+	      while (j < text.length()) {
+	        if (!sensitiveCharSet.contains(word)) {
+	          break;
+	        }
+	        String key = text.substring(i, j + 1);
+	        if (sensitiveWordSet.contains(key)) {
+	          text=text.replace(key, "**");
+	        }
+	        j++;
+	      }
+	    }
+	    return text;
+	  }
+	  
+
+//	public static void main(String[] args) throws ParseException {
+//	
+//		String str="他妈的日本鬼子,都是干嘛混的!你就知道牛逼哄哄的,是不是";
+//		readSensitiveWords();
+//		List<String> list=checkSensitiveWord(str);
+//		
+//		for(String len:list){
+//			System.out.println(len);
+//		}
+//		System.out.println("================================");
+//		System.out.println(checkAndReplaceSensitiveWord(str));
+//	}
+}
+
+
+

+ 156 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ToolsUtils.java

@@ -0,0 +1,156 @@
+package com.iamberry.wechat.tools;
+
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ToolsUtils {
+	
+	public static boolean isNotEmpty(Object obj){
+		if(null == obj){
+			return false;
+		} else if(obj instanceof String){
+			if("".equals(((String)obj).trim()) || "null".equals(((String)obj).trim())){
+				return false;
+			}
+		}
+		return true;
+	}
+	
+	public static String dateToString(Date date){
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		return sdf.format(date);
+	}
+	
+	public static String dateToStringFull(Date date){
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		return sdf.format(date);
+	}
+	
+	public static Date stringToDateFull(String datestr) throws ParseException{
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		return sdf.parse(datestr);
+	}
+	
+	public static Double Double2point(Double d){
+		if(d != null){
+			DecimalFormat df=new DecimalFormat(".##");
+			String st=df.format(d);
+			d = Double.parseDouble(st);
+		}else{
+			d = 0.00;
+		}
+		return d;
+	}
+	//商品满多少减多少优惠
+	public static Map<String, Object> getSumtotal100(Integer cardmember,Double tota,Double rate,Double pos,Double sumTotal,Double tota1,Double pos1,String loop){
+		Map<String, Object> map = new HashMap<String, Object>(); 
+		if("y".equals(loop.trim())){
+			if(cardmember != null && cardmember == 101){
+				if(sumTotal > 0 && sumTotal < tota){
+					sumTotal = sumTotal * rate + pos;
+					map.put("flag", "Y");
+				}else if(sumTotal >= tota && sumTotal < tota1 ){
+					sumTotal = sumTotal * rate;
+				}else{
+					int n = (int) (sumTotal/tota1);
+					sumTotal = (sumTotal - n * pos1) * rate;
+				}
+			}else{
+				if(sumTotal > 0 && sumTotal < tota){
+					sumTotal = sumTotal + pos;
+					map.put("flag", "Y");
+				}else if(sumTotal >= tota && sumTotal < tota1 ){
+				}else{
+					int n = (int) (sumTotal/tota1);
+					sumTotal = sumTotal - n * pos1;
+				}
+			}
+		}else{
+			if(cardmember != null && cardmember == 101){
+				if(sumTotal > 0 && sumTotal < tota){
+					sumTotal = sumTotal * rate + pos;
+					map.put("flag", "Y");
+				}else if(sumTotal >= tota && sumTotal < tota1 ){
+					sumTotal = sumTotal * rate;
+				}else{
+					sumTotal = (sumTotal - pos1) * rate;
+				}
+			}else{
+				if(sumTotal > 0 && sumTotal < tota){
+					sumTotal = sumTotal + pos;
+					map.put("flag", "Y");
+				}else if(sumTotal >= tota && sumTotal < tota1 ){
+				}else{
+					sumTotal = sumTotal - pos1;
+				}
+			}
+		}
+		map.put("sumTotal", sumTotal);
+		return map;
+	}
+	
+	
+	//商品总价打七折优惠   显示
+	public static Map<String, Object> getSumtotal(Integer cardmember,Double tota,Double rate,Double pos,Double sumTotal){
+		/*if(sumTotal > 0 && sumTotal < tota){
+			sumTotal = sumTotal * rate + pos;
+		}else{
+			sumTotal = sumTotal * rate;
+		}
+		return sumTotal;*/
+		Map<String, Object> map = new HashMap<String, Object>(); 
+		if(sumTotal > 0 && sumTotal < tota){
+			sumTotal = sumTotal * rate + pos;
+			map.put("flag", "Y");
+		}else{
+			sumTotal = sumTotal * rate;
+			if(sumTotal < tota){
+				sumTotal = sumTotal + pos;
+				map.put("flag", "Y");
+			}
+		}
+		map.put("sumTotal", sumTotal);
+		return map;
+	}
+	
+	//商品总价打七折优惠   计算
+	public static Double getSumtotal1(Integer cardmember,Double tota,Double rate,Double pos,Double sumTotal){
+		sumTotal = sumTotal * rate;
+		return sumTotal;
+	}
+	//内部8折优惠   显示页面
+	public static Map<String, Object> getSumtotal2(Integer cardmember,Double tota,Double rate,Double pos,Double sumTotal){
+		Map<String, Object> map = new HashMap<String, Object>(); 
+		if(cardmember != null && cardmember == 0){
+			if(sumTotal > 0 && sumTotal < tota){
+				sumTotal = sumTotal * rate + pos;
+				map.put("flag", "Y");
+			}else{
+				sumTotal = sumTotal * rate;
+				if(sumTotal < tota){
+					sumTotal = sumTotal + pos;
+					map.put("flag", "Y");
+				}
+			}
+		}else{
+			if(sumTotal > 0 && sumTotal < tota){
+				sumTotal = sumTotal + pos;
+				map.put("flag", "Y");
+			}
+		}
+		map.put("sumTotal", sumTotal);
+		return map;
+	}
+	//内部8折优惠   计算
+	public static Double getSumtotal3(Integer cardmember,Double tota,Double rate,Double pos,Double sumTotal){
+		//计算会员等级为0的支付价格
+		if(cardmember != null && cardmember == 0){
+			sumTotal = sumTotal * rate;
+		}
+		return sumTotal;
+	}
+}

+ 23 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/UUIDGenerator.java

@@ -0,0 +1,23 @@
+package com.iamberry.wechat.tools;
+
+import java.util.UUID;
+
+/**
+ * @description 用于生成唯一键
+ * @author 欧阳明
+ * @date 2016-4-20
+ */
+public class UUIDGenerator {
+
+	public UUIDGenerator() {  
+    }  
+  
+    public static String getUUID() {  
+        UUID uuid = UUID.randomUUID();  
+        String str = uuid.toString();  
+        // 去掉"-"符号  
+        String temp = str.substring(0, 8) + str.substring(9, 13) + str.substring(14, 18) + str.substring(19, 23) + str.substring(24);  
+        return temp;  
+    }  
+	
+}

+ 153 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidateUtil.java

@@ -0,0 +1,153 @@
+package com.iamberry.wechat.tools;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+/**
+ * @author 何秀刚
+ * Class Description: 校验规则
+ * Create Date:2016年5月3日
+ * Update Date:2016年5月3日
+ */
+public class ValidateUtil {
+
+    /**
+     * 6~16位字符,至少包含数字、大写字母、小写字母、符号中的两种
+     * http://www.docin.com/p-835484940.html
+     * @param value
+     * @return
+     */
+	public static boolean checkPwd(String value) {
+        return value.matches("(?!^[0-9]+$)(?!^[A-Z]+$)(?!^[a-z]+$)(?!^[^A-z0-9]+$)^.{6,16}");
+    }
+
+    public static void main(String[] args) {
+        System.out.println("asdAdss".matches("(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{6,16}"));
+        System.out.println(checkPwd("abc1234"));
+        System.out.println(checkPwd("Abc12s3"));
+        System.out.println(checkPwd("Abc1234"));
+    }
+
+    /**
+     * 验证交易密码
+     * @param value
+     * @return
+     */
+    public static boolean checkTradePwd(String value) {
+        return value.matches("[0-9]{6}");
+    }
+
+    public static boolean checkEmail(String value, int length) {
+        return value.matches("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")
+                && value.length() <= length;
+    }
+
+    /**
+     * 检查电话输入 是否正确
+     * 正确格 式 012-87654321、0123-87654321、0123-7654321
+     * @param value
+     * @return
+     */
+    public static boolean checkTel(String value) {
+        return value.matches("\\d{4}-\\d{8}|\\d{4}-\\d{7}|\\d(3)-\\d(8)");
+    }
+
+    /**
+     * 检查手机输入 是否正确
+     *
+     * @param value
+     * @return
+     */
+    public static boolean checkMobile(String value) {
+        return value.matches("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
+    }
+
+    /**
+     * 检查字符串是 否含有HTML标签
+     * @param value
+     * @return
+     */
+
+    public static boolean checkHtmlTag(String value) {
+        return value.matches("<(\\S*?)[^>]*>.*?</\\1>|<.*? />");
+    }
+
+    /**
+     * 检查URL是 否合法
+     * @param value
+     * @return
+     */
+    public static boolean checkURL(String value) {
+        return value.matches("[a-zA-z]+://[^\\s]*");
+    }
+
+    /**
+     * 检查IP是否 合法
+     * @param value
+     * @return
+     */
+    public static boolean checkIP(String value) {
+        return value.matches("\\d{1,3}+\\.\\d{1,3}+\\.\\d{1,3}+\\.\\d{1,3}");
+    }
+
+    /**
+     * 检查QQ是否 合法,必须是数字,且首位不能为0,最长15位
+     * @param value
+     * @return
+     */
+
+    public static boolean checkQQ(String value) {
+        return value.matches("[1-9][0-9]{4,13}");
+    }
+
+    /**
+     * 检查邮编是否 合法
+     * @param value
+     * @return
+     */
+    public static boolean checkPostCode(String value) {
+        return value.matches("[1-9]\\d{5}(?!\\d)");
+    }
+
+    /**
+     * 检查身份证是 否合法,15位或18位
+     * @param number
+     * @return
+     */
+    public static boolean checkIDCard(String number)
+    {
+        String rgx = "^\\d{15}|^\\d{17}([0-9]|X|x)$";
+
+        return isCorrect(rgx, number);
+    }
+
+    //正则验证
+    public static boolean isCorrect(String rgx, String res)
+    {
+        Pattern p = Pattern.compile(rgx);
+
+        Matcher m = p.matcher(res);
+
+        return m.matches();
+    }
+    /**
+     * 检查输入是否 超出规定长度
+     * Java教程:http://www.javaweb.cc
+     * @param length
+     * @param value
+     * @return
+     */
+    public static boolean checkLength(String value, int length) {
+        return ((value == null || "".equals(value.trim())) ? 0 : value.length()) <= length;
+    }
+
+    /**
+     * 检查是否为空 字符串,空:true,不空:false
+     *
+     * @param value
+     * @return
+     */
+    public static boolean checkNull(String value) {
+        return value == null || "".equals(value.trim());
+    }
+
+}

+ 47 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidationResult.java

@@ -0,0 +1,47 @@
+package com.iamberry.wechat.tools;
+
+import java.util.List;
+import java.util.Map;
+
+public class ValidationResult {
+
+	//校验结果是否有错
+	  private boolean hasErrors;
+	  
+	  //校验错误信息
+	  private Map<String,String> errorMsg;
+	   
+	  private List<String> errorMsgList;
+
+	  public boolean isHasErrors() {
+	    return hasErrors;
+	  }
+
+	  public void setHasErrors(boolean hasErrors) {
+	    this.hasErrors = hasErrors;
+	  }
+
+	  public Map<String, String> getErrorMsg() {
+	    return errorMsg;
+	  }
+
+	  public void setErrorMsg(Map<String, String> errorMsg) {
+	    this.errorMsg = errorMsg;
+	  }
+
+	  @Override
+	  public String toString() {
+	    return "ValidationResult [hasErrors=" + hasErrors + ", errorMsg="
+	        + errorMsg + "]";
+	  }
+
+	public List<String> getErrorMsgList() {
+		return errorMsgList;
+	}
+
+	public void setErrorMsgList(List<String> errorMsgList) {
+		this.errorMsgList = errorMsgList;
+	}
+	  
+	  
+}

+ 53 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidationUtils.java

@@ -0,0 +1,53 @@
+package com.iamberry.wechat.tools;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.groups.Default;
+
+/**
+ * @description 通过hibernate组件效验对象
+ * @author 欧阳明
+ * @date 2016-4-21
+ */
+public class ValidationUtils {
+
+	private static Validator validator =  Validation.buildDefaultValidatorFactory().getValidator();
+	  
+	  public static <T> ValidationResult validateEntity(T obj){
+	    ValidationResult result = new ValidationResult();
+	    List<String> errorList=new ArrayList<String>();
+	     Set<ConstraintViolation<T>> set = validator.validate(obj,Default.class);
+	     if( set.size()>0 ){
+	       result.setHasErrors(true);
+	       Map<String,String> errorMsg = new HashMap<String,String>();
+	       for(ConstraintViolation<T> cv : set){
+	         errorMsg.put(cv.getPropertyPath().toString(), cv.getMessage());
+	         errorList.add(cv.getMessage());
+	       }
+	       result.setErrorMsg(errorMsg);
+	       result.setErrorMsgList(errorList);
+	     }
+	     return result;
+	  }
+	  
+	  public static <T> ValidationResult validateProperty(T obj,String propertyName){
+	    ValidationResult result = new ValidationResult();
+	     Set<ConstraintViolation<T>> set = validator.validateProperty(obj,propertyName,Default.class);
+	     if(set.size()>0){
+	       result.setHasErrors(true);
+	       Map<String,String> errorMsg = new HashMap<String,String>();
+	       for(ConstraintViolation<T> cv : set){
+	         errorMsg.put(propertyName, cv.getMessage());
+	       }
+	       result.setErrorMsg(errorMsg);
+	     }
+	     return result;
+	  }
+}

+ 45 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidatorInterface.java

@@ -0,0 +1,45 @@
+package com.iamberry.wechat.tools;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+/**
+ * @author 何秀刚
+ * Introduction to the : 校验的注解标识
+ * create date: 2016年1月12日
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface ValidatorInterface {
+	
+	/**
+	 * 校验当前字段和指定字段是否一致
+	 * @return
+	 */
+	String equalsOtherField() default "";
+	
+	/**
+	 * 效验是否为空
+	 * @return
+	 */
+	String isNotNull() default "true";
+	
+	/**
+	 * 校验某个字段是否复合传输的规则
+	 * @return
+	 */
+	String validatorIsRule() default "";
+	
+	/**
+	 * 校验字符串长度
+	 */
+	int [] fieldLengthScope() default {-1, -1};
+	
+	/**
+	 * 是否启用本注解, true启动,false不启用
+	 */
+	boolean isEnable() default false;
+	
+}

+ 124 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidatorUtil.java

@@ -0,0 +1,124 @@
+package com.iamberry.wechat.tools;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * @author 何秀刚
+ * Introduction to the : 校验工具类
+ * create date: 2016年1月12日
+ */
+@Component
+public class ValidatorUtil {
+	
+	/**
+	 * 注解校验使用了@ValidatorInterface的实体类
+	 * @param obj
+	 * @return
+	 */
+	@SuppressWarnings(value = {"unchecked", "rawtypes"})
+	public boolean validatorObject(Object obj) {
+		if (obj == null) {
+			return false;
+		}
+		try {
+			//类加载
+			Class c = obj.getClass();
+			// 获取c是否使用ValidatorInterface这个注解
+			boolean flag = c.isAnnotationPresent(ValidatorInterface.class);
+			//判断是否注解了
+			if (flag) {
+				return false;
+			}
+			Field[] fields = c.getDeclaredFields();
+			for (Field field : fields) {
+				ValidatorInterface interface1 = field.getAnnotation(ValidatorInterface.class);
+				if (interface1 == null) {
+					continue;
+				}
+				if (!interface1.isEnable()) {
+					continue;
+				}
+				// 校验一个字段和其他字段
+				if (!interface1.equalsOtherField().isEmpty()) {
+					Field field2 = c.getDeclaredField(interface1.equalsOtherField());
+					if (field2 == null) {
+						return false;
+					}
+					// 注解属性的value
+					String method = "get" + captureName(field.getName());
+					Method m1 = c.getDeclaredMethod(method);
+					Object object1 = m1.invoke(obj);
+					if (object1 == null) {
+						return false;
+					}
+					// 需要匹配的值
+					method = "get" + captureName(field2.getName());
+					Method m2 = c.getDeclaredMethod(method);
+					Object object2 = m2.invoke(obj);
+					if (object2 == null) {
+						return false;
+					}
+					if (!object1.equals(object2)) {
+						return false;
+					}
+				}
+				// 校验字段长度范围
+				if (interface1.fieldLengthScope()[0] != interface1.fieldLengthScope()[1]) {
+					String method = "get" + captureName(field.getName());
+					Method m2 = c.getDeclaredMethod(method);
+					Object object2 = m2.invoke(obj);
+					if (object2 == null) {
+						return false;
+					}
+					if (!(object2 instanceof String)) {
+						return false;
+					}
+					int length = ((String) object2).length();
+					if (!(length >= interface1.fieldLengthScope()[0] && length <= interface1.fieldLengthScope()[1])) {
+						return false;
+					}
+					System.out.println("true");
+				}
+				// 需要根据正则校验字段
+				if (!interface1.validatorIsRule().isEmpty()) {
+					String method = "get" + captureName(field.getName());
+					Method m2 = c.getDeclaredMethod(method);
+					Object object2 = m2.invoke(obj);
+					if (object2 == null) {
+						return false;
+					}
+					if (!(object2 instanceof String)) {
+						return false;
+					}
+					Pattern pattern = Pattern.compile(interface1.validatorIsRule());
+					Matcher matcher = pattern.matcher((String)object2);
+					if (!matcher.find()) {
+						return false;
+					}
+				}
+			}
+			return true;
+		} catch (Exception e) {
+			return false;
+		}
+	}
+	
+	public String captureName(String name) {
+		if (!Character.isLowerCase(name.charAt(0))) {
+			return name;
+		}
+		char[] cs=name.toCharArray();
+		cs[0]-=32;
+		return String.valueOf(cs);
+	}
+
+	public static boolean isEmptyIgnoreBlank(String str){
+		if(str == null || "".equals(str) || "".equals(str.trim()))
+			return true;
+		return false;
+	}
+}

+ 157 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/ValidatorUtil2Map.java

@@ -0,0 +1,157 @@
+package com.iamberry.wechat.tools;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * @author 何秀刚
+ * Introduction to the : 校验工具类
+ * create date: 2016年1月12日
+ */
+@Component
+public class ValidatorUtil2Map {
+	
+	/**
+	 * 注解校验使用了@ValidatorInterface的实体类
+	 * @param obj
+	 * @return
+	 */
+	@SuppressWarnings(value = {"unchecked", "rawtypes"})
+	public Map validatorObject(Object obj) {
+		HashMap<String,Object> resultMap=new HashMap<String,Object>();
+		resultMap.put("result","true");
+		ArrayList al=new ArrayList();
+		if (obj == null) {
+			return null;
+		}
+		try {
+			//类加载
+			Class c = obj.getClass();
+			// 获取c是否使用ValidatorInterface这个注解
+			boolean flag = c.isAnnotationPresent(ValidatorInterface.class);
+			//判断是否注解了
+			if (flag) {
+				return null;
+			}
+			Field[] fields = c.getDeclaredFields();
+			for (Field field : fields) {
+				ValidatorInterface interface1 = field.getAnnotation(ValidatorInterface.class);
+				if (interface1 == null) {
+					continue;
+				}
+				if (!interface1.isEnable()) {
+					continue;
+				}
+				// 校验一个字段和其他字段
+				if (!interface1.equalsOtherField().isEmpty()) {
+					Field field2 = c.getDeclaredField(interface1.equalsOtherField());
+					if (field2 == null) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"找不到匹配的值");
+					}
+					// 注解属性的value
+					String method = "get" + captureName(field.getName());
+					Method m1 = c.getDeclaredMethod(method);
+					Object object1 = m1.invoke(obj);
+					if (object1 == null) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"找不到匹配的值");
+					}
+					// 需要匹配的值
+					method = "get" + captureName(field2.getName());
+					Method m2 = c.getDeclaredMethod(method);
+					Object object2 = m2.invoke(obj);
+					if (object2 == null) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"找不到匹配的值");
+					}
+					if (!object1.equals(object2)) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"找不到匹配的值");
+					}
+				}
+				// 校验字段长度范围
+				if (interface1.fieldLengthScope()[0] != interface1.fieldLengthScope()[1]) {
+					String method = "get" + captureName(field.getName());
+					Method m2 = c.getDeclaredMethod(method);
+					Object object2 = m2.invoke(obj);
+					if (object2 == null) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"长度不能为空!");
+					}
+					if (!(object2 instanceof String)) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"不是字符串!");
+					}
+					int length = ((String) object2).length();
+					if (!(length >= interface1.fieldLengthScope()[0] && length <= interface1.fieldLengthScope()[1])) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"长度不能超过指定范围");
+					}
+					System.out.println("true");
+				}
+				// 需要根据正则校验字段
+				if (!interface1.validatorIsRule().isEmpty()) {
+					String method = "get" + captureName(field.getName());
+					Method m2 = c.getDeclaredMethod(method);
+					Object object2 = m2.invoke(obj);
+					if (object2 == null) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"不能为空");
+					}
+					
+					Pattern pattern = Pattern.compile(interface1.validatorIsRule());
+					Matcher matcher = null;
+					
+					if (!(object2 instanceof String)) {
+						matcher = pattern.matcher(String.valueOf(object2));
+					}else{
+						matcher = pattern.matcher((String)object2);
+					}
+				
+					if (!matcher.find()) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"格式不正确,请确认");
+					}
+				}
+				//检查是否为空
+				if (!interface1.isNotNull().isEmpty()) {
+					String method = "get" + captureName(field.getName());
+					Method m2 = c.getDeclaredMethod(method);
+					Object object2 = m2.invoke(obj);
+					if (object2 == null) {
+						resultMap.put("result","false");
+						al.add(field.getName()+"不能为空");
+					}
+				}
+				
+			}
+			resultMap.put("message",al);
+			return resultMap;
+		} catch (Exception e) {
+			resultMap.put("result","false");
+			return resultMap;
+		}
+	}
+	
+	public String captureName(String name) {
+		if (!Character.isLowerCase(name.charAt(0))) {
+			return name;
+		}
+		char[] cs=name.toCharArray();
+		cs[0]-=32;
+		return String.valueOf(cs);
+	}
+
+	public static boolean isEmptyIgnoreBlank(String str){
+		if(str == null || "".equals(str) || "".equals(str.trim()))
+			return true;
+		return false;
+	}
+}

+ 84 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/WxPayDto.java

@@ -0,0 +1,84 @@
+package com.iamberry.wechat.tools;
+public class WxPayDto {
+
+	private String orderId;//订单号
+	private String totalFee;//金额
+	private String spbillCreateIp;//订单生成的机器 IP
+	private String notifyUrl;//这里notify_url是 支付完成后微信发给该链接信息,可以判断会员是否支付成功,改变订单状态等
+	private String body;// 商品描述根据情况修改
+	private String openId;//微信用户对一个公众号唯一
+	
+	/**
+	 * @return the orderId
+	 */
+	public String getOrderId() {
+		return orderId;
+	}
+	/**
+	 * @param orderId the orderId to set
+	 */
+	public void setOrderId(String orderId) {
+		this.orderId = orderId;
+	}
+	/**
+	 * @return the totalFee
+	 */
+	public String getTotalFee() {
+		return totalFee;
+	}
+	/**
+	 * @param totalFee the totalFee to set
+	 */
+	public void setTotalFee(String totalFee) {
+		this.totalFee = totalFee;
+	}
+	/**
+	 * @return the spbillCreateIp
+	 */
+	public String getSpbillCreateIp() {
+		return spbillCreateIp;
+	}
+	/**
+	 * @param spbillCreateIp the spbillCreateIp to set
+	 */
+	public void setSpbillCreateIp(String spbillCreateIp) {
+		this.spbillCreateIp = spbillCreateIp;
+	}
+	/**
+	 * @return the notifyUrl
+	 */
+	public String getNotifyUrl() {
+		return notifyUrl;
+	}
+	/**
+	 * @param notifyUrl the notifyUrl to set
+	 */
+	public void setNotifyUrl(String notifyUrl) {
+		this.notifyUrl = notifyUrl;
+	}
+	/**
+	 * @return the body
+	 */
+	public String getBody() {
+		return body;
+	}
+	/**
+	 * @param body the body to set
+	 */
+	public void setBody(String body) {
+		this.body = body;
+	}
+	/**
+	 * @return the openId
+	 */
+	public String getOpenId() {
+		return openId;
+	}
+	/**
+	 * @param openId the openId to set
+	 */
+	public void setOpenId(String openId) {
+		this.openId = openId;
+	}
+	
+}

+ 233 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/WxPayResult.java

@@ -0,0 +1,233 @@
+package com.iamberry.wechat.tools;
+
+/**
+ * description: 微信支付回调
+ * @author 
+ * @since 
+ * @see
+ */
+public class WxPayResult {
+	
+	private String attach;
+	private String appid;
+	private String bankType;
+	private String cashFee;
+	private String feeType;
+	private String isSubscribe;
+	private String mchId;
+	private String nonceStr;
+	private String openid;
+	private String outTradeNo;
+	private String resultCode;
+	private String returnCode;
+	private String sign;
+	private String timeEnd;
+	private String totalFee;
+	private String tradeType;
+	private String transactionId;
+   
+	
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -1227026039888867970L;
+	
+	public String getAttach() {
+		return attach;
+	}
+	public void setAttach(String attach) {
+		this.attach = attach;
+	}
+	/**
+	 * @return the appid
+	 */
+	public String getAppid() {
+		return appid;
+	}
+	/**
+	 * @param appid the appid to set
+	 */
+	public void setAppid(String appid) {
+		this.appid = appid;
+	}
+	/**
+	 * @return the bankType
+	 */
+	public String getBankType() {
+		return bankType;
+	}
+	/**
+	 * @param bankType the bankType to set
+	 */
+	public void setBankType(String bankType) {
+		this.bankType = bankType;
+	}
+	/**
+	 * @return the cashFee
+	 */
+	public String getCashFee() {
+		return cashFee;
+	}
+	/**
+	 * @param cashFee the cashFee to set
+	 */
+	public void setCashFee(String cashFee) {
+		this.cashFee = cashFee;
+	}
+	/**
+	 * @return the feeType
+	 */
+	public String getFeeType() {
+		return feeType;
+	}
+	/**
+	 * @param feeType the feeType to set
+	 */
+	public void setFeeType(String feeType) {
+		this.feeType = feeType;
+	}
+	/**
+	 * @return the isSubscribe
+	 */
+	public String getIsSubscribe() {
+		return isSubscribe;
+	}
+	/**
+	 * @param isSubscribe the isSubscribe to set
+	 */
+	public void setIsSubscribe(String isSubscribe) {
+		this.isSubscribe = isSubscribe;
+	}
+	/**
+	 * @return the mchId
+	 */
+	public String getMchId() {
+		return mchId;
+	}
+	/**
+	 * @param mchId the mchId to set
+	 */
+	public void setMchId(String mchId) {
+		this.mchId = mchId;
+	}
+	/**
+	 * @return the nonceStr
+	 */
+	public String getNonceStr() {
+		return nonceStr;
+	}
+	/**
+	 * @param nonceStr the nonceStr to set
+	 */
+	public void setNonceStr(String nonceStr) {
+		this.nonceStr = nonceStr;
+	}
+	/**
+	 * @return the openid
+	 */
+	public String getOpenid() {
+		return openid;
+	}
+	/**
+	 * @param openid the openid to set
+	 */
+	public void setOpenid(String openid) {
+		this.openid = openid;
+	}
+	/**
+	 * @return the outTradeNo
+	 */
+	public String getOutTradeNo() {
+		return outTradeNo;
+	}
+	/**
+	 * @param outTradeNo the outTradeNo to set
+	 */
+	public void setOutTradeNo(String outTradeNo) {
+		this.outTradeNo = outTradeNo;
+	}
+	/**
+	 * @return the resultCode
+	 */
+	public String getResultCode() {
+		return resultCode;
+	}
+	/**
+	 * @param resultCode the resultCode to set
+	 */
+	public void setResultCode(String resultCode) {
+		this.resultCode = resultCode;
+	}
+	/**
+	 * @return the returnCode
+	 */
+	public String getReturnCode() {
+		return returnCode;
+	}
+	/**
+	 * @param returnCode the returnCode to set
+	 */
+	public void setReturnCode(String returnCode) {
+		this.returnCode = returnCode;
+	}
+	/**
+	 * @return the sign
+	 */
+	public String getSign() {
+		return sign;
+	}
+	/**
+	 * @param sign the sign to set
+	 */
+	public void setSign(String sign) {
+		this.sign = sign;
+	}
+	/**
+	 * @return the timeEnd
+	 */
+	public String getTimeEnd() {
+		return timeEnd;
+	}
+	/**
+	 * @param timeEnd the timeEnd to set
+	 */
+	public void setTimeEnd(String timeEnd) {
+		this.timeEnd = timeEnd;
+	}
+	/**
+	 * @return the totalFee
+	 */
+	public String getTotalFee() {
+		return totalFee;
+	}
+	/**
+	 * @param totalFee the totalFee to set
+	 */
+	public void setTotalFee(String totalFee) {
+		this.totalFee = totalFee;
+	}
+	/**
+	 * @return the tradeType
+	 */
+	public String getTradeType() {
+		return tradeType;
+	}
+	/**
+	 * @param tradeType the tradeType to set
+	 */
+	public void setTradeType(String tradeType) {
+		this.tradeType = tradeType;
+	}
+	/**
+	 * @return the transactionId
+	 */
+	public String getTransactionId() {
+		return transactionId;
+	}
+	/**
+	 * @param transactionId the transactionId to set
+	 */
+	public void setTransactionId(String transactionId) {
+		this.transactionId = transactionId;
+	}
+}

+ 272 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/WxPayUtil.java

@@ -0,0 +1,272 @@
+package com.iamberry.wechat.tools;
+
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.iamberry.app.tool.des.MD5;
+import com.iamberry.app.tool.log.RatFWLogger;
+
+
+/**
+ * 支付核心类
+ */
+@Component
+public class WxPayUtil {
+	//微信支付商户开通后 微信会提供appid和appsecret和商户号partner
+	public String appid = NameUtils.appId;
+	public String appsecret = NameUtils.appSecret;
+	public String partner = NameUtils.partner;
+	//这个参数partnerkey是在商户后台配置的一个32位的key,微信商户平台-账户设置-安全设置-api安全
+	public String partnerkey = NameUtils.partnerkey;
+	//public static String openId = "oE5vNvk_xqtNgDORneoz3b6Dw7RU";
+	//微信支付成功后通知地址 必须要求80端口并且地址不能带参数
+//	public static String notifyurl = "http://wx.jiancat.com/goods/order/notifyPay";
+	//ip地址
+	public String ipAddress = NameUtils.ipAddress;
+	
+	@Autowired
+	private MD5 md5;
+	@Autowired
+	private RatFWLogger inLongLogger;
+	@Autowired
+	private RequestHandler reqHandler;
+	@Autowired
+	private GetWxOrderno getWxOrderno;
+
+	public void setMd5(MD5 md5) {
+		this.md5 = md5;
+	}
+	public void setGetWxOrderno(GetWxOrderno getWxOrderno) {
+		this.getWxOrderno = getWxOrderno;
+	}
+	public void setReqHandler(RequestHandler reqHandler) {
+		this.reqHandler = reqHandler;
+	}
+	public void setInLongLogger(RatFWLogger inLongLogger) {
+		this.inLongLogger = inLongLogger;
+	}
+	
+	public static void main(String[] args) {
+		WxPayUtil payUtil = new WxPayUtil();;
+		System.out.println(payUtil.getPackage("o-icas1BDo7PxGMZgcFpL12jL-A4", "1rsjklsjflasjf", 1, NameUtils.ipAddress, "测试的飞机是多久", NameUtils.appId, NameUtils.GET_OPENID_DEAL_URL));
+	}
+	
+	/**
+	 * 获取微信扫码支付二维码连接
+	 */
+	public String getCodeurl(WxPayDto tpWxPayDto, String notifyurl){
+		// 1 参数
+		// 订单号
+		String orderId = tpWxPayDto.getOrderId();
+		// 附加数据 原样返回
+		String attach = "";
+		// 总金额以分为单位,不带小数点
+		String totalFee = getMoney(tpWxPayDto.getTotalFee());
+		
+		// 订单生成的机器 IP
+		String spbill_create_ip = tpWxPayDto.getSpbillCreateIp();
+		// 这里notify_url是 支付完成后微信发给该链接信息,可以判断会员是否支付成功,改变订单状态等。
+		String notify_url = notifyurl;
+		String trade_type = "NATIVE";
+
+		// 商户号
+		String mch_id = this.partner;
+		// 随机字符串
+		String nonce_str = getNonceStr();
+
+		// 商品描述根据情况修改
+		String body = tpWxPayDto.getBody();
+
+		// 商户订单号
+		String out_trade_no = orderId;
+
+		SortedMap<String, String> packageParams = new TreeMap<String, String>();
+		packageParams.put("appid", appid);
+		packageParams.put("mch_id", mch_id);
+		packageParams.put("nonce_str", nonce_str);
+		packageParams.put("body", body);
+		packageParams.put("attach", attach);
+		packageParams.put("out_trade_no", out_trade_no);
+
+		// 这里写的金额为1 分到时修改
+		packageParams.put("total_fee", totalFee);
+		packageParams.put("spbill_create_ip", spbill_create_ip);
+		packageParams.put("notify_url", notify_url);
+
+		packageParams.put("trade_type", trade_type);
+
+		RequestHandler reqHandler = new RequestHandler(null, null);
+		reqHandler.init(appid, appsecret, partnerkey);
+
+		String sign = reqHandler.createSign(packageParams);
+		String xml = "<xml>" + "<appid>" + appid + "</appid>" + "<mch_id>"
+				+ mch_id + "</mch_id>" + "<nonce_str>" + nonce_str
+				+ "</nonce_str>" + "<sign>" + sign + "</sign>"
+				+ "<body><![CDATA[" + body + "]]></body>" 
+				+ "<out_trade_no>" + out_trade_no
+				+ "</out_trade_no>" + "<attach>" + attach + "</attach>"
+				+ "<total_fee>" + totalFee + "</total_fee>"
+				+ "<spbill_create_ip>" + spbill_create_ip
+				+ "</spbill_create_ip>" + "<notify_url>" + notify_url
+				+ "</notify_url>" + "<trade_type>" + trade_type
+				+ "</trade_type>" + "</xml>";
+		String code_url = "";
+		String createOrderURL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
+		
+		
+		code_url = new GetWxOrderno().getCodeUrl(createOrderURL, xml);
+//System.out.println("code_url----------------"+code_url);
+		
+		return code_url;
+	}
+	
+	
+	/**
+	 * 获取请求预支付id报文
+	 * @return
+	 */
+	@SuppressWarnings("static-access")
+	public Object getPackage(
+			String openid, 
+			String orderid, 
+			Integer total, 
+			String ip, 
+			String bodyStr,
+			String appIdStr,
+			String notifyurl) {
+		
+System.out.println("getPackage start....");
+		
+		String openId = openid;
+		// 1 参数
+		// 订单号
+		String orderId = orderid;
+		// 附加数据 原样返回,此处对订单idMD5加密
+		
+		String attach = null;
+		try {
+			attach = StaticInfo.orderIdMD5.encrypt(orderid);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		// 总金额以分为单位,不带小数点
+		String totalFee = total.toString(); 
+				//getMoney(total);
+		// 订单生成的机器 IP
+		String spbill_create_ip = ip;
+		// 这里notify_url是 支付完成后微信发给该链接信息,可以判断会员是否支付成功,改变订单状态等。
+		String notify_url = notifyurl;
+		String trade_type = "JSAPI";
+		// ---必须参数
+		// 商户号
+		String mch_id = partner;
+		// 随机字符串
+		String nonce_str = getNonceStr();
+		// 商品描述根据情况修改
+		String body = bodyStr;
+		// 商户订单号
+		String out_trade_no = orderId;
+		SortedMap<String, String> packageParams = new TreeMap<String, String>();
+		packageParams.put("appid", appIdStr);
+		packageParams.put("mch_id", mch_id);
+		packageParams.put("nonce_str", nonce_str);
+		packageParams.put("body", body);
+		packageParams.put("attach", attach);
+		packageParams.put("out_trade_no", out_trade_no);
+		// 这里写的金额为1 分到时修改
+		packageParams.put("total_fee", totalFee);
+		packageParams.put("spbill_create_ip", spbill_create_ip);
+		packageParams.put("notify_url", notify_url);
+		packageParams.put("trade_type", trade_type);
+		packageParams.put("openid", openId);
+		reqHandler.init(appid, appsecret, partnerkey);
+		String sign = reqHandler.createSign(packageParams);
+		String xml = "<xml>"
+					+ "<appid>" + appid + "</appid>" 
+					+ "<mch_id>" + mch_id + "</mch_id>" 
+					+ "<nonce_str>" + nonce_str + "</nonce_str>" 
+					+ "<sign>" + sign + "</sign>"
+					+ "<body><![CDATA[" + body + "]]></body>" 
+					+ "<out_trade_no>" + out_trade_no + "</out_trade_no>" 
+					+ "<attach>" + attach + "</attach>"
+					+ "<total_fee>" + totalFee + "</total_fee>"
+					+ "<spbill_create_ip>" + spbill_create_ip + "</spbill_create_ip>" 
+					+ "<notify_url>" + notify_url + "</notify_url>" 
+					+ "<trade_type>" + trade_type + "</trade_type>" 
+					+ "<openid>" + openId + "</openid>"
+				+ "</xml>";
+		String prepay_id = "";
+		String createOrderURL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
+		//判断
+		Object string = getWxOrderno.getPayNo(createOrderURL, xml);
+		if (string.getClass() == String.class) {
+			prepay_id = string.toString();
+		} else {
+			WxPrepayIdErrorResult errorResult = (WxPrepayIdErrorResult) string;
+			if (errorResult.getErr_code_des() != null && errorResult.getErr_code_des().equals("商户订单号重复")) {
+				// 最大的可能意味着,此订单的金额发生改变
+				errorResult.setErr_code_des("对不起,您的订单号重复,请重新下单!");
+			} else {
+				errorResult.setErr_code_des(errorResult.getReturn_msg());
+			}
+			return errorResult;
+		}
+		//获取prepay_id后,拼接最后请求支付所需要的package
+		SortedMap<String, String> finalpackage = new TreeMap<String, String>();
+		String timestamp = Sha1Util.getTimeStamp();
+		String packages = "prepay_id="+prepay_id;
+		finalpackage.put("appId", appid);  
+		finalpackage.put("timeStamp", timestamp);  
+		finalpackage.put("nonceStr", nonce_str);  
+		finalpackage.put("package", packages);  
+		finalpackage.put("signType", "MD5");
+		//签名
+		String finalsign = reqHandler.createSign(finalpackage);
+		String finaPackage = "\"appId\":\"" + appid + "\",\"timeStamp\":\"" + timestamp + "\",\"nonceStr\":\"" + nonce_str + "\",\"package\":\"" + packages + "\",\"signType\":\"MD5" + "\",\"paySign\":\"" + finalsign + "\"";
+		return finaPackage;
+	}
+
+	/**
+	 * 获取随机字符串
+	 * @return
+	 */
+	public static String getNonceStr() {
+		// 随机数
+		String currTime = TenpayUtil.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(); 
+	}
+}

+ 84 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/WxPrepayIdErrorResult.java

@@ -0,0 +1,84 @@
+package com.iamberry.wechat.tools;
+/**
+ * description: 获取预支付id时数据封装
+ * @author 何秀刚
+ * createDate:
+ */
+public class WxPrepayIdErrorResult {
+	//返回状态码
+	private String return_code;
+	//状态说明
+	private String return_msg;
+	//appid
+	private String appid;
+	//商户号
+	private String mch_id;
+	// nonce_str
+	private String nonce_str;
+	private String sign;
+	private String result_code;
+	private String err_code;
+	private String err_code_des;
+	public String getReturn_code() {
+		return return_code;
+	}
+	public void setReturn_code(String return_code) {
+		this.return_code = return_code;
+	}
+	public String getReturn_msg() {
+		return return_msg;
+	}
+	public void setReturn_msg(String return_msg) {
+		this.return_msg = return_msg;
+	}
+	public String getAppid() {
+		return appid;
+	}
+	public void setAppid(String appid) {
+		this.appid = appid;
+	}
+	public String getMch_id() {
+		return mch_id;
+	}
+	public void setMch_id(String mch_id) {
+		this.mch_id = mch_id;
+	}
+	public String getNonce_str() {
+		return nonce_str;
+	}
+	public void setNonce_str(String nonce_str) {
+		this.nonce_str = nonce_str;
+	}
+	public String getSign() {
+		return sign;
+	}
+	public void setSign(String sign) {
+		this.sign = sign;
+	}
+	public String getResult_code() {
+		return result_code;
+	}
+	public void setResult_code(String result_code) {
+		this.result_code = result_code;
+	}
+	public String getErr_code() {
+		return err_code;
+	}
+	public void setErr_code(String err_code) {
+		this.err_code = err_code;
+	}
+	public String getErr_code_des() {
+		return err_code_des;
+	}
+	public void setErr_code_des(String err_code_des) {
+		this.err_code_des = err_code_des;
+	}
+	@Override
+	public String toString() {
+		return "WxPrepayIdErrorResult [return_code=" + return_code
+				+ ", return_msg=" + return_msg + ", appid=" + appid
+				+ ", mch_id=" + mch_id + ", nonce_str=" + nonce_str + ", sign="
+				+ sign + ", result_code=" + result_code + ", err_code="
+				+ err_code + ", err_code_des=" + err_code_des + "]";
+	}
+}

+ 149 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/wechat/tools/loadResultUtil.java

@@ -0,0 +1,149 @@
+package com.iamberry.wechat.tools;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+
+//@Component("loadResultInfo")
+public class loadResultUtil {
+	private static Logger logger = Logger.getLogger(loadResultUtil.class);
+	
+	static String fileName="ResultInfo.properties";
+	public loadResultUtil(){
+		logger.info("loadResultInfo启动");
+		load();
+	}
+	public static void load(){
+		logger.info("loadResultInfo.load启动");
+		Properties prop = new Properties();
+		try {
+			prop.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(loadResultUtil.fileName));
+			ResultInfo.SUCCESSINFO=prop.getProperty("SUCCESSINFO");
+			ResultInfo.ERRORINFO=prop.getProperty("ERRORINFO");
+			ResultInfo.SUCCESSCODE=prop.getProperty("SUCCESSCODE");
+			ResultInfo.ERRORCODE=prop.getProperty("ERRORCODE");
+			//购物车活动字段
+			ResultInfo.ISSHOW=prop.getProperty("ISSHOW");
+			ResultInfo.CARTDESC=prop.getProperty("CARTDESC");
+			ResultInfo.CART_URL=prop.getProperty("CART_URL");
+			
+			
+			ResultInfo.getMoneyLimitDown=Integer.parseInt(prop.getProperty("getMoneyLimitDown"));
+			ResultInfo.getMoneyLimitTop=Integer.parseInt(prop.getProperty("getMoneyLimitTop"));
+			
+			ResultInfo.getMoneyLimitError=prop.getProperty("getMoneyLimitError");
+			ResultInfo.getMoneyCountError=prop.getProperty("getMoneyCountError");
+
+			ResultInfo.loginOutError = prop.getProperty("loginOutError");
+			ResultInfo.paramFormatError = prop.getProperty("paramFormatError");
+			ResultInfo.withdrawCountOutError =prop.getProperty("withdrawCountOutError");
+			ResultInfo.cartEmptyError = prop.getProperty("cartEmptyError");
+			ResultInfo.integralOutError = prop.getProperty("integralOutError");
+			ResultInfo.userIntegralOutError = prop.getProperty("userIntegralOutError");
+			ResultInfo.userMoneyOutError = prop.getProperty("userMoneyOutError");
+			ResultInfo.integralOutOrderMeonyError = prop.getProperty("integralOutOrderMeonyError");
+			ResultInfo.userNoDrpError = prop.getProperty("userNoDrpError");
+			
+			ResultInfo.APPLY_AGAIN = prop.getProperty("APPLY_AGAIN");
+			ResultInfo.APPLY_EXIST = prop.getProperty("APPLY_EXIST");
+			ResultInfo.APPLY_OPENID_IS_NULL = prop.getProperty("APPLY_OPENID_IS_NULL");
+			ResultInfo.APPLY_ORDER_IS_NULL = prop.getProperty("APPLY_ORDER_IS_NULL");
+			
+			ResultInfo.repeatNameError=prop.getProperty("repeatNameError");
+			ResultInfo.lostMemberInfo=prop.getProperty("lostMemberInfo");
+			
+			ResultInfo.initPorxySuccessPrifix=prop.getProperty("initPorxySuccessPrifix");
+			ResultInfo.initPorxySuccessSuffix=prop.getProperty("initPorxySuccessSuffix");
+			ResultInfo.initPorxyErrorByCodeError=prop.getProperty("initPorxyErrorByCodeError");
+			ResultInfo.initPorxyErrorByUseInit=prop.getProperty("initPorxyErrorByUseInit");
+			ResultInfo.initPorxyErrorByUseBuild=prop.getProperty("initPorxyErrorByUseBuild");
+			ResultInfo.initPorxyErrorByCodeWrong=prop.getProperty("initPorxyErrorByCodeWrong");
+			ResultInfo.subDefaultResponseText=prop.getProperty("subDefaultResponseText");
+			ResultInfo.messageDefaultResponseText=prop.getProperty("messageDefaultResponseText");
+			ResultInfo.messageIsNullResponseText=prop.getProperty("messageIsNullResponseText");
+			ResultInfo.imageMessageResponseText=prop.getProperty("imageMessageResponseText");
+			ResultInfo.locationMessageResponseText=prop.getProperty("locationMessageResponseText");
+			ResultInfo.linkMessageResponseText=prop.getProperty("linkMessageResponseText");
+			ResultInfo.videoMessageResponseText=prop.getProperty("videoMessageResponseText");
+			ResultInfo.tryCatchDefaultResponseText=prop.getProperty("tryCatchDefaultResponseText");
+			ResultInfo.rebateOrderText=prop.getProperty("rebateOrderText");
+			ResultInfo.FOLLOW_REPLY_MESSAGE_TEXT=prop.getProperty("follow_reply_message_text");
+			ResultInfo.FOLLOW_REPLY_MESSAGE_IS_IMAGE_TEXT="true".equals(prop.getProperty("follow_reply_message_is_image_text"))?true:false;
+			
+			//消息的回调连接
+			ResultInfo.INDEX_PAGE = prop.getProperty("INDEX_PAGE"); 	// 商城首页,,,
+			ResultInfo.PAGE_SHIPMENT = prop.getProperty("PAGE_SHIPMENT"); // 订单发货的界面
+			ResultInfo.TUIHUI_SHIPMENT = prop.getProperty("TUIHUI_SHIPMENT"); //收益退回的界面
+			ResultInfo.ORDER_GUOQI = prop.getProperty("ORDER_GUOQI"); 	//订单即将过期提醒
+			//消息的模板id
+			ResultInfo.rewards_template_id = prop.getProperty("rewards_template_id");//返现到账通知模版id
+			ResultInfo.Income_template_id = prop.getProperty("Income_template_id");//收入提醒模版id
+			ResultInfo.Shipment_template_id = prop.getProperty("Shipment_template_id");//发货提醒模版id
+			ResultInfo.Order_template_id = prop.getProperty("Order_template_id");//订单未支付模版id
+			
+			
+			
+		} catch (IOException e) {
+			ResultInfo.SUCCESSINFO="操作成功!";
+			ResultInfo.ERRORINFO="操作失败!";
+			ResultInfo.SUCCESSCODE="200";
+			ResultInfo.ERRORCODE="500";
+			
+			//购物车活动字段
+			ResultInfo.ISSHOW="是";
+			ResultInfo.CARTDESC="京东众筹价¥399,快快点我前往!";
+			ResultInfo.CART_URL="http://z.jd.com/project/details/53631.html?from=jr_search&type=0";
+			
+			ResultInfo.getMoneyLimitDown=100;
+			ResultInfo.getMoneyLimitTop=200000000;
+			
+			ResultInfo.getMoneyLimitError="提现资金不符合规则!";
+			ResultInfo.getMoneyCountError="当月取现次数不能超过两次";
+
+			ResultInfo.loginOutError = "登陆信息丢失,请登陆!";
+			ResultInfo.paramFormatError = "参数格式有误,请检测!";
+			ResultInfo.withdrawCountOutError = "对不起,本月提现次数已经使用完成!";
+			ResultInfo.cartEmptyError = "没有选中购物项,或者购物车已经结算!";
+			ResultInfo.integralOutError = "抵扣积分不能大于用户可用积分!";
+			ResultInfo.userIntegralOutError = "对不起,您的可用积分不足提现!";
+			ResultInfo.userMoneyOutError = "对不起,您的可用金额不足提现!";
+			ResultInfo.integralOutOrderMeonyError = "抵扣积分金额不能大于等于订单金额!";
+			ResultInfo.userNoDrpError = "您不是代理商,无法查看二维码!";
+			
+			ResultInfo.APPLY_AGAIN = "您的申请已经提交,请等待审核!";
+			ResultInfo.APPLY_EXIST = "您已经是微代理!";
+			ResultInfo.APPLY_OPENID_IS_NULL = "请关注公众号!";
+			ResultInfo.APPLY_ORDER_IS_NULL="请完成一次订单后再次申请!";
+
+			ResultInfo.repeatNameError="分销商用户名重复";
+			ResultInfo.lostMemberInfo="用户信息丢失!";
+			
+			ResultInfo.initPorxySuccessPrifix="尊敬的";
+			ResultInfo.initPorxySuccessSuffix="您好!\n恭喜您激活账户成功!";
+			ResultInfo.initPorxyErrorByCodeError="对不起!\n您输入的激活码不正确,请重试!";
+			ResultInfo.initPorxyErrorByUseInit="对不起!\n您输入的激活码不正确,请重试!";
+			ResultInfo.initPorxyErrorByUseBuild="对不起!您的微信已经绑定了其他代理商信息!导致无法绑定!";
+			ResultInfo.initPorxyErrorByCodeWrong="对不起!\n您输入的激活码不正确,请重试!";
+			ResultInfo.subDefaultResponseText="感谢您关注我们,我们会为您提供最好的服务!";
+			ResultInfo.messageDefaultResponseText="您好,有什么能帮到您的?";
+			ResultInfo.messageIsNullResponseText="您好,有什么能帮到您的!";
+			ResultInfo.imageMessageResponseText="哎哟 ~ 您发的图片我暂时不懂\n有什么能帮到您呢?";
+			ResultInfo.locationMessageResponseText="哎哟 ~ 您发的地址我暂时不懂\n有什么能帮到您呢?";
+			ResultInfo.linkMessageResponseText="哎哟 ~ 您发的链接我暂时不懂\n有什么能帮到您呢?";
+			ResultInfo.videoMessageResponseText="哎哟 ~ 您发的语音我暂时不懂\n有什么能帮到您呢?";
+			ResultInfo.tryCatchDefaultResponseText="对不起,暂时无法给您回复...";
+			ResultInfo.rebateOrderText="{1}购买了{2}订单,给{3}返利{4}元钱";
+			ResultInfo.FOLLOW_REPLY_MESSAGE_TEXT="恭喜您,已获得购买冲奶机优惠100元资格!";
+			ResultInfo.FOLLOW_REPLY_MESSAGE_IS_IMAGE_TEXT=false;
+			
+			
+			ResultInfo.INDEX_PAGE = "http://h5.iamberry.com/iamberry/wechat/index"; 	// 商城首页,,,
+			ResultInfo.PAGE_SHIPMENT = "http://h5.iamberry.com/iamberry/pay/goOrderInfo?orderId="; // 订单发货的界面
+			ResultInfo.TUIHUI_SHIPMENT = "http://h5.iamberry.com/iamberry/wechat/agentWechat/reback"; //收益退回的界面
+			ResultInfo.ORDER_GUOQI = "http://h5.iamberry.com/iamberry/pay/goOrderList"; 	//订单即将过期提醒
+			
+			
+		}
+	}
+}

+ 70 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/HostInfo.java

@@ -0,0 +1,70 @@
+package com.iamberry.zk;
+
+import java.io.Serializable;
+
+public class HostInfo implements Serializable {
+
+	private static final long serialVersionUID = 6537048826405265258L;
+
+	private String host;
+	
+	private String port;
+	
+	private String applicationName;
+	
+	// 0 : 正在运行,可以转化为1; 1:关闭中,可以转化为2 ;2:已经关闭;
+	private int state = 0;
+	
+	private String path;
+	
+	public String getPath() {
+		return path;
+	}
+
+	public void setPath(String path) {
+		this.path = path;
+	}
+
+	public HostInfo() {
+		super();
+	}
+
+	public HostInfo(String host, String port, String applicationName, int state) {
+		this.host = host;
+		this.port = port;
+		this.applicationName = applicationName;
+		this.state = state;
+	}
+
+	public String getHost() {
+		return host;
+	}
+
+	public void setHost(String host) {
+		this.host = host;
+	}
+
+	public String getPort() {
+		return port;
+	}
+
+	public void setPort(String port) {
+		this.port = port;
+	}
+
+	public String getApplicationName() {
+		return applicationName;
+	}
+
+	public void setApplicationName(String applicationName) {
+		this.applicationName = applicationName;
+	}
+
+	public int getState() {
+		return state;
+	}
+
+	public void setState(int state) {
+		this.state = state;
+	}
+}

+ 60 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/SpringContextHolder.java

@@ -0,0 +1,60 @@
+package com.iamberry.zk;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+
+/**
+ * @author:何秀刚
+ * @description: 以静态变量保存Spring ApplicationContext, <br> 可在任何代码、任何时候中取出ApplicaitonContext
+ * @createDate:2016年5月25日
+ */
+public class SpringContextHolder implements ApplicationContextAware {
+    private static ApplicationContext applicationContext;
+
+    /**
+     * 实现ApplicationContextAware接口的context注入函数, 将其存入静态变量.
+     */
+    public void setApplicationContext(ApplicationContext applicationContext) {
+        SpringContextHolder.applicationContext = applicationContext;
+    }
+
+    /**
+     * 取得存储在静态变量中的ApplicationContext.
+     */
+    public static ApplicationContext getApplicationContext() {
+        checkApplicationContext();
+        return applicationContext;
+    }
+
+    /**
+     * 从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的类型.
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> T getBean(String name) {
+        checkApplicationContext();
+        return (T) applicationContext.getBean(name);
+    }
+
+    /**
+     * 从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的类型.
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> T getBean(Class<T> clazz) {
+        checkApplicationContext();
+        return (T) applicationContext.getBeansOfType(clazz);
+    }
+
+    /**
+     * 清除applicationContext静态变量.
+     */
+    public static void cleanApplicationContext() {
+        applicationContext = null;
+    }
+
+    private static void checkApplicationContext() {
+        if (applicationContext == null) {
+            throw new IllegalStateException("applicaitonContext未注入,请在spring.xml中定义SpringContextHolder");
+        }
+    }
+}

+ 41 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/StartZK.java

@@ -0,0 +1,41 @@
+package com.iamberry.zk;
+
+import java.net.InetAddress;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.support.AbstractApplicationContext;
+
+import com.alibaba.dubbo.config.ApplicationConfig;
+import com.alibaba.dubbo.config.ProtocolConfig;
+import com.iamberry.zk.ZookeeperQueue;
+
+public class StartZK {
+	
+	private Logger logger = LoggerFactory.getLogger(StartZK.class);
+
+	public StartZK() {
+		logger.info("StartZK start, start Zookeeper...");
+		try {
+		// 上传当前机器的信息
+		ZookeeperQueue.hostInfo();
+		// 获取应用配置
+		AbstractApplicationContext ctx = (AbstractApplicationContext) SpringContextHolder.getApplicationContext();
+		ApplicationConfig applicationConfig = ctx.getBean(ApplicationConfig.class);
+		// 获取协议配置,可能存在多个,当port配置为-1时
+		Map<String, ProtocolConfig> beansOfType = ctx.getBeansOfType(ProtocolConfig.class);
+		String ports = "";
+		for (Entry<String, ProtocolConfig> string : beansOfType.entrySet()) {
+			ports = ports + string.getValue().getPort() + ",";
+		}
+			ZookeeperQueue.uploadHostInfo(InetAddress.getLocalHost().getHostAddress(), ports, 0, applicationConfig.getName());
+			ZookeeperQueue.monitorNowNodeData(1, ctx);
+		} catch (Exception e) {
+			// TODO: handle exception
+			logger.error("StartZK error : " + e.getMessage());
+		}
+		logger.info("StartZK start, end.");
+	}
+}

+ 143 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/ZookeeperFactory.java

@@ -0,0 +1,143 @@
+package com.iamberry.zk;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Properties;
+import org.I0Itec.zkclient.ZkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.util.DefaultPropertiesPersister;
+import org.springframework.util.PropertiesPersister;
+/**
+ * @company	深圳爱贝源科技有限公司
+ * @website www.iamberry.com
+ * @author 	献
+ * @tel		18271840547
+ * @date	2016年9月13日
+ * @explain	zookeeper的实例工厂类
+ */
+public final class ZookeeperFactory {
+	
+	/**
+	 * 获取实现了slf4j接口的日志
+	 */
+	private static Logger logger = LoggerFactory.getLogger(ZookeeperFactory.class);
+
+	/**
+	 * zk超时时间
+	 */
+	private static int TIME_OUT = 2000;
+	
+	/**
+	 * zk是否允许,true:允许,false:没有运行
+	 */
+	private static volatile boolean IS_ZK_RUN = false;
+	
+	public static boolean isZkRun() {
+		return IS_ZK_RUN;
+	}
+
+	/**
+	 * 全局保存Zookeeper的实例
+	 */
+	private static ZkClient zkClient = null;
+	
+	/**
+	 * 获取Zk的实例
+	 */
+	public static ZkClient getZkClient() {
+		return zkClient;
+	}
+	
+	/**
+	 * 一旦启动项目, 自动链接Zookeeper
+	 * Class 装载的顺序,静态代码块优先
+	 */
+	static {
+		// 加载
+		propertiesPersister = new DefaultPropertiesPersister();
+		resourceLoader = new PathMatchingResourcePatternResolver();
+		
+		// 通过JVM环境参数,指定是否启动zk
+		String zkStart = System.getProperty("zk.start");
+		logger.info("zk.start property:" + zkStart);
+		if ("true".equals(zkStart) || zkStart == null) {
+			initZookeeper();
+		}
+	}
+	
+	/**
+	 * 连接zookeeper
+	 * @throws IOException 
+	 * @throws FileNotFoundException 
+	 */
+	public synchronized static void initZookeeper() {
+		System.out.println("加载init");
+		if (isZkRun()) {
+			return;
+		}
+		logger.info("初始化Zookeeper连接");
+		try {
+			zkClient = new ZkClient(getConnectionStr(), TIME_OUT);
+			IS_ZK_RUN = true;
+		} catch (Exception e) {
+			logger.error("初始化Zookeeper异常:" + e.getMessage());
+		}
+	}
+	
+	/**
+	 * 获取Zookeeper链接
+	 * @throws FileNotFoundException
+	 * @throws IOException
+	 */
+	private static String getConnectionStr() throws FileNotFoundException, IOException {
+		logger.info("读取zookeeper的配置文件...");
+		try {
+			Properties props = loadProperties("zk.properties");
+			String host = (String) props.get("zookeeper.host");
+			String port = (String) props.get("zookeeper.port");
+			logger.info("读取配置文件完毕,host:" + host + ",port:" + port);
+			return new StringBuilder(host).append(":").append(port).toString();
+		} catch (Exception e) {
+			return "127.0.0.1:2181"; 
+		}
+	}
+	
+	/**
+	 * 载入多个properties文件, 相同的属性在最后载入的文件中的值将会覆盖之前的载入. 文件路径使用Spring Resource格式, 文件编码使用UTF-8.
+	 * @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
+	 */
+	public static Properties loadProperties(String... resourcesPaths) throws IOException {
+		if (resourcesPaths == null) {
+			throw new NullPointerException("No resource path");
+		}
+		
+		Properties props = new Properties();
+		for (String location : resourcesPaths) {
+			logger.debug("Loading properties file from:" + location);
+			InputStream is = null;
+			try {
+				Resource resource = resourceLoader.getResource(location);
+				is = resource.getInputStream();
+				propertiesPersister.load(props, new InputStreamReader(is, DEFAULT_ENCODING));
+			} catch (IOException ex) {
+				logger.info("Could not load properties from classpath:" + location + ": " + ex.getMessage());
+			} finally {
+				if (is != null) {
+					is.close();
+				}
+			}
+		}
+		return props;
+	}
+	// 编码
+	private static final String DEFAULT_ENCODING = "UTF-8";
+	// Spring-core 获取配置文件的类
+	private static PropertiesPersister propertiesPersister = null;
+	// Spring-core 获取资源的类
+	private static ResourceLoader resourceLoader = null;
+}

+ 248 - 0
iamberry-common-parent/iamberry-common-tool/src/main/java/com/iamberry/zk/ZookeeperQueue.java

@@ -0,0 +1,248 @@
+package com.iamberry.zk;
+
+import java.net.ConnectException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.SocketChannel;
+import java.util.Arrays;
+import java.util.List;
+
+import org.I0Itec.zkclient.IZkChildListener;
+import org.I0Itec.zkclient.IZkDataListener;
+import org.I0Itec.zkclient.ZkClient;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.zookeeper.CreateMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.support.AbstractApplicationContext;
+
+import com.alibaba.dubbo.config.ProtocolConfig;
+
+/**
+ * @company	深圳爱贝源科技有限公司
+ * @website www.iamberry.com
+ * @author 	献
+ * @tel		18271840547
+ * @date	2016年9月13日
+ * @explain 使用zookeeper实现队列
+ */
+public class ZookeeperQueue {
+
+	/**
+	 * 获取实现了slf4j接口的日志
+	 */
+	private static Logger logger = LoggerFactory.getLogger(ZookeeperQueue.class);
+	
+	/**
+	 * 目录节点
+	 */
+	private static String ROOT_PATH = "/iamberry";
+	private static String TIME_TASK_PATH = "/timetask";
+	private static String NOW_HOST_PATH = null;
+	private static String  HOST_NODE_PATH = "/host_info";
+	
+	/**
+	 * 当前机器是否能运行定时任务,true:可以运行,false:不可以运行
+	 */
+	private static volatile boolean TASK_RUN = false;
+	public static boolean getTaskRun() {
+		return TASK_RUN;
+	}
+	
+	/**
+	 * 处理节点选举问题
+	 */
+	public static void rootElement() {
+		logger.info("监听请求....");
+		if (!ZookeeperFactory.isZkRun()) {
+			throw new RuntimeException("Zookeeper Not Run!");
+		}
+		final ZkClient client = ZookeeperFactory.getZkClient();
+		if (!client.exists(ROOT_PATH)) {
+			// 创建一个持久化节点
+			client.create(ROOT_PATH, null, CreateMode.PERSISTENT);
+		}
+		
+		final String task = ROOT_PATH + TIME_TASK_PATH;
+		if (!client.exists(task)) {
+			// 创建一个持久化节点
+			client.create(task, null, CreateMode.PERSISTENT);
+		}
+		
+		// 为当前机器创建临时有序的节点,生成的规则为 : /基本目录/host_序号
+		final String hostNowPath = client.create(task + "/host_", "host".getBytes(), CreateMode.EPHEMERAL_SEQUENTIAL);
+		logger.info("当前机器的节点:" + hostNowPath);
+		// 监听此节点的节点变化
+		client.subscribeChildChanges(task, new IZkChildListener() {
+			@Override
+			public void handleChildChange(String path, List<String> nowChilds) throws Exception {
+				// 一旦机器下线,自动恢复
+				logger.info("节点变化:" + path);
+				hostRun(client, task, hostNowPath);
+			}
+		});
+		// 本次选举
+		hostRun(client, task, hostNowPath);
+	}
+	
+	/**
+	 * 机器信息问题
+	 */
+	public static void hostInfo() {
+		logger.info("监听请求....");
+		if (!ZookeeperFactory.isZkRun()) {
+			throw new RuntimeException("Zookeeper Not Run!");
+		}
+		String hostNode = HOST_NODE_PATH;
+		ZkClient client = ZookeeperFactory.getZkClient();
+		if (!client.exists(ROOT_PATH)) {
+			// 创建一个持久化节点
+			client.create(ROOT_PATH, null, CreateMode.PERSISTENT);
+		}
+		
+		String task = ROOT_PATH + hostNode;
+		if (!client.exists(task)) {
+			// 创建一个持久化节点
+			client.create(task, null, CreateMode.PERSISTENT);
+		}
+		// 为当前机器创建临时有序的节点,生成的规则为 : /基本目录/host_序号
+		String hostNowPath = client.create(task + "/hostNode_", "HN".getBytes(), CreateMode.EPHEMERAL_SEQUENTIAL);
+		logger.info("当前机器的节点:" + hostNowPath);
+		// 保存当前节点信息
+		NOW_HOST_PATH = hostNowPath;
+	}
+	
+	/**
+	 * 选举,不允许用户手动调用
+	 */
+	private synchronized static void hostRun(ZkClient client, String task, String hostNowPath) {
+		// 如果当前节点,确认在运行,那么进行选举
+		if (!TASK_RUN) {
+			// 启动队列标识
+			List<String> childs = client.getChildren(task);
+			String[] sorts = childs.toArray(new String[childs.size()]);
+			Arrays.sort(sorts);
+			// 获取最新的机器
+			String minHost = sorts[0];
+			// 最小的机器节点,即,获取到了锁的节点
+			Integer ver = new Integer(minHost.split("_")[1]);
+			Integer nowVer = new Integer(hostNowPath.split("_")[1]);
+			if (ver.intValue() == nowVer.intValue()) {
+				// 当前机器可以启动
+				TASK_RUN = true;
+				logger.info("选举出的节点:" + minHost);
+			}
+		}
+	}
+	
+	/**
+	 * 上传当前机器的信息
+	 */
+	public synchronized static void uploadHostInfo(String host, String port, int state, String applicationName) {
+		if (!ZookeeperFactory.isZkRun()) {
+			return;
+		}
+		logger.info("为" + NOW_HOST_PATH + "保存信息," + "HOST:" + host + ",PORT:" + port + ",STATE:" + state + ",applicationName:" + applicationName);
+		HostInfo hostInfo = new HostInfo(host, port, applicationName, state);
+		ZookeeperFactory.getZkClient().writeData(NOW_HOST_PATH, hostInfo);
+	}
+	
+	/**
+	 * 监听当前节点的数据变化
+	 * @param state 需要处理的节点状态事件
+	 * 	0 : 不处理
+	 *  1 : 关闭中
+	 *  2 : 已经关闭
+	 */
+	public synchronized static void monitorNowNodeData(int state, final AbstractApplicationContext context) {
+		if (!ZookeeperFactory.isZkRun()) {
+			return;
+		}
+		if (StringUtils.isEmpty(NOW_HOST_PATH)) {
+			return;
+		}
+		// 关注数据变化的时间(数据删除、数据修改)
+		ZookeeperFactory.getZkClient().subscribeDataChanges(NOW_HOST_PATH, new IZkDataListener() {
+			@Override
+			public void handleDataDeleted(String dataPath) throws Exception {
+				logger.info("节点数据被删除:" + dataPath);
+			}
+			@Override
+			public void handleDataChange(String dataPath, Object data) throws Exception {
+				logger.info("节点数据被修改:" + dataPath);
+				// 处理节点数据修改问题
+				HostInfo hostInfo = (HostInfo) data;
+				if (hostInfo.getState() == 1 && NOW_HOST_PATH.equals(dataPath)) {
+					// 若接受到关闭中的状态,执行关闭操作
+					// 关闭Spring, 需要手动关闭Spring,因为Spring 没有调用 registerShutdownHook方法
+					context.destroy();
+					// 关闭DUBBO,判断是否通过环境变量注册
+					if (!"true".equals(System.getProperty("dubbo.shutdown.hook"))) {
+						// 如果没有注册 ShutdownHook 线程,那么只能手动关闭,否则可以通过exit()自动关闭会回调。
+						ProtocolConfig.destroyAll();
+					}
+					// 关闭虚拟机,一个Dubbo的Main已经注册了ShutdownHook,那么我们调用exit(),则会触发,如此即可
+					Runtime.getRuntime().exit(0);
+					
+					/*
+					 * 
+						// 此处支持远程关闭tomcat(优雅关闭)
+						SocketChannel channel = SocketChannel.open();
+						// 设置阻塞
+						channel.configureBlocking(true);
+						// 连接时间
+						channel.socket().setSoTimeout(1000 * 10);
+						try {
+							// 连接(hostName需要上传)
+							channel.connect(new InetSocketAddress("127.0.0.1", 8005));
+						} catch (ConnectException e) {
+							// 连接超时,是否不存在?
+						}
+						// 发送命令(需要上传)
+						String endline = "\r\n";
+						ByteBuffer buffer = ByteBuffer.allocate(100).put(("SHUTDOWN1" + endline).getBytes());
+						buffer.flip();
+						channel.write(buffer);
+						channel.close();
+					 */
+				}
+			}
+		});
+	}
+
+	/**
+	 * 获取所有的机器节点
+	 * @return
+	 */
+	public static List<String> listHostInfo() {
+		if (!ZookeeperFactory.isZkRun()) {
+			return null;
+		}
+		List<String> list = ZookeeperFactory.getZkClient().getChildren(ROOT_PATH + HOST_NODE_PATH);
+		return list;
+	}
+	
+	/**
+	 * 获取节点信息
+	 * @param path 如果为null,返回当前节点的信息
+	 * @return null表示不存在此节点,或者当前节点没有数据
+	 */
+	public static HostInfo readNodeData(String path) {
+		if (!ZookeeperFactory.isZkRun()) {
+			return null;
+		}
+		if (path == null) {
+			path = NOW_HOST_PATH;
+		}
+		String task = ROOT_PATH + HOST_NODE_PATH + "/" + path;
+		return ZookeeperFactory.getZkClient().readData(task);
+	}
+	
+	public static void writeNodeData(String path, HostInfo hostInfo) {
+		if (!ZookeeperFactory.isZkRun()) {
+			return;
+		}
+		String task = ROOT_PATH + HOST_NODE_PATH + "/" + path;
+		ZookeeperFactory.getZkClient().writeData(task, hostInfo);
+	}
+}

+ 17 - 0
iamberry-common-parent/iamberry-common-tool/src/main/resources/iamberry-app-service-config.properties

@@ -0,0 +1,17 @@
+SMS_USERNAME=aibeiyuan
+SMS_PASSWORD=aibeiyuan632
+SMS_TEXT=\u3010\u6BD4\u6BD4\u840C\u3011\u60A8\u7684\u9A8C\u8BC1\u7801\u662F\uFF1A{0}\uFF0C\u5982\u975E\u672C\u4EBA\u64CD\u4F5C\uFF0C\u8BF7\u5FFD\u7565\u672C\u77ED\u4FE1
+SMS_URL=http://115.29.44.189:8080/sms/smsInterface.do
+SINA_IP_URL=http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip={0}
+APPID=wxe9e992877625202f
+MCH_ID=1316959401
+SECRET=ae12dfeca278d7e4f15047313d453733
+UNIFIED_ORDER_CALLBACK_URL=demo.tronsis.com
+master_secret=ffd6373d25f9e36ba6e9d7c3
+appkey=cef2f16aa36424f2a6d4ca60
+cdnUrl=http://cms.iamberry.com/cdn
+base_url=http://app.iamberry.com/imberry
+INTER_SMS_URL=https://sms.yunpian.com/v2/sms/single_send.json
+
+INTER_SMS_TEXT=\u3010\u6BD4\u6BD4\u840C\u3011\u60A8\u7684\u9A8C\u8BC1\u7801\u662F\uFF1A{0}\uFF0C3\u5206\u949F\u5185\u6709\u6548\u3002\u5982\u975E\u672C\u4EBA\u64CD\u4F5C\uFF0C\u8BF7\u5FFD\u7565\u672C\u77ED\u4FE1\u3002
+INTER_SMS_KEY=2d3cc4afa42ec747b43a09ab89151133

+ 2 - 0
iamberry-common-parent/iamberry-common-tool/src/main/resources/zk.properties

@@ -0,0 +1,2 @@
+zookeeper.host=127.0.0.1
+zookeeper.port=2181

BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/APIStatus.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/Constants.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/ImberryConfig.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/Response.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/config/ResponseHeader.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/des/MD5.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/AddressDTO.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/TuyaDTO.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/TuyaHistoryListDTO.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/TuyaHistoryRawDTO.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/dto/TuyaHistoryResultDTO.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/log/RatFWLogger.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/util/AES.class


BIN
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/util/Des.class


+ 0 - 0
iamberry-common-parent/iamberry-common-tool/target/classes/com/iamberry/app/tool/util/HttpUtility.class


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