diff --git a/admin/controllers/auto/Cars.php b/admin/controllers/auto/Cars.php index de433ef3..737142c6 100644 --- a/admin/controllers/auto/Cars.php +++ b/admin/controllers/auto/Cars.php @@ -68,10 +68,10 @@ class Cars extends HD_Controller{ $attr_ids = array(); foreach($rows as $v){ !in_array($v['s_id'], $s_ids) && $s_ids[] = $v['s_id']; - $ids = explode('_', $v['attrs']); - $attr_ids = array_merge($attr_ids, $ids); + $v['v_id'] && !in_array($v['v_id'], $attr_ids) && $attr_ids[] = $v['v_id']; + $v['cor_id'] && !in_array($v['cor_id'], $attr_ids) && $attr_ids[] = $v['cor_id']; + $v['incor_id'] && !in_array($v['incor_id'], $attr_ids) && $attr_ids[] = $v['incor_id']; } - $attr_ids = array_unique($attr_ids); //获取车系列表 $map_sery = array(); if($s_ids){ @@ -83,18 +83,12 @@ class Cars extends HD_Controller{ if($attr_ids){ $str_ids = implode(',', $attr_ids); $where_attr = array("id in ({$str_ids})" => null); - $map_attr = $this->auto_attr_model->map('id', '*', $where_attr, 'id desc', 0 , 0, 'id, title, type'); + $map_attr = $this->auto_attr_model->map('id', 'title', $where_attr, 'id desc', 0 , 0, 'id, title, type'); } //属性按'车型-车身颜色-内饰颜色'排序 foreach($rows as $v){ - $attr_ids = explode('_', $v['attrs']); - $arr = array(); - foreach($attr_ids as $attr_id){ - $attr = $map_attr[$attr_id]; - $arr[$attr['type']] =$attr['title']; - } - $attr_title = "{$arr[1]}-{$arr[0]}-内饰{$arr[2]}"; + $attr_title = "{$map_attr[$v['v_id']]}-{$map_attr[$v['cor_id']]}-内饰{$map_attr[$v['incor_id']]}"; $title = "{$map_brand[$v['brand_id']]} {$map_sery[$v['s_id']]} {$attr_title}"; $lists[] = array( 'id' => $v['id'], @@ -136,11 +130,14 @@ class Cars extends HD_Controller{ $row = $this->auto_cars_model->get(array('id' => $id)); //获取属性列表 - $attr_ids = explode('_', $row['attrs']); + $attr_ids = array(); + $row['v_id'] && $attr_ids[] = $row['v_id']; + $row['cor_id'] && $attr_ids[] = $row['cor_id']; + $row['incor_id'] && $attr_ids[] = $row['incor_id']; $str_ids = implode(',', $attr_ids); $where_attr = array("id in ({$str_ids})" => null); - $map_attr = $this->auto_attr_model->map('type', 'title', $where_attr, 'id desc', 0 , 0, 'type, title'); - $attr = "{$map_attr[1]}-{$map_attr[0]}-{$map_attr[2]}(内饰)"; + $map_attr = $this->auto_attr_model->map('id', 'title', $where_attr, 'id desc', 0 , 0, 'id, title'); + $attr = "{$map_attr[$row['v_id']]}-{$map_attr[$row['cor_id']]}-{$map_attr[$row['incor_id']]}(内饰)"; //车系 $row_sery = $this->auto_series_model->get(array('id' => $row['s_id'])); @@ -191,30 +188,45 @@ class Cars extends HD_Controller{ if(!$count){ return $this->show_json(SYS_CODE_FAIL, '该车系暂无属性!'); } - $attrs = array_column($map[0], 'id');//属性组合 - for($i=1; $i<$count; $i++){ + $attrs = array();//属性组合 0车身颜色,1车型,2内饰颜色 + foreach($map as $i => $arr){ $arr1 = $attrs; - $arr2 = $map[$i]; $attrs = array(); - foreach($arr1 as $k1 => $v1){ - foreach($arr2 as $k2 => $v2){ - $attrs[] = "{$v1}_{$v2['id']}"; + foreach($arr as $v){ + if($arr1){ + foreach($arr1 as $v1){ + $v1[$i] = $v['id']; + $attrs[] = $v1; + } + } else { + $attrs[] = array($i => $v['id']); } } } //车型库现有数据 $where = array('s_id' => $s_id); - $map_cars = $this->auto_cars_model->map('attrs', '*', $where); + $rows_car = $this->auto_cars_model->select($where, 'id desc', 0, 0, 'id, v_id, cor_id, incor_id'); + $map_cars = array(); + foreach($rows_car as $v){ + $k = "{$v['cor_id']}_{$v['v_id']}_{$v['incor_id']}"; + $map_cars[$k] = $v; + } $adds = array(); foreach($attrs as $attr){ - if($map_cars[$attr]){ - $map_cars[$attr]['ok'] = 1;//保留 + $cor_id = $attr[0] ? $attr[0] : 0;//0-车身颜色 + $v_id = $attr[1] ? $attr[1] : 0;//1-车型 + $incor_id = $attr[2] ? $attr[2] : 0;//2-内饰颜色 + $k = "{$cor_id}_{$v_id}_{$incor_id}"; + if($map_cars[$k]){ + $map_cars[$k]['ok'] = 1;//保留 } else { $adds[] = array( 'brand_id' => $brand_id, 's_id' => $s_id, - 'attrs' => $attr, + 'v_id' => $v_id, + 'cor_id' => $cor_id, + 'incor_id' => $incor_id, 'status' => 1, 'c_time' => time() ); @@ -323,13 +335,17 @@ class Cars extends HD_Controller{ function json_get(){ $brand_id = $this->input->post('brand_id'); $s_id = $this->input->post('s_id'); - $attrs = $this->input->post('attrs'); + $v_id = $this->input->post('v_id'); + $cor_id = $this->input->post('cor_id'); + $incor_id = $this->input->post('incor_id'); $where = array( 'status' => 1, 'brand_id' => $brand_id, 's_id' => $s_id, - 'attrs' => $attrs + 'v_id' => $v_id, + 'cor_id' => $cor_id, + 'incor_id' => $incor_id, ); $row = $this->auto_cars_model->get($where); @@ -343,4 +359,32 @@ class Cars extends HD_Controller{ return $this->show_json(SYS_CODE_SUCCESS); } + /** + * 旧数据attrs转存新字段 + */ + function json_transfer(){ + $where = array('v_id' => 0, 'cor_id' => 0, 'incor_id' => 0); + $total = $this->auto_cars_model->count($where); + $rows = $this->auto_cars_model->select($where, 'id asc', 1, 100, 'id, attrs'); + $count = count($rows); + $done = 0; + foreach($rows as $v){ + $attr_ids = str_replace('_', ',', $v['attrs']); + if($attr_ids){ + $where = array("id in({$attr_ids})" => null); + $map_attr = $this->auto_attr_model->map('type', 'id', $where, 'id desc', 0, 0, 'id, type'); + $upd = array(); + $map_attr[0] && $upd['cor_id'] = $map_attr[0]; + $map_attr[1] && $upd['v_id'] = $map_attr[1]; + $map_attr[2] && $upd['incor_id'] = $map_attr[2]; + if($upd){ + $ret = $this->auto_cars_model->update($upd, array('id' => $v['id'])); + $ret && $done++; + } + } + } + + exit("total:{$total}; count:{$count}; done:{$done};"); + } + } \ No newline at end of file diff --git a/admin/controllers/receiver/order/Sign.php b/admin/controllers/receiver/order/Sign.php index 1e51611d..42b63941 100644 --- a/admin/controllers/receiver/order/Sign.php +++ b/admin/controllers/receiver/order/Sign.php @@ -34,7 +34,10 @@ class Sign extends HD_Controller{ "$t2.id>" => 0, ]; - strlen($params['status']) && $where["$t1.status"] = $params['status']; + if(!strlen($params['status'])){ + $params['status'] = 2;//默认展示预付的 + } + $where["$t1.status"] = $params['status']; if ($params['title']) { $where["{$t2}.{$params['search_tp']} like '%{$params['title']}%'"] = null; diff --git a/admin/views/items/goods/edit.php b/admin/views/items/goods/edit.php index ca66beec..64b49205 100644 --- a/admin/views/items/goods/edit.php +++ b/admin/views/items/goods/edit.php @@ -462,7 +462,6 @@ return; } if(vm.info.v_id > 0 && vm.info.cor_id>0 && vm.info.incor_id>0){ - var attrs = vm.info.cor_id+'_'+ vm.info.v_id + '_' + vm.info.incor_id; $.ajax({ url: '/auto/cars/json_get', type: 'post', @@ -470,7 +469,9 @@ data: { brand_id: vm.info.brand_id, s_id: vm.info.s_id, - attrs: attrs + v_id: vm.info.v_id, + cor_id:vm.info.cor_id, + incor_id:vm.info.incor_id }, success: function (res) { if (res.data) { diff --git a/admin/views/receiver/order/sign/lists.php b/admin/views/receiver/order/sign/lists.php index 7dec12c0..29963988 100644 --- a/admin/views/receiver/order/sign/lists.php +++ b/admin/views/receiver/order/sign/lists.php @@ -1,9 +1,6 @@