Example #1
0
function agency_pay_log_list()
{
    $filter['order_sn'] = empty($_REQUEST['order_sn']) ? '' : trim($_REQUEST['order_sn']);
    $filter['status'] = empty($_REQUEST['status']) ? '' : trim($_REQUEST['status']);
    $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
    $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'id' : trim($_REQUEST['sort_by']);
    $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
    $where = '';
    $where .= agency_where();
    $where = preg_replace('|admin_agency_id|', 'ag.agency_id', $where);
    //dump($where);
    /* 订单号 */
    if (!empty($filter['order_sn'])) {
        $where .= " AND oi.order_sn = {$filter['order_sn']}";
    }
    /*状态*/
    if (!empty($filter['status'])) {
        $where .= " AND ag.status = {$filter['status']}";
    }
    /*代理商*/
    if (!empty($filter['admin_agency_id'])) {
        $where .= " AND ag.agency_id = {$filter['admin_agency_id']}";
    }
    $sql = "SELECT COUNT(*) FROM  " . $GLOBALS['ecs']->table('agency_pay_log') . "as ag left join " . $GLOBALS['ecs']->table('users') . " as u on u.user_id = ag.user_id left join " . $GLOBALS['ecs']->table('admin_user') . " as au on au.agency_user_id = ag.agency_id left join " . $GLOBALS['ecs']->table('order_info') . " as oi on oi.order_id = ag.order_id WHERE 1 {$where} order by {$filter['sort_by']} {$filter['sort_order']} ";
    $filter['record_count'] = $GLOBALS['db']->getOne($sql);
    $filter = page_and_size($filter);
    $sql = "SELECT ag.id,oi.order_sn,ag.order_id,au.user_name as admin_name,u.user_name,ag.order_amount,ag.time,ag.status FROM  " . $GLOBALS['ecs']->table('agency_pay_log') . "as ag left join " . $GLOBALS['ecs']->table('users') . " as u on u.user_id = ag.user_id left join " . $GLOBALS['ecs']->table('admin_user') . " as au on au.agency_user_id = ag.agency_id left join " . $GLOBALS['ecs']->table('order_info') . " as oi on oi.order_id = ag.order_id WHERE 1 {$where} order by {$filter['sort_by']} {$filter['sort_order']}  LIMIT " . $filter['start'] . ", " . $filter['page_size'] . "";
    $filter['keywords'] = stripslashes($filter['keywords']);
    set_filter($filter, $sql);
    $res = $GLOBALS['db']->getAll($sql);
    //dump($res);
    $arr = array('res' => $res, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #2
0
function get_stock_control_log()
{
    $result = get_filter();
    if ($result === false) {
        $filter = array();
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['start_date'] = empty($_REQUEST['start_date']) ? local_strtotime('-30 days') : $_REQUEST['start_date'];
        $filter['end_date'] = empty($_REQUEST['end_date']) ? local_strtotime('today') : $_REQUEST['end_date'];
        if (strpos($filter['start_date'], '-') !== false) {
            $filter['start_date'] = local_strtotime($filter['start_date']);
            $filter['end_date'] = local_strtotime($filter['end_date']);
        }
        $where = agency_where();
        /*add by hg for date 2014-04-21 可选商品*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                $where .= " AND (a.admin_agency_id = {$filter['admin_agency_id']} ) ";
            } else {
                $where .= " AND (a.admin_agency_id = 0 ) ";
            }
        }
        if (!empty($filter['keyword'])) {
            $where .= " AND (a.goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'  or a.stock_number LIKE '%" . mysql_like_quote($filter['keyword']) . "%' )";
        }
        if ($filter['start_date']) {
            $where = $where . " AND a.log_time >= '{$filter['start_date']}'";
        }
        if ($filter['end_date']) {
            $where = $where . " AND a.log_time <= '" . ($filter['end_date'] + 86400) . "'";
        }
        $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_control_log') . ' AS a ' . 'WHERE 1 ' . $where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $filter = page_and_size($filter);
        /* 获取库存日志管理数据 */
        $sql = 'SELECT a.*  ' . 'FROM ' . $GLOBALS['ecs']->table('stock_control_log') . ' AS a ' . 'WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order'];
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $arr = array();
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
    while ($rows = $GLOBALS['db']->fetchRow($res)) {
        $rows['date'] = local_date($GLOBALS['_CFG']['time_format'], $rows['log_time']);
        $rows['out_type_remarks'] = $GLOBALS['db']->getOne("SELECT remarks FROM " . $GLOBALS['ecs']->table('stock_out_type') . " WHERE id = '" . $rows['out_type_id'] . "' ");
        $arr[] = $rows;
    }
    $GLOBALS['smarty']->assign('start_date', local_date('Y-m-d', $filter['start_date']));
    $GLOBALS['smarty']->assign('end_date', local_date('Y-m-d', $filter['end_date']));
    $filter['start_date'] = local_date('Y-m-d', $filter['start_date']);
    $filter['end_date'] = local_date('Y-m-d', $filter['end_date']);
    return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}
Example #3
0
/**
 * 获得设置信息
 *
 * @param   array   $groups     需要获得的设置组
 * @param   array   $excludes   不需要获得的设置组
 *
 * @return  array
 */
function get_settings($groups = null, $excludes = null)
{
    global $db, $ecs, $_LANG;
    $config_groups = '';
    $excludes_groups = '';
    if (!empty($groups)) {
        foreach ($groups as $key => $val) {
            $config_groups .= " AND (id='{$val}' OR parent_id='{$val}')";
        }
    }
    if (!empty($excludes)) {
        foreach ($excludes as $key => $val) {
            $excludes_groups .= " AND (parent_id<>'{$val}' AND id<>'{$val}')";
        }
    }
    /*add by hg for date 2014-05-04筛选代理商 begin*/
    $admin_agency_id = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : '';
    $GLOBALS['smarty']->assign('agency_list', agency_list());
    $GLOBALS['smarty']->assign('admin_agency_id', $admin_agency_id);
    /*end*/
    /* 隐藏skype msn ym licence */
    $hide = " code not in('ym','msn','skype','licensed') AND ";
    /* 取出全部数据:分组和变量 */
    if (if_agency() && empty($admin_agency_id)) {
        $sql = "SELECT * FROM " . $ecs->table('shop_config') . " WHERE {$hide} type<>'hidden' {$config_groups} {$excludes_groups} ORDER BY parent_id, sort_order, id";
    } else {
        // add by hg for date 2014-05-04 代理商
        $sql = "SELECT * FROM " . $ecs->table('shop_config') . " WHERE {$hide} type<>'hidden' AND parent_id <> 1 {$config_groups} {$excludes_groups} ORDER BY parent_id, sort_order, id";
    }
    $item_list = $db->getAll($sql);
    /*add by hg for date 2014-05-04 代理商商店设置信息*/
    if (!if_agency() || !empty($admin_agency_id)) {
        $agency_where = agency_where($admin_agency_id);
        $agency_list = $db->getAll("SELECT * FROM " . $ecs->table('agency_shop_config') . " WHERE {$hide} type<>'hidden' {$agency_where} {$config_groups} {$excludes_groups} ORDER BY parent_id, sort_order, id");
        $item_list = array_merge($item_list, $agency_list);
    }
    /* 整理数据 */
    $group_list = array();
    foreach ($item_list as $key => $item) {
        $pid = $item['parent_id'];
        $item['name'] = isset($_LANG['cfg_name'][$item['code']]) ? $_LANG['cfg_name'][$item['code']] : $item['code'];
        $item['desc'] = isset($_LANG['cfg_desc'][$item['code']]) ? $_LANG['cfg_desc'][$item['code']] : '';
        if ($item['code'] == 'sms_shop_mobile') {
            $item['url'] = 1;
        }
        if ($pid == 0) {
            /* 分组 */
            if ($item['type'] == 'group') {
                $group_list[$item['id']] = $item;
            }
        } else {
            //dump($group_list[$pid]);
            /* 变量 */
            if (isset($group_list[$pid])) {
                if ($item['store_range']) {
                    $item['store_options'] = explode(',', $item['store_range']);
                    foreach ($item['store_options'] as $k => $v) {
                        $item['display_options'][$k] = isset($_LANG['cfg_range'][$item['code']][$v]) ? $_LANG['cfg_range'][$item['code']][$v] : $v;
                    }
                }
                $group_list[$pid]['vars'][] = $item;
            }
        }
    }
    return $group_list;
}
Example #4
0
/**
 * 获得商品列表
 *
 * @access  public
 * @params  integer $isdelete
 * @params  integer $real_goods
 * @params  integer $conditions
 * @return  array
 */
function goods_list($is_delete, $real_goods = 1, $conditions = '')
{
    /* 过滤条件 */
    $param_str = '-' . $is_delete . '-' . $real_goods;
    $result = get_filter($param_str);
    if ($result === false) {
        $day = getdate();
        $today = local_mktime(23, 59, 59, $day['mon'], $day['mday'], $day['year']);
        $filter['cat_id'] = empty($_REQUEST['cat_id']) ? 0 : intval($_REQUEST['cat_id']);
        $filter['intro_type'] = empty($_REQUEST['intro_type']) ? '' : trim($_REQUEST['intro_type']);
        $filter['is_promote'] = empty($_REQUEST['is_promote']) ? 0 : intval($_REQUEST['is_promote']);
        $filter['stock_warning'] = empty($_REQUEST['stock_warning']) ? 0 : intval($_REQUEST['stock_warning']);
        $filter['brand_id'] = empty($_REQUEST['brand_id']) ? 0 : intval($_REQUEST['brand_id']);
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        $filter['suppliers_id'] = isset($_REQUEST['suppliers_id']) ? empty($_REQUEST['suppliers_id']) ? '' : trim($_REQUEST['suppliers_id']) : '';
        $filter['is_on_sale'] = isset($_REQUEST['is_on_sale']) ? empty($_REQUEST['is_on_sale']) && $_REQUEST['is_on_sale'] === 0 ? '' : trim($_REQUEST['is_on_sale']) : '';
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'goods_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['extension_code'] = empty($_REQUEST['extension_code']) ? '' : trim($_REQUEST['extension_code']);
        $filter['is_delete'] = $is_delete;
        $filter['real_goods'] = $real_goods;
        /*代理商*/
        $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
        /*add by hg for date 2014-04-22		只显示代理商本身的产品*/
        $where = agency_where();
        /*end*/
        $where .= $filter['cat_id'] > 0 ? " AND " . get_children($filter['cat_id']) : '';
        //print_r($where);die;
        /* 推荐类型 */
        switch ($filter['intro_type']) {
            case 'is_best':
                $where .= " AND is_best=1";
                break;
            case 'is_hot':
                $where .= ' AND is_hot=1';
                break;
            case 'is_new':
                $where .= ' AND is_new=1';
                break;
            case 'is_promote':
                $where .= " AND is_promote = 1 AND promote_price > 0 AND promote_start_date <= '{$today}' AND promote_end_date >= '{$today}'";
                break;
            case 'all_type':
                $where .= " AND (is_best=1 OR is_hot=1 OR is_new=1 OR (is_promote = 1 AND promote_price > 0 AND promote_start_date <= '" . $today . "' AND promote_end_date >= '" . $today . "'))";
        }
        /* 库存警告 */
        if ($filter['stock_warning']) {
            $where .= ' AND goods_number <= warn_number ';
        }
        /* 品牌 */
        if ($filter['brand_id']) {
            $where .= " AND brand_id='{$filter['brand_id']}'";
        }
        /* 扩展 */
        if ($filter['extension_code']) {
            $where .= " AND extension_code='{$filter['extension_code']}'";
        }
        /* 关键字 */
        if (!empty($filter['keyword'])) {
            $where .= " AND (goods_sn LIKE '%" . mysql_like_quote($filter['keyword']) . "%' OR goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%')";
        }
        if ($real_goods > -1) {
            $where .= " AND is_real='{$real_goods}'";
        }
        /* 上架 */
        if ($filter['is_on_sale'] !== '') {
            $where .= " AND (is_on_sale = '" . $filter['is_on_sale'] . "')";
        }
        /* 供货商 */
        if (!empty($filter['suppliers_id'])) {
            $where .= " AND (suppliers_id = '" . $filter['suppliers_id'] . "')";
        }
        /*add by hg for date 2014-04-21 可选商品*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                $where .= " AND (admin_agency_id = {$filter['admin_agency_id']} )";
            } else {
                $where .= " AND (admin_agency_id = 0 )";
            }
        }
        //dump($where);
        $where .= $conditions;
        /* 记录总数 */
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='{$is_delete}' {$where}";
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        /* 分页大小 */
        $filter = page_and_size($filter);
        $sql = "SELECT cat_id,start_num,host_goods_id,goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number,costing_price, integral,admin_agency_id, province_name,city_name,area_name, " . " (promote_price > 0 AND promote_start_date <= '{$today}' AND promote_end_date >= '{$today}') AS is_promote " . " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='{$is_delete}' {$where}" . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . $filter['start'] . ",{$filter['page_size']}";
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql, $param_str);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $row = $GLOBALS['db']->getAll($sql);
    foreach ($row as $row_k => $row_v) {
        /*证明是代理商添加的商品*/
        if ($row_v['host_goods_id'] == '0' && $row_v['admin_agency_id']) {
            $row[$row_k]['agency_goods'] = '1';
        } elseif (!$row_v['admin_agency_id']) {
            //主站添加的商品
            //代理商起购数量
            $res = $GLOBALS['db']->getRow("SELECT user_price,rank_goods_start_num FROM " . $GLOBALS['ecs']->table('member_price') . " WHERE goods_id = {$row_v['goods_id']} AND user_rank=4");
            if ($res['rank_goods_start_num']) {
                $row[$row_k]['rank_goods_start_num'] = $res['rank_goods_start_num'];
            } else {
                $rank_start_num = $GLOBALS['db']->getOne("SELECT rank_start_num FROM " . $GLOBALS['ecs']->table('user_rank') . " WHERE rank_id = 4");
                $row[$row_k]['rank_goods_start_num'] = $rank_start_num;
            }
            /* 代理商价格 */
            if ($res['user_price']) {
                $row[$row_k]['agency_price'] = $res['user_price'];
            } else {
                $discount = $GLOBALS['db']->getOne("SELECT discount FROM " . $GLOBALS['ecs']->table('user_rank') . " WHERE rank_id = 4");
                $row[$row_k]['agency_price'] = number_format($discount * 0.01 * $row_v['shop_price'], 2, '.', '');
            }
        }
        /* 用于批量修改 */
        $goods_id_arr[] = $row_v['goods_id'];
        $goods_price_arr[] = $row_v['costing_price'];
    }
    /* 用于批量修改 */
    $filter['goods_id_arr'] = json_encode($goods_id_arr);
    $filter['goods_price_arr'] = json_encode($goods_price_arr);
    if ($row[0]['rank_goods_start_num']) {
        $GLOBALS['smarty']->assign('rank_goods_start_num', 1);
    }
    if (isset($row[0]['agency_price'])) {
        $GLOBALS['smarty']->assign('agency_price', 1);
    }
    return array('goods' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}
Example #5
0
function auction_list()
{
    $result = get_filter();
    if ($result === false) {
        /*add by hg for date 2014-05-08 获取代理商信息 begin*/
        $admin_agency_id = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : '0';
        //dump($admin_agency_id);
        $agency_list = agency_list();
        $GLOBALS['smarty']->assign('agency_list', $agency_list);
        $GLOBALS['smarty']->assign('admin_agency_id', $admin_agency_id);
        $action_list = if_agency() ? 'all' : '';
        $GLOBALS['smarty']->assign('all', $action_list);
        /*end*/
        $where = "";
        //根据代理商过滤信息
        $where .= agency_where();
        /*add by hg for date 2014-05-08 根据代理商筛选  begin*/
        if (if_agency() && !empty($admin_agency_id)) {
            $where .= " AND admin_agency_id = '{$admin_agency_id}' ";
        } elseif (if_agency()) {
            $where .= " AND admin_agency_id = '0' ";
        }
        /*end*
          /* 过滤条件 */
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['is_going'] = empty($_REQUEST['is_going']) ? 0 : 1;
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'act_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        if (!empty($filter['keyword'])) {
            $where .= " AND goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'";
        }
        if ($filter['is_going']) {
            $now = gmtime();
            $where .= " AND is_finished = 0 AND start_time <= '{$now}' AND end_time >= '{$now}' ";
        }
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type = '" . GAT_AUCTION . "' {$where}";
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        /* 分页大小 */
        $filter = page_and_size($filter);
        /* 查询 */
        $sql = "SELECT * " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type = '" . GAT_AUCTION . "' {$where} " . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . $filter['start'] . ", {$filter['page_size']}";
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $res = $GLOBALS['db']->query($sql);
    $list = array();
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        $ext_info = unserialize($row['ext_info']);
        $arr = array_merge($row, $ext_info);
        $arr['start_time'] = local_date('Y-m-d H:i', $arr['start_time']);
        $arr['end_time'] = local_date('Y-m-d H:i', $arr['end_time']);
        $list[] = $arr;
    }
    $arr = array('item' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #6
0
/**
* 获取代理商商店配置信息
* add by hg for date 2014-04-22 
* $agency_id 指定代理商id
**/
function agency_shop_config($agency_user_id = '')
{
    if (!$agency_user_id) {
        $agency_user_id = agency_id();
    }
    $where = agency_where($agency_user_id);
    $agency_shop_config = array();
    if ($where) {
        $agency_shop_config = $GLOBALS['db']->getAll("select code,value from " . $GLOBALS['ecs']->table('agency_shop_config') . "where 1 {$where}");
    }
    foreach ($agency_shop_config as $k => $v) {
        $GLOBALS['_CFG'][$v['code']] = $v['value'];
    }
    /* 特殊处理大学城地址不开放注册 
    	if(agency_url() == 'dxc.txd168.com')
    	{
    		$GLOBALS['_CFG']['anonymous_buy'] = '0';
    	}*/
}
Example #7
0
function get_stock_control_log()
{
    $result = get_filter();
    if ($result === false) {
        $filter = array();
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        $filter['delete'] = empty($_REQUEST['delete']) ? '' : trim($_REQUEST['delete']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
        /*add by ccx  for date 2014-11-27		只显示代理商本身*/
        $where = agency_where();
        /*add by hg for date 2014-04-21 可选商品*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                $where .= " AND (a.admin_agency_id = {$filter['admin_agency_id']} ) ";
            } else {
                $where .= " AND (a.admin_agency_id = 0 ) ";
            }
        }
        if (!empty($filter['keyword'])) {
            $where .= " AND (a.goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'  or a.stock_info_sn LIKE '%" . mysql_like_quote($filter['keyword']) . "%' )";
        }
        if (empty($filter['delete'])) {
            $where .= ' AND stock_status !=3 ';
        }
        $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_goods') . ' AS a ' . 'WHERE 1 ' . $where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $filter = page_and_size($filter);
        /* 获取采购商品列表管理数据 */
        $sql = 'SELECT a.*  ' . 'FROM ' . $GLOBALS['ecs']->table('stock_goods') . ' AS a ' . 'WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order'];
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    //echo $sql;
    $arr = array();
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
    while ($rows = $GLOBALS['db']->fetchRow($res)) {
        $arr[] = $rows;
    }
    $overall_order_amount = overall_order_amount($sql);
    //总的计算
    $GLOBALS['smarty']->assign('costing_price_amount', price_format($overall_order_amount['costing_price_amount']));
    $GLOBALS['smarty']->assign('goods_number_amount', $overall_order_amount['goods_number_amount']);
    return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}
Example #8
0
/**
 * 获取订购信息
 *
 * @access  public
 *
 * @return array
 */
function get_bookinglist()
{
    /* 查询条件 */
    $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']);
    $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
    if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
        $filter['keywords'] = json_str_iconv($filter['keywords']);
    }
    $filter['dispose'] = empty($_REQUEST['dispose']) ? 0 : intval($_REQUEST['dispose']);
    $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'sort_order' : trim($_REQUEST['sort_by']);
    $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
    $where = !empty($_REQUEST['keywords']) ? " AND g.goods_name LIKE '%" . mysql_like_quote($filter['keywords']) . "%' " : '';
    $where .= !empty($_REQUEST['dispose']) ? " AND bg.is_dispose = '{$filter['dispose']}' " : '';
    /*加入代理商条件*/
    if (!$filter['admin_agency_id']) {
        $agency_where = agency_where();
        if (!$agency_where) {
            $agency_where = "AND bg.admin_agency_id = 0";
        } else {
            $arr = explode(' ', $agency_where);
            $arr[2] = 'bg.' . $arr[2];
            $agency_where = implode(' ', $arr);
        }
    } else {
        $agency_where = " AND bg.admin_agency_id = {$filter['admin_agency_id']}";
    }
    $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('booking_goods') . ' AS bg, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE bg.goods_id = g.goods_id {$where} {$agency_where}";
    $filter['record_count'] = $GLOBALS['db']->getOne($sql);
    /* 分页大小 */
    $filter = page_and_size($filter);
    /* 获取活动数据 */
    $sql = 'SELECT bg.rec_id, bg.link_man, g.goods_id, g.goods_name, bg.goods_number, bg.booking_time, bg.is_dispose ' . 'FROM ' . $GLOBALS['ecs']->table('booking_goods') . ' AS bg, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE bg.goods_id = g.goods_id {$where} {$agency_where} " . "ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . "LIMIT " . $filter['start'] . ", {$filter['page_size']}";
    $row = $GLOBALS['db']->getAll($sql);
    foreach ($row as $key => $val) {
        $row[$key]['booking_time'] = local_date($GLOBALS['_CFG']['time_format'], $val['booking_time']);
    }
    $filter['keywords'] = stripslashes($filter['keywords']);
    $arr = array('item' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #9
0
/**
 *
 *
 * @access  public
 * @param
 *
 * @return void
 */
function account_list()
{
    $result = get_filter();
    if ($result === false) {
        /*add by hg for date 2014-04-23 获取代理商信息 begin*/
        $filter['admin_agency_id'] = !empty($_REQUEST['admin_agency_id']) ? intval($_REQUEST['admin_agency_id']) : 0;
        $GLOBALS['smarty']->assign('agency_list', agency_list());
        $GLOBALS['smarty']->assign('admin_agency_id', $filter['admin_agency_id']);
        $action_list = if_agency() ? 'all' : '';
        $GLOBALS['smarty']->assign('all', $action_list);
        /*end*/
        /*时间*/
        //dump($filter);
        /* 过滤列表 */
        $filter['user_id'] = !empty($_REQUEST['user_id']) ? intval($_REQUEST['user_id']) : 0;
        $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keywords'] = json_str_iconv($filter['keywords']);
        }
        $filter['process_type'] = isset($_REQUEST['process_type']) ? intval($_REQUEST['process_type']) : -1;
        $filter['payment'] = empty($_REQUEST['payment']) ? '' : trim($_REQUEST['payment']);
        $filter['is_paid'] = isset($_REQUEST['is_paid']) ? intval($_REQUEST['is_paid']) : -1;
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'add_time' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['start_date'] = empty($_REQUEST['start_date']) ? local_strtotime('-7 days') : $_REQUEST['start_date'];
        $filter['end_date'] = empty($_REQUEST['end_date']) ? local_strtotime('today') : $_REQUEST['end_date'];
        if (strpos($filter['start_date'], '-')) {
            $filter['start_date'] = local_strtotime($filter['start_date']);
            $filter['end_date'] = local_strtotime($filter['end_date']);
        }
        $where = " WHERE 1 ";
        /*add by hg for date 2014-04-22 只显示代理商本身所属信息 begin*/
        $where .= agency_where();
        /*end*/
        if ($filter['user_id'] > 0) {
            $where .= " AND ua.user_id = '{$filter['user_id']}' ";
        }
        if ($filter['process_type'] != -1) {
            $where .= " AND ua.process_type = '{$filter['process_type']}' ";
        } else {
            $where .= " AND ua.process_type " . db_create_in(array(SURPLUS_SAVE, SURPLUS_RETURN));
        }
        if ($filter['payment']) {
            $where .= " AND ua.payment = '{$filter['payment']}' ";
        }
        if ($filter['is_paid'] != -1) {
            $where .= " AND ua.is_paid = '{$filter['is_paid']}' ";
        }
        if ($filter['keywords']) {
            $where .= " AND u.user_name LIKE '%" . mysql_like_quote($filter['keywords']) . "%'";
            $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('user_account') . " AS ua, " . $GLOBALS['ecs']->table('users') . " AS u " . $where;
        }
        /* 时间过滤 */
        if (!empty($filter['start_date']) && !empty($filter['end_date'])) {
            $where .= "AND add_time >= " . $filter['start_date'] . " AND add_time < '" . $filter['end_date'] . "'";
        }
        /*add by hg for date 2014-04-23 根据代理商筛选 begin*/
        if ($filter['admin_agency_id'] > 0 && if_agency()) {
            $where .= " AND ua.admin_agency_id  = '{$filter['admin_agency_id']}' ";
        }
        /*end*/
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('user_account') . " AS ua LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u on ua.user_id = u.user_id" . $where;
        //dump($sql);
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        /* 分页大小 */
        $filter = page_and_size($filter);
        /* 查询数据 */
        $sql = 'SELECT ua.*, u.user_name FROM ' . $GLOBALS['ecs']->table('user_account') . ' AS ua LEFT JOIN ' . $GLOBALS['ecs']->table('users') . ' AS u ON ua.user_id = u.user_id' . $where . "ORDER by " . $filter['sort_by'] . " " . $filter['sort_order'] . " LIMIT " . $filter['start'] . ", " . $filter['page_size'];
        $filter['keywords'] = stripslashes($filter['keywords']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $list = $GLOBALS['db']->getAll($sql);
    tongji($sql);
    foreach ($list as $key => $value) {
        $list[$key]['surplus_amount'] = price_format(abs($value['amount']), false);
        $list[$key]['add_date'] = local_date($GLOBALS['_CFG']['time_format'], $value['add_time']);
        $list[$key]['process_type_name'] = $GLOBALS['_LANG']['surplus_type_' . $value['process_type']];
    }
    $GLOBALS['smarty']->assign('start_date', local_date('Y-m-d', $filter['start_date']));
    $GLOBALS['smarty']->assign('end_date', local_date('Y-m-d', $filter['end_date']));
    $filter['start_date'] = local_date('Y-m-d', $filter['start_date']);
    $filter['end_date'] = local_date('Y-m-d', $filter['end_date']);
    $arr = array('list' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #10
0
function group_buy_list()
{
    $result = get_filter();
    if ($result === false) {
        /* 过滤条件 */
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'act_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        /*加入代理商条件*/
        if (!$filter['admin_agency_id']) {
            $agency_where = agency_where();
            if (!$agency_where) {
                $agency_where = "AND admin_agency_id = 0";
            }
        } else {
            $agency_where = " AND admin_agency_id = {$filter['admin_agency_id']}";
        }
        $where = !empty($filter['keyword']) ? " AND goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'" : '';
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type = '" . GAT_GROUP_BUY . "' {$where}  {$agency_where}";
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        /* 分页大小 */
        $filter = page_and_size($filter);
        /* 查询 */
        $sql = "SELECT * " . "FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type = '" . GAT_GROUP_BUY . "' {$where} {$agency_where}" . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . $filter['start'] . ", {$filter['page_size']}";
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $res = $GLOBALS['db']->query($sql);
    $list = array();
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        $ext_info = unserialize($row['ext_info']);
        $stat = group_buy_stat($row['act_id'], $ext_info['deposit']);
        $arr = array_merge($row, $stat, $ext_info);
        /* 处理价格阶梯 */
        $price_ladder = $arr['price_ladder'];
        if (!is_array($price_ladder) || empty($price_ladder)) {
            $price_ladder = array(array('amount' => 0, 'price' => 0));
        } else {
            foreach ($price_ladder as $key => $amount_price) {
                $price_ladder[$key]['formated_price'] = price_format($amount_price['price']);
            }
        }
        /* 计算当前价 */
        $cur_price = $price_ladder[0]['price'];
        // 初始化
        $cur_amount = $stat['valid_goods'];
        // 当前数量
        foreach ($price_ladder as $amount_price) {
            if ($cur_amount >= $amount_price['amount']) {
                $cur_price = $amount_price['price'];
            } else {
                break;
            }
        }
        $arr['cur_price'] = $cur_price;
        $status = group_buy_status($arr);
        $arr['start_time'] = local_date($GLOBALS['_CFG']['date_format'], $arr['start_time']);
        $arr['end_time'] = local_date($GLOBALS['_CFG']['date_format'], $arr['end_time']);
        $arr['cur_status'] = $GLOBALS['_LANG']['gbs'][$status];
        $list[] = $arr;
    }
    $arr = array('item' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #11
0
/**
 * 获取活动列表
 *
 * @access  public
 *
 * @return void
 */
function get_snatchlist()
{
    $result = get_filter();
    if ($result === false) {
        /* 查询条件 */
        $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keywords'] = json_str_iconv($filter['keywords']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'act_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        /*add by hg for date 2014-05-08 获取代理商信息 begin*/
        $admin_agency_id = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : '0';
        //dump($admin_agency_id);
        $agency_list = agency_list();
        $GLOBALS['smarty']->assign('agency_list', $agency_list);
        $GLOBALS['smarty']->assign('admin_agency_id', $admin_agency_id);
        $action_list = if_agency() ? 'all' : '';
        $GLOBALS['smarty']->assign('all', $action_list);
        /*end*/
        //根据代理商过滤信息
        $where = agency_where();
        $where .= !empty($filter['keywords']) ? " AND act_name like '%" . mysql_like_quote($filter['keywords']) . "%'" : '';
        /*add by hg for date 2014-05-08 根据代理商筛选  begin*/
        if (if_agency() && !empty($admin_agency_id)) {
            $where .= " AND admin_agency_id = '{$admin_agency_id}' ";
        } elseif (if_agency()) {
            $where .= " AND admin_agency_id = '0' ";
        }
        /*end*/
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type =" . GAT_SNATCH . $where;
        //dump($sql);
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $filter = page_and_size($filter);
        /* 获活动数据 */
        $sql = "SELECT act_id, act_name AS snatch_name, goods_name, start_time, end_time, is_finished, ext_info, product_id " . " FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type = " . GAT_SNATCH . $where . " ORDER by {$filter['sort_by']} {$filter['sort_order']} LIMIT " . $filter['start'] . ", " . $filter['page_size'];
        $filter['keywords'] = stripslashes($filter['keywords']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $row = $GLOBALS['db']->getAll($sql);
    foreach ($row as $key => $val) {
        $row[$key]['start_time'] = local_date($GLOBALS['_CFG']['time_format'], $val['start_time']);
        $row[$key]['end_time'] = local_date($GLOBALS['_CFG']['time_format'], $val['end_time']);
        $info = unserialize($row[$key]['ext_info']);
        unset($row[$key]['ext_info']);
        if ($info) {
            foreach ($info as $info_key => $info_val) {
                $row[$key][$info_key] = $info_val;
            }
        }
    }
    $arr = array('snatchs' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #12
0
/**
 * 取得销售明细数据信息
 * @param   bool  $is_pagination  是否分页
 * @return  array   销售明细数据
 */
function get_sale_list($is_pagination = true)
{
    /* 时间参数 */
    $filter['start_date'] = empty($_REQUEST['start_date']) ? local_strtotime('-7 days') : local_strtotime($_REQUEST['start_date']);
    $filter['end_date'] = empty($_REQUEST['end_date']) ? local_strtotime('today') : local_strtotime($_REQUEST['end_date']);
    /*add by hg for date 2014-04-23 获取代理商信息 begin*/
    $filter['admin_agency_id'] = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : '0';
    /*add by ccx for date 2014-11-12 获取支付类型payment_method*/
    $filter['payment_method'] = empty($_REQUEST['payment_method']) ? '' : trim($_REQUEST['payment_method']);
    /*end*/
    $res = agency_list();
    $agency_list = array('-' => '全站');
    foreach ($res as $re_k => $res_v) {
        $agency_list[$re_k] = $res_v;
    }
    $GLOBALS['smarty']->assign('agency_list', $agency_list);
    $GLOBALS['smarty']->assign('admin_agency_id', $filter['admin_agency_id']);
    $action_list = if_agency() ? 'all' : '';
    $GLOBALS['smarty']->assign('all', $action_list);
    /*end*/
    /*add by hg for date 2014-04-22		加入代理商条件*/
    $agency_where = agency_where();
    if (!empty($agency_where)) {
        $whereArr = explode(' ', $agency_where);
        $sale_where = $whereArr[0] . $whereArr[1] . ' oi.' . $whereArr[2] . $whereArr[3] . $whereArr[4];
    }
    /*end*/
    /* 查询数据的条件 */
    $where = " WHERE og.order_id = oi.order_id" . order_query_sql('finished', 'oi.') . " AND oi.add_time >= '" . $filter['start_date'] . "' \r\n               AND oi.add_time < '" . ($filter['end_date'] + 86400) . "'{$sale_where}";
    /*add by hg for date 2014-04-23 根据代理商筛选  begin*/
    if (!empty($filter['admin_agency_id']) && if_agency()) {
        if ($filter['admin_agency_id'] != '-') {
            $where .= " AND oi.admin_agency_id = " . $filter['admin_agency_id'];
        }
    } elseif (if_agency()) {
        $where .= " AND admin_agency_id = '0' ";
    }
    /*en
    	/*end*/
    /*add by ccx for date 2014-11-12  根据选择支付类型(余额支付,货到付款,在线支付三种)筛选  begin*/
    if ($filter['payment_method']) {
        //$where .= " AND o.pay_id  = '$filter[payment_method]'";
        if ($filter['payment_method'] == 3) {
            $where .= " AND ( oi.pay_id !=1 AND oi.pay_id !=2 AND oi.pay_id !=0)";
        } elseif ($filter['payment_method'] == 1) {
            $where .= " AND oi.pay_id  = 1";
        } elseif ($filter['payment_method'] == 2) {
            $where .= " AND oi.pay_id  = 2";
        }
    }
    /*end*/
    $sql = "SELECT COUNT(og.goods_id) FROM " . $GLOBALS['ecs']->table('order_info') . ' AS oi,' . $GLOBALS['ecs']->table('order_goods') . ' AS og ' . $where;
    $filter['record_count'] = $GLOBALS['db']->getOne($sql);
    /* 分页大小 */
    $filter = page_and_size($filter);
    /* modify by SouthBear 2014-12-04 16:13:04
     * 增加 oi.order_amount, oi.goods_amount order_amount 字段用途不明,TABLE中无数据
     */
    $sql = 'SELECT og.goods_id, og.costing_price,og.goods_sn, og.goods_name, og.goods_number AS goods_num, 
    		og.goods_price AS sales_price, oi.add_time AS sales_time, oi.order_id, oi.order_sn,oi.order_amount,
    		oi.goods_amount , og.stock_costing_price ' . "FROM " . $GLOBALS['ecs']->table('order_goods') . " AS og, " . $GLOBALS['ecs']->table('order_info') . " AS oi " . $where . " ORDER BY sales_time DESC, goods_num DESC";
    $statistics_sql = $sql;
    if ($is_pagination) {
        $sql .= " LIMIT " . $filter['start'] . ', ' . $filter['page_size'];
    }
    $sale_list_data = $GLOBALS['db']->getAll($sql);
    /* modify by SouthBear 2014-12-04 16:13:04
     * 将订单成本和订单金额重新计算
     */
    //if (count($sale_list_data) > 0) {
    foreach ($sale_list_data as $key => $item) {
        //$sale_list_data[$key]['profit_total'] = price_format(($sale_list_data[$key]['sales_price'] - $sale_list_data[$key]['costing_price'])*$sale_list_data[$key]['goods_num']); //利润
        /*ccx 2014-12-10 订单商品的利润*/
        $sale_list_data[$key]['profit_total'] = price_format($sale_list_data[$key]['sales_price'] * $sale_list_data[$key]['goods_num'] - $sale_list_data[$key]['stock_costing_price']);
        //利润
        $sale_list_data[$key]['unit_sales_price'] = price_format($sale_list_data[$key]['sales_price']);
        //订单单价
        //成本
        $sale_list_data[$key]['unit_costing_price'] = price_format($sale_list_data[$key]['costing_price']);
        //成本单价
        //$sale_list_data[$key]['order_costing_price'] = price_format($sale_list_data[$key]['costing_price'] * $sale_list_data[$key]['goods_num']); //订单成本
        /*ccx 2014-12-10 ccx 读取订单商品表新建的库存商品成本总价*/
        $sale_list_data[$key]['order_costing_price'] = $sale_list_data[$key]['stock_costing_price'];
        //订单成本总价
        //订单总金额
        $sale_list_data[$key]['goods_amount'] = price_format($sale_list_data[$key]['sales_price'] * $sale_list_data[$key]['goods_num']);
        $sale_list_data[$key]['sales_time'] = local_date($GLOBALS['_CFG']['time_format'], $sale_list_data[$key]['sales_time']);
    }
    $statistics = statistics($statistics_sql);
    $arr = array('sale_list_data' => $sale_list_data, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count'], 'statistics' => $statistics);
    //} else {
    //	$arr = false;
    //}
    return $arr;
}
Example #13
0
/**
 *  获取发货单列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function delivery_list()
{
    $result = get_filter();
    if ($result === false) {
        /* 过滤信息 */
        $filter['order_sn'] = empty($_REQUEST['order_sn']) ? '' : trim($_REQUEST['order_sn']);
        if (!empty($_GET['is_ajax']) && $_GET['is_ajax'] == 1) {
            $_REQUEST['consignee'] = json_str_iconv($_REQUEST['consignee']);
            //$_REQUEST['address'] = json_str_iconv($_REQUEST['address']);
        }
        /*add by hg for date 2014-04-23 获取代理商id begin*/
        $filter['admin_agency_id'] = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : 0;
        /*end*/
        /*add by ccx for date 2014-11-12 获取支付类型payment_method*/
        $filter['payment_method'] = empty($_REQUEST['payment_method']) ? '' : trim($_REQUEST['payment_method']);
        /*end*/
        $filter['start_date'] = empty($_REQUEST['start_date']) ? local_strtotime('-360 days') : $_REQUEST['start_date'];
        $filter['end_date'] = empty($_REQUEST['end_date']) ? local_strtotime('today') : $_REQUEST['end_date'];
        if (strpos($filter['start_date'], '-') !== false) {
            $filter['start_date'] = local_strtotime($filter['start_date']);
            $filter['end_date'] = local_strtotime($filter['end_date']);
        }
        //dump(date('Y-m-d H-i-s',$filter['end_date']));
        $filter['pay_id'] = empty($_REQUEST['pay_id']) ? 0 : intval($_REQUEST['pay_id']);
        $filter['order_status'] = isset($_REQUEST['order_status']) ? intval($_REQUEST['order_status']) : -1;
        $filter['shipping_status'] = isset($_REQUEST['shipping_status']) ? intval($_REQUEST['shipping_status']) : -1;
        $filter['pay_status'] = isset($_REQUEST['pay_status']) ? intval($_REQUEST['pay_status']) : -1;
        $filter['user_id'] = empty($_REQUEST['user_id']) ? 0 : intval($_REQUEST['user_id']);
        $filter['user_name'] = empty($_REQUEST['user_name']) ? '' : trim($_REQUEST['user_name']);
        $filter['composite_status'] = isset($_REQUEST['composite_status']) ? intval($_REQUEST['composite_status']) : -1;
        $filter['group_buy_id'] = isset($_REQUEST['group_buy_id']) ? intval($_REQUEST['group_buy_id']) : 0;
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'add_time' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['start_time'] = empty($_REQUEST['start_time']) ? '' : (strpos($_REQUEST['start_time'], '-') > 0 ? local_strtotime($_REQUEST['start_time']) : $_REQUEST['start_time']);
        $filter['end_time'] = empty($_REQUEST['end_time']) ? '' : (strpos($_REQUEST['end_time'], '-') > 0 ? local_strtotime($_REQUEST['end_time']) : $_REQUEST['end_time']);
        $where = 'WHERE 1 ';
        /*add by hg for date 2014-04-22 只显示代理商本身所属订单 begin*/
        $where .= agency_where();
        /*end*/
        if ($filter['order_sn']) {
            $where .= " AND o.order_sn LIKE '%" . mysql_like_quote($filter['order_sn']) . "%'";
        }
        if ($filter['consignee']) {
            $where .= " AND o.consignee LIKE '%" . mysql_like_quote($filter['consignee']) . "%'";
        }
        if ($filter['email']) {
            $where .= " AND o.email LIKE '%" . mysql_like_quote($filter['email']) . "%'";
        }
        if ($filter['address']) {
            $where .= " AND o.address LIKE '%" . mysql_like_quote($filter['address']) . "%'";
        }
        if ($filter['zipcode']) {
            $where .= " AND o.zipcode LIKE '%" . mysql_like_quote($filter['zipcode']) . "%'";
        }
        if ($filter['tel']) {
            $where .= " AND o.tel LIKE '%" . mysql_like_quote($filter['tel']) . "%'";
        }
        if ($filter['mobile']) {
            $where .= " AND o.mobile LIKE '%" . mysql_like_quote($filter['mobile']) . "%'";
        }
        if ($filter['country']) {
            $where .= " AND o.country = '{$filter['country']}'";
        }
        if ($filter['province']) {
            $where .= " AND o.province = '{$filter['province']}'";
        }
        if ($filter['city']) {
            $where .= " AND o.city = '{$filter['city']}'";
        }
        if ($filter['district']) {
            $where .= " AND o.district = '{$filter['district']}'";
        }
        if ($filter['shipping_id']) {
            $where .= " AND o.shipping_id  = '{$filter['shipping_id']}'";
        }
        if ($filter['pay_id']) {
            $where .= " AND o.pay_id  = '{$filter['pay_id']}'";
        }
        /* ccx 2014-11-12  增加了对支付类型的搜索功能*/
        if ($filter['payment_method']) {
            //$where .= " AND o.pay_id  = '$filter[payment_method]'";
            if ($filter['payment_method'] == 3) {
                $where .= " AND ( o.pay_id !=1 AND o.pay_id !=2 AND o.pay_id !=0)";
            } elseif ($filter['payment_method'] == 1) {
                $where .= " AND o.pay_id  = 1";
            } elseif ($filter['payment_method'] == 2) {
                $where .= " AND o.pay_id  = 2";
            }
        }
        if ($filter['order_status'] != -1) {
            $where .= " AND o.order_status  = '{$filter['order_status']}'";
        }
        if ($filter['shipping_status'] != -1) {
            $where .= " AND o.shipping_status = '{$filter['shipping_status']}'";
        }
        if ($filter['pay_status'] != -1) {
            $where .= " AND o.pay_status = '{$filter['pay_status']}'";
        }
        if ($filter['user_id']) {
            $where .= " AND o.user_id = '{$filter['user_id']}'";
        }
        if ($filter['user_name']) {
            $where .= " AND u.user_name LIKE '%" . mysql_like_quote($filter['user_name']) . "%'";
        }
        //对已进行收费确认的订单进行分润处理
        $where .= " AND o.order_status =5 AND o.shipping_status = 2 AND o.pay_status = 2 ";
        /*add by hg for date 2014-04-23 根据代理商筛选 begin*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                if ($filter['admin_agency_id'] != '-') {
                    $where .= " AND o.admin_agency_id = {$filter['admin_agency_id']}";
                } else {
                    $GLOBALS['smarty']->assign('show_agency', true);
                    //查询整站订单
                }
            } else {
                $where .= " AND o.admin_agency_id != 0";
            }
        }
        /*end*/
        //综合状态
        switch ($filter['composite_status']) {
            case CS_AWAIT_PAY:
                $where .= order_query_sql('await_pay');
                break;
            case CS_AWAIT_SHIP:
                $where .= order_query_sql('await_ship');
                break;
            case CS_FINISHED:
                $where .= order_query_sql('finished');
                break;
            case PS_PAYING:
                if ($filter['composite_status'] != -1) {
                    $where .= " AND o.pay_status = '{$filter['composite_status']}' ";
                }
                break;
            case OS_SHIPPED_PART:
                if ($filter['composite_status'] != -1) {
                    $where .= " AND o.shipping_status  = '{$filter['composite_status']}'-2 ";
                }
                break;
            default:
                if ($filter['composite_status'] != -1) {
                    $where .= " AND o.order_status = '{$filter['composite_status']}' ";
                }
        }
        /* 团购订单 */
        if ($filter['group_buy_id']) {
            $where .= " AND o.extension_code = 'group_buy' AND o.extension_id = '{$filter['group_buy_id']}' ";
        }
        /* 如果管理员属于某个办事处,只列出这个办事处管辖的订单 */
        $sql = "SELECT agency_id FROM " . $GLOBALS['ecs']->table('admin_user') . " WHERE user_id = '{$_SESSION['admin_id']}'";
        $agency_id = $GLOBALS['db']->getOne($sql);
        if ($agency_id > 0) {
            $where .= " AND o.agency_id = '{$agency_id}' ";
        }
        /* 分页大小 */
        $filter['page'] = empty($_REQUEST['page']) || intval($_REQUEST['page']) <= 0 ? 1 : intval($_REQUEST['page']);
        if (isset($_REQUEST['page_size']) && intval($_REQUEST['page_size']) > 0) {
            $filter['page_size'] = intval($_REQUEST['page_size']);
        } elseif (isset($_COOKIE['ECSCP']['page_size']) && intval($_COOKIE['ECSCP']['page_size']) > 0) {
            $filter['page_size'] = intval($_COOKIE['ECSCP']['page_size']);
        } else {
            $filter['page_size'] = 15;
        }
        /* 记录总数 */
        if ($filter['user_name']) {
            $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('order_info') . " AS o ," . $GLOBALS['ecs']->table('users') . " AS u " . $where;
        } else {
            $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . $where;
        }
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        /* 查询 */
        $sql = "SELECT o.order_id, o.order_sn,o.add_time, o.order_status, o.shipping_status, " . "o.order_amount, o.money_paid,IFNULL(a.user_name, '主站') AS admin_user," . "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer , o.is_separate, o.user_id , o.admin_agency_id " . " FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u ON u.user_id=o.user_id LEFT JOIN " . $GLOBALS['ecs']->table('admin_user') . " as a ON a.agency_user_id=o.admin_agency_id " . $where . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
        foreach (array('order_sn', 'consignee', 'email', 'address', 'zipcode', 'tel', 'user_name') as $val) {
            $filter[$val] = stripslashes($filter[$val]);
        }
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $row = $GLOBALS['db']->getAll($sql);
    //print_r($row);
    /* 格式话数据 */
    foreach ($row as $key => $value) {
        $user_number = get_user_number($value['user_id']);
        //print_r($user_number); echo "<br>";
        $v2_message = 0;
        foreach ($user_number as $k => $v1) {
            $user_rank = $v1['user_rank'];
            $top_rank = $v1['top_rank'];
            //echo $user_rank;echo "ab";echo "<br>";
            if ($user_rank == 4) {
                $v1_message = $v1['user_id'];
                //判断是否是代理商
            }
            //if($user_rank == 36 )    //内网的V2等级是36
            if ($user_rank == 40) {
                $v2_message = 1;
                //判断是V2  1:表示存在V2,就可以参与分润了
                $sql = "SELECT user_name FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = " . $v1['user_id'];
                $user_name = $GLOBALS['db']->getOne($sql);
            }
            if ($top_rank == $value['admin_agency_id']) {
                $v1_message = $v1['top_rank'];
                //
            }
        }
        if ($v1_message != $value['admin_agency_id'] || $v2_message != 1) {
            //print_r($row[$key]);echo "<br>";
            unset($row[$key]);
            array_values($row);
            $filter['record_count'] = $filter['record_count'] - 1;
            //$filter['page_count']     = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
        } else {
            array_values($row);
            $sql = "SELECT el.order_id , el.money, g.goods_name, el.change_time FROM " . $GLOBALS['ecs']->table('earnings_log') . " AS el " . " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON el.goods_id = g.goods_id " . " WHERE order_id = " . $value['order_id'];
            //$stat = $GLOBALS['db']->getRow($sql);
            $stat = $GLOBALS['db']->getAll($sql);
            $money_message = "";
            $count_money = "";
            if ($stat) {
                foreach ($stat as $ab => $stat_value) {
                    $money_message = $money_message . $stat_value['goods_name'] . ":" . $stat_value['money'] . "&nbsp;";
                    $count_money = $count_money + $stat_value['money'];
                    $change_time = $stat_value['change_time'];
                }
                $row[$key]['stat_fenrun'] = "1";
                //$row[$key]['info'] = "V2(推广商)获得的分润:". $stat['money']."元";
                $row[$key]['info'] = "V2(推广商)" . $user_name . "获得的分润:" . $count_money . "<br> (&nbsp; " . $money_message . ')';
                $row[$key]['change_time'] = local_date('m-d H:i', $change_time);
            } else {
                $row[$key]['stat_fenrun'] = "2";
                $row[$key]['info'] = "";
            }
            $row[$key]['formated_order_amount'] = price_format($value['order_amount']);
            $row[$key]['formated_money_paid'] = price_format($value['money_paid']);
            $row[$key]['formated_total_fee'] = price_format($value['total_fee']);
            $row[$key]['short_order_time'] = local_date('m-d H:i', $value['add_time']);
            if ($value['order_status'] == OS_INVALID || $value['order_status'] == OS_CANCELED) {
                /* 如果该订单为无效或取消则显示删除链接 */
                $row[$key]['can_remove'] = 1;
            } else {
                $row[$key]['can_remove'] = 0;
            }
        }
    }
    $filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
    //print_r($row);
    //array_values($row);
    $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #14
0
function get_goods_stock_info()
{
    $result = get_filter();
    if ($result === false) {
        $filter = array();
        $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        $filter['status'] = strval(trim($_REQUEST['status']));
        //m1
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $where = agency_where();
        /*add by hg for date 2014-04-21 可选商品*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                $where .= " AND (a.admin_agency_id = {$filter['admin_agency_id']} ) ";
            } else {
                $where .= " AND (a.admin_agency_id = 0 ) ";
            }
        }
        //m1 增加采购订单查询条件
        if (strlen(trim($_REQUEST['status'])) > 0) {
            $where .= " AND (a.stock_status = " . $filter['status'] . " ) ";
        }
        if (!empty($filter['keyword'])) {
            $where .= " AND (a.stock_info_sn LIKE '%" . mysql_like_quote($filter['keyword']) . "%' )";
        }
        $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_info') . ' AS a ' . 'WHERE 1 ' . $where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $filter = page_and_size($filter);
        /* 获取采购商品列表管理数据 */
        $sql = 'SELECT a.*  ' . 'FROM ' . $GLOBALS['ecs']->table('stock_info') . ' AS a ' . 'WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order'];
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    //echo $sql.'<br/>';
    $arr = array();
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
    while ($rows = $GLOBALS['db']->fetchRow($res)) {
        $arr[] = $rows;
    }
    //显示采购订单的相关信息:包括库存数量,以及采购总价,当页的采购价格等等
    $sql_limit = $sql . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
    $overall_order_amount = overall_order_amount($sql);
    //总的计算
    $current_order_amount = current_order_amount($sql_limit);
    // 当前页的计算
    $GLOBALS['smarty']->assign('costing_price_amount', price_format($overall_order_amount['costing_price_amount']));
    $GLOBALS['smarty']->assign('goods_number_amount', $overall_order_amount['goods_number_amount']);
    $GLOBALS['smarty']->assign('current_costing_price_amount', price_format($current_order_amount['current_costing_price_amount']));
    $GLOBALS['smarty']->assign('current_goods_number_amount', $current_order_amount['current_goods_number_amount']);
    return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}
Example #15
0
/**
 * 取得订单概况数据(包括订单的几种状态)
 * @param       $start_date    开始查询的日期
 * @param       $end_date      查询的结束日期
 * @return      $order_info    订单概况数据
 */
function get_orderinfo($start_date, $end_date)
{
    /*add by hg for date 2014-04-23 获取代理商信息与根据代理商筛选 begin*/
    $admin_agency_id = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : '0';
    $res = agency_list();
    $agency_list = array('-' => '全站订单统计');
    foreach ($res as $re_k => $res_v) {
        $agency_list[$re_k] = $res_v;
    }
    $GLOBALS['smarty']->assign('agency_list', $agency_list);
    $GLOBALS['smarty']->assign('admin_agency_id', $admin_agency_id);
    $action_list = if_agency() ? 'all' : '';
    $GLOBALS['smarty']->assign('all', $action_list);
    if (!empty($admin_agency_id) && if_agency()) {
        if ($admin_agency_id != '-') {
            $agency_where = " AND admin_agency_id = '{$admin_agency_id}' ";
        }
    } elseif (if_agency()) {
        $agency_where = " AND admin_agency_id = '0' ";
    }
    /*end*
    	
        $order_info = array();
    	/*add by hg for date 2014-04-22		获取客户统计信息加入条件判定为当前代理商下的客户信息*/
    $where = agency_where();
    /*end*/
    /* 未确认订单数 */
    $sql = 'SELECT COUNT(*) AS unconfirmed_num FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_status = '" . OS_UNCONFIRMED . "' AND add_time >= '{$start_date}'" . " AND add_time < '" . ($end_date + 86400) . "' {$where} {$agency_where}";
    $order_info['unconfirmed_num'] = $GLOBALS['db']->getOne($sql);
    /* 已确认订单数 */
    $sql = 'SELECT COUNT(*) AS confirmed_num FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_status IN (1,5) AND shipping_status IN (0,5) AND pay_status IN (2,0) AND add_time >= '{$start_date}'" . " AND add_time < '" . ($end_date + 86400) . "' {$where} {$agency_where}";
    // dump($sql);
    $order_info['confirmed_num'] = $GLOBALS['db']->getOne($sql);
    /* 已成交订单数 */
    $sql = 'SELECT COUNT(*) AS succeed_num FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE 1 " . order_query_sql('finished') . " AND add_time >= '{$start_date}' AND add_time < '" . ($end_date + 86400) . "' {$where} {$agency_where}";
    $order_info['succeed_num'] = $GLOBALS['db']->getOne($sql);
    /* 无效或已取消订单数 */
    $sql = "SELECT COUNT(*) AS invalid_num FROM " . $GLOBALS['ecs']->table('order_info') . " WHERE order_status IN ('2','4','3') {$where} {$agency_where}" . " AND add_time >= '{$start_date}' AND add_time < '" . ($end_date + 86400) . "'";
    $order_info['invalid_num'] = $GLOBALS['db']->getOne($sql);
    return $order_info;
}
Example #16
0
function get_stock_control_log()
{
    $result = get_filter();
    if ($result === false) {
        $filter = array();
        $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['start_date'] = empty($_REQUEST['start_date']) ? local_strtotime('-30 days') : $_REQUEST['start_date'];
        $filter['end_date'] = empty($_REQUEST['end_date']) ? local_strtotime('today') : $_REQUEST['end_date'];
        if (strpos($filter['start_date'], '-') !== false) {
            $filter['start_date'] = local_strtotime($filter['start_date']);
            $filter['end_date'] = local_strtotime($filter['end_date']);
        }
        $where = ' AND stock_status = 1 ';
        $where .= agency_where();
        /*add by ccx for date 2014-11-28 商品入库列表*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                $where .= " AND (a.admin_agency_id = {$filter['admin_agency_id']} ) ";
            } else {
                $where .= " AND (a.admin_agency_id = 0 ) ";
            }
        }
        if (!empty($filter['keyword'])) {
            $where = $where . " AND (a.goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'  or a.stock_number LIKE '%" . mysql_like_quote($filter['keyword']) . "%' )";
        }
        if ($filter['start_date']) {
            $where = $where . " AND a.log_time >= '{$filter['start_date']}'";
        }
        if ($filter['end_date']) {
            $where = $where . " AND a.log_time <= '" . ($filter['end_date'] + 86400) . "'";
        }
        $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_control_log') . ' AS a ' . 'WHERE 1 ' . $where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $filter = page_and_size($filter);
        /* 获取库存日志管理数据 */
        $sql = 'SELECT a.*  ' . 'FROM ' . $GLOBALS['ecs']->table('stock_control_log') . ' AS a ' . 'WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order'];
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $arr = array();
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
    while ($rows = $GLOBALS['db']->fetchRow($res)) {
        $rows['date'] = local_date($GLOBALS['_CFG']['time_format'], $rows['log_time']);
        $arr[] = $rows;
    }
    $GLOBALS['smarty']->assign('start_date', local_date('Y-m-d', $filter['start_date']));
    $GLOBALS['smarty']->assign('end_date', local_date('Y-m-d', $filter['end_date']));
    //显示商品的入库成本入库数量相关信息
    $sql_limit = $sql . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
    $overall_order_amount = overall_order_amount($sql);
    //总的计算
    $current_order_amount = current_order_amount($sql_limit);
    // 当前页的计算
    $GLOBALS['smarty']->assign('costing_price_amount', price_format($overall_order_amount['costing_price_amount']));
    $GLOBALS['smarty']->assign('goods_number_amount', $overall_order_amount['goods_number_amount']);
    $GLOBALS['smarty']->assign('current_costing_price_amount', price_format($current_order_amount['current_costing_price_amount']));
    $GLOBALS['smarty']->assign('current_goods_number_amount', $current_order_amount['current_goods_number_amount']);
    $filter['start_date'] = local_date('Y-m-d', $filter['start_date']);
    $filter['end_date'] = local_date('Y-m-d', $filter['end_date']);
    return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}
Example #17
0
function get_user_orderinfo($is_pagination = true)
{
    global $db, $ecs, $start_date, $end_date;
    $filter['start_date'] = empty($_REQUEST['start_date']) ? $start_date : local_strtotime($_REQUEST['start_date']);
    $filter['end_date'] = empty($_REQUEST['end_date']) ? $end_date : local_strtotime($_REQUEST['end_date']);
    $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'order_num' : trim($_REQUEST['sort_by']);
    $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
    /*add by hg for date 2014-04-23 获取代理商信息 begin*/
    $admin_agency_id = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : '0';
    $res = agency_list();
    $agency_list = array('-' => '全站会员排行');
    foreach ($res as $re_k => $res_v) {
        $agency_list[$re_k] = $res_v;
    }
    $GLOBALS['smarty']->assign('agency_list', $agency_list);
    $GLOBALS['smarty']->assign('admin_agency_id', $admin_agency_id);
    $action_list = if_agency() ? 'all' : '';
    $GLOBALS['smarty']->assign('all', $action_list);
    /*end*/
    /*add by hg for date 2014-04-22		获取客户统计信息加入条件判定为当前代理商下的客户信息*/
    $user_order_where = agency_where();
    if (!empty($user_order_where)) {
        $whereArr = explode(' ', $user_order_where);
        $user_order_where = $whereArr[0] . $whereArr[1] . ' o.' . $whereArr[2] . $whereArr[3] . $whereArr[4];
    }
    /*end*/
    $where = "WHERE u.user_id = o.user_id " . "AND u.user_id > 0 " . order_query_sql('finished', 'o.');
    if ($filter['start_date']) {
        $where .= " AND o.add_time >= '" . $filter['start_date'] . "'";
    }
    if ($filter['end_date']) {
        $where .= " AND o.add_time <= '" . $filter['end_date'] . "'";
    }
    /*add by hg for date 2014-04-23 根据代理商筛选  begin*/
    if (!empty($admin_agency_id) && if_agency()) {
        if ($admin_agency_id != '-') {
            $where .= " AND o.admin_agency_id = '{$admin_agency_id}' ";
        }
    } elseif (if_agency()) {
        $where .= " AND admin_agency_id = '0' ";
    }
    /*end*/
    $sql = "SELECT count(distinct(u.user_id)) FROM " . $ecs->table('users') . " AS u, " . $ecs->table('order_info') . " AS o " . $where . $user_order_where;
    $filter['record_count'] = $GLOBALS['db']->getOne($sql);
    /* 分页大小 */
    $filter = page_and_size($filter);
    /* 计算订单各种费用之和的语句 */
    $total_fee = " SUM(" . order_amount_field() . ") AS turnover ";
    $sql = "SELECT u.user_id, u.user_name, COUNT(*) AS order_num, " . $total_fee . "FROM " . $ecs->table('users') . " AS u, " . $ecs->table('order_info') . " AS o " . $where . $user_order_where . " GROUP BY u.user_id" . " ORDER BY " . $filter['sort_by'] . " " . $filter['sort_order'];
    if ($is_pagination) {
        $sql .= " LIMIT " . $filter['start'] . ', ' . $filter['page_size'];
    }
    $user_orderinfo = array();
    $res = $db->query($sql);
    while ($items = $db->fetchRow($res)) {
        $items['turnover'] = price_format($items['turnover']);
        $user_orderinfo[] = $items;
    }
    $arr = array('user_orderinfo' => $user_orderinfo, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #18
0
function get_auto_goods()
{
    $where = ' WHERE g.is_delete <> 1 ';
    /*add by hg for date 2014-04-22 只显示代理商本身所属订单 begin*/
    $where .= agency_where();
    /*end*/
    if (!empty($_POST['goods_name'])) {
        $goods_name = trim($_POST['goods_name']);
        $where .= " AND g.goods_name LIKE '%{$goods_name}%'";
        $filter['goods_name'] = $goods_name;
    }
    $result = get_filter();
    if ($result === false) {
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'last_update' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods') . " g" . $where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        /* 分页大小 */
        $filter = page_and_size($filter);
        /* 查询 */
        $sql = "SELECT g.*,a.starttime,a.endtime FROM " . $GLOBALS['ecs']->table('goods') . " g LEFT JOIN " . $GLOBALS['ecs']->table('auto_manage') . " a ON g.goods_id = a.item_id AND a.type='goods'" . $where . " ORDER by goods_id, " . $filter['sort_by'] . ' ' . $filter['sort_order'] . " LIMIT " . $filter['start'] . ",{$filter['page_size']}";
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $query = $GLOBALS['db']->query($sql);
    $goodsdb = array();
    while ($rt = $GLOBALS['db']->fetch_array($query)) {
        if (!empty($rt['starttime'])) {
            $rt['starttime'] = local_date('Y-m-d H:i', $rt['starttime']);
        }
        if (!empty($rt['endtime'])) {
            $rt['endtime'] = local_date('Y-m-d H:i', $rt['endtime']);
        }
        $goodsdb[] = $rt;
    }
    $arr = array('goodsdb' => $goodsdb, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #19
0
/**
 * 取得用户等级数组,按用户级别排序
 * @param   bool      $is_special      是否只显示特殊会员组
 * @return  array     rank_id=>rank_name
 */
function get_rank_list($is_special = false)
{
    /* 加入判断所属代理商条件 */
    $where = agency_where();
    if (!$where) {
        $where = ' AND admin_agency_id = 0';
    }
    $rank_list = array();
    $sql = 'SELECT rank_id, rank_name, min_points FROM ' . $GLOBALS['ecs']->table('user_rank') . " WHERE 1";
    if ($is_special) {
        $sql .= ' AND special_rank = 1';
    }
    $sql .= " {$where} ORDER BY min_points";
    $res = $GLOBALS['db']->query($sql);
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        $rank_list[$row['rank_id']] = $row['rank_name'];
    }
    return $rank_list;
}
Example #20
0
/**
 * 取得销售排行数据信息
 * @param   bool  $is_pagination  是否分页
 * @return  array   销售排行数据
 */
function get_sales_order($is_pagination = true)
{
    $filter['start_date'] = empty($_REQUEST['start_date']) ? '' : local_strtotime($_REQUEST['start_date']);
    $filter['end_date'] = empty($_REQUEST['end_date']) ? '' : local_strtotime($_REQUEST['end_date']);
    $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'goods_num' : trim($_REQUEST['sort_by']);
    $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
    /*add by hg for date 2014-04-23 获取代理商信息 begin*/
    $admin_agency_id = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : '0';
    $res = agency_list();
    $agency_list = array('-' => '全站销售排行');
    foreach ($res as $re_k => $res_v) {
        $agency_list[$re_k] = $res_v;
    }
    $GLOBALS['smarty']->assign('agency_list', $agency_list);
    $GLOBALS['smarty']->assign('admin_agency_id', $admin_agency_id);
    $action_list = if_agency() ? 'all' : '';
    $GLOBALS['smarty']->assign('all', $action_list);
    /*end*/
    /*add by hg for date 2014-04-22		加入代理商条件*/
    $agency_where = agency_where();
    if (!empty($agency_where)) {
        $whereArr = explode(' ', $agency_where);
        $sale_where = $whereArr[0] . $whereArr[1] . ' oi.' . $whereArr[2] . $whereArr[3] . $whereArr[4];
    }
    /*end*/
    $where = " WHERE og.order_id = oi.order_id " . order_query_sql('finished', 'oi.');
    if ($filter['start_date']) {
        $where .= " AND oi.add_time >= '" . $filter['start_date'] . "'";
    }
    if ($filter['end_date']) {
        $where .= " AND oi.add_time <= '" . $filter['end_date'] . "'";
    }
    /*add by hg for date 2014-04-23 根据代理商筛选  begin*/
    if (!empty($admin_agency_id) && if_agency()) {
        if ($admin_agency_id != '-') {
            $where .= " AND oi.admin_agency_id = '{$admin_agency_id}' ";
        }
    } elseif (if_agency()) {
        $where .= " AND oi.admin_agency_id = '0' ";
    }
    /*end*/
    $sql = "SELECT COUNT(distinct(og.goods_id)) FROM " . $GLOBALS['ecs']->table('order_info') . ' AS oi,' . $GLOBALS['ecs']->table('order_goods') . ' AS og ' . $where;
    $filter['record_count'] = $GLOBALS['db']->getOne($sql);
    /* 分页大小 */
    $filter = page_and_size($filter);
    $sql = "SELECT og.goods_id, og.goods_sn, og.goods_name, oi.order_status, " . "SUM(og.goods_number) AS goods_num, SUM(og.goods_number * og.goods_price) AS turnover " . "FROM " . $GLOBALS['ecs']->table('order_goods') . " AS og, " . $GLOBALS['ecs']->table('order_info') . " AS oi  " . $where . $sale_where . " GROUP BY og.goods_id " . ' ORDER BY ' . $filter['sort_by'] . ' ' . $filter['sort_order'];
    if ($is_pagination) {
        $sql .= " LIMIT " . $filter['start'] . ', ' . $filter['page_size'];
    }
    $sales_order_data = $GLOBALS['db']->getAll($sql);
    foreach ($sales_order_data as $key => $item) {
        $sales_order_data[$key]['wvera_price'] = price_format($item['goods_num'] ? $item['turnover'] / $item['goods_num'] : 0);
        $sales_order_data[$key]['short_name'] = sub_str($item['goods_name'], 30, true);
        $sales_order_data[$key]['turnover'] = price_format($item['turnover']);
        $sales_order_data[$key]['taxis'] = $key + 1;
    }
    $arr = array('sales_order_data' => $sales_order_data, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #21
0
/**
 * 取得访问和购买次数统计数据
 *
 * @param   int             $cat_id          分类编号
 * @param   int             $brand_id        品牌编号
 * @param   int             $show_num        显示个数
 * @return  array           $click_sold_info  访问购买比例数据
 */
function click_sold_info($cat_id, $brand_id, $show_num, $admin_agency_id)
{
    global $db, $ecs;
    /*add by hg for date 2014-04-22		加入代理商条件*/
    $agency_where = agency_where();
    if (!empty($agency_where)) {
        $whereArr = explode(' ', $agency_where);
        $sale_where = $whereArr[0] . $whereArr[1] . ' o.' . $whereArr[2] . $whereArr[3] . $whereArr[4];
    }
    /*end*/
    $where = " WHERE o.order_id = og.order_id AND g.goods_id = og.goods_id " . order_query_sql('finished', 'o.');
    $limit = " LIMIT " . $show_num;
    if ($cat_id > 0) {
        $where .= " AND " . get_children($cat_id);
    }
    if ($brand_id > 0) {
        $where .= " AND g.brand_id = '{$brand_id}' ";
    }
    /*add by hg for date 2014-04-23 根据代理商筛选  begin*/
    if (!empty($admin_agency_id) && if_agency()) {
        if ($admin_agency_id != '-') {
            $where .= " AND o.admin_agency_id = '{$admin_agency_id}' ";
        }
    } elseif (if_agency()) {
        $where .= " AND o.admin_agency_id = '0' ";
    }
    /*end*/
    $click_sold_info = array();
    $sql = "SELECT og.goods_id, g.goods_sn, g.goods_name, g.click_count,  COUNT(og.goods_id) AS sold_times " . " FROM " . $ecs->table('goods') . " AS g, " . $ecs->table('order_goods') . " AS og, " . $ecs->table('order_info') . " AS o " . $where . $sale_where . " GROUP BY og.goods_id ORDER BY g.click_count DESC " . $limit;
    $res = $db->query($sql);
    while ($item = $db->fetchRow($res)) {
        if ($item['click_count'] <= 0) {
            $item['scale'] = 0;
        } else {
            /* 每一百个点击的订单比率 */
            $item['scale'] = sprintf("%0.2f", $item['sold_times'] / $item['click_count'] * 100) . '%';
        }
        $click_sold_info[] = $item;
    }
    return $click_sold_info;
}
Example #22
0
/**
 *  获取退货单列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function back_list()
{
    $result = get_filter();
    if ($result === false) {
        $aiax = isset($_GET['is_ajax']) ? $_GET['is_ajax'] : 0;
        /*add by hg for date 2014-04-23 获取代理商id begin*/
        $filter['admin_agency_id'] = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : 0;
        /*end*/
        /* 过滤信息 */
        $filter['delivery_sn'] = empty($_REQUEST['delivery_sn']) ? '' : trim($_REQUEST['delivery_sn']);
        $filter['order_sn'] = empty($_REQUEST['order_sn']) ? '' : trim($_REQUEST['order_sn']);
        $filter['order_id'] = empty($_REQUEST['order_id']) ? 0 : intval($_REQUEST['order_id']);
        if ($aiax == 1 && !empty($_REQUEST['consignee'])) {
            $_REQUEST['consignee'] = json_str_iconv($_REQUEST['consignee']);
        }
        $filter['consignee'] = empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']);
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'update_time' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $where = 'WHERE 1 ';
        /*add by hg for date 2014-04-22 只显示代理商本身所属订单 begin*/
        $where .= agency_where();
        /*end*/
        if ($filter['order_sn']) {
            $where .= " AND order_sn LIKE '%" . mysql_like_quote($filter['order_sn']) . "%'";
        }
        if ($filter['consignee']) {
            $where .= " AND consignee LIKE '%" . mysql_like_quote($filter['consignee']) . "%'";
        }
        if ($filter['delivery_sn']) {
            $where .= " AND delivery_sn LIKE '%" . mysql_like_quote($filter['delivery_sn']) . "%'";
        }
        /*add by hg for date 2014-04-23 根据代理商筛选 begin*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                if ($filter['admin_agency_id'] != '-') {
                    $where .= " AND admin_agency_id = {$filter['admin_agency_id']}";
                }
            } else {
                $where .= " AND admin_agency_id = 0";
            }
        }
        /*end*/
        /* 获取管理员信息 */
        $admin_info = admin_info();
        /* 如果管理员属于某个办事处,只列出这个办事处管辖的发货单 */
        if ($admin_info['agency_id'] > 0) {
            $where .= " AND agency_id = '" . $admin_info['agency_id'] . "' ";
        }
        /* 如果管理员属于某个供货商,只列出这个供货商的发货单 */
        if ($admin_info['suppliers_id'] > 0) {
            $where .= " AND suppliers_id = '" . $admin_info['suppliers_id'] . "' ";
        }
        /* 分页大小 */
        $filter['page'] = empty($_REQUEST['page']) || intval($_REQUEST['page']) <= 0 ? 1 : intval($_REQUEST['page']);
        if (isset($_REQUEST['page_size']) && intval($_REQUEST['page_size']) > 0) {
            $filter['page_size'] = intval($_REQUEST['page_size']);
        } elseif (isset($_COOKIE['ECSCP']['page_size']) && intval($_COOKIE['ECSCP']['page_size']) > 0) {
            $filter['page_size'] = intval($_COOKIE['ECSCP']['page_size']);
        } else {
            $filter['page_size'] = 15;
        }
        /* 记录总数 */
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('back_order') . $where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
        /* 查询 */
        $sql = "SELECT back_id, delivery_sn, order_sn, order_id, add_time, action_user, consignee, country,\r\n                       province, city, district, tel, status, update_time, email, return_time\r\n                FROM " . $GLOBALS['ecs']->table("back_order") . "\r\n                {$where}\r\n                ORDER BY " . $filter['sort_by'] . " " . $filter['sort_order'] . "\r\n                LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ", " . $filter['page_size'] . " ";
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $row = $GLOBALS['db']->getAll($sql);
    /* 格式化数据 */
    foreach ($row as $key => $value) {
        $row[$key]['return_time'] = local_date($GLOBALS['_CFG']['time_format'], $value['return_time']);
        $row[$key]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $value['add_time']);
        $row[$key]['update_time'] = local_date($GLOBALS['_CFG']['time_format'], $value['update_time']);
        if ($value['status'] == 1) {
            $row[$key]['status_name'] = $GLOBALS['_LANG']['delivery_status'][1];
        } else {
            $row[$key]['status_name'] = $GLOBALS['_LANG']['delivery_status'][0];
        }
    }
    $arr = array('back' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #23
0
    $agency_list[$re_k] = $res_v;
}
$GLOBALS['smarty']->assign('agency_list', $agency_list);
$GLOBALS['smarty']->assign('admin_agency_id', $admin_agency_id);
$action_list = if_agency() ? 'all' : '';
$GLOBALS['smarty']->assign('all', $action_list);
if (!empty($admin_agency_id) && if_agency()) {
    if ($admin_agency_id != '-') {
        $agency_where .= " AND admin_agency_id = '{$admin_agency_id}' ";
    }
} elseif (if_agency()) {
    $agency_where = " AND admin_agency_id = '0' ";
}
/*end*/
/*add by hg for date 2014-04-22		获取客户统计信息加入条件判定为当前代理商下的客户信息*/
$where = agency_where();
/* 分组统计订单数和销售额:已发货时间为准 */
$format = $query_type == 'year' ? '%Y' : '%Y-%m';
$sql = "SELECT DATE_FORMAT(FROM_UNIXTIME(shipping_time), '{$format}') AS period, COUNT(*) AS order_count, " . "SUM(goods_amount + shipping_fee + insure_fee + pay_fee + pack_fee + card_fee - discount) AS order_amount " . "FROM " . $ecs->table('order_info') . " WHERE (order_status = '" . OS_CONFIRMED . "' OR order_status >= '" . OS_SPLITED . "')" . " AND (pay_status = '" . PS_PAYED . "' OR pay_status = '" . PS_PAYING . "') " . " AND (shipping_status = '" . SS_SHIPPED . "' OR shipping_status = '" . SS_RECEIVED . "') " . " AND shipping_time >= '{$start_time}' AND shipping_time <= '{$end_time}' {$where} {$agency_where}" . " GROUP BY period ";
//dump($sql);
$data_list = $db->getAll($sql);
/*------------------------------------------------------ */
//-- 显示统计信息
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'list') {
    /* 赋值查询时间段 */
    $smarty->assign('start_time', local_date('Y-m-d', $start_time));
    $smarty->assign('end_time', local_date('Y-m-d', $end_time));
    /* 赋值统计数据 */
    $xml = "<chart caption='' xAxisName='%s' showValues='0' decimals='0' formatNumberScale='0'>%s</chart>";
    $set = "<set label='%s' value='%s' />";
Example #24
0
function get_typelist()
{
    $result = get_filter();
    if ($result === false) {
        $filter = array();
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.add_time' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $where = '';
        if (!empty($filter['keyword'])) {
            $where = " AND a.remarks LIKE '%" . mysql_like_quote($filter['keyword']) . "%'";
        }
        /*加入代理商条件*/
        if (!$filter['admin_agency_id']) {
            $agency_where = agency_where();
            if (!$agency_where) {
                $agency_where = "AND a.admin_agency_id = 0";
            } else {
                $agency_where = "AND a.admin_agency_id = " . admin_agency_id();
            }
        } else {
            $agency_where = " AND a.admin_agency_id = {$filter['admin_agency_id']}";
        }
        //dump($agency_where);
        /* 出库类型总数 */
        $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_out_type') . ' AS a ' . 'WHERE 1 ' . $where . $agency_where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $filter = page_and_size($filter);
        /* 获取出库类型数据 */
        $sql = 'SELECT a.* , u.user_name ' . 'FROM ' . $GLOBALS['ecs']->table('stock_out_type') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('admin_user') . ' AS u ON u.user_id = a.user_id ' . 'WHERE 1 ' . $where . $agency_where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order'];
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $arr = array();
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
    while ($rows = $GLOBALS['db']->fetchRow($res)) {
        $rows['date'] = local_date($GLOBALS['_CFG']['time_format'], $rows['add_time']);
        $arr[] = $rows;
    }
    return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}
Example #25
0
File: vote.php Project: dlpc/ecshop
function get_votelist()
{
    $filter = array();
    /* 加入代理商搜索条件 by hg*/
    $filter['admin_agency_id'] = isset($_REQUEST['admin_agency_id']) ? trim($_REQUEST['admin_agency_id']) : '';
    if (!$filter['admin_agency_id']) {
        $agency_where = agency_where();
        if (!$agency_where) {
            $agency_where = "AND admin_agency_id = 0";
        }
    } else {
        $agency_where = " AND admin_agency_id = {$filter['admin_agency_id']}";
    }
    /* 代理商列表 */
    $arr_res = agency_list();
    $GLOBALS['smarty']->assign('agency_list', $arr_res);
    /*判断代理商或管理员*/
    if (if_agency()) {
        $GLOBALS['smarty']->assign('if_agency', if_agency());
    }
    /* 记录总数以及页数 */
    $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('vote') . " WHERE 1 {$agency_where}";
    $filter['record_count'] = $GLOBALS['db']->getOne($sql);
    $filter = page_and_size($filter);
    /* 查询数据 */
    $sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('vote') . " WHERE 1 {$agency_where} ORDER BY vote_id DESC";
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
    $list = array();
    while ($rows = $GLOBALS['db']->fetchRow($res)) {
        $rows['begin_date'] = local_date('Y-m-d', $rows['start_time']);
        $rows['end_date'] = local_date('Y-m-d', $rows['end_time']);
        $list[] = $rows;
    }
    return array('list' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}