update($update); # 生成产品的链接 Dever::daemon('spider/handle.createProduct?id=' . $id, 'ku'); //Dever::load('ku/spider/handle.createProduct?id=' . $id); } public function showType($type, $set) { if ($set == 2) { return '自有商品'; } else { if ($type == 1) { return '有赞'; } elseif ($type == 2) { return '淘宝'; } elseif ($type == 3) { return '天猫'; } } return ''; } /** * 获取所有产品 * * @return mixed */ public function products($state = true) { $result = Dever::db('ku/cate')->state(); foreach ($result as $k => $v) { $result[$k]['child'] = Dever::db('ku/product')->state(array('cate' => $v['id'])); } $result['state'] = 1; return $result; } /** * 获取产品列表,用于后台联动搜索 * * @return mixed */ public function search_product_api() { $name = Dever::input('term'); $data = array(); if ($name) { $name = explode('|', $name); $search = array(); foreach ($name as $k => $v) { if ($v) { $search[] = 'name like("%'.$v.'%")'; } } $search = implode(' and ', $search); $sql = 'select *,name as value,name as label,cate,pic from jiazhi_ku_product where state = 1 and ' . $search; $data = Dever::db('ku/product')->fetchAll($sql); //print_r($data);die; //$data += Dever::db('ku/product')->search(array('name' => $name)); } /* if ($name) { $name = explode('|', $name); foreach ($name as $k => $v) { $data += Dever::db('ku/product')->search(array('name' => $v)); } } */ //Dever::debug($data); if ($data) { foreach ($data as $k => $v) { if (isset($v['cate']) && $v['cate'] > 0) { $cate = Dever::db('ku/cate')->one($v['cate']); $data[$k]['category'] = $cate['name']; } if(isset($v['pic']) && $v['pic']) { //$data[$k]['label'] = $data[$k]['value'] = '' . $data[$k]['value']; } } return $data; } return array ( 0 => array('id' => -1, 'value' => '没有找到您搜索的数据', 'label' => '没有找到您搜索的数据'), ); } /** * 获取产品列表,用于后台联动搜索 * * @return mixed */ public function search_product_by_ids($id) { $data = Dever::db('ku/product')->search($id); return $data; } /** * 获取产品列表,用于后台联动搜索 * * @return mixed */ public function search_product_list_api() { $name = trim(Dever::input('term')); $search_cate = Dever::input('cate'); $search_brand = Dever::input('brand'); $data = $cate = array(); $search = ''; if ($name) { $name = explode('|', $name); $search = array(); foreach ($name as $k => $v) { if ($v) { $search[] = 'name like("%'.$v.'%")'; } } $search = ' and ' . implode(' and ', $search); } if ($search_cate && $search_cate > 0) { $search .= ' and cate =' . $search_cate; } if ($search_brand && $search_brand > 0) { $search .= ' and brand =' . $search_brand; } $sql = 'select *,name as value,name as label,cate,pic from jiazhi_ku_product where state = 1 ' . $search; $data = Dever::db('ku/product')->fetchAll($sql); if ($data) { foreach ($data as $k => $v) { if (isset($v['cate']) && $v['cate'] > 0) { if (!isset($cate[$v['cate']])) { $info = Dever::db('ku/cate')->one($v['cate']); $cate[$v['cate']] = $info; } $cate[$v['cate']]['child'][] = $v; } } return $cate; } return array(); } public function search_cate_api() { $array = array ( -1 => '请选择分类' ); $info = Dever::db('ku/cate')->state(); if($info) { $array += $info; } return $array; } public function search_brand_api() { $array = array ( -1 => '请选择品牌' ); $info = Dever::db('ku/brand')->state(); if($info) { $array += $info; } return $array; } }