Преглед изворни кода

feat(user-info): 完善用户信息列表及详情支持企业筛选与金额字段展示

- 新增用户余额和累计消费的显示与格式化,支持排序功能
- 用户列表新增所属企业筛选,后台接口增加firmId参数支持
- 更新用户信息接口与VO,增加当前余额和累计消费字段
- 优化数据查询SQL,支持按余额和累计消费排序
- 页面删除新增功能、调整详情弹窗显示内容
- 调整表头和表格列配置,优化操作按钮样式与宽度
- 代码重构及样式调整,提高金额显示的可读性
SheepHy пре 2 дана
родитељ
комит
8881e34a6c

+ 11 - 0
src/main/java/com/zsElectric/boot/business/model/query/UserInfoQuery.java

@@ -19,4 +19,15 @@ import java.math.BigDecimal;
 @Setter
 public class UserInfoQuery extends BasePageQuery {
 
+    @Schema(description = "手机号")
+    private String phone;
+
+    @Schema(description = "所属企业ID")
+    private Long firmId;
+
+    @Schema(description = "排序字段")
+    private String sortField;
+
+    @Schema(description = "排序方式: ascending/descending")
+    private String sortOrder;
 }

+ 4 - 8
src/main/java/com/zsElectric/boot/business/model/vo/UserInfoVO.java

@@ -33,14 +33,10 @@ public class UserInfoVO implements Serializable {
     private String phone;
     @Schema(description = "微信openid")
     private String openid;
+    @Schema(description = "当前余额")
+    private BigDecimal balance;
+    @Schema(description = "累计消费")
+    private BigDecimal totalConsumption;
     @Schema(description = "创建时间")
     private LocalDateTime createTime;
-    @Schema(description = "创建人")
-    private Long createBy;
-    @Schema(description = "更新时间")
-    private LocalDateTime updateTime;
-    @Schema(description = "更新人")
-    private Long updateBy;
-    @Schema(description = "逻辑删除(0-未删除 1-已删除)")
-    private Integer isDeleted;
 }

+ 2 - 2
src/main/java/com/zsElectric/boot/charging/quartz/ChargingJob.java

@@ -46,7 +46,7 @@ public class ChargingJob {
      * 手动触发或启动时执行一次,从第三方接口获取充电站信息并存储到数据库
      * 注意:已移除定时任务,改为手动触发
      */
-     @Scheduled(cron = "0 0/30 * * * ?") // 已禁用定时执行
+//     @Scheduled(cron = "0 0/30 * * * ?") // 已禁用定时执行
     public void syncStationsInfo() {
         log.info("开始执行充电站信息同步定时任务");
         
@@ -83,7 +83,7 @@ public class ChargingJob {
      * 每10分钟执行一次,查询所有充电桩的价格策略并存储到数据库
      * cron表达式: 0 10 * * * ? 表示每10分钟执行
      */
-    @Scheduled(cron = "0 */1 * * * ?")
+//    @Scheduled(cron = "0 */1 * * * ?")
     public void syncEquipmentPricePolicy() {
         // 检查任务是否正在执行,防止并发
         if (isPricePolicySyncRunning) {

+ 35 - 7
src/main/resources/mapper/business/UserInfoMapper.xml

@@ -10,18 +10,46 @@
         fi.name AS firmName,
         ui.phone,
         ui.openid,
-        ui.create_time,
-        ui.create_by,
-        ui.update_time,
-        ui.update_by,
-        ui.is_deleted
+        IFNULL(ua.balance, 0) + IFNULL(ua.redeem_balance, 0) AS balance,
+        IFNULL(log.total_consumption, 0) AS totalConsumption,
+        ui.create_time
         FROM
         c_user_info ui
-        LEFT JOIN c_user_firm uf ON uf.user_id = ui.id
-        LEFT JOIN c_firm_info fi ON fi.id = uf.firm_id
+        LEFT JOIN c_user_firm uf ON uf.user_id = ui.id AND uf.is_deleted = 0
+        LEFT JOIN c_firm_info fi ON fi.id = uf.firm_id AND fi.is_deleted = 0
+        LEFT JOIN c_user_account ua ON ua.user_id = ui.id AND ua.is_deleted = 0
+        LEFT JOIN (
+            SELECT user_id, SUM(IFNULL(change_balance, 0)) AS total_consumption
+            FROM c_user_account_log
+            WHERE is_deleted = 0 AND change_type = 2 AND account_type = 1
+            GROUP BY user_id
+        ) log ON ui.id = log.user_id
         <where>
             ui.is_deleted = 0
+            <if test="queryParams.phone != null and queryParams.phone != ''">
+                AND ui.phone LIKE CONCAT('%', #{queryParams.phone}, '%')
+            </if>
+            <if test="queryParams.firmId != null">
+                AND uf.firm_id = #{queryParams.firmId}
+            </if>
         </where>
+        <choose>
+            <when test="queryParams.sortField == 'balance' and queryParams.sortOrder == 'ascending'">
+                ORDER BY balance ASC
+            </when>
+            <when test="queryParams.sortField == 'balance' and queryParams.sortOrder == 'descending'">
+                ORDER BY balance DESC
+            </when>
+            <when test="queryParams.sortField == 'totalConsumption' and queryParams.sortOrder == 'ascending'">
+                ORDER BY totalConsumption ASC
+            </when>
+            <when test="queryParams.sortField == 'totalConsumption' and queryParams.sortOrder == 'descending'">
+                ORDER BY totalConsumption DESC
+            </when>
+            <otherwise>
+                ORDER BY ui.create_time DESC
+            </otherwise>
+        </choose>
     </select>
     <select id="getAppletUserInfo" resultType="com.zsElectric.boot.business.model.vo.applet.AppUserInfoVO">
         SELECT