From 01c871894f7af8a68affe95bd59de260af088fd7 Mon Sep 17 00:00:00 2001 From: qianhy Date: Mon, 3 Apr 2023 16:42:56 +0800 Subject: [PATCH] cost add accident,350600 loan about --- admin/controllers/items/Cost.php | 1 + admin/controllers/receiver/orderv2/Orders.php | 13 +- admin/views/items/cost/get.php | 109 ++++++++++++++- api/controllers/plan/Order.php | 131 ++++++++++++------ common/models/items/Items_cost_model.php | 18 ++- 5 files changed, 225 insertions(+), 47 deletions(-) diff --git a/admin/controllers/items/Cost.php b/admin/controllers/items/Cost.php index 7fa6942a..119eaded 100644 --- a/admin/controllers/items/Cost.php +++ b/admin/controllers/items/Cost.php @@ -286,6 +286,7 @@ class Cost extends HD_Controller{ 'biz_type' => $biz['type'], 'biz_type_name' => $this->biz_model->type_ary($biz['type']), 'biz_name' => $biz['biz_name'], + 'biz_type_force' => $biz['type'] == 3 && $biz['city_id'] == 350600 ? 1 : 0, # 23-04-03: 贷款, 350600 代理店按所在城市的品牌店处理 'admin_name' => $admin['uname'], 'order_time' => date('Y-m-d',$order_row['c_time']), 'promotion_json' => $promotion_json, diff --git a/admin/controllers/receiver/orderv2/Orders.php b/admin/controllers/receiver/orderv2/Orders.php index b0fb7445..cb413116 100644 --- a/admin/controllers/receiver/orderv2/Orders.php +++ b/admin/controllers/receiver/orderv2/Orders.php @@ -1329,19 +1329,26 @@ class Orders extends HD_Controller } if ($result) { $img_data = $this->receiver_order_datas_model->get(['o_id'=>$row['id']]); - $img_data_jsondata = json_decode($img_data['jsondata'],true); $insurance_img = json_decode($img_data['insurance_img'],true); $business_img = json_decode($img_data['business_img'],true); + $accident_img = json_decode($img_data['accident_img'],true); $insurance_img['product'] = $params['insurance_product']; $insurance_img['price'] = $params['insurance_price']; $business_img['product'] = $params['business_product']; $business_img['price'] = $params['business_price']; + $accident_img['product'] = $params['accident_title']; + $accident_img['price'] = $params['accident_price']; + + # 23-04-03: close accident_title, accident_price + /*$img_data_jsondata = json_decode($img_data['jsondata'],true); $img_data_jsondata['accident_title'] = $params['accident_title']; - $img_data_jsondata['accident_price'] = $params['accident_price']; + $img_data_jsondata['accident_price'] = $params['accident_price'];*/ + $up_data = [ 'insurance_img' => json_encode($insurance_img,JSON_UNESCAPED_UNICODE), 'business_img' => json_encode($business_img,JSON_UNESCAPED_UNICODE), - 'jsondata' => json_encode($img_data_jsondata,JSON_UNESCAPED_UNICODE) + 'accident_img' => json_encode($accident_img,JSON_UNESCAPED_UNICODE), + #'jsondata' => json_encode($img_data_jsondata,JSON_UNESCAPED_UNICODE) ]; $this->receiver_order_datas_model->update($up_data,['o_id'=>$row['id']]); return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); diff --git a/admin/views/items/cost/get.php b/admin/views/items/cost/get.php index 19eb3c6d..ff4c8cc1 100644 --- a/admin/views/items/cost/get.php +++ b/admin/views/items/cost/get.php @@ -271,7 +271,7 @@
-
+
@@ -320,6 +320,27 @@
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
@@ -327,7 +348,7 @@
- +
@@ -491,6 +512,90 @@
+
+
+ 水平业务 + + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
整车合计 diff --git a/api/controllers/plan/Order.php b/api/controllers/plan/Order.php index 8ac5e41a..7a48ab0e 100644 --- a/api/controllers/plan/Order.php +++ b/api/controllers/plan/Order.php @@ -576,7 +576,9 @@ class Order extends CI_Controller{ $srv_json_cost = json_decode($cost['srv_json'], true); echo "get cost:
"; echo $this->items_cost_model->db->last_query()."
"; - echo "

"; + if($debug){ + echo("

"); + } } $money_json = json_decode($item['money_json'],true); @@ -672,11 +674,14 @@ class Order extends CI_Controller{ $img_data = $this->receiver_order_datas_model->get(['o_id'=>$item['id'],'status>='=>0]); $insurance_img = json_decode($img_data['insurance_img'],true); $business_img = json_decode($img_data['business_img'],true); + $accident_img = json_decode($img_data['accident_img'],true); if ($biz['type']==1 && $srv_if_insure){ $srv_json['insurance_price'] = $insurance_img['price'] ? $insurance_img['price'] : 0; $srv_json['insurance_product'] = $insurance_img['product'] ? $insurance_img['product'] : ''; $srv_json['business_price'] = $business_img['price'] ? $business_img['price'] : 0; $srv_json['business_product'] = $business_img['product'] ? $business_img['product'] : ''; + $srv_json['accident_price'] = $accident_img['price'] ? $accident_img['price'] : 0; + $srv_json['accident_title'] = $accident_img['product'] ? $accident_img['product'] : ''; if ($debug){ echo "get order_datas - 保险 img_data:
"; echo $this->receiver_order_datas_model->db->last_query()."
"; @@ -686,6 +691,8 @@ class Order extends CI_Controller{ echo "insurance_product: {$srv_json['insurance_product']}"."
"; echo "business_price: {$srv_json['business_price']}"."
"; echo "business_product: {$srv_json['business_product']}"."
"; + echo "accident_price: {$srv_json['accident_price']}"."
"; + echo "accident_title: {$srv_json['accident_title']}"."
"; echo "

"; } } @@ -694,14 +701,6 @@ class Order extends CI_Controller{ $srv_json['insurance_ins_price'] = $srv_json['insurance_fd'] = 0; if($biz['type']==1 && $srv_if_insure && $insurance_img && $insurance_img['product']){ $time = strtotime($insurance_img['date']); - /*$where = [ - 'biz_id' => $item['biz_id'], - 'title' => $insurance_img['product'], - 'type' => 2, - "json_extract(jsondata, '$.type') = '2'" => null, - "json_extract(jsondata, '$.s_time') >= '{$time}'" => null, - "json_extract(jsondata, '$.e_time') <= '{$time}'" => null - ];*/ $insure_product = $this->cost_insure_product($supplier2, $insurance_img['product']); $where = [ 'biz_id' => $item['biz_id'], @@ -755,14 +754,6 @@ class Order extends CI_Controller{ $srv_json['business_ins_price'] = $srv_json['business_fd'] = 0; if($biz['type']==1 && $srv_if_insure && $business_img && $business_img['product']){ $time = strtotime($business_img['date']); - /*$where = [ - 'biz_id' => $item['biz_id'], - 'title' => $business_img['product'], - 'type' => 2, - "json_extract(jsondata, '$.type') = '1'" => null, - "json_extract(jsondata, '$.s_time') >= '{$time}'" => null, - "json_extract(jsondata, '$.e_time') <= '{$time}'" => null - ];*/ $insure_product = $this->cost_insure_product($supplier2, $business_img['product']); $where = [ 'biz_id' => $item['biz_id'], @@ -812,28 +803,74 @@ class Order extends CI_Controller{ } } + //意外险 + $srv_json['accident_ins_price'] = $srv_json['accident_fd'] = 0; + if($biz['type']==1 && $srv_if_insure && $accident_img && $accident_img['product']){ + $time = strtotime($accident_img['date']); + $insure_product = $this->cost_insure_product($supplier2, $accident_img['product']); + $where = [ + 'biz_id' => $item['biz_id'], + 'title' => $insure_product, + 'status' => 1, + 'type' => 2, + "json_extract(jsondata, '$.type') = '3'" => null, + "json_extract(jsondata, '$.s_time') <= '{$time}'" => null, + "json_extract(jsondata, '$.e_time') >= '{$time}'" => null + ]; + $bis_fd_row = $this->biz_settle_srv_model->get($where); + if ($debug){ + echo "get 意外险配置 :
"; + if ($insure_product != $accident_img['product']){ + echo "{$accident_img['product']} -> {$insure_product}"."
"; + } + echo $this->biz_settle_srv_model->db->last_query()."
"; + var_dump($bis_fd_row); + echo "

"; + } + if(!$bis_fd_row){ + $where = [ + 'biz_id' => $item['biz_id'], + 'title' => $insure_product, + 'status' => 1, + 'type' => 2, + 'is_def' => 1, + "json_extract(jsondata, '$.type') = '3'" => null, + ]; + $bis_fd_row = $this->biz_settle_srv_model->get($where); + if ($debug){ + echo "get 意外险配置(默认) :
"; + echo $this->biz_settle_srv_model->db->last_query()."
"; + var_dump($bis_fd_row); + echo "

"; + } + } + $bis_fd_jsondata = json_decode($bis_fd_row['jsondata'],true); + $srv_json['accident_fd'] = $bis_fd_jsondata['rebate'] ? $bis_fd_jsondata['rebate'] : 0; + $bis_fd = $bis_fd_jsondata['rebate']/100; + $srv_json['accident_ins_price'] = floatval($accident_img['price'])*$bis_fd; + if ($debug){ + echo "get 意外险返点:
"; + echo "accident_fd: {$srv_json['accident_fd']}"."
"; + echo "accident_ins_price: {$srv_json['accident_ins_price']}"."
"; + echo "

"; + } + } + //挂牌 $srv_json['fee_carno'] = $money_json['fee_carno'] ? $money_json['fee_carno'] : 0; $srv_json['cb_fee_carno'] = 0; if($biz['type']==1 && $srv_if_num){ - /*$where = [ - 'biz_id' => $item['biz_id'], - 'type' => 1, - 'status' => 1, - 's_effect_time>=' => date('Y-m-01',strtotime($item['bill_time'])), - 's_effect_time<=' => date('Y-m-t',strtotime($item['bill_time'])), - ]; - */ + # 23-04-03: 350600优先取默认,不再区分二手车 $free_row = array(); - if(!$free_row){ + if(!$free_row && $biz['city_id']!=350600){ $where = [ 'biz_id' => $item['biz_id'], 'type' => 1, 'status' => 1, 's_effect_time<=' => date('Y-m-d',strtotime($item['bill_time'])), ]; - $biz['city_id']==350600 && $if_usedcar && $where['title like "%二手车%"'] = null; - $biz['city_id']==350600 && !$if_usedcar && $where['title not like "%二手车%"'] = null; + #$biz['city_id']==350600 && $if_usedcar && $where['title like "%二手车%"'] = null; + #$biz['city_id']==350600 && !$if_usedcar && $where['title not like "%二手车%"'] = null; $free_row = $this->biz_settle_srv_model->get($where); if ($debug){ echo "get 挂牌配置 :
"; @@ -844,8 +881,8 @@ class Order extends CI_Controller{ } if(!$free_row){ $where = ['biz_id'=>$item['biz_id'],'is_def'=>1,'status'=>1,'type'=>1]; - $biz['city_id']==350600 && $if_usedcar && $where['title like "%二手车%"'] = null; - $biz['city_id']==350600 && !$if_usedcar && $where['title not like "%二手车%"'] = null; + #$biz['city_id']==350600 && $if_usedcar && $where['title like "%二手车%"'] = null; + #$biz['city_id']==350600 && !$if_usedcar && $where['title not like "%二手车%"'] = null; $free_row = $this->biz_settle_srv_model->get($where); if ($debug){ echo "get 挂牌配置(默认) :
"; @@ -869,7 +906,21 @@ class Order extends CI_Controller{ //贷款信息 $srv_json['loan_product'] = ''; $srv_json['loan_srv_price'] = $srv_json['loan_num'] = $srv_json['loan_price'] = 0; - if($biz['type']==1 && $srv_if_finance && $money_json['price_loan']>0){ + # 23-04-03: 贷款, 350600 代理店按所在城市的品牌店处理 + $biz_type_force = $biz_id_force = 0; + if ($biz['type']==3 and $biz['city_id']==350600){ + $biz_force = $this->biz_model->get(['city_id'=>$biz['city_id'], 'type'=>1, 'status'=>1]); + $biz_force && $biz_type_force = 1; + $biz_force && $biz_id_force = $biz_force['id']; + if ($debug){ + echo "350600 代理店按所在城市的品牌店处理:
"; + echo $this->biz_model->db->last_query()."
"; + var_dump($biz_force); + echo "biz_type_force: {$biz_type_force}"."
"; + echo "
"; + } + } + if(($biz['type']==1 || $biz_type_force) && $srv_if_finance && $money_json['price_loan']>0){ $srv_json['loan_price'] = $money_json['price_loan']; $loan_row = $this->order_loans_model->get(['o_id'=>$item['id']]); if ($debug){ @@ -896,20 +947,15 @@ class Order extends CI_Controller{ echo "loan_price (money_json['price_loan']): {$srv_json['loan_price']}"."
"; echo "loan_product: {$srv_json['loan_product']}"."
"; echo "loan_num: {$srv_json['loan_num']}"."
"; + echo "is_tiexi: {$loan_row['is_tiexi']}"."
"; echo "

"; } $profix_loan = $loan_fd = 0; if (!$loan_row['is_tiexi']){ - /*$where = [ - 'biz_id' => $item['biz_id'], - 'type' => 3, - 's_effect_time' => $bill_time_month, - "json_extract(jsondata, '$.finance_id') = '{$finance_id}'" => null, - "json_extract(jsondata, '$.finance_num') = '{$finance_num}'" => null, - ];*/ + $biz_id_param = $biz_id_force ? $biz_id_force : $item['biz_id']; $where = [ - 'biz_id' => $item['biz_id'], + 'biz_id' => $biz_id_param, 'type' => 3, 'status' => 1, 's_effect_time<=' => date('Y-m-d',strtotime($item['bill_time'])), @@ -925,7 +971,7 @@ class Order extends CI_Controller{ echo "

"; } if(!$fd_row){ - $fd_row = $this->biz_settle_srv_model->get(['biz_id'=>$item['biz_id'],'is_def'=>1,'status'=>1,'type'=>3, + $fd_row = $this->biz_settle_srv_model->get(['biz_id'=>$biz_id_param,'is_def'=>1,'status'=>1,'type'=>3, "JSON_UNQUOTE(json_extract(jsondata, '$.supplier_id')) = '{$finance_id}'" => null, "JSON_UNQUOTE(json_extract(jsondata, '$.finance_num')) = '{$finance_num}'" => null, "JSON_UNQUOTE(json_extract(jsondata, '$.rebate')) > 0" => null, @@ -963,6 +1009,11 @@ class Order extends CI_Controller{ } $add_data['srv_json'] = json_encode($srv_json,JSON_UNESCAPED_UNICODE); if ($debug){ + echo "pay_price: {$pay_price}"."
"; + echo "need_price: {$need_price}"."
"; + echo "if_pay(pay_price>=need_price ? 1 : 0): {$srv_json['if_pay']}"."
"; + echo "

"; + echo "get add_data :
"; var_dump($add_data); diff --git a/common/models/items/Items_cost_model.php b/common/models/items/Items_cost_model.php index 45b8652f..4b6939a9 100644 --- a/common/models/items/Items_cost_model.php +++ b/common/models/items/Items_cost_model.php @@ -19,6 +19,7 @@ class Items_cost_model extends HD_Model $this->load->model('items/items_model'); $this->load->model('receiver/order/receiver_orders_v2_model'); $this->load->model('auto/auto_business_model'); + $this->load->model("biz/biz_model"); $row = $this->get(['id'=>$id]); if($row){ $item_row = $this->items_model->get(['id'=>$row['item_id']]); @@ -26,7 +27,7 @@ class Items_cost_model extends HD_Model $promotion_json = json_decode($row['promotion_json'],true); $srv_json = json_decode($row['srv_json'],true); - $order_row = $this->receiver_orders_v2_model->get(['id'=>$row['o_id']], 'id, info_json, (select type from lc_biz where id = lc_receiver_orders_v2.biz_id) as biz_type'); + $order_row = $this->receiver_orders_v2_model->get(['id'=>$row['o_id']], 'id, info_json, biz_id, (select type from lc_biz where id = lc_receiver_orders_v2.biz_id) as biz_type'); $biz_type = $order_row['biz_type']; $info_json = json_decode($order_row['info_json'],true); $business_id = $info_json['business_id'] ? $info_json['business_id'] : 0; @@ -55,7 +56,7 @@ class Items_cost_model extends HD_Model $insurance_price = $fee_carno_price = $loan_price = $srv_price = 0; if ($biz_type == 1){ //【保险收入合计】 - $insurance_price = $srv_json['business_ins_price']+$srv_json['insurance_ins_price']-$srv_json['back_price']; + $insurance_price = $srv_json['business_ins_price']+$srv_json['insurance_ins_price']+$srv_json['accident_ins_price']-$srv_json['back_price']; //【挂牌收入合计】 $fee_carno_price = $srv_json['fee_carno'] - $srv_json['cb_fee_carno']; //【按揭收入合计】(按揭综合服务费+按揭解抵服务费+利息补贴收入+金融公司手续费收入+其他收入-其他支出) @@ -69,6 +70,19 @@ class Items_cost_model extends HD_Model $loan_price = $row['loan_price']; $srv_price = $insurance_price+$fee_carno_price+$loan_price; } + elseif ($biz_type == 3){ + # 23-04-03: 贷款, 350600 代理店按所在城市的品牌店处理 + $biz = $this->biz_model->get(['id'=>$order_row['biz_id']]); + if ($biz['city_id']==350600){ + $biz_force = $this->biz_model->get(['city_id'=>$biz['city_id'], 'type'=>1, 'status'=>1]); + if ($biz_force){ + //【按揭收入合计】(按揭综合服务费+按揭解抵服务费+利息补贴收入+金融公司手续费收入+其他收入-其他支出) + $loan_price = $srv_json['loan_srv_price']+$srv_json['loan_offset_price']+$srv_json['loan_subsidy_price']+$srv_json['commission_price']+$srv_json['loan_in_price']-$srv_json['loan_out_price']; + //【水平业务总毛利】(保险收入合计+挂牌收入合计+按揭收入合计+其他收入-其他支出) + $srv_price = $insurance_price+$fee_carno_price+$loan_price+$srv_json['other_in_price']-$srv_json['other_out_price']; + } + } + } //【单车总毛利】(整车采购毛利+水平业务总毛利) $car_price = $car_profit_price + $srv_price;