diff --git a/ruoyi-api/src/main/java/com/ruoyi/app/modular/member/controller/UserController.java b/ruoyi-api/src/main/java/com/ruoyi/app/modular/member/controller/UserController.java index 53c2ff0..6149bba 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/app/modular/member/controller/UserController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/app/modular/member/controller/UserController.java @@ -23,6 +23,9 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; //import wiki.xsx.core.handler.StringHandler; //import wiki.xsx.core.util.RedisUtil; @@ -53,13 +56,19 @@ public class UserController { User user = userOperator.getUser(); StoreMember member = memberService.getById(user.getId()); MemberDTO memberDTO = memberMapper.toDto(member); + Map mapCount = orderService.countInfo(user.getId()); + memberDTO.setCountInfo(mapCount); return R.success(memberDTO); } @GetMapping(value = "/shop/user-my-address") @ApiOperation(value = "我的地址列表",notes = "我的地址列表") - public R addressList(@Validated @RequestBody PageVO pageVO){ + public R addressList(@RequestParam(value = "page",defaultValue = "0") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ int userId = userOperator.getUser().getId(); + PageVO pageVO = new PageVO(); + pageVO.setPage(page); + pageVO.setLimit(limit); return R.success(addressService.getList(pageVO,userId)); } @@ -97,8 +106,12 @@ public class UserController { @GetMapping(value = "/shop/user-my-collects") @ApiOperation(value = "我的收藏列表",notes = "我的收藏列表") - public R myCollect(@Validated @RequestBody PageVO pageVO){ + public R myCollect(@RequestParam(value = "page",defaultValue = "0") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ int userId = userOperator.getUser().getId(); + PageVO pageVO = new PageVO(); + pageVO.setPage(page); + pageVO.setLimit(limit); return R.success(goodsMapper.toDto(goodsService .collectGoods(pageVO.getPage(),pageVO.getLimit(),userId))); } diff --git a/ruoyi-api/src/main/java/com/ruoyi/app/modular/member/service/dto/MemberDTO.java b/ruoyi-api/src/main/java/com/ruoyi/app/modular/member/service/dto/MemberDTO.java index 505dca3..40a58b4 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/app/modular/member/service/dto/MemberDTO.java +++ b/ruoyi-api/src/main/java/com/ruoyi/app/modular/member/service/dto/MemberDTO.java @@ -6,6 +6,7 @@ import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; +import java.util.Map; @Data @@ -74,6 +75,8 @@ public class MemberDTO implements Serializable { */ private Integer status; + private Map countInfo; + diff --git a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/IndexController.java b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/IndexController.java index 15ed752..d5b6178 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/IndexController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/IndexController.java @@ -64,9 +64,10 @@ public class IndexController { @GetMapping("/shop/news-lists") @ApiOperation(value = "新闻列表",notes = "新闻列表") - public R news(@Validated @RequestBody PageVO pageVO){ + public R news(@RequestParam(value = "page",defaultValue = "0") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ - List newsList = newsService.getList(pageVO.getPage(),pageVO.getLimit()); + List newsList = newsService.getList(page,limit); return R.success(newsList); } diff --git a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/MallController.java b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/MallController.java index fcdba36..b2a5b62 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/MallController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/MallController.java @@ -44,15 +44,15 @@ public class MallController { @GetMapping("/shop/mall-lists") @ApiOperation(value = "商品分类模块列表",notes = "商品分类模块列表") - public R lists(@Validated @RequestBody PageVO pageVO){ + public R lists(@RequestParam(value = "page",defaultValue = "0") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ int userId = userOperator.getUser().getId(); List goodsCates = cateService.getList(); List recommedGoods = goodsService.getList(0, - pageVO.getPage(),pageVO.getLimit(),userId,"",1); - List newGoods = goodsService.getList(0,pageVO.getPage(), - pageVO.getLimit(),userId,"",2); + page,limit,userId,"",1); + List newGoods = goodsService.getList(0,page,limit,userId,"",2); - List collectGoods = goodsMapper.toDto(goodsService.collectGoods(pageVO.getPage(),pageVO.getLimit(),userId)); + List collectGoods = goodsMapper.toDto(goodsService.collectGoods(page,limit,userId)); Map map = new HashMap<>(); map.put("goodsCates",goodsCates); @@ -149,9 +149,13 @@ public class MallController { @GetMapping("/shop/mall-cart-list") @ApiOperation(value = "获取购物车列表",notes = "获取购物车列表") - public R cartList(@Validated @RequestBody PageVO pageVO){ + public R cartList(@RequestParam(value = "page",defaultValue = "0") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ int userId = userOperator.getUser().getId(); //goodsService.cartList(pageVO,userId); + PageVO pageVO = new PageVO(); + pageVO.setPage(page); + pageVO.setLimit(limit); return R.success(goodsService.cartList(pageVO,userId)); } diff --git a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/IOrderService.java b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/IOrderService.java index 74be6c6..a454430 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/IOrderService.java +++ b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/IOrderService.java @@ -12,6 +12,7 @@ import com.ruoyi.app.modular.shop.service.vo.PageVO; import java.util.List; +import java.util.Map; public interface IOrderService extends IService { @@ -32,4 +33,6 @@ public interface IOrderService extends IService { public List pointsMoneyLogs(int type, int userId, int page,int limit); + public Map countInfo(int userId); + } diff --git a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/impl/OrderServiceImpl.java b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/impl/OrderServiceImpl.java index 068bc1c..6cfcb82 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/impl/OrderServiceImpl.java +++ b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/impl/OrderServiceImpl.java @@ -32,10 +32,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; @Service @@ -418,4 +415,38 @@ public class OrderServiceImpl extends ServiceImpl return list; } + + @Override + public Map countInfo(int userId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("deleted",0).eq("user_id",userId).eq("pay_status",0); + int unpayCount = count(wrapper); + + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq("deleted",0).eq("user_id",userId) + .eq("pay_status",1).eq("shipping_status",0); + int undeliverCount = count(wrapper1); + + QueryWrapper wrapper2 = new QueryWrapper<>(); + wrapper2.eq("deleted",0).eq("user_id",userId) + .eq("shipping_status",1).eq("order_status",0); + int deliveringCount = count(wrapper2); + + QueryWrapper wrapper3 = new QueryWrapper<>(); + wrapper3.eq("deleted",0).eq("user_id",userId) + .eq("shipping_status",1).eq("order_status",1); + int unevalCount = count(wrapper3); + + QueryWrapper wrapper4 = new QueryWrapper<>(); + wrapper4.eq("deleted",0).eq("user_id",userId).gt("shipping_status",1); + int returnCount = count(wrapper4); + + Map map = new HashMap<>(); + map.put("unpayCount",unpayCount); + map.put("undeliverCount",undeliverCount); + map.put("deliveringCount",deliveringCount); + map.put("unevalCount",unevalCount); + map.put("returnCount",returnCount); + return map; + } }