<div style="width: 100%; height: 40px;">
    <h3 style="float: left; width: 100px;">商品信息</h3>

    <?php if (in_array($order_info['status'], [1, 2, 3, 4])) { ?>
        <button type="button" class="btn btn-success changeBtn edit-item">编辑</button>
    <?php } ?> 
</div>

 <div class="row-fluid table-responsive">
    <table class="table table-hover text-nowrap">
        <thead>
            <tr class="caption">
                <th>序号</th>
                <?php if ($order_info['order_goods_type'] == 2) { ?>
                    <th>商品ID</th>
                    <th>商品名</th>
                    <th>型号</th>
                <?php } else { ?>
                    <th>商品ID</th>
                    <th>商品名</th>
                <?php } ?>
                
                <th>制造商</th>

                <?php if ($order_info['order_goods_type'] == 1) { ?>
                    <th>标准品牌</th>
                    <th>供应商</th>
                <?php } ?>

                <!-- ERP或京东订单 -->
                <?php if (in_array($order_info['order_type'], [2, 3])) { ?>
                    <th>采购数量</th>
                    <th>采购单价</th>
                <?php } elseif ($username != 'vpadmin@ichunt.com') { ?>
                    <?php if ($order_info['order_goods_type'] == 2) { ?>
                        <th>购买数量</th>
                        <th>购买时单价</th>
                    <?php } else { ?>
                        <th>采购数量</th>
                        <th>采购单价</th>
                    <?php } ?>
                    <th>均摊后单价</th>
                <?php } else { ?>
                    <th>商品数量</th>
                    <th>商品单价</th>
                <?php } ?>
                
                <th>小计</th>
                <th>费用</th>
                <th>折扣</th>
                <th>合计</th>
                <th>货期</th>
                
                <?php if ($order_info['order_goods_type'] == 1) { ?>
                    <th>采购员</th>
                <?php } ?>

                <th>批次</th>

                <?php if ($order_info['order_goods_type'] == 1) { ?>
                    <th>生产跟踪</th>
                <?php } ?>
                
                <th>备注</th>     
                <th>状态</th>
            </tr>
        </thead>
        <tbody>
        <?php if (!empty($order_items_info)) { ?>
            <?php foreach ($order_items_info as $key => $v) { ?>
                <tr> 
                    <td><?= $key+1 ?></td>
                    <?php if ($order_info['order_goods_type'] == 2) { ?>
                        <td><?= $v['goods_id'] ?></td>
                        <td><a href="<?= Config('website.main_url').'item/'.$v['goods_id'].'.html?ptag=order' ?>" target="_blank"><?= $v['goods_name'] ?></a></td>
                        <td><?=  App\Http\Controllers\getGoodsName($v['goods_id'])  ?></td>
                    <?php } else { ?>
                        <td><?= $v['goods_id'] ?></td>
                        <td><a href="<?= Config('website.main_url').'goods_'.$v['goods_id'].'.html?ptag=order' ?>" target="_blank"><?= $v['goods_name'] ?></a></td>
                    <?php } ?>
                    
                    <td><?= $v['brand_name'] ?></td>
                    <?php if ($order_info['order_goods_type'] == 1) { ?>
                        <td><?= $v['standard_brand_name'] ?></td>
                        <td><?= $v['supplier_name'] ?></td>
                    <?php } ?>
                
                    <td id="goods_number_<?= $v['rec_id'] ?>"><?= $v['goods_number'] ?></td>
                    <td>
                        <span id="<?= $v['rec_id'] ?>"><?= $v['goods_price'] ?></span>
                    </td>
                    
                    <?php if (in_array($order_info['order_type'], [2, 3])) { ?>
                        <td><?=  $v['goods_amount_format']  ?></td>
                    <?php } elseif ($username != 'vpadmin@ichunt.com') { ?>
                        <td><?= $v['single_pre_price_format'] ?></td>
                        <td><?= $v['goods_amount_format'] ?></td>
                    <?php } else { ?>
                        <td><?=  $v['goods_amount_format']  ?></td>
                    <?php } ?>

                    <td><?= $v['extra_price'] ?></td>
                    <td><?= $v['goods_discount_amount'] ?></td>
                    <td><?=  number_format($v['goods_amount'] + $v['extra_price'] - $v['goods_discount_amount'], 2, '.', '')  ?></td>
                    <td><?= $v['delivery_time'] ?></td>

                    <?php if ($order_info['order_goods_type'] == 1) { ?>
                        <td> <div class="buyerName">
                            <?php
                                echo !empty($v['buyerName'])?$v['buyerName']:'';
                            ?>
                        </div>
                          
                        </td>
                    <?php } ?>

                    <td  class="batch"><?= !empty($v['batch']) ? $v['batch'] : ''; ?> </td>

                    <?php if ($order_info['order_goods_type'] == 1) { ?>
                        <td><a class="order-track" data-rid="<?= $v['rec_id'] ?>"><?=  App\Http\Controllers\getLastTrack($v['rec_id'])  ?></a></td>
                    <?php } ?>

                    <td><?= !empty($v['remarks']) ? $v['remarks'] : '' ?></td>

                    <td><?= $v['status'] == 1 ? '正常' : '<i class="error">已关闭</i>' ?></td>
                </tr>
            <?php } ?>
        <?php } ?>
        </tbody>
        <tfoot>
            <?php if ($order_info['order_remark']) { ?>
                <tr>
                    <td>订单备注信息:</td>
                    <td colspan="18"><?= $order_info['order_remark'] ?></td>
                </tr>
            <?php } ?>

            <?php if ($order_temp_info['kefu_remark']) { ?>
                <tr>
                    <td>客服备注信息:</td>
                    <td colspan="18"><?= $order_temp_info['kefu_remark'] ?></td>
                </tr>
            <?php } ?>

            <?php if ($order_info['order_goods_type'] == 2 && $order_temp_info['business_type'] == 1) { ?>
                <tr>
                    <td>项目需求描述:</td>
                    <td colspan="18"><?= $order_temp_info['sample_demand_desc'] ?></td>
                </tr>
            <?php } ?>
        </tfoot>
    </table>

    <!-- 退款已处理 -->
    <?php if ($order_refund_info['status'] == 10 && $order_price_info['refund_price'] != 0) { ?>
        <hr>
        <table  class="table">
            <thead>
                <tr class="caption">
                    <th>退款型号</th>
                    <th>退款数量</th>
                    <th>价格</th>
                    <th>小计</th>
                </tr>
            </thead>
            
            <tbody>
                <?php foreach ($order_refund_items as $k=>$v) { ?>
                    <tr>
                        <td><?= $v['goods_name'] ?></td>
                        <td><?= $v['refund_num'] ?></td>
                        <td><?= $currency . $v['single_pre_price'] ?></td>
                        <td><?= $currency . number_format($v['refund_num'] * $v['single_pre_price'], 4) ?></td>
                    </tr> 
                <?php } ?>
                <tr>
                    <td>手动差价</td>
                    <td></td>
                    <td></td>
                    <td><?= '-' . $order_refund_info['price_fall'] ?></td>
                </tr>
            </tbody>
        </table> 
    <?php } ?>
