liche update for admin goods sold lists
This commit is contained in:
@@ -197,17 +197,17 @@ class Goods extends HD_Controller
|
||||
if ($count) {
|
||||
switch($search_type){
|
||||
case 1://精品筛选
|
||||
$fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,in_time,addr_id,count(type_id) as fine_num';
|
||||
$fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,in_time,out_time,addr_id,count(type_id) as fine_num';
|
||||
$orderby = "{$order} {$sort}";
|
||||
$rows = $this->mdItems->select_fine($where_1, $orderby, $page, $size, $fileds);
|
||||
break;
|
||||
case 2://订单筛选
|
||||
$fileds = 'm.id, m.brand_id, m.s_id, m.vin, m.v_id, m.cor_id, m.incor_id, m.in_time, m.addr_id';
|
||||
$fileds = 'm.id, m.brand_id, m.s_id, m.vin, m.v_id, m.cor_id, m.incor_id, m.in_time, m.out_time, m.addr_id';
|
||||
$orderby = "{$order} {$sort}";
|
||||
$rows = $this->mdItems->select_order($where_2, $orderby, $page, $size, $fileds);
|
||||
break;
|
||||
case 3://精品+订单筛选
|
||||
$fileds = 'm.id, m.brand_id, m.s_id, m.vin, m.v_id, m.cor_id, m.incor_id, m.in_time, m.addr_id, count(j2.type_id) as fine_num';
|
||||
$fileds = 'm.id, m.brand_id, m.s_id, m.vin, m.v_id, m.cor_id, m.incor_id, m.in_time, m.out_time, m.addr_id, count(j2.type_id) as fine_num';
|
||||
if(in_array($order, array('admin_id'))){
|
||||
$orderby = "{$order} {$sort}";
|
||||
} else {
|
||||
@@ -269,76 +269,65 @@ class Goods extends HD_Controller
|
||||
}
|
||||
}
|
||||
|
||||
$map_fine = array();
|
||||
$map_item_fine = array();
|
||||
$map_item_admin = array();
|
||||
if($ids){
|
||||
if(1 == $params['status']){
|
||||
//获取精品加装
|
||||
$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_item_fine = array();//按item_id分组所属精品ID
|
||||
foreach($rows_fine as $v){
|
||||
!in_array($v['type_id'], $fine_ids) && $fine_ids[] = $v['type_id'];
|
||||
$map_item_fine[$v['item_id']][] = $v['type_id'];
|
||||
}
|
||||
//获取精品ID和名称映射
|
||||
if($fine_ids){
|
||||
$this->load->model('auto/auto_fine_model');
|
||||
$str_ids = implode(',', $fine_ids);
|
||||
$where= array("id in ({$str_ids})" => null);
|
||||
$map_fine = $this->auto_fine_model->map('id', 'title', $where);
|
||||
}
|
||||
//获取精品加装
|
||||
$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_item_fine = array();//按item_id分组所属精品ID
|
||||
foreach($rows_fine as $v){
|
||||
!in_array($v['type_id'], $fine_ids) && $fine_ids[] = $v['type_id'];
|
||||
$map_item_fine[$v['item_id']][] = $v['type_id'];
|
||||
}
|
||||
|
||||
//获取销售员信息
|
||||
if(2 == $params['status']){
|
||||
//订单列表
|
||||
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
$str_ids = implode(',', $ids);
|
||||
$where = array("item_id in ({$str_ids})" => null);
|
||||
$rows_order = $this->orders_model->select($where, 'id desc', 0, 0, 'item_id, admin_id');
|
||||
$admin_ids = array();
|
||||
foreach($rows_order as $v){
|
||||
$map_item_admin[$v['item_id']] = array('admin_id' => $v['admin_id']);
|
||||
$v['admin_id'] && !in_array($v['admin_id'], $admin_ids) && $admin_ids[] = $v['admin_id'];
|
||||
}
|
||||
if($admin_ids){
|
||||
//销售员列表
|
||||
$this->load->model('app/licheb/app_licheb_users_model', 'licheb_users_model');
|
||||
$str_ids = implode(',', $admin_ids);
|
||||
$where = array("id in({$str_ids})" => null);
|
||||
$select = 'id, uname, biz_id';
|
||||
$rows_admin = $this->licheb_users_model->select($where, 'id desc', 0, 0, $select);
|
||||
if($rows_admin){
|
||||
$biz_ids = array();
|
||||
$map_admin = array();
|
||||
$map_biz_name = array();
|
||||
foreach($rows_admin as $v){
|
||||
$map_admin[$v['id']] = $v;
|
||||
!in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id'];
|
||||
}
|
||||
if($biz_ids){//店铺列表
|
||||
$this->load->model("biz/biz_model");
|
||||
$str_ids = implode(',', $biz_ids);
|
||||
$where = array("id in({$str_ids})" => null);
|
||||
$map_biz_name = $this->biz_model->map('id', 'biz_name', $where);
|
||||
}
|
||||
//订单列表
|
||||
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
$str_ids = implode(',', $ids);
|
||||
$where = array("item_id in ({$str_ids})" => null);
|
||||
$rows_order = $this->orders_model->select($where, 'id desc', 0, 0, 'item_id, admin_id');
|
||||
$admin_ids = array();
|
||||
foreach($rows_order as $v){
|
||||
$map_item_admin[$v['item_id']] = array('admin_id' => $v['admin_id']);
|
||||
$v['admin_id'] && !in_array($v['admin_id'], $admin_ids) && $admin_ids[] = $v['admin_id'];
|
||||
}
|
||||
if($admin_ids){
|
||||
//销售员列表
|
||||
$this->load->model('app/licheb/app_licheb_users_model', 'licheb_users_model');
|
||||
$str_ids = implode(',', $admin_ids);
|
||||
$where = array("id in({$str_ids})" => null);
|
||||
$select = 'id, uname, biz_id';
|
||||
$rows_admin = $this->licheb_users_model->select($where, 'id desc', 0, 0, $select);
|
||||
if($rows_admin){
|
||||
$biz_ids = array();
|
||||
$map_admin = array();
|
||||
$map_biz_name = array();
|
||||
foreach($rows_admin as $v){
|
||||
$map_admin[$v['id']] = $v;
|
||||
!in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id'];
|
||||
}
|
||||
if($biz_ids){//店铺列表
|
||||
$this->load->model("biz/biz_model");
|
||||
$str_ids = implode(',', $biz_ids);
|
||||
$where = array("id in({$str_ids})" => null);
|
||||
$map_biz_name = $this->biz_model->map('id', 'biz_name', $where);
|
||||
}
|
||||
|
||||
foreach($map_item_admin as $k => $v){
|
||||
$admin_id = $v['admin_id'];
|
||||
$admin = $map_admin[$admin_id];
|
||||
if(!$admin){
|
||||
continue;
|
||||
}
|
||||
$biz_name = $map_biz_name[$admin['biz_id']];
|
||||
$admin_name = "{$biz_name} {$admin['uname']}";
|
||||
$map_item_admin[$k] = array(
|
||||
'admin_id' => $admin_id,
|
||||
'biz_id' => $admin['biz_id'],
|
||||
'admin_name' => $admin_name
|
||||
);
|
||||
foreach($map_item_admin as $k => $v){
|
||||
$admin_id = $v['admin_id'];
|
||||
$admin = $map_admin[$admin_id];
|
||||
if(!$admin){
|
||||
continue;
|
||||
}
|
||||
$biz_name = $map_biz_name[$admin['biz_id']];
|
||||
$admin_name = "{$biz_name} {$admin['uname']}";
|
||||
$map_item_admin[$k] = array(
|
||||
'admin_id' => $admin_id,
|
||||
'biz_id' => $admin['biz_id'],
|
||||
'admin_name' => $admin_name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,7 +347,7 @@ class Goods extends HD_Controller
|
||||
'address' => $v['addr_id'] ? $map_addr[$v['addr_id']] : '',
|
||||
'in_time' => '0000-00-00 00:00:00' == $v['in_time'] ? '' : substr($v['in_time'], 0, 10),
|
||||
'out_time' => '0000-00-00 00:00:00' == $v['out_time'] ? '' : substr($v['out_time'], 0, 10),
|
||||
'fine_ids' => $map_fine[$v['id']] ? $map_fine[$v['id']] : array(),
|
||||
'fine_ids' => $map_item_fine[$v['id']] ? $map_item_fine[$v['id']] : array(),
|
||||
'admin_name' => $admin ? $admin['admin_name'] : '',
|
||||
);
|
||||
}
|
||||
@@ -576,7 +565,8 @@ class Goods extends HD_Controller
|
||||
}
|
||||
|
||||
$this->data['status'] = 1;
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '添加成功!', '/items/goods/goods');
|
||||
$url = $info['bill_time'] ? '/items/goods/goods?sold=1' : "/items/goods/goods";
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '添加成功!', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -721,7 +711,8 @@ class Goods extends HD_Controller
|
||||
}
|
||||
|
||||
$this->data['status'] = 2;
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '修改成功!', '/items/goods/goods');
|
||||
$url = $info['bill_time'] ? '/items/goods/goods?sold=1' : "/items/goods/goods";
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '修改成功!', $url);
|
||||
}
|
||||
|
||||
//删除单条数据
|
||||
@@ -805,20 +796,19 @@ class Goods extends HD_Controller
|
||||
$params['addr_id'] = '';
|
||||
}
|
||||
|
||||
if(2 == $params['status']){//已售
|
||||
if(strlen($params['status'])>0){
|
||||
$where['status'] = $params['status'];
|
||||
$where_1['m.status'] = $params['status'];
|
||||
$where_2['m.status'] = $params['status'];
|
||||
$where_3['m.status'] = $params['status'];
|
||||
$view = '/items/goods/lists_sold';
|
||||
$_title = '已售车辆';
|
||||
} else {
|
||||
$where['status'] = 1;
|
||||
$where_1['m.status'] = 1;
|
||||
$where_2['m.status'] = 1;
|
||||
$where_3['m.status'] = 1;
|
||||
$view = '/items/goods/lists';
|
||||
$_title = '未售车辆';
|
||||
$params['status'] = '';
|
||||
}
|
||||
|
||||
if(1 == $params['sold']){//已售
|
||||
$where["bill_time<>'0000-00-00 00:00:00'"] = null;
|
||||
} else {
|
||||
$where["bill_time"] = '0000-00-00 00:00:00';
|
||||
}
|
||||
|
||||
if($params['vin']){
|
||||
@@ -939,28 +929,28 @@ class Goods extends HD_Controller
|
||||
if ($count) {
|
||||
switch($search_type){
|
||||
case 1://精品筛选
|
||||
$fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,in_time,addr_id,count(type_id) as fine_num';
|
||||
$fileds = 'm.*,count(type_id) as fine_num';
|
||||
$orderby = "{$order} {$sort}";
|
||||
$rows = $this->mdItems->select_fine($where_1, $orderby, $page, $size, $fileds);
|
||||
$rows = $this->mdItems->select_fine($where_1, $orderby, 0, 0, $fileds);
|
||||
break;
|
||||
case 2://订单筛选
|
||||
$fileds = 'm.id, m.brand_id, m.s_id, m.vin, m.v_id, m.cor_id, m.incor_id, m.in_time, m.addr_id';
|
||||
$fileds = 'm.*';
|
||||
$orderby = "{$order} {$sort}";
|
||||
$rows = $this->mdItems->select_order($where_2, $orderby, $page, $size, $fileds);
|
||||
$rows = $this->mdItems->select_order($where_2, $orderby, 0, 0, $fileds);
|
||||
break;
|
||||
case 3://精品+订单筛选
|
||||
$fileds = 'm.id, m.brand_id, m.s_id, m.vin, m.v_id, m.cor_id, m.incor_id, m.in_time, m.addr_id, count(j2.type_id) as fine_num';
|
||||
$fileds = 'm.*, count(j2.type_id) as fine_num';
|
||||
if(in_array($order, array('admin_id'))){
|
||||
$orderby = "{$order} {$sort}";
|
||||
} else {
|
||||
$orderby = "m.{$order} {$sort}";
|
||||
}
|
||||
$rows = $this->mdItems->select_order_fine($where_3, $orderby, $page, $size, $fileds);
|
||||
$rows = $this->mdItems->select_order_fine($where_3, $orderby, 0, 0, $fileds);
|
||||
break;
|
||||
default:
|
||||
$fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,in_time,addr_id';
|
||||
$fileds = '*';
|
||||
$orderby = "{$order} {$sort}";
|
||||
$rows = $this->mdItems->select($where, $orderby, $page, $size, $fileds);
|
||||
$rows = $this->mdItems->select($where, $orderby, 0, 0, $fileds);
|
||||
}
|
||||
|
||||
$lists[] = $indexs;
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
action="/items/goods/goods">
|
||||
<input title="排序字段" type="hidden" name="order" id="order" v-model="params.order"/>
|
||||
<input title="排序方向" type="hidden" name="sort" id="sort" v-model="params.sort"/>
|
||||
<input title="状态" type="hidden" name="status" v-model="params.status">
|
||||
<input title="是否已售" type="hidden" name="sold" v-model="params.sold">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">车型:</label>
|
||||
@@ -481,7 +481,7 @@
|
||||
});
|
||||
}
|
||||
},
|
||||
init_fines_lists:function(){
|
||||
init_fines_lists:function(){//初始化列表中精品
|
||||
var vm = this;
|
||||
if(vm.fine_ids.length > 0){
|
||||
$.ajax({
|
||||
@@ -506,7 +506,9 @@
|
||||
for(var j in goods.fine_ids){
|
||||
var fine_id = goods.fine_ids[j];
|
||||
fine = map_fine[fine_id];
|
||||
auto_fine += fine.title + " ";
|
||||
if(undefined != fine){
|
||||
auto_fine += fine.title + " ";
|
||||
}
|
||||
}
|
||||
goods.auto_fine = auto_fine;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
action="/items/goods/goods">
|
||||
<input title="排序字段" type="hidden" name="order" id="order" v-model="params.order"/>
|
||||
<input title="排序方向" type="hidden" name="sort" id="sort" v-model="params.sort"/>
|
||||
<input title="状态" type="hidden" name="status" v-model="params.status">
|
||||
<input title="是否已售" type="hidden" name="sold" v-model="params.sold">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">车型:</label>
|
||||
@@ -493,7 +493,7 @@
|
||||
});
|
||||
}
|
||||
},
|
||||
init_fines_lists:function(){
|
||||
init_fines_lists:function(){//初始化列表中精品
|
||||
var vm = this;
|
||||
if(vm.fine_ids.length > 0){
|
||||
$.ajax({
|
||||
@@ -518,7 +518,9 @@
|
||||
for(var j in goods.fine_ids){
|
||||
var fine_id = goods.fine_ids[j];
|
||||
fine = map_fine[fine_id];
|
||||
auto_fine += fine.title + " ";
|
||||
if(undefined != fine){
|
||||
auto_fine += fine.title + " ";
|
||||
}
|
||||
}
|
||||
goods.auto_fine = auto_fine;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user