owner_index.php 20 KB
<?php

use yii\helpers\Url;
use app\ht\widgets\LinkPager;
use domain\trade\RepairOrderStatus;
use common\business\SuspendOrder;
use domain\trade\RepairOrderType;

$this->title = '订单列表';
$this->params['breadcrumbs'][] = '非平台订单管理';
$this->params['breadcrumbs'][] = $this->title;

?>
<script src="<?= Yii::$app->request->baseUrl . "/exts/combo-select/js/jquery.combo.select.js"?>"></script>
<link rel="stylesheet" type="text/css" href="<?= Yii::$app->request->baseUrl . "/exts/combo-select/css/combo.select.css"?>" />
<style>
    .btncls{margin:0 10px!important;}
    .combo-select{margin-bottom: 0; width: 100%; text-align: left}
</style>
<div class="panel panel-default">
    <div class="panel-body" style="overflow-y: auto">
        <form action="" method="get" id="search-form" class="filter-form">
            <table width="100%" class="table table-bordered">
                <tbody>
                <tr >
                    <td width="10%" class="text-right">订单编号:</td>
                    <td width="10%"  class="text-left"><input type="text" class="form-control" name="order_no" id="order_no" value="<?php if (!empty($gets['order_no'])){ echo $gets['order_no']; } ?>"></td>
                    <td width="10%"  class="text-right">下单时间(起):</td>
                    <td width="20%" class="text-left"><input type="date" class="form-control" name="order_begin" id="order_begin" value="<?php if (!empty($gets['order_begin'])){ echo $gets['order_begin']; } ?>"></td>
                    <td width="10%"  class="text-right">下单时间(止):</td>
                    <td width="20%" class="text-left"><input type="date" class="form-control" name="order_end" id="order_end" value="<?php if (!empty($gets['order_end'])){ echo $gets['order_end']; } ?>"></td>
                </tr>
                <tr >
                    <td class="text-right">客户姓名:</td>
                    <td class="text-left"><input type="text" class="form-control" name="customer_name" id="customer_name" value="<?php if (!empty($gets['customer_name'])){ echo $gets['customer_name']; } ?>"></td>
                    <td class="text-right">客户电话:</td>
                    <td class="text-left"><input type="text" class="form-control" name="customer_phone" id="customer_phone" value="<?php if (!empty($gets['customer_phone'])){ echo $gets['customer_phone']; } ?>"></td>
                    <td class="text-right">设备名称:</td>
                    <td class="text-left"><input type="text" class="form-control" name="repair_device_name" id="repair_device_name" value="<?php if (!empty($gets['repair_device_name'])){ echo $gets['repair_device_name']; } ?>"></td>
                </tr>
                <tr >
                    <td class="text-right">报修城市:</td>
                    <td class="text-left">
                        <input type="text" class="form-control" name="city" id="city" value="<?php if (!empty($gets['city'])){ echo $gets['city']; } ?>" <?php if (empty($gets['is_accurate']))  { ?> style="display: none" <?php }?>>
                        <select  class="form-control" id="selcity" name="selcity" <?php if (isset($gets['is_accurate']) && $gets['is_accurate'] == 1) { ?> style="display: none" <?php }?>>
                            <option value="">全部</option>
                            <?php foreach ($citys as $city) : ?>
                                <option value="<?=$city->city ?>" <?php if ($gets['selcity'] == $city->city) { echo "selected"; } ?>><?=$city->city ?></option>
                            <?php endforeach; ?>
                        </select>

                        <input type="checkbox" class="form-control" style="width:30px;float: left;" <?php if (isset($gets['is_accurate']) && $gets['is_accurate'] == 1) { ?>checked="checked"<?php } ?> id="chkAccurate" name="chkAccurate" value="1"/>
                        <span style="float: left; margin-top: 3px;  margin-left: 10px;">模糊查找</span>
                    </td>
                    <td class="text-right">接单工程师:</td>
                    <td class="text-left">
                        <input type="hidden" name="order_status" id="order_status" value="<?=$gets['order_status']?>" />
                        <input class="form-control" name="engineer" id="engineer" value="<?=$gets['engineer']?>" autocomplete="off"/>
                    </td>
                    <td class="text-right">是否回访:</td>
                    <td class="text-left">
                        <select  class="form-control" id="selfinished" name="selfinished">
                            <option value="" <?php if (empty($gets['selfinished'])){ echo "selected"; } ?>>全部</option>
                            <option value="1" <?php if ($gets['selfinished'] == 1){ echo "selected"; } ?>>是</option>
                            <option value="2" <?php if ($gets['selfinished'] == 2){ echo "selected"; } ?>>否</option>
                        </select>
                    </td>
                </tr>
                <tr >
                    <td class="text-right">客服人员:</td>
                    <td class="text-right">
                        <select  class="form-control" id="customerName" name="customerName">
                            <option value="">全部</option>
                            <?php foreach ($sysUserList as $user) : ?>
                                <option value="<?=$user->realname ?>" <?php if ($gets['customerName'] == $user->realname) { echo "selected"; } ?>><?=$user->realname ?></option>
                            <?php endforeach; ?>
                        </select>
                    </td>
                    <td class="text-right">订单类型:</td>
                    <td class="text-left">
                        <select class="form-control" name="order_type" id="order_type">
                            <option value = "0">全部</option>
                            <option value = "<?= RepairOrderType::TYPE_PRIVATE ?>" <?php if (isset($gets["order_type"]) && $gets["order_type"] == RepairOrderType::TYPE_PRIVATE) { echo "selected";}?>><?= RepairOrderType::typeLabels(RepairOrderType::TYPE_PRIVATE)?></option>
                            <option value = "<?= RepairOrderType::TYPE_FORWARD_TO_FRIEND ?>" <?php if (isset($gets["order_type"]) && $gets["order_type"] == RepairOrderType::TYPE_FORWARD_TO_FRIEND) { echo "selected";}?>><?= RepairOrderType::typeLabels(RepairOrderType::TYPE_FORWARD_TO_FRIEND)?></option>
                        </select>
                    </td>
                    <td class="text-right">报修渠道:</td>
                    <td class="text-left">
                        <select  class="form-control" id="repairChannel" name="repairChannel">
                            <option value="" <?php if (empty($gets['repairChannel'])){ echo "selected"; } ?>>全部</option>
                            <?php foreach($repair_channels as $channel => $label): ?>
                                <option value="<?=$channel?>" <?php if ($gets['repairChannel'] == $channel){ echo "selected"; } ?>><?=$label?></option>
                            <?php endforeach;?>
                        </select>
                    </td>
                </tr>

                <tr class="search">
                    <td colspan="6"  class="text-center">
                        <button type="submit" class="btn btn-primary btncls" id="search"><i class="glyphicon glyphicon-search"></i> 查 询  </button>
                        <a class="btn btn-default btncls" href="<?=Url::toRoute(["/trade/order/owner-index", "order_status" => $gets['order_status']])?>">重&nbsp;&nbsp;&nbsp;&nbsp;置</a>
                        <a class="btn btn-success btncls" id="exportBtn" href="javascript:void(0)">导出订单报表</a>
                        <a class="btn btn-warning btncls" href="<?=Url::toRoute("/trade/order/owner-delay")?>">异常订单&nbsp;(<?= $delayOrderNum; ?>)</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>

