cost add accident,350600 loan about

This commit is contained in:
qianhy
2023-04-03 16:42:56 +08:00
committed by lccsw
parent 8f94583e91
commit 01c871894f
5 changed files with 225 additions and 47 deletions
+1
View File
@@ -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,
+10 -3
View File
@@ -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, '保存成功');
+107 -2
View File
@@ -271,7 +271,7 @@
</div>
<div class="am-panel-bd am-g" style="margin-top: 10px;margin-bottom: 10px;">
<div v-if="info.srv_json.srv_if_insure=='1'" class="am-form-inline">
<div class="am-form-group am-u-lg-4">
<div class="am-form-group am-u-lg-12">
<label class="am-para-label label-width"><span class="span-bold">保险公司:</span></label>
<div class="am-para-input">
<!-- <label class="am-para-label-con">{{info.srv_json.business_product}}</label>-->
@@ -320,6 +320,27 @@
<input type="number" v-model="info.srv_json.insurance_ins_price" style="width: 150px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">意外险金额:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.accident_price" style="width: 150px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">意外险返点:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.accident_fd" style="width: 150px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">意外险佣金:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.accident_ins_price" style="width: 150px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">客户退点金额:</span></label>
<div class="am-para-input">
@@ -327,7 +348,7 @@
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold" title="【保险收入合计】(商业险佣金+交强险佣金-客户退点金额">保险收入合计<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<label class="am-para-label label-width"><span class="span-bold" title="【保险收入合计】(商业险佣金+交强险佣金+意外险佣金-客户退点金额">保险收入合计<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.insurance_price}}</label>
</div>
@@ -491,6 +512,90 @@
</div>
</div>
</div>
<div v-if="info.biz_type_force == '1'" class="am-panel am-panel-default">
<div class="am-panel-hd">
<span style="font-size: 20px">水平业务</span>
<span style="float:right;margin-top:5px">
</span>
</div>
<div class="am-panel-bd am-g" style="margin-top: 10px;margin-bottom: 10px;">
<div v-if="info.payway=='0' && info.srv_json.srv_if_finance=='1'" class="am-form-inline">
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">按揭银行:</span></label>
<div class="am-para-input">
<input type="text" v-model="info.srv_json.loan_product" style="width: 200px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">按揭金额:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.loan_price" style="width: 150px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">按揭期数:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.loan_num" style="width: 150px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">按揭服务费:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.loan_srv_price" style="width: 150px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">解抵服务费:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.loan_offset_price" style="width: 150px">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">利息补贴收入:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.loan_subsidy_price" style="width: 150px">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">其他收入金额:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.loan_in_price" style="width: 150px">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">其他支出金额:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.loan_out_price" style="width: 150px">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">&nbsp;贴息:</span></label>
<div class="am-para-input">
<label class="am-para-label-con" v-if="info.srv_json.loan_is_tiexi==1"></label>
<label class="am-para-label-con" v-else></label>
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">按揭手续费收入:</span></label>
<div class="am-para-input">
<input type="number" v-model="info.srv_json.commission_price" style="width: 150px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold" title="【按揭收入合计】(按揭服务费+解抵服务费+利息补贴收入+按揭手续费收入+其他收入金额-其他支出金额)">按揭收入合计<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.loan_price}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">&nbsp;</span></label>
<div class="am-para-input">
<label class="am-para-label-con"></label>
</div>
</div>
</div>
</div>
</div>
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span style="font-size: 20px">整车合计</span>
+91 -40
View File
@@ -576,7 +576,9 @@ class Order extends CI_Controller{
$srv_json_cost = json_decode($cost['srv_json'], true);
echo "get cost: <br>";
echo $this->items_cost_model->db->last_query()."<br>";
echo "<br><br>";
if($debug){
echo("<br><br>");
}
}
$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: <br>";
echo $this->receiver_order_datas_model->db->last_query()."<br>";
@@ -686,6 +691,8 @@ class Order extends CI_Controller{
echo "insurance_product: {$srv_json['insurance_product']}"."<br>";
echo "business_price: {$srv_json['business_price']}"."<br>";
echo "business_product: {$srv_json['business_product']}"."<br>";
echo "accident_price: {$srv_json['accident_price']}"."<br>";
echo "accident_title: {$srv_json['accident_title']}"."<br>";
echo "<br><br>";
}
}
@@ -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 意外险配置 : <br>";
if ($insure_product != $accident_img['product']){
echo "{$accident_img['product']} -> {$insure_product}"."<br>";
}
echo $this->biz_settle_srv_model->db->last_query()."<br>";
var_dump($bis_fd_row);
echo "<br><br>";
}
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 意外险配置(默认) : <br>";
echo $this->biz_settle_srv_model->db->last_query()."<br>";
var_dump($bis_fd_row);
echo "<br><br>";
}
}
$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 意外险返点: <br>";
echo "accident_fd: {$srv_json['accident_fd']}"."<br>";
echo "accident_ins_price: {$srv_json['accident_ins_price']}"."<br>";
echo "<br><br>";
}
}
//挂牌
$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 挂牌配置 : <br>";
@@ -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 挂牌配置(默认) : <br>";
@@ -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 代理店按所在城市的品牌店处理: <br>";
echo $this->biz_model->db->last_query()."<br>";
var_dump($biz_force);
echo "biz_type_force: {$biz_type_force}"."<br>";
echo "<br>";
}
}
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']}"."<br>";
echo "loan_product: {$srv_json['loan_product']}"."<br>";
echo "loan_num: {$srv_json['loan_num']}"."<br>";
echo "is_tiexi: {$loan_row['is_tiexi']}"."<br>";
echo "<br><br>";
}
$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 "<br><br>";
}
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}"."<br>";
echo "need_price: {$need_price}"."<br>";
echo "if_pay(pay_price>=need_price ? 1 : 0): {$srv_json['if_pay']}"."<br>";
echo "<br><br>";
echo "get add_data : <br>";
var_dump($add_data);
+16 -2
View File
@@ -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;