$price = 0; $shop_price = 0; $lowest_price = 0; $promote_price = 0; } $data = array('name' => $name, 'shop_price' => $shop_price, 'price' => $price, 'lowest_price' => $lowest_price, 'img' => $img, 'desc' => $desc, 'detail' => $detail, 'category_id' => $category, 'promote_price' => $promote_price, 'promote_begin' => $promote_begin, 'promote_end' => $promote_end, 'order_view' => $order_view, 'status' => $product['status'] == 1 ? 1 : 2, 'prev_status' => $product['status'], 'integral' => $integral); $table = 'product'; $where = 'business_account = \'' . $_SESSION['business_account'] . '\' and id = \'' . $id . '\' and is_virtual = 1'; $order = ''; $limit = '1'; if ($db->autoUpdate($table, $data, $where, $order, $limit)) { //检查库存,如果存在无属性库存则更新库存 $check_inventory = 'select `id` from ' . $db->table('inventory') . ' where `product_sn`=\'' . $product_sn . '\' and `attributes`=\'\''; $inventory_id = $db->fetchOne($check_inventory); if ($inventory_id) { modify_inventory($product_sn, '', $inventory); } $links = array(array('link' => 'virtual_product.php', 'alt' => '虚拟产品列表'), array('link' => 'virtual_product.php?act=add', 'alt' => '添加虚拟产品')); show_system_message('修改产品成功', $links); exit; } else { show_system_message('系统繁忙,请稍后重试', array()); exit; } } if ('gallery' == $opera) { if (!check_purview('pur_virtual_product_edit', $_SESSION['business_purview'])) { show_system_message('权限不足', array()); exit; } $product_sn = trim(getPOST('sn'));
if (empty($product)) { echo json_encode(array('error' => 1, 'message' => '产品不存在')); exit; } $get_attribute = 'select * from ' . $db->table('inventory'); $get_attribute .= ' where id = ' . $id; $get_attribute .= ' and product_sn = \'' . $product_sn . '\' limit 1'; $attribute = $db->fetchRow($get_attribute); $data = array('attributes' => $attr, 'inventory' => $inventory, 'inventory_logic' => $inventory); $table = 'inventory'; $where = 'id = ' . $id; if (empty($attribute)) { echo json_encode(array('error' => 1, 'message' => '产品属性不存在')); exit; } else { if (modify_inventory($product_sn, $attribute['attributes'], $inventory)) { echo json_encode(array('error' => 0, 'message' => '产品属性更新成功')); exit; } else { echo json_encode(array('error' => 1, 'message' => '系统繁忙,请稍后重试')); exit; } } } //增加产品属性 if ('add_attr' == $opera) { $product_sn = trim(getPOST('sn')); $attr = trim(getPOST('attr')); $inventory = intval(getPOST('inventory')); if ('' == $product_sn) { echo json_encode(array('error' => 1, 'message' => '参数错误'));