admin_items_303
This commit is contained in:
@@ -274,72 +274,12 @@ class Goods extends HD_Controller
|
||||
$orderby = "{$order} {$sort}";
|
||||
$rows = $this->mdItems->select($where, $orderby, $page, $size, $fileds);
|
||||
}
|
||||
|
||||
$company_ids = $brand_ids = $s_ids = $attr_vids = $attr_corids = $attr_incorids = $biz_ids = $addr_ids = array();
|
||||
$ids = array();
|
||||
foreach ($rows as $v) {
|
||||
$ids[] = $v['id'];
|
||||
$v['brand_id'] && !in_array($v['brand_id'], $brand_ids) && $brand_ids[] = $v['brand_id'];
|
||||
$v['biz_id'] && !in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id'];
|
||||
$v['addr_id'] && !in_array($v['addr_id'], $addr_ids) && $addr_ids[] = $v['addr_id'];
|
||||
$v['s_id'] && !in_array($v['s_id'], $s_ids) && $s_ids[] = $v['s_id'];
|
||||
$v['v_id'] && !in_array($v['v_id'], $attr_vids) && $attr_vids[] = $v['v_id'];
|
||||
$v['cor_id'] && !in_array($v['cor_id'], $attr_corids) && $attr_corids[] = $v['cor_id'];
|
||||
$v['incor_id'] && !in_array($v['incor_id'], $attr_incorids) && $attr_incorids[] = $v['incor_id'];
|
||||
$v['company_id'] && !in_array($v['company_id'], $company_ids) && $company_ids[] = $v['company_id'];
|
||||
}
|
||||
$map_company = $map_brand = $map_sery = $map_vid = $map_corid = $map_incorid = $map_biz = $map_addr = array();
|
||||
if ($brand_ids) {
|
||||
$str_ids = implode(',', $brand_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_brand = $this->mdAutoBrand->map('id', 'name', $where);
|
||||
}
|
||||
if ($s_ids) {
|
||||
$str_ids = implode(',', $s_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_sery = $this->mdAutoSeries->map('id', 'name', $where);
|
||||
}
|
||||
if ($attr_vids) {
|
||||
$str_ids = implode(',', $attr_vids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_vid = $this->mdAutoAttr->map('id', 'title', $where);
|
||||
}
|
||||
if ($attr_corids) {
|
||||
$str_ids = implode(',', $attr_corids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_corid = $this->mdAutoAttr->map('id', 'title', $where);
|
||||
}
|
||||
if ($attr_incorids) {
|
||||
$str_ids = implode(',', $attr_incorids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_incorid = $this->mdAutoAttr->map('id', 'title', $where);
|
||||
}
|
||||
if ($biz_ids) {
|
||||
$str_ids = implode(',', $biz_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_biz = $this->mdBiz->map('id', 'biz_name', $where);
|
||||
}
|
||||
if ($addr_ids) {
|
||||
$str_ids = implode(',', $addr_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$orderby = 'id desc';
|
||||
$select = 'id, title, city_name, county_name';
|
||||
$rows_addr = $this->addr_model->select($where, $orderby, 0, 0, $select);
|
||||
foreach ($rows_addr as $v) {
|
||||
$map_addr[$v['id']] = "{$v['city_name']} {$v['county_name']} 其它 {$v['title']}";
|
||||
}
|
||||
}
|
||||
if ($company_ids) {
|
||||
$str_ids = implode(',', $company_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_company = $this->sys_company_model->map('id', 'short', $where);
|
||||
}
|
||||
|
||||
$items_info = $this->items_info($rows);
|
||||
$map_item_fine = array();
|
||||
$map_order = array();
|
||||
if ($ids) {
|
||||
if ($items_info['ids']) {
|
||||
//获取精品加装
|
||||
$str_ids = implode(',', $ids);
|
||||
$str_ids = implode(',', $items_info['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_item_fine = array();//按item_id分组所属精品ID
|
||||
@@ -347,10 +287,9 @@ class Goods extends HD_Controller
|
||||
!in_array($v['type_id'], $fine_ids) && $fine_ids[] = $v['type_id'];
|
||||
$map_item_fine[$v['item_id']][] = $v['type_id'];
|
||||
}
|
||||
|
||||
//已售商品订单信息
|
||||
$this->load->model('receiver/order/receiver_orders_model', 'orders_model');
|
||||
$str_ids = implode(',', $ids);
|
||||
$str_ids = implode(',', $items_info['ids']);
|
||||
$where = array("item_id in ({$str_ids})" => null);
|
||||
$rows_order = $this->orders_model->select($where, 'id desc', 0, 0, 'item_id, admin_id, name, mobile');
|
||||
$admin_ids = array();
|
||||
@@ -398,12 +337,11 @@ class Goods extends HD_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as $k => $v) {
|
||||
$order = $map_order[$v['id']];
|
||||
$address = '';
|
||||
if ($v['biz_id'] > 0) {
|
||||
$address = $map_biz[$v['biz_id']];
|
||||
$address = $items_info['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']));
|
||||
@@ -413,23 +351,27 @@ class Goods extends HD_Controller
|
||||
$re_area && $address = "{$re_area['city_name']} {$address}";
|
||||
}
|
||||
} else if ($v['biz_id'] == -1 && $v['addr_id']) {
|
||||
$address = $map_addr[$v['addr_id']];
|
||||
$address = $items_info['map_addr'][$v['addr_id']];
|
||||
}
|
||||
$title = "{$map_brand[$v['brand_id']]}-{$map_sery[$v['s_id']]}-{$map_vid[$v['v_id']]}-{$map_corid[$v['cor_id']]}";
|
||||
$brand_name = $items_info['map_brand'][$v['brand_id']];
|
||||
$s_name = $items_info['map_sery'][$v['s_id']];
|
||||
$v_name = $items_info['map_vid'][$v['v_id']];
|
||||
$cor_name = $items_info['map_corid'][$v['cor_id']];
|
||||
$incor_name = $items_info['map_incorid'][$v['incor_id']];
|
||||
$lists[] = array(
|
||||
'id' => $v['id'],
|
||||
'title' => $title,
|
||||
'brand_name' => $map_brand[$v['brand_id']],
|
||||
's_name' => $map_sery[$v['s_id']],
|
||||
'v_name' => $map_vid[$v['v_id']],
|
||||
'cor_name' => $map_corid[$v['cor_id']],
|
||||
'incor_name' => $map_incorid[$v['incor_id']],
|
||||
'title' => "{$brand_name}-{$s_name}-{$v_name}-{$cor_name}",
|
||||
'brand_name' => $brand_name,
|
||||
's_name' => $s_name,
|
||||
'v_name' => $v_name,
|
||||
'cor_name' => $cor_name,
|
||||
'incor_name' => $incor_name,
|
||||
'vin' => $v['vin'],
|
||||
'address' => $address,
|
||||
'in_time' => '0000-00-00 00:00:00' == $v['in_time'] ? '' : substr($v['in_time'], 0, 10),
|
||||
'sold_time' => '0000-00-00 00:00:00' == $v['bill_time'] ? '' : substr($v['bill_time'], 0, 10),
|
||||
'fine_ids' => $map_item_fine[$v['id']] ? $map_item_fine[$v['id']] : array(),
|
||||
'company_name' => $map_company[$v['company_id']] ? $map_company[$v['company_id']] : '',
|
||||
'company_name' => $items_info['map_company'][$v['company_id']] ? $items_info['map_company'][$v['company_id']] : '',
|
||||
'admin_name' => $order ? $order['admin_name'] : '',
|
||||
'uname' => $order ? $order['uname'] : '',
|
||||
'mobile' => $order ? (SUPER_ADMIN == $this->role ? $order['mobile'] : substr_replace($order['mobile'], '*****', 0, 5)) : '',
|
||||
@@ -1281,6 +1223,143 @@ class Goods extends HD_Controller
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function export_overdue()
|
||||
{
|
||||
$this->load->model('items/items_oplogs_model', 'mdItemsOplogs');
|
||||
$fileName = '超期车辆';
|
||||
$where = ['status<>' => 0, 'bill_time' => '0000-00-00 00:00:00'];
|
||||
$res = $this->mdItems->select($where, 'id asc', 1, 5000, 'brand_id,biz_id,addr_id,s_id,v_id,cor_id,incor_id,company_id,id,vin,in_time,status');
|
||||
$data = $list = [];
|
||||
foreach ($res as $key => $value) {
|
||||
$in_time = $value['in_time'];
|
||||
if ($value['biz_id'] > 0) {
|
||||
$where_logs = ["item_id" => $value['id'], 'type' => 2, 'biz_id_to' => $value['biz_id']];
|
||||
} else {
|
||||
$where_logs = ["item_id" => $value['id'], 'type' => 2, 'addr_id_to' => $value['addr_id']];
|
||||
}
|
||||
$re_logs = $this->mdItemsOplogs->max('com_time', $where_logs);
|
||||
$re_logs['com_time'] && $in_time = $re_logs['com_time'];
|
||||
if ($in_time && $in_time != '0000-00-00 00:00:00') {
|
||||
$days = round((time() - strtotime($in_time)) / 3600 / 24);
|
||||
if ($days > 30) {
|
||||
$value['in_time'] = $in_time;
|
||||
$value['days'] = $days;
|
||||
$list[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($list) {
|
||||
$items_info = $this->items_info($list);
|
||||
foreach ($list as $key => $value) {
|
||||
$address = '';
|
||||
if ($value['biz_id'] > 0) {
|
||||
$address = $items_info['map_biz'][$value['biz_id']];
|
||||
$re_biz = $this->mdBiz->get(array('id' => $value['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}";
|
||||
}
|
||||
} else if ($value['biz_id'] == -1 && $value['addr_id']) {
|
||||
$address = $items_info['map_addr'][$value['addr_id']];
|
||||
}
|
||||
$title = "{$items_info['map_brand'][$value['brand_id']]}-{$items_info['map_sery'][$value['s_id']]}-{$items_info['map_vid'][$value['v_id']]}-{$items_info['map_corid'][$value['cor_id']]}";
|
||||
$temp['address'] = $address;
|
||||
$temp['title'] = $title;
|
||||
$temp['vin'] = $value['vin'];
|
||||
$temp['in_time'] = $value['in_time'];
|
||||
$temp['days'] = $value['days'];
|
||||
$temp['status_name'] = $value['status'] == 1 ? '未分配' : '已分配';
|
||||
$data[] = $temp;
|
||||
}
|
||||
}
|
||||
$indexs = [
|
||||
'address' => '门店',
|
||||
'title' => '车辆',
|
||||
'vin' => '车架号',
|
||||
'in_time' => '入库日期',
|
||||
'days' => '库存天数',
|
||||
"status_name" => "状态",
|
||||
];
|
||||
array_unshift($data, $indexs);
|
||||
$this->load->library('excel');
|
||||
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:获取商品信息
|
||||
* Created on: 2022/3/3 16:35
|
||||
* Created by: dengbw
|
||||
* @param $list
|
||||
* @return array
|
||||
*/
|
||||
private function items_info($list)
|
||||
{
|
||||
$company_ids = $brand_ids = $s_ids = $attr_vids = $attr_corids = $attr_incorids = $biz_ids = $addr_ids = $ids = [];
|
||||
foreach ($list as $v) {
|
||||
$ids[] = $v['id'];
|
||||
$v['brand_id'] && !in_array($v['brand_id'], $brand_ids) && $brand_ids[] = $v['brand_id'];
|
||||
$v['biz_id'] && !in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id'];
|
||||
$v['addr_id'] && !in_array($v['addr_id'], $addr_ids) && $addr_ids[] = $v['addr_id'];
|
||||
$v['s_id'] && !in_array($v['s_id'], $s_ids) && $s_ids[] = $v['s_id'];
|
||||
$v['v_id'] && !in_array($v['v_id'], $attr_vids) && $attr_vids[] = $v['v_id'];
|
||||
$v['cor_id'] && !in_array($v['cor_id'], $attr_corids) && $attr_corids[] = $v['cor_id'];
|
||||
$v['incor_id'] && !in_array($v['incor_id'], $attr_incorids) && $attr_incorids[] = $v['incor_id'];
|
||||
$v['company_id'] && !in_array($v['company_id'], $company_ids) && $company_ids[] = $v['company_id'];
|
||||
}
|
||||
$map_company = $map_brand = $map_sery = $map_vid = $map_corid = $map_incorid = $map_biz = $map_addr = array();
|
||||
if ($brand_ids) {
|
||||
$str_ids = implode(',', $brand_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_brand = $this->mdAutoBrand->map('id', 'name', $where);
|
||||
}
|
||||
if ($s_ids) {
|
||||
$str_ids = implode(',', $s_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_sery = $this->mdAutoSeries->map('id', 'name', $where);
|
||||
}
|
||||
if ($attr_vids) {
|
||||
$str_ids = implode(',', $attr_vids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_vid = $this->mdAutoAttr->map('id', 'title', $where);
|
||||
}
|
||||
if ($attr_corids) {
|
||||
$str_ids = implode(',', $attr_corids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_corid = $this->mdAutoAttr->map('id', 'title', $where);
|
||||
}
|
||||
if ($attr_incorids) {
|
||||
$str_ids = implode(',', $attr_incorids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_incorid = $this->mdAutoAttr->map('id', 'title', $where);
|
||||
}
|
||||
if ($biz_ids) {
|
||||
$str_ids = implode(',', $biz_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_biz = $this->mdBiz->map('id', 'biz_name', $where);
|
||||
}
|
||||
if ($addr_ids) {
|
||||
$str_ids = implode(',', $addr_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$orderby = 'id desc';
|
||||
$select = 'id, title, city_name, county_name';
|
||||
$rows_addr = $this->addr_model->select($where, $orderby, 0, 0, $select);
|
||||
foreach ($rows_addr as $v) {
|
||||
$map_addr[$v['id']] = "{$v['city_name']} {$v['county_name']} 其它 {$v['title']}";
|
||||
}
|
||||
}
|
||||
if ($company_ids) {
|
||||
$str_ids = implode(',', $company_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$map_company = $this->sys_company_model->map('id', 'short', $where);
|
||||
}
|
||||
$date = ['map_brand' => $map_brand, 'map_sery' => $map_sery, 'map_vid' => $map_vid, 'map_corid' => $map_corid, 'map_incorid' => $map_incorid
|
||||
, 'map_biz' => $map_biz, 'map_addr' => $map_addr, 'map_company' => $map_company, 'ids' => $ids];
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:上传excel
|
||||
* Created on: 2021/7/14 15:06
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" id="import" class="am-btn am-btn-success am-btn-sm w100">导入</button>
|
||||
<button type="button" id="export" class="am-btn am-btn-success am-btn-sm w100">导出</button>
|
||||
<button type="button" id="export_overdue" class="am-btn am-btn-success am-btn-sm">超期车辆导出</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -785,6 +786,10 @@
|
||||
window.location.href = href;
|
||||
});
|
||||
|
||||
$('#export_overdue').click(function () {
|
||||
window.location.href = '/items/goods/goods/export_overdue';
|
||||
});
|
||||
|
||||
$('#bd-auto1-id').change(function () {
|
||||
$('#bd-auto2-id').empty();
|
||||
$('#bd-auto3-id').empty();
|
||||
|
||||
Reference in New Issue
Block a user