exportDa.php 9.29 KB
<?php

    use common\business\SuspendOrder;

    header('Content-Type: application/vnd.ms-excel;charset=utf-8');
    $title = date('Y-m-d') . '_订单';
    $name = $title . ".xls";
    header('Content-Disposition: attachment;filename=' . $name . '');
    header('Cache-Control: max-age=0');
    $fp = fopen('php://output', 'a');
    $limit = 10000;
    $cnt = 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:o="urn:schemas-microsoft-com:office:office"
      xmlns:x="urn:schemas-microsoft-com:office:excel"
      xmlns="http://www.w3.org/TR/REC-html40">

<head>
    <meta http-equiv=Content-Type content="text/html; charset=utf-8">

</head>
<body>
<div id="Classeur1_16681" align='center' x:publishsource="Excel">
    <table border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse">
        <thead>
        <tr>
            <th style="width:110px" class="text-center align-middle hqy-all-select">订单号</th>
            <th style="width:207px">设备拥有者</th>
            <th style="width:207px">设备绑定人</th>
            <th style="width:207px">报修设备</th>
            <th style="width:207px">报修客户</th>
            <th style="width:90px">报修时间</th>
            <th style="width:273px;">上门地址</th>
            <th style="width:80px;">支付金额</th>
            <th style="width:80px;">配件费用</th>
            <th style="width:80px">上门费</th>
            <th style="width:80px">感谢费</th>
            <th style="width:80px">工时费</th>
            <th style="width:80px">订单金额</th>
            <th style="width:80px">免佣金额</th>
            <th style="width:80px">平台佣金</th>
            <th style="width:70px">订单状态</th>
            <th style="width:70px">支付状态</th>
            <th style="width:70px">挂起状态</th>
            <th style="width:70px">关闭状态</th>
            <th style="width:60px">工程师</th>
            <th style="width:80px">报修渠道</th>
            <th style="width:90px">绑定时间</th>
            <th style="width:90px">是否完成回访</th>
            <!--<th style="width:280px">回访记录</th>-->
            <?php if (isset($questions) && $questions) {
                foreach ($questions as $item) {
                    ?>
                    <th style="width:90px"><?= $item->title ?></th>
                <?php }
            } ?>
            <th style="width:60px">综合评分</th>
            <th style="width:60px">速度评分</th>
            <th style="width:60px">态度评分</th>
            <th style="width:60px">技能评分</th>
            <th style="width:120px">评价内容</th>
            <th style="width:120px">回访评论</th>
            <th style="width:200px;">取消原因</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($orderList as $order) : ?>
            <tr>
                <td class="text-center align-middle hqy-row-select"
                    style="vnd.ms-excel.numberformat:@"><?= $order['order_no'] ?></td>
                <td>
                    <?= $order['ownername'] ?>
                </td>
                <td>
                    <?= !empty($order['bind_engineer_name']) ? $order['bind_engineer_name'] : $order['bind_engineer_nick_name'] ?>
                </td>
                <td>
                    <?= $order['repair_device_name'] ?>
                </td>
                <td>
                    <?= $order['nickname'] ?>(<?= $order['phone'] ?>)
                </td>
                <td>
                    <?= Yii::$app->formatter->asTime($order['created_at'], "yyyy-MM-dd"); ?>
                </td>
                <td>
                    <?php if ($order['title'] == $order['address']) {
                        echo $order['address'] . $order['address_detail'];
                    } else {
                        echo $order['title'] . $order['address_detail'] . '(' . $order['address'] . ')';
                    } ?>

                </td>
                <td style="vnd.ms-excel.numberformat:#,##0.00">
                    <?= $order['pay_price'] ?>
                </td>
                <td style="vnd.ms-excel.numberformat:#,##0.00">
                    <?= $order['parts_price'] ?>
                </td>
                <td style="vnd.ms-excel.numberformat:#,##0.00">
                    <?= $order['door_fee'] ?>
                </td>
                <td style="vnd.ms-excel.numberformat:#,##0.00">
                    <?= $order['thank_fee'] ?>
                </td>
                <td style="vnd.ms-excel.numberformat:#,##0.00">
                    <?= $order['labor_price'] ?>
                </td>
                <td style="vnd.ms-excel.numberformat:#,##0.00">
                    <?= $order['door_fee'] + $order['repair_price'] ?>
                </td>
                <td style="vnd.ms-excel.numberformat:#,##0.00">
                    <?= !empty($order['free_commission_amount']) ? $order['free_commission_amount'] : 0 ?>
                </td>
                <td style="vnd.ms-excel.numberformat:#,##0.00">
                    <?= !empty($order['employ_fee']) ? $order['employ_fee'] : 0 ?>
                </td>
                <td>
                    <?= $orderStatusList[$order['status']] ?>
                </td>
                <td>
                    <?= (isset($order['pay_at']) && $order['pay_at'] > 0) ? (($order['pay_price'] > 0) ? "已支付" : "优惠抵扣") : "未支付" ?>
                </td>
                <td>
                    <?php if ($order['is_suspend'] != SuspendOrder::SUSPEND_STATUS_SUCCESS) {
                        echo SuspendOrder::suspendLabels($order['is_suspend']);
                    } ?>
                </td>
                <td>
                    <?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 {
                        echo "正常";
                    }
                    ?>
                </td>
                <td>
                    <?= $order['engineer_name'] ?>
                </td>
                <td>
                    <?= $channels[$order['repair_channel']] ?>
                </td>

                <td>
                    <?= Yii::$app->formatter->asTime($order['bind_at'], "yyyy-MM-dd"); ?>
                </td>
                <td>
                    <?= (isset($order['interview_finished']) && $order['interview_finished']) == 1 ? "是" : "否" ?>
                </td>
                <?php if (isset($questions) && $questions) {
                    foreach ($questions as $item) {
                        ?>
                        <td><?php if (isset($order['interview_result']) && $order['interview_result']) {
                                $interview_result = json_decode($order['interview_result'], true);
                                if (isset($interview_result['answers'])) {
                                    foreach ($interview_result['answers'] as $result) {
                                        if (isset($result[$item->title])) {
                                            echo $result[$item->title];
                                        }
                                    }
                                }
                            } ?></td>
                    <?php }
                } ?>

                <td>
                    <?= $order['final_star'] ?>
                </td>
                <td>
                    <?= $order['user_speed_star'] ?>
                </td>
                <td>
                    <?= $order['user_attitude_star'] ?>
                </td>
                <td>
                    <?= $order['user_skill_star'] ?>
                </td>
                <td>
                    <?= $order['user_comment'] ?>
                </td>
                <td>
                    <?php
                    $interview_comment_content = $order['interview_comment_content'];
                    if (!empty($interview_comment_content)) {
                        $interview_comment_content = explode('|', $interview_comment_content);
                        $content_str = "";
                        foreach ($interview_comment_content as $key => $interview_comment_content_item) {
                            $content_str .= ($key + 1) . '、' . $interview_comment_content_item . "; &nbsp;";
                        }
                        echo $content_str;
                    }
                    ?>
                </td>
                <td>
                    <?php
                        if($order['cancel_reason']) {
                            echo $order['cancel_reason'];
                        } else {
                            echo "";
                        }
                    ?>
                </td>
            </tr>
            <?php
            $cnt++;
            if (1000 == $cnt) { //刷新一下输出buffer,防止由于数据过多造成问题
                ob_flush();
                flush();
                $cnt = 0;
            }
            ?>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
</body>
</html>