<%@ Page Title="" Language="C#" MasterPageFile="~/Master/UserMaster.master" CodeBehind="BorrowSum.aspx.cs" Inherits="WAP2P.Web.PC.User.Borrow.BorrowSum" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div class="m-userbox m-buserbox">
        <div class="m-prompt pl10 pr10 mt20">
            <div class="prompt-left g-left mt10 g-fcenter">
                您当前待付总额：
                <span class="fcred-3 g-fbold fs16 g-fcenter mt10 mb5 g-block"><% =(waitList.Sum(item => item.ShouldRepayPrincipal + item.ShouldRepayInterest + item.ShouldRepayOverdue + item.ShouldRepayFee)).ToMoneyString() %> 元</span>
            </div>
            <div class="prompt-small g-right">
                <p>展示所有的与借贷资金汇总相关的基本情况，了解相关的名词解释，将更好的协助您对借款情况进行评估。</p>
                <p>详细情况具体请查看 <a target="_blank" href="/Help/">帮助中心</a>。</p>
            </div>
        </div>
        <div class="table-account mt25">
            <h4>您在<% =SiteName %>总计借款<% =repayList.Sum(item => item.ShouldRepayPrincipal).ToMoneyString() %> 元，总计需支付<% =(repayList.Sum(item => item.ShouldRepayInterest + item.ShouldRepayOverdue + item.ShouldRepayFee) + (-accountList.Sum(item => item.Money))).ToMoneyString() %> 元的利息和费用</h4>
            <table style="width:30%;" class="g-left">
                <tr>
                    <th style="width:45%;">借款利息：</th>
                    <td><span><% =repayList.Sum(item => item.ShouldRepayInterest).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>综合费用：</th>
                    <td><span><% =repayList.Sum(item => item.ShouldRepayFee).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>逾期费用：</th>
                    <td><span><% =repayList.Sum(item => item.ShouldRepayOverdue).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>借款管理费：</th>
                    <td><span><% =(-accountList.Sum(item => item.Money)).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>总计：</th>
                    <td><span><% =(repayList.Sum(item => item.ShouldRepayPrincipal + item.ShouldRepayOverdue + item.ShouldRepayFee) + (-accountList.Sum(item => item.Money))).ToMoneyString() %></span> 元</td>
                </tr>
            </table>
            <div class="g-right" style="width: 70%; height: 320px;" id="js-chart-total">
            </div>
        </div>
        <div class="table-account mt15">
            <h4>您在<% =SiteName %>的借款待还总额为<% =waitList.Sum(item => item.ShouldRepayPrincipal +  item.ShouldRepayOverdue + item.ShouldRepayFee).ToMoneyString() %> 元</h4>
            <table style="width: 30%;" class="g-left">
                <tr>
                    <th style="width: 45%;">待还本金：</th>
                    <td><span><% =waitList.Sum(item => item.ShouldRepayPrincipal).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>待还利息：</th>
                    <td><span><% =waitList.Sum(item => item.ShouldRepayInterest).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>综合费用：</th>
                    <td><span><% =waitList.Sum(item => item.ShouldRepayFee).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>待还逾期费用：</th>
                    <td><span><% =waitList.Sum(item => item.ShouldRepayOverdue).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>总计：</th>
                    <td><span><% =waitList.Sum(item => item.ShouldRepayPrincipal + item.ShouldRepayInterest  + item.ShouldRepayOverdue + item.ShouldRepayFee).ToMoneyString() %></span> 元</td>
                </tr>
            </table>
            <div class="g-right" style="width: 70%; height: 320px;" id="js-chart-wait">
            </div>
        </div>
        <div class="table-account mt15">
            <h4>您在<% =SiteName %>的借款已还总额为<% =paiedList.Sum(item => item.ActuaRepayPrincipal + item.ActuaRepayInterest + item.ActuaRepayOverdue).ToMoneyString() %> 元</h4>
            <table style="width: 30%;" class="g-left">
                <tr>
                    <th style="width: 45%;">已还本金：</th>
                    <td><span><% =paiedList.Sum(item => item.ActuaRepayPrincipal).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>已还利息：</th>
                    <td><span><% =paiedList.Sum(item => item.ActuaRepayInterest).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>已交逾期费用：</th>
                    <td><span><% =paiedList.Sum(item => item.ActuaRepayOverdue).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>已交借款管理费：</th>
                    <td><span><% =(-accountList.Sum(item => item.Money)).ToMoneyString() %></span> 元</td>
                </tr>
                <tr>
                    <th>总计：</th>
                    <td><span><% =(paiedList.Sum(item => item.ActuaRepayPrincipal + item.ActuaRepayInterest + item.ActuaRepayOverdue) + (-accountList.Sum(item => item.Money))).ToMoneyString() %></span> 元</td>
                </tr>
            </table>
            <div class="g-right" style="width: 70%; height: 340px;" id="js-chart-paied">
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script src="<% =this.ImportJsCss("~/res/echarts/build/echarts-plain.js") %>"></script>
    <script src="<% =this.ImportJsCss("~/res/echarts/build/macarons.js") %>"></script>
    <script>        
        var legendTotalData = ['借款利息', '逾期费用', '借款管理费', '综合费用'];
        var legendWaitData = ['待还本金', '待还利息', '待还逾期费用', '待还综合费用'];
        var legendPaiedData = ['已还本金', '已还利息', '已交逾期费用', '已交借款管理费', '已交综合费用'];
        var xAxisData = ['<% =now.AddMonths(-5).Month %>月', '<% =now.AddMonths(-4).Month %>月', '<% =now.AddMonths(-3).Month %>月', '<% =now.AddMonths(-2).Month %>月', '<% =now.AddMonths(-1).Month %>月', '<% =now.Month %>月'];

        var seriesTotal = [
           {
               name: legendTotalData[0], type: 'line', stack: '总量', data: [
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ShouldRepayInterest) %>
               ]
           },
            {
                name: legendTotalData[1], type: 'line', stack: '总量', data: [
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ShouldRepayOverdue) %>
                ]
            }, {
                name: legendTotalData[2], type: 'line', stack: '总量', data: [
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => -item.Money) %>
                ]
            }, {
                name: legendTotalData[3], type: 'line', stack: '总量', data: [
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =repayList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ShouldRepayFee) %>
                ]
            }
        ];

        var seriesWait = [
            {
                name: legendWaitData[0], type: 'line', stack: '总量', data: [
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ShouldRepayPrincipal) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ShouldRepayPrincipal) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ShouldRepayPrincipal) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ShouldRepayPrincipal) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ShouldRepayPrincipal) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ShouldRepayPrincipal) %>
                ]
            }, {
                name: legendWaitData[1], type: 'line', stack: '总量', data: [
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ShouldRepayInterest) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ShouldRepayInterest) %>
                ]
            }, {
                name: legendWaitData[2], type: 'line', stack: '总量', data: [
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ShouldRepayOverdue) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ShouldRepayOverdue) %>
                ]
            }, {
                name: legendWaitData[1], type: 'line', stack: '总量', data: [
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ShouldRepayFee) %>,
                    <% =waitList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ShouldRepayFee) %>
                ]
            }
        ];

        var seriesPaied = [
            {
                name: legendPaiedData[0], type: 'line', stack: '总量', data: [
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ActuaRepayPrincipal) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ActuaRepayPrincipal) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ActuaRepayPrincipal) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ActuaRepayPrincipal) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ActuaRepayPrincipal) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ActuaRepayPrincipal) %>
                ]
            }, {
                name: legendPaiedData[1], type: 'line', stack: '总量', data: [
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ActuaRepayInterest) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ActuaRepayInterest) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ActuaRepayInterest) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ActuaRepayInterest) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ActuaRepayInterest) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ActuaRepayInterest) %>
                ]
            }, {
                name: legendPaiedData[2], type: 'line', stack: '总量', data: [
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ActuaRepayOverdue) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ActuaRepayOverdue) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ActuaRepayOverdue) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ActuaRepayOverdue) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ActuaRepayOverdue) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ActuaRepayOverdue) %>
                ]
            }, {
                name: legendPaiedData[3], type: 'line', stack: '总量', data: [
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => -item.Money) %>,
                    <% =accountList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => -item.Money) %>
                ]
            }, {
                name: legendPaiedData[1], type: 'line', stack: '总量', data: [
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-5).Month).Sum(item => item.ActuaRepayFee) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-4).Month).Sum(item => item.ActuaRepayFee) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-3).Month).Sum(item => item.ActuaRepayFee) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-2).Month).Sum(item => item.ActuaRepayFee) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.AddMonths(-1).Month).Sum(item => item.ActuaRepayFee) %>,
                    <% =paiedList.Where(item => item.CreateAt >= chartStart && item.CreateAt.Month == now.Month).Sum(item => item.ActuaRepayFee) %>
                ]
            }
        ];

        charts.line('js-chart-total', legendTotalData, xAxisData, seriesTotal);
        charts.line('js-chart-wait', legendWaitData, xAxisData, seriesWait);
        charts.line('js-chart-paied', legendPaiedData, xAxisData, seriesPaied);
        
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server">
</asp:Content>
