Example #1
0
/**
 * 生成计算应付款金额的字段
 * @param   string  $alias  order表的别名(包括.例如 o.)
 * @return  string
 */
function order_due_field($alias = '')
{
    return order_amount_field($alias) . " - {$alias}money_paid - {$alias}surplus - {$alias}integral_money" . " - {$alias}bonus - {$alias}discount ";
}
function getBackOrderMoney()
{
    global $ecs, $db;
    $rid = isset($_REQUEST['rid']) && intval($_REQUEST['rid']) > 0 ? intval($_REQUEST['rid']) : 0;
    $hpay_id = getPayHoudaofukuan();
    //货到付款支付方式id;
    $sql = "select bo.status_refund,(" . order_amount_field('oi.') . ") AS total_fee,oi.pay_id " . "from " . $ecs->table('order_info') . " as oi," . $ecs->table('back_order') . " as bo where oi.store_rebate_id=" . $rid . " and bo.back_type!=3 and bo.status_back < 5 and oi.order_id=bo.order_id";
    $query = $db->query($sql);
    $ret = array('all' => 0.0, 'finish' => 0.0, 'nofinish' => 0.0, 'online' => 0.0, 'onout' => 0.0);
    while ($row = $db->fetchRow($query)) {
        $ret['all'] += $row['total_fee'];
        if ($row['status_refund'] > 0) {
            //完成退款
            $ret['finish'] += $row['total_fee'];
        } else {
            //申请中
            $ret['nofinish'] += $row['total_fee'];
        }
        if ($row['pay_id'] != $hpay_id) {
            //在线支付
            $ret['online'] += $row['total_fee'];
        } else {
            //货到付款
            $ret['onout'] += $row['total_fee'];
        }
    }
    return $ret;
}
Example #3
0
/**
 *  获取订单列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function order_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']);
        }
        $filter['consignee'] = empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']);
        $filter['email'] = empty($_REQUEST['email']) ? '' : trim($_REQUEST['email']);
        $filter['address'] = empty($_REQUEST['address']) ? '' : trim($_REQUEST['address']);
        $filter['zipcode'] = empty($_REQUEST['zipcode']) ? '' : trim($_REQUEST['zipcode']);
        $filter['tel'] = empty($_REQUEST['tel']) ? '' : trim($_REQUEST['tel']);
        $filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']);
        $filter['country'] = empty($_REQUEST['country']) ? 0 : intval($_REQUEST['country']);
        $filter['province'] = empty($_REQUEST['province']) ? 0 : intval($_REQUEST['province']);
        $filter['city'] = empty($_REQUEST['city']) ? 0 : intval($_REQUEST['city']);
        $filter['district'] = empty($_REQUEST['district']) ? 0 : intval($_REQUEST['district']);
        $filter['shipping_id'] = empty($_REQUEST['shipping_id']) ? 0 : intval($_REQUEST['shipping_id']);
        $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 ';
        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']}'";
        }
        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']) . "%'";
        }
        if ($filter['start_time']) {
            $where .= " AND o.add_time >= '{$filter['start_time']}'";
        }
        if ($filter['end_time']) {
            $where .= " AND o.add_time <= '{$filter['end_time']}'";
        }
        //综合状态
        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);
        $filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
        /* 查询 */
        $sql = "SELECT o.order_id, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," . "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " . "(" . order_amount_field('o.') . ") AS total_fee, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer " . " FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u ON u.user_id=o.user_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);
    /* 格式话数据 */
    foreach ($row as $key => $value) {
        $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;
        }
    }
    $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #4
