commit 21e865185e6c84710f3afc31aaa6dba35d9841dd Author: xuao Date: Thu Jul 31 09:15:42 2025 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/lib/FYOpenApi.jar b/lib/FYOpenApi.jar new file mode 100644 index 0000000..3252408 Binary files /dev/null and b/lib/FYOpenApi.jar differ diff --git a/lib/QRCode.jar b/lib/QRCode.jar new file mode 100644 index 0000000..2b84560 Binary files /dev/null and b/lib/QRCode.jar differ diff --git a/lib/YeePay_HTMLcommon_V3.0.jar b/lib/YeePay_HTMLcommon_V3.0.jar new file mode 100644 index 0000000..00dfd17 Binary files /dev/null and b/lib/YeePay_HTMLcommon_V3.0.jar differ diff --git a/lib/activation.jar b/lib/activation.jar new file mode 100644 index 0000000..b7a4b47 Binary files /dev/null and b/lib/activation.jar differ diff --git a/lib/alisoft-xplatform-asf-cache-2.5.1.jar b/lib/alisoft-xplatform-asf-cache-2.5.1.jar new file mode 100644 index 0000000..622a853 Binary files /dev/null and b/lib/alisoft-xplatform-asf-cache-2.5.1.jar differ diff --git a/lib/aliyun-java-sdk-core-3.3.1.jar b/lib/aliyun-java-sdk-core-3.3.1.jar new file mode 100644 index 0000000..3e33994 Binary files /dev/null and b/lib/aliyun-java-sdk-core-3.3.1.jar differ diff --git a/lib/aliyun-java-sdk-dysmsapi-1.0.0.jar b/lib/aliyun-java-sdk-dysmsapi-1.0.0.jar new file mode 100644 index 0000000..3e68bdf Binary files /dev/null and b/lib/aliyun-java-sdk-dysmsapi-1.0.0.jar differ diff --git a/lib/antlr-3.0.jar b/lib/antlr-3.0.jar new file mode 100644 index 0000000..a827636 Binary files /dev/null and b/lib/antlr-3.0.jar differ diff --git a/lib/aopalliance.jar b/lib/aopalliance.jar new file mode 100644 index 0000000..578b1a0 Binary files /dev/null and b/lib/aopalliance.jar differ diff --git a/lib/asm-3.3.jar b/lib/asm-3.3.jar new file mode 100644 index 0000000..d44dfd8 Binary files /dev/null and b/lib/asm-3.3.jar differ diff --git a/lib/asm-commons-3.3.jar b/lib/asm-commons-3.3.jar new file mode 100644 index 0000000..e509842 Binary files /dev/null and b/lib/asm-commons-3.3.jar differ diff --git a/lib/asm-tree-3.3.jar b/lib/asm-tree-3.3.jar new file mode 100644 index 0000000..374bc2e Binary files /dev/null and b/lib/asm-tree-3.3.jar differ diff --git a/lib/aspectjweaver.jar b/lib/aspectjweaver.jar new file mode 100644 index 0000000..0777d01 Binary files /dev/null and b/lib/aspectjweaver.jar differ diff --git a/lib/c3p0-0.9.1.jar b/lib/c3p0-0.9.1.jar new file mode 100644 index 0000000..693667a Binary files /dev/null and b/lib/c3p0-0.9.1.jar differ diff --git a/lib/cglib-nodep-2.1_3.jar b/lib/cglib-nodep-2.1_3.jar new file mode 100644 index 0000000..e9b17eb Binary files /dev/null and b/lib/cglib-nodep-2.1_3.jar differ diff --git a/lib/chardet.jar b/lib/chardet.jar new file mode 100644 index 0000000..69f6503 Binary files /dev/null and b/lib/chardet.jar differ diff --git a/lib/com.ibm.icu_4.0.1.v20090415.jar b/lib/com.ibm.icu_4.0.1.v20090415.jar new file mode 100644 index 0000000..3730e59 Binary files /dev/null and b/lib/com.ibm.icu_4.0.1.v20090415.jar differ diff --git a/lib/com.springsource.antlr-2.7.6.jar b/lib/com.springsource.antlr-2.7.6.jar new file mode 100644 index 0000000..b7f86ad Binary files /dev/null and b/lib/com.springsource.antlr-2.7.6.jar differ diff --git a/lib/com.springsource.javax.mail-1.4.0.jar b/lib/com.springsource.javax.mail-1.4.0.jar new file mode 100644 index 0000000..188fae2 Binary files /dev/null and b/lib/com.springsource.javax.mail-1.4.0.jar differ diff --git a/lib/com.springsource.javax.transaction-1.1.0.jar b/lib/com.springsource.javax.transaction-1.1.0.jar new file mode 100644 index 0000000..56a0893 Binary files /dev/null and b/lib/com.springsource.javax.transaction-1.1.0.jar differ diff --git a/lib/com.springsource.net.sf.cglib-2.2.0.jar b/lib/com.springsource.net.sf.cglib-2.2.0.jar new file mode 100644 index 0000000..a4f97dc Binary files /dev/null and b/lib/com.springsource.net.sf.cglib-2.2.0.jar differ diff --git a/lib/com.springsource.org.apache.commons.beanutils-1.8.0.jar b/lib/com.springsource.org.apache.commons.beanutils-1.8.0.jar new file mode 100644 index 0000000..161b7ff Binary files /dev/null and b/lib/com.springsource.org.apache.commons.beanutils-1.8.0.jar differ diff --git a/lib/com.springsource.org.apache.commons.collections-3.2.1.jar b/lib/com.springsource.org.apache.commons.collections-3.2.1.jar new file mode 100644 index 0000000..aee7281 Binary files /dev/null and b/lib/com.springsource.org.apache.commons.collections-3.2.1.jar differ diff --git a/lib/com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar b/lib/com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar new file mode 100644 index 0000000..a8ef066 Binary files /dev/null and b/lib/com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar differ diff --git a/lib/com.springsource.org.apache.commons.digester-1.8.1.jar b/lib/com.springsource.org.apache.commons.digester-1.8.1.jar new file mode 100644 index 0000000..e53716e Binary files /dev/null and b/lib/com.springsource.org.apache.commons.digester-1.8.1.jar differ diff --git a/lib/com.springsource.org.apache.commons.discovery-0.4.0.jar b/lib/com.springsource.org.apache.commons.discovery-0.4.0.jar new file mode 100644 index 0000000..01576c6 Binary files /dev/null and b/lib/com.springsource.org.apache.commons.discovery-0.4.0.jar differ diff --git a/lib/com.springsource.org.apache.commons.fileupload-1.2.0.jar b/lib/com.springsource.org.apache.commons.fileupload-1.2.0.jar new file mode 100644 index 0000000..c52ae05 Binary files /dev/null and b/lib/com.springsource.org.apache.commons.fileupload-1.2.0.jar differ diff --git a/lib/com.springsource.org.apache.commons.httpclient-3.1.0.jar b/lib/com.springsource.org.apache.commons.httpclient-3.1.0.jar new file mode 100644 index 0000000..ae8b9e9 Binary files /dev/null and b/lib/com.springsource.org.apache.commons.httpclient-3.1.0.jar differ diff --git a/lib/com.springsource.org.apache.commons.io-1.4.0.jar b/lib/com.springsource.org.apache.commons.io-1.4.0.jar new file mode 100644 index 0000000..1482fdc Binary files /dev/null and b/lib/com.springsource.org.apache.commons.io-1.4.0.jar differ diff --git a/lib/com.springsource.org.apache.commons.logging-1.1.1.jar b/lib/com.springsource.org.apache.commons.logging-1.1.1.jar new file mode 100644 index 0000000..f50c78c Binary files /dev/null and b/lib/com.springsource.org.apache.commons.logging-1.1.1.jar differ diff --git a/lib/com.springsource.org.apache.commons.net-1.4.1.jar b/lib/com.springsource.org.apache.commons.net-1.4.1.jar new file mode 100644 index 0000000..a358561 Binary files /dev/null and b/lib/com.springsource.org.apache.commons.net-1.4.1.jar differ diff --git a/lib/com.springsource.org.apache.commons.pool-1.5.3.jar b/lib/com.springsource.org.apache.commons.pool-1.5.3.jar new file mode 100644 index 0000000..743c39b Binary files /dev/null and b/lib/com.springsource.org.apache.commons.pool-1.5.3.jar differ diff --git a/lib/com.springsource.org.apache.log4j-1.2.15.jar b/lib/com.springsource.org.apache.log4j-1.2.15.jar new file mode 100644 index 0000000..8043a9b Binary files /dev/null and b/lib/com.springsource.org.apache.log4j-1.2.15.jar differ diff --git a/lib/com.springsource.org.dom4j-1.6.1.jar b/lib/com.springsource.org.dom4j-1.6.1.jar new file mode 100644 index 0000000..16df47a Binary files /dev/null and b/lib/com.springsource.org.dom4j-1.6.1.jar differ diff --git a/lib/com.springsource.org.easymock.classextension-2.3.0.jar b/lib/com.springsource.org.easymock.classextension-2.3.0.jar new file mode 100644 index 0000000..d1ac771 Binary files /dev/null and b/lib/com.springsource.org.easymock.classextension-2.3.0.jar differ diff --git a/lib/com.springsource.org.hibernate-3.3.1.GA.jar b/lib/com.springsource.org.hibernate-3.3.1.GA.jar new file mode 100644 index 0000000..1e751f3 Binary files /dev/null and b/lib/com.springsource.org.hibernate-3.3.1.GA.jar differ diff --git a/lib/com.springsource.org.quartz-1.6.2.jar b/lib/com.springsource.org.quartz-1.6.2.jar new file mode 100644 index 0000000..30dcee7 Binary files /dev/null and b/lib/com.springsource.org.quartz-1.6.2.jar differ diff --git a/lib/com.springsource.slf4j.api-1.5.6.jar b/lib/com.springsource.slf4j.api-1.5.6.jar new file mode 100644 index 0000000..44f166d Binary files /dev/null and b/lib/com.springsource.slf4j.api-1.5.6.jar differ diff --git a/lib/com.springsource.slf4j.jcl-1.5.6.jar b/lib/com.springsource.slf4j.jcl-1.5.6.jar new file mode 100644 index 0000000..cf87be9 Binary files /dev/null and b/lib/com.springsource.slf4j.jcl-1.5.6.jar differ diff --git a/lib/commons-beanutils-1.8.0.jar b/lib/commons-beanutils-1.8.0.jar new file mode 100644 index 0000000..caf7ae3 Binary files /dev/null and b/lib/commons-beanutils-1.8.0.jar differ diff --git a/lib/commons-chain-1.2.jar b/lib/commons-chain-1.2.jar new file mode 100644 index 0000000..20fa4c5 Binary files /dev/null and b/lib/commons-chain-1.2.jar differ diff --git a/lib/commons-codec-1.9.jar b/lib/commons-codec-1.9.jar new file mode 100644 index 0000000..ef35f1c Binary files /dev/null and b/lib/commons-codec-1.9.jar differ diff --git a/lib/commons-collections-3.1.jar b/lib/commons-collections-3.1.jar new file mode 100644 index 0000000..41e230f Binary files /dev/null and b/lib/commons-collections-3.1.jar differ diff --git a/lib/commons-digester-2.0.jar b/lib/commons-digester-2.0.jar new file mode 100644 index 0000000..9c8bd13 Binary files /dev/null and b/lib/commons-digester-2.0.jar differ diff --git a/lib/commons-fileupload-1.3.1.jar b/lib/commons-fileupload-1.3.1.jar new file mode 100644 index 0000000..af0cda2 Binary files /dev/null and b/lib/commons-fileupload-1.3.1.jar differ diff --git a/lib/commons-httpclient-3.0.1.jar b/lib/commons-httpclient-3.0.1.jar new file mode 100644 index 0000000..cfc777c Binary files /dev/null and b/lib/commons-httpclient-3.0.1.jar differ diff --git a/lib/commons-io-2.4.jar b/lib/commons-io-2.4.jar new file mode 100644 index 0000000..90035a4 Binary files /dev/null and b/lib/commons-io-2.4.jar differ diff --git a/lib/commons-lang-2.4.jar b/lib/commons-lang-2.4.jar new file mode 100644 index 0000000..532939e Binary files /dev/null and b/lib/commons-lang-2.4.jar differ diff --git a/lib/commons-lang3-3.2.jar b/lib/commons-lang3-3.2.jar new file mode 100644 index 0000000..a30d272 Binary files /dev/null and b/lib/commons-lang3-3.2.jar differ diff --git a/lib/commons-logging-1.1.3.jar b/lib/commons-logging-1.1.3.jar new file mode 100644 index 0000000..ab51254 Binary files /dev/null and b/lib/commons-logging-1.1.3.jar differ diff --git a/lib/commons-logging-api-1.1.jar b/lib/commons-logging-api-1.1.jar new file mode 100644 index 0000000..d1abcbb Binary files /dev/null and b/lib/commons-logging-api-1.1.jar differ diff --git a/lib/commons-validator-1.3.1.jar b/lib/commons-validator-1.3.1.jar new file mode 100644 index 0000000..55b12b1 Binary files /dev/null and b/lib/commons-validator-1.3.1.jar differ diff --git a/lib/dom4j-1.6.1.jar b/lib/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/lib/dom4j-1.6.1.jar differ diff --git a/lib/emaysdkclient.jar b/lib/emaysdkclient.jar new file mode 100644 index 0000000..928fc96 Binary files /dev/null and b/lib/emaysdkclient.jar differ diff --git a/lib/ezmorph-1.0.6.jar b/lib/ezmorph-1.0.6.jar new file mode 100644 index 0000000..30fad12 Binary files /dev/null and b/lib/ezmorph-1.0.6.jar differ diff --git a/lib/fastjson-1.2.6.jar b/lib/fastjson-1.2.6.jar new file mode 100644 index 0000000..2e90418 Binary files /dev/null and b/lib/fastjson-1.2.6.jar differ diff --git a/lib/freemarker-2.3.22.jar b/lib/freemarker-2.3.22.jar new file mode 100644 index 0000000..a67a1c1 Binary files /dev/null and b/lib/freemarker-2.3.22.jar differ diff --git a/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar b/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar new file mode 100644 index 0000000..4c9ac4e Binary files /dev/null and b/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar differ diff --git a/lib/hibernate3.jar b/lib/hibernate3.jar new file mode 100644 index 0000000..036bf38 Binary files /dev/null and b/lib/hibernate3.jar differ diff --git a/lib/httpclient-4.5.2.jar b/lib/httpclient-4.5.2.jar new file mode 100644 index 0000000..701609f Binary files /dev/null and b/lib/httpclient-4.5.2.jar differ diff --git a/lib/httpcore-4.4.4.jar b/lib/httpcore-4.4.4.jar new file mode 100644 index 0000000..ac4a877 Binary files /dev/null and b/lib/httpcore-4.4.4.jar differ diff --git a/lib/jackson-core-asl-1.9.2.jar b/lib/jackson-core-asl-1.9.2.jar new file mode 100644 index 0000000..c506567 Binary files /dev/null and b/lib/jackson-core-asl-1.9.2.jar differ diff --git a/lib/jackson-mapper-asl-1.9.2.jar b/lib/jackson-mapper-asl-1.9.2.jar new file mode 100644 index 0000000..6407dc0 Binary files /dev/null and b/lib/jackson-mapper-asl-1.9.2.jar differ diff --git a/lib/javassist-3.11.0.GA.jar b/lib/javassist-3.11.0.GA.jar new file mode 100644 index 0000000..b3bfeeb Binary files /dev/null and b/lib/javassist-3.11.0.GA.jar differ diff --git a/lib/javassist-3.12.0.GA.jar b/lib/javassist-3.12.0.GA.jar new file mode 100644 index 0000000..8f692f4 Binary files /dev/null and b/lib/javassist-3.12.0.GA.jar differ diff --git a/lib/jaxen-1.1-beta-6.jar b/lib/jaxen-1.1-beta-6.jar new file mode 100644 index 0000000..6cef35d Binary files /dev/null and b/lib/jaxen-1.1-beta-6.jar differ diff --git a/lib/jdom.jar b/lib/jdom.jar new file mode 100644 index 0000000..97c85f5 Binary files /dev/null and b/lib/jdom.jar differ diff --git a/lib/jsf-api.jar b/lib/jsf-api.jar new file mode 100644 index 0000000..60ae0f6 Binary files /dev/null and b/lib/jsf-api.jar differ diff --git a/lib/jsf-impl.jar b/lib/jsf-impl.jar new file mode 100644 index 0000000..6550b01 Binary files /dev/null and b/lib/jsf-impl.jar differ diff --git a/lib/json-lib-2.4-jdk15.jar b/lib/json-lib-2.4-jdk15.jar new file mode 100644 index 0000000..68d4f3b Binary files /dev/null and b/lib/json-lib-2.4-jdk15.jar differ diff --git a/lib/json-simple-1.1.1.jar b/lib/json-simple-1.1.1.jar new file mode 100644 index 0000000..66347a6 Binary files /dev/null and b/lib/json-simple-1.1.1.jar differ diff --git a/lib/json.jar b/lib/json.jar new file mode 100644 index 0000000..ed0bc93 Binary files /dev/null and b/lib/json.jar differ diff --git a/lib/jsoup-1.5.2.jar b/lib/jsoup-1.5.2.jar new file mode 100644 index 0000000..66ae4df Binary files /dev/null and b/lib/jsoup-1.5.2.jar differ diff --git a/lib/jstl-1.2.jar b/lib/jstl-1.2.jar new file mode 100644 index 0000000..0fd275e Binary files /dev/null and b/lib/jstl-1.2.jar differ diff --git a/lib/jta-1.1.jar b/lib/jta-1.1.jar new file mode 100644 index 0000000..6d225b7 Binary files /dev/null and b/lib/jta-1.1.jar differ diff --git a/lib/junit-4.8.2.jar b/lib/junit-4.8.2.jar new file mode 100644 index 0000000..5b4bb84 Binary files /dev/null and b/lib/junit-4.8.2.jar differ diff --git a/lib/mail.jar b/lib/mail.jar new file mode 100644 index 0000000..aa357d4 Binary files /dev/null and b/lib/mail.jar differ diff --git a/lib/mysql-connector-java-5.0.8-bin.jar b/lib/mysql-connector-java-5.0.8-bin.jar new file mode 100644 index 0000000..0170c3e Binary files /dev/null and b/lib/mysql-connector-java-5.0.8-bin.jar differ diff --git a/lib/ognl-3.0.19.jar b/lib/ognl-3.0.19.jar new file mode 100644 index 0000000..8f31612 Binary files /dev/null and b/lib/ognl-3.0.19.jar differ diff --git a/lib/org.springframework.aop-3.0.5.RELEASE.jar b/lib/org.springframework.aop-3.0.5.RELEASE.jar new file mode 100644 index 0000000..db6f529 Binary files /dev/null and b/lib/org.springframework.aop-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.asm-3.0.5.RELEASE.jar b/lib/org.springframework.asm-3.0.5.RELEASE.jar new file mode 100644 index 0000000..7cd3a62 Binary files /dev/null and b/lib/org.springframework.asm-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.aspects-3.0.5.RELEASE.jar b/lib/org.springframework.aspects-3.0.5.RELEASE.jar new file mode 100644 index 0000000..11fc11b Binary files /dev/null and b/lib/org.springframework.aspects-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.beans-3.0.5.RELEASE.jar b/lib/org.springframework.beans-3.0.5.RELEASE.jar new file mode 100644 index 0000000..f2e2e92 Binary files /dev/null and b/lib/org.springframework.beans-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.context-3.0.5.RELEASE.jar b/lib/org.springframework.context-3.0.5.RELEASE.jar new file mode 100644 index 0000000..bd1367d Binary files /dev/null and b/lib/org.springframework.context-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.context.support-3.0.5.RELEASE.jar b/lib/org.springframework.context.support-3.0.5.RELEASE.jar new file mode 100644 index 0000000..e46f9eb Binary files /dev/null and b/lib/org.springframework.context.support-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.core-3.0.5.RELEASE.jar b/lib/org.springframework.core-3.0.5.RELEASE.jar new file mode 100644 index 0000000..ea9500d Binary files /dev/null and b/lib/org.springframework.core-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.expression-3.0.5.RELEASE.jar b/lib/org.springframework.expression-3.0.5.RELEASE.jar new file mode 100644 index 0000000..6ef99d8 Binary files /dev/null and b/lib/org.springframework.expression-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.instrument-3.0.5.RELEASE.jar b/lib/org.springframework.instrument-3.0.5.RELEASE.jar new file mode 100644 index 0000000..e149290 Binary files /dev/null and b/lib/org.springframework.instrument-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar b/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar new file mode 100644 index 0000000..dcd1e4d Binary files /dev/null and b/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.jdbc-3.0.5.RELEASE.jar b/lib/org.springframework.jdbc-3.0.5.RELEASE.jar new file mode 100644 index 0000000..f7a3b83 Binary files /dev/null and b/lib/org.springframework.jdbc-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.jms-3.0.5.RELEASE.jar b/lib/org.springframework.jms-3.0.5.RELEASE.jar new file mode 100644 index 0000000..9cea2ae Binary files /dev/null and b/lib/org.springframework.jms-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.orm-3.0.5.RELEASE.jar b/lib/org.springframework.orm-3.0.5.RELEASE.jar new file mode 100644 index 0000000..d0550cc Binary files /dev/null and b/lib/org.springframework.orm-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.oxm-3.0.5.RELEASE.jar b/lib/org.springframework.oxm-3.0.5.RELEASE.jar new file mode 100644 index 0000000..1688cf7 Binary files /dev/null and b/lib/org.springframework.oxm-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.test-3.0.5.RELEASE.jar b/lib/org.springframework.test-3.0.5.RELEASE.jar new file mode 100644 index 0000000..237995c Binary files /dev/null and b/lib/org.springframework.test-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.transaction-3.0.5.RELEASE.jar b/lib/org.springframework.transaction-3.0.5.RELEASE.jar new file mode 100644 index 0000000..2f52122 Binary files /dev/null and b/lib/org.springframework.transaction-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.web-3.0.5.RELEASE.jar b/lib/org.springframework.web-3.0.5.RELEASE.jar new file mode 100644 index 0000000..5a2381a Binary files /dev/null and b/lib/org.springframework.web-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar b/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar new file mode 100644 index 0000000..6ec9d68 Binary files /dev/null and b/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar b/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar new file mode 100644 index 0000000..6d13bd4 Binary files /dev/null and b/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar differ diff --git a/lib/org.springframework.web.struts-3.0.5.RELEASE.jar b/lib/org.springframework.web.struts-3.0.5.RELEASE.jar new file mode 100644 index 0000000..e351ae7 Binary files /dev/null and b/lib/org.springframework.web.struts-3.0.5.RELEASE.jar differ diff --git a/lib/servlet-api.jar b/lib/servlet-api.jar new file mode 100644 index 0000000..c2683a1 Binary files /dev/null and b/lib/servlet-api.jar differ diff --git a/lib/sigar.jar b/lib/sigar.jar new file mode 100644 index 0000000..58c733c Binary files /dev/null and b/lib/sigar.jar differ diff --git a/lib/sitemesh-2.4.2.jar b/lib/sitemesh-2.4.2.jar new file mode 100644 index 0000000..e881e47 Binary files /dev/null and b/lib/sitemesh-2.4.2.jar differ diff --git a/lib/slf4j-api-1.6.1.jar b/lib/slf4j-api-1.6.1.jar new file mode 100644 index 0000000..f1f4fdd Binary files /dev/null and b/lib/slf4j-api-1.6.1.jar differ diff --git a/lib/struts2-config-browser-plugin-2.3.24.1.jar b/lib/struts2-config-browser-plugin-2.3.24.1.jar new file mode 100644 index 0000000..2cd2beb Binary files /dev/null and b/lib/struts2-config-browser-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-core-2.3.32.jar b/lib/struts2-core-2.3.32.jar new file mode 100644 index 0000000..f340b98 Binary files /dev/null and b/lib/struts2-core-2.3.32.jar differ diff --git a/lib/struts2-dojo-plugin-2.3.24.1.jar b/lib/struts2-dojo-plugin-2.3.24.1.jar new file mode 100644 index 0000000..3d96532 Binary files /dev/null and b/lib/struts2-dojo-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-dwr-plugin-2.3.24.1.jar b/lib/struts2-dwr-plugin-2.3.24.1.jar new file mode 100644 index 0000000..48a3965 Binary files /dev/null and b/lib/struts2-dwr-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-jasperreports-plugin-2.3.24.1.jar b/lib/struts2-jasperreports-plugin-2.3.24.1.jar new file mode 100644 index 0000000..704df26 Binary files /dev/null and b/lib/struts2-jasperreports-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-javatemplates-plugin-2.3.24.1.jar b/lib/struts2-javatemplates-plugin-2.3.24.1.jar new file mode 100644 index 0000000..3adcc1d Binary files /dev/null and b/lib/struts2-javatemplates-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-jfreechart-plugin-2.3.24.1.jar b/lib/struts2-jfreechart-plugin-2.3.24.1.jar new file mode 100644 index 0000000..6d0a8df Binary files /dev/null and b/lib/struts2-jfreechart-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-junit-plugin-2.3.24.1.jar b/lib/struts2-junit-plugin-2.3.24.1.jar new file mode 100644 index 0000000..98fafb8 Binary files /dev/null and b/lib/struts2-junit-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-pell-multipart-plugin-2.3.24.1.jar b/lib/struts2-pell-multipart-plugin-2.3.24.1.jar new file mode 100644 index 0000000..e9b3a8b Binary files /dev/null and b/lib/struts2-pell-multipart-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-plexus-plugin-2.3.24.1.jar b/lib/struts2-plexus-plugin-2.3.24.1.jar new file mode 100644 index 0000000..82c9eb6 Binary files /dev/null and b/lib/struts2-plexus-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-sitegraph-plugin-2.3.24.1.jar b/lib/struts2-sitegraph-plugin-2.3.24.1.jar new file mode 100644 index 0000000..ccc9c10 Binary files /dev/null and b/lib/struts2-sitegraph-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-sitemesh-plugin-2.3.24.1.jar b/lib/struts2-sitemesh-plugin-2.3.24.1.jar new file mode 100644 index 0000000..d4a0ead Binary files /dev/null and b/lib/struts2-sitemesh-plugin-2.3.24.1.jar differ diff --git a/lib/struts2-spring-plugin-2.3.32.jar b/lib/struts2-spring-plugin-2.3.32.jar new file mode 100644 index 0000000..ea68701 Binary files /dev/null and b/lib/struts2-spring-plugin-2.3.32.jar differ diff --git a/lib/struts2-testng-plugin-2.3.24.1.jar b/lib/struts2-testng-plugin-2.3.24.1.jar new file mode 100644 index 0000000..3528da3 Binary files /dev/null and b/lib/struts2-testng-plugin-2.3.24.1.jar differ diff --git a/lib/swingx-1.6.1.jar b/lib/swingx-1.6.1.jar new file mode 100644 index 0000000..b0bcc87 Binary files /dev/null and b/lib/swingx-1.6.1.jar differ diff --git a/lib/taobao-sdk-java-auto_1450022832134-20151223.jar b/lib/taobao-sdk-java-auto_1450022832134-20151223.jar new file mode 100644 index 0000000..32e5d0b Binary files /dev/null and b/lib/taobao-sdk-java-auto_1450022832134-20151223.jar differ diff --git a/lib/ueditor-1.1.2.jar b/lib/ueditor-1.1.2.jar new file mode 100644 index 0000000..4819fe0 Binary files /dev/null and b/lib/ueditor-1.1.2.jar differ diff --git a/lib/urlrewritefilter-4.0.3.jar b/lib/urlrewritefilter-4.0.3.jar new file mode 100644 index 0000000..08f6ba2 Binary files /dev/null and b/lib/urlrewritefilter-4.0.3.jar differ diff --git a/lib/xssProtect-0.1.jar b/lib/xssProtect-0.1.jar new file mode 100644 index 0000000..e6fb163 Binary files /dev/null and b/lib/xssProtect-0.1.jar differ diff --git a/lib/xwork-core-2.3.32.jar b/lib/xwork-core-2.3.32.jar new file mode 100644 index 0000000..6bb5b13 Binary files /dev/null and b/lib/xwork-core-2.3.32.jar differ diff --git a/lib/yuicompressor-2.4.2.jar b/lib/yuicompressor-2.4.2.jar new file mode 100644 index 0000000..c29470b Binary files /dev/null and b/lib/yuicompressor-2.4.2.jar differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..17b1f3a --- /dev/null +++ b/pom.xml @@ -0,0 +1,426 @@ + + + 4.0.0 + + + + org.springframework.boot + spring-boot-starter-parent + 2.1.1.RELEASE + + + + org.example + ipdz + 1.0-SNAPSHOT + + + + 1.8 + 3.4.3.4 + 2.4.0 + 3.4.1 + 1.5.1 + UTF-8 + UTF-8 + + + + + + + + + + org.apache.httpcomponents + httpclient + 4.5.14 + + + + + org.apache.httpcomponents + httpmime + 4.5.14 + + + + + junit + junit + 4.13.2 + test + + + + jaxen + jaxen + 1.1.6 + + + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.13 + + + + + org.dom4j + dom4j + 2.1.4 + + + + + + log4j + log4j + 1.2.17 + + + + + org.fusesource + sigar + 1.6.4 + + + + + + + com.sun.mail + javax.mail + 1.6.2 + + + + + org.springframework + spring-orm + 3.2.18.RELEASE + + + + + + + + + org.apache.struts + struts2-core + 6.3.0 + + + + + net.sf.json-lib + json-lib + 2.4 + jdk15 + + + + + + + org.hibernate + hibernate-core + 5.6.15.Final + + + org.jasypt + jasypt + 1.9.3 + + + + + + + + + + + + org.jsoup + jsoup + 1.16.1 + + + + ch.qos.logback + logback-classic + 1.2.3 + + + ch.qos.logback + logback-core + 1.2.3 + + + org.slf4j + slf4j-api + 1.7.36 + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework + spring-web + + + + + + org.mapstruct + mapstruct + 1.5.0.Beta1 + + + + + org.mapstruct + mapstruct-processor + 1.5.0.Beta1 + + + + org.springframework.boot + spring-boot-starter-aop + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + org.apache.commons + commons-lang3 + 3.3.2 + + + + commons-collections + commons-collections + 3.2.2 + + + + com.alibaba + fastjson + 1.2.58 + + + + + com.auth0 + java-jwt + 3.9.0 + + + + com.alibaba + druid + 1.2.16 + + + + + mysql + mysql-connector-java + 8.0.22 + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus-version} + + + + com.baomidou + mybatis-plus-generator + ${mybatis-plus-generator-version} + + + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.4.2 + + + + + org.yaml + snakeyaml + + + + cn.hutool + hutool-all + 5.8.9 + + + + + + io.springfox + springfox-swagger2 + 2.8.0 + + + mapstruct + org.mapstruct + + + + + io.springfox + springfox-swagger-ui + 2.8.0 + + + + com.github.xiaoymin + swagger-bootstrap-ui + 1.9.1 + + + + javax.servlet + javax.servlet-api + 3.0.1 + true + + + + org.apache.httpcomponents + httpclient + 4.5.5 + + + commons-httpclient + commons-httpclient + 3.1 + + + com.hikvision.ga + artemis-http-client + 1.1.2 + + + + org.hibernate + hibernate-validator + 5.2.0.Final + + + + + org.projectlombok + lombok + true + + + + + + com.alibaba + easyexcel + 3.2.0 + sources + java-source + + + + + com.baomidou + dynamic-datasource-spring-boot-starter + 3.4.0 + + + org.apache.poi + poi + 4.1.2 + + + + + + com.github.yulichang + mybatis-plus-join + 1.2.4 + + + + + com.google.code.gson + gson + 2.8.5 + + + junit + junit + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + org.projectlombok + lombok + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + UTF-8 + + ${project.basedir}/lib + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/me/mofun/IpdzApplication.java b/src/main/java/me/mofun/IpdzApplication.java new file mode 100644 index 0000000..ef0c46a --- /dev/null +++ b/src/main/java/me/mofun/IpdzApplication.java @@ -0,0 +1,17 @@ +package me.mofun; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +@EnableAsync +@EnableScheduling +public class IpdzApplication { + + public static void main(String[] args) { + SpringApplication.run(IpdzApplication.class, args); + System.out.println("==============后台程序启动成功==============="); + } +} diff --git a/src/main/java/me/mofun/action/AboutAction.java b/src/main/java/me/mofun/action/AboutAction.java new file mode 100644 index 0000000..53aa7a5 --- /dev/null +++ b/src/main/java/me/mofun/action/AboutAction.java @@ -0,0 +1,32 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import org.springframework.stereotype.Component; + +@SuppressWarnings("unused") +@Component("AboutAction") +public class AboutAction extends ActionSupport { + + private static final long serialVersionUID = -6979064905632902960L; + + public String index(){ + + return "index"; + } + + public String jobs(){ + + return "jobs"; + } + + public String contactus(){ + + return "contactus"; + } + + public String Links(){ + + return "Links"; + } + +} diff --git a/src/main/java/me/mofun/action/AlipayAction.java b/src/main/java/me/mofun/action/AlipayAction.java new file mode 100644 index 0000000..fbb8975 --- /dev/null +++ b/src/main/java/me/mofun/action/AlipayAction.java @@ -0,0 +1,811 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.alipay.config.AlipayConfig; +import me.mofun.alipay.util.AlipayNotify; +import me.mofun.alipay.util.AlipaySubmit; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.tenpay.util.TenpayUtil; +import me.mofun.util.*; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.util.*; + +public class AlipayAction extends ActionSupport { + + private static final long serialVersionUID = -8970081284102469306L; + + RandomUtil randomUtil = new RandomUtil(); + @Autowired + ConsumetableService consumetableService; + @Autowired + ConsumerdetailService consumerdetailService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private RandomnumberService randomnumberService; + @Autowired + private UserService userService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ProductService productService; + @Autowired + private NewLotteryUtil newLotteryUtil; + @Autowired + CommissionqueryService commissionqueryService; + @Autowired + CommissionpointsService commissionpointsService; + + private User user; + private String userId; + private Consumetable consumetable; + private ProductCart productCart; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private Randomnumber randomnumber; + private Latestlottery latestlottery; + private Consumerdetail consumerdetail; + private List productCartList; + private List successCartList; + private ProductJSON productJSON; + private String paymentStatus; + private Commissionquery commissionquery; + private Commissionpoints commissionpoints; + + private Integer moneyCount; + private String integral; + + //当前时间 yyyyMMddHHmmss + private String currTime = TenpayUtil.getCurrTime(); + //8位日期 + private String strTime = currTime.substring(8, currTime.length()); + //四位随机数 + private String strRandom = TenpayUtil.buildRandom(4) + ""; + //10位序列号,可以自行调整。 + private String strReq = strTime + strRandom; + Random random = new Random(); + HttpServletRequest request = null; + HttpServletResponse response = null; + + + public String goPay() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + + //支付类型 + String payment_type = "1"; + //必填,不能修改 + //服务器异步通知页面路径 +// http://124.193.138.90/tenpay/notifyUrl.action + String notify_url = AlipayConfig.notify_url; + //需http://格式的完整路径,不能加?id=123这类自定义参数 + //页面跳转同步通知页面路径 +// http://124.193.138.90/tenpay/returnUrl.action + String return_url = AlipayConfig.return_url; + //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ + //卖家支付宝帐户 + String seller_email = AlipayConfig.mail; + //必填 + //商户订单号 + String out_trade_no = strReq; + //商户网站订单系统中唯一订单号,必填 + //订单名称 + String subject = ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")"; + //必填 + //付款金额 + String total_fee = moneyCount.toString(); + //必填 + //订单描述 + String body = "";//ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")"; + //商品展示地址 + String show_url = ApplicationListenerImpl.sysConfigureJson.getWwwUrl(); + //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html + //防钓鱼时间戳 + String anti_phishing_key = currTime; + //若要使用请调用类文件submit中的query_timestamp函数 + //客户端的IP地址 +// String exter_invoke_ip = request.getRemoteAddr(); + String exter_invoke_ip = request.getHeader("X-Real-IP"); + //非局域网的外网IP地址,如:221.0.0.1 + + + + /** + * 业务开始 + */ + productCartList = new ArrayList(); + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); +// if(userId!=null && !userId.equals("")){ +// user = userService.findById(userId); +// } + } + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + if(StringUtil.isNotBlank(userId)){ + Integer buyConut = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + buyConut += count; + productCount ++; + productCart.setCount(count); + productCart.setHeadImage(product.getHeadImage()); +// productCart.setMoneyCount(buyConut); + productCart.setProductCount(productCount); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + productCartList.add(productCart); + flag = true; + + body = body + product.getProductTitle(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } +// moneyCount 财付通充值的钱 600 +// buyConut 要花的钱 7 +// hidUseBalance 余额的钱 1 buyConut=moneyCount+hidUseBalance + if(flag){ + try { + consumetable = new Consumetable(); + double money = Double.parseDouble(String.valueOf(moneyCount)); + consumetable.setBuyCount(buyConut); //要花的钱 7 + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + consumetable.setInterfaceType("aliPay"); + consumetable.setMoney(money); //财付通充值的钱 6 + consumetable.setOutTradeNo(out_trade_no); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); + } catch (Exception e) { + e.printStackTrace(); + flag = false; + } + }else{ + flag = false; + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + + + //alipay 即时到帐接口:把请求参数打包成数组 + Map sParaTemp = new HashMap(); + sParaTemp.put("service", "create_direct_pay_by_user"); + sParaTemp.put("partner", AlipayConfig.partner); + sParaTemp.put("_input_charset", AlipayConfig.input_charset); + sParaTemp.put("payment_type", payment_type); + sParaTemp.put("notify_url", notify_url); + sParaTemp.put("return_url", return_url); + sParaTemp.put("seller_email", seller_email); + sParaTemp.put("out_trade_no", out_trade_no); + sParaTemp.put("subject", subject); + sParaTemp.put("total_fee", total_fee); + sParaTemp.put("body", body); + sParaTemp.put("show_url", show_url); + sParaTemp.put("anti_phishing_key", anti_phishing_key); + sParaTemp.put("exter_invoke_ip", exter_invoke_ip); + sParaTemp.put("extra_common_param", integral); + + //建立请求 + String sHtmlText = AlipaySubmit.buildRequest(sParaTemp,"get","确认"); + System.out.println(sHtmlText); + + if(flag){ + Struts2Utils.render("text/html", sHtmlText,"encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + return null; + } + + public String returnUrl() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String buyproduct ="";// 已经被买完的商品 + //获取支付宝GET过来反馈信息 + Map params = new HashMap(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { + String name = (String) iter.next(); + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化 + //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8"); + params.put(name, valueStr); + } + + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)// + //商户订单号 + String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8"); + //支付宝交易号 + String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8"); + //金额 + String total_fee = new String(request.getParameter("total_fee").getBytes("ISO-8859-1"),"UTF-8"); + //交易状态 + String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8"); + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)// + String integral = new String(request.getParameter("extra_common_param").getBytes("ISO-8859-1"),"UTF-8"); + + //计算得出通知验证结果 + boolean verify_result = AlipayNotify.verify(params); + if(verify_result){//验证成功 + //请在这里加上商户的业务逻辑程序代码 + + //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— + if(trade_status.equals("TRADE_FINISHED") || trade_status.equals("TRADE_SUCCESS")){ + //判断该笔订单是否在商户网站中已经做过处理 + //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 + //如果有做过处理,不执行商户的业务程序 + //即时到账处理业务开始 + //------------------------------ + try { + String key = MD5Util.encode(trade_no); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + MemCachedClientHelp.getIMemcachedCache().put(key, "y",new Date(12*60*60*1000)); + productCartList = new ArrayList(); + successCartList = new ArrayList(); + try { + consumetable = consumetableService.findByOutTradeNo(out_trade_no);//找到订单 + double money = Double.parseDouble(String.valueOf(total_fee));//充值的钱 + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId().equals(trade_no)){ + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + } + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + //总购买钱数 + Integer moneyCount = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + moneyCount += count; + productCount ++; + productCart.setCount(count); + productCart.setHeadImage(product.getHeadImage()); + productCart.setMoneyCount(moneyCount); + productCart.setProductCount(productCount); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + productCartList.add(productCart); + flag = true; + }else{ + buyproduct += "您购买的商品中 " + product.getProductName() + " 已经满员.
"; +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// flag = false; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + if(StringUtil.isNotBlank(userId)){ + user = userService.findById(userId); + } + + if(flag){ + for (final ProductCart productCart : productCartList) { + try { + spellbuyproduct = spellbuyproductService.findById(productCart.getProductId().toString()); + //真正要购买的数量 + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+productCart.getCount()) > productCart.getProductPrice()){ + count = productCart.getProductPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = productCart.getCount(); + } + + if(count>0){ + if(StringUtil.isNotBlank(integral) && !integral.equals("0")){ + if(user.getBalance()>=(count-(Integer.parseInt(integral)/100))){ + Double temp = user.getBalance() - (count-(Integer.parseInt(integral)/100)); + user.setBalance(temp); +// userService.add(user); + + consumerdetail = new Consumerdetail(); + consumerdetail.setBuyCount(count); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + consumerdetail.setProductTitle(productCart.getProductTitle()); + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + commissionquery = new Commissionquery(); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + }else{ + if(user.getBalance()>=count){ + Double temp = user.getBalance() - count; + user.setBalance(temp); + //userService.add(user); + consumerdetail = new Consumerdetail(); + consumerdetail.setBuyCount(count); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + consumerdetail.setProductTitle(productCart.getProductTitle()); + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + commissionquery = new Commissionquery(); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + + spellbuyproduct.setSpellbuyCount(spellbuyproduct.getSpellbuyCount()+count); + if(spellbuyproduct.getSpellbuyCount()>=productCart.getProductPrice()){ + spellbuyproduct.setSpellbuyCount(productCart.getProductPrice()); + //开奖状态 + spellbuyproduct.setSpStatus(2); + spellbuyproduct.setSpellbuyEndDate(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + } + spellbuyproductService.add(spellbuyproduct); + + spellbuyrecord = new Spellbuyrecord(); + spellbuyrecord.setFkSpellbuyProductId(spellbuyproduct.getSpellbuyProductId()); + spellbuyrecord.setBuyer(user.getUserId()); + spellbuyrecord.setBuyPrice(count); + spellbuyrecord.setBuyDate(DateUtil.DateTimeToStrBySSS(new Date())); + spellbuyrecord.setSpWinningStatus("0"); + spellbuyrecord.setBuyStatus("0"); + spellbuyrecord.setSpRandomNo(""); + spellbuyrecordService.add(spellbuyrecord); + randomnumber = new Randomnumber(); + randomnumber.setProductId(productCart.getProductId()); + + List RandomnumberList = randomnumberService.query(" from Randomnumber where productId='"+ spellbuyproduct.getSpellbuyProductId() + +"'"); + List oldRandomList = new ArrayList(); + for (Randomnumber randomnumber : RandomnumberList) { + if(randomnumber.getRandomNumber().contains(",")){ + String[] rs = randomnumber.getRandomNumber().split(","); + for (String string : rs) { + oldRandomList.add(string); + } + }else{ + oldRandomList.add(randomnumber.getRandomNumber()); + } + } + randomnumber.setRandomNumber(randomUtil.newRandom(count,spellbuyproduct.getSpellbuyPrice(),oldRandomList)); + + randomnumber.setSpellbuyrecordId(spellbuyrecord.getSpellbuyRecordId()); + randomnumber.setBuyDate(spellbuyrecord.getBuyDate()); + randomnumber.setUserId(Integer.parseInt(userId)); + randomnumberService.add(randomnumber); + + if(StringUtil.isNotBlank(integral) && !integral.equals("0")){ + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + } + + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count+"元获得福分"); + commissionpoints.setPay("+"+((count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())-(Integer.parseInt(integral)/100))); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points+((count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())-(Integer.parseInt(integral)/100))); + + Integer experience = user.getExperience(); + experience += (count*10); + user.setExperience(experience); + userService.add(user); + + productJSON = new ProductJSON(); + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductId(productCart.getProductId()); + productJSON.setProductName(productCart.getProductName()); + productJSON.setProductPeriod(productCart.getProductPeriod()); + productJSON.setProductTitle(productCart.getProductTitle()); + productJSON.setBuyCount(count); + successCartList.add(productJSON); + } + } catch (Exception e) { + e.printStackTrace(); + flag = false; + } + } + } + if(flag){ + /** + * 清空购物车 + */ + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("products",null); + cookie.setMaxAge(0); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + request.setAttribute("buyproduct", buyproduct); + System.out.println("即时到帐付款成功"); + paymentStatus = "success"; + + } + } catch (Exception e) { + e.printStackTrace(); + } + } + //该页面可做页面美工编辑 + System.out.println("验证成功
"); + //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— + ////////////////////////////////////////////////////////////////////////////////////////// + }else{ + //该页面可做页面美工编辑 + System.out.println("验证失败"); + paymentStatus = "error"; + } + return "success"; + } + + public String notifyUrl() throws Exception{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + //获取支付宝POST过来反馈信息 + Map params = new HashMap(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { + String name = (String) iter.next(); + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化 + //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk"); + params.put(name, valueStr); + } + + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)// + //商户订单号 + + String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8"); + //支付宝交易号 + String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8"); + String total_fee = new String(request.getParameter("total_fee").getBytes("ISO-8859-1"),"UTF-8"); + //交易状态 + String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8"); + + String integral = new String(request.getParameter("extra_common_param").getBytes("ISO-8859-1"),"UTF-8"); + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)// + if(AlipayNotify.verify(params)){//验证成功 + ////////////////////////////////////////////////////////////////////////////////////////// + //请在这里加上商户的业务逻辑程序代码 + + //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— + + if(trade_status.equals("TRADE_FINISHED")){ + //判断该笔订单是否在商户网站中已经做过处理 + //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 + //如果有做过处理,不执行商户的业务程序 + //即时到账处理业务开始 + //注意: + //该种交易状态只在两种情况下出现 + //1、开通了普通即时到账,买家付款成功后。 + //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。 + } else if (trade_status.equals("TRADE_SUCCESS")){ + //判断该笔订单是否在商户网站中已经做过处理 + //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 + //如果有做过处理,不执行商户的业务程序 + try { + consumetable = consumetableService.findByOutTradeNo(out_trade_no); + double money = Double.parseDouble(String.valueOf(total_fee)); + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId()==null){ + consumetable.setTransactionId(trade_no); + consumetableService.add(consumetable); + + user = userService.findById(String.valueOf(consumetable.getUserId())); + user.setBalance(money+user.getBalance()); + userService.add(user); + flag = true; + } + } catch (Exception e) { + flag = false; + e.printStackTrace(); + } + //注意: + //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。 + } + + //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— + + System.out.println("success"); //请不要修改或删除 + Struts2Utils.render("text/html", "success","encoding:UTF-8"); + ////////////////////////////////////////////////////////////////////////////////////////// + }else{//验证失败 + Struts2Utils.render("text/html", "fail","encoding:UTF-8"); + System.out.println("fail"); + } + return null; + } + + public Integer getMoneyCount() { + return moneyCount; + } + + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Consumetable getConsumetable() { + return consumetable; + } + + public void setConsumetable(Consumetable consumetable) { + this.consumetable = consumetable; + } + + public ProductCart getProductCart() { + return productCart; + } + + public void setProductCart(ProductCart productCart) { + this.productCart = productCart; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public Consumerdetail getConsumerdetail() { + return consumerdetail; + } + + public void setConsumerdetail(Consumerdetail consumerdetail) { + this.consumerdetail = consumerdetail; + } + + public List getProductCartList() { + return productCartList; + } + + public void setProductCartList(List productCartList) { + this.productCartList = productCartList; + } + + public List getSuccessCartList() { + return successCartList; + } + + public void setSuccessCartList(List successCartList) { + this.successCartList = successCartList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public String getPaymentStatus() { + return paymentStatus; + } + + public void setPaymentStatus(String paymentStatus) { + this.paymentStatus = paymentStatus; + } + + public Commissionquery getCommissionquery() { + return commissionquery; + } + + public void setCommissionquery(Commissionquery commissionquery) { + this.commissionquery = commissionquery; + } + + public Commissionpoints getCommissionpoints() { + return commissionpoints; + } + + public void setCommissionpoints(Commissionpoints commissionpoints) { + this.commissionpoints = commissionpoints; + } + + public String getIntegral() { + return integral; + } + + public void setIntegral(String integral) { + this.integral = integral; + } + + +} diff --git a/src/main/java/me/mofun/action/AlipayBalanceAction.java b/src/main/java/me/mofun/action/AlipayBalanceAction.java new file mode 100644 index 0000000..d7c39ec --- /dev/null +++ b/src/main/java/me/mofun/action/AlipayBalanceAction.java @@ -0,0 +1,404 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.alipay.config.AlipayConfig; +import me.mofun.alipay.util.AlipayNotify; +import me.mofun.alipay.util.AlipaySubmit; +import me.mofun.pojo.Consumetable; +import me.mofun.pojo.User; +import me.mofun.service.ConsumerdetailService; +import me.mofun.service.ConsumetableService; +import me.mofun.service.UserService; +import me.mofun.tenpay.util.TenpayUtil; +import me.mofun.util.*; +import net.sf.json.JSONArray; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.util.*; + +@SuppressWarnings("unused") +@Component("AlipayBalanceAction") +public class AlipayBalanceAction extends ActionSupport { + + private static final long serialVersionUID = 2055647485775038604L; + + @Autowired + ConsumetableService consumetableService; + @Autowired + ConsumerdetailService consumerdetailService; + @Autowired + private UserService userService; + + private User user; + private String userId; + private Consumetable consumetable; + private Integer moneyCount; + private String hidUseBalance; + private String paymentStatus; + + + //当前时间 yyyyMMddHHmmss + private String currTime = TenpayUtil.getCurrTime(); + //8位日期 + private String strTime = currTime.substring(8, currTime.length()); + //四位随机数 + private String strRandom = TenpayUtil.buildRandom(4) + ""; + //10位序列号,可以自行调整。 + private String strReq = strTime + strRandom; + Random random = new Random(); + HttpServletRequest request = null; + HttpServletResponse response = null; + + public String index(){ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + + boolean flag = false; + //支付类型 + String payment_type = "1"; + //必填,不能修改 + //服务器异步通知页面路径 +// http://124.193.138.90/tenpay/notifyUrl.action + String notify_url = ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/alipayBalance/notifyUrl.action"; + //需http://格式的完整路径,不能加?id=123这类自定义参数 + //页面跳转同步通知页面路径 +// http://124.193.138.90/tenpay/returnUrl.action + String return_url = ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/alipayBalance/returnUrl.action"; + //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ + //卖家支付宝帐户 + String seller_email = AlipayConfig.mail; + //必填 + //商户订单号 + String out_trade_no = strReq; + //商户网站订单系统中唯一订单号,必填 + //订单名称 + String subject = ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")"; + //必填 + //付款金额 + String total_fee = moneyCount.toString(); + //必填 + //订单描述 + String body = ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")"; + //商品展示地址 + String show_url = ApplicationListenerImpl.sysConfigureJson.getWwwUrl(); + //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html + //防钓鱼时间戳 + String anti_phishing_key = currTime; + //若要使用请调用类文件submit中的query_timestamp函数 + //客户端的IP地址 +// String exter_invoke_ip = request.getRemoteAddr(); + String exter_invoke_ip = request.getHeader("X-Real-IP"); + //非局域网的外网IP地址,如:221.0.0.1 + + //把请求参数打包成数组 + Map sParaTemp = new HashMap(); + sParaTemp.put("service", "create_direct_pay_by_user"); + sParaTemp.put("partner", AlipayConfig.partner); + sParaTemp.put("_input_charset", AlipayConfig.input_charset); + sParaTemp.put("payment_type", payment_type); + sParaTemp.put("notify_url", notify_url); + sParaTemp.put("return_url", return_url); + sParaTemp.put("seller_email", seller_email); + sParaTemp.put("out_trade_no", out_trade_no); + sParaTemp.put("subject", subject); + sParaTemp.put("total_fee", total_fee); + sParaTemp.put("body", body); + sParaTemp.put("show_url", show_url); + sParaTemp.put("anti_phishing_key", anti_phishing_key); + sParaTemp.put("exter_invoke_ip", exter_invoke_ip); + + + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); +// if(userId!=null && !userId.equals("")){ +// user = userService.findById(userId); +// } + } + } + } + + try { + consumetable = new Consumetable(); + int buyConut = moneyCount; + if(hidUseBalance!=null && !hidUseBalance.equals("")){ + buyConut +=Integer.parseInt(hidUseBalance); + } + double money = Double.parseDouble(String.valueOf(moneyCount)); + consumetable.setBuyCount(buyConut); + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + consumetable.setInterfaceType("aliPay"); + consumetable.setMoney(money); + consumetable.setOutTradeNo(out_trade_no); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); +// consumerdetail = new Consumerdetail(); +// consumerdetail.setBuyCount(productCart.getCount()); +// consumerdetail.setBuyMoney(Double.parseDouble(productCart.getCount().toString())); +// consumerdetail.setConsumetableId(out_trade_no); +// consumerdetail.setProductId(productCart.getProductId()); +// consumerdetail.setProductName(productCart.getProductName()); +// consumerdetail.setProductPeriod(productCart.getProductPeriod()); +// consumerdetail.setProductTitle(productCart.getProductTitle()); +// consumerdetailService.add(consumerdetail); + flag = true; + } catch (Exception e) { + e.printStackTrace(); + flag = false; + } + + //建立请求 + String sHtmlText = AlipaySubmit.buildRequest(sParaTemp,"get","确认"); + System.out.println(sHtmlText); + if(flag){ + Struts2Utils.render("text/html", sHtmlText,"encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + + return null; + } + + public String returnUrl() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + String buyproduct ="";// 已经被买完的商品 + //获取支付宝GET过来反馈信息 + Map params = new HashMap(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { + String name = (String) iter.next(); + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化 +// valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8"); + params.put(name, valueStr); + } + + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)// + //商户订单号 + String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8"); + //支付宝交易号 + String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8"); + //金额 + String total_fee = new String(request.getParameter("total_fee").getBytes("ISO-8859-1"),"UTF-8"); + //交易状态 + String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8"); + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)// + + //计算得出通知验证结果 + boolean verify_result = AlipayNotify.verify(params); + if(verify_result){//验证成功 + //请在这里加上商户的业务逻辑程序代码 + + //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— + if(trade_status.equals("TRADE_FINISHED") || trade_status.equals("TRADE_SUCCESS")){ + //判断该笔订单是否在商户网站中已经做过处理 + //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 + //如果有做过处理,不执行商户的业务程序 + //即时到账处理业务开始 + //------------------------------ + try { + + try { + consumetable = consumetableService.findByOutTradeNo(out_trade_no); + double money = Double.parseDouble(String.valueOf(total_fee)); + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId().equals(trade_no)){ + paymentStatus = "success"; + + }else{ + paymentStatus = "error"; + } + } catch (Exception e) { + e.printStackTrace(); + } + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + System.out.println("即时到帐付款成功"); + + } catch (Exception e) { + e.printStackTrace(); + } + } + //该页面可做页面美工编辑 + System.out.println("验证成功
"); + //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— + ////////////////////////////////////////////////////////////////////////////////////////// + }else{ + //该页面可做页面美工编辑 + System.out.println("验证失败"); + } + + return "success"; + } + + public String notifyUrl() throws Exception{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + //获取支付宝POST过来反馈信息 + Map params = new HashMap(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { + String name = (String) iter.next(); + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化 + //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk"); + params.put(name, valueStr); + } + + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)// + //商户订单号 + String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8"); + //支付宝交易号 + String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8"); + String total_fee = new String(request.getParameter("total_fee").getBytes("ISO-8859-1"),"UTF-8"); + //交易状态 + String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8"); + + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)// + if(AlipayNotify.verify(params)){//验证成功 + ////////////////////////////////////////////////////////////////////////////////////////// + //请在这里加上商户的业务逻辑程序代码 + + //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— + + if(trade_status.equals("TRADE_FINISHED")){ + //判断该笔订单是否在商户网站中已经做过处理 + //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 + //如果有做过处理,不执行商户的业务程序 + //即时到账处理业务开始 + //注意: + //该种交易状态只在两种情况下出现 + //1、开通了普通即时到账,买家付款成功后。 + //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。 + } else if (trade_status.equals("TRADE_SUCCESS")){ + //判断该笔订单是否在商户网站中已经做过处理 + //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 + //如果有做过处理,不执行商户的业务程序 + try { + consumetable = consumetableService.findByOutTradeNo(out_trade_no); + double money = Double.parseDouble(String.valueOf(total_fee)); + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId()==null){ + consumetable.setTransactionId(trade_no); + consumetableService.add(consumetable); + userId = String.valueOf(consumetable.getUserId()); + if(userId!=null && !userId.equals("")){ + try { + String key = MD5Util.encode(trade_no); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + user = userService.findById(userId); + Double recMoney = consumetable.getMoney(); + if(recMoney >= ApplicationListenerImpl.sysConfigureJson.getRecMoney()){ + recMoney += ApplicationListenerImpl.sysConfigureJson.getRecBalance(); + } + Double temp = user.getBalance() + recMoney; + System.err.println("user.getBalance()"+user.getBalance()); + System.err.println("consumetable.getMoney()"+consumetable.getMoney()); + System.err.println("temp:"+temp); + user.setBalance(temp); + userService.add(user); + MemCachedClientHelp.getIMemcachedCache().put(key, "y",new Date(12*60*60*1000)); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + } + } catch (Exception e) { + e.printStackTrace(); + } + //注意: + //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。 + } + + //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— + + System.out.println("success"); //请不要修改或删除 + Struts2Utils.render("text/html", "success","encoding:UTF-8"); + ////////////////////////////////////////////////////////////////////////////////////////// + }else{//验证失败 + Struts2Utils.render("text/html", "fail","encoding:UTF-8"); + System.out.println("fail"); + } + return null; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Consumetable getConsumetable() { + return consumetable; + } + + public void setConsumetable(Consumetable consumetable) { + this.consumetable = consumetable; + } + + public Integer getMoneyCount() { + return moneyCount; + } + + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + + public String getHidUseBalance() { + return hidUseBalance; + } + + public void setHidUseBalance(String hidUseBalance) { + this.hidUseBalance = hidUseBalance; + } + + public String getPaymentStatus() { + return paymentStatus; + } + + public void setPaymentStatus(String paymentStatus) { + this.paymentStatus = paymentStatus; + } + + + + +} diff --git a/src/main/java/me/mofun/action/AlipaySoftAction.java b/src/main/java/me/mofun/action/AlipaySoftAction.java new file mode 100644 index 0000000..8b4eb5e --- /dev/null +++ b/src/main/java/me/mofun/action/AlipaySoftAction.java @@ -0,0 +1,536 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.alipay.config.AlipayConfig; +import me.mofun.alipay.util.AlipayNotify; +import me.mofun.alipay.util.AlipaySubmit; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.tenpay.util.TenpayUtil; +import me.mofun.util.*; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.util.*; + +public class AlipaySoftAction extends ActionSupport { + + private static final long serialVersionUID = -8970081284102469306L; + + RandomUtil randomUtil = new RandomUtil(); + @Autowired + ConsumetableService consumetableService; + @Autowired + ConsumerdetailService consumerdetailService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private RandomnumberService randomnumberService; + @Autowired + private UserService userService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ProductService productService; + @Autowired + private NewLotteryUtil newLotteryUtil; + @Autowired + CommissionqueryService commissionqueryService; + @Autowired + CommissionpointsService commissionpointsService; + + private User user; + private String userId; + private Consumetable consumetable; + private ProductCart productCart; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private Randomnumber randomnumber; + private Latestlottery latestlottery; + private Consumerdetail consumerdetail; + private List productCartList; + private List successCartList; + private ProductJSON productJSON; + private String paymentStatus; + private Commissionquery commissionquery; + private Commissionpoints commissionpoints; + + private Integer moneyCount; + private String integral; + + //当前时间 yyyyMMddHHmmss + private String currTime = TenpayUtil.getCurrTime(); + //8位日期 + private String strTime = currTime.substring(8, currTime.length()); + //四位随机数 + private String strRandom = TenpayUtil.buildRandom(4) + ""; + //10位序列号,可以自行调整。 + private String strReq = strTime + strRandom; + Random random = new Random(); + HttpServletRequest request = null; + HttpServletResponse response = null; + + + public String goPay() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + //支付类型 + String payment_type = "1"; + //必填,不能修改 + //服务器异步通知页面路径 +// http://124.193.138.90/tenpay/notifyUrl.action + String notify_url = AlipayConfig.notify_url; + //需http://格式的完整路径,不能加?id=123这类自定义参数 + //页面跳转同步通知页面路径 +// http://124.193.138.90/tenpay/returnUrl.action + String return_url =AlipayConfig.return_url; + //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ + //卖家支付宝帐户 + String seller_email = AlipayConfig.mail; + //必填 + //商户订单号 + String out_trade_no = strReq; + //商户网站订单系统中唯一订单号,必填 + //订单名称 + String subject = "软件授权费"; + //必填 + //付款金额 + String total_fee = "5000"; + //必填 + //订单描述 + String body = "软件授权费"; + //商品展示地址 + String show_url = ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/buySoft/index.html"; + //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html + //防钓鱼时间戳 + String anti_phishing_key = currTime; + //若要使用请调用类文件submit中的query_timestamp函数 + //客户端的IP地址 +// String exter_invoke_ip = request.getRemoteAddr(); + String exter_invoke_ip = request.getHeader("X-Real-IP"); + //非局域网的外网IP地址,如:221.0.0.1 + + //把请求参数打包成数组 + Map sParaTemp = new HashMap(); + sParaTemp.put("service", "create_direct_pay_by_user"); + sParaTemp.put("partner", AlipayConfig.partner); + sParaTemp.put("_input_charset", AlipayConfig.input_charset); + sParaTemp.put("payment_type", payment_type); + sParaTemp.put("notify_url", notify_url); + sParaTemp.put("return_url", return_url); + sParaTemp.put("seller_email", seller_email); + sParaTemp.put("out_trade_no", out_trade_no); + sParaTemp.put("subject", subject); + sParaTemp.put("total_fee", total_fee); + sParaTemp.put("body", body); + sParaTemp.put("show_url", show_url); + sParaTemp.put("anti_phishing_key", anti_phishing_key); + sParaTemp.put("exter_invoke_ip", exter_invoke_ip); + sParaTemp.put("extra_common_param", integral); + + +// /** +// * 业务开始 +// */ +// productCartList = new ArrayList(); +// Cookie[] cookies = request.getCookies(); +// JSONArray array = null; +// if(request.isRequestedSessionIdFromCookie()){ +// for (int i = 0; i < cookies.length; i++) { +// Cookie cookie = cookies[i]; +// if(cookie.getName().equals("userId")){ +// userId = cookie.getValue(); +//// if(userId!=null && !userId.equals("")){ +//// user = userService.findById(userId); +//// } +// } +// if(cookie.getName().equals("products")){ +// String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); +// if(product!=null && !product.equals("")){ +// array = JSONArray.fromObject(product); +// } +// } +// } +// } +// +// if(StringUtil.isNotBlank(userId)){ +// Integer buyConut = 0; +// Integer productCount = 0; +// if(array!=null && !array.toString().equals("[{}]")){ +// for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); +// product = (Product) proList.get(0)[0]; +// spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; +// if(spellbuyproduct.getSpStatus()==0){ +// Integer count = 0; +// //当前拍购人数 +// Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); +// if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ +// count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); +// }else{ +// count = obj.getInt("num"); +// } +// buyConut += count; +// productCount ++; +// productCart.setCount(count); +// productCart.setHeadImage(product.getHeadImage()); +//// productCart.setMoneyCount(buyConut); +// productCart.setProductCount(productCount); +// productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); +// productCart.setProductName(product.getProductName()); +// productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); +// productCart.setProductTitle(product.getProductTitle()); +// productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); +// productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); +// productCartList.add(productCart); +// flag = true; +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// } +//// moneyCount 财付通充值的钱 600 +//// buyConut 要花的钱 7 +//// hidUseBalance 余额的钱 1 buyConut=moneyCount+hidUseBalance +// if(flag){ +// try { +// consumetable = new Consumetable(); +// double money = Double.parseDouble(String.valueOf(moneyCount)); +// consumetable.setBuyCount(buyConut); //要花的钱 7 +// consumetable.setDate(DateUtil.DateTimeToStr(new Date())); +// consumetable.setInterfaceType("aliPay"); +// consumetable.setMoney(money); //财付通充值的钱 6 +// consumetable.setOutTradeNo(out_trade_no); +// consumetable.setUserId(Integer.parseInt(userId)); +// consumetableService.add(consumetable); +// } catch (Exception e) { +// e.printStackTrace(); +// flag = false; +// } +// }else{ +// flag = false; +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// } +// } + + //建立请求 + String sHtmlText = AlipaySubmit.buildRequest(sParaTemp,"get","确认"); + System.out.println(sHtmlText); +// if(flag){ + Struts2Utils.render("text/html", sHtmlText,"encoding:UTF-8"); +// }else{ +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// } + return null; + } + + public String returnUrl() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + //获取支付宝GET过来反馈信息 + Map params = new HashMap(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { + String name = (String) iter.next(); + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化 +// valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8"); + params.put(name, valueStr); + } + + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)// + //商户订单号 + String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8"); + //支付宝交易号 + String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8"); + //金额 + String total_fee = new String(request.getParameter("total_fee").getBytes("ISO-8859-1"),"UTF-8"); + //交易状态 + String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8"); + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)// + integral = new String(request.getParameter("extra_common_param").getBytes("ISO-8859-1"),"UTF-8"); + + //计算得出通知验证结果 + boolean verify_result = AlipayNotify.verify(params); + if(verify_result){//验证成功 + //请在这里加上商户的业务逻辑程序代码 + + //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— + if(trade_status.equals("TRADE_FINISHED") || trade_status.equals("TRADE_SUCCESS")){ + //判断该笔订单是否在商户网站中已经做过处理 + //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 + //如果有做过处理,不执行商户的业务程序 + //即时到账处理业务开始 + //------------------------------ + try { + String key = MD5Util.encode(trade_no); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + MemCachedClientHelp.getIMemcachedCache().put(key, "y",new Date(12*60*60*1000)); + + + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + System.out.println("即时到帐付款成功"); + paymentStatus = "success"; + String s = UUID.randomUUID().toString().toUpperCase(); + s = s.substring(0,8)+s.substring(9,13)+s.substring(14,18)+s.substring(19,23)+s.substring(24); + String md5s = MD5Util.encode(s); + String softKey = s+ md5s; + userId = softKey; + }else{ + paymentStatus = "ok"; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + //该页面可做页面美工编辑 + System.out.println("验证成功
"); + //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— + ////////////////////////////////////////////////////////////////////////////////////////// + }else{ + //该页面可做页面美工编辑 + System.out.println("验证失败"); + paymentStatus = "error"; + } + return "success"; + } + + public String notifyUrl() throws Exception{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + //获取支付宝POST过来反馈信息 + Map params = new HashMap(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { + String name = (String) iter.next(); + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化 + //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk"); + params.put(name, valueStr); + } + + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)// + //商户订单号 + + String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8"); + //支付宝交易号 + String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8"); + String total_fee = new String(request.getParameter("total_fee").getBytes("ISO-8859-1"),"UTF-8"); + //交易状态 + String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8"); + + String integral = new String(request.getParameter("extra_common_param").getBytes("ISO-8859-1"),"UTF-8"); + //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)// + if(AlipayNotify.verify(params)){//验证成功 + ////////////////////////////////////////////////////////////////////////////////////////// + //请在这里加上商户的业务逻辑程序代码 + + //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— + + if(trade_status.equals("TRADE_FINISHED")){ + //判断该笔订单是否在商户网站中已经做过处理 + //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 + //如果有做过处理,不执行商户的业务程序 + //即时到账处理业务开始 + //注意: + //该种交易状态只在两种情况下出现 + //1、开通了普通即时到账,买家付款成功后。 + //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。 + } else if (trade_status.equals("TRADE_SUCCESS")){ + //判断该笔订单是否在商户网站中已经做过处理 + //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 + //如果有做过处理,不执行商户的业务程序 + + //注意: + //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。 + } + + //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— + + System.out.println("success"); //请不要修改或删除 + Struts2Utils.render("text/html", "success","encoding:UTF-8"); + ////////////////////////////////////////////////////////////////////////////////////////// + }else{//验证失败 + Struts2Utils.render("text/html", "fail","encoding:UTF-8"); + System.out.println("fail"); + } + return null; + } + + public String index(){ + integral = DateUtil.DateTimeToStr(new Date()); + return "index"; + } + + public Integer getMoneyCount() { + return moneyCount; + } + + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Consumetable getConsumetable() { + return consumetable; + } + + public void setConsumetable(Consumetable consumetable) { + this.consumetable = consumetable; + } + + public ProductCart getProductCart() { + return productCart; + } + + public void setProductCart(ProductCart productCart) { + this.productCart = productCart; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public Consumerdetail getConsumerdetail() { + return consumerdetail; + } + + public void setConsumerdetail(Consumerdetail consumerdetail) { + this.consumerdetail = consumerdetail; + } + + public List getProductCartList() { + return productCartList; + } + + public void setProductCartList(List productCartList) { + this.productCartList = productCartList; + } + + public List getSuccessCartList() { + return successCartList; + } + + public void setSuccessCartList(List successCartList) { + this.successCartList = successCartList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public String getPaymentStatus() { + return paymentStatus; + } + + public void setPaymentStatus(String paymentStatus) { + this.paymentStatus = paymentStatus; + } + + public Commissionquery getCommissionquery() { + return commissionquery; + } + + public void setCommissionquery(Commissionquery commissionquery) { + this.commissionquery = commissionquery; + } + + public Commissionpoints getCommissionpoints() { + return commissionpoints; + } + + public void setCommissionpoints(Commissionpoints commissionpoints) { + this.commissionpoints = commissionpoints; + } + + public String getIntegral() { + return integral; + } + + public void setIntegral(String integral) { + this.integral = integral; + } + + +} diff --git a/src/main/java/me/mofun/action/AppAction.java b/src/main/java/me/mofun/action/AppAction.java new file mode 100644 index 0000000..ddefa23 --- /dev/null +++ b/src/main/java/me/mofun/action/AppAction.java @@ -0,0 +1,52 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class AppAction extends ActionSupport { + + private static final long serialVersionUID = 2722149497257756507L; + + private String rnd; + + + HttpServletRequest request = null; + HttpServletResponse response = null; + + public String index(){ + + return "index"; + } + + public String mobile(){ + + return "mobile"; + } + + public String touch(){ + + return "touch"; + } + + public String microchannel(){ + + return "microchannel"; + } + + public String sincerity(){ + + return "sincerity"; + } + + + public String getRnd() { + return rnd; + } + + public void setRnd(String rnd) { + this.rnd = rnd; + } + +} diff --git a/src/main/java/me/mofun/action/BalanceAction.java b/src/main/java/me/mofun/action/BalanceAction.java new file mode 100644 index 0000000..3950487 --- /dev/null +++ b/src/main/java/me/mofun/action/BalanceAction.java @@ -0,0 +1,626 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.*; +import me.mofun.service.ConsumerdetailService; +import me.mofun.service.ConsumetableService; +import me.mofun.service.UserService; +import me.mofun.tenpay.RequestHandler; +import me.mofun.tenpay.ResponseHandler; +import me.mofun.tenpay.client.ClientResponseHandler; +import me.mofun.tenpay.client.TenpayHttpClient; +import me.mofun.tenpay.config.TenpayConfig; +import me.mofun.tenpay.util.TenpayUtil; +import me.mofun.util.*; +import net.sf.json.JSONArray; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Date; +import java.util.List; + +@SuppressWarnings("unused") +@Component("BalanceAction") +public class BalanceAction extends ActionSupport { + + private static final long serialVersionUID = 8197993150697915816L; + + @Autowired + ConsumetableService consumetableService; + @Autowired + ConsumerdetailService consumerdetailService; + @Autowired + private UserService userService; + + private User user; + private String userId; + private Consumetable consumetable; + private ProductCart productCart; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Consumerdetail consumerdetail; + private List productCartList; + private String paymentStatus; + + //---------------生成订单号 开始------------------------ + //当前时间 yyyyMMddHHmmss + private String currTime = TenpayUtil.getCurrTime(); + //8位日期 + private String strTime = currTime.substring(8, currTime.length()); + //四位随机数 + private String strRandom = TenpayUtil.buildRandom(4) + ""; + //10位序列号,可以自行调整。 + private String strReq = strTime + strRandom; + //订单号,此处用时间加随机数生成,商户根据自己情况调整,只要保持全局唯一就行 + private String out_trade_no = strReq; + private Integer moneyCount; + private String productBody = ""; + private String productName; + private String bank_type; + private String hidUseBalance; + private String requestUrl; + //---------------生成订单号 结束------------------------ + + + public String goBalance() throws IOException{ + HttpServletRequest request = Struts2Utils.getRequest(); + HttpServletResponse response = Struts2Utils.getResponse(); + //创建支付请求对象 + RequestHandler reqHandler = new RequestHandler(request, response); + reqHandler.init(); + + //设置密钥 + reqHandler.setKey(TenpayConfig.key); + //设置支付网关 + reqHandler.setGateUrl("https://gw.tenpay.com/gateway/pay.htm"); + //----------------------------- + //设置支付参数 + //----------------------------- + moneyCount = moneyCount * 100; + System.err.println("moneyCount:"+moneyCount); + System.err.println("bank_type"+bank_type); + reqHandler.setParameter("partner", TenpayConfig.partner); //商户号 + reqHandler.setParameter("out_trade_no", out_trade_no); //商家订单号 + reqHandler.setParameter("total_fee", moneyCount+""); //商品金额,以分为单位 + reqHandler.setParameter("return_url", TenpayConfig.balance_return_url); //交易完成后跳转的URL + reqHandler.setParameter("notify_url", TenpayConfig.balance_notify_url); //接收财付通通知的URL + reqHandler.setParameter("body",ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")"); //商品描述 + reqHandler.setParameter("bank_type",bank_type); //银行类型(中介担保时此参数无效) +// reqHandler.setParameter("spbill_create_ip",request.getRemoteAddr()); //用户的公网ip,不是商户服务器IP + reqHandler.setParameter("spbill_create_ip",request.getHeader("X-Real-IP")); //用户的公网ip,不是商户服务器IP + reqHandler.setParameter("fee_type", "1"); //币种,1人民币 + reqHandler.setParameter("subject", productName); //商品名称(中介交易时必填) + + //系统可选参数 + reqHandler.setParameter("sign_type", "MD5"); //签名类型,默认:MD5 + reqHandler.setParameter("service_version", "1.0"); //版本号,默认为1.0 + reqHandler.setParameter("input_charset", "UTF-8"); //字符编码 + reqHandler.setParameter("sign_key_index", "1"); //密钥序号 + + + //业务可选参数 + reqHandler.setParameter("attach", hidUseBalance); //附加数据,原样返回 +// reqHandler.setParameter("product_fee", ""); //商品费用,必须保证transport_fee + product_fee=total_fee +// reqHandler.setParameter("transport_fee", "0"); //物流费用,必须保证transport_fee + product_fee=total_fee +// reqHandler.setParameter("time_start", currTime); //订单生成时间,格式为yyyymmddhhmmss +// reqHandler.setParameter("time_expire", ""); //订单失效时间,格式为yyyymmddhhmmss +// reqHandler.setParameter("buyer_id", ""); //买方财付通账号 +// reqHandler.setParameter("goods_tag", ""); //商品标记 +// reqHandler.setParameter("trade_mode", "1"); //交易模式,1即时到账(默认),2中介担保,3后台选择(买家进支付中心列表选择) +// reqHandler.setParameter("transport_desc", ""); //物流说明 +// reqHandler.setParameter("trans_type", "1"); //交易类型,1实物交易,2虚拟交易 +// reqHandler.setParameter("agentid", ""); //平台ID +// reqHandler.setParameter("agent_type", ""); //代理模式,0无代理(默认),1表示卡易售模式,2表示网店模式 +// reqHandler.setParameter("seller_id", ""); //卖家商户号,为空则等同于partner + + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); +// if(userId!=null && !userId.equals("")){ +// user = userService.findById(userId); +// } + } + } + } + + try { + consumetable = new Consumetable(); + int buyConut = moneyCount / 100; + if(hidUseBalance!=null && !hidUseBalance.equals("")){ + buyConut +=Integer.parseInt(hidUseBalance); + } + double money = Double.parseDouble(String.valueOf(moneyCount)); + money = money * 0.01; + consumetable.setBuyCount(buyConut); + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + consumetable.setInterfaceType("tenPay"); + consumetable.setMoney(money); + consumetable.setOutTradeNo(out_trade_no); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); +// consumerdetail = new Consumerdetail(); +// consumerdetail.setBuyCount(productCart.getCount()); +// consumerdetail.setBuyMoney(Double.parseDouble(productCart.getCount().toString())); +// consumerdetail.setConsumetableId(out_trade_no); +// consumerdetail.setProductId(productCart.getProductId()); +// consumerdetail.setProductName(productCart.getProductName()); +// consumerdetail.setProductPeriod(productCart.getProductPeriod()); +// consumerdetail.setProductTitle(productCart.getProductTitle()); +// consumerdetailService.add(consumerdetail); + } catch (Exception e) { + e.printStackTrace(); + } + + //请求的url + requestUrl = reqHandler.getRequestURL(); + + //获取debug信息,建议把请求和debug信息写入日志,方便定位问题 + String debuginfo = reqHandler.getDebugInfo(); + System.out.println("requestUrl: " + requestUrl); + System.out.println("sign_String: " + debuginfo); +// return request.getRequestDispatcher(requestUrl).forward(request, response); + response.sendRedirect(requestUrl); + return null; + } + + public String returnUrl(){ + HttpServletRequest request = Struts2Utils.getRequest(); + HttpServletResponse response = Struts2Utils.getResponse(); + //创建支付应答对象 + ResponseHandler resHandler = new ResponseHandler(request, response); + resHandler.setKey(TenpayConfig.key); + System.out.println("前台回调返回参数:"+resHandler.getAllParameters()); + //判断签名 + if(resHandler.isTenpaySign()) { + //通知id + String notify_id = resHandler.getParameter("notify_id"); + //商户订单号 + String out_trade_no = resHandler.getParameter("out_trade_no"); + //财付通订单号 + String transaction_id = resHandler.getParameter("transaction_id"); + //金额,以分为单位 + String total_fee = resHandler.getParameter("total_fee"); + //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee + String discount = resHandler.getParameter("discount"); + //支付结果 + String trade_state = resHandler.getParameter("trade_state"); + //交易模式,1即时到账,2中介担保 + String trade_mode = resHandler.getParameter("trade_mode"); + //用户余额支付 + String hidUseBalance = resHandler.getParameter("attach"); + + if("1".equals(trade_mode)){ //即时到账 + if( "0".equals(trade_state)){ + //------------------------------ + //即时到账处理业务开始 + //------------------------------ + try { + consumetable = consumetableService.findByOutTradeNo(out_trade_no); + double money = Double.parseDouble(String.valueOf(total_fee)); + money = money * 0.01; + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId().equals(transaction_id)){ + paymentStatus = "success"; +// Cookie[] cookies = request.getCookies(); +// JSONArray array = null; +// if(request.isRequestedSessionIdFromCookie()){ +// for (int i = 0; i < cookies.length; i++) { +// Cookie cookie = cookies[i]; +// if(cookie.getName().equals("userId")){ +// userId = cookie.getValue(); +// if(userId!=null && !userId.equals("")){ +// try { +// String key = MD5Util.encode(transaction_id); +// if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ +// user = userService.findById(userId); +// Double temp = user.getBalance() + consumetable.getMoney(); +// System.err.println("user.getBalance()"+user.getBalance()); +// System.err.println("consumetable.getMoney()"+consumetable.getMoney()); +// System.err.println("temp:"+temp); +// user.setBalance(temp); +// userService.add(user); +// MemCachedClientHelp.getIMemcachedCache().put(key, "y",new Date(12*60*60*1000)); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// } +// } +// } + }else{ + paymentStatus = "error"; + } + } catch (Exception e) { + e.printStackTrace(); + } + + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + + System.out.println("即时到帐付款成功"); + }else{ + System.out.println("即时到帐付款失败"); + } + }else if("2".equals(trade_mode)){ //中介担保 + if( "0".equals(trade_state)){ + //------------------------------ + //中介担保处理业务开始 + //------------------------------ + + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //中介担保处理业务完毕 + //------------------------------ + + System.out.println("中介担保付款成功"); + }else{ + System.out.println("trade_state=" + trade_state); + } + } + } else { + System.out.println("认证签名失败"); + } + + //获取debug信息,建议把debug信息写入日志,方便定位问题 + String debuginfo = resHandler.getDebugInfo(); + System.out.println("debuginfo:" + debuginfo); + return "success"; + } + + public String notifyUrl() throws Exception{ + HttpServletRequest request = Struts2Utils.getRequest(); + HttpServletResponse response = Struts2Utils.getResponse(); + + //创建支付应答对象 + ResponseHandler resHandler = new ResponseHandler(request, response); + resHandler.setKey(TenpayConfig.key); + System.out.println("后台回调返回参数:"+resHandler.getAllParameters()); + //判断签名 + if(resHandler.isTenpaySign()) { + //通知id + String notify_id = resHandler.getParameter("notify_id"); + //创建请求对象 + RequestHandler queryReq = new RequestHandler(null, null); + //通信对象 + TenpayHttpClient httpClient = new TenpayHttpClient(); + //应答对象 + ClientResponseHandler queryRes = new ClientResponseHandler(); + + //通过通知ID查询,确保通知来至财付通 + queryReq.init(); + queryReq.setKey(TenpayConfig.key); + queryReq.setGateUrl("https://gw.tenpay.com/gateway/simpleverifynotifyid.xml"); + queryReq.setParameter("partner", TenpayConfig.partner); + queryReq.setParameter("notify_id", notify_id); + //通信对象 + httpClient.setTimeOut(5); + //设置请求内容 + httpClient.setReqContent(queryReq.getRequestURL()); + System.out.println("验证ID请求字符串:" + queryReq.getRequestURL()); + //后台调用 + if(httpClient.call()) { + //设置结果参数 + queryRes.setContent(httpClient.getResContent()); + System.out.println("验证ID返回字符串:" + httpClient.getResContent()); + queryRes.setKey(TenpayConfig.key); + //获取id验证返回状态码,0表示此通知id是财付通发起 + String retcode = queryRes.getParameter("retcode"); + //商户订单号 + String out_trade_no = resHandler.getParameter("out_trade_no"); + //财付通订单号 + String transaction_id = resHandler.getParameter("transaction_id"); + //金额,以分为单位 + String total_fee = resHandler.getParameter("total_fee"); + //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee + String discount = resHandler.getParameter("discount"); + //支付结果 + String trade_state = resHandler.getParameter("trade_state"); + //交易模式,1即时到账,2中介担保 + String trade_mode = resHandler.getParameter("trade_mode"); + //判断签名及结果 + if(queryRes.isTenpaySign()&& "0".equals(retcode)){ + System.out.println("id验证成功"); + if("1".equals(trade_mode)){ //即时到账 + if( "0".equals(trade_state)){ + //------------------------------ + //即时到账处理业务开始 + try { + consumetable = consumetableService.findByOutTradeNo(out_trade_no); + double money = Double.parseDouble(String.valueOf(total_fee)); + money = money * 0.01; + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId()==null){ + consumetable.setTransactionId(transaction_id); + consumetableService.add(consumetable); + userId = String.valueOf(consumetable.getUserId()); + if(userId!=null && !userId.equals("")){ + try { + String key = MD5Util.encode(transaction_id); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + user = userService.findById(userId); + Double recMoney = consumetable.getMoney(); + if(recMoney >= ApplicationListenerImpl.sysConfigureJson.getRecMoney()){ + recMoney += ApplicationListenerImpl.sysConfigureJson.getRecBalance(); + } + Double temp = user.getBalance() + recMoney; + System.err.println("user.getBalance()"+user.getBalance()); + System.err.println("consumetable.getMoney()"+consumetable.getMoney()); + System.err.println("temp:"+temp); + user.setBalance(temp); + userService.add(user); + MemCachedClientHelp.getIMemcachedCache().put(key, "y",new Date(12*60*60*1000)); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + resHandler.sendToCFT("success"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + //------------------------------ + + //处理数据库逻辑 + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + +// System.out.println("即时到账支付成功"); + //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知 + resHandler.sendToCFT("success"); + }else{ + System.out.println("即时到账支付失败"); + resHandler.sendToCFT("fail"); + } + }else if("2".equals(trade_mode)){ //中介担保 + //------------------------------ + //中介担保处理业务开始 + //------------------------------ + + //处理数据库逻辑 + //注意交易单不要重复处理 + //注意判断返回金额 + + int iStatus = TenpayUtil.toInt(trade_state); + switch(iStatus) { + case 0: //付款成功 + + break; + case 1: //交易创建 + + break; + case 2: //收获地址填写完毕 + + break; + case 4: //卖家发货成功 + + break; + case 5: //买家收货确认,交易成功 + + break; + case 6: //交易关闭,未完成超时关闭 + + break; + case 7: //修改交易价格成功 + + break; + case 8: //买家发起退款 + + break; + case 9: //退款成功 + + break; + case 10: //退款关闭 + + break; + default: + } + + //------------------------------ + //中介担保处理业务完毕 + //------------------------------ + + System.out.println("trade_state = " + trade_state); + //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知 + resHandler.sendToCFT("success"); + } + }else{ + //错误时,返回结果未签名,记录retcode、retmsg看失败详情。 + System.out.println("查询验证签名失败或id验证失败"+",retcode:" + queryRes.getParameter("retcode")); + } + } else { + System.out.println("后台调用通信失败"); + System.out.println(httpClient.getResponseCode()); + System.out.println(httpClient.getErrInfo()); + //有可能因为网络原因,请求已经处理,但未收到应答。 + } + }else{ + System.out.println("通知签名验证失败"); + } + return null; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Consumetable getConsumetable() { + return consumetable; + } + + public void setConsumetable(Consumetable consumetable) { + this.consumetable = consumetable; + } + + public ProductCart getProductCart() { + return productCart; + } + + public void setProductCart(ProductCart productCart) { + this.productCart = productCart; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public Consumerdetail getConsumerdetail() { + return consumerdetail; + } + + public void setConsumerdetail(Consumerdetail consumerdetail) { + this.consumerdetail = consumerdetail; + } + + public List getProductCartList() { + return productCartList; + } + + public void setProductCartList(List productCartList) { + this.productCartList = productCartList; + } + + public String getPaymentStatus() { + return paymentStatus; + } + + public void setPaymentStatus(String paymentStatus) { + this.paymentStatus = paymentStatus; + } + + public String getCurrTime() { + return currTime; + } + + public void setCurrTime(String currTime) { + this.currTime = currTime; + } + + public String getStrTime() { + return strTime; + } + + public void setStrTime(String strTime) { + this.strTime = strTime; + } + + public String getStrRandom() { + return strRandom; + } + + public void setStrRandom(String strRandom) { + this.strRandom = strRandom; + } + + public String getStrReq() { + return strReq; + } + + public void setStrReq(String strReq) { + this.strReq = strReq; + } + + public String getOut_trade_no() { + return out_trade_no; + } + + public void setOut_trade_no(String out_trade_no) { + this.out_trade_no = out_trade_no; + } + + public Integer getMoneyCount() { + return moneyCount; + } + + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + + public String getProductBody() { + return productBody; + } + + public void setProductBody(String productBody) { + this.productBody = productBody; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getBank_type() { + return bank_type; + } + + public void setBank_type(String bank_type) { + this.bank_type = bank_type; + } + + public String getHidUseBalance() { + return hidUseBalance; + } + + public void setHidUseBalance(String hidUseBalance) { + this.hidUseBalance = hidUseBalance; + } + + public String getRequestUrl() { + return requestUrl; + } + public void setRequestUrl(String requestUrl) { + this.requestUrl = requestUrl; + } + + +} diff --git a/src/main/java/me/mofun/action/BuyCartAction.java b/src/main/java/me/mofun/action/BuyCartAction.java new file mode 100644 index 0000000..893dfed --- /dev/null +++ b/src/main/java/me/mofun/action/BuyCartAction.java @@ -0,0 +1,29 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.Product; +import me.mofun.service.ProductService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@SuppressWarnings("unused") +@Component("BuyCartAction") +public class BuyCartAction extends ActionSupport { + + private static final long serialVersionUID = -4695580454502546044L; + + private String id; + + @Autowired + private ProductService productService; + private Product product; + + + public String index(){ + + product = productService.findById(id); + + return "index"; + } + +} diff --git a/src/main/java/me/mofun/action/CartPayAction.java b/src/main/java/me/mofun/action/CartPayAction.java new file mode 100644 index 0000000..6ff2d85 --- /dev/null +++ b/src/main/java/me/mofun/action/CartPayAction.java @@ -0,0 +1,908 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.tenpay.util.TenpayUtil; +import me.mofun.util.*; +import me.mofun.util.NewLotteryUtil; +import me.mofun.yeepay.config.PaymentForOnlineService; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.util.*; + +public class CartPayAction extends ActionSupport { + + private static final long serialVersionUID = 2516892117051908997L; + + @Autowired + @Qualifier("spellbuyproductService") + private SpellbuyproductService spellbuyproductService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private RandomnumberService randomnumberService; + @Autowired + private UserService userService; + @Autowired + private ConsumetableService consumetableService; + @Autowired + private ConsumerdetailService consumerdetailService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ProductService productService; + @Autowired + private NewLotteryUtil newLotteryUtil; + @Autowired + CommissionqueryService commissionqueryService; + @Autowired + LotteryproductutilService lotteryproductutilService; + @Autowired + CommissionpointsService commissionpointsService; + + RandomUtil randomUtil = new RandomUtil(); + + //---------------生成订单号 开始------------------------ + //当前时间 yyyyMMddHHmmss + private String currTime = TenpayUtil.getCurrTime(); + //8位日期 + private String strTime = currTime.substring(8, currTime.length()); + //四位随机数 + private String strRandom = TenpayUtil.buildRandom(4) + ""; + //10位序列号,可以自行调整。 + private String strReq = strTime + strRandom; + //订单号,此处用时间加随机数生成,商户根据自己情况调整,只要保持全局唯一就行 + private String out_trade_no = strReq; + private String paymentStatus; + + private Consumetable consumetable; + private Consumerdetail consumerdetail; + private List productCartList; + private List successCartList; + private ProductJSON productJSON; + private ProductCart productCart; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private Randomnumber randomnumber; + private Latestlottery latestlottery; + private Commissionquery commissionquery; + private Lotteryproductutil lotteryproductutil; + private Commissionpoints commissionpoints; + private Product product; + private String id; + private User user; + private String userId; + private Integer moneyCount; + private Integer userPayType; + private String integral; + private String hidUseBalance; + + private static String nodeAuthorizationURL = "https://www.yeepay.com/app-merchant-proxy/node"; + Random random = new Random(); + Calendar calendar = Calendar.getInstance(); + HttpServletRequest request = null; + HttpServletResponse response = null; + + public String index() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + productCartList = new ArrayList(); + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("buyProduct")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + } + } + if(cookie.getName().equals("buyProduct")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + Integer moneyCount = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i sParaTemp = new HashMap(); + sParaTemp.put("p0_Cmd", p0_Cmd); + sParaTemp.put("p1_MerId", p1_MerId); + sParaTemp.put("p2_Order", p2_Order); + sParaTemp.put("p3_Amt", p3_Amt); + sParaTemp.put("p4_Cur", p4_Cur); + sParaTemp.put("p5_Pid", p5_Pid); + sParaTemp.put("p6_Pcat", p6_Pcat); + sParaTemp.put("p7_Pdesc", p7_Pdesc); + sParaTemp.put("p8_Url", p8_Url); + sParaTemp.put("p9_SAF", p9_SAF); + sParaTemp.put("pa_MP", pa_MP); + sParaTemp.put("pd_FrpId", pd_FrpId); + sParaTemp.put("pr_NeedResponse", pr_NeedResponse); + sParaTemp.put("hmac", hmac); + + /** + * 业务开始 + */ + productCartList = new ArrayList(); + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); +// if(userId!=null && !userId.equals("")){ +// user = userService.findById(userId); +// } + } + if(cookie.getName().equals("buyProduct")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + if(StringUtil.isNotBlank(userId)){ + Integer buyConut = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;ialert(\"购物车中有商品已经满员,请选择下一期!\");window.location.href=\"/mycart/index.html\";","encoding:UTF-8"); + } + } + + //建立请求 + String sHtmlText = buildRequest(sParaTemp,nodeAuthorizationURL,"POST","确认"); + System.out.println(sHtmlText); + if(flag){ + Struts2Utils.render("text/html", sHtmlText,"encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + + return null; + } + + public String returnUrl() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + String keyValue = ApplicationListenerImpl.sysConfigureJson.getYeepayKey(); // 商家密钥 + String r0_Cmd = formatString(request.getParameter("r0_Cmd")); // 业务类型 + String p1_MerId = ApplicationListenerImpl.sysConfigureJson.getYeepayPartner(); // 商户编号 + String r1_Code = formatString(request.getParameter("r1_Code"));// 支付结果 + String r2_TrxId = formatString(request.getParameter("r2_TrxId"));// 易宝支付交易流水号 + String r3_Amt = formatString(request.getParameter("r3_Amt"));// 支付金额 + String r4_Cur = formatString(request.getParameter("r4_Cur"));// 交易币种 + String r5_Pid = new String(formatString(request.getParameter("r5_Pid")).getBytes("iso-8859-1"),"gbk");// 商品名称 + String r6_Order = formatString(request.getParameter("r6_Order"));// 商户订单号 + String r7_Uid = formatString(request.getParameter("r7_Uid"));// 易宝支付会员ID + String integral = new String(formatString(request.getParameter("integral")).getBytes("iso-8859-1"),"gbk");// 商户扩展信息 + String r9_BType = formatString(request.getParameter("r9_BType"));// 交易结果返回类型 + String hmac = formatString(request.getParameter("hmac"));// 签名数据 + + boolean flag = false; + + boolean isOK = false; + // 校验返回数据包 + isOK = PaymentForOnlineService.verifyCallback(hmac,p1_MerId,r0_Cmd,r1_Code, + r2_TrxId,r3_Amt,r4_Cur,r5_Pid,r6_Order,r7_Uid,integral,r9_BType,keyValue); + if(isOK) { + //在接收到支付结果通知后,判断是否进行过业务逻辑处理,不要重复进行业务逻辑处理 + if(r1_Code.equals("1")) { + // 产品通用接口支付成功返回-浏览器重定向 + if(r9_BType.equals("1")) { + System.out.println("callback方式:产品通用接口支付成功返回-浏览器重定向"); + // 产品通用接口支付成功返回-服务器点对点通讯 + } else if(r9_BType.equals("2")) { + // 如果在发起交易请求时 设置使用应答机制时,必须应答以"success"开头的字符串,大小写不敏感 + System.out.println("SUCCESS"); + // 产品通用接口支付成功返回-电话支付返回 + } + // 下面页面输出是测试时观察结果使用 + System.out.println("
交易成功!
商家订单号:" + r6_Order + "
支付金额:" + r3_Amt + "
易宝支付交易流水号:" + r2_TrxId); + //即时到账处理业务开始 + //------------------------------ + try { + String key = MD5Util.encode(r2_TrxId); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + MemCachedClientHelp.getIMemcachedCache().put(key, "y",new Date(12*60*60*1000)); + productCartList = new ArrayList(); + successCartList = new ArrayList(); + try { + consumetable = consumetableService.findByOutTradeNo(r6_Order);//找到订单 + double money = Double.parseDouble(String.valueOf(r3_Amt));//充值的钱 + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId().equals(r2_TrxId)){ + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + } + if(cookie.getName().equals("buyProduct")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + //总购买钱数 + Integer moneyCount = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i0){ + if(StringUtil.isNotBlank(integral) && !integral.equals("0")){ + if(user.getBalance()>=(count-(Integer.parseInt(integral)/100))){ + Double temp = user.getBalance() - (count-(Integer.parseInt(integral)/100)); + user.setBalance(temp); +// userService.add(user); + + consumerdetail = new Consumerdetail(); + consumerdetail.setBuyCount(count); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setConsumetableId(r6_Order); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductTitle(productCart.getProductTitle()); + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + commissionquery = new Commissionquery(); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + }else{ + if(user.getBalance()>=count){ + Double temp = user.getBalance() - count; + user.setBalance(temp); + //userService.add(user); + consumerdetail = new Consumerdetail(); + consumerdetail.setBuyCount(count); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setConsumetableId(r6_Order); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductTitle(productCart.getProductTitle()); + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + commissionquery = new Commissionquery(); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + + if(StringUtil.isNotBlank(integral) && !integral.equals("0")){ + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + } + + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count+"元获得福分"); + commissionpoints.setPay("+"+((count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())-(Integer.parseInt(integral)/100))); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points+((count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())-(Integer.parseInt(integral)/100))); + + Integer experience = user.getExperience(); + experience += (count*10); + user.setExperience(experience); + userService.add(user); + + productJSON = new ProductJSON(); + productJSON.setBuyDate(DateUtil.DateTimeToStr(new Date())); + productJSON.setProductId(productCart.getProductId()); + productJSON.setProductName(productCart.getProductName()); + productJSON.setProductTitle(productCart.getProductTitle()); + productJSON.setBuyCount(count); + successCartList.add(productJSON); + } + } catch (Exception e) { + e.printStackTrace(); + flag = false; + } + } + } + if(flag){ + /** + * 清空购物车 + */ + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("buyProduct",null); + cookie.setMaxAge(0); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + System.out.println("即时到帐付款成功"); + paymentStatus = "success"; + + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + } else { + paymentStatus = "error"; + System.out.println("交易签名被篡改!"); + } + return "success"; + } + + public String notifyUrl() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String keyValue = ApplicationListenerImpl.sysConfigureJson.getYeepayKey(); // 商家密钥 + String r0_Cmd = formatString(request.getParameter("r0_Cmd")); // 业务类型 + String p1_MerId = ApplicationListenerImpl.sysConfigureJson.getYeepayPartner(); // 商户编号 + String r1_Code = formatString(request.getParameter("r1_Code"));// 支付结果 + String r2_TrxId = formatString(request.getParameter("r2_TrxId"));// 易宝支付交易流水号 + String r3_Amt = formatString(request.getParameter("r3_Amt"));// 支付金额 + String r4_Cur = formatString(request.getParameter("r4_Cur"));// 交易币种 + String r5_Pid = new String(formatString(request.getParameter("r5_Pid")).getBytes("iso-8859-1"),"gbk");// 商品名称 + String r6_Order = formatString(request.getParameter("r6_Order"));// 商户订单号 + String r7_Uid = formatString(request.getParameter("r7_Uid"));// 易宝支付会员ID + String integral = new String(formatString(request.getParameter("r8_MP")).getBytes("iso-8859-1"),"gbk");// 商户扩展信息 + String r9_BType = formatString(request.getParameter("r9_BType"));// 交易结果返回类型 + String hmac = formatString(request.getParameter("hmac"));// 签名数据 + + //把请求参数打包成数组 + Map sParaTemp = new HashMap(); + sParaTemp.put("r0_Cmd", r0_Cmd); + sParaTemp.put("p1_MerId", p1_MerId); + sParaTemp.put("r1_Code", r1_Code); + sParaTemp.put("r2_TrxId", r2_TrxId); + sParaTemp.put("r3_Amt", r3_Amt); + sParaTemp.put("r4_Cur", r4_Cur); + sParaTemp.put("r5_Pid", r5_Pid); + sParaTemp.put("r6_Order", r6_Order); + sParaTemp.put("r7_Uid", r7_Uid); + sParaTemp.put("integral", integral); + sParaTemp.put("r9_BType", r9_BType); + sParaTemp.put("hmac", hmac); + + + boolean isOK = false; + // 校验返回数据包 + isOK = PaymentForOnlineService.verifyCallback(hmac,p1_MerId,r0_Cmd,r1_Code, + r2_TrxId,r3_Amt,r4_Cur,r5_Pid,r6_Order,r7_Uid,integral,r9_BType,keyValue); + if(isOK) { + //在接收到支付结果通知后,判断是否进行过业务逻辑处理,不要重复进行业务逻辑处理 + if(r1_Code.equals("1")) { + // 产品通用接口支付成功返回-浏览器重定向 + if(r9_BType.equals("1")) { + System.out.println("callback方式:产品通用接口支付成功返回-浏览器重定向"); + // 产品通用接口支付成功返回-服务器点对点通讯 + } else if(r9_BType.equals("2")) { + // 如果在发起交易请求时 设置使用应答机制时,必须应答以"success"开头的字符串,大小写不敏感 + System.out.println("SUCCESS"); + Struts2Utils.render("text/html", "success","encoding:UTF-8"); + // 产品通用接口支付成功返回-电话支付返回 + } + // 下面页面输出是测试时观察结果使用 + System.out.println("
交易成功!
商家订单号:" + r6_Order + "
支付金额:" + r3_Amt + "
易宝支付交易流水号:" + r2_TrxId); + //即时到账处理业务开始 + //------------------------------ + + try { + consumetable = consumetableService.findByOutTradeNo(r6_Order); + double money = Double.parseDouble(String.valueOf(r3_Amt)); + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId()==null){ + consumetable.setTransactionId(r2_TrxId); + consumetableService.add(consumetable); + + user = userService.findById(String.valueOf(consumetable.getUserId())); + user.setBalance(money+user.getBalance()); + userService.add(user); + flag = true; + } + } catch (Exception e) { + flag = false; + e.printStackTrace(); + } + String sHtmlText = buildRequest(sParaTemp,ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/yeepay/returnUrl.html","POST","确认"); + System.out.println(sHtmlText); + Struts2Utils.render("text/html", sHtmlText,"encoding:UTF-8"); + System.out.println("success"); //请不要修改或删除 + Struts2Utils.render("text/html", "success","encoding:UTF-8"); + + } + } else { + System.out.println("交易签名被篡改!"); + } + //建立请求 + return null; + } + + /** + * 建立请求,以表单HTML形式构造(默认) + * @param sParaTemp 请求参数数组 + * @param strMethod 提交方式。两个值可选:post、get + * @param strButtonName 确认按钮显示文字 + * @return 提交表单HTML文本 + */ + public static String buildRequest(Map sParaTemp,String postUrl, String strMethod, String strButtonName) { + //待请求参数数组 + Map sPara = sParaTemp; + List keys = new ArrayList(sPara.keySet()); + + StringBuffer sbHtml = new StringBuffer(); + + sbHtml.append("
"); + for (int i = 0; i < keys.size(); i++) { + String name = (String) keys.get(i); + String value = (String) sPara.get(name); + sbHtml.append(""); + } + + //submit按钮控件请不要含有name属性 + sbHtml.append("
"); + sbHtml.append(""); + + return sbHtml.toString(); + } + + public NewLotteryUtil getNewLotteryUtil() { + return newLotteryUtil; + } + + public void setNewLotteryUtil(NewLotteryUtil newLotteryUtil) { + this.newLotteryUtil = newLotteryUtil; + } + + public String getCurrTime() { + return currTime; + } + + public void setCurrTime(String currTime) { + this.currTime = currTime; + } + + public String getStrTime() { + return strTime; + } + + public void setStrTime(String strTime) { + this.strTime = strTime; + } + + public String getStrRandom() { + return strRandom; + } + + public void setStrRandom(String strRandom) { + this.strRandom = strRandom; + } + + public String getStrReq() { + return strReq; + } + + public void setStrReq(String strReq) { + this.strReq = strReq; + } + + public String getOut_trade_no() { + return out_trade_no; + } + + public void setOut_trade_no(String out_trade_no) { + this.out_trade_no = out_trade_no; + } + + public Consumetable getConsumetable() { + return consumetable; + } + + public void setConsumetable(Consumetable consumetable) { + this.consumetable = consumetable; + } + + public Consumerdetail getConsumerdetail() { + return consumerdetail; + } + + public void setConsumerdetail(Consumerdetail consumerdetail) { + this.consumerdetail = consumerdetail; + } + + public List getProductCartList() { + return productCartList; + } + + public void setProductCartList(List productCartList) { + this.productCartList = productCartList; + } + + public List getSuccessCartList() { + return successCartList; + } + + public void setSuccessCartList(List successCartList) { + this.successCartList = successCartList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public ProductCart getProductCart() { + return productCart; + } + + public void setProductCart(ProductCart productCart) { + this.productCart = productCart; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public Commissionquery getCommissionquery() { + return commissionquery; + } + + public void setCommissionquery(Commissionquery commissionquery) { + this.commissionquery = commissionquery; + } + + public Lotteryproductutil getLotteryproductutil() { + return lotteryproductutil; + } + + public void setLotteryproductutil(Lotteryproductutil lotteryproductutil) { + this.lotteryproductutil = lotteryproductutil; + } + + public Commissionpoints getCommissionpoints() { + return commissionpoints; + } + + public void setCommissionpoints(Commissionpoints commissionpoints) { + this.commissionpoints = commissionpoints; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Integer getMoneyCount() { + return moneyCount; + } + + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + + public Integer getUserPayType() { + return userPayType; + } + + public void setUserPayType(Integer userPayType) { + this.userPayType = userPayType; + } + + public String getIntegral() { + return integral; + } + + public void setIntegral(String integral) { + this.integral = integral; + } + + public String getHidUseBalance() { + return hidUseBalance; + } + + public void setHidUseBalance(String hidUseBalance) { + this.hidUseBalance = hidUseBalance; + } + + public String getPaymentStatus() { + return paymentStatus; + } + + public void setPaymentStatus(String paymentStatus) { + this.paymentStatus = paymentStatus; + } + +} diff --git a/src/main/java/me/mofun/action/ConsumeDetailAction.java b/src/main/java/me/mofun/action/ConsumeDetailAction.java new file mode 100644 index 0000000..40fc1a8 --- /dev/null +++ b/src/main/java/me/mofun/action/ConsumeDetailAction.java @@ -0,0 +1,141 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Consumerdetail; +import me.mofun.service.ConsumerdetailService; +import me.mofun.util.Struts2Utils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +@SuppressWarnings("unused") +@Component("ConsumeDetailAction") +public class ConsumeDetailAction extends ActionSupport { + + private static final long serialVersionUID = 3910394002303639758L; + + @Autowired + private ConsumerdetailService consumerdetailService; + + private String id; + private String userId; + private int pageNo; + private int pageSize = 10; + private int pageCount; + private int resultCount; + private List consumerdetailList; + + public String index(){ + HttpServletRequest request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + resultCount = consumerdetailService.userByConsumetableDetailByCount(id); + return "ConsumeDetail"; + } + } + } + } + return "login_index"; + } + + /** + * 消费记录-查看详情分页 + * @return + */ + public String ConsumeDetailAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = consumerdetailService.userByConsumetableDetail(id, pageNo, pageSize); + List dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * Count + */ + public void ConsumeDetailAjaxPageByCount(){ + resultCount = consumerdetailService.userByConsumetableDetailByCount(id); + Struts2Utils.renderText(resultCount+""); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public List getConsumerdetailList() { + return consumerdetailList; + } + + public void setConsumerdetailList(List consumerdetailList) { + this.consumerdetailList = consumerdetailList; + } + + + public String getUserId() { + return userId; + } + + + public void setUserId(String userId) { + this.userId = userId; + } + + + public int getPageNo() { + return pageNo; + } + + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + + public int getPageSize() { + return pageSize; + } + + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + + public int getPageCount() { + return pageCount; + } + + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + + public int getResultCount() { + return resultCount; + } + + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + +} diff --git a/src/main/java/me/mofun/action/DDNSAction.java b/src/main/java/me/mofun/action/DDNSAction.java new file mode 100644 index 0000000..2bf44e6 --- /dev/null +++ b/src/main/java/me/mofun/action/DDNSAction.java @@ -0,0 +1,2651 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import com.taobao.api.internal.util.StringUtils; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.*; +import net.sf.json.JSONObject; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.log4j.Logger; +import org.apache.struts2.ServletActionContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +@SuppressWarnings("unused") +@Component("DDNSAction") +public class DDNSAction extends ActionSupport { + private static final long serialVersionUID = 6146740235643445087L; + + @Autowired + private UserService userService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ShareService shareService; + @Autowired + private ConsumetableService consumetableService; + @Autowired + private NewsService newsService; + @Autowired + private RegionService regionService; + @Autowired + private CommissionqueryService commissionqueryService; + @Autowired + private CommissionpointsService commissionpointsService; + @Autowired + private ApplymentionService applymentionService; + @Autowired + private CardpasswordService cardpasswordService; + @Autowired + private OrderdetailService orderdetailService; + @Autowired + private DDNSGnudipUserService ddnsGnudipUserService; + + private String forward; + private List productList; + private List newDateList; + private ProductJSON productJSON; + private BuyHistoryJSON buyHistoryJSON; + private ShareJSON shareJSON; + private List buyHistoryJSONList; + private List randomNumberJSONList; + private RandomNumberJSON randomNumberJSON; + private List shareJSONList; + private List userbyaddressList; + private List newsList; + private List sProvinceList; + private List sCityList; + private List sDistrictList; + private List userList; + private List commissionqueryList; + private List commissionpointsList; + private List applymentionList; + private List commissionqueryJSONList; + private List orderdetailList; + private Orderdetail orderdetail; + private OrderDetailAddress orderDetailAddress; + private CommissionqueryJSON commissionqueryJSON; + private Applymention applymention; + private Commissionquery commissionquery; + private Commissionpoints commissionpoints; + private Userbyaddress userbyaddress; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private Randomnumber randomnumber; + private Latestlottery latestlottery; + private Shareinfo shareinfo; + private User user; + private String userJSON; + private String ddnsJSON; + private String userId; + private String id; + private int pageNo; + private int pageSize = 12; + private int pageCount; + private int resultCount; + private String startDate; + private String endDate; + private String selectTime; + private File myFile; + private String myFileFileName; + private String myFileContentType; + private String imageFileName; + private static final int BUFFER_SIZE = 100 * 1024 ; + private int x1; + private int y1; + private int w; + private int h; + private String hidPicUrl; + private String userName; + + HttpServletRequest request = null; + HttpServletResponse response = null; + static HTMLFilter htmlFilter = new HTMLFilter(); + + Logger logger = Logger.getLogger(this.getClass()); + + //文件上传 + private static void copy(File src, File dst) { + try { + InputStream in = null ; + OutputStream out = null ; + try { + in = new BufferedInputStream( new FileInputStream(src), BUFFER_SIZE); + out = new BufferedOutputStream( new FileOutputStream(dst), BUFFER_SIZE); + byte [] buffer = new byte [BUFFER_SIZE]; + while (in.read(buffer) > 0 ) { + out.write(buffer); + } + } finally { + if ( null != in) { + in.close(); + } + if ( null != out) { + out.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String index(){ + if(StringUtil.isNotBlank(forward)){ + forward = htmlFilter.filter(forward); + } + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + /** + * 即将揭晓商品 + */ + Pagination datePage = spellbuyproductService.upcomingAnnounced(pageNo, 5); + List dataList = (List) datePage.getList(); + productList = new ArrayList(); + for (int j = 0; j < dataList.size(); j++) { + productJSON = new ProductJSON(); + product = (Product) dataList.get(j)[0]; + spellbuyproduct = (Spellbuyproduct) dataList.get(j)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSON.setProductTitle(product.getProductTitle()); + productList.add(productJSON); + } + +// /** +// * 最新上架 +// */ +// Pagination datePage2 = spellbuyrecordService.nowUpProducts(pageNo, 5); +// List dataList2 = (List) datePage2.getList(); +// newDateList = new ArrayList(); +// for (int j = 0; j < dataList2.size(); j++) { +// productJSON = new ProductJSON(); +// product = (Product) dataList2.get(j)[0]; +// spellbuyproduct = (Spellbuyproduct) dataList2.get(j)[1]; +// productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); +// productJSON.setHeadImage(product.getHeadImage()); +// productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); +// productJSON.setProductName(product.getProductName()); +// productJSON.setProductPrice(product.getProductPrice()); +// productJSON.setProductTitle(product.getProductTitle()); +// newDateList.add(productJSON); +// } + + /** + * 新闻 + */ + newsList = newsService.indexNews(1,3); + return "index"; + } + } + } + } + return "login_index"; + } + + /** + * 拍购记录 + * @return + */ + public String UserBuyList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + resultCount = spellbuyrecordService.buyHistoryByUserByCount(userId,startDate,endDate); + return "UserBuyList"; + } + } + } + } + return "login_index"; + } + + /** + * 选择日期查询得到拍购记录resultCount 总数 + */ + public void getuserBuyListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = spellbuyrecordService.buyHistoryByUserByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 拍购记录ajax分页请求 + * @return + */ + public String userBuyListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = spellbuyrecordService.buyHistoryByUser(userId,startDate,endDate, pageNo, 5); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + + for (int j = 0; j < dataList.size(); j++) { + try { + buyHistoryJSON = dataList.get(j); + if(buyHistoryJSON.getBuyStatus()==1){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(buyHistoryJSON.getProductId()).get(0); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUser(userer); + buyHistoryJSON.setWinUserId(latestlottery.getUserId()); + } + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 查看商品详情 + * @return + */ + public String UserBuyDetail(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + buyHistoryJSON = (BuyHistoryJSON) spellbuyrecordService.getBuyHistoryByDetail(id,userId).get(0); + if(buyHistoryJSON.getBuyStatus()==1){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(buyHistoryJSON.getProductId()).get(0); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUser(userer); + buyHistoryJSON.setWinUserId(latestlottery.getUserId()); + } + resultCount = spellbuyrecordService.getRandomNumberListPageByCount(id,userId); + return "UserBuyDetail"; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "login_index"; + } + + /** + * 取得某条购买记录的拍购码(list 页) + */ + public void getRandomNumberList(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + List dataList = spellbuyrecordService.getRandomNumberList(id,userId); + randomNumberJSONList = new ArrayList(); + String numbers = ""; + for (Randomnumber randomnumber : dataList) { + String [] randoms = randomnumber.getRandomNumber().split(","); + for (String string : randoms) { + numbers += "
  • " +string+"
  • "; + } + } + Struts2Utils.renderText(numbers); + } + + /** + * 取得某条购买记录的拍购码(详细页面) + */ + public void getRandomNumberListPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = spellbuyrecordService.getRandomNumberListPage(id,userId, pageNo, 50); + List dataList = (List) datePage.getList(); + randomNumberJSONList = new ArrayList(); + for (Randomnumber randomnumber : dataList) { + try { + randomNumberJSON = new RandomNumberJSON(); + String [] randoms = randomnumber.getRandomNumber().split(","); + String numbers = ""; + for (String string : randoms) { + numbers += "" +string+""; + } + randomNumberJSON.setRandomNumbers(numbers); + randomNumberJSON.setBuyCount(String.valueOf(randoms.length)); + randomNumberJSON.setBuyDate(randomnumber.getBuyDate()); + randomNumberJSONList.add(randomNumberJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.renderJson(randomNumberJSONList); + } + + /** + * 获得的商品 + * @return + */ + public String OrderList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = latestlotteryService.getProductByUserByCount(userId,startDate,endDate); + return "OrderList"; + } + } + } + } + return "login_index"; + } + + /** + * 获得的商品AJAX分页 + * @return + */ + public String OrderListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = latestlotteryService.getProductByUser(userId,startDate,endDate, pageNo, 5); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + for (int j = 0; j < dataList.size(); j++) { + try { + buyHistoryJSON = new BuyHistoryJSON(); + latestlottery = dataList.get(j); + buyHistoryJSON.setProductName(latestlottery.getProductName()); + buyHistoryJSON.setProductTitle(latestlottery.getProductTitle()); + buyHistoryJSON.setProductImg(latestlottery.getProductImg()); + buyHistoryJSON.setProductId(latestlottery.getSpellbuyProductId()); + buyHistoryJSON.setProductPrice(latestlottery.getProductPrice()); + buyHistoryJSON.setProductPeriod(latestlottery.getProductPeriod()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setBuyStatus(latestlottery.getStatus()); + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 选择日期查询得到获得的商品resultCount 总数 + */ + public void OrderListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = latestlotteryService.getProductByUserByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 获取的商品详情 + * @return + */ + public String OrderDetail(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + latestlottery = latestlotteryService.findById(id); + if(latestlottery.getStatus()==1){ + userbyaddressList = userService.getUserbyaddress(userId); + sProvinceList = regionService.getProvinceList(); + }else{ + orderdetailList = latestlotteryService.orderDetailListById(id); + orderDetailAddress = latestlotteryService.orderDetailAddressFindByOrderDetailId(id); + } + return "OrderDetail"; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "login_index"; + } + + /** + * 获取的商品详情-确认收货地址 + * @return + */ + public void OrderDetailAddAddress(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + JSONObject object = JSONObject.fromObject(userJSON); + String orderRemarks = object.getString("orderRemarks"); + String postDate = object.getString("postDate"); + String hidOrderNO = object.getString("hidOrderNO"); + id = object.getString("id"); + userbyaddress = userService.findAddressById(Integer.parseInt(id)); + orderDetailAddress = new OrderDetailAddress(); + orderDetailAddress.setAddress(userbyaddress.getProvince()+" "+userbyaddress.getCity()+" "+userbyaddress.getDistrict()+" "+userbyaddress.getAddress()); + orderDetailAddress.setConsignee(userbyaddress.getConsignee()); + orderDetailAddress.setOrderRemarks(orderRemarks);//订单备注 + orderDetailAddress.setPostDate(postDate);//配送时间 + orderDetailAddress.setPhone(userbyaddress.getPhone()); + orderDetailAddress.setOrderDetailId(Integer.parseInt(hidOrderNO)); + latestlotteryService.addOrderDetailAddress(orderDetailAddress); + orderdetail = new Orderdetail(); + orderdetail.setDate(DateUtil.DateTimeToStr(new Date())); + orderdetail.setDetailText("会员已确认配送地址信息,等待商城发货"); + orderdetail.setOrderDetailId(Integer.parseInt(hidOrderNO)); + orderdetail.setUserName("会员本人"); + orderdetailService.add(orderdetail); + latestlottery = latestlotteryService.findById(hidOrderNO); + latestlottery.setStatus(2); + latestlotteryService.add(latestlottery); + Struts2Utils.renderText("success"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + /** + * 获取的商品详情-确认收到货物 + * @return + */ + public void confirmOrderDetail(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + latestlottery = latestlotteryService.findById(id); + latestlottery.setStatus(4); + latestlottery.setShareStatus(-1); + latestlotteryService.add(latestlottery); + orderdetail = new Orderdetail(); + orderdetail.setDate(DateUtil.DateTimeToStr(new Date())); + orderdetail.setDetailText("会员已确认收到商品。"); + orderdetail.setOrderDetailId(latestlottery.getSpellbuyProductId()); + orderdetail.setUserName("会员本人"); + orderdetailService.add(orderdetail); + Struts2Utils.renderText("success"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + public String PostSingleAdd(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + + return "PostSingleAdd"; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "login_index"; + } + + /** + * 我的晒单 + * @return + */ + public String PostSingleList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); +// Pagination datePage = shareService.shareByUser(userId,startDate,endDate, pageNo, 5); +// resultCount = datePage.getResultCount(); + return "PostSingleList"; + } + } + } + } + return "login_index"; + } + + /** + * 我的晒单分页AJAX + * @return + */ + public String PostSingleListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = shareService.shareByUser(userId,startDate,endDate, pageNo, 5); + List pageList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + for (int j = 0; j < pageList.size(); j++) { + try { + buyHistoryJSON = new BuyHistoryJSON(); + latestlottery = pageList.get(j); + buyHistoryJSON.setProductName(latestlottery.getProductName()); + buyHistoryJSON.setProductTitle(latestlottery.getProductTitle()); + buyHistoryJSON.setProductImg(latestlottery.getProductImg()); + buyHistoryJSON.setProductId(latestlottery.getProductId()); + buyHistoryJSON.setProductPeriod(latestlottery.getProductPeriod()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setBuyStatus(latestlottery.getShareStatus()); + buyHistoryJSON.setWinUserId(latestlottery.getShareId()); + buyHistoryJSON.setHistoryId(latestlottery.getId()); + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 选择日期查询得到我的晒单resultCount 总数 + */ + public void PostSingleListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = shareService.shareByUser(userId,startDate,endDate, pageNo, 5); + resultCount = datePage.getResultCount(); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 邀请好友 + * @return + */ + public String InvitedList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = userService.getInvitedListByCount(userId); + userList = userService.getInvitedListByData(userId); + for (User user : userList) { + if(user.getExperience()>0){ + w++; + h+=50; + } + } + return "InvitedList"; + } + } + } + } + return "login_index"; + } + + /** + * 邀请好友分页AJAX + * @return + */ + public String InvitedListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = userService.getInvitedList(userId, pageNo, pageSize); + userList = (List) datePage.getList(); + for (User user : userList) { + user.setUserName(UserNameUtil.userName(user)); + } + Struts2Utils.renderJson(userList); + return null; + } + + /** + * 佣金明细 + * @return + */ + public String CommissionQuery(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = commissionqueryService.getCommissionQueryListByCount(userId, startDate, endDate); + return "CommissionQuery"; + } + } + } + } + return "login_index"; + } + + /** + * 佣金明细 AJAX + * @return + */ + public String CommissionQueryAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = commissionqueryService.getCommissionQueryList(userId, startDate, endDate, pageNo, pageSize); + List dateList = (List) datePage.getList(); + if(dateList.size()>0){ + commissionqueryJSONList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + commissionqueryJSON = new CommissionqueryJSON(); + user = (User) dateList.get(i)[0]; + commissionquery = (Commissionquery) dateList.get(i)[1]; + commissionqueryJSON.setBuyMoney(commissionquery.getBuyMoney()); + commissionqueryJSON.setCommission(commissionquery.getCommission()); + commissionqueryJSON.setDate(commissionquery.getDate()); + commissionqueryJSON.setDescription(commissionquery.getDescription()); + commissionqueryJSON.setUserId(String.valueOf(user.getUserId())); + commissionqueryJSON.setUserName(UserNameUtil.userName(user)); + commissionqueryJSONList.add(commissionqueryJSON); + } + } + Struts2Utils.renderJson(commissionqueryJSONList); + return null; + } + + /** + * 佣金明细 AJAX ByCount + */ + public void getCommissionQueryAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = commissionqueryService.getCommissionQueryListByCount(userId, startDate, endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 我的福分 + * @return + */ + public String MemberPoints(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = commissionpointsService.getCommissionPointsListByCount(userId, startDate, endDate); + return "CommissionPoints"; + } + } + } + } + return "login_index"; + } + + /** + * 福分明细 AJAX + * @return + */ + public String CommissionPointsAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = commissionpointsService.CommissionPoints(userId, startDate, endDate, pageNo, pageSize); + commissionpointsList = (List) datePage.getList(); + Struts2Utils.renderJson(commissionpointsList); + return null; + } + + /** + * 提现申请 + * @return + */ + public String ApplyMention(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "ApplyMention"; + } + } + } + } + return "login_index"; + } + + /** + * 提现申请 ADD + */ + public void ApplyMentionAdd(){ + try { + JSONObject object = JSONObject.fromObject(userJSON); + userId = object.getString("userId"); + user = userService.findById(userId); + double money = Double.parseDouble(object.getString("money")); + double commissionBalance = user.getCommissionBalance(); + double commissionMention = user.getCommissionMention(); + if(commissionBalance dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * 提现记录 AJAX ByCount + */ + public void getMentionListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = applymentionService.getApplymentionListByCount(userId, startDate, endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 网银充值 + * @return + */ + public String UserRecharge(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "UserRecharge"; + } + } + } + } + return "login_index"; + } + + /** + * 卡密充值 + * @return + */ + public String userCardRecharge(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "userCardRecharge"; + } + } + } + } + return "login_index"; + } + + public void doCardRecharge(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + try { + String randomNo = id.substring(0,32); + String cardPwd = id.substring(32,id.length()); + Cardpassword cardpassword = cardpasswordService.doCardRecharge(randomNo, cardPwd); + if(cardpassword!=null){ + Double temp = user.getBalance(); + cardpasswordService.deleteByID(cardpassword.getId()); + user.setBalance(temp+cardpassword.getMoney()); + userService.add(user); + Consumetable consumetable = new Consumetable(); + consumetable.setBuyCount(Integer.parseInt(new java.text.DecimalFormat("0").format(cardpassword.getMoney()))); + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + consumetable.setInterfaceType("卡密冲值"); + consumetable.setMoney(cardpassword.getMoney()); + consumetable.setOutTradeNo(""); + String s = UUID.randomUUID().toString().toUpperCase(); + s = s.substring(0,8)+s.substring(9,13)+s.substring(14,18)+s.substring(19,23)+s.substring(24); + consumetable.setTransactionId(s); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); + Struts2Utils.renderText("yes"); + }else{ + Struts2Utils.renderText("no"); + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("no"); + } + } + } + } + } + } + + /** + * 账户明细 + * @return + */ + public String UserBalance(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + return "UserBalance"; + } + } + } + } + return "login_index"; + } + + /** + * 消费记录 + * @return + */ + public String ConsumeList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = consumetableService.userByConsumetableByCount(userId,startDate,endDate); + return "ConsumeList"; + } + } + } + } + return "login_index"; + } + + /*** + * 消费记录分页 + * @return + */ + public String ConsumeListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = consumetableService.userByConsumetable(userId,startDate,endDate, pageNo, pageSize); + List dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * 选择日期查询得到消费记录resultCount 总数 + */ + public void ConsumeListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = consumetableService.userByConsumetableByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + + /** + * 充值记录 + * @return + */ + public String RechargeList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + return "RechargeList"; + } + } + } + } + return "login_index"; + } + + /*** + * 充值记录分页 + * @return + */ + public String ConsumeListByDeltaAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = consumetableService.userByConsumetableByDelta(userId,startDate,endDate, pageNo, pageSize); + List dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * 选择日期查询得到充值记录resultCount 总数 + */ + public void ConsumeListByDeltaAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 收货地址 + * @return + */ + public String Address(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "Address"; + } + } + } + } + return "login_index"; + } + + /** + * DDNS页面 + * @return + */ + public String setDDNS(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "setDDNS"; + } + } + } + } + return "login_index"; + } + + public void getDDNSList(){ + if(StringUtil.isNotBlank(userId)) + { + + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination gnudipUserPage = ddnsGnudipUserService.getDomain(userId, pageNo, pageSize); + List dataList = (List) gnudipUserPage.getList(); + Struts2Utils.renderJson(dataList); + } + } + + public void getAddressList(){ + userbyaddressList = userService.getUserbyaddress(userId); + Struts2Utils.renderJson(userbyaddressList); + } + + /** + * 添加新收新地址 + * @return + */ + public String addAddress(){ + try { + JSONObject object = JSONObject.fromObject(userJSON); + int userId = object.getInt("userId"); + userbyaddressList = userService.getUserbyaddress(userId+""); + if(userbyaddressList.size()<4){ + String province = object.getString("province"); + String city = object.getString("city"); + String district = object.getString("district"); + String address = object.getString("address"); + int zipCode = object.getInt("zipCode"); + String consignee = object.getString("consignee"); + String phone = object.getString("phone"); + userbyaddress = new Userbyaddress(); + userbyaddress.setAddress(address); + userbyaddress.setCity(city); + userbyaddress.setConsignee(consignee); + userbyaddress.setDistrict(district); + userbyaddress.setPhone(phone); + userbyaddress.setProvince(province); + userbyaddress.setStatus(1); + userbyaddress.setUserId(userId); + userbyaddress.setZipCode(zipCode); + userService.addAddress(userbyaddress); + if(userbyaddress.getId()!=null){ + userService.setDefaultAddress(String.valueOf(userId),userbyaddress.getId()); + } + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("sizeError"); + } + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + return null; + } + + public String isExist(){ + if(org.apache.commons.lang.StringUtils.isNotBlank(ddnsJSON)) + try { + JSONObject object = JSONObject.fromObject(ddnsJSON); + int userId = object.getInt("userId"); + String userName = object.getString("username"); + String password = object.getString("password"); + String domain = object.getString("domain"); + boolean isExist = false; + if(StringUtils.isEmpty(userName)||StringUtils.isEmpty(domain)) + isExist=true; + else + isExist = ddnsGnudipUserService.isExist(userName, domain); + if(!isExist) + { + /* + if(userbyaddressList.size()<4){ + String province = object.getString("province"); + String city = object.getString("city"); + String district = object.getString("district"); + String address = object.getString("address"); + int zipCode = object.getInt("zipCode"); + String consignee = object.getString("consignee"); + String phone = object.getString("phone"); + userbyaddress = new Userbyaddress(); + userbyaddress.setAddress(address); + userbyaddress.setCity(city); + userbyaddress.setConsignee(consignee); + userbyaddress.setDistrict(district); + userbyaddress.setPhone(phone); + userbyaddress.setProvince(province); + userbyaddress.setStatus(1); + userbyaddress.setUserId(userId); + userbyaddress.setZipCode(zipCode); + userService.addAddress(userbyaddress); + if(userbyaddress.getId()!=null){ + userService.setDefaultAddress(String.valueOf(userId),userbyaddress.getId()); + } + */ + + Struts2Utils.renderText("false"); + }else{ + Struts2Utils.renderText("true"); + } + } catch (Exception e) { + Struts2Utils.renderText("error"); + e.printStackTrace(); + } + return null; + } + + /** + * 添加一个动态域名DDNS + * @return + */ + public String addDDNS(){ + try { + JSONObject object = JSONObject.fromObject(ddnsJSON); + Integer userId = object.getInt("userId"); + String domain = object.getString("domain"); + String username = object.getString("username"); + String password = object.getString("password"); + + if(userId!=null&&StringUtil.isNotBlank(domain)&&StringUtil.isNotBlank(username)&&StringUtil.isNotBlank(password)){ + boolean isExist = ddnsGnudipUserService.isExist(username, domain); + if(!isExist) + { + DDNSGnudipUser u = new DDNSGnudipUser(); + u.setIpdzId(userId); + u.setDomain(domain); + u.setUsername(username); + u.setPassword(DigestUtils.md5Hex(password)); + + //非空字段默认值 + u.setLevel("USER"); + u.setCreatedate(new Timestamp(new Date().getTime())); + u.setCurrentip("0.0.0.0"); + u.setMxbackup("NO"); + u.setWildcard("NO"); + u.setAllowwild("NO"); + u.setAllowmx("NO"); + + ddnsGnudipUserService.add(u); + + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("userError"); + } + }else + Struts2Utils.renderText("dataError"); + + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + return null; + } + + /** + * 重设 DDNS 域名对应的用户密码 + * @return + */ + public String resetPassword(){ + try { + JSONObject object = JSONObject.fromObject(ddnsJSON); + Integer userId = object.getInt("userId"); + String domain = object.getString("domain"); + String username = object.getString("username"); + String oldPassword = object.getString("oldPassword"); + String newPassword = object.getString("newPassword"); + + if(userId!=null&&StringUtil.isNotBlank(domain)&&StringUtil.isNotBlank(username)&&StringUtil.isNotBlank(oldPassword)&&StringUtil.isNotBlank(newPassword)){ + DDNSGnudipUser u = ddnsGnudipUserService.getUser(username, oldPassword); + if(u!=null&&u.getIpdzId().intValue()==userId) + { + u.setPassword(DigestUtils.md5Hex(newPassword)); + + //非空字段默认值 + /* + u.setLevel("USER"); + u.setCreatedate(new Timestamp(new Date().getTime())); + u.setCurrentip("0.0.0.0"); + u.setMxbackup("NO"); + u.setWildcard("NO"); + u.setAllowwild("NO"); + u.setAllowmx("NO"); + */ + + ddnsGnudipUserService.add(u); //更新用户密码 + + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("userError"); + } + }else + Struts2Utils.renderText("dataError"); + + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + return null; + } + + public String delDDNS(){ + if(StringUtils.areNotEmpty(ddnsJSON)) + try { + String json=URLDecoder.decode(ddnsJSON, "UTF-8"); + JSONObject object = JSONObject.fromObject(ddnsJSON); + Integer id = object.getInt("id"); + Integer userId = object.getInt("ipdzId"); + +// String domain = object.getString("domain"); + String username = object.getString("username"); + String oldPassword = object.getString("password"); +// String newPassword = object.getString("newPassword"); + + if(userId!=null&&id!=null){ + DDNSGnudipUser u = ddnsGnudipUserService.getUser(username, oldPassword); + if(u!=null&&u.getIpdzId().intValue()==userId) + { + //非空字段默认值 + /* + u.setLevel("USER"); + u.setCreatedate(new Timestamp(new Date().getTime())); + u.setCurrentip("0.0.0.0"); + u.setMxbackup("NO"); + u.setWildcard("NO"); + u.setAllowwild("NO"); + u.setAllowmx("NO"); + */ + + ddnsGnudipUserService.delete(u.getId()); + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("userError"); + } + }else + Struts2Utils.renderText("dataError"); + + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + return null; + } + + + public String renewLogic(){ + if(org.apache.commons.lang.StringUtils.isNotBlank(ddnsJSON)){ + try { + JSONObject object = JSONObject.fromObject(ddnsJSON); + String userId = object.getString("userId"); + String domain= object.getString("domain"); + String userName = object.getString("username"); + String password = object.getString("password"); + int days = object.getInt("days"); + float money=(float)object.getDouble("money"); + DDNSGnudipUser gnduipUser = ddnsGnudipUserService.getDomain(userId, userName+"."+domain); + if(gnduipUser!=null){ + String msg = "domain="+userName+"."+domain+","+DateUtil.DateTimeToStr(DateUtil.timestamp2Date(gnduipUser.getEnddate()))+"+"+days+"天="+DateUtil.DateTimeToStr(DateUtil.addDate(gnduipUser.getEnddate(), days)); + gnduipUser.setEnddate(new Timestamp(DateUtil.addDate(gnduipUser.getEnddate(), days).getTime())); + ddnsGnudipUserService.add(gnduipUser); + logger.info(msg); + Struts2Utils.renderText("success"); + } + else + { + logger.info("domain="+userName+"."+domain+","+days+"天,userId="+userId+"没找到对应域名"); + Struts2Utils.renderText("null"); + } + } catch (Exception e) { + Struts2Utils.renderText("exception"); + e.printStackTrace(); + } + } + else + Struts2Utils.renderText("null"); + return null; + } + + + /** + * 设置默认收货地址 + */ + public void setDefaultAddress(){ + try { + userService.defaultAddress(userId,Integer.parseInt(id)); + userService.setDefaultAddress(String.valueOf(userId),Integer.parseInt(id)); + Struts2Utils.renderText("success"); + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + } + + /** + * 删除收货地址 + */ + public void delAddress(){ + try { + userService.delAddress(Integer.parseInt(id)); + Struts2Utils.renderText("success"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + + } + + /** + * 省 + */ + public void getProvinceList(){ + sProvinceList = regionService.getProvinceList(); + Struts2Utils.renderJson(sProvinceList); + } + + /** + * 市 + */ + public void getCityList(){ + sCityList = regionService.getCityListByProvinceId(id); + Struts2Utils.renderJson(sCityList); + } + + /** + * 区 + */ + public void getDistrictList(){ + sDistrictList = regionService.getDistrictListByCityId(id); + Struts2Utils.renderJson(sDistrictList); + } + + + /** + * 编辑个人资料 + * @return + */ + public String MemberModify(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "MemberModify"; + } + } + } + } + return "login_index"; + } + + + /** + * 修改用户资料 + */ + public void updateUser(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + if(user!=null){ + try { + JSONObject object = JSONObject.fromObject(userJSON); + if(user.getUserName()==null){ + Integer m = user.getCommissionPoints(); + m += ApplicationListenerImpl.sysConfigureJson.getUserData(); + user.setCommissionPoints(m); + } + user.setUserName(object.getString("userName")); + String mobilePhone = object.getString("mobilePhone"); + if(!mobilePhone.equals("undefined") && !mobilePhone.equals("")){ + user.setMobilePhone(mobilePhone); + } + String phone = object.getString("phone"); + if(!phone.equals("undefined") && !phone.equals("")){ + user.setPhone(phone); + } + String mail = object.getString("mail"); + if(!mail.equals("undefined") && !mail.equals("")){ + user.setMail(mail); + } + String qq = object.getString("qq"); + if(!qq.equals("undefined") && !qq.equals("")){ + user.setQq(qq); + } + String userSign = object.getString("userSign"); + if(!userSign.equals("undefined") && !userSign.equals("")){ + user.setSignature(userSign); + } + userService.add(user); + Struts2Utils.renderJson(user); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + }else{ + Struts2Utils.renderText("false"); + } + } + } + } + } + } + + /** + * 用户昵称是否存在 + */ + public void isUserNameExists(){ + User user = userService.isUserName(id,userId); + if(user==null) + Struts2Utils.renderText("true"); + else + Struts2Utils.renderText("false"); + } + + /** + * 修改头像 + * @return + */ + public String UserPhoto(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "UserPhoto"; + } + } + } + } + return "login_index"; + } + + /** + * 上传图像文件 + * @return + * @throws Exception + */ + public String updateFaceFile() throws Exception{ + try { + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + imageFileName = userId+"_" + new Date().getTime()+ myFileFileName; + String filePath = ServletActionContext.getServletContext().getRealPath("/uploadImages")+"/" + imageFileName; + File imageFile = new File(filePath); + if(myFile!=null){ + copy(myFile, imageFile); +// CutImages.equimultipleConvert(300, 300, imageFile, imageFile); + CutImages.scale2(filePath, filePath, 300, 300, true); + Struts2Utils.renderText("/uploadImages/"+imageFileName); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 上传图像 + * @throws IOException + */ + public void updateFace() throws IOException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + hidPicUrl = hidPicUrl.replace("/", "\\"); + hidPicUrl = hidPicUrl.substring(hidPicUrl.lastIndexOf("\\")+1, hidPicUrl.length()); + String fileName = ServletActionContext.getServletContext().getRealPath("uploadImages")+"/" + hidPicUrl; + String faceName = ServletActionContext.getServletContext().getRealPath("faceImages")+"/" + hidPicUrl; + try { + CutImages cutImages = new CutImages(x1,y1,w,h,fileName,faceName); + cutImages.cut(); + faceName = faceName.substring(faceName.lastIndexOf("ROOT")+4,faceName.length()).replace("\\", "/"); + user = userService.findById(userId); + user.setFaceImg(faceName); + userService.add(user); + Cookie cookie3 = new Cookie("face",URLEncoder.encode(user.getFaceImg(), "UTF-8")); + cookie3.setMaxAge(-1); + cookie3.setPath("/"); + cookie3.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie3); + Struts2Utils.renderText("success"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + } + + /** + * 修改密码 + * @return + */ + public String UpdatePassWord(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "UpdatePassWord"; + } + } + } + } + return "login_index"; + } + + /** + * 修改密码 + */ + public void updatePwd(){ + if(StringUtil.isNotBlank(userId)){ + try { + user = userService.findById(userId); + if(user!=null){ + if(!user.getUserPwd().equals(id)){ + Struts2Utils.renderText("pwdError"); + }else{ + user.setUserPwd(userJSON); + userService.add(user); + Struts2Utils.renderText("success"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + //lwgoby add + //用户是否已关注,用于 bottom.js 中的 ajax调用 /user/hasCollectGoods.action + /** + * 用户未登录时,无法进行关注,右侧工具条关注提示为空,需要登录。 + * 用户未登录时,固定返回10,用于在 bottom.js 显示右侧关注工具条时是否提示用户登录用。 + * 用户登录后,固定返回0,用于提示已登录,用户一点关注某一商品,则会将相关数据存于 数据库中,用户下次登录还可以看到自己曾经关注过的商品 + */ + public String hasCollectGoods(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + if(user!=null){ + Struts2Utils.renderText("0"); //成功登录的用户暂且固定输出0; + return null; + } + } + } + } + } + Struts2Utils.renderText("10"); //未登录的用户固定输出10 供 bottom.js 中做比较 + return null; + } + + /** + * @Author lwgboy + * 检查用户名是否已经注册 + * @return + */ + public String isCheckName(){ + boolean isExist = false; + User user = userService.userByName(userName); + if(user==null) + Struts2Utils.renderText("true"); + else + Struts2Utils.renderText("false"); + return null; + } + + /** + * 修改手机号页面 + * @return + */ + public String MobileChecking(){ + return "MobileChecking"; + } + + /** + * 验证手机号后返回,用于 mobilechecking.js 的 e() 调用ajax 时使用 + * @author lwgboy + * @return + */ + public String MobileReturn(){ + String userJSON=Struts2Utils.getParameter("userJSON"); + String id=Struts2Utils.getParameter("id"); + if(userJSON.matches("^1[0-9]{10}$")) + { + if(user==null) + user = getUserFromCookie(); + if(user!=null){ + user.setPhone(userJSON); + user.setMobileCheck("0"); //设定手机为已验证状态; + userService.add(user); //更新用户的手机号 + } + Struts2Utils.renderText("0"); + }else + Struts2Utils.renderText("-1"); + return null; + } + + /** + * 更改手机号成功后返回页面 + * @author lwgboy + * @return + */ + public String MobileReturnSuccess(){ + return "MobileReturnSuccess"; + } + + public User getUserFromCookie(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + } + break; + } + } + } + return user; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getForward() { + return forward; + } + + public void setForward(String forward) { + this.forward = forward; + } + + public List getProductList() { + return productList; + } + + public void setProductList(List productList) { + this.productList = productList; + } + + public List getNewDateList() { + return newDateList; + } + + public void setNewDateList(List newDateList) { + this.newDateList = newDateList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public BuyHistoryJSON getBuyHistoryJSON() { + return buyHistoryJSON; + } + + public void setBuyHistoryJSON(BuyHistoryJSON buyHistoryJSON) { + this.buyHistoryJSON = buyHistoryJSON; + } + + public List getBuyHistoryJSONList() { + return buyHistoryJSONList; + } + + public void setBuyHistoryJSONList(List buyHistoryJSONList) { + this.buyHistoryJSONList = buyHistoryJSONList; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public String getSelectTime() { + return selectTime; + } + + public void setSelectTime(String selectTime) { + this.selectTime = selectTime; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public Shareinfo getShareinfo() { + return shareinfo; + } + + public void setShareinfo(Shareinfo shareinfo) { + this.shareinfo = shareinfo; + } + + public ShareJSON getShareJSON() { + return shareJSON; + } + + public void setShareJSON(ShareJSON shareJSON) { + this.shareJSON = shareJSON; + } + + public List getShareJSONList() { + return shareJSONList; + } + + public void setShareJSONList(List shareJSONList) { + this.shareJSONList = shareJSONList; + } + + public List getUserbyaddressList() { + return userbyaddressList; + } + + public void setUserbyaddressList(List userbyaddressList) { + this.userbyaddressList = userbyaddressList; + } + + public Userbyaddress getUserbyaddress() { + return userbyaddress; + } + + public void setUserbyaddress(Userbyaddress userbyaddress) { + this.userbyaddress = userbyaddress; + } + + public String getUserJSON() { + return userJSON; + } + public String getDdnsJSON() { + return ddnsJSON; + } + + public List getRandomNumberJSONList() { + return randomNumberJSONList; + } + + public void setRandomNumberJSONList(List randomNumberJSONList) { + this.randomNumberJSONList = randomNumberJSONList; + } + + public RandomNumberJSON getRandomNumberJSON() { + return randomNumberJSON; + } + + public void setRandomNumberJSON(RandomNumberJSON randomNumberJSON) { + this.randomNumberJSON = randomNumberJSON; + } + + public void setUserJSON(String userJSON) { + this.userJSON = userJSON; + } + + + public void setDdnsJSON(String ddnsJSON) { + this.ddnsJSON = ddnsJSON; + } + + public File getMyFile() { + return myFile; + } + + public void setMyFile(File myFile) { + this.myFile = myFile; + } + + public String getMyFileFileName() { + return myFileFileName; + } + + public void setMyFileFileName(String myFileFileName) { + this.myFileFileName = myFileFileName; + } + + public String getMyFileContentType() { + return myFileContentType; + } + + public void setMyFileContentType(String myFileContentType) { + this.myFileContentType = myFileContentType; + } + + public String getImageFileName() { + return imageFileName; + } + + public void setImageFileName(String imageFileName) { + this.imageFileName = imageFileName; + } + + public int getX1() { + return x1; + } + + public void setX1(int x1) { + this.x1 = x1; + } + + public int getY1() { + return y1; + } + + public void setY1(int y1) { + this.y1 = y1; + } + + public String getHidPicUrl() { + return hidPicUrl; + } + + public void setHidPicUrl(String hidPicUrl) { + this.hidPicUrl = hidPicUrl; + } + + public int getW() { + return w; + } + + public void setW(int w) { + this.w = w; + } + + public int getH() { + return h; + } + + public void setH(int h) { + this.h = h; + } + + public List getNewsList() { + return newsList; + } + + public void setNewsList(List newsList) { + this.newsList = newsList; + } + + public List getSProvinceList() { + return sProvinceList; + } + + public void setSProvinceList(List provinceList) { + sProvinceList = provinceList; + } + + public List getSCityList() { + return sCityList; + } + + public void setSCityList(List cityList) { + sCityList = cityList; + } + + public List getSDistrictList() { + return sDistrictList; + } + + public void setSDistrictList(List districtList) { + sDistrictList = districtList; + } + + public List getUserList() { + return userList; + } + + public void setUserList(List userList) { + this.userList = userList; + } + + public List getCommissionqueryList() { + return commissionqueryList; + } + + public void setCommissionqueryList(List commissionqueryList) { + this.commissionqueryList = commissionqueryList; + } + + public List getApplymentionList() { + return applymentionList; + } + + public void setApplymentionList(List applymentionList) { + this.applymentionList = applymentionList; + } + + public Applymention getApplymention() { + return applymention; + } + + public void setApplymention(Applymention applymention) { + this.applymention = applymention; + } + + public Commissionquery getCommissionquery() { + return commissionquery; + } + + public void setCommissionquery(Commissionquery commissionquery) { + this.commissionquery = commissionquery; + } + + public List getCommissionqueryJSONList() { + return commissionqueryJSONList; + } + + public void setCommissionqueryJSONList( + List commissionqueryJSONList) { + this.commissionqueryJSONList = commissionqueryJSONList; + } + + public CommissionqueryJSON getCommissionqueryJSON() { + return commissionqueryJSON; + } + + public void setCommissionqueryJSON(CommissionqueryJSON commissionqueryJSON) { + this.commissionqueryJSON = commissionqueryJSON; + } + + public List getCommissionpointsList() { + return commissionpointsList; + } + + public void setCommissionpointsList(List commissionpointsList) { + this.commissionpointsList = commissionpointsList; + } + + public Commissionpoints getCommissionpoints() { + return commissionpoints; + } + + public void setCommissionpoints(Commissionpoints commissionpoints) { + this.commissionpoints = commissionpoints; + } + + public List getOrderdetailList() { + return orderdetailList; + } + + public void setOrderdetailList(List orderdetailList) { + this.orderdetailList = orderdetailList; + } + + public OrderDetailAddress getOrderdetailaddress() { + return orderDetailAddress; + } + + public void setOrderDetailAddress(OrderDetailAddress orderDetailAddress) { + this.orderDetailAddress = orderDetailAddress; + } + + public Orderdetail getOrderdetail() { + return orderdetail; + } + + public void setOrderdetail(Orderdetail orderdetail) { + this.orderdetail = orderdetail; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + +} diff --git a/src/main/java/me/mofun/action/FileUploadAction.java b/src/main/java/me/mofun/action/FileUploadAction.java new file mode 100644 index 0000000..aeece62 --- /dev/null +++ b/src/main/java/me/mofun/action/FileUploadAction.java @@ -0,0 +1,88 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.util.ConfigUtil; +import me.mofun.util.StringUtil; +import me.mofun.util.Struts2Utils; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.struts2.ServletActionContext; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.io.IOException; + +@Component("FileUploadAction") +public class FileUploadAction extends ActionSupport { + + private static final long serialVersionUID = -6979064905632902960L; + Log log = LogFactory.getLog(FileUploadAction.class); + String folder; + File filedata; + String filedataContentType; + String filedataFileName; + String id; + + public String uploadImage(){ + if (filedata == null || StringUtil.isBlank(filedataFileName)) { + log.error("FileUploadAction.updateImage 文件上传失败!文件为空"); + } + File savefile = null; + try { + /**拼接文件存放路径**/ + String saveRealFilePath = ServletActionContext.getRequest() + .getSession().getServletContext().getRealPath("/") + + ConfigUtil.getValue("upfilefolder"); + if(StringUtil.isNotBlank(folder)){ + saveRealFilePath = saveRealFilePath + folder.replaceAll("[/\\\\]", ""); + } + File fileDir = new File(saveRealFilePath); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + //Todo 如果文件已经存在…… + savefile = new File(saveRealFilePath + filedataFileName); + if(savefile.exists()){ + Struts2Utils.renderText("{\"err\":\"\",\"msg\":\"上传文件失败!文件已存在.请修改文件名后重新上传.}"); + return null; + } + FileUtils.copyFile(filedata, savefile); + Struts2Utils.renderText("{\"success\":\"\",\"msg\":\"" + + savefile + "\"}"); + return null; + } catch (IOException e) { + log.error("上传文件失败!", e); + Struts2Utils.renderJson("{\"err\":\"" + e.getMessage() + + "\",\"msg\":\"" + "上传文件失败!" + "\"}"); + } + return null; + } + + public File getFiledata() { + return filedata; + } + public void setFiledata(File filedata) { + this.filedata = filedata; + } + public String getFiledataContentType() { + return filedataContentType; + } + public void setFiledataContentType(String filedataContentType) { + this.filedataContentType = filedataContentType; + } + public String getFiledataFileName() { + return filedataFileName; + } + public void setFiledataFileName(String filedataFileName) { + this.filedataFileName = filedataFileName; + } + + public String getFolder() { + return folder; + } + + public void setFolder(String folder) { + this.folder = folder; + } +} diff --git a/src/main/java/me/mofun/action/GetBackPwdAction.java b/src/main/java/me/mofun/action/GetBackPwdAction.java new file mode 100644 index 0000000..f480d71 --- /dev/null +++ b/src/main/java/me/mofun/action/GetBackPwdAction.java @@ -0,0 +1,385 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.User; +import me.mofun.service.UserService; +import me.mofun.util.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.util.Date; +import java.util.Random; + +@SuppressWarnings("unused") +@Component("GetBackPwdAction") +public class GetBackPwdAction extends ActionSupport { + + private static final long serialVersionUID = 686157280940778943L; + @Autowired + @Qualifier("userService") + private UserService userService; + + private String rnd; + private String mail; + private String key; + private User user; + private String newPwd; + private String phone; + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + HttpServletRequest request = null; + HttpServletResponse response = null; + + public String index(){ + + return "index"; + } + + public void getBackPwd(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("rndCode")){ + String rndCode = cookie.getValue(); + System.err.println(rndCode); + if(rnd.trim().equalsIgnoreCase(rndCode)){ + System.err.println(mail); + user = userService.userByName(mail); + if(user==null){ + Struts2Utils.renderText("false"); + }else{ + Struts2Utils.renderText("1"); + } + }else{ + Struts2Utils.renderText("3"); + } + } + } + } + } + + public void getRandomCode(){ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + response.setContentType("image/jpeg");//设置相应类型,告诉浏览器输出的内容为图片 + response.setHeader("Pragma", "No-cache");//设置响应头信息,告诉浏览器不要缓存此内容 + response.setHeader("Cache-Control", "no-cache"); + response.setDateHeader("Expire", 0); + RandomValidateCode randomValidateCode = new RandomValidateCode(); + try { + randomValidateCode.getRandcode(request, response);//输出图片方法 + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String findemailcheck(){ + + return "findemailcheck"; + } + + public String findmobilecheck(){ + key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.dateTimeToStr(new Date()))+Base64.getEncode(mail); + try{ + SendFindPwdCode(); + }catch(Exception ex){ + ex.printStackTrace(); + } + + return "findmobilecheck"; + } + + public static void main(String[] args) throws UnsupportedEncodingException { + System.err.println(Base64.getEncode("{\"mail\":\"45@qq.com\",\"key\":\"NjU2MTU2MDlAcXEuY29t\"}")); +// System.err.println(Base64.getDecode("eyJtYWlsIjoiNjU2MTU2MDlAcXEuY29tIiwia2V5IjoiTmpVMk1UVTJNRGxBY1hFdVkyOXQifQ==")); + String encodeStr = "AEA0C8AC170F486C086657B85B2774728F687413D0E7972CEA8814193E067541MTg4NTgxMTc3MzE="; + System.err.println(Base64.getDecode(encodeStr)); +// String key = "GEFENGBKINNJIDJDMOHMOOBJDMEOHKPPOEEMKGGAOOMCDKLLEPCCDCBNNILOOCICNTIwMTM1OTRAcXEuY29t"; +// key = key.substring(64,key.length()); + String key = MD5Util.encode("127.0.0.1"+1000); + MemCachedClientHelp.getIMemcachedCache().remove(key); + } + + public void sendFindPwdMail(){ + request = Struts2Utils.getRequest(); + key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.dateTimeToStr(new Date()))+Base64.getEncode(mail); + String html = ""+ + ""+ + ""+ + ""+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    首页"+ + "我的"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"帮助
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    亲爱的 "+mail+"

    您好!请点击下面的按钮,重新设置您的密码:

    重设密码
    如果上面按钮不能点击或点击后没有反应,您还可以将以下链接复制到浏览器地址栏中访问完成重设密码。
    "+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/getbackpwd/findreset.html?key="+key+"

    如果您现在想起了您的密码:

    可不必重设密码,继续用原来的密码登录。

    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ +// ""+ +// ""+ +// ""+ + "
    此邮件由系统自动发出,请勿回复!
    感谢您对"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")的支持,祝您好运!
    客服热线:400-685-9800
    "+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + "
    "+ApplicationListenerImpl.sysConfigureJson.getDomain()+" "+ApplicationListenerImpl.sysConfigureJson.getIcp()+"
    "; + + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("rndCode")){ + String rndCode = cookie.getValue(); + if(rnd.trim().equalsIgnoreCase(rndCode)){ + if(MemCachedClientHelp.getIMemcachedCache().get(MD5Util.encode(mail))==null){ + //boolean flag = EmailUtil.sendEmail(ApplicationListenerImpl.sysConfigureJson.getMailName(), ApplicationListenerImpl.sysConfigureJson.getMailPwd(), mail, ApplicationListenerImpl.sysConfigureJson.getSiteName()+"取回密码", html); + boolean flag = EmailUtil.sendEmailOverSSL(ApplicationListenerImpl.sysConfigureJson.getMailName(), ApplicationListenerImpl.sysConfigureJson.getMailPwd(), mail, ApplicationListenerImpl.sysConfigureJson.getSiteName()+"取回密码", html); + + if(flag){ + MemCachedClientHelp.getIMemcachedCache().put(MD5Util.encode(mail), mail,new Date(10*60*1000)); + Struts2Utils.renderText("0"); + }else{ + Struts2Utils.renderText("false"); + } + }else{ + Struts2Utils.renderText("3"); + } + }else{ + Struts2Utils.renderText("2"); + } + } + } + } + } + + public String findreset() throws UnsupportedEncodingException{ + if(StringUtil.isNotBlank(key)){ + key = key.substring(64,key.length()); + mail = Base64.getDecode(key); + if(StringUtil.isNotBlank(mail)){ + user = userService.userByName(mail); + if(user!=null){ + return "findreset"; + } + } + } + return "index_index"; + } + + /** + * 更换手机号时手机短信验证码验证 Action + * @author lwgboy + * @return + * @throws UnsupportedEncodingException + */ + public String findMobileReset() throws UnsupportedEncodingException{ + String randomStr = Struts2Utils.getParameter("rnd"); + if(mail.matches("^1[0-9]{10}$")) + phone = mail; + try{ + String validateCode = MemCachedClientHelp.getIMemcachedCache().get(Base64.getEncode(phone)).toString(); + if(validateCode!=null&&validateCode.equals(randomStr)) + { + //MemCachedClientHelp.getIMemcachedCache().remove(MD5Util.encode(mail)); + Struts2Utils.renderText("0"); + } + else + Struts2Utils.renderText("-1"); + } + catch(Exception ex) + { + Struts2Utils.renderText("-1"); + ex.printStackTrace(); + } + return null; + } + + public void updatePwd(){ + user = userService.userByName(mail); + if(user!=null){ + user.setUserPwd(newPwd); + userService.add(user); + Struts2Utils.renderText("0"); + }else{ + Struts2Utils.renderText("false"); + } + } + + public String findok(){ + + return "findok"; + } + + /** + * 如果提交过来的参数是手机号,则将 phone 参数传递到 RegisterAction 的 regSendMes() 继续处理。 + * @deprecated 弃用 + * @return + */ + public String regSendMes_old(){ + if(mail.matches("^1[0-9]{10}$")){ + this.setPhone(mail); + return "regSendMes"; + } + else + return null; + } + + /** + * 发送手机短信验证码 + * @see 参考RegisterAction 的 regSendMes 方法 + * @return + * @throws Exception + */ + public String regSendMes() throws Exception{ + Random random = new Random(); + String ran = ""; + for (int i = 0; i < 6; i++) { + ran += random.nextInt(9); + } + if(mail.matches("^1[0-9]{10}$")){ + phone = mail; + if(MemCachedClientHelp.getIMemcachedCache().get(Base64.getEncode(phone))==null){ + try { + boolean result = SendSMS.sendSMS(phone, ran); + if(!result){ + Struts2Utils.renderText("false"); + return null; + } + MemCachedClientHelp.getIMemcachedCache().put(Base64.getEncode(phone), ran,new Date(2*60*1000)); + Struts2Utils.renderText("0"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("error"); + } + }else{ + Struts2Utils.renderText("2"); + } + }else{ + Struts2Utils.renderText("error"); + } + return null; + } + + /** + * 发送找后密码时的手机短信验证码 + * @see 参考RegisterAction 的 regSendMes 方法 + * @return + * @throws Exception + */ + public boolean SendFindPwdCode() throws Exception{ + Random random = new Random(); + String ran = ""; + for (int i = 0; i < 6; i++) { + ran += random.nextInt(9); + } + if(mail.matches("^1[0-9]{10}$")){ + phone = mail; + if(MemCachedClientHelp.getIMemcachedCache().get(Base64.getEncode(phone))==null){ + try { + boolean result = SendSMS.sendSMS(phone, ran); + if(!result){ + return false; + } + MemCachedClientHelp.getIMemcachedCache().put(Base64.getEncode(phone), ran,new Date(2*60*1000)); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + }else{ + return false; + } + }else{ + return false; + } +} + + + public String getRnd() { + return rnd; + } + + public void setRnd(String rnd) { + this.rnd = rnd; + } + + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getNewPwd() { + return newPwd; + } + + public void setNewPwd(String newPwd) { + this.newPwd = newPwd; + } + + +} diff --git a/src/main/java/me/mofun/action/HelpAction.java b/src/main/java/me/mofun/action/HelpAction.java new file mode 100644 index 0000000..69647c9 --- /dev/null +++ b/src/main/java/me/mofun/action/HelpAction.java @@ -0,0 +1,217 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.HelpInfo; +import me.mofun.pojo.News; +import me.mofun.pojo.NewsType; +import me.mofun.pojo.Suggestion; +import me.mofun.service.NewsService; +import me.mofun.service.NewsTypeService; +import me.mofun.service.SysConfigureService; +import me.mofun.util.Struts2Utils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; + +@SuppressWarnings("unused") +@Component("HelpAction") +public class HelpAction extends ActionSupport { + + private static final long serialVersionUID = -8756837342149838857L; + + private Suggestion suggestion; + private String rnd; + private List helpInfoList; + private List helpTypeList; + private News news; + + @Autowired + private SysConfigureService sysConfigureService; + @Autowired + private NewsTypeService newsTypeService; + @Autowired + private NewsService newsService; + + HttpServletRequest request = null; + HttpServletResponse response = null; + + public Integer newsId; //帮助信息的文章编号,亦即 news表中的 newsId + + public String index(){ + news = newsService.findById(newsId.toString()); + helpTypeList = newsTypeService.indexNewsTypeByParentId(2); + helpInfoList = new ArrayList(); + for(NewsType nt:helpTypeList){ + HelpInfo item = new HelpInfo(); + List newsList = newsService.indexNews(nt.getId(),null); + item.setCategoryId(nt.getId()); + item.setCategoryName(nt.getCategoryName()); + item.setInfoList(newsList); + helpInfoList.add(item); + } + return "index"; + } + + public int getNewsId() { + return newsId; + } + + public void setNewsId(Integer newId) { + this.newsId = newId; + } + + + public News getNews() { + return news; + } + + public void setNews(News news) { + this.news = news; + } + + + public List getHelpInfoList() { + return helpInfoList; + } + + public void setHelpInfoList(List helpInfoList) { + this.helpInfoList = helpInfoList; + } + + public String openCookie(){ + + return "openCookie"; + } + + public String whatPaigou(){ + return "whatPaigou"; + } + + public String paigouRule(){ + + return "paigouRule"; + } + + public String paigouFlow(){ + + return "paigouFlow"; + } + + public String questionDetail(){ + + return "questionDetail"; + } + + public String agreement(){ + + return "agreement"; + } + + public String genuinetwo(){ + + return "genuinetwo"; + } + + public String genuine(){ + + return "genuine"; + } + + public String securepayment(){ + + return "securepayment"; + } + + public String ship(){ + + return "ship"; + } + + public String suggestion(){ + + return "suggestion"; + } + + public String doSuggestion(){ + request = Struts2Utils.getRequest(); + try { + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("rndCode")){ + String rndCode = cookie.getValue(); + if(rnd.trim().equalsIgnoreCase(rndCode)){ + sysConfigureService.doSuggestion(suggestion); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + + return null; + } + + public String deliveryFees(){ + + return "deliveryFees"; + } + + public String prodCheck(){ + + return "prodCheck"; + } + + public String shiptwo(){ + + return "shiptwo"; + } + + public String privacy(){ + + return "privacy"; + } + + public String userExperience(){ + + return "userExperience"; + } + + public String qqgroup(){ + + return "qqgroup"; + } + + public String show(){ + return "show"; + } + + public Suggestion getSuggestion() { + return suggestion; + } + + public void setSuggestion(Suggestion suggestion) { + this.suggestion = suggestion; + } + + + public String getRnd() { + return rnd; + } + + public void setRnd(String rnd) { + this.rnd = rnd; + } + +} diff --git a/src/main/java/me/mofun/action/IndexAction.java b/src/main/java/me/mofun/action/IndexAction.java new file mode 100644 index 0000000..2d4200e --- /dev/null +++ b/src/main/java/me/mofun/action/IndexAction.java @@ -0,0 +1,889 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.*; +import net.sf.json.JSONArray; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@SuppressWarnings("unused") +@Component("IndexAction") +public class IndexAction extends ActionSupport { + private static final long serialVersionUID = -7084752934617098983L; + + @Autowired + @Qualifier("spellbuyrecordService") + private SpellbuyrecordService spellbuyrecordService; + @Autowired + @Qualifier("latestlotteryService") + private LatestlotteryService latestlotteryService; + @Autowired + @Qualifier("spellbuyproductService") + private SpellbuyproductService spellbuyproductService; + @Autowired + private NewsService newsService; + @Autowired + private RecommendService recommendService; + @Autowired + private UserService userService; + + private List hotProductList; + private List newProductList; + private List indexPopProductList; + private List productList; + private List buyHistoryJSONList; + public static List newsList; + private BuyHistoryJSON buyHistoryJSON; + private ProductJSON productJSON; + private ProductJSON recommendJSON; + private UserJSON userJSON; + private Product product; + private Spellbuyrecord spellbuyrecord; + private Spellbuyproduct spellbuyproduct; + private Latestlottery latestlottery; + private List latestlotteryList; + private User user; + private String id; + private int pageNo; + private int pageSize = 20; + private int pageCount; + private int resultCount; + private String startDate; + private String endDate; + private List indexImgList; + + private String action; + + private String uid; + private static List nowBuyProductList; + private static List newRecordList; + private static Long allBuyCount; + private static Long nowDateByAllCount = System.currentTimeMillis(); + private static Long beginDateByAllCount; + private static Long nowDateByNowBuyProduct = System.currentTimeMillis(); + private static Long beginDateByNowBuyProduct; + private static Long nowDateByNewRecord = System.currentTimeMillis(); + private static Long beginDateByNewRecord; + + HttpServletRequest request = null; + HttpServletResponse response = null; + + + public String show(){ + return null; + } + + public String index(){ + if(!ApplicationListenerImpl.sysConfigureAuth){ + Struts2Utils.renderHtml("" + + "授权过期 开发中心" + + "
    该系统授权已过期,请联系管理员重新授权!谢谢合作。www.ipdz.me
    "); + return null; + } + + /** + * 首页广告位下方推荐 + * 首页大图轮播广告下方的推荐区域(用于首页大图轮播广告下方的两个显示区域) + * 这里取两条最新的商品作为推荐,参考自getIndexNewProductList()函数 + */ + Pagination phoneDigitalPage = spellbuyrecordService.indexNewProductList(pageNo,2); //取两条显示 + List phoneDigitalList = (List) phoneDigitalPage.getList(); + newProductList = new ArrayList(); + for (int i = 0; i < phoneDigitalList.size(); i++) { + productJSON = new ProductJSON(); + //product = (Product) phoneDigitalList.get(i)[0]; //jdk 1.7 + //spellbuyproduct = (Spellbuyproduct) phoneDigitalList.get(i)[1]; //jdk 1.7 + product = (Product) phoneDigitalList.get(i)[1]; //for jdk 1.8 lwg 2020.03.18 + spellbuyproduct = (Spellbuyproduct) phoneDigitalList.get(i)[0]; //for jdk1.8 lwg 2020.03.18 + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); //首页中的每个商品应该是产品ID,已完成开奖的每一期中的ID取拍品ID + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setActionName(spellbuyproduct.getActionName()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + newProductList.add(productJSON); + } + + + /** + * 最新揭晓 + */ + List objList = latestlotteryService.indexWinningScroll(); + latestlotteryList = new ArrayList(); + for (int i = 0; i < objList.size(); i++) { + latestlottery = new Latestlottery(); + latestlottery = objList.get(i); + String userName = ""; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userName = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userName = latestlottery.getBuyUser(); + if(userName.indexOf("@")!=-1){ + String[] u = userName.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userName = u1+"@"+u[1]; + }else{ + userName = userName.substring(0,4)+ "*** "+userName.substring(7); + } + } + latestlottery.setBuyUser(userName); + latestlotteryList.add(latestlottery); + } + + /** + * 每日推荐 + */ + List objectList = recommendService.getRecommend(); + if(objectList!=null && objectList.size()>0){ + recommendJSON = new ProductJSON(); + product = (Product) objectList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) objectList.get(0)[1]; + recommendJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + recommendJSON.setHeadImage(product.getHeadImage()); + recommendJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + recommendJSON.setProductName(product.getProductName()); + recommendJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + recommendJSON.setProductTitle(product.getProductTitle()); + } + /** + * 新闻 + */ + if(newsList==null){ + newsList = newsService.indexNews(10,3); //10:表示新闻公告类,参见 NewsType表定义 + } + + indexImgList = JSONArray.fromObject(ApplicationListenerImpl.indexImgAll); + + /** + * 即将揭晓 + * @return + */ + Pagination datePage = spellbuyproductService.upcomingAnnounced(pageNo, 5); + List dateList = (List) datePage.getList(); + productList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + //product = (Product) dateList.get(i)[0]; //for jdk1.7 lwg 2020.03.18 + //spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; //for jdk1.7 lwg 2020.03.18 + product = (Product) dateList.get(i)[1]; // for jdk1.8 lwg 2020.03.18 + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[0]; //for jdk1.8 lwg 2020.03.18 + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + productList.add(productJSON); + } + return "index"; + } + + /** + * 热门推荐 + */ + public void getIndexHotProductList(){ + Pagination hotPage = spellbuyrecordService.findHotProductList(1,8); + List HotList = (List) hotPage.getList(); + hotProductList = new ArrayList(); + for (int i = 0; i < HotList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) HotList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) HotList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + hotProductList.add(productJSON); + } + Struts2Utils.renderJson(hotProductList); + } + + /** + * 首页新品展示区使用(用于首页 index.js 中的 ajax请求:/getIndexNewProductList.action) + */ + public void getIndexNewProductList(){ + newProductList = new ArrayList(); + Pagination phoneDigitalPage = spellbuyrecordService.indexNewProductList(pageNo,10); + if(phoneDigitalPage!=null){ + List phoneDigitalList = (List) phoneDigitalPage.getList(); + for (int i = 0; i < phoneDigitalList.size(); i++) { + productJSON = new ProductJSON(); + //product = (Product) phoneDigitalList.get(i)[0];//for jdk1.7 lwg 2020.03.18 + //spellbuyproduct = (Spellbuyproduct) phoneDigitalList.get(i)[1];//for jdk1.7 lwg 2020.03.18 + product = (Product) phoneDigitalList.get(i)[1];//for jdk1.8 lwg 2020.03.18 + spellbuyproduct = (Spellbuyproduct) phoneDigitalList.get(i)[0]; //for jdk1.8 lwg 2020.03.18 + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); //首页中的每个商品应该是产品ID,已完成开奖的每一期中的ID取拍品ID + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); + productJSON.setActionName(spellbuyproduct.getActionName()); + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + newProductList.add(productJSON); + } + //Struts2Utils.getRequest().setAttribute("newProductList",newProductList); + } + Struts2Utils.renderJson(newProductList); + } + + public void getIndexPopProductList(){ + /** + * 人气排行 + */ + Pagination ComputerOfficePage = spellbuyrecordService.indexHotProductList(pageNo,5); + List ComputerOfficeList = (List) ComputerOfficePage.getList(); + indexPopProductList = new ArrayList(); + for (int i = 0; i < ComputerOfficeList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) ComputerOfficeList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) ComputerOfficeList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + indexPopProductList.add(productJSON); + } + Struts2Utils.renderJson(indexPopProductList); + } + + public void getIndexUserInfo(){ + user = userService.findById(id); + if(user!=null){ + userJSON = new UserJSON(); + userJSON.setUserBalance(user.getBalance()); + userJSON.setUserExperience(user.getExperience()); + userJSON.setUserFace(user.getFaceImg()); + userJSON.setUserId(user.getUserId().toString()); + if(user.getExperience()<10000){ + userJSON.setUserLevel(1); + userJSON.setUserLevelName(ApplicationListenerImpl.sysConfigureJson.getShortName()+"小将"); + }else if(user.getExperience()<50000){ + userJSON.setUserLevel(2); + userJSON.setUserLevelName(ApplicationListenerImpl.sysConfigureJson.getShortName()+"少将"); + }else if(user.getExperience()<100000){ + userJSON.setUserLevel(3); + userJSON.setUserLevelName(ApplicationListenerImpl.sysConfigureJson.getShortName()+"中将"); + }else if(user.getExperience()<500000){ + userJSON.setUserLevel(4); + userJSON.setUserLevelName(ApplicationListenerImpl.sysConfigureJson.getShortName()+"上将"); + }else if(user.getExperience()<1000000){ + userJSON.setUserLevel(5); + userJSON.setUserLevelName(ApplicationListenerImpl.sysConfigureJson.getShortName()+"少校"); + }else if(user.getExperience()<2000000){ + userJSON.setUserLevel(6); + userJSON.setUserLevelName(ApplicationListenerImpl.sysConfigureJson.getShortName()+"中校"); + }else if(user.getExperience()<5000000){ + userJSON.setUserLevel(7); + userJSON.setUserLevelName(ApplicationListenerImpl.sysConfigureJson.getShortName()+"上校"); + }else if(user.getExperience()<10000000){ + userJSON.setUserLevel(7); + userJSON.setUserLevelName(ApplicationListenerImpl.sysConfigureJson.getShortName()+"元帅"); + } + userJSON.setUserName(UserNameUtil.userName(user)); + Struts2Utils.renderJson(userJSON); + } + } + + /** + * TA们正在拍购 + * @return + */ + public String getNowBuyProduct(){ + nowDateByNowBuyProduct = System.currentTimeMillis(); + if(beginDateByNowBuyProduct==null){ + Pagination page = spellbuyrecordService.getNowBuyList(pageNo, pageSize); + List newBuyList = (List) page.getList(); + nowBuyProductList = new ArrayList(); + for (int i = 0; i < newBuyList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) newBuyList.get(i)[0]; + spellbuyrecord = (Spellbuyrecord) newBuyList.get(i)[1]; + user = (User) newBuyList.get(i)[2]; + spellbuyproduct = (Spellbuyproduct) newBuyList.get(i)[3]; + String userName = UserNameUtil.userName(user); + productJSON.setBuyer(userName); + productJSON.setUserId(String.valueOf(user.getUserId())); + productJSON.setHeadImage(user.getFaceImg()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductTitle(product.getProductTitle()); + nowBuyProductList.add(productJSON); + } + beginDateByNowBuyProduct = System.currentTimeMillis(); +// System.err.println("他们正在购执行SQL"); + Struts2Utils.renderJson(nowBuyProductList); + }else{ + if((nowDateByNowBuyProduct-beginDateByNowBuyProduct)<5000){ +// System.err.println("他们正在购不执行"); + Struts2Utils.renderJson(nowBuyProductList); + }else{ + beginDateByNowBuyProduct = System.currentTimeMillis(); + Pagination page = spellbuyrecordService.getNowBuyList(pageNo, pageSize); + List newBuyList = (List) page.getList(); + nowBuyProductList = new ArrayList(); + for (int i = 0; i < newBuyList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) newBuyList.get(i)[0]; + spellbuyrecord = (Spellbuyrecord) newBuyList.get(i)[1]; + user = (User) newBuyList.get(i)[2]; + spellbuyproduct = (Spellbuyproduct) newBuyList.get(i)[3]; + String userName = UserNameUtil.userName(user); + productJSON.setBuyer(userName); + productJSON.setUserId(String.valueOf(user.getUserId())); + productJSON.setHeadImage(user.getFaceImg()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductTitle(product.getProductTitle()); + nowBuyProductList.add(productJSON); + } +// System.err.println("他们正在购再执行SQL"); + Struts2Utils.renderJson(nowBuyProductList); + } + } + return null; + } + + public void getServerTime(){ + Date date = new Date(); + date = DateUtil.SDateTimeToDate("2014-09-23 16:14:29"); +// Struts2Utils.renderText((DateUtil.SDateTimeToDate(DateUtil.DateTimeToStr(new Date())).getTime()-date.getTime())+""); + Struts2Utils.renderText(System.currentTimeMillis()+""); + } + + public static void main(String[] args) { + Date date = new Date(); +// 2591723 + date = DateUtil.SDateTimeToDate("2014-10-23 15:42:47"); + System.err.println(date.getTime()); + System.err.println(DateUtil.SDateTimeToDate(DateUtil.DateTimeToStr(new Date())).getTime()); + System.err.println(DateUtil.SDateTimeToDate(DateUtil.DateTimeToStr(new Date())).getTime()-date.getTime()); + System.err.println((DateUtil.SDateTimeToDate(DateUtil.DateTimeToStr(new Date())).getTime()-date.getTime())/60); + System.err.println(System.currentTimeMillis()); + } + + /** + * 邀请 + * @return + */ + public String referAuth(){ + HttpServletRequest request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + uid = cookie.getValue(); +// if(uid!=null && !uid.equals("")){ +// return "referAuthLogin"; +// } + } + } + } + return "referAuthLogin"; + } + + /** + * 地图模式,add by lwgoby + * @return + */ + public String map(){ + return "map"; + } + public String sincerity(){ + return "sincerity"; + } + + + public String share(){ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("inviteId",uid); + cookie.setMaxAge(12*60*60); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + } + +// String ip = Struts2Utils.getRequest().getRemoteAddr(); + String ip = Struts2Utils.getRequest().getHeader("X-Real-IP"); + if(ip==null){ + ip = "127.0.0.1"; + } + if(MemCachedClientHelp.getIMemcachedCache().get(uid)==null){ + user = userService.findById(uid); + if(user!=null){ + Integer m = user.getCommissionPoints(); + m += ApplicationListenerImpl.sysConfigureJson.getInvite(); + user.setCommissionPoints(m); + userService.add(user); + MemCachedClientHelp.getIMemcachedCache().put(uid, 1,new Date(12*60*60*1000)); + } + } + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + + /** + * 全站拍购总人数,用于首页显示参与人数(index.html->bottom.js->getAllBuyCount()) + */ + public void getAllBuyCount(){ + nowDateByAllCount = System.currentTimeMillis(); + if(beginDateByAllCount==null){ + allBuyCount = Long.parseLong(spellbuyrecordService.getAllByCount().toString()); + beginDateByAllCount = System.currentTimeMillis(); +// System.err.println("全站拍购人数执行SQL"); + Struts2Utils.renderText(String.valueOf(allBuyCount)); + }else{ + if((nowDateByAllCount-beginDateByAllCount)<5000){ +// System.err.println("全站拍购人数不执行"); + Struts2Utils.renderText(String.valueOf(allBuyCount)); + }else{ + beginDateByAllCount = System.currentTimeMillis(); + allBuyCount = Long.parseLong(spellbuyrecordService.getAllByCount().toString()); +// System.err.println("全站拍购人数再执行SQL"); + Struts2Utils.renderText(String.valueOf(allBuyCount)); + } + } + } + + /** + * 最新100条拍购记录 + * @return + */ + public String getNewRecord(){ + Pagination page = spellbuyrecordService.getNowBuyList(pageNo, 100); + List newBuyList = (List) page.getList(); + productList = new ArrayList(); + for (int i = 0; i < newBuyList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) newBuyList.get(i)[0]; + spellbuyrecord = (Spellbuyrecord) newBuyList.get(i)[1]; + user = (User) newBuyList.get(i)[2]; + spellbuyproduct = (Spellbuyproduct) newBuyList.get(i)[3]; + String userName = UserNameUtil.userName(user); + productJSON.setBuyer(userName); + productJSON.setUserId(String.valueOf(user.getUserId())); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + if(product.getProductName().length()>35){ + productJSON.setProductName(product.getProductName().substring(0,35)+"..."); + }else{ + productJSON.setProductName(product.getProductName()); + } + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSON.setBuyCount(spellbuyrecord.getBuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductStyle(String.valueOf(spellbuyrecord.getSpellbuyRecordId())); + productList.add(productJSON); + } + return "newRecord"; + } + + /** + * 用于 /WEB-INF/template/index/newRecord.jsp 中 newRecord.js 每5秒钟进行一次 ajax 调用 + * 调用时,提交页面上以显示的最新一条记录的 id 作为参数 + */ + public void getNewRecordAjax(){ + nowDateByNewRecord = System.currentTimeMillis(); + if(beginDateByNewRecord==null){ + Pagination page = spellbuyrecordService.getNowBuyAjaxList(pageNo, 100,Integer.parseInt(id)); + List newBuyList = (List) page.getList(); + newRecordList = new ArrayList(); + for (int i = 0; i < newBuyList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) newBuyList.get(i)[0]; + spellbuyrecord = (Spellbuyrecord) newBuyList.get(i)[1]; + user = (User) newBuyList.get(i)[2]; + spellbuyproduct = (Spellbuyproduct) newBuyList.get(i)[3]; + String userName = UserNameUtil.userName(user); + productJSON.setBuyer(userName); + productJSON.setUserId(String.valueOf(user.getUserId())); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + if(product.getProductName().length()>35){ + productJSON.setProductName(product.getProductName().substring(0,35)+"..."); + }else{ + productJSON.setProductName(product.getProductName()); + } + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSON.setBuyCount(spellbuyrecord.getBuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductStyle(String.valueOf(spellbuyrecord.getSpellbuyRecordId())); + newRecordList.add(productJSON); + } + beginDateByNewRecord = System.currentTimeMillis(); +// System.err.println("最新参与执行SQL"); + if(newRecordList.size()>0) + Struts2Utils.renderJson(newRecordList); + else + Struts2Utils.renderText(""); + }else{ + if((nowDateByNewRecord-beginDateByNewRecord)<5000){ +// System.err.println("最新参与不执行"); + if(newRecordList.size()>0) + Struts2Utils.renderJson(newRecordList); + else + Struts2Utils.renderText(""); + }else{ + beginDateByNewRecord = System.currentTimeMillis(); + Pagination page = spellbuyrecordService.getNowBuyAjaxList(pageNo, 100,Integer.parseInt(id)); + List newBuyList = (List) page.getList(); + newRecordList = new ArrayList(); + for (int i = 0; i < newBuyList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) newBuyList.get(i)[0]; + spellbuyrecord = (Spellbuyrecord) newBuyList.get(i)[1]; + user = (User) newBuyList.get(i)[2]; + spellbuyproduct = (Spellbuyproduct) newBuyList.get(i)[3]; + String userName = UserNameUtil.userName(user); + productJSON.setBuyer(userName); + productJSON.setUserId(String.valueOf(user.getUserId())); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + if(product.getProductName().length()>35){ + productJSON.setProductName(product.getProductName().substring(0,35)+"..."); + }else{ + productJSON.setProductName(product.getProductName()); + } + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSON.setBuyCount(spellbuyrecord.getBuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductStyle(String.valueOf(spellbuyrecord.getSpellbuyRecordId())); + newRecordList.add(productJSON); + } +// System.err.println("最新参与再执行SQL"); + if(newRecordList.size()>0) + Struts2Utils.renderJson(newRecordList); + else + Struts2Utils.renderText(""); + } + } + } + + /** + * 全站拍购记录查询 (有选择时间) + * @return + */ + + public String getAllBuyRecord(){ + Pagination datePage = spellbuyrecordService.getAllBuyRecord(startDate,endDate, pageNo, pageSize); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + for (int j = 0; j < dataList.size(); j++) { + buyHistoryJSON = new BuyHistoryJSON(); + product = (Product) dataList.get(j)[0]; + spellbuyrecord = (Spellbuyrecord) dataList.get(j)[1]; + user = (User) dataList.get(j)[2]; + spellbuyproduct = (Spellbuyproduct) dataList.get(j)[3]; + buyHistoryJSON.setBuyCount(Long.parseLong(String.valueOf(spellbuyrecord.getBuyPrice()))); + buyHistoryJSON.setBuyStatus(spellbuyproduct.getSpStatus()); + buyHistoryJSON.setHistoryId(spellbuyrecord.getSpellbuyRecordId()); + buyHistoryJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + buyHistoryJSON.setProductImg(product.getHeadImage()); + buyHistoryJSON.setProductName(product.getProductName()); + buyHistoryJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + buyHistoryJSON.setProductTitle(product.getProductTitle()); + if(spellbuyproduct.getSpStatus()==1){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(spellbuyproduct.getSpellbuyProductId()).get(0); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setBuyTime(latestlottery.getBuyTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUser(userer); + } + buyHistoryJSONList.add(buyHistoryJSON); + } + return "allBuyRecord"; + } + + public void JPData() { + String temp=action; + if(request==null) + request = Struts2Utils.getRequest(); + String requestURL =request.getRequestURL().toString(); + String querString = request.getQueryString(); + action=querString.split("&")[0].split("=")[1]; + RequestDispatcher d = request.getRequestDispatcher("/group/"+action+".action"); + try { + d.forward(request, response); + } catch (ServletException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ; + /* + ActionContext ac = ActionContext.getContext();//获取当前action的上下文 + RequestMap reqMap = (RequestMap)ac.get("request");//获取请求Map + + String acPath = (String)reqMap.get("javax.servlet.forward.servlet_path");//获取跳转的action路径 + String queryString = (String)reqMap.get("javax.servlet.forward.query_string");//获取跳转的action请求参数 + */ + + } + + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + + public User getUser() { + return user; + } + + + public void setUser(User user) { + this.user = user; + } + + public List getHotProductList() { + return hotProductList; + } + + public void setHotProductList(List hotProductList) { + this.hotProductList = hotProductList; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getLatestlotteryList() { + return latestlotteryList; + } + + public void setLatestlotteryList(List latestlotteryList) { + this.latestlotteryList = latestlotteryList; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public List getNewsList() { + return newsList; + } + + public void setNewsList(List newsList) { + this.newsList = newsList; + } + + public ProductJSON getRecommendJSON() { + return recommendJSON; + } + + public void setRecommendJSON(ProductJSON recommendJSON) { + this.recommendJSON = recommendJSON; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public List getProductList() { + return productList; + } + + public void setProductList(List productList) { + this.productList = productList; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public List getBuyHistoryJSONList() { + return buyHistoryJSONList; + } + + public void setBuyHistoryJSONList(List buyHistoryJSONList) { + this.buyHistoryJSONList = buyHistoryJSONList; + } + + public BuyHistoryJSON getBuyHistoryJSON() { + return buyHistoryJSON; + } + + public void setBuyHistoryJSON(BuyHistoryJSON buyHistoryJSON) { + this.buyHistoryJSON = buyHistoryJSON; + } + + public List getIndexImgList() { + return indexImgList; + } + + public void setIndexImgList(List indexImgList) { + this.indexImgList = indexImgList; + } + + public List getNewProductList() { + return newProductList; + } + + public void setNewProductList(List newProductList) { + this.newProductList = newProductList; + } + + public void setIndexPopProductList(List indexPopProductList) { + this.indexPopProductList = indexPopProductList; + } + + public UserJSON getUserJSON() { + return userJSON; + } + + public void setUserJSON(UserJSON userJSON) { + this.userJSON = userJSON; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + +} diff --git a/src/main/java/me/mofun/action/ListAction.java b/src/main/java/me/mofun/action/ListAction.java new file mode 100644 index 0000000..ccd6991 --- /dev/null +++ b/src/main/java/me/mofun/action/ListAction.java @@ -0,0 +1,516 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Product; +import me.mofun.pojo.ProductJSON; +import me.mofun.pojo.ProductType; +import me.mofun.pojo.Spellbuyproduct; +import me.mofun.service.ProductTypeService; +import me.mofun.service.SpellbuyproductService; +import me.mofun.service.SpellbuyrecordService; +import me.mofun.test.tree.MenuNode; +import me.mofun.util.ApplicationListenerImpl; +import me.mofun.util.PaginationUtil; +import me.mofun.util.StringUtil; +import me.mofun.util.Struts2Utils; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.ArrayList; +import java.util.List; + +@SuppressWarnings("unused") +@Component("ListAction") +public class ListAction extends ActionSupport { + + private static final long serialVersionUID = 8452833122481904678L; + + @Autowired + @Qualifier("spellbuyrecordService") + private SpellbuyrecordService spellbuyrecordService; + @Autowired + @Qualifier("spellbuyproductService") + private SpellbuyproductService spellbuyproductService; + @Autowired + ProductTypeService productTypeService; + private static ProductTypeService theProductTypeService; + + private List ProductList; + private ProductJSON productJSON; + private Product product; + private Spellbuyproduct spellbuyproduct; + private List producttyList; + private List brandList; + + private List menuNodeList; //首页左上的产品类型菜单树 + + private String id; + private String typeId; + private String tId; + private String typeName; + private String brandName; + private int pageNo; + private String pages; + private String pageString; + private int pageSize = 20; + private int pageCount; + private int resultCount; + private String brandId; + +// public static ResourceBundle url = ResourceBundle.getBundle("config"); + + private Logger logger = Logger.getLogger(this.getClass()); + public String index(){ + if(pageNo==0){ + pageNo = 1; + } + if(pages!=null){ + pageNo = Integer.parseInt(pages.split("_")[1]); + } + if(StringUtil.isNotBlank(typeId)){ + if(typeId.indexOf("b")!=-1){ + brandId = typeId.split("b")[1]; + tId = typeId.split("b")[0]; + if(StringUtil.isNotBlank(tId)){ + typeName = productTypeService.findById(tId).getTypeName(); + }else{ + typeName = productTypeService.findById("1000").getTypeName(); + } + brandName = productTypeService.findBrandById(brandId).getTypeName(); + }else{ + tId = typeId; + typeName = productTypeService.findById(tId).getTypeName(); + } + }else{ + typeName = productTypeService.findById("1000").getTypeName(); + } + producttyList = productTypeService.listByProductList(); +// brandList = productTypeService.listByBrand(tId); + List tList = productTypeService.listByBrand(tId); + int j = 0; + for (int i = 0; i < tList.size(); i++) { + if(StringUtil.isNotBlank(brandId)){ + if(Integer.parseInt(brandId)==tList.get(i).getTypeId()){ + j = i; + } + } + } + if(j>16){ + if(StringUtil.isNotBlank(brandId)){ + brandList = new ArrayList(); + for (int i=0;i HotList = (List) hotPage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < HotList.size(); i++) { + productJSON = new ProductJSON(); + //product = (Product) HotList.get(i)[0]; //for jdk1.7 lwg 2020.03.08 + //spellbuyproduct = (Spellbuyproduct) HotList.get(i)[1]; //for jdk1.7 lwg 2020.03.08 + product = (Product) HotList.get(i)[1]; //for jdk1.8 lwg 2020.03.08 + spellbuyproduct = (Spellbuyproduct) HotList.get(i)[0]; //for jdk1.8 lwg 2020.03.08 + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = hotPage.getResultCount(); + if(tId!=null && !tId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/"+tId+"/p_"); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/p_"); + } + }else if(id.equals("date20")){ + Pagination datePage = spellbuyrecordService.ProductByTypeIdList(tId,brandId, "date", pageNo, pageSize); + List dateList = (List) datePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + //product = (Product) dateList.get(i)[0]; + //spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; + product = (Product) dateList.get(i)[1]; + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[0]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = datePage.getResultCount(); + if(tId!=null && !tId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/"+tId+"/p_"); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/p_"); + } + }else if(id.equals("price20")){ + Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(tId,brandId, "price", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + if(tId!=null && !tId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/"+tId+"/p_"); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/p_"); + } + }else if(id.equals("priceAsc20")){ + Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(tId,brandId, "priceAsc", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + if(tId!=null && !tId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/"+tId+"/p_"); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/p_"); + } + }else if (id.equals("about20")){ + Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(tId,brandId, "about", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + if(tId!=null && !tId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/"+tId+"/p_"); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/p_"); + } + }else if(id.equals("surplus20")){ + Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(tId,brandId, "surplus", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + if(tId!=null && !tId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/"+tId+"/p_"); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/list/"+id+"/p_"); + } + } + return "index"; + } + + /** + * id:商品的id,而非商品参加拍购时的拍购Id + * 查询商品是否满员 + * http://www.1ypg.com//list/isStatus.action?id=4647 + * http://127.0.0.1:8080/list/isStatus.action?id=1020 + */ + public void isStatus(){ + //spellbuyproduct = spellbuyproductService.findById(id); + spellbuyproduct = spellbuyproductService.findByFKProductId(id); //modify by lwg,这里的id 是产品id,非拍购品ID,因此改用此方法; + if(spellbuyproduct.getSpStatus()==1){ + Struts2Utils.renderText("false"); + }else{ + if(spellbuyproduct.getSpellbuyPrice() - spellbuyproduct.getSpellbuyCount()==0){ + Struts2Utils.renderText("false"); + }else{ + Struts2Utils.renderText(String.valueOf(spellbuyproduct.getSpellbuyPrice() - spellbuyproduct.getSpellbuyCount())); + } + } + } + + /** + * 首页左侧产品类目列表 + */ + public String getProductTypeSubList() + { + menuNodeList = productTypeService.getAllProductTypeTree(); + logger.info("menuNodeList.size="+menuNodeList.size()); + return "getMenuList"; + } + + @PostConstruct + public void init(){ + if(this.productTypeService!=null) + theProductTypeService = this.productTypeService; + } + + public static List getTypeSubList() + { + List nodeList = theProductTypeService.getAllProductTypeTree(); + return nodeList; + } + + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public ProductTypeService getTheProductTypeService() { + return theProductTypeService; + } + + public void setTheProductTypeService(ProductTypeService theProductTypeService) { + ListAction.theProductTypeService = theProductTypeService; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public List getProductList() { + return ProductList; + } + + public void setProductList(List productList) { + ProductList = productList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public String getTypeId() { + return typeId; + } + + public void setTypeId(String typeId) { + this.typeId = typeId; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getBrandName() { + return brandName; + } + + public void setBrandName(String brandName) { + this.brandName = brandName; + } + + + public String getPages() { + return pages; + } + + public void setPages(String pages) { + this.pages = pages; + } + + public String getPageString() { + return pageString; + } + + public void setPageString(String pageString) { + this.pageString = pageString; + } + + public List getProducttyList() { + return producttyList; + } + + public void setProducttyList(List producttyList) { + this.producttyList = producttyList; + } + + public List getBrandList() { + return brandList; + } + + public void setBrandList(List brandList) { + this.brandList = brandList; + } + + public List getMenuNodeList() { + return menuNodeList; + } + + public void setMenuNodeList(List menuNodeList) { + this.menuNodeList = menuNodeList; + } + + public String getBrandId() { + return brandId; + } + + public void setBrandId(String brandId) { + this.brandId = brandId; + } + + public String getTId() { + return tId; + } + + public void setTId(String id) { + tId = id; + } + + +} diff --git a/src/main/java/me/mofun/action/LoginAction.java b/src/main/java/me/mofun/action/LoginAction.java new file mode 100644 index 0000000..f8d5604 --- /dev/null +++ b/src/main/java/me/mofun/action/LoginAction.java @@ -0,0 +1,218 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.User; +import me.mofun.service.UserService; +import me.mofun.util.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.Map; + + +@SuppressWarnings("unused") +@Component("LoginAction") +public class LoginAction extends ActionSupport{ + private static final long serialVersionUID = -6356307819518359036L; + + private String userName; + private String pwd; + private String forward; + private String shareId; + + //add by lwgboy + private User loginUser; + + @Autowired + @Qualifier("userService") + private UserService userService; + + HttpServletRequest request = null; + static HTMLFilter htmlFilter = new HTMLFilter(); + + public String index(){ + try { + if(StringUtil.isNotBlank(forward)){ + forward = htmlFilter.filter(forward); + } + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + String userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + return "index_index"; + } + } + } + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); +// return null; + } + } catch (Exception e) { + e.printStackTrace(); + } + return "index"; + } + + public String login(){ + userName = htmlFilter.filter(userName); + pwd = htmlFilter.filter(pwd); + User user = userService.userByName(userName); +// String ip = Struts2Utils.getRequest().getRemoteAddr(); + String ip = Struts2Utils.getRequest().getHeader("X-Real-IP"); + if(ip==null){ + ip = "127.0.0.1"; + } + String date = DateUtil.DateTimeToStr(new Date()); + if(user!=null){ + if(userName.indexOf("@")!=-1){ + User u1 = userService.mailLogin(userName, pwd); + if(u1!=null){ + try { + if(u1.getMailCheck().equals("0")){ + Struts2Utils.renderJson(u1); + user.setIpAddress(ip); + String ipLocation = RegisterAction.seeker.getAddress(ip); + user.setIpLocation(ipLocation); +// user.setOldDate(user.getNewDate()); + user.setNewDate(date); + userService.add(user); + + //add by lwgboy + request = Struts2Utils.getRequest(); + request.setAttribute("user", user); + request.getSession().setAttribute("user", user); + + }else{ + Struts2Utils.renderText("check"); + } + } catch (Exception e) { + Struts2Utils.renderText("check"); + e.printStackTrace(); + } + }else{ + Struts2Utils.renderText("pwdError"); + } + }else{ + User u2 = userService.phoneLogin(userName, pwd); + if(u2!=null){ + try { + if(u2.getMobileCheck().equals("0")){ + Struts2Utils.renderJson(u2); + user.setIpAddress(ip); + String ipLocation = RegisterAction.seeker.getAddress(ip); + user.setIpLocation(ipLocation); +// user.setOldDate(user.getNewDate()); + user.setNewDate(date); + userService.add(user); + + //add by lwgboy + request = Struts2Utils.getRequest(); + request.setAttribute("user", user); + request.getSession().setAttribute("user", user); + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + { + request.getSession().setAttribute("admin", user); + } + /* + ActionContext actionContext = ActionContext.getContext(); + Map session = actionContext.getSession(); + session.put("user", user); + */ + + loginUser = user; + }else{ + Struts2Utils.renderText("check"); + } + } catch (Exception e) { + Struts2Utils.renderText("check"); + e.printStackTrace(); + } + }else{ + Struts2Utils.renderText("pwdError"); + } + } + }else{ + Struts2Utils.renderText("userError"); + } + return null; + } + + public String fastLogin(){ + + return "fastLogin"; + } + + public String buyCartLogin(){ + + return "buyCartLogin"; + } + + public String miniLogin(){ + return "miniLogin"; + } + + public String postCommentLogin(){ + + return "postCommentLogin"; + } + + //弹出登陆/注册对话框: /WEB-INF/template/login/popLogin.jsp + public String popLogin(){ + return "popLogin"; + } + + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPwd() { + return pwd; + } + + public void setPwd(String pwd) { + this.pwd = pwd; + } + + public String getForward() { + return forward; + } + + public void setForward(String forward) { + this.forward = forward; + } + + public String getShareId() { + return shareId; + } + + public void setShareId(String shareId) { + this.shareId = shareId; + } + + public String execute(){ + if(null!=this.loginUser) + { + ActionContext actionContext = ActionContext.getContext(); + Map session = actionContext.getSession(); + session.put("user",loginUser); + return SUCCESS; + } + return Action.ERROR; + } + +} diff --git a/src/main/java/me/mofun/action/LogoutAction.java b/src/main/java/me/mofun/action/LogoutAction.java new file mode 100644 index 0000000..ce1de02 --- /dev/null +++ b/src/main/java/me/mofun/action/LogoutAction.java @@ -0,0 +1,16 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import org.springframework.stereotype.Component; + +@SuppressWarnings("unused") +@Component("LogoutAction") +public class LogoutAction extends ActionSupport { + private static final long serialVersionUID = 5411610776024806651L; + + public String index(){ + + return "logout"; + } + +} diff --git a/src/main/java/me/mofun/action/LotteryAction.java b/src/main/java/me/mofun/action/LotteryAction.java new file mode 100644 index 0000000..c0525d2 --- /dev/null +++ b/src/main/java/me/mofun/action/LotteryAction.java @@ -0,0 +1,753 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@SuppressWarnings("unused") +@Component("LotteryAction") +public class LotteryAction extends ActionSupport { + + private static final long serialVersionUID = 2321693841189871589L; + + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private ProductService productService; + @Autowired + private RandomnumberService randomnumberService; + @Autowired + private LotteryproductutilService lotteryproductutilService; + + private Latestlottery latestlottery; + private List latestlotteryList; + private ProductJSON productJSON; + private ProductCart productCart; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private List LotteryproductutilList; + private User user; + private String id; + private int pageNo; + private String pages; + private String pageString; + private int pageSize = 14; + private int pageCount; + private int resultCount; + private long time; + Calendar calendar = Calendar.getInstance(); + private static List upcomingAnnouncedList; + private static List upcomingAnnouncedByTopList; + private static Long nowDateByUpcomingAnnounced = System.currentTimeMillis(); + private static Long beginDateByUpcomingAnnounced; + private static Long nowDateByUpcomingAnnouncedByTop = System.currentTimeMillis(); + private static Long beginDateByUpcomingAnnouncedByTop; + + public String index(){ + if(pageNo==0){ + pageNo = 1; + } + if(pages!=null){ + pageNo = Integer.parseInt(pages.split("_")[1]); + } + Pagination page = latestlotteryService.LatestAnnounced(pageNo, pageSize); + resultCount = page.getResultCount(); + List objList = (List) page.getList(); + latestlotteryList = new ArrayList(); + for (int i = 0; i < objList.size(); i++) { + latestlottery = new Latestlottery(); + latestlottery = objList.get(i); + String userName = ""; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userName = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userName = latestlottery.getBuyUser(); + if(userName.indexOf("@")!=-1){ + String[] u = userName.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userName = u1+"@"+u[1]; + }else{ + userName = userName.substring(0,4)+ "*** "+userName.substring(7); + } + } + latestlottery.setBuyUser(userName); + latestlotteryList.add(latestlottery); + } + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/lottery/index/p_"); + return "index"; + } + + //获取开奖产品列表,用于首页 index.js->lotteryproductutilList() + public void lotteryproductutilList(){ + LotteryproductutilList = lotteryproductutilService.loadAll(); + if(LotteryproductutilList.size()>0){ + Struts2Utils.renderJson(LotteryproductutilList); + } + } + + public synchronized void lotteryUtil(){ + String lotteryId = MD5Util.encode(id); + if(MemCachedClientHelp.getIMemcachedCache().get(lotteryId)==null){ + spellbuyproduct = spellbuyproductService.findById(id); + if(spellbuyproduct.getSpStatus()==2){ + /** + * 某商品结束日期全站100条购买记录 + */ + spellbuyrecord = (Spellbuyrecord) spellbuyrecordService.getEndBuyDateByProduct(spellbuyproduct.getSpellbuyProductId()).get(0); + String newDate = spellbuyrecord.getBuyDate(); + List dataList = spellbuyrecordService.getSpellbuyRecordByLast100(null, spellbuyproduct.getSpellbuyEndDate()); + Long DateSUM = 0L; + Integer buyId = dataList.get(0).getFkSpellbuyProductId(); + int i100=0; + for (int k = 0; k < dataList.size(); k++) { + + if(k>0) + { + if(newDate.equals(dataList.get(k).getBuyDate()) && dataList.get(k).getFkSpellbuyProductId() != buyId ){ + continue; + } + } + if(i100++==100) { + break; + } + + spellbuyrecord = dataList.get(k); +// + calendar.setTime(DateUtil.SDateTimeToDate(spellbuyrecord.getBuyDate())); +// Integer y = calendar.get(Calendar.YEAR); +// Integer M = calendar.get(Calendar.MONTH)+1; +// Integer d = calendar.get(Calendar.DAY_OF_MONTH); + Integer h = calendar.get(Calendar.HOUR_OF_DAY); + Integer m = calendar.get(Calendar.MINUTE); + Integer s1 = calendar.get(Calendar.SECOND); + Integer ss1 = calendar.get(Calendar.MILLISECOND); + String sh = ""; + String sm = ""; + String ss = ""; + String sss = ""; + if(h<10){ + sh = "0"+h; + }else{ + sh = h.toString(); + } + if(m<10){ + sm = "0"+m; + }else{ + sm = m.toString(); + } + if(s1<10){ + ss = "0"+s1; + }else{ + ss = s1.toString(); + } + if(ss1<10){ + sss = "00"+ss1; + }else if(ss1<100){ + sss = "0"+ss1; + }else{ + sss = ss1.toString(); + } + DateSUM += Long.parseLong(sh+sm+ss+sss); + System.err.println("Id:"+spellbuyrecord.getFkSpellbuyProductId()+"date:"+spellbuyrecord.getBuyDate()+"buyID:"+spellbuyrecord.getSpellbuyRecordId()); + } + System.err.println("NewLotteryUtil DateSUM:"+DateSUM +" "+id); + /** + * 计算出中奖码 + */ + Integer winNumber = Integer.parseInt(String.valueOf(((DateSUM % spellbuyproduct.getSpellbuyPrice())+10000001))); + + System.err.println("NewLotteryUtil winNmuber:"+winNumber+" "+spellbuyproduct.getSpellbuyProductId()); + boolean flag = false; + Integer productPrice = spellbuyproduct.getSpellbuyPrice(); + //需要修改时间的Randomnumber + //修改 + Randomnumber randomnumberUP = null; + long winCount = 0; + long count = productPrice; + while(!flag){ + List objList = spellbuyrecordService.WinRandomNumber(spellbuyproduct.getSpellbuyProductId(), winNumber); + if(objList.size()==0){ + winNumber ++; + if(winNumber > (10000000 + productPrice)){ + winNumber = 10000001; + } + }else{ + flag = true; + randomnumberUP = (Randomnumber) objList.get(0)[0]; + } + count --; + if(count == 0){ + winNumber = Integer.parseInt(String.valueOf(((DateSUM % spellbuyproduct.getSpellbuyPrice())+10000001))); + break; + } + } + long price = productPrice; + long sucess=(winNumber-10000001); //我要的中奖号码 2 + long real=DateSUM%price; //真实的中奖号码 1 + long update = DateSUM; //我要的时间总和 14 + + update +=(sucess-real); + winCount = sucess-real; + + if(randomnumberUP!=null){ + String updateDate = randomnumberUP.getBuyDate(); + Long dateTime = DateUtil.SDateTimeToDateBySSS(updateDate).getTime(); + dateTime +=winCount; + Date date = new Date(dateTime); + Spellbuyrecord spellbuyrecord2 = spellbuyrecordService.findById(String.valueOf(randomnumberUP.getSpellbuyrecordId())); + spellbuyrecord2.setBuyDate(DateUtil.DateTimeToStrBySSS(date)); + randomnumberUP.setBuyDate(DateUtil.DateTimeToStrBySSS(date)); + spellbuyrecordService.add(spellbuyrecord2); + randomnumberService.add(randomnumberUP); + } + + List objList = spellbuyrecordService.randomByBuyHistoryByspellbuyProductId(spellbuyproduct.getSpellbuyProductId(),String.valueOf(winNumber)); + Randomnumber randomnumber = (Randomnumber) objList.get(0)[0]; + Spellbuyrecord spellbuyrecord = (Spellbuyrecord) objList.get(0)[1]; + user = (User) objList.get(0)[2]; + + spellbuyrecord.setSpRandomNo(String.valueOf(winNumber)); + spellbuyrecord.setSpWinningStatus("1"); + spellbuyrecord.setBuyStatus("1"); + spellbuyrecordService.add(spellbuyrecord); + + int productPeriod = spellbuyproduct.getProductPeriod(); + +// int Period = Integer.parseInt(product.getAttribute71()); +// ++Period; +// product.setAttribute71(String.valueOf(Period)); +// product.setStatus(1); +// productService.add(product); + + spellbuyproduct.setSpStatus(1); + spellbuyproductService.add(spellbuyproduct); + + product = productService.findById(String.valueOf(spellbuyproduct.getFkProductId())); + if(product.getStatus()==1){ + List spellbuyproductOld = spellbuyproductService.findSpellbuyproductByProductIdIsStatus(spellbuyproduct.getFkProductId()); + System.err.println("spellbuyproductOld:"+spellbuyproductOld); + System.err.println("spellbuyproductOld-size:"+spellbuyproductOld.size()); + if(spellbuyproductOld.size()==0){ + Spellbuyproduct spellbuyproduct2 = new Spellbuyproduct(); + spellbuyproduct2.setFkProductId(spellbuyproduct.getFkProductId()); + spellbuyproduct2.setProductPeriod(++productPeriod); + spellbuyproduct2.setSpellbuyCount(0); + spellbuyproduct2.setSpellbuyType(0); + spellbuyproduct2.setSpellbuyEndDate(DateUtil.DateTimeToStr(new Date())); + spellbuyproduct2.setSpellbuyPrice(product.getProductPrice()); + spellbuyproduct2.setMarketPrice(product.getMarketPrice()); + spellbuyproduct2.setSpSinglePrice(product.getSinglePrice()); + spellbuyproduct2.setSpellbuyStartDate(DateUtil.DateTimeToStr(new Date())); + spellbuyproduct2.setSpStatus(0); + if(product.getAttribute71().equals("hot")){ + spellbuyproduct2.setSpellbuyType(8); + }else{ + spellbuyproduct2.setSpellbuyType(0); + } + //开奖完成后添加一条拍品到拍品表作为新一期拍品,让用户参加竞拍 + spellbuyproductService.add(spellbuyproduct2); + } + } + + + List list = latestlotteryService.getLatestlotteryBySpellbuyProductIdAndProductIdIsExist(spellbuyproduct.getSpellbuyProductId()); + + if(list.size()==0){ + latestlottery = new Latestlottery(); + latestlottery.setProductId(spellbuyproduct.getFkProductId()); + latestlottery.setProductName(product.getProductName()); + latestlottery.setProductTitle(product.getProductTitle()); + latestlottery.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + latestlottery.setProductImg(product.getHeadImage()); + latestlottery.setProductPeriod(spellbuyproduct.getProductPeriod()); + latestlottery.setAnnouncedTime(newDate); //揭晓时间 + latestlottery.setAnnouncedType(spellbuyproduct.getSpellbuyType()); + latestlottery.setDateSum(update); + latestlottery.setBuyTime(spellbuyrecord.getBuyDate()); //购买时间 + latestlottery.setSpellbuyRecordId(spellbuyrecord.getSpellbuyRecordId()); //购买记录ID + latestlottery.setSpellbuyProductId(spellbuyrecord.getFkSpellbuyProductId()); //某期商品ID + BigDecimal buyNumberCount = randomnumberService.RandomNumberByUserBuyCount(String.valueOf(user.getUserId()), spellbuyproduct.getSpellbuyProductId()); + latestlottery.setBuyNumberCount(Integer.parseInt(String.valueOf(buyNumberCount))); //购买总数 + latestlottery.setRandomNumber(winNumber); //中奖码 + latestlottery.setLocation(user.getIpLocation()); + latestlottery.setUserId(user.getUserId()); + latestlottery.setUserName(UserNameUtil.userName(user)); + latestlottery.setUserFace(user.getFaceImg()); + latestlottery.setStatus(1); + latestlottery.setShareStatus(-1); + latestlottery.setShareId(null); + latestlottery.setBuyType(1); //电商新增字段,1表示拍购,2表示普通电商购买 + latestlotteryService.add(latestlottery); + + } + try{ + MemCachedClientHelp.getIMemcachedCache().put(lotteryId, "y",new Date(12*60*60*1000)); + }catch(Exception ex){ + ex.printStackTrace(); + } + Struts2Utils.renderText("true"); + } + }else{ + List list = latestlotteryService.getLatestlotteryBySpellbuyProductIdAndProductIdIsExist(Integer.parseInt(id)); + if(list.size()>0){ + Struts2Utils.renderText("true"); + } + } + } + + public void lotteryUtilAjax(){ + String lotteryId = MD5Util.encode(id); + if(MemCachedClientHelp.getIMemcachedCache().get(lotteryId)==null){ + MemCachedClientHelp.getIMemcachedCache().put(lotteryId, "y",new Date(12*60*60*1000)); + spellbuyproduct = spellbuyproductService.findById(id); + if(spellbuyproduct.getSpStatus()==2){ + /** + * 某商品结束日期全站100条购买记录 + */ + List dataList = spellbuyrecordService.getSpellbuyRecordByLast100(null, spellbuyproduct.getSpellbuyEndDate()); + Long DateSUM = 0L; + String newDate = ""; + Integer buyId = dataList.get(0).getFkSpellbuyProductId(); + newDate = dataList.get(0).getBuyDate(); + int i100=0; + for (int k = 0; k < dataList.size(); k++) { + + if(k>0) + { + if(newDate.equals(dataList.get(k).getBuyDate()) && dataList.get(k).getFkSpellbuyProductId() != buyId ){ + continue; + } + } + if(i100++==100) { + break; + } + + spellbuyrecord = dataList.get(k); +// + calendar.setTime(DateUtil.SDateTimeToDate(spellbuyrecord.getBuyDate())); +// Integer y = calendar.get(Calendar.YEAR); +// Integer M = calendar.get(Calendar.MONTH)+1; +// Integer d = calendar.get(Calendar.DAY_OF_MONTH); + Integer h = calendar.get(Calendar.HOUR_OF_DAY); + Integer m = calendar.get(Calendar.MINUTE); + Integer s1 = calendar.get(Calendar.SECOND); + Integer ss1 = calendar.get(Calendar.MILLISECOND); + String sh = ""; + String sm = ""; + String ss = ""; + String sss = ""; + if(h<10){ + sh = "0"+h; + }else{ + sh = h.toString(); + } + if(m<10){ + sm = "0"+m; + }else{ + sm = m.toString(); + } + if(s1<10){ + ss = "0"+s1; + }else{ + ss = s1.toString(); + } + if(ss1<10){ + sss = "00"+ss1; + }else if(ss1<100){ + sss = "0"+ss1; + }else{ + sss = ss1.toString(); + } + DateSUM += Long.parseLong(sh+sm+ss+sss); +// System.err.println("Id:"+spellbuyrecord.getFkSpellbuyProductId()+"date:"+spellbuyrecord.getBuyDate()+"buyID:"+spellbuyrecord.getSpellbuyRecordId()); + + } + System.err.println("NewLotteryUtil DateSUM:"+DateSUM +" "+id); + /** + * 计算出中奖码 + */ + Integer winNumber = Integer.parseInt(String.valueOf(((DateSUM % spellbuyproduct.getSpellbuyPrice())+10000001))); + + System.err.println("NewLotteryUtil winNmuber:"+winNumber+" "+spellbuyproduct.getSpellbuyProductId()); + boolean flag = false; + Integer productPrice = productCart.getProductPrice(); + //需要修改时间的Randomnumber + Randomnumber randomnumberUP = null; + long winCount = 0; + long count = productPrice; + while(!flag){ + List objList = spellbuyrecordService.WinRandomNumber(productCart.getProductId(), winNumber); + if(objList.size()==0){ + winNumber ++; + if(winNumber > (10000000 + productPrice)){ + winNumber = 10000001; + } + }else{ + flag = true; + randomnumberUP = (Randomnumber) objList.get(0)[0]; + } + count --; + if(count == 0){ + winNumber = Integer.parseInt(String.valueOf(((DateSUM % productCart.getProductPrice())+10000001))); + break; + } + } + long price = productPrice; + long sucess=(winNumber-10000000); //我要的中奖号码 2 + long real=DateSUM%price; //真实的中奖号码 1 + long update = DateSUM; //我要的时间总和 14 + + update +=(sucess-real); + winCount = sucess-real; + + if(randomnumberUP!=null){ + String updateDate = randomnumberUP.getBuyDate(); + Long dateTime = DateUtil.SDateTimeToDateBySSS(updateDate).getTime(); + dateTime +=winCount; + Date date = new Date(dateTime); + Spellbuyrecord spellbuyrecord2 = spellbuyrecordService.findById(String.valueOf(randomnumberUP.getSpellbuyrecordId())); + spellbuyrecord2.setBuyDate(DateUtil.DateTimeToStrBySSS(date)); + randomnumberUP.setBuyDate(DateUtil.DateTimeToStrBySSS(date)); + spellbuyrecordService.add(spellbuyrecord2); + randomnumberService.add(randomnumberUP); + } + + List objList = spellbuyrecordService.randomByBuyHistoryByspellbuyProductId(spellbuyproduct.getSpellbuyProductId(),String.valueOf(winNumber)); + Randomnumber randomnumber = (Randomnumber) objList.get(0)[0]; + Spellbuyrecord spellbuyrecord = (Spellbuyrecord) objList.get(0)[1]; + user = (User) objList.get(0)[2]; + + + spellbuyrecord.setSpRandomNo(String.valueOf(winNumber)); + spellbuyrecord.setSpWinningStatus("1"); + spellbuyrecord.setBuyStatus("1"); + spellbuyrecordService.add(spellbuyrecord); + + int productPeriod = spellbuyproduct.getProductPeriod(); + +// int Period = Integer.parseInt(product.getAttribute71()); +// ++Period; +// product.setAttribute71(String.valueOf(Period)); +// product.setStatus(1); +// productService.add(product); + + spellbuyproduct.setSpStatus(1); + spellbuyproductService.add(spellbuyproduct); + + product = productService.findById(String.valueOf(spellbuyproduct.getFkProductId())); + if(product.getStatus()==1){ + List spellbuyproductOld = spellbuyproductService.findSpellbuyproductByProductIdIsStatus(spellbuyproduct.getFkProductId()); + System.err.println("spellbuyproductOld:"+spellbuyproductOld); + System.err.println("spellbuyproductOld-size:"+spellbuyproductOld.size()); + if(spellbuyproductOld.size()==0){ + Spellbuyproduct spellbuyproduct2 = new Spellbuyproduct(); + spellbuyproduct2.setFkProductId(spellbuyproduct.getFkProductId()); + spellbuyproduct2.setProductPeriod(++productPeriod); + spellbuyproduct2.setSpellbuyCount(0); + spellbuyproduct2.setSpellbuyType(0); + spellbuyproduct2.setSpellbuyEndDate(DateUtil.DateTimeToStr(new Date())); + spellbuyproduct2.setSpellbuyPrice(product.getProductPrice()); + spellbuyproduct2.setSpSinglePrice(product.getSinglePrice()); + spellbuyproduct2.setSpellbuyStartDate(DateUtil.DateTimeToStr(new Date())); + spellbuyproduct2.setSpStatus(0); + if(product.getAttribute71().equals("hot")){ + spellbuyproduct2.setSpellbuyType(8); + }else{ + spellbuyproduct2.setSpellbuyType(0); + } + spellbuyproductService.add(spellbuyproduct2); + } + } + + + List list = latestlotteryService.getLatestlotteryBySpellbuyProductIdAndProductIdIsExist(spellbuyproduct.getSpellbuyProductId()); + + if(list.size()==0){ + latestlottery = new Latestlottery(); + latestlottery.setProductId(spellbuyproduct.getFkProductId()); + latestlottery.setProductName(product.getProductName()); + latestlottery.setProductTitle(product.getProductTitle()); + latestlottery.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + latestlottery.setProductImg(product.getHeadImage()); + latestlottery.setProductPeriod(spellbuyproduct.getProductPeriod()); + latestlottery.setAnnouncedTime(newDate); //揭晓时间 + latestlottery.setAnnouncedType(spellbuyproduct.getSpellbuyType()); + latestlottery.setDateSum((DateSUM+winCount)); + latestlottery.setBuyTime(spellbuyrecord.getBuyDate()); //购买时间 + latestlottery.setSpellbuyRecordId(spellbuyrecord.getSpellbuyRecordId()); //购买记录ID + latestlottery.setSpellbuyProductId(spellbuyrecord.getFkSpellbuyProductId()); //某期商品ID + BigDecimal buyNumberCount = randomnumberService.RandomNumberByUserBuyCount(String.valueOf(user.getUserId()), spellbuyproduct.getSpellbuyProductId()); + latestlottery.setBuyNumberCount(Integer.parseInt(String.valueOf(buyNumberCount))); //购买总数 + latestlottery.setRandomNumber(winNumber); //中奖码 + latestlottery.setLocation(user.getIpLocation()); + latestlottery.setUserId(user.getUserId()); + latestlottery.setUserName(UserNameUtil.userName(user)); + latestlottery.setUserFace(user.getFaceImg()); + latestlottery.setStatus(1); + latestlottery.setShareStatus(-1); + latestlottery.setShareId(null); + latestlottery.setBuyType(1); //电商新增字段,1表示拍购,2表示电商普通购买 + latestlotteryService.add(latestlottery); + + } + Struts2Utils.renderJson(latestlottery); + } + }else{ + List list = latestlotteryService.getLatestlotteryBySpellbuyProductIdAndProductIdIsExist(Integer.parseInt(id)); + if(list.size()>0){ + latestlottery = (Latestlottery) list.get(0); + Struts2Utils.renderJson(latestlottery); + } + } + } + + /** + * 即将揭晓 + * @return + */ + + public String upcomingAnnounced(){ + nowDateByUpcomingAnnounced = System.currentTimeMillis(); + if(beginDateByUpcomingAnnounced==null){ + Pagination datePage = spellbuyproductService.upcomingAnnounced(pageNo, pageSize); + List dateList = (List) datePage.getList(); + upcomingAnnouncedList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) dateList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + upcomingAnnouncedList.add(productJSON); + } + beginDateByUpcomingAnnounced = System.currentTimeMillis(); + Struts2Utils.renderJson(upcomingAnnouncedList); + }else{ + if((nowDateByUpcomingAnnounced-beginDateByUpcomingAnnounced)<5000){ + Struts2Utils.renderJson(upcomingAnnouncedList); + }else{ + beginDateByUpcomingAnnounced = System.currentTimeMillis(); + Pagination datePage = spellbuyproductService.upcomingAnnounced(pageNo, pageSize); + List dateList = (List) datePage.getList(); + upcomingAnnouncedList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) dateList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + upcomingAnnouncedList.add(productJSON); + } + Struts2Utils.renderJson(upcomingAnnouncedList); + } + } + + return null; + } + + + /** + *人气TOP榜,用于列表页等页面下部的人气推荐栏目。 + * @return + */ + public String upcomingAnnouncedByTop(){ + nowDateByUpcomingAnnouncedByTop = System.currentTimeMillis(); + if(beginDateByUpcomingAnnouncedByTop==null){ + Pagination datePage = spellbuyproductService.upcomingAnnouncedByTop(pageNo, pageSize); + List dateList = (List) datePage.getList(); + upcomingAnnouncedByTopList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) dateList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + upcomingAnnouncedByTopList.add(productJSON); + } + beginDateByUpcomingAnnouncedByTop = System.currentTimeMillis(); + Struts2Utils.renderJson(upcomingAnnouncedByTopList); + }else{ + if((nowDateByUpcomingAnnouncedByTop-beginDateByUpcomingAnnouncedByTop)<5000){ + Struts2Utils.renderJson(upcomingAnnouncedByTopList); + }else{ + beginDateByUpcomingAnnouncedByTop = System.currentTimeMillis(); + Pagination datePage = spellbuyproductService.upcomingAnnouncedByTop(pageNo, pageSize); + List dateList = (List) datePage.getList(); + upcomingAnnouncedByTopList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) dateList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + upcomingAnnouncedByTopList.add(productJSON); + } + Struts2Utils.renderJson(upcomingAnnouncedByTopList); + } + } + return null; + } + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getLatestlotteryList() { + return latestlotteryList; + } + + public void setLatestlotteryList(List latestlotteryList) { + this.latestlotteryList = latestlotteryList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getPages() { + return pages; + } + + public void setPages(String pages) { + this.pages = pages; + } + + public String getPageString() { + return pageString; + } + + public void setPageString(String pageString) { + this.pageString = pageString; + } + + public ProductCart getProductCart() { + return productCart; + } + + public void setProductCart(ProductCart productCart) { + this.productCart = productCart; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + +} + diff --git a/src/main/java/me/mofun/action/LotteryDetailAction.java b/src/main/java/me/mofun/action/LotteryDetailAction.java new file mode 100644 index 0000000..c15dd63 --- /dev/null +++ b/src/main/java/me/mofun/action/LotteryDetailAction.java @@ -0,0 +1,602 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.DateUtil; +import me.mofun.util.Struts2Utils; +import me.mofun.util.UserNameUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +@SuppressWarnings("unused") +@Component("LotteryDetailAction") +public class LotteryDetailAction extends ActionSupport { + private static final long serialVersionUID = -8369327417332420791L; + + @Autowired + @Qualifier("latestlotteryService") + private LatestlotteryService latestlotteryService; + @Autowired + private RandomnumberService randomnumberService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private ProductImageService productImageService; + + private Latestlottery latestlottery; + private List latestlotteryList; + private List randomNumberJSONList; + private DetailBybuyerJSON detailBybuyerJSON; + private List detailBybuyerJSONList; + private List ParticipateJSONList; + private RandomNumberJSON randomNumberJSON; + private ProductJSON productJSON; + private Randomnumber randomnumber; + private List randomnumberList; + private Spellbuyrecord spellbuyrecord; + private Product product; + private Spellbuyproduct spellbuyproduct; + private User user; + private TreeMap productPeriodList; + private LotteryDetailJSON lotteryDetailJSON; + private List lotteryDetailJSONList; + private List productimageList; + + private String id; + private String spellbuyrecordId; + private int pageNo; + private int pageSize = 20; + private int pageCount; + private int resultCount; + private Integer buyerCount; + private int buyResultCount; + private int newProductId; + private int newProductPeriod; + private String winNumber = ""; + private String startDate; + private String endDate; + private Long DateSUM = 0L; + Calendar calendar = Calendar.getInstance(); + + public String index(){ + randomNumberJSONList = new ArrayList(); + latestlottery = (Latestlottery) latestlotteryService.getLotteryDetail(Integer.parseInt(id)).get(0); + randomnumberList = randomnumberService.LotteryDetailByRandomnumber(latestlottery.getUserId(), latestlottery.getSpellbuyProductId()); + + List objectList = spellbuyproductService.productPeriodList(latestlottery.getProductId()); + productPeriodList = new TreeMap(new Comparator(){ + public int compare(Object o1, Object o2){ + return o2.hashCode()-o1.hashCode(); + } + }); + for (Object[] objects : objectList) { + spellbuyproduct = (Spellbuyproduct) objects[1]; + productPeriodList.put(spellbuyproduct.getProductPeriod(),spellbuyproduct.getSpellbuyProductId()); + } + + productimageList = productImageService.findByProductId(String.valueOf(latestlottery.getProductId()), "show"); + + /** + * 获取该商品最新一期 + */ + product = (Product) objectList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) objectList.get(0)[1]; + if(product.getStatus()==1){ + productJSON = new ProductJSON(); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + } + + resultCount = latestlotteryService.getLotteryDetailBybuyerListByCount(latestlottery.getSpellbuyProductId()); + +// Pagination pagination = spellbuyrecordService.LatestParticipate(id, pageNo, pageSize); +// buyResultCount = pagination.getResultCount(); + + /** + * 得到该商品最后购买记录 + */ +// spellbuyrecord = (Spellbuyrecord) spellbuyrecordService.getEndBuyDateByProduct(latestlottery.getSpellbuyProductId()).get(0); + + startDate = latestlottery.getAnnouncedTime(); +// System.err.println("LotteryDetail startDate:"+startDate+" "+latestlottery.getSpellbuyProductId()); + /** + * 某商品结束日期全站100条购买记录 + */ + Pagination page = spellbuyrecordService.getlotteryDetail(null,startDate, 0, 120); + List dataList = (List) page.getList(); + lotteryDetailJSONList = new ArrayList(); + if(dataList!=null) { + int buyId = ((Spellbuyrecord) dataList.get(0)[1]).getFkSpellbuyProductId(); + int i100=0; + for (int j = 0; j < dataList.size(); j++) { + + if(j>0) + { + if(startDate.equals(((Spellbuyrecord) dataList.get(j)[1]).getBuyDate()) && ((Spellbuyrecord) dataList.get(j)[1]).getFkSpellbuyProductId() != buyId ){ + continue; + } + } + if(i100++==100) + break; + + + lotteryDetailJSON = new LotteryDetailJSON(); + product = (Product) dataList.get(j)[0]; + spellbuyrecord = (Spellbuyrecord) dataList.get(j)[1]; + user = (User) dataList.get(j)[2]; + spellbuyproduct = (Spellbuyproduct) dataList.get(j)[3]; + lotteryDetailJSON.setBuyCount(spellbuyrecord.getBuyPrice()); + lotteryDetailJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + lotteryDetailJSON.setProductName(product.getProductName()); + lotteryDetailJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + lotteryDetailJSON.setProductTitle(product.getProductTitle()); + lotteryDetailJSON.setBuyDate(spellbuyrecord.getBuyDate().split(" ")[0]); + lotteryDetailJSON.setBuyTime(spellbuyrecord.getBuyDate().split(" ")[1]); + + calendar.setTime(DateUtil.SDateTimeToDateBySSS(spellbuyrecord.getBuyDate())); + // Integer y = calendar.get(Calendar.YEAR); + // Integer M = calendar.get(Calendar.MONTH)+1; + // Integer d = calendar.get(Calendar.DAY_OF_MONTH); + Integer h = calendar.get(Calendar.HOUR_OF_DAY); + Integer m = calendar.get(Calendar.MINUTE); + Integer s1 = calendar.get(Calendar.SECOND); + Integer ss1 = calendar.get(Calendar.MILLISECOND); + String sh = ""; + String sm = ""; + String ss = ""; + String sss = ""; + if(h<10){ + sh = "0"+h; + }else{ + sh = h.toString(); + } + if(m<10){ + sm = "0"+m; + }else{ + sm = m.toString(); + } + if(s1<10){ + ss = "0"+s1; + }else{ + ss = s1.toString(); + } + if(ss1<10){ + sss = "00"+ss1; + }else if(ss1<100){ + sss = "0"+ss1; + }else{ + sss = ss1.toString(); + } + lotteryDetailJSON.setDateSum(sh+sm+ss+sss); + // DateSUM += Long.parseLong(sh+sm+ss); + DateSUM = latestlottery.getDateSum(); + + String userName = UserNameUtil.userName(user); + lotteryDetailJSON.setUserName(userName); + lotteryDetailJSON.setUserId(user.getUserId()); + lotteryDetailJSONList.add(lotteryDetailJSON); + // System.err.println("Idabc:"+spellbuyrecord.getFkSpellbuyProductId()+"date:"+spellbuyrecord.getBuyDate()+"buyID:"+spellbuyrecord.getSpellbuyRecordId()); + } + } + + char [] s = String.valueOf(latestlottery.getRandomNumber()).toCharArray(); + for (int i = 0; i < s.length; i++) { + winNumber += "
  • "+s[i]+"
  • "; + } + buyerCount = 0; + for (Randomnumber randomnumber : randomnumberList) { + randomNumberJSON = new RandomNumberJSON(); + String [] randoms = randomnumber.getRandomNumber().split(","); + String numbers = ""; + for (String string : randoms) { + if(string.equals(latestlottery.getRandomNumber().toString())){ + numbers += "" +string+""; + }else{ + numbers += "" +string+""; + } + buyerCount ++; + } + randomNumberJSON.setRandomNumbers(numbers); + randomNumberJSON.setBuyDate(randomnumber.getBuyDate()); + randomNumberJSONList.add(randomNumberJSON); + } + return "index"; + } + + public static void main(String[] args) throws ParseException { +// String number = "10020180"; +// char [] s = number.toCharArray(); +// String str = ""; +// for (int i = 0; i < s.length; i++) { +// str += "
  • "+s[i]+"
  • "; +// } +// System.err.println(str); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + + String date = "2013-06-27 12:02:32.455"; + + System.err.println(sdf.format(new Date())); + + +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(sdf.parse(date)); +// +// System.err.println(calendar.get(Calendar.YEAR)); +// System.err.println(calendar.get(Calendar.MONTH)+1); +// System.err.println(calendar.get(Calendar.DAY_OF_MONTH)); +// System.err.println(calendar.get(Calendar.HOUR_OF_DAY)); +// System.err.println(calendar.get(Calendar.MINUTE)); +// System.err.println(calendar.get(Calendar.SECOND)); + +// Integer y = Integer.parseInt(date.split("-")[0]); +// Integer m = Integer.parseInt(date.split("-")[1]); +//// Integer d = Integer.parseInt(date.lastIndexOf("-",1)); +// System.err.println(y+" "+m+" "); +// System.err.println(StringUtil.splitPreserveAllTokens("-")[1]); + } + + /** + * 获取该商品最新一期 + */ + public void getNewProductResult(){ + productJSON = new ProductJSON(); + List objectList = spellbuyproductService.productPeriodList(Integer.parseInt(id)); + product = (Product) objectList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) objectList.get(0)[1]; + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + Struts2Utils.renderJson(productJSON); + } + + /** + * 购买人详情分页 + * @return + */ + public String getLotteryDetailBybuyerListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = latestlotteryService.getLotteryDetailBybuyerList(Integer.parseInt(id),pageNo, 10); + List dataList = (List) datePage.getList(); + detailBybuyerJSONList = new ArrayList(); + for (int j = 0; j < dataList.size(); j++) { + detailBybuyerJSON = new DetailBybuyerJSON(); + randomnumber = (Randomnumber) dataList.get(j)[0]; + user = (User) dataList.get(j)[1]; + String [] randoms = randomnumber.getRandomNumber().split(","); + String numbers = ""; + for (String string : randoms) { + numbers += "" +string+""; + } + detailBybuyerJSON.setBuyCount(randoms.length+""); + detailBybuyerJSON.setBuyTime(randomnumber.getBuyDate()); + detailBybuyerJSON.setFaceImg(user.getFaceImg()); + detailBybuyerJSON.setRandomNumber(numbers); + detailBybuyerJSON.setUserId(user.getUserId()+""); + String userName = UserNameUtil.userName(user); + detailBybuyerJSON.setUserName(userName); + detailBybuyerJSONList.add(detailBybuyerJSON); + } + Struts2Utils.renderJson(detailBybuyerJSONList); + return null; + } + + /** + * 所有购买记录分页 + * @return + */ + public String buyListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + ParticipateJSONList = new ArrayList(); + Pagination pagination = spellbuyrecordService.LatestParticipate(id, pageNo, pageSize); + List list = (List) pagination.getList(); + for (int i = 0; i < list.size(); i++) { + ParticipateJSON participateJSON = new ParticipateJSON(); + spellbuyrecord = (Spellbuyrecord) list.get(i)[0]; + user = (User) list.get(i)[1]; + String userName = UserNameUtil.userName(user); + participateJSON.setBuyCount(spellbuyrecord.getBuyPrice().toString()); + participateJSON.setBuyDate(spellbuyrecord.getBuyDate()); + participateJSON.setIp_address(user.getIpAddress()); + participateJSON.setIp_location(user.getIpLocation()); + participateJSON.setUserName(userName); + ParticipateJSONList.add(participateJSON); + } + Struts2Utils.renderJson(ParticipateJSONList); + return null; + } + + public void getUserBuyCodeByBuyid(){ + try { + randomnumber = randomnumberService.getUserBuyCodeByBuyid(id, spellbuyrecordId); + if(randomnumber!=null){ + List numberList = new ArrayList(); + String [] randoms = randomnumber.getRandomNumber().split(","); + for (String string : randoms) { + numberList.add(string); + } + Struts2Utils.renderJson(numberList); + } + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getLatestlotteryList() { + return latestlotteryList; + } + + public void setLatestlotteryList(List latestlotteryList) { + this.latestlotteryList = latestlotteryList; + } + + public List getRandomNumberJSONList() { + return randomNumberJSONList; + } + + public void setRandomNumberJSONList(List randomNumberJSONList) { + this.randomNumberJSONList = randomNumberJSONList; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public RandomNumberJSON getRandomNumberJSON() { + return randomNumberJSON; + } + + public void setRandomNumberJSON(RandomNumberJSON randomNumberJSON) { + this.randomNumberJSON = randomNumberJSON; + } + + public List getRandomnumberList() { + return randomnumberList; + } + + public void setRandomnumberList(List randomnumberList) { + this.randomnumberList = randomnumberList; + } + + public Integer getBuyerCount() { + return buyerCount; + } + + public void setBuyerCount(Integer buyerCount) { + this.buyerCount = buyerCount; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public DetailBybuyerJSON getDetailBybuyerJSON() { + return detailBybuyerJSON; + } + + public void setDetailBybuyerJSON(DetailBybuyerJSON detailBybuyerJSON) { + this.detailBybuyerJSON = detailBybuyerJSON; + } + + public List getDetailBybuyerJSONList() { + return detailBybuyerJSONList; + } + + public void setDetailBybuyerJSONList( + List detailBybuyerJSONList) { + this.detailBybuyerJSONList = detailBybuyerJSONList; + } + public int getBuyResultCount() { + return buyResultCount; + } + + public void setBuyResultCount(int buyResultCount) { + this.buyResultCount = buyResultCount; + } + + public List getParticipateJSONList() { + return ParticipateJSONList; + } + + public void setParticipateJSONList(List participateJSONList) { + ParticipateJSONList = participateJSONList; + } + + public int getNewProductId() { + return newProductId; + } + + public void setNewProductId(int newProductId) { + this.newProductId = newProductId; + } + + public int getNewProductPeriod() { + return newProductPeriod; + } + + public void setNewProductPeriod(int newProductPeriod) { + this.newProductPeriod = newProductPeriod; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public TreeMap getProductPeriodList() { + return productPeriodList; + } + + public void setProductPeriodList(TreeMap productPeriodList) { + this.productPeriodList = productPeriodList; + } + + public String getWinNumber() { + return winNumber; + } + + public void setWinNumber(String winNumber) { + this.winNumber = winNumber; + } + + public LotteryDetailJSON getLotteryDetailJSON() { + return lotteryDetailJSON; + } + + public void setLotteryDetailJSON(LotteryDetailJSON lotteryDetailJSON) { + this.lotteryDetailJSON = lotteryDetailJSON; + } + + public List getLotteryDetailJSONList() { + return lotteryDetailJSONList; + } + + public void setLotteryDetailJSONList( + List lotteryDetailJSONList) { + this.lotteryDetailJSONList = lotteryDetailJSONList; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + public Long getDateSUM() { + return DateSUM; + } + + public void setDateSUM(Long dateSUM) { + DateSUM = dateSUM; + } + + public List getProductimageList() { + return productimageList; + } + + public void setProductimageList(List productimageList) { + this.productimageList = productimageList; + } + + public String getSpellbuyrecordId() { + return spellbuyrecordId; + } + + public void setSpellbuyrecordId(String spellbuyrecordId) { + this.spellbuyrecordId = spellbuyrecordId; + } + +} diff --git a/src/main/java/me/mofun/action/MyCartAction.java b/src/main/java/me/mofun/action/MyCartAction.java new file mode 100644 index 0000000..dda35f9 --- /dev/null +++ b/src/main/java/me/mofun/action/MyCartAction.java @@ -0,0 +1,1992 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.tenpay.util.TenpayUtil; +import me.mofun.util.*; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.util.*; + +@SuppressWarnings("unused") +@Component("MyCartAction") +public class MyCartAction extends ActionSupport { + + private static final long serialVersionUID = 837685801735393306L; + RandomUtil randomUtil = new RandomUtil(); + @Autowired + @Qualifier("spellbuyproductService") + private SpellbuyproductService spellbuyproductService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private RandomnumberService randomnumberService; + @Autowired + private UserService userService; + @Autowired + private ConsumetableService consumetableService; + @Autowired + private ConsumerdetailService consumerdetailService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ProductService productService; + @Autowired + private NewLotteryUtil newLotteryUtil; + @Autowired + CommissionqueryService commissionqueryService; + @Autowired + LotteryproductutilService lotteryproductutilService; + @Autowired + CommissionpointsService commissionpointsService; + + //---------------生成订单号 开始------------------------ + //当前时间 yyyyMMddHHmmss + private String currTime = TenpayUtil.getCurrTime(); + //8位日期 + private String strTime = currTime.substring(8, currTime.length()); + //四位随机数 + private String strRandom = TenpayUtil.buildRandom(4) + ""; + //10位序列号,可以自行调整。 + private String strReq = strTime + strRandom; + //订单号,此处用时间加随机数生成,商户根据自己情况调整,只要保持全局唯一就行 + private String out_trade_no = strReq; + + private Consumetable consumetable; + private Consumerdetail consumerdetail; + private List productCartList; + private List successCartList; + private ProductJSON productJSON; + private ProductCart productCart; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private Randomnumber randomnumber; + private Latestlottery latestlottery; + private Commissionquery commissionquery; + private Lotteryproductutil lotteryproductutil; + private Commissionpoints commissionpoints; + private Product product; + private String id; + private User user; + private String userId; + private Integer moneyCount; + private Integer userPayType; + private String integral; //使用福分支付时,前端 js 提交过来的需要扣减的福分值 + private String hidUseBalance; + + private Float singlePrice; //goodscomm.js 中 getShopResultForAjaxList.action 单价 + private Integer quantity; //goodscomm.js 中 getShopResultForAjaxList.action 数量 + + Random random = new Random(); + Calendar calendar = Calendar.getInstance(); + HttpServletRequest request = null; + HttpServletResponse response = null; + + public String index() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + productCartList = new ArrayList(); + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + Integer moneyCount = 0; + Integer productCount = 0; //产品样数?:购物车中的产品种类数量 + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + //moneyCount += count; + moneyCount += count*spellbuyproduct.getSpSinglePrice(); //电商版改造:某商品总金额=商品商量*该商品单价 + + productCount ++; + productCart.setCount(count); + productCart.setMoneyCount(moneyCount); + productCart.setHeadImage(product.getHeadImage()); + productCart.setProductCount(productCount); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + + //productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductId(spellbuyproduct.getFkProductId()); // + + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productCart.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productCart.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + + productCart.setLogicURL(product.getLogicURL()); + productCart.setKeyName(obj.getString("keyName")); + productCart.setKeyValue(obj.getString("keyValue")); + + productCartList.add(productCart); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "index"; + } + + public String getProductCartCount() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + productCount ++; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + Struts2Utils.renderText(String.valueOf(productCount)); + return null; + } + + + /** + * 获得购物车数据 + * 当显示右侧购物篮DIV 时, cartool.js 的 var showCart = function () 函数进行 ajax 调用 /mycart/getMyProductCart.html 获取购物篮相关数据 + * @return + * @throws UnsupportedEncodingException + */ + public String getMyProductCart() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + productCartList = new ArrayList(); + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + Integer moneyCount = 0; //总金额 + Integer productCount = 0; //商品数 + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentBuyCount = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + + //moneyCount += count; + moneyCount+=count * spellbuyproduct.getSpSinglePrice(); //电商版改造:总金额=商品数量*商品单价 + + productCount ++; + productCart.setCount(count); + productCart.setMoneyCount(moneyCount); + productCart.setHeadImage(product.getHeadImage()); + productCart.setProductCount(productCount); + //productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductId(spellbuyproduct.getFkProductId()); //for test + + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productCart.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productCart.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + + productCart.setLogicURL(product.getLogicURL()); + //productCart.setKeyName(obj.getString("keyName")); + //productCart.setKeyValue(obj.getString("keyValue")); + + productCartList.add(productCart); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + Struts2Utils.renderJson(productCartList); + return null; + } + + + /** + * 点击添加到购物车按钮动作 + * carttool.js 中的 _InsertIntoCart = function () 函数执行进行 ajax 调用 mycart/buyProductClick.html + * @return JSON 字符串,例如: {"productCount":"2","moneyCount":"15"} + * @throws UnsupportedEncodingException + */ + public String buyProductClick() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + productCartList = new ArrayList(); + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + Integer moneyCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + Product productTmp = (Product) proList.get(0)[0]; + Spellbuyproduct spellbuyproductTmp = (Spellbuyproduct) proList.get(0)[1]; + moneyCount += obj.getInt("num")*spellbuyproductTmp.getSpSinglePrice(); //电商版改造:金额=商品数量*商品单价 + + } + StringBuilder sb = new StringBuilder(); +// sb.append('['); + sb.append('{'); + sb.append("\"productCount\":\"").append(array.size()).append("\","); + sb.append("\"moneyCount\":\"").append(moneyCount).append("\""); + +// sb.append("\"keyName\":\"").append(obj.getInt("keyName")).append("\""); +// sb.append("\"keyValue\":\"").append(obj.getInt("keyValue")).append("\""); +// sb.append("\"keyCount\":\"").append(obj.getInt("keyCount")).append("\""); + + sb.append('}'); + sb.append(","); + sb.deleteCharAt(sb.length()-1); +// sb.append(']'); + Struts2Utils.renderJson(sb.toString()); + } + return null; + } + + //加入购物车立即购买/最后支付界面 http://127.0.0.1:8080/mycart/payment.html + public String payment() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + productCartList = new ArrayList(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + } + } + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + Integer moneyCount = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + //moneyCount += count; + moneyCount += obj.getInt("num")*spellbuyproduct.getSpSinglePrice(); //电商版改造:金额=商品数量*商品单价 + + productCount ++; + productCart.setCount(count); + productCart.setMoneyCount(moneyCount); + productCart.setHeadImage(product.getHeadImage()); + productCart.setProductCount(productCount); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + //productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductId(spellbuyproduct.getFkProductId()); //test + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productCart.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productCart.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + + productCart.setLogicURL(product.getLogicURL()); + productCart.setKeyName(obj.getString("keyName")); + productCart.setKeyValue(obj.getString("keyValue")); + + productCartList.add(productCart); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "payment"; + } + + //支付 + public String goPay() throws UnsupportedEncodingException, InterruptedException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String buyproduct ="";// 已经被买完的商品 + Cookie[] cookies = request.getCookies(); + productCartList = new ArrayList(); + successCartList = new ArrayList(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + } + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + //总购买钱数 + Integer moneyCount = 0; + Integer productCount = 0; + Integer allCount = 0; //电商版改造:各类商品总购买数量 + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ //1元拍购版中:SpellbuyPrice作为总拍购价;普通电商版中:SpellbuyPrice作为总库存量 + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + + allCount += count; //各类产品总购买数量 + + //moneyCount += count; + moneyCount += count*spellbuyproduct.getSpSinglePrice(); //数量*单价 + + productCount ++; + productCart.setCount(count); + productCart.setHeadImage(product.getHeadImage()); + productCart.setMoneyCount(moneyCount); + productCart.setProductCount(productCount); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productCart.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productCart.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + + productCart.setLogicURL(product.getLogicURL()); + productCart.setKeyName(obj.getString("keyName")); + productCart.setKeyValue(obj.getString("keyValue")); + + productCartList.add(productCart); + flag = true; + }else{ + buyproduct += "您购买的商品中 " + product.getProductName() + " 已经满员.
    "; +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// flag = false; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + if(StringUtil.isNotBlank(userId)){ + user = userService.findById(userId); + }else{ + flag = false; + } + + if(flag){ + //开始记录入消费表 consumeTable 中 + consumetable = new Consumetable(); + double money = Double.parseDouble(String.valueOf(moneyCount)); + + //consumetable.setBuyCount(moneyCount); + consumetable.setBuyCount(allCount); //本次消费各类商品的总购买件数 + + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + + if(userPayType==1){ + consumetable.setInterfaceType("余额支付"); + }else if(userPayType==2){ + consumetable.setInterfaceType("福分抵扣"); + }else{ + consumetable.setInterfaceType("福分+余额"); + } + consumetable.setMoney(money); + consumetable.setOutTradeNo(out_trade_no); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); + + //真正开始结算:循环处理购买各类商品所需支付的金额 + for (final ProductCart productCart : productCartList) { + //真正要购买的数量 + Integer count = 0; + try { + consumerdetail = new Consumerdetail(); + spellbuyrecord = new Spellbuyrecord(); + productJSON = new ProductJSON(); + commissionquery = new Commissionquery(); + spellbuyproduct = spellbuyproductService.findById(productCart.getProductId().toString()); + + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+productCart.getCount()) > productCart.getProductPrice()){ + count = productCart.getProductPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = productCart.getCount(); + } + + if(count>0){ + try { + if(userPayType==1){ // 余额方式支付 + //if(user.getBalance()>=count){ + if(user.getBalance()>=count*spellbuyproduct.getSpSinglePrice()){ //余额>=该项商品购买数量*该项商品单价 + //Double temp = user.getBalance() - count; + Double temp = user.getBalance() - count*spellbuyproduct.getSpSinglePrice(); //余额-数量*单价 + + Integer points = user.getCommissionPoints(); + user.setBalance(temp); + //user.setCommissionPoints(points+(count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())); + user.setCommissionPoints(points+(count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())); //电商版改造:福分=福分余额+新增福分=福分余额+(商品数*商品价格*购买商品福分奖励系数) + + consumerdetail.setBuyCount(count); + + //consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))*spellbuyproduct.getSpSinglePrice()); //数量*单价 + + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + + if(StringUtils.isNotBlank(productCart.getLogicURL())&&StringUtils.isNotBlank(productCart.getKeyValue())) + consumerdetail.setProductTitle(productCart.getProductTitle()+"("+productCart.getKeyValue()+")"); + else + consumerdetail.setProductTitle(productCart.getProductTitle()); + + consumerdetailService.add(consumerdetail); + + //用户消费后,邀请者获得的佣金计算 + if(user.getInvite()!=null){ //邀请者userId不会为空 + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + + //userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + //userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); //电商版改造:佣金计算基础=交易金额*佣金比率;交易金额=交易数量*商品单价 + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + + userService.add(userCommission); + + //佣金获得明细入库 + //commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))*spellbuyproduct.getSpSinglePrice()); //数量*单价 + + //commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); //电商版改造:佣金数=商品购买数量*商品单价*佣金比例(0.01) + + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + + //福分获得明细入库 + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + + //commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count+"元获得福分"); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count*spellbuyproduct.getSpSinglePrice()+"元获得福分"); //更改为数量*单价 + + //commissionpoints.setPay("+"+count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct()); + commissionpoints.setPay("+"+count*spellbuyproduct.getSpSinglePrice()*ApplicationListenerImpl.sysConfigureJson.getBuyProduct()); //电商版改造: 福分=商品数量*商品价格*福分奖励系数 + + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + flag = false; + break; + } + }else if(userPayType==2){//福分抵扣方式支付 + //if((user.getCommissionPoints()/100)>=count){ + if((user.getCommissionPoints()/100)>=count*spellbuyproduct.getSpSinglePrice()){ //电商版改造 + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + userService.add(user); + + consumerdetail.setBuyCount(count); + //consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))*spellbuyproduct.getSpSinglePrice()); //数量*单价 + + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + + if(StringUtils.isNotBlank(productCart.getLogicURL())&&StringUtils.isNotBlank(productCart.getKeyValue())) + consumerdetail.setProductTitle(productCart.getProductTitle()+"("+productCart.getKeyValue()+")"); + else + consumerdetail.setProductTitle(productCart.getProductTitle()); + + consumerdetailService.add(consumerdetail); + + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + flag = false; + break; + } + }else{//积分+余额方式支付 + + //积分+余额支付:先处理余额支付 + if(user.getBalance() >= Integer.parseInt(hidUseBalance)){ + Double temp = user.getBalance() - Integer.parseInt(hidUseBalance); + Integer points = user.getCommissionPoints(); + user.setBalance(temp); + user.setCommissionPoints(points+Integer.parseInt(hidUseBalance)); + userService.add(user); + + //邀请佣金计算 + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + + //userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + //userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); //电商版改造 + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + + userService.add(userCommission); + + //佣金明细入库 + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(hidUseBalance))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(hidUseBalance))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + + //福分增加 + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+hidUseBalance+"元获得福分"); + commissionpoints.setPay("+"+hidUseBalance); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + }else{ + flag = false; + break; + } + //积分+余额支付:接着处理福分支付逻辑 + if(user.getCommissionPoints()>=Integer.parseInt(integral)){ + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + userService.add(user); + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + } else{ + flag = false; + break; + } + consumerdetail.setBuyCount(count); + + //consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))); //电商版改造:商品数量*商品单价 + + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + + if(StringUtils.isNotBlank(productCart.getLogicURL())&&StringUtils.isNotBlank(productCart.getKeyValue())) + consumerdetail.setProductTitle(productCart.getProductTitle()+"("+productCart.getKeyValue()+")"); + else + consumerdetail.setProductTitle(productCart.getProductTitle()); + + consumerdetailService.add(consumerdetail); + } + } catch (Exception e) { + flag = false; + break; + } + + if(flag){ + spellbuyproduct.setSpellbuyCount(spellbuyproduct.getSpellbuyCount()+count); + //if(spellbuyproduct.getSpellbuyCount()>=productCart.getProductPrice()){ + if(spellbuyproduct.getSpellbuyCount()*spellbuyproduct.getSpSinglePrice()>=productCart.getProductPrice()){ //电商版改造:购买数量*单价>=商品定价 + + //spellbuyproduct.setSpellbuyCount(productCart.getProductPrice()); + spellbuyproduct.setSpellbuyCount((int)Math.ceil (productCart.getProductPrice()/spellbuyproduct.getSpSinglePrice())); //电商版改造:购买数量*单价>=商品定价 + + //开奖状态 + spellbuyproduct.setSpStatus(2); + spellbuyproduct.setSpellbuyEndDate(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + //放入开奖表 + lotteryproductutil = new Lotteryproductutil(); + lotteryproductutil.setLotteryProductEndDate(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + lotteryproductutil.setLotteryProductId(spellbuyproduct.getSpellbuyProductId()); + lotteryproductutil.setLotteryProductImg(productCart.getHeadImage()); + lotteryproductutil.setLotteryProductName(productCart.getProductName()); + lotteryproductutil.setLotteryProductPeriod(spellbuyproduct.getProductPeriod()); + lotteryproductutil.setLotteryProductPrice(spellbuyproduct.getSpellbuyPrice()); + lotteryproductutil.setLotteryProductTitle(productCart.getProductTitle()); + lotteryproductutilService.add(lotteryproductutil); + } + spellbuyproductService.add(spellbuyproduct); + + spellbuyrecord.setFkSpellbuyProductId(spellbuyproduct.getSpellbuyProductId()); + spellbuyrecord.setBuyer(user.getUserId()); + + //spellbuyrecord.setBuyPrice(count); + spellbuyrecord.setBuyPrice(count*spellbuyproduct.getSpSinglePrice()); //电商版改造:购买数量*该期商品单价 + + String ip = Struts2Utils.getRequest().getHeader("X-Real-IP"); + if(ip==null){ + ip = "127.0.0.1"; + } + spellbuyrecord.setBuyIp(ip); + spellbuyrecord.setBuyLocal(RegisterAction.seeker.getAddress(ip)); + spellbuyrecord.setBuyDate(DateUtil.DateTimeToStrBySSS(new Date())); + spellbuyrecord.setSpWinningStatus("0"); + spellbuyrecord.setBuyStatus("0"); + spellbuyrecord.setSpRandomNo(""); + spellbuyrecordService.add(spellbuyrecord); + randomnumber = new Randomnumber(); + randomnumber.setProductId(productCart.getProductId()); + + List RandomnumberList = randomnumberService.query(" from Randomnumber where productId='"+ spellbuyproduct.getSpellbuyProductId()+"'"); + List oldRandomList = new ArrayList(); + for (Randomnumber randomnumber : RandomnumberList) { + if(randomnumber.getRandomNumber().contains(",")){ + String[] rs = randomnumber.getRandomNumber().split(","); + for (String string : rs) { + oldRandomList.add(string); + } + + }else{ + oldRandomList.add(randomnumber.getRandomNumber()); + } + } + + //randomnumber.setRandomNumber(randomUtil.newRandom(count,spellbuyproduct.getSpellbuyPrice(),oldRandomList)); + randomnumber.setRandomNumber(randomUtil.newRandom(count*spellbuyproduct.getSpSinglePrice(),spellbuyproduct.getSpellbuyPrice(),oldRandomList)); //电商版改造:每一元可以获得一个竞拍号码,获得的竞拍号码个数=商品购买数量*该期商品单价 + + randomnumber.setSpellbuyrecordId(spellbuyrecord.getSpellbuyRecordId()); + randomnumber.setBuyDate(spellbuyrecord.getBuyDate()); + randomnumber.setUserId(Integer.parseInt(userId)); + randomnumberService.add(randomnumber); + + //经验值增加 + Integer experience = user.getExperience(); + + //experience += (count*10); + experience += (count*spellbuyproduct.getSpSinglePrice()*10); //电商版改造:经验值=购买数量*该期商品单价*10 + + user.setExperience(experience); + userService.add(user); + + + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductId(productCart.getProductId()); + productJSON.setProductName(productCart.getProductName()); + productJSON.setProductPeriod(productCart.getProductPeriod()); + productJSON.setProductTitle(productCart.getProductTitle()); + productJSON.setBuyCount(count); + + productJSON.setPayResult(true); + productJSON.setLogicURL(productCart.getLogicURL()); + productJSON.setKeyName(productCart.getKeyName()); + productJSON.setKeyValue(productCart.getKeyValue()); + + successCartList.add(productJSON); + } + + +// if(spellbuyproduct.getSpStatus()==2){ +// /** +// * 开奖工具类 +// */ +// String lotteryId = MD5Util.encode(String.valueOf(spellbuyproduct.getSpellbuyProductId())); +// if(MemCachedClientHelp.getIMemcachedCache().get(lotteryId)==null){ +// MemCachedClientHelp.getIMemcachedCache().put(lotteryId, "y",new Date(12*60*60*1000)); +// new Thread(){ +// public void run(){ +// try { +// newLotteryUtil.lottery(productCart); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// }.start(); +// } +// } + } + } catch (Exception e) { + flag= false; + e.printStackTrace(); + } + } + + } + + if(flag){ + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("products",null); + cookie.setMaxAge(0); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + } + } + + return "success"; + } + + /** + * 获取支付结果。 + * 分类商品列表中,点击 立即选购 ,弹出确认支付对话框,点击确认支付时用。 + * 前端程序:/mycart/index.jsp 的 /js/goodscomm.js ajax 调用 /mycart/getShopResult.action?id=... + * 参考自上面的 goPay() action 函数 + * @author lwgboy + * @return + * @throws UnsupportedEncodingException + * @throws InterruptedException + */ + public String getShopResult() throws UnsupportedEncodingException, InterruptedException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String buyproduct ="";// 已经被买完的商品 + Cookie[] cookies = request.getCookies(); + productCartList = new ArrayList(); + successCartList = new ArrayList(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + } + else + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + Integer moneyCount = 0; //总购买钱数 + Integer productCount = 0; //产品数 + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + //moneyCount += count; + moneyCount += count*spellbuyproduct.getSpSinglePrice(); //电商版改造:金额=商品数量*商品金额 + + productCount ++; + productCart.setCount(count); + productCart.setHeadImage(product.getHeadImage()); + productCart.setMoneyCount(moneyCount); + productCart.setProductCount(productCount); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productCart.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productCart.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + + productCart.setLogicURL(product.getLogicURL()); + productCart.setKeyName(obj.getString("keyName")); + productCart.setKeyValue(obj.getString("keyValue")); + + productCartList.add(productCart); + flag = true; + }else{ + buyproduct += "您购买的商品中 " + product.getProductName() + " 已经满员.
    "; +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// flag = false; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + if(StringUtil.isNotBlank(userId)){ + user = userService.findById(userId); + }else{ + flag = false; + } + + if(flag){ + consumetable = new Consumetable(); + double money = Double.parseDouble(String.valueOf(moneyCount)); + consumetable.setBuyCount(moneyCount); + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + + userPayType=1; + + if(userPayType==1){ + consumetable.setInterfaceType("余额支付"); + }else if(userPayType==2){ + consumetable.setInterfaceType("福分抵扣"); + }else{ + consumetable.setInterfaceType("福分+余额"); + } + consumetable.setMoney(money); + consumetable.setOutTradeNo(out_trade_no); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); + + for (final ProductCart productCart : productCartList) { + //真正要购买的数量 + Integer count = 0; + try { + consumerdetail = new Consumerdetail(); + spellbuyrecord = new Spellbuyrecord(); + productJSON = new ProductJSON(); + commissionquery = new Commissionquery(); + spellbuyproduct = spellbuyproductService.findById(productCart.getProductId().toString()); + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+productCart.getCount()) > productCart.getProductPrice()){ + count = productCart.getProductPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = productCart.getCount(); + } + + if(count>0){ + try { + if(userPayType==1){// 余额支付 + + //if(user.getBalance()>=count){ + if(user.getBalance()>=count*spellbuyproduct.getSpSinglePrice()){ + + //Double temp = user.getBalance() - count; + Double temp = user.getBalance() - count*spellbuyproduct.getSpSinglePrice(); + + Integer points = user.getCommissionPoints(); + user.setBalance(temp); + + //user.setCommissionPoints(points+(count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())); + user.setCommissionPoints(points+(count*spellbuyproduct.getSpSinglePrice()*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())); + + consumerdetail.setBuyCount(count); + + //consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))); //电商版改造 + + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + + if(StringUtils.isNotBlank(productCart.getLogicURL())&&StringUtils.isNotBlank(productCart.getKeyValue())) + consumerdetail.setProductTitle(productCart.getProductTitle()+"("+productCart.getKeyValue()+")"); + else + consumerdetail.setProductTitle(productCart.getProductTitle()); + + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); +// userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); +// userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); //电商版改造 + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + + userService.add(userCommission); + + //commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))); //电商版改造 + + //commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); //电商版改造 + + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + //commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count+"元获得福分"); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count*spellbuyproduct.getSpSinglePrice()+"元获得福分");//电商版改造 + + //commissionpoints.setPay("+"+count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct()); + commissionpoints.setPay("+"+count*spellbuyproduct.getSpSinglePrice()*ApplicationListenerImpl.sysConfigureJson.getBuyProduct()); //电商版改造 + + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + flag = false; + break; + } + }else if(userPayType==2){//福分抵扣 + + //if((user.getCommissionPoints()/100)>=count){ + if((user.getCommissionPoints()/100)>=count*spellbuyproduct.getSpSinglePrice()){ + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + userService.add(user); + consumerdetail.setBuyCount(count); + + //consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))); //电商版改造 + + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + + if(StringUtils.isNotBlank(productCart.getLogicURL())&&StringUtils.isNotBlank(productCart.getKeyValue())) + consumerdetail.setProductTitle(productCart.getProductTitle()+"("+productCart.getKeyValue()+")"); + else + consumerdetail.setProductTitle(productCart.getProductTitle()); + + consumerdetailService.add(consumerdetail); + + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + flag = false; + break; + } + }else{ + //余额福分 + if(user.getBalance() >= Integer.parseInt(hidUseBalance)){ + Double temp = user.getBalance() - Integer.parseInt(hidUseBalance); + Integer points = user.getCommissionPoints(); + user.setBalance(temp); + user.setCommissionPoints(points+Integer.parseInt(hidUseBalance)); + userService.add(user); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + //userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + //userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(hidUseBalance))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(hidUseBalance))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+hidUseBalance+"元获得福分"); + commissionpoints.setPay("+"+hidUseBalance); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + }else{ + flag = false; + break; + } + if(user.getCommissionPoints()>=Integer.parseInt(integral)){ + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + userService.add(user); + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + } else{ + flag = false; + break; + } + consumerdetail.setBuyCount(count); + + //consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))); + + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + + if(StringUtils.isNotBlank(productCart.getLogicURL())&&StringUtils.isNotBlank(productCart.getKeyValue())) + consumerdetail.setProductTitle(productCart.getProductTitle()+"("+productCart.getKeyValue()+")"); + else + consumerdetail.setProductTitle(productCart.getProductTitle()); + + consumerdetailService.add(consumerdetail); + } + } catch (Exception e) { + flag = false; + break; + } + + if(flag){ + spellbuyproduct.setSpellbuyCount(spellbuyproduct.getSpellbuyCount()+count); + //if(spellbuyproduct.getSpellbuyCount()>=productCart.getProductPrice()){ + // spellbuyproduct.setSpellbuyCount(productCart.getProductPrice()); + + if(spellbuyproduct.getSpellbuyCount()*spellbuyproduct.getSpSinglePrice()>=productCart.getProductPrice()){ //电商版改造:购买数量*单价>=商品定价 + spellbuyproduct.setSpellbuyCount((int)Math.ceil(productCart.getProductPrice()/spellbuyproduct.getSpSinglePrice())); //电商改造版 + + //开奖状态 + spellbuyproduct.setSpStatus(2); + spellbuyproduct.setSpellbuyEndDate(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + + //放入开奖表 + lotteryproductutil = new Lotteryproductutil(); + lotteryproductutil.setLotteryProductEndDate(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + lotteryproductutil.setLotteryProductId(spellbuyproduct.getSpellbuyProductId()); + lotteryproductutil.setLotteryProductImg(productCart.getHeadImage()); + lotteryproductutil.setLotteryProductName(productCart.getProductName()); + lotteryproductutil.setLotteryProductPeriod(spellbuyproduct.getProductPeriod()); + lotteryproductutil.setLotteryProductPrice(spellbuyproduct.getSpellbuyPrice()); + lotteryproductutil.setLotteryProductTitle(productCart.getProductTitle()); + lotteryproductutilService.add(lotteryproductutil); + } + spellbuyproductService.add(spellbuyproduct); + + spellbuyrecord.setFkSpellbuyProductId(spellbuyproduct.getSpellbuyProductId()); + spellbuyrecord.setBuyer(user.getUserId()); + + //spellbuyrecord.setBuyPrice(count); + spellbuyrecord.setBuyPrice(count*spellbuyproduct.getSpSinglePrice()); //电商改造版 + + spellbuyrecord.setBuyDate(DateUtil.DateTimeToStrBySSS(new Date())); + spellbuyrecord.setSpWinningStatus("0"); + spellbuyrecord.setBuyStatus("0"); + spellbuyrecord.setSpRandomNo(""); + spellbuyrecordService.add(spellbuyrecord); + randomnumber = new Randomnumber(); + randomnumber.setProductId(productCart.getProductId()); + + List RandomnumberList = randomnumberService.query(" from Randomnumber where productId='"+ spellbuyproduct.getSpellbuyProductId()+"'"); + List oldRandomList = new ArrayList(); + for (Randomnumber randomnumber : RandomnumberList) { + if(randomnumber.getRandomNumber().contains(",")){ + String[] rs = randomnumber.getRandomNumber().split(","); + for (String string : rs) { + oldRandomList.add(string); + } + + }else{ + oldRandomList.add(randomnumber.getRandomNumber()); + } + } + //randomnumber.setRandomNumber(randomUtil.newRandom(count,spellbuyproduct.getSpellbuyPrice(),oldRandomList)); + randomnumber.setRandomNumber(randomUtil.newRandom(count*spellbuyproduct.getSpSinglePrice(),spellbuyproduct.getSpellbuyPrice(),oldRandomList)); //电商改造版,每消费一元可获得一个拍购码 + + randomnumber.setSpellbuyrecordId(spellbuyrecord.getSpellbuyRecordId()); + randomnumber.setBuyDate(spellbuyrecord.getBuyDate()); + randomnumber.setUserId(Integer.parseInt(userId)); + randomnumberService.add(randomnumber); + + Integer experience = user.getExperience(); + + //experience += (count*10); + experience += (count*spellbuyproduct.getSpSinglePrice()*10); //电商改造版 + + user.setExperience(experience); + userService.add(user); + + + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductId(productCart.getProductId()); + productJSON.setProductName(productCart.getProductName()); + productJSON.setProductPeriod(productCart.getProductPeriod()); + productJSON.setProductTitle(productCart.getProductTitle()); + productJSON.setBuyCount(count); + + productJSON.setPayResult(true); + productJSON.setLogicURL(productCart.getLogicURL()); + productJSON.setKeyName(productCart.getKeyName()); + productJSON.setKeyValue(productCart.getKeyValue()); + + successCartList.add(productJSON); + } + + +// if(spellbuyproduct.getSpStatus()==2){ +// /** +// * 开奖工具类 +// */ +// String lotteryId = MD5Util.encode(String.valueOf(spellbuyproduct.getSpellbuyProductId())); +// if(MemCachedClientHelp.getIMemcachedCache().get(lotteryId)==null){ +// MemCachedClientHelp.getIMemcachedCache().put(lotteryId, "y",new Date(12*60*60*1000)); +// new Thread(){ +// public void run(){ +// try { +// newLotteryUtil.lottery(productCart); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// }.start(); +// } +// } + } + } catch (Exception e) { + flag= false; + e.printStackTrace(); + } + } + + } + + if(flag){ + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("products",null); + cookie.setMaxAge(0); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + } + } + Struts2Utils.renderText("success"); + return null; + //return "success"; + } + + /** + * 用于列表页 Ajax 支付调用:http://127.0.0.1:8080/list/date20.html + * goodscomm.js ajax : "/mycart/getShopResultForAjaxList.action?id=...&quantity=..." + * @return + * @throws UnsupportedEncodingException + * @throws InterruptedException + */ + public String getShopResultForAjaxList() throws UnsupportedEncodingException, InterruptedException{ + if(!StringUtils.isNotEmpty(id)) + return null; + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String buyproduct ="";// 已经被买完的商品 + Cookie[] cookies = request.getCookies(); + productCartList = new ArrayList(); + successCartList = new ArrayList(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + } + else + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + Integer moneyCount = 0; //总购买钱数 + Integer productCount = 0; //产品数 + //if(array!=null && !array.toString().equals("[{}]")){ + if((StringUtils.isNotEmpty(id))&&quantity!=null&&quantity>0){ + try { + productCart = new ProductCart(); + //List proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + //List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(id)); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+quantity) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = (int)quantity;; + } + //moneyCount += count; + moneyCount += count*spellbuyproduct.getSpSinglePrice(); //电商版改造:金额=商品数量*商品金额 + + productCount ++; + productCart.setCount(count); + productCart.setHeadImage(product.getHeadImage()); + productCart.setMoneyCount(moneyCount); + productCart.setProductCount(productCount); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productCart.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productCart.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + + productCart.setLogicURL(product.getLogicURL()); + //productCart.setKeyName(obj.getString("keyName")); + //productCart.setKeyValue(obj.getString("keyValue")); + + productCartList.add(productCart); + flag = true; + }else{ + buyproduct += "您购买的商品中 " + product.getProductName() + " 已经满员.
    "; +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// flag = false; + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + + if(StringUtil.isNotBlank(userId)){ + user = userService.findById(userId); + }else{ + flag = false; + } + + if(flag){ + consumetable = new Consumetable(); + double money = Double.parseDouble(String.valueOf(moneyCount)); + consumetable.setBuyCount(moneyCount); + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + + userPayType=1; + + if(userPayType==1){ + consumetable.setInterfaceType("余额支付"); + }else if(userPayType==2){ + consumetable.setInterfaceType("福分抵扣"); + }else{ + consumetable.setInterfaceType("福分+余额"); + } + consumetable.setMoney(money); + consumetable.setOutTradeNo(out_trade_no); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); + + for (final ProductCart productCart : productCartList) { + //真正要购买的数量 + Integer count = 0; + try { + consumerdetail = new Consumerdetail(); + spellbuyrecord = new Spellbuyrecord(); + productJSON = new ProductJSON(); + commissionquery = new Commissionquery(); + spellbuyproduct = spellbuyproductService.findById(productCart.getProductId().toString()); + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+productCart.getCount()) > productCart.getProductPrice()){ + count = productCart.getProductPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = productCart.getCount(); + } + + if(count>0){ + try { + if(userPayType==1){// 余额支付 + + //if(user.getBalance()>=count){ + if(user.getBalance()>=count*spellbuyproduct.getSpSinglePrice()){ + + //Double temp = user.getBalance() - count; + Double temp = user.getBalance() - count*spellbuyproduct.getSpSinglePrice(); + + Integer points = user.getCommissionPoints(); + user.setBalance(temp); + + //user.setCommissionPoints(points+(count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())); + user.setCommissionPoints(points+(count*spellbuyproduct.getSpSinglePrice()*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())); + + consumerdetail.setBuyCount(count); + + //consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))); //电商版改造 + + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + + if(StringUtils.isNotBlank(productCart.getLogicURL())&&StringUtils.isNotBlank(productCart.getKeyValue())) + consumerdetail.setProductTitle(productCart.getProductTitle()+"("+productCart.getKeyValue()+")"); + else + consumerdetail.setProductTitle(productCart.getProductTitle()); + + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); +// userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); +// userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); //电商版改造 + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + + userService.add(userCommission); + + //commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))); //电商版改造 + + //commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); //电商版改造 + + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + //commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count+"元获得福分"); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count*spellbuyproduct.getSpSinglePrice()+"元获得福分");//电商版改造 + + //commissionpoints.setPay("+"+count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct()); + commissionpoints.setPay("+"+count*spellbuyproduct.getSpSinglePrice()*ApplicationListenerImpl.sysConfigureJson.getBuyProduct()); //电商版改造 + + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + flag = false; + break; + } + }else if(userPayType==2){//福分抵扣 + + //if((user.getCommissionPoints()/100)>=count){ + if((user.getCommissionPoints()/100)>=count*spellbuyproduct.getSpSinglePrice()){ + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + userService.add(user); + consumerdetail.setBuyCount(count); + + //consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))); //电商版改造 + + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + + if(StringUtils.isNotBlank(productCart.getLogicURL())&&StringUtils.isNotBlank(productCart.getKeyValue())) + consumerdetail.setProductTitle(productCart.getProductTitle()+"("+productCart.getKeyValue()+")"); + else + consumerdetail.setProductTitle(productCart.getProductTitle()); + + consumerdetailService.add(consumerdetail); + + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + flag = false; + break; + } + }else{ + //余额福分 + if(user.getBalance() >= Integer.parseInt(hidUseBalance)){ + Double temp = user.getBalance() - Integer.parseInt(hidUseBalance); + Integer points = user.getCommissionPoints(); + user.setBalance(temp); + user.setCommissionPoints(points+Integer.parseInt(hidUseBalance)); + userService.add(user); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + //userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + //userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(hidUseBalance))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(hidUseBalance))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+hidUseBalance+"元获得福分"); + commissionpoints.setPay("+"+hidUseBalance); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + }else{ + flag = false; + break; + } + if(user.getCommissionPoints()>=Integer.parseInt(integral)){ + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + userService.add(user); + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + } else{ + flag = false; + break; + } + consumerdetail.setBuyCount(count); + + //consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count*spellbuyproduct.getSpSinglePrice()))); + + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + + if(StringUtils.isNotBlank(productCart.getLogicURL())&&StringUtils.isNotBlank(productCart.getKeyValue())) + consumerdetail.setProductTitle(productCart.getProductTitle()+"("+productCart.getKeyValue()+")"); + else + consumerdetail.setProductTitle(productCart.getProductTitle()); + + consumerdetailService.add(consumerdetail); + } + } catch (Exception e) { + flag = false; + break; + } + + if(flag){ + spellbuyproduct.setSpellbuyCount(spellbuyproduct.getSpellbuyCount()+count); + //if(spellbuyproduct.getSpellbuyCount()>=productCart.getProductPrice()){ + // spellbuyproduct.setSpellbuyCount(productCart.getProductPrice()); + + if(spellbuyproduct.getSpellbuyCount()*spellbuyproduct.getSpSinglePrice()>=productCart.getProductPrice()){ //电商版改造:购买数量*单价>=商品定价 + spellbuyproduct.setSpellbuyCount((int)Math.ceil(productCart.getProductPrice()/spellbuyproduct.getSpSinglePrice())); //电商改造版 + + //开奖状态 + spellbuyproduct.setSpStatus(2); + spellbuyproduct.setSpellbuyEndDate(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + + //放入开奖表 + lotteryproductutil = new Lotteryproductutil(); + lotteryproductutil.setLotteryProductEndDate(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + lotteryproductutil.setLotteryProductId(spellbuyproduct.getSpellbuyProductId()); + lotteryproductutil.setLotteryProductImg(productCart.getHeadImage()); + lotteryproductutil.setLotteryProductName(productCart.getProductName()); + lotteryproductutil.setLotteryProductPeriod(spellbuyproduct.getProductPeriod()); + lotteryproductutil.setLotteryProductPrice(spellbuyproduct.getSpellbuyPrice()); + lotteryproductutil.setLotteryProductTitle(productCart.getProductTitle()); + lotteryproductutilService.add(lotteryproductutil); + } + spellbuyproductService.add(spellbuyproduct); + + spellbuyrecord.setFkSpellbuyProductId(spellbuyproduct.getSpellbuyProductId()); + spellbuyrecord.setBuyer(user.getUserId()); + + //spellbuyrecord.setBuyPrice(count); + spellbuyrecord.setBuyPrice(count*spellbuyproduct.getSpSinglePrice()); //电商改造版 + + spellbuyrecord.setBuyDate(DateUtil.DateTimeToStrBySSS(new Date())); + spellbuyrecord.setSpWinningStatus("0"); + spellbuyrecord.setBuyStatus("0"); + spellbuyrecord.setSpRandomNo(""); + spellbuyrecordService.add(spellbuyrecord); + randomnumber = new Randomnumber(); + randomnumber.setProductId(productCart.getProductId()); + + List RandomnumberList = randomnumberService.query(" from Randomnumber where productId='"+ spellbuyproduct.getSpellbuyProductId()+"'"); + List oldRandomList = new ArrayList(); + for (Randomnumber randomnumber : RandomnumberList) { + if(randomnumber.getRandomNumber().contains(",")){ + String[] rs = randomnumber.getRandomNumber().split(","); + for (String string : rs) { + oldRandomList.add(string); + } + + }else{ + oldRandomList.add(randomnumber.getRandomNumber()); + } + } + //randomnumber.setRandomNumber(randomUtil.newRandom(count,spellbuyproduct.getSpellbuyPrice(),oldRandomList)); + randomnumber.setRandomNumber(randomUtil.newRandom(count*spellbuyproduct.getSpSinglePrice(),spellbuyproduct.getSpellbuyPrice(),oldRandomList)); //电商改造版,每消费一元可获得一个拍购码 + + randomnumber.setSpellbuyrecordId(spellbuyrecord.getSpellbuyRecordId()); + randomnumber.setBuyDate(spellbuyrecord.getBuyDate()); + randomnumber.setUserId(Integer.parseInt(userId)); + randomnumberService.add(randomnumber); + + Integer experience = user.getExperience(); + + //experience += (count*10); + experience += (count*spellbuyproduct.getSpSinglePrice()*10); //电商改造版 + + user.setExperience(experience); + userService.add(user); + + + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductId(productCart.getProductId()); + productJSON.setProductName(productCart.getProductName()); + productJSON.setProductPeriod(productCart.getProductPeriod()); + productJSON.setProductTitle(productCart.getProductTitle()); + productJSON.setBuyCount(count); + + productJSON.setPayResult(true); + productJSON.setLogicURL(productCart.getLogicURL()); + productJSON.setKeyName(productCart.getKeyName()); + productJSON.setKeyValue(productCart.getKeyValue()); + + successCartList.add(productJSON); + } + + +// if(spellbuyproduct.getSpStatus()==2){ +// /** +// * 开奖工具类 +// */ +// String lotteryId = MD5Util.encode(String.valueOf(spellbuyproduct.getSpellbuyProductId())); +// if(MemCachedClientHelp.getIMemcachedCache().get(lotteryId)==null){ +// MemCachedClientHelp.getIMemcachedCache().put(lotteryId, "y",new Date(12*60*60*1000)); +// new Thread(){ +// public void run(){ +// try { +// newLotteryUtil.lottery(productCart); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// }.start(); +// } +// } + } + } catch (Exception e) { + flag= false; + e.printStackTrace(); + } + } + + } + + if(flag){ + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("products",null); + cookie.setMaxAge(0); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + } + } + Struts2Utils.renderText("success"); + return null; + //return "success"; + } + + + /** + * @author lwgboy + * @return + */ + public String aliPayUser() + { + return "aliPayUser"; + } + + /** + * @author lwgboy + * @return + */ + public String tenPayUser() + { + return "tenPayUser"; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public List getProductCartList() { + return productCartList; + } + + public void setProductCartList(List productCartList) { + this.productCartList = productCartList; + } + + public ProductCart getProductCart() { + return productCart; + } + + public void setProductCart(ProductCart productCart) { + this.productCart = productCart; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getCurrTime() { + return currTime; + } + + public void setCurrTime(String currTime) { + this.currTime = currTime; + } + + public String getStrTime() { + return strTime; + } + + public void setStrTime(String strTime) { + this.strTime = strTime; + } + + public String getStrRandom() { + return strRandom; + } + + public void setStrRandom(String strRandom) { + this.strRandom = strRandom; + } + + public String getStrReq() { + return strReq; + } + + public void setStrReq(String strReq) { + this.strReq = strReq; + } + + public String getOut_trade_no() { + return out_trade_no; + } + + public void setOut_trade_no(String out_trade_no) { + this.out_trade_no = out_trade_no; + } + + public Consumetable getConsumetable() { + return consumetable; + } + + public void setConsumetable(Consumetable consumetable) { + this.consumetable = consumetable; + } + + public Consumerdetail getConsumerdetail() { + return consumerdetail; + } + + public void setConsumerdetail(Consumerdetail consumerdetail) { + this.consumerdetail = consumerdetail; + } + + public Integer getMoneyCount() { + return moneyCount; + } + + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getSuccessCartList() { + return successCartList; + } + + public void setSuccessCartList(List successCartList) { + this.successCartList = successCartList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public Commissionquery getCommissionquery() { + return commissionquery; + } + + public void setCommissionquery(Commissionquery commissionquery) { + this.commissionquery = commissionquery; + } + + public Lotteryproductutil getLotteryproductutil() { + return lotteryproductutil; + } + + public void setLotteryproductutil(Lotteryproductutil lotteryproductutil) { + this.lotteryproductutil = lotteryproductutil; + } + + public Commissionpoints getCommissionpoints() { + return commissionpoints; + } + + public void setCommissionpoints(Commissionpoints commissionpoints) { + this.commissionpoints = commissionpoints; + } + + public Integer getUserPayType() { + return userPayType; + } + + public void setUserPayType(Integer userPayType) { + this.userPayType = userPayType; + } + + public String getIntegral() { + return integral; + } + + public void setIntegral(String integral) { + this.integral = integral; + } + + public String getHidUseBalance() { + return hidUseBalance; + } + + public void setHidUseBalance(String hidUseBalance) { + this.hidUseBalance = hidUseBalance; + } + + public Float getSinglePrice() { + return singlePrice; + } + + public void setSinglePrice(Float singlePrice) { + this.singlePrice = singlePrice; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + + + +} diff --git a/src/main/java/me/mofun/action/NewsAction.java b/src/main/java/me/mofun/action/NewsAction.java new file mode 100644 index 0000000..00f3285 --- /dev/null +++ b/src/main/java/me/mofun/action/NewsAction.java @@ -0,0 +1,111 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.News; +import me.mofun.pojo.NewsType; +import me.mofun.service.NewsService; +import me.mofun.service.NewsTypeService; +import me.mofun.util.Struts2Utils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +@SuppressWarnings("unused") +@Component("NewsAction") +public class NewsAction extends ActionSupport { + + private static final long serialVersionUID = 1889272927204740730L; + + @Autowired + private NewsService newsService; + + @Autowired + private NewsTypeService newTypeService; + + private Integer id; + private Integer parentId; + + private Integer subId; //newsType 表子类型Id,用于前端根据子类型Id 找出所属的父类型id; + + + private News news; + + List newsTypeSubList; //新闻子类别列表 + List newsTypeTopList; //新闻根类别列表 + + public String index(){ + news = newsService.findById(id.toString()); + newsTypeTopList = newTypeService.indexNewsTypeByParentId(0); + parentId = newTypeService.findById(id.toString()).getParentId(); + return "index"; + } + + /** + * 根据父ID获取所有子类型,供前台调用。 + */ + public void getNewsTypeSubList(){ + newsTypeSubList = newTypeService.indexNewsTypeByParentId(parentId); + Struts2Utils.renderJson(newsTypeSubList); + } + + public void getNewsTypeParent(){ + Integer pid=newTypeService.findById(subId.toString()).getParentId(); + Struts2Utils.renderText(pid.toString()); + } + + public String toAdd(){ + + return "toAddOrUpdate"; + } + + public String add(){ + + return "success"; + } + + public String toUpdate(){ + + return "toAddOrUpdate"; + } + + public String update(){ + + return "success"; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public News getNews() { + return news; + } + + public void setNews(News news) { + this.news = news; + } + + public Integer getParentId() { + return parentId; + } + + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + public Integer getSubId() { + return subId; + } + + public void setSubId(Integer subId) { + this.subId = subId; + } + + + +} diff --git a/src/main/java/me/mofun/action/ProductInfoAction.java b/src/main/java/me/mofun/action/ProductInfoAction.java new file mode 100644 index 0000000..6da4d7a --- /dev/null +++ b/src/main/java/me/mofun/action/ProductInfoAction.java @@ -0,0 +1,62 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.Product; +import me.mofun.pojo.ProductImage; +import me.mofun.service.ProductImageService; +import me.mofun.service.ProductService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; +@SuppressWarnings("unused") +@Component("ProductInfoAction") +public class ProductInfoAction extends ActionSupport { + + private static final long serialVersionUID = -5354743639843709687L; + + @Autowired + private ProductService productService; + @Autowired + private ProductImageService productImageService; + + + private String id; + private Product product; + private List productimageList; + + public String index(){ + + product = productService.findById(id); + + productimageList = productImageService.findByProductId(String.valueOf(product.getProductId()), "show"); + + return "index"; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public List getProductimageList() { + return productimageList; + } + + public void setProductimageList(List productimageList) { + this.productimageList = productimageList; + } + + +} diff --git a/src/main/java/me/mofun/action/ProductList.java b/src/main/java/me/mofun/action/ProductList.java new file mode 100644 index 0000000..92ea8d4 --- /dev/null +++ b/src/main/java/me/mofun/action/ProductList.java @@ -0,0 +1,177 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Product; +import me.mofun.pojo.ProductJSON; +import me.mofun.pojo.Spellbuyproduct; +import me.mofun.service.ProductService; +import me.mofun.service.ProductTypeService; +import me.mofun.util.ApplicationListenerImpl; +import me.mofun.util.PaginationUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +@SuppressWarnings("unused") +@Component("ProductList") +public class ProductList extends ActionSupport { + + private static final long serialVersionUID = -8133635872882545829L; + + + @Autowired + ProductTypeService producttypeService; + @Autowired + ProductService productService; + + private List productList; + private ProductJSON productJSON; + private Product product; + private Spellbuyproduct spellbuyproduct; + private String id; + private String typeId; + private String typeName; + private int pageNo; + private String pages; + private String pageString; + private int pageSize = 20; + private int pageCount; + private int resultCount; + + public String index(){ + if(pageNo==0){ + pageNo = 1; + } + if(pages!=null){ + pageNo = Integer.parseInt(pages.split("_")[1]); + } + if(typeId!=null && !typeId.equals("")){ + typeName = producttypeService.findById(typeId).getTypeName(); + }else{ + typeName = producttypeService.findById("1000").getTypeName(); + } + if(id.equals("hot20")){ + Pagination page = productService.ProductListByTypeIdList(typeId, "hot", pageNo, pageSize); + productList = (List) page.getList(); + + resultCount = page.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/productList/"+id+"/"+typeId+"/p_"); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/productList/"+id+"/p_"); + } + } + + return "index"; + } + + public List getProductList() { + return productList; + } + + public void setProductList(List productList) { + this.productList = productList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeId() { + return typeId; + } + + public void setTypeId(String typeId) { + this.typeId = typeId; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getPages() { + return pages; + } + + public void setPages(String pages) { + this.pages = pages; + } + + public String getPageString() { + return pageString; + } + + public void setPageString(String pageString) { + this.pageString = pageString; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + + + +} diff --git a/src/main/java/me/mofun/action/ProductsAction.java b/src/main/java/me/mofun/action/ProductsAction.java new file mode 100644 index 0000000..719e349 --- /dev/null +++ b/src/main/java/me/mofun/action/ProductsAction.java @@ -0,0 +1,509 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.*; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; +@SuppressWarnings("unused") +@Component("ProductsAction") +public class ProductsAction extends ActionSupport { + + private static final long serialVersionUID = 1626790673064716640L; + + @Autowired + @Qualifier("spellbuyrecordService") + private SpellbuyrecordService spellbuyrecordService; + @Autowired + @Qualifier("spellbuyproductService") + private SpellbuyproductService spellbuyproductService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ProductImageService productImageService; + + @Autowired + private UserService userService;; + + + private ProductInfo productInfo; + private Product product; + private List ParticipateJSONList; + private Spellbuyrecord spellbuyrecord; + private List spellbuyrecordList; + private Spellbuyproduct spellbuyproduct; + private Latestlottery latestlottery; + private TreeMap productPeriodList; + private List productimageList; + private User user; + private String id; + private String userId; + private int pageNo; + private int pageSize = 20; + private int pageCount; + private int resultCount; + +// private static Long isStatusBeginDate; +// private static Long isStatusNowDate = System.currentTimeMillis(); + private String isLotteryJSON; + private Long endDate; + private Long nowDate; + + HttpServletRequest request = null; + + public String index() throws ServletException, IOException{ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + ParticipateJSONList = new ArrayList(); + //List proList = spellbuyproductService.findByProductId(Integer.parseInt(id)); + List proList = spellbuyproductService.findBySpellbuyProductId(Integer.parseInt(id)); + productInfo = new ProductInfo(); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + productInfo.setProductPeriod(spellbuyproduct.getProductPeriod()); //获取并设置商品期数 + productInfo.setProductId(product.getProductId()); //获取并设置商品Id + productInfo.setStatus(spellbuyproduct.getSpStatus()); + productInfo.setHeadImage(product.getHeadImage()); + productInfo.setProductDetail(product.getProductDetail()); + productInfo.setProductName(product.getProductName()); + productInfo.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productInfo.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productInfo.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productInfo.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productInfo.setProductTitle(product.getProductTitle()); + productInfo.setSpellbuyCount(spellbuyproduct.getSpellbuyCount()); + productInfo.setSpellbuyProductId(spellbuyproduct.getSpellbuyProductId()); //获取并设置本次拍购商品的拍购Id + productInfo.setBuyLimited(spellbuyproduct.getSpellbuyLimit()); +// if(spellbuyproduct.getSpStatus()==1){ +// latestlottery = (Latestlottery) latestlotteryService.getLotteryDetail(Integer.parseInt(id)).get(0); +// } + + List objectList = spellbuyproductService.productPeriodList(spellbuyproduct.getFkProductId()); + productPeriodList = new TreeMap(new Comparator(){ + public int compare(Object o1, Object o2){ + return o2.hashCode()-o1.hashCode(); + } + }); + for (Object[] objects : objectList) { + spellbuyproduct = (Spellbuyproduct) objects[1]; + productPeriodList.put(spellbuyproduct.getProductPeriod(),spellbuyproduct.getSpellbuyProductId()); + } + + productimageList = productImageService.findByProductId(String.valueOf(product.getProductId()), "show"); + + Pagination pagination = spellbuyrecordService.LatestParticipate(id, pageNo, 6); + List list = (List) pagination.getList(); + for (int i = 0; i < list.size(); i++) { + ParticipateJSON participateJSON = new ParticipateJSON(); + spellbuyrecord = (Spellbuyrecord) list.get(i)[0]; + user = (User) list.get(i)[1]; + String userName = UserNameUtil.userName(user); + participateJSON.setBuyCount(spellbuyrecord.getBuyPrice().toString()); + participateJSON.setBuyDate(DateUtil.getTime(DateUtil.SDateTimeToDate(spellbuyrecord.getBuyDate()))); + participateJSON.setBuyId(spellbuyrecord.getSpellbuyRecordId().toString()); + participateJSON.setIp_address(user.getIpAddress()); + participateJSON.setIp_location(user.getIpLocation()); + participateJSON.setUserName(userName); + participateJSON.setUserId(String.valueOf(user.getUserId())); + participateJSON.setUserFace(user.getFaceImg()); + ParticipateJSONList.add(participateJSON); + } + resultCount = spellbuyrecordService.LatestParticipateByCount(id); //获取某商品最新参与人数 + if(productInfo.getStatus()==2){ + return "lottery"; + }else if(productInfo.getStatus()==1){ + HttpServletResponse response = Struts2Utils.getResponse(); + response.sendRedirect("/lotteryDetail/"+productInfo.getSpellbuyProductId()+".html"); +// Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; +// HttpServletRequest request = Struts2Utils.getRequest(); +// HttpServletResponse response = Struts2Utils.getResponse(); +// request.getRequestDispatcher("/lotteryDetail/index.action?id="+productInfo.getSpellbuyProductId()).forward(request,response); + }else{ + return "index"; + } + } + + /** + * 本商品往期拍购列表 + * @return + */ + public String getProductNewList(){ + spellbuyproduct = spellbuyproductService.findById(id); + List objectList = spellbuyproductService.productPeriodList(spellbuyproduct.getFkProductId()); + productPeriodList = new TreeMap(); + for (Object[] objects : objectList) { + spellbuyproduct = (Spellbuyproduct) objects[1]; + productPeriodList.put(spellbuyproduct.getProductPeriod(),spellbuyproduct.getSpellbuyProductId()); + } + Struts2Utils.renderJson(productPeriodList); + return null; + } + + public String ajaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + ParticipateJSONList = new ArrayList(); + Pagination pagination = spellbuyrecordService.LatestParticipate(id, pageNo, pageSize); + List list = (List) pagination.getList(); + for (int i = 0; i < list.size(); i++) { + ParticipateJSON participateJSON = new ParticipateJSON(); + spellbuyrecord = (Spellbuyrecord) list.get(i)[0]; + user = (User) list.get(i)[1]; + String userName = UserNameUtil.userName(user); + participateJSON.setBuyCount(spellbuyrecord.getBuyPrice().toString()); + participateJSON.setBuyDate(spellbuyrecord.getBuyDate()); + participateJSON.setBuyId(spellbuyrecord.getSpellbuyRecordId().toString()); + participateJSON.setIp_address(user.getIpAddress()); + participateJSON.setIp_location(user.getIpLocation()); + participateJSON.setUserName(userName); + participateJSON.setUserId(String.valueOf(user.getUserId())); + participateJSON.setUserFace(user.getFaceImg()); + ParticipateJSONList.add(participateJSON); + } + Struts2Utils.renderJson(ParticipateJSONList); + return null; + } + + /** + * 我的购买记录 + */ + public void getUserByHistory(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + spellbuyrecordList = spellbuyrecordService.getUserByHistory(userId, id); + Struts2Utils.renderJson(spellbuyrecordList); + } + } + } + } + } + +/** + * 从cookie 中获取登陆用户Id + * @return userId + * @author mofun + */ +public String getUserIdFromCookie() +{ + String userIdFromCookie=""; + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userIdFromCookie = cookie.getValue(); + } + } + } + return userIdFromCookie; +} + + + + /** + * @author lwg + * 检查限购情况,用于商品详情页 goodsdetail.js 中 ajax 调用 /products/checkUserLimitBuy.action + * http://127.0.0.1:8080/products/checkUserLimitBuy.action?id=1001 + * @param id 产品id ProductId + * @return {"code":0,"codeLimitBuy":0,"buyNum":0,"codeState":0,"codeRemainNum":0,"userMoney":0.0} + * code: 本函数是否执行成功的标识返回码,仔细阅读前台js 得知有 0,-10,-6,-5,-4 等几个返回码状态,其中0应该标识成功 + * codeLimitBuy:该产品默认限购次数:无限购0;有限购的话为单人最多购买该商品的件数/次数,一般为5或10 + * buyNum:某用户已购买的次数 + * codeState: 产品状态,正常上架状态为 0 + * codeRemainNum:该产品剩余的购买次数 + * userMoney:某用户当前的余额 + */ + public String checkUserLimitBuy(){ + String theUserId=StringUtils.isNotBlank(userId)?userId:getUserIdFromCookie(); + + List objectList = spellbuyproductService.checkUserLimitBuy(id,theUserId); + UserLimitBuy u = new UserLimitBuy(); + u.setCode(0); //初始化返回码为0 默认执行成功 + if(StringUtils.isNotBlank(theUserId)) + { + for (Object[] objects : objectList) { + spellbuyproduct = (Spellbuyproduct)objects[0]; + spellbuyrecord = (Spellbuyrecord)objects[1]; + user = (User)objects[2]; + break; + } + + //如果没有拍购记录,只获取拍购产品及用户余额 + if(spellbuyrecord==null){ + spellbuyproduct = spellbuyproductService.findById(id); + user = userService.findById(theUserId); + } + } + else + { + spellbuyproduct = spellbuyproductService.findById(id); + u.setCode(-10); //用户没有登录时,返回码为-10 + } + + if(spellbuyproduct!=null){ + u.setCode(spellbuyproduct.getFkProductId()); + u.setCodeLimitBuy(spellbuyproduct.getSpellbuyLimit()); + u.setCodeRemainNum(spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount()); + u.setCodeState(spellbuyproduct.getSpStatus()); + + if(u.getCodeRemainNum()<=0) + u.setCode(-6); //剩余购买次数为0时,设置返回码为 -6,前端 js 中会据此设置 _CanBuy = 0 ,表示已售完或不能再购买了。 + + } + + if(user!=null) + u.setUserMoney((float)(user.getBalance()!=null?user.getBalance().floatValue():0.0)); + + if(user!=null&&spellbuyrecord!=null) + u.setBuyNum(spellbuyrecord.getBuyPrice()); + + Struts2Utils.renderJson(u); + + return null; + } + + /** + * 检查商品关注情况 + * 参照 http://www.1ypg.com/products/checkCollectGoods.action?id=3 无论 goodsId是否存在,没有登录的用户统一返回 10 + * 用于 goodsdetail.js /products/checkCollectGoods.action ajax 调用 + * @author mofun + * @return + */ + public String checkCollectGoods() + { + Struts2Utils.renderText("10"); + return null; + } + + /** + * 添加关注(登录后才可以关注) + * 参考 http://www.1ypg.com/products/addCollectGoods.action?id=4647 + * 没登陆时无论商品是否存在统一返回 10,前端据此会弹出登陆框提示用户登录。 + * 已登陆用户点击产品页关注 链接 会进行 ajax 调用,成功后返回 0 + * 用于前端 添加关注 时进行 ajax 调用 /products/addCollectGoods.action + */ + public String addCollectGoods() + { + String goodsId=id; + Struts2Utils.renderText("10"); + return null; + } + + /** + * 是否可以开奖了:spStatus=2表示,可以开奖了;spStatus=1 表示开奖已完成。 + * http://127.0.0.1:8080/products/isLottery.action?id=10020 + * http://www.1ypg.com//products/isLottery.action?id=17396 + */ + public String isLottery(){ + String key = MD5Util.encode(id+"status"); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + spellbuyproduct = spellbuyproductService.findById(id); + endDate = DateUtil.SDateTimeToDate(spellbuyproduct.getSpellbuyEndDate()).getTime(); + nowDate = System.currentTimeMillis(); + + //(endDate-nowDate)/1000 亦即:(产品竞拍结束时间转换成毫秒-当前时间毫秒数)/1000 意思产品竞购结束时间距当前时间已过去的秒数,就是说竞拍结束过去了多少秒 + isLotteryJSON = "{\"spStatus\":\""+spellbuyproduct.getSpStatus()+"\",\"date\":\""+((endDate-nowDate)/1000)+"\"}"; + try{ + MemCachedClientHelp.getIMemcachedCache().put(key, String.valueOf(endDate),new Date(10*60*1000)); + } + catch(Exception ex){ + ex.printStackTrace(); + } + Struts2Utils.renderJson(isLotteryJSON); + }else{ + endDate = Long.parseLong((String)MemCachedClientHelp.getIMemcachedCache().get(key)); + nowDate = System.currentTimeMillis(); + isLotteryJSON = "{\"spStatus\":\"2\",\"date\":\""+((endDate-nowDate)/1000)+"\"}"; + Struts2Utils.renderJson(isLotteryJSON); + } +// isStatusNowDate = System.currentTimeMillis(); +// if(isStatusBeginDate==null){ +// spellbuyproduct = spellbuyproductService.findById(id); +// endDate = DateUtil.SDateTimeToDate(spellbuyproduct.getSpellbuyEndDate()).getTime(); +// nowDate = System.currentTimeMillis(); +// isLotteryJSON = "{\"spStatus\":\""+spellbuyproduct.getSpStatus()+"\",\"date\":\""+((endDate-nowDate)/1000)+"\"}"; +// isStatusBeginDate = System.currentTimeMillis(); +// Struts2Utils.renderJson(isLotteryJSON); +// }else{ +// if((isStatusNowDate-isStatusBeginDate)<1000){ +// Struts2Utils.renderJson(isLotteryJSON); +// }else{ +// isStatusBeginDate = System.currentTimeMillis(); +// spellbuyproduct = spellbuyproductService.findById(id); +// endDate = DateUtil.SDateTimeToDate(spellbuyproduct.getSpellbuyEndDate()).getTime(); +// nowDate = System.currentTimeMillis(); +// isLotteryJSON = "{\"spStatus\":\""+spellbuyproduct.getSpStatus()+"\",\"date\":\""+((endDate-nowDate)/1000)+"\"}"; +// Struts2Utils.renderJson(isLotteryJSON); +// } +// } + + return null; + } + + public static void main(String[] args) { +// Long endDate = DateUtil.SDateTimeToDate("2013-11-27 14:12:38").getTime(); +// Long nowDate = System.currentTimeMillis(); +// System.err.println((endDate-nowDate)/1000); +// System.err.println(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + String lotteryId = MD5Util.encode("10022"); + String a = (String) MemCachedClientHelp.getIMemcachedCache().get(lotteryId); + System.err.println(a); + MemCachedClientHelp.getIMemcachedCache().remove(lotteryId); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public ProductInfo getProductInfo() { + return productInfo; + } + + public void setProductInfo(ProductInfo productInfo) { + this.productInfo = productInfo; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public List getParticipateJSONList() { + return ParticipateJSONList; + } + + public void setParticipateJSONList(List participateJSONList) { + ParticipateJSONList = participateJSONList; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public TreeMap getProductPeriodList() { + return productPeriodList; + } + + public void setProductPeriodList(TreeMap productPeriodList) { + this.productPeriodList = productPeriodList; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getProductimageList() { + return productimageList; + } + + public void setProductimageList(List productimageList) { + this.productimageList = productimageList; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public List getSpellbuyrecordList() { + return spellbuyrecordList; + } + + public void setSpellbuyrecordList(List spellbuyrecordList) { + this.spellbuyrecordList = spellbuyrecordList; + } + + +} diff --git a/src/main/java/me/mofun/action/RegisterAction.java b/src/main/java/me/mofun/action/RegisterAction.java new file mode 100644 index 0000000..717c613 --- /dev/null +++ b/src/main/java/me/mofun/action/RegisterAction.java @@ -0,0 +1,816 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import com.shcm.bean.SendResultBean; +import me.mofun.pojo.User; +import me.mofun.service.UserService; +import me.mofun.util.*; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Date; +import java.util.List; +import java.util.Random; + + +@SuppressWarnings("unused") +@Component("RegsiterAction") +public class RegisterAction extends ActionSupport { + private static final long serialVersionUID = 5054777863371691520L; + private Logger logger = Logger.getLogger(this.getClass()); + + + @Autowired + @Qualifier("userService") + private UserService userService; + + private User user; + private String phone; + private String mail; + private String userPwd; + private String userName; + private String forward; + private String str; + private String isVerify; + private String key; + private String date; + private String openId; + private String userFace; + + public static IPSeeker seeker = new IPSeeker(); + HttpServletRequest request = null; + HttpServletResponse response = null; + static HTMLFilter htmlFilter = new HTMLFilter(); + + public String index(){ + if(StringUtil.isNotBlank(forward)){ + forward = htmlFilter.filter(forward); + } + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + String userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + return "index_index"; + } + } + } + }else{ +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// return null; + } + + return "index"; + } + + public String register(){ + str = htmlFilter.filter(str); + userPwd = htmlFilter.filter(userPwd); + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + user = new User(); +// String ip = Struts2Utils.getRequest().getRemoteAddr(); + String ip = Struts2Utils.getRequest().getHeader("X-Real-IP"); + if(ip==null){ + ip = "127.0.0.1"; + } + String date = DateUtil.DateTimeToStr(new Date()); + if(str.indexOf("@")!=-1){ + user.setMail(str); + user.setMailCheck("3"); + user.setMobileCheck("3"); + if(userPwd!=null && !userPwd.equals("")){ + user.setUserPwd(userPwd); + } + user.setIpAddress(ip); + String ipLocation = seeker.getAddress(ip); + user.setIpLocation(ipLocation); + user.setOldDate(date); + user.setNewDate(date); + user.setBalance(ApplicationListenerImpl.sysConfigureJson.getRegBalance()); + user.setCommissionBalance(0.00); + user.setCommissionCount(0.00); + user.setCommissionMention(0.00); + user.setCommissionPoints(0); + user.setFaceImg("/Images/defaultUserFace.png"); + user.setUserType("0"); + user.setExperience(0); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("inviteId")){ + String inviteId = cookie.getValue(); + if(inviteId!=null && !inviteId.equals("")){ + user.setInvite(Integer.parseInt(inviteId)); + } + } + } + } + try { + this.userService.add(user); + Struts2Utils.renderText("true"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + }else{ + if(userPwd!=null && !userPwd.equals("")){ + MemCachedClientHelp.getIMemcachedCache().put(str, userPwd,new Date(10*60*1000)); + Struts2Utils.renderText("true"); + }else{ + Struts2Utils.renderText("false"); + } + } + + return null; + } + + public String mobilecheck() { + if(MemCachedClientHelp.getIMemcachedCache().get(str)==null){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + }else{ + isVerify = Base64.getEncode(str); + } + return "mobilecheck"; + } + + //供前段页面调用发送短信验证码 + public void regSendMes() throws Exception{ + Random random = new Random(); + String ran = ""; + for (int i = 0; i < 6; i++) { + ran += random.nextInt(9); + } + if(isVerify.equals(Base64.getEncode(phone))){ + if(MemCachedClientHelp.getIMemcachedCache().get(Base64.getEncode(phone))==null){ + try { + //boolean result = SendSMS.sendSMS(phone, "您本次的验证码是:"+ran+",请即时填写,祝您好运。"); + boolean result = SendSMS.sendSMS(phone, ran); + if(result){ + MemCachedClientHelp.getIMemcachedCache().put(Base64.getEncode(phone), ran,new Date(2*60*1000)); + Struts2Utils.renderText("0"); //成功! + }else{ + Struts2Utils.renderText("error"); + } + + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("error"); + } + }else{ + Struts2Utils.renderText("2"); + } + }else{ + Struts2Utils.renderText("error"); + } + } + + /** + * @deprecated 原短信验证码通道失效,弃用,改用上面的通道。 + * @throws Exception + */ + public void regSendMes_old() throws Exception{ + Random random = new Random(); + String ran = ""; + for (int i = 0; i < 6; i++) { + ran += random.nextInt(9); + } + if(isVerify.equals(Base64.getEncode(phone))){ + if(MemCachedClientHelp.getIMemcachedCache().get(Base64.getEncode(phone))==null){ + try { + List sendList = Sampler.sendOnce(phone, "您本次的手机验证码是:"+ran+",请即时填写,祝您好运。"); + if(sendList != null){ + for(SendResultBean t:sendList){ + if(t.getResult() < 1){ + Struts2Utils.renderText("false"); + return; + } + MemCachedClientHelp.getIMemcachedCache().put(Base64.getEncode(phone), ran,new Date(2*60*1000)); + Struts2Utils.renderText("0"); + } + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("error"); + } + }else{ + Struts2Utils.renderText("2"); + } + }else{ + Struts2Utils.renderText("error"); + } + } + + public String regSendMes2() throws Exception{ + Random random = new Random(); + String ran = ""; + for (int i = 0; i < 6; i++) { + ran += random.nextInt(9); + } + if(isVerify.equals(Base64.getEncode(phone))){ + if(MemCachedClientHelp.getIMemcachedCache().get(Base64.getEncode(phone))==null){ + try { + List sendList = Sampler.sendOnce(phone, "您本次的手机验证码是:"+ran+",请即时填写,祝您好运。"); + if(sendList != null){ + for(SendResultBean t:sendList){ + if(t.getResult() < 1){ + Struts2Utils.renderText("false"); + return null; + } + MemCachedClientHelp.getIMemcachedCache().put(Base64.getEncode(phone), ran,new Date(2*60*1000)); + Struts2Utils.renderText("0"); + } + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("error"); + } + }else{ + Struts2Utils.renderText("2"); + } + }else{ + Struts2Utils.renderText("error"); + } + return null; + } + + + public void checkMobileCode(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + user = new User(); +// String ip = Struts2Utils.getRequest().getRemoteAddr(); + String ip = Struts2Utils.getRequest().getHeader("X-Real-IP"); + if(ip==null){ + ip = "127.0.0.1"; + } + String date = DateUtil.DateTimeToStr(new Date()); + try { + if(MemCachedClientHelp.getIMemcachedCache().get(isVerify)!=null){ + if(MemCachedClientHelp.getIMemcachedCache().get(isVerify).equals(key)){ + phone = Base64.getDecode(isVerify); + user.setPhone(phone); + user.setMailCheck("3"); + user.setMobileCheck("0"); + userPwd = (String) MemCachedClientHelp.getIMemcachedCache().get(phone); + if(userPwd!=null && !userPwd.equals("")){ + user.setUserPwd(userPwd); + }else{ + Struts2Utils.renderText("timeOut"); + return; + } + user.setIpAddress(ip); + String ipLocation = seeker.getAddress(ip); + user.setIpLocation(ipLocation); + user.setOldDate(date); + user.setNewDate(date); + user.setBalance(ApplicationListenerImpl.sysConfigureJson.getRegBalance()); + user.setCommissionBalance(0.00); + user.setCommissionCount(0.00); + user.setCommissionMention(0.00); + user.setCommissionPoints(0); + user.setFaceImg("/Images/defaultUserFace.png"); + user.setUserType("0"); + user.setExperience(0); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("inviteId")){ + String inviteId = cookie.getValue(); + if(inviteId!=null && !inviteId.equals("")){ + user.setInvite(Integer.parseInt(inviteId)); + } + } + } + } + try { + this.userService.add(user); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + Struts2Utils.renderText("0"); + }else{ + Struts2Utils.renderText("1"); + } + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + } + + public String mobileok() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + user = userService.userByName(phone); + if(user!=null){ + if(user.getMobileCheck().equals("0")){ + isVerify = "0"; + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("phone",user.getPhone()); + cookie.setMaxAge(-1); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + Cookie cookie2 = new Cookie("userId",String.valueOf(user.getUserId())); + cookie2.setMaxAge(-1); + cookie2.setPath("/"); + cookie2.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie2); + Cookie cookie3 = new Cookie("face",URLEncoder.encode(user.getFaceImg(), "UTF-8")); + cookie3.setMaxAge(-1); + cookie3.setPath("/"); + cookie3.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie3); + } + }else{ + isVerify = "1"; + } + }else{ + isVerify = "1"; + } + return "mobileok"; + } + + public String emailcheck(){ +// System.err.println("str:"+str); + user = userService.userByName(str); + if(user==null){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + }else{ + isVerify = user.getMailCheck(); + } + return "emailcheck"; + } + + public void SendRegisterMail(){ + //System.err.println("mail:"+mail); + //只采用日期部分生成加密串,便于memcache 无效时直接验证,但有安全隐患。 + //key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.DateToStr(new Date(),"yyyyMMdd"))+Base64.getEncode(mail); + key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.dateTimeToStr(new Date()))+Base64.getEncode(mail+"|"+DateUtil.DateToStr(new Date(),"yyyyMMdd")); + + //将激活 key 存入数据库供后续的 emailok 验证 + //userService.updateKey(mail, key); //用后面发送邮件成功后的 user.setKey(key) 替代,因此注释掉。 + + String html = ""+ + ""+ + ""+ + ""+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    首页"+ + "我的"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"帮助
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    亲爱的 "+mail+"

    您好!感谢您注册"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"。

    请点击下面的按钮,完成邮箱验证。

    邮箱验证
    如果上面按钮不能点击或点击后没有反应,您还可以将以下链接复制到浏览器地址栏中访问完成验证。
    "+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/register/emailok.html?key="+key+"
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    此邮件由系统自动发出,请勿回复!
    感谢您对"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")的支持,祝您好运!
    客服热线:"+ApplicationListenerImpl.sysConfigureJson.getServiceTel()+"
    "+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + "
    "+ApplicationListenerImpl.sysConfigureJson.getDomain()+" "+ApplicationListenerImpl.sysConfigureJson.getIcp()+"
    "; + if(MemCachedClientHelp.getIMemcachedCache().get(MD5Util.encode(mail))==null){ + user = userService.userByName(mail); + if(user!=null){ + if(user.getMailCheck().equals("0")){ + Struts2Utils.renderText("0"); + }else{ + try { + boolean flag = EmailUtil.sendEmail(ApplicationListenerImpl.sysConfigureJson.getMailName(), ApplicationListenerImpl.sysConfigureJson.getMailPwd(), mail, ApplicationListenerImpl.sysConfigureJson.getSiteName()+"验证注册邮箱", html); + if(flag){ + user.setMailCheck("1"); + user.setMailKey(key); //保存key 到数据库,便于memcache 没启动时也能完成验证 + userService.add(user); + if(MemCachedClientHelp.getIMemcachedCache()!=null) + try{ + MemCachedClientHelp.getIMemcachedCache().put(MD5Util.encode(mail), mail,new Date(10*60*1000)); + }catch (Exception e) { + e.printStackTrace(); + } + Struts2Utils.renderText("2"); + }else{ + Struts2Utils.renderText("false"); + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + } + } + }else{ + user = userService.userByName(mail); + if(user!=null){ + if(user.getMailCheck().equals("1")){ + Struts2Utils.renderText("3"); + }else if(user.getMailCheck().equals("0")){ + Struts2Utils.renderText("0"); + } + } + } + } + + public void SendRegisterMail_old(){ + //System.err.println("mail:"+mail); + //只采用日期部分生成加密串,便于memcache 无效时直接验证,但有安全隐患。 + //key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.DateToStr(new Date(),"yyyyMMdd"))+Base64.getEncode(mail); + key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.dateTimeToStr(new Date()))+Base64.getEncode(mail+"|"+DateUtil.DateToStr(new Date(),"yyyyMMdd")); + + //将激活 key 存入数据库供后续的 emailok 验证 + //userService.updateKey(mail, key); //用后面发送邮件成功后的 user.setKey(key) 替代,因此注释掉。 + + String html = ""+ + ""+ + ""+ + ""+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    首页"+ + "我的"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"帮助
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    亲爱的 "+mail+"

    您好!感谢您注册"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"。

    请点击下面的按钮,完成邮箱验证。

    邮箱验证
    如果上面按钮不能点击或点击后没有反应,您还可以将以下链接复制到浏览器地址栏中访问完成验证。
    "+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/register/emailok.html?key="+key+"
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    此邮件由系统自动发出,请勿回复!
    感谢您对"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")的支持,祝您好运!
    客服热线:"+ApplicationListenerImpl.sysConfigureJson.getServiceTel()+"
    "+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + "
    "+ApplicationListenerImpl.sysConfigureJson.getDomain()+" "+ApplicationListenerImpl.sysConfigureJson.getIcp()+"
    "; + if(MemCachedClientHelp.getIMemcachedCache().get(MD5Util.encode(mail))==null){ + user = userService.userByName(mail); + if(user!=null){ + if(user.getMailCheck().equals("0")){ + Struts2Utils.renderText("0"); + }else{ + try { + boolean flag = EmailUtil.sendEmail(ApplicationListenerImpl.sysConfigureJson.getMailName(), ApplicationListenerImpl.sysConfigureJson.getMailPwd(), mail, ApplicationListenerImpl.sysConfigureJson.getSiteName()+"验证注册邮箱", html); + if(flag){ + user.setMailCheck("1"); + user.setMailKey(key); //保存key 到数据库,便于memcache 没启动时也能完成验证 + userService.add(user); + if(MemCachedClientHelp.getIMemcachedCache()!=null) + try{ + MemCachedClientHelp.getIMemcachedCache().put(MD5Util.encode(mail), mail,new Date(10*60*1000)); + }catch (Exception e) { + e.printStackTrace(); + } + Struts2Utils.renderText("2"); + }else{ + Struts2Utils.renderText("false"); + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + } + } + }else{ + user = userService.userByName(mail); + if(user!=null){ + if(user.getMailCheck().equals("1")){ + Struts2Utils.renderText("3"); + }else if(user.getMailCheck().equals("0")){ + Struts2Utils.renderText("0"); + } + } + } + } + + + public static void main(String[] args) { +// MemCachedClientHelp.getIMemcachedCache().put("GEFENGBKINNJIDJDMOHMOOBJDMEOHKPPMNLPIEGPDBGBGODOABGFADECBAMKNIOM", "52013594@qq.com",new Date(30*60*1000)); + + Random random = new Random(); + String ran = ""; + for (int i = 0; i < 6; i++) { + ran += random.nextInt(9); + } +// ran += random.nextInt(9); +// ran += random.nextInt(9); +// ran += random.nextInt(9); +// ran += random.nextInt(9); +// ran += random.nextInt(9); +// ran += random.nextInt(9); + System.err.println(ran); + } + + public String emailok() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); +// System.err.println("emailok:"+key); + if(StringUtil.isNotBlank(key)){ + String key_mail_date_str = key.substring(64,key.length()); + String [] keyStr = Base64.getDecode(key_mail_date_str).split("\\|"); + if(keyStr.length==2) + { + mail = keyStr[0]; + Date date = DateUtil.StrToDate(keyStr[1], "yyyyMMdd"); + if(DateUtil.addDate(new Date(), -1).before(date)&& StringUtil.isNotBlank(mail)) + { + user = userService.userByName(mail); + if(MemCachedClientHelp.getIMemcachedCache().get(MD5Util.encode(mail))!=null || (user!=null&&user.getMailKey().equals(key))) + { + if(!user.getMailCheck().equals("0")){ + user.setMailCheck("0"); + user.setMailKey("") ; //清空保存的用于激活的key + userService.add(user); + isVerify = "0"; + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("mail",user.getMail()); + cookie.setMaxAge(-1); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + Cookie cookie2 = new Cookie("userId",String.valueOf(user.getUserId())); + cookie2.setMaxAge(-1); + cookie2.setPath("/"); + cookie2.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie2); + Cookie cookie3 = new Cookie("face",URLEncoder.encode(user.getFaceImg(), "UTF-8")); + cookie3.setMaxAge(-1); + cookie3.setPath("/"); + cookie3.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie3); + } + }else{ + //说明已验证过没必要再次验证,置为验证码已失效状态 + isVerify = "1"; + } + }else{ + isVerify = "1"; + } + }else{ + isVerify = "1"; + } + }else{ + isVerify="1"; + } + } + else + isVerify="1"; + return "emailok"; + } + + //QQ互联登陆授权是否存在,供 login.js 中 ajax 调用 + public void authorizeIsExists(){ + user = userService.isNotOpenId(openId); + if(user==null) + Struts2Utils.renderText("false"); + else + Struts2Utils.renderJson(user); + } + + /** + * QQ互联登陆后进行授权用户注册,供 login.js 中 ajax 调用 + */ + public void authorizeRegsiter(){ + user = new User(); +// String ip = Struts2Utils.getRequest().getRemoteAddr(); + String ip = Struts2Utils.getRequest().getHeader("X-Real-IP"); + String date = DateUtil.DateTimeToStr(new Date()); + if(userName!=null && !userName.equals("")){ + user.setUserName(userName); + } + user.setMobileCheck("3"); + user.setMailCheck("3"); + user.setUserPwd(openId); + user.setQqOpenId(openId); + if(ip==null){ + ip = "127.0.0.1"; + } + user.setIpAddress(ip); + String ipLocation = seeker.getAddress(ip); + user.setIpLocation(ipLocation); + user.setOldDate(date); + + user.setBalance(ApplicationListenerImpl.sysConfigureJson.getRegBalance()); + user.setCommissionBalance(0.00); + user.setCommissionCount(0.00); + user.setCommissionMention(0.00); + user.setCommissionPoints(0); + user.setFaceImg(userFace); + user.setUserType("0"); + user.setExperience(0); + + try { + this.userService.add(user); + Struts2Utils.renderJson(user); + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + } + + /* + * qq 互联登陆成功后,当手机及邮箱都没有验证过时转向邮箱或手机号验证页面 + */ + public String qqUserInfoAuth(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + String userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + user.setAttribute22(user.getQqOpenId()); + if((StringUtils.isNoneEmpty(user.getMobileCheck())&&!user.getMobileCheck().equals("0"))&&(StringUtils.isNoneEmpty(user.getMail())&&!user.getMailCheck().equals("0"))) + return "qqUserInfoAuth"; + else + return "index_index"; + } + } + } + return null; + }else{ + //Struts2Utils.render("text/html", "","encoding:UTF-8"); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + } + + public String isExists(){ + user = userService.userByName(userName); + if(user==null) + Struts2Utils.renderText("true"); + else + Struts2Utils.renderText("false"); + return null; + } + + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + + public String getUserPwd() { + return userPwd; + } + + public void setUserPwd(String userPwd) { + this.userPwd = userPwd; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + public String getForward() { + return forward; + } + + public void setForward(String forward) { + this.forward = forward; + } + + public String getStr() { + return str; + } + + public void setStr(String str) { + this.str = str; + } + + public String getIsVerify() { + return isVerify; + } + + public void setIsVerify(String isVerify) { + this.isVerify = isVerify; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getOpenId() { + return openId; + } + + public void setOpenId(String openId) { + this.openId = openId; + } + + public String getUserFace() { + return userFace; + } + + public void setUserFace(String userFace) { + this.userFace = userFace; + } + + +} diff --git a/src/main/java/me/mofun/action/SearchAction.java b/src/main/java/me/mofun/action/SearchAction.java new file mode 100644 index 0000000..cc2b9ef --- /dev/null +++ b/src/main/java/me/mofun/action/SearchAction.java @@ -0,0 +1,435 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Product; +import me.mofun.pojo.ProductJSON; +import me.mofun.pojo.Spellbuyproduct; +import me.mofun.service.SpellbuyrecordService; +import me.mofun.util.ApplicationListenerImpl; +import me.mofun.util.PaginationUtil; +import me.mofun.util.Struts2Utils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@SuppressWarnings("unused") +@Component("SearchAction") +public class SearchAction extends ActionSupport { + + private static final long serialVersionUID = -6415908765367001524L; + + @Autowired + @Qualifier("spellbuyrecordService") + private SpellbuyrecordService spellbuyrecordService; + + private List ProductList; + private Product product; + private Spellbuyproduct spellbuyproduct; + private ProductJSON productJSON; + private String id; + private int pageNo; + private String pages; + private String pageString; + private int pageSize = 20; + private int pageCount; + private int resultCount; + private String keyword; + + public String index(){ + if(pageNo==0){ + pageNo = 1; + } + if(pages!=null){ + pageNo = Integer.parseInt(pages.split("_")[1]); + } + if(id.equals("hot20")){ + Pagination hotPage = spellbuyrecordService.searchProduct(keyword, "hot", pageNo, pageSize); + List HotList = (List) hotPage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < HotList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) HotList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) HotList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = hotPage.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/search/"+id+"/"+keyword+"/p_"); + }else if(id.equals("date20")){ + Pagination datePage = spellbuyrecordService.searchProduct(keyword, "date", pageNo, pageSize); + List dateList = (List) datePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) dateList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = datePage.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/search/"+id+"/"+keyword+"/p_"); + }else if(id.equals("price20")){ + Pagination pricePage = spellbuyrecordService.searchProduct(keyword, "price", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/search/"+id+"/"+keyword+"/p_"); + }else if(id.equals("priceAsc20")){ + Pagination pricePage = spellbuyrecordService.searchProduct(keyword, "priceAsc", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/search/"+id+"/"+keyword+"/p_"); + }else if(id.equals("about20")){ + Pagination pricePage = spellbuyrecordService.searchProduct(keyword, "about", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/search/"+id+"/"+keyword+"/p_"); + }else if(id.equals("surplus20")){ + Pagination pricePage = spellbuyrecordService.searchProduct(keyword, "surplus", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/search/"+id+"/"+keyword+"/p_"); + } + return "index"; + } + + public String ajaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + if(id.equals("hot20")){ + Pagination hotPage = spellbuyrecordService.searchProduct(keyword, "hot", pageNo, pageSize); + List HotList = (List) hotPage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < HotList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) HotList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) HotList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + Struts2Utils.renderJson(ProductList); + + }else if(id.equals("date20")){ + Pagination datePage = spellbuyrecordService.searchProduct(keyword, "date", pageNo, pageSize); + List dateList = (List) datePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) dateList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + Struts2Utils.renderJson(ProductList); + }else if(id.equals("price20")){ + Pagination pricePage = spellbuyrecordService.searchProduct(keyword, "price", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + Struts2Utils.renderJson(ProductList); + }else if(id.equals("priceAsc20")){ + Pagination pricePage = spellbuyrecordService.searchProduct(keyword, "priceAsc", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + ProductList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + + //productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + + productJSON.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productJSON.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productJSON.setLogicURL(product.getLogicURL()); + + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + ProductList.add(productJSON); + } + Struts2Utils.renderJson(ProductList); + } + return null; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public List getProductList() { + return ProductList; + } + + public void setProductList(List productList) { + ProductList = productList; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public String getPages() { + return pages; + } + + public void setPages(String pages) { + this.pages = pages; + } + + public String getPageString() { + return pageString; + } + + public void setPageString(String pageString) { + this.pageString = pageString; + } + + +} diff --git a/src/main/java/me/mofun/action/SetNamePwdAction.java b/src/main/java/me/mofun/action/SetNamePwdAction.java new file mode 100644 index 0000000..bbd2bf9 --- /dev/null +++ b/src/main/java/me/mofun/action/SetNamePwdAction.java @@ -0,0 +1,22 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import org.springframework.stereotype.Component; + +@SuppressWarnings("unused") +@Component("SetNamePwdAction") +public class SetNamePwdAction extends ActionSupport { + + private static final long serialVersionUID = -3714908489142137768L; + + public String index(){ + + return "index"; + } + + public String setNewPwd(){ + + return null; + } + +} diff --git a/src/main/java/me/mofun/action/ShareAction.java b/src/main/java/me/mofun/action/ShareAction.java new file mode 100644 index 0000000..38932b5 --- /dev/null +++ b/src/main/java/me/mofun/action/ShareAction.java @@ -0,0 +1,583 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.ShareService; +import me.mofun.service.UserService; +import me.mofun.util.*; +import net.sf.json.JSONObject; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Component("ShareAction") +public class ShareAction extends ActionSupport { + + private static final long serialVersionUID = -8202280107475087499L; + @Autowired + ShareService shareService; + + @Autowired + UserService userService;; + + private Shareinfo shareinfo; + private Shareimage shareimage; + private Latestlottery latestlottery; + private List ShareJSONList; + private List shareCommentJSONList; + private User user; + private Sharecomments sharecomments; + private ShareCommentJSON shareCommentJSON; + private ShareJSON shareJSON; + private String id; + private String shareURL; //转为新浪 t.cn 短网址用 + + private int pageNo; + private String pages; + private String pageString; + private int pageSize = 20; + private int pageCount; + private int resultCount; + + private static List ShareJSONByIndexList; + private static Long nowDateByShareJSONByIndex = System.currentTimeMillis(); + private static Long beginDateByShareJSONByIndex; + + public String index(){ + if(pageNo==0){ + pageNo = 1; + } + if(pages!=null){ + pageNo = Integer.parseInt(pages.split("_")[1]); + } + if(id.equals("new20")){ + Pagination page = shareService.loadPageShare("new20",pageNo, pageSize); + List pageList = (List) page.getList(); + ShareJSONList = new ArrayList(); + for (int i = 0; i < pageList.size(); i++) { + shareJSON = new ShareJSON(); + //shareinfo = (Shareinfo) pageList.get(i)[0]; //for jdk1.7 lwg 2020.03.18 + //shareimage = (Shareimage) pageList.get(i)[1]; //for jdk1.7 lwg 2020.03.18 + shareinfo = (Shareinfo) pageList.get(i)[1]; //for jdk1.8 lwg 2020.03.18 + shareimage = (Shareimage) pageList.get(i)[0]; //for jdk1.8 lwg 2020.03.18 + latestlottery = (Latestlottery) pageList.get(i)[2]; + String userName = ""; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userName = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userName = latestlottery.getBuyUser(); + if(userName.indexOf("@")!=-1){ + String[] u = userName.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userName = u1+"@"+u[1]; + }else{ + userName = userName.substring(0,4)+ "*** "+userName.substring(7); + } + } + shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); + shareJSON.setReplyCount(shareinfo.getReplyCount()); + shareJSON.setReward(shareinfo.getReward()); + shareJSON.setShareContent(shareinfo.getShareContent()); + shareJSON.setShareDate(DateUtil.getTime(DateUtil.SDateTimeToDate(shareinfo.getShareDate()))); + shareJSON.setShareImages(shareimage.getImages()); + shareJSON.setShareTitle(shareinfo.getShareTitle()); + shareJSON.setUid(shareinfo.getUid()); + shareJSON.setUpCount(shareinfo.getUpCount()); + shareJSON.setUserName(userName); + shareJSON.setUserFace(latestlottery.getUserFace()); + shareJSON.setUserId(latestlottery.getUserId()+""); + ShareJSONList.add(shareJSON); + } + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/share/"+id+"/p_"); + } + if(id.equals("hot20")){ + Pagination page = shareService.loadPageShare("hot20",pageNo, pageSize); + List pageList = (List) page.getList(); + ShareJSONList = new ArrayList(); + for (int i = 0; i < pageList.size(); i++) { + shareJSON = new ShareJSON(); + shareinfo = (Shareinfo) pageList.get(i)[0]; + shareimage = (Shareimage) pageList.get(i)[1]; + latestlottery = (Latestlottery) pageList.get(i)[2]; + String userName = ""; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userName = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userName = latestlottery.getBuyUser(); + if(userName.indexOf("@")!=-1){ + String[] u = userName.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userName = u1+"@"+u[1]; + }else{ + userName = userName.substring(0,4)+ "*** "+userName.substring(7); + } + } + shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); + shareJSON.setReplyCount(shareinfo.getReplyCount()); + shareJSON.setReward(shareinfo.getReward()); + shareJSON.setShareContent(shareinfo.getShareContent()); + shareJSON.setShareDate(shareinfo.getShareDate()); + shareJSON.setShareImages(shareimage.getImages()); + shareJSON.setShareTitle(shareinfo.getShareTitle()); + shareJSON.setUid(shareinfo.getUid()); + shareJSON.setUpCount(shareinfo.getUpCount()); + shareJSON.setUserName(userName); + shareJSON.setUserFace(latestlottery.getUserFace()); + shareJSON.setUserId(latestlottery.getUserId()+""); + ShareJSONList.add(shareJSON); + } + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/share/"+id+"/p_"); + } + if(id.equals("reply20")){ + Pagination page = shareService.loadPageShare("reply20",pageNo, pageSize); + List pageList = (List) page.getList(); + ShareJSONList = new ArrayList(); + for (int i = 0; i < pageList.size(); i++) { + shareJSON = new ShareJSON(); + shareinfo = (Shareinfo) pageList.get(i)[0]; + shareimage = (Shareimage) pageList.get(i)[1]; + latestlottery = (Latestlottery) pageList.get(i)[2]; + String userName = ""; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userName = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userName = latestlottery.getBuyUser(); + if(userName.indexOf("@")!=-1){ + String[] u = userName.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userName = u1+"@"+u[1]; + }else{ + userName = userName.substring(0,4)+ "*** "+userName.substring(7); + } + } + shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); + shareJSON.setReplyCount(shareinfo.getReplyCount()); + shareJSON.setReward(shareinfo.getReward()); + shareJSON.setShareContent(shareinfo.getShareContent()); + shareJSON.setShareDate(shareinfo.getShareDate()); + shareJSON.setShareImages(shareimage.getImages()); + shareJSON.setShareTitle(shareinfo.getShareTitle()); + shareJSON.setUid(shareinfo.getUid()); + shareJSON.setUpCount(shareinfo.getUpCount()); + shareJSON.setUserName(userName); + shareJSON.setUserFace(latestlottery.getUserFace()); + shareJSON.setUserId(latestlottery.getUserId()+""); + ShareJSONList.add(shareJSON); + } + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/share/"+id+"/p_"); + } + + return "index"; + } + + public String ajaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + nowDateByShareJSONByIndex = System.currentTimeMillis(); + if(beginDateByShareJSONByIndex==null){ + Pagination page = shareService.loadPageShare("new20",pageNo, pageSize); + List pageList = (List) page.getList(); + ShareJSONByIndexList = new ArrayList(); + for (int i = 0; i < pageList.size(); i++) { + shareJSON = new ShareJSON(); + shareinfo = (Shareinfo) pageList.get(i)[0]; + shareimage = (Shareimage) pageList.get(i)[1]; + latestlottery = (Latestlottery) pageList.get(i)[2]; + String userer = null; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); + shareJSON.setReplyCount(shareinfo.getReplyCount()); + shareJSON.setReward(shareinfo.getReward()); + shareJSON.setShareContent(shareinfo.getShareContent()); + shareJSON.setShareDate(shareinfo.getShareDate()); + shareJSON.setShareImages(shareimage.getImages()); + shareJSON.setShareTitle(shareinfo.getShareTitle()); + shareJSON.setUid(shareinfo.getUid()); + shareJSON.setUpCount(shareinfo.getUpCount()); + shareJSON.setUserName(userer); + shareJSON.setUserFace(latestlottery.getUserFace()); + shareJSON.setUserId(latestlottery.getUserId()+""); + ShareJSONByIndexList.add(shareJSON); + } + beginDateByShareJSONByIndex = System.currentTimeMillis(); + Struts2Utils.renderJson(ShareJSONByIndexList); + }else{ + if((nowDateByShareJSONByIndex-beginDateByShareJSONByIndex)<5000){ + Struts2Utils.renderJson(ShareJSONByIndexList); + }else{ + beginDateByShareJSONByIndex = System.currentTimeMillis(); + Pagination page = shareService.loadPageShare("new20",pageNo, pageSize); + List pageList = (List) page.getList(); + ShareJSONByIndexList = new ArrayList(); + for (int i = 0; i < pageList.size(); i++) { + shareJSON = new ShareJSON(); + shareinfo = (Shareinfo) pageList.get(i)[0]; + shareimage = (Shareimage) pageList.get(i)[1]; + latestlottery = (Latestlottery) pageList.get(i)[2]; + String userer = null; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); + shareJSON.setReplyCount(shareinfo.getReplyCount()); + shareJSON.setReward(shareinfo.getReward()); + shareJSON.setShareContent(shareinfo.getShareContent()); + shareJSON.setShareDate(shareinfo.getShareDate()); + shareJSON.setShareImages(shareimage.getImages()); + shareJSON.setShareTitle(shareinfo.getShareTitle()); + shareJSON.setUid(shareinfo.getUid()); + shareJSON.setUpCount(shareinfo.getUpCount()); + shareJSON.setUserName(userer); + shareJSON.setUserFace(latestlottery.getUserFace()); + shareJSON.setUserId(latestlottery.getUserId()+""); + ShareJSONByIndexList.add(shareJSON); + } + Struts2Utils.renderJson(ShareJSONByIndexList); + } + } +// if(id.equals("new20")){ +// Pagination page = shareService.loadPageShare("new20",pageNo, pageSize); +// List pageList = (List) page.getList(); +// ShareJSONList = new ArrayList(); +// for (int i = 0; i < pageList.size(); i++) { +// shareJSON = new ShareJSON(); +// shareinfo = (Shareinfo) pageList.get(i)[0]; +// shareimage = (Shareimage) pageList.get(i)[1]; +// latestlottery = (Latestlottery) pageList.get(i)[2]; +// String userer = null; +// if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ +// userer = latestlottery.getUserName(); +// }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ +// userer = latestlottery.getBuyUser(); +// if(userer.indexOf("@")!=-1){ +// String[] u = userer.split("@"); +// String u1 = u[0].substring(0,2)+"***"; +// userer = u1+"@"+u[1]; +// }else{ +// userer = userer.substring(0,4)+ "*** "+userer.substring(7); +// } +// } +// shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); +// shareJSON.setReplyCount(shareinfo.getReplyCount()); +// shareJSON.setReward(shareinfo.getReward()); +// shareJSON.setShareContent(shareinfo.getShareContent()); +// shareJSON.setShareDate(shareinfo.getShareDate()); +// shareJSON.setShareImages(shareimage.getImages()); +// shareJSON.setShareTitle(shareinfo.getShareTitle()); +// shareJSON.setUid(shareinfo.getUid()); +// shareJSON.setUpCount(shareinfo.getUpCount()); +// shareJSON.setUserName(userer); +// shareJSON.setUserFace(latestlottery.getUserFace()); +// shareJSON.setUserId(latestlottery.getUserId()+""); +// ShareJSONList.add(shareJSON); +// } +// Struts2Utils.renderJson(ShareJSONList); +// } +// if(id.equals("hot20")){ +// Pagination page = shareService.loadPageShare("hot20",pageNo, pageSize); +// List pageList = (List) page.getList(); +// ShareJSONList = new ArrayList(); +// for (int i = 0; i < pageList.size(); i++) { +// shareJSON = new ShareJSON(); +// shareinfo = (Shareinfo) pageList.get(i)[0]; +// shareimage = (Shareimage) pageList.get(i)[1]; +// latestlottery = (Latestlottery) pageList.get(i)[2]; +// String userer = null; +// if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ +// userer = latestlottery.getBuyUser(); +// if(userer.indexOf("@")!=-1){ +// String[] u = userer.split("@"); +// String u1 = u[0].substring(0,2)+"***"; +// userer = u1+"@"+u[1]; +// }else{ +// userer = userer.substring(0,4)+ "*** "+userer.substring(7); +// } +// } +// shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); +// shareJSON.setReplyCount(shareinfo.getReplyCount()); +// shareJSON.setReward(shareinfo.getReward()); +// shareJSON.setShareContent(shareinfo.getShareContent()); +// shareJSON.setShareDate(shareinfo.getShareDate()); +// shareJSON.setShareImages(shareimage.getImages()); +// shareJSON.setShareTitle(shareinfo.getShareTitle()); +// shareJSON.setUid(shareinfo.getUid()); +// shareJSON.setUpCount(shareinfo.getUpCount()); +// shareJSON.setUserName(userer); +// shareJSON.setUserFace(latestlottery.getUserFace()); +// shareJSON.setUserId(latestlottery.getUserId()+""); +// ShareJSONList.add(shareJSON); +// } +// Struts2Utils.renderJson(ShareJSONList); +// } +// if(id.equals("reply20")){ +// Pagination page = shareService.loadPageShare("reply20",pageNo, pageSize); +// List pageList = (List) page.getList(); +// ShareJSONList = new ArrayList(); +// for (int i = 0; i < pageList.size(); i++) { +// shareJSON = new ShareJSON(); +// shareinfo = (Shareinfo) pageList.get(i)[0]; +// shareimage = (Shareimage) pageList.get(i)[1]; +// latestlottery = (Latestlottery) pageList.get(i)[2]; +// String userer = null; +// if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ +// userer = latestlottery.getBuyUser(); +// if(userer.indexOf("@")!=-1){ +// String[] u = userer.split("@"); +// String u1 = u[0].substring(0,2)+"***"; +// userer = u1+"@"+u[1]; +// }else{ +// userer = userer.substring(0,4)+ "*** "+userer.substring(7); +// } +// } +// shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); +// shareJSON.setReplyCount(shareinfo.getReplyCount()); +// shareJSON.setReward(shareinfo.getReward()); +// shareJSON.setShareContent(shareinfo.getShareContent()); +// shareJSON.setShareDate(shareinfo.getShareDate()); +// shareJSON.setShareImages(shareimage.getImages()); +// shareJSON.setShareTitle(shareinfo.getShareTitle()); +// shareJSON.setUid(shareinfo.getUid()); +// shareJSON.setUpCount(shareinfo.getUpCount()); +// shareJSON.setUserName(userer); +// shareJSON.setUserFace(latestlottery.getUserFace()); +// shareJSON.setUserId(latestlottery.getUserId()+""); +// ShareJSONList.add(shareJSON); +// } +// Struts2Utils.renderJson(ShareJSONList); +// } + + return null; + } + + public String shareShow(){ + + return null; + } + + public void indexSharecommentsList(){ + List objectList = shareService.getIndexSharecommentsList(); + shareCommentJSONList = new ArrayList(); + for (Object[] objects : objectList) { + user = (User) objects[0]; + sharecomments = (Sharecomments) objects[1]; + shareCommentJSON = new ShareCommentJSON(); + shareCommentJSON.setContent(sharecomments.getContent()); + shareCommentJSON.setCreateDate(sharecomments.getCreateDate()); + shareCommentJSON.setUid(sharecomments.getUid()); + shareCommentJSON.setUserFace(user.getFaceImg()); + shareCommentJSON.setShareInfoId(sharecomments.getShareInfoId()); + String userName = UserNameUtil.userName(user); + shareCommentJSON.setReCount(sharecomments.getReCount()); + shareCommentJSON.setUserName(userName); + shareCommentJSON.setUserId(user.getUserId()); + shareCommentJSONList.add(shareCommentJSON); + } + Struts2Utils.renderJson(shareCommentJSONList); + } + + //获取新浪短网址: http://www.ipdz.me/getShortUrl.html?shareURL=http://www.ipdz.me/share?uid=106433333 + //参考:https://www.douban.com/note/249723561/ + // [{"url_short":"http://t.cn/zWXySpZ","url_long":http://www.douban.com/note/249723561/","type":0}] + public void getShortUrl() { + String [] param = shareURL.split("uid="); + if(param!=null&¶m.length==2) { + JSONObject json= new JSONObject() ; + User user = userService.findById(param[1]); + if(user!=null&&StringUtils.isNotBlank(user.getInviteShortURL())) { + String str = "{\"url_short\":\""+user.getInviteShortURL()+"\",\"url_long\":\""+shareURL+"\",\"type\":0,\"result\":true}"; + str="{\"urls\":["+str+"]}"; + json = JSONObject.fromObject(str); + }else { + String sinaShortUrlApi= "http://api.t.sina.com.cn/short_url/shorten.json?source=3271760578&url_long="; + String resultText=""; + boolean result = true; + try { + resultText = HttpsClientUtils.get(sinaShortUrlApi+shareURL); + resultText = resultText.replace("\"url_short\":","\"object_type\":\"\",\"result\":true,\"url_short\":"); + } catch (Exception e) { + result = false; + resultText = "{\"object_type\":\"\",\"result\":false,\"errorInfo\":\""+e.getMessage()+"\"}"; + json = JSONObject.fromObject(resultText); + e.printStackTrace(); + } + resultText="{\"urls\":"+resultText+"}"; + if(result) { + json = JSONObject.fromObject(resultText); + String inviteShortURL = json.getJSONArray("urls").getJSONObject(0).getString("url_short"); + user.setInviteShortURL(inviteShortURL); + userService.add(user); //将获得 shortURL 存数据库 + } + } + Struts2Utils.renderJson(json); + } + + } + + public Shareinfo getShareinfo() { + return shareinfo; + } + + public void setShareinfo(Shareinfo shareinfo) { + this.shareinfo = shareinfo; + } + + public Shareimage getShareimage() { + return shareimage; + } + + public void setShareimage(Shareimage shareimage) { + this.shareimage = shareimage; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getShareJSONList() { + return ShareJSONList; + } + + public void setShareJSONList(List shareJSONList) { + ShareJSONList = shareJSONList; + } + + public ShareJSON getShareJSON() { + return shareJSON; + } + + public void setShareJSON(ShareJSON shareJSON) { + this.shareJSON = shareJSON; + } + + public String getId() { + return id; + } + + public String getShareURL() { + return shareURL; + } + + public void setShareURL(String shareURL) { + this.shareURL = shareURL; + } + + public void setId(String id) { + this.id = id; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getPages() { + return pages; + } + + public void setPages(String pages) { + this.pages = pages; + } + + public String getPageString() { + return pageString; + } + + public void setPageString(String pageString) { + this.pageString = pageString; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public List getShareCommentJSONList() { + return shareCommentJSONList; + } + + public void setShareCommentJSONList(List shareCommentJSONList) { + this.shareCommentJSONList = shareCommentJSONList; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Sharecomments getSharecomments() { + return sharecomments; + } + + public void setSharecomments(Sharecomments sharecomments) { + this.sharecomments = sharecomments; + } + + public ShareCommentJSON getShareCommentJSON() { + return shareCommentJSON; + } + + public void setShareCommentJSON(ShareCommentJSON shareCommentJSON) { + this.shareCommentJSON = shareCommentJSON; + } + + +} diff --git a/src/main/java/me/mofun/action/ShareShowAction.java b/src/main/java/me/mofun/action/ShareShowAction.java new file mode 100644 index 0000000..a0ffbbb --- /dev/null +++ b/src/main/java/me/mofun/action/ShareShowAction.java @@ -0,0 +1,622 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.LatestlotteryService; +import me.mofun.service.ShareService; +import me.mofun.service.SpellbuyproductService; +import me.mofun.service.UserService; +import me.mofun.util.DateUtil; +import me.mofun.util.HTMLFilter; +import me.mofun.util.Struts2Utils; +import me.mofun.util.UserNameUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Component("ShareShowAction") +public class ShareShowAction extends ActionSupport { + private static final long serialVersionUID = -5418862771252833639L; + + @Autowired + private ShareService shareService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private UserService userService; + + private ShareInfoPro shareInfoPro; + private Sharecomments sharecomments; + private ShareCommentJSON shareCommentJSON; + private List shareCommentJSONList; + private Shareinfo shareinfo; + private User user; + private List shareimageList; + private Latestlottery latestlottery; + private List latestlotteryList; + private Product product; + private Spellbuyproduct spellbuyproduct; + private ProductJSON productJSON; + private List ShareJSONList; + private ShareInfoJSON ShareInfoJSON; + private Shareimage shareimage; + + private String id; + private int pageNo; + private int pageSize = 5; + private int pageCount; + private int resultCount; + private String productId; + private String shareId; + private String userId; + private String shareCommentId; + private String commentText; + private String reCommentId; + + HttpServletRequest request = null; + static HTMLFilter htmlFilter = new HTMLFilter(); + + public String index(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + } + } + } + } + shareInfoPro = new ShareInfoPro(); + shareimageList = new ArrayList(); + List objectList = shareService.shareShow(Integer.parseInt(id)); + shareinfo = (Shareinfo) objectList.get(0)[0]; + latestlottery = (Latestlottery) objectList.get(0)[1]; + shareInfoPro.setAnnouncedTime(latestlottery.getAnnouncedTime()); + shareInfoPro.setBuyNumberCount(String.valueOf(latestlottery.getBuyNumberCount())); + shareInfoPro.setProductId(String.valueOf(latestlottery.getProductId())); + shareInfoPro.setProductImg(latestlottery.getProductImg()); + shareInfoPro.setProductName(latestlottery.getProductName()); + shareInfoPro.setProductPeriod(String.valueOf(latestlottery.getProductPeriod())); + shareInfoPro.setProductPrice(String.valueOf(latestlottery.getProductPrice())); + shareInfoPro.setProductTitle(latestlottery.getProductTitle()); + shareInfoPro.setSpellbuyProductId(String.valueOf(latestlottery.getSpellbuyProductId())); + shareInfoPro.setBuyDate(latestlottery.getBuyTime()); + shareInfoPro.setReplyCount(shareinfo.getReplyCount()); + shareInfoPro.setReward(shareinfo.getReward()); + shareInfoPro.setShareContent(shareinfo.getShareContent()); + shareInfoPro.setShareDate(shareinfo.getShareDate()); + shareInfoPro.setShareId(String.valueOf(shareinfo.getUid())); + shareInfoPro.setUserId(String.valueOf(shareinfo.getUserId())); + shareimageList = shareService.getShareimage(String.valueOf(shareinfo.getUid())); +// String shareImgList = ""; +// for (Shareimage shareimage : shareimageList) { +// shareImgList += shareimage.getImages().substring(shareimage.getImages().lastIndexOf("/")+1,shareimage.getImages().length())+","; +// } +// shareImgList = shareImgList.substring(0, shareImgList.length()-1); +// shareInfoPro.setShareimageList(shareImgList); + shareInfoPro.setShareTitle(shareinfo.getShareTitle()); + shareInfoPro.setSpellbuyProductId(String.valueOf(latestlottery.getSpellbuyProductId())); + shareInfoPro.setUpCount(shareinfo.getUpCount()); + shareInfoPro.setWinRandomNumber(String.valueOf(latestlottery.getRandomNumber())); + shareInfoPro.setWinUserFace(latestlottery.getUserFace()); + shareInfoPro.setWinUserName(latestlottery.getUserName()); + + Pagination datePage = shareService.shareByComment(id, pageNo, pageSize); + resultCount = datePage.getResultCount(); + + /** + * 最新晒单 + */ + Pagination page = shareService.loadShareInfoByNew("new20",pageNo, pageSize); + List pageList = (List) page.getList(); + ShareJSONList = new ArrayList(); + for (int i = 0; i < pageList.size(); i++) { + ShareInfoJSON = new ShareInfoJSON(); + shareinfo = (Shareinfo) pageList.get(i)[0]; + latestlottery = (Latestlottery) pageList.get(i)[1]; + String userName = ""; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userName = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userName = latestlottery.getBuyUser(); + if(userName.indexOf("@")!=-1){ + String[] u = userName.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userName = u1+"@"+u[1]; + }else{ + userName = userName.substring(0,4)+ "*** "+userName.substring(7); + } + } + ShareInfoJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); + ShareInfoJSON.setReplyCount(shareinfo.getReplyCount()); + ShareInfoJSON.setReward(shareinfo.getReward()); + ShareInfoJSON.setShareContent(shareinfo.getShareContent()); + ShareInfoJSON.setShareDate(DateUtil.getTime(DateUtil.SDateTimeToDate(shareinfo.getShareDate()))); + ShareInfoJSON.setShareimageList(shareService.getShareimage(shareinfo.getUid().toString())); + ShareInfoJSON.setShareTitle(shareinfo.getShareTitle()); + ShareInfoJSON.setUid(shareinfo.getUid()); + ShareInfoJSON.setUpCount(shareinfo.getUpCount()); + ShareInfoJSON.setUserName(userName); + ShareInfoJSON.setUserFace(latestlottery.getUserFace()); + ShareInfoJSON.setUserId(latestlottery.getUserId()+""); + ShareJSONList.add(ShareInfoJSON); + } + + return "index"; + } + + /** + * 根据产品Id获得晒单列表 + * gooddetail.js + * ajax url: "/shareShow/productInfoShareListByProductId.action", + * data: "id=" + _GoodsID + "&pageNo=" + pageNo, + * http://www.local.com/shareShow/productInfoShareListByProductId.action?id=1013&pageNo=1 + */ + public void productInfoShareListByProductId() { + Pagination p = shareService.productInfoShareListByProductId(Integer.parseInt(id), pageNo,10); + this.resultCount = p.getResultCount(); + List objArraytList = ( List)p.getList(); + //Pagination p = shareService.productInfoShareListByProductId(Integer.parseInt(id), pageNo,10); + //List objArraytList = ( List)shareService.productInfoShareListByProductId(Integer.parseInt(id)); + List userList = new ArrayList(); + List spellbuyproductList = new ArrayList(); + List latestlotteryList = new ArrayList(); + List shareInfoList = new ArrayList(); + List shareimageList = new ArrayList(); + for(Object[] objArray:objArraytList) { + if(! shareInfoList.contains(objArray[0])) shareInfoList.add((Shareinfo)objArray[0]); + if(! latestlotteryList.contains(objArray[1])) latestlotteryList.add((Latestlottery)objArray[1]); + if(! spellbuyproductList.contains(objArray[2])) spellbuyproductList.add((Spellbuyproduct)objArray[2]); + if(! shareimageList.contains(objArray[3])) shareimageList.add((Shareimage)objArray[3]); + if(! userList.contains(objArray[4])) userList.add((User)objArray[4]); + } + List ShareInfoAjaxList = new ArrayList(); + for(Shareinfo info:shareInfoList) { + ShareInfoAjax sa = new ShareInfoAjax(); + for(Shareimage img : shareimageList) { + if(img.getShareInfoId().intValue()==info.getUid().intValue()) { + //sa.shareimageList.add(img.getImages()); + sa.shareimageList.add(img); + } + } + for(User u :userList) { + if(u.getUserId().intValue()==info.getUserId().intValue()) { + sa.userId = u.getUserId(); + sa.userName = u.getUserName(); + sa.userFace = u.getFaceImg(); + break; + } + } + for(Spellbuyproduct sp : spellbuyproductList) { + if(sp.getSpellbuyProductId().intValue()==info.getProductId().intValue()) { + sa.productPeriod = sp.getProductPeriod(); + break; + } + } + sa.replyCount = info.getReplyCount(); + sa.shareContent = info.getShareContent(); + sa.shareDate = info.getShareDate(); + sa.shareTitle = info.getShareTitle(); + sa.uid = info.getUid(); + sa.upCount = info.getUpCount(); + ShareInfoAjaxList.add(sa); + } + Struts2Utils.renderJson(ShareInfoAjaxList); + } + + /** + * 商品其他期数获得者 + * @return + */ + public String productOtherWinUser(){ + latestlotteryList = latestlotteryService.getProductOtherWinUser(productId, shareId); + Struts2Utils.renderJson(latestlotteryList); + return null; + } + + /** + * 评论列表 + * @return + */ + public String shareCommentListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = shareService.shareByComment(shareId, pageNo, pageSize); + List dataList = (List) datePage.getList(); + shareCommentJSONList = new ArrayList(); + for (Object[] objects : dataList) { + user = (User) objects[0]; + sharecomments = (Sharecomments) objects[1]; + shareCommentJSON = new ShareCommentJSON(); + shareCommentJSON.setContent(sharecomments.getContent()); + shareCommentJSON.setCreateDate(sharecomments.getCreateDate()); + shareCommentJSON.setUid(sharecomments.getUid()); + shareCommentJSON.setUserFace(user.getFaceImg()); + shareCommentJSON.setShareInfoId(sharecomments.getShareInfoId()); + String userName = UserNameUtil.userName(user); + shareCommentJSON.setReCount(sharecomments.getReCount()); + shareCommentJSON.setUserName(userName); + shareCommentJSON.setUserId(user.getUserId()); + shareCommentJSONList.add(shareCommentJSON); + } + Struts2Utils.renderJson(shareCommentJSONList); + return null; + } + + /** + * 获取评论的评论列表 + */ + public void getReCommentList(){ + List objectList = shareService.getReCommentList(shareCommentId); + shareCommentJSONList = new ArrayList(); + for (Object[] objects : objectList) { + user = (User) objects[0]; + sharecomments = (Sharecomments) objects[1]; + shareCommentJSON = new ShareCommentJSON(); + shareCommentJSON.setContent(sharecomments.getContent()); + shareCommentJSON.setCreateDate(sharecomments.getCreateDate()); + shareCommentJSON.setUid(sharecomments.getUid()); + shareCommentJSON.setUserFace(user.getFaceImg()); + shareCommentJSON.setShareInfoId(sharecomments.getShareInfoId()); + String userName = UserNameUtil.userName(user); + shareCommentJSON.setReCount(sharecomments.getReCount()); + shareCommentJSON.setUserName(userName); + shareCommentJSON.setUserId(user.getUserId()); + shareCommentJSONList.add(shareCommentJSON); + } + Struts2Utils.renderJson(shareCommentJSONList); + } + + /** + * 发表评论 + */ + public void postComment(){ + try { + commentText = htmlFilter.filter(commentText); + shareId = htmlFilter.filter(shareId); + userId = htmlFilter.filter(userId); + sharecomments = new Sharecomments(); + sharecomments.setContent(commentText); + sharecomments.setCreateDate(DateUtil.DateTimeToStr(new Date())); + if(reCommentId!=null){ + sharecomments.setReCommentId(Integer.parseInt(reCommentId)); + Sharecomments sharecomments = shareService.findBySharecommentsId(reCommentId); + Integer reCount = sharecomments.getReCount(); + sharecomments.setReCount(reCount+1); + shareService.createComment(sharecomments); + } + sharecomments.setShareInfoId(Integer.parseInt(shareId)); + sharecomments.setUserId(Integer.parseInt(userId)); + sharecomments.setReCount(0); + shareService.createComment(sharecomments); + shareinfo = shareService.findById(shareId); + Integer replyCount = shareinfo.getReplyCount(); + shareinfo.setReplyCount(replyCount+1); + shareService.add(shareinfo); + Struts2Utils.renderText("true"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + + } + + /** + * 顶一下 + */ + public void upShareInfo(){ + shareinfo = shareService.findById(shareId); + Integer upCount = shareinfo.getUpCount(); + shareinfo.setUpCount(upCount+1); + shareService.add(shareinfo); + Struts2Utils.renderText("true"); + } + + + public class ShareInfoAjax{ + + private Integer userId; //用户ID + private String userFace; //用户头像 + private String userName; //用户姓名 + private Integer productPeriod; //商品期数 + private String shareTitle; //晒单标题 + private String shareDate; //晒单日期 + private Integer uid; //晒单记录的ID + private String shareContent; //晒单内容 + private List shareimageList; //晒单时包含的图片列表 + private Integer upCount; //点赞或羡慕的数量 + private Integer replyCount; //回复数 + + public ShareInfoAjax() { + shareimageList = new ArrayList(); + } + public Integer getUserId() { + return userId; + } + public void setUserId(Integer userId) { + this.userId = userId; + } + public String getUserFace() { + return userFace; + } + public void setUserFace(String userFace) { + this.userFace = userFace; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public Integer getProductPeriod() { + return productPeriod; + } + public void setProductPeriod(Integer productPeriod) { + this.productPeriod = productPeriod; + } + public String getShareTitle() { + return shareTitle; + } + public void setShareTitle(String shareTitle) { + this.shareTitle = shareTitle; + } + public String getShareDate() { + return shareDate; + } + public void setShareDate(String shareDate) { + this.shareDate = shareDate; + } + public Integer getUid() { + return uid; + } + public void setUid(Integer uid) { + this.uid = uid; + } + public String getShareContent() { + return shareContent; + } + public void setShareContent(String shareContent) { + this.shareContent = shareContent; + } + public List getShareimageList() { + return shareimageList; + } + public void setShareimageList(List shareimageList) { + this.shareimageList = shareimageList; + } + public Integer getUpCount() { + return upCount; + } + public void setUpCount(Integer upCount) { + this.upCount = upCount; + } + public Integer getReplyCount() { + return replyCount; + } + public void setReplyCount(Integer replyCount) { + this.replyCount = replyCount; + } + } + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public ShareInfoPro getShareInfoPro() { + return shareInfoPro; + } + + public void setShareInfoPro(ShareInfoPro shareInfoPro) { + this.shareInfoPro = shareInfoPro; + } + + public Sharecomments getSharecomments() { + return sharecomments; + } + + public void setSharecomments(Sharecomments sharecomments) { + this.sharecomments = sharecomments; + } + + public List getShareCommentJSONList() { + return shareCommentJSONList; + } + + public void setShareCommentJSONList(List shareCommentJSONList) { + this.shareCommentJSONList = shareCommentJSONList; + } + + public Shareinfo getShareinfo() { + return shareinfo; + } + + public void setShareinfo(Shareinfo shareinfo) { + this.shareinfo = shareinfo; + } + + public List getShareimageList() { + return shareimageList; + } + + public void setShareimageList(List shareimageList) { + this.shareimageList = shareimageList; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getLatestlotteryList() { + return latestlotteryList; + } + + public void setLatestlotteryList(List latestlotteryList) { + this.latestlotteryList = latestlotteryList; + } + + public String getProductId() { + return productId; + } + + public void setProductId(String productId) { + this.productId = productId; + } + + public String getShareId() { + return shareId; + } + + public void setShareId(String shareId) { + this.shareId = shareId; + } + + public ShareCommentJSON getShareCommentJSON() { + return shareCommentJSON; + } + + public void setShareCommentJSON(ShareCommentJSON shareCommentJSON) { + this.shareCommentJSON = shareCommentJSON; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getShareCommentId() { + return shareCommentId; + } + + public void setShareCommentId(String shareCommentId) { + this.shareCommentId = shareCommentId; + } + public String getCommentText() { + return commentText; + } + + public void setCommentText(String commentText) { + this.commentText = commentText; + } + public String getReCommentId() { + return reCommentId; + } + + public void setReCommentId(String reCommentId) { + this.reCommentId = reCommentId; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public List getShareJSONList() { + return ShareJSONList; + } + + public void setShareJSONList(List shareJSONList) { + ShareJSONList = shareJSONList; + } + + public ShareInfoJSON getShareInfoJSON() { + return ShareInfoJSON; + } + + public void setShareInfoJSON(ShareInfoJSON shareInfoJSON) { + ShareInfoJSON = shareInfoJSON; + } + + public Shareimage getShareimage() { + return shareimage; + } + + public void setShareimage(Shareimage shareimage) { + this.shareimage = shareimage; + } + +} diff --git a/src/main/java/me/mofun/action/TenpayAction.java b/src/main/java/me/mofun/action/TenpayAction.java new file mode 100644 index 0000000..04f95de --- /dev/null +++ b/src/main/java/me/mofun/action/TenpayAction.java @@ -0,0 +1,1033 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.tenpay.RequestHandler; +import me.mofun.tenpay.ResponseHandler; +import me.mofun.tenpay.client.ClientResponseHandler; +import me.mofun.tenpay.client.TenpayHttpClient; +import me.mofun.tenpay.config.TenpayConfig; +import me.mofun.tenpay.util.TenpayUtil; +import me.mofun.util.*; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; + +@SuppressWarnings("unused") +@Component("TenpayAction") +public class TenpayAction extends ActionSupport { + + private static final long serialVersionUID = 2460509323066698846L; + RandomUtil randomUtil = new RandomUtil(); + @Autowired + ConsumetableService consumetableService; + @Autowired + ConsumerdetailService consumerdetailService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private RandomnumberService randomnumberService; + @Autowired + private UserService userService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ProductService productService; + @Autowired + private NewLotteryUtil newLotteryUtil; + @Autowired + CommissionqueryService commissionqueryService; + @Autowired + CommissionpointsService commissionpointsService; + + private User user; + private String userId; + private Consumetable consumetable; + private ProductCart productCart; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private Randomnumber randomnumber; + private Latestlottery latestlottery; + private Consumerdetail consumerdetail; + private List productCartList; + private List successCartList; + private ProductJSON productJSON; + private String paymentStatus; + private Commissionquery commissionquery; + private Commissionpoints commissionpoints; + + //---------------生成订单号 开始------------------------ + //当前时间 yyyyMMddHHmmss + private String currTime = TenpayUtil.getCurrTime(); + //8位日期 + private String strTime = currTime.substring(8, currTime.length()); + //四位随机数 + private String strRandom = TenpayUtil.buildRandom(4) + ""; + //10位序列号,可以自行调整。 + private String strReq = strTime + strRandom; + //订单号,此处用时间加随机数生成,商户根据自己情况调整,只要保持全局唯一就行 + private String out_trade_no = strReq; + private Integer moneyCount; + private String productBody = ""; + private String productName; + private String bank_type; + private String hidUseBalance; + private String integral; + private String requestUrl; + + Random random = new Random(); + Calendar calendar = Calendar.getInstance(); + HttpServletRequest request = null; + HttpServletResponse response = null; + + //---------------生成订单号 结束------------------------ + + + public String goPay() throws ServletException, IOException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + //创建支付请求对象 + RequestHandler reqHandler = new RequestHandler(request, response); + reqHandler.init(); + + //设置密钥 + reqHandler.setKey(TenpayConfig.key); + //设置支付网关 + reqHandler.setGateUrl("https://gw.tenpay.com/gateway/pay.htm"); + //----------------------------- + //设置支付参数 + //----------------------------- + moneyCount = moneyCount * 100; + reqHandler.setParameter("partner", TenpayConfig.partner); //商户号 + reqHandler.setParameter("out_trade_no", out_trade_no); //商家订单号 + reqHandler.setParameter("total_fee", moneyCount+""); //商品金额,以分为单位 + reqHandler.setParameter("return_url", TenpayConfig.return_url); //交易完成后跳转的URL + reqHandler.setParameter("notify_url", TenpayConfig.notify_url); //接收财付通通知的URL + reqHandler.setParameter("body",ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")"); //商品描述 + reqHandler.setParameter("bank_type",bank_type); //银行类型(中介担保时此参数无效) +// reqHandler.setParameter("spbill_create_ip",request.getRemoteAddr()); //用户的公网ip,不是商户服务器IP + reqHandler.setParameter("spbill_create_ip",request.getHeader("X-Real-IP")==null?request.getRemoteAddr():request.getRemoteAddr()); //用户的公网ip,不是商户服务器IP + reqHandler.setParameter("fee_type", "1"); //币种,1人民币 + reqHandler.setParameter("subject", productName); //商品名称(中介交易时必填) + + //系统可选参数 + reqHandler.setParameter("sign_type", "MD5"); //签名类型,默认:MD5 + reqHandler.setParameter("service_version", "1.0"); //版本号,默认为1.0 + reqHandler.setParameter("input_charset", "UTF-8"); //字符编码 + reqHandler.setParameter("sign_key_index", "1"); //密钥序号 + + + //业务可选参数 + reqHandler.setParameter("attach", integral); //附加数据,原样返回 +// reqHandler.setParameter("product_fee", ""); //商品费用,必须保证transport_fee + product_fee=total_fee +// reqHandler.setParameter("transport_fee", "0"); //物流费用,必须保证transport_fee + product_fee=total_fee +// reqHandler.setParameter("time_start", currTime); //订单生成时间,格式为yyyymmddhhmmss +// reqHandler.setParameter("time_expire", ""); //订单失效时间,格式为yyyymmddhhmmss +// reqHandler.setParameter("buyer_id", ""); //买方财付通账号 +// reqHandler.setParameter("goods_tag", ""); //商品标记 +// reqHandler.setParameter("trade_mode", "1"); //交易模式,1即时到账(默认),2中介担保,3后台选择(买家进支付中心列表选择) +// reqHandler.setParameter("transport_desc", ""); //物流说明 +// reqHandler.setParameter("trans_type", "1"); //交易类型,1实物交易,2虚拟交易 +// reqHandler.setParameter("agentid", ""); //平台ID +// reqHandler.setParameter("agent_type", ""); //代理模式,0无代理(默认),1表示卡易售模式,2表示网店模式 +// reqHandler.setParameter("seller_id", ""); //卖家商户号,为空则等同于partner + + + /** + * 业务开始 + */ + productCartList = new ArrayList(); + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); +// if(userId!=null && !userId.equals("")){ +// user = userService.findById(userId); +// } + } + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + if(StringUtil.isNotBlank(userId)){ + Integer buyConut = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + buyConut += count; + productCount ++; + productCart.setCount(count); + productCart.setHeadImage(product.getHeadImage()); +// productCart.setMoneyCount(buyConut); + productCart.setProductCount(productCount); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + productCartList.add(productCart); + flag = true; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } +// moneyCount 财付通充值的钱 600 +// buyConut 要花的钱 7 +// hidUseBalance 余额的钱 1 buyConut=moneyCount+hidUseBalance + if(flag){ + try { + consumetable = new Consumetable(); + double money = Double.parseDouble(String.valueOf(moneyCount)); + money = money * 0.01; + consumetable.setBuyCount(buyConut); //要花的钱 7 + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + consumetable.setInterfaceType("tenPay"); + consumetable.setMoney(money); //财付通充值的钱 6 + consumetable.setOutTradeNo(out_trade_no); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); +// for (ProductCart productCart : productCartList) { +// try { +// consumerdetail = new Consumerdetail(); +// consumerdetail.setBuyCount(productCart.getCount()); +// consumerdetail.setBuyMoney(Double.parseDouble(productCart.getCount().toString())); +// consumerdetail.setConsumetableId(out_trade_no); +// consumerdetail.setProductId(productCart.getProductId()); +// consumerdetail.setProductName(productCart.getProductName()); +// consumerdetail.setProductPeriod(productCart.getProductPeriod()); +// consumerdetail.setProductTitle(productCart.getProductTitle()); +// consumerdetailService.add(consumerdetail); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } + } catch (Exception e) { + e.printStackTrace(); + flag = false; + } + }else{ + flag = false; + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + + //请求的url + requestUrl = reqHandler.getRequestURL(); + + //获取debug信息,建议把请求和debug信息写入日志,方便定位问题 + String debuginfo = reqHandler.getDebugInfo(); + System.out.println("requestUrl: " + requestUrl); + System.out.println("sign_String: " + debuginfo); +// return request.getRequestDispatcher(requestUrl).forward(request, response); + if(flag){ + response.sendRedirect(requestUrl); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + return null; + } + + public String returnUrl(){ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + //创建支付应答对象 + ResponseHandler resHandler = new ResponseHandler(request, response); + resHandler.setKey(TenpayConfig.key); + System.out.println("前台回调返回参数:"+resHandler.getAllParameters()); + boolean flag = false; + String buyproduct ="";// 已经被买完的商品 + //判断签名 + if(resHandler.isTenpaySign()) { + //通知id + String notify_id = resHandler.getParameter("notify_id"); + //商户订单号 + String out_trade_no = resHandler.getParameter("out_trade_no"); + //财付通订单号 + String transaction_id = resHandler.getParameter("transaction_id"); + //金额,以分为单位 + String total_fee = resHandler.getParameter("total_fee"); + //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee + String discount = resHandler.getParameter("discount"); + //支付结果 + String trade_state = resHandler.getParameter("trade_state"); + //交易模式,1即时到账,2中介担保 + String trade_mode = resHandler.getParameter("trade_mode"); + + String integral = resHandler.getParameter("attach"); + + System.err.println("returnUrl integral:" +integral); + + if("1".equals(trade_mode)){ //即时到账 + if( "0".equals(trade_state)){ + //------------------------------ + //即时到账处理业务开始 + //------------------------------ + try { + String key = MD5Util.encode(transaction_id); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + MemCachedClientHelp.getIMemcachedCache().put(key, "y",new Date(12*60*60*1000)); + productCartList = new ArrayList(); + successCartList = new ArrayList(); + try { + consumetable = consumetableService.findByOutTradeNo(out_trade_no);//找到订单 + double money = Double.parseDouble(String.valueOf(total_fee));//充值的钱 *100 + money = money * 0.01; + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money)){ + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + } + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + //总购买钱数 + Integer moneyCount = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + moneyCount += count; + productCount ++; + productCart.setCount(count); + productCart.setHeadImage(product.getHeadImage()); + productCart.setMoneyCount(moneyCount); + productCart.setProductCount(productCount); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + productCartList.add(productCart); + flag = true; + }else{ + buyproduct += "您购买的商品中 " + product.getProductName() + " 已经满员.
    "; +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// flag = false; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + if(StringUtil.isNotBlank(userId)){ + user = userService.findById(userId); + } + + if(flag){ + for (final ProductCart productCart : productCartList) { + try { + spellbuyproduct = spellbuyproductService.findById(productCart.getProductId().toString()); + //真正要购买的数量 + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+productCart.getCount()) > productCart.getProductPrice()){ + count = productCart.getProductPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = productCart.getCount(); + } + + if(count>0){ + if(StringUtil.isNotBlank(integral) || !integral.equals("0")){ + if(user.getBalance()>=(count-(Integer.parseInt(integral)/100))){ + Double temp = user.getBalance() - (count-(Integer.parseInt(integral)/100)); + user.setBalance(temp); +// userService.add(user); + + consumerdetail = new Consumerdetail(); + consumerdetail.setBuyCount(count); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + consumerdetail.setProductTitle(productCart.getProductTitle()); + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + commissionquery = new Commissionquery(); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + }else{ + if(user.getBalance()>=count){ + Double temp = user.getBalance() - count; + user.setBalance(temp); + + consumerdetail = new Consumerdetail(); + consumerdetail.setBuyCount(count); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setConsumetableId(out_trade_no); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + consumerdetail.setProductTitle(productCart.getProductTitle()); + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + commissionquery = new Commissionquery(); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + + + spellbuyproduct.setSpellbuyCount(spellbuyproduct.getSpellbuyCount()+count); + if(spellbuyproduct.getSpellbuyCount()>=productCart.getProductPrice()){ + spellbuyproduct.setSpellbuyCount(productCart.getProductPrice()); + //开奖状态 + spellbuyproduct.setSpStatus(2); + spellbuyproduct.setSpellbuyEndDate(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + } + spellbuyproductService.add(spellbuyproduct); + + spellbuyrecord = new Spellbuyrecord(); + spellbuyrecord.setFkSpellbuyProductId(spellbuyproduct.getSpellbuyProductId()); + spellbuyrecord.setBuyer(user.getUserId()); + spellbuyrecord.setBuyPrice(count); + spellbuyrecord.setBuyDate(DateUtil.DateTimeToStrBySSS(new Date())); + spellbuyrecord.setSpWinningStatus("0"); + spellbuyrecord.setBuyStatus("0"); + spellbuyrecord.setSpRandomNo(""); + spellbuyrecordService.add(spellbuyrecord); + randomnumber = new Randomnumber(); + randomnumber.setProductId(productCart.getProductId()); + + List RandomnumberList = randomnumberService.query(" from Randomnumber where productId='"+ spellbuyproduct.getSpellbuyProductId() + +"'"); + List oldRandomList = new ArrayList(); + for (Randomnumber randomnumber : RandomnumberList) { + if(randomnumber.getRandomNumber().contains(",")){ + String[] rs = randomnumber.getRandomNumber().split(","); + for (String string : rs) { + oldRandomList.add(string); + } + }else{ + oldRandomList.add(randomnumber.getRandomNumber()); + } + } + randomnumber.setRandomNumber(randomUtil.newRandom(count,spellbuyproduct.getSpellbuyPrice(),oldRandomList)); + + randomnumber.setSpellbuyrecordId(spellbuyrecord.getSpellbuyRecordId()); + randomnumber.setBuyDate(spellbuyrecord.getBuyDate()); + randomnumber.setUserId(Integer.parseInt(userId)); + randomnumberService.add(randomnumber); + + if(StringUtil.isNotBlank(integral) && !integral.equals("0")){ + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + } + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count+"元获得福分"); + commissionpoints.setPay("+"+((count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())-(Integer.parseInt(integral)/100))); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points+((count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())-(Integer.parseInt(integral)/100))); + + Integer experience = user.getExperience(); + experience += (count*10); + user.setExperience(experience); + userService.add(user); + + productJSON = new ProductJSON(); + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductId(productCart.getProductId()); + productJSON.setProductName(productCart.getProductName()); + productJSON.setProductPeriod(productCart.getProductPeriod()); + productJSON.setProductTitle(productCart.getProductTitle()); + productJSON.setBuyCount(count); + successCartList.add(productJSON); + +// if(spellbuyproduct.getSpStatus()==2){ +// /** +// * 开奖工具类 +// */ +// String lotteryId = MD5Util.encode(String.valueOf(spellbuyproduct.getSpellbuyProductId())); +// if(MemCachedClientHelp.getIMemcachedCache().get(lotteryId)==null){ +// MemCachedClientHelp.getIMemcachedCache().put(lotteryId, "y",new Date(12*60*60*1000)); +// new Thread(){ +// public void run(){ +// try { +// newLotteryUtil.lottery(productCart); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// }.start(); +// } +// } + } + + + } catch (Exception e) { + e.printStackTrace(); + flag = false; + } + + + } + + } + if(flag){ + /** + * 清空购物车 + */ + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("products",null); + cookie.setMaxAge(0); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + request.setAttribute("buyproduct", buyproduct); + System.out.println("即时到帐付款成功"); + paymentStatus = "success"; + + } + } catch (Exception e) { + e.printStackTrace(); + } + }else{ + System.out.println("即时到帐付款失败"); + paymentStatus = "error"; + } + }else if("2".equals(trade_mode)){ //中介担保 + if( "0".equals(trade_state)){ + //------------------------------ + //中介担保处理业务开始 + //------------------------------ + + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //中介担保处理业务完毕 + //------------------------------ + + System.out.println("中介担保付款成功"); + }else{ + System.out.println("trade_state=" + trade_state); + } + } + } else { + System.out.println("认证签名失败"); + } + + //获取debug信息,建议把debug信息写入日志,方便定位问题 + String debuginfo = resHandler.getDebugInfo(); + System.out.println("debuginfo:" + debuginfo); + return "success"; + } + + public String notifyUrl() throws Exception{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String buyproduct ="";// 已经被买完的商品 + //创建支付应答对象 + ResponseHandler resHandler = new ResponseHandler(request, response); + resHandler.setKey(TenpayConfig.key); + System.out.println("后台回调返回参数:"+resHandler.getAllParameters()); + //判断签名 + if(resHandler.isTenpaySign()) { + //通知id + String notify_id = resHandler.getParameter("notify_id"); + //创建请求对象 + RequestHandler queryReq = new RequestHandler(null, null); + //通信对象 + TenpayHttpClient httpClient = new TenpayHttpClient(); + //应答对象 + ClientResponseHandler queryRes = new ClientResponseHandler(); + + String integral = resHandler.getParameter("attach"); + + //通过通知ID查询,确保通知来至财付通 + queryReq.init(); + queryReq.setKey(TenpayConfig.key); + queryReq.setGateUrl("https://gw.tenpay.com/gateway/simpleverifynotifyid.xml"); + queryReq.setParameter("partner", TenpayConfig.partner); + queryReq.setParameter("notify_id", notify_id); + queryReq.setParameter("attach", integral); + //通信对象 + httpClient.setTimeOut(5); + //设置请求内容 + httpClient.setReqContent(queryReq.getRequestURL()); + System.out.println("验证ID请求字符串:" + queryReq.getRequestURL()); + //后台调用 + if(httpClient.call()) { + //设置结果参数 + queryRes.setContent(httpClient.getResContent()); + System.out.println("验证ID返回字符串:" + httpClient.getResContent()); + queryRes.setKey(TenpayConfig.key); + //获取id验证返回状态码,0表示此通知id是财付通发起 + String retcode = queryRes.getParameter("retcode"); + //商户订单号 + String out_trade_no = resHandler.getParameter("out_trade_no"); + //财付通订单号 + String transaction_id = resHandler.getParameter("transaction_id"); + //金额,以分为单位 + String total_fee = resHandler.getParameter("total_fee"); + //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee + String discount = resHandler.getParameter("discount"); + //支付结果 + String trade_state = resHandler.getParameter("trade_state"); + //交易模式,1即时到账,2中介担保 + String trade_mode = resHandler.getParameter("trade_mode"); + //判断签名及结果 + if(queryRes.isTenpaySign()&& "0".equals(retcode)){ + System.out.println("id验证成功"); + if("1".equals(trade_mode)){ //即时到账 + if( "0".equals(trade_state)){ + //------------------------------ + //即时到账处理业务开始 + try { + consumetable = consumetableService.findByOutTradeNo(out_trade_no); + double money = Double.parseDouble(String.valueOf(total_fee)); + money = money * 0.01; + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId()==null){ + consumetable.setTransactionId(transaction_id); + consumetableService.add(consumetable); + + user = userService.findById(String.valueOf(consumetable.getUserId())); + user.setBalance(money+user.getBalance()); + userService.add(user); + + flag = true; + } + } catch (Exception e) { + flag = false; + e.printStackTrace(); + } + + //------------------------------ + + //处理数据库逻辑 + //注意交易单不要重复处理 + //注意判断返回金额 + + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + +// System.out.println("即时到账支付成功"); + //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知 + resHandler.sendToCFT("success"); + }else{ + System.out.println("即时到账支付失败"); + resHandler.sendToCFT("fail"); + } + }else if("2".equals(trade_mode)){ //中介担保 + //------------------------------ + //中介担保处理业务开始 + //------------------------------ + + //处理数据库逻辑 + //注意交易单不要重复处理 + //注意判断返回金额 + + int iStatus = TenpayUtil.toInt(trade_state); + switch(iStatus) { + case 0: //付款成功 + + break; + case 1: //交易创建 + + break; + case 2: //收获地址填写完毕 + + break; + case 4: //卖家发货成功 + + break; + case 5: //买家收货确认,交易成功 + + break; + case 6: //交易关闭,未完成超时关闭 + + break; + case 7: //修改交易价格成功 + + break; + case 8: //买家发起退款 + + break; + case 9: //退款成功 + + break; + case 10: //退款关闭 + + break; + default: + } + + //------------------------------ + //中介担保处理业务完毕 + //------------------------------ + + System.out.println("trade_state = " + trade_state); + //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知 + resHandler.sendToCFT("success"); + } + }else{ + //错误时,返回结果未签名,记录retcode、retmsg看失败详情。 + System.out.println("查询验证签名失败或id验证失败"+",retcode:" + queryRes.getParameter("retcode")); + } + } else { + System.out.println("后台调用通信失败"); + System.out.println(httpClient.getResponseCode()); + System.out.println(httpClient.getErrInfo()); + //有可能因为网络原因,请求已经处理,但未收到应答。 + } + }else{ + System.out.println("通知签名验证失败"); + } + return null; + } + + public Integer getMoneyCount() { + return moneyCount; + } + + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + + public String getProductBody() { + return productBody; + } + + public void setProductBody(String productBody) { + this.productBody = productBody; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getBank_type() { + return bank_type; + } + + public void setBank_type(String bank_type) { + this.bank_type = bank_type; + } + + public String getCurrTime() { + return currTime; + } + + public void setCurrTime(String currTime) { + this.currTime = currTime; + } + + public String getStrTime() { + return strTime; + } + + public void setStrTime(String strTime) { + this.strTime = strTime; + } + + public String getStrRandom() { + return strRandom; + } + + public void setStrRandom(String strRandom) { + this.strRandom = strRandom; + } + + public String getStrReq() { + return strReq; + } + + public void setStrReq(String strReq) { + this.strReq = strReq; + } + + public String getOut_trade_no() { + return out_trade_no; + } + + public void setOut_trade_no(String out_trade_no) { + this.out_trade_no = out_trade_no; + } + + public String getRequestUrl() { + return requestUrl; + } + + public void setRequestUrl(String requestUrl) { + this.requestUrl = requestUrl; + } + + public String getHidUseBalance() { + return hidUseBalance; + } + + public void setHidUseBalance(String hidUseBalance) { + this.hidUseBalance = hidUseBalance; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Consumetable getConsumetable() { + return consumetable; + } + + public void setConsumetable(Consumetable consumetable) { + this.consumetable = consumetable; + } + + public List getProductCartList() { + return productCartList; + } + + public void setProductCartList(List productCartList) { + this.productCartList = productCartList; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Consumerdetail getConsumerdetail() { + return consumerdetail; + } + + public void setConsumerdetail(Consumerdetail consumerdetail) { + this.consumerdetail = consumerdetail; + } + + public ProductCart getProductCart() { + return productCart; + } + + public void setProductCart(ProductCart productCart) { + this.productCart = productCart; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public String getPaymentStatus() { + return paymentStatus; + } + + public void setPaymentStatus(String paymentStatus) { + this.paymentStatus = paymentStatus; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getSuccessCartList() { + return successCartList; + } + + public void setSuccessCartList(List successCartList) { + this.successCartList = successCartList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public Commissionquery getCommissionquery() { + return commissionquery; + } + + public void setCommissionquery(Commissionquery commissionquery) { + this.commissionquery = commissionquery; + } + + public Commissionpoints getCommissionpoints() { + return commissionpoints; + } + + public void setCommissionpoints(Commissionpoints commissionpoints) { + this.commissionpoints = commissionpoints; + } + + public String getIntegral() { + return integral; + } + + public void setIntegral(String integral) { + this.integral = integral; + } + + + +} diff --git a/src/main/java/me/mofun/action/UserAction.java b/src/main/java/me/mofun/action/UserAction.java new file mode 100644 index 0000000..aecd098 --- /dev/null +++ b/src/main/java/me/mofun/action/UserAction.java @@ -0,0 +1,2600 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.*; +import net.sf.json.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts2.ServletActionContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +@SuppressWarnings("unused") +@Component("UserAction") +public class UserAction extends ActionSupport { + private static final long serialVersionUID = 6146740235643445087L; + + @Autowired + private UserService userService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ShareService shareService; + @Autowired + private ConsumetableService consumetableService; + @Autowired + private NewsService newsService; + @Autowired + private RegionService regionService; + @Autowired + private CommissionqueryService commissionqueryService; + @Autowired + private CommissionpointsService commissionpointsService; + @Autowired + private ApplymentionService applymentionService; + @Autowired + private CardpasswordService cardpasswordService; + @Autowired + private OrderdetailService orderdetailService; + + private String forward; + private List productList; + private List newDateList; + private ProductJSON productJSON; + private BuyHistoryJSON buyHistoryJSON; + private ShareJSON shareJSON; + private List buyHistoryJSONList; + private List randomNumberJSONList; + private RandomNumberJSON randomNumberJSON; + private List shareJSONList; + private List userbyaddressList; + private List newsList; + private List sProvinceList; + private List sCityList; + private List sDistrictList; + private List userList; + private List commissionqueryList; + private List commissionpointsList; + private List applymentionList; + private List commissionqueryJSONList; + private List orderdetailList; + private Orderdetail orderdetail; + private OrderDetailAddress orderDetailAddress; + private CommissionqueryJSON commissionqueryJSON; + private Applymention applymention; + private Commissionquery commissionquery; + private Commissionpoints commissionpoints; + private Userbyaddress userbyaddress; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private Randomnumber randomnumber; + private Latestlottery latestlottery; + private Shareinfo shareinfo; + private User user; + private String userJSON; + private String userId; + private String id; + private int pageNo; + private int pageSize = 12; + private int pageCount; + private int resultCount; + private String startDate; + private String endDate; + private String selectTime; + private File myFile; + private String myFileFileName; + private String myFileContentType; + private String imageFileName; + private static final int BUFFER_SIZE = 100 * 1024 ; + private int x1; + private int y1; + private int w; + private int h; + private String hidPicUrl; + + private String userName; + private String key; //用户邮箱或手机验证时用(/user/EmailChecking.jsp、/user/MobileChecking.jsp) + + HttpServletRequest request = null; + HttpServletResponse response = null; + static HTMLFilter htmlFilter = new HTMLFilter(); + + Logger logger = Logger.getLogger(this.getClass()); + String UploadImages = "/uploadImages"; + String FaceImages = "/faceImages"; + + //文件上传 + private static void copy(File src, File dst) { + try { + InputStream in = null ; + OutputStream out = null ; + try { + in = new BufferedInputStream( new FileInputStream(src), BUFFER_SIZE); + out = new BufferedOutputStream( new FileOutputStream(dst), BUFFER_SIZE); + byte [] buffer = new byte [BUFFER_SIZE]; + while (in.read(buffer) > 0 ) { + out.write(buffer); + } + } finally { + if ( null != in) { + in.close(); + } + if ( null != out) { + out.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String index(){ + if(StringUtil.isNotBlank(forward)){ + forward = htmlFilter.filter(forward); + } + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + /** + * 即将揭晓商品 + */ + Pagination datePage = spellbuyproductService.upcomingAnnounced(pageNo, 5); + List dataList = (List) datePage.getList(); + productList = new ArrayList(); + for (int j = 0; j < dataList.size(); j++) { + productJSON = new ProductJSON(); + product = (Product) dataList.get(j)[0]; + spellbuyproduct = (Spellbuyproduct) dataList.get(j)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSON.setProductTitle(product.getProductTitle()); + productList.add(productJSON); + } + +// /** +// * 最新上架 +// */ +// Pagination datePage2 = spellbuyrecordService.nowUpProducts(pageNo, 5); +// List dataList2 = (List) datePage2.getList(); +// newDateList = new ArrayList(); +// for (int j = 0; j < dataList2.size(); j++) { +// productJSON = new ProductJSON(); +// product = (Product) dataList2.get(j)[0]; +// spellbuyproduct = (Spellbuyproduct) dataList2.get(j)[1]; +// productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); +// productJSON.setHeadImage(product.getHeadImage()); +// productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); +// productJSON.setProductName(product.getProductName()); +// productJSON.setProductPrice(product.getProductPrice()); +// productJSON.setProductTitle(product.getProductTitle()); +// newDateList.add(productJSON); +// } + + /** + * 新闻 + */ + newsList = newsService.indexNews(1,3); + return "index"; + } + } + } + } + return "login_index"; + } + + /** + * 拍购记录 + * @return + */ + public String UserBuyList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + resultCount = spellbuyrecordService.buyHistoryByUserByCount(userId,startDate,endDate); + return "UserBuyList"; + } + } + } + } + return "login_index"; + } + + /** + * 选择日期查询得到拍购记录resultCount 总数 + */ + public void getuserBuyListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = spellbuyrecordService.buyHistoryByUserByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 拍购记录ajax分页请求 + * @return + */ + public String userBuyListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = spellbuyrecordService.buyHistoryByUser(userId,startDate,endDate, pageNo, 5); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + + for (int j = 0; j < dataList.size(); j++) { + try { + buyHistoryJSON = dataList.get(j); + if(buyHistoryJSON.getBuyStatus()==1){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(buyHistoryJSON.getProductId()).get(0); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUser(userer); + buyHistoryJSON.setWinUserId(latestlottery.getUserId()); + } + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 查看商品详情 + * @return + */ + public String UserBuyDetail(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + buyHistoryJSON = (BuyHistoryJSON) spellbuyrecordService.getBuyHistoryByDetail(id,userId).get(0); + if(buyHistoryJSON.getBuyStatus()==1){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(buyHistoryJSON.getProductId()).get(0); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUser(userer); + buyHistoryJSON.setWinUserId(latestlottery.getUserId()); + } + resultCount = spellbuyrecordService.getRandomNumberListPageByCount(id,userId); + return "UserBuyDetail"; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "login_index"; + } + + /** + * 取得某条购买记录的拍购码(list 页) + */ + public void getRandomNumberList(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + List dataList = spellbuyrecordService.getRandomNumberList(id,userId); + randomNumberJSONList = new ArrayList(); + String numbers = ""; + for (Randomnumber randomnumber : dataList) { + String [] randoms = randomnumber.getRandomNumber().split(","); + for (String string : randoms) { + numbers += "
  • " +string+"
  • "; + } + } + Struts2Utils.renderText(numbers); + } + + /** + * 取得某条购买记录的拍购码(详细页面) + */ + public void getRandomNumberListPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = spellbuyrecordService.getRandomNumberListPage(id,userId, pageNo, 50); + List dataList = (List) datePage.getList(); + randomNumberJSONList = new ArrayList(); + for (Randomnumber randomnumber : dataList) { + try { + randomNumberJSON = new RandomNumberJSON(); + String [] randoms = randomnumber.getRandomNumber().split(","); + String numbers = ""; + for (String string : randoms) { + numbers += "" +string+""; + } + randomNumberJSON.setRandomNumbers(numbers); + randomNumberJSON.setBuyCount(String.valueOf(randoms.length)); + randomNumberJSON.setBuyDate(randomnumber.getBuyDate()); + randomNumberJSONList.add(randomNumberJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.renderJson(randomNumberJSONList); + } + + /** + * 获得的商品 + * @return + */ + public String OrderList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = latestlotteryService.getProductByUserByCount(userId,startDate,endDate); + return "OrderList"; + } + } + } + } + return "login_index"; + } + + /** + * 获得的商品AJAX分页 + * @return + */ + public String OrderListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = latestlotteryService.getProductByUser(userId,startDate,endDate, pageNo, 5); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + for (int j = 0; j < dataList.size(); j++) { + try { + buyHistoryJSON = new BuyHistoryJSON(); + latestlottery = dataList.get(j); + buyHistoryJSON.setProductName(latestlottery.getProductName()); + buyHistoryJSON.setProductTitle(latestlottery.getProductTitle()); + buyHistoryJSON.setProductImg(latestlottery.getProductImg()); + buyHistoryJSON.setProductId(latestlottery.getSpellbuyProductId()); + buyHistoryJSON.setProductPrice(latestlottery.getProductPrice()); + buyHistoryJSON.setProductPeriod(latestlottery.getProductPeriod()); + buyHistoryJSON.setBuyTime(latestlottery.getBuyTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setBuyStatus(latestlottery.getStatus()); + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 选择日期查询得到获得的商品resultCount 总数 + */ + public void OrderListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = latestlotteryService.getProductByUserByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 获取的商品详情 + * @return + */ + public String OrderDetail(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + latestlottery = latestlotteryService.findById(id); + if(latestlottery.getStatus()==1){ + userbyaddressList = userService.getUserbyaddress(userId); + sProvinceList = regionService.getProvinceList(); + }else{ + orderdetailList = latestlotteryService.orderDetailListById(id); + orderDetailAddress = latestlotteryService.orderDetailAddressFindByOrderDetailId(id); + } + return "OrderDetail"; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "login_index"; + } + + /** + * 获取的商品详情-确认收货地址 + * @return + */ + public void OrderDetailAddAddress(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + JSONObject object = JSONObject.fromObject(userJSON); + String orderRemarks = object.getString("orderRemarks"); + String postDate = object.getString("postDate"); + String hidOrderNO = object.getString("hidOrderNO"); + id = object.getString("id"); + userbyaddress = userService.findAddressById(Integer.parseInt(id)); + orderDetailAddress = new OrderDetailAddress(); + orderDetailAddress.setAddress(userbyaddress.getProvince()+" "+userbyaddress.getCity()+" "+userbyaddress.getDistrict()+" "+userbyaddress.getAddress()); + orderDetailAddress.setConsignee(userbyaddress.getConsignee()); + orderDetailAddress.setOrderRemarks(orderRemarks);//订单备注 + orderDetailAddress.setPostDate(postDate);//配送时间 + orderDetailAddress.setPhone(userbyaddress.getPhone()); + orderDetailAddress.setOrderDetailId(Integer.parseInt(hidOrderNO)); + latestlotteryService.addOrderDetailAddress(orderDetailAddress); + orderdetail = new Orderdetail(); + orderdetail.setDate(DateUtil.DateTimeToStr(new Date())); + orderdetail.setDetailText("会员已确认配送地址信息,等待商城发货"); + orderdetail.setOrderDetailId(Integer.parseInt(hidOrderNO)); + orderdetail.setUserName("会员本人"); + orderdetailService.add(orderdetail); + latestlottery = latestlotteryService.findById(hidOrderNO); + latestlottery.setStatus(2); + latestlotteryService.add(latestlottery); + Struts2Utils.renderText("success"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + /** + * 获取的商品详情-确认收到货物 + * @return + */ + public void confirmOrderDetail(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + latestlottery = latestlotteryService.findById(id); + latestlottery.setStatus(4); + latestlottery.setShareStatus(-1); + latestlotteryService.add(latestlottery); + orderdetail = new Orderdetail(); + orderdetail.setDate(DateUtil.DateTimeToStr(new Date())); + orderdetail.setDetailText("会员已确认收到商品。"); + orderdetail.setOrderDetailId(latestlottery.getSpellbuyProductId()); + orderdetail.setUserName("会员本人"); + orderdetailService.add(orderdetail); + Struts2Utils.renderText("success"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + public String PostSingleAdd(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + + return "PostSingleAdd"; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "login_index"; + } + + /** + * 我的晒单 + * @return + */ + public String PostSingleList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); +// Pagination datePage = shareService.shareByUser(userId,startDate,endDate, pageNo, 5); +// resultCount = datePage.getResultCount(); + return "PostSingleList"; + } + } + } + } + return "login_index"; + } + + /** + * 我的晒单分页AJAX + * @return + */ + public String PostSingleListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = shareService.shareByUser(userId,startDate,endDate, pageNo, 5); + List pageList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + for (int j = 0; j < pageList.size(); j++) { + try { + buyHistoryJSON = new BuyHistoryJSON(); + latestlottery = pageList.get(j); + buyHistoryJSON.setProductName(latestlottery.getProductName()); + buyHistoryJSON.setProductTitle(latestlottery.getProductTitle()); + buyHistoryJSON.setProductImg(latestlottery.getProductImg()); + buyHistoryJSON.setProductId(latestlottery.getProductId()); + buyHistoryJSON.setProductPeriod(latestlottery.getProductPeriod()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setBuyStatus(latestlottery.getShareStatus()); + buyHistoryJSON.setWinUserId(latestlottery.getShareId()); + buyHistoryJSON.setHistoryId(latestlottery.getId()); + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 选择日期查询得到我的晒单resultCount 总数 + */ + public void PostSingleListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = shareService.shareByUser(userId,startDate,endDate, pageNo, 5); + resultCount = datePage.getResultCount(); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 邀请好友 + * @return + */ + public String InvitedList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = userService.getInvitedListByCount(userId); + userList = userService.getInvitedListByData(userId); + for (User user : userList) { + if(user.getExperience()>0){ + w++; + h+=50; + } + } + return "InvitedList"; + } + } + } + } + return "login_index"; + } + + /** + * 邀请好友分页AJAX + * @return + */ + public String InvitedListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = userService.getInvitedList(userId, pageNo, pageSize); + userList = (List) datePage.getList(); + for (User user : userList) { + user.setUserName(UserNameUtil.userName(user)); + } + Struts2Utils.renderJson(userList); + return null; + } + + /** + * 佣金明细 + * @return + */ + public String CommissionQuery(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = commissionqueryService.getCommissionQueryListByCount(userId, startDate, endDate); + return "CommissionQuery"; + } + } + } + } + return "login_index"; + } + + /** + * 佣金明细 AJAX + * @return + */ + public String CommissionQueryAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = commissionqueryService.getCommissionQueryList(userId, startDate, endDate, pageNo, pageSize); + List dateList = (List) datePage.getList(); + if(dateList.size()>0){ + commissionqueryJSONList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + commissionqueryJSON = new CommissionqueryJSON(); + user = (User) dateList.get(i)[0]; + commissionquery = (Commissionquery) dateList.get(i)[1]; + commissionqueryJSON.setBuyMoney(commissionquery.getBuyMoney()); + commissionqueryJSON.setCommission(commissionquery.getCommission()); + commissionqueryJSON.setDate(commissionquery.getDate()); + commissionqueryJSON.setDescription(commissionquery.getDescription()); + commissionqueryJSON.setUserId(String.valueOf(user.getUserId())); + commissionqueryJSON.setUserName(UserNameUtil.userName(user)); + commissionqueryJSONList.add(commissionqueryJSON); + } + } + Struts2Utils.renderJson(commissionqueryJSONList); + return null; + } + + /** + * 佣金明细 AJAX ByCount + */ + public void getCommissionQueryAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = commissionqueryService.getCommissionQueryListByCount(userId, startDate, endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 我的福分 + * @return + */ + public String MemberPoints(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = commissionpointsService.getCommissionPointsListByCount(userId, startDate, endDate); + return "CommissionPoints"; + } + } + } + } + return "login_index"; + } + + /** + * 福分明细 AJAX + * @return + */ + public String CommissionPointsAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = commissionpointsService.CommissionPoints(userId, startDate, endDate, pageNo, pageSize); + commissionpointsList = (List) datePage.getList(); + Struts2Utils.renderJson(commissionpointsList); + return null; + } + + /** + * 提现申请 + * @return + */ + public String ApplyMention(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "ApplyMention"; + } + } + } + } + return "login_index"; + } + + /** + * 提现申请 ADD + */ + public void ApplyMentionAdd(){ + try { + JSONObject object = JSONObject.fromObject(userJSON); + userId = object.getString("userId"); + user = userService.findById(userId); + double money = Double.parseDouble(object.getString("money")); + double commissionBalance = user.getCommissionBalance(); + double commissionMention = user.getCommissionMention(); + if(commissionBalance dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * 提现记录 AJAX ByCount + */ + public void getMentionListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = applymentionService.getApplymentionListByCount(userId, startDate, endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 网银充值 + * @return + */ + public String UserRecharge(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "UserRecharge"; + } + } + } + } + return "login_index"; + } + + /** + * 卡密充值 + * @return + */ + public String userCardRecharge(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "userCardRecharge"; + } + } + } + } + return "login_index"; + } + + public void doCardRecharge(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + try { + String randomNo = id.substring(0,32); + String cardPwd = id.substring(32,id.length()); + Cardpassword cardpassword = cardpasswordService.doCardRecharge(randomNo, cardPwd); + if(cardpassword!=null){ + Double temp = user.getBalance(); + cardpasswordService.deleteByID(cardpassword.getId()); + user.setBalance(temp+cardpassword.getMoney()); + userService.add(user); + Consumetable consumetable = new Consumetable(); + consumetable.setBuyCount(Integer.parseInt(new java.text.DecimalFormat("0").format(cardpassword.getMoney()))); + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + consumetable.setInterfaceType("卡密冲值"); + consumetable.setMoney(cardpassword.getMoney()); + consumetable.setOutTradeNo(""); + String s = UUID.randomUUID().toString().toUpperCase(); + s = s.substring(0,8)+s.substring(9,13)+s.substring(14,18)+s.substring(19,23)+s.substring(24); + consumetable.setTransactionId(s); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); + Struts2Utils.renderText("yes"); + }else{ + Struts2Utils.renderText("no"); + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("no"); + } + } + } + } + } + } + + /** + * 账户明细 + * @return + */ + public String UserBalance(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + return "UserBalance"; + } + } + } + } + return "login_index"; + } + + /** + * 消费记录 + * @return + */ + public String ConsumeList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = consumetableService.userByConsumetableByCount(userId,startDate,endDate); + return "ConsumeList"; + } + } + } + } + return "login_index"; + } + + /*** + * 消费记录分页 + * @return + */ + public String ConsumeListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = consumetableService.userByConsumetable(userId,startDate,endDate, pageNo, pageSize); + List dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * 选择日期查询得到消费记录resultCount 总数 + */ + public void ConsumeListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = consumetableService.userByConsumetableByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + + /** + * 充值记录 + * @return + */ + public String RechargeList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + return "RechargeList"; + } + } + } + } + return "login_index"; + } + + /*** + * 充值记录分页 + * @return + */ + public String ConsumeListByDeltaAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = consumetableService.userByConsumetableByDelta(userId,startDate,endDate, pageNo, pageSize); + List dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * 选择日期查询得到充值记录resultCount 总数 + */ + public void ConsumeListByDeltaAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 收货地址 + * @return + */ + public String Address(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "Address"; + } + } + } + } + return "login_index"; + } + + public void getAddressList(){ + userbyaddressList = userService.getUserbyaddress(userId); + Struts2Utils.renderJson(userbyaddressList); + } + + /** + * 添加新收新地址 + * @return + */ + public String addAddress(){ + try { + JSONObject object = JSONObject.fromObject(userJSON); + int userId = object.getInt("userId"); + userbyaddressList = userService.getUserbyaddress(userId+""); + if(userbyaddressList.size()<4){ + String province = object.getString("province"); + String city = object.getString("city"); + String district = object.getString("district"); + String address = object.getString("address"); + int zipCode = object.getInt("zipCode"); + String consignee = object.getString("consignee"); + String phone = object.getString("phone"); + userbyaddress = new Userbyaddress(); + userbyaddress.setAddress(address); + userbyaddress.setCity(city); + userbyaddress.setConsignee(consignee); + userbyaddress.setDistrict(district); + userbyaddress.setPhone(phone); + userbyaddress.setProvince(province); + userbyaddress.setStatus(1); + userbyaddress.setUserId(userId); + userbyaddress.setZipCode(zipCode); + userService.addAddress(userbyaddress); + if(userbyaddress.getId()!=null){ + userService.setDefaultAddress(String.valueOf(userId),userbyaddress.getId()); + } + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("sizeError"); + } + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + return null; + } + + /** + * 设置默认收货地址 + */ + public void setDefaultAddress(){ + try { + userService.defaultAddress(userId,Integer.parseInt(id)); + userService.setDefaultAddress(String.valueOf(userId),Integer.parseInt(id)); + Struts2Utils.renderText("success"); + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + } + + /** + * 删除收货地址 + */ + public void delAddress(){ + try { + userService.delAddress(Integer.parseInt(id)); + Struts2Utils.renderText("success"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + + } + + /** + * 省 + */ + public void getProvinceList(){ + sProvinceList = regionService.getProvinceList(); + Struts2Utils.renderJson(sProvinceList); + } + + /** + * 市 + */ + public void getCityList(){ + sCityList = regionService.getCityListByProvinceId(id); + Struts2Utils.renderJson(sCityList); + } + + /** + * 区 + */ + public void getDistrictList(){ + sDistrictList = regionService.getDistrictListByCityId(id); + Struts2Utils.renderJson(sDistrictList); + } + + + /** + * 编辑个人资料 + * @return + */ + public String MemberModify(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "MemberModify"; + } + } + } + } + return "login_index"; + } + + + /** + * 修改用户资料 + */ + public void updateUser(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + if(user!=null){ + try { + JSONObject object = JSONObject.fromObject(userJSON); + if(user.getUserName()==null){ + Integer m = user.getCommissionPoints(); + m += ApplicationListenerImpl.sysConfigureJson.getUserData(); + user.setCommissionPoints(m); + } + user.setUserName(object.getString("userName")); + String mobilePhone = object.getString("mobilePhone"); + if(!mobilePhone.equals("undefined") && !mobilePhone.equals("")){ + user.setMobilePhone(mobilePhone); + } + String phone = object.getString("phone"); + if(!phone.equals("undefined") && !phone.equals("")){ + user.setPhone(phone); + } + String mail = object.getString("mail"); + if(!mail.equals("undefined") && !mail.equals("")){ + user.setMail(mail); + } + String qq = object.getString("qq"); + if(!qq.equals("undefined") && !qq.equals("")){ + user.setQq(qq); + } + String userSign = object.getString("userSign"); + if(!userSign.equals("undefined") && !userSign.equals("")){ + user.setSignature(userSign); + } + userService.add(user); + Struts2Utils.renderJson(user); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + }else{ + Struts2Utils.renderText("false"); + } + } + } + } + } + } + + /** + * 用户昵称是否存在 + */ + public void isUserNameExists(){ + User user = userService.isUserName(id,userId); + if(user==null) + Struts2Utils.renderText("true"); + else + Struts2Utils.renderText("false"); + } + + /** + * 修改头像 + * @return + */ + public String UserPhoto(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "UserPhoto"; + } + } + } + } + return "login_index"; + } + + /** + * 上传图像文件,保存用户头像 + * @return + * @throws Exception + */ + public String updateFaceFile() throws Exception{ + try { + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + imageFileName = userId+"_" + new Date().getTime()+ myFileFileName; + String filePath = ServletActionContext.getServletContext().getRealPath(UploadImages)+ File.separator + imageFileName; + File imageFile = new File(filePath); + if(myFile!=null){ + copy(myFile, imageFile); +// CutImages.equimultipleConvert(300, 300, imageFile, imageFile); + CutImages.scale2(filePath, filePath, 300, 300, true); + Struts2Utils.renderText(UploadImages+ "/"+ imageFileName); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 上传图像 + * @throws IOException + */ + public void updateFace() throws IOException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + hidPicUrl = hidPicUrl.replace("/", "\\"); + hidPicUrl = hidPicUrl.substring(hidPicUrl.lastIndexOf("\\")+1, hidPicUrl.length()); + String fileName = ServletActionContext.getServletContext().getRealPath(UploadImages)+ File.separator + hidPicUrl; + String faceName = ServletActionContext.getServletContext().getRealPath(FaceImages)+ File.separator + hidPicUrl; + try { + CutImages cutImages = new CutImages(x1,y1,w,h,fileName,faceName); + cutImages.cut(); + //faceName = faceName.substring(faceName.lastIndexOf("ROOT")+4,faceName.length()).replace("\\", "/"); + faceName = FaceImages + "/" + hidPicUrl; + user = userService.findById(userId); + user.setFaceImg(faceName); + userService.add(user); + Cookie cookie3 = new Cookie("face",URLEncoder.encode(user.getFaceImg(), "UTF-8")); + cookie3.setMaxAge(-1); + cookie3.setPath("/"); + cookie3.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie3); + Struts2Utils.renderText("success"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + } + + /** + * 修改密码 + * @return + */ + public String UpdatePassWord(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "UpdatePassWord"; + } + } + } + } + return "login_index"; + } + + /** + * 修改密码 + */ + public void updatePwd(){ + if(StringUtil.isNotBlank(userId)){ + try { + user = userService.findById(userId); + if(user!=null){ + if(!user.getUserPwd().equals(id)){ + Struts2Utils.renderText("pwdError"); + }else{ + user.setUserPwd(userJSON); + userService.add(user); + Struts2Utils.renderText("success"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + //lwgoby add + //用户是否已关注,用于 bottom.js 中的 ajax调用 /user/hasCollectGoods.action + /** + * 用户未登录时,无法进行关注,右侧工具条关注提示为空,需要登录。 + * 用户未登录时,固定返回10,用于在 bottom.js 显示右侧关注工具条时是否提示用户登录用。 + * 用户登录后,固定返回0,用于提示已登录,用户一点关注某一商品,则会将相关数据存于 数据库中,用户下次登录还可以看到自己曾经关注过的商品 + */ + public String hasCollectGoods(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + if(user!=null){ + Struts2Utils.renderText("0"); //成功登录的用户暂且固定输出0; + return null; + } + } + } + } + } + Struts2Utils.renderText("10"); //未登录的用户固定输出10 供 bottom.js 中做比较 + return null; + } + + /** + * @Author lwgboy + * 检查用户名是否已经注册 + * @return + */ + public String isCheckName(){ + boolean isExist = false; + user = userService.userByName(userName); + if(user==null) + Struts2Utils.renderText("true"); + else + Struts2Utils.renderText("false"); + return null; + } + + /** + * 修改Email页面 + * @return + */ + public String EmailChecking(){ + user = getUserFromCookie(); + if(user!=null) + return "EmailChecking"; + else + return null; + } + + /** + * copy form RegisterAction.java 的 SendRegisterMail() + * @param mail 要重新发送验证邮件的目的邮箱地址 + */ + public void SendRegisterMail(String userId,String mail){ + //System.err.println("mail:"+mail); + //只采用日期部分生成加密串,便于memcache 无效时直接验证,但有安全隐患。 + //key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.DateToStr(new Date(),"yyyyMMdd"))+Base64.getEncode(mail); + key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.dateTimeToStr(new Date()))+Base64.getEncode(mail+"|"+userId+"|"+DateUtil.DateToStr(new Date(),"yyyyMMdd")); + + //将激活 key 存入数据库供后续的 emailok 验证 + //userService.updateKey(mail, key); //用后面发送邮件成功后的 user.setKey(key) 替代,因此注释掉。 + + String html = ""+ + ""+ + ""+ + ""+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    首页"+ + "我的"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"帮助
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    亲爱的 "+mail+"

    您好!感谢您注册"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"。

    请点击下面的按钮,完成邮箱验证。

    邮箱验证
    如果上面按钮不能点击或点击后没有反应,您还可以将以下链接复制到浏览器地址栏中访问完成验证。
    "+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/user/EmailReturnSuccess.html?key="+key+"
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    此邮件由系统自动发出,请勿回复!
    感谢您对"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")的支持,祝您好运!
    客服热线:"+ApplicationListenerImpl.sysConfigureJson.getServiceTel()+"
    "+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + "
    "+ApplicationListenerImpl.sysConfigureJson.getDomain()+" "+ApplicationListenerImpl.sysConfigureJson.getIcp()+"
    "; + if(MemCachedClientHelp.getIMemcachedCache().get(MD5Util.encode(mail+"|"+userId))==null){ + //user = userService.userByName(mail); + user = getUserFromCookie(); + if(user!=null){ + logger.info("SendRegisterMail("+mail+"): user.getMail()="+user.getMail()+",user.getMailCheck()="+user.getMailCheck()); + if(user.getMail()!=null&&user.getMail().equals(mail)&&user.getMailCheck()!=null&&user.getMailCheck().equals("0")){ //如果当前用户的邮箱地址等于提交过来邮件地址,并且邮箱验证已通过的话 + Struts2Utils.renderText("0"); + }else{ + try { + boolean flag = EmailUtil.sendEmail(ApplicationListenerImpl.sysConfigureJson.getMailName(), ApplicationListenerImpl.sysConfigureJson.getMailPwd(), mail, ApplicationListenerImpl.sysConfigureJson.getSiteName()+"验证注册邮箱", html); + if(flag){ + user.setMailCheck("1"); + user.setMailKey(key); //保存key 到数据库,便于memcache 没启动时也能完成验证 + userService.add(user); + if(MemCachedClientHelp.getIMemcachedCache()!=null) + try{ + MemCachedClientHelp.getIMemcachedCache().put(MD5Util.encode(mail+"|"+userId), mail+"|"+userId,new Date(10*60*1000)); + }catch (Exception e) { + e.printStackTrace(); + } + Struts2Utils.renderText("0"); + }else{ + Struts2Utils.renderText("false"); + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + } + } + }else{ + user = userService.userByName(mail); + if(user!=null){ + if(user.getMailCheck().equals("1")){ + Struts2Utils.renderText("3"); + }else if(user.getMailCheck().equals("0")){ + Struts2Utils.renderText("0"); + } + } + } + } + + /** + * 发送验证 Email 页面 ,供 /js/emailchecking.js 中 ajax调用 http://www.ipdz.me.com/user/EmailSending.html?userJSON=45201816@qq.com + * @return http://www.ipdz.me.com/user/EmailSendSuccess.html?userJSON=45201816@qq.com + */ + public void EmailSending(){ + if(StringUtils.isNoneEmpty(userJSON)){ + user = this.getUserFromCookie(); + if(user!=null) + SendRegisterMail(user.getUserId().toString(),userJSON); + } + } + + /** + * 发送验证 Email 成功后的页面,供 /js/emailchecking.js 中 ajax + * @return + */ + public String EmailSendSuccess(){ + user = this.getUserFromCookie(); + return "EmailSendSuccess"; + } + + /** + * 重新发送验证邮箱后,再次进行邮箱验证 + * @return + */ + public String EmailReturnSuccess() throws UnsupportedEncodingException { + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + String mail=""; + String isVerify=""; + if(StringUtil.isNotBlank(key)){ + String key_mail_date_str = key.substring(64,key.length()); + String [] keyStr = Base64.getDecode(key_mail_date_str).split("\\|"); + if(keyStr.length==3) + { + mail = keyStr[0]; + userId = keyStr[1]; + Date date = DateUtil.StrToDate(keyStr[2], "yyyyMMdd"); + if(DateUtil.addDate(new Date(), -1).before(date)&& StringUtil.isNotBlank(mail)&&StringUtil.isNotBlank(userId)) + { + user = userService.findById(userId); + if(MemCachedClientHelp.getIMemcachedCache().get(MD5Util.encode(mail+"|"+userId))!=null || (user!=null&&user.getMailKey().equals(key))) + { + if(user.getMailCheck()==null||(!user.getMailCheck().equals("0"))){ + user.setMail(mail); + user.setMailCheck("0"); + user.setMailKey("") ; //清空保存的用于激活的key + userService.add(user); + isVerify = "0"; + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("mail",user.getMail()); + cookie.setMaxAge(-1); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + Cookie cookie2 = new Cookie("userId",String.valueOf(user.getUserId())); + cookie2.setMaxAge(-1); + cookie2.setPath("/"); + cookie2.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie2); + Cookie cookie3 = new Cookie("face",URLEncoder.encode(user.getFaceImg(), "UTF-8")); + cookie3.setMaxAge(-1); + cookie3.setPath("/"); + cookie3.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie3); + } + }else{ + //说明已验证过没必要再次验证,置为验证码已失效状态 + isVerify = "1"; + } + }else{ + isVerify = "1"; + } + }else{ + isVerify = "1"; + } + }else{ + isVerify="1"; + } + } + else + isVerify="1"; + + if(isVerify.equals("0")) + return "EmailReturnSuccess"; + else + return null; + } + + /** + * 修改手机号页面 + * @return + */ + public String MobileChecking(){ + user = getUserFromCookie(); + if(user!=null) + return "MobileChecking"; + else + return null; + } + + /** + * 验证手机号后返回,用于 mobilechecking.js 的 e() 调用ajax 时使用 + * @author lwgboy + * @return + */ + public String MobileReturn(){ + String userJSON=Struts2Utils.getParameter("userJSON"); + String id=Struts2Utils.getParameter("id"); + if(userJSON.matches("^1[0-9]{10}$")) + { + if(user==null) + user = getUserFromCookie(); + if(user!=null){ + user.setPhone(userJSON); + user.setMobileCheck("0"); //设定手机为已验证状态; + userService.add(user); //更新用户的手机号 + } + Struts2Utils.renderText("0"); + }else + Struts2Utils.renderText("-1"); + return null; + } + + /** + * 更改手机号成功后返回页面 + * @author lwgboy + * @return + */ + public String MobileReturnSuccess(){ + return "MobileReturnSuccess"; + } + + public User getUserFromCookie(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + } + break; + } + } + } + return user; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getForward() { + return forward; + } + + public void setForward(String forward) { + this.forward = forward; + } + + public List getProductList() { + return productList; + } + + public void setProductList(List productList) { + this.productList = productList; + } + + public List getNewDateList() { + return newDateList; + } + + public void setNewDateList(List newDateList) { + this.newDateList = newDateList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public BuyHistoryJSON getBuyHistoryJSON() { + return buyHistoryJSON; + } + + public void setBuyHistoryJSON(BuyHistoryJSON buyHistoryJSON) { + this.buyHistoryJSON = buyHistoryJSON; + } + + public List getBuyHistoryJSONList() { + return buyHistoryJSONList; + } + + public void setBuyHistoryJSONList(List buyHistoryJSONList) { + this.buyHistoryJSONList = buyHistoryJSONList; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public String getSelectTime() { + return selectTime; + } + + public void setSelectTime(String selectTime) { + this.selectTime = selectTime; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public Shareinfo getShareinfo() { + return shareinfo; + } + + public void setShareinfo(Shareinfo shareinfo) { + this.shareinfo = shareinfo; + } + + public ShareJSON getShareJSON() { + return shareJSON; + } + + public void setShareJSON(ShareJSON shareJSON) { + this.shareJSON = shareJSON; + } + + public List getShareJSONList() { + return shareJSONList; + } + + public void setShareJSONList(List shareJSONList) { + this.shareJSONList = shareJSONList; + } + + public List getUserbyaddressList() { + return userbyaddressList; + } + + public void setUserbyaddressList(List userbyaddressList) { + this.userbyaddressList = userbyaddressList; + } + + public Userbyaddress getUserbyaddress() { + return userbyaddress; + } + + public void setUserbyaddress(Userbyaddress userbyaddress) { + this.userbyaddress = userbyaddress; + } + + public String getUserJSON() { + return userJSON; + } + + public List getRandomNumberJSONList() { + return randomNumberJSONList; + } + + public void setRandomNumberJSONList(List randomNumberJSONList) { + this.randomNumberJSONList = randomNumberJSONList; + } + + public RandomNumberJSON getRandomNumberJSON() { + return randomNumberJSON; + } + + public void setRandomNumberJSON(RandomNumberJSON randomNumberJSON) { + this.randomNumberJSON = randomNumberJSON; + } + + public void setUserJSON(String userJSON) { + this.userJSON = userJSON; + } + + public File getMyFile() { + return myFile; + } + + public void setMyFile(File myFile) { + this.myFile = myFile; + } + + public String getMyFileFileName() { + return myFileFileName; + } + + public void setMyFileFileName(String myFileFileName) { + this.myFileFileName = myFileFileName; + } + + public String getMyFileContentType() { + return myFileContentType; + } + + public void setMyFileContentType(String myFileContentType) { + this.myFileContentType = myFileContentType; + } + + public String getImageFileName() { + return imageFileName; + } + + public void setImageFileName(String imageFileName) { + this.imageFileName = imageFileName; + } + + public int getX1() { + return x1; + } + + public void setX1(int x1) { + this.x1 = x1; + } + + public int getY1() { + return y1; + } + + public void setY1(int y1) { + this.y1 = y1; + } + + public String getHidPicUrl() { + return hidPicUrl; + } + + public void setHidPicUrl(String hidPicUrl) { + this.hidPicUrl = hidPicUrl; + } + + public int getW() { + return w; + } + + public void setW(int w) { + this.w = w; + } + + public int getH() { + return h; + } + + public void setH(int h) { + this.h = h; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public List getNewsList() { + return newsList; + } + + public void setNewsList(List newsList) { + this.newsList = newsList; + } + + public List getSProvinceList() { + return sProvinceList; + } + + public void setSProvinceList(List provinceList) { + sProvinceList = provinceList; + } + + public List getSCityList() { + return sCityList; + } + + public void setSCityList(List cityList) { + sCityList = cityList; + } + + public List getSDistrictList() { + return sDistrictList; + } + + public void setSDistrictList(List districtList) { + sDistrictList = districtList; + } + + public List getUserList() { + return userList; + } + + public void setUserList(List userList) { + this.userList = userList; + } + + public List getCommissionqueryList() { + return commissionqueryList; + } + + public void setCommissionqueryList(List commissionqueryList) { + this.commissionqueryList = commissionqueryList; + } + + public List getApplymentionList() { + return applymentionList; + } + + public void setApplymentionList(List applymentionList) { + this.applymentionList = applymentionList; + } + + public Applymention getApplymention() { + return applymention; + } + + public void setApplymention(Applymention applymention) { + this.applymention = applymention; + } + + public Commissionquery getCommissionquery() { + return commissionquery; + } + + public void setCommissionquery(Commissionquery commissionquery) { + this.commissionquery = commissionquery; + } + + public List getCommissionqueryJSONList() { + return commissionqueryJSONList; + } + + public void setCommissionqueryJSONList( + List commissionqueryJSONList) { + this.commissionqueryJSONList = commissionqueryJSONList; + } + + public CommissionqueryJSON getCommissionqueryJSON() { + return commissionqueryJSON; + } + + public void setCommissionqueryJSON(CommissionqueryJSON commissionqueryJSON) { + this.commissionqueryJSON = commissionqueryJSON; + } + + public List getCommissionpointsList() { + return commissionpointsList; + } + + public void setCommissionpointsList(List commissionpointsList) { + this.commissionpointsList = commissionpointsList; + } + + public Commissionpoints getCommissionpoints() { + return commissionpoints; + } + + public void setCommissionpoints(Commissionpoints commissionpoints) { + this.commissionpoints = commissionpoints; + } + + public List getOrderdetailList() { + return orderdetailList; + } + + public void setOrderdetailList(List orderdetailList) { + this.orderdetailList = orderdetailList; + } + + public OrderDetailAddress getorderDetailAddress() { + return orderDetailAddress; + } + + public void setorderDetailAddress(OrderDetailAddress orderDetailAddress) { + this.orderDetailAddress = orderDetailAddress; + } + + public Orderdetail getOrderdetail() { + return orderdetail; + } + + public void setOrderdetail(Orderdetail orderdetail) { + this.orderdetail = orderdetail; + } + +} diff --git a/src/main/java/me/mofun/action/UserInfoAction.java b/src/main/java/me/mofun/action/UserInfoAction.java new file mode 100644 index 0000000..ee934cb --- /dev/null +++ b/src/main/java/me/mofun/action/UserInfoAction.java @@ -0,0 +1,632 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.DateUtil; +import me.mofun.util.Struts2Utils; +import me.mofun.util.UserNameUtil; +import org.apache.commons.lang3.time.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class UserInfoAction extends ActionSupport { + + private static final long serialVersionUID = 8426857698329495895L; + + @Autowired + private UserService userService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ShareService shareService; + @Autowired + private FriendsService friendsService; + @Autowired + private VisitorsService visitorsService; + + private User user; + private String id; + private String userId; + private int pageNo; + private int pageSize = 12; + private int pageCount; + private int resultCount; + private String userName; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private BuyHistoryJSON buyHistoryJSON; + private Latestlottery latestlottery; + private List buyHistoryJSONList; + private List ShareJSONList; + private ShareJSON shareJSON; + private Shareinfo shareinfo; + private Shareimage shareimage; + private List userList; + private Friends friends; + private Visitors visitors; + + HttpServletRequest request = null; + + public String index(){ + + request = Struts2Utils.getRequest(); + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + + user = userService.findById(id); + + userName = UserNameUtil.userName(user); + + Pagination datePage = spellbuyrecordService.buyHistoryByUser(id,null,null, pageNo, 6); + List dataList = (List) datePage.getList(); + if(dataList !=null && dataList.size()>0){ + buyHistoryJSONList = new ArrayList(); + for (int j = 0; j < dataList.size(); j++) { + try { + buyHistoryJSON = dataList.get(j); + if(buyHistoryJSON.getBuyStatus()==1){ + List list = latestlotteryService.getBuyHistoryByDetail(buyHistoryJSON.getProductId()); + if(list!=null && list.size()>0){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(buyHistoryJSON.getProductId()).get(0); + } + if(latestlottery!=null){ + buyHistoryJSON.setBuyTime(DateUtil.getTime(DateUtil.SDateTimeToDate(latestlottery.getAnnouncedTime()))); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUserId(latestlottery.getUserId()); + buyHistoryJSON.setWinUser(userer); + } + }else{ + String userName = UserNameUtil.userName(user); + String timeStr = DateUtil.getTime(DateUtil.SDateTimeToDate(buyHistoryJSON.getBuyTime())); + buyHistoryJSON.setBuyTime(timeStr); + buyHistoryJSON.setWinUser(userName); + } + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + + /** + * 访客 + */ + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + visitors = visitorsService.findVisitorsByUserIdAndVisitorsId(id, userId); + if(visitors!=null){ + List visitorsList = visitorsService.findVisitors(id, userId, DateUtil.DateTimeToStr(DateUtils.addHours(new Date(), -1)),DateUtil.DateTimeToStr(new Date())); + if(visitorsList.size()<0){ +// String ip = Struts2Utils.getRequest().getRemoteAddr(); + String ip = Struts2Utils.getRequest().getHeader("X-Real-IP"); + if(ip==null){ + ip ="127.0.0.1"; + } + String ipLocation = RegisterAction.seeker.getAddress(ip); + visitors.setAddress(ipLocation); + visitors.setDate(DateUtil.DateTimeToStr(new Date())); + visitors.setUid(Integer.parseInt(id)); + visitors.setVisitorsId(Integer.parseInt(userId)); + visitorsService.add(visitors); + } + }else{ +// String ip = Struts2Utils.getRequest().getRemoteAddr(); + String ip = Struts2Utils.getRequest().getHeader("X-Real-IP"); + if(ip==null){ + ip ="127.0.0.1"; + } + String ipLocation = RegisterAction.seeker.getAddress(ip); + visitors = new Visitors(); + visitors.setAddress(ipLocation); + visitors.setDate(DateUtil.DateTimeToStr(new Date())); + visitors.setUid(Integer.parseInt(id)); + visitors.setVisitorsId(Integer.parseInt(userId)); + visitorsService.add(visitors); + } + } + } + } + } + + return "index"; + } + + public static void main(String[] args) { + System.err.println(DateUtil.DateTimeToStr(DateUtils.addHours(new Date(), -1))); + } + + /** + * 拍购记录 + * @return + */ + public String userBuy(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + + user = userService.findById(id); + + userName = UserNameUtil.userName(user); + + resultCount = spellbuyrecordService.buyHistoryByUserByCount(id,null,null); + return "UserBuy"; + } + + /** + * 拍购记录AJAX分页 + * @return + */ + public String userBuyAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + user = userService.findById(id); + Pagination datePage = spellbuyrecordService.buyHistoryByUser(id,null,null, pageNo, pageSize); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + if(dataList !=null && dataList.size()>0){ + for (int j = 0; j < dataList.size(); j++) { + buyHistoryJSON = dataList.get(j); + if(buyHistoryJSON.getBuyStatus()==1){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(buyHistoryJSON.getProductId()).get(0); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUser(userer); + buyHistoryJSON.setWinUserId(latestlottery.getUserId()); + }else{ + String userName = UserNameUtil.userName(user); + buyHistoryJSON.setWinUser(userName); + } + buyHistoryJSONList.add(buyHistoryJSON); + } + } + + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 获得的商品 + * @return + */ + public String userRaffle(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + + user = userService.findById(id); + + userName = UserNameUtil.userName(user); + resultCount = latestlotteryService.getProductByUserByCount(id,null,null); + return "UserRaffle"; + } + + /** + * 获得的商AJAX品分页 + * @return + */ + public String userRaffleAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = latestlotteryService.getProductByUser(id,null,null, pageNo, pageSize); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + if(dataList != null && dataList.size()>0){ + for (int j = 0; j < dataList.size(); j++) { + buyHistoryJSON = new BuyHistoryJSON(); + latestlottery = dataList.get(j); + buyHistoryJSON.setProductId(latestlottery.getSpellbuyProductId()); + buyHistoryJSON.setProductImg(latestlottery.getProductImg()); + buyHistoryJSON.setProductName(latestlottery.getProductName()); + buyHistoryJSON.setProductPeriod(latestlottery.getProductPeriod()); + buyHistoryJSON.setProductPrice(latestlottery.getProductPrice()); + buyHistoryJSON.setProductTitle(latestlottery.getProductTitle()); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setBuyTime(latestlottery.getBuyTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + buyHistoryJSONList.add(buyHistoryJSON); + } + } + + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 晒单 + * @return + */ + public String userPost(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + + user = userService.findById(id); + + userName = UserNameUtil.userName(user); + Pagination datePage = shareService.shareByUser(id,null,null, pageNo, pageSize); + resultCount = datePage.getResultCount(); + return "UserPost"; + } + + /** + * 晒单AJAX分页 + * @return + */ + public String userPostAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination page = shareService.shareByUser(id,null,null, pageNo, pageSize); + List pageList = (List) page.getList(); + ShareJSONList = new ArrayList(); + if(pageList !=null && pageList.size()>0){ + for (int i = 0; i < pageList.size(); i++) { + shareJSON = new ShareJSON(); + shareinfo = (Shareinfo) pageList.get(i)[0]; + shareimage = (Shareimage) pageList.get(i)[1]; + latestlottery = (Latestlottery) pageList.get(i)[2]; + String userName = ""; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userName = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userName = latestlottery.getBuyUser(); + if(userName.indexOf("@")!=-1){ + String[] u = userName.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userName = u1+"@"+u[1]; + }else{ + userName = userName.substring(0,4)+ "*** "+userName.substring(7); + } + } + shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); + shareJSON.setReplyCount(shareinfo.getReplyCount()); + shareJSON.setReward(shareinfo.getReward()); + shareJSON.setShareContent(shareinfo.getShareContent()); + shareJSON.setShareDate(shareinfo.getShareDate()); + shareJSON.setShareImages(shareimage.getImages()); + shareJSON.setShareTitle(shareinfo.getShareTitle()); + shareJSON.setUid(shareinfo.getUid()); + shareJSON.setUpCount(shareinfo.getUpCount()); + shareJSON.setUserName(userName); + shareJSON.setUserFace(latestlottery.getUserFace()); + shareJSON.setUserId(latestlottery.getUserId()+""); + ShareJSONList.add(shareJSON); + } + } + + Struts2Utils.renderJson(ShareJSONList); + return null; + } + + /** + * 好友 + * @return + */ + public String userFriends(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + + user = userService.findById(id); + + userName = UserNameUtil.userName(user); + Pagination datePage = friendsService.getFriends(id, pageNo, pageSize); + resultCount = datePage.getResultCount(); + return "UserFriends"; + } + + /** + * 好友AJAX分页 + * @return + */ + public String userFriendsAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination page = friendsService.getFriends(id, pageNo, pageSize); + List pageList = (List) page.getList(); + userList = new ArrayList(); + if(pageList !=null && pageList.size()>0){ + for (int i = 0; i < pageList.size(); i++) { + friends = (Friends) pageList.get(i)[0]; + user = (User) pageList.get(i)[1]; + userName = UserNameUtil.userName(user); + user.setUserId(friends.getFriendsId()); + user.setUserName(userName); + userList.add(user); + } + } + Struts2Utils.renderJson(userList); + return null; + } + + /** + * 最近访客(访问) + * @return + */ + public String visitors(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + visitors = new Visitors(); + visitors.setAddress(user.getIpLocation()); + visitors.setDate(DateUtil.DateTimeToStr(new Date())); + visitors.setUid(Integer.parseInt(id)); + visitors.setVisitorsId(Integer.parseInt(userId)); + visitorsService.add(visitors); + } + } + } + } + return null; + } + + /** + * 访问列表 + * @return + */ + public String visitorsList(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination page = visitorsService.getVisitors(userId, pageNo, 9); + List pageList = (List) page.getList(); + userList = new ArrayList(); + if(pageList !=null && pageList.size()>0){ + for (int i = 0; i < pageList.size(); i++) { + user = (User) pageList.get(i)[0]; + visitors = (Visitors) pageList.get(i)[1]; + userName = UserNameUtil.userName(user); + user.setNewDate(DateUtil.getTime(DateUtil.SDateTimeToDate(visitors.getDate()))); + user.setUserId(visitors.getVisitorsId()); + user.setUserName(userName); + user.setIpLocation(visitors.getAddress()); + userList.add(user); + } + } + Struts2Utils.renderJson(userList); + return null; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public BuyHistoryJSON getBuyHistoryJSON() { + return buyHistoryJSON; + } + + public void setBuyHistoryJSON(BuyHistoryJSON buyHistoryJSON) { + this.buyHistoryJSON = buyHistoryJSON; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getBuyHistoryJSONList() { + return buyHistoryJSONList; + } + + public void setBuyHistoryJSONList(List buyHistoryJSONList) { + this.buyHistoryJSONList = buyHistoryJSONList; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public List getShareJSONList() { + return ShareJSONList; + } + + public void setShareJSONList(List shareJSONList) { + ShareJSONList = shareJSONList; + } + + public ShareJSON getShareJSON() { + return shareJSON; + } + + public void setShareJSON(ShareJSON shareJSON) { + this.shareJSON = shareJSON; + } + + public Shareinfo getShareinfo() { + return shareinfo; + } + + public void setShareinfo(Shareinfo shareinfo) { + this.shareinfo = shareinfo; + } + + public Shareimage getShareimage() { + return shareimage; + } + + public void setShareimage(Shareimage shareimage) { + this.shareimage = shareimage; + } + public List getUserList() { + return userList; + } + + public void setUserList(List userList) { + this.userList = userList; + } + public Friends getFriends() { + return friends; + } + + public void setFriends(Friends friends) { + this.friends = friends; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Visitors getVisitors() { + return visitors; + } + + public void setVisitors(Visitors visitors) { + this.visitors = visitors; + } +} diff --git a/src/main/java/me/mofun/action/YeepayAction.java b/src/main/java/me/mofun/action/YeepayAction.java new file mode 100644 index 0000000..4c7db00 --- /dev/null +++ b/src/main/java/me/mofun/action/YeepayAction.java @@ -0,0 +1,828 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.tenpay.util.TenpayUtil; +import me.mofun.util.*; +import me.mofun.yeepay.config.PaymentForOnlineService; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.util.*; + +public class YeepayAction extends ActionSupport { + + private static final long serialVersionUID = -4161171772234804569L; + + RandomUtil randomUtil = new RandomUtil(); + @Autowired + ConsumetableService consumetableService; + @Autowired + ConsumerdetailService consumerdetailService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private RandomnumberService randomnumberService; + @Autowired + private UserService userService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ProductService productService; + @Autowired + private NewLotteryUtil newLotteryUtil; + @Autowired + CommissionqueryService commissionqueryService; + @Autowired + CommissionpointsService commissionpointsService; + + private User user; + private String userId; + private Consumetable consumetable; + private ProductCart productCart; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private Randomnumber randomnumber; + private Latestlottery latestlottery; + private Consumerdetail consumerdetail; + private List productCartList; + private List successCartList; + private ProductJSON productJSON; + private String paymentStatus; + private Commissionquery commissionquery; + private Commissionpoints commissionpoints; + + private Integer moneyCount; + private String integral; + //当前时间 yyyyMMddHHmmss + private String currTime = TenpayUtil.getCurrTime(); + //8位日期 + private String strTime = currTime.substring(8, currTime.length()); + //四位随机数 + private String strRandom = TenpayUtil.buildRandom(4) + ""; + //10位序列号,可以自行调整。 + private String strReq = strTime + strRandom; + private static String nodeAuthorizationURL = "https://www.yeepay.com/app-merchant-proxy/node"; + Random random = new Random(); + HttpServletRequest request = null; + HttpServletResponse response = null; + + String formatString(String text){ + if(text == null) { + return ""; + } + return text; + } + + public String goPay() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String keyValue = ApplicationListenerImpl.sysConfigureJson.getYeepayKey(); // 商家密钥 + // 商家设置用户购买商品的支付信息 + String p0_Cmd = formatString("Buy"); // 在线支付请求,固定值 ”Buy” + String p1_MerId = ApplicationListenerImpl.sysConfigureJson.getYeepayPartner(); // 商户编号 + String p2_Order = strReq; // 商户订单号 + String p3_Amt = moneyCount.toString(); // 支付金额 + String p4_Cur = formatString("CNY"); // 交易币种 + String p5_Pid = ApplicationListenerImpl.sysConfigureJson.getWwwUrl(); // 商品名称 + String p6_Pcat = ApplicationListenerImpl.sysConfigureJson.getWwwUrl(); // 商品种类 + String p7_Pdesc = ApplicationListenerImpl.sysConfigureJson.getWwwUrl(); // 商品描述 + String p8_Url = ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/yeepay/notifyUrl.action"; // 商户接收支付成功数据的地址 + String p9_SAF = "0"; // 需要填写送货信息 0:不需要 1:需要 + String pa_MP = integral; // 商户扩展信息 + String pd_FrpId = ""; // 支付通道编码 + // 银行编号必须大写 + pd_FrpId = pd_FrpId.toUpperCase(); + String pr_NeedResponse = formatString("1"); // 默认为"1",需要应答机制 + String hmac = formatString(""); // 交易签名串 + + // 获得MD5-HMAC签名 + hmac = PaymentForOnlineService.getReqMd5HmacForOnlinePayment(p0_Cmd, + p1_MerId,p2_Order,p3_Amt,p4_Cur,p5_Pid,p6_Pcat,p7_Pdesc, + p8_Url,p9_SAF,pa_MP,pd_FrpId,pr_NeedResponse,keyValue); + + //把请求参数打包成数组 + Map sParaTemp = new HashMap(); + sParaTemp.put("p0_Cmd", p0_Cmd); + sParaTemp.put("p1_MerId", p1_MerId); + sParaTemp.put("p2_Order", p2_Order); + sParaTemp.put("p3_Amt", p3_Amt); + sParaTemp.put("p4_Cur", p4_Cur); + sParaTemp.put("p5_Pid", p5_Pid); + sParaTemp.put("p6_Pcat", p6_Pcat); + sParaTemp.put("p7_Pdesc", p7_Pdesc); + sParaTemp.put("p8_Url", p8_Url); + sParaTemp.put("p9_SAF", p9_SAF); + sParaTemp.put("pa_MP", pa_MP); + sParaTemp.put("pd_FrpId", pd_FrpId); + sParaTemp.put("pr_NeedResponse", pr_NeedResponse); + sParaTemp.put("hmac", hmac); + + /** + * 业务开始 + */ + productCartList = new ArrayList(); + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); +// if(userId!=null && !userId.equals("")){ +// user = userService.findById(userId); +// } + } + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + if(StringUtil.isNotBlank(userId)){ + Integer buyConut = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + buyConut += count; + productCount ++; + productCart.setCount(count); + productCart.setHeadImage(product.getHeadImage()); +// productCart.setMoneyCount(buyConut); + productCart.setProductCount(productCount); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + productCartList.add(productCart); + flag = true; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } +// moneyCount 财付通充值的钱 600 +// buyConut 要花的钱 7 +// hidUseBalance 余额的钱 1 buyConut=moneyCount+hidUseBalance + if(flag){ + try { + consumetable = new Consumetable(); + double money = Double.parseDouble(String.valueOf(moneyCount)); + consumetable.setBuyCount(buyConut); //要花的钱 7 + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + consumetable.setInterfaceType("yeePay"); + consumetable.setMoney(money); //财付通充值的钱 6 + consumetable.setOutTradeNo(p2_Order); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); + } catch (Exception e) { + e.printStackTrace(); + flag = false; + } + }else{ + flag = false; + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + + //建立请求 + String sHtmlText = buildRequest(sParaTemp,nodeAuthorizationURL,"POST","确认"); + System.out.println(sHtmlText); + if(flag){ + Struts2Utils.render("text/html", sHtmlText,"encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + + return null; + } + + public String returnUrl() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + String keyValue = ApplicationListenerImpl.sysConfigureJson.getYeepayKey(); // 商家密钥 + String r0_Cmd = formatString(request.getParameter("r0_Cmd")); // 业务类型 + String p1_MerId = ApplicationListenerImpl.sysConfigureJson.getYeepayPartner(); // 商户编号 + String r1_Code = formatString(request.getParameter("r1_Code"));// 支付结果 + String r2_TrxId = formatString(request.getParameter("r2_TrxId"));// 易宝支付交易流水号 + String r3_Amt = formatString(request.getParameter("r3_Amt"));// 支付金额 + String r4_Cur = formatString(request.getParameter("r4_Cur"));// 交易币种 + String r5_Pid = new String(formatString(request.getParameter("r5_Pid")).getBytes("iso-8859-1"),"gbk");// 商品名称 + String r6_Order = formatString(request.getParameter("r6_Order"));// 商户订单号 + String r7_Uid = formatString(request.getParameter("r7_Uid"));// 易宝支付会员ID + String integral = new String(formatString(request.getParameter("integral")).getBytes("iso-8859-1"),"gbk");// 商户扩展信息 + String r9_BType = formatString(request.getParameter("r9_BType"));// 交易结果返回类型 + String hmac = formatString(request.getParameter("hmac"));// 签名数据 + + boolean flag = false; + String buyproduct ="";// 已经被买完的商品 + + boolean isOK = false; + // 校验返回数据包 + isOK = PaymentForOnlineService.verifyCallback(hmac,p1_MerId,r0_Cmd,r1_Code, + r2_TrxId,r3_Amt,r4_Cur,r5_Pid,r6_Order,r7_Uid,integral,r9_BType,keyValue); + if(isOK) { + //在接收到支付结果通知后,判断是否进行过业务逻辑处理,不要重复进行业务逻辑处理 + if(r1_Code.equals("1")) { + // 产品通用接口支付成功返回-浏览器重定向 + if(r9_BType.equals("1")) { + System.out.println("callback方式:产品通用接口支付成功返回-浏览器重定向"); + // 产品通用接口支付成功返回-服务器点对点通讯 + } else if(r9_BType.equals("2")) { + // 如果在发起交易请求时 设置使用应答机制时,必须应答以"success"开头的字符串,大小写不敏感 + System.out.println("SUCCESS"); + // 产品通用接口支付成功返回-电话支付返回 + } + // 下面页面输出是测试时观察结果使用 + System.out.println("
    交易成功!
    商家订单号:" + r6_Order + "
    支付金额:" + r3_Amt + "
    易宝支付交易流水号:" + r2_TrxId); + //即时到账处理业务开始 + //------------------------------ + try { + String key = MD5Util.encode(r2_TrxId); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + MemCachedClientHelp.getIMemcachedCache().put(key, "y",new Date(12*60*60*1000)); + productCartList = new ArrayList(); + successCartList = new ArrayList(); + try { + consumetable = consumetableService.findByOutTradeNo(r6_Order);//找到订单 + double money = Double.parseDouble(String.valueOf(r3_Amt));//充值的钱 + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId().equals(r2_TrxId)){ + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + } + if(cookie.getName().equals("products")){ + String product = new StringUtil().getUTF8URLDecoder(cookie.getValue()); + if(product!=null && !product.equals("")){ + array = JSONArray.fromObject(product); + } + } + } + } + + //总购买钱数 + Integer moneyCount = 0; + Integer productCount = 0; + if(array!=null && !array.toString().equals("[{}]")){ + for(int i=0;i proList = spellbuyproductService.findByProductId(Integer.parseInt(obj.getString("pId"))); + List proList = spellbuyproductService.findByFKProductId(Integer.parseInt(obj.getString("pId"))); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + if(spellbuyproduct.getSpStatus()==0){ + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+obj.getInt("num")) > spellbuyproduct.getSpellbuyPrice()){ + count = spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = obj.getInt("num"); + } + moneyCount += count; + productCount ++; + productCart.setCount(count); + productCart.setHeadImage(product.getHeadImage()); + productCart.setMoneyCount(moneyCount); + productCart.setProductCount(productCount); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + productCartList.add(productCart); + flag = true; + }else{ + buyproduct += "您购买的商品中 " + product.getProductName() + " 已经满员.
    "; +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// flag = false; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + if(StringUtil.isNotBlank(userId)){ + user = userService.findById(userId); + } + + if(flag){ + for (final ProductCart productCart : productCartList) { + try { + spellbuyproduct = spellbuyproductService.findById(productCart.getProductId().toString()); + //真正要购买的数量 + Integer count = 0; + //当前拍购人数 + Integer CurrentPrice = spellbuyproduct.getSpellbuyCount(); + if((spellbuyproduct.getSpellbuyCount()+productCart.getCount()) > productCart.getProductPrice()){ + count = productCart.getProductPrice()-spellbuyproduct.getSpellbuyCount(); + }else{ + count = productCart.getCount(); + } + + if(count>0){ + if(StringUtil.isNotBlank(integral) && !integral.equals("0")){ + if(user.getBalance()>=(count-(Integer.parseInt(integral)/100))){ + Double temp = user.getBalance() - (count-(Integer.parseInt(integral)/100)); + user.setBalance(temp); +// userService.add(user); + + consumerdetail = new Consumerdetail(); + consumerdetail.setBuyCount(count); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setConsumetableId(r6_Order); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + consumerdetail.setProductTitle(productCart.getProductTitle()); + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + commissionquery = new Commissionquery(); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + }else{ + if(user.getBalance()>=count){ + Double temp = user.getBalance() - count; + user.setBalance(temp); + //userService.add(user); + consumerdetail = new Consumerdetail(); + consumerdetail.setBuyCount(count); + consumerdetail.setBuyMoney(Double.parseDouble(String.valueOf(count))); + consumerdetail.setConsumetableId(r6_Order); + consumerdetail.setSpellBuyProductId(productCart.getProductId()); + consumerdetail.setProductName(productCart.getProductName()); + consumerdetail.setProductPeriod(productCart.getProductPeriod()); + consumerdetail.setProductTitle(productCart.getProductTitle()); + consumerdetailService.add(consumerdetail); + + if(user.getInvite()!=null){ + User userCommission = userService.findById(String.valueOf(user.getInvite())); + double tempCommissionCount = userCommission.getCommissionCount(); + double commissionBalance = user.getCommissionBalance(); + userCommission.setCommissionCount(tempCommissionCount+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userCommission.setCommissionBalance(commissionBalance+=(Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + userService.add(userCommission); + commissionquery = new Commissionquery(); + commissionquery.setBuyMoney(Double.parseDouble(String.valueOf(count))); + commissionquery.setCommission((Double.parseDouble(String.valueOf(count))*ApplicationListenerImpl.sysConfigureJson.getCommission())); + commissionquery.setDate(DateUtil.DateTimeToStr(new Date())); + commissionquery.setDescription(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+productCart.getProductId()+")获得佣金"); + commissionquery.setInvitedId(user.getInvite()); + commissionquery.setToUserId(user.getUserId()); + commissionqueryService.add(commissionquery); + } + } else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + + spellbuyproduct.setSpellbuyCount(spellbuyproduct.getSpellbuyCount()+count); + if(spellbuyproduct.getSpellbuyCount()>=productCart.getProductPrice()){ + spellbuyproduct.setSpellbuyCount(productCart.getProductPrice()); + //开奖状态 + spellbuyproduct.setSpStatus(2); + spellbuyproduct.setSpellbuyEndDate(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + } + spellbuyproductService.add(spellbuyproduct); + + spellbuyrecord = new Spellbuyrecord(); + spellbuyrecord.setFkSpellbuyProductId(spellbuyproduct.getSpellbuyProductId()); + spellbuyrecord.setBuyer(user.getUserId()); + spellbuyrecord.setBuyPrice(count); + spellbuyrecord.setBuyDate(DateUtil.DateTimeToStrBySSS(new Date())); + spellbuyrecord.setSpWinningStatus("0"); + spellbuyrecord.setBuyStatus("0"); + spellbuyrecord.setSpRandomNo(""); + spellbuyrecordService.add(spellbuyrecord); + randomnumber = new Randomnumber(); + randomnumber.setProductId(productCart.getProductId()); + + List RandomnumberList = randomnumberService.query(" from Randomnumber where productId='"+ spellbuyproduct.getSpellbuyProductId() + +"'"); + List oldRandomList = new ArrayList(); + for (Randomnumber randomnumber : RandomnumberList) { + if(randomnumber.getRandomNumber().contains(",")){ + String[] rs = randomnumber.getRandomNumber().split(","); + for (String string : rs) { + oldRandomList.add(string); + } + }else{ + oldRandomList.add(randomnumber.getRandomNumber()); + } + } + randomnumber.setRandomNumber(randomUtil.newRandom(count,spellbuyproduct.getSpellbuyPrice(),oldRandomList)); + + randomnumber.setSpellbuyrecordId(spellbuyrecord.getSpellbuyRecordId()); + randomnumber.setBuyDate(spellbuyrecord.getBuyDate()); + randomnumber.setUserId(Integer.parseInt(userId)); + randomnumberService.add(randomnumber); + + if(StringUtil.isNotBlank(integral) && !integral.equals("0")){ + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")福分抵扣"); + commissionpoints.setPay("-"+integral); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points-Integer.parseInt(integral)); + } + + commissionpoints = new Commissionpoints(); + commissionpoints.setDate(DateUtil.DateTimeToStr(new Date())); + commissionpoints.setDetailed(ApplicationListenerImpl.sysConfigureJson.getShortName()+"商品编码("+spellbuyproduct.getSpellbuyProductId()+")支付"+count+"元获得福分"); + commissionpoints.setPay("+"+((count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())-(Integer.parseInt(integral)/100))); + commissionpoints.setToUserId(Integer.parseInt(userId)); + commissionpointsService.add(commissionpoints); + + Integer points = user.getCommissionPoints(); + user.setCommissionPoints(points+((count*ApplicationListenerImpl.sysConfigureJson.getBuyProduct())-(Integer.parseInt(integral)/100))); + + Integer experience = user.getExperience(); + experience += (count*10); + user.setExperience(experience); + userService.add(user); + + productJSON = new ProductJSON(); + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductId(productCart.getProductId()); + productJSON.setProductName(productCart.getProductName()); + productJSON.setProductPeriod(productCart.getProductPeriod()); + productJSON.setProductTitle(productCart.getProductTitle()); + productJSON.setBuyCount(count); + successCartList.add(productJSON); + } + } catch (Exception e) { + e.printStackTrace(); + flag = false; + } + } + } + if(flag){ + /** + * 清空购物车 + */ + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("products",null); + cookie.setMaxAge(0); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + request.setAttribute("buyproduct", buyproduct); + System.out.println("即时到帐付款成功"); + paymentStatus = "success"; + + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + } else { + paymentStatus = "error"; + System.out.println("交易签名被篡改!"); + } + return "success"; + } + + public String notifyUrl() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String keyValue = ApplicationListenerImpl.sysConfigureJson.getYeepayKey(); // 商家密钥 + String r0_Cmd = formatString(request.getParameter("r0_Cmd")); // 业务类型 + String p1_MerId = ApplicationListenerImpl.sysConfigureJson.getYeepayPartner(); // 商户编号 + String r1_Code = formatString(request.getParameter("r1_Code"));// 支付结果 + String r2_TrxId = formatString(request.getParameter("r2_TrxId"));// 易宝支付交易流水号 + String r3_Amt = formatString(request.getParameter("r3_Amt"));// 支付金额 + String r4_Cur = formatString(request.getParameter("r4_Cur"));// 交易币种 + String r5_Pid = new String(formatString(request.getParameter("r5_Pid")).getBytes("iso-8859-1"),"gbk");// 商品名称 + String r6_Order = formatString(request.getParameter("r6_Order"));// 商户订单号 + String r7_Uid = formatString(request.getParameter("r7_Uid"));// 易宝支付会员ID + String integral = new String(formatString(request.getParameter("r8_MP")).getBytes("iso-8859-1"),"gbk");// 商户扩展信息 + String r9_BType = formatString(request.getParameter("r9_BType"));// 交易结果返回类型 + String hmac = formatString(request.getParameter("hmac"));// 签名数据 + + //把请求参数打包成数组 + Map sParaTemp = new HashMap(); + sParaTemp.put("r0_Cmd", r0_Cmd); + sParaTemp.put("p1_MerId", p1_MerId); + sParaTemp.put("r1_Code", r1_Code); + sParaTemp.put("r2_TrxId", r2_TrxId); + sParaTemp.put("r3_Amt", r3_Amt); + sParaTemp.put("r4_Cur", r4_Cur); + sParaTemp.put("r5_Pid", r5_Pid); + sParaTemp.put("r6_Order", r6_Order); + sParaTemp.put("r7_Uid", r7_Uid); + sParaTemp.put("integral", integral); + sParaTemp.put("r9_BType", r9_BType); + sParaTemp.put("hmac", hmac); + + + boolean isOK = false; + // 校验返回数据包 + isOK = PaymentForOnlineService.verifyCallback(hmac,p1_MerId,r0_Cmd,r1_Code, + r2_TrxId,r3_Amt,r4_Cur,r5_Pid,r6_Order,r7_Uid,integral,r9_BType,keyValue); + if(isOK) { + //在接收到支付结果通知后,判断是否进行过业务逻辑处理,不要重复进行业务逻辑处理 + if(r1_Code.equals("1")) { + // 产品通用接口支付成功返回-浏览器重定向 + if(r9_BType.equals("1")) { + System.out.println("callback方式:产品通用接口支付成功返回-浏览器重定向"); + // 产品通用接口支付成功返回-服务器点对点通讯 + } else if(r9_BType.equals("2")) { + // 如果在发起交易请求时 设置使用应答机制时,必须应答以"success"开头的字符串,大小写不敏感 + System.out.println("SUCCESS"); + Struts2Utils.render("text/html", "success","encoding:UTF-8"); + // 产品通用接口支付成功返回-电话支付返回 + } + // 下面页面输出是测试时观察结果使用 + System.out.println("
    交易成功!
    商家订单号:" + r6_Order + "
    支付金额:" + r3_Amt + "
    易宝支付交易流水号:" + r2_TrxId); + //即时到账处理业务开始 + //------------------------------ + + try { + consumetable = consumetableService.findByOutTradeNo(r6_Order); + double money = Double.parseDouble(String.valueOf(r3_Amt)); + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId()==null){ + consumetable.setTransactionId(r2_TrxId); + consumetableService.add(consumetable); + + user = userService.findById(String.valueOf(consumetable.getUserId())); + user.setBalance(money+user.getBalance()); + userService.add(user); + flag = true; + } + } catch (Exception e) { + flag = false; + e.printStackTrace(); + } + String sHtmlText = buildRequest(sParaTemp,ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/yeepay/returnUrl.html","POST","确认"); + System.out.println(sHtmlText); + Struts2Utils.render("text/html", sHtmlText,"encoding:UTF-8"); + System.out.println("success"); //请不要修改或删除 + Struts2Utils.render("text/html", "success","encoding:UTF-8"); + + } + } else { + System.out.println("交易签名被篡改!"); + } + //建立请求 + return null; + } + + /** + * 建立请求,以表单HTML形式构造(默认) + * @param sParaTemp 请求参数数组 + * @param strMethod 提交方式。两个值可选:post、get + * @param strButtonName 确认按钮显示文字 + * @return 提交表单HTML文本 + */ + public static String buildRequest(Map sParaTemp,String postUrl, String strMethod, String strButtonName) { + //待请求参数数组 + Map sPara = sParaTemp; + List keys = new ArrayList(sPara.keySet()); + + StringBuffer sbHtml = new StringBuffer(); + + sbHtml.append("
    "); + for (int i = 0; i < keys.size(); i++) { + String name = (String) keys.get(i); + String value = (String) sPara.get(name); + sbHtml.append(""); + } + + //submit按钮控件请不要含有name属性 + sbHtml.append("
    "); + sbHtml.append(""); + + return sbHtml.toString(); + } + + public NewLotteryUtil getNewLotteryUtil() { + return newLotteryUtil; + } + + public void setNewLotteryUtil(NewLotteryUtil newLotteryUtil) { + this.newLotteryUtil = newLotteryUtil; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Consumetable getConsumetable() { + return consumetable; + } + + public void setConsumetable(Consumetable consumetable) { + this.consumetable = consumetable; + } + + public ProductCart getProductCart() { + return productCart; + } + + public void setProductCart(ProductCart productCart) { + this.productCart = productCart; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public Consumerdetail getConsumerdetail() { + return consumerdetail; + } + + public void setConsumerdetail(Consumerdetail consumerdetail) { + this.consumerdetail = consumerdetail; + } + + public List getProductCartList() { + return productCartList; + } + + public void setProductCartList(List productCartList) { + this.productCartList = productCartList; + } + + public List getSuccessCartList() { + return successCartList; + } + + public void setSuccessCartList(List successCartList) { + this.successCartList = successCartList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public String getPaymentStatus() { + return paymentStatus; + } + + public void setPaymentStatus(String paymentStatus) { + this.paymentStatus = paymentStatus; + } + + public Commissionquery getCommissionquery() { + return commissionquery; + } + + public void setCommissionquery(Commissionquery commissionquery) { + this.commissionquery = commissionquery; + } + + public Commissionpoints getCommissionpoints() { + return commissionpoints; + } + + public void setCommissionpoints(Commissionpoints commissionpoints) { + this.commissionpoints = commissionpoints; + } + + public Integer getMoneyCount() { + return moneyCount; + } + + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + + public String getIntegral() { + return integral; + } + + public void setIntegral(String integral) { + this.integral = integral; + } + + + +} diff --git a/src/main/java/me/mofun/action/YeepayBalanceAction.java b/src/main/java/me/mofun/action/YeepayBalanceAction.java new file mode 100644 index 0000000..dfb00dc --- /dev/null +++ b/src/main/java/me/mofun/action/YeepayBalanceAction.java @@ -0,0 +1,443 @@ +package me.mofun.action; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.Consumetable; +import me.mofun.pojo.User; +import me.mofun.service.ConsumerdetailService; +import me.mofun.service.ConsumetableService; +import me.mofun.service.UserService; +import me.mofun.tenpay.util.TenpayUtil; +import me.mofun.util.*; +import me.mofun.yeepay.config.PaymentForOnlineService; +import net.sf.json.JSONArray; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.util.*; + +public class YeepayBalanceAction extends ActionSupport { + + private static final long serialVersionUID = 1198398565998377267L; + @Autowired + ConsumetableService consumetableService; + @Autowired + ConsumerdetailService consumerdetailService; + @Autowired + private UserService userService; + + private User user; + private String userId; + private Consumetable consumetable; + private Integer moneyCount; + private String hidUseBalance; + private String paymentStatus; + + + //当前时间 yyyyMMddHHmmss + private String currTime = TenpayUtil.getCurrTime(); + //8位日期 + private String strTime = currTime.substring(8, currTime.length()); + //四位随机数 + private String strRandom = TenpayUtil.buildRandom(4) + ""; + //10位序列号,可以自行调整。 + private String strReq = strTime + strRandom; + private static String nodeAuthorizationURL = "https://www.yeepay.com/app-merchant-proxy/node"; + Random random = new Random(); + HttpServletRequest request = null; + HttpServletResponse response = null; + + String formatString(String text){ + if(text == null) { + return ""; + } + return text; + } + + public String index(){ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String keyValue = ApplicationListenerImpl.sysConfigureJson.getYeepayKey(); // 商家密钥 + // 商家设置用户购买商品的支付信息 + String p0_Cmd = formatString("Buy"); // 在线支付请求,固定值 ”Buy” + String p1_MerId = ApplicationListenerImpl.sysConfigureJson.getYeepayPartner(); // 商户编号 + String p2_Order = strReq; // 商户订单号 + String p3_Amt = moneyCount.toString(); // 支付金额 + String p4_Cur = formatString("CNY"); // 交易币种 + String p5_Pid = ApplicationListenerImpl.sysConfigureJson.getWwwUrl(); // 商品名称 + String p6_Pcat = ApplicationListenerImpl.sysConfigureJson.getWwwUrl(); // 商品种类 + String p7_Pdesc = ApplicationListenerImpl.sysConfigureJson.getWwwUrl(); // 商品描述 + String p8_Url = ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/yeepay/returnUrl.action"; // 商户接收支付成功数据的地址 + String p9_SAF = "0"; // 需要填写送货信息 0:不需要 1:需要 + String pa_MP = ""; // 商户扩展信息 + String pd_FrpId = ""; // 支付通道编码 + // 银行编号必须大写 + pd_FrpId = pd_FrpId.toUpperCase(); + String pr_NeedResponse = formatString("1"); // 默认为"1",需要应答机制 + String hmac = formatString(""); // 交易签名串 + + // 获得MD5-HMAC签名 + hmac = PaymentForOnlineService.getReqMd5HmacForOnlinePayment(p0_Cmd, + p1_MerId,p2_Order,p3_Amt,p4_Cur,p5_Pid,p6_Pcat,p7_Pdesc, + p8_Url,p9_SAF,pa_MP,pd_FrpId,pr_NeedResponse,keyValue); + + //把请求参数打包成数组 + Map sParaTemp = new HashMap(); + sParaTemp.put("p0_Cmd", p0_Cmd); + sParaTemp.put("p1_MerId", p1_MerId); + sParaTemp.put("p2_Order", p2_Order); + sParaTemp.put("p3_Amt", p3_Amt); + sParaTemp.put("p4_Cur", p4_Cur); + sParaTemp.put("p5_Pid", p5_Pid); + sParaTemp.put("p6_Pcat", p6_Pcat); + sParaTemp.put("p7_Pdesc", p7_Pdesc); + sParaTemp.put("p8_Url", p8_Url); + sParaTemp.put("p9_SAF", p9_SAF); + sParaTemp.put("pa_MP", pa_MP); + sParaTemp.put("pd_FrpId", pd_FrpId); + sParaTemp.put("pr_NeedResponse", pr_NeedResponse); + sParaTemp.put("hmac", hmac); + + Cookie[] cookies = request.getCookies(); + JSONArray array = null; + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); +// if(userId!=null && !userId.equals("")){ +// user = userService.findById(userId); +// } + } + } + } + + try { + consumetable = new Consumetable(); + int buyConut = moneyCount; + if(hidUseBalance!=null && !hidUseBalance.equals("")){ + buyConut +=Integer.parseInt(hidUseBalance); + } + double money = Double.parseDouble(String.valueOf(moneyCount)); + consumetable.setBuyCount(buyConut); + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + consumetable.setInterfaceType("yeePay"); + consumetable.setMoney(money); + consumetable.setOutTradeNo(p2_Order); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); +// consumerdetail = new Consumerdetail(); +// consumerdetail.setBuyCount(productCart.getCount()); +// consumerdetail.setBuyMoney(Double.parseDouble(productCart.getCount().toString())); +// consumerdetail.setConsumetableId(out_trade_no); +// consumerdetail.setProductId(productCart.getProductId()); +// consumerdetail.setProductName(productCart.getProductName()); +// consumerdetail.setProductPeriod(productCart.getProductPeriod()); +// consumerdetail.setProductTitle(productCart.getProductTitle()); +// consumerdetailService.add(consumerdetail); + flag = true; + } catch (Exception e) { + e.printStackTrace(); + flag = false; + } + + //建立请求 + String sHtmlText = buildRequest(sParaTemp,nodeAuthorizationURL,"POST","确认"); + System.out.println(sHtmlText); + if(flag){ + Struts2Utils.render("text/html", sHtmlText,"encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + return null; + } + + public String returnUrl() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + String keyValue = ApplicationListenerImpl.sysConfigureJson.getYeepayKey(); // 商家密钥 + String r0_Cmd = formatString(request.getParameter("r0_Cmd")); // 业务类型 + String p1_MerId = ApplicationListenerImpl.sysConfigureJson.getYeepayPartner(); // 商户编号 + String r1_Code = formatString(request.getParameter("r1_Code"));// 支付结果 + String r2_TrxId = formatString(request.getParameter("r2_TrxId"));// 易宝支付交易流水号 + String r3_Amt = formatString(request.getParameter("r3_Amt"));// 支付金额 + String r4_Cur = formatString(request.getParameter("r4_Cur"));// 交易币种 + String r5_Pid = new String(formatString(request.getParameter("r5_Pid")).getBytes("iso-8859-1"),"gbk");// 商品名称 + String r6_Order = formatString(request.getParameter("r6_Order"));// 商户订单号 + String r7_Uid = formatString(request.getParameter("r7_Uid"));// 易宝支付会员ID + String integral = new String(formatString(request.getParameter("integral")).getBytes("iso-8859-1"),"gbk");// 商户扩展信息 + String r9_BType = formatString(request.getParameter("r9_BType"));// 交易结果返回类型 + String hmac = formatString(request.getParameter("hmac"));// 签名数据 + + boolean isOK = false; + // 校验返回数据包 + isOK = PaymentForOnlineService.verifyCallback(hmac,p1_MerId,r0_Cmd,r1_Code, + r2_TrxId,r3_Amt,r4_Cur,r5_Pid,r6_Order,r7_Uid,integral,r9_BType,keyValue); + if(isOK) { + //在接收到支付结果通知后,判断是否进行过业务逻辑处理,不要重复进行业务逻辑处理 + if(r1_Code.equals("1")) { + // 产品通用接口支付成功返回-浏览器重定向 + if(r9_BType.equals("1")) { + System.out.println("callback方式:产品通用接口支付成功返回-浏览器重定向"); + // 产品通用接口支付成功返回-服务器点对点通讯 + } else if(r9_BType.equals("2")) { + // 如果在发起交易请求时 设置使用应答机制时,必须应答以"success"开头的字符串,大小写不敏感 + System.out.println("SUCCESS"); + // 产品通用接口支付成功返回-电话支付返回 + } + // 下面页面输出是测试时观察结果使用 + System.out.println("
    交易成功!
    商家订单号:" + r6_Order + "
    支付金额:" + r3_Amt + "
    易宝支付交易流水号:" + r2_TrxId); + //即时到账处理业务开始 + //------------------------------ + try { + try { + consumetable = consumetableService.findByOutTradeNo(r6_Order); + double money = Double.parseDouble(String.valueOf(r3_Amt)); + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId().equals(r2_TrxId)){ + paymentStatus = "success"; + }else{ + paymentStatus = "error"; + } + } catch (Exception e) { + e.printStackTrace(); + } + //注意交易单不要重复处理 + //注意判断返回金额 + + //------------------------------ + //即时到账处理业务完毕 + //------------------------------ + System.out.println("即时到帐付款成功"); + + } catch (Exception e) { + e.printStackTrace(); + } + } + } else { + System.out.println("交易签名被篡改!"); + } + + return "success"; + } + + + public String notifyUrl() throws UnsupportedEncodingException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + boolean flag = false; + String keyValue = ApplicationListenerImpl.sysConfigureJson.getYeepayKey(); // 商家密钥 + String r0_Cmd = formatString(request.getParameter("r0_Cmd")); // 业务类型 + String p1_MerId = ApplicationListenerImpl.sysConfigureJson.getYeepayPartner(); // 商户编号 + String r1_Code = formatString(request.getParameter("r1_Code"));// 支付结果 + String r2_TrxId = formatString(request.getParameter("r2_TrxId"));// 易宝支付交易流水号 + String r3_Amt = formatString(request.getParameter("r3_Amt"));// 支付金额 + String r4_Cur = formatString(request.getParameter("r4_Cur"));// 交易币种 + String r5_Pid = new String(formatString(request.getParameter("r5_Pid")).getBytes("iso-8859-1"),"gbk");// 商品名称 + String r6_Order = formatString(request.getParameter("r6_Order"));// 商户订单号 + String r7_Uid = formatString(request.getParameter("r7_Uid"));// 易宝支付会员ID + String integral = new String(formatString(request.getParameter("r8_MP")).getBytes("iso-8859-1"),"gbk");// 商户扩展信息 + String r9_BType = formatString(request.getParameter("r9_BType"));// 交易结果返回类型 + String hmac = formatString(request.getParameter("hmac"));// 签名数据 + + //把请求参数打包成数组 + Map sParaTemp = new HashMap(); + sParaTemp.put("r0_Cmd", r0_Cmd); + sParaTemp.put("p1_MerId", p1_MerId); + sParaTemp.put("r1_Code", r1_Code); + sParaTemp.put("r2_TrxId", r2_TrxId); + sParaTemp.put("r3_Amt", r3_Amt); + sParaTemp.put("r4_Cur", r4_Cur); + sParaTemp.put("r5_Pid", r5_Pid); + sParaTemp.put("r6_Order", r6_Order); + sParaTemp.put("r7_Uid", r7_Uid); + sParaTemp.put("integral", integral); + sParaTemp.put("r9_BType", r9_BType); + sParaTemp.put("hmac", hmac); + + + boolean isOK = false; + // 校验返回数据包 + isOK = PaymentForOnlineService.verifyCallback(hmac,p1_MerId,r0_Cmd,r1_Code, + r2_TrxId,r3_Amt,r4_Cur,r5_Pid,r6_Order,r7_Uid,integral,r9_BType,keyValue); + if(isOK) { + //在接收到支付结果通知后,判断是否进行过业务逻辑处理,不要重复进行业务逻辑处理 + if(r1_Code.equals("1")) { + // 产品通用接口支付成功返回-浏览器重定向 + if(r9_BType.equals("1")) { + System.out.println("callback方式:产品通用接口支付成功返回-浏览器重定向"); + // 产品通用接口支付成功返回-服务器点对点通讯 + } else if(r9_BType.equals("2")) { + // 如果在发起交易请求时 设置使用应答机制时,必须应答以"success"开头的字符串,大小写不敏感 + System.out.println("SUCCESS"); + Struts2Utils.render("text/html", "success","encoding:UTF-8"); + // 产品通用接口支付成功返回-电话支付返回 + } + // 下面页面输出是测试时观察结果使用 + System.out.println("
    交易成功!
    商家订单号:" + r6_Order + "
    支付金额:" + r3_Amt + "
    易宝支付交易流水号:" + r2_TrxId); + //即时到账处理业务开始 + //------------------------------ + + try { + consumetable = consumetableService.findByOutTradeNo(r6_Order); + double money = Double.parseDouble(String.valueOf(r3_Amt)); + System.err.println(consumetable.getMoney()); + System.err.println(money); + if(consumetable.getMoney().equals(money) && consumetable.getTransactionId()==null){ + consumetable.setTransactionId(r2_TrxId); + consumetableService.add(consumetable); + userId = String.valueOf(consumetable.getUserId()); + if(userId!=null && !userId.equals("")){ + try { + String key = MD5Util.encode(r2_TrxId); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + user = userService.findById(userId); + Double recMoney = consumetable.getMoney(); + if(recMoney >= ApplicationListenerImpl.sysConfigureJson.getRecMoney()){ + recMoney += ApplicationListenerImpl.sysConfigureJson.getRecBalance(); + } + Double temp = user.getBalance() + recMoney; + System.err.println("user.getBalance()"+user.getBalance()); + System.err.println("consumetable.getMoney()"+consumetable.getMoney()); + System.err.println("temp:"+temp); + user.setBalance(temp); + userService.add(user); + MemCachedClientHelp.getIMemcachedCache().put(key, "y",new Date(12*60*60*1000)); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + } + } catch (Exception e) { + e.printStackTrace(); + } + String sHtmlText = buildRequest(sParaTemp,ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/yeepayBalance/returnUrl.html","POST","确认"); + System.out.println(sHtmlText); + Struts2Utils.render("text/html", sHtmlText,"encoding:UTF-8"); + System.out.println("success"); //请不要修改或删除 + Struts2Utils.render("text/html", "success","encoding:UTF-8"); + + } + } else { + System.out.println("交易签名被篡改!"); + } + //建立请求 + return null; + } + + /** + * 建立请求,以表单HTML形式构造(默认) + * @param sParaTemp 请求参数数组 + * @param strMethod 提交方式。两个值可选:post、get + * @param strButtonName 确认按钮显示文字 + * @return 提交表单HTML文本 + */ + public static String buildRequest(Map sParaTemp,String postUrl, String strMethod, String strButtonName) { + //待请求参数数组 + Map sPara = sParaTemp; + List keys = new ArrayList(sPara.keySet()); + + StringBuffer sbHtml = new StringBuffer(); + + sbHtml.append("
    "); + for (int i = 0; i < keys.size(); i++) { + String name = (String) keys.get(i); + String value = (String) sPara.get(name); + sbHtml.append(""); + } + + //submit按钮控件请不要含有name属性 + sbHtml.append("
    "); + sbHtml.append(""); + + return sbHtml.toString(); + } + + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Consumetable getConsumetable() { + return consumetable; + } + + public void setConsumetable(Consumetable consumetable) { + this.consumetable = consumetable; + } + + public Integer getMoneyCount() { + return moneyCount; + } + + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + + public String getHidUseBalance() { + return hidUseBalance; + } + + public void setHidUseBalance(String hidUseBalance) { + this.hidUseBalance = hidUseBalance; + } + + public String getPaymentStatus() { + return paymentStatus; + } + + public void setPaymentStatus(String paymentStatus) { + this.paymentStatus = paymentStatus; + } + + public String getCurrTime() { + return currTime; + } + + public void setCurrTime(String currTime) { + this.currTime = currTime; + } + + public String getStrTime() { + return strTime; + } + + public void setStrTime(String strTime) { + this.strTime = strTime; + } + + public String getStrRandom() { + return strRandom; + } + + public void setStrRandom(String strRandom) { + this.strRandom = strRandom; + } + + public String getStrReq() { + return strReq; + } + + public void setStrReq(String strReq) { + this.strReq = strReq; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/action/my/GroupAction.java b/src/main/java/me/mofun/action/my/GroupAction.java new file mode 100644 index 0000000..4613724 --- /dev/null +++ b/src/main/java/me/mofun/action/my/GroupAction.java @@ -0,0 +1,933 @@ +package me.mofun.action.my; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.*; +import me.mofun.pojo.vo.CommentTreeVo; +import me.mofun.service.NewsReplyService; +import me.mofun.service.NewsService; +import me.mofun.service.NewsTypeService; +import me.mofun.service.UserService; +import me.mofun.util.DateUtil; +import me.mofun.util.Struts2Utils; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.struts2.dispatcher.RequestMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@SuppressWarnings("unused") +@Component("GroupAction") +public class GroupAction extends ActionSupport { + + private static final long serialVersionUID = 1889272927204740730L; + + @Autowired + private NewsService newsService; + + @Autowired + private NewsTypeService newTypeService; + + @Autowired + private UserService userService; + + @Autowired + private NewsReplyService newsReplyService; + + HttpServletRequest request = null; + HttpServletResponse response = null; + + private String action; + private Integer id; + private Integer parentId; + + private Integer subId; //newsType 表子类型Id,用于前端根据子类型Id 找出所属的父类型id; + + private NewsType group; + private Integer groupID; + private News topic; + private String topicID; + private NewsReply reply; + private User user; + private User logonUser; //记录登陆的用户信息 + + List groupSubList; //新闻子类别列表 + List groupTopList; //新闻根类别列表 + List replpContenttList; //新闻话题回复信息列表 + List replyList; //新闻话题回复信息及用户列表 + + List commentList; //新闻话题评论主题信息及用户列表 + List commentReplyList; //新闻话题评论主题回复及用户列表 + + //处理前端Ajax请求时的几个参数 http://127.0.0.1/JPData?action=replygetpagelist&groupID=10&topicID=1&FIdx=1&EIdx=10&isCount=1&fun=jsonp1461823453170&_=1461823529934 + private Integer FIdx; //分页时开始记录序号,假若每页10条的话,第一页该参数取值1 ,第二页该参数取值11 + private Integer EIdx; //分页时结束记录需要,假若每页10条的话,第一页该参数取值10,第二页该参数取值20 + private Integer isCount ; + private String fun; + private String _; + + //处理前端 Ajax inserttopicreply 请求时的几个参数 + private String json; + private String userId; //回复者或登录用户的ID + private String title; + private String content; + private Integer refFloor; + private String toUserId; + private String parentReplyId; + + public String index(){ + topic = newsService.findById(id.toString()); + groupTopList = newTypeService.indexNewsTypeByParentId(0); + parentId = newTypeService.findById(id.toString()).getParentId(); + return "index"; + } + + public String topic() { + if(topicID!=null) + { + topic=newsService.findById(""+topicID); + //group = newTypeService.findById(""+topic.getCategoryId()); + user=userService.findById(topic.getUserId()); + getLogonUserInfo(); //获取已登录的用户信息 + replyList = newsReplyService.indexNewsReply(topic.getNewsId(), null); + if(request==null) { + request = Struts2Utils.getRequest(); + } + request.getSession().setAttribute("groupID", topic.getCategoryId()); + } + return "topic"; + } + + public String JPData() { + + //for debug + ActionContext ac = ActionContext.getContext();//获取当前action的上下文 + RequestMap reqMap = (RequestMap)ac.get("request");//获取请求Map + String acPath = (String)reqMap.get("javax.servlet.forward.servlet_path");//获取跳转的action路径 + String queryString = (String)reqMap.get("javax.servlet.forward.query_string");//获取跳转的action请求参数 + + topic = newsService.findById(topicID.toString()); + groupTopList = newTypeService.indexNewsTypeByParentId(0); + parentId = newTypeService.findById(""+topic.getCategoryId()).getParentId(); + + user=userService.findById(topic.getUserId()); + getLogonUserInfo(); + + String temp=action; + if(request==null) + request = Struts2Utils.getRequest(); + String requestURL =request.getRequestURL().toString(); + String querString = request.getQueryString(); + if(action.equals("")&&queryString!=null) + action=querString.split("&")[0].split("=")[1]; + if(action.equals("replygetpagelist")) + //replygetpagelist(); + replygetpagelist(); + else + if (action.equals("updatelookcount")) + updatelookcount(); + else if (action.equals("deletegroupreply")) + deletegroupreply(); + else if (action.equals("getgroupusertotalinfo")) + getgroupusertotalinfo(); + else if (action.equals("checkadmingrouptopic")) + checkadmingrouptopic(); + else if (action.equals("updategrouptopicgood")) + updategrouptopicgood(); + else if (action.equals("showgrouptopicun")) + showgrouptopicun(); + else if (action.equals("inserttopicreply")) + inserttopicreply(); + else if (action.equals("checkgroupuserexists")) + checkgroupuserexists(); + else if (action.equals("insertgroupuser")) + insertgroupuser(); + else + { + RequestDispatcher d = request.getRequestDispatcher("/"+action+".action"); + try { + d.forward(request, response); + } catch (ServletException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /* + ActionContext ac = ActionContext.getContext();//获取当前action的上下文 + RequestMap reqMap = (RequestMap)ac.get("request");//获取请求Map + + String acPath = (String)reqMap.get("javax.servlet.forward.servlet_path");//获取跳转的action路径 + String queryString = (String)reqMap.get("javax.servlet.forward.query_string");//获取跳转的action请求参数 + */ + + return null; + } + + private class UserFloor{ + public int floor; //用户所在楼层数 + public String userName; //用户名 + //public int replyFloor; //用户回复楼层数,对XX楼说 + //public String replyFloorUserName; //回复楼层用户名, 对 XX 用户说 + } + + public UserFloor getUserFloor(List commnetTree,int replyId) + { + UserFloor uf = new UserFloor(); + if(commnetTree!=null) + { + int allFloor = commnetTree.size(); + for(int i=0;i commnetTree,int replyId) + { + UserReduce ur = new UserReduce(); + if(commnetTree!=null) + { + int allFloor = commnetTree.size(); + for(int i=0;i getCommentTree(String topicId,String type) { + List list=null; + try { + list=getTree(topicId,type); + } catch (Exception e) { + e.printStackTrace(); + } + + return list; + } + + public List getTree(String topicId,String type) throws Exception{ + + List treeList= null; + if(topicID!=null) + { + treeList=new ArrayList(); + topic = newsService.findById(topicID.toString()); + //groupTopList = newTypeService.indexNewsTypeByParentId(0); + //parentId = newTypeService.findById(""+topic.getCategoryId()).getParentId(); + replyList = newsReplyService.indexNewsReply(topic.getNewsId(), null); + for(int i=0;i replyChildList = getReplyChildList(replyList,replyId); + + if (replyChildList != null && replyChildList.size() > 0) { + if (parent.getChildren() == null) { + parent.setChildren(new ArrayList()); + } + for (Object[] temp : replyChildList) { + NewsReply nr = ((NewsReply)temp[1]); + User u = ((User)temp[0]); + CommentTreeVo vo = new CommentTreeVo(); + + vo.setReply(nr); + vo.setUser(u); + vo.setToUser(getUserReduce(nr.getParentReplyId())); //获取并设置对话对象的用户名 + vo.setLevel(parent.getLevel()+1); //获取并设置当前对话层级; + parent.getChildren().add(vo); + addTree(vo,nr.getReplyId(),type); + } + + } + } + + + public List getReplyChildList(List allReplyList,int replyId){ + List replyChildList = null; + for(int i=0;i(); + Object [] objs = {u,r}; + replyChildList.add(objs); + } + } + return replyChildList; + } + + //新显示风格 + public void replygetpagelist() { + if(topicID!=null) + { /* + topic = newsService.findById(topicID.toString()); + //groupTopList = newTypeService.indexNewsTypeByParentId(0); + //parentId = newTypeService.findById(""+topic.getCategoryId()).getParentId(); + replyList = newsReplyService.indexNewsReply(topic.getNewsId(), null); + */ + + List commnetTree = getCommentTree(topicID,""); + + JSONObject json = new JSONObject(); + int num=commnetTree.size(); + json.accumulate("num", num); + json.accumulate("code",0); + JSONObject subJson = new JSONObject(); + subJson.accumulate("hasPower", 0); + subJson.accumulate("loginUserID", -1); + JSONArray listItems = new JSONArray(); + UserFloor uf = new UserFloor(); + int allFloor = num; //总评论类主题数/总评论楼层数 + + if(this.FIdx==null||this.EIdx==null) { //分页开始记录需要和结束记录序号初始化判断 + this.FIdx=1; + this.EIdx=10; + } + for(int i=this.FIdx-1;i getReplyList() { + return replyList; + } + + public void setReplyList(List replyList) { + this.replyList = replyList; + } + + public String toAdd(){ + + return "toAddOrUpdate"; + } + + public String add(){ + + return "success"; + } + + public String toUpdate(){ + + return "toAddOrUpdate"; + } + + public String update(){ + + return "success"; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getGroupID() { + return groupID; + } + + public void setGroupID(Integer groupID) { + this.groupID = groupID; + } + + + public String getTopicID() { + return topicID; + } + + public void setTopicID(String topicID) { + this.topicID = topicID; + } + + public News getTopic() { + return topic; + } + + public void setTopic(News topic) { + this.topic = topic; + } + + public NewsType getGroup() { + return group; + } + + public void setGroup(NewsType group) { + this.group = group; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public User getLogonUser() { + return logonUser; + } + + public void setLogonUser(User logonUser) { + this.logonUser = logonUser; + } + + + public NewsReply getReply() { + return reply; + } + + public void setReply(NewsReply reply) { + this.reply = reply; + } + + public Integer getParentId() { + return parentId; + } + + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + public Integer getSubId() { + return subId; + } + + public void setSubId(Integer subId) { + this.subId = subId; + } + + public Integer getFIdx() { + return FIdx; + } + + public void setFIdx(Integer fIdx) { + FIdx = fIdx; + } + + public Integer getEIdx() { + return EIdx; + } + + public void setEIdx(Integer eIdx) { + EIdx = eIdx; + } + + public Integer getIsCount() { + return isCount; + } + + public void setIsCount(Integer isCount) { + this.isCount = isCount; + } + + public String getFun() { + return fun; + } + + public void setFun(String fun) { + this.fun = fun; + } + + public String get_() { + return _; + } + + public void set_(String _) { + this._ = _; + } + + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Integer getRefFloor() { + return refFloor; + } + + public void setRefFloor(Integer refFloor) { + this.refFloor = refFloor; + } + + public String getToUserId() { + return toUserId; + } + + public void setToUserId(String toUserId) { + this.toUserId = toUserId; + } + + public String getParentReplyId() { + return parentReplyId; + } + + public void setParentReplyId(String parentReplyId) { + this.parentReplyId = parentReplyId; + } + + public String getJson() { + return json; + } + + public void setJson(String json) { + this.json = json; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + + + + + + + +} diff --git a/src/main/java/me/mofun/action/my/HelpAction.java b/src/main/java/me/mofun/action/my/HelpAction.java new file mode 100644 index 0000000..4441c6c --- /dev/null +++ b/src/main/java/me/mofun/action/my/HelpAction.java @@ -0,0 +1,308 @@ +package me.mofun.action.my; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.Struts2Utils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; + +/** + * Help 带用户回复的版本 + * @author mofun + * + */ +@SuppressWarnings("unused") +@Component("HelpActionMy") +public class HelpAction extends ActionSupport { + + private static final long serialVersionUID = -8756837342149838857L; + + private Suggestion suggestion; + private String rnd; //投诉与建议的验证码? + private List helpInfoList; + private List helpTypeList; + + @Autowired + private SysConfigureService sysConfigureService; + @Autowired + private NewsTypeService newsTypeService; + @Autowired + private NewsService newsService; + + HttpServletRequest request = null; + HttpServletResponse response = null; + + public Integer newsId; //帮助信息的文章编号,亦即 news表中的 newsId + + + //用于用户回复时的几个属性定义 + private News topic; + private String topicID; + private NewsReply reply; + private User user; + private User logonUser; //记录登陆的用户信息 + + @Autowired + private UserService userService; + + @Autowired + private NewsReplyService newsReplyService; + + + public String index(){ +// news = newsService.findById(newsId.toString()); +// helpTypeList = newsTypeService.indexNewsTypeByParentId(2); +// helpInfoList = new ArrayList(); +// for(NewsType nt:helpTypeList){ +// HelpInfo item = new HelpInfo(); +// List newsList = newsService.indexNews(nt.getId(),null); +// item.setCategoryId(nt.getId()); +// item.setCategoryName(nt.getCategoryName()); +// item.setInfoList(newsList); +// helpInfoList.add(item); +// } + return "index"; + } + + public String help(){ + helpTypeList = newsTypeService.indexNewsTypeByParentId(2); //获取帮助类型的所有子类型 + helpInfoList = new ArrayList(); + for(NewsType nt:helpTypeList){ + if(!StringUtils.isNoneEmpty(nt.getCategoryName())) + continue; + HelpInfo item = new HelpInfo(); + List newsList = newsService.indexNews(nt.getId(),null); + item.setCategoryId(nt.getId()); + item.setCategoryName(nt.getCategoryName()); + item.setInfoList(newsList); + helpInfoList.add(item); + + if(newsId==null) { + for(News n:newsList) + { + newsId = n.getNewsId(); + } + } + } + topic = newsService.findById(newsId.toString()); + if(request==null) + request = Struts2Utils.getRequest(); + request.getSession().setAttribute("groupID", topic.getCategoryId()); + getLogonUserInfo(); + return "help"; + } + + public void getLogonUserInfo() { + if(request==null) { + request = Struts2Utils.getRequest(); + } + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + String userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + logonUser = userService.findById(userId); + request.getSession().setAttribute("user", logonUser); + } + } + } + } + } + + public int getNewsId() { + return newsId; + } + + public void setNewsId(Integer newId) { + this.newsId = newId; + } + + public List getHelpInfoList() { + return helpInfoList; + } + + public void setHelpInfoList(List helpInfoList) { + this.helpInfoList = helpInfoList; + } + + public String openCookie(){ + + return "openCookie"; + } + + public String whatPaigou(){ + return "whatPaigou"; + } + + public String paigouRule(){ + + return "paigouRule"; + } + + public String paigouFlow(){ + + return "paigouFlow"; + } + + public String questionDetail(){ + + return "questionDetail"; + } + + public String agreement(){ + + return "agreement"; + } + + public String genuinetwo(){ + + return "genuinetwo"; + } + + public String genuine(){ + + return "genuine"; + } + + public String securepayment(){ + + return "securepayment"; + } + + public String ship(){ + return "ship"; + } + + public String suggestion(){ + + return "suggestion"; + } + + public String doSuggestion(){ + request = Struts2Utils.getRequest(); + try { + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("rndCode")){ + String rndCode = cookie.getValue(); + if(rnd.trim().equalsIgnoreCase(rndCode)){ + sysConfigureService.doSuggestion(suggestion); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + + return null; + } + + public String deliveryFees(){ + return "deliveryFees"; + } + + public String prodCheck(){ + + return "prodCheck"; + } + + public String shiptwo(){ + + return "shiptwo"; + } + + public String privacy(){ + + return "privacy"; + } + + public String userExperience(){ + + return "userExperience"; + } + + public String qqgroup(){ + + return "qqgroup"; + } + + public String show(){ + return "show"; + } + + public Suggestion getSuggestion() { + return suggestion; + } + + public void setSuggestion(Suggestion suggestion) { + this.suggestion = suggestion; + } + + + public String getRnd() { + return rnd; + } + + public void setRnd(String rnd) { + this.rnd = rnd; + } + + public News getTopic() { + return topic; + } + + public void setTopic(News topic) { + this.topic = topic; + } + + public String getTopicID() { + return topicID; + } + + public void setTopicID(String topicID) { + this.topicID = topicID; + } + + public NewsReply getReply() { + return reply; + } + + public void setReply(NewsReply reply) { + this.reply = reply; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public User getLogonUser() { + return logonUser; + } + + public void setLogonUser(User logonUser) { + this.logonUser = logonUser; + } + + +} diff --git a/src/main/java/me/mofun/action/my/HelpNoReplyAction.java b/src/main/java/me/mofun/action/my/HelpNoReplyAction.java new file mode 100644 index 0000000..c5b9be9 --- /dev/null +++ b/src/main/java/me/mofun/action/my/HelpNoReplyAction.java @@ -0,0 +1,291 @@ +package me.mofun.action.my; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.*; +import me.mofun.service.NewsService; +import me.mofun.service.NewsTypeService; +import me.mofun.service.SysConfigureService; +import me.mofun.util.Struts2Utils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; + +/** + * Help 没有用户回复的版本 + * @author mofun + * + */ +@SuppressWarnings("unused") +@Component("HelpNoReplyActionMy") +public class HelpNoReplyAction extends ActionSupport { + + private static final long serialVersionUID = -8756837342149838857L; + + private Suggestion suggestion; + private String rnd; //投诉与建议的验证码? + private List helpInfoList; + private List helpTypeList; + private News news; + + @Autowired + private SysConfigureService sysConfigureService; + @Autowired + private NewsTypeService newsTypeService; + @Autowired + private NewsService newsService; + + HttpServletRequest request = null; + HttpServletResponse response = null; + + public Integer newsId; //帮助信息的文章编号,亦即 news表中的 newsId + + + //用于用户回复时的几个属性定义 + private News topic; + private String topicID; + private NewsReply reply; + private User user; + private User logonUser; //记录登陆的用户信息 + + + public String index(){ +// news = newsService.findById(newsId.toString()); +// helpTypeList = newsTypeService.indexNewsTypeByParentId(2); +// helpInfoList = new ArrayList(); +// for(NewsType nt:helpTypeList){ +// HelpInfo item = new HelpInfo(); +// List newsList = newsService.indexNews(nt.getId(),null); +// item.setCategoryId(nt.getId()); +// item.setCategoryName(nt.getCategoryName()); +// item.setInfoList(newsList); +// helpInfoList.add(item); +// } + return "index"; + } + + public String help(){ + helpTypeList = newsTypeService.indexNewsTypeByParentId(2); //获取帮助类型的所有子类型 + helpInfoList = new ArrayList(); + for(NewsType nt:helpTypeList){ + if(!StringUtils.isNoneEmpty(nt.getCategoryName())) + continue; + HelpInfo item = new HelpInfo(); + List newsList = newsService.indexNews(nt.getId(),null); + item.setCategoryId(nt.getId()); + item.setCategoryName(nt.getCategoryName()); + item.setInfoList(newsList); + helpInfoList.add(item); + + if(newsId==null) + for(News n:newsList) + { + newsId = n.getNewsId(); + } + } + news = newsService.findById(newsId.toString()); + return "help"; + } + + public int getNewsId() { + return newsId; + } + + public void setNewsId(Integer newId) { + this.newsId = newId; + } + + + public News getNews() { + return news; + } + + public void setNews(News news) { + this.news = news; + } + + + public List getHelpInfoList() { + return helpInfoList; + } + + public void setHelpInfoList(List helpInfoList) { + this.helpInfoList = helpInfoList; + } + + public String openCookie(){ + + return "openCookie"; + } + + public String whatPaigou(){ + return "whatPaigou"; + } + + public String paigouRule(){ + + return "paigouRule"; + } + + public String paigouFlow(){ + + return "paigouFlow"; + } + + public String questionDetail(){ + + return "questionDetail"; + } + + public String agreement(){ + + return "agreement"; + } + + public String genuinetwo(){ + + return "genuinetwo"; + } + + public String genuine(){ + + return "genuine"; + } + + public String securepayment(){ + + return "securepayment"; + } + + public String ship(){ + return "ship"; + } + + public String suggestion(){ + + return "suggestion"; + } + + public String doSuggestion(){ + request = Struts2Utils.getRequest(); + try { + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("rndCode")){ + String rndCode = cookie.getValue(); + if(rnd.trim().equalsIgnoreCase(rndCode)){ + sysConfigureService.doSuggestion(suggestion); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + + return null; + } + + public String deliveryFees(){ + return "deliveryFees"; + } + + public String prodCheck(){ + + return "prodCheck"; + } + + public String shiptwo(){ + + return "shiptwo"; + } + + public String privacy(){ + + return "privacy"; + } + + public String userExperience(){ + + return "userExperience"; + } + + public String qqgroup(){ + + return "qqgroup"; + } + + public String show(){ + return "show"; + } + + public Suggestion getSuggestion() { + return suggestion; + } + + public void setSuggestion(Suggestion suggestion) { + this.suggestion = suggestion; + } + + + public String getRnd() { + return rnd; + } + + public void setRnd(String rnd) { + this.rnd = rnd; + } + + public News getTopic() { + return topic; + } + + public void setTopic(News topic) { + this.topic = topic; + } + + public String getTopicID() { + return topicID; + } + + public void setTopicID(String topicID) { + this.topicID = topicID; + } + + public NewsReply getReply() { + return reply; + } + + public void setReply(NewsReply reply) { + this.reply = reply; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public User getLogonUser() { + return logonUser; + } + + public void setLogonUser(User logonUser) { + this.logonUser = logonUser; + } + + +} diff --git a/src/main/java/me/mofun/action/my/NewsTypeAction.java b/src/main/java/me/mofun/action/my/NewsTypeAction.java new file mode 100644 index 0000000..e1b24e4 --- /dev/null +++ b/src/main/java/me/mofun/action/my/NewsTypeAction.java @@ -0,0 +1,86 @@ +package me.mofun.action.my; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.NewsType; +import me.mofun.service.NewsTypeService; +import me.mofun.util.Struts2Utils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +@SuppressWarnings("unused") +@Component("NewsTypeAction") +public class NewsTypeAction extends ActionSupport { + + private static final long serialVersionUID = 1889272927204740730L; + + @Autowired + private NewsTypeService newTypeService; + + private Integer id; + private Integer parentId; + private String categoryName; + + private NewsType newsType; + List newsTypeList; + + public String index(){ + newsType = newTypeService.findById(id.toString()); + return "index"; + } + + /** + * 根据父ID获取所有子类型,供前台调用,暂时合并到 GroupAction.java 中,工前台 ajax 调用。 + */ + public void getNewsTypeSubList(){ + newsTypeList = newTypeService.indexNewsTypeByParentId(parentId); + Struts2Utils.renderJson(newsTypeList); + } + + public String toAdd(){ + + return "toAddOrUpdate"; + } + + public String add(){ + + return "success"; + } + + public String toUpdate(){ + + return "toAddOrUpdate"; + } + + public String update(){ + + return "success"; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getParentId() { + return parentId; + } + + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + public NewsType getNewsType() { + return newsType; + } + + public void setNewsType(NewsType newsType) { + this.newsType = newsType; + } + + +} diff --git a/src/main/java/me/mofun/action/my/ProductsAction.java b/src/main/java/me/mofun/action/my/ProductsAction.java new file mode 100644 index 0000000..8610444 --- /dev/null +++ b/src/main/java/me/mofun/action/my/ProductsAction.java @@ -0,0 +1,773 @@ +package me.mofun.action.my; + +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.*; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; +@SuppressWarnings("unused") +@Component("ProductsActionMy") +public class ProductsAction extends ActionSupport { + + private static final long serialVersionUID = 1626790673064716640L; + + @Autowired + @Qualifier("spellbuyrecordService") + private SpellbuyrecordService spellbuyrecordService; + @Autowired + @Qualifier("spellbuyproductService") + private SpellbuyproductService spellbuyproductService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ProductImageService productImageService; + + @Autowired + private UserService userService; + + @Autowired + private ShopService shopService; + + //@Autowired + //private SysConfigureService sysConfigureService; + + @Autowired + private DDNSGnudipUserService ddnsGnudipUserService; + + + private ProductInfo productInfo; + private Product product; + private Shop shop; + + private List ParticipateJSONList; + private Spellbuyrecord spellbuyrecord; + private List spellbuyrecordList; + private List spellbuyproductList; + private Spellbuyproduct spellbuyproduct; + private Latestlottery latestlottery; + private TreeMap productPeriodList; + private List productimageList; + private User user; + private String id; + private String userId; + private int pageNo; + private int pageSize = 20; + private int pageCount; + private int resultCount; + //private static Long isStatusBeginDate; + //private static Long isStatusNowDate = System.currentTimeMillis(); + private String isLotteryJSON; + private Long endDate; + private Long nowDate; + private String logicURL; + private ServiceLogic serviceLogic; + private List ddnsGnudipUserList; + + private boolean payResult=false; + private String keyName; + private String keyValue; + private Integer keyCount; + + //调试返回不同的页面参数,仅仅便于开发时调试用 + private String debugUrl; + + HttpServletRequest request = null; + + Logger logger = Logger.getLogger(this.getClass()); + + public String index() throws ServletException, IOException{ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + ParticipateJSONList = new ArrayList(); + + //List proList = spellbuyproductService.findByProductId(Integer.parseInt(id)); + //List proList = spellbuyproductService.findBySpellbuyProductId(Integer.parseInt(id)); + List proList =null; + if(Integer.parseInt(id)>10000) //产品ID一般是4位,作为商品/竞品发布后,其在竞品表中产生的竞品ID为5位或5位以上,如10028 + proList = spellbuyproductService.findBySpellbuyProductId(Integer.parseInt(id)); + else + proList = spellbuyproductService.findByFKProductId(Integer.parseInt(id)); + + productInfo = new ProductInfo(); + //product = (Product) proList.get(0)[0]; + //spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + product = (Product) proList.get(0)[1]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[0]; + productInfo.setProductPeriod(spellbuyproduct.getProductPeriod()); //获取并设置商品期数 + productInfo.setProductId(product.getProductId()); //获取并设置商品Id + productInfo.setStatus(spellbuyproduct.getSpStatus()); + productInfo.setHeadImage(product.getHeadImage()); + productInfo.setProductDetail(product.getProductDetail()); + productInfo.setProductName(product.getProductName()); + productInfo.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productInfo.setMarketPrice(spellbuyproduct.getMarketPrice()); //电商版新增字段:市场价 + productInfo.setActionName(spellbuyproduct.getActionName()); //电商版新增字段:优惠活动名称 + productInfo.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productInfo.setProductTitle(product.getProductTitle()); + productInfo.setSpellbuyCount(spellbuyproduct.getSpellbuyCount()); + productInfo.setSpellbuyProductId(spellbuyproduct.getSpellbuyProductId()); //获取并设置本次拍购商品的拍购Id + productInfo.setBuyLimited(spellbuyproduct.getSpellbuyLimit()); + + productInfo.setIsVirtual(product.getIsVirtual()); + productInfo.setIsNeedLogic(product.getIsNeedLogic()); + productInfo.setLogicURL(product.getLogicURL()); + + productInfo.setShopId(product.getShopId()); + + shop = shopService.findById(""+product.getShopId()); + + +// if(spellbuyproduct.getSpStatus()==1){ +// latestlottery = (Latestlottery) latestlotteryService.getLotteryDetail(Integer.parseInt(id)).get(0); +// } + + List objectList = spellbuyproductService.productPeriodList(spellbuyproduct.getFkProductId()); + productPeriodList = new TreeMap(new Comparator(){ + public int compare(Object o1, Object o2){ + return o2.hashCode()-o1.hashCode(); + } + }); + for (Object[] objects : objectList) { + //spellbuyproduct = (Spellbuyproduct) objects[1]; // for jdk1.7 lwg 2020.03.18 + spellbuyproduct = (Spellbuyproduct) objects[0]; // for jdk1.8 lwg 2020.03.18 + productPeriodList.put(spellbuyproduct.getProductPeriod(),spellbuyproduct.getSpellbuyProductId()); + } + + productimageList = productImageService.findByProductId(String.valueOf(product.getProductId()), "show"); + + Pagination pagination = spellbuyrecordService.LatestParticipate(id, pageNo, 6); + List list = (List) pagination.getList(); + for (int i = 0; i < list.size(); i++) { + ParticipateJSON participateJSON = new ParticipateJSON(); + spellbuyrecord = (Spellbuyrecord) list.get(i)[0]; + user = (User) list.get(i)[1]; + String userName = UserNameUtil.userName(user); + participateJSON.setBuyCount(spellbuyrecord.getBuyPrice().toString()); + participateJSON.setBuyDate(DateUtil.getTime(DateUtil.SDateTimeToDate(spellbuyrecord.getBuyDate()))); + participateJSON.setBuyId(spellbuyrecord.getSpellbuyRecordId().toString()); + participateJSON.setIp_address(user.getIpAddress()); + participateJSON.setIp_location(user.getIpLocation()); + participateJSON.setUserName(userName); + participateJSON.setUserId(String.valueOf(user.getUserId())); + participateJSON.setUserFace(user.getFaceImg()); + ParticipateJSONList.add(participateJSON); + } + resultCount = spellbuyrecordService.LatestParticipateByCount(id); //获取某商品最新参与人数 + + + //拼购状态:(0:未完成,可以正常购买中;1:开奖已完成,整个拍购及开奖过程均已结束;2:拍购刚完成,进入开奖环节,可以计算中奖号码了... + //if(productInfo.getStatus()==2){ + if(ApplicationListenerImpl.sysConfigureJson.getVersionType()==1&&productInfo.getStatus()==2){ //电商版新增判断,当是拍购版时,才进行开奖状态判断,否则直接进入产品详情页。 + return "lottery"; + }else if(ApplicationListenerImpl.sysConfigureJson.getVersionType()==1&&productInfo.getStatus()==1){ //电商版新增判断,当是拍购版时,才进行开奖状态判断,否则直接进入产品详情页。 + HttpServletResponse response = Struts2Utils.getResponse(); + response.sendRedirect("/lotteryDetail/"+productInfo.getSpellbuyProductId()+".html"); +// Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; +// HttpServletRequest request = Struts2Utils.getRequest(); +// HttpServletResponse response = Struts2Utils.getResponse(); +// request.getRequestDispatcher("/lotteryDetail/index.action?id="+productInfo.getSpellbuyProductId()).forward(request,response); + }else{ + //获取并设置userId 便于将userId 在 Index.jsp 中通过 传递给 ) gnudipUserPage.getList(); + //Struts2Utils.renderJson(ddnsGnudipUserList); + } + else + {//未登录时 + serviceLogic.setVirtual(true); + serviceLogic.setNeed(true); + serviceLogic.setResultCode(-1); + serviceLogic.setResultMsg("请先登录"); + } + } + return "serviceLogic"; + } + + public String getServiceLogicContent(){ + Map map = new HashMap(); + map.put("userId", userId); + map.put("id", id); + String htmlContent = HTTPClientUtils.getURLContent(logicURL, map, "post"); + Struts2Utils.renderText(htmlContent); + return null; + } + + /** + * 本商品往期拍购列表 + * @return + */ + public String getProductNewList(){ + spellbuyproduct = spellbuyproductService.findById(id); + List objectList = spellbuyproductService.productPeriodList(spellbuyproduct.getFkProductId()); + productPeriodList = new TreeMap(); + for (Object[] objects : objectList) { + spellbuyproduct = (Spellbuyproduct) objects[1]; + productPeriodList.put(spellbuyproduct.getProductPeriod(),spellbuyproduct.getSpellbuyProductId()); + } + Struts2Utils.renderJson(productPeriodList); + return null; + } + + /** + * 某产品最近交易的100条记录 + * @return + */ + public String ajaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + ParticipateJSONList = new ArrayList(); + Pagination pagination = spellbuyrecordService.LatestParticipate(id, pageNo, pageSize); + List list = (List) pagination.getList(); + for (int i = 0; i < list.size(); i++) { + ParticipateJSON participateJSON = new ParticipateJSON(); + spellbuyrecord = (Spellbuyrecord) list.get(i)[0]; + user = (User) list.get(i)[1]; + String userName = UserNameUtil.userName(user); + participateJSON.setBuyCount(spellbuyrecord.getBuyPrice().toString()); + participateJSON.setBuyDate(spellbuyrecord.getBuyDate()); + participateJSON.setBuyId(spellbuyrecord.getSpellbuyRecordId().toString()); + participateJSON.setIp_address(user.getIpAddress()); + participateJSON.setIp_location(user.getIpLocation()); + participateJSON.setUserName(userName); + participateJSON.setUserId(String.valueOf(user.getUserId())); + participateJSON.setUserFace(user.getFaceImg()); + ParticipateJSONList.add(participateJSON); + } + Struts2Utils.renderJson(ParticipateJSONList); + return null; + } + + /** + * 我的购买记录_Old版本 + */ + public void getUserByHistory_Dev(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + List listArrayObj= spellbuyrecordService.getUserByHistory(userId, id); + List spellbuyrecordExtList = new ArrayList(); + if(!listArrayObj.isEmpty()) { + //List spellbuyrecordExtList2 = new ArrayList(); + + if(spellbuyrecordList==null)spellbuyrecordList = new ArrayList(); + if(spellbuyproductList==null)spellbuyproductList = new ArrayList(); + for(Object[] objArray:listArrayObj) + { + if(!spellbuyrecordList.contains(objArray[0])) + { + Spellbuyrecord s=(Spellbuyrecord)objArray[0]; + SpellbuyrecordExt e =(SpellbuyrecordExt)s; + spellbuyrecordList.add((Spellbuyrecord)objArray[0]); + } + if(!spellbuyproductList.contains(objArray[1])) + spellbuyproductList.add((Spellbuyproduct)objArray[1]); + } + + //spellbuyrecordExtList2 = (List)spellbuyrecordList; + for(Spellbuyrecord r:spellbuyrecordList) + { + SpellbuyrecordExt ext =new SpellbuyrecordExt(); + ext.setAttribute66(r.getAttribute66()); + ext.setAttribute67(r.getAttribute67()); + ext.setBuyDate(r.getBuyDate()); + ext.setBuyer(r.getBuyer()); + ext.setBuyPrice(r.getBuyPrice()); + ext.setBuyStatus(r.getBuyStatus()); + ext.setFkSpellbuyProductId(r.getFkSpellbuyProductId()); + ext.setSpellbuyRecordId(r.getSpellbuyRecordId()); + ext.setSpRandomNo(r.getSpRandomNo()); + ext.setSpWinningStatus(r.getSpWinningStatus()); + + for(Spellbuyproduct sp: spellbuyproductList) + { + if(sp.getSpellbuyProductId().intValue()==r.getFkSpellbuyProductId().intValue()) { + ext.setSinglePrice(sp.getSpSinglePrice()); + break; + } + } + spellbuyrecordExtList.add(ext); + } + } + Struts2Utils.renderJson(spellbuyrecordExtList); + } + } + } + } + } + + + /** + * 我的购买记录_改进版:直接从数据库中取出自定义字段转换为所需对象 + * http://www.local.com/products/getUserByHistory.action?id=10047 + */ + public void getUserByHistory(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + List spellbuyrecordExtList= spellbuyrecordService.getUserByHistory(userId, id); + Struts2Utils.renderJson(spellbuyrecordExtList); + } + } + } + } + } + +/** + * 从cookie 中获取登陆用户Id + * @return userId + * @author mofun + */ +public String getUserIdFromCookie() +{ + String userIdFromCookie=""; + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userIdFromCookie = cookie.getValue(); + } + } + } + return userIdFromCookie; +} + + + + /** + * @author lwg + * 检查限购情况,用于商品详情页 goodsdetail.js 中 ajax 调用 /products/checkUserLimitBuy.action + * http://127.0.0.1:8080/products/checkUserLimitBuy.action?id=1001 + * @param id 产品id ProductId + * @return {"code":0,"codeLimitBuy":0,"buyNum":0,"codeState":0,"codeRemainNum":0,"userMoney":0.0} + * code: 本函数是否执行成功的标识返回码,仔细阅读前台js 得知有 0,-10,-6,-5,-4 等几个返回码状态,其中0应该标识成功 + * codeLimitBuy:该产品默认限购次数:无限购0;有限购的话为单人最多购买该商品的件数/次数,一般为5或10 + * buyNum:某用户已购买的次数 + * codeState: 产品状态,正常上架状态为 0 + * codeRemainNum:该产品剩余的购买次数 + * userMoney:某用户当前的余额 + */ + public String checkUserLimitBuy(){ + String theUserId=StringUtils.isNotBlank(userId)?userId:getUserIdFromCookie(); + + List objectList = spellbuyproductService.checkUserLimitBuy(id,theUserId); + UserLimitBuy u = new UserLimitBuy(); + u.setCode(0); //初始化返回码为0 默认执行成功 + if(StringUtils.isNotBlank(theUserId)) + { + for (Object[] objects : objectList) { + spellbuyproduct = (Spellbuyproduct)objects[0]; + spellbuyrecord = (Spellbuyrecord)objects[1]; + user = (User)objects[2]; + break; + } + + //如果没有拍购记录,只获取拍购产品及用户余额 + if(spellbuyrecord==null){ + spellbuyproduct = spellbuyproductService.findById(id); + user = userService.findById(theUserId); + } + } + else + { + spellbuyproduct = spellbuyproductService.findById(id); + u.setCode(-10); //用户没有登录时,返回码为-10 + } + + if(spellbuyproduct!=null){ + u.setCode(spellbuyproduct.getFkProductId()); + u.setCodeLimitBuy(spellbuyproduct.getSpellbuyLimit()); + u.setCodeRemainNum(spellbuyproduct.getSpellbuyPrice()-spellbuyproduct.getSpellbuyCount()); + u.setCodeState(spellbuyproduct.getSpStatus()); + + if(u.getCodeRemainNum()<=0) + u.setCode(-6); //剩余购买次数为0时,设置返回码为 -6,前端 js 中会据此设置 _CanBuy = 0 ,表示已售完或不能再购买了。 + + } + + if(user!=null) + u.setUserMoney((float)(user.getBalance()!=null?user.getBalance().floatValue():0.0)); + + if(user!=null&&spellbuyrecord!=null) + u.setBuyNum(spellbuyrecord.getBuyPrice()); + + Struts2Utils.renderJson(u); + + return null; + } + + /** + * 检查商品关注情况 + * 参照 http://www.1ypg.com/products/checkCollectGoods.action?id=3 无论 goodsId是否存在,没有登录的用户统一返回 10 + * 用于 goodsdetail.js /products/checkCollectGoods.action ajax 调用 + * @author mofun + * @return + */ + public String checkCollectGoods() + { + Struts2Utils.renderText("10"); + return null; + } + + /** + * 添加关注(登录后才可以关注) + * 参考 http://www.1ypg.com/products/addCollectGoods.action?id=4647 + * 没登陆时无论商品是否存在统一返回 10,前端据此会弹出登陆框提示用户登录。 + * 已登陆用户点击产品页关注 链接 会进行 ajax 调用,成功后返回 0 + * 用于前端 添加关注 时进行 ajax 调用 /products/addCollectGoods.action + */ + public String addCollectGoods() + { + String goodsId=id; + Struts2Utils.renderText("10"); + return null; + } + + /** + * 是否可以开奖了:spStatus=2表示,可以开奖了;spStatus=1 表示开奖已完成。 + * http://127.0.0.1:8080/products/isLottery.action?id=10020 + * http://www.1ypg.com//products/isLottery.action?id=17396 + */ + public String isLottery(){ + String key = MD5Util.encode(id+"status"); + if(MemCachedClientHelp.getIMemcachedCache().get(key)==null){ + spellbuyproduct = spellbuyproductService.findById(id); + endDate = DateUtil.SDateTimeToDate(spellbuyproduct.getSpellbuyEndDate()).getTime(); + nowDate = System.currentTimeMillis(); + + //(endDate-nowDate)/1000 亦即:(产品竞拍结束时间转换成毫秒-当前时间毫秒数)/1000 意思产品竞购结束时间距当前时间已过去的秒数,就是说竞拍结束过去了多少秒 + isLotteryJSON = "{\"spStatus\":\""+spellbuyproduct.getSpStatus()+"\",\"date\":\""+((endDate-nowDate)/1000)+"\"}"; + try{ + MemCachedClientHelp.getIMemcachedCache().put(key, String.valueOf(endDate),new Date(10*60*1000)); + } + catch(Exception ex){ + ex.printStackTrace(); + } + Struts2Utils.renderJson(isLotteryJSON); + }else{ + endDate = Long.parseLong((String)MemCachedClientHelp.getIMemcachedCache().get(key)); + nowDate = System.currentTimeMillis(); + isLotteryJSON = "{\"spStatus\":\"2\",\"date\":\""+((endDate-nowDate)/1000)+"\"}"; + Struts2Utils.renderJson(isLotteryJSON); + } +// isStatusNowDate = System.currentTimeMillis(); +// if(isStatusBeginDate==null){ +// spellbuyproduct = spellbuyproductService.findById(id); +// endDate = DateUtil.SDateTimeToDate(spellbuyproduct.getSpellbuyEndDate()).getTime(); +// nowDate = System.currentTimeMillis(); +// isLotteryJSON = "{\"spStatus\":\""+spellbuyproduct.getSpStatus()+"\",\"date\":\""+((endDate-nowDate)/1000)+"\"}"; +// isStatusBeginDate = System.currentTimeMillis(); +// Struts2Utils.renderJson(isLotteryJSON); +// }else{ +// if((isStatusNowDate-isStatusBeginDate)<1000){ +// Struts2Utils.renderJson(isLotteryJSON); +// }else{ +// isStatusBeginDate = System.currentTimeMillis(); +// spellbuyproduct = spellbuyproductService.findById(id); +// endDate = DateUtil.SDateTimeToDate(spellbuyproduct.getSpellbuyEndDate()).getTime(); +// nowDate = System.currentTimeMillis(); +// isLotteryJSON = "{\"spStatus\":\""+spellbuyproduct.getSpStatus()+"\",\"date\":\""+((endDate-nowDate)/1000)+"\"}"; +// Struts2Utils.renderJson(isLotteryJSON); +// } +// } + + return null; + } + + public static void main(String[] args) { +// Long endDate = DateUtil.SDateTimeToDate("2013-11-27 14:12:38").getTime(); +// Long nowDate = System.currentTimeMillis(); +// System.err.println((endDate-nowDate)/1000); +// System.err.println(DateUtil.DateTimeToStr(DateUtil.subMinute(new Date(), -3))); + String lotteryId = MD5Util.encode("10022"); + String a = (String) MemCachedClientHelp.getIMemcachedCache().get(lotteryId); + System.err.println(a); + MemCachedClientHelp.getIMemcachedCache().remove(lotteryId); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public ProductInfo getProductInfo() { + return productInfo; + } + + public void setProductInfo(ProductInfo productInfo) { + this.productInfo = productInfo; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public List getParticipateJSONList() { + return ParticipateJSONList; + } + + public void setParticipateJSONList(List participateJSONList) { + ParticipateJSONList = participateJSONList; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Shop getShop() { + return shop; + } + + public void setShop(Shop shop) { + this.shop = shop; + } + + public TreeMap getProductPeriodList() { + return productPeriodList; + } + + public void setProductPeriodList(TreeMap productPeriodList) { + this.productPeriodList = productPeriodList; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getProductimageList() { + return productimageList; + } + + public void setProductimageList(List productimageList) { + this.productimageList = productimageList; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public List getSpellbuyrecordList() { + return spellbuyrecordList; + } + + public void setSpellbuyrecordList(List spellbuyrecordList) { + this.spellbuyrecordList = spellbuyrecordList; + } + + public List getSpellbuyproductList() { + return spellbuyproductList; + } + + public void setSpellbuyproductList(List spellbuyproductList) { + this.spellbuyproductList = spellbuyproductList; + } + + public String getLogicURL() { + return logicURL; + } + + public void setLogicURL(String logicURL) { + this.logicURL = logicURL; + } + + public ServiceLogic getServiceLogic() { + return serviceLogic; + } + + + public void setServiceLogic(ServiceLogic serviceLogic) { + this.serviceLogic = serviceLogic; + } + + public List getDdnsGnudipUserList() { + return ddnsGnudipUserList; + } + + + public void setDdnsGnudipUserList(List ddnsGnudipUserList) { + this.ddnsGnudipUserList = ddnsGnudipUserList; + } + + public boolean isPayResult() { + return payResult; + } + + public void setPayResult(boolean payResult) { + this.payResult = payResult; + } + + public String getKeyName() { + return keyName; + } + + public void setKeyName(String keyName) { + this.keyName = keyName; + } + + public String getKeyValue() { + return keyValue; + } + + public void setKeyValue(String keyValue) { + this.keyValue = keyValue; + } + + public Integer getKeyCount() { + return keyCount; + } + + public void setKeyCount(Integer keyCount) { + this.keyCount = keyCount; + } + + public String getDebugUrl() { + return debugUrl; + } + + public void setDebugUrl(String debugUrl) { + this.debugUrl = debugUrl; + } + + public class SpellbuyrecordExt extends Spellbuyrecord{ + private float singlePrice; //单价 + + public float getSinglePrice() { + return singlePrice; + } + + public void setSinglePrice(float singlePrice) { + this.singlePrice = singlePrice; + } + } + +} diff --git a/src/main/java/me/mofun/action/my/ShopAction.java b/src/main/java/me/mofun/action/my/ShopAction.java new file mode 100644 index 0000000..0ae3a6a --- /dev/null +++ b/src/main/java/me/mofun/action/my/ShopAction.java @@ -0,0 +1,4089 @@ +package me.mofun.action.my; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.pojo.vo.ResultObj; +import me.mofun.service.*; +import me.mofun.util.*; +import net.sf.json.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts2.ServletActionContext; +import org.apache.struts2.dispatcher.RequestMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLEncoder; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +@SuppressWarnings("unused") +@Component("ShopAction") +public class ShopAction extends ActionSupport { + private static final long serialVersionUID = 6146740235643445087L; + + @Autowired + private UserService userService; + + @Autowired + private ShopService shopService; + + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ShareService shareService; + @Autowired + private ConsumetableService consumetableService; + @Autowired + private NewsService newsService; + @Autowired + private RegionService regionService; + @Autowired + private CommissionqueryService commissionqueryService; + @Autowired + private CommissionpointsService commissionpointsService; + @Autowired + private ApplymentionService applymentionService; + @Autowired + private CardpasswordService cardpasswordService; + @Autowired + private ConsumerdetailService consumerdetailService; + @Autowired + private OrderdetailService orderdetailService; + @Autowired + private OrderDetailAddressService orderDetailAddressService; + + @Autowired + private ProductService productService; + + @Autowired + private ProductTypeService productTypeService; + + private List productTypeList; + private List productBrandList; + private Shareimage shareimage; + private List productList; + private List productimageList; + private List shareimageList; + + private String forward; + private String to; + //private List productList; + private List newDateList; + private ProductJSON productJSON; + private List productJSONList; + private BuyHistoryJSON buyHistoryJSON; + private ShareJSON shareJSON; + private List buyHistoryJSONList; + private List randomNumberJSONList; + private RandomNumberJSON randomNumberJSON; + private List shareJSONList; + private List userbyaddressList; + private List newsList; + private List sProvinceList; + private List sCityList; + private List sDistrictList; + private List userList; + private List commissionqueryList; + private List commissionpointsList; + private List applymentionList; + private List commissionqueryJSONList; + private List orderdetailList; + private Orderdetail orderdetail; + private OrderDetailAddress orderDetailAddress; + private CommissionqueryJSON commissionqueryJSON; + private Applymention applymention; + private Commissionquery commissionquery; + private Commissionpoints commissionpoints; + private Userbyaddress userbyaddress; + private Product product; + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private Randomnumber randomnumber; + private Latestlottery latestlottery; + private Shareinfo shareinfo; + private User user; + private String userJSON; + private String userId; + private String id; + private String keyword; + + + + private Integer shopId; + private Shop shop; + private boolean hasAuditSuccessShop; //是否有审核成功的商铺 + private Integer imageType; + private File credentialsPhotoFile; + private String credentialsPhotoFileFileName; + private File cardIdPhotoFile; + private String cardIdPhotoFileFileName; + private String filename; + private String UploadImageDir="/uploadImages"; + private String ShopImageDir="/shopImages"; + private String hidCredentialsPhotoUrl; + private String hidCardIdPhotoUrl; + + private String companyName; + private String shopName; + private String province; + private String city; + private String county; + private String address; + private Double x; + private Double y; + private Integer credentialsType; + private String legalRepresentativeName; + private String legalRepresentativeId; + private Integer payChannel; + private String alipay; + private String tengpay; + private String managerPhone; + private String managerName; + private String manngerTitle; + private String weixinPublic; + private String servicePhone; + private String qq; + private String weixin; + private String synopsis; + + private List shopList; + private List orderBeanList; + + private int pageNo; + private String pages; + private String pageString; + private int pageSize = 20; + private int pageCount; + private int resultCount; + private String startDate; + private String endDate; + private String selectTime; + private File myFile; + private String myFileFileName; + private String myFileContentType; + private String imageFileName; + private static final int BUFFER_SIZE = 100 * 1024 ; + private int x1; + private int y1; + private int w; + private int h; + private String hidPicUrl; + + + + private List orderDetailAddressList; + + private String userName; + private String key; //用户邮箱或手机验证时用(/user/EmailChecking.jsp、/user/MobileChecking.jsp) + + private String typeId; + private String tId; + private String typeName; + + private String backUrl; + + private ResultObj resultObj; + + HttpServletRequest request = null; + HttpServletResponse response = null; + static HTMLFilter htmlFilter = new HTMLFilter(); + + Logger logger = Logger.getLogger(this.getClass()); + + //进入卖家中心入口 + public String main() { + //for debug + ActionContext ac = ActionContext.getContext();//获取当前action的上下文 + RequestMap reqMap = (RequestMap)ac.get("request");//获取请求Map + String acPath = (String)reqMap.get("javax.servlet.forward.servlet_path");//获取跳转的action路径 + String queryString = (String)reqMap.get("javax.servlet.forward.query_string");//获取跳转的action请求参数 + + boolean canUpdate = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canUpdate = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) { //需要是已注册用户且必须登录后才能继续,否则要先登录 + forward="shop"; + return "login_index"; + } + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canUpdate=true; + }else { + if(resultObj==null) { + resultObj = new ResultObj(); + } + resultObj.setCanNext(false); + resultObj.setCode(-4); + resultObj.setMsg("您名下还没有任何商铺,请先注册商铺升级为机构用户后再继续。"); + to="shopListSample"; + return "main"; + + } + } + + if(canUpdate){ + return "main"; + } + forward="shop"; + return "login_index"; + } + + public String shopList(){ + hasAuditSuccessShop = false; + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + if(shopService.isHasAuditSucceedShop(shopList)) + hasAuditSuccessShop = true; + } else { + return "shopListSample"; + } + } + + // if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + if(user.getUserName().equals("admin")) + return "shopList4AdminAll"; + else + return "shopList4NormalUser"; + } + return "index_login"; + } + + public String shopListSample(){ + hasAuditSuccessShop = false; + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + if(shopService.isHasAuditSucceedShop(shopList)) + hasAuditSuccessShop = true; + }else { //已登录用户,但是尚未申请未注册过店铺。 + if(resultObj==null) { + resultObj = new ResultObj(); + } + resultObj.setCanNext(false); + resultObj.setCode(-4); + resultObj.setMsg("您名下还没有任何商铺,请先注册商铺升级为机构用户后再继续。"); + to="shopListSample"; + return "shopListSample"; + } + } + + // if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + if(user.getUserName().equals("admin")) + return "shopList4AdminAll"; + else + return "shopListSample"; + } + return "index_login"; + } + + public String productList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + // if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + if(pageNo==0){ + pageNo = 1; + } + if(pages!=null){ + pageNo = Integer.parseInt(pages.split("_")[1]); + } + if(typeId==null){ + typeId = ""; + } + if(keyword==null){ + keyword = ""; + } + + shopList = shopService.getShopListByUserId(user.getUserId(),false); + + if(shopId==null) { + if(shopService.isHasAuditSucceedShop(shopList)) + shopId=shopList.get(0).getShopId(); + else { + if(resultObj==null) { + resultObj = new ResultObj(); + } + resultObj.setCanNext(false); + resultObj.setCode(-2); + resultObj.setMsg("您名下还没有审核通过的商铺,继续操作前需要有审核通过的店铺。"); + return "shopListSample"; + } + } + + productTypeList = productTypeService.queryAllProductType(); + productBrandList = productTypeService.listByBrand(null); + Pagination datePage = null; + if(user.getUserName().equals("admin")) + datePage = productService.searchProduct(typeId,keyword, pageNo, pageSize); + else + datePage = productService.searchProductByShopId(shopId,typeId,keyword, pageNo, pageSize); + productList = (List) datePage.getList(); + resultCount = datePage.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/productList.action?typeId="+typeId+"&keyword="+keyword+"&pageNo="); + pageString = pageString.replace(".html", ""); + + if(user.getUserName().equals("admin")) + return "productList"; + else + return "productList4normalUser"; + } + return "index_index"; + } + + + + public String index2(){ + if(StringUtil.isNotBlank(forward)){ + forward = htmlFilter.filter(forward); + } + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + return "index"; + } + } + } + } + return "login_index"; + } + + public String index(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + if(pageNo==0){ + pageNo = 1; + } + if(pages!=null){ + pageNo = Integer.parseInt(pages.split("_")[1]); + } + + //add by lwgboy + if(id==null) + id="hot20"; + + if(id.equals("hot20")){ + + Pagination hotPage = null; + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + hotPage = spellbuyrecordService.ProductByTypeIdList(typeId,"", "hot", pageNo, pageSize); + else + hotPage = spellbuyrecordService.ProductByTypeIdListAndShopId(user.getShopId(),typeId,"", "hot", pageNo, pageSize); + + List HotList = (List) hotPage.getList(); + productJSONList = new ArrayList(); + for (int i = 0; i < HotList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) HotList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) HotList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(product.getSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSONList.add(productJSON); + } + resultCount = hotPage.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&type="+typeId+"&pageNo="); + pageString = pageString.replace(".html", ""); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&pageNo="); + pageString = pageString.replace(".html", ""); + } + return "spellbuyProductList"; + }else if(id.equals("date20")){ + + Pagination datePage = null ; + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + datePage = spellbuyrecordService.ProductByTypeIdList(typeId,"", "date", pageNo, pageSize); + else + datePage = spellbuyrecordService.ProductByTypeIdListAndShopId(user.getShopId(),typeId,"", "date", pageNo, pageSize); + + List dateList = (List) datePage.getList(); + productJSONList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) dateList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(product.getSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSONList.add(productJSON); + } + resultCount = datePage.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/shop/index.action?id="+id+"&type="+typeId+"&pageNo="); + pageString = pageString.replace(".html", ""); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/shop/index.action?id="+id+"&pageNo="); + pageString = pageString.replace(".html", ""); + } + return "spellbuyProductList"; + }else if(id.equals("price20")){ + + Pagination pricePage = null; + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + pricePage = spellbuyrecordService.ProductByTypeIdList(typeId,"", "price", pageNo, pageSize); + else + pricePage = spellbuyrecordService.ProductByTypeIdListAndShopId(user.getShopId(),typeId,"", "price", pageNo, pageSize); + + List priceList = (List) pricePage.getList(); + productJSONList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(product.getSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSONList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/shop/index.action?id="+id+"&type="+typeId+"&pageNo="); + pageString = pageString.replace(".html", ""); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/shop/index.action?id="+id+"&pageNo="); + pageString = pageString.replace(".html", ""); + } + return "spellbuyProductList"; + + }else if(id.equals("priceAsc20")){ + + Pagination pricePage = null; + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + pricePage = spellbuyrecordService.ProductByTypeIdList(typeId,"", "priceAsc", pageNo, pageSize); + else + pricePage = spellbuyrecordService.ProductByTypeIdListAndShopId(user.getShopId(),typeId,"", "priceAsc", pageNo, pageSize); + + List priceList = (List) pricePage.getList(); + productJSONList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(product.getSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSONList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/shop/index.action?id="+id+"&type="+typeId+"&pageNo="); + pageString = pageString.replace(".html", ""); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/shop/index.action?id="+id+"&pageNo="); + pageString = pageString.replace(".html", ""); + } + return "spellbuyProductList"; + } + } + return "index_login"; //没登陆时要先登录 + } + + /** + * 会员列表 + * @return + */ + public String userListAll(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + if(pageNo==0){ + pageNo = 1; + } + if(typeName==null){ + typeName = ""; + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + Pagination page = null; + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + page = userService.adminUserList(typeId,keyword,typeName,pageNo, pageSize); + else + page = userService.getColleaguesList(user.getUserId(), typeId,keyword,typeName,pageNo, pageSize); + + userList = (List) page.getList(); + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/shop/userListAll.action?typeName="+typeName+"&pageNo="); + pageString = pageString.replace(".html", ""); + return "userList"; + } + return "index_index"; + } + + public String toAddUser(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "login_index";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopService.isHasAuditSucceedShop(shopList)&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + return "toAddUser"; + } + + if(resultObj==null) { + resultObj = new ResultObj(); + } + resultObj.setCanNext(false); + resultObj.setCode(-3); + resultObj.setMsg("您名下还没有审核通过的商铺,添加成员前需要有审核通过的店铺才能进行。"); + return "shopListSample"; + } + + public String toUpdateUser(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),true); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + user = userService.findById(id); + return "toAddUser"; + } + return "index_index"; + } + + public void doUpdateUser(){ + boolean canNext = false; + User u = null; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + u= (User)Struts2Utils.getSession().getAttribute("admin"); + if(u.getUserName().equals("admin")) + canNext = true; + }else { + u = UserUtils.getLogonUserInfo(request, userService); + if(u==null) return ;//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(u.getUserId(),true); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + //if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(u.getShopId()==user.getShopId()){ //两者同一家公司 + userService.add(user); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + } + + public String doAddUser(){ + boolean canNext = false; + User ur = null; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + ur= (User)Struts2Utils.getSession().getAttribute("admin"); + if(ur.getUserName().equals("admin")) + canNext = true; + }else { + ur = UserUtils.getLogonUserInfo(request, userService); + if(ur==null) return "login_index";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(ur.getUserId(),true); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + // if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(canNext) { + if(ur.getShopId().intValue()==user.getShopId().intValue()) { + if(StringUtil.isNotBlank(user.getMail())){ + User u = userService.userByName(user.getMail()); + if(u!=null){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + } + if(StringUtil.isNotBlank(user.getPhone())){ + User u2 = userService.userByName(user.getPhone()); + if(u2!=null){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + } + if(user.getCommissionBalance()==null){ + user.setCommissionBalance(0.00); + } + if(user.getCommissionCount()==null){ + user.setCommissionCount(0.00); + } + if(user.getCommissionMention()==null){ + user.setCommissionMention(0.00); + } + if(user.getCommissionPoints()==null){ + user.setCommissionPoints(0); + } + if(user.getExperience()==null){ + user.setExperience(0); + } + if(user.getBalance()==null){ + user.setBalance(0.00); + } + String date = DateUtil.DateTimeToStr(new Date()); + user.setOldDate(date); + user.setFaceImg("/Images/defaultUserFace.png"); + userService.add(user); + return "addUserSuccess"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + + } + return "index_index"; + } + + /** + * 消费记录 + * @return + */ + public String consumeAllList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + startDate = DateUtil.DateToStr(DateUtil.addMonth(new Date(), -1)); + endDate = DateUtil.DateToStr(new Date()); + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + resultCount = consumetableService.userByConsumetableByCount(userId,startDate,endDate); + return "consumeAllList"; + } + + return "index_index"; + } + + + + //注册商铺 + public String registerShop() + { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "login_index"; //需要是已注册用户且必须登录后才能升级为机构用户 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + + if(imageType!=null) + { + if(imageType==1){//营业执照 + try { + uploadFile(imageType); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(imageType==2) {//身份证 + try { + uploadFile(imageType); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(imageType==3) {//公司logo + + }else if(imageType==5) {//注册公司并提交所有参数 + try { + save4Audit(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return null; + } + return "registerShop"; + } + + //注册商铺_简单风格界面 + public String registerShopStyleSimple() + { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "login_index"; //需要是已注册用户且必须登录后才能升级为机构用户 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + + if(imageType!=null) + { + if(imageType==1){//营业执照 + try { + uploadFile(imageType); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(imageType==2) {//身份证 + try { + uploadFile(imageType); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(imageType==3) {//公司logo + + }else if(imageType==5) {//注册公司并提交所有参数 + try { + save4Audit(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return null; + } + return "registerShopStyleSimple"; + } + + //更新商铺信息 + public String registerShopUpdate() + { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "login_index"; //需要是已注册用户且必须登录后才能升级为机构用户 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + + if(shopId!=null&&shopId.intValue()>0) + for(Shop s:shopList) + { + if(s.getShopId().equals(shopId)) + { + shop = s; + return "registerShopUpdate"; + } + } + return null; + } + + //订单列表 + public String orderList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + if(pageNo==0){ + pageNo = 1; + } + + Pagination page = null; + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + page = consumetableService.orderList(userName, pageNo, pageSize); + else + page = consumetableService.getUserAllShopOrderList(user.getUserId(), pageNo, pageSize); + + List list = (List) page.getList(); + orderBeanList = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + OrderBean orderBean = new OrderBean(); + Consumetable consumetable = list.get(i); + orderBean.setOutTradeNo(consumetable.getOutTradeNo()); + orderBean.setBuyCount(consumetable.getBuyCount()); + orderBean.setDate(consumetable.getDate()); + orderBean.setMoney(consumetable.getMoney()); + if(consumetable.getInterfaceType().equals("tenPay")){ + orderBean.setPayType("财付通"); + }else if(consumetable.getInterfaceType().equals("aliPay")){ + orderBean.setPayType("支付宝"); + }if(consumetable.getInterfaceType().equals("yeePay")){ + orderBean.setPayType("易宝支付"); + }else{ + orderBean.setPayType("余额支付"); + } + orderBean.setUserId(consumetable.getUserId()); + orderBeanList.add(orderBean); + } + resultCount = page.getResultCount(); + if(StringUtil.isNotBlank(userName)){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/orderList.action?userName="+userName+"&pageNo="); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/orderList.action?pageNo="); + } + pageString = pageString.replace(".html", ""); + return "orderList"; + } + + return "index_index"; + } + + //订单详情 + public String orderInfo(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + if(pageNo==0){ + pageNo = 1; + } + Pagination page = consumerdetailService.orderInfo(id, pageNo, pageSize); + List list = (List) page.getList(); + orderBeanList = new ArrayList(); + for (Consumerdetail consumerdetail : list) { + OrderBean orderBean = new OrderBean(); + orderBean.setBuyCount(consumerdetail.getBuyCount()); + orderBean.setMoney(consumerdetail.getBuyMoney()); + orderBean.setSpellBuyProductId(consumerdetail.getSpellBuyProductId()); + orderBean.setProductName(consumerdetail.getProductName()); + orderBean.setProductPeriod(consumerdetail.getProductPeriod()+""); + orderBeanList.add(orderBean); + } + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/orderInfo.action?pageNo="); + pageString = pageString.replace(".html", ""); + return "orderInfo"; + } + return "index_index"; + } + + + + + + + + + + + + + + + + + + + + + /** + * 选择日期查询得到拍购记录resultCount 总数 + */ + public void getuserBuyListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = spellbuyrecordService.buyHistoryByUserByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 拍购记录ajax分页请求 + * @return + */ + public String userBuyListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = spellbuyrecordService.buyHistoryByUser(userId,startDate,endDate, pageNo, 5); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + + for (int j = 0; j < dataList.size(); j++) { + try { + buyHistoryJSON = dataList.get(j); + if(buyHistoryJSON.getBuyStatus()==1){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(buyHistoryJSON.getProductId()).get(0); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUser(userer); + buyHistoryJSON.setWinUserId(latestlottery.getUserId()); + } + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 查看商品详情 + * @return + */ + public String UserBuyDetail(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + buyHistoryJSON = (BuyHistoryJSON) spellbuyrecordService.getBuyHistoryByDetail(id,userId).get(0); + if(buyHistoryJSON.getBuyStatus()==1){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(buyHistoryJSON.getProductId()).get(0); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setBuyTime(latestlottery.getBuyTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUser(userer); + buyHistoryJSON.setWinUserId(latestlottery.getUserId()); + } + resultCount = spellbuyrecordService.getRandomNumberListPageByCount(id,userId); + return "UserBuyDetail"; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "login_index"; + } + + /** + * 取得某条购买记录的拍购码(list 页) + */ + public void getRandomNumberList(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + List dataList = spellbuyrecordService.getRandomNumberList(id,userId); + randomNumberJSONList = new ArrayList(); + String numbers = ""; + for (Randomnumber randomnumber : dataList) { + String [] randoms = randomnumber.getRandomNumber().split(","); + for (String string : randoms) { + numbers += "
  • " +string+"
  • "; + } + } + Struts2Utils.renderText(numbers); + } + + /** + * 取得某条购买记录的拍购码(详细页面) + */ + public void getRandomNumberListPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = spellbuyrecordService.getRandomNumberListPage(id,userId, pageNo, 50); + List dataList = (List) datePage.getList(); + randomNumberJSONList = new ArrayList(); + for (Randomnumber randomnumber : dataList) { + try { + randomNumberJSON = new RandomNumberJSON(); + String [] randoms = randomnumber.getRandomNumber().split(","); + String numbers = ""; + for (String string : randoms) { + numbers += "" +string+""; + } + randomNumberJSON.setRandomNumbers(numbers); + randomNumberJSON.setBuyCount(String.valueOf(randoms.length)); + randomNumberJSON.setBuyDate(randomnumber.getBuyDate()); + randomNumberJSONList.add(randomNumberJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.renderJson(randomNumberJSONList); + } + + /** + * 获得的商品 + * @return + */ + public String OrderList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = latestlotteryService.getProductByUserByCount(userId,startDate,endDate); + return "OrderList"; + } + } + } + } + return "login_index"; + } + + /** + * 获得的商品AJAX分页 + * @return + */ + public String OrderListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = latestlotteryService.getProductByUser(userId,startDate,endDate, pageNo, 5); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + for (int j = 0; j < dataList.size(); j++) { + try { + buyHistoryJSON = new BuyHistoryJSON(); + latestlottery = dataList.get(j); + buyHistoryJSON.setProductName(latestlottery.getProductName()); + buyHistoryJSON.setProductTitle(latestlottery.getProductTitle()); + buyHistoryJSON.setProductImg(latestlottery.getProductImg()); + buyHistoryJSON.setProductId(latestlottery.getSpellbuyProductId()); + buyHistoryJSON.setProductPrice(latestlottery.getProductPrice()); + buyHistoryJSON.setProductPeriod(latestlottery.getProductPeriod()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setBuyTime(latestlottery.getBuyTime()); + buyHistoryJSON.setBuyStatus(latestlottery.getStatus()); + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 选择日期查询得到获得的商品resultCount 总数 + */ + public void OrderListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = latestlotteryService.getProductByUserByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 获取的商品详情 + * @return + */ + public String OrderDetail(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + latestlottery = latestlotteryService.findById(id); + if(latestlottery.getStatus()==1){ + userbyaddressList = userService.getUserbyaddress(userId); + sProvinceList = regionService.getProvinceList(); + }else{ + orderdetailList = latestlotteryService.orderDetailListById(id); + orderDetailAddress = latestlotteryService.orderDetailAddressFindByOrderDetailId(id); + } + return "OrderDetail"; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "login_index"; + } + + /** + * 获取的商品详情-确认收货地址 + * @return + */ + public void OrderDetailAddAddress(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + JSONObject object = JSONObject.fromObject(userJSON); + String orderRemarks = object.getString("orderRemarks"); + String postDate = object.getString("postDate"); + String hidOrderNO = object.getString("hidOrderNO"); + id = object.getString("id"); + userbyaddress = userService.findAddressById(Integer.parseInt(id)); + orderDetailAddress = new OrderDetailAddress(); + orderDetailAddress.setAddress(userbyaddress.getProvince()+" "+userbyaddress.getCity()+" "+userbyaddress.getDistrict()+" "+userbyaddress.getAddress()); + orderDetailAddress.setConsignee(userbyaddress.getConsignee()); + orderDetailAddress.setOrderRemarks(orderRemarks);//订单备注 + orderDetailAddress.setPostDate(postDate);//配送时间 + orderDetailAddress.setPhone(userbyaddress.getPhone()); + orderDetailAddress.setOrderDetailId(Integer.parseInt(hidOrderNO)); + latestlotteryService.addOrderDetailAddress(orderDetailAddress); + orderdetail = new Orderdetail(); + orderdetail.setDate(DateUtil.DateTimeToStr(new Date())); + orderdetail.setDetailText("会员已确认配送地址信息,等待商城发货"); + orderdetail.setOrderDetailId(Integer.parseInt(hidOrderNO)); + orderdetail.setUserName("会员本人"); + orderdetailService.add(orderdetail); + latestlottery = latestlotteryService.findById(hidOrderNO); + latestlottery.setStatus(2); + latestlotteryService.add(latestlottery); + Struts2Utils.renderText("success"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + /** + * 获取的商品详情-确认收到货物 + * @return + */ + public void confirmOrderDetail(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + latestlottery = latestlotteryService.findById(id); + latestlottery.setStatus(4); + latestlottery.setShareStatus(-1); + latestlotteryService.add(latestlottery); + orderdetail = new Orderdetail(); + orderdetail.setDate(DateUtil.DateTimeToStr(new Date())); + orderdetail.setDetailText("会员已确认收到商品。"); + orderdetail.setOrderDetailId(latestlottery.getSpellbuyProductId()); + orderdetail.setUserName("会员本人"); + orderdetailService.add(orderdetail); + Struts2Utils.renderText("success"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + public String PostSingleAdd(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + try { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + + return "PostSingleAdd"; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return "login_index"; + } + + /** + * 我的晒单 + * @return + */ + public String PostSingleList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); +// Pagination datePage = shareService.shareByUser(userId,startDate,endDate, pageNo, 5); +// resultCount = datePage.getResultCount(); + return "PostSingleList"; + } + } + } + } + return "login_index"; + } + + /** + * 我的晒单分页AJAX + * @return + */ + public String PostSingleListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = shareService.shareByUser(userId,startDate,endDate, pageNo, 5); + List pageList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + for (int j = 0; j < pageList.size(); j++) { + try { + buyHistoryJSON = new BuyHistoryJSON(); + latestlottery = pageList.get(j); + buyHistoryJSON.setProductName(latestlottery.getProductName()); + buyHistoryJSON.setProductTitle(latestlottery.getProductTitle()); + buyHistoryJSON.setProductImg(latestlottery.getProductImg()); + buyHistoryJSON.setProductId(latestlottery.getProductId()); + buyHistoryJSON.setProductPeriod(latestlottery.getProductPeriod()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setBuyTime(latestlottery.getBuyTime()); + buyHistoryJSON.setBuyStatus(latestlottery.getShareStatus()); + buyHistoryJSON.setWinUserId(latestlottery.getShareId()); + buyHistoryJSON.setHistoryId(latestlottery.getId()); + buyHistoryJSONList.add(buyHistoryJSON); + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.renderJson(buyHistoryJSONList); + return null; + } + + /** + * 选择日期查询得到我的晒单resultCount 总数 + */ + public void PostSingleListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = shareService.shareByUser(userId,startDate,endDate, pageNo, 5); + resultCount = datePage.getResultCount(); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 邀请好友 + * @return + */ + public String InvitedList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = userService.getInvitedListByCount(userId); + userList = userService.getInvitedListByData(userId); + for (User user : userList) { + if(user.getExperience()>0){ + w++; + h+=50; + } + } + return "InvitedList"; + } + } + } + } + return "login_index"; + } + + /** + * 邀请好友分页AJAX + * @return + */ + public String InvitedListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = userService.getInvitedList(userId, pageNo, pageSize); + userList = (List) datePage.getList(); + for (User user : userList) { + user.setUserName(UserNameUtil.userName(user)); + } + Struts2Utils.renderJson(userList); + return null; + } + + /** + * 佣金明细 + * @return + */ + public String CommissionQuery(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = commissionqueryService.getCommissionQueryListByCount(userId, startDate, endDate); + return "CommissionQuery"; + } + } + } + } + return "login_index"; + } + + /** + * 佣金明细 AJAX + * @return + */ + public String CommissionQueryAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = commissionqueryService.getCommissionQueryList(userId, startDate, endDate, pageNo, pageSize); + List dateList = (List) datePage.getList(); + if(dateList.size()>0){ + commissionqueryJSONList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + commissionqueryJSON = new CommissionqueryJSON(); + user = (User) dateList.get(i)[0]; + commissionquery = (Commissionquery) dateList.get(i)[1]; + commissionqueryJSON.setBuyMoney(commissionquery.getBuyMoney()); + commissionqueryJSON.setCommission(commissionquery.getCommission()); + commissionqueryJSON.setDate(commissionquery.getDate()); + commissionqueryJSON.setDescription(commissionquery.getDescription()); + commissionqueryJSON.setUserId(String.valueOf(user.getUserId())); + commissionqueryJSON.setUserName(UserNameUtil.userName(user)); + commissionqueryJSONList.add(commissionqueryJSON); + } + } + Struts2Utils.renderJson(commissionqueryJSONList); + return null; + } + + /** + * 佣金明细 AJAX ByCount + */ + public void getCommissionQueryAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = commissionqueryService.getCommissionQueryListByCount(userId, startDate, endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 我的福分 + * @return + */ + public String MemberPoints(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = commissionpointsService.getCommissionPointsListByCount(userId, startDate, endDate); + return "CommissionPoints"; + } + } + } + } + return "login_index"; + } + + /** + * 福分明细 AJAX + * @return + */ + public String CommissionPointsAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Pagination datePage = commissionpointsService.CommissionPoints(userId, startDate, endDate, pageNo, pageSize); + commissionpointsList = (List) datePage.getList(); + Struts2Utils.renderJson(commissionpointsList); + return null; + } + + /** + * 提现申请 + * @return + */ + public String ApplyMention(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "ApplyMention"; + } + } + } + } + return "login_index"; + } + + /** + * 提现申请 ADD + */ + public void ApplyMentionAdd(){ + try { + JSONObject object = JSONObject.fromObject(userJSON); + userId = object.getString("userId"); + user = userService.findById(userId); + double money = Double.parseDouble(object.getString("money")); + double commissionBalance = user.getCommissionBalance(); + double commissionMention = user.getCommissionMention(); + if(commissionBalance dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * 提现记录 AJAX ByCount + */ + public void getMentionListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = applymentionService.getApplymentionListByCount(userId, startDate, endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 网银充值 + * @return + */ + public String UserRecharge(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "UserRecharge"; + } + } + } + } + return "login_index"; + } + + /** + * 卡密充值 + * @return + */ + public String userCardRecharge(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "userCardRecharge"; + } + } + } + } + return "login_index"; + } + + public void doCardRecharge(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + try { + String randomNo = id.substring(0,32); + String cardPwd = id.substring(32,id.length()); + Cardpassword cardpassword = cardpasswordService.doCardRecharge(randomNo, cardPwd); + if(cardpassword!=null){ + Double temp = user.getBalance(); + cardpasswordService.deleteByID(cardpassword.getId()); + user.setBalance(temp+cardpassword.getMoney()); + userService.add(user); + Consumetable consumetable = new Consumetable(); + consumetable.setBuyCount(Integer.parseInt(new java.text.DecimalFormat("0").format(cardpassword.getMoney()))); + consumetable.setDate(DateUtil.DateTimeToStr(new Date())); + consumetable.setInterfaceType("卡密冲值"); + consumetable.setMoney(cardpassword.getMoney()); + consumetable.setOutTradeNo(""); + String s = UUID.randomUUID().toString().toUpperCase(); + s = s.substring(0,8)+s.substring(9,13)+s.substring(14,18)+s.substring(19,23)+s.substring(24); + consumetable.setTransactionId(s); + consumetable.setUserId(Integer.parseInt(userId)); + consumetableService.add(consumetable); + Struts2Utils.renderText("yes"); + }else{ + Struts2Utils.renderText("no"); + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("no"); + } + } + } + } + } + } + + /** + * 账户明细 + * @return + */ + public String UserBalance(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + return "UserBalance"; + } + } + } + } + return "login_index"; + } + + /** + * 消费记录 + * @return + */ + public String ConsumeList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = consumetableService.userByConsumetableByCount(userId,startDate,endDate); + return "ConsumeList"; + } + } + } + } + return "login_index"; + } + + /*** + * 消费记录分页 + * @return + */ + public String ConsumeListAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = consumetableService.userByConsumetable(userId,startDate,endDate, pageNo, pageSize); + List dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * 选择日期查询得到消费记录resultCount 总数 + */ + public void ConsumeListAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = consumetableService.userByConsumetableByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + + /** + * 充值记录 + * @return + */ + public String RechargeList(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + return "RechargeList"; + } + } + } + } + return "login_index"; + } + + /*** + * 充值记录分页 + * @return + */ + public String ConsumeListByDeltaAjaxPage(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + Pagination datePage = consumetableService.userByConsumetableByDelta(userId,startDate,endDate, pageNo, pageSize); + List dataList = (List) datePage.getList(); + Struts2Utils.renderJson(dataList); + return null; + } + + /** + * 选择日期查询得到充值记录resultCount 总数 + */ + public void ConsumeListByDeltaAjaxPageResultCount(){ + if(pageNo==0){ + pageNo = 1; + }else{ + pageNo +=1; + } + Date date = new Date(); + if(StringUtil.isNotBlank(selectTime)){ + if(selectTime.equals("0")){ + startDate = null; + endDate = null; + }else if(selectTime.equals("1")){ + startDate = DateUtil.DateToStr(date)+" 00:00:00"; + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + }else if(selectTime.equals("2")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -7))+" 00:00:00"; + }else if(selectTime.equals("3")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -30))+" 00:00:00"; + }else if(selectTime.equals("4")){ + endDate = DateUtil.DateToStr(date)+" 23:59:59"; + startDate = DateUtil.DateToStr(DateUtil.addDate(date, -90))+" 00:00:00"; + } + }else{ + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + } + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + Struts2Utils.renderText(resultCount+""); + } + + /** + * 收货地址 + * @return + */ + public String Address(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "Address"; + } + } + } + } + return "login_index"; + } + + public void getAddressList(){ + userbyaddressList = userService.getUserbyaddress(userId); + Struts2Utils.renderJson(userbyaddressList); + } + + /** + * 添加新收新地址 + * @return + */ + public String addAddress(){ + try { + JSONObject object = JSONObject.fromObject(userJSON); + int userId = object.getInt("userId"); + userbyaddressList = userService.getUserbyaddress(userId+""); + if(userbyaddressList.size()<4){ + String province = object.getString("province"); + String city = object.getString("city"); + String district = object.getString("district"); + String address = object.getString("address"); + int zipCode = object.getInt("zipCode"); + String consignee = object.getString("consignee"); + String phone = object.getString("phone"); + userbyaddress = new Userbyaddress(); + userbyaddress.setAddress(address); + userbyaddress.setCity(city); + userbyaddress.setConsignee(consignee); + userbyaddress.setDistrict(district); + userbyaddress.setPhone(phone); + userbyaddress.setProvince(province); + userbyaddress.setStatus(1); + userbyaddress.setUserId(userId); + userbyaddress.setZipCode(zipCode); + userService.addAddress(userbyaddress); + if(userbyaddress.getId()!=null){ + userService.setDefaultAddress(String.valueOf(userId),userbyaddress.getId()); + } + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("sizeError"); + } + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + return null; + } + + /** + * 设置默认收货地址 + */ + public void setDefaultAddress(){ + try { + userService.defaultAddress(userId,Integer.parseInt(id)); + userService.setDefaultAddress(String.valueOf(userId),Integer.parseInt(id)); + Struts2Utils.renderText("success"); + } catch (Exception e) { + Struts2Utils.renderText("false"); + e.printStackTrace(); + } + } + + /** + * 删除收货地址 + */ + public void delAddress(){ + try { + userService.delAddress(Integer.parseInt(id)); + Struts2Utils.renderText("success"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + + } + + /** + * 省 + */ + public void getProvinceList(){ + sProvinceList = regionService.getProvinceList(); + Struts2Utils.renderJson(sProvinceList); + } + + /** + * 市 + */ + public void getCityList(){ + sCityList = regionService.getCityListByProvinceId(id); + Struts2Utils.renderJson(sCityList); + } + + /** + * 区 + */ + public void getDistrictList(){ + sDistrictList = regionService.getDistrictListByCityId(id); + Struts2Utils.renderJson(sDistrictList); + } + + + /** + * 编辑个人资料 + * @return + */ + public String MemberModify(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "MemberModify"; + } + } + } + } + return "login_index"; + } + + + /** + * 修改用户资料 + */ + public void updateUser(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + if(user!=null){ + try { + JSONObject object = JSONObject.fromObject(userJSON); + if(user.getUserName()==null){ + Integer m = user.getCommissionPoints(); + m += ApplicationListenerImpl.sysConfigureJson.getUserData(); + user.setCommissionPoints(m); + } + user.setUserName(object.getString("userName")); + String mobilePhone = object.getString("mobilePhone"); + if(!mobilePhone.equals("undefined") && !mobilePhone.equals("")){ + user.setMobilePhone(mobilePhone); + } + String phone = object.getString("phone"); + if(!phone.equals("undefined") && !phone.equals("")){ + user.setPhone(phone); + } + String mail = object.getString("mail"); + if(!mail.equals("undefined") && !mail.equals("")){ + user.setMail(mail); + } + String qq = object.getString("qq"); + if(!qq.equals("undefined") && !qq.equals("")){ + user.setQq(qq); + } + String userSign = object.getString("userSign"); + if(!userSign.equals("undefined") && !userSign.equals("")){ + user.setSignature(userSign); + } + userService.add(user); + Struts2Utils.renderJson(user); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + }else{ + Struts2Utils.renderText("false"); + } + } + } + } + } + } + + /** + * 用户昵称是否存在 + */ + public void isUserNameExists(){ + User user = userService.isUserName(id,userId); + if(user==null) + Struts2Utils.renderText("true"); + else + Struts2Utils.renderText("false"); + } + + /** + * 修改头像 + * @return + */ + public String UserPhoto(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "UserPhoto"; + } + } + } + } + return "login_index"; + } + + + /** + * 上传证照文件 + * @fileType 证照文件类型:1营业执照,2身份证,3公司logo + * @return + * @throws Exception + */ + public String uploadFile(Integer fileType) throws Exception{ + try { + if(fileType==1) { + filename=credentialsPhotoFileFileName.substring(credentialsPhotoFileFileName.lastIndexOf("."), credentialsPhotoFileFileName.length()); + myFile = credentialsPhotoFile; + } + else + if(fileType==2) { + filename=cardIdPhotoFileFileName.substring(cardIdPhotoFileFileName.lastIndexOf("."), cardIdPhotoFileFileName.length()); + myFile = cardIdPhotoFile; + } + imageFileName = userId+"_" +fileType+"_" +new Date().getTime()+ filename; + String filePath = ServletActionContext.getServletContext().getRealPath(UploadImageDir)+"/" + imageFileName; + if(myFile!=null){ + UploadFileInfo fi = new UploadFileInfo(); + long len = myFile.length(); + if(len>1024*1024*1024) { //文件大小<1M + fi.size = (int)(len/1024/1024); //转换为KB + fi.info = "照片尺寸过大,须小于1M!"; + }else { + File imageFile = new File(filePath); + copy(myFile, imageFile); + fi.setFilePath(UploadImageDir+"/"+imageFileName); + fi.setFileType(fileType); + } + JSONObject json = JSONObject.fromObject(fi); + Struts2Utils.renderText(json.toString()); //IE 浏览器遇到 json 格式的有时会提示下载,因此改成 String 格式传回去。 + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + //文件上传之從臨時拷貝到目的地 + private static void copy(File src, File dst) { + try { + InputStream in = null ; + OutputStream out = null ; + try { + in = new BufferedInputStream( new FileInputStream(src), BUFFER_SIZE); + out = new BufferedOutputStream( new FileOutputStream(dst), BUFFER_SIZE); + byte [] buffer = new byte [BUFFER_SIZE]; + while (in.read(buffer) > 0 ) { + out.write(buffer); + } + } finally { + if ( null != in) { + in.close(); + } + if ( null != out) { + out.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + + /** + * 保存註冊信息等待审核 + * @throws IOException + */ + public void save4Audit() throws IOException{ + if(request==null)request = Struts2Utils.getRequest(); + if(response==null)response = Struts2Utils.getResponse(); + + String fileSeparator= System.getProperty("file.separator"); + + hidCredentialsPhotoUrl = hidCredentialsPhotoUrl.replace("/", "\\"); + hidCredentialsPhotoUrl = hidCredentialsPhotoUrl.substring(hidCredentialsPhotoUrl.lastIndexOf("\\")+1, hidCredentialsPhotoUrl.length()); + + hidCardIdPhotoUrl = hidCardIdPhotoUrl.replace("/", "\\"); + hidCardIdPhotoUrl = hidCardIdPhotoUrl.substring(hidCardIdPhotoUrl.lastIndexOf("\\")+1, hidCardIdPhotoUrl.length()); + + String uploadFileName = ServletActionContext.getServletContext().getRealPath(UploadImageDir)+fileSeparator + hidCredentialsPhotoUrl; + String shopFileName = ServletActionContext.getServletContext().getRealPath(ShopImageDir)+fileSeparator + hidCredentialsPhotoUrl; + try { + boolean isMoved = FileIOUtil.moveFile(uploadFileName, shopFileName); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + uploadFileName = ServletActionContext.getServletContext().getRealPath(UploadImageDir)+fileSeparator+ hidCardIdPhotoUrl; + shopFileName = ServletActionContext.getServletContext().getRealPath(ShopImageDir)+fileSeparator + hidCardIdPhotoUrl; + + + try { + boolean isMoved = FileIOUtil.moveFile(uploadFileName, shopFileName); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + try { + //CutImages cutImages = new CutImages(x1,y1,w,h,fileName,faceName); + //cutImages.cut(); + //hidCredentialsPhotoUrl = hidCredentialsPhotoUrl.substring(hidCredentialsPhotoUrl.lastIndexOf("ROOT")+4,hidCredentialsPhotoUrl.length()).replace("\\", "/"); + //hidCardIdPhotoUrl = hidCardIdPhotoUrl.substring(hidCardIdPhotoUrl.lastIndexOf("ROOT")+4,hidCardIdPhotoUrl.length()).replace("\\", "/"); + + hidCredentialsPhotoUrl = ShopImageDir+"/" + hidCredentialsPhotoUrl; + hidCardIdPhotoUrl = ShopImageDir+"/" + hidCardIdPhotoUrl; + + if(shop==null) + shop = new Shop(); + + if(shopId!=null) //更新商铺信息时 + shop.setShopId(shopId); + + shop.setCredentialsPhoto(hidCredentialsPhotoUrl); + shop.setLegalPhoto(hidCardIdPhotoUrl); + shop.setAlipay(this.alipay); + shop.setCity(this.city); + shop.setCompanyName(this.companyName); + shop.setCountry("中国"); + shop.setCounty(this.county); + shop.setCreateTime(new Timestamp(new Date().getTime())); + shop.setCredentialsPhoto(this.hidCredentialsPhotoUrl); + shop.setCredentialsType(this.credentialsType); + shop.setLegalPhoto(this.hidCardIdPhotoUrl); + shop.setLegalRepresentativeId(this.legalRepresentativeId); + shop.setLegalRepresentativeName(this.legalRepresentativeName); + shop.setLogo(""); + shop.setManagerName(this.managerName); + shop.setManagerPhone(this.managerPhone); + shop.setManngerTitle(this.manngerTitle); + shop.setOriginatorId(Integer.parseInt(this.userId)); + shop.setPayChannel(this.payChannel); + shop.setProvince(this.province); + shop.setQq(this.qq); + shop.setQqGroup(""); + shop.setRegisterMoney(null); + shop.setServicePhone(this.servicePhone); + shop.setShopAddress(this.address); + //shop.setShopId(null); + shop.setShopName(this.shopName); + shop.setShopParentId(null); + shop.setShopType(null); + shop.setStatus((short)0); + shop.setStar((short)0); + shop.setSynopsis(this.synopsis); + shop.setTengpay(this.tengpay); + shop.setUpdateTime(new Timestamp(new Date().getTime())); + shop.setWeixin(this.weixin); + shop.setWeixinPublic(this.weixinPublic); + shop.setX(this.x); + shop.setY(this.y); + shopService.add(shop); + + /* + Cookie cookie3 = new Cookie("face",URLEncoder.encode(user.getFaceImg(), "UTF-8")); + cookie3.setMaxAge(-1); + cookie3.setPath("/"); + cookie3.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie3); + */ + Struts2Utils.renderText("success"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + } + + public String registershopsteptwo() { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "login_index"; //需要是已注册用户且必须登录后才能升级为机构用户 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + for(Shop shop : shopList) { + if(shop.getStatus()==0||shop.getStatus()==2) { + return "registerShopStep2"; + } + } + return "registerShopStep3"; + } + + public String registershopstepthree() { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "login_index"; //需要是已注册用户且必须登录后才能升级为机构用户 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + return "registerShopStep3"; + } + + + /** + * 上传图像 + * @throws IOException + */ + public void updateFace() throws IOException{ + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + hidPicUrl = hidPicUrl.replace("/", "\\"); + hidPicUrl = hidPicUrl.substring(hidPicUrl.lastIndexOf("\\")+1, hidPicUrl.length()); + String fileName = ServletActionContext.getServletContext().getRealPath("uploadImages")+"/" + hidPicUrl; + String faceName = ServletActionContext.getServletContext().getRealPath("faceImages")+"/" + hidPicUrl; + try { + CutImages cutImages = new CutImages(x1,y1,w,h,fileName,faceName); + cutImages.cut(); + faceName = faceName.substring(faceName.lastIndexOf("ROOT")+4,faceName.length()).replace("\\", "/"); + user = userService.findById(userId); + user.setFaceImg(faceName); + userService.add(user); + Cookie cookie3 = new Cookie("face",URLEncoder.encode(user.getFaceImg(), "UTF-8")); + cookie3.setMaxAge(-1); + cookie3.setPath("/"); + cookie3.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie3); + Struts2Utils.renderText("success"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + } + + /** + * 修改密码 + * @return + */ + public String UpdatePassWord(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + return "UpdatePassWord"; + } + } + } + } + return "login_index"; + } + + /** + * 修改密码 + */ + public void updatePwd(){ + if(StringUtil.isNotBlank(userId)){ + try { + user = userService.findById(userId); + if(user!=null){ + if(!user.getUserPwd().equals(id)){ + Struts2Utils.renderText("pwdError"); + }else{ + user.setUserPwd(userJSON); + userService.add(user); + Struts2Utils.renderText("success"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + //lwgoby add + //用户是否已关注,用于 bottom.js 中的 ajax调用 /user/hasCollectGoods.action + /** + * 用户未登录时,无法进行关注,右侧工具条关注提示为空,需要登录。 + * 用户未登录时,固定返回10,用于在 bottom.js 显示右侧关注工具条时是否提示用户登录用。 + * 用户登录后,固定返回0,用于提示已登录,用户一点关注某一商品,则会将相关数据存于 数据库中,用户下次登录还可以看到自己曾经关注过的商品 + */ + public String hasCollectGoods(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + if(user!=null){ + Struts2Utils.renderText("0"); //成功登录的用户暂且固定输出0; + return null; + } + } + } + } + } + Struts2Utils.renderText("10"); //未登录的用户固定输出10 供 bottom.js 中做比较 + return null; + } + + /** + * @Author lwgboy + * 检查用户名是否已经注册 + * @return + */ + public String isCheckName(){ + boolean isExist = false; + user = userService.userByName(userName); + if(user==null) + Struts2Utils.renderText("true"); + else + Struts2Utils.renderText("false"); + return null; + } + + /** + * 修改Email页面 + * @return + */ + public String EmailChecking(){ + user = getUserFromCookie(); + if(user!=null) + return "EmailChecking"; + else + return null; + } + + /** + * copy form RegisterAction.java 的 SendRegisterMail() + * @param mail 要重新发送验证邮件的目的邮箱地址 + */ + public void SendRegisterMail(String userId,String mail){ + //System.err.println("mail:"+mail); + //只采用日期部分生成加密串,便于memcache 无效时直接验证,但有安全隐患。 + //key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.DateToStr(new Date(),"yyyyMMdd"))+Base64.getEncode(mail); + key = MD5Util.encode(mail)+MD5Util.encode(DateUtil.dateTimeToStr(new Date()))+Base64.getEncode(mail+"|"+userId+"|"+DateUtil.DateToStr(new Date(),"yyyyMMdd")); + + //将激活 key 存入数据库供后续的 emailok 验证 + //userService.updateKey(mail, key); //用后面发送邮件成功后的 user.setKey(key) 替代,因此注释掉。 + + String html = ""+ + ""+ + ""+ + ""+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    首页"+ + "我的"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"帮助
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    亲爱的 "+mail+"

    您好!感谢您注册"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"。

    请点击下面的按钮,完成邮箱验证。

    邮箱验证
    如果上面按钮不能点击或点击后没有反应,您还可以将以下链接复制到浏览器地址栏中访问完成验证。
    "+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/user/EmailReturnSuccess.html?key="+key+"
    "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "
    此邮件由系统自动发出,请勿回复!
    感谢您对"+ApplicationListenerImpl.sysConfigureJson.getSiteName()+"("+ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+")的支持,祝您好运!
    客服热线:"+ApplicationListenerImpl.sysConfigureJson.getServiceTel()+"
    "+ + "
    "+ + ""+ + ""+ + ""+ + ""+ + "
    "+ApplicationListenerImpl.sysConfigureJson.getDomain()+" "+ApplicationListenerImpl.sysConfigureJson.getIcp()+"
    "; + if(MemCachedClientHelp.getIMemcachedCache().get(MD5Util.encode(mail+"|"+userId))==null){ + //user = userService.userByName(mail); + user = getUserFromCookie(); + if(user!=null){ + logger.info("SendRegisterMail("+mail+"): user.getMail()="+user.getMail()+",user.getMailCheck()="+user.getMailCheck()); + if(user.getMail()!=null&&user.getMail().equals(mail)&&user.getMailCheck()!=null&&user.getMailCheck().equals("0")){ //如果当前用户的邮箱地址等于提交过来邮件地址,并且邮箱验证已通过的话 + Struts2Utils.renderText("0"); + }else{ + try { + boolean flag = EmailUtil.sendEmail(ApplicationListenerImpl.sysConfigureJson.getMailName(), ApplicationListenerImpl.sysConfigureJson.getMailPwd(), mail, ApplicationListenerImpl.sysConfigureJson.getSiteName()+"验证注册邮箱", html); + if(flag){ + user.setMailCheck("1"); + user.setMailKey(key); //保存key 到数据库,便于memcache 没启动时也能完成验证 + userService.add(user); + if(MemCachedClientHelp.getIMemcachedCache()!=null) + try{ + MemCachedClientHelp.getIMemcachedCache().put(MD5Util.encode(mail+"|"+userId), mail+"|"+userId,new Date(10*60*1000)); + }catch (Exception e) { + e.printStackTrace(); + } + Struts2Utils.renderText("0"); + }else{ + Struts2Utils.renderText("false"); + } + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("false"); + } + } + } + }else{ + user = userService.userByName(mail); + if(user!=null){ + if(user.getMailCheck().equals("1")){ + Struts2Utils.renderText("3"); + }else if(user.getMailCheck().equals("0")){ + Struts2Utils.renderText("0"); + } + } + } + } + + /** + * 发送验证 Email 页面 ,供 /js/emailchecking.js 中 ajax调用 http://www.ipdz.me.com/user/EmailSending.html?userJSON=45201816@qq.com + * @return http://www.ipdz.me.com/user/EmailSendSuccess.html?userJSON=45201816@qq.com + */ + public void EmailSending(){ + if(StringUtils.isNoneEmpty(userJSON)){ + user = this.getUserFromCookie(); + if(user!=null) + SendRegisterMail(user.getUserId().toString(),userJSON); + } + } + + /** + * 发送验证 Email 成功后的页面,供 /js/emailchecking.js 中 ajax + * @return + */ + public String EmailSendSuccess(){ + user = this.getUserFromCookie(); + return "EmailSendSuccess"; + } + + /** + * 重新发送验证邮箱后,再次进行邮箱验证 + * @return + */ + public String EmailReturnSuccess() throws UnsupportedEncodingException { + request = Struts2Utils.getRequest(); + response = Struts2Utils.getResponse(); + String mail=""; + String isVerify=""; + if(StringUtil.isNotBlank(key)){ + String key_mail_date_str = key.substring(64,key.length()); + String [] keyStr = Base64.getDecode(key_mail_date_str).split("\\|"); + if(keyStr.length==3) + { + mail = keyStr[0]; + userId = keyStr[1]; + Date date = DateUtil.StrToDate(keyStr[2], "yyyyMMdd"); + if(DateUtil.addDate(new Date(), -1).before(date)&& StringUtil.isNotBlank(mail)&&StringUtil.isNotBlank(userId)) + { + user = userService.findById(userId); + if(MemCachedClientHelp.getIMemcachedCache().get(MD5Util.encode(mail+"|"+userId))!=null || (user!=null&&user.getMailKey().equals(key))) + { + if(user.getMailCheck()==null||(!user.getMailCheck().equals("0"))){ + user.setMail(mail); + user.setMailCheck("0"); + user.setMailKey("") ; //清空保存的用于激活的key + userService.add(user); + isVerify = "0"; + if(request.isRequestedSessionIdFromCookie()){ + Cookie cookie = new Cookie("mail",user.getMail()); + cookie.setMaxAge(-1); + cookie.setPath("/"); + cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie); + Cookie cookie2 = new Cookie("userId",String.valueOf(user.getUserId())); + cookie2.setMaxAge(-1); + cookie2.setPath("/"); + cookie2.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie2); + Cookie cookie3 = new Cookie("face",URLEncoder.encode(user.getFaceImg(), "UTF-8")); + cookie3.setMaxAge(-1); + cookie3.setPath("/"); + cookie3.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); + response.addCookie(cookie3); + } + }else{ + //说明已验证过没必要再次验证,置为验证码已失效状态 + isVerify = "1"; + } + }else{ + isVerify = "1"; + } + }else{ + isVerify = "1"; + } + }else{ + isVerify="1"; + } + } + else + isVerify="1"; + + if(isVerify.equals("0")) + return "EmailReturnSuccess"; + else + return null; + } + + /** + * 修改手机号页面 + * @return + */ + public String MobileChecking(){ + user = getUserFromCookie(); + if(user!=null) + return "MobileChecking"; + else + return null; + } + + /** + * 验证手机号后返回,用于 mobilechecking.js 的 e() 调用ajax 时使用 + * @author lwgboy + * @return + */ + public String MobileReturn(){ + String userJSON=Struts2Utils.getParameter("userJSON"); + String id=Struts2Utils.getParameter("id"); + if(userJSON.matches("^1[0-9]{10}$")) + { + if(user==null) + user = getUserFromCookie(); + if(user!=null){ + user.setPhone(userJSON); + user.setMobileCheck("0"); //设定手机为已验证状态; + userService.add(user); //更新用户的手机号 + } + Struts2Utils.renderText("0"); + }else + Struts2Utils.renderText("-1"); + return null; + } + + /** + * 更改手机号成功后返回页面 + * @author lwgboy + * @return + */ + public String MobileReturnSuccess(){ + return "MobileReturnSuccess"; + } + + public User getUserFromCookie(){ + request = Struts2Utils.getRequest(); + Cookie[] cookies = request.getCookies(); + if(request.isRequestedSessionIdFromCookie()){ + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + if(cookie.getName().equals("userId")){ + userId = cookie.getValue(); + if(userId!=null && !userId.equals("")){ + user = userService.findById(userId); + } + break; + } + } + } + return user; + } + + //转到新添加商品页面 + public String toAddProduct(){ + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "login_index"; //需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopService.isHasAuditSucceedShop(shopList)){ //名下必须有店铺才能进入商品添加页 + shopList = shopService.getAuditSucceedShop(shopList); + productTypeList = productTypeService.queryAllProductType(); + productBrandList = productTypeService.listByBrand(null); + return "addProduct"; + } + + if(resultObj==null) { + resultObj = new ResultObj(); + } + resultObj.setCanNext(false); + resultObj.setCode(-1); + resultObj.setMsg("您名下还没有审核通过的商铺,添加产品前需要有审核通过的店铺才能进行。"); + return "shopListSample"; //没有有效店铺时,转向提示页 + } + + + /** + * 新增商品 + * @return + * @throws Exception + */ + public String addProduct() throws Exception{ + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "login_index"; //需要是已注册用户且必须登录后才能升级为机构用户 + shopList = shopService.getShopListByUserId(user.getUserId(),true); //必须是有审核通过的商铺 + if(shopList!=null&&shopList.size()>0){ + String productImgPath = "/productImg/show"; + productService.add(product); + try { + if(myFile!=null){ + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + imageFileName = new Date().getTime()+ myFileFileName; + File imageFile = new File(UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/", String.valueOf(product.getProductId()))+"/" + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(200, 200, imageFile, imageFile); + product.setHeadImage(productImgPath+"/"+String.valueOf(product.getProductId())+"/" + imageFileName); + } + } catch (Exception e) { + e.printStackTrace(); + } + product.setProductRealPrice(String.valueOf(product.getProductPrice())); + product.setStatus(0); + product.setAttribute71(String.valueOf(1)); + productService.add(product); + return "success"; + } + return "index_index"; + } + + /** + * 发货管理 + * @return + */ + public String orderDetailAddressList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + + if(pageNo==0){ + pageNo = 1; + } + + Pagination page = orderDetailAddressService.orderDetailAddressList(pageNo, pageSize); + + orderDetailAddressList = (List) page.getList(); + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/orderdetailaddressList.action?pageNo="); + pageString = pageString.replace(".html", ""); + return "orderDetailAddressList"; + } + return "index_index"; + } + + + + + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getForward() { + return forward; + } + + public void setForward(String forward) { + this.forward = forward; + } + + public String getTo() { + return to; + } + + public void setTo(String to) { + this.to = to; + } + + + public Shareimage getShareimage() { + return shareimage; + } + + public void setShareimage(Shareimage shareimage) { + this.shareimage = shareimage; + } + + public List getProductimageList() { + return productimageList; + } + + public void setProductimageList(List productimageList) { + this.productimageList = productimageList; + } + + public List getShareimageList() { + return shareimageList; + } + + public void setShareimageList(List shareimageList) { + this.shareimageList = shareimageList; + } + + public void setProductList(List productList) { + this.productList = productList; + } + + public List getNewDateList() { + return newDateList; + } + + public void setNewDateList(List newDateList) { + this.newDateList = newDateList; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public List getProductJSONList() { + return productJSONList; + } + + public void setProductJSONList(List productJSONList) { + this.productJSONList = productJSONList; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + public BuyHistoryJSON getBuyHistoryJSON() { + return buyHistoryJSON; + } + + public void setBuyHistoryJSON(BuyHistoryJSON buyHistoryJSON) { + this.buyHistoryJSON = buyHistoryJSON; + } + + public List getBuyHistoryJSONList() { + return buyHistoryJSONList; + } + + public void setBuyHistoryJSONList(List buyHistoryJSONList) { + this.buyHistoryJSONList = buyHistoryJSONList; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public String getSelectTime() { + return selectTime; + } + + public void setSelectTime(String selectTime) { + this.selectTime = selectTime; + } + + public Randomnumber getRandomnumber() { + return randomnumber; + } + + public void setRandomnumber(Randomnumber randomnumber) { + this.randomnumber = randomnumber; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public Shareinfo getShareinfo() { + return shareinfo; + } + + public void setShareinfo(Shareinfo shareinfo) { + this.shareinfo = shareinfo; + } + + public ShareJSON getShareJSON() { + return shareJSON; + } + + public void setShareJSON(ShareJSON shareJSON) { + this.shareJSON = shareJSON; + } + + public List getShareJSONList() { + return shareJSONList; + } + + public void setShareJSONList(List shareJSONList) { + this.shareJSONList = shareJSONList; + } + + public List getUserbyaddressList() { + return userbyaddressList; + } + + public void setUserbyaddressList(List userbyaddressList) { + this.userbyaddressList = userbyaddressList; + } + + public Userbyaddress getUserbyaddress() { + return userbyaddress; + } + + public void setUserbyaddress(Userbyaddress userbyaddress) { + this.userbyaddress = userbyaddress; + } + + public String getUserJSON() { + return userJSON; + } + + public List getRandomNumberJSONList() { + return randomNumberJSONList; + } + + public void setRandomNumberJSONList(List randomNumberJSONList) { + this.randomNumberJSONList = randomNumberJSONList; + } + + public RandomNumberJSON getRandomNumberJSON() { + return randomNumberJSON; + } + + public void setRandomNumberJSON(RandomNumberJSON randomNumberJSON) { + this.randomNumberJSON = randomNumberJSON; + } + + public void setUserJSON(String userJSON) { + this.userJSON = userJSON; + } + + public File getMyFile() { + return myFile; + } + + public void setMyFile(File myFile) { + this.myFile = myFile; + } + + public String getMyFileFileName() { + return myFileFileName; + } + + public void setMyFileFileName(String myFileFileName) { + this.myFileFileName = myFileFileName; + } + + public String getMyFileContentType() { + return myFileContentType; + } + + public void setMyFileContentType(String myFileContentType) { + this.myFileContentType = myFileContentType; + } + + public String getImageFileName() { + return imageFileName; + } + + public void setImageFileName(String imageFileName) { + this.imageFileName = imageFileName; + } + + public int getX1() { + return x1; + } + + public void setX1(int x1) { + this.x1 = x1; + } + + public int getY1() { + return y1; + } + + public void setY1(int y1) { + this.y1 = y1; + } + + public String getHidPicUrl() { + return hidPicUrl; + } + + public void setHidPicUrl(String hidPicUrl) { + this.hidPicUrl = hidPicUrl; + } + + public int getW() { + return w; + } + + public void setW(int w) { + this.w = w; + } + + public int getH() { + return h; + } + + public void setH(int h) { + this.h = h; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public List getNewsList() { + return newsList; + } + + public void setNewsList(List newsList) { + this.newsList = newsList; + } + + public List getSProvinceList() { + return sProvinceList; + } + + public void setSProvinceList(List provinceList) { + sProvinceList = provinceList; + } + + public List getSCityList() { + return sCityList; + } + + public void setSCityList(List cityList) { + sCityList = cityList; + } + + public List getSDistrictList() { + return sDistrictList; + } + + public void setSDistrictList(List districtList) { + sDistrictList = districtList; + } + + public List getUserList() { + return userList; + } + + public void setUserList(List userList) { + this.userList = userList; + } + + public List getCommissionqueryList() { + return commissionqueryList; + } + + public void setCommissionqueryList(List commissionqueryList) { + this.commissionqueryList = commissionqueryList; + } + + public List getApplymentionList() { + return applymentionList; + } + + public void setApplymentionList(List applymentionList) { + this.applymentionList = applymentionList; + } + + public Applymention getApplymention() { + return applymention; + } + + public void setApplymention(Applymention applymention) { + this.applymention = applymention; + } + + public Commissionquery getCommissionquery() { + return commissionquery; + } + + public void setCommissionquery(Commissionquery commissionquery) { + this.commissionquery = commissionquery; + } + + public List getCommissionqueryJSONList() { + return commissionqueryJSONList; + } + + public void setCommissionqueryJSONList( + List commissionqueryJSONList) { + this.commissionqueryJSONList = commissionqueryJSONList; + } + + public CommissionqueryJSON getCommissionqueryJSON() { + return commissionqueryJSON; + } + + public void setCommissionqueryJSON(CommissionqueryJSON commissionqueryJSON) { + this.commissionqueryJSON = commissionqueryJSON; + } + + public List getCommissionpointsList() { + return commissionpointsList; + } + + public void setCommissionpointsList(List commissionpointsList) { + this.commissionpointsList = commissionpointsList; + } + + public Commissionpoints getCommissionpoints() { + return commissionpoints; + } + + public void setCommissionpoints(Commissionpoints commissionpoints) { + this.commissionpoints = commissionpoints; + } + + public List getOrderdetailList() { + return orderdetailList; + } + + public void setOrderdetailList(List orderdetailList) { + this.orderdetailList = orderdetailList; + } + + public OrderDetailAddress getOrderDetailAddress() { + return orderDetailAddress; + } + + public void setOrderdetailaddress(OrderDetailAddress orderDetailAddress) { + this.orderDetailAddress = orderDetailAddress; + } + + public Orderdetail getOrderdetail() { + return orderdetail; + } + + public List getOrderDetailAddressList() { + return orderDetailAddressList; + } + + public void setOrderDetailAddressList(List orderDetailAddressList) { + this.orderDetailAddressList = orderDetailAddressList; + } + + + public void setOrderdetail(Orderdetail orderdetail) { + this.orderdetail = orderdetail; + } + + + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Shop getShop() { + return shop; + } + + public void setShop(Shop shop) { + this.shop = shop; + } + + public boolean isHasAuditSuccessShop() { + return hasAuditSuccessShop; + } + + public void setHasAuditSuccessShop(boolean hasAuditSuccessShop) { + this.hasAuditSuccessShop = hasAuditSuccessShop; + } + + public Integer getImageType() { + return imageType; + } + + public void setImageType(Integer imageType) { + this.imageType = imageType; + } + + public File getCredentialsPhotoFile() { + return credentialsPhotoFile; + } + + public void setCredentialsPhotoFile(File credentialsPhotoFile) { + this.credentialsPhotoFile = credentialsPhotoFile; + } + + public File getCardIdPhotoFile() { + return cardIdPhotoFile; + } + + public void setCardIdPhotoFile(File cardIdPhotoFile) { + this.cardIdPhotoFile = cardIdPhotoFile; + } + + public String getCredentialsPhotoFileFileName() { + return credentialsPhotoFileFileName; + } + + public void setCredentialsPhotoFileFileName(String credentialsPhotoFileFileName) { + this.credentialsPhotoFileFileName = credentialsPhotoFileFileName; + } + + public String getCardIdPhotoFileFileName() { + return cardIdPhotoFileFileName; + } + + public void setCardIdPhotoFileFileName(String cardIdPhotoFileFileName) { + this.cardIdPhotoFileFileName = cardIdPhotoFileFileName; + } + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + public String getHidCredentialsPhotoUrl() { + return hidCredentialsPhotoUrl; + } + + public void setHidCredentialsPhotoUrl(String hidCredentialsPhotoUrl) { + this.hidCredentialsPhotoUrl = hidCredentialsPhotoUrl; + } + + public String getHidCardIdPhotoUrl() { + return hidCardIdPhotoUrl; + } + + public void setHidCardIdPhotoUrl(String hidCardIdPhotoUrl) { + this.hidCardIdPhotoUrl = hidCardIdPhotoUrl; + } + + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + + public String getShopName() { + return shopName; + } + + public void setShopName(String shopName) { + this.shopName = shopName; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCounty() { + return county; + } + + public void setCounty(String county) { + this.county = county; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public Double getX() { + return x; + } + + public void setX(Double x) { + this.x = x; + } + + public Double getY() { + return y; + } + + public void setY(Double y) { + this.y = y; + } + + public Integer getCredentialsType() { + return credentialsType; + } + + public void setCredentialsType(Integer credentialsType) { + this.credentialsType = credentialsType; + } + + public String getLegalRepresentativeName() { + return legalRepresentativeName; + } + + public void setLegalRepresentativeName(String legalRepresentativeName) { + this.legalRepresentativeName = legalRepresentativeName; + } + + public String getLegalRepresentativeId() { + return legalRepresentativeId; + } + + public void setLegalRepresentativeId(String legalRepresentativeId) { + this.legalRepresentativeId = legalRepresentativeId; + } + + public Integer getPayChannel() { + return payChannel; + } + + public void setPayChannel(Integer payChannel) { + this.payChannel = payChannel; + } + + public String getAlipay() { + return alipay; + } + + public void setAlipay(String alipay) { + this.alipay = alipay; + } + + public String getTengpay() { + return tengpay; + } + + public void setTengpay(String tengpay) { + this.tengpay = tengpay; + } + + public String getManagerPhone() { + return managerPhone; + } + + public void setManagerPhone(String managerPhone) { + this.managerPhone = managerPhone; + } + + public String getManagerName() { + return managerName; + } + + public void setManagerName(String managerName) { + this.managerName = managerName; + } + + public String getManngerTitle() { + return manngerTitle; + } + + public void setManngerTitle(String manngerTitle) { + this.manngerTitle = manngerTitle; + } + + public String getWeixinPublic() { + return weixinPublic; + } + + public void setWeixinPublic(String weixinPublic) { + this.weixinPublic = weixinPublic; + } + + public String getServicePhone() { + return servicePhone; + } + + public void setServicePhone(String servicePhone) { + this.servicePhone = servicePhone; + } + + public String getQq() { + return qq; + } + + public void setQq(String qq) { + this.qq = qq; + } + + public String getWeixin() { + return weixin; + } + + public void setWeixin(String weixin) { + this.weixin = weixin; + } + + public String getSynopsis() { + return synopsis; + } + + public void setSynopsis(String synopsis) { + this.synopsis = synopsis; + } + + public List getShopList() { + return shopList; + } + + public void setShopList(List shopList) { + this.shopList = shopList; + } + + public List getOrderBeanList() { + return orderBeanList; + } + + public void setOrderBeanList(List orderBeanList) { + this.orderBeanList = orderBeanList; + } + + public ProductService getProductService() { + return productService; + } + + public void setProductService(ProductService productService) { + this.productService = productService; + } + + public List getProductBrandList() { + return productBrandList; + } + + public void setProductBrandList(List productBrandList) { + this.productBrandList = productBrandList; + } + + public List getProductTypeList() { + return productTypeList; + } + + public void setProductTypeList(List productTypeList) { + this.productTypeList = productTypeList; + } + + public String getPages() { + return pages; + } + + public void setPages(String pages) { + this.pages = pages; + } + + public String getPageString() { + return pageString; + } + + public void setPageString(String pageString) { + this.pageString = pageString; + } + + public String getTypeId() { + return typeId; + } + + public void setTypeId(String typeId) { + this.typeId = typeId; + } + + public String gettId() { + return tId; + } + + public void settId(String tId) { + this.tId = tId; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + public String getBackUrl() { + return backUrl; + } + + public void setBackUrl(String backUrl) { + this.backUrl = backUrl; + } + + public ResultObj getResultObj() { + return resultObj; + } + + public void setResultObj(ResultObj resultObj) { + this.resultObj = resultObj; + } + + + + + public class UploadFileInfo{ + String filePath; + Integer fileType; + Integer size; + String info; + + public String getInfo() { + return info; + } + public void setInfo(String info) { + this.info = info; + } + public Integer getSize() { + return size; + } + public void setSize(Integer size) { + this.size = size; + } + public String getFilePath() { + return filePath; + } + public void setFilePath(String filePath) { + this.filePath = filePath; + } + public Integer getFileType() { + return fileType; + } + public void setFileType(Integer fileType) { + this.fileType = fileType; + } + } + + + +} diff --git a/src/main/java/me/mofun/action/my/TalkAction.java b/src/main/java/me/mofun/action/my/TalkAction.java new file mode 100644 index 0000000..2030408 --- /dev/null +++ b/src/main/java/me/mofun/action/my/TalkAction.java @@ -0,0 +1,1439 @@ +package me.mofun.action.my; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionSupport; +import me.mofun.pojo.*; +import me.mofun.pojo.weixin.WeiXinAccessToken; +import me.mofun.pojo.weixin.WeiXinOAuth2AccessToken; +import me.mofun.pojo.weixin.WeiXinOAuth2UserInfo; +import me.mofun.service.*; +import me.mofun.util.DateUtil; +import me.mofun.util.Struts2Utils; +import me.mofun.util.WeiXinUtil; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts2.ServletActionContext; +import org.apache.struts2.dispatcher.RequestMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@SuppressWarnings("unused") +@Component("TalkAction") +public class TalkAction extends ActionSupport { + Logger log = Logger.getLogger(TalkAction.class); + + private static final long serialVersionUID = 1889272927204740730L; + + @Autowired + private NewsService newsService; + + @Autowired + private NewsTypeService newTypeService; + + @Autowired + private UserService userService; + + @Autowired + private NewsReplyService newsReplyService; + + + @Autowired + private TalkUserService talkUserService; + + @Autowired + private TalkGroupService talkGroupService; + + @Autowired + private TalkMsgService talkMsgService; + + + HttpServletRequest request = null; + HttpServletResponse response = null; + + private String action; + private Integer id; + private Integer parentId; + + private Integer subId; //newsType 表子类型Id,用于前端根据子类型Id 找出所属的父类型id; + + private NewsType group; + private Integer groupID; + private News topic; + private String topicID; + private NewsReply reply; + private User user; + private User logonUser; //记录登陆的用户信息 + + List groupSubList; //新闻子类别列表 + List groupTopList; //新闻根类别列表 + List replpContenttList; //新闻话题回复信息列表 + List replyList; //新闻话题回复信息及用户列表 + + //处理前端Ajax请求时的几个参数 http://127.0.0.1/JPData?action=replygetpagelist&groupID=10&topicID=1&FIdx=1&EIdx=10&isCount=1&fun=jsonp1461823453170&_=1461823529934 + private Integer FIdx; //分页时开始记录序号,假若每页10条的话,第一页该参数取值1 ,第二页该参数取值11 + private Integer EIdx; //分页时结束记录需要,假若每页10条的话,第一页该参数取值10,第二页该参数取值20 + private Integer isCount ; + private String fun; + private String _; + + //处理前端 Ajax inserttopicreply 请求时的几个参数 + private String json; + private String userId; //回复者或登录用户的ID + private String title; + private String content; + private Integer refFloor; + private String toUserId; + private String parentReplyId; + + + private List talkUserList; + private List jsonTalkUserList; + private List jsonTalkMsgList; + private String mid; //myUserId + private String uid; //私聊时的对方userId + private String tuid; //私聊时的对方userId $.post("/index.php?s=/Talk/sendmsg/tuid/39.html",{"msg":txt,"cid":cid},function + private TalkUser talkUser; + private TalkUser toTalkUser; + private String userlist; + //private Integer gid; + private TalkGroup talkGroup; + + //获取及发送消息时的参数 + private Long time; + private Integer cid; + private String msg; + + private Integer p; + private Long enterTime; + private Long lastTime; + + private Integer maleCount; + private Integer femaleCount; + + private String code; //微信网页授权后会返回一个code,用于获取 access_token + //String appId = "wx0803a6e2d9e15786";// 第三方用户唯一凭证 + //String appSecret = "0763f3c61e85e18da67f6b5dbe9367db";// 第三方用户唯一凭证密钥 + private String appId = "wx61acf608d704c8e6"; + private String appSecret = "fadf1da2641424a28e03007f83230819"; + private WeiXinAccessToken weiXinAccessToken; + private WeiXinAccessToken weiXinJSApiTicket; + private String weiXinPutFileApiUrl = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE"; + private String weiXinGetFileApiUrl = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID"; + + public WeiXinAccessToken getWeiXinAccessToken(ServletContext ctx){ + boolean needUpdate = false; + Long timestamp = new Date().getTime()/1000; + if(ctx.getAttribute("weiXinAccessToken")!=null) + { + weiXinAccessToken = (WeiXinAccessToken)ctx.getAttribute("weiXinAccessToken"); + if((timestamp - weiXinAccessToken.getTokenTimestamp())>weiXinAccessToken.getExpiresIn()){ + needUpdate = true; + } + } + else + needUpdate = true; + + if(needUpdate){ + weiXinAccessToken = WeiXinUtil.getAccessToken(appId, appSecret); // 调用接口获取access_token + ctx.setAttribute("weiXinAccessToken", weiXinAccessToken); + } + + return weiXinAccessToken; + } + + public WeiXinAccessToken getWeiXinJSApiTicket(ServletContext ctx){ + boolean needUpdate = false; + Long timestamp = new Date().getTime()/1000; + if(ctx.getAttribute("weiXinJSApiTicket")!=null) + { + weiXinJSApiTicket = (WeiXinAccessToken)ctx.getAttribute("weiXinJSApiTicket"); + if((timestamp - weiXinJSApiTicket.getTokenTimestamp())>weiXinJSApiTicket.getExpiresIn()){ + needUpdate = true; + } + } + else + needUpdate = true; + + if(needUpdate){ + weiXinAccessToken = getWeiXinAccessToken(ctx); + weiXinJSApiTicket = WeiXinUtil.getJSApiTicket(weiXinAccessToken.getToken());// 调用接口获取jsapi_ticket + weiXinJSApiTicket.setAppId(weiXinAccessToken.getAppId()); + ctx.setAttribute("weiXinJSApiTicket", weiXinJSApiTicket); + } + + return weiXinJSApiTicket; + + } + + + public String index(){ + //topic = newsService.findById(id.toString()); + //groupTopList = newTypeService.indexNewsTypeByParentId(0); + //parentId = newTypeService.findById(id.toString()).getParentId(); + + ActionContext ac = ActionContext.getContext();//获取当前action的上下文 + RequestMap reqMap = (RequestMap)ac.get("request");//获取请求Map + String acPath = (String)reqMap.get("javax.servlet.forward.servlet_path");//获取跳转的action路径 + String queryString = (String)reqMap.get("javax.servlet.forward.query_string");//获取跳转的action请求参数 + + if(request==null)request=Struts2Utils.getRequest(); + if(response==null)response=Struts2Utils.getResponse(); + + //String url = "http://www.qzly.me"+request.getRequestURI().replace("action", "html")+(queryString==null?"":"?"+queryString); + String url = request.getRequestURL().toString(); + url = url.replace("action", "html")+(queryString==null?"":"?"+queryString); + + String wxOAuth2Url = ""; + WeiXinOAuth2UserInfo wxUser = (WeiXinOAuth2UserInfo)request.getSession().getAttribute("wxUser"); + //如果换取token的code为空且用户session为空,或者用户session不为空但token过期 + if((StringUtils.isBlank(code)&&wxUser==null)||(wxUser!=null&&((new Date().getTime())/1000-wxUser.getAccessToken().getTokenTimestamp()>wxUser.getAccessToken().getExpiresIn()))){ + wxOAuth2Url = WeiXinUtil.getWeiXinOAuth2Code(appId, url, WeiXinUtil.WeiXinScope.snsapi_userinfo, "STATE"); + try { + response.sendRedirect(wxOAuth2Url); //转向腾讯从头获取code + return null; + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else{ + WeiXinOAuth2UserInfo u = null; + WeiXinOAuth2AccessToken accessToken4OAuth2 = null; + if(wxUser==null&&StringUtils.isNoneBlank(code)){ //session用户为空,code不会空时,先换取token + accessToken4OAuth2 = WeiXinUtil.getWeiXinOAuth2AccessToken(appId, appSecret, code); + if(accessToken4OAuth2!=null&&accessToken4OAuth2.getAccessToken()!=null){//再获取用户 + u = WeiXinUtil.getWeiXinOAuth2UserInfo(accessToken4OAuth2.getAccessToken(), accessToken4OAuth2.getOpenId()); + u.setAccessToken(accessToken4OAuth2); + }else{ + if(accessToken4OAuth2!=null&&accessToken4OAuth2.getErrcode()!=null){//获取Token 失败时,从头重新获取 code + log.error("errCode="+accessToken4OAuth2.getErrcode()+",errMsg="+accessToken4OAuth2.getErrmsg()); + try { + wxOAuth2Url = WeiXinUtil.getWeiXinOAuth2Code(appId, url, WeiXinUtil.WeiXinScope.snsapi_userinfo, "STATE"); + response.sendRedirect(wxOAuth2Url); //转向腾讯从头获取code + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + } + }else{ + u = wxUser; + } + + if(u!=null){//成功获取用户之后 + request.getSession().setAttribute("wxUser", u); //存用户到session 中 + talkUser = talkUserService.getUserByOpenId(u.getOpenid()); // 判断微信用户是否已登记在DB中 + //if(talkUser==null) + { //是没登记或的新用户的话 + if(cid==null)cid=1; + if(talkUser==null) + talkUser = new TalkUser(); + + if(StringUtils.isNoneBlank(u.getProvince())) + talkUser.setProvince(u.getProvince()); + if(StringUtils.isNoneBlank(u.getCity())) + talkUser.setCity(u.getCity()); + if(StringUtils.isNoneBlank(u.getHeadimgurl())) + talkUser.setAvatar(u.getHeadimgurl()); + else + if(StringUtils.isBlank(talkUser.getAvatar())){ + if(u.getSex()!=null&&u.getSex()==1) + talkUser.setAvatar("/talk/public/res/chat/anonymous_boy.jpg"); + else + talkUser.setAvatar("/talk/public/res/chat/anonymous_girl.jpg"); + } + if(u.getSex()!=null) + talkUser.setSex(u.getSex()); + + if(StringUtils.isNoneBlank(u.getNickname())) + talkUser.setWxNick(u.getNickname()); + + if(StringUtils.isNoneBlank(u.getOpenid())) + talkUser.setWxOpenId(u.getOpenid()); + + if(StringUtils.isNoneBlank(talkUser.getGroupId())){ + if(!talkUser.isGroupMember(""+cid)) + talkUser.setGroupId(talkUser.getGroupId()+cid+","); + } + else + talkUser.setGroupId(cid+","); + + if(talkUser.getCreateTime()==null) + talkUser.setCreateTime(new Timestamp(new Date().getTime())); + + talkUserService.add(talkUser); + + if(talkUser==null){ //初次进入且未曾登记入库的用户,添加一条欢迎信息! + TalkMsg tm = new TalkMsg(); + tm.setContent("欢迎来自"+u.getProvince()+u.getCity()+"的"+u.getNickname()+(u.getSex()==1?"帅哥!":"美女!")); + tm.setToUserId("0"); + tm.setUserId("2"); + tm.setGroupId(cid); + tm.setPostDate(new Timestamp(new Date().getTime())); + talkMsgService.add(tm); + } + } + } + mid = talkUser.getId().toString(); + + }; + + //JS 方式调用时,一些参数的获取 + weiXinJSApiTicket = getWeiXinJSApiTicket(Struts2Utils.getApplication()); + String nonceStr = "abcd1234"; + Long timestamp = new Date().getTime()/1000; + String signature = WeiXinUtil.getSignature(weiXinJSApiTicket.getToken(), nonceStr, timestamp, url); + weiXinJSApiTicket.setNonceStr(nonceStr); + weiXinJSApiTicket.setSignature(signature); + weiXinJSApiTicket.setSignatureTimestamp(timestamp); + + if (null != weiXinJSApiTicket) { + log.info("获取 AccessToken 成功!"); + } + + + //私聊处理:uid不为空时表示要进行私聊(uid是私聊时传过来的对方的userId参数) + if(uid!=null){ + JSONObject json = new JSONObject(); + if(mid==null) + mid="1"; + + if(talkUser==null) + talkUser = talkUserService.findById(mid); + if(talkUser!=null){ + //"/index.php?s=/Talk/talkto/id/40/cid/1.html" + if(cid==null) + cid=1; + + if(talkUser.isGroupMember(cid.toString())){ + json.accumulate("msg", "/talk/talkto.html?tuid="+uid+"&cid="+cid); + json.accumulate("ret", 1); + } + else{ + json.accumulate("msg", "对方现在不是该聊天室用户,不能进行私聊!"); + json.accumulate("ret", 2); + } + }else{ + json.accumulate("msg", "对方未曾授权,不能进行私聊!"); + json.accumulate("ret", 3); + } + Struts2Utils.renderJson(json); + return null; + }else + uid="0"; //表示对所有人,公聊; + + + if(mid==null){ + if(talkUser!=null) + mid=talkUser.getId().toString(); +// else //实际线上时,该值必不能为空,必须是经腾讯获取用户身份后,对应的数据库表talkUser中的talkUser.Id +// mid="1"; //离线测试时用 + } + + if(userId==null) + userId=mid; + request.getSession().setAttribute("uid", userId); + + if(mid!=null&&talkUser==null){ + talkUser = talkUserService.findById(mid); + } + + if(cid==null) + cid=1; + + + //获取聊天室用户列表 + talkGroup = talkGroupService.findById(""+cid); + if(maleCount==null)maleCount = 0; + if(femaleCount==null)femaleCount =0; + talkUserList = talkUserService.getUserListByGroupId(cid); + if(talkUserList!=null&&talkUserList.size()>0){ + jsonTalkUserList = new ArrayList(); + for(TalkUser u:talkUserList){ + JSONTalkUser jsonUser = new JSONTalkUser(); + jsonUser.cid = Integer.parseInt(u.getGroupId().split(",")[0]); + jsonUser.city = u.getCity(); + jsonUser.headimgurl = StringUtils.isBlank(u.getAvatar())?"/talk/public/res/chat/anonymous.jpg":u.getAvatar(); + jsonUser.id = u.getId(); + jsonUser.nickname = u.getWxNick(); + jsonUser.province = u.getProvince(); + jsonUser.sex = u.getSex(); + jsonTalkUserList.add(jsonUser); + if(u.getSex()!=null&&u.getSex()==1) + maleCount++; + else + femaleCount++; + } + userlist = JSONArray.fromObject(jsonTalkUserList).toString(); + }else + userlist = "[]"; + + if(enterTime==null) + enterTime=new Date().getTime()/1000; + + if(lastTime==null) + lastTime=new Date().getTime()/1000; + + if(p!=null){ //根据页码获取第几页的历史消息 + time=enterTime; + getMessage(enterTime,cid,0,p); + return null; + }else{ + p=1; + } + + return "index"; + } + + //私聊处理过程 + public String talkto(){ + + ActionContext ac = ActionContext.getContext();//获取当前action的上下文 + RequestMap reqMap = (RequestMap)ac.get("request");//获取请求Map + String acPath = (String)reqMap.get("javax.servlet.forward.servlet_path");//获取跳转的action路径 + String queryString = (String)reqMap.get("javax.servlet.forward.query_string");//获取跳转的action请求参数 + + if(request==null)request=Struts2Utils.getRequest(); + if(response==null)response=Struts2Utils.getResponse(); + + //String url = "http://www.qzly.me"+request.getRequestURI().replace("action", "html")+(queryString==null?"":"?"+queryString); + String url = request.getRequestURL().toString(); + url = url.replace("action", "html")+(queryString==null?"":"?"+queryString); + //JS 方式调用时,一些参数的获取 + weiXinJSApiTicket = getWeiXinJSApiTicket(Struts2Utils.getApplication()); + String nonceStr = "abcd1234"; + Long timestamp = new Date().getTime()/1000; + String signature = WeiXinUtil.getSignature(weiXinJSApiTicket.getToken(), nonceStr, timestamp, url); + weiXinJSApiTicket.setNonceStr(nonceStr); + weiXinJSApiTicket.setSignature(signature); + weiXinJSApiTicket.setSignatureTimestamp(timestamp); + + if (null != weiXinJSApiTicket) { + log.info("获取 AccessToken 成功!"); + } + + uid=request.getSession().getAttribute("uid").toString(); + talkUser = talkUserService.findById(uid); + toTalkUser = talkUserService.findById(tuid); + + if(userId==null) + userId=uid; + + if(cid==null) + cid=1; + + if(enterTime==null) + enterTime=new Date().getTime()/1000; + + if(lastTime==null) + lastTime=new Date().getTime()/1000; + + if(p!=null){ //根据页码获取第几页的历史消息 + time=enterTime; + getPrivateMessage(enterTime,cid,Integer.parseInt(uid),Integer.parseInt(tuid),p); + + talkMsgService.updateMsgStatus(Integer.parseInt(tuid),Integer.parseInt(uid), 2); //更新信息为已读状态; + return null; + }else + p=1; + + return "talkTo"; + } + + public void getMessage(){ + + + List arrayList = null; + if(tuid==null) + arrayList = talkMsgService.getNewMsgList(time, cid,0); //获取公聊消息 + else{ + if(request==null)request=Struts2Utils.getRequest(); + if(uid==null) + uid=request.getSession().getAttribute("uid").toString(); + arrayList = talkMsgService.getNewPrivateMsgList(time, cid, Integer.parseInt(uid),Integer.parseInt(tuid));//获取私聊消息 + } +// if(arrayList==null||arrayList.size()==0) +// return; + List jsonTalkMsgList = new ArrayList(); + for(int i=0;i arrayList = talkMsgService.getMsgList(time, cid,toUserId,pageIndex); + List jsonTalkMsgList = new ArrayList(); + for(int i=0;i arrayList = talkMsgService.getMsgList(time, cid, fromUserId, toUserId, pageIndex); + List jsonTalkMsgList = new ArrayList(); + for(int i=0;i0) + chatListCount = talkUserList.size(); + Struts2Utils.renderText(""+chatListCount); + return null; + } + else{ //转向私聊列表(取所有人) + talkUserList = talkMsgService.getChatList(Integer.parseInt(mid)); + return "chatList"; + } + } + + public String topic() { + if(topicID!=null) + { + topic=newsService.findById(""+topicID); + //group = newTypeService.findById(""+topic.getCategoryId()); + user=userService.findById(topic.getUserId()); + getLogonUserInfo(); //获取已登录的用户信息 + replyList = newsReplyService.indexNewsReply(topic.getNewsId(), null); + if(request==null) { + request = Struts2Utils.getRequest(); + } + request.getSession().setAttribute("groupID", topic.getCategoryId()); + } + return "topic"; + } + + public String JPData() { + + //for debug + ActionContext ac = ActionContext.getContext();//获取当前action的上下文 + RequestMap reqMap = (RequestMap)ac.get("request");//获取请求Map + String acPath = (String)reqMap.get("javax.servlet.forward.servlet_path");//获取跳转的action路径 + String queryString = (String)reqMap.get("javax.servlet.forward.query_string");//获取跳转的action请求参数 + + topic = newsService.findById(topicID.toString()); + groupTopList = newTypeService.indexNewsTypeByParentId(0); + parentId = newTypeService.findById(""+topic.getCategoryId()).getParentId(); + + user=userService.findById(topic.getUserId()); + getLogonUserInfo(); + + String temp=action; + if(request==null) + request = Struts2Utils.getRequest(); + String requestURL =request.getRequestURL().toString(); + String querString = request.getQueryString(); + if(action.equals("")&&queryString!=null) + action=querString.split("&")[0].split("=")[1]; + if(action.equals("replygetpagelist")) + replygetpagelist(); + else + if (action.equals("updatelookcount")) + updatelookcount(); + else if (action.equals("deletegroupreply")) + deletegroupreply(); + else if (action.equals("getgroupusertotalinfo")) + getgroupusertotalinfo(); + else if (action.equals("checkadmingrouptopic")) + checkadmingrouptopic(); + else if (action.equals("updategrouptopicgood")) + updategrouptopicgood(); + else if (action.equals("showgrouptopicun")) + showgrouptopicun(); + else if (action.equals("inserttopicreply")) + inserttopicreply(); + else if (action.equals("checkgroupuserexists")) + checkgroupuserexists(); + else if (action.equals("insertgroupuser")) + insertgroupuser(); + else + { + RequestDispatcher d = request.getRequestDispatcher("/"+action+".action"); + try { + d.forward(request, response); + } catch (ServletException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /* + ActionContext ac = ActionContext.getContext();//获取当前action的上下文 + RequestMap reqMap = (RequestMap)ac.get("request");//获取请求Map + + String acPath = (String)reqMap.get("javax.servlet.forward.servlet_path");//获取跳转的action路径 + String queryString = (String)reqMap.get("javax.servlet.forward.query_string");//获取跳转的action请求参数 + */ + + return null; + } + + private class UserFloor{ + public int floor; + public String userName; + } + + public UserFloor getUserFloor(int replyId) + { + UserFloor uf = new UserFloor(); + if(replyList!=null) + { + int allFloor = replyList.size(); + for(int i=0;i getReplyList() { + return replyList; + } + + public void setReplyList(List replyList) { + this.replyList = replyList; + } + + public String toAdd(){ + + return "toAddOrUpdate"; + } + + public String add(){ + + return "success"; + } + + public String toUpdate(){ + + return "toAddOrUpdate"; + } + + public String update(){ + + return "success"; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getGroupID() { + return groupID; + } + + public void setGroupID(Integer groupID) { + this.groupID = groupID; + } + + + public String getTopicID() { + return topicID; + } + + public void setTopicID(String topicID) { + this.topicID = topicID; + } + + public News getTopic() { + return topic; + } + + public void setTopic(News topic) { + this.topic = topic; + } + + public NewsType getGroup() { + return group; + } + + public void setGroup(NewsType group) { + this.group = group; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public User getLogonUser() { + return logonUser; + } + + public void setLogonUser(User logonUser) { + this.logonUser = logonUser; + } + + + public NewsReply getReply() { + return reply; + } + + public void setReply(NewsReply reply) { + this.reply = reply; + } + + public Integer getParentId() { + return parentId; + } + + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + public Integer getSubId() { + return subId; + } + + public void setSubId(Integer subId) { + this.subId = subId; + } + + public Integer getFIdx() { + return FIdx; + } + + public void setFIdx(Integer fIdx) { + FIdx = fIdx; + } + + public Integer getEIdx() { + return EIdx; + } + + public void setEIdx(Integer eIdx) { + EIdx = eIdx; + } + + public Integer getIsCount() { + return isCount; + } + + public void setIsCount(Integer isCount) { + this.isCount = isCount; + } + + public String getFun() { + return fun; + } + + public void setFun(String fun) { + this.fun = fun; + } + + public String get_() { + return _; + } + + public void set_(String _) { + this._ = _; + } + + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Integer getRefFloor() { + return refFloor; + } + + public void setRefFloor(Integer refFloor) { + this.refFloor = refFloor; + } + + public String getToUserId() { + return toUserId; + } + + public void setToUserId(String toUserId) { + this.toUserId = toUserId; + } + + public String getParentReplyId() { + return parentReplyId; + } + + public void setParentReplyId(String parentReplyId) { + this.parentReplyId = parentReplyId; + } + + public String getJson() { + return json; + } + + public void setJson(String json) { + this.json = json; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + + + + + // TalkAction 属性 + public List getTalkUserList() { + return talkUserList; + } + + public void setTalkUserList(List talkUserList) { + this.talkUserList = talkUserList; + } + + public TalkUser getToTalkUser() { + return toTalkUser; + } + + public void setToTalkUser(TalkUser toTalkUser) { + this.toTalkUser = toTalkUser; + } + + public List getJsonTalkUserList() { + return jsonTalkUserList; + } + + public void setJsonTalkUserList(List jsonTalkUserList) { + this.jsonTalkUserList = jsonTalkUserList; + } + + public List getJsonTalkMsgList() { + return jsonTalkMsgList; + } + + public void setJsonTalkMsgList(List jsonTalkMsgList) { + this.jsonTalkMsgList = jsonTalkMsgList; + } + + + public String getMid() { + return uid; + } + + public void setMid(String uid) { + this.uid = uid; + } + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getTuid() { + return tuid; + } + + public void setTuid(String tuid) { + this.tuid = tuid; + } + + public TalkUser getTalkUser() { + return talkUser; + } + + public void setTalkUser(TalkUser talkUser) { + this.talkUser = talkUser; + } + + public String getUserlist() { + return userlist; + } + + public void setUserlist(String userlist) { + this.userlist = userlist; + } + + public TalkGroup getTalkGroup() { + return talkGroup; + } + + public void setTalkGroup(TalkGroup talkGroup) { + this.talkGroup = talkGroup; + } + + public Long getTime() { + return time; + } + + public void setTime(Long time) { + this.time = time; + } + + public Integer getCid() { + return cid; + } + + public void setCid(Integer cid) { + this.cid = cid; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public Integer getP() { + return p; + } + + public void setP(Integer p) { + this.p = p; + } + + public Long getEnterTime() { + return enterTime; + } + + public void setEnterTime(Long enterTime) { + this.enterTime = enterTime; + } + + public Long getLastTime() { + return lastTime; + } + + public void setLastTime(Long lastTime) { + this.lastTime = lastTime; + } + + public Integer getMaleCount() { + return maleCount; + } + + public void setMaleCount(Integer maleCount) { + this.maleCount = maleCount; + } + + public Integer getFemaleCount() { + return femaleCount; + } + + public void setFemaleCount(Integer femaleCount) { + this.femaleCount = femaleCount; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public WeiXinAccessToken getWeiXinAccessToken() { + return weiXinAccessToken; + } + + public void setWeiXinAccessToken(WeiXinAccessToken weiXinAccessToken) { + this.weiXinAccessToken = weiXinAccessToken; + } + + public WeiXinAccessToken getWeiXinJSApiTicket() { + return weiXinJSApiTicket; + } + + public void setWeiXinJSApiTicket(WeiXinAccessToken weiXinJSApiTicket) { + this.weiXinJSApiTicket = weiXinJSApiTicket; + } + + public class JSONTalkUser{ + private Integer id; + private Integer cid; + private String headimgurl; + private String nickname; + private Integer sex; + private String province; + private String city; + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public Integer getCid() { + return cid; + } + public void setCid(Integer cid) { + this.cid = cid; + } + public String getHeadimgurl() { + return headimgurl; + } + public void setHeadimgurl(String headimgurl) { + this.headimgurl = headimgurl; + } + public String getNickname() { + return nickname; + } + public void setNickname(String nickname) { + this.nickname = nickname; + } + public Integer getSex() { + return sex; + } + public void setSex(Integer sex) { + this.sex = sex; + } + public String getProvince() { + return province; + } + public void setProvince(String province) { + this.province = province; + } + public String getCity() { + return city; + } + public void setCity(String city) { + this.city = city; + } + } + + public class JSONTalkMsg{ + private Long addtime; + private String avatar; + private String cid; + private String fuid; + private String id; + private String msg; + private String nick; + private String pic; + private String remark; + private Integer sex; + private String status; + private String time; + private String tuid; + public Long getAddtime() { + return addtime; + } + public void setAddtime(Long addtime) { + this.addtime = addtime; + } + public String getAvatar() { + return avatar; + } + public void setAvatar(String avatar) { + this.avatar = avatar; + } + public String getCid() { + return cid; + } + public void setCid(String cid) { + this.cid = cid; + } + public String getFuid() { + return fuid; + } + public void setFuid(String fuid) { + this.fuid = fuid; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getMsg() { + return msg; + } + public void setMsg(String msg) { + this.msg = msg; + } + public String getNick() { + return nick; + } + public void setNick(String nick) { + this.nick = nick; + } + public String getPic() { + return pic; + } + public void setPic(String pic) { + this.pic = pic; + } + public String getRemark() { + return remark; + } + public void setRemark(String remark) { + this.remark = remark; + } + public Integer getSex() { + return sex; + } + public void setSex(Integer sex) { + this.sex = sex; + } + public String getStatus() { + return status; + } + public void setStatus(String status) { + this.status = status; + } + public String getTime() { + return time; + } + public void setTime(String time) { + this.time = time; + } + public String getTuid() { + return tuid; + } + public void setTuid(String tuid) { + this.tuid = tuid; + } + + } + + + + +} diff --git a/src/main/java/me/mofun/action/my/WeiXinMenuManager.java b/src/main/java/me/mofun/action/my/WeiXinMenuManager.java new file mode 100644 index 0000000..8cbadf5 --- /dev/null +++ b/src/main/java/me/mofun/action/my/WeiXinMenuManager.java @@ -0,0 +1,128 @@ +package me.mofun.action.my; + +import me.mofun.pojo.weixin.*; +import me.mofun.util.WeiXinUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 菜单管理器类 + * + * @author liufeng + * @date 2013-08-08 + */ +public class WeiXinMenuManager { + private static Logger log = LoggerFactory.getLogger(WeiXinMenuManager.class); + + public static void main(String[] args) { + // 第三方用户唯一凭证 + String appId = "000000000000000000"; + // 第三方用户唯一凭证密钥 + String appSecret = "00000000000000000000000000000000"; + + // 调用接口获取access_token + WeiXinAccessToken at = WeiXinUtil.getAccessToken(appId, appSecret); + + if (null != at) { + // 调用接口创建菜单 + int result = WeiXinUtil.createMenu(getMenu(), at.getToken()); + + // 判断菜单创建结果 + if (0 == result) + log.info("菜单创建成功!"); + else + log.info("菜单创建失败,错误码:" + result); + } + } + + /** + * 组装菜单数据 + * + * @return + */ + private static Menu getMenu() { + CommandButton btn11 = new CommandButton(); + btn11.setName("天气预报"); + btn11.setType("click"); + btn11.setKey("11"); + + CommandButton btn12 = new CommandButton(); + btn12.setName("公交查询"); + btn12.setType("click"); + btn12.setKey("12"); + + CommandButton btn13 = new CommandButton(); + btn13.setName("周边搜索"); + btn13.setType("click"); + btn13.setKey("13"); + + CommandButton btn14 = new CommandButton(); + btn14.setName("历史上的今天"); + btn14.setType("click"); + btn14.setKey("14"); + + CommandButton btn21 = new CommandButton(); + btn21.setName("歌曲点播"); + btn21.setType("click"); + btn21.setKey("21"); + + CommandButton btn22 = new CommandButton(); + btn22.setName("经典游戏"); + btn22.setType("click"); + btn22.setKey("22"); + + CommandButton btn23 = new CommandButton(); + btn23.setName("美女电台"); + btn23.setType("click"); + btn23.setKey("23"); + + CommandButton btn24 = new CommandButton(); + btn24.setName("人脸识别"); + btn24.setType("click"); + btn24.setKey("24"); + + CommandButton btn25 = new CommandButton(); + btn25.setName("聊天唠嗑"); + btn25.setType("click"); + btn25.setKey("25"); + + CommandButton btn31 = new CommandButton(); + btn31.setName("Q友圈"); + btn31.setType("click"); + btn31.setKey("31"); + + CommandButton btn32 = new CommandButton(); + btn32.setName("电影排行榜"); + btn32.setType("click"); + btn32.setKey("32"); + + CommandButton btn33 = new CommandButton(); + btn33.setName("幽默笑话"); + btn33.setType("click"); + btn33.setKey("33"); + + ComplexButton mainBtn1 = new ComplexButton(); + mainBtn1.setName("生活助手"); + mainBtn1.setSub_button(new CommandButton[] { btn11, btn12, btn13, btn14 }); + + ComplexButton mainBtn2 = new ComplexButton(); + mainBtn2.setName("休闲驿站"); + mainBtn2.setSub_button(new CommandButton[] { btn21, btn22, btn23, btn24, btn25 }); + + ComplexButton mainBtn3 = new ComplexButton(); + mainBtn3.setName("更多体验"); + mainBtn3.setSub_button(new CommandButton[] { btn31, btn32, btn33 }); + + /** + * 这是公众号xiaoqrobot目前的菜单结构,每个一级菜单都有二级菜单项
    + * + * 在某个一级菜单下没有二级菜单的情况,menu该如何定义呢?
    + * 比如,第三个一级菜单项不是“更多体验”,而直接是“幽默笑话”,那么menu应该这样定义:
    + * menu.setButton(new Button[] { mainBtn1, mainBtn2, btn33 }); + */ + Menu menu = new Menu(); + menu.setButton(new Button[] { mainBtn1, mainBtn2, mainBtn3 }); + + return menu; + } +} diff --git a/src/main/java/me/mofun/action/my/WeiXinService.java b/src/main/java/me/mofun/action/my/WeiXinService.java new file mode 100644 index 0000000..c2f4d9f --- /dev/null +++ b/src/main/java/me/mofun/action/my/WeiXinService.java @@ -0,0 +1,118 @@ +package me.mofun.action.my; + +import javax.servlet.http.HttpServletRequest; + +//import com.sun.xml.internal.ws.api.message.Message; + +/** + * http://www.2cto.com/weixin/201408/324645.html + * @author mofun + * + */ +public class WeiXinService { + /** + * 处理微信发来的请求 + * + * @param request + * @return + */ + public static String processRequest(HttpServletRequest request) { + String respMessage = null; + try { + // 默认返回的文本消息内容 + String respContent = "请求处理异常,请稍候尝试!"; + /* + // xml请求解析 + Map requestMap = Message.parseXml(request); + + // 发送方帐号(open_id) + String fromUserName = requestMap.get("FromUserName"); + // 公众帐号 + String toUserName = requestMap.get("ToUserName"); + // 消息类型 + String msgType = requestMap.get("MsgType"); + + + // 回复文本消息 + TextMessage textMessage = new TextMessage(); + textMessage.setToUserName(fromUserName); + textMessage.setFromUserName(toUserName); + textMessage.setCreateTime(new Date().getTime()); + textMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_TEXT); + textMessage.setFuncFlag(0); + + // 文本消息 + if (msgType.equals(MessageUtil.REQ_MESSAGE_TYPE_TEXT)) { + respContent = "您发送的是文本消息!"; + } + // 图片消息 + else if (msgType.equals(MessageUtil.REQ_MESSAGE_TYPE_IMAGE)) { + respContent = "您发送的是图片消息!"; + } + // 地理位置消息 + else if (msgType.equals(MessageUtil.REQ_MESSAGE_TYPE_LOCATION)) { + respContent = "您发送的是地理位置消息!"; + } + // 链接消息 + else if (msgType.equals(MessageUtil.REQ_MESSAGE_TYPE_LINK)) { + respContent = "您发送的是链接消息!"; + } + // 音频消息 + else if (msgType.equals(MessageUtil.REQ_MESSAGE_TYPE_VOICE)) { + respContent = "您发送的是音频消息!"; + } + // 事件推送 + else if (msgType.equals(MessageUtil.REQ_MESSAGE_TYPE_EVENT)) { + // 事件类型 + String eventType = requestMap.get("Event"); + // 订阅 + if (eventType.equals(MessageUtil.EVENT_TYPE_SUBSCRIBE)) { + respContent = "谢谢您的关注!"; + } + // 取消订阅 + else if (eventType.equals(MessageUtil.EVENT_TYPE_UNSUBSCRIBE)) { + // TODO 取消订阅后用户再收不到公众号发送的消息,因此不需要回复消息 + } + // 自定义菜单点击事件 + else if (eventType.equals(MessageUtil.EVENT_TYPE_CLICK)) { + // 事件KEY值,与创建自定义菜单时指定的KEY值对应 + String eventKey = requestMap.get("EventKey"); + + if (eventKey.equals("11")) { + respContent = "天气预报菜单项被点击!"; + } else if (eventKey.equals("12")) { + respContent = "公交查询菜单项被点击!"; + } else if (eventKey.equals("13")) { + respContent = "周边搜索菜单项被点击!"; + } else if (eventKey.equals("14")) { + respContent = "历史上的今天菜单项被点击!"; + } else if (eventKey.equals("21")) { + respContent = "歌曲点播菜单项被点击!"; + } else if (eventKey.equals("22")) { + respContent = "经典游戏菜单项被点击!"; + } else if (eventKey.equals("23")) { + respContent = "美女电台菜单项被点击!"; + } else if (eventKey.equals("24")) { + respContent = "人脸识别菜单项被点击!"; + } else if (eventKey.equals("25")) { + respContent = "聊天唠嗑菜单项被点击!"; + } else if (eventKey.equals("31")) { + respContent = "Q友圈菜单项被点击!"; + } else if (eventKey.equals("32")) { + respContent = "电影排行榜菜单项被点击!"; + } else if (eventKey.equals("33")) { + respContent = "幽默笑话菜单项被点击!"; + } + } + } + + textMessage.setContent(respContent); + respMessage = MessageUtil.textMessageToXml(textMessage); + */ + } catch (Exception e) { + e.printStackTrace(); + } + + return respMessage; + } +} diff --git a/src/main/java/me/mofun/admin/action/AdminIndexAction.java b/src/main/java/me/mofun/admin/action/AdminIndexAction.java new file mode 100644 index 0000000..064b0bc --- /dev/null +++ b/src/main/java/me/mofun/admin/action/AdminIndexAction.java @@ -0,0 +1,3381 @@ +package me.mofun.admin.action; + +import com.opensymphony.xwork2.ActionSupport; +import com.shcm.bean.SendResultBean; +import me.mofun.action.IndexAction; +import me.mofun.action.RegisterAction; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.*; +import me.mofun.util.*; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.struts2.ServletActionContext; +import org.jdesktop.swingx.util.OS; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.sql.Timestamp; +import java.util.*; + +@SuppressWarnings("unused") +@Component("AdminIndexAction") +public class AdminIndexAction extends ActionSupport{ + + private static final long serialVersionUID = 5983843029308947750L; + + @Autowired + private UserService userService; + @Autowired + private ProductService productService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private ProductTypeService productTypeService; + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private ProductImageService productImageService; + @Autowired + private NewsService newsService; + @Autowired + private NewsTypeService newsTypeService; + @Autowired + private ShareService shareService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ConsumerdetailService consumerdetailService; + @Autowired + private ConsumetableService consumetableService; + @Autowired + private CardpasswordService cardpasswordService; + @Autowired + private RecommendService recommendService; + @Autowired + private ApplymentionService applymentionService; + @Autowired + private OrderDetailAddressService orderDetailAddressService; + @Autowired + private SysConfigureService sysConfigureService; + + @Autowired + private ShopService shopService; + + + private Product product; + private Spellbuyproduct spellbuyproduct; + private ProductImage productimage; + private ProductType productType; + private News news; + private User user; + private Shareinfo shareinfo; + private Shareimage shareimage; + private List productTypeList; + private List productBrandList; + private List productList; + private List productimageList; + private List shareimageList; + + private List newsList; + private List newsTypeTopList; + private List newsTypeSubList; + + private List userList; + private List latestlotteryList; + private List ShareJSONList; + private ShareJSON shareJSON; + private Latestlottery latestlottery; + private List orderBeanList; + private List cardpasswordList; + private List applymentionList; + private List orderDetailAddressList; + private SysConfigure sysConfigure; + private List indexImgList; + private IndexImg indexImg; + private List suggestionList; + private List orderdetailList; + private OrderDetailAddress orderdetailaddress; + + private File myFile; + private String myFileFileName; + private String myFileContentType; + private String imageFileName; + private static final int BUFFER_SIZE = 100 * 1024 ; + + private int pageNo; + private String pages; + private String pageString; + private int pageSize = 20; + private int pageCount; + private int resultCount; + private String startDate; + private String endDate; + + private String id; + private String keyword; + private String userName; + private String pwd; + private String message; + private String userId; + private String announcedTime; + + private String typeId; + private String tId; + private String typeName; + private List productJSONList; + private ProductJSON productJSON; + + private List Filedata; // 默认的客户端文件对象,命名不符合java规范fileData + private List FiledataFileName; // 客户端文件名 + private List imageContentType; // 客户端文件名类型 + + private String channelUrl; + private String productTypeId; + //private DefaultHttpClient httpClient; + private HttpGet httpGet; + private HttpPost httpPost; + private String backUrl; + private SysInfoBean sysInfoBean; + + private Integer newsCategoryId; //新闻信息类型; + private Integer newsTypeParentId; //新闻信息所属类型的父类型Id,更新新闻文章时取用。 + + private Shop shop; + private Integer shopId; + + private List shopList; + + + public ConfigType setType; //管理员后端设置时的类型:基本设置/SEO设置/邮箱设置/短信设置/支付设置 + + HttpServletRequest request = null; + HttpServletResponse response = null; + + + //文件上传 + private static void copy(File src, File dst) { + try { + InputStream in = null ; + OutputStream out = null ; + try { + in = new BufferedInputStream( new FileInputStream(src), BUFFER_SIZE); + out = new BufferedOutputStream( new FileOutputStream(dst), BUFFER_SIZE); + byte [] buffer = new byte [BUFFER_SIZE]; + while (in.read(buffer) > 0 ) { + out.write(buffer); + } + } finally { + if ( null != in) { + in.close(); + } + if ( null != out) { + out.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String admin(){ + + return "index"; + } + + public String index(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + if(pageNo==0){ + pageNo = 1; + } + if(pages!=null){ + pageNo = Integer.parseInt(pages.split("_")[1]); + } + + //add by lwgboy + if(id==null) + id="hot20"; + + if(id.equals("hot20")){ + + Pagination hotPage = null; + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + hotPage = spellbuyrecordService.ProductByTypeIdList(typeId,"", "hot", pageNo, pageSize); + else + hotPage = spellbuyrecordService.ProductByTypeIdListAndShopId(user.getShopId(),typeId,"", "hot", pageNo, pageSize); + + List HotList = (List) hotPage.getList(); + productJSONList = new ArrayList(); + for (int i = 0; i < HotList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) HotList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) HotList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(product.getSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSONList.add(productJSON); + } + resultCount = hotPage.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&type="+typeId+"&pageNo="); + pageString = pageString.replace(".html", ""); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&pageNo="); + pageString = pageString.replace(".html", ""); + } + return "spellbuyProductList"; + }else if(id.equals("date20")){ + + Pagination datePage = spellbuyrecordService.ProductByTypeIdList(typeId,"", "date", pageNo, pageSize); + + List dateList = (List) datePage.getList(); + productJSONList = new ArrayList(); + for (int i = 0; i < dateList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) dateList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) dateList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(product.getSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSONList.add(productJSON); + } + resultCount = datePage.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&type="+typeId+"&pageNo="); + pageString = pageString.replace(".html", ""); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&pageNo="); + pageString = pageString.replace(".html", ""); + } + return "spellbuyProductList"; + }else if(id.equals("price20")){ + Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(typeId,"", "price", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + productJSONList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(product.getSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSONList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&type="+typeId+"&pageNo="); + pageString = pageString.replace(".html", ""); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&pageNo="); + pageString = pageString.replace(".html", ""); + } + return "spellbuyProductList"; + }else if(id.equals("priceAsc20")){ + Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(typeId,"", "priceAsc", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + productJSONList = new ArrayList(); + for (int i = 0; i < priceList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) priceList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) priceList.get(i)[1]; + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(product.getSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSONList.add(productJSON); + } + resultCount = pricePage.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&type="+typeId+"&pageNo="); + pageString = pageString.replace(".html", ""); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/index.action?id="+id+"&pageNo="); + pageString = pageString.replace(".html", ""); + } + return "spellbuyProductList"; + } + } + return "index_index"; + } + + /** + * 商品上架: + * 1、若竞品表中没有正在进行拍购的该商品,则向竞品表中插入一条该商品,并设置产品表中的 Attribute_71=竞拍期数; + * 2、若该商品是热门商品,则设置其对应竞品的 SpellbuyType=8 + * @return + */ + public String upSpellbuyproduct(){ + boolean canUpdate = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canUpdate = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canUpdate=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + // if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(canUpdate) { + product = productService.findById(id); + if(user.getUserName().equals("admin")||(product.getAuthorId()!=null&&user.getUserId().equals(product.getAuthorId()))) { //必须是管理员或产品发布者才能进行上架 + + spellbuyproduct = spellbuyproductService.findSpellbuyproductByStatus(product.getProductId()); + if(spellbuyproduct==null){ + int productPeriod = 0; + Spellbuyproduct spellbuyproduct = spellbuyproductService.findSpellbuyproductLastPeriod(product.getProductId()); + if(spellbuyproduct!=null){ + productPeriod = spellbuyproduct.getProductPeriod(); + productPeriod++; + }else{ + productPeriod = 1; + } + if(productPeriod > 0){ + spellbuyproduct = new Spellbuyproduct(); + spellbuyproduct.setFkProductId(product.getProductId()); + spellbuyproduct.setProductPeriod(productPeriod); + spellbuyproduct.setSpellbuyCount(0); + spellbuyproduct.setSpellbuyEndDate(DateUtil.DateTimeToStr(new Date())); + spellbuyproduct.setSpellbuyPrice(product.getProductPrice()); + spellbuyproduct.setSpSinglePrice(product.getSinglePrice()); + spellbuyproduct.setSpellbuyStartDate(DateUtil.DateTimeToStr(new Date())); + spellbuyproduct.setSpStatus(0); + if(product.getAttribute71().equals("hot")){ + spellbuyproduct.setSpellbuyType(8); + }else{ + spellbuyproduct.setSpellbuyType(0); + } + + //设置初始市场价(市场价为空时,设置市场价为0) +// if(spellbuyproduct.getMarketPrice()==null) +// spellbuyproduct.setMarketPrice(0F); + spellbuyproduct.setMarketPrice(product.getMarketPrice()); + + spellbuyproductService.add(spellbuyproduct); + product.setAttribute71(String.valueOf((productPeriod+1))); + } + + } + product.setStatus(1); + productService.add(product); + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("test"); + } + } + return null; + } + + /** + * 商品上架: + * 1、若竞品表中没有正在进行拍购的该商品,则向竞品表中插入一条该商品,并设置产品表中的 Attribute_71=竞拍期数; + * 2、若该商品是热门商品,则设置其对应竞品的 SpellbuyType=8 + * @return + */ + public String upSpellbuyproduct_old(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + product = productService.findById(id); + spellbuyproduct = spellbuyproductService.findSpellbuyproductByStatus(product.getProductId()); + if(spellbuyproduct==null){ + int productPeriod = 0; + Spellbuyproduct spellbuyproduct = spellbuyproductService.findSpellbuyproductLastPeriod(product.getProductId()); + if(spellbuyproduct!=null){ + productPeriod = spellbuyproduct.getProductPeriod(); + productPeriod++; + }else{ + productPeriod = 1; + } + if(productPeriod > 0){ + spellbuyproduct = new Spellbuyproduct(); + spellbuyproduct.setFkProductId(product.getProductId()); + spellbuyproduct.setProductPeriod(productPeriod); + spellbuyproduct.setSpellbuyCount(0); + spellbuyproduct.setSpellbuyEndDate(DateUtil.DateTimeToStr(new Date())); + spellbuyproduct.setSpellbuyPrice(product.getProductPrice()); + spellbuyproduct.setSpSinglePrice(product.getSinglePrice()); + spellbuyproduct.setSpellbuyStartDate(DateUtil.DateTimeToStr(new Date())); + spellbuyproduct.setSpStatus(0); + if(product.getAttribute71().equals("hot")){ + spellbuyproduct.setSpellbuyType(8); + }else{ + spellbuyproduct.setSpellbuyType(0); + } + + //设置初始市场价(市场价为空时,设置市场价为0) +// if(spellbuyproduct.getMarketPrice()==null) +// spellbuyproduct.setMarketPrice(0F); + spellbuyproduct.setMarketPrice(product.getMarketPrice()); + spellbuyproductService.add(spellbuyproduct); + + product.setAttribute71(String.valueOf((productPeriod+1))); + } + + } + product.setStatus(1); + productService.add(product); + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("test"); + } + } + return null; + } + + + + /** + * 下架商品 + */ + public void downSpellbuyproduct(){ + boolean canUpdate = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canUpdate = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return ;//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canUpdate=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + // if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(canUpdate) { + product = productService.findById(id); + if(user.getUserName().equals("admin")||(product.getAuthorId()!=null&&user.getUserId().equals(product.getAuthorId()))) { //必须是管理员或产品发布者才能进行上架 + + //product = productService.findById(id); + product.setStatus(2); + productService.add(product); + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("test"); + } + } + } + + public void hotProduct(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + try { + product = productService.findById(id); + product.setAttribute71("hot"); + productService.add(product); + List list = spellbuyproductService.findSpellbuyproductByProductIdIsStatus(Integer.parseInt(id)); + if(list!=null && list.size()>0){ + spellbuyproduct = list.get(0); + spellbuyproduct.setSpellbuyType(8); + spellbuyproductService.add(spellbuyproduct); + } + } catch (Exception e) { + e.printStackTrace(); + } + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("test"); + } + } + } + + public void downHotProduct(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + try { + product = productService.findById(id); + product.setAttribute71("0"); + productService.add(product); + List list = spellbuyproductService.findSpellbuyproductByProductIdIsStatus(Integer.parseInt(id)); + if(list!=null && list.size()>0){ + spellbuyproduct = list.get(0); + spellbuyproduct.setSpellbuyType(0); + spellbuyproductService.add(spellbuyproduct); + } + } catch (Exception e) { + e.printStackTrace(); + } + Struts2Utils.renderText("success"); + }else{ + Struts2Utils.renderText("test"); + } + } + } + + public String announcedProduct(){ + if(pageNo==0){ + pageNo = 1; + } + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + Pagination hotPage = spellbuyproductService.announcedProduct(pageNo, pageSize); + List HotList = (List) hotPage.getList(); + productJSONList = new ArrayList(); + for (int i = 0; i < HotList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) HotList.get(i)[0]; + spellbuyproduct = (Spellbuyproduct) HotList.get(i)[1]; + productJSON.setCurrentBuyCount(product.getProductId()); //商品ID,方便上架新一期商品 + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(product.getProductPrice()); + productJSON.setSinglePrice(product.getSinglePrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSONList.add(productJSON); + } + resultCount = hotPage.getResultCount(); + if(typeId!=null && !typeId.equals("")){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/announcedProduct.action?pageNo="); + pageString = pageString.replace(".html", ""); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/announcedProduct.action?pageNo="); + pageString = pageString.replace(".html", ""); + } + return "announcedProductList"; + } + return "index_index"; + } + + public String login(){ + if(!ApplicationListenerImpl.sysConfigureAuth){ + Struts2Utils.renderHtml("" + + "授权过期 ipdz.me 开发中心" + + "
    该系统授权已过期,请联系管理员重新授权!谢谢合作。www.ipdz.me
    "); + return null; + } + if(StringUtil.isBlank(userName)){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + user = userService.userByName(userName); + //只有网站工作人员能能登录后台. + if(user!=null && user.getUserType()!=null && "1".equals(user.getUserType())){ + String password = user.getUserPwd(); + if(StringUtil.isNotBlank(password) && password.equals(pwd)){ + Struts2Utils.getSession().setAttribute("admin", user); + String ip = Struts2Utils.getRequest().getHeader("X-Real-IP"); + if(ip==null){ + ip = Struts2Utils.getRequest().getRemoteAddr(); + } + String date = DateUtil.DateTimeToStr(new Date()); + user.setIpAddress(ip); + String ipLocation = RegisterAction.seeker.getAddress(ip); + user.setIpLocation(ipLocation); + user.setOldIpAddress(user.getIpAddress()+"("+user.getIpLocation()+")"); + user.setOldDate(user.getNewDate()); + user.setNewDate(date); + userService.add(user); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + return null; + } + + public String logOut(){ + Struts2Utils.getSession().removeAttribute("admin"); + return "index"; + } + + public String main(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + return "main"; + } + return "index_index"; + } + + public void numberCount(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + Pagination page = latestlotteryService.LatestAnnounced(pageNo, pageSize); + Pagination hotPage = spellbuyrecordService.ProductByTypeIdList(typeId,"", "hot", pageNo, pageSize); + Pagination page2 = shareService.loadPageShare("new20",pageNo, pageSize); + int userCount = userService.getCountUser(); + Long buyCount = Long.parseLong(spellbuyrecordService.getAllByCount().toString()); + int lotteryCount = page.getResultCount(); + int productCount = hotPage.getResultCount(); + int shareCount = page2.getResultCount(); + message = userCount+"_"+buyCount+"_"+productCount+"_"+lotteryCount+"_"+shareCount; + Struts2Utils.renderText(message); + } + } + + //转到新添加商品页面 + public String toAddProduct(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + productTypeList = productTypeService.queryAllProductType(); + productBrandList = productTypeService.listByBrand(null); + return "addProduct"; + } + return "index_index"; + } + + /** + * 新增商品入库 + * @return + * @throws Exception + */ + public String addProduct() throws Exception{ + boolean canUpdate = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canUpdate = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canUpdate=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canUpdate){ + String productImgPath = "/productImg/show"; + product.setAuthorId(user.getUserId()); + if(product.getShopId()==null) + product.setShopId(user.getShopId()); + productService.add(product); + try { + if(myFile!=null){ + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + imageFileName = new Date().getTime()+ myFileFileName; + File imageFile = new File(UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/", String.valueOf(product.getProductId()))+"/" + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(200, 200, imageFile, imageFile); + product.setHeadImage(productImgPath+"/"+String.valueOf(product.getProductId())+"/" + imageFileName); + } + } catch (Exception e) { + e.printStackTrace(); + } + product.setProductRealPrice(String.valueOf(product.getProductPrice())); + product.setStatus(0); + product.setAttribute71(String.valueOf(1)); + productService.add(product); + return "success"; +// if(user.getUserName().equals("admin")) +// return "success"; +// else +// return "success4normalUser"; + } + return "index_index"; + } + + public String toUpdate(){ + boolean canUpdate = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canUpdate = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),true); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canUpdate=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canUpdate) { + product = productService.findById(id); + if(!user.getUserName().equals("admin")&&product.getAuthorId()!=null&&!product.getAuthorId().equals(user.getUserId())) //必须是本用户名下的产品才能编辑 + return "index_index4normalUser"; + + productTypeList = productTypeService.queryAllProductType(); + productBrandList = productTypeService.listByBrand(null); + String queryString = Struts2Utils.getRequest().getQueryString(); + backUrl = queryString.substring(queryString.indexOf("backUrl=")+8, queryString.length()); + System.err.println(backUrl); + shopList = shopService.getShopListByUserId(user.getUserId(),true); + return "addProduct"; + } + return "index_index"; + } + + public void update() throws Exception{ + if(request==null) request = Struts2Utils.getRequest(); + if(request==null) response = Struts2Utils.getResponse(); + boolean canUpdate = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canUpdate = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return;//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canUpdate=true; + } + } + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + // if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(user!=null) { + if(canUpdate){ + String productImgPath = "/productImg/show"; + if(myFile!=null){ + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + imageFileName = new Date().getTime()+ myFileFileName; + File imageFile = new File(UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/", String.valueOf(product.getProductId()))+"/" + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(200, 200, imageFile, imageFile); + product.setHeadImage(productImgPath+"/"+String.valueOf(product.getProductId())+"/" + imageFileName); + } + spellbuyproduct = spellbuyproductService.findSpellbuyproductByStatus(product.getProductId()); + if(spellbuyproduct!=null){ + spellbuyproduct.setSpSinglePrice((product.getSinglePrice())); + + //设置初始市场价(市场价为空时,可设置市场价为0) + spellbuyproduct.setMarketPrice(product.getMarketPrice()); + + spellbuyproductService.add(spellbuyproduct); + } + if(product.getAuthorId()==null) + product.setAuthorId(user.getUserId()); + if(product.getShopId()==null) + product.setAuthorId(user.getShopId()); + productService.add(product); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + +// return "success"; + } +// return "index_index"; + } + + + public void deleteProduct(){ + boolean canUpdate = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canUpdate = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return ;//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canUpdate=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + // if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(canUpdate) { + try { + if(user.getUserName().equals("admin")) + productService.delete(Integer.parseInt(id)); + else + productService.deleteByUserId(user.getUserId(),Integer.parseInt(id)); + } catch (Exception e) { + e.printStackTrace(); + } + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + //} + } + + public String toAddProductType(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + productTypeList = productTypeService.queryAllProductType(); + if(id!=null){ + productType = productTypeService.findById(id); + } + return "addProductType"; + } + return "index_index"; + } + + public String addProductType(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(productType.getFtypeId()==null){ + productType.setFtypeId("1000"); + } + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + productType.setStypeId("0"); + productType.setAttribute70("type"); + if(productType.getTypeId()==null){ + if(productTypeService.findTypeByName(productType.getTypeName())!=null){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + }else{ + productTypeService.add(productType); + } + }else{ + productTypeService.add(productType); + } + return "addProductTypeSuccess"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + + } + return "index_index"; + } + + /** + * 获取所有商品类型列表 + * @return + */ + public String productTypeList(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + productTypeList = productTypeService.queryAllProductType(); + return "productTypeList"; + } + return "index_index"; + } + + /** + * 获取所有商品品牌列表(包含前台不想显示的) + * @return + */ + public String productBrandList(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + productTypeList = productTypeService.queryAllProductType(); + productBrandList = productTypeService.listByBrandAll(null); + return "productBrandList"; + } + return "index_index"; + } + + public String toAddProductBrand(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + productTypeList = productTypeService.queryAllProductType(); + if(id!=null){ + productType = productTypeService.findBrandById(id); + } + return "addProductBrand"; + } + return "index_index"; + } + + public String addProductBrand(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(productType.getFtypeId()==null){ + productType.setFtypeId("1000"); + } + productType.setStypeId("0"); + productType.setAttribute70("brand"); + if(productType.getTypeId()==null){ + if(productTypeService.findBrandByName(productType.getTypeName())!=null){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + }else{ + productTypeService.add(productType); + } + }else{ + productTypeService.add(productType); + } + return "addProductBrandSuccess"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + + } + return "index_index"; + } + + public String productList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),true); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + // if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + if(pageNo==0){ + pageNo = 1; + } + if(pages!=null){ + pageNo = Integer.parseInt(pages.split("_")[1]); + } + if(typeId==null){ + typeId = ""; + } + if(keyword==null){ + keyword = ""; + } + + if(shopId==null) + shopId=shopList.get(0).getShopId(); + + productTypeList = productTypeService.queryAllProductType(); + productBrandList = productTypeService.listByBrand(null); + Pagination datePage = null; + + if(user.getUserName().equals("admin")) + datePage = productService.searchProduct(typeId,keyword, pageNo, pageSize); + else + datePage = productService.searchProductByShopId(shopId,typeId,keyword, pageNo, pageSize); + + productList = (List) datePage.getList(); + resultCount = datePage.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/productList.action?typeId="+typeId+"&keyword="+keyword+"&pageNo="); + pageString = pageString.replace(".html", ""); + + if(user.getUserName().equals("admin")) + return "productList"; + else + return "productList4normalUser"; + } + return "index_index"; + } + + //转到到商品详情页橱窗去添加图片 + public String toAddProductImg(){ + boolean canUpdate = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canUpdate = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),true); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canUpdate=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canUpdate) { + if(user.getUserName().equals("admin")) + productimageList = productImageService.findByProductId(id, "show"); + else + productimageList = productImageService.findByProductIdByUserId(user.getUserId(),id, "show"); + return "addProductImg"; + } + return "index_index"; + } + + //在商品详情页橱窗区添加图片 + public String addProductImg() throws Exception{ + boolean canUpdate = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canUpdate = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canUpdate=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + // if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(canUpdate) { + product = productService.findById(id); + if(user.getUserName().equals("admin")||(product!=null&&product.getAuthorId()!=null&&product.getAuthorId().equals(user.getUserId()))){ + String productImgPath = "/productImg/imagezoom"; + long fileDateName = 0; + String imagePath = null; + if (Filedata == null || Filedata.size() == 0){ + return null; + } + for (int i = 0; i < Filedata.size(); ++i){ + try { + myFile = Filedata.get(i); + if(myFile!=null){ + myFileFileName = FiledataFileName.get(i).substring(FiledataFileName.get(i).lastIndexOf("."), FiledataFileName.get(i).length()); + fileDateName = new Date().getTime(); + imageFileName = fileDateName + myFileFileName; + imagePath = UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/", id)+"/"; + File imageFile = new File(imagePath + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(310, 310, imageFile, new File(imagePath+fileDateName+"_mid"+myFileFileName)); + CutImages.equimultipleConvert(40, 40, imageFile, new File(imagePath+fileDateName+"_small"+myFileFileName)); + productimage = new ProductImage(); + productimage.setProductId(Integer.parseInt(id)); + productimage.setImage(String.valueOf(fileDateName)); + productimage.setImageType(myFileFileName); + productimage.setIsShow("show"); + productimage.setImageName(fileDateName+myFileFileName); + productimage.setUserId(user.getUserId()); + productimage.setCreateTime(new Timestamp(new Date().getTime())); + productImageService.add(productimage); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + return null; + } + + public void doDeleteProductImg(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + try { + productImageService.delete(Integer.parseInt(id)); + } catch (Exception e) { + e.printStackTrace(); + } + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + + } + + public String toAddSpellbuyProduct(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + return "addSpellbuyProduct"; + } + return "index_index"; + } + + public String addSpellbuyProduct(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + return "spellbuyProductList"; + } + return "index_index"; + } + + + //商品详情内容区图片上传 + public String uploadImages() throws Exception{ + String productImgPath = "/productImg/detail"; + String filePrefixName = null; + String fileExtName= null; + String imagePath = null; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user = (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")){ + if (Filedata == null || Filedata.size() == 0){ + return null; + } + for (int i = 0; i < Filedata.size(); ++i){ + myFile = Filedata.get(i); + if(myFile!=null){ + fileExtName = FiledataFileName.get(i).substring(FiledataFileName.get(i).lastIndexOf("."), FiledataFileName.get(i).length()).toLowerCase(); + filePrefixName = ""+new Date().getTime(); + imageFileName = filePrefixName + fileExtName; + imagePath = UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/",DateUtil.dateToStr(new Date()))+"/"; + File imageFile = new File(imagePath + imageFileName); + copy(myFile, imageFile); + + ProductImage pi = new ProductImage(); + pi.setImage(filePrefixName); + pi.setImageType(fileExtName); + pi.setImageName(imageFileName); + pi.setUserId(user.getUserId()); + pi.setShopId(shopId); + pi.setCreateTime(new Timestamp(new Date().getTime())); + pi.setIsShow("show"); + pi.setStatus(0); + productImageService.add(pi); + } + } + } + }else { + if(request==null) request = Struts2Utils.getRequest(); + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "login_index"; //需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + if (Filedata == null || Filedata.size() == 0){ + return null; + } + for (int i = 0; i < Filedata.size(); ++i){ + myFile = Filedata.get(i); + if(myFile!=null){ + fileExtName = FiledataFileName.get(i).substring(FiledataFileName.get(i).lastIndexOf("."), FiledataFileName.get(i).length()).toLowerCase(); + filePrefixName = ""+new Date().getTime(); + imageFileName = filePrefixName + fileExtName; + imagePath = UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/",DateUtil.dateToStr(new Date()))+"/"; + File imageFile = new File(imagePath + imageFileName); + copy(myFile, imageFile); + + ProductImage pi = new ProductImage(); + pi.setImage(filePrefixName); + pi.setImageType(fileExtName); + pi.setImageName(imageFileName); + pi.setUserId(user.getUserId()); + pi.setShopId(shopId); + pi.setCreateTime(new Timestamp(new Date().getTime())); + pi.setIsShow("show"); + pi.setStatus(0); + productImageService.add(pi); + } + + } + } + } +// else +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// } + +// } + return null; + } + + public String crawl(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + productTypeList = productTypeService.queryAllProductType(); + return "crawl"; + } + return "index_index"; + } + + public String doCrawl() throws Exception{ + if(pages!=null && !pages.equals("")){ + String url = ""; + int page = Integer.parseInt(pages); + for (int i = 1; i < page; i++) { + try { +// http://www.360buy.com/products/652-653-655-0-0-0-0-0-0-0-1-1-1.html +// http://www.360buy.com/products/670-677-688-0-0-0-0-0-0-0-1-1-2.html +// http://www.360buy.com/products/737-794-798-0-0-0-0-0-0-0-1-1-1-1-72-33.html +// http://www.360buy.com/products/737-794-798-0-0-0-0-0-0-0-1-1-1-1-72-0.html + url = channelUrl.substring(0,channelUrl.lastIndexOf("0-1-1-")+6); + url += i+ channelUrl.substring(channelUrl.lastIndexOf("0-1-1-")+7,channelUrl.length()); + System.err.println(url); + Document document = Jsoup.parse(new URL(url), 60000); + Elements elements = null; + elements = document.select("div.plist > ul > li"); + if(elements.size()==0){ + elements = document.select("div#plist > ul > li"); + } + for (Element element : elements) { + try { + String productImg = ""; + String productName = ""; + String productTitle= ""; + int productPrice = 0; + int productRealPrice = 0; + String productDetail = ""; + String headImage = ""; + String Attribute_71 = "1"; + String strImg = element.select("div.p-img > a > img").first().attr("src"); + if(strImg.indexOf("360buyimg.com")!=-1){ + productImg = strImg; + }else{ + String strImg2 = element.select("div.p-img > a > img").first().attr("src2"); + productImg = strImg2; + } + productImg = productImg.replace(".com/n2/", ".com/n1/"); + productName = element.select("div.p-name > a").text(); + product = productService.findProductByName(productName); + if(product==null){ + product = new Product(); + String proUrl = element.select("div.p-name > a").attr("href"); + System.err.println(proUrl); + File myFile = saveURLFile(productImg); + + String myFileFileName = myFile.getName(); + product.setAttribute71("1"); + product.setProductType(Integer.parseInt(productTypeId)); + product.setProductDetail(proUrl); + product.setProductName(productName); + product.setProductPrice(0); + product.setProductRealPrice(String.valueOf(0)); + product.setProductTitle(productName); + product.setStatus(0); + productService.add(product); + String productImgPath = "/productImg/show"; + if(myFile!=null){ + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + String imageFileName = new Date().getTime()+ myFileFileName; + File imageFile = new File(UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/", String.valueOf(product.getProductId()))+"/" + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(200, 200, imageFile, imageFile); + product.setHeadImage(productImgPath+"/"+String.valueOf(product.getProductId())+"/" + imageFileName); + } + + productService.add(product); + + Document document2 = Jsoup.parse(new URL(proUrl), 60000); +// System.err.println(document2); + Elements element2 = document2.select("div.spec-items > ul > li"); + int count = 0; + for (Element element3 : element2) { + try { + count ++; + String img = element3.select("img").attr("src"); +// http://img14.360buyimg.com/n0/g9/M03/0D/12/rBEHaVCXVAsIAAAAAADw0WaBZaIAACptQFzb24AAPDp968.jpg +// http://img14.360buyimg.com/n5/g9/M03/0D/12/rBEHaVCXVAsIAAAAAADw0WaBZaIAACptQFzb24AAPDp968.jpg + + img = img.replace(".com/n5/", ".com/n0/"); + System.err.println(img); + productimage = new ProductImage(); + String productImgPath2 = "/productImg/imagezoom"; + long fileDateName = 0; + String imagePath = null; + File myFile2 = saveURLFile(img); + String myFileFileName2 = myFile2.getName(); + if(myFile2!=null){ + myFileFileName2 = myFileFileName2.substring(myFileFileName2.lastIndexOf("."), myFileFileName2.length()); + fileDateName = new Date().getTime(); + String imageFileName = fileDateName + myFileFileName; + imagePath = UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath2)+"/", String.valueOf(product.getProductId()))+"/"; + File imageFile = new File(imagePath + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(310, 310, imageFile, new File(imagePath+fileDateName+"_mid"+myFileFileName)); + CutImages.equimultipleConvert(40, 40, imageFile, new File(imagePath+fileDateName+"_small"+myFileFileName)); + productimage.setProductId(product.getProductId()); + productimage.setImage(String.valueOf(fileDateName)); + productimage.setImageType(myFileFileName); + productimage.setIsShow("show"); + productImageService.add(productimage); + } + if(count ==6){ + break; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + System.err.println("结束"); + Struts2Utils.renderText("结束"); + return null; + } + + public String doCrawlShare() throws Exception{ + if(pages!=null && !pages.equals("")){ + String url = ""; + int page = Integer.parseInt(pages); + for (int i = 1; i < page; i++) { + try { +// http://www.360buy.com/products/652-653-655-0-0-0-0-0-0-0-1-1-1.html +// http://www.360buy.com/products/670-677-688-0-0-0-0-0-0-0-1-1-2.html +// http://www.360buy.com/products/737-794-798-0-0-0-0-0-0-0-1-1-1-1-72-33.html +// http://www.360buy.com/products/737-794-798-0-0-0-0-0-0-0-1-1-1-1-72-0.html + url = channelUrl.substring(0,channelUrl.lastIndexOf("0-1-1-")+6); + url += i+ channelUrl.substring(channelUrl.lastIndexOf("0-1-1-")+7,channelUrl.length()); + System.err.println(url); + Document document = Jsoup.parse(new URL(url), 60000); + Elements elements = null; + elements = document.select("div.plist > ul > li"); + if(elements.size()==0){ + elements = document.select("div#plist > ul > li"); + } + for (Element element : elements) { + try { + String productImg = ""; + String productName = ""; + String productTitle= ""; + int productPrice = 0; + int productRealPrice = 0; + String productDetail = ""; + String headImage = ""; + String Attribute_71 = "1"; + String strImg = element.select("div.p-img > a > img").first().attr("src"); + if(strImg.indexOf("360buyimg.com")!=-1){ + productImg = strImg; + }else{ + String strImg2 = element.select("div.p-img > a > img").first().attr("src2"); + productImg = strImg2; + } + productImg = productImg.replace(".com/n2/", ".com/n1/"); + productName = element.select("div.p-name > a").text(); + product = productService.findProductByName(productName); + if(product==null){ + product = new Product(); + String proUrl = element.select("div.p-name > a").attr("href"); + System.err.println(proUrl); + File myFile = saveURLFile(productImg); + + String myFileFileName = myFile.getName(); + product.setAttribute71("1"); + product.setProductType(Integer.parseInt(productTypeId)); + product.setProductDetail(proUrl); + product.setProductName(productName); + product.setProductPrice(0); + product.setProductRealPrice(String.valueOf(0)); + product.setProductTitle(productName); + product.setStatus(0); + productService.add(product); + String productImgPath = "/productImg/show"; + if(myFile!=null){ + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + String imageFileName = new Date().getTime()+ myFileFileName; + File imageFile = new File(UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/", String.valueOf(product.getProductId()))+"/" + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(200, 200, imageFile, imageFile); + product.setHeadImage(productImgPath+"/"+String.valueOf(product.getProductId())+"/" + imageFileName); + } + + productService.add(product); + + Document document2 = Jsoup.parse(new URL(proUrl), 60000); +// System.err.println(document2); + Elements element2 = document2.select("div.spec-items > ul > li"); + int count = 0; + for (Element element3 : element2) { + try { + count ++; + String img = element3.select("img").attr("src"); +// http://img14.360buyimg.com/n0/g9/M03/0D/12/rBEHaVCXVAsIAAAAAADw0WaBZaIAACptQFzb24AAPDp968.jpg +// http://img14.360buyimg.com/n5/g9/M03/0D/12/rBEHaVCXVAsIAAAAAADw0WaBZaIAACptQFzb24AAPDp968.jpg + + img = img.replace(".com/n5/", ".com/n0/"); + System.err.println(img); + productimage = new ProductImage(); + String productImgPath2 = "/productImg/imagezoom"; + long fileDateName = 0; + String imagePath = null; + File myFile2 = saveURLFile(img); + String myFileFileName2 = myFile2.getName(); + if(myFile2!=null){ + myFileFileName2 = myFileFileName2.substring(myFileFileName2.lastIndexOf("."), myFileFileName2.length()); + fileDateName = new Date().getTime(); + String imageFileName = fileDateName + myFileFileName; + imagePath = UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath2)+"/", String.valueOf(product.getProductId()))+"/"; + File imageFile = new File(imagePath + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(310, 310, imageFile, new File(imagePath+fileDateName+"_mid"+myFileFileName)); + CutImages.equimultipleConvert(40, 40, imageFile, new File(imagePath+fileDateName+"_small"+myFileFileName)); + productimage.setProductId(product.getProductId()); + productimage.setImage(String.valueOf(fileDateName)); + productimage.setImageType(myFileFileName); + productimage.setIsShow("show"); + productImageService.add(productimage); + } + if(count ==6){ + break; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + System.err.println("结束"); + Struts2Utils.renderText("结束"); + return null; + } + + public static File saveURLFile(String fileUrl) throws MalformedURLException{ + File file = null; + try{ + URL url = new URL(fileUrl); + String myFileFileName = fileUrl; + URLConnection connect = url.openConnection(); + connect.connect(); + InputStream input = connect.getInputStream(); + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + String image = ServletActionContext.getServletContext().getRealPath("/uploadImages")+"/"+"imageTemp"+myFileFileName; + file = new File(image); + //创建一个输出流 + OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); + //每次的写入大小为: + int length=1024*1024; + byte[] a = new byte[length]; + //如果大小大于length继续循环,否则值为-1 + while((length=input.read(a))>0){ + out.write(a, 0, length); + } + //别忘了关闭流 + input.close(); + out.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return file; + } + + public String toAddNews(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + //获取顶级类型列表 + newsTypeTopList = newsTypeService.indexNewsTypeByParentId(0); + //System.out.println(groupTopList.get(0).getId()); + return "addNews"; + } + return "index_index"; + } + + //获取分类列表,供前台ajax调用: + public String getCategoryList(){ + + return null; + } + + public String addNews(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(news.getPostDate()==null || news.getPostDate().equals("")){ + news.setPostDate(DateUtil.DateToStr(new Date())); + } + newsService.add(news); + return "successNews"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + + } + return "index_index"; + } + + public String toUpdateNews(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + news = newsService.findById(id); + //获取顶级类型列表 + newsTypeTopList = newsTypeService.indexNewsTypeByParentId(0); + + //根据新闻所属类别ID,找出文章新闻类型,进而根据其 parentId,找出父类型的所有子类型; + NewsType selfType = newsTypeService.findById(news.getCategoryId().toString()); + newsTypeParentId = selfType.getParentId(); + newsTypeSubList = newsTypeService.indexNewsTypeByParentId(selfType.getParentId()); + + return "addNews"; + } + return "index_index"; + } + + public String updateNews(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + newsService.add(news); + return "successNews"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + } + return "index_index"; + } + + public String deleteNews(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + newsService.delete(Integer.parseInt(id)); + return "successNews"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + return "index_index"; + } + + public String newsList(){ + if(pageNo==0){ + pageNo = 1; + } + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + Pagination datePage = newsService.newsList(pageNo, pageSize); + newsList = (List) datePage.getList(); + resultCount = datePage.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/newsList.action?pageNo="); + pageString = pageString.replace(".html", ""); + return "newsList"; + } + + return "index_index"; + } + + /** + * 更新首页新闻 + */ + public String replaceNews(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + //拍购版: + //IndexAction.newsList = newsService.indexNews(); + + IndexAction.newsList = newsService.indexNews(1,3); //电商版 + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + + } + return null; + } + + public String indexImgAll(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + indexImgList = sysConfigureService.IndexImgAll(); + return "indexImgAll"; + } + return "index_index"; + } + + public String toAddIndexImg(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(StringUtil.isNotBlank(id)){ + indexImg = sysConfigureService.findByIndexImgId(id); + } + return "toIndexImg"; + } + return "index_index"; + } + + public void doAddIndexImg() throws Exception{ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + String productImgPath = "/productImg/show"; + try { + if(myFile!=null){ + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + imageFileName = new Date().getTime()+ myFileFileName; + File imageFile = new File(UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/", "indexImg")+"/" + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(992, 420, imageFile, imageFile); + indexImg.setProImg(productImgPath+"/"+"indexImg"+"/" + imageFileName); + } + } catch (Exception e) { + e.printStackTrace(); + } + sysConfigureService.addIndexImg(indexImg); + ApplicationListenerImpl.indexImgAll = sysConfigureService.initializationIndexImgAll(); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + } + + public void delIndexImg(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + sysConfigureService.delIndexImg(Integer.parseInt(id)); + ApplicationListenerImpl.indexImgAll = sysConfigureService.initializationIndexImgAll(); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + } + + public String suggestion(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(pageNo==0){ + pageNo = 1; + } + Pagination page = sysConfigureService.suggestionList(pageNo, pageSize); + suggestionList = (List) page.getList(); + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/suggestion.action?pageNo="); + pageString = pageString.replace(".html", ""); + return "suggestion"; + } + return "index_index"; + } + + + public String shareList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + if(pageNo==0){ + pageNo = 1; + } + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + + Pagination page = shareService.adminShareList(typeId,id, pageNo, pageSize); + List pageList = (List) page.getList(); + ShareJSONList = new ArrayList(); + for (int i = 0; i < pageList.size(); i++) { + shareJSON = new ShareJSON(); + shareinfo = (Shareinfo) pageList.get(i)[0]; + latestlottery = (Latestlottery) pageList.get(i)[1]; + String userName = ""; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userName = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userName = latestlottery.getBuyUser(); + if(userName.indexOf("@")!=-1){ + String[] u = userName.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userName = u1+"@"+u[1]; + }else{ + userName = userName.substring(0,4)+ "*** "+userName.substring(7); + } + } + shareJSON.setAnnouncedTime(latestlottery.getAnnouncedTime().substring(0,10)); + shareJSON.setReplyCount(shareinfo.getReplyCount()); + shareJSON.setReward(shareinfo.getReward()); + shareJSON.setShareContent(shareinfo.getShareContent()); + shareJSON.setShareDate(shareinfo.getShareDate()); + shareJSON.setShareTitle(shareinfo.getShareTitle()); + shareJSON.setUid(shareinfo.getUid()); + shareJSON.setUpCount(shareinfo.getUpCount()); + shareJSON.setUserName(userName); + shareJSON.setStatus(shareinfo.getStatus()); + ShareJSONList.add(shareJSON); + } + + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/shareList.action?id="+id+"&typeId="+typeId+"&pageNo="); + pageString = pageString.replace(".html", ""); + return "shareList"; + } + return "index_index"; + } + + /** + * 未发货订单 + * @return + */ + public String latestOrderList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + + if(pageNo==0){ + pageNo = 1; + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + Pagination page = latestlotteryService.LatestAnnounced(pageNo, pageSize); + resultCount = page.getResultCount(); + List objList = (List) page.getList(); + latestlotteryList = new ArrayList(); + for (int i = 0; i < objList.size(); i++) { + latestlottery = new Latestlottery(); + latestlottery = objList.get(i); + String userName = ""; + if(latestlottery.getUserName()!=null && !latestlottery.getUserName().equals("")){ + userName = latestlottery.getUserName(); + }else if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userName = latestlottery.getBuyUser(); + if(userName.indexOf("@")!=-1){ + String[] u = userName.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userName = u1+"@"+u[1]; + }else{ + userName = userName.substring(0,4)+ "*** "+userName.substring(7); + } + } + latestlottery.setBuyUser(userName); + latestlotteryList.add(latestlottery); + } + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/latestList.action?id="+id+"&pageNo="); + pageString = pageString.replace(".html", ""); + return "latestOrderList"; + } + return "index_index"; + } + + public String toPostDeliver(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + latestlottery = latestlotteryService.findById(id); + orderdetailaddress = latestlotteryService.orderDetailAddressFindByOrderDetailId(id); + return "postDeliver"; + } + return "index_index"; + } + + public String doPostDeliver(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + orderDetailAddressService.add(orderdetailaddress); + latestlottery = latestlotteryService.findById(id); + latestlottery.setStatus(3); + latestlotteryService.add(latestlottery); + return "postDeliverSuccess"; + } + return "index_index"; + } + + public String toAddShare(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + return "addShare"; + } + return "index_index"; + } + + public String addShare(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(shareinfo.getShareDate()==null || shareinfo.getShareDate().equals("")){ + shareinfo.setShareDate(DateUtil.DateTimeToStr(new Date())); + } + shareinfo.setUpCount(0); + shareinfo.setReplyCount(0); + shareinfo.setReward(0); + shareService.add(shareinfo); + latestlottery = latestlotteryService.findById(String.valueOf(shareinfo.getProductId())); + latestlottery.setShareStatus(0); + latestlottery.setShareId(shareinfo.getUid()); + latestlotteryService.add(latestlottery); + return "successShare"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + } + return "index_index"; + } + + public String toAddShareImage(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + shareimageList = shareService.getShareimage(id); + return "toAddShareImage"; + } + return "index_index"; + } + + public String addShareImage() throws Exception{ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + String productImgPath = "/userPost"; + long fileDateName = 0; + String biGImagePath = null; + String smallImagePath = null; + String listImgPath = null; + if (Filedata == null || Filedata.size() == 0){ + return null; + } + for (int i = 0; i < Filedata.size(); ++i){ + myFile = Filedata.get(i); + if(myFile!=null){ + myFileFileName = FiledataFileName.get(i).substring(FiledataFileName.get(i).lastIndexOf("."), FiledataFileName.get(i).length()); + fileDateName = new Date().getTime(); + imageFileName = fileDateName + myFileFileName; + biGImagePath = ServletActionContext.getServletContext().getRealPath(productImgPath)+"/big/"; + smallImagePath = ServletActionContext.getServletContext().getRealPath(productImgPath)+"/small/"; + listImgPath = ServletActionContext.getServletContext().getRealPath(productImgPath)+"/220/"; + File bigImageFile = new File(biGImagePath + imageFileName); + File smallImageFile = new File(smallImagePath + imageFileName); + File listImageFile = new File(smallImagePath + imageFileName); + copy(myFile, bigImageFile); + copy(myFile, smallImageFile); + copy(myFile, listImageFile); + CutImages.equimultipleConvert(560, 420, bigImageFile, new File(biGImagePath+fileDateName+myFileFileName)); + CutImages.equimultipleConvert(220, 220, listImageFile, new File(listImgPath+fileDateName+myFileFileName)); + CutImages.equimultipleConvert(100, 100, smallImageFile, new File(smallImagePath+fileDateName+myFileFileName)); + shareimage = new Shareimage(); + shareimage.setShareInfoId(Integer.parseInt(id)); + shareimage.setImages(fileDateName+myFileFileName); + shareService.addShareImage(shareimage); + } + } + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + } + return "index_index"; + } + + public String toUpdateShare(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + shareimageList = shareService.getShareimage(id); + shareinfo = shareService.findById(id); + return "addShare"; + } + return "index_index"; + } + + public String updateShare(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + shareService.add(shareinfo); + return "successShare"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + + } + return "index_index"; + } + + /** + * 会员列表 + * @return + */ + public String userListAll(){ + + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + if(pageNo==0){ + pageNo = 1; + } + if(typeName==null){ + typeName = ""; + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + Pagination page = null; + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + page = userService.adminUserList(typeId,keyword,typeName,pageNo, pageSize); + else + page = userService.getColleaguesList(user.getUserId(), typeId,keyword,typeName,pageNo, pageSize); + + userList = (List) page.getList(); + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/userListAll.action?typeName="+typeName+"&pageNo="); + pageString = pageString.replace(".html", ""); + return "userList"; + } + return "index_index"; + } + + public String toAddUser(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + + return "toAddUser"; + } + return "index_index"; + } + + public String toUpdateUser(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user = userService.findById(id); + return "toAddUser"; + } + return "index_index"; + } + + public void doUpdateUser(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + userService.add(user); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + } + + public String doAddUser(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(StringUtil.isNotBlank(user.getMail())){ + User u = userService.userByName(user.getMail()); + if(u!=null){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + } + if(StringUtil.isNotBlank(user.getPhone())){ + User u2 = userService.userByName(user.getPhone()); + if(u2!=null){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + } + if(user.getCommissionBalance()==null){ + user.setCommissionBalance(0.00); + } + if(user.getCommissionCount()==null){ + user.setCommissionCount(0.00); + } + if(user.getCommissionMention()==null){ + user.setCommissionMention(0.00); + } + if(user.getCommissionPoints()==null){ + user.setCommissionPoints(0); + } + if(user.getExperience()==null){ + user.setExperience(0); + } + if(user.getBalance()==null){ + user.setBalance(0.00); + } + String date = DateUtil.DateTimeToStr(new Date()); + user.setOldDate(date); + user.setFaceImg("/Images/defaultUserFace.png"); + userService.add(user); + return "addUserSuccess"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + + } + return "index_index"; + } + + /** + * 会员福利配置 + * @return + */ + public String toUserConfigure(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),true); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + //if(canNext) { + sysConfigure = ApplicationListenerImpl.sysConfigureJson; + return "toUserConfigure"; + } + return "index_index"; + } + + public String sysInfo(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ +// HttpServletRequest request = Struts2Utils.getRequest();; +// String path = request.getContextPath(); +// String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +// ResourceBundle url = ResourceBundle.getBundle("config"); +// sysInfoBean = new SysInfoBean(); +// sysInfoBean.setAlipayKey(url.getString("alipayKey")); +// sysInfoBean.setAlipayMail(url.getString("alipayMail")); +// sysInfoBean.setAlipayPartner(url.getString("alipayPartner")); +// sysInfoBean.setDomain(url.getString("domain")); +// sysInfoBean.setIcp(url.getString("icp")); +// sysInfoBean.setImg(url.getString("img")); +// sysInfoBean.setKeyword(url.getString("keyword")); +// sysInfoBean.setDescription(url.getString("description")); +// sysInfoBean.setMailName(url.getString("mailName")); +// sysInfoBean.setMailPwd(url.getString("mailPwd")); +// sysInfoBean.setSiteName(url.getString("siteName")); +// sysInfoBean.setSiteUrl(url.getString("www")); +// sysInfoBean.setSkin(url.getString("skin")); +// sysInfoBean.setTenpayKey(url.getString("tenpayKey")); +// sysInfoBean.setTenpayPartner(url.getString("tenpayPartner")); + + sysConfigure = ApplicationListenerImpl.sysConfigureJson; + + return "sysInfo"; + } + return "index_index"; + + } + + public String setSysInfo() { + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + Properties properties = new Properties(); + try + { + OutputStream outputStream = new FileOutputStream(ServletActionContext.getServletContext().getRealPath("/WEB-INF/classes")+"/"+"config.properties"); + properties.setProperty("alipayKey", sysInfoBean.getAlipayKey()); + properties.setProperty("alipayMail", sysInfoBean.getAlipayMail()); + properties.setProperty("alipayPartner",sysInfoBean.getAlipayPartner()); + properties.setProperty("domain",sysInfoBean.getDomain()); + properties.setProperty("icp",sysInfoBean.getIcp()); + properties.setProperty("img",sysInfoBean.getImg()); + properties.setProperty("keyword",sysInfoBean.getKeyword()); + properties.setProperty("description",sysInfoBean.getDescription()); + properties.setProperty("mailName",sysInfoBean.getMailName()); + properties.setProperty("mailPwd",sysInfoBean.getMailPwd()); + properties.setProperty("siteName",sysInfoBean.getSiteName()); + properties.setProperty("www",sysInfoBean.getSiteUrl()); + properties.setProperty("skin",sysInfoBean.getSkin()); + properties.setProperty("tenpayKey",sysInfoBean.getAlipayKey()); + properties.setProperty("tenpayPartner",sysInfoBean.getTenpayPartner()); + properties.setProperty("upfilefolder","productImg/"); + properties.store(outputStream, "author: taobao@hz.cn"); + outputStream.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + return "main"; + } + return "index_index"; + } + + public void restartTomcat() throws IOException, InterruptedException{ + String windowsPath = "D:\\tomcat\\bin"; + String linuxPath = "/usr/bin/ye"; + List cmd = new ArrayList(); + if (OS.isWindows()) { + cmd.add(windowsPath); + } else if (OS.isLinux()) { + cmd.add(linuxPath); + } + ProcessBuilder pb = new ProcessBuilder(); + pb.command(cmd); + pb.redirectErrorStream(true); + Process process = pb.start(); + int w = process.waitFor(); + System.out.println("status:"+w); + + } + + //订单列表 + public String orderList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext){ + if(pageNo==0){ + pageNo = 1; + } + + Pagination page = null; + if(user.getUserName()!=null&&user.getUserName().equals("admin")) + page = consumetableService.orderList(userName, pageNo, pageSize); + else + page = consumetableService.getUserAllShopOrderList(user.getUserId(), pageNo, pageSize); + + List list = (List) page.getList(); + orderBeanList = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + OrderBean orderBean = new OrderBean(); + Consumetable consumetable = list.get(i); + orderBean.setOutTradeNo(consumetable.getOutTradeNo()); + orderBean.setBuyCount(consumetable.getBuyCount()); + orderBean.setDate(consumetable.getDate()); + orderBean.setMoney(consumetable.getMoney()); + if(consumetable.getInterfaceType().equals("tenPay")){ + orderBean.setPayType("财付通"); + }else if(consumetable.getInterfaceType().equals("aliPay")){ + orderBean.setPayType("支付宝"); + }if(consumetable.getInterfaceType().equals("yeePay")){ + orderBean.setPayType("易宝支付"); + }else{ + orderBean.setPayType("余额支付"); + } + orderBean.setUserId(consumetable.getUserId()); + orderBeanList.add(orderBean); + } + resultCount = page.getResultCount(); + if(StringUtil.isNotBlank(userName)){ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/orderList.action?userName="+userName+"&pageNo="); + }else{ + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/orderList.action?pageNo="); + } + pageString = pageString.replace(".html", ""); + return "orderList"; + } + + return "index_index"; + } + + //订单详情 + public String orderInfo(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + if(pageNo==0){ + pageNo = 1; + } + Pagination page = consumerdetailService.orderInfo(id, pageNo, pageSize); + List list = (List) page.getList(); + orderBeanList = new ArrayList(); + for (Consumerdetail consumerdetail : list) { + OrderBean orderBean = new OrderBean(); + orderBean.setBuyCount(consumerdetail.getBuyCount()); + orderBean.setMoney(consumerdetail.getBuyMoney()); + orderBean.setSpellBuyProductId(consumerdetail.getSpellBuyProductId()); + orderBean.setProductName(consumerdetail.getProductName()); + orderBean.setProductPeriod(consumerdetail.getProductPeriod()+""); + orderBeanList.add(orderBean); + } + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/orderInfo.action?pageNo="); + pageString = pageString.replace(".html", ""); + return "orderInfo"; + } + return "index_index"; + } + + /** + * 卡密管理 + * @return + */ + public String cardList(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(pageNo==0){ + pageNo = 1; + } + Pagination page = cardpasswordService.cardRechargeList(pageNo, pageSize); + cardpasswordList = (List) page.getList(); + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/cardList.action?pageNo="); + pageString = pageString.replace(".html", ""); + return "cardList"; + } + return "index_index"; + } + + /** + * 首页推荐 + */ + public void indexTop(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + try { + Recommend recommend = new Recommend(); + recommend.setDate(DateUtil.DateToStr(new Date())); + recommend.setRecommendId(1); + recommend.setSpellbuyProductId(Integer.parseInt(id)); + recommendService.add(recommend); + Struts2Utils.renderText("success"); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.renderText("error"); + } + }else{ + Struts2Utils.renderText("test"); + } + } + + + } + + public String toAddCard(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + return "addCard"; + } + return "index_index"; + } + + /** + * 生成卡密 + * @throws InterruptedException + */ + public void doCard() throws InterruptedException{ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(pwd)){ + List cardpasswordList = new ArrayList(); + for (int i = 0; i < Integer.parseInt(id); i++) { + try { + Thread.sleep(100); + String s = UUID.randomUUID().toString().toUpperCase(); + s = s.substring(0,8)+s.substring(9,13)+s.substring(14,18)+s.substring(19,23)+s.substring(24); + String md5s = MD5Util.encode(s); + String key = s+ md5s; + Cardpassword cardpassword = new Cardpassword(); + cardpassword.setCardPwd(md5s); + cardpassword.setDate(DateUtil.DateTimeToStr(new Date())); + cardpassword.setMoney(Double.parseDouble(pwd)); + cardpassword.setRandomNo(s); + cardpasswordService.add(cardpassword); + cardpasswordList.add(cardpassword); + } catch (Exception e) { + Struts2Utils.renderText("error"); + e.printStackTrace(); + } + } + Struts2Utils.renderText("success"); + } + }else{ + Struts2Utils.renderText("test"); + } + + } + } + + /** + * 提现管理 + * @return + */ + public String applymentionList(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(pageNo==0){ + pageNo = 1; + } + Pagination page = applymentionService.getApplymentionList(null, null, null, pageNo, pageSize); + applymentionList = (List) page.getList(); + resultCount = applymentionService.getApplymentionListByCount(null, null, null); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/applymentionList.action?pageNo="); + pageString = pageString.replace(".html", ""); + return "applymentionList"; + } + return "index_index"; + } + + /** + * 发货管理 + * @return + */ + public String orderDetailAddressList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + + if(pageNo==0){ + pageNo = 1; + } + + Pagination page = orderDetailAddressService.orderDetailAddressList(pageNo, pageSize); + + orderDetailAddressList = (List) page.getList(); + resultCount = page.getResultCount(); + pageString = PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, "/admin_back/orderdetailaddressList.action?pageNo="); + pageString = pageString.replace(".html", ""); + return "orderdetailaddressList"; + } + return "index_index"; + } + + + /** + * 在线升级 + * @return + */ + public String lineUpdate(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + + return "lineUpdate"; + } + return "index_index"; + + + } + + /** + * QQ互联登录 + * @return + */ + public String qqSetInfo(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + sysConfigure = ApplicationListenerImpl.sysConfigureJson; + return "qqSetInfo"; + } + return "index_index"; + } + + /** + * SEO设置 + * @return + */ + public String toSeoSet(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + sysConfigure = ApplicationListenerImpl.sysConfigureJson; + setType = ConfigType.seoSet; + return "seoSet"; + } + return "index_index"; + + } + + /** + * 基本设置 + * @return + */ + public String toBasicSet(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + sysConfigure = ApplicationListenerImpl.sysConfigureJson; + setType = ConfigType.basicSet; + return "toBasicSet"; + } + return "index_index"; + + } + + /** + * 邮箱设置 + * @return + */ + public String toMailSet(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + sysConfigure = ApplicationListenerImpl.sysConfigureJson; + setType = ConfigType.mailSet; + return "toMailSet"; + } + return "index_index"; + + } + + /** + * 邮件测试 + * @throws InterruptedException + */ + public void doTestMail() throws InterruptedException{ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + if(StringUtil.isBlank(ApplicationListenerImpl.sysConfigureJson.getMailName()) || StringUtil.isBlank(ApplicationListenerImpl.sysConfigureJson.getMailPwd())){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + String html = message; + boolean flag = false; + if(StringUtil.isNotBlank(userName)){ + String[] mailTo = userName.split(","); + for (String string : mailTo) { + try { + flag = EmailUtil.sendEmail(ApplicationListenerImpl.sysConfigureJson.getMailName(), ApplicationListenerImpl.sysConfigureJson.getMailPwd(), string, tId, html); + } catch (Exception e) { + e.printStackTrace(); + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + Thread.sleep(1000); + } + } + if(flag){ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + } + + /** + * 短信设置 + * @return + */ + public String toMessageSet(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + sysConfigure = ApplicationListenerImpl.sysConfigureJson; + message = Sampler.getMesBalance(); + setType = ConfigType.smsSet; + return "toMessageSet"; + } + return "index_index"; + + } + + public void testMessage() throws Exception{ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + List sendList = Sampler.sendOnce(id, message); + if(sendList != null){ + for(SendResultBean t:sendList){ + if(t.getResult() < 1){ +// System.out.println("发送提交失败: " + t.getErrMsg()); + Struts2Utils.renderText("发送失败,请联系管理员!"); + return; + } + Struts2Utils.renderText("发送成功!总数:"+t.getTotal()); +// System.out.println("发送成功: 消息编号<" + t.getMsgId() + "> 总数<" + t.getTotal() + "> 余额<" + t.getRemain() + ">"); + } + } + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + + } + + /** + * 支付设置 + * @return + */ + public String toPaySet(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + sysConfigure = ApplicationListenerImpl.sysConfigureJson; + return "toPaySet"; + } + return "index_index"; + + } + + /** + * 支付设置页面 + * @return + */ + public String payInfo(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ +// if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + sysConfigure = ApplicationListenerImpl.sysConfigureJson; + setType = ConfigType.paySet; + return "payInfo"; +// }else{ +// Struts2Utils.render("text/html", "","encoding:UTF-8"); +// } + } + return "index_index"; + } + + /** + * 添加管理员 + * @return + */ + public String toAddAdmin(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + + return "toAddAdmin"; + } + return "index_index"; + + } + + public String doAddAdmin(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + User u = new User(); + u.setUserName(user.getUserName()); + u.setPhone(user.getUserName()); + u.setMail(user.getUserName()); + u.setUserPwd(user.getUserPwd()); + u.setUserType(user.getUserType()); + userService.add(u); + return "addAdminSuccess"; + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + return null; + } + + } + return "index_index"; + + } + + /** + * 管理员列表 + * @return + */ + public String toAdminList(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + userList = userService.query("from User u where 1=1 and u.userType = 1"); + return "toAdminList"; + } + return "index_index"; + + } + + /** + * 密码管理 + * @return + */ + public String updateAdminPwd(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + userName = id; + return "updateAdminPwd"; + } + return "index_index"; + } + + public void doUpdateAdminPwd(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + try { + user = (User) Struts2Utils.getSession().getAttribute("admin"); + user.setUserPwd(pwd); + userService.add(user); + Struts2Utils.renderText("success"); + } catch (Exception e) { + Struts2Utils.renderText("error"); + e.printStackTrace(); + } + }else{ + Struts2Utils.renderText("test"); + } + } + + } + + //设置支付方式、SEO等状态 + public String doSeoSet(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(((User)Struts2Utils.getSession().getAttribute("admin")).getUserName().equals("admin")){ + try { + if(setType.equals(ConfigType.basicSet)){ + ApplicationListenerImpl.sysConfigureJson.setDomain(sysConfigure.getDomain()); + ApplicationListenerImpl.sysConfigureJson.setSkinUrl(sysConfigure.getSkinUrl()); + ApplicationListenerImpl.sysConfigureJson.setImgUrl(sysConfigure.getImgUrl()); + ApplicationListenerImpl.sysConfigureJson.setServiceQq(sysConfigure.getServiceQq()); + ApplicationListenerImpl.sysConfigureJson.setServiceTel(sysConfigure.getServiceTel()); + } + else + if(setType.equals(ConfigType.seoSet)){ + ApplicationListenerImpl.sysConfigureJson.setWwwUrl(sysConfigure.getWwwUrl()); + ApplicationListenerImpl.sysConfigureJson.setSiteLogo(sysConfigure.getSiteLogo()); + ApplicationListenerImpl.sysConfigureJson.setSiteName(sysConfigure.getSiteName()); + ApplicationListenerImpl.sysConfigureJson.setShortName(sysConfigure.getShortName()); + ApplicationListenerImpl.sysConfigureJson.setSiteTitle(sysConfigure.getSiteTitle()); + ApplicationListenerImpl.sysConfigureJson.setKeyword(sysConfigure.getKeyword()); + ApplicationListenerImpl.sysConfigureJson.setDescription(sysConfigure.getDescription()); + ApplicationListenerImpl.sysConfigureJson.setIcp(sysConfigure.getIcp()); + } + else + if(setType.equals(ConfigType.smsSet)){ + ApplicationListenerImpl.sysConfigureJson.setMessagePartner(sysConfigure.getMessagePartner()); + ApplicationListenerImpl.sysConfigureJson.setMessageKey(sysConfigure.getMessageKey()); + ApplicationListenerImpl.sysConfigureJson.setMessageChannel(sysConfigure.getMessageChannel()); + ApplicationListenerImpl.sysConfigureJson.setMessageSign(sysConfigure.getMessageSign()); + } + else + if(setType.equals(ConfigType.mailSet)){ + ApplicationListenerImpl.sysConfigureJson.setWwwUrl(sysConfigure.getMailsmtp()); + ApplicationListenerImpl.sysConfigureJson.setSiteLogo(sysConfigure.getMailName()); + ApplicationListenerImpl.sysConfigureJson.setSiteName(sysConfigure.getMailPwd()); + } + else + { + if(setType.equals(ConfigType.paySet_alipay)){ + ApplicationListenerImpl.sysConfigureJson.setAlipayPartner(sysConfigure.getAlipayPartner()); + ApplicationListenerImpl.sysConfigureJson.setAlipayKey(sysConfigure.getAlipayKey()); + ApplicationListenerImpl.sysConfigureJson.setAlipayMail(sysConfigure.getAlipayMail()); + ApplicationListenerImpl.sysConfigureJson.setAlipayStatus(sysConfigure.getAlipayStatus()); + } + else + if(setType.equals(ConfigType.paySet_tenpay)){ + ApplicationListenerImpl.sysConfigureJson.setTenpayPartner(sysConfigure.getTenpayPartner()); + ApplicationListenerImpl.sysConfigureJson.setTenpayKey(sysConfigure.getTenpayKey()); + ApplicationListenerImpl.sysConfigureJson.setTenpayStatus(sysConfigure.getTenpayStatus()); + } + else + if(setType.equals(ConfigType.paySet_yeepay)){ + ApplicationListenerImpl.sysConfigureJson.setYeepayPartner(sysConfigure.getYeepayPartner()); + ApplicationListenerImpl.sysConfigureJson.setYeepayStatus(sysConfigure.getYeepayStatus()); + ApplicationListenerImpl.sysConfigureJson.setYeepayKey(sysConfigure.getYeepayKey()); + } + } + sysConfigure = ApplicationListenerImpl.sysConfigureJson; //Add by lwgboy ,将sysConfigure数据重新赋值,不取从前段页面提交过来的数据,避免数据不安全。 + + String productImgPath = "/Images"; + if(myFile!=null){ + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + imageFileName = "new-logo"+ myFileFileName; + File imageFile = new File(UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/", "")+"/" + imageFileName); + copy(myFile, imageFile); + imageFileName = imageFileName.toLowerCase(); + sysConfigure.setSiteLogo(productImgPath+"/" + imageFileName); + } + + sysConfigure.setAuthorization(Struts2Utils.getLocalIP()); + sysConfigureService.add(sysConfigure); + ApplicationListenerImpl.sysConfigureJson = sysConfigureService.findById(ApplicationListenerImpl.sysConfigureId.toString()); //更新sysConfigureJson为最新状态值。 + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } catch (Exception e) { + Struts2Utils.render("text/html", "","encoding:UTF-8"); + e.printStackTrace(); + } + }else{ + Struts2Utils.render("text/html", "","encoding:UTF-8"); + } + } + return null; + + } + + /** + * 充值记录 + * @return + */ + public String rechargeAllList(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + startDate = DateUtil.DateToStr(DateUtil.addMonth(new Date(), -1)); + endDate = DateUtil.DateToStr(new Date()); + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + resultCount = consumetableService.userByConsumetableByDeltaByCount(userId,startDate,endDate); + return "rechargeAllList"; + } + return "index_index"; + } + + /** + * 消费记录 + * @return + */ + public String consumeAllList(){ + boolean canNext = false; + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + user= (User)Struts2Utils.getSession().getAttribute("admin"); + if(user.getUserName().equals("admin")) + canNext = true; + }else { + user = UserUtils.getLogonUserInfo(request, userService); + if(user==null) return "index_index4normalUser";//需要是已注册用户且必须登录后才能继续 + shopList = shopService.getShopListByUserId(user.getUserId(),false); + if(shopList!=null&&shopList.size()>0){ //必须是名下有审核通过的店铺才能进入商品添加页 + canNext=true; + } + } + + //if(Struts2Utils.getSession().getAttribute("admin")!=null){ + if(canNext) { + startDate = DateUtil.DateToStr(DateUtil.addMonth(new Date(), -1)); + endDate = DateUtil.DateToStr(new Date()); + startDate +=" 00:00:00"; + endDate +=" 23:59:59"; + resultCount = consumetableService.userByConsumetableByCount(userId,startDate,endDate); + return "consumeAllList"; + } + + return "index_index"; + } + + /** + * 网站地图 + * @return + */ + public String toSiteMap(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + return "toSiteMap"; + } + return "index_index"; + } + + /** + * 站点提交 + * @return + */ + public String toSitePost(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + return "toSitePost"; + + } + return "index_index"; + } + + /** + * 网站统计 + * @return + */ + public String toSiteCount(){ + if(Struts2Utils.getSession().getAttribute("admin")!=null){ + return "toSiteCount"; + } + return "index_index"; + } + + public String timeOut(){ + + return "timeout"; + } + + /** + * 定义后台管理员进行网站配置时的类型 + * @author mofun + * + */ + public enum ConfigType { + basicSet, //基本设置 + seoSet, //SEO设置 + mailSet, //邮箱设置 + smsSet, //短信设置 + paySet, //支付设置 + paySet_alipay, //阿里支付设置 + paySet_tenpay, //腾讯支付设置 + paySet_yeepay //快钱支付设置 + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPwd() { + return pwd; + } + + public void setPwd(String pwd) { + this.pwd = pwd; + } + + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + public ProductImage getProductimage() { + return productimage; + } + + public void setProductimage(ProductImage productimage) { + this.productimage = productimage; + } + + public ProductType getProductType() { + return productType; + } + + public void setProductType(ProductType producttype) { + this.productType = producttype; + } + + public List getProductTypeList() { + return productTypeList; + } + + public void setProductTypeList(List productTypeList) { + this.productTypeList = productTypeList; + } + + public File getMyFile() { + return myFile; + } + + public void setMyFile(File myFile) { + this.myFile = myFile; + } + + public String getMyFileFileName() { + return myFileFileName; + } + + public void setMyFileFileName(String myFileFileName) { + this.myFileFileName = myFileFileName; + } + + public String getMyFileContentType() { + return myFileContentType; + } + + public void setMyFileContentType(String myFileContentType) { + this.myFileContentType = myFileContentType; + } + + public String getImageFileName() { + return imageFileName; + } + + public void setImageFileName(String imageFileName) { + this.imageFileName = imageFileName; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + public List getProductList() { + return productList; + } + + public void setProductList(List productList) { + this.productList = productList; + } + + + public String getPageString() { + return pageString; + } + + + public void setPageString(String pageString) { + this.pageString = pageString; + } + + + public String getPages() { + return pages; + } + + + public void setPages(String pages) { + this.pages = pages; + } + + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public List getFiledata() { + return Filedata; + } + + + public void setFiledata(List filedata) { + Filedata = filedata; + } + + + public List getFiledataFileName() { + return FiledataFileName; + } + + + public void setFiledataFileName(List filedataFileName) { + FiledataFileName = filedataFileName; + } + + + public List getImageContentType() { + return imageContentType; + } + + + public void setImageContentType(List imageContentType) { + this.imageContentType = imageContentType; + } + + + public List getProductimageList() { + return productimageList; + } + + + public void setProductimageList(List productimageList) { + this.productimageList = productimageList; + } + + + public String getTypeId() { + return typeId; + } + + + public void setTypeId(String typeId) { + this.typeId = typeId; + } + + + public String getTypeName() { + return typeName; + } + + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + + public List getProductJSONList() { + return productJSONList; + } + + + public void setProductJSONList(List productJSONList) { + this.productJSONList = productJSONList; + } + + + public ProductJSON getProductJSON() { + return productJSON; + } + + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public String getChannelUrl() { + return channelUrl; + } + + public void setChannelUrl(String channelUrl) { + this.channelUrl = channelUrl; + } + + public String getProductTypeId() { + return productTypeId; + } + + public void setProductTypeId(String productTypeId) { + this.productTypeId = productTypeId; + } + public String getBackUrl() { + return backUrl; + } + + public void setBackUrl(String backUrl) { + this.backUrl = backUrl; + } + + public News getNews() { + return news; + } + + public void setNews(News news) { + this.news = news; + } + + public List getNewsList() { + return newsList; + } + + public void setNewsList(List newsList) { + this.newsList = newsList; + } + + public List getNewsTypeTopList() { + return newsTypeTopList; + } + + public void setNewsTypeTopList(List newsTypeTopList) { + this.newsTypeTopList = newsTypeTopList; + } + + public List getNewsTypeSubList() { + return newsTypeSubList; + } + + public void setNewsTypeSubList(List newsTypeSubList) { + this.newsTypeSubList = newsTypeSubList; + } + + public Integer getNewsTypeParentId() { + return newsTypeParentId; + } + + public void setNewsTypeParentId(Integer newsTypeParentId) { + this.newsTypeParentId = newsTypeParentId; + } + + + public Integer getNewsCategoryId() { + return newsCategoryId; + } + + public void setNewsCategoryId(Integer newsCategoryId) { + this.newsCategoryId = newsCategoryId; + } + + + public Shareinfo getShareinfo() { + return shareinfo; + } + + public void setShareinfo(Shareinfo shareinfo) { + this.shareinfo = shareinfo; + } + + public Shareimage getShareimage() { + return shareimage; + } + + public void setShareimage(Shareimage shareimage) { + this.shareimage = shareimage; + } + + public List getShareJSONList() { + return ShareJSONList; + } + + public void setShareJSONList(List shareJSONList) { + ShareJSONList = shareJSONList; + } + + public ShareJSON getShareJSON() { + return shareJSON; + } + + public void setShareJSON(ShareJSON shareJSON) { + this.shareJSON = shareJSON; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getUserList() { + return userList; + } + + public void setUserList(List userList) { + this.userList = userList; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public List getLatestlotteryList() { + return latestlotteryList; + } + + public void setLatestlotteryList(List latestlotteryList) { + this.latestlotteryList = latestlotteryList; + } + + public List getShareimageList() { + return shareimageList; + } + + public void setShareimageList(List shareimageList) { + this.shareimageList = shareimageList; + } + + public String getAnnouncedTime() { + return announcedTime; + } + + public void setAnnouncedTime(String announcedTime) { + this.announcedTime = announcedTime; + } + + public SysInfoBean getSysInfoBean() { + return sysInfoBean; + } + + public void setSysInfoBean(SysInfoBean sysInfoBean) { + this.sysInfoBean = sysInfoBean; + } + + public List getOrderBeanList() { + return orderBeanList; + } + + public void setOrderBeanList(List orderBeanList) { + this.orderBeanList = orderBeanList; + } + + public List getCardpasswordList() { + return cardpasswordList; + } + + public void setCardpasswordList(List cardpasswordList) { + this.cardpasswordList = cardpasswordList; + } + + public List getApplymentionList() { + return applymentionList; + } + + public void setApplymentionList(List applymentionList) { + this.applymentionList = applymentionList; + } + + public List getOrderDetailAddressList() { + return orderDetailAddressList; + } + + public void setOrderDetailAddressList( List orderDetailAddressList) { + this.orderDetailAddressList = orderDetailAddressList; + } + + public SysConfigure getSysConfigure() { + return sysConfigure; + } + + public void setSysConfigure(SysConfigure sysConfigure) { + this.sysConfigure = sysConfigure; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public List getIndexImgList() { + return indexImgList; + } + + public void setIndexImgList(List indexImgList) { + this.indexImgList = indexImgList; + } + + public IndexImg getIndexImg() { + return indexImg; + } + + public void setIndexImg(IndexImg indexImg) { + this.indexImg = indexImg; + } + + public List getProductBrandList() { + return productBrandList; + } + + public void setProductBrandList(List productBrandList) { + this.productBrandList = productBrandList; + } + + public String getTId() { + return tId; + } + + public void setTId(String id) { + this.tId = id; + } + + public List getSuggestionList() { + return suggestionList; + } + + public void setSuggestionList(List suggestionList) { + this.suggestionList = suggestionList; + } + + public List getOrderdetailList() { + return orderdetailList; + } + + public void setOrderdetailList(List orderdetailList) { + this.orderdetailList = orderdetailList; + } + + public OrderDetailAddress getOrderDetailAddress() { + return orderdetailaddress; + } + + public void seOrderDetailAddress(OrderDetailAddress orderdetailaddress) { + this.orderdetailaddress = orderdetailaddress; + } + + public List getShopList() { + return shopList; + } + + public void setShopList(List shopList) { + this.shopList = shopList; + } + + public Shop getShop() { + return shop; + } + + public void setShop(Shop shop) { + this.shop = shop; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public ConfigType getSetType() { + return setType; + } + + public void setSetType(ConfigType setType) { + this.setType = setType; + } + +} diff --git a/src/main/java/me/mofun/alipay/config/AlipayConfig.java b/src/main/java/me/mofun/alipay/config/AlipayConfig.java new file mode 100644 index 0000000..7cc8e90 --- /dev/null +++ b/src/main/java/me/mofun/alipay/config/AlipayConfig.java @@ -0,0 +1,56 @@ +package me.mofun.alipay.config; + +import me.mofun.util.ApplicationListenerImpl; + +/* * + *类名:AlipayConfig + *功能:基础配置类 + *详细:设置帐户有关信息及返回路径 + *版本:3.3 + *日期:2012-08-10 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + + *提示:如何获取安全校验码和合作身份者ID + *1.用您的签约支付宝账号登录支付宝网站(www.alipay.com) + *2.点击“商家服务”(https://b.alipay.com/order/myOrder.htm) + *3.点击“查询合作者身份(PID)”、“查询安全校验码(Key)” + + *安全校验码查看时,输入支付密码后,页面呈灰色的现象,怎么办? + *解决方法: + *1、检查浏览器配置,不让浏览器做弹框屏蔽设置 + *2、更换浏览器或电脑,重新登录查询。 + */ + +public class AlipayConfig { + + //↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ + // 合作身份者ID,以2088开头由16位纯数字组成的字符串 + //public static String partner = "2088611781615594"; + public static String partner = ApplicationListenerImpl.sysConfigureJson.getAlipayPartner(); + // 商户的私钥 + //public static String key = "j7j16nzpchmr34j8fxco842ra0qupjpm"; + public static String key = ApplicationListenerImpl.sysConfigureJson.getAlipayKey(); + + public static String return_url =ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/buySoft/returnUrl.action"; +// public static String return_url ="http://epgwyc1.eicp.net:21522/buySoft/returnUrl.action"; + public static String notify_url =ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/buySoft/notifyUrl.action"; +// public static String notify_url ="http://epgwyc1.eicp.net:21522/buySoft/notifyUrl.action"; +// public static String mail = "service@hahsun.com"; + public static String mail = ApplicationListenerImpl.sysConfigureJson.getAlipayMail(); + + //↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ + + + // 调试用,创建TXT日志文件夹路径 +// public static String log_path = "D:\\"; + public static String log_path = "/usr/"; + + // 字符编码格式 目前支持 gbk 或 utf-8 + public static String input_charset = "utf-8"; + + // 签名方式 不需修改 + public static String sign_type = "MD5"; + +} diff --git a/src/main/java/me/mofun/alipay/services/AlipayService.java b/src/main/java/me/mofun/alipay/services/AlipayService.java new file mode 100644 index 0000000..3152777 --- /dev/null +++ b/src/main/java/me/mofun/alipay/services/AlipayService.java @@ -0,0 +1,89 @@ +package me.mofun.alipay.services; + +import me.mofun.alipay.config.AlipayConfig; +import me.mofun.alipay.util.AlipaySubmit; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Node; +import org.dom4j.io.SAXReader; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; +import java.util.Map; + +/* * + *类名:AlipayService + *功能:支付宝各接口构造类 + *详细:构造支付宝各接口请求参数 + *版本:3.2 + *修改日期:2011-03-17 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + */ + +public class AlipayService { + + /** + * 支付宝提供给商户的服务接入网关URL(新) + */ + private static final String ALIPAY_GATEWAY_NEW = "https://mapi.alipay.com/gateway.do?"; + + /** + * 构造即时到帐接口 + * @param sParaTemp 请求参数集合 + * @return 表单提交HTML信息 + */ + public static String create_direct_pay_by_user(Map sParaTemp) { + + //增加基本配置 + sParaTemp.put("service", "create_direct_pay_by_user"); + sParaTemp.put("partner", AlipayConfig.partner); + sParaTemp.put("return_url", AlipayConfig.return_url); + sParaTemp.put("notify_url", AlipayConfig.notify_url); + //sParaTemp.put("seller_email", AlipayConfig.seller_email); + sParaTemp.put("seller_email", AlipayConfig.mail); + sParaTemp.put("_input_charset", AlipayConfig.input_charset); + + String strButtonName = "确认"; + + //return AlipaySubmit.buildForm(sParaTemp, ALIPAY_GATEWAY_NEW, "get", strButtonName); + return AlipaySubmit.buildRequest(sParaTemp, ALIPAY_GATEWAY_NEW, "get", strButtonName); + } + + /** + * 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数 + * 注意:远程解析XML出错,与服务器是否支持SSL等配置有关 + * @return 时间戳字符串 + * @throws IOException + * @throws DocumentException + * @throws MalformedURLException + */ + public static String query_timestamp() throws MalformedURLException, + DocumentException, IOException { + + //构造访问query_timestamp接口的URL串 + String strUrl = ALIPAY_GATEWAY_NEW + "service=query_timestamp&partner=" + AlipayConfig.partner; + StringBuffer result = new StringBuffer(); + + SAXReader reader = new SAXReader(); + Document doc = reader.read(new URL(strUrl).openStream()); + + List nodeList = doc.selectNodes("//alipay/*"); + + for (Node node : nodeList) { + // 截取部分不需要解析的信息 + if (node.getName().equals("is_success") && node.getText().equals("T")) { + // 判断是否有成功标示 + List nodeList1 = doc.selectNodes("//response/timestamp/*"); + for (Node node1 : nodeList1) { + result.append(node1.getText()); + } + } + } + + return result.toString(); + } +} diff --git a/src/main/java/me/mofun/alipay/sign/MD5.java b/src/main/java/me/mofun/alipay/sign/MD5.java new file mode 100644 index 0000000..205582b --- /dev/null +++ b/src/main/java/me/mofun/alipay/sign/MD5.java @@ -0,0 +1,68 @@ +package me.mofun.alipay.sign; + +import org.apache.commons.codec.digest.DigestUtils; + +import java.io.UnsupportedEncodingException; +import java.security.SignatureException; + +/** +* 功能:支付宝MD5签名处理核心文件,不需要修改 +* 版本:3.3 +* 修改日期:2012-08-17 +* 说明: +* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 +* 该代码仅供学习和研究支付宝接口使用,只是提供一个 +* */ + +public class MD5 { + + /** + * 签名字符串 + * @param text 需要签名的字符串 + * @param key 密钥 + * @param input_charset 编码格式 + * @return 签名结果 + */ + public static String sign(String text, String key, String input_charset) { + text = text + key; + return DigestUtils.md5Hex(getContentBytes(text, input_charset)); + } + + /** + * 签名字符串 + * @param text 需要签名的字符串 + * @param sign 签名结果 + * @param key 密钥 + * @param input_charset 编码格式 + * @return 签名结果 + */ + public static boolean verify(String text, String sign, String key, String input_charset) { + text = text + key; + String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset)); + if(mysign.equals(sign)) { + return true; + } + else { + return false; + } + } + + /** + * @param content + * @param charset + * @return + * @throws SignatureException + * @throws UnsupportedEncodingException + */ + private static byte[] getContentBytes(String content, String charset) { + if (charset == null || "".equals(charset)) { + return content.getBytes(); + } + try { + return content.getBytes(charset); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset); + } + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/alipay/util/AlipayCore.java b/src/main/java/me/mofun/alipay/util/AlipayCore.java new file mode 100644 index 0000000..359fc87 --- /dev/null +++ b/src/main/java/me/mofun/alipay/util/AlipayCore.java @@ -0,0 +1,117 @@ +package me.mofun.alipay.util; + +import me.mofun.alipay.config.AlipayConfig; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.httpclient.methods.multipart.FilePartSource; +import org.apache.commons.httpclient.methods.multipart.PartSource; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.*; + +/* * + *类名:AlipayFunction + *功能:支付宝接口公用函数类 + *详细:该类是请求、通知返回两个文件所调用的公用函数核心处理文件,不需要修改 + *版本:3.3 + *日期:2012-08-14 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + */ + +public class AlipayCore { + + /** + * 除去数组中的空值和签名参数 + * @param sArray 签名参数组 + * @return 去掉空值与签名参数后的新签名参数组 + */ + public static Map paraFilter(Map sArray) { + + Map result = new HashMap(); + + if (sArray == null || sArray.size() <= 0) { + return result; + } + + for (String key : sArray.keySet()) { + String value = sArray.get(key); + if (value == null || value.equals("") || key.equalsIgnoreCase("sign") + || key.equalsIgnoreCase("sign_type")) { + continue; + } + result.put(key, value); + } + + return result; + } + + /** + * 把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串 + * @param params 需要排序并参与字符拼接的参数组 + * @return 拼接后字符串 + */ + public static String createLinkString(Map params) { + + List keys = new ArrayList(params.keySet()); + Collections.sort(keys); + + String prestr = ""; + + for (int i = 0; i < keys.size(); i++) { + String key = keys.get(i); + String value = params.get(key); + + if (i == keys.size() - 1) {//拼接时,不包括最后一个&字符 + prestr = prestr + key + "=" + value; + } else { + prestr = prestr + key + "=" + value + "&"; + } + } + + return prestr; + } + + /** + * 写日志,方便测试(看网站需求,也可以改成把记录存入数据库) + * @param sWord 要写入日志里的文本内容 + */ + public static void logResult(String sWord) { + FileWriter writer = null; + try { + writer = new FileWriter(AlipayConfig.log_path + "alipay_log_" + System.currentTimeMillis()+".txt"); + writer.write(sWord); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (writer != null) { + try { + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * 生成文件摘要 + * @param strFilePath 文件路径 + * @param file_digest_type 摘要算法 + * @return 文件摘要结果 + */ + public static String getAbstract(String strFilePath, String file_digest_type) throws IOException { + PartSource file = new FilePartSource(new File(strFilePath)); + if(file_digest_type.equals("MD5")){ + return DigestUtils.md5Hex(file.createInputStream()); + } + else if(file_digest_type.equals("SHA")) { + return DigestUtils.sha256Hex(file.createInputStream()); + } + else { + return ""; + } + } +} diff --git a/src/main/java/me/mofun/alipay/util/AlipayMd5Encrypt.java b/src/main/java/me/mofun/alipay/util/AlipayMd5Encrypt.java new file mode 100644 index 0000000..ca8795c --- /dev/null +++ b/src/main/java/me/mofun/alipay/util/AlipayMd5Encrypt.java @@ -0,0 +1,53 @@ +package me.mofun.alipay.util; + +import me.mofun.alipay.config.AlipayConfig; +import org.apache.commons.codec.digest.DigestUtils; + +import java.io.UnsupportedEncodingException; +import java.security.SignatureException; + +/** +* 功能:支付宝MD5签名处理核心文件,不需要修改 +* 版本:3.1 +* 修改日期:2010-11-01 +* 说明: +* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 +* 该代码仅供学习和研究支付宝接口使用,只是提供一个 +* */ + +public class AlipayMd5Encrypt { + + /** + * 对字符串进行MD5签名 + * + * @param text + * 明文 + * + * @return 密文 + */ + public static String md5(String text) { + + return DigestUtils.md5Hex(getContentBytes(text, AlipayConfig.input_charset)); + + } + + /** + * @param content + * @param charset + * @return + * @throws SignatureException + * @throws UnsupportedEncodingException + */ + private static byte[] getContentBytes(String content, String charset) { + if (charset == null || "".equals(charset)) { + return content.getBytes(); + } + + try { + return content.getBytes(charset); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset); + } + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/alipay/util/AlipayNotify.java b/src/main/java/me/mofun/alipay/util/AlipayNotify.java new file mode 100644 index 0000000..8d2727a --- /dev/null +++ b/src/main/java/me/mofun/alipay/util/AlipayNotify.java @@ -0,0 +1,124 @@ +package me.mofun.alipay.util; + +import me.mofun.alipay.config.AlipayConfig; +import me.mofun.alipay.sign.MD5; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Map; + +/* * + *类名:AlipayNotify + *功能:支付宝通知处理类 + *详细:处理支付宝各接口通知返回 + *版本:3.3 + *日期:2012-08-17 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考 + + *************************注意************************* + *调试通知返回时,可查看或改写log日志的写入TXT里的数据,来检查通知返回是否正常 + */ +public class AlipayNotify { + + /** + * 支付宝消息验证地址 + */ + private static final String HTTPS_VERIFY_URL = "https://mapi.alipay.com/gateway.do?service=notify_verify&"; + + /** + * 验证消息是否是支付宝发出的合法消息 + * @param params 通知返回来的参数数组 + * @return 验证结果 + */ + public static boolean verify(Map params) { + + //判断responsetTxt是否为true,isSign是否为true + //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关 + //isSign不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关 + String responseTxt = "true"; + if(params.get("notify_id") != null) { + String notify_id = params.get("notify_id"); + responseTxt = verifyResponse(notify_id); + } + String sign = ""; + if(params.get("sign") != null) {sign = params.get("sign");} + boolean isSign = getSignVeryfy(params, sign); + + //写日志记录(若要调试,请取消下面两行注释) + //String sWord = "responseTxt=" + responseTxt + "\n isSign=" + isSign + "\n 返回回来的参数:" + AlipayCore.createLinkString(params); + //AlipayCore.logResult(sWord); + + if (isSign && responseTxt.equals("true")) { + return true; + } else { + return false; + } + } + + /** + * 根据反馈回来的信息,生成签名结果 + * @param Params 通知返回来的参数数组 + * @param sign 比对的签名结果 + * @return 生成的签名结果 + */ + private static boolean getSignVeryfy(Map Params, String sign) { + //过滤空值、sign与sign_type参数 + Map sParaNew = AlipayCore.paraFilter(Params); + //获取待签名字符串 + String preSignStr = AlipayCore.createLinkString(sParaNew); + //获得签名验证结果 + boolean isSign = false; + if(AlipayConfig.sign_type.equals("MD5") ) { + isSign = MD5.verify(preSignStr, sign, AlipayConfig.key, AlipayConfig.input_charset); + } + return isSign; + } + + /** + * 获取远程服务器ATN结果,验证返回URL + * @param notify_id 通知校验ID + * @return 服务器ATN结果 + * 验证结果集: + * invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空 + * true 返回正确信息 + * false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟 + */ + private static String verifyResponse(String notify_id) { + //获取远程服务器ATN结果,验证是否是支付宝服务器发来的请求 + + String partner = AlipayConfig.partner; + String veryfy_url = HTTPS_VERIFY_URL + "partner=" + partner + "¬ify_id=" + notify_id; + + return checkUrl(veryfy_url); + } + + /** + * 获取远程服务器ATN结果 + * @param urlvalue 指定URL路径地址 + * @return 服务器ATN结果 + * 验证结果集: + * invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空 + * true 返回正确信息 + * false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟 + */ + private static String checkUrl(String urlvalue) { + String inputLine = ""; + + try { + URL url = new URL(urlvalue); + HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection + .getInputStream())); + inputLine = in.readLine().toString(); + } catch (Exception e) { + e.printStackTrace(); + inputLine = ""; + } + + return inputLine; + } +} diff --git a/src/main/java/me/mofun/alipay/util/AlipaySubmit.java b/src/main/java/me/mofun/alipay/util/AlipaySubmit.java new file mode 100644 index 0000000..a16ca74 --- /dev/null +++ b/src/main/java/me/mofun/alipay/util/AlipaySubmit.java @@ -0,0 +1,219 @@ +package me.mofun.alipay.util; + +import me.mofun.alipay.config.AlipayConfig; +import me.mofun.alipay.sign.MD5; +import me.mofun.alipay.util.httpClient.HttpProtocolHandler; +import me.mofun.alipay.util.httpClient.HttpRequest; +import me.mofun.alipay.util.httpClient.HttpResponse; +import me.mofun.alipay.util.httpClient.HttpResultType; +import org.apache.commons.httpclient.NameValuePair; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Node; +import org.dom4j.io.SAXReader; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/* * + *类名:AlipaySubmit + *功能:支付宝各接口请求提交类 + *详细:构造支付宝各接口表单HTML文本,获取远程HTTP数据 + *版本:3.3 + *日期:2012-08-13 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + */ + +public class AlipaySubmit { + + /** + * 支付宝提供给商户的服务接入网关URL(新) + */ + private static final String ALIPAY_GATEWAY_NEW = "https://mapi.alipay.com/gateway.do?"; + + /** + * 生成签名结果 + * @param sPara 要签名的数组 + * @return 签名结果字符串 + */ + public static String buildRequestMysign(Map sPara) { + String prestr = AlipayCore.createLinkString(sPara); //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 + String mysign = ""; + if(AlipayConfig.sign_type.equals("MD5") ) { + mysign = MD5.sign(prestr, AlipayConfig.key, AlipayConfig.input_charset); + } + return mysign; + } + + /** + * 生成要请求给支付宝的参数数组 + * @param sParaTemp 请求前的参数数组 + * @return 要请求的参数数组 + */ + private static Map buildRequestPara(Map sParaTemp) { + //除去数组中的空值和签名参数 + Map sPara = AlipayCore.paraFilter(sParaTemp); + //生成签名结果 + String mysign = buildRequestMysign(sPara); + + //签名结果与签名方式加入请求提交参数组中 + sPara.put("sign", mysign); + sPara.put("sign_type", AlipayConfig.sign_type); + + return sPara; + } + + /** + * 建立请求,以表单HTML形式构造(默认) + * @param sParaTemp 请求参数数组 + * @param strMethod 提交方式。两个值可选:post、get + * @param strButtonName 确认按钮显示文字 + * @return 提交表单HTML文本 + */ + public static String buildRequest(Map sParaTemp, String strMethod, String strButtonName) { + //待请求参数数组 + Map sPara = buildRequestPara(sParaTemp); + List keys = new ArrayList(sPara.keySet()); + + StringBuffer sbHtml = new StringBuffer(); + + sbHtml.append("
    "); + + for (int i = 0; i < keys.size(); i++) { + String name = (String) keys.get(i); + String value = (String) sPara.get(name); + + sbHtml.append(""); + } + + //submit按钮控件请不要含有name属性 + sbHtml.append("
    "); + sbHtml.append(""); + + return sbHtml.toString(); + } + + /** + * 建立请求,以表单HTML形式构造,带文件上传功能 + * @param sParaTemp 请求参数数组 + * @param strMethod 提交方式。两个值可选:post、get + * @param strButtonName 确认按钮显示文字 + * @param strParaFileName 文件上传的参数名 + * @return 提交表单HTML文本 + */ + public static String buildRequest(Map sParaTemp, String strMethod, String strButtonName, String strParaFileName) { + //待请求参数数组 + Map sPara = buildRequestPara(sParaTemp); + List keys = new ArrayList(sPara.keySet()); + + StringBuffer sbHtml = new StringBuffer(); + + sbHtml.append("
    "); + + for (int i = 0; i < keys.size(); i++) { + String name = (String) keys.get(i); + String value = (String) sPara.get(name); + + sbHtml.append(""); + } + + sbHtml.append(""); + + //submit按钮控件请不要含有name属性 + sbHtml.append("
    "); + + return sbHtml.toString(); + } + + /** + * 建立请求,以模拟远程HTTP的POST请求方式构造并获取支付宝的处理结果 + * 如果接口中没有上传文件参数,那么strParaFileName与strFilePath设置为空值 + * 如:buildRequest("", "",sParaTemp) + * @param strParaFileName 文件类型的参数名 + * @param strFilePath 文件路径 + * @param sParaTemp 请求参数数组 + * @return 支付宝处理结果 + * @throws Exception + */ + public static String buildRequest(String strParaFileName, String strFilePath,Map sParaTemp) throws Exception { + //待请求参数数组 + Map sPara = buildRequestPara(sParaTemp); + + HttpProtocolHandler httpProtocolHandler = HttpProtocolHandler.getInstance(); + + HttpRequest request = new HttpRequest(HttpResultType.BYTES); + //设置编码集 + request.setCharset(AlipayConfig.input_charset); + + request.setParameters(generatNameValuePair(sPara)); + request.setUrl(ALIPAY_GATEWAY_NEW+"_input_charset="+AlipayConfig.input_charset); + + HttpResponse response = httpProtocolHandler.execute(request,strParaFileName,strFilePath); + if (response == null) { + return null; + } + + String strResult = response.getStringResult(); + + return strResult; + } + + /** + * MAP类型数组转换成NameValuePair类型 + * @param properties MAP类型数组 + * @return NameValuePair类型数组 + */ + private static NameValuePair[] generatNameValuePair(Map properties) { + NameValuePair[] nameValuePair = new NameValuePair[properties.size()]; + int i = 0; + for (Map.Entry entry : properties.entrySet()) { + nameValuePair[i++] = new NameValuePair(entry.getKey(), entry.getValue()); + } + + return nameValuePair; + } + + /** + * 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数 + * 注意:远程解析XML出错,与服务器是否支持SSL等配置有关 + * @return 时间戳字符串 + * @throws IOException + * @throws DocumentException + * @throws MalformedURLException + */ + public static String query_timestamp() throws MalformedURLException, + DocumentException, IOException { + + //构造访问query_timestamp接口的URL串 + String strUrl = ALIPAY_GATEWAY_NEW + "service=query_timestamp&partner=" + AlipayConfig.partner + "&_input_charset" +AlipayConfig.input_charset; + StringBuffer result = new StringBuffer(); + + SAXReader reader = new SAXReader(); + Document doc = reader.read(new URL(strUrl).openStream()); + + List nodeList = doc.selectNodes("//alipay/*"); + + for (Node node : nodeList) { + // 截取部分不需要解析的信息 + if (node.getName().equals("is_success") && node.getText().equals("T")) { + // 判断是否有成功标示 + List nodeList1 = doc.selectNodes("//response/timestamp/*"); + for (Node node1 : nodeList1) { + result.append(node1.getText()); + } + } + } + + return result.toString(); + } +} diff --git a/src/main/java/me/mofun/alipay/util/UtilDate.java b/src/main/java/me/mofun/alipay/util/UtilDate.java new file mode 100644 index 0000000..f3aa73d --- /dev/null +++ b/src/main/java/me/mofun/alipay/util/UtilDate.java @@ -0,0 +1,71 @@ + +package me.mofun.alipay.util; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Random; + +/* * + *类名:UtilDate + *功能:自定义订单类 + *详细:工具类,可以用作获取系统日期、订单编号等 + *版本:3.3 + *日期:2012-08-17 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + */ +public class UtilDate { + + /** 年月日时分秒(无下划线) yyyyMMddHHmmss */ + public static final String dtLong = "yyyyMMddHHmmss"; + + /** 完整时间 yyyy-MM-dd HH:mm:ss */ + public static final String simple = "yyyy-MM-dd HH:mm:ss"; + + /** 年月日(无下划线) yyyyMMdd */ + public static final String dtShort = "yyyyMMdd"; + + + /** + * 返回系统当前时间(精确到毫秒),作为一个唯一的订单编号 + * @return + * 以yyyyMMddHHmmss为格式的当前系统时间 + */ + public static String getOrderNum(){ + Date date=new Date(); + DateFormat df=new SimpleDateFormat(dtLong); + return df.format(date); + } + + /** + * 获取系统当前日期(精确到毫秒),格式:yyyy-MM-dd HH:mm:ss + * @return + */ + public static String getDateFormatter(){ + Date date=new Date(); + DateFormat df=new SimpleDateFormat(simple); + return df.format(date); + } + + /** + * 获取系统当期年月日(精确到天),格式:yyyyMMdd + * @return + */ + public static String getDate(){ + Date date=new Date(); + DateFormat df=new SimpleDateFormat(dtShort); + return df.format(date); + } + + /** + * 产生随机的三位数 + * @return + */ + public static String getThree(){ + Random rad=new Random(); + return rad.nextInt(1000)+""; + } + +} diff --git a/src/main/java/me/mofun/alipay/util/httpClient/HttpProtocolHandler.java b/src/main/java/me/mofun/alipay/util/httpClient/HttpProtocolHandler.java new file mode 100644 index 0000000..e8cc774 --- /dev/null +++ b/src/main/java/me/mofun/alipay/util/httpClient/HttpProtocolHandler.java @@ -0,0 +1,191 @@ +package me.mofun.alipay.util.httpClient; + +import org.apache.commons.httpclient.*; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.multipart.*; +import org.apache.commons.httpclient.params.HttpMethodParams; +import org.apache.commons.httpclient.util.IdleConnectionTimeoutThread; + +import java.io.File; +import java.io.IOException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; + +/* * + *类名:HttpProtocolHandler + *功能:HttpClient方式访问 + *详细:获取远程HTTP数据 + *版本:3.3 + *日期:2012-08-17 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + */ + +public class HttpProtocolHandler { + + private static String DEFAULT_CHARSET = "GBK"; + + /** 连接超时时间,由bean factory设置,缺省为8秒钟 */ + private int defaultConnectionTimeout = 8000; + + /** 回应超时时间, 由bean factory设置,缺省为30秒钟 */ + private int defaultSoTimeout = 30000; + + /** 闲置连接超时时间, 由bean factory设置,缺省为60秒钟 */ + private int defaultIdleConnTimeout = 60000; + + private int defaultMaxConnPerHost = 30; + + private int defaultMaxTotalConn = 80; + + /** 默认等待HttpConnectionManager返回连接超时(只有在达到最大连接数时起作用):1秒*/ + private static final long defaultHttpConnectionManagerTimeout = 3 * 1000; + + /** + * HTTP连接管理器,该连接管理器必须是线程安全的. + */ + private HttpConnectionManager connectionManager; + + private static HttpProtocolHandler httpProtocolHandler = new HttpProtocolHandler(); + + /** + * 工厂方法 + * + * @return + */ + public static HttpProtocolHandler getInstance() { + return httpProtocolHandler; + } + + /** + * 私有的构造方法 + */ + private HttpProtocolHandler() { + // 创建一个线程安全的HTTP连接池 + connectionManager = new MultiThreadedHttpConnectionManager(); + connectionManager.getParams().setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost); + connectionManager.getParams().setMaxTotalConnections(defaultMaxTotalConn); + + IdleConnectionTimeoutThread ict = new IdleConnectionTimeoutThread(); + ict.addConnectionManager(connectionManager); + ict.setConnectionTimeout(defaultIdleConnTimeout); + + ict.start(); + } + + /** + * 执行Http请求 + * + * @param request 请求数据 + * @param strParaFileName 文件类型的参数名 + * @param strFilePath 文件路径 + * @return + * @throws HttpException, IOException + */ + public HttpResponse execute(HttpRequest request, String strParaFileName, String strFilePath) throws HttpException, IOException { + HttpClient httpclient = new HttpClient(connectionManager); + + // 设置连接超时 + int connectionTimeout = defaultConnectionTimeout; + if (request.getConnectionTimeout() > 0) { + connectionTimeout = request.getConnectionTimeout(); + } + httpclient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout); + + // 设置回应超时 + int soTimeout = defaultSoTimeout; + if (request.getTimeout() > 0) { + soTimeout = request.getTimeout(); + } + httpclient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout); + + // 设置等待ConnectionManager释放connection的时间 + httpclient.getParams().setConnectionManagerTimeout(defaultHttpConnectionManagerTimeout); + + String charset = request.getCharset(); + charset = charset == null ? DEFAULT_CHARSET : charset; + HttpMethod method = null; + + //get模式且不带上传文件 + if (request.getMethod().equals(HttpRequest.METHOD_GET)) { + method = new GetMethod(request.getUrl()); + method.getParams().setCredentialCharset(charset); + + // parseNotifyConfig会保证使用GET方法时,request一定使用QueryString + method.setQueryString(request.getQueryString()); + } else if(strParaFileName.equals("") && strFilePath.equals("")) { + //post模式且不带上传文件 + method = new PostMethod(request.getUrl()); + ((PostMethod) method).addParameters(request.getParameters()); + method.addRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=" + charset); + } + else { + //post模式且带上传文件 + method = new PostMethod(request.getUrl()); + List parts = new ArrayList(); + for (int i = 0; i < request.getParameters().length; i++) { + parts.add(new StringPart(request.getParameters()[i].getName(), request.getParameters()[i].getValue(), charset)); + } + //增加文件参数,strParaFileName是参数名,使用本地文件 + parts.add(new FilePart(strParaFileName, new FilePartSource(new File(strFilePath)))); + + // 设置请求体 + ((PostMethod) method).setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[0]), new HttpMethodParams())); + } + + // 设置Http Header中的User-Agent属性 + method.addRequestHeader("User-Agent", "Mozilla/4.0"); + HttpResponse response = new HttpResponse(); + + try { + httpclient.executeMethod(method); + if (request.getResultType().equals(HttpResultType.STRING)) { + response.setStringResult(method.getResponseBodyAsString()); + } else if (request.getResultType().equals(HttpResultType.BYTES)) { + response.setByteResult(method.getResponseBody()); + } + response.setResponseHeaders(method.getResponseHeaders()); + } catch (UnknownHostException ex) { + + return null; + } catch (IOException ex) { + + return null; + } catch (Exception ex) { + + return null; + } finally { + method.releaseConnection(); + } + return response; + } + + /** + * 将NameValuePairs数组转变为字符串 + * + * @param nameValues + * @return + */ + protected String toString(NameValuePair[] nameValues) { + if (nameValues == null || nameValues.length == 0) { + return "null"; + } + + StringBuffer buffer = new StringBuffer(); + + for (int i = 0; i < nameValues.length; i++) { + NameValuePair nameValue = nameValues[i]; + + if (i == 0) { + buffer.append(nameValue.getName() + "=" + nameValue.getValue()); + } else { + buffer.append("&" + nameValue.getName() + "=" + nameValue.getValue()); + } + } + + return buffer.toString(); + } +} diff --git a/src/main/java/me/mofun/alipay/util/httpClient/HttpRequest.java b/src/main/java/me/mofun/alipay/util/httpClient/HttpRequest.java new file mode 100644 index 0000000..1287f72 --- /dev/null +++ b/src/main/java/me/mofun/alipay/util/httpClient/HttpRequest.java @@ -0,0 +1,152 @@ +package me.mofun.alipay.util.httpClient; + +import org.apache.commons.httpclient.NameValuePair; + +/* * + *类名:HttpRequest + *功能:Http请求对象的封装 + *详细:封装Http请求 + *版本:3.3 + *日期:2011-08-17 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + */ + +public class HttpRequest { + + /** HTTP GET method */ + public static final String METHOD_GET = "GET"; + + /** HTTP POST method */ + public static final String METHOD_POST = "POST"; + + /** + * 待请求的url + */ + private String url = null; + + /** + * 默认的请求方式 + */ + private String method = METHOD_POST; + + private int timeout = 0; + + private int connectionTimeout = 0; + + /** + * Post方式请求时组装好的参数值对 + */ + private NameValuePair[] parameters = null; + + /** + * Get方式请求时对应的参数 + */ + private String queryString = null; + + /** + * 默认的请求编码方式 + */ + private String charset = "GBK"; + + /** + * 请求发起方的ip地址 + */ + private String clientIp; + + /** + * 请求返回的方式 + */ + private HttpResultType resultType = HttpResultType.BYTES; + + public HttpRequest(HttpResultType resultType) { + super(); + this.resultType = resultType; + } + + /** + * @return Returns the clientIp. + */ + public String getClientIp() { + return clientIp; + } + + /** + * @param clientIp The clientIp to set. + */ + public void setClientIp(String clientIp) { + this.clientIp = clientIp; + } + + public NameValuePair[] getParameters() { + return parameters; + } + + public void setParameters(NameValuePair[] parameters) { + this.parameters = parameters; + } + + public String getQueryString() { + return queryString; + } + + public void setQueryString(String queryString) { + this.queryString = queryString; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public int getConnectionTimeout() { + return connectionTimeout; + } + + public void setConnectionTimeout(int connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + + public int getTimeout() { + return timeout; + } + + public void setTimeout(int timeout) { + this.timeout = timeout; + } + + /** + * @return Returns the charset. + */ + public String getCharset() { + return charset; + } + + /** + * @param charset The charset to set. + */ + public void setCharset(String charset) { + this.charset = charset; + } + + public HttpResultType getResultType() { + return resultType; + } + + public void setResultType(HttpResultType resultType) { + this.resultType = resultType; + } + +} diff --git a/src/main/java/me/mofun/alipay/util/httpClient/HttpResponse.java b/src/main/java/me/mofun/alipay/util/httpClient/HttpResponse.java new file mode 100644 index 0000000..dce3d36 --- /dev/null +++ b/src/main/java/me/mofun/alipay/util/httpClient/HttpResponse.java @@ -0,0 +1,72 @@ +package me.mofun.alipay.util.httpClient; + +import me.mofun.alipay.config.AlipayConfig; +import org.apache.commons.httpclient.Header; + +import java.io.UnsupportedEncodingException; + +/* * + *类名:HttpResponse + *功能:Http返回对象的封装 + *详细:封装Http返回信息 + *版本:3.3 + *日期:2011-08-17 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + */ + +public class HttpResponse { + + /** + * 返回中的Header信息 + */ + private Header[] responseHeaders; + + /** + * String类型的result + */ + private String stringResult; + + /** + * btye类型的result + */ + private byte[] byteResult; + + public Header[] getResponseHeaders() { + return responseHeaders; + } + + public void setResponseHeaders(Header[] responseHeaders) { + this.responseHeaders = responseHeaders; + } + + public byte[] getByteResult() { + if (byteResult != null) { + return byteResult; + } + if (stringResult != null) { + return stringResult.getBytes(); + } + return null; + } + + public void setByteResult(byte[] byteResult) { + this.byteResult = byteResult; + } + + public String getStringResult() throws UnsupportedEncodingException { + if (stringResult != null) { + return stringResult; + } + if (byteResult != null) { + return new String(byteResult, AlipayConfig.input_charset); + } + return null; + } + + public void setStringResult(String stringResult) { + this.stringResult = stringResult; + } + +} diff --git a/src/main/java/me/mofun/alipay/util/httpClient/HttpResultType.java b/src/main/java/me/mofun/alipay/util/httpClient/HttpResultType.java new file mode 100644 index 0000000..00cfc62 --- /dev/null +++ b/src/main/java/me/mofun/alipay/util/httpClient/HttpResultType.java @@ -0,0 +1,27 @@ +/* + * Alipay.com Inc. + * Copyright (c) 2004-2005 All Rights Reserved. + */ +package me.mofun.alipay.util.httpClient; + +/* * + *类名:HttpResultType + *功能:表示Http返回的结果字符方式 + *详细:表示Http返回的结果字符方式 + *版本:3.3 + *日期:2012-08-17 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + */ +public enum HttpResultType { + /** + * 字符串方式 + */ + STRING, + + /** + * 字节数组方式 + */ + BYTES +} diff --git a/src/main/java/me/mofun/dao/BaseDAO.java b/src/main/java/me/mofun/dao/BaseDAO.java new file mode 100644 index 0000000..ac1430c --- /dev/null +++ b/src/main/java/me/mofun/dao/BaseDAO.java @@ -0,0 +1,89 @@ +package me.mofun.dao; + +import org.hibernate.Session; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** 统一数据访问接口 */ +public interface BaseDAO { + + public Session getSessions(); + /** 加载指定ID的持久化对象 */ + @SuppressWarnings("rawtypes") + public Object loadById(Class clazz,Serializable id); + + /** 加载满足 hibernate hql 条件的持久化对象 */ + public Object loadObject(String hql); + + + /** + * 加载满足sql条件的持久化对象 + * @author mofun + * @param sql 数据库sql语句 + * @return + */ + //public Object loadObjectBySql(String sql); + //public T loadObjectBySql(String sql); + //public T loadObjectBySql(String sql, Class theClass); + public T loadObjectBySql(String sql,Class theClass); + + /** 删除指定ID的持久化对象 */ + public void delById(Class clazz,Serializable id); + + /** 保存或更新指定的持久化对象 */ + public void saveOrUpdate(Object obj); + + /** 根据SQL保存或更新指定的持久化对象 */ + public Object saveOrUpdateSQL(String sql); + + /** 装载指定类的所有持久化对象 */ + public List listAll(String clazz); + + /** 分页装载指定类的所有持久化对象 */ + public List listAll(String clazz,int pageNo,int pageSize); + + /** 统计指定类的所有持久化对象 */ + public int countAll(String clazz); + + /** 查询指定类的满足条件的持久化对象 */ + public List query(String hql); + + /** 查询指定类的满足条件的持久化对象 */ + public List querySQL(String sql); + + /** 分页查询指定类的满足条件的持久化对象 */ + public List query(String hql,int pageNo,int pageSize); + + /** 统计指定类的查询结果 */ + public int countQuery(String hql); + + /** 条件更新数据 */ + public int update(String hql); + + /** + * 直接执行原生 SQL 语句进行更新操作 + * @param sql + * @return + */ + public int updateBySql(String sql); + + /***分页查询***/ + public Pagination pageQuery(Pagination pageCommon,StringBuffer hql,StringBuffer sql); + + /***执行存储过程***/ + public List callProc(String proName,List paramList); + /**执行sql查询,支持分页**/ + public List sqlQuery(StringBuffer sql,Map entityMap,Pagination page); + public List sqlQueryBean(StringBuffer sql, Map entityMap,Pagination page); + public int getAllNum(StringBuffer sql); + public BigDecimal getSelectSum(StringBuffer sql); + /**连表查询不带分页**/ + public List sqlQueryEntity(StringBuffer sql,Map entityMap); + public List sqlQueryEntityBean(StringBuffer sql, Map entityMap); + /** loadALL**/ + public List find(String hql); +} + diff --git a/src/main/java/me/mofun/dao/BaseDAOImpl.java b/src/main/java/me/mofun/dao/BaseDAOImpl.java new file mode 100644 index 0000000..6ff902e --- /dev/null +++ b/src/main/java/me/mofun/dao/BaseDAOImpl.java @@ -0,0 +1,528 @@ +package me.mofun.dao; + +import me.mofun.util.StringUtil; +import org.apache.log4j.Logger; +import org.hibernate.*; +import org.hibernate.transform.Transformers; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.DataAccessResourceFailureException; +import org.springframework.orm.hibernate3.HibernateCallback; +import org.springframework.orm.hibernate3.SessionFactoryUtils; +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** 统一数据访问接口实现 */ +@SuppressWarnings("unchecked") +@Repository("baseDao") +public class BaseDAOImpl extends HibernateDaoSupport implements BaseDAO { + + @Autowired + @Qualifier("sessionFactory") + public void setSessionFactory1(SessionFactory sessionFactory){ + super.setSessionFactory(sessionFactory); + } + + Logger log = Logger.getLogger(this.getClass()); + + /** 统计指定类的所有持久化对象 */ + public int countAll(String clazz) { + final String hql = "select count(*) from "+clazz+ " as a"; + @SuppressWarnings("rawtypes") + Long count = (Long)getHibernateTemplate().execute(new HibernateCallback(){ + public Object doInHibernate(Session session) throws HibernateException{ + Query query = session.createQuery(hql); + query.setMaxResults(1); + return query.uniqueResult(); + } + }); + return count.intValue(); + } + + /** 统计指定类的查询结果 */ + public int countQuery(String hql) { + final String counthql = hql; + Long count = (Long)getHibernateTemplate().execute(new HibernateCallback(){ + public Object doInHibernate(Session session) throws HibernateException{ + Query query = session.createQuery(counthql); + query.setMaxResults(1); + return query.uniqueResult(); + } + }); + return count.intValue(); + } + + /** 查询指定类的满足条件的持久化对象 */ + public List querySQL(String sql) { + final String sql1= sql; + return getHibernateTemplate().executeFind(new HibernateCallback(){ + public Object doInHibernate(Session session) throws HibernateException{ + Query query = session.createSQLQuery(sql1); + return query.list(); + } + }); + } + + /** 删除指定ID的持久化对象 */ + public void delById(Class clazz,Serializable id) { + getHibernateTemplate().delete(getHibernateTemplate().load(clazz, id)); + } + + /** 装载指定类的所有持久化对象 */ + public List listAll(String clazz) { + return getHibernateTemplate().find("from "+clazz+" as a order by a.id desc"); + } + + /** 分页装载指定类的所有持久化对象 */ + public List listAll(String clazz, int pageNo, int pageSize) { + final int pNo = pageNo; + final int pSize = pageSize; + final String hql = "from "+clazz+ " as a order by a.id desc"; + List list = getHibernateTemplate().executeFind(new HibernateCallback(){ + public Object doInHibernate(Session session) throws HibernateException{ + Query query = session.createQuery(hql); + query.setMaxResults(pSize); + query.setFirstResult((pNo-1)*pSize); + List result = query.list(); + if (!Hibernate.isInitialized(result))Hibernate.initialize(result); + return result; + } + }); + return list; + } + + /** 加载指定ID的持久化对象 */ + public Object loadById(Class clazz,Serializable id) { + return getHibernateTemplate().get(clazz, id); + } + + /**加载满足 hibernate hql 条件的持久化对象*/ + public Object loadObject(String hql) { + final String hql1 = hql; + Object obj = null; + List list = getHibernateTemplate().executeFind(new HibernateCallback(){ + public Object doInHibernate(Session session) throws HibernateException{ + Query query = session.createQuery(hql1); + return query.list(); + } + }); + if(list.size()>0)obj=list.get(0); + return obj; + } + + /** + * 加载满足sql条件的持久化对象(亦即将唯一的一条sql查询结果转换为单一对象) + * @author mofun + * @param + * @param sql 数据库sql语句 + * @return + */ + public T loadObjectBySql(String sql,Class theClass){ + StringBuffer sb = new StringBuffer(sql); + Map entityMap = new HashMap(); + T obj=null; + entityMap.put("object",theClass); + List list = this.sqlQueryEntity(sb, entityMap); + if(list.size()>0)obj=(T)list.get(0); + return obj; + } + + /** 查询指定类的满足条件的持久化对象 */ + public List query(String hql) { + final String hql1 = hql; + return getHibernateTemplate().executeFind(new HibernateCallback(){ + public Object doInHibernate(Session session) throws HibernateException{ + Query query = session.createQuery(hql1); + return query.list(); + } + }); + } + + /** 分页查询指定类的满足条件的持久化对象 */ + public List query(String hql, int pageNo, int pageSize) { + final int pNo = pageNo; + final int pSize = pageSize; + final String hql1 = hql; + return getHibernateTemplate().executeFind(new HibernateCallback(){ + public Object doInHibernate(Session session) throws HibernateException{ + Query query = session.createQuery(hql1); + query.setMaxResults(pSize); + query.setFirstResult((pNo-1)*pSize); + List result = query.list(); + if (!Hibernate.isInitialized(result))Hibernate.initialize(result); + return result; + } + }); + } + + /** 保存或更新指定的持久化对象 */ + @Transactional + public void saveOrUpdate(Object obj) { + this.getHibernateTemplate().saveOrUpdate(obj); + } + + /** 根据SQL保存或更新指定的持久化对象 */ + public Object saveOrUpdateSQL(String hql) { + final String hql1 = hql; + Object obj = null; + List list = getHibernateTemplate().executeFind(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + Query query = session.createQuery(hql1); + return query.list(); + } + }); + if (list.size() > 0) + obj = list.get(0); + return obj; + } + + /** 条件更新数据 */ + public int update(String hql) { + final String hql1 = hql; + return ((Integer) getHibernateTemplate().execute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + Query query = session.createQuery(hql1); + return query.executeUpdate(); + } + })).intValue(); + } + + /** + * 执行原生SQL语句 更新数据库 + */ + public int updateBySql(String sql) { + int result = 0; + + //方法1: + Session session = getSession(); + + Connection conn = null; + try { + Transaction trans = session.beginTransaction(); + conn = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); + PreparedStatement stmt = conn.prepareStatement(sql); + result = stmt.executeUpdate(); + trans.commit(); + } catch (SQLException ex) { + log.error(ex); + } + + + // Hibernate4 :方法2:http://www.360sdn.com/hibernate/2013/1230/1599.html + /* + final String finalSql = sql; + Session session = getSession(); + try { + session.beginTransaction(); + session.doWork( + // 定义一个匿名类,实现了Work接口 + new Work() { + public void execute(Connection connection) throws SQLException { + // 经由过程JDBC API执行SQL语句 + PreparedStatement ps = connection.prepareStatement(finalSql); + ResultSet rs = ps.executeQuery(); + try { + ResultSetMetaData metadata = rs.getMetaData(); + }catch(Exception ex){ + log.error(ex,ex); + } + finally { + doClose(null, ps, rs); + } + + } + }); + session.getTransaction().commit(); + // session.close(); + } catch (Exception ex) { + log.error(ex,ex); + } finally { + this.doClose(session, null, null); + } + */ + return result; + } + + // 释放数据资源 by rhine + protected void doClose(Session session, Statement stmt, ResultSet rs) { + if (rs != null) { + try { + rs.close(); + rs = null; + } catch (Exception ex) { + rs = null; + // log.error(ex,ex); + ex.printStackTrace(); + } + // Statement对象关闭时,会自动释放其管理的一个ResultSet对象 + if (stmt != null) { + try { + stmt.close(); + stmt = null; + } catch (Exception ex) { + stmt = null; + // log.error(ex,ex); + ex.printStackTrace(); + } + } + // 当Hibernate的事务由Spring接管时,session的关闭由Spring管理.不用手动关闭 + //  if(session != null){ + //    session.close(); + // } + } + } + + /*分页查询*/ + public Pagination pageQuery(Pagination pagination,StringBuffer hql,StringBuffer sql) { + List list = null; + Session session = getSession(); + try { + pagination.setResultCount(this.getAllNum(sql));// 给工具类PageCommon赋予记录总数 + Query query = session.createQuery(hql.toString()); + query.setFirstResult(pagination.getFirstResult()).setMaxResults(pagination.pageSize); // 设置开始标记和结束标记 + list = query.list(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if(session != null){ + session.close(); + } + } + + pagination.setList(list); + + return pagination; + } + /** + * 获取总记录数 + * + * @return + */ + public int getAllNum(StringBuffer sql) { + Session session = getSession(); + try { + BigInteger t = (BigInteger) session.createSQLQuery(sql.toString()).uniqueResult(); + if (t != null) + return t.intValue(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if(session != null){ + session.close(); + } + } + return 0; + } + + public Session getSessions(){ + return this.getSession(); + } + + public List callProc(String proName, List paramList) { + if(StringUtil.isBlank(proName)){ + return null; + } + Query query = this.getSession().getNamedQuery(proName); + if(paramList != null && paramList.size() > 0){ + int i = 0; + for (String str : paramList) { + query.setString(i, str); + i++; + } + } + return query.list(); + } + + public List sqlQuery(StringBuffer sql, Map entityMap,Pagination page) { + if(StringUtil.isBlank(sql.toString())){ + return null; + } + Session session = null; + try { + session = getSession(); + SQLQuery query = session.createSQLQuery(sql.toString()); + if(entityMap != null && entityMap.size() > 0){ + for (String key : entityMap.keySet()) { + Class value = entityMap.get(key); + query.addEntity(key,value); + } + } + query.setFirstResult(page.getFirstResult()).setMaxResults(page.pageSize); // 设置开始标记和结束标记 + return query.list(); + } catch (DataAccessResourceFailureException e) { + e.printStackTrace(); + } catch (HibernateException e) { + e.printStackTrace(); + } catch (IllegalStateException e) { + e.printStackTrace(); + }finally { + if(session != null){ + session.close(); + } + } + return null; + } + + public List sqlQueryBean(StringBuffer sql, Map entityMap,Pagination page) { + if(StringUtil.isBlank(sql.toString())){ + return null; + } + Session session = null; + try { + session = getSession(); + SQLQuery query = session.createSQLQuery(sql.toString()); + if(entityMap != null && entityMap.size() > 0){ + for (String key : entityMap.keySet()) { + Class value = entityMap.get(key); +// query.addEntity(key,value); + query.setResultTransformer(Transformers.aliasToBean(value)); + } + } + query.setFirstResult(page.getFirstResult()).setMaxResults(page.pageSize); // 设置开始标记和结束标记 + return query.list(); + } catch (DataAccessResourceFailureException e) { + e.printStackTrace(); + } catch (HibernateException e) { + e.printStackTrace(); + } catch (IllegalStateException e) { + e.printStackTrace(); + }finally { + if(session != null){ + session.close(); + } + } + return null; + } + + /** + * 获取sum数 + */ + public BigDecimal getSelectSum(StringBuffer sql) { + Session session = getSession(); + try { + BigDecimal t = (BigDecimal) session.createSQLQuery(sql.toString()).uniqueResult(); + if (t != null) + return t; + } catch (Exception e) { + e.printStackTrace(); + } finally { + if(session != null){ + session.close(); + } + } + return null; + } + + public List sqlQueryEntity(StringBuffer sql, Map entityMap) { + if(StringUtil.isBlank(sql.toString())){ + return null; + } + Session session = null; + try { + session = getSession(); + SQLQuery query = session.createSQLQuery(sql.toString()); + if(entityMap != null && entityMap.size() > 0){ + for (String key : entityMap.keySet()) { + Class value = entityMap.get(key); + query.addEntity(key,value); + } + } + return query.list(); + } catch (DataAccessResourceFailureException e) { + e.printStackTrace(); + } catch (HibernateException e) { + e.printStackTrace(); + } catch (IllegalStateException e) { + e.printStackTrace(); + }finally { + if(session != null){ + session.close(); + } + } + return null; + } + + + /** + * 将 SQL 查询结果转换为 不依赖 *.hbm.xml 的 hibernate 自定义查询对象列表 + */ + public List sqlQueryEntityBean(StringBuffer sql, Map entityMap) { + if(StringUtil.isBlank(sql.toString())){ + return null; + } + Session session = null; + try { + session = getSession(); + SQLQuery query = session.createSQLQuery(sql.toString()); + if(entityMap != null && entityMap.size() > 0){ + for (String key : entityMap.keySet()) { + Class value = entityMap.get(key); + //query.addEntity(key,value); + query.setResultTransformer(Transformers.aliasToBean(value)); + } + } + return query.list(); + } catch (DataAccessResourceFailureException e) { + e.printStackTrace(); + } catch (HibernateException e) { + e.printStackTrace(); + } catch (IllegalStateException e) { + e.printStackTrace(); + }finally { + if(session != null){ + session.close(); + } + } + return null; + } + + public List sqlQueryBean(StringBuffer sql, Map entityMap) { + if(StringUtil.isBlank(sql.toString())){ + return null; + } + Session session = null; + try { + session = getSession(); + SQLQuery query = session.createSQLQuery(sql.toString()); + if(entityMap != null && entityMap.size() > 0){ + for (String key : entityMap.keySet()) { + Class value = entityMap.get(key); +// query.addEntity(key,value); + query.setResultTransformer(Transformers.aliasToBean(value)); + } + } + return query.list(); + } catch (DataAccessResourceFailureException e) { + e.printStackTrace(); + } catch (HibernateException e) { + e.printStackTrace(); + } catch (IllegalStateException e) { + e.printStackTrace(); + }finally { + if(session != null){ + session.close(); + } + } + return null; + } + + + public List find(String hql) { + try { + return getHibernateTemplate().find(hql); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/dao/EscapeColumnToBean.java b/src/main/java/me/mofun/dao/EscapeColumnToBean.java new file mode 100644 index 0000000..000d507 --- /dev/null +++ b/src/main/java/me/mofun/dao/EscapeColumnToBean.java @@ -0,0 +1,84 @@ +package me.mofun.dao; + +import org.hibernate.HibernateException; +import org.hibernate.property.ChainedPropertyAccessor; +import org.hibernate.property.PropertyAccessor; +import org.hibernate.property.PropertyAccessorFactory; +import org.hibernate.property.Setter; +import org.hibernate.transform.ResultTransformer; + +import java.lang.reflect.Field; +import java.util.List; + + +/** + * 自定义的数据库字段转换成POJO,以便灵活的使用Hibernate + */ +public class EscapeColumnToBean implements ResultTransformer { + private static final long serialVersionUID = 1L; + private final Class resultClass; + private Setter[] setters; + private PropertyAccessor propertyAccessor; + + public EscapeColumnToBean(Class resultClass) { + if(resultClass==null) throw new IllegalArgumentException("resultClass cannot be null"); + this.resultClass = resultClass; + propertyAccessor = new ChainedPropertyAccessor(new PropertyAccessor[] { PropertyAccessorFactory.getPropertyAccessor(resultClass,null), PropertyAccessorFactory.getPropertyAccessor("field")}); + } + + //结果转换时,HIBERNATE调用此方法 + public Object transformTuple(Object[] tuple, String[] aliases) { + Object result; + + try { + if(setters==null) {//首先初始化,取得目标POJO类的所有SETTER方法 + setters = new Setter[aliases.length]; + for (int i = 0; i < aliases.length; i++) { + String alias = aliases[i]; + if(alias != null) { + //我的逻辑主要是在getSetterByColumnName方法里面,其它都是HIBERNATE的另一个类中COPY的 + //这里填充所需要的SETTER方法 + setters[i] = getSetterByColumnName(alias); + } + } + } + result = resultClass.newInstance(); + + //这里使用SETTER方法填充POJO对象 + for (int i = 0; i < aliases.length; i++) { + if(setters[i]!=null) { + setters[i].set(result, tuple[i], null); + } + } + } catch (InstantiationException e) { + throw new HibernateException("Could not instantiate resultclass: " + resultClass.getName()); + } catch (IllegalAccessException e) { + throw new HibernateException("Could not instantiate resultclass: " + resultClass.getName()); + } + + return result; + } + + //根据数据库字段名在POJO查找JAVA属性名,参数就是数据库字段名,如:USER_ID + private Setter getSetterByColumnName(String alias) { + //取得POJO所有属性名 + Field[] fields = resultClass.getDeclaredFields(); + if(fields==null || fields.length==0){ + throw new RuntimeException("实体"+resultClass.getName()+"不含任何属性"); + } + //把字段名中所有的下杠去除 + String proName = alias.replaceAll("_", "").toLowerCase(); + for (Field field : fields) { + if(field.getName().toLowerCase().equals(proName)){//去除下杠的字段名如果和属性名对得上,就取这个SETTER方法 + return propertyAccessor.getSetter(resultClass, field.getName()); + } + } + throw new RuntimeException("找不到数据库字段 :"+ alias + " 对应的POJO属性或其getter方法,比如数据库字段为USER_ID或USERID,那么JAVA属性应为userId"); + } + + @SuppressWarnings("unchecked") + public List transformList(List collection) { + return collection; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/dao/Pagination.java b/src/main/java/me/mofun/dao/Pagination.java new file mode 100644 index 0000000..59e76c5 --- /dev/null +++ b/src/main/java/me/mofun/dao/Pagination.java @@ -0,0 +1,133 @@ +package me.mofun.dao; + +import java.util.List; + +/** + * 用于分页处理 + * @author songchong email:song316@gmail.com + * + */ +public class Pagination { + + public int pageSize = 10; //每页显示数 + private int pageNo = 0; //当前页码 + private int pageCount = 0; //总页数 + private int resultCount = 0; //总结果数 + private boolean isHaveNext = false; //是否有下一页 + private boolean isHavePrevious = false; //是否有上一页 + private int currentCount; //当前结果数 + private List list = null; //返回结果list  + + public Pagination(){}; + + public Pagination(int pageNo,int pageSize,int resultCount,List list){ + this.pageSize = pageSize; + this.pageNo = pageNo; + this.setResultCount(resultCount); + this.list = list; + this.setCurrentCount(); + } + +// 在设置记录总数时初始化下列值 + public void setResultCount(int resultCount) { + if(resultCount <= 0){ + return ; + } + this.resultCount = resultCount; +// 变量初始化 +// 初始化总页数 pageCount + if(resultCount % pageSize == 0){ + pageCount = resultCount / pageSize; + }else{ + pageCount = resultCount / pageSize + 1; + } +// 初始化是否有下一页 isHaveNext + if(pageNo < pageCount && pageNo > 0){ + this.isHaveNext = true; + } +// 初始化是否有上一页 isHavePrevious + if(pageNo > 1 && pageNo <= pageCount){ + this.isHavePrevious = true; + } + } + +// 返回开始标记 + public int getFirstResult(){ + int firstNo = 1; + firstNo = (pageNo - 1) * pageSize; + return firstNo; + } +// 返回结束标记 + public int getEndResult(){ + int endNo = 1; + if(pageNo == pageCount){ + endNo = resultCount; + }else if(pageNo < pageCount && pageNo > 0){ + endNo = pageNo * pageSize; + } + return endNo; + } +// 设置当前结果数 + public void setCurrentCount() { + if(list != null){ + this.currentCount = list.size(); + } + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public boolean isHaveNext() { + return isHaveNext; + } + + public void setHaveNext(boolean isHaveNext) { + this.isHaveNext = isHaveNext; + } + + public boolean isHavePrevious() { + return isHavePrevious; + } + + public void setHavePrevious(boolean isHavePrevious) { + this.isHavePrevious = isHavePrevious; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public int getResultCount() { + return resultCount; + } + + public int getCurrentCount() { + return currentCount; + } + +} diff --git a/src/main/java/me/mofun/generics/dao/GenericsUtils.java b/src/main/java/me/mofun/generics/dao/GenericsUtils.java new file mode 100644 index 0000000..66bc822 --- /dev/null +++ b/src/main/java/me/mofun/generics/dao/GenericsUtils.java @@ -0,0 +1,51 @@ +package me.mofun.generics.dao; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +/** + * 泛型参数辅助类 + * + * @author DigitalSonic + */ +public class GenericsUtils{ + /** *//** + * 通过反射,获得定义Class时声明的父类的第一个范型参数的类型。 + */ + public static Class getSuperClassGenricType(Class clazz){ + return getSuperClassGenricType(clazz, 0); + } + + /** + * 通过反射,获得定义Class时声明的父类的范型参数的类型。 + * 如没有找到符合要求的范型参数,则递归向上直到Object。 + * + * @param clazz 要进行查询的类 + * @param index 如有多个范型声明该索引从0开始 + * @return 在index位置的范型参数的类型,如果无法判断则返回Object.class + */ + public static Class getSuperClassGenricType(Class clazz, int index){ + boolean flag = true; + Type genType = clazz.getGenericSuperclass(); + Type[] params = null; + + if (!(genType instanceof ParameterizedType)) + flag = false; + else { + params = ((ParameterizedType) genType).getActualTypeArguments(); + if (index >= params.length || index < 0) + flag = false; + if (!(params[index] instanceof Class)) + flag = false; + } + if (!flag) { + clazz = clazz.getSuperclass(); + if (clazz == Object.class) + return Object.class; + else + return getSuperClassGenricType(clazz, index); + } + + return (Class) params[index]; + } +} + diff --git a/src/main/java/me/mofun/generics/dao/HibernateGenericsDao.java b/src/main/java/me/mofun/generics/dao/HibernateGenericsDao.java new file mode 100644 index 0000000..c5e2542 --- /dev/null +++ b/src/main/java/me/mofun/generics/dao/HibernateGenericsDao.java @@ -0,0 +1,368 @@ +package me.mofun.generics.dao; + +import org.hibernate.Criteria; +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.criterion.*; +import org.springframework.orm.hibernate3.HibernateCallback; +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 泛型Hibernate DAO类 + * @author songchong + * + */ +@SuppressWarnings("unchecked") +public class HibernateGenericsDao extends HibernateDaoSupport{ + private Class pojoClass; + + /** + * 初始化DAO,获取POJO类型 + */ + public HibernateGenericsDao(){ + this.pojoClass = GenericsUtils.getSuperClassGenricType(getClass()); + } + + /** *//** + * 获得该DAO对应的POJO类型 + */ + public Class getPojoClass(){ + return this.pojoClass; + } + + /** *//** + * 获得该DAO对应的POJO类型名 + */ + public String getPojoClassName(){ + return getPojoClass().getName(); + } + + //加载对象 + + /** *//** + * 加载所有的对象 + */ + public List loadAll() { + return (List)getHibernateTemplate().loadAll(getPojoClass()); + } + + /** *//** + * 根据hql查询 + * + * @param values 可变参数 + */ + public List find(String hql, Object values) { + return getHibernateTemplate().find(hql, values); + } + + /** *//** + * 根据条件加载对象 + * + * @param criteria Criteria实例 + */ + public List findByCriteria(final Criteria criteria) { + List list = criteria.list(); + return transformResults(list); + } + + /** *//** + * 根据条件加载对象 + * @param detachedCriteria DetachedCriteria实例 + */ + public List findByCriteria(final DetachedCriteria detachedCriteria) { + return (List) getHibernateTemplate().execute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + Criteria criteria = detachedCriteria.getExecutableCriteria(session); + List list = criteria.list(); + return transformResults(list); + } + }); + } + + /** *//** + * 根据给定的实例查找对象 + */ + public List findByExample(T instance) { + List results = (List)getHibernateTemplate().findByExample(instance); + return results; + } + + /** *//** + * 根据ID查找对象 + */ + public T findById(ID id) { + return (T) getHibernateTemplate().get(getPojoClassName(), id); + } + + /** + * 根据某个具体属性进行查找 + */ + public List findByProperty(String propertyName, Object value) { + String queryString = "from " + getPojoClassName() + " as model where model." + + propertyName + "= ?"; + return (List)getHibernateTemplate().find(queryString, value); + } + + //新建、修改、删除 + + /** *//** + * 新建对象实例化 + */ + public ID save(T transientInstance) { + return (ID)getHibernateTemplate().save(transientInstance); + } + + /** *//** + * 更新已存在的对象 + */ + public void update(T transientInstance) { + getHibernateTemplate().update(transientInstance); + } + + /** *//** + * 删除指定ID的对象 + */ + public void delete(ID id) { + T instance = findById(id); + if (instance != null) + getHibernateTemplate().delete(instance); + } + + /** *//** + * 删除指定对象 + */ + public void delete(T persistentInstance) { + getHibernateTemplate().delete(persistentInstance); + } + + //分页 + /** *//** + * 根据Criteria加载分页,指定页大小和起始位置 + */ + public PaginationSupport findPageByCriteria(final Criteria criteria, final int pageSize, final int startIndex) { + int totalCount = getCountByCriteria(criteria); + criteria.setProjection(null); + List items = criteria.setFirstResult(startIndex).setMaxResults(pageSize).list(); + items = transformResults(items); + PaginationSupport ps = new PaginationSupport(items, totalCount, pageSize, startIndex); + return ps; + } + + /** *//** + * 根据Criteria加载分页,默认页大小,从第0条开始 + */ + public PaginationSupport findPageByCriteria(final Criteria criteria) { + return findPageByCriteria(criteria, PaginationSupport.PAGESIZE, 0); + } + + /** *//** + * 根据Criteria加载分页,默认页大小,从第startIndex条开始 + */ + public PaginationSupport findPageByCriteria(final Criteria criteria, final int startIndex) { + return findPageByCriteria(criteria, PaginationSupport.PAGESIZE, startIndex); + } + + /** *//** + * 根据Criteria统计总数 + */ + public int getCountByCriteria(final Criteria criteria) { + Integer count = (Integer) criteria.setProjection(Projections.rowCount()).uniqueResult(); + return count.intValue(); + } + + /** *//** + * 根据DetachedCriteria加载分页,指定页大小和起始位置 + */ + public PaginationSupport findPageByCriteria(final DetachedCriteria detachedCriteria, final int pageSize, final int startIndex) { + return (PaginationSupport) getHibernateTemplate().execute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + Criteria criteria = detachedCriteria.getExecutableCriteria(session); + int totalCount = ((Integer) criteria.setProjection(Projections.rowCount()).uniqueResult()).intValue(); + criteria.setProjection(null); + List items = criteria.setFirstResult(startIndex).setMaxResults(pageSize).list(); + items = transformResults(items); + PaginationSupport ps = new PaginationSupport(items, totalCount, pageSize, startIndex); + return ps; + } + }); + } + + /** *//** + * 根据DetachedCriteria加载分页,默认页大小,从第0条开始 + */ + public PaginationSupport findPageByCriteria(final DetachedCriteria detachedCriteria) { + return findPageByCriteria(detachedCriteria, PaginationSupport.PAGESIZE, 0); + } + + /** *//** + * 根据DetachedCriteria加载分页,默认页大小,从第startIndex条开始 + */ + public PaginationSupport findPageByCriteria(final DetachedCriteria detachedCriteria, final int startIndex) { + return findPageByCriteria(detachedCriteria, PaginationSupport.PAGESIZE, startIndex); + } + + /** *//** + * 根据DetachedCriteria统计总数 + */ + public int getCountByCriteria(final DetachedCriteria detachedCriteria) { + Integer count = (Integer) getHibernateTemplate().execute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + Criteria criteria = detachedCriteria.getExecutableCriteria(session); + return criteria.setProjection(Projections.rowCount()).uniqueResult(); + } + }); + return count.intValue(); + } + + /** *//** + * 根据hql加载分页,指定页大小和起始位置 + */ + public PaginationSupport findPageByQuery(final String hql, final int pageSize, final int startIndex, Object values) { + int totalCount = getCountByQuery(hql, values); + + if (totalCount < 1) + return new PaginationSupport(new ArrayList(0), 0); + + Query query = createQuery(hql, values); + List items = query.setFirstResult(startIndex).setMaxResults(pageSize).list(); + PaginationSupport ps = new PaginationSupport(items, totalCount, pageSize, startIndex); + return ps; + } + + /** *//** + * 根据hql加载分页,默认页大小,从第0条开始 + */ + public PaginationSupport findPageByQuery(final String hql, Object values) { + return findPageByQuery(hql, PaginationSupport.PAGESIZE, 0, values); + } + + /** *//** + * 根据hql加载分页,默认页大小,从第startIndex条开始 + */ + public PaginationSupport findPageByQuery(final String hql, final int startIndex, Object values) { + return findPageByQuery(hql, PaginationSupport.PAGESIZE, startIndex, values); + } + + /** *//** + * 根据hql统计总数 + */ + public int getCountByQuery(final String hql, Object values) { + String countQueryString = " select count (*) " + removeSelect(removeOrders(hql)); + List countlist = getHibernateTemplate().find(countQueryString, values); + return (Integer) countlist.get(0); + } + + //创建Criteria和Query + + /** *//** + * 创建Criteria对象 + * + * @param criterions 可变的Restrictions条件列表 + */ + public Criteria createCriteria(Criterion ... criterions) { + Criteria criteria = getSession().createCriteria(getPojoClass()); + for (Criterion c : criterions) + criteria.add(c); + return criteria; + } + + /** *//** + * 创建Criteria对象,带排序字段与升降序字段 + */ + public Criteria createCriteria(String orderBy, boolean isAsc, Criterion criterions) { + Criteria criteria = createCriteria(criterions); + if (isAsc) + criteria.addOrder(Order.asc(orderBy)); + else + criteria.addOrder(Order.desc(orderBy)); + return criteria; + } + + /** *//** + * 方法取自SpringSide. + * 创建Query对象. 对于需要first,max,fetchsize,cache,cacheRegion等诸多设置的函数,可以在返回Query后自行设置. + * 留意可以连续设置,如下: + *
    +     * dao.getQuery(hql).setMaxResult(100).setCacheable(true).list();
    +     * 
    + * 调用方式如下: + *
    +     *        dao.createQuery(hql)
    +     *        dao.createQuery(hql,arg0);
    +     *        dao.createQuery(hql,arg0,arg1);
    +     *        dao.createQuery(hql,new Object[arg0,arg1,arg2])
    +     * 
    + * + * @param values 可变参数. + */ + public Query createQuery(String hql, Object ... values) { + Query query = getSession().createQuery(hql); + for (int i = 0; i < values.length; i++) { + query.setParameter(i, values[i]); + } + return query; + } + + /** *//** + * 方法取自SpringSide. + * 去除hql的select子句,未考虑union的情况 + */ + private static String removeSelect(String hql) { + int beginPos = hql.toLowerCase().indexOf("from"); + return hql.substring(beginPos); + } + + /** *//** + * 方法取自SpringSide. + * 去除hql的orderby子句 + */ + private static String removeOrders(String hql) { + Pattern p = Pattern.compile("order\\s*by[\\w|\\W|\\s|\\S]*", Pattern.CASE_INSENSITIVE); + Matcher m = p.matcher(hql); + StringBuffer sb = new StringBuffer(); + while (m.find()) { + m.appendReplacement(sb, ""); + } + m.appendTail(sb); + return sb.toString(); + } + + /** *//** + * 将联合查询的结果内容从Map或者Object[]转换为实体类型,如果没有转换必要则直接返回 + */ + private List transformResults(List items) { + if (items.size() > 0) { + if (items.get(0) instanceof Map) { + ArrayList list = new ArrayList(items.size()); + for (int i = 0; i < items.size(); i++) { + Map map = (Map)items.get(i); + list.add(map.get(CriteriaSpecification.ROOT_ALIAS)); + } + return list; + } else if (items.get(0) instanceof Object[]){ + ArrayList list = new ArrayList(items.size()); + int pos = 0; + for (int i = 0; i < ((Object[])items.get(0)).length; i++) { + if (((Object[])items.get(0))[i].getClass() == getPojoClass()) { + pos = i; + break; + } + } + for (int i = 0; i < items.size(); i++) { + list.add(((Object[])items.get(i))[pos]); + } + return list; + } else + return items; + } else + return items; + } +} diff --git a/src/main/java/me/mofun/generics/dao/PaginationSupport.java b/src/main/java/me/mofun/generics/dao/PaginationSupport.java new file mode 100644 index 0000000..5026622 --- /dev/null +++ b/src/main/java/me/mofun/generics/dao/PaginationSupport.java @@ -0,0 +1,173 @@ +package me.mofun.generics.dao; + +import java.util.List; + +/** + * 分页类,参考自JavaEye及SpringSide + */ +public class PaginationSupport{ + public final static int PAGESIZE = 10; + + private int pageSize = PAGESIZE; + + private List items; + + private int totalCount; + + private int[] indexes = new int[0]; + + private int startIndex = 0; + + public PaginationSupport(List items, int totalCount){ + setPageSize(PAGESIZE); + setTotalCount(totalCount); + setItems(items); + setStartIndex(0); + } + + public PaginationSupport(List items, int totalCount, int startIndex){ + setPageSize(PAGESIZE); + setTotalCount(totalCount); + setItems(items); + setStartIndex(startIndex); + } + + public PaginationSupport(List items, int totalCount, int pageSize, int startIndex){ + setPageSize(pageSize); + setTotalCount(totalCount); + setItems(items); + setStartIndex(startIndex); + } + + /** *//** + * 将页码转换为列表的startIndex,页大小为默认大小 + */ + public static int convertFromPageToStartIndex(int pageNo){ + return (pageNo - 1) * PAGESIZE; + } + + /** *//** + * 将页码转换为列表的startIndex + */ + public static int convertFromPageToStartIndex(int pageNo, int pageSize){ + return (pageNo - 1) * pageSize; + } + + public List getItems(){ + return items; + } + + public void setItems(List items){ + this.items = items; + } + + public int getPageSize(){ + return pageSize; + } + + public void setPageSize(int pageSize){ + this.pageSize = pageSize; + } + + public int getTotalCount(){ + return totalCount; + } + + /** *//** + * 设置数据总数,并计算各页起始位置 + */ + public void setTotalCount(int totalCount){ + if (totalCount > 0){ + this.totalCount = totalCount; + int count = totalCount / pageSize; + if (totalCount % pageSize > 0) + count++; + indexes = new int[count]; + for (int i = 0; i < count; i++){ + indexes[i] = pageSize * i; + } + } else{ + this.totalCount = 0; + } + } + + public int[] getIndexes(){ + return indexes; + } + + public void setIndexes(int[] indexes){ + this.indexes = indexes; + } + + public int getStartIndex(){ + return startIndex; + } + + /** *//** + * 设置当前起始位置 + */ + public void setStartIndex(int startIndex){ + if (totalCount <= 0) + this.startIndex = 0; + else if (startIndex >= totalCount) + this.startIndex = indexes[indexes.length - 1]; + else if (startIndex < 0) + this.startIndex = 0; + else{ + this.startIndex = indexes[startIndex / pageSize]; + } + } + + /** *//** + * 获得下页起始位置 + */ + public int getNextIndex(){ + int nextIndex = getStartIndex() + pageSize; + if (nextIndex >= totalCount) + return getStartIndex(); + else + return nextIndex; + } + + /** + * 获得上页起始位置 + */ + public int getPreviousIndex(){ + int previousIndex = getStartIndex() - pageSize; + if (previousIndex < 0) + return 0; + else + return previousIndex; + } + + /** + * 取总页数. + */ + public long getTotalPageCount() { + if (totalCount % pageSize == 0) + return totalCount / pageSize; + else + return totalCount / pageSize + 1; + } + + /** + * 取该页当前页码,页码从1开始. + */ + public long getCurrentPageNo() { + return startIndex / pageSize + 1; + } + + /** + * 该页是否有下一页. + */ + public boolean hasNextPage() { + return this.getCurrentPageNo() < this.getTotalPageCount() - 1; + } + + /** + * 该页是否有上一页. + */ + public boolean hasPreviousPage() { + return this.getCurrentPageNo() > 1; + } +} diff --git a/src/main/java/me/mofun/pay/wxpay/WxPayApi.java b/src/main/java/me/mofun/pay/wxpay/WxPayApi.java new file mode 100644 index 0000000..e31d285 --- /dev/null +++ b/src/main/java/me/mofun/pay/wxpay/WxPayApi.java @@ -0,0 +1,744 @@ +package me.mofun.pay.wxpay; + +import me.mofun.util.DateUtil; +import me.mofun.util.HttpsClientUtils; +import org.apache.log4j.Logger; + +import java.util.Date; +import java.util.Random; +import java.util.UUID; + + + +/** + * 参考 https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=11_1 C#样例 + * 参考:http://www.360doc.com/content/15/0311/13/10675863_454281733.shtml + * @author mofun + * + */ +public class WxPayApi { + + static Logger log = Logger.getLogger(WxPayApi.class); + /** + * 提交被扫支付API + * 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台, + * 由商户收银台或者商户后台调用该接口发起支付。 + * @param WxPayData inputObj 提交给被扫支付API的参数 + * @param int timeOut 超时时间 + * @throws Exception + * @return 成功时返回调用结果,其他抛异常 + */ + public static WxPayData Micropay(WxPayData inputObj, Integer timeOut) + { + if(timeOut==null) + timeOut = 10; + String url = "https://api.mch.weixin.qq.com/pay/micropay"; + try{ + //检测必填参数 + if (!inputObj.IsSet("body")) + { + throw new Exception("提交被扫支付API接口中,缺少必填参数body!"); + } + else if (!inputObj.IsSet("out_trade_no")) + { + throw new Exception("提交被扫支付API接口中,缺少必填参数out_trade_no!"); + } + else if (!inputObj.IsSet("total_fee")) + { + throw new Exception("提交被扫支付API接口中,缺少必填参数total_fee!"); + } + else if (!inputObj.IsSet("auth_code")) + { + throw new Exception("提交被扫支付API接口中,缺少必填参数auth_code!"); + } + } + catch(Exception ex){ + ex.printStackTrace(); + } + + inputObj.SetValue("spbill_create_ip", WxPayConfig.IP);//终端ip + inputObj.SetValue("appid", WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id", WxPayConfig.MCHID);//商户号 + inputObj.SetValue("nonce_str", UUID.randomUUID().toString().replace("-", ""));//随机字符串 + inputObj.SetValue("sign", inputObj.MakeSign());//签名 + String xml = inputObj.ToXml(); + + long start = new Date().getTime();//请求开始时间 + log.debug("WxPayApi:MicroPay request : " + xml); + + //String response = HttpService.Post(xml, url, false, timeOut);//调用HTTP通信接口以提交数据到API + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } log.debug("WxPayApi:MicroPay response : " + response); + + long end = new Date().getTime(); + int timeCost = (int)(end - start);//获得接口耗时毫秒数 + + //将xml格式的结果转换为对象以返回 + WxPayData result = new WxPayData(); + result.FromXml(response); + + ReportCostTime(url, timeCost, result);//测速上报 + + return result; + } + + + /** + * + * 查询订单 + * @param WxPayData inputObj 提交给查询订单API的参数 + * @param int timeOut 超时时间 + * @throws Exception + * @return 成功时返回订单查询结果,其他抛异常 + */ + public static WxPayData OrderQuery(WxPayData inputObj, Integer timeOut) + { + if(timeOut == null) + timeOut =6; + String url = "https://api.mch.weixin.qq.com/pay/orderquery"; + //检测必填参数 + try{ + if (!inputObj.IsSet("out_trade_no") && !inputObj.IsSet("transaction_id")) + { + throw new Exception("订单查询接口中,out_trade_no、transaction_id至少填一个!"); + } + } + catch(Exception ex){ + ex.printStackTrace(); + } + + inputObj.SetValue("appid", WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id", WxPayConfig.MCHID);//商户号 + inputObj.SetValue("nonce_str", WxPayApi.GenerateNonceStr());//随机字符串 + inputObj.SetValue("sign", inputObj.MakeSign());//签名 + + String xml = inputObj.ToXml(); + + long start = new Date().getTime(); + + log.debug("WxPayApi:OrderQuery request : " + xml); + //String response = HttpService.Post(xml, url, false, timeOut);//调用HTTP通信接口提交数据 + + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } + log.debug("WxPayApi:OrderQuery response : " + response); + + long end = new Date().getTime(); + int timeCost = (int)((end - start));//获得接口耗时 + + //将xml格式的数据转化为对象以返回 + WxPayData result = new WxPayData(); + result.FromXml(response); + + ReportCostTime(url, timeCost, result);//测速上报 + + return result; + } + + + /** + * + * 撤销订单API接口 + * @param WxPayData inputObj 提交给撤销订单API接口的参数,out_trade_no和transaction_id必填一个 + * @param int timeOut 接口超时时间 + * @throws Exception + * @return 成功时返回API调用结果,其他抛异常 + */ + public static WxPayData Reverse(WxPayData inputObj, Integer timeOut) + { + if(timeOut==null) + timeOut=6; + String url = "https://api.mch.weixin.qq.com/secapi/pay/reverse"; + + try{ + //检测必填参数 + if (!inputObj.IsSet("out_trade_no") && !inputObj.IsSet("transaction_id")) + { + throw new Exception("撤销订单API接口中,参数out_trade_no和transaction_id必须填写一个!"); + } + }catch(Exception ex){ + ex.printStackTrace(); + } + + inputObj.SetValue("appid", WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id", WxPayConfig.MCHID);//商户号 + inputObj.SetValue("nonce_str", GenerateNonceStr());//随机字符串 + inputObj.SetValue("sign", inputObj.MakeSign());//签名 + String xml = inputObj.ToXml(); + + long start = new Date().getTime();//请求开始时间 + + log.debug("WxPayApi:Reverse request : " + xml); + + //String response = HttpService.Post(xml, url, true, timeOut); + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } log.debug("WxPayApi:Reverse response : " + response); + + long end = new Date().getTime(); + int timeCost = (int)((end - start)); + + WxPayData result = new WxPayData(); + result.FromXml(response); + + ReportCostTime(url, timeCost, result);//测速上报 + + return result; + } + + + /** + * + * 申请退款 + * @param WxPayData inputObj 提交给申请退款API的参数 + * @param int timeOut 超时时间 + * @throws Exception + * @return 成功时返回接口调用结果,其他抛异常 + */ + public static WxPayData Refund(WxPayData inputObj, Integer timeOut) + { + if(timeOut==null) + timeOut = 6; + String url = "https://api.mch.weixin.qq.com/secapi/pay/refund"; + + try{ + //检测必填参数 + if (!inputObj.IsSet("out_trade_no") && !inputObj.IsSet("transaction_id")) + { + throw new Exception("退款申请接口中,out_trade_no、transaction_id至少填一个!"); + } + else if (!inputObj.IsSet("out_refund_no")) + { + throw new Exception("退款申请接口中,缺少必填参数out_refund_no!"); + } + else if (!inputObj.IsSet("total_fee")) + { + throw new Exception("退款申请接口中,缺少必填参数total_fee!"); + } + else if (!inputObj.IsSet("refund_fee")) + { + throw new Exception("退款申请接口中,缺少必填参数refund_fee!"); + } + else if (!inputObj.IsSet("op_user_id")) + { + throw new Exception("退款申请接口中,缺少必填参数op_user_id!"); + } + } + catch(Exception ex) + { + ex.printStackTrace(); + } + inputObj.SetValue("appid", WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id", WxPayConfig.MCHID);//商户号 + inputObj.SetValue("nonce_str", UUID.randomUUID().toString().replace("-", ""));//随机字符串 + inputObj.SetValue("sign", inputObj.MakeSign());//签名 + + String xml = inputObj.ToXml(); + long start = new Date().getTime(); + + log.debug("WxPayApi:Refund request : " + xml); + //String response = HttpService.Post(xml, url, true, timeOut);//调用HTTP通信接口提交数据到API + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } log.debug("WxPayApi:Refund response : " + response); + + long end = new Date().getTime(); + int timeCost = (int)((end - start));//获得接口耗时 + + //将xml格式的结果转换为对象以返回 + WxPayData result = new WxPayData(); + result.FromXml(response); + + ReportCostTime(url, timeCost, result);//测速上报 + + return result; + } + + + /** + * + * 查询退款 + * 提交退款申请后,通过该接口查询退款状态。退款有一定延时, + * 用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。 + * out_refund_no、out_trade_no、transaction_id、refund_id四个参数必填一个 + * @param WxPayData inputObj 提交给查询退款API的参数 + * @param int timeOut 接口超时时间 + * @throws Exception + * @return 成功时返回,其他抛异常 + */ + public static WxPayData RefundQuery(WxPayData inputObj, Integer timeOut) + { + if(timeOut==null) + timeOut = 6; + String url = "https://api.mch.weixin.qq.com/pay/refundquery"; + try{ + //检测必填参数 + if(!inputObj.IsSet("out_refund_no") && !inputObj.IsSet("out_trade_no") && + !inputObj.IsSet("transaction_id") && !inputObj.IsSet("refund_id")) + { + throw new Exception("退款查询接口中,out_refund_no、out_trade_no、transaction_id、refund_id四个参数必填一个!"); + } + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + inputObj.SetValue("appid",WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id",WxPayConfig.MCHID);//商户号 + inputObj.SetValue("nonce_str",GenerateNonceStr());//随机字符串 + inputObj.SetValue("sign",inputObj.MakeSign());//签名 + + String xml = inputObj.ToXml(); + + long start = new Date().getTime();//请求开始时间 + + log.debug("WxPayApi:RefundQuery request : " + xml); + //String response = HttpService.Post(xml, url, false, timeOut);//调用HTTP通信接口以提交数据到API + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } log.debug("WxPayApi:RefundQuery response : " + response); + + long end = new Date().getTime(); + int timeCost = (int)((end-start));//获得接口耗时 + + //将xml格式的结果转换为对象以返回 + WxPayData result = new WxPayData(); + result.FromXml(response); + + ReportCostTime(url, timeCost, result);//测速上报 + + return result; + } + + + /** + * 下载对账单 + * @param WxPayData inputObj 提交给下载对账单API的参数 + * @param int timeOut 接口超时时间 + * @throws Exception + * @return 成功时返回,其他抛异常 + */ + public static WxPayData DownloadBill(WxPayData inputObj, Integer timeOut) + { + if(timeOut==null) + timeOut=6; + String url = "https://api.mch.weixin.qq.com/pay/downloadbill"; + try{ + //检测必填参数 + if (!inputObj.IsSet("bill_date")) + { + throw new Exception("对账单接口中,缺少必填参数bill_date!"); + } + }catch(Exception ex){ + ex.printStackTrace(); + } + + inputObj.SetValue("appid", WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id", WxPayConfig.MCHID);//商户号 + inputObj.SetValue("nonce_str", GenerateNonceStr());//随机字符串 + inputObj.SetValue("sign", inputObj.MakeSign());//签名 + + String xml = inputObj.ToXml(); + + log.debug("WxPayApi:DownloadBill request : " + xml); + //String response = HttpService.Post(xml, url, false, timeOut);//调用HTTP通信接口以提交数据到API + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } log.debug("WxPayApi:DownloadBill result : " + response); + + WxPayData result = new WxPayData(); + //若接口调用失败会返回xml格式的结果 + if (response.substring(0, 5).equals("")) + { + result.FromXml(response); + } + //接口调用成功则返回非xml格式的数据 + else + result.SetValue("result", response); + + return result; + } + + + /** + * + * 转换短链接 + * 该接口主要用于扫码原生支付模式一中的二维码链接转成短链接(weixin://wxpay/s/XXXXXX), + * 减小二维码数据量,提升扫描速度和精确度。 + * @param WxPayData inputObj 提交给转换短连接API的参数 + * @param int timeOut 接口超时时间 + * @throws Exception + * @return 成功时返回,其他抛异常 + */ + public static WxPayData ShortUrl(WxPayData inputObj, Integer timeOut) + { + if(timeOut==null) + timeOut=6; + String url = "https://api.mch.weixin.qq.com/tools/shorturl"; + try{ + //检测必填参数 + if(!inputObj.IsSet("long_url")) + { + throw new Exception("需要转换的URL,签名用原串,传输需URL encode!"); + } + } + catch(Exception ex){ + ex.printStackTrace(); + } + inputObj.SetValue("appid",WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id",WxPayConfig.MCHID);//商户号 + inputObj.SetValue("nonce_str",GenerateNonceStr());//随机字符串 + inputObj.SetValue("sign",inputObj.MakeSign());//签名 + String xml = inputObj.ToXml(); + + long start = new Date().getTime();//请求开始时间 + + log.debug("WxPayApi:ShortUrl request : " + xml); + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } log.debug("WxPayApi:ShortUrl response : " + response); + + long end = new Date().getTime(); + int timeCost = (int)((end - start)); + + WxPayData result = new WxPayData(); + result.FromXml(response); + ReportCostTime(url, timeCost, result);//测速上报 + + return result; + } + + + /** + * + * 统一下单 + * @param WxPaydata inputObj 提交给统一下单API的参数 + * @param int timeOut 超时时间 + * @throws Exception + * @return 成功时返回,其他抛异常 + */ + public static WxPayData UnifiedOrder(WxPayData inputObj, Integer timeOut) + { + if(timeOut==null) + timeOut=6; + String url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; + + try{ + //检测必填参数 + if (!inputObj.IsSet("out_trade_no")) + { + throw new Exception("缺少统一支付接口必填参数out_trade_no!"); + } + else if (!inputObj.IsSet("body")) + { + throw new Exception("缺少统一支付接口必填参数body!"); + } + else if (!inputObj.IsSet("total_fee")) + { + throw new Exception("缺少统一支付接口必填参数total_fee!"); + } + else if (!inputObj.IsSet("trade_type")) + { + throw new Exception("缺少统一支付接口必填参数trade_type!"); + } + + //关联参数 + if (inputObj.GetValue("trade_type").toString().equals("JSAPI") && !inputObj.IsSet("openid")) + { + throw new Exception("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!"); + } + if (inputObj.GetValue("trade_type").toString().equals("NATIVE") && !inputObj.IsSet("product_id")) + { + throw new Exception("统一支付接口中,缺少必填参数product_id!trade_type为JSAPI时,product_id为必填参数!"); + } + } + catch(Exception ex){ + ex.printStackTrace(); + } + + //异步通知url未设置,则使用配置文件中的url + if (!inputObj.IsSet("notify_url")) + { + inputObj.SetValue("notify_url", WxPayConfig.NOTIFY_URL);//异步通知url + } + + inputObj.SetValue("appid", WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id", WxPayConfig.MCHID);//商户号 + inputObj.SetValue("spbill_create_ip", WxPayConfig.IP);//终端ip + inputObj.SetValue("nonce_str", GenerateNonceStr());//随机字符串 + + //签名 + inputObj.SetValue("sign", inputObj.MakeSign()); + String xml = inputObj.ToXml(); + + long start = new Date().getTime(); + + log.debug("WxPayApi:UnfiedOrder request : " + xml); + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } log.debug("WxPayApi:UnfiedOrder response : " + response); + + long end = new Date().getTime(); + int timeCost = (int)((end - start)); + + WxPayData result = new WxPayData(); + result.FromXml(response); + + ReportCostTime(url, timeCost, result);//测速上报 + + return result; + } + + + /** + * + * 关闭订单 + * @param WxPayData inputObj 提交给关闭订单API的参数 + * @param int timeOut 接口超时时间 + * @throws Exception + * @return 成功时返回,其他抛异常 + */ + public static WxPayData CloseOrder(WxPayData inputObj, Integer timeOut) + { + if(timeOut==null) + timeOut=6; + String url = "https://api.mch.weixin.qq.com/pay/closeorder"; + try{ + //检测必填参数 + if(!inputObj.IsSet("out_trade_no")) + { + throw new Exception("关闭订单接口中,out_trade_no必填!"); + } + }catch(Exception ex){ + ex.printStackTrace(); + } + + inputObj.SetValue("appid",WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id",WxPayConfig.MCHID);//商户号 + inputObj.SetValue("nonce_str",GenerateNonceStr());//随机字符串 + inputObj.SetValue("sign",inputObj.MakeSign());//签名 + String xml = inputObj.ToXml(); + + long start = new Date().getTime();//请求开始时间 + + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } + long end = new Date().getTime(); + int timeCost = (int)((end - start)); + + WxPayData result = new WxPayData(); + result.FromXml(response); + + ReportCostTime(url, timeCost, result);//测速上报 + + return result; + } + + + /** + * + * 测速上报 + * @param String interface_url 接口URL + * @param int timeCost 接口耗时 + * @param WxPayData inputObj参数数组 + */ + private static void ReportCostTime(String interface_url, int timeCost, WxPayData inputObj) + { + //如果不需要进行上报 + if(WxPayConfig.REPORT_LEVENL == 0) + { + return; + } + + //如果仅失败上报 + if(WxPayConfig.REPORT_LEVENL == 1 && inputObj.IsSet("return_code") && inputObj.GetValue("return_code").toString().equals("SUCCESS") && + inputObj.IsSet("result_code") && inputObj.GetValue("result_code").toString().equals("SUCCESS")) + { + return; + } + + //上报逻辑 + WxPayData data = new WxPayData(); + data.SetValue("interface_url",interface_url); + data.SetValue("execute_time_",timeCost); + //返回状态码 + if(inputObj.IsSet("return_code")) + { + data.SetValue("return_code",inputObj.GetValue("return_code")); + } + //返回信息 + if(inputObj.IsSet("return_msg")) + { + data.SetValue("return_msg",inputObj.GetValue("return_msg")); + } + //业务结果 + if(inputObj.IsSet("result_code")) + { + data.SetValue("result_code",inputObj.GetValue("result_code")); + } + //错误代码 + if(inputObj.IsSet("err_code")) + { + data.SetValue("err_code",inputObj.GetValue("err_code")); + } + //错误代码描述 + if(inputObj.IsSet("err_code_des")) + { + data.SetValue("err_code_des",inputObj.GetValue("err_code_des")); + } + //商户订单号 + if(inputObj.IsSet("out_trade_no")) + { + data.SetValue("out_trade_no",inputObj.GetValue("out_trade_no")); + } + //设备号 + if(inputObj.IsSet("device_info")) + { + data.SetValue("device_info",inputObj.GetValue("device_info")); + } + + try + { + Report(data,1); + } + catch (Exception ex) + { + //不做任何处理 + } + } + + + /** + * + * 测速上报接口实现 + * @param WxPayData inputObj 提交给测速上报接口的参数 + * @param int timeOut 测速上报接口超时时间 + * @throws Exception + * @return 成功时返回测速上报接口返回的结果,其他抛异常 + */ + public static WxPayData Report(WxPayData inputObj, Integer timeOut) + { + if(timeOut==null) + timeOut=1; + String url = "https://api.mch.weixin.qq.com/payitil/report"; + try{ + //检测必填参数 + if(!inputObj.IsSet("interface_url")) + { + throw new Exception("接口URL,缺少必填参数interface_url!"); + } + if(!inputObj.IsSet("return_code")) + { + throw new Exception("返回状态码,缺少必填参数return_code!"); + } + if(!inputObj.IsSet("result_code")) + { + throw new Exception("业务结果,缺少必填参数result_code!"); + } + if(!inputObj.IsSet("user_ip")) + { + throw new Exception("访问接口IP,缺少必填参数user_ip!"); + } + if(!inputObj.IsSet("execute_time_")) + { + throw new Exception("接口耗时,缺少必填参数execute_time_!"); + } + }catch(Exception ex){ + ex.printStackTrace(); + } + + inputObj.SetValue("appid",WxPayConfig.APPID);//公众账号ID + inputObj.SetValue("mch_id",WxPayConfig.MCHID);//商户号 + inputObj.SetValue("user_ip",WxPayConfig.IP);//终端ip + inputObj.SetValue("time",DateUtil.getCurrentTime());//商户上报时间 + inputObj.SetValue("nonce_str",GenerateNonceStr());//随机字符串 + inputObj.SetValue("sign",inputObj.MakeSign());//签名 + String xml = inputObj.ToXml(); + + log.info("WxPayApi:Report request : " + xml); + + + String response = ""; + try{ + response = HttpsClientUtils.post(url, xml, "application/xml", "UTF-8", timeOut, timeOut); + } + catch(Exception ex){ + ex.printStackTrace(); + } + log.info("WxPayApi:Report response : " + response); + + WxPayData result = new WxPayData(); + result.FromXml(response); + return result; + } + + /** + * 根据当前系统时间加随机序列来生成订单号 + * @return 订单号 + */ + public static String GenerateOutTradeNo() + { + Random ran = new Random(); + ran.setSeed(999); + return String.format("{0}{1}{2}", WxPayConfig.MCHID, DateUtil.getCurrentTime(), ran.nextInt()); + } + + /** + * 生成时间戳,标准北京时间,时区为东八区,自1970年1月1日 0点0分0秒以来的秒数 + * @return 时间戳 + */ + public static String GenerateTimeStamp() + { + return ""+DateUtil.getCurrentMillisecond(); + } + + /** + * 生成随机串,随机串包含字母或数字 + * @return 随机串 + */ + public static String GenerateNonceStr() + { + return UUID.randomUUID().toString().replace("-", ""); + } + +} diff --git a/src/main/java/me/mofun/pay/wxpay/WxPayConfig.java b/src/main/java/me/mofun/pay/wxpay/WxPayConfig.java new file mode 100644 index 0000000..d25aefb --- /dev/null +++ b/src/main/java/me/mofun/pay/wxpay/WxPayConfig.java @@ -0,0 +1,50 @@ +package me.mofun.pay.wxpay; + +import me.mofun.util.ConfigUtil; + +public class WxPayConfig { + + public static String AppKey(String key) { + return ConfigUtil.getValue(key); + } + + // APPID:绑定支付的APPID(必须配置) + public static String APPID = AppKey("wx_appid"); + + // KEY:商户支付密钥,参考开户邮件设置(必须配置) + public static String KEY = AppKey("wx_key"); + + // 商户号(必须配置) + public static String MCHID = AppKey("wx_mchid"); + + // APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置) + public static String APPSECRET = AppKey("wx_appsecret"); + + // 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要) + public static String SSLCERT_PATH = AppKey("wx_sslcert_path"); + + // 证书密码,默认商户号为密码 + public static String SSLCERT_PASSWORD = AppKey("wx_sslcert_password"); + + // 支付结果通知回调url,用于商户接收支付结果 + public static String NOTIFY_URL = AppKey("wx_notify_url"); + + // 日志等级,0.不输出日志;1.只输出错误信息; 2.输出错误和正常信息; 3.输出错误信息、正常信息和调试信息 + public static String LOG_LEVENL = AppKey("log_leven"); + + /// + /// 商户系统后台机器IP,此参数可手动配置也可在程序中自动获取 + /// + public static String IP = "8.8.8.8"; + + /// + /// 代理服务器设置,默认IP和端口号分别为0.0.0.0和0,此时不开启代理(如有需要才设置) + /// + public static String PROXY_URL = "http://10.152.18.220:8080"; + + /// + /// 上报信息配置,测速上报等级,0.关闭上报; 1.仅错误时上报; 2.全量上报 + /// + public static int REPORT_LEVENL = 1; + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pay/wxpay/WxPayData.java b/src/main/java/me/mofun/pay/wxpay/WxPayData.java new file mode 100644 index 0000000..8e127ab --- /dev/null +++ b/src/main/java/me/mofun/pay/wxpay/WxPayData.java @@ -0,0 +1,281 @@ +package me.mofun.pay.wxpay; + +import com.alibaba.fastjson.JSONArray; +import me.mofun.util.MD5Util; + +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + + +/// +/// 微信支付协议接口数据类,所有的API接口通信都依赖这个数据结构, +/// 在调用接口之前先填充各个字段的值,然后进行接口通信, +/// 这样设计的好处是可扩展性强,用户可随意对协议进行更改而不用重新设计数据结构, +/// 还可以随意组合出不同的协议数据包,不用为每个协议设计一个数据包结构 +/// +public class WxPayData +{ + public WxPayData() + { + + } + + //采用排序的Dictionary的好处是方便对数据包进行签名,不用再签名之前再做一次排序 + private SortedMap m_values = new TreeMap(); + + /** + * 设置某个字段的值 + * @param key 字段名 + * @param value 字段值 + */ + public void SetValue(String key, Object value) + { + m_values.put(key, value); + } + + /** + * 根据字段名获取某个字段的值 + * @param key 字段名 + * @return key对应的字段值 + */ + public Object GetValue(String key) + { + return m_values.get(key); + } + + /** + * 判断某个字段是否已设置 + * @param key 字段名 + * @return 若字段key已被设置,则返回true,否则返回false + */ + public boolean IsSet(String key) + { + return m_values.containsKey(key); + } + + /** + * @将Dictionary转成xml + * @return 经转换得到的xml串 + * @throws WxPayException + **/ + public String ToXml() + { + String xml = ""; + try{ + + + //数据为空时不能转化为xml格式 + if (0 == m_values.size()) + { + throw new Exception("WxPayData数据为空!"); + } + + + for(Map.Entry pair : m_values.entrySet()) + { + //字段值不能为null,会影响后续流程 + if (pair.getValue() == null) + { + throw new Exception("WxPayData内部含有值为null的字段!"); + } + + if (pair.getValue() instanceof Integer) + { + xml += "<" + pair.getKey() + ">" + pair.getValue() + ""; + } + else if (pair.getValue() instanceof String) + { + xml += "<" + pair.getKey() + ">" + ""; + } + else//除了string和int类型不能含有其他数据类型 + { + throw new Exception("WxPayData字段数据类型错误!"); + } + } + }catch(Exception ex){ + ex.printStackTrace(); + } + xml += ""; + return xml; + } + + /** + * @将xml转为WxPayData对象并返回对象内部的数据 + * @param string 待转换的xml串 + * @return 经转换得到的Dictionary + * @throws WxPayException + */ + public SortedMap FromXml(String xml) + { + try{ + + if (null==xml&&xml.equals("")) + { + throw new Exception("将空的xml串转换为WxPayData不合法!"); + } + }catch(Exception ex){ + ex.printStackTrace(); + } + + /* + + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(xml); + XmlNode xmlNode = xmlDoc.FirstChild;//获取到根节点 + XmlNodeList nodes = xmlNode.ChildNodes; + foreach (XmlNode xn in nodes) + { + XmlElement xe = (XmlElement)xn; + m_values[xe.Name] = xe.InnerText;//获取xml的键值对到WxPayData内部的数据中 + } + + try + { + //通信成功, 如果通信失败是没有签名 + if (!"SUCCESS".Equals(m_values["return_code"].ToString())) + { + return m_values; + } + CheckSign();//验证签名,不通过会抛异常 + } + catch (WxPayException ex) + { + throw ex; + } + */ + return m_values; + + } + + /** + * @Dictionary格式转化成url参数格式 + * @ return url格式串, 该串不包含sign字段值 + */ + public String ToUrl() + { + StringBuilder buff = new StringBuilder(); + try{ for(Map.Entry pair : m_values.entrySet()) + { + if (pair.getValue() == null) + { + throw new Exception("WxPayData内部含有值为null的字段!"); + } + + if (pair.getKey() != "sign" && pair.getValue().toString() != "") + { + buff.append(pair.getKey()+"="+pair.getValue()+"&"); + } + } + } + catch(Exception ex){ + ex.printStackTrace(); + } + return buff.toString().substring(0, buff.length()-1); + } + + + /** + * @Dictionary格式化成Json + * @return json串数据 + */ + public String ToJson() + { + JSONArray json = new JSONArray(); + json.add(m_values); + String jsonStr = json.toJSONString(); + return jsonStr; + } + + /** + * @values格式化成能在Web页面上显示的结果(因为web页面上不能直接输出xml格式的字符串) + */ + public String ToPrintStr() + { + String str = ""; + try{ + for(Map.Entry pair : m_values.entrySet()) + { + if (pair.getValue() == null) + { + throw new Exception("WxPayData内部含有值为null的字段!"); + } + + str += String.format("{0}={1}
    ", pair.getKey(), pair.getValue().toString()); + } + }catch(Exception ex){ + ex.printStackTrace(); + } + return str; + } + + /** + * @生成签名,详见签名生成算法 + * @return 签名, sign字段不参加签名 + */ + public String MakeSign() + { + //转url格式 + String str = ToUrl(); + //在string后加入API KEY + //str += "&key=" + WxPayConfig.Instance.KEY; + //MD5加密 + + String bs = MD5Util.encode(str); + StringBuilder sb = new StringBuilder(); + /* + for(byte b in bs) + { + sb.Append(b.ToString("x2")); + } + */ + //所有字符转为大写 + //return sb.ToString().ToUpper(); + return bs; + } + + /** + * + * 检测签名是否正确 + * 正确返回true,错误抛异常 + */ + public boolean CheckSign() + { + //如果没有设置签名 + try{ + if (!IsSet("sign")) + { + throw new Exception("WxPayData签名不存在"); + } + //如果设置了签名但是签名为空,则抛异常 + else if (GetValue("sign") == null || GetValue("sign").toString().equals("")) + { + throw new Exception("WxPayData签名存在但不合法!"); + } + + //获取接收到的签名 + String return_sign = GetValue("sign").toString(); + + //在本地计算新的签名 + String cal_sign = MakeSign(); + + if (cal_sign == return_sign) + { + return true; + } + throw new Exception("WxPayData签名验证错误!"); + } + catch(Exception ex){ + ex.printStackTrace(); + } + return false; + } + + /** + * @获取Dictionary + */ + public SortedMap GetValues() + { + return m_values; + } +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pay/wxpay/WxUtil.java b/src/main/java/me/mofun/pay/wxpay/WxUtil.java new file mode 100644 index 0000000..5dd5194 --- /dev/null +++ b/src/main/java/me/mofun/pay/wxpay/WxUtil.java @@ -0,0 +1,157 @@ +package me.mofun.pay.wxpay; + +import me.mofun.util.MyX509TrustManager; +import net.sf.json.JSONObject; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.servlet.http.HttpServletRequest; +import java.io.*; +import java.net.ConnectException; +import java.net.URL; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Formatter; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * reference http://blog.csdn.net/qq_23477421/article/details/51756611 + * @author mofun + * + */ +public class WxUtil { + + /** + * 方法名:httpRequest
    + * 详述:发送http请求
    + * 开发人员:souvc
    + * 创建时间:2016-1-5
    + * @param requestUrl + * @param requestMethod + * @param outputStr + * @return 说明返回值含义 + * @throws 说明发生此异常的条件 + */ + public static JSONObject httpRequest(String requestUrl,String requestMethod, String outputStr) { + JSONObject jsonObject = null; + StringBuffer buffer = new StringBuffer(); + try { + TrustManager[] tm = { new MyX509TrustManager() }; + SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE"); + sslContext.init(null, tm, new java.security.SecureRandom()); + SSLSocketFactory ssf = sslContext.getSocketFactory(); + URL url = new URL(requestUrl); + HttpsURLConnection httpUrlConn = (HttpsURLConnection) url.openConnection(); + httpUrlConn.setSSLSocketFactory(ssf); + httpUrlConn.setDoOutput(true); + httpUrlConn.setDoInput(true); + httpUrlConn.setUseCaches(false); + httpUrlConn.setRequestMethod(requestMethod); + if ("GET".equalsIgnoreCase(requestMethod)) + httpUrlConn.connect(); + if (null != outputStr) { + OutputStream outputStream = httpUrlConn.getOutputStream(); + outputStream.write(outputStr.getBytes("UTF-8")); + outputStream.close(); + } + InputStream inputStream = httpUrlConn.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8"); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + String str = null; + while ((str = bufferedReader.readLine()) != null) { + buffer.append(str); + } + bufferedReader.close(); + inputStreamReader.close(); + inputStream.close(); + inputStream = null; + httpUrlConn.disconnect(); + jsonObject = JSONObject.fromObject(buffer.toString()); + } catch (ConnectException ce) { + ce.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return jsonObject; + } + + + /** + * 方法名:getWxConfig
    + * 详述:获取微信的配置信息
    + * 开发人员:souvc
    + * 创建时间:2016-1-5
    + * @param request + * @return 说明返回值含义 + * @throws 说明发生此异常的条件 + */ + public static Map getWxConfig(HttpServletRequest request) { + Map ret = new HashMap(); + + String appId = "xxxx"; // 必填,公众号的唯一标识 + String secret = "xxxx"; + + String requestUrl = request.getRequestURL().toString(); + String access_token = ""; + String jsapi_ticket = ""; + String timestamp = Long.toString(System.currentTimeMillis() / 1000); // 必填,生成签名的时间戳 + String nonceStr = UUID.randomUUID().toString(); // 必填,生成签名的随机串 + String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+ appId + "&secret=" + secret; + + JSONObject json = WxUtil.httpRequest(url, "GET", null); + + if (json != null) { + //要注意,access_token需要缓存 + access_token = json.getString("access_token"); + + url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token="+ access_token + "&type=jsapi"; + json = WxUtil.httpRequest(url, "GET", null); + if (json != null) { + jsapi_ticket = json.getString("ticket"); + } + } + String signature = ""; + // 注意这里参数名必须全部小写,且必须有序 + String sign = "jsapi_ticket=" + jsapi_ticket + "&noncestr=" + nonceStr+ "×tamp=" + timestamp + "&url=" + requestUrl; + try { + MessageDigest crypt = MessageDigest.getInstance("SHA-1"); + crypt.reset(); + crypt.update(sign.getBytes("UTF-8")); + signature = byteToHex(crypt.digest()); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + ret.put("appId", appId); + ret.put("timestamp", timestamp); + ret.put("nonceStr", nonceStr); + ret.put("signature", signature); + return ret; + } + + + /** + * 方法名:byteToHex
    + * 详述:字符串加密辅助方法
    + * 开发人员:souvc
    + * 创建时间:2016-1-5
    + * @param hash + * @return 说明返回值含义 + * @throws 说明发生此异常的条件 + */ + 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; + + } +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Applymention.hbm.xml b/src/main/java/me/mofun/pojo/Applymention.hbm.xml new file mode 100644 index 0000000..e7cead3 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Applymention.hbm.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + 银行名称 + + + + + 开 户 人 + + + + + 开户支行 + + + + + 银行帐号 + + + + + 联系电话 + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Applymention.java b/src/main/java/me/mofun/pojo/Applymention.java new file mode 100644 index 0000000..e3d253d --- /dev/null +++ b/src/main/java/me/mofun/pojo/Applymention.java @@ -0,0 +1,154 @@ +package me.mofun.pojo; + +/** + * Applymention entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Applymention implements java.io.Serializable { + + // Fields + + private Integer id; + private String date; + private Double money; + private Double fee; + private String bankName; + private String bankUser; + private String bankSubbranch; + private String bankNo; + private String phone; + private Integer userId; + private String status; + + // Constructors + + /** + * @param date + * @param money + * @param fee + * @param bankName + * @param bankUser + * @param bankSubbranch + * @param bankNo + * @param phone + * @param userId + * @param status + */ + public Applymention(String date, Double money, Double fee, String bankName, + String bankUser, String bankSubbranch, String bankNo, String phone, + Integer userId, String status) { + super(); + this.date = date; + this.money = money; + this.fee = fee; + this.bankName = bankName; + this.bankUser = bankUser; + this.bankSubbranch = bankSubbranch; + this.bankNo = bankNo; + this.phone = phone; + this.userId = userId; + this.status = status; + } + + /** default constructor */ + public Applymention() { + } + + /** full constructor */ + + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getDate() { + return this.date; + } + + public void setDate(String date) { + this.date = date; + } + + public Double getMoney() { + return this.money; + } + + public void setMoney(Double money) { + this.money = money; + } + + public Double getFee() { + return this.fee; + } + + public void setFee(Double fee) { + this.fee = fee; + } + + public String getBankName() { + return this.bankName; + } + + public void setBankName(String bankName) { + this.bankName = bankName; + } + + public String getBankUser() { + return this.bankUser; + } + + public void setBankUser(String bankUser) { + this.bankUser = bankUser; + } + + public String getBankSubbranch() { + return this.bankSubbranch; + } + + public void setBankSubbranch(String bankSubbranch) { + this.bankSubbranch = bankSubbranch; + } + + public String getBankNo() { + return this.bankNo; + } + + public void setBankNo(String bankNo) { + this.bankNo = bankNo; + } + + public String getPhone() { + return this.phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public Integer getUserId() { + return this.userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Auctionproduct.hbm.xml b/src/main/java/me/mofun/pojo/Auctionproduct.hbm.xml new file mode 100644 index 0000000..7a3b225 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Auctionproduct.hbm.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + 商品id + + + + + 开始竞拍时间 yyyyMMddHHmmss + + + + + 竞拍结束时间 yyyyMMddHHmmss + + + + + 拍购总人数 + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Auctionproduct.java b/src/main/java/me/mofun/pojo/Auctionproduct.java new file mode 100644 index 0000000..1b9e91d --- /dev/null +++ b/src/main/java/me/mofun/pojo/Auctionproduct.java @@ -0,0 +1,106 @@ +package me.mofun.pojo; + +/** + * Auctionproduct entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Auctionproduct implements java.io.Serializable { + + // Fields + + private Integer auctionProductId; + private Integer fkProductId; + private String auctionStartDate; + private String auctionEndDate; + private String auctionCount; + private String attribute62; + private String attribute63; + + // Constructors + + /** default constructor */ + public Auctionproduct() { + } + + /** minimal constructor */ + public Auctionproduct(Integer fkProductId, String auctionStartDate, + String auctionEndDate, String auctionCount) { + this.fkProductId = fkProductId; + this.auctionStartDate = auctionStartDate; + this.auctionEndDate = auctionEndDate; + this.auctionCount = auctionCount; + } + + /** full constructor */ + public Auctionproduct(Integer fkProductId, String auctionStartDate, + String auctionEndDate, String auctionCount, String attribute62, + String attribute63) { + this.fkProductId = fkProductId; + this.auctionStartDate = auctionStartDate; + this.auctionEndDate = auctionEndDate; + this.auctionCount = auctionCount; + this.attribute62 = attribute62; + this.attribute63 = attribute63; + } + + // Property accessors + + public Integer getAuctionProductId() { + return this.auctionProductId; + } + + public void setAuctionProductId(Integer auctionProductId) { + this.auctionProductId = auctionProductId; + } + + public Integer getFkProductId() { + return this.fkProductId; + } + + public void setFkProductId(Integer fkProductId) { + this.fkProductId = fkProductId; + } + + public String getAuctionStartDate() { + return this.auctionStartDate; + } + + public void setAuctionStartDate(String auctionStartDate) { + this.auctionStartDate = auctionStartDate; + } + + public String getAuctionEndDate() { + return this.auctionEndDate; + } + + public void setAuctionEndDate(String auctionEndDate) { + this.auctionEndDate = auctionEndDate; + } + + public String getAuctionCount() { + return this.auctionCount; + } + + public void setAuctionCount(String auctionCount) { + this.auctionCount = auctionCount; + } + + public String getAttribute62() { + return this.attribute62; + } + + public void setAttribute62(String attribute62) { + this.attribute62 = attribute62; + } + + public String getAttribute63() { + return this.attribute63; + } + + public void setAttribute63(String attribute63) { + this.attribute63 = attribute63; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Auctionrecord.hbm.xml b/src/main/java/me/mofun/pojo/Auctionrecord.hbm.xml new file mode 100644 index 0000000..ff2d313 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Auctionrecord.hbm.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + 竞拍商品id + + + + + 竞拍人 + + + + + 竞拍价 + + + + + 竞拍时间 + + + + + 拼购随机码 + + + + + 中奖状态 0:未中奖 1:中奖 2:未中奖差价购买 + + + + + 竞拍状态 本次竞拍是否成功. 0:未完成1:已完成 + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Auctionrecord.java b/src/main/java/me/mofun/pojo/Auctionrecord.java new file mode 100644 index 0000000..9a7b3be --- /dev/null +++ b/src/main/java/me/mofun/pojo/Auctionrecord.java @@ -0,0 +1,141 @@ +package me.mofun.pojo; + +/** + * Auctionrecord entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Auctionrecord implements java.io.Serializable { + + // Fields + + private Integer auctionRecordId; + private Integer fkAuctionProductId; + private Integer bidder; + private Integer bidderPrice; + private String bidderDate; + private String arRandomNo; + private String arWinningStatus; + private String bidderStatus; + private String attribute68; + private String attribute69; + + // Constructors + + /** default constructor */ + public Auctionrecord() { + } + + /** minimal constructor */ + public Auctionrecord(Integer fkAuctionProductId, Integer bidder, + Integer bidderPrice, String bidderDate, String arRandomNo, + String arWinningStatus, String bidderStatus) { + this.fkAuctionProductId = fkAuctionProductId; + this.bidder = bidder; + this.bidderPrice = bidderPrice; + this.bidderDate = bidderDate; + this.arRandomNo = arRandomNo; + this.arWinningStatus = arWinningStatus; + this.bidderStatus = bidderStatus; + } + + /** full constructor */ + public Auctionrecord(Integer fkAuctionProductId, Integer bidder, + Integer bidderPrice, String bidderDate, String arRandomNo, + String arWinningStatus, String bidderStatus, String attribute68, + String attribute69) { + this.fkAuctionProductId = fkAuctionProductId; + this.bidder = bidder; + this.bidderPrice = bidderPrice; + this.bidderDate = bidderDate; + this.arRandomNo = arRandomNo; + this.arWinningStatus = arWinningStatus; + this.bidderStatus = bidderStatus; + this.attribute68 = attribute68; + this.attribute69 = attribute69; + } + + // Property accessors + + public Integer getAuctionRecordId() { + return this.auctionRecordId; + } + + public void setAuctionRecordId(Integer auctionRecordId) { + this.auctionRecordId = auctionRecordId; + } + + public Integer getFkAuctionProductId() { + return this.fkAuctionProductId; + } + + public void setFkAuctionProductId(Integer fkAuctionProductId) { + this.fkAuctionProductId = fkAuctionProductId; + } + + public Integer getBidder() { + return this.bidder; + } + + public void setBidder(Integer bidder) { + this.bidder = bidder; + } + + public Integer getBidderPrice() { + return this.bidderPrice; + } + + public void setBidderPrice(Integer bidderPrice) { + this.bidderPrice = bidderPrice; + } + + public String getBidderDate() { + return this.bidderDate; + } + + public void setBidderDate(String bidderDate) { + this.bidderDate = bidderDate; + } + + public String getArRandomNo() { + return this.arRandomNo; + } + + public void setArRandomNo(String arRandomNo) { + this.arRandomNo = arRandomNo; + } + + public String getArWinningStatus() { + return this.arWinningStatus; + } + + public void setArWinningStatus(String arWinningStatus) { + this.arWinningStatus = arWinningStatus; + } + + public String getBidderStatus() { + return this.bidderStatus; + } + + public void setBidderStatus(String bidderStatus) { + this.bidderStatus = bidderStatus; + } + + public String getAttribute68() { + return this.attribute68; + } + + public void setAttribute68(String attribute68) { + this.attribute68 = attribute68; + } + + public String getAttribute69() { + return this.attribute69; + } + + public void setAttribute69(String attribute69) { + this.attribute69 = attribute69; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/BuyHistoryJSON.java b/src/main/java/me/mofun/pojo/BuyHistoryJSON.java new file mode 100644 index 0000000..777d9a4 --- /dev/null +++ b/src/main/java/me/mofun/pojo/BuyHistoryJSON.java @@ -0,0 +1,135 @@ +package me.mofun.pojo; + +import java.io.Serializable; + +public class BuyHistoryJSON implements Serializable { + + private Integer productId; + private String productName; + private String productTitle; + private String productImg; + private Integer productPeriod; //商品期数 + private Integer buyStatus;//商品状态 + private String winUser; //获得者 + private String buyTime; //购买时间 + private Long buyCount; //购买总数 + private Integer historyId; //购买记录ID + private Integer winUserId; //获得者ID + private Integer winId; //幸运编号 + private String winDate; //揭晓时间 + private Integer spellbuyCount; //当前购买数 + private Integer productPrice;//商品价格 + public BuyHistoryJSON() { + super(); + } + + + public String getBuyTime() { + return buyTime; + } + + public void setBuyTime(String buyTime) { + this.buyTime = buyTime; + } + + + + public Integer getSpellbuyCount() { + return spellbuyCount; + } + + public void setSpellbuyCount(Integer spellbuyCount) { + this.spellbuyCount = spellbuyCount; + } + + public Integer getProductPrice() { + return productPrice; + } + + public void setProductPrice(Integer productPrice) { + this.productPrice = productPrice; + } + + public Integer getWinUserId() { + return winUserId; + } + + public void setWinUserId(Integer winUserId) { + this.winUserId = winUserId; + } + + public Integer getWinId() { + return winId; + } + + public void setWinId(Integer winId) { + this.winId = winId; + } + + public String getWinDate() { + return winDate; + } + + public void setWinDate(String winDate) { + this.winDate = winDate; + } + + public Integer getProductId() { + return productId; + } + public void setProductId(Integer productId) { + this.productId = productId; + } + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + public String getProductTitle() { + return productTitle; + } + public void setProductTitle(String productTitle) { + this.productTitle = productTitle; + } + public String getProductImg() { + return productImg; + } + public void setProductImg(String productImg) { + this.productImg = productImg; + } + public Integer getProductPeriod() { + return productPeriod; + } + public void setProductPeriod(Integer productPeriod) { + this.productPeriod = productPeriod; + } + public Integer getBuyStatus() { + return buyStatus; + } + public void setBuyStatus(Integer buyStatus) { + this.buyStatus = buyStatus; + } + public String getWinUser() { + return winUser; + } + public void setWinUser(String winUser) { + this.winUser = winUser; + } + public Long getBuyCount() { + return buyCount; + } + + public void setBuyCount(Object buyCount) { + this.buyCount = Long.parseLong((buyCount.toString())); + } + + + public Integer getHistoryId() { + return historyId; + } + public void setHistoryId(Integer historyId) { + this.historyId = historyId; + } + +} diff --git a/src/main/java/me/mofun/pojo/Cardpassword.hbm.xml b/src/main/java/me/mofun/pojo/Cardpassword.hbm.xml new file mode 100644 index 0000000..849167f --- /dev/null +++ b/src/main/java/me/mofun/pojo/Cardpassword.hbm.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Cardpassword.java b/src/main/java/me/mofun/pojo/Cardpassword.java new file mode 100644 index 0000000..d63875a --- /dev/null +++ b/src/main/java/me/mofun/pojo/Cardpassword.java @@ -0,0 +1,49 @@ +package me.mofun.pojo; + + +public class Cardpassword implements java.io.Serializable { + + private static final long serialVersionUID = 2626873670299057819L; + + private Integer id; + private String randomNo; + private String cardPwd; + private Double money; + private String date; + + + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public String getRandomNo() { + return randomNo; + } + public void setRandomNo(String randomNo) { + this.randomNo = randomNo; + } + public String getCardPwd() { + return cardPwd; + } + public void setCardPwd(String cardPwd) { + this.cardPwd = cardPwd; + } + public Double getMoney() { + return money; + } + public void setMoney(Double money) { + this.money = money; + } + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Commissionpoints.hbm.xml b/src/main/java/me/mofun/pojo/Commissionpoints.hbm.xml new file mode 100644 index 0000000..2471622 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Commissionpoints.hbm.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 详情 + + + + + 获得/支出 + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Commissionpoints.java b/src/main/java/me/mofun/pojo/Commissionpoints.java new file mode 100644 index 0000000..4d7c1ee --- /dev/null +++ b/src/main/java/me/mofun/pojo/Commissionpoints.java @@ -0,0 +1,62 @@ +package me.mofun.pojo; + +/** + * Commissionquery entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Commissionpoints implements java.io.Serializable { + + private static final long serialVersionUID = 5429099233990126477L; + + private Integer id; + private Integer toUserId; + private String date; + private String pay; + private String detailed; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getToUserId() { + return toUserId; + } + + public void setToUserId(Integer toUserId) { + this.toUserId = toUserId; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getPay() { + return pay; + } + + public void setPay(String pay) { + this.pay = pay; + } + + public String getDetailed() { + return detailed; + } + + public void setDetailed(String detailed) { + this.detailed = detailed; + } + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Commissionquery.hbm.xml b/src/main/java/me/mofun/pojo/Commissionquery.hbm.xml new file mode 100644 index 0000000..bace620 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Commissionquery.hbm.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + 描述 + + + + + 拍购金额 + + + + + 佣金 + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Commissionquery.java b/src/main/java/me/mofun/pojo/Commissionquery.java new file mode 100644 index 0000000..1ba5c66 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Commissionquery.java @@ -0,0 +1,96 @@ +package me.mofun.pojo; + +/** + * Commissionquery entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Commissionquery implements java.io.Serializable { + + // Fields + + private Integer id; + private String date; + private String description; + private Double buyMoney; + private Double commission; + private Integer toUserId; + private Integer invitedId; + + // Constructors + + /** default constructor */ + public Commissionquery() { + } + + /** full constructor */ + public Commissionquery(String date, String description, Double buyMoney, + Double commission, Integer toUserId, Integer invitedId) { + this.date = date; + this.description = description; + this.buyMoney = buyMoney; + this.commission = commission; + this.toUserId = toUserId; + this.invitedId = invitedId; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getDate() { + return this.date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Double getBuyMoney() { + return this.buyMoney; + } + + public void setBuyMoney(Double buyMoney) { + this.buyMoney = buyMoney; + } + + public Double getCommission() { + return this.commission; + } + + public void setCommission(Double commission) { + this.commission = commission; + } + + public Integer getToUserId() { + return toUserId; + } + + public void setToUserId(Integer toUserId) { + this.toUserId = toUserId; + } + + public Integer getInvitedId() { + return this.invitedId; + } + + public void setInvitedId(Integer invitedId) { + this.invitedId = invitedId; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/CommissionqueryJSON.java b/src/main/java/me/mofun/pojo/CommissionqueryJSON.java new file mode 100644 index 0000000..e1be6f4 --- /dev/null +++ b/src/main/java/me/mofun/pojo/CommissionqueryJSON.java @@ -0,0 +1,50 @@ +package me.mofun.pojo; + +public class CommissionqueryJSON { + + private String userId; + private String userName; + private String date; + private String description; + private Double buyMoney; + private Double commission; + + + public String getUserId() { + return userId; + } + public void setUserId(String userId) { + this.userId = userId; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public Double getBuyMoney() { + return buyMoney; + } + public void setBuyMoney(Double buyMoney) { + this.buyMoney = buyMoney; + } + public Double getCommission() { + return commission; + } + public void setCommission(Double commission) { + this.commission = commission; + } + +} diff --git a/src/main/java/me/mofun/pojo/Consumerdetail.hbm.xml b/src/main/java/me/mofun/pojo/Consumerdetail.hbm.xml new file mode 100644 index 0000000..12bfff7 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Consumerdetail.hbm.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + 消费记录ID + + + + + 商品拍品ID + + + + + 拍购次数 + + + + + 金额 + + + + + 商品标题 + + + + + 商品名称 + + + + + 商品期数 + + + + diff --git a/src/main/java/me/mofun/pojo/Consumerdetail.java b/src/main/java/me/mofun/pojo/Consumerdetail.java new file mode 100644 index 0000000..0cb6cd5 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Consumerdetail.java @@ -0,0 +1,117 @@ +package me.mofun.pojo; + +/** + * Consumerdetail entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Consumerdetail implements java.io.Serializable { + + // Fields + + private Integer id; + private String consumetableId; //消费记录ID + private Integer spellBuyProductId;//商品拍品ID + private Integer buyCount;//拍购次数 + private Double buyMoney;//金额 + private String productTitle;//商品标题 + private String productName;//商品名称 + private Integer productPeriod;//商品期数 + + // Constructors + + /** default constructor */ + public Consumerdetail() { + } + + /** minimal constructor */ + public Consumerdetail(String consumetableId, Integer spellBuyProductId, + Integer buyCount, Double buyMoney, Integer productPeriod) { + this.consumetableId = consumetableId; + this.spellBuyProductId = spellBuyProductId; + this.buyCount = buyCount; + this.buyMoney = buyMoney; + this.productPeriod = productPeriod; + } + + /** full constructor */ + public Consumerdetail(String consumetableId, Integer spellBuyProductId, + Integer buyCount, Double buyMoney, String productTitle, + String productName, Integer productPeriod) { + this.consumetableId = consumetableId; + this.spellBuyProductId = spellBuyProductId; + this.buyCount = buyCount; + this.buyMoney = buyMoney; + this.productTitle = productTitle; + this.productName = productName; + this.productPeriod = productPeriod; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getConsumetableId() { + return consumetableId; + } + + public void setConsumetableId(String consumetableId) { + this.consumetableId = consumetableId; + } + + public Integer getSpellBuyProductId() { + return this.spellBuyProductId; + } + + public void setSpellBuyProductId(Integer spellBuyProductId) { + this.spellBuyProductId = spellBuyProductId; + } + + public Integer getBuyCount() { + return this.buyCount; + } + + public void setBuyCount(Integer buyCount) { + this.buyCount = buyCount; + } + + public Double getBuyMoney() { + return this.buyMoney; + } + + public void setBuyMoney(Double buyMoney) { + this.buyMoney = buyMoney; + } + + public String getProductTitle() { + return this.productTitle; + } + + public void setProductTitle(String productTitle) { + this.productTitle = productTitle; + } + + public String getProductName() { + return this.productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public Integer getProductPeriod() { + return this.productPeriod; + } + + public void setProductPeriod(Integer productPeriod) { + this.productPeriod = productPeriod; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Consumetable.hbm.xml b/src/main/java/me/mofun/pojo/Consumetable.hbm.xml new file mode 100644 index 0000000..a00a5bb --- /dev/null +++ b/src/main/java/me/mofun/pojo/Consumetable.hbm.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + 金额 + + + + + 交易时间 + + + + + 拍购次数 + + + + + 用户ID + + + + + 财付通订单号 + + + + + 商户订单号 + + + + + 接口类型 + + + + diff --git a/src/main/java/me/mofun/pojo/Consumetable.java b/src/main/java/me/mofun/pojo/Consumetable.java new file mode 100644 index 0000000..4d4611d --- /dev/null +++ b/src/main/java/me/mofun/pojo/Consumetable.java @@ -0,0 +1,115 @@ +package me.mofun.pojo; + +/** + * Consumetable entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Consumetable implements java.io.Serializable { + + // Fields + + private Integer id; + private Double money;//金额 + private String date;//交易时间 + private Integer buyCount;//拍购次数 + private Integer userId;//用户ID + private String transactionId;//财付通订单号 + private String outTradeNo;//商户订单号 + private String interfaceType;//接口类型 + + // Constructors + + /** default constructor */ + public Consumetable() { + } + + /** minimal constructor */ + public Consumetable(Double money, String date, + Integer userId) { + this.money = money; + this.date = date; + this.userId = userId; + } + + /** full constructor */ + public Consumetable(Double money, + String date, Integer buyCount, Integer userId, + String transactionId, String outTradeNo, String interfaceType) { + this.money = money; + this.date = date; + this.buyCount = buyCount; + this.userId = userId; + this.transactionId = transactionId; + this.outTradeNo = outTradeNo; + this.interfaceType = interfaceType; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Double getMoney() { + return this.money; + } + + public void setMoney(Double money) { + this.money = money; + } + + public String getDate() { + return this.date; + } + + public void setDate(String date) { + this.date = date; + } + + public Integer getBuyCount() { + return this.buyCount; + } + + public void setBuyCount(Integer buyCount) { + this.buyCount = buyCount; + } + + public Integer getUserId() { + return this.userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getTransactionId() { + return this.transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public String getOutTradeNo() { + return this.outTradeNo; + } + + public void setOutTradeNo(String outTradeNo) { + this.outTradeNo = outTradeNo; + } + + public String getInterfaceType() { + return this.interfaceType; + } + + public void setInterfaceType(String interfaceType) { + this.interfaceType = interfaceType; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/DDNSBindDNSRecord.hbm.xml b/src/main/java/me/mofun/pojo/DDNSBindDNSRecord.hbm.xml new file mode 100644 index 0000000..ae9b634 --- /dev/null +++ b/src/main/java/me/mofun/pojo/DDNSBindDNSRecord.hbm.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + ͼšͨƶκ硢ڲ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0:Ч,״̬ 1:Ƿ 2:ͣ 3:nsupdate delete ɾ + + + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/DDNSBindDNSRecord.java b/src/main/java/me/mofun/pojo/DDNSBindDNSRecord.java new file mode 100644 index 0000000..4c78e47 --- /dev/null +++ b/src/main/java/me/mofun/pojo/DDNSBindDNSRecord.java @@ -0,0 +1,234 @@ +package me.mofun.pojo; +// default package + +import java.sql.Timestamp; + + +/** + * DDNSBindDNSRecord entity. @author MyEclipse Persistence Tools + */ + +public class DDNSBindDNSRecord implements java.io.Serializable { + + + // Fields + + private Integer id; + private String view; + private String zone; + private String host; + private String type; + private String data; + private Integer ttl; + private Integer mxPriority; + private Integer refresh; + private Integer retry; + private Integer expire; + private Integer minimum; + private Integer serial; + private String respPerson; + private String primaryNs; + private Boolean status; + private Timestamp createtime; + private Timestamp modifytime; + private Integer dataCount; + + + // Constructors + + /** default constructor */ + public DDNSBindDNSRecord() { + } + + /** minimal constructor */ + public DDNSBindDNSRecord(String primaryNs, Integer dataCount) { + this.primaryNs = primaryNs; + this.dataCount = dataCount; + } + + /** full constructor */ + public DDNSBindDNSRecord(String view, String zone, String host, String type, String data, Integer ttl, Integer mxPriority, Integer refresh, Integer retry, Integer expire, Integer minimum, Integer serial, String respPerson, String primaryNs, Boolean status, Timestamp createtime, Timestamp modifytime, Integer dataCount) { + this.view = view; + this.zone = zone; + this.host = host; + this.type = type; + this.data = data; + this.ttl = ttl; + this.mxPriority = mxPriority; + this.refresh = refresh; + this.retry = retry; + this.expire = expire; + this.minimum = minimum; + this.serial = serial; + this.respPerson = respPerson; + this.primaryNs = primaryNs; + this.status = status; + this.createtime = createtime; + this.modifytime = modifytime; + this.dataCount = dataCount; + } + + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getView() { + return this.view; + } + + public void setView(String view) { + this.view = view; + } + + public String getZone() { + return this.zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public String getHost() { + return this.host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public String getData() { + return this.data; + } + + public void setData(String data) { + this.data = data; + } + + public Integer getTtl() { + return this.ttl; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public Integer getMxPriority() { + return this.mxPriority; + } + + public void setMxPriority(Integer mxPriority) { + this.mxPriority = mxPriority; + } + + public Integer getRefresh() { + return this.refresh; + } + + public void setRefresh(Integer refresh) { + this.refresh = refresh; + } + + public Integer getRetry() { + return this.retry; + } + + public void setRetry(Integer retry) { + this.retry = retry; + } + + public Integer getExpire() { + return this.expire; + } + + public void setExpire(Integer expire) { + this.expire = expire; + } + + public Integer getMinimum() { + return this.minimum; + } + + public void setMinimum(Integer minimum) { + this.minimum = minimum; + } + + public Integer getSerial() { + return this.serial; + } + + public void setSerial(Integer serial) { + this.serial = serial; + } + + public String getRespPerson() { + return this.respPerson; + } + + public void setRespPerson(String respPerson) { + this.respPerson = respPerson; + } + + public String getPrimaryNs() { + return this.primaryNs; + } + + public void setPrimaryNs(String primaryNs) { + this.primaryNs = primaryNs; + } + + public Boolean getStatus() { + return this.status; + } + + public void setStatus(Boolean status) { + this.status = status; + } + + public Timestamp getCreatetime() { + return this.createtime; + } + + public void setCreatetime(Timestamp createtime) { + this.createtime = createtime; + } + + public Timestamp getModifytime() { + return this.modifytime; + } + + public void setModifytime(Timestamp modifytime) { + this.modifytime = modifytime; + } + + public Integer getDataCount() { + return this.dataCount; + } + + public void setDataCount(Integer dataCount) { + this.dataCount = dataCount; + } + + + + + + + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/DDNSGnudipUser.hbm.xml b/src/main/java/me/mofun/pojo/DDNSGnudipUser.hbm.xml new file mode 100644 index 0000000..e658491 --- /dev/null +++ b/src/main/java/me/mofun/pojo/DDNSGnudipUser.hbm.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + ipdz.meվûid,һipdz.meûעDDNS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ʾû״̬:-1:ɾ,0:,1:,2:Ƿѹ + + + + diff --git a/src/main/java/me/mofun/pojo/DDNSGnudipUser.java b/src/main/java/me/mofun/pojo/DDNSGnudipUser.java new file mode 100644 index 0000000..81d113c --- /dev/null +++ b/src/main/java/me/mofun/pojo/DDNSGnudipUser.java @@ -0,0 +1,238 @@ +package me.mofun.pojo; +// default package + +import java.sql.Timestamp; + + +/** + * gnudipUser entity. @author MyEclipse Persistence Tools + */ + +public class DDNSGnudipUser implements java.io.Serializable { + + + // Fields + + private Integer id; + private Integer ipdzId; + private String username; + private String password; + private String domain; + private String email; + private Timestamp createdate; + private Timestamp enddate; + private String forwardurl; + private Timestamp updated; + private String level; + private String currentip; + private String autourlon; + private String mxvalue; + private String mxbackup; + private String wildcard; + private String allowwild; + private String allowmx; + private Integer status; + + + // Constructors + + /** default constructor */ + public DDNSGnudipUser() { + } + + /** minimal constructor */ + public DDNSGnudipUser(String username, String domain, String level, String mxbackup, String wildcard, String allowwild, String allowmx) { + this.username = username; + this.domain = domain; + this.level = level; + this.mxbackup = mxbackup; + this.wildcard = wildcard; + this.allowwild = allowwild; + this.allowmx = allowmx; + } + + /** full constructor */ + public DDNSGnudipUser(Integer ipdzId, String username, String password, String domain, String email, Timestamp createdate, Timestamp enddate,String forwardurl, Timestamp updated, String level, String currentip, String autourlon, String mxvalue, String mxbackup, String wildcard, String allowwild, String allowmx,Integer status) { + this.ipdzId = ipdzId; + this.username = username; + this.password = password; + this.domain = domain; + this.email = email; + this.createdate = createdate; + this.enddate = enddate; + this.forwardurl = forwardurl; + this.updated = updated; + this.level = level; + this.currentip = currentip; + this.autourlon = autourlon; + this.mxvalue = mxvalue; + this.mxbackup = mxbackup; + this.wildcard = wildcard; + this.allowwild = allowwild; + this.allowmx = allowmx; + this.status = status; + } + + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getIpdzId() { + return this.ipdzId; + } + + public void setIpdzId(Integer ipdzId) { + this.ipdzId = ipdzId; + } + + public String getUsername() { + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return this.password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getDomain() { + return this.domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Timestamp getCreatedate() { + return this.createdate; + } + + public void setCreatedate(Timestamp createdate) { + this.createdate = createdate; + } + + + public Timestamp getEnddate() { + return this.enddate; + } + + public void setEnddate(Timestamp enddate) { + this.enddate = enddate; + } + + public String getForwardurl() { + return this.forwardurl; + } + + public void setForwardurl(String forwardurl) { + this.forwardurl = forwardurl; + } + + public Timestamp getUpdated() { + return this.updated; + } + + public void setUpdated(Timestamp updated) { + this.updated = updated; + } + + public String getLevel() { + return this.level; + } + + public void setLevel(String level) { + this.level = level; + } + + public String getCurrentip() { + return this.currentip; + } + + public void setCurrentip(String currentip) { + this.currentip = currentip; + } + + public String getAutourlon() { + return this.autourlon; + } + + public void setAutourlon(String autourlon) { + this.autourlon = autourlon; + } + + public String getMxvalue() { + return this.mxvalue; + } + + public void setMxvalue(String mxvalue) { + this.mxvalue = mxvalue; + } + + public String getMxbackup() { + return this.mxbackup; + } + + public void setMxbackup(String mxbackup) { + this.mxbackup = mxbackup; + } + + public String getWildcard() { + return this.wildcard; + } + + public void setWildcard(String wildcard) { + this.wildcard = wildcard; + } + + public String getAllowwild() { + return this.allowwild; + } + + public void setAllowwild(String allowwild) { + this.allowwild = allowwild; + } + + public String getAllowmx() { + return this.allowmx; + } + + public void setAllowmx(String allowmx) { + this.allowmx = allowmx; + } + + public Integer getStatus() { + return this.status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + + + + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/DetailBybuyerJSON.java b/src/main/java/me/mofun/pojo/DetailBybuyerJSON.java new file mode 100644 index 0000000..118b6ee --- /dev/null +++ b/src/main/java/me/mofun/pojo/DetailBybuyerJSON.java @@ -0,0 +1,64 @@ +package me.mofun.pojo; + +public class DetailBybuyerJSON { + + private String userId; + private String userName; + private String buyTime; + private String faceImg; + private String randomNumber; + private String buyCount; + + + public DetailBybuyerJSON() { + super(); + } + public DetailBybuyerJSON(String userId, String userName, String buyTime, + String faceImg, String randomNumber, String buyCount) { + super(); + this.userId = userId; + this.userName = userName; + this.buyTime = buyTime; + this.faceImg = faceImg; + this.randomNumber = randomNumber; + this.buyCount = buyCount; + } + public String getUserId() { + return userId; + } + public void setUserId(String userId) { + this.userId = userId; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getBuyTime() { + return buyTime; + } + public void setBuyTime(String buyTime) { + this.buyTime = buyTime; + } + public String getFaceImg() { + return faceImg; + } + public void setFaceImg(String faceImg) { + this.faceImg = faceImg; + } + public String getRandomNumber() { + return randomNumber; + } + public void setRandomNumber(String randomNumber) { + this.randomNumber = randomNumber; + } + public String getBuyCount() { + return buyCount; + } + public void setBuyCount(String buyCount) { + this.buyCount = buyCount; + } + + +} diff --git a/src/main/java/me/mofun/pojo/Friends.hbm.xml b/src/main/java/me/mofun/pojo/Friends.hbm.xml new file mode 100644 index 0000000..90cf88c --- /dev/null +++ b/src/main/java/me/mofun/pojo/Friends.hbm.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Friends.java b/src/main/java/me/mofun/pojo/Friends.java new file mode 100644 index 0000000..a8eeede --- /dev/null +++ b/src/main/java/me/mofun/pojo/Friends.java @@ -0,0 +1,55 @@ +package me.mofun.pojo; + +/** + * Friends entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Friends implements java.io.Serializable { + + // Fields + + private Integer id; + private Integer friendsId; + private Integer userId; + + // Constructors + + /** default constructor */ + public Friends() { + } + + /** full constructor */ + public Friends(Integer friendsId, Integer userId) { + this.friendsId = friendsId; + this.userId = userId; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getFriendsId() { + return this.friendsId; + } + + public void setFriendsId(Integer friendsId) { + this.friendsId = friendsId; + } + + public Integer getUserId() { + return this.userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/HelpInfo.java b/src/main/java/me/mofun/pojo/HelpInfo.java new file mode 100644 index 0000000..8245c60 --- /dev/null +++ b/src/main/java/me/mofun/pojo/HelpInfo.java @@ -0,0 +1,38 @@ +package me.mofun.pojo; + +import java.util.List; + +public class HelpInfo { + + + private Integer categoryId; //帮助信息所属类别 + private String categoryName; //帮助信息所属类别名称 + List InfoList; //该类别下所有信息的列表 + + + public HelpInfo() { + // TODO Auto-generated constructor stub + } + + + public Integer getCategoryId() { + return categoryId; + } + public void setCategoryId(Integer categoryId) { + this.categoryId = categoryId; + } + public String getCategoryName() { + return categoryName; + } + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + public List getInfoList() { + return InfoList; + } + public void setInfoList(List infoList) { + InfoList = infoList; + } + + +} diff --git a/src/main/java/me/mofun/pojo/HibernateSessionFactory.java b/src/main/java/me/mofun/pojo/HibernateSessionFactory.java new file mode 100644 index 0000000..07b3e2e --- /dev/null +++ b/src/main/java/me/mofun/pojo/HibernateSessionFactory.java @@ -0,0 +1,116 @@ +package me.mofun.pojo; + +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.cfg.Configuration; + +/** + * Configures and provides access to Hibernate sessions, tied to the + * current thread of execution. Follows the Thread Local Session + * pattern, see {@link http://hibernate.org/42.html }. + */ +public class HibernateSessionFactory { + + /** + * Location of hibernate.cfg.xml file. + * Location should be on the classpath as Hibernate uses + * #resourceAsStream style lookup for its configuration file. + * The default classpath location of the hibernate config file is + * in the default package. Use #setConfigFile() to update + * the location of the configuration file for the current session. + */ + private static final ThreadLocal threadLocal = new ThreadLocal(); + private static org.hibernate.SessionFactory sessionFactory; + + private static Configuration configuration = new Configuration(); + private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml"; + private static String configFile = CONFIG_FILE_LOCATION; + + static { + try { + configuration.configure(configFile); + sessionFactory = configuration.buildSessionFactory(); + } catch (Exception e) { + System.err.println("%%%% Error Creating SessionFactory %%%%"); + e.printStackTrace(); + } + } + private HibernateSessionFactory() { + } + + /** + * Returns the ThreadLocal Session instance. Lazy initialize + * the SessionFactory if needed. + * + * @return Session + * @throws HibernateException + */ + public static Session getSession() throws HibernateException { + Session session = (Session) threadLocal.get(); + + if (session == null || !session.isOpen()) { + if (sessionFactory == null) { + rebuildSessionFactory(); + } + session = (sessionFactory != null) ? sessionFactory.openSession() + : null; + threadLocal.set(session); + } + + return session; + } + + /** + * Rebuild hibernate session factory + * + */ + public static void rebuildSessionFactory() { + try { + configuration.configure(configFile); + sessionFactory = configuration.buildSessionFactory(); + } catch (Exception e) { + System.err.println("%%%% Error Creating SessionFactory %%%%"); + e.printStackTrace(); + } + } + + /** + * Close the single hibernate session instance. + * + * @throws HibernateException + */ + public static void closeSession() throws HibernateException { + Session session = (Session) threadLocal.get(); + threadLocal.set(null); + + if (session != null) { + session.close(); + } + } + + /** + * return session factory + * + */ + public static org.hibernate.SessionFactory getSessionFactory() { + return sessionFactory; + } + + /** + * return session factory + * + * session factory will be rebuilded in the next call + */ + public static void setConfigFile(String configFile) { + HibernateSessionFactory.configFile = configFile; + sessionFactory = null; + } + /** + * return hibernate configuration + * + */ + public static Configuration getConfiguration() { + return configuration; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/IndexImg.hbm.xml b/src/main/java/me/mofun/pojo/IndexImg.hbm.xml new file mode 100644 index 0000000..5227d4b --- /dev/null +++ b/src/main/java/me/mofun/pojo/IndexImg.hbm.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + 标题 + + + + + URL链接 + + + + + 商品幻灯图片 + + + + + + + diff --git a/src/main/java/me/mofun/pojo/IndexImg.java b/src/main/java/me/mofun/pojo/IndexImg.java new file mode 100644 index 0000000..6141401 --- /dev/null +++ b/src/main/java/me/mofun/pojo/IndexImg.java @@ -0,0 +1,76 @@ +package me.mofun.pojo; + +/** + * IndexImg entity. + * + * @author MyEclipse Persistence Tools + */ + +public class IndexImg implements java.io.Serializable { + + // Fields + + private Integer id; + private String title; + private String proUrl; + private String proImg; + private Integer status; + + // Constructors + + /** default constructor */ + public IndexImg() { + } + + /** full constructor */ + public IndexImg(String title, String proUrl, String proImg,Integer status) { + this.title = title; + this.proUrl = proUrl; + this.proImg = proImg; + this.status = status; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getProUrl() { + return this.proUrl; + } + + public void setProUrl(String proUrl) { + this.proUrl = proUrl; + } + + public String getProImg() { + return this.proImg; + } + + public void setProImg(String proImg) { + this.proImg = proImg; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Latestlottery.hbm.xml b/src/main/java/me/mofun/pojo/Latestlottery.hbm.xml new file mode 100644 index 0000000..e60017a --- /dev/null +++ b/src/main/java/me/mofun/pojo/Latestlottery.hbm.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + 商品ID + + + + + 商品名称 + + + + + 商品Title + + + + + 商品价格 + + + + + 商品图片 + + + + + 商品期数 + + + + + 获得人名称 + + + + + 所在地 + + + + + 揭晓时间 + + + + + 揭晓类型(1限时0普通) + + + + + 购买时间 + + + + + 购买记录ID + + + + + 某期商品ID + + + + + 中奖码 + + + + + 时间总和 + + + + + 购买总数 + + + + + 用户ID + + + + + 手机号域邮箱 + + + + + 用户头像 + + + + + 状态 1未提交收获地址 2等待发货 3等待收货 4已确认收货 10交易完成 11交易取消 + + + + + 晒单状态 -1 暂未晒单 0等待审核 1未审核通过,请重新修改晒单信息 2审核通过,奖励10元 + + + + + 晒单ID + + + + + 购买类型:1拍购,2电商普选购,可对应sys_configure的versionType字段 + + + + diff --git a/src/main/java/me/mofun/pojo/Latestlottery.java b/src/main/java/me/mofun/pojo/Latestlottery.java new file mode 100644 index 0000000..457d30d --- /dev/null +++ b/src/main/java/me/mofun/pojo/Latestlottery.java @@ -0,0 +1,290 @@ +package me.mofun.pojo; + +/** + * Latestlottery entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Latestlottery implements java.io.Serializable { + + private static final long serialVersionUID = -9159929891012838918L; + private Integer id; + private Integer productId; + private String productName; + private String productTitle; + private Integer productPrice; + private String productImg; + private Integer productPeriod; + private String userName; + private String location; + private String announcedTime; + private Integer announcedType; + private String buyTime; + private Integer spellbuyRecordId; + private Integer spellbuyProductId; + private Integer randomNumber; + private Long dateSum; + private Integer sscNumber; + private Long sscPeriod; + private Integer buyNumberCount; + private Integer userId; + private String buyUser; + private String userFace; + private Integer status; + private Integer shareStatus; + private Integer shareId; + private Integer buyType; + + // Constructors + + public Latestlottery(Integer productId, String productName, + String productTitle, Integer productPrice, String productImg, + Integer productPeriod, String userName, String location, + String announcedTime, Integer announcedType, String buyTime, + Integer spellbuyRecordId, Integer spellbuyProductId, + Integer randomNumber, Long dateSum, Integer buyNumberCount, + Integer userId, String buyUser, String userFace, Integer status, + Integer shareStatus, Integer shareId,Integer buyType) { + super(); + this.productId = productId; + this.productName = productName; + this.productTitle = productTitle; + this.productPrice = productPrice; + this.productImg = productImg; + this.productPeriod = productPeriod; + this.userName = userName; + this.location = location; + this.announcedTime = announcedTime; + this.announcedType = announcedType; + this.buyTime = buyTime; + this.spellbuyRecordId = spellbuyRecordId; + this.spellbuyProductId = spellbuyProductId; + this.randomNumber = randomNumber; + this.dateSum = dateSum; + this.buyNumberCount = buyNumberCount; + this.userId = userId; + this.buyUser = buyUser; + this.userFace = userFace; + this.status = status; + this.shareStatus = shareStatus; + this.shareId = shareId; + this.buyType = buyType; + } + + public Latestlottery() { + super(); + } + + + + public String getUserFace() { + return userFace; + } + + public void setUserFace(String userFace) { + this.userFace = userFace; + } + + /** full constructor */ + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getProductId() { + return this.productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public String getProductName() { + return this.productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProductTitle() { + return this.productTitle; + } + + public void setProductTitle(String productTitle) { + this.productTitle = productTitle; + } + + public Integer getProductPrice() { + return this.productPrice; + } + + public void setProductPrice(Integer productPrice) { + this.productPrice = productPrice; + } + + public String getProductImg() { + return this.productImg; + } + + public void setProductImg(String productImg) { + this.productImg = productImg; + } + + public Integer getProductPeriod() { + return this.productPeriod; + } + + public void setProductPeriod(Integer productPeriod) { + this.productPeriod = productPeriod; + } + + public String getUserName() { + return this.userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getAnnouncedTime() { + return this.announcedTime; + } + + public void setAnnouncedTime(String announcedTime) { + this.announcedTime = announcedTime; + } + + public String getBuyTime() { + return this.buyTime; + } + + public void setBuyTime(String buyTime) { + this.buyTime = buyTime; + } + + public Integer getRandomNumber() { + return this.randomNumber; + } + + public void setRandomNumber(Integer randomNumber) { + this.randomNumber = randomNumber; + } + + public Integer getSscNumber() { + return this.buyNumberCount; + } + public void setSscNumber(Integer sscNumber) { + this.sscNumber = sscNumber; + } + + public Long getSscPeriod() { + return this.sscPeriod; + } + + public void setSscPeriod(Long sscPeriod) { + this.sscPeriod = sscPeriod; + } + + public Integer getBuyNumberCount() { + return this.buyNumberCount; + } + + public void setBuyNumberCount(Integer buyNumberCount) { + this.buyNumberCount = buyNumberCount; + } + + public String getBuyUser() { + return buyUser; + } + + public void setBuyUser(String buyUser) { + this.buyUser = buyUser; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + public Integer getShareStatus() { + return shareStatus; + } + + public void setShareStatus(Integer shareStatus) { + this.shareStatus = shareStatus; + } + public Integer getShareId() { + return shareId; + } + + public void setShareId(Integer shareId) { + this.shareId = shareId; + } + + public Integer getSpellbuyRecordId() { + return spellbuyRecordId; + } + + public void setSpellbuyRecordId(Integer spellbuyRecordId) { + this.spellbuyRecordId = spellbuyRecordId; + } + + public Integer getSpellbuyProductId() { + return spellbuyProductId; + } + + public void setSpellbuyProductId(Integer spellbuyProductId) { + this.spellbuyProductId = spellbuyProductId; + } + + public Long getDateSum() { + return dateSum; + } + + public void setDateSum(Long dateSum) { + this.dateSum = dateSum; + } + public Integer getAnnouncedType() { + return announcedType; + } + public void setAnnouncedType(Integer announcedType) { + this.announcedType = announcedType; + } + + public Integer getBuyType() { + return buyType; + } + + public void setBuyType(Integer buyType) { + this.buyType = buyType; + } + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/LotteryDetailJSON.java b/src/main/java/me/mofun/pojo/LotteryDetailJSON.java new file mode 100644 index 0000000..5ab58d5 --- /dev/null +++ b/src/main/java/me/mofun/pojo/LotteryDetailJSON.java @@ -0,0 +1,99 @@ +package me.mofun.pojo; + +import java.io.Serializable; + +public class LotteryDetailJSON implements Serializable{ + + private Integer productId; + private String productName; + private String productTitle; + private Integer productPeriod; //商品期数 + private String userName; + private Integer userId; + private String buyTime; //购买时间 + private Integer buyCount; //购买总数 + private String buyDate;//购买日期 + private String dateSum;//日期和 + public LotteryDetailJSON() { + super(); + } + public LotteryDetailJSON(Integer productId, String productName, + String productTitle, Integer productPeriod, String userName, + Integer userId, String buyTime, Integer buyCount, String buyDate, + String dateSum) { + super(); + this.productId = productId; + this.productName = productName; + this.productTitle = productTitle; + this.productPeriod = productPeriod; + this.userName = userName; + this.userId = userId; + this.buyTime = buyTime; + this.buyCount = buyCount; + this.buyDate = buyDate; + this.dateSum = dateSum; + } + public Integer getProductId() { + return productId; + } + public void setProductId(Integer productId) { + this.productId = productId; + } + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + public String getProductTitle() { + return productTitle; + } + public void setProductTitle(String productTitle) { + this.productTitle = productTitle; + } + public Integer getProductPeriod() { + return productPeriod; + } + public void setProductPeriod(Integer productPeriod) { + this.productPeriod = productPeriod; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public Integer getUserId() { + return userId; + } + public void setUserId(Integer userId) { + this.userId = userId; + } + public String getBuyTime() { + return buyTime; + } + public void setBuyTime(String buyTime) { + this.buyTime = buyTime; + } + public Integer getBuyCount() { + return buyCount; + } + public void setBuyCount(Integer buyCount) { + this.buyCount = buyCount; + } + public String getBuyDate() { + return buyDate; + } + public void setBuyDate(String buyDate) { + this.buyDate = buyDate; + } + public String getDateSum() { + return dateSum; + } + public void setDateSum(String dateSum) { + this.dateSum = dateSum; + } + + + +} diff --git a/src/main/java/me/mofun/pojo/Lotteryproductutil.hbm.xml b/src/main/java/me/mofun/pojo/Lotteryproductutil.hbm.xml new file mode 100644 index 0000000..644813e --- /dev/null +++ b/src/main/java/me/mofun/pojo/Lotteryproductutil.hbm.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Lotteryproductutil.java b/src/main/java/me/mofun/pojo/Lotteryproductutil.java new file mode 100644 index 0000000..30b1fcf --- /dev/null +++ b/src/main/java/me/mofun/pojo/Lotteryproductutil.java @@ -0,0 +1,108 @@ +package me.mofun.pojo; + +/** + * Lotteryproductutil entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Lotteryproductutil implements java.io.Serializable { + + // Fields + + private Integer lotteryId; + private Integer lotteryProductId; + private String lotteryProductName; + private String lotteryProductTitle; + private Integer lotteryProductPrice; + private Integer lotteryProductPeriod; + private String lotteryProductImg; + private String lotteryProductEndDate; + + // Constructors + + /** default constructor */ + public Lotteryproductutil() { + } + + /** full constructor */ + public Lotteryproductutil(Integer lotteryProductId, + String lotteryProductName, String lotteryProductTitle, + Integer lotteryProductPrice, Integer lotteryProductPeriod, + String lotteryProductImg, String lotteryProductEndDate) { + this.lotteryProductId = lotteryProductId; + this.lotteryProductName = lotteryProductName; + this.lotteryProductTitle = lotteryProductTitle; + this.lotteryProductPrice = lotteryProductPrice; + this.lotteryProductPeriod = lotteryProductPeriod; + this.lotteryProductImg = lotteryProductImg; + this.lotteryProductEndDate = lotteryProductEndDate; + } + + // Property accessors + + public Integer getLotteryId() { + return this.lotteryId; + } + + public void setLotteryId(Integer lotteryId) { + this.lotteryId = lotteryId; + } + + public Integer getLotteryProductId() { + return this.lotteryProductId; + } + + public void setLotteryProductId(Integer lotteryProductId) { + this.lotteryProductId = lotteryProductId; + } + + public String getLotteryProductName() { + return this.lotteryProductName; + } + + public void setLotteryProductName(String lotteryProductName) { + this.lotteryProductName = lotteryProductName; + } + + public String getLotteryProductTitle() { + return this.lotteryProductTitle; + } + + public void setLotteryProductTitle(String lotteryProductTitle) { + this.lotteryProductTitle = lotteryProductTitle; + } + + public Integer getLotteryProductPrice() { + return this.lotteryProductPrice; + } + + public void setLotteryProductPrice(Integer lotteryProductPrice) { + this.lotteryProductPrice = lotteryProductPrice; + } + + public Integer getLotteryProductPeriod() { + return this.lotteryProductPeriod; + } + + public void setLotteryProductPeriod(Integer lotteryProductPeriod) { + this.lotteryProductPeriod = lotteryProductPeriod; + } + + public String getLotteryProductImg() { + return this.lotteryProductImg; + } + + public void setLotteryProductImg(String lotteryProductImg) { + this.lotteryProductImg = lotteryProductImg; + } + + public String getLotteryProductEndDate() { + return this.lotteryProductEndDate; + } + + public void setLotteryProductEndDate(String lotteryProductEndDate) { + this.lotteryProductEndDate = lotteryProductEndDate; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Message.hbm.xml b/src/main/java/me/mofun/pojo/Message.hbm.xml new file mode 100644 index 0000000..3bf9132 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Message.hbm.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + 信息 + + + + + + + + 信息类型 + + + + + 状态 + + + + diff --git a/src/main/java/me/mofun/pojo/Message.java b/src/main/java/me/mofun/pojo/Message.java new file mode 100644 index 0000000..047be64 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Message.java @@ -0,0 +1,96 @@ +package me.mofun.pojo; + +/** + * Message entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Message implements java.io.Serializable { + + // Fields + + private Integer id; + private Integer userId; + private Integer sender; + private String message; + private String date; + private Integer type; + private Integer status; + + // Constructors + + /** default constructor */ + public Message() { + } + + /** full constructor */ + public Message(Integer userId, Integer sender, String message, String date, + Integer type, Integer status) { + this.userId = userId; + this.sender = sender; + this.message = message; + this.date = date; + this.type = type; + this.status = status; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUserId() { + return this.userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getSender() { + return this.sender; + } + + public void setSender(Integer sender) { + this.sender = sender; + } + + public String getMessage() { + return this.message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getDate() { + return this.date; + } + + public void setDate(String date) { + this.date = date; + } + + public Integer getType() { + return this.type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getStatus() { + return this.status; + } + + public void setStatus(Integer status) { + this.status = status; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/News.hbm.xml b/src/main/java/me/mofun/pojo/News.hbm.xml new file mode 100644 index 0000000..a4ffacb --- /dev/null +++ b/src/main/java/me/mofun/pojo/News.hbm.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + 标题 + + + + + 信息类别Id + + + + + 作者Id,来自于User表的userId字段 + + + + + 发布时间 + + + + + 内容 + + + + diff --git a/src/main/java/me/mofun/pojo/News.java b/src/main/java/me/mofun/pojo/News.java new file mode 100644 index 0000000..9fbb7da --- /dev/null +++ b/src/main/java/me/mofun/pojo/News.java @@ -0,0 +1,85 @@ +package me.mofun.pojo; + +/** + * News entity. + * + * @author MyEclipse Persistence Tools + */ + +public class News implements java.io.Serializable { + + // Fields + + private Integer newsId; + private String title; + private Integer categoryId; + private String postDate; + private String content; + private String userId; + + // Constructors + + /** default constructor */ + public News() { + } + + /** full constructor */ + public News(String title,Integer categoryId, String postDate, String content) { + this.title = title; + this.categoryId = categoryId; + this.postDate = postDate; + this.content = content; + } + + // Property accessors + + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getCategoryId() { + return categoryId; + } + + public void setCategoryId(Integer categoryId) { + this.categoryId = categoryId; + } + + public String getPostDate() { + return this.postDate; + } + + public void setPostDate(String postDate) { + this.postDate = postDate; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public Integer getNewsId() { + return newsId; + } + + public void setNewsId(Integer newsId) { + this.newsId = newsId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/NewsReply.hbm.xml b/src/main/java/me/mofun/pojo/NewsReply.hbm.xml new file mode 100644 index 0000000..b4d7075 --- /dev/null +++ b/src/main/java/me/mofun/pojo/NewsReply.hbm.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + 新闻话题Id + + + + + 父回复话题Id + + + + + 回复者UserId,来自于User表的UserId + + + + + 被回复者Id,来自于User表的userId字段,同时是某个新闻话题的作者或回复者 + + + + + 回复时间 + + + + + 回复内容 + + + + + 是否显示该回复 + + + + + 是否能继续回复该回复 + + + + + 该条信息的状态 + + + + \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/NewsReply.java b/src/main/java/me/mofun/pojo/NewsReply.java new file mode 100644 index 0000000..dde2e33 --- /dev/null +++ b/src/main/java/me/mofun/pojo/NewsReply.java @@ -0,0 +1,121 @@ +package me.mofun.pojo; + +import java.sql.Timestamp; + +/** + * News entity. + * + * @author MyEclipse Persistence Tools + */ + +public class NewsReply implements java.io.Serializable { + + // Fields + private Integer replyId; + private Integer newsId; + private Integer parentReplyId; + private String userId; + private String toUserId; + private Timestamp postDate; + private String content; + private Integer isShow; + private Integer isCanReply; + private Integer status; + + // Constructors + + /** default constructor */ + public NewsReply() { + } + + /** full constructor */ + public NewsReply(Integer replyId,Integer newsId, Integer parentReplyId,Timestamp postDate, String content) { + this.replyId = replyId; + this.newsId = newsId; + this.parentReplyId=parentReplyId; + this.postDate = postDate; + this.content = content; + } + + // Property accessors + public Integer getReplyId() { + return replyId; + } + + public void setReplyId(Integer replyId) { + this.replyId = replyId; + } + + public Integer getNewsId() { + return newsId; + } + + public void setNewsId(Integer newsId) { + this.newsId = newsId; + } + + public Integer getParentReplyId() { + return parentReplyId; + } + + public void setParentReplyId(Integer parentReplyId) { + this.parentReplyId = parentReplyId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getToUserId() { + return toUserId; + } + + public void setToUserId(String toUserId) { + this.toUserId = toUserId; + } + + public Timestamp getPostDate() { + return postDate; + } + + public void setPostDate(Timestamp postDate) { + this.postDate = postDate; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Integer getIsShow() { + return isShow; + } + + public void setIsShow(Integer isShow) { + this.isShow = isShow; + } + + public Integer getIsCanReply() { + return isCanReply; + } + + public void setIsCanReply(Integer isCanReply) { + this.isCanReply = isCanReply; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/NewsType.hbm.xml b/src/main/java/me/mofun/pojo/NewsType.hbm.xml new file mode 100644 index 0000000..8cec829 --- /dev/null +++ b/src/main/java/me/mofun/pojo/NewsType.hbm.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + 父类ID + + + + + 信息类别名称 + + + + + 该类别、圈子的Logo图片URL + + + + + 该类别、栏目、圈子的管理员Id,来自于User表的UserId字段 + + + + + 管理员LogoURL + + + + + 该栏目创建时间 + + + + + 该栏目是否在前台展示 + + + + + 该栏目、类别、圈子的简介 + + + + + diff --git a/src/main/java/me/mofun/pojo/NewsType.java b/src/main/java/me/mofun/pojo/NewsType.java new file mode 100644 index 0000000..88941db --- /dev/null +++ b/src/main/java/me/mofun/pojo/NewsType.java @@ -0,0 +1,109 @@ +package me.mofun.pojo; + +import java.sql.Timestamp; + +/** + * NewsType entity. + * + * @author MyEclipse Persistence Tools + */ + +public class NewsType implements java.io.Serializable { + + // Fields + + private Integer id; + private Integer parentId; + private String categoryName; + private String logo; + private String adminId; + private String adminLogo; + private Timestamp createTime; + private Integer isShow; + private String memo; + + // Constructors + /** default constructor */ + public NewsType() { + } + + /** full constructor */ + public NewsType(String categoryName) { + this.categoryName =categoryName; + } + + // Property accessors + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getParentId() { + return parentId; + } + + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + public String getLogo() { + return logo; + } + + public void setLogo(String logo) { + this.logo = logo; + } + + public String getAdminId() { + return adminId; + } + + public void setAdminId(String adminId) { + this.adminId = adminId; + } + + public String getAdminLogo() { + return adminLogo; + } + + public void setAdminLogo(String adminLogo) { + this.adminLogo = adminLogo; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public Integer getIsShow() { + return isShow; + } + + public void setIsShow(Integer isShow) { + this.isShow = isShow; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Node.java b/src/main/java/me/mofun/pojo/Node.java new file mode 100644 index 0000000..8da63cc --- /dev/null +++ b/src/main/java/me/mofun/pojo/Node.java @@ -0,0 +1,55 @@ +package me.mofun.pojo; + + +import java.util.ArrayList; +import java.util.List; + +public class Node { + + private int id; // 节点编号 + private int pid; // 父亲节点 + private String title; + private Boolean is_Show; + private List childrens = new ArrayList(); + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Boolean getIs_Show() { + return is_Show; + } + + public void setIs_Show(Boolean is_Show) { + this.is_Show = is_Show; + } + + public List getChildrens() { + return childrens; + } + + public void setChildrens(List childrens) { + this.childrens = childrens; + } + +} diff --git a/src/main/java/me/mofun/pojo/OrderBean.java b/src/main/java/me/mofun/pojo/OrderBean.java new file mode 100644 index 0000000..5f662c2 --- /dev/null +++ b/src/main/java/me/mofun/pojo/OrderBean.java @@ -0,0 +1,83 @@ +package me.mofun.pojo; + +public class OrderBean implements java.io.Serializable { + + private static final long serialVersionUID = 8961198063107641727L; + + private String outTradeNo; + private String date; + private Integer buyCount; + private double money; + private String payType; + private Integer userId; + private String userName; + private Integer spellBuyProductId; + private String productName; + private String productPeriod; + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } + public Integer getBuyCount() { + return buyCount; + } + public void setBuyCount(Integer buyCount) { + this.buyCount = buyCount; + } + public double getMoney() { + return money; + } + public void setMoney(double money) { + this.money = money; + } + public String getPayType() { + return payType; + } + public void setPayType(String payType) { + this.payType = payType; + } + public Integer getUserId() { + return userId; + } + public void setUserId(Integer userId) { + this.userId = userId; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public Integer getSpellBuyProductId() { + return spellBuyProductId; + } + public void setSpellBuyProductId(Integer spellBuyProductId) { + this.spellBuyProductId = spellBuyProductId; + } + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + public String getProductPeriod() { + return productPeriod; + } + public void setProductPeriod(String productPeriod) { + this.productPeriod = productPeriod; + } + public static long getSerialVersionUID() { + return serialVersionUID; + } + public String getOutTradeNo() { + return outTradeNo; + } + public void setOutTradeNo(String outTradeNo) { + this.outTradeNo = outTradeNo; + } + + + +} diff --git a/src/main/java/me/mofun/pojo/OrderDetailAddress.hbm.xml b/src/main/java/me/mofun/pojo/OrderDetailAddress.hbm.xml new file mode 100644 index 0000000..2d2e736 --- /dev/null +++ b/src/main/java/me/mofun/pojo/OrderDetailAddress.hbm.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + 收货人 + + + + + 联系电话 + + + + + 收货地址 + + + + + 配送时间 + + + + + 订单备注 + + + + + 快递单号 + + + + + 快递公司 + + + + + 发货时间 + + + + + 发货备注 + + + + diff --git a/src/main/java/me/mofun/pojo/OrderDetailAddress.java b/src/main/java/me/mofun/pojo/OrderDetailAddress.java new file mode 100644 index 0000000..bcdeafb --- /dev/null +++ b/src/main/java/me/mofun/pojo/OrderDetailAddress.java @@ -0,0 +1,138 @@ +package me.mofun.pojo; + +/** + * Orderdetailaddress entity. + * + * @author MyEclipse Persistence Tools + */ + +public class OrderDetailAddress implements java.io.Serializable { + + // Fields + + private Integer id; + private Integer orderDetailId; + private String consignee; + private String phone; + private String address; + private String postDate; + private String orderRemarks; + private String expressNo; + private String expressCompany; + private String deliverTime; + private String deliverRemarks; + + // Constructors + + /** default constructor */ + public OrderDetailAddress() { + } + + /** full constructor */ + public OrderDetailAddress(Integer orderDetailId, String consignee, + String phone, String address, String postDate, String orderRemarks, + String expressNo, String expressCompany, String deliverTime, + String deliverRemarks) { + this.orderDetailId = orderDetailId; + this.consignee = consignee; + this.phone = phone; + this.address = address; + this.postDate = postDate; + this.orderRemarks = orderRemarks; + this.expressNo = expressNo; + this.expressCompany = expressCompany; + this.deliverTime = deliverTime; + this.deliverRemarks = deliverRemarks; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getOrderDetailId() { + return this.orderDetailId; + } + + public void setOrderDetailId(Integer orderDetailId) { + this.orderDetailId = orderDetailId; + } + + public String getConsignee() { + return this.consignee; + } + + public void setConsignee(String consignee) { + this.consignee = consignee; + } + + public String getPhone() { + return this.phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getAddress() { + return this.address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPostDate() { + return this.postDate; + } + + public void setPostDate(String postDate) { + this.postDate = postDate; + } + + public String getOrderRemarks() { + return this.orderRemarks; + } + + public void setOrderRemarks(String orderRemarks) { + this.orderRemarks = orderRemarks; + } + + public String getExpressNo() { + return this.expressNo; + } + + public void setExpressNo(String expressNo) { + this.expressNo = expressNo; + } + + public String getExpressCompany() { + return this.expressCompany; + } + + public void setExpressCompany(String expressCompany) { + this.expressCompany = expressCompany; + } + + public String getDeliverTime() { + return this.deliverTime; + } + + public void setDeliverTime(String deliverTime) { + this.deliverTime = deliverTime; + } + + public String getDeliverRemarks() { + return this.deliverRemarks; + } + + public void setDeliverRemarks(String deliverRemarks) { + this.deliverRemarks = deliverRemarks; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Orderdetail.hbm.xml b/src/main/java/me/mofun/pojo/Orderdetail.hbm.xml new file mode 100644 index 0000000..833ce91 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Orderdetail.hbm.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Orderdetail.java b/src/main/java/me/mofun/pojo/Orderdetail.java new file mode 100644 index 0000000..e297f17 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Orderdetail.java @@ -0,0 +1,86 @@ +package me.mofun.pojo; + +/** + * Orderdetail entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Orderdetail implements java.io.Serializable { + + // Fields + + private Integer id; + private Integer orderDetailId; + private String date; + private String detailText; + private String userName; + private Integer addressId; + + // Constructors + + /** default constructor */ + public Orderdetail() { + } + + /** full constructor */ + public Orderdetail(Integer orderDetailId, String date, String detailText, + String userName, Integer addressId) { + this.orderDetailId = orderDetailId; + this.date = date; + this.detailText = detailText; + this.userName = userName; + this.addressId = addressId; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getOrderDetailId() { + return this.orderDetailId; + } + + public void setOrderDetailId(Integer orderDetailId) { + this.orderDetailId = orderDetailId; + } + + public String getDate() { + return this.date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getDetailText() { + return this.detailText; + } + + public void setDetailText(String detailText) { + this.detailText = detailText; + } + + public String getUserName() { + return this.userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public Integer getAddressId() { + return this.addressId; + } + + public void setAddressId(Integer addressId) { + this.addressId = addressId; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/ParticipateJSON.java b/src/main/java/me/mofun/pojo/ParticipateJSON.java new file mode 100644 index 0000000..e2b4ca6 --- /dev/null +++ b/src/main/java/me/mofun/pojo/ParticipateJSON.java @@ -0,0 +1,102 @@ +package me.mofun.pojo; + +import java.io.Serializable; + +public class ParticipateJSON implements Serializable { + + private String userId; + private String userName; + private String userFace; + private String ip_address; + private String ip_location; + private String buyCount; + private String buyDate; + private String buyId; + + public ParticipateJSON() { + super(); + } + + public ParticipateJSON(String userId, String userName, String userFace, + String ip_address, String ip_location, String buyCount, + String buyDate, String buyId) { + super(); + this.userId = userId; + this.userName = userName; + this.userFace = userFace; + this.ip_address = ip_address; + this.ip_location = ip_location; + this.buyCount = buyCount; + this.buyDate = buyDate; + this.buyId = buyId; + } + + + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserFace() { + return userFace; + } + + public void setUserFace(String userFace) { + this.userFace = userFace; + } + + public String getIp_address() { + return ip_address; + } + + public void setIp_address(String ip_address) { + this.ip_address = ip_address; + } + + public String getIp_location() { + return ip_location; + } + + public void setIp_location(String ip_location) { + this.ip_location = ip_location; + } + + public String getBuyCount() { + return buyCount; + } + + public void setBuyCount(String buyCount) { + this.buyCount = buyCount; + } + + public String getBuyDate() { + return buyDate; + } + + public void setBuyDate(String buyDate) { + this.buyDate = buyDate; + } + + public String getBuyId() { + return buyId; + } + + public void setBuyId(String buyId) { + this.buyId = buyId; + } + + + +} diff --git a/src/main/java/me/mofun/pojo/Product.hbm.xml b/src/main/java/me/mofun/pojo/Product.hbm.xml new file mode 100644 index 0000000..8e6172c --- /dev/null +++ b/src/main/java/me/mofun/pojo/Product.hbm.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + 商品名称 + + + + + 商品参考价 + + + + + 市场价:电商新增字段(没有活动时该字段填充0即可,有活动时需要填写,且需要>singlePrice的值,用与优惠活动时的价格比较) + + + + + 单次价格 + + + + + 商品买入价 不显示. + + + + + 网页显示商品标题. + + + + + 商品详情 + + + + + + + + + + + + + + 是否上架 0未上架 1已上架 + + + + + 是否在前台页面展示(1:默认展示,0:暂时不在前台页面展示) + + + + + + 是否虚拟商品(1:虚拟商品,0:实物商品) + + + + + 是否需要单独的逻辑处理(1:需要,0:无需) + + + + + 虚拟商品单独选购时单独进行处理的URL + + + + + 作者或发布者Id,默认1表示系统超级管理员Id发布;用此字段和shopEmployee表关联起来 + + + + + 所属店铺Id + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Product.java b/src/main/java/me/mofun/pojo/Product.java new file mode 100644 index 0000000..4e2d2b2 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Product.java @@ -0,0 +1,244 @@ +package me.mofun.pojo; + +/** + * Product entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Product implements java.io.Serializable { + + // Fields + + private Integer productId; + private String productName; + private Integer productPrice; + private Float marketPrice; + private Integer singlePrice; + private String productRealPrice; + private String productTitle; + private String productDetail; + private Integer productType; + private Integer productBrand; + private String headImage; + private Integer status; + private Integer isShow; + private Integer isVirtual; + private Integer isNeedLogic; + private String logicURL; + private Integer authorId; + private Integer shopId; + private String style; + private String attribute71; + + // Constructors + + public Product(Integer productId, String productName, Integer productPrice,Float marketPrice, + Integer singlePrice, String productRealPrice, String productTitle, + String productDetail, Integer productType, Integer productBrand, + String headImage, Integer status, Integer isVirtual, Integer isNeedLogic,String logicURL,String style, String attribute71) { + super(); + this.productId = productId; + this.productName = productName; + this.productPrice = productPrice; + this.marketPrice = marketPrice; + this.singlePrice = singlePrice; + this.productRealPrice = productRealPrice; + this.productTitle = productTitle; + this.productDetail = productDetail; + this.productType = productType; + this.productBrand = productBrand; + this.headImage = headImage; + this.status = status; + this.isVirtual = isVirtual; + this.isNeedLogic = isNeedLogic; + this.logicURL = logicURL; + this.style = style; + this.attribute71 = attribute71; + } + + /** default constructor */ + public Product() { + } + + /** minimal constructor */ + public Product(String productName, Integer productPrice,Float marketPrice,Integer singlePrice, + String productTitle, String productDetail, Integer productType, + String headImage) { + this.productName = productName; + this.productPrice = productPrice; + this.marketPrice = marketPrice; + this.singlePrice = singlePrice; + this.productTitle = productTitle; + this.productDetail = productDetail; + this.productType = productType; + this.headImage = headImage; + } + + /** full constructor */ + + + // Property accessors + + public Integer getProductId() { + return this.productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public String getProductName() { + return this.productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public Integer getProductPrice() { + return this.productPrice; + } + + public void setProductPrice(Integer productPrice) { + this.productPrice = productPrice; + } + + public String getProductRealPrice() { + return this.productRealPrice; + } + + public void setProductRealPrice(String productRealPrice) { + this.productRealPrice = productRealPrice; + } + + public String getProductTitle() { + return this.productTitle; + } + + public void setProductTitle(String productTitle) { + this.productTitle = productTitle; + } + + public String getProductDetail() { + return this.productDetail; + } + + public void setProductDetail(String productDetail) { + this.productDetail = productDetail; + } + + public Integer getProductType() { + return this.productType; + } + + public void setProductType(Integer productType) { + this.productType = productType; + } + + public String getHeadImage() { + return this.headImage; + } + + public void setHeadImage(String headImage) { + this.headImage = headImage; + } + + public String getAttribute71() { + return this.attribute71; + } + + public void setAttribute71(String attribute71) { + this.attribute71 = attribute71; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getIsShow() { + return isShow; + } + + public void setIsShow(Integer isShow) { + this.isShow = isShow; + } + + public String getStyle() { + return style; + } + + public void setStyle(String style) { + this.style = style; + } + + public Float getMarketPrice() { + return marketPrice; + } + + public void setMarketPrice(Float marketPrice) { + this.marketPrice = marketPrice; + } + + + public Integer getSinglePrice() { + return singlePrice; + } + + public void setSinglePrice(Integer singlePrice) { + this.singlePrice = singlePrice; + } + + public Integer getProductBrand() { + return productBrand; + } + + public void setProductBrand(Integer productBrand) { + this.productBrand = productBrand; + } + public Integer getIsVirtual() { + return isVirtual; + } + + public void setIsVirtual(Integer isVirtual) { + this.isVirtual = isVirtual; + } + + public Integer getIsNeedLogic() { + return isNeedLogic; + } + + public void setIsNeedLogic(Integer isNeedLogic) { + this.isNeedLogic = isNeedLogic; + } + + public String getLogicURL() { + return logicURL; + } + + public void setLogicURL(String logicURL) { + this.logicURL = logicURL; + } + + public Integer getAuthorId() { + return authorId; + } + + public void setAuthorId(Integer authorId) { + this.authorId = authorId; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/ProductCart.java b/src/main/java/me/mofun/pojo/ProductCart.java new file mode 100644 index 0000000..cc09a12 --- /dev/null +++ b/src/main/java/me/mofun/pojo/ProductCart.java @@ -0,0 +1,169 @@ +package me.mofun.pojo; + +public class ProductCart implements java.io.Serializable{ + + private static final long serialVersionUID = 7721286969488307469L; + private Integer productId; + private String productName; + private String productTitle; + private Float marketPrice; //电商版新增字段:市场价 + private String actionName; //电商版新增字段:优惠活动名称 + private Integer productPrice; //竞拍版:单品价值或价格; 普通电商版:库存 + private Integer singlePrice; //竞拍版:单次购买价格;普通电商版:商品单价 + private String headImage; + private Integer productCount; //产品样数?:购物车中的产品种类数量 + private Integer count; //购买的商品数量 + private Integer moneyCount; //总金额 + private Integer currentBuyCount; //该商品当前已购买的数量 + private Integer productPeriod; //商品所属期数 + + private String logicURL; + private String keyName; + private String keyValue; + + public ProductCart() { + super(); + } + + public ProductCart(Integer productId, String productName, + String productTitle, Integer productPrice, Float marketPrice,String actionName,Integer singlePrice, + String headImage, Integer productCount, Integer count, + Integer moneyCount, Integer currentBuyCount, Integer productPeriod,String logicURL,String keyName,String keyValue) { + super(); + this.productId = productId; + this.productName = productName; + this.productTitle = productTitle; + this.productPrice = productPrice; + this.marketPrice = marketPrice; + this.actionName = actionName; + this.singlePrice = singlePrice; + this.headImage = headImage; + this.productCount = productCount; + this.count = count; + this.moneyCount = moneyCount; + this.currentBuyCount = currentBuyCount; + this.productPeriod = productPeriod; + this.logicURL = logicURL; + this.keyName = keyName; + this.keyValue = keyValue; + } + + + public Integer getProductPeriod() { + return productPeriod; + } + + public void setProductPeriod(Integer productPeriod) { + this.productPeriod = productPeriod; + } + + public Integer getCurrentBuyCount() { + return currentBuyCount; + } + + public void setCurrentBuyCount(Integer currentBuyCount) { + this.currentBuyCount = currentBuyCount; + } + + public Integer getProductId() { + return productId; + } + public void setProductId(Integer productId) { + this.productId = productId; + } + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + public String getProductTitle() { + return productTitle; + } + public void setProductTitle(String productTitle) { + this.productTitle = productTitle; + } + public Integer getProductPrice() { + return productPrice; + } + public void setProductPrice(Integer productPrice) { + this.productPrice = productPrice; + } + public String getHeadImage() { + return headImage; + } + public void setHeadImage(String headImage) { + this.headImage = headImage; + } + public Integer getProductCount() { + return productCount; + } + public void setProductCount(Integer productCount) { + this.productCount = productCount; + } + public Integer getCount() { + return count; + } + public void setCount(Integer count) { + this.count = count; + } + public Integer getMoneyCount() { + return moneyCount; + } + public void setMoneyCount(Integer moneyCount) { + this.moneyCount = moneyCount; + } + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public Float getMarketPrice() { + return marketPrice; + } + + public void setMarketPrice(Float marketPrice) { + this.marketPrice = marketPrice; + } + + public String getActionName() { + return actionName; + } + + public void setActionName(String actionName) { + this.actionName = actionName; + } + + + public Integer getSinglePrice() { + return singlePrice; + } + + public void setSinglePrice(Integer singlePrice) { + this.singlePrice = singlePrice; + } + + public String getLogicURL() { + return logicURL; + } + + public void setLogicURL(String logicURL) { + this.logicURL = logicURL; + } + + public String getKeyName() { + return keyName; + } + + public void setKeyName(String keyName) { + this.keyName = keyName; + } + + public String getKeyValue() { + return keyValue; + } + + public void setKeyValue(String keyValue) { + this.keyValue = keyValue; + } + +} diff --git a/src/main/java/me/mofun/pojo/ProductImage.java b/src/main/java/me/mofun/pojo/ProductImage.java new file mode 100644 index 0000000..5f591db --- /dev/null +++ b/src/main/java/me/mofun/pojo/ProductImage.java @@ -0,0 +1,152 @@ +package me.mofun.pojo; + +import java.sql.Timestamp; + +/** + * ProductImage entity. + * + * @author MyEclipse Persistence Tools + */ + +public class ProductImage implements java.io.Serializable { + + // Fields + private Integer imageId; + private Integer productId; + private Integer userId; + private Integer shopId; + private String imageName; + private String title; + private String description; + private String tag; + private Timestamp createTime; + private String image; + private String imageType; + private String isShow; + private Integer status; + + // Constructors + + /** default constructor */ + public ProductImage() { + } + + // Property accessors + + public ProductImage(Integer productImageId, Integer productId, + String image, String imageType, String isShow) { + super(); + this.imageId = productImageId; + this.productId = productId; + this.image = image; + this.imageType = imageType; + this.isShow = isShow; + } + + public Integer getImageId() { + return imageId; + } + + public void setImageId(Integer imageId) { + this.imageId = imageId; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public String getImageName() { + return imageName; + } + + public void setImageName(String imageName) { + this.imageName = imageName; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getImageType() { + return imageType; + } + + public void setImageType(String imageType) { + this.imageType = imageType; + } + + public String getIsShow() { + return isShow; + } + + public void setIsShow(String isShow) { + this.isShow = isShow; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/ProductInfo.java b/src/main/java/me/mofun/pojo/ProductInfo.java new file mode 100644 index 0000000..6704d5e --- /dev/null +++ b/src/main/java/me/mofun/pojo/ProductInfo.java @@ -0,0 +1,192 @@ +package me.mofun.pojo; + +import java.io.Serializable; + +public class ProductInfo implements Serializable { + + private static final long serialVersionUID = 2984681206487401036L; + + private Integer productId; + private String productName; + private String productTitle; + private Integer productPrice; + private Float marketPrice; //电商版新增字段:市场价 + private String actionName; //电商版新增字段:优惠活动名称 + private Integer singlePrice;//单次购买价格 + private String headImage; + private String productDetail; + private Integer spellbuyProductId; + private Integer spellbuyCount; + private Integer productPeriod; //商品期数 + private Integer status; + private Integer buyLimited; //商品是否限购或该商品单人限购次数 + private Integer isVirtual; + private Integer isNeedLogic; + private String logicURL; + private Integer shopId; + + public ProductInfo() { + super(); + } + + public ProductInfo(Integer productId, String productName, String productTitle, + Integer productPrice,Float marketPrice,String actionName, Integer singlePrice, String headImage, + String productDetail, Integer spellbuyProductId, + Integer spellbuyCount, Integer productPeriod, Integer status,Integer buyLimited,Integer isVirtual, Integer isNeedLogic,String logicURL) { + super(); + this.productId = productId; + this.productName = productName; + this.productTitle = productTitle; + this.productPrice = productPrice; + this.marketPrice = marketPrice; + this.actionName = actionName; + this.singlePrice = singlePrice; + this.headImage = headImage; + this.productDetail = productDetail; + this.spellbuyProductId = spellbuyProductId; + this.spellbuyCount = spellbuyCount; + this.productPeriod = productPeriod; + this.status = status; + this.buyLimited = buyLimited; + this.isVirtual = isVirtual; + this.isNeedLogic = isNeedLogic; + this.logicURL = logicURL; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public Integer getStatus() { + return status; + } + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getBuyLimited() { + return buyLimited; + } + public void setBuyLimited(Integer buyLimited) { + this.buyLimited = buyLimited; + } + + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + public String getProductTitle() { + return productTitle; + } + public void setProductTitle(String productTitle) { + this.productTitle = productTitle; + } + public Integer getProductPrice() { + return productPrice; + } + public void setProductPrice(Integer productPrice) { + this.productPrice = productPrice; + } + + public Float getMarketPrice() { + return marketPrice; + } + + public void setMarketPrice(Float marketPrice) { + this.marketPrice = marketPrice; + } + + public String getActionName() { + return actionName; + } + + public void setActionName(String actionName) { + this.actionName = actionName; + } + + + public String getHeadImage() { + return headImage; + } + public void setHeadImage(String headImage) { + this.headImage = headImage; + } + public String getProductDetail() { + return productDetail; + } + public void setProductDetail(String productDetail) { + this.productDetail = productDetail; + } + public Integer getSpellbuyProductId() { + return spellbuyProductId; + } + public void setSpellbuyProductId(Integer spellbuyProductId) { + this.spellbuyProductId = spellbuyProductId; + } + public Integer getSpellbuyCount() { + return spellbuyCount; + } + public void setSpellbuyCount(Integer spellbuyCount) { + this.spellbuyCount = spellbuyCount; + } + + public Integer getProductPeriod() { + return productPeriod; + } + + public void setProductPeriod(Integer productPeriod) { + this.productPeriod = productPeriod; + } + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public Integer getSinglePrice() { + return singlePrice; + } + + public void setSinglePrice(Integer singlePrice) { + this.singlePrice = singlePrice; + } + + public int getIsVirtual() { + return isVirtual; + } + + public void setIsVirtual(int isVirtual) { + this.isVirtual = isVirtual; + } + + public int getIsNeedLogic() { + return isNeedLogic; + } + + public void setIsNeedLogic(int isNeedLogic) { + this.isNeedLogic = isNeedLogic; + } + + public String getLogicURL() { + return logicURL; + } + + public void setLogicURL(String logicURL) { + this.logicURL = logicURL; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + +} diff --git a/src/main/java/me/mofun/pojo/ProductJSON.java b/src/main/java/me/mofun/pojo/ProductJSON.java new file mode 100644 index 0000000..908f24c --- /dev/null +++ b/src/main/java/me/mofun/pojo/ProductJSON.java @@ -0,0 +1,245 @@ +package me.mofun.pojo; + +import java.io.Serializable; + +public class ProductJSON implements Serializable { + + private static final long serialVersionUID = -8927491985109183983L; + + private Integer productId;//商品ID + private String productName;//商品名称 + private Integer productPrice;//商品价格|商品总份数 + private float marketPrice;//市场价 + private String actionName;//活动名称 + private Integer singlePrice;//拍购版:单次购买价格;电商版:当前价/活动价/优惠价 + private String productTitle;//商品标题 + private String headImage;//商品图片 + private Integer currentBuyCount;//当前购买数 + private String buyer;//购买人 + private String userId; + private Integer productPeriod; //商品期数 + private String buyDate; //购买时间 + private Integer buyCount;//购买数量 + private String productStyle; //商品种类 + + private boolean payResult; //支付结果:成功/失败 + private String logicURL; //子业务逻辑处理网址 + private String keyName; //子业务逻辑关键字名 + private String keyValue; //子业务逻辑关键字值 + + public ProductJSON() { + super(); + this.payResult = false; //初始化默认支付失败,表示支付还未开始或完成 + } + + + public ProductJSON(Integer productId, String productName, + Integer productPrice, float marketPrice,String actionName,Integer singlePrice, String productTitle, + String headImage, Integer currentBuyCount, String buyer, + String userId, Integer productPeriod, String buyDate, + Integer buyCount, boolean payResult,String logicURL,String keyName,String keyValue,String productStyle) { + super(); + this.productId = productId; + this.productName = productName; + this.productPrice = productPrice; + this.marketPrice = marketPrice; + this.actionName = actionName; + this.singlePrice = singlePrice; + this.productTitle = productTitle; + this.headImage = headImage; + this.currentBuyCount = currentBuyCount; + this.buyer = buyer; + this.userId = userId; + this.productPeriod = productPeriod; + this.buyDate = buyDate; + this.buyCount = buyCount; + this.payResult = payResult; + this.logicURL = logicURL; + this.keyName = keyName; + this.keyValue = keyValue; + this.productStyle = productStyle; + } + + + public Integer getProductId() { + return productId; + } + + + public void setProductId(Integer productId) { + this.productId = productId; + } + + + public String getProductName() { + return productName; + } + + + public void setProductName(String productName) { + this.productName = productName; + } + + + public Integer getProductPrice() { + return productPrice; + } + + + public void setProductPrice(Integer productPrice) { + this.productPrice = productPrice; + } + + public float getMarketPrice() { + return marketPrice; + } + + + public void setMarketPrice(float marketPrice) { + this.marketPrice = marketPrice; + } + + + public String getActionName() { + return actionName; + } + + + public void setActionName(String actionName) { + this.actionName = actionName; + } + + + public String getProductTitle() { + return productTitle; + } + + + public void setProductTitle(String productTitle) { + this.productTitle = productTitle; + } + + + public String getHeadImage() { + return headImage; + } + + + public void setHeadImage(String headImage) { + this.headImage = headImage; + } + + + public Integer getCurrentBuyCount() { + return currentBuyCount; + } + + + public void setCurrentBuyCount(Integer currentBuyCount) { + this.currentBuyCount = currentBuyCount; + } + + + public String getBuyer() { + return buyer; + } + + + public void setBuyer(String buyer) { + this.buyer = buyer; + } + + + public String getUserId() { + return userId; + } + + + public void setUserId(String userId) { + this.userId = userId; + } + + + public Integer getProductPeriod() { + return productPeriod; + } + + + public void setProductPeriod(Integer productPeriod) { + this.productPeriod = productPeriod; + } + + + public String getBuyDate() { + return buyDate; + } + + + public void setBuyDate(String buyDate) { + this.buyDate = buyDate; + } + + + public Integer getBuyCount() { + return buyCount; + } + + + public void setBuyCount(Integer buyCount) { + this.buyCount = buyCount; + } + + + public String getProductStyle() { + return productStyle; + } + + + public void setProductStyle(String productStyle) { + this.productStyle = productStyle; + } + + + public Integer getSinglePrice() { + return singlePrice; + } + + + public void setSinglePrice(Integer singlePrice) { + this.singlePrice = singlePrice; + } + + public boolean isPayResult() { + return payResult; + } + + public void setPayResult(boolean payResult) { + this.payResult = payResult; + } + + public String getLogicURL() { + return logicURL; + } + + + public void setLogicURL(String logicURL) { + this.logicURL = logicURL; + } + + public String getKeyName() { + return keyName; + } + + public void setKeyName(String keyName) { + this.keyName = keyName; + } + + public String getKeyValue() { + return keyValue; + } + + public void setKeyValue(String keyValue) { + this.keyValue = keyValue; + } + +} diff --git a/src/main/java/me/mofun/pojo/ProductType.java b/src/main/java/me/mofun/pojo/ProductType.java new file mode 100644 index 0000000..87a52db --- /dev/null +++ b/src/main/java/me/mofun/pojo/ProductType.java @@ -0,0 +1,102 @@ +package me.mofun.pojo; + +/** + * ProductType entity. + * + * @author MyEclipse Persistence Tools + */ + +public class ProductType implements java.io.Serializable { + + // Fields + + private Integer typeId; + private String typeName; + private String ftypeId; + private String stypeId; + private String attribute70; + private Integer sequence; + private Integer isShow; + + // Constructors + + /** default constructor */ + public ProductType() { + } + + /** minimal constructor */ + public ProductType(String typeName, String ftypeId, String stypeId) { + this.typeName = typeName; + this.ftypeId = ftypeId; + this.stypeId = stypeId; + } + + /** full constructor */ + public ProductType(String typeName, String ftypeId, String stypeId, + String attribute70) { + this.typeName = typeName; + this.ftypeId = ftypeId; + this.stypeId = stypeId; + this.attribute70 = attribute70; + } + + // Property accessors + + public Integer getTypeId() { + return this.typeId; + } + + public void setTypeId(Integer typeId) { + this.typeId = typeId; + } + + public String getTypeName() { + return this.typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getFtypeId() { + return this.ftypeId; + } + + public void setFtypeId(String ftypeId) { + this.ftypeId = ftypeId; + } + + public String getStypeId() { + return this.stypeId; + } + + public void setStypeId(String stypeId) { + this.stypeId = stypeId; + } + + public String getAttribute70() { + return this.attribute70; + } + + public void setAttribute70(String attribute70) { + this.attribute70 = attribute70; + } + + public Integer getSequence() { + return sequence; + } + + public void setSequence(Integer sequence) { + this.sequence = sequence; + } + + public Integer getIsShow() { + return this.isShow; + } + + public void setIsShow(Integer isShow) { + this.isShow = isShow; + } + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Productimage.hbm.xml b/src/main/java/me/mofun/pojo/Productimage.hbm.xml new file mode 100644 index 0000000..e8c1671 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Productimage.hbm.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + 商品id + + + + + 上传用户id + + + + + 所属商铺id + + + + + 图片文件全名 + + + + + 图片 + + + + + 图片类型 + + + + + 图片标题 + + + + + 图片详细描述 + + + + + 图片标签,多个标签以英文逗号分隔。 + + + + + 创建时间 + + + + + + + + 图片状态 + + + + diff --git a/src/main/java/me/mofun/pojo/Producttype.hbm.xml b/src/main/java/me/mofun/pojo/Producttype.hbm.xml new file mode 100644 index 0000000..1c450a8 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Producttype.hbm.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + 类别名称 + + + + + 父类别ID + + + + + 子类别id + + + + + 表示记录属于产品类型还是属于品牌:type:表示产品类型;brand:表示品牌 + + + + + 菜单显示时同层级中菜单项的先后显示顺序。默认从1开始,数值越小显示顺序越靠前 + + + + + 该类别是否在前台页面中显示,1:默认显示;0:不显示 + + + + diff --git a/src/main/java/me/mofun/pojo/RandomNumberJSON.java b/src/main/java/me/mofun/pojo/RandomNumberJSON.java new file mode 100644 index 0000000..b43e603 --- /dev/null +++ b/src/main/java/me/mofun/pojo/RandomNumberJSON.java @@ -0,0 +1,54 @@ +package me.mofun.pojo; + +public class RandomNumberJSON { + + private String buyDate; + private String buyCount; + private String randomNumbers; + + + public RandomNumberJSON() { + super(); + } + + public RandomNumberJSON(String buyDate, String buyCount, + String randomNumbers) { + super(); + this.buyDate = buyDate; + this.buyCount = buyCount; + this.randomNumbers = randomNumbers; + } + + + public String getBuyCount() { + return buyCount; + } + + + public void setBuyCount(String buyCount) { + this.buyCount = buyCount; + } + + + public String getBuyDate() { + return buyDate; + } + + + public void setBuyDate(String buyDate) { + this.buyDate = buyDate; + } + + + public String getRandomNumbers() { + return randomNumbers; + } + + + public void setRandomNumbers(String randomNumbers) { + this.randomNumbers = randomNumbers; + } + + + +} diff --git a/src/main/java/me/mofun/pojo/Randomnumber.hbm.xml b/src/main/java/me/mofun/pojo/Randomnumber.hbm.xml new file mode 100644 index 0000000..e5fc1df --- /dev/null +++ b/src/main/java/me/mofun/pojo/Randomnumber.hbm.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + 随机码 + + + + + 购买时间 + + + + diff --git a/src/main/java/me/mofun/pojo/Randomnumber.java b/src/main/java/me/mofun/pojo/Randomnumber.java new file mode 100644 index 0000000..8b4e3a8 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Randomnumber.java @@ -0,0 +1,90 @@ +package me.mofun.pojo; + +/** + * Randomnumber entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Randomnumber implements java.io.Serializable { + + // Fields + + private Integer id; + private Integer spellbuyrecordId; + private Integer userId; + private Integer productId; + private String randomNumber; + private String buyDate; + + // Constructors + + public Randomnumber(Integer id, Integer spellbuyrecordId, Integer userId, + Integer productId, String randomNumber, String buyDate) { + super(); + this.id = id; + this.spellbuyrecordId = spellbuyrecordId; + this.userId = userId; + this.productId = productId; + this.randomNumber = randomNumber; + this.buyDate = buyDate; + } + + /** default constructor */ + public Randomnumber() { + } + + /** full constructor */ + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getSpellbuyrecordId() { + return this.spellbuyrecordId; + } + + public void setSpellbuyrecordId(Integer spellbuyrecordId) { + this.spellbuyrecordId = spellbuyrecordId; + } + + public String getRandomNumber() { + return this.randomNumber; + } + + public void setRandomNumber(String randomNumber) { + this.randomNumber = randomNumber; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public String getBuyDate() { + return buyDate; + } + + public void setBuyDate(String buyDate) { + this.buyDate = buyDate; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Recommend.hbm.xml b/src/main/java/me/mofun/pojo/Recommend.hbm.xml new file mode 100644 index 0000000..22750eb --- /dev/null +++ b/src/main/java/me/mofun/pojo/Recommend.hbm.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Recommend.java b/src/main/java/me/mofun/pojo/Recommend.java new file mode 100644 index 0000000..4b6ac18 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Recommend.java @@ -0,0 +1,46 @@ +package me.mofun.pojo; + +/** + * Recommend entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Recommend implements java.io.Serializable { + + // Fields + + private Integer recommendId; + private Integer spellbuyProductId; + private String date; + + public Recommend() { + super(); + } + public Recommend(Integer recommendId, Integer spellbuyProductId, String date) { + super(); + this.recommendId = recommendId; + this.spellbuyProductId = spellbuyProductId; + this.date = date; + } + public Integer getRecommendId() { + return recommendId; + } + public void setRecommendId(Integer recommendId) { + this.recommendId = recommendId; + } + public Integer getSpellbuyProductId() { + return spellbuyProductId; + } + public void setSpellbuyProductId(Integer spellbuyProductId) { + this.spellbuyProductId = spellbuyProductId; + } + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Replies.hbm.xml b/src/main/java/me/mofun/pojo/Replies.hbm.xml new file mode 100644 index 0000000..59c1407 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Replies.hbm.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 状态:0话题人未阅读,1话题人已阅读 + + + + + + + \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Replies.java b/src/main/java/me/mofun/pojo/Replies.java new file mode 100644 index 0000000..c0660fb --- /dev/null +++ b/src/main/java/me/mofun/pojo/Replies.java @@ -0,0 +1,179 @@ +package me.mofun.pojo; + +/** + * Replies entity. @author MyEclipse Persistence Tools + */ + +public class Replies implements java.io.Serializable { + + // Fields + + private Integer replyId; + private Integer parentReplyId; + private Integer topicId; + private Integer userId; + private Integer toUserId; + private Boolean deleted; + private Long upvotes; + private Long downvotes; + private Long score; + private String content; + private Long createdAt; + private Long updatedAt; + private Short status; + private Long version; + + // Constructors + + /** default constructor */ + public Replies() { + } + + /** minimal constructor */ + public Replies(Integer topicId, Integer userId, Boolean deleted, Long upvotes, Long downvotes, Long score, String content, Long createdAt, Long updatedAt, + Long version) { + this.topicId = topicId; + this.userId = userId; + this.deleted = deleted; + this.upvotes = upvotes; + this.downvotes = downvotes; + this.score = score; + this.content = content; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.version = version; + } + + /** full constructor */ + public Replies(Integer parentReplyId, Integer topicId, Integer userId, Integer toUserId, Boolean deleted, Long upvotes, Long downvotes, Long score, + String content, Long createdAt, Long updatedAt, Short status, Long version) { + this.parentReplyId = parentReplyId; + this.topicId = topicId; + this.userId = userId; + this.toUserId = toUserId; + this.deleted = deleted; + this.upvotes = upvotes; + this.downvotes = downvotes; + this.score = score; + this.content = content; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.status = status; + this.version = version; + } + + // Property accessors + + public Integer getReplyId() { + return this.replyId; + } + + public void setReplyId(Integer replyId) { + this.replyId = replyId; + } + + public Integer getParentReplyId() { + return this.parentReplyId; + } + + public void setParentReplyId(Integer parentReplyId) { + this.parentReplyId = parentReplyId; + } + + public Integer getTopicId() { + return this.topicId; + } + + public void setTopicId(Integer topicId) { + this.topicId = topicId; + } + + public Integer getUserId() { + return this.userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getToUserId() { + return this.toUserId; + } + + public void setToUserId(Integer toUserId) { + this.toUserId = toUserId; + } + + public Boolean getDeleted() { + return this.deleted; + } + + public void setDeleted(Boolean deleted) { + this.deleted = deleted; + } + + public Long getUpvotes() { + return this.upvotes; + } + + public void setUpvotes(Long upvotes) { + this.upvotes = upvotes; + } + + public Long getDownvotes() { + return this.downvotes; + } + + public void setDownvotes(Long downvotes) { + this.downvotes = downvotes; + } + + public Long getScore() { + return this.score; + } + + public void setScore(Long score) { + this.score = score; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public Long getCreatedAt() { + return this.createdAt; + } + + public void setCreatedAt(Long createdAt) { + this.createdAt = createdAt; + } + + public Long getUpdatedAt() { + return this.updatedAt; + } + + public void setUpdatedAt(Long updatedAt) { + this.updatedAt = updatedAt; + } + + public Short getStatus() { + return this.status; + } + + public void setStatus(Short status) { + this.status = status; + } + + public Long getVersion() { + return this.version; + } + + public void setVersion(Long version) { + this.version = version; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/SCity.hbm.xml b/src/main/java/me/mofun/pojo/SCity.hbm.xml new file mode 100644 index 0000000..55c71f7 --- /dev/null +++ b/src/main/java/me/mofun/pojo/SCity.hbm.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/SCity.java b/src/main/java/me/mofun/pojo/SCity.java new file mode 100644 index 0000000..b7f3218 --- /dev/null +++ b/src/main/java/me/mofun/pojo/SCity.java @@ -0,0 +1,65 @@ +package me.mofun.pojo; + +/** + * SCity entity. + * + * @author MyEclipse Persistence Tools + */ + +public class SCity implements java.io.Serializable { + + // Fields + + private Integer cid; + private String cname; + private String cpostcode; + private Integer pid; + + // Constructors + + /** default constructor */ + public SCity() { + } + + /** full constructor */ + public SCity(String cname, String cpostcode, Integer pid) { + this.cname = cname; + this.cpostcode = cpostcode; + this.pid = pid; + } + + // Property accessors + + public Integer getCid() { + return this.cid; + } + + public void setCid(Integer cid) { + this.cid = cid; + } + + public String getCname() { + return this.cname; + } + + public void setCname(String cname) { + this.cname = cname; + } + + public String getCpostcode() { + return this.cpostcode; + } + + public void setCpostcode(String cpostcode) { + this.cpostcode = cpostcode; + } + + public Integer getPid() { + return this.pid; + } + + public void setPid(Integer pid) { + this.pid = pid; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/SDistrict.hbm.xml b/src/main/java/me/mofun/pojo/SDistrict.hbm.xml new file mode 100644 index 0000000..57804bd --- /dev/null +++ b/src/main/java/me/mofun/pojo/SDistrict.hbm.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/SDistrict.java b/src/main/java/me/mofun/pojo/SDistrict.java new file mode 100644 index 0000000..65b5fe9 --- /dev/null +++ b/src/main/java/me/mofun/pojo/SDistrict.java @@ -0,0 +1,55 @@ +package me.mofun.pojo; + +/** + * SDistrict entity. + * + * @author MyEclipse Persistence Tools + */ + +public class SDistrict implements java.io.Serializable { + + // Fields + + private Integer did; + private String dname; + private Integer cid; + + // Constructors + + /** default constructor */ + public SDistrict() { + } + + /** full constructor */ + public SDistrict(String dname, Integer cid) { + this.dname = dname; + this.cid = cid; + } + + // Property accessors + + public Integer getDid() { + return this.did; + } + + public void setDid(Integer did) { + this.did = did; + } + + public String getDname() { + return this.dname; + } + + public void setDname(String dname) { + this.dname = dname; + } + + public Integer getCid() { + return this.cid; + } + + public void setCid(Integer cid) { + this.cid = cid; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/SProvince.hbm.xml b/src/main/java/me/mofun/pojo/SProvince.hbm.xml new file mode 100644 index 0000000..26ab103 --- /dev/null +++ b/src/main/java/me/mofun/pojo/SProvince.hbm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/SProvince.java b/src/main/java/me/mofun/pojo/SProvince.java new file mode 100644 index 0000000..b4a954b --- /dev/null +++ b/src/main/java/me/mofun/pojo/SProvince.java @@ -0,0 +1,45 @@ +package me.mofun.pojo; + +/** + * SProvince entity. + * + * @author MyEclipse Persistence Tools + */ + +public class SProvince implements java.io.Serializable { + + // Fields + + private Integer pid; + private String pname; + + // Constructors + + /** default constructor */ + public SProvince() { + } + + /** full constructor */ + public SProvince(String pname) { + this.pname = pname; + } + + // Property accessors + + public Integer getPid() { + return this.pid; + } + + public void setPid(Integer pid) { + this.pid = pid; + } + + public String getPname() { + return this.pname; + } + + public void setPname(String pname) { + this.pname = pname; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/ServiceLogic.java b/src/main/java/me/mofun/pojo/ServiceLogic.java new file mode 100644 index 0000000..d560a78 --- /dev/null +++ b/src/main/java/me/mofun/pojo/ServiceLogic.java @@ -0,0 +1,108 @@ +package me.mofun.pojo; + +public class ServiceLogic { + private String userId; //使用当前业务的用户Id + private boolean isVirtual; //是否非实物商品 + private boolean isNeed; //是否需要本业务逻辑 + private Integer productId; //产品Id + private String keyId; //关键子业务ID + private String keyName; //关键子业务名称 + private String keyInfo; //关键子业务信息 + private boolean isValidated; //是否验证通过 + private String validateFailureMsg; //验证失败时的提示信息 + private Integer resultCode; //业务逻辑执行结果返回码,只有 resultCode==0 时表示业务逻辑校验或执行成功 + private String resultMsg; //业务逻辑执行完毕后,对应的返回码的信息解释 + + public ServiceLogic() { + // TODO Auto-generated constructor stub + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public boolean isVirtual() { + return isVirtual; + } + + public void setVirtual(boolean isVirtual) { + this.isVirtual = isVirtual; + } + + public boolean isNeed() { + return isNeed; + } + + public void setNeed(boolean isNeed) { + this.isNeed = isNeed; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public String getKeyId() { + return keyId; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyName() { + return keyName; + } + + public void setKeyName(String keyName) { + this.keyName = keyName; + } + + public String getKeyInfo() { + return keyInfo; + } + + public void setKeyInfo(String keyInfo) { + this.keyInfo = keyInfo; + } + + public boolean isValidated() { + return isValidated; + } + + public void setValidated(boolean isValidated) { + this.isValidated = isValidated; + } + + public String getValidateFailureMsg() { + return validateFailureMsg; + } + + public void setValidateFailureMsg(String validateFailureMsg) { + this.validateFailureMsg = validateFailureMsg; + } + + public Integer getResultCode() { + return resultCode; + } + + public void setResultCode(Integer resultCode) { + this.resultCode = resultCode; + } + + public String getResultMsg() { + return resultMsg; + } + + public void setResultMsg(String resultMsg) { + this.resultMsg = resultMsg; + } + +} diff --git a/src/main/java/me/mofun/pojo/ShareCommentJSON.java b/src/main/java/me/mofun/pojo/ShareCommentJSON.java new file mode 100644 index 0000000..6b5b155 --- /dev/null +++ b/src/main/java/me/mofun/pojo/ShareCommentJSON.java @@ -0,0 +1,94 @@ +package me.mofun.pojo; + +public class ShareCommentJSON { + + private Integer uid; + private Integer shareInfoId; + private Integer reCommentId; + private Integer userId; + private String userName; + private String userFace; + private String content; + private String createDate; + private Integer reCount; + + public ShareCommentJSON() { + super(); + } + + public ShareCommentJSON(Integer uid, Integer shareInfoId, + Integer reCommentId, Integer userId, String userName, + String userFace, String content, String createDate, Integer reCount) { + super(); + this.uid = uid; + this.shareInfoId = shareInfoId; + this.reCommentId = reCommentId; + this.userId = userId; + this.userName = userName; + this.userFace = userFace; + this.content = content; + this.createDate = createDate; + this.reCount = reCount; + } + + + public Integer getUid() { + return uid; + } + public void setUid(Integer uid) { + this.uid = uid; + } + public Integer getShareInfoId() { + return shareInfoId; + } + public void setShareInfoId(Integer shareInfoId) { + this.shareInfoId = shareInfoId; + } + public Integer getReCommentId() { + return reCommentId; + } + public void setReCommentId(Integer reCommentId) { + this.reCommentId = reCommentId; + } + public Integer getUserId() { + return userId; + } + public void setUserId(Integer userId) { + this.userId = userId; + } + public String getContent() { + return content; + } + public void setContent(String content) { + this.content = content; + } + public String getCreateDate() { + return createDate; + } + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getUserFace() { + return userFace; + } + public void setUserFace(String userFace) { + this.userFace = userFace; + } + + public Integer getReCount() { + return reCount; + } + + public void setReCount(Integer reCount) { + this.reCount = reCount; + } + + +} diff --git a/src/main/java/me/mofun/pojo/ShareInfoJSON.java b/src/main/java/me/mofun/pojo/ShareInfoJSON.java new file mode 100644 index 0000000..62bf968 --- /dev/null +++ b/src/main/java/me/mofun/pojo/ShareInfoJSON.java @@ -0,0 +1,129 @@ +package me.mofun.pojo; + +import java.io.Serializable; +import java.util.List; + +public class ShareInfoJSON implements Serializable { + + private static final long serialVersionUID = -8825464421098017421L; + + private Integer uid; + private String shareTitle; + private String shareContent; + private List shareimageList; + private Integer upCount; + private Integer replyCount; + private Integer reward; + private String shareDate; + private String announcedTime; + private String userName; + private String userFace; + private String userId; + private Integer status; + public ShareInfoJSON() { + super(); + } + public ShareInfoJSON(Integer uid, String shareTitle, String shareContent, + List shareimageList, Integer upCount, + Integer replyCount, Integer reward, String shareDate, + String announcedTime, String userName, String userFace, + String userId, Integer status) { + super(); + this.uid = uid; + this.shareTitle = shareTitle; + this.shareContent = shareContent; + this.shareimageList = shareimageList; + this.upCount = upCount; + this.replyCount = replyCount; + this.reward = reward; + this.shareDate = shareDate; + this.announcedTime = announcedTime; + this.userName = userName; + this.userFace = userFace; + this.userId = userId; + this.status = status; + } + public Integer getUid() { + return uid; + } + public void setUid(Integer uid) { + this.uid = uid; + } + public String getShareTitle() { + return shareTitle; + } + public void setShareTitle(String shareTitle) { + this.shareTitle = shareTitle; + } + public String getShareContent() { + return shareContent; + } + public void setShareContent(String shareContent) { + this.shareContent = shareContent; + } + public List getShareimageList() { + return shareimageList; + } + public void setShareimageList(List shareimageList) { + this.shareimageList = shareimageList; + } + public Integer getUpCount() { + return upCount; + } + public void setUpCount(Integer upCount) { + this.upCount = upCount; + } + public Integer getReplyCount() { + return replyCount; + } + public void setReplyCount(Integer replyCount) { + this.replyCount = replyCount; + } + public Integer getReward() { + return reward; + } + public void setReward(Integer reward) { + this.reward = reward; + } + public String getShareDate() { + return shareDate; + } + public void setShareDate(String shareDate) { + this.shareDate = shareDate; + } + public String getAnnouncedTime() { + return announcedTime; + } + public void setAnnouncedTime(String announcedTime) { + this.announcedTime = announcedTime; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getUserFace() { + return userFace; + } + public void setUserFace(String userFace) { + this.userFace = userFace; + } + public String getUserId() { + return userId; + } + public void setUserId(String userId) { + this.userId = userId; + } + public Integer getStatus() { + return status; + } + public void setStatus(Integer status) { + this.status = status; + } + public static long getSerialVersionUID() { + return serialVersionUID; + } + + +} diff --git a/src/main/java/me/mofun/pojo/ShareInfoPro.java b/src/main/java/me/mofun/pojo/ShareInfoPro.java new file mode 100644 index 0000000..4cf46be --- /dev/null +++ b/src/main/java/me/mofun/pojo/ShareInfoPro.java @@ -0,0 +1,284 @@ +package me.mofun.pojo; + +public class ShareInfoPro implements java.io.Serializable { + private static final long serialVersionUID = 1L; + + private String shareId; + private String shareTitle; + private String shareContent; + private String shareDate; + private String shareimageList; + private int upCount; + private int replyCount; + private int reward; + private String productId; + private String spellbuyProductId; + private String productName; + private String productTitle; + private String productPrice; + private String productPeriod; + private String buyDate; //购买日期 + private String winRandomNumber; + private String productImg; + private String winUserName; + private String winUserFace; + private String buyNumberCount; + private String announcedTime; + private String userId; + private int resultSize; + + + public ShareInfoPro() { + super(); + } + + public ShareInfoPro(String shareId, String shareTitle, String shareContent, + String shareDate, String shareimageList, int upCount, + int replyCount, int reward, String productId, + String spellbuyProductId, String productName, String productTitle, + String productPrice, String productPeriod, String winRandomNumber, + String productImg, String winUserName, String winUserFace, + String buyNumberCount, String announcedTime, String userId, + int resultSize) { + super(); + this.shareId = shareId; + this.shareTitle = shareTitle; + this.shareContent = shareContent; + this.shareDate = shareDate; + this.shareimageList = shareimageList; + this.upCount = upCount; + this.replyCount = replyCount; + this.reward = reward; + this.productId = productId; + this.spellbuyProductId = spellbuyProductId; + this.productName = productName; + this.productTitle = productTitle; + this.productPrice = productPrice; + this.productPeriod = productPeriod; + this.winRandomNumber = winRandomNumber; + this.productImg = productImg; + this.winUserName = winUserName; + this.winUserFace = winUserFace; + this.buyNumberCount = buyNumberCount; + this.announcedTime = announcedTime; + this.userId = userId; + this.resultSize = resultSize; + } + + public String getUserId() { + return userId; + } + + + public void setUserId(String userId) { + this.userId = userId; + } + + + public String getShareId() { + return shareId; + } + + + public void setShareId(String shareId) { + this.shareId = shareId; + } + + + public String getShareTitle() { + return shareTitle; + } + + + public void setShareTitle(String shareTitle) { + this.shareTitle = shareTitle; + } + + + public String getShareContent() { + return shareContent; + } + + + public void setShareContent(String shareContent) { + this.shareContent = shareContent; + } + + + public String getShareDate() { + return shareDate; + } + + public void setShareDate(String shareDate) { + this.shareDate = shareDate; + } + + public String getShareimageList() { + return shareimageList; + } + + public void setShareimageList(String shareimageList) { + this.shareimageList = shareimageList; + } + + public int getUpCount() { + return upCount; + } + + public void setUpCount(int upCount) { + this.upCount = upCount; + } + + + public int getReward() { + return reward; + } + + + public void setReward(int reward) { + this.reward = reward; + } + + + public String getProductId() { + return productId; + } + + + public void setProductId(String productId) { + this.productId = productId; + } + + + public String getProductName() { + return productName; + } + + + public void setProductName(String productName) { + this.productName = productName; + } + + + public String getProductTitle() { + return productTitle; + } + + + public void setProductTitle(String productTitle) { + this.productTitle = productTitle; + } + + + public String getProductPrice() { + return productPrice; + } + + + public void setProductPrice(String productPrice) { + this.productPrice = productPrice; + } + + + public String getWinRandomNumber() { + return winRandomNumber; + } + + + public void setWinRandomNumber(String winRandomNumber) { + this.winRandomNumber = winRandomNumber; + } + + + public String getProductImg() { + return productImg; + } + + + public void setProductImg(String productImg) { + this.productImg = productImg; + } + + + public String getWinUserName() { + return winUserName; + } + + + public void setWinUserName(String winUserName) { + this.winUserName = winUserName; + } + + + public String getBuyNumberCount() { + return buyNumberCount; + } + + + public void setBuyNumberCount(String buyNumberCount) { + this.buyNumberCount = buyNumberCount; + } + + + public String getAnnouncedTime() { + return announcedTime; + } + + public void setAnnouncedTime(String announcedTime) { + this.announcedTime = announcedTime; + } + + public int getResultSize() { + return resultSize; + } + + + public void setResultSize(int resultSize) { + this.resultSize = resultSize; + } + + + public String getSpellbuyProductId() { + return spellbuyProductId; + } + + + public void setSpellbuyProductId(String spellbuyProductId) { + this.spellbuyProductId = spellbuyProductId; + } + + public String getProductPeriod() { + return productPeriod; + } + + public void setProductPeriod(String productPeriod) { + this.productPeriod = productPeriod; + } + + public String getBuyDate() { + return buyDate; + } + + public void setBuyDate(String buyDate) { + this.buyDate = buyDate; + } + + public String getWinUserFace() { + return winUserFace; + } + + public void setWinUserFace(String winUserFace) { + this.winUserFace = winUserFace; + } + + + public int getReplyCount() { + return replyCount; + } + + + public void setReplyCount(int replyCount) { + this.replyCount = replyCount; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/ShareJSON.java b/src/main/java/me/mofun/pojo/ShareJSON.java new file mode 100644 index 0000000..37f268f --- /dev/null +++ b/src/main/java/me/mofun/pojo/ShareJSON.java @@ -0,0 +1,127 @@ +package me.mofun.pojo; + +import java.io.Serializable; + +public class ShareJSON implements Serializable { + + private static final long serialVersionUID = -8825464421098017421L; + + private Integer uid; + private String shareTitle; + private String shareContent; + private String shareImages; + private Integer upCount; + private Integer replyCount; + private Integer reward; + private String shareDate; + private String announcedTime; + private String userName; + private String userFace; + private String userId; + private Integer status; + public ShareJSON() { + super(); + } + public ShareJSON(Integer uid, String shareTitle, String shareContent, + String shareImages, Integer upCount, Integer replyCount, + Integer reward, String shareDate, String announcedTime, + String userName, String userFace, String userId, Integer status) { + super(); + this.uid = uid; + this.shareTitle = shareTitle; + this.shareContent = shareContent; + this.shareImages = shareImages; + this.upCount = upCount; + this.replyCount = replyCount; + this.reward = reward; + this.shareDate = shareDate; + this.announcedTime = announcedTime; + this.userName = userName; + this.userFace = userFace; + this.userId = userId; + this.status = status; + } + public Integer getUid() { + return uid; + } + public void setUid(Integer uid) { + this.uid = uid; + } + public String getShareTitle() { + return shareTitle; + } + public void setShareTitle(String shareTitle) { + this.shareTitle = shareTitle; + } + public String getShareContent() { + return shareContent; + } + public void setShareContent(String shareContent) { + this.shareContent = shareContent; + } + public String getShareImages() { + return shareImages; + } + public void setShareImages(String shareImages) { + this.shareImages = shareImages; + } + public Integer getUpCount() { + return upCount; + } + public void setUpCount(Integer upCount) { + this.upCount = upCount; + } + public Integer getReplyCount() { + return replyCount; + } + public void setReplyCount(Integer replyCount) { + this.replyCount = replyCount; + } + public Integer getReward() { + return reward; + } + public void setReward(Integer reward) { + this.reward = reward; + } + public String getShareDate() { + return shareDate; + } + public void setShareDate(String shareDate) { + this.shareDate = shareDate; + } + public String getAnnouncedTime() { + return announcedTime; + } + public void setAnnouncedTime(String announcedTime) { + this.announcedTime = announcedTime; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getUserFace() { + return userFace; + } + public void setUserFace(String userFace) { + this.userFace = userFace; + } + public String getUserId() { + return userId; + } + public void setUserId(String userId) { + this.userId = userId; + } + public Integer getStatus() { + return status; + } + public void setStatus(Integer status) { + this.status = status; + } + public static long getSerialVersionUID() { + return serialVersionUID; + } + + +} diff --git a/src/main/java/me/mofun/pojo/Sharecomments.hbm.xml b/src/main/java/me/mofun/pojo/Sharecomments.hbm.xml new file mode 100644 index 0000000..df28e98 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Sharecomments.hbm.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + shareInfo表外键 + + + + + 回复评论ID + + + + + 评论人id + + + + + + + + + + + 回复评论数 + + + + diff --git a/src/main/java/me/mofun/pojo/Sharecomments.java b/src/main/java/me/mofun/pojo/Sharecomments.java new file mode 100644 index 0000000..2610ed3 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Sharecomments.java @@ -0,0 +1,98 @@ +package me.mofun.pojo; + +/** + * Sharecomments entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Sharecomments implements java.io.Serializable { + + // Fields + + private Integer uid; + private Integer shareInfoId; + private Integer reCommentId; + private Integer userId; + private String content; + private String createDate; + private Integer reCount; + + // Constructors + + public Sharecomments(Integer uid, Integer shareInfoId, Integer reCommentId, + Integer userId, String content, String createDate, Integer reCount) { + super(); + this.uid = uid; + this.shareInfoId = shareInfoId; + this.reCommentId = reCommentId; + this.userId = userId; + this.content = content; + this.createDate = createDate; + this.reCount = reCount; + } + + /** default constructor */ + public Sharecomments() { + } + + // Property accessors + + public Integer getUid() { + return this.uid; + } + + public void setUid(Integer uid) { + this.uid = uid; + } + + public Integer getShareInfoId() { + return this.shareInfoId; + } + + public void setShareInfoId(Integer shareInfoId) { + this.shareInfoId = shareInfoId; + } + + public Integer getUserId() { + return this.userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getCreateDate() { + return this.createDate; + } + + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + + public Integer getReCommentId() { + return reCommentId; + } + + public void setReCommentId(Integer reCommentId) { + this.reCommentId = reCommentId; + } + + + public Integer getReCount() { + return reCount; + } + + public void setReCount(Integer reCount) { + this.reCount = reCount; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Shareimage.hbm.xml b/src/main/java/me/mofun/pojo/Shareimage.hbm.xml new file mode 100644 index 0000000..97c6346 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Shareimage.hbm.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + shareInfo表外键 + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Shareimage.java b/src/main/java/me/mofun/pojo/Shareimage.java new file mode 100644 index 0000000..daa7dbf --- /dev/null +++ b/src/main/java/me/mofun/pojo/Shareimage.java @@ -0,0 +1,61 @@ +package me.mofun.pojo; + +/** + * Shareimage entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Shareimage implements java.io.Serializable { + + // Fields + + private Integer uid; + private Integer shareInfoId; + private String images; + + + public Shareimage() { + super(); + } + + + public Shareimage(Integer uid, Integer shareInfoId, String images) { + super(); + this.uid = uid; + this.shareInfoId = shareInfoId; + this.images = images; + } + + + public Integer getUid() { + return uid; + } + + + public void setUid(Integer uid) { + this.uid = uid; + } + + + public Integer getShareInfoId() { + return shareInfoId; + } + + + public void setShareInfoId(Integer shareInfoId) { + this.shareInfoId = shareInfoId; + } + + + public String getImages() { + return images; + } + + + public void setImages(String images) { + this.images = images; + } + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Shareinfo.hbm.xml b/src/main/java/me/mofun/pojo/Shareinfo.hbm.xml new file mode 100644 index 0000000..f21cbf8 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Shareinfo.hbm.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + 商品ID + + + + + 分享主题 + + + + + 分享内容 + + + + + 顶的次数 + + + + + 回复数 + + + + + 是否奖励过,0:未奖励.1:已奖励 + + + + + 分享时间 + + + + + 用户id + + + + + 状态 -1 暂未晒单 0等待审核 1未审核通过,请重新修改晒单信息 2审核通过,奖励10元 + + + + diff --git a/src/main/java/me/mofun/pojo/Shareinfo.java b/src/main/java/me/mofun/pojo/Shareinfo.java new file mode 100644 index 0000000..392e58d --- /dev/null +++ b/src/main/java/me/mofun/pojo/Shareinfo.java @@ -0,0 +1,128 @@ +package me.mofun.pojo; + +/** + * Shareinfo entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Shareinfo implements java.io.Serializable { + + // Fields + + private Integer uid; + private Integer productId; + private String shareTitle; + private String shareContent; + private Integer upCount; + private Integer replyCount; + private Integer reward; + private String shareDate; + private Integer userId; + private Integer status = 0; + + // Constructors + + + /** default constructor */ + public Shareinfo() { + } + + public Shareinfo(Integer productId, String shareTitle, String shareContent, + Integer upCount, Integer replyCount, Integer reward, + String shareDate, Integer userId, Integer status) { + super(); + this.productId = productId; + this.shareTitle = shareTitle; + this.shareContent = shareContent; + this.upCount = upCount; + this.replyCount = replyCount; + this.reward = reward; + this.shareDate = shareDate; + this.userId = userId; + this.status = status; + } + + + + public Integer getUid() { + return uid; + } + + public void setUid(Integer uid) { + this.uid = uid; + } + + public String getShareTitle() { + return shareTitle; + } + + public void setShareTitle(String shareTitle) { + this.shareTitle = shareTitle; + } + + public String getShareContent() { + return shareContent; + } + + public void setShareContent(String shareContent) { + this.shareContent = shareContent; + } + + public Integer getUpCount() { + return upCount; + } + + public void setUpCount(Integer upCount) { + this.upCount = upCount; + } + + public Integer getReplyCount() { + return replyCount; + } + + public void setReplyCount(Integer replyCount) { + this.replyCount = replyCount; + } + + public Integer getReward() { + return reward; + } + + public void setReward(Integer reward) { + this.reward = reward; + } + + public String getShareDate() { + return shareDate; + } + + public void setShareDate(String shareDate) { + this.shareDate = shareDate; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Shop.hbm.xml b/src/main/java/me/mofun/pojo/Shop.hbm.xml new file mode 100644 index 0000000..45525bd --- /dev/null +++ b/src/main/java/me/mofun/pojo/Shop.hbm.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + 父店铺ID + + + + + 店铺或机构的昵称 + + + + + + + + 店铺或机构的注册名字 + + + + + 国家/地区 + + + + + 省份 + + + + + + + + + + 县/城区 + + + + + 店铺详细地址 + + + + + 所属商圈 + + + + + 店铺证照 + + + + + 店铺证照类型 + + + + + 店铺类型:0个人店铺;1机构或企业店铺 + + + + + 店铺X坐标 + + + + + 店铺Y坐标 + + + + + 法人代表名字 + + + + + 法人代表身份证号 + + + + + 法人近照 + + + + + 注册资金 + + + + + 保证金(元) + + + + + 创始人ID,来自于User表userId字段 + + + + + 公司客服QQ,多个QQ之间以英文逗号分隔 + + + + + 公司QQ群,多个QQ群之间以英文逗号分隔 + + + + + 微信账号,多个微信账号之间以英文逗号分隔 + + + + + 公司微信公共账号,多个账号之间以英文逗号分隔 + + + + + 默认支付渠道:1支付宝,2腾讯支付 + + + + + 公司腾讯支付账号 + + + + + 公司支付宝账号 + + + + + 管理者姓名,紧急联络时用,无其他用途. + + + + + 管理者头衔,紧急联络时用,无其他用途. + + + + + 管理者电话,紧急联络时用,无其他用途. + + + + + 客服电话,多个客服电话以英文逗号分隔 + + + + + 创建时间 + + + + + 本条信息更新时间,用于信息变更时用 + + + + + 星级 + + + + + 店铺状态: + + + + + 店铺介绍 + + + + + 审核者Id,来自于User表UserID字段 + + + + + 审核意见:通过/不通过及原因 + + + + + 审核时间 + + + + diff --git a/src/main/java/me/mofun/pojo/Shop.java b/src/main/java/me/mofun/pojo/Shop.java new file mode 100644 index 0000000..83c3e6e --- /dev/null +++ b/src/main/java/me/mofun/pojo/Shop.java @@ -0,0 +1,437 @@ +package me.mofun.pojo; + +import java.sql.Timestamp; + +/** + * Shop entity. @author MyEclipse Persistence Tools + */ + +public class Shop implements java.io.Serializable { + + // Fields + + private Integer shopId; + private Integer shopParentId; + private String shopName; + private String logo; + private String companyName; + private String country; + private String province; + private String city; + private String county; + private String shopAddress; + private String businessArea; + private String credentialsPhoto; + private Integer credentialsType; + private Integer shopType; + private Double x; + private Double y; + private String legalRepresentativeName; + private String legalRepresentativeId; + private String legalPhoto; + private Float registerMoney; + private Float cashDeposit; + private Integer originatorId; + private String qq; + private String qqGroup; + private String weixin; + private String weixinPublic; + private Integer payChannel; + private String tengpay; + private String alipay; + private String managerName; + private String manngerTitle; + private String managerPhone; + private String servicePhone; + private Timestamp createTime; + private Timestamp updateTime; + private Short star; + private Short status; + private String synopsis; + private Integer auditorId; + private String auditMessage; + private Timestamp auditTime; + + // Constructors + + /** default constructor */ + public Shop() { + } + + /** full constructor */ + public Shop(Integer shopParentId, String shopName, String logo, String companyName, String country, String province, String city, String county, + String shopAddress, String businessArea, String credentialsPhoto, Integer credentialsType, Integer shopType, Double x, Double y, + String legalRepresentativeName, String legalRepresentativeId, String legalPhoto, Float registerMoney, Float cashDeposit, Integer originatorId, + String qq, String qqGroup, String weixin, String weixinPublic,Integer payChannel, String tengpay, String alipay, String managerName, String manngerTitle, + String managerPhone, String servicePhone, Timestamp createTime, Timestamp updateTime, Short star, Short status, String synopsis) { + this.shopParentId = shopParentId; + this.shopName = shopName; + this.logo = logo; + this.companyName = companyName; + this.country = country; + this.province = province; + this.city = city; + this.county = county; + this.shopAddress = shopAddress; + this.businessArea = businessArea; + this.credentialsPhoto = credentialsPhoto; + this.credentialsType = credentialsType; + this.shopType = shopType; + this.x = x; + this.y = y; + this.legalRepresentativeName = legalRepresentativeName; + this.legalRepresentativeId = legalRepresentativeId; + this.legalPhoto = legalPhoto; + this.registerMoney = registerMoney; + this.cashDeposit = cashDeposit; + this.originatorId = originatorId; + this.qq = qq; + this.qqGroup = qqGroup; + this.weixin = weixin; + this.weixinPublic = weixinPublic; + this.payChannel = payChannel; + this.tengpay = tengpay; + this.alipay = alipay; + this.managerName = managerName; + this.manngerTitle = manngerTitle; + this.managerPhone = managerPhone; + this.servicePhone = servicePhone; + this.createTime = createTime; + this.updateTime = updateTime; + this.star = star; + this.status = status; + this.synopsis = synopsis; + } + + // Property accessors + + public Integer getShopId() { + return this.shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getShopParentId() { + return this.shopParentId; + } + + public void setShopParentId(Integer shopParentId) { + this.shopParentId = shopParentId; + } + + public String getShopName() { + return this.shopName; + } + + public void setShopName(String shopName) { + this.shopName = shopName; + } + + public String getLogo() { + return this.logo; + } + + public void setLogo(String logo) { + this.logo = logo; + } + + public String getCompanyName() { + return this.companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + + public String getCountry() { + return this.country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getProvince() { + return this.province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return this.city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCounty() { + return this.county; + } + + public void setCounty(String county) { + this.county = county; + } + + public String getShopAddress() { + return this.shopAddress; + } + + public void setShopAddress(String shopAddress) { + this.shopAddress = shopAddress; + } + + public String getBusinessArea() { + return this.businessArea; + } + + public void setBusinessArea(String businessArea) { + this.businessArea = businessArea; + } + + public String getCredentialsPhoto() { + return this.credentialsPhoto; + } + + public void setCredentialsPhoto(String credentialsPhoto) { + this.credentialsPhoto = credentialsPhoto; + } + + public Integer getCredentialsType() { + return this.credentialsType; + } + + public void setCredentialsType(Integer credentialsType) { + this.credentialsType = credentialsType; + } + + public Integer getShopType() { + return this.shopType; + } + + public void setShopType(Integer shopType) { + this.shopType = shopType; + } + + public Double getX() { + return this.x; + } + + public void setX(Double x) { + this.x = x; + } + + public Double getY() { + return this.y; + } + + public void setY(Double y) { + this.y = y; + } + + public String getLegalRepresentativeName() { + return this.legalRepresentativeName; + } + + public void setLegalRepresentativeName(String legalRepresentativeName) { + this.legalRepresentativeName = legalRepresentativeName; + } + + public String getLegalRepresentativeId() { + return this.legalRepresentativeId; + } + + public void setLegalRepresentativeId(String legalRepresentativeId) { + this.legalRepresentativeId = legalRepresentativeId; + } + + public String getLegalPhoto() { + return this.legalPhoto; + } + + public void setLegalPhoto(String legalPhoto) { + this.legalPhoto = legalPhoto; + } + + public Float getRegisterMoney() { + return this.registerMoney; + } + + public void setRegisterMoney(Float registerMoney) { + this.registerMoney = registerMoney; + } + + public Float getCashDeposit() { + return this.cashDeposit; + } + + public void setCashDeposit(Float cashDeposit) { + this.cashDeposit = cashDeposit; + } + + public Integer getOriginatorId() { + return this.originatorId; + } + + public void setOriginatorId(Integer originatorId) { + this.originatorId = originatorId; + } + + public String getQq() { + return this.qq; + } + + public void setQq(String qq) { + this.qq = qq; + } + + public String getQqGroup() { + return this.qqGroup; + } + + public void setQqGroup(String qqGroup) { + this.qqGroup = qqGroup; + } + + public String getWeixin() { + return this.weixin; + } + + public void setWeixin(String weixin) { + this.weixin = weixin; + } + + public String getWeixinPublic() { + return this.weixinPublic; + } + + public void setWeixinPublic(String weixinPublic) { + this.weixinPublic = weixinPublic; + } + + public Integer getPayChannel() { + return payChannel; + } + + public void setPayChannel(Integer payChannel) { + this.payChannel = payChannel; + } + + public String getTengpay() { + return this.tengpay; + } + + public void setTengpay(String tengpay) { + this.tengpay = tengpay; + } + + public String getAlipay() { + return this.alipay; + } + + public void setAlipay(String alipay) { + this.alipay = alipay; + } + + public String getManagerName() { + return this.managerName; + } + + public void setManagerName(String managerName) { + this.managerName = managerName; + } + + public String getManngerTitle() { + return this.manngerTitle; + } + + public void setManngerTitle(String manngerTitle) { + this.manngerTitle = manngerTitle; + } + + public String getManagerPhone() { + return this.managerPhone; + } + + public void setManagerPhone(String managerPhone) { + this.managerPhone = managerPhone; + } + + public String getServicePhone() { + return this.servicePhone; + } + + public void setServicePhone(String servicePhone) { + this.servicePhone = servicePhone; + } + + public Timestamp getCreateTime() { + return this.createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public Timestamp getUpdateTime() { + return this.updateTime; + } + + public void setUpdateTime(Timestamp updateTime) { + this.updateTime = updateTime; + } + + public Short getStar() { + return this.star; + } + + public void setStar(Short star) { + this.star = star; + } + + public Short getStatus() { + return this.status; + } + + public void setStatus(Short status) { + this.status = status; + } + + public String getSynopsis() { + return this.synopsis; + } + + public void setSynopsis(String synopsis) { + this.synopsis = synopsis; + } + + public Integer getAuditorId() { + return auditorId; + } + + public void setAuditorId(Integer auditorId) { + this.auditorId = auditorId; + } + + public String getAuditMessage() { + return auditMessage; + } + + public void setAuditMessage(String auditMessage) { + this.auditMessage = auditMessage; + } + + public Timestamp getAuditTime() { + return auditTime; + } + + public void setAuditTime(Timestamp auditTime) { + this.auditTime = auditTime; + } + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Spellbuyproduct.hbm.xml b/src/main/java/me/mofun/pojo/Spellbuyproduct.hbm.xml new file mode 100644 index 0000000..cba8f99 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Spellbuyproduct.hbm.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + 商品id + + + + + 拼购开始时间 + + + + + 拼购结束时间 + + + + + 拼购总份数 + + + + + 拼购单价 + + + + + 市场价(电商版新增字段,用于与促销活动时,活动价对比用,有活动时应该填充这个值且高于singlePrice价格,没活动时填写0就好,实际价格会取singlePrice字段值 + + + + + 市场价(活动名称) + + + + + 拍购版:单次价格;电商版:当前价/活动价/实际支付价 + + + + + 期数 + + + + + 限购次数,0:不限购,5:单人限购5次 + + + + + 状态 0未完成 1已完成 + + + + + 1限时0普通 + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Spellbuyproduct.java b/src/main/java/me/mofun/pojo/Spellbuyproduct.java new file mode 100644 index 0000000..91e4647 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Spellbuyproduct.java @@ -0,0 +1,195 @@ +package me.mofun.pojo; + +/** + * Spellbuyproduct entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Spellbuyproduct implements java.io.Serializable { + + // Fields + + private Integer spellbuyProductId; + private Integer fkProductId; + private String spellbuyStartDate; + private String spellbuyEndDate; + private Integer spellbuyCount; + private Integer spellbuyPrice; + private Float marketPrice; + private String actionName; + private Integer spSinglePrice; + private Integer productPeriod; + private Integer spellbuyLimit; + private Integer spStatus; + private Integer spellbuyType; + private String attribute64; + private String attribute65; + + // Constructors + + + public Spellbuyproduct(Integer spellbuyProductId, Integer fkProductId, + String spellbuyStartDate, String spellbuyEndDate, + Integer spellbuyCount, Integer spellbuyPrice,Float marketPrice,String actionName,Integer spSinglePrice, + Integer productPeriod, Integer spellbuyLimit, Integer spStatus, Integer spellbuyType, + String attribute64, String attribute65) { + super(); + this.spellbuyProductId = spellbuyProductId; + this.fkProductId = fkProductId; + this.spellbuyStartDate = spellbuyStartDate; + this.spellbuyEndDate = spellbuyEndDate; + this.spellbuyCount = spellbuyCount; + this.spellbuyPrice = spellbuyPrice; + this.marketPrice = marketPrice; + this.actionName = actionName; + this.spSinglePrice = spSinglePrice; + this.productPeriod = productPeriod; + this.spellbuyLimit = spellbuyLimit; + this.spStatus = spStatus; + this.spellbuyType = spellbuyType; + this.attribute64 = attribute64; + this.attribute65 = attribute65; + } + + /** default constructor */ + public Spellbuyproduct() { + } + + /** minimal constructor */ + public Spellbuyproduct(Integer fkProductId, String spellbuyStartDate, + String spellbuyEndDate, Integer spellbuyCount, Integer spellbuyPrice,Integer spSinglePrice) { + this.fkProductId = fkProductId; + this.spellbuyStartDate = spellbuyStartDate; + this.spellbuyEndDate = spellbuyEndDate; + this.spellbuyCount = spellbuyCount; + this.spellbuyPrice = spellbuyPrice; + this.spSinglePrice = spSinglePrice; + } + + /** full constructor */ + + + // Property accessors + + public Integer getSpellbuyProductId() { + return this.spellbuyProductId; + } + + public void setSpellbuyProductId(Integer spellbuyProductId) { + this.spellbuyProductId = spellbuyProductId; + } + + public Integer getFkProductId() { + return this.fkProductId; + } + + public void setFkProductId(Integer fkProductId) { + this.fkProductId = fkProductId; + } + + public String getSpellbuyStartDate() { + return this.spellbuyStartDate; + } + + public void setSpellbuyStartDate(String spellbuyStartDate) { + this.spellbuyStartDate = spellbuyStartDate; + } + + public String getSpellbuyEndDate() { + return this.spellbuyEndDate; + } + + public void setSpellbuyEndDate(String spellbuyEndDate) { + this.spellbuyEndDate = spellbuyEndDate; + } + + public Integer getSpellbuyCount() { + return this.spellbuyCount; + } + + public void setSpellbuyCount(Integer spellbuyCount) { + this.spellbuyCount = spellbuyCount; + } + + public Integer getSpellbuyPrice() { + return this.spellbuyPrice; + } + + public void setSpellbuyPrice(Integer spellbuyPrice) { + this.spellbuyPrice = spellbuyPrice; + } + + public Float getMarketPrice() { + return marketPrice; + } + + public void setMarketPrice(Float marketPrice) { + this.marketPrice = marketPrice; + } + + public String getActionName() { + return actionName; + } + + public void setActionName(String actionName) { + this.actionName = actionName; + } + + public String getAttribute64() { + return this.attribute64; + } + + public void setAttribute64(String attribute64) { + this.attribute64 = attribute64; + } + + public String getAttribute65() { + return this.attribute65; + } + + public void setAttribute65(String attribute65) { + this.attribute65 = attribute65; + } + + public Integer getProductPeriod() { + return productPeriod; + } + + public void setProductPeriod(Integer productPeriod) { + this.productPeriod = productPeriod; + } + + public Integer getSpellbuyLimit() { + return spellbuyLimit; + } + + public void setSpellbuyLimit(Integer spellbuyLimit) { + this.spellbuyLimit = spellbuyLimit; + } + + public Integer getSpStatus() { + return spStatus; + } + + public void setSpStatus(Integer spStatus) { + this.spStatus = spStatus; + } + + public Integer getSpellbuyType() { + return spellbuyType; + } + + public void setSpellbuyType(Integer spellbuyType) { + this.spellbuyType = spellbuyType; + } + + public Integer getSpSinglePrice() { + return spSinglePrice; + } + + public void setSpSinglePrice(Integer spSinglePrice) { + this.spSinglePrice = spSinglePrice; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Spellbuyrecord.hbm.xml b/src/main/java/me/mofun/pojo/Spellbuyrecord.hbm.xml new file mode 100644 index 0000000..f78a084 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Spellbuyrecord.hbm.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + 拼购人 + + + + + 出价 + + + + + 拼购时间 yyyyMMddHHmmss + + + + + buyIp + + + + + buyLocal + + + + + buySource + + + + + 拼购随机码 + + + + + 中奖状态 0:未中奖 1:中奖 2:未中奖差价购买 + + + + + 拼购状态 本次拼购是否完成. 0:未完成1:已完成 + + + + + + + + + + diff --git a/src/main/java/me/mofun/pojo/Spellbuyrecord.java b/src/main/java/me/mofun/pojo/Spellbuyrecord.java new file mode 100644 index 0000000..44a041d --- /dev/null +++ b/src/main/java/me/mofun/pojo/Spellbuyrecord.java @@ -0,0 +1,168 @@ +package me.mofun.pojo; + +/** + * Spellbuyrecord entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Spellbuyrecord implements java.io.Serializable { + + // Fields + + public Integer spellbuyRecordId; + public Integer fkSpellbuyProductId; + public Integer buyer; + public Integer buyPrice; + public String buyDate; + public String buyIp; + public String buyLocal; + public Integer buySource; + public String spRandomNo; + public String spWinningStatus; + public String buyStatus; + public String attribute66; + public String attribute67; + + // Constructors + + /** default constructor */ + public Spellbuyrecord() { + } + + /** minimal constructor */ + public Spellbuyrecord(Integer fkSpellbuyProductId, Integer buyer, + Integer buyPrice, String buyDate, String spRandomNo, + String spWinningStatus, String buyStatus) { + this.fkSpellbuyProductId = fkSpellbuyProductId; + this.buyer = buyer; + this.buyPrice = buyPrice; + this.buyDate = buyDate; + this.spRandomNo = spRandomNo; + this.spWinningStatus = spWinningStatus; + this.buyStatus = buyStatus; + } + + /** full constructor */ + public Spellbuyrecord(Integer fkSpellbuyProductId, Integer buyer, + Integer buyPrice, String buyDate, String spRandomNo, + String spWinningStatus, String buyStatus, String attribute66, + String attribute67) { + this.fkSpellbuyProductId = fkSpellbuyProductId; + this.buyer = buyer; + this.buyPrice = buyPrice; + this.buyDate = buyDate; + this.spRandomNo = spRandomNo; + this.spWinningStatus = spWinningStatus; + this.buyStatus = buyStatus; + this.attribute66 = attribute66; + this.attribute67 = attribute67; + } + + // Property accessors + + public Integer getSpellbuyRecordId() { + return this.spellbuyRecordId; + } + + public void setSpellbuyRecordId(Integer spellbuyRecordId) { + this.spellbuyRecordId = spellbuyRecordId; + } + + public Integer getFkSpellbuyProductId() { + return this.fkSpellbuyProductId; + } + + public void setFkSpellbuyProductId(Integer fkSpellbuyProductId) { + this.fkSpellbuyProductId = fkSpellbuyProductId; + } + + public Integer getBuyer() { + return this.buyer; + } + + public void setBuyer(Integer buyer) { + this.buyer = buyer; + } + + public Integer getBuyPrice() { + return this.buyPrice; + } + + public void setBuyPrice(Integer buyPrice) { + this.buyPrice = buyPrice; + } + + public String getBuyDate() { + return this.buyDate; + } + + public void setBuyDate(String buyDate) { + this.buyDate = buyDate; + } + + public String getBuyIp() { + return buyIp; + } + + public void setBuyIp(String buyIp) { + this.buyIp = buyIp; + } + + public String getBuyLocal() { + return buyLocal; + } + + public void setBuyLocal(String buyLocal) { + this.buyLocal = buyLocal; + } + + public Integer getBuySource() { + return buySource; + } + + public void setBuySource(Integer buySource) { + this.buySource = buySource; + } + + public String getSpRandomNo() { + return this.spRandomNo; + } + + public void setSpRandomNo(String spRandomNo) { + this.spRandomNo = spRandomNo; + } + + public String getSpWinningStatus() { + return this.spWinningStatus; + } + + public void setSpWinningStatus(String spWinningStatus) { + this.spWinningStatus = spWinningStatus; + } + + public String getBuyStatus() { + return this.buyStatus; + } + + public void setBuyStatus(String buyStatus) { + this.buyStatus = buyStatus; + } + + public String getAttribute66() { + return this.attribute66; + } + + public void setAttribute66(String attribute66) { + this.attribute66 = attribute66; + } + + public String getAttribute67() { + return this.attribute67; + } + + public void setAttribute67(String attribute67) { + this.attribute67 = attribute67; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Suggestion.hbm.xml b/src/main/java/me/mofun/pojo/Suggestion.hbm.xml new file mode 100644 index 0000000..2d5667b --- /dev/null +++ b/src/main/java/me/mofun/pojo/Suggestion.hbm.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + 主题 + + + + + 昵称 + + + + + 电话 + + + + + 邮箱 + + + + + 内容 + + + + diff --git a/src/main/java/me/mofun/pojo/Suggestion.java b/src/main/java/me/mofun/pojo/Suggestion.java new file mode 100644 index 0000000..cd2164f --- /dev/null +++ b/src/main/java/me/mofun/pojo/Suggestion.java @@ -0,0 +1,86 @@ +package me.mofun.pojo; + +/** + * Suggestion entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Suggestion implements java.io.Serializable { + + // Fields + + private Integer id; + private String subject; + private String userName; + private String mobilePhone; + private String mail; + private String postText; + + // Constructors + + /** default constructor */ + public Suggestion() { + } + + /** full constructor */ + public Suggestion(String subject, String userName, String mobilePhone, + String mail, String postText) { + this.subject = subject; + this.userName = userName; + this.mobilePhone = mobilePhone; + this.mail = mail; + this.postText = postText; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getSubject() { + return this.subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public String getUserName() { + return this.userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getMobilePhone() { + return this.mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getMail() { + return this.mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + + public String getPostText() { + return this.postText; + } + + public void setPostText(String postText) { + this.postText = postText; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/SysConfigure.hbm.xml b/src/main/java/me/mofun/pojo/SysConfigure.hbm.xml new file mode 100644 index 0000000..6f13004 --- /dev/null +++ b/src/main/java/me/mofun/pojo/SysConfigure.hbm.xml @@ -0,0 +1,292 @@ + + + + + + + + + + + + 图片域名网址 + + + + + 皮肤域名网址 + + + + + 主域名网址 + + + + + 圈子域名网址 + + + + + 用户域名网址 + + + + + 用户头像域名网址 + + + + + 通行证域名网址 + + + + + api域名网址 + + + + + 域名域 + + + + + 网站名称 + + + + + 网站短名称 + + + + + 网站标题 + + + + + 网站logo + + + + + 网站关键词 + + + + + 网站描述 + + + + + 系统邮箱 + + + + + 系统邮箱密码 + + + + + 系统邮箱SMTP服务器地址 + + + + + 财付通号 + + + + + 财付通密钥 + + + + + 财付通是否启用 0 启用 1禁用 + + + + + 支付宝号 + + + + + 支付宝密钥 + + + + + 支付宝邮箱 + + + + + 支付宝是否启用 0 启用 1禁用 + + + + + 易付宝号 + + + + + 易付宝密钥 + + + + + 易付宝是否启用 0 启用 1禁用 + + + + + + 中国银行是否启用 0 启用 1禁用 + + + + + 快钱支付是否启用 0 启用 1禁用 + + + + + 统一支付是否启用 0 启用 1禁用 + + + + + 阿里支付是否启用 0 启用 1禁用 + + + + + 腾讯支付是否启用 0 启用 1禁用 + + + + + 微信是否启用 0 启用 1禁用 + + + + + + + ICP备案号 + + + + + 客服QQ + + + + + 客服电话 + + + + + qqAppId + + + + + qqAppKey + + + + + qq互联登录是否开启 0 启用 1禁用 + + + + + 短信服务帐号 + + + + + 短信服务密钥 + + + + + 短信通道编号 + + + + + 短信签名编号 + + + + + 注册送余额 + + + + + 充值满多少 + + + + + 充值满多少送多少 + + + + + 佣金提成?% + + + + + 邀请奖励福分 + + + + + 资料完善奖励福分 + + + + + 购买商品奖励福分 + + + + + + + + + + 告警或系统监控邮件接收邮箱地址,便于系统维护 + + + + + 对象JSON序列化后时的密钥Key,用于AES加密 + + + + + 系统版本类型:1表示拍购版本,2表示普通电商版本 + + + + diff --git a/src/main/java/me/mofun/pojo/SysConfigure.java b/src/main/java/me/mofun/pojo/SysConfigure.java new file mode 100644 index 0000000..acdea78 --- /dev/null +++ b/src/main/java/me/mofun/pojo/SysConfigure.java @@ -0,0 +1,616 @@ +package me.mofun.pojo; + +/** + * SysConfigure entity. + * + * @author MyEclipse Persistence Tools + */ + +public class SysConfigure implements java.io.Serializable { + + // Fields + + private Integer id; + private String imgUrl; + private String skinUrl; + private String wwwUrl; + private String groupUrl; + private String userUrl; + private String faceUrl; + private String passportUrl; + private String apiUrl; + private String domain; + private String siteName; + private String shortName; + private String siteTitle; + private String siteLogo; + private String keyword; + private String description; + private String mailName; + private String mailPwd; + private String mailsmtp; + private String tenpayPartner; + private String tenpayKey; + private Integer tenpayStatus; + private String alipayPartner; + private String alipayKey; + private String alipayMail; + private Integer alipayStatus; + private String yeepayKey; + private String yeepayPartner; + private Integer yeepayStatus; + + //add by lwgboy + private Integer chinabankStatus; + private Integer billStatus; + private Integer unionpayStatus; + private Integer aliPayUserStatus; + private Integer tenPayUserStatus; + private Integer weixinStatus; + + private String icp; + private String serviceQq; + private String serviceTel; + private String qqAppId; + private String qqAppKey; + private Integer qqAppStatus; + private String messagePartner; + private String messageKey; + private String messageChannel; + private String messageSign; + private Double regBalance; + private Double recMoney; + private Double recBalance; + private Double commission; + private Integer invite; + private Integer userData; + private Integer buyProduct; //用户购买商品时奖励福分的系数:0:表示不奖励福;,n:表示参与拍购每消费1元奖励n个福分,一般取值1 + private String authorization; + private String alertMail; + private String jsonAESKey; //对象序列化时的加密秘钥key + private Integer versionType; //版本类型:1表示拍购版本,2表示普通电商版本 + + public SysConfigure(Integer id, String imgUrl, String skinUrl, + String wwwUrl, String groupUrl, String userUrl, String faceUrl, String passportUrl, String apiUrl,String domain, String siteName, String shortName, + String siteTitle, String siteLogo, String keyword, + String description, String mailName, String mailPwd, + String tenpayPartner, String tenpayKey, Integer tenpayStatus, + String alipayPartner, String alipayKey, String alipayMail, + Integer alipayStatus, String yeepayKey, String yeepayPartner, + Integer yeepayStatus, + + Integer chinabankStatus, + Integer billStatus, + Integer unionpayStatus, + Integer aliPayUserStatus, + Integer tenPayUserStatus, + Integer weixinStatus, + + String icp, String serviceQq, + String serviceTel, String qqAppId, String qqAppKey, + Integer qqAppStatus, String messagePartner, String messageKey, + String messageChannel, String messageSign, Double regBalance, + Double recMoney, Double recBalance, Double commission, + Integer invite, Integer userData, Integer buyProduct, + String authorization, + String alertMail, + String jsonAESKey, + Integer versionType) { + super(); + this.id = id; + this.imgUrl = imgUrl; + this.skinUrl = skinUrl; + this.wwwUrl = wwwUrl; + this.groupUrl = groupUrl; + this.userUrl = userUrl; + this.faceUrl = faceUrl; + this.passportUrl = passportUrl; + this.apiUrl = apiUrl; + this.domain = domain; + this.siteName = siteName; + this.shortName = shortName; + this.siteTitle = siteTitle; + this.siteLogo = siteLogo; + this.keyword = keyword; + this.description = description; + this.mailName = mailName; + this.mailPwd = mailPwd; + this.tenpayPartner = tenpayPartner; + this.tenpayKey = tenpayKey; + this.tenpayStatus = tenpayStatus; + this.alipayPartner = alipayPartner; + this.alipayKey = alipayKey; + this.alipayMail = alipayMail; + this.alipayStatus = alipayStatus; + this.yeepayKey = yeepayKey; + this.yeepayPartner = yeepayPartner; + this.yeepayStatus = yeepayStatus; + + this.chinabankStatus = chinabankStatus; + this.billStatus = billStatus; + this.unionpayStatus = unionpayStatus; + this.aliPayUserStatus = aliPayUserStatus; + this.tenPayUserStatus = tenPayUserStatus; + this.weixinStatus = weixinStatus; + + this.icp = icp; + this.serviceQq = serviceQq; + this.serviceTel = serviceTel; + this.qqAppId = qqAppId; + this.qqAppKey = qqAppKey; + this.qqAppStatus = qqAppStatus; + this.messagePartner = messagePartner; + this.messageKey = messageKey; + this.messageChannel = messageChannel; + this.messageSign = messageSign; + this.regBalance = regBalance; + this.recMoney = recMoney; + this.recBalance = recBalance; + this.commission = commission; + this.invite = invite; + this.userData = userData; + this.buyProduct = buyProduct; + this.authorization = authorization; + this.alertMail = alertMail; + this.jsonAESKey = jsonAESKey; + this.versionType = versionType; + } + + /** default constructor */ + public SysConfigure() { + } + + /** full constructor */ + + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getImgUrl() { + return this.imgUrl; + } + + public void setImgUrl(String imgUrl) { + this.imgUrl = imgUrl; + } + + public String getSkinUrl() { + return this.skinUrl; + } + + public void setSkinUrl(String skinUrl) { + this.skinUrl = skinUrl; + } + + public String getWwwUrl() { + return this.wwwUrl; + } + + public void setWwwUrl(String wwwUrl) { + this.wwwUrl = wwwUrl; + } + + public String getGroupUrl() { + return groupUrl; + } + + public void setGroupUrl(String groupUrl) { + this.groupUrl = groupUrl; + } + + public String getUserUrl() { + return userUrl; + } + + public void setUserUrl(String userUrl) { + this.userUrl = userUrl; + } + + public String getFaceUrl() { + return faceUrl; + } + + public void setFaceUrl(String faceUrl) { + this.faceUrl = faceUrl; + } + + public String getPassportUrl() { + return passportUrl; + } + + public void setPassportUrl(String passportUrl) { + this.passportUrl = passportUrl; + } + + public String getApiUrl() { + return apiUrl; + } + + public void setApiUrl(String apiUrl) { + this.apiUrl = apiUrl; + } + + public String getDomain() { + return this.domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getSiteName() { + return this.siteName; + } + + public void setSiteName(String siteName) { + this.siteName = siteName; + } + + public String getSiteLogo() { + return this.siteLogo; + } + + public void setSiteLogo(String siteLogo) { + this.siteLogo = siteLogo; + } + + public String getKeyword() { + return this.keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getMailName() { + return this.mailName; + } + + public void setMailName(String mailName) { + this.mailName = mailName; + } + + public String getMailPwd() { + return this.mailPwd; + } + + public void setMailPwd(String mailPwd) { + this.mailPwd = mailPwd; + } + + public String getMailsmtp() { + return mailsmtp; + } + + public void setMailsmtp(String mailsmtp) { + this.mailsmtp = mailsmtp; + } + + public String getTenpayPartner() { + return this.tenpayPartner; + } + + public void setTenpayPartner(String tenpayPartner) { + this.tenpayPartner = tenpayPartner; + } + + public String getTenpayKey() { + return this.tenpayKey; + } + + public void setTenpayKey(String tenpayKey) { + this.tenpayKey = tenpayKey; + } + + public Integer getTenpayStatus() { + return this.tenpayStatus; + } + + public void setTenpayStatus(Integer tenpayStatus) { + this.tenpayStatus = tenpayStatus; + } + + public String getAlipayPartner() { + return this.alipayPartner; + } + + public void setAlipayPartner(String alipayPartner) { + this.alipayPartner = alipayPartner; + } + + public String getAlipayKey() { + return this.alipayKey; + } + + public void setAlipayKey(String alipayKey) { + this.alipayKey = alipayKey; + } + + public String getAlipayMail() { + return this.alipayMail; + } + + public void setAlipayMail(String alipayMail) { + this.alipayMail = alipayMail; + } + + public Integer getAlipayStatus() { + return this.alipayStatus; + } + + public void setAlipayStatus(Integer alipayStatus) { + this.alipayStatus = alipayStatus; + } + + public String getYeepayKey() { + return this.yeepayKey; + } + + public void setYeepayKey(String yeepayKey) { + this.yeepayKey = yeepayKey; + } + + public String getYeepayPartner() { + return this.yeepayPartner; + } + + public void setYeepayPartner(String yeepayPartner) { + this.yeepayPartner = yeepayPartner; + } + + public Integer getYeepayStatus() { + return this.yeepayStatus; + } + + public void setYeepayStatus(Integer yeepayStatus) { + this.yeepayStatus = yeepayStatus; + } + + public Integer getChinabankStatus() { + return chinabankStatus; + } + + public void setChinabankStatus(Integer chinabankStatus) { + this.chinabankStatus = chinabankStatus; + } + + public Integer getBillStatus() { + return billStatus; + } + + public void setBillStatus(Integer billStatus) { + this.billStatus = billStatus; + } + + public Integer getUnionpayStatus() { + return unionpayStatus; + } + + public void setUnionpayStatus(Integer unionpayStatus) { + this.unionpayStatus = unionpayStatus; + } + + public Integer getAliPayUserStatus() { + return aliPayUserStatus; + } + + public void setAliPayUserStatus(Integer aliPayUserStatus) { + this.aliPayUserStatus = aliPayUserStatus; + } + + public Integer getTenPayUserStatus() { + return tenPayUserStatus; + } + + public void setTenPayUserStatus(Integer tenPayUserStatus) { + this.tenPayUserStatus = tenPayUserStatus; + } + + public Integer getWeixinStatus() { + return weixinStatus; + } + + public void setWeixinStatus(Integer weixinStatus) { + this.weixinStatus = weixinStatus; + } + + public String getIcp() { + return this.icp; + } + + public void setIcp(String icp) { + this.icp = icp; + } + + public String getServiceQq() { + return this.serviceQq; + } + + public void setServiceQq(String serviceQq) { + this.serviceQq = serviceQq; + } + + public String getServiceTel() { + return this.serviceTel; + } + + public void setServiceTel(String serviceTel) { + this.serviceTel = serviceTel; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + + public String getSiteTitle() { + return siteTitle; + } + + public void setSiteTitle(String siteTitle) { + this.siteTitle = siteTitle; + } + + public String getQqAppId() { + return qqAppId; + } + + public void setQqAppId(String qqAppId) { + this.qqAppId = qqAppId; + } + + public String getQqAppKey() { + return qqAppKey; + } + + public void setQqAppKey(String qqAppKey) { + this.qqAppKey = qqAppKey; + } + + public Integer getQqAppStatus() { + return qqAppStatus; + } + + public void setQqAppStatus(Integer qqAppStatus) { + this.qqAppStatus = qqAppStatus; + } + + public String getMessagePartner() { + return messagePartner; + } + + public void setMessagePartner(String messagePartner) { + this.messagePartner = messagePartner; + } + + public String getMessageKey() { + return messageKey; + } + + public void setMessageKey(String messageKey) { + this.messageKey = messageKey; + } + + public String getMessageChannel() { + return messageChannel; + } + + public void setMessageChannel(String messageChannel) { + this.messageChannel = messageChannel; + } + + public String getMessageSign() { + return messageSign; + } + + public void setMessageSign(String messageSign) { + this.messageSign = messageSign; + } + + public Double getRegBalance() { + return regBalance; + } + + public void setRegBalance(Double regBalance) { + this.regBalance = regBalance; + } + + public Double getRecMoney() { + return recMoney; + } + + public void setRecMoney(Double recMoney) { + this.recMoney = recMoney; + } + + public Double getRecBalance() { + return recBalance; + } + + public void setRecBalance(Double recBalance) { + this.recBalance = recBalance; + } + + public Double getCommission() { + return commission; + } + + public void setCommission(Double commission) { + this.commission = commission; + } + + public Integer getInvite() { + return invite; + } + + public void setInvite(Integer invite) { + this.invite = invite; + } + + public Integer getUserData() { + return userData; + } + + public void setUserData(Integer userData) { + this.userData = userData; + } + + public Integer getBuyProduct() { + return buyProduct; + } + + public void setBuyProduct(Integer buyProduct) { + this.buyProduct = buyProduct; + } + + public String getAuthorization() { + return authorization; + } + + public void setAuthorization(String authorization) { + this.authorization = authorization; + } + + public String getAlertMail() { + return alertMail; + } + + public void setAlertMail(String alertMail) { + this.alertMail = alertMail; + } + + public Integer getVersionType() { + return versionType; + } + + public String getJsonAESKey() { + return jsonAESKey; + } + + public void setJsonAESKey(String jsonAESKey) { + this.jsonAESKey = jsonAESKey; + } + + public void setVersionType(Integer versionType) { + this.versionType = versionType; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/SysInfoBean.java b/src/main/java/me/mofun/pojo/SysInfoBean.java new file mode 100644 index 0000000..ada7911 --- /dev/null +++ b/src/main/java/me/mofun/pojo/SysInfoBean.java @@ -0,0 +1,122 @@ +package me.mofun.pojo; + +import java.io.Serializable; + +public class SysInfoBean implements Serializable { + + private static final long serialVersionUID = -408939127393554870L; + + public String siteName; + public String siteUrl; + public String keyword; + public String description; + public String mailName; + public String mailPwd; + public String icp; + public String tenpayPartner; //财付通商户号 + public String tenpayKey; //财付通商户密钥 + public String alipayPartner; //支付宝商户号 + public String alipayKey; //支付宝商户密钥 + public String alipayMail; //支付宝帐号 + public String domain; //域名域 (.ipdz.me) + public String skin; //CSS、JS 域名 + public String img; //图片域名 + public String getSiteName() { + return siteName; + } + public void setSiteName(String siteName) { + this.siteName = siteName; + } + public String getSiteUrl() { + return siteUrl; + } + public void setSiteUrl(String siteUrl) { + this.siteUrl = siteUrl; + } + public String getKeyword() { + return keyword; + } + public void setKeyword(String keyword) { + this.keyword = keyword; + } + public String getMailName() { + return mailName; + } + public void setMailName(String mailName) { + this.mailName = mailName; + } + public String getMailPwd() { + return mailPwd; + } + public void setMailPwd(String mailPwd) { + this.mailPwd = mailPwd; + } + public String getIcp() { + return icp; + } + public void setIcp(String icp) { + this.icp = icp; + } + public String getTenpayPartner() { + return tenpayPartner; + } + public void setTenpayPartner(String tenpayPartner) { + this.tenpayPartner = tenpayPartner; + } + public String getTenpayKey() { + return tenpayKey; + } + public void setTenpayKey(String tenpayKey) { + this.tenpayKey = tenpayKey; + } + public String getAlipayPartner() { + return alipayPartner; + } + public void setAlipayPartner(String alipayPartner) { + this.alipayPartner = alipayPartner; + } + public String getAlipayKey() { + return alipayKey; + } + public void setAlipayKey(String alipayKey) { + this.alipayKey = alipayKey; + } + public String getAlipayMail() { + return alipayMail; + } + public void setAlipayMail(String alipayMail) { + this.alipayMail = alipayMail; + } + public String getDomain() { + return domain; + } + public void setDomain(String domain) { + this.domain = domain; + } + public String getSkin() { + return skin; + } + public void setSkin(String skin) { + this.skin = skin; + } + public String getImg() { + return img; + } + public void setImg(String img) { + this.img = img; + } + public static long getSerialVersionUID() { + return serialVersionUID; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + + + + +} diff --git a/src/main/java/me/mofun/pojo/TalkGroup.hbm.xml b/src/main/java/me/mofun/pojo/TalkGroup.hbm.xml new file mode 100644 index 0000000..cc4a39b --- /dev/null +++ b/src/main/java/me/mofun/pojo/TalkGroup.hbm.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + Ȧ + + + + + ȦLogo + + + + + ʱ + + + + + ȦId,UserUserId + + + + + ȦLogo,дLogoַ + + + + + + + diff --git a/src/main/java/me/mofun/pojo/TalkGroup.java b/src/main/java/me/mofun/pojo/TalkGroup.java new file mode 100644 index 0000000..5b12d85 --- /dev/null +++ b/src/main/java/me/mofun/pojo/TalkGroup.java @@ -0,0 +1,76 @@ +package me.mofun.pojo; + +import java.sql.Timestamp; + +public class TalkGroup { + + private Integer groupId; + private String name; + private String logo; + private Timestamp createTime; + private Integer admin; + private String adminLogo; + private String memo; + + public TalkGroup() { + // TODO Auto-generated constructor stub + } + + public Integer getGroupId() { + return groupId; + } + + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLogo() { + return logo; + } + + public void setLogo(String logo) { + this.logo = logo; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public Integer getAdmin() { + return admin; + } + + public void setAdmin(Integer admin) { + this.admin = admin; + } + + public String getAdminLogo() { + return adminLogo; + } + + public void setAdminLogo(String adminLogo) { + this.adminLogo = adminLogo; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } + + +} diff --git a/src/main/java/me/mofun/pojo/TalkMsg.hbm.xml b/src/main/java/me/mofun/pojo/TalkMsg.hbm.xml new file mode 100644 index 0000000..5c0f737 --- /dev/null +++ b/src/main/java/me/mofun/pojo/TalkMsg.hbm.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + 圈子Id + + + + + 消息类型:1文本,2图像,3音频,4视频,5混合 + + + + + 作者Id/发表者Id,对应于user表的Id字段 + + + + + 0:表示群聊,非零表示1对1私聊,存被对话的用户OpenId + + + + + 发布时间 + + + + + 通用消息 + + + + + 文本内容,包含超链接类的文本内容 + + + + + 图片消息 + + + + + + + + + + + 信息状态:-1已删除、撤销一条消息,0待审核,1已审核通过 + + + + diff --git a/src/main/java/me/mofun/pojo/TalkMsg.java b/src/main/java/me/mofun/pojo/TalkMsg.java new file mode 100644 index 0000000..15055a0 --- /dev/null +++ b/src/main/java/me/mofun/pojo/TalkMsg.java @@ -0,0 +1,133 @@ +package me.mofun.pojo; + +import java.sql.Timestamp; + +/** + * News entity. + * + * @author MyEclipse Persistence Tools + */ + +public class TalkMsg implements java.io.Serializable { + + // Fields + + private Integer groupId; + private Integer msgType; + private String userId; + private String toUserId; + private Timestamp postDate; + private String content; + private String msgText; + private String msgImage; + private String msgAudio; + private String msgVideo; + private Integer status; + + // Constructors + + /** default constructor */ + public TalkMsg() { + } + + private Integer msgId; + public Integer getMsgId() { + return msgId; + } + + public void setMsgId(Integer msgId) { + this.msgId = msgId; + } + + public Integer getGroupId() { + return groupId; + } + + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + + public Integer getMsgType() { + return msgType; + } + + public void setMsgType(Integer msgType) { + this.msgType = msgType; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getToUserId() { + return toUserId; + } + + public void setToUserId(String toUserId) { + this.toUserId = toUserId; + } + + public Timestamp getPostDate() { + return postDate; + } + + public void setPostDate(Timestamp postDate) { + this.postDate = postDate; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getMsgText() { + return msgText; + } + + public void setMsgText(String msgText) { + this.msgText = msgText; + } + + public String getMsgImage() { + return msgImage; + } + + public void setMsgImage(String msgImage) { + this.msgImage = msgImage; + } + + public String getMsgAudio() { + return msgAudio; + } + + public void setMsgAudio(String msgAudio) { + this.msgAudio = msgAudio; + } + + public String getMsgVideo() { + return msgVideo; + } + + public void setMsgVideo(String msgVideo) { + this.msgVideo = msgVideo; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/TalkUser.hbm.xml b/src/main/java/me/mofun/pojo/TalkUser.hbm.xml new file mode 100644 index 0000000..e90a62d --- /dev/null +++ b/src/main/java/me/mofun/pojo/TalkUser.hbm.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + ΢ûdz + + + + + ΢ûOpenId + + + + + Ա1У2Ů + + + + + ûͷ + + + + + ʡ + + + + + + + + + + ʲôط + + + + + ʱ + + + + + IdӢĶŷָ + + + + diff --git a/src/main/java/me/mofun/pojo/TalkUser.java b/src/main/java/me/mofun/pojo/TalkUser.java new file mode 100644 index 0000000..54f885b --- /dev/null +++ b/src/main/java/me/mofun/pojo/TalkUser.java @@ -0,0 +1,169 @@ +package me.mofun.pojo; + +import java.sql.Timestamp; + +/** + * User entity. + * + * @author MyEclipse Persistence Tools + */ + +public class TalkUser implements java.io.Serializable { + + // Fields + private Integer id; + private String wxNick; + private String wxOpenId; + private Integer sex; + private String avatar; + private String province; + private String city; + private String address; + private Timestamp createTime; + private String groupId; + + /** default constructor */ + public TalkUser(){ + + } + public TalkUser(Integer id,String wxNick,String wxOpenId,Integer sex,String avatar,String province,String city,String address,Timestamp createTime,String groupId) { + super(); + this.id=id; + this.wxNick = wxNick; + this.wxOpenId = wxOpenId; + this.sex =sex; + this.avatar = avatar; + this.province = province; + this.city = city; + this.address = address; + this.createTime = createTime; + this.groupId = groupId; + } + + + public boolean isJoinGroup(String groupId) + { + // if(this.getGroupIdList()!=null&&this.getGroupIdList().indexOf(groupId+",")>=0) + return true; + // else + // return false; + } + + /** full constructor */ + + + // Property accessors + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + public String getWxNick() { + return wxNick; + } + + + public void setWxNick(String wxNick) { + this.wxNick = wxNick; + } + + + public String getWxOpenId() { + return wxOpenId; + } + + + public void setWxOpenId(String wxOpenId) { + this.wxOpenId = wxOpenId; + } + + + public Integer getSex() { + return sex; + } + + + public void setSex(Integer sex) { + this.sex = sex; + } + + + public String getAvatar() { + return avatar; + } + + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getProvince() { + return province; + } + + + public void setProvince(String province) { + this.province = province; + } + + + public String getCity() { + return city; + } + + + public void setCity(String city) { + this.city = city; + } + + + public String getAddress() { + return address; + } + + + public void setAddress(String address) { + this.address = address; + } + + + public Timestamp getCreateTime() { + return createTime; + } + + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + + public String getGroupId() { + return groupId; + } + + public String[] getGroupIdArray() { + if(groupId!=null&&(!groupId.trim().equals(""))) + return groupId.split(","); + else + return null; + } + + public boolean isGroupMember(String groupId) { + String [] groupIdArray = getGroupIdArray(); + for(String str:groupIdArray){ + if(str.equals(groupId)) + return true; + } + return false; + } + + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/User.hbm.xml b/src/main/java/me/mofun/pojo/User.hbm.xml new file mode 100644 index 0000000..1324a34 --- /dev/null +++ b/src/main/java/me/mofun/pojo/User.hbm.xml @@ -0,0 +1,233 @@ + + + + + + + + + + + + 用户名 + + + + + 密码 + + + + + 通过邮箱找回密码时 随机串 + + + + + 通过邮箱找回密码时 随机串生成时间.超过半小时点击无效. + + + + + 真实姓名 + + + + + 身份证号 + + + + + 移动电话 + + + + + 手机是否验证 0:未验证1:已验证 + + + + + 固定电话 + + + + + 所加入的群组Id列表,每个群组之间以英文逗号相隔 + + + + + + + + QQ互联登陆时获取的OpenId + + + + + + + + 邮箱是否已验证 0:未验证1:已验证 + + + + + + + 邮箱激活时的Key,memcache 关闭或失效时,带有时间信息加密key 存放在数据库中,便于用户激活。--add by lwgboy + + + + + 手机号验证时的Key,memcache 关闭或失效时,带有时间信息加密key 存放在数据库中,便于用户激活。--add by lwgboy + + + + + + 性别 0:男1:女 + + + + + 生日 年月日yyyyMMdd + + + + + 用户头像 + + + + + 地址 + + + + + 邮政编码 + + + + + ip地址 + + + + + ip归属地 + + + + + 上次登录IP所在地 + + + + + 婚姻状况 0:未婚1:已婚2:离异 + + + + + 月收入 + + + + + 兴趣爱好 + + + + + + + + 上次登录时间 + + + + + 本次登录时间 + + + + + 余额 + + + + + 用户类型,0为普通用户.1为系统管理员;普通用户不能登录后台.系统管理员可以登陆后台;2:企业雇员,一般由企业创始人作为雇员添加进来,此时shopId和creatorId也将被填充值 + + + + + 经验值 + + + + + 个性签名 + + + + + 邀请人 + + + + + 邀请短网址:邀请其他人访问网站的短链接,暂用sina的短链接,获取后存储在数据库中加快获取短链接时的速度 + + + + + 佣金 + + + + + 佣金余额 + + + + + 佣金提现 + + + + + 福分 + + + + + 所属shopId,该值不为空说明是机构雇员;一般用于企业创始人添加雇员时,此时会记录该用户是属于哪个企业的雇员 + + + + + 创用户建者UserId,一般用于企业创始人添加企业雇员时,记录由谁创建的该用户。 + + + + + 岗位标签,每个岗位之间用英文逗号分隔 + + + + + diff --git a/src/main/java/me/mofun/pojo/User.java b/src/main/java/me/mofun/pojo/User.java new file mode 100644 index 0000000..de2a3c0 --- /dev/null +++ b/src/main/java/me/mofun/pojo/User.java @@ -0,0 +1,492 @@ +package me.mofun.pojo; + +/** + * User entity. + * + * @author MyEclipse Persistence Tools + */ + +public class User implements java.io.Serializable { + + // Fields + + private Integer userId; + private String userName; + private String userPwd; + private String changePwdNo; + private String changePwdTime; + private String realName; + private String cardNo; + private String mobilePhone; + private String mobileCheck; + private String phone; + private String groupIdList; + private String qq; + private String qqOpenId; + private String mail; + private String mailCheck; + private String mailKey; + private Integer smsKey; + private String sex; + private String birthday; + private String faceImg; + private String location; + private String postNo; + private String ipAddress; + private String ipLocation; + private String oldIpAddress; + private String maritalStatus; + private String monthlyIncome; + private String interests; + private String attribute22; + private String oldDate; + private String newDate; + private Double balance; + private String userType; + private Integer experience; + private String signature; + private Integer invite; + private String inviteShortURL; + private Double commissionCount; + private Double commissionBalance; + private Double commissionMention; + private Integer commissionPoints; + private Integer shopId; + private Integer creatorId; + private String jobTags; + + + public User(Integer userId, String userName, String userPwd, + String changePwdNo, String changePwdTime, String realName, + String cardNo, String mobilePhone, String mobileCheck, + String phone, String groupIdList, String qq, String qqOpenId,String mail, String mailCheck, String mailKey, Integer smsKey,String sex, + String birthday, String faceImg, String location, String postNo, + String ipAddress, String ipLocation, String oldIpAddress, + String maritalStatus, String monthlyIncome, String interests, + String attribute22, String oldDate, String newDate, Double balance, + String userType, Integer experience, String signature, + Integer invite, Double commissionCount, Double commissionBalance, + Double commissionMention, Integer commissionPoints, + Integer shopId,Integer creatorId,String jobTags + ) { + super(); + this.userId = userId; + this.userName = userName; + this.userPwd = userPwd; + this.changePwdNo = changePwdNo; + this.changePwdTime = changePwdTime; + this.realName = realName; + this.cardNo = cardNo; + this.mobilePhone = mobilePhone; + this.mobileCheck = mobileCheck; + this.phone = phone; + this.groupIdList = groupIdList; + this.qq = qq; + this.qqOpenId = qqOpenId; + this.mail = mail; + this.mailCheck = mailCheck; + this.mailKey = mailKey; + this.sex = sex; + this.birthday = birthday; + this.faceImg = faceImg; + this.location = location; + this.postNo = postNo; + this.ipAddress = ipAddress; + this.ipLocation = ipLocation; + this.oldIpAddress = oldIpAddress; + this.maritalStatus = maritalStatus; + this.monthlyIncome = monthlyIncome; + this.interests = interests; + this.attribute22 = attribute22; + this.oldDate = oldDate; + this.newDate = newDate; + this.balance = balance; + this.userType = userType; + this.experience = experience; + this.signature = signature; + this.invite = invite; + this.commissionCount = commissionCount; + this.commissionBalance = commissionBalance; + this.commissionMention = commissionMention; + this.commissionPoints = commissionPoints; + this.shopId = shopId; + this.creatorId = creatorId; + this.jobTags = jobTags; + } + + /** default constructor */ + public User() { + } + + /** minimal constructor */ + public User(String userPwd, String userType) { + this.userPwd = userPwd; + this.userType = userType; + } + + public boolean isJoinGroup(String groupId) + { + if(this.getGroupIdList()!=null&&this.getGroupIdList().indexOf(groupId+",")>=0) + return true; + else + return false; + } + + /** full constructor */ + + + // Property accessors + + public Integer getUserId() { + return this.userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getUserName() { + return this.userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPwd() { + return this.userPwd; + } + + public void setUserPwd(String userPwd) { + this.userPwd = userPwd; + } + + public String getChangePwdNo() { + return this.changePwdNo; + } + + public void setChangePwdNo(String changePwdNo) { + this.changePwdNo = changePwdNo; + } + + public String getChangePwdTime() { + return this.changePwdTime; + } + + public void setChangePwdTime(String changePwdTime) { + this.changePwdTime = changePwdTime; + } + + public String getRealName() { + return this.realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public String getCardNo() { + return this.cardNo; + } + + public void setCardNo(String cardNo) { + this.cardNo = cardNo; + } + + public String getMobilePhone() { + return this.mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getMobileCheck() { + return this.mobileCheck; + } + + public void setMobileCheck(String mobileCheck) { + this.mobileCheck = mobileCheck; + } + + public String getPhone() { + return this.phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getGroupIdList() { + return groupIdList; + } + + public void setGroupIdList(String groupIdList) { + this.groupIdList = groupIdList; + } + + public String getQq() { + return this.qq; + } + + public void setQq(String qq) { + this.qq = qq; + } + + public String getQqOpenId() { + return qqOpenId; + } + + public void setQqOpenId(String qqOpenId) { + this.qqOpenId = qqOpenId; + } + + public String getMail() { + return this.mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + + public String getMailCheck() { + return this.mailCheck; + } + + public void setMailCheck(String mailCheck) { + this.mailCheck = mailCheck; + } + + public String getMailKey() { + return this.mailKey; + } + + public void setMailKey(String mailKey) { + this.mailKey = mailKey; + } + + public Integer getSmsKey() { + return this.smsKey; + } + + public void setSmsKey(Integer smsKey) { + this.smsKey = smsKey; + } + + public String getSex() { + return this.sex; + } + + public void setSex(String sex) { + this.sex = sex; + } + + public String getBirthday() { + return this.birthday; + } + + public void setBirthday(String birthday) { + this.birthday = birthday; + } + + public String getFaceImg() { + return this.faceImg; + } + + public void setFaceImg(String faceImg) { + this.faceImg = faceImg; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getPostNo() { + return this.postNo; + } + + public void setPostNo(String postNo) { + this.postNo = postNo; + } + + public String getIpAddress() { + return this.ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public String getIpLocation() { + return this.ipLocation; + } + + public void setIpLocation(String ipLocation) { + this.ipLocation = ipLocation; + } + + public String getMaritalStatus() { + return this.maritalStatus; + } + + public void setMaritalStatus(String maritalStatus) { + this.maritalStatus = maritalStatus; + } + + public String getMonthlyIncome() { + return this.monthlyIncome; + } + + public void setMonthlyIncome(String monthlyIncome) { + this.monthlyIncome = monthlyIncome; + } + + public String getInterests() { + return this.interests; + } + + public void setInterests(String interests) { + this.interests = interests; + } + + public String getAttribute22() { + return this.attribute22; + } + + public void setAttribute22(String attribute22) { + this.attribute22 = attribute22; + } + + public String getOldDate() { + return this.oldDate; + } + + public void setOldDate(String oldDate) { + this.oldDate = oldDate; + } + + public String getNewDate() { + return this.newDate; + } + + public void setNewDate(String newDate) { + this.newDate = newDate; + } + + public Double getBalance() { + return this.balance; + } + + public void setBalance(Double balance) { + this.balance = balance; + } + + public String getUserType() { + return this.userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + public Integer getExperience() { + return this.experience; + } + + public void setExperience(Integer experience) { + this.experience = experience; + } + + public String getSignature() { + return this.signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public Integer getInvite() { + return this.invite; + } + + public void setInvite(Integer invite) { + this.invite = invite; + } + + public String getInviteShortURL() { + return inviteShortURL; + } + + public void setInviteShortURL(String inviteShortURL) { + this.inviteShortURL = inviteShortURL; + } + + public Double getCommissionCount() { + return commissionCount; + } + + public void setCommissionCount(Double commissionCount) { + this.commissionCount = commissionCount; + } + + public Double getCommissionBalance() { + return commissionBalance; + } + + public void setCommissionBalance(Double commissionBalance) { + this.commissionBalance = commissionBalance; + } + + public Double getCommissionMention() { + return commissionMention; + } + + public void setCommissionMention(Double commissionMention) { + this.commissionMention = commissionMention; + } + + public Integer getCommissionPoints() { + return commissionPoints; + } + + public void setCommissionPoints(Integer commissionPoints) { + this.commissionPoints = commissionPoints; + } + + public String getOldIpAddress() { + return oldIpAddress; + } + + public void setOldIpAddress(String oldIpAddress) { + this.oldIpAddress = oldIpAddress; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getCreatorId() { + return creatorId; + } + + public void setCreatorId(Integer creatorId) { + this.creatorId = creatorId; + } + + public String getJobTags() { + return jobTags; + } + + public void setJobTags(String jobTags) { + this.jobTags = jobTags; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/UserBuy.java b/src/main/java/me/mofun/pojo/UserBuy.java new file mode 100644 index 0000000..a7a319f --- /dev/null +++ b/src/main/java/me/mofun/pojo/UserBuy.java @@ -0,0 +1,52 @@ +package me.mofun.pojo; + +public class UserBuy { + + String String1; + String String2; + + + /** + * @param buyDate + * @param userName + */ + + public UserBuy() { + } + + + /** + * @param string1 + * @param string2 + */ + public UserBuy(String string1, String string2) { + super(); + String1 = string1; + String2 = string2; + } + + + public String getString1() { + return String1; + } + + + public void setString1(String string1) { + String1 = string1; + } + + + public String getString2() { + return String2; + } + + + public void setString2(String string2) { + String2 = string2; + } + + + + + +} diff --git a/src/main/java/me/mofun/pojo/UserJSON.java b/src/main/java/me/mofun/pojo/UserJSON.java new file mode 100644 index 0000000..953db52 --- /dev/null +++ b/src/main/java/me/mofun/pojo/UserJSON.java @@ -0,0 +1,73 @@ +package me.mofun.pojo; + +public class UserJSON { + + private String userId; + private String userName; + private String userFace; + private int userExperience; + private double userBalance; + private int userLevel; + private String userLevelName; + + + public UserJSON(String userId, String userName, String userFace, + int userExperience, double userBalance, int userLevel, + String userLevelName) { + super(); + this.userId = userId; + this.userName = userName; + this.userFace = userFace; + this.userExperience = userExperience; + this.userBalance = userBalance; + this.userLevel = userLevel; + this.userLevelName = userLevelName; + } + public UserJSON() { + super(); + } + public String getUserId() { + return userId; + } + public void setUserId(String userId) { + this.userId = userId; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getUserFace() { + return userFace; + } + public void setUserFace(String userFace) { + this.userFace = userFace; + } + + public int getUserExperience() { + return userExperience; + } + public void setUserExperience(int userExperience) { + this.userExperience = userExperience; + } + public double getUserBalance() { + return userBalance; + } + public void setUserBalance(double userBalance) { + this.userBalance = userBalance; + } + public int getUserLevel() { + return userLevel; + } + public void setUserLevel(int userLevel) { + this.userLevel = userLevel; + } + public String getUserLevelName() { + return userLevelName; + } + public void setUserLevelName(String userLevelName) { + this.userLevelName = userLevelName; + } + +} diff --git a/src/main/java/me/mofun/pojo/UserLimitBuy.java b/src/main/java/me/mofun/pojo/UserLimitBuy.java new file mode 100644 index 0000000..467e535 --- /dev/null +++ b/src/main/java/me/mofun/pojo/UserLimitBuy.java @@ -0,0 +1,84 @@ +package me.mofun.pojo; + +/** + * 用于用户限购检查时,返回 json 对象 {"code":0,"codeLimitBuy":5,"buyNum":0,"codeState":0,"codeRemainNum":240,"userMoney":0.0} + * @author mofun + * + */ +public class UserLimitBuy { + + + private int code; //代码 + private int codeLimitBuy; //限购次数: 0表示不限购,其他表示限购次数 + private int buyNum; //某登陆用户已经购买的次数 + private int codeState; //产品购买状态 + private int codeRemainNum; //总剩余购买次数 + private float userMoney; //某登陆用户的余额 + + + public UserLimitBuy() { + // TODO Auto-generated constructor stub + } + + public Integer getCode() { + return code; + } + + + public void setCode(Integer code) { + this.code = code; + } + + + public Integer getCodeLimitBuy() { + return codeLimitBuy; + } + + + public void setCodeLimitBuy(Integer codeLimitBuy) { + this.codeLimitBuy = codeLimitBuy; + } + + + public Integer getBuyNum() { + return buyNum; + } + + + public void setBuyNum(Integer buyNum) { + this.buyNum = buyNum; + } + + + public Integer getCodeState() { + return codeState; + } + + + public void setCodeState(Integer codeState) { + this.codeState = codeState; + } + + + public Integer getCodeRemainNum() { + return codeRemainNum; + } + + + public void setCodeRemainNum(Integer codeRemainNum) { + this.codeRemainNum = codeRemainNum; + } + + + public float getUserMoney() { + return userMoney; + } + + + public void setUserMoney(float userMoney) { + this.userMoney = userMoney; + } + + + +} diff --git a/src/main/java/me/mofun/pojo/UserReduce.java b/src/main/java/me/mofun/pojo/UserReduce.java new file mode 100644 index 0000000..74bdd62 --- /dev/null +++ b/src/main/java/me/mofun/pojo/UserReduce.java @@ -0,0 +1,40 @@ +package me.mofun.pojo; + +/** + * User entity. + * + * @author MyEclipse Persistence Tools + */ + +//简化版用户类,用于安全的返回用户信息(不包含密码等隐私信息)给前端页面: +public class UserReduce extends User { + + private int floor; + + + public int getFloor() { + return floor; + } + + + public void setFloor(int floor) { + this.floor = floor; + } + + + public String getUserPwd(){ + return ""; + } + + /** + * 将 User 转化为简化版的 UserReduce + * @param user + */ + public void toUserReduce(User user){ + this.setUserId(user.getUserId()); + this.setUserName(user.getUserName()); + this.setUserType(user.getUserType()); + this.setFaceImg(user.getFaceImg()); + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Userbyaddress.hbm.xml b/src/main/java/me/mofun/pojo/Userbyaddress.hbm.xml new file mode 100644 index 0000000..acb45bc --- /dev/null +++ b/src/main/java/me/mofun/pojo/Userbyaddress.hbm.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 收货地址 + + + + + 邮政编码 + + + + + 收货人 + + + + + 电话号码 + + + + + 状态 是否默认 + + + + diff --git a/src/main/java/me/mofun/pojo/Userbyaddress.java b/src/main/java/me/mofun/pojo/Userbyaddress.java new file mode 100644 index 0000000..72fb334 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Userbyaddress.java @@ -0,0 +1,124 @@ +package me.mofun.pojo; + +/** + * Userbyaddress entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Userbyaddress implements java.io.Serializable { + + // Fields + + private Integer id; + private Integer userId; + private String province; + private String city; + private String district; + private String address; + private Integer zipCode; + private String consignee; + private String phone; + private Integer status = 1; + + + /** + * + */ + public Userbyaddress() { + super(); + } + /** + * @param id + * @param userId + * @param province + * @param city + * @param district + * @param address + * @param zipCode + * @param consignee + * @param phone + * @param status + */ + public Userbyaddress(Integer id, Integer userId, String province, + String city, String district, String address, Integer zipCode, + String consignee, String phone, Integer status) { + super(); + this.id = id; + this.userId = userId; + this.province = province; + this.city = city; + this.district = district; + this.address = address; + this.zipCode = zipCode; + this.consignee = consignee; + this.phone = phone; + this.status = status; + } + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public Integer getUserId() { + return userId; + } + public void setUserId(Integer userId) { + this.userId = userId; + } + public String getProvince() { + return province; + } + public void setProvince(String province) { + this.province = province; + } + public String getCity() { + return city; + } + public void setCity(String city) { + this.city = city; + } + public String getDistrict() { + return district; + } + public void setDistrict(String district) { + this.district = district; + } + public String getAddress() { + return address; + } + public void setAddress(String address) { + this.address = address; + } + public Integer getZipCode() { + return zipCode; + } + public void setZipCode(Integer zipCode) { + this.zipCode = zipCode; + } + public String getConsignee() { + return consignee; + } + public void setConsignee(String consignee) { + this.consignee = consignee; + } + public String getPhone() { + return phone; + } + public void setPhone(String phone) { + this.phone = phone; + } + public Integer getStatus() { + return status; + } + public void setStatus(Integer status) { + this.status = status; + } + + + + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/Visitors.hbm.xml b/src/main/java/me/mofun/pojo/Visitors.hbm.xml new file mode 100644 index 0000000..96a69d1 --- /dev/null +++ b/src/main/java/me/mofun/pojo/Visitors.hbm.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + 时间 + + + + + 地点 + + + + diff --git a/src/main/java/me/mofun/pojo/Visitors.java b/src/main/java/me/mofun/pojo/Visitors.java new file mode 100644 index 0000000..6cd818e --- /dev/null +++ b/src/main/java/me/mofun/pojo/Visitors.java @@ -0,0 +1,80 @@ +package me.mofun.pojo; + +/** + * Visitors entity. + * + * @author MyEclipse Persistence Tools + */ + +public class Visitors implements java.io.Serializable { + + // Fields + + private Integer id; + private Integer uid; + private Integer visitorsId; + private String date; + private String address; + + // Constructors + + /** default constructor */ + public Visitors() { + } + + + public Visitors(Integer id, Integer uid, Integer visitorsId, String date, + String address) { + super(); + this.id = id; + this.uid = uid; + this.visitorsId = visitorsId; + this.date = date; + this.address = address; + } + + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUid() { + return uid; + } + + public void setUid(Integer uid) { + this.uid = uid; + } + + public Integer getVisitorsId() { + return visitorsId; + } + + public void setVisitorsId(Integer visitorsId) { + this.visitorsId = visitorsId; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/vo/CommentTreeVo.java b/src/main/java/me/mofun/pojo/vo/CommentTreeVo.java new file mode 100644 index 0000000..8471664 --- /dev/null +++ b/src/main/java/me/mofun/pojo/vo/CommentTreeVo.java @@ -0,0 +1,78 @@ +package me.mofun.pojo.vo; + +import me.mofun.pojo.NewsReply; +import me.mofun.pojo.User; +import me.mofun.pojo.UserReduce; + +import java.io.Serializable; +import java.util.List; + +public class CommentTreeVo implements Serializable{ + + + private int topicId; //评论所属文章或话题的Id + private String type; //类型,保留字段 + private int level; //层级,第几层对话; + + private User user; + private UserReduce toUser; //对话目标用户信息 + private NewsReply reply; + private List children; + + public CommentTreeVo(){ + + } + public CommentTreeVo(int topicId, String type) { + this.topicId = topicId; + this.type = type; + } + + public int getTopicId() { + return topicId; + } + public void setTopicId(int topicId) { + this.topicId = topicId; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + public int getLevel() { + return level; + } + public void setLevel(int level) { + this.level = level; + } + + public UserReduce getToUser() { + return toUser; + } + public void setToUser(UserReduce toUser) { + this.toUser = toUser; + } + + public User getUser() { + return user; + } + public void setUser(User user) { + this.user = user; + } + public NewsReply getReply() { + return reply; + } + public void setReply(NewsReply reply) { + this.reply = reply; + } + public List getChildren() { + return children; + } + public void setChildren(List children) { + this.children = children; + } + + + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/vo/Reply.java b/src/main/java/me/mofun/pojo/vo/Reply.java new file mode 100644 index 0000000..5fe9719 --- /dev/null +++ b/src/main/java/me/mofun/pojo/vo/Reply.java @@ -0,0 +1,17 @@ +package me.mofun.pojo.vo; + +import net.sf.json.JSONArray; + +public class Reply { + + public Reply() { + // TODO Auto-generated constructor stub + } + + public void test() { + JSONArray array = new JSONArray(); + + + } + +} diff --git a/src/main/java/me/mofun/pojo/vo/ResultObj.java b/src/main/java/me/mofun/pojo/vo/ResultObj.java new file mode 100644 index 0000000..21940eb --- /dev/null +++ b/src/main/java/me/mofun/pojo/vo/ResultObj.java @@ -0,0 +1,37 @@ +package me.mofun.pojo.vo; + +public class ResultObj { + + private boolean canNext; //是否可以继续 + private Integer code; //返回码 + private String msg; //返回消息 + + public ResultObj() { + // TODO Auto-generated constructor stub + } + + public boolean isCanNext() { + return canNext; + } + + public void setCanNext(boolean canNext) { + this.canNext = canNext; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + +} diff --git a/src/main/java/me/mofun/pojo/vo/SpellbuyrecordExt.java b/src/main/java/me/mofun/pojo/vo/SpellbuyrecordExt.java new file mode 100644 index 0000000..16ed35d --- /dev/null +++ b/src/main/java/me/mofun/pojo/vo/SpellbuyrecordExt.java @@ -0,0 +1,45 @@ +package me.mofun.pojo.vo; + +import me.mofun.pojo.Spellbuyrecord; + +/** + * 通过继承的方法来扩展父类字段,用于 Hibernate 自定义查询后直接转换为非与数据库表一一对应对象,取关联查询中的个别字段组成新对象。 + * 应用于 SpellbuyrecordServiceImpl.java 的 getUserByHistory 方法: * + * @author mofun + * + */ +public class SpellbuyrecordExt extends Spellbuyrecord{ + + private float spSinglePrice; //单价 + private String Attribute_66; + private String Attribute_67; + + public void setSpSinglePrice(float spSinglePrice) { + this.spSinglePrice = spSinglePrice; + } + + public float getSpSinglePrice() { + return spSinglePrice; + } + + public void seSpSinglePrice(float spSinglePrice) { + this.spSinglePrice = spSinglePrice; + } + + public String getAttribute_66() { + return Attribute_66; + } + + public void setAttribute_66(String attribute_66) { + Attribute_66 = attribute_66; + } + + public String getAttribute_67() { + return Attribute_67; + } + + public void setAttribute_67(String attribute_67) { + Attribute_67 = attribute_67; + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/weixin/Button.java b/src/main/java/me/mofun/pojo/weixin/Button.java new file mode 100644 index 0000000..f669810 --- /dev/null +++ b/src/main/java/me/mofun/pojo/weixin/Button.java @@ -0,0 +1,13 @@ +package me.mofun.pojo.weixin; + +public class Button { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/me/mofun/pojo/weixin/CommandButton.java b/src/main/java/me/mofun/pojo/weixin/CommandButton.java new file mode 100644 index 0000000..55826db --- /dev/null +++ b/src/main/java/me/mofun/pojo/weixin/CommandButton.java @@ -0,0 +1,22 @@ +package me.mofun.pojo.weixin; + +public class CommandButton extends Button { + private String type; + private String key; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } +} diff --git a/src/main/java/me/mofun/pojo/weixin/ComplexButton.java b/src/main/java/me/mofun/pojo/weixin/ComplexButton.java new file mode 100644 index 0000000..1788866 --- /dev/null +++ b/src/main/java/me/mofun/pojo/weixin/ComplexButton.java @@ -0,0 +1,18 @@ +package me.mofun.pojo.weixin; + +/** + * http://www.2cto.com/weixin/201408/324645.html + * @author mofun + * + */ +public class ComplexButton extends Button { + private Button[] sub_button; + + public Button[] getSub_button() { + return sub_button; + } + + public void setSub_button(Button[] sub_button) { + this.sub_button = sub_button; + } +} \ No newline at end of file diff --git a/src/main/java/me/mofun/pojo/weixin/Menu.java b/src/main/java/me/mofun/pojo/weixin/Menu.java new file mode 100644 index 0000000..e5d168b --- /dev/null +++ b/src/main/java/me/mofun/pojo/weixin/Menu.java @@ -0,0 +1,18 @@ +package me.mofun.pojo.weixin; + +/** + * http://www.2cto.com/weixin/201408/324645.html + * @author mofun + * + */ +public class Menu { + private Button[] button; + + public Button[] getButton() { + return button; + } + + public void setButton(Button[] button) { + this.button = button; + } +} diff --git a/src/main/java/me/mofun/pojo/weixin/WeiXinAccessToken.java b/src/main/java/me/mofun/pojo/weixin/WeiXinAccessToken.java new file mode 100644 index 0000000..71300fa --- /dev/null +++ b/src/main/java/me/mofun/pojo/weixin/WeiXinAccessToken.java @@ -0,0 +1,102 @@ +package me.mofun.pojo.weixin; + +/** + * http://www.2cto.com/weixin/201408/324645.html + * @author mofun + * + */ +public class WeiXinAccessToken { + + private String appId; + + // 获取到的凭证 + private String token; + + // 凭证有效时间,单位:秒 + private int expiresIn; + + //最近一次存取凭证的时间,Timestamp + private Long tokenTimestamp; + + private String nonceStr; + private String signature; + private Long signatureTimestamp; //每次签名的时间 + + private Integer errcode; + private String errmsg; + + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public int getExpiresIn() { + return expiresIn; + } + + public void setExpiresIn(int expiresIn) { + this.expiresIn = expiresIn; + } + + + + public String getNonceStr() { + return nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public Long getTokenTimestamp() { + return tokenTimestamp; + } + + public void setTokenTimestamp(Long tokenTimestamp) { + this.tokenTimestamp = tokenTimestamp; + } + + public Long getSignatureTimestamp() { + return signatureTimestamp; + } + + public void setSignatureTimestamp(Long signatureTimestamp) { + this.signatureTimestamp = signatureTimestamp; + } + + public Integer getErrcode() { + return errcode; + } + + public void setErrcode(Integer errcode) { + this.errcode = errcode; + } + + public String getErrmsg() { + return errmsg; + } + + public void setErrmsg(String errmsg) { + this.errmsg = errmsg; + } +} diff --git a/src/main/java/me/mofun/pojo/weixin/WeiXinOAuth2AccessToken.java b/src/main/java/me/mofun/pojo/weixin/WeiXinOAuth2AccessToken.java new file mode 100644 index 0000000..b519ff0 --- /dev/null +++ b/src/main/java/me/mofun/pojo/weixin/WeiXinOAuth2AccessToken.java @@ -0,0 +1,140 @@ +package me.mofun.pojo.weixin; + +/** + * http://www.2cto.com/weixin/201408/324645.html + * @author mofun + * + */ +public class WeiXinOAuth2AccessToken { + + private String appId; + + // 获取到的凭证 + private String accessToken; + + // 凭证有效时间,单位:秒 + private int expiresIn; + + + private String refreshToken; + private String openId; + private String scope; + private String unionid; + + //凭证创建的时间,Timestamp + private Long tokenTimestamp; + + private String nonceStr; + private String signature; + private Long signatureTimestamp; //每次签名的时间 + + private Integer errcode; + private String errmsg; + + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public String getRefreshToken() { + return refreshToken; + } + + public void setRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; + } + + public String getOpenId() { + return openId; + } + + public void setOpenId(String openId) { + this.openId = openId; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getUnionid() { + return unionid; + } + + public void setUnionid(String unionid) { + this.unionid = unionid; + } + + public int getExpiresIn() { + return expiresIn; + } + + public void setExpiresIn(int expiresIn) { + this.expiresIn = expiresIn; + } + + + + public String getNonceStr() { + return nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public Long getTokenTimestamp() { + return tokenTimestamp; + } + + public void setTokenTimestamp(Long tokenTimestamp) { + this.tokenTimestamp = tokenTimestamp; + } + + public Long getSignatureTimestamp() { + return signatureTimestamp; + } + + public void setSignatureTimestamp(Long signatureTimestamp) { + this.signatureTimestamp = signatureTimestamp; + } + + public Integer getErrcode() { + return errcode; + } + + public void setErrcode(Integer errcode) { + this.errcode = errcode; + } + + public String getErrmsg() { + return errmsg; + } + + public void setErrmsg(String errmsg) { + this.errmsg = errmsg; + } +} diff --git a/src/main/java/me/mofun/pojo/weixin/WeiXinOAuth2UserInfo.java b/src/main/java/me/mofun/pojo/weixin/WeiXinOAuth2UserInfo.java new file mode 100644 index 0000000..1b4c4ef --- /dev/null +++ b/src/main/java/me/mofun/pojo/weixin/WeiXinOAuth2UserInfo.java @@ -0,0 +1,80 @@ +package me.mofun.pojo.weixin; + +public class WeiXinOAuth2UserInfo { + + private String openid; + private String nickname; + private Integer sex; + private String province; + private String city; + private String country; + private String headimgurl; + private String [] privilege; + private String unionid; + + private WeiXinOAuth2AccessToken accessToken; + + + public String getOpenid() { + return openid; + } + public void setOpenid(String openid) { + this.openid = openid; + } + public String getNickname() { + return nickname; + } + public void setNickname(String nickname) { + this.nickname = nickname; + } + public Integer getSex() { + return sex; + } + public void setSex(Integer sex) { + this.sex = sex; + } + public String getProvince() { + return province; + } + public void setProvince(String province) { + this.province = province; + } + public String getCity() { + return city; + } + public void setCity(String city) { + this.city = city; + } + public String getCountry() { + return country; + } + public void setCountry(String country) { + this.country = country; + } + public String getHeadimgurl() { + return headimgurl; + } + public void setHeadimgurl(String headimgurl) { + this.headimgurl = headimgurl; + } + public String[] getPrivilege() { + return privilege; + } + public void setPrivilege(String[] privilege) { + this.privilege = privilege; + } + public String getUnionid() { + return unionid; + } + public void setUnionid(String unionid) { + this.unionid = unionid; + } + + public WeiXinOAuth2AccessToken getAccessToken() { + return accessToken; + } + public void setAccessToken(WeiXinOAuth2AccessToken accessToken) { + this.accessToken = accessToken; + } + +} diff --git a/src/main/java/me/mofun/service/ApplymentionService.java b/src/main/java/me/mofun/service/ApplymentionService.java new file mode 100644 index 0000000..4f4e228 --- /dev/null +++ b/src/main/java/me/mofun/service/ApplymentionService.java @@ -0,0 +1,29 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Applymention; + +public interface ApplymentionService extends TService { + + + /** + * 提现记录 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getApplymentionList(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 提现记录 ByCount + * @param userId + * @param startDate + * @param endDate + * @return + */ + public Integer getApplymentionListByCount(String userId,String startDate,String endDate); + +} diff --git a/src/main/java/me/mofun/service/CardpasswordService.java b/src/main/java/me/mofun/service/CardpasswordService.java new file mode 100644 index 0000000..50de38c --- /dev/null +++ b/src/main/java/me/mofun/service/CardpasswordService.java @@ -0,0 +1,19 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Cardpassword; + +public interface CardpasswordService extends TService { + + /** + * 卡密充值 + * @param id + * @return + */ + public Cardpassword doCardRecharge(String randomNo,String cardPwd); + + public Pagination cardRechargeList(int pageNo,int pageSize); + + public void deleteByID(Integer id); + +} diff --git a/src/main/java/me/mofun/service/CommissionpointsService.java b/src/main/java/me/mofun/service/CommissionpointsService.java new file mode 100644 index 0000000..6cc68ce --- /dev/null +++ b/src/main/java/me/mofun/service/CommissionpointsService.java @@ -0,0 +1,25 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Commissionpoints; + +public interface CommissionpointsService extends TService{ + + /** + * 福分明细 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination CommissionPoints(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 佣金明细 ByCount + * @param userId + * @return + */ + public Integer getCommissionPointsListByCount(String userId,String startDate,String endDate); + + +} diff --git a/src/main/java/me/mofun/service/CommissionqueryService.java b/src/main/java/me/mofun/service/CommissionqueryService.java new file mode 100644 index 0000000..67fdb3a --- /dev/null +++ b/src/main/java/me/mofun/service/CommissionqueryService.java @@ -0,0 +1,33 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Commissionquery; + +import java.util.List; + +public interface CommissionqueryService extends TService{ + + /** + * 佣金明细 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getCommissionQueryList(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 佣金明细 ByCount + * @param userId + * @return + */ + public Integer getCommissionQueryListByCount(String userId,String startDate,String endDate); + + /** + * 佣金明细 ByData + * @param userId + * @return + */ + public List getCommissionQueryListByData(String userId); + +} diff --git a/src/main/java/me/mofun/service/ConsumerdetailService.java b/src/main/java/me/mofun/service/ConsumerdetailService.java new file mode 100644 index 0000000..4b2bd94 --- /dev/null +++ b/src/main/java/me/mofun/service/ConsumerdetailService.java @@ -0,0 +1,39 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Consumerdetail; + +public interface ConsumerdetailService extends TService { + + /** + * 消费记录-查看详情 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination userByConsumetableDetail(String id,int pageNo,int pageSize); + + /** + * 消费记录-查看详情ByCount + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Integer userByConsumetableDetailByCount(String id); + + /** + * 订单详情 + * @param userKey + * @param pageNo + * @param pageSize + * @return + */ + public Pagination orderInfo(String id,int pageNo, int pageSize); + +} diff --git a/src/main/java/me/mofun/service/ConsumetableService.java b/src/main/java/me/mofun/service/ConsumetableService.java new file mode 100644 index 0000000..b731f10 --- /dev/null +++ b/src/main/java/me/mofun/service/ConsumetableService.java @@ -0,0 +1,73 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Consumetable; + +public interface ConsumetableService extends TService { + + public Consumetable findByOutTradeNo(String id); + + /** + * 冲值记录 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination userByConsumetableByDelta(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 冲值记录ByCount + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Integer userByConsumetableByDeltaByCount(String userId,String startDate,String endDate); + + + /** + * 消费记录 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination userByConsumetable(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 消费记录ByCount + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Integer userByConsumetableByCount(String userId,String startDate,String endDate); + + /** + * 订单列表 + * @param userKey + * @param pageNo + * @param pageSize + * @return + */ + public Pagination orderList(String userKey,int pageNo, int pageSize); + + /** + * 订单列表_获取某用户下所有店铺的订单列表 + * @param userId 公司员工ID,根据员工ID找其所属的所有公司,然后找到公司的所有订单 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getUserAllShopOrderList(Integer userId,int pageNo, int pageSize); + +} diff --git a/src/main/java/me/mofun/service/DDNSGnudipUserService.java b/src/main/java/me/mofun/service/DDNSGnudipUserService.java new file mode 100644 index 0000000..c9a8852 --- /dev/null +++ b/src/main/java/me/mofun/service/DDNSGnudipUserService.java @@ -0,0 +1,44 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.DDNSGnudipUser; + +public interface DDNSGnudipUserService extends TService { + + /** + * 获取某用户对应的域名列表 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getDomain(String userId,int pageNo,int pageSize); + + /** + * 判断子域名是否已经被注册;子域名构成形式:userName.domain,如:username.ipdz.cc + * @param userName + * @param domain + * @return + */ + public boolean isExist(String userName,String domain); + + + /** + * 根据用户名及密码获取用户 + * @param userName + * @param password + * @return + */ + public DDNSGnudipUser getUser(String userName,String password); + + /** + * 根据域名和ipdzUserId 获取 Gnudip.User + * @param IpdzUserId + * @param domain + * @return + */ + public DDNSGnudipUser getDomain(String IpdzUserId,String domain); + + public void insert(DDNSGnudipUser u); + +} diff --git a/src/main/java/me/mofun/service/FriendsService.java b/src/main/java/me/mofun/service/FriendsService.java new file mode 100644 index 0000000..feb6ba6 --- /dev/null +++ b/src/main/java/me/mofun/service/FriendsService.java @@ -0,0 +1,17 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Friends; + +public interface FriendsService extends TService { + + /** + * 好友 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getFriends(String userId,int pageNo,int pageSize); + +} diff --git a/src/main/java/me/mofun/service/GroupService.java b/src/main/java/me/mofun/service/GroupService.java new file mode 100644 index 0000000..af59bf1 --- /dev/null +++ b/src/main/java/me/mofun/service/GroupService.java @@ -0,0 +1,87 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.User; +import me.mofun.pojo.Userbyaddress; + +import java.util.List; + +public interface GroupService extends TService{ + public User phoneLogin(String phone,String userPwd); + public User mailLogin(String mail,String userPwd); + public User userByName(String userName); + public User userByIsUserName(String userName); + public User isUserName(String userName,String userId); + public List getUserbyaddress(String userId); + public void addAddress(Userbyaddress userbyaddress); + public void delAddress(Integer id); + public Userbyaddress findAddressById(Integer id); + /** + * 修改除id 外其它的地址为0 + * @param userId + * @param id + */ + public void setDefaultAddress(String userId,Integer id); + /** + * 设置默认收货地址 + * @param userId + * @param id + */ + public void defaultAddress(String userId,Integer id); + + + public List loadAll(); + + /** + * 获取邀请好友列表 + * @param userId + * @return + */ + public Pagination getInvitedList(String userId,int pageNo,int pageSize); + + /** + * 获取邀请好友列表统计数据 + * @param userId + * @return + */ + public List getInvitedListByData(String userId); + + /** + * 获取邀请好友列表By Count + * @param userId + * @return + */ + public Integer getInvitedListByCount(String userId); + + /** + * 会员列表 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination adminUserList(String typeId,String keyword,String orderName,int pageNo,int pageSize); + + /** + * 会员总数 + * @return + */ + public Integer getCountUser(); + + /** + * 判断是否已经存在OpenId + * @param openId + * @return + */ + public User isNotOpenId(String openId); + + /** + * @author lwgboy + * 根据登陆邮箱更新对应的激活Key + * @param mail 登陆邮箱 + * @param key 激活Key + * @return 更新的记录条数 + */ + public int updateKey(String mail,String key) ; + + +} diff --git a/src/main/java/me/mofun/service/LatestlotteryService.java b/src/main/java/me/mofun/service/LatestlotteryService.java new file mode 100644 index 0000000..55e1ae5 --- /dev/null +++ b/src/main/java/me/mofun/service/LatestlotteryService.java @@ -0,0 +1,116 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Latestlottery; +import me.mofun.pojo.OrderDetailAddress; + +import java.util.List; + +public interface LatestlotteryService extends TService { + + /** + * 最新揭晓 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination LatestAnnounced(int pageNo,int pageSize); + + /** + * 最新揭晓6条滚动 + * @return + */ + public List indexWinningScroll(); + + /** + * 查看拍购记录商品详情 + * @param productId + * @return + */ + public List getBuyHistoryByDetail(Integer spellbuyProductId); + + /** + * 查询某用户获得的商品 + * @param userId + * @param startDate + * @param endDate + * @return + */ + public Pagination getProductByUser(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 查询某用户获得的商品ByCount + * @param userId + * @param startDate + * @param endDate + * @return + */ + public Integer getProductByUserByCount(String userId,String startDate,String endDate); + + /** + * 最新揭晓详情 + * @param productId + * @return + */ + public List getLotteryDetail(Integer spellbuyProductId); + + /** + * 某件商品其他期数获得者 + * @param productId + * @param shareId + * @return + */ + public List getProductOtherWinUser(String productId,String shareId); + + /** + * 最新揭晓详情-总共多个人购买 + * @param id + * @return + */ + public Integer getCountByLotteryDetail(String spellbuyProductId); + + /** + * 最新揭晓详情-购买人购买详情 + * @param productId + * @return + */ + public Pagination getLotteryDetailBybuyerList(Integer SpellbuyProductId,int pageNo,int pageSize); + + /** + * 最新揭晓详情-购买人购买详情ByCount + * @param productId + * @return + */ + public Integer getLotteryDetailBybuyerListByCount(Integer SpellbuyProductId); + + /** + * 查询某商品ID与商品基数ID是否已经开过奖 + * @param SpellbuyProductId + * @param productId + * @return + */ + public List getLatestlotteryBySpellbuyProductIdAndProductIdIsExist(Integer SpellbuyProductId); + + public Latestlottery findLatestlotteryByspellbuyrecordId(Integer spellbuyrecordId); + + /** + * 获得商品详情-物流操作详情 + * @param id + * @return + */ + public List orderDetailListById(String id); + + /** + * 获得商品详情-物流地址详情 + * @param id + * @return + */ + public OrderDetailAddress orderDetailAddressFindByOrderDetailId(String id); + + /** + * 获得商品详情-添加物流地址详情 + * @param orderdetailaddress + */ + public void addOrderDetailAddress(OrderDetailAddress orderdetailaddress); + +} diff --git a/src/main/java/me/mofun/service/LotteryproductutilService.java b/src/main/java/me/mofun/service/LotteryproductutilService.java new file mode 100644 index 0000000..a6c5e26 --- /dev/null +++ b/src/main/java/me/mofun/service/LotteryproductutilService.java @@ -0,0 +1,11 @@ +package me.mofun.service; + +import me.mofun.pojo.Lotteryproductutil; + +import java.util.List; + +public interface LotteryproductutilService extends TService { + + public List loadAll(); + +} diff --git a/src/main/java/me/mofun/service/MessageService.java b/src/main/java/me/mofun/service/MessageService.java new file mode 100644 index 0000000..59313a5 --- /dev/null +++ b/src/main/java/me/mofun/service/MessageService.java @@ -0,0 +1,7 @@ +package me.mofun.service; + +import me.mofun.pojo.Message; + +public interface MessageService extends TService { + +} diff --git a/src/main/java/me/mofun/service/NewsReplyService.java b/src/main/java/me/mofun/service/NewsReplyService.java new file mode 100644 index 0000000..2d4899a --- /dev/null +++ b/src/main/java/me/mofun/service/NewsReplyService.java @@ -0,0 +1,24 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.NewsReply; + +import java.util.List; + +public interface NewsReplyService extends TService { + + public Pagination newsReplyList(int pageNo,int pageSize); + + public Pagination newsReplyList(int newsId,int pageNo, int pageSize) ; + + public List indexNewsReply(); + + public List indexNewsReply(Integer recordCount) ; + + public List indexNewsReply(int newsId,Integer recordCount) ; + + + + + +} diff --git a/src/main/java/me/mofun/service/NewsService.java b/src/main/java/me/mofun/service/NewsService.java new file mode 100644 index 0000000..3b59727 --- /dev/null +++ b/src/main/java/me/mofun/service/NewsService.java @@ -0,0 +1,18 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.News; + +import java.util.List; + +public interface NewsService extends TService { + + public Pagination newsList(int pageNo,int pageSize); + + public Pagination newsList(int categoryId,int pageNo, int pageSize) ; + + public List indexNews(); + + public List indexNews(int categoryId,Integer recordCount) ; + +} diff --git a/src/main/java/me/mofun/service/NewsTypeService.java b/src/main/java/me/mofun/service/NewsTypeService.java new file mode 100644 index 0000000..307cbf9 --- /dev/null +++ b/src/main/java/me/mofun/service/NewsTypeService.java @@ -0,0 +1,16 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.NewsType; + +import java.util.List; + +public interface NewsTypeService extends TService { + + public Pagination newsTypeList(int pageNo,int pageSize); + + public List indexNewsType(); + public List indexNewsTypeByParentId(int parentId); + + public Pagination newsTypeList(int Id,int pageNo, int pageSize) ; +} diff --git a/src/main/java/me/mofun/service/OrderDetailAddressService.java b/src/main/java/me/mofun/service/OrderDetailAddressService.java new file mode 100644 index 0000000..5766f84 --- /dev/null +++ b/src/main/java/me/mofun/service/OrderDetailAddressService.java @@ -0,0 +1,10 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.OrderDetailAddress; + +public interface OrderDetailAddressService extends TService { + + public Pagination orderDetailAddressList(int pageNo, int pageSize); + +} diff --git a/src/main/java/me/mofun/service/OrderdetailService.java b/src/main/java/me/mofun/service/OrderdetailService.java new file mode 100644 index 0000000..9e7b676 --- /dev/null +++ b/src/main/java/me/mofun/service/OrderdetailService.java @@ -0,0 +1,7 @@ +package me.mofun.service; + +import me.mofun.pojo.Orderdetail; + +public interface OrderdetailService extends TService { + +} diff --git a/src/main/java/me/mofun/service/ProductImageService.java b/src/main/java/me/mofun/service/ProductImageService.java new file mode 100644 index 0000000..188d90d --- /dev/null +++ b/src/main/java/me/mofun/service/ProductImageService.java @@ -0,0 +1,26 @@ +package me.mofun.service; + +import me.mofun.pojo.ProductImage; + +import java.util.List; + +public interface ProductImageService extends TService{ + + public List findByProductId(String productId,String type); + + public List findByProductIdByUserId(Integer userId, String productId, String type); + + public List findByUserId(Integer userId); + + /** + * 根据用户Id,获取其所有同事所上传的照片 + * @param userId + * @return + */ + public List findAllColleagueUploadImgByUserId(Integer userId); + + public List findByShopId(Integer shopId); + + public List getAllList(); + +} diff --git a/src/main/java/me/mofun/service/ProductService.java b/src/main/java/me/mofun/service/ProductService.java new file mode 100644 index 0000000..c8fcc3c --- /dev/null +++ b/src/main/java/me/mofun/service/ProductService.java @@ -0,0 +1,46 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Product; + +public interface ProductService extends TService { + + /** + * 商品期数列表 + * @param keyword + * @param orderName + * @param pageNo + * @param pageSize + * @return + */ + public Pagination searchSpellbuyproduct(String keyword,String orderName, int pageNo, int pageSize) ; + + /** + * 商品列表 + * @param keyword + * @param orderName + * @param pageNo + * @param pageSize + * @return + */ + public Pagination searchProduct(String typeId,String keyword, int pageNo, int pageSize) ; + + public Pagination searchProductByUserId(Integer userId,String typeId,String keyword, int pageNo, int pageSize) ; + + public Pagination searchProductByShopId(Integer shopId,String typeId,String keyword, int pageNo, int pageSize) ; + + public Product findProductByName(String productName); + + public boolean deleteByUserId(Integer userId,Integer productId); + + + /** + * 直接购买商品列表 + * @param typeId + * @param orderName + * @param pageNo + * @param pageSize + * @return + */ + public Pagination ProductListByTypeIdList(String typeId,String orderName,int pageNo,int pageSize); +} diff --git a/src/main/java/me/mofun/service/ProductTypeService.java b/src/main/java/me/mofun/service/ProductTypeService.java new file mode 100644 index 0000000..bc50625 --- /dev/null +++ b/src/main/java/me/mofun/service/ProductTypeService.java @@ -0,0 +1,45 @@ +package me.mofun.service; + +import me.mofun.pojo.ProductType; +import me.mofun.test.tree.MenuNode; + +import java.util.List; + +public interface ProductTypeService extends TService { + + public List queryAllProductType(); + + public List listByProductList(); + + public List listByProductListBybrand(String id); + + /** + * 获取所有要显示的品牌列表,供前台展示使用 + * @param parentId + * @return + */ + public List listByBrand(String parentId); + + /** + * 获取所有 父Id 下所有的品牌列表,包含不想在前台展示的 + * @param parentId + * @return + */ + public List listByBrandAll(String parentId); + + + /** + * 获取所有的产品类目树 + * @return + */ + public ListgetAllProductTypeTree(); + + + + public ProductType findBrandById(String id); + + public ProductType findTypeByName(String name); + + public ProductType findBrandByName(String name); + +} diff --git a/src/main/java/me/mofun/service/RandomnumberService.java b/src/main/java/me/mofun/service/RandomnumberService.java new file mode 100644 index 0000000..d670da6 --- /dev/null +++ b/src/main/java/me/mofun/service/RandomnumberService.java @@ -0,0 +1,24 @@ +package me.mofun.service; + +import me.mofun.pojo.Randomnumber; + +import java.math.BigDecimal; +import java.util.List; + +public interface RandomnumberService extends TService { + + public List LotteryDetailByRandomnumber(Integer userId,Integer spellbuyProductId); + + /** + * 查询某商品某用户总共总买人次 + * @param userId + * @param spellbuyProductId + * @return + */ + public BigDecimal RandomNumberByUserBuyCount(String userId,Integer spellbuyProductId); + + public Randomnumber findRandomnumberByspellbuyrecordId(Integer spellbuyrecordId); + + public Randomnumber getUserBuyCodeByBuyid(String productId,String spellbuyrecordId); + +} diff --git a/src/main/java/me/mofun/service/RecommendService.java b/src/main/java/me/mofun/service/RecommendService.java new file mode 100644 index 0000000..4681792 --- /dev/null +++ b/src/main/java/me/mofun/service/RecommendService.java @@ -0,0 +1,11 @@ +package me.mofun.service; + +import me.mofun.pojo.Recommend; + +import java.util.List; + +public interface RecommendService extends TService{ + + public List getRecommend(); + +} diff --git a/src/main/java/me/mofun/service/RegionService.java b/src/main/java/me/mofun/service/RegionService.java new file mode 100644 index 0000000..f401c10 --- /dev/null +++ b/src/main/java/me/mofun/service/RegionService.java @@ -0,0 +1,28 @@ +package me.mofun.service; + +import java.util.List; + + +public interface RegionService{ + + /** + * 得到省List + * @return + */ + public List getProvinceList(); + + /** + * 得到市List + * @param provinceId + * @return + */ + public List getCityListByProvinceId(String provinceId); + + /** + * 得到区List + * @param cityId + * @return + */ + public List getDistrictListByCityId(String cityId); + +} diff --git a/src/main/java/me/mofun/service/ShareService.java b/src/main/java/me/mofun/service/ShareService.java new file mode 100644 index 0000000..234ab1f --- /dev/null +++ b/src/main/java/me/mofun/service/ShareService.java @@ -0,0 +1,115 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Sharecomments; +import me.mofun.pojo.Shareimage; +import me.mofun.pojo.Shareinfo; + +import java.util.List; + +public interface ShareService extends TService{ + + /** + * 晒单列表页 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination loadPageShare(String type,int pageNo,int pageSize); + + /** + * 晒单详情页最新晒单 + * @param type + * @param pageNo + * @param pageSize + * @return + */ + public Pagination loadShareInfoByNew(String type,int pageNo,int pageSize); + + /** + * 后台晒单列表 + * @param type + * @param pageNo + * @param pageSize + * @return + */ + public Pagination adminShareList(String type,String status,int pageNo,int pageSize); + + /** + * 晒单内容页 + * @param id + * @return + */ + public List shareShow(int id); + + + /** + * 获取某产品的晒单列表 + * @param id + * @return + */ + public Pagination productInfoShareListByProductId(int id,int pageNo,int pageSize); + + public List productInfoShareListByProductId(int id); + + /** + * 我的晒单 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination shareByUser(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 获取晒单图片 + * @param shareId + * @return + */ + public List getShareimage(String shareId); + + /** + * 添加晒单图片 + * @param shareimage + */ + public void addShareImage(Shareimage shareimage); + + /** + * 晒单评论列表 + * @param shareId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination shareByComment(String shareId,int pageNo,int pageSize); + + /** + * 获取评论列表的评论 + * @param shareCommentId + * @return + */ + public List getReCommentList(String shareCommentId); + + /** + * 添加评论 + * @param sharecomments + */ + public void createComment(Sharecomments sharecomments); + + /** + * 查询某条评论 + * @param sharecommentsId + * @return + */ + public Sharecomments findBySharecommentsId(String sharecommentsId); + + /** + * 首页TA们都在说 + + * @return + */ + public List getIndexSharecommentsList(); + +} diff --git a/src/main/java/me/mofun/service/ShopService.java b/src/main/java/me/mofun/service/ShopService.java new file mode 100644 index 0000000..a61e7d0 --- /dev/null +++ b/src/main/java/me/mofun/service/ShopService.java @@ -0,0 +1,118 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Shop; +import me.mofun.pojo.Userbyaddress; + +import java.util.List; + +; + +public interface ShopService extends TService{ + public Shop phoneLogin(String phone,String userPwd); + public Shop mailLogin(String mail,String userPwd); + public Shop userByName(String userName); + public Shop userByIsShopName(String userName); + public Shop isShopName(String userName,String userId); + public List getShopbyaddress(String userId); + public void addAddress(Userbyaddress userbyaddress); + public void delAddress(Integer id); + public Userbyaddress findAddressById(Integer id); + /** + * 修改除id 外其它的地址为0 + * @param userId + * @param id + */ + public void setDefaultAddress(String userId,Integer id); + /** + * 设置默认收货地址 + * @param userId + * @param id + */ + public void defaultAddress(String userId,Integer id); + + + public List loadAll(); + + /** + * 获取邀请好友列表 + * @param userId + * @return + */ + public Pagination getInvitedList(String userId,int pageNo,int pageSize); + + /** + * 获取邀请好友列表统计数据 + * @param userId + * @return + */ + public List getInvitedListByData(String userId); + + /** + * 获取邀请好友列表By Count + * @param userId + * @return + */ + public Integer getInvitedListByCount(String userId); + + /** + * 会员列表 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination adminShopList(String typeId,String keyword,String orderName,int pageNo,int pageSize); + + /** + * 店铺总数 + * @return + */ + public Integer getCountShop(); + + /** + * 判断是否已经存在OpenId + * @param openId + * @return + */ + public Shop isNotOpenId(String openId); + + /** + * @author lwgboy + * 根据登陆邮箱更新对应的激活Key + * @param mail 登陆邮箱 + * @param key 激活Key + * @return 更新的记录条数 + */ + public int updateKey(String mail,String key) ; + + /** + * 获取某用户名下所有店铺 + * @param userId + * @param isAuditSuccess 是否仅仅列出审核通过的商铺 + * @return + */ + public List getShopListByUserId(Integer userId,boolean isOnlyListAuditSuccess) ; + + /** + * 获取某用户所有的同事,主要用于获取其所有同事上传的所有图片用 + * @param userId + * @param isAuditSuccess 是否仅仅列出审核通过的商铺 + * @return + */ + public List getShopUserListByUserId(Integer userId) ; + + /** + * 是否有审核成功的商铺 + * @param listShop + * @return + */ + public boolean isHasAuditSucceedShop(List shopList); + + /** + * 获得审核成功的店铺(移除审核不成功及尚未审核的商铺) + * @param listShop + * @return + */ + public List getAuditSucceedShop(List shopList); + +} diff --git a/src/main/java/me/mofun/service/SpellbuyproductService.java b/src/main/java/me/mofun/service/SpellbuyproductService.java new file mode 100644 index 0000000..a11b868 --- /dev/null +++ b/src/main/java/me/mofun/service/SpellbuyproductService.java @@ -0,0 +1,109 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Spellbuyproduct; + +import java.util.List; + +public interface SpellbuyproductService extends TService { + + /** + * 商品页 + * @param spellbuyProductId 商品的拍购ID + * @return + */ + public List findBySpellbuyProductId(int spellbuyProductId); + + /** + * 商品页 + * @param fkProductId 商品ID + * @return + */ + public List findByFKProductId(int fkProductId); + + /** + * 根据外键产品ID(fkProductId)返回最新一个该商品的最新拍购对象 + * @author mofun + * @param fkProductId 商品ID,非商品的拍购ID + * @return + */ + public Spellbuyproduct findByFKProductId(String fkProductId) ; + + + /** + * 即将揭晓商品 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination upcomingAnnounced(int pageNo, int pageSize); + + /** + * 人气top,人气推荐,用于列表页等页面下部的人气推荐栏目。 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination upcomingAnnouncedByTop(int pageNo, int pageSize); + + /** + * 商品期数列表 + * @param integer + * @return + */ + public List productPeriodList(Integer integer); + + /** + * 查询某商品最后一期数 + * @param productId + * @return + */ + public Spellbuyproduct findSpellbuyproductLastPeriod(Integer productId); + + /** + * 查询某商品正在拍购期数,by 修改商品价格 + * @param productId + * @return + */ + public Spellbuyproduct findSpellbuyproductByStatus(Integer productId); + + /** + * 已经揭晓商品列表 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination announcedProduct(int pageNo, int pageSize); + + public List loadAllByType(); + + public List loadAll(); + + public List UpdateLatestlotteryGetList(); + + /** + * 查询某个商品是否已经有最新期 + * @param productId + * @return + */ + public List findSpellbuyproductByProductIdIsStatus(Integer productId); + + /** + * 暂时废弃 + * @author lwg * + * 检查限购情况明细,用于商品详情页 goodsdetail.js 中 ajax 调用 /products/checkUserLimitBuy.action + * http://127.0.0.1:8080/products/checkUserLimitBuy.action?id=1001 + * @param spellbuyId + * @return + */ + public List checkUserLimitBuyDetail(String spellbuyId); + + /** + * @author lwg + * 检查用户限购情况,用于商品详情页 goodsdetail.js 中 ajax 调用 /products/checkUserLimitBuy.action + * http://127.0.0.1:8080/products/checkUserLimitBuy.action?id=1001 + * @param spellbuyId + * @return + */ + public List checkUserLimitBuy(String spellbuyId,String userId); +} diff --git a/src/main/java/me/mofun/service/SpellbuyrecordService.java b/src/main/java/me/mofun/service/SpellbuyrecordService.java new file mode 100644 index 0000000..5db0d63 --- /dev/null +++ b/src/main/java/me/mofun/service/SpellbuyrecordService.java @@ -0,0 +1,242 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Spellbuyrecord; + +import java.math.BigDecimal; +import java.util.List; + +public interface SpellbuyrecordService extends TService { + + /** + * 最热人气商品 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination findHotProductList(int pageNo,int pageSize); + + /** + * 最新上架商品,用于首页新品展示区 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination indexNewProductList(int pageNo,int pageSize); + + /** + * 人气排行商品 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination indexHotProductList(int pageNo,int pageSize); + + /** + * 最新拍购商品 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getNowBuyList(int pageNo,int pageSize); + + /** + * 最新100条拍购记录AJAX请求 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getNowBuyAjaxList(int pageNo,int pageSize,int spellbuyRecordId); + + /** + * 全站拍购记录查询 + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getAllBuyRecord(String startDate,String endDate,int pageNo,int pageSize); + + /** + * 揭晓详细计算结果(全站最后100条购买记录) + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getlotteryDetail(String startDate,String endDate,int pageNo,int pageSize); + + /** + * 开奖最后一百条购买记录 + * @return + */ + public List getSpellbuyRecordByLast100(String startDate,String endDate); + + /** + * 得到某商品最后购买记录 + * @param fkSpellbuyProductId + * @return + */ + public List getEndBuyDateByProduct(Integer fkSpellbuyProductId); + + /** + * 首页分类显示商品 + * @param typeId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination findProductByTypeId(String typeId,int pageNo,int pageSize); + + /** + * 商品页按商品类型查询商品 + * @param typeId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination ProductByTypeIdList(String typeId,String brandId,String orderName,int pageNo,int pageSize); + + /** + * 商品页按商品类型及shopId查询商品 + * @param typeId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination ProductByTypeIdListAndShopId(Integer shopId,String typeId,String brandId,String orderName,int pageNo,int pageSize); + + /** + * 商品页按商品类型及所属用户查询商品 + * @param typeId + * @param pageNo + * @param pageSize + * @return + */ + //public Pagination ProductByTypeIdListAndUserId(Integer UserId,String typeId,String brandId,String orderName,int pageNo,int pageSize); + + /** + * 用户中心首页最新上架 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination nowUpProducts(int pageNo,int pageSize); + + /** + * 搜索商品 + * @param keyword + * @param pageNo + * @param pageSize + * @return + */ + public Pagination searchProduct(String keyword,String orderName,int pageNo,int pageSize); + + + /** + * 最新参与 + * @param productId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination LatestParticipate(String spellbuyProductId,int pageNo,int pageSize); + + /** + * 最新参与ByCount + * @param productId + * @param pageNo + * @param pageSize + * @return + */ + public Integer LatestParticipateByCount(String spellbuyProductId); + + /** + * 得到某条购买记录的随机码(list 页) + * @param spellbuyrecordId + * @param pageNo + * @param pageSize + * @return + */ + public List getRandomNumberList(String spellbuyProductId,String userId); + + /** + * 得到某条购买记录的随机码(详细 页) + * @param spellbuyrecordId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getRandomNumberListPage(String spellbuyProductId,String userId,int pageNo,int pageSize); + + /** + * 得到某条购买记录的随机码(详细 页)ByCount + * @param spellbuyrecordId + * @param pageNo + * @param pageSize + * @return + */ + public Integer getRandomNumberListPageByCount(String spellbuyProductId,String userId); + + /** + * 查询某用户的购买记录 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination buyHistoryByUser(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 查询某用户的购买记录ByCount + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Integer buyHistoryByUserByCount(String userId,String startDate,String endDate); + + /** + * 查询某用户购买记录详情 + * @param userId + * @param productId + * @return + */ + public List getBuyHistoryByDetail(String productId,String userId); + + /** + * 我的购买记录 + * @param userId + * @param fkSpellbuyProductId + * @return + */ + public List getUserByHistory(String userId,String fkSpellbuyProductId); + + /** + * 某件商品满员后抽奖 + * @param spellbuyProductId + * @return + */ + public List randomByBuyHistoryByspellbuyProductId(Integer productId,String randomNumber); + + + public List WinRandomNumber(Integer productId,Integer randomNumber); + + /** + * 全站总拍购人数 + * @return + */ + public BigDecimal getAllByCount(); + + /** + * 查询某用户总共消费金额 + * @param userId + * @return + */ + public BigDecimal findSumByBuyPriceByUserId(String userId); + + + +} diff --git a/src/main/java/me/mofun/service/SysConfigureService.java b/src/main/java/me/mofun/service/SysConfigureService.java new file mode 100644 index 0000000..d7bb4e1 --- /dev/null +++ b/src/main/java/me/mofun/service/SysConfigureService.java @@ -0,0 +1,26 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.IndexImg; +import me.mofun.pojo.Suggestion; +import me.mofun.pojo.SysConfigure; + +import java.util.List; + +public interface SysConfigureService extends TService { + + public List initializationIndexImgAll(); + + public List IndexImgAll(); + + public void addIndexImg(IndexImg indexImg); + + public IndexImg findByIndexImgId(String id); + + public void delIndexImg(Integer id); + + public void doSuggestion(Suggestion suggestion); + + public Pagination suggestionList(int pageNo, int pageSize) ; + +} diff --git a/src/main/java/me/mofun/service/TService.java b/src/main/java/me/mofun/service/TService.java new file mode 100644 index 0000000..7f1b5ff --- /dev/null +++ b/src/main/java/me/mofun/service/TService.java @@ -0,0 +1,11 @@ +package me.mofun.service; + +import java.util.List; + +public interface TService { + public void add(T t); + public void delete(Integer id); + public void update(String hql); + public T findById(String id); + public List query(String hql); +} diff --git a/src/main/java/me/mofun/service/TalkGroupService.java b/src/main/java/me/mofun/service/TalkGroupService.java new file mode 100644 index 0000000..6c0564d --- /dev/null +++ b/src/main/java/me/mofun/service/TalkGroupService.java @@ -0,0 +1,15 @@ +package me.mofun.service; + +import me.mofun.pojo.TalkGroup; + +import java.util.List; + +public interface TalkGroupService extends TService{ + + /** + * 获取所有的聊天圈子列表 + * @return + */ + public List getGroupList(); + +} diff --git a/src/main/java/me/mofun/service/TalkMsgService.java b/src/main/java/me/mofun/service/TalkMsgService.java new file mode 100644 index 0000000..84bacc4 --- /dev/null +++ b/src/main/java/me/mofun/service/TalkMsgService.java @@ -0,0 +1,95 @@ +package me.mofun.service; + +import me.mofun.pojo.TalkMsg; +import me.mofun.pojo.TalkUser; + +import java.util.List; + +public interface TalkMsgService extends TService{ + + /** + * 获取给定时间之后所有新的公聊消息列表 + * @param beforeTime + * @param groupId + */ + public List getNewMsgList(Long afterTime,Integer groupId); + + /** + * 获取给定时间之后所有新消息的列表 + * @param beforeTime + * @param groupId + * @param toUserId 接收消息者的用户Id + */ + public List getNewMsgList(Long afterTime,Integer groupId,Integer toUserId); + + + /** + * 获取给定时间之后所有新新私聊消息的列表 + * @param beforeTime + * @param groupId + * @param toUserId 接收消息者的用户Id + */ + public List getNewPrivateMsgList(Long afterTime,Integer groupId,Integer fromUserId,Integer toUserId); + + + /** + * 获取给定时间之前所有公聊消息列表之第几页数据 + * @param beforeTime + * @param groupId + * @@param pageIndex 页码索引 + */ + public List getMsgList(Long beforeTime,Integer groupId,Integer pageIndex); + + + + /** + * 获取给定时间之前所有发给某用户消息列表之第几页数据 + * @param beforeTime + * @param groupId + * @param toUserId 接收消息者的用户Id + * @@param pageIndex 页码索引 + */ + public List getMsgList(Long beforeTime,Integer groupId,Integer toUserId,Integer pageIndex); + + + /** + * 获取给定时间之前,某两个用户之间私聊消息列表之第几页数据 + * @param beforeTime + * @param groupId + * @param toUserId 接收消息者的用户Id + * @@param pageIndex 页码索引 + */ + public List getMsgList(Long beforeTime,Integer groupId,Integer fromUserId,Integer toUserId,Integer pageIndex); + + + /** + * 获取给定时间之前的私聊消息列表及用户信息 + * @param beforeTime + * @param groupId + */ + public List getMsgListAndUserInfo(Integer fromUserId,Integer toUserId,Integer beforeTime); + + /** + * 获取某用户的所有聊天者列表 + * @param toUserId + * @return + */ + public List getChatList(Integer toUserId); + + /** + * 获取某用户最新的聊天者列表(有未读信息) + * @param toUserId + * @return + */ + public List getNewChatList(Integer toUserId); + + + /** + * 更新私聊信息中用户A发给用户B的信息状态为已读状态 + * @param fromUserId + * @param toUserId + * @param status + * @return + */ + public boolean updateMsgStatus(Integer fromUserId,Integer toUserId,Integer status); +} diff --git a/src/main/java/me/mofun/service/TalkUserService.java b/src/main/java/me/mofun/service/TalkUserService.java new file mode 100644 index 0000000..dab5844 --- /dev/null +++ b/src/main/java/me/mofun/service/TalkUserService.java @@ -0,0 +1,18 @@ +package me.mofun.service; + +import me.mofun.pojo.TalkUser; + +import java.util.List; + +public interface TalkUserService extends TService{ + + /** + * 根据圈子Id 获取聊天用户列表 + * @param groupId + * @return + */ + public List getUserListByGroupId(Integer groupId); + + public TalkUser getUserByOpenId(String openId); + +} diff --git a/src/main/java/me/mofun/service/UserService.java b/src/main/java/me/mofun/service/UserService.java new file mode 100644 index 0000000..60c3003 --- /dev/null +++ b/src/main/java/me/mofun/service/UserService.java @@ -0,0 +1,99 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.User; +import me.mofun.pojo.Userbyaddress; + +import java.util.List; + +public interface UserService extends TService{ + public User phoneLogin(String phone,String userPwd); + public User mailLogin(String mail,String userPwd); + public User userByName(String userName); + public User userByIsUserName(String userName); + public User isUserName(String userName,String userId); + public List getUserbyaddress(String userId); + public void addAddress(Userbyaddress userbyaddress); + public void delAddress(Integer id); + public Userbyaddress findAddressById(Integer id); + /** + * 修改除id 外其它的地址为0 + * @param userId + * @param id + */ + public void setDefaultAddress(String userId,Integer id); + /** + * 设置默认收货地址 + * @param userId + * @param id + */ + public void defaultAddress(String userId,Integer id); + + + public List loadAll(); + + /** + * 获取邀请好友列表 + * @param userId + * @return + */ + public Pagination getInvitedList(String userId,int pageNo,int pageSize); + + /** + * 获取邀请好友列表统计数据 + * @param userId + * @return + */ + public List getInvitedListByData(String userId); + + /** + * 获取邀请好友列表By Count + * @param userId + * @return + */ + public Integer getInvitedListByCount(String userId); + + /** + * 会员列表 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination adminUserList(String typeId,String keyword,String orderName,int pageNo,int pageSize); + + /** + * 获取同事列表 + * @param userId + * @param typeId + * @param keyword + * @param orderName + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getColleaguesList(Integer userId,String typeId,String keyword,String orderName,int pageNo, int pageSize) ; + + /** + * 会员总数 + * @return + */ + public Integer getCountUser(); + + /** + * 判断是否已经存在OpenId + * @param openId + * @return + */ + public User isNotOpenId(String openId); + + /** + * @author lwgboy + * 根据登陆邮箱更新对应的激活Key + * @param mail 登陆邮箱 + * @param key 激活Key + * @return 更新的记录条数 + */ + public int updateKey(String mail,String key) ; + + +} diff --git a/src/main/java/me/mofun/service/VisitorsService.java b/src/main/java/me/mofun/service/VisitorsService.java new file mode 100644 index 0000000..9726661 --- /dev/null +++ b/src/main/java/me/mofun/service/VisitorsService.java @@ -0,0 +1,33 @@ +package me.mofun.service; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Visitors; + +import java.util.List; + +public interface VisitorsService extends TService { + + /** + * 访客列表 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getVisitors(String userId,int pageNo,int pageSize); + + /** + * 查询某用户是否有访问记录 + * @param userId + * @param visitorsId + * @return + */ + public Visitors findVisitorsByUserIdAndVisitorsId(String userId,String visitorsId); + + /** + * 查询一小时内是否访问过 + * @return + */ + public List findVisitors(String userId,String visitorsId,String startDate,String endDate); + +} diff --git a/src/main/java/me/mofun/service/impl/ApplymentionServiceImpl.java b/src/main/java/me/mofun/service/impl/ApplymentionServiceImpl.java new file mode 100644 index 0000000..f026860 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/ApplymentionServiceImpl.java @@ -0,0 +1,81 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Applymention; +import me.mofun.service.ApplymentionService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class ApplymentionServiceImpl implements ApplymentionService { + @Autowired + BaseDAO baseDao; + + public void add(Applymention t) { + this.baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public Applymention findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination getApplymentionList(String userId, String startDate,String endDate, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from applymention an where 1=1"); + if(StringUtils.isNotBlank(userId)){ + hql.append(" and an.userId = '"+userId+"'"); + } + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and an.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and an.date <='"+endDate+"'"); + } + hql.append(" order by an.date desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("an", Applymention.class); + List list = baseDao.sqlQueryBean(hql, entityMap, page); + page.setList(list); + return page; + } + + public Integer getApplymentionListByCount(String userId, String startDate, + String endDate) { + StringBuffer sql = new StringBuffer("select count(*) from applymention an where 1=1"); + if(StringUtils.isNotBlank(userId)){ + sql.append(" and an.userId = '"+userId+"'"); + } + if(StringUtils.isNotBlank(startDate)){ + sql.append(" and an.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + sql.append(" and an.date <='"+endDate+"'"); + } + return baseDao.getAllNum(sql); + } + +} diff --git a/src/main/java/me/mofun/service/impl/CardpasswordServiceImpl.java b/src/main/java/me/mofun/service/impl/CardpasswordServiceImpl.java new file mode 100644 index 0000000..9563661 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/CardpasswordServiceImpl.java @@ -0,0 +1,74 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Cardpassword; +import me.mofun.service.CardpasswordService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class CardpasswordServiceImpl implements CardpasswordService { + @Autowired + BaseDAO baseDAO; + + public Cardpassword doCardRecharge(String randomNo,String cardPwd) { + StringBuffer hql = new StringBuffer(); + if(StringUtils.isNotBlank(randomNo) && StringUtils.isNotBlank(cardPwd)){ + hql.append("from Cardpassword cd where cd.randomNo ='"+randomNo+"' and cd.cardPwd ='"+cardPwd+"'"); + } + return (Cardpassword) this.baseDAO.loadObject(hql.toString()); + } + + public void delete(Integer id) { + this.baseDAO.delById(Cardpassword.class, id); + } + + public void deleteByID(Integer id) { + this.baseDAO.delById(Cardpassword.class, id); + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public void add(Cardpassword t) { + this.baseDAO.saveOrUpdate(t); + + } + + + public Cardpassword findById(String id) { + // TODO Auto-generated method stub + return null; + } + + + public Pagination cardRechargeList(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from cardpassword cd where 1=1 order by cd.date desc"); + StringBuffer sql = new StringBuffer("select count(*) from cardpassword "); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("cd", Cardpassword.class); + List list = baseDAO.sqlQuery(hql, entityMap, page); + int resultCount = baseDAO.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + +} diff --git a/src/main/java/me/mofun/service/impl/CommissionpointsServiceImpl.java b/src/main/java/me/mofun/service/impl/CommissionpointsServiceImpl.java new file mode 100644 index 0000000..4b3f60e --- /dev/null +++ b/src/main/java/me/mofun/service/impl/CommissionpointsServiceImpl.java @@ -0,0 +1,76 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Commissionpoints; +import me.mofun.service.CommissionpointsService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class CommissionpointsServiceImpl implements CommissionpointsService { + @Autowired + BaseDAO baseDao; + + public Pagination CommissionPoints(String userId, String startDate, + String endDate, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from commissionpoints cs where cs.toUserid = '"+userId+"'"); + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and cs.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and cs.date <='"+endDate+"'"); + } + hql.append(" order by cs.date desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("cs", Commissionpoints.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + page.setList(list); + return page; + } + + public void add(Commissionpoints t) { + this.baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public Commissionpoints findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Integer getCommissionPointsListByCount(String userId, + String startDate, String endDate) { + StringBuffer sql = new StringBuffer("select count(*) from commissionpoints cs where cs.toUserid = '"+userId+"'"); + if(StringUtils.isNotBlank(startDate)){ + sql.append(" and cs.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + sql.append(" and cs.date <='"+endDate+"'"); + } + return baseDao.getAllNum(sql); + } + +} diff --git a/src/main/java/me/mofun/service/impl/CommissionqueryServiceImpl.java b/src/main/java/me/mofun/service/impl/CommissionqueryServiceImpl.java new file mode 100644 index 0000000..3dfe144 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/CommissionqueryServiceImpl.java @@ -0,0 +1,84 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Commissionquery; +import me.mofun.pojo.User; +import me.mofun.service.CommissionqueryService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class CommissionqueryServiceImpl implements CommissionqueryService { + @Autowired + BaseDAO baseDao; + + public Pagination getCommissionQueryList(String userId, String startDate,String endDate,int pageNo,int pageSize) { + StringBuffer hql = new StringBuffer("select * from commissionquery cy,user ur where cy.toUserId=ur.userId and cy.invitedId = '"+userId+"'"); + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and cy.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and cy.date <='"+endDate+"'"); + } + hql.append(" order by cy.date desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("cy", Commissionquery.class); + entityMap.put("ur", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + page.setList(list); + return page; + } + + public Integer getCommissionQueryListByCount(String userId,String startDate,String endDate) { + StringBuffer sql = new StringBuffer("select count(*) from commissionquery cy,user ur where cy.toUserId=ur.userId and cy.invitedId = '"+userId+"'"); + if(StringUtils.isNotBlank(startDate)){ + sql.append(" and cy.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + sql.append(" and cy.date <='"+endDate+"'"); + } + return baseDao.getAllNum(sql); + } + + public List getCommissionQueryListByData(String userId) { + StringBuffer hql = new StringBuffer("select * from commissionquery cy where cy.invitedId = '"+userId+"'"); + Map entityMap = new HashMap(); + entityMap.put("cy", Commissionquery.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + public void add(Commissionquery t) { + this.baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public Commissionquery findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/me/mofun/service/impl/ConsumerdetailServiceImpl.java b/src/main/java/me/mofun/service/impl/ConsumerdetailServiceImpl.java new file mode 100644 index 0000000..d2681ea --- /dev/null +++ b/src/main/java/me/mofun/service/impl/ConsumerdetailServiceImpl.java @@ -0,0 +1,78 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Consumerdetail; +import me.mofun.service.ConsumerdetailService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("consumerdetailService") +public class ConsumerdetailServiceImpl implements ConsumerdetailService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(Consumerdetail t) { + baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + baseDao.delById(Consumerdetail.class, id); + } + + public Consumerdetail findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination userByConsumetableDetail(String id, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from consumerdetail cl where cl.consumetableId = '"+id+"'"); +// StringBuffer sql = new StringBuffer("select count(*) from consumerdetail cl where cl.consumetableId = '"+id+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("cl", Consumerdetail.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer userByConsumetableDetailByCount(String id){ + StringBuffer sql = new StringBuffer("select count(*) from consumerdetail cl where cl.consumetableId = '"+id+"'"); + return baseDao.getAllNum(sql); + } + + public Pagination orderInfo(String id,int pageNo, int pageSize){ + StringBuffer hql = new StringBuffer("select * from consumerdetail cl where cl.consumetableId = '"+id+"'"); + StringBuffer sql = new StringBuffer("select count(*) from consumerdetail where consumetableId = '"+id+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("cl", Consumerdetail.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + +} diff --git a/src/main/java/me/mofun/service/impl/ConsumetableServiceImpl.java b/src/main/java/me/mofun/service/impl/ConsumetableServiceImpl.java new file mode 100644 index 0000000..662cf2d --- /dev/null +++ b/src/main/java/me/mofun/service/impl/ConsumetableServiceImpl.java @@ -0,0 +1,188 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Consumetable; +import me.mofun.service.ConsumetableService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service("consumetableService") +public class ConsumetableServiceImpl implements ConsumetableService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(Consumetable t) { + baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + baseDao.delById(Consumetable.class, id); + } + + public Consumetable findById(String id) { + StringBuffer hql = new StringBuffer("from Consumetable consumetable where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and consumetable.id='"+id+"'"); + } + return (Consumetable) baseDao.loadObject(hql.toString()); + } + + public Consumetable findByOutTradeNo(String id) { + StringBuffer hql = new StringBuffer("from Consumetable consumetable where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and consumetable.outTradeNo='"+id+"'"); + } + return (Consumetable) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + /** + * 获取充值记录,充值记录在 consumetable 表中,当该表的 transactionId 不为空时即表示是充值行为 + * + */ + public Pagination userByConsumetableByDelta(String userId, String startDate, + String endDate, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from consumetable ce where 1=1"); +// StringBuffer sql = new StringBuffer("select count(*) from consumetable ce where ce.userId = '"+userId+"' and ce.transactionId is not null"); + if(StringUtils.isNotBlank(userId)){ + hql.append(" and ce.userId = '"+userId+"'"); + } + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and ce.date >= '"+startDate+"'"); +// sql.append(" and ce.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and ce.date <='"+endDate+"'"); +// sql.append(" and ce.date <='"+endDate+"'"); + } + hql.append(" and ce.transactionId is not null order by ce.date desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ce", Consumetable.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer userByConsumetableByDeltaByCount(String userId,String startDate,String endDate){ + StringBuffer sql = new StringBuffer("select count(*) from consumetable ce where 1=1 "); + if(StringUtils.isNotBlank(userId)){ + sql.append(" and ce.userId = '"+userId+"'"); + } + if(StringUtils.isNotBlank(startDate)){ + sql.append(" and ce.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + sql.append(" and ce.date <='"+endDate+"'"); + } + sql.append(" and ce.transactionId is not null"); + return baseDao.getAllNum(sql); + } + + /** + * 获取消费金额记录,消费记录和充值记录都在 Consumetable 表中 + * + */ + public Pagination userByConsumetable(String userId, String startDate,String endDate, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from consumetable ce where 1=1 "); +// StringBuffer sql = new StringBuffer("select count(*) from consumetable ce where ce.userId = '"+userId+"' and ((ce.interfaceType = 'tenPay' and ce.transactionId is not null) or ce.interfaceType = '余额支付')"); + if(StringUtils.isNotBlank(userId)){ + hql.append(" and ce.userId = '"+userId+"'"); + } + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and ce.date >= '"+startDate+"'"); +// sql.append(" and ce.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and ce.date <='"+endDate+"'"); +// sql.append(" and ce.date <='"+endDate+"'"); + } + hql.append(" and ((ce.interfaceType = 'tenPay' and ce.transactionId is not null) or (ce.interfaceType = 'aliPay' and ce.transactionId is not null) or (ce.interfaceType = 'yeePay' and ce.transactionId is not null) or ce.interfaceType = '余额支付' or ce.interfaceType='福分+余额' ) and ce.outTradeNo in(select consumetableId from consumerdetail) order by ce.date desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ce", Consumetable.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer userByConsumetableByCount(String userId,String startDate,String endDate){ + StringBuffer sql = new StringBuffer("select count(*) from consumetable ce where 1=1"); + if(StringUtils.isNotBlank(userId)){ + sql.append(" and ce.userId = '"+userId+"'"); + } + if(StringUtils.isNotBlank(startDate)){ + sql.append(" and ce.date >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + sql.append(" and ce.date <='"+endDate+"'"); + } + sql.append(" and ((ce.interfaceType = 'tenPay' and ce.transactionId is not null) or (ce.interfaceType = 'aliPay' and ce.transactionId is not null) or (ce.interfaceType = 'yeePay' and ce.transactionId is not null) or ce.interfaceType = '余额支付') and ce.outTradeNo in(select consumetableId from consumerdetail)"); + return baseDao.getAllNum(sql); + } + + public Pagination orderList(String userKey,int pageNo, int pageSize){ + StringBuffer hql = new StringBuffer("select ce.* from consumetable ce inner join consumerdetail cl on ce.outTradeNo=cl.consumetableId where 1=1 and ( ( ce.interfaceType = 'tenPay' and ce.transactionId is not null ) or ( ce.interfaceType = 'aliPay' and ce.transactionId is not null ) or ( ce.interfaceType = 'yeePay' and ce.transactionId is not null ) or ce.interfaceType = '余额支付' )"); + StringBuffer sql = new StringBuffer("select count(DISTINCT(ce.id)) from consumetable ce inner join consumerdetail cl on ce.outTradeNo=cl.consumetableId where 1=1 and ( ( ce.interfaceType = 'tenPay' and ce.transactionId is not null ) or ( ce.interfaceType = 'aliPay' and ce.transactionId is not null ) or ( ce.interfaceType = 'yeePay' and ce.transactionId is not null ) or ce.interfaceType = '余额支付' )"); + if(StringUtils.isNotBlank(userKey)){ + hql.append(" and ce.userId='"+userKey.trim()+"'"); + sql.append(" and ce.userId='"+userKey.trim()+"'"); + } + hql.append(" group by ce.id order by ce.date desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ce", Consumetable.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + //获得某用户所在公司的所有订单 + public Pagination getUserAllShopOrderList(Integer userId,int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select ce.* from consumetable ce inner join consumerdetail cl on ce.outTradeNo=cl.consumetableId inner join spellbuyproduct st on cl.spellbuyproductId=st.spellbuyProductId inner join product pt on st.fkProductId=pt.productId where 1=1 and pt.shopId in (select shopid from user where userId="+ userId+") and ( ( ce.interfaceType = 'tenPay' and ce.transactionId is not null ) or ( ce.interfaceType = 'aliPay' and ce.transactionId is not null ) or ( ce.interfaceType = 'yeePay' and ce.transactionId is not null ) or ce.interfaceType = '余额支付' )"); + StringBuffer sql = new StringBuffer("select count(DISTINCT(ce.id)) from consumetable ce inner join consumerdetail cl on ce.outTradeNo=cl.consumetableId inner join spellbuyproduct st on cl.spellbuyproductId=st.spellbuyProductId inner join product pt on st.fkProductId=pt.productId where 1=1 and pt.shopId in (select shopid from user where userId="+ userId+") and ( ( ce.interfaceType = 'tenPay' and ce.transactionId is not null ) or ( ce.interfaceType = 'aliPay' and ce.transactionId is not null ) or ( ce.interfaceType = 'yeePay' and ce.transactionId is not null ) or ce.interfaceType = '余额支付' )"); + hql.append(" group by ce.id order by ce.date desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ce", Consumetable.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + + +} diff --git a/src/main/java/me/mofun/service/impl/DDNSGnudipUserServiceImpl.java b/src/main/java/me/mofun/service/impl/DDNSGnudipUserServiceImpl.java new file mode 100644 index 0000000..a208595 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/DDNSGnudipUserServiceImpl.java @@ -0,0 +1,135 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.DDNSGnudipUser; +import me.mofun.service.DDNSGnudipUserService; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class DDNSGnudipUserServiceImpl implements DDNSGnudipUserService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + Logger logger = Logger.getLogger(this.getClass()); + + public void add(DDNSGnudipUser t) { + baseDao.saveOrUpdate(t); + } + + /** + * @deprecated 仅仅是测试时顺手写的,SQL语句有问题不能执行,有空时再研究,弃用。 + */ + public void insert(DDNSGnudipUser u) { + String sql = "insert into gnudip2.users(ipdzId, username, password, domain, email, createdate, enddate, forwardurl, updated, level, currentip, autourlon, MXvalue, MXbackup, wildcard, allowwild, allowmx, status) values(" + + "%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s',%d)"; + sql = sql.format(sql,u.getIpdzId(),u.getUsername(),u.getPassword(),u.getDomain(),u.getEmail(),u.getCreatedate(),u.getEnddate(),u.getForwardurl(),u.getUpdated(),u.getLevel(),u.getCurrentip(),u.getAutourlon(),u.getMxvalue(),u.getMxbackup(),u.getWildcard(),u.getAllowwild(),u.getAllowmx(),u.getStatus()); + + baseDao.saveOrUpdateSQL(sql); + } + + public void delete(Integer id) { + baseDao.delById(DDNSGnudipUser.class, id); + } + + public DDNSGnudipUser findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination getDomain(String IpdzUserId, int pageNo, int pageSize) { + //StringBuffer hql = new StringBuffer("select * from friends fs,user ur where fs.friendsId = ur.userId and fs.userId = '"+userId+"'"); + //StringBuffer sql = new StringBuffer("select count(*) from friends fs,user ur where fs.friendsId = ur.userId and fs.userId = '"+IpdzUserId+"'"); + StringBuffer hql = new StringBuffer("select * from gnudip2.users where ipdzId ="+IpdzUserId+""); + StringBuffer sql = new StringBuffer("select count(*) from gnudip2.users user where ipdzId ="+IpdzUserId+""); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + //entityMap.put("fs", Friends.class); + entityMap.put("user", DDNSGnudipUser.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + /** + * 根据域名和ipdzUserId 获取 Gnudip.User + * @param IpdzUserId + * @param domain + * @return + */ + public DDNSGnudipUser getDomain(String IpdzUserId,String domain) { + //StringBuffer hql = new StringBuffer("select * from friends fs,user ur where fs.friendsId = ur.userId and fs.userId = '"+userId+"'"); + //StringBuffer sql = new StringBuffer("select count(*) from friends fs,user ur where fs.friendsId = ur.userId and fs.userId = '"+IpdzUserId+"'"); + StringBuffer sql = new StringBuffer("select * from gnudip2.users where ipdzId ="+IpdzUserId+" and concat_ws('.',userName,domain)='"+domain+"'" ); + Map entityMap = new HashMap(); + entityMap.put("user", DDNSGnudipUser.class); + DDNSGnudipUser gnudipUser = baseDao.loadObjectBySql(sql.toString(), DDNSGnudipUser.class); + return gnudipUser; + } + + public boolean isExist(String userName, String domain) { + // TODO Auto-generated method stub + StringBuffer hql = new StringBuffer("select count(*) from DDNSGnudipUser where username='"+userName+"' and domain='"+domain+"'"); + int count = baseDao.countQuery(hql.toString()); + if(count>0) + return true; + else + return false; + } + + + public boolean login(String userName,String password){ + StringBuffer hql = new StringBuffer("select count(*) from DDNSGnudipUser where username='"+userName+"' and password='"+password+"'"); + int count = baseDao.countQuery(hql.toString()); + if(count>0) + return true; + else + return false; + } + + /** + * 根据用户名及密码获取用户 + * @param userName + * @param password + * @return + */ + public DDNSGnudipUser getUser(String userName,String password){ + StringBuffer hql = new StringBuffer("from DDNSGnudipUser where username='"+userName+"' and password='"+password+"'"); + try{ + List userList = baseDao.query(hql.toString()) ; + if(userList!=null&&userList.size()>0) + { + return (DDNSGnudipUser)(userList.get(0)); + } + else + return null; + } + catch(Exception ex) + { + logger.error(ex.getMessage()); + return null; + } + } +} diff --git a/src/main/java/me/mofun/service/impl/FriendsServiceImpl.java b/src/main/java/me/mofun/service/impl/FriendsServiceImpl.java new file mode 100644 index 0000000..128e016 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/FriendsServiceImpl.java @@ -0,0 +1,62 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Friends; +import me.mofun.pojo.User; +import me.mofun.service.FriendsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class FriendsServiceImpl implements FriendsService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(Friends t) { + baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public Friends findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination getFriends(String userId, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from friends fs,user ur where fs.friendsId = ur.userId and fs.userId = '"+userId+"'"); + StringBuffer sql = new StringBuffer("select count(*) from friends fs,user ur where fs.friendsId = ur.userId and fs.userId = '"+userId+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("fs", Friends.class); + entityMap.put("ur", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + +} diff --git a/src/main/java/me/mofun/service/impl/GroupServiceImpl.java b/src/main/java/me/mofun/service/impl/GroupServiceImpl.java new file mode 100644 index 0000000..220ce14 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/GroupServiceImpl.java @@ -0,0 +1,226 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.User; +import me.mofun.pojo.Userbyaddress; +import me.mofun.service.GroupService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("GroupService") +public class GroupServiceImpl implements GroupService{ + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(User user) { + baseDao.saveOrUpdate(user); + } + + public void delete(Integer id) { + baseDao.delById(User.class, id); + } + + public User findById(String id) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and user.userId='"+id+"'"); + } + return (User) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + return (List)baseDao.query(hql); + } + + public void update(String hql) { + baseDao.update(hql); + } + + public User phoneLogin(String phone,String userPwd) { + StringBuffer hql = new StringBuffer(); + if(StringUtils.isNotBlank(phone) && StringUtils.isNotBlank(userPwd)){ + hql.append("from User user where user.phone ='"+phone+"' and user.userPwd ='"+userPwd+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public User mailLogin(String mail,String userPwd) { + StringBuffer hql = new StringBuffer(); + if(StringUtils.isNotBlank(mail) && StringUtils.isNotBlank(userPwd)){ + hql.append("from User user where user.mail ='"+mail+"' and user.userPwd ='"+userPwd+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public User userByName(String userName) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(userName)){ + hql.append(" and user.phone='"+userName+"' or user.mail='"+userName+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public List getUserbyaddress(String userId) { + StringBuffer hql = new StringBuffer("select us.* from userbyaddress us where us.userId = '"+userId+"'"); + Map entityMap = new HashMap(); + entityMap.put("us", Userbyaddress.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public void addAddress(Userbyaddress userbyaddress) { + baseDao.saveOrUpdate(userbyaddress); + } + + public void delAddress(Integer id) { + baseDao.delById(Userbyaddress.class, id); + } + + public Userbyaddress findAddressById(Integer id) { + StringBuffer hql = new StringBuffer("from Userbyaddress userbyaddress where id='"+id+"'"); + return (Userbyaddress) baseDao.loadObject(hql.toString()); + } + + public void setDefaultAddress(String userId,Integer id) { + StringBuffer hql = new StringBuffer("update Userbyaddress u set u.status = 0 where u.userId='"+userId+"' and u.id <> '"+id+"'"); + baseDao.update(hql.toString()); + } + + public void defaultAddress(String userId,Integer id) { + StringBuffer hql = new StringBuffer("update Userbyaddress u set u.status = 1 where u.userId='"+userId+"' and u.id = '"+id+"'"); + baseDao.update(hql.toString()); + } + + /** + * @author lwgboy + * 根据登陆邮箱更新对应的激活Key + * @param mail 登陆邮箱 + * @param key 激活Key + * @return 更新的记录条数 + */ + public int updateKey(String mail,String key) { + StringBuffer hql = new StringBuffer("update User u set u.key = '"+key+"' where u.mail='"+mail+"'"); + return baseDao.update(hql.toString()); + } + + public User isUserName(String userName,String userId) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(userName)){ + hql.append(" and user.userName='"+userName+"' and user.userId <> '"+userId+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public List loadAll() { + StringBuffer sql = new StringBuffer("from User u where 1=1 and u.userPwd = 'pwd.ipdz.me'"); + List list = baseDao.find(sql.toString()); + return list; + } + + public User userByIsUserName(String userName) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(userName)){ + hql.append(" and user.userName='"+userName+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public Pagination getInvitedList(String userId,int pageNo,int pageSize) { + StringBuffer hql = new StringBuffer("select * from user u where u.invite = '"+userId+"' order by u.oldDate desc"); +// StringBuffer sql = new StringBuffer("select count(*) from user u where u.invite = '"+userId+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("u", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer getInvitedListByCount(String userId) { + StringBuffer sql = new StringBuffer("select count(*) from user u where u.invite = '"+userId+"'"); + return baseDao.getAllNum(sql); + } + + public List getInvitedListByData(String userId) { + StringBuffer hql = new StringBuffer("select u.* from user u where u.invite = '"+userId+"'"); + Map entityMap = new HashMap(); + entityMap.put("u", User.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public Pagination adminUserList(String typeId,String keyword,String orderName,int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from user u where 1=1 and u.userType = 0 and u.userPwd <> 'pwd.ipdz.me' "); + if(StringUtils.isNotBlank(typeId) && StringUtils.isNotBlank(keyword)){ + if(typeId.equals("userId")){ + hql.append(" and u.userId='"+keyword+"'"); + } + if(typeId.equals("userName")){ + hql.append(" and u.userName='"+keyword+"'"); + } + if(typeId.equals("mail")){ + hql.append(" and u.mail='"+keyword+"'"); + } + if(typeId.equals("phone")){ + hql.append(" and u.phone='"+keyword+"'"); + } + } + if(StringUtils.isNotBlank(orderName)){ + hql.append(" order by u."+orderName+" desc"); + }else{ + hql.append(" order by u.oldDate desc"); + } + StringBuffer sql = new StringBuffer("select count(*) from user u where 1=1 and u.userType = 0 and u.userPwd <> 'pwd.ipdz.me' "); + if(StringUtils.isNotBlank(typeId) && StringUtils.isNotBlank(keyword)){ + if(typeId.equals("userId")){ + sql.append(" and u.userId='"+keyword+"'"); + } + if(typeId.equals("userName")){ + sql.append(" and u.userName='"+keyword+"'"); + } + if(typeId.equals("mail")){ + sql.append(" and u.mail='"+keyword+"'"); + } + if(typeId.equals("phone")){ + sql.append(" and u.phone='"+keyword+"'"); + } + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("u", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Integer getCountUser() { + StringBuffer sql = new StringBuffer("select count(*) from user"); + return baseDao.getAllNum(sql); + } + + public User isNotOpenId(String openId) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(openId)){ + hql.append(" and user.qqOpenId='"+openId+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + + +} diff --git a/src/main/java/me/mofun/service/impl/LatestlotteryServiceImpl.java b/src/main/java/me/mofun/service/impl/LatestlotteryServiceImpl.java new file mode 100644 index 0000000..ca9fbd1 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/LatestlotteryServiceImpl.java @@ -0,0 +1,192 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.LatestlotteryService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service("latestlotteryService") +public class LatestlotteryServiceImpl implements LatestlotteryService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public Pagination LatestAnnounced(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from latestlottery order by AnnouncedTime desc"); + StringBuffer sql = new StringBuffer("select count(*) from latestlottery"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public void add(Latestlottery t) { + baseDao.saveOrUpdate(t); + + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public Latestlottery findById(String id) { + StringBuffer hql = new StringBuffer("from Latestlottery ly where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and ly.spellbuyProductId='"+id+"'"); + } + return (Latestlottery) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + return (List) baseDao.query(hql); + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public List getBuyHistoryByDetail(Integer spellbuyProductId) { + StringBuffer hql = new StringBuffer("select * from latestlottery ly where ly.spellbuyProductId = '"+spellbuyProductId+"'"); + Map entityMap = new HashMap(); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + public Pagination getProductByUser(String userId, String startDate,String endDate,int pageNo,int pageSize) { + StringBuffer hql = new StringBuffer("select * from latestlottery ly where ly.userId = '"+userId+"'"); +// StringBuffer sql = new StringBuffer("select count(*) from latestlottery ly where ly.userId = '"+userId+"'"); + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and ly.announcedTime >='"+startDate+"'"); +// sql.append(" and ly.announcedTime >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and ly.announcedTime <='"+endDate+"'"); +// sql.append(" and ly.announcedTime <='"+endDate+"'"); + } + hql.append(" order by ly.announcedTime desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer getProductByUserByCount(String userId,String startDate,String endDate){ + StringBuffer sql = new StringBuffer("select count(*) from latestlottery ly where ly.userId = '"+userId+"'"); + if(StringUtils.isNotBlank(startDate)){ + sql.append(" and ly.announcedTime >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + sql.append(" and ly.announcedTime <='"+endDate+"'"); + } + return baseDao.getAllNum(sql); + } + + public List indexWinningScroll() { + StringBuffer hql = new StringBuffer("select * from latestlottery ly order by ly.announcedTime desc limit 6"); + Map entityMap = new HashMap(); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + /** + * 最新 揭晓/开奖 详情 + */ + public List getLotteryDetail(Integer spellbuyProductId) { + StringBuffer hql = new StringBuffer("select * from latestlottery ly where ly.spellbuyProductId = '"+spellbuyProductId+"'"); + Map entityMap = new HashMap(); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + public Integer getCountByLotteryDetail(String spellbuyProductId) { + StringBuffer hql = new StringBuffer("select count(DISTINCT buyer) from spellbuyrecord where fkSpellbuyProductId = '"+spellbuyProductId+"'"); + return baseDao.getAllNum(hql); + } + + public Pagination getLotteryDetailBybuyerList(Integer SpellbuyProductId,int pageNo,int pageSize) { + StringBuffer hql = new StringBuffer("select * from user ur,randomnumber rr where rr.userId=ur.userId and rr.productId= '"+SpellbuyProductId+"' order by rr.buyDate desc "); +// StringBuffer sql = new StringBuffer("select count(*) from user ur,randomnumber rr where rr.userId=ur.userId and rr.productId = '"+SpellbuyProductId+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("rr", Randomnumber.class); + entityMap.put("ur", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer getLotteryDetailBybuyerListByCount(Integer SpellbuyProductId){ + StringBuffer sql = new StringBuffer("select count(*) from user ur,randomnumber rr where rr.userId=ur.userId and rr.productId = '"+SpellbuyProductId+"'"); + return baseDao.getAllNum(sql); + } + + public List getProductOtherWinUser(String productId, String shareId) { + StringBuffer hql = new StringBuffer("select * from latestlottery where productId = '"+productId+"' and shareId <> '"+shareId+"' limit 6"); + Map entityMap = new HashMap(); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + public List getLatestlotteryBySpellbuyProductIdAndProductIdIsExist( + Integer SpellbuyProductId) { + StringBuffer hql = new StringBuffer("select * from latestlottery ly where ly.spellbuyProductId = '"+SpellbuyProductId+"' limit 1"); + Map entityMap = new HashMap(); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + public Latestlottery findLatestlotteryByspellbuyrecordId(Integer spellbuyrecordId) { + StringBuffer hql = new StringBuffer("from Latestlottery latestlottery where latestlottery.spellbuyRecordId='"+spellbuyrecordId+"' "); + return (Latestlottery) baseDao.loadObject(hql.toString()); + } + + public List orderDetailListById(String id) { + StringBuffer hql = new StringBuffer("select * from orderdetail ol where ol.orderDetailId = '"+id+"'"); + Map entityMap = new HashMap(); + entityMap.put("ol", Orderdetail.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + public OrderDetailAddress orderDetailAddressFindByOrderDetailId(String id) { + StringBuffer hql = new StringBuffer("from OrderDetailAddress os where os.orderDetailId = '"+id+"'"); + + return (OrderDetailAddress) baseDao.loadObject(hql.toString()); + } + + public void addOrderDetailAddress(OrderDetailAddress orderdetailaddress) { + baseDao.saveOrUpdate(orderdetailaddress); + } + +} diff --git a/src/main/java/me/mofun/service/impl/LotteryproductutilServiceImpl.java b/src/main/java/me/mofun/service/impl/LotteryproductutilServiceImpl.java new file mode 100644 index 0000000..929ee8f --- /dev/null +++ b/src/main/java/me/mofun/service/impl/LotteryproductutilServiceImpl.java @@ -0,0 +1,45 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.pojo.Lotteryproductutil; +import me.mofun.service.LotteryproductutilService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class LotteryproductutilServiceImpl implements LotteryproductutilService { + @Autowired + BaseDAO baseDAO; + + public void add(Lotteryproductutil t) { + this.baseDAO.saveOrUpdate(t); + } + + public void delete(Integer id) { + this.baseDAO.delById(Lotteryproductutil.class,id); + } + + public Lotteryproductutil findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + return (List) this.baseDAO.query(hql); + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + /** + * @return 获取所有的开奖工具列表 + */ + public List loadAll() { + return (List) this.baseDAO.query("from Lotteryproductutil lotteryproductutil where 1=1"); + } + +} diff --git a/src/main/java/me/mofun/service/impl/MessageServiceImpl.java b/src/main/java/me/mofun/service/impl/MessageServiceImpl.java new file mode 100644 index 0000000..48b99e3 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/MessageServiceImpl.java @@ -0,0 +1,42 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.pojo.Message; +import me.mofun.service.MessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class MessageServiceImpl implements MessageService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(Message t) { + baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public Message findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/me/mofun/service/impl/NewsReplyServiceImpl.java b/src/main/java/me/mofun/service/impl/NewsReplyServiceImpl.java new file mode 100644 index 0000000..ed0e1c9 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/NewsReplyServiceImpl.java @@ -0,0 +1,130 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.NewsReply; +import me.mofun.pojo.User; +import me.mofun.service.NewsReplyService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class NewsReplyServiceImpl implements NewsReplyService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(NewsReply t) { + baseDao.saveOrUpdate(t); + + } + + public void delete(Integer id) { + baseDao.delById(NewsReply.class, id); + } + + public NewsReply findById(String id) { + StringBuffer hql = new StringBuffer("from NewsReply n where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and n.replyId='"+id+"'"); + } + return (NewsReply) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination newsReplyList(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from newsReply n order by postDate desc"); + StringBuffer sql = new StringBuffer("select count(*) from newsReply"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("n", NewsReply.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Pagination newsReplyList(int newsId,int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from newsReply n where newsId=" + newsId + " order by postDate desc"); + StringBuffer sql = new StringBuffer("select count(*) from news where newsId=" + newsId); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("n", NewsReply.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public List indexNewsReply() { + StringBuffer sql = new StringBuffer("select * from newsReply n order by postDate desc limit 5"); + Map entityMap = new HashMap(); + entityMap.put("n", NewsReply.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + public List indexNewsReply(Integer recordCount) { + String limitStr=""; + if(recordCount!=null) + limitStr=" limit "+recordCount.intValue(); + StringBuffer sql= new StringBuffer("select * from newsReply n,user u where n.userId=u.userId order by n.postDate desc "+ limitStr); + Map entityMap = new HashMap(); + entityMap.put("n", NewsReply.class); + entityMap.put("u", User.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + /** + * 获得某新闻话题的回复信息列表 + * Author:lwgboy + * @newsId 主题新闻信息ID + * @recordCount 控制返回的记录数 + */ + public List indexNewsReply(int newsId,Integer recordCount) { + String limitStr=""; + if(recordCount!=null) + limitStr=" limit "+recordCount.intValue(); + //StringBuffer sql = new StringBuffer("select * from newsReply n where newsId=" + newsId + " order by postDate desc "+ limitStr); + StringBuffer sql= new StringBuffer("select * from newsReply n,user u where n.newsId="+newsId+" and n.userId=u.userId order by n.postDate desc "+ limitStr); + Map entityMap = new HashMap(); + entityMap.put("n", NewsReply.class); + entityMap.put("u", User.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + public List hotReply(Integer recordCount) { + return null; + } + + + + + + + + +} diff --git a/src/main/java/me/mofun/service/impl/NewsServiceImpl.java b/src/main/java/me/mofun/service/impl/NewsServiceImpl.java new file mode 100644 index 0000000..b8159b5 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/NewsServiceImpl.java @@ -0,0 +1,104 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.News; +import me.mofun.service.NewsService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class NewsServiceImpl implements NewsService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(News t) { + baseDao.saveOrUpdate(t); + + } + + public void delete(Integer id) { + baseDao.delById(News.class, id); + } + + public News findById(String id) { + StringBuffer hql = new StringBuffer("from News n where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and n.newsId='"+id+"'"); + } + return (News) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination newsList(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from news n order by postDate desc"); + StringBuffer sql = new StringBuffer("select count(*) from news"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("n", News.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Pagination newsList(int categoryId,int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from news n where categoryId=" + categoryId + " order by postDate desc"); + StringBuffer sql = new StringBuffer("select count(*) from news where categoryId=" + categoryId); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("n", News.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public List indexNews() { + StringBuffer sql = new StringBuffer("select * from news n order by postDate desc limit 5"); + Map entityMap = new HashMap(); + entityMap.put("n", News.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + /** + * 获得信息列表 + * Author:lwgboy + * @categoryId 信息类别ID,1表示新闻 + * @recordCount 控制返回的记录数 + */ + public List indexNews(int categoryId,Integer recordCount) { + String limitStr=""; + if(recordCount!=null) + limitStr=" limit "+recordCount.intValue(); + StringBuffer sql = new StringBuffer("select * from news n where categoryId=" + categoryId + " order by postDate desc "+ limitStr); + Map entityMap = new HashMap(); + entityMap.put("n", News.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + +} diff --git a/src/main/java/me/mofun/service/impl/NewsTypeServiceImpl.java b/src/main/java/me/mofun/service/impl/NewsTypeServiceImpl.java new file mode 100644 index 0000000..fa96bdb --- /dev/null +++ b/src/main/java/me/mofun/service/impl/NewsTypeServiceImpl.java @@ -0,0 +1,113 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.News; +import me.mofun.pojo.NewsType; +import me.mofun.service.NewsTypeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class NewsTypeServiceImpl implements NewsTypeService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(NewsType t) { + baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + baseDao.delById(News.class, id); + } + + public NewsType findById(String id) { + StringBuffer hql = new StringBuffer("from NewsType n where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and n.id='"+id+"'"); + } + return (NewsType) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination newsTypeList(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from newsType n order by id desc"); + StringBuffer sql = new StringBuffer("select count(*) from newsType"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("n", NewsType.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + + + public Pagination newsTypeList(int Id,int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from newsType n where Id=" + Id + " order by Id desc"); + StringBuffer sql = new StringBuffer("select count(*) from news where Id=" + Id); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("n", NewsType.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + + public List indexNewsType() { + StringBuffer sql = new StringBuffer("select * from newsType n order by id"); + Map entityMap = new HashMap(); + entityMap.put("n", NewsType.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + /** + * 获取不同级别的信息级别列表 + * @param parentId 父级别ID + * @return + */ + public List indexNewsTypeByParentId(int parentId) { + StringBuffer sql = new StringBuffer("select * from newsType n where parentId="+parentId +" and categoryName is not null order by id"); + Map entityMap = new HashMap(); + entityMap.put("n", NewsType.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + /** + * 获取不同级别的信息级别列表 + * @param parentId 父级别ID + * @return + */ + public List indexNewsTypeByParentIdX(int parentId) { + StringBuffer hql = new StringBuffer("select * from newsType n where n.parentId="+parentId +" and n.categoryName is not null order by id"); + return this.baseDao.querySQL(hql.toString()); + } + +} diff --git a/src/main/java/me/mofun/service/impl/OrderDetailAddressServiceImpl.java b/src/main/java/me/mofun/service/impl/OrderDetailAddressServiceImpl.java new file mode 100644 index 0000000..3783a0a --- /dev/null +++ b/src/main/java/me/mofun/service/impl/OrderDetailAddressServiceImpl.java @@ -0,0 +1,75 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.OrderDetailAddress; +import me.mofun.service.OrderDetailAddressService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class OrderDetailAddressServiceImpl implements OrderDetailAddressService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(OrderDetailAddress t) { + this.baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public OrderDetailAddress findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination orderDetailAddressList(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from orderdetailaddress os order by os.deliverTime desc"); + StringBuffer sql = new StringBuffer("select count(*) from orderdetailaddress"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("os", OrderDetailAddress.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Pagination getShopOrderDetailAddressList(Integer userId,int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from orderdetailaddress os order by os.deliverTime desc"); + StringBuffer sql = new StringBuffer("select count(*) from orderdetailaddress"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("os", OrderDetailAddress.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + +} diff --git a/src/main/java/me/mofun/service/impl/OrderdetailServiceImpl.java b/src/main/java/me/mofun/service/impl/OrderdetailServiceImpl.java new file mode 100644 index 0000000..9f689d7 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/OrderdetailServiceImpl.java @@ -0,0 +1,40 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.pojo.Orderdetail; +import me.mofun.service.OrderdetailService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class OrderdetailServiceImpl implements OrderdetailService { + @Autowired + BaseDAO baseDAO; + + public void add(Orderdetail t) { + this.baseDAO.saveOrUpdate(t); + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public Orderdetail findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/me/mofun/service/impl/ProductImageServiceImpl.java b/src/main/java/me/mofun/service/impl/ProductImageServiceImpl.java new file mode 100644 index 0000000..4ef0aa8 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/ProductImageServiceImpl.java @@ -0,0 +1,95 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.pojo.ProductImage; +import me.mofun.service.ProductImageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("productImageService") +public class ProductImageServiceImpl implements ProductImageService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(ProductImage t) { + baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + baseDao.delById(ProductImage.class, id); + } + + public ProductImage findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public List findByProductId(String productId, String type) { + StringBuffer hql = new StringBuffer("select pe.* from productimage pe where pe.productId = '"+productId+"' and pe.isShow = '"+type+"' order by pe.image asc"); + Map entityMap = new HashMap(); + entityMap.put("pe", ProductImage.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public List findByProductIdByUserId(Integer userId, String productId, String type) { + StringBuffer hql = new StringBuffer("select pe.* from productimage pe where pe.userId="+userId+" and pe.productId = '"+productId+"' and pe.isShow = '"+type+"' order by pe.image asc"); + Map entityMap = new HashMap(); + entityMap.put("pe", ProductImage.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public List findByUserId(Integer userId) { + StringBuffer hql = new StringBuffer("select pe.* from productimage pe where pe.userId = "+userId+" order by pe.image asc"); + Map entityMap = new HashMap(); + entityMap.put("pe", ProductImage.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + /** + * 根据用户Id,获取其所有同事所上传的照片 + * @param userId + * @return + */ + public List findAllColleagueUploadImgByUserId(Integer userId) { + StringBuffer hql = new StringBuffer("select pe.* from productimage pe where pe.userId in (select userId from user u where u.shopId in (select s.shopId from shop s where s.originatorId = "+userId +")) order by pe.image asc"); + Map entityMap = new HashMap(); + entityMap.put("pe", ProductImage.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public List findByShopId(Integer shopId) { + StringBuffer hql = new StringBuffer("select pe.* from productimage pe where pe.shopId = "+shopId+" order by pe.image asc"); + Map entityMap = new HashMap(); + entityMap.put("pe", ProductImage.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public List getAllList() { + StringBuffer hql = new StringBuffer("select pe.* from productimage pe order by pe.image asc"); + Map entityMap = new HashMap(); + entityMap.put("pe", ProductImage.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + +} diff --git a/src/main/java/me/mofun/service/impl/ProductServiceImpl.java b/src/main/java/me/mofun/service/impl/ProductServiceImpl.java new file mode 100644 index 0000000..d3d2ef1 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/ProductServiceImpl.java @@ -0,0 +1,248 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Product; +import me.mofun.pojo.ProductType; +import me.mofun.pojo.Spellbuyproduct; +import me.mofun.service.ProductService; +import me.mofun.util.StringUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("productService") +public class ProductServiceImpl implements ProductService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(Product t) { + baseDao.saveOrUpdate(t); + + } + + public void delete(Integer id) { + baseDao.delById(Product.class, id); + } + + public void update(String hql) { + baseDao.update(hql); + } + + public Product findById(String id) { + StringBuffer hql = new StringBuffer("from Product product where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and product.productId='"+id+"'"); + } + return (Product) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + + return (List) baseDao.query(hql); + } + + public Pagination searchSpellbuyproduct(String keyword,String orderName, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select pt.*,st.* from product pt,spellbuyproduct st where st.fkProductId=pt.productId"); + StringBuffer sql = new StringBuffer("select count(DISTINCT(pt.productId)) from product pt,spellbuyproduct st where st.fkProductId=pt.productId "); + if(StringUtil.isNotBlank(keyword)){ + hql.append(" and pt.productName like '%"+keyword+"%'"); + sql.append(" and pt.productName like '%"+keyword+"%'"); + } + if(orderName.equals("hot")){ + hql.append(" and (st.spellbuyCount > (pt.productPrice/2)) GROUP by st.spellbuyProductId order by st.spellbuyCount desc"); + sql.append(" and (st.spellbuyCount > (pt.productPrice/2))"); + } + if(orderName.equals("date")){ + hql.append(" GROUP by st.spellbuyProductId order by st.spellbuyStartDate desc"); + } + if(orderName.equals("price")){ + hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice desc"); + } + if(orderName.equals("priceAsc")){ + hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice asc"); + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Pagination searchProduct(String typeId,String keyword, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select pt.* from product pt where 1=1"); + StringBuffer sql = new StringBuffer("select count(*) from product pt where 1=1"); + if(StringUtil.isNotBlank(typeId)){ + hql.append(" and pt.productType = '"+typeId+"'"); + sql.append(" and pt.productType = '"+typeId+"'"); + StringBuffer _hql = new StringBuffer("from ProductType p where p.ftypeId ='"+typeId +"' and p.attribute70='type'" ); + List objList = (List) baseDao.query(_hql.toString()); + if(objList != null && objList.size()>0){ + for (ProductType producttype : objList) { + hql.append(" or (pt.productType= '"+producttype.getTypeId()+"')"); + sql.append(" or (pt.productType= '"+producttype.getTypeId()+"')"); + } + } + } + if(StringUtil.isNotBlank(keyword)){ + hql.append(" and pt.productName like '%"+keyword+"%'"); + sql.append(" and pt.productName like '%"+keyword+"%'"); + } + hql.append(" order by pt.productId desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Pagination searchProductByUserId(Integer userId,String typeId,String keyword, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select pt.* from product pt where 1=1 and authorId="+userId); + StringBuffer sql = new StringBuffer("select count(*) from product pt where 1=1 and authorId="+userId); + if(StringUtil.isNotBlank(typeId)){ + hql.append(" and pt.productType = '"+typeId+"'"); + sql.append(" and pt.productType = '"+typeId+"'"); + StringBuffer _hql = new StringBuffer("from ProductType p where p.ftypeId ='"+typeId +"' and p.attribute70='type'" ); + List objList = (List) baseDao.query(_hql.toString()); + if(objList != null && objList.size()>0){ + for (ProductType producttype : objList) { + hql.append(" or (pt.productType= '"+producttype.getTypeId()+"')"); + sql.append(" or (pt.productType= '"+producttype.getTypeId()+"')"); + } + } + } + if(StringUtil.isNotBlank(keyword)){ + hql.append(" and pt.productName like '%"+keyword+"%'"); + sql.append(" and pt.productName like '%"+keyword+"%'"); + } + hql.append(" order by pt.productId desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Pagination searchProductByShopId(Integer shopId,String typeId,String keyword, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select pt.* from product pt where 1=1 and shopId="+shopId); + StringBuffer sql = new StringBuffer("select count(*) from product pt where 1=1 and shopId="+shopId); + if(StringUtil.isNotBlank(typeId)){ + hql.append(" and pt.productType = '"+typeId+"'"); + sql.append(" and pt.productType = '"+typeId+"'"); + StringBuffer _hql = new StringBuffer("from ProductType p where p.ftypeId ='"+typeId +"' and p.attribute70='type'" ); + List objList = (List) baseDao.query(_hql.toString()); + if(objList != null && objList.size()>0){ + for (ProductType producttype : objList) { + hql.append(" or (pt.productType= '"+producttype.getTypeId()+"')"); + sql.append(" or (pt.productType= '"+producttype.getTypeId()+"')"); + } + } + } + if(StringUtil.isNotBlank(keyword)){ + hql.append(" and pt.productName like '%"+keyword+"%'"); + sql.append(" and pt.productName like '%"+keyword+"%'"); + } + hql.append(" order by pt.productId desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + + public Product findProductByName(String productName) { + StringBuffer hql = new StringBuffer("from Product product where 1=1"); + if(StringUtils.isNotBlank(productName)){ + hql.append(" and product.productName='"+productName+"'"); + } + return (Product) baseDao.loadObject(hql.toString()); + } + + public Pagination ProductListByTypeIdList(String typeId, String orderName, + int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from product pt where pt.status = 1"); + StringBuffer sql = new StringBuffer("select count(*) from product pt where pt.status = 1"); + if(typeId!=null && !typeId.equals("")){ + hql.append(" and (1=2"); + sql.append(" and (1=2"); + hql.append(" or (pt.productType= '"+typeId+"')"); + sql.append(" or (pt.productType= '"+typeId+"')"); + StringBuffer _hql = new StringBuffer("from ProductType p where p.ftypeId ='"+typeId+"' and p.attribute70='type'"); + List objList = (List) baseDao.query(_hql.toString()); + if(objList != null && objList.size()>0){ + for (ProductType producttype : objList) { + hql.append(" or (pt.productType= '"+producttype.getTypeId()+"')"); + sql.append(" or (pt.productType= '"+producttype.getTypeId()+"')"); + } + } + hql.append(")"); + sql.append(")"); + } +// if(orderName.equals("hot")){ +// hql.append(" GROUP by st.spellbuyProductId order by st.spellbuyCount desc"); +// } +// if(orderName.equals("date")){ +// hql.append(" GROUP by st.spellbuyProductId order by st.spellbuyStartDate desc"); +// } +// if(orderName.equals("price")){ +// hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice desc"); +// } +// if(orderName.equals("priceAsc")){ +// hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice asc"); +// } +// if(orderName.equals("about")){ +// hql.append(" and (st.spellbuyCount > (pt.productPrice/1.5)) GROUP by pt.productId order by st.spellbuyCount desc"); +// sql.append(" and (st.spellbuyCount > (pt.productPrice/1.5))"); +// } +// if(orderName.equals("surplus")){ +// hql.append(" GROUP by pt.productId order by (pt.productPrice -st.spellbuyCount) asc"); +// } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public boolean deleteByUserId(Integer userId,Integer productId) { + String sql = "delete from Product where authorId="+userId+" and product="+productId; + int cnt = baseDao.update(sql); + if(cnt>0) + return true; + else + return false; + } + +} diff --git a/src/main/java/me/mofun/service/impl/ProductTypeServiceImpl.java b/src/main/java/me/mofun/service/impl/ProductTypeServiceImpl.java new file mode 100644 index 0000000..aec2165 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/ProductTypeServiceImpl.java @@ -0,0 +1,182 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.pojo.ProductType; +import me.mofun.service.ProductTypeService; +import me.mofun.test.tree.MenuNode; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class ProductTypeServiceImpl implements ProductTypeService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(ProductType t) { + baseDao.saveOrUpdate(t); + + } + + public void delete(Integer id) { + baseDao.delById(ProductType.class, id); + + } + + public ProductType findById(String id) { + StringBuffer hql = new StringBuffer("from ProductType p where 1=1 and p.attribute70='type'"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and p.typeId='"+id+"'"); + } + return (ProductType) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + /** + * 获取所有的产品类型(包含暂时不想在前台展示的),主要用于后台管理( AdminIndexAction.java -> productTypeList()) + */ + public List queryAllProductType() { + String hql = " from ProductType p where 1=1 and p.attribute70='type' order by fTypeId,sequence"; + return (List)baseDao.query(hql); + } + + public List listByProductList() { + String hql = " from ProductType p where 1=1 and p.ftypeId = '1000' and p.attribute70='type' and isShow=1"; + return (List)baseDao.query(hql); + } + + /** + * 根据 父Id 获取该 父Id 下的产品类型 + */ + public List listByProductListBybrand(String ParentTypeId){ + String hql = " from ProductType p where 1=1 and p.ftypeId = '"+ParentTypeId+"' and p.attribute70='type' and isShow=1"; + return (List)baseDao.query(hql); + } + + /** + * 根据 父Id 获取该 父Id 下的品牌类型 + */ + public List listByBrand(String id,Integer isShow) { + StringBuffer hql = new StringBuffer("from ProductType p where 1=1 and p.attribute70='brand' "); + if(StringUtils.isNotBlank(id)){ + hql.append(" and p.ftypeId='"+id+"' "); + } + if(isShow!=null) + { + hql.append(" and p.isShow='"+isShow.toString()+"' "); + } + return (List)baseDao.query(hql.toString()); + } + + /** + * 获取所有的品牌列表,供后台管理端使用(AdminIndexAction.java->productBrandList(...)) + * @author lwgboy + * @param parentId + * @return + */ + public List listByBrandAll(String parentId) { + return listByBrand(parentId,null); + } + + /** + * 获取所有要显示的品牌列表,供前台展示使用(AdminIndexAction.java->productBrandList(...)) + */ + public List listByBrand(String parentId) { + return listByBrand(parentId,1); + } + + + public ProductType findBrandById(String id) { + StringBuffer hql = new StringBuffer("from ProductType p where 1=1 and p.attribute70='brand' "); + if(StringUtils.isNotBlank(id)){ + hql.append(" and p.typeId='"+id+"'"); + } + return (ProductType) baseDao.loadObject(hql.toString()); + } + + public ProductType findBrandByName(String name) { + StringBuffer hql = new StringBuffer("from ProductType p where 1=1 and p.typeName='"+name+"' and p.attribute70='brand' "); + return (ProductType) baseDao.loadObject(hql.toString()); + } + + public ProductType findTypeByName(String name) { + StringBuffer hql = new StringBuffer("from ProductType p where 1=1 and p.typeName='"+name+"' and p.attribute70='type' "); + return (ProductType) baseDao.loadObject(hql.toString()); + } + + + //获取产品类型树菜单相关函数实现 + private List nodes; + public void MenuTree(List nodes){ + this.nodes = nodes; + } + + public List buildTree(){ + for (MenuNode node : nodes) { + Integer id = node.getId(); + if (node.getParentId() == 0) { + build(node); + return node.getChildNodeList(); + } + } + return null; + } + + private void build(MenuNode node){ + List children = getChildren(node); + if (!children.isEmpty()) { + for (MenuNode child : children) { + Integer id = child.getId(); + build(child); + } + node.setChildNodeList(children); + } + } + + private List getChildren(MenuNode node){ + List children = new ArrayList(); + Integer id = node.getId(); + for (MenuNode child : nodes) { + if (id.equals(child.getParentId())) { + children.add(child); + } + } + return children; + } + + //获取所有产品类型目录树 + public ListgetAllProductTypeTree(){ + nodes = new ArrayList(); + + List productTypeList = queryAllProductType() ; + for(int i=0;i query(String hql) { + // TODO Auto-generated method stub + return (List)baseDao.query(hql); + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public List LotteryDetailByRandomnumber(Integer userId, Integer spellbuyProductId) { + StringBuffer hql = new StringBuffer("select * from randomnumber rr where rr.userId = '"+userId+"' and rr.productId = '"+spellbuyProductId+"' order by rr.buyDate desc"); + Map entityMap = new HashMap(); + entityMap.put("rr", Randomnumber.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public BigDecimal RandomNumberByUserBuyCount(String userId,Integer spellbuyProductId){ + StringBuffer hql = new StringBuffer("select sum(buyPrice) from spellbuyrecord where buyer = '"+userId+"' and fkSpellbuyProductId='"+spellbuyProductId+"'"); + return baseDao.getSelectSum(hql); + } + + public Randomnumber findRandomnumberByspellbuyrecordId(Integer spellbuyrecordId) { + StringBuffer hql = new StringBuffer("from Randomnumber randomnumber where randomnumber.spellbuyrecordId='"+spellbuyrecordId+"' "); + return (Randomnumber) baseDao.loadObject(hql.toString()); + } + + public Randomnumber getUserBuyCodeByBuyid(String productId, String spellbuyrecordId) { + StringBuffer hql = new StringBuffer("from Randomnumber randomnumber where randomnumber.productId='"+productId+"' and randomnumber.spellbuyrecordId='"+spellbuyrecordId+"' "); + return (Randomnumber) baseDao.loadObject(hql.toString()); + } + + + +} diff --git a/src/main/java/me/mofun/service/impl/RecommendServiceImpl.java b/src/main/java/me/mofun/service/impl/RecommendServiceImpl.java new file mode 100644 index 0000000..90f775d --- /dev/null +++ b/src/main/java/me/mofun/service/impl/RecommendServiceImpl.java @@ -0,0 +1,55 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.pojo.Product; +import me.mofun.pojo.Recommend; +import me.mofun.pojo.Spellbuyproduct; +import me.mofun.service.RecommendService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service +public class RecommendServiceImpl implements RecommendService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public Recommend findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return (List) baseDao.query(hql); + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public List getRecommend() { + StringBuffer sql = new StringBuffer("select * from recommend rd,spellbuyproduct st,product pt where rd.spellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId order by rd.date desc limit 1"); + Map entityMap = new HashMap(); + entityMap.put("rd", Recommend.class); + entityMap.put("st", Spellbuyproduct.class); + entityMap.put("pt", Product.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + public void add(Recommend t) { + this.baseDao.saveOrUpdate(t); + } + +} diff --git a/src/main/java/me/mofun/service/impl/RegionServiceImpl.java b/src/main/java/me/mofun/service/impl/RegionServiceImpl.java new file mode 100644 index 0000000..b6516c1 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/RegionServiceImpl.java @@ -0,0 +1,32 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.service.RegionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class RegionServiceImpl implements RegionService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public List getCityListByProvinceId(String provinceId) { + StringBuffer hql = new StringBuffer("select * from s_city where pid = '"+provinceId+"'"); + return this.baseDao.querySQL(hql.toString()); + } + + public List getDistrictListByCityId(String cityId) { + StringBuffer hql = new StringBuffer("select * from s_district where cid = '"+cityId+"'"); + return this.baseDao.querySQL(hql.toString()); + } + + public List getProvinceList() { + StringBuffer hql = new StringBuffer("select * from s_province"); + return this.baseDao.querySQL(hql.toString()); + } + +} diff --git a/src/main/java/me/mofun/service/impl/ShareServiceImpl.java b/src/main/java/me/mofun/service/impl/ShareServiceImpl.java new file mode 100644 index 0000000..88a43c9 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/ShareServiceImpl.java @@ -0,0 +1,271 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.service.ShareService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +@Service +public class ShareServiceImpl implements ShareService{ + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public Pagination loadPageShare(String type,int pageNo,int pageSize) { + StringBuffer hql = new StringBuffer("select so.*,se.*,ly.* from shareinfo so,shareimage se,latestlottery ly where so.productId = ly.spellbuyProductId and so.userId = ly.userId and so.uid = se.shareInfoId and so.status = 2 group by so.uid"); + StringBuffer sql = new StringBuffer("select count(DISTINCT(so.uid)) from shareinfo so,shareimage se,latestlottery ly where so.productId = ly.spellbuyProductId and so.userId = ly.userId and so.uid = se.shareInfoId and so.status = 2"); + if(type.equals("new20")){ + hql.append(" ORDER BY so.shareDate DESC"); + } + if(type.equals("hot20")){ + hql.append(" ORDER BY so.upCount DESC"); + } + if(type.equals("reply20")){ + hql.append(" ORDER BY so.replyCount DESC"); + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("so", Shareinfo.class); + entityMap.put("se", Shareimage.class); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Pagination adminShareList(String type,String status, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select so.*,ly.* from shareinfo so,latestlottery ly where so.userId = ly.userId and so.productId = ly.spellbuyProductId"); + StringBuffer sql = new StringBuffer("select count(*) from shareinfo so,latestlottery ly where so.userId = ly.userId and so.productId = ly.spellbuyProductId"); + if(StringUtils.isNotEmpty(status)){ + if(!status.equals("null")){ + hql.append(" and so.status ='"+status+"'"); + sql.append(" and so.status ='"+status+"'"); + } + } + if(type.equals("new20")){ + hql.append(" ORDER BY so.shareDate DESC"); + } + if(type.equals("hot20")){ + hql.append(" ORDER BY so.upCount DESC"); + } + if(type.equals("reply20")){ + hql.append(" ORDER BY so.replyCount DESC"); + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("so", Shareinfo.class); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + /** + * 晒单内容页 + * @param id + * @return + */ + public List shareShow(int id) { + StringBuffer sql = new StringBuffer("select {so.*},{ly.*} from shareinfo so,latestlottery ly where so.userId = ly.userId and so.productId = ly.spellbuyProductId and so.uid ='"+id+"'"); + Map entityMap = new HashMap(); + entityMap.put("so", Shareinfo.class); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + + /** + * 获取某产品的晒单列表 + * @param id + * @return + */ + public Pagination productInfoShareListByProductId(int id,int pageNo,int pageSize) { + StringBuffer hql = new StringBuffer("select {so.*}, {ly.*}, {sp.*}, {se.*}, {u.*} from shareinfo so,latestlottery ly, spellbuyproduct sp,shareimage se,user u where so.userId = ly.userId and so.productId = ly.spellbuyProductId and so.productId=sp.spellbuyproductId and se.shareinfoid=so.uid and so.userId=u.userId and sp.fkProductId='"+id+"'"); + StringBuffer sql = new StringBuffer("select count(*) from shareinfo so,latestlottery ly, spellbuyproduct sp,shareimage se,user u where so.userId = ly.userId and so.productId = ly.spellbuyProductId and so.productId=sp.spellbuyproductId and se.shareinfoid=so.uid and so.userId=u.userId and sp.fkProductId='"+id+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new LinkedHashMap(); //LinkedHashMap 的默认存储顺序就是按照压入时的顺序,因此用 LinkedHashMap,而没选用HashMap,便于后续使用时按照压入顺序获取值。 + entityMap.put("so", Shareinfo.class); + entityMap.put("ly", Latestlottery.class); + entityMap.put("sp", Spellbuyproduct.class); + entityMap.put("se", Shareimage.class); + entityMap.put("u", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public List productInfoShareListByProductId(int id) { + //StringBuffer hql = new StringBuffer("select so.*,ly.* from shareinfo so,latestlottery ly where so.userId = ly.userId and so.productId = ly.spellbuyProductId and so.uid ='"+id+"'"); + //StringBuffer sql = new StringBuffer("select count(*) from shareinfo so,latestlottery ly where so.userId = ly.userId and so.productId = ly.spellbuyProductId"); + StringBuffer hql = new StringBuffer("select {so.*}, {ly.*}, {sp.*}, {se.*}, {u.*} from shareinfo so,latestlottery ly, spellbuyproduct sp,shareimage se,user u where so.userId = ly.userId and so.productId = ly.spellbuyProductId and so.productId=sp.spellbuyproductId and se.shareinfoid=so.uid and so.userId=u.userId and sp.fkProductId='"+id+"'"); + //hql = new StringBuffer("select {soObj.*},{lyObj.*},{spObj.*},{seObj.*},{u.*} from shareinfo soObj,latestlottery lyObj, spellbuyproduct spObj,shareimage seObj where soObj.userId = lyObj.userId and soObj.productId = lyObj.spellbuyProductId and soObj.productId=spObj.spellbuyproductId and seObj.shareinfoid=soObj.uid and spObj.fkproductId='"+id+"'") ; + StringBuffer sql = new StringBuffer("select count(*) from shareinfo so,latestlottery ly, spellbuyproduct sp,shareimage si,user u where so.userId = ly.userId and so.productId = ly.spellbuyProductId and so.productId=sp.spellbuyproductId and si.shareinfoid=so.uid and so.userId=u.userId and sp.fkProductId='"+id+"'"); + Map entityMap = new LinkedHashMap(); //LinkedHashMap 的默认存储顺序就是按照压入时的顺序,因此用 LinkedHashMap,而没选用HashMap,便于后续使用时按照压入顺序获取值。 + entityMap.put("so", Shareinfo.class); + entityMap.put("ly", Latestlottery.class); + entityMap.put("sp", Spellbuyproduct.class); + entityMap.put("se", Shareimage.class); + entityMap.put("u", User.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + public void add(Shareinfo t) { + this.baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public Shareinfo findById(String id) { + StringBuffer hql = new StringBuffer("from Shareinfo shareinfo where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and shareinfo.uid='"+id+"'"); + } + return (Shareinfo) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination shareByUser(String userId, String startDate, + String endDate, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select so.*,se.*,ly.* from shareinfo so,shareimage se,latestlottery ly where so.productId = ly.spellbuyProductId and so.userId = ly.userId and so.uid = se.shareInfoId and so.status = 2 and so.userId = '"+userId+"'"); + StringBuffer sql = new StringBuffer("select count(*) from shareinfo so,latestlottery ly where so.productId = ly.spellbuyProductId and so.userId = ly.userId and so.status = 2 and so.userId = '"+userId+"' "); + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and so.shareDate >= '"+startDate+"'"); + sql.append(" and so.shareDate >= '"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and so.shareDate <='"+endDate+"'"); + sql.append(" and so.shareDate <='"+endDate+"'"); + } + hql.append(" group by so.uid order by so.shareDate desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("so", Shareinfo.class); + entityMap.put("se", Shareimage.class); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public List getShareimage(String shareId) { + StringBuffer sql = new StringBuffer("select * from shareimage se where se.shareInfoId = '"+shareId+"'"); + Map entityMap = new HashMap(); + entityMap.put("se", Shareimage.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + public void addShareImage(Shareimage shareimage) { + baseDao.saveOrUpdate(shareimage); + } + + public Pagination shareByComment(String shareId, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from sharecomments ss,user ur where ss.userId = ur.userId and ss.shareInfoId = '"+shareId+"' and ss.reCommentId is null order by createDate desc"); + StringBuffer sql = new StringBuffer("select count(*) from sharecomments ss,user ur where ss.userId = ur.userId and ss.shareInfoId = '"+shareId+"' and ss.reCommentId is null"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ss", Sharecomments.class); + entityMap.put("ur", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public List getReCommentList(String shareCommentId) { + StringBuffer sql = new StringBuffer("select * from sharecomments ss,user ur where ss.userId = ur.userId and ss.reCommentId = '"+shareCommentId+"'"); + Map entityMap = new HashMap(); + entityMap.put("ss", Sharecomments.class); + entityMap.put("ur", User.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + public void createComment(Sharecomments sharecomments) { + this.baseDao.saveOrUpdate(sharecomments); + } + + public Sharecomments findBySharecommentsId(String sharecommentsId) { + StringBuffer hql = new StringBuffer("from Sharecomments sharecomments where 1=1"); + if(StringUtils.isNotBlank(sharecommentsId)){ + hql.append(" and sharecomments.uid='"+sharecommentsId+"'"); + } + return (Sharecomments) baseDao.loadObject(hql.toString()); + } + + public List getIndexSharecommentsList() { + StringBuffer sql = new StringBuffer("select * from sharecomments ss,user ur where ss.userId = ur.userId order by ss.createDate desc limit 18"); + Map entityMap = new HashMap(); + entityMap.put("ss", Sharecomments.class); + entityMap.put("ur", User.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + public Pagination loadShareInfoByNew(String type, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select so.*,ly.* from shareinfo so,latestlottery ly where so.productId = ly.spellbuyProductId and so.userId = ly.userId and so.status = 2 group by so.uid"); + StringBuffer sql = new StringBuffer("select count(DISTINCT(so.uid)) from shareinfo so,latestlottery ly where so.productId = ly.spellbuyProductId and so.userId = ly.userId and so.status = 2"); + if(type.equals("new20")){ + hql.append(" ORDER BY so.shareDate DESC"); + } + if(type.equals("hot20")){ + hql.append(" ORDER BY so.upCount DESC"); + } + if(type.equals("reply20")){ + hql.append(" ORDER BY so.replyCount DESC"); + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("so", Shareinfo.class); + entityMap.put("ly", Latestlottery.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + +} diff --git a/src/main/java/me/mofun/service/impl/ShopServiceImpl.java b/src/main/java/me/mofun/service/impl/ShopServiceImpl.java new file mode 100644 index 0000000..fab4d7c --- /dev/null +++ b/src/main/java/me/mofun/service/impl/ShopServiceImpl.java @@ -0,0 +1,272 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Shop; +import me.mofun.pojo.User; +import me.mofun.pojo.Userbyaddress; +import me.mofun.service.ShopService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("shopService") +public class ShopServiceImpl implements ShopService{ + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(Shop shop) { + baseDao.saveOrUpdate(shop); + } + + public void delete(Integer id) { + baseDao.delById(Shop.class, id); + } + + public Shop findById(String id) { + StringBuffer hql = new StringBuffer("from Shop shop where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and shop.shopId='"+id+"'"); + } + return (Shop) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + return (List)baseDao.query(hql); + } + + public void update(String hql) { + baseDao.update(hql); + } + + public Shop phoneLogin(String phone,String userPwd) { + StringBuffer hql = new StringBuffer(); + if(StringUtils.isNotBlank(phone) && StringUtils.isNotBlank(userPwd)){ + hql.append("from Shop user where user.phone ='"+phone+"' and user.userPwd ='"+userPwd+"'"); + } + return (Shop) this.baseDao.loadObject(hql.toString()); + } + + public Shop mailLogin(String mail,String userPwd) { + StringBuffer hql = new StringBuffer(); + if(StringUtils.isNotBlank(mail) && StringUtils.isNotBlank(userPwd)){ + hql.append("from Shop user where user.mail ='"+mail+"' and user.userPwd ='"+userPwd+"'"); + } + return (Shop) this.baseDao.loadObject(hql.toString()); + } + + public Shop userByName(String userName) { + StringBuffer hql = new StringBuffer("from Shop user where 1=1"); + if(StringUtils.isNotBlank(userName)){ + hql.append(" and user.phone='"+userName+"' or user.mail='"+userName+"'"); + } + return (Shop) this.baseDao.loadObject(hql.toString()); + } + + public List getShopbyaddress(String userId) { + StringBuffer hql = new StringBuffer("select us.* from userbyaddress us where us.userId = '"+userId+"'"); + Map entityMap = new HashMap(); + entityMap.put("us", Userbyaddress.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public void addAddress(Userbyaddress userbyaddress) { + baseDao.saveOrUpdate(userbyaddress); + } + + public void delAddress(Integer id) { + baseDao.delById(Userbyaddress.class, id); + } + + public Userbyaddress findAddressById(Integer id) { + StringBuffer hql = new StringBuffer("from Userbyaddress userbyaddress where id='"+id+"'"); + return (Userbyaddress) baseDao.loadObject(hql.toString()); + } + + public void setDefaultAddress(String userId,Integer id) { + StringBuffer hql = new StringBuffer("update Userbyaddress u set u.status = 0 where u.userId='"+userId+"' and u.id <> '"+id+"'"); + baseDao.update(hql.toString()); + } + + + + public void defaultAddress(String userId,Integer id) { + StringBuffer hql = new StringBuffer("update Userbyaddress u set u.status = 1 where u.userId='"+userId+"' and u.id = '"+id+"'"); + baseDao.update(hql.toString()); + } + + /** + * @author lwgboy + * 根据登陆邮箱更新对应的激活Key + * @param mail 登陆邮箱 + * @param key 激活Key + * @return 更新的记录条数 + */ + public int updateKey(String mail,String key) { + StringBuffer hql = new StringBuffer("update Shop u set u.key = '"+key+"' where u.mail='"+mail+"'"); + return baseDao.update(hql.toString()); + } + + public Shop isShopName(String userName,String userId) { + StringBuffer hql = new StringBuffer("from Shop user where 1=1"); + if(StringUtils.isNotBlank(userName)){ + hql.append(" and user.userName='"+userName+"' and user.userId <> '"+userId+"'"); + } + return (Shop) this.baseDao.loadObject(hql.toString()); + } + + public List loadAll() { + StringBuffer sql = new StringBuffer("from Shop u where 1=1 and u.userPwd = 'pwd.ipdz.me'"); + List list = baseDao.find(sql.toString()); + return list; + } + + public Shop userByIsShopName(String userName) { + StringBuffer hql = new StringBuffer("from Shop user where 1=1"); + if(StringUtils.isNotBlank(userName)){ + hql.append(" and user.userName='"+userName+"'"); + } + return (Shop) this.baseDao.loadObject(hql.toString()); + } + + public Pagination getInvitedList(String userId,int pageNo,int pageSize) { + StringBuffer hql = new StringBuffer("select * from user u where u.invite = '"+userId+"' order by u.oldDate desc"); +// StringBuffer sql = new StringBuffer("select count(*) from user u where u.invite = '"+userId+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("u", Shop.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer getInvitedListByCount(String userId) { + StringBuffer sql = new StringBuffer("select count(*) from user u where u.invite = '"+userId+"'"); + return baseDao.getAllNum(sql); + } + + public List getInvitedListByData(String userId) { + StringBuffer hql = new StringBuffer("select u.* from user u where u.invite = '"+userId+"'"); + Map entityMap = new HashMap(); + entityMap.put("u", Shop.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public Pagination adminShopList(String typeId,String keyword,String orderName,int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from user u where 1=1 and u.userType = 0 and u.userPwd <> 'pwd.ipdz.me' "); + if(StringUtils.isNotBlank(typeId) && StringUtils.isNotBlank(keyword)){ + if(typeId.equals("userId")){ + hql.append(" and u.userId='"+keyword+"'"); + } + if(typeId.equals("userName")){ + hql.append(" and u.userName='"+keyword+"'"); + } + if(typeId.equals("mail")){ + hql.append(" and u.mail='"+keyword+"'"); + } + if(typeId.equals("phone")){ + hql.append(" and u.phone='"+keyword+"'"); + } + } + if(StringUtils.isNotBlank(orderName)){ + hql.append(" order by u."+orderName+" desc"); + }else{ + hql.append(" order by u.oldDate desc"); + } + StringBuffer sql = new StringBuffer("select count(*) from user u where 1=1 and u.userType = 0 and u.userPwd <> 'pwd.ipdz.me' "); + if(StringUtils.isNotBlank(typeId) && StringUtils.isNotBlank(keyword)){ + if(typeId.equals("userId")){ + sql.append(" and u.userId='"+keyword+"'"); + } + if(typeId.equals("userName")){ + sql.append(" and u.userName='"+keyword+"'"); + } + if(typeId.equals("mail")){ + sql.append(" and u.mail='"+keyword+"'"); + } + if(typeId.equals("phone")){ + sql.append(" and u.phone='"+keyword+"'"); + } + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("u", Shop.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Integer getCountShop() { + StringBuffer sql = new StringBuffer("select count(*) from shop"); + return baseDao.getAllNum(sql); + } + + public Shop isNotOpenId(String openId) { + StringBuffer hql = new StringBuffer("from Shop user where 1=1"); + if(StringUtils.isNotBlank(openId)){ + hql.append(" and user.qqOpenId='"+openId+"'"); + } + return (Shop) this.baseDao.loadObject(hql.toString()); + } + + public List getShopListByUserId(Integer userId,boolean isOnlyListAuditSuccess){ + StringBuffer hql = new StringBuffer("select s.* from shop s where s.originatorId = '"+userId+"'"); + if(isOnlyListAuditSuccess) //仅列出审核通过的商铺 + hql.append(" and s.status=1"); + Map entityMap = new HashMap(); + entityMap.put("s", Shop.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + /** + * 获取某用户所有的同事,包含公司状态未审核过的同事;主要用于获取其所有同事上传的所有图片用 + * @param userId + * @return + */ + public List getShopUserListByUserId(Integer userId) { + StringBuffer hql = new StringBuffer("select u.* from user u where u.shopId in (select s.shopId from shop s where s.originatorId = )"+userId); + Map entityMap = new HashMap(); + entityMap.put("u", User.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public boolean isHasAuditSucceedShop(List shopList) { + boolean hasAuditSucceedShop = false; + if(shopList!=null) + for(Shop shop :shopList) + if(shop.getStatus()==1) { + hasAuditSucceedShop=true; + break; + } + return hasAuditSucceedShop; + } + + public List getAuditSucceedShop(List shopList) { + for(Shop shop :shopList) + if(shop.getStatus()!=1) { + shopList.remove(shop); + } + return shopList; + } + + + + +} diff --git a/src/main/java/me/mofun/service/impl/SpellbuyproductServiceImpl.java b/src/main/java/me/mofun/service/impl/SpellbuyproductServiceImpl.java new file mode 100644 index 0000000..7dd55cb --- /dev/null +++ b/src/main/java/me/mofun/service/impl/SpellbuyproductServiceImpl.java @@ -0,0 +1,229 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.Product; +import me.mofun.pojo.Spellbuyproduct; +import me.mofun.pojo.Spellbuyrecord; +import me.mofun.pojo.User; +import me.mofun.service.SpellbuyproductService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("spellbuyproductService") +public class SpellbuyproductServiceImpl implements SpellbuyproductService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(Spellbuyproduct t) { + baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + baseDao.delById(Spellbuyproduct.class, id); + } + + public Spellbuyproduct findById(String id) { + StringBuffer hql = new StringBuffer("from Spellbuyproduct spellbuyproduct where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and spellbuyproduct.spellbuyProductId='"+id+"'"); + } + return (Spellbuyproduct) baseDao.loadObject(hql.toString()); + } + + /** + * 根据外键产品ID(fkProductId)返回最新一个该商品的最新拍购对象 + * @author mofun + * @param fkProductId 商品ID,非商品的拍购ID + * @return + */ + public Spellbuyproduct findByFKProductId(String fkProductId) { + StringBuffer sql = new StringBuffer("select * from Spellbuyproduct spellbuyproduct where 1=1"); + if(StringUtils.isNotBlank(fkProductId)){ + sql.append(" and spellbuyproduct.fkProductId='"+fkProductId+"' order by spellbuyproductId desc limit 1 "); + } + Spellbuyproduct obj = baseDao.loadObjectBySql(sql.toString(),Spellbuyproduct.class); + return obj; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return (List) baseDao.query(hql); + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + /** + * 商品页显示页:根据商品的拍购ID,获取拍购商品相关属性 + * + */ + public List findBySpellbuyProductId(int spellbuyProductId) { + StringBuffer sql = new StringBuffer("select pt.*,st.* from spellbuyproduct st,product pt where pt.productId = st.fkProductId and st.spellbuyProductId ="+spellbuyProductId); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + /** + * 商品页显示页:根据商品ID,获取拍购商品相关属性 + */ + public List findByFKProductId(int fkProductId) { + StringBuffer sql = new StringBuffer("select pt.*,st.* from spellbuyproduct st,product pt where pt.productId = st.fkProductId and st.fkProductId ="+fkProductId + " order by st.spellbuyProductId desc"); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + public Pagination upcomingAnnounced(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select pt.*,st.* from Product pt,Spellbuyproduct st where 1=1 and st.fkProductId=pt.productId and (st.spellbuyCount > (pt.productPrice/1.5)) and st.spStatus <> 1 GROUP by pt.productId order by st.spellbuyCount desc"); +// StringBuffer hql = new StringBuffer("select pt.*,st.* from Product pt,Spellbuyproduct st where 1=1 and st.fkProductId=pt.productId and st.spStatus <> 1 GROUP by pt.productId order by st.spellbuyCount desc"); +// StringBuffer sql = new StringBuffer("select count(DISTINCT(pt.productId)) from product pt,spellbuyproduct st where st.fkProductId=pt.productId and (st.spellbuyCount > (pt.productPrice/1.5)) and st.status <> 1"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + /** + * 人气TOP榜,用于列表页等页面下部的人气推荐栏目(isShow表示是否显示,这里只取希望在前台展示的商品)。 + * + */ + public Pagination upcomingAnnouncedByTop(int pageNo, int pageSize) { +// StringBuffer hql = new StringBuffer("select pt.*,st.* from Product pt,Spellbuyproduct st where 1=1 and st.fkProductId=pt.productId and (st.spellbuyCount > (pt.productPrice/1.5)) and st.spStatus <> 1 GROUP by pt.productId order by st.spellbuyCount desc"); + StringBuffer hql = new StringBuffer("select pt.*,st.* from Product pt,Spellbuyproduct st where 1=1 and pt.isShow=1 and st.fkProductId=pt.productId and st.spStatus <> 1 GROUP by pt.productId order by st.spellbuyCount desc"); +// StringBuffer sql = new StringBuffer("select count(DISTINCT(pt.productId)) from product pt,spellbuyproduct st where st.fkProductId=pt.productId and (st.spellbuyCount > (pt.productPrice/1.5)) and st.status <> 1"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public List productPeriodList(Integer productId) { + StringBuffer hql = new StringBuffer("select st.*,pt.* from spellbuyproduct st,product pt where st.fkProductId = pt.productId and pt.productId = '"+productId+"' order by st.productPeriod desc"); + Map entityMap = new HashMap(); + entityMap.put("st", Spellbuyproduct.class); + entityMap.put("pt", Product.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public Spellbuyproduct findSpellbuyproductLastPeriod(Integer productId){ + StringBuffer hql = new StringBuffer("from Spellbuyproduct spellbuyproduct where spellbuyproduct.fkProductId ='"+productId+"' order by spellbuyproduct.productPeriod desc limit 1"); + return (Spellbuyproduct) baseDao.loadObject(hql.toString()); + } + + public Spellbuyproduct findSpellbuyproductByStatus(Integer productId){ + StringBuffer hql = new StringBuffer("from Spellbuyproduct spellbuyproduct where spellbuyproduct.fkProductId ='"+productId+"' and spellbuyproduct.spStatus=0 "); + return (Spellbuyproduct) baseDao.loadObject(hql.toString()); + } + + public Pagination announcedProduct(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select pt.*,st.* from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus = 1"); + StringBuffer sql = new StringBuffer("select count(DISTINCT(st.spellbuyProductId)) from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus = 1"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public List loadAllByType() { + StringBuffer sql = new StringBuffer("from Spellbuyproduct st where 1=1 and st.spStatus <> 1 and st.spellbuyType = 8"); + List list = baseDao.find(sql.toString()); + return list; + } + + public List loadAll() { + StringBuffer sql = new StringBuffer("from Spellbuyproduct st where 1=1 and st.spStatus <> 1"); + List list = baseDao.find(sql.toString()); + return list; + } + + public List UpdateLatestlotteryGetList() { + StringBuffer sql = new StringBuffer("from Spellbuyproduct st where 1=1 and st.spStatus = 1"); + List list = baseDao.find(sql.toString()); + return list; + } + + public List findSpellbuyproductByProductIdIsStatus(Integer productId){ + StringBuffer hql = new StringBuffer("select * from spellbuyproduct st where st.fkProductId = '"+productId+"' and spStatus = 0"); + Map entityMap = new HashMap(); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + + /** + * 暂时废弃 + * @author lwg + * 检查限购情况,用于商品详情页 goodsdetail.js 中 ajax 调用 /products/checkUserLimitBuy.action + * http://127.0.0.1:8080/products/checkUserLimitBuy.action?id=1001 + * @param spellbuyId + * @return + */ + public List checkUserLimitBuyDetail(String spellbuyId) + { + StringBuffer sql =new StringBuffer("SELECT * FROM spellbuyproduct p, spellbuyrecord r, user u WHERE r.fkSpellbuyProductId = p.spellbuyProductId and r.buyer=u.userId and r.fkSpellbuyProductId"+spellbuyId); + Map entityMap = new HashMap(); + entityMap.put("spellbuyproduct", Spellbuyproduct.class); + entityMap.put("spellbuyrecord", Spellbuyrecord.class); + entityMap.put("user", User.class); + List list = baseDao.sqlQueryEntity(sql,entityMap); + return list; + } + + /** + * @sql SELECT * FROM spellbuyproduct p, spellbuyrecord r, user u WHERE r.fkSpellbuyProductId = p.spellbuyProductId and r.buyer=u.userId and r.fkSpellbuyProductId=10020 and u.userid=1001640353 + * @sql SELECT DISTINCT p.*,u.*, r.spellbuyRecordId, r.fkSpellbuyProductId,r.buyer,sum(r.buyPrice) as buyPrice,r.buyDate,r.buyIp,r.buyLocal,r.buySource,r.buyStatus,r.spRandomNo,r.spWinningStatus,r.Attribute_66,r.Attribute_67 FROM spellbuyproduct p, spellbuyrecord r, user u WHERE r.fkSpellbuyProductId = p.spellbuyProductId and r.buyer=u.userId and r.fkSpellbuyProductId=10020 and u.userid=1001640353 + */ + public List checkUserLimitBuy(String spellbuyId,String userId) + { + Map entityMap = new HashMap(); + entityMap.put("spellbuyproduct", Spellbuyproduct.class); + StringBuffer sql =new StringBuffer("SELECT * FROM spellbuyproduct p where p.spellbuyProductId="+spellbuyId); + if(StringUtils.isNotBlank(userId)){ + sql.setLength(0); + sql.append("SELECT DISTINCT p.*,u.*, r.spellbuyRecordId, r.fkSpellbuyProductId,r.buyer,sum(r.buyPrice) as buyPrice,r.buyDate,r.buyIp,r.buyLocal,r.buySource,r.buyStatus,r.spRandomNo,r.spWinningStatus,r.Attribute_66,r.Attribute_67 FROM spellbuyproduct p, spellbuyrecord r, user u WHERE r.fkSpellbuyProductId = p.spellbuyProductId and r.buyer=u.userId and r.fkSpellbuyProductId="+spellbuyId+" and u.userid="+userId); + entityMap.put("user", User.class); + entityMap.put("spellbuyrecord", Spellbuyrecord.class); + } + List list = baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + +} diff --git a/src/main/java/me/mofun/service/impl/SpellbuyrecordServiceImpl.java b/src/main/java/me/mofun/service/impl/SpellbuyrecordServiceImpl.java new file mode 100644 index 0000000..ae61969 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/SpellbuyrecordServiceImpl.java @@ -0,0 +1,612 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.*; +import me.mofun.pojo.vo.SpellbuyrecordExt; +import me.mofun.service.SpellbuyrecordService; +import me.mofun.util.DateUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; + +@Service("spellbuyrecordService") +public class SpellbuyrecordServiceImpl implements SpellbuyrecordService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + public void add(Spellbuyrecord t) { + baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + baseDao.delById(Spellbuyrecord.class, id); + } + + public Spellbuyrecord findById(String id) { + StringBuffer hql = new StringBuffer("from Spellbuyrecord spellbuyrecord where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and spellbuyrecord.spellbuyRecordId='"+id+"'"); + } + return (Spellbuyrecord) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + // TODO Auto-generated method stub + return (List) baseDao.query(hql); + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + /** + * 首页最热门商品 + */ + public Pagination findHotProductList(int pageNo, int pageSize) { +// StringBuffer hql = new StringBuffer("select pt.*,st.* from Product pt,Spellbuyproduct st where 1=1 and st.fkProductId=pt.productId and (st.spellbuyCount > (pt.productPrice/2)) and st.spStatus <> 1 GROUP by pt.productId order by st.spellbuyCount desc"); + StringBuffer hql = new StringBuffer("select pt.*,st.* from Product pt,Spellbuyproduct st where 1=1 and st.fkProductId=pt.productId and st.spStatus <> 1 GROUP by pt.productId order by st.spellbuyCount desc"); +// StringBuffer sql = new StringBuffer("select count(*) from Spellbuyrecord"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + + /** + * 首页最新上架商品,首页新品展示区用 + * 这里只取上架商品(Product.status=1)和要在前段展示的商品(Product.isShow=1) + */ + public Pagination indexNewProductList(int pageNo, int pageSize) { + //StringBuffer hql = new StringBuffer("select pt.*,st.* from Product pt,Spellbuyproduct st where 1=1 and st.fkProductId=pt.productId and st.spStatus <> 1 GROUP by pt.productId order by st.spellbuyStartDate desc"); + StringBuffer hql = new StringBuffer("select {pt.*},{st.*} from Product pt,Spellbuyproduct st where pt.status=1 and pt.isShow=1 and st.fkProductId=pt.productId and st.spStatus <> 1 GROUP by pt.productId order by st.spellbuyStartDate desc"); + //StringBuffer sql = new StringBuffer("select count(*) from Spellbuyrecord"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + /** + * 首页人气排行商品 + */ + public Pagination indexHotProductList(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select pt.*,st.* from Product pt,Spellbuyproduct st where 1=1 and st.fkProductId=pt.productId and st.spStatus <> 1 GROUP by pt.productId order by st.productPeriod desc"); +// StringBuffer sql = new StringBuffer("select count(*) from Spellbuyrecord"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + /** + * Ta他们正在购买 + */ + public Pagination getNowBuyList(int pageNo, int pageSize) { + Date sDate = DateUtil.subMinute(new Date(), 20); + String startDate = sdf.format(sDate); + String endDate = sdf.format(new Date()); + StringBuffer hql = new StringBuffer("select ur.*,sd.*,pt.*,st.* from User ur, Spellbuyrecord sd,Product pt,Spellbuyproduct st where 1=1 and sd.buyer=ur.userId and sd.fkSpellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId order by sd.buyDate desc"); +// StringBuffer sql = new StringBuffer("select count(*) from Spellbuyrecord"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ur", User.class); + entityMap.put("sd", Spellbuyrecord.class); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(6); + return page; + } + + /** + * 首页按商品类型查询商品 + */ + public Pagination findProductByTypeId(String typeId, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select {pt.*},{st.*} from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus <> 1"); +// StringBuffer sql = new StringBuffer("select count(*) from Spellbuyrecord"); + if(typeId!=null && !typeId.equals("")){ + hql.append(" and (1=2"); + hql.append(" or (1=1 and pt.productType= "+typeId+")"); + StringBuffer _hql = new StringBuffer("from ProductType p where p.ftypeId ='"+typeId+"'"); + List objList = (List) baseDao.query(_hql.toString()); + if(objList != null && objList.size()>0){ + for (ProductType producttype : objList) { + hql.append(" or (1=1 and pt.productType= '"+producttype.getTypeId()+"')"); + } + } + hql.append(")"); + } + hql.append(" GROUP by pt.productId"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(8); + return page; + } + + /** + * 商品页按商品类型查询商品,这里只查询上架产品(status=1) 和 在前台展示的商品(isShow=1) + */ + public Pagination ProductByTypeIdList(String typeId,String brandId,String orderName, int pageNo,int pageSize) { + //StringBuffer hql = new StringBuffer("select pt.*,st.* from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus <> 1"); + //StringBuffer sql = new StringBuffer("select count(DISTINCT(st.spellbuyProductId)) from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus <> 1"); + StringBuffer hql = new StringBuffer("select pt.*,st.* from product pt,spellbuyproduct st where pt.status=1 and pt.isShow=1 and st.fkProductId=pt.productId and st.spStatus <> 1"); + StringBuffer sql = new StringBuffer("select count(DISTINCT(st.spellbuyProductId)) from product pt,spellbuyproduct st where pt.status=1 and pt.isShow=1 and st.fkProductId=pt.productId and st.spStatus <> 1"); + if(StringUtils.isNotBlank(typeId)){ + hql.append(" and (1=2"); + sql.append(" and (1=2"); + hql.append(" or (1=1 and pt.productType= '"+typeId+"')"); + sql.append(" or (1=1 and pt.productType= '"+typeId+"')"); + StringBuffer _hql = new StringBuffer("from ProductType p where p.ftypeId ='"+typeId+"'"); + List objList = (List) baseDao.query(_hql.toString()); + if(objList != null && objList.size()>0){ + for (ProductType producttype : objList) { + hql.append(" or (1=1 and pt.productType= '"+producttype.getTypeId()+"')"); + sql.append(" or (1=1 and pt.productType= '"+producttype.getTypeId()+"')"); + } + } + hql.append(")"); + sql.append(")"); + } + if(StringUtils.isNotBlank(brandId)){ + hql.append(" and pt.productBrand='"+brandId+"'"); + sql.append(" and pt.productBrand='"+brandId+"'"); + } + if(orderName.equals("hot")){ + hql.append(" GROUP by st.spellbuyProductId order by st.spellbuyCount desc"); + } + if(orderName.equals("date")){ + hql.append(" GROUP by st.spellbuyProductId order by st.spellbuyStartDate desc"); + } + if(orderName.equals("price")){ + hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice desc"); + } + if(orderName.equals("priceAsc")){ + hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice asc"); + } + if(orderName.equals("about")){ + hql.append(" and (st.spellbuyCount > (pt.productPrice/1.5)) GROUP by pt.productId order by st.spellbuyCount desc"); + sql.append(" and (st.spellbuyCount > (pt.productPrice/1.5))"); + } + if(orderName.equals("surplus")){ + hql.append(" GROUP by pt.productId order by (pt.productPrice -st.spellbuyCount) asc"); + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + + /** + * 商品页按商品类型及所属用户查询商品 + * @param typeId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination ProductByTypeIdListAndShopId(Integer shopId,String typeId,String brandId,String orderName,int pageNo,int pageSize) { + //StringBuffer hql = new StringBuffer("select pt.*,st.* from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus <> 1"); + //StringBuffer sql = new StringBuffer("select count(DISTINCT(st.spellbuyProductId)) from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus <> 1"); + StringBuffer hql = new StringBuffer("select pt.*,st.* from product pt,spellbuyproduct st where pt.status=1 and pt.isShow=1 and pt.shopId="+shopId+" and st.fkProductId=pt.productId and st.spStatus <> 1"); + StringBuffer sql = new StringBuffer("select count(DISTINCT(st.spellbuyProductId)) from product pt,spellbuyproduct st where pt.status=1 and pt.isShow=1 and pt.shopId="+shopId+" and st.fkProductId=pt.productId and st.spStatus <> 1"); + if(StringUtils.isNotBlank(typeId)){ + hql.append(" and (1=2"); + sql.append(" and (1=2"); + hql.append(" or (1=1 and pt.productType= '"+typeId+"')"); + sql.append(" or (1=1 and pt.productType= '"+typeId+"')"); + StringBuffer _hql = new StringBuffer("from ProductType p where p.ftypeId ='"+typeId+"'"); + List objList = (List) baseDao.query(_hql.toString()); + if(objList != null && objList.size()>0){ + for (ProductType producttype : objList) { + hql.append(" or (1=1 and pt.productType= '"+producttype.getTypeId()+"')"); + sql.append(" or (1=1 and pt.productType= '"+producttype.getTypeId()+"')"); + } + } + hql.append(")"); + sql.append(")"); + } + if(StringUtils.isNotBlank(brandId)){ + hql.append(" and pt.productBrand='"+brandId+"'"); + sql.append(" and pt.productBrand='"+brandId+"'"); + } + if(orderName.equals("hot")){ + hql.append(" GROUP by st.spellbuyProductId order by st.spellbuyCount desc"); + } + if(orderName.equals("date")){ + hql.append(" GROUP by st.spellbuyProductId order by st.spellbuyStartDate desc"); + } + if(orderName.equals("price")){ + hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice desc"); + } + if(orderName.equals("priceAsc")){ + hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice asc"); + } + if(orderName.equals("about")){ + hql.append(" and (st.spellbuyCount > (pt.productPrice/1.5)) GROUP by pt.productId order by st.spellbuyCount desc"); + sql.append(" and (st.spellbuyCount > (pt.productPrice/1.5))"); + } + if(orderName.equals("surplus")){ + hql.append(" GROUP by pt.productId order by (pt.productPrice -st.spellbuyCount) asc"); + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; +} + + + + /** + * 搜索商品 + */ + public Pagination searchProduct(String keyword,String orderName, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select pt.*,st.* from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus <> 1 and pt.productName like '%"+keyword+"%'"); + StringBuffer sql = new StringBuffer("select count(DISTINCT(pt.productId)) from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus <> 1 and pt.productName like '%"+keyword+"%'"); + if(orderName.equals("hot")){ + hql.append(" GROUP by st.spellbuyProductId order by st.spellbuyCount desc"); + } + if(orderName.equals("date")){ + hql.append(" GROUP by st.spellbuyProductId order by st.spellbuyStartDate desc"); + } + if(orderName.equals("price")){ + hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice desc"); + } + if(orderName.equals("priceAsc")){ + hql.append(" GROUP by st.spellbuyProductId order by pt.productPrice asc"); + } + if(orderName.equals("about")){ + hql.append(" and (st.spellbuyCount > (pt.productPrice/1.5)) GROUP by pt.productId order by st.spellbuyCount desc"); + } + if(orderName.equals("surplus")){ + hql.append(" GROUP by pt.productId order by (pt.productPrice -st.spellbuyCount) asc"); + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + /** + * 最新参与 + * http://www.local.com/products/ajaxPage.action?id=10047&pageNo=1 + */ + public Pagination LatestParticipate(String spellbuyProductId, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select {ur.*}, {sd.*} from user ur, spellbuyrecord sd where sd.buyer=ur.userId and sd.fkSpellbuyProductId = '"+spellbuyProductId+"' order by sd.buyDate desc"); +// StringBuffer sql = new StringBuffer("select count(*) from user ur, spellbuyrecord sd where sd.buyer=ur.userId and sd.fkSpellbuyProductId ='"+spellbuyProductId+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ur", User.class); + entityMap.put("sd", Spellbuyrecord.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + /** + * 获取某商品最新参与人数,用于判断人数是否凑够,是否可开奖 + */ + public Integer LatestParticipateByCount(String spellbuyProductId){ + StringBuffer sql = new StringBuffer("select count(*) from user ur, spellbuyrecord sd where sd.buyer=ur.userId and sd.fkSpellbuyProductId ='"+spellbuyProductId+"'"); + return baseDao.getAllNum(sql); + } + + /** + * 得到某条购买记录的随机码(list 页) + */ + public List getRandomNumberList(String spellbuyProductId,String userId) { + StringBuffer hql = new StringBuffer("SELECT * from randomnumber rr where rr.productId = '"+spellbuyProductId+"' and rr.userId = '"+userId+"' limit 6"); + Map entityMap = new HashMap(); + entityMap.put("rr", Randomnumber.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + /** + * 得到某条购买记录的随机码(详细页面) + */ + public Pagination getRandomNumberListPage(String spellbuyProductId,String userId, int pageNo,int pageSize) { + StringBuffer hql = new StringBuffer("SELECT * from randomnumber rr where rr.productId = '"+spellbuyProductId+"' and rr.userId = '"+userId+"' order by rr.buyDate desc"); +// StringBuffer sql = new StringBuffer("select count(*) from randomnumber rr where rr.productId = '"+spellbuyProductId+"' and rr.userId = '"+userId+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("rr", Randomnumber.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer getRandomNumberListPageByCount(String spellbuyProductId,String userId){ + StringBuffer sql = new StringBuffer("select count(*) from randomnumber rr where rr.productId = '"+spellbuyProductId+"' and rr.userId = '"+userId+"'"); + return baseDao.getAllNum(sql); + } + + /** + * 查询某用户的购买记录 + */ + public Pagination buyHistoryByUser(String userId,String startDate,String endDate, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select st.spellbuyProductId as productId,pt.productName as productName,pt.productTitle as productTitle,pt.headImage as productImg,st.productPeriod as productPeriod,st.spStatus as buyStatus,sd.buyDate as buyTime,sum(sd.buyPrice) as buyCount,sd.spellbuyRecordId as historyId,st.spellbuyCount as spellbuyCount,st.spellbuyPrice as productPrice from spellbuyrecord sd,spellbuyproduct st,product pt,user ur where sd.fkSpellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId and sd.buyer=ur.userId and sd.buyer='"+userId+"'"); +// StringBuffer sql = new StringBuffer("select count(*) from (select count(*) from spellbuyrecord sd,spellbuyproduct st,product pt,user ur where sd.fkSpellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId and sd.buyer=ur.userId and sd.buyer='"+userId+"' "); + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and sd.buyDate >='"+startDate+"'"); +// sql.append(" and sd.buyDate >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and sd.buyDate <='"+endDate+"'"); +// sql.append(" and sd.buyDate <='"+endDate+"'"); + } + hql.append(" group by st.spellbuyProductId order by sd.buyDate desc"); +// sql.append(" group by st.spellbuyProductId) as counts"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("buyCount", BuyHistoryJSON.class); + List list = baseDao.sqlQueryBean(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer buyHistoryByUserByCount(String userId,String startDate,String endDate){ + StringBuffer sql = new StringBuffer("select count(*) from (select count(*) from spellbuyrecord sd,spellbuyproduct st,product pt,user ur where sd.fkSpellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId and sd.buyer=ur.userId and sd.buyer='"+userId+"' "); + if(StringUtils.isNotBlank(startDate)){ + sql.append(" and sd.buyDate >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + sql.append(" and sd.buyDate <='"+endDate+"'"); + } + sql.append(" group by st.spellbuyProductId) as counts"); + return baseDao.getAllNum(sql); + } + + /** + * 查询某用户购买记录详情 + * http://www.local.com/user/UserBuyDetail.action?id=10020 + */ + public List getBuyHistoryByDetail(String productId,String userId) { + StringBuffer hql = new StringBuffer("select st.spellbuyProductId as productId,pt.productName as productName,pt.productTitle as productTitle,pt.headImage as productImg,st.productPeriod as productPeriod,st.spStatus as buyStatus,sd.buyDate as buyTime,sum(sd.buyPrice) as buyCount,sd.spellbuyRecordId as historyId,st.spellbuyCount as spellbuyCount,st.spellbuyPrice as productPrice from spellbuyrecord sd,spellbuyproduct st,product pt,user ur where sd.fkSpellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId and sd.buyer=ur.userId and sd.buyer='"+userId+"' and st.spellbuyProductId='"+productId+"'"); + Map entityMap = new HashMap(); + entityMap.put("buyCount", BuyHistoryJSON.class); + List list = baseDao.sqlQueryEntityBean(hql, entityMap); + return list; + } + + public Pagination nowUpProducts(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select pt.*,st.* from product pt,spellbuyproduct st where st.fkProductId=pt.productId and st.spStatus <> 1 GROUP by st.spellbuyProductId order by st.spellbuyStartDate desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + page.setList(list); + return page; + } + + public List randomByBuyHistoryByspellbuyProductId(Integer productId,String randomNumber) { + StringBuffer hql = new StringBuffer("select * from spellbuyrecord sd,user ur,randomnumber rr where sd.buyer=ur.userId and sd.spellbuyRecordId = rr.spellbuyrecordId and sd.fkSpellbuyProductId='"+productId+"' and rr.randomNumber like '%"+randomNumber+"%'"); + Map entityMap = new HashMap(); + entityMap.put("sd", Spellbuyrecord.class); + entityMap.put("ur", User.class); + entityMap.put("rr", Randomnumber.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + public List WinRandomNumber(Integer productId,Integer randomNumber){ + StringBuffer hql = new StringBuffer("select * from user ur,randomnumber rr where ur.userId = rr.userId and ur.userPwd = 'pwd.ipdz.me' and rr.productId = '"+productId+"' and rr.randomNumber like '%"+randomNumber+"%'"); + Map entityMap = new HashMap(); + entityMap.put("ur", User.class); + entityMap.put("rr", Randomnumber.class); + List list = baseDao.sqlQueryEntity(hql, entityMap); + return list; + } + + public BigDecimal getAllByCount() { + StringBuffer hql = new StringBuffer("select sum(buyPrice) from spellbuyrecord"); + return baseDao.getSelectSum(hql); + } + + public Pagination getAllBuyRecord(String startDate, String endDate, + int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from spellbuyrecord sd,spellbuyproduct st,product pt,user ur where sd.fkSpellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId and sd.buyer=ur.userId "); + StringBuffer sql = new StringBuffer("select count(*) from spellbuyrecord sd,spellbuyproduct st,product pt,user ur where sd.fkSpellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId and sd.buyer=ur.userId "); + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and sd.buyDate >='"+startDate+"'"); + sql.append(" and sd.buyDate >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and sd.buyDate <='"+endDate+"'"); + sql.append(" and sd.buyDate <='"+endDate+"'"); + } + hql.append(" order by sd.buyDate desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("sd", Spellbuyrecord.class); + entityMap.put("st", Spellbuyproduct.class); + entityMap.put("pt", Product.class); + entityMap.put("ur", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Pagination getlotteryDetail(String startDate, String endDate, + int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from spellbuyrecord sd,spellbuyproduct st,product pt,user ur where sd.fkSpellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId and sd.buyer=ur.userId "); + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and sd.buyDate >='"+startDate+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and sd.buyDate <='"+endDate+"'"); + } + hql.append(" order by sd.buyDate desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("sd", Spellbuyrecord.class); + entityMap.put("st", Spellbuyproduct.class); + entityMap.put("pt", Product.class); + entityMap.put("ur", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + page.setList(list); + return page; + } + + public List getSpellbuyRecordByLast100(String startDate,String endDate){ + StringBuffer hql = new StringBuffer("select * from spellbuyrecord sd where 1=1"); + if(StringUtils.isNotBlank(startDate)){ + hql.append(" and sd.buyDate >='"+startDate+".000"+"'"); + } + if(StringUtils.isNotBlank(endDate)){ + hql.append(" and sd.buyDate <='"+endDate+".999"+"'"); + } + hql.append(" order by sd.buyDate desc limit 120"); + Map entityMap = new HashMap(); + entityMap.put("sd", Spellbuyrecord.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public List getEndBuyDateByProduct(Integer fkSpellbuyProductId) { + StringBuffer hql = new StringBuffer("select * from spellbuyrecord sd where fkSpellbuyProductId = '"+fkSpellbuyProductId+"' order by buyDate desc limit 1"); + Map entityMap = new HashMap(); + entityMap.put("sd", Spellbuyrecord.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public BigDecimal findSumByBuyPriceByUserId(String userId) { + StringBuffer hql = new StringBuffer("select sum(buyPrice) from spellbuyrecord where buyer = '"+userId+"'"); + return baseDao.getSelectSum(hql); + } + + /** + * http://www.local.com/products/getUserByHistory.action?id=10047 + * 获取登录用户自己的历史购买记录 + */ + public List getUserByHistory_old(String userId, String fkSpellbuyProductId) { + StringBuffer hql = new StringBuffer("select {sd.*}, {sp.*} from spellbuyrecord sd,spellbuyProduct sp where sd.buyer = '"+userId+"' and sd.fkSpellbuyProductId = '"+fkSpellbuyProductId+"' and sd.fkSpellbuyProductId=sp.SpellbuyProductId order by sd.buyDate desc limit 8") ; + Map entityMap = new LinkedHashMap(); + entityMap.put("sd", Spellbuyrecord.class); + entityMap.put("sp", Spellbuyproduct.class); + List list = baseDao.sqlQueryEntityBean(hql, entityMap); + return list; + } + + /** + * http://www.local.com/products/getUserByHistory.action?id=10047 + * 获取登录用户自己的历史购买记录 + * 转换为临时自定义对象SpellbuyrecordExt + */ + public List getUserByHistory(String userId, String fkSpellbuyProductId) { + StringBuffer hql = new StringBuffer("select sd.*,sp.spSinglePrice from spellbuyrecord sd,spellbuyProduct sp where sd.buyer = '"+userId+"' and sd.fkSpellbuyProductId = '"+fkSpellbuyProductId+"' and sd.fkSpellbuyProductId=sp.SpellbuyProductId order by sd.buyDate desc limit 8") ; + Map entityMap = new LinkedHashMap(); + entityMap.put("his", SpellbuyrecordExt.class); + List list = baseDao.sqlQueryEntityBean(hql, entityMap); + return list; + } + + public Pagination getNowBuyAjaxList(int pageNo, int pageSize, int spellbuyRecordId) { + Date sDate = DateUtil.subMinute(new Date(), 20); + String startDate = sdf.format(sDate); + String endDate = sdf.format(new Date()); + StringBuffer hql = new StringBuffer("select ur.*,sd.*,pt.*,st.* from User ur, Spellbuyrecord sd,Product pt,Spellbuyproduct st where 1=1 and sd.buyer=ur.userId and sd.fkSpellbuyProductId=st.spellbuyProductId and st.fkProductId=pt.productId and sd.spellbuyRecordId > '"+spellbuyRecordId+"' order by sd.buyDate desc"); +// StringBuffer sql = new StringBuffer("select count(*) from Spellbuyrecord"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("ur", User.class); + entityMap.put("sd", Spellbuyrecord.class); + entityMap.put("pt", Product.class); + entityMap.put("st", Spellbuyproduct.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(6); + return page; + } + + + +} diff --git a/src/main/java/me/mofun/service/impl/SysConfigureServiceImpl.java b/src/main/java/me/mofun/service/impl/SysConfigureServiceImpl.java new file mode 100644 index 0000000..25abfe4 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/SysConfigureServiceImpl.java @@ -0,0 +1,96 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.IndexImg; +import me.mofun.pojo.Suggestion; +import me.mofun.pojo.SysConfigure; +import me.mofun.service.SysConfigureService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class SysConfigureServiceImpl implements SysConfigureService { + @Autowired + BaseDAO baseDao; + + public void add(SysConfigure t) { + this.baseDao.saveOrUpdate(t); + } + + public void delete(Integer id) { + // TODO Auto-generated method stub + + } + + public SysConfigure findById(String id) { + StringBuffer hql = new StringBuffer("from SysConfigure s where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and s.id='"+id+"'"); + } + return (SysConfigure) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public List initializationIndexImgAll(){ + StringBuffer sql = new StringBuffer("from IndexImg ig where 1=1 and ig.status = 0"); + List list = baseDao.find(sql.toString()); + return list; + } + + public List IndexImgAll(){ + StringBuffer sql = new StringBuffer("from IndexImg ig where 1=1"); + List list = baseDao.find(sql.toString()); + return list; + } + + public void addIndexImg(IndexImg indexImg){ + this.baseDao.saveOrUpdate(indexImg); + } + + public IndexImg findByIndexImgId(String id){ + StringBuffer hql = new StringBuffer("from IndexImg ig where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and ig.id='"+id+"'"); + } + return (IndexImg) baseDao.loadObject(hql.toString()); + } + + public void delIndexImg(Integer id){ + this.baseDao.delById(IndexImg.class, id); + } + + public void doSuggestion(Suggestion suggestion) { + this.baseDao.saveOrUpdate(suggestion); + } + + public Pagination suggestionList(int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from suggestion sn where 1=1"); + StringBuffer sql = new StringBuffer("select count(*) from suggestion where 1=1"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("sn", Suggestion.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + +} diff --git a/src/main/java/me/mofun/service/impl/TalkGroupServiceImpl.java b/src/main/java/me/mofun/service/impl/TalkGroupServiceImpl.java new file mode 100644 index 0000000..a5d150b --- /dev/null +++ b/src/main/java/me/mofun/service/impl/TalkGroupServiceImpl.java @@ -0,0 +1,58 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.pojo.TalkGroup; +import me.mofun.service.TalkGroupService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service("TalkGroupService") +public class TalkGroupServiceImpl implements TalkGroupService{ + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(TalkGroup group) { + baseDao.saveOrUpdate(group); + } + + public void delete(Integer id) { + baseDao.delById(TalkGroup.class, id); + } + + public TalkGroup findById(String id) { + StringBuffer hql = new StringBuffer("from TalkGroup group where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and group.groupId='"+id+"'"); + } + return (TalkGroup) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + return (List)baseDao.query(hql); + } + + public void update(String hql) { + baseDao.update(hql); + } + + public List getGroupList(){ + String hql = "select * from talkGroup"; + return query(hql); + } + + + + + + + + + + + + +} diff --git a/src/main/java/me/mofun/service/impl/TalkMsgServiceImpl.java b/src/main/java/me/mofun/service/impl/TalkMsgServiceImpl.java new file mode 100644 index 0000000..2cdb152 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/TalkMsgServiceImpl.java @@ -0,0 +1,215 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.pojo.TalkMsg; +import me.mofun.pojo.TalkUser; +import me.mofun.service.TalkMsgService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("TalkMsgService") +public class TalkMsgServiceImpl implements TalkMsgService{ + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(TalkMsg msg) { + baseDao.saveOrUpdate(msg); + } + + public void delete(Integer id) { + baseDao.delById(TalkMsg.class, id); + } + + public TalkMsg findById(String id) { + StringBuffer hql = new StringBuffer("from TalkMsg group where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and TalkGroup.msgId='"+id+"'"); + } + return (TalkMsg) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + return (List)baseDao.query(hql); + } + + public void update(String hql) { + baseDao.update(hql); + } + + public List getMsgListOld(Integer beforeTime, Integer groupId) { + // TODO Auto-generated method stub + String sql = "select * from talkMsg m where m.postDate<=" + beforeTime + " and m.groupId="+groupId; + return query(sql); + } + + /** + * 获取某时间之后所有新的公聊信息 + */ + public List getNewMsgList(Long afterTime, Integer groupId) { + StringBuffer sql = new StringBuffer("select {m.*},{u.*} from talkMsg m,talkUser u where m.userId=u.id and m.toUserId=0 and m.postDate>FROM_UNIXTIME(" + afterTime + ") and m.groupId="+groupId); + Map entityMap = new HashMap(); + entityMap.put("m", TalkMsg.class); + entityMap.put("u", TalkUser.class); + List list = baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + /** + * 获取给定时间之后所有新消息的列表 + * @param beforeTime + * @param groupId + * @param toUserId 接收消息者的用户Id + */ + public List getNewMsgList(Long afterTime,Integer groupId,Integer toUserId){ + StringBuffer sql = new StringBuffer("select {m.*},{u.*} from talkMsg m,talkUser u where m.userId=u.id and m.toUserId="+toUserId + " and m.postDate>FROM_UNIXTIME(" + afterTime + ") and m.groupId="+groupId); + Map entityMap = new HashMap(); + entityMap.put("m", TalkMsg.class); + entityMap.put("u", TalkUser.class); + List list = baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + /** + * 获取给定时间之后所有新新私聊消息的列表 + * @param beforeTime + * @param groupId + * @param toUserId 接收消息者的用户Id + */ + public List getNewPrivateMsgList(Long afterTime,Integer groupId,Integer fromUserId,Integer toUserId){ + StringBuffer sql = new StringBuffer("select {m.*},{u.*} from talkMsg m,talkUser u where m.userId=u.id and ((m.userId="+fromUserId+ " and m.toUserId="+toUserId+") or (m.userId="+toUserId+" and m.toUserId="+fromUserId+")) and m.postDate>FROM_UNIXTIME(" + afterTime + ") and m.groupId="+groupId); + Map entityMap = new HashMap(); + entityMap.put("m", TalkMsg.class); + entityMap.put("u", TalkUser.class); + List list = baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + + + + /** + * 获取给定时间之前所有的公聊消息列表之第几页数据 + * @param beforeTime + * @param groupId + * @@param pageIndex 页码索引 + */ + public List getMsgList(Long beforeTime,Integer groupId,Integer pageIndex){ + StringBuffer sql = new StringBuffer("select {m.*},{u.*} from talkMsg m,talkUser u where m.userId=u.id and m.toUserId=0 and m.postDate<=FROM_UNIXTIME(" + beforeTime + ") and m.groupId="+groupId +" order by m.postDate desc limit "+(pageIndex-1)*8+",8"); + Map entityMap = new HashMap(); + entityMap.put("m", TalkMsg.class); + entityMap.put("u", TalkUser.class); + List list = baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + /** + * 获取给定时间之前所有发给某用户消息列表之第几页数据 + * @param beforeTime + * @param groupId + * @param toUserId 接收消息者的用户Id + * @@param pageIndex 页码索引 + */ + public List getMsgList(Long beforeTime,Integer groupId,Integer toUserId,Integer pageIndex){ + StringBuffer sql = new StringBuffer("select {m.*},{u.*} from talkMsg m,talkUser u where m.userId=u.id and m.toUserId="+toUserId + " and m.postDate<=FROM_UNIXTIME(" + beforeTime + ") and m.groupId="+groupId +" order by m.postDate desc limit "+(pageIndex-1)*8+",8"); + Map entityMap = new HashMap(); + entityMap.put("m", TalkMsg.class); + entityMap.put("u", TalkUser.class); + List list = baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + /** + * 获取给定时间之前,某两个用户之间私聊消息列表之第几页数据 + * @param beforeTime + * @param groupId + * @param toUserId 接收消息者的用户Id + * @@param pageIndex 页码索引 + */ + public List getMsgList(Long beforeTime,Integer groupId,Integer fromUserId,Integer toUserId,Integer pageIndex){ + StringBuffer sql = new StringBuffer("select {m.*},{u.*} from talkMsg m,talkUser u where ((m.userId=u.id and m.userId="+fromUserId + " and m.toUserId="+toUserId+") or (m.toUserId=u.id and m.userId="+toUserId + " and m.toUserId="+fromUserId+")) and m.postDate<=FROM_UNIXTIME(" + beforeTime + ") and m.groupId="+groupId +" order by m.postDate desc limit "+(pageIndex-1)*8+",8"); + Map entityMap = new HashMap(); + entityMap.put("m", TalkMsg.class); + entityMap.put("u", TalkUser.class); + List list = baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + + /** + * 获取某时间之前两个用户间所有的私聊信息 + */ + public List getMsgListAndUserInfo(Integer fromUserId,Integer toUserId,Integer beforeTime){ + StringBuffer sql = new StringBuffer("select {m.*},{u.*} from talkMsg m,talkUser u where m.postDate<=FROM_UNIXTIME(" + beforeTime + ") and ((m.userId="+fromUserId + " and m.toUserId="+toUserId +") or (m.userId="+toUserId + " and m.toUserId="+fromUserId+")) and m.userId=u.id"); + Map entityMap = new HashMap(); + entityMap.put("m", TalkMsg.class); + entityMap.put("u", TalkUser.class); + List list = baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + /** + * 获取某用户的聊天者列表 + * @param toUserId + * @return + */ + public List getChatList(Integer toUserId){ + StringBuffer sql = new StringBuffer("select distinct u.* from talkUser u,talkMsg m where m.toUserId="+toUserId +" and u.Id=m.userId"); + Map entityMap = new HashMap(); + entityMap.put("u", TalkUser.class); + List list = (List )baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + /** + * 获取某用户最新的聊天者列表(有未读信息) + * @param toUserId + * @return + */ + public List getNewChatList(Integer toUserId){ + StringBuffer sql = new StringBuffer("select distinct u.* from talkUser u,talkMsg m where m.toUserId="+toUserId +" and u.Id=m.userId and m.status=1"); + Map entityMap = new HashMap(); + entityMap.put("u", TalkUser.class); + List list = (List )baseDao.sqlQueryEntity(sql, entityMap); + return list; + } + + /** + * 更新私聊信息中用户A发给用户B的信息状态为已读状态 + * @param fromUserId + * @param toUserId + * @param status + * @return + */ + public boolean updateMsgStatus(Integer fromUserId,Integer toUserId,Integer status){ + boolean result = false; + String sql = "update talkMsg set status="+status+" where userId="+fromUserId + " and toUserId="+toUserId +" and status=1"; + try{ + int cnt = baseDao.updateBySql(sql); + if(cnt>0)result=true; + }catch(Exception ex){ + ex.printStackTrace(); + } + + return result; + } + + + + + + + + + + + + + + +} diff --git a/src/main/java/me/mofun/service/impl/TalkUserServiceImpl.java b/src/main/java/me/mofun/service/impl/TalkUserServiceImpl.java new file mode 100644 index 0000000..dca3e87 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/TalkUserServiceImpl.java @@ -0,0 +1,74 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.pojo.TalkUser; +import me.mofun.service.TalkUserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("TalkUserService") +public class TalkUserServiceImpl implements TalkUserService{ + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(TalkUser user) { + baseDao.saveOrUpdate(user); + } + + public void delete(Integer id) { + baseDao.delById(TalkUser.class, id); + } + + public TalkUser findById(String id) { + StringBuffer hql = new StringBuffer("from TalkUser user where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and user.id='"+id+"'"); + } + return (TalkUser) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + return (List)baseDao.query(hql); + } + + public void update(String hql) { + baseDao.update(hql); + } + + public List getUserListByGroupId(Integer groupId){ + if(groupId!=null){ + StringBuffer sql = new StringBuffer("select u.* from talkUser u where u.groupId='"+groupId+",' or u.groupId like '%,"+groupId+",%'"); + Map entityMap = new HashMap(); + entityMap.put("u", TalkUser.class); + return (List)baseDao.sqlQueryEntityBean(sql,entityMap); + } + else + return null; + } + + public TalkUser getUserByOpenId(String openId){ + StringBuffer hql = new StringBuffer("from TalkUser user where 1=1"); + if(StringUtils.isNotBlank(openId)){ + hql.append(" and user.wxOpenId='"+openId+"'"); + } + return (TalkUser) baseDao.loadObject(hql.toString()); + } + + + + + + + + + + + + +} diff --git a/src/main/java/me/mofun/service/impl/UserServiceImpl.java b/src/main/java/me/mofun/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..bd2734b --- /dev/null +++ b/src/main/java/me/mofun/service/impl/UserServiceImpl.java @@ -0,0 +1,286 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.User; +import me.mofun.pojo.Userbyaddress; +import me.mofun.service.UserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("userService") +public class UserServiceImpl implements UserService{ + @Autowired + @Qualifier("baseDao") + BaseDAO baseDao; + + public void add(User user) { + baseDao.saveOrUpdate(user); + } + + public void delete(Integer id) { + baseDao.delById(User.class, id); + } + + public User findById(String id) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(id)){ + hql.append(" and user.userId='"+id+"'"); + } + return (User) baseDao.loadObject(hql.toString()); + } + + public List query(String hql) { + return (List)baseDao.query(hql); + } + + public void update(String hql) { + baseDao.update(hql); + } + + public User phoneLogin(String phone,String userPwd) { + StringBuffer hql = new StringBuffer(); + if(StringUtils.isNotBlank(phone) && StringUtils.isNotBlank(userPwd)){ + hql.append("from User user where user.phone ='"+phone+"' and user.userPwd ='"+userPwd+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public User mailLogin(String mail,String userPwd) { + StringBuffer hql = new StringBuffer(); + if(StringUtils.isNotBlank(mail) && StringUtils.isNotBlank(userPwd)){ + hql.append("from User user where user.mail ='"+mail+"' and user.userPwd ='"+userPwd+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public User userByName(String userName) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(userName)){ + hql.append(" and user.phone='"+userName+"' or user.mail='"+userName+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public List getUserbyaddress(String userId) { + StringBuffer hql = new StringBuffer("select us.* from userbyaddress us where us.userId = '"+userId+"'"); + Map entityMap = new HashMap(); + entityMap.put("us", Userbyaddress.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public void addAddress(Userbyaddress userbyaddress) { + baseDao.saveOrUpdate(userbyaddress); + } + + public void delAddress(Integer id) { + baseDao.delById(Userbyaddress.class, id); + } + + public Userbyaddress findAddressById(Integer id) { + StringBuffer hql = new StringBuffer("from Userbyaddress userbyaddress where id='"+id+"'"); + return (Userbyaddress) baseDao.loadObject(hql.toString()); + } + + public void setDefaultAddress(String userId,Integer id) { + StringBuffer hql = new StringBuffer("update Userbyaddress u set u.status = 0 where u.userId='"+userId+"' and u.id <> '"+id+"'"); + baseDao.update(hql.toString()); + } + + + + public void defaultAddress(String userId,Integer id) { + StringBuffer hql = new StringBuffer("update Userbyaddress u set u.status = 1 where u.userId='"+userId+"' and u.id = '"+id+"'"); + baseDao.update(hql.toString()); + } + + /** + * @author lwgboy + * 根据登陆邮箱更新对应的激活Key + * @param mail 登陆邮箱 + * @param key 激活Key + * @return 更新的记录条数 + */ + public int updateKey(String mail,String key) { + StringBuffer hql = new StringBuffer("update User u set u.key = '"+key+"' where u.mail='"+mail+"'"); + return baseDao.update(hql.toString()); + } + + public User isUserName(String userName,String userId) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(userName)){ + hql.append(" and user.userName='"+userName+"' and user.userId <> '"+userId+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public List loadAll() { + StringBuffer sql = new StringBuffer("from User u where 1=1 and u.userPwd = 'pwd.ipdz.me'"); + List list = baseDao.find(sql.toString()); + return list; + } + + public User userByIsUserName(String userName) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(userName)){ + hql.append(" and user.userName='"+userName+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + public Pagination getInvitedList(String userId,int pageNo,int pageSize) { + StringBuffer hql = new StringBuffer("select * from user u where u.invite = '"+userId+"' order by u.oldDate desc"); +// StringBuffer sql = new StringBuffer("select count(*) from user u where u.invite = '"+userId+"'"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("u", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public Integer getInvitedListByCount(String userId) { + StringBuffer sql = new StringBuffer("select count(*) from user u where u.invite = '"+userId+"'"); + return baseDao.getAllNum(sql); + } + + public List getInvitedListByData(String userId) { + StringBuffer hql = new StringBuffer("select u.* from user u where u.invite = '"+userId+"'"); + Map entityMap = new HashMap(); + entityMap.put("u", User.class); + List list = baseDao.sqlQueryEntity(hql,entityMap); + return list; + } + + public Pagination adminUserList(String typeId,String keyword,String orderName,int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from user u where 1=1 and u.userType = 0 and u.userPwd <> 'pwd.ipdz.me' "); + if(StringUtils.isNotBlank(typeId) && StringUtils.isNotBlank(keyword)){ + if(typeId.equals("userId")){ + hql.append(" and u.userId='"+keyword+"'"); + } + if(typeId.equals("userName")){ + hql.append(" and u.userName='"+keyword+"'"); + } + if(typeId.equals("mail")){ + hql.append(" and u.mail='"+keyword+"'"); + } + if(typeId.equals("phone")){ + hql.append(" and u.phone='"+keyword+"'"); + } + } + if(StringUtils.isNotBlank(orderName)){ + hql.append(" order by u."+orderName+" desc"); + }else{ + hql.append(" order by u.oldDate desc"); + } + StringBuffer sql = new StringBuffer("select count(*) from user u where 1=1 and u.userType = 0 and u.userPwd <> 'pwd.ipdz.me' "); + if(StringUtils.isNotBlank(typeId) && StringUtils.isNotBlank(keyword)){ + if(typeId.equals("userId")){ + sql.append(" and u.userId='"+keyword+"'"); + } + if(typeId.equals("userName")){ + sql.append(" and u.userName='"+keyword+"'"); + } + if(typeId.equals("mail")){ + sql.append(" and u.mail='"+keyword+"'"); + } + if(typeId.equals("phone")){ + sql.append(" and u.phone='"+keyword+"'"); + } + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("u", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + /** + * 获取同事列表 + * @param userId + * @param typeId + * @param keyword + * @param orderName + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getColleaguesList(Integer userId,String typeId,String keyword,String orderName,int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from user u where 1=1 and shopId in (select shopId from user where userId="+userId+") and u.userType = 0 and u.userPwd <> 'pwd.ipdz.me' "); + if(StringUtils.isNotBlank(typeId) && StringUtils.isNotBlank(keyword)){ + if(typeId.equals("userId")){ + hql.append(" and u.userId='"+keyword+"'"); + } + if(typeId.equals("userName")){ + hql.append(" and u.userName='"+keyword+"'"); + } + if(typeId.equals("mail")){ + hql.append(" and u.mail='"+keyword+"'"); + } + if(typeId.equals("phone")){ + hql.append(" and u.phone='"+keyword+"'"); + } + } + if(StringUtils.isNotBlank(orderName)){ + hql.append(" order by u."+orderName+" desc"); + }else{ + hql.append(" order by u.oldDate desc"); + } + StringBuffer sql = new StringBuffer("select count(*) from user u where 1=1 and u.userType = 0 and u.userPwd <> 'pwd.ipdz.me' "); + if(StringUtils.isNotBlank(typeId) && StringUtils.isNotBlank(keyword)){ + if(typeId.equals("userId")){ + sql.append(" and u.userId='"+keyword+"'"); + } + if(typeId.equals("userName")){ + sql.append(" and u.userName='"+keyword+"'"); + } + if(typeId.equals("mail")){ + sql.append(" and u.mail='"+keyword+"'"); + } + if(typeId.equals("phone")){ + sql.append(" and u.phone='"+keyword+"'"); + } + } + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("u", User.class); + List list = baseDao.sqlQuery(hql, entityMap, page); + int resultCount = baseDao.getAllNum(sql); + page.setList(list); + page.setResultCount(resultCount); + return page; + } + + public Integer getCountUser() { + StringBuffer sql = new StringBuffer("select count(*) from user"); + return baseDao.getAllNum(sql); + } + + public User isNotOpenId(String openId) { + StringBuffer hql = new StringBuffer("from User user where 1=1"); + if(StringUtils.isNotBlank(openId)){ + hql.append(" and user.qqOpenId='"+openId+"'"); + } + return (User) this.baseDao.loadObject(hql.toString()); + } + + + +} diff --git a/src/main/java/me/mofun/service/impl/VisitorsServiceImpl.java b/src/main/java/me/mofun/service/impl/VisitorsServiceImpl.java new file mode 100644 index 0000000..ec310f9 --- /dev/null +++ b/src/main/java/me/mofun/service/impl/VisitorsServiceImpl.java @@ -0,0 +1,77 @@ +package me.mofun.service.impl; + +import me.mofun.dao.BaseDAO; +import me.mofun.dao.Pagination; +import me.mofun.pojo.User; +import me.mofun.pojo.Visitors; +import me.mofun.service.VisitorsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class VisitorsServiceImpl implements VisitorsService { + @Autowired + @Qualifier("baseDao") + BaseDAO baseDAO; + + public void add(Visitors t) { + baseDAO.saveOrUpdate(t); + + } + + public void delete(Integer id) { + baseDAO.delById(Visitors.class, id); + + } + + public Visitors findById(String id) { + // TODO Auto-generated method stub + return null; + } + + public List query(String hql) { + // TODO Auto-generated method stub + return null; + } + + public void update(String hql) { + // TODO Auto-generated method stub + + } + + public Pagination getVisitors(String userId, int pageNo, int pageSize) { + StringBuffer hql = new StringBuffer("select * from visitors vs,user ur where vs.visitorsId = ur.userId and vs.uid = '"+userId+"' order by date desc"); +// StringBuffer sql = new StringBuffer("select count(*) from visitors vs,user ur where vs.visitorsId = ur.userId and vs.userId = '"+userId+"' order by date desc"); + Pagination page = new Pagination(); + page.setPageNo(pageNo); + page.setPageSize(pageSize); + Map entityMap = new HashMap(); + entityMap.put("vs", Visitors.class); + entityMap.put("ur", User.class); + List list = baseDAO.sqlQuery(hql, entityMap, page); +// int resultCount = baseDao.getAllNum(sql); + page.setList(list); +// page.setResultCount(resultCount); + return page; + } + + public List findVisitors(String userId, String visitorsId, String startDate,String endDate) { + StringBuffer sql = new StringBuffer("select * from visitors vs where vs.uid = '"+userId+"' and vs.visitorsId = '"+visitorsId+"' and vs.date >= '"+startDate+"' and vs.date <= '"+endDate+"'"); + Map entityMap = new HashMap(); + entityMap.put("vs", Visitors.class); + List list = baseDAO.sqlQueryEntity(sql,entityMap); + return list; + } + + public Visitors findVisitorsByUserIdAndVisitorsId(String userId, + String visitorsId) { + StringBuffer hql = new StringBuffer("from Visitors vs where vs.uid = '"+userId+"' and vs.visitorsId = '"+visitorsId+"'"); + return (Visitors) baseDAO.loadObject(hql.toString()); + } + +} diff --git a/src/main/java/me/mofun/temp/ApplymentionService.java b/src/main/java/me/mofun/temp/ApplymentionService.java new file mode 100644 index 0000000..35a9b33 --- /dev/null +++ b/src/main/java/me/mofun/temp/ApplymentionService.java @@ -0,0 +1,29 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Applymention; + +public interface ApplymentionService extends TService { + + + /** + * 提现记录 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getApplymentionList(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 提现记录 ByCount + * @param userId + * @param startDate + * @param endDate + * @return + */ + public Integer getApplymentionListByCount(String userId,String startDate,String endDate); + +} diff --git a/src/main/java/me/mofun/temp/CardpasswordService.java b/src/main/java/me/mofun/temp/CardpasswordService.java new file mode 100644 index 0000000..29b9e83 --- /dev/null +++ b/src/main/java/me/mofun/temp/CardpasswordService.java @@ -0,0 +1,19 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Cardpassword; + +public interface CardpasswordService extends TService { + + /** + * 卡密充值 + * @param id + * @return + */ + public Cardpassword doCardRecharge(String randomNo,String cardPwd); + + public Pagination cardRechargeList(int pageNo,int pageSize); + + public void deleteByID(Integer id); + +} diff --git a/src/main/java/me/mofun/temp/CommissionpointsService.java b/src/main/java/me/mofun/temp/CommissionpointsService.java new file mode 100644 index 0000000..30dd5ed --- /dev/null +++ b/src/main/java/me/mofun/temp/CommissionpointsService.java @@ -0,0 +1,25 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Commissionpoints; + +public interface CommissionpointsService extends TService{ + + /** + * 福分明细 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination CommissionPoints(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 佣金明细 ByCount + * @param userId + * @return + */ + public Integer getCommissionPointsListByCount(String userId,String startDate,String endDate); + + +} diff --git a/src/main/java/me/mofun/temp/CommissionqueryService.java b/src/main/java/me/mofun/temp/CommissionqueryService.java new file mode 100644 index 0000000..a15acb3 --- /dev/null +++ b/src/main/java/me/mofun/temp/CommissionqueryService.java @@ -0,0 +1,33 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Commissionquery; + +import java.util.List; + +public interface CommissionqueryService extends TService{ + + /** + * 佣金明细 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getCommissionQueryList(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 佣金明细 ByCount + * @param userId + * @return + */ + public Integer getCommissionQueryListByCount(String userId,String startDate,String endDate); + + /** + * 佣金明细 ByData + * @param userId + * @return + */ + public List getCommissionQueryListByData(String userId); + +} diff --git a/src/main/java/me/mofun/temp/ConsumerdetailService.java b/src/main/java/me/mofun/temp/ConsumerdetailService.java new file mode 100644 index 0000000..19921a4 --- /dev/null +++ b/src/main/java/me/mofun/temp/ConsumerdetailService.java @@ -0,0 +1,39 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Consumerdetail; + +public interface ConsumerdetailService extends TService { + + /** + * 消费记录-查看详情 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination userByConsumetableDetail(String id,int pageNo,int pageSize); + + /** + * 消费记录-查看详情ByCount + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Integer userByConsumetableDetailByCount(String id); + + /** + * 订单详情 + * @param userKey + * @param pageNo + * @param pageSize + * @return + */ + public Pagination orderInfo(String id,int pageNo, int pageSize); + +} diff --git a/src/main/java/me/mofun/temp/ConsumetableService.java b/src/main/java/me/mofun/temp/ConsumetableService.java new file mode 100644 index 0000000..b1f0878 --- /dev/null +++ b/src/main/java/me/mofun/temp/ConsumetableService.java @@ -0,0 +1,64 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Consumetable; + +public interface ConsumetableService extends TService { + + public Consumetable findByOutTradeNo(String id); + + /** + * 冲值记录 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination userByConsumetableByDelta(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 冲值记录ByCount + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Integer userByConsumetableByDeltaByCount(String userId,String startDate,String endDate); + + + /** + * 消费记录 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination userByConsumetable(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 消费记录ByCount + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Integer userByConsumetableByCount(String userId,String startDate,String endDate); + + /** + * 订单列表 + * @param userKey + * @param pageNo + * @param pageSize + * @return + */ + public Pagination orderList(String userKey,int pageNo, int pageSize); + +} diff --git a/src/main/java/me/mofun/temp/FriendsService.java b/src/main/java/me/mofun/temp/FriendsService.java new file mode 100644 index 0000000..b20a911 --- /dev/null +++ b/src/main/java/me/mofun/temp/FriendsService.java @@ -0,0 +1,17 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Friends; + +public interface FriendsService extends TService { + + /** + * 好友 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getFriends(String userId,int pageNo,int pageSize); + +} diff --git a/src/main/java/me/mofun/temp/LatestlotteryService.java b/src/main/java/me/mofun/temp/LatestlotteryService.java new file mode 100644 index 0000000..7b688ba --- /dev/null +++ b/src/main/java/me/mofun/temp/LatestlotteryService.java @@ -0,0 +1,116 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Latestlottery; +import me.mofun.pojo.OrderDetailAddress; + +import java.util.List; + +public interface LatestlotteryService extends TService { + + /** + * 最新揭晓 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination LatestAnnounced(int pageNo,int pageSize); + + /** + * 最新揭晓6条滚动 + * @return + */ + public List indexWinningScroll(); + + /** + * 查看拍购记录商品详情 + * @param productId + * @return + */ + public List getBuyHistoryByDetail(Integer spellbuyProductId); + + /** + * 查询某用户获得的商品 + * @param userId + * @param startDate + * @param endDate + * @return + */ + public Pagination getProductByUser(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 查询某用户获得的商品ByCount + * @param userId + * @param startDate + * @param endDate + * @return + */ + public Integer getProductByUserByCount(String userId,String startDate,String endDate); + + /** + * 最新揭晓详情 + * @param productId + * @return + */ + public List getLotteryDetail(Integer spellbuyProductId); + + /** + * 某件商品其他期数获得者 + * @param productId + * @param shareId + * @return + */ + public List getProductOtherWinUser(String productId,String shareId); + + /** + * 最新揭晓详情-总共多个人购买 + * @param id + * @return + */ + public Integer getCountByLotteryDetail(String spellbuyProductId); + + /** + * 最新揭晓详情-购买人购买详情 + * @param productId + * @return + */ + public Pagination getLotteryDetailBybuyerList(Integer SpellbuyProductId,int pageNo,int pageSize); + + /** + * 最新揭晓详情-购买人购买详情ByCount + * @param productId + * @return + */ + public Integer getLotteryDetailBybuyerListByCount(Integer SpellbuyProductId); + + /** + * 查询某商品ID与商品基数ID是否已经开过奖 + * @param SpellbuyProductId + * @param productId + * @return + */ + public List getLatestlotteryBySpellbuyProductIdAndProductIdIsExist(Integer SpellbuyProductId); + + public Latestlottery findLatestlotteryByspellbuyrecordId(Integer spellbuyrecordId); + + /** + * 获得商品详情-物流操作详情 + * @param id + * @return + */ + public List orderdetailListById(String id); + + /** + * 获得商品详情-物流地址详情 + * @param id + * @return + */ + //public Orderdetailaddress orderdetailaddressFindByOrderdetailId(String id); + + /** + * 获得商品详情-添加物流地址详情 + * @param orderdetailaddress + */ + //public void addOrderdetailaddress(Orderdetailaddress orderdetailaddress); + +} diff --git a/src/main/java/me/mofun/temp/LotteryproductutilService.java b/src/main/java/me/mofun/temp/LotteryproductutilService.java new file mode 100644 index 0000000..f827029 --- /dev/null +++ b/src/main/java/me/mofun/temp/LotteryproductutilService.java @@ -0,0 +1,11 @@ +package me.mofun.temp; + +import me.mofun.pojo.Lotteryproductutil; + +import java.util.List; + +public interface LotteryproductutilService extends TService { + + public List loadAll(); + +} diff --git a/src/main/java/me/mofun/temp/MessageService.java b/src/main/java/me/mofun/temp/MessageService.java new file mode 100644 index 0000000..3aeb096 --- /dev/null +++ b/src/main/java/me/mofun/temp/MessageService.java @@ -0,0 +1,7 @@ +package me.mofun.temp; + +import me.mofun.pojo.Message; + +public interface MessageService extends TService { + +} diff --git a/src/main/java/me/mofun/temp/NewsService.java b/src/main/java/me/mofun/temp/NewsService.java new file mode 100644 index 0000000..dd1c6f0 --- /dev/null +++ b/src/main/java/me/mofun/temp/NewsService.java @@ -0,0 +1,14 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.News; + +import java.util.List; + +public interface NewsService extends TService { + + public Pagination newsList(int pageNo,int pageSize); + + public List indexNews(); + +} diff --git a/src/main/java/me/mofun/temp/OrderdetailService.java b/src/main/java/me/mofun/temp/OrderdetailService.java new file mode 100644 index 0000000..e38ebc3 --- /dev/null +++ b/src/main/java/me/mofun/temp/OrderdetailService.java @@ -0,0 +1,7 @@ +package me.mofun.temp; + +import me.mofun.pojo.Orderdetail; + +public interface OrderdetailService extends TService { + +} diff --git a/src/main/java/me/mofun/temp/OrderdetailaddressService.java b/src/main/java/me/mofun/temp/OrderdetailaddressService.java new file mode 100644 index 0000000..9fe890d --- /dev/null +++ b/src/main/java/me/mofun/temp/OrderdetailaddressService.java @@ -0,0 +1,12 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; + +/** + * Orderdetailaddress找不到改obj + */ +public interface OrderdetailaddressService extends TService { + + public Pagination orderdetailaddressList(int pageNo, int pageSize); + +} diff --git a/src/main/java/me/mofun/temp/ProductImageService.java b/src/main/java/me/mofun/temp/ProductImageService.java new file mode 100644 index 0000000..6deec49 --- /dev/null +++ b/src/main/java/me/mofun/temp/ProductImageService.java @@ -0,0 +1,14 @@ +package me.mofun.temp; +/** + * Productimage 找不到 改obj + */ + +//import me.mofun.pojo.Productimage; + +import java.util.List; + +public interface ProductImageService extends TService{ + + public List findByProductId(String productId,String type); + +} diff --git a/src/main/java/me/mofun/temp/ProductService.java b/src/main/java/me/mofun/temp/ProductService.java new file mode 100644 index 0000000..7498549 --- /dev/null +++ b/src/main/java/me/mofun/temp/ProductService.java @@ -0,0 +1,40 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Product; + +public interface ProductService extends TService { + + /** + * 商品期数列表 + * @param keyword + * @param orderName + * @param pageNo + * @param pageSize + * @return + */ + public Pagination searchSpellbuyproduct(String keyword,String orderName, int pageNo, int pageSize) ; + + /** + * 商品列表 + * @param keyword + * @param orderName + * @param pageNo + * @param pageSize + * @return + */ + public Pagination searchProduct(String typeId,String keyword, int pageNo, int pageSize) ; + + public Product findProductByName(String productName); + + + /** + * 直接购买商品列表 + * @param typeId + * @param orderName + * @param pageNo + * @param pageSize + * @return + */ + public Pagination ProductListByTypeIdList(String typeId,String orderName,int pageNo,int pageSize); +} diff --git a/src/main/java/me/mofun/temp/ProductTypeService.java b/src/main/java/me/mofun/temp/ProductTypeService.java new file mode 100644 index 0000000..46d59ae --- /dev/null +++ b/src/main/java/me/mofun/temp/ProductTypeService.java @@ -0,0 +1,23 @@ +package me.mofun.temp; + +import me.mofun.pojo.ProductType; + +import java.util.List; + +public interface ProductTypeService extends TService { + + public List queryAllProductType(); + + public List listByProductList(); + + public List listByProductListBybrand(String id); + + public List listByBrand(String id); + + public ProductType findBrandById(String id); + + public ProductType findTypeByName(String name); + + public ProductType findBrandByName(String name); + +} diff --git a/src/main/java/me/mofun/temp/RandomnumberService.java b/src/main/java/me/mofun/temp/RandomnumberService.java new file mode 100644 index 0000000..dfc7a19 --- /dev/null +++ b/src/main/java/me/mofun/temp/RandomnumberService.java @@ -0,0 +1,24 @@ +package me.mofun.temp; + +import me.mofun.pojo.Randomnumber; + +import java.math.BigDecimal; +import java.util.List; + +public interface RandomnumberService extends TService { + + public List LotteryDetailByRandomnumber(Integer userId,Integer spellbuyProductId); + + /** + * 查询某商品某用户总共总买人次 + * @param userId + * @param spellbuyProductId + * @return + */ + public BigDecimal RandomNumberByUserBuyCount(String userId,Integer spellbuyProductId); + + public Randomnumber findRandomnumberByspellbuyrecordId(Integer spellbuyrecordId); + + public Randomnumber getUserBuyCodeByBuyid(String productId,String spellbuyrecordId); + +} diff --git a/src/main/java/me/mofun/temp/RecommendService.java b/src/main/java/me/mofun/temp/RecommendService.java new file mode 100644 index 0000000..e7e29d8 --- /dev/null +++ b/src/main/java/me/mofun/temp/RecommendService.java @@ -0,0 +1,11 @@ +package me.mofun.temp; + +import me.mofun.pojo.Recommend; + +import java.util.List; + +public interface RecommendService extends TService{ + + public List getRecommend(); + +} diff --git a/src/main/java/me/mofun/temp/RegionService.java b/src/main/java/me/mofun/temp/RegionService.java new file mode 100644 index 0000000..9f89666 --- /dev/null +++ b/src/main/java/me/mofun/temp/RegionService.java @@ -0,0 +1,28 @@ +package me.mofun.temp; + +import java.util.List; + + +public interface RegionService{ + + /** + * 得到省List + * @return + */ + public List getProvinceList(); + + /** + * 得到市List + * @param provinceId + * @return + */ + public List getCityListByProvinceId(String provinceId); + + /** + * 得到区List + * @param cityId + * @return + */ + public List getDistrictListByCityId(String cityId); + +} diff --git a/src/main/java/me/mofun/temp/ShareService.java b/src/main/java/me/mofun/temp/ShareService.java new file mode 100644 index 0000000..8074b55 --- /dev/null +++ b/src/main/java/me/mofun/temp/ShareService.java @@ -0,0 +1,105 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Sharecomments; +import me.mofun.pojo.Shareimage; +import me.mofun.pojo.Shareinfo; + +import java.util.List; + +public interface ShareService extends TService{ + + /** + * 晒单列表页 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination loadPageShare(String type,int pageNo,int pageSize); + + /** + * 晒单详情页最新晒单 + * @param type + * @param pageNo + * @param pageSize + * @return + */ + public Pagination loadShareInfoByNew(String type,int pageNo,int pageSize); + + /** + * 后台晒单列表 + * @param type + * @param pageNo + * @param pageSize + * @return + */ + public Pagination adminShareList(String type,String status,int pageNo,int pageSize); + + /** + * 晒单内容页 + * @param id + * @return + */ + public List shareShow(int id); + + /** + * 我的晒单 + * @param userId + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination shareByUser(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 获取晒单图片 + * @param shareId + * @return + */ + public List getShareimage(String shareId); + + /** + * 添加晒单图片 + * @param shareimage + */ + public void addShareImage(Shareimage shareimage); + + /** + * 晒单评论列表 + * @param shareId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination shareByComment(String shareId,int pageNo,int pageSize); + + /** + * 获取评论列表的评论 + * @param shareCommentId + * @return + */ + public List getReCommentList(String shareCommentId); + + /** + * 添加评论 + * @param sharecomments + */ + public void createComment(Sharecomments sharecomments); + + /** + * 查询某条评论 + * @param sharecommentsId + * @return + */ + public Sharecomments findBySharecommentsId(String sharecommentsId); + + /** + * 首页TA们都在说 + + * @return + */ + public List getIndexSharecommentsList(); + +} diff --git a/src/main/java/me/mofun/temp/SpellbuyproductService.java b/src/main/java/me/mofun/temp/SpellbuyproductService.java new file mode 100644 index 0000000..8f40677 --- /dev/null +++ b/src/main/java/me/mofun/temp/SpellbuyproductService.java @@ -0,0 +1,74 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Spellbuyproduct; + +import java.util.List; + +public interface SpellbuyproductService extends TService { + + /** + * 商品页 + * @param productId + * @return + */ + public List findByProductId(int productId); + + /** + * 即将揭晓商品 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination upcomingAnnounced(int pageNo, int pageSize); + + /** + * 人气top + * @param pageNo + * @param pageSize + * @return + */ + public Pagination upcomingAnnouncedByTop(int pageNo, int pageSize); + + /** + * 商品期数列表 + * @param integer + * @return + */ + public List productPeriodList(Integer integer); + + /** + * 查询某商品最后一期数 + * @param productId + * @return + */ + public Spellbuyproduct findSpellbuyproductLastPeriod(Integer productId); + + /** + * 查询某商品正在拍购期数,by 修改商品价格 + * @param productId + * @return + */ + public Spellbuyproduct findSpellbuyproductByStatus(Integer productId); + + /** + * 已经揭晓商品列表 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination announcedProduct(int pageNo, int pageSize); + + public List loadAllByType(); + + public List loadAll(); + + public List UpdateLatestlotteryGetList(); + + /** + * 查询某个商品是否已经有最新期 + * @param productId + * @return + */ + public List findSpellbuyproductByProductIdIsStatus(Integer productId); +} diff --git a/src/main/java/me/mofun/temp/SpellbuyrecordService.java b/src/main/java/me/mofun/temp/SpellbuyrecordService.java new file mode 100644 index 0000000..b89e66a --- /dev/null +++ b/src/main/java/me/mofun/temp/SpellbuyrecordService.java @@ -0,0 +1,224 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Spellbuyrecord; + +import java.math.BigDecimal; +import java.util.List; + +public interface SpellbuyrecordService extends TService { + + /** + * 最热人气商品 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination findHotProductList(int pageNo,int pageSize); + + /** + * 最新上架商品 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination indexNewProductList(int pageNo,int pageSize); + + /** + * 人气排行商品 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination indexHotProductList(int pageNo,int pageSize); + + /** + * 最新拍购商品 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getNowBuyList(int pageNo,int pageSize); + + /** + * 最新100条拍购记录AJAX请求 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getNowBuyAjaxList(int pageNo,int pageSize,int spellbuyRecordId); + + /** + * 全站拍购记录查询 + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getAllBuyRecord(String startDate,String endDate,int pageNo,int pageSize); + + /** + * 揭晓详细计算结果(全站最后100条购买记录) + * @param startDate + * @param endDate + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getlotteryDetail(String startDate,String endDate,int pageNo,int pageSize); + + /** + * 开奖最后一百条购买记录 + * @return + */ + public List getSpellbuyRecordByLast100(String startDate,String endDate); + + /** + * 得到某商品最后购买记录 + * @param fkSpellbuyProductId + * @return + */ + public List getEndBuyDateByProduct(Integer fkSpellbuyProductId); + + /** + * 首页分类显示商品 + * @param typeId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination findProductByTypeId(String typeId,int pageNo,int pageSize); + + /** + * 商品页按商品类型查询商品 + * @param typeId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination ProductByTypeIdList(String typeId,String brandId,String orderName,int pageNo,int pageSize); + + /** + * 用户中心首页最新上架 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination nowUpProducts(int pageNo,int pageSize); + + /** + * 搜索商品 + * @param keyword + * @param pageNo + * @param pageSize + * @return + */ + public Pagination searchProduct(String keyword,String orderName,int pageNo,int pageSize); + + + /** + * 最新参与 + * @param productId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination LatestParticipate(String spellbuyProductId,int pageNo,int pageSize); + + /** + * 最新参与ByCount + * @param productId + * @param pageNo + * @param pageSize + * @return + */ + public Integer LatestParticipateByCount(String spellbuyProductId); + + /** + * 得到某条购买记录的随机码(list 页) + * @param spellbuyrecordId + * @param pageNo + * @param pageSize + * @return + */ + public List getRandomNumberList(String spellbuyProductId,String userId); + + /** + * 得到某条购买记录的随机码(详细 页) + * @param spellbuyrecordId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getRandomNumberListPage(String spellbuyProductId,String userId,int pageNo,int pageSize); + + /** + * 得到某条购买记录的随机码(详细 页)ByCount + * @param spellbuyrecordId + * @param pageNo + * @param pageSize + * @return + */ + public Integer getRandomNumberListPageByCount(String spellbuyProductId,String userId); + + /** + * 查询某用户的购买记录 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination buyHistoryByUser(String userId,String startDate,String endDate,int pageNo,int pageSize); + + /** + * 查询某用户的购买记录ByCount + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Integer buyHistoryByUserByCount(String userId,String startDate,String endDate); + + /** + * 查询某用户购买记录详情 + * @param userId + * @param productId + * @return + */ + public List getBuyHistoryByDetail(String productId,String userId); + + /** + * 我的购买记录 + * @param userId + * @param fkSpellbuyProductId + * @return + */ + public List getUserByHistory(String userId,String fkSpellbuyProductId); + + /** + * 某件商品满员后抽奖 + * @param spellbuyProductId + * @return + */ + public List randomByBuyHistoryByspellbuyProductId(Integer productId,String randomNumber); + + + public List WinRandomNumber(Integer productId,Integer randomNumber); + + /** + * 全站总拍购人数 + * @return + */ + public BigDecimal getAllByCount(); + + /** + * 查询某用户总共消费金额 + * @param userId + * @return + */ + public BigDecimal findSumByBuyPriceByUserId(String userId); + + + +} diff --git a/src/main/java/me/mofun/temp/SysConfigureService.java b/src/main/java/me/mofun/temp/SysConfigureService.java new file mode 100644 index 0000000..8baeef7 --- /dev/null +++ b/src/main/java/me/mofun/temp/SysConfigureService.java @@ -0,0 +1,26 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.IndexImg; +import me.mofun.pojo.Suggestion; +import me.mofun.pojo.SysConfigure; + +import java.util.List; + +public interface SysConfigureService extends TService { + + public List initializationIndexImgAll(); + + public List IndexImgAll(); + + public void addIndexImg(IndexImg indexImg); + + public IndexImg findByIndexImgId(String id); + + public void delIndexImg(Integer id); + + public void doSuggestion(Suggestion suggestion); + + public Pagination suggestionList(int pageNo, int pageSize) ; + +} diff --git a/src/main/java/me/mofun/temp/TService.java b/src/main/java/me/mofun/temp/TService.java new file mode 100644 index 0000000..d4529a1 --- /dev/null +++ b/src/main/java/me/mofun/temp/TService.java @@ -0,0 +1,11 @@ +package me.mofun.temp; + +import java.util.List; + +public interface TService { + public void add(T t); + public void delete(Integer id); + public void update(String hql); + public T findById(String id); + public List query(String hql); +} diff --git a/src/main/java/me/mofun/temp/UserService.java b/src/main/java/me/mofun/temp/UserService.java new file mode 100644 index 0000000..44317d1 --- /dev/null +++ b/src/main/java/me/mofun/temp/UserService.java @@ -0,0 +1,87 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.User; +import me.mofun.pojo.Userbyaddress; + +import java.util.List; + +public interface UserService extends TService{ + public User phoneLogin(String phone,String userPwd); + public User mailLogin(String mail,String userPwd); + public User userByName(String userName); + public User userByIsUserName(String userName); + public User isUserName(String userName,String userId); + public List getUserbyaddress(String userId); + public void addAddress(Userbyaddress userbyaddress); + public void delAddress(Integer id); + public Userbyaddress findAddressById(Integer id); + /** + * 修改除id 外其它的地址为0 + * @param userId + * @param id + */ + public void setDefaultAddress(String userId,Integer id); + /** + * 设置默认收货地址 + * @param userId + * @param id + */ + public void defaultAddress(String userId,Integer id); + + + public List loadAll(); + + /** + * 获取邀请好友列表 + * @param userId + * @return + */ + public Pagination getInvitedList(String userId,int pageNo,int pageSize); + + /** + * 获取邀请好友列表统计数据 + * @param userId + * @return + */ + public List getInvitedListByData(String userId); + + /** + * 获取邀请好友列表By Count + * @param userId + * @return + */ + public Integer getInvitedListByCount(String userId); + + /** + * 会员列表 + * @param pageNo + * @param pageSize + * @return + */ + public Pagination adminUserList(String typeId,String keyword,String orderName,int pageNo,int pageSize); + + /** + * 会员总数 + * @return + */ + public Integer getCountUser(); + + /** + * 判断是否已经存在OpenId + * @param openId + * @return + */ + public User isNotOpenId(String openId); + + /** + * @author lwgboy + * 根据登陆邮箱更新对应的激活Key + * @param mail 登陆邮箱 + * @param key 激活Key + * @return 更新的记录条数 + */ + public int updateKey(String mail,String key) ; + + +} diff --git a/src/main/java/me/mofun/temp/VisitorsService.java b/src/main/java/me/mofun/temp/VisitorsService.java new file mode 100644 index 0000000..e11ee05 --- /dev/null +++ b/src/main/java/me/mofun/temp/VisitorsService.java @@ -0,0 +1,33 @@ +package me.mofun.temp; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Visitors; + +import java.util.List; + +public interface VisitorsService extends TService { + + /** + * 访客列表 + * @param userId + * @param pageNo + * @param pageSize + * @return + */ + public Pagination getVisitors(String userId,int pageNo,int pageSize); + + /** + * 查询某用户是否有访问记录 + * @param userId + * @param visitorsId + * @return + */ + public Visitors findVisitorsByUserIdAndVisitorsId(String userId,String visitorsId); + + /** + * 查询一小时内是否访问过 + * @return + */ + public List findVisitors(String userId,String visitorsId,String startDate,String endDate); + +} diff --git a/src/main/java/me/mofun/tenpay/RequestHandler.java b/src/main/java/me/mofun/tenpay/RequestHandler.java new file mode 100644 index 0000000..82c0134 --- /dev/null +++ b/src/main/java/me/mofun/tenpay/RequestHandler.java @@ -0,0 +1,199 @@ +package me.mofun.tenpay; + +import me.mofun.tenpay.util.MD5Util; +import me.mofun.tenpay.util.TenpayUtil; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.*; + +/** + * 请求处理类 + * 请求处理类继承此类,重写createSign方法即可。 + * @author miklchen + * + */ +public class RequestHandler { + + /** 网关url地址 */ + private String gateUrl; + + /** 密钥 */ + private String key; + + /** 请求的参数 */ + private SortedMap parameters; + + /** debug信息 */ + private String debugInfo; + + private HttpServletRequest request; + + private HttpServletResponse response; + + /** + * 构造函数 + * @param request + * @param response + */ + public RequestHandler(HttpServletRequest request, HttpServletResponse response) { + this.request = request; + this.response = response; + + this.gateUrl = "https://gw.tenpay.com/gateway/pay.htm"; + this.key = ""; + this.parameters = new TreeMap(); + this.debugInfo = ""; + } + + /** + *初始化函数。 + */ + public void init() { + //nothing to do + } + + /** + *获取入口地址,不包含参数值 + */ + public String getGateUrl() { + return gateUrl; + } + + /** + *设置入口地址,不包含参数值 + */ + public void setGateUrl(String gateUrl) { + this.gateUrl = gateUrl; + } + + /** + *获取密钥 + */ + public String getKey() { + return key; + } + + /** + *设置密钥 + */ + public void setKey(String key) { + this.key = key; + } + + /** + * 获取参数值 + * @param parameter 参数名称 + * @return String + */ + public String getParameter(String parameter) { + String s = (String)this.parameters.get(parameter); + return (null == s) ? "" : s; + } + + /** + * 设置参数值 + * @param parameter 参数名称 + * @param parameterValue 参数值 + */ + public void setParameter(String parameter, String parameterValue) { + String v = ""; + if(null != parameterValue) { + v = parameterValue.trim(); + } + this.parameters.put(parameter, v); + } + + /** + * 返回所有的参数 + * @return SortedMap + */ + public SortedMap getAllParameters() { + return this.parameters; + } + + /** + *获取debug信息 + */ + public String getDebugInfo() { + return debugInfo; + } + + /** + * 获取带参数的请求URL + * @return String + * @throws UnsupportedEncodingException + */ + public String getRequestURL() throws UnsupportedEncodingException { + + this.createSign(); + + StringBuffer sb = new StringBuffer(); + String enc = TenpayUtil.getCharacterEncoding(this.request, this.response); + Set es = this.parameters.entrySet(); + Iterator it = es.iterator(); + while(it.hasNext()) { + Map.Entry entry = (Map.Entry)it.next(); + String k = (String)entry.getKey(); + String v = (String)entry.getValue(); + sb.append(k + "=" + URLEncoder.encode(v, enc) + "&"); + } + + //去掉最后一个& + String reqPars = sb.substring(0, sb.lastIndexOf("&")); + + return this.getGateUrl() + "?" + reqPars; + + } + + public void doSend() throws UnsupportedEncodingException, IOException { + this.response.sendRedirect(this.getRequestURL()); + } + + /** + * 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。 + */ + protected void createSign() { + StringBuffer sb = new StringBuffer(); + Set es = this.parameters.entrySet(); + Iterator it = es.iterator(); + while(it.hasNext()) { + Map.Entry entry = (Map.Entry)it.next(); + String k = (String)entry.getKey(); + String v = (String)entry.getValue(); + if(null != v && !"".equals(v) + && !"sign".equals(k) && !"key".equals(k)) { + sb.append(k + "=" + v + "&"); + } + } + sb.append("key=" + this.getKey()); + + String enc = TenpayUtil.getCharacterEncoding(this.request, this.response); + String sign = MD5Util.MD5Encode(sb.toString(), enc).toLowerCase(); + + this.setParameter("sign", sign); + + //debug信息 + this.setDebugInfo(sb.toString() + " => sign:" + sign); + + } + + /** + *设置debug信息 + */ + protected void setDebugInfo(String debugInfo) { + this.debugInfo = debugInfo; + } + + protected HttpServletRequest getHttpServletRequest() { + return this.request; + } + + protected HttpServletResponse getHttpServletResponse() { + return this.response; + } + +} diff --git a/src/main/java/me/mofun/tenpay/ResponseHandler.java b/src/main/java/me/mofun/tenpay/ResponseHandler.java new file mode 100644 index 0000000..4b97ffe --- /dev/null +++ b/src/main/java/me/mofun/tenpay/ResponseHandler.java @@ -0,0 +1,208 @@ +package me.mofun.tenpay; + +import me.mofun.tenpay.util.MD5Util; +import me.mofun.tenpay.util.TenpayUtil; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.*; + +/** + * 应答处理类 + * 应答处理类继承此类,重写isTenpaySign方法即可。 + * @author miklchen + * + */ +public class ResponseHandler { + + /** 密钥 */ + private String key; + + /** 应答的参数 */ + private SortedMap parameters; + + /** debug信息 */ + private String debugInfo; + + private HttpServletRequest request; + + private HttpServletResponse response; + + private String uriEncoding; + + /** + * 构造函数 + * + * @param request + * @param response + */ + public ResponseHandler(HttpServletRequest request, + HttpServletResponse response) { + this.request = request; + this.response = response; + + this.key = ""; + this.parameters = new TreeMap(); + this.debugInfo = ""; + + this.uriEncoding = ""; + + Map m = this.request.getParameterMap(); + Iterator it = m.keySet().iterator(); + while (it.hasNext()) { + String k = (String) it.next(); + String v = ((String[]) m.get(k))[0]; + this.setParameter(k, v); + } + + } + + /** + *获取密钥 + */ + public String getKey() { + return key; + } + + /** + *设置密钥 + */ + public void setKey(String key) { + this.key = key; + } + + /** + * 获取参数值 + * @param parameter 参数名称 + * @return String + */ + public String getParameter(String parameter) { + String s = (String)this.parameters.get(parameter); + return (null == s) ? "" : s; + } + + /** + * 设置参数值 + * @param parameter 参数名称 + * @param parameterValue 参数值 + */ + public void setParameter(String parameter, String parameterValue) { + String v = ""; + if(null != parameterValue) { + v = parameterValue.trim(); + } + this.parameters.put(parameter, v); + } + + /** + * 返回所有的参数 + * @return SortedMap + */ + public SortedMap getAllParameters() { + return this.parameters; + } + + /** + * 是否财付通签名,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。 + * @return boolean + */ + public boolean isTenpaySign() { + StringBuffer sb = new StringBuffer(); + Set es = this.parameters.entrySet(); + Iterator it = es.iterator(); + while(it.hasNext()) { + Map.Entry entry = (Map.Entry)it.next(); + String k = (String)entry.getKey(); + String v = (String)entry.getValue(); + if(!"sign".equals(k) && null != v && !"".equals(v)) { +// if(!k.equals("PcacheTime")){ + sb.append(k + "=" + v + "&"); +// } + } + } + + sb.append("key=" + this.getKey()); + + //算出摘要 + String enc = TenpayUtil.getCharacterEncoding(this.request, this.response); + String sign = MD5Util.MD5Encode(sb.toString(), enc).toLowerCase(); + + String tenpaySign = this.getParameter("sign").toLowerCase(); + + //debug信息 + this.setDebugInfo(sb.toString() + " => sign:" + sign + + " tenpaySign:" + tenpaySign); + + return tenpaySign.equals(sign); + } + + /** + * 返回处理结果给财付通服务器。 + * @param msg: Success or fail。 + * @throws IOException + */ + public void sendToCFT(String msg) throws IOException { + String strHtml = msg; + PrintWriter out = this.getHttpServletResponse().getWriter(); + out.println(strHtml); + out.flush(); + out.close(); + + } + + /** + * 获取uri编码 + * @return String + */ + public String getUriEncoding() { + return uriEncoding; + } + + /** + * 设置uri编码 + * @param uriEncoding + * @throws UnsupportedEncodingException + */ + public void setUriEncoding(String uriEncoding) + throws UnsupportedEncodingException { + if (!"".equals(uriEncoding.trim())) { + this.uriEncoding = uriEncoding; + + // 编码转换 + String enc = TenpayUtil.getCharacterEncoding(request, response); + Iterator it = this.parameters.keySet().iterator(); + while (it.hasNext()) { + String k = (String) it.next(); + String v = this.getParameter(k); + v = new String(v.getBytes(uriEncoding.trim()), enc); + this.setParameter(k, v); + } + } + } + + /** + *获取debug信息 + */ + public String getDebugInfo() { + return debugInfo; + } + + /** + *设置debug信息 + */ + protected void setDebugInfo(String debugInfo) { + this.debugInfo = debugInfo; + } + + protected HttpServletRequest getHttpServletRequest() { + return this.request; + } + + protected HttpServletResponse getHttpServletResponse() { + return this.response; + } + +} diff --git a/src/main/java/me/mofun/tenpay/client/ClientResponseHandler.java b/src/main/java/me/mofun/tenpay/client/ClientResponseHandler.java new file mode 100644 index 0000000..e197704 --- /dev/null +++ b/src/main/java/me/mofun/tenpay/client/ClientResponseHandler.java @@ -0,0 +1,202 @@ +package me.mofun.tenpay.client; + +import me.mofun.tenpay.util.MD5Util; +import me.mofun.tenpay.util.XMLUtil; +import org.jdom.JDOMException; + +import java.io.IOException; +import java.util.*; +/** + * 后台应答类
    + * ========================================================================
    + * api说明:
    + * getKey()/setKey(),获取/设置密钥
    + * getContent() / setContent(), 获取/设置原始内容
    + * getParameter()/setParameter(),获取/设置参数值
    + * getAllParameters(),获取所有参数
    + * isTenpaySign(),是否财付通签名,true:是 false:否
    + * getDebugInfo(),获取debug信息
    + * + * ========================================================================
    + * + */ +public class ClientResponseHandler { + + /** 应答原始内容 */ + private String content; + + /** 应答的参数 */ + private SortedMap parameters; + + /** debug信息 */ + private String debugInfo; + + /** 密钥 */ + private String key; + + /** 字符集 */ + private String charset; + + public ClientResponseHandler() { + this.content = ""; + this.parameters = new TreeMap(); + this.debugInfo = ""; + this.key = ""; + this.charset = "GBK"; + } + + public String getContent() { + return content; + } + + public void setContent(String content) throws Exception { + this.content = content; + + this.doParse(); + } + + /** + * 获取参数值 + * @param parameter 参数名称 + * @return String + */ + public String getParameter(String parameter) { + String s = (String)this.parameters.get(parameter); + return (null == s) ? "" : s; + } + + /** + * 设置参数值 + * @param parameter 参数名称 + * @param parameterValue 参数值 + */ + public void setParameter(String parameter, String parameterValue) { + String v = ""; + if(null != parameterValue) { + v = parameterValue.trim(); + } + this.parameters.put(parameter, v); + } + + /** + * 返回所有的参数 + * @return SortedMap + */ + public SortedMap getAllParameters() { + return this.parameters; + } + + public String getDebugInfo() { + return debugInfo; + } + + /** + *获取密钥 + */ + public String getKey() { + return key; + } + + /** + *设置密钥 + */ + public void setKey(String key) { + this.key = key; + } + + public String getCharset() { + return this.charset; + } + + public void setCharset(String charset) { + this.charset = charset; + } + + /** + * 是否财付通签名,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。 + * @return boolean + */ + public boolean isTenpaySign() { + StringBuffer sb = new StringBuffer(); + Set es = this.parameters.entrySet(); + Iterator it = es.iterator(); + while(it.hasNext()) { + Map.Entry entry = (Map.Entry)it.next(); + String k = (String)entry.getKey(); + String v = (String)entry.getValue(); + if(!"sign".equals(k) && null != v && !"".equals(v)) { + sb.append(k + "=" + v + "&"); + } + } + + sb.append("key=" + this.getKey()); + + //算出摘要 + String sign = MD5Util.MD5Encode(sb.toString(), this.charset).toLowerCase(); + + String tenpaySign = this.getParameter("sign").toLowerCase(); + + //debug信息 + this.setDebugInfo(sb.toString() + " => sign:" + sign + + " tenpaySign:" + tenpaySign); + + return tenpaySign.equals(sign); + } + + /** + * 是否财付通签名 + * @param signParameterArray 签名的参数数组 + * @return boolean + */ + protected boolean isTenpaySign(String signParameterArray[]) { + + StringBuffer signPars = new StringBuffer(); + for(int index = 0; index < signParameterArray.length; index++) { + String k = signParameterArray[index]; + String v = this.getParameter(k); + if(null != v && !"".equals(v)) { + signPars.append(k + "=" + v + "&"); + } + } + + signPars.append("key=" + this.getKey()); + + //算出摘要 + String sign = MD5Util.MD5Encode( + signPars.toString(), this.charset).toLowerCase(); + + String tenpaySign = this.getParameter("sign").toLowerCase(); + + //debug信息 + this.setDebugInfo(signPars.toString() + " => sign:" + sign + + " tenpaySign:" + tenpaySign); + + return tenpaySign.equals(sign); + } + + + protected void setDebugInfo(String debugInfo) { + this.debugInfo = debugInfo; + } + + /** + * 解析XML内容 + */ + protected void doParse() throws JDOMException, IOException { + String xmlContent = this.getContent(); + + //解析xml,得到map + Map m = XMLUtil.doXMLParse(xmlContent); + + //设置参数 + Iterator it = m.keySet().iterator(); + while(it.hasNext()) { + String k = (String) it.next(); + String v = (String) m.get(k); + this.setParameter(k, v); + } + + } + + +} diff --git a/src/main/java/me/mofun/tenpay/client/TenpayHttpClient.java b/src/main/java/me/mofun/tenpay/client/TenpayHttpClient.java new file mode 100644 index 0000000..86abb99 --- /dev/null +++ b/src/main/java/me/mofun/tenpay/client/TenpayHttpClient.java @@ -0,0 +1,442 @@ +package me.mofun.tenpay.client; + +import me.mofun.tenpay.util.HttpClientUtil; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import java.io.*; +import java.net.HttpURLConnection; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +/** + * 财付通http或者https网络通信客户端
    + * ========================================================================
    + * api说明:
    + * setReqContent($reqContent),设置请求内容,无论post和get,都用get方式提供
    + * getResContent(), 获取应答内容
    + * setMethod(method),设置请求方法,post或者get
    + * getErrInfo(),获取错误信息
    + * setCertInfo(certFile, certPasswd),设置证书,双向https时需要使用
    + * setCaInfo(caFile), 设置CA,格式未pem,不设置则不检查
    + * setTimeOut(timeOut), 设置超时时间,单位秒
    + * getResponseCode(), 取返回的http状态码
    + * call(),真正调用接口
    + * getCharset()/setCharset(),字符集编码
    + * + * ========================================================================
    + * + */ +public class TenpayHttpClient { + + private static final String USER_AGENT_VALUE = + "Mozilla/4.0 (compatible; MSIE 6.0; Windows XP)"; + + private static final String JKS_CA_FILENAME = + "tenpay_cacert.jks"; + + private static final String JKS_CA_ALIAS = "tenpay"; + + private static final String JKS_CA_PASSWORD = ""; + + /** ca证书文件 */ + private File caFile; + + /** 证书文件 */ + private File certFile; + + /** 证书密码 */ + private String certPasswd; + + /** 请求内容,无论post和get,都用get方式提供 */ + private String reqContent; + + /** 应答内容 */ + private String resContent; + + /** 请求方法 */ + private String method; + + /** 错误信息 */ + private String errInfo; + + /** 超时时间,以秒为单位 */ + private int timeOut; + + /** http应答编码 */ + private int responseCode; + + /** 字符编码 */ + private String charset; + + private InputStream inputStream; + + public TenpayHttpClient() { + this.caFile = null; + this.certFile = null; + this.certPasswd = ""; + + this.reqContent = ""; + this.resContent = ""; + this.method = "POST"; + this.errInfo = ""; + this.timeOut = 30;//30秒 + + this.responseCode = 0; + this.charset = "GBK"; + + this.inputStream = null; + } + + /** + * 设置证书信息 + * @param certFile 证书文件 + * @param certPasswd 证书密码 + */ + public void setCertInfo(File certFile, String certPasswd) { + this.certFile = certFile; + this.certPasswd = certPasswd; + } + + /** + * 设置ca + * @param caFile + */ + public void setCaInfo(File caFile) { + this.caFile = caFile; + } + + /** + * 设置请求内容 + * @param reqContent 表求内容 + */ + public void setReqContent(String reqContent) { + this.reqContent = reqContent; + } + + /** + * 获取结果内容 + * @return String + * @throws IOException + */ + public String getResContent() { + try { + this.doResponse(); + } catch (IOException e) { + this.errInfo = e.getMessage(); + //return ""; + } + return this.resContent; + } + + /** + * 设置请求方法post或者get + * @param method 请求方法post/get + */ + public void setMethod(String method) { + this.method = method; + } + + /** + * 获取错误信息 + * @return String + */ + public String getErrInfo() { + return this.errInfo; + } + + /** + * 设置超时时间,以秒为单位 + * @param timeOut 超时时间,以秒为单位 + */ + public void setTimeOut(int timeOut) { + this.timeOut = timeOut; + } + + /** + * 获取http状态码 + * @return int + */ + public int getResponseCode() { + return this.responseCode; + } + + /** + * 执行http调用。true:成功 false:失败 + * @return boolean + */ + public boolean call() { + + boolean isRet = false; + + //http + if(null == this.caFile && null == this.certFile) { + try { + this.callHttp(); + isRet = true; + } catch (IOException e) { + this.errInfo = e.getMessage(); + } + return isRet; + } + + //https + try { + this.callHttps(); + isRet = true; + } catch (UnrecoverableKeyException e) { + this.errInfo = e.getMessage(); + } catch (KeyManagementException e) { + this.errInfo = e.getMessage(); + } catch (CertificateException e) { + this.errInfo = e.getMessage(); + } catch (KeyStoreException e) { + this.errInfo = e.getMessage(); + } catch (NoSuchAlgorithmException e) { + this.errInfo = e.getMessage(); + } catch (IOException e) { + this.errInfo = e.getMessage(); + } + + return isRet; + + } + + protected void callHttp() throws IOException { + + if("POST".equals(this.method.toUpperCase())) { + String url = HttpClientUtil.getURL(this.reqContent); + String queryString = HttpClientUtil.getQueryString(this.reqContent); + byte[] postData = queryString.getBytes(this.charset); + this.httpPostMethod(url, postData); + + return ; + } + + this.httpGetMethod(this.reqContent); + + } + + protected void callHttps() throws IOException, CertificateException, + KeyStoreException, NoSuchAlgorithmException, + UnrecoverableKeyException, KeyManagementException { + + // ca目录 + String caPath = this.caFile.getParent(); + + File jksCAFile = new File(caPath + "/" + + TenpayHttpClient.JKS_CA_FILENAME); + if (!jksCAFile.isFile()) { + X509Certificate cert = (X509Certificate) HttpClientUtil + .getCertificate(this.caFile); + + FileOutputStream out = new FileOutputStream(jksCAFile); + + // store jks file + HttpClientUtil.storeCACert(cert, TenpayHttpClient.JKS_CA_ALIAS, + TenpayHttpClient.JKS_CA_PASSWORD, out); + + out.close(); + + } + + FileInputStream trustStream = new FileInputStream(jksCAFile); + FileInputStream keyStream = new FileInputStream(this.certFile); + + SSLContext sslContext = HttpClientUtil.getSSLContext(trustStream, + TenpayHttpClient.JKS_CA_PASSWORD, keyStream, this.certPasswd); + + //关闭流 + keyStream.close(); + trustStream.close(); + + if("POST".equals(this.method.toUpperCase())) { + String url = HttpClientUtil.getURL(this.reqContent); + String queryString = HttpClientUtil.getQueryString(this.reqContent); + byte[] postData = queryString.getBytes(this.charset); + + this.httpsPostMethod(url, postData, sslContext); + + return ; + } + + this.httpsGetMethod(this.reqContent, sslContext); + + } + + /** + * 以http post方式通信 + * @param url + * @param postData + * @throws IOException + */ + protected void httpPostMethod(String url, byte[] postData) + throws IOException { + + HttpURLConnection conn = HttpClientUtil.getHttpURLConnection(url); + + this.doPost(conn, postData); + } + + /** + * 以http get方式通信 + * + * @param url + * @throws IOException + */ + protected void httpGetMethod(String url) throws IOException { + + HttpURLConnection httpConnection = + HttpClientUtil.getHttpURLConnection(url); + + this.setHttpRequest(httpConnection); + + httpConnection.setRequestMethod("GET"); + + this.responseCode = httpConnection.getResponseCode(); + + this.inputStream = httpConnection.getInputStream(); + + } + + /** + * 以https get方式通信 + * @param url + * @param sslContext + * @throws IOException + */ + protected void httpsGetMethod(String url, SSLContext sslContext) + throws IOException { + + SSLSocketFactory sf = sslContext.getSocketFactory(); + + HttpsURLConnection conn = HttpClientUtil.getHttpsURLConnection(url); + + conn.setSSLSocketFactory(sf); + + this.doGet(conn); + + } + + protected void httpsPostMethod(String url, byte[] postData, + SSLContext sslContext) throws IOException { + + SSLSocketFactory sf = sslContext.getSocketFactory(); + + HttpsURLConnection conn = HttpClientUtil.getHttpsURLConnection(url); + + conn.setSSLSocketFactory(sf); + + this.doPost(conn, postData); + + } + + /** + * 设置http请求默认属性 + * @param httpConnection + */ + protected void setHttpRequest(HttpURLConnection httpConnection) { + + //设置连接超时时间 + httpConnection.setConnectTimeout(this.timeOut * 1000); + + //User-Agent + httpConnection.setRequestProperty("User-Agent", + TenpayHttpClient.USER_AGENT_VALUE); + + //不使用缓存 + httpConnection.setUseCaches(false); + + //允许输入输出 + httpConnection.setDoInput(true); + httpConnection.setDoOutput(true); + + } + + /** + * 处理应答 + * @throws IOException + */ + protected void doResponse() throws IOException { + + if(null == this.inputStream) { + return; + } + + BufferedReader reader = new BufferedReader( + new InputStreamReader(this.inputStream, this.charset) ); + + //获取应答内容 + this.resContent = HttpClientUtil.bufferedReader2String(reader); + + //关闭流 + reader.close(); + + //关闭输入流 + this.inputStream.close(); + + } + + /** + * post方式处理 + * @param conn + * @param postData + * @throws IOException + */ + protected void doPost(HttpURLConnection conn, byte[] postData) + throws IOException { + + // 以post方式通信 + conn.setRequestMethod("POST"); + + // 设置请求默认属性 + this.setHttpRequest(conn); + + // Content-Type + conn.setRequestProperty("Content-Type", + "application/x-www-form-urlencoded"); + + BufferedOutputStream out = new BufferedOutputStream(conn + .getOutputStream()); + + final int len = 1024; // 1KB + HttpClientUtil.doOutput(out, postData, len); + + // 关闭流 + out.close(); + + // 获取响应返回状态码 + this.responseCode = conn.getResponseCode(); + + // 获取应答输入流 + this.inputStream = conn.getInputStream(); + + } + + /** + * get方式处理 + * @param conn + * @throws IOException + */ + protected void doGet(HttpURLConnection conn) throws IOException { + + //以GET方式通信 + conn.setRequestMethod("GET"); + + //设置请求默认属性 + this.setHttpRequest(conn); + + //获取响应返回状态码 + this.responseCode = conn.getResponseCode(); + + //获取应答输入流 + this.inputStream = conn.getInputStream(); + } + + +} diff --git a/src/main/java/me/mofun/tenpay/config/TenpayConfig.java b/src/main/java/me/mofun/tenpay/config/TenpayConfig.java new file mode 100644 index 0000000..0f75a38 --- /dev/null +++ b/src/main/java/me/mofun/tenpay/config/TenpayConfig.java @@ -0,0 +1,42 @@ +package me.mofun.tenpay.config; + +import me.mofun.util.ApplicationListenerImpl; + +public class TenpayConfig { + /** + * 商户号 + */ + public static String partner =ApplicationListenerImpl.sysConfigureJson.getTenpayPartner(); +// public static String partner ="1900000113"; + + /** + * 密钥 + */ + public static String key =ApplicationListenerImpl.sysConfigureJson.getTenpayKey(); +// public static String key ="e82573dc7e6136ba414f2e2affbe39fa"; + + /** + * 交易完成后跳转的URL + */ + public static String return_url =ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/tenpay/returnUrl.action"; +// public static String return_url ="http://124.193.138.90/tenpay/returnUrl.action"; + + /** + * 接收财付通通知的URL + */ + public static String notify_url =ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/tenpay/notifyUrl.action"; +// public static String notify_url ="http://124.193.138.90/tenpay/notifyUrl.action"; + + /** + * 冲值后跳转的URL + */ + public static String balance_return_url = ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/balance/returnUrl.action"; +// public static String balance_return_url = "http://124.193.138.90/balance/returnUrl.action"; + + /** + * 冲值后接收财付通通知的URL + */ + public static String balance_notify_url = ApplicationListenerImpl.sysConfigureJson.getWwwUrl()+"/balance/notifyUrl.action"; +// public static String balance_notify_url = "http://124.193.138.90/balance/notifyUrl.action"; + +} diff --git a/src/main/java/me/mofun/tenpay/util/HttpClientUtil.java b/src/main/java/me/mofun/tenpay/util/HttpClientUtil.java new file mode 100644 index 0000000..18e1d58 --- /dev/null +++ b/src/main/java/me/mofun/tenpay/util/HttpClientUtil.java @@ -0,0 +1,287 @@ +package me.mofun.tenpay.util; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.security.*; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.util.HashMap; +import java.util.Map; + +/** + * Http客户端工具类
    + * 这是内部调用类,请不要在外部调用。 + * @author miklchen + * + */ +public class HttpClientUtil { + + public static final String SunX509 = "SunX509"; + public static final String JKS = "JKS"; + public static final String PKCS12 = "PKCS12"; + public static final String TLS = "TLS"; + + /** + * get HttpURLConnection + * @param strUrl url地址 + * @return HttpURLConnection + * @throws IOException + */ + public static HttpURLConnection getHttpURLConnection(String strUrl) + throws IOException { + URL url = new URL(strUrl); + HttpURLConnection httpURLConnection = (HttpURLConnection) url + .openConnection(); + return httpURLConnection; + } + + /** + * get HttpsURLConnection + * @param strUrl url地址 + * @return HttpsURLConnection + * @throws IOException + */ + public static HttpsURLConnection getHttpsURLConnection(String strUrl) + throws IOException { + URL url = new URL(strUrl); + HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url + .openConnection(); + return httpsURLConnection; + } + + /** + * 获取不带查询串的url + * @param strUrl + * @return String + */ + public static String getURL(String strUrl) { + + if(null != strUrl) { + int indexOf = strUrl.indexOf("?"); + if(-1 != indexOf) { + return strUrl.substring(0, indexOf); + } + + return strUrl; + } + + return strUrl; + + } + + /** + * 获取查询串 + * @param strUrl + * @return String + */ + public static String getQueryString(String strUrl) { + + if(null != strUrl) { + int indexOf = strUrl.indexOf("?"); + if(-1 != indexOf) { + return strUrl.substring(indexOf+1, strUrl.length()); + } + + return ""; + } + + return strUrl; + } + + /** + * 查询字符串转换成Map
    + * name1=key1&name2=key2&... + * @param queryString + * @return + */ + public static Map queryString2Map(String queryString) { + if(null == queryString || "".equals(queryString)) { + return null; + } + + Map m = new HashMap(); + String[] strArray = queryString.split("&"); + for(int index = 0; index < strArray.length; index++) { + String pair = strArray[index]; + HttpClientUtil.putMapByPair(pair, m); + } + + return m; + + } + + /** + * 把键值添加至Map
    + * pair:name=value + * @param pair name=value + * @param m + */ + public static void putMapByPair(String pair, Map m) { + + if(null == pair || "".equals(pair)) { + return; + } + + int indexOf = pair.indexOf("="); + if(-1 != indexOf) { + String k = pair.substring(0, indexOf); + String v = pair.substring(indexOf+1, pair.length()); + if(null != k && !"".equals(k)) { + m.put(k, v); + } + } else { + m.put(pair, ""); + } + } + + /** + * BufferedReader转换成String
    + * 注意:流关闭需要自行处理 + * @param reader + * @return String + * @throws IOException + */ + public static String bufferedReader2String(BufferedReader reader) throws IOException { + StringBuffer buf = new StringBuffer(); + String line = null; + while( (line = reader.readLine()) != null) { + buf.append(line); + buf.append("\r\n"); + } + + return buf.toString(); + } + + /** + * 处理输出
    + * 注意:流关闭需要自行处理 + * @param out + * @param data + * @param len + * @throws IOException + */ + public static void doOutput(OutputStream out, byte[] data, int len) + throws IOException { + int dataLen = data.length; + int off = 0; + while(off < dataLen) { + if(len >= dataLen) { + out.write(data, off, dataLen); + } else { + out.write(data, off, len); + } + + //刷新缓冲区 + out.flush(); + + off += len; + + dataLen -= len; + } + + } + + /** + * 获取SSLContext + * @param trustFile + * @param trustPasswd + * @param keyFile + * @param keyPasswd + * @return + * @throws NoSuchAlgorithmException + * @throws KeyStoreException + * @throws IOException + * @throws CertificateException + * @throws UnrecoverableKeyException + * @throws KeyManagementException + */ + public static SSLContext getSSLContext( + FileInputStream trustFileInputStream, String trustPasswd, + FileInputStream keyFileInputStream, String keyPasswd) + throws NoSuchAlgorithmException, KeyStoreException, + CertificateException, IOException, UnrecoverableKeyException, + KeyManagementException { + + // ca + TrustManagerFactory tmf = TrustManagerFactory.getInstance(HttpClientUtil.SunX509); + KeyStore trustKeyStore = KeyStore.getInstance(HttpClientUtil.JKS); + trustKeyStore.load(trustFileInputStream, HttpClientUtil + .str2CharArray(trustPasswd)); + tmf.init(trustKeyStore); + + final char[] kp = HttpClientUtil.str2CharArray(keyPasswd); + KeyManagerFactory kmf = KeyManagerFactory.getInstance(HttpClientUtil.SunX509); + KeyStore ks = KeyStore.getInstance(HttpClientUtil.PKCS12); + ks.load(keyFileInputStream, kp); + kmf.init(ks, kp); + + SecureRandom rand = new SecureRandom(); + SSLContext ctx = SSLContext.getInstance(HttpClientUtil.TLS); + ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), rand); + + return ctx; + } + + /** + * 获取CA证书信息 + * @param cafile CA证书文件 + * @return Certificate + * @throws CertificateException + * @throws IOException + */ + public static Certificate getCertificate(File cafile) + throws CertificateException, IOException { + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + FileInputStream in = new FileInputStream(cafile); + Certificate cert = cf.generateCertificate(in); + in.close(); + return cert; + } + + /** + * 字符串转换成char数组 + * @param str + * @return char[] + */ + public static char[] str2CharArray(String str) { + if(null == str) return null; + + return str.toCharArray(); + } + + /** + * 存储ca证书成JKS格式 + * @param cert + * @param alias + * @param password + * @param out + * @throws KeyStoreException + * @throws NoSuchAlgorithmException + * @throws CertificateException + * @throws IOException + */ + public static void storeCACert(Certificate cert, String alias, + String password, OutputStream out) throws KeyStoreException, + NoSuchAlgorithmException, CertificateException, IOException { + KeyStore ks = KeyStore.getInstance("JKS"); + + ks.load(null, null); + + ks.setCertificateEntry(alias, cert); + + // store keystore + ks.store(out, HttpClientUtil.str2CharArray(password)); + + } + + public static InputStream String2Inputstream(String str) { + return new ByteArrayInputStream(str.getBytes()); + } + +} diff --git a/src/main/java/me/mofun/tenpay/util/MD5Util.java b/src/main/java/me/mofun/tenpay/util/MD5Util.java new file mode 100644 index 0000000..afa98e8 --- /dev/null +++ b/src/main/java/me/mofun/tenpay/util/MD5Util.java @@ -0,0 +1,45 @@ +package me.mofun.tenpay.util; + +import java.security.MessageDigest; + +public class MD5Util { + + private static String byteArrayToHexString(byte b[]) { + StringBuffer resultSb = new StringBuffer(); + for (int i = 0; i < b.length; i++) + resultSb.append(byteToHexString(b[i])); + + return resultSb.toString(); + } + + private static String byteToHexString(byte b) { + int n = b; + if (n < 0) { + n += 256; + } + int d1 = n / 16; + int d2 = n % 16; + return hexDigits[d1] + hexDigits[d2]; + } + + public static String MD5Encode(String origin, String charsetname) { + String resultString = null; + try { + resultString = new String(origin); + MessageDigest md = MessageDigest.getInstance("MD5"); + if (charsetname == null || "".equals(charsetname)) { + resultString = byteArrayToHexString(md.digest(resultString + .getBytes())); + } else { + resultString = byteArrayToHexString(md.digest(resultString + .getBytes(charsetname))); + } + } catch (Exception exception) { + } + return resultString; + } + + private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; + +} diff --git a/src/main/java/me/mofun/tenpay/util/TenpayUtil.java b/src/main/java/me/mofun/tenpay/util/TenpayUtil.java new file mode 100644 index 0000000..28a06a0 --- /dev/null +++ b/src/main/java/me/mofun/tenpay/util/TenpayUtil.java @@ -0,0 +1,131 @@ +package me.mofun.tenpay.util; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.text.SimpleDateFormat; +import java.util.Date; + + +public class TenpayUtil { + + /** + * 把对象转换成字符串 + * @param obj + * @return String 转换成字符串,若对象为null,则返回空字符串. + */ + public static String toString(Object obj) { + if(obj == null) + return ""; + + return obj.toString(); + } + + /** + * 把对象转换为int数值. + * + * @param obj + * 包含数字的对象. + * @return int 转换后的数值,对不能转换的对象返回0。 + */ + public static int toInt(Object obj) { + int a = 0; + try { + if (obj != null) + a = Integer.parseInt(obj.toString()); + } catch (Exception e) { + + } + return a; + } + + /** + * 获取当前时间 yyyyMMddHHmmss + * @return String + */ + public static String getCurrTime() { + Date now = new Date(); + SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + String s = outFormat.format(now); + return s; + } + + /** + * 获取当前日期 yyyyMMdd + * @param date + * @return String + */ + public static String formatDate(Date date) { + SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); + String strDate = formatter.format(date); + return strDate; + } + + /** + * 取出一个指定长度大小的随机正整数. + * + * @param length + * int 设定所取出随机数的长度。length小于11 + * @return int 返回生成的随机数。 + */ + public static int buildRandom(int length) { + int num = 1; + double random = Math.random(); + if (random < 0.1) { + random = random + 0.1; + } + for (int i = 0; i < length; i++) { + num = num * 10; + } + return (int) ((random * num)); + } + + /** + * 获取编码字符集 + * @param request + * @param response + * @return String + */ + public static String getCharacterEncoding(HttpServletRequest request, + HttpServletResponse response) { + + if(null == request || null == response) { + return "gbk"; + } + + String enc = request.getCharacterEncoding(); + if(null == enc || "".equals(enc)) { + enc = response.getCharacterEncoding(); + } + + if(null == enc || "".equals(enc)) { + enc = "gbk"; + } + + return enc; + } + + /** + * 获取unix时间,从1970-01-01 00:00:00开始的秒数 + * @param date + * @return long + */ + public static long getUnixTime(Date date) { + if( null == date ) { + return 0; + } + + return date.getTime()/1000; + } + + /** + * 时间转换成字符串 + * @param date 时间 + * @param formatType 格式化类型 + * @return String + */ + public static String date2String(Date date, String formatType) { + SimpleDateFormat sdf = new SimpleDateFormat(formatType); + return sdf.format(date); + } + +} diff --git a/src/main/java/me/mofun/tenpay/util/XMLUtil.java b/src/main/java/me/mofun/tenpay/util/XMLUtil.java new file mode 100644 index 0000000..05410ee --- /dev/null +++ b/src/main/java/me/mofun/tenpay/util/XMLUtil.java @@ -0,0 +1,103 @@ +package me.mofun.tenpay.util; + +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * xml工具类 + * @author miklchen + * + */ +public class XMLUtil { + + /** + * 解析xml,返回第一级元素键值对。如果第一级元素有子节点,则此节点的值是子节点的xml数据。 + * @param strxml + * @return + * @throws JDOMException + * @throws IOException + */ + public static Map doXMLParse(String strxml) throws JDOMException, IOException { + if(null == strxml || "".equals(strxml)) { + return null; + } + + Map m = new HashMap(); + InputStream in = HttpClientUtil.String2Inputstream(strxml); + SAXBuilder builder = new SAXBuilder(); + Document doc = builder.build(in); + Element root = doc.getRootElement(); + List list = root.getChildren(); + Iterator it = list.iterator(); + while(it.hasNext()) { + Element e = (Element) it.next(); + String k = e.getName(); + String v = ""; + List children = e.getChildren(); + if(children.isEmpty()) { + v = e.getTextNormalize(); + } else { + v = XMLUtil.getChildrenText(children); + } + + m.put(k, v); + } + + //关闭流 + in.close(); + + return m; + } + + /** + * 获取子结点的xml + * @param children + * @return String + */ + public static String getChildrenText(List children) { + StringBuffer sb = new StringBuffer(); + if(!children.isEmpty()) { + Iterator it = children.iterator(); + while(it.hasNext()) { + Element e = (Element) it.next(); + String name = e.getName(); + String value = e.getTextNormalize(); + List list = e.getChildren(); + sb.append("<" + name + ">"); + if(!list.isEmpty()) { + sb.append(XMLUtil.getChildrenText(list)); + } + sb.append(value); + sb.append(""); + } + } + + return sb.toString(); + } + + /** + * 获取xml编码字符集 + * @param strxml + * @return + * @throws IOException + * @throws JDOMException + */ + public static String getXMLEncoding(String strxml) throws JDOMException, IOException { + InputStream in = HttpClientUtil.String2Inputstream(strxml); + SAXBuilder builder = new SAXBuilder(); + Document doc = builder.build(in); + in.close(); + return (String)doc.getProperty("encoding"); + } + + +} diff --git a/src/main/java/me/mofun/test/CrawlUserFaceImg.java b/src/main/java/me/mofun/test/CrawlUserFaceImg.java new file mode 100644 index 0000000..0fa073c --- /dev/null +++ b/src/main/java/me/mofun/test/CrawlUserFaceImg.java @@ -0,0 +1,375 @@ +package me.mofun.test; + +import me.mofun.service.UserService; +import me.mofun.util.ReadFile; +import me.mofun.util.SaveFile; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.commons.lang.time.DateUtils; +import org.apache.http.HttpHost; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.DefaultHttpClient; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.*; + + +public class CrawlUserFaceImg { + + private static DefaultHttpClient httpClient; + private static HttpGet httpGet; + private HttpPost httpPost; + + @Autowired + private UserService userService; + + @Test + public void go() throws Exception{ + httpClient = new DefaultHttpClient(); + org.apache.http.params.HttpParams params = httpClient.getParams(); + org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, 60000); + org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 60000); + int count = 1400; + int codeID = 24069; + int i = 1; + int j = 10; + long startDate = System.currentTimeMillis(); + int imgCount = 0; + List imgList = new ArrayList(); + while(count --> 0){ + try { + System.err.println(i +" "+j); +// http://dataserver.ipdz.me/JPData?action=GetUserBuyListByCode&codeID=11807&FIdx=51&EIdx=60&isCount=0&fun=jsonp1362634201995&_=1362644662143 + String url = "http://dataserver.ipdz.me/JPData?action=GetUserBuyListByCode&codeID="+codeID+"&FIdx="+i+"&EIdx="+j+"&fun=jsonp"+startDate+"&_="+System.currentTimeMillis(); + System.err.println(url); + httpGet = new HttpGet(url); + httpGet.setHeader("Accept", "*/*"); + httpGet.setHeader("Accept-Encoding", "gzip, deflate"); + httpGet.setHeader("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"); + httpGet.setHeader("Connection", "keep-alive"); + httpGet.setHeader("Cookie", "__utma=248799431.1617822012.1357546987.1357546987.1357611571.2; __utmz=248799431.1357546987.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmb=248799431.4.10.1357611571; __utmc=248799431"); + httpGet.setHeader("Host", "dataserver.ipdz.me"); + httpGet.setHeader("Referer", "http://www.ipdz.me/products/21252.html"); + httpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20100101 Firefox/17.0"); + ResponseHandler responseHandler = new BasicResponseHandler(); + String content = httpClient.execute(httpGet,responseHandler); + content = content.replaceAll("jsonp"+startDate, ""); + content = content.substring(1, content.length()); + content = content.substring(0, content.length()-1); + JSONObject object = JSONObject.fromObject(content); + JSONObject data = JSONObject.fromObject(object.getString("Data")); + JSONObject Tables = JSONObject.fromObject(data.getString("Tables")); + JSONObject BuyList = JSONObject.fromObject(Tables.getString("BuyList")); + JSONArray Rows = JSONArray.fromObject(BuyList.getString("Rows")); + for (Object object2 : Rows) { + JSONObject obj = JSONObject.fromObject(object2); +// System.err.println(obj); +// System.err.println(obj.getString("userName")); +// System.err.println(obj.getString("buyNum")); +// System.err.println(obj.getString("buyIP")); +// System.err.println(obj.getString("buyIPAddr")); +// System.err.println(obj.getString("buyTime")); +// System.err.println(obj.getString("userPhoto")); + + + if(!obj.getString("userPhoto").equals("00000000000000000.jpg")){ + String imgUrl = "http://faceimg.ipdz.me/UserFace/160/"+obj.getString("userPhoto"); + System.err.println(imgUrl); +// WeiboImg.getImage(imgUrl, "c:\\userImgTemp\\"+obj.getString("userPhoto")); + SaveFile.svaeWeibo("c:\\imgFile2.txt", imgUrl+"-."+obj.getString("userPhoto").split("\\.")[1]); +// System.err.println(obj.getString("userPhoto")); +// System.err.println(obj.getString("userPhoto").split("\\.")[1]); + +// WeiboImg.getImage(imgUrl, "c:\\UserImg\\"+imgCount+"."+obj.getString("userPhoto").split("\\.")[1]); +// imgCount++; + } + } + startDate+=1; + i+=10; + j+=10; +// break; + } catch (Exception e) { + e.printStackTrace(); + break; + } + + } + } + + public static void main(String[] args) throws Exception { + CrawlUserFaceImg crawlUserFaceImg = new CrawlUserFaceImg(); +// System.err.println(new Date(Long.parseLong("1372731188001"))); +// System.err.println(DateUtils.addMinutes(new Date(), -5).getTime()); +// HttpHost proxy = new HttpHost("64.85.181.46", 8080); +// crawlUserFaceImg.loginWeibo("15201558450","epgwyc11",proxy); +// crawlUserFaceImg.createUserFace("1000546330"); +// getUserDate(); +// readfile("c:\\UserImg\\"); +// List list = imgList("c:\\UserImg\\"); +// for (String string : list) { +// System.err.println(string); +// } +// WeiboImg.getImage("http://faceimg.ipdz.me/UserFace/160/00000000000000035.gif", "c:\\123\\123.gif"); + Map map = new TreeMap(); + + ReadFile readFile = new ReadFile(); + List strList = readFile.readFile("c:\\imgFile.txt"); + for (String string : strList) { + map.put(string, string); + } + System.err.println(map.size()); + for (Object object : map.keySet()) { +// System.err.println(map.get(object)); + WeiboImg.getImage(map.get(object).split("-")[0], "c:\\UserImg\\"+System.currentTimeMillis()+map.get(object).split("-")[1]); + } + + +// map.put("00000000000000035", "http://faceimg.ipdz.me/UserFace/160/00000000000000035.gif-.gif"); +// map.put("00000000000000035", "http://faceimg.ipdz.me/UserFace/160/00000000000000035.gif-.gif"); +// map.put("00000000000000035", "http://faceimg.ipdz.me/UserFace/160/00000000000000035.gif-.gif"); +// map.put("00000000000000035", "http://faceimg.ipdz.me/UserFace/160/00000000000000035.gif-.gif"); +// map.put("123", "http://faceimg.ipdz.me/UserFace/160/00000000000000035.gif-.gif"); +// for (Object object : map.keySet()) { +// System.err.println(map.get(object)+object); +// } + } + + public synchronized String loginWeibo(String username,String password,HttpHost proxy) throws Exception{ + httpClient = new DefaultHttpClient(); + org.apache.http.params.HttpParams params = httpClient.getParams(); + org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, 60000); + org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 60000); + +// String cookie = "U_TRS1=0000005a.da7c329.501f3982.97007c28; path=/; expires=Thu, 04-Aug-22 03:26:58 GMT; domain=.sina.com.cn U_TRS2=0000005a.da90329.501f3982.95384a8f; path=/; domain=.sina.com.cn"; +// String domain = "http://weibo.com/jiejingkong"; + +// httpClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109); +// HttpState initialState = new HttpState(); +// String[] cookieNameAndValue = getCookieNameAndCookieValue(setSinaCookie(cookie)); +// initialState.addCookie(new Cookie(domain, cookieNameAndValue[0], cookieNameAndValue[1], "/", new Date(new Date().getTime() + 1000 * 60 * 60 * 24), false)); + +// HttpPost httpPost = new HttpPost("http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.1)"); +// ResponseHandler responseHandler = new BasicResponseHandler(); +// httpPost.setEntity(new UrlEncodedFormEntity(postList, HTTP.UTF_8)); +// String responseBody = httpClient.execute(httpPost, responseHandler); + String url = "http://passport.ipdz.me/JPData?action=userlogin&name="+username+"&pwd="+password+"&fun=jsonp"+DateUtils.addMinutes(new Date(), -5).getTime()+"&_="+System.currentTimeMillis(); + httpGet = new HttpGet(url); + httpGet.setHeader("Accept","text/javascript, application/javascript, */*"); + httpGet.setHeader("Accept-Encoding","gzip, deflate"); + httpGet.setHeader("Accept-Language","zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"); + httpGet.setHeader("Connection","keep-alive"); + httpGet.setHeader("Cookie","__utma=248799431.455476130.1371809745.1372668973.1372729700.19; __utmz=248799431.1372385864.12.6.utmcsr=ipdz.me|utmccn=(referral)|utmcmd=referral|utmcct=/; CNZZDATA3362429=cnzz_eid%3D1594148446-1372212393-http%253A%252F%252Fpassport.ipdz.me%26ntime%3D1372729700%26cnzz_a%3D0%26retime%3D1372731187996%26sin%3Dhttp%253A%252F%252Fu.ipdz.me%252F1000652467%26ltime%3D1372731187996%26rtime%3D2; __utmb=248799431.7.10.1372729700; __utmc=248799431"); + httpGet.setHeader("Host","passport.ipdz.me"); + httpGet.setHeader("Referer","http://passport.ipdz.me/login.html?forward=rego"); + httpGet.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0"); + httpGet.setHeader("X-Requested-With","XMLHttpRequest"); + ResponseHandler responseHandler = new BasicResponseHandler(); + String result1 = httpClient.execute(httpGet, responseHandler); + System.err.println(result1); + return null; + } + + public synchronized String createUserFace(String id) throws Exception{ + if(httpClient == null){ + throw new Exception("httpClientΪnull..."); + } + String url = "http://u.ipdz.me/"+id; + httpGet = new HttpGet(url); + ResponseHandler responseHandler = new BasicResponseHandler(); + String result1 = httpClient.execute(httpGet, responseHandler); + System.err.println(result1); + return null; + } + + public static String getUserDate() throws ClientProtocolException, IOException{ + httpClient = new DefaultHttpClient(); + org.apache.http.params.HttpParams params = httpClient.getParams(); + org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, 60000); + org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 60000); + int count = 1400; + int codeID = 11807; + int i = 1; + int j = 10; + long startDate = System.currentTimeMillis(); + while(count --> 0){ + System.err.println(i +" "+j); +// http://dataserver.ipdz.me/JPData?action=GetUserBuyListByCode&codeID=11807&FIdx=51&EIdx=60&isCount=0&fun=jsonp1362634201995&_=1362644662143 + String url = "http://dataserver.ipdz.me/JPData?action=GetUserBuyListByCode&codeID="+codeID+"&FIdx="+i+"&EIdx="+j+"&fun=jsonp"+startDate+"&_="+System.currentTimeMillis(); + System.err.println(url); + httpGet = new HttpGet(url); + httpGet.setHeader("Accept", "*/*"); + httpGet.setHeader("Accept-Encoding", "gzip, deflate"); + httpGet.setHeader("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"); + httpGet.setHeader("Connection", "keep-alive"); + httpGet.setHeader("Cookie", "__utma=248799431.1617822012.1357546987.1357546987.1357611571.2; __utmz=248799431.1357546987.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmb=248799431.4.10.1357611571; __utmc=248799431"); + httpGet.setHeader("Host", "dataserver.ipdz.me"); + httpGet.setHeader("Referer", "http://www.ipdz.me/products/21252.html"); + httpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20100101 Firefox/17.0"); + ResponseHandler responseHandler = new BasicResponseHandler(); + String content = httpClient.execute(httpGet,responseHandler); + content = content.replaceAll("jsonp"+startDate, ""); + content = content.substring(1, content.length()); + content = content.substring(0, content.length()-1); + JSONObject object = JSONObject.fromObject(content); + JSONObject data = JSONObject.fromObject(object.getString("Data")); + JSONObject Tables = JSONObject.fromObject(data.getString("Tables")); + JSONObject BuyList = JSONObject.fromObject(Tables.getString("BuyList")); + JSONArray Rows = JSONArray.fromObject(BuyList.getString("Rows")); + for (Object object2 : Rows) { + JSONObject obj = JSONObject.fromObject(object2); +// System.err.println(obj); +// System.err.println(obj.getString("userName")); +// System.err.println(obj.getString("buyNum")); +// System.err.println(obj.getString("buyIP")); +// System.err.println(obj.getString("buyIPAddr")); +// System.err.println(obj.getString("buyTime")); +// System.err.println(obj.getString("userPhoto")); + if(!obj.getString("userPhoto").equals("00000000000000000.jpg")){ + System.err.println("http://faceimg.ipdz.me/UserFace/160/"+obj.getString("userPhoto")); + } + } + startDate+=1; + i+=10; + j+=10; + break; + } + + return null; + } + + public static List imgList(String filepath) throws FileNotFoundException, IOException{ + List imgList = new ArrayList(); + File file = new File(filepath); + if (!file.isDirectory()) { + System.err.println("文件夹不存在!"); + }else if(file.isDirectory()){ + String[] filelist = file.list(); + for (int i = 0; i < filelist.length; i++) { + File readfile = new File(filepath + "\\" + filelist[i]); + if (!readfile.isDirectory()) { +// System.out.println("path=" + readfile.getPath()); +// System.out.println("absolutepath="+ readfile.getAbsolutePath()); +// System.out.println("name=" + readfile.getName()); + imgList.add(readfile.getName()); + } else if (readfile.isDirectory()) { + readfile(filepath + "\\" + filelist[i]); + } + } + } + return imgList; + } + + /** + * 读取某个文件夹下的所有文件 + */ + public static boolean readfile(String filepath) throws FileNotFoundException, IOException { + try { + + File file = new File(filepath); + if (!file.isDirectory()) { + System.out.println("文件"); +// System.out.println("path=" + file.getPath()); +// System.out.println("absolutepath=" + file.getAbsolutePath()); + System.out.println("name1=" + file.getName()); + + } else if (file.isDirectory()) { + System.out.println("文件夹"); + String[] filelist = file.list(); + for (int i = 0; i < filelist.length; i++) { + File readfile = new File(filepath + "\\" + filelist[i]); + if (!readfile.isDirectory()) { +// System.out.println("path=" + readfile.getPath()); +// System.out.println("absolutepath="+ readfile.getAbsolutePath()); + System.out.println("name2=" + readfile.getName()); + + } else if (readfile.isDirectory()) { + readfile(filepath + "\\" + filelist[i]); + } + } + + } + + } catch (FileNotFoundException e) { + System.out.println("readfile() Exception:" + e.getMessage()); + } + return true; + } + + private static String[] getCookieNameAndCookieValue(Map cookie) { + String[] result = new String[2]; + String cookieName = null; + String cookieValue = ""; + String key; + Iterator iterator = cookie.keySet().iterator(); + while (iterator.hasNext()) { + if (cookieName == null) + cookieName = iterator.next(); + else { + key = iterator.next(); + cookieValue = cookieValue + key + "=" + cookie.get(key) + ";"; + } + } + cookieValue = cookie.get(cookieName) + ";" + cookieValue; + result[0] = cookieName; + result[1] = cookieValue; + return result; + } + + public static Map setSinaCookie(String sinacookie) { + Map map = new HashMap(); + for (int i = 0; i < sinacookie.split(";").length; i = i + 1) { + try { + map.put(sinacookie.split(";")[i].split("=")[0].trim(), sinacookie.split(";")[i].split("=")[1]); + // System.out.println(sinacookie.split(";")[i].split("=")[0].trim() + // + " = " + sinacookie.split(";")[i].split("=")[1].trim()); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + return map; + } + + public static String encryptPassword(String password, String servertime, String code) { + return Encrypt(Encrypt(Encrypt(password)) + servertime + code); + } + + public static String Encrypt(String strSrc) { + MessageDigest md = null; + String strDes = null; + byte[] bt = strSrc.getBytes(); + try { + md = MessageDigest.getInstance("SHA-1"); + md.update(bt); + strDes = bytes2Hex(md.digest()); // to HexString + } catch (NoSuchAlgorithmException e) { + System.out.println("Invalid algorithm."); + return null; + } + return strDes; + } + + public static String bytes2Hex(byte[] bts) { + String des = ""; + String tmp = null; + for (int i = 0; i < bts.length; i++) { + tmp = (Integer.toHexString(bts[i] & 0xFF)); + if (tmp.length() == 1) { + des += "0"; + } + des += tmp; + } + return des; + } + +} diff --git a/src/main/java/me/mofun/test/EngineContainer.java b/src/main/java/me/mofun/test/EngineContainer.java new file mode 100644 index 0000000..38b2b3c --- /dev/null +++ b/src/main/java/me/mofun/test/EngineContainer.java @@ -0,0 +1,28 @@ +package me.mofun.test; + +import java.util.List; + +public class EngineContainer { + + private List engineList; + private static int count = 0; + + public EngineContainer(List engineList){ + this.engineList = engineList; + } + + public synchronized String getEngineUrl() { + if(engineList.size()==count){ + count = 0; + } + return engineList.get(count++); + } + + public boolean isEmpty(){ + boolean isEmpty = false; + if(engineList.size()==0) + isEmpty = true; + return isEmpty; + } + +} diff --git a/src/main/java/me/mofun/test/EngineTest.java b/src/main/java/me/mofun/test/EngineTest.java new file mode 100644 index 0000000..f0b5789 --- /dev/null +++ b/src/main/java/me/mofun/test/EngineTest.java @@ -0,0 +1,81 @@ +package me.mofun.test; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class EngineTest { + + public static void main(String[] args) { + new EngineTest().run(); + } + + public void run(){ +try { + + // 获得所有账号信息 + String separator = System.getProperty("file.separator"); +// String path = System.getProperty("user.dir") + separator + "config" + separator + "account.txt"; + String path = Thread.currentThread().getContextClassLoader().getResource("").getPath()+"account.txt"; + + List engineList = new ArrayList(); + //1元拍购 + engineList.add("http://www.baidu.com/s?wd=1%E5%85%83%E6%8B%8D%E8%B4%AD&rsv_bp=0&ch=&tn=baidu&bar=&rsv_spt=3&ie=utf-8&rsv_sug3=4&rsv_sug=0&rsv_sug1=4&rsv_sug4=51&inputT=5488"); + //1元拍 + engineList.add("http://www.baidu.com/s?ie=utf-8&bs=1%E5%85%83%E6%8B%8D&f=8&rsv_bp=1&rsv_spt=3&wd=1%E5%85%83%E6%8B%8D&inputT=0"); + engineList.add("http://www.baidu.com/s?ie=utf-8&bs=1%E5%85%83%E6%8B%8D%E8%B4%AD&f=8&rsv_bp=1&rsv_spt=3&wd=1%E5%85%83%E6%8B%8D&rsv_sug3=1&rsv_sug1=1&rsv_sug4=20&inputT=3520"); + engineList.add("http://www.baidu.com/link?url=jGs2GJqjJ4zBBpC8yDF8xDh8vibiRE26EyoEbodO"); + engineList.add("http://www.baidu.com/s?ie=utf-8&bs=%E6%8B%8D%E8%B4%AD%E7%BD%91&f=8&rsv_bp=1&wd=%E6%8B%8D%E8%B4%AD&rsv_sug3=1&rsv_sug=0&rsv_sug1=1&rsv_sug4=17&inputT=590"); + engineList.add("http://www.baidu.com/s?ie=utf-8&bs=%E6%8B%8D%E8%B4%AD&f=8&rsv_bp=1&wd=1%E5%85%83%E6%8B%8D%E8%B4%AD%E7%BD%91&rsv_n=2&rsv_sug3=1&rsv_sug1=1&rsv_sug4=12&inputT=710"); + engineList.add("http://www.baidu.com/s?ie=utf-8&bs=%E4%B8%80%E5%85%83%E6%8B%8D%E8%B4%AD&f=8&rsv_bp=1&wd=%E4%B8%80%E5%85%83%E6%8B%8D%E8%B4%AD+ipdz.me&rsv_sug3=7&rsv_sug1=6&rsv_sug4=61&inputT=3199"); + engineList.add("http://www.baidu.com/s?ie=utf-8&bs=%E4%B8%80%E5%85%83%E8%B4%AD%E7%89%A9&f=8&rsv_bp=1&wd=%E4%B8%80%E5%85%83%E8%B4%AD%E7%89%A9&inputT=0"); + engineList.add("http://www.baidu.com/s?ie=utf-8&bs=%E4%B8%80%E5%85%83%E8%B4%AD%E7%89%A9&f=8&rsv_bp=1&wd=1%E5%85%83%E8%B4%AD%E7%89%A9&rsv_sug3=1&rsv_sug1=1&rsv_sug4=9&inputT=224"); + engineList.add("http://www.baidu.com/s?ie=utf-8&bs=1%E5%85%83%E8%B4%AD%E7%89%A9&f=8&rsv_bp=1&wd=1%E5%85%83%E8%B4%AD%E7%89%A9&inputT=0"); + +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364534679&nv=1&rnd=186738380&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26bs%3D1%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9%26f%3D8%26rsv_bp%3D1%26wd%3D1%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9%26inputT%3D0&sw=1%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364534796&nv=1&rnd=907471097&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fwd%3D1%25E5%2585%2583%25E6%258B%258D%25E8%25B4%25AD%26rsv_bp%3D0%26ch%3D%26tn%3Dbaidu%26bar%3D%26rsv_spt%3D3%26ie%3Dutf-8%26rsv_sug3%3D4%26rsv_sug%3D0%26rsv_sug1%3D4%26rsv_sug4%3D51%26inputT%3D5488&sw=1%25E5%2585%2583%25E6%258B%258D%25E8%25B4%25AD&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364534830&nv=1&rnd=1169128642&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26bs%3D1%25E5%2585%2583%25E6%258B%258D%26f%3D8%26rsv_bp%3D1%26rsv_spt%3D3%26wd%3D1%25E5%2585%2583%25E6%258B%258D%26inputT%3D0&sw=1%25E5%2585%2583%25E6%258B%258D&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364534924&nv=1&rnd=1188301869&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26bs%3D1%25E5%2585%2583%25E6%258B%258D%25E8%25B4%25AD%26f%3D8%26rsv_bp%3D1%26rsv_spt%3D3%26wd%3D1%25E5%2585%2583%25E6%258B%258D%26rsv_sug3%3D1%26rsv_sug1%3D1%26rsv_sug4%3D20%26inputT%3D3520&sw=1%25E5%2585%2583%25E6%258B%258D&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364534924&nv=0&rnd=267843145&si=874caa3b9536373fecc72345e5e0ef19&st=4&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364535034&nv=1&rnd=849236387&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26bs%3D%25E6%258B%258D%25E8%25B4%25AD%25E7%25BD%2591%26f%3D8%26rsv_bp%3D1%26wd%3D%25E6%258B%258D%25E8%25B4%25AD%26rsv_sug3%3D1%26rsv_sug%3D0%26rsv_sug1%3D1%26rsv_sug4%3D17%26inputT%3D590&sw=%25E6%258B%258D%25E8%25B4%25AD&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364535101&nv=1&rnd=1642236941&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26bs%3D%25E6%258B%258D%25E8%25B4%25AD%26f%3D8%26rsv_bp%3D1%26wd%3D1%25E5%2585%2583%25E6%258B%258D%25E8%25B4%25AD%25E7%25BD%2591%26rsv_n%3D2%26rsv_sug3%3D1%26rsv_sug1%3D1%26rsv_sug4%3D12%26inputT%3D710&sw=1%25E5%2585%2583%25E6%258B%258D%25E8%25B4%25AD%25E7%25BD%2591&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364535131&nv=1&rnd=1418806658&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26bs%3D%25E4%25B8%2580%25E5%2585%2583%25E6%258B%258D%25E8%25B4%25AD%26f%3D8%26rsv_bp%3D1%26wd%3D%25E4%25B8%2580%25E5%2585%2583%25E6%258B%258D%25E8%25B4%25AD%2Bipdz.me%26rsv_sug3%3D7%26rsv_sug1%3D6%26rsv_sug4%3D61%26inputT%3D3199&sw=%25E4%25B8%2580%25E5%2585%2583%25E6%258B%258D%25E8%25B4%25AD%2Bipdz.me&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364535159&nv=1&rnd=1840284625&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26bs%3D%25E4%25B8%2580%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9%26f%3D8%26rsv_bp%3D1%26wd%3D%25E4%25B8%2580%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9%26inputT%3D0&sw=%25E4%25B8%2580%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364535198&nv=1&rnd=509173837&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26bs%3D%25E4%25B8%2580%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9%26f%3D8%26rsv_bp%3D1%26wd%3D1%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9%26rsv_sug3%3D1%26rsv_sug1%3D1%26rsv_sug4%3D9%26inputT%3D224&sw=1%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); +// engineList.add("http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1280x768&et=0&fl=11.6&ja=0&ln=zh-CN&lo=0<=1364535245&nv=1&rnd=1258558338&se=1&si=874caa3b9536373fecc72345e5e0ef19&st=2&su=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26bs%3D1%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9%26f%3D8%26rsv_bp%3D1%26wd%3D1%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9%26inputT%3D0&sw=1%25E5%2585%2583%25E8%25B4%25AD%25E7%2589%25A9&sse=0&v=1.0.40&lv=3&tt=1%E5%85%83%E6%8B%8D%E8%B4%AD%20-%20%E4%BA%AB%E5%8F%97%E8%B4%AD%E7%89%A9%E7%9A%84%E4%B9%90%E8%B6%A3"); + + + // 获得所有代理信息 +// String ip = System.getProperty("user.dir") + separator + "config" + separator + "ip.txt"; + String ip = Thread.currentThread().getContextClassLoader().getResource("").getPath()+"ip.txt"; + List proxyList = FollowTools.readProxyIP(ip); + Collections.shuffle(proxyList); + System.err.println("proxyList:"+proxyList.size()); + + // 计数器 + CountDownLatch countDownLatch = new CountDownLatch(engineList.size()); + // 搜索引擎地址容器 + EngineContainer engineContainer = new EngineContainer(engineList); + // 代理容器 + ProxyContainer proxyContainer = new ProxyContainer(proxyList,countDownLatch); + + System.out.println(engineList.size()); + //线程池 + ExecutorService exec = Executors.newFixedThreadPool(10); + for (int i = 0; i < 10; i++) + exec.submit(new EngineThread("抓取详细线程" + i, engineContainer, proxyContainer)); + try { + countDownLatch.await(); + } catch (Throwable e) { + e.printStackTrace(); + } + exec.shutdownNow(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/main/java/me/mofun/test/EngineThread.java b/src/main/java/me/mofun/test/EngineThread.java new file mode 100644 index 0000000..617f491 --- /dev/null +++ b/src/main/java/me/mofun/test/EngineThread.java @@ -0,0 +1,94 @@ +package me.mofun.test; + +import org.apache.http.HttpHost; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.params.CookiePolicy; +import org.apache.http.conn.params.ConnRoutePNames; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.apache.http.util.EntityUtils; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + + +public class EngineThread extends Thread { + + private EngineContainer engineContainer; + private ProxyContainer proxyContainer; + private HttpClient httpClient; + private HttpGet httpGet; + + String threadName; + + public EngineThread(String threadName,EngineContainer engineContainer,ProxyContainer proxyContainer){ + this.engineContainer = engineContainer; + this.proxyContainer = proxyContainer; + this.threadName = threadName; + } + + @Override + public void run(){ + while(!engineContainer.isEmpty()){ + String engineUrl = engineContainer.getEngineUrl(); + if(engineUrl == null) + return; + try { + Proxy proxyIp = proxyContainer.getProxy(); + System.err.println("启动线程:"+threadName+"代理IP:"+proxyIp.getIp()+"端口:"+proxyIp.getPort()); + httpClient = new DefaultHttpClient(); + HttpParams params = httpClient.getParams(); + HttpConnectionParams.setConnectionTimeout(params, 60000); + HttpConnectionParams.setSoTimeout(params, 60000); + HttpHost proxy = new HttpHost(proxyIp.getIp(), proxyIp.getPort()); + httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); + httpClient.getParams().setParameter(CookiePolicy.BROWSER_COMPATIBILITY,null); +// httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); + httpGet = new HttpGet(engineUrl); +// httpGet.setHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); +// httpGet.setHeader("Accept-Encoding","gzip, deflate"); +// httpGet.setHeader("Accept-Language","zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"); +// httpGet.setHeader("Connection","keep-alive"); +// httpGet.setHeader("Host","www.baidu.com"); +// httpGet.setHeader("Referer",engineUrl); +// httpGet.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0"); + ResponseHandler responseHandler = new BasicResponseHandler(); + Thread.sleep(2000); + System.err.println("停留2秒。。。。"); + String html = httpClient.execute(httpGet,responseHandler); + Document document = Jsoup.parse(html); + Elements links = document.select("a[href]"); + for (Element link : links) { + String linkHref = link.attr("href"); + String linkText = link.text(); + if(linkText.indexOf("1元拍购 - 享受购物的乐趣")!=-1){ + System.err.println(linkHref); + HttpGet getMethod = new HttpGet(linkHref); + getMethod.setHeader("Accept","*/*"); + getMethod.setHeader("Accept-Encoding","gzip, deflate"); + getMethod.setHeader("Accept-Language","zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"); + getMethod.setHeader("Connection","keep-alive"); + getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0"); + HttpResponse entity123 = httpClient.execute(getMethod); + byte[] bytes123 = EntityUtils.toByteArray(entity123.getEntity()); + String content123 = new String(bytes123, "UTF-8"); + if(content123.indexOf("")!=-1){ + System.err.println("进入首页成功!"); + } + } + } + } catch (Exception e) { +// e.printStackTrace(); + }finally{ + proxyContainer.reduceTask(); + } + } + } + +} diff --git a/src/main/java/me/mofun/test/FollowTools.java b/src/main/java/me/mofun/test/FollowTools.java new file mode 100644 index 0000000..71a216b --- /dev/null +++ b/src/main/java/me/mofun/test/FollowTools.java @@ -0,0 +1,77 @@ +package me.mofun.test; + +import org.apache.commons.lang.StringUtils; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.security.MessageDigest; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class FollowTools { + /** + * 读取IP + * @param path + * @return + * @throws Exception + */ + public static List readProxyIP(String path) throws Exception { +// Map map = new HashMap(); + List IpLists = new ArrayList(); + File file = new File(path); + FileReader fReader = new FileReader(file); + BufferedReader bReader = new BufferedReader(fReader); + String temp = null; + String[] tempArr = null; + while ((temp = bReader.readLine()) != null) { + Proxy ipList = new Proxy(); + if (StringUtils.isNotBlank(temp)) { + tempArr = temp.split("\\:"); + if (tempArr.length > 1) { + String ip = tempArr[0]; + String proxy = tempArr[1]; + if (StringUtils.isNotBlank(ip) && StringUtils.isNotBlank(proxy)) { + ipList.setIp(ip); + ipList.setPort(Integer.valueOf(proxy)); + IpLists.add(ipList); + } + } + } + temp = null; + tempArr = null; + } + return IpLists; + } + + + public static String getPasswod() throws Exception { + Random random = new Random(); + double pwd = random.nextLong(); + String pass = String.valueOf(pwd); + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(pass.getBytes()); + byte b[] = md.digest(); + int i; + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < b.length; offset++) { + i = b[offset]; + if (i < 0) + i += 256; + if (i < 16) + buf.append("0"); + buf.append(Integer.toHexString(i)); + } + String password = buf.toString(); + password = password.substring(0, 15); + return password; + } + + + @SuppressWarnings("static-access") + public static void main(String[] args) throws Exception { + + } + +} diff --git a/src/main/java/me/mofun/test/HttpClientTest.java b/src/main/java/me/mofun/test/HttpClientTest.java new file mode 100644 index 0000000..9c43ffc --- /dev/null +++ b/src/main/java/me/mofun/test/HttpClientTest.java @@ -0,0 +1,59 @@ +package me.mofun.test; + +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.DefaultHttpClient; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +import java.io.IOException; + +public class HttpClientTest { + + private static DefaultHttpClient httpClient; + private static HttpGet httpGet; + private HttpPost httpPost; + + + public static void main(String[] args) throws ClientProtocolException, IOException { + httpClient = new DefaultHttpClient(); + org.apache.http.params.HttpParams params = httpClient.getParams(); + org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, 60000); + org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 60000); + String index = "http://www.ipdz.me"; + httpGet = new HttpGet(index); + ResponseHandler responseHandler = new BasicResponseHandler(); + String content = httpClient.execute(httpGet,responseHandler); + Document document = Jsoup.parse(content); + Elements elements = document.select("a"); + for (Element element : elements) { + try { + String url = element.attr("href"); + if(url.indexOf("http://www.ipdz.me")!=-1){ + System.err.println(url); + go(url); + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + + public static void go(String url) throws ClientProtocolException, IOException{ + httpClient = new DefaultHttpClient(); + org.apache.http.params.HttpParams params = httpClient.getParams(); + org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, 60000); + org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 60000); + httpGet = new HttpGet(url); + ResponseHandler responseHandler = new BasicResponseHandler(); + String content = httpClient.execute(httpGet,responseHandler); + System.err.println(content); + } + +} diff --git a/src/main/java/me/mofun/test/HttpUtils.java b/src/main/java/me/mofun/test/HttpUtils.java new file mode 100644 index 0000000..ce1ef18 --- /dev/null +++ b/src/main/java/me/mofun/test/HttpUtils.java @@ -0,0 +1,626 @@ +package me.mofun.test; + +import me.mofun.util.StringUtil; +import org.apache.commons.httpclient.*; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.params.HttpMethodParams; +import org.apache.commons.lang.StringUtils; + +import java.io.IOException; +import java.net.ConnectException; +import java.net.SocketTimeoutException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class HttpUtils { + final static String[] ipAndPort = {"127.0.0.1","48100"}; +// final static String[] ipAndPort = { "122.49.11.168", "48100" }; + +// final static WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_7_0, ipAndPort[0], Integer.valueOf(ipAndPort[1])); +// static { +// webClient.setJavaScriptEnabled(false); +// webClient.setTimeout(30000); +// } + + private static String currentDynamicProxyIp; + static int start; + public static List ipList = new ArrayList(); + static Map disabledIpMap = new HashMap(); + + static { + start = 0; +// ipList.add("111.85.41.14:6675"); +// ipList.add("219.138.47.213:6666"); +// ipList.add("61.189.226.33:6675"); +// ipList.add("61.189.212.162:6675"); +// ipList.add("61.189.209.4:6675"); +// ipList.add("58.16.206.250:6675"); +// ipList.add("111.176.146.80:6675"); +// ipList.add("111.177.32.222:6675"); +// ipList.add("111.176.221.119:6675"); + ipList.add("111.176.157.103:6675"); + try { +// ipList = HttpUtils.getAvailableIpAndPort(1); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void insertSomeIpToIpList(int count){ + List list = HttpUtils.getAvailableIpAndPort(count); + if(list.size()>0){ + ipList.addAll(list); + } + } + + private static String getDynamicIp() { + for(int i=0;i<10;i++){ + if(ipList.size()==0){ + insertSomeIpToIpList(1); + }else{ + break; + } + } + if(ipList.size()>0){ + String dynamicIp = ipList.get(start); + start++; + if (start == ipList.size()) { + start = 0; + } + return dynamicIp; + } + return "111.111.111.11:1111"; + } + + private static void removeUnavailableIp(String unavailableIp) { + //如果disabledIpMap中包含该ip 就去查看该ip一共出现了几次 + if(disabledIpMap.containsKey(unavailableIp)){ + int count = disabledIpMap.get(unavailableIp); + disabledIpMap.put(unavailableIp, count+1); + System.out.println("该无效ip:"+unavailableIp+" 在disabledIpMap已有记录 出现次数为:"+disabledIpMap.get(unavailableIp)); + //如果累计请求不成功的次数超过5次 那么就移除该ip + if(disabledIpMap.get(unavailableIp)>5){ + try { + ipList.remove(unavailableIp); + System.out.println("移除无用IP成功:"+unavailableIp); + } catch (Exception e) { + e.printStackTrace(); + } + try { + String ip = HttpUtils.getAvailableIpAndPort(1).get(0); + ipList.add(ip); + System.out.println("添加有效IP成功:"+ip); + } catch (Exception e) { + e.printStackTrace(); + } + //同样从disabledIpMap中移除该ip + disabledIpMap.remove(unavailableIp); + System.out.println("该无效ip:"+unavailableIp+" 在disabledIpMap出现超过5次,从disabledIpMap中移除"); + } + }else{ + System.out.println("该无效ip:"+unavailableIp+" 在disabledIpMap无记录,首次出现"); + disabledIpMap.put(unavailableIp, 1); + } + + /* + try { + ipList.remove(unavailableIp); + System.out.println("移除无用IP成功:"+unavailableIp); + } catch (Exception e) { + e.printStackTrace(); + } + try { + String ip = HttpUtils.getAvailableIpAndPort(1).get(0); + ipList.add(ip); + System.out.println("添加有效IP成功:"+ip); + } catch (Exception e) { + e.printStackTrace(); + } + * */ + } + + public static void main(String[] args) throws IOException { + System.out.println(getSogouContentUseProxy("http://iframe.ip138.com/ic.asp","gb2312")); + List list = HttpUtils.ipList; + for(String s:list){ + System.out.println("@@@@@@@@:"+s); + } + } + + public static String generateRandom(Integer digits) { + String s = ""; + for (int i = 0; i < digits; i++) { + s += "0"; + } + int multiplier = Integer.valueOf(1 + s); + int temp = (int) (Math.random() * multiplier); + s = String.valueOf(temp); + return s; + } + + public static List getAvailableIpAndPort(int size){ + String dq = ""; + try { + dq = URLEncoder.encode("北京", "gb2312"); + } catch (Exception e) { + System.out.println("encode err:"+e.getMessage()); + } + String getUrl = "http://60.173.11.232:2222/api.asp?ddbh=225988240275820&old=1&dq="+ dq +"&sl="+size; + List list = new ArrayList(); + GetMethod getMethod = null; + try { + HttpClient httpClient = new HttpClient(); + httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000); + httpClient.getParams().setBooleanParameter("http.protocol.expect-continue", false); + getMethod = new GetMethod(getUrl); + getMethod.addRequestHeader("Connection", "close"); + + getMethod.addRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"); + + getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 5000); + getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, true)); + httpClient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "gb2312"); + httpClient.getParams().setContentCharset("gb2312"); + httpClient.getParams().setCredentialCharset("gb2312"); + int statusCode = httpClient.executeMethod(getMethod); + if (statusCode != HttpStatus.SC_OK) { + return null; + } + String html = getMethod.getResponseBodyAsString(); + System.out.println("@@:"+html); + String left = StringUtils.substringBetween(html, "", "IP"); + html = StringUtils.substringAfterLast(html, "QQ:"); + html = StringUtils.substringAfter(html, "
    "); + html = StringUtils.substringBefore(html, "
    "); + String[] ipAndPort = StringUtils.split(html, "
    "); + //格式为:118.73.111.238:6666 + for(String s:ipAndPort){ + try { + list.add(s.trim()); +// System.out.println(s.trim()); + } catch (Exception e) { + e.printStackTrace(); + } + } + System.out.println("剩余IP数量:"+getFormatStr(left)); + } catch (RedirectException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (getMethod != null) + getMethod.releaseConnection(); + } + return list; + } + + public static String getFormatStr(String str) { + String regEx = "[^0-9]"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(str); + return m.replaceAll("").trim(); + } + + public static String getSogouContentUseProxy(String url, String charset) throws IOException { + GetMethod getMethod = null; + currentDynamicProxyIp = getDynamicIp(); + try { + HttpClient httpClient = new HttpClient(); + httpClient.getHostConfiguration().setProxy(currentDynamicProxyIp.split(":")[0], Integer.parseInt(currentDynamicProxyIp.split(":")[1])); + System.out.println("当前使用的代理ip是:"+currentDynamicProxyIp); + httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(10000); + httpClient.getParams().setBooleanParameter("http.protocol.expect-continue", false); + getMethod = new GetMethod(url); + getMethod.addRequestHeader("Connection", "close"); + getMethod.addRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"); + getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 10000); + getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, true)); + httpClient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, charset); + httpClient.getParams().setContentCharset(charset); + httpClient.getParams().setCredentialCharset(charset); + getMethod.addRequestHeader("Accept-Encoding", "gzip, deflate"); + int statusCode = httpClient.executeMethod(getMethod); + if (statusCode != HttpStatus.SC_OK) { + return null; + } + return getMethod.getResponseBodyAsString(); + +// int statusCode = httpClient.executeMethod(getMethod); +// if (statusCode != HttpStatus.SC_OK) { +// return null; +// } +// +// InputStream is = getMethod.getResponseBodyAsStream(); +// GZIPInputStream gzin = new GZIPInputStream(is); +// +// InputStreamReader isr = new InputStreamReader(gzin, charset); +// java.io.BufferedReader br = new java.io.BufferedReader(isr); +// StringBuffer sb = new StringBuffer(); +// String tempbf; +// while ((tempbf = br.readLine()) != null) { +// sb.append(tempbf); +// sb.append("\r\n"); +// } +// isr.close(); +// gzin.close(); +// return sb.toString(); + } catch (SocketTimeoutException e) { + e.printStackTrace(); + //先移除无用的IP + removeUnavailableIp(currentDynamicProxyIp); + //再切换IP重新登录 + currentDynamicProxyIp = getDynamicIp(); + } catch (ConnectTimeoutException e) { + e.printStackTrace(); + //先移除无用的IP + removeUnavailableIp(currentDynamicProxyIp); + //再切换IP重新登录 + currentDynamicProxyIp = getDynamicIp(); + } catch (ProtocolException e) { + e.printStackTrace(); + //先移除无用的IP + removeUnavailableIp(currentDynamicProxyIp); + //再切换IP重新登录 + currentDynamicProxyIp = getDynamicIp(); + } catch(ConnectException e){ + e.printStackTrace(); + //先移除无用的IP + removeUnavailableIp(currentDynamicProxyIp); + //再切换IP重新登录 + currentDynamicProxyIp = getDynamicIp(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (getMethod != null) + getMethod.releaseConnection(); + } + return null; + } + + public static String getContentUseHtmlUnitProxy(String url, String charset) throws IOException { + String result = null;; +// String random1 = generateRandom(3); +// String random2 = generateRandom(2); +// String random3 = generateRandom(4); +// String random4 = generateRandom(4); +// // String cookie = +// // "PREF=ID=2f6a699f8423f164:U=772dae8a8758ad05:FF=2:LD=zh-CN:NW=1:TM=1307259001:LM=1308324493:S=pY10KdNbKMd6ia_6; +// // NID=48=NT7eyEss_bjOKob_ZSz3hEIu4qxI0lgzknJCnd6upHeLdCQ1oDGepTU4IxiON4B67p5JyUSuSfG0ZDCCDs3yQE3SSySwmOR7UuhJhaqsDfK4X8pSKOKP2L6OefOXYMM3"; +// String randomCookie = "PREF=ID=2f6a699f8423f" + random1 + ":U=772dae8a8758ad" + random2 + ":FF=2:LD=zh-CN:NW=1:TM=130725" + random3 + ":LM=130832" + random4 +// + ":S=pY10KdNbKMd6ia_6; NID=48=NT7eyEss_bjOKob_ZSz3hEIu4qxI0lgzknJCnd6upHeLdCQ1oDGepTU4IxiON4B67p5JyUSuSfG0ZDCCDs3yQE3SSySwmOR7UuhJhaqsDfK4X8pSKOKP2L6OefOXYMM3"; +// +// webClient.addRequestHeader("Cookie", randomCookie); +// +// try { +// Page page = webClient.getPage(url); +// result = page.getWebResponse().getContentAsString(); +// } catch (Exception e) { +// try { +// Page page = webClient.getPage(url); +// result = page.getWebResponse().getContentAsString(); +// } catch (Exception e1) { +// Page page = webClient.getPage(url); +// result = page.getWebResponse().getContentAsString(); +// } +// } + return result; + } + + public static String getContentUseProxy(String url, String charset) throws IOException { + GetMethod getMethod = null; + currentDynamicProxyIp = getDynamicIp(); + try { + HttpClient httpClient = new HttpClient(); + httpClient.getHostConfiguration().setProxy(currentDynamicProxyIp.split(":")[0], Integer.parseInt(currentDynamicProxyIp.split(":")[1])); + System.out.println("当前使用的代理ip是:"+currentDynamicProxyIp); + httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000); + httpClient.getParams().setBooleanParameter("http.protocol.expect-continue", false); + getMethod = new GetMethod(url); + getMethod.addRequestHeader("Connection", "close"); + getMethod.addRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"); + getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 10000); + getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, true)); + httpClient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, charset); + httpClient.getParams().setContentCharset(charset); + httpClient.getParams().setCredentialCharset(charset); +// getMethod.addRequestHeader("Accept-Encoding", "gzip, deflate"); + int statusCode = httpClient.executeMethod(getMethod); + if (statusCode != HttpStatus.SC_OK) { + return null; + } + return getMethod.getResponseBodyAsString(); + } catch (SocketTimeoutException e) { + e.printStackTrace(); + //先移除无用的IP + removeUnavailableIp(currentDynamicProxyIp); + //再切换IP重新登录 + currentDynamicProxyIp = getDynamicIp(); + } catch (ConnectTimeoutException e) { + e.printStackTrace(); + //先移除无用的IP + removeUnavailableIp(currentDynamicProxyIp); + //再切换IP重新登录 + currentDynamicProxyIp = getDynamicIp(); + } catch (ProtocolException e) { + e.printStackTrace(); + //先移除无用的IP + removeUnavailableIp(currentDynamicProxyIp); + //再切换IP重新登录 + currentDynamicProxyIp = getDynamicIp(); + } catch(ConnectException e){ + e.printStackTrace(); + //先移除无用的IP + removeUnavailableIp(currentDynamicProxyIp); + //再切换IP重新登录 + currentDynamicProxyIp = getDynamicIp(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (getMethod != null) + getMethod.releaseConnection(); + } + return null; + } + + + public static String getContent(String url, String encoder) throws IOException { + GetMethod getMethod = null; + try { + HttpClient httpClient = new HttpClient(); + httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(3000); + //httpClient.getHostConfiguration().setProxy("111.161.163.222", 6665); + httpClient.getParams().setBooleanParameter("http.protocol.expect-continue", false); + getMethod = new GetMethod(url); + getMethod.addRequestHeader("Connection", "close"); + + getMethod.addRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"); + + getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 3000); + getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, true)); + httpClient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, encoder); + httpClient.getParams().setContentCharset(encoder); + httpClient.getParams().setCredentialCharset(encoder); + + if (url.indexOf("http://cn.bing.com") > -1) { +// getMethod.setRequestHeader("Cookie", "SRCHHPGUSR=NEWWND=1&ADLT=STRICT&NRSLT=50&NRSPH=2&SRCHLANG=&AS=1;"); + } else if (url.indexOf("http://www.youdao.com/search") > -1) { + // getMethod.getParams().setParameter("http.protocol.cookie-policy", + // CookiePolicy.BROWSER_COMPATIBILITY); + getMethod + .setRequestHeader( + "Cookie", + "sbt=1303958840550; OUTFOX_SEARCH_USER_ID=-1678663480@114.132.243.206; JSESSIONID=abc8jdg-_JhcveiolaA_s; YOUDAO_MOBILE_ACCESS_TYPE=1; _PREF_ANONYUSER__SUGGEST=c3VnZ2VzdD1vcGVu; _PREF_ANONYUSER__WEB=bWFnbmlmaWVyPTpyZXN1bHRWaWV3PV9ibGFuazpsYW5ndWFnZT0yNTU6YmxvZ1NlYXJjaD1hcnRp_Y2xlOnJlc3VsdENvdW50RGlzcGxheT0zMDptYWduaWZpZXJJY29uPQ==; _PREF_ANONYUSER__DICT=dHJhbnNsYXRpb249ZXhwYW5kX2ZpcnN0; _PREF_ANONYUSER__IMAGE=aW1hZ2VTbGlkZVNob3dUaW1lPTM=; _PREF_ANONYUSER__IMAGE-LOCAL=cmVzdWx0Q291bnREaXNwbGF5SW1hZ2U9MjQ="); + } else if (url.indexOf("http://www.qihoo.com") > -1) { + getMethod + .setRequestHeader( + "Cookie", + "B=ID=984051309159946:V=2:S=b8de9df6b5; __utma=194495986.754955894.1309160408.1309160408.1309247171.2; __utmz=194495986.1309160408.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); QT_UID=63ff28bba397b03b; UT=T=1309159946:F=cWlob28uY29t:S=1:REF=qihoo.com; __utmc=194495986; __utmb=194495986.2.10.1309247171"); + } + int statusCode = httpClient.executeMethod(getMethod); + if (statusCode != HttpStatus.SC_OK) { + return null; + } + return getMethod.getResponseBodyAsString(); + } catch (RedirectException e) { + String result = getContentUseProxy(url, encoder); + if(result==null) + result = getContentUseProxy(url, encoder); + if(result==null) + result = getContentUseProxy(url, encoder); + return result; + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (getMethod != null) + getMethod.releaseConnection(); + } + return null; + } + + public static String down(String url) { + GetMethod getMethod = null; + try { + HttpClient httpClient = new HttpClient(); + httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(10000); + httpClient.getParams().setBooleanParameter("http.protocol.expect-continue", false); + getMethod = new GetMethod(url); + getMethod.addRequestHeader("Connection", "close"); + getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 10000); + getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, true)); + getMethod.setFollowRedirects(true); + getMethod.addRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows XP)"); + int statusCode = httpClient.executeMethod(getMethod); + if (statusCode == HttpStatus.SC_OK) { + return StringUtil.encodingHtml(getMethod.getResponseBodyAsStream(), getMethod.getRequestCharSet()); + } + return null; + } catch (Exception e) { + // System.out.println("error url: " + url); + System.err.println(url+"---"+e.getMessage()); + } finally { + if (getMethod != null) + getMethod.releaseConnection(); + } + return null; + } + + /** + * 删除input字符串中的html格式 + * + * @param input + * @param length + * @return + */ + public static String splitAndFilterString(String input, int length) { + if (input == null || input.trim().equals("")) { + return ""; + } + // 去掉所有html元素, + String str = input.replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", ""); + str = str.replaceAll("[(/>)<]", ""); + int len = str.length(); + if (len <= length) { + return str; + } else { + str = str.substring(0, length); + } + return str; + } + + /** + * 去掉html代码中的注释 包括 会影响htmlparser的抓取 + * + * @param html + * @return + */ + public static String throwAnnotation(String html) { + while (html.indexOf("") >= 0) { + String prefixString = html.substring(0, html.indexOf("") + 3); + html = prefixString + postfixString; + } else { + break; + } + if (html.length() > 1000000) + break; + } + html = html.replaceAll("", Pattern.DOTALL); + private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); + private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); + private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); + private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); + private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); + private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); + private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); + private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); + private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); + private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); + private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); + private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); + private static final Pattern P_END_ARROW = Pattern.compile("^>"); + private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_AMP = Pattern.compile("&"); + private static final Pattern P_QUOTE = Pattern.compile("\""); + private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); + private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); + private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); + + // @xxx could grow large... maybe use sesat's ReferenceMap + private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap(); + private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap(); + + /** set of allowed html elements, along with allowed attributes for each element **/ + private final Map> vAllowed; + /** counts of open tags for each (allowable) html element **/ + private final Map vTagCounts = new HashMap(); + + /** html elements which must always be self-closing (e.g. "") **/ + private final String[] vSelfClosingTags; + /** html elements which must always have separate opening and closing tags (e.g. "") **/ + private final String[] vNeedClosingTags; + /** set of disallowed html elements **/ + private final String[] vDisallowed; + /** attributes which should be checked for valid protocols **/ + private final String[] vProtocolAtts; + /** allowed protocols **/ + private final String[] vAllowedProtocols; + /** tags which should be removed if they contain no content (e.g. "" or "") **/ + private final String[] vRemoveBlanks; + /** entities allowed within html markup **/ + private final String[] vAllowedEntities; + /** flag determining whether comments are allowed in input String. */ + private final boolean stripComment; + private final boolean encodeQuotes; + private boolean vDebug = false; + /** + * flag determining whether to try to make tags when presented with "unbalanced" + * angle brackets (e.g. "" becomes " text "). If set to false, + * unbalanced angle brackets will be html escaped. + */ + private final boolean alwaysMakeTags; + + /** Default constructor. + * + */ + public HTMLFilter() { + vAllowed = new HashMap>(); + + final ArrayList a_atts = new ArrayList(); + a_atts.add("href"); + a_atts.add("target"); + vAllowed.put("a", a_atts); + + final ArrayList img_atts = new ArrayList(); + img_atts.add("src"); + img_atts.add("width"); + img_atts.add("height"); + img_atts.add("alt"); + vAllowed.put("img", img_atts); + + final ArrayList no_atts = new ArrayList(); + vAllowed.put("b", no_atts); + vAllowed.put("strong", no_atts); + vAllowed.put("i", no_atts); + vAllowed.put("em", no_atts); + + vSelfClosingTags = new String[]{"img"}; + vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"}; + vDisallowed = new String[]{}; + vAllowedProtocols = new String[]{"http", "mailto"}; // no ftp. + vProtocolAtts = new String[]{"src", "href"}; + vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"}; + vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"}; + stripComment = true; + encodeQuotes = true; + alwaysMakeTags = true; + } + + /** Set debug flag to true. Otherwise use default settings. See the default constructor. + * + * @param debug turn debug on with a true argument + */ + public HTMLFilter(final boolean debug) { + this(); + vDebug = debug; + + } + + /** Map-parameter configurable constructor. + * + * @param conf map containing configuration. keys match field names. + */ + public HTMLFilter(final Map conf) { + + assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; + assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; + assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; + assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; + assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; + assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; + assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; + assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; + + vAllowed = Collections.unmodifiableMap((HashMap>) conf.get("vAllowed")); + vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); + vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); + vDisallowed = (String[]) conf.get("vDisallowed"); + vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); + vProtocolAtts = (String[]) conf.get("vProtocolAtts"); + vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); + vAllowedEntities = (String[]) conf.get("vAllowedEntities"); + stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; + encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; + alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; + } + + private void reset() { + vTagCounts.clear(); + } + + private void debug(final String msg) { + if (vDebug) { + Logger.getAnonymousLogger().info(msg); + } + } + + //--------------------------------------------------------------- + // my versions of some PHP library functions + public static String chr(final int decimal) { + return String.valueOf((char) decimal); + } + + public static String htmlSpecialChars(final String s) { + String result = s; + result = regexReplace(P_AMP, "&", result); + result = regexReplace(P_QUOTE, """, result); + result = regexReplace(P_LEFT_ARROW, "<", result); + result = regexReplace(P_RIGHT_ARROW, ">", result); + return result; + } + + //--------------------------------------------------------------- + /** + * given a user submitted input String, filter out any invalid or restricted + * html. + * + * @param input text (i.e. submitted by a user) than may contain html + * @return "clean" version of input, with only valid, whitelisted html elements allowed + */ + public String filter(final String input) { + reset(); + String s = input; + + debug("************************************************"); + debug(" INPUT: " + input); + + s = escapeComments(s); + debug(" escapeComments: " + s); + + s = balanceHTML(s); + debug(" balanceHTML: " + s); + + s = checkTags(s); + debug(" checkTags: " + s); + + s = processRemoveBlanks(s); + debug("processRemoveBlanks: " + s); + + s = validateEntities(s); + debug(" validateEntites: " + s); + + debug("************************************************\n\n"); + return s; + } + + public boolean isAlwaysMakeTags(){ + return alwaysMakeTags; + } + + public boolean isStripComments(){ + return stripComment; + } + + private String escapeComments(final String s) { + final Matcher m = P_COMMENTS.matcher(s); + final StringBuffer buf = new StringBuffer(); + if (m.find()) { + final String match = m.group(1); //(.*?) + m.appendReplacement(buf, Matcher.quoteReplacement("")); + } + m.appendTail(buf); + + return buf.toString(); + } + + private String balanceHTML(String s) { + if (alwaysMakeTags) { + // + // try and form html + // + s = regexReplace(P_END_ARROW, "", s); + s = regexReplace(P_BODY_TO_END, "<$1>", s); + s = regexReplace(P_XML_CONTENT, "$1<$2", s); + + } else { + // + // escape stray brackets + // + s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); + s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); + + // + // the last regexp causes '<>' entities to appear + // (we need to do a lookahead assertion so that the last bracket can + // be used in the next pass of the regexp) + // + s = regexReplace(P_BOTH_ARROWS, "", s); + } + + return s; + } + + private String checkTags(String s) { + Matcher m = P_TAGS.matcher(s); + + final StringBuffer buf = new StringBuffer(); + while (m.find()) { + String replaceStr = m.group(1); + replaceStr = processTag(replaceStr); + m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); + } + m.appendTail(buf); + + s = buf.toString(); + + // these get tallied in processTag + // (remember to reset before subsequent calls to filter method) + for (String key : vTagCounts.keySet()) { + for (int ii = 0; ii < vTagCounts.get(key); ii++) { + s += ""; + } + } + + return s; + } + + private String processRemoveBlanks(final String s) { + String result = s; + for (String tag : vRemoveBlanks) { + if(!P_REMOVE_PAIR_BLANKS.containsKey(tag)){ + P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); + } + result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); + if(!P_REMOVE_SELF_BLANKS.containsKey(tag)){ + P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); + } + result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); + } + + return result; + } + + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + + private String processTag(final String s) { + // ending tags + Matcher m = P_END_TAG.matcher(s); + if (m.find()) { + final String name = m.group(1).toLowerCase(); + if (allowed(name)) { + if (!inArray(name, vSelfClosingTags)) { + if (vTagCounts.containsKey(name)) { + vTagCounts.put(name, vTagCounts.get(name) - 1); + return ""; + } + } + } + } + + // starting tags + m = P_START_TAG.matcher(s); + if (m.find()) { + final String name = m.group(1).toLowerCase(); + final String body = m.group(2); + String ending = m.group(3); + + //debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); + if (allowed(name)) { + String params = ""; + + final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); + final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); + final List paramNames = new ArrayList(); + final List paramValues = new ArrayList(); + while (m2.find()) { + paramNames.add(m2.group(1)); //([a-z0-9]+) + paramValues.add(m2.group(3)); //(.*?) + } + while (m3.find()) { + paramNames.add(m3.group(1)); //([a-z0-9]+) + paramValues.add(m3.group(3)); //([^\"\\s']+) + } + + String paramName, paramValue; + for (int ii = 0; ii < paramNames.size(); ii++) { + paramName = paramNames.get(ii).toLowerCase(); + paramValue = paramValues.get(ii); + +// debug( "paramName='" + paramName + "'" ); +// debug( "paramValue='" + paramValue + "'" ); +// debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); + + if (allowedAttribute(name, paramName)) { + if (inArray(paramName, vProtocolAtts)) { + paramValue = processParamProtocol(paramValue); + } + params += " " + paramName + "=\"" + paramValue + "\""; + } + } + + if (inArray(name, vSelfClosingTags)) { + ending = " /"; + } + + if (inArray(name, vNeedClosingTags)) { + ending = ""; + } + + if (ending == null || ending.length() < 1) { + if (vTagCounts.containsKey(name)) { + vTagCounts.put(name, vTagCounts.get(name) + 1); + } else { + vTagCounts.put(name, 1); + } + } else { + ending = " /"; + } + return "<" + name + params + ending + ">"; + } else { + return ""; + } + } + + // comments + m = P_COMMENT.matcher(s); + if (!stripComment && m.find()) { + return "<" + m.group() + ">"; + } + + return ""; + } + + private String processParamProtocol(String s) { + s = decodeEntities(s); + final Matcher m = P_PROTOCOL.matcher(s); + if (m.find()) { + final String protocol = m.group(1); + if (!inArray(protocol, vAllowedProtocols)) { + // bad protocol, turn into local anchor link instead + s = "#" + s.substring(protocol.length() + 1, s.length()); + if (s.startsWith("#//")) { + s = "#" + s.substring(3, s.length()); + } + } + } + + return s; + } + + private String decodeEntities(String s) { + StringBuffer buf = new StringBuffer(); + + Matcher m = P_ENTITY.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.decode(match).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENTITY_UNICODE.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENCODE.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + s = validateEntities(s); + return s; + } + + private String validateEntities(final String s) { + StringBuffer buf = new StringBuffer(); + + // validate entities throughout the string + Matcher m = P_VALID_ENTITIES.matcher(s); + while (m.find()) { + final String one = m.group(1); //([^&;]*) + final String two = m.group(2); //(?=(;|&|$)) + m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); + } + m.appendTail(buf); + + return encodeQuotes(buf.toString()); + } + + private String encodeQuotes(final String s){ + if(encodeQuotes){ + StringBuffer buf = new StringBuffer(); + Matcher m = P_VALID_QUOTES.matcher(s); + while (m.find()) { + final String one = m.group(1); //(>|^) + final String two = m.group(2); //([^<]+?) + final String three = m.group(3); //(<|$) + m.appendReplacement(buf, Matcher.quoteReplacement(one + regexReplace(P_QUOTE, """, two) + three)); + } + m.appendTail(buf); + return buf.toString(); + }else{ + return s; + } + } + + private String checkEntity(final String preamble, final String term) { + + return ";".equals(term) && isValidEntity(preamble) + ? '&' + preamble + : "&" + preamble; + } + + private boolean isValidEntity(final String entity) { + return inArray(entity, vAllowedEntities); + } + + private static boolean inArray(final String s, final String[] array) { + for (String item : array) { + if (item != null && item.equals(s)) { + return true; + } + } + return false; + } + + private boolean allowed(final String name) { + return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); + } + + private boolean allowedAttribute(final String name, final String paramName) { + return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); + } +} diff --git a/src/main/java/me/mofun/util/HTMLFilterTest.java b/src/main/java/me/mofun/util/HTMLFilterTest.java new file mode 100644 index 0000000..91873f5 --- /dev/null +++ b/src/main/java/me/mofun/util/HTMLFilterTest.java @@ -0,0 +1,193 @@ +package me.mofun.util; +//package test.java.net.sf.xsshtmlfilter; +// +//import main.java.net.sf.xsshtmlfilter.HTMLFilter; +// +//import org.junit.After; +//import org.junit.Before; +//import org.junit.Test; +// +//import java.util.Arrays; +//import java.util.Collections; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//import static org.hamcrest.MatcherAssert.assertThat; +//import static org.hamcrest.Matchers.is; +// +///** +// * +// */ +//public class HTMLFilterTest { +// protected HTMLFilter vFilter; +// +// @Before +// public void setUp() { +// vFilter = new HTMLFilter(true); +// } +// +// @After +// public void tearDown() { +// vFilter = null; +// } +// +// @Test +// public void testBasics() { +// assertThat(vFilter.filter(""), is("")); +// assertThat(vFilter.filter("hello"), is("hello")); +// } +// +// @Test +// public void testBalancingTags() { +// assertThat(vFilter.filter("hello"), is("hello")); +// assertThat(vFilter.filter("hello"), is("hello")); +// assertThat(vFilter.filter("hello"), is("hello")); +// assertThat(vFilter.filter("hello"), is("hello")); +// assertThat(vFilter.filter("hello"), is("hello")); +// assertThat(vFilter.filter("hello"), is("hello")); +// assertThat(vFilter.filter(""), is("")); +// } +// +// @Test +// public void testEndSlashes() { +// assertThat(vFilter.filter(""), is("")); +// assertThat(vFilter.filter(""), is("")); +// assertThat(vFilter.filter(""), is("")); +// } +// +// @Test +// public void testBalancingAngleBrackets() { +// if (vFilter.isAlwaysMakeTags()) { +// assertThat(vFilter.filter("")); +// assertThat(vFilter.filter("i>"), is("")); +// assertThat(vFilter.filter("")); +// assertThat(vFilter.filter(">"), is("")); +// assertThat(vFilter.filter("foofoo"), is("foo")); +// assertThat(vFilter.filter("><"), is("")); +// assertThat(vFilter.filter(">"), is("")); +// } else { +// assertThat(vFilter.filter(""), is("b>")); +// assertThat(vFilter.filter(""), is(">")); +// assertThat(vFilter.filter("foofoo"), is("b>foo")); +// assertThat(vFilter.filter("><"), is("b><")); +// assertThat(vFilter.filter(">"), is(">")); +// } +// } +// +// @Test +// public void testAttributes() { +// assertThat(vFilter.filter(""), is("")); +// assertThat(vFilter.filter(""), is("")); +// assertThat(vFilter.filter(""), is("")); +// } +// +// @Test +// public void testDisallowScriptTags() { +// assertThat(vFilter.filter(""), is("")); +// assertThat(vFilter.filter("","encoding:UTF-8"); + return null; + } + + /** + * 全站拍购总人数 + */ + public void getAllBuyCount(){ + nowDateByAllCount = System.currentTimeMillis(); + if(beginDateByAllCount==null){ + allBuyCount = Long.parseLong(spellbuyrecordService.getAllByCount().toString()); + beginDateByAllCount = System.currentTimeMillis(); +// System.err.println("全站拍购人数执行SQL"); + Struts2Utils.renderText(String.valueOf(allBuyCount)); + }else{ + if((nowDateByAllCount-beginDateByAllCount)<5000){ +// System.err.println("全站拍购人数不执行"); + Struts2Utils.renderText(String.valueOf(allBuyCount)); + }else{ + beginDateByAllCount = System.currentTimeMillis(); + allBuyCount = Long.parseLong(spellbuyrecordService.getAllByCount().toString()); +// System.err.println("全站拍购人数再执行SQL"); + Struts2Utils.renderText(String.valueOf(allBuyCount)); + } + } + } + + /** + * 最新100条拍购记录 + * @return + */ + public String getNewRecord(){ + Pagination page = spellbuyrecordService.getNowBuyList(pageNo, 100); + List newBuyList = (List) page.getList(); + productList = new ArrayList(); + for (int i = 0; i < newBuyList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) newBuyList.get(i)[0]; + spellbuyrecord = (Spellbuyrecord) newBuyList.get(i)[1]; + user = (User) newBuyList.get(i)[2]; + spellbuyproduct = (Spellbuyproduct) newBuyList.get(i)[3]; + String userName = UserNameUtil.userName(user); + productJSON.setBuyer(userName); + productJSON.setUserId(String.valueOf(user.getUserId())); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + if(product.getProductName().length()>35){ + productJSON.setProductName(product.getProductName().substring(0,35)+"..."); + }else{ + productJSON.setProductName(product.getProductName()); + } + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSON.setBuyCount(spellbuyrecord.getBuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductStyle(String.valueOf(spellbuyrecord.getSpellbuyRecordId())); + productList.add(productJSON); + } + return "newRecord"; + } + + public void getNewRecordAjax(){ + nowDateByNewRecord = System.currentTimeMillis(); + if(beginDateByNewRecord==null){ + Pagination page = spellbuyrecordService.getNowBuyAjaxList(pageNo, 100,Integer.parseInt(id)); + List newBuyList = (List) page.getList(); + newRecordList = new ArrayList(); + for (int i = 0; i < newBuyList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) newBuyList.get(i)[0]; + spellbuyrecord = (Spellbuyrecord) newBuyList.get(i)[1]; + user = (User) newBuyList.get(i)[2]; + spellbuyproduct = (Spellbuyproduct) newBuyList.get(i)[3]; + String userName = UserNameUtil.userName(user); + productJSON.setBuyer(userName); + productJSON.setUserId(String.valueOf(user.getUserId())); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + if(product.getProductName().length()>35){ + productJSON.setProductName(product.getProductName().substring(0,35)+"..."); + }else{ + productJSON.setProductName(product.getProductName()); + } + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSON.setBuyCount(spellbuyrecord.getBuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductStyle(String.valueOf(spellbuyrecord.getSpellbuyRecordId())); + newRecordList.add(productJSON); + } + beginDateByNewRecord = System.currentTimeMillis(); +// System.err.println("最新参与执行SQL"); + Struts2Utils.renderJson(newRecordList); + }else{ + if((nowDateByNewRecord-beginDateByNewRecord)<5000){ +// System.err.println("最新参与不执行"); + Struts2Utils.renderJson(newRecordList); + }else{ + beginDateByNewRecord = System.currentTimeMillis(); + Pagination page = spellbuyrecordService.getNowBuyAjaxList(pageNo, 100,Integer.parseInt(id)); + List newBuyList = (List) page.getList(); + newRecordList = new ArrayList(); + for (int i = 0; i < newBuyList.size(); i++) { + productJSON = new ProductJSON(); + product = (Product) newBuyList.get(i)[0]; + spellbuyrecord = (Spellbuyrecord) newBuyList.get(i)[1]; + user = (User) newBuyList.get(i)[2]; + spellbuyproduct = (Spellbuyproduct) newBuyList.get(i)[3]; + String userName = UserNameUtil.userName(user); + productJSON.setBuyer(userName); + productJSON.setUserId(String.valueOf(user.getUserId())); + productJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + if(product.getProductName().length()>35){ + productJSON.setProductName(product.getProductName().substring(0,35)+"..."); + }else{ + productJSON.setProductName(product.getProductName()); + } + productJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + productJSON.setBuyCount(spellbuyrecord.getBuyPrice()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setBuyDate(spellbuyrecord.getBuyDate()); + productJSON.setProductStyle(String.valueOf(spellbuyrecord.getSpellbuyRecordId())); + newRecordList.add(productJSON); + } +// System.err.println("最新参与再执行SQL"); + Struts2Utils.renderJson(newRecordList); + } + } + } + + /** + * 全站拍购记录查询 (有选择时间) + * @return + */ + + public String getAllBuyRecord(){ + Pagination datePage = spellbuyrecordService.getAllBuyRecord(startDate,endDate, pageNo, pageSize); + List dataList = (List) datePage.getList(); + buyHistoryJSONList = new ArrayList(); + for (int j = 0; j < dataList.size(); j++) { + buyHistoryJSON = new BuyHistoryJSON(); + product = (Product) dataList.get(j)[0]; + spellbuyrecord = (Spellbuyrecord) dataList.get(j)[1]; + user = (User) dataList.get(j)[2]; + spellbuyproduct = (Spellbuyproduct) dataList.get(j)[3]; + buyHistoryJSON.setBuyCount(Long.parseLong(String.valueOf(spellbuyrecord.getBuyPrice()))); + buyHistoryJSON.setBuyStatus(spellbuyproduct.getSpStatus()); + buyHistoryJSON.setHistoryId(spellbuyrecord.getSpellbuyRecordId()); + buyHistoryJSON.setProductId(spellbuyproduct.getSpellbuyProductId()); + buyHistoryJSON.setProductImg(product.getHeadImage()); + buyHistoryJSON.setProductName(product.getProductName()); + buyHistoryJSON.setProductPeriod(spellbuyproduct.getProductPeriod()); + buyHistoryJSON.setProductTitle(product.getProductTitle()); + if(spellbuyproduct.getSpStatus()==1){ + latestlottery = (Latestlottery) latestlotteryService.getBuyHistoryByDetail(spellbuyproduct.getSpellbuyProductId()).get(0); + buyHistoryJSON.setWinDate(latestlottery.getAnnouncedTime()); + buyHistoryJSON.setWinId(latestlottery.getRandomNumber()); + String userer = null; + if(latestlottery.getUserName()!=null &&!latestlottery.getUserName().equals("")){ + userer = latestlottery.getUserName(); + }else{ + if(latestlottery.getBuyUser()!=null && !latestlottery.getBuyUser().equals("")){ + userer = latestlottery.getBuyUser(); + if(userer.indexOf("@")!=-1){ + String[] u = userer.split("@"); + String u1 = u[0].substring(0,2)+"***"; + userer = u1+"@"+u[1]; + }else{ + userer = userer.substring(0,4)+ "*** "+userer.substring(7); + } + } + } + buyHistoryJSON.setWinUser(userer); + } + buyHistoryJSONList.add(buyHistoryJSON); + } + return "allBuyRecord"; + } + + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Spellbuyrecord getSpellbuyrecord() { + return spellbuyrecord; + } + + + public void setSpellbuyrecord(Spellbuyrecord spellbuyrecord) { + this.spellbuyrecord = spellbuyrecord; + } + + + public Spellbuyproduct getSpellbuyproduct() { + return spellbuyproduct; + } + + + public void setSpellbuyproduct(Spellbuyproduct spellbuyproduct) { + this.spellbuyproduct = spellbuyproduct; + } + + + public User getUser() { + return user; + } + + + public void setUser(User user) { + this.user = user; + } + + public List getHotProductList() { + return hotProductList; + } + + public void setHotProductList(List hotProductList) { + this.hotProductList = hotProductList; + } + + public Latestlottery getLatestlottery() { + return latestlottery; + } + + public void setLatestlottery(Latestlottery latestlottery) { + this.latestlottery = latestlottery; + } + + public List getLatestlotteryList() { + return latestlotteryList; + } + + public void setLatestlotteryList(List latestlotteryList) { + this.latestlotteryList = latestlotteryList; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public ProductJSON getProductJSON() { + return productJSON; + } + + public void setProductJSON(ProductJSON productJSON) { + this.productJSON = productJSON; + } + + public List getNewsList() { + return newsList; + } + + public void setNewsList(List newsList) { + this.newsList = newsList; + } + + public ProductJSON getRecommendJSON() { + return recommendJSON; + } + + public void setRecommendJSON(ProductJSON recommendJSON) { + this.recommendJSON = recommendJSON; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public List getProductList() { + return productList; + } + + public void setProductList(List productList) { + this.productList = productList; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public List getBuyHistoryJSONList() { + return buyHistoryJSONList; + } + + public void setBuyHistoryJSONList(List buyHistoryJSONList) { + this.buyHistoryJSONList = buyHistoryJSONList; + } + + public BuyHistoryJSON getBuyHistoryJSON() { + return buyHistoryJSON; + } + + public void setBuyHistoryJSON(BuyHistoryJSON buyHistoryJSON) { + this.buyHistoryJSON = buyHistoryJSON; + } + + public List getIndexImgList() { + return indexImgList; + } + + public void setIndexImgList(List indexImgList) { + this.indexImgList = indexImgList; + } + + public List getNewProductList() { + return newProductList; + } + + public void setNewProductList(List newProductList) { + this.newProductList = newProductList; + } + + public void setIndexPopProductList(List indexPopProductList) { + this.indexPopProductList = indexPopProductList; + } + + public UserJSON getUserJSON() { + return userJSON; + } + + public void setUserJSON(UserJSON userJSON) { + this.userJSON = userJSON; + } + + +} diff --git a/src/main/java/me/mofun/yeepay/config/Configuration.java b/src/main/java/me/mofun/yeepay/config/Configuration.java new file mode 100644 index 0000000..29fd326 --- /dev/null +++ b/src/main/java/me/mofun/yeepay/config/Configuration.java @@ -0,0 +1,34 @@ +package me.mofun.yeepay.config; + +import java.util.ResourceBundle; + + +/** + * @author lu.li + * + */ +public class Configuration { + + + private static Object lock = new Object(); + private static Configuration config = null; + private static ResourceBundle rb = null; + private static final String CONFIG_FILE = "merchantInfo"; + + private Configuration() { + rb = ResourceBundle.getBundle(CONFIG_FILE); + } + + public static Configuration getInstance() { + synchronized(lock) { + if(null == config) { + config = new Configuration(); + } + } + return (config); + } + + public String getValue(String key) { + return (rb.getString(key)); + } +} diff --git a/src/main/java/me/mofun/yeepay/config/DigestUtil.java b/src/main/java/me/mofun/yeepay/config/DigestUtil.java new file mode 100644 index 0000000..160ec75 --- /dev/null +++ b/src/main/java/me/mofun/yeepay/config/DigestUtil.java @@ -0,0 +1,111 @@ +package me.mofun.yeepay.config; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; + +public class DigestUtil { + + private static String encodingCharset = "UTF-8"; + + /** + * @param aValue + * @param aKey + * @return + */ + public static String hmacSign(String aValue, String aKey) { + byte k_ipad[] = new byte[64]; + byte k_opad[] = new byte[64]; + byte keyb[]; + byte value[]; + try { + keyb = aKey.getBytes(encodingCharset); + value = aValue.getBytes(encodingCharset); + } catch (UnsupportedEncodingException e) { + keyb = aKey.getBytes(); + value = aValue.getBytes(); + } + + Arrays.fill(k_ipad, keyb.length, 64, (byte) 54); + Arrays.fill(k_opad, keyb.length, 64, (byte) 92); + for (int i = 0; i < keyb.length; i++) { + k_ipad[i] = (byte) (keyb[i] ^ 0x36); + k_opad[i] = (byte) (keyb[i] ^ 0x5c); + } + + MessageDigest md = null; + try { + md = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException e) { + + return null; + } + md.update(k_ipad); + md.update(value); + byte dg[] = md.digest(); + md.reset(); + md.update(k_opad); + md.update(dg, 0, 16); + dg = md.digest(); + return toHex(dg); + } + + public static String toHex(byte input[]) { + if (input == null) + return null; + StringBuffer output = new StringBuffer(input.length * 2); + for (int i = 0; i < input.length; i++) { + int current = input[i] & 0xff; + if (current < 16) + output.append("0"); + output.append(Integer.toString(current, 16)); + } + + return output.toString(); + } + + /** + * + * @param args + * @param key + * @return + */ + public static String getHmac(String[] args, String key) { + if (args == null || args.length == 0) { + return (null); + } + StringBuffer str = new StringBuffer(); + for (int i = 0; i < args.length; i++) { + str.append(args[i]); + } + return (hmacSign(str.toString(), key)); + } + + /** + * @param aValue + * @return + */ + public static String digest(String aValue) { + aValue = aValue.trim(); + byte value[]; + try { + value = aValue.getBytes(encodingCharset); + } catch (UnsupportedEncodingException e) { + value = aValue.getBytes(); + } + MessageDigest md = null; + try { + md = MessageDigest.getInstance("SHA"); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } + return toHex(md.digest(value)); + + } + +// public static void main(String[] args) { +// System.out.println(hmacSign("AnnulCard1000043252120080620160450.0http://localhost/SZXpro/callback.asp这4564868265473632445648682654736324511","8UPp0KE8sq73zVP370vko7C39403rtK1YwX40Td6irH216036H27Eb12792t")); +// } +} diff --git a/src/main/java/me/mofun/yeepay/config/HttpUtils.java b/src/main/java/me/mofun/yeepay/config/HttpUtils.java new file mode 100644 index 0000000..f78009a --- /dev/null +++ b/src/main/java/me/mofun/yeepay/config/HttpUtils.java @@ -0,0 +1,144 @@ +package me.mofun.yeepay.config; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.util.*; +/** + * + *

    Title:

    + *

    Description: http utils

    + *

    Copyright: Copyright (c) 2006

    + *

    Company:

    + * @author LiLu + * @version 1.0 + */ +public class HttpUtils { + + + private static final String URL_PARAM_CONNECT_FLAG = "&"; + private static final int SIZE = 1024 * 1024; + private static Log log = LogFactory.getLog(HttpUtils.class); + + private HttpUtils() { + } + + /** + * GET METHOD + * @param strUrl String + * @param map Map + * @throws IOException + * @return List + */ + public static List URLGet(String strUrl, Map map) throws IOException { + String strtTotalURL = ""; + List result = new ArrayList(); + if(strtTotalURL.indexOf("?") == -1) { + strtTotalURL = strUrl + "?" + getUrl(map); + } else { + strtTotalURL = strUrl + "&" + getUrl(map); + } + log.debug("strtTotalURL:" + strtTotalURL); + URL url = new URL(strtTotalURL); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + con.setUseCaches(false); + con.setFollowRedirects(true); + BufferedReader in = new BufferedReader( + new InputStreamReader(con.getInputStream()),SIZE); + while (true) { + String line = in.readLine(); + if (line == null) { + break; + } + else { + result.add(line); + } + } + in.close(); + return (result); + } + + /** + * POST METHOD + * @param strUrl String + * @param content Map + * @throws IOException + * @return List + */ + public static List URLPost(String strUrl, Map map) throws IOException { + + String content = ""; + content = getUrl(map); + String totalURL = null; + if(strUrl.indexOf("?") == -1) { + totalURL = strUrl + "?" + content; + } else { + totalURL = strUrl + "&" + content; + } + URL url = new URL(strUrl); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + con.setDoInput(true); + con.setDoOutput(true); + con.setAllowUserInteraction(false); + con.setUseCaches(false); + con.setRequestMethod("POST"); + con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=GBK"); + BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(con. + getOutputStream())); + bout.write(content); + bout.flush(); + bout.close(); + BufferedReader bin = new BufferedReader(new InputStreamReader(con. + getInputStream()),SIZE); + List result = new ArrayList(); + while (true) { + String line = bin.readLine(); + if (line == null) { + break; + } + else { + result.add(line); + } + } + return (result); + } + + /** + * ���URL + * @param map Map + * @return String + */ + private static String getUrl(Map map) { + if (null == map || map.keySet().size() == 0) { + return (""); + } + StringBuffer url = new StringBuffer(); + Set keys = map.keySet(); + for (Iterator i = keys.iterator(); i.hasNext(); ) { + String key = String.valueOf(i.next()); + if (map.containsKey(key)) { + Object val = map.get(key); + String str = val!=null?val.toString():""; + try { + str = URLEncoder.encode(str, "GBK"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + url.append(key).append("=").append(str). + append(URL_PARAM_CONNECT_FLAG); + } + } + String strURL = ""; + strURL = url.toString(); + if (URL_PARAM_CONNECT_FLAG.equals("" + strURL.charAt(strURL.length() - 1))) { + strURL = strURL.substring(0, strURL.length() - 1); + } + return (strURL); + } + +} + diff --git a/src/main/java/me/mofun/yeepay/config/PaymentForOnlineService.java b/src/main/java/me/mofun/yeepay/config/PaymentForOnlineService.java new file mode 100644 index 0000000..2a9b4f9 --- /dev/null +++ b/src/main/java/me/mofun/yeepay/config/PaymentForOnlineService.java @@ -0,0 +1,333 @@ +package me.mofun.yeepay.config; + +import me.mofun.util.ApplicationListenerImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class PaymentForOnlineService { + + private static Log log = LogFactory.getLog(PaymentForOnlineService.class); + private static String p1_MerId = ApplicationListenerImpl.sysConfigureJson.getYeepayPartner(); // 商家ID + private static String queryRefundReqURL = "https://www.yeepay.com/app-merchant-proxy/command"; // 请求地址 + private static String keyValue = ApplicationListenerImpl.sysConfigureJson.getYeepayKey(); // 商家密钥 + private static String query_Cmd = "QueryOrdDetail"; // 订单查询请求,固定值” QueryOrdDetail” + private static String buy_Cmd = "Buy"; // 订单查询请求,固定值” Buy” + private static String refund_Cmd = "RefundOrd"; // 退款请求,固定值 ” RefundOrd” + private static String decodeCharset = "GBK"; // 定义编码格式 + private static String EMPTY = ""; + + + + /** + * 生成hmac方法 + * 业务类型 + * @param p0_Cmd + * 商户编号 + * @param p1_MerId + * 商户订单号 + * @param p2_Order + * 支付金额 + * @param p3_Amt + * 交易币种 + * @param p4_Cur + * 商品名称 + * @param p5_Pid + * 商品种类 + * @param p6_Pcat + * 商品描述 + * @param p7_Pdesc + * 商户接收支付成功数据的地址 + * @param p8_Url + * 送货地址 + * @param p9_SAF + * 商户扩展信息 + * @param pa_MP + * 银行编码 + * @param pd_FrpId + * 应答机制 + * @param pr_NeedResponse + * 商户密钥 + * @param keyValue + * @return + */ + public static String getReqMd5HmacForOnlinePayment(String p0_Cmd,String p1_MerId, + String p2_Order, String p3_Amt, String p4_Cur,String p5_Pid, String p6_Pcat, + String p7_Pdesc,String p8_Url, String p9_SAF,String pa_MP,String pd_FrpId, + String pr_NeedResponse,String keyValue) { + StringBuffer sValue = new StringBuffer(); + // 业务类型 + sValue.append(p0_Cmd); + // 商户编号 + sValue.append(p1_MerId); + // 商户订单号 + sValue.append(p2_Order); + // 支付金额 + sValue.append(p3_Amt); + // 交易币种 + sValue.append(p4_Cur); + // 商品名称 + sValue.append(p5_Pid); + // 商品种类 + sValue.append(p6_Pcat); + // 商品描述 + sValue.append(p7_Pdesc); + // 商户接收支付成功数据的地址 + sValue.append(p8_Url); + // 送货地址 + sValue.append(p9_SAF); + // 商户扩展信息 + sValue.append(pa_MP); + // 银行编码 + sValue.append(pd_FrpId); + // 应答机制 + sValue.append(pr_NeedResponse); + + String sNewString = null; + + sNewString = DigestUtil.hmacSign(sValue.toString(), keyValue); + return (sNewString); + } + + + + /** + * 订单查询请求参数 + * 该方法是根据《易宝支付产品通用接口(HTML版)文档 v3.0》怎样查询订单进行的封装 + * 具体参数含义请仔细阅读《易宝支付产品通用接口(HTML版)文档 v3.0》 + * 商户订单号 + * @param p2_Order + * @return queryResult + */ + public static QueryResult queryByOrder(String p2_Order) { + + QueryResult qr = null; + String hmac = DigestUtil.getHmac(new String[] {query_Cmd,p1_MerId,p2_Order},keyValue); + Map reParams = new HashMap(); + reParams.put("p0_Cmd", query_Cmd); + reParams.put("p1_MerId", p1_MerId); + reParams.put("p2_Order", p2_Order); + reParams.put("hmac", hmac); + List responseStr = null; + + try { + log.debug("Begin http communications.data[" + reParams + "]"); + responseStr = HttpUtils.URLGet(queryRefundReqURL, reParams); + log.debug("End http communications.responseStr.data[" + responseStr + "]"); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + if (responseStr.size() == 0) { + throw new RuntimeException("No response."); + } + qr = new QueryResult(); + for (int t = 0; t < responseStr.size(); t++) { + String currentResult = (String) responseStr.get(t); + if (currentResult == null || currentResult.equals("")) { + continue; + } + int i = currentResult.indexOf("="); + int j = currentResult.length(); + if (i >= 0) { + String sKey = currentResult.substring(0, i); + String sValue = currentResult.substring(i + 1); + try { + sValue = URLDecoder.decode(sValue, decodeCharset); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e.getMessage()); + } + if (sKey.equals("r0_Cmd")) { + qr.setR0_Cmd(sValue); + } else if (sKey.equals("r1_Code")) { + qr.setR1_Code(sValue); + } else if (sKey.equals("r2_TrxId")) { + qr.setR2_TrxId(sValue); + } else if (sKey.equals("r3_Amt")) { + qr.setR3_Amt(sValue); + } else if (sKey.equals("r4_Cur")) { + qr.setR4_Cur(sValue); + } else if (sKey.equals("r5_Pid")) { + qr.setR5_Pid(sValue); + } else if (sKey.equals("r6_Order")) { + qr.setR6_Order(sValue); + } else if (sKey.equals("r8_MP")) { + qr.setR8_MP(sValue); + } else if (sKey.equals("rb_PayStatus")) { + qr.setRb_PayStatus(sValue); + } else if (sKey.equals("rc_RefundCount")) { + qr.setRc_RefundCount(sValue); + } else if (sKey.equals("rd_RefundAmt")) { + qr.setRd_RefundAmt(sValue); + } else if (sKey.equals("hmac")) { + qr.setHmac(sValue); + } + } + } + if (!qr.getR1_Code().equals("1")) { + throw new RuntimeException("Query fail.Error code:" + qr.getR1_Code()); + } + String newHmac = ""; + newHmac = DigestUtil.getHmac(new String[] { qr.getR0_Cmd(), qr.getR1_Code(), qr.getR2_TrxId(), + qr.getR3_Amt(), qr.getR4_Cur(), qr.getR5_Pid(), qr.getR6_Order(), qr.getR8_MP(), + qr.getRb_PayStatus(), qr.getRc_RefundCount(),qr.getRd_RefundAmt()}, keyValue); + if (!newHmac.equals(qr.getHmac())) { + throw new RuntimeException("Hmac error."); + } + return (qr); + + } + + /** + * 订单退款请求参数 + * 方法是根据《易宝支付产品通用接口(HTML版)文档 v3.0》退款如何操作进行的封装 + * 具体参数含义请仔细阅读《易宝支付产品通用接口(HTML版)文档 v3.0》 + * 易宝支付交易流水号 + * @param pb_TrxId + * 退款金额 + * @param p3_Amt + * 交易币种 + * @param p4_Cur + * 退款说明 + * @param p5_Desc + * @return refundResult + */ + public static RefundResult refundByTrxId(String pb_TrxId,String p3_Amt,String p4_Cur,String p5_Desc) { + RefundResult rr = null; + String hmac = DigestUtil.getHmac(new String[] {refund_Cmd,p1_MerId,pb_TrxId,p3_Amt,p4_Cur,p5_Desc},keyValue); + Map reParams = new HashMap(); + reParams.put("p0_Cmd", refund_Cmd); + reParams.put("p1_MerId", p1_MerId); + reParams.put("pb_TrxId", pb_TrxId); + reParams.put("p3_Amt", p3_Amt); + reParams.put("p4_Cur", p4_Cur); + reParams.put("p5_Desc", p5_Desc); + reParams.put("hmac", hmac); + List responseStr = null; + try { + log.debug("Begin http communications.data[" + reParams + "]"); + responseStr = HttpUtils.URLGet(queryRefundReqURL, reParams); + log.debug("End http communications.responseStr.data[" + responseStr + "]"); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + if (responseStr.size() == 0) { + throw new RuntimeException("No response."); + } + + + rr = new RefundResult(); + for (int t = 0; t < responseStr.size(); t++) { + String currentResult = (String) responseStr.get(t); + if (currentResult == null || currentResult.equals("")) { + continue; + } + try { + URLDecoder.decode(currentResult, decodeCharset); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e.getMessage()); + } + int i = currentResult.indexOf("="); + int j = currentResult.length(); + if (i >= 0) { + String sKey = currentResult.substring(0, i); + String sValue = currentResult.substring(i + 1); + if (sKey.equals("r0_Cmd")) { + rr.setR0_Cmd(sValue); + } else if (sKey.equals("r1_Code")) { + rr.setR1_Code(sValue); + } else if (sKey.equals("r2_TrxId")) { + rr.setR2_TrxId(sValue); + } else if (sKey.equals("r3_Amt")) { + rr.setR3_Amt(sValue); + } else if (sKey.equals("r4_Cur")) { + rr.setR4_Cur(sValue); + } else if (sKey.equals("hmac")) { + rr.setHmac(sValue); + } + } + } + if (!rr.getR1_Code().equals("1")) { + throw new RuntimeException("Query fail.Error code:" + rr.getR1_Code()); + } + String newHmac = ""; + newHmac = DigestUtil.getHmac(new String[] { rr.getR0_Cmd(), rr.getR1_Code(), rr.getR2_TrxId(), + rr.getR3_Amt(), rr.getR4_Cur()}, keyValue); + if (!newHmac.equals(rr.getHmac())) { + throw new RuntimeException("Hmac error."); + } + return (rr); + } + + /** + * 返回校验hmac方法 + * + * @param hmac + * 商户编号 + * @param p1_MerId + * 业务类型 + * @param r0_Cmd + * 支付结果 + * @param r1_Code + * 易宝支付交易流水号 + * @param r2_TrxId + * 支付金额 + * @param r3_Amt + * 交易币种 + * @param r4_Cur + * 商品名称 + * @param r5_Pid + * 商户订单号 + * @param r6_Order + * 易宝支付会员ID + * @param r7_Uid + * 商户扩展信息 + * @param r8_MP + * 交易结果返回类型 + * @param r9_BType + * 交易结果返回类型 + * @param keyValue + * @return + */ + public static boolean verifyCallback(String hmac, String p1_MerId, + String r0_Cmd, String r1_Code, String r2_TrxId, String r3_Amt, + String r4_Cur, String r5_Pid, String r6_Order, String r7_Uid, + String r8_MP, String r9_BType, String keyValue) { + StringBuffer sValue = new StringBuffer(); + // 商户编号 + sValue.append(p1_MerId); + // 业务类型 + sValue.append(r0_Cmd); + // 支付结果 + sValue.append(r1_Code); + // 易宝支付交易流水号 + sValue.append(r2_TrxId); + // 支付金额 + sValue.append(r3_Amt); + // 交易币种 + sValue.append(r4_Cur); + // 商品名称 + sValue.append(r5_Pid); + // 商户订单号 + sValue.append(r6_Order); + // 易宝支付会员ID + sValue.append(r7_Uid); + // 商户扩展信息 + sValue.append(r8_MP); + // 交易结果返回类型 + sValue.append(r9_BType); + String sNewString = null; + sNewString = DigestUtil.hmacSign(sValue.toString(), keyValue); + + if (hmac.equals(sNewString)) { + return (true); + } + return (false); + } + +} \ No newline at end of file diff --git a/src/main/java/me/mofun/yeepay/config/QueryResult.java b/src/main/java/me/mofun/yeepay/config/QueryResult.java new file mode 100644 index 0000000..28e1d75 --- /dev/null +++ b/src/main/java/me/mofun/yeepay/config/QueryResult.java @@ -0,0 +1,90 @@ +package me.mofun.yeepay.config; + +public class QueryResult { + + private String r0_Cmd; //业务类型 + private String r1_Code; //查询结果 + private String r2_TrxId; //易宝支付交易流水号 + private String r3_Amt; //支付金额 + private String r4_Cur; //交易币种 + private String r5_Pid; //商品名称 + private String r6_Order; //商户订单号 + private String r8_MP; //商户扩展信息 + private String rb_PayStatus; //支付状态 + private String rc_RefundCount; //已退款次数 + private String rd_RefundAmt; //已退款金额 + private String hmac; //密钥 + + public String getHmac() { + return hmac; + } + public void setHmac(String hmac) { + this.hmac = hmac; + } + public String getR0_Cmd() { + return r0_Cmd; + } + public void setR0_Cmd(String cmd) { + r0_Cmd = cmd; + } + public String getR1_Code() { + return r1_Code; + } + public void setR1_Code(String code) { + r1_Code = code; + } + public String getR2_TrxId() { + return r2_TrxId; + } + public void setR2_TrxId(String trxId) { + r2_TrxId = trxId; + } + public String getR3_Amt() { + return r3_Amt; + } + public void setR3_Amt(String amt) { + r3_Amt = amt; + } + public String getR4_Cur() { + return r4_Cur; + } + public void setR4_Cur(String cur) { + r4_Cur = cur; + } + public String getR5_Pid() { + return r5_Pid; + } + public void setR5_Pid(String pid) { + r5_Pid = pid; + } + public String getR6_Order() { + return r6_Order; + } + public void setR6_Order(String order) { + r6_Order = order; + } + public String getR8_MP() { + return r8_MP; + } + public void setR8_MP(String r8_mp) { + r8_MP = r8_mp; + } + public String getRb_PayStatus() { + return rb_PayStatus; + } + public void setRb_PayStatus(String rb_PayStatus) { + this.rb_PayStatus = rb_PayStatus; + } + public String getRc_RefundCount() { + return rc_RefundCount; + } + public void setRc_RefundCount(String rc_RefundCount) { + this.rc_RefundCount = rc_RefundCount; + } + public String getRd_RefundAmt() { + return rd_RefundAmt; + } + public void setRd_RefundAmt(String rd_RefundAmt) { + this.rd_RefundAmt = rd_RefundAmt; + } +} diff --git a/src/main/java/me/mofun/yeepay/config/RefundResult.java b/src/main/java/me/mofun/yeepay/config/RefundResult.java new file mode 100644 index 0000000..22802cb --- /dev/null +++ b/src/main/java/me/mofun/yeepay/config/RefundResult.java @@ -0,0 +1,58 @@ +package me.mofun.yeepay.config; + +public class RefundResult { + private String r0_Cmd; // 请求命令 + private String r1_Code; // 请求结果 + private String r2_TrxId; // 交易流水号 + private String r3_Amt; // 交易金额 + private String r4_Cur; // 交易币种 + private String hmac; // 签名校验 + + public String getR0_Cmd() { + return r0_Cmd; + } + + public void setR0_Cmd(String cmd) { + r0_Cmd = cmd; + } + + public String getR1_Code() { + return r1_Code; + } + + public void setR1_Code(String code) { + r1_Code = code; + } + + public String getR2_TrxId() { + return r2_TrxId; + } + + public void setR2_TrxId(String trxId) { + r2_TrxId = trxId; + } + + public String getR3_Amt() { + return r3_Amt; + } + + public void setR3_Amt(String amt) { + r3_Amt = amt; + } + + public String getR4_Cur() { + return r4_Cur; + } + + public void setR4_Cur(String cur) { + r4_Cur = cur; + } + + public String getHmac() { + return hmac; + } + + public void setHmac(String hmac) { + this.hmac = hmac; + } +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..99f8e05 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,60 @@ +server: + port: 12356 + servlet: + # 应用的访问路径 + context-path: /shop + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # tomcat最大线程数,默认为200 + max-threads: 800 + # # Tomcat启动初始化的线程数,默认值25 + min-spare-threads: 30 + +spring: + datasource: + dynamic: + hikari: + min-idle: 5 + max-pool-size: 20 + connection-timeout: 60000 + primary: traffic + strict: false + datasource: + traffic: + url: jdbc:mysql://test166.ipdz.cc:29036/ipdz?characterEncoding=utf8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL + type: com.alibaba.druid.pool.DruidDataSource + username: ipdz + password: ipdz@test + driver-class-name: com.mysql.cj.jdbc.Driver +# redis: +# host: 127.0.0.1 +# port: 6379 +# password: +# jedis: +# pool: +# max-active: 200 +# max-idle: 10 +# servlet: +# multipart: +# max-file-size: 500MB +# max-request-size: 500MB +#mybatis 配置 +mybatis-plus: + mapper-locations: classpath:mapper/*.xml + type-aliases-package: com.zh.traffic + configuration: + map-underscore-to-camel-case: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + logic-delete-field: isDelete + logic-delete-value: 1 + logic-not-delete-value: 0 +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql +swagger: + enable: true diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..caf4dfc --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,3 @@ +spring: + profiles: + active: dev \ No newline at end of file diff --git a/src/test/java/me/mofun/test/CrawlBuy360Test.java b/src/test/java/me/mofun/test/CrawlBuy360Test.java new file mode 100644 index 0000000..768a72a --- /dev/null +++ b/src/test/java/me/mofun/test/CrawlBuy360Test.java @@ -0,0 +1,166 @@ +package me.mofun.test; + +import me.mofun.pojo.Product; +import me.mofun.pojo.ProductImage; +import me.mofun.service.ProductImageService; +import me.mofun.service.ProductService; +import me.mofun.util.CutImages; +import me.mofun.util.UploadImagesUtil; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.struts2.ServletActionContext; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.io.*; +import java.net.URI; +import java.net.URL; +import java.util.Date; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:/applicationContext*.xml" }) +@Repository +public class CrawlBuy360Test { + @Autowired + ProductService productService; + @Autowired + ProductImageService productImageService; + + private static final int BUFFER_SIZE = 100 * 1024 ; + private DefaultHttpClient httpClient; + private HttpGet httpGet; + private HttpPost httpPost; + + //文件上传 + private static void copy(File src, File dst) { + try { + InputStream in = null ; + OutputStream out = null ; + try { + in = new BufferedInputStream( new FileInputStream(src), BUFFER_SIZE); + out = new BufferedOutputStream( new FileOutputStream(dst), BUFFER_SIZE); + byte [] buffer = new byte [BUFFER_SIZE]; + while (in.read(buffer) > 0 ) { + out.write(buffer); + } + } finally { + if ( null != in) { + in.close(); + } + if ( null != out) { + out.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void go() throws Exception { + String url = "http://www.360buy.com/products/652-653-655.html"; +// http://www.360buy.com/products/652-653-655-0-0-0-0-0-0-0-1-1-2.html + httpClient = new DefaultHttpClient(); + org.apache.http.params.HttpParams params = httpClient.getParams(); + org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, 60000); + org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 60000); + httpGet = new HttpGet(url); + ResponseHandler responseHandler = new BasicResponseHandler(); + String content = httpClient.execute(httpGet,responseHandler); + Document document = Jsoup.parse(new URL(url), 60000); + Elements elements = document.select("div.plist > ul > li"); + for (Element element : elements) { + String productImg = ""; + String productName = ""; + String productTitle= ""; + int productType = 1000; + int productPrice = 0; + int productRealPrice = 0; + String productDetail = ""; + String headImage = ""; + String Attribute_71 = "1"; + String strImg = element.select("div.p-img > a > img").first().attr("src"); + if(strImg.indexOf("360buyimg.com")!=-1){ + productImg = strImg; + }else{ + String strImg2 = element.select("div.p-img > a > img").first().attr("src2"); + productImg = strImg2; + } + productName = element.select("div.p-name > a").text(); + + String proUrl = element.select("div.p-name > a").attr("href"); + System.err.println(proUrl); + Product product = new Product(); + File myFile = new File(productImg); + String myFileFileName = myFile.getName(); + product.setAttribute71(String.valueOf(1)); + product.setProductDetail(proUrl); + product.setProductName(productName); + product.setProductPrice(0); + product.setProductRealPrice(String.valueOf(0)); + product.setProductTitle(productName); + product.setProductType(1001); + productService.add(product); + String productImgPath = "/productImg/show"; + if(myFile!=null){ + myFileFileName = myFileFileName.substring(myFileFileName.lastIndexOf("."), myFileFileName.length()); + String imageFileName = new Date().getTime()+ myFileFileName; + File imageFile = new File(UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath)+"/", String.valueOf(product.getProductId()))+"/" + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(200, 200, imageFile, imageFile); + product.setHeadImage(productImgPath+"/"+String.valueOf(product.getProductId())+"/" + imageFileName); + } + + productService.add(product); + + Document document2 = Jsoup.parse(new URL(proUrl), 60000); +// System.err.println(document2); + Elements element2 = document2.select("div.spec-items > ul > li"); + for (Element element3 : element2) { + String img = element3.select("img").attr("src"); + System.err.println(img); + ProductImage productimage = new ProductImage(); + String productImgPath2 = "/productImg/imagezoom"; + long fileDateName = 0; + String imagePath = null; + File myFile2 = new File(new URI(img)); + String myFileFileName2 = myFile2.getName(); + if(myFile2!=null){ + myFileFileName2 = myFileFileName2.substring(myFileFileName2.lastIndexOf("."), myFileFileName2.length()); + fileDateName = new Date().getTime(); + String imageFileName = fileDateName + myFileFileName; + imagePath = UploadImagesUtil.getFolder(ServletActionContext.getServletContext().getRealPath(productImgPath2)+"/", String.valueOf(product.getProductId()))+"/"; + File imageFile = new File(imagePath + imageFileName); + copy(myFile, imageFile); + CutImages.equimultipleConvert(310, 310, imageFile, new File(imagePath+fileDateName+"_mid"+myFileFileName)); + CutImages.equimultipleConvert(40, 40, imageFile, new File(imagePath+fileDateName+"_small"+myFileFileName)); + productimage = new ProductImage(); + productimage.setProductId(product.getProductId()); + productimage.setImage(String.valueOf(fileDateName)); + productimage.setImageType(myFileFileName); + productimage.setIsShow("show"); + productImageService.add(productimage); + } + } + + break; +// System.err.println(productImg); +// System.err.println(productName); + + } + + } + +} diff --git a/src/test/java/me/mofun/test/CrawlByUserIP.java b/src/test/java/me/mofun/test/CrawlByUserIP.java new file mode 100644 index 0000000..677e2a1 --- /dev/null +++ b/src/test/java/me/mofun/test/CrawlByUserIP.java @@ -0,0 +1,152 @@ +package me.mofun.test; + +import me.mofun.pojo.User; +import me.mofun.service.UserService; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.DefaultHttpClient; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.io.IOException; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:/applicationContext*.xml" }) +@Repository +public class CrawlByUserIP { + @Autowired + private UserService userService; + private User user; + + private static DefaultHttpClient httpClient; + private static HttpGet httpGet; + private HttpPost httpPost; + + @Test + public void go() throws ClientProtocolException, IOException{ + httpClient = new DefaultHttpClient(); + org.apache.http.params.HttpParams params = httpClient.getParams(); + org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, 60000); + org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 60000); + int count = 1400; + int codeID = 24064; + int i = 1; + int j = 10; + long startDate = System.currentTimeMillis(); + while(count-- > 0){ + System.err.println(i +" "+j); + String url = "http://dataserver.ipdz.me/JPData?action=GetUserBuyListByCode&codeID="+codeID+"&FIdx="+i+"&EIdx="+j+"&fun=jsonp"+startDate+"&_="+System.currentTimeMillis(); + System.err.println(url); + httpGet = new HttpGet(url); + httpGet.setHeader("Accept", "*/*"); + httpGet.setHeader("Accept-Encoding", "gzip, deflate"); + httpGet.setHeader("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"); + httpGet.setHeader("Connection", "keep-alive"); + httpGet.setHeader("Cookie", "__utma=248799431.1617822012.1357546987.1357546987.1357611571.2; __utmz=248799431.1357546987.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmb=248799431.4.10.1357611571; __utmc=248799431"); + httpGet.setHeader("Host", "dataserver.ipdz.me"); + httpGet.setHeader("Referer", "http://www.ipdz.me/products/21252.html"); + httpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20100101 Firefox/17.0"); + ResponseHandler responseHandler = new BasicResponseHandler(); + String content = httpClient.execute(httpGet,responseHandler); + content = content.replaceAll("jsonp"+startDate, ""); + content = content.substring(1, content.length()); + content = content.substring(0, content.length()-1); + JSONObject object = JSONObject.fromObject(content); + JSONObject data = JSONObject.fromObject(object.getString("Data")); + JSONObject Tables = JSONObject.fromObject(data.getString("Tables")); + JSONObject BuyList = JSONObject.fromObject(Tables.getString("BuyList")); + JSONArray Rows = JSONArray.fromObject(BuyList.getString("Rows")); + for (Object object2 : Rows) { + JSONObject obj = JSONObject.fromObject(object2); + System.err.println(obj.getString("userName")+ obj.getString("buyNum") +obj.getString("buyIP")+obj.getString("buyIPAddr")+obj.getString("buyTime")); + user = new User(); + String nowDate = obj.getString("buyTime"); + nowDate = nowDate.substring(0, nowDate.length()-3); + String userName = obj.getString("userName"); + user.setUserName(userName); + user.setUserPwd("pwd.ipdz.me"); + user.setIpLocation(obj.getString("buyIPAddr")); + user.setIpAddress(obj.getString("buyIP")); + user.setNewDate(nowDate); + user.setFaceImg("/Images/defaultUserFace.png"); + user.setUserType("0"); + user.setBalance(0.00); + user.setExperience(0); + user.setCommissionBalance(0.00); + user.setCommissionCount(0.00); + user.setCommissionMention(0.00); +// user.setSignature("这家伙很懒,什么也没留下。"); + User user2 = userService.userByIsUserName(userName); + if(user2==null){ + userService.add(user); + } + } + startDate+=1; + i+=10; + j+=10; +// break; + } + } + + public static void main(String[] args) throws ClientProtocolException, IOException { + httpClient = new DefaultHttpClient(); + org.apache.http.params.HttpParams params = httpClient.getParams(); + org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, 60000); + org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 60000); + int count = 1400; + int codeID = 24064; + int i = 1; + int j = 20; + long startDate = System.currentTimeMillis(); + while(count-- > 0){ + System.err.println(i +" "+j); +// http://dataserver.ipdz.me/JPData?action=GetUserBuyListByCode&codeID=11807&FIdx=51&EIdx=60&isCount=0&fun=jsonp1362634201995&_=1362644662143 + String url = "http://dataserver.ipdz.me/JPData?action=GetUserBuyListByCode&codeID="+codeID+"&FIdx="+i+"&EIdx="+j+"&fun=jsonp"+startDate+"&_="+System.currentTimeMillis(); + System.err.println(url); + httpGet = new HttpGet(url); + httpGet.setHeader("Accept", "*/*"); + httpGet.setHeader("Accept-Encoding", "gzip, deflate"); + httpGet.setHeader("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"); + httpGet.setHeader("Connection", "keep-alive"); + httpGet.setHeader("Cookie", "__utma=248799431.1617822012.1357546987.1357546987.1357611571.2; __utmz=248799431.1357546987.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmb=248799431.4.10.1357611571; __utmc=248799431"); + httpGet.setHeader("Host", "dataserver.ipdz.me"); + httpGet.setHeader("Referer", "http://www.ipdz.me/products/21252.html"); + httpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20100101 Firefox/17.0"); + ResponseHandler responseHandler = new BasicResponseHandler(); + String content = httpClient.execute(httpGet,responseHandler); + content = content.replaceAll("jsonp"+startDate, ""); + content = content.substring(1, content.length()); + content = content.substring(0, content.length()-1); + JSONObject object = JSONObject.fromObject(content); + JSONObject data = JSONObject.fromObject(object.getString("Data")); + JSONObject Tables = JSONObject.fromObject(data.getString("Tables")); + JSONObject BuyList = JSONObject.fromObject(Tables.getString("BuyList")); + JSONArray Rows = JSONArray.fromObject(BuyList.getString("Rows")); + for (Object object2 : Rows) { + JSONObject obj = JSONObject.fromObject(object2); + System.err.println(obj); + System.err.println(obj.getString("userName")); + System.err.println(obj.getString("buyNum")); + System.err.println(obj.getString("buyIP")); + System.err.println(obj.getString("buyIPAddr")); + System.err.println(obj.getString("buyTime")); + } + startDate+=1; + i+=20; + j+=20; + break; + } +// System.err.println(DateUtil.DateTimeToStr(new Date(Long.parseLong("1357613245334")))); +// System.err.println(DateUtil.DateTimeToStr(new Date(Long.parseLong("1357614225335")))); + } + +} diff --git a/src/test/java/me/mofun/test/TestNumber.java b/src/test/java/me/mofun/test/TestNumber.java new file mode 100644 index 0000000..ae5e073 --- /dev/null +++ b/src/test/java/me/mofun/test/TestNumber.java @@ -0,0 +1,102 @@ +package me.mofun.test; + +import me.mofun.pojo.Latestlottery; +import me.mofun.pojo.Randomnumber; +import me.mofun.pojo.Spellbuyproduct; +import me.mofun.service.LatestlotteryService; +import me.mofun.service.RandomnumberService; +import me.mofun.service.SpellbuyproductService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; +import org.springframework.stereotype.Service; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:/applicationContext*.xml" }) +@Repository +@Service("TestNumber") +public class TestNumber { + + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private RandomnumberService randomnumberService; + @Autowired + private SpellbuyproductService spellbuyproductService; + + private List randomnumberList; + private List latestlotteryList; + + + + @Test + public void go(){ + List spellbuyproductList = spellbuyproductService.query("from Spellbuyproduct s where s.spStatus=0"); + for (Spellbuyproduct spellbuyproduct : spellbuyproductList) { + int price = spellbuyproduct.getSpellbuyPrice(); + randomnumberList = randomnumberService.query("from Randomnumber r where r.productId='"+spellbuyproduct.getSpellbuyProductId()+"'"); + for (Randomnumber randomnumber : randomnumberList) { + String [] randoms = randomnumber.getRandomNumber().split(","); + String numbers = ""; + int count=0; + for (String string : randoms) { + int num = Integer.parseInt(string); + num -= 10000000; + if(num >price){ + if(num>1000){ + num-=1000; + }else if(num>100){ + num-=100; + } + } + num+=10000000; +// System.err.println("num:"+num); + numbers +=num+","; + } + numbers = numbers.substring(0,numbers.length()-1); + System.err.println("numbers:"+numbers); + randomnumber.setRandomNumber(numbers); + randomnumberService.add(randomnumber); + } + } + } + +// @Test +// public void go(){ +// latestlotteryList = latestlotteryService.query("from Latestlottery l where 1=1"); +// for (Latestlottery latestlottery : latestlotteryList) { +//// Latestlottery latestlottery = (Latestlottery) latestlotteryService.getLotteryDetail(784).get(0); +// int price = latestlottery.getProductPrice(); +// randomnumberList = randomnumberService.LotteryDetailByRandomnumber(latestlottery.getUserId(), latestlottery.getSpellbuyProductId()); +// for (Randomnumber randomnumber : randomnumberList) { +// String [] randoms = randomnumber.getRandomNumber().split(","); +// String numbers = ""; +// int count=0; +// for (String string : randoms) { +// int num = Integer.parseInt(string); +// num -= 10000000; +// if(num >price){ +// if(num>1000){ +// num-=1000; +// }else if(num>100){ +// num-=100; +// } +// } +// num+=10000000; +//// System.err.println("num:"+num); +// numbers +=num+","; +// } +// numbers = numbers.substring(0,numbers.length()-1); +// System.err.println("numbers:"+numbers); +// randomnumber.setRandomNumber(numbers); +// randomnumberService.add(randomnumber); +// } +// } +// } + +} diff --git a/src/test/java/me/mofun/test/UpdateLatestlottery.java b/src/test/java/me/mofun/test/UpdateLatestlottery.java new file mode 100644 index 0000000..d551422 --- /dev/null +++ b/src/test/java/me/mofun/test/UpdateLatestlottery.java @@ -0,0 +1,64 @@ +package me.mofun.test; + +import me.mofun.pojo.Product; +import me.mofun.pojo.ProductCart; +import me.mofun.pojo.Spellbuyproduct; +import me.mofun.service.LatestlotteryService; +import me.mofun.service.ProductService; +import me.mofun.service.SpellbuyproductService; +import me.mofun.service.SpellbuyrecordService; +import me.mofun.util.NewLotteryUtil; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; +import org.springframework.stereotype.Service; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:/applicationContext*.xml" }) +@Repository +@Service("updateLatestlottery") +public class UpdateLatestlottery { + + @Autowired + private SpellbuyrecordService spellbuyrecordService; + @Autowired + private SpellbuyproductService spellbuyproductService; + @Autowired + private LatestlotteryService latestlotteryService; + @Autowired + private ProductService productService; + @Autowired + private NewLotteryUtil newLotteryUtil; + + private ProductCart productCart; + private Product product; + + + + @Test + public void go() throws InterruptedException{ + List spellbuyproductList = spellbuyproductService.UpdateLatestlotteryGetList(); + for (Spellbuyproduct spellbuyproduct : spellbuyproductList) { + productCart = new ProductCart(); + //List proList = spellbuyproductService.findByProductId(spellbuyproduct.getSpellbuyProductId()); + List proList = spellbuyproductService.findBySpellbuyProductId(spellbuyproduct.getSpellbuyProductId()); + product = (Product) proList.get(0)[0]; + spellbuyproduct = (Spellbuyproduct) proList.get(0)[1]; + productCart.setHeadImage(product.getHeadImage()); + productCart.setProductId(spellbuyproduct.getSpellbuyProductId()); + productCart.setProductName(product.getProductName()); + productCart.setProductPrice(product.getProductPrice()); + productCart.setProductTitle(product.getProductTitle()); + productCart.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productCart.setProductPeriod(spellbuyproduct.getProductPeriod()); + + newLotteryUtil.lottery(productCart); + } + + } +} diff --git a/src/test/java/me/mofun/test/UpdateRandom.java b/src/test/java/me/mofun/test/UpdateRandom.java new file mode 100644 index 0000000..88e2a56 --- /dev/null +++ b/src/test/java/me/mofun/test/UpdateRandom.java @@ -0,0 +1,70 @@ +package me.mofun.test; + +import me.mofun.dao.Pagination; +import me.mofun.pojo.Latestlottery; +import me.mofun.pojo.Randomnumber; +import me.mofun.pojo.Spellbuyrecord; +import me.mofun.pojo.User; +import me.mofun.service.LatestlotteryService; +import me.mofun.service.RandomnumberService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:/applicationContext*.xml" }) +@Repository +public class UpdateRandom { + + @Autowired + @Qualifier("latestlotteryService") + private LatestlotteryService latestlotteryService; + @Autowired + private RandomnumberService randomnumberService; + + @Test + public void go(){ + + for (int i = 0; i < 20; i++) { + Pagination page = latestlotteryService.LatestAnnounced(i, 20); + List objList = (List) page.getList(); + System.err.println(objList.size()+"********"); + + for (Latestlottery latestlottery : objList) { + + for (int j = 0; j < 100; j++) { + System.err.println(latestlottery.getSpellbuyProductId()+"&&&&&&&&&&&&&&&&"); + Pagination datePage = latestlotteryService.getLotteryDetailBybuyerList(latestlottery.getSpellbuyProductId(), j, 20); + List dataList = (List) datePage.getList(); + if(dataList.size()==0){ + break; + } + System.err.println(dataList.size()+"%%%%%%%%%%%%%%%"); + for (int k = 0; k < dataList.size(); k++) { + Spellbuyrecord spellbuyrecord = (Spellbuyrecord) dataList.get(k)[0]; + Randomnumber randomnumber = (Randomnumber) dataList.get(k)[1]; + User user = (User) dataList.get(k)[2]; + System.err.println(randomnumber.getId()+"++++++++++++++++++++"); + System.err.println(spellbuyrecord.getFkSpellbuyProductId()+"=================="); + randomnumber.setProductId(spellbuyrecord.getFkSpellbuyProductId()); + randomnumberService.add(randomnumber); + } + } + + + + + } + + } + + + } + +} diff --git a/src/test/java/me/mofun/test/UpdateUserFaceImg.java b/src/test/java/me/mofun/test/UpdateUserFaceImg.java new file mode 100644 index 0000000..edae406 --- /dev/null +++ b/src/test/java/me/mofun/test/UpdateUserFaceImg.java @@ -0,0 +1,160 @@ +package me.mofun.test; + +import me.mofun.pojo.User; +import me.mofun.service.UserService; +import me.mofun.util.ReadFile; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.DefaultHttpClient; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:/applicationContext*.xml" }) +@Repository +public class UpdateUserFaceImg { + + @Autowired + private UserService userService; + private User user; + + private static DefaultHttpClient httpClient; + private static HttpGet httpGet; + private HttpPost httpPost; + + @Test + public void go() throws Exception{ + + List userList = userService.loadAll(); + Collections.shuffle(userList); + + ReadFile readFile = new ReadFile(); + List strList = readFile.readFile("c:\\imgFile2.txt"); + System.err.println(strList.size()); + int i = 0; + + for (String string : strList) { + try { + user = userList.get(i); + if(user.getFaceImg().equals("/Images/defaultUserFace.png")){ + System.err.println(string.split("-")[0]); +// /faceImages/1000_1372755064097.png + Long time = System.currentTimeMillis(); + String path = "/faceImages/"+user.getUserId()+"_"+time+string.split("-")[1]; + System.err.println(path); + String localPath = "c:\\UserImg\\"+user.getUserId()+"_"+time+string.split("-")[1]; + WeiboImg.getImage(string.split("-")[0], localPath); + System.err.println(localPath); + user.setFaceImg(path); + userService.add(user); + i++; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + + +// httpClient = new DefaultHttpClient(); +// org.apache.http.params.HttpParams params = httpClient.getParams(); +// org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, 60000); +// org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 60000); + +// String url = "http://www.1ypg.com/user/updateFaceFile.action"; +// System.err.println(url); +// httpPost = new HttpPost(url); +// httpPost.setHeader("Referer", "http://www.1ypg.com/user/UserPhoto.html"); +// httpPost.setHeader("Host", "www.1ypg.com"); +// +// FileBody bin = new FileBody(file); +// MultipartEntity reqEntity = new MultipartEntity(); +// reqEntity.addPart("myFile", bin); +// httpPost.setEntity(reqEntity); +// +// List vlaueList = new ArrayList(); +// vlaueList.add(new BasicNameValuePair("userId","1000")); +// httpPost.setEntity(new UrlEncodedFormEntity(vlaueList, HTTP.UTF_8)); +// +// HttpResponse entity = httpClient.execute(httpPost); +// byte[] bytes = EntityUtils.toByteArray(entity.getEntity()); +// String content = new String(bytes, "UTF-8"); +// System.err.println("content: "+content); + + + + } + + + + public static List imgList(String filepath) throws FileNotFoundException, IOException{ + List imgList = new ArrayList(); + File file = new File(filepath); + if (!file.isDirectory()) { + System.err.println("文件夹不存在!"); + }else if(file.isDirectory()){ + String[] filelist = file.list(); + for (int i = 0; i < filelist.length; i++) { + File readfile = new File(filepath + "\\" + filelist[i]); + if (!readfile.isDirectory()) { +// System.out.println("path=" + readfile.getPath()); +// System.out.println("absolutepath="+ readfile.getAbsolutePath()); +// System.out.println("name=" + readfile.getName()); + imgList.add(readfile.getName()); + } else if (readfile.isDirectory()) { + readfile(filepath + "\\" + filelist[i]); + } + } + } + return imgList; + } + + + /** + * 读取某个文件夹下的所有文件 + */ + public static boolean readfile(String filepath) throws FileNotFoundException, IOException { + try { + + File file = new File(filepath); + if (!file.isDirectory()) { + System.out.println("文件"); +// System.out.println("path=" + file.getPath()); +// System.out.println("absolutepath=" + file.getAbsolutePath()); + System.out.println("name1=" + file.getName()); + + } else if (file.isDirectory()) { + System.out.println("文件夹"); + String[] filelist = file.list(); + for (int i = 0; i < filelist.length; i++) { + File readfile = new File(filepath + "\\" + filelist[i]); + if (!readfile.isDirectory()) { +// System.out.println("path=" + readfile.getPath()); +// System.out.println("absolutepath="+ readfile.getAbsolutePath()); + System.out.println("name2=" + readfile.getName()); + + } else if (readfile.isDirectory()) { + readfile(filepath + "\\" + filelist[i]); + } + } + + } + + } catch (FileNotFoundException e) { + System.out.println("readfile() Exception:" + e.getMessage()); + } + return true; + } + +}