xuhy
2024-10-23 480aa235bba16d8c356a28821edbf3c09a8efb59
Merge remote-tracking branch 'origin/master'
14个文件已修改
585 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppCouponFallbackFactory.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppCouponClient.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingBill.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingOrderVO.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/PayOrderChargingInfo.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java 297 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderInvoiceServiceImpl.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/task/TaskUtil.java 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppCouponFallbackFactory.java
@@ -59,6 +59,11 @@
            public R<TAppCoupon> getAppCouponById(Long id) {
                return R.fail("根据id获取优惠券领取记录失败:" + throwable.getMessage());
            }
            @Override
            public R updateAppCoupon(TAppCoupon appCoupon) {
                return R.fail("修改用户优惠券失败:" + throwable.getMessage());
            }
        };
    }
}
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppCouponClient.java
@@ -62,4 +62,13 @@
     */
    @PostMapping(value = "/t-app-coupon/getAppCouponById")
    R<TAppCoupon> getAppCouponById(@RequestParam("id") Long id);
    /**
     * 修改用户优惠券
     * @param appCoupon
     * @return
     */
    @PostMapping(value = "/t-app-coupon/updateAppCoupon")
    R updateAppCoupon(@RequestBody TAppCoupon appCoupon);
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingBill.java
@@ -55,6 +55,9 @@
    @ApiModelProperty(value = "1未出账2已出账")
    @TableField("status")
    private Integer status;
    @ApiModelProperty(value = "账单类型 1充电算帐单 2账号结算帐单")
    @TableField("billType")
    private Integer billType;
    @ApiModelProperty(value = "1日结2月结")
    @TableField("orderState")
    private Integer orderState;
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingOrderVO.java
@@ -23,8 +23,7 @@
    private Long chargingSecond;
    @ApiModelProperty(value = "平台手续费")
    private BigDecimal platFormMoney;
    @ApiModelProperty(value = "三方平台分佣")
    private BigDecimal commission;
    @ApiModelProperty(value = "车牌号")
    private String licensePlate;
    @ApiModelProperty(value = "手机号")
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java
@@ -306,5 +306,16 @@
        TAppCoupon appCoupon = tAppCouponService.getById(id);
        return R.ok(appCoupon);
    }
    /**
     * 修改用户优惠券
     * @param appCoupon
     * @return
     */
    @PostMapping("/updateAppCoupon")
    public R updateAppCoupon(@RequestBody TAppCoupon appCoupon){
        tAppCouponService.updateById(appCoupon);
        return R.ok();
    }
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java
@@ -65,6 +65,9 @@
    @Autowired
    private SysUserClient sysUserClient;
    @Resource
    private IntegrationClient integrationClient;
    @Autowired
    public TAccountingStrategyController(TAccountingStrategyService accountingStrategyService, TAccountingStrategyDetailService accountingStrategyDetailService) {
@@ -118,7 +121,7 @@
        accountingStrategyService.save(dto);
        if(null != dto.getSiteId()){
            //下发硬件数据
            List<TChargingPile> list = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, dto.getSiteId()).list();
            List<TChargingPile> list = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, dto.getSiteId()).eq(TChargingPile::getDelFlag, 0).list();
            for (TChargingPile tChargingPile : list) {
                integrationClient.setupBillingModel1(tChargingPile.getCode());
            }
@@ -178,11 +181,6 @@
                });
                accountingStrategyDetailService.saveBatch(accountingStrategyDetails);
            }
            //下发硬件数据
            List<TChargingPile> list = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, dto.getSiteId()).list();
            for (TChargingPile tChargingPile : list) {
                integrationClient.setupBillingModel1(tChargingPile.getCode());
            }
        }else {
            // 删除计费策略明细信息
            accountingStrategyDetailService.remove(Wrappers.lambdaQuery(TAccountingStrategyDetail.class)
@@ -192,6 +190,14 @@
            // 添加明细
            dto.getAccountingStrategyDetails().forEach(detail -> detail.setAccountingStrategyId(dto.getId()));
            accountingStrategyDetailService.saveBatch(dto.getAccountingStrategyDetails());
        }
        if(null != dto.getSiteId()){
            //下发硬件数据
            List<TChargingPile> list = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, dto.getSiteId()).eq(TChargingPile::getDelFlag, 0).list();
            for (TChargingPile tChargingPile : list) {
                integrationClient.setupBillingModel1(tChargingPile.getCode());
            }
        }
        return AjaxResult.success();
    }
@@ -323,8 +329,7 @@
        return AjaxResult.ok(accountingStrategyService.pageList(query));
    }
    @Resource
    private IntegrationClient integrationClient;
    @ApiOperation(tags = {"后台-申请表单-计费模板审核"},value = "审核")
    @PostMapping(value = "/auth/pass")
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
@@ -24,6 +24,7 @@
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.integration.api.feignClient.IntegrationClient;
import com.ruoyi.other.api.domain.TVip;
import com.ruoyi.other.api.feignClient.RoleSiteClient;
import com.ruoyi.other.api.feignClient.UserSiteClient;
@@ -76,6 +77,9 @@
    private SysUserRoleClient sysUserRoleClient;
    @Resource
    private TParkingLotService parkingLotService;
    @Resource
    private IntegrationClient integrationClient;
    
    
