Browse Source

init from phab

xielq 4 years ago
parent
commit
83c1b620eb
62 changed files with 7996 additions and 0 deletions
  1. 0 0
      README.md
  2. 46 0
      build.gradle
  3. 28 0
      gradle/dependencies-base.gradle
  4. 11 0
      gradle/tasks.gradle
  5. BIN
      gradle/wrapper/gradle-wrapper.jar
  6. 6 0
      gradle/wrapper/gradle-wrapper.properties
  7. 164 0
      gradlew
  8. 90 0
      gradlew.bat
  9. 2 0
      settings.gradle
  10. 6 0
      src/main/docker/Dockerfile
  11. 14 0
      src/main/java/com/uas/cloud/mall/commodity/StoreApplication.java
  12. 157 0
      src/main/java/com/uas/cloud/mall/commodity/api/CommodityController.java
  13. 136 0
      src/main/java/com/uas/cloud/mall/commodity/api/ReleaseProductByBatchController.java
  14. 1041 0
      src/main/java/com/uas/cloud/mall/commodity/domain/Commodity.java
  15. 754 0
      src/main/java/com/uas/cloud/mall/commodity/domain/CommodityHistory.java
  16. 322 0
      src/main/java/com/uas/cloud/mall/commodity/domain/CommodityPriceInfo.java
  17. 135 0
      src/main/java/com/uas/cloud/mall/commodity/domain/CommodityQtyPrice.java
  18. 409 0
      src/main/java/com/uas/cloud/mall/commodity/domain/CommoditySimple.java
  19. 77 0
      src/main/java/com/uas/cloud/mall/commodity/domain/CreateNumber.java
  20. 15 0
      src/main/java/com/uas/cloud/mall/commodity/domain/FileUpload.java
  21. 262 0
      src/main/java/com/uas/cloud/mall/commodity/domain/PriceChangeLog.java
  22. 917 0
      src/main/java/com/uas/cloud/mall/commodity/domain/ReleaseProductByBatch.java
  23. 138 0
      src/main/java/com/uas/cloud/mall/commodity/domain/ShopComponent.java
  24. 323 0
      src/main/java/com/uas/cloud/mall/commodity/repository/CommodityDao.java
  25. 39 0
      src/main/java/com/uas/cloud/mall/commodity/repository/CommodityHistoryDao.java
  26. 77 0
      src/main/java/com/uas/cloud/mall/commodity/repository/CommodityPriceInfoDao.java
  27. 43 0
      src/main/java/com/uas/cloud/mall/commodity/repository/CommoditySimpleDao.java
  28. 131 0
      src/main/java/com/uas/cloud/mall/commodity/repository/CommonDao.java
  29. 14 0
      src/main/java/com/uas/cloud/mall/commodity/repository/CreateNumberDao.java
  30. 13 0
      src/main/java/com/uas/cloud/mall/commodity/repository/PriceChangeLogDao.java
  31. 68 0
      src/main/java/com/uas/cloud/mall/commodity/repository/ReleaseProductByBatchDao.java
  32. 23 0
      src/main/java/com/uas/cloud/mall/commodity/repository/ShopComponentDao.java
  33. 18 0
      src/main/java/com/uas/cloud/mall/commodity/service/CommodityHistoryService.java
  34. 36 0
      src/main/java/com/uas/cloud/mall/commodity/service/CommodityPriceInfoService.java
  35. 65 0
      src/main/java/com/uas/cloud/mall/commodity/service/CommodityService.java
  36. 47 0
      src/main/java/com/uas/cloud/mall/commodity/service/CreateNumberService.java
  37. 22 0
      src/main/java/com/uas/cloud/mall/commodity/service/PriceChangeLogService.java
  38. 76 0
      src/main/java/com/uas/cloud/mall/commodity/service/ReleaseProductByBatchService.java
  39. 28 0
      src/main/java/com/uas/cloud/mall/commodity/service/ShopComponentService.java
  40. 61 0
      src/main/java/com/uas/cloud/mall/commodity/service/impl/CommodityHistoryServiceImpl.java
  41. 173 0
      src/main/java/com/uas/cloud/mall/commodity/service/impl/CommodityPriceInfoServiceImpl.java
  42. 213 0
      src/main/java/com/uas/cloud/mall/commodity/service/impl/CommodityServiceImpl.java
  43. 91 0
      src/main/java/com/uas/cloud/mall/commodity/service/impl/CreateNumberServiceImpl.java
  44. 39 0
      src/main/java/com/uas/cloud/mall/commodity/service/impl/PriceChangeLogServiceImpl.java
  45. 700 0
      src/main/java/com/uas/cloud/mall/commodity/service/impl/ReleaseProductByBatchServiceImpl.java
  46. 53 0
      src/main/java/com/uas/cloud/mall/commodity/service/impl/ShopComponentServiceImpl.java
  47. 133 0
      src/main/java/com/uas/cloud/mall/commodity/statusAndType/ReleaseStatus.java
  48. 69 0
      src/main/java/com/uas/cloud/mall/commodity/statusAndType/Status.java
  49. 64 0
      src/main/java/com/uas/cloud/mall/commodity/statusAndType/Type.java
  50. 158 0
      src/main/java/com/uas/cloud/mall/commodity/support/Entity.java
  51. 33 0
      src/main/java/com/uas/cloud/mall/commodity/support/EntityFactory.java
  52. 95 0
      src/main/java/com/uas/cloud/mall/commodity/support/JxlsExcelView.java
  53. 13 0
      src/main/java/com/uas/cloud/mall/commodity/util/DateFormatUtils.java
  54. 68 0
      src/main/java/com/uas/cloud/mall/commodity/util/JacksonUtils.java
  55. 85 0
      src/main/java/com/uas/cloud/mall/commodity/util/JdbcUtil.java
  56. 69 0
      src/main/java/com/uas/cloud/mall/commodity/util/PageParams.java
  57. 25 0
      src/main/resources/application-dev.yml
  58. 25 0
      src/main/resources/application-prod.yml
  59. 25 0
      src/main/resources/application-test.yml
  60. 5 0
      src/main/resources/application.yml
  61. 11 0
      src/test/java/com/uas/cloud/mall/commodity/parent/GoodsApplication.java
  62. 35 0
      src/test/java/com/uas/cloud/mall/commodity/service/CommodityServiceTest.java

+ 0 - 0
README.md


+ 46 - 0
build.gradle

@@ -0,0 +1,46 @@
+// Gradle build file for Gradle 2.14.1
+// Created by huxz on 2017-3-17 13:38:59
+buildscript {
+	ext {
+		springBootVersion = '1.4.4.RELEASE'
+		// 0.12.0 升级到了 Gradle 3.4,Gradle 2.14.1 只能使用 0.11.0及以下
+		dockerVersion = '0.11.0'
+		dcokerRegistry = "10.10.100.200:5000"
+	}
+	repositories {
+		maven { url "https://plugins.gradle.org/m2/" }
+		maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
+		mavenCentral()
+		jcenter()
+	}
+	dependencies {
+		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
+		classpath "gradle.plugin.com.palantir.gradle.docker:gradle-docker:${dockerVersion}"
+	}
+}
+
+group 'com.uas.cloud.mall'
+version '0.1.0'
+
+apply plugin: 'java'
+apply plugin: "com.palantir.docker"
+apply plugin: "org.springframework.boot"
+
+apply from: "$rootDir/gradle/tasks.gradle"
+apply from: "$rootDir/gradle/dependencies-base.gradle"
+
+allprojects {
+	sourceCompatibility = 1.8
+}
+
+dependencies {
+	compile("org.springframework.boot:spring-boot-starter-data-jpa")
+	compile('com.uas.cloud.mall:commons:0.0.1') {
+		exclude(module: 'servlet-api')
+	}
+    compile('org.apache.poi:poi:3.9')
+	compile('net.sf.jxls:jxls-core:1.0.4')
+	compile('org.codehaus.jackson:jackson-core-asl:1.9.13')
+	compile('org.apache.commons:commons-lang3:3.1')
+	runtime("com.oracle:ojdbc6:11.2.0")
+}

+ 28 - 0
gradle/dependencies-base.gradle

@@ -0,0 +1,28 @@
+// Gradle Base Dependencies Configurations
+// Created by huxz on 2017-3-17 14:39:36
+repositories {
+	mavenLocal()
+	maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
+	maven {
+		url 'http://10.10.101.21:8081/artifactory/libs-release'
+	}
+	maven {
+		url 'http://10.10.101.21:8081/artifactory/libs-snapshot'
+	}
+	maven {
+		url 'http://10.10.101.21:8081/artifactory/plugins-snapshot'
+	}
+	mavenCentral()
+}
+
+dependencyManagement {
+	imports {
+		mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Camden.SR5'
+	}
+}
+
+dependencies {
+	compile 'org.springframework.cloud:spring-cloud-starter-config'
+	compile "org.springframework.cloud:spring-cloud-starter-eureka"
+	testCompile 'org.springframework.boot:spring-boot-starter-test'
+}

+ 11 - 0
gradle/tasks.gradle

@@ -0,0 +1,11 @@
+// Gradle Tasks Configurations
+// Created by huxz on 2017-3-17 14:39:36
+bootRun {
+	addResources = true
+}
+
+docker {
+	name "${dcokerRegistry}/${project.name}:${project.version}"
+	dockerfile "${projectDir}/src/main/docker/Dockerfile"
+	files "${buildDir}/libs/${project.name}-${project.version}.jar"
+}.dependsOn build

BIN
gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Wed Mar 01 11:16:18 CST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip

+ 164 - 0
gradlew

@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

+ 90 - 0
gradlew.bat

@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 2 - 0
settings.gradle

@@ -0,0 +1,2 @@
+rootProject.name = 'mall-commodity-service'
+

+ 6 - 0
src/main/docker/Dockerfile

@@ -0,0 +1,6 @@
+FROM hub.c.163.com/library/java:8-jre-alpine
+VOLUME /tmp # reate a temporary file on my host under "/var/lib/docker" and link it to the container under "/tmp".
+ADD mall-commodity-service-0.1.0.jar app.jar
+RUN sh -c "touch /app.jar" #  "touch" the jar file so that it has a file modification time (Docker creates all container files in an "unmodified" state by default). This actually isn’t important for the simple app that we wrote, but any static content (e.g. "index.html") would require the file to have a modification time.
+ENV JAVA_OPTS=""
+ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar --spring.profiles.active=test"] # To reduce Tomcat startup time we added a system property pointing to "/dev/urandom" as a source of entropy.

+ 14 - 0
src/main/java/com/uas/cloud/mall/commodity/StoreApplication.java

@@ -0,0 +1,14 @@
+package com.uas.cloud.mall.commodity;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+@EnableDiscoveryClient
+@SpringBootApplication
+public class StoreApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(StoreApplication.class, args);
+	}
+}

+ 157 - 0
src/main/java/com/uas/cloud/mall/commodity/api/CommodityController.java

@@ -0,0 +1,157 @@
+package com.uas.cloud.mall.commodity.api;
+
+import com.uas.cloud.commons.domain.PageInfo;
+import com.uas.cloud.commons.domain.PageParams;
+import com.uas.cloud.commons.support.SystemSession;
+import com.uas.cloud.mall.commodity.domain.Commodity;
+import com.uas.cloud.mall.commodity.domain.CommodityHistory;
+import com.uas.cloud.mall.commodity.domain.CommoditySimple;
+import com.uas.cloud.mall.commodity.service.CommodityHistoryService;
+import com.uas.cloud.mall.commodity.service.CommodityService;
+import com.uas.cloud.mall.commodity.statusAndType.Status;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/commodity-service")
+public class CommodityController {
+
+	private static final Logger logger = LoggerFactory.getLogger(CommodityController.class);
+
+	private final CommodityService commodityService;
+
+	private final CommodityHistoryService commodityHistoryService;
+
+	@Autowired
+	public CommodityController(CommodityService commodityService, CommodityHistoryService commodityHistoryService) {
+		this.commodityService = commodityService;
+		this.commodityHistoryService = commodityHistoryService;
+	}
+
+	/**
+	 * 分页获取店铺某一类目的商品信息
+	 *
+	 * @param enUU			店铺企业UU
+	 * @param kindUuid		类目UUID
+	 * @param params		分页信息
+	 */
+	@RequestMapping(value = "/commodities", method = RequestMethod.GET, params = "origin=store", produces = "application/json")
+	public Page<Commodity> pageStoreCommoditiesByEnInfos(@RequestParam("enUU") Long enUU, @RequestParam(name = "kindUuid", required = false) String kindUuid, PageParams params) {
+		logger.info(String.format("Find commodities information of store by page param %s", params.toString()));
+		if (params.getPage() > 1) {
+			params.setPage(params.getPage() - 1);
+		} else {
+			params.setPage(1);
+		}
+		PageRequest pageRequest = new PageRequest(params.getPage() - 1, params.getCount());
+		return commodityService.pageCommoditiesByEnInfos(enUU, false, kindUuid, pageRequest);
+	}
+
+	/**
+	 * 查看在售(有效/无效)产品
+	 *
+	 * @return
+	 */
+	//TODO 这个需要企业和用户服务传入publishUus过来。根据keyword和enuu找到所以这个企业下的个人UU
+	@RequestMapping(value = "/saling", method = RequestMethod.GET, produces = "application/json")
+	public Page<Commodity> findSalingGoods(PageParams params, String status, @RequestParam(required = false) String keyword, @RequestParam(required = false) List<Long> publisherUUs) {
+		PageInfo info = new PageInfo(params);
+		Long enUU = SystemSession.getUser().getEnterprise().getUu();
+		info.filter("enUU", enUU);
+		if (status.equals("AVAILABLE")) {
+			info.filter("status", Status.AVAILABLE.value());
+		} else if (status.equals("UNAVAILABLE")) {
+			info.filter("status", Status.UNAVAILABLE.value());
+		}
+		Page<Commodity> page = commodityService.findPageByStatus(info, keyword, publisherUUs);
+		return page;
+	}
+
+	/**
+	 * 查看在售(有效/无效)产品
+	 *
+	 * @return
+	 */
+	//TODO 这个需要企业和用户服务传入publishUus过来。根据keyword和enuu找到所以这个企业下的个人UU
+	@RequestMapping(value = "/saling/admin", method = RequestMethod.GET, produces = "application/json")
+	public Page<Commodity> findSalingGoodsAdmin(PageParams params, String status, @RequestParam(required = false) String keyword, @RequestParam(required = false) List<Long> publisherUUs) {
+		PageInfo info = new PageInfo(params);
+		if (status.equals("AVAILABLE")) {
+			info.filter("status", Status.AVAILABLE.value());
+		} else if (status.equals("UNAVAILABLE")) {
+			info.filter("status", Status.UNAVAILABLE.value());
+		}
+		Page<Commodity> page = commodityService.findPageByStatus(info, keyword, publisherUUs);
+		return page;
+	}
+
+	/**
+	 * 查看已下架的产品
+	 *
+	 * @return
+	 */
+	//TODO 这个需要企业和用户服务传入publishUus过来。根据keyword(用户名称)和enuu找到这个企业下的所有包含keyword的个人UU
+	@RequestMapping(value = "/downed", method = RequestMethod.GET, produces = "application/json")
+	public Page<CommodityHistory> findDownedGoods(PageParams params, String keyword, List<Long> publishUus) {
+		PageInfo info = new PageInfo(params);
+		Long enUU = SystemSession.getUser().getEnterprise().getUu();
+		info.filter("enUU", enUU);
+		info.filter("status", Status.REMOVED.value());
+		Page<CommodityHistory> page = commodityHistoryService.findPageByStatus(info, keyword, publishUus);
+		return page;
+	}
+
+	/**
+	 * 管理平台查看已下架的产品
+	 *
+	 * @return Page<GoodsHistory>
+	 */
+	//TODO 这个需要企业和用户服务传入publishUus过来。根据keyword(用户名称)和enuu找到这个企业下的所有包含keyword的个人UU
+	@RequestMapping(value = "/downed/admin", method = RequestMethod.GET, produces = "application/json")
+	public Page<CommodityHistory> findDownedGoodsAdmin(PageParams params, String keyword, List<Long> publishUus) {
+		PageInfo info = new PageInfo(params);
+		info.filter("status", Status.REMOVED.value());
+		Page<CommodityHistory> page = commodityHistoryService.findPageByStatus(info, keyword, publishUus);
+		return page;
+	}
+
+	/**
+	 * 根据uuid查找Goods
+	 *
+	 * @param uuid 器件的UUID
+	 * @return List<Commodity>
+	 */
+	@RequestMapping(value = "/{uuid}", method = RequestMethod.GET, produces = "application/json")
+	public List<Commodity> findAllByUuid(@PathVariable("uuid") String uuid) {
+		List<Commodity> goodses = commodityService.findGoodsByUuid(uuid);
+		return goodses;
+	}
+
+
+	/**
+	 * 根据uuid查找全部的GoodsSimple
+	 *
+	 * @param uuid
+	 * @return
+	 */
+	@RequestMapping(value = "/simple/{uuid}", method = RequestMethod.GET, produces = "application/json")
+	public List<CommoditySimple> findSimpleAllByUuid(@PathVariable("uuid") String uuid) {
+		List<CommoditySimple> goodses = commodityService.findGoodsSimpleByUuid(uuid);
+		return goodses;
+	}
+
+	/**
+	 * 根据批次号查看产品详情
+	 */
+	@RequestMapping(value = "/commodity", method = RequestMethod.GET, produces = "application/json")
+	public Commodity findByBatchCode(@RequestParam("batchCode") String batchCode) {
+		Commodity commodity = commodityService.findGoodsByBatchCode(batchCode);
+		return commodity;
+	}
+}

+ 136 - 0
src/main/java/com/uas/cloud/mall/commodity/api/ReleaseProductByBatchController.java