0
$smarty->assign('lang', $_LANG);
/* act操作项的初始化 */
if (empty($_REQUEST['act'])) {
    $_REQUEST['act'] = 'list';
} else {
    $_REQUEST['act'] = trim($_REQUEST['act']);
}
/*------------------------------------------------------ */
//--订单统计
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'list') {
    admin_priv('sale_order_stats');
    /* 随机的颜色数组 */
    $color_array = array('33FF66', 'FF6600', '3399FF', '009966', 'CC3399', 'FFCC33', '6699CC', 'CC3366');
    /* 计算订单各种费用之和的语句 */
    $total_fee = " SUM(" . order_amount_field() . ") AS total_turnover ";
    /* 取得订单转化率数据 */
    $sql = "SELECT COUNT(*) AS total_order_num, " . $total_fee . " FROM " . $ecs->table('order_info') . " WHERE 1 " . order_query_sql('finished');
    $order_general = $db->getRow($sql);
    $order_general['total_turnover'] = floatval($order_general['total_turnover']);
    /* 取得商品总点击数量 */
    $sql = 'SELECT SUM(click_count) FROM ' . $ecs->table('goods') . ' WHERE is_delete = 0';
    $click_count = floatval($db->getOne($sql));
    /* 每千个点击的订单数 */
    $click_ordernum = $click_count > 0 ? round($order_general['total_order_num'] * 1000 / $click_count, 2) : 0;
    /* 每千个点击的购物额 */
    $click_turnover = $click_count > 0 ? round($order_general['total_turnover'] * 1000 / $click_count, 2) : 0;
    /* 时区 */
    $timezone = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : $GLOBALS['_CFG']['timezone'];
    /* 时间参数 */
    $is_multi = empty($_POST['is_multi']) ? false : true;
function getRebateOrderMoney($rid)
{
    global $ecs, $db;
    $back_and = '';
    if (($back_order_id = getBackOrderByRebate($rid)) != false) {
        //获取退货订单中相关订单
        $back_and = "and order_id not in(" . implode(',', $back_order_id) . ")";
    }
    $pay_id = getPayHoudaofukuan();
    //获取货到付款的id
    $sql = "select (" . order_amount_field() . ") AS total_fee,pay_id,order_id from " . $ecs->table('order_info') . " where store_rebate_id=" . $rid . " {$back_and} and store_rebate_ispay=2";
    $query = $db->query($sql);
    $online = $online_rebate = $onout = $onout_rebate = 0;
    $online_ids = $onout_ids = array();
    while ($row = $db->fetchRow($query)) {
        if ($row['pay_id'] == $pay_id) {
            //货到付款
            $onout += $row['total_fee'];
            $onout_rebate += getGoodsOrderRebatePrice($row['order_id']);
            $onout_ids[] = $row['order_id'];
        } else {
            //在线支付
            $online += $row['total_fee'];
            $online_rebate += getGoodsOrderRebatePrice($row['order_id']);
            $online_ids[] = $row['order_id'];
        }
    }
    if (count($onout_ids) > 0) {
        //货到付款订单当中有商品发生的退货
        $sql = "select (goods_price * is_back) as price_out from " . $ecs->table('order_goods') . " where order_id in(" . implode(',', $onout_ids) . ")";
        $out_price = $db->getOne($sql);
        $onout = $onout - $out_price;
    }
    if (count($online_ids) > 0) {
        //在线支付订单当中有商品发生退货
        $sql = "select (goods_price * is_back) as price_out from " . $ecs->table('order_goods') . " where order_id in(" . implode(',', $online_ids) . ")";
        $line_price = $db->getOne($sql);
        $online = $online - $line_price;
    }
    return array('all' => array('online' => $online, 'onout' => $onout), 'rebate' => array('online' => $online_rebate, 'onout' => $onout_rebate));
}
Example #6
0
/**
 *  获取订单列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function order_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('-7 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['consignee'] = empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']);
        $filter['email'] = empty($_REQUEST['email']) ? '' : trim($_REQUEST['email']);
        $filter['address'] = empty($_REQUEST['address']) ? '' : trim($_REQUEST['address']);
        $filter['zipcode'] = empty($_REQUEST['zipcode']) ? '' : trim($_REQUEST['zipcode']);
        $filter['tel'] = empty($_REQUEST['tel']) ? '' : trim($_REQUEST['tel']);
        $filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']);
        $filter['country'] = empty($_REQUEST['country']) ? 0 : intval($_REQUEST['country']);
        $filter['province'] = empty($_REQUEST['province']) ? 0 : intval($_REQUEST['province']);
        $filter['city'] = empty($_REQUEST['city']) ? 0 : intval($_REQUEST['city']);
        $filter['district'] = empty($_REQUEST['district']) ? 0 : intval($_REQUEST['district']);
        $filter['shipping_id'] = empty($_REQUEST['shipping_id']) ? 0 : intval($_REQUEST['shipping_id']);
        $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']) . "%'";
        }
        if ($filter['start_time']) {
            $where .= " AND o.add_time >= '{$filter['start_time']}'";
        }
        if ($filter['end_time']) {
            $where .= " AND o.add_time <= '{$filter['end_time']}'";
        }
        $where .= " AND o.add_time >= '" . $filter['start_date'] . "' AND o.add_time < '" . ($filter['end_date'] + 86400) . "'";
        /*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);
        $filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
        /* 查询 */
        $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, " . "(" . order_amount_field('o.') . ") AS total_fee, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer " . " 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);
    /* 格式话数据 */
    foreach ($row as $key => $value) {
        $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;
        }
        /*ccx 2014-12-14 对已经抽奖过的订单,提示该订单不能进行退货和退款 开始 */
        $sql_luck = "SELECT id FROM " . $GLOBALS['ecs']->table('lucky_draw') . " WHERE order_sn = '" . $value['order_sn'] . "'";
        $lucky_draw = $GLOBALS['db']->getOne($sql_luck);
        $row[$key]['lucky_draw'] = $lucky_draw;
        /*ccx 2014-12-14 对已经抽奖过的订单,提示该订单不能进行退货和退款 结束 */
    }
    /*统计总金额和应付金额 by hg for 2014-06-10*/
    $overall_order_amount = overall_order_amount($sql);
    $GLOBALS['smarty']->assign('overall_formated_total_fee', price_format($overall_order_amount['overall_formated_total_fee']));
    $GLOBALS['smarty']->assign('overall_formated_order_amount', price_format($overall_order_amount['overall_formated_order_amount']));
    $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('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #7
0
/**
 *  获取供应商列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function rebate_list($act = '')
{
    $result = get_filter();
    if ($result === false) {
        //$aiax = isset($_GET['is_ajax']) ? $_GET['is_ajax'] : 0;
        /* 过滤信息 */
        $filter['rebate_paytime_start'] = !empty($_REQUEST['rebate_paytime_start']) ? local_strtotime($_REQUEST['rebate_paytime_start']) : 0;
        $filter['rebate_paytime_end'] = !empty($_REQUEST['rebate_paytime_end']) ? local_strtotime($_REQUEST['rebate_paytime_end'] . " 23:59:59") : 0;
        $filter['status'] = isset($_REQUEST['status']) ? intval($_REQUEST['status']) : -1;
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? ' sr.supplier_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? ' ASC' : trim($_REQUEST['sort_order']);
        $filter['is_pay_ok'] = empty($_REQUEST['is_pay_ok']) ? '0' : intval($_REQUEST['is_pay_ok']);
        $filter['actname'] = empty($act) ? trim($_REQUEST['act']) : $act;
        $where = 'WHERE 1 ';
        $where .= $filter['rebate_paytime_start'] ? " AND sr.rebate_paytime_start >= '" . $filter['rebate_paytime_start'] . "' " : " ";
        $where .= $filter['rebate_paytime_end'] ? " AND sr.rebate_paytime_end <= '" . $filter['rebate_paytime_end'] . "' " : " ";
        $where .= $filter['is_pay_ok'] ? " AND sr.is_pay_ok = '" . $filter['is_pay_ok'] . "' " : " AND sr.is_pay_ok = '0' ";
        $where .= $filter['status'] > -1 ? " AND sr.status = '" . $filter['status'] . "' " : " ";
        /* 分页大小 */
        $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('supplier_rebate') . " AS sr  " . $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 sr.* , s.supplier_name, s.supplier_rebate " . "FROM " . $GLOBALS['ecs']->table("supplier_rebate") . " AS  sr left join " . $GLOBALS['ecs']->table("supplier") . " AS s on sr.supplier_id=s.supplier_id \n                {$where}\n                ORDER BY " . $filter['sort_by'] . " " . $filter['sort_order'] . "\n                LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ", " . $filter['page_size'] . " ";
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $list = array();
    $res = $GLOBALS['db']->query($sql);
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        $row['sign'] = createSign($row['rebate_id'], $row['supplier_id']);
        $row['rebate_paytime_start'] = local_date('Y.m.d', $row['rebate_paytime_start']);
        $endtime = $row['rebate_paytime_end'];
        //+$GLOBALS['_CFG']['tuihuan_days_qianshou']*3600*24;
        $row['rebate_paytime_end'] = local_date('Y.m.d', $endtime);
        //$row['all_money'] = $GLOBALS['db']->getOne("select sum(money_paid + surplus) from ". $GLOBALS['ecs']->table('order_info') ." where rebate_id=". $row['rebate_id'] ." and rebate_ispay=2");
        $row['all_money'] = $GLOBALS['db']->getOne("select sum(" . order_amount_field() . ") from " . $GLOBALS['ecs']->table('order_info') . " where rebate_id=" . $row['rebate_id'] . " and rebate_ispay=2");
        $row['all_money_formated'] = price_format($row['all_money']);
        $row['rebate_money'] = round($row['all_money'] * $row['supplier_rebate'] / 100, 2);
        $row['rebate_money_formated'] = price_format($row['rebate_money']);
        $row['pay_money'] = $row['all_money'] - $row['rebate_money'];
        $row['pay_money_formated'] = price_format($row['pay_money']);
        $row['pay_status'] = $row['is_pay_ok'] ? "已处理,已返佣" : "未处理";
        $row['pay_time'] = local_date('Y.m.d', $row['pay_time']);
        $row['user'] = $_SESSION['user_name'];
        $row['payable_price'] = price_format($row['payable_price']);
        $row['status_name'] = rebateStatus($row['status']);
        $row['caozuo'] = getRebateDo($row['status'], $row['rebate_id'], $filter['actname']);
        $list[] = $row;
    }
    $arr = array('result' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #8
0
/**
 *  获取订单列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function order_list()
{
    $result = get_filter();
    if ($result === false) {
        /* 过滤信息 */
        /* 代码增加_start  By  morestock_morecity */
        $filter['sid'] = empty($_REQUEST['sid']) ? '0' : intval($_REQUEST['sid']);
        $filter['ssid'] = empty($_REQUEST['ssid']) ? '0' : intval($_REQUEST['ssid']);
        /* 代码增加_end  By  morestock_morecity */
        $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']);
        }
        $filter['consignee'] = empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']);
        $filter['email'] = empty($_REQUEST['email']) ? '' : trim($_REQUEST['email']);
        $filter['address'] = empty($_REQUEST['address']) ? '' : trim($_REQUEST['address']);
        $filter['zipcode'] = empty($_REQUEST['zipcode']) ? '' : trim($_REQUEST['zipcode']);
        $filter['tel'] = empty($_REQUEST['tel']) ? '' : trim($_REQUEST['tel']);
        $filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']);
        $filter['country'] = empty($_REQUEST['country']) ? 0 : intval($_REQUEST['country']);
        $filter['province'] = empty($_REQUEST['province']) ? 0 : intval($_REQUEST['province']);
        $filter['city'] = empty($_REQUEST['city']) ? 0 : intval($_REQUEST['city']);
        $filter['district'] = empty($_REQUEST['district']) ? 0 : intval($_REQUEST['district']);
        $filter['shipping_id'] = empty($_REQUEST['shipping_id']) ? 0 : intval($_REQUEST['shipping_id']);
        $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']);
        /* 代码增加_start   By www.ecshop68.com */
        $filter['order_type'] = isset($_REQUEST['order_type']) ? intval($_REQUEST['order_type']) : 0;
        /* 代码增加_end   By www.ecshop68.com */
        $filter['supp'] = isset($_REQUEST['supp']) && !empty($_REQUEST['supp']) && intval($_REQUEST['supp']) > 0 ? intval($_REQUEST['supp']) : 0;
        $filter['suppid'] = isset($_REQUEST['suppid']) && !empty($_REQUEST['suppid']) && intval($_REQUEST['suppid']) > 0 ? intval($_REQUEST['suppid']) : 0;
        //$where = 'WHERE 1 ';
        $where = $filter['supp'] > 0 ? 'WHERE o.supplier_id > 0' : 'WHERE o.supplier_id = 0';
        //morestock_morecity
        if ($filter['suppid']) {
            //$where .= " AND o.supplier_id = ".$filter['suppid'];
            $where = 'WHERE o.supplier_id = ' . $filter['suppid'];
            //morestock_morecity
        }
        //判断是否是查询过来的
        if (isset($_REQUEST['search']) && $_REQUEST['search']) {
            $where = "where 1";
            $search = false;
        } else {
            $search = true;
        }
        /* 代码增加_start    By morestock_morecity */
        if ($filter['ssid']) {
            $where .= " AND o.sub_id like '%|" . $filter['ssid'] . "|%' ";
        } else {
            if ($filter['sid']) {
                $where .= " AND o.store_id = '" . $filter['sid'] . "' ";
            }
        }
        //获取当前管理员负责的store_id列表
        if ($filter['supp'] == 0 && $search) {
            //如果是查看自己的订单,就获取仓库列表
            $storeid_list = "";
            if ($_SESSION['action_list'] == 'all') {
                //自营超级管理员,可以查看所有
                $sql2 = "select store_id from " . $GLOBALS['ecs']->table('store_main') . " where supplier_id=0 and parent_id > 0";
                $res2 = $GLOBALS['db']->query($sql2);
                while ($row2 = $GLOBALS['db']->fetchRow($res2)) {
                    $storeid_list .= $storeid_list ? " or " : "";
                    $storeid_list .= " sub_id like '%|" . $row2['store_id'] . "|%' ";
                }
            } else {
                $sql1 = "select store_id from " . $GLOBALS['ecs']->table('store_adminer') . " where supplier_id=0 and admin_id = " . $_SESSION['admin_id'];
                $res1 = $GLOBALS['db']->query($sql1);
                while ($row1 = $GLOBALS['db']->fetchRow($res1)) {
                    $storeid_list .= $storeid_list ? " or " : "";
                    $storeid_list .= " sub_id like '%|" . $row1['store_id'] . "|%' ";
                    $sql2 = "select store_id from " . $GLOBALS['ecs']->table('store_main') . " where supplier_id=0 and parent_id = '{$row1['store_id']}' ";
                    $res2 = $GLOBALS['db']->query($sql2);
                    while ($row2 = $GLOBALS['db']->fetchRow($res2)) {
                        $storeid_list .= $storeid_list ? " or " : "";
                        $storeid_list .= " sub_id like '%|" . $row2['store_id'] . "|%' ";
                    }
                }
            }
            if ($storeid_list) {
                $where .= " AND  ({$storeid_list}) ";
            }
        }
        /* 代码增加_end   By morestock_morecity */
        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']}'";
        }
        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']) . "%'";
        }
        if ($filter['start_time']) {
            $where .= " AND o.add_time >= '{$filter['start_time']}'";
        }
        if ($filter['end_time']) {
            $where .= " AND o.add_time <= '{$filter['end_time']}'";
        }
        /* 代码增加_start   By www.ecshop68.com */
        switch ($filter['order_type']) {
            case 1:
                $where .= " AND o.is_pickup = 0";
                break;
            case 2:
                $where .= " AND o.is_pickup > 0";
                break;
        }
        /* 代码增加_end   By www.ecshop68.com */
        //综合状态
        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);
        $filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
        /* 查询 */
        if ($filter['supp']) {
            $sql = "SELECT o.order_id, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," . "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " . "(" . order_amount_field('o.') . ") AS total_fee, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer,supplier_name,o.froms,is_pickup  " . " FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['ecs']->table('supplier') . " AS s ON s.supplier_id=o.supplier_id " . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u ON u.user_id=o.user_id " . $where . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
        } else {
            $sql = "SELECT o.order_id, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," . "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " . "(" . order_amount_field('o.') . ") AS total_fee, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer, o.froms , is_pickup " . " FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u ON u.user_id=o.user_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);
    /* 格式话数据 */
    foreach ($row as $key => $value) {
        $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;
        }
        $tuihuan_info = $GLOBALS['db']->getOne("select order_sn from " . $GLOBALS['ecs']->table('back_order') . " where order_sn = '" . $row[$key]['order_sn'] . "' AND status_back < 6");
        if (!empty($tuihuan_info)) {
            $row[$key]['tuihuan'] = 1;
        }
    }
    $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #9