@@ -395,5 +399,11 @@
            tChargingGun.setAccountingStrategyId(accountingStrategyId);
        }
        chargingGunService.updateBatchById(list);
        //下发硬件数据
        List<TChargingPile> list1 = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, id).eq(TChargingPile::getDelFlag, 0).list();
        for (TChargingPile tChargingPile : list1) {
            integrationClient.setupBillingModel1(tChargingPile.getCode());
        }
    }
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java
@@ -73,18 +73,12 @@
    public R<AccountListVO> accountBillList(@RequestBody ChargingListQuery dto) {
        AccountListVO accountListVO = new AccountListVO();
        ChargingBillVO res = chargingBillService.chargingBillList1(dto);
        ChargingBillVO res1 = chargingBillService.chargingBillList1(dto);
        List<ChargingBillListVO> records = res1.getList().getRecords();
        List<ChargingBillListVO> records = res.getList().getRecords();
        accountListVO.setBillCount(records.size());
        accountListVO.setTotalAmount(
                res1.getPaymentAmount().subtract(res1.getRefundAmount()==null?BigDecimal.ZERO:res1.getRefundAmount())
                        .subtract(res1.getCommissionAmount()==null?BigDecimal.ZERO:res1.getCommissionAmount())
                        .subtract(res1.getSharingAmount()==null?BigDecimal.ZERO:res1.getSharingAmount()));
        accountListVO.setPaymentAmount(res1.getPaymentAmount());
        accountListVO.setRefundAmount(res1.getRefundAmount());
        accountListVO.setCommissionAmount(res1.getCommissionAmount());
        accountListVO.setSharingAmount(res1.getSharingAmount());
        accountListVO.setPaymentAmount(res.getPaymentAmount());
        accountListVO.setRefundAmount(res.getRefundAmount());
        accountListVO.setCommissionAmount(res.getCommissionAmount());
        accountListVO.setSharingAmount(res.getSharingAmount());
        accountListVO.setList(res.getList());
        return R.ok(accountListVO);
    }
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -248,7 +248,7 @@
    @ResponseBody
    @GetMapping(value = "/pay/order/charging")
    @ApiOperation(value = "充电信息", tags = {"管理后台-支付订单-订单信息"})
    public R refundDetail(Long orderId) {
    public R<PayOrderChargingInfo> refundDetail(Long orderId) {
        PayOrderChargingInfo payOrderChargingInfo = new PayOrderChargingInfo();
        TChargingOrder byId = chargingOrderService.getById(orderId);
        List<Site> data = siteClient.getSiteByIds(Collections.singletonList(byId.getSiteId())).getData();
@@ -261,7 +261,20 @@
            List<TAppUserCar> data3 = appUserCarClient.getCarByIds(Collections.singletonList(byId.getAppUserCarId())).getData();
            payOrderChargingInfo.setCarNum(data3.get(0).getLicensePlate());
        }
        return R.ok();
        payOrderChargingInfo.setTChargingOrder(byId);
        Long count = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId).count();
        payOrderChargingInfo.setPeriodCount(count);
        if (byId.getAppUserCarId()!=null) {
            List<Long> carid = new ArrayList<>();
            carid.add(byId.getAppUserCarId());
            R<List<TAppUserCar>> carByIds = appUserCarClient.getCarByIds(carid);
            payOrderChargingInfo.setCarNum(carByIds.getData().get(0).getLicensePlate());
        }
        payOrderChargingInfo.setStartTime(byId.getStartTime());
        payOrderChargingInfo.setEndTime(byId.getEndTime());
        payOrderChargingInfo.setTimeCount(payOrderChargingInfo.calculateDuration());
        return R.ok(payOrderChargingInfo);
    }
    @ResponseBody
