刘帅
2026-09-21 dcd3a10769dbd29487540aaa2515a552993120a7
cloud-server-management/src/main/webapp/WEB-INF/view/system/dataStatistics/platformIncome.html
@@ -350,6 +350,17 @@
<script src="${ctxPath}/modular/system/dataStatistics/echarts.min.js"></script>
<script src="${ctxPath}/static/js/plugins/switchery/switchery.js"></script>
<script>
    // 仅格式化前端展示,接口返回的原始数值不作改动。
    function formatStatisticNumber(value) {
        var number = Number(value);
        return isFinite(number) ? number.toFixed(2) : '0.00';
    }
    // 首次进入页面时,收入类型来自服务端模板变量;同样按两位小数展示。
    $(function () {
        $('#fee1, #fee2, #fee3, #fee4, #fee5, #fee7').each(function () {
            $(this).text(formatStatisticNumber($(this).text()));
        });
    });
   laydate.render({
      elem: '#beginTime'
      , trigger: 'click'
@@ -357,19 +368,20 @@
   });
    function search1() {
        var time =  $("#beginTime").val();
        loadIncomeTypePieCharts(time);
        // 营收卡片与收入类型卡片使用同一接口、同一时间范围,避免筛选后口径不一致。
        var incomeAjax = new $ax(Feng.ctxPath + "/data/getIncomeData", function(resp){
            $("#totalIncome").text(resp.incomeStatistics.totalIncomeAmount || 0);
            $("#netIncomeAmount").text(resp.incomeStatistics.netIncomeAmount || 0);
            $("#couponDeductionAmount").text(resp.incomeStatistics.couponDeductionAmount || 0);
            $("#refundAmount").text(resp.incomeStatistics.refundAmount || 0);
            $("#totalIncome").text(formatStatisticNumber(resp.incomeStatistics.totalIncomeAmount));
            $("#netIncomeAmount").text(formatStatisticNumber(resp.incomeStatistics.netIncomeAmount));
            $("#couponDeductionAmount").text(formatStatisticNumber(resp.incomeStatistics.couponDeductionAmount));
            $("#refundAmount").text(formatStatisticNumber(resp.incomeStatistics.refundAmount));
            var incomeTypeNet = resp.incomeTypeNet || {};
            $("#fee1").text(incomeTypeNet[1] || 0);
            $("#fee2").text(incomeTypeNet[2] || 0);
            $("#fee3").text(incomeTypeNet[3] || 0);
            $("#fee4").text(incomeTypeNet[4] || 0);
            $("#fee5").text(incomeTypeNet[5] || 0);
            $("#fee7").text(incomeTypeNet[6] || 0);
            $("#fee1").text(formatStatisticNumber(incomeTypeNet[1]));
            $("#fee2").text(formatStatisticNumber(incomeTypeNet[2]));
            $("#fee3").text(formatStatisticNumber(incomeTypeNet[3]));
            $("#fee4").text(formatStatisticNumber(incomeTypeNet[4]));
            $("#fee5").text(formatStatisticNumber(incomeTypeNet[5]));
            $("#fee7").text(formatStatisticNumber(incomeTypeNet[6]));
            renderTicketIncomeChart(resp.ticketIncome || {});
        });
        incomeAjax.set("time", time);
@@ -399,6 +411,30 @@
            }]
        }, true);
    }
    function renderIncomeTypePieChart(elementId, title, data) {
        var chartDom = document.getElementById(elementId);
        var chart = echarts.getInstanceByDom(chartDom) || echarts.init(chartDom);
        chart.setOption({
            title: {text: title, left: 'center'},
            tooltip: {trigger: 'item'},
            series: [{name: title, type: 'pie', radius: '50%', data: data || []}]
        }, true);
    }
    // 使用接口返回的 JSON 分类数据,避免服务端模板字符串解析遗漏最后一个分类。
    function loadIncomeTypePieCharts(time) {
        var ajax = new $ax(Feng.ctxPath + "/data/type1", function (data) {
            renderIncomeTypePieChart('cookieCourse', '课程收入', data.courseData);
            renderIncomeTypePieChart('cookieBooking', '订场收入', data.siteData);
        });
        ajax.set('time', time);
        ajax.start();
    }
    $(function () {
        loadIncomeTypePieCharts('');
    });
    // 创建一个日期对象
    var currentDate = new Date();
    // 获取当前日期的号数