@@ -0,0 +1,136 @@
+package com.uas.cloud.mall.commodity.api;
+
+import com.uas.cloud.commons.domain.PageInfo;
+import com.uas.cloud.commons.domain.PageParams;
+import com.uas.cloud.commons.exception.IllegalOperatorException;
+import com.uas.cloud.commons.util.FastjsonUtils;
+import com.uas.cloud.mall.commodity.domain.FileUpload;
+import com.uas.cloud.mall.commodity.domain.ReleaseProductByBatch;
+import com.uas.cloud.mall.commodity.repository.ReleaseProductByBatchDao;
+import com.uas.cloud.mall.commodity.service.ReleaseProductByBatchService;
+import com.uas.cloud.mall.commodity.support.JxlsExcelView;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by John on 2017/3/2.
+ */
+@RestController
+@RequestMapping("/releaseProductByBatchs")
+public class ReleaseProductByBatchController {
+
+    private final ReleaseProductByBatchService releaseProductByBatchService;
+
+    private final ReleaseProductByBatchDao releaseProductByBatchDao;
+
+    @Autowired
+    public ReleaseProductByBatchController(ReleaseProductByBatchService releaseProductByBatchService, ReleaseProductByBatchDao releaseProductByBatchDao) {
+        this.releaseProductByBatchService = releaseProductByBatchService;
+        this.releaseProductByBatchDao = releaseProductByBatchDao;
+    }
+
+    /**
+     * 通过id删除信息
+     *
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
+    public void deleteProInfo(@PathVariable("id") Long id) {
+        releaseProductByBatchService.delete(id);
+    }
+
+    /**
+     * 通过batch批量发布产品,
+     * @param batch
+     * @return
+     */
+    //TODO 器件服务 需要调用器件的服务,更新器件的库存,
+    //TODO ShopComponent 对象需要填充,消费者需要调用根据当前登录的ENUU 再根据返回的UUID查找数据库,再填充相应的数据。
+    @RequestMapping(value = "/commodities", method = RequestMethod.POST, produces = "application/json")
+    public Set<String> batchRelease(String batch) {
+        return releaseProductByBatchService.publishByBatch(batch);
+    }
+
+    /**
+     * 通过excel批量导入商品发布(大量)
+     * @param uploadItem
+     * @return
+     */
+    @RequestMapping(value = "/excel", method = RequestMethod.POST, produces = "application/json")
+    public ModelMap releaseByExcel(FileUpload uploadItem) {
+        ModelMap map = new ModelMap();
+        String fileName = uploadItem.getFile().getOriginalFilename();
+        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
+        InputStream is = null;
+        Workbook workbook = null;
+        try {
+            is = uploadItem.getFile().getInputStream();
+            if ("xls".equals(suffix)) {
+                workbook = new HSSFWorkbook(is);
+            } else if ("xlsx".equals(suffix)) {
+                workbook = new XSSFWorkbook(is);
+            } else {
+                throw new IllegalOperatorException("文件格不正确,请上传.xls或.xlsx的文件");
+            }
+            map = releaseProductByBatchService.releaseByWorkbook(workbook);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return map;
+    }
+
+    /**
+     * 导出不合格的数据
+     * @param batch
+     * @return
+     */
+    @RequestMapping(value = "/failure/releaseProductByBatch/xls", method = RequestMethod.GET, produces = "application/json")
+    public ModelAndView exportOrderses(String batch) {
+        ModelAndView modelAndView = new ModelAndView();
+        modelAndView.addObject("data", releaseProductByBatchService.findFailureReleaseProductByBatchByBatch(batch));
+        modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/releaseByBatcherrdata", "优软商城批量发布匹配不正确的产品"));
+        return modelAndView;
+    }
+
+    /**
+     * 通过发布者的UU查询所有的产品的信息
+     *
+     * @param useruu
+     * @return
+     */
+    @RequestMapping(value = "/releaseProductByBatch/useruu", method = RequestMethod.GET, produces = "application/json")
+    public List<ReleaseProductByBatch> getAll(@RequestBody Long useruu) {
+        return releaseProductByBatchService.findByPublisheruu(useruu);
+    }
+
+    /**
+     * 通过id批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @RequestMapping(value = "deleteByQuery", method = RequestMethod.DELETE)
+    public String deleteByQuery(@RequestBody String ids) {
+        List<Long> idArray = FastjsonUtils.fromJsonArray(ids, Long.class);
+        releaseProductByBatchService.delete(idArray);
+        return "success";
+    }
+
+    @RequestMapping(value = "/page", method = RequestMethod.GET, produces = "application/json")
+    public Page<ReleaseProductByBatch> getRelease(PageParams param, String batch) {
+        PageInfo info = new PageInfo(param);
+        return releaseProductByBatchService.getPageReleaseProductByBatch(info, batch);
+    }
+}

+ 1041 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/Commodity.java

@@ -0,0 +1,1041 @@
+package com.uas.cloud.mall.commodity.domain;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.uas.cloud.mall.commodity.util.JacksonUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 上架商品的信息
+ * 
+ * @author ChenHao
+ * @since 201612819:35:19 suntg 修改表名为trade$goods,修改个别字段名字
+ *
+ */
+@Entity
+@Table(name = "trade$goods")
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+public class Commodity implements Serializable {
+
+	/**
+	  * 
+	  */
+	private static final long serialVersionUID = 1L;
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "trade$goods_gen")
+	@SequenceGenerator(name = "trade$goods_gen", sequenceName = "trade$goods_seq", allocationSize = 1)
+	@Column(name = "go_id")
+	private Long id;
+
+	/*=========================================================================
+	 * 器件基础信息
+	 *=========================================================================*/
+
+	/**
+	 * 对应的器件uuid
+	 */
+	@Column(name = "cmp_uuid")
+	private String uuid;
+
+	/**
+	 * 原厂型号
+	 */
+	@Column(name = "cmp_code")
+	private String code;
+
+	/**
+	 * 图片path
+	 */
+	@Column(name = "cmp_img")
+	private String img;
+
+	/**
+	 * 类名UUID
+	 */
+	@Column(name = "go_kind_uuid")
+	private String kindUuid;
+
+	/**
+	 * 类目的名称
+	 */
+	@Column(name = "ki_name")
+	private String kindNameCn;
+
+	/**
+	 * 品牌中文名称
+	 */
+	@Column(name = "br_name_cn")
+	private String brandNameCn;
+
+	/*=========================================================================
+	 * 供应商基础信息
+	 *=========================================================================*/
+
+	/**
+	 * 卖家企业uu
+	 */
+	@Column(name = "go_enuu")
+	private Long enUU;
+
+	/**
+	 * 企业名称
+	 */
+	@Column(name = "go_enterprisename")
+	private String enterpriseName;
+
+	/**
+	 * 发布者个人UU
+	 */
+	@Column(name = "go_publisheruu")
+	private Long publisherUU;
+
+	/**
+	 * 发布者姓名
+	 */
+	@Column(name = "go_publishername")
+	private String publisherName;
+
+	/**
+	 * 发布者联系电话
+	 */
+	@Column(name = "go_publishphone")
+	private String publishPhone;
+
+	/*=========================================================================
+	 * 商品基础信息
+	 *=========================================================================*/
+
+	/**
+	 * 批次号
+	 */
+	@Column(name = "go_batchcode", unique = true)
+	private String batchCode;
+
+	/**
+	 * 是否原厂原装,1311 现货,1312 呆滞库存,(暂时不用)1313 废料
+	 */
+	@Column(name = "go_original")
+	private Integer original = 1311;
+
+	/**
+	 * 唯一标识,用于接口调用
+	 *
+	 * example UAS里面上架申请单商品明细ID
+	 */
+	@Column(name = "go_sourceid")
+	private Long sourceId;
+
+	/**
+	 * 上架时间
+	 */
+	@Column(name = "go_createddate")
+	private Date createdDate;
+
+	/**
+	 * 上次有效期更新时间
+	 */
+	@Column(name = "go_updateDate")
+	private Date updateDate;
+
+	/**
+	 * 有效天数
+	 */
+	@Column(name = "go_availableDays")
+	private Integer availableDays;
+
+	/**
+	 * 状态 AVAILABLE(601, "有效地"), UNAVAILABLE(602, "无效的"),
+	 */
+	@Column(name = "go_status")
+	private Integer status;
+
+	/**
+	 * 产品生产日期
+	 */
+	@Column(name = "go_producedate")
+	private Date produceDate;
+
+	/**
+	 * 本批次的库存数量
+	 */
+	@Column(name = "go_reserve")
+	private Double reserve;
+
+	/**
+	 * 批次信息的修改请求中带有的oldreserve
+	 */
+	@Transient
+	private Double oldReserve;
+
+	/**
+	 * 发布备注
+	 */
+	@Column(name = "go_remark")
+	private String remark;
+
+	/**
+	 * 最小包装量
+	 */
+	@Column(name = "go_minpackqty")
+	private Double minPackQty;
+
+	/**
+	 * 最小起订量
+	 */
+	@Column(name = "go_minbuyqty")
+	private Double minBuyQty;
+
+	/**
+	 * 器件发送到客户的时间
+	 */
+	@Column(name = "go_componentDelivery")
+	private Short componentDelivery;
+
+	/**
+	 * 供应商上架的样品数量(总数)
+	 */
+	@Column(name = "go_sampleqty")
+	private Double sampleQty = (double) 0;
+
+	/**
+	 * 已申请的样品数量
+	 */
+	@Column(name = "go_sampleappliedqty")
+	private Double sampleAppliedQty = (double) 0;
+
+	/**
+	 * 币种名称
+	 */
+	@Column(name = "cr_name")
+	private String currencyName;
+
+	/**
+	 * 是否支持7天无理由退货,1:支持,0:不支持
+	 */
+	@Column(name = "go_returninweek")
+	private Short returnInWeek;
+
+	/**
+	 * 当前登录企业是否对此批次已送样(默认False)
+	 */
+	@Transient
+	private boolean hasSample;
+
+	/**
+	 * 剩余有效天数
+	 */
+	@Transient
+	private Integer restDays;
+
+	/**
+	 * 包装:托盘、管装、卷带
+	 */
+	@Column(name = "go_packaging")
+	private String packaging;
+
+	/**
+	 * 发货地区
+	 */
+	@Column(name = "go_shiparea")
+	private String shipArea;
+
+	/*=========================================================================
+	 * 商品价格信息
+	 *=========================================================================*/
+
+	/**
+	 * 人民币税率
+	 */
+	@Column(name = "go_rmbTaxRate")
+	private Double rmbTaxRate;
+
+	/**
+	 * 美元税率
+	 */
+	@Column(name = "go_usdTaxRate")
+	private Double usdTaxRate;
+
+	/**
+	 * 分段报价(JSON串) eg:[{"start":0,"end":1000,"price":2.3,"taxPrice":2.5},...]
+	 */
+	@Column(name = "go_qtyprice")
+	private String qtyPrice;
+
+	/**
+	 * 分段报价(List)
+	 */
+	@Transient
+	private List<CommodityQtyPrice> prices;
+
+	/*=========================================================================
+	 * 交货周期
+	 *=========================================================================*/
+
+	/**
+	 * 大陆交期[供应商送平台的时间]
+	 */
+	@Column(name = "go_deliverydemtime")
+	private Short deliveryDemTime;
+
+	/**
+	 * 大陆交期最短
+	 */
+	@Column(name = "go_deliverydemintime")
+	private Short b2cDeliveryDemMinTime;
+
+	/**
+	 * 大陆交期最长
+	 */
+	@Column(name = "go_deliverydemaxtime")
+	private Short b2cDeliveryDemMaxTime;
+
+	/**
+	 * 香港交期[供应商送平台的时间]
+	 */
+	@Column(name = "go_deliveryhktime")
+	private Short deliveryHKTime;
+
+	/**
+	 * 香港交期最短
+	 */
+	@Column(name = "go_deliveryhkmintime")
+	private Short b2cDeliveryHKMinTime;
+
+	/**
+	 * 香港交期最长
+	 */
+	@Column(name = "go_deliveryhkmaxtime")
+	private Short b2cDeliveryHKMaxTime;
+
+	/*=========================================================================
+	 * 价格区间信息
+	 *=========================================================================*/
+
+	/**
+	 * 本批次的最低人民币价格
+	 */
+	@Column(name = "go_minpricermb")
+	private Double minPriceRMB;
+
+	/**
+	 * 本批次的最高人民币价格
+	 */
+	@Column(name = "go_maxpricermb")
+	private Double maxPriceRMB;
+
+	/**
+	 * 本批次的最低美元价格
+	 */
+	@Column(name = "go_minpriceusd")
+	private Double minPriceUSD;
+
+	/**
+	 * 本批次的最高美元价格
+	 */
+	@Column(name = "go_maxpriceusd")
+	private Double maxPriceUSD;
+
+	/**
+	 * 是否为优软代售
+	 */
+	@Column(name = "go_is_self_support")
+	private Boolean isSelfSupport = true;
+
+	/**
+	 * 批次所属的店铺
+	 */
+	@Column(name = "go_store_uuid")
+	private String storeuuid;
+
+	/**
+	 * 批量上传的标志
+	 */
+	@Column(name = "go_batchid")
+	private String batchid;
+
+	public Commodity() {
+	}
+
+	/*=========================================================================
+	 * Getter And Setter
+	 *=========================================================================*/
+
+	public String getPackaging() {
+		return packaging;
+	}
+
+	public void setPackaging(String packaging) {
+		this.packaging = packaging;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getUuid() {
+		return uuid;
+	}
+
+	public void setUuid(String uuid) {
+		this.uuid = uuid;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getImg() {
+		return img;
+	}
+
+	public void setImg(String img) {
+		this.img = img;
+	}
+
+	public String getKindUuid() {
+		return kindUuid;
+	}
+
+	public void setKindUuid(String kindUuid) {
+		this.kindUuid = kindUuid;
+	}
+
+	public String getKindNameCn() {
+		return kindNameCn;
+	}
+
+	public void setKindNameCn(String kindNameCn) {
+		this.kindNameCn = kindNameCn;
+	}
+
+	public String getBrandNameCn() {
+		return brandNameCn;
+	}
+
+	public void setBrandNameCn(String brandNameCn) {
+		this.brandNameCn = brandNameCn;
+	}
+
+	public Long getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(Long sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public Date getCreatedDate() {
+		return createdDate;
+	}
+
+	public String getStoreuuid() {
+		return storeuuid;
+	}
+
+	public Commodity setStoreuuid(String storeuuid) {
+		this.storeuuid = storeuuid;
+		return this;
+	}
+
+	public void setCreatedDate(Date createdDate) {
+		this.createdDate = createdDate;
+	}
+
+	public String getPublisherName() {
+		return publisherName;
+	}
+
+	public void setPublisherName(String publisherName) {
+		this.publisherName = publisherName;
+	}
+
+	public String getPublishPhone() {
+		return publishPhone;
+	}
+
+	public void setPublishPhone(String publishPhone) {
+		this.publishPhone = publishPhone;
+	}
+
+	public Date getUpdateDate() {
+		return updateDate;
+	}
+
+	public void setUpdateDate(Date updateDate) {
+		this.updateDate = updateDate;
+	}
+
+	public Integer getAvailableDays() {
+		return availableDays;
+	}
+
+	public void setAvailableDays(Integer availableDays) {
+		this.availableDays = availableDays;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Date getProduceDate() {
+		return produceDate;
+	}
+
+	public void setProduceDate(Date produceDate) {
+		this.produceDate = produceDate;
+	}
+
+	public Double getReserve() {
+		return reserve;
+	}
+
+	public void setReserve(Double reserve) {
+		this.reserve = reserve;
+	}
+
+	public Double getOldReserve() {
+		return oldReserve;
+	}
+
+	public void setOldReserve(Double oldReserve) {
+		this.oldReserve = oldReserve;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Double getMinPackQty() {
+		return minPackQty;
+	}
+
+	public void setMinPackQty(Double minPackQty) {
+		this.minPackQty = minPackQty;
+	}
+
+	public String getBatchCode() {
+		return batchCode;
+	}
+
+	public void setBatchCode(String batchCode) {
+		this.batchCode = batchCode;
+	}
+
+	public Long getEnUU() {
+		return enUU;
+	}
+
+	public void setEnUU(Long enUU) {
+		this.enUU = enUU;
+	}
+
+	public Long getPublisherUU() {
+		return this.publisherUU;
+	}
+
+	public void setPublisherUU(Long publisherUU) {
+		this.publisherUU = publisherUU;
+	}
+
+	public Double getMinBuyQty() {
+		return minBuyQty;
+	}
+
+	public void setMinBuyQty(Double minBuyQty) {
+		this.minBuyQty = minBuyQty;
+	}
+
+	public Short getComponentDelivery() {
+		return componentDelivery;
+	}
+
+	public void setComponentDelivery(Short componentDelivery) {
+		this.componentDelivery = componentDelivery;
+	}
+
+	public Double getSampleQty() {
+		return sampleQty;
+	}
+
+	public void setSampleQty(Double sampleQty) {
+		this.sampleQty = sampleQty;
+	}
+
+	public Double getSampleAppliedQty() {
+		return sampleAppliedQty;
+	}
+
+	public void setSampleAppliedQty(Double sampleAppliedQty) {
+		this.sampleAppliedQty = sampleAppliedQty;
+	}
+
+	public boolean isHasSample() {
+		return hasSample;
+	}
+
+	public void setHasSample(boolean hasSample) {
+		this.hasSample = hasSample;
+	}
+
+	public Integer getRestDays() {
+		return restDays;
+	}
+
+	public void setRestDays(Integer restDays) {
+		this.restDays = restDays;
+	}
+
+	public Integer getOriginal() {
+		return original;
+	}
+
+	public void setOriginal(Integer original) {
+		this.original = original;
+	}
+
+	public String getEnterpriseName() {
+		return enterpriseName;
+	}
+
+	public void setEnterpriseName(String enterpriseName) {
+		this.enterpriseName = enterpriseName;
+	}
+
+	public String getCurrencyName() {
+		return currencyName;
+	}
+
+	public void setCurrencyName(String currencyName) {
+		this.currencyName = currencyName;
+	}
+
+	public Short getReturnInWeek() {
+		return returnInWeek;
+	}
+
+	public void setReturnInWeek(Short returnInWeek) {
+		this.returnInWeek = returnInWeek;
+	}
+
+	public String getShipArea() {
+		return shipArea;
+	}
+
+	public void setShipArea(String shipArea) {
+		this.shipArea = shipArea;
+	}
+
+	public Double getRmbTaxRate() {
+		return rmbTaxRate == null ? 0.17 : rmbTaxRate;
+	}
+
+	public void setRmbTaxRate(Double rmbTaxRate) {
+		this.rmbTaxRate = rmbTaxRate;
+	}
+
+	public Double getUsdTaxRate() {
+		return usdTaxRate == null ? 0 : usdTaxRate;
+	}
+
+	public void setUsdTaxRate(Double usdTaxRate) {
+		this.usdTaxRate = usdTaxRate;
+	}
+
+	public Short getDeliveryDemTime() {
+		return deliveryDemTime;
+	}
+
+	public void setDeliveryDemTime(Short deliveryDemTime) {
+		this.deliveryDemTime = deliveryDemTime;
+	}
+
+	public Short getB2cDeliveryDemMinTime() {
+		return b2cDeliveryDemMinTime;
+	}
+
+	public void setB2cDeliveryDemMinTime(Short b2cDeliveryDemMinTime) {
+		this.b2cDeliveryDemMinTime = b2cDeliveryDemMinTime;
+	}
+
+	public Short getB2cDeliveryDemMaxTime() {
+		return b2cDeliveryDemMaxTime;
+	}
+
+	public void setB2cDeliveryDemMaxTime(Short b2cDeliveryDemMaxTime) {
+		this.b2cDeliveryDemMaxTime = b2cDeliveryDemMaxTime;
+	}
+
+	public Short getDeliveryHKTime() {
+		return deliveryHKTime;
+	}
+
+	public void setDeliveryHKTime(Short deliveryHKTime) {
+		this.deliveryHKTime = deliveryHKTime;
+	}
+
+	public Short getB2cDeliveryHKMinTime() {
+		return b2cDeliveryHKMinTime;
+	}
+
+	public void setB2cDeliveryHKMinTime(Short b2cDeliveryHKMinTime) {
+		this.b2cDeliveryHKMinTime = b2cDeliveryHKMinTime;
+	}
+
+	public Short getB2cDeliveryHKMaxTime() {
+		return b2cDeliveryHKMaxTime;
+	}
+
+	public void setB2cDeliveryHKMaxTime(Short b2cDeliveryHKMaxTime) {
+		this.b2cDeliveryHKMaxTime = b2cDeliveryHKMaxTime;
+	}
+
+	public Double getMinPriceRMB() {
+		return minPriceRMB;
+	}
+
+	public void setMinPriceRMB(Double minPriceRMB) {
+		this.minPriceRMB = minPriceRMB;
+	}
+
+	public Double getMaxPriceRMB() {
+		return maxPriceRMB;
+	}
+
+	public void setMaxPriceRMB(Double maxPriceRMB) {
+		this.maxPriceRMB = maxPriceRMB;
+	}
+
+	public Double getMinPriceUSD() {
+		return minPriceUSD;
+	}
+
+	public void setMinPriceUSD(Double minPriceUSD) {
+		this.minPriceUSD = minPriceUSD;
+	}
+
+	public Double getMaxPriceUSD() {
+		return maxPriceUSD;
+	}
+
+	public void setMaxPriceUSD(Double maxPriceUSD) {
+		this.maxPriceUSD = maxPriceUSD;
+	}
+
+	public Boolean getSelfSupport() {
+		return isSelfSupport;
+	}
+
+	public void setSelfSupport(Boolean selfSupport) {
+		isSelfSupport = selfSupport;
+	}
+
+	public String getBatchid() {
+		return batchid;
+	}
+
+	public Commodity setBatchid(String batchid) {
+		this.batchid = batchid;
+		return this;
+	}
+
+	/*=========================================================================
+	 * Property Method
+	 *=========================================================================*/
+
+	@JsonIgnore
+	public String getQtyPrice() {
+		return qtyPrice;
+	}
+
+	public void setQtyPrice(String qtyPrice) {
+		this.qtyPrice = qtyPrice;
+	}
+
+	public List<CommodityQtyPrice> getPrices() {
+		System.out.println(this.qtyPrice);
+		if (CollectionUtils.isEmpty(prices) && StringUtils.hasText(qtyPrice)) {
+			return JacksonUtils.fromJsonArray(this.qtyPrice, CommodityQtyPrice.class);
+		} else {
+			return prices;
+		}
+	}
+
+	public void setPrices(List<CommodityQtyPrice> prices) {
+		this.prices = prices;
+		if (!CollectionUtils.isEmpty(prices)) {
+			this.qtyPrice = JacksonUtils.toJson(this.prices);
+		}
+	}
+
+	/**
+	 * 用人民币含税单价修改未含税人民币单价
+	 */
+	public void setWithOutTaxRMBPrice() {
+		if (!CollectionUtils.isEmpty(this.prices)) {
+			if (this.currencyName.contains("RMB")) {
+				for (CommodityQtyPrice price : prices) {
+					BigDecimal taxNum = new BigDecimal(this.getRmbTaxRate() + 1);
+					if (price.getrMBPrice() == null) {
+						throw new IllegalStateException("您上架了RMB币别,但是没有对应的价格");
+					}
+					BigDecimal priceNum = new BigDecimal(price.getrMBPrice());
+					price.setrMBNTPrice(priceNum.divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
+				}
+			}
+			// 更新分段价格JSON字符串
+			this.qtyPrice = JacksonUtils.toJson(this.prices);
+		}
+	}
+
+	/**
+	 * 用美元含税单价修改未含税美元单价
+	 */
+	public void setWithOutTaxUSDPrice() {
+		if (!CollectionUtils.isEmpty(this.prices)) {
+			if (this.currencyName.contains("USD")) {
+				for (CommodityQtyPrice price : prices) {
+					BigDecimal taxNum = new BigDecimal(this.getUsdTaxRate() + 1);
+					if (price.getuSDPrice() == null) {
+						throw new IllegalStateException("您上架了USD币别,但是没有对应的价格");
+					}
+					BigDecimal priceNum = new BigDecimal(price.getuSDPrice());
+					price.setuSDNTPrice(priceNum.divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
+				}
+			}
+			// 更新分段价格JSON字符串
+			this.qtyPrice = JacksonUtils.toJson(this.prices);
+		}
+	}
+
+	/**
+	 * 获取对应币别的交货周期
+	 * 
+	 * @return
+	 */
+	public Short getDeliveryTime() {
+		if (StringUtils.isEmpty(currencyName)) {
+			return null;
+		}
+		if ("RMB".equalsIgnoreCase(currencyName)) {
+			return getDeliveryDemTime();
+		} else if ("USD".equalsIgnoreCase(currencyName)) {
+			return getDeliveryHKTime();
+		} else if ("RMB-USD".equalsIgnoreCase(currencyName)) {
+			return null;
+		} else {
+			return null;
+		}
+	}
+
+	/**
+	 * 设置对应币别的交货周期
+	 * 
+	 * @param deliveryTime
+	 *            交货周期
+	 */
+	public void setDeliveryTime(Short deliveryTime) {
+		if (StringUtils.isEmpty(currencyName)) {
+			return;
+		}
+		if ("RMB".equalsIgnoreCase(currencyName)) {
+			this.deliveryDemTime = deliveryTime;
+		} else if ("USD".equalsIgnoreCase(currencyName)) {
+			this.deliveryHKTime = deliveryTime;
+		}
+	}
+
+	/**
+	 * 根据币别获取本批次最小价格
+	 */
+	public Double getMinPrice() {
+		if (StringUtils.isEmpty(currencyName)) {
+			return null;
+		}
+		if ("RMB".equalsIgnoreCase(currencyName)) {
+			return getMinPriceRMB();
+		} else if ("USD".equalsIgnoreCase(currencyName)) {
+			return getMinPriceUSD();
+		} else if ("RMB-USD".equalsIgnoreCase(currencyName)) {
+			return null;
+		} else {
+			return null;
+		}
+	}
+
+	/**
+	 * 根据币别设置本批次最小价格
+	 */
+	public void setMinPrice(Double minPrice) {
+		if (StringUtils.isEmpty(currencyName)) {
+			return;
+		}
+		if ("RMB".equalsIgnoreCase(currencyName)) {
+			this.minPriceRMB = minPrice;
+		} else if ("USD".equalsIgnoreCase(currencyName)) {
+			this.minPriceUSD = minPrice;
+		}
+	}
+
+	/**
+	 * 根据币别获取本批次最大价格
+	 */
+	public Double getMaxPrice() {
+		if (StringUtils.isEmpty(currencyName)) {
+			return null;
+		}
+		if ("RMB".equalsIgnoreCase(currencyName)) {
+			return getMaxPriceRMB();
+		} else if ("USD".equalsIgnoreCase(currencyName)) {
+			return getMaxPriceUSD();
+		} else if ("RMB-USD".equalsIgnoreCase(currencyName)) {
+			return null;
+		} else {
+			return null;
+		}
+	}
+
+	/**
+	 * 根据币别设置本批次最大价格
+	 */
+	public void setMaxPrice(Double maxPrice) {
+		if (StringUtils.isEmpty(currencyName)) {
+			return;
+		}
+		if ("RMB".equalsIgnoreCase(currencyName)) {
+			this.maxPriceRMB = maxPrice;
+		} else if ("USD".equalsIgnoreCase(currencyName)) {
+			this.maxPriceUSD = maxPrice;
+		}
+	}
+
+	/**
+	 * 根据币别获取对应税率
+	 */
+	public Short getTax() {
+		if (StringUtils.isEmpty(currencyName)) {
+			return null;
+		}
+		if ("RMB".equalsIgnoreCase(currencyName)) {
+			if (this.rmbTaxRate == null) {
+				this.rmbTaxRate = 0.17D;
+			}
+			Double value = this.rmbTaxRate * 100;
+			return value.shortValue();
+		} else if ("USD".equalsIgnoreCase(currencyName)) {
+			if (this.usdTaxRate == null) {
+				this.usdTaxRate = 0.0D;
+			}
+			Double value = this.usdTaxRate * 100;
+			return value.shortValue();
+		} else if ("RMB-USD".equalsIgnoreCase(currencyName)) {
+			return null;
+		} else {
+			return null;
+		}
+	}
+
+	/**
+	 * 根据币别设置对应税率
+	 */
+	public void setTax(Short tax) {
+		if (StringUtils.isEmpty(currencyName)) {
+			return;
+		}
+		if ("RMB".equalsIgnoreCase(currencyName)) {
+			this.rmbTaxRate = ((double) tax) / 100;
+		} else if ("USD".equalsIgnoreCase(currencyName)) {
+			this.usdTaxRate = ((double) tax) / 100;
+		} else if ("RMB-USD".equalsIgnoreCase(currencyName)) {
+			this.rmbTaxRate = 0.17D;
+			this.usdTaxRate = 0.0D;
+		}
+	}
+
+	/**
+	 * 获取人民币分段报价列表
+	 */
+	public List<CommodityQtyPrice> getRmbSegPriceList() {
+		List<CommodityQtyPrice> prices = new ArrayList<>();
+		if (!currencyName.contains("RMB")) {
+			return null;
+		}
+        if(!CollectionUtils.isEmpty(getPrices())) {
+            for (CommodityQtyPrice qtyPrice : getPrices()) {
+                CommodityQtyPrice price = new CommodityQtyPrice();
+                price.setStart(qtyPrice.getStart());
+                price.setEnd(qtyPrice.getEnd());
+                price.setTaxPrice(qtyPrice.getrMBPrice());
+                price.setPrice(qtyPrice.getrMBNTPrice());
+                prices.add(price);
+            }
+        }
+		return prices;
+	}
+
+	/**
+	 * 获取美元分段报价列表
+	 */
+	public List<CommodityQtyPrice> getUsdSegPriceList() {
+		if (!currencyName.contains("USD")) {
+			return null;
+		}
+		List<CommodityQtyPrice> prices = new ArrayList<>();
+		if(!CollectionUtils.isEmpty(getPrices())) {
+            for (CommodityQtyPrice qtyPrice : getPrices()) {
+                CommodityQtyPrice price = new CommodityQtyPrice();
+                price.setStart(qtyPrice.getStart());
+                price.setEnd(qtyPrice.getEnd());
+                price.setTaxPrice(qtyPrice.getuSDPrice());
+                price.setPrice(qtyPrice.getuSDNTPrice());
+                prices.add(price);
+            }
+        }
+		return prices;
+	}
+	
+	@Override
+	public String toString() {
+		return "Goods [id=" + id + ", uuid=" + uuid + ", code=" + code + ", img=" + img + ", kindNameCn=" + kindNameCn
+				+ ", brandNameCn=" + brandNameCn + ", enUU=" + enUU + ", enterpriseName=" + enterpriseName
+				+ ", publisherUU=" + publisherUU + ", publisherName=" + publisherName + ", publishPhone=" + publishPhone
+				+ ", batchCode=" + batchCode + ", original=" + original + ", sourceId=" + sourceId + ", createdDate="
+				+ createdDate + ", updateDate=" + updateDate + ", availableDays=" + availableDays + ", status=" + status
+				+ ", produceDate=" + produceDate + ", reserve=" + reserve + ", oldReserve=" + oldReserve + ", remark="
+				+ remark + ", minPackQty=" + minPackQty + ", minBuyQty=" + minBuyQty + ", componentDelivery="
+				+ componentDelivery + ", sampleQty=" + sampleQty + ", sampleAppliedQty=" + sampleAppliedQty
+				+ ", currencyName=" + currencyName + ", returnInWeek=" + returnInWeek + ", hasSample=" + hasSample
+				+ ", restDays=" + restDays + ", packaging=" + packaging + ", shipArea=" + shipArea + ", rmbTaxRate="
+				+ rmbTaxRate + ", usdTaxRate=" + usdTaxRate + ", qtyPrice=" + qtyPrice + ", prices=" + prices
+				+ ", deliveryDemTime=" + deliveryDemTime + ", b2cDeliveryDemMinTime=" + b2cDeliveryDemMinTime
+				+ ", b2cDeliveryDemMaxTime=" + b2cDeliveryDemMaxTime + ", deliveryHKTime=" + deliveryHKTime
+				+ ", b2cDeliveryHKMinTime=" + b2cDeliveryHKMinTime + ", b2cDeliveryHKMaxTime=" + b2cDeliveryHKMaxTime
+				+ ", minPriceRMB=" + minPriceRMB + ", maxPriceRMB=" + maxPriceRMB + ", minPriceUSD=" + minPriceUSD
+				+ ", maxPriceUSD=" + maxPriceUSD + "]";
+	}
+
+}

+ 754 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/CommodityHistory.java

@@ -0,0 +1,754 @@
+package com.uas.cloud.mall.commodity.domain;
+
+import javax.persistence.*;
+import java.util.Date;
+
+/**
+ * 上架商品的历史信息
+ * 
+ * @author ChenHao
+ *
+ */
+@Entity
+@Table(name = "trade$goods_history")
+public class CommodityHistory {
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "trade$goods_history_gen")
+	@SequenceGenerator(name = "trade$goods_history_gen", sequenceName = "trade$goods_history_seq", allocationSize = 1)
+	@Column(name = "go_id")
+	private Long id;
+
+	/**
+	 * 对应的器件uuid
+	 */
+	@Column(name = "cmp_uuid")
+	private String uuid;
+
+	/**
+	 * 原厂型号
+	 */
+	@Column(name = "cmp_code")
+	private String code;
+
+	/**
+	 * 图片path
+	 */
+	@Column(name = "cmp_img")
+	private String img;
+
+	/**
+	 * 类目的名称
+	 */
+	@Column(name = "ki_name")
+	private String kindNameCn;
+
+	/**
+	 * 品牌中文名称
+	 */
+	@Column(name = "br_name_cn")
+	private String brandNameCn;
+
+	/**
+	 * 批次号
+	 */
+	@Column(name = "go_batchcode")
+	private String batchCode;
+
+	/**
+	 * 库存,现货 1311 ,呆滞库存 1312,(暂时不用) 废料 1313
+	 */
+	@Column(name = "go_original")
+	private Integer original;
+
+	/**
+	 * 卖家企业uu
+	 */
+	@Column(name = "go_enuu")
+	private Long enUU;
+
+	/**
+	 * 唯一标识,用于接口调用
+	 *
+	 * @example UAS里面上架申请单商品明细ID
+	 */
+	@Column(name = "go_sourceid")
+	private Long sourceId;
+	
+	/**
+	 * 发布者个人UU
+	 */
+	@Column(name = "go_publisheruu")
+	private Long publisherUU;
+
+	/**
+	 * 发布者姓名
+	 */
+	@Column(name = "go_publishername")
+	private String publisherName;
+
+	/**
+	 * 发布者联系电话
+	 */
+	@Column(name = "go_publishphone")
+	private String publishPhone;
+
+	/**
+	 * 上架时间
+	 */
+	@Column(name = "go_createdate")
+	private Date createdDate;
+
+	/**
+	 * 上次有效期更新时间
+	 */
+	@Column(name = "go_updateDate")
+	private Date updateDate;
+
+	/**
+	 * 有效天数
+	 */
+	@Column(name = "go_availableDays")
+	private Integer availableDays;
+
+	/**
+	 * 状态 AVAILABLE(601, "有效地"), UNAVAILABLE(602, "无效的"), REMOVED(604, "已下架");
+	 */
+	@Column(name = "go_status")
+	private Integer status;
+
+	/**
+	 * 分段报价(JSON串) eg:[{"start":0,"end":1000,"price":2.3,"taxPrice":2.5},...]
+	 */
+	@Column(name = "go_qtyprice")
+	private String qtyPrice;
+
+	/**
+	 * 交期
+	 */
+	@Column(name = "go_deliveryTime")
+	private Short deliveryTime;
+
+	/**
+	 * 到大陆交期
+	 */
+	@Column(name = "go_deliveryDemTime")
+	private Short deliveryDemTime;
+
+	/**
+	 * 到香港交期
+	 */
+	@Column(name = "go_deliveryHKTime")
+	private Short deliveryHKTime;
+
+	/**
+	 * 产品生产日期
+	 */
+	@Column(name = "go_producedate")
+	private Date produceDate;
+
+	/**
+	 * 本批次的库存数量
+	 */
+	@Column(name = "go_reserve")
+	private Double reserve;
+
+	/**
+	 * 发布备注
+	 */
+	@Column(name = "go_remark")
+	private String remark;
+
+	/**
+	 * 最小起订量
+	 */
+	@Column(name = "go_minbuyqty")
+	private Double minBuyQty;
+
+	/**
+	 * 最小包装量
+	 */
+	@Column(name = "go_minpackqty")
+	private Double minPackQty;
+
+	/**
+	 * 包装:托盘、管装、卷带
+	 */
+	@Column(name = "go_packaging")
+	private String packaging;
+	
+	/**
+	 * 操作类型
+	 */
+	@Column(name = "log_operateType")
+	private String operateType;
+
+	/**
+	 * 操作时间
+	 */
+	@Column(name = "log_operateDate")
+	private Date operateDate;
+
+	/**
+	 * 币种名称
+	 */
+	@Column(name = "cr_name")
+	private String currencyName;
+
+	/**
+	 * 税率
+	 */
+	@Column(name = "go_tax")
+	private Short tax;
+
+	/**
+	 * 人民币税率
+	 */
+	@Column(name = "go_rmbTaxRate")
+	private Double rmbTaxRate;
+
+	/**
+	 * 美元税率
+	 */
+	@Column(name = "go_usdTaxRate")
+	private Double usdTaxRate;
+
+	/**
+	 * 是否支持7天无理由退货
+	 */
+	@Column(name = "go_returninweek")
+	private Short returnInWeek;
+
+	/**
+	 * 操作详情
+	 */
+	@Column(name = "log_message")
+	private String message;
+	
+	/**
+	 * 发货地区
+	 */
+	@Column(name = "go_shiparea")
+	private String shipArea;
+	
+	/**
+	 * 换算之后的汇率
+	 */
+	@Column(name = "go_exchangeprice")
+	private String exchangeQtyPrices;
+	
+	/**
+	 * 换算的币别
+	 */
+	@Column(name = "go_exchangecurrency")
+	private String exchangeCurrency;
+	
+	/**
+	 * 货到香港交期最短
+	 */
+	@Column(name = "go_b2cdeliveryhkmintime")	
+	private Short b2cDeliveryHKMinTime;
+	
+	/**
+	 * 货到香港交期最长
+	 */
+	@Column(name = "go_b2cdeliveryhkmaxtime")	
+	private Short b2cDeliveryHKMaxTime;
+	
+	/**
+	 * 货到大陆交期最短
+	 */
+	@Column(name = "go_b2cdeliverydemintime")	
+	private Short b2cDeliveryDemMinTime;
+	
+	/**
+	 * 货到大陆交期最长
+	 */
+	@Column(name = "go_b2cdeliverydemaxtime")	
+	private Short b2cDeliveryDemMaxTime;
+	
+	/**
+	 * 变更库存人uu
+	 */
+	@Column(name = "log_operateuu")
+	private Long operateUU;
+	
+	public enum OperateType {
+		/**
+		 * {@code 101产品上架}
+		 */
+		Publish(101, "发布商品"),
+
+		/**
+		 * {@code 102更新批次信息}
+		 */
+		Update(102, "更新批次信息"),
+
+		/**
+		 * {@code 103产品下架}
+		 */
+		Down(103, "下架商品"),
+
+		/**
+		 * {@code  104供应商手动刷新}
+		 */
+		VendorRefresh(104, "供应商手动刷新"),
+
+		/**
+		 * {@code  105订单已付款}
+		 */
+		OrderPaied(105, "商品售出"),
+
+		/**
+		 * {@code  106订单生成,锁定库存}
+		 */
+		DeductReserve(106, "锁定库存"),
+
+		/**
+		 * {@code  107订单取消,释放库存}
+		 */
+		ReleaseReserve(107, "释放库存");
+
+		OperateType(int value, String phrase) {
+			this.value = value;
+			this.phrase = phrase;
+		}
+
+		private final int value;
+
+		private final String phrase;
+
+		/**
+		 * @return 状态的整型编码
+		 */
+		public int value() {
+			return this.value;
+		}
+
+		/**
+		 * @return 状态的描述
+		 */
+		public String getPhrase() {
+			return this.phrase;
+		}
+	}
+
+	@Transient
+	private String enterpriseName;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getUuid() {
+		return uuid;
+	}
+
+	public void setUuid(String uuid) {
+		this.uuid = uuid;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getShipArea() {
+		return shipArea;
+	}
+
+	public void setShipArea(String shipArea) {
+		this.shipArea = shipArea;
+	}
+
+	public String getExchangeQtyPrices() {
+		return exchangeQtyPrices;
+	}
+
+	public void setExchangeQtyPrices(String exchangeQtyPrices) {
+		this.exchangeQtyPrices = exchangeQtyPrices;
+	}
+
+	public String getExchangeCurrency() {
+		return exchangeCurrency;
+	}
+
+	public void setExchangeCurrency(String exchangeCurrency) {
+		this.exchangeCurrency = exchangeCurrency;
+	}
+
+	public Short getB2cDeliveryHKMinTime() {
+		return b2cDeliveryHKMinTime;
+	}
+
+	public void setB2cDeliveryHKMinTime(Short b2cDeliveryHKMinTime) {
+		this.b2cDeliveryHKMinTime = b2cDeliveryHKMinTime;
+	}
+
+	public Short getB2cDeliveryHKMaxTime() {
+		return b2cDeliveryHKMaxTime;
+	}
+
+	public void setB2cDeliveryHKMaxTime(Short b2cDeliveryHKMaxTime) {
+		this.b2cDeliveryHKMaxTime = b2cDeliveryHKMaxTime;
+	}
+
+	public Short getB2cDeliveryDemMinTime() {
+		return b2cDeliveryDemMinTime;
+	}
+
+	public void setB2cDeliveryDemMinTime(Short b2cDeliveryDemMinTime) {
+		this.b2cDeliveryDemMinTime = b2cDeliveryDemMinTime;
+	}
+
+	public Short getB2cDeliveryDemMaxTime() {
+		return b2cDeliveryDemMaxTime;
+	}
+
+	public void setB2cDeliveryDemMaxTime(Short b2cDeliveryDemMaxTime) {
+		this.b2cDeliveryDemMaxTime = b2cDeliveryDemMaxTime;
+	}
+
+	public Long getOperateUU() {
+		return operateUU;
+	}
+
+	public void setOperateUU(Long operateUU) {
+		this.operateUU = operateUU;
+	}
+
+	public Double getRmbTaxRate() {
+		return rmbTaxRate;
+	}
+
+	public void setRmbTaxRate(Double rmbTaxRate) {
+		this.rmbTaxRate = rmbTaxRate;
+	}
+
+	public Double getUsdTaxRate() {
+		return usdTaxRate;
+	}
+
+	public void setUsdTaxRate(Double usdTaxRate) {
+		this.usdTaxRate = usdTaxRate;
+	}
+
+	public String getImg() {
+		return img;
+	}
+
+	public void setImg(String img) {
+		this.img = img;
+	}
+
+	public String getKindNameCn() {
+		return kindNameCn;
+	}
+
+	public void setKindNameCn(String kindNameCn) {
+		this.kindNameCn = kindNameCn;
+	}
+
+	public String getBrandNameCn() {
+		return brandNameCn;
+	}
+
+	public void setBrandNameCn(String brandNameCn) {
+		this.brandNameCn = brandNameCn;
+	}
+
+	public String getBatchCode() {
+		return batchCode;
+	}
+
+	public void setBatchCode(String batchCode) {
+		this.batchCode = batchCode;
+	}
+
+	public Long getEnUU() {
+		return enUU;
+	}
+
+	public void setEnUU(Long enUU) {
+		this.enUU = enUU;
+	}
+
+	public Long getPublisherUU() {
+		return publisherUU;
+	}
+
+	public void setPublisherUU(Long publisherUU) {
+		this.publisherUU = publisherUU;
+	}
+
+	public String getPublisherName() {
+		return publisherName;
+	}
+
+	public void setPublisherName(String publisherName) {
+		this.publisherName = publisherName;
+	}
+
+	public String getPublishPhone() {
+		return publishPhone;
+	}
+
+	public void setPublishPhone(String publishPhone) {
+		this.publishPhone = publishPhone;
+	}
+
+	public Date getCreatedDate() {
+		return createdDate;
+	}
+
+	public void setCreatedDate(Date createdDate) {
+		this.createdDate = createdDate;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Double getMinBuyQty() {
+		return minBuyQty;
+	}
+
+	public void setMinBuyQty(Double minBuyQty) {
+		this.minBuyQty = minBuyQty;
+	}
+
+	public String getQtyPrice() {
+		return qtyPrice;
+	}
+
+	public void setQtyPrice(String qtyPrice) {
+		this.qtyPrice = qtyPrice;
+	}
+
+	public Short getDeliveryTime() {
+		return deliveryTime;
+	}
+
+	public void setDeliveryTime(Short deliveryTime) {
+		this.deliveryTime = deliveryTime;
+	}
+
+	public Short getDeliveryDemTime() {
+		return deliveryDemTime;
+	}
+
+	public void setDeliveryDemTime(Short deliveryDemTime) {
+		this.deliveryDemTime = deliveryDemTime;
+	}
+
+	public Short getDeliveryHKTime() {
+		return deliveryHKTime;
+	}
+
+	public void setDeliveryHKTime(Short deliveryHKTime) {
+		this.deliveryHKTime = deliveryHKTime;
+	}
+
+	public Date getProduceDate() {
+		return produceDate;
+	}
+
+	public void setProduceDate(Date produceDate) {
+		this.produceDate = produceDate;
+	}
+
+	public Double getReserve() {
+		return reserve;
+	}
+
+	public void setReserve(Double reserve) {
+		this.reserve = reserve;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Double getMinPackQty() {
+		return minPackQty;
+	}
+
+	public void setMinPackQty(Double minPackQty) {
+		this.minPackQty = minPackQty;
+	}
+
+	public Integer getOriginal() {
+		return original;
+	}
+
+	public void setOriginal(Integer original) {
+		this.original = original;
+	}
+
+	public Date getUpdateDate() {
+		return updateDate;
+	}
+
+	public void setUpdateDate(Date updateDate) {
+		this.updateDate = updateDate;
+	}
+
+	public Integer getAvailableDays() {
+		return availableDays;
+	}
+
+	public void setAvailableDays(Integer availableDays) {
+		this.availableDays = availableDays;
+	}
+
+	public String getOperateType() {
+		return operateType;
+	}
+
+	public void setOperateType(String operateType) {
+		this.operateType = operateType;
+	}
+
+	@Override
+	public String toString() {
+		return "GoodsHistory [id=" + id + ", uuid=" + uuid + ", code=" + code
+				+ ", img=" + img + ", kindNameCn=" + kindNameCn
+				+ ", brandNameCn=" + brandNameCn + ", batchCode=" + batchCode
+				+ ", original=" + original + ", enUU=" + enUU
+				+ ", publisherUU=" + publisherUU + ", publisherName="
+				+ publisherName + ", publishPhone=" + publishPhone
+				+ ", createdDate=" + createdDate + ", updateDate=" + updateDate
+				+ ", availableDays=" + availableDays + ", status=" + status
+				+ ", qtyPrice=" + qtyPrice + ", deliveryTime=" + deliveryTime
+				+ ", produceDate=" + produceDate + ", reserve=" + reserve
+				+ ", remark=" + remark + ", minBuyQty=" + minBuyQty
+				+ ", minPackQty=" + minPackQty + ", packaging=" + packaging
+				+ ", operateType=" + operateType + ", operateDate="
+				+ operateDate + ", currencyName=" + currencyName + ", tax="
+				+ tax + ", returnInWeek=" + returnInWeek + ", message="
+				+ message + ", enterpriseName=" + enterpriseName + "]";
+	}
+
+	public String getPackaging() {
+		return packaging;
+	}
+
+	public void setPackaging(String packaging) {
+		this.packaging = packaging;
+	}
+
+	public Date getOperateDate() {
+		return operateDate;
+	}
+
+	public void setOperateDate(Date operateDate) {
+		this.operateDate = operateDate;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public String getEnterpriseName() {
+		return enterpriseName;
+	}
+
+	public void setEnterpriseName(String enterpriseName) {
+		this.enterpriseName = enterpriseName;
+	}
+
+	public Long getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(Long sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getCurrencyName() {
+		return currencyName;
+	}
+
+	public void setCurrencyName(String currencyName) {
+		this.currencyName = currencyName;
+	}
+
+	public Short getTax() {
+		return tax;
+	}
+
+	public void setTax(Short tax) {
+		this.tax = tax;
+	}
+
+	public Short getReturnInWeek() {
+		return returnInWeek;
+	}
+
+	public void setReturnInWeek(Short returnInWeek) {
+		this.returnInWeek = returnInWeek;
+	}
+
+	public CommodityHistory() {
+	}
+
+	public CommodityHistory(Commodity goods) {
+		this.uuid = goods.getUuid();
+		this.produceDate = goods.getProduceDate();
+		this.reserve = goods.getReserve();
+		this.status = goods.getStatus();
+		this.enUU = goods.getEnUU();
+		this.code = goods.getCode();
+		this.brandNameCn = goods.getBrandNameCn();
+		this.kindNameCn = goods.getKindNameCn();
+		this.img = goods.getImg();
+		this.batchCode = goods.getBatchCode();
+		this.createdDate = goods.getCreatedDate();
+		this.availableDays = goods.getAvailableDays();
+		this.updateDate = goods.getUpdateDate();
+		this.minBuyQty = goods.getMinBuyQty();
+		this.minPackQty = goods.getMinPackQty();
+		this.publisherUU = goods.getPublisherUU();
+		this.publisherName = goods.getPublisherName();
+		this.publishPhone = goods.getPublishPhone();
+		this.qtyPrice = goods.getQtyPrice();
+		this.currencyName = goods.getCurrencyName();
+		this.returnInWeek = goods.getReturnInWeek();
+		this.remark = goods.getRemark();
+		this.original = goods.getOriginal();
+		this.sourceId = goods.getSourceId();
+		if (goods.getCurrencyName().contains("RMB")) {
+			this.rmbTaxRate = goods.getRmbTaxRate();
+			this.deliveryDemTime = goods.getDeliveryDemTime();
+			this.b2cDeliveryDemMaxTime = goods.getB2cDeliveryDemMaxTime();
+			this.b2cDeliveryDemMinTime = goods.getB2cDeliveryDemMinTime();
+		}
+		if (goods.getCurrencyName().contains("USD")) {
+			this.usdTaxRate = goods.getUsdTaxRate();
+			this.deliveryHKTime = goods.getDeliveryHKTime();
+			this.b2cDeliveryHKMaxTime = goods.getB2cDeliveryHKMaxTime();
+			this.b2cDeliveryHKMinTime = goods.getB2cDeliveryHKMinTime();
+		}
+		this.shipArea = goods.getShipArea();
+	}
+
+}

+ 322 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/CommodityPriceInfo.java

@@ -0,0 +1,322 @@
+package com.uas.cloud.mall.commodity.domain;
+
+import javax.persistence.*;
+import java.math.BigDecimal;
+
+/**
+ * 卖家商品价格信息表
+ * 
+ * @date 201683115:01:17
+ * @author huxz
+ *
+ */
+@Entity
+@Table(name = "trade$goods_price")
+public class CommodityPriceInfo {
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "trade$goods_price_gen")
+	@SequenceGenerator(name = "trade$goods_price_gen", sequenceName = "trade$goods_price_seq", allocationSize = 1)
+	@Column(name = "gp_id")
+	private Long id;
+
+	/**************************************************************************
+	 * 唯一确定价格信息字段组合{enUU, uuid[code], original, currencyName, tax}
+	 **************************************************************************/
+
+	/**
+	 * 卖家企业uu
+	 */
+	@Column(name = "gp_enuu")
+	private Long enUU;
+
+	/**
+	 * 对应的器件uuid
+	 */
+	@Column(name = "cmp_uuid")
+	private String uuid;
+
+	/**
+	 * 器件原厂型号
+	 */
+	@Column(name = "gp_code")
+	private String code;
+
+	/**
+	 * 是否原厂原装,1311 现货,1312 呆滞库存,(暂时不用)1313 废料
+	 */
+	@Column(name = "gp_original")
+	private Integer original = 1311;
+
+	/**
+	 * 币种名称
+	 */
+	@Column(name = "gp_currency_name")
+	private String currencyName;
+
+	/**
+	 * 税率
+	 */
+	@Column(name = "gp_tax")
+	private Short tax;
+
+	/**************************************************************************
+	 * 器件相关信息
+	 **************************************************************************/
+
+	/**
+	 * 商品图片
+	 */
+	@Column(name = "cm_img")
+	private String img;
+
+	/**
+	 * 类目的名称
+	 */
+	@Column(name = "ki_name")
+	private String kindNameCn;
+
+	/**
+	 * 品牌中文名称
+	 */
+	@Column(name = "br_name")
+	private String brandNameCn;
+
+	/**
+	 * 最小包装量
+	 */
+	@Column(name = "go_minpackqty")
+	private Double minPackQty;
+
+	/**
+	 * 最小起订量
+	 */
+	@Column(name = "go_minbuyqty")
+	private Double minBuyQty;
+
+	/**************************************************************************
+	 * 商品价格基础信息 @version 0.2
+	 **************************************************************************/
+
+	/**
+	 * 含税价格
+	 */
+	@Column(name = "gp_price")
+	private Double price;
+
+	/**
+	 * 旧含税价格信息
+	 */
+	@Transient
+	private Double oldPrice;
+
+	/**
+	 * 未税价格
+	 */
+	@Column(name = "gp_taxprice")
+	private Double taxPrice;
+
+	/**
+	 * 状态 AVAILABLE(601, "有效地"), UNAVAILABLE(602, "无效的"),
+	 */
+	@Column(name = "go_status")
+	private Integer status;
+
+	/**
+	 * 价格调整幅度
+	 */
+	@Transient
+	private Float range;
+
+	/**************************************************************************
+	 * Constructor Method
+	 **************************************************************************/
+
+	public CommodityPriceInfo() {
+	}
+
+	public CommodityPriceInfo(String uuid, Long enUU, String code, String currencyName, Integer original, Short tax) {
+		this.uuid = uuid;
+		this.enUU = enUU;
+		this.code = code;
+		this.currencyName = currencyName;
+		this.original = original;
+		this.tax = tax;
+	}
+
+	/**************************************************************************
+	 * Getter And Setter
+	 **************************************************************************/
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getUuid() {
+		return uuid;
+	}
+
+	public void setUuid(String uuid) {
+		this.uuid = uuid;
+	}
+
+	public Long getEnUU() {
+		return enUU;
+	}
+
+	public void setEnUU(Long enUU) {
+		this.enUU = enUU;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getCurrencyName() {
+		return currencyName;
+	}
+
+	public void setCurrencyName(String currencyName) {
+		this.currencyName = currencyName;
+	}
+
+	public void setOldPrice(Double oldPrice) {
+		this.oldPrice = oldPrice;
+	}
+
+	public Integer getOriginal() {
+		return original;
+	}
+
+	public void setOriginal(Integer original) {
+		this.original = original;
+	}
+
+	public Short getTax() {
+		return tax;
+	}
+
+	public void setTax(Short tax) {
+		this.tax = tax;
+	}
+
+	public Double getPrice() {
+		return price;
+	}
+
+	public void setPrice(Double price) {
+		// 保存商品旧价格
+		this.oldPrice = this.price;
+		// 更新商品价格
+		this.price = price;
+		if (this.tax != null) {
+			BigDecimal priceDec = new BigDecimal(price);
+			BigDecimal taxRate = new BigDecimal(this.tax.doubleValue() / 100 + 1);
+			this.taxPrice = priceDec.divide(taxRate, 6, BigDecimal.ROUND_HALF_UP).doubleValue();
+		}
+	}
+
+	public Double getOldPrice() {
+		return oldPrice;
+	}
+
+	public Double getTaxPrice() {
+		return taxPrice;
+	}
+
+	public void setTaxPrice(Double taxPrice) {
+		this.taxPrice = taxPrice;
+	}
+
+	public String getImg() {
+		return img;
+	}
+
+	public void setImg(String img) {
+		this.img = img;
+	}
+
+	public String getKindNameCn() {
+		return kindNameCn;
+	}
+
+	public void setKindNameCn(String kindNameCn) {
+		this.kindNameCn = kindNameCn;
+	}
+
+	public String getBrandNameCn() {
+		return brandNameCn;
+	}
+
+	public void setBrandNameCn(String brandNameCn) {
+		this.brandNameCn = brandNameCn;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Double getMinBuyQty() {
+		return minBuyQty;
+	}
+
+	public void setMinBuyQty(Double minBuyQty) {
+		this.minBuyQty = minBuyQty;
+	}
+
+	public Double getMinPackQty() {
+		return minPackQty;
+	}
+
+	public void setMinPackQty(Double minPackQty) {
+		this.minPackQty = minPackQty;
+	}
+
+	public Float getRange() {
+		return range;
+	}
+
+	public void setRange(Float range) {
+		this.range = range;
+	}
+
+	/**************************************************************************
+	 * Override Method
+	 **************************************************************************/
+
+	@Override
+	public String toString() {
+		return "GoodsPriceInfo{" +
+				"id=" + id +
+				", enUU=" + enUU +
+				", uuid='" + uuid + '\'' +
+				", code='" + code + '\'' +
+				", original=" + original +
+				", currencyName='" + currencyName + '\'' +
+				", tax=" + tax +
+				", img='" + img + '\'' +
+				", kindNameCn='" + kindNameCn + '\'' +
+				", brandNameCn='" + brandNameCn + '\'' +
+				", minPackQty=" + minPackQty +
+				", minBuyQty=" + minBuyQty +
+				", price=" + price +
+				", oldPrice=" + oldPrice +
+				", taxPrice=" + taxPrice +
+				", status=" + status +
+				", range=" + range +
+				'}';
+	}
+
+}

+ 135 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/CommodityQtyPrice.java

@@ -0,0 +1,135 @@
+package com.uas.cloud.mall.commodity.domain;
+
+/**
+ * 商品分段数量价格
+ * 
+ * @author suntg
+ * @since 2016128日下午8:01:23 新建
+ */
+public class CommodityQtyPrice {
+
+	/**
+	 * 起始数量
+	 */
+	private Double start;
+
+	/**
+	 * 截止数量
+	 */
+	private Double end;
+
+	/**
+	 * 人民币含税价格(默认含税17%),单位元
+	 */
+	private Double rMBPrice;
+
+	/**
+	 * 人民币未税价格,单位元
+	 */
+	private Double rMBNTPrice;
+
+	/**
+	 * 美元价含税格(默认含税0%),单位美元
+	 */
+	private Double uSDPrice;
+
+	/**
+	 * 美元未税价格,单位美元
+	 */
+	private Double uSDNTPrice;
+
+	// price和taxprice作兼容使用
+	/**
+	 * 未税价格,单位为元
+	 */
+	private Double price;
+
+	/**
+	 * 含税价格,单位为元
+	 */
+	private Double taxPrice;
+
+	public CommodityQtyPrice() {
+	}
+
+	public Double getStart() {
+		return start;
+	}
+
+	public void setStart(Double start) {
+		this.start = start;
+	}
+
+	public Double getEnd() {
+		return end;
+	}
+
+	public void setEnd(Double end) {
+		this.end = end;
+	}
+
+	public Double getrMBPrice() {
+		return rMBPrice;
+	}
+
+	public void setrMBPrice(Double rMBPrice) {
+		this.rMBPrice = rMBPrice;
+	}
+
+	public Double getrMBNTPrice() {
+		return rMBNTPrice;
+	}
+
+	public void setrMBNTPrice(Double rMBNTPrice) {
+		this.rMBNTPrice = rMBNTPrice;
+	}
+
+	public Double getuSDPrice() {
+		return uSDPrice;
+	}
+
+	public void setuSDPrice(Double uSDPrice) {
+		this.uSDPrice = uSDPrice;
+	}
+
+	public Double getuSDNTPrice() {
+		return uSDNTPrice;
+	}
+
+	public void setuSDNTPrice(Double uSDNTPrice) {
+		this.uSDNTPrice = uSDNTPrice;
+	}
+
+	public Double getPrice() {
+		return price;
+	}
+
+	public void setPrice(Double price) {
+		this.price = price;
+	}
+
+	public Double getTaxPrice() {
+		return taxPrice;
+	}
+
+	public void setTaxPrice(Double taxPrice) {
+		this.taxPrice = taxPrice;
+	}
+
+	public Double getPrice(String currencyName) {
+		if("USD".equals(currencyName)) {
+			return uSDNTPrice;
+		}else {
+			return rMBNTPrice;
+		}
+	}
+
+	public Double getTaxPrice(String currencyName) {
+		if("USD".equalsIgnoreCase(currencyName)) {//返回
+			return uSDPrice;
+		}else {
+			return rMBPrice;
+		}
+	}
+
+}

+ 409 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/CommoditySimple.java

@@ -0,0 +1,409 @@
+package com.uas.cloud.mall.commodity.domain;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.uas.cloud.mall.commodity.util.JacksonUtils;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.*;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 上架商品的简单信息
+ * 
+ * @author ChenHao
+ *
+ */
+@Entity
+@Table(name = "trade$goods")
+public class CommoditySimple {
+
+	@Id
+	@Column(name = "go_id")
+	private Long id;
+
+	/**
+	 * 批次号
+	 */
+	@Column(name = "go_batchcode", unique = true)
+	private String batchCode;
+
+	/**
+	 * 库存, 现货 13111312 呆滞库存 ,(暂时不用) 1313 废料
+	 */
+	@Column(name = "go_original", unique = true)
+	private Integer original = 1311;
+
+	/**
+	 * 未税分段报价(JSON串) eg:[{"start":0,"end":1000,"price":2.3},...]
+	 */
+	@Column(name = "go_qtyprice")
+	private String qtyPrice;
+	/**
+	 * 大陆交期最短
+	 */
+	@Column(name = "go_deliverydemintime")
+	private Short b2cDeliveryDemMinTime;
+
+	/**
+	 * 大陆交期最长
+	 */
+	@Column(name = "go_deliverydemaxtime")
+	private Short b2cDeliveryDemMaxTime;
+
+	/**
+	 * 香港交期[供应商送平台的时间]
+	 */
+	@Column(name = "go_deliveryhktime")
+	private Short deliveryHKTime;
+
+	/**
+	 * 香港交期最短
+	 */
+	@Column(name = "go_deliveryhkmintime")
+	private Short b2cDeliveryHKMinTime;
+
+	/**
+	 * 香港交期最长
+	 */
+	@Column(name = "go_deliveryhkmaxtime")
+	private Short b2cDeliveryHKMaxTime;
+	
+	/**
+	 * 大陆交期[供应商送平台的时间]
+	 */
+	@Column(name = "go_deliverydemtime")
+	private Short deliveryDemTime;
+	
+	/**
+	 * 产品生产日期
+	 */
+	@Column(name = "go_producedate")
+	private Date produceDate;
+
+	/**
+	 * 创建日期
+	 */
+	@Column(name = "go_createddate")
+	private Date createdDate;
+
+	/**
+	 * 库存
+	 */
+	@Column(name = "go_reserve")
+	private Double reserve;
+
+	/**
+	 * 最小包装量
+	 */
+	@Column(name = "go_minpackqty")
+	private Double minPackQty;
+
+	/**
+	 * 最小起订量
+	 */
+	@Column(name = "go_minbuyqty")
+	private Double minBuyQty;
+
+	/**
+	 * 发布备注
+	 */
+	@Column(name = "go_remark")
+	private String remark;
+
+	/**
+	 * 器件uuid
+	 */
+	@Column(name = "cmp_uuid")
+	private String uuid;
+
+	/**
+	 * 状态 AVAILABLE(601, "有效地"), UNAVAILABLE(602, "无效的"),
+	 */
+	@Column(name = "go_status")
+	private Integer status;
+
+	/**
+	 * 供应商上架的样品数量(总数)
+	 */
+	@Column(name = "go_sampleqty")
+	private Double sampleQty = (double) 0;
+
+	/**
+	 * 已申请的样品数量
+	 */
+	@Column(name = "go_sampleappliedqty")
+	private Double sampleAppliedQty = (double) 0;
+
+	/**
+	 * 币种名称
+	 */
+	@Column(name = "cr_name")
+	private String currencyName;
+
+	/**
+	 * 是否支持7天无理由退货,1:支持,0:不支持
+	 */
+	@Column(name = "go_returninweek")
+	private Short returnInWeek;
+
+	/**
+	 * 未税分段报价(List)
+	 */
+	@Transient
+	private List<CommodityQtyPrice> prices;
+
+	/**
+	 * 当前登录企业是否对此批次已送样
+	 */
+	@Transient
+	private boolean hasSample;
+
+	public String getUuid() {
+		return uuid;
+	}
+
+	public void setUuid(String uuid) {
+		this.uuid = uuid;
+	}
+
+	public String getBatchCode() {
+		return batchCode;
+	}
+
+	public void setBatchCode(String batchCode) {
+		this.batchCode = batchCode;
+	}
+
+	public Short getDeliveryDemTime() {
+		return deliveryDemTime;
+	}
+
+	public void setDeliveryDemTime(Short deliveryDemTime) {
+		this.deliveryDemTime = deliveryDemTime;
+	}
+
+	@JSONField(serialize = false)
+	@JsonIgnore
+	public String getQtyPrice() {
+		return qtyPrice;
+	}
+
+	public void setQtyPrice(String qtyPrice) {
+		this.qtyPrice = qtyPrice;
+	}
+
+	public Date getProduceDate() {
+		return produceDate;
+	}
+
+	public void setProduceDate(Date produceDate) {
+		this.produceDate = produceDate;
+	}
+
+	public Date getCreatedDate() {
+		return createdDate;
+	}
+
+	public void setCreatedDate(Date createdDate) {
+		this.createdDate = createdDate;
+	}
+
+	public Double getReserve() {
+		return reserve;
+	}
+
+	public void setReserve(Double reserve) {
+		this.reserve = reserve;
+	}
+
+	public Double getMinPackQty() {
+		return minPackQty;
+	}
+
+	public void setMinPackQty(Double minPackQty) {
+		this.minPackQty = minPackQty;
+	}
+
+	public Double getMinBuyQty() {
+		return minBuyQty;
+	}
+
+	public void setMinBuyQty(Double minBuyQty) {
+		this.minBuyQty = minBuyQty;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getCurrencyName() {
+		return currencyName;
+	}
+
+	public void setCurrencyName(String currencyName) {
+		this.currencyName = currencyName;
+	}
+
+	public Short getReturnInWeek() {
+		return returnInWeek;
+	}
+
+	public void setReturnInWeek(Short returnInWeek) {
+		this.returnInWeek = returnInWeek;
+	}
+
+	public List<CommodityQtyPrice> getPrices() {
+		if (StringUtils.hasText(this.qtyPrice)) {
+			this.prices = JacksonUtils.fromJsonArray(this.qtyPrice, CommodityQtyPrice.class);
+		}
+		return prices;
+	}
+
+	public void setPrices(List<CommodityQtyPrice> prices) {
+		this.prices = prices;
+	}
+	
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Short getB2cDeliveryDemMinTime() {
+		return b2cDeliveryDemMinTime;
+	}
+
+	public void setB2cDeliveryDemMinTime(Short b2cDeliveryDemMinTime) {
+		this.b2cDeliveryDemMinTime = b2cDeliveryDemMinTime;
+	}
+
+	public Short getB2cDeliveryDemMaxTime() {
+		return b2cDeliveryDemMaxTime;
+	}
+
+	public void setB2cDeliveryDemMaxTime(Short b2cDeliveryDemMaxTime) {
+		this.b2cDeliveryDemMaxTime = b2cDeliveryDemMaxTime;
+	}
+
+	public Short getDeliveryHKTime() {
+		return deliveryHKTime;
+	}
+
+	public void setDeliveryHKTime(Short deliveryHKTime) {
+		this.deliveryHKTime = deliveryHKTime;
+	}
+
+	public Short getB2cDeliveryHKMinTime() {
+		return b2cDeliveryHKMinTime;
+	}
+
+	public void setB2cDeliveryHKMinTime(Short b2cDeliveryHKMinTime) {
+		this.b2cDeliveryHKMinTime = b2cDeliveryHKMinTime;
+	}
+
+	public Short getB2cDeliveryHKMaxTime() {
+		return b2cDeliveryHKMaxTime;
+	}
+
+	public void setB2cDeliveryHKMaxTime(Short b2cDeliveryHKMaxTime) {
+		this.b2cDeliveryHKMaxTime = b2cDeliveryHKMaxTime;
+	}
+
+	public Double getSampleQty() {
+		return sampleQty;
+	}
+
+	public void setSampleQty(Double sampleQty) {
+		this.sampleQty = sampleQty;
+	}
+
+	public Double getSampleAppliedQty() {
+		return sampleAppliedQty;
+	}
+
+	public void setSampleAppliedQty(Double sampleAppliedQty) {
+		this.sampleAppliedQty = sampleAppliedQty;
+	}
+
+	public boolean isHasSample() {
+		return hasSample;
+	}
+
+	public void setHasSample(boolean hasSample) {
+		this.hasSample = hasSample;
+	}
+
+	public Integer getOriginal() {
+		return original;
+	}
+
+	public void setOriginal(Integer original) {
+		this.original = original;
+	}
+
+	public CommoditySimple() {
+		
+	}
+	
+	public CommoditySimple(Commodity goods) {
+		this.batchCode = goods.getBatchCode();
+		this.original = goods.getOriginal();
+		this.qtyPrice = goods.getQtyPrice();
+		this.b2cDeliveryDemMaxTime = goods.getB2cDeliveryDemMaxTime();
+		this.b2cDeliveryDemMinTime = goods.getB2cDeliveryDemMinTime();
+		this.b2cDeliveryHKMaxTime = goods.getB2cDeliveryHKMaxTime();
+		this.b2cDeliveryHKMinTime = goods.getB2cDeliveryHKMinTime();
+		this.produceDate = goods.getProduceDate();
+		this.createdDate = goods.getCreatedDate();
+		this.reserve = goods.getReserve();
+		this.minPackQty = goods.getMinPackQty();
+		this.minBuyQty = goods.getMinBuyQty();
+		this.uuid = goods.getUuid();
+		this.currencyName = goods.getCurrencyName();
+		this.prices = goods.getPrices();
+	}
+	
+	public CommoditySimple(CommodityHistory goods) {
+		this.batchCode = goods.getBatchCode();
+		this.original = goods.getOriginal();
+		this.qtyPrice = goods.getQtyPrice();
+		this.b2cDeliveryDemMaxTime = goods.getB2cDeliveryDemMaxTime();
+		this.b2cDeliveryDemMinTime = goods.getB2cDeliveryDemMinTime();
+		this.b2cDeliveryHKMaxTime = goods.getB2cDeliveryHKMaxTime();
+		this.b2cDeliveryHKMinTime = goods.getB2cDeliveryHKMinTime();
+		this.produceDate = goods.getProduceDate();
+		this.createdDate = goods.getCreatedDate();
+		this.reserve = goods.getReserve();
+		this.minPackQty = goods.getMinPackQty();
+		this.minBuyQty = goods.getMinBuyQty();
+		this.uuid = goods.getUuid();
+		this.currencyName = goods.getCurrencyName();
+		this.prices = JacksonUtils.fromJsonArray(this.qtyPrice, CommodityQtyPrice.class);
+	}
+	/*
+	 * public GoodsSimpleUas converUas(){ GoodsSimpleUas uas = new
+	 * GoodsSimpleUas(); uas.setBatchCode(this.batchCode);
+	 * uas.setCreatedDate(this.createdDate);
+	 * uas.setDeliveryTime(this.deliveryTime); uas.setMinBuyQty(this.minBuyQty);
+	 * uas.setMinPackQty(this.minPackQty); uas.setOriginal(this.original);
+	 * uas.setQtyPrice(this.qtyPrice); uas.setProduceDate(this.produceDate);
+	 * uas.setRemark(this.remark); uas.setReserve(this.reserve);
+	 * uas.setSampleQty(this.sampleQty); uas.setUuid(this.uuid); return uas; }
+	 */
+}

+ 77 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/CreateNumber.java

@@ -0,0 +1,77 @@
+package com.uas.cloud.mall.commodity.domain;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+/**
+ * 生成各种单号后面的数字
+ * 
+ * @author ChenHao
+ *
+ */
+@Entity
+@Table(name = "product$creat_number")
+public class CreateNumber {
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "product$goods_gen")
+	@SequenceGenerator(name = "product$goods_gen", sequenceName = "product$goods_seq", allocationSize = 1)
+	@Column(name = "cn_id")
+	private Long id;
+
+	/**
+	 * 表名称
+	 */
+	@Column(name = "cn_tbname", unique = true)
+	private String tbname;
+	
+	/**
+	 * 日期
+	 */
+	@Column(name = "cn_time")
+	private String time;
+	
+	/**
+	 * 数字
+	 */
+	@Column(name = "cn_number")
+	private Integer number;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getTbname() {
+		return tbname;
+	}
+
+	public void setTbname(String tbname) {
+		this.tbname = tbname;
+	}
+
+	public String getTime() {
+		return time;
+	}
+
+	public void setTime(String time) {
+		this.time = time;
+	}
+
+	public Integer getNumber() {
+		return number;
+	}
+
+	public void setNumber(Integer number) {
+		this.number = number;
+	}
+
+}

+ 15 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/FileUpload.java

@@ -0,0 +1,15 @@
+package com.uas.cloud.mall.commodity.domain;
+
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+
+public class FileUpload {
+	private CommonsMultipartFile file;
+
+	public CommonsMultipartFile getFile() {
+		return file;
+	}
+
+	public void setFile(CommonsMultipartFile file) {
+		this.file = file;
+	}
+}

+ 262 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/PriceChangeLog.java

@@ -0,0 +1,262 @@
+package com.uas.cloud.mall.commodity.domain;
+
+import com.uas.cloud.commons.support.SystemSession;
+
+import javax.persistence.*;
+import java.util.Date;
+
+/**
+ * 卖家商品价格变更日志
+ * 
+ * @date 20169115:57:35
+ * @author huxz
+ *
+ */
+@Entity
+@Table(name = "trade$price_changes_log")
+public class PriceChangeLog{
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "log$price_changes_gen")
+	@SequenceGenerator(name = "log$price_changes_gen", sequenceName = "log$price_changes_seq", allocationSize = 1)
+	@Column(name = "log_id")
+	private Long id;
+	
+	@Column(name = "log_enuu")
+	private Long enUU;
+	
+	@Column(name = "log_useruu")
+	private Long userUU;
+	
+	/**
+	 * 操作者的IP
+	 */
+	@Column(name = "log_ip")
+	private String ip;
+	
+	/**
+	 * 操作者的设备信息
+	 */
+	@Column(name = "log_agent")
+	private String agent;
+	
+	/**
+	 * 操作时间
+	 */
+	@Column(name = "log_time")
+	private Date time;
+	
+	/**
+	 * 价格变更的商品型号
+	 */
+	@Column(name = "log_code")
+	private String code;
+	
+	/**
+	 * 变更商品的币别
+	 */
+	@Column(name = "log_currency_name")
+	private String currencyName;
+	
+	/**
+	 * 商品库存类型
+	 */
+	@Column(name = "log_original")
+	private Integer original;
+	
+	/**
+	 * 商品税率
+	 */
+	@Column(name = "log_tax")
+	private Short tax;
+	/**
+	 * 操作之前的商品价格信息
+	 */
+	@Column(name = "log_oldPrice")
+	private Double oldPrice;
+	
+	/**
+	 * 新的价格信息
+	 */
+	@Column(name = "log_price")
+	private Double price;
+	
+	/**
+	 * 价格调整幅度
+	 */
+	@Column(name = "log_range")
+	private Float range;
+	
+	/**
+	 * 备注
+	 */
+	@Column(name = "log_comment")
+	private String comment;
+	
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getEnUU() {
+		return enUU;
+	}
+
+	public void setEnUU(Long enUU) {
+		this.enUU = enUU;
+	}
+
+	public Long getUserUU() {
+		return userUU;
+	}
+
+	public void setUserUU(Long userUU) {
+		this.userUU = userUU;
+	}
+
+	public String getIp() {
+		return ip;
+	}
+
+	public void setIp(String ip) {
+		this.ip = ip;
+	}
+
+	public String getAgent() {
+		return agent;
+	}
+
+	public void setAgent(String agent) {
+		this.agent = agent;
+	}
+
+	public Long getTime() {
+		return time.getTime();
+	}
+
+	public void setTime(Long time) {
+		this.time = new Date(time);
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getCurrencyName() {
+		return currencyName;
+	}
+
+	public void setCurrencyName(String currencyName) {
+		this.currencyName = currencyName;
+	}
+
+	public Integer getOriginal() {
+		return original;
+	}
+
+	public void setOriginal(Integer original) {
+		this.original = original;
+	}
+
+	public Short getTax() {
+		return tax;
+	}
+
+	public void setTax(Short tax) {
+		this.tax = tax;
+	}
+
+	public Double getOldPrice() {
+		return oldPrice;
+	}
+
+	public void setOldPrice(Double oldPrice) {
+		this.oldPrice = oldPrice;
+	}
+
+	public Double getPrice() {
+		return price;
+	}
+
+	public void setPrice(Double price) {
+		this.price = price;
+	}
+	
+	public Float getRange() {
+		return range;
+	}
+	
+	public void setRange(Float range) {
+		this.range = range;
+	}
+
+	public String getComment() {
+		return comment;
+	}
+
+	public void setComment(String comment) {
+		this.comment = comment;
+	}
+	
+	public PriceChangeLog() {
+	}
+
+	public PriceChangeLog(String agent, String code, String currencyName, Integer original, Short tax, Double oldPrice,
+			Double price, String comment) {
+		this.enUU = SystemSession.getUser().getEnterprise().getUu();
+		this.userUU = SystemSession.getUser().getUserUU();
+		this.ip = SystemSession.getUser().getIp();
+		this.agent = agent;
+		this.time = new Date();
+		this.code = code;
+		this.currencyName = currencyName;
+		this.original = original;
+		this.tax = tax;
+		this.oldPrice = oldPrice;
+		this.price = price;
+		this.comment = comment;
+	}
+
+	public PriceChangeLog(String code, String currencyName, Integer original, Short tax, Double oldPrice, Double price,
+			String comment) {
+		this.enUU = SystemSession.getUser().getEnterprise().getUu();
+		this.userUU = SystemSession.getUser().getUserUU();
+		this.ip = SystemSession.getUser().getIp();
+		this.agent = "NORMAL";
+		this.time = new Date();
+		this.code = code;
+		this.currencyName = currencyName;
+		this.original = original;
+		this.tax = tax;
+		this.oldPrice = oldPrice;
+		this.price = price;
+		this.comment = comment;
+	}
+	
+	
+
+	public PriceChangeLog(String agent, String code, String currencyName, Integer original, Short tax, Double oldPrice,
+			Double price, Float range, String comment) {
+		this.enUU = SystemSession.getUser().getEnterprise().getUu();
+		this.userUU = SystemSession.getUser().getUserUU();
+		this.ip = SystemSession.getUser().getIp();
+		this.agent = agent;
+		this.time = new Date();
+		this.code = code;
+		this.currencyName = currencyName;
+		this.original = original;
+		this.tax = tax;
+		this.oldPrice = oldPrice;
+		this.price = price;
+		this.range = range;
+		this.comment = comment;
+	}
+
+}

+ 917 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/ReleaseProductByBatch.java

@@ -0,0 +1,917 @@
+package com.uas.cloud.mall.commodity.domain;
+
+import com.uas.cloud.commons.exception.IllegalOperatorException;
+import com.uas.cloud.commons.util.FastjsonUtils;
+import com.uas.cloud.mall.commodity.statusAndType.ReleaseStatus;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * 批量上传商品建立临时表存储相关信息
+ * 
+ * @author hejq
+ * @time 创建时间:2016924
+ */
+@Entity
+@Table(name = "trade$releasebybatch")
+public class ReleaseProductByBatch implements Serializable {
+
+	/**
+	 * 序列
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * id
+	 */
+	@Id
+	@Column(name = "rel_id")
+	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "trade$releasebybatch_gen")
+	@SequenceGenerator(name = "trade$releasebybatch_gen", sequenceName = "trade$releasebybatch_seq", allocationSize = 1)
+	private Long id;
+	
+	//当前的申请的这一批的单号
+	@Column(name = "rel_batchid")
+	private String relbatchid;
+
+	/**
+	 * 产品中文品牌
+	 */
+	@Column(name = "rel_brandcn")
+	private String brandNameCn;
+
+	/**
+	 * 产品英文品牌
+	 */
+	@Column(name = "rel_branden")
+	private String brandNameEn;
+
+	/**
+	 * 品牌id
+	 */
+	@Column(name = "rel_brandid")
+	private Long brandId;
+
+	/**
+	 * 产品型号
+	 */
+	@Column(name = "rel_code")
+	private String code;
+
+	/**
+	 * 产品UUId
+	 */
+	@Column(name = "rel_uuid")
+	private String componentUuId;
+
+	/**
+	 * 单位
+	 */
+	@Column(name = "rel_unit")
+	private String unit;
+
+	/**
+	 * 库存类型 :1311 现货,1312 呆滞库存(暂时不用)1313 废料
+	 */
+	@Column(name = "rel_original")
+	private Integer original = 1311;
+
+	/**
+	 * 发布库存量
+	 */
+	@Column(name = "rel_publishreserve")
+	private Double reserve;
+
+	/**
+	 * 最小起定量
+	 */
+	@Column(name = "rel_minbuyqty")
+	private Double minBuyQty;
+
+	/**
+	 * 分段报价(JSON串) eg:[{"start":0,"end":1000,"price":2.3,"taxPrice":2.5},...]
+	 */
+	@Column(name = "rel_qtyprice")
+	private String qtyPrice;
+
+	/**
+	 * 分段报价(List)
+	 */
+	@Transient
+	private List<CommodityQtyPrice> prices;
+
+	/**
+	 * 产品生产日期
+	 */
+	@Column(name = "rel_productdate")
+	private Date productDate;
+
+	/**
+	 * 上传时间
+	 */
+	@Column(name = "rel_createdate")
+	private Date createDate;
+
+	/**
+	 * 产品最小包装量
+	 */
+	@Column(name = "rel_minpackage")
+	private Double minPackage;
+
+	/**
+	 * 大陆交货周期(天)
+	 */
+	@Column(name = "rel_deliverydemtime")
+	private Short deliveryDemTime;
+
+	/**
+	 * 大陆交货周期(最短)
+	 */
+	@Column(name = "rel_mindeliverydemtime")
+	private Short mindeliveryDemTime;
+
+	/**
+	 * 大陆交货周期(最长)
+	 */
+	@Column(name = "rel_maxdeliverydemtime")
+	private Short maxdeliveryDemTime;
+
+	/**
+	 * 香港交期[供应商送平台的时间]
+	 */
+	@Column(name = "rel_deliveryhktime")
+	private Short deliveryHKTime;
+
+	/**
+	 * 香港交货周期(最短)
+	 */
+	@Column(name = "rel_mindeliveryhktime")
+	private Short mindeliveryHKTime;
+
+	/**
+	 * 香港交货周期(最长)
+	 */
+	@Column(name = "rel_maxdeliveryhktime")
+	private Short maxdeliveryHKTime;
+
+	/**
+	 * 备注
+	 */
+	@Column(name = "rel_remark")
+	private String remark;
+
+	/**
+	 * 发布人姓名
+	 */
+	@Column(name = "rel_publishername")
+	private String publisherName;
+
+	/**
+	 * 发布人UU
+	 */
+	@Column(name = "rel_publisheruu")
+	private Long publisherUu;
+
+	/**
+	 * 联系电话
+	 */
+	@Column(name = "rel_publishertel")
+	private String publisherTel;
+
+	/**
+	 * 币别
+	 */
+	@Column(name = "rel_currency")
+	private String currency;
+	
+	/**
+	 * 样品数
+	 */
+	@Column(name = "rel_sampleqty")
+	private Double sampleqty;
+
+	/**
+	 * 人民币税率
+	 */
+	@Column(name = "rel_rmb_tax_rate")
+	private Double rmbTaxRate;
+
+	/**
+	 * 美元税率
+	 */
+	@Column(name = "rel_usd_tax_rate")
+	private Double usdTaxRate;
+
+	/**
+	 * 是否支持七天无理由退货 1:支持 0:不支持
+	 */
+	@Column(name = "rel_returninweek")
+	private Short returnInWeek;
+
+	/**
+	 * 发布状态编号
+	 * 
+	 * @return
+	 */
+	@Column(name = "rel_releasecode")
+	private Integer releaseCode;
+
+	/**
+	 * 发布状态
+	 * 
+	 * @return
+	 */
+	@Column(name = "rel_releasestatus")
+	private String releaseStatus;
+
+	/**
+	 * 发货地区
+	 */
+	@Column(name = "rel_shiparea")
+	private String shipArea;
+
+	/**
+	 * 最小包单价(人民币)
+	 */
+	@Column(name = "rel_rmbprice")
+	private Double rmbMinPackPrice;
+
+	/**
+	 * 最小包单价(美元)
+	 */
+	@Column(name = "rel_usdprice")
+	private Double usdMinPackPrice;
+	
+	/**
+	 * 图片path,便于发布
+	 */
+	@Column(name = "rel_img")
+	private String img;
+	
+	/**
+	 * 类目名称,便于发布
+	 */
+	@Column(name = "rel_kindname")	
+	private String kindName;
+	
+	@Transient
+	private Double seg1qty;
+
+	@Transient
+	private Double seg1RMBPrice;
+	
+	@Transient
+	private Double seg1USDPrice;
+	
+	@Transient
+	private Double seg2qty;
+
+	@Transient
+	private Double seg2RMBPrice;
+	
+	@Transient
+	private Double seg2USDPrice;
+	
+	@Transient
+	private Double seg3qty;
+
+	@Transient
+	private Double seg3RMBPrice;
+	
+	@Transient
+	private Double seg3USDPrice;
+	
+	/**
+	 * 错误的信息
+	 */
+	@Column(name = "rel_errmsg")
+	private String errmsg;
+	
+	
+	/**
+	 * 本批次的最低人民币价格
+	 */
+	@Column(name = "rel_minpricermb")
+	private Double minPriceRMB;
+
+	/**
+	 * 本批次的最高人民币价格
+	 */
+	@Column(name = "rel_maxpricermb")
+	private Double maxPriceRMB;
+
+	/**
+	 * 本批次的最低美元价格
+	 */
+	@Column(name = "rel_minpriceusd")
+	private Double minPriceUSD;
+
+	/**
+	 * 本批次的最高美元价格
+	 */
+	@Column(name = "rel_maxpriceusd")
+	private Double maxPriceUSD;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getBrandNameCn() {
+		return brandNameCn;
+	}
+
+	public void setBrandNameCn(String brandNameCn) {
+		this.brandNameCn = brandNameCn;
+	}
+	
+	public String getBrandNameEn() {
+		return brandNameEn;
+	}
+
+	public void setBrandNameEn(String brandNameEn) {
+		this.brandNameEn = brandNameEn;
+	}
+
+	public Double getMinPriceRMB() {
+		return minPriceRMB;
+	}
+
+	public void setMinPriceRMB(Double minPriceRMB) {
+		this.minPriceRMB = minPriceRMB;
+	}
+
+	public Double getMaxPriceRMB() {
+		return maxPriceRMB;
+	}
+
+	public void setMaxPriceRMB(Double maxPriceRMB) {
+		this.maxPriceRMB = maxPriceRMB;
+	}
+
+	public Double getMinPriceUSD() {
+		return minPriceUSD;
+	}
+
+	public void setMinPriceUSD(Double minPriceUSD) {
+		this.minPriceUSD = minPriceUSD;
+	}
+
+	public Double getMaxPriceUSD() {
+		return maxPriceUSD;
+	}
+
+	public void setMaxPriceUSD(Double maxPriceUSD) {
+		this.maxPriceUSD = maxPriceUSD;
+	}
+
+	public Long getBrandId() {
+		return brandId;
+	}
+
+	public void setBrandId(Long brandId) {
+		this.brandId = brandId;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getComponentUuId() {
+		return componentUuId;
+	}
+
+	public void setComponentUuId(String componentUuId) {
+		this.componentUuId = componentUuId;
+	}
+
+	public String getUnit() {
+		return unit;
+	}
+
+	public void setUnit(String unit) {
+		this.unit = unit;
+	}
+
+	public Double getSeg1qty() {
+		return seg1qty;
+	}
+
+	public void setSeg1qty(Double seg1qty) {
+		this.seg1qty = seg1qty;
+	}
+
+	public Double getSeg1RMBPrice() {
+		return seg1RMBPrice;
+	}
+
+	public void setSeg1RMBPrice(Double seg1rmbPrice) {
+		seg1RMBPrice = seg1rmbPrice;
+	}
+
+	public Double getSeg1USDPrice() {
+		return seg1USDPrice;
+	}
+
+	public void setSeg1USDPrice(Double seg1usdPrice) {
+		seg1USDPrice = seg1usdPrice;
+	}
+
+	public Double getSeg2qty() {
+		return seg2qty;
+	}
+
+	public void setSeg2qty(Double seg2qty) {
+		this.seg2qty = seg2qty;
+	}
+
+	public Double getSeg2RMBPrice() {
+		return seg2RMBPrice;
+	}
+
+	public void setSeg2RMBPrice(Double seg2rmbPrice) {
+		seg2RMBPrice = seg2rmbPrice;
+	}
+
+	public Double getSeg2USDPrice() {
+		return seg2USDPrice;
+	}
+
+	public void setSeg2USDPrice(Double seg2usdPrice) {
+		seg2USDPrice = seg2usdPrice;
+	}
+
+	public Double getSeg3qty() {
+		return seg3qty;
+	}
+
+	public void setSeg3qty(Double seg3qty) {
+		this.seg3qty = seg3qty;
+	}
+
+	public Double getSeg3RMBPrice() {
+		return seg3RMBPrice;
+	}
+
+	public void setSeg3RMBPrice(Double seg3rmbPrice) {
+		seg3RMBPrice = seg3rmbPrice;
+	}
+
+	public Double getSeg3USDPrice() {
+		return seg3USDPrice;
+	}
+
+	public void setSeg3USDPrice(Double seg3usdPrice) {
+		seg3USDPrice = seg3usdPrice;
+	}
+
+	public String getRelbatchid() {
+		return relbatchid;
+	}
+
+	public void setRelbatchid(String relbatchid) {
+		this.relbatchid = relbatchid;
+	}
+
+	public Integer getOriginal() {
+		return original;
+	}
+
+	public void setOriginal(Integer original) {
+		this.original = original;
+	}
+
+	public String getImg() {
+		return img;
+	}
+
+	public void setImg(String img) {
+		this.img = img;
+	}
+
+	public String getKindName() {
+		return kindName;
+	}
+
+	public void setKindName(String kindName) {
+		this.kindName = kindName;
+	}
+
+	public Double getReserve() {
+		return reserve;
+	}
+
+	public void setReserve(Double reserve) {
+		this.reserve = reserve;
+	}
+
+	public Double getMinBuyQty() {
+		return minBuyQty;
+	}
+
+	public void setMinBuyQty(Double minBuyQty) {
+		this.minBuyQty = minBuyQty;
+	}
+
+	public String getQtyPrice() {
+		return qtyPrice;
+	}
+
+	public void setQtyPrice(String qtyPrice) {
+		this.qtyPrice = qtyPrice;
+	}
+
+	public Date getProductDate() {
+		return productDate;
+	}
+
+	public void setProductDate(Date productDate) {
+		this.productDate = productDate;
+	}
+
+	public Date getCreateDate() {
+		return createDate;
+	}
+
+	public void setCreateDate(Date createDate) {
+		this.createDate = createDate;
+	}
+
+	public Double getMinPackage() {
+		return minPackage;
+	}
+
+	public void setMinPackage(Double minPackage) {
+		this.minPackage = minPackage;
+	}
+
+	public Short getDeliveryDemTime() {
+		return deliveryDemTime;
+	}
+
+	public void setDeliveryDemTime(Short deliveryDemTime) {
+		this.deliveryDemTime = deliveryDemTime;
+	}
+
+	public Short getMindeliveryDemTime() {
+		return mindeliveryDemTime;
+	}
+
+	public void setMindeliveryDemTime(Short mindeliveryDemTime) {
+		this.mindeliveryDemTime = mindeliveryDemTime;
+	}
+
+	public Short getMaxdeliveryDemTime() {
+		return maxdeliveryDemTime;
+	}
+
+	public void setMaxdeliveryDemTime(Short maxdeliveryDemTime) {
+		this.maxdeliveryDemTime = maxdeliveryDemTime;
+	}
+
+	public String getErrmsg() {
+		return errmsg;
+	}
+
+	public void setErrmsg(String errmsg) {
+		this.errmsg = errmsg;
+	}
+	
+	public void addErrmsg(String errmsg) {
+		if(StringUtils.isEmpty(this.errmsg)) {
+			this.errmsg = "";
+		}
+		this.errmsg +=  (","  + errmsg);
+	}
+
+	public Short getDeliveryHKTime() {
+		return deliveryHKTime;
+	}
+
+	public void setDeliveryHKTime(Short deliveryHKTime) {
+		this.deliveryHKTime = deliveryHKTime;
+	}
+
+	public Short getMindeliveryHKTime() {
+		return mindeliveryHKTime;
+	}
+
+	public void setMindeliveryHKTime(Short mindeliveryHKTime) {
+		this.mindeliveryHKTime = mindeliveryHKTime;
+	}
+
+	public Short getMaxdeliveryHKTime() {
+		return maxdeliveryHKTime;
+	}
+
+	public void setMaxdeliveryHKTime(Short maxdeliveryHKTime) {
+		this.maxdeliveryHKTime = maxdeliveryHKTime;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Double getSampleqty() {
+		return sampleqty;
+	}
+
+	public void setSampleqty(Double sampleqty) {
+		this.sampleqty = sampleqty;
+	}
+
+	public String getPublisherName() {
+		return publisherName;
+	}
+
+	public void setPublisherName(String publisherName) {
+		this.publisherName = publisherName;
+	}
+
+	public Long getPublisherUu() {
+		return publisherUu;
+	}
+
+	public void setPublisherUu(Long publisherUu) {
+		this.publisherUu = publisherUu;
+	}
+
+	public String getPublisherTel() {
+		return publisherTel;
+	}
+
+	public void setPublisherTel(String publisherTel) {
+		this.publisherTel = publisherTel;
+	}
+
+	public String getCurrency() {
+		return currency;
+	}
+
+	public void setCurrency(String currency) {
+		this.currency = currency;
+	}
+
+	public Double getRmbTaxRate() {
+		return rmbTaxRate;
+	}
+
+	public void setRmbTaxRate(Double rmbTaxRate) {
+		this.rmbTaxRate = rmbTaxRate;
+	}
+
+	public Double getUsdTaxRate() {
+		return usdTaxRate;
+	}
+
+	public void setUsdTaxRate(Double usdTaxRate) {
+		this.usdTaxRate = usdTaxRate;
+	}
+
+	public Short getReturnInWeek() {
+		return returnInWeek;
+	}
+
+	public void setReturnInWeek(Short returnInWeek) {
+		this.returnInWeek = returnInWeek;
+	}
+
+	public Integer getReleaseCode() {
+		return releaseCode;
+	}
+
+	public void setReleaseCode(Integer releaseCode) {
+		this.releaseCode = releaseCode;
+	}
+
+	public String getReleaseStatus() {
+		return releaseStatus;
+	}
+
+	public void setReleaseStatus(String releaseStatus) {
+		this.releaseStatus = releaseStatus;
+	}
+
+	public String getShipArea() {
+		return shipArea;
+	}
+
+	public void setShipArea(String shipArea) {
+		this.shipArea = shipArea;
+	}
+
+	public Double getRmbMinPackPrice() {
+		return rmbMinPackPrice;
+	}
+
+	public void setRmbMinPackPrice(Double rmbMinPackPrice) {
+		this.rmbMinPackPrice = rmbMinPackPrice;
+	}
+
+	public Double getUsdMinPackPrice() {
+		return usdMinPackPrice;
+	}
+
+	public void setUsdMinPackPrice(Double usdMinPackPrice) {
+		this.usdMinPackPrice = usdMinPackPrice;
+	}
+
+	/**
+	 * 价格分段数据
+	 * 
+	 * @return
+	 */
+	@Transient
+	public List<CommodityQtyPrice> getPrices() {
+		if (CollectionUtils.isEmpty(prices) && StringUtils.hasText(qtyPrice)) {
+			return FastjsonUtils.fromJsonArray(qtyPrice, CommodityQtyPrice.class);
+		} else {
+			return prices;
+		}
+	}
+
+	public void setPrices(List<CommodityQtyPrice> prices) {
+		this.prices = prices;
+		if (!CollectionUtils.isEmpty(prices)) {
+			this.qtyPrice = FastjsonUtils.toJson(prices);
+		}
+	}
+	
+	/**
+	 * 分段填充到字段中
+	 * 
+	 * @return
+	 */
+	public void fillSegData() {
+		List<CommodityQtyPrice> prices2 = getPrices();
+		if(org.springframework.util.CollectionUtils.isEmpty(prices2)) {
+			for (int i = 0; i < prices2.size(); i++) {
+				switch (i) {
+				case 0:
+					this.seg1qty = prices2.get(0).getStart();
+					this.seg1RMBPrice = prices2.get(0).getrMBPrice();
+					this.seg1USDPrice = prices2.get(0).getuSDPrice();
+					break;
+				case 1:
+					this.seg1qty = prices2.get(1).getStart();
+					this.seg1RMBPrice = prices2.get(1).getrMBPrice();
+					this.seg1USDPrice = prices2.get(1).getuSDPrice();
+					break;
+				case 2:
+					this.seg1qty = prices2.get(2).getStart();
+					this.seg1RMBPrice = prices2.get(2).getrMBPrice();
+					this.seg1USDPrice = prices2.get(2).getuSDPrice();
+					break;
+				default:
+					throw new IllegalOperatorException("当前的分段超过了三个,请确定信息之后再上传。");
+				}
+				
+			}
+		}
+	}
+
+	/**
+	 * 用人民币含税单价修改未含税人民币单价
+	 */
+	public void setWithOutTaxRMBPrice() {
+		if (!CollectionUtils.isEmpty(this.prices)) {
+			if (this.currency.contains("RMB")) {
+				for (CommodityQtyPrice price : prices) {
+					BigDecimal taxNum = new BigDecimal(this.getRmbTaxRate() + 1);
+					BigDecimal priceNum = new BigDecimal(price.getrMBPrice());
+					price.setrMBNTPrice(priceNum.divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
+				}
+			}
+			// 更新分段价格JSON字符串
+			this.qtyPrice = FastjsonUtils.toJson(this.prices);
+		}
+	}
+
+	/**
+	 * 用美元含税单价修改未含税美元单价
+	 */
+	public void setWithOutTaxUSDPrice() {
+		if (!CollectionUtils.isEmpty(this.prices)) {
+			if (this.currency.contains("USD")) {
+				for (CommodityQtyPrice price : prices) {
+					BigDecimal taxNum = new BigDecimal(this.getUsdTaxRate() + 1);
+					BigDecimal priceNum = new BigDecimal(price.getuSDPrice());
+					price.setuSDNTPrice(priceNum.divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
+				}
+			}
+			// 更新分段价格JSON字符串
+			this.qtyPrice = FastjsonUtils.toJson(this.prices);
+		}
+	}
+
+	/**
+	 * 获取人民币分段报价列表
+	 * 
+	 * @return
+	 */
+	@Transient
+	public List<CommodityQtyPrice> getRmbSegPriceList() {
+		List<CommodityQtyPrice> prices = new ArrayList<CommodityQtyPrice>();
+		List<CommodityQtyPrice> prices2 = getPrices();
+		if (!currency.contains("RMB") || org.springframework.util.CollectionUtils.isEmpty(prices2)) {
+			return null;
+		}
+		for (CommodityQtyPrice qtyPrice : prices2) {
+			CommodityQtyPrice price = new CommodityQtyPrice();
+			price.setStart(qtyPrice.getStart());
+			price.setEnd(qtyPrice.getEnd());
+			price.setTaxPrice(qtyPrice.getrMBPrice());
+			price.setPrice(qtyPrice.getrMBNTPrice());
+			prices.add(price);
+		}
+		return prices;
+	}
+
+	/**
+	 * 获取美元分段报价列表
+	 * 
+	 * @return
+	 */
+	@Transient
+	public List<CommodityQtyPrice> getUsdSegPriceList() {
+		List<CommodityQtyPrice> prices = new ArrayList<CommodityQtyPrice>();
+		List<CommodityQtyPrice> prices2 = getPrices();
+		if (!currency.contains("USD") || org.springframework.util.CollectionUtils.isEmpty(prices2)) {
+			return null;
+		}
+		
+		for (CommodityQtyPrice qtyPrice : prices2) {
+			CommodityQtyPrice price = new CommodityQtyPrice();
+			price.setStart(qtyPrice.getStart());
+			price.setEnd(qtyPrice.getEnd());
+			price.setTaxPrice(qtyPrice.getuSDPrice());
+			price.setPrice(qtyPrice.getuSDNTPrice());
+			prices.add(price);
+		}
+		return prices;
+	}
+
+	public ReleaseProductByBatch() {
+		//空构造函数
+	}
+
+	public ReleaseProductByBatch(String batch) {
+		this.relbatchid = batch;
+		this.releaseStatus = ReleaseStatus.success.getPhrase();
+		this.releaseCode = ReleaseStatus.success.value();
+	}
+
+	public Commodity releaseProductByBatchConvertToGoods(ReleaseProductByBatch releaseProductByBatch) {
+		Commodity commodity = new Commodity();
+		commodity.setBrandNameCn(releaseProductByBatch.getBrandNameEn());
+		commodity.setCurrencyName(releaseProductByBatch.getCurrency());
+		commodity.setCode(releaseProductByBatch.getCode());
+		commodity.setCreatedDate(new Date());
+		commodity.setUpdateDate(new Date());
+		// 交货周期 暂未做最长与最短
+		commodity.setB2cDeliveryDemMaxTime(releaseProductByBatch.getMaxdeliveryDemTime());
+		commodity.setB2cDeliveryDemMinTime(releaseProductByBatch.getMindeliveryDemTime());
+		commodity.setDeliveryDemTime(releaseProductByBatch.getDeliveryDemTime());
+		commodity.setB2cDeliveryHKMaxTime(releaseProductByBatch.getMaxdeliveryHKTime());
+		commodity.setB2cDeliveryHKMinTime(releaseProductByBatch.getMindeliveryHKTime());
+		commodity.setDeliveryHKTime(releaseProductByBatch.getDeliveryHKTime());
+		commodity.setProduceDate(releaseProductByBatch.getProductDate());
+		commodity.setPublisherUU(releaseProductByBatch.getPublisherUu());
+		commodity.setPublisherName(releaseProductByBatch.getPublisherName());
+		commodity.setMinBuyQty(releaseProductByBatch.getMinBuyQty());
+		commodity.setMinPackQty(releaseProductByBatch.getMinPackage());
+		commodity.setUuid(releaseProductByBatch.getComponentUuId());
+		commodity.setOriginal(releaseProductByBatch.getOriginal());
+		commodity.setPrices(releaseProductByBatch.getPrices());
+		commodity.setRemark(releaseProductByBatch.getRemark());
+		commodity.setRmbTaxRate(releaseProductByBatch.getRmbTaxRate());
+		commodity.setUsdTaxRate(releaseProductByBatch.getUsdTaxRate());
+		commodity.setReserve(releaseProductByBatch.getReserve());
+		commodity.setPublishPhone(releaseProductByBatch.getPublisherTel());
+		commodity.setReturnInWeek(releaseProductByBatch.getReturnInWeek());
+		commodity.setShipArea(releaseProductByBatch.getShipArea());
+		commodity.setSampleQty(releaseProductByBatch.getSampleqty());
+		commodity.setKindNameCn(releaseProductByBatch.getKindName());
+		commodity.setImg(releaseProductByBatch.getImg());
+		return commodity;
+	}
+}

+ 138 - 0
src/main/java/com/uas/cloud/mall/commodity/domain/ShopComponent.java

@@ -0,0 +1,138 @@
+package com.uas.cloud.mall.commodity.domain;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * Created by John on 2017/3/3.
+ */
+@Entity
+@Table(name = "trade$shopcomponent")
+public class ShopComponent implements Serializable{
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "trade$shopcomponent_gen")
+    @SequenceGenerator(name = "trade$shopcomponent_gen", sequenceName = "trade$shopcomponent_seq", allocationSize = 1)
+    private Long id;
+
+    /**
+     * 企业UU
+     */
+    @Column(name = "sc_enuu")
+    private Long enuu;
+
+    /**
+     * 企业名称
+     */
+    @Column(name = "sc_enterprisename")
+    private String enterpriseName;
+
+    /**
+     * 器件名称
+     */
+    @Column(name = "sc_code")
+    private String code;
+
+    /**
+     * 器件的uuid
+     */
+    @Column(name = "sc_uuid")
+    private String uuid;
+
+    /**
+     * 器件所属类目
+     */
+    @Column(name = "sc_kindid")
+    private Long kindid;
+
+    /**
+     * 类目的名称
+     */
+    @Column(name = "sc_kiname")
+    private String kindNameCn;
+
+    /**
+     * 品牌中文名称
+     */
+    @Column(name = "sc_brnamecn")
+    private String brandNameCn;
+
+    public ShopComponent(Long enuu, String enterpriseName, String code, String uuid) {
+        this.enuu = enuu;
+        this.enterpriseName = enterpriseName;
+        this.code = code;
+        this.uuid = uuid;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public ShopComponent setId(Long id) {
+        this.id = id;
+        return this;
+    }
+
+    public Long getEnuu() {
+        return enuu;
+    }
+
+    public ShopComponent setEnuu(Long enuu) {
+        this.enuu = enuu;
+        return this;
+    }
+
+    public String getEnterpriseName() {
+        return enterpriseName;
+    }
+
+    public ShopComponent setEnterpriseName(String enterpriseName) {
+        this.enterpriseName = enterpriseName;
+        return this;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public ShopComponent setCode(String code) {
+        this.code = code;
+        return this;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public ShopComponent setUuid(String uuid) {
+        this.uuid = uuid;
+        return this;
+    }
+
+    public Long getKindid() {
+        return kindid;
+    }
+
+    public ShopComponent setKindid(Long kindid) {
+        this.kindid = kindid;
+        return this;
+    }
+
+    public String getKindNameCn() {
+        return kindNameCn;
+    }
+
+    public ShopComponent setKindNameCn(String kindNameCn) {
+        this.kindNameCn = kindNameCn;
+        return this;
+    }
+
+    public String getBrandNameCn() {
+        return brandNameCn;
+    }
+
+    public ShopComponent setBrandNameCn(String brandNameCn) {
+        this.brandNameCn = brandNameCn;
+        return this;
+    }
+}

+ 323 - 0
src/main/java/com/uas/cloud/mall/commodity/repository/CommodityDao.java

@@ -0,0 +1,323 @@
+package com.uas.cloud.mall.commodity.repository;
+
+import com.uas.cloud.mall.commodity.domain.Commodity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+@Repository
+public interface CommodityDao extends JpaSpecificationExecutor<Commodity>, JpaRepository<Commodity, Long> {
+
+    /**
+     * 根据UUID查找对应的货物信息
+     *
+     * @return
+     */
+    List<Commodity> findByUuid(String uuid);
+
+    /**
+     * 根据batch(批次号)查找对应的货物信息
+     *
+     * @return
+     */
+    Commodity findByBatchCode(String batchCode);
+
+    /**
+     * 根据UUID和状态查找对应的货物信息
+     *
+     * @return
+     */
+    List<Commodity> findByUuidAndStatus(String uuid, Integer status);
+
+    /**
+     * 根据UUID和状态和库存的类型查找对应的货物信息
+     *
+     * @return
+     */
+    @Query("select g from Commodity g where g.uuid = :uuid and g.status = :status and g.original in (:originals)")
+    List<Commodity> findByUuidAndStatusAndOriginals(@Param("uuid") String uuid, @Param("status") Integer status, @Param("originals") List<Integer> orginals);
+
+    /**
+     * 获取某一器件的总库存
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select sum(nvl(g.reserve, 0)) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Double findTotalReserveByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取某一器件的最低人民币单价
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select min(g.minPriceRMB) from Commodity g where g.uuid=:uuid and g.status =:status ")
+    Double findMinPriceRMBByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取某一器件的最高人民币单价
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select max(g.maxPriceRMB) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Double findMaxPriceRMBByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取某一器件的最低美元单价
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select min(g.minPriceUSD) from Commodity g where g.uuid=:uuid and g.status =:status ")
+    Double findMinPriceUSDByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取某一器件的最高美元单价
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select max(g.maxPriceUSD) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Double findMaxPriceUSDByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取某一器件的最小起订量
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select min(g.minBuyQty) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Double findMinBuyQtyByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取某一器件的最小大陆交货周期
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select min(g.b2cDeliveryDemMinTime) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Short findMinDemDeliveryByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取某一器件的最大大陆交货周期
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select max(g.b2cDeliveryDemMaxTime) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Short findMaxDemDeliveryByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取某一器件的最小香港交货周期
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select min(g.b2cDeliveryHKMinTime) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Short findMinHKDeliveryByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取某一器件的最大香港交货周期
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select max(g.b2cDeliveryHKMaxTime) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Short findMaxHKDeliveryByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 根据企业UU和状态status,获取产品
+     */
+    List<Commodity> findByEnUUAndStatus(Long enUU, Integer status);
+
+    /**
+     * 根据企业UU、商品型号和库存类型获取产品
+     *
+     * @param enUU
+     *            卖家企业UU
+     * @param code
+     *            商品型号
+     * @param original
+     *            库存类型
+     * @return 商品列表
+     */
+    List<Commodity> findByEnUUAndCodeAndOriginal(Long enUU, String code, Integer original);
+
+    /**
+     * 获取器件型号的有效样品数量
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select sum(nvl(g.sampleQty, 0) - nvl(g.sampleAppliedQty, 0)) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Double findAvailableSampleQtyByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取器件型号现货数量
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select sum(nvl(g.reserve, 0)) from Commodity g where g.uuid=:uuid and g.original=1311 and g.status =:status")
+    Double findOriginalQtyByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取器件型号呆滞库存数量
+     *
+     * @param uuid
+     * @return
+     */
+    @Query("select sum(nvl(g.reserve, 0)) from Commodity g where g.uuid=:uuid and g.original=1312 and g.status =:status")
+    Double findInactionStockQtyByUuid(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 查询所有样品商品
+     *
+     * @return
+     */
+    @Query(value = "select sum(nvl(g.sampleAppliedQty, 0)) from Commodity g where g.uuid=:uuid and g.status =:status")
+    Double findApplyedSampleQty(@Param("uuid") String uuid, @Param("status") Integer status);
+
+    /**
+     * 获取废料数量
+     *
+     * @param uuid
+     * @return
+     */
+    // @Query("select sum(nvl(g.reserve, 0)) from Goods g where g.uuid=:uuid and g.original=1313 and g.status =:status")
+    // public Double findWastageQtyByUuid(@Param("uuid") String uuid,
+    // @Param("status") Integer status);
+
+    /**
+     * 查询所有样品商品
+     *
+     * @return
+     */
+    @Query(value = "select * from (select * from trade$goods g where nvl(g.go_sampleqty, 0) - nvl(g.go_sampleappliedqty, 0) >0 order by go_id desc) where rownum<=:qty", nativeQuery = true)
+    List<Commodity> findAvailableSampleQty(@Param("qty") Integer qty);
+
+    /**
+     * 查找指定的前qty个货物批次
+     *
+     * @return
+     */
+    @Query(value = "select * from (select * from trade$goods order by go_id desc) where rownum<=:qty", nativeQuery = true)
+    List<Commodity> findAvailableOriginal(@Param("qty") Integer qty);
+
+    /**
+     * 查找指定的前qty个货物批次,有图片的优先
+     *
+     * @return
+     */
+    @Query(value = "select * from (select u from (select cmp_code, max(cmp_img) i, max(go_createddate) d,max(cmp_uuid) u from trade$goods group by cmp_code) order by i, d desc) where rownum<=:qty", nativeQuery = true)
+    List<String> findAvailableOriginalWithImg(@Param("qty") Integer qty);
+
+    /**
+     * 查询即将失效的批次
+     *
+     * @param date
+     * @return
+     */
+    @Query(value = "select g from Commodity g where to_char(:date,'yyyy-mm-dd') = to_char(g.updateDate+g.availableDays-1,'yyyy-mm-dd' and g.sourceId is null)")
+    List<Commodity> findOvertimeBatch(@Param("date") Date date);
+
+    /*
+     * 删除指定的批次
+     */
+    @Modifying
+    @Transactional
+    @Query(value = "delete from Commodity g where g.batchCode=:code")
+    void deleteByBatchCode(@Param("code") String code);
+
+    /*
+     * 修改库存信息和状态
+     */
+    @Modifying
+    @Transactional
+    @Query(value = "update Commodity g set g.reserve = :number, g.status = :status  where g.batchCode =:batchCode and g.uuid =:uuid")
+    void modifyReserve(@Param("batchCode") String batchCode, @Param("uuid") String uuid, @Param("number") Double number, @Param("status") int status);
+
+    /**
+     * 根据企业UU、商品UUID、库存类型和商品状态获取有效产品
+     *
+     * @param enUU
+     *            卖家企业UU
+     * @param uuid
+     *            器件UUID
+     * @param original
+     *            库存类型
+     * @param status
+     *            商品状态
+     * @return 商品列表
+     */
+    List<Commodity> findByEnUUAndUuidAndOriginalAndStatus(Long enUU, String uuid, Integer original, int status);
+
+    /**
+     * 获取在售商品器件型号数量
+     *
+     * @return
+     */
+    @Query(value = "select count(distinct g.code) from Commodity g")
+    public Double findCountCodes();
+
+    /**
+     * 获取在售商品器件类目数量
+     *
+     * @return
+     */
+    @Query(value = "select count(distinct g.kindNameCn) from Commodity g")
+    public Double findCountKind();
+
+    /**
+     * 获取在售商品器件品牌数量
+     *
+     * @return
+     */
+    @Query(value = "select count(distinct g.brandNameCn) from Commodity g")
+    public Double findCountBrand();
+
+    /**
+     * 获取在售商品总库存数
+     *
+     * @return
+     */
+    @Query(value = "select sum(g.reserve) from Commodity g")
+    public Double findSumReserve();
+
+    /**
+     * 获取在售商品总库存数
+     *
+     * @return
+     */
+    @Query(value = "select sum(g.reserve * g.maxPriceRMB) from Commodity g")
+    public Double findSumRMB();
+
+    /**
+     *
+     * 创建时间 :2016128日 下午12:42:23
+     * @author yujia
+     * @return List<String>
+     * @Description: 上架了那些器件的库存
+     *
+     */
+    @Query(value = "select distinct(g.uuid) from Commodity g")
+    public List<String> findUuid();
+
+    /**
+     * @author yujia
+     * @return List<Commodity>
+     * @Description: 根据批量上架的标志获取Commodity
+     *
+     */
+    @Query(value = "select g from Commodity g where g.batchid = :batchid")
+    public List<Commodity> findByBatchid(@Param("batchid") String batchid);
+}

+ 39 - 0
src/main/java/com/uas/cloud/mall/commodity/repository/CommodityHistoryDao.java

@@ -0,0 +1,39 @@
+package com.uas.cloud.mall.commodity.repository;
+
+import com.uas.cloud.mall.commodity.domain.CommodityHistory;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface CommodityHistoryDao extends JpaSpecificationExecutor<CommodityHistory>, JpaRepository<CommodityHistory, Long> {
+
+	/**
+	 * 根据UUID查找对应的货物历史信息
+	 * 
+	 * @return
+	 */
+	List<CommodityHistory> findByUuid(String uuid);
+
+	/**
+	 * 根据batch(批次号)查找对应的货物历史信息
+	 * 
+	 * @return
+	 */
+	List<CommodityHistory> findByBatchCode(String batch);
+
+	/**
+	 * 根据UUID和状态查找对应的历史货物信息
+	 * 
+	 * @return
+	 */
+	List<CommodityHistory> findByUuidAndStatus(String uuid, Integer status);
+
+	@Query(value = "select g from CommodityHistory g where g.batchCode = :batchCode and g.operateDate = (select max(c.operateDate) from CommodityHistory c where c.batchCode = :batchCode)")
+    CommodityHistory findNewByBatchCode(@Param("batchCode") String batchCode);
+
+}

+ 77 - 0
src/main/java/com/uas/cloud/mall/commodity/repository/CommodityPriceInfoDao.java

@@ -0,0 +1,77 @@
+package com.uas.cloud.mall.commodity.repository;
+
+import com.uas.cloud.mall.commodity.domain.CommodityPriceInfo;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * 卖家商品价格信息表数据访问对象
+ * 
+ * @date 201683115:34:36
+ * @author HuXueZhi
+ *
+ */
+@Repository
+public interface CommodityPriceInfoDao extends JpaSpecificationExecutor<CommodityPriceInfo>, JpaRepository<CommodityPriceInfo, Long>{
+
+	/**
+	 * 根据企业UU查询商品价格信息列表
+	 * 
+	 * @param enUU 企业UU
+	 * @return
+	 */
+	List<CommodityPriceInfo> findByEnUU(Long enUU);
+
+	/**
+	 * 根据器件的UUID查询商品价格信息列表
+	 * 
+	 * @param uuid 器件UUID
+	 * @return
+	 */
+	List<CommodityPriceInfo> findByUuid(String uuid);
+
+	/**
+	 * 根据器件的UUID查询某个卖家的商品价格信息列表
+	 *
+	 * @param enUU 企业UU号
+	 * @param uuid 器件UUID
+	 * @return
+	 */
+	List<CommodityPriceInfo> findByEnUUAndUuid(Long enUU, String uuid);
+
+	/**
+	 * 根据器件的UUID和库存类型查询某个供应商的商品价格信息列表
+	 *
+	 * @param enUU 企业UU号
+	 * @param uuid 器件UUID
+	 * @param original 库存类型
+	 * @return
+	 */
+	List<CommodityPriceInfo> findByEnUUAndUuidAndOriginal(Long enUU, String uuid, Integer original);
+
+	/**
+	 * 根据卖家uu、器件UUID和库存类型获取唯一的商品价格信息
+	 *
+	 * @param enUU 企业UU号
+	 * @param uuid 器件UUID
+	 * @param original 库存类型
+	 * @return
+	 */
+	List<CommodityPriceInfo> findByEnUUAndUuidAndOriginalAndCurrencyNameAndTax(Long enUU, String uuid, Integer original, String currencyName, Short tax);
+
+	/**
+	 * 根据卖家uu、商品型号和库存类型获取唯一的商品价格信息
+	 * @param enUU 器件UU
+	 * @param uuid 器件的UUID
+	 * @param code 	器件型号
+	 * @param currencyName 币别
+	 * @param tax 税率
+	 * @return
+	 */
+	List<CommodityPriceInfo> findByEnUUAndCodeAndOriginalAndCurrencyNameAndTax(Long enUU, String uuid, String code, String currencyName, Short tax);
+
+	List<CommodityPriceInfo> findByEnUUAndCodeAndCurrencyNameAndOriginalAndTax(Long enUU, String code, String currencyName, Integer original, Short tax);
+}

+ 43 - 0
src/main/java/com/uas/cloud/mall/commodity/repository/CommoditySimpleDao.java

@@ -0,0 +1,43 @@
+package com.uas.cloud.mall.commodity.repository;
+
+import com.uas.cloud.mall.commodity.domain.CommoditySimple;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface CommoditySimpleDao extends JpaSpecificationExecutor<CommoditySimple>, JpaRepository<CommoditySimple, Long> {
+
+	/**
+	 * 根据UUID和状态查找对应的货物信息
+	 * 
+	 * @return
+	 */
+	List<CommoditySimple> findByUuidAndStatus(String uuid, Integer status);
+
+	/**
+	 * 根据uuid获取货物商品信息
+	 * 
+	 * @param uuid
+	 * @return
+	 */
+	List<CommoditySimple> findByUuid(String uuid);
+
+	/**
+	 * 根据uuid和币别获取商品信息
+	 * 
+	 * @param uuid
+	 * @param currencyName
+	 * @return
+	 */
+	List<CommoditySimple> findByUuidAndCurrencyName(String uuid, String currencyName);
+	
+	/**
+	 * 根据batchCode获取商品信息
+	 * @param batchCode
+	 * @return
+	 */
+	public CommoditySimple findByBatchCode(String batchCode);
+}

+ 131 - 0
src/main/java/com/uas/cloud/mall/commodity/repository/CommonDao.java

@@ -0,0 +1,131 @@
+package com.uas.cloud.mall.commodity.repository;
+
+import com.uas.cloud.mall.commodity.util.JdbcUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+
+
+@Repository
+public class CommonDao {
+
+	@Autowired
+	private JdbcTemplate jdbcTemplate;
+
+	public List<Map<String, Object>> queryForList(String sql) {
+		return this.jdbcTemplate.queryForList(sql);
+	}
+
+	public <T> List<T> queryForList(String sql, Class<T> elementType) {
+		return this.jdbcTemplate.queryForList(sql, elementType);
+	}
+
+	public List<Map<String, Object>> queryForList(String sql, Object... args) {
+		return this.jdbcTemplate.queryForList(sql, args);
+	}
+
+	public <T> List<T> queryForList(String sql, Object[] args, Class<T> elementType) {
+		return this.jdbcTemplate.queryForList(sql, args, elementType);
+	}
+
+	public <T> List<T> queryForList(String sql, Class<T> elementType, Object... args) {
+		return this.jdbcTemplate.queryForList(sql, elementType, args);
+	}
+
+	public <T> List<T> query(String sql, Object[] args, Class<T> elementType) {
+		return this.jdbcTemplate.query(sql, args, new BeanPropertyRowMapper<T>(elementType));
+	}
+
+	public <T> List<T> query(String sql, Class<T> elementType) {
+		return this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<T>(elementType));
+	}
+
+	public <T> List<T> query(String sql, Class<T> elementType, Object... args) {
+		return this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<T>(elementType), args);
+	}
+
+	/**
+	 * 查找自定义实体对象集合
+	 * 
+	 * @param sql
+	 * @param args
+	 * @param elementType
+	 * @return
+	 */
+	public <T> T queryBean(String sql, Object[] args, Class<T> elementType) {
+		try {
+			return this.jdbcTemplate.queryForObject(sql, args, new BeanPropertyRowMapper<T>(elementType));
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * 查找自定义实体对象集合
+	 * 
+	 * @param sql
+	 * @param elementType
+	 * @return
+	 */
+	public <T> T queryBean(String sql, Class<T> elementType) {
+		try {
+			return this.jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<T>(elementType));
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * 查找自定义实体对象
+	 * 
+	 * @param sql
+	 * @param elementType
+	 * @param args
+	 * @return
+	 */
+	public <T> T queryBean(String sql, Class<T> elementType, Object... args) {
+		try {
+			return this.jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<T>(elementType), args);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	public <T> T queryForObject(String sql, Object[] args, Class<T> elementType) {
+		return this.jdbcTemplate.queryForObject(sql, args, elementType);
+	}
+
+	public <T> T queryForObject(String sql, Class<T> elementType) {
+		return this.jdbcTemplate.queryForObject(sql, elementType);
+	}
+
+	public <T> T queryForObject(String sql, Class<T> elementType, Object... args) {
+		return this.jdbcTemplate.queryForObject(sql, elementType, args);
+	}
+
+	/**
+	 * 取序列值<br>
+	 * 只针对oracle数据库
+	 * 
+	 * @param sequenceName
+	 * @return
+	 */
+	public long generateSequence(String sequenceName) {
+		return this.jdbcTemplate.queryForObject("select " + sequenceName + ".nextval from dual", Long.class);
+	}
+
+	public JdbcTemplate getJdbcTemplate() {
+		return jdbcTemplate;
+	}
+	
+	public <T> void save(List<T> saveObjs, Class<T> objCls) {
+		JdbcUtil.batchInsert(saveObjs, objCls, getJdbcTemplate());
+	}
+
+}

+ 14 - 0
src/main/java/com/uas/cloud/mall/commodity/repository/CreateNumberDao.java

@@ -0,0 +1,14 @@
+package com.uas.cloud.mall.commodity.repository;
+
+import com.uas.cloud.mall.commodity.domain.CreateNumber;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public interface CreateNumberDao extends JpaSpecificationExecutor<CreateNumber>, JpaRepository<CreateNumber, Long>{
+	
+	CreateNumber findByTbname(String tbname);
+	
+}

+ 13 - 0
src/main/java/com/uas/cloud/mall/commodity/repository/PriceChangeLogDao.java

@@ -0,0 +1,13 @@
+package com.uas.cloud.mall.commodity.repository;
+
+import com.uas.cloud.mall.commodity.domain.PriceChangeLog;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by yujia on 2017/3/20.
+ */
+@Repository
+public interface PriceChangeLogDao extends JpaSpecificationExecutor<PriceChangeLog>, JpaRepository<PriceChangeLog, Long> {
+}

+ 68 - 0
src/main/java/com/uas/cloud/mall/commodity/repository/ReleaseProductByBatchDao.java

@@ -0,0 +1,68 @@
+package com.uas.cloud.mall.commodity.repository;
+
+import com.uas.cloud.mall.commodity.domain.ReleaseProductByBatch;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.jpa.repository.query.Procedure;
+import org.springframework.data.repository.query.Param;
+
+import java.util.List;
+
+
+
+/**
+ * 批量上传商品建立临时表存储相关信息
+ * 
+ * @author hejq
+ * @time 创建时间:2016924
+ */
+public interface ReleaseProductByBatchDao
+		extends JpaSpecificationExecutor<ReleaseProductByBatch>, JpaRepository<ReleaseProductByBatch, Long> {
+
+
+	/**
+	  * 创建时间 :20161222日 上午10:16:26
+	  * @param publisherUu
+	  * @param relbatchid
+	  * @param releaseCode
+	  * @return
+	  * @return List<ReleaseProductByBatch>
+	  * @Description: 通过uu查找对应的信息
+	  * 
+	  */
+	public List<ReleaseProductByBatch> findByPublisherUuAndRelbatchidAndReleaseCode(Long publisherUu, String relbatchid, Integer releaseCode);
+	
+	
+	/**
+	  * 创建时间 :20161222日 上午10:25:36
+	  * @author yujia
+	  * @param publisherUu
+	  * @return List<ReleaseProductByBatch>
+	  * @Description: 查找指定人的所有的信息
+	  */
+	public List<ReleaseProductByBatch> findByPublisherUu(Long publisherUu);
+
+	@Query("select count(*) from ReleaseProductByBatch r where r.publisherUu =:publisherUu and r.relbatchid =:relbatchid and r.releaseCode =:releaseCode")
+	public Integer getCountPublisherUuAndBatchAndReleaseCode(@Param("publisherUu") Long publisherUu, @Param("relbatchid") String relbatchid, @Param("releaseCode") Integer releaseCode);
+	/**
+	 * 验证器件和品牌的信息
+	 * 
+	 * @param publisherUu
+	 */
+	@Procedure(procedureName = "product$release$valid")
+	public void callValidProcedure(Long publisherUu, String batchid);
+	
+	/**
+	 * 
+	  * 创建时间 :201716日 下午8:25:57
+	  * @param enuu 上架的所属的uu
+	  * @param enterName 上架的所属的公司名称
+	  * @param batchid 这个批次的id
+	  * @return String
+	  * @Description: 批量上架的存储过程
+	  *
+	 */
+	@Procedure(procedureName = "product$release$batch$publish")
+	public void callPublishByBatch(Long enuu, String enterName, String batchid);
+}

+ 23 - 0
src/main/java/com/uas/cloud/mall/commodity/repository/ShopComponentDao.java

@@ -0,0 +1,23 @@
+package com.uas.cloud.mall.commodity.repository;
+
+import com.uas.cloud.mall.commodity.domain.ShopComponent;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Created by John on 2017/3/3.
+ */
+@Repository
+public interface ShopComponentDao extends JpaSpecificationExecutor<ShopComponent>, JpaRepository<ShopComponent, Long>{
+
+    /**
+     * 根据enuu 和 uuid 找店铺的器件
+     * @param enuu
+     * @param uuid
+     * @return List<ShopComponent>
+     */
+    List<ShopComponent> findByEnuuAndUuid(Long enuu, String uuid);
+}

+ 18 - 0
src/main/java/com/uas/cloud/mall/commodity/service/CommodityHistoryService.java

@@ -0,0 +1,18 @@
+package com.uas.cloud.mall.commodity.service;
+
+import com.uas.cloud.commons.domain.PageInfo;
+import com.uas.cloud.mall.commodity.domain.CommodityHistory;
+import org.springframework.data.domain.Page;
+
+import java.util.List;
+
+/**
+ * Created by John on 2017/3/3.
+ */
+public interface CommodityHistoryService {
+
+    /**
+     * 获取已下架产品历史记录
+     */
+    Page<CommodityHistory> findPageByStatus(final PageInfo info, String keyword, List<Long> publisherUUs);
+}

+ 36 - 0
src/main/java/com/uas/cloud/mall/commodity/service/CommodityPriceInfoService.java

@@ -0,0 +1,36 @@
+package com.uas.cloud.mall.commodity.service;
+
+import com.uas.cloud.mall.commodity.domain.CommodityPriceInfo;
+
+/**
+ * Created by John on 2017/3/2.
+ */
+public interface CommodityPriceInfoService {
+
+    /**
+     * 保存商品价格信息,并记录日志信息
+     *
+     * @param priceInfo 商品价格信息
+     * @param deviceInfo 设备信息
+     */
+    void saveOrUpdate(CommodityPriceInfo priceInfo, String deviceInfo);
+
+
+    /**
+     * 根据企业UU、器件型号、币别、库存类型和税率查询商品价格信息
+     *
+     * @param priceInfo 价格信息
+     * @return
+     */
+    CommodityPriceInfo findByBasicInfo(CommodityPriceInfo priceInfo);
+
+    /**
+     * 持久化商品价格信息,更新商品的价格和有效期,记录器操作日志
+     *
+     * @param priceInfo 完整的商品价格信息
+     * @param comment 操作日志信息
+     * @param deviceInfo 设备信息
+     * @return 持久化的商品信息对象
+     */
+    CommodityPriceInfo save(CommodityPriceInfo priceInfo, String comment, String deviceInfo);
+}

+ 65 - 0
src/main/java/com/uas/cloud/mall/commodity/service/CommodityService.java

@@ -0,0 +1,65 @@
+package com.uas.cloud.mall.commodity.service;
+
+import com.uas.cloud.commons.domain.PageInfo;
+import com.uas.cloud.mall.commodity.domain.Commodity;
+import com.uas.cloud.mall.commodity.domain.CommoditySimple;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+public interface CommodityService {
+
+	List<Commodity> findAllGoods();
+
+	/**
+	 * 分页获取店铺的某一类名的商品信息
+	 *
+	 * @param enuu				店铺企业UU
+	 * @param isSelfSupport		是否为优软代售
+	 * @param kindUuid			查询的类目UUID
+	 * @param pageable			分页信息
+	 */
+	Page<Commodity> pageCommoditiesByEnInfos(Long enuu, Boolean isSelfSupport, String kindUuid, Pageable pageable);
+
+
+	/**
+	 * 添加或修改商品价格信息
+	 *
+	 * @param goods
+	 *            上架商品信息
+	 * 这个方法 里面调用了多线程,需要等库存的信息保存到数据库之后,在调用这个方法
+	 */
+	void saveOrUpdatePriceInfos(Commodity goods, String deviceInfo);
+
+
+	/**
+	 * 分页查找在售有效的产品
+	 */
+	Page<Commodity> findPageByStatus(PageInfo pageInfo, String keyword, List<Long> publisherUUs);
+
+
+	/**
+	 * 根据uuid查找货物信息
+	 *
+	 * @param uuid
+	 * @return
+	 */
+	List<Commodity> findGoodsByUuid(String uuid);
+
+	/**
+	 * 根据uuid查找简单货物信息
+	 *
+	 * @param uuid
+	 * @return
+	 */
+	List<CommoditySimple> findGoodsSimpleByUuid(String uuid);
+
+
+	/**
+	 * 根据批次获取 Commodity
+	 * @param batchCode
+	 * @return Commodity
+	 */
+	public Commodity findGoodsByBatchCode(String batchCode);
+}

+ 47 - 0
src/main/java/com/uas/cloud/mall/commodity/service/CreateNumberService.java

@@ -0,0 +1,47 @@
+package com.uas.cloud.mall.commodity.service;
+
+import com.uas.cloud.mall.commodity.domain.CreateNumber;
+
+public interface CreateNumberService {
+
+	/**
+	 * 保存
+	 * 
+	 * @param createNumber
+	 * @return
+	 */
+	CreateNumber save(CreateNumber createNumber);
+	
+	/**
+	 * 获得8位时间+某张表应该给的number
+	 * @param tbname 表名称
+	 * @param digit number位数
+	 * @return
+	 */
+	String getTimeNumber(String tbname, int digit, Integer... addNum);
+	
+	/**
+	  * 创建时间 :20161229日 下午9:52:14
+	  * @author yujia
+	  * @param orderType
+	  * @param table
+	  * @param number
+	  * @return String
+	  * @Description: 传入订单的类型、表,数字生成单号
+	  * 一般主表 8位,明细9
+	  * 
+	  */
+	String generateOrderNumber(String orderType, String table, int number);
+
+	/**
+	 * 根据订单的编码规则生成单据编号ID
+	 * Created by huxz
+	 *
+	 * @param voucherType		单据编号类型
+	 * @param tableName			单据对应表名称
+	 * @param number			单据编码位数
+	 * @return	生成的单据编号
+	 */
+	String generateVoucherId(String voucherType, String tableName, int number);
+
+}

+ 22 - 0
src/main/java/com/uas/cloud/mall/commodity/service/PriceChangeLogService.java

@@ -0,0 +1,22 @@
+package com.uas.cloud.mall.commodity.service;
+
+/**
+ * Created by John on 2017/3/2.
+ */
+public interface PriceChangeLogService {
+
+    /**
+     * 记录卖家商品价格变更记录
+     *  @param agent 设备信息
+     * @param code 商品型号
+     * @param currencyName 币别
+     * @param original 库存类型
+     * @param tax 税率
+     * @param oldPrice 原价格
+     * @param priceInfoPrice
+     * @param price 新价格
+     * @param comment 备注
+     */
+    void log(String agent, String code, String currencyName, Integer original, Short tax, Double oldPrice, Double priceInfoPrice, Float price,
+             String comment);
+}

+ 76 - 0
src/main/java/com/uas/cloud/mall/commodity/service/ReleaseProductByBatchService.java

@@ -0,0 +1,76 @@
+package com.uas.cloud.mall.commodity.service;
+
+import com.uas.cloud.commons.domain.PageInfo;
+import com.uas.cloud.mall.commodity.domain.ReleaseProductByBatch;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.data.domain.Page;
+import org.springframework.ui.ModelMap;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by John on 2017/3/2.
+ */
+public interface ReleaseProductByBatchService {
+
+    /**
+     * 通过Excel上传资料发布商品
+     *
+     * @param workbook
+     * @return
+     */
+    public ModelMap releaseByWorkbook(Workbook workbook);
+
+    /**
+     * 批量发布验证通过的信息
+     *
+     * @param batch
+     * @return
+     */
+    public Set<String> publishByBatch(String batch);
+
+    /**
+     * 获取当前用户这个批次的验证不通过的信息
+     *
+     * @param batch
+     * @return
+     */
+    public List<ReleaseProductByBatch> findFailureReleaseProductByBatchByBatch(String batch);
+
+
+    /**
+     * 通过id删除信息
+     *
+     * @param id
+     */
+    public void delete(Long id);
+
+    /**
+     * 通过ids删除信息
+     *
+     * @param ids
+     */
+    public void delete(List<Long> ids);
+
+
+    /**
+     * 根据发布者UU获取一组产品的信息
+     *
+     * @param publisheruu
+     * @return
+     */
+    public List<ReleaseProductByBatch> findByPublisheruu(Long publisheruu);
+
+
+    /**
+     * 创建时间 :20161222日 上午11:33:28
+     * @author yujia
+     * @param info
+     * @param batch
+     * @return Page<ReleaseProductByBatch>
+     * @Description: 获取分页的信息
+     *
+     */
+    public Page<ReleaseProductByBatch> getPageReleaseProductByBatch(final PageInfo info, String batch);
+}

+ 28 - 0
src/main/java/com/uas/cloud/mall/commodity/service/ShopComponentService.java

@@ -0,0 +1,28 @@
+package com.uas.cloud.mall.commodity.service;
+
+import com.uas.cloud.mall.commodity.domain.Commodity;
+import com.uas.cloud.mall.commodity.domain.ShopComponent;
+
+import java.util.List;
+
+/**
+ * Created by John on 2017/3/3.
+ */
+public interface ShopComponentService {
+
+    /**
+     * 根据 enuu, uuid获取 ShopComponent
+     * @param enuu
+     * @param uuid
+     * @return List<ShopComponent>
+     */
+    List<ShopComponent> findByEnuuAndUuid(Long enuu, String uuid);
+
+    /**
+     * commodities 保存 ShopComponent
+     * @param commodities
+     */
+    public void saveShopComponent(List<Commodity> commodities);
+
+
+}

+ 61 - 0
src/main/java/com/uas/cloud/mall/commodity/service/impl/CommodityHistoryServiceImpl.java

@@ -0,0 +1,61 @@
+package com.uas.cloud.mall.commodity.service.impl;
+
+import com.uas.cloud.commons.domain.PageInfo;
+import com.uas.cloud.commons.persistence.criteria.CriterionExpression.Operator;
+import com.uas.cloud.commons.persistence.criteria.LogicalExpression;
+import com.uas.cloud.commons.persistence.criteria.SimpleExpression;
+import com.uas.cloud.mall.commodity.domain.CommodityHistory;
+import com.uas.cloud.mall.commodity.repository.CommodityHistoryDao;
+import com.uas.cloud.mall.commodity.service.CommodityHistoryService;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.List;
+
+/**
+ * Created by John on 2017/3/3.
+ */
+@Service
+public class CommodityHistoryServiceImpl implements CommodityHistoryService {
+
+    private final CommodityHistoryDao commodityHistoryDao;
+
+    @Autowired
+    public CommodityHistoryServiceImpl(CommodityHistoryDao commodityHistoryDao) {
+        this.commodityHistoryDao = commodityHistoryDao;
+    }
+
+    @Override
+    public Page<CommodityHistory> findPageByStatus(PageInfo info, String keyword, List<Long> publisherUUs) {
+        if (StringUtils.hasText(keyword)) {
+            int k = CollectionUtils.isEmpty(publisherUUs) ? 0 : publisherUUs.size();
+            SimpleExpression[] simpArrs = new SimpleExpression[4 + k];
+            for (int i = 0; i < k; i++) {
+                simpArrs[i] = new SimpleExpression("enUU", publisherUUs.get(i), Operator.EQ);
+            }
+            simpArrs[k] = new SimpleExpression("batchCode", keyword, Operator.LIKE, true);
+            simpArrs[k + 1] = new SimpleExpression("code", keyword, Operator.LIKE, true);
+            simpArrs[k + 2] = new SimpleExpression("kindNameCn", keyword, Operator.LIKE, true);
+            simpArrs[k + 3] = new SimpleExpression("brandNameCn", keyword, Operator.LIKE, true);
+
+            LogicalExpression logical = new LogicalExpression(simpArrs, Operator.OR);
+            info.expression(logical);
+        }
+        Page<CommodityHistory> pageGHistory = commodityHistoryDao.findAll(new Specification<CommodityHistory>() {
+            public Predicate toPredicate(Root<CommodityHistory> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+                query.where(info.getPredicates(root, query, builder));
+                return null;
+            }
+        }, info);
+
+        return pageGHistory;
+    }
+}

+ 173 - 0
src/main/java/com/uas/cloud/mall/commodity/service/impl/CommodityPriceInfoServiceImpl.java

@@ -0,0 +1,173 @@
+package com.uas.cloud.mall.commodity.service.impl;
+
+import com.uas.cloud.commons.exception.IllegalOperatorException;
+import com.uas.cloud.commons.thread.BoundedExecutor;
+import com.uas.cloud.mall.commodity.domain.Commodity;
+import com.uas.cloud.mall.commodity.domain.CommodityPriceInfo;
+import com.uas.cloud.mall.commodity.domain.CommodityQtyPrice;
+import com.uas.cloud.mall.commodity.repository.CommodityDao;
+import com.uas.cloud.mall.commodity.repository.CommodityPriceInfoDao;
+import com.uas.cloud.mall.commodity.service.CommodityPriceInfoService;
+import com.uas.cloud.mall.commodity.service.PriceChangeLogService;
+import com.uas.cloud.mall.commodity.statusAndType.Status;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * Created by John on 2017/3/2.
+ */
+@Service
+public class CommodityPriceInfoServiceImpl implements CommodityPriceInfoService {
+
+    private final CommodityDao goodsDao;
+
+    private final CommodityPriceInfoDao commodityPriceInfoDao;
+
+    private final PriceChangeLogService changeLogService;
+
+    private final BoundedExecutor executor;
+
+    @Autowired
+    public CommodityPriceInfoServiceImpl(CommodityDao goodsDao, CommodityPriceInfoDao commodityPriceInfoDao, PriceChangeLogService changeLogService) {
+        this.goodsDao = goodsDao;
+        this.commodityPriceInfoDao = commodityPriceInfoDao;
+        this.changeLogService = changeLogService;
+        ExecutorService executorService = Executors.newCachedThreadPool();
+        this.executor = new BoundedExecutor(executorService, 1000);
+    }
+
+    /**
+     * 保存商品价格信息,并记录日志信息
+     *
+     * @param priceInfo 商品价格信息
+     * @param deviceInfo 设备信息
+     */
+    @Override
+    public void saveOrUpdate(CommodityPriceInfo priceInfo, String deviceInfo) {
+        String comment;
+        // 记录商品价格变更
+        if (priceInfo.getId() == null) {
+            comment = "新建价格";
+        } else {
+            comment = "更新价格";
+        }
+        priceInfo.setStatus(Status.AVAILABLE.value());
+        save(priceInfo, comment, deviceInfo);
+    }
+
+    /**
+     * 持久化商品价格信息,更新商品的价格和有效期,记录器操作日志
+     *
+     * @param priceInfo 完整的商品价格信息
+     * @param comment 操作日志信息
+     * @param deviceInfo 设备信息
+     * @return 持久化的商品信息对象
+     */
+    @Override
+    public CommodityPriceInfo save(CommodityPriceInfo priceInfo, String comment, String deviceInfo) {
+        checkPriceInfo(priceInfo);
+        priceInfo = commodityPriceInfoDao.save(priceInfo);
+        updateGoodsInfos(priceInfo);
+        log(priceInfo, comment, deviceInfo);
+        return priceInfo;
+    }
+
+    /**
+     * 记录商品价格变更日志
+     *
+     * @param priceInfo 商品价格信息对象
+     * @param comment 备注
+     * @param deviceInfo 设备信息
+     */
+    private void log(CommodityPriceInfo priceInfo, String comment, String deviceInfo) {
+        changeLogService.log(deviceInfo, priceInfo.getCode(), priceInfo.getCurrencyName(), priceInfo.getOriginal(), priceInfo.getTax(), priceInfo.getOldPrice(), priceInfo.getPrice(),
+                priceInfo.getRange(), comment);
+    }
+
+    /**
+     * 更新卖家的同一型号同一币别的商品的价格和有效期信息
+     *
+     * @param priceInfo 卖家商品价格信息
+     */
+    private void updateGoodsInfos(final CommodityPriceInfo priceInfo) {
+        final Runnable command = new Runnable() {
+
+            @Override
+            public void run() {
+                List<Commodity> goodsList = goodsDao.findByEnUUAndUuidAndOriginalAndStatus(priceInfo.getEnUU(), priceInfo.getUuid(), priceInfo.getOriginal(), Status.AVAILABLE.value());
+                // 遍历商品信息,并更新对应商品的价格
+                for (Commodity goods : goodsList) {
+                    if (!goods.getCurrencyName().trim().contains(priceInfo.getCurrencyName())) {
+                        continue;
+                    }
+                    List<CommodityQtyPrice> prices = goods.getPrices();
+                    // 判断是否没有区间分段
+                    if (prices != null && prices.size() == 1) {
+                        // 如果商品的税率库存类型和价格信息中的税率库存类型相同,则可以进行更新
+                        CommodityQtyPrice price = prices.get(0);
+                        // 更新价格信息
+                        if ("RMB".equalsIgnoreCase(priceInfo.getCurrencyName().trim())) {
+                            price.setrMBPrice(priceInfo.getPrice());
+                            price.setrMBNTPrice(priceInfo.getTaxPrice());
+                        }
+                        if ("USD".equalsIgnoreCase(priceInfo.getCurrencyName().trim())) {
+                            price.setuSDPrice(priceInfo.getPrice());
+                            price.setuSDNTPrice(priceInfo.getTaxPrice());
+                        }
+                        prices.clear();
+                        prices.add(price);
+                        goods.setPrices(prices);
+                        goodsDao.saveAndFlush(goods);
+                    }
+                }
+            }
+        };
+        try {
+            executor.submitTask(command);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 根据企业UU、器件型号、币别、库存类型和税率查询商品价格信息
+     *
+     * @param priceInfo 价格信息
+     * @return
+     */
+    @Override
+    public CommodityPriceInfo findByBasicInfo(CommodityPriceInfo priceInfo) {
+        checkPriceInfo(priceInfo);
+        List<CommodityPriceInfo> prices = commodityPriceInfoDao.findByEnUUAndCodeAndCurrencyNameAndOriginalAndTax(priceInfo.getEnUU(), priceInfo.getCode(), priceInfo.getCurrencyName(),
+                priceInfo.getOriginal(), priceInfo.getTax());
+        if (prices != null && prices.size() == 1) {
+            return prices.get(0);
+        } else if (prices != null && prices.size() > 1) {
+            throw new IllegalOperatorException("同一个卖家的相同型号、币别、税率和库存类型的商品价格不能重复");
+        }
+        return null;
+    }
+
+    /**
+     * 检测卖家企业UU、商品型号、库存类型、税率和币别合法性
+     */
+    private void checkPriceInfo(CommodityPriceInfo priceInfo) {
+        if (priceInfo.getEnUU() == null) {
+            throw new IllegalOperatorException("商家企业UU不能为空");
+        }
+        if (StringUtils.isEmpty(priceInfo.getCode()) || StringUtils.isEmpty(priceInfo.getCurrencyName())) {
+            throw new IllegalOperatorException("商品型号或币别不能为空或空字符串");
+        }
+        if (priceInfo.getOriginal() == null) {
+            throw new IllegalOperatorException("商品库存类型不能为空");
+        }
+        if (priceInfo.getTax() == null) {
+            throw new IllegalOperatorException("商品税率不能为空");
+        }
+    }
+}

+ 213 - 0
src/main/java/com/uas/cloud/mall/commodity/service/impl/CommodityServiceImpl.java

@@ -0,0 +1,213 @@
+package com.uas.cloud.mall.commodity.service.impl;
+
+import com.uas.cloud.commons.domain.PageInfo;
+import com.uas.cloud.commons.exception.IllegalOperatorException;
+import com.uas.cloud.commons.persistence.criteria.CriterionExpression.Operator;
+import com.uas.cloud.commons.persistence.criteria.LogicalExpression;
+import com.uas.cloud.commons.persistence.criteria.SimpleExpression;
+import com.uas.cloud.mall.commodity.domain.Commodity;
+import com.uas.cloud.mall.commodity.domain.CommodityPriceInfo;
+import com.uas.cloud.mall.commodity.domain.CommoditySimple;
+import com.uas.cloud.mall.commodity.repository.CommodityDao;
+import com.uas.cloud.mall.commodity.repository.CommoditySimpleDao;
+import com.uas.cloud.mall.commodity.service.CommodityService;
+import com.uas.cloud.mall.commodity.service.CommodityPriceInfoService;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.List;
+
+@Service
+public class CommodityServiceImpl implements CommodityService {
+
+	private final CommodityDao commodityDao;
+
+	private final CommodityPriceInfoService commodityPriceInfoService;
+
+	private final CommoditySimpleDao commoditySimpleDao;
+
+	@Autowired
+	public CommodityServiceImpl(CommodityDao commodityDao, CommodityPriceInfoService commodityPriceInfoService, CommoditySimpleDao commoditySimpleDao) {
+		this.commodityDao = commodityDao;
+		this.commodityPriceInfoService = commodityPriceInfoService;
+		this.commoditySimpleDao = commoditySimpleDao;
+	}
+
+	@Override
+	public List<Commodity> findAllGoods() {
+		Pageable pageable = new PageRequest(0, 10);
+		return commodityDao.findAll(pageable).getContent();
+	}
+
+	@Override
+	public Page<Commodity> pageCommoditiesByEnInfos(final Long enuu, final Boolean isSelfSupport, final String kindUuid, Pageable pageable) {
+		if (enuu == null || isSelfSupport == null) {
+			return null;
+		}
+		return commodityDao.findAll((root, query, builder) -> {
+			Predicate predicate = builder.conjunction();
+			Predicate enUUExpression = builder.equal(root.get("enUU"), enuu);
+			predicate.getExpressions().add(enUUExpression);
+			Predicate supportExpression = builder.equal(root.get("isSelfSupport"), isSelfSupport);
+			predicate.getExpressions().add(supportExpression);
+			if (StringUtils.hasText(kindUuid)) {
+				Predicate expression = builder.equal(root.get("kindUuid"), kindUuid);
+				predicate.getExpressions().add(expression);
+			}
+			return predicate;
+		}, pageable);
+	}
+
+
+	/**
+	 * 添加或修改商品价格信息
+	 *
+	 * @param goods
+	 *            上架商品信息 这个方法 里面调用了多线程,需要等库存的信息保存到数据库之后,在调用这个方法
+	 */
+	@Transactional
+	@Override
+	public void saveOrUpdatePriceInfos(Commodity goods, String deviceInfo) {
+
+		// TODO huxz 价格库待修改
+		// 如果商品存在商品价格区间分段,则不进行价格信息的操作操作
+		if (goods.getPrices() == null || goods.getPrices().size() == 0 || goods.getPrices().size() > 1) {
+			return;
+		}
+		// 如果商品的币别为单币别,则保存一次,否则保存两次
+		if ("RMB".equalsIgnoreCase(goods.getCurrencyName().trim())
+				|| "USD".equalsIgnoreCase(goods.getCurrencyName().trim())) {
+			CommodityPriceInfo priceInfo = getGoodsPriceInfo(goods);
+			// 添加价格信息
+			if ("RMB".equalsIgnoreCase(goods.getCurrencyName().trim())) {
+				priceInfo.setPrice(goods.getPrices().get(0).getrMBPrice());
+			}
+			if ("USD".equalsIgnoreCase(goods.getCurrencyName().trim())) {
+				priceInfo.setPrice(goods.getPrices().get(0).getuSDPrice());
+			}
+
+			// 如果新旧价格不一样,则保存商品价格信息
+			if (priceInfo.getPrice() != priceInfo.getOldPrice()) {
+				commodityPriceInfoService.saveOrUpdate(priceInfo, deviceInfo);
+			}
+		} else if ("RMB-USD".equalsIgnoreCase(goods.getCurrencyName().trim())) {
+			Commodity findGoods = new Commodity();
+			String[] param = new String[] { "deliveryTime", "maxPrice", "minPrice", "tax", "rmbSegPriceList",
+					"usdSegPriceList" };
+			BeanUtils.copyProperties(goods, findGoods, param);
+			// 保存人民币的价格信息
+			findGoods.setCurrencyName("RMB");
+			CommodityPriceInfo priceInfoRMB = getGoodsPriceInfo(findGoods);
+			priceInfoRMB.setPrice(goods.getPrices().get(0).getrMBPrice());
+			// 如果新旧价格不一样,则保存商品价格信息
+			if (priceInfoRMB.getPrice() != priceInfoRMB.getOldPrice()) {
+				commodityPriceInfoService.saveOrUpdate(priceInfoRMB, deviceInfo);
+			}
+			// 保存美元的价格信息
+			findGoods.setCurrencyName("USD");
+			CommodityPriceInfo priceInfoUSD = getGoodsPriceInfo(findGoods);
+			priceInfoUSD.setPrice(goods.getPrices().get(0).getuSDPrice());
+			// 如果新旧价格不一样,则保存商品价格信息
+			if (priceInfoUSD.getPrice() != priceInfoUSD.getOldPrice()) {
+				commodityPriceInfoService.saveOrUpdate(priceInfoUSD, deviceInfo);
+			}
+		} else {
+			throw new IllegalOperatorException(
+					"[com.uas.platform.b2c.trade.service.impl.GoodsServiceImpl.saveOrUpdatePriceInfos]" + "暂不支持其他币种");
+		}
+
+	}
+
+
+	/**
+	 * 根据器件UUID、卖家UU、器件型号、币别、库存类型和税率检测商品信息是否存在
+	 * 若存在,则返回存在的商品价格信息,否则,返回添加器件和商品信息的GoodsPriceInfo对象
+	 *
+	 * @param goods
+	 *            商品信息
+	 * @return GoodsPriceInfo
+	 */
+	private CommodityPriceInfo getGoodsPriceInfo(Commodity goods) {
+		// 从价格库中查询价格信息
+		CommodityPriceInfo priceInfo = new CommodityPriceInfo(goods.getUuid(), goods.getEnUU(), goods.getCode(),
+				goods.getCurrencyName(), goods.getOriginal(), goods.getTax());
+		CommodityPriceInfo existPrice = commodityPriceInfoService.findByBasicInfo(priceInfo);
+
+		// 判断是否需要修改当前商品的价格库信息
+		if (existPrice != null) {
+			BeanUtils.copyProperties(existPrice, priceInfo);
+		}
+		// 更新器件和商品相关的信息
+		priceInfo.setImg(goods.getImg());
+		priceInfo.setBrandNameCn(goods.getBrandNameCn());
+		priceInfo.setKindNameCn(goods.getKindNameCn());
+		priceInfo.setUuid(goods.getUuid());
+		priceInfo.setMinBuyQty(goods.getMinBuyQty());
+		priceInfo.setMinPackQty(goods.getMinPackQty());
+		return priceInfo;
+	}
+
+
+	@Override
+	public Page<Commodity> findPageByStatus(final PageInfo pageInfo, String keyword, List<Long> publisherUUs) {
+		if (StringUtils.hasText(keyword)) {
+			int k = CollectionUtils.isEmpty(publisherUUs) ? 0 : publisherUUs.size();
+			SimpleExpression[] simpArrs = new SimpleExpression[5 + k];
+			for (int i = 0; i < k; i++) {
+				simpArrs[i] = new SimpleExpression("publisherUU", publisherUUs.get(i), Operator.EQ);
+			}
+			simpArrs[k] = new SimpleExpression("batchCode", keyword, Operator.LIKE, true);
+			simpArrs[k + 1] = new SimpleExpression("code", keyword, Operator.LIKE, true);
+			simpArrs[k + 2] = new SimpleExpression("kindNameCn", keyword, Operator.LIKE, true);
+			simpArrs[k + 3] = new SimpleExpression("brandNameCn", keyword, Operator.LIKE, true);
+			simpArrs[k + 4] = new SimpleExpression("currencyName", keyword, Operator.EQ, true);
+
+			LogicalExpression logical = new LogicalExpression(simpArrs, Operator.OR);
+			pageInfo.expression(logical);
+		}
+		Page<Commodity> pageGoods = commodityDao.findAll(new Specification<Commodity>() {
+			public Predicate toPredicate(Root<Commodity> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+				query.where(pageInfo.getPredicates(root, query, builder));
+				return null;
+			}
+		}, pageInfo);
+		return pageGoods;
+	}
+
+
+	@Override
+	public List<Commodity> findGoodsByUuid(String uuid) {
+		return commodityDao.findByUuid(uuid);
+	}
+
+	@Override
+	public List<CommoditySimple> findGoodsSimpleByUuid(String uuid) {
+		return commoditySimpleDao.findByUuid(uuid);
+	}
+
+	/**
+	 * 根据批次获取 Commodity
+	 *
+	 * @param batchCode
+	 * @return Commodity
+	 */
+	@Override
+	public Commodity findGoodsByBatchCode(String batchCode) {
+		if(StringUtils.isEmpty(batchCode)) {
+			return null;
+		}
+		return commodityDao.findByBatchCode(batchCode);
+	}
+}

+ 91 - 0
src/main/java/com/uas/cloud/mall/commodity/service/impl/CreateNumberServiceImpl.java

@@ -0,0 +1,91 @@
+package com.uas.cloud.mall.commodity.service.impl;
+
+
+import com.uas.cloud.mall.commodity.domain.CreateNumber;
+import com.uas.cloud.mall.commodity.repository.CreateNumberDao;
+import com.uas.cloud.mall.commodity.service.CreateNumberService;
+import com.uas.cloud.mall.commodity.util.DateFormatUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+@Service
+public class CreateNumberServiceImpl implements CreateNumberService {
+
+	private final CreateNumberDao createNumberDao;
+
+	@Autowired
+	public CreateNumberServiceImpl(CreateNumberDao createNumberDao) {
+		this.createNumberDao = createNumberDao;
+	}
+
+	@Override
+	public CreateNumber save(CreateNumber createNumber) {
+		return createNumberDao.save(createNumber);
+	}
+
+	@Override
+	public String getTimeNumber(String tbname, int digit, Integer... addNums) {
+		synchronized (tbname) {
+			// 1、找有没有用存这个表的
+			String time = getTime();
+			int num;
+			String timeNumber;
+			CreateNumber createNumber = createNumberDao.findByTbname(tbname);
+			if (createNumber == null) {
+				createNumber = new CreateNumber();
+				createNumber.setTbname(tbname);
+				createNumber.setTime(time);
+				num = 1;
+			} else {
+				// 2、检查时间是不是今天
+				if (time.equals(createNumber.getTime())) {
+					num = createNumber.getNumber() + 1;
+				} else {
+					num = 1;
+					createNumber.setTime(time);
+				}
+			}
+			if (addNums.length > 0) {
+				createNumber.setNumber(num + addNums[0] - 1);
+			} else {
+				createNumber.setNumber(num);
+			}
+			createNumberDao.save(createNumber);
+			timeNumber = createNumber.getTime() + formatIntToStr(num, digit);
+			return timeNumber;
+		}
+	}
+
+	/**
+	 * 获得8位时间
+	 */
+	private static String getTime() {
+		return DateFormatUtils.DATE_YMD_FORMAT.format(new Date());
+	}
+
+	/**
+	 * 
+	 * @param number
+	 *            需要被处理的数字
+	 * @param digit
+	 *            返回的位数
+	 */
+	private static String formatIntToStr(int number, int digit) {
+		String format = "%0" + String.valueOf(digit) + "d";
+		return String.format(format, number);
+	}
+	
+	
+	public String generateOrderNumber(String orderType, String table, int number) {
+		return orderType.replaceAll("_TIMESTAP_NUMBER", getTimeNumber(table, number));
+	}
+
+	@Override
+	public String generateVoucherId(String voucherType, String tableName, int number) {
+		String timeNumber = getTimeNumber(tableName, number);
+		return voucherType.replace("_TIMESTAP_NUMBER", timeNumber);
+	}
+
+}

+ 39 - 0
src/main/java/com/uas/cloud/mall/commodity/service/impl/PriceChangeLogServiceImpl.java

@@ -0,0 +1,39 @@
+package com.uas.cloud.mall.commodity.service.impl;
+
+import com.uas.cloud.mall.commodity.domain.PriceChangeLog;
+import com.uas.cloud.mall.commodity.repository.PriceChangeLogDao;
+import com.uas.cloud.mall.commodity.service.PriceChangeLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by John on 2017/3/2.
+ */
+@Service
+public class PriceChangeLogServiceImpl implements PriceChangeLogService {
+
+    private final PriceChangeLogDao priceChangeLogDao;
+
+    @Autowired
+    public PriceChangeLogServiceImpl(PriceChangeLogDao priceChangeLogDao) {
+        this.priceChangeLogDao = priceChangeLogDao;
+    }
+
+    /**
+     * 记录卖家商品价格变更记录
+     *
+     * @param agent 设备信息
+     * @param code 商品型号
+     * @param currencyName 币别
+     * @param original 库存类型
+     * @param tax 税率
+     * @param oldPrice 原价格
+     * @param price 新价格
+     * @param comment 备注
+     */
+    @Override
+    public void log(String agent, String code, String currencyName, Integer original, Short tax, Double oldPrice, Double priceInfoPrice, Float price, String comment) {
+        PriceChangeLog log = new PriceChangeLog(agent, code, currencyName, original, tax, oldPrice, priceInfoPrice, price, comment);
+        priceChangeLogDao.save(log);
+    }
+}

+ 700 - 0
src/main/java/com/uas/cloud/mall/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -0,0 +1,700 @@
+package com.uas.cloud.mall.commodity.service.impl;
+
+import com.uas.cloud.commons.domain.Enterprise;
+import com.uas.cloud.commons.domain.PageInfo;
+import com.uas.cloud.commons.exception.IllegalOperatorException;
+import com.uas.cloud.commons.support.SystemSession;
+import com.uas.cloud.mall.commodity.domain.Commodity;
+import com.uas.cloud.mall.commodity.domain.CommodityQtyPrice;
+import com.uas.cloud.mall.commodity.domain.ReleaseProductByBatch;
+import com.uas.cloud.mall.commodity.repository.CommonDao;
+import com.uas.cloud.mall.commodity.repository.CommodityDao;
+import com.uas.cloud.mall.commodity.repository.ReleaseProductByBatchDao;
+import com.uas.cloud.mall.commodity.service.CommodityService;
+import com.uas.cloud.mall.commodity.service.CreateNumberService;
+import com.uas.cloud.mall.commodity.service.ReleaseProductByBatchService;
+import com.uas.cloud.mall.commodity.service.ShopComponentService;
+import com.uas.cloud.mall.commodity.statusAndType.ReleaseStatus;
+import com.uas.cloud.mall.commodity.statusAndType.Type;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Created by John on 2017/3/2.
+ */
+@Service
+public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchService {
+
+    private final ReleaseProductByBatchDao releaseProductByBatchDao;
+
+    private final CommodityService goodsService;
+
+    private final CreateNumberService createNumberService;
+
+    private final CommodityDao goodsDao;
+
+    private final CommonDao commonDao;
+
+    private final ShopComponentService shopComponentService;
+
+    @Autowired
+    public ReleaseProductByBatchServiceImpl(ReleaseProductByBatchDao releaseProductByBatchDao, CommodityService goodsService, CreateNumberService createNumberService, CommodityDao goodsDao, CommonDao commonDao, ShopComponentService shopComponentService) {
+        this.releaseProductByBatchDao = releaseProductByBatchDao;
+        this.goodsService = goodsService;
+        this.createNumberService = createNumberService;
+        this.goodsDao = goodsDao;
+        this.commonDao = commonDao;
+        this.shopComponentService = shopComponentService;
+    }
+
+    /**
+     * 导入excel发布商品(大量)
+     *
+     * @author hejq
+     */
+    @Override
+    public ModelMap releaseByWorkbook(Workbook workbook) {
+        ModelMap modelMap = new ModelMap();
+        List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<ReleaseProductByBatch>();
+        Sheet sheet = workbook.getSheetAt(0);
+        int rowNum = sheet.getLastRowNum();
+        int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
+        if(colNum != 23) {
+            throw new IllegalOperatorException("您上传的信息列信息不正确,请与模板的列做比较");
+        }
+        Row headerRow = sheet.getRow(0);
+        String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);
+        int total = 0;
+        if (headerRow != null) {
+            Cell cellHead = headerRow.getCell(0);
+            Object readWorkBookCell = readWorkBookCell(cellHead, Cell.CELL_TYPE_STRING, 0, 0);
+            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
+            Matcher m = p.matcher(readWorkBookCell.toString());
+            String str = m.replaceAll("");
+            if(StringUtils.isEmpty(str) || !("中文产品品牌".equals(str))) {
+                throw new IllegalOperatorException("上传的文件信息第一列的表头为空,或第一列的表头名称不为中文产品品牌");
+            }
+            for (int r = 1; r <= rowNum; r++) {
+                Row row = sheet.getRow(r);
+                // 英文品牌名称
+                total++;
+                if (row != null && row.getCell(1) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
+                    ReleaseProductByBatch releaseProductByBatch = new ReleaseProductByBatch(batch);
+                    Cell cell = row.getCell(1);
+                    Object cellValue = readWorkBookCell(cell, Cell.CELL_TYPE_STRING, r, 1);
+                    if(StringUtils.isEmpty(cellValue) || "UAS1".equals(cellValue) || "UAS2".equals(cellValue)) {
+                        continue;
+                    }else {
+                        releaseProductByBatch.setBrandNameEn(String.valueOf(cellValue));
+                    }
+
+                    // 中文品牌名
+                    Object brandNameCnCellValue = readWorkBookCell(row.getCell(0), Cell.CELL_TYPE_STRING, r, 0);
+                    if("示例优软商城品牌1".equals(brandNameCnCellValue) || "示例优软商城品牌2".equals(brandNameCnCellValue)) {
+                        continue;
+                    }else {
+                        releaseProductByBatch.setBrandNameCn(String.valueOf(brandNameCnCellValue));
+                    }
+
+                    // 产品型号
+                    Object codeCellValue = readWorkBookCell(row.getCell(2), Cell.CELL_TYPE_STRING, r, 2);
+                    if(StringUtils.isEmpty(codeCellValue) || "B2C1".equals(brandNameCnCellValue) || "B2C2".equals(brandNameCnCellValue)) {
+                        continue;
+                    }else {
+                        releaseProductByBatch.setCode(codeCellValue.toString());
+                    }
+
+                    // 库存类型
+                    Object originialCellValue = readWorkBookCell(row.getCell(3), Cell.CELL_TYPE_STRING, r, 3);
+                    if (StringUtils.isEmpty(originialCellValue)
+                            || ((!"现货".equals(originialCellValue)) && (!"呆滞库存".equals(originialCellValue)))) {
+                        releaseProductByBatch.addErrmsg("4:库存类型为空,或者没有选择现货或者呆滞库存");
+                    } else {
+                        if ("现货".equals(originialCellValue)) {
+                            releaseProductByBatch.setOriginal(Type.Goods_Original_Code.value());
+                        } else if ("呆滞库存".equals(originialCellValue)) {
+                            releaseProductByBatch.setOriginal(Type.Goods_Inaction_Stock.value());
+                        }
+                    }
+
+                    // 发布库存量
+                    Double reserve = null;
+                    Object reserveCellValue = readWorkBookCell(row.getCell(4), Cell.CELL_TYPE_NUMERIC, r, 4);
+                    if (reserveCellValue == null || Double.valueOf(reserveCellValue.toString()).doubleValue() <= 0) {
+                        releaseProductByBatch.addErrmsg("5:发布数量为空或者小于等于0");
+                    } else {
+                        reserve = Double.valueOf(reserveCellValue.toString());
+                        int compareTo = reserve.compareTo(99999999d);
+                        if(compareTo > 0) {
+                            releaseProductByBatch.addErrmsg("5:发布数量大于了我们设置的最大值99999999");
+                        }
+                        releaseProductByBatch.setReserve(reserve);
+                    }
+
+                    Double sample = null;
+                    Object sampleObj = readWorkBookCell(row.getCell(5), Cell.CELL_TYPE_NUMERIC, r, 5);
+                    if (sampleObj != null) {
+                        sample = Double.valueOf(sampleObj.toString());
+                        if (sample <= 0) {
+                            // 这个是存在输入数据后再删除就会默认成0
+                            releaseProductByBatch.setSampleqty((double) 0);
+                        } else {
+                            releaseProductByBatch.setSampleqty(sample);
+                        }
+                    } else {
+                        // 这个是没有输入数据默认为null
+                        releaseProductByBatch.setMinPackage((double) 0);
+                    }
+
+                    // 最小起订量
+                    Object minBuyCellValue = readWorkBookCell(row.getCell(6), Cell.CELL_TYPE_NUMERIC, r, 6);
+                    if (minBuyCellValue != null) {
+                        Double minBuy = Double.valueOf(minBuyCellValue.toString());
+                        if (minBuy <= 0) {
+                            // 输入负数
+                            releaseProductByBatch.addErrmsg("6:最小起订量的数量不能是负数");
+                        } else {
+                            Double rel_reserve = releaseProductByBatch.getReserve() == null ? 0 : releaseProductByBatch.getReserve();
+                            int relVal = minBuy.compareTo(rel_reserve);
+                            if(relVal > 0) {
+                                releaseProductByBatch.setErrmsg("6:最小起订量的数量不能大于库存的数量");
+                            }
+                            releaseProductByBatch.setMinBuyQty(minBuy);
+                        }
+                    }else {
+                        releaseProductByBatch.addErrmsg("6:最小起订量的数量不可以为空");
+                    }
+
+                    // 最小包装量
+                    Object minPackQtyCellValue = readWorkBookCell(row.getCell(7), Cell.CELL_TYPE_NUMERIC, r, 7);
+                    if (minPackQtyCellValue != null) {
+                        Double minPackQty = Double.valueOf(minPackQtyCellValue.toString());
+                        if (minPackQty <= 0) {
+                            // 输入负数
+                            releaseProductByBatch.addErrmsg("7:最小包装量的数量不能是负数");
+                        } else {
+                            releaseProductByBatch.setMinPackage(minPackQty);
+                        }
+                    }else {
+                        releaseProductByBatch.addErrmsg("7:最小包装量不可以为空");
+                    }
+
+
+
+                    // 最小包单价(人民币)
+                    Object rmbPriceMinPackQtyCellValue = readWorkBookCell(row.getCell(8), Cell.CELL_TYPE_NUMERIC, r, 8);
+                    if (rmbPriceMinPackQtyCellValue != null) {
+                        Double rmbPrice = Double.valueOf(rmbPriceMinPackQtyCellValue.toString());
+                        releaseProductByBatch.setRmbMinPackPrice(rmbPrice);
+                    }
+
+                    // 最小包单价(美元)
+                    Object usdPriceMinPackQtyCellValue = readWorkBookCell(row.getCell(9), Cell.CELL_TYPE_NUMERIC, r, 9);
+                    if (usdPriceMinPackQtyCellValue != null) {
+                        Double usdPrice = Double.valueOf(usdPriceMinPackQtyCellValue.toString());
+                        releaseProductByBatch.setUsdMinPackPrice(usdPrice);
+                    }
+
+                    //确认币别
+                    comfirmCurrency(releaseProductByBatch);
+
+                    // 生产日期
+                    Object produceDateCellValue = readWorkBookCell(row.getCell(10), Integer.MAX_VALUE, r, 10);
+                    if (produceDateCellValue == null) {
+                        releaseProductByBatch.addErrmsg("10:产品生产日期不可以为空");
+                    } else {
+                        Date produceDate =  (Date) produceDateCellValue;
+                        int compareTo = produceDate.compareTo(new Date());
+                        if(compareTo > 0) {
+                            releaseProductByBatch.addErrmsg("10:产品生产日期不能早于今天");
+                        }
+                        releaseProductByBatch.setProductDate((Date)produceDateCellValue);
+                    }
+
+                    // 大陆交期
+                    if(releaseProductByBatch.getCurrency() != null && releaseProductByBatch.getCurrency().contains("RMB")) {
+                        Object deliveryCellValue = readWorkBookCell(row.getCell(11), Cell.CELL_TYPE_STRING, r, 11);
+                        setDemDeliveryTime(releaseProductByBatch, deliveryCellValue);
+                    }
+
+                    // 香港交期
+                    if(releaseProductByBatch.getCurrency() != null && releaseProductByBatch.getCurrency().contains("USD")) {
+                        Object deliveryhkCellValue = readWorkBookCell(row.getCell(12), Cell.CELL_TYPE_STRING, r, 12);
+                        setHKDeliveryTime(releaseProductByBatch ,deliveryhkCellValue);
+                    }
+
+                    if (releaseProductByBatch.getDeliveryDemTime() == null
+                            && releaseProductByBatch.getDeliveryHKTime() == null) {
+                        releaseProductByBatch.addErrmsg("11-12:大陆交期和香港交期至少填一种");
+                    }
+
+
+                    // 分段数量
+                    List<CommodityQtyPrice> prices = new ArrayList<CommodityQtyPrice>();
+                    Double[] priceMaxMinPrice = {Double.MAX_VALUE, Double.MIN_VALUE, Double.MAX_VALUE, Double.MIN_VALUE}; //最小人民币价格,最大人民币价格,最小美金价格,最大美金价格
+                    for (int i = 0; i < 3; i++) {
+                        // 起始量必须等于最小起定量
+                        readSectionPrice(row.getCell(13 + 3 * i), row.getCell(14 + 3 * i), row.getCell(15 + 3 * i),
+                                prices, releaseProductByBatch, r, (13 + 3 * i), priceMaxMinPrice);
+                    }
+                    //设置分段价格分段价格
+                    setSectionPrice(releaseProductByBatch, prices, priceMaxMinPrice);
+
+                    //设置最小最大价格
+                    setMinMaxPrices(releaseProductByBatch, priceMaxMinPrice);
+
+                    // 备注
+                    Object remarkCellValue = readWorkBookCell(row.getCell(22), Cell.CELL_TYPE_STRING, r, 21);
+                    if (!StringUtils.isEmpty(remarkCellValue)) {
+                        String remark = remarkCellValue.toString();
+                        releaseProductByBatch.setRemark(remark);
+                    }
+
+                    // 读取当前申请人信息
+                    releaseProductByBatch.setPublisherName(SystemSession.getUser().getUserName());
+                    releaseProductByBatch.setPublisherTel(SystemSession.getUser().getUserTel());
+                    releaseProductByBatch.setPublisherUu(SystemSession.getUser().getUserUU());
+
+                    releaseProductByBatch.setUnit("PCS");
+                    releaseProductByBatch.setCreateDate(new Date());
+                    releaseProductByBatchs.add(releaseProductByBatch);
+                }
+            }
+        }
+        commonDao.save(releaseProductByBatchs, ReleaseProductByBatch.class);
+        Long userUU = SystemSession.getUser().getUserUU();
+        releaseProductByBatchDao.callValidProcedure(userUU, batch);
+        Integer failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
+        Integer success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
+        modelMap.put("total", total);
+        modelMap.put("success", success);
+        modelMap.put("failure", failure);
+        modelMap.put("filter", total - failure - success);
+        modelMap.put("batch", batch);
+        return modelMap;
+    }
+
+    /**
+     * 设置当前的最小和最大价格
+     * @param releaseProductByBatch
+     * @param priceMaxMinPrice
+     */
+    private void setMinMaxPrices(ReleaseProductByBatch releaseProductByBatch, Double[] priceMaxMinPrice) {
+        if(!priceMaxMinPrice[0].equals(Double.MAX_VALUE)) {
+            releaseProductByBatch.setMinPriceRMB(priceMaxMinPrice[0]);
+        }
+        if(!priceMaxMinPrice[1].equals(Double.MIN_VALUE)) {
+            releaseProductByBatch.setMaxPriceRMB(priceMaxMinPrice[1]);
+        }
+        if(!priceMaxMinPrice[2].equals(Double.MAX_VALUE)) {
+            releaseProductByBatch.setMinPriceUSD(priceMaxMinPrice[2]);
+        }
+        if(!priceMaxMinPrice[3].equals(Double.MIN_VALUE)) {
+            releaseProductByBatch.setMaxPriceUSD(priceMaxMinPrice[3]);
+        }
+    }
+
+    /**
+     * 设置分段价格
+     * @param releaseProductByBatch
+     */
+    private void setSectionPrice(ReleaseProductByBatch releaseProductByBatch, List<CommodityQtyPrice> prices, Double[] priceMaxMinPrice) {
+        if (!CollectionUtils.isEmpty(prices)) {
+            double start = -1;
+            for (int j = 0; j < prices.size(); j++) {
+                CommodityQtyPrice price = prices.get(j);
+                if(j == 0) {
+                    int val = price.getStart().compareTo(releaseProductByBatch.getMinBuyQty());
+                    if(val != 0) {
+                        releaseProductByBatch.addErrmsg("13:第一个分段数量的起始值与最小起订量不相等");
+                    }
+                }
+
+                // 判断输入的后一个分段是否大于前一个分段
+                if (start < price.getStart()) {
+                    start = price.getStart();
+                } else {
+                    releaseProductByBatch.addErrmsg("13:分段数量起始值存在后一个分段的开始值小于前一个分段的开始值");
+                }
+
+                if (j < prices.size() - 1) {
+                    price.setEnd(prices.get(j + 1).getStart() - 1);
+                }
+                if (j == prices.size() - 1) {
+                    price.setEnd(releaseProductByBatch.getReserve());
+                }
+            }
+        } else {
+            // 如果未填分段价格,默认为最小包装量价格
+            CommodityQtyPrice qtyPrice = new CommodityQtyPrice();
+            qtyPrice.setStart(releaseProductByBatch.getMinBuyQty());
+            Double rmbMinPackPrice = releaseProductByBatch.getRmbMinPackPrice();
+            if (rmbMinPackPrice != null) {
+                qtyPrice.setrMBPrice(rmbMinPackPrice);
+                priceMaxMinPrice[0] = rmbMinPackPrice;
+                priceMaxMinPrice[1] = rmbMinPackPrice;
+            }
+            Double usdMinPackPrice = releaseProductByBatch.getUsdMinPackPrice();
+            if (usdMinPackPrice != null) {
+                qtyPrice.setuSDPrice(usdMinPackPrice);
+                priceMaxMinPrice[2] = usdMinPackPrice;
+                priceMaxMinPrice[3] = usdMinPackPrice;
+            }
+            qtyPrice.setEnd(releaseProductByBatch.getReserve());
+            prices.add(qtyPrice);
+        }
+        releaseProductByBatch.setPrices(prices);
+    }
+
+    /**
+     * 设置内地的交货周期
+     * @param releaseProductByBatch
+     * @param deliveryCellValue
+     */
+    private void setDemDeliveryTime(ReleaseProductByBatch releaseProductByBatch, Object deliveryCellValue) {
+        if (!StringUtils.isEmpty(deliveryCellValue)) {
+            Short[] delivers = splitDeliveryString(deliveryCellValue.toString());
+            if (delivers != null) {
+                releaseProductByBatch.setMindeliveryDemTime(delivers[0]);
+                releaseProductByBatch.setMaxdeliveryDemTime(delivers[1]);
+                // 以最大的时间设为交货周期
+                releaseProductByBatch.setDeliveryDemTime(delivers[1]);
+
+                Short maxdeliveryDemTime = releaseProductByBatch.getMaxdeliveryDemTime();
+                int compareTo = maxdeliveryDemTime.compareTo((short)30);
+                if(compareTo > 0) {
+                    releaseProductByBatch.setErrmsg("11:大陆交期的最大值超过了30天");
+                }
+
+                Short mindeliveryDemTime = releaseProductByBatch.getMindeliveryDemTime();
+                int compareTo2 = mindeliveryDemTime.compareTo((short)0);
+                if(compareTo2 < 0) {
+                    releaseProductByBatch.setErrmsg("11:大陆交期的最小值小于1");
+                }
+            }
+        }
+    }
+
+    /**
+     * 设置香港的交货周期
+     * @param releaseProductByBatch
+     * @param deliveryhkCellValue
+     */
+    private void setHKDeliveryTime(ReleaseProductByBatch releaseProductByBatch, Object deliveryhkCellValue) {
+        if (!StringUtils.isEmpty(deliveryhkCellValue)) {
+            Short[] deliverys = splitDeliveryString(deliveryhkCellValue.toString());
+            if (deliverys != null) {
+                releaseProductByBatch.setMindeliveryHKTime(deliverys[0]);
+                releaseProductByBatch.setMaxdeliveryHKTime(deliverys[1]);
+                releaseProductByBatch.setDeliveryHKTime(deliverys[1]);
+
+                Short maxdeliveryHKTime = releaseProductByBatch.getMaxdeliveryHKTime();
+                int compareTo = maxdeliveryHKTime.compareTo((short)30);
+                if(compareTo > 0) {
+                    releaseProductByBatch.setErrmsg("12:香港交期的最大值超过了30天");
+                }
+
+                Short mindeliveryHKTime = releaseProductByBatch.getMindeliveryHKTime();
+                int compareTo2 = mindeliveryHKTime.compareTo((short)0);
+                if(compareTo2 < 1) {
+                    releaseProductByBatch.setErrmsg("12:香港交期的最小值小于1");
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 根据价格确认币别
+     * @param releaseProductByBatch
+     */
+    private void comfirmCurrency(ReleaseProductByBatch releaseProductByBatch) {
+        // 确认币别
+        Double rmbMinPackPrice = releaseProductByBatch.getRmbMinPackPrice();
+        Double usdMinPackPrice = releaseProductByBatch.getUsdMinPackPrice();
+        if (rmbMinPackPrice == null && usdMinPackPrice == null) {
+            releaseProductByBatch.addErrmsg("8-9:最小包单价至少填一种价格");
+        } else if (rmbMinPackPrice != null && usdMinPackPrice == null) {
+            releaseProductByBatch.setCurrency("RMB");
+            releaseProductByBatch.setRmbTaxRate(0.17d);
+        } else if (rmbMinPackPrice == null && usdMinPackPrice != null) {
+            releaseProductByBatch.setCurrency("USD");
+            releaseProductByBatch.setUsdTaxRate(0d);
+        } else {
+            releaseProductByBatch.setCurrency("RMB-USD");
+            releaseProductByBatch.setRmbTaxRate(0.17d);
+            releaseProductByBatch.setUsdTaxRate(0d);
+        }
+    }
+
+    /**
+     * 创建时间 :20161211日 下午2:02:16
+     *
+     * @author yujia
+     * @param cell
+     * @param cellType
+     * @throws @Description:
+     *             传入单元格,类型,返回值
+     *
+     */
+    private Object readWorkBookCell(Cell cell, int cellType, int r, int n) {
+        Object obj = null;
+        try {
+            if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
+                switch (cellType) {
+                    case Cell.CELL_TYPE_STRING:
+                        cell.setCellType(Cell.CELL_TYPE_STRING);
+                        String str = cell.getStringCellValue().trim();
+                        if(str.indexOf("\u00A0")>0){
+                            str= str.replaceAll("\u00A0", "");
+                        }
+                        obj = str.trim();
+                        break;
+                    case Cell.CELL_TYPE_NUMERIC:
+                        cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+                        obj = cell.getNumericCellValue();
+                        break;
+                    default:
+                        if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
+                            String productTime = cell.getStringCellValue();
+                            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
+                            Matcher m = p.matcher(productTime);
+                            String time = m.replaceAll("");
+                            if(time.indexOf("\u00A0")>0){
+                                time= time.replaceAll("\u00A0", "");
+                            }
+                            DateFormat format1 = new SimpleDateFormat("yyyy/MM/dd");
+                            obj = format1.parse(time);
+                        }else if (HSSFDateUtil.isCellDateFormatted(cell)) {
+                            obj = cell.getDateCellValue();
+                        }
+                        break;
+                }
+            }
+        }catch (Exception e) {
+            throw new IllegalOperatorException("读取表格中"+r+"行"+ (n+1)+ "列的内容错误,有可能是该单元格的格式不正确");
+        }
+        return obj;
+    }
+
+
+    /**
+     * 创建时间 :20161211日 下午2:02:47
+     *
+     * @author yujia
+     * @return
+     * @return Short[]
+     * @throws @Description:
+     *             大陆交货和香港交货的
+     *
+     */
+    private Short[] splitDeliveryString(String delivery) {
+        Short[] shorts = null;
+        if (!StringUtils.isEmpty(delivery)) {
+            shorts = new Short[2];
+            String[] deliverys = delivery.split("~");
+            if (deliverys.length == 1) {
+                try {
+                    shorts[0] = Short.valueOf(deliverys[0].trim());
+                    shorts[1] = Short.valueOf(deliverys[0].trim());
+                } catch (Exception e) {
+                    // TODO: 如果转换失败,出错怎么办
+                }
+            } else {// 如果长度大于等于两个,取前面两个
+                try {
+                    shorts[0] = Short.valueOf(deliverys[0]);
+                    shorts[1] = Short.valueOf(deliverys[1]);
+                    Arrays.sort(shorts);
+                } catch (Exception e) {
+                    // TODO: 如果转换失败,出错怎么办
+                }
+            }
+        }
+        return shorts;
+    }
+    /**
+     * 创建时间 :20161212日 下午4:46:21
+     *
+     * @author yujia
+     * @param cellQty
+     * @param cellPriceRMB
+     * @param cellPriceUSD
+     * @param prices
+     * @param releaseProductByBatch
+     * @return void
+     * @throws @Description:
+     *             获取每一个分段的的数量
+     *
+     */
+    private void readSectionPrice(Cell cellQty, Cell cellPriceRMB, Cell cellPriceUSD, List<CommodityQtyPrice> prices,
+                                  ReleaseProductByBatch releaseProductByBatch, int r, int num, Double[] priceMaxMinPrice) {
+        // 先跟据币别判断对应的价格是否有空值
+        Object startQtyCellValue = readWorkBookCell(cellQty, Cell.CELL_TYPE_NUMERIC, r, num);
+        if (startQtyCellValue != null) {
+            Double start = Double.valueOf(startQtyCellValue.toString());
+            CommodityQtyPrice qtyPrice = new CommodityQtyPrice();
+            // 分段数量start不得大于库存量
+            if (start > releaseProductByBatch.getReserve() || start <= 0) {
+                releaseProductByBatch.addErrmsg("11: 分段数量存在起始值大于库存量或者开始数量小于0");
+            }
+            qtyPrice.setStart(start);
+
+            String currency = releaseProductByBatch.getCurrency();
+
+            // 人民币价格
+            if(currency != null && currency.contains("RMB")) {
+                Double pricermb = null;
+                Object pricermbReadWorkBookCellValue = readWorkBookCell(cellPriceRMB, Cell.CELL_TYPE_NUMERIC, r, num+1);
+                if (pricermbReadWorkBookCellValue != null) {
+                    pricermb = Double.valueOf(pricermbReadWorkBookCellValue.toString());
+                }
+                if (pricermb != null && pricermb > 0.0) {
+                    qtyPrice.setrMBPrice(pricermb);
+                    BigDecimal priceNum = new BigDecimal(pricermb);
+                    BigDecimal taxNum = new BigDecimal(releaseProductByBatch.getRmbTaxRate() + 1);
+                    qtyPrice.setrMBNTPrice(priceNum.divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
+                    if(priceMaxMinPrice[0] > pricermb) {
+                        priceMaxMinPrice[0] = pricermb;
+                    }
+                    if(priceMaxMinPrice[1] < pricermb) {
+                        priceMaxMinPrice[1] = pricermb;
+                    }
+                }
+            }
+
+            if(currency != null && currency.contains("USD")) {
+                // 美金价格
+                Double priceusd = null;
+                Object priceusdReadWorkBookCellValue = readWorkBookCell(cellPriceUSD, Cell.CELL_TYPE_NUMERIC, r, num+2);
+                if (priceusdReadWorkBookCellValue != null) {
+                    priceusd = Double.valueOf(priceusdReadWorkBookCellValue.toString());
+                }
+                if (priceusd != null && priceusd > 0) {
+                    qtyPrice.setuSDPrice(priceusd);
+                    qtyPrice.setuSDNTPrice(priceusd);
+                    if(priceMaxMinPrice[2] > priceusd) {
+                        priceMaxMinPrice[2] = priceusd;
+                    }
+                    if(priceMaxMinPrice[3] < priceusd) {
+                        priceMaxMinPrice[3] = priceusd;
+                    }
+                }
+            }
+
+            // 验证信息的一致性
+            Double rmbPrice = qtyPrice.getrMBPrice();
+            Double usdPrice = qtyPrice.getuSDPrice();
+
+            boolean isUnit = true;
+            if ("RMB".equalsIgnoreCase(currency)) {
+                if (rmbPrice == null) {
+                    isUnit = false;
+                }
+            } else if ("RMB-USD".equalsIgnoreCase(currency)) {
+                if (rmbPrice == null || usdPrice == null) {
+                    isUnit = false;
+                }
+            } else if ("USD".equalsIgnoreCase(currency)) {
+                if (usdPrice == null) {
+                    isUnit = false;
+                }
+            }
+            if (!isUnit) {
+                releaseProductByBatch.addErrmsg("11: 前后的价格信息不一致,例如最小包单价填了人民币和美金,后面的分段只填了人民币");
+            }
+
+            prices.add(qtyPrice);
+        }
+    }
+
+    @Override
+    public Set<String> publishByBatch(String batch) {
+        Enterprise enterprise = SystemSession.getUser().getEnterprise();
+        releaseProductByBatchDao.callPublishByBatch(enterprise.getUu(), enterprise.getEnName(), batch);
+        List<Commodity> goodsList = goodsDao.findByBatchid(batch);
+        Set<String> uuids = new HashSet<String>();
+        for (Commodity goods : goodsList) {
+            uuids.add(goods.getUuid());
+            goodsService.saveOrUpdatePriceInfos(goods, "NORMAL");
+        }
+        shopComponentService.saveShopComponent(goodsList);
+        return uuids;
+    }
+
+
+    /**
+     * 获取这次上架批次有误的信息
+     * @param batch
+     * @return
+     */
+    @Override
+    public List<ReleaseProductByBatch> findFailureReleaseProductByBatchByBatch(String batch) {
+        return releaseProductByBatchDao.findByPublisherUuAndRelbatchidAndReleaseCode(SystemSession.getUser().getUserUU(), batch, ReleaseStatus.failure.value());
+    }
+
+    /**
+     * 通过id删除产品信息
+     */
+    @Override
+    public void delete(Long id) {
+        if (releaseProductByBatchDao.exists(id)) {
+            releaseProductByBatchDao.delete(id);
+        }
+    }
+
+    /**
+     * 通过ids删除产品信息
+     */
+    @Override
+    public void delete(List<Long> ids) {
+        for (int i = 0; i < ids.size(); i++) {
+            if (releaseProductByBatchDao.exists(ids.get(i))) {
+                releaseProductByBatchDao.delete(ids.get(i));
+            }
+        }
+    }
+
+    /**
+     * 通过uu查询所有信息
+     */
+    @Override
+    public List<ReleaseProductByBatch> findByPublisheruu(Long publisheruu) {
+        List<ReleaseProductByBatch> releaseProductByBatchs = releaseProductByBatchDao.findByPublisherUu(publisheruu);
+        return releaseProductByBatchs;
+    }
+
+    @Override
+    public Page<ReleaseProductByBatch> getPageReleaseProductByBatch(final PageInfo info, String batch) {
+        info.filter("relbatchid", batch);
+        info.filter("releaseCode", ReleaseStatus.success.value());
+        return releaseProductByBatchDao.findAll(new Specification<ReleaseProductByBatch>() {
+
+            @Override
+            public Predicate toPredicate(Root<ReleaseProductByBatch> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+                query.where(info.getPredicates(root, query, cb));
+                return null;
+            }
+        }, info);
+    }
+}

+ 53 - 0
src/main/java/com/uas/cloud/mall/commodity/service/impl/ShopComponentServiceImpl.java

@@ -0,0 +1,53 @@
+package com.uas.cloud.mall.commodity.service.impl;
+
+import com.uas.cloud.commons.support.SystemSession;
+import com.uas.cloud.mall.commodity.domain.Commodity;
+import com.uas.cloud.mall.commodity.domain.ShopComponent;
+import com.uas.cloud.mall.commodity.repository.ShopComponentDao;
+import com.uas.cloud.mall.commodity.service.ShopComponentService;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by John on 2017/3/3.
+ */
+@Service
+public class ShopComponentServiceImpl implements ShopComponentService{
+
+    private final ShopComponentDao shopComponentDao;
+
+    @Autowired
+    public ShopComponentServiceImpl(ShopComponentDao shopComponentDao) {
+        this.shopComponentDao = shopComponentDao;
+    }
+
+    @Override
+    public List<ShopComponent> findByEnuuAndUuid(Long enuu, String uuid) {
+        return shopComponentDao.findByEnuuAndUuid(enuu, uuid);
+    }
+
+
+    /**
+     * commodities 保存 ShopComponent
+     * @param commodities
+     */
+    @Override
+    public void saveShopComponent(List<Commodity> commodities) {
+        Long enuu = SystemSession.getUser().getEnterprise().getUu();
+        String enName = SystemSession.getUser().getEnterprise().getEnName();
+        List<ShopComponent> scs = new ArrayList<ShopComponent>();
+        for (Commodity commodity : commodities) {
+            List<ShopComponent> shopComponents = shopComponentDao.findByEnuuAndUuid(enuu, commodity.getUuid());
+            if(CollectionUtils.isEmpty(shopComponents)) {
+                ShopComponent sc = new ShopComponent(enuu, enName, commodity.getCode(), commodity.getUuid());
+                scs.add(sc);
+            }
+
+        }
+        shopComponentDao.save(scs);
+    }
+}

+ 133 - 0
src/main/java/com/uas/cloud/mall/commodity/statusAndType/ReleaseStatus.java

@@ -0,0 +1,133 @@
+package com.uas.cloud.mall.commodity.statusAndType;
+
+public enum ReleaseStatus {
+	/**
+	 * {@code 101已发布}
+	 */
+	released(101, "已发布"),
+
+	/**
+	 * {@code 102未发布}
+	 */
+	unreleased(102, "未发布"),
+
+	/**
+	 * {@code 103品牌不存在}
+	 */
+	error_brand(103, "品牌不存在"),
+	/**
+	 * {@code 103器件不存在}
+	 */
+	error_component(104, "器件不存在"),
+	
+	/**
+	 * {@code 105 生产日期为空}
+	 */
+	error_productDate(105, "生产日期为空"),
+	
+	/**
+	 * {@code 106库存类型为空}
+	 */
+	error_origial(106, "库存类型为空"),
+	
+	/**
+	 * {@code 107 库存数量为空}
+	 */
+	error_reserve(107, "库存数量为空"),
+	
+	/**
+	 * {@code 108  最小包单价都为空}
+	 */
+	error_minPackPrice(108, "最小包单价都为空"),
+	
+	/**
+	 * {@code 109  交期都为空}
+	 */
+	error_deliveryTime(109, "交期都为空"),
+	
+	/**
+	 * {@code 110 价格信息不统一}
+	 */
+	error_priceNUnite(110, "价格信息不统一"),
+	
+	/**
+	 * {@code 1101 分段价格错误}
+	 */
+	error_sectionPrice(111, "分段价格错误"),
+
+	/**
+	 * {@code 112 匹配成功}
+	 */
+	success(112, "匹配成功"),
+	
+	/**
+	 * {@code 113  匹配失败}
+	 */
+	failure(113, "匹配失败");
+	/**
+	 * @param value
+	 *            发布状态
+	 *            <p>
+	 *            101<i>已发布</i>
+	 *            </p>
+	 *            <p>
+	 *            102<i>未发布</i>
+	 *            </p>
+	 *            <p>
+	 *            103<i>品牌不存在</i>
+	 *            </p>
+	 *            <p>
+	 *            104<i>器件不存在</i>
+	 *            </p>
+	 *            <p>
+	 *            105<i>匹配成功</i>
+	 *            </p>
+	 *
+	 */
+	private ReleaseStatus(int value, String phrase) {
+		this.value = value;
+		this.phrase = phrase;
+	}
+
+	private final int value;
+
+	private final String phrase;
+
+	/**
+	 * @return 发布状态的编码
+	 */
+	public int value() {
+		return this.value;
+	}
+
+	/**
+	 * @return 业务动作描述
+	 */
+	public String getPhrase() {
+		return this.phrase;
+	}
+
+	/**
+	 * @param statusCode
+	 *            状态的编码
+	 * @return 状态
+	 * @throws IllegalArgumentException
+	 *             如果statusCode不存在的话
+	 */
+	public static ReleaseStatus valueOf(int statusCode) {
+		for (ReleaseStatus status : values()) {
+			if (status.value == statusCode) {
+				return status;
+			}
+		}
+		throw new IllegalArgumentException("没有与编号 [" + statusCode + "]匹配的业务状态");
+	}
+
+	/**
+	 * 返回状态的编号
+	 */
+	@Override
+	public String toString() {
+		return Integer.toString(value);
+	}
+}

+ 69 - 0
src/main/java/com/uas/cloud/mall/commodity/statusAndType/Status.java

@@ -0,0 +1,69 @@
+package com.uas.cloud.mall.commodity.statusAndType;
+
+/**
+ * Created by John on 2017/3/2.
+ */
+public enum Status {
+
+    /**
+     * {@code 612 已下架}
+     */
+    REMOVED(612, "已下架"),
+
+    /**
+     * {@code 601  有效的}
+     */
+    AVAILABLE(601, "有效地"),
+
+    /**
+     * {@code 602 无效的(因库存不足而失效)}
+     */
+    UNAVAILABLE(602, "无效的(因库存不足而失效)");
+
+    private Status(int value, String phrase) {
+        this.value = value;
+        this.phrase = phrase;
+    }
+
+    private final int value;
+
+    private final String phrase;
+
+    /**
+     * @return 状态的整型编码
+     */
+    public int value() {
+        return this.value;
+    }
+
+    /**
+     * @return 状态的描述
+     */
+    public String getPhrase() {
+        return this.phrase;
+    }
+
+    /**
+     * @param statusCode
+     *            状态的编码
+     * @return 状态
+     * @throws IllegalArgumentException
+     *             如果statusCode不存在的话
+     */
+    public static Status valueOf(int statusCode) {
+        for (Status status : values()) {
+            if (status.value == statusCode) {
+                return status;
+            }
+        }
+        throw new IllegalArgumentException("没有与编号 [" + statusCode + "]匹配的状态");
+    }
+
+    /**
+     * 返回状态的编号
+     */
+    @Override
+    public String toString() {
+        return Integer.toString(value);
+    }
+}

+ 64 - 0
src/main/java/com/uas/cloud/mall/commodity/statusAndType/Type.java

@@ -0,0 +1,64 @@
+package com.uas.cloud.mall.commodity.statusAndType;
+
+/**
+ * Created by John on 2017/3/2.
+ */
+public enum Type {
+
+    /**
+     * {@code 1311 现货 <b>上架商品类型</b>}
+     */
+    Goods_Original_Code(1311, "现货"),
+
+    /**
+     * {@code 1312 呆滞库存 <b>上架商品类型</b>}
+     */
+    Goods_Inaction_Stock(1312, "呆滞库存");
+
+    private Type(int value, String phrase) {
+        this.value = value;
+        this.phrase = phrase;
+    }
+
+    private final int value;
+
+    private final String phrase;
+
+    /**
+     * @return 状态的整型编码
+     */
+    public int value() {
+        return this.value;
+    }
+
+    /**
+     * @return 状态的描述
+     */
+    public String getPhrase() {
+        return this.phrase;
+    }
+
+    /**
+     * @param statusCode
+     *            状态的编码
+     * @return 状态
+     * @throws IllegalArgumentException
+     *             如果statusCode不存在的话
+     */
+    public static Type valueOf(int statusCode) {
+        for (Type status : values()) {
+            if (status.value == statusCode) {
+                return status;
+            }
+        }
+        throw new IllegalArgumentException("没有与编号 [" + statusCode + "]匹配的状态");
+    }
+
+    /**
+     * 返回状态的编号
+     */
+    @Override
+    public String toString() {
+        return Integer.toString(value);
+    }
+}

+ 158 - 0
src/main/java/com/uas/cloud/mall/commodity/support/Entity.java

@@ -0,0 +1,158 @@
+package com.uas.cloud.mall.commodity.support;
+
+import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.lang.reflect.Field;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.*;
+
+public class Entity<T> {
+
+	private Table table;
+
+	private Map<String, Column> columns;
+
+	private List<Field> fields;
+	// 映射模型
+	private Class<T> targetCls;
+	// 映射关系
+	private ParameterizedPreparedStatementSetter<T> rowSetter;
+	// ID字段
+	private String idProperty;
+	// 表字段
+	private String insertProperties;
+
+	public Entity(final Class<T> targetCls) {
+		this.targetCls = targetCls;
+		this.table = targetCls.getAnnotation(Table.class);
+		Field[] _fields = this.targetCls.getDeclaredFields();
+		this.fields = new ArrayList<Field>();
+		this.columns = new HashMap<String, Column>();
+		List<String> _insertProperties = new ArrayList<String>();
+		for (Field field : _fields) {
+			if (!field.isAnnotationPresent(Transient.class) && hasSetterMethod(field, targetCls)) {
+				field.setAccessible(true);
+				this.fields.add(field);
+				String property = field.getName();
+				Column column = field.getAnnotation(Column.class);
+				if (null != column) {
+					this.columns.put(field.getName(), column);
+					property = StringUtils.isEmpty(column.name()) ? property : column.name();
+				}
+				if (field.isAnnotationPresent(Id.class)) {
+					idProperty = property;
+				}
+				_insertProperties.add(property);
+			}
+		}
+		insertProperties = StringUtils.collectionToDelimitedString(_insertProperties, ",");
+		this.rowSetter = new ParameterizedPreparedStatementSetter<T>() {
+
+			@Override
+			public void setValues(PreparedStatement ps, T argument) throws SQLException {
+				int i = 1;
+				for (Field field : fields) {
+					try {
+						Object val = field.get(argument);
+						if (null != val) {
+							if (field.getType().equals(Date.class)) {
+								val = new Timestamp(((Date) val).getTime());
+							}
+						}
+						ps.setObject(i++, val);
+					} catch (IllegalArgumentException e) {
+						e.printStackTrace();
+					} catch (IllegalAccessException e) {
+						e.printStackTrace();
+					}
+				}
+			}
+
+		};
+	}
+
+	/**
+	 * 有set方法
+	 * 
+	 * @param field
+	 * @param targetCls
+	 * @return
+	 */
+	private boolean hasSetterMethod(Field field, Class<?> targetCls) {
+		String setMethodName = "set" + StringUtils.capitalize(field.getName());
+		try {
+			targetCls.getMethod(setMethodName, field.getType());
+			return true;
+		} catch (Exception e) {
+			return false;
+		}
+	}
+
+	public Table getTable() {
+		return table;
+	}
+
+	public void setTable(Table table) {
+		this.table = table;
+	}
+
+	public Map<String, Column> getColumns() {
+		return columns;
+	}
+
+	public void setColumns(Map<String, Column> columns) {
+		this.columns = columns;
+	}
+
+	public Class<T> getTargetCls() {
+		return targetCls;
+	}
+
+	public void setTargetCls(Class<T> targetCls) {
+		this.targetCls = targetCls;
+	}
+
+	public String getTableName() {
+		return null == table ? this.targetCls.getSimpleName() : table.name();
+	}
+
+	public List<Field> getFields() {
+		return fields;
+	}
+
+	public void setFields(List<Field> fields) {
+		this.fields = fields;
+	}
+
+	public ParameterizedPreparedStatementSetter<T> getRowSetter() {
+		return rowSetter;
+	}
+
+	public void setRowSetter(ParameterizedPreparedStatementSetter<T> rowSetter) {
+		this.rowSetter = rowSetter;
+	}
+
+	public String getIdProperty() {
+		return idProperty;
+	}
+
+	public void setIdProperty(String idProperty) {
+		this.idProperty = idProperty;
+	}
+
+	public String getInsertProperties() {
+		return insertProperties;
+	}
+
+	public void setInsertProperties(String insertProperties) {
+		this.insertProperties = insertProperties;
+	}
+
+}

+ 33 - 0
src/main/java/com/uas/cloud/mall/commodity/support/EntityFactory.java

@@ -0,0 +1,33 @@
+package com.uas.cloud.mall.commodity.support;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class EntityFactory {
+
+	private static EntityFactory instance;
+
+	private Map<String, Entity<?>> entities;
+
+	private EntityFactory() {
+		entities = new HashMap<String, Entity<?>>();
+	}
+
+	public static EntityFactory getFactory() {
+		if (instance == null) {
+			instance = new EntityFactory();
+		}
+		return instance;
+	}
+
+	@SuppressWarnings("unchecked")
+	public <T> Entity<T> getEntity(Class<T> targetCls) {
+		Entity<?> entity = entities.get(targetCls.getName());
+		if (null == entity) {
+			entity = new Entity<T>(targetCls);
+			entities.put(targetCls.getName(), entity);
+		}
+		return (Entity<T>) entity;
+	}
+
+}

+ 95 - 0
src/main/java/com/uas/cloud/mall/commodity/support/JxlsExcelView.java

@@ -0,0 +1,95 @@
+package com.uas.cloud.mall.commodity.support;
+
+import com.uas.cloud.commons.support.SystemSession;
+import com.uas.cloud.commons.web.context.ContextUtils;
+import com.uas.cloud.mall.commodity.util.DateFormatUtils;
+import net.sf.jxls.transformer.XLSTransformer;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.LocalizedResourceHelper;
+import org.springframework.web.servlet.support.RequestContextUtils;
+import org.springframework.web.servlet.view.document.AbstractExcelView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URLEncoder;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * 利用jxls模板生成excel
+ * 
+ * @author yingp
+ * 
+ */
+public class JxlsExcelView extends AbstractExcelView {
+
+	/**
+	 * 最大导出行
+	 */
+	public final static int MAX_SIZE = 50000;
+
+	private String fileName;
+
+	private static final String EXTENSION = ".xls";
+
+	public JxlsExcelView(String tplPath, String fileName) {
+		super();
+		setUrl(tplPath);
+		this.fileName = fileName;
+	}
+
+	@Override
+	protected HSSFWorkbook getTemplateSource(String url, HttpServletRequest request) throws Exception {
+		LocalizedResourceHelper helper = new LocalizedResourceHelper(ContextUtils.getApplicationContext());
+		Locale userLocale = RequestContextUtils.getLocale(request);
+		Resource inputFile = helper.findLocalizedResource(url, EXTENSION, userLocale);
+		if (this.logger.isDebugEnabled()) {
+			this.logger.debug("Loading Excel workbook from " + inputFile);
+		}
+		POIFSFileSystem fs = new POIFSFileSystem(inputFile.getInputStream());
+		return new HSSFWorkbook(fs);
+	}
+
+	@Override
+	protected void buildExcelDocument(Map<String, Object> map, HSSFWorkbook workbook, HttpServletRequest request,
+			HttpServletResponse response) throws Exception {
+		if (map == null)
+			map = new HashMap<String, Object>();
+		map.put("export", new Export());
+		XLSTransformer transformer = new XLSTransformer();
+		transformer.transformWorkbook(workbook, map);
+		response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8") + EXTENSION);
+	}
+
+	public class Export {
+
+		private String date;
+		private String user;
+
+		public String getDate() {
+			return date;
+		}
+
+		public void setDate(String date) {
+			this.date = date;
+		}
+
+		public String getUser() {
+			return user;
+		}
+
+		public void setUser(String user) {
+			this.user = user;
+		}
+
+		public Export() {
+			this.user = SystemSession.getUser().getUserName();
+			this.date = DateFormatUtils.DATETIME_FORMAT.format(new Date());
+		}
+	}
+
+}

+ 13 - 0
src/main/java/com/uas/cloud/mall/commodity/util/DateFormatUtils.java

@@ -0,0 +1,13 @@
+package com.uas.cloud.mall.commodity.util;
+
+import org.apache.commons.lang3.time.FastDateFormat;
+
+public class DateFormatUtils {
+
+	public static final FastDateFormat DATETIME_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
+
+	public static final FastDateFormat DATE_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd");
+
+	public static final FastDateFormat DATE_YMD_FORMAT = FastDateFormat.getInstance("yyyyMMdd");
+
+}

+ 68 - 0
src/main/java/com/uas/cloud/mall/commodity/util/JacksonUtils.java

@@ -0,0 +1,68 @@
+package com.uas.cloud.mall.commodity.util;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * JSON 工具类
+ *
+ * history:
+ * Created by huxz on 2017-3-1 10:16:03
+ */
+public final class JacksonUtils {
+
+	private static ObjectMapper objectMapper;
+
+	/**
+	 * 把JSON文本parse为JavaBean
+	 */
+	public static <T> T fromJson(String text, Class<T> clazz) {
+		if (objectMapper == null) {
+			objectMapper = new ObjectMapper();
+		}
+		try {
+			return objectMapper.readValue(text, clazz);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 把JSON文本parse成JavaBean集合
+	 */
+	public static <T> List<T> fromJsonArray(String text, Class<T> clazz) {
+		if (objectMapper == null) {
+			objectMapper = new ObjectMapper();
+		}
+		JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, clazz);
+		try {
+			return objectMapper.readValue(text, javaType);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return Collections.emptyList();
+	}
+
+	/**
+	 * 将JavaBean序列化为JSON文本
+	 */
+	public static String toJson(Object object) {
+		if (objectMapper == null) {
+			objectMapper = new ObjectMapper();
+		}
+		try {
+			return objectMapper.writeValueAsString(object);
+		} catch (JsonProcessingException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+}

+ 85 - 0
src/main/java/com/uas/cloud/mall/commodity/util/JdbcUtil.java

@@ -0,0 +1,85 @@
+package com.uas.cloud.mall.commodity.util;
+
+import com.uas.cloud.commons.util.StringUtil;
+import com.uas.cloud.mall.commodity.support.Entity;
+import com.uas.cloud.mall.commodity.support.EntityFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter;
+
+import java.math.BigDecimal;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+public class JdbcUtil {
+
+	private static final EntityFactory factory = EntityFactory.getFactory();
+
+	public static <T> Entity<T> getEntity(Class<T> targetCls) {
+		return factory.getEntity(targetCls);
+	}
+
+	public static <T> String getTableName(Class<T> targetCls) {
+		return getEntity(targetCls).getTableName();
+	}
+
+	public static <T> ParameterizedPreparedStatementSetter<T> getRowSetter(Class<T> targetCls) {
+		return getEntity(targetCls).getRowSetter();
+	}
+	
+	/**
+	  * 创建时间 :2017110日 下午5:19:39
+	  * @author yujia
+	  * @param targets
+	  * @param targetCls
+	  * @param jdbcTemplate
+	  * @return void
+	  * @throws
+	  * @Description: 批量新增
+	  * 
+	  */
+	public static <T> void batchInsert(List<T> targets, Class<T> targetCls, JdbcTemplate jdbcTemplate) {
+		Entity<T> entity = getEntity(targetCls);
+		StringBuffer sql = new StringBuffer("insert into ").append(entity.getTableName()).append("(")
+				.append(entity.getInsertProperties()).append(") values (").append(StringUtil.repeat("?", entity.getFields().size(), ",")).append(")");
+		jdbcTemplate.batchUpdate(sql.toString(), targets, targets.size(), getRowSetter(targetCls));
+	}
+
+	public static Object getResultSetValue(ResultSet rs, String field, Class<?> requiredType) throws SQLException {
+		if (String.class.equals(requiredType)) {
+			return rs.getString(field);
+		} else if (boolean.class.equals(requiredType) || Boolean.class.equals(requiredType)) {
+			return rs.getBoolean(field);
+		} else if (byte.class.equals(requiredType) || Byte.class.equals(requiredType)) {
+			return rs.getByte(field);
+		} else if (short.class.equals(requiredType) || Short.class.equals(requiredType)) {
+			return rs.getShort(field);
+		} else if (int.class.equals(requiredType) || Integer.class.equals(requiredType)) {
+			return rs.getInt(field);
+		} else if (long.class.equals(requiredType) || Long.class.equals(requiredType)) {
+			return rs.getLong(field);
+		} else if (float.class.equals(requiredType) || Float.class.equals(requiredType)) {
+			return rs.getFloat(field);
+		} else if (double.class.equals(requiredType) || Double.class.equals(requiredType) || Number.class.equals(requiredType)) {
+			return rs.getDouble(field);
+		} else if (BigDecimal.class.equals(requiredType)) {
+			return rs.getBigDecimal(field);
+		} else if (java.sql.Date.class.equals(requiredType)) {
+			return rs.getDate(field);
+		} else if (java.sql.Time.class.equals(requiredType)) {
+			return rs.getTime(field);
+		} else if (java.sql.Timestamp.class.equals(requiredType) || java.util.Date.class.equals(requiredType)) {
+			return rs.getTimestamp(field);
+		} else if (byte[].class.equals(requiredType)) {
+			return rs.getBytes(field);
+		} else if (Blob.class.equals(requiredType)) {
+			return rs.getBlob(field);
+		} else if (Clob.class.equals(requiredType)) {
+			return rs.getClob(field);
+		}
+		return rs.getObject(field);
+	}
+
+}

+ 69 - 0
src/main/java/com/uas/cloud/mall/commodity/util/PageParams.java

@@ -0,0 +1,69 @@
+package com.uas.cloud.mall.commodity.util;
+
+import java.io.Serializable;
+
+public class PageParams implements Serializable {
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private int count;
+	private int page;
+	private String filter;
+	private String sorting;
+
+	public int getCount() {
+		return count;
+	}
+
+	public void setCount(int count) {
+		this.count = count;
+	}
+
+	public int getPage() {
+		return page;
+	}
+
+	public void setPage(int page) {
+		this.page = page;
+	}
+
+	public String getFilter() {
+		return filter;
+	}
+
+	public void setFilter(String filter) {
+		this.filter = filter;
+	}
+
+	public String getSorting() {
+		return sorting;
+	}
+
+	public void setSorting(String sorting) {
+		this.sorting = sorting;
+	}
+
+	public PageParams() {
+		super();
+	}
+
+	public PageParams(int count, int page, String filter, String sorting) {
+		super();
+		this.count = count;
+		this.page = page;
+		this.filter = filter;
+		this.sorting = sorting;
+	}
+
+	@Override
+	public String toString() {
+		return "PageParams{" +
+				"count=" + count +
+				", page=" + page +
+				", filter='" + filter + '\'' +
+				", sorting='" + sorting + '\'' +
+				'}';
+	}
+}

+ 25 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,25 @@
+server:
+  port: 20080
+
+eureka:
+  instance:
+    appname: mall-commodity-service
+    hostname: mall-commodity-service
+    preferIpAddress: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://localhost:1111/eureka/
+
+spring:
+  jpa:
+    properties:
+      hibernate:
+        hbm2ddl:
+          auto: update
+  datasource:
+    url: jdbc:oracle:thin:@192.168.253.6:1521:orcl
+    username: uuplatformdemo
+    password: selectuuplatform
+    driver-class-name: oracle.jdbc.driver.OracleDriver

+ 25 - 0
src/main/resources/application-prod.yml

@@ -0,0 +1,25 @@
+server:
+  port: 20080
+
+eureka:
+  instance:
+    appname: mall-commodity-service
+    hostname: mall-commodity-service
+    preferIpAddress: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://10.10.100.23:28000/eureka/
+
+spring:
+  jpa:
+    properties:
+      hibernate:
+        hbm2ddl:
+          auto: update
+  datasource:
+    url: jdbc:oracle:thin:@192.168.253.6:1521:orcl
+    username: uuplatformdemo
+    password: selectuuplatform
+    driver-class-name: oracle.jdbc.driver.OracleDriver

+ 25 - 0
src/main/resources/application-test.yml

@@ -0,0 +1,25 @@
+server:
+  port: 20080
+
+eureka:
+  instance:
+    appname: mall-commodity-service
+    hostname: mall-commodity-service
+    preferIpAddress: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://10.10.100.23:28000/eureka/
+
+spring:
+  jpa:
+    properties:
+      hibernate:
+        hbm2ddl:
+          auto: update
+  datasource:
+    url: jdbc:oracle:thin:@192.168.253.6:1521:orcl
+    username: uuplatformdemo
+    password: selectuuplatform
+    driver-class-name: oracle.jdbc.driver.OracleDriver

+ 5 - 0
src/main/resources/application.yml

@@ -0,0 +1,5 @@
+spring:
+  application:
+    name: mall-commodity-service
+  profiles:
+    active: dev

+ 11 - 0
src/test/java/com/uas/cloud/mall/commodity/parent/GoodsApplication.java

@@ -0,0 +1,11 @@
+package com.uas.cloud.mall.commodity.parent;
+
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest
+public abstract class GoodsApplication {
+
+}

+ 35 - 0
src/test/java/com/uas/cloud/mall/commodity/service/CommodityServiceTest.java

@@ -0,0 +1,35 @@
+package com.uas.cloud.mall.commodity.service;
+
+import com.uas.cloud.mall.commodity.domain.Commodity;
+import com.uas.cloud.mall.commodity.parent.GoodsApplication;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+public class CommodityServiceTest extends GoodsApplication {
+
+	@Autowired
+	private CommodityService commodityService;
+
+	@Test
+	public void findAllGoods() throws Exception {
+		List<Commodity> commodities = commodityService.findAllGoods();
+		System.out.println(commodities.size());
+		for(Commodity commodity : commodities) {
+			System.out.println(String.format("Goods[%d] uuid=%s batchCode=%s", commodity.getId(), commodity.getUuid(), commodity.getBatchCode()));
+		}
+	}
+
+	@Test
+	public void pageCommoditiesByEnInfos() throws Exception {
+		Pageable pageable = new PageRequest(0, 10);
+		Page<Commodity> commodities = commodityService.pageCommoditiesByEnInfos(10030994L, false, null, pageable);
+		System.out.println(commodities);
+		System.out.println(commodities.getClass()); // org.springframework.data.domain.PageImpl
+	}
+
+}