0
/**
 *  获取订单列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function order_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']);
        }
        $filter['consignee'] = empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']);
        $filter['composite_status'] = isset($_REQUEST['composite_status']) ? intval($_REQUEST['composite_status']) : -1;
        $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']);
        $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['rebateid'] = isset($_REQUEST['rebateid']) && !empty($_REQUEST['rebateid']) && intval($_REQUEST['rebateid']) > 0 ? intval($_REQUEST['rebateid']) : 0;
        $filter['isreb'] = !isset($_REQUEST['isreb']) ? 1 : intval($_REQUEST['isreb']);
        ishavereb($filter['rebateid']);
        //$where = 'WHERE 1 ';
        $where = $filter['rebateid'] > 0 ? 'WHERE o.rebate_id = ' . $filter['rebateid'] : 'WHERE 1';
        $where .= " AND o.rebate_ispay = " . $filter['isreb'];
        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']) . "%'";
        }
        //综合状态
        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']}' ";
                }
        }
        /* 分页大小 */
        $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('order_info') . " AS o " . $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 o.order_id, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," . "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, o.shipping_time, " . "(" . order_amount_field('o.') . ") AS total_fee, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer " . " FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u ON u.user_id=o.user_id " . $where . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
        //echo $sql;
        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);
    /* 格式话数据 */
    foreach ($row as $key => $value) {
        $is_order = $is_shipping = $is_pay = 0;
        $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']);
        $row[$key]['is_rebeat'] = 0;
        if ($value['order_status'] == OS_INVALID || $value['order_status'] == OS_CANCELED) {
            /* 如果该订单为无效或取消则显示删除链接 */
            $row[$key]['can_remove'] = 1;
        } else {
            $row[$key]['can_remove'] = 0;
        }
        //订单状态
        if ($value['order_status'] == OS_CONFIRMED || $value['order_status'] == OS_SPLITED) {
            $is_order = 1;
        }
        //配送状态
        if ($value['shipping_status'] == SS_SHIPPED || $value['shipping_status'] == SS_RECEIVED) {
            $is_shipping = 1;
        }
        //支付状态
        if ($value['pay_status'] == PS_PAYED) {
            $is_pay = 1;
        }
        if ($is_order && $is_shipping && $is_pay) {
            $row[$key]['is_rebeat'] = 1;
            $cha = getdatecha($value['shipping_time']);
            $row[$key]['datas'] = $GLOBALS['_CFG']['tuihuan_days_qianshou'] - $cha;
        }
    }
    $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
