add($data); return $this->success($brand_id); } /** * 修改品牌 * @param $data * @param $condition * @return array */ public function editBrand($data, $condition) { $res = model('goods_brand')->update($data, $condition); return $this->success($res); } /** * 删除品牌 * @param array $condition */ public function deleteBrand($condition) { $res = model('goods_brand')->delete($condition); return $this->success($res); } /** * 修改排序 * @param int $sort * @param int $brand_id */ public function modifyBrandSort($sort, $condition) { $res = model('goods_brand')->update([ 'sort' => $sort ], $condition); return $this->success($res); } /** * 获取品牌信息 * @param array $condition * @param string $field */ public function getBrandInfo($condition, $field = 'brand_id, brand_name, brand_initial, image_url, sort, create_time, is_recommend') { $res = model('goods_brand')->getInfo($condition, $field); return $this->success($res); } /** * 获取品牌列表 * @param array $condition * @param string $field * @param string $order * @param string $limit */ public function getBrandList($condition = [], $field = 'brand_id, brand_name, brand_initial, image_url, sort, create_time', $order = '', $limit = null) { $list = model('goods_brand')->getList($condition, $field, $order, '', '', '', $limit); return $this->success($list); } /** * 获取品牌分页列表 * @param array $condition * @param number $page * @param string $page_size * @param string $order * @param string $field */ public function getBrandPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'ngb.create_time desc', $field = 'ngb.brand_id,ngb.brand_name,ngb.brand_initial,ngb.image_url,ngb.sort,ngb.create_time,ngb.is_recommend,ngb.site_id,ns.site_name,nsp.title as supply_name') { $list = model('goods_brand')->pageList($condition, $field, $order, $page, $page_size, '', ''); return $this->success($list); } public function copyBrand($id, $site_id, $site_agent_id){ $condition = []; $condition[] = [ 'site_id', '=', $site_agent_id ]; $condition[] = [ 'brand_id', '=', $id ]; $info = self::getBrandInfo($condition)['data']; if($info){ $add = [ 'brand_name' => $info['brand_name'], 'brand_initial' => $info['brand_initial'], 'image_url' => $info['image_url'], 'site_id' => $site_id, 'is_recommend' => $info['is_recommend'], 'sort' => $info['sort'], 'create_time' => time() ]; $new_id = model('goods_brand')->add($add); return $this->success($new_id,'复制成功'); }else{ return $this->error('', '数据信息错误'); } } }