<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->

<!--条件搜索-->
<div class="inner-content">
    <form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)">
        <div nz-row>
            <div nz-col nzSpan="8" *ngIf="roleType === 1">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">区域公司</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select [nzPlaceHolder]="'请选择区域公司...'" nzShowSearch nzAllowClear [formControlName]="'companyId'">
                            <nz-option *ngFor="let item of companyData" nzValue="{{item.id}}" nzLabel="{{item.name}}"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">充值内容</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <input nz-input placeholder="请输入充值内容..." [formControlName]="'rechargeContent'"/>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">订单号</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <input nz-input placeholder="请输入订单号..." [formControlName]="'orderNo'"/>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">支付状态</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear formControlName="payStatus" nzPlaceHolder="请选择订单状态">
                            <nz-option nzLabel="待支付" nzValue="101"></nz-option>
                            <nz-option nzLabel="已支付" nzValue="102"></nz-option>
                            <nz-option nzLabel="已完成" nzValue="100"></nz-option>
                            <nz-option nzLabel="已取消" nzValue="104"></nz-option>
                            <nz-option nzLabel="已退款" nzValue="105"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">充值状态</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear formControlName="rechargeStatus" nzPlaceHolder="请选择充值状态">
                            <nz-option nzLabel="充值中" nzValue="201"></nz-option>
                            <nz-option nzLabel="充值成功" nzValue="202"></nz-option>
                            <nz-option nzLabel="充值失败" nzValue="203"></nz-option>
                            <nz-option nzLabel="未充值" nzValue="204"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>

            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">运营商类型</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear formControlName="operatorType" nzPlaceHolder="请选择运营商类型">
                            <nz-option nzLabel="电信运营商" nzValue="1"></nz-option>
                            <nz-option nzLabel="移动运营商" nzValue="2"></nz-option>
                            <nz-option nzLabel="联通运营商" nzValue="3"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">充值类型</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear formControlName="rechargeType" nzPlaceHolder="请选择充值类型">
                            <nz-option nzLabel="快充" nzValue="1"></nz-option>
                            <nz-option nzLabel="慢充" nzValue="2"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">查询超时订单</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear formControlName="whetherTimeOut" nzPlaceHolder="请选择是否查询">
                            <nz-option nzLabel="查询超时" [nzValue]="true"></nz-option>
                            <nz-option nzLabel="不查询" [nzValue]="false"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>

            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">支付方式</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear formControlName="payType" nzPlaceHolder="支付方式">
                            <nz-option nzLabel="微信支付" nzValue="2"></nz-option>
                            <nz-option nzLabel="工会卡支付" nzValue="3"></nz-option>
                            <nz-option nzLabel="银联支付" nzValue="4"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>

            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">工会卡卡号</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <input nz-input placeholder="请输入工会卡卡号..." [formControlName]="'laborUnionCard'"/>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">支付时间</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-range-picker [nzShowTime]="{ nzFormat: 'HH:mm' }"
                                         formControlName="payTime"></nz-range-picker>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">创建时间</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-range-picker [nzShowTime]="{ nzFormat: 'HH:mm' }"
                                         formControlName="createTime"></nz-range-picker>
                    </nz-form-control>
                </nz-form-item>
            </div>
        </div>
        <div nz-row>
            <div nz-col nzSpan="24" class="search-button">
                <button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>搜索</button>
                <button nz-button nzType="default" (click)="resetForm()"><i nz-icon nzType="reload"
                                                                            nzTheme="outline"></i>重置
                </button>
            </div>
        </div>
    </form>
</div>