Example #10
0
} else {
    $_REQUEST['act'] = trim($_REQUEST['act']);
}
/*------------------------------------------------------ */
//-- 客户统计列表
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'list') {
    /* 权限判断 */
    admin_priv('client_flow_stats');
    /* 取得会员总数 */
    $users =& init_users();
    $sql = 'SELECT COUNT(*) FROM ' . $ecs->table('users');
    $res = $db->getCol($sql);
    $user_num = $res[0];
    /* 计算订单各种费用之和的语句 */
    $total_fee = ' SUM(' . order_amount_field() . ') AS turnover ';
    /* 有过订单的会员数 */
    $sql = 'SELECT COUNT(DISTINCT user_id) FROM ' . $ecs->table('order_info') . ' WHERE user_id > 0 ' . order_query_sql('finished');
    $have_order_usernum = $db->getOne($sql);
    /* 会员订单总数和订单总购物额 */
    $user_all_order = array();
    $sql = 'SELECT COUNT(*) AS order_num, ' . $total_fee . 'FROM ' . $ecs->table('order_info') . ' WHERE user_id > 0 ' . order_query_sql('finished');
    $user_all_order = $db->getRow($sql);
    $user_all_order['turnover'] = floatval($user_all_order['turnover']);
    /* 匿名会员订单总数和总购物额 */
    $guest_all_order = array();
    $sql = 'SELECT COUNT(*) AS order_num, ' . $total_fee . 'FROM ' . $ecs->table('order_info') . ' WHERE user_id = 0 ' . order_query_sql('finished');
    $guest_all_order = $db->getRow($sql);
    /* 匿名会员平均订单额: 购物总额/订单数 */
    $guest_order_amount = $guest_all_order['order_num'] > 0 ? floatval($guest_all_order['turnover'] / $guest_all_order['order_num']) : '0.00';
    $_GET['flag'] = isset($_GET['flag']) ? 'download' : '';
Example #11
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']);
    $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'] . "'";
    }
    $sql = 'SELECT count(distinct(u.user_id)) FROM ' . $ecs->table('users') . ' AS u, ' . $ecs->table('order_info') . ' AS o ' . $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 . ' 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 #12
