Beispiel #1
0
function user_lose()
{
    $filter['admin_id'] = intval($_REQUEST['admin_id']);
    $filter['role_id'] = intval($_REQUEST['role_id']);
    $filter['service_time'] = isset($_REQUEST['service_time']) ? intval($_REQUEST['service_time']) : 1;
    $filter['order_time'] = isset($_REQUEST['order_time']) ? intval($_REQUEST['order_time']) : 1;
    $filter['manner'] = empty($_REQUEST['manner']) ? ' OR ' : ' AND ';
    extract($filter);
    $now_time = $_SERVER['REQUEST_TIME'];
    $manner = empty($_REQUEST['manner']) ? ' OR ' : ' AND ';
    $filter['page_size'] = empty($_REQUEST['page_size']) ? 15 : intval($_REQUEST['page_size']);
    $condition = array();
    foreach ($filter as $key => $val) {
        $condition[] = $key . '=' . $val;
    }
    unset($key, $val);
    $where = ' WHERE is_black=0 AND customer_type NOT IN(4,5,6) AND service_time>0 AND order_time>0 ';
    if ($admin_id) {
        $where .= " AND admin_id={$admin_id}";
    }
    if ($role_id) {
        $where .= " AND role_id={$role_id}";
    }
    //$where .= $service_time<4? " AND TIMESTAMPDIFF(MONTH,FROM_UNIXTIME(service_time,'%Y-%m-%d'),FROM_UNIXTIME($now_time,'%Y-%m-%d'))=$service_time":" AND TIMESTAMPDIFF(MONTH,FROM_UNIXTIME(service_time,'%Y-%m-%d'),FROM_UNIXTIME('%Y-%m-%d',$now_time))>$service_time";
    $where .= ' AND service_time<' . strtotime("-{$service_time} month") . ' AND order_time<' . strtotime("-{$order_time} month");
    //$where .= $order_time<4?" $manner TIMESTAMPDIFF(MONTH,FROM_UNIXTIME(order_time,'%Y-%m-%d'),FROM_UNIXTIME($now_time,'%Y-%m-%d'))=$order_time":" $manner TIMESTAMPDIFF(MONTH,FROM_UNIXTIME(order_time,'%Y-%m-%d'),FROM_UNIXTIME('%Y-%m-%d',$now_time))>$order_time";
    $filter['page'] = intval($_REQUEST['page']) <= 0 ? 1 : intval($_REQUEST['page']);
    $sql_count = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('users') . $where;
    $record_count = $GLOBALS['db']->getOne($sql_count);
    $page = break_pages($record_count, $filter['page_size'], $filter['page']);
    $sql_select = 'SELECT user_id,user_name,sex,admin_name,order_time,service_time FROM ' . $GLOBALS['ecs']->table('users') . " {$where} LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ',' . $filter['page'] * $filter['page_size'];
    $result = $GLOBALS['db']->getAll($sql_select);
    foreach ($result as &$val) {
        $val['add_time'] = date('Y-m-d', $val['add_time']);
        $val['service_time'] = date('Y-m-d', $val['service_time']);
        $val['order_time'] = date('Y-m-d', $val['order_time']);
    }
    $arr = array('user_list' => $result, 'filter' => $filter, 'page_count' => $page['page_count'], 'record_count' => $record_count, 'page_size' => $filter['page_size'], 'page' => $filter['page'], 'page_set' => $page['page_set'], 'condition' => $condition, 'start' => $page['start'], 'end' => $page['end']);
    return $arr;
}
Beispiel #2
0
function get_inventory_storage($filter = array())
{
    $where = ' WHERE 1 ';
    if ($filter) {
        foreach ($filter as $key => $val) {
            $where .= " AND {$key}={$val}";
        }
    } else {
        $where .= ' AND end_time=0 ';
    }
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
    $page_size = isset($_REQUEST['page_size']) ? intval($_REQUEST['page_size']) : 15;
    $sql_select = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('inventory_storage') . $where;
    $record_count = $GLOBALS['db']->getOne($sql_select);
    $limit = ' LIMIT ' . ($page - 1) * $page_size . ",{$page_size}";
    $sql = 'SELECT storage_id,goods_sn,goods_name,start_time,end_time,quantity,place_goods_num,delive_goods_num,(quantity-place_goods_num-delive_goods_num) AS logic_quantity,before_inventory_num,actual_quantity FROM ' . $GLOBALS['ecs']->table('inventory_storage');
    $sql_select = $sql . $where . ' ORDER BY place_goods_num DESC ,delive_goods_num DESC, before_inventory_num DESC ' . $limit;
    $inventory_list = $GLOBALS['db']->getAll($sql_select);
    if (!$inventory_list) {
        $sql_select = 'SELECT start_time,end_time FROM ' . $GLOBALS['ecs']->table('inventory_storage') . ' ORDER BY start_time DESC LIMIT 1';
        $row = $GLOBALS['db']->getRow($sql_select);
        if ($row) {
            $condition = "&start_time={$row['start_time']}&end_time={$row['end_time']}";
            $where = " WHERE start_time={$row['start_time']} AND end_time={$row['end_time']}";
            $inventory_list = $GLOBALS['db']->getAll($sql . $where . ' ORDER BY start_time DESC' . $limit);
        }
    }
    $filter = break_pages($record_count, $page_size, $page);
    $filter['act'] = 'inventory_list';
    $filter['condition'] = $condition;
    $filter['page'] = $page;
    $filter['page_size'] = $page_size;
    $filter['record_count'] = $record_count;
    $inventory_list = array('inventory_list' => $inventory_list, 'filter' => $filter);
    return $inventory_list;
}
Beispiel #3
0
function get_admin_log($do_admin = 0, $code = '', $module = '', $start_time = '', $end_time = '', $order_by = '', $filter_page = '')
{
    $where = ' WHERE 1';
    $condition = '';
    if ($user_id) {
        $where .= " AND l.do_admin={$do_admin} ";
        $condition .= "&do_admin={$do_admin}";
    }
    if (!empty($code) && $code != 'all') {
        $where .= " AND l.code='{$code}'";
        $condition .= "&code={$code}";
    }
    if (!$start_time && !$end_time) {
        $start_time = strtotime(date('Y-m-d 00:00:00'));
        $end_time = strtotime(date('Y-m-d 23:59:59'));
    }
    $condition .= "&start_time={$start_time}&end_time={$end_time}";
    $where .= " AND log_time BETWEEN {$start_time} AND {$end_time} ";
    if ($filter_page) {
        $sql_select = ' SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('admin_log') . ' l LEFT JOIN ' . $GLOBALS['ecs']->table('admin_user') . ' a ON a.user_id=l.do_admin ' . $where;
        $record_count = $GLOBALS['db']->getOne($sql_select);
        $page_size = !empty($_REQUEST['page_size']) ? intval($_REQUEST['page_size']) : 8;
        $page = !empty($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
        $filter = break_pages($record_count, $page_size, $page);
        $filter['codition'] = $condition;
        $filter['page'] = $page;
        $filter['page_size'] = $page_size;
        $limit = ' LIMIT ' . ($page - 1) * $page_size . ",{$page_size}";
    }
    $order_by = $order_by ? $order_by : 'log_time DESC';
    $sql_select = 'SELECT l.log_time,l.log_info,l.sn,l.module,l.do_admin,l.admin_id,l.code,a.user_name,l.do_times FROM ' . $GLOBALS['ecs']->table('admin_log') . ' l LEFT JOIN ' . $GLOBALS['ecs']->table('admin_user') . ' a ON a.user_id=l.do_admin ' . "{$where} ORDER BY {$order_by}" . $limit;
    $log_list = $GLOBALS['db']->getAll($sql_select);
    if ($log_list) {
        foreach ($log_list as &$val) {
            $val['log_time'] = date('Y-m-d H:i:s', $val['log_time']);
            if (strpos($val['sn'], ',')) {
                $val['sn'] = explode(',', $val['sn']);
            }
        }
    }
    return array('log_list' => $log_list, 'filter' => $filter);
}
Beispiel #4
0
/**
 * false_order_list
 * @return array
 * @author Nixus
 **/
function false_order_list()
{
    $filter['end_time'] = time();
    $filter['begin_time'] = $filter['end_time'] - 3600 * 30;
    // 收集查询条件
    foreach ($filter as $key => $val) {
        if (!empty($val)) {
            $condition .= "&{$key}={$val}";
        }
    }
    // $platform;
    // $shipping_way;
    // 总记录数
    $sql_select = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE add_time BETWEEN {$filter['begin_time']} AND {$filter['end_time']} AND team NOT IN ({$_SESSION['role_id']},25)" . ' AND platform>1 AND order_status=5 AND shipping_status=1 AND pay_id<>3 ';
    $filter['record_count'] = $GLOBALS['db']->getOne($sql_select);
    // 页码
    $filter['page_no'] = intval($_REQUEST['page_no']) ?: 1;
    // 页数
    $filter['page_size'] = intval($_REQUEST['page_size']) ?: 20;
    $page_set = break_pages($filter['record_count'], $filter['page_size'], $filter['page_no']);
    $sql_select = 'SELECT i.consignee,FROM_UNIXTIME(i.shipping_time,"%Y-%m-%d %H:%i:%s") add_time,i.shipping_name,i.tracking_sn,' . 'i.order_id,p.region_name prov, c.region_name city, d.region_name dist, i.address addr, r.role_name platform,t.brush_order_sn tmall_sn,
        j.brush_order_sn jd_sn, dd.brush_order_sn dd_sn, m.brush_order_sn 1m_sn FROM ' . $GLOBALS['ecs']->table('order_info') . ' i LEFT JOIN ' . $GLOBALS['ecs']->table('region') . ' p ON i.province=p.region_id LEFT JOIN ' . $GLOBALS['ecs']->table('region') . ' c ON c.region_id=i.city LEFT JOIN ' . $GLOBALS['ecs']->table('region') . ' d ON d.region_id=i.district LEFT JOIN ' . $GLOBALS['ecs']->table('role') . ' r ON i.team=r.role_id LEFT JOIN ' . $GLOBALS['ecs']->table('brush_order') . ' t ON t.source_order_id=i.order_id AND t.brush_platform=6 LEFT JOIN ' . $GLOBALS['ecs']->table('brush_order') . ' j ON j.source_order_id=i.order_id AND j.brush_platform=10 LEFT JOIN ' . $GLOBALS['ecs']->table('brush_order') . ' dd ON dd.source_order_id=i.order_id AND dd.brush_platform=16 LEFT JOIN ' . $GLOBALS['ecs']->table('brush_order') . ' m ON m.source_order_id=i.order_id AND m.brush_platform=14 ' . ' WHERE i.pay_id<>3 AND i.order_status=5 AND i.shipping_status=1 AND i.add_time BETWEEN ' . " {$filter['begin_time']} AND {$filter['end_time']} AND i.team NOT IN ({$_SESSION['role_id']},25) AND i.platform>1 ORDER BY shipping_time DESC" . ' LIMIT ' . ($filter['page_no'] - 1) * $filter['page_size'] . ',' . $filter['page_size'];
    $row = $GLOBALS['db']->getAll($sql_select);
    return array('orders' => $row, 'filter' => $filter, 'page_count' => $page_set['page_count'], 'record_count' => $filter['record_count'], 'page_size' => $filter['page_size'], 'page_no' => $filter['page_no'], 'page_set' => $page_set['page_set'], 'condition' => $condition, 'start' => ($filter['page_no'] - 1) * $filter['page_size'] + 1, 'end' => $filter['page_no'] * $filter['page_size']);
}
Beispiel #5
0
/**
 * 统计重复购买的
 */
function rebuy_stats($num_limit = 2)
{
    $filter['start_time'] = empty($_REQUEST['start_time']) ? '' : trim($_REQUEST['start_time']);
    $filter['end_time'] = empty($_REQUEST['end_time']) ? '' : trim($_REQUEST['end_time']);
    $filter['platform'] = empty($_REQUEST['platform']) ? 0 : intval($_REQUEST['platform']);
    $filter['admin_id'] = empty($_REQUEST['admin_id']) ? 0 : intval($_REQUEST['admin_id']);
    if (empty($filter['start_time']) || empty($filter['end_time'])) {
        $filter['start_time'] = date('Y-m-01 00:00:00');
        $filter['end_time'] = date('Y-m-t 00:00:00');
    }
    $filter['page_size'] = empty($_REQUEST['page_size']) ? 20 : intval($_REQUEST['page_size']);
    $filter['page'] = empty($_REQUEST['page_no']) ? 1 : intval($_REQUEST['page_no']);
    $ex_where = ' p.ordinal_number>1 ';
    if (admin_priv('rebuy_stats_all', '', false)) {
        if ($filter['platform']) {
            $ex_where .= " AND p.team={$filter['platform']}";
        }
    } else {
        $ex_where .= " AND p.team={$_SESSION['role_id']}";
    }
    if ($filter['admin_id']) {
        $ex_where .= " AND p.admin_id={$filter['admin_id']} ";
    }
    $condition = '';
    foreach ($filter as $key => $val) {
        if (!empty($val)) {
            if ($key == 'type') {
                $condition .= "&{$key}=" . urlencode($val);
                continue;
            }
            $condition .= "&{$key}={$val}";
        }
    }
    $start_time = strtotime($filter['start_time']);
    $end_time = strtotime($filter['end_time']);
    // 统计总记录数
    $sql_select = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('repeat_purchase') . " p WHERE {$ex_where} AND buy_time BETWEEN {$start_time} AND {$end_time}";
    $record_count = $GLOBALS['db']->getOne($sql_select);
    $page = break_pages($record_count, $filter['page_size'], $filter['page']);
    $sql_select = 'SELECT ordinal_number,final_amount,FROM_UNIXTIME(buy_time,"%Y-%m-%d") buy_time,u.user_name,p.user_id,a.user_name admin_name,r.role_name FROM ' . $GLOBALS['ecs']->table('repeat_purchase') . ' p LEFT JOIN ' . $GLOBALS['ecs']->table('users') . ' u ON u.user_id=p.user_id LEFT JOIN ' . $GLOBALS['ecs']->table('role') . ' r ON p.team=r.role_id LEFT JOIN ' . $GLOBALS['ecs']->table('admin_user') . " a ON a.user_id=p.admin_id WHERE {$ex_where} AND buy_time BETWEEN {$start_time} AND {$end_time} ORDER BY final_amount DESC,ordinal_number DESC LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ', ' . $filter['page_size'];
    $res = $GLOBALS['db']->getAll($sql_select);
    $result = array('stats' => $res, 'filter' => $filter, 'page_count' => $page['page_count'], 'record_count' => $record_count, 'page_size' => $filter['page_size'], 'page' => $filter['page'], 'page_set' => $page['page_set'], 'condition' => $condition, 'start' => $page['start'], 'end' => $page['end']);
    return $result;
}
Beispiel #6
0
/**
 * 短信记录
 */
function sms_history()
{
    // 通用参数
    $filter['page_size'] = empty($_REQUEST['page_size']) ? 20 : intval($_REQUEST['page_size']);
    $filter['current_page'] = empty($_REQUEST['page_no']) ? 1 : intval($_REQUEST['page_no']);
    $filter['page_size'] = $filter['page_size'] ?: 20;
    $filter['current_page'] = $filter['current_page'] ?: 1;
    // 查询参数
    $filter['start'] = empty($_REQUEST['start']) ? '' : strtotime($_REQUEST['start']);
    $filter['end'] = empty($_REQUEST['end']) ? '' : strtotime($_REQUEST['end']);
    $filter['admin_id'] = empty($_REQUEST['admin_id']) ? '' : intval($_REQUEST['admin_id']);
    $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : mysql_real_escape_string($_REQUEST['keywords']);
    $filter['start'] = $filter['start'] ? $filter['start'] : 0;
    $filter['end'] = $filter['end'] ? $filter['end'] : 0;
    $filter['admin_id'] = $filter['admin_id'] ? $filter['admin_id'] : '';
    $filter['keywords'] = $filter['keywords'] ? $filter['keywords'] : '';
    $condition = array();
    foreach ($_REQUEST as $key => $val) {
        if (!in_array($key, array('act', 'page_size', 'page_no')) && !empty($val)) {
            $condition[] = "{$key}={$val}";
        }
    }
    $condition = '&' . implode('&', $condition);
    $where = 1;
    if (admin_priv('sms_history_all', '', false)) {
        $where .= '';
    } elseif (admin_priv('sms_history_part', '', false)) {
        $where .= " AND u.role_id={$_SESSION['role_id']} ";
    } elseif (admin_priv('sms_history_group', '', false)) {
        $where .= " AND u.group_id={$_SESSION['group_id']} ";
    } else {
        $filter['admin_id'] = $_SESSION['admin_id'];
    }
    if ($filter['admin_id']) {
        $where .= " AND s.admin_id={$filter['admin_id']} ";
    }
    if ($filter['start'] && $filter['end']) {
        $where .= " AND s.send_time BETWEEN {$filter['start']} AND {$filter['end']} ";
    }
    if ($filter['keywords']) {
        $where .= " AND s.sms_content LIKE '%{$filter['keywords']}%' ";
    }
    $sql_select = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('sms_log') . ' s LEFT JOIN ' . $GLOBALS['ecs']->table('admin_user') . " u ON s.admin_id=u.user_id WHERE {$where}";
    $record_count = $GLOBALS['db']->getOne($sql_select);
    $page = break_pages($record_count, $filter['page_size'], $filter['current_page']);
    $sql_select = 'SELECT s.phone_num,s.sms_content,FROM_UNIXTIME(s.send_time, "%Y-%m-%d %H:%i:%s") send_time,u.user_name,s.words_num FROM ' . $GLOBALS['ecs']->table('sms_log') . ' s LEFT JOIN ' . $GLOBALS['ecs']->table('admin_user') . ' u ON u.user_id=s.admin_id WHERE ' . "{$where} ORDER BY send_time DESC LIMIT " . ($filter['current_page'] - 1) * $filter['page_size'] . ',' . $filter['page_size'];
    $sms_list = $GLOBALS['db']->getAll($sql_select);
    $result = array('outflow_list' => $sms_list, 'filter' => $filter, 'page_count' => $page['page_count'], 'record_count' => $record_count, 'page_size' => $filter['page_size'], 'page' => $filter['current_page'], 'page_set' => $page['page_set'], 'condition' => $condition, 'start' => $page['start'], 'end' => $page['end']);
    return $result;
}