/**
 * 取商品的下拉框Select列表
 *
 * @param       int      $goods_id    商品id
 *
 * @return  array
 */
function get_good_products_select($goods_id)
{
    $return_array = array();
    $products = get_good_products($goods_id);
    if (empty($products)) {
        return $return_array;
    }
    foreach ($products as $value) {
        $return_array[$value['product_id']] = $value['goods_attr_str'];
    }
    return $return_array;
}
Example #2
0
} elseif ($_REQUEST['act'] == 'search_goods') {
    check_authz_json('auction');
    include_once ROOT_PATH . 'includes/cls_json.php';
    $json = new JSON();
    $filter = $json->decode($_GET['JSON']);
    $arr['goods'] = get_goods_list($filter);
    if (!empty($arr['goods'][0]['goods_id'])) {
        $arr['products'] = get_good_products($arr['goods'][0]['goods_id']);
    }
    make_json_result($arr);
} elseif ($_REQUEST['act'] == 'search_products') {
    include_once ROOT_PATH . 'includes/cls_json.php';
    $json = new JSON();
    $filters = $json->decode($_GET['JSON']);
    if (!empty($filters->goods_id)) {
        $arr['products'] = get_good_products($filters->goods_id);
    }
    make_json_result($arr);
}
/*
 * 取得拍卖活动列表
 * @return   array
 */