0
/**
 *  获取订单列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function order_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']);
        }
        $filter['consignee'] = empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']);
        $filter['email'] = empty($_REQUEST['email']) ? '' : trim($_REQUEST['email']);
        $filter['address'] = empty($_REQUEST['address']) ? '' : trim($_REQUEST['address']);
        $filter['zipcode'] = empty($_REQUEST['zipcode']) ? '' : trim($_REQUEST['zipcode']);
        $filter['tel'] = empty($_REQUEST['tel']) ? '' : trim($_REQUEST['tel']);
        $filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']);
        $filter['country'] = empty($_REQUEST['country']) ? 0 : intval($_REQUEST['country']);
        $filter['province'] = empty($_REQUEST['province']) ? 0 : intval($_REQUEST['province']);
        $filter['city'] = empty($_REQUEST['city']) ? 0 : intval($_REQUEST['city']);
        $filter['district'] = empty($_REQUEST['district']) ? 0 : intval($_REQUEST['district']);
        $filter['shipping_id'] = empty($_REQUEST['shipping_id']) ? 0 : intval($_REQUEST['shipping_id']);
        $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']);
        /* 代码增加_start   By www.ecshop68.com */
        $filter['order_type'] = isset($_REQUEST['order_type']) ? intval($_REQUEST['order_type']) : 0;
        /* 代码增加_end   By www.ecshop68.com */
        $filter['supp'] = isset($_REQUEST['supp']) && !empty($_REQUEST['supp']) && intval($_REQUEST['supp']) > 0 ? intval($_REQUEST['supp']) : 0;
        $filter['suppid'] = isset($_REQUEST['suppid']) && !empty($_REQUEST['suppid']) && intval($_REQUEST['suppid']) > 0 ? intval($_REQUEST['suppid']) : 0;
        /*增值税发票_添加_START_www.68ecshop.com*/
        $filter['inv_status'] = empty($_REQUEST['inv_status']) ? '' : trim($_REQUEST['inv_status']);
        $filter['inv_type'] = empty($_REQUEST['inv_type']) ? '' : trim($_REQUEST['inv_type']);
        $filter['vat_inv_consignee_name'] = empty($_REQUEST['vat_inv_consignee_name']) ? '' : trim($_REQUEST['vat_inv_consignee_name']);
        $filter['vat_inv_consignee_phone'] = empty($_REQUEST['vat_inv_consignee_phone']) ? '' : trim($_REQUEST['vat_inv_consignee_phone']);
        $filter['add_time'] = empty($_REQUEST['add_time']) ? '' : (strpos($_REQUEST['add_time'], '-') > 0 ? local_strtotime($_REQUEST['add_time']) : $_REQUEST['add_time']);
        if (!empty($filter['add_time'])) {
            $filter['start_time'] = $filter['add_time'];
            $filter['end_time'] = $filter['add_time'] + '86400';
        }
        /*增值税发票_添加_END_www.68ecshop.com*/
        //$where = 'WHERE 1 ';
        $where = $filter['supp'] > 0 ? 'WHERE o.supplier_id > 0' : 'WHERE o.supplier_id = 0';
        if ($filter['suppid']) {
            //$where .= " AND o.supplier_id = ".$filter['suppid'];
            $where = 'WHERE o.supplier_id = ' . $filter['suppid'];
        }
        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']}'";
        }
        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']) . "%'";
        }
        if ($filter['start_time']) {
            $where .= " AND o.add_time >= '{$filter['start_time']}'";
        }
        if ($filter['end_time']) {
            $where .= " AND o.add_time <= '{$filter['end_time']}'";
        }
        /*增值税发票_添加_START_www.68ecshop.com*/
        if ($filter['inv_status']) {
            $where .= " AND o.inv_status = '{$filter['inv_status']}'";
        }
        if ($filter['inv_type']) {
            $where .= " AND o.inv_type = '{$filter['inv_type']}'";
        }
        if ($filter['vat_inv_consignee_name']) {
            $where .= " AND o.inv_consignee_name = '{$filter['vat_inv_consignee_name']}'";
        }
        if ($filter['vat_inv_consignee_phone']) {
            $where .= " AND o.inv_consignee_phone = '{$filter['vat_inv_consignee_phone']}'";
        }
        if ($_REQUEST['act'] == 'invoice_list' || isset($_REQUEST['act_detail']) && $_REQUEST['act_detail'] == 'invoice_query') {
            $where .= " AND o.inv_type != ''";
        }
        /* 普通订单不显示虚拟团购订单 添加_START_www.68ecshop.com*/
        $where .= " AND o.extension_code != 'virtual_good'";
        /* 普通订单不显示虚拟团购订单 添加_END_www.68ecshop.com*/
        /*增值税发票_添加_END_www.68ecshop.com*/
        /* 代码增加_start   By www.ecshop68.com */
        switch ($filter['order_type']) {
            case 1:
                $where .= " AND o.is_pickup = 0";
                break;
            case 2:
                $where .= " AND o.is_pickup > 0";
                break;
        }
        /* 代码增加_end   By www.ecshop68.com */
        //综合状态
        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_CODE . "' AND o.extension_id = '{$filter['group_buy_id']}' ";
        }
        /* 预售订单 */
        if ($filter['pre_sale_id']) {
            $where .= " AND o.extension_code = '" . PRE_SALE_CODE . "' AND o.extension_id = '{$filter['pre_sale_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);
        $filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
        /* 查询 */
        if ($filter['supp']) {
            $sql = "SELECT o.order_id, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," . "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " . "(" . order_amount_field('o.') . ") AS total_fee, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer,supplier_name,o.froms,is_pickup  " . ',o.mobile,o.inv_payee,o.inv_content,o.inv_type,o.vat_inv_company_name' . ',o.vat_inv_taxpayer_id,o.vat_inv_registration_address,o.vat_inv_registration_phone' . ',o.vat_inv_deposit_bank,o.vat_inv_bank_account' . ',o.inv_consignee_name,o.inv_consignee_phone,o.inv_consignee_country' . ',o.inv_consignee_province,o.inv_consignee_city,o.inv_consignee_district' . ',o.inv_consignee_address,o.inv_status,o.inv_payee_type,o.inv_money' . " FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['ecs']->table('supplier') . " AS s ON s.supplier_id=o.supplier_id " . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u ON u.user_id=o.user_id " . $where . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
        } else {
            $sql = "SELECT o.order_id, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," . "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " . "(" . order_amount_field('o.') . ") AS total_fee, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer, o.froms , is_pickup " . ',o.mobile,o.inv_payee,o.inv_content,o.inv_type,o.vat_inv_company_name' . ',o.vat_inv_taxpayer_id,o.vat_inv_registration_address,o.vat_inv_registration_phone' . ',o.vat_inv_deposit_bank,o.vat_inv_bank_account' . ',o.inv_consignee_name,o.inv_consignee_phone,o.inv_consignee_country' . ',o.inv_consignee_province,o.inv_consignee_city,o.inv_consignee_district' . ',o.inv_consignee_address,o.inv_status,o.inv_payee_type,o.inv_money' . " FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u ON u.user_id=o.user_id " . $where . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
        }
        //echo $sql;
        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);
    /* 格式话数据 */
    foreach ($row as $key => $value) {
        $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']);
        /*增值税发票_添加_START_www.68ecshop.com*/
        $row[$key]['formatted_add_time'] = local_date('Y-m-d H:i', $value['add_time']);
        $row[$key]['formatted_inv_money'] = price_format($value['inv_money']);
        /*增值税发票_添加_END_www.68ecshop.com*/
        if ($value['order_status'] == OS_INVALID || $value['order_status'] == OS_CANCELED) {
            /* 如果该订单为无效或取消则显示删除链接 */
            $row[$key]['can_remove'] = 1;
        } else {
            $row[$key]['can_remove'] = 0;
        }
        $tuihuan_info = $GLOBALS['db']->getOne("select order_sn from " . $GLOBALS['ecs']->table('back_order') . " where order_sn = '" . $row[$key]['order_sn'] . "' AND status_back < 6");
        if (!empty($tuihuan_info)) {
            $row[$key]['tuihuan'] = 1;
        }
    }
    $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    /*增值税发票_添加_START_www.68ecshop.com*/
    if ($filter['inv_type']) {
        global $smarty;
        $smarty->assign('inv_type', $filter['inv_type']);
    }
    /*增值税发票_添加_END_www.68ecshop.com*/
    return $arr;
}
Example #13
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;
}
function get_user_orderinfo($show_num, $order_by, $start_date, $end_date)
{
    global $db, $ecs;
    $where = "WHERE u.user_id = o.user_id " . "AND u.user_id > 0 " . order_query_sql('finished', 'o.');
    $limit = " LIMIT " . $show_num;
    if ($start_date) {
        $where .= "AND o.add_time >= '{$start_date}' ";
    }
    if ($end_date) {
        $where .= "AND o.add_time <= '{$end_date}' ";
    }
    /* 计算订单各种费用之和的语句 */
    $total_fee = " SUM(" . order_amount_field() . ") AS turnover ";
    if ($order_by == 'order_num') {
        /* 按订单数量来排序 */
        $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 . "GROUP BY u.user_id ORDER BY order_num DESC, turnover DESC" . $limit;
    } else {
        /* 按购物金额来排序 */
        $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 . "GROUP BY u.user_id ORDER BY turnover DESC, order_num DESC" . $limit;
    }
    $user_orderinfo = array();
    $res = $db->query($sql);
    while ($items = $db->fetchRow($res)) {
        $items['turnover'] = price_format($items['turnover']);
        $user_orderinfo[] = $items;
    }
    return $user_orderinfo;
}
Example #15
0
function writelog($rid, $inout = 0)
{
    return true;
    //已经不用了
    global $db, $ecs;
    $sql = "select order_sn, (" . order_amount_field() . ") AS total_fee,supplier_id from " . $ecs->table('order_info') . " where rebate_id=" . $rid . " and rebate_ispay=2";
    $query = $db->query($sql);
    $addtime = gmtime();
    $bs_qian = '';
    //前缀内容
    $bs_do = '+';
    //增减
    if ($inout > 0) {
        $bs_qian = '撤销';
        $bs_do = '-';
    }
    $nowmoney = 0;
    $suppid = 0;
    $suppmoney = array();
    while ($row = $db->fetchRow($query)) {
        if ($suppid != $row['supplier_id']) {
            $nowmoney = $db->getOne("select supplier_money from " . $ecs->table('supplier') . " where supplier_id=" . $row['supplier_id']);
        }
        if ($inout > 0) {
            $nowmoney -= $row['total_fee'];
        } else {
            $nowmoney += $row['total_fee'];
        }
        $loginfo = array('rebateid' => $rid, 'addtime' => $addtime, 'reason' => $bs_qian . '订单' . $row['order_sn'] . '分佣:' . $bs_do . $row['total_fee'], 'supplier_money' => $nowmoney, 'doman' => '平台方:' . $_SESSION['user_name'], 'supplier_id' => $row['supplier_id']);
        $db->autoExecute($ecs->table('supplier_money_log'), $loginfo, 'INSERT');
        $suppid = $row['supplier_id'];
        $suppmoney[$suppid] = $nowmoney;
        unset($loginfo);
    }
    //保存目前的资金
    foreach ($suppmoney as $k => $v) {
        $db->query('update ' . $ecs->table('supplier') . " set supplier_money='" . $v . "' where supplier_id=" . $k);
    }
}
Example #16
0
function teammem_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']);
        }
        $filter['consignee'] = empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']);
        $filter['email'] = empty($_REQUEST['email']) ? '' : trim($_REQUEST['email']);
        $filter['address'] = empty($_REQUEST['address']) ? '' : trim($_REQUEST['address']);
        $filter['zipcode'] = empty($_REQUEST['zipcode']) ? '' : trim($_REQUEST['zipcode']);
        $filter['tel'] = empty($_REQUEST['tel']) ? '' : trim($_REQUEST['tel']);
        $filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']);
        $filter['country'] = empty($_REQUEST['country']) ? 0 : intval($_REQUEST['country']);
        $filter['province'] = empty($_REQUEST['province']) ? 0 : intval($_REQUEST['province']);
        $filter['city'] = empty($_REQUEST['city']) ? 0 : intval($_REQUEST['city']);
        $filter['district'] = empty($_REQUEST['district']) ? 0 : intval($_REQUEST['district']);
        $filter['shipping_id'] = empty($_REQUEST['shipping_id']) ? 0 : intval($_REQUEST['shipping_id']);
        $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']);
        $filter['pay_start_time'] = empty($_REQUEST['pay_start_time']) ? '' : (strpos($_REQUEST['pay_start_time'], '-') > 0 ? local_strtotime($_REQUEST['pay_start_time']) : $_REQUEST['pay_start_time']);
        $filter['pay_end_time'] = empty($_REQUEST['pay_end_time']) ? '' : (strpos($_REQUEST['pay_end_time'], '-') > 0 ? local_strtotime($_REQUEST['pay_end_time']) : $_REQUEST['pay_end_time']);
        $filter['team_sign'] = empty($_REQUEST['team_sign']) ? '' : $_REQUEST['team_sign'];
        $filter['team_status'] = isset($_REQUEST['team_status']) ? intval($_REQUEST['team_status']) : -1;
        $filter['search_team_sign'] = empty($_REQUEST['search_team_sign']) ? '' : $_REQUEST['search_team_sign'];
        $filter['extension_id'] = isset($_REQUEST['extension_id']) ? intval($_REQUEST['extension_id']) : '';
        $filter['team_lack_num'] = isset($_REQUEST['team_lack_num']) ? intval($_REQUEST['team_lack_num']) : '';
        $where = " WHERE 1 and o.extension_code='team_goods' and o.team_sign= " . $filter['team_sign'] . " ";
        //and o.team_status>0
        /*
                if(!empty($refund_ex) )
                {
                    $arr = $GLOBALS['db']->getCol("select distinct order_id from ".$GLOBALS['hhs']->table("order_goods")." where   ".$refund_ex);
                    $arr[] = 0;
                    $where .= " and o.order_id ".db_create_in($arr);
                }*/
        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']}'";
        }
        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']) . "%'";
        }
        if ($filter['start_time']) {
            $where .= " AND o.add_time >= '{$filter['start_time']}'";
        }
        if ($filter['end_time']) {
            $where .= " AND o.add_time <= '{$filter['end_time']}'";
        }
        if ($filter['pay_start_time']) {
            $where .= " AND o.pay_time >= '{$filter['pay_start_time']}'";
        }
        if ($filter['pay_end_time']) {
            $where .= " AND o.pay_time <= '{$filter['pay_end_time']}'";
        }
        if ($filter['team_status'] != -1) {
            $where .= " AND o.team_status = '{$filter['team_status']}'";
        }
        if ($filter['extension_id']) {
            $where .= " AND o.extension_id = '{$filter['extension_id']}'";
        }
        //综合状态
        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['hhs']->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['HHSCP']['page_size']) && intval($_COOKIE['HHSCP']['page_size']) > 0)
                {
                    $filter['page_size'] = intval($_COOKIE['HHSCP']['page_size']);
                }
                else
                {
                    $filter['page_size'] = 15;
                }*/
        /* 记录总数
                if ($filter['user_name'])
                {
                    $sql = "SELECT COUNT(*) FROM " . $GLOBALS['hhs']->table('order_info') . " AS o ,".
                        $GLOBALS['hhs']->table('users') . " AS u " . $where;
                }
                else
                {
                    $sql = "SELECT COUNT(*) FROM " . $GLOBALS['hhs']->table('order_info') . " AS o ". $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 * from " . $GLOBALS['hhs']->table('order_info') . " as o  LEFT JOIN " . $GLOBALS['hhs']->table('users') . " AS u ON u.user_id=o.user_id " . $where;
        //."  LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",$filter[page_size]";
        $orders = $GLOBALS['db']->getAll($sql);
        if (!empty($orders)) {
            foreach ($orders as $v) {
                if ($v['extension_code'] == 'team_goods' && $v['team_status'] == 1 && $v['team_sign']) {
                    $sql = "select pay_time from " . $GLOBALS['hhs']->table('order_info') . " where order_id=" . $v['team_sign'];
                    $pay_time = $GLOBALS['db']->getOne($sql);
                    if ($pay_time + $GLOBALS['_CFG']['team_suc_time'] * 24 * 3600 < gmtime()) {
                        //取消订单
                        $sql = "update " . $GLOBALS['hhs']->table('order_info') . " set team_status=3,order_status=2 where team_status=1 and team_sign=" . $v['team_sign'];
                        $GLOBALS['db']->query($sql);
                        $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET order_status=2 WHERE team_status=0 and team_sign=" . $v['team_sign'];
                        $GLOBALS['db']->query($sql);
                    }
                }
            }
        }
        /* 查询 */
        $sql = "SELECT o.discount_type,o.discount_amount,u.uname,o.team_num,o.transaction_id,o.teammen_num,(o.team_num-o.teammen_num) as team_lack_num, o.team_status,o.team_sign,o.team_first,o.extension_code, o.order_id, o.order_sn, o.add_time,o.pay_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," . "o.pay_status, o.consignee, o.address, o.email, o.tel,  o.extension_id, " . "(" . order_amount_field('o.') . ") AS total_fee, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer,u.openid,u.user_name,u.headimgurl, " . "g.goods_name,g.goods_sn ,g.goods_id,g.shop_price " . " FROM " . $GLOBALS['hhs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['hhs']->table('users') . " AS u ON u.user_id=o.user_id " . " LEFT JOIN " . $GLOBALS['hhs']->table('goods') . " AS g ON g.goods_id=o.extension_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);
    /* 格式话数据 */
    foreach ($row as $key => $value) {
        $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']);
        $row[$key]['refund_goods_list'] = get_order_goods_list($value['order_id'], " and refund_status>0");
        if ($value['order_status'] == OS_INVALID || $value['order_status'] == OS_CANCELED) {
            /* 如果该订单为无效或取消则显示删除链接 */
            $row[$key]['can_remove'] = 1;
        } else {
            $row[$key]['can_remove'] = 0;
        }
        $sql = "select count(*) from " . $GLOBALS['hhs']->table('order_info') . " where team_sign=" . $value['team_sign'] . " and team_status=3 ";
        $row[$key]['can_refund'] = $GLOBALS['db']->getOne($sql);
        $row[$key]['formated_pay_date'] = local_date('Y-m-d H:i:s', $value['pay_time']);
        if ($value['team_sign']) {
            $sql = "select pay_time from " . $GLOBALS['hhs']->table('order_info') . " where order_id=" . $value['team_sign'];
            $team_start_time = $GLOBALS['db']->getOne($sql);
            if ($team_start_time) {
                $row[$key]['team_start_date'] = local_date('Y-m-d H:i:s', $team_start_time);
                $row[$key]['team_end_date'] = local_date('Y-m-d H:i:s', $team_start_time + $GLOBALS['_CFG']['team_suc_time'] * 24 * 3600);
            }
        }
        //商品价格
        $sql = "select goods_price,goods_number from " . $GLOBALS['hhs']->table('order_goods') . " where order_id=" . $value['order_id'] . " limit 1";
        $goods = $GLOBALS['db']->getRow($sql);
        $row[$key]['goods_price'] = $goods['goods_price'];
        $row[$key]['goods_number'] = $goods['goods_number'];
    }
    $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}