</div>

<div class="order-total" style="margin-top: 30px;">
    <div>
        <table>
            <tr>
                <td>商品总额:</td>
                <td><?= $currency ?><span id="order-total" class="amount"><?= $order_price_info['goods_price'] ?></span></td>
            </tr>

            <?php if ($order_price_info['new_client_price'] != 0) { ?>
            <tr>
                <?php if ($order_info['order_type_extend'] == 1) { ?>
                    <td>团购优惠:</td>
                <?php } else { ?>
                    <td>新客价优惠:</td>
                <?php } ?>
                <td><span id="order-total" class="amount"><?= $order_price_info['new_client_price'] ?></span></td>
            </tr>
            <?php } ?>

            <?php if (isset($order_price_info['ext_price'])) { ?>
                <tr>
                    <td>附加款:</td>
                    <td class="edit-parent-td">
                        <?= $currency ?><span id="other_money"><?= $order_price_info['ext_price'] ?></span>
                    </td>
                </tr>
            <?php } ?>

            <?php if ($order_price_info['shipping_price'] != 0) { ?>
                <tr>
                    <td>快递费用:</td>
                    <td class="edit-parent-td">
                        <?= $currency ?><span id="other_money"><?= $order_price_info['shipping_price'] ?></span>
                    </td>
                </tr>
            <?php } ?> 

            <?php if ($order_price_info['discount_amount'] != 0) { ?>
                <tr>
                    <td>优惠金额:</td>
                    <td class="edit-parent-td">
                        <span id="other_money"><?= $order_price_info['discount_amount'] ?></span>
                    </td>
                </tr>
            <?php } ?> 

            <?php if (isset($order_price_info['refund_price']) && $order_price_info['refund_price'] != 0) { ?>
                <tr>
                    <td>退款金额:</td>
                    <td class="edit-parent-td">
                        <?= $currency ?><span id="other_money"><?= $order_price_info['refund_price'] ?></span>
                    </td>
                </tr>
            <?php } ?>

            <tr>
                <td>订单总额:</td>
                <td>
                    <span style="color:red;font-size:20px">
                        <?= $currency ?><span class="amount"><?= $order_info['order_amount'] ?></span>
                    </span>
                </td>
            </tr>

            <?php if (isset($order_price_info['pay_preferential']) && $order_price_info['pay_preferential'] != 0) { ?>
                <tr>
                    <td>支付优惠:</td>
                    <td class="edit-parent-td">
                        <span id="other_money"><?= $order_price_info['pay_preferential'] ?></span>
                    </td>
                </tr>
                <tr>
                    <td>实际支付金额:</td>
                    <td class="edit-parent-td">
                        <span style="color:red;font-size:20px">
                            <?= $currency ?><span class="amount"><?= $order_info['order_amount'] + $order_price_info['pay_preferential'] ?></span>
                        </span>
                    </td>
                </tr>
            <?php } ?>
        </table>
    </div>

    <!-- 非内部采购下单显示付款地址 -->
    <?php if (isset($order_temp_info) && $order_temp_info['order_type'] != 3 && $order_info['status'] < 4) { ?>
        <p>客户付款地址:<?=  Config('website.pay_url').$order_info['order_id']  ?></p>
    <?php } ?>                
</div>