!22 fix(后台管理): 首页统计功能新增二维码维度统计,灵活设置分账比例,过滤测试二维码订单的数据等
Merge pull request !22 from Iamasoldier/feature_temp
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;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PageContainer } from '@ant-design/pro-components';
|
||||
import { Card, Row, Col, Statistic, Progress, Typography, Select, DatePicker, Space, Button } from 'antd';
|
||||
import { Card, Row, Col, Statistic, Progress, Typography, Select, DatePicker, Space, Button, Switch } from 'antd';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { dashboard } from '@/services/orders/api';
|
||||
import { dashboard, getQrcodeOptions } from '@/services/orders/api';
|
||||
import { Area, Column, Pie } from '@ant-design/plots';
|
||||
import {
|
||||
ShoppingCartOutlined,
|
||||
@@ -15,6 +15,28 @@ import styles from './Welcome.less';
|
||||
const { Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
// 平台分账比例选项
|
||||
const PLATFORM_RATE_OPTIONS = [
|
||||
{ label: '90% (平台90%)', value: 0.9 },
|
||||
{ label: '85% (平台85%)', value: 0.85 },
|
||||
{ label: '80% (平台80%)', value: 0.8 },
|
||||
{ label: '75% (平台75%)', value: 0.75 },
|
||||
{ label: '70% (平台70%)', value: 0.7 },
|
||||
{ label: '65% (平台65%)', value: 0.65 },
|
||||
{ label: '60% (平台60%)', value: 0.6 },
|
||||
{ label: '55% (平台55%)', value: 0.55 },
|
||||
{ label: '50% (平台50%)', value: 0.5 },
|
||||
{ label: '45% (平台45%)', value: 0.45 },
|
||||
{ label: '40% (平台40%)', value: 0.4 },
|
||||
{ label: '35% (平台35%)', value: 0.35 },
|
||||
{ label: '30% (平台30%)', value: 0.3 },
|
||||
{ label: '25% (平台25%)', value: 0.25 },
|
||||
{ label: '20% (平台20%)', value: 0.2 },
|
||||
{ label: '15% (平台15%)', value: 0.15 },
|
||||
{ label: '10% (平台10%)', value: 0.1 },
|
||||
{ label: '5% (平台5%)', value: 0.05 },
|
||||
];
|
||||
|
||||
interface Statistics {
|
||||
orderStats: {
|
||||
totalOrders: number;
|
||||
@@ -57,18 +79,24 @@ const Welcome: React.FC = () => {
|
||||
const [statistics, setStatistics] = useState<any>({});
|
||||
// 只保留景区筛选
|
||||
const [selectedTourism, setSelectedTourism] = useState<number | undefined>();
|
||||
// 新增二维码筛选
|
||||
const [selectedQrcode, setSelectedQrcode] = useState<string | undefined>();
|
||||
// 新增平台分账比例,默认70%
|
||||
const [platformRate, setPlatformRate] = useState<number>(0.7);
|
||||
// 新增时间区间筛选
|
||||
const [timeRange, setTimeRange] = useState<[string, string]>(['', '']);
|
||||
// 新增是否包含测试二维码筛选,默认不包含
|
||||
const [includeTestQrcodes, setIncludeTestQrcodes] = useState<boolean>(false);
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const params = {
|
||||
tourismId: selectedTourism,
|
||||
qrcodeId: selectedQrcode,
|
||||
startTime: timeRange[0],
|
||||
endTime: timeRange[1],
|
||||
includeTestQrcodes: includeTestQrcodes,
|
||||
};
|
||||
const result = await dashboard(params);
|
||||
if (result.resp_code === 0) {
|
||||
@@ -83,7 +111,47 @@ const Welcome: React.FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
}, [selectedTourism, timeRange]);
|
||||
}, [selectedTourism, selectedQrcode, timeRange, includeTestQrcodes]);
|
||||
|
||||
// 处理景区选择变化
|
||||
const handleTourismChange = (tourismId: number | undefined) => {
|
||||
setSelectedTourism(tourismId);
|
||||
// 当景区变化时,清空二维码选择
|
||||
setSelectedQrcode(undefined);
|
||||
// 重新获取二维码选项
|
||||
fetchQrcodeOptions(tourismId);
|
||||
};
|
||||
|
||||
// 获取当前景区下的二维码选项
|
||||
const getCurrentTourismQrcodes = () => {
|
||||
if (!selectedTourism) return [];
|
||||
// 从筛选选项中获取当前景区的二维码
|
||||
return filterOptions.qrcodeList || [];
|
||||
};
|
||||
|
||||
// 获取二维码列表
|
||||
const fetchQrcodeOptions = async (tourismId: number | undefined) => {
|
||||
if (!tourismId) return;
|
||||
try {
|
||||
const params = {
|
||||
tourismId: tourismId,
|
||||
includeTestQrcodes: includeTestQrcodes,
|
||||
};
|
||||
const result = await getQrcodeOptions(params);
|
||||
if (result.resp_code === 0 && result.data?.qrcodeList) {
|
||||
// 更新二维码选项
|
||||
setStatistics((prev: any) => ({
|
||||
...prev,
|
||||
filterOptions: {
|
||||
...prev.filterOptions,
|
||||
qrcodeList: result.data.qrcodeList
|
||||
}
|
||||
}));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取二维码列表失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 更新数据访问方式
|
||||
const orderStats = statistics.orderStats || {};
|
||||
@@ -153,20 +221,50 @@ const Welcome: React.FC = () => {
|
||||
allowClear
|
||||
options={filterOptions.tourismList || []}
|
||||
value={selectedTourism}
|
||||
onChange={setSelectedTourism}
|
||||
onChange={handleTourismChange}
|
||||
/>
|
||||
{/* 新增二维码选择器 */}
|
||||
<Select
|
||||
placeholder="选择二维码"
|
||||
style={{ width: 200 }}
|
||||
allowClear
|
||||
disabled={!selectedTourism}
|
||||
options={getCurrentTourismQrcodes()}
|
||||
value={selectedQrcode}
|
||||
onChange={setSelectedQrcode}
|
||||
/>
|
||||
{/* 新增平台分账比例选择 */}
|
||||
<span>平台分账比例:</span>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
style={{ width: 140 }}
|
||||
value={platformRate}
|
||||
onChange={setPlatformRate}
|
||||
options={[
|
||||
{ label: '70%', value: 0.7 },
|
||||
{ label: '60%', value: 0.6 },
|
||||
{ label: '50%', value: 0.5 },
|
||||
]}
|
||||
showSearch
|
||||
placeholder="选择分账比例"
|
||||
optionFilterProp="label"
|
||||
filterOption={(input, option) =>
|
||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
|
||||
}
|
||||
options={PLATFORM_RATE_OPTIONS}
|
||||
/>
|
||||
<span style={{ color: '#666', fontSize: '12px' }}>
|
||||
(当前:平台{Math.round(platformRate * 100)}% | 景区{Math.round((1 - platformRate) * 100)}%)
|
||||
</span>
|
||||
{/* 快速选择常用分账比例 */}
|
||||
<Space size="small">
|
||||
<span style={{ color: '#666', fontSize: '12px' }}>快速选择:</span>
|
||||
{[0.7, 0.6, 0.5, 0.4, 0.3].map(rate => (
|
||||
<Button
|
||||
key={rate}
|
||||
size="small"
|
||||
type={platformRate === rate ? 'primary' : 'default'}
|
||||
onClick={() => setPlatformRate(rate)}
|
||||
style={{ fontSize: '11px', padding: '0 6px' }}
|
||||
>
|
||||
{Math.round(rate * 100)}%
|
||||
</Button>
|
||||
))}
|
||||
</Space>
|
||||
{/* 新增时间区间筛选 */}
|
||||
<RangePicker
|
||||
placeholder={['开始时间', '结束时间']}
|
||||
@@ -190,6 +288,14 @@ const Welcome: React.FC = () => {
|
||||
>
|
||||
刷新
|
||||
</Button>
|
||||
{/* 新增测试二维码筛选开关 */}
|
||||
<span>包含测试二维码:</span>
|
||||
<Switch
|
||||
checked={includeTestQrcodes}
|
||||
onChange={setIncludeTestQrcodes}
|
||||
checkedChildren="是"
|
||||
unCheckedChildren="否"
|
||||
/>
|
||||
</Space>
|
||||
</Card>
|
||||
|
||||
|
||||
@@ -9,6 +9,12 @@ import {
|
||||
import { Form } from 'antd';
|
||||
import { ENABLE_PROFIT_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_VIDEO_EDIT_OPTIONS } from '../index';
|
||||
|
||||
// 添加测试二维码选项常量
|
||||
export const IS_TEST_OPTIONS = [
|
||||
{ label: '否', value: 0 },
|
||||
{ label: '是', value: 1 },
|
||||
];
|
||||
|
||||
interface CreateFormProps {
|
||||
visible: boolean;
|
||||
onVisibleChange: (visible: boolean) => void;
|
||||
@@ -184,6 +190,15 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
rules={[{ required: true, message: '请选择是否开启一键成片' }]}
|
||||
initialValue={0}
|
||||
/>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="isTest"
|
||||
label="是否为测试二维码"
|
||||
options={IS_TEST_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择是否为测试二维码' }]}
|
||||
initialValue={0}
|
||||
tooltip="测试二维码的数据不会计入正式统计"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
|
||||
@@ -10,6 +10,12 @@ import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_PROFIT_OPTIONS, ENABLE_VIDEO
|
||||
import { Form, Space } from 'antd';
|
||||
import styles from './index.less';
|
||||
|
||||
// 添加测试二维码选项常量
|
||||
export const IS_TEST_OPTIONS = [
|
||||
{ label: '否', value: 0 },
|
||||
{ label: '是', value: 1 },
|
||||
];
|
||||
|
||||
interface UpdateFormProps {
|
||||
updateModalVisible: boolean;
|
||||
onVisibleChange: (visible: boolean) => void;
|
||||
@@ -184,6 +190,14 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
options={ENABLE_VIDEO_EDIT_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择是否开启一键成片' }]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="isTest"
|
||||
label="是否为测试二维码"
|
||||
options={IS_TEST_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择是否为测试二维码' }]}
|
||||
tooltip="测试二维码的数据不会计入正式统计"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
|
||||
@@ -55,6 +55,12 @@ export const ENABLE_VIDEO_EDIT_OPTIONS = [
|
||||
{ label: '是', value: 1 },
|
||||
] as const;
|
||||
|
||||
// 添加测试二维码选项常量
|
||||
export const IS_TEST_OPTIONS = [
|
||||
{ label: '否', value: 0 },
|
||||
{ label: '是', value: 1 },
|
||||
] as const;
|
||||
|
||||
const handleApiRequest = async (
|
||||
apiCall: () => Promise<any>,
|
||||
loadingMessage: string,
|
||||
@@ -91,7 +97,7 @@ const TableList: React.FC = () => {
|
||||
|
||||
// 将 renderStatus 函数移到组件内部
|
||||
const renderStatus = (status: number) => {
|
||||
const statusColorMap = {
|
||||
const statusColorMap: Record<number, { color: string; text: string }> = {
|
||||
0: { color: 'green', text: '启用' },
|
||||
1: { color: 'red', text: '未启用' },
|
||||
};
|
||||
@@ -100,12 +106,12 @@ const TableList: React.FC = () => {
|
||||
};
|
||||
|
||||
// 处理添加
|
||||
const handleAdd = async (fields: ORDERS.Qrcode) => {
|
||||
const handleAdd = async (fields: Partial<ORDERS.Qrcode>) => {
|
||||
const template = templateOptions.find(item => item.value === fields.templateId);
|
||||
return handleApiRequest(
|
||||
() => saveOrUpdateQrcode({
|
||||
...fields,
|
||||
}),
|
||||
} as ORDERS.Qrcode),
|
||||
'正在添加',
|
||||
'添加成功'
|
||||
);
|
||||
@@ -170,7 +176,7 @@ const TableList: React.FC = () => {
|
||||
});
|
||||
|
||||
if (result?.data) {
|
||||
const options = result.data.map(item => ({
|
||||
const options = result.data.map((item: any) => ({
|
||||
label: item.tourismName || item.name,
|
||||
value: item.id,
|
||||
info: item
|
||||
@@ -205,7 +211,7 @@ const TableList: React.FC = () => {
|
||||
});
|
||||
|
||||
if (result?.data) {
|
||||
const options = result.data.map((item: DEVICE.Device) => ({
|
||||
const options = result.data.map((item: any) => ({
|
||||
label: `${item.deviceName}(${item.deviceSn})`,
|
||||
value: item.deviceSn,
|
||||
info: item
|
||||
@@ -225,7 +231,7 @@ const TableList: React.FC = () => {
|
||||
status: 1, // 只获取启用的模板
|
||||
});
|
||||
if (result.data?.data) {
|
||||
const options = result.data.data.map(item => ({
|
||||
const options = result.data.data.map((item: any) => ({
|
||||
label: item.templateName,
|
||||
value: item.templateId,
|
||||
info: item,
|
||||
@@ -418,6 +424,20 @@ const TableList: React.FC = () => {
|
||||
1: { text: '是' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '是否为测试二维码',
|
||||
dataIndex: 'isTest',
|
||||
width: 140,
|
||||
render: (_, record) => {
|
||||
const status = record.isTest === 1 ? '是' : '否';
|
||||
const color = record.isTest === 1 ? 'blue' : 'default';
|
||||
return <Tag color={color}>{status}</Tag>;
|
||||
},
|
||||
valueEnum: {
|
||||
0: { text: '否' },
|
||||
1: { text: '是' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
@@ -480,6 +500,12 @@ const TableList: React.FC = () => {
|
||||
placeholder="请选择状态"
|
||||
options={STATUS_OPTIONS}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="isTest"
|
||||
label="是否为测试二维码"
|
||||
placeholder="请选择是否为测试二维码"
|
||||
options={IS_TEST_OPTIONS}
|
||||
/>
|
||||
</QueryFilter>
|
||||
<ProTable<ORDERS.Qrcode>
|
||||
rowKey="id"
|
||||
|
||||
@@ -190,6 +190,7 @@ export async function dashboard(params?: {
|
||||
deviceSn?: string;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
includeTestQrcodes?: boolean;
|
||||
}) {
|
||||
return request('/api-order/dashboard/statistics', {
|
||||
method: 'GET',
|
||||
@@ -197,6 +198,17 @@ export async function dashboard(params?: {
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取二维码列表 GET /api-order/qrcode/options */
|
||||
export async function getQrcodeOptions(params?: {
|
||||
tourismId?: number;
|
||||
includeTestQrcodes?: boolean;
|
||||
}) {
|
||||
return request('/api-order/dashboard/qrcode/options', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 分页查询分账记录 */
|
||||
export async function profitSharingList(params: {
|
||||
page: number;
|
||||
|
||||
@@ -63,9 +63,11 @@ declare namespace ORDERS {
|
||||
type Qrcode = {
|
||||
id: number;
|
||||
codeId: string;
|
||||
name?: string;
|
||||
tourismId: string;
|
||||
path: string;
|
||||
fileId: string;
|
||||
viewUrl?: string;
|
||||
price: string;
|
||||
deviceSn: string;
|
||||
createTime?: string;
|
||||
@@ -79,6 +81,10 @@ declare namespace ORDERS {
|
||||
payeeFailReason?: string;
|
||||
templateId: string;
|
||||
materialCount?: number;
|
||||
isTest?: number; // 是否为测试二维码(0:否,1:是)
|
||||
enableProfit?: number; // 是否开启分润(0:否,1:是)
|
||||
enableVideoEdit?: number; // 是否开启一键成片(0:否,1:是)
|
||||
waylineId?: string; // 航线ID
|
||||
}
|
||||
|
||||
type HomeCarousel = {
|
||||
|
||||
Reference in New Issue
Block a user