瀏覽代碼

feat(export): 增加充电订单和用户支付订单导出功能

- 充电订单信息支持根据查询参数导出Excel文件
- 用户支付订单信息支持导出功能,包含详细支付状态和类型说明
- ChargeOrderInfoMapper和UserOrderInfoMapper新增导出数据查询方法
- 对充电订单和用户支付订单的查询条件和字段做适配调整
- Controller层新增导出接口,增加权限控制和响应头设置
- Service层新增导出列表方法实现数据获取
- 查询DTO和XML文件更新,新增导出所需字段及条件
- 使用EasyExcel实现导出Excel操作,支持文件名中文编码处理
wzq 3 周之前
父節點
當前提交
ec9b4d6d9c

+ 23 - 0
src/main/java/com/zsElectric/boot/business/controller/ChargeOrderInfoController.java

@@ -1,6 +1,11 @@
 package com.zsElectric.boot.business.controller;
 
+import cn.idev.excel.EasyExcel;
+import com.zsElectric.boot.business.model.dto.ChargeOrderInfoExportDTO;
 import com.zsElectric.boot.business.service.ChargeOrderInfoService;
+import com.zsElectric.boot.business.service.ThirdPartyChargingService;
+import com.zsElectric.boot.charging.entity.ThirdPartyStationInfo;
+import jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -18,6 +23,11 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import jakarta.validation.Valid;
 
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
 /**
  * 充电订单信息前端控制层
  *
@@ -70,4 +80,17 @@ public class ChargeOrderInfoController  {
         boolean result = chargeOrderInfoService.deleteChargeOrderInfos(ids);
         return Result.judge(result);
     }
+
+    @Operation(summary = "导出充电订单信息")
+    @PostMapping("/export")
+    @PreAuthorize("@ss.hasPerm('business:charge-order-info:export')")
+    public void exportChargeOrderInfo(@RequestBody ChargeOrderInfoQuery queryParams, HttpServletResponse response) throws IOException {
+        String fileName = "充电订单信息.xlsx";
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
+
+        List<ChargeOrderInfoExportDTO> exportList = chargeOrderInfoService.listExportChargeOrderInfo(queryParams);
+        EasyExcel.write(response.getOutputStream(), ChargeOrderInfoExportDTO.class).sheet("充电订单信息")
+                .doWrite(exportList);
+    }
 }

+ 21 - 0
src/main/java/com/zsElectric/boot/business/controller/UserOrderInfoController.java

@@ -1,6 +1,9 @@
 package com.zsElectric.boot.business.controller;
 
+import cn.idev.excel.EasyExcel;
+import com.zsElectric.boot.business.model.dto.UserOrderInfoExportDTO;
 import com.zsElectric.boot.business.service.UserOrderInfoService;
+import jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -18,6 +21,11 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import jakarta.validation.Valid;
 
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
 /**
  * 用户支付订单信息前端控制层
  *
@@ -78,4 +86,17 @@ public class UserOrderInfoController {
         boolean result = userOrderInfoService.deleteUserOrderInfos(ids);
         return Result.judge(result);
     }
+
+    @Operation(summary = "导出用户支付订单信息")
+    @PostMapping("/export")
+    @PreAuthorize("@ss.hasPerm('business:user-order-info:export')")
+    public void exportUserOrderInfo(@RequestBody UserOrderInfoQuery queryParams, HttpServletResponse response) throws IOException {
+        String fileName = "充值订单信息.xlsx";
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
+
+        List<UserOrderInfoExportDTO> exportList = userOrderInfoService.listExportUserOrderInfo(queryParams);
+        EasyExcel.write(response.getOutputStream(), UserOrderInfoExportDTO.class).sheet("充值订单信息")
+                .doWrite(exportList);
+    }
 }

+ 11 - 0
src/main/java/com/zsElectric/boot/business/mapper/ChargeOrderInfoMapper.java

@@ -1,6 +1,7 @@
 package com.zsElectric.boot.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zsElectric.boot.business.model.dto.ChargeOrderInfoExportDTO;
 import com.zsElectric.boot.business.model.entity.ChargeOrderInfo;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zsElectric.boot.business.model.query.ChargeOrderInfoQuery;
@@ -9,6 +10,8 @@ import com.zsElectric.boot.business.model.vo.ChargeOrderInfoVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 充电订单信息Mapper接口
  *
@@ -30,4 +33,12 @@ public interface ChargeOrderInfoMapper extends BaseMapper<ChargeOrderInfo> {
     Page<ChargeOrderInfoVO> getPage(Page<Object> objectPage,@Param("queryParams") AppChargeOrderInfoQuery queryParams);
 
     ChargeOrderInfoVO queryOrder(@Param("chargeOrderNo") String chargeOrderNo);
+
+    /**
+     * 获取充电订单信息导出列表
+     *
+     * @param queryParams 查询参数
+     * @return 充电订单信息导出列表
+     */
+    List<ChargeOrderInfoExportDTO> listExportChargeOrderInfo(@Param("queryParams") ChargeOrderInfoQuery queryParams);
 }

