<!-- start 面包屑 -->
<nz-breadcrumb>
    <nz-breadcrumb-item>
        首页
    </nz-breadcrumb-item>
</nz-breadcrumb>
<!-- end 面包屑 -->

<!--条件搜索-->
<div class="inner-content" *ngIf="adminInfoObject['merchantStore'] != null && adminInfoObject['merchantStore']['type'] == 1">
    <!--<div *ngIf="adminInfoObject['merchantStore']['prestoreType'] == 1" style="width: 100%;text-align: center;">
        <nz-row [nzGutter]="16">
            <nz-col [nzSpan]="24">
                <nz-statistic [nzValue]="'￥' + balanceData['amounts']" [nzTitle]="'预存账户余额'" [nzSuffix]="suffixTpl"></nz-statistic>
                <ng-template #suffixTpl><a (click)="isVisibleOil = true" style="font-size: 13px;">记录</a></ng-template>
            </nz-col>
        </nz-row>
    </div>
    <br/><br/><br/>-->
    <nz-card nzTitle="历史加油订单">
        <nz-row [nzGutter]="16">
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.history.totalPrice ? gasCountData.history.totalPrice : 0" [nzTitle]="'订单总金额'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.history.totalCount ? gasCountData.history.totalCount : 0" [nzTitle]="'订单笔数'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.history.incomePrice ? gasCountData.history.incomePrice : 0" [nzTitle]="'加油金额'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.history.incomeCount ? gasCountData.history.incomeCount : 0" [nzTitle]="'加油笔数'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.history.refundPrice ? gasCountData.history.refundPrice : 0" [nzTitle]="'退款金额'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.history.refundCount ? gasCountData.history.refundCount : 0" [nzTitle]="'退款笔数'"></nz-statistic>
            </nz-col>
        </nz-row>
    </nz-card>
    <br/><br/><br/>
    <nz-card nzTitle="今日加油订单">
        <nz-row [nzGutter]="16">
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.today.totalPrice ? gasCountData.today.totalPrice : 0" [nzTitle]="'订单总金额'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.today.totalCount ? gasCountData.today.totalCount : 0" [nzTitle]="'订单笔数'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.today.incomePrice ? gasCountData.today.incomePrice : 0" [nzTitle]="'加油金额'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.today.incomeCount ? gasCountData.today.incomeCount : 0" [nzTitle]="'加油笔数'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.today.refundPrice ? gasCountData.today.refundPrice : 0" [nzTitle]="'退款金额'"></nz-statistic>
            </nz-col>
            <nz-col [nzSpan]="4">
                <nz-statistic [nzValue]="gasCountData.today.refundCount ? gasCountData.today.refundCount : 0" [nzTitle]="'退款笔数'"></nz-statistic>
            </nz-col>
        </nz-row>
    </nz-card>

</div>

<!--条件搜索-->
<div class="inner-content" *ngIf="roleType == 2">
    <div style="width: 100%;text-align: center;">
        <nz-row [nzGutter]="16">
            <nz-col [nzSpan]="24">
                <nz-statistic [nzValue]="'￥' + merGasCount['amount']" [nzTitle]="'预存账户余额'"></nz-statistic>
            </nz-col>
        </nz-row>
    </div>
    <br/><br/><br/>
    <nz-card nzTitle="油站加油金额">
        <nz-table #basicTable [nzData]="merGasCount.storeList" [nzHideOnSinglePage]="true">
            <thead>
            <tr>
                <th>序号</th>
                <th>油站名称</th>
                <th>油站地址</th>
                <th>油站加油总额</th>
            </tr>
            </thead>
            <tbody>
            <tr *ngFor="let data of basicTable.data;let i = index;">
                <td>{{ i + 1 }}</td>
                <td>{{ data.store_name }}</td>
                <td>{{ data.address }}</td>
                <td>{{ '￥' + data.countPrice }}</td>
            </tr>
            </tbody>
        </nz-table>
    </nz-card>
</div>

