liche update for admin auto cars attr exporde
This commit is contained in:
@@ -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};");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/font-awesome.min.css?v=1581252500">
|
||||
<div class="bs-example bs-example-tabs" data-example-id="togglable-tabs" style="font-size:15px;">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="<?=!strlen($params['status'])?'active':'' ?>">
|
||||
<a href="javascript:void (0);" data-open="/receiver/order/sign">全部</a>
|
||||
</li>
|
||||
<?foreach($status_arr as $key=>$val){?>
|
||||
<li role="presentation" class="<?=strlen($params['status']) && $params['status']==$key?'active':''?>">
|
||||
<a href="javascript:void (0);" data-open="/receiver/order/sign?status=<?=$key?>">
|
||||
|
||||
@@ -170,8 +170,13 @@ class Series extends Wxapp{
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$attrs = "{$color_id}_{$v_id}_{$incolor_id}";
|
||||
$car = $this->auto_cars_model->get(['attrs'=>$attrs,'s_id'=>$s_id]);
|
||||
$where_car = array(
|
||||
's_id'=>$s_id,
|
||||
'v_id' => $v_id,
|
||||
'cor_id' => $color_id,
|
||||
'incor_id' => $incolor_id
|
||||
);
|
||||
$car = $this->auto_cars_model->get($where_car);
|
||||
$data = [
|
||||
'price' => $car['price_car'] ? $car['price_car'] : 0,
|
||||
'deposit' => $car['price_book'] ? $car['price_book'] : 0
|
||||
|
||||
@@ -26,8 +26,13 @@ class Loan extends Wxapp{
|
||||
$oid = $this->input_param('oid');
|
||||
|
||||
$row = $this->orders_model->get(['id'=>$id]);
|
||||
$attrs = "{$row['cor_id']}_{$row['v_id']}_{$row['incor_id']}";
|
||||
$car = $this->auto_cars_model->get(['attrs'=>$attrs,'s_id'=>$row['s_id']],'first_pay');
|
||||
$where_car = array(
|
||||
's_id'=>$row['s_id'],
|
||||
'v_id' => $row['v_id'],
|
||||
'cor_id' => $row['cor_id'],
|
||||
'incor_id' => $row['incor_id']
|
||||
);
|
||||
$car = $this->auto_cars_model->get($where_car,'first_pay');
|
||||
$money = $car['first_pay'] ? $car['first_pay'] * 36 : 0;
|
||||
$banks = [
|
||||
'易鑫金融'
|
||||
|
||||
@@ -87,8 +87,13 @@ class Protocol extends CI_Controller{
|
||||
if($packs['srv_ids']){
|
||||
$row['services'] = $services = $this->services_model->select(["id in ({$packs['srv_ids']})"=>null],'','','','title,field_name');
|
||||
}
|
||||
$attrs = "{$row['cor_id']}_{$row['v_id']}_{$row['incor_id']}";
|
||||
$car = $this->auto_cars_model->get(['attrs'=>$attrs,'s_id'=>$row['s_id']]);
|
||||
$where_car = array(
|
||||
's_id'=>$row['s_id'],
|
||||
'v_id' => $row['v_id'],
|
||||
'cor_id' => $row['cor_id'],
|
||||
'incor_id' => $row['incor_id']
|
||||
);
|
||||
$car = $this->auto_cars_model->get($where_car);
|
||||
//获取挂牌价
|
||||
$this->load->model('sys/sys_city_model');
|
||||
$city = $this->sys_city_model->get(['city_id'=>$biz['city_id']],'fee_carno');
|
||||
@@ -169,8 +174,13 @@ class Protocol extends CI_Controller{
|
||||
if($packs['srv_ids']){
|
||||
$row['services'] = $services = $this->services_model->select(["id in ({$packs['srv_ids']})"=>null],'','','','title,field_name');
|
||||
}
|
||||
$attrs = "{$row['cor_id']}_{$row['v_id']}_{$row['incor_id']}";
|
||||
$car = $this->auto_cars_model->get(['attrs'=>$attrs,'s_id'=>$row['s_id']]);
|
||||
$where_car = array(
|
||||
's_id'=>$row['s_id'],
|
||||
'v_id' => $row['v_id'],
|
||||
'cor_id' => $row['cor_id'],
|
||||
'incor_id' => $row['incor_id']
|
||||
);
|
||||
$car = $this->auto_cars_model->get($where_car);
|
||||
//获取挂牌价
|
||||
$this->load->model('sys/sys_city_model');
|
||||
$city = $this->sys_city_model->get(['city_id'=>$biz['city_id']],'fee_carno');
|
||||
|
||||
@@ -291,8 +291,13 @@ class Orders_entity{
|
||||
if($packs['srv_ids']){
|
||||
$services = $this->ci->services_model->select(["id in ({$packs['srv_ids']})"],'','','','title,field_name');
|
||||
}
|
||||
$attrs = "{$row['cor_id']}_{$row['v_id']}_{$row['incor_id']}";
|
||||
$car = $this->ci->auto_cars_model->get(['attrs'=>$attrs,'s_id'=>$row['s_id']]);
|
||||
$where_car = array(
|
||||
's_id'=>$row['s_id'],
|
||||
'v_id' => $row['v_id'],
|
||||
'cor_id' => $row['cor_id'],
|
||||
'incor_id' => $row['incor_id'],
|
||||
);
|
||||
$car = $this->ci->auto_cars_model->get($where_car);
|
||||
//获取挂牌价
|
||||
if($row['brand_id']==3){ //狸车品牌写死挂牌费用0.01 测试用
|
||||
$car['fee_carno'] = 0.01;
|
||||
|
||||
+7
-1
@@ -75,8 +75,14 @@ create table lc_auto_cars (
|
||||
primary key (id),
|
||||
unique(attrs)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='车型库';
|
||||
alter table lc_auto_cars add column month_pay double(10,2) not null default 0.0 comment '月供' after first_pay;
|
||||
alter table lc_auto_cars add column month_pay double(10,2) not null default 0.0 comment '月供' after first_pay;
|
||||
alter table lc_auto_cars add column price_book double(10,2) not null default 0.0 comment '定金' after price_car;
|
||||
alter table lc_auto_cars
|
||||
add column v_id int unsigned not null default '0' comment '车型id' after s_id,
|
||||
add column cor_id int unsigned not null default '0' comment '车身颜色id' after v_id,
|
||||
add column incor_id int unsigned not null default '0' comment '内饰颜色' after cor_id;
|
||||
alter table lc_auto_cars modify attrs char(30) not null default '' comment '属性组合:{type0id}_{type1id}_{type2id}';
|
||||
alter table lc_auto_cars drop index attrs;
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
||||
Reference in New Issue
Block a user