From f52de346853f3cef13c25f0c118b0b8d13e2eddd Mon Sep 17 00:00:00 2001
From: lccsw <805383944@qq.com>
Date: Thu, 18 Aug 2022 15:23:36 +0800
Subject: [PATCH] edit-plan-settle_static
---
admin/controllers/biz/Settle.php | 17 +++++-
admin/views/biz/settle/lists_brand.php | 34 ++++++++++--
admin/views/biz/settle/lists_static_brand.php | 33 +++++++-----
api/controllers/plan/Biz.php | 52 +++++++------------
common/models/biz/Biz_settle_price_model.php | 1 +
5 files changed, 86 insertions(+), 51 deletions(-)
diff --git a/admin/controllers/biz/Settle.php b/admin/controllers/biz/Settle.php
index 5b1ef377..df55f6c0 100644
--- a/admin/controllers/biz/Settle.php
+++ b/admin/controllers/biz/Settle.php
@@ -80,7 +80,7 @@ class Settle extends HD_Controller
$lists = array();
if($total){
$orderby = "$t1.id desc";
- $select = "$t1.*,$t2.sid,$t2.name,$t2.mobile,$t2.s_id,$t2.v_id,$t2.brand_id,$t2.cor_id,$t2.item_id";
+ $select = "$t1.*,$t2.sid,$t2.name,$t2.mobile,$t2.s_id,$t2.v_id,$t2.brand_id,$t2.cor_id,$t2.item_id,$t2.money_json as o_money_json,$t2.srv_ids";
$rows = $this->biz_settle_model->selectOrders($where, $orderby, $page, $size,0, $select);
if($rows){
$s_ids = array_unique(array_filter(array_column($rows,'s_id')));
@@ -118,7 +118,18 @@ class Settle extends HD_Controller
$title = "{$map_brand[$v['brand_id']]} {$map_sery[$v['s_id']]} {$map_attr[$v['v_id']]} {$map_attr[$v['cor_id']]}";
$month = date('Y-m',strtotime("{$v['year']}-{$v['month']}"));
$money_json = json_decode($v['money_json'],true);
+ $o_money_json = json_decode($v['o_money_json'],true);
$sum_srv = $v['profix_insure']+$v['profix_carno']+$v['profix_loan']+$v['profix_fine'];
+ $srv_json = json_decode($v['srv_ids'],true);
+ $srv_loan = 0;
+ if($v['profix_loan']>0 && $srv_json){
+ foreach ($srv_json as $v2) {
+ if($v2['key']=='price_finance'){
+ $srv_loan = $v2['price'];
+ break;
+ }
+ }
+ }
$lists[] = array(
'id' => $v['id'],
'o_id' => $v['o_id'],
@@ -129,6 +140,7 @@ class Settle extends HD_Controller
'profix_insure' => $v['profix_insure'],
'profix_carno' => $v['profix_carno'],
'profix_loan' => $v['profix_loan'],
+ 'srv_json' => $srv_loan,
'profix_fine' => $v['profix_fine'],
'sum_srv' => $sum_srv,
'sum_srv_after' => sprintf("%.2f",$sum_srv/1.06),
@@ -138,7 +150,8 @@ class Settle extends HD_Controller
'sid' => $v['sid'],
'month' => $month,
'vin' => $map_item[$v['item_id']],
- 'money_json' => $money_json
+ 'money_json' => is_array($money_json) ? $money_json : [],
+ 'o_money_json' => $o_money_json
);
}
}
diff --git a/admin/views/biz/settle/lists_brand.php b/admin/views/biz/settle/lists_brand.php
index 96658b57..3a89a942 100644
--- a/admin/views/biz/settle/lists_brand.php
+++ b/admin/views/biz/settle/lists_brand.php
@@ -81,11 +81,37 @@
{{v.title}} {{v.vin}}
-
{{v.profix_car}} |
+
+ {{v.profix_car}}
+ 优惠金额:{{v.o_money_json.price_discount}}
+ |
{{v.profix_car_after}} |
- {{v.profix_insure}} |
- {{v.profix_loan}} |
- {{v.profix_carno}} |
+
+ {{v.profix_insure}}
+ 强险佣金:
+ {{v.money_json.profix_insuer_ins}}
+ 0
+ 商业险佣金:
+ {{v.money_json.profix_insuer_bis}}
+ 0
+ |
+
+ {{v.profix_loan}}
+
+ 手续费:
+ {{v.srv_json}}
+ 0
+ 利润:{{v.profix_loan-v.srv_json}}
+
+
+ |
+
+ {{v.profix_carno}}
+
+ 挂牌:{{v.o_money_json.fee_carno}}
+ 手续费:{{v.o_money_json.fee_carno-v.profix_carno}}
+
+ |
{{v.profix_fine}} |
{{v.sum_srv}} |
{{v.sum_srv_after}} |
diff --git a/admin/views/biz/settle/lists_static_brand.php b/admin/views/biz/settle/lists_static_brand.php
index 089481df..791f7325 100644
--- a/admin/views/biz/settle/lists_static_brand.php
+++ b/admin/views/biz/settle/lists_static_brand.php
@@ -38,10 +38,9 @@
门店 |
单车总毛利 |
- 服务费 |
- 佣金 |
+ 税后单车总毛利 |
+ 水平业务总毛利 |
门店费用 |
- 精品 |
其它费用 |
总利润 |
分润 |
@@ -56,27 +55,35 @@
{{v.biz_name}} |
{{v.profix_car}} |
- |
- |
+ {{v.profix_car_after}} |
+ {{v.price_all}} |
-
+
+
+ {{i2}}:{{v2}}
+
+ 总费用:{{v.money_json.biz_price}}
+
|
-
- |
-
-
+
+ {{item.name}}:{{item.money}}({{type_arr[item.type]}})
+
|
{{v.price_ml}} |
狸车分润:{{v.profix_liche}}
- 品牌店分润:{{v.profix_partner}}
+ 合伙人分润:{{v.profix_partner}}
|
{{v.month_str}} |
- |
- 查看明细
+ |
+ 查看明细
+ 新增费用
+
|
diff --git a/api/controllers/plan/Biz.php b/api/controllers/plan/Biz.php
index 6913cfd1..50e5a351 100644
--- a/api/controllers/plan/Biz.php
+++ b/api/controllers/plan/Biz.php
@@ -264,6 +264,7 @@ class Biz extends HD_Controller
$data_row = $this->receiver_order_datas_model->get(['o_id'=>$val['id']]);
$insurance_img = json_decode($data_row['insurance_img'],true);
$business_img = json_decode($data_row['business_img'],true);
+ $profix_insuer_ins = 0;
if($insurance_img){
//强险
$time = strtotime($insurance_img['date']);
@@ -290,6 +291,7 @@ class Biz extends HD_Controller
$qx_fd = $fd_jsondata['rebate']/100;
$profix_insuer_ins = floatval($insurance_img['price']) * $qx_fd;
}
+ $profix_insuer_bis = 0;
if($business_img){
//商业险
$time = strtotime($business_img['date']);
@@ -380,6 +382,7 @@ class Biz extends HD_Controller
'money_json' => json_encode($settle_money_json,JSON_UNESCAPED_UNICODE),
'year' => date('Y',strtotime($val['bill_time'])),
'month' => intval(date('m',strtotime($val['bill_time']))),
+ 'type' => 1,
'c_time' => time()
];
if($money_json['price_car']>$b_row_one['price_floor']){
@@ -407,39 +410,38 @@ class Biz extends HD_Controller
$rows = $this->biz_settle_model->select($where,'id asc',$page,$size);
if($rows){
foreach($rows as $key=>$val){
- $settle_money_json = json_decode($val['money_json'],true);
$where = [
'biz_id' => $val['biz_id'],
'year' => $val['year'],
'month' => $val['month']
];
$static_row = $this->biz_settle_static_model->get($where);
+ $price_all = $val['profix_insure']+$val['profix_loan']+$val['profix_carno']+$val['profix_fine'];
if(!$static_row){
$data = [
'biz_id' => $val['biz_id'],
'profix_car' => $val['profix_car'],
+ 'price_all' => $price_all,
'year' => $val['year'],
'month' => $val['month'],
'c_time' => time()
];
- $add_money_json['in'] = [ //收入
- 'profix_car' => $val['profix_car'], //整车
- 'srv_price' => $settle_money_json['srv_price'], //服务费
- 'commission' => $settle_money_json['commission'], //佣金
- ];
$biz_price = 0;//门店成本
+ $biz_price_list = [];
$p_where = [
'biz_id' => $val['biz_id'],
'status' => 1,
- 'year' => date('Y',$val['year']),
- 'month' => date('m',$val['month']),
+ 'year' => $val['year'],
+ 'month' => $val['month'],
];
$price_row = $this->biz_settle_price_model->get($p_where);
- $price_row && $biz_price = $this->biz_settle_price_model->sum_jsondata($price_row['jsondata']);
- $add_money_json['out'] = [ //成本
+ if($price_row){
+ $biz_price = $this->biz_settle_price_model->sum_jsondata($price_row['money_json']);
+ $biz_price_list = $this->biz_settle_price_model->get_jsondata($price_row['money_json']);
+ }
+ $add_money_json = [ //成本
'biz_price' => $biz_price, //门店成本
- 'apply_price' => $settle_money_json['apply_price'], //申请成本
- 'fine_price' => $settle_money_json['fine_price'], //赠送精品成本
+ 'biz_price_list' => $biz_price_list
];
$data['money_json'] = json_encode($add_money_json,JSON_UNESCAPED_UNICODE);
$stic_id = $this->biz_settle_static_model->add($data);
@@ -447,23 +449,10 @@ class Biz extends HD_Controller
$this->biz_settle_model->update(['stic_id'=>$stic_id],['id'=>$val['id']]);
}
}else{
- $static_money_json = json_decode($static_row['money_json'],true);
$data = [
'profix_car' => $static_row['profix_car'] + $val['profix_car'],
+ 'price_all' => $static_row['price_all'] + $price_all,
];
- $out = $static_money_json['out'];
- $in = $static_money_json['in'];
- $add_money_json['in'] = [ //收入
- 'profix_car' => $val['profix_car'] + $in['profix_car'], //整车
- 'srv_price' => $settle_money_json['srv_price'] + $in['profix_car'], //服务费
- 'commission' => $settle_money_json['commission'] + $in['commission'], //佣金
- ];
- $add_money_json['out'] = [ //成本
- 'biz_price' => $out['biz_price'], //门店成本
- 'apply_price' => $settle_money_json['apply_price']+$out['apply_price'], //申请成本
- 'fine_price' => $settle_money_json['fine_price'] + $out['fine_price'], //赠送精品成本
- ];
- $data['money_json'] = json_encode($add_money_json,JSON_UNESCAPED_UNICODE);
$res = $this->biz_settle_static_model->update($data,['id'=>$static_row['id']]);
if($res){
$this->biz_settle_model->update(['stic_id'=>$static_row['id']],['id'=>$val['id']]);
@@ -479,17 +468,16 @@ class Biz extends HD_Controller
if($rows){
foreach($rows as $val){
$money_json = json_decode($val['money_json'],true);
+ $data = [
+ 'profix_car_after' => sprintf("%.2f",$val['profix_car']/1.13),
+ ];
+ $data['price_total'] = $val['price_all']+$data['profix_car_after'];
$biz_info = $this->biz_info_model->get(['biz_id'=>$val['biz_id']]);
- $in = $money_json['in'];
- $out = $money_json['out'];
- $in_price = $in['profix_car']+$in['srv_price']+$in['commission'];
- $out_price = $out['biz_price']+$out['apply_price']+$out['fine_price'];
- $price_need = $in_price-$out_price;
+ $price_need = $data['price_total'] = $money_json['biz_price'];
$partner_rate = $biz_info['rate']/100;
$liche_rate = (100-$biz_info['rate'])/100;
$data['profix_liche'] = $price_need*$liche_rate;
$data['profix_partner'] = $price_need*$partner_rate;
- $data['price_total'] = $in_price-$out_price;
$this->biz_settle_static_model->update($data,['id'=>$val['id']]);
}
diff --git a/common/models/biz/Biz_settle_price_model.php b/common/models/biz/Biz_settle_price_model.php
index 8bcaff28..cf66c878 100644
--- a/common/models/biz/Biz_settle_price_model.php
+++ b/common/models/biz/Biz_settle_price_model.php
@@ -44,6 +44,7 @@ class Biz_settle_price_model extends HD_Model
*/
public function sum_jsondata($jsondata=[]){
$jsondata = json_decode($jsondata,true);
+ print_r($jsondata);
$res = 0;
if($jsondata){
foreach ($jsondata as $key=>$val) {