cost plan adjust srv about, ordersv2 fixbug if_num if_finance, cost add srv about

This commit is contained in:
qianhy
2023-03-03 14:43:57 +08:00
committed by lccsw
parent 48a14cd74e
commit 2859b70883
3 changed files with 84 additions and 66 deletions
@@ -1546,8 +1546,8 @@ class Orders extends HD_Controller
}
$srv_ids = is_array($new_services) ? array_column($new_services,'id') : [];
$updata = [
'if_insure' => in_array(1,$srv_ids) ? 0 : 1,
'if_num' => in_array(2,$srv_ids) ? 0 : 1,
'if_insure' => in_array(1,$srv_ids) ? 1 : 0,
'if_num' => in_array(2,$srv_ids) ? 1 : 0,
'srv_ids' => json_encode($new_services,JSON_UNESCAPED_UNICODE),
'money_json' => json_encode($money_json,JSON_UNESCAPED_UNICODE)
];
+6 -6
View File
@@ -270,7 +270,7 @@
</span>
</div>
<div class="am-panel-bd am-g" style="margin-top: 10px;margin-bottom: 10px;">
<div class="am-form-inline">
<div v-if="info.srv_json.srv_if_insure=='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">
@@ -333,8 +333,8 @@
</div>
</div>
</div>
<hr class="am-u-lg-12 wp90" style="margin: 10px">
<div class="am-form-inline">
<hr v-if="info.srv_json.srv_if_insure=='1'" class="am-u-lg-12 wp90" style="margin: 10px">
<div v-if="info.srv_json.srv_if_num=='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">
@@ -356,8 +356,8 @@
</div>
</div>
</div>
<hr v-if="info.payway=='0'" class="am-u-lg-12 wp90" style="margin: 10px">
<div v-if="info.payway=='0'" class="am-form-inline">
<hr v-if="info.srv_json.srv_if_num=='1'" class="am-u-lg-12 wp90" style="margin: 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">
@@ -434,7 +434,7 @@
</div>
</div>
</div>
<hr class="am-u-lg-12 wp90" style="margin: 10px">
<hr v-if="info.payway=='0' && info.srv_json.srv_if_finance=='1'" class="am-u-lg-12 wp90" style="margin: 10px">
<div 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>
+76 -58
View File
@@ -508,11 +508,37 @@ class Order extends CI_Controller{
foreach ($rows as $item) {
$if_usedcar = $item['if_usedcar'];
//`if_insure` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否保险(0否 1是)',
//`if_num` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否上牌(0否 1是)',
// if_insure 与 if_num,后台编辑会导致反转,参考接口改用 item['srv_ids'] 判断处理,后序再考虑修复现有数据
$srv_if_insure = $srv_if_num = $srv_if_finance = 0;
$srv_insure = $srv_fee_carno = $srv_loan = 0;
$srv_ids = json_decode($item['srv_ids'],true);
foreach ($srv_ids as $ks) {
$ks['id'] == 1 && $srv_if_insure = 1;
$ks['id'] == 1 && $srv_insure = floatval($ks['price']); # $money_json['price_insure']
$ks['id'] == 2 && $srv_if_num = 1;
$ks['id'] == 2 && $srv_fee_carno = floatval($ks['price']); # $money_json['fee_carno']
$ks['id'] == 4 && $srv_if_finance = 1;
$ks['id'] == 4 && $srv_loan = floatval($ks['price']); # $money_json['price_finance']
}
if ($debug){
echo "finance_id: {$item['finance_id']}"."<br>";
echo "biz_id: {$item['biz_id']}"."<br>";
echo "status: {$item['status']}"."<br>";
echo "if_usedcar: {$if_usedcar}"."<br>";
echo "if_num: {$item['if_num']}"."<br>";
echo "if_insure: {$item['if_insure']}"."<br>";
echo "srv_ids: {$item['srv_ids']}"."<br>";
echo "<br>"."=====srv_ids====="."<br>";
echo "srv_if_insure: {$srv_if_insure}"."<br>";
echo "srv_if_num: {$srv_if_num}"."<br>";
echo "srv_if_finance: {$srv_if_finance}"."<br>";
echo "srv_insure: {$srv_insure}"."<br>";
echo "srv_fee_carno: {$srv_fee_carno}"."<br>";
echo "srv_loan: {$srv_loan}"."<br>";
echo "<br><br>";
}
@@ -537,7 +563,6 @@ class Order extends CI_Controller{
$money_json = json_decode($item['money_json'],true);
$info_json = json_decode($item['info_json'],true);
$bill_time_month = date('Y-m-d',strtotime($item['bill_time']));
$add_data = [
'o_id' => $item['id'],
'price' => $this->orders_v2_entity->total_price($item['id'],$item['money_json']),
@@ -565,6 +590,10 @@ class Order extends CI_Controller{
$srv_json = [];
$recost && $srv_json = $srv_json_cost; // recost要保留原来有可能修改过的srv
$srv_json['srv_if_insure'] = $srv_if_insure;
$srv_json['srv_if_num'] = $srv_if_num;
$srv_json['srv_if_finance'] = $srv_if_finance;
//精品
$srv_json['price_fine_select'] = $money_json['price_fine_select'] ? $money_json['price_fine_select'] : 0;
@@ -617,7 +646,7 @@ 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);
if ($biz['type']==1){
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;
@@ -635,10 +664,9 @@ class Order extends CI_Controller{
}
}
//强险
$srv_json['insurance_ins_price'] = $srv_json['insurance_fd'] = 0;
if($biz['type']==1 && $insurance_img && $insurance_img['product']){
if($biz['type']==1 && $srv_if_insure && $insurance_img && $insurance_img['product']){
$time = strtotime($insurance_img['date']);
/*$where = [
'biz_id' => $item['biz_id'],
@@ -699,7 +727,7 @@ class Order extends CI_Controller{
//商业险
$srv_json['business_ins_price'] = $srv_json['business_fd'] = 0;
if($biz['type']==1 && $business_img && $business_img['product']){
if($biz['type']==1 && $srv_if_insure && $business_img && $business_img['product']){
$time = strtotime($business_img['date']);
/*$where = [
'biz_id' => $item['biz_id'],
@@ -761,7 +789,7 @@ class Order extends CI_Controller{
//挂牌
$srv_json['fee_carno'] = $money_json['fee_carno'] ? $money_json['fee_carno'] : 0;
$srv_json['cb_fee_carno'] = 0;
if($biz['type']==1 && $money_json['fee_carno']>0){
if($biz['type']==1 && $srv_if_num){
/*$where = [
'biz_id' => $item['biz_id'],
'type' => 1,
@@ -830,7 +858,10 @@ class Order extends CI_Controller{
$free_jsondata = json_decode($free_row['jsondata'],true);
$srv_json['cb_fee_carno'] = $free_jsondata['price'] ? $free_jsondata['price'] : 0;
if ($debug){
echo "挂牌返点 cb_fee_carno: {$srv_json['cb_fee_carno']}"."<br>";
echo "挂牌费用 fee_carno: {$srv_json['fee_carno']}"."<br>";
echo "挂牌成本 cb_fee_carno: {$srv_json['cb_fee_carno']}"."<br>";
$fee_carno_price = $srv_json['fee_carno'] - $srv_json['cb_fee_carno'];
echo "挂牌收入合计 fee_carno_price: {$fee_carno_price}"."<br>";
echo "<br><br>";
}
}
@@ -838,7 +869,7 @@ class Order extends CI_Controller{
//贷款信息
$srv_json['loan_product'] = '';
$srv_json['loan_srv_price'] = $srv_json['loan_num'] = $srv_json['loan_price'] = 0;
if($money_json['price_loan']>0){
if($biz['type']==1 && $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){
@@ -867,61 +898,48 @@ class Order extends CI_Controller{
echo "<br><br>";
}
if ($biz['type']==1){
/*$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,
];*/
$where = [
'biz_id' => $item['biz_id'],
'type' => 3,
'status' => 1,
's_effect_time<=' => date('Y-m-d',strtotime($item['bill_time'])),
"JSON_UNQUOTE(json_extract(jsondata, '$.supplier_id')) = '{$finance_id}'" => null,
"JSON_UNQUOTE(json_extract(jsondata, '$.finance_num')) = '{$finance_num}'" => null,
];
$fd_row = $this->biz_settle_srv_model->get($where);
/*$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,
];*/
$where = [
'biz_id' => $item['biz_id'],
'type' => 3,
'status' => 1,
's_effect_time<=' => date('Y-m-d',strtotime($item['bill_time'])),
"JSON_UNQUOTE(json_extract(jsondata, '$.supplier_id')) = '{$finance_id}'" => null,
"JSON_UNQUOTE(json_extract(jsondata, '$.finance_num')) = '{$finance_num}'" => null,
];
$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($fd_row);
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,
"JSON_UNQUOTE(json_extract(jsondata, '$.supplier_id')) = '{$finance_id}'" => null, "JSON_UNQUOTE(json_extract(jsondata, '$.finance_num')) = '{$finance_num}'" => null]);
if ($debug){
echo "get 贷款配置 : <br>";
echo "get 贷款配置(默认) : <br>";
echo $this->biz_settle_srv_model->db->last_query()."<br>";
var_dump($fd_row);
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,
"JSON_UNQUOTE(json_extract(jsondata, '$.supplier_id')) = '{$finance_id}'" => null, "JSON_UNQUOTE(json_extract(jsondata, '$.finance_num')) = '{$finance_num}'" => null]);
if ($debug){
echo "get 贷款配置(默认) : <br>";
echo $this->biz_settle_srv_model->db->last_query()."<br>";
var_dump($fd_row);
echo "<br><br>";
}
}
$fd_jsondata = json_decode($fd_row['jsondata'],true);
$loan_fd = $fd_jsondata['rebate'] ? $fd_jsondata['rebate']/100:0;
$profix_loan = $money_json['price_loan']*$loan_fd;
//获取贷款手续费
$srv_loan = 0;
$s_json = json_decode($item['srv_ids'],true);
if($s_json){
foreach ($s_json as $v2) {
if($v2['key']=='price_finance'){
$srv_loan = $v2['price'];
break;
}
}
}
$srv_json['loan_srv_price'] = $profix_loan + $srv_loan;
if ($debug){
echo "贷款返点: loan_fd: {$loan_fd}"."<br>";
echo "贷款返点金额: profix_loan: {$profix_loan}"."<br>";
echo "贷款手续费: srv_loan: {$srv_loan}"."<br>";
echo "按揭综合服务费: loan_srv_price: {$srv_json['loan_srv_price']}"."<br>";
echo "<br><br>";
}
}
$fd_jsondata = json_decode($fd_row['jsondata'],true);
$loan_fd = $fd_jsondata['rebate'] ? $fd_jsondata['rebate']/100:0;
$profix_loan = $money_json['price_loan']*$loan_fd;
$srv_json['loan_srv_price'] = $profix_loan + $srv_loan;
if ($debug){
echo "贷款返点: loan_fd: {$loan_fd}"."<br>";
echo "贷款返点金额: profix_loan: {$profix_loan}"."<br>";
echo "贷款手续费: srv_loan: {$srv_loan}"."<br>";
echo "按揭综合服务费: loan_srv_price: {$srv_json['loan_srv_price']}"."<br>";
echo "<br><br>";
}
}