#@layout()

#define script()
<script>

    function deliver() {
        openlayer('发货','#(CPATH)/admin/order/deliver/#(order.id)');
    }

    function invoice() {
        openlayer('开具发票','#(CPATH)/admin/order/invoice/#(order.id)');
    }

    function remark() {
        openlayer('备注信息','#(CPATH)/admin/order/remark/#(order.id)');
    }

    function updatePaystatus() {
        openlayer('手动入账','#(CPATH)/admin/order/updatePaystatus/#(order.id)');
    }

    function updatePrice() {
        openlayer('修改价格','#(CPATH)/admin/order/updatePrice/#(order.id)');
    }
    
    function openlayer(title,url) {
        layer.open({
            type: 2,
            title: title,
            anim: 2,
            shadeClose: true,
            shade: 0.5,
            area: ['70%', '90%'],
            content: url,
            end: function () {

            }
        });
    }

</script>
#end

#define css()
<style>
    .page-header{
        margin: 10px 0 20px;
    }
    .remark{
        width: 100%;
        height: 100px;
        background-color: #f5f5f5;
        text-align: center;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    address{
        margin-top: 10px;
        margin-bottom: 30px;
    }

</style>
#end

#define content()
<div class="content-wrapper" style="min-height: 1126px;">
    <section class="content-header">
        <h1>
            订单信息
            <small>订单号：##(order.ns ??)</small>
        </h1>
    </section>

    #if(order.buyer_msg)
    <div class="pad margin no-print">
        <div class="callout callout-info" style="margin-bottom: 0!important;">
            <h4><i class="fa fa-info"></i> 用户留言:</h4>
            #(order.buyer_msg)
        </div>
    </div>
    #end

    <!-- Main content -->
    <section class="invoice">
        <!-- title row -->
        <div class="row">
            <div class="col-xs-12">
                <h2 class="page-header">
                    <i class="fa fa-globe"></i> 订单信息.
                    <small class="pull-right">下单时间: #date(order.created)</small>
                </h2>
            </div>
            <!-- /.col -->
        </div>
        <!-- info row -->
        <div class="row invoice-info">
            <div class="col-sm-4 invoice-col">
                <strong>订单预览</strong>
                <address>
                    价格：#number(order.orderRealAmount ,'0.00') 元<br>
                    订单用户：<a href="#(CPATH)/admin/user/detail/#(orderUser.id ??)"> #(orderUser.nickname ??)</a><br>
                    支付状态：#(order.payStatusStr ??)<br>
                    物流状态：#(order.deliveryStatusStr ??)<br>
                    发票状态：#(order.invoiceStatusStr ??)
                </address>
            </div>
            <!-- /.col -->
            <div class="col-sm-4 invoice-col">
                <strong>收货信息</strong>
                <address>
                    收件人：#(order.delivery_addr_username ??)<br>
                    电话：#(order.delivery_addr_mobile ??)<br>
                    编码: #(order.delivery_addr_zipcode ??)<br>
                    地址：#(order.delivery_addr_province ??) #(order.delivery_addr_city ??) #(order.delivery_addr_district ??)<br>
                    #(order.delivery_addr_detail ??)
                </address>
            </div>
            <!-- /.col -->
            <div class="col-sm-4 invoice-col">
                <strong>备注信息</strong>
                <address>
                   <div class="remark">
                       #(order.remarks ?? '暂无备注信息')
                   </div>
                </address>
            </div>
            <!-- /.col -->
            <div class="col-sm-4 invoice-col">
                <strong>发票信息</strong>
                <address>
                    类型：#(invoice.type ??)<br>
                    抬头：#(invoice.title ??)<br>
                    内容：#(invoice.content ??)<br>
                    纳税人识别号：#(invoice.identity ??)
                </address>
            </div>
            <!-- /.col -->
            <div class="col-sm-4 invoice-col">
                <strong>优惠券</strong>
                <address>
                    优惠券：#(orderCoupon.title ??)<br>
                    优惠码：#(orderCoupon.code ??)<br>
                    优惠金额：#(order.coupon_amount ??)<br>
                    用户: <a href="#(CPATH)/admin/user/detail/#(orderCouponUser.id ??)" >#(orderCouponUser.nickname ??)</a>
                </address>
            </div>
            <!-- /.col -->
            <div class="col-sm-4 invoice-col">
<!--                <strong>分销情况</strong>-->
<!--                <address>-->
<!--                    分销用户：#(distUser.nickname ??)<br>-->
<!--                    分销金额：#(order.dist_amount ??)<br>-->
<!--                </address>-->
            </div>
            <!-- /.col -->



        </div>
        <!-- /.row -->

        <div class="row no-print">
            <div class="col-xs-2">
<!--                <a href="#" class="btn btn-default"><i class="fa fa-print"></i> 打印 </a>-->
            </div>
            <div class="col-xs-10"style="text-align: right">
                <button type="button" class="btn btn-success " onclick="updatePrice()">
                    <i class="fa fa-fw fa-money"></i> 修改价格
                </button>
                <button type="button" class="btn btn-success " onclick="updatePaystatus()">
                    <i class="fa fa-fw fa-anchor"></i> 手动入账
                </button>
                <button type="button" class="btn btn-primary " onclick="invoice()">
                    <i class="fa fa-fw fa-cc"></i> 开具发票
                </button>
                #if(order.isNotDeliveried())
                <button type="button" class="btn btn-primary " onclick="deliver()">
                    <i class="fa fa-fw fa-location-arrow"></i> 发货
                </button>
                #end
                <button type="button" class="btn btn-primary " onclick="remark()">
                    <i class="fa fa-fw fa-commenting"></i> 备注
                </button>
            </div>
        </div>
    </section>


    <!-- Main content -->
    <section class="invoice">
        <!-- title row -->
        <div class="row">
            <div class="col-xs-12">
                <h2 class="page-header">
                    <i class="fa fa-globe"></i> 商品信息.
                </h2>
            </div>
            <!-- /.col -->
        </div>


        <!-- Table row -->
        <div class="row">
            <div class="col-xs-12 table-responsive">
                <table class="table table-striped" id="tab">
                    <thead>
                    <tr>
                        <th style="text-align: center">商品</th>
                        <th style="text-align: center">数量</th>
                        <th style="text-align: center">单价</th>
                        <th style="text-align: center">总价</th>
                        <th style="text-align: center">分销用户</th>
                        <th style="text-align: center">分销收益</th>
                        <th style="text-align: center">操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    #for(item : orderItems)
                    <tr>
                        <td style="text-align: center">
                            #(item.product_title ??)
                            <div style="color: #9c9c9c">
                                #for(option : item.optionsMap)
                                    #(option.key ??) : #(option.value ??) #if(!(for.last))<br />#end
                                #end
                            </div>
                        </td>
                        <td style="width: 10%;text-align: center">
                            #(item.product_count ??)
                        </td>
                        <td style="width: 10%;text-align: center">
                            #(item.product_price ??)
                        </td>
                        <td style="width: 10%;text-align: center">
                            #(item.product_price * item.product_count ??)
                        </td>
                        <td style="width: 10%;text-align: center">
                           #if(item.distUser)
                            <a href="#(CPATH)/admin/user/detail/#(item.distUser.id ??)"> #(item.distUser.nickname ?? item.distUser.username)</a>
                           #else
                            --
                           #end
                        </td>
                        <td style="width: 10%;text-align: center">
                            #if(item.totalDistAmount)
                            #number(item.totalDistAmount,'0.00')
                            #else
                            --
                            #end
                        </td>
                        <td style="width: 10%;text-align: center">
                            <a href="#">编辑</a>
                        </td>
                    </tr>
                    #end

                    </tbody>
                </table>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>




    <!-- Main content -->
    <section class="invoice">
        <!-- title row -->
        <div class="row">
            <div class="col-xs-12">
                <h2 class="page-header">
                    <i class="fa fa-globe"></i> 物流信息.
                    #if(order.isNotDeliveried())(尚未发货)
                    #else
                    #(delivery.company ??)（#(delivery.number ??)）
                    #end
                </h2>
            </div>
            <!-- /.col -->
        </div>

        <!-- Table row -->
        <div class="row">
            <div class="col-xs-12 table-responsive">
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th style="width: 18%">时间</th>
                        <th>信息</th>
                    </tr>
                    </thead>
                    <tbody>
                    #for(ex : expressInfos)
                    <tr>
                        <td>#(ex.time ??)</td>
                        <td>#(ex.info ??)</td>
                    </tr>
                    #end
                    </tbody>
                </table>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->

    </section>
    <!-- /.content -->
    <div class="clearfix"></div>
</div>
#end