@@ -315,10 +328,10 @@
        TChargingOrder byId = chargingOrderService.getById(strategyId);
        ChargingOrderInfoVO chargingOrderInfoVO = new ChargingOrderInfoVO();
        chargingOrderInfoVO.setCdElectronic(byId.getCurrent()!=null?byId.getCurrent()+"":"");
        chargingOrderInfoVO.setCdVoltage(byId.getVoltage()!=null?byId.getVoltage()+"":"");
        chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()!=null?byId.getTotalElectricity()+"":"");
        chargingOrderInfoVO.setTotalPower(byId.getPower()!=null?byId.getPower()+"":"");
        chargingOrderInfoVO.setCdElectronic(byId.getCurrent()!=null?byId.getCurrent().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        chargingOrderInfoVO.setCdVoltage(byId.getVoltage()!=null?byId.getVoltage().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()!=null?byId.getTotalElectricity().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        chargingOrderInfoVO.setTotalPower(byId.getPower()!=null?byId.getPower().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        if (byId.getAppUserCarId()!=null){
            List<TAppUserCar> data = appUserCarClient.getCarByIds(Collections.singletonList(byId.getAppUserCarId())).getData();
            if (!data.isEmpty()){
@@ -331,16 +344,20 @@
        // 时段总服务费
        BigDecimal bigDecimal = new BigDecimal("0");
        List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, strategyId).orderByDesc(TChargingOrderAccountingStrategy::getStartTime).list();
        for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : list) {
            if (byId.getVipDiscountAmount()!=null){
                BigDecimal multiply = byId.getVipDiscountAmount().divide(byId.getServiceCharge(), 2)
                        .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
                tChargingOrderAccountingStrategy.setVipDiscount(multiply);
            }
            bigDecimal = bigDecimal.add(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
            tChargingOrderAccountingStrategy.setVipDiscount(
                    tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice()
                            .subtract(tChargingOrderAccountingStrategy.getPeriodServicePrice())
            );
            tChargingOrderAccountingStrategy.setCouponDiscount(
                    tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice()
                            .subtract(tChargingOrderAccountingStrategy.getPeriodServicePrice())
            );
            if (byId.getCouponDiscountAmount()!=null){
                BigDecimal multiply = byId.getCouponDiscountAmount().divide(byId.getServiceCharge(), 2)
                        .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
                tChargingOrderAccountingStrategy.setCouponDiscount(multiply);
            }
        }
        chargingOrderInfoVO.setList(list);
        return AjaxResult.success(chargingOrderInfoVO);
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/PayOrderChargingInfo.java
@@ -2,9 +2,10 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.order.api.model.TChargingOrder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.Duration;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@@ -34,4 +35,20 @@
    private BigDecimal orderAmount;
    @ApiModelProperty(value = "车牌")
    private String carNum;
    private TChargingOrder tChargingOrder;
    private Long periodCount;
    private String timeCount;
    public String calculateDuration() {
        if (startTime == null || endTime == null) {
            return "00:00:00";
        }
        Duration duration = Duration.between(startTime, endTime);
        long totalSeconds = duration.getSeconds();
        long hours = totalSeconds / 3600;
        long minutes = (totalSeconds % 3600) / 60;
        long seconds = totalSeconds % 60;
        return String.format("%02d:%02d:%02d", hours, minutes, seconds);
    }
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java
@@ -29,8 +29,10 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.TemporalAdjusters;
import java.util.Arrays;
import java.util.List;
@@ -71,7 +73,10 @@
            startTime2 = split[1];
        }
        PageInfo<ChargingBillListVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
        PageInfo<ChargingBillListVO> pageInfo1 = new PageInfo<>(1,9999999);
        List<ChargingBillListVO> list = this.baseMapper.chargingBillList1(pageInfo,dto,startTime1,startTime2);
        List<ChargingBillListVO> list1 = this.baseMapper.chargingBillList1(pageInfo1,dto,startTime1,startTime2);
        chargingBillVO.setOrderCount(list1.size());
        BigDecimal paymentAmountTotal = new BigDecimal("0");
        BigDecimal orderAmountTotal = new BigDecimal("0");
        BigDecimal electrovalenceTotal = new BigDecimal("0");
@@ -109,15 +114,20 @@
            chargingBillListVO.setUid(chargingBillListVO.getId().toString());
            // 根据账单的出账时间 查询上个月的充电订单
            LocalDateTime localDate = chargingBillListVO.getBillTime().minusMonths(1);
//            LocalDateTime localDate = chargingBillListVO.getBillTime().minusMonths(1);
            // todo 临时修改为查询昨天的充电订单
            LocalDateTime localDate = chargingBillListVO.getBillTime().minusDays(1);
            // 账单周期
            chargingBillListVO.setBillWeek(localDate.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM")));
            // 获取 LocalDate 对象
            LocalDate date = localDate.toLocalDate();
            // 获取该月份的第一天
            LocalDate firstDayOfMonth = date.withDayOfMonth(1);
            // 获取该月份的最后一天
            LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
//            // 获取该月份的第一天
//            LocalDate firstDayOfMonth = date.withDayOfMonth(1);
//            // 获取该月份的最后一天
//            LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
            // todo 临时修改为查询昨天凌晨00:00:00 到 23:59:59
            LocalDateTime firstDayOfMonth = LocalDateTime.of(date, LocalTime.MIN);
            LocalDateTime lastDayOfMonth = LocalDateTime.of(date, LocalTime.MAX);
            QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>()
                    .between("create_time", firstDayOfMonth, lastDayOfMonth)
                    .eq("status", 5)
@@ -189,7 +199,7 @@
                }
                BigDecimal add = tChargingOrder.getElectrovalence().add(tChargingOrder.getServiceCharge());
                tChargingOrder.setTotalAmount(add.toString());
                tChargingOrder.setDiscount(tChargingOrder.getCouponDiscountAmount().toString());
                tChargingOrder.setDiscount(tChargingOrder.getCouponDiscountAmount()!=null?tChargingOrder.getCouponDiscountAmount().toString():"0");
                UploadRealTimeMonitoringData data5 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(tChargingOrder.getCode()).getData();
                if (data5!=null){
                    if (data5.getTime_remaining()!=null){
@@ -228,52 +238,38 @@
                // 累加实收金额 支付金额减去退款金额
                if (tChargingOrder.getRefundAmount()!=null && tChargingOrder.getPaymentAmount()!=null){
                    paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()).subtract(tChargingOrder.getRefundAmount());
                    paymentAmountTotal = paymentAmountTotal.add(tChargingOrder.getPaymentAmount()).subtract(tChargingOrder.getRefundAmount());
                }else if (tChargingOrder.getPaymentAmount()!=null){
                    paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount());
                    paymentAmountTotal = paymentAmountTotal.add(tChargingOrder.getPaymentAmount());
                }
                // 累加订单金额
                if (tChargingOrder.getOrderAmount()!=null){
                    orderAmount = orderAmount.add(tChargingOrder.getOrderAmount());
                    orderAmountTotal = orderAmountTotal.add(tChargingOrder.getOrderAmount());
                }
                // 累加累计电费
                if (tChargingOrder.getElectrovalence()!=null){
                    electrovalence = electrovalence.add(tChargingOrder.getElectrovalence());
                    electrovalenceTotal = electrovalenceTotal.add(tChargingOrder.getElectrovalence());
                }
                if (tChargingOrder.getRefundAmount()!=null && tChargingOrder.getRefundStatus() == 2){
                if (tChargingOrder.getRefundAmount()!=null && tChargingOrder.getRefundStatus()!=null && tChargingOrder.getRefundStatus()== 2){
                    refundAmount = refundAmount.add(tChargingOrder.getRefundAmount());
                }
                // 累加累计服务费
                if (tChargingOrder.getServiceCharge()!=null){
                    serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge());
                    serviceChargeTotal = serviceChargeTotal.add(tChargingOrder.getServiceCharge());
                }
                // 累加平台手续费
                if (tChargingOrder.getCommissionAmount()!=null){
                    commissionAmount = commissionAmount.add(tChargingOrder.getCommissionAmount());
                    commissionAmountTotal = commissionAmountTotal.add(tChargingOrder.getCommissionAmount());
                }
                // 累加平台分佣
                if (tChargingOrder.getSharingAmount()!=null){
                    sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount());
                    sharingAmountTotal = sharingAmountTotal.add(tChargingOrder.getSharingAmount());
                }
                // 累加充电度数
                if (tChargingOrder.getChargingCapacity()!=null){
                    chargingCapacity = chargingCapacity.add(tChargingOrder.getChargingCapacity());
                    chargingCapacityTotal = chargingCapacityTotal.add(tChargingOrder.getChargingCapacity());
                }
                // 累加优惠金额
                if (tChargingOrder.getCouponDiscountAmount()!=null){
                    discountTotal = discountTotal.add(tChargingOrder.getCouponDiscountAmount());
                }
                if (tChargingOrder.getVipDiscountAmount()!=null){
                    discountTotal = discountTotal.add(tChargingOrder.getVipDiscountAmount());
                }
            }
            // 将chargingSecond 这是以秒为单位存放的总秒数 将其转化为xx小时xx分钟xx秒
            int hours = chargingSecond / 3600;
@@ -315,6 +311,95 @@
            // 充电时间秒
            chargingBillListVO.setChargingSecond(chargingSecond);
        }
        for (ChargingBillListVO chargingBillListVO : list1) {
            LocalDateTime billTime = chargingBillListVO.getBillTime();
            // 将其转化为yyyy-MM格式字符串
            chargingBillVO.setCreateTime(billTime.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            // 将billTime减去一个月 转化为yyyy-MM格式字符串
            chargingBillVO.setBillWeek(billTime.minusMonths(1).format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM")));
            chargingBillListVO.setUid(chargingBillListVO.getId().toString());
            // 根据账单的出账时间 查询上个月的充电订单
            LocalDateTime localDate = chargingBillListVO.getBillTime().minusMonths(1);
            // 账单周期
            chargingBillListVO.setBillWeek(localDate.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM")));
            // 获取 LocalDate 对象
            LocalDate date = localDate.toLocalDate();
//            // 获取该月份的第一天
//            LocalDate firstDayOfMonth = date.withDayOfMonth(1);
//            // 获取该月份的最后一天
//            LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
            // todo 临时修改为查询昨天凌晨00:00:00 到 23:59:59
            LocalDateTime firstDayOfMonth = LocalDateTime.of(date, LocalTime.MIN);
            LocalDateTime lastDayOfMonth = LocalDateTime.of(date, LocalTime.MAX);
            QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>()
                    .between("create_time", firstDayOfMonth, lastDayOfMonth)
                    .eq("status", 5)
                    .eq("recharge_payment_status", 2);
            if (chargingBillListVO.getType() == 2) {
                eq.eq("site_id", chargingBillListVO.getSiteId());
            }
            List<TChargingOrder> tChargingOrders = chargingOrderList.selectList(eq);
            int chargingSecond = 0;
            BigDecimal paymentAmount = new BigDecimal("0");
            BigDecimal orderAmount = new BigDecimal("0");
            BigDecimal electrovalence = new BigDecimal("0");
            BigDecimal serviceCharge = new BigDecimal("0");
            BigDecimal commissionAmount = new BigDecimal("0");
            BigDecimal sharingAmount = new BigDecimal("0");
            BigDecimal chargingCapacity = new BigDecimal("0");
            orderCount+=tChargingOrders.size();
            chargingBillVO.setCategory("");
            chargingBillVO.setExportList(tChargingOrders);
            for (TChargingOrder tChargingOrder : tChargingOrders) {
                // 累加实收金额 支付金额减去退款金额
                if (tChargingOrder.getRefundAmount()!=null && tChargingOrder.getPaymentAmount()!=null){
                    paymentAmountTotal = paymentAmountTotal.add(tChargingOrder.getPaymentAmount()).subtract(tChargingOrder.getRefundAmount());
                }else if (tChargingOrder.getPaymentAmount()!=null){
                    paymentAmountTotal = paymentAmountTotal.add(tChargingOrder.getPaymentAmount());
                }
                // 累加订单金额
                if (tChargingOrder.getOrderAmount()!=null){
                    orderAmountTotal = orderAmountTotal.add(tChargingOrder.getOrderAmount());
                }
                // 累加累计电费
                if (tChargingOrder.getElectrovalence()!=null){
                    electrovalenceTotal = electrovalenceTotal.add(tChargingOrder.getElectrovalence());
                }
                if (tChargingOrder.getRefundAmount()!=null && tChargingOrder.getRefundStatus() == 2){
                    refundAmount = refundAmount.add(tChargingOrder.getRefundAmount());
                }
                // 累加累计服务费
                if (tChargingOrder.getServiceCharge()!=null){
                    serviceChargeTotal = serviceChargeTotal.add(tChargingOrder.getServiceCharge());
                }
                // 累加平台手续费
                if (tChargingOrder.getServiceCharge()!=null){
                    commissionAmountTotal = commissionAmountTotal.add(tChargingOrder.getServiceCharge().multiply(new BigDecimal("0.006")));
                }
                // 累加平台分佣
                if (tChargingOrder.getSharingAmount()!=null){
                    sharingAmountTotal = sharingAmountTotal.add(tChargingOrder.getSharingAmount());
                }
                // 累加充电度数
                if (tChargingOrder.getElectricity()!=null){
                    chargingCapacityTotal = chargingCapacityTotal.add(tChargingOrder.getElectricity());
                }
                // 累加优惠金额
                if (tChargingOrder.getCouponDiscountAmount()!=null){
                    discountTotal = discountTotal.add(tChargingOrder.getCouponDiscountAmount());
                }
                if (tChargingOrder.getVipDiscountAmount()!=null){
                    discountTotal = discountTotal.add(tChargingOrder.getVipDiscountAmount());
                }
            }
        }
        chargingBillVO.setChargingCapacity(chargingCapacityTotal);
        chargingBillVO.setPaymentAmount(paymentAmountTotal);
        chargingBillVO.setOrderAmount(orderAmountTotal);
@@ -341,7 +426,9 @@
            startTime2 = split[1];
        }
        PageInfo<ChargingBillListVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
        PageInfo<ChargingBillListVO> pageInfo1 = new PageInfo<>(1,9999999);
        List<ChargingBillListVO> list = this.baseMapper.chargingBillList(pageInfo,dto,startTime1,startTime2);
        List<ChargingBillListVO> list1 = this.baseMapper.chargingBillList(pageInfo1,dto,startTime1,startTime2);
        BigDecimal paymentAmountTotal = new BigDecimal("0");
        BigDecimal orderAmountTotal = new BigDecimal("0");
        BigDecimal electrovalenceTotal = new BigDecimal("0");
@@ -379,15 +466,20 @@
            chargingBillListVO.setUid(chargingBillListVO.getId().toString());
            // 根据账单的出账时间 查询上个月的充电订单
            LocalDateTime localDate = chargingBillListVO.getBillTime().minusMonths(1);
//            LocalDateTime localDate = chargingBillListVO.getBillTime().minusMonths(1);
            // todo 临时修改为查询昨天的充电订单
            LocalDateTime localDate = chargingBillListVO.getBillTime().minusDays(1);
            // 账单周期
            chargingBillListVO.setBillWeek(localDate.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM")));
            // 获取 LocalDate 对象
            LocalDate date = localDate.toLocalDate();
            // 获取该月份的第一天
            LocalDate firstDayOfMonth = date.withDayOfMonth(1);
            // 获取该月份的最后一天
            LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
//            // 获取该月份的第一天
//            LocalDate firstDayOfMonth = date.withDayOfMonth(1);
//            // 获取该月份的最后一天
//            LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
            // todo 临时修改为查询昨天凌晨00:00:00 到 23:59:59
            LocalDateTime firstDayOfMonth = LocalDateTime.of(date, LocalTime.MIN);
            LocalDateTime lastDayOfMonth = LocalDateTime.of(date, LocalTime.MAX);
            QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>()
                    .between("create_time", firstDayOfMonth, lastDayOfMonth)
                    .eq("status", 5)
@@ -498,6 +590,113 @@
                // 累加实收金额 支付金额减去退款金额
                if (tChargingOrder.getRefundAmount()!=null && tChargingOrder.getPaymentAmount()!=null){
                    paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()).subtract(tChargingOrder.getRefundAmount());
                }else if (tChargingOrder.getPaymentAmount()!=null){
                    paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount());
                }
                // 累加订单金额
                if (tChargingOrder.getOrderAmount()!=null){
                orderAmount = orderAmount.add(tChargingOrder.getOrderAmount());
                }
                // 累加累计电费
                if (tChargingOrder.getElectrovalence()!=null){
                electrovalence = electrovalence.add(tChargingOrder.getElectrovalence());
                }
                if (tChargingOrder.getRefundAmount()!=null && tChargingOrder.getRefundStatus() !=null && tChargingOrder.getRefundStatus() == 2){
                    refundAmount = refundAmount.add(tChargingOrder.getRefundAmount());
                }
                // 累加累计服务费
                if (tChargingOrder.getServiceCharge()!=null){
                serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge());
                }
                // 累加平台手续费
                if (tChargingOrder.getCommissionAmount()!=null){
                    commissionAmount = commissionAmount.add(tChargingOrder.getCommissionAmount());
                }
                // 累加平台分佣
                if (tChargingOrder.getSharingAmount()!=null){
                    sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount());
                }
                // 累加充电度数
                if (tChargingOrder.getChargingCapacity()!=null){
                    chargingCapacity = chargingCapacity.add(tChargingOrder.getChargingCapacity());
                }
            }
            // 将chargingSecond 这是以秒为单位存放的总秒数 将其转化为xx小时xx分钟xx秒
            int hours = chargingSecond / 3600;
            int minutes = (chargingSecond % 3600) / 60;
            int seconds = chargingSecond % 60;
            // 格式化为字符串
            String timeString = String.format("%d小时%d分钟%d秒", hours, minutes, seconds);
            chargingBillVO.setChargingTime(timeString);
            chargingBillListVO.setPaymentAmount(paymentAmount);
            chargingBillListVO.setOrderAmount(orderAmount);
            chargingBillListVO.setElectrovalence(electrovalence);
            chargingBillListVO.setServiceCharge(serviceCharge.setScale(2,RoundingMode.HALF_DOWN));
            chargingBillListVO.setCommissionAmount(commissionAmount);
            chargingBillListVO.setSharingAmount(sharingAmount);
            chargingBillListVO.setChargingCapacity(chargingCapacity);
            switch (chargingBillListVO.getType()){
                case 1:
                    chargingBillListVO.setSiteName("全站");
                    break;
                case 2:
                    Site site = siteClient.getSiteByIds(Arrays.asList(chargingBillListVO.getSiteId())).getData().get(0);
                    if (site!=null){
                        chargingBillListVO.setSiteName(site.getName());
                    }
                    break;
            }
            // 订单数
            chargingBillListVO.setOrderCount(tChargingOrders.size());
            // 充电时间秒
            chargingBillListVO.setChargingSecond(chargingSecond);
        }
        for (ChargingBillListVO chargingBillListVO : list1) {
            LocalDateTime billTime = chargingBillListVO.getBillTime();
            // 将其转化为yyyy-MM格式字符串
            chargingBillVO.setCreateTime(billTime.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            // 将billTime减去一个月 转化为yyyy-MM格式字符串
            chargingBillVO.setBillWeek(billTime.minusMonths(1).format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM")));
            chargingBillListVO.setUid(chargingBillListVO.getId().toString());
            // 根据账单的出账时间 查询上个月的充电订单
//            LocalDateTime localDate = chargingBillListVO.getBillTime().minusMonths(1);
            // todo 临时修改为查询昨天的充电订单
            LocalDateTime localDate = chargingBillListVO.getBillTime().minusDays(1);
            // 账单周期
            chargingBillListVO.setBillWeek(localDate.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM")));
            // 获取 LocalDate 对象
            LocalDate date = localDate.toLocalDate();
//            // 获取该月份的第一天
//            LocalDate firstDayOfMonth = date.withDayOfMonth(1);
//            // 获取该月份的最后一天
//            LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
            // todo 临时修改为查询昨天凌晨00:00:00 到 23:59:59
            LocalDateTime firstDayOfMonth = LocalDateTime.of(date, LocalTime.MIN);
            LocalDateTime lastDayOfMonth = LocalDateTime.of(date, LocalTime.MAX);
            QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>()
                    .between("create_time", firstDayOfMonth, lastDayOfMonth)
                    .eq("status", 5)
                    .eq("recharge_payment_status", 2);
            if (chargingBillListVO.getType() == 2) {
                eq.eq("site_id", chargingBillListVO.getSiteId());
            }
            List<TChargingOrder> tChargingOrders = chargingOrderList.selectList(eq);
            int chargingSecond = 0;
            BigDecimal paymentAmount = new BigDecimal("0");
            BigDecimal orderAmount = new BigDecimal("0");
            BigDecimal electrovalence = new BigDecimal("0");
            BigDecimal serviceCharge = new BigDecimal("0");
            BigDecimal commissionAmount = new BigDecimal("0");
            BigDecimal sharingAmount = new BigDecimal("0");
            BigDecimal chargingCapacity = new BigDecimal("0");
            orderCount+=tChargingOrders.size();
            for (TChargingOrder tChargingOrder : tChargingOrders) {
                // 累加实收金额 支付金额减去退款金额
                if (tChargingOrder.getRefundAmount()!=null && tChargingOrder.getPaymentAmount()!=null){
                    paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()).subtract(tChargingOrder.getRefundAmount());
                    paymentAmountTotal = paymentAmountTotal.add(tChargingOrder.getPaymentAmount()).subtract(tChargingOrder.getRefundAmount());
                }else if (tChargingOrder.getPaymentAmount()!=null){
@@ -523,9 +722,9 @@
                serviceChargeTotal = serviceChargeTotal.add(tChargingOrder.getServiceCharge());
                }
                // 累加平台手续费
                if (tChargingOrder.getCommissionAmount()!=null){
                    commissionAmount = commissionAmount.add(tChargingOrder.getCommissionAmount());
                    commissionAmountTotal = commissionAmountTotal.add(tChargingOrder.getCommissionAmount());
                if (tChargingOrder.getServiceCharge()!=null){
                    commissionAmount = commissionAmount.add(tChargingOrder.getServiceCharge().multiply(new BigDecimal("0.006")).setScale(2, RoundingMode.HALF_DOWN));
                    commissionAmountTotal = commissionAmountTotal.add(tChargingOrder.getServiceCharge().multiply(new BigDecimal("0.006")).setScale(2, RoundingMode.HALF_DOWN));
                }
                // 累加平台分佣
                if (tChargingOrder.getSharingAmount()!=null){
@@ -533,9 +732,9 @@
                    sharingAmountTotal = sharingAmountTotal.add(tChargingOrder.getSharingAmount());
                }
                // 累加充电度数
                if (tChargingOrder.getChargingCapacity()!=null){
                    chargingCapacity = chargingCapacity.add(tChargingOrder.getChargingCapacity());
                    chargingCapacityTotal = chargingCapacityTotal.add(tChargingOrder.getChargingCapacity());
                if (tChargingOrder.getElectricity()!=null){
                    chargingCapacity = chargingCapacity.add(tChargingOrder.getElectricity());
                    chargingCapacityTotal = chargingCapacityTotal.add(tChargingOrder.getElectricity());
                }
                // 累加优惠金额
                if (tChargingOrder.getCouponDiscountAmount()!=null){
@@ -545,36 +744,6 @@
                    discountTotal = discountTotal.add(tChargingOrder.getVipDiscountAmount());
                }
            }
            // 将chargingSecond 这是以秒为单位存放的总秒数 将其转化为xx小时xx分钟xx秒
            int hours = chargingSecond / 3600;
            int minutes = (chargingSecond % 3600) / 60;
            int seconds = chargingSecond % 60;
            // 格式化为字符串
            String timeString = String.format("%d小时%d分钟%d秒", hours, minutes, seconds);
            chargingBillVO.setChargingTime(timeString);
            chargingBillListVO.setPaymentAmount(paymentAmount);
            chargingBillListVO.setOrderAmount(orderAmount);
            chargingBillListVO.setElectrovalence(electrovalence);
            chargingBillListVO.setServiceCharge(serviceCharge);
            chargingBillListVO.setCommissionAmount(commissionAmount);
            chargingBillListVO.setSharingAmount(sharingAmount);
            chargingBillListVO.setChargingCapacity(chargingCapacity);
            switch (chargingBillListVO.getType()){
                case 1:
                    chargingBillListVO.setSiteName("全站");
                    break;
                case 2:
                    Site site = siteClient.getSiteByIds(Arrays.asList(chargingBillListVO.getSiteId())).getData().get(0);
                    if (site!=null){
                        chargingBillListVO.setSiteName(site.getName());
                    }
                    break;
            }
            // 订单数
            chargingBillListVO.setOrderCount(tChargingOrders.size());
            // 充电时间秒
            chargingBillListVO.setChargingSecond(chargingSecond);
        }
        chargingBillVO.setChargingCapacity(chargingCapacityTotal);
        chargingBillVO.setPaymentAmount(paymentAmountTotal);
@@ -585,8 +754,6 @@
        chargingBillVO.setCommissionAmount(commissionAmountTotal);
        chargingBillVO.setSharingAmount(sharingAmountTotal);
        chargingBillVO.setDiscount(discountTotal);
        pageInfo.setRecords(list);
        chargingBillVO.setList(pageInfo);
        return chargingBillVO;
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -916,30 +916,29 @@
                appUserTagClient.addUserTag(data1);
            }
        }
        //充电评率
        //充电频率
        List<TUserTag> userTagList2 = data.stream().filter(s -> s.getStandardCondition() == 2).collect(Collectors.toList());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (TUserTag tUserTag : userTagList2) {
            TAppUserTag appUserTag = new TAppUserTag();
            appUserTag.setAppUserId(chargingOrder.getAppUserId());
            appUserTag.setUserTagId(tUserTag.getId());
            TAppUserTag data1 = appUserTagClient.getUserTag(appUserTag).getData();
            if(null == data1){
                Integer day = JSON.parseObject(tUserTag.getConditions()).getInteger("day");
                Integer times = JSON.parseObject(tUserTag.getConditions()).getInteger("times");
                Calendar start = Calendar.getInstance();
                start.set(Calendar.DAY_OF_YEAR, start.get(Calendar.DAY_OF_YEAR) + day);
            LocalDateTime endTime = LocalDateTime.now();
            endTime.plusDays(day);
            String start = tUserTag.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            String end = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                count1 = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId())
                        .eq(TChargingOrder::getRechargePaymentStatus, 2).isNotNull(TChargingOrder::getPaymentAmount)
                        .between(TChargingOrder::getStartTime, sdf.format(start.getTime()), sdf.format(new Date())).eq(TChargingOrder::getDelFlag, 0));
                //加上本次充电
                if(count1 >= times){
                    .between(TChargingOrder::getStartTime, start, end).eq(TChargingOrder::getDelFlag, 0));
            if(null == data1 && (count1 + 1) >= times){
                    data1 = new TAppUserTag();
                    data1.setAppUserId(chargingOrder.getAppUserId());
                    data1.setUserTagId(tUserTag.getId());
                    data1.setCreateTime(LocalDateTime.now());
                    appUserTagClient.addUserTag(data1);
                }
            }
        }
    }
