diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderController.java index 008285b..a29243a 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderController.java @@ -26,6 +26,12 @@ public class OrderController extends BaseController { return iOrderService.selectListPage(page, showType); } + @PostMapping("statusCount") + public R statusCount() { + return iOrderService.statusCount(); + } + + @PostMapping("submit") public R submit(@RequestBody OrderVO orderVO) { return iOrderService.submit(orderVO); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/service/IOrderService.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/service/IOrderService.java index 3d98931..c1f1779 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/service/IOrderService.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/service/IOrderService.java @@ -64,4 +64,10 @@ public interface IOrderService extends IService { * @return r */ R payNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 查询用户订单各状态数量(包含待支付、代发货、待收货、待评价) + * @return r + */ + R statusCount(); } diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/service/impl/OrderServiceImpl.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/service/impl/OrderServiceImpl.java index 4968ede..808829f 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/service/impl/OrderServiceImpl.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/service/impl/OrderServiceImpl.java @@ -130,6 +130,36 @@ public class OrderServiceImpl extends ServiceImpl implements return R.success().add("data", orderVoList).add("pages", orderIPage.getPages()).add("page", orderIPage.getCurrent()); } + @Override + public R statusCount() { + R success = R.success(); + Long userId = SecurityUtils.getUserId(); + List orderList = list(new QueryWrapper().select("order_status", "comments").eq("user_id", userId)); + int unpaid = 0; + int unship = 0; + int unrecv = 0; + int uncomment = 0; + for (Order order : orderList) { + if (OrderUtil.isCreateStatus(order)) { + unpaid++; + } else if (OrderUtil.isPayStatus(order)) { + unship++; + } else if (OrderUtil.isShipStatus(order)) { + unrecv++; + } else if (OrderUtil.isConfirmStatus(order) || OrderUtil.isAutoConfirmStatus(order)) { + uncomment += order.getComments(); + } else { + // todo + } + } + success.add("unpaid", unpaid); + success.add("unship", unship); + success.add("unrecv", unrecv); + success.add("uncomment", uncomment); + return success; + } + + @Override @Transactional(rollbackFor = Exception.class) public R submit(OrderVO orderVO) { @@ -158,28 +188,28 @@ public class OrderServiceImpl extends ServiceImpl implements } // 商品费用 - BigDecimal checkedGoodsPrice = new BigDecimal(0.00); + BigDecimal checkedGoodsPrice = new BigDecimal("0.00"); for (Cart checkGoods : checkedGoodsList) { checkedGoodsPrice = checkedGoodsPrice.add(checkGoods.getPrice().multiply(new BigDecimal(checkGoods.getNumber()))); } // 根据订单商品总价计算运费,满足条件(例如88元)则免运费,否则需要支付运费(例如8元); - BigDecimal freightPrice = new BigDecimal(0.00); + BigDecimal freightPrice = new BigDecimal("0.00"); /*if (checkedGoodsPrice.compareTo(SystemConfig.getFreightLimit()) < 0) { freightPrice = SystemConfig.getFreight(); }*/ // 可以使用的其他钱,例如用户积分 - BigDecimal integralPrice = new BigDecimal(0.00); + BigDecimal integralPrice = new BigDecimal("0.00"); // 优惠卷抵扣费用 - BigDecimal couponPrice = new BigDecimal(0.00); + BigDecimal couponPrice = new BigDecimal("0.00"); // 团购抵扣费用 - BigDecimal grouponPrice = new BigDecimal(0.00); + BigDecimal grouponPrice = new BigDecimal("0.00"); // 订单费用 - BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice).max(new BigDecimal(0.00)); + BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice).max(new BigDecimal("0.00")); // 最终支付费用 BigDecimal actualPrice = orderTotalPrice.subtract(integralPrice); @@ -394,5 +424,4 @@ public class OrderServiceImpl extends ServiceImpl implements return R.error(WxPayNotifyResponse.success("处理成功!")); } - }