+ 12 - 0
src/main/java/com/zsElectric/boot/business/mapper/UserOrderInfoMapper.java

@@ -2,11 +2,15 @@ package com.zsElectric.boot.business.mapper;
 
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zsElectric.boot.business.model.dto.UserOrderInfoExportDTO;
 import com.zsElectric.boot.business.model.entity.UserOrderInfo;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zsElectric.boot.business.model.query.UserOrderInfoQuery;
 import com.zsElectric.boot.business.model.vo.UserOrderInfoVO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 用户支付订单信息Mapper接口
@@ -25,4 +29,12 @@ public interface UserOrderInfoMapper extends BaseMapper<UserOrderInfo> {
      * @return {@link Page<UserOrderInfoVO>} 用户支付订单信息分页列表
      */
     Page<UserOrderInfoVO> getUserOrderInfoPage(Page<UserOrderInfoVO> page, UserOrderInfoQuery queryParams);
+
+    /**
+     * 获取用户支付订单信息导出列表
+     *
+     * @param queryParams 查询参数
+     * @return 用户支付订单信息导出列表
+     */
+    List<UserOrderInfoExportDTO> listExportUserOrderInfo(@Param("queryParams") UserOrderInfoQuery queryParams);
 }

+ 9 - 0
src/main/java/com/zsElectric/boot/business/model/query/ChargeOrderInfoQuery.java

@@ -1,9 +1,11 @@
 package com.zsElectric.boot.business.model.query;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.zsElectric.boot.common.base.BasePageQuery;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Getter;
 import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
 
