• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP sort_goods_attr_id_array函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP sort_results函数代码示例发布时间:2022-05-23
下一篇:
PHP sort_flag函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap