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 = ''; $table .= ''; $table .= ''; foreach ($data as $k => $v) { $table .= ''; } $table .= ''; $table .= '
ID 名称 名称 规格
'.$v['id'].' '.$v['name'].' '.$v['sname'].' '.$v['spec'].'
'; $result['list'] = $data; //$result['table'] = $table; $result['table_config'] = array('width' => $width); return $result; } public function getGoods($id, $table = 'scm_servicer/in_order_goods', $cash = true) { $result = array(); $result['head'] = array('名称', '批次', '单价', '数量', '状态'); if (!$cash) { unset($result['head'][1]); } $result['body'] = array(); $data = Dever::db($table)->select(array('order_id' => $id)); if ($data) { $status = Dever::db($table)->config['status']; foreach ($data as $k => $v) { $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($v['goods_id'], $v['sku_id']); $status_name = Dever::status($status, $v['status']); $unit = Dever::db('scm/unit')->one($v['unit_id']); $result['body'][$k][] = $goods_info['aname']; if (isset($v['batch'])) { $result['body'][$k][] = $v['batch']; } else { unset($result['head'][1]); } $result['body'][$k][] = $v['cash']; $result['body'][$k][] = $v['num'] . $unit['name']; $result['body'][$k][] = $status_name; if (!$cash) { unset($result['body'][$k][1]); } } } $body[''] = array ( 'type' => 'table', 'content' => $result, ); if ($result['body']) { return Dever::show('', $body); } else { return '暂无'; } } public function searchRole_api() { $in_type = Dever::input('in_type'); $service_id = Dever::input('service_id'); $servicer_store_id = Dever::input('servicer_store_id'); if ($in_type == 2) { # 生成仓库入库单 } } # 根据商品获取信息,后台入库出库单使用 public function showInfo_api() { $goods = Dever::input('value'); $cash_col = Dever::input('cash_col', 'cost_price'); list($goods_id, $sku_id) = explode('-', $goods); $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id); $option = array(); $result = array(); $result['goods_id'] = '暂无'; $result['unit_id'] = 1; $result['cash'] = '0.00'; if ($goods_info) { $result['cash'] = $goods_info[$cash_col]; $string = ''; $table = Dever::input('table'); $unit_id = false; if ($table != 'out_order') { # 出库不需要 $unit_id = -1; } $data = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit_id, Dever::input('cash_col')); if ($data) { $result['cash'] = $data['cash']; $result['goods_id'] = $data['num'] . $goods_info['unit'] . $string; } $result['unit_id'] = $goods_info['unit_id']; if ($result['unit_id']) { $unit = Dever::db('scm_product/info_unit')->select(array('info_id' => $goods_info['id'])); $option['unit_id'] = ''; $unit_info = Dever::db('scm/unit')->find($result['unit_id']); $option['unit_id'] .= ''; if ($unit) { foreach ($unit as $k => $v) { $unit_info = Dever::db('scm/unit')->find($v['unit_id']); $option['unit_id'] .= ''; } } } $result['cash'] = Dever::number($result['cash']); $result['num'] = '1.00'; } return array('data' => $result, 'html' => '', 'option' => $option); } # 根据单位获取价格 public function showPriceByUnit_api() { $unit = Dever::input('value'); $goods = Dever::input('goods'); $temp = explode('-', $goods); $goods_id = $temp[0]; $sku_id = $temp[1]; $data = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit, Dever::input('cash_col')); if ($data && $data['num'] > 0) { $unit = Dever::db('scm/unit')->one($unit); $data['goods_id'] = $data['num'] . $unit['name']; } unset($data['num']); return array('data' => $data, 'html' => ''); } }