@@ -36,12 +38,19 @@ public class ChargeOrderInfoQuery extends BasePageQuery {
     @Schema(description = "充电订单号")
     private String chargeOrderNo;
 
+    @Schema(description = "第三方充电站ID")
+    private Long thirdStationId;
+
     @Schema(description = "1 主动停止 2 充满停止 3 余额不足停止, 4电桩按钮停止")
     private Integer stopType;
 
     @Schema(description = "开始时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime startTime;
 
     @Schema(description = "结束时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime endTime;
 }

+ 13 - 0
src/main/java/com/zsElectric/boot/business/service/ChargeOrderInfoService.java

@@ -1,5 +1,6 @@
 package com.zsElectric.boot.business.service;
 
+import com.zsElectric.boot.business.model.dto.ChargeOrderInfoExportDTO;
 import com.zsElectric.boot.business.model.entity.ChargeOrderInfo;
 import com.zsElectric.boot.business.model.form.ChargeOrderInfoForm;
 import com.zsElectric.boot.business.model.form.applet.AppInvokeChargeForm;
@@ -10,6 +11,9 @@ import com.zsElectric.boot.business.model.vo.ChargeOrderInfoVO;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zsElectric.boot.business.model.vo.applet.AppChargeVO;
+import com.zsElectric.boot.charging.entity.ThirdPartyStationInfo;
+
+import java.util.List;
 
 /**
  * 充电订单信息服务类
@@ -73,4 +77,13 @@ public interface ChargeOrderInfoService extends IService<ChargeOrderInfo> {
     void orderSettlement(Long chargeOrderId);
 
     ChargeOrderInfoVO queryOrder(String chargeOrderNo);
+
+    /**
+     * 获取充电订单信息导出列表
+     *
+     * @param queryParams 查询参数
+     * @return 充电订单信息导出列表
+     */
+    List<ChargeOrderInfoExportDTO> listExportChargeOrderInfo(ChargeOrderInfoQuery queryParams);
+
 }

+ 10 - 0
src/main/java/com/zsElectric/boot/business/service/UserOrderInfoService.java

@@ -1,5 +1,6 @@
 package com.zsElectric.boot.business.service;
 
+import com.zsElectric.boot.business.model.dto.UserOrderInfoExportDTO;
 import com.zsElectric.boot.business.model.entity.UserOrderInfo;
 import com.zsElectric.boot.business.model.form.UserOrderInfoForm;
 import com.zsElectric.boot.business.model.form.applet.AppLevelOrderForm;
@@ -13,6 +14,7 @@ import com.zsElectric.boot.business.model.vo.applet.AppUserInfoVO;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -80,4 +82,12 @@ public interface UserOrderInfoService extends IService<UserOrderInfo> {
     IPage<UserOrderInfoVO> getTicketRecords(AppUserOrderInfoQuery queryParams);
 
     AppUserInfoVO getAppletUserInfo(Long userId);
+
+    /**
+     * 获取用户支付订单信息导出列表
+     *
+     * @param queryParams 查询参数
+     * @return 用户支付订单信息导出列表
+     */
+    List<UserOrderInfoExportDTO> listExportUserOrderInfo(UserOrderInfoQuery queryParams);
 }

+ 15 - 0
src/main/java/com/zsElectric/boot/business/service/impl/ChargeOrderInfoServiceImpl.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zsElectric.boot.business.converter.ChargeOrderInfoConverter;
 import com.zsElectric.boot.business.mapper.*;
+import com.zsElectric.boot.business.model.dto.ChargeOrderInfoExportDTO;
 import com.zsElectric.boot.business.model.entity.*;
 import com.zsElectric.boot.business.model.form.ChargeOrderInfoForm;
 import com.zsElectric.boot.business.model.form.applet.AppInvokeChargeForm;
@@ -23,6 +24,7 @@ import com.zsElectric.boot.business.service.ChargeOrderInfoService;
 import com.zsElectric.boot.business.service.UserAccountService;
 import com.zsElectric.boot.charging.dto.StartChargingRequestDTO;
 import com.zsElectric.boot.charging.dto.StartChargingResponseVO;
+import com.zsElectric.boot.charging.entity.ThirdPartyStationInfo;
 import com.zsElectric.boot.charging.service.ChargingBusinessService;
 import com.zsElectric.boot.charging.vo.EquipmentAuthResponseVO;
 import com.zsElectric.boot.charging.vo.StopChargingOperationResponseVO;
@@ -68,6 +70,8 @@ public class ChargeOrderInfoServiceImpl extends ServiceImpl<ChargeOrderInfoMappe
 
     private final AppletHomeService appletHomeService;
 
+    private final ThirdPartyStationInfoMapper thirdPartyStationInfoMapper;
+
     //充电订单号前缀
     private final String ORDER_NO_PREFIX = "CD";
     //设备流水号前缀
@@ -307,6 +311,17 @@ public class ChargeOrderInfoServiceImpl extends ServiceImpl<ChargeOrderInfoMappe
         return baseMapper.queryOrder(chargeOrderNo);
     }
 
