cost plan add debug mode with single order.id

This commit is contained in:
qianhy
2023-03-02 10:55:52 +08:00
committed by lccsw
parent b86d491e98
commit e8632626c5
+134 -71
View File
@@ -341,15 +341,18 @@ class Order extends CI_Controller{
'id>=' => Orders_v2_entity::V2_START_ID
];
$id && $where['id'] = $id;
if ($debug && !$id){
exit('debug下,只支持单个id参数');
if ($debug){
if (!$id){
exit('debug下,只支持单个id参数');
}
$where['(status = 1 or ( status = 0 and id in (select o_id from `lc_receiver_order_status` where (pid_status = 4 and `status` in (1,2)) or (pid_status = 3 and `status` = 1) group by o_id having count(distinct pid_status) = 2 )) or ( status = 0 and id in (select id from lc_receiver_orders_v2 where if_usedcar = 1 and bill_time > 0 )) )'] = null;
}
$rows = $this->receiver_orders_v2_model->select($where,'',$page,$size);
if ($debug){
echo "debug mode<br>get order_v2: {$id}<br>";
echo "debug mode start <br><br>get order_v2: {$id}<br>";
echo $this->receiver_orders_v2_model->db->last_query()."<br>";
var_dump($rows);
echo "<br><br>";
echo "<br>";
}
if($rows){
$supplier2 = $this->sys_supplier_model->select(['status' => 1, 'type' => 2], '', 0, 0, 'id,title,short');
@@ -366,6 +369,11 @@ class Order extends CI_Controller{
foreach ($rows as $item) {
$biz = $this->biz_model->get(['id'=>$item['biz_id']]);
if ($debug){
echo "finance_id: {$item['finance_id']}"."<br>";
echo "biz_id: {$item['biz_id']}"."<br>";
echo "status: {$item['status']}"."<br>";
echo "<br><br>";
echo "get biz: <br>";
echo $this->biz_model->db->last_query()."<br>";
var_dump($biz);
@@ -396,34 +404,17 @@ class Order extends CI_Controller{
echo "bill_price: {$add_data['bill_price']}"."<br>";
echo "<br><br>";
}
$srv_json = [];
//精品
$srv_json['price_fine_select'] = $money_json['price_fine_select'] ? $money_json['price_fine_select'] : 0;
//保险
$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);
$srv_json['insurance_price'] = $insurance_img['price'] ? $insurance_img['price'] : '';
$srv_json['insurance_product'] = $insurance_img['product'] ? $insurance_img['product'] : '';
$srv_json['business_price'] = $business_img['price'] ? $business_img['price'] : '';
$srv_json['business_product'] = $business_img['product'] ? $business_img['product'] : '';
if ($debug){
echo "get order_datas - 保险 img_data: <br>";
echo $this->receiver_order_datas_model->db->last_query()."<br>";
var_dump($img_data);
echo "<br>";
echo "insurance_price: {$srv_json['insurance_price']}"."<br>";
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 "<br><br>";
}
//获取创建订单时商务政策
$where = [
'id' => $info_json['business_id'],
];
$b_row_one = $this->auto_business_model->get($where);
$srv_json['ori_price'] = $b_row_one['price_car'] ? $b_row_one['price_car'] : '';
$srv_json['ori_price'] = $b_row_one['price_car'] ? $b_row_one['price_car'] : 0;
$srv_json['price_floor'] = $b_row_one['price_floor'] ? $b_row_one['price_floor'] : 0;
$srv_json['profix_car'] = $biz['type']==2 ? $b_row_one['proxy_profix_car'] : $b_row_one['profix_car'];
if ($debug){
@@ -437,7 +428,6 @@ class Order extends CI_Controller{
echo "<br><br>";
}
$srv_json['insurance_ins_price'] = $srv_json['insurance_fd'] = 0;
/*
水平
品牌店按现有逻辑 (1)
@@ -448,6 +438,13 @@ class Order extends CI_Controller{
$add_data['insurance_price'] = $b_row_one['profix_insure'] ? $b_row_one['profix_insure'] : 0.00;
$add_data['fee_carno_price'] = $b_row_one['profix_carno'] ? $b_row_one['profix_carno'] : 0.00;
$add_data['loan_price'] = $b_row_one['profix_loan'] ? $b_row_one['profix_loan'] : 0.00;
if ($debug){
echo "biz_type==2 (biz_type==3时均为0): "."<br>";
echo "insurance_price: {$add_data['insurance_price']}"."<br>";
echo "fee_carno_price: {$add_data['fee_carno_price']}"."<br>";
echo "loan_price: {$add_data['loan_price']}"."<br>";
echo "<br><br>";
}
}
elseif ($biz['type']==3){
$add_data['insurance_price'] = 0.00;
@@ -455,7 +452,34 @@ class Order extends CI_Controller{
$add_data['loan_price'] = 0.00;
}
if($insurance_img && $insurance_img['product']){//
//
$srv_json['insurance_price'] = $srv_json['business_price'] = 0;
$srv_json['insurance_product'] = $srv_json['business_product'] = '';
$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){
$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'] : '';
if ($debug){
echo "get order_datas - 保险 img_data: <br>";
echo $this->receiver_order_datas_model->db->last_query()."<br>";
var_dump($img_data);
echo "<br>";
echo "insurance_price: {$srv_json['insurance_price']}"."<br>";
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 "<br><br>";
}
}
//强险
$srv_json['insurance_ins_price'] = $srv_json['insurance_fd'] = 0;
if($biz['type']==1 && $insurance_img && $insurance_img['product']){
$time = strtotime($insurance_img['date']);
/*$where = [
'biz_id' => $item['biz_id'],
@@ -478,6 +502,9 @@ class Order extends CI_Controller{
$fd_row = $this->biz_settle_srv_model->get($where);
if ($debug){
echo "get 强险配置 : <br>";
if ($insure_product != $insurance_img['product']){
echo "{$insurance_img['product']} -> {$insure_product}"."<br>";
}
echo $this->biz_settle_srv_model->db->last_query()."<br>";
var_dump($fd_row);
echo "<br><br>";
@@ -510,8 +537,10 @@ class Order extends CI_Controller{
echo "<br><br>";
}
}
//商业险
$srv_json['business_ins_price'] = $srv_json['business_fd'] = 0;
if($business_img && $business_img['product']){//商业险
if($biz['type']==1 && $business_img && $business_img['product']){
$time = strtotime($business_img['date']);
/*$where = [
'biz_id' => $item['biz_id'],
@@ -534,6 +563,9 @@ class Order extends CI_Controller{
$bis_fd_row = $this->biz_settle_srv_model->get($where);
if ($debug){
echo "get 商业险配置 : <br>";
if ($insure_product != $business_img['product']){
echo "{$business_img['product']} -> {$insure_product}"."<br>";
}
echo $this->biz_settle_srv_model->db->last_query()."<br>";
var_dump($bis_fd_row);
echo "<br><br>";
@@ -566,10 +598,11 @@ class Order extends CI_Controller{
echo "<br><br>";
}
}
//挂牌
$srv_json['fee_carno'] = $money_json['fee_carno'] ? $money_json['fee_carno'] : 0;
$srv_json['cb_fee_carno'] = 0;
if($money_json['fee_carno']>0){
if($biz['type']==1 && $money_json['fee_carno']>0){
/*$where = [
'biz_id' => $item['biz_id'],
'type' => 1,
@@ -603,11 +636,11 @@ 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 "get 挂牌返点: <br>";
echo "cb_fee_carno: {$srv_json['cb_fee_carno']}"."<br>";
echo "挂牌返点 cb_fee_carno: {$srv_json['cb_fee_carno']}"."<br>";
echo "<br><br>";
}
}
//贷款信息
$srv_json['loan_product'] = '';
$srv_json['loan_srv_price'] = $srv_json['loan_num'] = $srv_json['loan_price'] = 0;
@@ -622,59 +655,80 @@ class Order extends CI_Controller{
$srv_json['loan_product'] = $finance_row ? $finance_row['title'] : '';
}
$srv_json['loan_num'] = $finance_num = $loan_row['num'] ? $loan_row['num'] : 36;
/*$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_extract(jsondata, '$.supplier_id') = '{$finance_id}'" => null,
"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 "get 贷款信息: <br>";
echo $this->order_loans_model->db->last_query()."<br>";
var_dump($loan_row);
echo "<br>";
if ($finance_id){
echo $this->sys_supplier_model->db->last_query()."<br>";
var_dump($finance_row);
echo "<br>";
}
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 "<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_extract(jsondata, '$.supplier_id') = '{$finance_id}'" => null, "json_extract(jsondata, '$.finance_num') = '{$finance_num}'" => null]);
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_extract(jsondata, '$.supplier_id') = '{$finance_id}'" => null,
"json_extract(jsondata, '$.finance_num') = '{$finance_num}'" => null,
];
$fd_row = $this->biz_settle_srv_model->get($where);
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>";
}
}
$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;
if(!$fd_row){
$fd_row = $this->biz_settle_srv_model->get(['biz_id'=>$item['biz_id'],'is_def'=>1,'status'=>1,'type'=>3,
"json_extract(jsondata, '$.supplier_id') = '{$finance_id}'" => null, "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>";
}
}
}
$srv_json['loan_srv_price'] = $profix_loan + $srv_loan;
if ($debug){
echo "get 贷款返点: <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_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>";
}
}
}
$sum = $this->app_liche_orders_model->sum('total_price', ['o_id'=>$item['id'],'status'=>1,'pay_price <>'=>0]);
$pay_price = $sum['total_price'] ? $sum['total_price'] : 0;
$need_price = $this->orders_v2_entity->recevable_price($item['id'],$srv_price=true,$price_loan=false);
@@ -683,6 +737,15 @@ class Order extends CI_Controller{
if ($debug){
echo "get add_data : <br>";
var_dump($add_data);
if ($cost = $this->items_cost_model->get(array('o_id'=>$item['id']))){
echo "<br><br>";
echo $this->items_cost_model->db->last_query()."<br>";
var_dump($cost);
echo "<br>";
echo "c_time: ".date("Y-m-d H:i:s",$cost['c_time'])."<br>";
}
echo "<br><br>debug mode end<br><br>";
exit();
}
$id = $this->items_cost_model->add($add_data);