diff --git a/admin/controllers/receiver/orderv2/Orders.php b/admin/controllers/receiver/orderv2/Orders.php
index 8831ce7f..6f179d89 100644
--- a/admin/controllers/receiver/orderv2/Orders.php
+++ b/admin/controllers/receiver/orderv2/Orders.php
@@ -139,7 +139,8 @@ class Orders extends HD_Controller
$today_end = date('Y-m-d 00:00:00', strtotime('+1 day'));
$total_start = date('Y-m-01 00:00:00');
$total_end = date('Y-m-01 00:00:00', strtotime('+1 month'));
- $title_today = date('m月d日');
+ //$title_today = date('m月d日');
+ $title_today = '来源';
$title_ding_today = '当日订单';
$title_ding = '月累计订单';
$title_piao_today = '当日开票';
@@ -1647,7 +1648,7 @@ class Orders extends HD_Controller
if(!$row){
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
- if($info['field']=='ins_img'){
+ if($info['field']=='ins_img' || $info['field']=='other_img'){
$jsondata = json_decode($row[$info['field']],true);
$new_jsondata = [];
foreach ($jsondata as $item) {
@@ -1659,7 +1660,7 @@ class Orders extends HD_Controller
$update = [
$info['field'] => json_encode($new_jsondata,JSON_UNESCAPED_UNICODE)
];
- }elseif ($info['field']=='insurance_img'||$info['field']=='business_img'){
+ }elseif ($info['field']=='insurance_img'||$info['field']=='business_img'||$info['field']=='accident_img'||$info['field']=='bill_ck_img'){
$update = [
$info['field'] => json_encode([])
];
diff --git a/api/controllers/plan/Order.php b/api/controllers/plan/Order.php
index ca875c63..68c71050 100644
--- a/api/controllers/plan/Order.php
+++ b/api/controllers/plan/Order.php
@@ -316,7 +316,7 @@ class Order extends CI_Controller{
/**
* 添加成本数据
* @return void
- * https://liche-api-dev.xiaoyu.com/plan/order/cost
+ * https://liche-api-dev.xiaoyu.com/plan/order/cost?debug=1&id=102997
*/
public function cost(){
$this->load->model('receiver/order/receiver_order_bills_model', 'order_bills_model');
@@ -331,16 +331,26 @@ class Order extends CI_Controller{
$page = $this->input->get('page');
$size = $this->input->get('size');
$id = $this->input->get('id');
+ $debug = $this->input->get('debug');
!$page && $page = 1;
!$size && $size = 5;
- $where = [
+ !$debug && $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,
'id not in (select o_id from lc_items_cost)' => null,
'item_id>' => 0,
'id>=' => Orders_v2_entity::V2_START_ID
];
$id && $where['id'] = $id;
+ if ($debug && !$id){
+ exit('debug下,只支持单个id参数');
+ }
$rows = $this->receiver_orders_v2_model->select($where,'',$page,$size);
+ if ($debug){
+ echo "debug mode
get order_v2: {$id}
";
+ echo $this->receiver_orders_v2_model->db->last_query()."
";
+ var_dump($rows);
+ echo "
";
+ }
if($rows){
$supplier2 = $this->sys_supplier_model->select(['status' => 1, 'type' => 2], '', 0, 0, 'id,title,short');
/*//测试 保险公司名 匹配 保险供应商
@@ -355,6 +365,14 @@ class Order extends CI_Controller{
foreach ($rows as $item) {
$biz = $this->biz_model->get(['id'=>$item['biz_id']]);
+ if ($debug){
+ echo "get biz:
";
+ echo $this->biz_model->db->last_query()."
";
+ var_dump($biz);
+ echo "
";
+ echo "biz_type: {$biz['type']}"."
";
+ echo "
";
+ }
$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']));
@@ -368,6 +386,16 @@ class Order extends CI_Controller{
$bill_info['销货单位名称'] && $add_data['bill_name'] = $bill_info['销货单位名称'];
$bill_info['开票日期'] && $add_data['bill_time'] = $bill_info['开票日期'];
$bill_info['价税合计(小写)'] && $add_data['bill_price'] = str_replace('¥','',$bill_info['价税合计(小写)']);
+ if ($debug){
+ echo "get bill_info:
";
+ echo $this->order_bills_model->db->last_query()."
";
+ var_dump($bill_info);
+ echo "
";
+ echo "bill_time: {$add_data['bill_time']}"."
";
+ echo "bill_name: {$add_data['bill_name']}"."
";
+ echo "bill_price: {$add_data['bill_price']}"."
";
+ echo "
";
+ }
$srv_json = [];
//精品
$srv_json['price_fine_select'] = $money_json['price_fine_select'] ? $money_json['price_fine_select'] : 0;
@@ -379,6 +407,17 @@ class Order extends CI_Controller{
$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:
";
+ echo $this->receiver_order_datas_model->db->last_query()."
";
+ var_dump($img_data);
+ echo "
";
+ echo "insurance_price: {$srv_json['insurance_price']}"."
";
+ echo "insurance_product: {$srv_json['insurance_product']}"."
";
+ echo "business_price: {$srv_json['business_price']}"."
";
+ echo "business_product: {$srv_json['business_product']}"."
";
+ echo "
";
+ }
//获取创建订单时商务政策
$where = [
'id' => $info_json['business_id'],
@@ -387,8 +426,18 @@ class Order extends CI_Controller{
$srv_json['ori_price'] = $b_row_one['price_car'] ? $b_row_one['price_car'] : '';
$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'];
- $srv_json['insurance_ins_price'] = $srv_json['insurance_fd'] = 0;
+ if ($debug){
+ echo "get 商务政策:
";
+ echo $this->auto_business_model->db->last_query()."
";
+ var_dump($b_row_one);
+ echo "
";
+ echo "ori_price: {$srv_json['ori_price']}"."
";
+ echo "price_floor: {$srv_json['price_floor']}"."
";
+ echo "profix_car: {$srv_json['profix_car']}"."
";
+ echo "
";
+ }
+ $srv_json['insurance_ins_price'] = $srv_json['insurance_fd'] = 0;
/*
水平
品牌店按现有逻辑 (1)
@@ -427,6 +476,12 @@ class Order extends CI_Controller{
"json_extract(jsondata, '$.e_time') >= '{$time}'" => 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){
$where = [
'biz_id' => $item['biz_id'],
@@ -437,11 +492,23 @@ class Order extends CI_Controller{
"json_extract(jsondata, '$.type') = '2'" => 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 "
";
+ }
}
$fd_jsondata = json_decode($fd_row['jsondata'],true);
$srv_json['insurance_fd'] = $fd_jsondata['rebate'] ? $fd_jsondata['rebate'] : 0;
$qx_fd = $fd_jsondata['rebate']/100;
$srv_json['insurance_ins_price'] = floatval($insurance_img['price']) * $qx_fd;
+ if ($debug){
+ echo "get 强险返点:
";
+ echo "insurance_fd: {$srv_json['insurance_fd']}"."
";
+ echo "insurance_ins_price: {$srv_json['insurance_ins_price']}"."
";
+ echo "
";
+ }
}
$srv_json['business_ins_price'] = $srv_json['business_fd'] = 0;
if($business_img && $business_img['product']){//商业险
@@ -465,6 +532,12 @@ class Order extends CI_Controller{
"json_extract(jsondata, '$.e_time') >= '{$time}'" => 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 "
";
+ }
if(!$bis_fd_row){
$where = [
'biz_id' => $item['biz_id'],
@@ -475,11 +548,23 @@ class Order extends CI_Controller{
"json_extract(jsondata, '$.type') = '1'" => 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['business_fd'] = $bis_fd_jsondata['rebate'] ? $bis_fd_jsondata['rebate'] : 0;
$bis_fd = $bis_fd_jsondata['rebate']/100;
$srv_json['business_ins_price'] = floatval($business_img['price'])*$bis_fd;
+ if ($debug){
+ echo "get 商业险返点:
";
+ echo "business_fd: {$srv_json['business_fd']}"."
";
+ echo "business_ins_price: {$srv_json['business_ins_price']}"."
";
+ echo "
";
+ }
}
//挂牌
$srv_json['fee_carno'] = $money_json['fee_carno'] ? $money_json['fee_carno'] : 0;
@@ -500,11 +585,28 @@ class Order extends CI_Controller{
's_effect_time<=' => date('Y-m-d',strtotime($item['bill_time'])),
];
$free_row = $this->biz_settle_srv_model->get($where);
+ if ($debug){
+ echo "get 挂牌配置 :
";
+ echo $this->biz_settle_srv_model->db->last_query()."
";
+ var_dump($free_row);
+ echo "
";
+ }
if(!$free_row){
$free_row = $this->biz_settle_srv_model->get(['biz_id'=>$item['biz_id'],'is_def'=>1,'status'=>1,'type'=>1]);
+ if ($debug){
+ echo "get 挂牌配置(默认) :
";
+ echo $this->biz_settle_srv_model->db->last_query()."
";
+ var_dump($free_row);
+ echo "
";
+ }
}
$free_jsondata = json_decode($free_row['jsondata'],true);
$srv_json['cb_fee_carno'] = $free_jsondata['price'] ? $free_jsondata['price'] : 0;
+ if ($debug){
+ echo "get 挂牌返点:
";
+ echo "cb_fee_carno: {$srv_json['cb_fee_carno']}"."
";
+ echo "
";
+ }
}
//贷款信息
$srv_json['loan_product'] = '';
@@ -536,9 +638,21 @@ class Order extends CI_Controller{
"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_extract(jsondata, '$.supplier_id') = '{$finance_id}'" => null, "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;
@@ -555,12 +669,22 @@ class Order extends CI_Controller{
}
}
$srv_json['loan_srv_price'] = $profix_loan + $srv_loan;
+ if ($debug){
+ echo "get 贷款返点:
";
+ echo "loan_srv_price: {$srv_json['loan_srv_price']}"."
";
+ echo "
";
+ }
}
$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);
$srv_json['if_pay'] = $pay_price>=$need_price ? 1 : 0;
$add_data['srv_json'] = json_encode($srv_json,JSON_UNESCAPED_UNICODE);
+ if ($debug){
+ echo "get add_data :
";
+ var_dump($add_data);
+ exit();
+ }
$id = $this->items_cost_model->add($add_data);
if(is_numeric($id)){
$this->items_cost_model->update_total($id);
diff --git a/common/libraries/receiver/Orders_v2_entity.php b/common/libraries/receiver/Orders_v2_entity.php
index 2143bbed..1a738b94 100644
--- a/common/libraries/receiver/Orders_v2_entity.php
+++ b/common/libraries/receiver/Orders_v2_entity.php
@@ -1183,7 +1183,8 @@ class Orders_v2_entity{
!$today_end && $today_end = date('Y-m-d 00:00:00', strtotime('+1 day'));
!$total_start && $total_start = date('Y-m-01 00:00:00');
!$total_end && $total_end = date('Y-m-01 00:00:00', strtotime('+1 month'));
- !$title_today && $title_today = date('m月d日');
+ //!$title_today && $title_today = date('m月d日');
+ !$title_today && $title_today = '来源';
!$title_ding_today && $title_ding_today = '当日订单';
!$title_ding && $title_ding = '月累计订单';
!$title_piao_today && $title_piao_today = '当日开票';
@@ -1491,7 +1492,8 @@ class Orders_v2_entity{
!$today_end && $today_end = date('Y-m-d 00:00:00', strtotime('+1 day'));
!$total_start && $total_start = date('Y-m-01 00:00:00');
!$total_end && $total_end = date('Y-m-01 00:00:00', strtotime('+1 month'));
- !$title_today && $title_today = date('m月d日');
+ //!$title_today && $title_today = date('m月d日');
+ !$title_today && $title_today = '来源';
!$title_ding_today && $title_ding_today = '当日订单';
!$title_ding && $title_ding = '月累计订单';
!$title_piao_today && $title_piao_today = '当日开票';
@@ -1798,7 +1800,8 @@ class Orders_v2_entity{
!$today_end && $today_end = date('Y-m-d 00:00:00', strtotime('+1 day'));
!$total_start && $total_start = date('Y-m-01 00:00:00');
!$total_end && $total_end = date('Y-m-01 00:00:00', strtotime('+1 month'));
- !$title_today && $title_today = date('m月d日');
+ //!$title_today && $title_today = date('m月d日');
+ !$title_today && $title_today = '来源';
!$title_ding_today && $title_ding_today = '当日订单';
!$title_ding && $title_ding = '月累计订单';
!$title_piao_today && $title_piao_today = '当日开票';