ImportDataModel.class.php 1.67 KB
<?php
/**
 * Created by IntelliJ IDEA.
 * User: zhuxun37
 * Date: 2017/5/17
 * Time: 上午11:46
 */

namespace Common\Model;


class ImportDataModel extends AbstractModel
{
    // 导入结果: 未知
    const IS_ERROR_TYPE_UNKNOWN = 0;
    // 导入结果: 已出错
    const IS_ERROR_TYPE_ERROR = 1;

    // 数据类型, title: excel表头
    const DATA_TYPE_TITLE = 'title';

    // 构造方法
    public function __construct()
    {

        parent::__construct();
    }


    /**
     * 获取错误列表,并返回title信息
     *
     * @param array $conds 条件数组
     * @param array $order_option 排序
     *
     * @return array|bool
     */
    public function list_import_data_by_conds($conds, $order_option = array())
    {

        $where = 'domain=? AND status<? ';
        $params = array(
            QY_DOMAIN,
            self::ST_DELETE
        );

        if (!empty($conds['import_flag'])) {
            $where .= ' AND import_flag  = ?';
            $params[] = $conds['import_flag'];
        }

        if (!empty($conds['ea_id'])) {
            $where .= ' AND ea_id  = ?';
            $params[] = $conds['ea_id'];
        }

        if (!empty($conds['is_error'])) {
            // 获取title
            $where .= ' AND (data_type  = ?';
            $params[] = self::DATA_TYPE_TITLE;

            $where .= ' or is_error  = ?)';
            $params[] = $conds['is_error'];
        }

        // 排序
        $orderby = '';
        if (!$this->_order_by($orderby, $order_option)) {
            return false;
        }

        $sql = 'SELECT * FROM __TABLE__ WHERE ' . $where . ' ' . $orderby;

        return $this->_m->fetch_array($sql, $params);
    }
}