<div class="panel panel-default">
    <div  class="panel-body">
        <ul id="countryTab" class="nav nav-tabs" style="margin-bottom: 20px">
            <li <?php if (empty($gets['order_status'])){ echo "class=\"active\""; } ?> ><a style="padding: 10px 20px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => 0])?>" >全部</a></li>
            <li <?php if ($gets['order_status'] == -1){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => '-1'])?>" >等待接单</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_WAIT_DOOR){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_WAIT_DOOR])?>" >等待上门</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_WAIT_PRICE){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_WAIT_PRICE])?>" >等待报价</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_CONFIRM_PRICE){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_CONFIRM_PRICE])?>" >确认报价</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_WAIT_ACCEPT){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_WAIT_ACCEPT])?>" >等待验收</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_WAIT_PAY){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_WAIT_PAY])?>" >等待支付</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_WAIT_RATE){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_WAIT_RATE])?>" >等待评价</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_SUSPEND){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_SUSPEND])?>" >挂起</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_FINISH){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_FINISH])?>" >已完成</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_USER_CANCEL){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_USER_CANCEL])?>" >用户取消</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_ENGINEER_CANCEL){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_ENGINEER_CANCEL])?>" >工程师取消</a></li>
            <!--li <?php /*if ($gets['order_status'] == RepairOrderStatus::STATUS_USER_CLOSE){ echo "class=\"active\""; } */?> ><a style="padding: 10px 12px;" href="<?//=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_USER_CLOSE])?>" >用户关闭</a></li-->
            <!--li <?php /*if ($gets['order_status'] == RepairOrderStatus::STATUS_ENGINEER_CLOSE){ echo "class=\"active\""; } */?> ><a style="padding: 10px 12px;" href="<?//=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_ENGINEER_CLOSE])?>" >工程师关闭</a></li-->
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_SYSTEM_CLOSE){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_SYSTEM_CLOSE])?>" >系统自动关闭</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_ADMIN_CLOSE){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_ADMIN_CLOSE])?>" >管理员关闭</a></li>
            <li <?php if ($gets['order_status'] == RepairOrderStatus::STATUS_SYSTEM_DELETE){ echo "class=\"active\""; } ?> ><a style="padding: 10px 12px;" href="<?=Url::current(['uid' => $gets['uid'], 'order_status' => RepairOrderStatus::STATUS_SYSTEM_DELETE])?>" >无效订单</a></li>
        </ul>

        <div style="overflow-y: auto">
        <?php if (!empty($orderList)) : ?>
            <table class="table table-striped table-bordered"  id="brand-table">
                <thead>
                <tr>
                    <th style="width:5%;">订单ID</th>
                    <th style="width:25%;">订单信息</th>
                    <th style="width:12%;">设备信息</th>
                    <th style="width:8%;">报修时间</th>
                    <th style="width:8%;">订单金额</th>
                    <th style="width:7%;">订单状态</th>
                    <th style="width:7%;">带走设备</th>
                    <th style="width:7%;">接单工程师</th>
                    <th style="width:8%;">客服信息</th>
                    <th style="width:20%;">操作</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($orderList as $order) : ?>
                    <tr>
                        <td class="text-center align-middle hqy-row-select"><?=$order['id'] ?></td>
                        <td >
                            订单编号:<span style="font-weight: bold; color: #C40000; margin-left: 10px;"><?= $order['order_no'] ?></span><br/>
                            账户信息:<span style="font-weight: bold; margin-left: 10px;">
                                <?php if(empty($order['phone'])){?>
                                    <?='未认领';?>
                                    <?php } else {?>
                                    <?= $order['nickname'] ?>(<?=$order['phone'] ?>)
                                <?php }?>
                                </span><br/>
                            联系信息:<span style="font-weight: bold; margin-left: 10px;"><?= $order['contact_name'] ?>(<?=$order['contact_phone'] ?>)</span><br/>

                            上门地址:<span style="font-weight: bold; margin-left: 10px;">
                                <?php if ($order['title']  == $order['address'] ) {echo $order['address'] .$order['address_detail']; } else { echo $order['title'] . $order['address_detail'].'('.$order['address'].')'; } ?></span><br/>
                            报修渠道:<span style="font-weight: bold; margin-left: 10px;"><?= $channels[$order['repair_channel']] ?></span><br/>
                            订单类型:<b style="color: #C40000"><?=RepairOrderType::typeLabels($order['type'])?></b><br/>
                            所属工程师:<span style="font-weight: bold; margin-left: 10px;"><?= $order['owner_engineer_name'] . "(" . $order['owner_engineer_phone']  .")" ?></span><br/>

                        </td>
                        <td>
                            设备名称:<a style="margin-left: 10px;" href="<?=$order['device_info_url']; ?>"><?=$order['repair_device_name']; ?></a><br/>
                        </td>
                        <td >
                            <?=Yii::$app->formatter->asTime($order['created_at'],"yyyy-MM-dd HH:mm:ss"); ?>
                        </td>
                        <td >
                            支付金额: <?= $order['pay_price'] ?><br/>

                        </td>
                        <td >
                            <?=$orderStatusList[$order['status']];?>
                            <?php if ($order['is_admin_close']==1){
                                        echo "(管理员关闭)";}
                                    else if ($order['is_user_close']==1){
                                        echo "(用户处理关闭)";}
                                    else if ($order['is_engineer_close']==1){
                                        echo "(工程师处理关闭)";}
                                   else if ($order['is_suspend'] != SuspendOrder::SUSPEND_STATUS_OFF){
                                        echo SuspendOrder::suspendLabels($order['is_suspend']);}
                                ?><br/>
                        </td>
                        <td >
                            <?=$order["is_take_away_label"] ? $order["is_take_away_label"] : "未带走" ?>
                        </td>
                        <td>
                            <?php if (!empty($order['engineer_name'])): ?>
                                <?= $order['engineer_name'] . '(' . $order['engineer_phone'] . ')' ?>
                            <?php else : ?>
                                未接单
                            <?php endif; ?>
                        </td>
                        <td >
                            通话语音记录:<span style="font-weight: bold; color: #C40000; margin-left: 10px;"><?= $order['is_consult'] == 1 ? "有" : "无" ?></span><br/>
                            跟单客服:<span style="font-weight: bold; margin-left: 10px;color: #C40000"><?= empty($order["customerName"]) ? "无" : $order["customerName"] ?></span><br/>
                            是否回访完毕:<b style="color: #C40000;font-size: 13px;">
                                <?= (isset($order['interview_finished']) && $order['interview_finished'])==1 ? "是" : "否" ?>
                            </b>
                        </td>
                        <td >
                            <a class="btn btn-primary" style="margin: 4px;" href="<?php echo Url::toRoute(['/trade/order/owner-info', 'id' => $order['id'],'order_status'=>$gets['order_status']])  ?>">查看详情</a>
                            <?php if ($order['has_dispatch'] == 1): ?>
                                <a class="btn btn-success" style="margin: 4px;" href="<?php echo Url::toRoute(['/trade/order-dispatch-record/owner-index', 'order_no' => $order['order_no']])  ?>">查看派单信息</a>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>
        <?php else : ?>
            <p class="text-center">
                没有找到数据
            </p>
        <?php endif; ?>
    </div>

    <div class="panel-footer">
        <div class="hqy-panel-pager">
            <?= LinkPager::widget([
                'pagination' => $pages,
            ]); ?>
            <div class="clearfix"></div>
        </div>
    </div>
</div>

<script>
    var searchItemUrl = "<?=Url::toRoute('/trade/order/search-engineer')?>";
    var search_engineer_count = '<?=$search_engineer_count ?>';
    $(function(){
        $('#customerName').comboSelect();
        var getUrl ='<?=Url::toRoute("/trade/order/export-owner-da")?>';
        var filterUrl ='<?=Url::toRoute("/trade/order/owner-index")?>';
        $(function(){
            $('#exportBtn').click(function(e){
                $('#search-form').attr('action',getUrl);
                $('#search-form').submit();
                return false;
            })
            //
            $('#search').click(function(e){
                $('#search-form').attr('action',filterUrl);
                $('#search-form').submit();
                return false;
            })
        })

        // 是否精准查找
        $("#chkAccurate").change(function () {
            var checked = $(this).is(':checked');
            if (checked) {
                $("#selcity").hide();
                $("#city").show();
            } else {
                $("#selcity").show();
                $("#city").hide();
            }
        })
    })
</script>