Commit 3abfeea8 authored by Junling Bu's avatar Junling Bu
Browse files

修复商品排序问题

parent d2a561f3
......@@ -32,8 +32,6 @@ public class WxCartController {
private LitemallGoodsSpecificationService goodsSpecificationService;
@Autowired
private LitemallAddressService addressService;
@Autowired
private LitemallCouponService apiCouponService;
/**
* 购物车
......
......@@ -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;
/**
......
......@@ -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);
......
......@@ -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,
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment