find($id); if ($value != $data['source_type']) { $data['source_id'] = -1; } } $config['source_id'] = Dever::db('scm_product/info')->config['struct']['source_id']; $config['source_id']['update'] = 'select'; $config['source_id']['update_search'] = 'scm/lib/role.search?source_type=' . $value; $result = Dever::load('manage/database')->update_struct(array('struct' => $config), false, $data, -1, '', true); return $result; } /** * 更新信息 * * @return mixed */ public function updateInfo($id, $name, $data) { # 更新分类id $category = Dever::param('category', $data); if ($category) { if (is_array($category)) { $category_id = end($category); $top_category_id = $category[0]; if (isset($category[1])) { $second_category_id = $category[1]; } else { $second_category_id = $category[0]; } } else { $category_id = $category; $top_category_id = $category; $second_category_id = $category; } $update['top_category_id'] = $top_category_id; $update['second_category_id'] = $second_category_id; $update['category_id'] = $category_id; } if (isset($update)) { $update['where_id'] = $id; Dever::db('scm_product/info')->update($update); } } public function updateCategory($id, $name, $data) { $info = Dever::param('category', $data); if ($info && $info != -1) { $update['top_category_id'] = $info[0]; $num = count($info)+1; $update['level'] = $num; $parent = Dever::param('category_id', $data); $child = Dever::db('scm_product/category')->one(array('category_id' => $id)); if (!$child) { $update['level'] = -1; } Dever::db('scm_product/category')->update(array('where_id' => $parent, 'level' => $num - 1)); } else { $update['level'] = 1; $update['top_category_id'] = -1; } if (isset($update)) { $update['where_id'] = $id; Dever::db('scm_product/category')->update($update); } } /** * 更新属性信息 * * @return mixed */ public function updateAttr($id, $name, $data) { return; $is_sell = Dever::param('is_sell', $data); if ($is_sell > 1) { $update['type'] = 11; } if (isset($update)) { $update['where_id'] = $id; Dever::db('scm_product/category_attr')->update($update); } } public function searchProduct_api() { $id = Dever::input('id'); $keyword = Dever::input('keyword'); $where = array(); if ($keyword) { $where['name'] = $keyword; } $data = array(); $cate = ''; $supplier_id = Dever::input('supplier_id'); if ($supplier_id) { $where['supplier_id'] = $supplier_id; $data = Dever::search('scm_supplier/goods', $where); if (!$data) { $supplier = Dever::db('scm_supplier/info')->find($supplier_id); if ($supplier && $supplier['category']) { $cate = $supplier['category']; } } } $seller_id = Dever::input('seller_id'); if ($seller_id) { $where['seller_id'] = $seller_id; $data = Dever::search('scm_seller/goods', $where); if (!$data) { $seller = Dever::db('scm_seller/info')->find($seller_id); if ($seller && $seller['category']) { $cate = $seller['category']; } } } $service_id = Dever::input('service_id'); $servicer_store_id = Dever::input('servicer_store_id'); if ($servicer_store_id) { $where['servicer_store_id'] = $servicer_store_id; $data = Dever::search('scm_servicer/store_goods', $where); } if (!$data) { $id = Dever::input('where_id'); if ($id) { $where['id_no'] = $id; } if ($cate) { $where['cate'] = $cate; } $data = Dever::search('scm_product/info', $where); } if ($data) { $old = $data; $data = array(); foreach ($old as $k => $v) { Dever::load('scm_product/lib/sku')->getList($v, $data); } } $width = '600'; $table = '
ID | 名称 | 名称 | 规格 |
---|---|---|---|
'.$v['id'].' | '.$v['name'].' | '.$v['sname'].' | '.$v['spec'].' |