+    /**
+     * 获取充电订单信息导出列表
+     *
+     * @param queryParams 查询参数
+     * @return 充电订单信息导出列表
+     */
+    @Override
+    public List<ChargeOrderInfoExportDTO> listExportChargeOrderInfo(ChargeOrderInfoQuery queryParams) {
+        return baseMapper.listExportChargeOrderInfo(queryParams);
+    }
+
     /**
      * 创建商户订单号
      * 要求 32个字符内,只能是数字、大小写字母_-|*且在同一个商户号下唯一

+ 12 - 0
src/main/java/com/zsElectric/boot/business/service/impl/UserOrderInfoServiceImpl.java

@@ -8,6 +8,7 @@ import com.google.gson.Gson;
 import com.google.gson.JsonObject;
 import com.zsElectric.boot.business.model.entity.UserRefundsOrderInfo;
 import com.zsElectric.boot.business.mapper.*;
+import com.zsElectric.boot.business.model.dto.UserOrderInfoExportDTO;
 import com.zsElectric.boot.business.model.entity.*;
 import com.zsElectric.boot.business.model.form.applet.AppLevelOrderForm;
 import com.zsElectric.boot.business.model.form.applet.AppUserPayForm;
@@ -782,4 +783,15 @@ public class UserOrderInfoServiceImpl extends ServiceImpl<UserOrderInfoMapper, U
         return money + "";
     }
 
+    /**
+     * 获取用户支付订单信息导出列表
+     *
+     * @param queryParams 查询参数
+     * @return 用户支付订单信息导出列表
+     */
+    @Override
+    public List<UserOrderInfoExportDTO> listExportUserOrderInfo(UserOrderInfoQuery queryParams) {
+        return baseMapper.listExportUserOrderInfo(queryParams);
+    }
+
 }

+ 177 - 64
src/main/resources/mapper/business/ChargeOrderInfoMapper.xml

@@ -5,85 +5,95 @@
     <!-- 获取充电订单信息分页列表 -->
     <select id="getChargeOrderInfoPage" resultType="com.zsElectric.boot.business.model.vo.ChargeOrderInfoVO">
         SELECT
-        a.id,
-        a.user_id,
-        a.order_type,
-        a.equipment_id,
-        a.charge_order_no,
-        a.start_time,
-        a.end_time,
-        a.charge_time,
-        a.status,
-        a.third_party_total_cost,
-        a.third_party_serverfee,
-        a.third_party_elecfee,
-        a.total_charge,
-        a.real_cost,
-        a.real_service_cost,
-        a.stop_type,
-        a.phone_num,
-        a.plate_num,
-        a.stop_reason,
-        a.charge_details,
-        a.third_party_station_id,
-        a.pre_amt,
-        a.real_predict_service_cost,
-        a.masp_amount,
-        a.masp_real_amount,
-        a.total_masp_money,
-        a.masp_status,
-        a.masp_time,
-        a.masp_desc,
-        a.discount_money,
-        a.discount_desc,
-        a.discount_info_id,
-        a.real_third_cost,
-        a.firm_id,
-        a.firm_price,
-        a.coupon_price,
-        a.coupon_id,
-        a.remark,
-        a.create_by,
-        a.create_time,
-        a.update_by,
-        a.update_time,
-        a.version,
-        a.is_deleted,
-        b.phone
+        coi.id,
+        coi.user_id,
+        coi.order_type,
+        psi.station_name,
+        coi.equipment_id,
+        coi.charge_order_no,
+        coi.start_time,
+        coi.end_time,
+        coi.charge_time,
+        coi.status,
+        coi.third_party_total_cost,
+        coi.third_party_serverfee,
+        coi.third_party_elecfee,
+        coi.total_charge,
+        coi.real_cost,
+        coi.real_service_cost,
+        coi.stop_type,
+        ui.phone AS phoneNum,
+        coi.plate_num,
+        coi.stop_reason,
+        coi.charge_details,
+        coi.third_party_station_id,
+        coi.pre_amt,
+        coi.real_predict_service_cost,
+        coi.masp_amount,
+        coi.masp_real_amount,
+        coi.total_masp_money,
+        coi.masp_status,
+        coi.masp_time,
+        coi.masp_desc,
+        coi.discount_money,
+        coi.discount_desc,
+        coi.discount_info_id,
+        coi.real_third_cost,
+        coi.firm_id,
+        coi.firm_price,
+        coi.coupon_price,
+        coi.coupon_id,
+        CASE
+        WHEN coi.remark IS NULL OR coi.remark = '' THEN '无'
+        ELSE coi.remark
+        END AS remark,
+        coi.create_by,
+        coi.create_time,
+        coi.update_by,
+        coi.update_time,
+        coi.version,
+        coi.is_deleted,
+        pci.connector_id,
+        pci.connector_name
         FROM