@@ -1073,6 +1072,7 @@
            endTime2 = split[1];
        }
        PageInfo<ChargingOrderVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
        PageInfo<ChargingOrderVO> pageInfo1 = new PageInfo<>(1,9999999);
        if (StringUtils.hasLength(dto.getPhone())){
            List<Long> data = appUserClient.getUserIdsByPhone(dto.getPhone()).getData();
@@ -1083,12 +1083,15 @@
            dto.setUserIds(data);
        }
        List<ChargingOrderVO> list = this.baseMapper.chargingOrder(pageInfo,dto,startTime1,startTime2,endTime1,endTime2);
        List<ChargingOrderVO> list1 = this.baseMapper.chargingOrder(pageInfo1,dto,startTime1,startTime2,endTime1,endTime2);
         BigDecimal total = new BigDecimal("0");
         long time = 0L;
         BigDecimal income = new BigDecimal("0");
         BigDecimal electronicMoney = new BigDecimal("0");
         BigDecimal serviceMoney = new BigDecimal("0");
        for (ChargingOrderVO chargingOrderVO : list) {
            chargingOrderVO.setCommissionAmount(chargingOrderVO.getServiceCharge().multiply(new BigDecimal("0.006")));
            chargingOrderVO.setPlatFormMoney(chargingOrderVO.getServiceCharge().multiply(new BigDecimal("0.006")));
            chargingOrderVO.setUid(chargingOrderVO.getId()+"");
            TChargingGun data3 = chargingGunClient.getChargingGunById(chargingOrderVO.getChargingGunId()).getData();
            TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderVO.getChargingPileId()).getData();
