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; }
function get_user_team_orders($user_id, $num = 10, $start = 0, $ext = null) { global $_CFG; /*判断组团的状态*/ $sql = "select * from " . $GLOBALS['hhs']->table('order_info') . " where user_id='{$user_id}' limit " . $start . "," . $num; $orders = $GLOBALS['db']->getAll($sql); if (!empty($orders)) { foreach ($orders as $v) { if ($v['extension_code'] == 'team_goods' && $v['team_status'] == 1) { $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 + $_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); } } } } /* 取得订单列表 */ $arr = array(); $sql = "SELECT extension_id,team_sign,team_first,team_status,order_id, order_sn, order_status, shipping_status, pay_status, add_time, " . "(goods_amount + shipping_fee + insure_fee + pay_fee + pack_fee + card_fee + tax - discount) AS total_fee " . " FROM " . $GLOBALS['hhs']->table('order_info') . " WHERE user_id = '{$user_id}' and extension_code='team_goods' and team_status>0 " . $ext . " ORDER BY add_time DESC"; $res = $GLOBALS['db']->SelectLimit($sql, $num, $start); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['order_status'] == OS_UNCONFIRMED) { $row['handler'] = "<a href=\"user.php?act=cancel_order&order_id=" . $row['order_id'] . "\" onclick=\"if (!confirm('" . $GLOBALS['_LANG']['confirm_cancel'] . "')) return false;\">" . $GLOBALS['_LANG']['cancel'] . "</a>"; } else { if ($row['order_status'] == OS_SPLITED) { /* 对配送状态的处理 */ if ($row['shipping_status'] == SS_SHIPPED) { @($row['handler'] = "<a href=\"user.php?act=affirm_received&order_id=" . $row['order_id'] . "\" onclick=\"if (!confirm('" . $GLOBALS['_LANG']['confirm_received'] . "')) return false;\">" . $GLOBALS['_LANG']['received'] . "</a>"); } elseif ($row['shipping_status'] == SS_RECEIVED) { @($row['handler'] = '<span style="color:red">' . $GLOBALS['_LANG']['ss_received'] . '</span>'); } else { if ($row['pay_status'] == PS_UNPAYED) { @($row['handler'] = "<a href=\"user.php?act=order_detail&order_id=" . $row['order_id'] . '">' . $GLOBALS['_LANG']['pay_money'] . '</a>'); } else { @($row['handler'] = "<a href=\"user.php?act=order_detail&order_id=" . $row['order_id'] . '">' . $GLOBALS['_LANG']['view_order'] . '</a>'); } } } else { $row['handler'] = '<span style="color:red">' . $GLOBALS['_LANG']['os'][$row['order_status']] . '</span>'; } } $row['shipping_status'] = $row['shipping_status'] == SS_SHIPPED_ING ? SS_PREPARING : $row['shipping_status']; $row['order_status'] = $GLOBALS['_LANG']['os'][$row['order_status']] . ',' . $GLOBALS['_LANG']['ps'][$row['pay_status']] . ',' . $GLOBALS['_LANG']['ss'][$row['shipping_status']]; $row['team_status'] = $GLOBALS['_LANG']['team_status'][$row['team_status']]; $row['goods_list'] = get_order_goods_list($row['order_id']); $row['can_refund'] = can_refund($row['order_id']); $arr[] = array('order_id' => $row['order_id'], 'order_sn' => $row['order_sn'], 'extension_id' => $row['extension_id'], 'team_sign' => $row['team_sign'], 'goods_list' => $row['goods_list'], 'team_first' => $row['team_first'], 'team_status' => $row['team_status'], 'goods_num' => count($row['goods_list']), 'order_time' => local_date($GLOBALS['_CFG']['time_format'], $row['add_time']), 'order_status' => $row['order_status'], 'total_fee' => price_format($row['total_fee'], false), 'can_refund' => $row['can_refund'], 'handler' => $row['handler']); } return $arr; }