-        c_charge_order_info a
-        left join c_user_info b ON a.user_id = b.id
+        c_charge_order_info coi
+        LEFT JOIN c_user_info ui ON coi.user_id = ui.id
+        left JOIN third_party_connector_info pci ON coi.connector_id = pci.connector_id
+        LEFT JOIN third_party_station_info psi ON coi.third_party_station_id = psi.id
         <where>
-            a.is_deleted = 0
+            coi.is_deleted = 0
             <if test="queryParams.equipmentId != null">
-                AND a.equipment_id = #{queryParams.equipmentId}
+                AND coi.equipment_id = #{queryParams.equipmentId}
             </if>
             <if test="queryParams.maspStatus != null">
-                AND a.masp_status = #{queryParams.maspStatus}
+                AND coi.masp_status = #{queryParams.maspStatus}
             </if>
             <if test="queryParams.status != null">
-                AND a.status = #{queryParams.status}
+                AND coi.status = #{queryParams.status}
             </if>
             <if test="queryParams.startTime != null">
-                AND a.create_time <![CDATA[  >=  ]]> #{queryParams.startTime,jdbcType=DATE}
+                AND coi.create_time <![CDATA[  >=  ]]> #{queryParams.startTime,jdbcType=DATE}
             </if>
             <if test="queryParams.endTime != null">
-                AND a.create_time <![CDATA[  <=  ]]> #{queryParams.endTime,jdbcType=DATE}
+                AND coi.create_time <![CDATA[  <=  ]]> #{queryParams.endTime,jdbcType=DATE}
             </if>
             <if test="queryParams.stopType != null">
-                AND a.stop_type = #{queryParams.stopType}
+                AND coi.stop_type = #{queryParams.stopType}
             </if>
             <if test="queryParams.orderType != null">
-                AND a.order_type = #{queryParams.orderType}
+                AND coi.order_type = #{queryParams.orderType}
             </if>
             <if test="queryParams.phoneNum != null and queryParams.phoneNum != ''">