@@ -1100,10 +1103,6 @@
            }
            if (data2!=null && data3!=null){
                chargingOrderVO.setTerminalName(data2.getName()+"-"+data3.getName());
            }
            if (chargingOrderVO.getChargingCapacity()!=null){
                total = total.add(chargingOrderVO.getElectricity());
            }
            // 充电订单 明细记录
            List<TChargingOrderAccountingStrategy> chargingOrderId = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>()
@@ -1112,14 +1111,6 @@
            if (data5!=null){
                long l = data5.getCumulative_charging_time() * 60L;
                chargingOrderVO.setChargingSecond(l);
                time+=l;
            }
            electronicMoney = electronicMoney.add(chargingOrderVO.getElectrovalence());
            serviceMoney = serviceMoney.add(chargingOrderVO.getServiceCharge());
            income = income.add(chargingOrderVO.getServiceCharge().add(chargingOrderVO.getElectrovalence()));
            if (chargingOrderVO.getRefundAmount()!=null){
                income = income.subtract(chargingOrderVO.getRefundAmount());
            }
            // 充电时段数
            int size = chargingOrderId.size();
@@ -1139,6 +1130,27 @@
                }
            }
        }
        for (ChargingOrderVO chargingOrderVO : list1) {
            if (chargingOrderVO.getChargingCapacity()!=null){
                total = total.add(chargingOrderVO.getElectricity());
            }
            // 充电订单 明细记录
            List<TChargingOrderAccountingStrategy> chargingOrderId = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>()
                    .eq("charging_order_id", chargingOrderVO.getId()));
            UploadRealTimeMonitoringData data5 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrderVO.getCode()).getData();
            if (data5!=null){
                long l = data5.getCumulative_charging_time() * 60L;
                chargingOrderVO.setChargingSecond(l);
                time+=l;
            }
            electronicMoney = electronicMoney.add(chargingOrderVO.getElectrovalence());
            serviceMoney = serviceMoney.add(chargingOrderVO.getServiceCharge());
            income = income.add(chargingOrderVO.getOrderAmount());
        }
        tCharingOrderVO.setTotal(total);
        tCharingOrderVO.setTime(time);
