cost plan add debug, modify date_title; orderv2 fixbug del_img
This commit is contained in:
@@ -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([])
|
||||
];
|
||||
|
||||
@@ -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<br>get order_v2: {$id}<br>";
|
||||
echo $this->receiver_orders_v2_model->db->last_query()."<br>";
|
||||
var_dump($rows);
|
||||
echo "<br><br>";
|
||||
}
|
||||
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: <br>";
|
||||
echo $this->biz_model->db->last_query()."<br>";
|
||||
var_dump($biz);
|
||||
echo "<br>";
|
||||
echo "biz_type: {$biz['type']}"."<br>";
|
||||
echo "<br><br>";
|
||||
}
|
||||
$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: <br>";
|
||||
echo $this->order_bills_model->db->last_query()."<br>";
|
||||
var_dump($bill_info);
|
||||
echo "<br>";
|
||||
echo "bill_time: {$add_data['bill_time']}"."<br>";
|
||||
echo "bill_name: {$add_data['bill_name']}"."<br>";
|
||||
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;
|
||||
@@ -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: <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'],
|
||||
@@ -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 商务政策: <br>";
|
||||
echo $this->auto_business_model->db->last_query()."<br>";
|
||||
var_dump($b_row_one);
|
||||
echo "<br>";
|
||||
echo "ori_price: {$srv_json['ori_price']}"."<br>";
|
||||
echo "price_floor: {$srv_json['price_floor']}"."<br>";
|
||||
echo "profix_car: {$srv_json['profix_car']}"."<br>";
|
||||
echo "<br><br>";
|
||||
}
|
||||
|
||||
$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 强险配置 : <br>";
|
||||
echo $this->biz_settle_srv_model->db->last_query()."<br>";
|
||||
var_dump($fd_row);
|
||||
echo "<br><br>";
|
||||
}
|
||||
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 强险配置(默认) : <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);
|
||||
$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 强险返点: <br>";
|
||||
echo "insurance_fd: {$srv_json['insurance_fd']}"."<br>";
|
||||
echo "insurance_ins_price: {$srv_json['insurance_ins_price']}"."<br>";
|
||||
echo "<br><br>";
|
||||
}
|
||||
}
|
||||
$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 商业险配置 : <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'],
|
||||
@@ -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 商业险配置(默认) : <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['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 商业险返点: <br>";
|
||||
echo "business_fd: {$srv_json['business_fd']}"."<br>";
|
||||
echo "business_ins_price: {$srv_json['business_ins_price']}"."<br>";
|
||||
echo "<br><br>";
|
||||
}
|
||||
}
|
||||
//挂牌
|
||||
$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 挂牌配置 : <br>";
|
||||
echo $this->biz_settle_srv_model->db->last_query()."<br>";
|
||||
var_dump($free_row);
|
||||
echo "<br><br>";
|
||||
}
|
||||
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 挂牌配置(默认) : <br>";
|
||||
echo $this->biz_settle_srv_model->db->last_query()."<br>";
|
||||
var_dump($free_row);
|
||||
echo "<br><br>";
|
||||
}
|
||||
}
|
||||
$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 "<br><br>";
|
||||
}
|
||||
}
|
||||
//贷款信息
|
||||
$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 贷款配置 : <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_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>";
|
||||
}
|
||||
}
|
||||
$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 贷款返点: <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);
|
||||
$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 : <br>";
|
||||
var_dump($add_data);
|
||||
exit();
|
||||
}
|
||||
$id = $this->items_cost_model->add($add_data);
|
||||
if(is_numeric($id)){
|
||||
$this->items_cost_model->update_total($id);
|
||||
|
||||
@@ -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 = '当日开票';
|
||||
|
||||
Reference in New Issue
Block a user