luodangjia
2024-11-01 be1ab2eb2032a747a409fb765ec90f76c3116c51
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -196,6 +196,7 @@
                payOrderInfoDto.setPayAmount(byId.getPaymentAmount());
                payOrderInfoDto.setPayTime(byId.getCreateTime());
                payOrderInfoDto.setRefundAmount(byId.getRefundAmount());
                payOrderInfoDto.setRechargeAmount(byId.getRechargeAmount());
                return R.ok(payOrderInfoDto);
            case 2:
                TShoppingOrder byId1 = shoppingOrderService.getById(orderId);
@@ -207,6 +208,7 @@
                payOrderInfoDto1.setPayAmount(byId1.getPaymentAmount());
                payOrderInfoDto1.setPayTime(byId1.getCreateTime());
                payOrderInfoDto1.setRefundAmount(byId1.getRefundAmount());
                payOrderInfoDto1.setRechargeAmount(byId1.getPaymentAmount());
                return R.ok(payOrderInfoDto1);
            case 3:
                TVipOrder byId2 = vipOrderService.getById(orderId);
@@ -218,6 +220,7 @@
                payOrderInfoDto2.setPayAmount(byId2.getPaymentAmount());
                payOrderInfoDto2.setPayTime(byId2.getCreateTime());
                payOrderInfoDto2.setRefundAmount(byId2.getRefundAmount());
                payOrderInfoDto2.setRechargeAmount(byId2.getPaymentAmount());
                return R.ok(payOrderInfoDto2);
            //todo luo 停车场订单