@@ -1475,6 +1487,8 @@
        TChargingOrder chargingOrder= this.getById(uid);
        ChargingOrderListInfoVO chargingOrderListInfoVO = new ChargingOrderListInfoVO();
        chargingOrderListInfoVO.setStatus(chargingOrder.getStatus());
        BigDecimal bigDecimal = new BigDecimal("0.006");
        if (chargingOrder.getServiceCharge()!=null){
            chargingOrderListInfoVO.setCommissionAmount(chargingOrder.getServiceCharge().multiply(bigDecimal));
@@ -1792,6 +1806,9 @@
                        order.setCouponDiscountAmount(couponDiscountAmount);
                        payAmount = payAmount.subtract(couponDiscountAmount);
                    }
                    appCoupon.setStatus(2);
                    appCouponClient.updateAppCoupon(appCoupon);
                }else{
                    order.setAppCouponId(null);
                    order.setCouponDiscountAmount(BigDecimal.ZERO);
@@ -1814,6 +1831,9 @@
                        order.setCouponDiscountAmount(divide);
                        payAmount = payAmount.subtract(divide);
                    }
                    appCoupon.setStatus(2);
                    appCouponClient.updateAppCoupon(appCoupon);
                }else{
                    order.setAppCouponId(null);
                    order.setCouponDiscountAmount(BigDecimal.ZERO);
@@ -2602,12 +2622,13 @@
        info.setRefundAmount(chargingOrder.getRefundAmount());
        LocalDateTime startTime = chargingOrder.getStartTime();
        LocalDateTime endTime = chargingOrder.getEndTime();
        info.setStartDay(startTime.format(DateTimeFormatter.ofPattern("MM月dd日")) + " 周" + startTime.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.SIMPLIFIED_CHINESE));
        info.setStartDay(startTime.format(DateTimeFormatter.ofPattern("MM月dd日")) + " " + startTime.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.SIMPLIFIED_CHINESE));
        info.setStartHour(startTime.format(DateTimeFormatter.ofPattern("HH:mm")));
        info.setEndDay(endTime.format(DateTimeFormatter.ofPattern("MM月dd日")) + " 周" + endTime.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.SIMPLIFIED_CHINESE));
        info.setEndDay(endTime.format(DateTimeFormatter.ofPattern("MM月dd日")) + " " + endTime.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.SIMPLIFIED_CHINESE));
        info.setEndHour(endTime.format(DateTimeFormatter.ofPattern("HH:mm")));
        int hour = endTime.getHour() - startTime.getHour();
        int second = endTime.getMinute() - startTime.getMinute();
        long time = (endTime.toEpochSecond(ZoneOffset.UTC) - startTime.toEpochSecond(ZoneOffset.UTC)) / 60;
        long hour = time / 60;
        long second = time % 60;
        info.setDuration(0 == hour ? String.format("%s分钟", second) : String.format("%s小时%s分钟", hour, second));
        return info;
    }
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderInvoiceServiceImpl.java
@@ -162,9 +162,11 @@
    public List<OrderInvoiceList> getMyOrderInvoiceList(GetOrderInvoiceList query) {
        Long userId = tokenService.getLoginUserApplet().getUserId();
        Integer pageCurr = (query.getPageCurr() - 1) * query.getPageSize();
        List<TOrderInvoice> list = this.list(new LambdaQueryWrapper<TOrderInvoice>().eq(TOrderInvoice::getAppUserId, userId)
                .eq(TOrderInvoice::getStatus, query.getStatus()).orderByDesc(TOrderInvoice::getCreateTime)
                .last(" limit " + pageCurr + ", " + query.getPageSize()));
        LambdaQueryWrapper<TOrderInvoice> wrapper = new LambdaQueryWrapper<TOrderInvoice>().eq(TOrderInvoice::getAppUserId, userId);
        if(query.getStatus() != 1){
            wrapper.eq(TOrderInvoice::getStatus, query.getStatus());
        }
        List<TOrderInvoice> list = this.list(wrapper.orderByDesc(TOrderInvoice::getCreateTime).last(" limit " + pageCurr + ", " + query.getPageSize()));
        List<OrderInvoiceList> pageList = new ArrayList<>();
        for (TOrderInvoice tOrderInvoice : list) {
            OrderInvoiceList orderInvoiceList = new OrderInvoiceList();
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/task/TaskUtil.java
@@ -49,9 +49,9 @@
@Scheduled(cron = "0 0 12 1 * ?")
//@Scheduled(fixedRate = 60000)
    public void taskMonth() {
        try {
            System.err.println("执行定时任务生成账单");
            // 获取上个月的开始和结束日期
            LocalDate firstDayOfLastMonth = LocalDate.now().minusMonths(1).
                    withDayOfMonth(2);
@@ -71,33 +71,70 @@
            tChargingBill.setBillTime(LocalDateTime.now());
            tChargingBill.setStatus(1);
            tChargingBill.setOrderState(2);
            tChargingBill.setBillType(1);
            System.err.println("定时任务生成充电算帐单:全站");
            chargingBillService.save(tChargingBill);
            // 每月二号给每个站点生成上月账单
            List<Integer> collect = siteClient.getSiteAll().getData().stream().map(Site::getId).collect(Collectors.toList());
            List<TChargingBill> tChargingBills = new ArrayList<>();
            for (int i = 0; i < collect.size(); i++) {
            // 生成一次全站订单
                TChargingBill tChargingBill1 = new TChargingBill();
            // 订单生成规则JSD+20231201(账单所属月份)+1131304205(随机10位数)+001(当月账单序号,每月重置)
                Random random1 = new Random();
                String randomDigits1 = random1.ints(10, 0, 10) // 生成10个随机数字,范围在0-9
                        .mapToObj(String::valueOf)
                        .collect(Collectors.joining()); // 将其连接成一个字符串
                tChargingBill1.setCode("JSD"+string+randomDigits1+(i+1) );
                tChargingBill1.setType(2);
                tChargingBill1.setSiteId(collect.get(i));
            tChargingBill1.setCode("JSD"+string+randomDigits1 );
            tChargingBill1.setType(1);
            tChargingBill1.setSiteId(0);
                tChargingBill1.setBillTime(LocalDateTime.now());
                tChargingBill1.setStatus(1);
                tChargingBill1.setOrderState(2);
                tChargingBills.add(tChargingBill1);
            tChargingBill1.setBillType(2);
            System.err.println("定时任务生成账户结算帐单:全站");
            chargingBillService.save(tChargingBill1);
            System.err.println("定时任务生成各个站点结算帐单");
            List<Integer> collect = siteClient.getSiteAll().getData().stream().map(Site::getId).collect(Collectors.toList());
            // 充电算帐单
            List<TChargingBill> tChargingBills = new ArrayList<>();
            // 账户结算账单
            List<TChargingBill> tChargingBills1 = new ArrayList<>();
            for (int i = 0; i < collect.size(); i++) {
                TChargingBill tChargingBill2 = new TChargingBill();
                Random random2 = new Random();
                String randomDigits2 = random2.ints(10, 0, 10) // 生成10个随机数字,范围在0-9
                        .mapToObj(String::valueOf)
                        .collect(Collectors.joining()); // 将其连接成一个字符串
                tChargingBill2.setCode("JSD"+string+randomDigits2+(i+1) );
                tChargingBill2.setType(2);
                tChargingBill2.setSiteId(collect.get(i));
                tChargingBill2.setBillTime(LocalDateTime.now());
                tChargingBill2.setBillType(1);
                tChargingBill2.setStatus(1);
                tChargingBill2.setOrderState(2);
                tChargingBills.add(tChargingBill2);
                TChargingBill tChargingBill3 = new TChargingBill();
                Random random3 = new Random();
                String randomDigits3 = random3.ints(10, 0, 10) // 生成10个随机数字,范围在0-9
                        .mapToObj(String::valueOf)
                        .collect(Collectors.joining()); // 将其连接成一个字符串
                tChargingBill3.setCode("JSD"+string+randomDigits3+(i+1) );
                tChargingBill3.setType(2);
                tChargingBill3.setSiteId(collect.get(i));
                tChargingBill3.setBillTime(LocalDateTime.now());
                tChargingBill3.setBillType(1);
                tChargingBill3.setStatus(1);
                tChargingBill3.setOrderState(2);
                tChargingBills1.add(tChargingBill3);
            }
            System.err.println("列表"+tChargingBills);
            if (!tChargingBills.isEmpty())chargingBillService.saveBatch(tChargingBills);
            if (!tChargingBills1.isEmpty())chargingBillService.saveBatch(tChargingBills1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    // 每个月最后一天23点执行的定时任务
    @Scheduled(cron = "0 0 12 1 * ?")
    // 每天晚上23:59:59执行的定时任务
    @Scheduled(cron = "0 0 23 1 * ?")
    public void taskLastDay() {
        try {
            // 获取上个月的开始和结束日期
@@ -110,10 +147,10 @@
            LocalDateTime endDateTime = lastDayOfLastMonth.atTime(23, 59, 59); // 设定到最后一秒
            // 构建查询条件
            LambdaQueryWrapper<TChargingBill> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.ge(TChargingBill::getBillTime,
                            Date.from(startDateTime.atZone(ZoneId.systemDefault()).toInstant()))
                    .le(TChargingBill::getBillTime,
                            Date.from(endDateTime.atZone(ZoneId.systemDefault()).toInstant())); // 使用 le 包括最后一天的记录
//            queryWrapper.ge(TChargingBill::getBillTime,
//                            Date.from(startDateTime.atZone(ZoneId.systemDefault()).toInstant()))
//                    .le(TChargingBill::getBillTime,
//                            Date.from(endDateTime.atZone(ZoneId.systemDefault()).toInstant())); // 使用 le 包括最后一天的记录
            List<TChargingBill> list = chargingBillService.list(queryWrapper);
            for (TChargingBill tChargingBill : list) {
                tChargingBill.setStatus(2);