Эх сурвалжийг харах

修复小程序充值页 stationId 为空导致多组数据问题

- 归属站为空时 fallback 到 URL 传入的消费站
- 都为空时则不传 stationId 参数,后端走默认分组

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 3 өдөр өмнө
parent
commit
b8091388bc

+ 1 - 1
car-wash-mapper/src/main/java/com/kym/mapper/RechargeConfigStationGroupMapper.java

@@ -1,7 +1,7 @@
 package com.kym.mapper;
 
 import com.kym.entity.RechargeConfigStationGroup;
-import com.kym.service.mybatisplus.MyBaseMapper;
+import com.kym.mapper.mybatisplus.MyBaseMapper;
 
 /**
  * 充值配置分组-站点关联 Mapper

+ 7 - 1
car-wash-mp/src/pages-user/wallet/recharge.vue

@@ -87,8 +87,14 @@ const handleRechargeClick = (recharge: any, idx: number) => {
 };
 
 const loadRechargeConfig = () => {
+  // 优先使用归属站,无归属站时用当前消费站,都没有则不传(走默认分组)
   const homeStationId = getApp<any>().globalData.user?.stationId;
-  get("/common/rechargeConfig", { stationId: homeStationId })
+  const stationId = homeStationId || state.stationId || undefined;
+  const params: any = {};
+  if (stationId) {
+    params.stationId = stationId;
+  }
+  get("/common/rechargeConfig", params)
     .then((res: any) => {
       state.configList = res;
     })

+ 2 - 1
car-wash-service/src/main/java/com/kym/service/impl/RechargeConfigGroupServiceImpl.java

@@ -7,6 +7,7 @@ import com.kym.service.RechargeConfigGroupService;
 import com.kym.service.RechargeConfigService;
 import com.kym.service.RechargeConfigStationGroupService;
 import com.kym.service.mybatisplus.MyBaseServiceImpl;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -26,7 +27,7 @@ public class RechargeConfigGroupServiceImpl
     private final RechargeConfigService itemService;
     private final RechargeConfigStationGroupService stationGroupService;
 
-    public RechargeConfigGroupServiceImpl(RechargeConfigService itemService,
+    public RechargeConfigGroupServiceImpl(@Lazy RechargeConfigService itemService,
                                            RechargeConfigStationGroupService stationGroupService) {
         this.itemService = itemService;
         this.stationGroupService = stationGroupService;

+ 2 - 1
car-wash-service/src/main/java/com/kym/service/impl/RechargeConfigServiceImpl.java

@@ -6,6 +6,7 @@ import com.kym.mapper.RechargeConfigMapper;
 import com.kym.service.RechargeConfigGroupService;
 import com.kym.service.RechargeConfigService;
 import com.kym.service.mybatisplus.MyBaseServiceImpl;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -21,7 +22,7 @@ public class RechargeConfigServiceImpl extends MyBaseServiceImpl<RechargeConfigM
 
     private final RechargeConfigGroupService groupService;
 
-    public RechargeConfigServiceImpl(RechargeConfigGroupService groupService) {
+    public RechargeConfigServiceImpl(@Lazy RechargeConfigGroupService groupService) {
         this.groupService = groupService;
     }