當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sort_goods_attr_id_array函數代碼示例

本文整理匯總了PHP中sort_goods_attr_id_array函數的典型用法代碼示例。如果您正苦於以下問題:PHP sort_goods_attr_id_array函數的具體用法?PHP sort_goods_attr_id_array怎麽用?PHP sort_goods_attr_id_array使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了sort_goods_attr_id_array函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_products_info

/**
 * 取指定規格的貨品信息
 *
 * @access      public
 * @param       string      $goods_id
 * @param       array       $spec_goods_attr_id
 * @return      array
 */
function get_products_info($goods_id, $spec_goods_attr_id)
{
    $return_array = array();
    if (empty($spec_goods_attr_id) || !is_array($spec_goods_attr_id) || empty($goods_id)) {
        return $return_array;
    }
    $goods_attr_array = sort_goods_attr_id_array($spec_goods_attr_id);
    if (isset($goods_attr_array['sort'])) {
        $goods_attr = implode('|', $goods_attr_array['sort']);
        $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('products') . " WHERE goods_id = '{$goods_id}' AND goods_attr = '{$goods_attr}' LIMIT 0, 1";
        $return_array = $GLOBALS['db']->getRow($sql);
    }
    return $return_array;
}
開發者ID:shaoslu,項目名稱:jumei,代碼行數:22,代碼來源:lib_goods.php

示例2: get_product_attr_num

/**
 * 獲取相關屬性的庫存
 * @param int $goodid 商品id
 * @param string(array) $attrids 商品屬性id的數組或者逗號分開的字符串
 */
function get_product_attr_num($goodid, $attrids = 0)
{
    $ret = array();
    /* 判斷商品是否參與預售活動,如果參與則獲取商品的(預售庫存-已售出的數量) */
    // if(!empty($_REQUEST['pre_sale_id']))
    // {
    // 	$pre_sale = pre_sale_info($_REQUEST['pre_sale_id'], $goods_num);
    // 	//如果預售為空或者預售庫存小於等於0則認為不限購
    // 	if(!empty($pre_sale) && $pre_sale['restrict_amount'] > 0){
    // 		$product_num = $pre_sale['restrict_amount'] - $pre_sale['valid_goods'];
    // 		return $product_num;
    // 	}
    // }
    if (empty($attrids)) {
        $ginfo = get_goods_attr_value($goodid, 'goods_number');
        return $ginfo['goods_number'];
        //$ret[$attrids] = $ginfo['goods_number'];
        //return $ret;
    }
    if (!is_array($attrids)) {
        $attrids = explode(',', $attrids);
    }
    $goods_attr_array = sort_goods_attr_id_array($attrids);
    if (isset($goods_attr_array['sort'])) {
        $goods_attr = implode('|', $goods_attr_array['sort']);
        $sql = "SELECT product_id, goods_id, goods_attr, product_sn, product_number\n                FROM " . $GLOBALS['ecs']->table('products') . " \n                WHERE goods_id = {$goodid} AND goods_attr = '" . $goods_attr . "' LIMIT 0, 1";
        $row = $GLOBALS['db']->getRow($sql);
        return $row['product_number'];
    }
    //sort($attrids);
    //$attrids = implode('|',$attrids);
    //$attrids = array_unique($attrids);
    //$attrids = str_replace(',','|',$attrids);
    /*
    	echo "<pre>";
    	print_r($row);
    
    	foreach ($row as $key => $value)
    {
        if(in_array($value['goods_attr'],$attrids)){
        	$ret[$value['goods_attr']] = $value['product_number'];
        }
    }
    return $ret;
    */
}
開發者ID:firsteam,項目名稱:falcons,代碼行數:51,代碼來源:goods.php

