<%@ Page Title="" Language="C#" MasterPageFile="~/Master/UserMaster.master" CodeBehind="BidSum.aspx.cs" Inherits="WAP2P.Web.PC.User.Loan.BidSum" %>
<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">
                您当前待收总额：
                <span class="fcred-3 g-fbold fs16 g-fcenter mt10 mb5 g-block"><% =WAP2P.Account.UserAccount.LoadOrNew(CurrentUser.Id).WaitReceive.ToMoneyString() %>元</span>
            </div>
            <div class="prompt-small g-right">
                <p>展示所有的与投资资金汇总相关的基本情况，了解相关的名词解释，将更好的协助您对投资收益情况进行评估。</p>
                <p>详细情况具体请查看 <a href="/Help/" target="_blank">帮助中心</a>。</p>
            </div>
        </div>
        <div class="table-account mt15">
            <h4>您最近半年在<% =SiteName %>赚取 <% =(interestList.Sum(item => item.Money) + overdueList.Sum(item => item.Money) + transferList.Sum(item => item.UpDownAmount - item.Amount)).RoundX().ToMoneyString() %> 元</h4>
            <table style="width:30%;" class="g-left">
                <tr>
                    <th style="width:45%;">已赚利息：</th>
                    <td><span><% =interestList.Sum(item => item.Money).RoundX().ToMoneyString() %></span>元</td>
                </tr>
                <tr>
                    <th>已赚罚息：</th>
                    <td><span><% =overdueList.Sum(item => item.Money).RoundX().ToMoneyString() %></span>元</td>
                </tr>
                <tr>
                    <th>已赚违约金：</th>
                    <td><span><% =breakList.Sum(item => item.Money).RoundX().ToMoneyString() %></span>元</td>
                </tr>
                <tr>
                    <th>债权转让盈亏：</th>
                    <td><span><% =transferList.Sum(item => item.UpDownAmount - item.Amount).RoundX().ToMoneyString() %></span>元</td>
                </tr>
                <tr>
                    <th>总计：</th>
                    <td><span><% =(interestList.Sum(item => item.Money) + overdueList.Sum(item => item.Money) + transferList.Sum(item => item.UpDownAmount - item.Amount)).RoundX().ToMoneyString() %></span>元</td>
                </tr>
            </table>
            <div class="g-right" style="width:70%; height:320px;" id="js-interest">
            </div>
        </div>
        <div class="table-account mt20">
            <h4>您最近半年通过<% =SiteName %>累计投资 <% =receiveList.Sum(item => item.ShouldRepayPrincipal).ToMoneyString() %> 元</h4>
            <table style="width:30%;" class="g-left">
                <asp:Repeater runat="server" ID="rptBorrowTypeList" ItemType="WAP2P.Sys.BorrowType">
                    <ItemTemplate>
                        <tr>
                            <th<%# Container.ItemIndex == 0 ? " style=\"width:45%;\"" : string.Empty %>><%# Item.Name %>：</th>
                            <td><span><%# GetBorrowTypeSum(Item.Id, null).ToMoneyString() %></span>元</td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>                
                <tr>
                    <th>总计：</th>
                    <td><span><% =receiveList.Sum(item => item.ShouldRepayPrincipal).ToMoneyString() %></span>元</td>
                </tr>
            </table>
            <div class="g-right" style="width:70%; height:320px;" id="js-bid">                
            </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 interestTitle = ['已赚利息', '已赚罚息', "已赚违约金", '债权转让盈亏', '总计'];
        var bidTitle = [<asp:Repeater runat="server" ID="rptBorrowTypeTitle" ItemType="WAP2P.Sys.BorrowType"><ItemTemplate>'<%# Item.Name %>',</ItemTemplate></asp:Repeater>'总计'];
        var xAxisData = ['<% =startAt.Month %>月', '<% =startAt.AddMonths(1).Month %>月', '<% =startAt.AddMonths(2).Month %>月', '<% =startAt.AddMonths(3).Month %>月', '<% =startAt.AddMonths(4).Month %>月', '<% =startAt.AddMonths(5).Month %>月'];
        var interestData = [
           {
               name: interestTitle[0], type: 'line', data: [
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.Month).Sum(item => item.Money) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(1).Month).Sum(item => item.Money) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(2).Month).Sum(item => item.Money) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(3).Month).Sum(item => item.Money) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(4).Month).Sum(item => item.Money) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(5).Month).Sum(item => item.Money) %>
               ]
           }, {
                name: interestTitle[1], type: 'line', data: [
                    <% =overdueList.Where(item => item.CreateAt.Month == startAt.Month).Sum(item => item.Money) %>,
                    <% =overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(1).Month).Sum(item => item.Money) %>,
                    <% =overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(2).Month).Sum(item => item.Money) %>,
                    <% =overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(3).Month).Sum(item => item.Money) %>,
                    <% =overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(4).Month).Sum(item => item.Money) %>,
                    <% =overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(5).Month).Sum(item => item.Money) %>
                ]
           }, {
               name: interestTitle[2], type: 'line', data: [
                    <% =breakList.Where(item => item.CreateAt.Month == startAt.Month).Sum(item => item.Money) %>,
                    <% =breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(1).Month).Sum(item => item.Money) %>,
                    <% =breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(2).Month).Sum(item => item.Money) %>,
                    <% =breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(3).Month).Sum(item => item.Money) %>,
                    <% =breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(4).Month).Sum(item => item.Money) %>,
                    <% =breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(5).Month).Sum(item => item.Money) %>
               ]
           }, {
                name: interestTitle[3], type: 'line', data: [
                    <% =transferList.Where(item => item.CreateAt.Month == startAt.Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(1).Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(2).Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(3).Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(4).Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(5).Month).Sum(item => item.UpDownAmount - item.Amount) %>
                ]
            }, {
                name: interestTitle[4], type: 'line', data: [
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.Month).Sum(item => item.Money) + overdueList.Where(item => item.CreateAt.Month == startAt.Month).Sum(item => item.Money) + breakList.Where(item => item.CreateAt.Month == startAt.Month).Sum(item => item.Money) + transferList.Where(item => item.CreateAt.Month == startAt.Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(1).Month).Sum(item => item.Money) + overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(1).Month).Sum(item => item.Money) + breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(1).Month).Sum(item => item.Money) + transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(1).Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(2).Month).Sum(item => item.Money) + overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(2).Month).Sum(item => item.Money) + breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(2).Month).Sum(item => item.Money) + transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(2).Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(3).Month).Sum(item => item.Money) + overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(3).Month).Sum(item => item.Money) + breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(3).Month).Sum(item => item.Money) + transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(3).Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(4).Month).Sum(item => item.Money) + overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(4).Month).Sum(item => item.Money) + breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(4).Month).Sum(item => item.Money) + transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(4).Month).Sum(item => item.UpDownAmount - item.Amount) %>,
                    <% =interestList.Where(item => item.CreateAt.Month == startAt.AddMonths(5).Month).Sum(item => item.Money) + overdueList.Where(item => item.CreateAt.Month == startAt.AddMonths(5).Month).Sum(item => item.Money) + breakList.Where(item => item.CreateAt.Month == startAt.AddMonths(5).Month).Sum(item => item.Money) + transferList.Where(item => item.CreateAt.Month == startAt.AddMonths(5).Month).Sum(item => item.UpDownAmount - item.Amount) %>
                ]
            }
        ];
        var bidData = [
            <asp:Repeater runat="server" ID="rptBorrowTypeData" ItemType="WAP2P.Sys.BorrowType">
                <ItemTemplate>
                    {
                        name: bidTitle[<%# Container.ItemIndex %>], type: 'line', data: [
                            <%# GetBorrowTypeSum(Item.Id, startAt.Month) %>,
                            <%# GetBorrowTypeSum(Item.Id, startAt.AddMonths(1).Month) %>,
                            <%# GetBorrowTypeSum(Item.Id, startAt.AddMonths(2).Month) %>,
                            <%# GetBorrowTypeSum(Item.Id, startAt.AddMonths(3).Month) %>,
                            <%# GetBorrowTypeSum(Item.Id, startAt.AddMonths(4).Month) %>,
                            <%# GetBorrowTypeSum(Item.Id, startAt.AddMonths(5).Month) %>
                        ]
                    },
                </ItemTemplate>
            </asp:Repeater>
           {
               name: bidTitle[bidTitle.length - 1], type: 'line', data: [
                   <% =receiveList.Where(item => item.CreateAt.Month == startAt.Month).Sum(item => item.ShouldRepayPrincipal) %>,
                   <% =receiveList.Where(item => item.CreateAt.Month == startAt.AddMonths(1).Month).Sum(item => item.ShouldRepayPrincipal) %>,
                   <% =receiveList.Where(item => item.CreateAt.Month == startAt.AddMonths(2).Month).Sum(item => item.ShouldRepayPrincipal) %>,
                   <% =receiveList.Where(item => item.CreateAt.Month == startAt.AddMonths(3).Month).Sum(item => item.ShouldRepayPrincipal) %>,
                   <% =receiveList.Where(item => item.CreateAt.Month == startAt.AddMonths(4).Month).Sum(item => item.ShouldRepayPrincipal) %>,
                   <% =receiveList.Where(item => item.CreateAt.Month == startAt.AddMonths(5).Month).Sum(item => item.ShouldRepayPrincipal) %>
               ]
           }
        ];

        charts.line('js-interest', interestTitle, xAxisData, interestData);
        charts.line('js-bid', bidTitle, xAxisData, bidData);
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server">
</asp:Content>