-                AND b.phone like concat('%',#{queryParams.phoneNum},'%')
+                AND ui.phone like concat('%',#{queryParams.phoneNum},'%')
             </if>
             <if test="queryParams.chargeOrderNo != null and queryParams.chargeOrderNo != ''">
-                AND a.charge_order_no like concat('%',#{queryParams.chargeOrderNo},'%')
+                AND coi.charge_order_no like concat('%',#{queryParams.chargeOrderNo},'%')
+            </if>
+            <if test="queryParams.thirdStationId != null">
+                AND coi.third_party_station_id = #{queryParams.thirdStationId}
             </if>
         </where>
-        ORDER BY a.create_time DESC
+        ORDER BY coi.create_time DESC
     </select>
     <select id="getPage" resultType="com.zsElectric.boot.business.model.vo.ChargeOrderInfoVO">
         SELECT
@@ -124,7 +134,10 @@
         coi.firm_price,
         coi.coupon_price,
         coi.coupon_id,
-        coi.remark,
+        CASE
+        WHEN coi.remark IS NULL OR coi.remark = '' THEN '无'
+        ELSE coi.remark
+        END AS remark,
         coi.create_by,
         coi.create_time,
         coi.update_by,
@@ -161,6 +174,7 @@
         coi.id,
         coi.user_id,
         coi.order_type,
+        psi.station_name,
         coi.equipment_id,
         coi.charge_order_no,
         coi.start_time,
@@ -174,7 +188,7 @@
         coi.real_cost,
         coi.real_service_cost,
         coi.stop_type,
-        coi.phone_num,
+        ui.phone AS phoneNum,
         coi.plate_num,
         coi.stop_reason,
         coi.charge_details,
@@ -195,7 +209,10 @@
         coi.firm_price,
         coi.coupon_price,
         coi.coupon_id,
-        coi.remark,
+        CASE
+        WHEN coi.remark IS NULL OR coi.remark = '' THEN '无'
+        ELSE coi.remark
+        END AS remark,
         coi.create_by,
         coi.create_time,
         coi.update_by,
@@ -203,12 +220,12 @@
         coi.version,
         coi.is_deleted,
         pci.connector_id,
-        pci.connector_name,
-        psi.station_name
+        pci.connector_name
         FROM
         c_charge_order_info coi
+        LEFT JOIN c_user_info ui ON coi.user_id = ui.id
         left JOIN third_party_connector_info pci ON coi.connector_id = pci.connector_id
-        LEFT JOIN third_party_station_info psi ON pci.station_id = psi.station_id
+        LEFT JOIN third_party_station_info psi ON coi.third_party_station_id = psi.id
         <where>
             coi.is_deleted = 0
             <if test="chargeOrderNo != null and chargeOrderNo !=''">
@@ -217,4 +234,100 @@
         </where>
     </select>
 
+    <!-- 获取充电订单信息导出列表 -->
+    <select id="listExportChargeOrderInfo" resultType="com.zsElectric.boot.business.model.dto.ChargeOrderInfoExportDTO">
+        SELECT
+        a.charge_order_no,
+        b.phone,
+        CASE a.order_type
+        WHEN 0 THEN '个人订单'
+        WHEN 1 THEN '集团订单'
+        ELSE '未知'
+        END AS order_type_name,
+        psi.station_name,
+        pci.connector_name,
+        a.equipment_id,
+        a.start_time,
+        a.end_time,
+        a.charge_time,
+        CASE a.status
+        WHEN 0 THEN '待启动'
+        WHEN 1 THEN '充电中'
+        WHEN 2 THEN '结算中'
+        WHEN 3 THEN '已完成'
+        WHEN 5 THEN '未成功充电'
+        ELSE '未知'
+        END AS status_name,
+        a.total_charge,
+        a.real_cost,
+        a.real_service_cost,
+        a.third_party_total_cost,
+        a.third_party_serverfee,
+        a.third_party_elecfee,
+        a.pre_amt,
+        a.discount_money,
+        a.discount_desc,
+        a.coupon_price,
+        CASE a.stop_type
+        WHEN 1 THEN '主动停止'
+        WHEN 2 THEN '充满停止'
+        WHEN 3 THEN '余额不足停止'
+        WHEN 4 THEN '电桩按钮停止'
+        ELSE ''
+        END AS stop_type_name,
+        CASE a.stop_reason
+        WHEN 0 THEN '用户手动停止充电'
+        WHEN 1 THEN '客户归属地运营商平台停止充电'
+        WHEN 2 THEN 'BMS停止充电'
+        WHEN 3 THEN '充电机设备故障'
+        WHEN 4 THEN '连接器断开'
+        WHEN 99 THEN '其他'
+        ELSE ''
+        END AS stopReason,
+        CASE
+        WHEN a.remark IS NULL OR a.remark = '' THEN '无'
+        ELSE a.remark
+        END AS remark,
+        a.create_time
+        FROM
+        c_charge_order_info a
+        LEFT JOIN c_user_info b ON a.user_id = b.id
+        LEFT JOIN third_party_connector_info pci ON a.connector_id = pci.connector_id
+        LEFT JOIN third_party_station_info psi ON a.third_party_station_id = psi.id
+        <where>
+            a.is_deleted = 0
+            <if test="queryParams.equipmentId != null">
+                AND a.equipment_id = #{queryParams.equipmentId}
+            </if>
+            <if test="queryParams.maspStatus != null">
+                AND a.masp_status = #{queryParams.maspStatus}
+            </if>
+            <if test="queryParams.status != null">
+                AND a.status = #{queryParams.status}
+            </if>
+            <if test="queryParams.startTime != null">
+                AND a.create_time <![CDATA[  >=  ]]> #{queryParams.startTime,jdbcType=DATE}
+            </if>
+            <if test="queryParams.endTime != null">
+                AND a.create_time <![CDATA[  <=  ]]> #{queryParams.endTime,jdbcType=DATE}
+            </if>
+            <if test="queryParams.stopType != null">
+                AND a.stop_type = #{queryParams.stopType}
+            </if>
+            <if test="queryParams.orderType != null">
+                AND a.order_type = #{queryParams.orderType}
+            </if>
+            <if test="queryParams.phoneNum != null and queryParams.phoneNum != ''">
+                AND b.phone like concat('%',#{queryParams.phoneNum},'%')
+            </if>
+            <if test="queryParams.chargeOrderNo != null and queryParams.chargeOrderNo != ''">
+                AND a.charge_order_no like concat('%',#{queryParams.chargeOrderNo},'%')
+            </if>
+            <if test="queryParams.thirdStationId != null">
+                AND a.third_party_station_id = #{queryParams.thirdStationId}
+            </if>
+        </where>
+        ORDER BY a.create_time DESC
+    </select>
+
 </mapper>

+ 62 - 2
src/main/resources/mapper/business/UserOrderInfoMapper.xml

@@ -9,7 +9,7 @@
         a.user_id,
         a.order_no,
         a.order_money,
-        a.last_money,
+        a.order_money - a.refund_money AS last_money,
         a.pay_time,
         a.level_id,
         a.out_trade_no,
@@ -18,7 +18,10 @@
         a.transaction_id,
         a.refund_money,
         a.refund_time,
-        a.remark,
+        CASE
+        WHEN a.remark IS NULL OR a.remark = '' THEN '无'
+        ELSE a.remark
+        END AS remark,
         a.version,
         a.create_time,
         a.update_time,
@@ -50,4 +53,61 @@
         ORDER BY a.create_time DESC
     </select>
 
+    <!-- 获取用户支付订单信息导出列表 -->
+    <select id="listExportUserOrderInfo" resultType="com.zsElectric.boot.business.model.dto.UserOrderInfoExportDTO">
+        SELECT
+        a.order_no,
+        b.phone,
+        a.order_money,
+        a.order_money - a.refund_money AS last_money,
+        a.pay_time,
+        CASE a.order_status
+        WHEN 1 THEN '待支付'
+        WHEN 2 THEN '已支付'
+        WHEN 3 THEN '已取消'
+        WHEN 4 THEN '已退款'
+        WHEN 5 THEN '部分退款'
+        ELSE '未知'
+        END AS order_status_name,
+        CASE a.order_type
+        WHEN 1 THEN '微信'
+        WHEN 2 THEN '第三方'
+        ELSE '未知'
+        END AS order_type_name,
+        a.out_trade_no,
+        a.transaction_id,
+        a.refund_money,
+        a.refund_time,
+        CASE
+        WHEN a.remark IS NULL OR a.remark = '' THEN '无'
+        ELSE a.remark
+        END AS remark,
+        a.create_time
+        FROM
+        c_user_order_info a
+        LEFT JOIN c_user_info b ON a.user_id = b.id
+        <where>
+            a.is_deleted = 0
+            <if test="queryParams.userId != null">
+                AND a.user_id = #{queryParams.userId}
+            </if>
+            <if test="queryParams.orderStatus != null">
+                AND a.order_status = #{queryParams.orderStatus}
+            </if>
+            <if test="queryParams.phone != null and queryParams.phone != ''">
+                AND b.phone like concat('%',#{queryParams.phone},'%')
+            </if>
+            <if test="queryParams.orderNo != null">
+                AND a.order_no = #{queryParams.orderNo}
+            </if>
+            <if test="queryParams.startTime != null">
+                AND a.create_time <![CDATA[  >=  ]]> #{queryParams.startTime,jdbcType=DATE}
+            </if>
+            <if test="queryParams.endTime != null">
+                AND a.create_time <![CDATA[  <=  ]]> #{queryParams.endTime,jdbcType=DATE}
+            </if>
+        </where>
+        ORDER BY a.create_time DESC
+    </select>
+
 </mapper>