diff --git a/api/controllers/plan/Order.php b/api/controllers/plan/Order.php
index 966a661c..8974d218 100644
--- a/api/controllers/plan/Order.php
+++ b/api/controllers/plan/Order.php
@@ -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']}"."
";
echo "biz_id: {$item['biz_id']}"."
";
echo "status: {$item['status']}"."
";
echo "if_usedcar: {$if_usedcar}"."
";
+ echo "if_num: {$item['if_num']}"."
";
+ echo "if_insure: {$item['if_insure']}"."
";
+ echo "srv_ids: {$item['srv_ids']}"."
";
+ echo "
"."=====srv_ids====="."
";
+ echo "srv_if_insure: {$srv_if_insure}"."
";
+ echo "srv_if_num: {$srv_if_num}"."
";
+ echo "srv_if_finance: {$srv_if_finance}"."
";
+ echo "srv_insure: {$srv_insure}"."
";
+ echo "srv_fee_carno: {$srv_fee_carno}"."
";
+ echo "srv_loan: {$srv_loan}"."
";
echo "
";
}
@@ -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']}"."
";
+ echo "挂牌费用 fee_carno: {$srv_json['fee_carno']}"."
";
+ echo "挂牌成本 cb_fee_carno: {$srv_json['cb_fee_carno']}"."
";
+ $fee_carno_price = $srv_json['fee_carno'] - $srv_json['cb_fee_carno'];
+ echo "挂牌收入合计 fee_carno_price: {$fee_carno_price}"."
";
echo "
";
}
}
@@ -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 "
";
}
- 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 贷款配置 :
";
+ echo $this->biz_settle_srv_model->db->last_query()."
";
+ var_dump($fd_row);
+ echo "
";
+ }
+ 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 贷款配置 :
";
+ echo "get 贷款配置(默认) :
";
echo $this->biz_settle_srv_model->db->last_query()."
";
var_dump($fd_row);
echo "
";
}
- 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 贷款配置(默认) :
";
- echo $this->biz_settle_srv_model->db->last_query()."
";
- var_dump($fd_row);
- echo "
";
- }
- }
- $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}"."
";
- echo "贷款返点金额: profix_loan: {$profix_loan}"."
";
- echo "贷款手续费: srv_loan: {$srv_loan}"."
";
- echo "按揭综合服务费: loan_srv_price: {$srv_json['loan_srv_price']}"."
";
- echo "
";
- }
+ }
+ $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}"."
";
+ echo "贷款返点金额: profix_loan: {$profix_loan}"."
";
+ echo "贷款手续费: srv_loan: {$srv_loan}"."
";
+ echo "按揭综合服务费: loan_srv_price: {$srv_json['loan_srv_price']}"."
";
+ echo "
";
}
}