@@ -432,18 +468,18 @@
    function renderIncomeStatistics(elementId, periodName, statistics) {
        document.getElementById(elementId).innerText = periodName + "统计:总营收金额 "
            + statistics.totalIncomeAmount + ",净收入金额 " + statistics.netIncomeAmount
            + ",优惠券抵扣金额 " + statistics.couponDeductionAmount + ",退款金额 "
            + statistics.refundAmount;
            + formatStatisticNumber(statistics.totalIncomeAmount) + ",净收入金额 " + formatStatisticNumber(statistics.netIncomeAmount)
            + ",优惠券抵扣金额 " + formatStatisticNumber(statistics.couponDeductionAmount) + ",退款金额 "
            + formatStatisticNumber(statistics.refundAmount);
    }
    function renderIncomeStatisticsList(elementId, title, labels, statistics) {
        var records = labels.map(function (label, index) {
            var item = statistics[index];
            return '<div class="income-period-record"><strong>' + label + '</strong>:总营收金额 '
                + item.totalIncomeAmount + ',净收入金额 ' + item.netIncomeAmount
                + ',优惠券抵扣金额 ' + item.couponDeductionAmount
                + ',退款金额 ' + item.refundAmount + '</div>';
                + formatStatisticNumber(item.totalIncomeAmount) + ',净收入金额 ' + formatStatisticNumber(item.netIncomeAmount)
                + ',优惠券抵扣金额 ' + formatStatisticNumber(item.couponDeductionAmount)
                + ',退款金额 ' + formatStatisticNumber(item.refundAmount) + '</div>';
        }).join('');
        document.getElementById(elementId).innerHTML = '<div class="income-period-title">' + title
            + '</div><div class="income-period-records">' + records + '</div>';
@@ -458,10 +494,10 @@
                formatter: function (params) {
                    var item = params[0];
                    var detail = statistics[item.dataIndex];
                    return labels[item.dataIndex] + '<br/>总营收:' + detail.totalIncomeAmount
                        + '<br/>净收入:' + detail.netIncomeAmount
                        + '<br/>优惠券抵扣:' + detail.couponDeductionAmount
                        + '<br/>退款:' + detail.refundAmount;
                    return labels[item.dataIndex] + '<br/>总营收:' + formatStatisticNumber(detail.totalIncomeAmount)
                        + '<br/>净收入:' + formatStatisticNumber(detail.netIncomeAmount)
                        + '<br/>优惠券抵扣:' + formatStatisticNumber(detail.couponDeductionAmount)
                        + '<br/>退款:' + formatStatisticNumber(detail.refundAmount);
                }
            },
            grid: {left: '5%', right: '4%', bottom: '18%', containLabel: true},
@@ -539,10 +575,10 @@
            var netIncomeAmount = document.getElementById("netIncomeAmount");
            var couponDeductionAmount = document.getElementById("couponDeductionAmount");
            var refundAmount = document.getElementById("refundAmount");
            t1.innerText = list[0] || 0;
            netIncomeAmount.innerText = resp.incomeStatistics.netIncomeAmount || 0;
            couponDeductionAmount.innerText = resp.incomeStatistics.couponDeductionAmount || 0;
            refundAmount.innerText = resp.incomeStatistics.refundAmount || 0;
            t1.innerText = formatStatisticNumber(list[0]);
            netIncomeAmount.innerText = formatStatisticNumber(resp.incomeStatistics.netIncomeAmount);
            couponDeductionAmount.innerText = formatStatisticNumber(resp.incomeStatistics.couponDeductionAmount);
            refundAmount.innerText = formatStatisticNumber(resp.incomeStatistics.refundAmount);
            renderIncomeStatisticsList("yearIncomeStatistics", "历年营收明细", resp.yearLabels, resp.yearIncomeStatistics);
            renderIncomeStatisticsList("monthIncomeStatistics", "本年各月营收明细", resp.monthLabels, resp.monthIncomeStatistics);
            renderIncomeStatisticsList("weekIncomeStatistics", "近四周营收明细", resp.weekLabels, resp.weekIncomeStatistics);
@@ -551,10 +587,10 @@
            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);
            $("#back1").text(formatStatisticNumber(resp.yearIncomeStatistics[resp.yearIncomeStatistics.length - 1].refundAmount));
            $("#back2").text(formatStatisticNumber(resp.monthIncomeStatistics[new Date().getMonth()].refundAmount));
            $("#back3").text(formatStatisticNumber(resp.weekIncomeStatistics[resp.weekIncomeStatistics.length - 1].refundAmount));
            $("#back4").text(formatStatisticNumber(resp.dayIncomeStatistics[resp.dayIncomeStatistics.length - 1].refundAmount));
            renderRefundChart(myChart1, resp);
        });
        ajax.set("type",1);