<!--渠道公司-->
<div class="inner-content" *ngIf="roleType == 7">
    <div  nz-row >
        <button nz-button nzType="primary" (click)="isVisibleAdd = true">新增预充值余额</button>
    </div>

    <div nz-row  style="margin-top: 20px;" [nzGutter]="16">
        <div nz-col nzSpan="8">
            <nz-card nzHoverable [nzLoading]="loading" (click)="isVisible = true">
                <h3>汇联通预充值账号</h3>
                <p>余额:{{(balance - balanceData['payRealPrice']).toFixed(2)}}</p>
                <p>订单数量:{{balanceData['count']}}</p>
                <p>支付总额:{{balanceData['payRealPrice'] == null ? '0': balanceData['payRealPrice']}}</p>
            </nz-card>
        </div>
        <div nz-col nzSpan="8">
            <nz-card nzHoverable [nzLoading]="loading"  [routerLink]="['/admin/order/order-list']">
                <h3>中石化订单</h3>
                <p>订单数量:{{orderData['count']}}</p>
                <p>订单总额:{{orderData['orderPrice'] == null ? '0': orderData['orderPrice']}}</p>
                <p>支付总额:{{orderData['payRealPrice'] == null ? '0': orderData['payRealPrice']}}</p>
            </nz-card>
        </div>
        <div nz-col nzSpan="8">
            <nz-card nzHoverable [nzLoading]="loading"   [routerLink]="['/admin/order/order-h-list']">
                <h3>话费订单</h3>
                <p>订单数量:{{rechargeData['count']}}</p>
                <p>订单总额:{{rechargeData['orderPrice'] == null ? '0': rechargeData['orderPrice']}}</p>
                <p>支付总额:{{rechargeData['payRealPrice'] == null ? '0': rechargeData['payRealPrice']}}</p>
            </nz-card>
        </div>
    </div>
</div>
<!--运营角色-->
<div class="inner-content"  *ngIf="roleType == 1">
    <div nz-row  style="margin-top: 20px;" [nzGutter]="16">
        <div nz-col  nzSpan="8" *ngFor="let item of tyBalance" class="row-bottom">
            <nz-card nzHoverable [nzLoading]="loading" [nzTitle]="item['energyType'] | energyType">
                <h3>{{item['accountBalance']}}</h3>
            </nz-card>
        </div>
        <div nz-col nzSpan="8" class="row-bottom">
            <nz-card nzHoverable [nzLoading]="loading" [nzTitle]="'注册总人数'">
                <h3>{{countData['registrantNum']}}</h3>
            </nz-card>
        </div>
        <div nz-col nzSpan="8" class="row-bottom">
            <nz-card nzHoverable [nzLoading]="loading" [nzTitle]="'总交易金额'">
                <h3>{{countData['transactionNum']}}</h3>
            </nz-card>
        </div>
        <div nz-col nzSpan="8" class="row-bottom">
            <nz-card nzHoverable [nzLoading]="loading" [nzTitle]="'总交易订单数量'">
                <h3>{{countData['transactionOrder']}}</h3>
            </nz-card>
        </div>
        <div nz-col nzSpan="8" class="row-bottom">
            <nz-card nzHoverable [nzLoading]="loading" [nzTitle]="'当天交易金额'">
                <h3>{{countData['transactionToday']}}</h3>
            </nz-card>
        </div>
        <div nz-col nzSpan="8" class="row-bottom">
            <nz-card nzHoverable [nzLoading]="loading" [nzTitle]="'当天交易订单'">
                <h3>{{countData['transactionOrderToday']}}</h3>
            </nz-card>
        </div>
    </div>
    <div style="margin-top: 20px" echarts [options]="data"></div>
</div>

