首页统计
This commit is contained in:
+27
@@ -42,6 +42,19 @@ public class DashboardController {
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
// 追加统计粒度(day/month/year),从请求参数读取
|
||||
try {
|
||||
org.springframework.web.context.request.ServletRequestAttributes attrs = (org.springframework.web.context.request.ServletRequestAttributes) org.springframework.web.context.request.RequestContextHolder.getRequestAttributes();
|
||||
jakarta.servlet.http.HttpServletRequest req = attrs != null ? attrs.getRequest() : null;
|
||||
String statType = req != null ? req.getParameter("statType") : null;
|
||||
if (statType != null && !statType.isEmpty()) {
|
||||
params.put("statType", statType);
|
||||
}
|
||||
String incStr = req != null ? req.getParameter("includeChildren") : null;
|
||||
if (incStr != null && !incStr.isEmpty()) {
|
||||
params.put("includeChildren", incStr);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
params.put("tourismId", tourismId);
|
||||
params.put("qrcodeId", qrcodeId);
|
||||
params.put("deviceSn", deviceSn);
|
||||
@@ -64,6 +77,20 @@ public class DashboardController {
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
// 追加租户范围(当前租户及其所有子租户)
|
||||
try {
|
||||
String anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.LoginUserContextHolder.getCurrentTenantId();
|
||||
}
|
||||
com.central.common.service.ITenantHierarchyService tenantService = com.central.common.utils.SpringContextHolder.getBean(com.central.common.service.ITenantHierarchyService.class);
|
||||
if (tenantService != null && anchor != null && !anchor.isEmpty()) {
|
||||
java.util.List<String> tenantIds = tenantService.getAllSubTenantIds(anchor);
|
||||
if (tenantIds != null && !tenantIds.isEmpty()) {
|
||||
params.put("tenantIds", tenantIds);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
params.put("tourismId", tourismId);
|
||||
params.put("includeTestQrcodes", includeTestQrcodes);
|
||||
|
||||
|
||||
+13
@@ -1,11 +1,16 @@
|
||||
package com.central.order.feign;
|
||||
|
||||
import com.central.common.constant.ServiceNameConstants;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.model.SysUser;
|
||||
import com.central.order.feign.fallback.UserCenterServiceFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* user-center模块远程调用
|
||||
@@ -26,4 +31,12 @@ public interface UserCenterService {
|
||||
*/
|
||||
@GetMapping("/users/{id}")
|
||||
SysUser findUserById(@PathVariable("id") Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定租户(含自身)及其所有子孙租户ID
|
||||
* @param tenantId 锚点租户ID
|
||||
*/
|
||||
@GetMapping("/tenant/hierarchy/{tenantId}")
|
||||
Result<List<String>> getDescendantTenantIds(@PathVariable("tenantId") String tenantId) throws Exception;
|
||||
}
|
||||
|
||||
+8
@@ -1,11 +1,14 @@
|
||||
package com.central.order.feign.fallback;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.model.SysUser;
|
||||
import com.central.order.feign.UserCenterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户中心调用失败回调
|
||||
*
|
||||
@@ -26,6 +29,11 @@ public class UserCenterServiceFallbackFactory implements FallbackFactory<UserCen
|
||||
public SysUser findUserById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<String>> getDescendantTenantIds(String tenantId) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+109
-7
@@ -38,6 +38,15 @@ public interface DashboardMapper {
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<choose>",
|
||||
" <when test='(p.startTime == null or p.startTime == \"\") and p.statType == \"day\"'> AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY) </when>",
|
||||
" <when test='(p.startTime == null or p.startTime == \"\") and p.statType == \"month\"'> AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) </when>",
|
||||
" <when test='(p.startTime == null or p.startTime == \"\") and p.statType == \"year\"'> AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR) </when>",
|
||||
"</choose>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTotalOrders(@Param("p") Map<String, Object> params);
|
||||
@@ -63,6 +72,10 @@ public interface DashboardMapper {
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTodayOrders(@Param("p") Map<String, Object> params);
|
||||
@@ -93,6 +106,15 @@ public interface DashboardMapper {
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<choose>",
|
||||
" <when test='(p.startTime == null or p.startTime == \"\") and p.statType == \"day\"'> AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY) </when>",
|
||||
" <when test='(p.startTime == null or p.startTime == \"\") and p.statType == \"month\"'> AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) </when>",
|
||||
" <when test='(p.startTime == null or p.startTime == \"\") and p.statType == \"year\"'> AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR) </when>",
|
||||
"</choose>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getRefundedOrders(@Param("p") Map<String, Object> params);
|
||||
@@ -117,6 +139,10 @@ public interface DashboardMapper {
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTodayRefundedOrders(@Param("p") Map<String, Object> params);
|
||||
@@ -147,6 +173,15 @@ public interface DashboardMapper {
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<choose>",
|
||||
" <when test='(p.startTime == null or p.startTime == \"\") and p.statType == \"day\"'> AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY) </when>",
|
||||
" <when test='(p.startTime == null or p.startTime == \"\") and p.statType == \"month\"'> AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) </when>",
|
||||
" <when test='(p.startTime == null or p.startTime == \"\") and p.statType == \"year\"'> AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR) </when>",
|
||||
"</choose>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTotalPaidOrders(@Param("p") Map<String, Object> params);
|
||||
@@ -172,6 +207,10 @@ public interface DashboardMapper {
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTodayPaidOrders(@Param("p") Map<String, Object> params);
|
||||
@@ -241,7 +280,11 @@ public interface DashboardMapper {
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" <choose>",
|
||||
" <when test=\"p.statType == 'year'\"> DATE_FORMAT(o.create_time, '%Y') as date, </when>",
|
||||
" <when test=\"p.statType == 'month'\"> DATE_FORMAT(o.create_time, '%Y-%m') as date, </when>",
|
||||
" <otherwise> DATE_FORMAT(o.create_time, '%Y-%m-%d') as date, </otherwise>",
|
||||
" </choose>",
|
||||
" 'created' as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders o",
|
||||
@@ -267,10 +310,23 @@ public interface DashboardMapper {
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"GROUP BY ",
|
||||
"<choose>",
|
||||
" <when test=\"p.statType == 'year'\"> DATE_FORMAT(o.create_time, '%Y') </when>",
|
||||
" <when test=\"p.statType == 'month'\"> DATE_FORMAT(o.create_time, '%Y-%m') </when>",
|
||||
" <otherwise> DATE_FORMAT(o.create_time, '%Y-%m-%d') </otherwise>",
|
||||
"</choose>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" <choose>",
|
||||
" <when test=\"p.statType == 'year'\"> DATE_FORMAT(o.create_time, '%Y') as date, </when>",
|
||||
" <when test=\"p.statType == 'month'\"> DATE_FORMAT(o.create_time, '%Y-%m') as date, </when>",
|
||||
" <otherwise> DATE_FORMAT(o.create_time, '%Y-%m-%d') as date, </otherwise>",
|
||||
" </choose>",
|
||||
" 'completed' as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders o",
|
||||
@@ -296,10 +352,23 @@ public interface DashboardMapper {
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"GROUP BY ",
|
||||
"<choose>",
|
||||
" <when test=\"p.statType == 'year'\"> DATE_FORMAT(o.create_time, '%Y') </when>",
|
||||
" <when test=\"p.statType == 'month'\"> DATE_FORMAT(o.create_time, '%Y-%m') </when>",
|
||||
" <otherwise> DATE_FORMAT(o.create_time, '%Y-%m-%d') </otherwise>",
|
||||
"</choose>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" <choose>",
|
||||
" <when test=\"p.statType == 'year'\"> DATE_FORMAT(o.create_time, '%Y') as date, </when>",
|
||||
" <when test=\"p.statType == 'month'\"> DATE_FORMAT(o.create_time, '%Y-%m') as date, </when>",
|
||||
" <otherwise> DATE_FORMAT(o.create_time, '%Y-%m-%d') as date, </otherwise>",
|
||||
" </choose>",
|
||||
" 'refunded' as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders o",
|
||||
@@ -325,7 +394,16 @@ public interface DashboardMapper {
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"GROUP BY ",
|
||||
"<choose>",
|
||||
" <when test=\"p.statType == 'year'\"> DATE_FORMAT(o.create_time, '%Y') </when>",
|
||||
" <when test=\"p.statType == 'month'\"> DATE_FORMAT(o.create_time, '%Y-%m') </when>",
|
||||
" <otherwise> DATE_FORMAT(o.create_time, '%Y-%m-%d') </otherwise>",
|
||||
"</choose>",
|
||||
"ORDER BY date, type",
|
||||
"</script>"
|
||||
})
|
||||
@@ -346,6 +424,10 @@ public interface DashboardMapper {
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND q.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND q.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
@@ -454,6 +536,10 @@ public interface DashboardMapper {
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"GROUP BY o.order_status",
|
||||
"</script>"
|
||||
})
|
||||
@@ -486,6 +572,10 @@ public interface DashboardMapper {
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '景区分账' as type,",
|
||||
@@ -512,6 +602,10 @@ public interface DashboardMapper {
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '退款金额' as type,",
|
||||
@@ -538,6 +632,10 @@ public interface DashboardMapper {
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
|
||||
" AND o.tourism_id IN",
|
||||
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
List<IncomeDataVO> getIncomeBreakdown(@Param("p") Map<String, Object> params);
|
||||
@@ -553,6 +651,10 @@ public interface DashboardMapper {
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tenantIds != null and p.tenantIds.size > 0'>",
|
||||
" AND tenant_id IN",
|
||||
" <foreach collection='p.tenantIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -560,4 +662,4 @@ public interface DashboardMapper {
|
||||
"</script>"
|
||||
})
|
||||
List<FilterOptions.OptionItem> getQrcodeOptions(@Param("p") Map<String, Object> params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,4 +74,9 @@ public interface TourismMapper extends SuperMapper<Tourism> {
|
||||
@Param("maxLatitude") BigDecimal maxLatitude
|
||||
);
|
||||
|
||||
/**
|
||||
* 根据租户ID集合查询景区ID集合
|
||||
*/
|
||||
List<Long> findTourismIdsByTenantIds(@Param("tenantIds") List<String> tenantIds);
|
||||
|
||||
}
|
||||
|
||||
+64
@@ -1,7 +1,13 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.central.common.context.LoginUserContextHolder;
|
||||
import com.central.common.context.TenantQueryOverrideContext;
|
||||
import com.central.common.datascope.annotation.IgnoreTenantScope;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.service.ITenantHierarchyService;
|
||||
import com.central.common.utils.SpringContextHolder;
|
||||
import com.central.order.mapper.DashboardMapper;
|
||||
import com.central.order.mapper.TourismMapper;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.vo.*;
|
||||
import com.central.order.service.IDashboardService;
|
||||
@@ -23,9 +29,32 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
|
||||
private final DashboardMapper dashboardMapper;
|
||||
private final IOrderService orderService;
|
||||
private final TourismMapper tourismMapper;
|
||||
|
||||
@Override
|
||||
@IgnoreTenantScope
|
||||
public DashboardStatisticsVO getDashboardStatistics(Map<String, Object> params) {
|
||||
// 依据租户层级组装景区ID集合,作为统计范围(支持 includeChildren=false 仅当前租户)
|
||||
try {
|
||||
boolean includeChildren = true;
|
||||
try {
|
||||
Object inc = params != null ? params.get("includeChildren") : null;
|
||||
if (inc != null) {
|
||||
String s = String.valueOf(inc);
|
||||
includeChildren = !("false".equalsIgnoreCase(s) || "0".equals(s));
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
List<String> tenantIds = resolveTenantIdsFromContext(includeChildren);
|
||||
if (tenantIds != null && !tenantIds.isEmpty()) {
|
||||
List<Long> tourismIds = resolveTourismIdsByTenants(tenantIds);
|
||||
if (tourismIds != null && !tourismIds.isEmpty()) {
|
||||
params.put("tourismIds", tourismIds);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("解析租户/景区范围失败,使用默认上下文: {}", e.getMessage());
|
||||
}
|
||||
DashboardStatisticsVO statistics = new DashboardStatisticsVO();
|
||||
|
||||
try {
|
||||
@@ -187,4 +216,39 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析当前请求上下文的租户集合(包含子租户)
|
||||
*/
|
||||
private List<String> resolveTenantIdsFromContext(boolean includeChildren) {
|
||||
String anchor = TenantQueryOverrideContext.getTenantId();
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = LoginUserContextHolder.getCurrentTenantId();
|
||||
}
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
if (!includeChildren) {
|
||||
return java.util.Collections.singletonList(anchor);
|
||||
}
|
||||
try {
|
||||
ITenantHierarchyService tenantService = SpringContextHolder.getBean(ITenantHierarchyService.class);
|
||||
List<String> all = tenantService != null ? tenantService.getAllSubTenantIds(anchor) : null;
|
||||
if (all != null && !all.isEmpty()) return all;
|
||||
} catch (Exception ignored) { }
|
||||
return java.util.Collections.singletonList(anchor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据租户集合查询景区ID集合
|
||||
*/
|
||||
private List<Long> resolveTourismIdsByTenants(List<String> tenantIds) {
|
||||
try {
|
||||
if (tenantIds == null || tenantIds.isEmpty()) return java.util.Collections.emptyList();
|
||||
return tourismMapper.findTourismIdsByTenantIds(tenantIds);
|
||||
} catch (Exception e) {
|
||||
log.debug("根据租户查询景区失败: {}", e.getMessage());
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,20 @@
|
||||
<mapper namespace="com.central.order.mapper.TourismMapper">
|
||||
|
||||
<select id="findList" resultType="com.central.order.model.Tourism">
|
||||
select * from tourisms t
|
||||
SELECT *
|
||||
FROM tourisms t
|
||||
<where>
|
||||
<if test="p.tenantIds != null and p.tenantIds.size > 0">
|
||||
AND t.tenant_id IN
|
||||
<foreach collection="p.tenantIds" item="tid" open="(" separator="," close=")">
|
||||
#{tid}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="(p.tenantIds == null or p.tenantIds.size == 0) and p.tenantId != null and p.tenantId != ''">
|
||||
AND t.tenant_id = #{p.tenantId}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.id DESC
|
||||
</select>
|
||||
|
||||
<resultMap id="TourismResultMap" type="com.central.order.model.Tourism">
|
||||
@@ -89,4 +102,17 @@
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据租户ID集合查询景区ID集合 -->
|
||||
<select id="findTourismIdsByTenantIds" resultType="java.lang.Long">
|
||||
SELECT id FROM tourisms
|
||||
WHERE is_del = 0
|
||||
<if test="tenantIds != null and tenantIds.size > 0">
|
||||
AND tenant_id IN
|
||||
<foreach collection="tenantIds" item="tid" open="(" separator="," close=")">
|
||||
#{tid}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user