function auction_list()
{
    $result = get_filter();
    if ($result === false) {
        /* 过滤条件 */
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
Example #3
0
     ecs_header("Location: {$page}\n");
     exit;
 }
 $result = get_snatch_result($id);
 if ($_SESSION['user_id'] != $result['user_id']) {
     show_message($_LANG['not_for_you']);
 }
 //检查是否已经购买过
 if ($result['order_count'] > 0) {
     show_message($_LANG['order_placed']);
 }
 /* 处理规格属性 */
 $goods_attr = '';
 $goods_attr_id = '';
 if ($snatch['product_id'] > 0) {
     $product_info = get_good_products($snatch['goods_id'], 'AND product_id = ' . $snatch['product_id']);
     $goods_attr_id = str_replace('|', ',', $product_info[0]['goods_attr']);
     $attr_list = array();
     $sql = "SELECT a.attr_name, g.attr_value " . "FROM " . $ecs->table('goods_attr') . " AS g, " . $ecs->table('attribute') . " AS a " . "WHERE g.attr_id = a.attr_id " . "AND g.goods_attr_id " . db_create_in($goods_attr_id);
     $res = $db->query($sql);
     while ($row = $db->fetchRow($res)) {
         $attr_list[] = $row['attr_name'] . ': ' . $row['attr_value'];
     }
     $goods_attr = join('', $attr_list);
 } else {
     $snatch['product_id'] = 0;
 }
 /* 清空购物车中所有商品 */
 include_once ROOT_PATH . 'includes/lib_order.php';
 clear_cart(CART_SNATCH_GOODS);
 /* 加入购物车 */
Example #4
0
    /* 检查活动重名 */
    $sql = "SELECT COUNT(*) " . " FROM " . $hhs->table('goods_activity') . " WHERE act_type='" . GAT_PACKAGE . "' AND act_name='{$val}' AND act_id <> '{$id}'";
    if ($db->getOne($sql)) {
        make_json_error(sprintf($_LANG['package_exist'], $val));
    }
    $exc->edit("act_name='{$val}'", $id);
    make_json_result(stripslashes($val));
} elseif ($_REQUEST['act'] == 'search_goods') {
    include_once ROOT_PATH . 'includes/cls_json.php';
    $json = new JSON();
    $filters = $json->decode($_GET['JSON']);
    $arr = get_goods_list($filters);
    $opt = array();
    foreach ($arr as $key => $val) {
        $opt[$key] = array('value' => $val['goods_id'], 'text' => $val['goods_name'], 'data' => $val['shop_price']);
        $opt[$key]['products'] = get_good_products($val['goods_id']);
    }
    make_json_result($opt);
} elseif ($_REQUEST['act'] == 'add_package_goods') {
    include_once ROOT_PATH . 'includes/cls_json.php';
    $json = new JSON();
    check_authz_json('package_manage');
    $fittings = $json->decode($_GET['add_ids']);
    $arguments = $json->decode($_GET['JSON']);
    $package_id = $arguments[0];
    $number = $arguments[1];
    foreach ($fittings as $val) {
        $val_array = explode('_', $val);
        if (!isset($val_array[1]) || $val_array[1] <= 0) {
            $val_array[1] = 0;
        }
Example #5
0
 /* 查询:是否登录 */
 $user_id = $_SESSION['user_id'];
 if ($user_id <= 0) {
     show_message($_LANG['au_buy_after_login']);
 }
 /* 查询:最后出价的是该用户吗 */
 if ($auction['last_bid']['bid_user'] != $user_id) {
     show_message($_LANG['au_final_bid_not_you'], '', '', 'error');
 }
 /* 查询:取得商品信息 */
 $goods = goods_info($auction['goods_id']);
 /* 查询:处理规格属性 */
 $goods_attr = '';
 $goods_attr_id = '';
 if ($auction['product_id'] > 0) {
     $product_info = get_good_products($auction['goods_id'], 'AND product_id = ' . $auction['product_id']);
     $goods_attr_id = str_replace('|', ',', $product_info[0]['goods_attr']);
     $attr_list = array();
     $sql = "SELECT a.attr_name, g.attr_value " . "FROM " . $ecs->table('goods_attr') . " AS g, " . $ecs->table('attribute') . " AS a " . "WHERE g.attr_id = a.attr_id " . "AND g.goods_attr_id " . db_create_in($goods_attr_id);
     $res = $db->query($sql);
     while ($row = $db->fetchRow($res)) {
         $attr_list[] = $row['attr_name'] . ': ' . $row['attr_value'];
     }
     $goods_attr = join(chr(13) . chr(10), $attr_list);
 } else {
     $auction['product_id'] = 0;
 }
 /* 清空购物车中所有拍卖商品 */
 include_once ROOT_PATH . 'includes/lib_order.php';
 clear_cart(CART_AUCTION_GOODS);
 /* 加入购物车 */
Example #6
0
 /**
  * 购买商品
  */
 public function buy()
 {
     if (empty($this->id)) {
         $this->redirect(url('Snatch/info', array('id' => $this->id)));
         exit;
     }
     if (empty($_SESSION['user_id'])) {
         show_message(L('not_login'));
     }
     $snatch = model('Snatch')->get_snatch($this->id);
     if (empty($snatch)) {
         $this->redirect(url('index', array('id' => $this->id)));
         exit;
     }
     /* 未结束,不能购买 */
     if (empty($snatch['is_end'])) {
         $this->redirect(url('index', array('id' => $this->id)));
         exit;
     }
     $result = model('ActivityBase')->get_snatch_result($this->id);
     if ($_SESSION['user_id'] != $result['user_id']) {
         show_message(L('not_for_you'));
     }
     //检查是否已经购买过
     if ($result['order_count'] > 0) {
         show_message(L('order_placed'));
     }
     /* 处理规格属性 */
     $goods_attr = '';
     $goods_attr_id = '';
     if ($snatch['product_id'] > 0) {
         $product_info = get_good_products($snatch['goods_id'], 'AND product_id = ' . $snatch['product_id']);
         $goods_attr_id = str_replace('|', ',', $product_info[0]['goods_attr']);
         $attr_list = array();
         $sql = "SELECT a.attr_name, g.attr_value " . "FROM " . $this->model->pre . "goods_attr AS g, " . $this->model->pre . "attribute AS a " . "WHERE g.attr_id = a.attr_id " . "AND g.goods_attr_id " . db_create_in($goods_attr_id);
         $res = $this->model->query($sql);
         foreach ($res as $row) {
             $attr_list[] = $row['attr_name'] . ': ' . $row['attr_value'];
         }
         $goods_attr = join('', $attr_list);
     } else {
         $snatch['product_id'] = 0;
     }
     /* 清空购物车中所有商品 */
     model('Order')->clear_cart(CART_SNATCH_GOODS);
     /* 加入购物车 */
     $cart = array('user_id' => $_SESSION['user_id'], 'session_id' => SESS_ID, 'goods_id' => $snatch['goods_id'], 'product_id' => $snatch['product_id'], 'goods_sn' => addslashes($snatch['goods_sn']), 'goods_name' => addslashes($snatch['goods_name']), 'market_price' => $snatch['market_price'], 'goods_price' => $result['buy_price'], 'goods_number' => 1, 'goods_attr' => $goods_attr, 'goods_attr_id' => $goods_attr_id, 'is_real' => $snatch['is_real'], 'extension_code' => addslashes($snatch['extension_code']), 'parent_id' => 0, 'rec_type' => CART_SNATCH_GOODS, 'is_gift' => 0);
     $this->model->table('cart')->data($cart)->insert();
     /* 记录购物流程类型:夺宝奇兵 */
     $_SESSION['flow_type'] = CART_SNATCH_GOODS;
     $_SESSION['extension_code'] = 'snatch';
     $_SESSION['extension_id'] = $this->id;
     /* 进入收货人页面 */
     $this->redirect(url('flow/consignee'));
     exit;
 }