make_json_error($_LANG['sys']['wrong'] . $_LANG['cannot_found_goods']); } else { $goods_id = intval($_REQUEST['goods_id']); } /* 取出商品信息 */ $sql = "SELECT goods_sn, goods_name, goods_type, shop_price FROM " . $ecs->table('goods') . " WHERE goods_id = '{$goods_id}'"; $goods = $db->getRow($sql); if (empty($goods)) { make_json_error($_LANG['sys']['wrong'] . $_LANG['cannot_found_goods']); } $smarty->assign('sn', sprintf($_LANG['good_goods_sn'], $goods['goods_sn'])); $smarty->assign('price', sprintf($_LANG['good_shop_price'], $goods['shop_price'])); $smarty->assign('goods_name', sprintf($_LANG['products_title'], $goods['goods_name'])); $smarty->assign('goods_sn', sprintf($_LANG['products_title_2'], $goods['goods_sn'])); /* 获取商品规格列表 */ $attribute = get_goods_specifications_list($goods_id); if (empty($attribute)) { make_json_error($_LANG['sys']['wrong'] . $_LANG['cannot_found_goods']); } foreach ($attribute as $attribute_value) { //转换成数组 $_attribute[$attribute_value['attr_id']]['attr_values'][] = $attribute_value['attr_value']; $_attribute[$attribute_value['attr_id']]['attr_id'] = $attribute_value['attr_id']; $_attribute[$attribute_value['attr_id']]['attr_name'] = $attribute_value['attr_name']; } $attribute_count = count($_attribute); $smarty->assign('attribute_count', $attribute_count); $smarty->assign('attribute', $_attribute); $smarty->assign('attribute_count_3', $attribute_count + 3); $smarty->assign('product_sn', $goods['goods_sn'] . '_'); $smarty->assign('product_number', $_CFG['default_storage']);
} else { /* 商品信息 */ $sql = 'SELECT * FROM ' . $ecs->table('goods') . " WHERE goods_id = '{$_REQUEST['goods_id']}'"; $goods = $db->getRow($sql); /* 虚拟卡商品复制时, 将其库存置为0*/ if ($is_copy && $code != '') { $goods['goods_number'] = 0; } if (empty($goods) === true) { /* 默认值 */ $goods = array('goods_id' => 0, 'goods_desc' => '', 'cat_id' => 0, 'is_on_sale' => '1', 'is_alone_sale' => '1', 'is_shipping' => '0', 'other_cat' => array(), 'goods_type' => 0, 'shop_price' => 0, 'promote_price' => 0, 'market_price' => 0, 'integral' => 0, 'goods_number' => 1, 'warn_number' => 1, 'promote_start_date' => local_date('Y-m-d'), 'goods_weight' => 0, 'give_integral' => -1, 'rank_integral' => -1, 'shelflife' => 24, 'per_number' => 100, 'every_num' => 3, 'everyday_use' => 3, 'per_number_units' => '粒', 'every_num_units' => '粒'); } /* 获取商品类型存在规格的类型 */ $specifications = get_goods_type_specifications(); $goods['specifications_id'] = $specifications[$goods['goods_type']]; $_attribute = get_goods_specifications_list($goods['goods_id']); $goods['_attribute'] = empty($_attribute) ? '' : 1; /* 根据商品重量的单位重新计算 */ if ($goods['goods_weight'] > 0) { $goods['goods_weight_by_unit'] = $goods['goods_weight'] >= 1 ? $goods['goods_weight'] : $goods['goods_weight'] / 0.001; } if (!empty($goods['goods_brief'])) { $goods['goods_brief'] = trim_right($goods['goods_brief']); $goods['goods_brief'] = $goods['goods_brief']; } if (!empty($goods['keywords'])) { $goods['keywords'] = trim_right($goods['keywords']); $goods['keywords'] = $goods['keywords']; } /* 如果不是促销,处理促销日期 */ if (isset($goods['is_promote']) && $goods['is_promote'] == '0') {