<nz-modal [(nzVisible)]="isVisible" nzWidth="1200" nzTitle="订单列表" (nzOnCancel)="isVisible = false" (nzOnOk)="isVisible = false">

    <div nz-row>
        <button nz-button nzType="primary"  (click)="downloadTemplate()">导出汇联通预充值数据</button>
    </div>

    <nz-table #basicTable [nzData]="listOfData" style="margin-top: 20px;" [nzScroll]="{ x: '1200px' }">
        <thead>
        <tr>
            <th nzWidth="50px">编号</th>
            <th nzWidth="180px">商品名称</th>
            <th nzWidth="180px">订单来源</th>
            <th nzWidth="180px">订单类型</th>
            <th nzWidth="180px">订单号</th>
            <th nzWidth="180px">支付流水号</th>
            <th nzWidth="120px">客户名称</th>
            <th nzWidth="130px">客户电话</th>
            <th nzWidth="110px">支付模式</th>
            <th nzWidth="100px">支付方式</th>
            <th nzWidth="100px">支付金额</th>
            <th nzWidth="140px">生成时间</th>
            <th nzWidth="140px">支付时间</th>
            <th nzWidth="140px">取消时间</th>
            <th nzRight nzWidth="100px">状态</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of basicTable.data; let i = index">
            <td>{{i+1}}</td>
            <td>{{data.goodsName}}</td>
            <td>{{data.giveawayType}}</td>
            <td>{{data.goodsType}}</td>
            <td>{{data.orderNo}}</td>
            <td>{{data.paySerialNo}}</td>
            <td>{{data.memName == null ? '暂无': data.memName}}</td>
            <td>{{data.memPhone == null ? '暂无': data.memPhone}}</td>
            <td>{{data.payModel}}</td>
            <td>{{data.payType}}</td>
            <td>{{data.payPrice}}</td>
            <td>{{data.createTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
            <td>{{data.payTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
            <td>{{data.cancelTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
            <td nzRight>{{data.orderStatus}}</td>
        </tr>
        </tbody>
    </nz-table>
</nz-modal>

<nz-modal [(nzVisible)]="isVisibleAdd" nzTitle="新增预充值余额" (nzOnCancel)="isVisibleAdd = false" (nzOnOk)="handleOk()">
  <div nz-row>
      <div nz-col nzSpan="18">
          <nz-form-item>
              <nz-form-label [nzSpan]="6">充值金额</nz-form-label>
              <nz-form-control [nzSpan]="16">
                  <input nz-input placeholder="请输入充值金额..." [(ngModel)]="price" />
              </nz-form-control>
          </nz-form-item>
      </div>
  </div>
</nz-modal>

<nz-modal [(nzVisible)]="isVisibleOil" nzWidth="900" nzTitle="预充值账户记录" [nzBodyStyle]="{ padding: '15px', height: '600px'}" (nzOnCancel)="isVisibleOil = false" [nzFooter]="null">
    <nz-table #RecordList [nzData]="recordList" [nzScroll]="{ y: '450px', x : '900px' }">
        <thead>
        <tr>
            <th nzWidth="80px">编号</th>
            <th nzWidth="80px">类型</th>
            <th nzWidth="100px">交易金额</th>
            <th nzWidth="110px">变更前金额</th>
            <th nzWidth="110px">变更后金额</th>
            <th nzWidth="110px">来源类型</th>
            <th nzWidth="300px">内容</th>
            <th nzWidth="130px">操作时间</th>
            <th nzWidth="150px">操作人</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of RecordList.data; let i = index">
            <td>{{i+1}}</td>
            <td>{{data.type == 1 ? '进账': '出账'}}</td>
            <td>{{'￥' + data.amount}}</td>
            <td>{{'￥' + data.beforeAmount}}</td>
            <td>{{'￥' + data.afterAmount}}</td>
            <td>
                <span *ngIf="data.sourceType == 1">金额充值</span>
                <span *ngIf="data.sourceType == 2">订单消费</span>
                <span *ngIf="data.sourceType == 3">订单退款</span>
            <td>{{data.sourceContent}}</td>
            <td>{{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td>
            <td>{{data.opUserName}}</td>
        </tr>
        </tbody>
    </nz-table>
</nz-modal>
