/** * 获取数据 */ public function show($fromusername, $info) { $articles = array(); $data = model('base')->model->table('goods')->field('goods_id, goods_name, goods_img')->where('is_on_sale = 1 and is_delete = 0 and goods_name like "%' . $info['user_keywords'] . '%"')->order('last_update desc')->limit(4)->select(); if (!empty($data)) { $articles['type'] = 'news'; foreach ($data as $key => $val) { // 不是远程图片 if (!preg_match('/(http:|https:)/is', $val['goods_img'])) { $articles['content'][$key]['PicUrl'] = get_image_path('', $val['goods_img']); } else { $articles['content'][$key]['PicUrl'] = $val['goods_img']; } $articles['content'][$key]['Title'] = $val['goods_name']; $articles['content'][$key]['Url'] = __HOST__ . url('goods/index', array('id' => $val['goods_id'])); } } else { $goods = model('Base')->model->table('goods')->field('goods_id, goods_name')->where('is_best = 1 and is_on_sale = 1 and is_delete = 0')->order('RAND()')->find(); $goods_url = __HOST__ . url('goods/index', array('id' => $goods['goods_id'])); $articles['type'] = 'text'; $articles['content'] = '没有搜索到相关商品,我们为您推荐:<a href="' . $goods_url . '" >' . $goods['goods_name'] . '</a>'; } // 积分赠送 $this->give_point($fromusername, $info); return $articles; }
/** * 获取指定用户的收藏商品列表 * @access public * @param int $user_id 用户ID * @param int $num 列表最大数量 * @param int $start 列表其实位置 * @return array $arr */ public function get_collection_goods($user_id, $num = 10, $start = 0) { $sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, g.promote_start_date,g.promote_end_date, c.rec_id, c.is_attention' . ' FROM ' . $this->pre . 'collect_goods AS c' . ' LEFT JOIN ' . $this->pre . 'goods AS g ' . 'ON g.goods_id = c.goods_id ' . ' LEFT JOIN ' . $this->pre . 'member_price AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " WHERE c.user_id = '{$user_id}' ORDER BY c.rec_id DESC limit {$start}, {$num}"; $res = $this->query($sql); $goods_list = array(); if (is_array($res)) { foreach ($res as $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } $goods_list[$row['goods_id']]['rec_id'] = $row['rec_id']; $goods_list[$row['goods_id']]['is_attention'] = $row['is_attention']; $goods_list[$row['goods_id']]['goods_id'] = $row['goods_id']; $goods_list[$row['goods_id']]['goods_name'] = $row['goods_name']; $goods_list[$row['goods_id']]['goods_thumb'] = get_image_path(0, $row['goods_thumb']); $goods_list[$row['goods_id']]['market_price'] = price_format($row['market_price']); $goods_list[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $goods_list[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $goods_list[$row['goods_id']]['url'] = url('goods/index', array('id' => $row['goods_id'])); } } return $goods_list; }
function get_goodslist($cat_id = 0) { $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_team=1 "; if ($cat_id > 0) { $where .= "AND g.cat_id = " . $cat_id; } $sql = 'SELECT g.goods_id, g.goods_name,g.goods_number, g.goods_name_style, g.little_img, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img,g.little_img ' . ' ,g.team_num,g.team_price ' . 'FROM ' . $GLOBALS['hhs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['hhs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE {$where} ORDER BY g.sort_order, g.goods_id"; $res = $GLOBALS['db']->getAll($sql); $arr = array(); foreach ($res as $idx => $row) { $arr[$idx]['goods_name'] = $row['goods_name']; $arr[$idx]['goods_brief'] = $row['goods_brief']; $arr[$idx]['goods_number'] = $row['goods_number']; $arr[$idx]['market_price'] = price_format($row['market_price'], false); $arr[$idx]['shop_price'] = price_format($row['shop_price'], false); $arr[$idx]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$idx]['little_img'] = get_image_path($row['goods_id'], $row['little_img'], true); $arr[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$idx]['url'] = "tgoods.php?id=" . $row['goods_id']; //build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']); $arr[$idx]['team_num'] = $row['team_num']; $arr[$idx]['team_price'] = price_format($row['team_price'], false); //echo $arr[$idx]['url'];exit(); $arr[$idx]['team_discount'] = number_format($row['team_price'] / $row['shop_price'] * 10, 1); } return $arr; }
/** * 获取指定用户的收藏商品列表 * * @access public * @param int $user_id 用户ID * @param int $num 列表最大数量 * @param int $start 列表其实位置 * * @return array $arr */ function get_collection_goods($user_id, $num = 10, $start = 0) { $sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, g.promote_start_date,g.promote_end_date, c.rec_id, c.is_attention' . ' FROM ' . $GLOBALS['ecs']->table('collect_goods') . ' AS c' . " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g " . "ON g.goods_id = c.goods_id " . " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " WHERE c.user_id = '{$user_id}' ORDER BY c.rec_id DESC"; $res = $GLOBALS['db']->selectLimit($sql, $num, $start); $goods_list = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } /* 判断是否为正在预售的商品 */ // $pre_sale_id = is_pre_sale_goods($row['goods_id']); // if($pre_sale_id != null) // { // $goods_list[$row['goods_id']]['is_pre_sale'] = 1; // $goods_list[$row['goods_id']]['pre_sale_id'] = $pre_sale_id; // } // else // { // $goods_list[$row['goods_id']]['is_pre_sale'] = 0; // } $goods_list[$row['goods_id']]['rec_id'] = $row['rec_id']; $goods_list[$row['goods_id']]['is_attention'] = $row['is_attention']; $goods_list[$row['goods_id']]['goods_id'] = $row['goods_id']; $goods_list[$row['goods_id']]['goods_name'] = $row['goods_name']; $goods_list[$row['goods_id']]['market_price'] = price_format($row['market_price']); $goods_list[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $goods_list[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $goods_list[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $goods_list[$row['goods_id']]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); } return $goods_list; }
function brand_get_goodsex($brand_id, $cate, $size, $page, $sort, $order) { $cate_where = 0 < $cate ? "AND " . get_children($cate) : ""; $sql = "SELECT g.goods_id, g.goods_name, g.goods_sn, g.market_price, g.shop_price AS org_price,g.is_promote, g.is_new, g.is_best, g.is_hot," . ("IFNULL(mp.user_price, g.shop_price * '" . $_SESSION['discount'] . "') AS shop_price, g.promote_price, ") . "(select AVG(r.comment_rank) from " . $GLOBALS['ecs']->table("comment") . " as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_rank, (select IFNULL(sum(r.id_value), 0) from " . $GLOBALS['ecs']->table("comment") . " as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_count, (select IFNULL(sum(og.goods_number), 0) from " . $GLOBALS['ecs']->table("order_goods") . " as og where og.goods_id = g.goods_id) AS sell_number, g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img FROM " . $GLOBALS['ecs']->table("goods") . " AS g LEFT JOIN " . $GLOBALS['ecs']->table("member_price") . " AS mp " . ("ON mp.goods_id = g.goods_id AND mp.user_rank = '" . $_SESSION['user_rank'] . "' ") . ("WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '" . $brand_id . "' {$cate_where}") . ("ORDER BY " . $sort . " {$order}"); $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if (0 < $row['promote_price']) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($GLOBALS['display'] == "grid") { $arr[$row['goods_id']]['short_name'] = 0 < $GLOBALS['_CFG']['goods_name_length'] ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_sn'] = $row['goods_sn']; $arr[$row['goods_id']]['comment_count'] = $row['comment_count']; $arr[$row['goods_id']]['comment_rank'] = $row['comment_rank']; $arr[$row['goods_id']]['sell_number'] = $row['sell_number']; $arr[$row['goods_id']]['is_promote'] = $row['is_promote']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['is_best'] = $row['is_best']; $arr[$row['goods_id']]['is_hot'] = $row['is_hot']; $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['promote_price'] = 0 < $promote_price ? price_format($promote_price) : ""; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], TRUE); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri("goods", array("gid" => $row['goods_id']), $row['goods_name']); } return $arr; }
/** * 获得推荐商品 * * @access public * @param string $type 推荐类型,可以是 best, new, hot * @return array */ function get_index_best($limit = '') { $time = gmtime(); //取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中 $sql = 'SELECT g.goods_id, g.goods_name,g.click_count, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' "; $sql .= ' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = "best" '; $sql .= ' ORDER BY g.sort_order, g.last_update DESC'; $sql .= " {$limit}"; $result = $GLOBALS['db']->getAll($sql); foreach ($result as $idx => $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$idx]['promote_price'] = ''; } $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : ''; $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); $goods[$idx]['market_price'] = price_format($row['market_price']); $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['thumb'] = '../' . get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods[$idx]['goods_img'] = '../' . get_image_path($row['goods_id'], $row['goods_img']); $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $goods[$idx]['sell_count'] = selled_count($row['goods_id']); $goods[$idx]['pinglun'] = get_evaluation_sum($row['goods_id']); $goods[$idx]['count'] = selled_count($row['goods_id']); $goods[$idx]['click_count'] = $row['click_count']; } return $goods; }
/** * 调用购物车信息 * * @access public * @return string */ function insert_cart_info() { $sql = 'SELECT c.*,g.goods_name,g.goods_thumb,g.goods_id,c.goods_number,c.goods_price' . ' FROM ' . $GLOBALS['ecs']->table('cart') . " AS c " . " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON g.goods_id=c.goods_id " . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'"; $row = $GLOBALS['db']->GetAll($sql); $arr = array(); foreach ($row as $k => $v) { $arr[$k]['goods_thumb'] = get_image_path($v['goods_id'], $v['goods_thumb'], true); $arr[$k]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($v['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $v['goods_name']; $arr[$k]['url'] = build_uri('goods', array('gid' => $v['goods_id']), $v['goods_name']); $arr[$k]['goods_number'] = $v['goods_number']; $arr[$k]['goods_name'] = $v['goods_name']; $arr[$k]['goods_price'] = price_format($v['goods_price']); $arr[$k]['rec_id'] = $v['rec_id']; } $sql = 'SELECT SUM(goods_number) AS number, SUM(goods_price * goods_number) AS amount' . ' FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'"; $row = $GLOBALS['db']->GetRow($sql); if ($row) { $number = intval($row['number']); $amount = floatval($row['amount']); } else { $number = 0; $amount = 0; } $GLOBALS['smarty']->assign('str', sprintf($GLOBALS['_LANG']['cart_info'], $number, price_format($amount, false))); $GLOBALS['smarty']->assign('goods', $arr); $output = $GLOBALS['smarty']->fetch('library/cart_info.lbi'); return $output; }
/** * 调用浏览历史 * * @access public * @return string */ function insert_history() { $time = gmtime(); $str = ''; if (!empty($_COOKIE['ECS']['history'])) { $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id'); $sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price ,promote_price,promote_start_date,promote_end_date,is_promote FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0"; $query = $GLOBALS['db']->query($sql); $res = array(); while ($row = $GLOBALS['db']->fetch_array($query)) { $goods['goods_id'] = $row['goods_id']; $goods['goods_name'] = $row['goods_name']; $goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); if ($row['is_promote'] == 1 && $time > $row['promote_start_date'] && $time < $row['promote_end_date']) { $goods['shop_price'] = price_format($row['promote_price']); } else { $goods['shop_price'] = price_format($row['shop_price']); } $goods['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $str .= '<ul class="clearfix"><li class="goodsimg"><a href="' . $goods['url'] . '" target="_blank"><img src="' . $goods['goods_thumb'] . '" alt="' . $goods['goods_name'] . '" class="B_blue" /></a></li><li><a href="' . $goods['url'] . '" target="_blank" title="' . $goods['goods_name'] . '">' . $goods['short_name'] . '</a><br />' . $GLOBALS['_LANG']['shop_price'] . '<font class="f1">' . $goods['shop_price'] . '</font><br /></li></ul>'; } $str .= '<ul id="clear_history"><a onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</a></ul>'; } return $str; }
function brand_get_goodsex($brand_id, $cate, $size, $page, $sort, $order) { $cate_where = $cate > 0 ? 'AND ' . get_children($cate) : ''; /* 获得商品列表 */ $sql = 'SELECT g.goods_id, g.goods_name, g.goods_sn, g.market_price, g.shop_price AS org_price, g.is_new,' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, " . '(select AVG(r.comment_rank) from ' . $GLOBALS['ecs']->table('comment') . ' as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_rank, ' . '(select IFNULL(sum(og.goods_number), 0) from ' . $GLOBALS['ecs']->table('order_goods') . ' as og where og.goods_id = g.goods_id) AS sell_number, ' . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '{$brand_id}' {$cate_where}" . "ORDER BY {$sort} {$order}"; $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($GLOBALS['display'] == 'grid') { $arr[$row['goods_id']]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_sn'] = $row['goods_sn']; $arr[$row['goods_id']]['comment_rank'] = $row['comment_rank']; $arr[$row['goods_id']]['sell_number'] = $row['sell_number']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } return $arr; }
function fetch($fetch_type = 'complete', $type = 1) { $user = $this->auth->get_user(); $this->_data['data']['user_id'] = $user['id']; $sql = ' SELECT n.*, CONCAT(uc.first_name, " ", uc.last_name) created_fullname FROM notification n JOIN user uc ON n.created_by = uc.id WHERE n.user_id = ? AND n.`type` = ? AND n.read_time IS NULL ORDER BY n.id DESC LIMIT 1 '; $this->_data['data']['new_row'] = $this->db->query($sql, array($user['id'], $type))->row_array(); if (empty($this->_data['data']['new_row'])) { $this->_data['data']['new_row'] = null; } else { $this->load->helper('text'); $this->_data['data']['new_row']['message'] = word_limiter($this->_data['data']['new_row']['message'], 25); } if (!empty($this->_data['data']['new_row'])) { $sql = ' SELECT COUNT(*) count FROM notification WHERE user_id = ? AND `type` = ? AND read_time IS NULL '; $this->_data['data']['row_count'] = $this->db->query($sql, array($user['id'], $type))->row()->count; } if ($fetch_type == 'rows' || $fetch_type == 'complete') { $this->load->helper('gravatar'); $sql = ' SELECT n.*, uc.email, uc.image, CONCAT(uc.first_name, " ", uc.last_name) created_fullname FROM notification n JOIN user u ON n.user_id = u.id JOIN user uc ON n.created_by = uc.id WHERE user_id = ? AND `type` = ? ORDER BY id DESC LIMIT 5 '; $rows = $this->db->query($sql, array($user['id'], $type))->result_array(); foreach ($rows as &$row) { if (!empty($row['icon']) && strpos($row['icon'], '://') === FALSE) { $row['icon'] = site_url($row['icon']); } if (!empty($row['url']) && strpos($row['url'], '://') === FALSE) { $row['url'] = site_url(str_replace('/edit/', '/detail/', $row['url'])); } $row['icon'] = get_image_path($row['image']); } $this->db->set('read_time', date('Y-m-d H:i:s'))->where('read_time IS NULL', null, false)->where('user_id', $user['id'])->where('type', $type)->update('notification'); $this->_data['data']['rows'] = $rows; } }
/** * 获得品牌下的商品 * * @access private * @param integer $brand_id * @return array */ function brand_get_goods($brand_id, $cate, $sort, $order, $size, $page) { $cate_where = ($cate > 0) ? 'AND ' . get_children($cate) : ''; $start = ($page - 1) * $size; /* 获得商品列表 */ $sort = $sort =='sales_volume'? 'xl.sales_volume': $sort; $sql = 'SELECT g.goods_id, g.goods_name,g.goods_number, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $this->pre . 'goods AS g ' . 'LEFT JOIN ' . $this->pre . 'touch_goods AS xl ' . "ON g.goods_id=xl.goods_id " . 'LEFT JOIN ' . $this->pre . 'member_price AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '$brand_id' $cate_where" . "ORDER BY $sort $order LIMIT $start , $size"; $res = $this->query($sql); $arr = array(); foreach ($res as $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($GLOBALS['display'] == 'grid') { $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $arr[$row['goods_id']]['discount'] = $row['market_price'] > 0 ? (round((($promote_price > 0 ? $promote_price : $row['shop_price']) / $row['market_price']) * 10)) : 0; $arr[$row['goods_id']]['goods_number'] = $row['goods_number']; $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri('goods/index', array( 'id' => $row['goods_id'] ), $row['goods_name']); $arr[$row['goods_id']]['sales_count'] = model('GoodsBase')->get_sales_count($row['goods_id']); $arr[$row['goods_id']]['sc'] = model('GoodsBase')->get_goods_collect($row['goods_id']); $arr[$row['goods_id']]['promotion'] = model('GoodsBase')->get_promotion_show($row['goods_id']); $arr[$row['goods_id']]['mysc'] = 0; // 检查是否已经存在于用户的收藏夹 if ($_SESSION['user_id']) { unset($where); // 用户自己有没有收藏过 $where['goods_id'] = $row['goods_id']; $where['user_id'] = $_SESSION['user_id']; $rs = $this->model->table('collect_goods') ->where($where) ->count(); $arr[$row['goods_id']]['mysc'] = $rs; } } return $arr; }
function print_ext_tree($object) { global $gbl, $sgbl, $login, $ghtml; $icondir = get_image_path('/button/'); $icon = "{$icondir}/{$object->getClass()}_list.gif"; ?> <script> Ext.onReady(function(){ // shorthand var Tree = Ext.tree; var tree = new Tree.TreePanel('tree-div', { animate:true, loader: new Tree.TreeLoader({ //dataUrl:'get-nodes.php' dataUrl:'/ajax.php?frm_action=tree' }), enableDD:true, containerScroll: true }); // set the root node var root = new Tree.AsyncTreeNode({ text: '<?php echo $object->getId(); ?> ', href: '<?php echo $ghtml->getFullUrl('a=show'); ?> ', hrefTarget: 'mainframe', icon: '<?php echo $icon; ?> ', draggable:false, id:'/' }); tree.setRootNode(root); // render the tree tree.render(); root.expand(); }); </script> <?php }
/** * 获取指定id package 的信息 * * @access public * @param int $id package_id * * @return array array(package_id, package_name, goods_id,start_time, end_time, min_price, integral) */ function get_package_info($id) { global $ecs, $db, $_CFG; $id = is_numeric($id) ? intval($id) : 0; $now = gmtime(); $sql = "SELECT act_id AS id, act_name AS package_name, goods_id , goods_name, start_time, end_time, act_desc, ext_info" . " FROM " . $this->pre . "goods_activity WHERE act_id='{$id}' AND act_type = " . GAT_PACKAGE; $package = $this->row($sql); /* 将时间转成可阅读格式 */ if ($package['start_time'] <= $now && $package['end_time'] >= $now) { $package['is_on_sale'] = "1"; } else { $package['is_on_sale'] = "0"; } $package['start_time'] = local_date('Y-m-d H:i', $package['start_time']); $package['end_time'] = local_date('Y-m-d H:i', $package['end_time']); $row = unserialize($package['ext_info']); unset($package['ext_info']); if ($row) { foreach ($row as $key => $val) { $package[$key] = $val; } } $sql = "SELECT pg.package_id, pg.goods_id, pg.goods_number, pg.admin_id, " . " g.goods_sn, g.goods_name, g.market_price, g.goods_thumb, g.is_real, " . " IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS rank_price " . " FROM " . $this->pre . "package_goods AS pg " . " LEFT JOIN " . $this->pre . "goods AS g " . " ON g.goods_id = pg.goods_id " . " LEFT JOIN " . $this->pre . "member_price AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " WHERE pg.package_id = " . $id . " " . " ORDER BY pg.package_id, pg.goods_id"; $goods_res = $this->query($sql); $market_price = 0; $real_goods_count = 0; $virtual_goods_count = 0; foreach ($goods_res as $key => $val) { $goods_res[$key]['goods_thumb'] = get_image_path($val['goods_id'], $val['goods_thumb'], true); $goods_res[$key]['market_price_format'] = price_format($val['market_price']); $goods_res[$key]['rank_price_format'] = price_format($val['rank_price']); $market_price += $val['market_price'] * $val['goods_number']; /* 统计实体商品和虚拟商品的个数 */ if ($val['is_real']) { $real_goods_count++; } else { $virtual_goods_count++; } } if ($real_goods_count > 0) { $package['is_real'] = 1; } else { $package['is_real'] = 0; } $package['goods_list'] = $goods_res; $package['market_package'] = $market_price; $package['market_package_format'] = price_format($market_price); $package['package_price_format'] = price_format($package['package_price']); return $package; }
function display($var) { global $gbl, $sgbl, $login, $ghtml; if ($var === 'description') { if (isset($this->{$var}) && $this->{$var}) { return $this->{$var}; } $url = base64_decode($this->nname); $buttonpath = get_image_path() . "/button/"; $description = $ghtml->getActionDetails($url, null, $buttonpath, $path, $post, $file, $name, $image, $__t_identity); return "{$description['2']} for {$__t_identity}"; } return parent::display($var); }
function display($var) { global $gbl, $sgbl, $login, $ghtml; if ($var === 'portdescription') { $dir = get_image_path() . "/button"; $text = null; $list = $this->getList("monitorport"); foreach ($list as $p) { $ig = "_lximg:{$dir}/{$p->portstatus}.gif:10:10:"; $text .= "{$p->portname}: {$ig} "; } return $text; } return $this->{$var}; }
/** * 获得促销商品 * * @access public * @return array */ function get_flash_sale_goods($cats = '') { $time = gmtime(); $order_type = $GLOBALS['_CFG']['recommend_order']; /* 取得促销lbi的数量限制 */ $num = get_library_number("recommend_promotion"); $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, b.brand_name, " . "g.is_best, g.is_new, g.is_hot, g.is_promote, RAND() AS rnd " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ' . " AND g.is_promote = 1 AND promote_start_date <= '{$time}' AND promote_end_date >= '{$time}' "; $sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY rnd'; $result = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($result as $idx => $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? $promote_price : ''; } else { $goods[$idx]['promote_price'] = ''; } $sql = 'SELECT sum(goods_number) AS goods_number FROM ' . $GLOBALS['ecs']->table('order_goods') . ' WHERE goods_id =' . $row['goods_id'] . ' GROUP BY goods_id'; $goods_number = $GLOBALS['db']->getOne($sql); if (empty($goods_number)) { $goods_number = 0; } if (!empty($row['promote_end_date'])) { $goods[$idx]['end_date'] = $row['promote_end_date']; } $goods[$idx]['soldnum'] = get_soldnum($row['goods_id']); $goods[$idx]['jiesheng'] = $row['market_price'] - $row['promote_price']; $goods[$idx]['zhekou'] = sprintf("%1\$.1f", $row['promote_price'] / $row['shop_price'] * 10); $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['number'] = $goods_number; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = $row['brand_name']; $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); $goods[$idx]['market_price'] = $row['market_price']; $goods[$idx]['shop_price'] = $row['shop_price']; $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $properties = get_goods_properties($row['goods_id']); // 获得商品的规格和属性 $goods[$idx]['pro'] = $properties['pro']['商品属性']; } return $goods; }
/** * 取得某页的拍卖活动 * @param int $size 每页记录数 * @param int $page 当前页 * @param str $sort 分类 * @param str $order 排序 * @return array */ function auction_list($size, $page, $sort, $order) { $auction_list = array(); $auction_list['finished'] = $auction_list['finished'] = array(); $now = gmtime(); $start = ($page - 1) * $size; $sort = $sort != 'goods_id' ? 't.' . $sort : $sort; $sql = "SELECT a.*,t.act_banner ,t.sales_count ,t.click_num , IFNULL(g.goods_thumb, '') AS goods_thumb " . "FROM " . $this->pre . "goods_activity AS a " . "LEFT JOIN " . $this->pre . "goods AS g ON a.goods_id = g.goods_id " . "LEFT JOIN " . $this->pre . "touch_goods_activity AS t ON a.act_id = t.act_id " . "LEFT JOIN " . $this->pre . "touch_goods as tg ON g.goods_id = tg.goods_id " . "WHERE a.act_type = '" . GAT_AUCTION . "' " . "AND a.start_time <= '{$now}' AND a.end_time >= '{$now}' AND a.is_finished < 2 ORDER BY {$sort} {$order} LIMIT {$start} ,{$size} "; $res = $this->query($sql); foreach ($res as $row) { $ext_info = unserialize($row['ext_info']); $auction = array_merge($row, $ext_info); $auction['status_no'] = auction_status($auction); $auction['start_time'] = local_date(C('time_format'), $auction['start_time']); $auction['end_time'] = local_date(C('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['act_banner'] = $row['act_banner'] ? $row['act_banner'] : $auction['goods_thumb']; $auction['url'] = build_uri('info', array('id' => $auction['act_id'])); if ($auction['status_no'] < 2) { $auction_list['under_way'][] = $auction; } else { $auction_list['finished'][] = $auction; } //增加扩展表判断 $sql = 'SELECT count(*) as count FROM ' . $this->pre . "touch_goods_activity WHERE `act_id` = '" . $auction['act_id'] . "'"; $res = $this->row($sql); if ($res['count']) { $this->table = 'touch_goods_activity'; $data['cur_price'] = $auction['start_price']; $condition['act_id'] = $auction['act_id']; $this->update($condition, $data); } else { $this->table = 'touch_goods_activity'; $data1['act_id'] = $auction['act_id']; $data1['cur_price'] = $auction['start_price']; $this->insert($data1); } } $auction_list = @array_merge($auction_list['under_way'], $auction_list['finished']); return $auction_list; }
function main() { // start timer $timeparts = explode(' ', microtime()); $starttime = $timeparts[1] . substr($timeparts[0], 1); // find source image if (isset($_GET['src'])) { $image = get_image_path($_GET['src']); } else { header('HTTP/1.1 400 Bad Request'); die('Error: no image was specified'); } // extract arguments from query string if (defined('WIDTH') && defined('HEIGHT')) { // prep cache path $cache = get_cache_path($image); // compute image if needed $result = dispatch($image, $cache); } elseif (!defined('WIDTH') && !defined('HEIGHT')) { $cache = $image; $result = 0; } else { header('HTTP/1.1 400 Bad Request'); die("ERROR: Both width and height need to be provided"); } if (DEBUG == 1) { // show source image for comparison render(end(explode('/', $image)), true, 'img'); echo "<br/>"; } // end timer $timeparts = explode(' ', microtime()); $endtime = $timeparts[1] . substr($timeparts[0], 1); $elapsed = bcsub($endtime, $starttime, 6); dprint("<br/>Script execution time (s): " . $elapsed); // serve out results render($cache, DEBUG == 1 ? true : false, FORMAT); // log results $lf = fopen(LOG_PATH, 'a'); $logstring = date(DATE_RFC822) . "\n" . $_SERVER["QUERY_STRING"] . "\n{$elapsed} s\n\n"; fwrite($lf, $logstring); fclose($lf); }
function main() { // start timer $timeparts = explode(' ', microtime()); $starttime = $timeparts[1] . substr($timeparts[0], 1); // find source image if (isset($_GET['src'])) { $image = get_image_path($_GET['src']); } else { header('HTTP/1.1 400 Bad Request'); die('Error: no image was specified'); } // extract the commands from the query string // eg.: cmd=resize(....)+flip+blur(...) if (isset($_GET['cmd'])) { preg_match_all('/\\+*(([a-z\\-]+[0-9]*)(\\(([^\\)]*)\\))?)\\+*/', $_GET['cmd'], $cmds, PREG_SET_ORDER); // prep cache path $cache = get_cache_path($image, $cmds, FORMAT); // compute image if needed $result = dispatch($image, $cache, $cmds); } else { $cache = $image; $result = 0; } if (DEBUG == 1) { // show source image for comparison render(end(explode('/', $image)), true, 'img'); echo "<br/>"; } // end timer $timeparts = explode(' ', microtime()); $endtime = $timeparts[1] . substr($timeparts[0], 1); $elapsed = bcsub($endtime, $starttime, 6); dprint("<br/>Script execution time (s): " . $elapsed); // serve out results render($cache, DEBUG == 1 ? true : false, FORMAT); // log results $lf = fopen(LOG_PATH, 'a'); $logstring = date(DATE_RFC822) . "\n" . $_SERVER["QUERY_STRING"] . "\n{$elapsed} s\n\n"; fwrite($lf, $logstring); fclose($lf); }
/** * 调用浏览历史 * * @access public * @return string */ function insert_history() { $str = ''; $history = array(); if (!empty($_COOKIE['ECS']['history'])) { $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id'); $sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . M()->pre . 'goods' . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0"; $query = M()->query($sql); $res = array(); foreach ($query as $key => $row) { $goods['goods_id'] = $row['goods_id']; $goods['goods_name'] = $row['goods_name']; $goods['short_name'] = C('goods_name_length') > 0 ? sub_str($row['goods_name'], C('goods_name_length')) : $row['goods_name']; $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods['shop_price'] = price_format($row['shop_price']); $goods['url'] = url('goods/index', array('id' => $row['goods_id'])); $history[] = $goods; } } return $history; }
/** * 调用浏览历史 */ function insert_siy_history() { $str = ''; if (!empty($_COOKIE['ECS']['history'])) { $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id'); $sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0"; $query = $GLOBALS['db']->query($sql); $res = array(); $str .= '<div id="history" class="box"> <b class="tp"><b></b></b> <div class="hd"><h3>' . $GLOBALS['_LANG']['view_history'] . '</h3><span class="more" onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</span></div> <div class="bd"> <ul class="goods-list">'; while ($row = $GLOBALS['db']->fetch_array($query)) { $goods['goods_id'] = $row['goods_id']; $goods['goods_name'] = $row['goods_name']; $goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods['shop_price'] = price_format($row['shop_price']); $goods['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $str .= ' <li> <span class="photo"> <a href="' . $goods['url'] . '" title="' . $goods['goods_name'] . '" class="image"><img src="' . $goods['goods_thumb'] . '" alt="' . $goods['goods_name'] . '"/></a> </span> <span class="info"> <a href="' . $goods['url'] . '" title="' . $goods['goods_name'] . '" class="name">' . $goods['short_name'] . '</a> <em class="price">' . $goods['shop_price'] . '</em> </span> <span class="action"> <a href="' . $goods['url'] . '" class="detail">' . $GLOBALS['_LANG']['btn_detail'] . '</a> </span> </li>'; } $str .= ' </ul> </div> <b class="bt"><b></b></b> </div>'; } return $str; }
/** * 获取数据 */ public function show($fromusername, $info) { $articles = array('type' => 'text', 'content' => '暂无新品'); $data = model('base')->model->table('goods')->field('goods_id, goods_name, goods_img')->where('is_new = 1 and is_on_sale = 1 and is_delete = 0 and last_update > (UNIX_TIMESTAMP(NOW()) - 3600*24*30)')->order('last_update desc')->limit(4)->select(); if (!empty($data)) { $articles = array(); $articles['type'] = 'news'; foreach ($data as $key => $val) { // 不是远程图片 if (!preg_match('/(http:|https:)/is', $val['goods_img'])) { $articles['content'][$key]['PicUrl'] = get_image_path('', $val['goods_img']); } else { $articles['content'][$key]['PicUrl'] = $val['goods_img']; } $articles['content'][$key]['Title'] = $val['goods_name']; $articles['content'][$key]['Url'] = __HOST__ . url('goods/index', array('id' => $val['goods_id'])); } // 积分赠送 $this->give_point($fromusername, $info); } return $articles; }
/** * 获得文章关联的商品 * * @access public * @param integer $id * @return array */ function article_related_goods($id) { $sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' . 'FROM ' . $GLOBALS['ecs']->table('goods_article') . ' ga ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = ga.goods_id ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE ga.article_id = '{$id}' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0"; $res = $GLOBALS['db']->query($sql); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['goods_id']]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); if ($row['promote_price'] > 0) { $arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']); } else { $arr[$row['goods_id']]['promote_price'] = 0; } } return $arr; }
function action_my_comment() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; $min_time = gmtime() - 86400 * $_CFG['comment_youxiaoqi']; $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $count = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('order_goods') . " AS og \r\n\t\t\t\t\t\t LEFT JOIN " . $ecs->table('order_info') . " AS o ON og.order_id=o.order_id\r\n\t\t\t\t\t\t WHERE o.user_id = '{$user_id}' AND o.shipping_time_end > 0 AND og.is_back = 0"); $size = 20; $page_count = $count > 0 ? intval(ceil($count / $size)) : 1; // 代码添加$o_id,if判断 $o_id = $_REQUEST['order_id']; if ($o_id) { $sql = "SELECT og.*, o.add_time, o.shipping_time_end, o.order_id, g.goods_thumb, s.shaidan_id, s.pay_points AS shaidan_points, s.status AS shaidan_status,\r\n\t\t\tc.status AS comment_status,g.supplier_id,ifnull(ssc.value,'网站自营') AS shopname\r\n\t\t\tFROM " . $ecs->table('order_goods') . " AS og\r\n\t\t\tLEFT JOIN " . $ecs->table('order_info') . " AS o ON og.order_id=o.order_id\r\n\t\t\tLEFT JOIN " . $ecs->table('goods') . " AS g ON og.goods_id=g.goods_id\r\n\t\t\tLEFT JOIN " . $ecs->table('shaidan') . " AS s ON og.rec_id=s.rec_id\r\n\t\t\tLEFT JOIN " . $ecs->table('comment') . " AS c ON og.rec_id=c.rec_id\r\n\t\t\tLEFT JOIN " . $ecs->table('supplier_shop_config') . " AS ssc ON ssc.supplier_id=g.supplier_id AND ssc.code='shop_name'\r\n\t\t\tWHERE o.user_id = '{$user_id}' AND og.order_id = '{$o_id}' AND o.shipping_time_end > 0 AND og.is_back = 0 ORDER BY o.add_time DESC"; } else { $sql = "SELECT og.*, o.add_time, o.shipping_time_end, o.order_id, g.goods_thumb, s.shaidan_id, s.pay_points AS \tshaidan_points, s.status AS shaidan_status, \r\n\t\t\tc.status AS comment_status,g.supplier_id,ifnull(ssc.value,'网站自营') AS shopname \r\n\t\t\tFROM " . $ecs->table('order_goods') . " AS og \r\n\t\t\tLEFT JOIN " . $ecs->table('order_info') . " AS o ON og.order_id=o.order_id\r\n\t\t\tLEFT JOIN " . $ecs->table('goods') . " AS g ON og.goods_id=g.goods_id\r\n\t\t\tLEFT JOIN " . $ecs->table('shaidan') . " AS s ON og.rec_id=s.rec_id\r\n\t\t\tLEFT JOIN " . $ecs->table('comment') . " AS c ON og.rec_id=c.rec_id\r\n\t\t\tLEFT JOIN " . $ecs->table('supplier_shop_config') . " AS ssc ON ssc.supplier_id=g.supplier_id AND ssc.code='shop_name'\r\n\t\t\tWHERE o.user_id = '{$user_id}' AND o.shipping_time_end > 0 AND c.content > 0 AND og.is_back = 0 ORDER BY o.add_time DESC"; } $res = $db->selectLimit($sql, $size, ($page - 1) * $size); $points_list = array(); while ($row = $db->fetchRow($res)) { $row['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $row['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $row['add_time_str'] = local_date("Y-m-d", $row['add_time']); $row['goods_tags'] = $db->getAll("SELECT * FROM " . $ecs->table('goods_tag') . " WHERE goods_id = '{$row['goods_id']}'"); $item_list[] = $row; } // 代码增加 for 循环 for ($i = 1; $i < count($item_list); $i++) { $item_list[$i]['o_id'] = $item_list[$i]['order_id']; unset($item_list[$i]['order_id']); } $smarty->assign('item_list', $item_list); // 统计信息 $num['x'] = $db->getOne("SELECT COUNT(*) AS num FROM " . $ecs->table('order_goods') . " AS og \r\n\t\t\t\t\t\t\tLEFT JOIN " . $ecs->table('order_info') . " AS o ON og.order_id=o.order_id\r\n\t\t\t\t\t\t\tWHERE o.user_id = '{$user_id}' AND og.is_back = 0 AND og.comment_state = 0 AND o.shipping_time_end > {$min_time}"); $num['y'] = $db->getOne("SELECT COUNT(*) AS num FROM " . $ecs->table('order_goods') . " AS og \r\n\t\t\t\t\t\t\tLEFT JOIN " . $ecs->table('order_info') . " AS o ON og.order_id=o.order_id\r\n\t\t\t\t\t\t\tWHERE o.user_id = '{$user_id}' AND og.is_back = 0 AND og.shaidan_state = 0 AND o.shipping_time_end > {$min_time}"); $smarty->assign('num', $num); $pager = get_pager('user.php', array('act' => $action), $count, $page, $size); $smarty->assign('min_time', $min_time); $smarty->assign('pager', $pager); $smarty->display('user_my_comment.dwt'); }
/** * 分享推荐 */ public function share() { $share = unserialize(C('affiliate')); $goodsid = I('request.goodsid', 0); if (empty($goodsid)) { $page = I('request.page', 1); $size = I(C('page_size'), 10); empty($share) && ($share = array()); if (empty($share['config']['separate_by'])) { // 推荐注册分成 $affdb = array(); $num = count($share['item']); $up_uid = "'{$this->user_id}'"; $all_uid = "'{$this->user_id}'"; for ($i = 1; $i <= $num; $i++) { $count = 0; if ($up_uid) { $where = 'parent_id IN(' . $up_uid . ')'; $rs = $this->model->table('users')->field('user_id')->where($where)->select(); if (empty($rs)) { $rs = array(); } $up_uid = ''; foreach ($rs as $k => $v) { $up_uid .= $up_uid ? ",'{$v['user_id']}'" : "'{$v['user_id']}'"; if ($i < $num) { $all_uid .= ", '{$v['user_id']}'"; } $count++; } } $affdb[$i]['num'] = $count; $affdb[$i]['point'] = $share['item'][$i - 1]['level_point']; $affdb[$i]['money'] = $share['item'][$i - 1]['level_money']; $this->assign('affdb', $affdb); $sqlcount = "SELECT count(*) as count FROM " . $this->model->pre . "order_info o" . " LEFT JOIN " . $this->model->pre . "users u ON o.user_id = u.user_id" . " LEFT JOIN " . $this->model->pre . "affiliate_log a ON o.order_id = a.order_id" . " WHERE o.user_id > 0 AND (u.parent_id IN ({$all_uid}) AND o.is_separate = 0 OR a.user_id = '{$this->user_id}' AND o.is_separate > 0)"; $sql = "SELECT o.*, a.log_id, a.user_id as suid, a.user_name as auser, a.money, a.point, a.separate_type FROM " . $this->model->pre . "order_info o" . " LEFT JOIN " . $this->model->pre . "users u ON o.user_id = u.user_id" . " LEFT JOIN " . $this->model->pre . "affiliate_log a ON o.order_id = a.order_id" . " WHERE o.user_id > 0 AND (u.parent_id IN ({$all_uid}) AND o.is_separate = 0 OR a.user_id = '{$this->user_id}' AND o.is_separate > 0)" . " ORDER BY order_id DESC"; } } else { // 推荐订单分成 $sqlcount = "SELECT count(*) as count FROM " . $this->model->pre . "order_info o" . " LEFT JOIN " . $this->model->pre . "users u ON o.user_id = u.user_id" . " LEFT JOIN " . $this->model->pre . "affiliate_log a ON o.order_id = a.order_id" . " WHERE o.user_id > 0 AND (o.parent_id = '{$this->user_id}' AND o.is_separate = 0 OR a.user_id = '{$this->user_id}' AND o.is_separate > 0)"; $sql = "SELECT o.*, a.log_id,a.user_id as suid, a.user_name as auser, a.money, a.point, a.separate_type,u.parent_id as up FROM " . $this->model->pre . "order_info o" . " LEFT JOIN " . $this->model->pre . "users u ON o.user_id = u.user_id" . " LEFT JOIN " . $this->model->pre . "affiliate_log a ON o.order_id = a.order_id" . " WHERE o.user_id > 0 AND (o.parent_id = '{$this->user_id}' AND o.is_separate = 0 OR a.user_id = '{$this->user_id}' AND o.is_separate > 0)" . " ORDER BY order_id DESC"; } $res = $this->model->query($sqlcount); $count = $res[0]['count']; $url_format = url('share', array('page' => '{page}')); $limit = $this->pageLimit($url_format, 10); $sql = $sql . ' LIMIT ' . $limit; $rt = $this->model->query($sql); if ($rt) { foreach ($rt as $k => $v) { if (!empty($v['suid'])) { // 在affiliate_log有记录 if ($v['separate_type'] == -1 || $v['separate_type'] == -2) { // 已被撤销 $v['is_separate'] = 3; } } $rt[$k]['order_sn'] = substr($v['order_sn'], 0, strlen($v['order_sn']) - 5) . "***" . substr($v['order_sn'], -2, 2); } } else { $rt = array(); } $pager = $this->pageShow($count); $this->assign('pager', $pager); $this->assign('affiliate_type', $share['config']['separate_by']); $this->assign('logdb', $rt); } else { // 单个商品推荐 $this->assign('userid', $this->user_id); $this->assign('goodsid', $goodsid); $types = array(1, 2, 3, 4, 5); $this->assign('types', $types); $goods = model('Goods')->get_goods_info($goodsid); $goods['goods_img'] = get_image_path(0, $goods['goods_img']); $goods['goods_thumb'] = get_image_path(0, $goods['goods_thumb']); $goods['shop_price'] = price_format($goods['shop_price']); $this->assign('goods', $goods); } $shopurl = __URL__ . '/?u=' . $this->user_id; $this->assign('shopurl', $shopurl); $this->assign('domain', __HOST__); $this->assign('shopdesc', C('shop_desc')); $this->assign('title', L('label_share')); $this->assign('share', $share); $this->display('user_share.dwt'); }
function get_supplier_goods($gtype = 0) { $gtype = intval($gtype); if ($gtype <= 0) { return; } $sql = "SELECT DISTINCT g.goods_id,g.* FROM " . $GLOBALS['ecs']->table('goods') . " AS g, " . $GLOBALS['ecs']->table('supplier_goods_cat') . " AS gc, " . $GLOBALS['ecs']->table('supplier_cat_recommend') . " AS cr \n\tWHERE cr.recommend_type =" . $gtype . " AND cr.supplier_id =" . $_GET['suppId'] . " AND cr.cat_id = gc.cat_id AND gc.goods_id = g.goods_id \n\tAND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 \n\tORDER BY g.sort_order, g.last_update DESC LIMIT 10"; $result = $GLOBALS['db']->getAll($sql); $goods = array(); if ($result) { foreach ($result as $idx => $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$idx]['promote_price'] = ''; } $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : ''; $goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']); $goods[$idx]['market_price'] = price_format($row['market_price']); $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['thumb'] = '../' . get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods[$idx]['goods_img'] = '../' . get_image_path($row['goods_id'], $row['goods_img']); $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } } return $goods; }
function get_on_top_goods($id, $num = 5) { $sql = 'SELECT cat_id,cat_name FROM ' . $GLOBALS['ecs']->table('category') . ' WHERE is_on_top = 1 AND parent_id =' . $id; $res = $GLOBALS['db']->getAll($sql); foreach ($res as $idx => $row) { $arr[$idx]['cat_url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); $arr[$idx]['cat_name'] = $row['cat_name']; $children = get_children($row['cat_id']); $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . "FROM " . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ' . 'g.is_delete = 0 AND (' . $children . ') '; $order_rule = 'ORDER BY g.sort_order, g.goods_id DESC'; $sql .= $order_rule; if ($num > 0) { $sql .= ' LIMIT ' . $num; } $goods_res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($goods_res as $goods_idx => $goods_row) { if ($goods_row['promote_price'] > 0) { $promote_price = bargain_price($goods_row['promote_price'], $goods_row['promote_start_date'], $goods_row['promote_end_date']); $goods[$goods_idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$goods_idx]['promote_price'] = ''; } $goods[$goods_idx]['id'] = $goods_row['goods_id']; $goods[$goods_idx]['name'] = $goods_row['goods_name']; $goods[$goods_idx]['brief'] = $goods_row['goods_brief']; $goods[$goods_idx]['market_price'] = price_format($goods_row['market_price']); $goods[$goods_idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($goods_row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $goods_row['goods_name']; $goods[$goods_idx]['shop_price'] = price_format($goods_row['shop_price']); $goods[$goods_idx]['thumb'] = get_image_path($goods_row['goods_id'], $goods_row['goods_thumb'], true); $goods[$goods_idx]['goods_img'] = get_image_path($goods_row['goods_id'], $goods_row['goods_img']); $goods[$goods_idx]['url'] = build_uri('goods', array('gid' => $goods_row['goods_id']), $goods_row['goods_name']); } $arr[$idx]['goods'] = $goods; } return $arr; }
/** * 获得购物车中的商品 * * @access public * @return array */ function get_cart_goods() { /* 初始化 */ $goods_list = array(); $total = array('goods_price' => 0, 'market_price' => 0, 'saving' => 0, 'save_rate' => 0, 'goods_amount' => 0); /* 循环、统计 */ $sql = "SELECT *, IF(parent_id, parent_id, goods_id) AS pid , goods_number " . " FROM " . $GLOBALS['ecs']->table('cart') . " " . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'" . " ORDER BY pid, parent_id"; // by Leah add goods_number $res = $GLOBALS['db']->query($sql); /* 用于统计购物车中实体商品和虚拟商品的个数 */ $virtual_goods_count = 0; $real_goods_count = 0; while ($row = $GLOBALS['db']->fetchRow($res)) { $total['goods_price'] += $row['goods_price'] * $row['goods_number']; $total['market_price'] += $row['market_price'] * $row['goods_number']; $total['total_number'] += $row['goods_number']; //by Leah $row['subtotal'] = price_format($row['goods_price'] * $row['goods_number'], false); $row['goods_price'] = price_format($row['goods_price'], false); $row['market_price'] = price_format($row['market_price'], false); /* 统计实体商品和虚拟商品的个数 */ if ($row['is_real']) { $real_goods_count++; } else { $virtual_goods_count++; } /* 查询规格 */ if (trim($row['goods_attr']) != '') { $sql = "SELECT attr_value FROM " . $GLOBALS['ecs']->table('goods_attr') . " WHERE goods_attr_id " . db_create_in($row['goods_attr']); $attr_list = $GLOBALS['db']->getCol($sql); foreach ($attr_list as $attr) { $row['goods_name'] .= ' [' . $attr . '] '; } } /* 增加是否在购物车里显示商品图 */ if (($GLOBALS['_CFG']['show_goods_in_cart'] == "2" || $GLOBALS['_CFG']['show_goods_in_cart'] == "3") && $row['extension_code'] != 'package_buy') { $goods_thumb = $GLOBALS['db']->getOne("SELECT `goods_thumb` FROM " . $GLOBALS['ecs']->table('goods') . " WHERE `goods_id`='{$row['goods_id']}'"); $row['goods_thumb'] = get_image_path($row['goods_id'], $goods_thumb, true); } if ($row['extension_code'] == 'package_buy') { $row['package_goods_list'] = get_package_goods($row['goods_id']); } $goods_list[] = $row; } $total['goods_amount'] = $total['goods_price']; $total['saving'] = price_format($total['market_price'] - $total['goods_price'], false); if ($total['market_price'] > 0) { $total['save_rate'] = $total['market_price'] ? round(($total['market_price'] - $total['goods_price']) * 100 / $total['market_price']) . '%' : 0; } $total['goods_price'] = price_format($total['goods_price'], false); $total['market_price'] = price_format($total['market_price'], false); $total['real_goods_count'] = $real_goods_count; $total['virtual_goods_count'] = $virtual_goods_count; return array('goods_list' => $goods_list, 'total' => $total); }
/** * 取得跟商品关联的礼包列表 * * @param string $goods_id 商品编号 * * @return 礼包列表 */ function get_package_goods_list($goods_id) { $now = gmtime(); $sql = "SELECT pg.goods_id, ga.act_id, ga.act_name, ga.act_desc, ga.goods_name, ga.start_time,\r\n ga.end_time, ga.is_finished, ga.ext_info\r\n FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS ga, " . $GLOBALS['ecs']->table('package_goods') . " AS pg\r\n WHERE pg.package_id = ga.act_id\r\n AND ga.start_time <= '" . $now . "'\r\n AND ga.end_time >= '" . $now . "'\r\n AND pg.goods_id = " . $goods_id . "\r\n GROUP BY ga.act_id\r\n ORDER BY ga.act_id "; $res = $GLOBALS['db']->getAll($sql); foreach ($res as $tempkey => $value) { $subtotal = 0; $row = unserialize($value['ext_info']); unset($value['ext_info']); if ($row) { foreach ($row as $key => $val) { $res[$tempkey][$key] = $val; } } $sql = "SELECT pg.package_id, pg.goods_id, pg.goods_number, pg.admin_id, p.goods_attr, g.goods_sn, g.goods_name, g.market_price, g.goods_thumb, IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS rank_price\r\n FROM " . $GLOBALS['ecs']->table('package_goods') . " AS pg\r\n LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g\r\n ON g.goods_id = pg.goods_id\r\n LEFT JOIN " . $GLOBALS['ecs']->table('products') . " AS p\r\n ON p.product_id = pg.product_id\r\n LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp\r\n ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}'\r\n WHERE pg.package_id = " . $value['act_id'] . "\r\n ORDER BY pg.package_id, pg.goods_id"; $goods_res = $GLOBALS['db']->getAll($sql); foreach ($goods_res as $key => $val) { $goods_id_array[] = $val['goods_id']; $goods_res[$key]['goods_thumb'] = get_image_path($val['goods_id'], $val['goods_thumb'], true); $goods_res[$key]['market_price'] = price_format($val['market_price']); $goods_res[$key]['rank_price'] = price_format($val['rank_price']); $subtotal += $val['rank_price'] * $val['goods_number']; } /* 取商品属性 */ $sql = "SELECT ga.goods_attr_id, ga.attr_value\r\n FROM " . $GLOBALS['ecs']->table('goods_attr') . " AS ga, " . $GLOBALS['ecs']->table('attribute') . " AS a\r\n WHERE a.attr_id = ga.attr_id\r\n AND a.attr_type = 1\r\n AND " . db_create_in($goods_id_array, 'goods_id'); $result_goods_attr = $GLOBALS['db']->getAll($sql); $_goods_attr = array(); foreach ($result_goods_attr as $value) { $_goods_attr[$value['goods_attr_id']] = $value['attr_value']; } /* 处理货品 */ $format = '[%s]'; foreach ($goods_res as $key => $val) { if ($val['goods_attr'] != '') { $goods_attr_array = explode('|', $val['goods_attr']); $goods_attr = array(); foreach ($goods_attr_array as $_attr) { $goods_attr[] = $_goods_attr[$_attr]; } $goods_res[$key]['goods_attr_str'] = sprintf($format, implode(',', $goods_attr)); } } $res[$tempkey]['goods_list'] = $goods_res; $res[$tempkey]['subtotal'] = price_format($subtotal); $res[$tempkey]['saving'] = price_format($subtotal - $res[$tempkey]['package_price']); $res[$tempkey]['package_price'] = price_format($res[$tempkey]['package_price']); } return $res; }
function get_order_goods($order) { /* 取得订单商品及货品 */ $goods_list = array(); $goods_attr = array(); $sql = "SELECT o.*, IF(o.product_id > 0, p.product_number, g.goods_number) AS storage, o.goods_attr, o.goods_attr_id, g.suppliers_id, IFNULL(b.brand_name, '') AS brand_name, p.product_sn, a.attr_value,g.goods_thumb,g.goods_id \n FROM " . $GLOBALS['ecs']->table('order_goods') . " AS o\n LEFT JOIN " . $GLOBALS['ecs']->table('products') . " AS p\n ON p.product_id = o.product_id\n LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g\n ON o.goods_id = g.goods_id\n LEFT JOIN " . $GLOBALS['ecs']->table('brand') . " AS b\n ON g.brand_id = b.brand_id\n\t\t\t\tLEFT JOIN " . $GLOBALS['ecs']->table('goods_attr') . " AS a\n ON o.goods_attr_id = a.goods_attr_id\n WHERE o.order_id = '{$order['order_id']}'"; $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { /* 虚拟商品支持 */ if ($row['is_real'] == 0) { /* 取得语言项 */ $filename = ROOT_PATH . 'plugins/' . $row['extension_code'] . '/languages/common_' . $_CFG['lang'] . '.php'; if (file_exists($filename)) { include_once $filename; if (!empty($_LANG[$row['extension_code'] . '_link'])) { $row['goods_name'] = $row['goods_name'] . sprintf($_LANG[$row['extension_code'] . '_link'], $row['goods_id'], $order['order_sn']); } } } $row['formated_subtotal'] = price_format($row['goods_price'] * $row['goods_number']); $row['formated_goods_price'] = price_format($row['goods_price']); $row['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $row['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods_attr[] = explode(' ', trim($row['goods_attr'])); //将商品属性拆分为一个数组 if ($row['extension_code'] == 'package_buy') { $row['storage'] = ''; $row['brand_name'] = ''; $row['package_goods_list'] = get_package_goods($row['goods_id']); } $goods_list[] = $row; } foreach ($goods_list as $goods_key => $goods_val) { $sql_goods = "select bo.*,bg.product_id from " . $GLOBALS['ecs']->table('back_order') . " as bo " . " left join " . $GLOBALS['ecs']->table('back_goods') . " as bg " . " on bo.back_id = bg.back_id and bo.goods_id = bg.goods_id" . " where bo.order_id='{$order['order_id']}' and bo.goods_id='{$goods_val['goods_id']}' " . " and bg.product_id='{$goods_val['product_id']}' and bo.status_back < 6"; $back_order = $GLOBALS['db']->getRow($sql_goods); $goods_list[$goods_key]['back_can'] = count($back_order['order_id']) > 0 ? '0' : '1'; switch ($back_order['status_back']) { case '3': $sb = "已完成"; break; case '5': $sb = "已申请"; break; //case '6' : $sb = ""; break; //case '7' : $sb = ""; break; //case '6' : $sb = ""; break; //case '7' : $sb = ""; break; default: $sb = "正在"; break; } switch ($back_order['back_type']) { case '1': $bt = "退货"; break; case '3': $bt = "申请维修"; break; case '4': $bt = "退款"; break; default: break; } $goods_list[$goods_key]['back_can_no'] = $sb . " " . $bt; } return $goods_list; }