xuhy
2023-05-17 566c44cc5712ab9c997424ee5a5438e0a81a016e
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java
@@ -154,9 +154,13 @@
    public void queryOtherInfo(List<TBranchOfficeResp> tBranchOfficeRespList) {
        List<TOrder> orders = tOrderMapper.selectList(new EntityWrapper<TOrder>());
        for (TBranchOfficeResp tBranchOfficeResp : tBranchOfficeRespList) {
            List<TOrder> orderList = orders.stream().filter(t -> tBranchOfficeResp.getId().equals(t.getBranchOfficeId())).collect(Collectors.toList());
            List<TUserToCoupon> tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>().eq("objectId", tBranchOfficeResp.getId())
                    .eq("roleType",2));
            if(!CollectionUtils.isEmpty(orderList)){
@@ -167,30 +171,29 @@
                // 优惠券数据,,,通过订单找到该区域的下单人,找出优惠券信息
                List<Integer> userIds = orderList.stream().map(TOrder::getUserId).collect(Collectors.toList());
                List<TUserToCoupon> tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>().eq("objectId", tBranchOfficeResp.getId())
                        .eq("roleType",2));
                // 优惠券有效数量
                int validCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getValidCount).sum();
                // 过期数量
                int expireCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getExpireCount).sum();
                // 总数量
                int totalCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getCouponTotal).sum();
                // 已使用优惠券;总数量减去有效数量
                tBranchOfficeResp.setUsedCount(totalCount-validCount-expireCount);
                // 已发放优惠券
                tBranchOfficeResp.setTotalCount(totalCount);
                BigDecimal orderPriceCount = new BigDecimal("0");
                // 累计优惠券金额
                for (TUserToCoupon tUserToCoupon : tUserToCoupons) {
                    TCoupon tCoupon = tCouponMapper.selectById(tUserToCoupon.getCouponId());
                    BigDecimal price = tCoupon.getCouponPreferentialAmount().multiply(new BigDecimal(tUserToCoupon.getCouponTotal()));
                    orderPriceCount = orderPriceCount.add(price);
                }
                tBranchOfficeResp.setOrderPriceCount(orderPriceCount);
            }
            // 优惠券有效数量
            int validCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getValidCount).sum();
            // 过期数量
            int expireCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getExpireCount).sum();
            // 总数量
            int totalCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getCouponTotal).sum();
            // 已使用优惠券;总数量减去有效数量
            tBranchOfficeResp.setUsedCount(totalCount-validCount-expireCount);
            // 已发放优惠券
            tBranchOfficeResp.setTotalCount(totalCount);
            BigDecimal orderPriceCount = new BigDecimal("0");
            // 累计优惠券金额
            for (TUserToCoupon tUserToCoupon : tUserToCoupons) {
                TCoupon tCoupon = tCouponMapper.selectById(tUserToCoupon.getCouponId());
                BigDecimal price = tCoupon.getCouponPreferentialAmount().multiply(new BigDecimal(tUserToCoupon.getCouponTotal()));
                orderPriceCount = orderPriceCount.add(price);
            }
            tBranchOfficeResp.setOrderPriceCount(orderPriceCount);
            // 司机数量
            Integer driverCount = tDriverMapper.selectCount(new EntityWrapper<TDriver>().eq("branchOfficeId", tBranchOfficeResp.getId()));
            tBranchOfficeResp.setDriverCount(driverCount);