/** * 调用浏览历史 * * @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; }
/** * 取得某推荐下商品 * @param int $recom_id 推荐类型 * @param int $num 取商品数量 * @param bool $default_image 如果商品没有图片,是否取默认图片 * @param int $mall_cate_id 分类(最新商品用到) */ function get_recommended_goods($recom_id, $num, $default_image = true, $mall_cate_id = 0) { $goods_list = array(); $conditions = "g.if_show = 1 AND g.closed = 0 AND s.state = 1 "; if ($recom_id == REC_NEW) { /* 最新商品 */ if ($mall_cate_id > 0) { $gcategory_mod =& m('gcategory'); $conditions .= " AND g.cate_id " . db_create_in($gcategory_mod->get_descendant($mall_cate_id)); } $sql = "SELECT g.goods_id, g.goods_name, g.default_image, gs.price, gs.stock, gs.spec_id " . "FROM " . DB_PREFIX . "goods AS g " . "LEFT JOIN " . DB_PREFIX . "goods_spec AS gs ON g.default_spec = gs.spec_id " . "LEFT JOIN " . DB_PREFIX . "store AS s ON g.store_id = s.store_id " . "WHERE " . $conditions . "ORDER BY g.add_time DESC " . "LIMIT {$num}"; } else { /* 推荐商品 */ $sql = "SELECT g.goods_id, g.goods_name, g.default_image, gs.price, gs.stock, gs.spec_id " . "FROM " . DB_PREFIX . "recommended_goods AS rg " . " LEFT JOIN " . DB_PREFIX . "goods AS g ON rg.goods_id = g.goods_id " . " LEFT JOIN " . DB_PREFIX . "goods_spec AS gs ON g.default_spec = gs.spec_id " . " LEFT JOIN " . DB_PREFIX . "store AS s ON g.store_id = s.store_id " . "WHERE " . $conditions . "AND rg.recom_id = '{$recom_id}' " . "AND g.goods_id IS NOT NULL " . "ORDER BY rg.sort_order " . "LIMIT {$num}"; } $res = $this->db->query($sql); $promotion_mod =& m('promotion'); while ($row = $this->db->fetchRow($res)) { $default_image && empty($row['default_image']) && ($row['default_image'] = Conf::get('default_goods_image')); /* 读取促销价格 */ $row['price'] = $promotion_mod->get_promotion_price($row['goods_id'], $row['spec_id']); $goods_list[] = $row; } return $goods_list; }
function get_cat_id_goods_list($cat_id = '', $num = '', $ext = '') { $sql = 'Select g.goods_id,g.guige, g.cat_id,c.parent_id, g.goods_name, g.goods_number, 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, " . "g.is_best, g.is_new, g.is_hot, g.is_promote,b.brand_name " . 'FROM ' . $GLOBALS['hhs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['hhs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' . "LEFT JOIN " . $GLOBALS['hhs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " left join " . $GLOBALS['hhs']->table('brand') . " as b on g.brand_id=b.brand_id " . " Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_new = 1 AND g.is_delete = 0 and g.is_mall=1 " . ($sql .= " AND (c.parent_id =" . $cat_id . " OR g.cat_id = " . $cat_id . " OR g.cat_id " . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ")"); $sql .= $ext; $sql .= " LIMIT {$num}"; $res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($res as $idx => $row) { $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['guige'] = $row['guige']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = $row['brand_name']; $goods[$idx]['goods_number'] = $row['goods_number']; $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'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb']; $goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img']; $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); if ($GLOBALS['SID']) { $goods[$idx]['shop_price'] = price_format($row['s_goods_price']); } } return $goods; }
function __category_goods_where($data = array()) { if (empty($data)) { return ""; } $cid = isset($data['cid']) && intval($data['cid']) > 0 ? intval($data['cid']) : 0; $bid = isset($data['bid']) && intval($data['bid']) > 0 ? intval($data['bid']) : 0; $comd[] = "g.is_on_sale = '1' AND g.is_delete = '0' AND g.is_alone_sale='1'"; //品牌 if ($bid > 0) { //子分类 $sub_bid = $this->get_brand_sub_cat_ids_model($bid); //子分类id $comd[] = "(b.brand_id" . db_create_in($sub_bid) . ")"; unset($sub_bid); } if ($cid > 0) { //子分类 $sub_cid = $this->get_goods_sub_cat_ids_model($cid); //子分类id $comd[] = "(g.cat_id" . db_create_in($sub_cid) . " OR csg.cat_id='{$cid}')"; unset($sub_cid); } $w = ""; if (!empty($comd)) { $w = "WHERE " . implode(' AND ', $comd); } return $w; }
function get_temp_list() { // Obtaion to the temp list $result = get_filter(); if ($result === false) { $filter = array(); $where = "WHERE 1"; $filter['bdate'] = empty($_REQUEST['bdate']) ? date('Y-m-d') : trim($_REQUEST['bdate']); if (!empty($_REQUEST['city'])) { $where .= " AND "; } else { $where .= " AND a.country" . db_create_in(array_keys($_SESSION['city_arr'])); } $where .= " AND a.order_status=1 AND b.goods_price>100"; if ($filter['bdate']) { $where .= " AND a.best_time BETWEEN '" . $filter['bdate'] . " 00:00:00' AND '" . $filter['bdate'] . " 23:59:59'"; } $query = "SELECT DISTINCT COUNT(*) FROM ecs_order_info AS a \r\n\t\t\tLEFT JOIN ecs_order_goods AS b ON a.order_id=b.order_id \r\n\t\t\tLEFT JOIN order_dispatch AS c ON c.order_id=a.order_id \r\n\t\t\tLEFT JOIN ship_route AS d ON d.route_id=c.route_id {$where}"; $filter['record_count'] = $GLOBALS['db_read']->getOne($query); $filter = page_and_size($filter); $limit = "LIMIT " . $filter['start'] . "," . $filter['page_size'] . ""; $sql = "SELECT SUM(b.goods_number) AS gnum,c.turn,d.station_id \r\n\t\t\tFROM ecs_order_info AS a \r\n\t\t\tLEFT JOIN ecs_order_goods AS b ON a.order_id=b.order_id \r\n\t\t\tLEFT JOIN order_dispatch AS c ON c.order_id=a.order_id \r\n\t\t\tLEFT JOIN ship_route AS d ON d.route_id=c.route_id {$where} \r\n\t\t\tGROUP BY c.turn,d.station_id {$limit}"; set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $list = $GLOBALS['db_read']->getAll($sql); return array('list' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
/** * 调用浏览历史 * * @access public * @return string */ function insert_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,market_price FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE $where AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 limit 3"; $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['market_price'] = floor($row['market_price']); $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.='<ul class="clearfix" style=" height:248px;"><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 />吉采价:<font class="f1">'.$goods['shop_price'].'</font>元 <i style="text-decoration:line-through;">市场价:<font class="f1">'.$goods['market_price'].'</font>元</i><br /></li></ul>'; } $str .= ''; } return $str; }
function ajax_select_goods($maxattr = 0, $page = 1) { $cid = isset($_COOKIE['GZ_cid']) ? $_COOKIE['GZ_cid'] : 0; $subcid = array(); if ($cid > 0) { $subcid = $this->action('catalog', 'get_goods_sub_cat_ids', $cid); } //分类 /// isset($_COOKIE['GZ_bid']) && intval($_COOKIE['GZ_bid']) > 0 ? $comd[] = "b.brand_id = '" . intval($_COOKIE['GZ_bid']) . "'" : 0; //品牌 if ($maxattr > 0) { for ($i = 0; $i < $maxattr; $i++) { isset($_COOKIE['GZ_' . $i]) && !empty($_COOKIE['GZ_' . $i]) ? $comd[] = "ga.attr_value = '" . $_COOKIE['GZ_' . $i] . "'" : 0; //属性 } } if (!empty($subcid)) { $comd[] = "gc.cat_id " . db_create_in($subcid); } $w = !empty($comd) ? " WHERE " . implode(' AND ', $comd) : ""; $tt = $this->__get_user_goods_select_count($w); $rt['count'] = $tt; $list = 12; $rt['goodslist'] = $this->__get_user_goods_select($w, $page, $list); $rt['goodspage'] = Import::basic()->ajax_page($tt, $list, $page, 'get_select_goods_page'); $this->set('rt', $rt); $con = $this->fetch('ajax_user_goods_select', true); die($con); }
/** * 获得指定分类同级的所有分类以及该分类下的子分类 * * @access public * @param integer $cat_id 分类编号 * @return array */ function get_categories_tree_pro($cat_id = 0) { if ($cat_id > 0) { $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'"; $parent_id = $GLOBALS['db']->getOne($sql); } else { $parent_id = 0; } /* 判断当前分类中全是是否是底级分类, 如果是取出底级分类上级分类, 如果不是取当前分类及其下的子分类 */ $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '{$parent_id}' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $parent_id == 0) { /* 获取当前分类及其子分类 */ $sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$parent_id}' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($sql); foreach ($res as $row) { $cat_id = $row['cat_id']; $children = get_children($cat_id); $cat = $GLOBALS['db']->getRow('SELECT cat_name, keywords, cat_desc, style, grade, filter_attr, parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'"); /* 获取分类下文章 */ $sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type FROM ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac RIGHT JOIN ' . $GLOBALS['ecs']->table('article') . " AS a ON a.cat_id=ac.cat_id AND a.is_open = 1 WHERE ac.cat_name='{$row['cat_name']}' ORDER BY a.article_type,a.article_id DESC LIMIT 4 "; $articles = $GLOBALS['db']->getAll($sql); foreach ($articles as $key => $val) { $articles[$key]['url'] = $val['open_type'] != 1 ? build_uri('article', array('aid' => $val['article_id']), $val['title']) : trim($val['file_url']); } /* 获取分类下品牌 */ $sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, COUNT(*) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag " . "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, " . $GLOBALS['ecs']->table('goods') . " AS g LEFT JOIN " . $GLOBALS['ecs']->table('goods_cat') . " AS gc ON g.goods_id = gc.goods_id " . "WHERE g.brand_id = b.brand_id AND ({$children} OR " . 'gc.cat_id ' . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ") AND b.is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC"; $brands = $GLOBALS['db']->getAll($sql); foreach ($brands as $key => $val) { $temp_key = $key + 1; $brands[$temp_key]['brand_name'] = $val['brand_name']; $brands[$temp_key]['url'] = build_uri('category', array('cid' => $cat_id, 'bid' => $val['brand_id'], 'price_min' => $price_min, 'price_max' => $price_max, 'filter_attr' => $filter_attr_str), $cat['cat_name']); /* 判断品牌是否被选中 */ if ($brand == $brands[$key]['brand_id']) { $brands[$temp_key]['selected'] = 1; } else { $brands[$temp_key]['selected'] = 0; } } unset($brands[0]); $cat_arr[$row['cat_id']]['brands'] = $brands; $cat_arr[$row['cat_id']]['articles'] = $articles; if ($row['is_show']) { $cat_arr[$row['cat_id']]['id'] = $row['cat_id']; $cat_arr[$row['cat_id']]['name'] = $row['cat_name']; $cat_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); if (isset($row['cat_id']) != NULL) { $cat_arr[$row['cat_id']]['cat_id'] = get_child_tree_pro($row['cat_id']); } } } } if (isset($cat_arr)) { return $cat_arr; } }
/** * 保存投票结果信息 * * @access public * @param integer $vote_id * @param string $ip_address * @param string $option_id * @return void */ function save_vote($vote_id, $ip_address, $option_id) { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('vote_log') . " (vote_id, ip_address, vote_time) " . "VALUES ('{$vote_id}', '{$ip_address}', " . gmtime() . ")"; $res = $GLOBALS['db']->query($sql); /* 更新投票主题的数量 */ $sql = "UPDATE " . $GLOBALS['ecs']->table('vote') . " SET " . "vote_count = vote_count + 1 " . "WHERE vote_id = '{$vote_id}'"; $GLOBALS['db']->query($sql); /* 更新投票选项的数量 */ $sql = "UPDATE " . $GLOBALS['ecs']->table('vote_option') . " SET " . "option_count = option_count + 1 " . "WHERE " . db_create_in($option_id, 'option_id'); $GLOBALS['db']->query($sql); }
/** * 保存投票结果信息. * * @param int $vote_id * @param string $ip_address * @param string $option_id */ function save_vote($vote_id, $ip_address, $option_id) { $sql = 'INSERT INTO ' . $GLOBALS['ecs']->table('vote_log') . ' (vote_id, ip_address, vote_time) ' . "VALUES ('{$vote_id}', '{$ip_address}', " . gmtime() . ')'; $res = $GLOBALS['db']->query($sql); /* 更新投票主题的数量 */ $sql = 'UPDATE ' . $GLOBALS['ecs']->table('vote') . ' SET ' . 'vote_count = vote_count + 1 ' . "WHERE vote_id = '{$vote_id}'"; $GLOBALS['db']->query($sql); /* 更新投票选项的数量 */ $sql = 'UPDATE ' . $GLOBALS['ecs']->table('vote_option') . ' SET ' . 'option_count = option_count + 1 ' . 'WHERE ' . db_create_in($option_id, 'option_id'); $GLOBALS['db']->query($sql); }
function delete() { $ques_id = empty($_GET['id']) ? 0 : trim($_GET['id']); $ids = explode(',', $ques_id); $conditions = "1 = 1 AND ques_id " . db_create_in($ids); if (!($res = $this->goodsqa_mod->drop($conditions))) { $this->show_warning('drop_failed'); return; } else { $this->show_warning('drop_successful', 'to_qa_list', 'index.php?app=consulting'); return; } }
function _get_descendant($ids, &$ids_total) { $childs = $this->find(array('fields' => 'cate_id', 'conditions' => "parent_id " . db_create_in($ids))); $ids_total = array_merge($ids_total, $ids); $ids = array(); foreach ($childs as $child) { $ids[] = $child['cate_id']; } if (empty($ids)) { return; } $this->_get_descendant($ids, $ids_total); }
function get_ACC($ACC_code = '') { if ($ACC_code) { $ACC = $this->get("code = '{$ACC_code}'"); return isset($ACC['cate_id']) ? $ACC['cate_id'] : false; } else { $ACC_code = array(ACC_HELP, ACC_NOTICE, ACC_SYSTEM); $data = $this->find('code ' . db_create_in($ACC_code)); foreach ($data as $v) { $ACC[$v['code']] = $v['cate_id']; } return isset($ACC) ? $ACC : false; } }
function groupbuy() { /* 店铺信息 */ $id = empty($_GET['id']) ? 0 : intval($_GET['id']); if (!$id) { $this->show_warning('Hacking Attempt'); return; } $this->set_store($id); $store = $this->get_store_data(); $this->assign('store', $store); /* 搜索团购 */ empty($_GET['state']) && ($_GET['state'] = 'on'); $conditions = '1=1'; if ($_GET['state'] == 'on') { $conditions .= ' AND gb.state =' . GROUP_ON . ' AND gb.end_time>' . gmtime(); $search_name = array(array('text' => Lang::get('group_on')), array('text' => Lang::get('all_groupbuy'), 'url' => url('app=store&act=groupbuy&state=all&id=' . $id))); } else { if ($_GET['state'] == 'all') { $conditions .= ' AND gb.state ' . db_create_in(array(GROUP_ON, GROUP_END, GROUP_FINISHED)); $search_name = array(array('text' => Lang::get('all_groupbuy')), array('text' => Lang::get('group_on'), 'url' => url('app=store&act=groupbuy&state=on&id=' . $id))); } } $page = $this->_get_page(16); $groupbuy_mod =& m('groupbuy'); $groupbuy_list = $groupbuy_mod->find(array('fields' => 'goods.default_image, gb.group_name, gb.group_id, gb.spec_price, gb.end_time, gb.state', 'join' => 'belong_goods', 'conditions' => $conditions . ' AND gb.store_id=' . $id, 'order' => 'group_id DESC', 'limit' => $page['limit'], 'count' => true)); $page['item_count'] = $groupbuy_mod->getCount(); $this->_format_page($page); $this->assign('page_info', $page); if (empty($groupbuy_list)) { $groupbuy_list = array(); } foreach ($groupbuy_list as $key => $_g) { empty($groupbuy_list[$key]['default_image']) && ($groupbuy_list[$key]['default_image'] = Conf::get('default_goods_image')); $tmp = current(unserialize($_g['spec_price'])); $groupbuy_list[$key]['price'] = $tmp['price']; if ($_g['end_time'] < gmtime()) { $groupbuy_list[$key]['group_state'] = group_state($_g['state']); } else { $groupbuy_list[$key]['lefttime'] = lefttime($_g['end_time']); } } /* 当前位置 */ $this->_curlocal(LANG::get('all_stores'), 'index.php?app=search&act=store', $store['store_name'], 'index.php?app=store&id=' . $store['store_id'], LANG::get('groupbuy_list')); $this->assign('groupbuy_list', $groupbuy_list); $this->assign('search_name', $search_name); $this->_config_seo('title', $search_name[0]['text'] . ' - ' . $store['store_name']); $this->display('store.groupbuy.html'); }
function drop() { if (!isset($_GET['id']) && empty($_GET['id'])) { $this->show_warning("involid_data"); exit; } $ids = explode(',', trim($_GET['id'])); $couponsn_mod =& m('couponsn'); $couponsn_mod->unlinkRelation('bind_user', db_create_in($ids, 'coupon_sn')); if ($couponsn_mod->has_error()) { $this->show_warning($couponsn_mod->get_error()); exit; } $this->show_message('drop_ok', 'back_list', 'index.php?app=my_coupon'); }
function drop() { $id = trim($_GET['id']); $ids = explode(',', $id); if (empty($ids)) { $this->show_warning("no_valid_data"); exit; } $this->_groupbuy_mod->drop(db_create_in($ids, 'group_id')); if ($this->_groupbuy_mod->has_error()) { $this->show_warning($this->_groupbuy_mod->get_error()); exit; } $this->show_warning('drop_success', 'back_list', 'index.php?app=groupbuy'); }
function category_get_goods22() { $where = "g.is_on_sale = 1 and g.is_bind_card='2' AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 "; $id = isset($_REQUEST['id']) ? trim($_REQUEST['id']) : 0; if ($id) { $where .= " and g.cat_id " . db_create_in(array_unique(array_keys(cat_list($id, 0, false)))); } /* 获得商品列表 */ $sql = 'SELECT g.goods_id, g.goods_name,g.cat_id, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, 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 ' . '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 {$where} "; $goodlist = $GLOBALS['db']->getAll($sql); $arr = array(); foreach ($goodlist 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; } /* 处理商品水印图片 */ $watermark_img = ''; if ($promote_price != 0) { $watermark_img = "watermark_promote_small"; } elseif ($row['is_new'] != 0) { $watermark_img = "watermark_new_small"; } elseif ($row['is_best'] != 0) { $watermark_img = "watermark_best_small"; } elseif ($row['is_hot'] != 0) { $watermark_img = 'watermark_hot_small'; } if ($watermark_img != '') { $arr[$row['goods_id']]['watermark_img'] = $watermark_img; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $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']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $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; }
/** * 查询订单数 * * @param mix $group_id */ function get_order_count($group_id) { if (is_array($group_id)) { $ids = $group_id; } else { $ids = array(intval($group_id)); } $count = $this->db->getAllWithIndex("SELECT group_id,count(*) as count FROM " . DB_PREFIX . "groupbuy_log WHERE group_id " . db_create_in($ids) . " AND order_id>0 GROUP BY group_id", array('group_id')); if (is_array($group_id)) { foreach ($ids as $id) { !isset($count[$id]) && ($count[$id] = array()); } return $count; } else { return isset($count[$group_id]['count']) ? $count[$group_id]['count'] : 0; } }
function cake_list() { $filter['ids'] = empty($_REQUEST['ids']) ? '' : trim($_REQUEST['ids']); $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'best_time' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $sql = "SELECT order_id,order_sn,scts,add_time,best_time FROM ecs_order_info WHERE order_id " . db_create_in($filter['ids']) . " ORDER by " . $filter['sort_by'] . " " . $filter['sort_order']; $r = $GLOBALS['db_read']->getAll($sql); $cake_list = array(); foreach ($r as $key => $val) { $cake_list[$key]['i'] = $key + 1; $cake_list[$key]['order_id'] = $val['order_id']; $cake_list[$key]['order_sn'] = $val['order_sn']; $cake_list[$key]['best_time'] = $val['best_time']; $cake_list[$key]['done_time'] = date('Y-m-d H:i', strtotime($val['best_time']) - 4 * 3600); $cake_list[$key]['add_time'] = date('Y-m-d H:i', $val['add_time']); } return array('cake_list' => $cake_list, 'filter' => $filter); }
/** * 取得某配送方式对应于某收货地址的区域信息 * @param int $shipping_id 配送方式id * @param array $region_id_list 收货人地区id数组 * @return array 配送区域信息(config 对应着反序列化的 configure) */ function shipping_area_info($shipping_id, $region_id_list) { $sql = 'SELECT s.shipping_code, s.shipping_name, ' . 's.shipping_desc, s.insure, s.support_cod, a.configure ' . 'FROM ' . $this->pre . 'shipping AS s, ' . $this->pre . 'shipping_area AS a, ' . $this->pre . 'area_region AS r ' . "WHERE s.shipping_id = '{$shipping_id}' " . 'AND r.region_id ' . db_create_in($region_id_list) . ' AND r.shipping_area_id = a.shipping_area_id AND a.shipping_id = s.shipping_id AND s.enabled = 1'; $row = $this->row($sql); if (!empty($row)) { $shipping_config = unserialize_config($row['configure']); if (isset($shipping_config['pay_fee'])) { if (strpos($shipping_config['pay_fee'], '%') !== false) { $row['pay_fee'] = floatval($shipping_config['pay_fee']) . '%'; } else { $row['pay_fee'] = floatval($shipping_config['pay_fee']); } } else { $row['pay_fee'] = 0.0; } } return $row; }
function _get_system_notice($member_role = 'buyer_admin') { // 根据不同的用户角色(卖家或买家),在用户中心首页显示不同的文章 if ($member_role == 'seller_admin') { $article_cate_id = 2; } else { $article_cate_id = 1; } $article_mod =& m('article'); $acategory_mod =& m('acategory'); $cate_ids = $acategory_mod->get_descendant($article_cate_id); if ($cate_ids) { $conditions = ' AND cate_id ' . db_create_in($cate_ids); } else { $conditions = ''; } $data = $article_mod->find(array('conditions' => 'code = "" AND if_show=1 AND store_id=0 ' . $conditions, 'fields' => 'article_id, title', 'limit' => 5, 'order' => 'sort_order ASC, article_id DESC')); return $data; }
function _get_channel_goods($cate_id) { $gcategory_mod =& m('gcategory'); $goods_mod =& m('goods'); $page = $this->_get_page(64); $cate_id && ($conditions = " AND g.cate_id " . db_create_in($gcategory_mod->get_descendant($cate_id))); $goods_list = $goods_mod->get_list(array('conditions' => 'g.if_show = 1 AND g.closed = 0 ' . $conditions, 'order' => 'add_time desc', 'limit' => $page['limit'], 'count' => true)); foreach ($goods_list as $key => $goods) { empty($goods['default_image']) && ($goods_list[$key]['default_image'] = Conf::get('default_goods_image')); /* if($goods['default_image']){ $goods_list[$key]['default_image'] = str_replace("small_","", $goods['default_image']); } */ } $page['item_count'] = $goods_mod->getCount(); $this->_format_page($page); return array('goods_list' => $goods_list, 'page_info' => $page); }
function delete() { $ques_id = empty($_GET['id']) ? 0 : trim($_GET['id']); $ids = explode(',', $ques_id); $conditions = "1 = 1 AND ques_id " . db_create_in($ids); $ms =& ms(); foreach ($ids as $key => $val) { $title = Lang::get('drop_goodsqa_notice'); $store = $this->goodsqa_mod->get(array('conditions' => 'ques_id =' . $val, 'join' => 'belongs_to_goods', 'fields' => 'goods_qa.store_id,goods_name,question_content')); $content = sprintf(Lang::get('admin_drop_your_goodsqa'), LANG::get('goods'), addslashes($store['goods_name']), Lang::get('content_is'), addslashes($store['question_content'])); $ms->pm->send(MSG_SYSTEM, $store['store_id'], $title, $content); } if (!($res = $this->goodsqa_mod->drop($conditions))) { $this->show_warning('drop_failed'); return; } else { $this->show_warning('drop_successful', 'to_qa_list', 'index.php?app=goodsqa'); return; } }
/** * 添加好友 * * @author Hyber * @return void */ function add() { if (!IS_POST) { /* 当前位置 */ $this->_curlocal(LANG::get('member_center'), 'index.php?app=member', LANG::get('friend'), 'index.php?app=friend', LANG::get('add_friend')); header('Content-Type:text/html;charset=' . CHARSET); /* 当前所处子菜单 */ $this->_curmenu('add_friend'); /* 当前用户中心菜单 */ $this->_curitem('friend'); $this->display('friend.form.html'); } else { $user_name = str_replace(Lang::get('comma'), ',', $_POST['user_name']); //替换中文格式的逗号 if (!$user_name) { $this->pop_warning('input_username'); return; } $user_names = explode(',', $user_name); //将逗号分割的用户名转换成数组 $mod_member =& m('member'); $members = $mod_member->find("user_name " . db_create_in($user_names)); $friend_ids = array_keys($members); if (!$friend_ids) { $this->pop_warning('no_such_user'); return; } $ms =& ms(); $result = $ms->friend->add($this->visitor->get('user_id'), $friend_ids); if (!$result) { $msg = current($ms->friend->get_error()); $this->pop_warning($msg['msg']); return; } $this->pop_warning('ok', APP . '_' . ACT); /*$this->show_message('add_friend_successed', 'back_list', 'index.php?app=friend', 'continue_add', 'index.php?app=friend&act=add' );*/ } }
/** * 取得某推荐下商品 * @param int $recom_id 推荐类型 * @param int $num 取商品数量 * @param bool $default_image 如果商品没有图片,是否取默认图片 * @param int $mall_cate_id 分类(最新商品用到) */ function get_recommended_goods($recom_id, $num, $default_image = true, $mall_cate_id = 0, $timeslot = array(), $sort_by = '') { $goods_list = array(); $order = ''; $conditions = "g.if_show = 1 AND g.closed = 0 AND s.state = 1 "; // tyioocom 加了时间段 if (count($timeslot) > 0) { $conditions .= "AND g.add_time >='" . $timeslot['begin'] . "' and g.add_time <='" . $timeslot['end'] . "'"; } if ($recom_id == REC_NEW) { if (empty($sort_by)) { $order = ' g.add_time DESC '; } elseif (in_array($sort_by, array('views', 'collects', 'comments', 'sales'))) { $order = ' goodsstatistics.' . $sort_by . ' DESC,g.add_time DESC '; } elseif ($sort_by == 'add_time') { $order = ' g.add_time DESC '; } /* 最新商品 */ if ($mall_cate_id > 0) { $gcategory_mod =& m('gcategory'); $conditions .= " AND g.cate_id " . db_create_in($gcategory_mod->get_descendant($mall_cate_id)); } $sql = "SELECT g.goods_id, g.goods_name, g.default_image, gs.price, gs.stock,goodsstatistics.sales,s.store_id,s.store_name " . "FROM " . DB_PREFIX . "goods AS g " . "LEFT JOIN " . DB_PREFIX . "goods_spec AS gs ON g.default_spec = gs.spec_id " . "LEFT JOIN " . DB_PREFIX . "store AS s ON g.store_id = s.store_id " . "LEFT JOIN " . DB_PREFIX . "goods_statistics AS goodsstatistics ON goodsstatistics.goods_id=g.goods_id " . "WHERE " . $conditions . "ORDER BY " . $order . "LIMIT {$num}"; } else { if (empty($sort_by)) { $order = ' rg.sort_order '; } elseif (in_array($sort_by, array('views', 'collects', 'comments', 'sales'))) { $order = ' goodsstatistics.' . $sort_by . ' DESC,rg.sort_order '; } elseif ($sort_by == 'add_time') { $order = ' g.add_time DESC '; } /* 推荐商品 */ $sql = "SELECT g.goods_id, g.goods_name, g.default_image, gs.price, gs.stock,goodsstatistics.sales,s.store_id,s.store_name " . "FROM " . DB_PREFIX . "recommended_goods AS rg " . " LEFT JOIN " . DB_PREFIX . "goods AS g ON rg.goods_id = g.goods_id " . " LEFT JOIN " . DB_PREFIX . "goods_spec AS gs ON g.default_spec = gs.spec_id " . " LEFT JOIN " . DB_PREFIX . "store AS s ON g.store_id = s.store_id " . "\tLEFT JOIN " . DB_PREFIX . "goods_statistics AS goodsstatistics ON goodsstatistics.goods_id=g.goods_id " . "WHERE " . $conditions . "AND rg.recom_id = '{$recom_id}' " . "AND g.goods_id IS NOT NULL " . "ORDER BY " . $order . "LIMIT {$num}"; } $res = $this->db->query($sql); while ($row = $this->db->fetchRow($res)) { $default_image && empty($row['default_image']) && ($row['default_image'] = Conf::get('default_goods_image')); $goods_list[] = $row; } return $goods_list; }
/** * 取消订单 * * @author Garbin * @return void */ function cancel_order() { $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; if (!$order_id) { echo Lang::get('no_such_order'); return; } $model_order =& m('order'); /* 只有待付款的订单可以取消 */ $order_info = $model_order->get("order_id={$order_id} AND buyer_id=" . $this->visitor->get('user_id') . " AND status " . db_create_in(array(ORDER_PENDING, ORDER_SUBMITTED))); if (empty($order_info)) { echo Lang::get('no_such_order'); return; } if (!IS_POST) { header('Content-Type:text/html;charset=' . CHARSET); $this->assign('order', $order_info); $this->display('buyer_order.cancel.html'); } else { $model_order->edit($order_id, array('status' => ORDER_CANCELED)); if ($model_order->has_error()) { $_errors = $model_order->get_error(); $error = current($_errors); $this->json_error(Lang::get($error['msg'])); return; } /* 加回商品库存 */ $model_order->change_stock('+', $order_id); $cancel_reason = !empty($_POST['remark']) ? $_POST['remark'] : $_POST['cancel_reason']; /* 记录订单操作日志 */ $order_log =& m('orderlog'); $order_log->add(array('order_id' => $order_id, 'operator' => addslashes($this->visitor->get('user_name')), 'order_status' => order_status($order_info['status']), 'changed_status' => order_status(ORDER_CANCELED), 'remark' => $cancel_reason, 'log_time' => gmtime())); /* 发送给卖家订单取消通知 */ $model_member =& m('member'); $seller_info = $model_member->get($order_info['seller_id']); $mail = get_mail('toseller_cancel_order_notify', array('order' => $order_info, 'reason' => $_POST['remark'])); $this->_mailto($seller_info['email'], addslashes($mail['subject']), addslashes($mail['message'])); $new_data = array('status' => Lang::get('order_canceled'), 'actions' => array()); $this->pop_warning('ok'); } }
/** * 调用浏览历史 * * @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; }
/** * 生成查询订单的sql * @param string $type 类型 * @param string $alias order表的别名(包括.例如 o.) * @return string */ function GZ_order_query_sql($type = 'finished', $alias = '') { /* 已完成订单 */ if ($type == 'finished') { return " AND {$alias}order_status " . db_create_in(array(OS_CONFIRMED, OS_SPLITED)) . " AND {$alias}shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) . " AND {$alias}pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) . " "; } elseif ($type == 'await_ship') { return " AND {$alias}order_status " . db_create_in(array(OS_CONFIRMED, OS_SPLITED, OS_SPLITING_PART)) . " AND {$alias}shipping_status " . db_create_in(array(SS_UNSHIPPED, SS_PREPARING, SS_SHIPPED_ING)) . " AND ( {$alias}pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) . " OR {$alias}pay_id " . db_create_in(payment_id_list(true)) . ") "; } elseif ($type == 'await_pay') { return " AND {$alias}order_status " . db_create_in(array(OS_CONFIRMED, OS_SPLITED, OS_UNCONFIRMED)) . " AND {$alias}pay_status = '" . PS_UNPAYED . "'" . " AND ( {$alias}shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) . " OR {$alias}pay_id " . db_create_in(payment_id_list(false)) . ") "; } elseif ($type == 'unconfirmed') { return " AND {$alias}order_status = '" . OS_UNCONFIRMED . "' "; } elseif ($type == 'unprocessed') { return " AND {$alias}order_status " . db_create_in(array(OS_UNCONFIRMED, OS_CONFIRMED)) . " AND {$alias}shipping_status = '" . SS_UNSHIPPED . "'" . " AND {$alias}pay_status = '" . PS_UNPAYED . "' "; } elseif ($type == 'unpay_unship') { return " AND {$alias}order_status " . db_create_in(array(OS_UNCONFIRMED, OS_CONFIRMED)) . " AND {$alias}shipping_status " . db_create_in(array(SS_UNSHIPPED, SS_PREPARING)) . " AND {$alias}pay_status = '" . PS_UNPAYED . "' "; } elseif ($type == 'shipped') { return " AND {$alias}shipping_status " . db_create_in(array(SS_SHIPPED)) . " "; } else { die('函数 order_query_sql 参数错误'); } }
/** * 调用浏览历史 * * @access public * @return string */ function insert_history1() { $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(); 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><a href="' . $goods['url'] . '" target="_blank"><img src="' . $goods['goods_thumb'] . '" alt="' . $goods['goods_name'] . '" height="50" width="50" /></a></li>'; } //$str .= '<ul id="clear_history"><a onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</a></ul>'; } return $str; }
/** * 调用浏览历史 */ 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; }