Example #1
0
/**
* 根据条形码获取对应商品信息
* @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;
}
Example #2
0
    }
}
/*------------------------------------------------------ */
//-- 商品出库操作
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'outstore') {
    admin_priv('goods_auto');
    if (!isset($_POST['number']) || count($_POST['number']) < 0) {
        sys_msg('没有要更新库存的数据!');
    }
    $bar_info = array_keys($_POST['number']);
    $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']]) {