fix(后台管理): 首页统计功能新增二维码维度统计,灵活设置分账比例,过滤测试二维码订单的数据等
This commit is contained in:
+28
-1
@@ -15,6 +15,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import com.central.order.model.vo.FilterOptions;
|
||||
import com.central.order.mapper.DashboardMapper;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -24,6 +27,7 @@ import java.util.Map;
|
||||
public class DashboardController {
|
||||
|
||||
private final IDashboardService dashboardService;
|
||||
private final DashboardMapper dashboardMapper;
|
||||
|
||||
@Operation(summary = "获取首页统计数据")
|
||||
@GetMapping("/statistics")
|
||||
@@ -32,7 +36,8 @@ public class DashboardController {
|
||||
@Parameter(description = "二维码ID") @RequestParam(required = false) String qrcodeId,
|
||||
@Parameter(description = "设备编号") @RequestParam(required = false) String deviceSn,
|
||||
@Parameter(description = "开始时间") @RequestParam(required = false) String startTime,
|
||||
@Parameter(description = "结束时间") @RequestParam(required = false) String endTime) {
|
||||
@Parameter(description = "结束时间") @RequestParam(required = false) String endTime,
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("tourismId", tourismId);
|
||||
@@ -40,6 +45,7 @@ public class DashboardController {
|
||||
params.put("deviceSn", deviceSn);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
params.put("includeTestQrcodes", includeTestQrcodes);
|
||||
|
||||
DashboardStatisticsVO statistics = dashboardService.getDashboardStatistics(params);
|
||||
return Result.succeed(statistics, "获取首页统计数据成功");
|
||||
@@ -48,4 +54,25 @@ public class DashboardController {
|
||||
return Result.failed("获取统计数据失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取二维码选项")
|
||||
@GetMapping("/qrcode/options")
|
||||
public Result<Map<String, Object>> getQrcodeOptions(
|
||||
@Parameter(description = "景区ID") @RequestParam(required = false) Long tourismId,
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("tourismId", tourismId);
|
||||
params.put("includeTestQrcodes", includeTestQrcodes);
|
||||
|
||||
List<FilterOptions.OptionItem> qrcodeList = dashboardMapper.getQrcodeOptions(params);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("qrcodeList", qrcodeList);
|
||||
|
||||
return Result.succeed(result, "获取二维码选项成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取二维码选项失败", e);
|
||||
return Result.failed("获取二维码选项失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+170
-84
@@ -14,21 +14,26 @@ public interface DashboardMapper {
|
||||
// 基础订单统计(支持筛选)
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders WHERE is_del = 0",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -36,15 +41,21 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders WHERE is_del = 0 AND DATE(create_time) = CURDATE()",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND DATE(o.create_time) = CURDATE()",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -52,15 +63,21 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders WHERE is_del = 0 AND DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND DATE(o.create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -68,21 +85,27 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders WHERE is_del = 0 AND order_status = 3",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status = 3",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -91,18 +114,22 @@ public interface DashboardMapper {
|
||||
// 对账相关统计
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(order_amount), 0)",
|
||||
"FROM orders",
|
||||
"WHERE is_del = 0",
|
||||
"AND (order_status = 3 OR order_status = 8)",
|
||||
"SELECT COALESCE(SUM(o.order_amount), 0)",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND (o.order_status = 3 OR o.order_status = 8)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -110,23 +137,28 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(platform_amount), 0)",
|
||||
"FROM order_statistics",
|
||||
"SELECT COALESCE(SUM(os.platform_amount), 0)",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -134,23 +166,28 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(tourism_amount), 0)",
|
||||
"FROM order_statistics",
|
||||
"SELECT COALESCE(SUM(os.tourism_amount), 0)",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -161,7 +198,11 @@ public interface DashboardMapper {
|
||||
"SELECT COALESCE(SUM(CAST(r.refund_amount AS SIGNED)), 0)",
|
||||
"FROM orders_refund r",
|
||||
"JOIN orders o ON r.order_no = o.order_no",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE r.status = 8",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -179,22 +220,26 @@ public interface DashboardMapper {
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" DATE_FORMAT(create_time, '%Y-%m-%d') as date,",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" 'orders' as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders",
|
||||
"WHERE is_del = 0",
|
||||
" AND create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
" AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')",
|
||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||
"ORDER BY date",
|
||||
"</script>"
|
||||
})
|
||||
@@ -203,7 +248,7 @@ public interface DashboardMapper {
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" CASE order_status",
|
||||
" CASE o.order_status",
|
||||
" WHEN 0 THEN '待支付'",
|
||||
" WHEN 1 THEN '已支付排队中'",
|
||||
" WHEN 2 THEN '已取消'",
|
||||
@@ -217,24 +262,28 @@ public interface DashboardMapper {
|
||||
" ELSE '其他'",
|
||||
" END as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders",
|
||||
"WHERE is_del = 0",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"GROUP BY order_status",
|
||||
"GROUP BY o.order_status",
|
||||
"</script>"
|
||||
})
|
||||
List<DistributionDataVO> getOrderDistribution(@Param("p") Map<String, Object> params);
|
||||
@@ -243,77 +292,114 @@ public interface DashboardMapper {
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" '平台分账' as type,",
|
||||
" COALESCE(SUM(platform_amount), 0) as value",
|
||||
"FROM order_statistics",
|
||||
" COALESCE(SUM(os.platform_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '景区分账' as type,",
|
||||
" COALESCE(SUM(tourism_amount), 0) as value",
|
||||
"FROM order_statistics",
|
||||
" COALESCE(SUM(os.tourism_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '退款金额' as type,",
|
||||
" COALESCE(SUM(refund_amount), 0) as value",
|
||||
"FROM order_statistics",
|
||||
" COALESCE(SUM(os.refund_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
List<IncomeDataVO> getIncomeBreakdown(@Param("p") Map<String, Object> params);
|
||||
|
||||
// 筛选选项
|
||||
@Select("SELECT id as value, tourism_name as label FROM tourisms WHERE is_del = 0 ORDER BY tourism_name")
|
||||
@Select("SELECT id as value, tourism_name as label FROM tourisms WHERE is_del = 0 ORDER BY create_time DESC")
|
||||
List<FilterOptions.OptionItem> getTourismOptions();
|
||||
|
||||
@Select("SELECT code_id as value, CONCAT(name, ' | ', device_sn) as label FROM qrcodes WHERE is_del = 0 ORDER BY name")
|
||||
List<FilterOptions.OptionItem> getQrcodeOptions();
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT code_id as value, name as label FROM qrcodes",
|
||||
"WHERE is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"ORDER BY create_time DESC",
|
||||
"</script>"
|
||||
})
|
||||
List<FilterOptions.OptionItem> getQrcodeOptions(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select("SELECT DISTINCT device_sn as value, device_sn as label FROM orders WHERE device_sn IS NOT NULL AND device_sn != '' ORDER BY device_sn")
|
||||
List<FilterOptions.OptionItem> getDeviceOptions();
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT DISTINCT device_sn as value, device_sn as label FROM qrcodes",
|
||||
"WHERE is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND is_test = 0",
|
||||
"</if>",
|
||||
"AND device_sn IS NOT NULL",
|
||||
"ORDER BY device_sn",
|
||||
"</script>"
|
||||
})
|
||||
List<FilterOptions.OptionItem> getDeviceOptions(@Param("p") Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -99,4 +99,10 @@ public class QrCode extends SuperEntity {
|
||||
@Schema(description = "素材数量")
|
||||
private Integer materialCount;
|
||||
|
||||
/**
|
||||
* 是否为测试二维码(0:否,1:是)
|
||||
*/
|
||||
@Schema(description = "是否为测试二维码")
|
||||
private Integer isTest;
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -31,7 +31,7 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
statistics.setChartStats(getChartStatistics(params));
|
||||
|
||||
// 3. 获取筛选选项
|
||||
statistics.setFilterOptions(getFilterOptions());
|
||||
statistics.setFilterOptions(getFilterOptions(params));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取仪表盘统计数据失败", e);
|
||||
@@ -102,17 +102,17 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
/**
|
||||
* 获取筛选选项
|
||||
*/
|
||||
private FilterOptions getFilterOptions() {
|
||||
private FilterOptions getFilterOptions(Map<String, Object> params) {
|
||||
FilterOptions options = new FilterOptions();
|
||||
|
||||
// 获取景区列表
|
||||
options.setTourismList(dashboardMapper.getTourismOptions());
|
||||
|
||||
// 获取二维码列表
|
||||
options.setQrcodeList(dashboardMapper.getQrcodeOptions());
|
||||
options.setQrcodeList(dashboardMapper.getQrcodeOptions(params));
|
||||
|
||||
// 获取设备列表
|
||||
options.setDeviceList(dashboardMapper.getDeviceOptions());
|
||||
options.setDeviceList(dashboardMapper.getDeviceOptions(params));
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user