//                case 4:
@@ -366,14 +369,14 @@
        List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, strategyId).orderByDesc(TChargingOrderAccountingStrategy::getStartTime).list();
        for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : list) {
            if (byId.getVipDiscountAmount()!=null){
            if (byId.getVipDiscountAmount()!=null && byId.getServiceCharge().compareTo(BigDecimal.ZERO) != 0){
                BigDecimal multiply = byId.getVipDiscountAmount().divide(byId.getServiceCharge(), 2)
                        .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
                tChargingOrderAccountingStrategy.setVipDiscount(multiply);
            }
            bigDecimal = bigDecimal.add(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
            if (byId.getCouponDiscountAmount()!=null){
            if (byId.getCouponDiscountAmount()!=null && byId.getServiceCharge().compareTo(BigDecimal.ZERO) != 0){
                BigDecimal multiply = byId.getCouponDiscountAmount().divide(byId.getServiceCharge(), 2)
                        .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
                tChargingOrderAccountingStrategy.setCouponDiscount(multiply);
@@ -775,6 +778,9 @@
        LocalDate sixBefore = PreviousSixMonths.get();
        Map<String,Object>  map = chargingOrderService.countAll(sixBefore);
        BigDecimal data = parkingLotClient.getRecordAmount(sixBefore).getData();
        if (map ==null){
            map = new HashMap<String,Object>();
        }
        map.put("parkingAmount",data);
        BigDecimal data1 =   shoppingOrderService.getSumAmount(sixBefore);
        map.put("shopAmount",data1);
@@ -794,7 +800,8 @@
    public R watchChargingOrder(@RequestBody MongoChargingOrderQuery mongoChargingOrderQuery) {
        mongoChargingOrderQuery.setPageSize(10);
        UploadRealTimeMonitoringPageData data1 = uploadRealTimeMonitoringDataClient.getAll(mongoChargingOrderQuery).getData();
        R<UploadRealTimeMonitoringPageData> all = uploadRealTimeMonitoringDataClient.getAll(mongoChargingOrderQuery);
        UploadRealTimeMonitoringPageData data1 = all.getData();
        List<ChargingOrderAndUploadRealTimeMonitoringDataDto> dtos = new ArrayList<>();
        Map<String,ChargingOrderVO> map  = new HashMap<>();
@@ -908,16 +915,13 @@
            // 获取当前日期
            LocalDate today = LocalDate.now();
            start = statisticsQueryDto.getStartTime();
            end = statisticsQueryDto.getEndTime();
            end = statisticsQueryDto.getEndTime().plusDays(1);
            // 获取本月1号的日期
            YearMonth yearMonth = YearMonth.from(today);
//            start = yearMonth.atDay(1);
//
//            System.out.println("本月1号是: " + start);
        }else if (statisticsQueryDto.getDayType()==4){
            LocalDate today = LocalDate.now();
            // 获取当前年份
            int currentYear = today.getYear();
            // 获取今年1月1日的日期
            start = statisticsQueryDto.getStartTime();
            end = statisticsQueryDto.getEndTime();
@@ -926,7 +930,11 @@
            // 获取今年1月1日的日期
            start = statisticsQueryDto.getStartTime();
            end = statisticsQueryDto.getEndTime();
            if (start.equals(end)){
                end =  end.plusDays(1);
            }
        }
        List<TChargingOrder> list = chargingOrderService.lambdaQuery().ge(TChargingOrder::getCreateTime, start).le(TChargingOrder::getCreateTime, end).in(TChargingOrder::getSiteId, siteIds).list();
        List<Long> chargingOrderIds = list.stream().map(TChargingOrder::getId).collect(Collectors.toList());
        chargingOrderIds.add(-1L);
@@ -1026,6 +1034,7 @@
            LocalDate startDate = statisticsQueryDto.getStartTime();
            LocalDate endDate = statisticsQueryDto.getEndTime();
            List<Map<String, Object>> dateRangeStatistics = new ArrayList<>();
            // 遍历日期范围
@@ -1055,6 +1064,8 @@
            LocalDate startDate = statisticsQueryDto.getStartTime();
            LocalDate endDate = statisticsQueryDto.getEndTime();
            List<Map<String, Object>> dateRangeStatistics = new ArrayList<>();
@@ -1175,6 +1186,8 @@
        tCharingUserMapVO.setMap(charMap);
        tCharingUserMapVO.setMap1(charMap1);
        }else {
            List<Map<String,Object>> map =  chargingOrderService.usersByQuery(statisticsQueryDto);
@@ -1255,8 +1268,19 @@
        //车辆用途
        List<Map<String, Object>> carMap = chargingOrderService.carUserMethod();
        //车辆品牌
        List<Map<String, Object>> carBrandMap = chargingOrderService.carUserBrand();
        List<String> brands = new ArrayList<>();
        for (Map<String, Object> objectMap : carBrandMap) {
            brands.add(objectMap.get("vehicle_brand").toString());
        }
        Long count = chargingOrderService.countCar(brands);
        Map<String, Object> others = new HashMap<>();
        others.put("vehicle_brand","其他");
        others.put("counts",count);
        carBrandMap.add(others);
        //本地车数量
        Map<String,Object> localCarMap = chargingOrderService.countLocalCar();
@@ -1319,7 +1343,7 @@
    @ApiOperation(value = "电站评价", tags = {"管理后台-数据分析-设备运维分析"})
    public R<TCharingUserEquimentVO> equipment(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto){
        List<Integer> siteIds =new ArrayList<>();
        if (statisticsQueryDto.getSiteId()==null) {
        if (statisticsQueryDto.getSiteId()==null||statisticsQueryDto.getSiteId()==0) {
            Long userId = SecurityUtils.getUserId();
            //获取当前登录的siteIds
            List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
@@ -1679,7 +1703,7 @@
        Long userId = tokenService.getLoginUserApplet().getUserId();
        List<TChargingOrder> list = chargingOrderService.list(Wrappers.lambdaQuery(TChargingOrder.class)
                .eq(TChargingOrder::getAppUserId, userId)
                .eq(TChargingOrder::getStatus, 3));
                .in(TChargingOrder::getStatus, Arrays.asList(1,2,3,4)));
        List<Integer> gunIds = list.stream().map(TChargingOrder::getChargingGunId).collect(Collectors.toList());
        return R.ok(gunIds);
    }
@@ -1783,4 +1807,16 @@
        EndOfChargePageInfo endOfChargePageInfo = chargingOrderService.getEndOfChargePageInfo(id);
        return AjaxResult.success(endOfChargePageInfo);
    }
    /**
     * 获取订单数据
     * @param order
     * @return
     */
    @PostMapping("/getChargingOrder")
    public R<List<TChargingOrder>> getChargingOrder(@RequestBody TChargingOrderVo order){
        List<TChargingOrder> chargingOrder = chargingOrderService.getChargingOrder(order);
        return R.ok(chargingOrder);
    }
}