Browse Source

品牌产品数和品类产品数取值时间过滤更新

hejq 7 years ago
parent
commit
c02013f996

+ 24 - 11
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java

@@ -99,7 +99,6 @@ import com.uas.platform.b2c.trade.presale.model.GoodsBrowsingHistory;
 import com.uas.platform.b2c.trade.presale.model.TradeDeliveryDelayTime;
 import com.uas.platform.b2c.trade.presale.service.BrowsingHistoryService;
 import com.uas.platform.b2c.trade.presale.service.CartService;
-import com.uas.platform.b2c.trade.seek.utils.DateUtils;
 import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.b2c.trade.util.BoundedExecutor;
@@ -4067,13 +4066,20 @@ public class GoodsServiceImpl implements GoodsService {
     public com.uas.sso.support.Page<BrandCount> getBrandProductsCount(Pageable pageable, Date startTime, Date endTime) {
         java.sql.Date startDate = assignStartDate(startTime);
         java.sql.Date endDate = assignEndDate(endTime);
-        StringBuffer sql = new StringBuffer("select pr_brand as brand, count(1) as count from products where pr_brand is not null and pr_create_time between ? and ? group by pr_brand");
+        StringBuffer sql = new StringBuffer("select pr_brand as brand, count(1) as count from products where pr_brand is not null ");
+        if (null != startDate) {
+            sql.append(" and pr_create_time >= '").append(startDate).append("' ");
+        }
+        if (null != endDate) {
+            sql.append(" and pr_create_time < '").append(endDate).append("' ");
+        }
+        sql.append("group by pr_brand");
         StringBuffer countSql = new StringBuffer("select count(1) from (").append(sql).append(") as a");
-        Integer count = commonDao.queryForObject(countSql.toString(), Integer.class, startDate, endDate);
+        Integer count = commonDao.queryForObject(countSql.toString(), Integer.class);
         // 分页参数
         Integer offset = (pageable.getPageNumber() - 1) * pageable.getPageSize();
         sql.append(" limit ? offset ?");
-        List<BrandCount> brandCountList = commonDao.query(sql.toString(), BrandCount.class, startDate, endDate, pageable.getPageSize(), offset);
+        List<BrandCount> brandCountList = commonDao.query(sql.toString(), BrandCount.class, pageable.getPageSize(), offset);
         return new com.uas.sso.support.Page<>(pageable.getPageNumber(), pageable.getPageSize(), brandCountList, count);
     }
 
@@ -4086,7 +4092,7 @@ public class GoodsServiceImpl implements GoodsService {
     private java.sql.Date assignStartDate(Date startTime) {
         java.sql.Date startDate;
         if (null == startTime) {
-            startDate = new java.sql.Date(DateUtils.addTime(new Date(), -30, 0, 0, 0).getTime());
+            startDate = null;
         } else {
             startDate = new java.sql.Date(startTime.getTime());
         }
@@ -4105,12 +4111,12 @@ public class GoodsServiceImpl implements GoodsService {
         java.sql.Date endDate;
         // 截止时间+1天
         if (null == endTime) {
-            endDate = new java.sql.Date(System.currentTimeMillis());
+            endDate = null;
         } else {
             endDate = new java.sql.Date(endTime.getTime());
+            Integer addend = 60 * 60 * 24 * 1000;
+            endDate = new java.sql.Date(endDate.getTime() + addend);
         }
-        Integer addend = 60 * 60 * 24 * 1000;
-        endDate = new java.sql.Date(endDate.getTime() + addend);
         return endDate;
     }
 
@@ -4126,13 +4132,20 @@ public class GoodsServiceImpl implements GoodsService {
     public com.uas.sso.support.Page<KindHierarchicalCount> getKindProductsCount(Pageable pageable, Date startTime, Date endTime) {
         java.sql.Date startDate = assignStartDate(startTime);
         java.sql.Date endDate = assignEndDate(endTime);
-        StringBuffer sql = new StringBuffer("select pr_kind as thirdKind, pr_kindid as kindId, count(1) as count from products where pr_create_time between ? and ? group by pr_kind, pr_kindid");
+        StringBuffer sql = new StringBuffer("select pr_kind as thirdKind, pr_kindid as kindId, count(1) as count from products where pr_kind is not null ");
+        if (null != startDate) {
+            sql.append(" and pr_create_time >= '").append(startDate).append("' ");
+        }
+        if (null != endDate) {
+            sql.append(" and pr_create_time < '").append(endDate).append("' ");
+        }
+        sql.append("group by pr_kind, pr_kindid");
         StringBuffer countSql = new StringBuffer("select count(1) from (").append(sql).append(") as a");
-        Integer count = commonDao.queryForObject(countSql.toString(), Integer.class, startDate, endDate);
+        Integer count = commonDao.queryForObject(countSql.toString(), Integer.class);
         // 分页参数
         Integer offset = (pageable.getPageNumber() - 1) * pageable.getPageSize();
         sql.append(" limit ? offset ?");
-        List<KindHierarchicalCount> kindList = commonDao.query(sql.toString(), KindHierarchicalCount.class, startDate, endDate, pageable.getPageSize(), offset);
+        List<KindHierarchicalCount> kindList = commonDao.query(sql.toString(), KindHierarchicalCount.class, pageable.getPageSize(), offset);
         if (CollectionUtils.isNotEmpty(kindList)) {
             kindList.forEach(kind -> {
                 if (null != kind.getKindId()) {