<div class="wrapper">
    @include('layouts.header')
    
	<div class="page-content">
        <div class="tabs-box table-responsive">
            <table class="table table-bordered order-express">
                <tr>
                    <th width="10%">订单编号</th>
                    <td>{{$refund->order_sn}} <a href="/details/{{$refund->order_goods_type == 1 ? $refund->order_id : $refund->order_id.'?tags=self'}}" target="_blank" style="margin-left: 20px;">查看订单</a></td>
                </tr>
                <tr>
                    <th>用户账号</th>
                    <td>{{ App\Http\Controllers\getAccountName($refund->user_id) }}</td>
                </tr>
                <tr>
                    <th>申请时间</th>
                    <td>{{$refund->create_time ? date('Y-m-d H:i:s', $refund->create_time) : ''}}</td>
                </tr>
                <tr>
                    <th>申请状态</th>
                    <td>
                        <?php 
                            switch ($refund->status) {
                                case -1: echo '已拒绝'; break;
                                case 1: echo '待处理'; break;
                                case 10: echo '已处理'; break;
                            }
                        ?>
                    </td>
                </tr>
                
                <?php 
                    $currencySign = $refund->currency == 1 ? '¥' : '$';
                ?> 

                <tr>
                    <th>订单金额</th>
                    <td>{{$currencySign}} {{ App\Http\Controllers\getOrderAmount($refund->order_id) }}</td>
                </tr>
                <tr>
                    <th>退款金额</th>
                    <td>{{$currencySign.$refund->pay_amount}}</td>
                </tr>

                @if ($refund->order_goods_type == 1)
                <tr>
                    <th>手动差价</th>
                    <td>{{$currencySign.$refund->price_fall}}</td>
                </tr>
                <tr>
                    <th>最终退款总额</th>
                    <td>{{$currencySign.($refund->pay_amount - $refund->price_fall)}}</td>
                </tr>
                @endif

                <tr>
                    <th>退款原因</th>
                    <td>{{$refund->refund_reason}}</td>
                </tr>
                
                <tr>
                    <th>退款型号</th>
                    <td>
                        @if ($refundItems)
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>退款型号</th>
                                    <th>退款数量</th>
                                    <th>价格</th>
                                    <th>小计</th>
                                </tr>
                            </thead>

                            <tbody>
                                @foreach ($refundItems as $k=>$v)
                                    <tr>
                                        <td>{{$v->goods_name}}</td>
                                        <td>{{$v->refund_num}}</td>
                                        <td>{{$v->single_pre_price}}</td>
                                        <td>{{number_format($v->refund_num * $v->single_pre_price, 4)}}</td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                        @endif
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>