<div class="inner-content">
    <span>共计 {{total}} 条数据</span>
    <div class="operating-button">
        <nz-upload
                [nzAccept]="'.xls,.xlsx'"
                nzAction="{{WEB_SERVE_URL}}outRechargeOrder/importRechargeOrder"
                [nzHeaders]="{ authorization: 'authorization-text' }"
                (nzChange)="handleChange($event)"
                [nzShowUploadList]="false"
        >
            <button  nz-button nzType="primary" ><i nz-icon nzType="import" nzTheme="outline"></i>导入充值订单</button>
        </nz-upload>
        <button nz-button nzType="primary" class="right-btn" (click)="downloadTemplate(searchForm.value)" ><i nz-icon nzType="download" nzTheme="outline"></i>导出订单</button>
    </div>
    <nz-table
            class="table"
            #ajaxTable
            nzShowSizeChanger
            [nzFrontPagination]="false"
            [nzData]="requestData"
            [nzLoading]="loading"
            [nzTotal]="total"
            [(nzPageIndex)]="pageNum"
            [(nzPageSize)]="pageSize"
            [nzScroll]="{ x: '1200px' }"
            (nzPageIndexChange)="getRequest(false , searchForm.value)"
            (nzPageSizeChange)="getRequest(false , searchForm.value)">
        <thead nzSingleSort>
        <tr>
            <th nzWidth="80px">编号</th>
            <th nzWidth="100px">充值类型</th>
            <th nzWidth="120px">运营商</th>
            <th nzWidth="180px">充值内容</th>
            <th nzWidth="100px">充值金额</th>
            <th nzWidth="180px">充值订单号</th>
            <th nzWidth="120px">客户名称</th>
            <th nzWidth="140px">生成时间</th>
            <th nzWidth="140px">支付时间</th>
            <th nzWidth="100px" nzRight>支付方式</th>
            <th nzWidth="90px" nzRight>充值状态</th>
            <th nzWidth="100px" nzRight>支付状态</th>
            <th nzWidth="180px" nzRight>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of ajaxTable.data; let i = index">
            <td>{{i + 1}}</td>
            <td>{{data.type == 1 ? '话费充值' : ''}}</td>
            <td>{{data.operatorName}}</td>
            <td>{{data.rechargeContent}} | {{data.rechargeType  == 1 ? '快充' : '慢充'}}</td>
            <td>¥{{data.rechargePrice}}</td>
            <td>{{data.orderNo}}</td>
            <td>{{data.userName == null ? '暂无' : data.userName}}</td>
            <td>{{data.createTimed | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
            <td>{{data.payTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
            <td nzRight>{{data.payType  | rechargePayType}}</td>
            <td nzRight>{{data.rechargeStatus | rechargeStatus}}</td>
            <td nzRight>{{data.payStatus | payStatus}}</td>
            <td nzRight class="table-td-operation">
                <a (click)="getDetail(data.id)">详情</a>
                <nz-divider nzType="vertical"></nz-divider>
                <a (click)="getChildOrder(data.id)">查看子订单</a>
            </td>
        </tbody>
    </nz-table>
</div>

<nz-modal [(nzVisible)]="isVisible" nzTitle="订单详情" nzWidth="1200" (nzOnOk)="isVisible = false"
          (nzOnCancel)="isVisible = false">
    <nz-descriptions nzBordered [nzColumn]="{ xxl: 4, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }">
        <nz-descriptions-item nzTitle="订单号">{{data['orderNo']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="充值类型">{{data['type'] == 1 ? '话费充值' : ''}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="运营商">{{data['operatorName']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="充值内容">{{data['rechargeContent']}} ｜ {{data['rechargeType']  == 1 ? '快充' : '慢充'}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="充值金额">¥{{data['rechargePrice']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="应付金额">¥{{data['payPrice']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="积分抵扣金额">¥{{data['integralDeductionPrice'] == null ? '0' : data['integralDeductionPrice']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="优惠券抵扣金额">¥{{data['discountDeductionPrice'] == null ? '0' : data['discountDeductionPrice']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="实付金额">¥{{data['payRealPrice']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="退款金额" *ngIf="data['refundFee'] != null">¥{{data['refundFee']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="优惠券名称" *ngIf="data['memDiscountName'] != null">{{data['memDiscountName']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="支付流水号">{{data['paySerialNo']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="生成时间">{{data['createTimed'] | date: 'yyyy-MM-dd HH:mm:ss'}}</nz-descriptions-item>
        <nz-descriptions-item *ngIf="data['cancelTime'] != null" nzTitle="取消时间">{{data['cancelTime'] | date: 'yyyy-MM-dd HH:mm:ss'}}</nz-descriptions-item>
        <nz-descriptions-item *ngIf="data['finishTime'] != null" nzTitle="完成时间">{{data['finishTime'] | date: 'yyyy-MM-dd HH:mm:ss'}}</nz-descriptions-item>
        <nz-descriptions-item *ngIf="data['payTime'] != null" nzTitle="支付时间">{{data['payTime'] | date: 'yyyy-MM-dd HH:mm:ss'}}</nz-descriptions-item>
        <nz-descriptions-item *ngIf="data['refundTime'] != null" nzTitle="退款时间">{{data['refundTime'] | date: 'yyyy-MM-dd HH:mm:ss'}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="支付类型">{{data['payType'] | rechargePayType}}</nz-descriptions-item>
        <nz-descriptions-item *ngIf="data['laborUnionCard'] != null" nzTitle="工会卡号">{{data['laborUnionCard']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="充值状态">{{data['rechargeStatus'] | rechargeStatus}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="支付状态">{{data['payStatus'] | payStatus}}</nz-descriptions-item>
    </nz-descriptions>
</nz-modal>


<nz-modal [(nzVisible)]="isVisibleChild" nzWidth="700" nzTitle="子订单记录" (nzOnCancel)="isVisibleChild = false" (nzOnOk)="isVisibleChild = false">
    <nz-table #basicTable [nzData]="childData">
        <thead>
        <tr>
            <th>订单号</th>
            <th>充值平台</th>
            <th>充值状态</th>
            <th>创建时间</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of basicTable.data">
            <td>{{data.orderNo}}</td>
            <td>{{data.rechargePlatform | platform}}</td>
            <td>{{data.status | chlidRechargeStatus}}</td>
            <td>{{data['createTime'] | date: 'yyyy-MM-dd HH:mm'}}</td>
        </tr>
        </tbody>
    </nz-table>
</nz-modal>
<nz-modal [(nzVisible)]="errorStudentVisible" nzTitle="导入失败数据" (nzOnCancel)="errorStudentVisible = false" nzWidth="1200px" [nzFooter]="null">
    <nz-table #errorStudentTable [nzData]="importErrorStudentArray"  [nzScroll]="{ x: '1200px' }">
        <thead>
        <tr>
            <th nzWidth="80px">序号</th>
            <th nzWidth="150px">订单号</th>
            <th nzWidth="150px">用户昵称</th>
            <th nzWidth="150px">用户联系方式</th>
            <th nzWidth="150px">充值类型</th>
            <th nzWidth="150px">充值内容</th>
            <th nzWidth="150px">支付方式</th>
            <th nzWidth="150px">卡号</th>
            <th nzWidth="150px">订单金额</th>
            <th nzWidth="150px">应付金额</th>
            <th nzWidth="150px">订单状态</th>
            <th nzWidth="150px">支付时间</th>
            <th nzWidth="300px">原因</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of errorStudentTable.data;let i = index">
            <td>{{ i + 1}}</td>
            <td>{{data.orderNo}}</td>
            <td>{{data.userName}}</td>
            <td>{{data.userPhone}}</td>
            <td>{{data.rechargeModelName}}</td>
            <td>{{data.rechargeContent}}</td>
            <td>{{data.payTypeName}}</td>
            <td>{{data.cardNo}}</td>
            <td>{{data.orderPrice}}</td>
            <td>{{data.payRealPrice}}</td>
            <td>{{data.statusName}}</td>
            <td>{{data.payTime}}</td>
            <td>{{data.errorMessage}}</td>
        </tr>
        </tbody>
    </nz-table>
</nz-modal>
