123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace Product\Lib;
- use Dever;
- class Manage
- {
- public function check($id,$name,$data)
- {
- //Dever::alert('reload');
- }
- /**
- * 更新信息
- *
- * @return mixed
- */
- public function infoUpdate($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('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('product/category')->one(array('category_id' => $id));
- if (!$child) {
- $update['level'] = -1;
- }
- Dever::db('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('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('product/category_attr')->update($update);
- }
- }
- public function searchProduct_api()
- {
- $where = array();
- $cate = Dever::input('cate');
- if ($cate) {
- $where['cate_id'] = $cate;
- }
- $id = Dever::input('where_id');
- if ($id) {
- $where['id_no'] = $id;
- }
- $data = Dever::search('product/info', $where);
- if ($data) {
- $old = $data;
- $data = array();
- foreach ($old as $k => $v) {
- Dever::load('product/lib/sku')->getList($v, $data);
- }
- }
- return $data;
- }
- }
|