diff --git a/admin/controllers/auto/Attr.php b/admin/controllers/auto/Attr.php index 6589633a..a9c0d335 100644 --- a/admin/controllers/auto/Attr.php +++ b/admin/controllers/auto/Attr.php @@ -16,6 +16,7 @@ class Attr extends HD_Controller $this->load->model('auto/auto_brand_model'); $this->load->model('auto/auto_series_model'); $this->load->model('auto/auto_attr_model'); + $this->load->model('auto/auto_option_model'); } public function index() @@ -105,7 +106,8 @@ class Attr extends HD_Controller $id = $this->input->get('id'); $info = [ - 'title' => '' + 'title' => '', + 'options' => [], ]; if ($id) { $info = $this->auto_attr_model->get(array('id' => $id)); @@ -114,17 +116,20 @@ class Attr extends HD_Controller } $info['jsondata'] = json_decode($info['jsondata'], true); $info['jsondata']['img'] && $info['jsondata']['s_img'] = build_qiniu_image_url($info['jsondata']['img']); + $info['options'] = $info['jsondata']['options'] ? $info['jsondata']['options'] : []; } $brand_id = ''; if ($info['s_id']) { $row_sery = $this->auto_series_model->get(array('id' => $info['s_id'])); $brand_id = $row_sery['brand_id']; } + $options = $this->auto_option_model->select(['status'=>1],'id desc',0,0,'id,title,price'); $type_arr = $this->auto_attr_model->get_type(); !$info['type'] && $info['type'] = 0; $info['brand_id'] = $brand_id; !$info['s_id'] && $info['s_id'] = ''; !$info['jsondata']['img'] && $info['jsondata']['img'] = ''; + $this->data['options'] = $options; $this->data['type_arr'] = $type_arr; $this->data['info'] = $info; $this->data['_title'] = $id ? '编辑' : '新增'; @@ -146,6 +151,7 @@ class Attr extends HD_Controller 'type' => $post['type'], 'c_time' => time() ]; + $post['jsondata']['options'] = $post['options'] ? $post['options'] : []; $post['jsondata'] && $add_data['jsondata'] = json_encode($post['jsondata'], JSON_UNESCAPED_UNICODE); $result = $this->auto_attr_model->add($add_data); if (!$result) { @@ -172,6 +178,7 @@ class Attr extends HD_Controller 's_id' => $post['s_id'], 'type' => $post['type'], ]; + $post['jsondata']['options'] = $post['options'] ? $post['options'] : []; $post['jsondata'] && $update['jsondata'] = json_encode($post['jsondata'], JSON_UNESCAPED_UNICODE); $result = $this->auto_attr_model->update($update, ['id' => $row['id']]); if (!$result) { diff --git a/admin/controllers/auto/Options.php b/admin/controllers/auto/Options.php new file mode 100644 index 00000000..094fff81 --- /dev/null +++ b/admin/controllers/auto/Options.php @@ -0,0 +1,192 @@ +load->model('auto/auto_option_model'); + $this->load->model('auto/auto_brand_model'); + $this->load->model('auto/auto_series_model'); + } + + public function index() + { + $this->lists(); + } + + public function lists() + { + $params = $this->input->get(); + !$params['s_id'] && $params['s_id'] = ''; + !$params['brand_id'] && $params['brand_id'] = ''; + $page = $this->input->get('page'); + !$page && $page = 1; + $size = 20; + $where["status > -1"] = null; + $params['title'] && $where["title like '%{$params['title']}%'"] = null; + + //获取品牌map + $where_brand = array('status > -1' => null); + $map_brand = $this->auto_brand_model->map_brand($where_brand); + + $params['brand_id'] && $where['brand_id'] = intval($params['brand_id']); + $params['s_id'] && $where['s_id'] = intval($params['s_id']); + $count = $this->auto_option_model->count($where); + + $list = []; + if($count){ + $status_arr = $this->auto_option_model->get_status(); + $rows = $this->auto_option_model->select($where,'id desc',$page,$size); + $b_rows = $this->auto_brand_model->get_map_by_ids(array_column($rows,'brand_id')); + $s_rows = $this->auto_series_model->get_map_by_ids(array_column($rows,'s_id')); + foreach ($rows as $item) { + $b_row = $b_rows[$item['brand_id']][0]; + $s_row = $s_rows[$item['s_id']][0]; + $list[] = [ + 'id' => $item['id'], + 'brand_cn' => $b_row['name'], + 'series_cn' => $s_row['name'], + 'title' => $item['title'], + 'price' => $item['price'], + 'status_name' => $status_arr[$item['status']], + 'status' => $item['status'], + 'c_time' => date('Y-m-d H:i:s',$item['c_time']) + ]; + } + } + $this->data['lists'] = $list; + $this->data['params'] = $params; + $this->data['brandAry'] = $this->auto_brand_model->map_brand_list($map_brand); + $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); + $this->data['_title'] = '选装管理'; + $this->show_view('auto/options/lists', true); + } + + public function get() + { + $id = $this->input->get('id'); + + $info = [ + 'title' => '', + 'options' => [], + 'brand_id' => 0, + 's_id' => 0 + ]; + if ($id) { + $info = $this->auto_option_model->get(array('id' => $id)); + if (!$info) { + return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); + } + $info['brand_id'] = " {$info['brand_id']}"; + } + //获取品牌map + $where_brand = array('status > -1' => null); + $map_brand = $this->auto_brand_model->map_brand($where_brand); + $this->data['brandAry'] = $this->auto_brand_model->map_brand_list($map_brand); + $this->data['info'] = $info; + $this->data['_title'] = $id ? '编辑' : '新增'; + return $this->show_view('auto/options/edit',true); + } + + public function add() + { + if (!$this->if_ajax) { + return $this->show_json(SYS_CODE_FAIL, '提交出错!'); + } + $post = $this->input->post(); + if (!$post['title']) { + return $this->show_json(SYS_CODE_FAIL, '标题不能为空'); + } + $add_data = [ + 'title' => $post['title'], + 'price' => floatval($post['price']), + 'brand_id' => intval($post['brand_id']), + 's_id' => intval($post['s_id']), + 'descrip' => $post['descrip'], + 'c_time' => time() + ]; + $result = $this->auto_option_model->add($add_data); + if (!$result) { + return $this->show_json(SYS_CODE_FAIL, '添加失败'); + } + return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); + } + + public function edit() + { + if (!$this->if_ajax) { + return $this->show_json(SYS_CODE_FAIL, '提交出错!'); + } + $post = $this->input->post(); + $row = $this->auto_option_model->get(['id' => $post['id']]); + if (!$row) { + return $this->show_json(SYS_CODE_FAIL, '数据不存在'); + } + if (!$post['title']) { + return $this->show_json(SYS_CODE_FAIL, '标题不能为空'); + } + $update = [ + 'title' => $post['title'], + 'price' => floatval($post['price']), + 'descrip' => $post['descrip'], + 'brand_id' => intval($post['brand_id']), + 's_id' => intval($post['s_id']), + ]; + $result = $this->auto_option_model->update($update, ['id' => $row['id']]); + if (!$result) { + return $this->show_json(SYS_CODE_FAIL, '保存失败'); + } + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + public function del() + { + $id = $this->input->post('id'); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $stauts = $this->input->post('status'); + $where = ['id' => $id]; + $this->auto_option_model->update(['status' => $stauts], $where); + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } + + public function batch() + { + + } + + public function export() + { + + } + + function json_lists() + { + $brand_id = $this->input->get('brand_id'); + $s_id = $this->input->get('s_id'); + $where = [ + 'status'=>1, + 'brand_id' => intval($brand_id) + ]; + $s_id && $where['s_id'] = $s_id; + $lists = []; + $rows = $this->auto_option_model->select($where,'','','','id,title,price'); + if($rows){ + foreach ($rows as $items) { + $lists[] = $items; + } + } + $this->data['lists'] = $lists; + $this->show_json(SYS_CODE_SUCCESS,''); + } +} diff --git a/admin/controllers/items/goods/Goods.php b/admin/controllers/items/goods/Goods.php index 7c140097..27aadcc4 100644 --- a/admin/controllers/items/goods/Goods.php +++ b/admin/controllers/items/goods/Goods.php @@ -432,6 +432,7 @@ class Goods extends HD_Controller $info['company_id'] = $info['brand_id'] = $info['s_id'] = $info['v_id'] = $info['cor_id'] = $info['incor_id'] = 0; $info['if_pack'] = $info['city_id'] = $info['county_id'] = $info['biz_id'] = $info['addr_id'] = ''; $info['status'] = 1; + $info['option_ids'] = []; $autoList[2] = $autoList[3] = $autoList[4] = $autoList[5] = array(); $comList = $this->sys_company_model->select(['status' => 1], '', '', '', 'id,short'); if ($id > 0) { @@ -440,6 +441,7 @@ class Goods extends HD_Controller return $this->show_json(SYS_CODE_FAIL, '商品不存在!'); } $info = $re; + $info['option_ids'] = $info['option_ids'] ? json_decode($info['option_ids'],true) : []; $info['pro_time'] = $re['pro_time'] != '0000-00-00 00:00:00' ? $re['pro_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'] : ''; @@ -634,6 +636,7 @@ class Goods extends HD_Controller } $addData['biz_id'] = $biz_id; $addData['addr_id'] = $addr_id; + $addData['option_ids'] = $info['option_ids'] ? json_encode($info['option_ids']) : json_encode([]); $id = $this->mdItems->add($addData); if (!$id) { return $this->show_json(SYS_CODE_FAIL, '添加失败!'); @@ -806,6 +809,7 @@ class Goods extends HD_Controller } $editData['biz_id'] = $biz_id; $editData['addr_id'] = $addr_id; + $editData['option_ids'] = $info['option_ids'] ? json_encode($info['option_ids']) : json_encode([]); $ret = $this->mdItems->update($editData, array('id' => $info['id'])); if (!$ret) { return $this->show_json(SYS_CODE_FAIL, '修改失败!'); diff --git a/admin/views/auto/attr/edit.php b/admin/views/auto/attr/edit.php index 77b67023..75614983 100755 --- a/admin/views/auto/attr/edit.php +++ b/admin/views/auto/attr/edit.php @@ -59,6 +59,16 @@ + +
+ +
+ + +
+
@@ -73,7 +83,8 @@ info:[], brandAry:[], seryAry:[], - type_arr:[] + type_arr:[], + options:[] }, mounted: function () { this.info = ; @@ -150,6 +161,17 @@ layer.closeAll('loading'); } }); + $.get("/auto/options/json_lists",{'brand_id':nv,'s_id':vm.info.s_id},function (res){ + vm.options = res.data.lists + },'json'); + } + }, + 'info.s_id':function(nv, ov){ + var vm = this; + if(nv > 0){ + $.get("/auto/options/json_lists",{'brand_id':vm.info.brand_id,'s_id':nv},function (res){ + vm.options = res.data.lists + },'json'); } } } diff --git a/admin/views/auto/options/edit.php b/admin/views/auto/options/edit.php new file mode 100755 index 00000000..db9ec606 --- /dev/null +++ b/admin/views/auto/options/edit.php @@ -0,0 +1,113 @@ +
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+ diff --git a/admin/views/auto/options/lists.php b/admin/views/auto/options/lists.php new file mode 100755 index 00000000..83559bb5 --- /dev/null +++ b/admin/views/auto/options/lists.php @@ -0,0 +1,158 @@ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID品牌车系标题价格状态创建时间操作
+ -1) { ?> + + + + | 禁用 + + | 恢复 + + -1) { ?> + | 删除 + +
+
+
+
+ +
+
+
+ + + diff --git a/admin/views/items/goods/edit.php b/admin/views/items/goods/edit.php index 8555c4a8..84630d20 100644 --- a/admin/views/items/goods/edit.php +++ b/admin/views/items/goods/edit.php @@ -96,6 +96,17 @@
+ + +
+
选装包
+ +   +
+ +
@@ -321,7 +332,8 @@ addrAry: [], bizAry: [], fines: [], - modal_fine: {title: '', lists: [], selected: [], page: 1, size: 10, total: 0} + modal_fine: {title: '', lists: [], selected: [], page: 1, size: 10, total: 0}, + options:[] }, mounted: function () { var that = this; @@ -700,6 +712,22 @@ }); } }, + 'info.brand_id': function (nv, ov) { + var vm = this; + if(nv > 0){ + $.get("/auto/options/json_lists",{'brand_id':nv,'s_id':vm.info.s_id},function (res){ + vm.options = res.data.lists + },'json'); + } + }, + 'info.s_id': function (nv, ov) { + var vm = this; + if(nv > 0){ + $.get("/auto/options/json_lists",{'brand_id':vm.info.brand_id,'s_id':nv},function (res){ + vm.options = res.data.lists + },'json'); + } + }, } }); }); diff --git a/api/controllers/wxapp/app/Options.php b/api/controllers/wxapp/app/Options.php new file mode 100644 index 00000000..ae07163e --- /dev/null +++ b/api/controllers/wxapp/app/Options.php @@ -0,0 +1,54 @@ +login_white = array('get');//登录白名单 + $this->check_status = array();//用户状态校验 + $this->check_mobile = array();//需要手机号 + $this->check_headimg =array();//授权微信信息 + $this->load->model('auto/auto_option_model'); + } + + protected function get(){ + $page = $this->input_param('page'); + $size = $this->input_param('size'); + $s_id = $this->input_param('id'); //车系id + !$page && $page = 1; + !$size && $size = 100; + + $where = [ + 'status' => 1, + 's_id' => $s_id + ]; + + $count = $this->auto_option_model->count($where); + $lists = []; + if($count){ + $rows = $this->auto_option_model->select($where,'id desc',$page,$size); + foreach ($rows as $item) { + $lists[] = [ + 'id' => $item['id'], + 'title' => $item['title'], + 'descrip' => $item['descrip'], + 'price' => $item['price'] + ]; + } + } + + $data = [ + 'list' => $lists, + 'total' => $count + ]; + return $data; + } +} \ No newline at end of file diff --git a/api/controllers/wxapp/licheb/CusorderV2.php b/api/controllers/wxapp/licheb/CusorderV2.php index b58e2d64..91988c80 100644 --- a/api/controllers/wxapp/licheb/CusorderV2.php +++ b/api/controllers/wxapp/licheb/CusorderV2.php @@ -36,6 +36,7 @@ class CusorderV2 extends Wxapp $this->load->model('auto/auto_attr_model'); $this->load->model('auto/auto_cars_model'); $this->load->model('auto/auto_business_model'); + $this->load->model('auto/auto_option_model'); $this->load->model("biz/biz_model"); $this->load->model('items/items_model'); @@ -98,6 +99,7 @@ class CusorderV2 extends Wxapp $if_local_bill = $this->input_param('if_local_bill');//是否需要开具本地发票 $if_zero_firstpay = $this->input_param('if_zero_firstpay');//$payway=0下是否0首付;0首付区分:payway==0 && money_json.price_book==0 //$if_zero_firstpay = 1; $deposit = 0; // 模拟0首付 + $optinos_ids = $this->input_param('options_ids');//选装id 数组 $row = $this->customers_model->get(['id' => $cus_id]); $series_row = $this->auto_series_model->get(['id' => $car_id]); @@ -222,6 +224,7 @@ class CusorderV2 extends Wxapp 'price_fine_select' => 0, 'price_color' => $price_color, 'price_coplus' => $price_coplus, + 'price_options' => 0 ]; if ($srv_arr) { foreach ($srv_arr as $item) { @@ -238,6 +241,13 @@ class CusorderV2 extends Wxapp } } } + //选装金额 + if($optinos_ids){ + $data['option_ids'] = json_encode($optinos_ids); + $optinos_ids_str = implode(',',$optinos_ids); + $optinos_ids_str && $optinos_rows = $this->auto_option_model->select(["id in ({$optinos_ids_str})"=>null],'','','','id,price'); + $optinos_rows && $money_json['price_options'] = array_sum(array_column($optinos_rows,'price')); + } $car_json = $money_json; $car_json['delivery_day'] = $business_row['delivery_day']; $data['money_json'] = json_encode($money_json, JSON_UNESCAPED_UNICODE); @@ -371,6 +381,7 @@ class CusorderV2 extends Wxapp $sa = $this->input_param('sa'); //补充协商 $if_local_bill = $this->input_param('if_local_bill');//是否需要开具本地发票 $if_zero_firstpay = $this->input_param('if_zero_firstpay');//$payway=0下是否0首付;0首付区分:payway==0 && money_json.price_book==0 + $optinos_ids = $this->input_param('options_ids');//选装id 数组 $row = $this->orders_model->get(['id' => $id]); $main_type = $row['main_type']; @@ -496,6 +507,14 @@ class CusorderV2 extends Wxapp } } } + $data['option_ids'] = json_encode($optinos_ids); + $money_json['price_options'] = 0; + //选装金额 + if($optinos_ids){ + $optinos_ids_str = implode(',',$optinos_ids); + $optinos_ids_str && $optinos_rows = $this->auto_option_model->select(["id in ({$optinos_ids_str})"=>null],'','','','id,price'); + $optinos_rows && $money_json['price_options'] = array_sum(array_column($optinos_rows,'price')); + } if ($row['c_time'] >= strtotime('2022-04-08 14:43:00')) { $this->ck_money($money_json, $srv_arr, $biz); } @@ -565,6 +584,14 @@ class CusorderV2 extends Wxapp $car_data['委托代办']['list'][$val['title']] = is_numeric($val['money']) ? sprintf("%.2f", $val['money']) : ''; } } + $optinos_ids_str = $row['option_ids'] ? implode(',',json_decode($row['option_ids'],true)) : ''; + if($optinos_ids_str){ + $optinos_rows = $this->auto_option_model->select(["id in ({$optinos_ids_str})"=>null],'','','','id,title,price'); + $car_data['选装']['value'] = sprintf("%.2f", $money_json['price_options']); + foreach ($optinos_rows as $item) { + $car_data['选装']['list'][$item['title']] = is_numeric($item['price']) ? sprintf("%.2f", $item['price']) : ''; + } + } $fines = json_decode($row['fines'], true); if ($fines) { $fines_list = []; @@ -691,6 +718,7 @@ class CusorderV2 extends Wxapp $order_data = $this->receiver_order_datas_model->get(['o_id' => $row['id']], 'sa'); $data['sa'] = $order_data['sa'] ? $order_data['sa'] : ''; $data['refund_status'] = $row['status'] == 2 ? true : false; + $data['option_ids'] = $row['option_ids'] ? json_decode($row['option_ids'],true) : []; return $data; } diff --git a/common/libraries/receiver/Orders_v2_entity.php b/common/libraries/receiver/Orders_v2_entity.php index 814b6c74..6e56acfa 100644 --- a/common/libraries/receiver/Orders_v2_entity.php +++ b/common/libraries/receiver/Orders_v2_entity.php @@ -477,6 +477,9 @@ class Orders_v2_entity{ if($money_json['price_coplus']){ $total_price += $money_json['price_coplus']; } + if($money_json['price_options']){ + $total_price += $money_json['price_options']; + } return $total_price ? $total_price : 0; } diff --git a/common/models/auto/Auto_option_model.php b/common/models/auto/Auto_option_model.php new file mode 100644 index 00000000..13c2f618 --- /dev/null +++ b/common/models/auto/Auto_option_model.php @@ -0,0 +1,21 @@ + '删除',0 => '下架',1 => '正常']; + + public function __construct() + { + parent::__construct($this->table_name, 'default'); + } + + public function get_status(){ + return $this->status_arr; + } +} diff --git a/sql/receiver/order.sql b/sql/receiver/order.sql index 88e42c43..514df3e7 100644 --- a/sql/receiver/order.sql +++ b/sql/receiver/order.sql @@ -161,7 +161,7 @@ create table lc_receiver_order_signs ( -- Table:lc_receiver_orders --- jsondata if_fine 是否选择精品尊享包 -- info_json entrust_name 代办人姓名 entrust_idcard 代办人身份证 name 姓名 sex 性别 nation 民族 birth 出生日期 address 家庭地址 cardid 身份证 c_address 创建时输入的地址 c_cardid 创建时输入的身份证 --- money_json price_car 裸车价 price_book 定金 price_insure 保险价格 price_fine 精品报价 price_finance 金融报价 price_loan贷款金额 price_discount优惠金额 price_intention意向金 price_fine_discount精品优惠金额 price_fine_select精品选装总金额 +-- money_json price_car 裸车价 price_book 定金 price_insure 保险价格 price_fine 精品报价 price_finance 金融报价 price_loan贷款金额 price_discount优惠金额 price_intention意向金 price_fine_discount精品优惠金额 price_fine_select精品选装总金额 price_options选装金额 -- --------------------------- drop table if exists lc_receiver_orders; create table lc_receiver_orders (