From ae01f50b73e0089f414499937cb52fed907155c6 Mon Sep 17 00:00:00 2001 From: wayn <1669738430@qq.com> Date: Tue, 18 Aug 2020 00:01:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=95=86=E5=9F=8E):=20=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=20=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=90=84=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/OrderController.java | 6 +++ .../mobile/api/service/IOrderService.java | 6 +++ .../api/service/impl/OrderServiceImpl.java | 43 ++++++++++++++++--- 3 files changed, 48 insertions(+), 7 deletions(-) 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("处理成功!")); } - }