luodangjia
2024-09-05 fbf430ea78304dc7ae60271090d082f05b21239b
Merge remote-tracking branch 'origin/master'
1 文件已重命名
11个文件已修改
12个文件已添加
1288 ■■■■■ 已修改文件
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/ChargingListQuery.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingBill.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillListVO.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillVO.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/resources/template/充电算帐单已出账.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java 361 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/FinancialSettlementController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillDetailExport.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillExport.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillPayExport.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillRefundExport.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/TChargingBillExport.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingBillMapper.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingBillService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java 327 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingBillMapper.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java
@@ -4,9 +4,11 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TChargingCountQuery;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
import com.ruoyi.order.api.vo.ChargingBillVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -36,6 +38,11 @@
            }
            @Override
            public R<ChargingBillVO> chargingBillListR(ChargingListQuery dto) {
                return R.fail("查询充电算帐单失败" + throwable.getMessage());
            }
            @Override
            public R<TChargingOrder> orderDetail(Long orderId) {
                return R.fail("订单详情:" + throwable.getMessage());
            }
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java
@@ -5,9 +5,12 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.order.api.factory.ChargingOrderFallbackFactory;
import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TChargingCountQuery;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
import com.ruoyi.order.api.vo.ChargingBillVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@@ -21,7 +24,8 @@
public interface ChargingOrderClient {
    @PostMapping(value = "/t-charging-order/useOrderCount")
    R<Long> useOrderCount(@RequestParam("userId") Long userId);
    @PostMapping(value = "/t-charging-order/chargingBillListR")
    R<ChargingBillVO> chargingBillListR(@RequestBody ChargingListQuery dto);
    @PostMapping(value = "/t-charging-order/detail")
    R<TChargingOrder> orderDetail(@RequestParam("orderId") Long orderId);
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/ChargingListQuery.java
File was renamed from ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingListQuery.java
@@ -1,4 +1,4 @@
package com.ruoyi.order.dto;
package com.ruoyi.order.api.model;
import com.ruoyi.common.core.web.page.BasePage;
import io.swagger.annotations.ApiModel;
@@ -12,9 +12,11 @@
@ApiModel(value = "充电账单列表查询参数")
public class ChargingListQuery extends BasePage {
    @ApiModelProperty("订单分类 1全站 2各个站点")
    private String category;
    @ApiModelProperty("账单周期2020-01-01 - 2020-01-01")
    private String type;
    @ApiModelProperty("账单周期2020-01-01 00:00:00 - 2020-01-01 23:59:59")
    private String startTime;
    @ApiModelProperty("1已出账 2未出账")
    private Integer state;
    @ApiModelProperty("uid 前端忽略")
    private String uid;
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingBill.java
New file
@@ -0,0 +1,62 @@
package com.ruoyi.order.api.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.web.domain.BasePojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.cglib.core.Local;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
 * <p>
 * 充电算帐单
 * </p>
 *
 * @author 无关风月
 * @since 2024-09-04
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_charging_bill")
@ApiModel(value="TChargingBill对象", description="")
public class TChargingBill extends BasePojo {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.NONE)
    private Long id;
    @ApiModelProperty(value = "账单编号")
    @TableField("code")
    private String code;
    @ApiModelProperty(value = "账单类型 1全站账单 2站点账单")
    @TableField("type")
    private Integer type;
    @ApiModelProperty(value = "站点id")
    @TableField("site_id")
    private Integer siteId;
    @ApiModelProperty(value = "账单生成时间 每月二号")
    @TableField("bill_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime billTime;
    @ApiModelProperty(value = "1未出账2已出账")
    @TableField("status")
    private Integer status;
    @ApiModelProperty(value = "uid")
    @TableField(exist = false)
    private String uid;
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java
@@ -158,6 +158,9 @@
    @ApiModelProperty(value = "退款流水号")
    @TableField("refund_code")
    private String refundCode;
    @ApiModelProperty(value = "退款原因")
    @TableField("refund_reason")
    private String refundReason;
    @ApiModelProperty(value = "退款金额")
    @TableField("refund_amount")
@@ -190,4 +193,53 @@
    @TableField("pay_time")
    private LocalDateTime payTime;
    @ApiModelProperty(value = "站点名称")
    @TableField(exist = false)
    private String siteName;
    @ApiModelProperty(value = "终端名称")
    @TableField(exist = false)
    private String terminalName;
    @ApiModelProperty(value = "终端编号")
    @TableField(exist = false)
    private String terminalCode;
    @ApiModelProperty(value = "订单分类")
    @TableField(exist = false)
    private String orderClassification1;
    @ApiModelProperty(value = "支付方式")
    @TableField(exist = false)
    private String rechargePaymentType1;
    @ApiModelProperty(value = "充电启动方式")
    @TableField(exist = false)
    private String chargingType;
    @ApiModelProperty(value = "订单状态")
    @TableField(exist = false)
    private String status1;
    @ApiModelProperty(value = "终端名称")
    @TableField(exist = false)
    private String endMode1;
    @ApiModelProperty(value = "充电费用")
    @TableField(exist = false)
    private String totalAmount;
    @ApiModelProperty(value = "优惠抵扣")
    @TableField(exist = false)
    private String discount;
    @ApiModelProperty(value = "充电时长")
    @TableField(exist = false)
    private String chargingTime;
    @ApiModelProperty(value = "充电后soc")
    @TableField(exist = false)
    private String endSoc;
    @ApiModelProperty(value = "客户昵称")
    @TableField(exist = false)
    private String userName;
    @ApiModelProperty(value = "手机号")
    @TableField(exist = false)
    private String phone;
    @ApiModelProperty(value = "车牌号")
    @TableField(exist = false)
    private String licensePlate;
    @ApiModelProperty(value = "车辆品牌")
    @TableField(exist = false)
    private String vehicleModel;
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillListVO.java
New file
@@ -0,0 +1,37 @@
package com.ruoyi.order.api.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.order.api.model.TChargingBill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@ApiModel(value = "ChargingBillListVO对象",description = "充电算帐单列表VO")
public class ChargingBillListVO extends TChargingBill {
    @ApiModelProperty(value = "账单周期")
    private String billWeek;
    @ApiModelProperty(value = "充电时间 秒")
    private Integer chargingSecond;
    @ApiModelProperty(value = "订单数量")
    private Integer orderCount;
    @ApiModelProperty(value = "站点名称")
    private String siteName;
    @ApiModelProperty(value = "实收金额")
    private BigDecimal paymentAmount;
    @ApiModelProperty(value = "总金额")
    private BigDecimal orderAmount;
    @ApiModelProperty(value = "累计电费")
    private BigDecimal electrovalence;
    @ApiModelProperty(value = "累计服务费")
    private BigDecimal serviceCharge;
    @ApiModelProperty(value = "平台手续费")
    private BigDecimal commissionAmount;
    @ApiModelProperty(value = "平台分佣")
    private BigDecimal sharingAmount;
    @ApiModelProperty(value = "充电电流 度")
    private BigDecimal chargingCapacity;
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillVO.java
@@ -1,11 +1,13 @@
package com.ruoyi.order.api.vo;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.model.TChargingOrder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
@ApiModel(value = "ChargingBillVO对象",description = "充电算帐单")
@@ -23,11 +25,27 @@
    @ApiModelProperty(value = "订单数量")
    private Integer orderCount;
    @ApiModelProperty(value = "平台手续费")
    private String commissionAmount;
    private BigDecimal commissionAmount;
    @ApiModelProperty(value = "三方平台分佣")
    private String sharingAmount;
    private BigDecimal sharingAmount;
    @ApiModelProperty(value = "优惠抵扣")
    private String discount;
    private BigDecimal discount;
    @ApiModelProperty(value = "账单分类 1全站 2各个站点 前端忽略")
    private String category;
    @ApiModelProperty(value = "账单类型 月结 前端忽略")
    private String type;
    @ApiModelProperty(value = "站点名称 前端忽略")
    private String siteName;
    @ApiModelProperty(value = "账单周期 前端忽略")
    private String billWeek;
    @ApiModelProperty(value = "账单生成日期 前端忽略")
    private String createTime;
    @ApiModelProperty(value = "账单编号 前端忽略")
    private String code;
    @ApiModelProperty(value = "充电时长 前端忽略")
    private String chargingTime;
    @ApiModelProperty(value = "列表数据")
    private PageInfo<ChargingOrderListVO> list;
    private PageInfo<ChargingBillListVO> list;
    @ApiModelProperty(value = "导出Excel数据 前端忽略")
    private List<TChargingOrder> exportList;
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
@@ -82,8 +82,6 @@
    @Resource
    private ChargingOrderClient chargingOrderClient;
    /**
     * 小程序扫一扫
     * @param number
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java
@@ -1,10 +1,18 @@
package com.ruoyi.chargingPile.controller;
import java.math.BigDecimal;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.vo.ChargingBillListVO;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.enums.WriteDirectionEnum;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.alibaba.excel.write.metadata.fill.FillWrapper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -24,18 +32,23 @@
import com.ruoyi.common.log.enums.OperatorType;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.vo.ChargingBillVO;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.CharEncoding;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@@ -55,6 +68,8 @@
    private final TApplyChargingPileService applyChargingPileService;
    private final TokenService tokenService;
    private final RedisService redisService;
    @Resource
    private ChargingOrderClient chargingOrderClient;
    @Autowired
    public TApplyChargingPileController(TApplyChargingPileService applyChargingPileService, TokenService tokenService, RedisService redisService) {
@@ -217,6 +232,87 @@
        return R.ok();
    }
    @ApiOperation(value = "下载-已出账", tags = {"管理后台-充电算账单"})
    @GetMapping("/downloadBill")
    public R downloadBill(String uid,HttpServletResponse response)
    {
        ChargingListQuery chargingListQuery = new ChargingListQuery();
        chargingListQuery.setUid(uid);
        chargingListQuery.setPageCurr(1);
        chargingListQuery.setPageSize(99999);
        ChargingBillVO data = chargingOrderClient.chargingBillListR(chargingListQuery).getData();
        List<ChargingBillVO> chargingBillVOS = new ArrayList<>();
        chargingBillVOS.add(data);
        try {
            response.setCharacterEncoding(Constants.UTF8);
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Access-Control-Expose-Headers", "Content-disposition");
            response.setHeader("Content-Disposition", "attachment;filename=" +
                    URLEncoder.encode("月账单-"+data.getCategory()+"-"+data.getBillWeek()+"-"+data.getSiteName(), CharEncoding.UTF_8) + ".xlsx");
        } catch (UnsupportedEncodingException e) {
            return R.fail("excel导出失败!");
        }
        try {
            // excel模板封装
            ExcelWriterBuilder excelWriterBuilder = EasyExcelFactory.write(response.getOutputStream());
            InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/" +"充电算帐单已出账" + ".xlsx");
            // 自动释放资源
            try (ExcelWriter excelWriter = excelWriterBuilder.withTemplate(stream).build()) {
                WriteSheet writeSheet = EasyExcel.writerSheet().build();
                FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build();
                excelWriter.fill(new FillWrapper("data1", chargingBillVOS), fillConfig, writeSheet);
                excelWriter.fill(new FillWrapper("data2", data.getExportList()), fillConfig, writeSheet);
                excelWriter.finish();
            } catch (Exception e) {
                return R.fail("excel导出失败!");
            }
        } catch (IOException e) {
            return R.fail("excel导出失败!");
        }
        return R.ok();
    }
    @ApiOperation(value = "下载-未出账", tags = {"管理后台-充电算账单"})
    @GetMapping("/download")
    public R download(String uid,HttpServletResponse response)
    {
        ChargingListQuery chargingListQuery = new ChargingListQuery();
        chargingListQuery.setUid(uid);
        chargingListQuery.setPageCurr(1);
        chargingListQuery.setPageSize(99999);
        ChargingBillVO data = chargingOrderClient.chargingBillListR(chargingListQuery).getData();
        List<ChargingBillVO> chargingBillVOS = new ArrayList<>();
        chargingBillVOS.add(data);
        try {
            response.setCharacterEncoding(Constants.UTF8);
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Access-Control-Expose-Headers", "Content-disposition");
            response.setHeader("Content-Disposition", "attachment;filename=" +
                    URLEncoder.encode("月账单-"+data.getCategory()+data.getBillWeek()+data.getSiteName(), CharEncoding.UTF_8) + ".xlsx");
        } catch (UnsupportedEncodingException e) {
            return R.fail("excel导出失败!");
        }
        try {
            // excel模板封装
            ExcelWriterBuilder excelWriterBuilder = EasyExcelFactory.write(response.getOutputStream());
            InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/" +"充电算帐单已出账" + ".xlsx");
            // 自动释放资源
            try (ExcelWriter excelWriter = excelWriterBuilder.withTemplate(stream).build()) {
                WriteSheet writeSheet = EasyExcel.writerSheet().build();
                FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build();
                excelWriter.fill(new FillWrapper("data1", chargingBillVOS), fillConfig, writeSheet);
                excelWriter.fill(new FillWrapper("data2", data.getExportList()), fillConfig, writeSheet);
                excelWriter.finish();
            } catch (Exception e) {
                return R.fail("excel导出失败!");
            }
        } catch (IOException e) {
            return R.fail("excel导出失败!");
        }
        return R.ok();
    }
    public static boolean isImageUrl(JSONObject jsonObject) {
        String url = jsonObject.getString("url");
        Pattern pattern = Pattern.compile(
ruoyi-service/ruoyi-chargingPile/src/main/resources/template/充电算帐单已出账.xlsx
Binary files differ
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java
@@ -1,29 +1,50 @@
package com.ruoyi.order.controller;
import com.ruoyi.account.api.feignClient.AppUserCarClient;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient;
import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.alibaba.nacos.shaded.com.google.common.collect.Maps;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.chargingPile.api.feignClient.SiteClient;
import com.ruoyi.chargingPile.api.model.Site;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.WebUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.order.api.model.TChargingBill;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TOrderInvoiceQuery;
import com.ruoyi.order.api.vo.ChargingBillListVO;
import com.ruoyi.order.api.vo.ChargingBillVO;
import com.ruoyi.order.api.vo.ChargingOrderTimeVO;
import com.ruoyi.order.dto.ChargingBillQuery;
import com.ruoyi.order.dto.ChargingListQuery;
import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.vo.TOrderInvoiceVO;
import com.ruoyi.order.export.*;
import com.ruoyi.order.service.*;
import com.ruoyi.order.vo.ChargingOrderListInfoVO;
import com.ruoyi.payment.api.feignClient.AliPaymentClient;
import com.ruoyi.payment.api.feignClient.WxPaymentClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
 * <p>
@@ -39,53 +60,279 @@
public class ChargingBillController {
    @Resource
    private TChargingOrderService chargingOrderService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private TOrderEvaluateService orderEvaluateService;
    @Resource
    private WxPaymentClient wxPaymentClient;
    @Resource
    private RedisService redisService;
    @Resource
    private AliPaymentClient aliPaymentClient;
    @Resource
    private TShoppingOrderService shoppingOrderService;
    @Resource
    private AppUserClient appUserClient;
    @Resource
    private TVipOrderService vipOrderService;
    @Resource
    private ParkingLotClient parkingLotClient;
    @Resource
    private TChargingOrderRefundService chargingOrderRefundService;
    @Resource
    private TShoppingOrderRefundService shoppingOrderRefundService;
    @Resource
    private TVipOrderRefundService vipOrderRefundService;
    private TChargingBillService chargingBillService;
    @Resource
    private SiteClient siteClient;
    @Resource
    private ChargingPileClient chargingPileClient;
    @Resource
    private ChargingGunClient chargingGunClient;
    @Resource
    private AppUserCarClient appUserCarClient;
    @Resource
    private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService;
    @ResponseBody
    @PostMapping(value = "/chargingList")
    @ApiOperation(value = "充电算帐单列表查询", tags = {"管理后台-充电算账单"})
    public AjaxResult<ChargingBillVO> chargingList(@RequestBody ChargingListQuery dto) {
    private TChargingOrderService chargingOrderService;
        return AjaxResult.success(null);
    @PostMapping(value = "/chargingBillList")
    @ApiOperation(value = "充电算帐单列表查询", tags = {"管理后台-充电算账单"})
    public AjaxResult<ChargingBillVO> chargingBillList(@RequestBody ChargingListQuery dto) {
        ChargingBillVO res = chargingBillService.chargingBillList(dto);
        return AjaxResult.success(res);
    }
    @PostMapping(value = "/chargingBillListR")
    public R<ChargingBillVO> chargingBillListR(@RequestBody ChargingListQuery dto) {
        ChargingBillVO res = chargingBillService.chargingBillList(dto);
        return R.ok(res);
    }
    @GetMapping(value = "/chargingBillListExport")
    public R<ChargingBillVO> chargingBillListExport(String uid) {
        return R.ok(null);
    }
    @ApiOperation(value = "导出", tags = {"管理后台-充电算账单"})
    @PostMapping("/export")
    public void export(@RequestBody ChargingListQuery dto)
    {
        ChargingBillVO res = chargingBillService.chargingBillList(dto);
        List<ChargingBillListVO> list = res.getList().getRecords();
        List<TChargingBillExport> tChargingBillExports = new ArrayList<>();
        for (ChargingBillListVO orderInvoiceVO : list) {
            TChargingBillExport tChargingBillExport = new TChargingBillExport();
            tChargingBillExport.setCode(orderInvoiceVO.getCode());
            tChargingBillExport.setBillType("月账单");
            tChargingBillExport.setType(orderInvoiceVO.getType().toString());
            tChargingBillExport.setBillWeek(orderInvoiceVO.getBillWeek());
            tChargingBillExport.setSiteName(orderInvoiceVO.getSiteName());
            tChargingBillExport.setPaymentAmount(orderInvoiceVO.getPaymentAmount());
            tChargingBillExport.setElectrovalence(orderInvoiceVO.getElectrovalence());
            tChargingBillExport.setServiceCharge(orderInvoiceVO.getServiceCharge());
            tChargingBillExport.setChargingCapacity(orderInvoiceVO.getChargingCapacity());
            Integer chargingSecond = orderInvoiceVO.getChargingSecond();
            // 根据秒数 转换为xx小时xx分钟xx秒 如果小时为0不展示 如果分钟为0则不展示
            // 计算小时、分钟和秒
            int hours = chargingSecond / 60 / 60;
            int minutes = chargingSecond /60 % 60;
            int seconds = 0; // 如果没有秒数,则默认是0
            // 构造结果字符串
            StringBuilder result = new StringBuilder();
            if (hours > 0) {
                result.append(hours).append("小时");
            }
            if (minutes > 0) {
                result.append(minutes).append("分钟");
            }
            if (seconds > 0 || result.length() == 0) { // 如果秒数大于0,或者小时和分钟都为0,则显示秒数
                result.append(seconds).append("秒");
            }
            tChargingBillExport.setChargingTime(result.toString());
            tChargingBillExport.setOrderCount(orderInvoiceVO.getOrderCount());
            tChargingBillExport.setBillTime(orderInvoiceVO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            tChargingBillExports.add(tChargingBillExport);
        }
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TChargingBillExport.class, tChargingBillExports);
        HttpServletResponse response = WebUtils.response();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("月账单-"+res.getCategory()+"-"+res.getBillWeek()+"-"+res.getSiteName()+".xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    @ApiOperation(value = "下载-未出账", tags = {"管理后台-充电算账单"})
    @GetMapping("/download")
    public void download(String uid)
    {
        List<ChargingBillExport> chargingBillExports = new ArrayList<>();
        List<ChargingBillRefundExport> chargingBillRefundExports = new ArrayList<>();
        List<ChargingBillPayExport> chargingBillPayExports = new ArrayList<>();
        TChargingBill byId = chargingBillService.getById(uid);
        ChargingBillExport chargingBillExport = new ChargingBillExport();
        chargingBillExport.setCode(byId.getCode());
        // todo 确认商户类型
        chargingBillExport.setAccountType("商户类型");
        chargingBillExport.setType(byId.getType().toString());
        chargingBillExport.setBillType("月结");
        LocalDateTime billTime = byId.getBillTime();
        // 将billTime 减去一个月 转化为yyyy-MM格式字符串
        billTime = billTime.minusMonths(1);
        chargingBillExport.setBillWeek(DateUtils.parseDateToStr("yyyy-MM",DateUtils.toDate(billTime)));
        chargingBillExport.setBillTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(billTime)));
        chargingBillExport.setState("未出账");
        List<Site> data = siteClient.getSiteByIds(Arrays.asList(byId.getSiteId())).getData();
        if (!data.isEmpty()){
            chargingBillExport.setSiteName(data.get(0).getName());
        }
        // 根据账单的出账时间 查询上个月的充电订单
        LocalDateTime localDate = byId.getBillTime().minusMonths(1);
        // 账单周期
        // 获取 LocalDate 对象
        LocalDate date = localDate.toLocalDate();
        // 获取该月份的第一天
        LocalDate firstDayOfMonth = date.withDayOfMonth(1);
        // 获取该月份的最后一天
        LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
        QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>()
                .between("create_time", firstDayOfMonth, lastDayOfMonth)
                .eq("status", 5)
                .eq("recharge_payment_status", 2);
        if (byId.getType() == 2) {
            eq.eq("site_id", byId.getSiteId());
        }
        BigDecimal paymentAmount = new BigDecimal("0");
        BigDecimal refundAmount = new BigDecimal("0");
        BigDecimal income = new BigDecimal("0");
        List<TChargingOrder> tChargingOrders = chargingOrderService.list(eq);
        // 累加支付金额
        int i =1;
        for (TChargingOrder tChargingOrder : tChargingOrders) {
            // 账单信息
            paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount());
            if (tChargingOrder.getRefundStatus()!=null && tChargingOrder.getRefundStatus()==2){
                refundAmount = refundAmount.add(tChargingOrder.getRefundAmount());
            }
            // 退款信息
            ChargingBillRefundExport chargingBillRefundExport = new ChargingBillRefundExport();
            ChargingBillPayExport chargingBillPayExport = new ChargingBillPayExport();
            chargingBillRefundExport.setId(i+"");
            switch (tChargingOrder.getRechargePaymentType()){
                case 1:
                    chargingBillRefundExport.setPlatform("微信");
                    chargingBillRefundExport.setPlatformPay("微信小程序支付");
                    chargingBillPayExport.setPlatform("微信");
                    chargingBillPayExport.setPlatformPay("微信小程序支付");
                    break;
                case 2:
                    chargingBillRefundExport.setPlatform("支付宝");
                    chargingBillRefundExport.setPlatformPay("支付宝小程序支付");
                    chargingBillPayExport.setPlatform("支付宝");
                    chargingBillPayExport.setPlatformPay("支付宝小程序支付");
            }
            chargingBillRefundExport.setRechargeSerialNumber(tChargingOrder.getRechargeSerialNumber());
            chargingBillRefundExport.setCode(tChargingOrder.getCode());
            chargingBillRefundExport.setPayTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getPayTime())));
            if (tChargingOrder.getRefundTime()!=null){
                chargingBillRefundExport.setRefundTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getRefundTime())));
            }
            chargingBillRefundExport.setRefundMoney(tChargingOrder.getRefundAmount().toString());
            chargingBillRefundExport.setRefundRemark(tChargingOrder.getRefundReason());
            chargingBillRefundExport.setRefundCode(tChargingOrder.getRefundCode());
            chargingBillRefundExport.setRefundSerialNumber(tChargingOrder.getRefundSerialNumber());
            chargingBillRefundExports.add(chargingBillRefundExport);
            // 支付信息
            chargingBillPayExport.setId(i+"");
            chargingBillPayExport.setRechargeSerialNumber(tChargingOrder.getRechargeSerialNumber());
            chargingBillPayExport.setCode(tChargingOrder.getCode());
            chargingBillPayExport.setPayTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getPayTime())));
            chargingBillPayExport.setPaymentAmount(tChargingOrder.getPaymentAmount().toString());
            chargingBillPayExport.setTotal("");
            chargingBillPayExports.add(chargingBillPayExport);
            i++;
        }
        chargingBillExport.setPaymentAmount(paymentAmount);
        chargingBillExport.setRefundAmount(refundAmount);
        chargingBillExport.setIncome(paymentAmount.subtract(refundAmount));
        chargingBillExports.add(chargingBillExport);
        // 导出
        List<Map<String, Object>> sheetsList = new ArrayList<>();
        AtomicInteger atomicInteger = new AtomicInteger();
        for (int i1 = 0; i1 < 3; i1++) {
            String sheetName="";
            switch (i1){
                case 1:
                    sheetName= "账单信息";
                    Map<String, Object> exportMap = Maps.newHashMap();
                    ExportParams exportParams = new ExportParams(null, sheetName, ExcelType.HSSF);
                    // 以下3个参数为API中写死的参数名 分别是sheet配置/导出类(注解定义)/数据集
                    exportMap.put("title", exportParams);
                    exportMap.put("entity", ChargingBillExport.class);
                    exportMap.put("data", chargingBillExports);
                    // 加入多sheet配置列表
                    sheetsList.add(exportMap);
                    break;
                case 2:
                    sheetName= "退款订单";
                    Map<String, Object> exportMap1 = Maps.newHashMap();
                    ExportParams exportParams1 = new ExportParams(null, sheetName, ExcelType.HSSF);
                    // 以下3个参数为API中写死的参数名 分别是sheet配置/导出类(注解定义)/数据集
                    exportMap1.put("title", exportParams1);
                    exportMap1.put("entity", ChargingBillRefundExport.class);
                    exportMap1.put("data", chargingBillRefundExports);
                    // 加入多sheet配置列表
                    sheetsList.add(exportMap1);
                    break;
                case 3:
                    sheetName= "支付记录";
                    Map<String, Object> exportMap2 = Maps.newHashMap();
                    ExportParams exportParams2 = new ExportParams(null, sheetName, ExcelType.HSSF);
                    // 以下3个参数为API中写死的参数名 分别是sheet配置/导出类(注解定义)/数据集
                    exportMap2.put("title", exportParams2);
                    exportMap2.put("entity", ChargingBillPayExport.class);
                    exportMap2.put("data", chargingBillPayExports);
                    // 加入多sheet配置列表
                    sheetsList.add(exportMap2);
                    break;
            }
        }
        if (!chargingBillRefundExports.isEmpty()){
            ChargingBillRefundExport chargingBillRefundExport = chargingBillRefundExports.get(0);
            chargingBillRefundExport.setTotal(refundAmount.toString());
        }
        if (!chargingBillPayExports.isEmpty()){
            ChargingBillPayExport chargingBillPayExport = chargingBillPayExports.get(0);
            chargingBillPayExport.setTotal(refundAmount.toString());
        }
        String type="";
        String type1="";
        switch (byId.getType()){
            case 1:
                type = "全站账单";
                type1 = "全站";
                break;
            case 2:
                type = "各个站点账单";
                List<Site> data1 = siteClient.getSiteByIds(Arrays.asList(byId.getSiteId())).getData();
                if (!data1.isEmpty()){
                    type1 = data.get(0).getName();
                }
                break;
        }
        String s = DateUtils.parseDateToStr("yyyy-MM", DateUtils.toDate(billTime));
        Workbook workbook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
        HttpServletResponse response = WebUtils.response();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("账户结算账单-月账单-"+type+"-"+s+"-"+type1+".xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/FinancialSettlementController.java
@@ -12,7 +12,7 @@
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.vo.ChargingOrderListInfoVO;
import com.ruoyi.order.api.vo.ChargingOrderTimeVO;
import com.ruoyi.order.dto.ChargingListQuery;
import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.service.*;
import com.ruoyi.payment.api.feignClient.AliPaymentClient;
import com.ruoyi.payment.api.feignClient.WxPaymentClient;
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillDetailExport.java
New file
@@ -0,0 +1,62 @@
package com.ruoyi.order.export;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@ApiModel(value = "导出充电算帐单明细")
public class ChargingBillDetailExport implements Serializable {
    @Excel(name = "序号",width = 30)
    private String id;
    @Excel(name = "订单编号",width = 30)
    private String code;
    @Excel(name  = "电站名称",width = 30)
    private String siteName;
    @Excel(name  = "终端名称",width = 30)
    private String terminalName;
    @Excel(name  = "终端编号",width = 30)
    private String terminalCode;
    @Excel(name = "收款方式(直接修改成订单分类)",width = 30,replace = {"线上订单_1","线下订单_2"})
    private String type;
    @Excel(name = "支付方式(预付/先充后付)",width = 30)
    private String billType;
    @Excel(name  = "充电启动方式(对应订单类型)",width = 30)
    private String billWeek;
    @Excel(name  = "订单创建时间(支付订单)",width = 30)
    private String orderAmount;
    @Excel(name  = "充电开始时间(充电桩订单)",width = 30)
    private BigDecimal discount;
    @Excel(name  = "充电结束时间(充电桩订单)",width = 30)
    private BigDecimal discount1;
    @Excel(name  = "订单状态",width = 30,replace = {"未知_0","等待中_1","启动中_2","充电中_3","停止_4","已结束_5"})
    private BigDecimal d;
    @Excel(name  = "判定结束原因",width = 30)
    private BigDecimal electrovalence1;
    @Excel(name  = "充电电费(元)",width = 30)
    private BigDecimal electrovalence;
    @Excel(name  = "充电服务费(元)",width = 30)
    private BigDecimal serviceCharge;
    @Excel(name  = "充电费用(元)",width = 30)
    private BigDecimal serviceCharge1;
    @Excel(name  = "优惠券抵扣",width = 30)
    private BigDecimal chargingCapacity;
    @Excel(name  = "充电电量(度)",width = 30)
    private BigDecimal chargingCapacity1;
    @Excel(name  = "充电时长(从充电桩订单中获取)",width = 30)
    private String chargingTime;
    @Excel(name  = "充电后soc",width = 30)
    private Integer orderCount;
    @Excel(name  = "客户昵称",width = 30)
    private Integer orderCount1;
    @Excel(name  = "手机号",width = 30)
    private Integer orderCount2;
    @Excel(name  = "车牌号",width = 30)
    private Integer orderCount3;
    @Excel(name  = "汽车类型",width = 30)
    private Integer orderCount4;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillExport.java
New file
@@ -0,0 +1,41 @@
package com.ruoyi.order.export;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@ApiModel(value = "导出充电算帐单-导出")
public class ChargingBillExport implements Serializable {
    @Excel(name = "账单编号",width = 30)
    private String code;
    @Excel(name = "账户类型",width = 30)
    private String accountType;
    @Excel(name = "账单分类",width = 30,replace = {"全站账单_1","各个站点账单_2"})
    private String type;
    @Excel(name = "账单类型",width = 30)
    private String billType;
    @Excel(name  = "账单周期",width = 30 )
    private String billWeek;
    @Excel(name  = "账单生成日期",width = 30)
    private String billTime;
    @Excel(name  = "状态",width = 30)
    private String state;
    @Excel(name  = "站点名称",width = 30)
    private String siteName;
    @Excel(name  = "支付金额",width = 30)
    private BigDecimal paymentAmount;
    @Excel(name  = "退款金额",width = 30)
    private BigDecimal refundAmount;
    @Excel(name  = "入账金额",width = 30)
    private BigDecimal income;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillPayExport.java
New file
@@ -0,0 +1,28 @@
package com.ruoyi.order.export;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(value = "导出充电算帐单支付-导出")
public class ChargingBillPayExport implements Serializable {
    @Excel(name = "序号",width = 30)
    private String id;
    @Excel(name = "支付平台",width = 30)
    private String platform;
    @Excel(name = "支付方式名称",width = 30)
    private String platformPay;
    @Excel(name = "支付平台流水号",width = 30)
    private String rechargeSerialNumber;
    @Excel(name = "平台订单号",width = 30)
    private String code;
    @Excel(name = "支付时间",width = 30)
    private String payTime;
    @Excel(name = "支付金额",width = 30)
    private String paymentAmount;
    @Excel(name = "合计",width = 30)
    private String total;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillRefundExport.java
New file
@@ -0,0 +1,37 @@
package com.ruoyi.order.export;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@ApiModel(value = "导出充电算帐单退款-导出")
public class ChargingBillRefundExport implements Serializable {
    @Excel(name = "序号",width = 30)
    private String id;
    @Excel(name = "支付平台",width = 30)
    private String platform;
    @Excel(name = "支付方式名称",width = 30)
    private String platformPay;
    @Excel(name = "源(支付平台流水号)",width = 30)
    private String rechargeSerialNumber;
    @Excel(name = "源(平台支付订单号)",width = 30)
    private String code;
    @Excel(name = "支付时间",width = 30)
    private String payTime;
    @Excel(name = "退款时间",width = 30)
    private String refundTime;
    @Excel(name = "退款金额",width = 30)
    private String refundMoney;
    @Excel(name = "退款描述",width = 30)
    private String refundRemark;
    @Excel(name = "平台退款编号",width = 30)
    private String refundCode;
    @Excel(name = "支付平台退款流水号",width = 30)
    private String refundSerialNumber;
    @Excel(name = "合计",width = 30)
    private String total;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/TChargingBillExport.java
New file
@@ -0,0 +1,39 @@
package com.ruoyi.order.export;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.models.auth.In;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@ApiModel(value = "充电算帐单列表-导出")
public class TChargingBillExport implements Serializable {
    @Excel(name = "账单编号",width = 30)
    private String code;
    @Excel(name = "账单类型",width = 30)
    private String billType;
    @Excel(name = "账单分类",width = 30,replace = {"全站账单_1","各个站点账单_2"})
    private String type;
    @Excel(name  = "账单周期",width = 30 )
    private String billWeek;
    @Excel(name  = "站点名称",width = 30)
    private String siteName;
    @Excel(name  = "总金额",width = 30)
    private BigDecimal paymentAmount;
    @Excel(name  = "总电费",width = 30)
    private BigDecimal electrovalence;
    @Excel(name  = "总服务费",width = 30)
    private BigDecimal serviceCharge;
    @Excel(name  = "总电量",width = 30)
    private BigDecimal chargingCapacity;
    @Excel(name  = "充电时长",width = 30)
    private String chargingTime;
    @Excel(name  = "充电订单数量",width = 30)
    private Integer orderCount;
    @Excel(name  = "账单生成日期",width = 30)
    private String billTime;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingBillMapper.java
New file
@@ -0,0 +1,30 @@
package com.ruoyi.order.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.model.TChargingBill;
import com.ruoyi.order.api.vo.ChargingBillListVO;
import com.ruoyi.order.api.model.ChargingListQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xiaochen
 * @since 2024-08-07
 */
@Mapper
public interface TChargingBillMapper extends BaseMapper<TChargingBill> {
    List<ChargingBillListVO> chargingBillList(
            @Param("pageInfo") PageInfo<ChargingBillListVO> pageInfo,
            @Param("req") ChargingListQuery dto,
            @Param("startTime1")String startTime1,
            @Param("startTime2")String startTime2);
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java
@@ -4,6 +4,7 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.model.TChargingOrderRefund;
import com.ruoyi.order.api.query.ChargingOrderQuery;
@@ -76,7 +77,7 @@
    List<Map<String, BigDecimal>> getYearData(List<Long> chargingOrderIds);
    List<ChargingOrderListVO> chargingList(@Param("pageInfo")PageInfo<ChargingOrderListVO> pageInfo, @Param("req")ChargingListQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2, @Param("endTime1")String endTime1, @Param("endTime2")String endTime2);
    List<ChargingOrderListVO> chargingList(@Param("pageInfo")PageInfo<ChargingOrderListVO> pageInfo, @Param("req") ChargingListQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2, @Param("endTime1")String endTime1, @Param("endTime2")String endTime2);
    List<ChargingOrderListVO> chargingList1( @Param("req")ChargingListQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2, @Param("endTime1")String endTime1, @Param("endTime2")String endTime2);
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingBillService.java
New file
@@ -0,0 +1,20 @@
package com.ruoyi.order.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.order.api.model.TChargingBill;
import com.ruoyi.order.api.vo.ChargingBillVO;
import com.ruoyi.order.api.model.ChargingListQuery;
/**
 * <p>
 *  服务类
 * </p>
 *
 * @author xiaochen
 * @since 2024-08-07
 */
public interface TChargingBillService extends IService<TChargingBill> {
    ChargingBillVO chargingBillList(ChargingListQuery dto);
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java
@@ -5,14 +5,13 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.model.TChargingOrderRefund;
import com.ruoyi.order.api.query.ChargingOrderQuery;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
import com.ruoyi.order.api.vo.ChargingOrderTimeVO;
import com.ruoyi.order.api.vo.ChargingOrderVO;
import com.ruoyi.order.api.vo.TCharingOrderVO;
import com.ruoyi.order.dto.*;
import com.ruoyi.order.vo.ChargingOrderListInfoVO;
@@ -141,15 +140,15 @@
     * @param query
     */
    void chargeMonitoring(UploadRealTimeMonitoringDataQuery query);
    /**
     * 自动结束充电后的处理逻辑
     * @param code
     */
    void endCharge(String code, Integer endMode);
    /**
     * 异常结束充电处理逻辑
     * @param orderCode
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java
New file
@@ -0,0 +1,327 @@
package com.ruoyi.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.account.api.feignClient.AppUserCarClient;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.account.api.model.TAppUserCar;
import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient;
import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
import com.ruoyi.chargingPile.api.feignClient.SiteClient;
import com.ruoyi.chargingPile.api.model.Site;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient;
import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.vo.ChargingBillListVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.model.TChargingBill;
import com.ruoyi.order.api.vo.ChargingBillVO;
import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.mapper.TChargingBillMapper;
import com.ruoyi.order.mapper.TChargingOrderMapper;
import com.ruoyi.order.service.TChargingBillService;
import org.omg.CORBA.PRIVATE_MEMBER;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.Arrays;
import java.util.List;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaochen
 * @since 2024-08-07
 */
@Service
public class TChargingBillServiceImpl extends ServiceImpl<TChargingBillMapper, TChargingBill> implements TChargingBillService {
    @Resource
    private TChargingOrderMapper chargingOrderList;
    @Resource
    private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient;
    @Resource
    private SiteClient siteClient;
    @Resource
    private ChargingPileClient chargingPileClient;
    @Resource
    private ChargingGunClient chargingGunClient;
    @Resource
    private AppUserClient appUserClient;
    @Resource
    private AppUserCarClient appUserCarClient;
    @Override
    public ChargingBillVO chargingBillList(ChargingListQuery dto) {
        ChargingBillVO chargingBillVO = new ChargingBillVO();
        String startTime1 = null;
        String startTime2 = null;
        if (StringUtils.hasLength(dto.getStartTime())){
            String[] split = dto.getStartTime().split(" - ");
            startTime1 = split[0];
            startTime2 = split[1];
        }
        PageInfo<ChargingBillListVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
        List<ChargingBillListVO> list = this.baseMapper.chargingBillList(pageInfo,dto,startTime1,startTime2);
        BigDecimal paymentAmountTotal = new BigDecimal("0");
        BigDecimal orderAmountTotal = new BigDecimal("0");
        BigDecimal electrovalenceTotal = new BigDecimal("0");
        BigDecimal serviceChargeTotal = new BigDecimal("0");
        BigDecimal commissionAmountTotal = new BigDecimal("0");
        BigDecimal sharingAmountTotal = new BigDecimal("0");
        BigDecimal chargingCapacityTotal = new BigDecimal("0");
        BigDecimal discountTotal = new BigDecimal("0");
        int orderCount = 0;
        for (ChargingBillListVO chargingBillListVO : list) {
            String temp = "";
            String temp1 = "";
            switch (chargingBillListVO.getType()){
                case 1:
                    temp = "全站账单";
                    temp1 = "全站";
                    break;
                case 2:
                    temp = "各个站点账单";
                    temp1 = siteClient.getSiteByIds(Arrays.asList(chargingBillListVO.getSiteId())).getData().get(0).getName();
                    break;
            }
            chargingBillVO.setCategory(temp);
            chargingBillVO.setSiteName(temp1);
            chargingBillVO.setType("月账单");
            chargingBillVO.setCode(chargingBillListVO.getCode());
            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());
            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) {
                List<Site> data = siteClient.getSiteByIds(Arrays.asList(tChargingOrder.getSiteId())).getData();
                if (!data.isEmpty()){
                    chargingBillVO.setSiteName(data.get(0).getName());
                }
                TChargingPile data1 = chargingPileClient.getChargingPileById(tChargingOrder.getChargingPileId()).getData();
                TChargingGun data2 = chargingGunClient.getChargingGunById(tChargingOrder.getChargingGunId()).getData();
                if (data1!=null && data2!=null){
                    tChargingOrder.setTerminalName(data1.getName()+data2.getName());
                    tChargingOrder.setTerminalCode(data2.getCode());
                }
                tChargingOrder.setOrderClassification1("线上订单");
                tChargingOrder.setRechargePaymentType1("预付");
                tChargingOrder.setChargingType("充电桩接口充电服务");
                switch (tChargingOrder.getStatus()){
                    case 1:
                        tChargingOrder.setStatus1("等待中");
                        break;
                    case 2:
                        tChargingOrder.setStatus1("启动中");
                        break;
                    case 3:
                        tChargingOrder.setStatus1("充电中");
                        break;
                    case 4:
                        tChargingOrder.setStatus1("停止中");
                        break;
                    case 5:
                        tChargingOrder.setStatus1("已结束");
                         break;
                    case 0:
                        tChargingOrder.setStatus1("未知");
                        break;
                }
                if (tChargingOrder.getEndMode()!=null){
                    switch (tChargingOrder.getEndMode()){
                        case 1:
                            tChargingOrder.setEndMode1("主动终止");
                            break;
                        case 2:
                            tChargingOrder.setEndMode1("满电终止");
                            break;
                        case 3:
                            tChargingOrder.setEndMode1("费用不足终止");
                            break;
                        case 0:
                            tChargingOrder.setEndMode1("异常终止");
                            break;
                    }
                }
                BigDecimal add = tChargingOrder.getElectrovalence().add(tChargingOrder.getServiceCharge());
                tChargingOrder.setTotalAmount(add.toString());
                tChargingOrder.setDiscount(tChargingOrder.getCouponDiscountAmount().toString());
                UploadRealTimeMonitoringData data5 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(tChargingOrder.getCode()).getData();
                if (data5!=null){
                    if (data5.getTime_remaining()!=null){
                        chargingSecond+=data5.getTime_remaining()*60;
                    }
                }
                Integer cumulativeChargingTime = data5.getCumulative_charging_time();
                // 将其转化为xx小时xx分钟xx秒显示 如果是0小时则不展示小时 如果是0分钟则不展示分钟
                if (cumulativeChargingTime!=null){
                    // 计算小时、分钟和秒
                    int hours = cumulativeChargingTime / 60;
                    int minutes = cumulativeChargingTime % 60;
                    int seconds = 0; // 如果没有秒数,则默认是0
                    StringBuilder result = new StringBuilder();
                    if (hours > 0) {
                        result.append(hours).append("小时");
                    }
                    if (minutes > 0) {
                        result.append(minutes).append("分钟");
                    }
                    if (seconds > 0 || result.length() == 0) { // 如果秒数大于0,或者小时和分钟都为0,则显示秒数
                        result.append(seconds).append("秒");
                    }
                    tChargingOrder.setChargingTime(result.toString());
                }
                tChargingOrder.setEndSoc(data5.getSoc().toString());
                TAppUser data3 = appUserClient.getUserById(tChargingOrder.getAppUserId()).getData();
                if (tChargingOrder.getAppUserCarId()!=null){
                    List<TAppUserCar> data4 = appUserCarClient.getCarByIds(Arrays.asList(tChargingOrder.getAppUserCarId())).getData();
                    if (!data4.isEmpty()){
                        tChargingOrder.setLicensePlate(data4.get(0).getLicensePlate());
                        tChargingOrder.setVehicleModel(data4.get(0).getVehicleModel());
                    }
                }
                if (data3!=null)tChargingOrder.setUserName(data3.getName());
                // 累加实收金额 支付金额减去退款金额
                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.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;
            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);
        chargingBillVO.setOrderAmount(orderAmountTotal);
        chargingBillVO.setElectrovalence(electrovalenceTotal);
        chargingBillVO.setServiceCharge(serviceChargeTotal);
        chargingBillVO.setOrderCount(orderCount);
        chargingBillVO.setCommissionAmount(commissionAmountTotal);
        chargingBillVO.setSharingAmount(sharingAmountTotal);
        chargingBillVO.setDiscount(discountTotal);
        pageInfo.setRecords(list);
        chargingBillVO.setList(pageInfo);
        return chargingBillVO;
    }
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        // 将时间转化为字符串 只保留年月日 格式为yyyy-MM-dd
        String format = now.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    }
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -4,7 +4,6 @@
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.*;
import com.ruoyi.account.api.model.*;
@@ -16,11 +15,9 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.integration.api.feignClient.ChargingHandshakeClient;
import com.ruoyi.integration.api.feignClient.PlatformStartChargingReplyClient;
import com.ruoyi.integration.api.feignClient.SendMessageClient;
@@ -43,6 +40,10 @@
import com.ruoyi.order.api.vo.TCharingOrderVO;
import com.ruoyi.order.dto.*;
import com.ruoyi.order.mapper.TChargingOrderMapper;
import com.ruoyi.order.service.TChargingOrderAccountingStrategyService;
import com.ruoyi.order.service.TChargingOrderRefundService;
import com.ruoyi.order.service.TChargingOrderService;
import com.ruoyi.order.service.TOrderEvaluateService;
import com.ruoyi.order.service.*;
import com.ruoyi.other.api.domain.TCoupon;
import com.ruoyi.other.api.domain.TGoods;
@@ -57,7 +58,6 @@
import com.ruoyi.payment.api.model.RefundResp;
import com.ruoyi.payment.api.model.WxPaymentRefundModel;
import com.ruoyi.payment.api.vo.*;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import io.seata.spring.annotation.GlobalTransactional;
import io.swagger.annotations.ApiModelProperty;
@@ -77,7 +77,6 @@
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingBillMapper.xml
New file
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.order.mapper.TChargingBillMapper">
    <select id="chargingBillList" resultType="com.ruoyi.order.api.vo.ChargingBillListVO">
    select t1.* from t_charging_bill t1
    where 1=1
        <if test="req.type != null ">
            and t1.type = #{req.type}
        </if>
      <if test="req.state != null ">
            and t1.status = #{req.state}
        </if>
        <if test="startTime1 != null and startTime1!=''">
            and (t1.bill_time between #{startTime1} and #{startTime2}
        </if>
        <if test="req.uid != null and req.uid!=''">
            and t1.id = #{req.uid}
        </if>
    </select>
</mapper>