-
diff --git a/api/controllers/plan/Xzcall.php b/api/controllers/plan/Xzcall.php
index a97be2dc..8416b647 100644
--- a/api/controllers/plan/Xzcall.php
+++ b/api/controllers/plan/Xzcall.php
@@ -181,23 +181,31 @@ class Xzcall extends HD_Controller
//更新订单服务id
public function up_srv_ids(){
- $this->load->model('receiver/receiver_service_package_model','package_model');
$page = $this->input->get('page');
$size = $this->input->get('size');
!$page && $page = 1;
!$size && $size = 20;
$where = [
- 'pack_id>' => 0,
- 'srv_ids' => ''
+ "srv_ids like '%3%'" => null
];
- $rows = $this->orders_model->select($where,'id asc',$page,$size);
+ $rows = $this->orders_model->select($where,'id asc',$page,$size,'id,srv_ids,jsondata');
if($rows){
foreach($rows as $item){
- $pack = $this->package_model->get(['id'=>$item['pack_id']]);
$res = false;
- if($pack){
+ $srv_ids_arr = explode(',',$item['srv_ids']);
+ if(in_array(3,$srv_ids_arr)){
+ $jsondata = json_decode($item['jsondata'],true);
+ $jsondata['old_srv_ids'] = $item['srv_ids'];
+ $jsondata['if_fine'] = 1;
+ foreach($srv_ids_arr as $key=>$val){
+ if($val==3){
+ unset($srv_ids_arr[$key]);
+ break;
+ }
+ }
$updata = [
- 'srv_ids' => $pack['srv_ids']
+ 'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE),
+ 'srv_ids' => implode(',',$srv_ids_arr)
];
$res = $this->orders_model->update($updata,['id'=>$item['id']]);
}
diff --git a/api/controllers/wxapp/app/Series.php b/api/controllers/wxapp/app/Series.php
index 6d72ceff..0676eb90 100644
--- a/api/controllers/wxapp/app/Series.php
+++ b/api/controllers/wxapp/app/Series.php
@@ -195,10 +195,13 @@ class Series extends Wxapp{
if(!$car){
throw new Exception('当前车型暂无库存', ERR_PARAMS_ERROR);
}
+ $dis_fine_money = $car['price_fine_floor']>0 && $car['price_fine']-$car['price_fine_floor']>0 ? $car['price_fine']-$car['price_fine_floor'] : 0;
$data = [
- 'price' => $car['price_car'] ? $car['price_car'] : 0,
- 'deposit' => $car['price_book'] ? $car['price_book'] : 0,
- 'dis_money' => $car['price_car'] - $car['price_floor']
+ 'price' => $car['price_car'] ? floatval($car['price_car']) : 0,
+ 'deposit' => $car['price_book'] ? floatval($car['price_book']) : 0,
+ 'dis_money' => $car['price_car'] - $car['price_floor'],
+ 'fine_money' => floatval($car['price_fine']),
+ 'dis_fine_money' => $dis_fine_money,
];
return $data;
}
diff --git a/api/controllers/wxapp/licheb/Cusorder.php b/api/controllers/wxapp/licheb/Cusorder.php
index 0d1da16d..a2938d9a 100644
--- a/api/controllers/wxapp/licheb/Cusorder.php
+++ b/api/controllers/wxapp/licheb/Cusorder.php
@@ -79,6 +79,8 @@ class Cusorder extends Wxapp{
$finance_id = $this->input_param('finance_id');
$inten_money = floatval($this->input_param('inten_money'));//意向金
$disc_money = floatval($this->input_param('disc_money'));//优惠金额
+ $disc_fine_money = floatval($this->input_param('disc_fine_money'));//精品优惠金额
+ $if_fine = $this->input_param('if_fine');
$srv_ids = $this->input_param('srv_ids');
$fine_ids = $this->input_param('fine_ids');
@@ -123,7 +125,7 @@ class Cusorder extends Wxapp{
}else{
if($disc_money) throw new Exception('当前车型没有优惠额度', API_CODE_FAIL);
}
- $total_dis_money = $disc_money; //总优惠金额包含精品
+ $total_dis_money = $disc_money; //总优惠金额包含赠送精品
if(!$payway){ //分期
$finance_row = $this->sys_finance_model->get(['id'=>$finance_id,'status'=>1]);
if(!$finance_row){
@@ -185,6 +187,9 @@ class Cusorder extends Wxapp{
$cardid && $info_json['c_cardid'] = $cardid;
$address && $info_json['c_address'] = $address;
$info_json && $data['info_json'] = json_encode($info_json,JSON_UNESCAPED_UNICODE);
+ $jsondata = [];
+ $jsondata['if_fine'] = $if_fine ? 1 : 0;
+ $data['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
$finance_row && $data['finance_id'] = $finance_row['id'];
//获取金额json数据
$orders_entity = new Orders_entity();
@@ -195,7 +200,8 @@ class Cusorder extends Wxapp{
'price_fine' => $car_row['price_fine'],
'price_discount' =>$disc_money ? $disc_money : 0,
'price_intention' => $inten_money ? $inten_money : 0,
- 'price_finance' => $series_row['brand_id'] == 4 ? $orders_entity::PRICE_FINANCE_NZ : $orders_entity::PRICE_FINANCE
+ 'price_finance' => $series_row['brand_id'] == 4 ? $orders_entity::PRICE_FINANCE_NZ : $orders_entity::PRICE_FINANCE,
+ 'price_fine_discount' => $disc_fine_money ? $disc_fine_money : 0
];
//获取挂牌价
if($series_row['brand_id']==3){ //狸车品牌写死挂牌费用0.01 测试用
@@ -374,9 +380,11 @@ class Cusorder extends Wxapp{
if(!$row){
throw new Exception('订单不存在', ERR_PARAMS_ERROR);
}
+ $orders_entity = new Orders_entity();
$money_json = json_decode($row['money_json'],true);
$info_json = json_decode($row['info_json'],true);
+ $jsondata = json_decode($row['jsondata'],true);
$brand = $this->auto_brand_model->get(['id'=>$row['brand_id']],'name');
$series = $this->auto_series_model->get(['id'=>$row['s_id']],'name');
@@ -404,7 +412,9 @@ class Cusorder extends Wxapp{
$pack_title = '';
if($row['srv_ids']){
$srv_rows = $this->services_model->select(["id in ({$row['srv_ids']})"=>null],'','','','title');
- $srv_rows && $pack_title = implode('+',array_column($srv_rows,'title'));
+ $srv_title_arr = array_column($srv_rows,'title');
+ $jsondata['if_fine'] && $srv_title_arr[] = '精品尊享包';
+ $srv_rows && $pack_title = implode('+',$srv_title_arr);
}
$car_data = [];
if($row['brand_id'] && $row['s_id'] && $row['v_id']){
@@ -412,20 +422,30 @@ class Cusorder extends Wxapp{
$car_data['车辆名称'] = $brand['name'].$series['name'];
$car_data['车辆级别'] = $version;
$car_data['颜色'] = $color;
- $car_data['车辆合同售价'] = $money_json['price_discount'] ? $row['price']-$money_json['price_discount'] : $row['price'];
+ $car_data['车辆平台售价'] = $money_json['price_discount'] ? $row['price']-$money_json['price_discount'] : $row['price'];
$money_json['price_discount'] && $car_data['优惠金额'] = $money_json['price_discount'];
$car_data['定金'] = $row['deposit'];
$car_data['代办包'] = $pack_title;
- $car_data['购车主体'] = $row['main_type'] ? '公司' : '个人';
- $car_data['是否委托'] = $row['ifentrust'] ? '是' : '否';
+ //服务费
+ $srv_data = $orders_entity->order_srv_money($row['id'],1);
+ if($srv_data['total']>0){
+ $car_data['代办费']['value'] = sprintf('%.2f',$srv_data['total']);
+ foreach($srv_data['list'] as $val){
+ $car_data['代办费']['list'][$val['title']] = sprintf('%.2f',$val['money']);
+ }
+ }
if($row['ifentrust']){
+ $car_data['是否委托'] = '是';
$car_data['委托人姓名'] = $info_json['entrust_name'] ? $info_json['entrust_name'] : '';
$car_data['委托人手机号'] = $info_json['entrust_mobile'] ? $info_json['entrust_mobile'] : '';
$car_data['委托人身份证'] = $info_json['entrust_idcard'] ? $info_json['entrust_idcard'] : '';
}
+ if($row['ifentrust'] && $row['main_type']){
+ $car_data['购车主体'] = '公司';
+ }
}
- $info_json['c_address'] && $car_data['地址'] = $info_json['c_address'];
$info_json['c_cardid'] && $car_data['身份证号'] = $info_json['c_cardid'];
+ $info_json['c_address'] && $car_data['地址'] = $info_json['c_address'];
if(!$row['payway']){
$finance_row = $this->sys_finance_model->get(['id'=>$row['finance_id']],'title');
$car_data['金融产品'] = $finance_row['title'];
@@ -468,7 +488,6 @@ class Cusorder extends Wxapp{
if($row['status']==5&&in_array($delivery['status'],[0,1])){
$ckcar_status = 1;
}
- $orders_entity = new Orders_entity();
$data = [
'id' => $id,
'name' => $row['name'],
@@ -502,6 +521,8 @@ class Cusorder extends Wxapp{
'edit_status' => $row['status'] > 2 ? 0 : 1,
'status' => $row['status'],
'my_img' => $orders_entity::API_CREATE_PAY_IMG,
+ 'if_fine' => $jsondata['if_fine'] ? 1 : 0,
+ 'disc_fine_money' => $money_json['price_fine_discount'] ? $money_json['price_fine_discount'] : 0
];
$inten_money && $data['inten_money'] = $inten_money;
return $data;
diff --git a/api/controllers/wxapp/licheb/Cusorder2.php b/api/controllers/wxapp/licheb/Cusorder2.php
index 1be1692f..9a75ba9c 100644
--- a/api/controllers/wxapp/licheb/Cusorder2.php
+++ b/api/controllers/wxapp/licheb/Cusorder2.php
@@ -133,6 +133,8 @@ class Cusorder2 extends Wxapp{
$delry_time = $this->input_param('delry_time');
$finance_id = $this->input_param('finance_id');
$disc_money = floatval($this->input_param('disc_money'));//优惠金额
+ $disc_fine_money = floatval($this->input_param('disc_fine_money'));//精品优惠金额
+ $if_fine = $this->input_param('if_fine');
$srv_ids = $this->input_param('srv_ids');
$fine_ids = $this->input_param('fine_ids');
@@ -222,10 +224,15 @@ class Cusorder2 extends Wxapp{
$money_json['price_insure'] = $car_row['price_insure'];
$money_json['price_fine'] = $car_row['price_fine'];
$money_json['price_discount'] = $disc_money;
+ $money_json['price_fine_discount'] = $disc_fine_money;
$orders_entity = new Orders_entity();
$money_json['price_finance'] = $series_row['brand_id'] == 4 ? $orders_entity::PRICE_FINANCE_NZ : $orders_entity::PRICE_FINANCE;
$data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE);
+ $jsondata = json_decode($row['jsondata'],true);
+ $jsondata['if_fine'] = $if_fine ? 1 : 0;
+ $data['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
+
$result = $this->orders_model->update($data,['id'=>$row['id']]);
if($result){
$orders_entity->edit_order($data,$row,$this->session['uid'],$this->session['uname']);
diff --git a/api/controllers/wxapp/licheb/Protocol.php b/api/controllers/wxapp/licheb/Protocol.php
index 528df939..696397fe 100644
--- a/api/controllers/wxapp/licheb/Protocol.php
+++ b/api/controllers/wxapp/licheb/Protocol.php
@@ -97,6 +97,7 @@ class Protocol extends CI_Controller{
$services = [];
if($row){
$money_json = json_decode($row['money_json'],true);
+ $jsondata = json_decode($row['jsondata'],true);
//获取门店信息
$biz = $this->biz_model->get(['id'=>$row['biz_id']]);
if($biz['srv_company_id']){
@@ -104,7 +105,6 @@ class Protocol extends CI_Controller{
}else{
$row['company'] = $this->sys_company_model->get(["title like '%服务%'"=>null,'status'=>1]);
}
- $is_insure = false;
if($row['srv_ids']){
$money_json = json_decode($row['money_json'],true);
$service_rows = $this->services_model->select(["id in ({$row['srv_ids']})"=>null],'','','','id,title,field_name');
@@ -120,12 +120,18 @@ class Protocol extends CI_Controller{
}
$srv_id_arr = explode(',',$row['srv_ids']);
- $is_insure = in_array(1,$srv_id_arr) ? true : false;
+ }
+ if($jsondata['if_fine']){ //选择精品包
+ $fine_price = $money_json['price_fine_discount'] ? $money_json['price_fine'] - $money_json['price_fine_discount'] : $money_json['price_fine'];
+ $services[] = [
+ 'id' => '',
+ 'title' => '精品尊享包',
+ 'money' => $fine_price
+ ];
}
$this->load->library('receiver/orders_entity');
$srv_price = $this->orders_entity->order_srv_money($row['id']);
}
- $row['is_insure'] = $is_insure;
$row['services'] = $services;
$row['srv_price'] = $srv_price;
$row['info_json'] = json_decode($row['info_json'],true);
@@ -328,7 +334,9 @@ class Protocol extends CI_Controller{
//获取修改前数据
$opt_row = $this->receiver_order_oplogs_model->select(['order_id'=>$row['id'],'type'=>3],'id desc',1,1);//最后修改日志
$opt_row = json_decode($opt_row[0]['log_json'],true);
+ $old_jsondata = json_decode($opt_row['jsondata'],true);
$money_json = json_decode($row['money_json'],true);
+ $jsondata = json_decode($row['jsondata'],true);
//获取门店信息
$biz = $this->biz_model->get(['id'=>$row['biz_id']]);
if($biz['srv_company_id']){
@@ -338,12 +346,16 @@ class Protocol extends CI_Controller{
}
if($row['srv_ids']){
$service_rows = $this->services_model->select(["id in ({$row['srv_ids']})"=>null],'','','','title');
- $services = implode(',',array_column($service_rows,'title'));
+ $service_array = array_column($service_rows,'title');
}
+ $jsondata['if_fine'] && $service_array[]='精品尊享包';
+ $services = implode(',',$service_array);
if($opt_row['srv_ids']){
$service_rows = $this->services_model->select(["id in ({$opt_row['srv_ids']})"=>null],'','','','title');
- $old_services = implode(',',array_column($service_rows,'title'));
+ $old_service_array = array_column($service_rows,'title');
}
+ $old_jsondata['if_fine'] && $old_service_array[]='精品尊享包';
+ $old_services = implode(',',$old_service_array);
$this->load->library('receiver/orders_entity');
$srv_price = $this->orders_entity->order_srv_money($row['id']);
}
diff --git a/api/controllers/wxapp/licheb/Services.php b/api/controllers/wxapp/licheb/Services.php
index 95d3f3d1..64d17ce8 100644
--- a/api/controllers/wxapp/licheb/Services.php
+++ b/api/controllers/wxapp/licheb/Services.php
@@ -33,7 +33,9 @@ class Services extends Wxapp{
$order_row = $this->orders_model->get(['id'=>$id]);
$row = $this->customers_model->get(['id'=>$cus_id],'biz_id');
$car_row = $this->auto_cars_model->get(['s_id'=>$s_id,'v_id'=>$v_id,'status'=>1],'price_insure,price_fine');
- $where = [];
+ $where = [
+ 'id!=' => 3
+ ];
$payway && $where['id !='] = 4; //全款不显示金融
$count = $this->services_model->count($where);
$list = [];
@@ -65,7 +67,7 @@ class Services extends Wxapp{
$list[] = [
'id' => $val['id'],
'title' => $val['title'],
- 'price' => $price_arr[$field_arr[1]] ? $price_arr[$field_arr[1]] : 0
+ 'price' => $price_arr[$field_arr[1]] && $field_arr[1]!='price_insure' ? $price_arr[$field_arr[1]] : 0
];
}
}
diff --git a/api/libraries/liche/Progressopt.php b/api/libraries/liche/Progressopt.php
index 8ce8340a..4bdde4b2 100644
--- a/api/libraries/liche/Progressopt.php
+++ b/api/libraries/liche/Progressopt.php
@@ -89,7 +89,7 @@ class Progressopt{
'brand_id>' => 0,
"(mobile='{$mobile}' or (ifentrust=1 and json_extract(info_json,'$.entrust_mobile')='{$mobile}'))" => null
];
- $rows = $this->ci->orders_model->select($where,'id asc','','','id,name,payway,money_json,status,s_id,v_id,cor_id,incor_id,srv_ids');
+ $rows = $this->ci->orders_model->select($where,'id asc','','','id,name,payway,money_json,status,s_id,v_id,cor_id,incor_id,srv_ids,jsondata');
$progress_list = [];
if($rows){
foreach($rows as $order){
@@ -105,7 +105,9 @@ class Progressopt{
$opt_row = $this->ci->receiver_order_oplogs_model->select(['order_id'=>$order['id'],'type'=>3],'id desc',1,1);//最后修改日志
$opt_row = json_decode($opt_row[0]['log_json'],true);
$opt_money_json = json_decode($opt_row['money_json'],true);
+ $opt_jsondata = json_decode($opt_row['jsondata'],true);
$money_json = json_decode($order['money_json'],true);
+ $jsondata = json_decode($order['jsondata'],true);
$progressOpt = [];
foreach($progress_arr as $item){
$imgs = [];
@@ -129,6 +131,18 @@ class Progressopt{
if($opt_row['srv_ids']!=$order['srv_ids']){
$need_resign_agent = true; //需要签服务补充协议
}
+ //修改精品
+ if($jsondata['if_fine']!=$opt_jsondata['if_fine']){
+ $need_resign_agent = true; //需要签服务补充协议
+ }
+ if($jsondata['if_fine'] && $opt_jsondata['if_fine']){
+ $price_fine = $money_json['price_fine_discount'] ? $money_json['fine_price'] - $money_json['price_fine_discount'] : $money_json['fine_price'];
+ $opt_price_fine = $opt_money_json['price_fine_discount'] ? $opt_money_json['fine_price'] - $opt_money_json['price_fine_discount'] : $opt_money_json['fine_price'];
+ if($price_fine!=$opt_price_fine){
+ $need_resign_agent = true; //需要签服务补充协议
+ }
+ }
+
if($need_resign_car && !$car_count){
$url = '/pages/mine/signContract/maiMaiBu?id='.$order['id'];
}elseif($need_resign_agent && !$agent_count){
diff --git a/common/libraries/receiver/Orders_entity.php b/common/libraries/receiver/Orders_entity.php
index 307be094..4ee006d9 100644
--- a/common/libraries/receiver/Orders_entity.php
+++ b/common/libraries/receiver/Orders_entity.php
@@ -357,6 +357,19 @@ class Orders_entity{
}
}
}
+ $jsondata = json_decode($this->order_row['jsondata'],true);
+ if($jsondata['if_fine']){ //选择精品包
+ $fine_price = $money_json['price_fine'];
+ if($money_json['price_fine_discount']){ //优惠精品价格
+ $fine_price = $fine_price - $money_json['price_fine_discount'];
+ }
+ $srv_price += $fine_price;
+
+ $list[] = [
+ 'title' => '精品尊享包',
+ 'money' => $fine_price
+ ];
+ }
$result['total'] = $srv_price;
$result['list'] = $list;
return $res_type ? $result:$srv_price;
@@ -549,9 +562,22 @@ class Orders_entity{
//修改优惠金额
$money_json = json_decode($row['money_json'],true);
$new_money_json = json_decode($new_data['money_json'],true);
+ $jsondata = json_decode($row['jsondata'],true);
+ $new_jsondata = json_decode($new_data['jsondata'],true);
if($money_json['price_discount']!=$new_money_json['price_discount']){
$need_resign = true;
}
+ //修改精品
+ if($jsondata['if_fine']!=$new_jsondata['if_fine']){
+ $need_resign = true;
+ }
+ if($jsondata['if_fine'] && $new_jsondata['if_fine']){
+ $price_fine = $money_json['price_fine_discount'] ? $money_json['fine_price'] - $money_json['price_fine_discount'] : $money_json['fine_price'];
+ $new_price_fine = $new_money_json['price_fine_discount'] ? $new_money_json['fine_price'] - $new_money_json['price_fine_discount'] : $new_money_json['fine_price'];
+ if($price_fine!=$new_price_fine){
+ $need_resign = true;
+ }
+ }
if($new_data['payway']!=$row['payway']){ //修改付款方式
$this->ci->load->model('receiver/order/receiver_order_loans_model');
$this->ci->receiver_order_loans_model->delete(['o_id'=>$row['id']]);
@@ -560,18 +586,19 @@ class Orders_entity{
$content = '修改订单信息';
$jsondata = json_encode($row,JSON_UNESCAPED_UNICODE);
$this->add_log($row['id'],$uid,$uname,$content,3,'wxapp',$jsondata); //添加日志
- $this->ci->receiver_order_contracts_model->delete(['o_id'=>$row['id'],'type in (4,5)'=>null]);
- if(!$row['status']){ //未签合同删除旧合同文件并且删除未支付订单
- $this->ci->load->model('app/liche/app_liche_users_model');
- $this->ci->receiver_order_contracts_model->delete(['o_id'=>$row['id']]);
- $userinfo = $this->ci->app_liche_users_model->get(['mobile'=>$row['mobile']]);
- $this->ci->app_liche_orders_model->delete(['o_id'=>$row['id'],'status'=>0,'pid!='=>0]);
- }
+ $this->ci->receiver_order_contracts_model->delete(['o_id'=>$row['id'],'type in (4,5)'=>null]); //删除补充合同
$this->ci->signs_model->update(['status'=>0],['id'=>$sign_row['id']]);
$this->ci->orders_model->update(['status'=>0],['id'=>$row['id']]);
}
}else{
- $this->ci->signs_model->add(['o_id'=>$row['id'],'c_time'=>time()]);
+ if($sign_row){ //未签合同删除旧合同文件并且删除未支付订单
+ $this->ci->load->model('app/liche/app_liche_users_model');
+ $this->ci->receiver_order_contracts_model->delete(['o_id'=>$row['id']]);
+ $userinfo = $this->ci->app_liche_users_model->get(['mobile'=>$row['mobile']]);
+ $this->ci->app_liche_orders_model->delete(['o_id'=>$row['id'],'status'=>0,'pid!='=>0]);
+ }else{
+ $this->ci->signs_model->add(['o_id'=>$row['id'],'c_time'=>time()]);
+ }
}
}
/**
diff --git a/sql/receiver/order.sql b/sql/receiver/order.sql
index cf993e7c..b76b9b3f 100644
--- a/sql/receiver/order.sql
+++ b/sql/receiver/order.sql
@@ -159,8 +159,9 @@ create table lc_receiver_order_signs (
-- Title:订单表
-- Author:lcc
-- Table:lc_receiver_orders
--- 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意向金
+--- 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精品优惠金额
-- ---------------------------
drop table if exists lc_receiver_orders;
create table lc_receiver_orders (