/** * 获取订单列表信息 * * @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; }
function get_stock_control_log() { $result = get_filter(); if ($result === false) { $filter = array(); $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']); $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']); if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['keyword'] = json_str_iconv($filter['keyword']); } $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $filter['start_date'] = empty($_REQUEST['start_date']) ? local_strtotime('-30 days') : $_REQUEST['start_date']; $filter['end_date'] = empty($_REQUEST['end_date']) ? local_strtotime('today') : $_REQUEST['end_date']; if (strpos($filter['start_date'], '-') !== false) { $filter['start_date'] = local_strtotime($filter['start_date']); $filter['end_date'] = local_strtotime($filter['end_date']); } $where = ' AND stock_status = 1 '; $where .= agency_where(); /*add by ccx for date 2014-11-28 商品入库列表*/ if (if_agency()) { if (!empty($filter['admin_agency_id'])) { $where .= " AND (a.admin_agency_id = {$filter['admin_agency_id']} ) "; } else { $where .= " AND (a.admin_agency_id = 0 ) "; } } if (!empty($filter['keyword'])) { $where = $where . " AND (a.goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%' or a.stock_number LIKE '%" . mysql_like_quote($filter['keyword']) . "%' )"; } if ($filter['start_date']) { $where = $where . " AND a.log_time >= '{$filter['start_date']}'"; } if ($filter['end_date']) { $where = $where . " AND a.log_time <= '" . ($filter['end_date'] + 86400) . "'"; } $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_control_log') . ' AS a ' . 'WHERE 1 ' . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获取库存日志管理数据 */ $sql = 'SELECT a.* ' . 'FROM ' . $GLOBALS['ecs']->table('stock_control_log') . ' AS a ' . 'WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $filter['keyword'] = stripslashes($filter['keyword']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $arr = array(); $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $rows['date'] = local_date($GLOBALS['_CFG']['time_format'], $rows['log_time']); $arr[] = $rows; } $GLOBALS['smarty']->assign('start_date', local_date('Y-m-d', $filter['start_date'])); $GLOBALS['smarty']->assign('end_date', local_date('Y-m-d', $filter['end_date'])); //显示商品的入库成本入库数量相关信息 $sql_limit = $sql . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}"; $overall_order_amount = overall_order_amount($sql); //总的计算 $current_order_amount = current_order_amount($sql_limit); // 当前页的计算 $GLOBALS['smarty']->assign('costing_price_amount', price_format($overall_order_amount['costing_price_amount'])); $GLOBALS['smarty']->assign('goods_number_amount', $overall_order_amount['goods_number_amount']); $GLOBALS['smarty']->assign('current_costing_price_amount', price_format($current_order_amount['current_costing_price_amount'])); $GLOBALS['smarty']->assign('current_goods_number_amount', $current_order_amount['current_goods_number_amount']); $filter['start_date'] = local_date('Y-m-d', $filter['start_date']); $filter['end_date'] = local_date('Y-m-d', $filter['end_date']); return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
function get_stock_control_log() { $result = get_filter(); if ($result === false) { $filter = array(); $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']); $filter['delete'] = empty($_REQUEST['delete']) ? '' : trim($_REQUEST['delete']); if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['keyword'] = json_str_iconv($filter['keyword']); } $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']); /*add by ccx for date 2014-11-27 只显示代理商本身*/ $where = agency_where(); /*add by hg for date 2014-04-21 可选商品*/ if (if_agency()) { if (!empty($filter['admin_agency_id'])) { $where .= " AND (a.admin_agency_id = {$filter['admin_agency_id']} ) "; } else { $where .= " AND (a.admin_agency_id = 0 ) "; } } if (!empty($filter['keyword'])) { $where .= " AND (a.goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%' or a.stock_info_sn LIKE '%" . mysql_like_quote($filter['keyword']) . "%' )"; } if (empty($filter['delete'])) { $where .= ' AND stock_status !=3 '; } $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_goods') . ' AS a ' . 'WHERE 1 ' . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获取采购商品列表管理数据 */ $sql = 'SELECT a.* ' . 'FROM ' . $GLOBALS['ecs']->table('stock_goods') . ' AS a ' . 'WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $filter['keyword'] = stripslashes($filter['keyword']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } //echo $sql; $arr = array(); $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $arr[] = $rows; } $overall_order_amount = overall_order_amount($sql); //总的计算 $GLOBALS['smarty']->assign('costing_price_amount', price_format($overall_order_amount['costing_price_amount'])); $GLOBALS['smarty']->assign('goods_number_amount', $overall_order_amount['goods_number_amount']); return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
function get_goods_stock_info() { $result = get_filter(); if ($result === false) { $filter = array(); $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']); $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']); $filter['status'] = strval(trim($_REQUEST['status'])); //m1 if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['keyword'] = json_str_iconv($filter['keyword']); } $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = agency_where(); /*add by hg for date 2014-04-21 可选商品*/ if (if_agency()) { if (!empty($filter['admin_agency_id'])) { $where .= " AND (a.admin_agency_id = {$filter['admin_agency_id']} ) "; } else { $where .= " AND (a.admin_agency_id = 0 ) "; } } //m1 增加采购订单查询条件 if (strlen(trim($_REQUEST['status'])) > 0) { $where .= " AND (a.stock_status = " . $filter['status'] . " ) "; } if (!empty($filter['keyword'])) { $where .= " AND (a.stock_info_sn LIKE '%" . mysql_like_quote($filter['keyword']) . "%' )"; } $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_info') . ' AS a ' . 'WHERE 1 ' . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获取采购商品列表管理数据 */ $sql = 'SELECT a.* ' . 'FROM ' . $GLOBALS['ecs']->table('stock_info') . ' AS a ' . 'WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $filter['keyword'] = stripslashes($filter['keyword']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } //echo $sql.'<br/>'; $arr = array(); $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $arr[] = $rows; } //显示采购订单的相关信息:包括库存数量,以及采购总价,当页的采购价格等等 $sql_limit = $sql . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}"; $overall_order_amount = overall_order_amount($sql); //总的计算 $current_order_amount = current_order_amount($sql_limit); // 当前页的计算 $GLOBALS['smarty']->assign('costing_price_amount', price_format($overall_order_amount['costing_price_amount'])); $GLOBALS['smarty']->assign('goods_number_amount', $overall_order_amount['goods_number_amount']); $GLOBALS['smarty']->assign('current_costing_price_amount', price_format($current_order_amount['current_costing_price_amount'])); $GLOBALS['smarty']->assign('current_goods_number_amount', $current_order_amount['current_goods_number_amount']); return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }