cost add biz_type in (2,3) spyw

This commit is contained in:
qianhy
2023-01-12 15:17:21 +08:00
parent 4c23e18b20
commit 528b0e165e
4 changed files with 182 additions and 11 deletions
+22 -1
View File
@@ -251,7 +251,8 @@ class Cost extends HD_Controller{
'company_name' => $company['short'],
'name' => $order_row['owner_name']."({$order_row['owner_mobile']})", // 'name' => $order_row['name']."({$order_row['mobile']})",
'payway' => $order_row['payway'],
'biz_type' => $this->biz_model->type_ary($biz['type']),
'biz_type' => $biz['type'],
'biz_type_name' => $this->biz_model->type_ary($biz['type']),
'biz_name' => $biz['biz_name'],
'admin_name' => $admin['uname'],
'order_time' => date('Y-m-d',$order_row['c_time']),
@@ -300,6 +301,26 @@ class Cost extends HD_Controller{
'promotion_json' => json_encode($post_data['promotion_json'],JSON_UNESCAPED_UNICODE),
'srv_json' => json_encode($post_data['srv_json'],JSON_UNESCAPED_UNICODE),
];
/*
水平
品牌店按现有逻辑 (1)
合伙店取商务政策的固定值 (2)
代理店没有水平业务 (3)
*/
$order_row = $this->receiver_orders_v2_model->get(['id'=>$row['o_id']], 'id, (select type from lc_biz where id = lc_receiver_orders_v2.biz_id) as biz_type');
$biz_type = $order_row['biz_type'];
if ($biz_type == 2){
$insurance_price = $post_data['insurance_price'] ? $post_data['insurance_price'] : 0;
$insurance_price != $row['insurance_price'] && $data['insurance_price'] = $insurance_price;
$fee_carno_price = $post_data['fee_carno_price'] ? $post_data['fee_carno_price'] : 0;
$fee_carno_price != $row['fee_carno_price'] && $data['fee_carno_price'] = $fee_carno_price;
$loan_price = $post_data['loan_price'] ? $post_data['loan_price'] : 0;
$loan_price != $row['loan_price'] && $data['loan_price'] = $loan_price;
}
$res = $this->items_cost_model->update($data,['id'=>$row['id']]);
if(is_numeric($res_item) || is_numeric($res)){
$this->items_cost_model->update_total($row['id']);
+39 -2
View File
@@ -99,7 +99,7 @@
<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">
<label class="am-para-label-con">{{info.biz_type}}</label>
<label class="am-para-label-con">{{info.biz_type_name}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-4">
@@ -261,7 +261,7 @@
</div>
</div>
</div>
<div class="am-panel am-panel-default">
<div v-if="info.biz_type == '1'" class="am-panel am-panel-default">
<div class="am-panel-hd">
<span style="font-size: 20px">水平业务</span>
<span style="float:right;margin-top:5px">
@@ -454,6 +454,40 @@
</div>
</div>
</div>
<div v-if="info.biz_type == '2'" class="am-panel am-panel-default">
<div class="am-panel-hd">
<span style="font-size: 20px">水平业务</span>
<span style="float:right;margin-top:5px">
</span>
</div>
<div class="am-panel-bd am-g" style="margin-top: 10px;margin-bottom: 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">保险收入合计</a></span></label>
<div class="am-para-input">
<input type="number" v-model="info.row.insurance_price" style="width: 150px;">
</div>
</div>
</div>
<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>
<div class="am-para-input">
<input type="number" v-model="info.row.fee_carno_price" style="width: 150px;">
</div>
</div>
</div>
<!-- <div v-if="info.payway=='1'" class="am-form-inline">-->
<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>
<div class="am-para-input">
<input type="number" v-model="info.row.loan_price" style="width: 150px;">
</div>
</div>
</div>
</div>
</div>
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span style="font-size: 20px">整车合计</span>
@@ -606,6 +640,9 @@
post_data['srv_json'] = vm.info.srv_json;
post_data['price'] = vm.info.price;
post_data['buy_price'] = vm.info.buy_price;
post_data['insurance_price'] = vm.info.row.insurance_price;
post_data['fee_carno_price'] = vm.info.row.fee_carno_price;
post_data['loan_price'] = vm.info.row.loan_price;
$.ajax({
url: '/items/cost/edit',
type: 'post',
+93
View File
@@ -373,6 +373,24 @@ class Order extends CI_Controller{
$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;
/*
水平
品牌店按现有逻辑 (1)
合伙店取商务政策的固定值 (2)
代理店没有水平业务 (3)
*/
if ($biz['type']==2){
$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;
}
elseif ($biz['type']==3){
$add_data['insurance_price'] = 0.00;
$add_data['fee_carno_price'] = 0.00;
$add_data['loan_price'] = 0.00;
}
if($insurance_img){//强险
$time = strtotime($insurance_img['date']);
$where = [
@@ -497,4 +515,79 @@ class Order extends CI_Controller{
echo "数据不存在";
}
}
/**
* 修复成本数据的非品牌店的水平业务
* @return void
*/
public function cost_repair_spyw(){
$this->load->model("biz/biz_model");
$this->load->model('auto/auto_business_model');
$this->load->model('items/items_cost_model');
$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 ) ))' => null,
'id in (select o_id from lc_items_cost)' => null,
'item_id>' => 0,
'id>=' => Orders_v2_entity::V2_START_ID,
'biz_id in (select id from lc_biz where type <> 1)' => null,
];
$rows = $this->receiver_orders_v2_model->select($where,'',0,0);
if (!$rows){
echo "数据不存在";exit();
}
foreach ($rows as $item) {
$o_id = $item['id'];
$cost = $this->items_cost_model->get(['o_id'=>$o_id]);
if (!$cost){
echo "{$o_id}, cost not found<br>";
}
$biz = $this->biz_model->get(['id'=>$item['biz_id']]);
if (!$biz){
echo "{$o_id}, biz not found, biz_id: {$item['biz_id']}<br>";
}
$info_json = json_decode($item['info_json'],true);
//获取创建订单时商务政策
$b_row_one = $this->auto_business_model->get(['id' => $info_json['business_id']]);
if (!$b_row_one){
echo "{$o_id}, business not found, business_id: {$item['business_id']}<br>";
}
/*
水平
品牌店按现有逻辑 (1)
合伙店取商务政策的固定值 (2)
代理店没有水平业务 (3)
*/
$add_data = [];
if ($biz['type']==2){
$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;
}
elseif ($biz['type']==3){
$add_data['insurance_price'] = 0.00;
$add_data['fee_carno_price'] = 0.00;
$add_data['loan_price'] = 0.00;
}
echo "{$o_id}, biz_type: {$biz['type']}<br>";
$id = $cost['id'];
if ($add_data){
$res = $this->items_cost_model->update($add_data, array('id'=>$id));
$sql = $this->items_cost_model->db->last_query();
$res = is_numeric($res) ? is_numeric($res) : 0;
echo "{$o_id}, cost {$id} update: {$res}, ({$sql})<br>";
}
else{
echo "{$o_id}, cost {$id} update: ignore<br>";
}
$res = $this->items_cost_model->update_total($id);
echo "{$o_id}, cost {$id} update_total: {$res}<br><br>";
}
echo "repair ".count($rows)." rows ok!";
}
}
+28 -8
View File
@@ -17,6 +17,7 @@ class Items_cost_model extends HD_Model
*/
public function update_total($id){
$this->load->model('items/items_model');
$this->load->model('receiver/order/receiver_orders_v2_model');
$row = $this->get(['id'=>$id]);
if($row){
$item_row = $this->items_model->get(['id'=>$row['item_id']]);
@@ -33,14 +34,33 @@ class Items_cost_model extends HD_Model
$car_buy_price = $item_row['buy_price'] - $promotion_json['factory_price'];
//【整车采购毛利】(销售收入合计 - 整车采购成本 - 促销成本合计 - 选装金额 -选装工时费)
$car_profit_price = $sale_price - $car_buy_price - $promotion_price - $cost_json['select_price'] - $cost_json['labor_price'];
//【保险收入合计】
$insurance_price = $srv_json['business_ins_price']+$srv_json['insurance_ins_price']-$srv_json['back_price'];
//【挂牌收入合计】
$fee_carno_price = $srv_json['fee_carno'] - $srv_json['cb_fee_carno'];
//【按揭收入合计】(按揭综合服务费+按揭解抵服务费+利息补贴收入+金融公司手续费收入+其他收入-其他支出)
$loan_price = $srv_json['loan_srv_price']+$srv_json['loan_offset_price']+$srv_json['loan_subsidy_price']+$srv_json['commission_price']+$srv_json['loan_in_price']-$srv_json['loan_out_price'];
//【水平业务总毛利】(保险收入合计+挂牌收入合计+按揭收入合计+其他收入-其他支出)
$srv_price = $insurance_price+$fee_carno_price+$loan_price+$srv_json['other_in_price']-$srv_json['other_out_price'];
/*
水平
品牌店按现有逻辑 (1)
合伙店取商务政策的固定值 (2)
代理店没有水平业务 (3)
*/
$order_row = $this->receiver_orders_v2_model->get(['id'=>$row['o_id']], 'id, (select type from lc_biz where id = lc_receiver_orders_v2.biz_id) as biz_type');
$biz_type = $order_row['biz_type'];
$insurance_price = $fee_carno_price = $loan_price = $srv_price = 0;
if ($biz_type == 1){
//【保险收入合计】
$insurance_price = $srv_json['business_ins_price']+$srv_json['insurance_ins_price']-$srv_json['back_price'];
//【挂牌收入合计】
$fee_carno_price = $srv_json['fee_carno'] - $srv_json['cb_fee_carno'];
//【按揭收入合计】(按揭综合服务费+按揭解抵服务费+利息补贴收入+金融公司手续费收入+其他收入-其他支出)
$loan_price = $srv_json['loan_srv_price']+$srv_json['loan_offset_price']+$srv_json['loan_subsidy_price']+$srv_json['commission_price']+$srv_json['loan_in_price']-$srv_json['loan_out_price'];
//【水平业务总毛利】(保险收入合计+挂牌收入合计+按揭收入合计+其他收入-其他支出)
$srv_price = $insurance_price+$fee_carno_price+$loan_price+$srv_json['other_in_price']-$srv_json['other_out_price'];
}
elseif ($biz_type == 2){
$insurance_price = $row['insurance_price'];
$fee_carno_price = $row['fee_carno_price'];
$loan_price = $row['loan_price'];
$srv_price = $insurance_price+$fee_carno_price+$loan_price;
}
//【单车总毛利】(整车采购毛利+水平业务总毛利)
$car_price = $car_profit_price + $srv_price;
//【直营店单车毛利/代理店单车毛利/合伙店采购毛利】(根据门店类型取, 商务政策分润 - 选装金额 - 选装工时费 - 促销成本 + 水平业务总毛利 + (实际售价入 - 商务政策底价))