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) { $supplier_goods = Dever::db('scm_supplier/goods')->one(array('supplier_id' => $supplier_id)); if ($supplier_goods) { $where['supplier_id'] = $supplier_id; $data = Dever::search('scm_supplier/goods_sku', $where); } else { $supplier = Dever::db('scm_supplier/info')->find($supplier_id); if ($supplier && $supplier['category']) { $cate = $supplier['category']; } } } $service_id = Dever::input('service_id'); $servicer_store_id = Dever::input('servicer_store_id'); if ($servicer_store_id) { $store_goods = Dever::db('scm_servicer/store_goods')->one(array('servicer_store_id' => $servicer_store_id)); if ($store_goods) { $where['servicer_store_id'] = $servicer_store_id; $data = Dever::search('scm_servicer/store_goods_sku', $where); } else { # 没有库存 return array(); } } 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']; $result['body'][$k][] = $v['batch']; $result['body'][$k][] = $unit['name']; $result['body'][$k][] = $v['cash']; $result['body'][$k][] = $v['num']; $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'); 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) { $where['goods_id'] = $goods_id; $where['sku_id'] = $sku_id; $info = array(); # 仓库 $servicer_store_id = Dever::input('servicer_store_id'); if ($servicer_store_id) { $where['servicer_store_id'] = $servicer_store_id; $info = Dever::db('scm_servicer/store_goods_sku')->getOne($where); } # 获取供应商供货价 $supplier_id = Dever::input('supplier_id'); if ($supplier_id) { $where['supplier_id'] = $supplier_id; $sku = Dever::db('scm_supplier/goods_sku')->getOne($where); } $result['cash'] = isset($sku['cost_price']) && $sku['cost_price'] ? $sku['cost_price'] : $goods_info['cost_price']; if ($info) { $result['goods_id'] = $info['total'] . $goods_info['unit']; } $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'] .= ''; } } } } return array('data' => $result, 'html' => '', 'option' => $option); } # 根据单位获取价格 public function showPriceByUnit_api() { $unit = Dever::input('value'); $goods = Dever::input('goods'); list($goods_id, $sku_id) = explode('-', $goods); return array('data' => Dever::load('scm/lib/price')->getByUnit($goods_id, $sku_id, $unit, 1, 'cost_price', Dever::input('supplier_id')), 'html' => ''); } }