Explorar el Código

Merge remote-tracking branch 'origin/dev-mysql' into cartPopPositionError

hangb hace 8 años
padre
commit
169e3c13c6

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/product/common/CommonTask.java

@@ -29,7 +29,7 @@ public class CommonTask {
     public void updateCount() {
     public void updateCount() {
         List<CommonCount> commonCounts = commonCountDao.findByStatus((short) 1);
         List<CommonCount> commonCounts = commonCountDao.findByStatus((short) 1);
         for (CommonCount commonCount : commonCounts) {
         for (CommonCount commonCount : commonCounts) {
-            commonCount.setCount(jdbcTemplate.queryForLong(commonCount.getSql()));
+            commonCount.setCount(jdbcTemplate.queryForObject(commonCount.getSql(), Double.class));
         }
         }
         commonCountDao.save(commonCounts);
         commonCountDao.save(commonCounts);
     }
     }

+ 15 - 3
src/main/java/com/uas/platform/b2c/prod/product/common/api/CommonCountController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -55,11 +56,22 @@ public class CommonCountController {
      * @return
      * @return
      */
      */
     @RequestMapping(value ="/{id}/count", method = RequestMethod.GET)
     @RequestMapping(value ="/{id}/count", method = RequestMethod.GET)
-    public Long findCountById(@PathVariable("id") Long id) {
+    public String findCountById(@PathVariable("id") Long id) {
         CommonCount commonCount = commonCountService.findById(id);
         CommonCount commonCount = commonCountService.findById(id);
-        if(commonCount == null)
+        if(commonCount == null && commonCount.getCount() != null)
             throw new IllegalArgumentException("参数ID错误,数据不存在");
             throw new IllegalArgumentException("参数ID错误,数据不存在");
-        return commonCount.getCount();
+
+        String result = "";
+        Double countdb = commonCount.getCount();
+        if (countdb % 1.0 == 0) {
+            result = String.valueOf(countdb.longValue());
+        } else {
+            BigDecimal count = new BigDecimal(countdb);
+            BigDecimal dividenum = new BigDecimal(1);
+            result = count.divide(dividenum, 3, BigDecimal.ROUND_HALF_UP).toString();
+        }
+
+        return result;
     }
     }
 
 
 }
 }

+ 3 - 3
src/main/java/com/uas/platform/b2c/prod/product/common/model/CommonCount.java

@@ -46,7 +46,7 @@ public class CommonCount implements Serializable{
      * 数量
      * 数量
      */
      */
     @Column(name = "cc_count")
     @Column(name = "cc_count")
-    private Long count;
+    private Double count;
 
 
     /**
     /**
      * 应用
      * 应用
@@ -92,11 +92,11 @@ public class CommonCount implements Serializable{
         this.sql = sql;
         this.sql = sql;
     }
     }
 
 
-    public Long getCount() {
+    public Double getCount() {
         return count;
         return count;
     }
     }
 
 
-    public void setCount(Long count) {
+    public void setCount(Double count) {
         this.count = count;
         this.count = count;
     }
     }
 
 

+ 1 - 1
src/main/webapp/resources/js/common/controllers/commonCtrls.js

@@ -105,7 +105,7 @@ define([ 'app/app' ], function(app) {
 				return AuthenticationService.getAuthentication().success(function(data) {
 				return AuthenticationService.getAuthentication().success(function(data) {
 					if(data && data.enterprises) {
 					if(data && data.enterprises) {
 						//data.enterprise = data.enterprises[data.enterprises.length - 1];
 						//data.enterprise = data.enterprises[data.enterprises.length - 1];
-						if(data.enterprises.length > 1) {
+						if(data.enterprises.length > 0) {
 							var enSelect = [];
 							var enSelect = [];
 							angular.forEach(data.enterprises, function(e){
 							angular.forEach(data.enterprises, function(e){
 								if(e.current)
 								if(e.current)