diff --git a/admin/controllers/auto/Attr.php b/admin/controllers/auto/Attr.php index c736a771..45852603 100644 --- a/admin/controllers/auto/Attr.php +++ b/admin/controllers/auto/Attr.php @@ -160,4 +160,45 @@ class Attr extends HD_Controller{ } + /** + * 属性选项列表 + * @return bool + */ + function json_lists(){ + $s_id = $this->input->post('s_id'); + $status = $this->input->post('status'); + $type = $this->input->post('type'); + $page = $this->input->post('page'); + $size = $this->input->post('size'); + + $where = array(); + $s_id && $where['s_id'] = $s_id; + strlen($type) > 0 && $where['type'] = $type; + if(strlen($status) > 0){ + $where['status'] = $status; + } else { + $where['status>-1'] = null; + } + + $total = $this->auto_attr_model->count($where); + + + $lists = array(); + if($total){ + $orderby = 'id desc'; + $select = 'id, title'; + $rows = $this->auto_attr_model->select($where, $orderby, $page, $size, $select); + + foreach($rows as $v){ + $lists[] = array( + 'id' => $v['id'], + 'title' => $v['title'], + ); + } + } + + $this->data = array('total' => $total, 'list' => $lists); + return $this->show_json(SYS_CODE_SUCCESS); + } + } diff --git a/admin/controllers/auto/Brand.php b/admin/controllers/auto/Brand.php index 25d99db0..91d4f3a0 100644 --- a/admin/controllers/auto/Brand.php +++ b/admin/controllers/auto/Brand.php @@ -172,7 +172,7 @@ class Brand extends HD_Controller{ } $this->data = array('total' => $total, 'list' => $lists); - return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); + return $this->show_json(SYS_CODE_SUCCESS); } } diff --git a/admin/controllers/items/goods/Goods.php b/admin/controllers/items/goods/Goods.php index e6825ae3..887a80e0 100644 --- a/admin/controllers/items/goods/Goods.php +++ b/admin/controllers/items/goods/Goods.php @@ -43,6 +43,13 @@ class Goods extends HD_Controller if ($params['v_id']) { $where['v_id'] = $params['v_id']; } + //车身颜色 + if ($params['cor_id']) { + $where['cor_id'] = $params['cor_id']; + } else { + $params['cor_id'] = ''; + } + if($params['addr_id']){ $where['addr_id'] = $params['addr_id']; } else if($params['city_id']){ @@ -73,16 +80,25 @@ class Goods extends HD_Controller if($params['vin']){ $where["vin like '%{$params['vin']}%'"] = null; } + //精品筛选 + if($params['fine_ids']){ + $fine_count = substr_count($params['fine_ids'], ',') + 1; + $sql = "select item_id from lc_items_relate where type=1 and status=1 and type_id in ({$params['fine_ids']}) group by item_id having count(item_id)={$fine_count}"; + $where["id in ($sql)"] = null; + } $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); $count = $this->mdItems->count($where); $lists = array(); + $fine_ids = array(); if ($count) { - $fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,p_time,addr_id'; + $fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,in_time,addr_id'; $rows = $this->mdItems->select($where, 'id desc', $page, $size, $fileds); $brand_id_arr = array(); $addr_ids = array(); + $ids = array(); foreach($rows as $v){ + $ids[] = $v['id']; !in_array($v['brand_id'], $brand_id_arr) && $brand_id_arr[] = $v['brand_id']; $v['addr_id'] && !in_array($v['addr_id'], $addr_ids) && $addr_ids[] = $v['addr_id']; } @@ -95,6 +111,7 @@ class Goods extends HD_Controller $attr_corid_rows = $this->mdAutoAttr->get_map_by_ids($attr_corid_arr, 'id,title'); $attr_incorid_arr = array_unique(array_column($rows, 'incor_id')); $attr_incorid_rows = $this->mdAutoAttr->get_map_by_ids($attr_incorid_arr, 'id,title'); + //获取存放地址 $map_addr = array(); if($addr_ids){ $str_ids = implode(',', $addr_ids); @@ -103,11 +120,17 @@ class Goods extends HD_Controller $select = 'id, title'; $map_addr = $this->addr_model->map('id', 'title', $where, $orderby, 0, 0, $select); } + //获取精品加装 + $str_ids = implode(',', $ids); + $where = array("item_id in ({$str_ids})" => null, 'type' => 1, 'status' => 1); + $rows_fine = $this->items_relate_model->select($where, '', 0, 0, 'item_id, type_id'); + $map_fine = array(); + foreach($rows_fine as $v){ + !in_array($v['type_id'], $fine_ids) && $fine_ids[] = $v['type_id']; + $map_fine[$v['item_id']][] = $v['type_id']; + } + foreach ($rows as $key => $val) { - $p_days = ''; - if('0000-00-00 00:00:00' != $val['p_time']){ - $p_days = intval((time() - strtotime($val['p_time']))/3600/24); - } $setVal = array(); $setVal['id'] = $val['id']; $setVal['brand_name'] = isset($brands_rows[$val['brand_id']]) ? $brands_rows[$val['brand_id']][0]['name'] : ''; @@ -117,12 +140,13 @@ class Goods extends HD_Controller $setVal['incor_name'] = isset($attr_incorid_rows[$val['incor_id']]) ? $attr_incorid_rows[$val['incor_id']][0]['title'] : ''; $setVal['vin'] = $val['vin']; $setVal['address'] = $val['addr_id'] ? $map_addr[$val['addr_id']] : ''; - $setVal['p_time'] = '0000-00-00 00:00:00' == $val['p_time'] ? '' : $val['p_time']; - $setVal['p_days'] = $p_days; + $setVal['in_time'] = '0000-00-00 00:00:00' == $val['in_time'] ? '' : $val['in_time']; + $setVal['fine_ids'] = $map_fine[$val['id']] ? $map_fine[$val['id']] : array(); $lists[] = $setVal; } } $this->data['lists'] = $lists; + $this->data['fine_ids'] = $fine_ids; $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); $this->data['params'] = $params; $this->data['autoList'] = $autoList; @@ -146,7 +170,7 @@ class Goods extends HD_Controller } $info = $re; $info['pro_time'] = $re['pro_time'] != '0000-00-00 00:00:00' ? $re['pro_time'] : ''; - $info['p_time'] = $re['p_time'] != '0000-00-00 00:00:00' ? $re['p_time'] : ''; + $info['in_time'] = $re['in_time'] != '0000-00-00 00:00:00' ? $re['in_time'] : ''; $info['out_time'] = $re['out_time'] != '0000-00-00 00:00:00' ? $re['out_time'] : ''; $info['bill_time'] = $re['bill_time'] != '0000-00-00 00:00:00' ? $re['bill_time'] : ''; if ($re['brand_id']) { @@ -181,6 +205,7 @@ class Goods extends HD_Controller $info['county_id'] = ''; $info['addr_id'] = ''; $info['fine_ids'] = array(); + $info['in_time'] = date('Y-m-d H:i:s'); $_title = '新增商品'; $edit_url = '/items/goods/goods/add'; } @@ -223,7 +248,7 @@ class Goods extends HD_Controller $info['buy_price'] = $re['buy_price'] . '元'; $info['discount'] = $re['discount'] ? $re['discount'] . '%' : '100%'; $info['pro_time'] = $re['pro_time'] != '0000-00-00 00:00:00' ? $re['pro_time'] : ''; - $info['p_time'] = $re['p_time'] != '0000-00-00 00:00:00' ? $re['p_time'] : ''; + $info['in_time'] = $re['in_time'] != '0000-00-00 00:00:00' ? $re['in_time'] : ''; $info['out_time'] = $re['out_time'] != '0000-00-00 00:00:00' ? $re['out_time'] : ''; $info['bill_time'] = $re['bill_time'] != '0000-00-00 00:00:00' ? $re['bill_time'] : ''; if($info['addr_id']){ @@ -267,6 +292,16 @@ class Goods extends HD_Controller if (!$checkInfo['code']) { return $this->show_json($checkInfo['code'], $checkInfo['msg']); } + + if($info['vin']){ + //车架号不重复 + $where = array('vin' => $info['vin']); + $count = $this->mdItems->count($where); + if($count>0){ + return $this->show_json(SYS_CODE_FAIL, 'vin码已存在'); + } + } + $addData['brand_id'] = $info['brand_id']; $addData['s_id'] = $info['s_id']; $addData['v_id'] = $info['v_id']; @@ -287,7 +322,7 @@ class Goods extends HD_Controller $addData['buy_price'] = $info['buy_price'] ? $info['buy_price'] : 0.00; $addData['pro_time'] = $info['pro_time'] ? $info['pro_time'] : '0000-00-00 00:00:00'; - $addData['p_time'] = $info['p_time'] ? $info['p_time'] : '0000-00-00 00:00:00'; + $addData['in_time'] = $info['in_time'] ? $info['in_time'] : date('Y-m-d H:i:s'); $addData['out_time'] = $info['out_time'] ? $info['out_time'] : '0000-00-00 00:00:00'; $addData['bill_time'] = $info['bill_time'] ? $info['bill_time'] : '0000-00-00 00:00:00'; $addData['c_time'] = time(); @@ -371,6 +406,7 @@ class Goods extends HD_Controller 'cor_id' => $cor_id, 'incor_id' => $incor_id, 'vin' => $vin ? $vin : '', + 'in_time' => date('Y-m-d H:i:s'), 'c_time' => time() ); $id = $this->mdItems->add($addData); @@ -391,6 +427,16 @@ class Goods extends HD_Controller if (!$checkInfo['code']) { return $this->show_json($checkInfo['code'], $checkInfo['msg']); } + + if($info['vin']){ + //车架号不重复 + $where = array('vin' => $info['vin'], "id<>{$info['id']}" => null); + $count = $this->mdItems->count($where); + if($count>0){ + return $this->show_json(SYS_CODE_FAIL, 'vin码已存在'); + } + } + $editData['brand_id'] = $info['brand_id']; $editData['s_id'] = $info['s_id']; $editData['v_id'] = $info['v_id']; @@ -411,7 +457,7 @@ class Goods extends HD_Controller $editData['buy_price'] = $info['buy_price']; $editData['pro_time'] = $info['pro_time']; - $editData['p_time'] = $info['p_time']; + $editData['in_time'] = $info['in_time']; $editData['out_time'] = $info['out_time']; $editData['bill_time'] = $info['bill_time']; //存货地址 @@ -540,7 +586,7 @@ class Goods extends HD_Controller 'if_pack' =>'精品加装', 'status' =>'状态', 'pro_time' =>'生产时间', - 'p_time' =>'分配时间', + 'in_time' =>'分配时间', 'out_time' =>'出库时间', 'bill_time' =>'开票时间', ); @@ -615,7 +661,7 @@ class Goods extends HD_Controller 'if_pack' => $v['if_pack'], 'status' => $this->statusAry[$v['status']], 'pro_time' => '0000-00-00 00:00:00' == $v['pro_time'] ? '' : $v['pro_time'], - 'p_time' => '0000-00-00 00:00:00' == $v['p_time'] ? '' : $v['p_time'], + 'in_time' => '0000-00-00 00:00:00' == $v['in_time'] ? '' : $v['in_time'], 'out_time' => '0000-00-00 00:00:00' == $v['out_time'] ? '' : $v['out_time'], 'bill_time' => '0000-00-00 00:00:00' == $v['bill_time'] ? '' : $v['bill_time'], ); diff --git a/admin/views/items/goods/edit.php b/admin/views/items/goods/edit.php index 1d08b840..ca66beec 100644 --- a/admin/views/items/goods/edit.php +++ b/admin/views/items/goods/edit.php @@ -189,8 +189,8 @@ -->