From 9af2c277033957c095d1090c8e6f77e54b86172f Mon Sep 17 00:00:00 2001
From: shinnosuke <tantao@1hoper.com>
Date: 星期四, 02 七月 2026 16:58:59 +0800
Subject: [PATCH] 新增企业用户充电分析功能页(包含充电明细);新增系统用户管理中的重置操作密码功能;在角色管理中增加独立合作商角色;角色管理中的添加角色操作新增数据驾驶舱和视频监控入口(需在角色管理员有按钮权限控制)。
---
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 179 insertions(+), 1 deletions(-)
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
index 9eaf884..7dbaa6e 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?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.TChargingOrderMapper">
@@ -2454,4 +2454,182 @@
group by orderId,recharge_payment_type,site_id,recharge_amount,refund_amount,platformFee
) as aa group by aa.site_id,aa.recharge_payment_type order by aa.site_id
</select>
+
+ <sql id="enterpriseChargingBaseWhere">
+ toi.invoicing_object_type = 2
+ AND toi.status IN (2, 3)
+ AND tod.order_type = 1
+ AND co.del_flag = 0
+ AND co.recharge_payment_status = 2
+ <if test="data.exactCompanyName != null and data.exactCompanyName != ''">
+ AND toi.name = #{data.exactCompanyName}
+ </if>
+ <if test="(data.exactCompanyName == null or data.exactCompanyName == '') and data.companyName != null and data.companyName != ''">
+ AND toi.name LIKE CONCAT('%', #{data.companyName}, '%')
+ </if>
+ <if test="data.socialCreditCode != null and data.socialCreditCode != ''">
+ AND IFNULL(toi.tax_identification_number, '') = #{data.socialCreditCode}
+ </if>
+ <if test="data.siteType != null">
+ AND s.site_type = #{data.siteType}
+ </if>
+ <if test="data.partnerId != null">
+ AND s.partner_id = #{data.partnerId}
+ </if>
+ <if test="data.siteId != null">
+ AND co.site_id = #{data.siteId}
+ </if>
+ <if test="data.createTime1 != null">
+ AND co.create_time >= #{data.createTime1}
+ </if>
+ <if test="data.createTime2 != null">
+ AND co.create_time <= #{data.createTime2}
+ </if>
+ </sql>
+
+ <select id="enterpriseChargingAnalysis" resultType="com.ruoyi.order.dto.EnterpriseChargingAnalysisVO">
+ SELECT
+ b.companyName,
+ b.socialCreditCode,
+ MAX(b.companyAddress) AS companyAddress,
+ MAX(b.companyPhone) AS companyPhone,
+ SUM(b.orderCount) AS chargingCount,
+ COUNT(1) AS invoiceCount,
+ SUM(CASE WHEN b.detailInvoiceAmount > 0 THEN b.detailInvoiceAmount ELSE b.totalAmount END) AS invoiceAmount,
+ MAX(b.latestChargingTime) AS latestChargingTime
+ FROM (
+ SELECT
+ toi.id AS invoiceId,
+ toi.name AS companyName,
+ IFNULL(toi.tax_identification_number, '') AS socialCreditCode,
+ MAX(toi.company_address) AS companyAddress,
+ MAX(toi.company_phone) AS companyPhone,
+ MAX(IFNULL(toi.total_amount, 0)) AS totalAmount,
+ SUM(IFNULL(tod.invoice_amount, 0)) AS detailInvoiceAmount,
+ COUNT(DISTINCT co.id) AS orderCount,
+ MAX(co.end_time) AS latestChargingTime
+ FROM t_order_invoice toi
+ INNER JOIN t_order_invoice_detail tod ON tod.order_invoice_id = toi.id
+ INNER JOIN t_charging_order co ON co.id = tod.order_id
+ LEFT JOIN charging_pile_service.t_site s ON s.id = co.site_id
+ <where>
+ <include refid="enterpriseChargingBaseWhere" />
+ </where>
+ GROUP BY toi.id, toi.name, toi.tax_identification_number
+ ) b
+ GROUP BY b.companyName, b.socialCreditCode
+ ORDER BY chargingCount DESC
+ </select>
+
+ <select id="enterpriseTopSites" resultType="map">
+ SELECT
+ s.name AS siteName,
+ COUNT(DISTINCT co.id) AS counts
+ FROM t_order_invoice toi
+ INNER JOIN t_order_invoice_detail tod ON tod.order_invoice_id = toi.id
+ INNER JOIN t_charging_order co ON co.id = tod.order_id
+ LEFT JOIN charging_pile_service.t_site s ON s.id = co.site_id
+ <where>
+ <include refid="enterpriseChargingBaseWhere" />
+ AND s.name IS NOT NULL
+ </where>
+ GROUP BY s.id, s.name
+ ORDER BY counts DESC
+ LIMIT 3
+ </select>
+
+ <select id="enterpriseChargingTimes" resultType="java.time.LocalDateTime">
+ SELECT DISTINCT co.start_time
+ FROM t_order_invoice toi
+ INNER JOIN t_order_invoice_detail tod ON tod.order_invoice_id = toi.id
+ INNER JOIN t_charging_order co ON co.id = tod.order_id
+ LEFT JOIN charging_pile_service.t_site s ON s.id = co.site_id
+ <where>
+ <include refid="enterpriseChargingBaseWhere" />
+ AND co.start_time IS NOT NULL
+ </where>
+ ORDER BY co.start_time ASC
+ </select>
+
+ <sql id="enterpriseChargingDetailWhere">
+ <include refid="enterpriseChargingBaseWhere" />
+ <if test="data.code != null and data.code != ''">
+ AND co.code LIKE CONCAT('%', #{data.code}, '%')
+ </if>
+ <if test="data.orderType != null">
+ AND co.order_type = #{data.orderType}
+ </if>
+ <if test="data.phone != null and data.phone != ''">
+ AND au.phone LIKE CONCAT('%', #{data.phone}, '%')
+ </if>
+ <if test="data.status != null">
+ AND co.status = #{data.status}
+ </if>
+ <if test="data.partnerName != null and data.partnerName != ''">
+ AND p.name LIKE CONCAT('%', #{data.partnerName}, '%')
+ </if>
+ <if test="data.orderSource != null">
+ AND co.order_source = #{data.orderSource}
+ </if>
+ <if test="data.startTime1 != null">
+ AND co.start_time >= #{data.startTime1}
+ </if>
+ <if test="data.startTime2 != null">
+ AND co.start_time <= #{data.startTime2}
+ </if>
+ <if test="data.endTime1 != null">
+ AND co.end_time >= #{data.endTime1}
+ </if>
+ <if test="data.endTime2 != null">
+ AND co.end_time <= #{data.endTime2}
+ </if>
+ </sql>
+
+ <sql id="enterpriseChargingDetailSelect">
+ SELECT DISTINCT
+ co.id,
+ co.code,
+ co.order_type AS orderType,
+ co.order_classification AS orderClassification,
+ s.name AS siteName,
+ CONCAT(IFNULL(cp.name, ''), IFNULL(cg.name, '')) AS terminalName,
+ co.status,
+ (UNIX_TIMESTAMP(co.end_time) - UNIX_TIMESTAMP(co.start_time)) AS chargingSecond,
+ co.recharge_amount AS totalAmount,
+ IFNULL(co.coupon_discount_amount, 0) AS couponDiscountAmount,
+ IFNULL(co.vip_discount_amount, 0) AS vipDiscountAmount,
+ co.payment_amount AS paymentAmount,
+ IFNULL(co.refund_amount, 0) AS refundAmount,
+ co.order_source AS orderSource,
+ p.name AS partnerName,
+ au.phone AS phone,
+ co.create_time AS createTime,
+ co.start_time AS startTime,
+ co.end_time AS endTime,
+ co.pay_time AS payTime
+ FROM t_order_invoice toi
+ INNER JOIN t_order_invoice_detail tod ON tod.order_invoice_id = toi.id
+ INNER JOIN t_charging_order co ON co.id = tod.order_id
+ LEFT JOIN charging_pile_service.t_site s ON s.id = co.site_id
+ LEFT JOIN charging_pile_service.t_partner p ON p.id = s.partner_id
+ LEFT JOIN charging_pile_service.t_charging_pile cp ON cp.id = co.charging_pile_id
+ LEFT JOIN charging_pile_service.t_charging_gun cg ON cg.id = co.charging_gun_id
+ LEFT JOIN charging_pile_account.t_app_user au ON au.id = co.app_user_id
+ </sql>
+
+ <select id="enterpriseChargingDetail" resultType="com.ruoyi.order.dto.EnterpriseChargingDetailVO">
+ <include refid="enterpriseChargingDetailSelect" />
+ <where>
+ <include refid="enterpriseChargingDetailWhere" />
+ </where>
+ ORDER BY co.create_time DESC
+ </select>
+
+ <select id="enterpriseChargingDetailExport" resultType="com.ruoyi.order.dto.EnterpriseChargingDetailVO">
+ <include refid="enterpriseChargingDetailSelect" />
+ <where>
+ <include refid="enterpriseChargingDetailWhere" />
+ </where>
+ ORDER BY co.create_time DESC
+ </select>
</mapper>
--
Gitblit v1.7.1