刘帅
2026-09-17 f9fa8e891af1b6ffe6e12607629a644579bcdab1
feat&bug:退费数据不一致
1个文件已修改
142 ■■■■■ 已修改文件
cloud-server-management/src/main/webapp/WEB-INF/view/system/dataStatistics/platformIncome.html 142 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/webapp/WEB-INF/view/system/dataStatistics/platformIncome.html
@@ -452,6 +452,47 @@
        });
    }
    // 退费图与营收图使用同一接口返回的退款流水,保证统计口径一致。
    function renderRefundChart(chart, resp) {
        var labelsByPeriod = {
            '年度退费': resp.yearLabels,
            '月度退费': resp.monthLabels,
            '周度退费': resp.weekLabels,
            '日度退费': resp.dayLabels
        };
        var statisticsByPeriod = {
            '年度退费': resp.yearIncomeStatistics,
            '月度退费': resp.monthIncomeStatistics,
            '周度退费': resp.weekIncomeStatistics,
            '日度退费': resp.dayIncomeStatistics
        };
        chart.off('legendselectchanged');
        chart.setOption({
            tooltip: {trigger: 'axis'},
            legend: {
                data: ['年度退费', '月度退费', '周度退费', '日度退费'],
                icon: 'stack',
                selectedMode: 'single',
                selected: {'年度退费': true, '月度退费': false, '周度退费': false, '日度退费': false}
            },
            grid: {left: '3%', right: '4%', bottom: '12%', containLabel: true},
            toolbox: {feature: {saveAsImage: {}}},
            xAxis: {type: 'category', boundaryGap: false, data: labelsByPeriod['年度退费'], axisLabel: {rotate: 35, interval: 0}},
            yAxis: {type: 'value'},
            series: Object.keys(statisticsByPeriod).map(function (period) {
                return {
                    name: period,
                    type: 'line',
                    data: statisticsByPeriod[period].map(function (item) { return item.refundAmount; })
                };
            })
        }, true);
        chart.on('legendselectchanged', function (event) {
            var labels = labelsByPeriod[event.name];
            chart.setOption({xAxis: {data: labels, axisLabel: {rotate: labels.length > 7 ? 35 : 0, interval: 0}}});
        });
    }
    $(function(){
        getContent(1);
        getContent1(1);
@@ -459,6 +500,7 @@
        ptCourse();
        var myChart1 = echarts.init(document.getElementById('refund'));
        var ajax = new $ax(Feng.ctxPath + "/data/getIncomeData", function(resp){
            // 运营、教学等其他图表仍复用年度横轴。
            yearX = resp.year;
@@ -479,87 +521,16 @@
            renderIncomeTrendChart("incomeMonthChart", "本年各月营收趋势", resp.monthLabels, resp.monthIncomeStatistics);
            renderIncomeTrendChart("incomeWeekChart", "近四周营收趋势", resp.weekLabels, resp.weekIncomeStatistics);
            renderIncomeTrendChart("incomeDayChart", "近七日营收趋势", resp.dayLabels, resp.dayIncomeStatistics);
            $("#back1").text(resp.yearIncomeStatistics[resp.yearIncomeStatistics.length - 1].refundAmount || 0);
            $("#back2").text(resp.monthIncomeStatistics[new Date().getMonth()].refundAmount || 0);
            $("#back3").text(resp.weekIncomeStatistics[resp.weekIncomeStatistics.length - 1].refundAmount || 0);
            $("#back4").text(resp.dayIncomeStatistics[resp.dayIncomeStatistics.length - 1].refundAmount || 0);
            renderRefundChart(myChart1, resp);
        });
        ajax.set("type",1);
        ajax.start();
        var myChart1 = echarts.init(document.getElementById('refund'));
        var myChart7 = echarts.init(document.getElementById('courseData'));
        var ajax3 = new $ax(Feng.ctxPath + "/data/backPt", function(data){
            $("#back1").text(data.thisYear);
            $("#back2").text(data.thisMonth);
            $("#back3").text(data.thisWeek);
            $("#back4").text(data.thisDay);
            optionBack = {
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['年度退费', '月度退费','周度退费','日度退费'],
                    icon: 'stack',
                    selectedMode: 'single', // 单选
                    selected: {
                        年度会员数: true,
                        月度会员数: false,
                        周度会员数: false,
                        日度会员数: false
                    }
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                toolbox: {
                    feature: {
                        saveAsImage: {}
                    }
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: yearX
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name: '年度退费',
                        type: 'line',
                        stack: 'Total',
                        data: data.yearData
                    },
                    {
                        name: '月度退费',
                        type: 'line',
                        stack: 'Total',
                        data: data.monthData
                    },
                    {
                        name: '周度退费',
                        type: 'line',
                        stack: 'Total',
                        data: data.weekData
                    },
                    {
                        name: '日度退费',
                        type: 'line',
                        stack: 'Total',
                        data: data.dayData
                    }
                ]
            };
        });
        ajax3.start();
        var ajax4 = new $ax(Feng.ctxPath + "/data/userAndVipPt", function(data){
            option1 = {
@@ -627,25 +598,6 @@
            };
        });
        ajax4.start();
        myChart1.on('legendselectchanged', obj => {
            var options = myChart1.getOption()
            //这里是选择切换什么样的x轴,那么他会进行对Y值的切换
            if (obj.name == '年度退费') {
                options.xAxis[0].data = yearX
            } else if (obj.name == '月度退费') {
                options.xAxis[0].data = monthX
            } else if (obj.name == '周度退费') {
                options.xAxis[0].data = ["1周","2周","3周","4周"]
            } else if (obj.name == '日度退费') {
                options.xAxis[0].data = dataX
            }
            myChart1.setOption(options, true)
        })
        // 使用刚指定的配置项和数据显示图表。
        myChart1.setOption(optionBack);
        myChart7.setOption(option7);
    });