diff --git a/admin/controllers/app/licheb/Usersog.php b/admin/controllers/app/licheb/Usersog.php new file mode 100644 index 00000000..db1be405 --- /dev/null +++ b/admin/controllers/app/licheb/Usersog.php @@ -0,0 +1,153 @@ +load->model('items/items_stock_log_model', 'mdStockLog'); + $this->load->model('items/items_model', 'mdItems'); + $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); + $this->load->model('auto/auto_series_model', 'mdAutoSeries'); + $this->load->model("biz/biz_model", 'mdBiz'); + $this->load->model('area_model', 'mdArea'); + } + + public function index() + { + return $this->lists(); + } + + public function lists() + { + $params = $this->input->get(); + $params['page'] = $params['page'] ? intval($params['page']) : 1; + $params['size'] = $params['size'] ? intval($params['size']) : 20; + $lists = $where = []; + $params['days_sort'] = $params['days_sort'] ? $params['days_sort'] : ''; + if ($params['days_sort']) { + $order = $params['days_sort'] == 1 ? 'stay_days desc,id desc' : 'stay_days asc,id desc'; + } else { + $order = "id desc"; + } + if ($params['brand_id']) { + $where['brand_id'] = $params['brand_id']; + } + if ($params['s_id']) { + $where['s_id'] = $params['s_id']; + } + if ($params['vin']) { + $where["item_id in(select id from lc_items where vin like '%{$params['vin']}%')"] = null; + } + if ($params['biz_id']) { + $where['biz_id'] = $params['biz_id']; + } else if ($params['city_id']) { + $where_biz['status'] = 1; + $params['city_id'] && $where_biz['city_id'] = $params['city_id']; + $params['county_id'] && $where_biz['county_id'] = $params['county_id']; + $res_biz = $this->mdBiz->select($where_biz, 'id desc', 0, 0, 'id'); + if ($res_biz) { + $str_ids = implode(',', array_column($res_biz, 'id')); + $where["biz_id in ({$str_ids})"] = null; + } else { + $where['biz_id'] = -2; + } + } else { + $params['city_id'] = ''; + $params['county_id'] = ''; + $params['biz_id'] = ''; + } + if ($params['time']) { + $time = explode(' ~ ', $params['time']); + $time[0] && $where["log_date>="] = $time[0]; + $time[1] && $where["log_date<="] = $time[1]; + } + $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), "id desc", 0, 0, 'id,name'); + if ($params['brand_id']) { + $autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $params['brand_id']), 'id desc', 0, 0, 'id,name'); + } + $total = $this->mdStockLog->count($where); + if ($total) { + $res = $this->mdStockLog->select($where, $order, $params['page'], $params['size']); + $brand_ids = $s_ids = $biz_ids = $item_ids = array(); + foreach ($res as $v) { + $v['brand_id'] && !in_array($v['brand_id'], $brand_ids) && $brand_ids[] = $v['brand_id']; + $v['s_id'] && !in_array($v['s_id'], $s_ids) && $s_ids[] = $v['s_id']; + $v['biz_id'] && !in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id']; + $v['item_id'] && !in_array($v['item_id'], $item_ids) && $item_ids[] = $v['item_id']; + } + $map_brand = $map_sery = $map_biz = $map_item = array(); + if ($brand_ids) { + $str_ids = implode(',', $brand_ids); + $map_brand = $this->mdAutoBrand->map('id', 'name', ["id in ({$str_ids})" => null]); + } + if ($s_ids) { + $str_ids = implode(',', $s_ids); + $map_sery = $this->mdAutoSeries->map('id', 'name', ["id in ({$str_ids})" => null]); + } + if ($biz_ids) { + $str_ids = implode(',', $biz_ids); + $map_biz = $this->mdBiz->map('id', 'biz_name', ["id in ({$str_ids})" => null]); + } + if ($item_ids) { + $str_ids = implode(',', $item_ids); + $map_item = $this->mdItems->map('id', 'vin', ["id in ({$str_ids})" => null]); + } + foreach ($res as $v) { + $address = $map_biz[$v['biz_id']]; + $re_biz = $this->mdBiz->get(array('id' => $v['biz_id'])); + if ($re_biz['county_id']) { + $re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id'])); + $re_area && $address = "{$re_area['city_name']} {$re_area['county_name']} {$address}"; + } else if ($re_biz['city_id']) { + $re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id'])); + $re_area && $address = "{$re_area['city_name']} {$address}"; + } + $title = "{$map_brand[$v['brand_id']]}-{$map_sery[$v['s_id']]}"; + $vin = $map_item[$v['item_id']]; + $in_time = !$v['in_time'] || '0000-00-00 00:00:00' == $v['in_time'] ? '' : substr($v['in_time'], 0, 10); + $lists[] = ['item_id' => $v['item_id'], 'title' => $title, 'vin' => $vin, 'in_time' => $in_time, 'address' => $address + , 'log_date' => $v['log_date'], 'stay_days' => $v['stay_days']]; + } + } + $this->data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total); + $this->data['lists'] = $lists; + $this->data['autoList'] = $autoList; + $this->data['params'] = $params; + $this->data['_title'] = "库存车辆日志"; + $this->show_view('items/stock/lists', true); + } + + + public function get() + { + } + + public function add() + { + } + + public function edit() + { + } + + public function del() + { + } + + + public function batch() + { + } + + public function export() + { + } +} \ No newline at end of file diff --git a/api/controllers/plan/Licheb.php b/api/controllers/plan/Licheb.php index 5a8cb556..05cdc1a6 100644 --- a/api/controllers/plan/Licheb.php +++ b/api/controllers/plan/Licheb.php @@ -51,7 +51,6 @@ class Licheb extends HD_Controller } $id = $redis->get($redisKey); !$id && $id = 0; - $id = 19; $log = []; $where = ['id >' => $id, 'group_id < 4' => null, 'status' => 1]; $res = $this->mdUsers->select($where, 'id asc', 1, $size, 'id,biz_id');