示例3: empty

 $product['product_number'][$key] = empty($product['product_number'][$key]) ? empty($_CFG['use_storage']) ? 0 : $_CFG['default_storage'] : trim($product['product_number'][$key]);
 //庫存
 //獲取規格在商品屬性表中的id
 foreach ($product['attr'] as $attr_key => $attr_value) {
     /* 檢測:如果當前所添加的貨品規格存在空值或0 */
     if (empty($attr_value[$key])) {
         continue 2;
     }
     $is_spec_list[$attr_key] = 'true';
     $value_price_list[$attr_key] = $attr_value[$key] . chr(9) . '';
     //$key,當前
     $id_list[$attr_key] = $attr_key;
 }
 $goods_attr_id = handle_goods_attr($product['goods_id'], $id_list, $is_spec_list, $value_price_list);
 /* 是否為重複規格的貨品 */
 $goods_attr = sort_goods_attr_id_array($goods_attr_id);
 $goods_attr = implode('|', $goods_attr['sort']);
 if (check_goods_attr_exist($goods_attr, $product['goods_id'])) {
     continue;
     //sys_msg($_LANG['sys']['wrong'] . $_LANG['exist_same_goods_attr'], 1, array(), false);
 }
 //貨品號不為空
 if (!empty($value)) {
     /* 檢測:貨品貨號是否在商品表和貨品表中重複 */
     if (check_goods_sn_exist($value)) {
         continue;
         //sys_msg($_LANG['sys']['wrong'] . $_LANG['exist_same_goods_sn'], 1, array(), false);
     }
     if (check_product_sn_exist($value)) {
         continue;
         //sys_msg($_LANG['sys']['wrong'] . $_LANG['exist_same_product_sn'], 1, array(), false);
開發者ID:dlpc,項目名稱:ecshop,代碼行數:31,代碼來源:goods.php

示例4: get_goods_by_txm

/**
* 根據條形碼獲取對應商品信息
* @param array $info  條形碼數組信息
*/
function get_goods_by_txm($info)
{
    global $db, $ecs;
    $sql = "select bc.*,g.* from " . $ecs->table('bar_code') . " as bc left join " . $ecs->table('goods') . " as g on bc.goods_id=g.goods_id where bc.bar_code in(" . implode(',', $info) . ")";
    $ret = $db->query($sql);
    $goodsinfo = array();
    while ($row = $db->fetchRow($ret)) {
        $attr_info = get_goods_attr_txm($row['goods_id'], $row['taypes']);
        //獲取商品屬性信息
        if (empty($attr_info['info'])) {
            $goods_number = $row['goods_number'];
            $attr_ids = '';
            $row['goods_attr'] = $row['goods_attr_id'] = $row['goods_attr_price'] = '';
        } else {
            $attr_ids = array_keys($attr_info['info']);
            $attr_ids = sort_goods_attr_id_array($attr_ids);
            //商品屬性id排序
            $row['goods_attr_id'] = implode(',', $attr_ids['sort']);
            $row['goods_attr'] = $attr_info['info'];
            $row['goods_attr_price'] = is_array($attr_info['price']) ? array_sum($attr_info['price']) : 0;
            $goods_number = get_goods_nums_txm($row['goods_id'], $attr_ids['sort']);
            //貨品總數量
        }
        $goodsinfo[$row['bar_code']]['goods_id'] = $row['goods_id'];
        $goodsinfo[$row['bar_code']]['goods_name'] = $row['goods_name'];
        $goodsinfo[$row['bar_code']]['goods_sn'] = $row['goods_sn'];
        $goodsinfo[$row['bar_code']]['product_id'] = '';
        $goodsinfo[$row['bar_code']]['goods_name'] = $row['goods_name'];
        $goodsinfo[$row['bar_code']]['market_price'] = $row['market_price'] + $row['goods_attr_price'];
        $goodsinfo[$row['bar_code']]['goods_price'] = get_final_price($row['goods_id'], 1, true, $attr_ids['sort']);
        //最終結算價格
        $goodsinfo[$row['bar_code']]['goods_number'] = intval($goods_number);
        $goodsinfo[$row['bar_code']]['goods_attr'] = $row['goods_attr'];
        $goodsinfo[$row['bar_code']]['goods_attr_id'] = $row['goods_attr_id'];
        $goodsinfo[$row['bar_code']]['goods_attr_price'] = $row['goods_attr_price'];
        $goodsinfo[$row['bar_code']]['goods_thumb'] = $row['goods_thumb'];
        $goodsinfo[$row['bar_code']]['goods_img'] = $row['goods_img'];
    }
    return $goodsinfo;
}
開發者ID:seanguo166,項目名稱:yinoos,代碼行數:44,代碼來源:lib_goods.php

示例5: get_goods_attr_id

function get_goods_attr_id($goods_id, $attr_str)
{
    if (empty($attr_str)) {
        return '';
    } else {
        $attr_str = str_replace("\r", "", $attr_str);
        $attr_array = explode("\n", $attr_str);
        if (!is_array($attr_array)) {
            return '';
        }
        $attr_array = array_filter($attr_array);
        $return = "";
        foreach ($attr_array as $attr_temp) {
            $attr_temp = preg_replace("/\\[.+\\]/", "", $attr_temp);
            if ($attr_temp) {
                $attr_arr = explode(":", $attr_temp);
                $sql = "SELECT  a.attr_id  FROM " . $GLOBALS['ecs']->table('goods') . " AS g left join " . $GLOBALS['ecs']->table('attribute') . "  AS a on g.goods_type=a.cat_id WHERE g.goods_id='{$goods_id}' and a.attr_name='{$attr_arr['0']}' ";
                $attr_id = $GLOBALS['db']->getOne($sql);
                $sql = "SELECT goods_attr_id  FROM " . $GLOBALS['ecs']->table('goods_attr') . " WHERE goods_id='{$goods_id}' and attr_id='{$attr_id}' and attr_value='{$attr_arr['1']}' ";
                $goods_attr_id = $GLOBALS['db']->getOne($sql);
                $return .= $return ? "|" : "";
                $return .= $goods_attr_id;
            }
        }
        if ($return) {
            $goods_attr = explode("|", $return);
            $goods_attr = sort_goods_attr_id_array($goods_attr);
            $goods_attr = implode('|', $goods_attr['sort']);
            $return = $goods_attr;
        }
        return $return;
    }
}
開發者ID:moonlight-wang,項目名稱:feilun,代碼行數:33,代碼來源:lib_main.php

示例6: array

 $error = array();
 $sql = "select bc.*,g.* from " . $ecs->table('bar_code') . " as bc left join " . $ecs->table('goods') . " as g on bc.goods_id=g.goods_id where bc.bar_code in(" . implode(',', $bar_info) . ")";
 $ret = $db->query($sql);
 while ($row = $db->fetchRow($ret)) {
     $attr_info = get_goods_attr_txm($row['goods_id'], $row['taypes']);
     //獲取商品屬性信息
     if (empty($attr_info['info'])) {
         //沒有屬性直接增加庫存
         if ($row['goods_number'] < $_POST['number'][$row['bar_code']]) {
             $error[$row['bar_code']] = $_POST['number'][$row['bar_code']];
         } else {
             update_goods_store_num($row['goods_id'], 0 - $_POST['number'][$row['bar_code']]);
         }
     } else {
         $attr_ids = array_keys($attr_info['info']);
         $attr_ids = sort_goods_attr_id_array($attr_ids);
         //商品屬性id排序
         $product_info = get_product_info_by_goods($row['goods_id'], $attr_ids['sort']);
         if ($product_info) {
             if ($product_info['product_number'] < $_POST['number'][$row['bar_code']]) {
                 $error[$row['bar_code']] = $_POST['number'][$row['bar_code']];
             } else {
                 $product_id = $product_info['product_id'];
                 $num = 0 - $_POST['number'][$row['bar_code']];
                 $sql = "UPDATE " . $ecs->table('products') . " SET product_number = product_number+" . $num . " WHERE product_id = " . $product_id;
                 $db->query($sql);
                 update_goods_store_num($row['goods_id'], $num);
             }
         } else {
             $error[$row['bar_code']] = $_POST['number'][$row['bar_code']];
         }
開發者ID:seanguo166,項目名稱:yinoos,代碼行數:31,代碼來源:scan.php

示例7: get_goods_send_stock

/**
* 獲取當前商品對應的倉庫信息
*/
function get_goods_send_stock($goods_id, $attr = '')
{
    $attr = trim($attr);
    if (!empty($attr)) {
        $attr = str_replace('|', ',', $attr);
        $attrids = explode(',', $attr);
        $goods_attr_array = sort_goods_attr_id_array($attrids);
        $attr = implode("|", $goods_attr_array['sort']);
        $tj = "and sgs.goods_attr='" . $attr . "'";
    } else {
        $tj = "";
    }
    $sql = "select sm.* from " . $GLOBALS['ecs']->table('store_goods_stock') . " as sgs , " . $GLOBALS['ecs']->table('store_shipping_region') . " as ssr, \n\t\t\t" . $GLOBALS['ecs']->table('store_main') . " as sm\n\t\t\twhere sgs.goods_id=" . $goods_id . " " . $tj . " and sm.store_id = sgs.store_id \n\t\t\tand ssr.province=" . $_COOKIE["region_1"] . " and ssr.city=" . $_COOKIE["region_2"] . " and ssr.district=" . $_COOKIE["region_3"] . " and ssr.xiangcun=" . $_COOKIE["region_4"] . " and ssr.store_id=sm.parent_id";
    $row = $GLOBALS['db']->getRow($sql);
    return $row;
}
開發者ID:moonlight-wang,項目名稱:feilun,代碼行數:19,代碼來源:lib_stock.php

示例8: is_have_stock

/**
 * 獲取商品對應城市下是否有庫存
 * @param int $goodId  商品id
 * @param string $attrValue 商品屬性組合串
 * @return int $stock 商品庫存值
 */
function is_have_stock($goodId, $attrValue = '')
{
    global $db, $ecs;
    $where = " sgs.goods_id=" . intval($goodId);
    if (!empty($attrValue)) {
        if (!is_array($attrValue)) {
            $attrValue = str_replace('|', ',', $attrValue);
            $attrids = explode(',', $attrValue);
        } else {
            $attrids = $attrValue;
        }
        $goods_attr_array = sort_goods_attr_id_array($attrids);
        $attrValue = implode("|", $goods_attr_array['sort']);
        $where .= " AND sgs.goods_attr='" . $attrValue . "'";
    }
    $stock = 0;
    $address = cookie_to_str();
    $stockArray = get_address_by_store($address);
    if (is_array($stockArray)) {
        $sql = "SELECT sgs.store_number,sgs.store_id,sgs.goods_attr FROM " . $ecs->table('store_goods_stock') . " as sgs," . $ecs->table('store_main') . " as sm WHERE " . $where . "  and sm.parent_id in (" . implode(',', $stockArray) . ") and sgs.store_id = sm.store_id";
        $ret = $db->query($sql);
        if ($ret) {
            while ($row = $db->fetchRow($ret)) {
                if (!empty($attrValue) && $row['goods_attr'] == $attrValue && $row['store_number'] > 0) {
                    return $row['store_number'];
                }
                $stock = $stock > $row['store_number'] ? $stock : $row['store_number'];
            }
        }
    }
    return $stock;
}
開發者ID:moonlight-wang,項目名稱:feilun,代碼行數:38,代碼來源:lib_goods.php


注:本文中的sort_goods_attr_id_array函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。