Browse Source

初始化仓库代码

rayson 1 năm trước cách đây
commit
75f6d44d56
100 tập tin đã thay đổi với 16138 bổ sung0 xóa
  1. 1 0
      README.md
  2. 467 0
      pom.xml
  3. 31 0
      src/main/java/com/wechat/activerequests/ActiveRequests.java
  4. 7 0
      src/main/java/com/wechat/activerequests/EnumUserIdentifierType.java
  5. 19 0
      src/main/java/com/wechat/activerequests/responses/CustomeServiceResponse.java
  6. 12 0
      src/main/java/com/wechat/activerequests/responses/MessageIdResponse.java
  7. 25 0
      src/main/java/com/wechat/activerequests/responses/WxBaseResponse.java
  8. 137 0
      src/main/java/com/wechat/callback/controller/MasterRequestController.java
  9. 137 0
      src/main/java/com/wechat/callback/controller/MiniprogMasterController.java
  10. 12 0
      src/main/java/com/wechat/callback/handlers/ITencentRequestHandler.java
  11. 57 0
      src/main/java/com/wechat/callback/handlers/event/ClickReceivedHandler.java
  12. 79 0
      src/main/java/com/wechat/callback/handlers/event/EventReceivedHandler.java
  13. 64 0
      src/main/java/com/wechat/callback/handlers/event/SubscribeEventHandler.java
  14. 40 0
      src/main/java/com/wechat/callback/handlers/event/TemplateSendFinishEventHandler.java
  15. 75 0
      src/main/java/com/wechat/callback/handlers/text/TextMessageReceivedHandler.java
  16. 69 0
      src/main/java/com/wechat/callback/passiveresponses/BasePassiveResponse.java
  17. 72 0
      src/main/java/com/wechat/callback/passiveresponses/NewsResponse.java
  18. 29 0
      src/main/java/com/wechat/callback/passiveresponses/PictureResponse.java
  19. 12 0
      src/main/java/com/wechat/callback/passiveresponses/ServiceResponse.java
  20. 38 0
      src/main/java/com/wechat/callback/passiveresponses/TextResponse.java
  21. 43 0
      src/main/java/com/wechat/callback/processors/ClickEventProcessor.java
  22. 37 0
      src/main/java/com/wechat/callback/processors/CustomerServiceProcessor.java
  23. 133 0
      src/main/java/com/wechat/callback/processors/FaqAnswerProcessor.java
  24. 27 0
      src/main/java/com/wechat/callback/processors/UnSubscribeProcessor.java
  25. 60 0
      src/main/java/com/wechat/callback/tencentrequests/BaseRequest.java
  26. 52 0
      src/main/java/com/wechat/callback/tencentrequests/RefundRequest.java
  27. 7 0
      src/main/java/com/wechat/callback/tencentrequests/TBaseRequest.java
  28. 58 0
      src/main/java/com/wechat/callback/tencentrequests/UserSentLocationRequest.java
  29. 28 0
      src/main/java/com/wechat/callback/tencentrequests/UserSentTextRequest.java
  30. 32 0
      src/main/java/com/wechat/callback/tencentrequests/events/BaseEventRequest.java
  31. 27 0
      src/main/java/com/wechat/callback/tencentrequests/events/ClickEventRequest.java
  32. 7 0
      src/main/java/com/wechat/callback/tencentrequests/events/TBaseEventRequest.java
  33. 37 0
      src/main/java/com/wechat/callback/tencentrequests/events/TemplateSendFinishEventRequest.java
  34. 567 0
      src/main/java/com/wechat/common/CommonEnum.java
  35. 246 0
      src/main/java/com/wechat/common/CommonHelper.java
  36. 167 0
      src/main/java/com/wechat/common/Constants.java
  37. 20 0
      src/main/java/com/wechat/common/IEnum.java
  38. 111 0
      src/main/java/com/wechat/common/IdGenarator.java
  39. 53 0
      src/main/java/com/wechat/common/TengXunYunBase64URL.java
  40. 195 0
      src/main/java/com/wechat/common/TwoDimensionCode.java
  41. 29 0
      src/main/java/com/wechat/common/TwoDimensionCodeImage.java
  42. 159 0
      src/main/java/com/wechat/common/utils/AESUtil.java
  43. 107 0
      src/main/java/com/wechat/common/utils/BaiDuKeyWordFilerUtils.java
  44. 56 0
      src/main/java/com/wechat/common/utils/BaseUtils.java
  45. 878 0
      src/main/java/com/wechat/common/utils/DateUtils.java
  46. 99 0
      src/main/java/com/wechat/common/utils/HttpClientUtils.java
  47. 38 0
      src/main/java/com/wechat/common/utils/IOStreamUtils.java
  48. 153 0
      src/main/java/com/wechat/common/utils/JacksonUtils.java
  49. 131 0
      src/main/java/com/wechat/common/utils/KeyWordUtil.java
  50. 86 0
      src/main/java/com/wechat/common/utils/ListPageUtil.java
  51. 422 0
      src/main/java/com/wechat/common/utils/LocalFileUtil.java
  52. 431 0
      src/main/java/com/wechat/common/utils/MailUtil.java
  53. 88 0
      src/main/java/com/wechat/common/utils/Md5Utils.java
  54. 153 0
      src/main/java/com/wechat/common/utils/MessageUtils.java
  55. 167 0
      src/main/java/com/wechat/common/utils/MvcUtil.java
  56. 295 0
      src/main/java/com/wechat/common/utils/NetworkUtils.java
  57. 285 0
      src/main/java/com/wechat/common/utils/NumberUtils.java
  58. 378 0
      src/main/java/com/wechat/common/utils/RSAUtils.java
  59. 304 0
      src/main/java/com/wechat/common/utils/Reflections.java
  60. 46 0
      src/main/java/com/wechat/common/utils/SSLClient.java
  61. 90 0
      src/main/java/com/wechat/common/utils/SignUtils.java
  62. 1187 0
      src/main/java/com/wechat/common/utils/StringsUtils.java
  63. 188 0
      src/main/java/com/wechat/common/utils/TLSSigAPIv2.java
  64. 99 0
      src/main/java/com/wechat/common/utils/Time2Now.java
  65. 98 0
      src/main/java/com/wechat/common/utils/WordUtils.java
  66. 42 0
      src/main/java/com/wechat/common/utils/XmlUtils.java
  67. 49 0
      src/main/java/com/wechat/common/utils/view/JSONView.java
  68. 81 0
      src/main/java/com/wechat/config/AlipayConfig.java
  69. 56 0
      src/main/java/com/wechat/config/ConfigReader.java
  70. 63 0
      src/main/java/com/wechat/controller/AuthorizedController.java
  71. 36 0
      src/main/java/com/wechat/controller/BoleInfoController.java
  72. 37 0
      src/main/java/com/wechat/controller/CaptchaController.java
  73. 749 0
      src/main/java/com/wechat/controller/CommonController.java
  74. 213 0
      src/main/java/com/wechat/controller/EnterpriseController.java
  75. 81 0
      src/main/java/com/wechat/controller/FaqController.java
  76. 53 0
      src/main/java/com/wechat/controller/ForgetPasswordController.java
  77. 203 0
      src/main/java/com/wechat/controller/GoodsController.java
  78. 153 0
      src/main/java/com/wechat/controller/GroupController.java
  79. 191 0
      src/main/java/com/wechat/controller/HumanVeinController.java
  80. 336 0
      src/main/java/com/wechat/controller/InterviewController.java
  81. 172 0
      src/main/java/com/wechat/controller/InvitationController.java
  82. 99 0
      src/main/java/com/wechat/controller/JsSdkController.java
  83. 263 0
      src/main/java/com/wechat/controller/LoginController.java
  84. 361 0
      src/main/java/com/wechat/controller/MainPageController.java
  85. 140 0
      src/main/java/com/wechat/controller/MendunerShowController.java
  86. 204 0
      src/main/java/com/wechat/controller/NoLoginController.java
  87. 308 0
      src/main/java/com/wechat/controller/OrderController.java
  88. 43 0
      src/main/java/com/wechat/controller/PackageController.java
  89. 854 0
      src/main/java/com/wechat/controller/PersonCeneterController.java
  90. 593 0
      src/main/java/com/wechat/controller/PositionController.java
  91. 92 0
      src/main/java/com/wechat/controller/QrCodeController.java
  92. 93 0
      src/main/java/com/wechat/controller/RecruitmentReleaseController.java
  93. 147 0
      src/main/java/com/wechat/controller/RefundController.java
  94. 347 0
      src/main/java/com/wechat/controller/RegisterController.java
  95. 160 0
      src/main/java/com/wechat/controller/TalentRetrievalController.java
  96. 144 0
      src/main/java/com/wechat/controller/TicketController.java
  97. 89 0
      src/main/java/com/wechat/controller/VerificationCodeController.java
  98. 266 0
      src/main/java/com/wechat/controller/WxMiniprogController.java
  99. 37 0
      src/main/java/com/wechat/dao/AccessTokenRedisDao.java
  100. 126 0
      src/main/java/com/wechat/dao/AdCtrRedisDao.java

+ 1 - 0
README.md

@@ -0,0 +1 @@
+#LZCT_API

+ 467 - 0
pom.xml

@@ -0,0 +1,467 @@
+<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/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>com.wechat</groupId>
+	<artifactId>RecruitmentApi</artifactId>
+	<packaging>war</packaging>
+	<version>1.0.0</version>
+	<name>RecruitmentApi Maven Webapp</name>
+	<url>http://maven.apache.org</url>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+	<dependencies>
+
+		<dependency>
+			<groupId>com.github.qcloudsms</groupId>
+			<artifactId>qcloudsms</artifactId>
+			<version>1.0.3</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.nutz</groupId>
+			<artifactId>nutz-plugins-qrcode</artifactId>
+			<version>1.r.60.r3</version>
+		</dependency>
+
+		<dependency>
+			<groupId>cn.apiclub.tool</groupId>
+			<artifactId>simplecaptcha</artifactId>
+			<version>1.2.2</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>3.1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.11</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-core</artifactId>
+			<version>4.2.4.RELEASE</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.springframework</groupId>
+		    <artifactId>spring-beans</artifactId>
+		    <version>4.2.4.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-webmvc</artifactId>
+			<version>4.2.4.RELEASE</version>
+		</dependency>
+		<!-- 发送邮件 -->
+		<dependency>
+			<groupId>javax.mail</groupId>
+			<artifactId>javax.mail-api</artifactId>
+			<version>1.5.3</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.mail</groupId>
+			<artifactId>javax.mail</artifactId>
+			<version>1.5.3</version>
+		</dependency>
+		<dependency>
+			    <groupId>com.alibaba</groupId>
+			    <artifactId>druid</artifactId>
+			    <version>1.1.10</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-jdbc</artifactId>
+			<version>5.2.3.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-tx</artifactId>
+			<version>4.2.4.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.aspectj</groupId>
+			<artifactId>aspectjweaver</artifactId>
+			<version>1.8.2</version>
+		</dependency>
+		<dependency>
+			<groupId>cn.apiclub.tool</groupId>
+			<artifactId>simplecaptcha</artifactId>
+			<version>1.2.2</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<version>1.2</version>
+		</dependency>
+		<dependency>
+			<groupId>com.auth0</groupId>
+			<artifactId>java-jwt</artifactId>
+			<version>3.1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>com.fasterxml.jackson.core</groupId>
+			<artifactId>jackson-core</artifactId>
+			<version>2.4.2</version>
+		</dependency>
+		<dependency>
+			<groupId>com.fasterxml.jackson.core</groupId>
+			<artifactId>jackson-databind</artifactId>
+			<version>2.4.2</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>1.4</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.6</version>
+		</dependency>
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.17</version>
+		</dependency>
+		<dependency>
+			<groupId>org.nutz</groupId>
+			<artifactId>nutz-plugins-qrcode</artifactId>
+			<version>1.r.60.r2</version>
+		</dependency>
+		<dependency>
+			<groupId>org.projectlombok</groupId>
+			<artifactId>lombok</artifactId>
+			<version>1.14.8</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context</artifactId>
+			<version>4.2.4.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.batch</groupId>
+			<artifactId>spring-batch-infrastructure</artifactId>
+			<version>4.0.0.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.data</groupId>
+			<artifactId>spring-data-redis</artifactId>
+			<version>1.6.2.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.12</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-aop</artifactId>
+			<version>4.2.4.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context-support</artifactId>
+			<version>4.2.4.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-pool2</artifactId>
+			<version>2.4.2</version>
+		</dependency>
+		<dependency>
+			<groupId>redis.clients</groupId>
+			<artifactId>jedis</artifactId>
+			<version>2.7.3</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.httpcomponents</groupId>
+			<artifactId>httpclient</artifactId>
+			<version>4.5</version>
+		</dependency>
+		<dependency>
+			<groupId>net.sf.json-lib</groupId>
+			<artifactId>json-lib</artifactId>
+			<version>2.4</version>
+			<classifier>jdk15</classifier>
+		</dependency>
+		<dependency>
+			<groupId>commons-fileupload</groupId>
+			<artifactId>commons-fileupload</artifactId>
+			<version>1.3.3</version>
+		</dependency>
+		<dependency>
+			<groupId>org.hibernate</groupId>
+			<artifactId>hibernate-core</artifactId>
+			<version>4.3.6.Final</version>
+		</dependency>
+		<dependency>
+			<groupId>org.hibernate</groupId>
+			<artifactId>hibernate-entitymanager</artifactId>
+			<version>4.3.6.Final</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.data</groupId>
+			<artifactId>spring-data-jpa</artifactId>
+			<version>2.1.6.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+			<version>1.7.12</version>
+		</dependency>
+		<dependency>
+			<groupId>net.sourceforge.jtds</groupId>
+			<artifactId>jtds</artifactId>
+			<version>1.2.4</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.maven.plugins</groupId>
+			<artifactId>maven-resources-plugin</artifactId>
+			<version>2.4.3</version>
+		</dependency>
+		<dependency>
+			<groupId>org.mybatis</groupId>
+			<artifactId>mybatis-spring</artifactId>
+			<version>1.3.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.mybatis</groupId>
+			<artifactId>mybatis</artifactId>
+			<version>3.4.2</version>
+		</dependency>
+	 	<dependency> 
+		    <groupId>org.mybatis</groupId> 
+		    <artifactId>mybatis-typehandlers-jsr310</artifactId> 
+			<version>1.0.1</version> 
+		</dependency>
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<version>5.1.8</version>
+		</dependency>
+		<dependency>
+			<groupId>org.bouncycastle</groupId>
+			<artifactId>bcprov-jdk15on</artifactId>
+			<version>1.52</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.axis</groupId>
+			<artifactId>axis</artifactId>
+			<version>1.4</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.axis</groupId>
+			<artifactId>axis-jaxrpc</artifactId>
+			<version>1.4</version>
+		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>19.0</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-discovery</groupId>
+			<artifactId>commons-discovery</artifactId>
+			<version>0.5</version>
+		</dependency>
+		<dependency>
+			<groupId>wsdl4j</groupId>
+			<artifactId>wsdl4j</artifactId>
+			<version>1.6.3</version>
+		</dependency>
+
+		<!-- http://mvnrepository.com/artifact/com.alibaba/fastjson -->
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>fastjson</artifactId>
+			<version>1.2.9</version>
+		</dependency>
+
+		<!-- https://mvnrepository.com/artifact/com.allenru/cross-origin -->
+		<!-- 跨域请求依赖 -->
+		<dependency>
+			<groupId>com.allenru</groupId>
+			<artifactId>cross-origin</artifactId>
+			<version>1.0.1</version>
+		</dependency>
+		
+		<!-- 生成word依赖 -->
+		<!-- <dependency>
+		    <groupId>org.freemarker</groupId>
+		    <artifactId>freemarker</artifactId>
+		    <version>2.3.23</version>
+		</dependency> -->
+		<dependency>
+			<groupId>com.deepoove</groupId>
+			<artifactId>poi-tl</artifactId>
+			<version>1.3.0</version>
+		</dependency>
+		
+		<dependency>
+		    <groupId>org.hibernate</groupId>
+		    <artifactId>hibernate-validator</artifactId>
+		    <version>5.3.5.Final</version>
+		</dependency>
+        
+        <!-- 图片缩略图 -->
+		<dependency>
+		    <groupId>net.coobird</groupId>
+		    <artifactId>thumbnailator</artifactId>
+		    <version>0.4.8</version>
+		</dependency>
+		
+		<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
+		<dependency>
+		    <groupId>com.itextpdf</groupId>
+		    <artifactId>itextpdf</artifactId>
+		    <version>5.5.13</version>
+		</dependency>
+		
+		<!-- 控制word输出 -->
+		<dependency>
+		    <groupId>org.apache.poi</groupId>
+		    <artifactId>poi</artifactId>
+		    <version>4.1.0</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.apache.poi</groupId>
+		    <artifactId>poi-scratchpad</artifactId>
+		    <version>4.1.0</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.apache.poi</groupId>
+		    <artifactId>poi-ooxml</artifactId>
+		    <version>4.1.0</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.apache.poi</groupId>
+		    <artifactId>poi-ooxml-schemas</artifactId>
+		    <version>4.1.0</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.apache.poi</groupId>
+		    <artifactId>ooxml-schemas</artifactId>
+		    <version>1.4</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.docx4j</groupId>
+		    <artifactId>docx4j</artifactId>
+		    <version>6.1.2</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.docx4j</groupId>
+		    <artifactId>docx4j-ImportXHTML</artifactId>
+		     <version>8.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.xml.bind</groupId>
+			<artifactId>jaxb-impl</artifactId>
+			<version>2.3.1</version>
+		</dependency>
+		<dependency>
+		    <groupId>com.sun.istack</groupId>
+		    <artifactId>istack-commons-runtime</artifactId>
+		    <version>3.0.8</version>
+		</dependency>
+		<!-- 腾讯云开发者工具套件(SDK) 请到https://search.maven.org/search?q=tencentcloud-sdk-java查询最新版本 -->
+		<dependency>
+		  <groupId>com.tencentcloudapi</groupId>
+		  <artifactId>tencentcloud-sdk-java</artifactId>
+		  <version>3.1.119</version>
+		</dependency>
+		<!-- https://mvnrepository.com/artifact/com.github.stuxuhai/jpinyin -->
+		<!-- 
+			可以识别词组、成语、地名
+			ChineseHelper.java     汉字简繁体转换类
+			PinyinFormat.java         拼音格式类
+			PinyinHelper.java          汉字转拼音类
+			PinyinResource.java    资源文件加载类
+		 -->
+		<dependency>
+		    <groupId>com.github.stuxuhai</groupId>
+		    <artifactId>jpinyin</artifactId>
+		    <version>1.1.8</version>
+		</dependency>
+		<!-- 解析html -->
+		<dependency>
+		    <groupId>org.jsoup</groupId>
+		    <artifactId>jsoup</artifactId>
+		    <version>1.11.3</version>
+		</dependency>
+		<!-- 解析HTTPServletRequest -->
+		<dependency>
+		    <groupId>nl.basjes.parse.useragent</groupId>
+		    <artifactId>yauaa</artifactId>
+		    <version>5.14</version>
+		</dependency>
+				
+	</dependencies>
+
+	<build>
+		<finalName>RecruitmentApi</finalName>
+		<defaultGoal>compile</defaultGoal>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.2</version>
+				<configuration>
+					<source>1.8</source>
+					<target>1.8</target>
+					<compilerArguments>
+						<extdirs>src/main/webapp/WEB-INF/lib</extdirs>
+					</compilerArguments>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<version>2.12.4</version>
+				<configuration>
+					<skipTests>true</skipTests>
+				</configuration>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>
+											org.apache.maven.plugins
+										</groupId>
+										<artifactId>
+											maven-compiler-plugin
+										</artifactId>
+										<versionRange>
+											[3.2,)
+										</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore></ignore>
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+</project>

+ 31 - 0
src/main/java/com/wechat/activerequests/ActiveRequests.java

@@ -0,0 +1,31 @@
+//package com.wechat.activerequests;
+//
+//import org.apache.commons.logging.LogFactory;
+//
+//import com.wechat.activerequests.requests.IActiveRequest;
+//import com.wechat.activerequests.responses.BaseResponse;
+//import com.wechat.common.utils.JacksonUtils;
+//import com.wechat.common.utils.NetworkUtils;
+//import com.wechat.service.WeiXinService;
+//
+//public class ActiveRequests {
+//
+//    /**
+//     * 实际发送接口
+//     */
+//    public static BaseResponse send(IActiveRequest req) {
+//    	
+//        String url = req.getTargetUrl();
+//        String payload = req.getPayload();
+//        LogFactory.getLog(ActiveRequests.class).debug("Ready to send request to:" + url + "\n payload: "+ payload);
+//        BaseResponse rsp;
+//        if (payload == null) {
+//            rsp = NetworkUtils.getRemoteResponseAsJsonMethodGET(url, req.getResponseType());
+//        } else {
+//            url = String.format("%s?access_token=%s", url, WeiXinService.getInstance().getAccessToken());
+//            rsp = NetworkUtils.getRemoteResponseAsJsonWithStringPayload(url, payload, req.getResponseType());
+//        }
+//        LogFactory.getLog(ActiveRequests.class).debug("Responded: " + JacksonUtils.beautifulSerialize(rsp));
+//        return rsp;
+//    }
+//}

+ 7 - 0
src/main/java/com/wechat/activerequests/EnumUserIdentifierType.java

@@ -0,0 +1,7 @@
+package com.wechat.activerequests;
+
+public enum EnumUserIdentifierType {
+    OPENID,
+    QQ,
+    MOBILE
+}

+ 19 - 0
src/main/java/com/wechat/activerequests/responses/CustomeServiceResponse.java

@@ -0,0 +1,19 @@
+package com.wechat.activerequests.responses;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public final class CustomeServiceResponse extends WxBaseResponse {
+    @JsonProperty("createtime")
+    private String createtime;
+
+    public String getCreateTime() {
+        return createtime;
+    }
+    
+    @JsonProperty("kf_account")
+    private String kfAccount;
+
+    public String getKfAccount() {
+        return kfAccount;
+    }
+}

+ 12 - 0
src/main/java/com/wechat/activerequests/responses/MessageIdResponse.java

@@ -0,0 +1,12 @@
+package com.wechat.activerequests.responses;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public final class MessageIdResponse extends WxBaseResponse {
+    @JsonProperty("msgid")
+    private Long messageId;
+
+    public Long getMessageId() {
+        return messageId;
+    }
+}

+ 25 - 0
src/main/java/com/wechat/activerequests/responses/WxBaseResponse.java

@@ -0,0 +1,25 @@
+package com.wechat.activerequests.responses;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * 主动接口调用回执
+ */
+public class WxBaseResponse {
+    @JsonProperty("errcode")
+    private Long errCode = 0L;
+    @JsonProperty("errmsg")
+    private String errMsg;
+
+    public final Long getErrorCode() {
+        return errCode;
+    }
+
+    public final String getErrorMsg() {
+        return errMsg;
+    }
+
+    public boolean isSuccessful() {
+        return errCode == 0L;
+    }
+}

+ 137 - 0
src/main/java/com/wechat/callback/controller/MasterRequestController.java

@@ -0,0 +1,137 @@
+package com.wechat.callback.controller;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.callback.handlers.ITencentRequestHandler;
+import com.wechat.callback.passiveresponses.BasePassiveResponse;
+import com.wechat.callback.passiveresponses.TextResponse;
+import com.wechat.callback.tencentrequests.BaseRequest;
+import com.wechat.callback.tencentrequests.TBaseRequest;
+import com.wechat.common.utils.DateUtils;
+import com.wechat.common.utils.JacksonUtils;
+import com.wechat.common.utils.SignUtils;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.common.utils.XmlUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+
+/**
+ * 核心请求处理类 
+ * @author jt-wu
+ */
+@Controller
+@RequestMapping("weChatCallBack")
+public class MasterRequestController extends BaseController {
+    @Autowired
+    @Qualifier("eventHandler")
+    ITencentRequestHandler eventHandler;
+
+    @Autowired
+    @Qualifier("textHandler")
+    ITencentRequestHandler textHandler;
+
+    
+    // 与接口配置信息中的Token一致
+    @Value("#{configProperties['token']}")
+    private  String    token;
+
+
+    @RequestMapping(value = "main", method = RequestMethod.GET)
+    @ResponseBody
+    protected String doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        request.setCharacterEncoding("UTF-8");  
+        response.setCharacterEncoding("UTF-8");
+        
+        /** 判断是否是微信接入激活验证,只有首次接入验证时才会收到echostr参数,此时需要验证后把它返回 */  
+        // 随机字符串  
+        String echostr = request.getParameter("echostr");  
+        if (echostr != null && echostr.length() > 1) {  
+            // 微信加密签名  
+            String signature = request.getParameter("signature");  
+            // 时间戳  
+            String timestamp = request.getParameter("timestamp");  
+            // 随机数  
+            String nonce = request.getParameter("nonce");  
+
+            // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败  
+            if (SignUtils.checkSignature(token, signature, timestamp, nonce)) {  
+                return echostr;  
+            }
+            else
+            {
+                return null;
+            }
+        }
+        else
+        {
+            return null;
+        }
+    }
+    
+    
+    /**
+     * 回调主接口
+     */
+    @RequestMapping(value = "main", method = RequestMethod.POST)
+    @ResponseBody
+    public BasePassiveResponse callbackEntrance(@RequestBody String xml) {
+        try {
+            log.info("*********↓回调主入口XML↓*********");
+            log.info(xml);
+            log.info("*********↑回调主入口XML↑*********");
+            if (xml.trim().length() == 0) {
+                return new TextResponse(InfoMsg.ERROR_EMPTY_REQUEST.getMsg());
+            }
+            TBaseRequest req = XmlUtils.xml2obj(xml, TBaseRequest.class);
+            if (req == null) throw new RuntimeException("Xml parse error");
+            BaseRequest.MsgTypeEnum msgType = req.getMsgType();
+            BasePassiveResponse rsp = null;
+            switch (msgType) {
+                case TEXT: {
+                    rsp = textHandler.handle(xml, null);
+                    break;
+                }
+                case EVENT: {
+                    rsp = eventHandler.handle(xml, null);
+                    break;
+                }
+                default: {
+                	log.warn("未定义的入口消息类型:[" + msgType + "]");
+                    return TextResponse.NULL_RESPONSE;
+                }
+            }
+            
+            if (rsp == BasePassiveResponse.NULL_RESPONSE)
+            {
+            	return null;
+            }
+
+            if (rsp == null)
+            {
+            	rsp = TextResponse.SERVER_ERROR();
+            }
+                
+            rsp.setFromUserName(req.getToUserName());
+            rsp.setToUserName(req.getFromUserName());
+            rsp.setCreateTime(StringsUtils.parseLong(DateUtils.getCurrentDate().getTime()));
+            log.debug("Responded: " + JacksonUtils.beautifulSerialize(rsp));
+            return rsp;
+        } catch (Exception ex) {
+            log.error("腾讯回调入口解析异常:", ex);
+            return TextResponse.SERVER_ERROR();
+        }
+    }
+}

+ 137 - 0
src/main/java/com/wechat/callback/controller/MiniprogMasterController.java

@@ -0,0 +1,137 @@
+package com.wechat.callback.controller;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.callback.handlers.ITencentRequestHandler;
+import com.wechat.callback.passiveresponses.BasePassiveResponse;
+import com.wechat.callback.passiveresponses.TextResponse;
+import com.wechat.callback.tencentrequests.BaseRequest;
+import com.wechat.callback.tencentrequests.TBaseRequest;
+import com.wechat.common.utils.DateUtils;
+import com.wechat.common.utils.JacksonUtils;
+import com.wechat.common.utils.SignUtils;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.common.utils.XmlUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+
+/**
+ * 核心请求处理类 
+ * @author jt-wu
+ */
+@Controller
+@RequestMapping("miniprogCallBack")
+public class MiniprogMasterController extends BaseController {
+    @Autowired
+    @Qualifier("eventHandler")
+    ITencentRequestHandler eventHandler;
+
+    @Autowired
+    @Qualifier("textHandler")
+    ITencentRequestHandler textHandler;
+
+    
+    // 与接口配置信息中的Token一致
+    @Value("#{configProperties['wx.miniprog.video.token']}")
+    private  String    miniprogVideoToken;
+
+
+    @RequestMapping(value = "main", method = RequestMethod.GET)
+    @ResponseBody
+    protected String doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        request.setCharacterEncoding("UTF-8");  
+        response.setCharacterEncoding("UTF-8");
+        
+        /** 判断是否是微信接入激活验证,只有首次接入验证时才会收到echostr参数,此时需要验证后把它返回 */  
+        // 随机字符串  
+        String echostr = request.getParameter("echostr");  
+        if (echostr != null && echostr.length() > 1) {  
+            // 微信加密签名  
+            String signature = request.getParameter("signature");  
+            // 时间戳  
+            String timestamp = request.getParameter("timestamp");  
+            // 随机数  
+            String nonce = request.getParameter("nonce");  
+
+            // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败  
+            if (SignUtils.checkSignature(miniprogVideoToken, signature, timestamp, nonce)) {  
+                return echostr;  
+            }
+            else
+            {
+                return null;
+            }
+        }
+        else
+        {
+            return null;
+        }
+    }
+    
+    
+    /**
+     * 回调主接口
+     */
+    @RequestMapping(value = "main", method = RequestMethod.POST)
+    @ResponseBody
+    public BasePassiveResponse callbackEntrance(@RequestBody String xml) {
+        try {
+            log.info("*********↓回调主入口XML↓*********");
+            log.info(xml);
+            log.info("*********↑回调主入口XML↑*********");
+            if (xml.trim().length() == 0) {
+                return new TextResponse(InfoMsg.ERROR_EMPTY_REQUEST.getMsg());
+            }
+            TBaseRequest req = XmlUtils.xml2obj(xml, TBaseRequest.class);
+            if (req == null) throw new RuntimeException("Xml parse error");
+            BaseRequest.MsgTypeEnum msgType = req.getMsgType();
+            BasePassiveResponse rsp = null;
+            switch (msgType) {
+                case TEXT: {
+                    rsp = textHandler.handle(xml, null);
+                    break;
+                }
+                case EVENT: {
+                    rsp = eventHandler.handle(xml, null);
+                    break;
+                }
+                default: {
+                	log.warn("未定义的入口消息类型:[" + msgType + "]");
+                    return TextResponse.NULL_RESPONSE;
+                }
+            }
+            
+            if (rsp == BasePassiveResponse.NULL_RESPONSE)
+            {
+            	return null;
+            }
+
+            if (rsp == null)
+            {
+            	rsp = TextResponse.SERVER_ERROR();
+            }
+                
+            rsp.setFromUserName(req.getToUserName());
+            rsp.setToUserName(req.getFromUserName());
+            rsp.setCreateTime(StringsUtils.parseLong(DateUtils.getCurrentDate().getTime()));
+            log.debug("Responded: " + JacksonUtils.beautifulSerialize(rsp));
+            return rsp;
+        } catch (Exception ex) {
+            log.error("腾讯回调入口解析异常:", ex);
+            return TextResponse.SERVER_ERROR();
+        }
+    }
+}

+ 12 - 0
src/main/java/com/wechat/callback/handlers/ITencentRequestHandler.java

@@ -0,0 +1,12 @@
+package com.wechat.callback.handlers;
+
+import com.wechat.callback.passiveresponses.BasePassiveResponse;
+
+/**
+ * 
+ * @author Hptest
+ *
+ */
+public interface ITencentRequestHandler {
+    public BasePassiveResponse handle(String xml, Object obj);
+}

+ 57 - 0
src/main/java/com/wechat/callback/handlers/event/ClickReceivedHandler.java

@@ -0,0 +1,57 @@
+package com.wechat.callback.handlers.event;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.wechat.callback.handlers.ITencentRequestHandler;
+import com.wechat.callback.passiveresponses.BasePassiveResponse;
+import com.wechat.callback.passiveresponses.TextResponse;
+import com.wechat.callback.processors.ClickEventProcessor;
+import com.wechat.callback.tencentrequests.events.ClickEventRequest;
+import com.wechat.common.utils.XmlUtils;
+
+/**
+ * 按钮处理类
+ */
+
+@Component("clickEvent")
+public class ClickReceivedHandler implements ITencentRequestHandler {
+    @Autowired
+    ClickEventProcessor clickProcessor;
+    
+    //log
+    protected static final Log log = LogFactory.getLog(ClickReceivedHandler.class);
+
+    @Override
+    public BasePassiveResponse handle(String xml, Object obj) {
+        try {
+            ClickEventRequest req = XmlUtils.xml2obj(xml, ClickEventRequest.class);
+            if (req == null) {
+                throw new RuntimeException("Xml parse error");
+            }
+
+            if (req.getEventKey() == null) {
+                log.warn("点击事件类别为空!");
+                return BasePassiveResponse.NULL_RESPONSE;
+            }
+
+            switch (req.getEventKey()) {
+                //我的账户
+                case CALL_ACCOUNT_INQUIRY: {
+                    TextResponse response = clickProcessor.getAccountBinding(req);
+                    return response;
+                }
+
+                default: {
+                    log.warn("未定义的点击事件:[ " + req.getEventKey() + "]");
+                    return BasePassiveResponse.NULL_RESPONSE;
+                }
+            }
+        } catch (Exception ex) {
+            log.error("点击事件分发处理异常");
+            log.error(ex);
+            return TextResponse.SERVER_ERROR();
+        }
+    }
+}

+ 79 - 0
src/main/java/com/wechat/callback/handlers/event/EventReceivedHandler.java

@@ -0,0 +1,79 @@
+package com.wechat.callback.handlers.event;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import com.wechat.callback.handlers.ITencentRequestHandler;
+import com.wechat.callback.passiveresponses.BasePassiveResponse;
+import com.wechat.callback.passiveresponses.TextResponse;
+import com.wechat.callback.tencentrequests.events.BaseEventRequest;
+import com.wechat.callback.tencentrequests.events.TBaseEventRequest;
+import com.wechat.common.utils.XmlUtils;
+
+/**
+ * 事件处理类
+ */
+@Component("eventHandler")
+public class EventReceivedHandler implements ITencentRequestHandler {
+    @Autowired
+    @Qualifier("clickEvent")
+    ITencentRequestHandler clickEventHandler;
+    
+//    @Autowired
+//    @Qualifier("unSubscribeEvent")
+//    ITencentRequestHandler unSubscribeHandler;
+//    
+    @Autowired
+    @Qualifier("subscribeEvent")
+    ITencentRequestHandler subscribeHandler;
+    
+    @Autowired
+    @Qualifier("templateSendFinishEvent")
+    ITencentRequestHandler templateSendFinishHandler;
+
+    //log
+    protected static final Log log = LogFactory.getLog(EventReceivedHandler.class);
+    
+    @Override
+    public BasePassiveResponse handle(String xml, Object obj) {
+        try {
+            BaseEventRequest.EventType eventType = XmlUtils.xml2obj(xml, TBaseEventRequest.class).getEventType();
+            //事件类型为空时
+            if (eventType == null) {
+                log.warn("事件类型为空!");
+                return BasePassiveResponse.NULL_RESPONSE;
+            }
+            
+            switch (eventType) {
+                //按钮处理
+                case CLICK: {
+                    return clickEventHandler.handle(xml, null);
+                }
+                //取消关注事件
+//                case UNSUBSCRIBE:{
+//                    return unSubscribeHandler.handle(xml,null);
+//                }
+                //关注事件
+                case SUBSCRIBE:{
+                    return subscribeHandler.handle(xml,null);
+                }
+                //模板消息发送回执事件
+                case TEMPLATESENDJOBFINISH:{
+                    return templateSendFinishHandler.handle(xml,null);
+                }
+
+                default: {
+                    log.warn("未定义的事件类型:[" + eventType + "]");
+                    return TextResponse.NULL_RESPONSE;
+                }
+            }
+        } catch (Exception ex) {
+            log.error("事件分发处理异常");
+            log.error(ex);
+            return TextResponse.SERVER_ERROR();
+        }
+    }
+}

+ 64 - 0
src/main/java/com/wechat/callback/handlers/event/SubscribeEventHandler.java

@@ -0,0 +1,64 @@
+package com.wechat.callback.handlers.event;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import com.wechat.callback.handlers.ITencentRequestHandler;
+import com.wechat.callback.passiveresponses.TextResponse;
+import com.wechat.callback.tencentrequests.events.TBaseEventRequest;
+import com.wechat.common.Constants;
+import com.wechat.common.utils.XmlUtils;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.TdtgFoucsView;
+import com.wechat.service.SubscribeService;
+
+@Component("subscribeEvent")
+public class SubscribeEventHandler implements ITencentRequestHandler {
+    //订阅信息
+    @Value("#{messageProperties['tmpl.subscribe']}")
+    private String             tmplSubscribe;
+
+    @Resource
+    private SubscribeService subscribeService;
+    
+    @Override
+    public TextResponse handle(String xml, Object obj) {
+        TextResponse textResponse = new TextResponse();
+        try {
+            TBaseEventRequest req = XmlUtils.xml2obj(xml, TBaseEventRequest.class);
+            if (req == null) {
+                textResponse.setContent(InfoMsg.ERROR_SYSTEM_ERROR.getMsg());
+            }
+            else {
+            	
+            	//通过用户发送的信息,检索FAQ内容
+                TdtgFoucsView contentDto = subscribeService.selectTxt();
+                if (contentDto == null) {
+                    // 没有抽取到数据
+                    return null;
+                }
+                else {
+                    StringBuffer sb = new StringBuffer();
+
+                    // 将回车变成换行,腾讯不接收回车。
+                    sb.append(contentDto.getFocusText().replaceAll(Constants.ENTER_LINE, Constants.NEXT_LINE));
+
+                    StringBuffer sTemp = new StringBuffer(); 
+                    sTemp.append(sb.toString());
+
+                    textResponse.setContent(sb.toString()); 
+                }          
+            }
+        }
+        catch (Exception ex) {
+            textResponse.setContent(InfoMsg.ERROR_SYSTEM_ERROR.getMsg());
+            LogFactory.getLog(SubscribeEventHandler.class).error(ex);
+        }
+        return textResponse;
+    }
+    
+    
+}

+ 40 - 0
src/main/java/com/wechat/callback/handlers/event/TemplateSendFinishEventHandler.java

@@ -0,0 +1,40 @@
+package com.wechat.callback.handlers.event;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Component;
+
+import com.wechat.callback.handlers.ITencentRequestHandler;
+import com.wechat.callback.passiveresponses.BasePassiveResponse;
+import com.wechat.callback.passiveresponses.TextResponse;
+import com.wechat.callback.tencentrequests.events.TemplateSendFinishEventRequest;
+import com.wechat.common.utils.XmlUtils;
+
+@Component("templateSendFinishEvent")
+public class TemplateSendFinishEventHandler implements ITencentRequestHandler {
+    
+    protected static final Log log = LogFactory.getLog(TemplateSendFinishEventHandler.class);
+    
+    @Override
+    public BasePassiveResponse handle(String xml, Object obj) {
+        try {
+            TemplateSendFinishEventRequest req = XmlUtils.xml2obj(xml, TemplateSendFinishEventRequest.class);
+            if (req == null) {
+                throw new Exception("Xml parse error");
+            }
+            
+            if(!req.getStatus().equals(TemplateSendFinishEventRequest.StatusEnum.SUCCESS))
+            {
+                log.error("模板消息推送失败:[ " + req.getStatus() + "]");
+                log.error("OpenID:[ " + req.getFromUserName() + "]");
+                log.error("CreateTime:[ " + req.getCreateTime() + "]");
+                log.error("MsgID:[ " + req.getMsgID() + "]");
+            }
+        }
+        catch (Exception ex) {
+            log.error("message:",ex);
+        }
+        
+        return TextResponse.NULL_RESPONSE;
+    }
+}

+ 75 - 0
src/main/java/com/wechat/callback/handlers/text/TextMessageReceivedHandler.java

@@ -0,0 +1,75 @@
+package com.wechat.callback.handlers.text;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+import com.wechat.callback.handlers.ITencentRequestHandler;
+import com.wechat.callback.passiveresponses.BasePassiveResponse;
+import com.wechat.callback.passiveresponses.TextResponse;
+import com.wechat.callback.processors.CustomerServiceProcessor;
+import com.wechat.callback.processors.FaqAnswerProcessor;
+import com.wechat.callback.tencentrequests.UserSentTextRequest;
+import com.wechat.common.utils.XmlUtils;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.TdtgFaqInfo;
+
+@Component
+@Qualifier("textHandler")
+public class TextMessageReceivedHandler implements ITencentRequestHandler {
+    protected static final Log log = LogFactory.getLog(TextMessageReceivedHandler.class);
+
+    @Autowired
+    FaqAnswerProcessor faqProcessor;
+    
+    
+    @Autowired
+    CustomerServiceProcessor         serviceProcessor;
+    
+    @Override
+    public BasePassiveResponse handle(String xml, Object obj) {
+        UserSentTextRequest req = XmlUtils.xml2obj(xml, UserSentTextRequest.class);
+        try {
+	        if (req == null) {
+	            log.error("*********文本反馈XML解析异常********");
+	            return new TextResponse(InfoMsg.ERROR_SYSTEM_ERROR.getMsg());
+	        }
+	        else {
+				log.info("Text Input:[" + req.getContent() + "]");
+				List<TdtgFaqInfo> faqInfoList = faqProcessor.getAllInfoByKeyWord(req);
+				
+				if(faqInfoList.size() > 0)
+				{
+					boolean isNewsMsg = false;
+					for (TdtgFaqInfo faqInfo : faqInfoList) {
+						if (faqInfo.getMsgType() == 1) {
+							isNewsMsg = true;
+							break;
+						}
+					}
+					if (faqInfoList.size() == 0 || isNewsMsg == false) {
+						// 返回文本消息
+						log.info("Return text response");
+						return faqProcessor.getFAQTextResponse(req);
+					} else {
+						// 返回图文消息
+						log.info("Return news response");
+						return faqProcessor.getFAQNewsResponse(faqInfoList);
+					}
+				}
+				else
+				{
+					//faq查不到发送给客服
+	                return serviceProcessor.getCustomerService(req.getFromUserName());
+				}
+
+			}
+		}
+	   catch (Exception e) {
+		   return new TextResponse(InfoMsg.ERROR_SYSTEM_ERROR.getMsg());
+		}
+    }
+}

+ 69 - 0
src/main/java/com/wechat/callback/passiveresponses/BasePassiveResponse.java

@@ -0,0 +1,69 @@
+package com.wechat.callback.passiveresponses;
+
+import javax.xml.bind.annotation.*;
+
+import com.wechat.common.utils.DateUtils;
+import com.wechat.common.utils.StringsUtils;
+
+/**
+ * in fact, it's identical to tencentrequests.BaseRequest
+ * except the MsgTypeEnum
+ */
+@XmlTransient
+public abstract class BasePassiveResponse {
+    @XmlType
+    @XmlEnum(String.class)
+    public static enum MsgTypeEnum {
+        @XmlEnumValue("text")TEXT, //文本
+        @XmlEnumValue("news")NEWS, //图文
+        @XmlEnumValue("transfer_customer_service")SERVICE, //多客服
+        @XmlEnumValue("image")IMAGE //图片
+    }
+
+    public final static BasePassiveResponse NULL_RESPONSE = null;
+
+    private String ToUserName;  //用户OpenID
+    private String FromUserName;//公众号
+    private String CreateTime;//创建时间
+    private MsgTypeEnum MsgType;//消息类型
+
+    protected BasePassiveResponse() {
+        setCreateTime(StringsUtils.parseLong(DateUtils.getCurrentDate().getTime()));
+    }
+
+    public String getToUserName() {
+        return ToUserName;
+    }
+
+    @XmlElement(name = "ToUserName")
+    public void setToUserName(String toUserName) {
+        ToUserName = toUserName;
+    }
+
+    public String getFromUserName() {
+        return FromUserName;
+    }
+
+    @XmlElement(name = "FromUserName")
+    public void setFromUserName(String fromUserName) {
+        FromUserName = fromUserName;
+    }
+
+    public String getCreateTime() {
+        return CreateTime;
+    }
+
+    @XmlElement(name = "CreateTime")
+    public void setCreateTime(String createTime) {
+        CreateTime = createTime;
+    }
+
+    public MsgTypeEnum getMsgType() {
+        return MsgType;
+    }
+
+    @XmlElement(name = "MsgType")
+    public void setMsgType(MsgTypeEnum msgType) {
+        MsgType = msgType;
+    }
+}

+ 72 - 0
src/main/java/com/wechat/callback/passiveresponses/NewsResponse.java

@@ -0,0 +1,72 @@
+package com.wechat.callback.passiveresponses;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import com.wechat.callback.passiveresponses.BasePassiveResponse.MsgTypeEnum;
+
+import java.util.LinkedList;
+import java.util.List;
+
+@XmlRootElement(name = "xml")
+public final class NewsResponse extends BasePassiveResponse {
+
+    private static final class PictureArticle {
+        private String title;
+        private String desc;
+        private String picurl;
+        private String url;
+
+        public PictureArticle(String title, String desc, String picurl, String url) {
+            super();
+            this.title = title;
+            this.desc = desc;
+            this.picurl = picurl;
+            this.url = url;
+        }
+
+        @XmlElement(name = "Title")
+        public String getTitle() {
+            return title;
+        }
+
+        @XmlElement(name = "Description")
+        public String getDesc() {
+            return desc;
+        }
+
+        @XmlElement(name = "PicUrl")
+        public String getPicurl() {
+            return picurl;
+        }
+
+        @XmlElement(name = "Url")
+        public String getUrl() {
+            return url;
+        }
+    }
+
+    private List<PictureArticle> articles = null;
+
+    public NewsResponse() {
+        setMsgType(MsgTypeEnum.NEWS);
+        articles = new LinkedList<>();
+    }   
+    
+    public NewsResponse appendArticle(String title, String desc, String picurl, String url) {
+        articles.add(new PictureArticle(title, desc, picurl, url));
+        return this;
+    }
+
+    @XmlElementWrapper(name = "Articles")
+    @XmlElement(name = "item")
+    public List<PictureArticle> getArticles() {
+        return articles;
+    }
+
+    @XmlElement(name = "ArticleCount")
+    public Integer getArticleCount() {
+        return articles.size();
+    }
+}

+ 29 - 0
src/main/java/com/wechat/callback/passiveresponses/PictureResponse.java

@@ -0,0 +1,29 @@
+package com.wechat.callback.passiveresponses;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Collections;
+import java.util.List;
+
+@XmlRootElement(name = "xml")
+public final class PictureResponse extends BasePassiveResponse {
+    private List<String> mediaId;
+
+    public PictureResponse() {
+        super();
+        setMsgType(MsgTypeEnum.IMAGE);
+    }
+
+    public PictureResponse(final String mediaIdIn) {
+        super();
+        this.mediaId = Collections.singletonList(mediaIdIn);
+        setMsgType(MsgTypeEnum.IMAGE);
+    }
+
+    @XmlElementWrapper(name = "Image")
+    @XmlElement(name = "MediaId")
+    public List<String> getMediaId() {
+        return mediaId;
+    }
+}

+ 12 - 0
src/main/java/com/wechat/callback/passiveresponses/ServiceResponse.java

@@ -0,0 +1,12 @@
+package com.wechat.callback.passiveresponses;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "xml")
+public final class ServiceResponse extends BasePassiveResponse {
+
+    public ServiceResponse() {
+        super();
+        setMsgType(MsgTypeEnum.SERVICE);
+    }
+}

+ 38 - 0
src/main/java/com/wechat/callback/passiveresponses/TextResponse.java

@@ -0,0 +1,38 @@
+package com.wechat.callback.passiveresponses;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import com.wechat.global.message.InfoMsg;
+
+@XmlRootElement(name = "xml")
+public final class TextResponse extends BasePassiveResponse {
+
+    private String content;//消息内容
+
+    /**
+     * 系统出错提示
+     */
+    public static TextResponse SERVER_ERROR() {
+        return new TextResponse(InfoMsg.ERROR_SYSTEM_ERROR.getMsg());
+    }
+
+    public TextResponse(String response) {
+        super();
+        setMsgType(MsgTypeEnum.TEXT);
+        setContent(response);
+    }
+
+    public TextResponse() {
+        super();
+        setMsgType(MsgTypeEnum.TEXT);
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    @XmlElement(name = "Content")
+    public void setContent(String content) {
+        this.content = content.replace("\\", "\\\\").replace("\"", "\\\"");
+    }
+}

+ 43 - 0
src/main/java/com/wechat/callback/processors/ClickEventProcessor.java

@@ -0,0 +1,43 @@
+package com.wechat.callback.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.wechat.callback.passiveresponses.TextResponse;
+import com.wechat.callback.tencentrequests.events.ClickEventRequest;
+import com.wechat.common.CommonHelper;
+import com.wechat.global.message.InfoMsg;
+
+// 按钮事件处理类
+@Component
+public class ClickEventProcessor {
+
+    @Autowired
+    CommonHelper               helper;
+
+    
+
+    protected static final Log log = LogFactory.getLog(ClickEventProcessor.class);
+
+    //账户绑定
+    public TextResponse getAccountBinding(ClickEventRequest req) {
+        TextResponse rsp = new TextResponse();
+        try {
+            //用户OpenID
+            String openID = req.getFromUserName();
+
+            rsp.setContent(openID);
+        }
+        catch (Exception e) {
+            log.equals(e);
+            //系统异常
+            rsp.setContent(InfoMsg.ERROR_SYSTEM_ERROR.getMsg());
+        }
+        return rsp;
+    }
+
+   
+
+}

+ 37 - 0
src/main/java/com/wechat/callback/processors/CustomerServiceProcessor.java

@@ -0,0 +1,37 @@
+package com.wechat.callback.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Component;
+
+import com.wechat.callback.passiveresponses.BasePassiveResponse;
+import com.wechat.callback.passiveresponses.ServiceResponse;
+import com.wechat.callback.passiveresponses.TextResponse;
+
+
+/**
+ * 多客服
+ *
+ * @author jt-wu
+ */
+@Component
+public class CustomerServiceProcessor {
+
+
+    protected static final Log log = LogFactory.getLog(CustomerServiceProcessor.class);
+    
+    //多客服跳转
+    public BasePassiveResponse getCustomerService(String openId) {
+        try {
+            //用户OpenID
+        	ServiceResponse rsp = new ServiceResponse();	
+            return rsp;
+        }
+        catch (Exception e) {
+            log.equals(e);
+            //系统异常
+            return TextResponse.SERVER_ERROR();
+        }
+    }
+
+}

+ 133 - 0
src/main/java/com/wechat/callback/processors/FaqAnswerProcessor.java

@@ -0,0 +1,133 @@
+package com.wechat.callback.processors;
+
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import com.wechat.callback.passiveresponses.NewsResponse;
+import com.wechat.callback.passiveresponses.TextResponse;
+import com.wechat.callback.tencentrequests.UserSentTextRequest;
+import com.wechat.common.CommonHelper;
+import com.wechat.common.Constants;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.TdtgFaqInfo;
+import com.wechat.service.FaqService;
+
+/**
+ * FAQ问答回复
+ *
+ * @author la-lin
+ */
+@Component
+public class FaqAnswerProcessor {
+    //faq 内容
+    @Value("#{configProperties['url.client.faqContent']}")
+    private String             urlFaqContent;
+    
+    //根域名
+    @Value("#{configProperties['url.base']}")
+    private String             urlBase;
+    
+    //图片根目录
+    @Value("#{configProperties['url.img.base']}")
+    private String             urlImgBase;
+  
+    @Autowired
+    private CommonHelper         commonHelper;
+    
+    @Resource
+    private FaqService faqService;
+
+    protected static final Log log = LogFactory.getLog(FaqAnswerProcessor.class);
+
+
+    public TextResponse getFAQTextResponse(UserSentTextRequest req) {
+        TextResponse rsp = new TextResponse();
+        try {
+            String resContent = ""; // 回复用户的信息 
+            
+    		//通过用户发送的信息,检索FAQ内容
+            TdtgFaqInfo faqInfo = faqService.getInfoByKeyWord(req.getContent());
+            if (faqInfo == null) {
+                // 没有抽取到FAQ数据
+                return null;
+            }
+            else {
+                StringBuffer sb = new StringBuffer();
+                // FAQ标题
+                sb.append(faqInfo.getTitle());
+                // 换行
+                sb.append(Constants.NEXT_LINE);
+                // FAQ内容
+                // 将回车变成换行,腾讯不接收回车。
+                sb.append(faqInfo.getContent().replaceAll(Constants.ENTER_LINE, Constants.NEXT_LINE));
+
+                StringBuffer sTemp = new StringBuffer(); 
+                sTemp.append(sb.toString());
+
+
+                // 返回文字长度超出时需要截取文字(),截取文字后需要增加查看更多链接
+                if (sb.toString().getBytes("UTF-8").length > 2048) {
+                    sb = sb.delete(599, sb.length()).append("......");
+                }
+                resContent = sb.toString();
+            }
+
+            rsp.setContent(resContent);
+        }
+        catch (Exception e) {
+            log.error(e);
+            rsp.setContent(InfoMsg.ERROR_SYSTEM_ERROR.getMsg());//系统异常
+        }
+        return rsp;
+    }
+
+    
+    /**
+     * 通过用户发送的信息,取得FAQ的问题
+     * 
+     * @param userSentTextRequest 用户发送的信息
+     * @return
+     */
+    public List<TdtgFaqInfo> getAllInfoByKeyWord(UserSentTextRequest userSentTextRequest) throws Exception {
+	    //通过用户发送的信息,检索FAQ内容
+	    List<TdtgFaqInfo> faqInfoList = faqService.getAllInfoByKeyWord(userSentTextRequest.getContent());
+	    return faqInfoList;    
+    }
+
+    /**
+     * 获取图文消息
+     * @param faqListResponse
+     * @return
+     */
+    public NewsResponse getFAQNewsResponse(List<TdtgFaqInfo> faqListResponse) {
+        try {
+            NewsResponse newsResponse = new NewsResponse();
+
+            for (TdtgFaqInfo faqInfo : faqListResponse) {
+                if (newsResponse.getArticleCount() < 10) {
+                    if (faqInfo.getMsgType() == 1) {
+                        String sNewsUrl;
+                        if (StringsUtils.isEmpty(faqInfo.getNewsUrl())) {
+                            sNewsUrl = urlFaqContent + "?id=" + faqInfo.getFaqId().toString();
+                        } else {
+                            sNewsUrl = faqInfo.getNewsUrl();
+                        }
+                        newsResponse.appendArticle(faqInfo.getTitle(), faqInfo.getNewsDesc(),  commonHelper.getImgUrl(faqInfo.getNewsPicurl()), sNewsUrl);
+                    }
+                }
+            }
+            return newsResponse;
+        } catch (Exception e) {
+            log.error("message", e);
+            return new NewsResponse();
+        }
+    }
+}

+ 27 - 0
src/main/java/com/wechat/callback/processors/UnSubscribeProcessor.java

@@ -0,0 +1,27 @@
+//package com.wechat.callback.processors;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.wechat.callback.passiveresponses.TextResponse;
+//import com.wechat.callback.tencentrequests.events.TBaseEventRequest;
+//import com.wechat.common.Constants;
+//import com.wechat.model.dto.BaseUserInfoDto;
+//
+//@Component
+//public class UnSubscribeProcessor {
+//
+//    public TextResponse getResponse(TBaseEventRequest req) {
+//        //openId取得
+//        String openId = req.getFromUserName();
+//        BaseUserInfoDto baseUserInfoDto = baseInfoRedis.selectBaseUserInfo(openId);
+//        String resContent = Constants.EMPTY;
+//        if (baseUserInfoDto != null) {
+//            //取消成功
+//            //1.删除用户信息 及相关资讯设定
+//            accountInfoService.deleteAccountInfo(openId);
+//
+//        }
+//        return new TextResponse(resContent);
+//    }
+//}

+ 60 - 0
src/main/java/com/wechat/callback/tencentrequests/BaseRequest.java

@@ -0,0 +1,60 @@
+package com.wechat.callback.tencentrequests;
+
+import javax.xml.bind.annotation.*;
+
+@XmlTransient
+public abstract class BaseRequest {
+    @XmlType
+    @XmlEnum(String.class)
+    public static enum MsgTypeEnum {
+        @XmlEnumValue("text")TEXT,   //文本消息
+        @XmlEnumValue("event")EVENT, //事件消息
+        @XmlEnumValue("image")IMAGE, //图片消息
+        @XmlEnumValue("location")LOCATION, //地理位置消息
+        @XmlEnumValue("voice")VOICE, //语音消息
+        @XmlEnumValue("video")VIDEO, //视频消息
+        @XmlEnumValue("shortvideo")SHORTVIDEO, //小视屏消息
+        @XmlEnumValue("link")LINK, //链接消息
+    }
+
+    private String ToUserName;  //公众号
+    private String FromUserName;//用户OpenID
+    private String CreateTime;  //创建时间
+    private MsgTypeEnum MsgType;//消息类型
+
+    public String getToUserName() {
+        return ToUserName;
+    }
+
+    @XmlElement(name = "ToUserName")
+    public void setToUserName(String toUserName) {
+        ToUserName = toUserName;
+    }
+
+    public String getFromUserName() {
+        return FromUserName;
+    }
+
+    @XmlElement(name = "FromUserName")
+    public void setFromUserName(String fromUserName) {
+        FromUserName = fromUserName;
+    }
+
+    public String getCreateTime() {
+        return CreateTime;
+    }
+
+    @XmlElement(name = "CreateTime")
+    public void setCreateTime(String createTime) {
+        CreateTime = createTime;
+    }
+
+    public MsgTypeEnum getMsgType() {
+        return MsgType;
+    }
+
+    @XmlElement(name = "MsgType")
+    public void setMsgType(MsgTypeEnum msgType) {
+        MsgType = msgType;
+    }
+}

+ 52 - 0
src/main/java/com/wechat/callback/tencentrequests/RefundRequest.java

@@ -0,0 +1,52 @@
+package com.wechat.callback.tencentrequests;
+
+import java.math.BigDecimal;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "xml")
+public final class RefundRequest extends BaseRequest {
+
+	private String orderNo;// 订单号
+	private String groupId;// 团购Id
+	private String refundFlg;// 退款标志
+	private String amount;// 退款金额
+
+	public String getOrderNo() {
+		return orderNo;
+	}
+
+	@XmlElement(name = "OrderNo")
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+
+	public String getGroupId() {
+		return groupId;
+	}
+
+	@XmlElement(name = "GroupId")
+	public void setGroupId(String groupId) {
+		this.groupId = groupId;
+	}
+
+	public String getRefundFlg() {
+		return refundFlg;
+	}
+
+	@XmlElement(name = "RefundFlg")
+	public void setRefundFlg(String refundFlg) {
+		this.refundFlg = refundFlg;
+	}
+
+	public String getAmount() {
+		return amount;
+	}
+
+	@XmlElement(name = "Amount")
+	public void setAmount(String amount) {
+		this.amount = amount;
+	}
+
+}

+ 7 - 0
src/main/java/com/wechat/callback/tencentrequests/TBaseRequest.java

@@ -0,0 +1,7 @@
+package com.wechat.callback.tencentrequests;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "xml")
+public final class TBaseRequest extends BaseRequest {
+}

+ 58 - 0
src/main/java/com/wechat/callback/tencentrequests/UserSentLocationRequest.java

@@ -0,0 +1,58 @@
+package com.wechat.callback.tencentrequests;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "xml")
+public final class UserSentLocationRequest extends BaseRequest {
+    private Double longitude; //经度
+    private Double latitude;//纬度
+    private Double scale;//缩放大小
+    private String lable;//位置信息
+    private Long msgId;//消息ID
+
+    public Double getLongitude() {
+        return longitude;
+    }
+
+    @XmlElement(name = "Location_Y")
+    public void setLongitude(Double longitude) {
+        this.longitude = longitude;
+    }
+
+    public Double getLatitude() {
+        return latitude;
+    }
+
+    @XmlElement(name = "Location_X")
+    public void setLatitude(Double latitude) {
+        this.latitude = latitude;
+    }
+
+    public Double getScale() {
+        return scale;
+    }
+
+    @XmlElement(name = "Scale")
+    public void setScale(Double scale) {
+        this.scale = scale;
+    }
+
+    public String getLable() {
+        return lable;
+    }
+
+    @XmlElement(name = "Label")
+    public void setLable(String lable) {
+        this.lable = lable;
+    }
+
+    public Long getMsgId() {
+        return msgId;
+    }
+
+    @XmlElement(name = "MsgId")
+    public void setMsgId(Long msgId) {
+        this.msgId = msgId;
+    }
+}

+ 28 - 0
src/main/java/com/wechat/callback/tencentrequests/UserSentTextRequest.java

@@ -0,0 +1,28 @@
+package com.wechat.callback.tencentrequests;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "xml")
+public final class UserSentTextRequest extends BaseRequest {
+    private String content;//消息内容
+    private Long msgId;//消息id
+
+    public Long getMsgId() {
+        return msgId;
+    }
+
+    @XmlElement(name = "MsgId")
+    public void setMsgId(Long msgId) {
+        this.msgId = msgId;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    @XmlElement(name = "Content")
+    public void setContent(String content) throws Exception {
+        this.content = new String(content.getBytes("ISO-8859-1"),"UTF-8");
+    }
+}

+ 32 - 0
src/main/java/com/wechat/callback/tencentrequests/events/BaseEventRequest.java

@@ -0,0 +1,32 @@
+package com.wechat.callback.tencentrequests.events;
+
+import javax.xml.bind.annotation.*;
+
+import com.wechat.callback.tencentrequests.BaseRequest;
+
+@XmlTransient
+public abstract class BaseEventRequest extends BaseRequest {
+	@XmlType
+	@XmlEnum(String.class)
+	public static enum EventType {
+		@XmlEnumValue("subscribe") SUBSCRIBE, // 关注事件
+		@XmlEnumValue("unsubscribe") UNSUBSCRIBE, // 取消关注事件
+		@XmlEnumValue("SCAN") SCAN, // 扫描二维码事件
+		@XmlEnumValue("LOCATION") LOCATION, // 自动地理位置上报事件
+		@XmlEnumValue("CLICK") CLICK, // 菜单点击事件
+		@XmlEnumValue("MASSSENDJOBFINISH") MASSSENDJOBFINISH, // 群发消息完成事件
+		@XmlEnumValue("VIEW") VIEW, // 菜单点击跳转链接事件
+		@XmlEnumValue("TEMPLATESENDJOBFINISH") TEMPLATESENDJOBFINISH, // 单独OpenID发送完成事件
+	}
+
+	private EventType eventType;// 事件类型
+
+	public EventType getEventType() {
+		return eventType;
+	}
+
+	@XmlElement(name = "Event")
+	public void setEventType(EventType eventType) {
+		this.eventType = eventType;
+	}
+}

+ 27 - 0
src/main/java/com/wechat/callback/tencentrequests/events/ClickEventRequest.java

@@ -0,0 +1,27 @@
+package com.wechat.callback.tencentrequests.events;
+
+import javax.xml.bind.annotation.*;
+
+@XmlRootElement(name = "xml")
+public final class ClickEventRequest extends BaseEventRequest {
+    @XmlType
+    @XmlEnum(String.class)
+    public static enum EventKeyEnum {
+        @XmlEnumValue("CALL_MOBILE_HALL")CALL_MOBILE_HALL,   //掌厅
+        @XmlEnumValue("CALL_ACCOUNT_MANAGER")CALL_ACCOUNT_MANAGER,   //客户经理查询
+        @XmlEnumValue("CALL_ACCOUNT_INQUIRY")CALL_ACCOUNT_INQUIRY,    //账户查询
+        @XmlEnumValue("CALL_CUSTOMER_SERVICE")CALL_CUSTOMER_SERVICE    //客服
+    }
+
+    private EventKeyEnum eventKey;//按钮key
+
+    public EventKeyEnum getEventKey() {
+        return eventKey;
+    }
+
+    @XmlElement(name = "EventKey")
+    public void setEventKey(EventKeyEnum eventKey) {
+        this.eventKey = eventKey;
+    }
+
+}

+ 7 - 0
src/main/java/com/wechat/callback/tencentrequests/events/TBaseEventRequest.java

@@ -0,0 +1,7 @@
+package com.wechat.callback.tencentrequests.events;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "xml")
+public final class TBaseEventRequest extends BaseEventRequest {
+}

+ 37 - 0
src/main/java/com/wechat/callback/tencentrequests/events/TemplateSendFinishEventRequest.java

@@ -0,0 +1,37 @@
+package com.wechat.callback.tencentrequests.events;
+
+import javax.xml.bind.annotation.*;
+
+@XmlRootElement(name = "xml")
+public final class TemplateSendFinishEventRequest extends BaseEventRequest {
+    @XmlType
+    @XmlEnum(String.class)
+    public static enum StatusEnum {
+        @XmlEnumValue("success")SUCCESS,   //发送状态为成功
+        @XmlEnumValue("failed:user block")USER_BLOCK,   //发送状态为用户拒绝接收
+        @XmlEnumValue("failed:system failed")SYSTEM_FAILED    //发送状态为发送失败(非用户拒绝)
+    }
+
+    private StatusEnum status;//发送状态
+    
+    private String msgID;//消息id
+
+    public StatusEnum getStatus() {
+        return status;
+    }
+    
+    @XmlElement(name = "Status")
+    public void setStatus(StatusEnum status) {
+        this.status = status;
+    }
+
+    public String getMsgID() {
+        return msgID;
+    }
+
+    @XmlElement(name = "MsgID")
+    public void setMsgID(String msgID) {
+        this.msgID = msgID;
+    }
+
+}

+ 567 - 0
src/main/java/com/wechat/common/CommonEnum.java

@@ -0,0 +1,567 @@
+package com.wechat.common;
+
+import com.wechat.common.utils.StringsUtils;
+
+public final class CommonEnum {
+
+    /** 不提供构造函数 */
+    private CommonEnum()
+    {
+    }
+    
+    
+    /**
+     * 是否删除
+     */
+    public enum IS_DELETE implements IEnum {
+        /** 0: 未删除 */
+        NO("未删除", "0"),
+        /** 1: 删除 */
+        YES("删除", "1");
+      
+
+        /** 值 */
+        private String label;
+
+        /** 键 */
+        private String code;
+
+        /**
+         * 取得枚举区分
+         * 
+         * @return String
+         */
+        public String getEnumName() {
+            return "IS_DELETE";
+        }
+
+        /**
+         * 构造函数
+         * 
+         * @param label String
+         * @param code String
+         */
+        private IS_DELETE(String label, String code)
+        {
+            this.label = label;
+            this.code = code;
+        }
+
+        /**
+         * 根据键取得值
+         * 
+         * @param code String
+         * @return String
+         */
+        public static String getEnumLabel(String code) {
+            for (IS_DELETE c : IS_DELETE.values()) {
+                if (StringsUtils.isEqual(c.getCode(), code)) {
+                    return c.label;
+                }
+            }
+            return null;
+        }
+
+        /**
+         * 根据值取得第一个匹配的键
+         * 
+         * @param label String
+         * @return String
+         */
+        public static String getEnumCode(String label) {
+            for (IS_DELETE c : IS_DELETE.values()) {
+                if (StringsUtils.isEqual(c.getLabel(), label)) {
+                    return c.code;
+                }
+            }
+            return null;
+        }
+
+
+        /**
+         * get
+         * 
+         * @return String
+         */
+        public String getLabel() {
+            return label;
+        }
+
+        /**
+         * set
+         * 
+         * @return String
+         */
+        public String getCode() {
+            return code;
+        }
+
+        /**
+         * String转换,中间加横杠
+         * 
+         * @return String
+         */
+        @Override
+        public String toString() {
+            return this.label;
+        }
+
+        /**
+         * 转换成value
+         * 
+         * @return String
+         */
+        public String toValueString() {
+            return String.valueOf(this.code);
+        }
+
+        /**
+         * 转换成label
+         * 
+         * @return String
+         */
+        public String toLabelString() {
+            return String.valueOf(this.label);
+        }
+    }
+    
+    
+
+    /**
+     * 微信客服消息类别
+     */
+    public enum SERVICE_MSG_TYPE {
+        /** 文本 */
+        TXT("text"),
+        /** 图片 */
+        IMAGE("image"),
+        /** 语音 */
+        VOICE("voice"),
+        /** 视频 */
+        VIDEO("video"),
+        /** 音乐 */
+        MUSIC("music"),
+        /** 图文 */
+        NEWS("news");
+      
+
+        /** 值 */
+        private String label;
+        
+        /**
+         * 构造函数
+         * 
+         * @param label String
+         * @param code String
+         */
+        private SERVICE_MSG_TYPE(String label)
+        {
+            this.label = label;
+        }
+
+        public String getLabel() {
+            return label;
+        }
+    }
+
+    
+    
+    /**
+     * 子菜单类型及关键词对应关系
+     */
+    public enum SUB_BTN_TYPE implements IEnum {
+        /** click - key */
+    	CLICK("key", "click"),
+        /** view - url */
+        VIEW("url", "view");
+      
+
+        /** 值 */
+        private String label;
+
+        /** 键 */
+        private String code;
+
+
+        /**
+         * 构造函数
+         * 
+         * @param label String
+         * @param code String
+         */
+        private SUB_BTN_TYPE(String label, String code)
+        {
+            this.label = label;
+            this.code = code;
+        }
+
+        /**
+         * 根据键取得值
+         * 
+         * @param code String
+         * @return String
+         */
+        public static String getEnumLabel(String code) {
+            for (SUB_BTN_TYPE c : SUB_BTN_TYPE.values()) {
+                if (StringsUtils.isEqual(c.getCode(), code)) {
+                    return c.label;
+                }
+            }
+            return null;
+        }
+
+        /**
+         * 根据值取得第一个匹配的键
+         * 
+         * @param label String
+         * @return String
+         */
+        public static String getEnumCode(String label) {
+            for (SUB_BTN_TYPE c : SUB_BTN_TYPE.values()) {
+                if (StringsUtils.isEqual(c.getLabel(), label)) {
+                    return c.code;
+                }
+            }
+            return null;
+        }
+
+
+        /**
+         * get
+         * 
+         * @return String
+         */
+        public String getLabel() {
+            return label;
+        }
+
+        /**
+         * set
+         * 
+         * @return String
+         */
+        public String getCode() {
+            return code;
+        }
+
+    }
+    
+    
+    /**
+     * 退款原因
+     */
+    public enum REFOUND_REASON implements IEnum {
+        ZERO("团购失败", "0"),
+        ONE("随机优惠减免", "1"),
+        TWO("超出成团指定人数", "2"),
+        THREE("售后维权", "3"),
+        FOUR("您参与的抽奖活动未中奖", "4"),
+        NINE("淘豆商城", "9");
+
+        /** 值 */
+        private String label;
+
+        /** 键 */
+        private String code;
+
+        /**
+         * 取得枚举区分
+         * 
+         * @return String
+         */
+        public String getEnumName() {
+            return "REFOUND_REASON";
+        }
+
+        /**
+         * 构造函数
+         * 
+         * @param label String
+         * @param code String
+         */
+        private REFOUND_REASON(String label, String code)
+        {
+            this.label = label;
+            this.code = code;
+        }
+
+        /**
+         * 根据键取得值
+         * 
+         * @param code String
+         * @return String
+         */
+        public static String getEnumLabel(String code) {
+            for (REFOUND_REASON c : REFOUND_REASON.values()) {
+                if (StringsUtils.isEqual(c.getCode(), code)) {
+                    return c.label;
+                }
+            }
+            return null;
+        }
+
+        /**
+         * 根据值取得第一个匹配的键
+         * 
+         * @param label String
+         * @return String
+         */
+        public static String getEnumCode(String label) {
+            for (REFOUND_REASON c : REFOUND_REASON.values()) {
+                if (StringsUtils.isEqual(c.getLabel(), label)) {
+                    return c.code;
+                }
+            }
+            return null;
+        }
+
+
+        /**
+         * get
+         * 
+         * @return String
+         */
+        public String getLabel() {
+            return label;
+        }
+
+        /**
+         * set
+         * 
+         * @return String
+         */
+        public String getCode() {
+            return code;
+        }
+
+        /**
+         * String转换,中间加横杠
+         * 
+         * @return String
+         */
+        @Override
+        public String toString() {
+            return this.label;
+        }
+
+        /**
+         * 转换成value
+         * 
+         * @return String
+         */
+        public String toValueString() {
+            return String.valueOf(this.code);
+        }
+
+        /**
+         * 转换成label
+         * 
+         * @return String
+         */
+        public String toLabelString() {
+            return String.valueOf(this.label);
+        }
+    }
+    
+    /**
+     * 职位发布时间
+     */
+    public enum POSITION_PUB_TIME {
+        /** 1周内 */
+        WEEK("1"),
+        /** 1月内 */
+        MONTH("2"),
+        /** 3月内 */
+        MONTHS("3"),
+        /** 半年内 */
+        YEAR("4"),
+    	/** 没有的 */
+        NONE("9");
+
+        /** 值 */
+        private String value;
+        
+        /**
+         * 构造函数
+         * 
+         * @param label String
+         * @param code String
+         */
+        private POSITION_PUB_TIME(String value)
+        {
+            this.value = value;
+        }
+
+        public String getValue() {
+            return value;
+        }
+
+ 		// 根据value返回枚举类型,主要在switch中使用
+	     public static POSITION_PUB_TIME getByValue(String value) {
+	        for (POSITION_PUB_TIME tim : values()) {
+	             if (tim.getValue().equals(value)) {
+	                 return tim;
+	             }
+	        }
+	         return NONE;
+	     }
+    }
+
+    
+    /**
+     *酒店筹开类型
+     */
+    public enum PREPARE_FLAG {
+        /** 运营酒店 */
+        OPENING("0"),
+        /** 筹开酒店 */
+        OPERATING("1"),
+        /** 酒店集团 */
+        GROUP("9");
+
+        /** 值 */
+        private String value;
+        
+        /**
+         * 构造函数
+         * 
+         * @param label String
+         * @param code String
+         */
+        private PREPARE_FLAG(String value)
+        {
+            this.value = value;
+        }
+
+        public String getValue() {
+            return value;
+        }
+
+ 		// 根据value返回枚举类型,主要在switch中使用
+	     public static PREPARE_FLAG getByValue(String value) {
+	        for (PREPARE_FLAG tim : values()) {
+	             if (tim.getValue().equals(value)) {
+	                 return tim;
+	             }
+	        }
+	         return OPENING;
+	     }
+    }
+    
+    /**
+     *酒店筹开类型
+     */
+    public enum PICTURE_FILE_TYPE  implements IEnum{
+    	/**  JPEG (jpg) */
+        JPG("jpg", "ffd8ff"), 
+        /** JPEG (jpg) */
+		JPG2("jpg", "ffd8ffe000104a464946"),  
+		/** PNG (png) */
+        PNG("png", "89504e47"), 
+        /** PNG (png) */
+		PNG2("png", "89504e470d0a1a0a0000"), 
+		 /**  GIF (gif) */
+        GIF("gif", "47494638"),
+        /**  Windows Bitmap (bmp) */
+        BMP("bmp", "424d"), 
+        /**  16色位图(bmp) */
+        BMP2("bmp", "424d228c010000000000"), 
+        /**  24位位图(bmp) */
+        BMP3("bmp", "424d8240090000000000"), 
+        /**  256色位图(bmp) */
+        BMP4("bmp", "424d8e1b030000000000"); 
+    	
+    	 /** 值 */
+        private String label;
+
+        /** 键 */
+        private String code;
+
+        /**
+         * 取得枚举区分
+         * 
+         * @return String
+         */
+        public String getEnumName() {
+            return "PICTURE_FILE_TYPE";
+        }
+
+        /**
+         * 构造函数
+         * 
+         * @param label String
+         * @param code String
+         */
+        private PICTURE_FILE_TYPE(String label, String code)
+        {
+            this.label = label;
+            this.code = code;
+        }
+
+        /**
+         * 根据键取得值
+         * 
+         * @param code String
+         * @return String
+         */
+        public static String getEnumLabel(String code) {
+            for (PICTURE_FILE_TYPE c : PICTURE_FILE_TYPE.values()) {
+                if (StringsUtils.isEqual(c.getCode(), code)) {
+                    return c.label;
+                }
+            }
+            return null;
+        }
+
+        /**
+         * 根据值取得第一个匹配的键
+         * 
+         * @param label String
+         * @return String
+         */
+        public static String getEnumCode(String label) {
+            for (PICTURE_FILE_TYPE c : PICTURE_FILE_TYPE.values()) {
+                if (StringsUtils.isEqual(c.getLabel(), label)) {
+                    return c.code;
+                }
+            }
+            return null;
+        }
+
+
+        /**
+         * get
+         * 
+         * @return String
+         */
+        public String getLabel() {
+            return label;
+        }
+
+        /**
+         * set
+         * 
+         * @return String
+         */
+        public String getCode() {
+            return code;
+        }
+
+        /**
+         * String转换
+         * 
+         * @return String
+         */
+        @Override
+        public String toString() {
+            return this.label;
+        }
+
+		 
+    }
+    
+
+    
+
+}
+

+ 246 - 0
src/main/java/com/wechat/common/CommonHelper.java

@@ -0,0 +1,246 @@
+package com.wechat.common;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTCreationException;
+import com.wechat.activerequests.responses.MessageIdResponse;
+import com.wechat.common.utils.AESUtil;
+import com.wechat.common.utils.JacksonUtils;
+import com.wechat.common.utils.MessageUtils;
+import com.wechat.common.utils.NetworkUtils;
+import com.wechat.common.utils.NumberUtils;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.model.dbEntity.MdeLoginHis;
+import com.wechat.model.requestDto.TMsgSendBaseReq;
+import com.wechat.service.WeiXinService;
+
+import nl.basjes.parse.useragent.UserAgent;
+import nl.basjes.parse.useragent.UserAgentAnalyzer;
+
+
+/**
+ * The common method shared in all project
+ * 
+ * @author Administrator
+ */
+@Component
+public class CommonHelper {
+	// url根目录
+	@Value("#{configProperties['hostPort']}")
+	private String urlBase;
+
+	// 模板消息发送用url
+	@Value("#{configProperties['weixin.tmsg.send']}")
+	private String tmsgSendUrl;
+
+	// token过期时间
+	@Value("#{configProperties['token.expire.minute']}")
+	private String tokenExpireTime;
+
+	private static final Log log = LogFactory.getLog(CommonHelper.class);
+
+	public String getIRealIPAddr(HttpServletRequest request) {
+		String ip = request.getHeader("x-forwarded-for");
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip) || "null".equalsIgnoreCase(ip)) {
+			ip = request.getHeader("Proxy-Client-IP");
+		}
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip) || "null".equalsIgnoreCase(ip)) {
+			ip = request.getHeader("WL-Proxy-Client-IP");
+		}
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip) || "null".equalsIgnoreCase(ip)) {
+			ip = request.getRemoteAddr();
+		}
+
+		// 如果通过多级反向代理,X-Forwarded-For的值不止一个,而是一串用逗号分隔的IP值,此时取X-Forwarded-For中第一个非unknown的有效IP字符串
+		if ((ip.indexOf(",") > -1)) {
+			ip = ip.split(",")[0];
+		}
+		return ip;
+	}
+
+	/**
+	 * 验证是否是手机号码
+	 * 
+	 * @param mobile
+	 * @return
+	 */
+	public boolean isMobile(String mobile) {
+		Pattern p = null;
+		Matcher m = null;
+		p = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$"); // 验证手机号
+		m = p.matcher(mobile);
+		return m.matches();
+	}
+
+	/**
+	 * 取得完整的图片访问url
+	 * 
+	 * @param mobile
+	 * @return
+	 */
+	public String getImgUrl(String urlChild) {
+		return urlBase + urlChild;
+	}
+
+	/**
+	 * 模板消息推送
+	 * 
+	 * @param keyWord
+	 *            用户发送的信息
+	 * @return
+	 */
+	public String send(TMsgSendBaseReq req) {
+		String url = MessageUtils.getText(tmsgSendUrl, WeiXinService.getInstance().getAccessToken());
+		MessageIdResponse response = NetworkUtils.getRemoteResponseAsJson(url, req, MessageIdResponse.class);
+		log.debug("Responded: " + JacksonUtils.beautifulSerialize(response));
+
+		// 模板消息推送出错
+		if (!StringsUtils.isEqual(Constants.STR_OK, Long.toString(response.getErrorCode()))) {
+			log.error("模板消息推送异常:ErrorMsg=" + response.getErrorMsg() + "; ErrorCode=" + response.getErrorCode()
+					+ "; MessageId=" + response.getMessageId());
+			// 40001 的情况下强制重取token
+			if (StringsUtils.isEqual(Constants.STR_TOKEN_ERO, Long.toString(response.getErrorCode()))) {
+				WeiXinService.getInstance().updAccessTokenInfo();
+				url = MessageUtils.getText(tmsgSendUrl, WeiXinService.getInstance().getAccessToken());
+			}
+			// 重新发送
+			response = NetworkUtils.getRemoteResponseAsJson(url, req, MessageIdResponse.class);
+			log.error("模板消息重发:ErrorMsg=" + response.getErrorMsg() + "; ErrorCode=" + response.getErrorCode()
+					+ "; MessageId=" + response.getMessageId());
+		}
+
+		return response.getErrorCode().toString();
+	}
+
+	/**
+	 * token生成
+	 * 
+	 * @param userCode 用户code          
+	 * @param req
+	 * @param identityFlag 个人企业区分
+	 * @param creatDate    用户注册日期
+	 * @return
+	 * @throws IllegalArgumentException
+	 * @throws JWTCreationException
+	 * @throws UnsupportedEncodingException
+	 */
+	public String getToken(String userCode, String identityFlag, String creatDate)
+			throws IllegalArgumentException, JWTCreationException, UnsupportedEncodingException {
+		Calendar calendar = Calendar.getInstance();
+		calendar.add(Calendar.MINUTE, NumberUtils.stringToInt(tokenExpireTime, 120));
+		// 生成token 用户code拼上随机字符串进行md5加密
+		String token = JWT.create().withClaim(Constants.TOKEN_USER_ID, userCode).withClaim(Constants.TOKEN_IDENTITY_FLAG, identityFlag).withClaim(Constants.TOKEN_CREATDATE, creatDate).withExpiresAt(calendar.getTime())
+				.sign(Algorithm.HMAC512(Constants.TOKEN_KEY));
+		return token;
+	}
+
+	/**
+	 * ActivationToken生成 邮箱激活token
+	 * 
+	 * @param userCode
+	 *            用户code
+	 * @return token
+	 * @throws UnsupportedEncodingException
+	 * @throws JWTCreationException
+	 * @throws IllegalArgumentException
+	 */
+	public String getActivationToken(String userCode)
+			throws IllegalArgumentException, JWTCreationException, UnsupportedEncodingException {
+		Calendar calendar = Calendar.getInstance();
+		calendar.add(Calendar.DAY_OF_YEAR, 5);
+		// 生成token 用户code拼上随机字符串进行md5加密
+		String token = JWT.create().withClaim(Constants.ACTIVATION_TOKEN, userCode).withExpiresAt(calendar.getTime())
+				.sign(Algorithm.HMAC512(Constants.TOKEN_KEY));
+		return token;
+	}
+	
+	
+	/**
+	 * 获取客户端信息
+	 * @param request
+	 * @return
+	 */
+	public MdeLoginHis getDeviceType(HttpServletRequest request) {
+		MdeLoginHis his = new MdeLoginHis();
+        String agentString = request.getHeader("User-Agent");
+        
+        UserAgentAnalyzer a = UserAgentAnalyzer.newBuilder().hideMatcherLoadStats().delayInitialization().build();
+        UserAgent userAgent = a.parse(agentString);
+
+        // 浏览器信息
+        his.setBrowser(userAgent.getValue(UserAgent.AGENT_NAME));
+        his.setBrowserVersion(userAgent.getValue(UserAgent.AGENT_NAME_VERSION));
+        his.setIp(getIRealIPAddr(request));
+        // 设备信息
+        String deviceName = userAgent.getValue(UserAgent.DEVICE_NAME);
+
+    	String lower = agentString.toLowerCase();
+    	if(lower.contains("devtool") || lower.contains("postman") || lower.contains("request") || lower.contains("debug") || lower.contains("api")) {
+    		deviceName = "IT人员!";
+    	}
+        his.setOperating(deviceName);
+        
+        // 设备类型
+        his.setDeviceClass(userAgent.getValue(UserAgent.DEVICE_CLASS));
+    	
+    	// 操作系统信息
+        his.setSystem(userAgent.getValue(UserAgent.OPERATING_SYSTEM_NAME_VERSION));
+      
+        his.setRemarks(agentString);
+
+        return his;
+    }
+	
+	/**
+	 * 根据shareJob 获取jobid
+	 * @param request
+	 * @return
+	 */
+	public int getJobId(String shareJob) {
+		String jobId = shareJob.substring(10);
+        return NumberUtils.stringToInt(jobId, 0);
+    }
+	
+	
+	
+	/**
+	 * 获取分享用-用户code
+	 * Aes加密
+	 * @param request
+	 * @return
+	 */
+	public String getShareCodeAes(String userCode, Date creatTime) {
+		String shareCode = AESUtil.encrypt(userCode+Constants.UNDER_LINE+String.valueOf(creatTime.getTime()), Constants.AES_PASSWORD);
+        return shareCode;
+    }
+	
+	/**
+	 * 获取分享用-用户code
+	 * Aes解密
+	 * @param request
+	 * @return
+	 */
+	public String[] getUserCodeAes(String shareCode) {
+		/*
+		 * try { shareCode = URLDecoder.decode(shareCode,"utf-8"); } catch
+		 * (UnsupportedEncodingException e) { // TODO Auto-generated catch block
+		 * e.printStackTrace(); }
+		 */
+		String shareCodeStr = AESUtil.decryptStr(shareCode, Constants.AES_PASSWORD);
+        return shareCodeStr.split(Constants.UNDER_LINE);
+    }
+
+}

+ 167 - 0
src/main/java/com/wechat/common/Constants.java

@@ -0,0 +1,167 @@
+/**
+ * Title: Constants.java Package com.linggou.net.base All rights Reserved, Designed By soyo Copyright: Copyright(C) 2010-2015 Company: soyo SuZhou LTD. Create By shensuoyao Create
+ * Date 2014年8月14日 下午2:03:45 Version V1.0
+ */
+package com.wechat.common;
+
+/**
+ * @ClassName: Constants
+ * @Description: 公共常量
+ * @author shensuoyao
+ */
+public class Constants {
+
+	// ============ 自定义常量 =================
+	/** 验证失败 */
+	public static final int VALID_ERROR = 99;
+
+	/** 错误code 40001 */
+	public static final String STR_TOKEN_ERO = "40001";
+
+	/** 错误code 0 */
+	public static final String STR_OK = "0";
+	
+	/** 首推标识[1-推荐] */
+	public static final String RECOMMEND_YES = "1";
+
+	/** 首推标识[0-不推荐] */
+	public static final String RECOMMEND_NO = "0";
+	
+	
+	/** 订单类别[0会员套餐订单 1个人服务,2企业服务,3商品购买,4积分兑换] */
+	public static final String ORDER_TYPE_VIP = "0";
+	public static final String ORDER_TYPE_PERSONAL = "1";
+	public static final String ORDER_TYPE_ENTERPRISE = "2";
+	public static final String ORDER_TYPE_GOODS = "3";
+	public static final String ORDER_TYPE_INTEGRAL = "4";
+	
+
+	// ============== 固定文字 =================
+	/** 空文字 */
+	public static final String EMPTY = "";
+
+	/** 1 */
+	public static final String ONE = "1.";
+
+	/** 2 */
+	public static final String TWO = "2.";
+
+	/** 3 */
+	public static final String THREE = "3.";
+
+	/** 4 */
+	public static final String FOUR = "4.";
+
+	/** 5 */
+	public static final String FIVE = "5.";
+
+	/** base url */
+	public static final String URL_BEGIN = "\n<a href='";
+
+	public static final String URL_BEGIN_NOBR = "<a href='";
+
+	public static final String URL_MIDDLE = "'>";
+
+	public static final String URL_END = "</a>\n";
+
+	public static final String URL_END_NOBR = "</a>";
+
+	/** 换行符 */
+	public static final String NEXT_LINE = "\n";
+
+	/** 回车 换行 */
+	public static final String ENTER_LINE = "\r\n";
+
+	/** 下划线 */
+	public static final String UNDER_LINE = "_";
+	
+	/** token 用 */
+	public final static String TOKEN_KEY = "16e7749d-7372-4c3e-ab82-895627ec5e8f";
+	public final static String TOKEN_COOKIE_NAME = "token";
+	public final static String TOKEN_USER_ID = "userCode";
+	public final static String TOKEN_IDENTITY_FLAG = "identityFlag";
+	public final static String TOKEN_CREATDATE = "creatdate";
+	public final static String TOKEN_SHORT_INVITER = "shortInviter";
+	public final static String LANGUAGE = "lang";
+	public final static String UUID = "uuid";
+	
+	public final static String ACTIVATION_TOKEN="activationToken";
+	
+	public final static String MD5_PASSWORD="dp&V9W^1Bd"; // 密码加密拼上固定字符串
+	
+	/** 加密使用 */
+	public final static String AES_PASSWORD="wQ&M2W}74Tg#s$"; // AES加密Key
+	
+	/** 中英文 */
+	public static final String LANG_CN="zh";
+	public static final String LANG_EN="en";
+	
+	/** 用户的身份标识[0-个人;1-企业] */
+	public static final String IDENTITY_P="0";
+	public static final String IDENTITY_C="1";
+	
+	/** 订阅标识[0-未订阅;1-订阅] */
+	public static final String SUBSCRIBED_NO="0";
+	public static final String SUBSCRIBED_YES="1";
+	
+	//--------redis 用 key-----------------
+	/** 商品的销售额 */
+	public static final String REDIS_GOODS_SALE="goodsSale_";
+	/** 职位PV UV信息统计 */
+	public static final String REDIS_JOB_PV="jobPv_";
+	public static final String REDIS_JOB_UV="jobUv_";
+	
+	/** 广告点击率 信息统计 */
+	public static final String REDIS_AD_SHOW="adShow_";
+	public static final String REDIS_AD_CLICK="adClick_";
+	
+	/** api访问限制 */
+	public static final String REDIS_LIMIT_AD_CTR="apiLimit__adCtr_";
+
+
+	/** 广告位id(字典表维护)[1-PC登录页(背景);2-PC登录页(轮播);3-PC主页(顶部);4-PC主页(右侧1);5-PC主页(右侧2);6-PC职位页(顶部);
+	 * 7-PC人才页(顶部);8-PC职位详情页(底部);9-PC个人中心页(顶部);10-PC套餐页(顶部);11-PC人脉页(左侧);12-PC用户信息(顶部);13-PC个人资料(底部);
+	 * 21-手机登录页(背景);22-动态页(头部轮播));23-职位页(头部轮播);24-人才页(头部轮播)];25-手机个人中心(中部);
+	 *  */
+	public static final String PC_LOGIN_BG="1";//1-PC登录页(背景)
+	public static final String PC_LOGIN_BROADCAST="2";//2-PC登录页(轮播)
+	public static final String PC_MAINPAGE_TOP_AD="3";//3-PC主页(顶部)
+	public static final String PC_MAINPAGE_RIGHT_AD1="4";//4-PC主页(右侧1)
+	public static final String PC_MAINPAGE_RIGHT_AD2="5";//5-PC主页(右侧2)
+	public static final String PC_POSITION_TOP_AD="6";//6-PC职位页(顶部)
+	public static final String PC_RENCAI_TOP_AD="7";//7-PC人才页(顶部)
+	public static final String PC_POSITION_DETAIL_BOTTOM_AD="8";//8-PC职位详情页(底部)
+	public static final String PC_PERSONCENTER_TOP_AD="9";//9-PC个人中心页(顶部)
+	public static final String PC_TAOCAN_TOP_AD="10";//10-PC套餐页(顶部)
+	public static final String PC_HUMAN_VEIN_LEFT_AD="11";//11-PC人脉页(左侧)
+	public static final String PC_USER_DETAIL_TOP_AD="12";//12-PC用户信息(顶部)
+	public static final String PC_PERSON_DETAIL_BOTTOM="13";//13-PC个人资料(底部)
+	public static final String PC_OPEN_CN="14";//14-首开广告(中文)
+	public static final String PC_OPEN_EN="15";//15-首开广告(英文)
+	
+	public static final String SJ_LOGIN_BG="21";//21-手机登录页(背景)
+	public static final String SJ_TRENDS_TOP="22";//22-动态页(头部轮播)
+	public static final String SJ_POSITION_TOP="23";//23-职位页(头部轮播)
+	public static final String SJ_TALENT_TOP="24";//24-人才页(头部轮播)
+	public static final String SJ_PERSONCENTER_MIDDLE="25";//25-手机个人中心(中部)
+	public static final String SJ_OPEN_CN="26";//26-首开广告(中文)
+	public static final String SJ_OPEN_EN="27";//27-首开广告(英文)
+	public static final String SJ_POSITION_DTL="28";//28-职位详情(底部)
+	
+	
+	public static final String INFORMATION_ZIXUN="1";
+	public static final String INFORMATION_GUANGGAO="2";
+	public static final String INFORMATION_FABUHUI="3";
+	
+	//邮件发送昵称
+	public static final String EMAIL_NICK="门墩儿";
+	
+	/** 职位检索排序 */
+	/** 发布时间 */
+	public static final String SORT_TIME="time";
+	/** 职位等级 顺序 */
+	public static final String SORT_GRADE_ASC="down";
+	/** 职位等级 降序 */
+	public static final String SORT_GRADE_DESC="up";
+
+}

+ 20 - 0
src/main/java/com/wechat/common/IEnum.java

@@ -0,0 +1,20 @@
+package com.wechat.common;
+/**
+ * @author ma.jinchang
+ */
+public interface IEnum {
+
+    /**
+     * 取得编号
+     * 
+     * @return 枚举code
+     */
+    public String getCode();
+
+    /**
+     * 取得label
+     * 
+     * @return 枚举名
+     */
+    public String getLabel();
+}

+ 111 - 0
src/main/java/com/wechat/common/IdGenarator.java

@@ -0,0 +1,111 @@
+package com.wechat.common;
+/**
+ * twitter的snowflake算法 -- java实现
+ * 
+ * @author tangwc
+ * @date 2018/8/24
+ */
+public class IdGenarator {
+
+    /**
+     * 起始的时间戳
+     */
+    private final static long START_STMP = 1535105445000L;
+
+    /**
+     * 每一部分占用的位数
+     */
+    private final static long SEQUENCE_BIT = 12; //序列号占用的位数
+    private final static long MACHINE_BIT = 5;   //机器标识占用的位数
+    private final static long DATACENTER_BIT = 5;//数据中心占用的位数
+
+    /**
+     * 每一部分的最大值
+     */
+//    private final static long MAX_DATACENTER_NUM = -1L ^ (-1L << DATACENTER_BIT);
+//    private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT);
+    private final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT);
+
+    /**
+     * 每一部分向左的位移
+     */
+    private final static long MACHINE_LEFT = SEQUENCE_BIT;
+    private final static long DATACENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT;
+    private final static long TIMESTMP_LEFT = DATACENTER_LEFT + DATACENTER_BIT;
+
+    private static long datacenterId = 1L;  //数据中心
+    private static long machineId = 1L;     //机器标识
+    private static long sequence = 0L; //序列号
+    private static long lastStmp = -1L;//上一次时间戳
+
+    /*public SnowFlake(long datacenterId, long machineId) {
+        if (datacenterId > MAX_DATACENTER_NUM || datacenterId < 0) {
+            throw new IllegalArgumentException("datacenterId can't be greater than MAX_DATACENTER_NUM or less than 0");
+        }
+        if (machineId > MAX_MACHINE_NUM || machineId < 0) {
+            throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0");
+        }
+        this.datacenterId = datacenterId;
+        this.machineId = machineId;
+    }*/
+
+    /**
+     * 产生下一个ID
+     *
+     * @return
+     */
+    public synchronized static long nextId() {
+        long currStmp = getNewstmp();
+        if (currStmp < lastStmp) {
+            throw new RuntimeException("Clock moved backwards.  Refusing to generate id");
+        }
+
+        if (currStmp == lastStmp) {
+            //相同毫秒内,序列号自增
+            sequence = (sequence + 1) & MAX_SEQUENCE;
+            //同一毫秒的序列数已经达到最大
+            if (sequence == 0L) {
+                currStmp = getNextMill();
+            }
+        } else {
+            //不同毫秒内,序列号置为0
+            sequence = 0L;
+        }
+
+        lastStmp = currStmp;
+
+        long longId = (currStmp - START_STMP) << TIMESTMP_LEFT //时间戳部分
+                | datacenterId << DATACENTER_LEFT       //数据中心部分
+                | machineId << MACHINE_LEFT             //机器标识部分
+                | sequence;                             //序列号部分
+        
+        return longId;
+    }
+
+    private static long getNextMill() {
+        long mill = getNewstmp();
+        while (mill <= lastStmp) {
+            mill = getNewstmp();
+        }
+        return mill;
+    }
+
+    private static long getNewstmp() {
+        return System.currentTimeMillis();
+    }
+// IdGenarator.nextId()
+    public static void main(String[] args) {
+////        SnowFlake snowFlake = new SnowFlake(2, 3);
+      
+        for (int i = 0; i < 50; i++) {
+        	try {
+				Thread.sleep(1);
+				 System.out.println(IdGenarator.nextId());
+			} catch (InterruptedException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+        }
+
+    }
+}

+ 53 - 0
src/main/java/com/wechat/common/TengXunYunBase64URL.java

@@ -0,0 +1,53 @@
+package com.wechat.common;
+/**
+* @author jadyn
+* @version 创建时间:Sep 1, 2020 5:14:07 PM
+*  类说明
+*/
+
+//使用旧版本 base64 编解码实现增强兼容性
+
+import sun.misc.BASE64Encoder;
+import sun.misc.BASE64Decoder;
+
+import java.io.IOException;
+
+public class TengXunYunBase64URL {
+ public static byte[] base64EncodeUrl(byte[] input) {
+     byte[] base64 = new BASE64Encoder().encode(input).getBytes();
+     for (int i = 0; i < base64.length; ++i)
+         switch (base64[i]) {
+             case '+':
+                 base64[i] = '*';
+                 break;
+             case '/':
+                 base64[i] = '-';
+                 break;
+             case '=':
+                 base64[i] = '_';
+                 break;
+             default:
+                 break;
+         }
+     return base64;
+ }
+
+ public static byte[] base64DecodeUrl(byte[] input) throws IOException {
+     byte[] base64 = input.clone();
+     for (int i = 0; i < base64.length; ++i)
+         switch (base64[i]) {
+             case '*':
+                 base64[i] = '+';
+                 break;
+             case '-':
+                 base64[i] = '/';
+                 break;
+             case '_':
+                 base64[i] = '=';
+                 break;
+             default:
+                 break;
+         }
+     return new BASE64Decoder().decodeBuffer(base64.toString());
+ }
+}

+ 195 - 0
src/main/java/com/wechat/common/TwoDimensionCode.java

@@ -0,0 +1,195 @@
+package com.wechat.common;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import jp.sourceforge.qrcode.QRCodeDecoder;
+import jp.sourceforge.qrcode.exception.DecodingFailedException;
+
+import com.swetake.util.Qrcode;
+
+public class TwoDimensionCode{
+
+    public TwoDimensionCode(){
+        System.out.println(1);
+    }
+
+    /** 
+     * 生成二维码(QRCode)图片 
+     * @param content 存储内容 
+     * @param imgPath 图片路径 
+     */  
+    public static void encoderQRCode(String content, String imgPath) {  
+        encoderQRCode(content, imgPath, "png", 7);  
+    }
+
+    /** 
+     * 生成二维码(QRCode)图片 
+     * @param content 存储内容 
+     * @param output 输出流 
+     */  
+    public static void encoderQRCode(String content, OutputStream output) {  
+        encoderQRCode(content, output, "png", 7);  
+    }  
+      
+    /** 
+     * 生成二维码(QRCode)图片 
+     * @param content 存储内容 
+     * @param imgPath 图片路径 
+     * @param imgType 图片类型 
+     */  
+    public static void encoderQRCode(String content, String imgPath, String imgType) {  
+        encoderQRCode(content, imgPath, imgType, 7);  
+    }  
+      
+    /** 
+     * 生成二维码(QRCode)图片 
+     * @param content 存储内容 
+     * @param output 输出流 
+     * @param imgType 图片类型 
+     */  
+    public static void encoderQRCode(String content, OutputStream output, String imgType) {  
+        encoderQRCode(content, output, imgType, 7);  
+    }  
+  
+    /** 
+     * 生成二维码(QRCode)图片 
+     * @param content 存储内容 
+     * @param imgPath 图片路径 
+     * @param imgType 图片类型 
+     * @param size 二维码尺寸 
+     */  
+    public static void encoderQRCode(String content, String imgPath, String imgType, int size) {  
+        try {  
+            BufferedImage bufImg = qRCodeCommon(content, imgType, size);  
+              
+            File imgFile = new File(imgPath);  
+            // 生成二维码QRCode图片  
+            ImageIO.write(bufImg, imgType, imgFile);  
+        } catch (Exception e) {  
+            e.printStackTrace();  
+        }  
+    }  
+  
+    /** 
+     * 生成二维码(QRCode)图片 
+     * @param content 存储内容 
+     * @param output 输出流 
+     * @param imgType 图片类型 
+     * @param size 二维码尺寸 
+     */  
+    public static void encoderQRCode(String content, OutputStream output, String imgType, int size) {  
+        try {  
+            BufferedImage bufImg = qRCodeCommon(content, imgType, size);  
+            // 生成二维码QRCode图片  
+            ImageIO.write(bufImg, imgType, output);  
+        } catch (Exception e) {  
+            e.printStackTrace();  
+        }  
+    }  
+      
+    /** 
+     * 生成二维码(QRCode)图片的公共方法 
+     * @param content 存储内容 
+     * @param imgType 图片类型 
+     * @param size 二维码尺寸 
+     * @return 
+     */  
+    private static BufferedImage qRCodeCommon(String content, String imgType, int size) {  
+        BufferedImage bufImg = null;  
+        try {  
+            Qrcode qrcodeHandler = new Qrcode();  
+            // 设置二维码排错率,可选L(7%)、M(15%)、Q(25%)、H(30%),排错率越高可存储的信息越少,但对二维码清晰度的要求越小  
+            qrcodeHandler.setQrcodeErrorCorrect('H');  
+            qrcodeHandler.setQrcodeEncodeMode('B');  
+            // 设置设置二维码尺寸,取值范围1-40,值越大尺寸越大,可存储的信息越大  
+            qrcodeHandler.setQrcodeVersion(size);  
+            // 获得内容的字节数组,设置编码格式  
+            byte[] contentBytes = content.getBytes("utf-8");  
+            // 图片尺寸  
+//            int imgSize = 4+results *3;
+            int imgSize = 67 + 12 * (size - 1);  
+            bufImg = new BufferedImage(imgSize, imgSize, BufferedImage.TYPE_INT_RGB);  
+            Graphics2D gs = bufImg.createGraphics();  
+            // 设置背景颜色  
+            gs.setBackground(Color.WHITE);  
+            gs.clearRect(0, 0, imgSize, imgSize);  
+  
+            // 设定图像颜色> BLACK  
+            gs.setColor(Color.BLACK);  
+            // 设置偏移量,不设置可能导致解析出错  
+            int pixoff = 2;  
+            // 输出内容> 二维码  
+            if (contentBytes.length > 0 && contentBytes.length < 800) {  
+                boolean[][] codeOut = qrcodeHandler.calQrcode(contentBytes);  
+                for (int i = 0; i < codeOut.length; i++) {  
+                    for (int j = 0; j < codeOut.length; j++) {  
+                        if (codeOut[j][i]) {  
+                            gs.fillRect(j * 3 + pixoff, i * 3 + pixoff, 3, 3);  
+                        }  
+                    }  
+                }  
+            } else {  
+                throw new Exception("QRCode content bytes length = " + contentBytes.length + " not in [0, 800].");  
+            }  
+            gs.dispose();  
+            bufImg.flush();  
+        } catch (Exception e) {  
+            e.printStackTrace();  
+        }  
+        return bufImg;  
+    }  
+      
+    /** 
+     * 解析二维码(QRCode) 
+     * @param imgPath 图片路径 
+     * @return 
+     */  
+    public static String decoderQRCode(String imgPath) {  
+        // QRCode 二维码图片的文件  
+        File imageFile = new File(imgPath);  
+        BufferedImage bufImg = null;  
+        String content = null;  
+        try {  
+            bufImg = ImageIO.read(imageFile);  
+            QRCodeDecoder decoder = new QRCodeDecoder();  
+            content = new String(decoder.decode(new TwoDimensionCodeImage(bufImg)), "utf-8");   
+        } catch (IOException e) {  
+            System.out.println("Error: " + e.getMessage());  
+            e.printStackTrace();  
+        } catch (DecodingFailedException dfe) {  
+            System.out.println("Error: " + dfe.getMessage());  
+            dfe.printStackTrace();  
+        }  
+        return content;  
+    }  
+      
+    /** 
+     * 解析二维码(QRCode) 
+     * @param input 输入流 
+     * @return 
+     */  
+    public static String decoderQRCode(InputStream input) {  
+        BufferedImage bufImg = null;  
+        String content = null;  
+        try {  
+            bufImg = ImageIO.read(input);  
+            QRCodeDecoder decoder = new QRCodeDecoder();  
+            content = new String(decoder.decode(new TwoDimensionCodeImage(bufImg)), "utf-8");   
+        } catch (IOException e) {  
+            System.out.println("Error: " + e.getMessage());  
+            e.printStackTrace();  
+        } catch (DecodingFailedException dfe) {  
+            System.out.println("Error: " + dfe.getMessage());  
+            dfe.printStackTrace();  
+        }  
+        return content;  
+    }
+}

+ 29 - 0
src/main/java/com/wechat/common/TwoDimensionCodeImage.java

@@ -0,0 +1,29 @@
+package com.wechat.common;
+
+import java.awt.image.BufferedImage;
+
+import jp.sourceforge.qrcode.data.QRCodeImage;
+
+public class TwoDimensionCodeImage implements QRCodeImage {
+
+    BufferedImage bufImg;  
+    
+    public TwoDimensionCodeImage(BufferedImage bufImg) {  
+        this.bufImg = bufImg;  
+    }  
+      
+    @Override  
+    public int getHeight() {  
+        return bufImg.getHeight();  
+    }  
+  
+    @Override  
+    public int getPixel(int x, int y) {  
+        return bufImg.getRGB(x, y);  
+    }  
+  
+    @Override  
+    public int getWidth() {  
+        return bufImg.getWidth();  
+    }  
+}

+ 159 - 0
src/main/java/com/wechat/common/utils/AESUtil.java

@@ -0,0 +1,159 @@
+package com.wechat.common.utils;
+
+import java.io.UnsupportedEncodingException;
+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.SecretKeySpec;
+
+import org.apache.commons.codec.binary.Base64;
+
+
+public final class AESUtil extends BaseUtils{
+    // 定义加密算法
+    private static final String ALGORITHM = "AES";
+
+    private AESUtil() {
+    }
+
+    /**
+     * @param strCustomKey 自定义密钥,对于AES算法,请输入16||24||32个ASCII字符
+     * @return 密钥对象
+     * @throws UnsupportedEncodingException
+     */
+    public static SecretKey createKey(String strCustomKey) throws UnsupportedEncodingException {
+        SecretKey desKey = null;
+
+        desKey = new SecretKeySpec(strCustomKey.getBytes("UTF-8"), ALGORITHM);
+
+        return desKey;
+    }
+
+    /**
+     * 加密数据
+     * 
+     * @param para 要加密的数据
+     * @param deskey 密钥
+     * @return 加密后的密文
+     * @throws UnsupportedEncodingException
+     */
+    public static String encrypt(String content, String password) {
+        try {
+            KeyGenerator kgen = KeyGenerator.getInstance("AES");
+            SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
+            secureRandom.setSeed(password.getBytes());
+            kgen.init(128, secureRandom);
+            SecretKey secretKey = kgen.generateKey();
+            byte[] enCodeFormat = secretKey.getEncoded();
+            SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");
+            Cipher cipher = Cipher.getInstance("AES");// 创建密码器   
+            byte[] byteContent = content.getBytes("utf-8");
+            cipher.init(Cipher.ENCRYPT_MODE, key);// 初始化   
+            byte[] result = cipher.doFinal(byteContent); 
+            return new String(new Base64().encodeToString(result)); // 加密   
+        } catch (NoSuchAlgorithmException e) {
+            log.error(e);
+        } catch (NoSuchPaddingException e) {
+            log.error(e);
+        } catch (InvalidKeyException e) {
+            log.error(e);
+        } catch (UnsupportedEncodingException e) {
+            log.error(e);
+        } catch (IllegalBlockSizeException e) {
+            log.error(e);
+        } catch (BadPaddingException e) {
+            log.error(e);
+        }
+        return null;
+    }
+
+    /**
+     * 解密
+     * 
+     * @param content 密文
+     * @param password 密钥
+     * @return 解密后的内容
+     */
+    public static String decryptStr(String content, String password){
+    	byte[] byteContent = Base64.decodeBase64(content);
+		byte[] result = decrypt(byteContent,password);
+		return new String(result);
+    }
+    
+    /**
+     * 解密
+     * 
+     * @param content 密文
+     * @param password 密钥
+     * @return 解密后的内容
+     */
+    public static byte[] decrypt(byte[] content, String password) {
+        try {
+            KeyGenerator kgen = KeyGenerator.getInstance("AES");
+            SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
+            secureRandom.setSeed(password.getBytes());
+            kgen.init(128, secureRandom);
+            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(content);
+            return result; // 加密   
+        } catch (NoSuchAlgorithmException e) {
+            log.error("AES解密错误",e);
+        } catch (NoSuchPaddingException e) {
+            log.error("AES解密错误",e);
+        } catch (InvalidKeyException e) {
+            log.error("AES解密错误",e);
+        } catch (IllegalBlockSizeException e) {
+            log.error("AES解密错误",e);
+        } catch (BadPaddingException e) {
+            log.error("AES解密错误",e);
+        }
+        return null;
+    }
+
+    /**
+     * 将二进制转换成16进制
+     * 
+     * @param buf
+     * @return
+     */
+    public static String parseByte2HexStr(byte buf[]) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < buf.length; i++) {
+            String hex = Integer.toHexString(buf[i] & 0xFF);
+            if (hex.length() == 1) {
+                hex = '0' + hex;
+            }
+            sb.append(hex.toUpperCase());
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 将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;
+    }
+}

+ 107 - 0
src/main/java/com/wechat/common/utils/BaiDuKeyWordFilerUtils.java

@@ -0,0 +1,107 @@
+package com.wechat.common.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.wechat.model.dto.BaiDuFilterDto;
+import com.wechat.model.dto.BaiDuTokenDto;
+import com.wechat.service.AuthorizedService;
+import com.wechat.service.BaiDuTokenService;
+
+@Component
+public class BaiDuKeyWordFilerUtils {
+
+	@Value("#{configProperties['baidu.keyWord.filer.url']}")
+	private String filerUrl;
+
+	@Autowired
+	private BaiDuTokenService baiDuTokenService;
+
+	private StringBuilder replaceAll;// 初始化
+	private String replceStr = "*";
+	private int replceSize = 20000;
+	private List<String> arrayList = Lists.newArrayList();
+	private Set<String> sensitiveWordSet;// 包含的敏感词列表,过滤掉重复项
+	private List<String> sensitiveWordList;// 包含的敏感词列表,包括重复项,统计次数
+
+	public String filterKeWord(String context) {
+		if (StringsUtils.isEmpty(context)) {
+			return context;
+		}
+		String filterContext = context;
+		BaiDuTokenDto tokenDto = baiDuTokenService.getBaiDuAccessToken();
+		String url = filerUrl + "access_token=" + tokenDto.getAccess_token();
+		Map<String, String> req = Maps.newHashMap();
+		req.put("content", context);
+		HttpClientUtils httpClientUtils = new HttpClientUtils();
+		String json = httpClientUtils.doPost(url, req, "UTF-8");
+		JSONObject parseObject = JSONObject.parseObject(json);
+		String result = parseObject.getString("result");
+		JSONObject parseObject1 = JSONObject.parseObject(result);
+		String reject = parseObject1.getString("reject");
+		List<BaiDuFilterDto> list = JSONObject.parseArray(reject, BaiDuFilterDto.class);
+		for (BaiDuFilterDto baiDuFilterDto : list) {
+			arrayList.addAll(baiDuFilterDto.getHit());
+		}
+		replaceAll = new StringBuilder(replceSize);
+		for (int x = 0; x < replceSize; x++) {
+			replaceAll.append(replceStr);
+		}
+		filterContext = filterInfo(context);
+		return filterContext;
+	}
+
+	/**
+	 * @param str
+	 *            将要被过滤信息
+	 * @return 过滤后的信息
+	 */
+	private String filterInfo(String str) {
+		sensitiveWordSet = new HashSet<String>();
+		sensitiveWordList = new ArrayList<>();
+		StringBuilder buffer = new StringBuilder(str);
+		HashMap<Integer, Integer> hash = new HashMap<Integer, Integer>(arrayList.size());
+		String temp;
+		for (int x = 0; x < arrayList.size(); x++) {
+			temp = arrayList.get(x);
+			int findIndexSize = 0;
+			for (int start = -1; (start = buffer.indexOf(temp, findIndexSize)) > -1;) {
+				// System.out.println("###replace="+temp);
+				findIndexSize = start + temp.length();// 从已找到的后面开始找
+				Integer mapStart = hash.get(start);// 起始位置
+				if (mapStart == null || (mapStart != null && findIndexSize > mapStart))// 满足1个,即可更新map
+				{
+					hash.put(start, findIndexSize);
+					// System.out.println("###敏感词:"+buffer.substring(start, findIndexSize));
+				}
+			}
+		}
+		Collection<Integer> values = hash.keySet();
+		for (Integer startIndex : values) {
+			Integer endIndex = hash.get(startIndex);
+			// 获取敏感词,并加入列表,用来统计数量
+			String sensitive = buffer.substring(startIndex, endIndex);
+			// System.out.println("###敏感词:"+sensitive);
+			if (!sensitive.contains("*")) {// 添加敏感词到集合
+				sensitiveWordSet.add(sensitive);
+				sensitiveWordList.add(sensitive);
+			}
+			buffer.replace(startIndex, endIndex, replaceAll.substring(0, endIndex - startIndex));
+		}
+		hash.clear();
+		return buffer.toString();
+	}
+
+}

+ 56 - 0
src/main/java/com/wechat/common/utils/BaseUtils.java

@@ -0,0 +1,56 @@
+
+package com.wechat.common.utils;
+
+import java.util.Date;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.wechat.common.Constants;
+
+/**
+ * @version 1.0
+ * @author ma.jinchang
+ * @createDate 2012-9-7
+ * @modifyBy ma.jinchang
+ * @modifyDate 2012-9-7
+ */
+public class BaseUtils {
+    /**
+     * 日志工具
+     */
+    protected static final Log log = LogFactory.getLog(BaseUtils.class);
+    
+	/**
+	 * 生成分享用的职位id
+	 * @param createDate
+	 * @param jobId
+	 * @return
+	 */
+	public static String getShareJob(Date createDate,int jobId) {
+		return String.valueOf((createDate.getTime())/1000)+String.valueOf(jobId);
+	}
+	
+	
+	/**
+	 * 获取分享用-用户code
+	 * Aes加密
+	 * @param request
+	 * @return
+	 */
+	public static String getShareCodeAes(String userCode, Date creatTime) {
+		String shareCode = AESUtil.encrypt(userCode+Constants.UNDER_LINE+String.valueOf(creatTime.getTime()), Constants.AES_PASSWORD);
+        return shareCode;
+    }
+	
+	/**
+	 * 获取分享用-用户code
+	 * Aes解密
+	 * @param request
+	 * @return
+	 */
+	public static String[] getUserCodeAes(String shareCode) {
+		String shareCodeStr = AESUtil.decryptStr(shareCode, Constants.AES_PASSWORD);
+        return shareCodeStr.split(Constants.UNDER_LINE);
+    }
+}

+ 878 - 0
src/main/java/com/wechat/common/utils/DateUtils.java

@@ -0,0 +1,878 @@
+package com.wechat.common.utils;
+
+import java.math.BigDecimal;
+import java.text.Format;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Calendar;
+import java.util.Date;
+
+
+public class DateUtils extends BaseUtils {
+
+    /**
+     * 日期格式
+     */
+    public static String PATTEN_YMD = "yyyy-MM-dd";
+    
+    /**
+     * 日期格式2yyyy/MM/dd
+     */
+    public static String PATTEN_YMD2 = "yyyy/MM/dd";
+    
+    /**
+     * 日期格式
+     */
+    public static String PATTEN_YMTOW = "yyyy-MM";
+
+    /**
+     * 日期时间 格式
+     */
+    public static String PATTEN_HMS = "yyyy-MM-dd HH:mm:ss";
+    
+    /**
+     * 日期格式,不带分隔符 yyyyMMddHHmmss
+     */
+    public static String PATTEN_YMD_HH_MM_SS_SEPRATE = "yyyyMMddHHmmss";
+
+    /**
+     * 日期时间 格式
+     */
+    public static String PATTEN_HM = "yyyy-MM-dd HH:mm";
+
+    /**
+     * 带毫秒日期格式
+     */
+    public static String PATTEN_SSS = "yyyy-MM-dd HH:mm:ss.SSS";
+
+    /**
+     * 日期格式,不带分隔符
+     */
+    public static String PATTEN_YMD_NO_SEPRATE = "yyyyMM";
+
+    /**
+     * 文件重命名专用日期格式
+     */
+    public static String PATTEN_FILE_RENAME = "yyyyMMddHHmmssSSS";
+    
+    /**
+     * HH:mm:ss
+     */
+    public static String PATTEN_ONLYHMS = "HH:mm:ss";
+    
+    /**
+     * 日期格式
+     */
+    public static String PATTEN_YMDH = "yyyy-MM-dd HH";
+
+    public static String PATTEN_YM = "yyyyMM";
+    public static String PATTEN_Y = "yyyy";
+    
+    public static String PATTEN_MD = "MM/dd";
+
+    /**
+     * 大于
+     */
+    public static final String COMPARE_TYPE_GT = "GT";
+
+    /**
+     * 大于等于
+     */
+    public static final String COMPARE_TYPE_GTE = "GTE";
+
+    /**
+     * 不等于
+     */
+    public static final String COMPARE_TYPE_NE = "NE";
+
+    /**
+     * 日期验证复杂正则
+     */
+    public static String DATE_REG = "([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-9])))";
+
+    /**
+     * 日期验证简单正则
+     */
+    private static String DATE_REG_SIMPLE = "^\\d{4}-\\d{2}-\\d{2}$";
+
+    /**
+     * 默认的日期间隔符
+     */
+    public static String DEFAULT_SEPERATOR = "-";
+    
+    /**
+     * 股票市场开始时的点
+     */
+    public static int MARKET_START_POINT = 570;
+
+    /**
+     * 提供日期格式化工具
+     * 
+     * @param pattern 日期格式
+     * @return 格式化工具类
+     */
+    private static SimpleDateFormat getDateParser(String pattern) {
+        return new SimpleDateFormat(pattern);
+    }
+
+    /**
+     * 将当前时间转换成指定的格式显示
+     * 
+     * @param pattern 日期格式
+     * @return 转换后的日期字符串
+     */
+    public static String dateToString(String pattern) {
+        return getDateParser(pattern).format(new Date());
+    }
+
+    /**
+     * 将指定日期转换成指定格式的字符串
+     * 
+     * @param date 日期
+     * @param pattern 日期格式
+     * @return 转换后的日期字符串
+     */
+    public static String dateToString(Date date, String pattern) {
+        return getDateParser(pattern).format(date);
+    }
+
+    /**
+     * 将指定格式的时间转换成Date类型
+     * 
+     * @param date 指定日期
+     * @param pattern 格式
+     * @return 转换后日期
+     * @throws Exception 转换异常时,返回系统异常
+     */
+    public static Date stringToDate(String date, String pattern) throws Exception{
+        if (StringsUtils.isEmpty(pattern)) {
+            pattern = PATTEN_YMD;
+        }
+        if (StringsUtils.isEmpty(date)) {
+            return null;
+        }
+        Date result = null;
+        try {
+            result = getDateParser(pattern).parse(date);
+        } catch (ParseException e) {
+        	log.error("日期格式转换错误",e);
+            throw e;
+        }
+        return result;
+    }
+    
+    
+    /**
+     * 将指定日期的时间戳格式转换成日期
+     * 
+     * @param pattern 日期格式
+     * @return 转换后的日期字符串
+     */
+    public static Date stringToDate(String dateTime) {
+    	Date date = null;
+    	if(!StringsUtils.isEmpty(dateTime))
+    	{
+    		date = new Date(Long.parseLong(dateTime));
+    	}
+        return date;
+    }
+
+
+    /**
+     * 将指定格式的时间转换成其他日期格式
+     * 
+     * @param date 指定日期
+     * @param pattern 指定格式
+     * @param resultPattern 目标格式
+     * @return 转换后的日期字符串
+     * @throws Exception 转换异常,抛出系统异常
+     */
+    public static String changeDateFormat(String date, String pattern, String resultPattern) throws Exception {
+        String result = "";
+        try {
+            Date dateTmp = null;
+            dateTmp = getDateParser(pattern).parse(date);
+            result = getDateParser(resultPattern).format(dateTmp);
+        } catch (ParseException e) {
+        	log.error("日期格式转换错误",e);
+        	throw e;
+        }
+        return result;
+    }
+
+    /**
+     * 获取前一天日期
+     * 
+     * @param fm 日期格式
+     * @return 前一天 日期
+     * @throws Exception 转换异常,抛出系统异常
+     */
+    public static String stringToBeforeDate(String fm) {
+        String result;
+        Calendar date = Calendar.getInstance();
+        date.add(Calendar.DAY_OF_MONTH, -1);
+        Format format = new SimpleDateFormat(fm);
+        result = format.format(date.getTime());
+        return result;
+    }
+
+    /**
+     * 获取当前日期前30天的日期
+     * 
+     * @param fm 日期格式
+     * @return 当前日期前三十天的日期
+     * @throws Exception 转换异常,抛出系统异常
+     */
+    public static String thirtyDaysBeforeNow(String fm) throws Exception {
+        String result;
+        Calendar date = Calendar.getInstance();
+        date.add(Calendar.DAY_OF_MONTH, -30);
+        Format format = new SimpleDateFormat(fm);
+        result = format.format(date.getTime());
+        return result;
+    }
+
+    /**
+     * 获取指定日期的前30天的日期
+     * 
+     * @param startDate 指定日期
+     * @param fm 格式
+     * @return 指定日期前30天的日期
+     * @throws Exception 转换异常,抛出系统异常
+     */
+    public static String thirtyDaysBeforeSpecifiedDate(Date startDate, String fm) throws Exception {
+        String result;
+        Calendar date = Calendar.getInstance();
+        date.setTime(startDate);
+        date.add(Calendar.DAY_OF_MONTH, -30);
+        Format format = new SimpleDateFormat(fm);
+        result = format.format(date.getTime());
+        return result;
+    }
+
+    /**
+     * 获取当天日期
+     * 
+     * @param fm 日期格式
+     * @return 当天日期
+     * @throws Exception 转换异常,抛出系统异常
+     */
+    public static String stringToToday(String fm) throws Exception {
+        String result;
+        Format format = new SimpleDateFormat(fm);
+        result = format.format(new Date());
+        return result;
+    }
+
+    /**
+     * 返回某月的第一天
+     * 
+     * @param year 年
+     * @param month 月
+     * @return 某月的第一天
+     * @throws Exception 
+     */
+    public static Date getFirstDayOfMonth(String year, String month) throws Exception {
+        //验证空
+        if (StringsUtils.isEmpty(year) || StringsUtils.isEmpty(month)) {
+            return null;
+        }
+        //验证年
+        if (!StringsUtils.matches(year, "\\d{4}")) {
+            return null;
+        }
+        //验证月
+        int monthValue = Integer.parseInt(month);
+        if (monthValue > 12 || monthValue < 1) {
+            return null;
+        }
+        //改成  yyyy-MM-dd格式
+        StringBuilder sb = new StringBuilder();
+        sb.append(year);
+        sb.append(DEFAULT_SEPERATOR);
+        sb.append(month);
+        sb.append(DEFAULT_SEPERATOR);
+        sb.append("01");
+        return stringToDate(sb.toString(), PATTEN_YMD);
+    }
+    
+    /**
+     * 指定日期的每月第一天
+     * 
+     * @param date 待转化的日期数据
+     * @return 每月第一天
+     */
+    public static LocalDate getFistDayOfMonth(LocalDate date) {
+        if (null == date) {
+        	date=LocalDate.now();
+        }
+        LocalDate rest = date.withDayOfMonth(1);
+        return rest;
+    }
+    
+    public static LocalDate getFistDayOfMonth(Date date) {
+    	LocalDate localDate=LocalDate.now();
+        if (null != date) {
+        	localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+        }
+        
+        return getFistDayOfMonth(localDate);
+    }
+
+    /**
+     * 返回某月的最后一天
+     * 
+     * @param year 年
+     * @param month 月
+     * @return 某月的最后一天
+     */
+    public static Date getLastDayOfMonth(String year, String month) {
+        //验证空
+        if (StringsUtils.isEmpty(year) || StringsUtils.isEmpty(month)) {
+            return null;
+        }
+        //验证年
+        if (!StringsUtils.matches(year, "\\d{4}")) {
+            return null;
+        }
+        //验证月
+        int monthValue = Integer.parseInt(month);
+        if (monthValue > 12 || monthValue < 1) {
+            return null;
+        }
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.YEAR, Integer.parseInt(year));
+        cal.set(Calendar.MONTH, monthValue - 1);
+        cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+        return cal.getTime();
+    }
+    
+    /**
+     * 指定日期的每月最后一天
+     * 
+     * @param date 待转化的日期数据
+     * @return 每月最后一天
+     */
+    public static LocalDate getLastDayOfMonth(LocalDate date) {
+        if (null == date) {
+        	date=LocalDate.now();
+        }
+        LocalDate rest = date.withDayOfMonth(date.lengthOfMonth());
+        return rest;
+    }
+    
+    public static LocalDate getLastDayOfMonth(Date date) {
+    	LocalDate localDate=LocalDate.now();
+        if (null != date) {
+        	localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+        }
+        
+        return getLastDayOfMonth(localDate);
+    }
+    
+    /**
+     * 指定日期的当年第一天
+     * 
+     * @param date 待转化的日期数据
+     * @return 当年第一天
+     */
+    public static LocalDate getFistDayOfYear(LocalDate date) {
+        if (null == date) {
+        	date=LocalDate.now();
+        }
+        LocalDate rest = date.withDayOfYear(1);
+        return rest;
+    }
+    
+    public static LocalDate getFistDayOfYear(Date date) {
+    	LocalDate localDate=LocalDate.now();
+        if (null != date) {
+        	localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+        }
+        
+        return getFistDayOfYear(localDate);
+    }
+    
+    /**
+     * 指定日期的当年最后一天
+     * 
+     * @param date 待转化的日期数据
+     * @return 当年最后一天
+     */
+    public static LocalDate getLastDayOfYear(LocalDate date) {
+        if (null == date) {
+        	date=LocalDate.now();
+        }
+        LocalDate rest = date.withMonth(12).withDayOfMonth(31);
+        return rest;
+    }
+    
+    public static LocalDate getLastDayOfYear(Date date) {
+    	LocalDate localDate=LocalDate.now();
+        if (null != date) {
+        	localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+        }
+        
+        return getLastDayOfYear(localDate);
+    }
+
+    /**
+     * 返回yyyy-mm-dd格式日期
+     * 
+     * @param date 传入的日期
+     * @return yyyy-mm-dd格式日期
+     */
+    public static String formatString(String date) {
+
+        if (StringsUtils.isEmpty(date) || !checkIsActiveDate(date)) {
+            return "";
+        }
+        if (date.length() < 10) {
+            return date;
+        } else {
+            return date.substring(0, 10);
+        }
+    }
+
+    /**
+     * 返回指定格式的日期字符串
+     * 
+     * @param date 待转化的日期数据
+     * @param dateFm 日期格式
+     * @return 指定格式的日期字符串
+     */
+    public static String formatString(Date date, String dateFm) {
+        if (StringsUtils.isEmpty(dateFm)) {
+            dateFm = PATTEN_YMD;
+        }
+        if (null == date) {
+            return "";
+        }
+        Format fm = new SimpleDateFormat(dateFm);
+        return fm.format(date);
+    }
+    
+    /**
+     * 返回指定格式的日期字符串
+     * 
+     * @param date 待转化的日期数据
+     * @param dateFm 日期格式
+     * @return 指定格式的日期字符串
+     */
+    public static String localDateformatString(LocalDate date, String dateFm) {
+        if (StringsUtils.isEmpty(dateFm)) {
+            dateFm = PATTEN_YMD;
+        }
+        if (null == date) {
+        	date=LocalDate.now();
+        }
+        
+        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(dateFm);
+        String dateStr = dateTimeFormatter.format(date);
+        return dateStr;
+    }
+    
+
+    /**
+     * 获取当前日期字符串
+     * 
+     * @param formart 日期格式
+     * @return 当前日期字符串
+     */
+    public static String getDateFormatStr(String formart) {
+        return new SimpleDateFormat(formart).format(new java.util.Date());
+    }
+    
+    public static String getLocalDateNowStr(String formart) {
+        return localDateformatString(LocalDate.now(),formart);
+    }
+
+    /**
+     * 日期加年
+     * 
+     * @param date 日期
+     * @param spans 增加数量
+     * @return 增加X年后的日期
+     */
+    public static Date addYear(Date date, int spans) {
+        return addDate(date, Calendar.YEAR, spans);
+    }
+
+    /**
+     * 日期加月
+     * 
+     * @param date 日期
+     * @param spans 增加数量
+     * @return 加月后的日期
+     */
+    public static Date addMonth(Date date, int spans) {
+        return addDate(date, Calendar.MONTH, spans);
+    }
+
+    /**
+     * 日期加天
+     * 
+     * @param date 日期
+     * @param spans 增加数量
+     * @return 加天后的日期
+     */
+    public static Date addDay(Date date, int spans) {
+        return addDate(date, Calendar.DAY_OF_MONTH, spans);
+    }
+
+    /**
+     * 日期加小时
+     * 
+     * @param date 日期
+     * @param spans 增加数量
+     * @return 加小时后的日期
+     */
+    public static Date addHour(Date date, int spans) {
+        return addDate(date, Calendar.HOUR_OF_DAY, spans);
+    }
+
+    /**
+     * 日期加分钟
+     * 
+     * @param date 日期
+     * @param spans 增加数量
+     * @return 加分钟后的日期
+     */
+    public static Date addMinute(Date date, int spans) {
+        return addDate(date, Calendar.MINUTE, spans);
+    }
+
+    /**
+     * 日期加秒
+     * 
+     * @param date 日期
+     * @param spans 增加数量
+     * @return 加秒后的日期
+     */
+    public static Date addSecond(Date date, int spans) {
+        return addDate(date, Calendar.SECOND, spans);
+    }
+
+    /**
+     * 日期加法计算
+     * 
+     * @param date 日期
+     * @param type 增加类型
+     * @param spans 增加数量
+     * @return 加法计算后的日期
+     */
+    public static Date addDate(Date date, int type, int spans) {
+        Calendar inputCalendar = Calendar.getInstance();
+        inputCalendar.setTime(date);
+        inputCalendar.add(type, spans);
+        return inputCalendar.getTime();
+    }
+
+    /**
+     * 获取当前day of month
+     * 
+     * @return String
+     */
+    public static String getCurrentDayOfMonth() {
+        Calendar calendar = Calendar.getInstance();
+        return String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
+    }
+
+    /**
+     * 获取当前月份数字
+     * 
+     * @return String
+     */
+    public static String getCurrentMonth() {
+        Calendar calendar = Calendar.getInstance();
+        return String.valueOf(calendar.get(Calendar.MONTH) + 1);
+    }
+
+    /**
+     * 获取当前小时
+     * 
+     * @return String
+     */
+    public static String getCurrentHour() {
+        Calendar calendar = Calendar.getInstance();
+        return String.valueOf(calendar.get(Calendar.HOUR_OF_DAY));
+    }
+    
+    /**
+     * 获取当前年
+     * 
+     * @return String
+     */
+    public static String getCurrentYear() {
+        Calendar calendar = Calendar.getInstance();
+        return String.valueOf(calendar.get(Calendar.YEAR));
+    }
+
+    /**
+     * 获取当前时间,字符串类型,格式(yyyy-mm-dd)
+     * 
+     * @return String
+     */
+    public static String getCurrentDateString() {
+        return getDateFormatStr(PATTEN_YMD);
+    }
+
+    /**
+     * 获取当前时间, 日期类型
+     * 
+     * @return java.util.Date
+     */
+    public static Date getCurrentDate() {
+        return new Date();
+    }
+
+    /**
+     * 判断是否是有效日期
+     * 
+     * @param date 判断日期
+     * @return 是否有效日期
+     */
+    public static boolean checkIsActiveDate(String date) {
+        //先验证基本格式是否正确
+        if (!StringsUtils.matches(date, DATE_REG_SIMPLE)) {
+            return false;
+        }
+        //验证复杂格式是否正确
+        if (StringsUtils.isNotEmpty(date) && date.contains(DEFAULT_SEPERATOR)) {
+            String dateNoSeprator = date.replaceAll(DEFAULT_SEPERATOR, "");
+            return StringsUtils.matches(dateNoSeprator, DATE_REG);
+        }
+        return false;
+    }
+
+    /**
+     * 比较两个日期大小
+     * 
+     * @param startDate 开始日期
+     * @param endDate 结束日期
+     * @return 开始日期早于结束日期,返回true。否则返回false。相等,返回false
+     */
+    public static boolean dateCompare(Date startDate, Date endDate) {
+        if (endDate.compareTo(startDate)==1) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 比较两个日期是否相等
+     * 
+     * @param startDate 开始日期
+     * @param endDate 结束日期
+     * @return 开始日期等于结束日期,返回true。否则返回false
+     */
+    public static boolean dateEqual(Date startDate, Date endDate) {
+        if (startDate.compareTo(endDate) == 0) {
+            return true;
+        }
+        return false;
+    }
+    
+    /**
+     * 返回指定日期的年
+     * 
+     * @param date 指定的日期
+     * @return 指定日期的年
+     */
+    public static String getYearFromDate(String date) {
+        if (!checkIsActiveDate(date)) {
+            return "";
+        }
+        //日期格式化
+        try {
+            Date dateTmp = getDateParser(PATTEN_YMD).parse(date);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(dateTmp);
+            return String.valueOf(calendar.get(Calendar.YEAR));
+        } catch (ParseException e) {
+        	log.error("日期格式转换错误",e);
+            return "";
+        }
+    }
+
+    /**
+     * 返回指定日期的月
+     * 
+     * @param date 指定的日期
+     * @return 指定日期的月
+     */
+    public static String getMonthFromDate(String date) {
+        if (!checkIsActiveDate(date)) {
+            return "";
+        }
+        //日期格式化
+        try {
+            Date dateTmp = getDateParser(PATTEN_YMD).parse(date);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(dateTmp);
+            return String.valueOf(calendar.get(Calendar.MONTH) + 1);
+        } catch (ParseException e) {
+        	log.error("日期格式转换错误",e);
+            return "";
+        }
+    }
+
+    /**
+     * 返回指定日期的日
+     * 
+     * @param date 指定日期
+     * @return 指定日期的日
+     */
+    public static String getDayFromDate(String date) {
+        if (!checkIsActiveDate(date)) {
+            return "";
+        }
+        //日期格式化
+        try {
+            Date dateTmp = getDateParser(PATTEN_YMD).parse(date);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(dateTmp);
+            return String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
+        } catch (ParseException e) {
+        	log.error("日期格式转换错误",e);
+            return "";
+        }
+    }
+    
+    /**
+	 * 根据日期取得星期几
+	 * @param dt
+	 * @return
+	 */
+    public static String getWeekOfDate(Date dt) {
+        String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(dt);
+
+        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
+        if (w < 0)
+            w = 0;
+
+        return weekDays[w];
+    }
+    
+    /**
+     * 获取某月的第一天的0点0分1秒
+     * 
+     * @param pattern 日期格式
+     * @return 转换后的日期字符串
+     */
+    public static Date getFirstdayOfMonth(Date theDate) {
+    	Calendar calendar = Calendar.getInstance();
+    	calendar.setTime(theDate);
+    	//将月至1
+    	calendar.set(Calendar.DAY_OF_MONTH, 1);
+    	//将小时至0
+    	calendar.set(Calendar.HOUR_OF_DAY, 0);
+    	//将分钟至0
+    	calendar.set(Calendar.MINUTE, 0);
+    	//将秒至1
+    	calendar.set(Calendar.SECOND,1);
+    	//将毫秒至0
+    	calendar.set(Calendar.MILLISECOND, 0);
+
+    	return calendar.getTime();
+    }
+    
+    
+    /**
+     * 获取某日的0点0分1秒
+     * 
+     * @param pattern 日期格式
+     * @return 转换后的日期字符串
+     */
+    public static Date getFirstTimeOfDay(Date theDate) {
+    	Calendar calendar = Calendar.getInstance();
+    	calendar.setTime(theDate);
+    	//将小时至0
+    	calendar.set(Calendar.HOUR_OF_DAY, 0);
+    	//将分钟至0
+    	calendar.set(Calendar.MINUTE, 0);
+    	//将秒至1
+    	calendar.set(Calendar.SECOND,1);
+    	//将毫秒至0
+    	calendar.set(Calendar.MILLISECOND, 0);
+
+    	return calendar.getTime();
+    }
+    
+    
+    /**
+    * <li>功能描述:时间相减得到天数
+    * @param beginDateStr
+    * @param endDateStr
+    * @return
+    * long 
+    * @author Administrator
+    */
+    public static long getDaySub(Date beginDate,Date endDate)
+    {
+        return  (endDate.getTime()-beginDate.getTime())/(24*60*60*1000);
+    }
+    
+    
+    /**
+     * <li>功能描述:时间相减得到分钟数(向上取整)
+     * @param beginDateStr
+     * @param endDateStr
+     * @return
+     * long 
+     * @author Administrator
+     */
+     public static int getMinuteSubUp(Date beginDate,Date endDate)
+     {
+    	 if(beginDate == null || endDate == null)
+    	 {
+    		 return 0;
+    	 }
+    	 BigDecimal second = new BigDecimal((endDate.getTime()-beginDate.getTime())/1000);
+    	 
+    	 return second.divide(new BigDecimal(60),0,BigDecimal.ROUND_UP).intValue();
+     }
+    
+    /**
+     * <li>功能描述:时间相减得到年数(四舍五入)
+     * @param beginDateStr
+     * @param endDateStr
+     * @return
+     * long 
+     * @author Administrator
+     */
+     public static int getYearSub(Date beginDate,Date endDate)
+     {
+    	 if(beginDate == null || endDate == null)
+    	 {
+    		 return 0;
+    	 }
+    	 BigDecimal second = new BigDecimal((endDate.getTime()-beginDate.getTime())/1000);
+    	 
+    	 return second.divide(new BigDecimal((24*60*60*365)),0,BigDecimal.ROUND_HALF_UP).intValue();
+     }
+
+     /**
+      * 返回指定格式的日期字符串
+      * 
+      * @param date 待转化的日期数据
+      * @param dateFm 日期格式
+      * @return 指定格式的日期字符串
+      */
+     public static String localDateYMDString(LocalDate date) {
+         if (null == date) {
+         	date=LocalDate.now();
+         }
+         String dateStr = localDateformatString(date,PATTEN_YMD);
+         return dateStr;
+     }
+     
+     
+
+
+}

+ 99 - 0
src/main/java/com/wechat/common/utils/HttpClientUtils.java

@@ -0,0 +1,99 @@
+package com.wechat.common.utils;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+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.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+
+public class HttpClientUtils {
+	private static final Log log = LogFactory.getLog(HttpClientUtils.class);
+
+	/**
+	 * @param url
+	 *            领英token地址
+	 * @param map
+	 *            参数
+	 * @param charset
+	 *            utf-8
+	 * @return
+	 */
+	public String doPost(String url, Map<String, String> map, String charset) {
+		CloseableHttpClient httpClient = null;
+		HttpPost httpPost = null;
+		String result = null;
+		try {
+			httpClient = HttpClients.createDefault();
+			httpPost = new HttpPost(url);
+			// 设置参数
+			List<NameValuePair> list = new ArrayList<NameValuePair>();
+			Iterator iterator = map.entrySet().iterator();
+			while (iterator.hasNext()) {
+				Map.Entry<String, String> elem = (Map.Entry<String, String>) iterator.next();
+				list.add(new BasicNameValuePair(elem.getKey(), elem.getValue()));
+			}
+			if (list.size() > 0) {
+				UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, charset);
+				entity.setContentType("application/x-www-form-urlencoded");
+				httpPost.setEntity(entity);
+			}
+			HttpResponse response = httpClient.execute(httpPost);
+			if (response != null) {
+				HttpEntity resEntity = response.getEntity();
+				if (resEntity != null) {
+					result = EntityUtils.toString(resEntity, charset);
+				}
+			}
+		} catch (Exception ex) {
+			log.error(ex);
+		}
+		return result;
+	}
+
+	public String doGet(String strURL, String authorizationStr) {
+		String result = "";
+		try {
+			URL url = new URL(strURL);// 创建连接
+			HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+			connection.setDoOutput(true);
+			connection.setUseCaches(false);
+			connection.setRequestMethod("GET"); // 设置请求方式
+			connection.setRequestProperty("Accept", "application/json"); // 设置接收数据的格式
+			connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); // 设置发送数据的格式
+			connection.setRequestProperty("Authorization", authorizationStr);// 对应坑2,token放到这里
+			connection.setRequestProperty("contentType", "utf-8");
+			connection.connect();
+			// 处理响应数据
+			BufferedReader in = null;
+			try {
+				in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+				String line;
+				while ((line = in.readLine()) != null) {
+					result += line;
+				}
+			} finally {
+				if (in != null)
+					in.close();
+			}
+		} catch (Exception e) {
+			log.error(e);
+		}
+		return result;
+	}
+}

+ 38 - 0
src/main/java/com/wechat/common/utils/IOStreamUtils.java

@@ -0,0 +1,38 @@
+package com.wechat.common.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.springframework.util.FileCopyUtils;
+
+public class IOStreamUtils extends BaseUtils {
+
+	/**
+	 * 根据图片名称获取字节流
+	 * 
+	 * @param basePath
+	 *            根路径
+	 * @param filePath
+	 *            图片路径
+	 * @param fileName
+	 *            图片名称
+	 * @return
+	 */
+	public static byte[] getimagefile(String basePath, String filePath, String fileName) {
+		byte[] data = null;
+		try {
+			// 设置文件上传路径
+			String uploadPath = basePath + filePath;
+			File file = new File(uploadPath, fileName);
+			if (file.exists()) {
+				FileInputStream fis = new FileInputStream(file);
+				data = FileCopyUtils.copyToByteArray(fis);
+			}
+		} catch (Exception ex) {
+			log.error("io异常", ex);
+			return null;
+		}
+		return data;
+	}
+
+}

+ 153 - 0
src/main/java/com/wechat/common/utils/JacksonUtils.java

@@ -0,0 +1,153 @@
+package com.wechat.common.utils;
+
+import java.util.List;
+import java.util.Map;
+
+import org.nutz.json.Json;
+import org.nutz.json.JsonFormat;
+import org.nutz.lang.util.NutMap;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+import com.alibaba.fastjson.JSON;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/** Another JSON Serialize & Deserialize Library */
+public class JacksonUtils extends BaseUtils{
+    private static ObjectMapper mapper = new ObjectMapper();
+    public static String serialize(Object obj) {
+        try {
+            return mapper.writeValueAsString(obj);
+        } catch (Exception ex) {
+            log.error("Error when serializing object to string.", ex);
+        }
+        return null;
+    }
+
+    /**
+     * pretty print enabled, for debug purpose.
+     * @param obj
+     * @return
+     */
+    public static String beautifulSerialize(Object obj) {
+        try {
+
+            return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
+        } catch (Exception ex) {
+            log.error("Error when serializing object to string.", ex);
+        }
+        return null;
+    }
+
+    public static <T> T deserialize(final String json, Class<T> classofT) {
+        try {
+
+            return mapper.readValue(json, classofT);
+        } catch (Exception ex) {
+            log.error("Error when deserializing json: " + json, ex);
+        }
+        return null;
+    }
+    
+    /**
+     * bean 转换成JSON
+     * 
+     * @param bean 对象参数
+     * @return 转换后的JSON字符串
+     */
+    public static String bean2json(Object bean) {
+        return JSONObject.fromObject(bean).toString();
+    }
+
+    /**
+     * list 转换成JSON
+     * 
+     * @param list 需要转换的list
+     * @return 转换后的JSON字符串
+     */
+    public static String list2json(List<?> list) {
+        return JSONArray.fromObject(list).toString();
+    }
+    
+    
+    /**
+     * JSON 转换成 list
+     * @param <T>
+     * 
+     * @param list 需要转换的list
+     * @return 转换后的JSON字符串
+     */
+    public static <T> List<T> json2list(String jsonArray, Class<T> objectClass) {
+    	return JSON.parseArray(jsonArray, objectClass);
+    }
+    
+    /**
+     * string 转json
+     * 
+     * @param param
+     * @return
+     */
+    public static JSONObject StringTOJson(String param) {
+        if (param != null && param != "") {
+            //          param = param.substring(1, param.length() -1);
+            JSONObject jasonObject = JSONObject.fromObject(param);
+            return jasonObject;
+        }
+        else {
+            return null;
+        }
+    }
+
+    /**
+     String j = "{\"result\":0,\"msg\":\"msg\",\"info\":\"info_here\"}";
+     JsonResp<String> rsp = JacksonUtils.deserializeGeneric(j, new TypeReference<JsonResp<String>>() { });
+     System.out.print(rsp.getInfo());
+
+     This code will print `info_here`
+     */
+    public static <T> T deserializeGeneric(final String json, TypeReference<T> classofT) {
+        try {
+            return mapper.readValue(json, classofT);
+        } catch (Exception ex) {
+            log.error("Error when deserializing json: " + json, ex);
+        }
+        return null;
+    }
+    
+    
+    /**
+     * 从一个JSON 对象字符格式中得到一个java对象,其中beansList是一类的集合,形如: {"id" : idValue, "name" : nameValue, "aBean" : {"aBeanId" : aBeanIdValue, ...}, beansList:[{}, {}, ...]}
+     * 
+     * @param jsonString
+     * @param clazz
+     * @param map 集合属性的类型 (key : 集合属性名, value : 集合属性类型class) eg: ("beansList" : Bean.class)
+     * @return
+     */
+    @SuppressWarnings("rawtypes")
+    public static Object getDTO(String jsonString, Class clazz, Map map) {
+        JSONObject jsonObject = null;
+        try {
+            jsonObject = JSONObject.fromObject(jsonString);
+        }
+        catch (Exception e) {
+            log.error("json转dto异常",e);
+        }
+        return JSONObject.toBean(jsonObject, clazz, map);
+    }
+    
+    /**
+     * 把jackson null转为""串
+     * 
+     * @param response
+     * @param object
+     * @return
+     */
+    public static NutMap writeNullToString(Object object) {
+        JsonFormat format = JsonFormat.tidy();
+        format.setNullAsEmtry(true);
+        String json = Json.toJson(object, format);
+        return NutMap.WRAP(json);
+    }
+}

+ 131 - 0
src/main/java/com/wechat/common/utils/KeyWordUtil.java

@@ -0,0 +1,131 @@
+package com.wechat.common.utils;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+public class KeyWordUtil {
+	
+	private Map<String, Object> dictionaryMap;
+	
+	private KeyWordUtil() {}
+	private static KeyWordUtil keyWordUtil = new KeyWordUtil();
+	private static KeyWordUtil getNew() {
+		return keyWordUtil;
+	}
+	 
+    public KeyWordUtil setWords(Set<String> wordSet) {
+        this.dictionaryMap = handleToMap(wordSet);
+        return keyWordUtil;
+    }
+ 
+    public Map<String, Object> getDictionaryMap() {
+        return dictionaryMap;
+    }
+ 
+    public void setDictionaryMap(Map<String, Object> dictionaryMap) {
+        this.dictionaryMap = dictionaryMap;
+    }
+ 
+    @SuppressWarnings("unchecked")
+    private Map<String, Object> handleToMap(Set<String> wordSet) {
+        if (wordSet == null) {
+            return null;
+        }
+        Map<String, Object> map = new HashMap<String, Object>(wordSet.size());
+        Map<String, Object> curMap = null;
+        Iterator<String> ite = wordSet.iterator();
+        while (ite.hasNext()) {
+            String word = ite.next();
+            curMap = map;
+            int len = word.length();
+            for (int i = 0; i < len; i++) {
+                String key = String.valueOf(word.charAt(i));
+                Map<String, Object> wordMap = (Map<String, Object>) curMap
+                        .get(key);
+                if (wordMap == null) {
+                    wordMap = new HashMap<String, Object>();
+                    wordMap.put("isEnd", "0");
+                    curMap.put(key, wordMap);
+                    curMap = wordMap;
+                }
+                else {
+                    curMap = wordMap;
+                }
+                if (i == len - 1) {
+                    curMap.put("isEnd", "1");
+                }
+            }
+        }
+        return map;
+    }
+ 
+    @SuppressWarnings("unchecked")
+    public int checkWord(String text, int beginIndex) {
+        if (dictionaryMap == null) {
+            throw new RuntimeException("字典不能为空!");
+        }
+        boolean isEnd = false;
+        int wordLength = 0;
+        Map<String, Object> curMap = dictionaryMap;
+        int len = text.length();
+        for (int i = beginIndex; i < len; i++) {
+            String key = String.valueOf(text.charAt(i));
+            curMap = (Map<String, Object>) curMap.get(key);
+            if (curMap == null) {
+                break;
+            }
+            else {
+                wordLength++;
+                if ("1".equals(curMap.get("isEnd"))) {
+                    isEnd = true;
+                }
+            }
+        }
+        if (!isEnd) {
+            wordLength = 0;
+        }
+        return wordLength;
+    }
+ 
+    public Set<String> getWords(String text) {
+        Set<String> wordSet = new HashSet<String>();
+        int len = text.length();
+        for (int i = 0; i < len; i++) {
+            int wordLength = checkWord(text, i);
+            if (wordLength > 0) {
+                String word = text.substring(i, i + wordLength);
+                wordSet.add(word);
+                i = i + wordLength - 1;
+            }
+        }
+        return wordSet;
+    }
+	public static Set<String> returnKeys(Set<String> wordSet,String text) {
+    	return KeyWordUtil.getNew().setWords(wordSet).getWords(text);
+    }
+    /*public static void main(String[] args) {
+        Set<String> wordSet = new HashSet<String>();
+        wordSet.add("叶良辰");
+        wordSet.add("叶良辰的");
+        wordSet.add("叶良辰的人");
+        wordSet.add("叶良辰的兄弟");
+        wordSet.add("良辰");
+        wordSet.add("良辰不");
+        wordSet.add("呵呵");
+        KeyWordUtil keyWordUtil = new KeyWordUtil(wordSet);
+        Map<String, Object> map = keyWordUtil.getDictionaryMap();
+        System.out.println(map);
+        String text = "不错,我就是叶良辰。你的行为实在欺人太甚,你若是感觉有实力跟我玩,良辰不介意奉陪到底。呵呵,我会让你明白,良辰从不说空话。";
+        int beginIndex = 6;
+        int wordLength = keyWordUtil.checkWord(text, beginIndex);
+        System.out.println(wordLength);
+        System.out.println(keyWordUtil.getWords(text));
+        System.out.println("s".split(" ").toString()); 
+        
+	}*/
+
+
+}

+ 86 - 0
src/main/java/com/wechat/common/utils/ListPageUtil.java

@@ -0,0 +1,86 @@
+package com.wechat.common.utils;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 集合分页工具类
+ * 
+ * @author zhouyd
+ *
+ */
+public class ListPageUtil<T> {
+
+	private List<T> data; // 原集合
+
+	private int nowPage; // 当前页
+
+	private int pageSize; // 每页条数
+
+	private int totalPage; // 总页数
+
+	private int totalCount; // 总条数
+
+	public ListPageUtil(List<T> data, int nowPage, int pageSize) {
+		this.data = data;
+		this.pageSize = pageSize;
+		this.nowPage = nowPage;
+		this.totalCount = data.size();
+		this.totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
+	}
+
+	/**
+	 * 得到分页后的数据
+	 *
+	 * @param pageNum
+	 *            页码
+	 * @return 分页后结果
+	 */
+	public List<T> getPagedList() {
+		int fromIndex = (nowPage - 1) * pageSize;
+		if (fromIndex >= data.size()) {
+			return Collections.emptyList();// 空数组
+		}
+		if (fromIndex < 0) {
+			return Collections.emptyList();// 空数组
+		}
+		int toIndex = nowPage * pageSize;
+		if (toIndex >= data.size()) {
+			toIndex = data.size();
+		}
+		return data.subList(fromIndex, toIndex);
+	}
+
+	public List<T> getData() {
+		return data;
+	}
+
+	public void setData(List<T> data) {
+		this.data = data;
+	}
+
+	public int getNowPage() {
+		return nowPage;
+	}
+
+	public void setNowPage(int nowPage) {
+		this.nowPage = nowPage;
+	}
+
+	public int getPageSize() {
+		return pageSize;
+	}
+
+	public void setPageSize(int pageSize) {
+		this.pageSize = pageSize;
+	}
+
+	public int getTotalPage() {
+		return totalPage;
+	}
+
+	public void setTotalPage(int totalPage) {
+		this.totalPage = totalPage;
+	}
+
+}

+ 422 - 0
src/main/java/com/wechat/common/utils/LocalFileUtil.java

@@ -0,0 +1,422 @@
+package com.wechat.common.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.nio.file.Files;
+
+import org.apache.commons.codec.binary.Base64;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.wechat.global.CustomException;
+import com.wechat.global.message.InfoMsg;
+
+import net.coobird.thumbnailator.Thumbnails;
+import sun.misc.BASE64Decoder;
+
+public class LocalFileUtil extends BaseUtils{
+	
+	/**
+     * 上传文件
+     * @param file
+     * @param basePackagePath 系统默认路径
+     * @return
+     * @throws IOException
+     */
+    public static String transferToFile(MultipartFile file,String basePackagePath) throws IOException {
+    	// 获取新的文件名称
+        String fileName = getNewFileName(file.getOriginalFilename());
+        // 创建接受文件
+        File targetFile = doFile(basePackagePath,fileName);
+        file.transferTo(targetFile);
+        return fileName;
+    }
+    
+    /**
+     * 上传图片
+     * @param file
+     * @param basePackagePath 系统默认路径
+     * @param pack 自定义文件上传路径  如: test/
+     * @return
+     * @throws IOException
+     */
+    public static String transferToImageFile(MultipartFile file,String basePackagePath,String pack) throws IOException {
+    	String rest = "";
+    	if(!file.isEmpty() && file.getSize()> 0) {
+    		// 获取新的文件名称
+        	String fileName = getNewFileName(file.getOriginalFilename());
+        	//验证图片格式
+        	if(checkImage(fileName))
+        	{
+    	        pack = StringsUtils.isEmpty(pack)? "" : pack;
+    	        if(pack.length()>0) {
+    	        	pack =  pack.indexOf("/") < 0 ?  pack + "/":pack;
+    	        }
+    	        // 创建接受文件
+    	        File targetFile = doFile(basePackagePath+pack,fileName);
+    	        file.transferTo(targetFile);
+    	        rest =  pack+fileName;//targetFile.getPath().replace("\\","/");
+        	}
+    	}
+    	
+    	return rest;
+    }
+    
+    
+    /**
+     * 上传文件
+     * @param file
+     * @param basePackagePath 系统默认路径
+     * @param pack 自定义文件上传路径  如: test/
+     * @return
+     * @throws IOException
+     */
+    public static String transferToFile(MultipartFile file,String basePackagePath,String pack) throws IOException {
+    	// 获取新的文件名称
+    	String fileName = getNewFileName(file.getOriginalFilename());
+
+        pack = StringsUtils.isEmpty(pack)? "" : pack;
+        if(pack.length()>0) {
+        	pack =  pack.indexOf("/") < 0 ?  pack + "/":pack;
+        }
+        // 创建接受文件
+        File targetFile = doFile(basePackagePath+pack,fileName);
+        file.transferTo(targetFile);
+        return  pack+fileName;//targetFile.getPath().replace("\\","/");
+
+    }
+    
+    
+    private static String getNewFileName(String filename) {
+        long startTime = System.currentTimeMillis();
+        String newName = startTime + StringsUtils.getRandomString(5)+ filename.substring(filename.lastIndexOf("."));
+        return newName;
+    }
+    private static File doFile(String path,String fileName) {
+    	//指定上传目录,不指定盘符会自动保存到你的项目所在盘符
+    	File fileDir = new File(path);
+        //目录不存在则生成目录
+        if (!fileDir.isDirectory()) {
+            fileDir.mkdirs();
+        }
+        return new File(fileDir, fileName);
+    }
+    /**
+     * 删除单个文件
+     * @param fileUrl
+     * @return
+     */
+    public static boolean deleteLocalFile(String fileUrl) {
+    	File file = new File(fileUrl);
+		if (file.exists() && file.isFile()) {
+			if (file.delete()) {
+				return true;
+			} else {
+				return false;
+			}
+		} else {
+			return true;
+		}
+    }
+    /**
+     * 上传头像 并生成缩略图
+     * @param file
+     * @param basePackagePath
+     * @return
+     */
+    public static String transferHeadProtrait(MultipartFile file,String basePackagePath,String baseImagePackagePath,int imageSize) throws IOException{
+    	return solvePictureUpload(file, basePackagePath, baseImagePackagePath, null, null, null, null);
+    }
+    
+    /**
+     * 将图片转换成Base64编码
+     * @param imgFile 待处理图片
+     * @return
+     */
+    public static String getImgBase64Str(String imgFile) {
+        // 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
+        InputStream in = null;
+        byte[] data = null;
+        // 读取图片字节数组
+        try {
+            in = new FileInputStream(imgFile);
+            data = new byte[in.available()];
+            in.read(data);
+            in.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return Base64.encodeBase64String(data);
+    }
+    
+    
+    /**
+	 * base64字符串转化成图片
+	 * 
+	 * @return
+	 */
+	public static boolean generateImage(String imgStr,String filePackagePath,String fileName) {// 对字节数组字符串进行Base64解码并生成图片
+		if (imgStr == null) // 图像数据为空
+		{
+			return false;
+		}else {
+			String[] img = imgStr.split("base64,",2);
+			if(img.length > 1) {
+				imgStr = img[1];
+			}
+		}
+
+		BASE64Decoder decoder = new sun.misc.BASE64Decoder();
+		try {
+			//Base64解码
+			byte[] b = decoder.decodeBuffer(imgStr);
+			for (int i = 0; i < b.length; ++i) {
+				if (b[i] < 0) {// 调整异常数据
+					b[i] += 256;
+				}
+			}
+	    	//指定上传目录,不指定盘符会自动保存到你的项目所在盘符
+	    	File fileDir = new File(filePackagePath);
+	        //目录不存在则生成目录
+	        if (!fileDir.isDirectory()) {
+	            fileDir.mkdirs();
+	        }
+			//生成图片至指定路径
+			OutputStream out = new FileOutputStream(filePackagePath+fileName);
+			out.write(b);
+			out.flush();
+			out.close();
+			return true;
+		} catch (Exception e) {
+			log.error("Base64解析异常",e);
+			return false;
+		}
+	}
+
+    
+    /**
+     * 上传头像 并生成缩略图 base64上传
+     * @param file
+     * @param basePackagePath
+     * @return
+     */
+    public static String transferHeadProtraitForBase64(String imgStr,String basePackagePath,String baseImagePackagePath,String pre) throws IOException{
+    	Integer imageWidthOrHeightSize = 400;
+    	Float quality = 0.8f;
+		String suf = ".jpg";
+		String finalName = pre + suf;
+    	if(generateImage(imgStr, basePackagePath+baseImagePackagePath,finalName))
+		{
+    		String fileUrl = basePackagePath+baseImagePackagePath+finalName;
+    		File mid = doFile(basePackagePath + baseImagePackagePath, pre + "_mid" + suf);
+    		File mini = doFile(basePackagePath + baseImagePackagePath, pre + "_mini" + suf);
+    		Thumbnails.of(fileUrl).size(imageWidthOrHeightSize, imageWidthOrHeightSize).outputQuality(quality).toFile(mid);// 中等尺寸
+    		Thumbnails.of(fileUrl).size(200, 200).outputQuality(quality).toFile(mini);// 最小尺寸
+    		//删除原图
+    		new File(fileUrl).delete();
+    		return baseImagePackagePath + pre + "_mini" + suf;
+		}else {
+			return null;
+		}
+
+		
+    }
+    /**
+     * 
+     * @param file 上传的文件名称
+     * @param basePackagePath 根路径
+     * @param baseImagePackagePath 文件地址的相对路径
+     * @param limitKilobyte 大小限制 默认200K
+     * @param imageWidthOrHeightSize 图片长宽限制 默认 400
+     * @param quality 图片质量限制 默认0.8f
+     * @param finalName 给定图片名称
+     * @return
+     * @throws IOException
+     */
+	public static String solvePictureUpload(MultipartFile file, String basePackagePath, String baseImagePackagePath,
+			Integer limitKilobyte, Integer imageWidthOrHeightSize, Float quality, String finalName) throws IOException {
+		if (imageWidthOrHeightSize == null)
+			imageWidthOrHeightSize = 400;
+		if (quality == null)
+			quality = 0.8f;
+		if (finalName == null)
+			finalName = getNewFileName(file.getOriginalFilename());
+		String pre = finalName.substring(0, finalName.lastIndexOf("."));
+		String suf = finalName.substring(finalName.lastIndexOf("."));
+
+		File mid = doFile(basePackagePath + baseImagePackagePath, pre + "_mid" + suf);
+		File mini = doFile(basePackagePath + baseImagePackagePath, pre + "_mini" + suf);
+
+		Thumbnails.of(file.getInputStream()).size(imageWidthOrHeightSize, imageWidthOrHeightSize).outputQuality(quality)
+				.toFile(mid);// 中等尺寸
+		Thumbnails.of(file.getInputStream()).size(200, 200).outputQuality(quality).toFile(mini);// 最小尺寸
+		// 压缩图片
+		if (limitKilobyte != null) {
+			commpressPicCycle(basePackagePath + baseImagePackagePath + pre + "_mini" + suf, new Long(limitKilobyte),
+					quality);
+			commpressPicCycle(basePackagePath + baseImagePackagePath + pre + "_mid" + suf, new Long(limitKilobyte),
+					quality);
+		}
+		return baseImagePackagePath + pre + "_mini" + suf;
+	}
+    /**
+     * 图片保真上传
+     * @param file
+     * @param basePackagePath
+     * @param baseImagePackagePath
+     * @return
+     * @throws IOException
+     */
+    public static String uploadFileWithoutLimit(
+    		MultipartFile file,
+    		String basePackagePath,
+    		String baseImagePackagePath)  throws IOException 
+    {
+    	String finalName = getNewFileName(file.getOriginalFilename());
+    	String pre = finalName.substring(0,finalName.lastIndexOf("."));
+    	String suf = finalName.substring(finalName.lastIndexOf("."));
+    	File mini = doFile(basePackagePath+baseImagePackagePath,pre+"_mini"+suf);
+    	Thumbnails.of(file.getInputStream()).scale(1).toFile(mini);//最小尺寸
+
+    	return baseImagePackagePath+pre+"_mini"+suf;
+    }
+    
+    /**
+     * 上传头像 并生成缩略图
+     * @param file
+     * @param basePackagePath
+     * @param destFileName 目标文件名称 xxx.jpg
+     * @return
+     */
+    public static String saveHeadProtrait(MultipartFile file,String basePackagePath,String baseImagePackagePath,int imageSize, String destFileName) throws IOException{
+    	return solvePictureUpload(file, basePackagePath, baseImagePackagePath, null, null, null, destFileName);
+    	// 获取新的文件名称
+//        String pre = destFileName.substring(0,destFileName.lastIndexOf("."));
+//        String suf = destFileName.substring(destFileName.lastIndexOf("."));
+//        
+////        File max = doFile(basePackagePath+baseImagePackagePath,pre+"_max"+suf);
+//        File mid = doFile(basePackagePath+baseImagePackagePath,pre+"_mid"+suf);
+//    	File mini = doFile(basePackagePath+baseImagePackagePath,pre+"_mini"+suf);
+//        
+//    	Thumbnails.of(file.getInputStream()).size(400,400).outputQuality(0.8f).toFile(mid);//中等尺寸
+//    	Thumbnails.of(file.getInputStream()).size(200,200).outputQuality(0.8f).toFile(mini);//最小尺寸
+//    	return baseImagePackagePath+pre+"_mini"+suf;
+    }
+    
+    /**
+	 * 压缩图片
+	 * @param desPath 文件路径 (绝对路径)
+	 * @param desFileSize 目标大小 kb
+	 * @param accuracy 图片质量 例如: 0.8d
+	 * @throws IOException
+	 */
+    public static void commpressPicCycle(String desPath, long desFileSize,  double accuracy) throws IOException {
+        FileInputStream in = new FileInputStream(desPath);
+        byte[] imgByte = new byte[in.available()];
+        in.read(imgByte);
+        imgByte = compressPicForScale(imgByte,desFileSize);
+        FileOutputStream out = new FileOutputStream(desPath);
+        out.write(imgByte);
+        if(in != null) {
+        	in.close();
+        }
+        if(out != null) {
+        	out.close();
+        }
+    }
+
+	public static String transferDefaultImageToDest(String basePackagePath, String basePackagePathImage, String fileName) {
+		String pre = fileName.substring(0,fileName.lastIndexOf("."));
+        String suf = fileName.substring(fileName.lastIndexOf("."));
+        File mid = doFile(basePackagePath+basePackagePathImage,pre+"_mid"+suf);
+    	File mini = doFile(basePackagePath+basePackagePathImage,pre+"_mini"+suf);
+    	URL in = LocalFileUtil.class.getClassLoader().getResource("/template/person-add.png");
+    	File f = new File(in.getPath());
+        if(f.exists()) {
+        	try {
+				Files.copy(f.toPath(), mid.toPath());
+				Files.copy(f.toPath(), mini.toPath()); 
+				return basePackagePathImage+pre+"_mini"+suf;
+			} catch (IOException e) {
+				log.error("图片压缩异常",e);
+				e.printStackTrace();
+			} 
+        }
+        return null;
+	}
+	
+	
+	
+	/**
+     * 根据指定大小压缩图片
+     *
+     * @param imageBytes  源图片字节数组
+     * @param desFileSize 指定图片大小,单位kb
+     * @param imageId     影像编号
+     * @return 压缩质量后的图片字节数组
+     */
+    public static byte[] compressPicForScale(byte[] imageBytes, long desFileSize) {
+        if (imageBytes == null || imageBytes.length <= 0 || imageBytes.length < desFileSize * 1024) {
+            return imageBytes;
+        }
+        long srcSize = imageBytes.length;
+        double accuracy = getAccuracy(srcSize / 1024);
+        try {
+            while (imageBytes.length > desFileSize * 1024) {
+                ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes);
+                ByteArrayOutputStream outputStream = new ByteArrayOutputStream(imageBytes.length);
+                Thumbnails.of(inputStream)
+                        .scale(accuracy)
+                        .outputQuality(accuracy)
+                        .toOutputStream(outputStream);
+                imageBytes = outputStream.toByteArray();
+            }
+        } catch (Exception e) {
+        	log.error("图片指定大小压缩异常",e);
+        	throw new CustomException(InfoMsg.ERROR_UPLOAD_FIELD);
+        }
+        return imageBytes;
+    }
+ 
+    /**
+     * 自动调节精度(经验数值)
+     *
+     * @param size 源图片大小
+     * @return 图片压缩质量比
+     */
+    private static double getAccuracy(long size) {
+        double accuracy;
+        if (size < 900) {
+            accuracy = 0.85;
+        } else if (size < 2047) {
+            accuracy = 0.6;
+        } else if (size < 3275) {
+            accuracy = 0.44;
+        } else {
+            accuracy = 0.4;
+        }
+        return accuracy;
+    }
+    
+    /**
+     * 判断是否为允许的上传文件类型,true表示允许
+     */
+    public static boolean checkImage(String fileName) {
+        //设置允许上传文件类型
+        String suffixList = "jpg,gif,png,jpeg";
+        // 获取文件后缀
+        String suffix = fileName.substring(fileName.lastIndexOf(".")
+                + 1, fileName.length());
+        if (suffixList.contains(suffix.trim().toLowerCase())) {
+            return true;
+        }
+        return false;
+    }
+
+}

+ 431 - 0
src/main/java/com/wechat/common/utils/MailUtil.java

@@ -0,0 +1,431 @@
+package com.wechat.common.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.NoSuchProviderException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import com.sun.mail.util.MailSSLSocketFactory;
+import com.wechat.common.Constants;
+
+@Component
+public class MailUtil {
+	protected static Logger logger = LoggerFactory.getLogger(MailUtil.class);
+
+	@Value("#{configProperties['send_email_address']}")
+	private String sendEmailAddress;
+	
+	@Value("#{configProperties['send_email_password']}")
+	private String sendEmailPassword;
+	/**
+	 * 企业注册发送激活邮件
+	 * 
+	 * @param token
+	 *            加密token
+	 * @param userCode
+	 * @param recipientAddress
+	 * @return
+	 */
+	public  Boolean sendActivationMail(String token, String userCode, String recipientAddress) {
+		Transport transport = null;
+		Boolean flag = false;
+		try {
+			// 创建连接对象 连接到邮件服务器
+			Properties properties = new Properties();
+			// 设置用户的认证方式
+			properties.setProperty("mail.smtp.auth", "true");
+
+			// 设置传输协议
+			properties.setProperty("mail.transport.protocol", "smtp");
+
+			// 设置发件人的SMTP服务器地址
+			properties.setProperty("mail.smtp.host", "smtp.mxhichina.com");
+			// 开启ssl加密,如果没有ssl加密,会报530错误
+			MailSSLSocketFactory sf = new MailSSLSocketFactory();
+			sf.setTrustAllHosts(true);
+			properties.put("mail.smtp.ssl.enable", "true");
+			properties.put("mail.smtp.ssl.socketFactory", sf);
+			// 2、创建定义整个应用程序所需的环境信息的 Session 对象
+			Session session = Session.getInstance(properties);
+			// 设置调试信息在控制台打印出来
+			session.setDebug(false);
+			// 3、创建邮件的实例对象
+			Message msg = getMimeActivationMessage(session, sendEmailAddress, recipientAddress, token, userCode);
+			// 4、根据session对象获取邮件传输对象Transport
+			transport = session.getTransport();
+			// 设置发件人的账户名和密码
+			transport.connect(sendEmailAddress, sendEmailPassword);
+			// 发送邮件,并发送到所有收件人地址,message.getAllRecipients() 获取到的是在创建邮件对象时添加的所有收件人, 抄送人, 密送人
+			transport.sendMessage(msg, msg.getAllRecipients());
+			flag = true;
+		} catch (NoSuchProviderException e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} catch (MessagingException e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} catch (Exception e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} finally {
+			// 5、关闭邮件连接
+			if (transport != null) {
+				try {
+					transport.close();
+				} catch (MessagingException e) {
+					logger.error("企业注册邮件发送异常",e.getMessage());
+				}
+
+			}
+		}
+		return flag;
+	}
+
+	private static String domain = "";
+
+	public static void setDomain(String domain) {
+		MailUtil.domain = domain;
+	}
+
+	/**
+	 * 
+	 * @param session
+	 * @param senderAddress
+	 * @param recipientAddress
+	 * @param token
+	 * @param userCode
+	 * @return
+	 */
+	private static MimeMessage getMimeActivationMessage(Session session, String senderAddress,
+			String recipientAddress, String token, String userCode) {
+		// 创建一封邮件的实例对象
+		MimeMessage msg = null;
+		try {
+			msg = new MimeMessage(session);
+			// 设置发件人地址
+			msg.setFrom(new InternetAddress(senderAddress));
+			/**
+			 * 设置收件人地址(可以增加多个收件人、抄送、密送),即下面这一行代码书写多行 MimeMessage.RecipientType.TO:发送
+			 * MimeMessage.RecipientType.CC:抄送 MimeMessage.RecipientType.BCC:密送
+			 */
+			msg.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(recipientAddress));
+			// 设置邮件主题
+			msg.setSubject("门墩儿验证", "UTF-8");
+			// 设置邮件正文
+			// msg.setText("验证码" + text);
+			// msg.setContent("验证码" + text, "text/html;charset=UTF-8");
+
+			StringBuffer sb = new StringBuffer("<html><head></head><body><h1>这是一封激活邮件,激活请点击以下链接</h1><h3>");
+			sb.append("<a href=\"" + domain + "login/activation?userCode=");
+			sb.append(userCode);
+			sb.append("&activationToken=");
+			sb.append(token);
+			sb.append("\">点击链接激活");
+			sb.append("</a>");
+			sb.append("</h3></body></html>");
+			/*
+			 * String content =
+			 * "<html><head></head><body><h1>这是一封激活邮件,激活请点击以下链接</h1><h3><a href='http://192.168.1.118:8081/RecruitmentApi/login/activation?code="
+			 * + token + "'&userCode='" + userCode + "'>点击激活</a></h3></body></html>";
+			 */
+			msg.setContent(sb.toString(), "text/html;charset=UTF-8");
+			// 设置邮件的发送时间,默认立即发送
+			msg.setSentDate(new Date());
+		} catch (AddressException e) {
+			logger.error("邮件发送异常",e.getMessage());
+		} catch (MessagingException e) {
+			logger.error("邮件发送异常",e.getMessage());
+		}
+
+		return msg;
+	}
+
+	/**
+	 * 
+	 * @param content 邮件内容
+	 * @param recipientAddress 邮件地址
+	 * @return
+	 */
+	public  Boolean sendCodeMail(String content, String recipientAddress) {
+		Transport transport = null;
+		Boolean flag = false;
+		try {
+			// 创建连接对象 连接到邮件服务器
+			Properties properties = new Properties();
+			// 设置用户的认证方式
+			properties.setProperty("mail.smtp.auth", "true");
+
+			// 设置传输协议
+			properties.setProperty("mail.transport.protocol", "smtp");
+
+			// 设置发件人的SMTP服务器地址
+			properties.setProperty("mail.smtp.host", "smtp.mxhichina.com");
+			// 开启ssl加密,如果没有ssl加密,会报530错误
+			MailSSLSocketFactory sf = new MailSSLSocketFactory();
+			sf.setTrustAllHosts(true);
+			properties.put("mail.smtp.ssl.enable", "true");
+			properties.put("mail.smtp.ssl.socketFactory", sf);
+			// 2、创建定义整个应用程序所需的环境信息的 Session 对象
+			Session session = Session.getInstance(properties);
+			// 设置调试信息在控制台打印出来
+			session.setDebug(true);
+			// 3、创建邮件的实例对象
+			Message msg = getMimeCodeMessage(session,sendEmailAddress, recipientAddress, content);
+			// 4、根据session对象获取邮件传输对象Transport
+			transport = session.getTransport();
+			// 设置发件人的账户名和密码
+			transport.connect(sendEmailAddress, sendEmailPassword);
+			// 发送邮件,并发送到所有收件人地址,message.getAllRecipients() 获取到的是在创建邮件对象时添加的所有收件人, 抄送人, 密送人
+			transport.sendMessage(msg, msg.getAllRecipients());
+			flag = true;
+		} catch (NoSuchProviderException e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} catch (MessagingException e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} catch (Exception e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} finally {
+			// 5、关闭邮件连接
+			if (transport != null) {
+				try {
+					transport.close();
+				} catch (MessagingException e) {
+					logger.error(e.getMessage());
+				}
+
+			}
+		}
+		return flag;
+	}
+
+	/**
+	 * 
+	 * @param session
+	 * @param senderAddress
+	 *            发件地址
+	 * @param recipientAddress
+	 *            收件地址
+	 * @return
+	 * @throws Exception
+	 */
+	private  MimeMessage getMimeCodeMessage(Session session, String senderAddress, String recipientAddress,
+			String content) {
+		// 创建一封邮件的实例对象
+		MimeMessage msg = null;
+		try {
+			msg = new MimeMessage(session);
+			// 设置发件人地址
+			msg.setFrom(new InternetAddress(senderAddress));
+			/**
+			 * 设置收件人地址(可以增加多个收件人、抄送、密送),即下面这一行代码书写多行 MimeMessage.RecipientType.TO:发送
+			 * MimeMessage.RecipientType.CC:抄送 MimeMessage.RecipientType.BCC:密送
+			 */
+			msg.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(recipientAddress));
+			// 设置邮件主题
+			msg.setSubject("门墩儿-酒店职业发展社交平台", "UTF-8");
+			// 设置邮件正文
+			//msg.setText("验证码" + code);
+			msg.setContent(content, "text/html;charset=UTF-8");
+			// 设置邮件的发送时间,默认立即发送
+			msg.setSentDate(new Date());
+		} catch (AddressException e) {
+			logger.error("邮件验证码发送异常",e.getMessage());
+		} catch (MessagingException e) {
+			logger.error("邮件验证码发送异常",e.getMessage());
+		}
+
+		return msg;
+	}
+	public  Boolean sendMailNew(String recipientAddress, String mailContent,String subject) {
+		Transport transport = null;
+		Boolean flag = false;
+		try {
+			// 创建连接对象 连接到邮件服务器
+			Properties properties = new Properties();
+			// 设置用户的认证方式
+			properties.setProperty("mail.smtp.auth", "true");
+
+			// 设置传输协议
+			properties.setProperty("mail.transport.protocol", "smtp");
+
+			// 设置发件人的SMTP服务器地址
+			properties.setProperty("mail.smtp.host", "smtp.mxhichina.com");
+			// 开启ssl加密,如果没有ssl加密,会报530错误
+			MailSSLSocketFactory sf = new MailSSLSocketFactory();
+			sf.setTrustAllHosts(true);
+			properties.put("mail.smtp.ssl.enable", "true");
+			properties.put("mail.smtp.ssl.socketFactory", sf);
+			// 2、创建定义整个应用程序所需的环境信息的 Session 对象
+			Session session = Session.getInstance(properties);
+			// 设置调试信息在控制台打印出来
+			session.setDebug(false);
+			// 3、创建邮件的实例对象
+			Message msg = getMimeMessageNew(session, sendEmailAddress, recipientAddress, mailContent,subject);
+			// 4、根据session对象获取邮件传输对象Transport
+			transport = session.getTransport();
+			// 设置发件人的账户名和密码
+			transport.connect(sendEmailAddress, sendEmailPassword);
+			// 发送邮件,并发送到所有收件人地址,message.getAllRecipients() 获取到的是在创建邮件对象时添加的所有收件人, 抄送人, 密送人
+			transport.sendMessage(msg, msg.getAllRecipients());
+			flag = true;
+		} catch (NoSuchProviderException e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} catch (MessagingException e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} catch (Exception e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} finally {
+			// 5、关闭邮件连接
+			if (transport != null) {
+				try {
+					transport.close();
+				} catch (MessagingException e) {
+					logger.error("邮件发送异常",e.getMessage());
+				}
+
+			}
+		}
+		return flag;
+	}
+	
+	private  MimeMessage getMimeMessageNew(Session session, String senderAddress, String recipientAddress,
+			String mailContent,String subject) {
+		// 创建一封邮件的实例对象
+		MimeMessage msg = null;
+		try {
+			msg = new MimeMessage(session);
+			// 设置发件人地址
+			msg.setFrom(new InternetAddress(senderAddress));
+			/**
+			 * 设置收件人地址(可以增加多个收件人、抄送、密送),即下面这一行代码书写多行 MimeMessage.RecipientType.TO:发送
+			 * MimeMessage.RecipientType.CC:抄送 MimeMessage.RecipientType.BCC:密送
+			 */
+			//设置自定义发件人昵称  
+	        String nick="";  
+	        try {  
+	            nick=javax.mail.internet.MimeUtility.encodeText(Constants.EMAIL_NICK,"utf-8",null);  
+	        } catch (UnsupportedEncodingException e) {  
+	            e.printStackTrace();  
+	        } 
+			// 设置发件人地址
+			msg.setFrom(new InternetAddress(nick+" <"+sendEmailAddress+">"));
+			msg.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(recipientAddress));
+			// 设置邮件主题
+			msg.setSubject(subject, "UTF-8");
+			// 设置邮件正文
+			msg.setContent(mailContent, "text/html;charset=UTF-8");
+			// 设置邮件的发送时间,默认立即发送
+			msg.setSentDate(new Date());
+		} catch (AddressException e) {
+			logger.error(e.getMessage());
+		} catch (MessagingException e) {
+			logger.error(e.getMessage());
+		}
+
+		return msg;
+	}
+	
+	/**
+	 * 系统内部邮件通知
+	 * @param recipientAddress
+	 *            收件地址
+	 * @return
+	 * @throws Exception
+	 */
+	public  Boolean sendNoticeMail(String recipientAddress, String notice, String mailContent) {
+		Transport transport = null;
+		Boolean flag = false;
+		try {
+			// 创建连接对象 连接到邮件服务器
+			Properties properties = new Properties();
+			// 设置用户的认证方式
+			properties.setProperty("mail.smtp.auth", "true");
+
+			// 设置传输协议
+			properties.setProperty("mail.transport.protocol", "smtp");
+
+			// 设置发件人的SMTP服务器地址
+			properties.setProperty("mail.smtp.host", "smtp.mxhichina.com");
+			// 开启ssl加密,如果没有ssl加密,会报530错误
+			MailSSLSocketFactory sf = new MailSSLSocketFactory();
+			sf.setTrustAllHosts(true);
+			properties.put("mail.smtp.ssl.enable", "true");
+			properties.put("mail.smtp.ssl.socketFactory", sf);
+			// 2、创建定义整个应用程序所需的环境信息的 Session 对象
+			Session session = Session.getInstance(properties);
+			// 设置调试信息在控制台打印出来
+			session.setDebug(true);
+			// 3、创建邮件的实例对象
+			MimeMessage msg = new MimeMessage(session);
+			//设置自定义发件人昵称  
+	        String nick="";  
+	        try {
+	        	nick=javax.mail.internet.MimeUtility.encodeText(Constants.EMAIL_NICK,"utf-8",null);
+	        } catch (UnsupportedEncodingException e) {  
+	            e.printStackTrace();  
+	        } 
+			// 设置发件人地址
+			msg.setFrom(new InternetAddress(nick+" <"+sendEmailAddress+">"));
+			/**
+			 * 设置收件人地址(可以增加多个收件人、抄送、密送),即下面这一行代码书写多行 MimeMessage.RecipientType.TO:发送
+			 * MimeMessage.RecipientType.CC:抄送 MimeMessage.RecipientType.BCC:密送
+			 */
+			Address[] internetAddressTo = (new InternetAddress()).parse(recipientAddress);
+			msg.setRecipients(MimeMessage.RecipientType.TO, internetAddressTo);
+			// 设置邮件主题
+			msg.setSubject("门墩儿系统通知-"+notice, "UTF-8");
+			// 设置邮件正文
+			msg.setContent(mailContent, "text/html;charset=UTF-8");
+			// 设置邮件的发送时间,默认立即发送
+			msg.setSentDate(new Date());
+			// 4、根据session对象获取邮件传输对象Transport
+			transport = session.getTransport();
+			// 设置发件人的账户名和密码
+			transport.connect(sendEmailAddress, sendEmailPassword);
+			// 发送邮件,并发送到所有收件人地址,message.getAllRecipients() 获取到的是在创建邮件对象时添加的所有收件人, 抄送人, 密送人
+			transport.sendMessage(msg, msg.getAllRecipients());
+			flag = true;
+		} catch (NoSuchProviderException e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} catch (MessagingException e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} catch (Exception e) {
+			flag = false;
+			logger.error(e.getMessage());
+		} finally {
+			// 5、关闭邮件连接
+			if (transport != null) {
+				try {
+					transport.close();
+				} catch (MessagingException e) {
+					logger.error("邮件发送异常",e.getMessage());
+				}
+
+			}
+		}
+		return flag;
+	}
+	
+}

+ 88 - 0
src/main/java/com/wechat/common/utils/Md5Utils.java

@@ -0,0 +1,88 @@
+package com.wechat.common.utils;
+
+import java.security.MessageDigest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.wechat.common.Constants;
+import com.wechat.global.CustomException;
+import com.wechat.global.message.InfoMsg;
+
+/**
+ * 加密工具类
+ * 
+ * @author jil
+ *
+ */
+public class Md5Utils {
+	protected static Logger logger = LoggerFactory.getLogger(Md5Utils.class);
+	
+	/**
+	 * 生成md5  密码m+固定字符串 加密
+	 * @param message
+	 * @return
+	 */
+	public static String EncoderByMd5(String str,String key) {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(str);
+		// 混淆用的加密key
+		if(!StringsUtils.isEmpty(key))
+		{
+			buffer.append(key);
+		}
+		
+		String md5str = "";
+		try {
+			// 1 创建一个提供信息摘要算法的对象,初始化为md5算法对象
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			// 2 将消息变成byte数组
+			byte[] input = buffer.toString().getBytes();
+
+			// 3 计算后获得字节数组,这就是那128位了
+			byte[] buff = md.digest(input);
+
+			// 4 把数组每一字节(一个字节占八位)换成16进制连成md5字符串
+			md5str = bytesToHex(buff);
+
+		} catch (Exception e) {
+			logger.error("md5加密错误",e.getMessage());
+			throw new CustomException(InfoMsg.ERROR_MD5ENCRYPT_ERROR);
+		}
+		return md5str;
+	}
+	
+	/**
+	 * 生成md5  密码m+固定字符串 加密
+	 * @param message
+	 * @return
+	 */
+	public static String EncoderPassword(String password) {
+		return EncoderByMd5(password,Constants.MD5_PASSWORD);
+	}
+
+	/**
+	 * 二进制转十六进制
+	 * 
+	 * @param bytes
+	 * @return
+	 */
+	public static String bytesToHex(byte[] bytes) {
+		StringBuffer md5str = new StringBuffer();
+		// 把数组每一字节换成16进制连成md5字符串
+		int digital;
+		for (int i = 0; i < bytes.length; i++) {
+			digital = bytes[i];
+
+			if (digital < 0) {
+				digital += 256;
+			}
+			if (digital < 16) {
+				md5str.append("0");
+			}
+			md5str.append(Integer.toHexString(digital));
+		}
+		return md5str.toString().toUpperCase();
+	}
+}

+ 153 - 0
src/main/java/com/wechat/common/utils/MessageUtils.java

@@ -0,0 +1,153 @@
+package com.wechat.common.utils;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.wechat.common.Constants;
+
+public class MessageUtils extends BaseUtils {
+
+    /**
+     * message cache
+     */
+    public static Map<String, String> messageMap = new HashMap<String, String>();
+
+
+    /**
+     * Message 格式化工具
+     */
+    final static MessageFormat FORMAT = new MessageFormat("");
+
+
+    /**
+     * 单一参数的Message
+     * 
+     * @param mes message mes
+     * @param arg0 参数1
+     * @return Message内容
+     */
+    public static String getText(String mes, String arg0) {
+        FORMAT.applyPattern(mes);
+        return FORMAT.format(new String[] { arg0 });
+    }
+
+    /**
+     * 两个参数的Message
+     * 
+     * @param mes message mes
+     * @param arg0 参数1
+     * @param arg1 参数2
+     * @return Message内容
+     */
+    public static String getText(String mes, String arg0, String arg1) {
+        FORMAT.applyPattern(mes);
+        return FORMAT.format(new String[] { arg0, arg1 });
+    }
+
+    /**
+     * 三个参数的Message
+     * 
+     * @param mes message mes
+     * @param arg0 参数1
+     * @param arg1 参数2
+     * @param arg2 参数3
+     * @return Message内容
+     */
+    public static String getText(String mes, String arg0, String arg1, String arg2) {
+        FORMAT.applyPattern(mes);
+        return FORMAT.format(new String[] { arg0, arg1, arg2 });
+    }
+
+    /**
+     * 四个参数的Message
+     * 
+     * @param mes message mes
+     * @param arg0 参数1
+     * @param arg1 参数2
+     * @param arg2 参数3
+     * @param arg3 参数4
+     * @return Message内容
+     */
+    public static String getText(String mes, String arg0, String arg1, String arg2, String arg3) {
+        FORMAT.applyPattern(mes);
+        return FORMAT.format(new String[] { arg0, arg1, arg2, arg3 });
+    }
+
+    /**
+     * 五个参数的Message
+     * 
+     * @param mes message mes
+     * @param arg0 参数1
+     * @param arg1 参数2
+     * @param arg2 参数3
+     * @param arg3 参数4
+     * @param arg4 参数5
+     * @return Message内容
+     */
+    public static String getText(String mes, String arg0, String arg1, String arg2, String arg3, String arg4) {
+        FORMAT.applyPattern(mes);
+        return FORMAT.format(new String[] { arg0, arg1, arg2, arg3, arg4 });
+    }
+    
+    /**
+     * 六个参数的Message
+     * 
+     * @param mes message mes
+     * @param arg0 参数1
+     * @param arg1 参数2
+     * @param arg2 参数3
+     * @param arg3 参数4
+     * @param arg4 参数5
+     * @return Message内容
+     */
+    public static String getText(String mes, String arg0, String arg1, String arg2, String arg3, String arg4, String arg5) {
+        FORMAT.applyPattern(mes);
+        return FORMAT.format(new String[] { arg0, arg1, arg2, arg3, arg4, arg5 });
+    }
+
+    /**
+     * 多个参数的Message
+     * 
+     * @param mes message mes
+     * @param arg0 参数数组
+     * @return Message内容
+     */
+    public static String getText(String mes, String[] arg0) {
+        if (arg0 == null || arg0.length == 0) {
+            return mes;
+        } else {
+            FORMAT.applyPattern(mes);
+            return FORMAT.format(arg0);
+        }
+    }
+    
+    /**
+     * 三个参数的url
+     * 
+     * @param mes message mes
+     * @param linkUrl
+     * @param Str 
+     * @param Content
+     * @return url内容
+     */
+    public static String getHyperLink(String linkUrl, String Str, String Content) {
+        String result =Constants.URL_BEGIN + linkUrl + Str + Constants.URL_MIDDLE + Content + Constants.URL_END;
+        return result;
+    }
+    
+    /**
+     * 三个参数的url 不换行
+     * 
+     * @param mes message mes
+     * @param linkUrl
+     * @param Str 
+     * @param Content
+     * @return url内容
+     */
+    public static String getHyperLinkNoNewline(String linkUrl, String Str, String Content) {
+        String result =Constants.URL_BEGIN_NOBR + linkUrl + Str + Constants.URL_MIDDLE + Content + Constants.URL_END_NOBR;
+        return result;
+    }
+
+}

+ 167 - 0
src/main/java/com/wechat/common/utils/MvcUtil.java

@@ -0,0 +1,167 @@
+package com.wechat.common.utils;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.FieldError;
+import org.springframework.validation.ObjectError;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.wechat.common.utils.view.JSONView;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+/**
+ * springMVC返回值工具类
+ * 
+
+ */
+@SuppressWarnings("all")
+public class MvcUtil {
+	private static final JSONView jsonLibView = new JSONView();
+	private static final SimpleDateFormat FORMAT_DATE = new SimpleDateFormat(
+			"yyyy-MM-dd");
+	private static final SimpleDateFormat FORMAT_TIME = new SimpleDateFormat(
+			"hh:mm:ss");
+	private static final SimpleDateFormat FORMAT_TIMESTAMP = new SimpleDateFormat(
+			"yyyy-MM-dd hh:mm:ss");
+
+	public MvcUtil() {
+	}
+
+	public static ModelAndView jsonObjectModelAndView(JSONObject jsonObject) {
+		return new ModelAndView(jsonLibView, "jsonObject", jsonObject);
+	}
+
+	public static ModelAndView jsonArrayModelAndView(JSONArray jsonArray) {
+		return new ModelAndView(jsonLibView, "jsonArray", jsonArray);
+	}
+
+	public static boolean checkBindingResult(BindingResult bindingResult,
+			JSONObject returnObject) {
+		if (bindingResult.hasErrors()) {
+			if (bindingResult.hasFieldErrors()) {
+				List list = bindingResult.getFieldErrors();
+				JSONObject errors = new JSONObject();
+				for (int i = 0; i < list.size(); i++) {
+					FieldError fieldError = (FieldError) list.get(i);
+					errors.element(fieldError.getField(), fieldError
+							.getRejectedValue().toString());
+				}
+
+				returnObject.element("errors", errors);
+			}
+			if (bindingResult.hasGlobalErrors()) {
+				List list = bindingResult.getGlobalErrors();
+				String errorMessage = "";
+				for (int i = 0; i < list.size(); i++) {
+					ObjectError fieldError = (ObjectError) list.get(i);
+					if (i > 0)
+						errorMessage = (new StringBuilder(String
+								.valueOf(errorMessage))).append("; ")
+								.toString();
+					errorMessage = (new StringBuilder(String
+							.valueOf(errorMessage))).append(
+							fieldError.getDefaultMessage()).toString();
+				}
+
+				returnObject.element("errorMessage", errorMessage);
+			}
+			return false;
+		} else {
+			return true;
+		}
+	}
+
+	public static void main(String[] args) {
+		Object obj=(Object)"120";
+		System.out.println(toJsonString(obj));
+	}
+	public static String toJsonString(Object obj) {
+		if (obj != null){
+			if(obj instanceof Double ||obj instanceof BigDecimal){
+				DecimalFormat df = new DecimalFormat("#0.00");
+				return df.format(Double.parseDouble(obj.toString()));
+			}else{
+				return obj.toString();
+			}
+		}
+			
+		else
+			return null;
+	}
+
+	public String toJsonString(Date obj) {
+		if (obj != null)
+			return FORMAT_DATE.format(obj);
+		else
+			return null;
+	}
+
+	public String toJsonString(Time obj) {
+		if (obj != null)
+			return FORMAT_TIME.format(obj);
+		else
+			return null;
+	}
+
+	public static String toJsonString(Timestamp obj) {
+		if (obj != null)
+			return FORMAT_TIMESTAMP.format(obj);
+		else
+			return null;
+	}
+
+	public static Long parseLong(HttpServletRequest request, String paramName) {
+		Long result = null;
+		String s = request.getParameter(paramName);
+		if (s != null && !"".equals(s))
+			result = Long.valueOf(Long.parseLong(s));
+		return result;
+	}
+
+	public static String toBigString(Object obj) {
+		if (obj != null)
+			return obj.toString();
+		else
+			return "0.00";
+	}
+
+	public static String toBigString2(Object obj) {
+		if (obj != null && !"".equals(obj.toString()))
+			return new BigDecimal(obj.toString()).setScale(2, RoundingMode.HALF_UP).toString();
+		else
+			return "";
+	}
+	
+	public static void writeJson(HttpServletRequest request, HttpServletResponse response, String json)
+			throws IOException {
+		response.setContentType("text/html;charset=utf-8");
+		String clientOrigin = request.getHeader("origin");
+		PrintWriter out = response.getWriter();
+		response.setHeader("Cache-control", "no-cache, no-store");
+		response.setHeader("Pragma", "no-cache");
+		response.setHeader("Expires", "-1");
+		response.setHeader("Access-Control-Allow-Methods", "POST");
+		response.setHeader("Access-Control-Allow-Origin", clientOrigin);
+		response.setHeader("Access-Control-Allow-Headers", "Content-Type");
+		response.setHeader("Access-Control-Max-Age", "86400");
+
+		out.println(json);
+		out.close();
+	}
+	
+}

+ 295 - 0
src/main/java/com/wechat/common/utils/NetworkUtils.java

@@ -0,0 +1,295 @@
+package com.wechat.common.utils;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.Charset;
+
+import net.sf.json.JSONObject;
+
+public class NetworkUtils extends BaseUtils{
+
+    /**
+     * 通过HTTP Post请求外部数据
+     * @param url 要访问的地址
+     * @param request 发送的数据, 会被转换成json字符串
+     * @param classofResp 返回数据类的类型
+     * @param <T> 返回数据类
+     * @return 将远端返回的Json字串解析为对象,类型为T
+     */
+    public static <T> T getRemoteResponseAsJson(String url, Object request, Class<T> classofResp) {
+        String payload = JacksonUtils.bean2json(request);
+        try {
+            URL obj = new URL(url);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+            //add reuqest header
+            con.setRequestMethod("POST");
+            con.setRequestProperty("Content-Type", "application/json");
+            con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3");
+
+            // Send post request
+            con.setDoOutput(true);
+            PrintWriter wr = new PrintWriter(new OutputStreamWriter(
+            		con.getOutputStream(), "UTF-8"));
+            wr.write(payload);
+            wr.flush();
+            wr.close();
+
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader(con.getInputStream(), Charset.forName("UTF-8")));
+            String inputLine;
+            StringBuffer response = new StringBuffer();
+
+            while ((inputLine = in.readLine()) != null) {
+                response.append(inputLine);
+            }
+            in.close();
+            log.debug("Get response: " + response.toString());
+            return JacksonUtils.deserialize(response.toString(), classofResp);
+            
+        } catch (Exception ex) {
+            log.error("Network error.", ex);
+            return null;
+        }
+    }
+
+    /**
+     * 通过HTTP Post请求外部数据
+     * @param url 要访问的地址
+     * @param request 发送的数据, 会被转换成json字符串
+     * @param classofResp 返回数据类的类型
+     * @return 将远端返回的Json字串解析为对象,类型为T
+     */
+    public static String getResponseAsApp(String url, Object request) {
+        String payload = JacksonUtils.bean2json(request);
+        try {
+        	
+            URL obj = new URL(url);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+            //add reuqest header
+            con.setRequestMethod("POST");
+            con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+            con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3");
+
+            // Send post request
+            con.setDoOutput(true);
+            PrintWriter wr = new PrintWriter(new OutputStreamWriter(
+            		con.getOutputStream(), "UTF-8"));
+            wr.write(payload);
+            wr.flush();
+            wr.close();
+
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader(con.getInputStream(), Charset.forName("UTF-8")));
+            String inputLine;
+            StringBuffer response = new StringBuffer();
+
+            while ((inputLine = in.readLine()) != null) {
+                response.append(inputLine);
+            }
+            in.close();
+            log.debug("Get response: " + response.toString());
+            return response.toString();
+            
+        } catch (Exception ex) {
+            log.error("Network error.", ex);
+            return null;
+        }
+    }
+    
+    
+    /**
+     * 通过HTTP Post请求外部数据
+     * @param url 要访问的地址
+     * @param request 发送的数据, 会被转换成json字符串
+     * @param classofResp 返回数据类的类型
+     * @return 将远端返回的Json字串解析为对象,类型为T
+     */
+    public static String getRemoteResponseAsJson(String url, Object request) {
+        String payload = JacksonUtils.bean2json(request);
+        try {
+            URL obj = new URL(url);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+            //add reuqest header
+            con.setRequestMethod("POST");
+            con.setRequestProperty("Content-Type", "application/json");
+            con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3");
+
+            // Send post request
+            con.setDoOutput(true);
+            PrintWriter wr = new PrintWriter(new OutputStreamWriter(
+            		con.getOutputStream(), "UTF-8"));
+            wr.write(payload);
+            wr.flush();
+            wr.close();
+
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader(con.getInputStream(), Charset.forName("UTF-8")));
+            String inputLine;
+            StringBuffer response = new StringBuffer();
+
+            while ((inputLine = in.readLine()) != null) {
+                response.append(inputLine);
+            }
+            in.close();
+            log.debug("Get response: " + response.toString());
+            return response.toString();
+            
+        } catch (Exception ex) {
+            log.error("Network error.", ex);
+            return null;
+        }
+    }
+    
+    public static <T> T getRemoteResponseAsJsonWithStringPayload(String url, String req, Class<T> classofResp){
+        String payload = req;
+        try {
+            URL obj = new URL(url);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+            //add reuqest header
+            con.setRequestMethod("POST");
+            con.setRequestProperty("Content-Type", "application/json");
+            con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3");
+
+            // Send post request
+            con.setDoOutput(true);
+            PrintWriter wr = new PrintWriter(new OutputStreamWriter(
+            		con.getOutputStream(), "UTF-8"));
+            wr.write(payload);
+            wr.flush();
+            wr.close();
+
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader(con.getInputStream(), Charset.forName("UTF-8")));
+            String inputLine;
+            StringBuffer response = new StringBuffer();
+
+            while ((inputLine = in.readLine()) != null) {
+                response.append(inputLine);
+            }
+            in.close();
+            log.debug("Get response: " + response.toString());
+            return JacksonUtils.deserialize(response.toString(), classofResp);
+
+        } catch (Exception ex) {
+            log.error("Network error.", ex);
+            return null;
+        }
+    }
+    
+    
+    /**
+     * 通过HTTP Get请求外部数据,以JSON格式直接返回
+     * @param url 要访问的地址
+     * @param request 发送的数据, 会被转换成JSON字符串
+     * @param 以JSON格式直接返回
+     * @return 将远端返回的JSON字串
+     */
+    public static JSONObject getRemoteResponseAsJson(String url) {
+        try {
+            URL obj = new URL(url);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+            //add reuqest header
+            con.setRequestMethod("GET");
+            con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3");
+
+            // Send post request
+            con.setDoOutput(true);
+
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader(con.getInputStream(), Charset.forName("UTF-8")));
+            String inputLine;
+            StringBuffer response = new StringBuffer();
+            while ((inputLine = in.readLine()) != null) {
+                response.append(inputLine);
+            }
+            in.close();
+            log.debug("Get response: " + response.toString());
+            return JacksonUtils.StringTOJson(response.toString());
+            
+        } catch (Exception ex) {
+            log.error("Network error.", ex);
+            return null;
+        }
+    }
+    
+    /**
+       * 通过HTTP Get请求外部数据,以JSON格式直接返回
+     * @param url 要访问的地址
+     * @param classofResp需要格式化的目标类型
+     * @return 将远端返回的JSON格式化后输出
+     */
+    public static <T> T getRemoteResponseAsClass(String url, Class<T> classofResp) {
+        try {
+            URL obj = new URL(url);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+            //add reuqest header
+            con.setRequestMethod("GET");
+			con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3");
+
+            // Send post request
+            con.setDoOutput(true);
+
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader(con.getInputStream(), Charset.forName("UTF-8")));
+            String inputLine;
+            StringBuffer response = new StringBuffer();
+
+            while ((inputLine = in.readLine()) != null) {
+                response.append(inputLine);
+            }
+            in.close();
+            log.debug("Get response: " + response.toString());
+            return JacksonUtils.deserialize(response.toString(), classofResp);
+            
+        } catch (Exception ex) {
+            log.error("Network error.", ex);
+            return null;
+        }
+    }
+
+
+    /**
+     * 通过HTTP Get请求外部数据,以JSON格式直接返回
+   * @param url 要访问的地址
+   * @param classofResp需要格式化的目标类型
+   * @return 将远端返回的JSON格式化后输出
+   */
+/*    public static <T> T getRemoteResponseAsJsonMethodGET(String url, Class<T> classofResp){
+        try {
+            URL obj = new URL(url);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+            //add reuqest header
+            con.setRequestMethod("GET");
+            con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3");
+
+            con.setDoOutput(false);
+            con.setDoInput(true);
+
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader(con.getInputStream(), Charset.forName("UTF-8")));
+            String inputLine;
+            StringBuffer response = new StringBuffer();
+
+            while ((inputLine = in.readLine()) != null) {
+                response.append(inputLine);
+            }
+            in.close();
+            log.debug("Get response: " + response.toString());
+            return JacksonUtils.deserialize(response.toString(), classofResp);
+
+        } catch (Exception ex) {
+            log.error("Network error.", ex);
+            return null;
+        }
+    }*/
+}

+ 285 - 0
src/main/java/com/wechat/common/utils/NumberUtils.java

@@ -0,0 +1,285 @@
+package com.wechat.common.utils;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+
+public class NumberUtils extends BaseUtils {
+    /**
+     * 将字符串转换为数字
+     * 
+     * @param str 字符串
+     * @param min 是否设置成最大值。 如果为false, 当转换异常时返回int的最大值
+     * @return 转换后的数字
+     */
+    public static int stringToInt(String str, boolean min) {
+        int result = 0;
+        try {
+            result = Integer.parseInt(str);
+        } catch (Exception e) {
+            if (!min) {
+                result = Integer.MAX_VALUE;
+            }
+        }
+        return result;
+    }
+    
+    /**
+     * 将字符串转换为int
+     * 
+     * @param str
+     * @param min
+     * @return
+     */
+    public static int stringToInt(String str, int defult) {
+    	int result = 0;
+        try {
+            result = Integer.parseInt(str);
+        } catch (Exception e) {
+           	result = defult;
+        }
+        return result;
+    }
+
+    /**
+     * Integer 转换成Short
+     * 
+     * @param intValue
+     * @return
+     */
+    public static Short intToShort(Integer intValue) {
+        //TODO bug fix
+        if (null == intValue) {
+            return null;
+        }
+        return Short.valueOf(String.valueOf(intValue));
+    }
+
+    /**
+     * 将字符串转换为long
+     * 
+     * @param str
+     * @param min
+     * @return
+     */
+    public static long stringToLong(String str, boolean min) {
+        long result = 0;
+        try {
+            result = Long.parseLong(str);
+        } catch (Exception e) {
+            if (!min) {
+                result = Long.MAX_VALUE;
+            }
+        }
+        return result;
+    }
+    
+    /**
+     * 将字符串转换为long
+     * 
+     * @param str
+     * @param min
+     * @return
+     */
+    public static long stringToLong(String str, long defult) {
+    	long result = 0;
+        try {
+            result = Long.parseLong(str);
+        } catch (Exception e) {
+           	result = defult;
+        }
+        return result;
+    }
+
+    /**
+     * Integer 转换成long
+     * 
+     * @param intValue
+     * @return
+     */
+    public static long intTolong(Integer intValue) {
+        //TODO bug fix
+        if (null == intValue) {
+            return 0;
+        }
+        return Long.valueOf(String.valueOf(intValue));
+    }
+
+    /**
+     * 将字符串转换为Short
+     * 
+     * @param str
+     * @param min
+     * @return
+     */
+    public static Short stringToShort(String str, boolean min) {
+        Short result = 0;
+        try {
+            result = Short.parseShort(str);
+        } catch (Exception e) {
+            if (!min) {
+                result = Short.MAX_VALUE;
+            }
+        }
+        return result;
+    }
+    
+    /**
+     * 将字符串转换为Short
+     * 
+     * @param str
+     * @param min
+     * @return
+     */
+    public static Short stringToShort(String str, Short defult) {
+        Short result = 0;
+        try {
+            result = Short.parseShort(str);
+        } catch (Exception e) {
+           	result = defult;
+        }
+        return result;
+    }
+    
+    /**
+     * 将字符串转换为Bety
+     * 
+     * @param str
+     * @param min
+     * @return
+     */
+    public static Byte stringToByte(String str, boolean min) {
+    	Byte result = 0;
+        try {
+            result = Byte.parseByte(str);
+        } catch (Exception e) {
+            if (!min) {
+                result = Byte.MAX_VALUE;
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Short 比较大小
+     * 
+     * @param s1 参数
+     * @param s2 参数
+     * @return 比较结果
+     */
+    public static int compareShort(Short s1, Short s2) {
+        if (s1 == null) {
+            s1 = 0;
+        }
+        if (s2 == null) {
+            s2 = 0;
+        }
+        return s1.compareTo(s2);
+    }
+    
+    /**
+     * Long转String
+     * @param longVal
+     * @return
+     */
+    public static String longToString(Long longVal){
+        if(longVal == null){
+            return null;
+        }else{
+            return Long.toString(longVal);
+        }
+    }
+    
+    /**
+     * string 转BigDecimal
+     * @param str
+     * @return
+     */
+    public static BigDecimal stringToBigDecimal(String str){
+        BigDecimal result = new BigDecimal(0);
+        try {
+            result = new BigDecimal(str);
+        } catch (Exception e) {
+            
+        }
+        return result;
+    }
+    
+    /**
+     * 保留小数(位数由传入参数决定)
+     * @param str 传入参数
+     * @param digital 保留几位小数
+     * @return 
+     */
+    public static String stringToHalfUp(String str, int digital) {
+        BigDecimal b = stringToBigDecimal(str);
+        if (b == null) {
+            return null;
+        }
+        return b.setScale(digital, RoundingMode.HALF_UP).toString();
+    }
+    
+    public static String stringToConUnit(String str) {
+        BigDecimal b = stringToBigDecimal(str);
+        if (b == null) {
+            return null;
+        }
+        if (b.compareTo(new BigDecimal(10000)) < 0) {
+            // 小于10000的时候没有单位
+            return b.toString();
+        } else if (b.compareTo(new BigDecimal(100000000)) >= 0) {
+            // 大于1亿
+            return null;
+        } else if (b.compareTo(new BigDecimal(10000)) >= 0 && b.compareTo(new BigDecimal(100000000)) < 0) {
+            // 大于1万,小于1亿
+            return null;
+        } else {
+            return null;
+        }
+    }
+    
+    /**
+     * Decimal 类型判空
+     * @param longVal
+     * @return
+     */
+    public static boolean isEmpty(BigDecimal val){
+        if(val == null){
+            return true;
+        }
+        if(val.compareTo(new BigDecimal(0)) == 0)
+        {
+            return true;
+        }
+        return false;
+    }
+    
+    /**
+     * 当数据类型属于BigDecimal时,转化操作
+     * 
+     * @param bd
+     * @return
+     */
+    public static BigDecimal formatBigDecimal(String bd) {
+
+        BigDecimal temp = BigDecimal.ZERO;
+
+        // 传值为空时
+        if (StringsUtils.isEmpty(bd)) {
+            return temp;
+        }
+        else {
+            bd = bd.trim();
+        }
+
+        if (bd.startsWith(".")) {
+            bd = "0" + bd;
+        }
+
+        if (StringsUtils.isBigDecimal(bd)) {
+            temp = new BigDecimal(bd);
+        }
+
+        return temp;
+    }
+}

+ 378 - 0
src/main/java/com/wechat/common/utils/RSAUtils.java

@@ -0,0 +1,378 @@
+package com.wechat.common.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.math.BigInteger;
+import java.security.InvalidParameterException;
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.security.SecureRandom;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.RSAPrivateKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.crypto.Cipher;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateFormatUtils;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+public abstract class RSAUtils extends BaseUtils {
+    
+    /** 算法名称 */
+    private static final String ALGORITHOM = "RSA";
+    /**保存生成的密钥对的文件名称。 */
+    private static final String RSA_PAIR_FILENAME = "/__RSA_PAIR.txt";
+    /** 密钥大小 */
+    private static final int KEY_SIZE = 1024;
+    /** 默认的安全服务提供者 */
+    private static final Provider DEFAULT_PROVIDER = new BouncyCastleProvider();
+ 
+    private static KeyPairGenerator keyPairGen = null;
+    private static KeyFactory keyFactory = null;
+    /** 缓存的密钥对。 */
+    private static KeyPair oneKeyPair = null;
+    
+    /** 密钥对系数和专用指数。 */
+    private static Map<String,String> modulusAndExponent = new HashMap<String, String>();
+ 
+    private static File rsaPairFile = null;
+ 
+    static {
+        try {
+            keyPairGen = KeyPairGenerator.getInstance(ALGORITHOM, DEFAULT_PROVIDER);
+            keyFactory = KeyFactory.getInstance(ALGORITHOM, DEFAULT_PROVIDER);
+        } catch (NoSuchAlgorithmException ex) {
+            log.error(ex.getMessage());
+        }
+        rsaPairFile = new File(getRSAPairFilePath());
+    }
+ 
+    private RSAUtils() {  
+    }
+    
+    /**
+     * 生成并返回RSA密钥对。
+     */
+    private static synchronized KeyPair generateKeyPair() {
+        try {
+            //当前时间(毫秒)+ 5位随机数生成 密匙
+            keyPairGen.initialize(KEY_SIZE, new SecureRandom((DateFormatUtils.format(new Date(),"yyyyMMddHHmmssSSS")+ com.wechat.common.utils.StringsUtils.getRandomNum(5)).getBytes()));
+            oneKeyPair = keyPairGen.generateKeyPair();
+            saveKeyPair(oneKeyPair);
+            return oneKeyPair;
+        } catch (InvalidParameterException ex) {
+            log.error("KeyPairGenerator does not support a key length of " + KEY_SIZE + ".", ex);
+        } catch (NullPointerException ex) {
+            log.error("RSAUtils#KEY_PAIR_GEN is null, can not generate KeyPairGenerator instance.",
+                    ex);
+        }
+        return null;
+    }
+    
+    /**
+     * bigInt转16进制。
+     */
+    private static String bigInt2Hex(BigInteger bi) {
+        return AESUtil.parseByte2HexStr(bi.toByteArray());
+    }
+    
+    /**
+     * 生成并返回RSA密钥对的系数和专用指数。
+     *      * 
+     * @param modulus 系数。
+     * @param publicExponent 专用指数。
+     */
+    public static synchronized Map<String, String> generateKeyPairModulusExponent() {
+        try {
+            //当前时间(毫秒)+ 5位随机数生成 密匙
+            keyPairGen.initialize(KEY_SIZE, new SecureRandom((DateFormatUtils.format(new Date(),"yyyyMMddHHmmssSSS")+ com.wechat.common.utils.StringsUtils.getRandomNum(5)).getBytes()));
+            oneKeyPair = keyPairGen.generateKeyPair();
+            modulusAndExponent.put("pubM",bigInt2Hex(((RSAPublicKey)oneKeyPair.getPublic()).getModulus()));
+            modulusAndExponent.put("pubE",bigInt2Hex(((RSAPublicKey)oneKeyPair.getPublic()).getPublicExponent()));
+            modulusAndExponent.put("priM",bigInt2Hex(((RSAPrivateKey)oneKeyPair.getPrivate()).getModulus()));
+            modulusAndExponent.put("priE",bigInt2Hex(((RSAPrivateKey)oneKeyPair.getPrivate()).getPrivateExponent()));
+            return modulusAndExponent;
+        } catch (InvalidParameterException ex) {
+            log.error("KeyPairGenerator does not support a key length of " + KEY_SIZE + ".", ex);
+        } catch (NullPointerException ex) {
+            log.error("RSAUtils#KEY_PAIR_GEN is null, can not generate KeyPairGenerator instance.",
+                    ex);
+        }
+        return null;
+    }
+    
+    
+    
+    
+    /**
+     * 返回生成/读取的密钥对文件的路径。
+     */
+    private static String getRSAPairFilePath() {
+        String urlPath = RSAUtils.class.getResource("/").getPath();
+        return (new File(urlPath).getParent() + RSA_PAIR_FILENAME);
+    }
+    
+    /**
+     * 将指定的RSA密钥对以文件形式保存。
+     * 
+     * @param keyPair 要保存的密钥对。
+     */
+    private static void saveKeyPair(KeyPair keyPair) {
+        FileOutputStream fos = null;
+        ObjectOutputStream oos = null;
+        try {
+            fos = FileUtils.openOutputStream(rsaPairFile);
+            oos = new ObjectOutputStream(fos);
+            oos.writeObject(keyPair);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            IOUtils.closeQuietly(oos);
+            IOUtils.closeQuietly(fos);
+        }
+    }
+ 
+    /**
+     * 返回RSA密钥对。
+     */
+    public static KeyPair getKeyPair(boolean isCreateKeyPair) {
+        // 首先判断是否需要重新生成新的密钥对文件
+        if (isCreateKeyPair) {
+            // 直接强制生成密钥对文件,并存入缓存。
+            return generateKeyPair();
+        }
+        if (oneKeyPair != null) {
+            return oneKeyPair;
+        }
+        return readKeyPair();
+    }
+     
+    // 同步读出保存的密钥对
+    private static KeyPair readKeyPair() {
+        FileInputStream fis = null;
+        ObjectInputStream ois = null;
+        try {
+            fis = FileUtils.openInputStream(rsaPairFile);
+            ois = new ObjectInputStream(fis);
+            oneKeyPair = (KeyPair) ois.readObject();
+            return oneKeyPair;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            IOUtils.closeQuietly(ois);
+            IOUtils.closeQuietly(fis);
+        }
+        return null;
+    }
+ 
+    /**
+     * 根据给定的系数和专用指数构造一个RSA专用的公钥对象。
+     * 
+     * @param modulus 系数。
+     * @param publicExponent 专用指数。
+     * @return RSA专用公钥对象。
+     */
+    public static RSAPublicKey generateRSAPublicKey(byte[] modulus, byte[] publicExponent) {
+        RSAPublicKeySpec publicKeySpec = new RSAPublicKeySpec(new BigInteger(modulus),
+                new BigInteger(publicExponent));
+        try {
+            return (RSAPublicKey) keyFactory.generatePublic(publicKeySpec);
+        } catch (InvalidKeySpecException ex) {
+            log.error("RSAPublicKeySpec is unavailable.", ex);
+        } catch (NullPointerException ex) {
+            log.error("RSAUtils#KEY_FACTORY is null, can not generate KeyFactory instance.", ex);
+        }
+        return null;
+    }
+ 
+    /**
+     * 根据给定的系数和专用指数构造一个RSA专用的私钥对象。
+     * 
+     * @param modulus 系数。
+     * @param privateExponent 专用指数。
+     * @return RSA专用私钥对象。
+     */
+    public static RSAPrivateKey generateRSAPrivateKey(byte[] modulus, byte[] privateExponent) {
+        RSAPrivateKeySpec privateKeySpec = new RSAPrivateKeySpec(new BigInteger(modulus),
+                new BigInteger(privateExponent));
+        try {
+            return (RSAPrivateKey) keyFactory.generatePrivate(privateKeySpec);
+        } catch (InvalidKeySpecException ex) {
+            log.error("RSAPrivateKeySpec is unavailable.", ex);
+        } catch (NullPointerException ex) {
+            log.error("RSAUtils#KEY_FACTORY is null, can not generate KeyFactory instance.", ex);
+        }
+        return null;
+    }
+     
+    /**
+     * 根据给定的16进制系数和专用指数字符串构造一个RSA专用的私钥对象。
+     * 
+     * @param modulus 系数。
+     * @param privateExponent 专用指数。
+     * @return RSA专用私钥对象。
+     */
+    public static RSAPrivateKey getRSAPrivateKey(String hexModulus, String hexPrivateExponent) {
+        if(StringUtils.isBlank(hexModulus) || StringUtils.isBlank(hexPrivateExponent)) {
+            if(log.isDebugEnabled()) {
+                log.debug("hexModulus and hexPrivateExponent cannot be empty. RSAPrivateKey value is null to return.");
+            }
+            return null;
+        }
+        byte[] modulus = null;
+        byte[] privateExponent = null;
+        try {
+            modulus = Hex.decodeHex(hexModulus.toCharArray());
+            privateExponent = Hex.decodeHex(hexPrivateExponent.toCharArray());
+        } catch(DecoderException ex) {
+            log.error("hexModulus or hexPrivateExponent value is invalid. return null(RSAPrivateKey).");
+        }
+        if(modulus != null && privateExponent != null) {
+            return generateRSAPrivateKey(modulus, privateExponent);
+        }
+        return null;
+    }
+     
+    /**
+     * 根据给定的16进制系数和专用指数字符串构造一个RSA专用的公钥对象。
+     * 
+     * @param modulus 系数。
+     * @param publicExponent 专用指数。
+     * @return RSA专用公钥对象。
+     */
+    public static RSAPublicKey getRSAPublidKey(String hexModulus, String hexPublicExponent) {
+        if(StringUtils.isBlank(hexModulus) || StringUtils.isBlank(hexPublicExponent)) {
+            if(log.isDebugEnabled()) {
+                log.debug("hexModulus and hexPublicExponent cannot be empty. return null(RSAPublicKey).");
+            }
+            return null;
+        }
+        byte[] modulus = null;
+        byte[] publicExponent = null;
+        try {
+            modulus = Hex.decodeHex(hexModulus.toCharArray());
+            publicExponent = Hex.decodeHex(hexPublicExponent.toCharArray());
+        } catch(DecoderException ex) {
+            log.error("hexModulus or hexPublicExponent value is invalid. return null(RSAPublicKey).");
+        }
+        if(modulus != null && publicExponent != null) {
+            return generateRSAPublicKey(modulus, publicExponent);
+        }
+        return null;
+    }
+ 
+    /**
+     * 使用指定的公钥加密数据。
+     * 
+     * @param publicKey 给定的公钥。
+     * @param data 要加密的数据。
+     * @return 加密后的数据。
+     */
+    public static byte[] encrypt(PublicKey publicKey, byte[] data) throws Exception {
+        Cipher ci = Cipher.getInstance(ALGORITHOM, DEFAULT_PROVIDER);
+        ci.init(Cipher.ENCRYPT_MODE, publicKey);
+        return ci.doFinal(data);
+    }
+ 
+    /**
+     * 使用指定的私钥解密数据。
+     * 
+     * @param privateKey 给定的私钥。
+     * @param data 要解密的数据。
+     * @return 原数据。
+     */
+    public static byte[] decrypt(PrivateKey privateKey, byte[] data) throws Exception {
+        Cipher ci = Cipher.getInstance(ALGORITHOM, DEFAULT_PROVIDER);
+        ci.init(Cipher.DECRYPT_MODE, privateKey);
+        return ci.doFinal(data);
+    }
+ 
+    /**
+     * 使用给定的公钥加密给定的字符串。
+     * <p />
+     * 若 {@code publicKey} 为 {@code null},或者 {@code plaintext} 为 {@code null} 则返回 {@code
+     * null}。
+     * 
+     * @param publicKey 给定的公钥。
+     * @param plaintext 字符串。
+     * @return 给定字符串的密文。
+     */
+    public static String encryptString(PublicKey publicKey, String plaintext) {
+        if (publicKey == null || plaintext == null) {
+            return null;
+        }
+        byte[] data = plaintext.getBytes();
+        try {
+            byte[] en_data = encrypt(publicKey, data);
+            return new String(Hex.encodeHex(en_data));
+        } catch (Exception ex) {
+            log.error(ex.getCause().getMessage());
+        }
+        return null;
+    }
+     
+
+ 
+    /**
+     * 使用给定的私钥解密给定的字符串。
+     * <p />
+     * 若私钥为 {@code null},或者 {@code encrypttext} 为 {@code null}或空字符串则返回 {@code null}。
+     * 私钥不匹配时,返回 {@code null}。
+     * 
+     * @param privateKey 给定的私钥。
+     * @param encrypttext 密文。
+     * @return 原文字符串。
+     */
+    public static String decryptString(PrivateKey privateKey, String encrypttext) {
+        if (privateKey == null || StringUtils.isBlank(encrypttext)) {
+            return null;
+        }
+        try {
+            byte[] en_data = Hex.decodeHex(encrypttext.toCharArray());
+            byte[] data = decrypt(privateKey, en_data);
+            return new String(data);
+        } catch (Exception ex) {
+            log.error(String.format("\"%s\" Decryption failed. Cause: %s", encrypttext, ex.getCause().getMessage()));
+        }
+        return null;
+    }
+     
+   
+     
+    /** 返回已初始化的默认的公钥。*/
+    public static RSAPublicKey getDefaultPublicKey(boolean isCreateKeyPair) {
+        KeyPair keyPair = getKeyPair(isCreateKeyPair);
+        if(keyPair != null) {
+            return (RSAPublicKey)keyPair.getPublic();
+        }
+        return null;
+    }
+     
+    /** 返回已初始化的默认的私钥。*/
+    public static RSAPrivateKey getDefaultPrivateKey(boolean isCreateKeyPair) {
+        KeyPair keyPair = getKeyPair(isCreateKeyPair);
+        if(keyPair != null) {
+            return (RSAPrivateKey)keyPair.getPrivate();
+        }
+        return null;
+    }
+     
+}

+ 304 - 0
src/main/java/com/wechat/common/utils/Reflections.java

@@ -0,0 +1,304 @@
+/**
+ * Copyright (c) 2005-2012 springside.org.cn
+ */
+package com.wechat.common.utils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Validate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.Assert;
+
+/**
+ * 反射工具类.
+ * 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数.
+ * @author calvin
+ * @version 2013-01-15
+ */
+@SuppressWarnings("rawtypes")
+public class Reflections {
+	
+	private static final String SETTER_PREFIX = "set";
+
+	private static final String GETTER_PREFIX = "get";
+
+	private static final String CGLIB_CLASS_SEPARATOR = "$$";
+	
+	private static Logger logger = LoggerFactory.getLogger(Reflections.class);
+
+	/**
+	 * 调用Getter方法.
+	 * 支持多级,如:对象名.对象名.方法
+	 */
+	public static Object invokeGetter(Object obj, String propertyName) {
+		Object object = obj;
+		for (String name : StringUtils.split(propertyName, ".")){
+			String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
+			object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
+		}
+		return object;
+	}
+
+	/**
+	 * 调用Setter方法, 仅匹配方法名。
+	 * 支持多级,如:对象名.对象名.方法
+	 */
+	public static void invokeSetter(Object obj, String propertyName, Object value) {
+		Object object = obj;
+		String[] names = StringUtils.split(propertyName, ".");
+		for (int i=0; i<names.length; i++){
+			if(i<names.length-1){
+				String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
+				object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
+			}else{
+				String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
+				invokeMethodByName(object, setterMethodName, new Object[] { value });
+			}
+		}
+	}
+
+	/**
+	 * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数.
+	 */
+	public static Object getFieldValue(final Object obj, final String fieldName) {
+		Field field = getAccessibleField(obj, fieldName);
+
+		if (field == null) {
+			throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
+		}
+
+		Object result = null;
+		try {
+			result = field.get(obj);
+		} catch (IllegalAccessException e) {
+			logger.error("不可能抛出的异常{}", e.getMessage());
+		}
+		return result;
+	}
+
+	/**
+	 * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数.
+	 */
+	public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
+		Field field = getAccessibleField(obj, fieldName);
+
+		if (field == null) {
+			throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
+		}
+
+		try {
+			field.set(obj, value);
+		} catch (IllegalAccessException e) {
+			logger.error("不可能抛出的异常:{}", e.getMessage());
+		}
+	}
+
+	/**
+	 * 直接调用对象方法, 无视private/protected修饰符.
+	 * 用于一次性调用的情况,否则应使用getAccessibleMethod()函数获得Method后反复调用.
+	 * 同时匹配方法名+参数类型,
+	 */
+	public static Object invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
+			final Object[] args) {
+		Method method = getAccessibleMethod(obj, methodName, parameterTypes);
+		if (method == null) {
+			throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
+		}
+
+		try {
+			return method.invoke(obj, args);
+		} catch (Exception e) {
+			throw convertReflectionExceptionToUnchecked(e);
+		}
+	}
+
+	/**
+	 * 直接调用对象方法, 无视private/protected修饰符,
+	 * 用于一次性调用的情况,否则应使用getAccessibleMethodByName()函数获得Method后反复调用.
+	 * 只匹配函数名,如果有多个同名函数调用第一个。
+	 */
+	public static Object invokeMethodByName(final Object obj, final String methodName, final Object[] args) {
+		Method method = getAccessibleMethodByName(obj, methodName);
+		if (method == null) {
+			throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
+		}
+
+		try {
+			return method.invoke(obj, args);
+		} catch (Exception e) {
+			throw convertReflectionExceptionToUnchecked(e);
+		}
+	}
+
+	/**
+	 * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问.
+	 * 
+	 * 如向上转型到Object仍无法找到, 返回null.
+	 */
+	public static Field getAccessibleField(final Object obj, final String fieldName) {
+		Validate.notNull(obj, "object can't be null");
+		Validate.notBlank(fieldName, "fieldName can't be blank");
+		for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
+			try {
+				Field field = superClass.getDeclaredField(fieldName);
+				makeAccessible(field);
+				return field;
+			} catch (NoSuchFieldException e) {//NOSONAR
+				// Field不在当前类定义,继续向上转型
+				continue;// new add
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问.
+	 * 如向上转型到Object仍无法找到, 返回null.
+	 * 匹配函数名+参数类型。
+	 * 
+	 * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
+	 */
+	public static Method getAccessibleMethod(final Object obj, final String methodName,
+			final Class<?>... parameterTypes) {
+		Validate.notNull(obj, "object can't be null");
+		Validate.notBlank(methodName, "methodName can't be blank");
+
+		for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
+			try {
+				Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
+				makeAccessible(method);
+				return method;
+			} catch (NoSuchMethodException e) {
+				// Method不在当前类定义,继续向上转型
+				continue;// new add
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问.
+	 * 如向上转型到Object仍无法找到, 返回null.
+	 * 只匹配函数名。
+	 * 
+	 * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
+	 */
+	public static Method getAccessibleMethodByName(final Object obj, final String methodName) {
+		Validate.notNull(obj, "object can't be null");
+		Validate.notBlank(methodName, "methodName can't be blank");
+
+		for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
+			Method[] methods = searchType.getDeclaredMethods();
+			for (Method method : methods) {
+				if (method.getName().equals(methodName)) {
+					makeAccessible(method);
+					return method;
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
+	 */
+	public static void makeAccessible(Method method) {
+		if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
+				&& !method.isAccessible()) {
+			method.setAccessible(true);
+		}
+	}
+
+	/**
+	 * 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
+	 */
+	public static void makeAccessible(Field field) {
+		if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) || Modifier
+				.isFinal(field.getModifiers())) && !field.isAccessible()) {
+			field.setAccessible(true);
+		}
+	}
+
+	/**
+	 * 通过反射, 获得Class定义中声明的泛型参数的类型, 注意泛型必须定义在父类处
+	 * 如无法找到, 返回Object.class.
+	 * eg.
+	 * public UserDao extends HibernateDao<User>
+	 *
+	 * @param clazz The class to introspect
+	 * @return the first generic declaration, or Object.class if cannot be determined
+	 */
+	@SuppressWarnings("unchecked")
+	public static <T> Class<T> getClassGenricType(final Class clazz) {
+		return getClassGenricType(clazz, 0);
+	}
+
+	/**
+	 * 通过反射, 获得Class定义中声明的父类的泛型参数的类型.
+	 * 如无法找到, 返回Object.class.
+	 * 
+	 * 如public UserDao extends HibernateDao<User,Long>
+	 *
+	 * @param clazz clazz The class to introspect
+	 * @param index the Index of the generic ddeclaration,start from 0.
+	 * @return the index generic declaration, or Object.class if cannot be determined
+	 */
+	public static Class getClassGenricType(final Class clazz, final int index) {
+
+		Type genType = clazz.getGenericSuperclass();
+
+		if (!(genType instanceof ParameterizedType)) {
+			logger.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType");
+			return Object.class;
+		}
+
+		Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
+
+		if (index >= params.length || index < 0) {
+			logger.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
+					+ params.length);
+			return Object.class;
+		}
+		if (!(params[index] instanceof Class)) {
+			logger.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
+			return Object.class;
+		}
+
+		return (Class) params[index];
+	}
+	
+	public static Class<?> getUserClass(Object instance) {
+		Assert.notNull(instance, "Instance must not be null");
+		Class clazz = instance.getClass();
+		if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
+			Class<?> superClass = clazz.getSuperclass();
+			if (superClass != null && !Object.class.equals(superClass)) {
+				return superClass;
+			}
+		}
+		return clazz;
+
+	}
+	
+	/**
+	 * 将反射时的checked exception转换为unchecked exception.
+	 */
+	public static RuntimeException convertReflectionExceptionToUnchecked(Exception e) {
+		if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException
+				|| e instanceof NoSuchMethodException) {
+			return new IllegalArgumentException(e);
+		} else if (e instanceof InvocationTargetException) {
+			return new RuntimeException(((InvocationTargetException) e).getTargetException());
+		} else if (e instanceof RuntimeException) {
+			return (RuntimeException) e;
+		}
+		return new RuntimeException("Unexpected Checked Exception.", e);
+	}
+}

+ 46 - 0
src/main/java/com/wechat/common/utils/SSLClient.java

@@ -0,0 +1,46 @@
+package com.wechat.common.utils;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+public class SSLClient extends DefaultHttpClient{
+
+	public SSLClient() throws Exception {
+		super();
+		SSLContext ctx = SSLContext.getInstance("TLSv1.2");
+		X509TrustManager tm = new X509TrustManager() {
+
+			@Override
+			public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+				
+			}
+
+			@Override
+			public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+				
+			}
+
+			@Override
+			public X509Certificate[] getAcceptedIssuers() {
+				return null;
+			}
+			
+		};
+		ctx.init(null, new TrustManager[] { tm }, null);
+		org.apache.http.conn.ssl.SSLSocketFactory ssf = new org.apache.http.conn.ssl.SSLSocketFactory(ctx,
+				org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+		ClientConnectionManager ccm = this.getConnectionManager();
+		SchemeRegistry sr = ccm.getSchemeRegistry();
+		sr.register(new Scheme("https", 443, ssf));
+	}
+
+}

+ 90 - 0
src/main/java/com/wechat/common/utils/SignUtils.java

@@ -0,0 +1,90 @@
+
+package com.wechat.common.utils;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * 请求校验工具类
+ * 
+ */
+public class SignUtils {
+
+    /**
+     * 验证签名
+     * 
+     * @param signature 微信加密签名
+     * @param timestamp 时间戳
+     * @param nonce 随机数
+     * @return
+     */
+    public static boolean checkSignature(String token, String signature, String timestamp,
+            String nonce) {
+        String[] arr = new String[] { token, timestamp, nonce };
+        // 将token、timestamp、nonce三个参数进行字典序排序
+        //Arrays.sort(arr);
+        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;
+    }
+
+    /**
+     * 将字节数组转换为十六进制字符串
+     * 
+     * @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;
+    }
+
+    public static void sort(String a[]) {
+        for (int i = 0; i < a.length - 1; i++) {
+            for (int j = i + 1; j < a.length; j++) {
+                if (a[j].compareTo(a[i]) < 0) {
+                    String temp = a[i];
+                    a[i] = a[j];
+                    a[j] = temp;
+                }
+            }
+        }
+    }
+}

+ 1187 - 0
src/main/java/com/wechat/common/utils/StringsUtils.java

@@ -0,0 +1,1187 @@
+package com.wechat.common.utils;
+
+import java.math.BigDecimal;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.text.DecimalFormat;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class StringsUtils extends BaseUtils {
+
+    /**
+     * 编码格式定义
+     */
+    private static final String ENCODE    = "UTF-8";
+
+    /**
+     * 随机对象
+     */
+    private static Random       crsRand;
+
+    /**
+     * 随机对象
+     */
+    private static SecureRandom crsSecureRand;
+
+    /**
+     * token 用
+     */
+    private static final int    PAD_BELOW = 0x10;
+
+    /**
+     * token 用
+     */
+    private static final int    TWO_BYTES = 0xFF;
+
+    /**
+     * 访问Ip
+     */
+    private static String       s_id;
+
+    /**
+     * 构造函数
+     */
+    private StringsUtils()
+    {
+    }
+
+    /**
+     * 加载数据
+     */
+    static {
+        crsSecureRand = new SecureRandom();
+        long secureInitializer = crsSecureRand.nextLong();
+        crsRand = new Random(secureInitializer);
+        try {
+            s_id = InetAddress.getLocalHost().toString();
+        }
+        catch (UnknownHostException e) {
+            //DebugLogger.log(e.getMessage());
+        }
+    }
+
+    /**
+     * 字符串转黄成字符创数组,用逗号分组
+     * 
+     * @param str
+     * @return
+     */
+    public static String[] str2Array(String str) {
+        return str2Array(str, ",");
+    }
+
+    /**
+     * 根据只等分隔符处理String装换成数组
+     * 
+     * @param str
+     * @param sep
+     * @return
+     */
+    public static String[] str2Array(String str, String sep) {
+        StringTokenizer token = null;
+        String[] array = null;
+
+        // check
+        if (str == null || sep == null) {
+            return null;
+        }
+
+        // get string array
+        token = new StringTokenizer(str, sep);
+        array = new String[token.countTokens()];
+        for (int i = 0; token.hasMoreTokens(); i++) {
+            array[i] = token.nextToken();
+        }
+
+        return array;
+    }
+
+    /**
+     * String 数组转换成String
+     * 
+     * @param str
+     * @return
+     */
+    public static String array2String(String[] str) {
+        int num = 0;
+        StringBuffer result = new StringBuffer("");
+        if (str == null) {
+            return "";
+        }
+        num = str.length;
+        for (int i = 0; i < num; i++) {
+            if (str[i] != null) {
+                result.append(str[i]);
+            }
+        }
+        return result.toString();
+    }
+
+    /**
+     * 正则表达式匹配<br>
+     * 
+     * @param value
+     * @param regexp
+     * @return boolean
+     */
+    public static boolean matches(String value, String regexp) {
+        if (isEmpty(value) || isEmpty(regexp)) {
+            return false;
+        }
+        else {
+            return value.matches(regexp);
+        }
+    }
+
+    /**
+     * 判断是否都是半角 <br>
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isHalf(String txt) {
+        if (txt == null) {
+            return true;
+        }
+        try {
+            txt = txt.replaceAll("\\?", "");
+
+            byte[] b = txt.getBytes(ENCODE);
+            for (int i = 0; i < b.length; i++) {
+                if ((b[i] & 0x80) == 0x80) {
+                    if (!(((byte) 0xA0) <= b[i] && b[i] <= ((byte) 0xDf))) {
+                        return false;
+                    }
+                }
+                else if (b[i] == 0x3F) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        catch (java.io.UnsupportedEncodingException e) {
+            return false;
+        }
+    }
+
+    /**
+     * 判断是否都是半角的英文和数字
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isHalfENGNum(String txt) {
+        StringBuffer checkText = null;
+
+        if (txt == null) {
+            return true;
+        }
+        checkText = new StringBuffer(txt);
+        for (int i = 0; i < checkText.length(); i++) {
+            String subcheckText = checkText.substring(i, i + 1);
+            if (!matches(subcheckText, "([a-zA-Z]+)") && !matches(subcheckText, "([0-9]+)")) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 判断半角大写英文字符和数字
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isHalfUpperENGNum(String txt) {
+        StringBuffer checkText = null;
+
+        if (txt == null) {
+            return true;
+        }
+        checkText = new StringBuffer(txt);
+        for (int i = 0; i < checkText.length(); i++) {
+            String subcheckText = checkText.substring(i, i + 1);
+            if (!matches(subcheckText, "([A-Z]+)") && !matches(subcheckText, "([0-9]+)")) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 判断半角大写英文字符和数字和符号"-"
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isHalfUpperENGNumHalfSymbol(String txt) {
+        StringBuffer checkText = null;
+
+        if (txt == null) {
+            return true;
+        }
+        checkText = new StringBuffer(txt);
+        for (int i = 0; i < checkText.length(); i++) {
+            String subcheckText = checkText.substring(i, i + 1);
+            if (!matches(subcheckText, "([A-Z]+)") && !matches(subcheckText, "([0-9]+)") && !matches(subcheckText, "-")
+                    && !matches(subcheckText, " ")) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 判断半角大写英文字符和数字和符号"-" 加空格
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isHalfUpperENGNumHalfSymbolSpace(String txt) {
+        StringBuffer checkText = null;
+
+        if (txt == null) {
+            return true;
+        }
+        checkText = new StringBuffer(txt);
+        for (int i = 0; i < checkText.length(); i++) {
+            String subcheckText = checkText.substring(i, i + 1);
+            if (!matches(subcheckText, "([A-Z]+)") && !matches(subcheckText, "([0-9]+)") && !matches(subcheckText, "-")
+                    && !isEqual(subcheckText, " ")) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 判断半角大写英文字符与数字
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isHalfEN(String txt) {
+        if (txt == null) {
+            return true;
+        }
+        if (matches(txt, "([a-zA-Z]+)")) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 正整数验证
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isPositiveNumHalf(String txt) {
+        if (isEmpty(txt)) {
+            return true;
+        }
+
+        if (matches(txt, "([0-9]+)")) {
+            if (Integer.parseInt(txt) <= 0) {
+                return false;
+            }
+            else {
+                return true;
+            }
+        }
+        else {
+            return false;
+        }
+    }
+
+    /**
+     * 判断是否是半角数字
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isHalfNum(String txt) {
+        if (txt == null) {
+            return true;
+        }
+        if (matches(txt, "([0-9]+)")) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 整数验证
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isInteger(String txt) {
+        if (isEmpty(txt)) {
+            return true;
+        }
+
+        if (matches(txt, "([-+]?[0-9]+)")) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 判断是否是半角数字和小数点
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isHalfNumPoint(String txt) {
+        if (txt == null) {
+            return true;
+        }
+        if (!txt.contains(".")) {
+            if (matches(txt, "([0-9]+)")) {
+                return true;
+            }
+        }
+        if (matches(txt, "([0-9]+.[0-9]+)")) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 判断是否是半角数字和小数点
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isBigDecimal(String txt) {
+        if (txt == null) {
+            return true;
+        }
+        if (!txt.contains(".")) {
+            if (matches(txt, "^[-+]?([0-9]+)")) {
+                return true;
+            }
+        }
+        if (matches(txt, "^[-+]?([0-9]+.[0-9]+)")) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 判断两个String 是否相等, 如果都是null 也表示相等
+     * 
+     * @param s1
+     * @param s2
+     * @return boolean
+     */
+    public static boolean isEqual(String s1, String s2) {
+        if (s1 == null) {
+            s1 = "";
+        }
+        if (s2 == null) {
+            s2 = "";
+        }
+
+        return (s1.equals(s2));
+    }
+
+    /**
+     * 判断s1 是否包含s2
+     * 
+     * @param s1
+     * @param s2
+     * @return boolean
+     */
+    public static boolean isContains(String s1, String s2) {
+        if (s1 == null) {
+            return false;
+        }
+        if (s2 == null) {
+            return false;
+        }
+
+        return (s1.contains(s2));
+    }
+
+    /**
+     * 处理String null 如果是null 返回空字符串,否则返回trim后的String
+     * 
+     * @param value
+     * @return String
+     */
+    public static String nvl(String value) {
+        if (value == null) {
+            return "";
+        }
+        else {
+            return value.trim();
+        }
+    }
+
+    /**
+     * int 转换成String
+     * 
+     * @param value
+     * @return String
+     */
+    public static String parseInt(Integer value) {
+        if (value == null) {
+            return "";
+        }
+        else {
+            return String.valueOf(value);
+        }
+    }
+
+    /**
+     * long 转换成字符串
+     * 
+     * @param value
+     * @return String
+     */
+    public static String parseLong(Long value) {
+        if (value == null) {
+            return "";
+        }
+        else {
+            return String.valueOf(value);
+        }
+    }
+
+    /**
+     * Short 转换成字符串
+     * 
+     * @param value
+     * @return String
+     */
+    public static String parseShort(Short value) {
+        if (value == null) {
+            return "";
+        }
+        else {
+            return String.valueOf(value);
+        }
+    }
+
+    /**
+     * 判断是否为空
+     * 
+     * @param str
+     * @return boolean
+     */
+    public static boolean isEmpty(String str) {
+        if ("".equals(nvl(str))) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
+    /**
+     * String list转换成String 数组
+     * 
+     * @param inputList
+     * @return String[]
+     */
+    public static String[] listToStringArray(List<String> inputList) {
+        return inputList.toArray(new String[inputList.size()]);
+    }
+
+    /**
+     * 取得 hash String
+     * 
+     * @param md5Data
+     * @return String
+     */
+    public static String getHashString(byte[] md5Data) {
+        StringBuffer hashString = new StringBuffer();
+        for (int i = 0; i < md5Data.length; ++i) {
+            String hex = Integer.toHexString(md5Data[i]);
+            if (hex.length() == 1) {
+                hashString.append('0');
+                hashString.append(hex.charAt(0));
+            }
+            else {
+                hashString.append(hex.substring(hex.length() - 2));
+            }
+        }
+        return hashString.toString();
+    }
+
+    /**
+     * 取得HexString
+     * 
+     * @param in
+     * @return String
+     */
+    public static String toHexString(byte[] in) {
+        byte ch = 0x00;
+        int i = 0;
+
+        if (in == null || in.length <= 0) {
+            return null;
+        }
+
+        String[] pseudo = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" };
+
+        StringBuffer out = new StringBuffer(in.length * 2);
+
+        while (i < in.length) {
+            ch = (byte) (in[i] & 0xF0);
+            ch = (byte) (ch >>> 4);
+            ch = (byte) (ch & 0x0F);
+            out.append(pseudo[(int) ch]);
+            ch = (byte) (in[i] & 0x0F);
+            out.append(pseudo[(int) ch]);
+            i++;
+        }
+
+        String rslt = new String(out);
+        return rslt;
+
+    }
+
+    /**
+     * String 数组转List
+     * 
+     * @param arrays
+     * @return List<String>
+     */
+    public static List<String> stringArray2List(String[] arrays) {
+        if (arrays == null) {
+            return null;
+        }
+        ArrayList<String> list = new ArrayList<String>();
+        for (int i = 0; i < arrays.length; i++) {
+            list.add(arrays[i]);
+        }
+        return list;
+    }
+
+    /**
+     * @Title: anyIsEmpty
+     * @Description: 判断是否为空
+     * @author hl
+     * @return boolean
+     * @throws
+     */
+    public static boolean anyIsEmpty(Object... object) {
+        for (Object o : object) {
+            if (o == null) {
+                return true;
+            }
+            if (o instanceof String) {
+                if (isEmpty((String) o)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 随机字符串源
+     */
+    private static final String BASE_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+    /**
+     * 或得随机字符串
+     * 
+     * @param length
+     * @return String
+     */
+    public static String getRandomString(int length) {
+        Random random = new Random();
+        StringBuffer sbReturn = new StringBuffer();
+        for (int i = 0; i < length; i++) {
+            int number = random.nextInt(BASE_CHAR.length());
+            sbReturn.append(BASE_CHAR.charAt(number));
+        }
+        return sbReturn.toString();
+    }
+    
+    /**
+     * 随机字符串源
+     */
+    private static final String UPPERCASE_BASE_CHAR = "ABCDEFGHJKLMNOPQRSTUVWXYZ023456789";
+
+    /**
+     * 或得随机字符串英文大写(没有1和I)
+     * 
+     * @param length
+     * @return String
+     */
+    public static String getRandomStringUppercase(int length) {
+        Random random = new Random();
+        StringBuffer sbReturn = new StringBuffer();
+        for (int i = 0; i < length; i++) {
+            int number = random.nextInt(UPPERCASE_BASE_CHAR.length());
+            sbReturn.append(UPPERCASE_BASE_CHAR.charAt(number));
+        }
+        return sbReturn.toString();
+    }
+
+    /**
+     * 随机字符串源
+     */
+    private static final String BASE_NUM = "0123456789";
+
+    /**
+     * 获得随机数字
+     * 
+     * @param length
+     * @return String
+     */
+    public static String getRandomNum(int length) {
+        Random random = new Random();
+        StringBuffer sbReturn = new StringBuffer();
+        for (int i = 0; i < length; i++) {
+            int number = random.nextInt(BASE_NUM.length());
+            sbReturn.append(BASE_NUM.charAt(number));
+        }
+        return sbReturn.toString();
+    }
+    
+    /**
+     * 获得指定范围的随机一个数字
+     * 
+     * @param length
+     * @return int
+     */
+    public static int getOneRandomNum(int length) {
+        Random random = new Random();
+        int number = random.nextInt(BASE_NUM.substring(0, length).length());
+        return number;
+    }
+
+    /**
+     * String 转换成 bigDecimail
+     * 
+     * @param number
+     * @return BigDecimal
+     */
+    public static BigDecimal formatString2BigDecimal(String number) {
+        if (isEmpty(number)) {
+            return null;
+        }
+        try {
+            return new BigDecimal(number.trim().replace(",", ""));
+        }
+        catch (Exception e) {
+            throw e;
+        }
+    }
+
+    /**
+     * BigDecimal 转String
+     * 
+     * @param value
+     * @param suffix
+     * @return String
+     */
+    public static String formatBigDecimal(BigDecimal value, int suffix) {
+        if (value == null) {
+            return "";
+        }
+        String fmtString = "###,###,###,###,##0";
+
+        if (suffix > 0) {
+            fmtString += ".";
+
+            for (int i = 0; i < suffix; i++) {
+                fmtString += "0";
+            }
+        }
+
+        DecimalFormat fmt = new DecimalFormat(fmtString);
+        if (value.doubleValue() == 0) {
+            return fmt.format(0.00);
+        }
+        else {
+            return fmt.format(value.doubleValue());
+        }
+    }
+
+    /**
+     * BigDecimal 转String
+     * 
+     * @param value
+     * @param suffix
+     * @return String
+     */
+    public static String bigDecimalToString(BigDecimal value, int suffix) {
+        if (value == null) {
+            return "";
+        }
+        String fmtString = "##############0";
+
+        if (suffix > 0) {
+            fmtString += ".";
+
+            for (int i = 0; i < suffix; i++) {
+                fmtString += "0";
+            }
+        }
+
+        DecimalFormat fmt = new DecimalFormat(fmtString);
+        if (value.doubleValue() == 0) {
+            return fmt.format(0.00);
+        }
+        else {
+            return fmt.format(value.doubleValue());
+        }
+    }
+
+    /**
+     * BigDecimal 转String 如果格式错误, 返回原字符串
+     * 
+     * @param value
+     * @param suffix
+     * @return String
+     */
+    public static String formatBigDecimal(String value, int suffix) {
+        if (!isBigDecimal(value)) {
+            return value;
+        }
+        BigDecimal bigDecimalvalue = formatString2BigDecimal(value);
+        String fmtString = "###,###,###,###,###,##0";
+
+        if (suffix > 0) {
+            fmtString += ".";
+
+            for (int i = 0; i < suffix; i++) {
+                fmtString += "0";
+            }
+        }
+
+        DecimalFormat fmt = new DecimalFormat(fmtString);
+        if (bigDecimalvalue.doubleValue() == 0) {
+            return fmt.format(0.00);
+        }
+        else {
+            return fmt.format(bigDecimalvalue.doubleValue());
+        }
+    }
+
+    /**
+     * 将String 形式的数值格式化(保留指定位数的小数), 返回原字符串
+     * 
+     * @param value
+     * @param suffix
+     * @return String
+     */
+    public static String formatStringToNumber(String value, int suffix) {
+
+        return StringsUtils.bigDecimalToString(StringsUtils.formatString2BigDecimal(value), suffix);
+    }
+
+    /** 半角符号 */
+    private static String halfSymbol = "!\"#$%&'()=~|`{+*}<>?_-^\\@[;:],./";
+
+    /**
+     * 判断是否是半角符号
+     * 
+     * @param txt
+     * @return boolean
+     */
+    public static boolean isHalfSymbol(String txt) {
+        if (halfSymbol.indexOf(txt) >= 0) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
+    /**
+     * token create<br>
+     * 
+     * @return String token
+     */
+    public static String createToken(boolean secure) {
+        MessageDigest md5 = null;
+        StringBuffer sbValueBeforeMD5 = new StringBuffer(128);
+        String valueBeforeMD5 = "";
+        try {
+            md5 = MessageDigest.getInstance("MD5");
+        }
+        catch (NoSuchAlgorithmException e) {
+            // Should not happen
+            throw new IllegalStateException(e);
+        }
+
+        long time = System.currentTimeMillis();
+        long rand = 0;
+
+        if (secure) {
+            rand = crsSecureRand.nextLong();
+        }
+        else {
+            rand = crsRand.nextLong();
+        }
+        sbValueBeforeMD5.append(s_id);
+        sbValueBeforeMD5.append(":");
+        sbValueBeforeMD5.append(Long.toString(time));
+        sbValueBeforeMD5.append(":");
+        sbValueBeforeMD5.append(Long.toString(rand));
+
+        valueBeforeMD5 = sbValueBeforeMD5.toString();
+        md5.update(valueBeforeMD5.getBytes());
+
+        byte[] array = md5.digest();
+        StringBuffer sb = new StringBuffer(32);
+        for (int j = 0; j < array.length; ++j) {
+            int b = array[j] & TWO_BYTES;
+            if (b < PAD_BELOW) {
+                sb.append('0');
+            }
+            sb.append(Integer.toHexString(b));
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * 长度范围内前加0
+     * 
+     * @param val
+     * @param length
+     * @return String
+     */
+    public static String addPreZeroF(Object val, int length) {
+        if (val == null) {
+            val = "";
+        }
+        String result = val.toString();
+        int strLen = result.length();
+        if (strLen < length) {
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < length - strLen; i++) {
+                sb.append('0');
+            }
+            sb.append(val);
+            result = sb.toString();
+        }
+        else {
+            result = result.substring(0, length);
+        }
+
+        return result;
+    }
+    
+    /**
+     * 长度范围内前加0
+     * 	超长的从后截取
+     * 
+     * @param val
+     * @param length
+     * @return String
+     */
+    public static String addPreZeroE(Object val, int length) {
+        if (val == null) {
+            val = "";
+        }
+        String result = val.toString();
+        int strLen = result.length();
+        if (strLen < length) {
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < length - strLen; i++) {
+                sb.append('0');
+            }
+            sb.append(val);
+            result = sb.toString();
+        }
+        else {
+            result = result.substring(strLen-length, strLen);
+        }
+
+        return result;
+    }
+
+    /**
+     * 判断List是否为空,空返回true
+     */
+    @SuppressWarnings("rawtypes")
+    public static boolean isListEmpty(List list) {
+        if (null != list && list.size() > 0) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 判断是否不为空,不空返回true
+     * 
+     * @param str
+     * @return boolean
+     */
+    public static boolean isNotEmpty(String str) {
+        return !isEmpty(str);
+    }
+
+    /**
+     * 去除所有空格,包括中间的
+     * 
+     * @param str
+     * @return boolean
+     */
+    public static String removeAllSpace(String str) {
+        return str.replaceAll("\\s+", "");
+    }
+
+    /**
+     * 封装String类的split
+     * 
+     * @param str
+     * @param symbol
+     * @return String[]
+     */
+    public static String[] split(String str, String symbol) {
+        if (isEmpty(str)) {
+            return null;
+        }
+
+        return str.split(symbol);
+    }
+
+    /**
+     * 去掉 resource中的空元素
+     * 
+     * @param resource
+     * @return String[]
+     */
+    public static String[] removeNull(String[] resource) {
+        List<String> target = new LinkedList<String>();
+
+        if (!isNotEmptyStringArray(resource)) {
+            return null;
+        }
+
+        for (String s : resource) {
+            if (isNotEmpty(s)) {
+                target.add(s);
+            }
+        }
+
+        return target.toArray(new String[target.size()]);
+    }
+
+    /**
+     * 判断是否是空的字符串数组
+     * 
+     * @param strs
+     * @return boolean
+     */
+    public static boolean isNotEmptyStringArray(String[] strs) {
+        return strs != null && strs.length != 0;
+    }
+
+    /**
+     * 验证金额输入框的值
+     * 
+     * @return
+     */
+    public static boolean isMoneyInput(String value) {
+        if (StringsUtils.matches(value, "(^[1-9]\\d{0,8}$)|(^0\\.\\d{1,2}$)|(^[1-9]\\d{0,8}\\.\\d{1,2}$)")) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 验证金额的整数部分是不是大于5位
+     * 
+     * @param value
+     * @return
+     */
+    public static boolean checkMoneyInputFiveBelow(BigDecimal value) {
+        if (null == value) {
+            return false;
+        }
+        String val = String.valueOf(value);
+        String intVal = "";
+        if (val.indexOf(".") < 0) {
+            intVal = val;
+        }
+        else {
+            intVal = val.substring(0, val.indexOf("."));
+        }
+        if (intVal.length() > 5) {
+            return false;
+        }
+        else {
+            return true;
+        }
+    }
+
+    /**
+     * 判断String中是否包含空格
+     * 
+     * @param str 判断字符串
+     * @return 是否包含空格
+     */
+    public static boolean checkHasBlankSpace(String str) {
+        if (str.contains(" ") || str.contains(" ")) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
+    /**
+     * Object 转换成String 避免出现空指针异常
+     * 
+     * @param obj 传入对象
+     * @return 转换后的字符串
+     */
+    public static String object2String(Object obj) {
+        return String.valueOf(obj);
+    }
+
+    /**
+     * 去除全角半角的前后空格
+     * 
+     * @param str 源字符串
+     * @return trim 后的字符串
+     */
+    public static String trim(String str) {
+        if (str == null) {
+            return "";
+        }
+        else {
+            str = str.trim();
+            if (str.startsWith(" ") || str.startsWith(" ") || str.startsWith(" ")) {
+                str = str.substring(1, str.length());
+                return trim(str);
+            }
+            else if (str.endsWith(" ") || str.endsWith(" ") || str.endsWith(" ")) {
+                str = str.substring(0, str.length() - 1);
+                return trim(str);
+            }
+            else {
+                return str;
+            }
+        }
+    }
+
+    /**
+     * String 字符串格式化, 传入格式化模式, 源字符串
+     * 
+     * @param formatPartten
+     * @param regionString
+     * @return 格式化后的字符串
+     */
+    public static String stringFormat(String formatPartten, String regionString) {
+        try {
+            String s = String.format(formatPartten, regionString);
+            return s;
+        }
+        catch (Exception e) {
+            return regionString.toString();
+        }
+    }
+
+    /**
+     * 使用java正则表达式去掉多余的.与0
+     * 
+     * @param s
+     * @return
+     */
+    public static String subZeroAndDot(String s) {
+        if (s.indexOf("0E") == 0) {
+            s = "0";
+        }
+        if (s.indexOf(".") > 0) {
+            s = s.replaceAll("0+?$", "");//去掉多余的0  
+            s = s.replaceAll("[.]$", "");//如最后一位是.则去掉  
+        }
+        return s;
+    }
+
+    /**
+     * BigDecimal转String
+     * 
+     * @param s
+     * @return
+     */
+    public static String decimal2String(BigDecimal d) {
+        if (d == null) {
+            return null;
+        }
+        else {
+            return d.toString();
+        }
+    }
+
+    /**
+     * 第一参数为空返回默认第二参数
+     * 
+     * @param target
+     * @param def
+     * @return
+     */
+    public static String defaultStr(String target, String def) {
+        if (StringsUtils.isEmpty(target)) {
+            return def;
+        }
+        return StringsUtils.trim(target);
+    }
+
+    public static String defaultStr(String target) {
+        return defaultStr(target, "");
+    }
+
+    public static void main(String[] args) {
+    }
+    
+    /**
+     * 将富文本内容中的图片地址转化为请求流
+     * @param source 富文本内容
+     * @param target 拼接富文本图片请求地址
+     * @return 将富文本内容中的图片地址转化为请求流
+     */
+    public static String strConvert(String source,String target){
+        Pattern p = Pattern.compile("<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>");
+        Matcher m = p.matcher(source);
+        while (m.find()) {
+                String src = m.group(1);
+                String[] st = src.split("/");
+                String img = "/";
+                for (int i =st.length - 2; i< st.length;i++){
+                    if (i == st.length - 1){
+                        img = img + st[i];
+                    } else {
+                        img = img + st[i] + "/";
+                    }
+                }
+                source=source.replace(src, target+img);
+        }
+        return source;
+    }
+    
+    /**
+     * URL中加变量
+     * 
+     * @param url
+     * @return
+     */
+    public static String urlAddTs(String url) {
+    	return url + "?ts="+Instant.now().toEpochMilli();
+    }
+
+    
+}

+ 188 - 0
src/main/java/com/wechat/common/utils/TLSSigAPIv2.java

@@ -0,0 +1,188 @@
+package com.wechat.common.utils;
+
+import sun.misc.BASE64Encoder;
+import java.io.UnsupportedEncodingException;
+import java.security.*;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.zip.Deflater;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.json.JSONObject;
+
+import com.wechat.common.TengXunYunBase64URL;
+
+public class TLSSigAPIv2 {
+    private long sdkappid;
+    private String key;
+
+    public TLSSigAPIv2(long sdkappid, String key) {
+        this.sdkappid = sdkappid;
+        this.key = key;
+    }
+
+    /**
+     * 【功能说明】用于签发 TRTC 和 IM 服务中必须要使用的 UserSig 鉴权票据
+     * <p>
+     * 【参数说明】
+     *
+     * @param userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。
+     * @param expire - UserSig 票据的过期时间,单位是秒,比如 86400 代表生成的 UserSig 票据在一天后就无法再使用了。
+     * @return usersig -生成的签名
+     */
+    public String genUserSig(String userid, long expire) {
+        return genUserSig(userid, expire, null);
+    }
+
+    /**
+     * 【功能说明】
+     * 用于签发 TRTC 进房参数中可选的 PrivateMapKey 权限票据。
+     * PrivateMapKey 需要跟 UserSig 一起使用,但 PrivateMapKey 比 UserSig 有更强的权限控制能力:
+     * - UserSig 只能控制某个 UserID 有无使用 TRTC 服务的权限,只要 UserSig 正确,其对应的 UserID 可以进出任意房间。
+     * - PrivateMapKey 则是将 UserID 的权限控制的更加严格,包括能不能进入某个房间,能不能在该房间里上行音视频等等。
+     * 如果要开启 PrivateMapKey 严格权限位校验,需要在【实时音视频控制台】/【应用管理】/【应用信息】中打开“启动权限密钥”开关。
+     * <p>
+     * 【参数说明】
+     *
+     * @param userid       - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。
+     * @param expire       - PrivateMapKey 票据的过期时间,单位是秒,比如 86400 生成的 PrivateMapKey 票据在一天后就无法再使用了。
+     * @param roomid       - 房间号,用于指定该 userid 可以进入的房间号
+     * @param privilegeMap - 权限位,使用了一个字节中的 8 个比特位,分别代表八个具体的功能权限开关:
+     * - 第 1 位:0000 0001 = 1,创建房间的权限
+     * - 第 2 位:0000 0010 = 2,加入房间的权限
+     * - 第 3 位:0000 0100 = 4,发送语音的权限
+     * - 第 4 位:0000 1000 = 8,接收语音的权限
+     * - 第 5 位:0001 0000 = 16,发送视频的权限
+     * - 第 6 位:0010 0000 = 32,接收视频的权限
+     * - 第 7 位:0100 0000 = 64,发送辅路(也就是屏幕分享)视频的权限
+     * - 第 8 位:1000 0000 = 200,接收辅路(也就是屏幕分享)视频的权限
+     * - privilegeMap == 1111 1111 == 255 代表该 userid 在该 roomid 房间内的所有功能权限。
+     * - privilegeMap == 0010 1010 == 42  代表该 userid 拥有加入房间和接收音视频数据的权限,但不具备其他权限。
+     * @return usersig - 生成带userbuf的签名
+     */
+    public String genPrivateMapKey(String userid, long expire, long roomid, long privilegeMap) {
+        byte[] userbuf = genUserBuf(userid, roomid, expire, privilegeMap, 0);  //生成userbuf
+        return genUserSig(userid, expire, userbuf);
+    }
+
+    private String hmacsha256(String identifier, long currTime, long expire, String base64Userbuf) {
+        String contentToBeSigned = "TLS.identifier:" + identifier + "\n"
+                + "TLS.sdkappid:" + sdkappid + "\n"
+                + "TLS.time:" + currTime + "\n"
+                + "TLS.expire:" + expire + "\n";
+        if (null != base64Userbuf) {
+            contentToBeSigned += "TLS.userbuf:" + base64Userbuf + "\n";
+        }
+        try {
+            byte[] byteKey = key.getBytes("UTF-8");
+            Mac hmac = Mac.getInstance("HmacSHA256");
+            SecretKeySpec keySpec = new SecretKeySpec(byteKey, "HmacSHA256");
+            hmac.init(keySpec);
+            byte[] byteSig = hmac.doFinal(contentToBeSigned.getBytes("UTF-8"));
+            return (new BASE64Encoder().encode(byteSig)).replaceAll("\\s*", "");
+        } catch (UnsupportedEncodingException e) {
+            return "";
+        } catch (NoSuchAlgorithmException e) {
+            return "";
+        } catch (InvalidKeyException e) {
+            return "";
+        }
+    }
+
+    private String genUserSig(String userid, long expire, byte[] userbuf) {
+
+        long currTime = System.currentTimeMillis() / 1000;
+
+        JSONObject sigDoc = new JSONObject();
+        sigDoc.put("TLS.ver", "2.0");
+        sigDoc.put("TLS.identifier", userid);
+        sigDoc.put("TLS.sdkappid", sdkappid);
+        sigDoc.put("TLS.expire", expire);
+        sigDoc.put("TLS.time", currTime);
+
+        String base64UserBuf = null;
+        if (null != userbuf) {
+            base64UserBuf = new BASE64Encoder().encode(userbuf);
+            sigDoc.put("TLS.userbuf", base64UserBuf);
+        }
+        String sig = hmacsha256(userid, currTime, expire, base64UserBuf);
+        if (sig.length() == 0) {
+            return "";
+        }
+        sigDoc.put("TLS.sig", sig);
+        Deflater compressor = new Deflater();
+        compressor.setInput(sigDoc.toString().getBytes(Charset.forName("UTF-8")));
+        compressor.finish();
+        byte[] compressedBytes = new byte[2048];
+        int compressedBytesLength = compressor.deflate(compressedBytes);
+        compressor.end();
+        return (new String(TengXunYunBase64URL.base64EncodeUrl(Arrays.copyOfRange(compressedBytes,
+                0, compressedBytesLength)))).replaceAll("\\s*", "");
+    }
+
+    public byte[] genUserBuf(String account, long dwAuthID, long dwExpTime,
+                             long dwPrivilegeMap, long dwAccountType) {
+        //视频校验位需要用到的字段,按照网络字节序放入buf中
+        /*
+         cVer    unsigned char/1 版本号,填0
+         wAccountLen unsigned short /2   第三方自己的帐号长度
+         account wAccountLen 第三方自己的帐号字符
+         dwSdkAppid  unsigned int/4  sdkappid
+         dwAuthID    unsigned int/4  群组号码
+         dwExpTime   unsigned int/4  过期时间 ,直接使用填入的值
+         dwPrivilegeMap  unsigned int/4  权限位,主播0xff,观众0xab
+         dwAccountType   unsigned int/4  第三方帐号类型
+         */
+        int accountLength = account.length();
+        int offset = 0;
+        byte[] userbuf = new byte[1 + 2 + accountLength + 4 + 4 + 4 + 4 + 4];
+
+        //cVer
+        userbuf[offset++] = 0;
+
+        //wAccountLen
+        userbuf[offset++] = (byte) ((accountLength & 0xFF00) >> 8);
+        userbuf[offset++] = (byte) (accountLength & 0x00FF);
+
+        //account
+        for (; offset < 3 + accountLength; ++offset) {
+            userbuf[offset] = (byte) account.charAt(offset - 3);
+        }
+
+        //dwSdkAppid
+        userbuf[offset++] = (byte) ((sdkappid & 0xFF000000) >> 24);
+        userbuf[offset++] = (byte) ((sdkappid & 0x00FF0000) >> 16);
+        userbuf[offset++] = (byte) ((sdkappid & 0x0000FF00) >> 8);
+        userbuf[offset++] = (byte) (sdkappid & 0x000000FF);
+
+        //dwAuthId,房间号
+        userbuf[offset++] = (byte) ((dwAuthID & 0xFF000000) >> 24);
+        userbuf[offset++] = (byte) ((dwAuthID & 0x00FF0000) >> 16);
+        userbuf[offset++] = (byte) ((dwAuthID & 0x0000FF00) >> 8);
+        userbuf[offset++] = (byte) (dwAuthID & 0x000000FF);
+
+        //expire,过期时间,当前时间 + 有效期(单位:秒)
+        long currTime = System.currentTimeMillis() / 1000;
+        long expire = currTime + dwExpTime;
+        userbuf[offset++] = (byte) ((expire & 0xFF000000) >> 24);
+        userbuf[offset++] = (byte) ((expire & 0x00FF0000) >> 16);
+        userbuf[offset++] = (byte) ((expire & 0x0000FF00) >> 8);
+        userbuf[offset++] = (byte) (expire & 0x000000FF);
+
+        //dwPrivilegeMap,权限位
+        userbuf[offset++] = (byte) ((dwPrivilegeMap & 0xFF000000) >> 24);
+        userbuf[offset++] = (byte) ((dwPrivilegeMap & 0x00FF0000) >> 16);
+        userbuf[offset++] = (byte) ((dwPrivilegeMap & 0x0000FF00) >> 8);
+        userbuf[offset++] = (byte) (dwPrivilegeMap & 0x000000FF);
+
+        //dwAccountType,账户类型
+        userbuf[offset++] = (byte) ((dwAccountType & 0xFF000000) >> 24);
+        userbuf[offset++] = (byte) ((dwAccountType & 0x00FF0000) >> 16);
+        userbuf[offset++] = (byte) ((dwAccountType & 0x0000FF00) >> 8);
+        userbuf[offset++] = (byte) (dwAccountType & 0x000000FF);
+
+        return userbuf;
+    }
+}

+ 99 - 0
src/main/java/com/wechat/common/utils/Time2Now.java

@@ -0,0 +1,99 @@
+package com.wechat.common.utils;
+
+import java.util.Date;
+
+public class Time2Now {
+	private static final long ONE_MINUTE = 60000L;
+    private static final long ONE_HOUR = 3600000L;
+    private static final long ONE_DAY = 86400000L;
+    private static final long ONE_WEEK = 604800000L;
+ 
+    private static final String ONE_SECOND_AGO = "秒前: second ago";
+    private static final String ONE_SECONDS_AGO = "秒前: seconds ago";
+    private static final String ONE_MINUTE_AGO = "分钟前: minute ago";
+    private static final String ONE_MINUTES_AGO = "分钟前: minutes ago";
+    private static final String ONE_HOUR_AGO = "小时前: hour ago";
+    private static final String ONE_HOURS_AGO = "小时前: hours ago";
+    private static final String YESTERDAY = "昨天: yesterday";
+    private static final String ONE_DAY_AGO = "天前: day ago";
+    private static final String ONE_DAYS_AGO = "天前: days ago";
+    private static final String ONE_MONTH_AGO = "月前: month ago";
+    private static final String ONE_MONTHS_AGO = "月前: months ago";
+    private static final String ONE_YEAR_AGO = "年前: year ago";
+    private static final String ONE_YEARS_AGO = "年前: years ago";
+    
+    public static String[] format(Date date,String lang) {
+    	String[] result = new String[2];
+        long delta = new Date().getTime() - date.getTime();
+        String returnStr = "";
+        long p = 0L;
+        if (delta < 1L * ONE_MINUTE) {
+            long seconds = toSeconds(delta);
+            p = (seconds <= 0 ? 1 : seconds);
+            returnStr = (p==1 ?  ONE_SECOND_AGO : ONE_SECONDS_AGO);
+        }else
+        if (delta < 45L * ONE_MINUTE) {
+            long minutes = toMinutes(delta);
+            p = (minutes <= 0 ? 1 : minutes);
+            returnStr = (p==1 ?  ONE_MINUTE_AGO : ONE_MINUTES_AGO);
+        }else
+        if (delta < 24L * ONE_HOUR) {
+            long hours = toHours(delta);
+            p = (hours <= 0 ? 1 : hours);
+            returnStr = (p==1 ?  ONE_HOUR_AGO : ONE_HOURS_AGO);
+        }else
+        if (delta < 48L * ONE_HOUR) {
+        	returnStr =  YESTERDAY;
+        }else
+        if (delta < 30L * ONE_DAY) {
+            long days = toDays(delta);
+            p = (days <= 0 ? 1 : days);
+            returnStr = (p==1 ?  ONE_DAY_AGO : ONE_DAYS_AGO);
+        }else
+        if (delta < 12L * 4L * ONE_WEEK) {
+            long months = toMonths(delta);
+            p =  (months <= 0 ? 1 : months);
+            returnStr = (p==1 ?  ONE_MONTH_AGO : ONE_MONTHS_AGO);
+        } else {
+            long years = toYears(delta);
+            p = (years <= 0 ? 1 : years);
+            returnStr = (p==1 ? ONE_YEAR_AGO :  ONE_YEARS_AGO);
+        }
+        
+        if(StringsUtils.isEmpty(lang))
+        {
+        	result = returnStr.split(":");
+        }
+        if(p != 0) {
+        	String[] ary = new String[] {p + result[0],p + result[1]};
+        	result= ary;
+        }
+        return result;
+    }
+ 
+    private static long toSeconds(long date) {
+        return date / 1000L;
+    }
+ 
+    private static long toMinutes(long date) {
+        return toSeconds(date) / 60L;
+    }
+ 
+    private static long toHours(long date) {
+        return toMinutes(date) / 60L;
+    }
+ 
+    private static long toDays(long date) {
+        return toHours(date) / 24L;
+    }
+ 
+    private static long toMonths(long date) {
+        return toDays(date) / 30L;
+    }
+ 
+    private static long toYears(long date) {
+        return toMonths(date) / 365L;
+    }
+
+
+}

+ 98 - 0
src/main/java/com/wechat/common/utils/WordUtils.java

@@ -0,0 +1,98 @@
+package com.wechat.common.utils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import com.deepoove.poi.XWPFTemplate;
+import com.wechat.global.CustomException;
+import com.wechat.global.message.InfoMsg;
+
+/**
+ * word 文档生成工具类
+ * 
+ * @author Administrator
+ *
+ */
+// @SuppressWarnings("deprecation")
+public class WordUtils {
+	/*
+	 * //配置信息,代码本身写的还是很可读的,就不过多注解了 private static Configuration configuration =
+	 * null; //这里注意的是利用WordUtils的类加载器动态获得模板文件的位置 private static final String
+	 * templateFolder = WordUtils.class.getClassLoader().getResource("/").getPath()
+	 * + "template/"; static { configuration = new Configuration();
+	 * configuration.setDefaultEncoding("utf-8"); try {
+	 * configuration.setDirectoryForTemplateLoading(new File(templateFolder)); }
+	 * catch (IOException e) { e.printStackTrace(); } }
+	 */
+
+	private WordUtils() {
+		throw new AssertionError();
+	}
+
+	/*
+	 * public static void exportMillCertificateWord(HttpServletRequest request,
+	 * HttpServletResponse response, Map<String,Object> map) throws IOException {
+	 * Template freemarkerTemplate = configuration.getTemplate("tempWord.ftl"); File
+	 * file = null; InputStream fin = null; ServletOutputStream out = null; try { //
+	 * 调用工具类的createDoc方法生成Word文档 file = createDoc(map,freemarkerTemplate); fin = new
+	 * FileInputStream(file);
+	 * 
+	 * response.setCharacterEncoding("utf-8");
+	 * response.setContentType("application/msword"); // 设置浏览器以下载的方式处理该文件名 String
+	 * fileName = "简历附件"+System.currentTimeMillis()+ ".doc";
+	 * response.setHeader("Content-Disposition", "attachment;filename="
+	 * .concat(String.valueOf(URLEncoder.encode(fileName, "UTF-8"))));
+	 * 
+	 * out = response.getOutputStream(); byte[] buffer = new byte[512]; // 缓冲区 int
+	 * bytesToRead = -1; // 通过循环将读入的Word文件的内容输出到浏览器中 while((bytesToRead =
+	 * fin.read(buffer)) != -1) { out.write(buffer, 0, bytesToRead); } }catch
+	 * (Exception e) { throw new CustomException(InfoMsg.ERROR_DOWNLOAD_WORD); }
+	 * finally { if(fin != null) fin.close(); if(out != null) out.close(); if(file
+	 * != null) file.delete(); // 删除临时文件 } }
+	 */
+	/**
+	 * 使用poi-tl 生成word
+	 * 
+	 * @param response
+	 * @param map
+	 * @param basePackagePath
+	 *            根路径
+	 * @param fileTemplate
+	 *            模板路径
+	 * @param templateFilenName
+	 *            文件名
+	 * @return
+	 */
+	public static String poiTlWord(HttpServletResponse response, Map<String, Object> map, String basePackagePath,
+			String fileTemplate, String templateFilenName) {
+		String tempWordPath = WordUtils.class.getClassLoader().getResource("/").getPath()
+				+ "template/TemplateWord.docx";
+		XWPFTemplate template = XWPFTemplate.compile(tempWordPath).render(map);
+		try {
+			// String fileName =
+			// ""+System.currentTimeMillis()+StringsUtils.getRandomString(5)+ ".docx";
+			File saveDir = new File(basePackagePath + fileTemplate);
+			if (!saveDir.exists()) {
+				saveDir.mkdir();
+			}
+			File file = new File(saveDir + File.separator + templateFilenName);
+			template.write(new FileOutputStream(file));
+			template.close();
+			return fileTemplate + templateFilenName;
+		} catch (Exception e) {
+			throw new CustomException(InfoMsg.ERROR_DOWNLOAD_WORD);
+		}
+	}
+
+	/*
+	 * private static File createDoc(Map<String,Object> dataMap, Template template)
+	 * { String name = "test.doc"; File f = new File(name); Template t = template;
+	 * try { // 这个地方不能使用FileWriter因为需要指定编码类型否则生成的Word文档会因为有无法识别的编码而无法打开 Writer w =
+	 * new OutputStreamWriter(new FileOutputStream(f), "utf-8"); t.process(dataMap,
+	 * w); w.close(); } catch (Exception ex) { ex.printStackTrace(); throw new
+	 * RuntimeException(ex); } return f; }
+	 */
+}

+ 42 - 0
src/main/java/com/wechat/common/utils/XmlUtils.java

@@ -0,0 +1,42 @@
+package com.wechat.common.utils;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+public class XmlUtils extends BaseUtils{
+    /**
+     * XML转成object
+     * 
+     * @param xml
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> T xml2obj(String xml, Class<T> classOfT) {
+        try {
+            JAXBContext jaxbContext = JAXBContext.newInstance(classOfT);
+            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+            return (T)jaxbUnmarshaller.unmarshal(new StringReader(xml));
+        } catch (JAXBException ex) {
+            log.error(ex);
+            return null;
+        }
+    }
+
+    public static String obj2xml(Object obj) {
+        try {
+            JAXBContext context = JAXBContext.newInstance(obj.getClass());
+            Marshaller marshaller =  context.createMarshaller();
+            StringWriter writer = new StringWriter();
+            marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+            marshaller.marshal(obj, writer);
+            return writer.toString();
+        } catch (JAXBException ex) {
+            log.error(ex);
+            return null;
+        }
+    }
+}

+ 49 - 0
src/main/java/com/wechat/common/utils/view/JSONView.java

@@ -0,0 +1,49 @@
+package com.wechat.common.utils.view;
+
+import java.util.Map;
+
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+import org.springframework.web.servlet.view.AbstractView;
+
+/**
+ * 
+ * @author 王科(小)
+ * 
+ */
+public class JSONView extends AbstractView {
+	public JSONView() {
+		setContentType("text/html");
+	}
+
+	@SuppressWarnings({ "rawtypes" })
+	protected void renderMergedOutputModel(Map model,
+			HttpServletRequest request, HttpServletResponse response)
+			throws Exception {
+		response.setContentType("text/html");
+		response.setHeader("Pragma", "No-cache");
+		response.setDateHeader("Expires", 0L);
+		response.setHeader("Cache-Control", "no-cache");
+		response.setCharacterEncoding("UTF-8");
+		JSONArray jsonArray = (JSONArray) model.get("jsonArray");
+		if (jsonArray != null) {
+			jsonArray.write(response.getWriter());
+		} else {
+			JSONObject jsonObject = (JSONObject) model.get("jsonObject");
+			if (jsonObject != null) {
+				if (jsonObject.get("success") != null
+						&& !jsonObject.getBoolean("success"))
+					response.setStatus(417);
+				jsonObject.write(response.getWriter());
+			} else {
+				jsonArray = new JSONArray();
+				jsonArray.write(response.getWriter());
+			}
+		}
+	}
+}

+ 81 - 0
src/main/java/com/wechat/config/AlipayConfig.java

@@ -0,0 +1,81 @@
+package com.wechat.config;
+
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Component;
+
+import com.wechat.common.utils.BaseUtils;
+
+/* *
+ *类名:AlipayConfig
+ *功能:基础配置类
+ *详细:设置帐户有关信息及返回路径
+ *修改日期:2017-04-05
+ *说明:
+ *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
+ *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
+ */
+@Component
+public class AlipayConfig {
+
+    // ↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
+
+    // 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号
+    public static String app_id = "2016091400511497";
+
+    // 商户私钥,您的PKCS8格式RSA2私钥
+    public static String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCrleqPtDAdqzBXLG3+5abMuGR8FslRaqxMHxcuZYsz3V/CWlTSITou3UHm+OlNlHK2GlpXOLW0soSqJKymDIloMgZC/fVBHhItAkupEHgEltn4P8QCqY9RLMp9eQW5bxkxt5oedJJH43CAImiIUubLhwDb1QdOYHYibD6ttVOF7tSjwpI2FZiWgKOMbtkBKBh2Xe3ML/Pr6MZRICG3a8B2/VdtT8kGj4RGXRnNj7ClhA5Fnf8svB2WIffxKU60RhM390mjMh3qGb8bLn+UOtDgy1Jj9Tbp3xMUid6rZxERK1A5qEpxB9VV0K24a6yzjLNhMiw+6l4ufkQwOguBu3cBAgMBAAECggEAXjglJCHqpfABzGyOPgC3FgVO0EDm7TkpQWd1IDoMNT+jPKLDnts2CtPeQ0l9OueAEfTolKqERKQeaxtWXpvVvAx0GcdALDCqBGMVTtHHRaXcLRA+vsOC+i0hR8Lz3L5f1EggbgbO6IDAnuvGAM2dBDeuxgf1Shl35TERPeuq4Ii78hj2qN7sbp3OJH4rNCvfiqicrgCdmk/Qo8oVSkizoDqKoEMW4t8RaChoWphGeqFYkFsl21CbxH47WGXLMZUZFocBlQhpl53DY52GMw3DwtTz1wJcZUmtY0L1yUKDyjEfix8dWWQdy4YVsDc7TCS2jYmuXUK5CS2la90zI93nPQKBgQDtRtCOyCcZlAZXu79WJKNLpiutTUjhwGHhagcNEUhwiPdIHG6qPUe2Y2cxGGKDDE/GvwTL5ppR64CbwbTOH+CKUgEonPi2h4rB+HTGvFwqH5eZY+It81CJArqF5c1BImlIasUONigW3iv3iRnCCBDLrrCetd+ACG5hX8CD5DquQwKBgQC5IBamjBqMiw0z1TUqR4lRvFdGtz97i6TdSz09Knd3uzdxq8tSqNQFH2gmrMrGKLsnRHF52kOT7hxV3v3DfP9mHXRf7FZsV9B6MQKnHnOxAFLiBnCOQS+Wlw+Y4PjdaHWaXpuVO5UBoVLEhh1UJho44HdEZmXxLbCvvAhfVk1LawKBgQCC2w4D4HBn09HXqqwv5s7D1qW50qiCD+YrOZ0f4MsxfOfbNgr2Cgu1k4aCde9GVJDei9QqW0f6K8XmoGKFVuEvh2AqNL+ZcpDcvpgwTgsKFBg4OPSw4MImfYG+fGjBJigoDvIUD1v2mJpozoyNDIOuwO2Y6baT1pKBUxxJ4KFYHwKBgH+vJDBHHeCl37tKaNr6cDoR31iE96Is1M9VH63aZoAMftdGGHywuVu3J8zVDR7T5RHWYTYcVtPnPV/05643vqgd1LB8f7dGciJ1P1Eo7b69bG0859EWIM6K7lURhlSfwc1xR3oMmF+Bd2bY4c2yYg+sslZZEiLg0qbC2Dt5eOJ1AoGBAMePw9HuHxPwyxzxl9NSnxGWWlOTKGAn1TizqMB/rAeFmBL5HM9ZtptGPBCKs/K1zL2YnUeDJeP9DZQIHME98w6FnTy4xqCO8QvyBJ8RlWj2jVBxmP+ASidvtKFHc63PepmVpoq+4sSHSjLBVVf8kIBCur+GnrtIctZoYjzac3fG";
+
+    // 支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm
+    // 对应APPID下的支付宝公钥。
+    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA43S8BUhcInAPPfu/WYsvh3pR1bfy+MuP/23mXJfvlD8MH6JQnV3b17yx82wUdsIr6I4xkybMTgftPGkUWzDEpwTt0nP4j5RupBBNp9tN2P7DUPLpBrz80PbIi80P+/ATFyhK86IUZ5Nc1e9XTIrVD9PuDMHK4SDKofMMxfYkoGMPdWzh5QhXT8IM8RqqCrdwvwchNGxVFjCJCEtH/3s0hHza6tFWHbchS1V5KqFN0v0ND47vg4hIpzrRucAFfqlRFbVTPFSKkUlMZRvyWNed46Wr9vbNhgOsp8TYpgrNMIUnWjklklxzaQDtRUytDDEY6D5BQx7lRNk/emexSMtVnQIDAQAB";
+
+    // 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
+    public static String notify_url = "http://localhost:8080/RecruitmentApi/Order/aliPay_notify_url";
+
+    // 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
+    public static String return_url = "http://localhost:8080/RecruitmentApi/Order/notify_url";
+
+    // 签名方式
+    public static String sign_type = "RSA2";
+
+    // 字符编码格式
+    public static String charset = "utf-8";
+
+    // 支付宝网关
+    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
+
+    // 支付宝网关
+    public static String log_path = "C:\\";
+
+    // ↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
+
+    protected static final Log log = LogFactory.getLog(AlipayConfig.class);
+    
+    /**
+     * 写日志,方便测试(看网站需求,也可以改成把记录存入数据库)
+     * 
+     * @param sWord
+     *            要写入日志里的文本内容
+     */
+    public static void logResult(String sWord) {
+        FileWriter writer = null;
+        try {
+            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis() + ".txt");
+            writer.write(sWord);
+        } catch (Exception e) {
+        	log.error(e);
+        } finally {
+            if (writer != null) {
+                try {
+                    writer.close();
+                } catch (IOException e) {
+                	log.error("支付宝异常",e);
+                }
+            }
+        }
+    }
+}

+ 56 - 0
src/main/java/com/wechat/config/ConfigReader.java

@@ -0,0 +1,56 @@
+package com.wechat.config;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ConfigReader {
+	
+	private static final Log logger = LogFactory
+			.getLog(ConfigReader.class);
+	
+	@PostConstruct
+	private void PrintLog() {
+		logger.info("Configuration Initializing...");
+		logger.info(String.format("%s is %s", "redisUrl", redisUrl));
+		logger.info(String.format("%s is %s", "jdbcUrl", jdbcUrl));
+		logger.info(String.format("%s is %s", "apiURL", apiURL));
+	}
+	
+	//just for log,no setter,getter
+	@Value("#{configProperties['redis.ip']}")
+	private String redisUrl;
+	
+	//just for log,no setter,getter
+	@Value("#{configProperties['jdbc.oracle.url']}")
+	private String jdbcUrl;
+	
+	
+	
+	@Value("#{configProperties['middleAPIURL']}")
+	private String apiURL;
+	
+	@Value("#{configProperties['token.key']}")
+	private String tokenKey;
+	
+	public String getApiURL() {
+		return apiURL;
+	}
+
+	public void setApiURL(String apiURL) {
+		this.apiURL = apiURL;
+	}
+
+	public String getTokenKey() {
+		return tokenKey;
+	}
+
+	public void setTokenKey(String tokenKey) {
+		this.tokenKey = tokenKey;
+	}
+
+}

+ 63 - 0
src/main/java/com/wechat/controller/AuthorizedController.java

@@ -0,0 +1,63 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.alibaba.fastjson.JSON;
+import com.wechat.common.Constants;
+import com.wechat.common.utils.MvcUtil;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dto.AuzAccesTokenDto;
+import com.wechat.model.responseDto.JsonResp;
+import com.wechat.service.AuthorizedService;
+
+
+@Controller
+@RequestMapping("account")
+public class AuthorizedController extends BaseController {
+	
+    // 微信静默授权
+    @Autowired
+    private AuthorizedService auzService;
+
+    /**
+     * 授权获取用户信息
+     * 
+     * @param code
+     * @return
+     */
+ /*   @RequestMapping(value = "getOpenid", method = RequestMethod.GET)
+    public void getOpenid(@RequestParam String code, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        JsonResp<String> resp = new JsonResp<String>();
+
+        AuzAccesTokenDto auzAccesTokenDto = auzService.getAccessTokenDto(code);
+        if(auzAccesTokenDto == null)
+        {
+            resp.setResult(Constants.RESULT_WARNING);
+            resp.setMsg(InfoMsg.ERROR_AUZ_FAILED);
+        }
+        else
+        {
+            resp.setInfo(auzAccesTokenDto.getOpenid());
+        }
+
+        String json = JSON.toJSONString(resp, true);
+        try {
+            MvcUtil.writeJson(request, response, json);
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+           log.error(e);
+        }
+
+    }*/
+    
+}

+ 36 - 0
src/main/java/com/wechat/controller/BoleInfoController.java

@@ -0,0 +1,36 @@
+package com.wechat.controller;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeBoleInfoService;
+
+@Controller
+@RequestMapping("bole")
+public class BoleInfoController {
+	@Autowired
+	private MdeBoleInfoService boleInfoService;
+	@Autowired
+	private CommonService commonService;
+	/**
+	 * 获取所有伯乐信息
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String,Object>> getAllBole(HttpServletRequest req) throws Exception {
+		Map<String,Object> map = boleInfoService.getAllBole(commonService.getLanguage(req));
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,map);
+	}
+}

+ 37 - 0
src/main/java/com/wechat/controller/CaptchaController.java

@@ -0,0 +1,37 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CaptchaService;
+
+@Controller
+@RequestMapping("captcha")
+public class CaptchaController {
+
+	@Autowired
+	private CaptchaService captchaService;
+
+	/**
+	 * 获取图形验证码
+	 * 
+	 * @param response
+	 * @return
+	 * @throws IOException
+	 */
+	@RequestMapping(value = "getNext", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<String> next(HttpServletResponse response) throws IOException {
+		
+		return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST,captchaService.next(response));
+	}
+}

+ 749 - 0
src/main/java/com/wechat/controller/CommonController.java

@@ -0,0 +1,749 @@
+package com.wechat.controller;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.Constants;
+import com.wechat.common.utils.Md5Utils;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.dao.RedisDPResp;
+import com.wechat.dao.RedisHotelBrandDao;
+import com.wechat.dao.RedisHotelCompanyDao;
+import com.wechat.dao.RedisHotelSubBrandDao;
+import com.wechat.dao.RedisLVResp;
+import com.wechat.dao.RedisPhoneCodeResp;
+import com.wechat.dao.RedisProvinceCityDao;
+import com.wechat.global.Init;
+import com.wechat.global.base.dao.RedisWithExpiryTimeDao;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeUser;
+import com.wechat.model.dto.AdImageDto;
+import com.wechat.model.dto.HotelBrandDto;
+import com.wechat.model.dto.HotelSubBrandDto;
+import com.wechat.model.dto.Province;
+import com.wechat.model.requestDto.AdCtrReq;
+import com.wechat.model.requestDto.AdReq;
+import com.wechat.model.responseDto.DPResp;
+import com.wechat.model.responseDto.HotelCompanyResp;
+import com.wechat.model.responseDto.LVResp;
+import com.wechat.model.responseDto.OpenAdResq;
+import com.wechat.model.responseDto.PhoneCodeResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.AreaService;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeAdImagesService;
+import com.wechat.service.MdeHotelBrandService;
+import com.wechat.service.MdeHotelCompanyService;
+import com.wechat.service.MdeHotelSubBrandService;
+
+/**
+ * 公共请求类
+ * 
+ * @author tangwc
+ *
+ */
+@Controller
+public class CommonController {
+
+	@Value("#{configProperties['upload.base.path']}")
+	private String basePackagePath;
+	
+	@Value("#{configProperties['url.base']}")
+	private String domainUrl;
+
+	@Resource
+	private CommonService commonService;
+
+	@Autowired
+	private MdeHotelBrandService mdeHotelBrandService;
+	@Autowired
+	private MdeHotelSubBrandService mdeHotelSubBrandService;
+	@Autowired
+	private MdeHotelCompanyService mdeHotelCompanyService;
+	@Autowired
+	private AreaService areaService;
+	
+	@Autowired
+	private RedisWithExpiryTimeDao redisDao;
+	@Autowired
+	private RedisProvinceCityDao redisProvinceCityDao;
+	@Autowired
+	private RedisHotelBrandDao redisHotelBrandDao;
+	@Autowired
+	private RedisHotelSubBrandDao redisHotelSubBrandDao;
+	@Autowired
+	private RedisHotelCompanyDao redisHotelCompanyDao;
+	@Autowired
+	private RedisLVResp redisLVResp;
+	@Autowired
+	private RedisDPResp redisDPResp;
+	@Autowired
+	private RedisPhoneCodeResp redisPhoneCodeResp;
+	
+	@Autowired
+	private MdeAdImagesService adImagesService;
+	
+	@Autowired
+	private Init init;
+	
+	protected static final Log log = LogFactory.getLog(CommonController.class);
+
+	@RequestMapping(value = "getBaseData", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getBaseData(HttpServletRequest request) {
+		String lang = commonService.getLanguage(request);
+		Map<String, Object> map = new HashMap<String, Object>();
+		String departmentsAndPositions = null;// 部门职位
+		List<Province> provinceCityArea = null;// 省市区
+		List<Province> provinceCity = null;// 省市
+		List<HotelBrandDto> hotelBrands = null;// 酒店主品牌
+		List<HotelSubBrandDto> hotelSubBrands = null;// 酒店子品牌
+		List<HotelCompanyResp> hotelCompanys = null;// 酒店公司
+		List<LVResp> schoolList = null;// 学校列表
+		List<DPResp> workYear = null;// 工作年限
+		List<DPResp> workStatus = null;// 工作状态
+		List<DPResp> orderStatus = null;// 订单状态
+		List<DPResp> cvStatus = null;// 简历投递状态
+		List<DPResp> education = null;// 学历
+		List<DPResp> international = null;// 国际区分
+		List<PhoneCodeResp> phoneCode = null;// 国家码
+		// 判断redis中的基础数据是否过期
+		if(!redisDao.hasKey("departmentsAndPositions_en")) {
+			init.init();
+		}
+		try {
+            hotelCompanys =     redisHotelCompanyDao.selectMessageInfo("hotelCompanys");
+			if(lang.equalsIgnoreCase("en")) {
+				departmentsAndPositions = redisDao.select("departmentsAndPositions_en");
+				provinceCityArea = 	redisProvinceCityDao.selectMessageInfo("provinceCityArea_en");
+				provinceCity = 		redisProvinceCityDao.selectMessageInfo("provinceCity_en");
+				hotelBrands = 		redisHotelBrandDao.selectMessageInfo("hotelBrands_en");
+				hotelSubBrands = 	redisHotelSubBrandDao.selectMessageInfo("hotelSubBrands_en");
+				schoolList = 		redisLVResp.selectMessageInfo("schoolList_en");
+				workYear = 			redisDPResp.selectMessageInfo("workYear_en");
+				workStatus = 		redisDPResp.selectMessageInfo("workStatus_en");
+				orderStatus = 		redisDPResp.selectMessageInfo("orderStatus_en");
+				cvStatus = 			redisDPResp.selectMessageInfo("cvStatus_en");
+				education = 		redisDPResp.selectMessageInfo("education_en");
+				international = 	redisDPResp.selectMessageInfo("international_en");
+				phoneCode = 		redisPhoneCodeResp.selectMessageInfo("phoneCode_en");
+			}else {
+				departmentsAndPositions = redisDao.select("departmentsAndPositions_cn");
+				provinceCityArea = 	redisProvinceCityDao.selectMessageInfo("provinceCityArea_cn");
+				provinceCity = 		redisProvinceCityDao.selectMessageInfo("provinceCity_cn");
+				hotelBrands = 		redisHotelBrandDao.selectMessageInfo("hotelBrands_cn");
+				hotelSubBrands = 	redisHotelSubBrandDao.selectMessageInfo("hotelSubBrands_cn");
+				schoolList = 		redisLVResp.selectMessageInfo("schoolList_cn");
+				workYear = 			redisDPResp.selectMessageInfo("workYear_cn");
+				workStatus = 		redisDPResp.selectMessageInfo("workStatus_cn");
+				orderStatus = 		redisDPResp.selectMessageInfo("orderStatus_cn");
+				cvStatus = 			redisDPResp.selectMessageInfo("cvStatus_cn");
+				education = 		redisDPResp.selectMessageInfo("education_cn");
+				international = 	redisDPResp.selectMessageInfo("international_cn");
+				phoneCode = 		redisPhoneCodeResp.selectMessageInfo("phoneCode_cn");
+			}
+		} catch (Exception e) {
+			departmentsAndPositions = commonService.getDepartmentsAndPositions(lang);// 部门职位
+			provinceCityArea = areaService.getAllArea(lang);// 省市区
+			provinceCity = areaService.getAllProvinceAndCity(lang);// 省市
+			hotelBrands = mdeHotelBrandService.getAllHotelInternational(lang);// 酒店主品牌
+			hotelSubBrands = mdeHotelSubBrandService.getAllHotelSubBrandInternational(lang);// 酒店子品牌
+			hotelCompanys = mdeHotelCompanyService.getAllHotelCompanyInternational();// 酒店公司
+			schoolList = commonService.getSchoolList("cn");// 学校列表
+			workYear = commonService.getDictByType("job_year",lang);// 工作年限
+			workStatus = commonService.getDictByType("work_status",lang);// 工作状态
+			orderStatus = commonService.getDictByType("order_status",lang);// 订单状态
+			cvStatus = commonService.getDictByType("cv_status",lang);// 简历投递状态
+			education = commonService.getDictByType("education",lang);// 学历
+			international = commonService.getDictByType("international",lang);// 国际区分
+			phoneCode = commonService.getPhoneCode("phone_code", lang);// 国家码
+		}
+		map.put("departmentsAndPositions", departmentsAndPositions);
+		map.put("provinceCityArea", provinceCityArea);
+		map.put("provinceCity", provinceCity);
+		map.put("hotelBrands", hotelBrands);
+		map.put("hotelSubBrands", hotelSubBrands);
+		map.put("hotelCompanys", hotelCompanys);
+		map.put("schoolList", schoolList);
+		map.put("workYear", workYear);
+		map.put("workStatus", workStatus);
+		map.put("orderStatus", orderStatus);
+		map.put("cvStatus", cvStatus);
+		map.put("education", education);
+		map.put("international", international);
+		map.put("phoneCode", phoneCode);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	
+	 /**
+     * 获取基础数据-注册用
+     * 
+     */
+	@RequestMapping(value = "getBaseDataForRegister", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getBaseDataForRegister(HttpServletRequest request) {
+		String lang = commonService.getLanguage(request);
+		Map<String, Object> map = new HashMap<String, Object>();
+		List<HotelBrandDto> hotelBrands = null;// 酒店主品牌
+		List<DPResp> international = null;// 国际区分
+		List<PhoneCodeResp> phoneCode = null;// 国家码
+		// 判断redis中的基础数据是否过期
+		if(!redisDao.hasKey("departmentsAndPositions_en")) {
+			init.init();
+		}
+		try {
+			if(lang.equalsIgnoreCase("en")) {
+				hotelBrands = 		redisHotelBrandDao.selectMessageInfo("hotelBrands_en");
+				international = 	redisDPResp.selectMessageInfo("international_en");
+				phoneCode = 		redisPhoneCodeResp.selectMessageInfo("phoneCode_en");
+			}else {
+				hotelBrands = 		redisHotelBrandDao.selectMessageInfo("hotelBrands_cn");
+				international = 	redisDPResp.selectMessageInfo("international_cn");
+				phoneCode = 		redisPhoneCodeResp.selectMessageInfo("phoneCode_cn");
+			}
+		} catch (Exception e) {
+			hotelBrands = mdeHotelBrandService.getAllHotelInternational(lang);// 酒店主品牌
+			international = commonService.getDictByType("international",lang);// 国际区分
+			phoneCode = commonService.getPhoneCode("phone_code", lang);// 国家码
+		}
+		map.put("hotelBrands", hotelBrands);
+		map.put("international", international);
+		map.put("phoneCode", phoneCode);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	
+	 /**
+     * 获取基础数据-填写工作经验
+     * 
+     */
+	@RequestMapping(value = "getBaseDataForExp", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getBaseDataForExp(HttpServletRequest request) {
+		String lang = commonService.getLanguage(request);
+		Map<String, Object> map = new HashMap<String, Object>();
+		List<HotelCompanyResp> hotelCompanys = null;// 酒店公司
+		List<LVResp> schoolList = null;// 学校列表
+		List<DPResp> education = null;// 学历
+		// 判断redis中的基础数据是否过期
+		if(!redisDao.hasKey("departmentsAndPositions_en")) {
+			init.init();
+		}
+		try {
+            hotelCompanys =     redisHotelCompanyDao.selectMessageInfo("hotelCompanys");
+			if(lang.equalsIgnoreCase("en")) {
+				schoolList = 		redisLVResp.selectMessageInfo("schoolList_en");
+				education = 		redisDPResp.selectMessageInfo("education_en");
+			}else {
+				schoolList = 		redisLVResp.selectMessageInfo("schoolList_cn");
+				education = 		redisDPResp.selectMessageInfo("education_cn");
+			}
+		} catch (Exception e) {
+			hotelCompanys = mdeHotelCompanyService.getAllHotelCompanyInternational();// 酒店公司
+			schoolList = commonService.getSchoolList(lang);// 学校列表
+			education = commonService.getDictByType("education",lang);// 学历
+		}
+		map.put("hotelCompanys", hotelCompanys);
+		map.put("schoolList", schoolList);
+		map.put("education", education);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+
+
+	/**
+	 * 酒店品牌列表(主)
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "getAllHotelInternational", method = RequestMethod.POST)
+	@ResponseBody
+	public List<HotelBrandDto> getAllHotelInternational(HttpServletRequest req, HttpServletResponse resp) {
+		String language = commonService.getLanguage(req);
+		return mdeHotelBrandService.getAllHotelInternational(language);
+	}
+	/**
+	 * 酒店品牌列表(子)
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "getAllHotelSubInternational", method = RequestMethod.POST)
+	@ResponseBody
+	public List<HotelSubBrandDto> getAllHotelSubBrandInternational(HttpServletRequest req, HttpServletResponse resp) {
+		String language = commonService.getLanguage(req);
+		return mdeHotelSubBrandService.getAllHotelSubBrandInternational(language);
+	}
+	
+	/**
+	 * 导入 省市 json 数据 
+	 * @param req
+	 * @param resp
+	 * @return
+	 */
+//	@RequestMapping(value = "getaaa", method = RequestMethod.POST)
+//	@ResponseBody
+//	public String getaaa(HttpServletRequest req, HttpServletResponse resp) {
+//		String language = commonService.getLanguage(req);
+//		return areaService.importEn();
+//	}
+
+	/**
+	 * 文件下载
+	 * 
+	 * @param filePath
+	 * @param response
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "/downloadFile", method = RequestMethod.GET)
+	public void downloadFile(@RequestParam String filePath, HttpServletResponse response) throws Exception {
+
+		InputStream in = null;
+		OutputStream os = null;
+		try {
+			if(filePath.indexOf(domainUrl)>=0) {
+				filePath = filePath.substring(filePath.indexOf(domainUrl)+domainUrl.length());
+			}
+			// 获取文件
+			File file = new File(basePackagePath + filePath);
+			if (!file.exists()) {
+				return;
+			}
+			// 设置 返回消息
+			response.setContentType("application/octet-stream; charset=utf-8");// application/bytes
+																				// application/octet-stream video/mp4
+			response.setHeader("Content-Disposition", "inline;fileName=" + URLEncoder.encode(filePath, "utf-8"));
+			response.addHeader("Content-Length", "" + file.length());
+			in = new FileInputStream(file);
+			os = response.getOutputStream();
+			byte[] b = new byte[2048];
+			int length;
+			while ((length = in.read(b)) > 0) {
+				os.write(b, 0, length);
+			}
+		} catch (Exception e) {
+			log.error("文件下载异常",e);
+			e.fillInStackTrace();
+		} finally {
+			if (in != null)
+				in.close();
+			if (os != null)
+				os.close();
+		}
+	}
+
+	/**
+	 * 可能认识的人
+	 * @param req
+	 * @return
+	 */
+	@RequestMapping(value = "getMaybeFriends")
+	@ResponseBody
+	public ResultEntity<List<MdeUser>> getMaybeFriends (HttpServletRequest req) {
+		String userCode = commonService.getUserCode(req);
+		String identityFlag = commonService.getIdentityFlag(req);
+		String lang = commonService.getLanguage(req);
+		List<MdeUser> maybeFriends = commonService.getMaybeFriends(userCode,identityFlag,lang);
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST,maybeFriends);
+	}
+	
+	/**
+	 * 优选人才列表
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return
+	 */
+	@RequestMapping(value = "getRecommentPeople", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<MdeUser>> getRecommentPeople(HttpServletRequest req, HttpServletResponse resp) {
+		List<MdeUser> recommentPeoplListe = commonService.getRecommentPeople(commonService.getUserCode(req));
+		return new ResultEntity<List<MdeUser>>(InfoMsg.SUCCESS_REQUEST, recommentPeoplListe);
+	}
+	
+	/**
+	 * 可能认识的人
+	 * @param req
+	 * @return
+	 */
+	@RequestMapping(value = "getMaybeFriend", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<MdeUser>> getMaybeFriend(HttpServletRequest req, HttpServletResponse resp) {
+		String userCode = commonService.getUserCode(req);
+		String identityFlag = commonService.getIdentityFlag(req);
+		String lang = commonService.getLanguage(req);
+		List<MdeUser> recommentPeoplListe = commonService.getMaybeFriends(userCode,identityFlag,lang);
+		return new ResultEntity<List<MdeUser>>(InfoMsg.SUCCESS_REQUEST, recommentPeoplListe);
+	}
+
+	/**
+	 * 获取学校列表
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return
+	 */
+	@RequestMapping(value = "getSchoolList", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<LVResp>> getSchoolList(HttpServletRequest request) {
+		String lang = commonService.getLanguage(request);
+		List<LVResp> list = commonService.getSchoolList(lang);
+		return new ResultEntity<List<LVResp>>(InfoMsg.SUCCESS_REQUEST, list);
+	}
+	/**
+	 * 获取广告图片
+	 * @param request
+	 * @param adType
+	 * @return
+	 */
+	@RequestMapping(value = "getAdImage", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<AdImageDto>> getAdImage(HttpServletRequest request,@RequestParam String adType) {
+		List<AdImageDto> list = commonService.getAdImages(adType);
+		return new ResultEntity<List<AdImageDto>>(InfoMsg.SUCCESS_REQUEST, list);
+	}
+	
+	/**
+	 * 记录广告浏览历史
+	 * @param request
+	 * @param adId
+	 * @return
+	 */
+	@RequestMapping(value = "lookOverAd", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Integer> lookOverAd(HttpServletRequest request,@RequestBody AdReq adReq) {
+		return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST, commonService.lookOverAd(adReq));
+	}
+	
+	/**
+	 * 清除基础数据缓存
+	 * @return
+	 */
+	@RequestMapping(value = "resetBaseData", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Integer> resetBaseData(HttpServletRequest request,@RequestParam String mm) {
+		//密码验证
+		if(Md5Utils.EncoderPassword("B5oT$6X&oqAjcrvO").endsWith(mm)){
+			redisDao.delete("departmentsAndPositions_en");
+			return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST);
+		}
+		return new ResultEntity<Integer>(InfoMsg.ERROR_EMPTY_REQUEST);
+	}
+	
+	/**
+	 * 获取登陆首页广告图片
+	 * @param request
+	 * @param adType
+	 * @return
+	 */
+	@RequestMapping(value = "getLoginAdImage", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<OpenAdResq> getLoginAdImage() {
+		OpenAdResq resp = new OpenAdResq();
+		List<AdImageDto> pcList = new ArrayList<AdImageDto>();
+		List<AdImageDto> sjList = new ArrayList<AdImageDto>();
+		AdImageDto adDto = commonService.getAdImage(Constants.PC_OPEN_CN);
+		pcList.add(adDto);
+		pcList.add(commonService.getAdImage(Constants.PC_OPEN_EN));
+		sjList.add(commonService.getAdImage(Constants.SJ_OPEN_CN));
+		sjList.add(commonService.getAdImage(Constants.SJ_OPEN_EN));
+		if(adDto.getUpdateDate() != null)
+		{
+			resp.setAdCode(String.valueOf(adDto.getUpdateDate().getTime()));
+		}
+		resp.setAdListPc(pcList);
+		resp.setAdListPhone(sjList);
+		
+		return new ResultEntity<OpenAdResq>(InfoMsg.SUCCESS_REQUEST, resp);
+	}
+
+	/**
+	 * 获取部门和职位
+	 * 
+	 */
+	@RequestMapping(value = "getDepartmentsAndPositions", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getPositions(HttpServletRequest request) {
+		String lang = commonService.getLanguage(request);
+		Map<String, Object> map = new HashMap<String, Object>();
+		String departmentsAndPositions = null;// 部门职位
+		// 判断redis中的基础数据是否过期
+		if(!redisDao.hasKey("departmentsAndPositions_en")) {
+			init.init();
+		}
+		try {
+			if(lang.equalsIgnoreCase("en")) {
+				departmentsAndPositions = redisDao.select("departmentsAndPositions_en");
+			}else {
+				departmentsAndPositions = redisDao.select("departmentsAndPositions_cn");
+			}
+		} catch (Exception e) {
+			departmentsAndPositions = commonService.getDepartmentsAndPositions(lang);// 部门职位
+		}
+		map.put("departmentsAndPositions", departmentsAndPositions);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	/**
+	 * 获取省市区
+	 * 
+	 */
+	@RequestMapping(value = "getProvinceCityArea", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getProvinceCityArea(HttpServletRequest request) {
+		String lang = commonService.getLanguage(request);
+		Map<String, Object> map = new HashMap<String, Object>();
+		List<Province> provinceCityArea = null;// 省市区
+		List<Province> provinceCity = null;// 省市
+		// 判断redis中的基础数据是否过期
+		if(!redisDao.hasKey("departmentsAndPositions_en")) {
+			init.init();
+		}
+		try {
+			if(lang.equalsIgnoreCase("en")) {
+				provinceCityArea = 	redisProvinceCityDao.selectMessageInfo("provinceCityArea_en");
+				provinceCity = 		redisProvinceCityDao.selectMessageInfo("provinceCity_en");
+			}else {
+				provinceCityArea = 	redisProvinceCityDao.selectMessageInfo("provinceCityArea_cn");
+				provinceCity = 		redisProvinceCityDao.selectMessageInfo("provinceCity_cn");
+			}
+		} catch (Exception e) {
+			provinceCityArea = areaService.getAllArea(lang);// 省市区
+			provinceCity = areaService.getAllProvinceAndCity(lang);// 省市
+		}
+		map.put("provinceCityArea", provinceCityArea);
+		map.put("provinceCity", provinceCity);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	/**
+	 * 获取酒店公司名称
+	 * 
+	 */
+	@RequestMapping(value = "getHotelCompanys", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getHotelCompanys(HttpServletRequest request) {
+		Map<String, Object> map = new HashMap<String, Object>();
+		List<HotelCompanyResp> hotelCompanys = null;// 酒店公司
+		// 判断redis中的基础数据是否过期
+		if(!redisDao.hasKey("departmentsAndPositions_en")) {
+			init.init();
+		}
+		try {
+            hotelCompanys =     redisHotelCompanyDao.selectMessageInfo("hotelCompanys");
+		} catch (Exception e) {
+			hotelCompanys = mdeHotelCompanyService.getAllHotelCompanyInternational();// 酒店公司
+		}
+		map.put("hotelCompanys", hotelCompanys);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	/**
+	 * 获取酒店品牌
+	 * 
+	 */
+	@RequestMapping(value = "getHotelBrands", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getHotelBrands(HttpServletRequest request) {
+		String lang = commonService.getLanguage(request);
+		Map<String, Object> map = new HashMap<String, Object>();
+		List<HotelBrandDto> hotelBrands = null;// 酒店主品牌
+		List<HotelSubBrandDto> hotelSubBrands = null;// 酒店子品牌
+		// 判断redis中的基础数据是否过期
+		if(!redisDao.hasKey("departmentsAndPositions_en")) {
+			init.init();
+		}
+		try {
+			if(lang.equalsIgnoreCase("en")) {
+				hotelBrands = 		redisHotelBrandDao.selectMessageInfo("hotelBrands_en");
+				hotelSubBrands = 	redisHotelSubBrandDao.selectMessageInfo("hotelSubBrands_en");
+			}else {
+				hotelBrands = 		redisHotelBrandDao.selectMessageInfo("hotelBrands_cn");
+				hotelSubBrands = 	redisHotelSubBrandDao.selectMessageInfo("hotelSubBrands_cn");
+			}
+		} catch (Exception e) {
+			hotelBrands = mdeHotelBrandService.getAllHotelInternational(lang);// 酒店主品牌
+			hotelSubBrands = mdeHotelSubBrandService.getAllHotelSubBrandInternational(lang);// 酒店子品牌
+		}
+		map.put("hotelBrands", hotelBrands);
+		map.put("hotelSubBrands", hotelSubBrands);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	
+	/**
+	 * 获取工作年限和学历
+	 * 
+	 */
+	@RequestMapping(value = "getWorkYearAndEducation", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getWorkYearAndEducation(HttpServletRequest request) {
+		String lang = commonService.getLanguage(request);
+		Map<String, Object> map = new HashMap<String, Object>();
+		List<DPResp> workYear = null;// 工作年限
+		List<DPResp> education = null;// 学历
+		// 判断redis中的基础数据是否过期
+		if(!redisDao.hasKey("departmentsAndPositions_en")) {
+			init.init();
+		}
+		try {
+			if(lang.equalsIgnoreCase("en")) {
+				workYear = 			redisDPResp.selectMessageInfo("workYear_en");
+				education = 		redisDPResp.selectMessageInfo("education_en");
+			}else {
+				workYear = 			redisDPResp.selectMessageInfo("workYear_cn");
+				education = 		redisDPResp.selectMessageInfo("education_cn");
+			}
+		} catch (Exception e) {
+			workYear = commonService.getDictByType("job_year",lang);// 工作年限
+			education = commonService.getDictByType("education",lang);// 学历
+		}
+		map.put("workYear", workYear);
+		map.put("education", education);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+
+	/**
+	 * 获取简历投递状态
+	 * 
+	 */
+	@RequestMapping(value = "getCvStatus", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getCvStatus(HttpServletRequest request) {
+		String lang = commonService.getLanguage(request);
+		Map<String, Object> map = new HashMap<String, Object>();
+		List<DPResp> cvStatus = null;// 简历投递状态
+		// 判断redis中的基础数据是否过期
+		if(!redisDao.hasKey("departmentsAndPositions_en")) {
+			init.init();
+		}
+		try {
+			if(lang.equalsIgnoreCase("en")) {
+				cvStatus = 			redisDPResp.selectMessageInfo("cvStatus_en");
+			}else {
+				cvStatus = 			redisDPResp.selectMessageInfo("cvStatus_cn");
+			}
+		} catch (Exception e) {
+			cvStatus = commonService.getDictByType("cv_status",lang);// 简历投递状态
+		}
+		map.put("cvStatus", cvStatus);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	
+	/**
+	 * 获取标准时间
+	 * 
+	 */
+	@RequestMapping(value = "getStandardTime", method = RequestMethod.GET)
+	@ResponseBody
+	public Date getStandardTime(HttpServletRequest request) {
+		return new Date();
+	}
+	
+	/**
+	 * 获取拉新活动id
+	 * 
+	 */
+	@RequestMapping(value = "getActId", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<String> getActId(HttpServletRequest request) {
+		ResultEntity<String> rest = new ResultEntity<String>();
+		String actId = commonService.getActId();
+		if(StringsUtils.isEmpty(actId))
+		{
+			rest.setMsg(InfoMsg.ERROR_SYSTEM_ERROR);
+		} 
+		rest.setResult(actId);
+		return rest;
+	}
+	
+	/**
+	 * 获取职位详情底部广告图片
+	 * @param request
+	 * @param adType
+	 * @return
+	 */
+	@RequestMapping(value = "getAdOfJobDtl", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<AdImageDto>> getAdOfJobDtl(HttpServletRequest request,@RequestParam String adType) {
+		
+		List<AdImageDto> list = new ArrayList<AdImageDto>();
+		if(Constants.SJ_POSITION_DTL.equals(adType) || Constants.PC_POSITION_DETAIL_BOTTOM_AD.equals(adType))
+		{
+			list = commonService.getAdImages(adType);
+		}
+		 
+		return new ResultEntity<List<AdImageDto>>(InfoMsg.SUCCESS_REQUEST, list);
+	}
+	
+	
+	/**
+	 * 获取酒店类型下拉列表
+	 * 
+	 */
+	@RequestMapping(value = "getPrepareFlagList", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<DPResp>> getPrepareFlagList(HttpServletRequest request) {
+		ResultEntity<List<DPResp>> rest = new ResultEntity<List<DPResp>>();
+		List<DPResp> prepareFlagList = commonService.getDictByType("prepare_flag",request);
+		rest.setResult(prepareFlagList);
+		return rest;
+	}
+
+	/**
+	 * 获取职位发布时间下拉列表
+	 * 
+	 */
+	@RequestMapping(value = "getPositionPubTList", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<DPResp>> getPositionPubTList(HttpServletRequest request) {
+		ResultEntity<List<DPResp>> rest = new ResultEntity<List<DPResp>>();
+		List<DPResp> prepareFlagList = commonService.getDictByType("position_publish_time",request);
+		rest.setResult(prepareFlagList);
+		return rest;
+	}
+	
+	/**
+	 * 广告点击量记录
+	 * @return
+	 */
+	@RequestMapping(value="setAdCtrs", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> setAdCtrs(@RequestBody List<AdCtrReq> adCtrReqList,HttpServletRequest request){
+		ResultEntity<String> rest = new ResultEntity<String>();
+		int result = 0;
+		for(AdCtrReq adCtrReq : adCtrReqList) {
+			//记录广告点击率
+			result = result+ adImagesService.recodeAdCtr(adCtrReq);
+		}
+		if(result > 0) {
+			rest.setMsg(InfoMsg.ERROR_SAVE_FIELD);
+		};
+
+		return rest;
+	}
+}

+ 213 - 0
src/main/java/com/wechat/controller/EnterpriseController.java

@@ -0,0 +1,213 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.requestDto.InterviewCreateReq;
+import com.wechat.model.requestDto.JobAdvertisedReqDto;
+import com.wechat.model.requestDto.UpdUserCvReq;
+import com.wechat.model.requestDto.UserCvByJobReq;
+import com.wechat.model.requestDto.UserCvStatusReq;
+import com.wechat.model.responseDto.AlreadyPublishResp;
+import com.wechat.model.responseDto.ContactUserInfoResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.EnterpriseService;
+import com.wechat.service.MdeJobAdvertisedService;
+
+/**
+ * 企业查看简历
+ * 
+ * @author zhouyd
+ *
+ */
+@Controller
+@RequestMapping(value = "enterprise")
+public class EnterpriseController{
+
+	@Autowired
+	private EnterpriseService enterpriseService;
+	@Autowired
+	private CommonService commonService;
+	@Resource
+	private MdeJobAdvertisedService jobAdvertisedService;
+	/**
+	 * 企业点击收到的简历
+	 * 
+	 * @return
+	 * @throws Exception
+	 */
+/*	@RequestMapping(value = "receive", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> receiveUserCv(HttpServletRequest req, HttpServletResponse resp,
+			@RequestBody Page page) throws Exception {
+
+		Map<String, Object> maps = enterpriseService.receiveUserCv(req, page);
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, maps);
+	}*/
+
+	/**
+	 * 查看简历
+	 * 
+	 * @param userCode
+	 * @return
+	 */
+	@RequestMapping(value = "lookUserCv", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<ContactUserInfoResp> lookUserCv(@RequestBody Map<String, String> param,HttpServletRequest req) {
+		String lang = commonService.getLanguage(req);
+		String hotelCode = commonService.getUserCode(req);
+		ContactUserInfoResp contactUserInfoResp = enterpriseService.lookUserCv(hotelCode,param,lang);
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, contactUserInfoResp);
+	}
+
+	/**
+	 * 更新职位发布状态
+	 * 
+	 * @param req
+	 * @param resp
+	 * @param params
+	 * @return
+	 * @throws Exception 
+	 */
+	@RequestMapping(value = "updateJobAdvertisedStatus", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> updateJobAdvertisedStatus(HttpServletRequest req, HttpServletResponse resp,
+			@RequestBody Map<String, String> params) throws Exception {
+		return enterpriseService.updateJobAdvertisedStatus(req,params);
+	}
+	
+	/**
+	 * 更新职位首推状态
+	 * 
+	 * @param req
+	 * @param resp
+	 * @param params
+	 * @return
+	 */
+	@RequestMapping(value = "updateJobRecommend", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> updateJobRecommend(HttpServletRequest req, HttpServletResponse resp,
+			@RequestBody Map<String, String> params) {
+		return enterpriseService.updateJobRecommend(req,params);
+	}
+
+	/**
+	 * 下载简历
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return
+	 * @throws IOException 
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "download", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> downloadUserCv(HttpServletRequest req, HttpServletResponse resp,
+			@RequestBody Map<String, Object> param) {
+		String infoMsg = enterpriseService.downloadUserCv(req, resp, param);
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST,infoMsg);
+	}
+
+	/**
+	 * 切换简历类型 根据类型判断 ( 0-新投递;1-已查看;2-已下载;3-邀请面试;4-录取;5-淘汰;6-储备)
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "getUserCvStateListInfo", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getUserCvStateListInfo(HttpServletRequest req,
+			@Valid @RequestBody UserCvStatusReq param) {
+		Map<String, Object> maps = enterpriseService.getUserCvStateListInfo2(req, param, "0");
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, maps);
+	}
+	
+	/**
+	 * PC端专用
+	 * 切换简历类型 根据类型判断 ( 0-新投递;1-已查看;2-已下载;3-邀请面试;4-录取;5-淘汰;6-储备)
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "getUserCvStateListInfoPc", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getUserCvStateListInfoPc(HttpServletRequest req,
+			@Valid @RequestBody UserCvStatusReq param) {
+		Map<String, Object> maps = enterpriseService.getUserCvStateListInfo2(req, param, "1");
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, maps);
+	}
+	
+	/**
+	 * PC端专用
+	 *   按职位显示投递列表 
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "getUserCvListInfoByJobPc", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getUserCvListInfoByJobPc(HttpServletRequest req,
+			 @RequestBody UserCvByJobReq param) {
+		Map<String, Object> maps = enterpriseService.getUserCvStateListInfoByJob(req, param, "1");
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, maps);
+	}
+
+
+	/**
+	 * 邀请面试/录用/淘汰 更新简历状态 type ( 0-新投递;1-已查看;2-已下载;3-邀请面试;4-录取;5-淘汰;6-储备)
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "updateUserCvStatus", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> updateUserCvStatus(HttpServletRequest req, @RequestBody UpdUserCvReq param)
+			throws Exception {
+		InfoMsg infoMsg = enterpriseService.updateUserCvStatus(req, param, new InterviewCreateReq());
+		return new ResultEntity<>(infoMsg);
+	}
+
+	/**
+	 * 已发布信息
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return
+	 */
+	@RequestMapping(value = "alreadyPublish", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<AlreadyPublishResp> alreadyPublish (@RequestBody JobAdvertisedReqDto jobReq,
+			HttpServletRequest req, HttpServletResponse resp) {
+		String userCode = commonService.getUserCode(req);
+		AlreadyPublishResp response = new AlreadyPublishResp();
+		// 获取已发布职位信息
+		response.setList(enterpriseService.alreadyPublish(req, resp, userCode,jobReq));
+		// 获取首推数据
+		response.setRecommendNum(jobAdvertisedService.getAvailableAndUsedCount(userCode));
+
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, response);
+	}
+
+}

+ 81 - 0
src/main/java/com/wechat/controller/FaqController.java

@@ -0,0 +1,81 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.alibaba.fastjson.JSON;
+import com.wechat.callback.tencentrequests.UserSentTextRequest;
+import com.wechat.common.utils.MvcUtil;
+import com.wechat.global.base.BaseController;
+import com.wechat.model.dbEntity.TdtgFaqInfo;
+import com.wechat.model.responseDto.JsonResp;
+import com.wechat.service.FaqService;
+
+
+/**
+ * FAQ问答
+ * 
+ */
+@Controller
+@RequestMapping("faq")
+public class FaqController extends BaseController {
+
+    @Resource
+    private FaqService faqService;
+
+    /**
+     * 通过用户发送的信息,取得FAQ的问题
+     * 
+     * @param userSentTextRequest 用户发送的信息
+     */
+    @RequestMapping(value = "getFaqInfo", method = RequestMethod.POST)
+	public void getFaqInfoByMsg(@RequestBody UserSentTextRequest userSentTextRequest, HttpServletRequest request, HttpServletResponse response)
+			throws Exception {
+		JsonResp<TdtgFaqInfo> ret = new JsonResp<TdtgFaqInfo>();
+		// 通过用户发送的信息,检索FAQ内容
+		TdtgFaqInfo faqInfo = faqService.getInfoByKeyWord(userSentTextRequest.getContent());
+		ret.setInfo(faqInfo);
+		
+		String json = JSON.toJSONString(ret, true);
+        try {
+            MvcUtil.writeJson(request, response, json);
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+           log.error(e);
+        }
+
+	}
+    
+    /**
+     * FAQ信息取得ID查询
+     * 
+     * @param int ID信息
+     */
+    @RequestMapping(value = "getFaqInfoById", method = RequestMethod.GET)
+    public void getFaqInfoById(@RequestParam int id, HttpServletRequest request, HttpServletResponse response)throws Exception {
+        JsonResp<String> ret = new JsonResp<String>();
+        TdtgFaqInfo faqInfo = faqService.getInfoById(id);
+        if(faqInfo != null)
+        {
+        	ret.setInfo(faqInfo.getNewsContent());
+        }
+        
+    	String json = JSON.toJSONString(ret, true);
+        try {
+            MvcUtil.writeJson(request, response, json);
+        } catch (IOException e) {
+           log.error(e);
+        }
+    }
+
+
+}

+ 53 - 0
src/main/java/com/wechat/controller/ForgetPasswordController.java

@@ -0,0 +1,53 @@
+package com.wechat.controller;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.alibaba.fastjson.JSONObject;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.ForgetPasswordService;
+
+@Controller
+@RequestMapping("forgetPassword")
+public class ForgetPasswordController {
+
+	@Autowired
+	private ForgetPasswordService forgetPasswordService;
+
+//	@Autowired
+//	private VerificationCodeService verificationCodeService;
+
+	/**
+	 * @author zhouyd 忘记密码
+	 * 
+	 * @param request
+	 * @param response
+	 * 
+	 */
+	@RequestMapping(value = "forgetPassword", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> forgetPassword(HttpServletRequest request, HttpServletResponse response)
+			throws Exception {
+
+		BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
+		String line;
+		StringBuilder sb = new StringBuilder();
+		while ((line = br.readLine()) != null) {
+			sb.append(line);
+		}
+		JSONObject jo = JSONObject.parseObject(sb.toString());
+		// 修改密码
+
+		return forgetPasswordService.forgetPassWord(jo, request);
+	}
+
+}

+ 203 - 0
src/main/java/com/wechat/controller/GoodsController.java

@@ -0,0 +1,203 @@
+package com.wechat.controller;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeAddress;
+import com.wechat.model.dto.AddressesDto;
+import com.wechat.model.dto.GoodsDetailDto;
+import com.wechat.model.dto.GoodsListDto;
+import com.wechat.model.dto.UpTimeGroupDto;
+import com.wechat.model.responseDto.GoodsListInitResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeAddressService;
+import com.wechat.service.MdeGoodsService;
+
+@Controller
+@RequestMapping(value = "goods")
+public class GoodsController {
+
+	@Autowired
+	MdeGoodsService goodService;
+	
+	@Autowired
+	MdeAddressService  addressService;
+
+	@Autowired
+	CommonService commonService;
+
+	/**
+	 * 商品列表页初始化
+	 * @return
+	 */
+	@RequestMapping(value = "init", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<GoodsListInitResp> initGoodsPage(HttpServletRequest request) {
+		ResultEntity<GoodsListInitResp> result = new ResultEntity<GoodsListInitResp>();
+		GoodsListInitResp resp = new GoodsListInitResp();
+		
+		String lang = commonService.getLanguage(request);
+		
+		//获取上架时间分组
+		List<UpTimeGroupDto> upTimeGroupList = goodService.getUpTimeGroup();
+		
+		// 获取显示的上架时间
+		UpTimeGroupDto showTimeDto = goodService.getUpTimeShow();
+		Date showTime = null;
+		
+		// 根据上架时间和上架状态获取商品列表
+		List<GoodsListDto> goodsList = new ArrayList<GoodsListDto>();
+		if(showTimeDto != null)
+		{
+			//有当天的场次的情况
+			showTime = showTimeDto.getUpTime();
+			goodsList = goodService.getGoodsListByUpTime(showTime,showTimeDto.getOnSale(), lang);
+		} else if(upTimeGroupList != null){
+			//当天的在售和热销都没有的情况
+			showTime = upTimeGroupList.get(0).getUpTime();
+			goodsList = goodService.getGoodsListByUpTime(null,upTimeGroupList.get(0).getOnSale(), lang);
+		}
+		
+		//商品销量赋值
+		goodService.setGoodsSale(goodsList);
+		
+		//结果封装
+		resp.setUpTimeGroupList(upTimeGroupList);
+		resp.setShowTime(showTime);
+		resp.setGoodsList(goodsList);
+		resp.setStandardTime(new Date());
+		result.setResult(resp);
+		return result;
+	}
+	
+	/**
+	 * 商品列表页查询
+	 * @return
+	 */
+	@RequestMapping(value = "getPartOfGoodsList", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<List<GoodsListDto>> getPartOfGoodsList(HttpServletRequest request,@RequestBody UpTimeGroupDto upTimeReq) {
+		ResultEntity<List<GoodsListDto>> result = new ResultEntity<List<GoodsListDto>>();
+		String lang = commonService.getLanguage(request);
+		
+		// 根据上架时间和上架状态获取商品列表
+		List<GoodsListDto> goodsList = new ArrayList<GoodsListDto>();
+		String onSale = upTimeReq.getOnSale();
+		if(StringsUtils.isEmpty(onSale) ||(!"1".equals(onSale)&& !"2".equals(onSale)))
+		{
+			result.setMsg(InfoMsg.ERROR_PARAMS_ERROR);
+		}else {
+			goodsList =  goodService.getGoodsListByUpTime(upTimeReq.getUpTime(),onSale, lang);
+		}
+
+		//商品销量赋值
+		goodService.setGoodsSale(goodsList);
+		
+		//结果封装
+		result.setResult(goodsList);
+		return result;
+	}
+	
+	/**
+	 *  商品详情查询
+	 * @return
+	 */
+	@RequestMapping(value = "getGoodsDetail", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<GoodsDetailDto> getGoodsDetail(HttpServletRequest request,@RequestParam int goodsId) {
+		ResultEntity<GoodsDetailDto> result = new ResultEntity<GoodsDetailDto>();
+		String lang = commonService.getLanguage(request);
+		
+		// 获取商品详情
+		GoodsDetailDto goodsDetail = goodService.getGoodsInfo(goodsId, lang);
+		//结果封装
+		result.setResult(goodsDetail);
+		return result;
+	}
+	
+	/**
+	 *  根据用户id查询配送地址
+	 * @return
+	 */
+	@RequestMapping(value = "getAddressesByUser", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<AddressesDto>> getAddressesByUser(HttpServletRequest request) {
+		ResultEntity<List<AddressesDto>> result = new ResultEntity<List<AddressesDto>>();
+		String userid = commonService.getUserCode(request);
+		
+		// 获取配送地址
+		List<AddressesDto> adds = addressService.getAddressesByUser(userid);
+		//结果封装
+		result.setResult(adds);
+		return result;
+	}
+	
+	
+	/**
+	 *  新增、修改查询地址
+	 * @return
+	 */
+	@RequestMapping(value = "updAddress", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Integer> updAddress(HttpServletRequest request,@RequestBody AddressesDto addDto) {
+		ResultEntity<Integer> result = new ResultEntity<Integer>();
+		String userId = commonService.getUserCode(request);
+
+		//将entity和入参相同属性复制至entity中
+		MdeAddress entity = new MdeAddress();
+		BeanUtils.copyProperties(addDto, entity);
+		entity.setUserId(userId);
+		
+		int count = addressService.updAddress(entity);
+		if(count < 1)
+		{
+			result.setMsg(InfoMsg.ERROR_DATA_UPDATE);
+		}
+		
+		//返回主key
+		result.setResult(entity.getAddId());
+		return result;
+	}
+	
+
+	/**
+	 *删除 用户地址
+	 * 
+	 * @param addId 地址id
+	 */
+	@RequestMapping(value = "delAddress", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> deleteOrderByUser(@RequestParam Integer addId, HttpServletRequest req){
+		ResultEntity<String> result = new ResultEntity<String>();
+		String userCode = commonService.getUserCode(req);
+		int count = 0;
+		if(addId == null) {
+			result.setMsg(InfoMsg.ERROR_EMPTY_REQUEST);
+		} else {
+			count = addressService.delete(addId, userCode);
+		}
+		
+		if (count < 1)
+		{
+			result.setMsg(InfoMsg.ERROR_DATA_UPDATE);
+		}
+		
+		return result;
+	}
+
+}

+ 153 - 0
src/main/java/com/wechat/controller/GroupController.java

@@ -0,0 +1,153 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.alibaba.fastjson.JSON;
+import com.wechat.common.Constants;
+import com.wechat.common.utils.MvcUtil;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dto.WxUserInfoDto;
+import com.wechat.model.responseDto.JsonResp;
+import com.wechat.service.GroupService;
+import com.wechat.service.WeiXinService;
+
+
+/**
+ * FAQ问答
+ * 
+ */
+@Controller
+@RequestMapping("group")
+public class GroupController extends BaseController {
+
+    //菜单设置
+    @Value("#{configProperties['weixin.menu']}")
+    private String wxMenuUrl;
+    
+    @Resource
+    private WeiXinService wxService;
+    
+    @Resource
+    private GroupService groupService;
+    
+    /**
+     * 验证用户是否关注公众号
+     * 
+     * @param userSentTextRequest 用户发送的信息
+     */
+    @RequestMapping(value = "isSubscribe", method = RequestMethod.POST)
+    public void isSubscribe(@RequestParam String openId, HttpServletRequest request, HttpServletResponse response) throws Exception{
+        JsonResp<String> ret = new JsonResp<String>();
+        //通过openid,检索用户信息
+        WxUserInfoDto userInfo= wxService.getUserInfo(openId);
+        
+        if(userInfo != null)
+        {
+        	//token过期的情况
+        	if(StringsUtils.isEqual(userInfo.getErrorCode().toString(), Constants.STR_TOKEN_ERO))
+        	{
+        		//强制更新token
+        		wxService.updAccessTokenInfo();
+        		log.info("重取用户信息");
+        		//取得用户微信信息
+        		userInfo= wxService.getUserInfo(openId);
+        	}
+        	//取不到openid说明出错
+        	if(StringsUtils.isEmpty(userInfo.getOpenid()))
+        	{
+        		 log.error("isSubscribe 拉取用户信息异常!");
+                 log.error("errcode:【" + userInfo.getErrorCode() + "】");
+                 log.error("errmsg:【" + userInfo.getErrorMsg() + "】");
+             	 ret.setMsg(InfoMsg.ERROR_SYSTEM_ERROR);
+        	}
+        	else
+        	{
+            	//值为0时,代表此用户没有关注该公众号
+            	ret.setInfo(userInfo.getSubscribe());
+        	}
+        }
+        
+        String json = JSON.toJSONString(ret, true);
+        try {
+            MvcUtil.writeJson(request, response, json);
+        } catch (IOException e) {
+           log.error(e);
+        } 
+    }
+    
+    /**
+     * 微信菜单设置
+     * 
+     */
+    /*@RequestMapping(value = "setWechatMenu", method = RequestMethod.GET)
+    public void setWechatMenu(HttpServletRequest request, HttpServletResponse response) throws Exception{
+        JsonResp<String> ret = new JsonResp<String>();
+        JSONObject menuObj = groupService.getWechatMenu();
+    	//设置菜单
+        BaseResponse resp = NetworkUtils.getRemoteResponseAsJson(MessageUtils.getText(wxMenuUrl, wxService.getAccessToken()), menuObj,BaseResponse.class);
+
+        if (resp.getErrorCode() != 0) {
+            log.error(InfoMsg.ERROR_WECHAT_MENU.getMsg());
+            log.error("errcode:【" + resp.getErrorCode() + "】");
+            log.error("errmsg:【" + resp.getErrorMsg() + "】");
+            ret.setResult(Constants.RESULT_WARNING);
+            ret.setMsg(InfoMsg.ERROR_WECHAT_MENU);
+        }  
+
+        String json = JSON.toJSONString(ret, true);
+        try {
+            MvcUtil.writeJson(request, response, json);
+        } catch (IOException e) {
+           log.error(e);
+        } 
+    }*/
+
+    
+    /**
+     * 通过openid获取用户信息
+     * 
+     * @param userSentTextRequest 用户发送的信息
+     */
+    @RequestMapping(value = "getUserInfoByOpenid", method = RequestMethod.GET)
+	public void getUserInfoByOpenid(@RequestParam String openId, HttpServletRequest request,
+			HttpServletResponse response) throws Exception {
+		JsonResp<WxUserInfoDto> ret = new JsonResp<WxUserInfoDto>();
+		WxUserInfoDto wxUserInfoDto = new WxUserInfoDto();
+		// 通过开团id,检索参团用户
+		if (!StringsUtils.isEmpty(openId)) {
+			// 取得用户微信信息
+			wxUserInfoDto = wxService.getUserInfo(openId);
+			// token过期的情况
+			if (StringsUtils.isEqual(wxUserInfoDto.getErrorCode().toString(), Constants.STR_TOKEN_ERO)) {
+				// 强制更新token
+				wxService.updAccessTokenInfo();
+				log.info("重取用户头像列表");
+				// 取得用户微信信息
+				wxUserInfoDto = wxService.getUserInfo(openId);
+			}
+		}
+
+		// 数据返回
+		ret.setInfo(wxUserInfoDto);
+
+		String json = JSON.toJSONString(ret, true);
+		try {
+			MvcUtil.writeJson(request, response, json);
+		} catch (IOException e) {
+			log.error(e);
+		}
+	}
+    
+}

+ 191 - 0
src/main/java/com/wechat/controller/HumanVeinController.java

@@ -0,0 +1,191 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.base.dao.PagingResult;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeFriendRelation;
+import com.wechat.model.dbEntity.MdeUser;
+import com.wechat.model.requestDto.PageReq;
+import com.wechat.model.requestDto.UserCodeWithPage;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.HumanVeinService;
+
+@Controller
+@RequestMapping("humanVein")
+public class HumanVeinController extends BaseController {
+
+	@Autowired
+	HumanVeinService humanVeinService;
+
+	@Autowired
+	CommonService commonService;
+
+	/**
+	 * 人脉主页初始化
+	 * 	  获取好友邀请信息和广告内容
+	 * 
+	 * @param req
+	 * @return
+	 */
+	@RequestMapping(value = "")
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> initHumanVeinPage(HttpServletRequest req) {
+		String userCode = commonService.getUserCode(req);
+		Map<String, Object> map = humanVeinService.init(userCode);
+
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	/**
+	 * 获取页面中好友更新动态和好友列表
+	 * 
+	 * @param req
+	 * @return
+	 */
+	@RequestMapping(value = "getFriendsAndTrends",method=RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getFriendsAndTrends(HttpServletRequest req,@RequestBody PageReq page) {
+		String userCode = commonService.getUserCode(req);
+		String lang = commonService.getLanguage(req);
+		Map<String, Object> map = humanVeinService.getFriendsAndTrends(userCode,lang, String.valueOf(page.getSize()));
+
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	
+	/**
+	 * 可能认识的人
+	 * 
+	 * @param req
+	 * @return
+	 */
+	@RequestMapping(value = "getMaybeFriends",method=RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getMaybeFriends(HttpServletRequest req) {
+		String userCode = commonService.getUserCode(req);
+		String lang = commonService.getLanguage(req);
+		String identityFlag = commonService.getIdentityFlag(req);
+		
+		Map<String, Object> map = new HashMap<String, Object>();
+		// 可能认识的人
+		map.put("maybeFriends", commonService.getMaybeFriends(userCode,identityFlag,lang));
+
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+		
+
+	/**
+	 * 获取好友列表
+	 * @param page
+	 * @param req
+	 * @return
+	 */
+	@RequestMapping(value = "getPagefriends",method=RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<PagingResult<MdeUser>> getPagefriends(@RequestBody PageReq page,HttpServletRequest req) {
+		PagingResult<MdeUser> pagingResult = humanVeinService.getPagefriends(req, page);
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST,pagingResult);
+	}
+	
+	/**
+	 * 好友搜索
+	 * 
+	 * @param map
+	 * @return
+	 * @throws IOException
+	 */
+	@RequestMapping(value = "friendSearch", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<PagingResult<MdeUser>> friendSearch(@RequestBody Map<String, String> map,HttpServletRequest req) throws IOException {
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST,humanVeinService.friendSearch(map,req));
+	}
+
+	/**
+	 * 新的好友邀请信息获取
+	 * 
+	 * @param req
+	 * @return
+	 * @throws IOException
+	 */
+//	@RequestMapping(value = "getMakeFriendInfo")
+//	@ResponseBody
+//	public ResultEntity<List<MdeFriendRelation>> getMakeFriendInfo(HttpServletRequest req) throws IOException {
+//		String userCode = commonService.getUserCode(req);
+//		return humanVeinService.getMakeFriendInfo(userCode);
+//	}
+
+	/**
+	 * 好友添加确认(0同意,1拒绝)
+	 * 
+	 * @param map
+	 * @return
+	 * @throws IOException
+	 */
+	@RequestMapping(value = "friendsConfirm", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> friendsConfirm(@RequestBody Map<String, Object> map, HttpServletRequest req) throws IOException {
+		// 好友申请人
+		String userCodeReq = map.get("userCodeReq").toString();
+		// 好友处理人 map.get("userCodeResp").toString();
+		String userCodeResp = commonService.getUserCode(req) + "";
+		// 0同意,1拒绝
+		String confirm = map.get("confirm").toString();
+		if (StringsUtils.isEmpty(userCodeReq) || StringsUtils.isEmpty(confirm)) {
+			return new ResultEntity<>(InfoMsg.ERROR_NULL_PARAM);
+		}
+		return humanVeinService.friendsConfirm(userCodeReq, userCodeResp, confirm);
+	}
+
+	/**
+	 * 我的好友
+	 * 
+	 * @param pageNum
+	 * @param req
+	 * @return
+	 * @throws IOException
+	 */
+//	@RequestMapping(value = "getFriendsInfo", method = RequestMethod.POST)
+//	@ResponseBody
+//	public ResultEntity<PagingResult<MdeUser>> getFriendsInfo(@RequestBody UserCodeWithPage param, HttpServletRequest req)
+//			throws IOException {
+//		String userCode = commonService.getUserCode(req);
+//		param.setUserCode(userCode);
+//		PagingResult<MdeUser> result = humanVeinService.findFriends(param);
+//		return new ResultEntity<PagingResult<MdeUser>>(InfoMsg.SUCCESS_REQUEST, result);
+//	}
+	
+	
+	/**
+	 * 删除 同意好友申请
+	 * @param userCode
+	 * @param req
+	 * @return
+	 * @throws IOException
+	 */
+	@RequestMapping(value = "deleteComfirmedFriendship", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<String> deleteComfirmedFriendship(@RequestParam String userCode, HttpServletRequest req)
+			throws IOException {
+		String currentUserCode = commonService.getUserCode(req);
+		commonService.deleteComfirmedFriendship(currentUserCode, userCode);
+		return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST);
+	}
+	
+}

+ 336 - 0
src/main/java/com/wechat/controller/InterviewController.java

@@ -0,0 +1,336 @@
+package com.wechat.controller;
+
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.Constants;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeIntvContacts;
+import com.wechat.model.dbEntity.MdeUser;
+import com.wechat.model.dto.InterviewDetailDto;
+import com.wechat.model.dto.IntvContactsDto;
+import com.wechat.model.dto.WxBaseUserInfoDto;
+import com.wechat.model.requestDto.InterviewConfirmReq;
+import com.wechat.model.requestDto.InterviewCreateReq;
+import com.wechat.model.requestDto.InterviewHisReq;
+import com.wechat.model.requestDto.InterviewRefuseReq;
+import com.wechat.model.requestDto.InterviewUpdateReq;
+import com.wechat.model.responseDto.DPResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.model.responseDto.WxMiniCode2SessionResp;
+import com.wechat.service.CommonService;
+import com.wechat.service.InterviewService;
+import com.wechat.service.MdeUserService;
+import com.wechat.service.WeiXinProgService;
+
+/**
+* @author jadyn
+* @version 创建时间:2020年6月28日 下午4:32:51
+* 面试相关接口
+*/
+
+@Controller
+@RequestMapping(value = "interview")
+public class InterviewController extends BaseController{
+
+	@Resource
+	private InterviewService intvService;
+	
+	@Resource
+	private CommonService commonService;
+
+	@Resource
+	private WeiXinProgService wxProgService;
+	
+	@Resource
+	private MdeUserService userService;
+	
+	/**
+	 * 提交面试邀请
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "createIntvInfo", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> createIntvInfo(@RequestBody @Valid InterviewCreateReq intvReq, HttpServletRequest request){
+    	ResultEntity<String> resp = new ResultEntity<String>();
+    	
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+    	
+    	//创建面试邀请信息
+    	int count = intvService.createIntv(request,intvReq,userCode);
+    	if(count == 0) {
+    		resp.setMsg(InfoMsg.ERROR_SAVE_FIELD);
+    	} 
+    	return resp;
+    }
+    
+    /**
+	 * 获取面试邀请信息
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "getIntvInfo", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<InterviewDetailDto> getIntvInfo(@RequestParam String intvId, HttpServletRequest request) {
+    	ResultEntity<InterviewDetailDto> resp = new ResultEntity<InterviewDetailDto>();
+    	
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+    	//获取当前登录用户的身份标识[0-个人;1-企业]
+    	String identityFlag = commonService.getIdentityFlag(request);
+    	
+    	String publisher = null;
+    	String interviewee = null;
+    	
+    	if(Constants.IDENTITY_P.equals(identityFlag))
+    	{
+    		interviewee = userCode;
+    	} else {
+    		publisher = userCode;
+    	}
+    	
+    	//获取面试邀请信息
+    	resp.setResult(intvService.getIntvDetail(publisher,interviewee,intvId));
+
+    	return resp;
+    }
+	
+	
+	/**
+	 * 修改联系人
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "updateContacts", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> updateContacts(@RequestBody MdeIntvContacts req, HttpServletRequest request) throws Exception {
+    	ResultEntity<String> resp = new ResultEntity<String>();
+    	
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+    	
+    	//修改联系人
+    	int count = intvService.updateContacts(req,userCode);
+    	if(count == 0) {
+    		resp.setMsg(InfoMsg.ERROR_DATA_UPDATE);
+    	}
+
+    	return resp;
+    }
+    
+	/**
+	 * 获取联系人
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "getContacts", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<List<IntvContactsDto>> getContacts(HttpServletRequest request) throws Exception {
+    	ResultEntity<List<IntvContactsDto>> resp = new ResultEntity<List<IntvContactsDto>>();
+    	
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+    	
+    	//获取联系人列表
+    	resp.setResult(intvService.getContacts(userCode));
+    	
+    	return resp;
+    }
+    
+	/**
+	 * 删除联系人
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "delContact", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> delContact(@RequestParam Integer contId, HttpServletRequest request) throws Exception {
+    	ResultEntity<String> resp = new ResultEntity<String>();
+    	
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+    	
+    	//修改联系人
+    	int count = intvService.delContact(contId,userCode);
+    	if(count < 1) {
+    		resp.setMsg(InfoMsg.ERROR_DATA_UPDATE);
+    	}
+
+    	return resp;
+    }
+	
+	/**
+	 * 修改面试预约时间
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "updateIntvTimes", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> updateIntvTimes(@RequestBody @Valid InterviewUpdateReq intvUpdReq, HttpServletRequest request) {
+    	ResultEntity<String> resp = new ResultEntity<String>();
+    	
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+    	
+    	//获取当前登录用户的身份标识[0-个人;1-企业]
+    	String identityFlag = commonService.getIdentityFlag(request);	
+    	
+    	//修改面试预约时间
+    	intvService.updateIntvTimes(intvUpdReq, userCode, identityFlag);
+    	
+    	//发送信息提示
+    	intvService.sendIntvChangeTimeMsg(intvUpdReq,identityFlag);
+
+    	return resp;
+    }
+    
+	/**
+	 * 确认面试时间
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "confirmIntvTime", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> confirmIntvTime(@RequestBody @Valid InterviewConfirmReq confirmReq, HttpServletRequest request){
+    	ResultEntity<String> resp = new ResultEntity<String>();
+    	
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+
+    	//确认面试时间
+    	intvService.confirmIntvTime(confirmReq, userCode);
+    	
+    	// 发送通知(企业和个人)-异步处理
+		// 个人用户信息
+		MdeUser personUser = userService.getFullInfo(confirmReq.getInterviewee());
+		// 企业用户信息
+		MdeUser enterpriseUser = userService.getFullInfo(confirmReq.getPublisher());
+		
+		intvService.sendIntvConfirmMsgAsync(confirmReq,personUser,enterpriseUser);
+
+    	return resp;
+    }
+    
+
+    /**
+	 * 拒绝面试
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "refuseIntv", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> refuseIntv(@RequestBody @Valid InterviewRefuseReq refuseReq, HttpServletRequest request){
+    	ResultEntity<String> resp = new ResultEntity<String>();
+    	
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+
+    	//拒绝面试
+    	int count = intvService.refuseIntv(refuseReq, userCode);
+    	if(count < 1) {
+    		resp.setMsg(InfoMsg.ERROR_DATA_UPDATE);
+    	} else {
+    		try {
+    			//发送信息
+        		intvService.sendRefuseIntvMsg(refuseReq,commonService.getUserInfo(userCode));
+			} catch (Exception e) {
+				log.error("*************拒绝面试信息发送异常*************",e);
+			}
+    		
+    	}
+
+    	return resp;
+    }
+    
+    
+	/**
+	 * 获取拒绝理由下拉列表
+	 * 
+	 */
+	@RequestMapping(value = "getRefuseReasonList", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<DPResp>> getRefuseReasonList() {
+		ResultEntity<List<DPResp>> rest = new ResultEntity<List<DPResp>>();
+		List<DPResp> prepareFlagList = commonService.getDictByType("refuse_reasons",Constants.LANG_CN);
+		rest.setResult(prepareFlagList);
+		return rest;
+	}
+	
+	
+	/**
+	 * 获取视频面试时长
+	 * 
+	 */
+	@RequestMapping(value = "markIntvTimes", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<DPResp>> markIntvTimes() {
+		ResultEntity<List<DPResp>> rest = new ResultEntity<List<DPResp>>();
+		List<DPResp> prepareFlagList = commonService.getDictByType("refuse_reasons",Constants.LANG_CN);
+		rest.setResult(prepareFlagList);
+		return rest;
+	}
+	
+	
+	/**
+	 * 记录使用记录-Start
+     * 
+     * @param 
+     * @return
+     */
+	@RequestMapping(value = "setInterviewHis", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> setInterviewHis(@RequestBody @Valid InterviewHisReq req, HttpServletRequest request) throws Exception {
+		ResultEntity<String> resp = new ResultEntity<String>();
+		
+	  	//获取当前用户信息
+    	WxMiniCode2SessionResp wxResp = wxProgService.getJscodeToSession(req.getCode());
+    	if(StringsUtils.isEmpty(wxResp.getOpenid()))
+    	{
+    		//调用小程序登陆出错
+    		log.error("**************调用小程序登陆出错【jscode2session】【"+wxResp.getErrmsg()+"】*********************"); 
+    		resp.setMsg(InfoMsg.ERROR_AUZ_FAILED);
+    	} else {
+    		//缓存中获取openid等信息
+        	WxBaseUserInfoDto wxBUser = wxProgService.getSessionKey(wxResp.getOpenid());
+        	if (wxBUser == null)
+        	{
+        		//非登录小程序用户
+        		log.error("**************小程序非登录状态OpenId【"+wxResp.getOpenid()+"】*********************"); 
+        		resp.setMsg(InfoMsg.ERROR_AUZ_FAILED);
+        	} else {
+    			// 记录使用记录
+    			String usedId = intvService.setInterviewHis(req,wxBUser.getUserCode(),wxBUser.getIdentityFlag());
+    			resp.setResult(usedId);
+        	}
+    	}
+
+		return resp;
+	}
+	
+	
+
+	 
+    
+}

+ 172 - 0
src/main/java/com/wechat/controller/InvitationController.java

@@ -0,0 +1,172 @@
+package com.wechat.controller;
+
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.alibaba.druid.util.StringUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeUser;
+import com.wechat.model.dto.ActivityDetailDto;
+import com.wechat.model.dto.ActivityInfoDto;
+import com.wechat.model.dto.BaseUserDto;
+import com.wechat.model.dto.BeInvitedDtlDto;
+import com.wechat.model.dto.ExchangeHisDto;
+import com.wechat.model.dto.InvitationNumDto;
+import com.wechat.model.responseDto.InvitationInitResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.InvitationService;
+
+
+@Controller
+@RequestMapping("invitation")
+public class InvitationController extends BaseController {
+	
+	@Resource
+	private CommonService commonService;
+	
+	@Resource
+	private InvitationService invitationService;
+
+    /**
+     * 邀请页面初始化
+     * 
+     * @param actId 活动场次id
+     * @return
+     */
+    @RequestMapping(value = "init", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<InvitationInitResp> init(@RequestParam String actId, HttpServletRequest request) throws Exception {
+    	InvitationInitResp result = new InvitationInitResp();
+    	ResultEntity<InvitationInitResp> resp = new ResultEntity<InvitationInitResp>();
+    	//活动场次id不能为空
+    	if(StringUtils.isEmpty(actId))
+    	{
+    		log.error("活动场次id为空");
+    		resp.setResultEntity(InfoMsg.ERROR_DATA_MISS);
+    		return resp;
+    	}
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+    	MdeUser userInfo = commonService.getUserInfo(userCode);
+    	//将user和返回类中相同属性复制至返回集中
+    	BaseUserDto baseUserInfo = new BaseUserDto();
+		BeanUtils.copyProperties(userInfo, baseUserInfo);
+    	
+    	//拼装邀请人id
+		String inviter = commonService.getInviter(userCode, actId);
+    	
+    	//获取用户邀请的数据
+    	InvitationNumDto invitationNum = invitationService.getInvitationNum(inviter,userCode, actId);
+    	
+    	//活动相关内容
+    	ActivityInfoDto activityInfo = invitationService.getActivityInfo(actId);
+    	List<ActivityDetailDto> activityDetailList = invitationService.getActivityDetails(actId);
+    	
+    	//邀请明细
+    	List<BeInvitedDtlDto> beInvitedDtlList = invitationService.getBeInvitedDtl(inviter);
+    	
+    	//结果封装
+    	result.setActivityDetail(activityDetailList);
+    	result.setActivityInfo(activityInfo);
+    	result.setBaseUser(baseUserInfo);
+    	result.setBeInvitedDtlList(beInvitedDtlList);
+    	result.setInvitationNum(invitationNum);
+    	result.setInviter(inviter);
+    	resp.setResult(result);
+    	
+    	return resp;
+    }
+    
+    /**
+     * 获取兑换履历
+     * 
+     * @param actId 活动场次id
+     * @return
+     */
+    @RequestMapping(value = "getExchangeHis", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<List<ExchangeHisDto>> getExchangeHis(@RequestParam String actId, HttpServletRequest request) throws Exception {
+    	ResultEntity<List<ExchangeHisDto>> resp = new ResultEntity<List<ExchangeHisDto>>();
+    	//活动场次id不能为空
+    	if(StringUtils.isEmpty(actId))
+    	{
+    		log.error("活动场次id为空");
+    		resp.setResultEntity(InfoMsg.ERROR_DATA_MISS);
+    		return resp;
+    	}
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+    	
+    	//获取兑换记录
+    	List<ExchangeHisDto> exList = invitationService.getExchangeHis(actId,userCode);
+    	
+    	//结果封装
+    	resp.setResult(exList);
+    	return resp;
+    }
+    
+    
+    /**
+     * 提交兑换申请
+     * 
+     * @param prizeId 奖品id
+     * @return
+     */
+    @RequestMapping(value = "exchangeRequest", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<InvitationInitResp> exchangeRequest(@RequestParam String prizeId, HttpServletRequest request) throws Exception {
+    	ResultEntity<InvitationInitResp> resp = new ResultEntity<InvitationInitResp>();
+    	//奖品id不能为空
+    	if(StringUtils.isEmpty(prizeId))
+    	{
+    		log.error("活动奖品id为空");
+    		resp.setResultEntity(InfoMsg.ERROR_DATA_MISS);
+    		return resp;
+    	}
+
+    	//兑换申请存储
+    	int inNum = invitationService.exchangeRequest(prizeId, request);
+    	if(inNum < 1)
+    	{
+    		resp.setMsg(InfoMsg.ERROR_INSERT_ERROR);
+    	}
+    	
+    	return resp;
+    }
+    
+    /**
+     * 取消兑换申请
+     * 
+     * @param prizeId 奖品id
+     * @return
+     */
+    @RequestMapping(value = "cancelExchangeRequest", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<InvitationInitResp> cancelExchangeRequest(@RequestParam Integer hisId, HttpServletRequest request) throws Exception {
+    	ResultEntity<InvitationInitResp> resp = new ResultEntity<InvitationInitResp>();
+    	//兑换请求id不能为空
+    	if(hisId == null || hisId < 1)
+    	{
+    		log.error("兑换请求id为空");
+    		resp.setResultEntity(InfoMsg.ERROR_DATA_MISS);
+    		return resp;
+    	}
+
+    	//兑换申请删除
+    	invitationService.cancelExchangeRequest(hisId, request);
+
+    	return resp;
+    }
+    
+}

+ 99 - 0
src/main/java/com/wechat/controller/JsSdkController.java

@@ -0,0 +1,99 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Formatter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.alibaba.fastjson.JSON;
+import com.wechat.common.utils.MessageUtils;
+import com.wechat.common.utils.MvcUtil;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.model.dto.JsapiSignatureDto;
+import com.wechat.model.responseDto.JsonResp;
+import com.wechat.service.WeiXinService;
+
+@Controller
+@RequestMapping("jsSdk")
+public class JsSdkController extends BaseController {
+
+    //微信服务
+    @Autowired
+    private WeiXinService               weiXinService;
+    
+    // 签名字符串
+    @Value("#{configProperties['weixin.jsapi.signature']}")
+    private String wxJspSignatureStr;
+
+    // Appid
+    @Value("#{configProperties['weixin.appid']}")
+    private String wxAppid;
+    
+
+    /**
+     * jssdk 签名
+     * 
+     * @param openId
+     * @throws NoSuchAlgorithmException 
+     * @throws UnsupportedEncodingException 
+     */
+    @RequestMapping(value = "signature", method = RequestMethod.GET)
+    public void getSignature(@RequestParam String url, HttpServletRequest request, HttpServletResponse response) throws NoSuchAlgorithmException, UnsupportedEncodingException {
+        //获取16位随机字符串
+        String randomStr = StringsUtils.getRandomString(16);
+        //时间戳
+        String timestamp = Long.toString(System.currentTimeMillis()/1000);
+        
+        String urlForSign = java.net.URLDecoder.decode(url, "utf-8");
+        
+        //签名用字符串
+        String signatureStr = MessageUtils.getText(wxJspSignatureStr, weiXinService.getJsapiTicket(), randomStr, timestamp, urlForSign);
+        log.info("签名用字符:" + signatureStr);
+        
+        //签名
+        MessageDigest crypt = MessageDigest.getInstance("SHA-1");
+        crypt.reset();
+        crypt.update(signatureStr.getBytes("UTF-8"));
+        String signature = byteToHex(crypt.digest());
+        
+        JsapiSignatureDto jsapiSignatureDto = new JsapiSignatureDto();
+        jsapiSignatureDto.setAppId(wxAppid);
+        jsapiSignatureDto.setNonceStr(randomStr);
+        jsapiSignatureDto.setTimestamp(timestamp);
+        jsapiSignatureDto.setSignature(signature);
+        
+        JsonResp<JsapiSignatureDto> resp = new JsonResp<JsapiSignatureDto>();
+        resp.setInfo(jsapiSignatureDto);
+        
+        String json = JSON.toJSONString(resp, true);
+        try {
+            MvcUtil.writeJson(request, response, json);
+        } catch (IOException e) {
+           log.error(e);
+        } 
+    }
+    
+    private static String byteToHex(final byte[] hash) {
+        Formatter formatter = new Formatter();
+        for (byte b : hash)
+        {
+            formatter.format("%02x", b);
+        }
+        String result = formatter.toString();
+        formatter.close();
+        return result;
+    }
+
+}

+ 263 - 0
src/main/java/com/wechat/controller/LoginController.java

@@ -0,0 +1,263 @@
+package com.wechat.controller;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Map;
+
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.alibaba.fastjson.JSONObject;
+import com.wechat.common.CommonHelper;
+import com.wechat.common.Constants;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeCooperationMsg;
+import com.wechat.model.dbEntity.MdeUser;
+import com.wechat.model.requestDto.LoginByPasswordReq;
+import com.wechat.model.requestDto.PositionSearchReq;
+import com.wechat.model.requestDto.UserInfoDto;
+import com.wechat.model.requestDto.UserInfoWithOpenidDto;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.LoginService;
+
+@Controller
+@RequestMapping(value = "login")
+public class LoginController  extends BaseController{
+
+	@Autowired
+	private LoginService loginService;
+	@Autowired
+	private CommonService commonService;
+	
+	@Autowired
+	private CommonHelper commonHelper;
+
+	@Value("#{configProperties['enterprise.mail.activation.redirectUrl']}")
+	private String redirectUrl;
+
+	/**
+	 * 用户登录
+	 * @param loginReq
+	 * @param req
+	 * @param resp
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "login", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<UserInfoDto> login(@RequestBody LoginByPasswordReq loginReq, HttpServletRequest req, HttpServletResponse resp) throws Exception {
+		ResultEntity<UserInfoDto> rest = new ResultEntity<UserInfoDto>();
+		
+		// 验证身份
+		if (loginReq != null && StringsUtils.isNotEmpty(commonHelper.getIRealIPAddr(req))) {
+
+			//登陆信息验证
+			ResultEntity<MdeUser> checkRest = loginService.checkPassword(loginReq);
+			MdeUser mdeUser = checkRest.getResult();
+			if(Constants.STR_OK.equals(checkRest.getCode()))
+			{
+				rest = loginService.login(mdeUser,loginReq,resp);
+				//记录登陆历史
+				commonService.addLoginHis(req,mdeUser.getUserCode());
+			} else {
+				rest.setCode(checkRest.getCode());
+				rest.setMsg(checkRest.getMsg());
+			}
+		} else {
+			rest.setMsg(InfoMsg.ERROR_LOGIN_MISS);
+		}
+		
+		return rest;
+	}
+
+	/**
+	 * 第三方登录
+	 * 
+	 * @param <T>
+	 * 
+	 * @param request
+	 * @param response
+	 *            return
+	 */
+	@RequestMapping(value = "loginByCode", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<UserInfoWithOpenidDto> loginByCode(HttpServletRequest request, HttpServletResponse response)
+			throws Exception {
+		ResultEntity<UserInfoWithOpenidDto> result = new ResultEntity<UserInfoWithOpenidDto>();
+		BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
+		String line;
+		StringBuilder sb = new StringBuilder();
+		while ((line = br.readLine()) != null) {
+			sb.append(line);
+		}
+		JSONObject jo = JSONObject.parseObject(sb.toString());
+
+		// 获取授权code
+		String code = jo.getString("code");
+		if (StringsUtils.isEmpty(code)) {
+			return new ResultEntity<>(InfoMsg.ERROR_AUZ_FAILED);
+		}
+
+		// 根据类型判断是微信登录还是领英 0.微信 1.领英
+		String type = jo.getString("type");
+		if (StringsUtils.isEmpty(type)) {
+			return new ResultEntity<>(InfoMsg.ERROR_Type_MISS);
+		}
+
+		// 判断是pc端登录还是微信端登录
+		String loginModel = jo.getString("loginModel");
+		if (StringsUtils.isEmpty(loginModel)) {
+			return new ResultEntity<>(InfoMsg.ERROR_LOGINMODEL_ERROR);
+		}
+		// 0.微信登录
+		if ("0".equals(type)) {
+			result = loginService.loginByWechatCode(request, response, code, loginModel);
+			return result;
+			// 领英登录
+		} else {
+			result = loginService.loginByLinkedInCode(request, response, code);
+			return result;
+		}
+	}
+	
+	
+	 /**
+     * 解除绑定
+     * 
+     * @param <T>
+     * 
+     * @param request
+     * @param response
+     *            return
+     */
+    @RequestMapping(value = "unBinding", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<UserInfoDto> unBinding(HttpServletRequest request, HttpServletResponse response)
+            throws Exception {
+        ResultEntity<UserInfoDto> result = new ResultEntity<UserInfoDto>();
+        BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
+        String line;
+        StringBuilder sb = new StringBuilder();
+        while ((line = br.readLine()) != null) {
+            sb.append(line);
+        }
+        JSONObject jo = JSONObject.parseObject(sb.toString());
+
+        // 获取授权code
+        String code = jo.getString("code");
+        if (StringsUtils.isEmpty(code)) {
+            return new ResultEntity<>(InfoMsg.ERROR_AUZ_FAILED);
+        }
+        // 判断是pc端登录还是微信端登录
+        String loginModel = jo.getString("loginModel");
+        if (StringsUtils.isEmpty(loginModel)) {
+            return new ResultEntity<>(InfoMsg.ERROR_LOGINMODEL_ERROR);
+        }
+
+        // 解除微信绑定
+        result = loginService.unBindingWechatCode(code, loginModel);
+        return result;
+
+    }
+	
+
+	/**
+	 * 第三方登录绑定账号
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "binding", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<UserInfoDto> binDingAccount(HttpServletRequest req, HttpServletResponse resp) throws Exception {
+		ServletInputStream inputStream = req.getInputStream();
+		BufferedReader buffer = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
+		String line;
+		StringBuilder builder = new StringBuilder();
+		while ((line = buffer.readLine()) != null) {
+			builder.append(line);
+		}
+		JSONObject jo = JSONObject.parseObject(builder.toString());
+		ResultEntity<UserInfoDto> result = loginService.binDingAccount(req, resp, jo);
+		return result;
+	}
+
+	/**
+	 * 职位关键词搜索
+	 * 
+	 * @param page
+	 * @return
+	 */
+	@RequestMapping(value = "searchJob", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String,Object>> searchJob(HttpServletRequest req, HttpServletResponse resp,
+			@RequestBody PositionSearchReq searchReq) {
+		return loginService.searchJob(searchReq);
+
+	}
+
+	/**
+	 * 合作伙伴
+	 * 
+	 * @param resp
+	 * @param resp
+	 * @return
+	 */
+	@RequestMapping(value = "cooperate", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> cooperate(HttpServletRequest req, HttpServletResponse resp,
+			@RequestBody @Validated(value = MdeCooperationMsg.SaveGroup.class) MdeCooperationMsg mdeCooperationMsg) {
+		String lang = commonService.getLanguage(req);
+		InfoMsg infoMsg = loginService.cooperate(mdeCooperationMsg,lang);
+		return new ResultEntity<>(infoMsg);
+	}
+
+	/**
+	 * 企业用户 邮箱激活
+	 * 
+	 * @param req
+	 * @param resp
+	 * @throws IOException
+	 */
+	@RequestMapping(value = "activation")
+	public void activationEnterprise(
+			HttpServletRequest req, 
+			HttpServletResponse resp,
+			@RequestParam("userCode") String userCode, 
+			@RequestParam("activationToken") String activationToken)
+			throws IOException {
+		loginService.activationEnterprise(activationToken, userCode, resp);
+		resp.sendRedirect(redirectUrl);
+	}
+
+	/**
+	 * 登录页初始化图片地址
+	 * 
+	 * @param param
+	 * @return
+	 */
+	@RequestMapping(value = "getLoginInitImage", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getLoginInitImage(@RequestBody Map<String, String> param) {
+		String type = param.get("type");
+		return loginService.getLoginInitImage(type);
+	}
+
+}

+ 361 - 0
src/main/java/com/wechat/controller/MainPageController.java

@@ -0,0 +1,361 @@
+package com.wechat.controller;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.CustomException;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeInformation;
+import com.wechat.model.dbEntity.MdeTrends;
+import com.wechat.model.requestDto.FriendRelationReq;
+import com.wechat.model.requestDto.SendTrendsResp;
+import com.wechat.model.requestDto.TrendCommentInfo;
+import com.wechat.model.requestDto.TrendThumbUpInfo;
+import com.wechat.model.requestDto.UserCodeWithPage;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.MainPageService;
+import com.wechat.service.MdeTrendsService;
+
+@Controller
+@RequestMapping("mainPage")
+public class MainPageController extends BaseController{
+	
+	@Autowired
+	private MainPageService mainPageService;
+	
+	@Autowired
+	private CommonService commonService;
+	@Autowired
+	private MdeTrendsService trendsService;
+	
+	/**
+	 * 主页初始化(广告内容加载)
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String,Object>> initMainPage(HttpServletRequest request) throws Exception {
+		Map<String,Object> map = mainPageService.init();
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,map);
+	}
+	
+	/**
+	 * 获取可能认识的人
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getMaybeFriends",method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String,Object>> getMaybeFriends(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		String identityFlag = commonService.getIdentityFlag(request);
+		String lang = commonService.getLanguage(request);
+		
+		Map<String,Object> map = mainPageService.maybeFriends(userCode,lang,identityFlag);
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,map);
+	}
+	
+	/**
+	 * 获取热门资讯
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getInforOfZixun",method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<List<MdeInformation>> getInforOfZixun(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		// 热门资讯
+		List<MdeInformation> list = commonService.getInformationsOfZixun(userCode);	
+		return new ResultEntity<List<MdeInformation>>(InfoMsg.SUCCESS_REQUEST,list);
+	}
+	
+	
+	/**
+	 * 获取热门资讯、动态广告详情
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getHotInformations",method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<MdeInformation> getHotInformatinos(HttpServletRequest request,@RequestParam String infoId) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		String lang = commonService.getLanguage(request);
+		return new ResultEntity<MdeInformation>(InfoMsg.SUCCESS_REQUEST,mainPageService.getHotInformatinoByID(userCode,lang,infoId));
+	}
+	
+	/**
+	 * 获取初始好友动态
+	 * @return
+	 * @throws Exception
+	 */
+/*	@RequestMapping(value="getTrendsAndInfo",method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String,Object>> getTrendsAndInfo(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		String lang = commonService.getLanguage(request);
+		
+		Map<String,Object> map = mainPageService.trendsAndInfo(userCode,lang);
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,map);
+	}
+*/
+	
+	/**
+	 * 获取推荐内容
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getRecomments",method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String,Object>> getRecomments(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		String identityFlag = commonService.getIdentityFlag(request);
+		String lang = commonService.getLanguage(request);
+		
+		Map<String,Object> map = mainPageService.recomments(userCode,lang,identityFlag);
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,map);
+	}
+	
+	/**
+	 * 获取更多好友动态
+	 * @param param > userCode index size
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getMoreTrendsOrHotInfo", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String,Object>> getMoreTrendsOrHotInfo2(@RequestBody UserCodeWithPage param,HttpServletRequest request) throws Exception {
+		String lang = commonService.getLanguage(request);
+		String userCode = commonService.getUserCode(request);
+		Map<String,Object> map = mainPageService.getMoreTrendsOrHotInfo(param,lang,userCode);
+		
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,map);
+	}
+	
+	/**
+	 * 发送动态内容
+	 * @param request
+	 * @param response
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="sendDynamicMessage",method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> sendDynamicMessage(HttpServletRequest request, HttpServletResponse response) throws Exception {
+		List<MultipartFile> picture = ((MultipartHttpServletRequest)request).getFiles("picture");
+		if(picture.size()>9) {
+			throw new CustomException(InfoMsg.ERROR_IMG_BEYOUND_LIMIT);
+		}
+		String trendDesc = request.getParameter("trendDesc");
+		trendDesc = trendDesc.replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "*");//过滤四字节和六字节特殊字符(如颜文字)
+		String linkInfo = request.getParameter("linkInfo");
+		String showFlag = request.getParameter("showFlag");
+		String userCode = commonService.getUserCode(request);
+		if(StringsUtils.isEmpty(showFlag)) throw new CustomException(InfoMsg.ERROR_EMPTY_REQUEST);
+		trendDesc = StringsUtils.isEmpty(trendDesc) ? "" :trendDesc;
+		if(trendDesc.length() >= 255) {
+			return new ResultEntity<String>(InfoMsg.ERROR_LENGTH_OVER_LIMIT);
+		}
+		int i = mainPageService.insertDynamicMessage(picture, trendDesc,showFlag,userCode,linkInfo);
+		if(i == 1) {
+			return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST);
+		}
+		return new ResultEntity<String>(InfoMsg.ERROR_SAVE_FIELD);
+	}
+	/**
+	 * 获取链接简介
+	 * @param request
+	 * @param response
+	 * @param url
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getUrlInfo",method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<String> getUrlInfo(HttpServletRequest request, HttpServletResponse response,@RequestParam String url) throws Exception {
+		return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST,mainPageService.formatURL(url));
+	}
+	
+	/**
+	 * 发送动态内容 手机端
+	 * @param request
+	 * @param response
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="sendDynamicMessageMB",method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> sendDynamicMessageMB(HttpServletRequest request, @RequestBody SendTrendsResp resp) throws Exception {
+		
+		// 手机端发布动态, 图片上传到微信服务器上,返回id ,接口这边直接通过图片Id获取服务器上的图片
+		String trendDesc = resp.getTrendDesc().replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "*");//过滤四字节和六字节特殊字符(如颜文字);
+		String showFlag = resp.getShowFlag();
+		String userCode = commonService.getUserCode(request);
+		if(StringsUtils.isEmpty(showFlag)) throw new CustomException(InfoMsg.ERROR_EMPTY_REQUEST);
+		trendDesc = StringsUtils.isEmpty(trendDesc) ? "" :trendDesc;
+		int i = mainPageService.sendDynamicMessageMB(resp.getPicture(), trendDesc,showFlag,userCode,resp.getLinkInfo());
+		if(i == 1) {
+			return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST);
+		}
+		return new ResultEntity<String>(InfoMsg.ERROR_SAVE_FIELD);
+	}
+	
+	/**
+	 * 评论 动态
+	 * 参数: 动态信息id, 发布者userCodeE, 评论内容, 评论者用户姓名、评论者职称、评论者头像路径
+	 * @param request
+	 * @param response
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="commentTrend",method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> commentTrend(@RequestBody TrendCommentInfo info,HttpServletRequest request) throws Exception {
+		String lang = commonService.getLanguage(request);
+		String userCode = commonService.getUserCode(request);// 评论者userCode
+		info.setCommentatorCode(userCode);
+		String comment = mainPageService.commentTrend(info,lang);
+		return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST,comment);
+	}
+	
+	
+	/**
+	 * 动态点赞 (保存或取消)
+	 * 参数: 动态信息id, 用户CODE, 用户姓名、职称、头像路径
+	 * @param request
+	 * @param response
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="thumbUpTrend",method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<MdeTrends> thumbUpTrend(@RequestBody TrendThumbUpInfo info,HttpServletRequest request) throws Exception {
+		String lang = commonService.getLanguage(request);
+		String userCode = commonService.getUserCode(request);
+		info.setCommentatorCode(userCode);
+		mainPageService.thumbUpTrend(info,lang);
+		return new ResultEntity<MdeTrends>(InfoMsg.SUCCESS_REQUEST,trendsService.getTrendsById(info.getTrendId(), lang));
+	}
+	/**
+	 * 动态分享
+	 * 参数: 动态信息trendId, 动态描述 trendDesc, 好友可见标记showFlag
+	 * 
+	 * @param request
+	 * @param response
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="shareTrend",method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> shareTrend(@RequestBody Map<String, Object> param,HttpServletRequest request) throws Exception {
+		String lang = commonService.getLanguage(request);
+		String userCode = commonService.getUserCode(request);
+		param.put("currentUserCode", userCode);
+		param.put("lang", lang);
+		int i = mainPageService.shareTrend(param);
+		if(i == 1) {
+			return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST);
+		}
+		return new ResultEntity<String>(InfoMsg.ERROR_SAVE_FIELD);
+	}
+	
+	/**
+	 * 添加好友
+	 * @param user  userCode1(申请人) userCode2(被申请人)
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="makeFriends",method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> makeFriends(@RequestBody FriendRelationReq user) throws Exception {
+		if(user.getUserCode1().equals(user.getUserCode2())) {
+			return new ResultEntity<String>(InfoMsg.ERROR_MAKE_FRIEND_MYSELF);
+		}
+		int i = mainPageService.makeFriends(user.getUserCode1(),user.getUserCode2());
+		if(i == 1) {
+			return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST);
+		}
+		return new ResultEntity<String>(InfoMsg.ERROR_SAVE_FIELD);
+	}
+	
+	
+	/**
+	 * 获取用户通知数量
+	 * @param userCode
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getNoticeCount",method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getNoticeCount(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST,mainPageService.getNoticeCount(userCode));
+	}
+	
+	/**
+	 * 获取用户通知信息和数量
+	 * @param  userCode
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getNoticeInfo",method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String,Object>> getNoticeInfo(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		Map<String,Object> map = mainPageService.getNoticeInfo(userCode);
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,map);
+	}
+	
+
+	
+	/**
+	 * 获取动态详情
+	 * @param request
+	 * @param trendId
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getTrendsDetail",method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<MdeTrends>> getTrendsDetail(HttpServletRequest request, @RequestParam(required=false) Long trendId) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		String lang = commonService.getLanguage(request);
+		return new ResultEntity<List<MdeTrends>>(InfoMsg.SUCCESS_REQUEST,mainPageService.getTrendsDetail(trendId,userCode,lang));
+	}
+	/**
+	 * 分型动态到领英
+	 * @param request
+	 * @param code 领英返回的code
+	 * @param trendId 被分享的动态id
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="shareTrendToLinkedIn",method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<String> shareTrendToLinkedIn(
+			HttpServletRequest request, 
+			@RequestParam String code,
+			@RequestParam String trendId) 
+					throws Exception {
+		String userCode = commonService.getUserCode(request);
+		String lang = commonService.getLanguage(request);
+		return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST,mainPageService.shareTrendToLinkedIn(trendId,userCode,code,lang));
+	}
+	
+}

+ 140 - 0
src/main/java/com/wechat/controller/MendunerShowController.java

@@ -0,0 +1,140 @@
+package com.wechat.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.Constants;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.requestDto.MdeShowReq;
+import com.wechat.model.responseDto.DPResp;
+import com.wechat.model.responseDto.MdeShowListResp;
+import com.wechat.model.responseDto.MdeShowResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.MendunerShowService;
+
+
+@Controller
+@RequestMapping("mendunerShow")
+public class MendunerShowController extends BaseController{
+	@Autowired
+	private CommonService commonService;
+	
+	@Autowired
+	private MendunerShowService mdeShowService;
+	
+	/** 
+	 * 获取福利信息
+	 * @param request
+	 * @return
+	 */
+	@RequestMapping(value="getWelfares",method = RequestMethod.GET)
+    @ResponseBody
+	public ResultEntity<List<DPResp>> getWelfares(HttpServletRequest request)
+	{
+		List<DPResp> list = commonService.getDictByType("welfare",Constants.LANG_CN);
+		return new ResultEntity<List<DPResp>>(InfoMsg.SUCCESS_REQUEST,list);
+	}
+	
+	
+	
+	/** 
+	 *  创建、修改门墩秀
+	 * @param request
+	 * @return
+	 */
+	@RequestMapping(value="makeMdeShow",method = RequestMethod.POST)
+    @ResponseBody
+	public ResultEntity<Integer> makeMdeShow(HttpServletRequest request, @RequestBody MdeShowReq showReq)
+	{
+		ResultEntity<Integer> rest = new ResultEntity<Integer>();
+		String userCode = commonService.getUserCode(request);
+		Integer showId = mdeShowService.makeMdeShow(userCode, showReq);
+		
+		if(showId < 1)
+		{
+			rest.setMsg(InfoMsg.ERROR_INSERT_ERROR);
+		}
+		rest.setResult(showId);
+		return rest;
+	}
+	
+	
+	/** 
+	 *  获取创建门墩秀信息
+	 * @param request
+	 * @return
+	 */
+	@RequestMapping(value="getInfoAboutShow",method = RequestMethod.GET)
+    @ResponseBody
+	public ResultEntity<MdeShowReq> getInfoAboutShow(HttpServletRequest request, @RequestParam int showId)
+	{
+		ResultEntity<MdeShowReq> rest = new ResultEntity<MdeShowReq>();
+		String userCode = commonService.getUserCode(request);
+		rest.setResult(mdeShowService.getInfoAboutShow(userCode,showId));
+		
+		return rest;
+	}
+	
+	/** 
+	 *  删除门墩秀数据信息
+	 * @param showId
+	 * @return
+	 */
+	@RequestMapping(value="delShow",method = RequestMethod.POST)
+    @ResponseBody
+	public ResultEntity<MdeShowReq> delShow(HttpServletRequest request, @RequestParam int showId)
+	{
+		ResultEntity<MdeShowReq> rest = new ResultEntity<MdeShowReq>();
+		String userCode = commonService.getUserCode(request);
+		int count = mdeShowService.delShow(userCode,showId);
+		if(count < 1)
+		{
+			rest.setMsg(InfoMsg.ERROR_DATA_UPDATE);
+		}
+		return rest;
+	}
+	
+	
+	/** 
+	 *  获取门墩秀列表信息
+	 * @param request
+	 * @return
+	 */
+	@RequestMapping(value="getShowList",method = RequestMethod.GET)
+    @ResponseBody
+	public ResultEntity<List<MdeShowListResp>> getShowList(HttpServletRequest request)
+	{
+		ResultEntity<List<MdeShowListResp>> rest = new ResultEntity<List<MdeShowListResp>>();
+		String userCode = commonService.getUserCode(request);
+		rest.setResult(mdeShowService.getShowList(userCode));
+		
+		return rest;
+	}
+	
+	
+	/** 
+	 *  获取门墩秀数据信息
+	 * @param request
+	 * @return
+	 */
+	@RequestMapping(value="getTheShow",method = RequestMethod.GET)
+    @ResponseBody
+	public ResultEntity<MdeShowResp> getTheShow(HttpServletRequest request, @RequestParam int showId)
+	{
+		ResultEntity<MdeShowResp> rest = new ResultEntity<MdeShowResp>();
+		rest.setResult(mdeShowService.getTheShow(showId));
+		return rest;
+	}
+	
+}

+ 204 - 0
src/main/java/com/wechat/controller/NoLoginController.java

@@ -0,0 +1,204 @@
+package com.wechat.controller;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.CommonHelper;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.requestDto.AdCtrReq;
+import com.wechat.model.responseDto.JobAdvertisedNologinResp;
+import com.wechat.model.responseDto.PhotoAlbumResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.model.responseDto.UserHomePageResp;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeAdImagesService;
+import com.wechat.service.PersonCeneterService;
+import com.wechat.service.PositionService;
+
+
+
+/**
+ * 免登陆接口
+ * @author jadyn.wu
+ * @date: 2020-05-20 14:18
+ */
+@Controller
+@RequestMapping("noLogin")
+public class NoLoginController {
+	
+	@Autowired
+	private PositionService positionService;
+	
+	@Resource
+	private CommonHelper commonHelper;
+	
+	@Autowired
+	private CommonService commonService;
+	
+	@Autowired
+	private PersonCeneterService personCenterService;
+	
+	@Autowired
+	private MdeAdImagesService adImagesService;
+	
+	
+	@Value("#{configProperties['upload.base.path']}")
+	private String basePackagePath;
+	@Value("#{configProperties['upload.path.file']}")
+	private String uploadFilePath;
+	
+	// log 处理
+	protected static final Log log = LogFactory.getLog(NoLoginController.class);
+	
+	/**
+	 * 职位页面初始化
+	 * @param userCode
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String,Object>> initMainPage(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		String lang = commonService.getLanguage(request);
+		Map<String,Object> map = positionService.init(userCode,lang);
+		
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,map);
+	}
+	
+	/**
+	 * 个人主页单独使用
+	 * 获取用的详细信息
+	 * @param req
+	 * @param jobId
+	 * @return
+	 */
+	@RequestMapping(value = "getHomePageNologin", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<UserHomePageResp<JobAdvertisedNologinResp>> getHomePageNologin(HttpServletRequest request,@RequestParam String shareCode) {
+		ResultEntity<UserHomePageResp<JobAdvertisedNologinResp> > rest = new ResultEntity<UserHomePageResp<JobAdvertisedNologinResp> >();
+		UserHomePageResp<JobAdvertisedNologinResp> resp = new UserHomePageResp<JobAdvertisedNologinResp> ();
+		String lang = commonService.getLanguage(request);
+		//获取解密后数据
+		String[] codeAndTime = commonHelper.getUserCodeAes(shareCode);
+		if(codeAndTime.length > 1)
+		{	//查询目标用户code
+			String userCode = codeAndTime[0];
+			//验证用时间戳
+			String creatTime = codeAndTime[1];
+			//查询页面信息
+			resp = personCenterService.getHomePageNologin(userCode,lang,"",creatTime);
+		} else {
+			log.error("有攻击嫌疑!!ip:【"+ commonHelper.getIRealIPAddr(request)+"】");
+			rest.setMsg(InfoMsg.ERROR_USER_MISS);
+		}
+		rest.setResult(resp);
+		return rest;
+	}
+	
+	
+	/**
+	 * 获取企业相册
+	 * 
+	 * @param userCode
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "getPhotoAlbum", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<PhotoAlbumResp>> getPhotoAlbum(@RequestParam String shareCode) throws Exception {
+		ResultEntity<List<PhotoAlbumResp>> rest = new ResultEntity<List<PhotoAlbumResp>>();
+		//获取解密后数据
+		String[] codeAndTime = commonHelper.getUserCodeAes(shareCode);
+		if(codeAndTime.length>1)
+		{
+			rest.setResult(personCenterService.getPhotoAlbum(codeAndTime[0]));
+		}else {
+			rest.setMsg(InfoMsg.ERROR_USER_MISS);
+		}
+
+		return rest;
+	}
+	
+	
+	/**
+	 * 职位详情页广告点击记录(非登陆)
+	 * @param jobId 发布职位id
+	 * @return
+	 */
+	@RequestMapping(value="setPDetailAdCtr", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> setPDetailAdCtr(@RequestBody AdCtrReq adCtrReq,HttpServletRequest request){
+		ResultEntity<String> rest = new ResultEntity<String>();
+		
+		if(commonService.limitApiFrequencyAdCtrs(request)) {
+			String userCode = commonService.getUserCode(request);
+			String lang = commonService.getLanguage(request);
+			String shareJob = adCtrReq.getShareJob();
+			int jobId = 0;
+			if(!StringsUtils.isEmpty(shareJob))
+			{
+				jobId = commonHelper.getJobId(shareJob);
+			}
+			Map<String, Object> mapResult = positionService.getPositionDetail(jobId,userCode,lang,null);
+			//职位id不正确
+			if(mapResult == null)
+			{
+				log.error("有攻击嫌疑!!ip:【"+ commonHelper.getIRealIPAddr(request)+"】");
+			} else {
+				//记录广告点击率
+				if(adImagesService.recodeAdCtr(adCtrReq) > 0) {
+					rest.setMsg(InfoMsg.ERROR_SAVE_FIELD);
+				};
+			}
+		}
+		return rest;
+	}
+
+	
+	
+	/**
+	 * 登陆页广告点击记录(非登陆)
+	 * @return
+	 */
+	@RequestMapping(value="setAdsCtr", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> setAdsCtr(@RequestBody List<AdCtrReq> adCtrReqList,HttpServletRequest request){
+		ResultEntity<String> rest = new ResultEntity<String>();
+		int result = 0;
+		//接口调用频率控制
+		if(commonService.limitApiFrequencyAdCtrs(request)) {
+			for(AdCtrReq adCtrReq : adCtrReqList) {
+				//验证广告点击率
+				if(adImagesService.checkAdsCtr(adCtrReq)) {
+					//记录广告点击率
+					result = result+ adImagesService.recodeAdCtr(adCtrReq);
+				}
+			}
+		}
+
+		if(result > 0) {
+			rest.setMsg(InfoMsg.ERROR_SAVE_FIELD);
+		};
+
+		return rest;
+	}
+	
+	
+	
+}

+ 308 - 0
src/main/java/com/wechat/controller/OrderController.java

@@ -0,0 +1,308 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.alipay.api.AlipayApiException;
+import com.wechat.common.Constants;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.dao.RedisGoodsSaleDao;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeGoods;
+import com.wechat.model.dbEntity.MdeOrders;
+import com.wechat.model.requestDto.GoodsOrdersReq;
+import com.wechat.model.requestDto.MdeOrdersReq;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeGoodsService;
+import com.wechat.service.MdeInvoiceTitleService;
+import com.wechat.service.MdeOrdersService;
+import com.wechat.service.MdeVipPackageService;
+import com.wechat.service.OrderService;
+import com.wechat.service.VerificationCodeService;
+
+@Controller
+@RequestMapping(value = "order")
+public class OrderController extends BaseController{
+
+	@Autowired
+	OrderService orderService;
+
+	@Autowired
+	VerificationCodeService verificationCodeService;
+
+	@Autowired
+	MdeInvoiceTitleService mdeInvoiceTitleService;
+
+	@Autowired
+	MdeVipPackageService mdeVipPackageService;
+	
+	@Autowired
+	MdeOrdersService MdeOrdersService;
+	
+	@Autowired
+	RedisGoodsSaleDao goodsRedisDao;
+	
+	@Autowired
+	MdeGoodsService goodService;
+
+	@Autowired
+	CommonService commonService;
+
+	/**
+	 * 订单页初始化 -> 获取套餐信息,套餐价格信息,开票信息
+	 * @param pkgId 套餐id
+	 * @return
+	 */
+	@RequestMapping(method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> initOrderPage(HttpServletRequest request, @RequestParam int pkgId) {
+		String lang = commonService.getLanguage(request);
+		String identityFlag = commonService.getIdentityFlag(request);
+		Map<String, Object> maps = new HashMap<String, Object>();
+		// 套餐内容
+		maps.put("vipPackage", mdeVipPackageService.getPkgInfoById(pkgId, lang));
+		// 开票信息
+		maps.putAll(orderService.initInvoiceInfo(lang, identityFlag));
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, maps);
+	}
+	
+	
+	/**
+	 * 确认订单-服务套餐
+	 * 
+	 * @param mdeOrders
+	 * @param req
+	 * @param rep
+	 * @throws IOException
+	 * @throws AlipayApiException
+	 */
+	@RequestMapping(value = "confirmOrder", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, String>> confirmOrder(@Validated @RequestBody MdeOrdersReq mdeOrdersReq,
+			HttpServletRequest req, HttpServletResponse rep) throws AlipayApiException, IOException {
+		// 订单类别[0会员套餐订单 1个人服务,2企业服务,3商品购买,4积分兑换] 
+		mdeOrdersReq.setType(Constants.ORDER_TYPE_VIP);
+		
+		Map<String, String> map = orderService.confirmOrder(mdeOrdersReq, req, rep);
+		if (!map.isEmpty()) {
+			return new ResultEntity<Map<String, String>>(InfoMsg.SUCCESS_REQUEST, map);
+		}
+		return new ResultEntity<Map<String, String>>(InfoMsg.ERROR_SYSTEM_ERROR);
+	}
+	
+	/**
+	 * 支付宝支付 回调方法
+	 * 
+	 * @param request
+	 * @param response
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "aliPay_notify_url", method = RequestMethod.POST)
+	@ResponseBody
+	public void aliPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
+		orderService.aliPayNotify(request, response);
+	}
+	
+	/**
+	 * 微信支付 回调方法
+	 * @param request
+	 * @param response
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "weChat_notify_url", method = RequestMethod.POST)
+	@ResponseBody
+	public String weChatNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
+		return orderService.weChatNotify(request, response);
+	}
+	
+	
+	/**
+	 * 获取订单详情 订单信息, 套餐信息, 套餐价格信息, 开票信息
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "getOrderDetail", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> getOrderDetail(HttpServletRequest request,  @RequestParam String orderId,  @RequestParam String type) throws Exception {
+		String lang = commonService.getLanguage(request);
+		String userCode = commonService.getUserCode(request);
+		String identityFlag = commonService.getIdentityFlag(request);
+		
+		ResultEntity<Map<String, Object>> result = new ResultEntity<Map<String, Object>>();
+		Map<String, Object> repMap = orderService.getOrderDetail(orderId, lang, userCode, identityFlag,type);
+
+		result.setResult(repMap);
+		return result;
+	}
+	
+	/**
+	 * 检查支付状态
+	 * @param request
+	 * @param response
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "checkPayStatus", method = RequestMethod.GET)
+	@ResponseBody
+	public String checkPayStatus(@RequestParam String orderId, HttpServletRequest request, HttpServletResponse response) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		return orderService.checkPayStatus(orderId,userCode);
+	}
+	
+
+	
+//	/**
+//	 * 退款
+//	 * 
+//	 * @param map
+//	 * @param req
+//	 * @param rep
+//	 * @throws AlipayApiException
+//	 */
+//	@RequestMapping(value = "refund", method = RequestMethod.POST)
+//	@ResponseBody
+//	public ResultEntity<String> refund(@RequestBody Map<String, Object> map, HttpServletRequest req, HttpServletResponse rep)
+//			throws AlipayApiException {
+//		return orderService.refund(map, req, rep);
+//	}
+//
+//	/**
+//	 * 退款查询
+//	 * 
+//	 * @param map
+//	 * @param req
+//	 * @param rep
+//	 * @throws AlipayApiException
+//	 */
+//	@RequestMapping(value = "queryRefund", method = RequestMethod.POST)
+//	@ResponseBody
+//	public ResultEntity<Map<String, String>> queryRefund(@RequestBody Map<String, Object> map, HttpServletRequest req, HttpServletResponse rep)
+//			throws AlipayApiException {
+//		return orderService.queryRefund(map, req, rep);
+//	}
+	
+	/**
+	 * 订单查询
+	 * 
+	 * @param map
+	 * @param req
+	 * @param rep
+	 * @throws AlipayApiException
+	 */
+	@RequestMapping(value = "queryOrder", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, String>> queryOrder(@RequestBody Map<String, Object> map, HttpServletRequest req, HttpServletResponse rep)
+			throws AlipayApiException {
+		return orderService.queryOrder(map, req, rep);
+	}
+	
+	/**
+	 * 用户删除订单
+	 * 
+	 * @param orderId 订单号
+	 */
+	@RequestMapping(value = "deleteOrderByUser", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, String>> deleteOrderByUser(@RequestBody Map<String, String> map, HttpServletRequest req){
+		String orderId = map.get("orderId");
+		String userCode = commonService.getUserCode(req);
+		
+		if(StringsUtils.isEmpty(orderId)) {
+			return new ResultEntity<>(InfoMsg.ERROR_EMPTY_REQUEST);
+		}
+		int count = orderService.deleteOrderByUser(orderId,userCode);
+		if (count < 1)
+		{
+			return new ResultEntity<>(InfoMsg.ERROR_DATA_UPDATE);
+		}
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST);
+	}
+	
+	
+	/**
+	 * 确认商品订单 
+	 * 
+	 * @param mdeOrders
+	 * @param req
+	 * @param rep
+	 * @throws IOException
+	 * @throws AlipayApiException
+	 */
+	@RequestMapping(value = "confirmGoodsOrder", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, String>> confirmGoodsOrder(@Validated @RequestBody GoodsOrdersReq ordReq,
+			HttpServletRequest req, HttpServletResponse rep) throws AlipayApiException, IOException {
+		 ResultEntity<Map<String, String>> result = new ResultEntity<Map<String, String>>();
+		// 订单类别[0会员套餐订单 1个人服务,2企业服务,3商品购买,4积分兑换] 
+		
+		Map<String, String> map = new HashMap<String, String>();
+		
+		String userCode = commonService.getUserCode(req);
+		String identityFlag = commonService.getIdentityFlag(req);
+		String lang = commonService.getLanguage(req);
+    	//获取用户注册时间
+		Date userCreatDate = commonService.getUserCreatDate(req);
+		
+		// 获取商品详情
+		MdeGoods goodsDetail = goodService.getGoodsAllInfo(ordReq.getGoodsId());
+		if(goodsDetail != null )
+		{
+			//购买资格验证
+			ResultEntity<Boolean> checkEnt = orderService.checkQualification(goodsDetail, userCode, userCreatDate,ordReq);
+			if(checkEnt.getResult())
+			{
+				//下订单
+				MdeOrders mdeOrders = orderService.confirmGoodsOrder(ordReq, goodsDetail, userCode, identityFlag, lang);
+
+				//下订单成功后计算销量并发起支付
+				if(mdeOrders != null)
+				{
+					//新增订单计算销量
+					if(StringsUtils.isEmpty(ordReq.getOrderId()))
+					{
+						//计算销量
+						Integer goodsSale = goodService.getGoodsSale(goodsDetail.getGoodsId());
+						//存入缓存 并设置30天过期
+						goodsRedisDao.insertSaleNum(goodsDetail.getGoodsId(), goodsSale+mdeOrders.getGoodsNums());
+					}
+					
+					//发起支付
+					map = orderService.confirmOrderPay(mdeOrders,ordReq.getWxCode(), req, rep);
+					if (!map.isEmpty()) {
+						result.setResult(map);
+					} else {
+						result.setMsg(InfoMsg.ERROR_SYSTEM_ERROR);
+					}
+				} else {
+					log.error("***************订单初始化异常*************");
+					result.setMsg(InfoMsg.ERROR_SYSTEM_ERROR);
+				}
+			} else {
+				result.setCode(checkEnt.getCode());
+				result.setMsg(checkEnt.getMsg());
+			}
+		} else {
+			log.error("***************商品不存在*************");
+			result.setMsg(InfoMsg.ERROR_SYSTEM_ERROR);
+		}
+
+		return result;
+	}
+	
+
+}

+ 43 - 0
src/main/java/com/wechat/controller/PackageController.java

@@ -0,0 +1,43 @@
+package com.wechat.controller;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.PackageService;
+
+@Controller
+@RequestMapping(value = "package")
+public class PackageController {
+
+	@Autowired
+	PackageService PackageService;
+
+	@Autowired
+	CommonService commonService;
+
+	/**
+	 * 套餐页初始化
+	 * @param req
+	 * @return
+	 */
+	@RequestMapping(value = "",method=RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> initPackagePage(HttpServletRequest req, @RequestParam String identityFlag) {
+//		String userCode = commonService.getUserCode(req);
+		String lang = commonService.getLanguage(req);
+		Map<String, Object> map = PackageService.initPackagePage(identityFlag,lang);
+
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+}

+ 854 - 0
src/main/java/com/wechat/controller/PersonCeneterController.java

@@ -0,0 +1,854 @@
+package com.wechat.controller;
+
+import com.wechat.common.CommonHelper;
+import com.wechat.common.Constants;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.CustomException;
+import com.wechat.global.base.dao.PagingResult;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeEducationExperience;
+import com.wechat.model.dbEntity.MdeUser;
+import com.wechat.model.dbEntity.MdeUserCv;
+import com.wechat.model.dbEntity.MdeWorkExperience;
+import com.wechat.model.dto.OrderListDto;
+import com.wechat.model.dto.PositionCvHisDto;
+import com.wechat.model.dto.SubscribedPositionsDto;
+import com.wechat.model.dto.TrendsDto;
+import com.wechat.model.requestDto.*;
+import com.wechat.model.responseDto.*;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeUserService;
+import com.wechat.service.PersonCeneterService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 个人中心
+ *
+ * @author tangwc
+ */
+@Controller
+@RequestMapping(value = "person")
+public class PersonCeneterController {
+    @Autowired
+    private PersonCeneterService personCenterService;
+    @Autowired
+    private CommonService commonService;
+    @Resource
+    private CommonHelper commonHelper;
+
+    @Autowired
+    private MdeUserService userService;
+
+    @Value("#{configProperties['upload.base.path']}")
+    private String basePackagePath;
+    @Value("#{configProperties['upload.path.image']}")
+    private String baseImagePackagePath;
+    @Value("#{configProperties['upload.path.image.album']}")
+    private String photoAlbumPath;
+    @Value("#{configProperties['url.base']}")
+    private String urlBase;
+
+
+    /**
+     * 个人中心 初始化
+     *
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String, Object>> init(HttpServletRequest request) throws Exception {
+        String userCode = commonService.getUserCode(request);
+        Map<String, Object> map = personCenterService.init(userCode);
+        return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+    }
+
+
+    /**
+     * 获取用户信息
+     *
+     * @param userCode
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "getPersonInformation", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<PersonInformationReq> getPersonInformation(HttpServletRequest request) throws Exception {
+        String userCode = commonService.getUserCode(request);
+        String lang = commonService.getLanguage(request);
+        MdeUser user = personCenterService.getPersonInformation(userCode, lang);
+
+        //结果集封装
+        PersonInformationReq req = new PersonInformationReq();
+        //将user和返回类中相同属性复制至返回集中
+        BeanUtils.copyProperties(user, req);
+        req.setShortInviter(commonService.getShortInviter(userCode));
+        req.setShareCode(commonHelper.getShareCodeAes(userCode, user.getCreateDate()));
+        //获取PC底部广告图并赋值
+        req.setAdListPc(commonService.getAdImages(Constants.PC_PERSON_DETAIL_BOTTOM));
+        //获取手机中部广告图并赋值
+        req.setAdListPhone(commonService.getAdImages(Constants.SJ_PERSONCENTER_MIDDLE));
+
+        return new ResultEntity<PersonInformationReq>(InfoMsg.SUCCESS_REQUEST, req);
+    }
+
+    /**
+     * 修改用户基本信息
+     *
+     * @param info
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "modifyBaseInfo", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> modifyBaseInfo(HttpServletRequest req) throws Exception {
+
+        return personCenterService.modifyBaseInfo(req);
+    }
+
+    /**
+     * 修改企业联系人信息
+     *
+     * @param info
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "modifyEntContacts", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> modifyEntContacts(HttpServletRequest req) throws Exception {
+
+        return personCenterService.modifyEntContacts(req);
+    }
+
+    /**
+     * 修改用户简介信息
+     *
+     * @param info
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "modifyIntroduction", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> modifyIntroduction(HttpServletRequest req) throws Exception {
+
+        return personCenterService.modifyIntroduction(req);
+    }
+
+    /**
+     * 投递简历情况详情
+     *
+     * @param info
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "postPositionDetailInfo", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<List<PositionCvHisDto>> postPositionDetailInfo(HttpServletRequest request, @RequestParam String status) throws Exception {
+        String userCode = commonService.getUserCode(request);
+        List<PositionCvHisDto> list = personCenterService.postPositionDetailInfo(userCode, status);
+
+        return new ResultEntity<List<PositionCvHisDto>>(InfoMsg.SUCCESS_REQUEST, list);
+    }
+
+    /**
+     * 酒店(职位)邀请信息获取
+     *
+     * @param userCode
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "getRecievedHotelInvationInfo", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<PagingResult<HotelInvitationInfoResp>> getRecievedHotelInvationInfo(@RequestBody Map<String, String> param, HttpServletRequest request) throws Exception {
+        param.put("userCode", commonService.getUserCode(request));
+        PagingResult<HotelInvitationInfoResp> pageResult = personCenterService.getRecievedHotelInvationInfo(param, request);
+        return new ResultEntity<PagingResult<HotelInvitationInfoResp>>(InfoMsg.SUCCESS_REQUEST, pageResult);
+    }
+
+    /**
+     * 我的互动 - 收到的评论列表
+     *
+     * @param userCode
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "myInteractionOfTrends", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<List<TrendCommentInfo>> myInteractionOfTrends(HttpServletRequest request) throws Exception {
+        String userCode = commonService.getUserCode(request);
+        List<TrendCommentInfo> list = personCenterService.myInteractionOfTrends(userCode);
+
+        return new ResultEntity<List<TrendCommentInfo>>(InfoMsg.SUCCESS_REQUEST, list);
+    }
+
+    /**
+     * 我的互动 - 点赞列表
+     *
+     * @param userCode
+     * @return
+     * @throws Exception
+     */
+//	@RequestMapping(value = "myThumbUp", method = RequestMethod.GET)
+//	@ResponseBody
+//	public ResultEntity<List<MdeTrends>> myThumbUp(HttpServletRequest request) throws Exception {
+//		String userCode = commonService.getUserCode(request);
+//		String lang = commonService.getLanguage(request);
+//		List<MdeTrends> list = personCenterService.myThumbUp(userCode,lang);
+//
+//		return new ResultEntity<List<MdeTrends>>(InfoMsg.SUCCESS_REQUEST, list);
+//	}
+
+    /**
+     * 获取 工作经历、教育经历、简历列表
+     *
+     * @param userCode
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "getMyCVInfos", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String, Object>> getMyCVInfos(HttpServletRequest request) throws Exception {
+        String userCode = commonService.getUserCode(request);
+        String lang = commonService.getLanguage(request);
+        Map<String, Object> map = personCenterService.getMyCVInfos(userCode, lang);
+
+        return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+    }
+
+    /**
+     * 新增(修改)工作履历
+     *
+     * @param workExperience
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "modefyWorkExperience", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> modefyWorkExperience(@Validated @RequestBody MdeWorkExperience workExperience, HttpServletRequest request)
+            throws Exception {
+        String userCode = commonService.getUserCode(request);
+        workExperience.setUserCode(userCode + "");
+        return personCenterService.modefyWorkExperience(workExperience, request);
+    }
+
+    /**
+     * 删除工作履历
+     *
+     * @param request
+     * @param workExperience -> workId
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "deleteWorkExperience", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> deleteWorkExperience(HttpServletRequest request,
+                                                      @RequestBody Map<String, Integer> workExperience) throws Exception {
+        Integer workId = workExperience.get("workId");
+        personCenterService.deleteAndUpdatePositionTitle(workId, request);
+        return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST);
+    }
+
+    /**
+     * 修改职位头衔
+     *
+     * @param workExperience workId
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "modefyPositionTitle", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> modefyPositionTitle(HttpServletRequest request,
+                                                     @RequestBody Map<String, Integer> workExperience) throws Exception {
+        String userCode = commonService.getUserCode(request);
+        Integer workId = workExperience.get("workId");
+        if (workId == null)
+            throw new CustomException(InfoMsg.ERROR_EMPTY_REQUEST);
+        int i = personCenterService.modefyPositionTitle(workId, userCode);
+
+        return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST, i);
+    }
+
+    /**
+     * 新增(修改)教育经历
+     *
+     * @param educationExperience
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "modefyEducationExperience", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> modefyEducationExperience(
+            @Validated(value = MdeEducationExperience.SaveGroup.class) @RequestBody MdeEducationExperience educationExperience,
+            HttpServletRequest req)
+            throws Exception {
+        String lang = commonService.getLanguage(req);
+        int i = personCenterService.modefyEducationExperience(educationExperience, lang);
+
+        return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST, i);
+    }
+
+    /**
+     * 删除教育履历
+     *
+     * @param request
+     * @param workExperience
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "deleteEducationExperience", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> deleteEducationExperience(HttpServletRequest request,
+                                                           @RequestBody Map<String, Integer> educationExperience) throws Exception {
+        String userCode = commonService.getUserCode(request);
+        Integer eduId = educationExperience.get("eduId");
+        if (eduId == null)
+            throw new CustomException(InfoMsg.ERROR_EMPTY_REQUEST);
+        int i = personCenterService.deleteEducationExperience(educationExperience.get("eduId"), userCode);
+
+        return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST, i);
+    }
+
+    /**
+     * 删除简历附件
+     *
+     * @param userCv
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "deleteUserCv", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> deleteUserCv(HttpServletRequest request, @RequestBody Map<String, Long> map) throws Exception {
+        String userCode = commonService.getUserCode(request);
+
+        Long cvId = map.get("cvId");
+        if (cvId == null)
+            throw new CustomException(InfoMsg.ERROR_EMPTY_REQUEST);
+        int i = personCenterService.deleteUserCv(cvId, userCode);
+        return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST, i);
+    }
+
+    /**
+     * 上传简历附件
+     *
+     * @param userCv
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "uploadUserCv", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> uploadUserCv(HttpServletRequest request) throws Exception {
+        ResultEntity<Integer> rest = new ResultEntity<Integer>();
+        String userCode = commonService.getUserCode(request);
+        String system = commonHelper.getDeviceType(request).getSystem();
+        List<MultipartFile> file = ((MultipartHttpServletRequest) request).getFiles("file");
+        if (file.size() != 1) {
+            rest.setMsg(InfoMsg.ERROR_EMPTY_REQUEST);
+        } else {
+            try {
+                int i = personCenterService.uploadUserCv(file.get(0), userCode + "", system);
+                rest.setResult(i);
+            } catch (CustomException e) {
+                rest.setMsg(e.getMessage());
+                rest.setCode(e.getCode());
+            }
+        }
+
+        return rest;
+    }
+
+    /**
+     * 获取简历
+     *
+     * @param userCv
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "getUserCv", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<List<MdeUserCv>> getUserCv(HttpServletRequest request) throws Exception {
+        String userCode = commonService.getUserCode(request);
+        List<MdeUserCv> list = personCenterService.getUserCv(userCode);
+        return new ResultEntity<List<MdeUserCv>>(InfoMsg.SUCCESS_REQUEST, list);
+    }
+
+    /**
+     * 获取收藏的职位列表
+     *
+     * @param userCode
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "getCollectionJobList", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<List<JobAdvertisedRes>> getCollectionJobList(HttpServletRequest request) throws Exception {
+        String userCode = commonService.getUserCode(request);
+        String lang = commonService.getLanguage(request);
+        List<JobAdvertisedRes> list = personCenterService.getCollectionJobList(userCode, lang);
+        return new ResultEntity<List<JobAdvertisedRes>>(InfoMsg.SUCCESS_REQUEST, list);
+    }
+
+    /**
+     * 修改用户头像
+     *
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "changeUserHeadPortrait", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> changeUserHeadPortrait(HttpServletRequest request) throws Exception {
+        List<MultipartFile> file = ((MultipartHttpServletRequest) request).getFiles("headPortrait");
+        String userCode = commonService.getUserCode(request);
+        if (file.size() != 1) {
+            return new ResultEntity<String>(InfoMsg.ERROR_EMPTY_REQUEST);
+        }
+        String path = personCenterService.changeUserHeadPortrait(file.get(0), userCode);
+        return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST, path);
+    }
+
+    /**
+     * 获取我的动态
+     *
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "getMyTrends", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<PagingResult<TrendsDto>> getMyTrends(HttpServletRequest request, @RequestBody PageReq page)
+            throws Exception {
+        String userCode = commonService.getUserCode(request);
+        String lang = commonService.getLanguage(request);
+        PagingResult<TrendsDto> trends = personCenterService.getMyTrends(userCode, userCode, page, lang);
+        return new ResultEntity<PagingResult<TrendsDto>>(InfoMsg.SUCCESS_REQUEST, trends);
+    }
+
+    /**
+     * 删除好友
+     *
+     * @param request
+     * @param map     -> userCode(需要删除的好友信息)
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "delFriends", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> delFriends(HttpServletRequest request, @RequestBody Map<String, String> map)
+            throws Exception {
+        String userCode = commonService.getUserCode(request);
+        String userCode1 = map.get("userCode");
+        if (userCode1 == null)
+            throw new CustomException(InfoMsg.ERROR_EMPTY_REQUEST);
+        int i = personCenterService.delFriends(userCode, userCode1);
+        return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST, i);
+    }
+
+    /**
+     * 删除动态
+     *
+     * @param request
+     * @param map     -> trendId
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "delTrends", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> delTrends(HttpServletRequest request, @RequestBody Map<String, Long> map)
+            throws Exception {
+        String userCode = commonService.getUserCode(request);
+        Long trendId = map.get("trendId");
+        if (trendId == null)
+            throw new CustomException(InfoMsg.ERROR_EMPTY_REQUEST);
+        int i = personCenterService.delTrends(userCode, trendId);
+        return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST, i);
+    }
+
+    /**
+     * 修改密码
+     *
+     * @param request
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "changePassword", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> changePassword(HttpServletRequest request, @Validated @RequestBody ChangPReq req)
+            throws Exception {
+        String userCode = commonService.getUserCode(request);
+        req.setUserCode(userCode);
+        int i = personCenterService.changePassword(req);
+        return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST, i);
+    }
+
+    /**
+     * 购买记录
+     *
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "buyRecord", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<PagingResult<OrderListDto>> buyRecord(
+            @RequestBody BuyRecordReq record, HttpServletRequest request) throws Exception {
+        String lang = commonService.getLanguage(request);
+        PagingResult<OrderListDto> i = personCenterService.buyRecord(record, lang);
+        return new ResultEntity<PagingResult<OrderListDto>>(InfoMsg.SUCCESS_REQUEST, i);
+    }
+
+    /**
+     * 查看企业详情并更新职位状态 (不知道哪边会用到)
+     *
+     * @param req
+     * @param jobId
+     * @return
+     */
+    @RequestMapping(value = "lookEnterPriseDetailAndUpdateStatus", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String, Object>> lookEnterPriseDetailAndUpdateStatus(
+            HttpServletRequest req,
+            @RequestParam(value = "jobId") Integer jobId) {
+        String userCode = commonService.getUserCode(req);
+        String lang = commonService.getLanguage(req);
+        Map<String, Object> maps = personCenterService.lookEnterPriseDetailAndUpdateStatus(userCode, jobId, lang);
+        return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, maps);
+    }
+
+    /**
+     * 个人主页单独使用
+     * 获取用的详细信息
+     *
+     * @param req
+     * @param jobId
+     * @return
+     */
+    @RequestMapping(value = "getUserFullInfo", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<UserHomePageResp<JobAdvertisedResp>> getUserFullInfo(HttpServletRequest request, @RequestParam String userCode, @RequestParam(required = false) String shareCode) {
+        ResultEntity<UserHomePageResp<JobAdvertisedResp>> rest = new ResultEntity<UserHomePageResp<JobAdvertisedResp>>();
+        String theSearch = commonService.getUserCode(request);
+        String currentUserIdentityFlag = commonService.getIdentityFlag(request);
+        String lang = commonService.getLanguage(request);
+
+        //当通过外部链接进入时,没有userCode 只有shareCode
+        if (StringsUtils.isEmpty(userCode) && !StringsUtils.isEmpty(shareCode)) {
+            //获取解密后数据
+            String[] codeAndTime = commonHelper.getUserCodeAes(shareCode);
+            if (codeAndTime.length > 1) {
+                userCode = codeAndTime[0];
+            } else {
+                rest.setMsg(InfoMsg.ERROR_USER_MISS);
+                return rest;
+            }
+        }
+        rest.setResult(personCenterService.getHomePageInfo(userCode, lang, theSearch, currentUserIdentityFlag));
+        return rest;
+    }
+
+    /**
+     * 获取指定用户动态
+     *
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "getTrendsOfSomeone", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<PagingResult<TrendsDto>> getTrendsOfSomeone(HttpServletRequest request, @RequestBody UserCodeWithPage param)
+            throws Exception {
+        String theSearch = commonService.getUserCode(request);
+        String lang = commonService.getLanguage(request);
+        PagingResult<TrendsDto> trends = personCenterService.getMyTrends(param.getUserCode(), theSearch, param, lang);
+        return new ResultEntity<PagingResult<TrendsDto>>(InfoMsg.SUCCESS_REQUEST, trends);
+    }
+
+
+    /**
+     * 上传企业相册
+     *
+     * @param request
+     * @param response
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "uploadPhotoAlbum", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> uploadPhotoAlbum(HttpServletRequest request, @RequestParam List<MultipartFile> pictureList) throws Exception {
+        int size = pictureList.size();
+        if (size > 8) {
+            throw new CustomException(InfoMsg.ERROR_IMG_BEYOUND_LIMIT);
+        }
+
+        String userCode = commonService.getUserCode(request);
+
+        int i = personCenterService.uploadPhotoAlbum(userCode, pictureList);
+        if (i == size) {
+            return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST);
+        } else {
+            return new ResultEntity<String>(InfoMsg.ERROR_UPLOAD_FIELD);
+        }
+    }
+
+    /**
+     * 删除照片
+     *
+     * @param request
+     * @param response
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "delPhotoAlbum", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> delPhotoAlbum(HttpServletRequest request, @RequestParam int pictureId) throws Exception {
+        String userCode = commonService.getUserCode(request);
+
+        int i = personCenterService.delPhotoAlbum(userCode, pictureId);
+        if (i == 1) {
+            return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST);
+        } else {
+            return new ResultEntity<String>(InfoMsg.ERROR_DATA_UPDATE);
+        }
+    }
+
+    /**
+     * 修改排序和描述
+     *
+     * @param request
+     * @param response
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "updatePhotoSort", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> updatePhotoSort(HttpServletRequest request, @RequestBody List<PhotoAlbumReq> photoAlbumReqList) throws Exception {
+        String userCode = commonService.getUserCode(request);
+
+        int count = personCenterService.updatePhotoSort(userCode, photoAlbumReqList);
+        if (count == photoAlbumReqList.size()) {
+            return new ResultEntity<String>(InfoMsg.SUCCESS_REQUEST);
+        } else {
+            return new ResultEntity<String>(InfoMsg.ERROR_DATA_UPDATE);
+        }
+    }
+
+
+    /**
+     * 获取企业相册
+     *
+     * @param userCode
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "getPhotoAlbum", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<List<PhotoAlbumResp>> getPhotoAlbum(@RequestParam String userCode) throws Exception {
+        List<PhotoAlbumResp> req = personCenterService.getPhotoAlbum(userCode);
+
+        return new ResultEntity<List<PhotoAlbumResp>>(InfoMsg.SUCCESS_REQUEST, req);
+    }
+
+
+    /**
+     * 上传企业相册-手机
+     *
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "uploadPhotoAlbumMobile", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<String> uploadPhotoAlbumMobile(HttpServletRequest request, @RequestBody List<String> pictureIds) throws Exception {
+        ResultEntity<String> resq = new ResultEntity<String>();
+        String userCode = commonService.getUserCode(request);
+        int count = 0;
+        int size = pictureIds.size();
+        if (size > 8) {
+            resq.setMsg(InfoMsg.ERROR_IMG_BEYOUND_LIMIT);
+        } else if (size < 1) {
+            resq.setMsg(InfoMsg.ERROR_NULL_PARAM);
+        } else {
+            //上传并保存
+            count = personCenterService.uploadPhotoAlbumMobile(userCode, pictureIds);
+        }
+
+        if (count != size) {
+            resq.setMsg(InfoMsg.ERROR_UPLOAD_FIELD);
+        }
+        return resq;
+    }
+
+    /**
+     * 用户信息完整度验证
+     *
+     * @return
+     */
+    @RequestMapping(value = "checkUserInfo", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Boolean> checkUserInfo(HttpServletRequest request) {
+        ResultEntity<Boolean> checkEnt = new ResultEntity<Boolean>();
+
+        //暂时去除 20200612
+	/*	String userCode = commonService.getUserCode(request);
+		checkEnt = userService.checkUserInfo(userCode);*/
+
+        checkEnt.setResult(true);
+        return checkEnt;
+    }
+
+
+    /**
+     * 修改个人隐私标识
+     *
+     * @param userCode
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "updatePrivateFlag", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> updatePrivateFlag(@RequestParam String privateFlag, HttpServletRequest request) {
+        ResultEntity<Integer> rest = new ResultEntity<Integer>();
+        Integer count = userService.updatePrivateFlag(commonService.getUserCode(request), privateFlag);
+        rest.setResult(count);
+        return rest;
+    }
+
+
+    /**
+     * 修改意向工作地信息
+     *
+     * @param info
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "modifyInterestedAdds", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> modifyInterestedAdds(@RequestBody @Valid List<InterestedAddsReq> addsList, HttpServletRequest req) {
+        ResultEntity<Integer> rest = new ResultEntity<Integer>();
+        String userCode = commonService.getUserCode(req);
+        Integer num = personCenterService.modifyInterestedAdds(addsList, userCode);
+        rest.setResult(num);
+        return rest;
+    }
+
+    /**
+     * 修改职位订阅信息
+     *
+     * @param info
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "modifySubscribedPositions", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> modifySubscribedPositions(@RequestBody @Valid SubscribePositionReq subPositionReq, HttpServletRequest req) {
+        ResultEntity<Integer> rest = new ResultEntity<Integer>();
+        String userCode = commonService.getUserCode(req);
+        Integer num = new Integer(0);
+        //订阅时验证用户是否关注公众号
+        InfoMsg msg = commonService.checkBindingAndSubscribe(userCode);
+
+        if (InfoMsg.SUCCESS_REQUEST.getCode().equals(msg.getCode())) {
+            //验证通过的情况下 修改职位订阅信息
+            num = personCenterService.modifySubscribedPositions(subPositionReq, userCode);
+        }
+        rest.setMsg(msg);
+        rest.setResult(num);
+        return rest;
+    }
+
+
+    /**
+     * 获取用户订阅信息
+     *
+     * @param userCode
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "getSubscribedInfo", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<SubscribedInfoResp> getSubscribedInfo(HttpServletRequest request) throws Exception {
+        ResultEntity<SubscribedInfoResp> resp = new ResultEntity<SubscribedInfoResp>();
+        String userCode = commonService.getUserCode(request);
+        String lang = commonService.getLanguage(request);
+        //获取意向工作地信息
+        List<InterestedAddsReq> interestedAdds = personCenterService.getInterestedAdds(userCode, lang);
+        //获取意向职位信息
+        List<SubscribedPositionsDto> subdPositions = personCenterService.getSubscribedPositions(userCode, lang);
+        //获取意向筹开类型信息
+        List<String> prepareFlags = personCenterService.getSubscribedPrepareType(userCode);
+        //获取用户信息
+        MdeUser user = commonService.getUserInfo(userCode);
+
+        //结果集封装
+        SubscribedInfoResp req = new SubscribedInfoResp();
+        req.setInterestedAdds(interestedAdds);
+        req.setPositions(subdPositions);
+        req.setPrepareFlags(prepareFlags);
+        req.setSubscribedFlag(user.getSubscribedFlag());
+        resp.setResult(req);
+
+        return resp;
+    }
+
+    /**
+     * 修改职位订阅标识
+     *
+     * @param info
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "modifySubscribedFlag", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<Integer> modifySubscribedFlag(@RequestParam String subdFlag, HttpServletRequest request) {
+        ResultEntity<Integer> rest = new ResultEntity<Integer>();
+        String userCode = commonService.getUserCode(request);
+        InfoMsg msg = userService.modifySubscribedFlag(userCode, subdFlag);
+        rest.setMsg(msg);
+        return rest;
+    }
+
+    /**
+     * 修改企业主页背景
+     *
+     * @param request
+     * @return
+     * @throws Exception
+     */
+//	@RequestMapping(value = "changeCenterBgImages", method = RequestMethod.POST)
+//	@ResponseBody
+//	public ResultEntity<EnterpriseBgImgsResp> changePortraitBackgroundPc(
+//			@RequestParam(required = false) MultipartFile portraitBackgroundPc,
+//			@RequestParam(required = false) MultipartFile portraitBackgroundMob,
+//			@RequestParam(required = false) MultipartFile topBackgroundPc,
+//			@RequestParam(required = false) MultipartFile topBackgroundMob, HttpServletRequest request)
+//			throws Exception {
+//		String userCode = commonService.getUserCode(request);
+//		ResultEntity<EnterpriseBgImgsResp> rest = new ResultEntity<EnterpriseBgImgsResp>();
+//		// 上传后的完整的背景图地址
+//		EnterpriseBgImgsResp bgImgsResp = new EnterpriseBgImgsResp(urlBase);
+//		// 上传图片并返回地址和更新的db数据条数
+//		int count = personCenterService.changeCenterBgImages(userCode, portraitBackgroundPc,portraitBackgroundMob,topBackgroundPc,topBackgroundMob, bgImgsResp);
+//
+//		if (count < 1) {
+//			rest.setMsg(InfoMsg.ERROR_UPLOAD_FIELD);
+//		} else {
+//			rest.setResult(bgImgsResp);
+//		}
+//		return rest;
+//	}
+
+}

+ 593 - 0
src/main/java/com/wechat/controller/PositionController.java

@@ -0,0 +1,593 @@
+package com.wechat.controller;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.docx4j.TraversalUtil;
+import org.docx4j.XmlUtils;
+import org.docx4j.convert.in.xhtml.FormattingOption;
+import org.docx4j.convert.in.xhtml.ImportXHTMLProperties;
+import org.docx4j.convert.in.xhtml.XHTMLImporter;
+import org.docx4j.convert.in.xhtml.XHTMLImporterImpl;
+import org.docx4j.dml.wordprocessingDrawing.Inline;
+import org.docx4j.finders.RangeFinder;
+import org.docx4j.jaxb.Context;
+import org.docx4j.openpackaging.io3.Save;
+import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
+import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage;
+import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
+import org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart;
+import org.docx4j.org.apache.poi.util.IOUtils;
+import org.docx4j.wml.Body;
+import org.docx4j.wml.CTBookmark;
+import org.docx4j.wml.Document;
+import org.docx4j.wml.Drawing;
+import org.docx4j.wml.ObjectFactory;
+import org.docx4j.wml.P;
+import org.docx4j.wml.R;
+import org.docx4j.wml.RFonts;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.CommonHelper;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.dao.PagingResult;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dto.City;
+import com.wechat.model.dto.JobAdvertisedListDto;
+import com.wechat.model.dto.JobRepFormDtlDto;
+import com.wechat.model.dto.JobRepFormPvDto;
+import com.wechat.model.dto.JobViewDateViewDto;
+import com.wechat.model.requestDto.JobCollectionReq;
+import com.wechat.model.requestDto.JobFairReq;
+import com.wechat.model.requestDto.JobReportFormReq;
+import com.wechat.model.requestDto.PageReq;
+import com.wechat.model.requestDto.PositionSearchReq;
+import com.wechat.model.responseDto.DPResp;
+import com.wechat.model.responseDto.JobAdvertisedNologinResp;
+import com.wechat.model.responseDto.JobFairByHotelResp;
+import com.wechat.model.responseDto.JobfairDepdsCitys;
+import com.wechat.model.responseDto.LVResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeJobAdvertisedService;
+import com.wechat.service.PositionService;
+
+
+/**
+ * 职位
+ * @author tangwc
+ *
+ */
+@Controller
+@RequestMapping("position")
+public class PositionController {
+	
+	@Autowired
+	private PositionService positionService;
+	
+	@Autowired
+	private MdeJobAdvertisedService jobAdvertisedService;
+	
+	@Resource
+	private CommonHelper commonHelper;
+	
+	@Autowired
+	private CommonService commonService;
+	
+	@Value("#{configProperties['upload.base.path']}")
+	private String basePackagePath;
+	@Value("#{configProperties['upload.path.file']}")
+	private String uploadFilePath;
+	
+	// log 处理
+	protected static final Log log = LogFactory.getLog(PositionController.class);
+	
+	/**
+	 * 职位页面初始化
+	 * @param userCode
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Map<String,Object>> initMainPage(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		String lang = commonService.getLanguage(request);
+		Map<String,Object> map = positionService.init(userCode,lang);
+		
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,map);
+	}
+	
+	/**
+	 * 获取推荐职位-分页查询
+	 * @param userCode
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getPagingRecommentJobs", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<PagingResult<JobAdvertisedListDto>> getPagingRecommentJobs(HttpServletRequest request,@RequestBody PageReq page) throws Exception {
+		ResultEntity<PagingResult<JobAdvertisedListDto>> rest = new ResultEntity<PagingResult<JobAdvertisedListDto>>();
+		String userCode = commonService.getUserCode(request);
+
+		rest.setResult(positionService.getPagingRecommentJobs(page, userCode));
+		
+		return rest;
+	}
+	
+	/**
+	 * 获取企业邀请数量
+	 * @param userCode
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getHotelInvitationCount", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<Integer> getHotelInvitationCount(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST,positionService.getRecievedHotelInvationInfoCounts(userCode));
+	}
+	
+	/**
+	 * 职位检索 按照关键词检索
+	 * @param searchReq > keyWord index size
+	 * @return
+	 */
+	@RequestMapping(value="searchPosition", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<PagingResult<JobAdvertisedListDto>> searchPositionByKeyWord(@RequestBody PositionSearchReq searchReq, HttpServletRequest request){
+		String lang = commonService.getLanguage(request);
+		return new ResultEntity<PagingResult<JobAdvertisedListDto>>(InfoMsg.SUCCESS_REQUEST,positionService.searchPositionByKeyWord(searchReq,lang));
+	}
+	/**
+	 * 职位检索 按条件检索
+	 * @param searchReq > position addProvince addCity addArea index size
+	 * @return
+	 */
+	@RequestMapping(value="searchPositionByCondition", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<PagingResult<JobAdvertisedListDto>> searchPositionByCondition(@RequestBody PositionSearchReq searchReq, HttpServletRequest request){
+		String lang = commonService.getLanguage(request);
+		return new ResultEntity<PagingResult<JobAdvertisedListDto>>(InfoMsg.SUCCESS_REQUEST,positionService.searchPositionByCondition(searchReq,lang));
+	}
+	
+	/**
+	 * 职位详情
+	 * @param jobId 发布职位id
+	 * @return
+	 */
+	@RequestMapping(value="getPositionDetail", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String,Object>> getPositionDetail(@RequestParam Integer jobId,@RequestParam(required=false) String shareJob,HttpServletRequest request){
+		String userCode = commonService.getUserCode(request);
+		String lang = commonService.getLanguage(request);
+		if(jobId==0 && !StringsUtils.isEmpty(shareJob))
+		{
+			jobId = commonHelper.getJobId(shareJob);
+		}
+		Map<String, Object> mapResult = positionService.getPositionDetail(jobId,userCode,lang,null);
+		//职位id不正确
+		if(mapResult == null)
+		{
+			log.error("有攻击嫌疑!!ip:【"+ commonHelper.getIRealIPAddr(request)+"】");
+		} else {
+			//记录pv uv
+			positionService.recodeJobDtlPvUv(jobId,request);
+		}
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,mapResult);
+	}
+	
+	/**
+	 * 职位PV获取
+	 * @param jobId 发布职位id
+	 * @return
+	 */
+	@RequestMapping(value="getPositionPv", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Integer> getPositionPv(@RequestParam Integer jobId,@RequestParam(required=false) String shareJob,HttpServletRequest request){
+		if(jobId==0 && !StringsUtils.isEmpty(shareJob))
+		{
+			jobId = commonHelper.getJobId(shareJob);
+		}
+		int jobPv = positionService.getPvByJobId(jobId);
+		return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST,jobPv);
+	}
+	
+	/**
+	 * 职位详情 未登录状态
+	 * @param jobId 发布职位id
+	 * @return
+	 */
+	@RequestMapping(value="getDetailNoLogin", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String,Object>> getDetailNoLogin(@RequestParam String shareJob,HttpServletRequest request){
+		Integer jobId = commonHelper.getJobId(shareJob);
+		String lang = commonService.getLanguage(request);
+		Map<String, Object> mapResult = positionService.getPositionDetail(jobId,null,lang,shareJob);
+		//职位id不正确
+		if(mapResult == null)
+		{
+			log.error("有攻击嫌疑!!ip:【"+ commonHelper.getIRealIPAddr(request)+"】");
+		} else {
+			//记录pv uv
+			positionService.recodeJobDtlPvUv(jobId,request);
+		}
+
+		return new ResultEntity<Map<String,Object>>(InfoMsg.SUCCESS_REQUEST,mapResult);
+	}
+	
+	/**
+	 * 职位收藏与取消
+	 * @param userCode  jobId 发布职位id
+	 * @return
+	 */
+	@RequestMapping(value="jobCollection", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Integer> jobCollection(@RequestBody JobCollectionReq collection){
+		
+		return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST,positionService.updateUserJobCollection(collection));
+	}
+	
+	
+	/**
+	 * 投递简历
+	 * @param jobId 发布职位id  curriculumVitae
+	 * @return
+	 */
+	@RequestMapping(value="postCurriculumVitae", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Integer> postCurriculumVitae(@Valid @RequestBody JobCollectionReq collection,HttpServletRequest req){
+		int i = positionService.postCurriculumVitae(collection,req);
+		if(i == 1) {
+			return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST,i);
+		}
+		return new ResultEntity<Integer>(InfoMsg.ERROR_SAVE_FIELD,i);
+		
+	}
+	
+	/**
+	 * 创建简历
+	 * @param jobId 发布职位id  curriculumVitae
+	 * @throws Exception 
+	 */
+	@RequestMapping(value="makeCV", method = RequestMethod.POST)
+	@ResponseBody
+	public void makeCV(@RequestParam String html) throws Exception{
+	        String baseURL = "C:\\Users\\Administrator\\Desktop";
+
+	        String content = "<html>" +
+	                "<head>你好</head>" +
+	               "<body>" +
+	                 "<table>" +
+	                  "<tr>" +
+	                   "<td>信息1</td>" +              
+	                   "<td>信息2</td>" +              
+	                   "<td>t3</td>" +              
+	                  "<tr>" +
+	                 "</table>" +
+	                 "</body>" +
+	                 "</html>";
+
+	        
+	        String unescaped = html;
+	        if (html.contains("&lt;") ) {
+	            unescaped = StringEscapeUtils.unescapeHtml(html);
+	        }
+	        // 设置字体映射
+	        RFonts rfonts = Context.getWmlObjectFactory().createRFonts();
+	        rfonts.setAscii("Century Gothic");
+	        XHTMLImporterImpl.addFontMapping("Century Gothic", rfonts);
+
+	        // 创建一个空的docx对象
+	        ImportXHTMLProperties.setProperty("docx4j-ImportXHTML.Element.Heading.MapToStyle", true);
+	        WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+
+	        XHTMLImporter importer = new XHTMLImporterImpl(wordMLPackage);
+	        importer.setRunFormatting(FormattingOption.CLASS_PLUS_OTHER);
+
+
+	        NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
+	        wordMLPackage.getMainDocumentPart().addTargetPart(ndp);
+	        ndp.unmarshalDefaultNumbering();
+
+	        // 转换XHTML,并将其添加到我们制作的空docx中
+	        XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage);
+
+	        XHTMLImporter.setHyperlinkStyle("Hyperlink");
+	        wordMLPackage.getMainDocumentPart().getContent().addAll(
+	                XHTMLImporter.convert(unescaped, basePackagePath+uploadFilePath));
+	        wordMLPackage.save(new java.io.File(basePackagePath+uploadFilePath+"test.docx"));
+		
+	}
+	
+	@RequestMapping(value="makeCV2", method = RequestMethod.POST)
+	@ResponseBody
+	public static void main(@RequestParam String img) throws Exception {
+
+        org.docx4j.wml.ObjectFactory foo = Context.getWmlObjectFactory();
+
+        String template = "C:/Users/LENOVO/Desktop/20190623tpl.docx";
+
+        boolean save = true;
+        String outputfilepath = "C:/Users/LENOVO/Desktop/test.docx";
+        
+        String imagePath = "C:/Users/LENOVO/Desktop/1537933417000_11861375768989696_mini.jpg";
+        
+        // 书签名
+        String bookmarkName = "headimg";
+        // 载入模板文件
+        WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(template));
+        // 提取正文
+        MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
+        Document wmlDoc = (Document) documentPart.getJaxbElement();
+        Body body = wmlDoc.getBody();
+        // 提取正文中所有段落
+        List<Object> paragraphs = body.getContent();
+        // 提取书签并创建书签的游标
+        RangeFinder rt = new RangeFinder("CTBookmark", "CTMarkupRange");
+        new TraversalUtil(paragraphs, rt);
+
+        //需要替换的map
+        HashMap<String, String> mappings = new HashMap<String, String>();
+        mappings.put("img", img);
+        mappings.put("name", "25");
+        /*        mappings.put("username", "qlq");*/
+        
+        
+     // 遍历书签
+        for (CTBookmark bm : rt.getStarts()) {
+            // 这儿可以对单个书签进行操作,也可以用一个map对所有的书签进行处理
+            if (bm.getName().equals(bookmarkName)) {
+        // 读入图片并转化为字节数组,因为docx4j只能字节数组的方式插入图片
+        InputStream is = new FileInputStream(imagePath);
+        byte[] bytes = IOUtils.toByteArray(is);
+        // 穿件一个行内图片
+        BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
+
+        // createImageInline函数的前四个参数我都没有找到具体啥意思,,,,
+        // 最有一个是限制图片的宽度,缩放的依据
+        Inline inline = imagePart.createImageInline(null, null, 0, 1, false, 800);
+        // 获取该书签的父级段落headimg
+        P p = (P) (bm.getParent());
+
+        ObjectFactory factory = new ObjectFactory();
+        // R对象是匿名的复杂类型,然而我并不知道具体啥意思,估计这个要好好去看看ooxml才知道
+        R run = factory.createR();
+        // drawing理解为画布?
+        Drawing drawing = factory.createDrawing();
+        drawing.getAnchorOrInline().add(inline);
+        run.getContent().add(drawing);
+        p.getContent().add(run);
+
+            }}
+
+        long start = System.currentTimeMillis();
+
+        documentPart.variableReplace(mappings);
+
+        long end = System.currentTimeMillis();
+        long total = end - start;
+        System.out.println("Time: " + total);
+
+        // Save it
+        if (save) {
+        	Save saver = new Save(wordMLPackage);
+        	saver.save(new FileOutputStream(outputfilepath));
+/*            SaveToZipFile saver = new SaveToZipFile(wordMLPackage);
+            saver.save(outputfilepath);*/
+        } else {
+            System.out.println(XmlUtils.marshaltoString(documentPart.getJaxbElement(), true, true));
+        }
+    }
+	
+	
+	/**
+	 * 获取招聘会信息
+	 * @return
+	 * @throws UnsupportedEncodingException 
+	 */
+	@RequestMapping(value="getJobFair", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<JobFairByHotelResp> getJobFair(@RequestBody JobFairReq fairReq,HttpServletRequest request) throws UnsupportedEncodingException{
+		ResultEntity<JobFairByHotelResp> result = new ResultEntity<JobFairByHotelResp>();
+		JobFairByHotelResp hotels = positionService.getJobFairByHotel(fairReq.getFairId());
+		//招聘会获取为空
+		if(null == hotels)
+		{
+			result.setMsg(InfoMsg.ERROR_JOBFAIR_OFF);
+		}
+		result.setResult(hotels);
+
+		return result;
+	}
+	
+	/**
+	 * 获取招聘会
+			酒店在招职位列表信息
+	 * @param usercode 用户id
+	 * @return
+	 */
+	@RequestMapping(value="getFairJobList", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<JobAdvertisedNologinResp>> getFairJobListByHotel(@RequestParam String shareCode,HttpServletRequest request){
+		ResultEntity<List<JobAdvertisedNologinResp>> result = new ResultEntity<List<JobAdvertisedNologinResp>>();
+		String code[] = commonHelper.getUserCodeAes(shareCode);
+		String userCode= code[0];
+		
+		List<JobAdvertisedNologinResp> jobList = jobAdvertisedService.getPublishingJobsNologin(userCode);
+		//职位列表为空
+		if(jobList == null)
+		{
+			result.setMsg(InfoMsg.ERROR_JOBFAIR_OFF);
+		}
+		result.setResult(jobList);
+
+		return result;
+	}
+	
+	/**
+	 * 获取招聘会参与酒店的
+	 *  职位列表信息和城市信息
+	 * @return
+	 */
+	@RequestMapping(value="getJobFairDepdCitys", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<JobfairDepdsCitys> getJobFairDepdCitys(@RequestParam Integer fairId,HttpServletRequest request){
+		ResultEntity<JobfairDepdsCitys> result = new ResultEntity<JobfairDepdsCitys>();
+		List<City> citys = positionService.getJobFairCitys(fairId);
+		List<DPResp> depds = positionService.getJobFairDepartments(fairId);
+		//招聘会获取为空
+		if(citys == null || depds == null || depds.isEmpty() || citys.isEmpty())
+		{
+			result.setMsg(InfoMsg.ERROR_JOBFAIR_OFF);
+		}
+		
+		JobfairDepdsCitys fairInfo = new JobfairDepdsCitys();
+		fairInfo.setCitys(citys);
+		fairInfo.setDepds(depds);
+		result.setResult(fairInfo);
+
+		return result;
+	}
+	
+	
+	/**
+	 * 根据时间查询 某企业简历投递数据
+	 * @param usercode 用户id
+	 * @return
+	 */
+	@RequestMapping(value="getJobViewByDate", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<List<JobRepFormPvDto>> getJobViewByDate(@RequestBody JobReportFormReq req, HttpServletRequest request, HttpServletResponse response) {
+		ResultEntity<List<JobRepFormPvDto>> result = new ResultEntity<List<JobRepFormPvDto>>();
+		String userCode = commonService.getUserCode(request);
+		
+		//按时间统计
+		List<JobRepFormPvDto> resultList = new ArrayList<JobRepFormPvDto>();
+		//统计类型
+		String statisticType = req.getStatisticType();
+		if(StringsUtils.isEmpty(statisticType) && req.getDayStart() ==null) {
+			req.setStatisticType("0");
+			statisticType = "0";
+		}
+		
+		//根据集记方式处理起止时间
+		JobViewDateViewDto dvDto = positionService.getStrEndDataByType(statisticType,req.getDayStart(),req.getDayEnd());
+		
+		//按时间集记
+		resultList = positionService.findRepFormPvByDate(userCode,dvDto,req.getJobId());
+
+		result.setResult(resultList);
+		
+		return result;
+	}
+	
+	/**
+	 * 根据时间查询 某企业简历投递数据
+	 * 总分析图表
+	 * @param usercode 用户id
+	 * @return
+	 */
+	@RequestMapping(value="getGeneralJobViewByDate", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Map<String, Integer>> getGeneralJobViewByDate(@RequestBody JobReportFormReq req, HttpServletRequest request, HttpServletResponse response) {
+		ResultEntity<Map<String, Integer>> result = new ResultEntity<Map<String, Integer>>();
+		String userCode = commonService.getUserCode(request);
+		//统计类型
+		String statisticType = req.getStatisticType();
+		if(StringsUtils.isEmpty(statisticType) && req.getDayStart() ==null) {
+			req.setStatisticType("0");
+			statisticType = "0";
+		}
+		
+		//根据集记方式处理起止时间
+		JobViewDateViewDto dvDto = positionService.getStrEndDataByType(statisticType,req.getDayStart(),req.getDayEnd());
+		
+		//按时间集记
+		Map<String, Integer> resultMap = positionService.findGeneralViewByDate(userCode,dvDto,req.getJobId());
+
+		result.setResult(resultMap);
+		
+		return result;
+	}
+	
+	/**
+	 * 根据时间查询 候选者的学历分步
+	 * 总分析图表
+	 * @param usercode 用户id
+	 * @return
+	 */
+	@RequestMapping(value="countEducationByDate", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<List<LVResp>> countEducationByDate(@RequestBody JobReportFormReq req, HttpServletRequest request, HttpServletResponse response) {
+		ResultEntity<List<LVResp>> result = new ResultEntity<List<LVResp>>();
+		String userCode = commonService.getUserCode(request);
+		//统计类型
+		String statisticType = req.getStatisticType();
+		if(StringsUtils.isEmpty(statisticType) && req.getDayStart() ==null) {
+			req.setStatisticType("0");
+			statisticType = "0";
+		}
+		
+		//根据集记方式处理起止时间
+		JobViewDateViewDto dvDto = positionService.getStrEndDataByType(statisticType,req.getDayStart(),req.getDayEnd());
+		
+		//按时间集记
+		List<LVResp> resultMap = positionService.countEducationByDate(userCode,dvDto,req.getJobId());
+
+		result.setResult(resultMap);
+		
+		return result;
+	}
+	
+	/**
+	 * 根据时间查询 某企业简历投递数据
+	 * 数据列表
+	 * @param usercode 用户id
+	 * @return
+	 */
+	@RequestMapping(value="getReportsFormByDate", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<List<JobRepFormDtlDto>> getReportsFormByDate(@RequestBody JobReportFormReq req, HttpServletRequest request, HttpServletResponse response) {
+		ResultEntity<List<JobRepFormDtlDto>> result = new ResultEntity<List<JobRepFormDtlDto>>();
+		String userCode = commonService.getUserCode(request);
+		//统计类型
+		String statisticType = req.getStatisticType();
+		if(StringsUtils.isEmpty(statisticType) && req.getDayStart() ==null) {
+			req.setStatisticType("0");
+			statisticType = "0";
+		}
+		
+		//根据集记方式处理起止时间
+		JobViewDateViewDto dvDto = positionService.getStrEndDataByType(statisticType,req.getDayStart(),req.getDayEnd());
+		
+		//按时间集记
+		List<JobRepFormDtlDto> resultList = positionService.getReportsFormByDate(userCode,dvDto);
+
+		result.setResult(resultList);
+		
+		return result;
+	}
+	
+}

+ 92 - 0
src/main/java/com/wechat/controller/QrCodeController.java

@@ -0,0 +1,92 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.util.Date;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.alibaba.fastjson.JSON;
+import com.wechat.common.Constants;
+import com.wechat.common.TwoDimensionCode;
+import com.wechat.common.utils.MvcUtil;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.responseDto.JsonResp;
+import com.wechat.model.responseDto.QrCodeResp;
+import com.wechat.service.WeiXinService;
+
+
+/**
+ * FAQ问答
+ * 
+ */
+@Controller
+@RequestMapping("qrCode")
+public class QrCodeController extends BaseController {
+	
+	// 上传根路径
+	@Value("#{configProperties['upload.base.path']}")
+	private String updBaseUrl;
+	
+	// 二维码图片
+	@Value("#{configProperties['upload.qrcode.path']}")
+	private String updQrcodeUrl;
+	
+	// 访问根路径
+	@Value("#{configProperties['url.base']}")
+	private String baseUrl;
+	
+	// 图片根路径
+	@Value("#{configProperties['url.img.base']}")
+	private String baseImgUrl;
+	
+    @Resource
+    private WeiXinService wxService;
+     
+    /**
+     * 入口二维码生成
+     * 
+     */
+    @RequestMapping(value = "getQrCode", method = RequestMethod.GET)
+    public void getQrCode(HttpServletRequest request, HttpServletResponse response, @RequestParam String longUrl) throws Exception{
+        JsonResp<QrCodeResp> ret = new JsonResp<QrCodeResp>();
+        QrCodeResp qrResp = new QrCodeResp();
+        //生成短链接
+        String url = wxService.getShortUrl(URLDecoder.decode(longUrl, "utf-8"));
+        if(StringsUtils.isEmpty(url))
+        {
+        	log.error("短链接生成异常");
+	     	ret.setMsg(InfoMsg.ERROR_SYSTEM_ERROR);
+        }
+        else
+        {
+        	//二维码生成生成
+        	String qrCodeName =  "qrCode" + StringsUtils.parseLong((new Date()).getTime()) + ".png";
+            TwoDimensionCode.encoderQRCode(url, updBaseUrl + updQrcodeUrl + qrCodeName, "png", 5);
+            
+            //返回信息时装
+            qrResp.setQrCodeImg(baseUrl + baseImgUrl + updQrcodeUrl + qrCodeName);
+            qrResp.setShortUrl(url);
+            
+            ret.setInfo(qrResp);
+        }
+
+        String json = JSON.toJSONString(ret, true);
+        try {
+            MvcUtil.writeJson(request, response, json);
+        } catch (IOException e) {
+           log.error(e);
+        } 
+    }
+    
+}

+ 93 - 0
src/main/java/com/wechat/controller/RecruitmentReleaseController.java

@@ -0,0 +1,93 @@
+package com.wechat.controller;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.utils.MessageUtils;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeJobAdvertised;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.RecruitmentInformationReleaseService;
+
+@Controller
+@RequestMapping("recruit")
+public class RecruitmentReleaseController {
+
+	@Autowired
+	RecruitmentInformationReleaseService releaseService;
+
+	@Autowired
+	CommonService commonService;
+
+	//非付费企业可发职位次数
+	@Value("#{configProperties['unvip_release_no']}")
+	private String unvipReleaseNo;
+	
+	/**
+	 * 是否可发布招聘信息
+	 * 
+	 * @param mdeJobAdvertised
+	 * @return true 可发布  false 不可发布
+	 * @throws Exception 
+	 */
+	@RequestMapping(value = "checkReleaseLimit", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Boolean> checkReleaseLimit(HttpServletRequest req) throws Exception {
+		ResultEntity<Boolean> rest = new ResultEntity<Boolean>();
+		// 获取发布人信息
+		String publisher = commonService.getUserCode(req);
+		boolean bol = releaseService.checkReleaseLimit(publisher);
+		//验证企业发布次数
+		if(!bol)
+		{
+			//超限
+			InfoMsg msg = InfoMsg.ERROR_RELEASE_BEYOND;
+			msg.setMsg(MessageUtils.getText(msg.getMsg(), unvipReleaseNo));
+			rest.setMsg(msg);
+		}
+		rest.setResult(bol);
+		return rest;
+	}
+
+	/**
+	 * 招聘信息提交
+	 * 	并进行入参数据校验
+	 * @return
+	 * @throws Exception 
+	 */
+	@RequestMapping(value = "recruitmentInformationRelease", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> recruitmentInformationRelease(
+			@Validated(value = MdeJobAdvertised.SaveGroup.class) @RequestBody MdeJobAdvertised jobAdvertised, HttpServletRequest req) throws Exception {
+		// 获取发布人信息
+		String publisher = commonService.getUserCode(req);
+		jobAdvertised.setPublisher(publisher);
+		
+		// 职位类别
+		Integer jobCode = jobAdvertised.getJobId();
+
+		// 新增或者重启结束的职位 (职位发布状态[0-招聘中;1-结束]) 验证发布次数
+		if(jobCode== null && "1".equals(jobAdvertised.getJobStatus()))
+		{
+			//验证企业发布次数
+			if(!releaseService.checkReleaseLimit(publisher))
+			{
+				//超限
+				InfoMsg msg = InfoMsg.ERROR_RELEASE_BEYOND;
+				msg.setMsg(MessageUtils.getText(msg.getMsg(), unvipReleaseNo));
+				return new ResultEntity<>(msg);
+			}
+		}
+
+		return releaseService.recruitmentInformationRelease(jobAdvertised, req);
+	}
+}

+ 147 - 0
src/main/java/com/wechat/controller/RefundController.java

@@ -0,0 +1,147 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.alibaba.fastjson.JSON;
+import com.wechat.common.Constants;
+import com.wechat.common.utils.MvcUtil;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.TdtgGoodsRejected;
+import com.wechat.model.responseDto.JsonResp;
+import com.wechat.service.WeiXinService;
+
+
+/**
+ * FAQ问答
+ * 
+ */
+@Controller
+@RequestMapping("refund")
+public class RefundController extends BaseController {
+
+    //域名
+    @Value("#{configProperties['url.base']}")
+    private String baseUrl;
+    
+    //图片根目录
+    @Value("#{configProperties['url.img.base']}")
+    private String imgUrl;
+    
+    //退款图片路径
+    @Value("#{configProperties['upload.refund.path']}")
+    private String refoundUrl;
+
+    
+    @Resource
+    private WeiXinService wxService;
+
+
+    /**
+
+     * 获取下载图片信息(jpg)
+     * 
+     * @param mediaId 文件的id
+     * @throws Exception
+     */
+    @RequestMapping(value = "saveGoodsRejected", method = RequestMethod.POST)
+    public  void saveGoodsRejected(@RequestParam String orderNo, @RequestParam String refundReason,@RequestParam BigDecimal refundAmount,@RequestParam String mobile,@RequestParam String imgList, @RequestParam String oldImgList, HttpServletRequest request, HttpServletResponse response) throws Exception {
+    	TdtgGoodsRejected rejected = new TdtgGoodsRejected();
+    	JsonResp<String> ret = new JsonResp<String>();
+    	int imgLength = 0;
+    	if(StringsUtils.isEmpty(orderNo))
+    	{
+         	 ret.setMsg(InfoMsg.ERROR_SAVE_FIELD);
+    	}
+    	else
+    	{
+    		//mediaid 获取微信服务器图片
+    		if(!StringsUtils.isEmpty(imgList))
+    		{
+    			String[] imgArray = StringsUtils.split(imgList, ";");
+    			imgLength = imgArray.length;
+    			for(int i=0; i<imgArray.length; i++ )
+        		{
+        			String mediaId = imgArray[i];
+        			String fileName = "";
+        			if(!StringsUtils.isEmpty(mediaId))
+    				{
+        				//从微信服务器上获取图片至本地
+        				fileName = wxService.saveImageToDisk(mediaId,"");
+        				if(StringsUtils.isEmpty(fileName))
+        				{
+        					//系统异常
+        					throw new Exception();
+        				}
+        				switch (i)
+        				{
+        					case 0 :
+    	    					rejected.setVoucherImg1(fileName);
+    			    		    break;
+        					case 1 :
+    	    					rejected.setVoucherImg2(fileName);
+    			    		    break;
+        					case 2 :
+    	    					rejected.setVoucherImg3(fileName);
+    			    		    break;
+        				}
+    				}	
+        		}
+    		}
+    			
+			// 原已上传的服务器图片
+			if (!StringsUtils.isEmpty(oldImgList)) {
+				String[] oldImgArray = StringsUtils.split(oldImgList, ";");
+				for (int i = 0; i < oldImgArray.length; i++) {
+					String fileName = oldImgArray[i];
+					if (StringsUtils.isEmpty(fileName)) {
+						// 系统异常
+						throw new Exception();
+					}
+					switch (i+imgLength) {
+					case 0:
+						rejected.setVoucherImg1(fileName);
+						break;
+					case 1:
+						rejected.setVoucherImg2(fileName);
+						break;
+					case 2:
+						rejected.setVoucherImg3(fileName);
+						break;
+					}
+
+				}
+			}
+
+    		rejected.setOrderNo(orderNo);
+    		rejected.setRefundReason(refundReason);
+    		rejected.setRefundAmount(refundAmount);
+    		rejected.setMobile(mobile);
+    		//已申请
+    		rejected.setStatus(1);
+
+    	}
+    	
+        
+        String json = JSON.toJSONString(ret, true);
+        try {
+            MvcUtil.writeJson(request, response, json);
+        } catch (IOException e) {
+           log.error(e);
+        } 
+    }
+
+    
+}

+ 347 - 0
src/main/java/com/wechat/controller/RegisterController.java

@@ -0,0 +1,347 @@
+package com.wechat.controller;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+
+import com.wechat.common.Constants;
+import com.wechat.common.utils.Md5Utils;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeEducationExperience;
+import com.wechat.model.dbEntity.MdeHotelCompany;
+import com.wechat.model.dbEntity.MdePositionAnotherName;
+import com.wechat.model.dbEntity.MdeUser;
+import com.wechat.model.dto.AuzUserInfoDto;
+import com.wechat.model.requestDto.ExperienceResp;
+import com.wechat.model.requestDto.RegisterResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.AuthorizedService;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeHotelCompanyService;
+import com.wechat.service.MdeUserService;
+import com.wechat.service.PersonCeneterService;
+import com.wechat.service.RegisterService;
+import com.wechat.service.WeiXinService;
+
+@Controller
+@RequestMapping("register")
+public class RegisterController extends BaseController {
+	@Value("#{configProperties['upload.base.path']}")
+	private String basePackagePath;
+	@Value("#{configProperties['upload.path.image']}")
+	private String baseImagePackagePath;
+	@Value("#{configProperties['compress.image.size']}")
+	private int compressImageSize;
+	
+	@Value("#{configProperties['upload.path.image.temporary']}")
+	private String imageTemporary;
+	
+	//在职证明 营业执照
+	@Value("#{configProperties['upload.path.image.onjob']}")
+	private String imageOnjob;
+
+	@Value("#{configProperties['url.base']}")
+	private String urlBase;
+	
+	@Autowired
+	private RegisterService registerService;
+
+	@Autowired
+	private MdeHotelCompanyService mdeHotelCompanyService;
+	
+	@Autowired
+	private PersonCeneterService personCenterService;
+
+	@Autowired
+	CommonService commonService;
+	
+	@Resource
+	private AuthorizedService authorizedService;
+
+	@Resource
+	private MdeUserService mdeUserService;
+
+	/**
+	 * 注册页面初始化 获取酒店品牌 区分国际
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "")
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> initRegisterPage(HttpServletRequest req) {
+		// 获取酒店品牌,区分国际国内
+		String lang = commonService.getLanguage(req);
+		Map<String, Object> map = new HashMap<String, Object>();
+		map.put("1", registerService.getHotelBrandList("1", lang));
+		map.put("2", registerService.getHotelBrandList("2", lang));
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+
+
+	/**
+	 * 用户注册
+	 * @param request
+	 * @throws Exception
+	 * @author jadyn.wu
+	 */
+	@RequestMapping(value = "userInfoSubmit", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> userInfoSubmit(@RequestBody RegisterResp jo, HttpServletRequest request, HttpServletResponse resp) throws Exception {
+		MdeUser userInfo = new MdeUser();
+		
+		// 身份标识[0-个人;1-企业]
+		String identityFlag = jo.getIdentityFlag();
+		userInfo.setIdentityFlag(identityFlag);
+		// 国家电话区号(列 +86)
+		String phoneCode = jo.getPhoneCode();
+		// 登录名[手机号-个人/邮箱-企业]
+		String userName = StringsUtils.trim(jo.getUserName());
+		// 密码
+		String password = StringsUtils.trim(jo.getPassword());
+		// 用户姓名/企业名称
+		String name = StringsUtils.trim(jo.getName());
+		// 外文名称
+		String foreignName = StringsUtils.trim(jo.getForeignName());
+		// 短信验证码
+		String phoneCheckCode = StringsUtils.trim(jo.getPhoneCheckCode());
+		//推广渠道来源
+		String inviter = jo.getInviter();
+		if(!StringsUtils.isEmpty(inviter))
+		{
+			//拼接 用户id短码+活动id
+			inviter = inviter.split(Constants.UNDER_LINE)[0]+Constants.UNDER_LINE+commonService.getActId();
+		}
+		
+		ResultEntity<String> entity = new ResultEntity<String>();
+
+		// 共通内容验证
+		if (StringUtils.isEmpty(jo.getHeadPortrait()) || StringUtils.isEmpty(userName) || StringUtils.isEmpty(password) || StringUtils.isEmpty(phoneCheckCode)
+				|| StringUtils.isEmpty(name) || StringUtils.isEmpty(identityFlag)) {
+			log.error("[出现空数据]HeadPortrait:"+jo.getHeadPortrait()+"--userName:"+userName+"--password:"+password+"--phoneCheckCode:"+phoneCheckCode+"--name:"+name+"--identityFlag:"+identityFlag);
+			return new ResultEntity<String>(InfoMsg.ERROR_INCOMPLETE_INFORMATION);
+		}else {
+			//用户名初始值
+			userInfo.setUserName(userName);
+			// 针对国外手机的个人用户
+			if ("0".equals(identityFlag)) {
+				String[] phoneCodeSplit = phoneCode.split("-");
+				if (phoneCodeSplit == null || phoneCodeSplit.length != 3) {
+					return new ResultEntity<>(InfoMsg.ERROR_PHONECODE_ERROR);
+				}
+				String phoneCodeStr = phoneCodeSplit[0]; // 国际手机区号码
+				// 设值
+				userInfo.setPhoneCode(phoneCodeStr); // 国际手机区号码
+				if (!phoneCodeStr.equals("86")) {
+					userInfo.setUserName("+" + phoneCodeStr + userName); // 如+86123456 (国际)
+				}
+				
+				// 个人注册验证短信
+				if (!commonService.validateCode(phoneCheckCode, userInfo.getUserName())) {
+					return new ResultEntity<String>(InfoMsg.ERROR_VERIFICATIONCODE);
+				}
+			} else {
+				// 企业注册验证短信
+				if (!commonService.validateCode(phoneCheckCode, jo.getEntPhone())) {
+					return new ResultEntity<String>(InfoMsg.ERROR_VERIFICATIONCODE);
+				}
+			}
+			
+			// 验证是否注册过
+			MdeUser mdeUser = mdeUserService.checkUserNameIsRegester(userInfo.getUserName());
+			if (mdeUser != null)
+			{
+				if ("0".equals(identityFlag)) {
+					return new ResultEntity<>(InfoMsg.ERROR_PHONE_IS_EXSIT);
+				} else {
+				return new ResultEntity<>(InfoMsg.ERROR_EMAIL_IS_EXSIT);}
+			}
+
+			//密码进行二次加密后存储
+			userInfo.setPassword(Md5Utils.EncoderPassword(password));
+			userInfo.setName(name);
+			userInfo.setForeignName(StringsUtils.isEmpty(foreignName) ? "" : foreignName);
+			
+			//记录推广渠道来源
+			userInfo.setInviter(StringsUtils.isEmpty(inviter) ? "" : inviter);
+			
+			//微信端静默登陆的情况下
+			if(!StringsUtils.isEmpty(jo.getCode()))
+			{
+				//登录来源0.pc 1.移动端
+				//获取用户微信信息
+				AuzUserInfoDto auzUserInfoDto = authorizedService.getUserInfoDetail(jo.getCode(), "1");
+				userInfo.setUnionId(auzUserInfoDto.getUnionid());
+				userInfo.setOpenId(auzUserInfoDto.getOpenid());
+			}
+			
+			//第三方登陆的情况下
+			if (StringsUtils.isNotEmpty(jo.getType())) {
+				userInfo = registerService.theThirdRegister(jo, userInfo);
+			}
+			if ("0".equals(identityFlag)) {
+				//个人注册
+				entity = registerService.personalRegister(jo, userInfo, resp, request);
+			} else {
+				//企业注册
+				entity = registerService.companyRegister(jo, userInfo, resp, request);	
+			}
+			
+			//记录登陆历史
+			commonService.addLoginHis(request,userInfo.getUserCode());
+			
+			return entity;
+		}
+		
+	}
+
+	
+	/**
+	 * 工作简历及教育经历提交
+	 * 
+	 * @param mdeWorkExperiences
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "experienceSubmit", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> experienceSubmit(@RequestBody ExperienceResp resp, HttpServletRequest req) throws Exception {
+		String lang = commonService.getLanguage(req);
+		String userCode = commonService.getUserCode(req);
+		
+		//工作经验入参验证
+		if (!registerService.validated(resp.getMdeWorkExperienceList())) {
+			return new ResultEntity<>(InfoMsg.ERROR_INCOMPLETE_INFORMATION);
+		}else {
+			//工作经验保存
+			if (!registerService.expericnceSubmit(resp.getMdeWorkExperienceList(),userCode, req).getCode().equals("0")) {
+				return new ResultEntity<>(InfoMsg.ERROR_INSERT_ERROR);
+			}
+		}
+		
+		//教育履历修
+		MdeEducationExperience edu = resp.getEducationExperience();
+		if(edu != null)
+		{
+			if(edu.getEducation() == null || StringsUtils.isEmpty(edu.getSchName()) || StringsUtils.isEmpty(edu.getSpeciality())|| edu.getEnterDate() == null)
+			{
+				return new ResultEntity<>(InfoMsg.ERROR_INCOMPLETE_INFORMATION);
+			}
+			edu.setUserCode(userCode);
+			if (personCenterService.modefyEducationExperience(edu,lang) != 1) {
+				return new ResultEntity<>(InfoMsg.ERROR_INSERT_ERROR);
+			}
+		}
+
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST);
+	}
+	
+
+	/**
+	 * 企业执照上传
+	 * 
+	 * @param request
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "upload", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> upload(HttpServletRequest request) throws Exception {
+		MultipartFile picture = ((MultipartHttpServletRequest) request).getFile("picture");
+		if (picture.isEmpty()) {
+			return new ResultEntity<>(InfoMsg.ERROR_NULL_PARAM);
+		}
+		return registerService.upload(picture,imageOnjob);
+	}
+
+	/**
+	 * 在职证明上传
+	 * 
+	 * @param request
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "uploadOnJobImage", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> uploadOnJobImage(HttpServletRequest request) throws Exception {
+		MultipartFile onJobImage = ((MultipartHttpServletRequest) request).getFile("onJobImage");
+		if (onJobImage.isEmpty()) {
+			return new ResultEntity<>(InfoMsg.ERROR_NULL_PARAM);
+		}
+		return registerService.upload(onJobImage,imageOnjob);
+	}
+	
+	/**
+	 * 在职证明\营业执照上传 手机
+	 * 
+	 * @param request
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "uploadOnJobImageWx", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> uploadOnJobImage(@RequestParam String pictureId) throws Exception {
+		return commonService.uploadByWx(pictureId,imageOnjob);
+	}
+	
+
+	/**
+	 * 获取所有职位
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "getAllPositionAnotherName")
+	@ResponseBody
+	public ResultEntity<List<MdePositionAnotherName>> getAllPositionAnotherName() {
+
+		return registerService.getAllPositionAnotherName();
+	}
+
+	/**
+	 * 根据语言获取所有酒店
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "getAllHotelCompany")
+	@ResponseBody
+	public ResultEntity<List<MdeHotelCompany>> getAllHotelCompany(HttpServletRequest req) {
+		String lang = commonService.getLanguage(req);
+		Map<String, String> map = new HashMap<String, String>();
+		map.put("lang", lang);
+		List<MdeHotelCompany> list = mdeHotelCompanyService.getAllHotelCompanyByLang(map);
+		return new ResultEntity<List<MdeHotelCompany>>(InfoMsg.SUCCESS_REQUEST, list);
+	}
+
+	
+	/**
+	 * 头像上传-手机
+	 * 
+	 * @param request
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "uploadHeadPortrait", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> uploadHeadPortrait(@RequestParam String pictureId) throws Exception {
+		return commonService.uploadByWx(pictureId,imageTemporary);
+	}
+	
+
+}

+ 160 - 0
src/main/java/com/wechat/controller/TalentRetrievalController.java

@@ -0,0 +1,160 @@
+package com.wechat.controller;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.global.base.dao.PagingResult;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeJobAdvertised;
+import com.wechat.model.dbEntity.MdeJobInvitationRel;
+import com.wechat.model.dbEntity.MdeUser;
+import com.wechat.model.dto.TalentRetrievalDto;
+import com.wechat.model.requestDto.AlentRetrievalReq;
+import com.wechat.model.requestDto.KeyWordReq;
+import com.wechat.model.requestDto.PageReq;
+import com.wechat.model.responseDto.ContactUserInfoResp;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeJobInvitationRelService;
+import com.wechat.service.TalentRetrievalService;
+
+/**
+ * 人才检索
+ * 
+ * @author zhouyd
+ *
+ */
+@Controller
+@RequestMapping(value = "talentRetrieval")
+public class TalentRetrievalController {
+
+	@Autowired
+	private TalentRetrievalService talentRetrievalService;
+
+	@Autowired
+	private MdeJobInvitationRelService mdeJobInvitationRelService;
+	
+	@Autowired
+	private CommonService commonService;
+
+	/**
+	 * 人才页面初始化
+	 * @param request
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<Map<String, Object>> initTalen(HttpServletRequest request) throws Exception {
+		Map<String, Object> map = talentRetrievalService.init(request);
+		return new ResultEntity<Map<String, Object>>(InfoMsg.SUCCESS_REQUEST, map);
+	}
+	
+	/**
+	 * 优选人才-分页查询
+	 * @param userCode
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getPagingRecmtPep", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<PagingResult<TalentRetrievalDto>> getPagingRecmtPep(HttpServletRequest request,@RequestBody PageReq page) throws Exception {
+		ResultEntity<PagingResult<TalentRetrievalDto>> rest = new ResultEntity<PagingResult<TalentRetrievalDto>>();
+		String userCode = commonService.getUserCode(request);
+		PagingResult<TalentRetrievalDto>  talentList= talentRetrievalService.getPagingRecmtPep(page,userCode);
+		rest.setResult(talentList);
+		return rest;
+	}
+	
+
+	/**
+	 * 人才检索
+	 * 
+	 * @param req
+	 * @param resp
+	 * @param alentReq
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "searchKeyWord", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<PagingResult<TalentRetrievalDto>> searchPersonAbility(HttpServletRequest req,
+			HttpServletResponse resp, @RequestBody KeyWordReq keyWordReq) throws Exception {
+		PagingResult<TalentRetrievalDto> page = talentRetrievalService.searchKeyWord(keyWordReq,req);
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, page);
+	}
+
+	/**
+	 * 筛选人才
+	 * 
+	 * @param req
+	 * @param resp
+	 * @param alentRetrievalReq
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "filterPersonAbility", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<PagingResult<TalentRetrievalDto>> filterPersonAbility(HttpServletRequest req,
+			HttpServletResponse resp, @RequestBody AlentRetrievalReq alentRetrievalReq) throws Exception {
+		PagingResult<TalentRetrievalDto> page = talentRetrievalService.filterPersonAbility(alentRetrievalReq,req);
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, page);
+	}
+
+	/**
+	 * 查看联系方式
+	 * 
+	 * @param userCode
+	 * @return
+	 */
+	@RequestMapping(value = "getContactNumber", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<ContactUserInfoResp> getContactNumber(@RequestParam String userCode, HttpServletRequest req) {
+		String lang = commonService.getLanguage(req);
+		ContactUserInfoResp contactUserInfoResp = talentRetrievalService.getContactNumber(userCode,lang);
+
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, contactUserInfoResp);
+	}
+
+	/**
+	 * 邀请投递简历
+	 * 
+	 * @param mdeJobInvitationRel
+	 * @param req
+	 * @param resp
+	 * @return
+	 */
+	@RequestMapping(value = "invitationDeliver", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> invitationDeliver(@Valid @RequestBody MdeJobInvitationRel mdeJobInvitationRel,
+			HttpServletRequest req, HttpServletResponse resp) {
+		return mdeJobInvitationRelService.invitationDeliver(req, mdeJobInvitationRel);
+	}
+
+	/**
+	 * 点击邀请投递简历 获取企业正在招聘的职位
+	 * 
+	 * @param req
+	 * @param resp
+	 * @return List<MdeJobInvitationRel>
+	 */
+	@RequestMapping(value = "clickInvitation")
+	@ResponseBody
+	public ResultEntity<List<MdeJobAdvertised>> clickInvitation(HttpServletRequest req, HttpServletResponse resp) {
+
+		List<MdeJobAdvertised> mdeJobAdvertised = mdeJobInvitationRelService.clickInvitation(req);
+		return new ResultEntity<>(InfoMsg.SUCCESS_REQUEST, mdeJobAdvertised);
+	}
+}

+ 144 - 0
src/main/java/com/wechat/controller/TicketController.java

@@ -0,0 +1,144 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package com.wechat.controller;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.google.common.collect.Maps;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.base.dao.Pagination;
+import com.wechat.global.base.dao.PagingResult;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeTicketCategory;
+import com.wechat.model.dbEntity.MdeTicketDetail;
+import com.wechat.model.requestDto.PageWithTicketDetail;
+import com.wechat.model.requestDto.TicketReq;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.CommonService;
+import com.wechat.service.MdeTicketCategoryService;
+import com.wechat.service.MdeTicketDetailService;
+
+
+/**
+ * 用户券Controller
+ * @author tangwc
+ * @version 2018-09-09
+ */
+@Controller
+@RequestMapping(value = "ticket")
+public class TicketController extends BaseController {
+
+	@Resource
+	private MdeTicketCategoryService ticketCategoryService;
+	@Resource
+	private MdeTicketDetailService mdeTicketDetailService;
+	@Resource
+	private CommonService commonService;
+	
+	/**
+	 * 获取券信息
+	 * @param request
+	 * @param page
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getTicketInfo", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<MdeTicketCategory> getTicketInfo(HttpServletRequest request,@RequestParam String id) throws Exception {
+		String lang = commonService.getLanguage(request);
+		MdeTicketCategory result = mdeTicketDetailService.getByCode(id,lang);
+		return new ResultEntity<MdeTicketCategory>(InfoMsg.SUCCESS_REQUEST,result);
+	}
+
+	/**
+	 * 获取用户券 分页
+	 * @param request
+	 * @param page
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getTicketDetails", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<PagingResult<MdeTicketDetail>> getTicketDetails(HttpServletRequest request,@RequestBody PageWithTicketDetail page) throws Exception {
+		String userCode = commonService.getUserCode(request);
+//		String identityFlag = commonService.getIdentityFlag(request);
+		String lang = commonService.getLanguage(request);
+		
+		Pagination pagination = new Pagination(page.getIndex(), page.getSize());
+		// 获取券信息
+		Map<Object, Object> params = Maps.newHashMap();
+		params.put("userCode", userCode);
+//		params.put("identityFlag", identityFlag);
+		params.put("usedFlag", page.getUsedFlag());
+		params.put("lang", lang);
+		pagination.setParams(params);
+		PagingResult<MdeTicketDetail> result = mdeTicketDetailService.getTicketDetails(pagination);
+		
+		return new ResultEntity<PagingResult<MdeTicketDetail>>(InfoMsg.SUCCESS_REQUEST,result);
+	}
+	
+	/**
+	 * 领取券 营销券和分享券
+	 * @param request
+	 * @param param tcCode tdCode contactInfo
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="acquireTicket", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<Integer> acquireSharedTicket(HttpServletRequest request,@RequestBody TicketReq param) throws Exception {
+		String lang = commonService.getLanguage(request);
+		int result = mdeTicketDetailService.acquireTicket(param,lang);
+		if(result<0)
+		{
+		    return new ResultEntity<Integer>(InfoMsg.ERROR_TICKET_OUT,result);
+		}else
+		{
+		    return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST,result);
+		}
+	}
+	
+//	/**
+//	 * 领取营销的券
+//	 * @param request
+//	 * @param page
+//	 * @return
+//	 * @throws Exception
+//	 */
+//	@RequestMapping(value="acquireMarketingTicket", method = RequestMethod.POST)
+//	@ResponseBody
+//	public ResultEntity<Integer> acquireMarketingTicket(HttpServletRequest request,@RequestBody MarketingTicketReq param) throws Exception {
+//		String lang = commonService.getLanguage(request);
+//		int result = mdeTicketDetailService.acquireMarketingTicket(param,lang);
+//		return new ResultEntity<Integer>(InfoMsg.SUCCESS_REQUEST,result);
+//	}
+	/**
+	 * 获取用户所有可使用券 日期倒叙排序
+	 * @param request
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping(value="getValidTicketByUser", method = RequestMethod.GET)
+	@ResponseBody
+	public ResultEntity<List<MdeTicketDetail>> getValidTicketByUser(HttpServletRequest request) throws Exception {
+		String userCode = commonService.getUserCode(request);
+		String identityFlag = commonService.getIdentityFlag(request);
+		String lang = commonService.getLanguage(request);
+		List<MdeTicketDetail> list = mdeTicketDetailService.getValidTicketByUser(userCode,identityFlag,lang);
+		return new ResultEntity<List<MdeTicketDetail>>(InfoMsg.SUCCESS_REQUEST,list);
+	}
+	
+
+}

+ 89 - 0
src/main/java/com/wechat/controller/VerificationCodeController.java

@@ -0,0 +1,89 @@
+package com.wechat.controller;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.base.BaseController;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.service.VerificationCodeService;
+
+@Controller
+@RequestMapping("verifyCode")
+public class VerificationCodeController extends BaseController {
+
+	@Resource
+	private VerificationCodeService vefificationCodeService;
+
+	/**
+	 * 短信验证码取得
+	 * 
+	 * @param map
+	 * @param request
+	 * @return
+	 * @throws IOException
+	 */
+	@RequestMapping(value = "getVerifyCode", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> getVerifyCode(@RequestBody Map<String, String> map, HttpServletRequest request)
+			throws IOException {
+
+		Cookie[] cookies = request.getCookies();
+		String type = map.get("type");
+		// type 0:个人 1:企业 2:忘记密码
+		if (StringsUtils.isEmpty(type)) {
+			return new ResultEntity<String>(InfoMsg.ERROR_NULL_PARAM);
+		}
+		String userName = StringsUtils.trim(map.get("userName"));
+		String imageCode = map.get("imageCode");
+		String entPhone = StringsUtils.trim(map.get("entPhone"));
+		String phoneCode = map.get("phoneCode");
+		
+		//去除验证码首尾空格
+		imageCode = StringsUtils.trim(imageCode);
+		
+		// 个人注册
+		if (type.equals("0")) {
+			return vefificationCodeService.getPersonVerifyCode(userName, imageCode, cookies, phoneCode);
+		} else if (type.equals("1")) {
+			// 企业注册
+			return vefificationCodeService.getEnterpriseVerifyCode(userName, imageCode, entPhone, cookies);
+		} else if (type.equals("2")) {
+			// 忘记密码
+			return vefificationCodeService.getForgetVerifyCode( userName, imageCode, cookies, request);
+		} else {
+			return new ResultEntity<>(InfoMsg.ERROR_TYPE_ERROR);
+		}
+	}
+
+	/**
+	 * 企业发送汇款短信
+	 * 
+	 * @param param
+	 * @return
+	 */
+	@RequestMapping(value = "sendRemittanceInformation", method = RequestMethod.POST)
+	@ResponseBody
+	public ResultEntity<String> sendRemit(@RequestBody Map<String, String> param) {
+		String phoneNo = param.get("phoneNo"); // 手机号
+		String orderId = param.get("orderId"); // 汇付识别码
+		if (StringsUtils.isEmpty(orderId) || StringsUtils.isEmpty(phoneNo)) {
+			return new ResultEntity<>(InfoMsg.ERROR_PARAMS_ERROR);
+		}
+		return vefificationCodeService.sendRemit( phoneNo, orderId);
+
+	}
+	
+	
+}

+ 266 - 0
src/main/java/com/wechat/controller/WxMiniprogController.java

@@ -0,0 +1,266 @@
+package com.wechat.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.wechat.common.CommonHelper;
+import com.wechat.common.Constants;
+import com.wechat.common.utils.StringsUtils;
+import com.wechat.global.message.InfoMsg;
+import com.wechat.model.dbEntity.MdeInterview;
+import com.wechat.model.dbEntity.MdeUser;
+import com.wechat.model.dto.WxBaseUserInfoDto;
+import com.wechat.model.requestDto.LoginByPasswordReq;
+import com.wechat.model.requestDto.LoginByPhoneReq;
+import com.wechat.model.requestDto.UserInfoWithOpenidDto;
+import com.wechat.model.responseDto.ResultEntity;
+import com.wechat.model.responseDto.WxMiniCode2SessionResp;
+import com.wechat.service.CommonService;
+import com.wechat.service.InterviewService;
+import com.wechat.service.LoginService;
+import com.wechat.service.MdeUserService;
+import com.wechat.service.WeiXinProgService;
+
+import net.sf.json.JSONObject;
+
+/**
+* @author jadyn
+* @version 创建时间:2020年7月17日 下午3:32:51
+* 微信小程序
+*/
+
+@Controller
+@RequestMapping(value = "wxMiniprog")
+public class WxMiniprogController {
+	
+	protected static final Log log = LogFactory.getLog(WxMiniprogController.class);
+	
+	@Autowired
+	private WeiXinProgService wxProgService;
+	
+	@Autowired
+	private CommonService commonService;
+	
+	@Autowired
+	private LoginService loginService;
+
+	@Autowired
+	private MdeUserService mdeUserService;
+	
+	@Autowired
+	private InterviewService intvService;
+	
+	@Autowired
+	private CommonHelper commonHelper;
+
+	
+	/**
+	 * 小程序登陆
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "wxMiniLogin", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<UserInfoWithOpenidDto> wxMiniLogin(@RequestParam String jscode, HttpServletRequest request, HttpServletResponse response) throws Exception {
+    	ResultEntity<UserInfoWithOpenidDto> restEnty = new ResultEntity<UserInfoWithOpenidDto>();
+    	UserInfoWithOpenidDto userDto = new UserInfoWithOpenidDto();
+    	//获取当前用户信息
+    	WxMiniCode2SessionResp wxResp = wxProgService.getJscodeToSession(jscode);
+    	if(StringsUtils.isEmpty(wxResp.getOpenid()))
+    	{
+    		//调用小程序登陆出错
+    		log.error("**************调用小程序登陆出错【jscode2session】【"+wxResp.getErrmsg()+"】*********************"); 
+    		restEnty.setMsg(InfoMsg.ERROR_AUZ_FAILED);
+    	} else if(StringsUtils.isEmpty(wxResp.getUnionid())){
+    		//unionid为空说明没有关注
+    		restEnty.setMsg(InfoMsg.ERROR_UN_SUBSCRIBE);
+    	} else {
+    		// 根据UnionId查询用户
+    		MdeUser mdeUser = mdeUserService.findByUnionId(wxResp.getUnionid());
+    		
+    		//session存储
+    		WxBaseUserInfoDto rdsBUInfo = new WxBaseUserInfoDto();
+    		rdsBUInfo.setOpenId(wxResp.getOpenid());
+    		rdsBUInfo.setSessionKey(wxResp.getSession_key());
+    		rdsBUInfo.setUnionId(wxResp.getUnionid());
+    		if(mdeUser != null)
+    		{
+        		rdsBUInfo.setUserCode(mdeUser.getUserCode());
+        		rdsBUInfo.setIdentityFlag(mdeUser.getIdentityFlag());
+    		}
+    		wxProgService.setSessionKey(rdsBUInfo);
+    		
+    		//调用微信登陆
+    		restEnty = loginService.loginByWechatBase(response,wxResp.getUnionid(), "", wxResp.getOpenid(),"1",mdeUser);
+    		if (InfoMsg.SUCCESS_REQUEST.getCode().equals(restEnty.getCode())) {
+				//正常处理的场合
+				userDto = restEnty.getResult();
+				userDto.setOpenIdMini(wxResp.getOpenid());// 手机端登录存储 (微信模板信息推送需要)
+				//记录登陆历史
+				commonService.addLoginHis(request,userDto.getUserCode());
+			} else if(InfoMsg.ERROR_BINDING_ERROR.getCode().equals(restEnty.getCode())){
+				//未绑定的情况下
+				userDto.setOpenIdMini(wxResp.getOpenid());// 手机端登录存储 (微信模板信息推送需要)
+				restEnty.setResult(userDto);
+			}
+    	}
+
+    	return restEnty;
+    }
+    
+    
+    /**
+	 * 通过微信小程序 手机号登陆
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "loginByPhone", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<UserInfoWithOpenidDto> loginByPhone(@RequestBody @Valid LoginByPhoneReq req, HttpServletRequest request, HttpServletResponse response) throws Exception {
+    	ResultEntity<UserInfoWithOpenidDto> restEnty = new ResultEntity<UserInfoWithOpenidDto>();
+    	UserInfoWithOpenidDto userDto = new UserInfoWithOpenidDto();
+    	
+    	//缓存中获取openid等信息
+    	WxBaseUserInfoDto sessionInfo = wxProgService.getSessionKey(req.getOpenId());
+    	if(sessionInfo != null)
+    	{
+    		//通过微信小程序解码获得手机号
+    		JSONObject phoneJson = wxProgService.getDecodeInfo(sessionInfo.getSessionKey(), req.getEncryptedData(), req.getIv());
+    		if(phoneJson != null) {
+    			// 根据手机号查询用户
+        		MdeUser mdeUser = mdeUserService.findByUserName(phoneJson.get("phoneNumber").toString());
+        		if(mdeUser == null) {
+        			restEnty.setMsg(InfoMsg.ERROR_PERSON_USER_NOTEXIST);
+        		} else {
+        			mdeUser.setOpenIdMini(sessionInfo.getOpenId());
+            		mdeUser.setUnionId(sessionInfo.getUnionId());
+            		//调用微信登陆
+            		restEnty = loginService.loginByWechatBase(response,sessionInfo.getUnionId(), "", sessionInfo.getOpenId(),"1",mdeUser);
+            		if (InfoMsg.SUCCESS_REQUEST.getCode().equals(restEnty.getCode())) {
+        				//正常处理的场合
+        				userDto = restEnty.getResult();
+        				//记录登陆历史
+        				commonService.addLoginHis(request,userDto.getUserCode());
+        			}
+            		//session存储
+            		sessionInfo.setUserCode(mdeUser.getUserCode());
+            		sessionInfo.setIdentityFlag(mdeUser.getIdentityFlag());
+            		wxProgService.setSessionKey(sessionInfo);
+        		}
+    		} else {
+    			restEnty.setMsg(InfoMsg.ERROR_SYSTEM_ERROR);
+    		}
+    	} else {
+       		//调用小程序登陆出错
+    		log.error("**************小程序未登录*********************"); 
+    		restEnty.setMsg(InfoMsg.ERROR_AUZ_FAILED);
+    	}
+
+    	return restEnty;
+    }
+    
+
+    /**
+	 * 通过账号密码登录(小程序)
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "loginByPassword", method = RequestMethod.POST)
+    @ResponseBody
+    public ResultEntity<UserInfoWithOpenidDto> loginByPassword(@RequestBody @Valid LoginByPasswordReq loginReq, HttpServletRequest request, HttpServletResponse response) throws Exception {
+    	ResultEntity<UserInfoWithOpenidDto> restEnty = new ResultEntity<UserInfoWithOpenidDto>();
+    	UserInfoWithOpenidDto userDto = new UserInfoWithOpenidDto();
+
+		// 验证身份
+		if (loginReq != null && StringsUtils.isNotEmpty(commonHelper.getIRealIPAddr(request))) {
+	    	//缓存中获取openid等信息
+	    	WxBaseUserInfoDto sessionInfo = wxProgService.getSessionKey(loginReq.getOpenId());
+	    	if(sessionInfo != null)
+	    	{
+	    		//登陆信息验证
+				ResultEntity<MdeUser> checkRest = loginService.checkPassword(loginReq);
+				MdeUser mdeUser = checkRest.getResult();
+				if(Constants.STR_OK.equals(checkRest.getCode()))
+				{
+					mdeUser.setOpenIdMini(sessionInfo.getOpenId());
+	        		mdeUser.setUnionId(sessionInfo.getUnionId());
+	        		//调用微信登陆
+	        		restEnty = loginService.loginByWechatBase(response,sessionInfo.getUnionId(), "", sessionInfo.getOpenId(),"1",mdeUser);
+	        		if (InfoMsg.SUCCESS_REQUEST.getCode().equals(restEnty.getCode())) {
+	    				//正常处理的场合
+	    				userDto = restEnty.getResult();
+	    				//记录登陆历史
+	    				commonService.addLoginHis(request,userDto.getUserCode());
+	    				
+	    				//session存储
+	            		sessionInfo.setUserCode(mdeUser.getUserCode());
+	            		sessionInfo.setIdentityFlag(mdeUser.getIdentityFlag());
+	            		wxProgService.setSessionKey(sessionInfo);
+	    			}
+				} else {
+					restEnty.setCode(checkRest.getCode());
+					restEnty.setMsg(checkRest.getMsg());
+				}
+	    	} else {
+	    		//调用小程序登陆出错
+	    		log.error("**************小程序未登录*********************"); 
+	    		restEnty.setMsg(InfoMsg.ERROR_AUZ_FAILED);
+	    	}
+		} else {
+			restEnty.setMsg(InfoMsg.ERROR_LOGIN_MISS);
+		}
+		
+		return restEnty;
+    }
+
+
+    /**
+	 * 验证视频用户权限
+     * 
+     * @param 
+     * @return
+     */
+    @RequestMapping(value = "checkVUserRight", method = RequestMethod.GET)
+    @ResponseBody
+    public ResultEntity<String> checkVUserRight(@RequestParam String roomId, HttpServletRequest request) {
+    	ResultEntity<String> restEnty = new ResultEntity<String>(InfoMsg.ERROR_JOIN_VIDEO_ROOM);
+    	String userSin = "";
+    	//获取当前登录用户
+    	String userCode = commonService.getUserCode(request);
+    	String identityFlg = commonService.getIdentityFlag(request);
+    	
+    	if(!StringsUtils.anyIsEmpty(roomId,userCode,identityFlg))
+    	{
+    		//检查用户是否和房间号相匹配
+    		MdeInterview intv = intvService.getIntvInfoByKey(roomId,userCode,identityFlg);
+    		if(intv != null && intv.getIntvId() != null) {
+    			restEnty.setMsg(InfoMsg.SUCCESS_REQUEST);
+    			//获取用户签名
+    			userSin = wxProgService.getVideoUserSig(userCode);
+    			if(StringsUtils.isEmpty(userSin))
+    			{
+    				restEnty.setMsg(InfoMsg.ERROR_SYSTEM_ERROR);
+    				log.error("**********************视频用户签名出错:roomid【"+roomId+"】usercode【"+userCode+"】*******************************");
+    			}
+    		}
+    	} 
+		restEnty.setResult(userSin);
+		return restEnty;
+    }
+    
+}

+ 37 - 0
src/main/java/com/wechat/dao/AccessTokenRedisDao.java

@@ -0,0 +1,37 @@
+package com.wechat.dao;
+
+import org.springframework.stereotype.Repository;
+
+import com.wechat.global.base.dao.RedisGeneratorDao;
+import com.wechat.model.dto.AccessTokenDto;
+
+/**
+ * This is test for Git Stash
+ * @author Administrator
+ *
+ */
+@Repository
+public class AccessTokenRedisDao extends RedisGeneratorDao<String, AccessTokenDto>  {
+
+    private String tableKey = "accessTokenRedis";
+
+    public AccessTokenDto selectAccessToken(String infoKey) {
+        return selectOne(tableKey, infoKey);
+    }
+
+    public void updateAccessToken(String infoKey, AccessTokenDto infoValue) {
+        update(tableKey, infoKey, infoValue);
+
+    }
+
+    public void insertAccessToken(String infoKey, AccessTokenDto infoValue) {
+        insert(tableKey, infoKey, infoValue);
+
+    }
+
+    public void deleteAccessToken(String infoKey) {
+        delete(tableKey, infoKey);
+
+    }
+
+}

+ 126 - 0
src/main/java/com/wechat/dao/AdCtrRedisDao.java

@@ -0,0 +1,126 @@
+package com.wechat.dao;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Repository;
+
+import com.wechat.common.Constants;
+import com.wechat.common.utils.DateUtils;
+import com.wechat.common.utils.StringsUtils;
+
+
+
+/**
+ * @author jadyn.wu
+ * @date: 2020-04-21 18:08
+ */
+@Repository
+public class AdCtrRedisDao {
+	// log 处理
+	protected static final Log log = LogFactory.getLog(AdCtrRedisDao.class);
+	
+	//PV/UV记录失效时间(一周 7天 )
+	@Value("#{configProperties['pvuv.expired.days']}")
+	private Integer expiredDays;
+	
+	@Autowired
+	protected RedisTemplate<String, Integer> redisTemplate;
+
+    
+    //广告展现量
+    public void insertAdShow(String id, int num) {
+    	//按日期统计
+        insertAdCtr(Constants.REDIS_AD_SHOW,id,num);
+    }
+    
+    //广告点击量
+    public void insertAdClick(String id, int num) {
+    	//按日期统计
+        insertAdCtr(Constants.REDIS_AD_CLICK,id,num);
+    }
+    
+    
+    private void insertAdCtr(String baseKey, String id, int num) {
+    	if(num>0) {
+    		//按日期统计
+            String adKey = baseKey + DateUtils.getLocalDateNowStr(DateUtils.PATTEN_YMD)+Constants.UNDER_LINE;
+        	if(!StringsUtils.isEmpty(id))
+        	{
+        		String key = adKey+id;
+            	if(hasKey(key))
+            	{
+            		insert(key, select(key)+num);
+            		//log.info("**********广告数量************"+key+"::"+select(key));
+            	} else {
+            		insertDay(key, num, expiredDays);
+            	}
+        	}
+    	}
+    }
+    
+    
+    //根据广告id获取展现量
+    public int getAdShowById(Integer id) {
+    	int showNum = 0;
+    	//按日期统计
+        String showKey = DateUtils.getLocalDateNowStr(DateUtils.PATTEN_YMD)+Constants.UNDER_LINE;
+    	if(null != id &&  id != 0)
+    	{
+    		String key = Constants.REDIS_AD_SHOW + showKey+id.toString();
+        	if(hasKey(key))
+        	{
+        		Integer pv = select(key);
+        		showNum = pv != null ? pv.intValue()+1 : 1;
+        	} 
+    	}
+    	return showNum;
+    }
+
+	public Integer select(String infoKey) {
+		return redisTemplate.opsForValue().get(infoKey);
+	}
+
+	private void insert(String infoKey, Integer infoValue) {
+		redisTemplate.opsForValue().set(infoKey, infoValue);
+	}
+
+	/**
+	 * 保存并设置过期时间
+	 * @param infoKey
+	 * @param infoValue
+	 * @param expiry    过期时长
+	 * @param unit      单位
+	 */
+	private void insertAndExptime(String infoKey, Integer infoValue, int expiryNum, TimeUnit unit) {
+		redisTemplate.opsForValue().set(infoKey, infoValue);
+		// 设置失效时间
+		redisTemplate.expire(infoKey, expiryNum, unit);
+	}
+	
+	/**
+	 * 
+	 * @param infoKey
+	 * @param infoValue
+	 * @param expiry 过期时长 单位:天
+	 */
+	private void insertDay(String infoKey, Integer infoValue, int expired) {
+		// 设置失效时间
+		insertAndExptime(infoKey, infoValue, expired, TimeUnit.DAYS);
+	}
+	
+
+
+	public void delete(String infoKey) {
+		redisTemplate.delete(infoKey);
+	}
+	
+   public Boolean hasKey(String infoKey) {
+       return redisTemplate.hasKey(infoKey);
+    }
+
+}

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác