7 Star 19 Fork 7

王东祥/HongYuDSC

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
auction.php 24.12 KB
Copy Edit Raw Blame History
鸿宇科技 authored 2018-03-02 02:43 . Initial commit
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
<?php
//zend by QQ:1527200768 鸿宇科技 禁止倒卖 一经发现停止任何服务
function auction_count($keywords, $top_children = array())
{
$now = gmtime();
$where = '';
if ($keywords) {
$where = 'AND (a.act_name LIKE \'%' . $keywords . '%\' OR g.goods_name LIKE \'%' . $keywords . '%\') ';
}
if (!empty($top_children)) {
$where .= 'AND ' . $top_children . '';
}
$sql = 'SELECT COUNT(*) ' . 'FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON a.goods_id = g.goods_id ' . ' WHERE a.act_type = \'' . GAT_AUCTION . '\' ' . ('AND a.start_time <= \'' . $now . '\' AND a.end_time >= \'' . $now . '\' AND a.is_finished < 2 AND a.review_status = 3 ') . $where;
return $GLOBALS['db']->getOne($sql);
}
function get_top_cat()
{
$now = gmtime();
$cat_top_list = array();
$sql = 'SELECT g.cat_id ' . 'FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON a.goods_id = g.goods_id ' . ' WHERE a.act_type = \'' . GAT_AUCTION . '\' ' . ('AND a.start_time <= \'' . $now . '\' AND a.end_time >= \'' . $now . '\' AND a.is_finished < 2 AND a.review_status = 3 ');
$cat_list = $GLOBALS['db']->getAll($sql);
foreach ($cat_list as $k => $v) {
$cat_info = get_topparent_cat($v['cat_id']);
$cat_top_list[$cat_info['cat_id']] = $cat_info;
}
return $cat_top_list;
}
function auction_list($keywords, $sort, $order, $size, $page, $top_children = array())
{
$auction_list = array();
$auction_list['finished'] = $auction_list['finished'] = array();
$where = '';
if ($keywords) {
$where = 'AND (a.act_name LIKE \'%' . $keywords . '%\' OR g.goods_name LIKE \'%' . $keywords . '%\') ';
}
if ($sort) {
$by_sort = ' a.' . $sort;
}
if (!empty($top_children)) {
$where .= 'AND ' . $top_children . '';
}
$now = gmtime();
$sql = 'SELECT a.*, IFNULL(g.goods_thumb, \'\') AS goods_thumb ' . 'FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON a.goods_id = g.goods_id ' . 'WHERE a.act_type = \'' . GAT_AUCTION . '\' ' . $where . ('AND a.start_time <= \'' . $now . '\' AND a.end_time >= \'' . $now . '\' AND a.is_finished < 2 AND a.review_status = 3 ORDER BY ' . $by_sort . ' ' . $order);
if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'load_more_goods') {
$start = intval($_REQUEST['goods_num']);
}
else {
$start = ($page - 1) * $size;
}
$res = $GLOBALS['db']->selectLimit($sql, $size, $start);
while ($row = $GLOBALS['db']->fetchRow($res)) {
$ext_info = unserialize($row['ext_info']);
$auction = array_merge($row, $ext_info);
$auction['status_no'] = auction_status($auction);
$auction['start_time'] = local_date($GLOBALS['_CFG']['time_format'], $auction['start_time']);
$auction['end_time'] = local_date($GLOBALS['_CFG']['time_format'], $auction['end_time']);
$auction['formated_start_price'] = price_format($auction['start_price']);
$auction['formated_end_price'] = price_format($auction['end_price']);
$auction['formated_deposit'] = price_format($auction['deposit']);
$auction['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$auction['url'] = build_uri('auction', array('auid' => $auction['act_id']));
$auction['count'] = auction_log($auction['act_id'], 1);
$auction['current_time'] = local_date('Y-m-d H:i:s', gmtime());
$auction['rz_shopName'] = get_shop_name($row['user_id'], 1);
if (1 < $auction['status_no']) {
$sql = 'SELECT COUNT(*)' . ' FROM ' . $GLOBALS['ecs']->table('order_info') . ' WHERE extension_code = \'auction\'' . (' AND extension_id = \'' . $auction['act_id'] . '\'') . ' AND order_status ' . db_create_in(array(OS_CONFIRMED, OS_UNCONFIRMED));
$auction['order_count'] = $GLOBALS['db']->getOne($sql);
}
else {
$auction['order_count'] = 0;
}
$sql = 'SELECT COUNT(DISTINCT bid_user) FROM ' . $GLOBALS['ecs']->table('auction_log') . (' WHERE act_id = \'' . $auction['act_id'] . '\'');
$auction['bid_user_count'] = $GLOBALS['db']->getOne($sql);
if (0 < $auction['bid_user_count']) {
$sql = 'SELECT a.*, u.user_name ' . 'FROM ' . $GLOBALS['ecs']->table('auction_log') . ' AS a, ' . $GLOBALS['ecs']->table('users') . ' AS u ' . 'WHERE a.bid_user = u.user_id ' . ('AND act_id = \'' . $auction['act_id'] . '\' ') . 'ORDER BY a.log_id DESC';
$row = $GLOBALS['db']->getRow($sql);
$row['formated_bid_price'] = price_format($row['bid_price'], false);
$row['bid_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['bid_time']);
$auction['last_bid'] = $row;
}
$auction['is_winner'] = 0;
if ($auction['last_bid']['bid_user']) {
if ($auction['status_no'] == FINISHED && $auction['last_bid']['bid_user'] == $_SESSION['user_id'] && $auction['order_count'] == 0) {
$auction['is_winner'] = 1;
}
}
$auction['s_user_id'] = $_SESSION['user_id'];
if ($auction['status_no'] < 2) {
$auction_list['under_way'][] = $auction;
}
else {
$auction_list['finished'][] = $auction;
}
}
if ($auction_list['under_way']) {
$auction_list = @array_merge($auction_list['under_way'], $auction_list['finished']);
}
else {
$auction_list = $auction_list['finished'];
}
return $auction_list;
}
function get_exchange_recommend_goods($type = '', $cats = '', $min = 0, $max = 0, $ext)
{
$price_where = 0 < $min ? ' AND g.shop_price >= ' . $min . ' ' : '';
$price_where .= 0 < $max ? ' AND g.shop_price <= ' . $max . ' ' : '';
$now = gmtime();
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, ' . 'g.goods_brief, g.goods_thumb, goods_img, b.brand_name, ' . 'ga.act_name, ga.act_id, ga.ext_info, ga.start_time, ga.start_time, ga.end_time ' . 'FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' AS ga ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = ga.goods_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . 'WHERE ga.act_type = \'' . GAT_AUCTION . '\' ' . ('AND ga.start_time <= \'' . $now . '\' AND ga.review_status = 3 AND ga.end_time >= \'' . $now . '\' AND ga.is_finished < 2 ') . $price_where . $ext;
$num = 0;
$type2lib = array('best' => 'auction_best', 'new' => 'auction_new', 'hot' => 'auction_hot');
$num = get_library_number($type2lib[$type], 'auction_list');
switch ($type) {
case 'best':
$sql .= ' AND ga.is_best = 1';
break;
case 'new':
$sql .= ' AND ga.is_new = 1';
break;
case 'hot':
$sql .= ' AND ga.is_hot = 1';
break;
}
if (!empty($cats)) {
}
$order_type = $GLOBALS['_CFG']['recommend_order'];
$sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY RAND()';
$res = $GLOBALS['db']->selectLimit($sql, $num);
$idx = 0;
$auction = array();
while ($row = $GLOBALS['db']->fetchRow($res)) {
$auction[$idx]['id'] = $row['goods_id'];
$auction[$idx]['name'] = $row['goods_name'];
$auction[$idx]['brief'] = $row['goods_brief'];
$auction[$idx]['brand_name'] = $row['brand_name'];
$auction[$idx]['short_name'] = 0 < $GLOBALS['_CFG']['goods_name_length'] ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$auction[$idx]['exchange_integral'] = $row['exchange_integral'];
$auction[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$auction[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$auction[$idx]['url'] = build_uri('auction', array('auid' => $row['act_id'], 0 => $row['act_name']));
$auction[$idx]['format_start_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['start_time']);
$auction[$idx]['format_end_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['end_time']);
$ext_info = unserialize($row['ext_info']);
$auction_info = array_merge($row, $ext_info);
$auction[$idx]['auction'] = $auction_info;
$auction[$idx]['status_no'] = auction_status($auction_info);
$auction[$idx]['start_price'] = price_format($auction_info['start_price']);
$auction[$idx]['count'] = auction_log($row['act_id'], 1);
$auction[$idx]['short_style_name'] = add_style($auction[$idx]['short_name'], $row['goods_name_style']);
$idx++;
}
return $auction;
}
define('IN_ECS', true);
require dirname(__FILE__) . '/includes/init.php';
require ROOT_PATH . '/includes/lib_area.php';
require ROOT_PATH . 'includes/lib_order.php';
$area_info = get_area_info($province_id);
$area_id = $area_info['region_id'];
$where = 'regionId = \'' . $province_id . '\'';
$date = array('parent_id');
$region_id = get_table_date('region_warehouse', $where, $date, 2);
if (isset($_COOKIE['region_id']) && !empty($_COOKIE['region_id'])) {
$region_id = $_COOKIE['region_id'];
}
if (empty($_REQUEST['act'])) {
$_REQUEST['act'] = 'list';
}
$smarty->assign('now_time', gmtime());
if ($_REQUEST['act'] == 'list') {
$smarty->assign('category_load_type', $_CFG['category_load_type']);
$smarty->assign('query_string', preg_replace('/act=\\w+&?/', '', $_SERVER['QUERY_STRING']));
$page = isset($_REQUEST['page']) && 0 < intval($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
$size = isset($_CFG['page_size']) && 0 < intval($_CFG['page_size']) ? intval($_CFG['page_size']) : 10;
$size = 15;
$cat_id = isset($_REQUEST['cat_id']) && 0 < intval($_REQUEST['cat_id']) ? intval($_REQUEST['cat_id']) : 0;
$integral_max = isset($_REQUEST['integral_max']) && 0 < intval($_REQUEST['integral_max']) ? intval($_REQUEST['integral_max']) : 0;
$integral_min = isset($_REQUEST['integral_min']) && 0 < intval($_REQUEST['integral_min']) ? intval($_REQUEST['integral_min']) : 0;
$keywords = !empty($_REQUEST['keywords']) ? htmlspecialchars(trim($_REQUEST['keywords'])) : '';
$cat_top_id = isset($_REQUEST['cat_top_id']) ? intval($_REQUEST['cat_top_id']) : 0;
$default_sort_order_method = $_CFG['sort_order_method'] == '0' ? 'DESC' : 'ASC';
$default_sort_order_type = $_CFG['sort_order_type'] == '0' ? 'act_id' : ($_CFG['sort_order_type'] == '1' ? 'start_time' : 'end_time');
$sort = isset($_REQUEST['sort']) && in_array(trim(strtolower($_REQUEST['sort'])), array('act_id', 'start_time', 'end_time')) ? trim($_REQUEST['sort']) : $default_sort_order_type;
$order = isset($_REQUEST['order']) && in_array(trim(strtoupper($_REQUEST['order'])), array('ASC', 'DESC')) ? trim($_REQUEST['order']) : $default_sort_order_method;
$children = get_children($cat_id);
$top_children = array();
if (0 < $cat_top_id) {
$top_children = get_children($cat_top_id);
}
$count = auction_count($keywords, $top_children);
if (0 < $count) {
$page_count = ceil($count / $size);
$page = $page_count < $page ? $page_count : $page;
$cache_id = $_CFG['lang'] . '-' . $size . '-' . $page;
$cache_id = sprintf('%X', crc32($cache_id));
}
else {
$cache_id = $_CFG['lang'];
$cache_id = sprintf('%X', crc32($cache_id));
}
if (!$smarty->is_cached('auction_list.dwt', $cache_id)) {
if (0 < $count) {
$auction_list = auction_list($keywords, $sort, $order, $size, $page, $top_children);
$smarty->assign('auction_list', $auction_list);
if (defined('THEME_EXTENSION')) {
$smarty->assign('cat_top_list', get_top_cat());
}
if (!$_CFG['category_load_type']) {
$pager = get_pager('auction.php', array('act' => 'list', 'keywords' => $keywords, 'sort' => $sort, 'order' => $order), $count, $page, $size);
$smarty->assign('pager', $pager);
}
}
$smarty->assign('cfg', $_CFG);
assign_template();
$position = assign_ur_here();
$smarty->assign('page_title', $position['title']);
$smarty->assign('ur_here', $position['ur_here']);
$smarty->assign('helps', get_shop_help());
if (!defined('THEME_EXTENSION')) {
$categories_pro = get_category_tree_leve_one();
$smarty->assign('categories_pro', $categories_pro);
}
$smarty->assign('feed_url', $_CFG['rewrite'] == 1 ? 'feed-typeauction.xml' : 'feed.php?type=auction');
$smarty->assign('hot_goods', get_exchange_recommend_goods('hot', $children, $integral_min, $integral_max));
$smarty->assign('category', 1.0E+19);
if (defined('THEME_EXTENSION')) {
$smarty->assign('cat_top_id', $cat_top_id);
for ($i = 1; $i <= $_CFG['auction_ad']; $i++) {
$activity_top_banner .= '\'activity_top_ad_auction' . $i . ',';
}
$smarty->assign('activity_top_banner', $activity_top_banner);
}
assign_dynamic('auction_list');
}
$smarty->display('auction_list.dwt', $cache_id);
}
if ($_REQUEST['act'] == 'load_more_goods') {
$page = isset($_REQUEST['page']) && 0 < intval($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
$size = isset($_CFG['page_size']) && 0 < intval($_CFG['page_size']) ? intval($_CFG['page_size']) : 10;
$size = 15;
$cat_id = isset($_REQUEST['cat_id']) && 0 < intval($_REQUEST['cat_id']) ? intval($_REQUEST['cat_id']) : 0;
$integral_max = isset($_REQUEST['integral_max']) && 0 < intval($_REQUEST['integral_max']) ? intval($_REQUEST['integral_max']) : 0;
$integral_min = isset($_REQUEST['integral_min']) && 0 < intval($_REQUEST['integral_min']) ? intval($_REQUEST['integral_min']) : 0;
$keywords = !empty($_REQUEST['keywords']) ? htmlspecialchars(trim($_REQUEST['keywords'])) : '';
$cat_top_id = isset($_REQUEST['cat_top_id']) ? intval($_REQUEST['cat_top_id']) : 0;
$default_sort_order_method = $_CFG['sort_order_method'] == '0' ? 'DESC' : 'ASC';
$default_sort_order_type = $_CFG['sort_order_type'] == '0' ? 'act_id' : ($_CFG['sort_order_type'] == '1' ? 'start_time' : 'end_time');
$sort = isset($_REQUEST['sort']) && in_array(trim(strtolower($_REQUEST['sort'])), array('act_id', 'start_time', 'end_time')) ? trim($_REQUEST['sort']) : $default_sort_order_type;
$order = isset($_REQUEST['order']) && in_array(trim(strtoupper($_REQUEST['order'])), array('ASC', 'DESC')) ? trim($_REQUEST['order']) : $default_sort_order_method;
$children = get_children($cat_id);
if (0 < $cat_top_id) {
$top_children = get_children($cat_top_id);
}
$auction_list = auction_list($keywords, $sort, $order, $size, $page, $top_children);
$smarty->assign('auction_list', $auction_list);
$smarty->assign('type', 'auction');
if (defined('THEME_EXTENSION')) {
$smarty->assign('cat_top_list', get_top_cat());
$smarty->assign('cat_top_id', $cat_top_id);
}
$result = array('error' => 0, 'message' => '', 'cat_goods' => '', 'best_goods' => '');
$result['cat_goods'] = html_entity_decode($smarty->fetch('library/more_goods_page.lbi'));
exit(json_encode($result));
}
else if ($_REQUEST['act'] == 'view') {
$cat_id = isset($_REQUEST['cat_id']) && 0 < intval($_REQUEST['cat_id']) ? intval($_REQUEST['cat_id']) : 0;
$integral_max = isset($_REQUEST['integral_max']) && 0 < intval($_REQUEST['integral_max']) ? intval($_REQUEST['integral_max']) : 0;
$integral_min = isset($_REQUEST['integral_min']) && 0 < intval($_REQUEST['integral_min']) ? intval($_REQUEST['integral_min']) : 0;
$user_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0;
$children = get_children($cat_id);
$smarty->assign('hot_goods', get_exchange_recommend_goods('hot', $children, $integral_min, $integral_max));
$smarty->assign('user_id', $user_id);
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
if ($id <= 0) {
ecs_header("Location: ./\n");
exit();
}
$user = user_info($user_id);
$smarty->assign('user', $user);
$auction = auction_info($id);
if (!$auction) {
show_message($_LANG['now_not_snatch'], $_LANG['back_auction_home'], 'auction.php');
}
$auction['is_winner'] = 0;
$cache_id = $_CFG['lang'] . '-' . $id . '-' . $auction['status_no'];
if ($auction['status_no'] == UNDER_WAY) {
if (isset($auction['last_bid'])) {
$cache_id = $cache_id . '-' . $auction['last_bid']['bid_time'];
}
}
else if ($auction['last_bid']) {
if ($auction['status_no'] == FINISHED && $auction['last_bid']['bid_user'] == $_SESSION['user_id'] && $auction['order_count'] == 0) {
$auction['is_winner'] = 1;
}
$cache_id = $cache_id . '-' . $auction['last_bid']['bid_time'] . '-1';
}
$cache_id = sprintf('%X', crc32($cache_id));
if (!$smarty->is_cached('auction.dwt', $cache_id)) {
if (0 < $auction['product_id']) {
$goods_specifications = get_specifications_list($auction['goods_id']);
$good_products = get_good_products($auction['goods_id'], 'AND product_id = ' . $auction['product_id']);
$_good_products = explode('|', $good_products[0]['goods_attr']);
$products_info = '';
foreach ($_good_products as $value) {
$products_info .= ' ' . $goods_specifications[$value]['attr_name'] . ':' . $goods_specifications[$value]['attr_value'];
}
$smarty->assign('products_info', $products_info);
unset($goods_specifications);
unset($good_products);
unset($_good_products);
unset($products_info);
}
$auction['gmt_end_time'] = local_strtotime($auction['end_time']);
$smarty->assign('auction', $auction);
$goods_id = $auction['goods_id'];
$goods = goods_info($goods_id, '', '', '', '', 1);
if (empty($goods)) {
ecs_header("Location: ./\n");
exit();
}
$goods['url'] = build_uri('goods', array('gid' => $goods_id), $goods['goods_name']);
$smarty->assign('auction_goods', $goods);
$smarty->assign('goods', $goods);
$smarty->assign('auction_log', auction_log($id));
$smarty->assign('auction_count', auction_log($id, 1));
$smarty->assign('cfg', $_CFG);
assign_template();
$position = assign_ur_here(0, $goods['goods_name']);
$smarty->assign('page_title', $position['title']);
$smarty->assign('ur_here', $position['ur_here']);
if (!defined('THEME_EXTENSION')) {
$categories_pro = get_category_tree_leve_one();
$smarty->assign('categories_pro', $categories_pro);
}
$smarty->assign('helps', get_shop_help());
$smarty->assign('pictures', get_goods_gallery($goods_id));
$mc_all = ments_count_all($goods_id);
$mc_one = ments_count_rank_num($goods_id, 1);
$mc_two = ments_count_rank_num($goods_id, 2);
$mc_three = ments_count_rank_num($goods_id, 3);
$mc_four = ments_count_rank_num($goods_id, 4);
$mc_five = ments_count_rank_num($goods_id, 5);
$comment_all = get_conments_stars($mc_all, $mc_one, $mc_two, $mc_three, $mc_four, $mc_five);
if (0 < $goods['user_id']) {
$merchants_goods_comment = get_merchants_goods_comment($goods['user_id']);
}
$smarty->assign('comment_all', $comment_all);
$smarty->assign('merch_cmt', $merchants_goods_comment);
assign_dynamic('auction');
}
$basic_date = array('region_name');
$basic_info['province'] = get_table_date('region', 'region_id = \'' . $goods['province'] . '\'', $basic_date, 2);
$basic_info['city'] = get_table_date('region', 'region_id= \'' . $goods['city'] . '\'', $basic_date, 2) . '市';
$basic_info['kf_type'] = $goods['kf_type'];
$basic_info['[kf_ww'] = $goods['kf_ww'];
$basic_info['kf_qq'] = $goods['kf_qq'];
$basic_info['shop_name'] = $goods['shop_name'];
$shop_information = get_shop_name($goods['user_id']);
if ($goods['user_id'] == 0) {
if ($db->getOne('SELECT kf_im_switch FROM ' . $ecs->table('seller_shopinfo') . 'WHERE ru_id = 0')) {
$shop_information['is_dsc'] = true;
}
else {
$shop_information['is_dsc'] = false;
}
}
else {
$shop_information['is_dsc'] = false;
}
$smarty->assign('shop_information', $shop_information);
$smarty->assign('basic_info', $basic_info);
$smarty->assign('category', 1.0E+19);
$sql = 'UPDATE ' . $ecs->table('goods') . ' SET click_count = click_count + 1 ' . 'WHERE goods_id = \'' . $auction['goods_id'] . '\'';
$db->query($sql);
$smarty->display('auction.dwt', $cache_id);
}
else if ($_REQUEST['act'] == 'bid') {
include_once ROOT_PATH . 'includes/lib_order.php';
$_POST['price'] = isset($_POST['price']) ? intval($_POST['price']) : 0;
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
if ($id <= 0) {
ecs_header("Location: ./\n");
exit();
}
$auction = auction_info($id);
if (empty($auction)) {
ecs_header("Location: ./\n");
exit();
}
if ($auction['status_no'] != UNDER_WAY) {
show_message($_LANG['au_not_under_way'], '', '', 'error');
}
$user_id = $_SESSION['user_id'];
if ($user_id <= 0) {
show_message($_LANG['au_bid_after_login']);
}
$user = user_info($user_id);
$bid_price = isset($_POST['buy-price']) ? round(floatval($_POST['buy-price']), 2) : 0;
if ($bid_price <= 0) {
show_message($_LANG['au_bid_price_error'], '', '', 'error');
}
$is_ok = false;
if (0 < $auction['end_price']) {
if ($auction['end_price'] <= $bid_price) {
$bid_price = $auction['end_price'];
$is_ok = true;
}
}
if (!$is_ok) {
if ($auction['bid_user_count'] == 0) {
$min_price = $auction['start_price'];
}
else {
$min_price = $auction['last_bid']['bid_price'] + $auction['amplitude'];
if (0 < $auction['end_price']) {
$min_price = min($min_price, $auction['end_price']);
}
}
if ($bid_price < $min_price) {
show_message(sprintf($_LANG['au_your_lowest_price'], price_format($min_price, false)), '', '', 'error');
}
}
if ($auction['last_bid']['bid_user'] == $user_id && $bid_price != $auction['end_price']) {
show_message($_LANG['au_bid_repeat_user'], '', '', 'error');
}
if (0 < $auction['deposit']) {
if ($user['user_money'] < $auction['deposit']) {
show_message($_LANG['au_user_money_short'], '', '', 'error');
}
if (0 < $auction['bid_user_count']) {
log_account_change($auction['last_bid']['bid_user'], $auction['deposit'], -1 * $auction['deposit'], 0, 0, sprintf($_LANG['au_unfreeze_deposit'], $auction['act_name']));
}
log_account_change($user_id, -1 * $auction['deposit'], $auction['deposit'], 0, 0, sprintf($_LANG['au_freeze_deposit'], $auction['act_name']));
}
$auction_log = array('act_id' => $id, 'bid_user' => $user_id, 'bid_price' => $bid_price, 'bid_time' => gmtime());
$db->autoExecute($ecs->table('auction_log'), $auction_log, 'INSERT');
if ($bid_price == $auction['end_price']) {
$sql = 'UPDATE ' . $ecs->table('goods_activity') . (' SET is_finished = 1 WHERE act_id = \'' . $id . '\' LIMIT 1');
$db->query($sql);
}
ecs_header('Location: auction.php?act=view&id=' . $id . "\n");
exit();
}
else if ($_REQUEST['act'] == 'buy') {
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
if ($id <= 0) {
ecs_header("Location: ./\n");
exit();
}
$auction = auction_info($id);
if (empty($auction)) {
ecs_header("Location: ./\n");
exit();
}
if ($auction['status_no'] != FINISHED) {
show_message($_LANG['au_not_finished'], '', '', 'error');
}
if ($auction['bid_user_count'] <= 0) {
show_message($_LANG['au_no_bid'], '', '', 'error');
}
if (0 < $auction['order_count']) {
show_message($_LANG['au_order_placed']);
}
$user_id = $_SESSION['user_id'];
if ($user_id <= 0) {
show_message($_LANG['au_buy_after_login']);
}
if ($auction['last_bid']['bid_user'] != $user_id) {
show_message($_LANG['au_final_bid_not_you'], '', '', 'error');
}
$goods = goods_info($auction['goods_id']);
$goods_attr = '';
$goods_attr_id = '';
if (0 < $auction['product_id']) {
$product_info = get_good_products($auction['goods_id'], 'AND product_id = ' . $auction['product_id']);
$goods_attr_id = str_replace('|', ',', $product_info[0]['goods_attr']);
$attr_list = array();
$sql = 'SELECT a.attr_name, g.attr_value ' . 'FROM ' . $ecs->table('goods_attr') . ' AS g, ' . $ecs->table('attribute') . ' AS a ' . 'WHERE g.attr_id = a.attr_id ' . 'AND g.goods_attr_id ' . db_create_in($goods_attr_id) . ' ORDER BY a.sort_order, a.attr_id, g.goods_attr_id';
$res = $db->query($sql);
while ($row = $db->fetchRow($res)) {
$attr_list[] = $row['attr_name'] . ': ' . $row['attr_value'];
}
$goods_attr = join(chr(13) . chr(10), $attr_list);
}
else {
$auction['product_id'] = 0;
}
if (!empty($_SESSION['user_id'])) {
$sess = '';
}
else {
$sess = real_cart_mac_ip();
}
include_once ROOT_PATH . 'includes/lib_order.php';
clear_cart(CART_AUCTION_GOODS);
$cart = array('user_id' => $user_id, 'session_id' => $sess, 'goods_id' => $auction['goods_id'], 'goods_sn' => addslashes($goods['goods_sn']), 'goods_name' => addslashes($goods['goods_name']), 'market_price' => $goods['market_price'], 'goods_price' => $auction['last_bid']['bid_price'], 'goods_number' => 1, 'goods_attr' => $goods_attr, 'goods_attr_id' => $goods_attr_id, 'warehouse_id' => $region_id, 'area_id' => $area_id, 'is_real' => $goods['is_real'], 'ru_id' => $goods['user_id'], 'extension_code' => addslashes($goods['extension_code']), 'parent_id' => 0, 'rec_type' => CART_AUCTION_GOODS, 'is_gift' => 0);
$db->autoExecute($ecs->table('cart'), $cart, 'INSERT');
$_SESSION['flow_type'] = CART_AUCTION_GOODS;
$_SESSION['extension_code'] = 'auction';
$_SESSION['extension_id'] = $id;
$_SESSION['direct_shopping'] = 2;
ecs_header("Location: ./flow.php?step=checkout&direct_shopping=2\n");
exit();
}
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/doney/HongYuDSC.git
git@gitee.com:doney/HongYuDSC.git
doney
HongYuDSC
HongYuDSC
master

Search

D67c1975 1850385 1daf7b77 1850385