ソースを参照

修复商品排序问题

Junling Bu 7 年 前
コミット
3abfeea8de
45 ファイル変更142 行追加184 行削除
  1. 4 5
      litemall-admin/src/views/goods/comment.vue
  2. 2 1
      litemall-admin/src/views/goods/list.vue
  3. 2 1
      litemall-admin/src/views/mall/brand.vue
  4. 2 1
      litemall-admin/src/views/mall/category.vue
  5. 2 1
      litemall-admin/src/views/mall/issue.vue
  6. 2 1
      litemall-admin/src/views/mall/keyword.vue
  7. 2 1
      litemall-admin/src/views/mall/order.vue
  8. 1 2
      litemall-admin/src/views/mall/region.vue
  9. 2 1
      litemall-admin/src/views/promotion/ad.vue
  10. 2 1
      litemall-admin/src/views/promotion/topic.vue
  11. 2 1
      litemall-admin/src/views/sys/admin.vue
  12. 2 1
      litemall-admin/src/views/sys/os.vue
  13. 2 1
      litemall-admin/src/views/user/address.vue
  14. 2 1
      litemall-admin/src/views/user/collect.vue
  15. 2 1
      litemall-admin/src/views/user/footprint.vue
  16. 2 1
      litemall-admin/src/views/user/history.vue
  17. 2 1
      litemall-admin/src/views/user/user.vue
  18. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdService.java
  19. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAddressService.java
  20. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdminService.java
  21. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java
  22. 7 2
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java
  23. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCategoryService.java
  24. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCollectService.java
  25. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java
  26. 0 7
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCouponService.java
  27. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallFootprintService.java
  28. 0 25
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsAttributeService.java
  29. 18 17
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java
  30. 0 34
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsSpecificationService.java
  31. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallIssueService.java
  32. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallKeywordService.java
  33. 5 1
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderService.java
  34. 0 25
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallProductService.java
  35. 6 1
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallRegionService.java
  36. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallSearchHistoryService.java
  37. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallStorageService.java
  38. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java
  39. 4 0
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallUserService.java
  40. 0 33
      litemall-db/src/main/java/org/linlinjava/litemall/db/util/SortUtil.java
  41. 0 2
      litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java
  42. 0 3
      litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java
  43. 3 8
      litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java
  44. 6 2
      litemall-wx/pages/hotGoods/hotGoods.js
  45. 6 2
      litemall-wx/pages/newGoods/newGoods.js

+ 4 - 5
litemall-admin/src/views/goods/comment.vue

@@ -111,7 +111,8 @@ export default {
         limit: 20,
         userId: undefined,
         valueId: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,
@@ -119,8 +120,7 @@ export default {
         valueId: undefined,
         content: undefined,
         hasPicture: false,
-        picUrls: [],
-        addTime: undefined
+        picUrls: []
       },
       dialogFormVisible: false,
       dialogStatus: '',
@@ -170,8 +170,7 @@ export default {
         userId: undefined,
         valueId: undefined,
         content: undefined,
-        picUrls: [],
-        addTime: undefined
+        picUrls: []
       }
     },
     handleCreate() {

+ 2 - 1
litemall-admin/src/views/goods/list.vue

@@ -139,7 +139,8 @@ export default {
         limit: 20,
         goodsSn: undefined,
         name: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/mall/brand.vue

@@ -120,7 +120,8 @@ export default {
         limit: 20,
         id: undefined,
         name: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/mall/category.vue

@@ -156,7 +156,8 @@ export default {
         limit: 20,
         id: undefined,
         name: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       catL1: {},
       dataForm: {

+ 2 - 1
litemall-admin/src/views/mall/issue.vue

@@ -70,7 +70,8 @@ export default {
         page: 1,
         limit: 20,
         question: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/mall/keyword.vue

@@ -102,7 +102,8 @@ export default {
         limit: 20,
         keyword: undefined,
         url: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/mall/order.vue

@@ -116,7 +116,8 @@ export default {
         limit: 20,
         id: undefined,
         name: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       shipForm: {
         orderId: undefined,

+ 1 - 2
litemall-admin/src/views/mall/region.vue

@@ -58,8 +58,7 @@ export default {
         page: 1,
         limit: 20,
         name: undefined,
-        code: undefined,
-        sort: '+id'
+        code: undefined
       },
       downloadLoading: false
     }

+ 2 - 1
litemall-admin/src/views/promotion/ad.vue

@@ -128,7 +128,8 @@ export default {
         limit: 20,
         name: undefined,
         content: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/promotion/topic.vue

@@ -131,7 +131,8 @@ export default {
         limit: 20,
         title: undefined,
         subtitle: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/sys/admin.vue

@@ -99,7 +99,8 @@ export default {
         page: 1,
         limit: 20,
         username: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/sys/os.vue

@@ -85,7 +85,8 @@ export default {
         limit: 20,
         key: undefined,
         name: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       createDialogVisible: false,
       dataForm: {

+ 2 - 1
litemall-admin/src/views/user/address.vue

@@ -117,7 +117,8 @@ export default {
         limit: 20,
         name: undefined,
         userId: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       provinces: {},
       cities: {},

+ 2 - 1
litemall-admin/src/views/user/collect.vue

@@ -80,7 +80,8 @@ export default {
         limit: 20,
         userId: undefined,
         valueId: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/user/footprint.vue

@@ -80,7 +80,8 @@ export default {
         limit: 20,
         userId: undefined,
         goodsId: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/user/history.vue

@@ -79,7 +79,8 @@ export default {
         limit: 20,
         userId: undefined,
         keyword: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 2 - 1
litemall-admin/src/views/user/user.vue

@@ -148,7 +148,8 @@ export default {
         limit: 20,
         username: undefined,
         mobile: undefined,
-        sort: '+id'
+        sort: 'add_time',
+        order: 'desc'
       },
       dataForm: {
         id: undefined,

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdService.java

@@ -33,6 +33,10 @@ public class LitemallAdService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, limit);
         return adMapper.selectByExample(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAddressService.java

@@ -63,6 +63,10 @@ public class LitemallAddressService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, limit);
         return addressMapper.selectByExample(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdminService.java

@@ -32,6 +32,10 @@ public class LitemallAdminService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+        
         PageHelper.startPage(page, limit);
         return adminMapper.selectByExampleSelective(example, result);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java

@@ -44,6 +44,10 @@ public class LitemallBrandService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return brandMapper.selectByExample(example);
     }

+ 7 - 2
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java

@@ -5,6 +5,7 @@ import org.linlinjava.litemall.db.dao.LitemallCartMapper;
 import org.linlinjava.litemall.db.domain.LitemallCart;
 import org.linlinjava.litemall.db.domain.LitemallCartExample;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.util.List;
@@ -77,14 +78,18 @@ public class LitemallCartService {
         LitemallCartExample example = new LitemallCartExample();
         LitemallCartExample.Criteria criteria = example.createCriteria();
 
-        if(userId != null){
+        if(!StringUtils.isEmpty(userId)){
             criteria.andUserIdEqualTo(userId);
         }
-        if(goodsId != null){
+        if(!StringUtils.isEmpty(goodsId)){
             criteria.andGoodsIdEqualTo(goodsId);
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, limit);
         return cartMapper.selectByExample(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCategoryService.java

@@ -63,6 +63,10 @@ public class LitemallCategoryService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return categoryMapper.selectByExample(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCollectService.java

@@ -61,6 +61,10 @@ public class LitemallCollectService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return collectMapper.selectByExample(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java

@@ -83,6 +83,10 @@ public class LitemallCommentService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return commentMapper.selectByExample(example);
     }

+ 0 - 7
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCouponService.java

@@ -1,7 +0,0 @@
-package org.linlinjava.litemall.db.service;
-
-import org.springframework.stereotype.Service;
-
-@Service
-public class LitemallCouponService {
-}

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallFootprintService.java

@@ -53,6 +53,10 @@ public class LitemallFootprintService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return footprintMapper.selectByExample(example);
     }

+ 0 - 25
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsAttributeService.java

@@ -20,31 +20,6 @@ public class LitemallGoodsAttributeService {
         return goodsAttributeMapper.selectByExample(example);
     }
 
-    public List<LitemallGoodsAttribute> querySelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
-        LitemallGoodsAttributeExample example = new LitemallGoodsAttributeExample();
-        LitemallGoodsAttributeExample.Criteria criteria = example.createCriteria();
-
-        if(goodsId != null){
-            criteria.andGoodsIdEqualTo(goodsId);
-        }
-        criteria.andDeletedEqualTo(false);
-
-        PageHelper.startPage(page, size);
-        return goodsAttributeMapper.selectByExample(example);
-    }
-
-    public int countSelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
-        LitemallGoodsAttributeExample example = new LitemallGoodsAttributeExample();
-        LitemallGoodsAttributeExample.Criteria criteria = example.createCriteria();
-
-        if(goodsId != null){
-            criteria.andGoodsIdEqualTo(goodsId);
-        }
-        criteria.andDeletedEqualTo(false);
-
-        return (int)goodsAttributeMapper.countByExample(example);
-    }
-
     public void updateById(LitemallGoodsAttribute goodsAttribute) {
         goodsAttributeMapper.updateByPrimaryKeySelective(goodsAttribute);
     }

+ 18 - 17
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java

@@ -58,31 +58,32 @@ public class LitemallGoodsService {
         return (int)goodsMapper.countByExample(example);
     }
 
-    public List<LitemallGoods> querySelective(Integer catId, Integer brandId, String keyword, Integer isHot, Integer isNew, Integer offset, Integer limit, String sort) {
+    public List<LitemallGoods> querySelective(Integer catId, Integer brandId, String keyword, Boolean isHot, Boolean isNew, Integer offset, Integer limit, String sort, String order) {
         LitemallGoodsExample example = new LitemallGoodsExample();
         LitemallGoodsExample.Criteria criteria = example.createCriteria();
 
-        if(catId != null && catId != 0){
+        if(!StringUtils.isEmpty(catId) && catId != 0){
             criteria.andCategoryIdEqualTo(catId);
         }
-        if(brandId != null){
+        if(!StringUtils.isEmpty(brandId)){
             criteria.andBrandIdEqualTo(brandId);
         }
-        if(isNew != null){
-            criteria.andIsNewEqualTo(isNew.intValue() == 1);
+        if(!StringUtils.isEmpty(isNew)){
+            criteria.andIsNewEqualTo(isNew);
         }
-        if(isHot != null){
-            criteria.andIsHotEqualTo(isHot.intValue() == 1);
+        if(!StringUtils.isEmpty(isHot)){
+            criteria.andIsHotEqualTo(isHot);
         }
-        if(keyword != null){
+        if(!StringUtils.isEmpty(keyword)){
             criteria.andKeywordsLike("%" + keyword + "%");
         }
         criteria.andDeletedEqualTo(false);
 
-        if(sort != null){
-            example.setOrderByClause(sort);
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
         }
-        if(limit != null && offset != null) {
+
+        if(!StringUtils.isEmpty(limit) && !StringUtils.isEmpty(offset)) {
             PageHelper.startPage(offset, limit);
         }
 
@@ -90,7 +91,7 @@ public class LitemallGoodsService {
         return goodsMapper.selectByExampleSelective(example ,columns);
     }
 
-    public int countSelective(Integer catId, Integer brandId, String keyword, Integer isHot, Integer isNew, Integer offset, Integer limit, String sort) {
+    public int countSelective(Integer catId, Integer brandId, String keyword, Boolean isHot, Boolean isNew, Integer offset, Integer limit, String sort, String order) {
         LitemallGoodsExample example = new LitemallGoodsExample();
         LitemallGoodsExample.Criteria criteria = example.createCriteria();
 
@@ -101,10 +102,10 @@ public class LitemallGoodsService {
             criteria.andBrandIdEqualTo(brandId);
         }
         if(isNew != null){
-            criteria.andIsNewEqualTo(isNew.intValue() == 1);
+            criteria.andIsNewEqualTo(isNew);
         }
         if(isHot != null){
-            criteria.andIsHotEqualTo(isHot.intValue() == 1);
+            criteria.andIsHotEqualTo(isHot);
         }
         if(keyword != null){
             criteria.andKeywordsLike("%" + keyword + "%");
@@ -182,7 +183,7 @@ public class LitemallGoodsService {
         return (int)goodsMapper.countByExample(example);
     }
 
-    public List<Integer> getCatIds(Integer brandId, String keyword, Integer isHot, Integer isNew) {
+    public List<Integer> getCatIds(Integer brandId, String keyword, Boolean isHot, Boolean isNew) {
         LitemallGoodsExample example = new LitemallGoodsExample();
         LitemallGoodsExample.Criteria criteria = example.createCriteria();
 
@@ -190,10 +191,10 @@ public class LitemallGoodsService {
             criteria.andBrandIdEqualTo(brandId);
         }
         if(isNew != null){
-            criteria.andIsNewEqualTo(isNew.intValue() == 1);
+            criteria.andIsNewEqualTo(isNew);
         }
         if(isHot != null){
-            criteria.andIsHotEqualTo(isHot.intValue() == 1);
+            criteria.andIsHotEqualTo(isHot);
         }
         if(keyword != null){
             criteria.andKeywordsLike("%" + keyword + "%");

+ 0 - 34
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsSpecificationService.java

@@ -27,31 +27,6 @@ public class LitemallGoodsSpecificationService {
         return goodsSpecificationMapper.selectByPrimaryKey(id);
     }
 
-    public List<LitemallGoodsSpecification> querySelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
-        LitemallGoodsSpecificationExample example = new LitemallGoodsSpecificationExample();
-        LitemallGoodsSpecificationExample.Criteria criteria = example.createCriteria();
-
-        if(goodsId != null){
-            criteria.andGoodsIdEqualTo(goodsId);
-        }
-        criteria.andDeletedEqualTo(false);
-
-        PageHelper.startPage(page, size);
-        return goodsSpecificationMapper.selectByExample(example);
-    }
-
-    public int countSelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
-        LitemallGoodsSpecificationExample example = new LitemallGoodsSpecificationExample();
-        LitemallGoodsSpecificationExample.Criteria criteria = example.createCriteria();
-
-        if(goodsId != null){
-            criteria.andGoodsIdEqualTo(goodsId);
-        }
-        criteria.andDeletedEqualTo(false);
-
-        return (int)goodsSpecificationMapper.countByExample(example);
-    }
-
     public void updateById(LitemallGoodsSpecification goodsSpecification) {
         goodsSpecificationMapper.updateByPrimaryKeySelective(goodsSpecification);
     }
@@ -70,15 +45,6 @@ public class LitemallGoodsSpecificationService {
         goodsSpecificationMapper.insertSelective(goodsSpecification);
     }
 
-    public Integer[] queryIdsByGid(Integer goodsId) {
-        List<LitemallGoodsSpecification> goodsSpecificationList = queryByGid(goodsId);
-        Integer[] ids = new Integer[goodsSpecificationList.size()];
-        for(int i = 0; i < ids.length; i++){
-            ids[i] = goodsSpecificationList.get(i).getId();
-        }
-        return ids;
-    }
-
     private class VO {
         private String name;
         private List<LitemallGoodsSpecification> valueList;

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallIssueService.java

@@ -38,6 +38,10 @@ public class LitemallIssueService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return issueMapper.selectByExample(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallKeywordService.java

@@ -53,6 +53,10 @@ public class LitemallKeywordService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, limit);
         return keywordsMapper.selectByExample(example);
     }

+ 5 - 1
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderService.java

@@ -75,7 +75,7 @@ public class LitemallOrderService {
 
     public List<LitemallOrder> queryByOrderStatus(Integer userId, List<Short> orderStatus) {
         LitemallOrderExample example = new LitemallOrderExample();
-        example.orderBy(LitemallOrder.Column.addTime.desc());
+        example.setOrderByClause(LitemallOrder.Column.addTime.desc());
         LitemallOrderExample.Criteria criteria = example.or();
         criteria.andUserIdEqualTo(userId);
         if(orderStatus != null) {
@@ -112,6 +112,10 @@ public class LitemallOrderService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return orderMapper.selectByExample(example);
     }

+ 0 - 25
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallProductService.java

@@ -24,31 +24,6 @@ public class LitemallProductService {
         return productMapper.selectByPrimaryKey(id);
     }
 
-    public List<LitemallProduct> querySelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
-        LitemallProductExample example = new LitemallProductExample();
-        LitemallProductExample.Criteria criteria = example.createCriteria();
-
-        if(goodsId != null){
-            criteria.andGoodsIdEqualTo(goodsId);
-        }
-        criteria.andDeletedEqualTo(false);
-
-        PageHelper.startPage(page, size);
-        return productMapper.selectByExample(example);
-    }
-
-    public int countSelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
-        LitemallProductExample example = new LitemallProductExample();
-        LitemallProductExample.Criteria criteria = example.createCriteria();
-
-        if(goodsId != null){
-            criteria.andGoodsIdEqualTo(goodsId);
-        }
-        criteria.andDeletedEqualTo(false);
-
-        return (int)productMapper.countByExample(example);
-    }
-
     public void updateById(LitemallProduct product) {
         productMapper.updateByPrimaryKeySelective(product);
     }

+ 6 - 1
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallRegionService.java

@@ -32,9 +32,14 @@ public class LitemallRegionService {
         if(!StringUtils.isEmpty(name)){
             criteria.andNameLike("%" + name + "%");
         }
-        if(code != null){
+        if(!StringUtils.isEmpty(code)){
             criteria.andCodeEqualTo(code);
         }
+
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return regionMapper.selectByExample(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallSearchHistoryService.java

@@ -57,6 +57,10 @@ public class LitemallSearchHistoryService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return searchHistoryMapper.selectByExample(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallStorageService.java

@@ -58,6 +58,10 @@ public class LitemallStorageService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, limit);
         return storageMapper.selectByExample(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java

@@ -66,6 +66,10 @@ public class LitemallTopicService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, limit);
         return topicMapper.selectByExampleWithBLOBs(example);
     }

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallUserService.java

@@ -44,6 +44,10 @@ public class LitemallUserService {
         }
         criteria.andDeletedEqualTo(false);
 
+        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+            example.setOrderByClause(sort + " " + order);
+        }
+
         PageHelper.startPage(page, size);
         return userMapper.selectByExample(example);
     }

+ 0 - 33
litemall-db/src/main/java/org/linlinjava/litemall/db/util/SortUtil.java

@@ -1,33 +0,0 @@
-package org.linlinjava.litemall.db.util;
-
-public class SortUtil {
-    public static final String goodsSort(String sort, String order){
-        if(sort == null){
-            return null;
-        }
-
-        String sortWithOrder = "";
-        if(sort.equalsIgnoreCase("price")){
-            sortWithOrder = "retail_price";
-        }
-        else if(sort.equalsIgnoreCase("default") || sort.equalsIgnoreCase("category")){
-            return null;
-        }
-        else{
-            return null;
-        }
-
-        if(order == null) {
-            return sortWithOrder;
-        }
-
-        if(order.equalsIgnoreCase("asc")){
-            sortWithOrder += " ASC";
-        }
-        else if(order.equalsIgnoreCase("DESC")){
-            sortWithOrder += " DESC";
-        }
-
-        return sortWithOrder;
-    }
-}

+ 0 - 2
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java

@@ -32,8 +32,6 @@ public class WxCartController {
     private LitemallGoodsSpecificationService goodsSpecificationService;
     @Autowired
     private LitemallAddressService addressService;
-    @Autowired
-    private LitemallCouponService apiCouponService;
 
     /**
      * 购物车

+ 0 - 3
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java

@@ -3,7 +3,6 @@ package org.linlinjava.litemall.wx.web;
 import org.apache.commons.lang3.ObjectUtils;
 import org.linlinjava.litemall.db.domain.LitemallComment;
 import org.linlinjava.litemall.db.service.LitemallCommentService;
-import org.linlinjava.litemall.db.service.LitemallCouponService;
 import org.linlinjava.litemall.db.service.LitemallUserService;
 import org.linlinjava.litemall.core.util.ResponseUtil;
 import org.linlinjava.litemall.wx.annotation.LoginUser;
@@ -26,8 +25,6 @@ public class WxCommentController {
     @Autowired
     private LitemallUserService userService;
     @Autowired
-    private LitemallCouponService couponService;
-    @Autowired
     private UserInfoService userInfoService;
 
     /**

+ 3 - 8
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java

@@ -5,7 +5,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.linlinjava.litemall.db.domain.*;
 import org.linlinjava.litemall.db.service.*;
-import org.linlinjava.litemall.db.util.SortUtil;
 import org.linlinjava.litemall.core.util.ResponseUtil;
 import org.linlinjava.litemall.wx.annotation.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -48,8 +47,6 @@ public class WxGoodsController {
     @Autowired
     private LitemallSearchHistoryService searchHistoryService;
     @Autowired
-    private LitemallCouponService apiCouponService;
-    @Autowired
     private LitemallCartService cartService;
     @Autowired
     private LitemallGoodsSpecificationService goodsSpecificationService;
@@ -229,14 +226,12 @@ public class WxGoodsController {
      *   失败则 { errno: XXX, errmsg: XXX }
      */
     @GetMapping("list")
-    public Object list(Integer categoryId, Integer brandId, String keyword, Integer isNew, Integer isHot,
+    public Object list(Integer categoryId, Integer brandId, String keyword, Boolean isNew, Boolean isHot,
                        @LoginUser Integer userId,
                        @RequestParam(value = "page", defaultValue = "1") Integer page,
                        @RequestParam(value = "size", defaultValue = "10") Integer size,
                        String sort, String order) {
 
-        String sortWithOrder = SortUtil.goodsSort(sort, order);
-
         //添加到搜索历史
         if (userId != null && !StringUtils.isNullOrEmpty(keyword)) {
             LitemallSearchHistory searchHistoryVo = new LitemallSearchHistory();
@@ -248,8 +243,8 @@ public class WxGoodsController {
         }
 
         //查询列表数据
-        List<LitemallGoods> goodsList = goodsService.querySelective(categoryId, brandId, keyword, isHot, isNew, page, size, sortWithOrder);
-        int total = goodsService.countSelective(categoryId, brandId, keyword, isHot, isNew, page, size, sortWithOrder);
+        List<LitemallGoods> goodsList = goodsService.querySelective(categoryId, brandId, keyword, isHot, isNew, page, size, sort, order);
+        int total = goodsService.countSelective(categoryId, brandId, keyword, isHot, isNew, page, size, sort, order);
 
         // 查询商品所属类目列表。
         List<Integer> goodsCatIds = goodsService.getCatIds(brandId, keyword, isHot, isNew);

+ 6 - 2
litemall-wx/pages/hotGoods/hotGoods.js

@@ -13,6 +13,7 @@ Page({
     goodsList: [],
     categoryId: 0,
     currentSortType: 'default',
+    currentSort: 'add_time',
     currentSortOrder: 'desc',
     page: 1,
     size: 100
@@ -42,7 +43,7 @@ Page({
   getGoodsList: function (){
     var that = this;
 
-    util.request(api.GoodsList, { isHot: 1, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSortType, categoryId: that.data.categoryId})
+    util.request(api.GoodsList, { isHot: true, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSort, categoryId: that.data.categoryId})
       .then(function (res) {
         if (res.errno === 0) {
           that.setData({
@@ -80,7 +81,8 @@ Page({
         this.setData({
           categoryFilter: !this.data.categoryFilter,
           currentSortType: 'category',
-          currentSortOrder: 'asc'
+          currentSort: 'add_time',
+          currentSortOrder: 'desc'
         });
         break;
       case 'priceSort':
@@ -90,6 +92,7 @@ Page({
         }
         this.setData({
           currentSortType: 'price',
+          currentSort: 'retail_price',
           currentSortOrder: tmpSortOrder,
           categoryFilter: false
         });
@@ -100,6 +103,7 @@ Page({
         //综合排序
         this.setData({
           currentSortType: 'default',
+          currentSort: 'add_time',
           currentSortOrder: 'desc',
           categoryFilter: false,
           categoryId: 0,

+ 6 - 2
litemall-wx/pages/newGoods/newGoods.js

@@ -13,6 +13,7 @@ Page({
     goodsList: [],
     categoryId: 0,
     currentSortType: 'default',
+    currentSort: 'add_time',
     currentSortOrder: 'desc',
     page: 1,
     size: 100
@@ -30,7 +31,7 @@ Page({
   getGoodsList: function() {
     var that = this;
 
-    util.request(api.GoodsList, { isNew: 1, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSortType, categoryId: that.data.categoryId })
+    util.request(api.GoodsList, { isNew: true, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSort, categoryId: that.data.categoryId })
       .then(function (res) {
         if (res.errno === 0) {
           that.setData({
@@ -67,7 +68,8 @@ Page({
         this.setData({
           categoryFilter: !this.data.categoryFilter,
           currentSortType: 'category',
-          currentSortOrder: 'asc'
+          currentSort: 'add_time',
+          currentSortOrder: 'desc'
         });
         break;
       case 'priceSort':
@@ -77,6 +79,7 @@ Page({
         }
         this.setData({
           currentSortType: 'price',
+          currentSort: 'retail_price',
           currentSortOrder: tmpSortOrder,
           categoryFilter: false
         });
@@ -87,6 +90,7 @@ Page({
         //综合排序
         this.setData({
           currentSortType: 'default',
+          currentSort: 'add_time',
           currentSortOrder: 'desc',
           categoryFilter: false,
           categoryId: 0