edit-plan-settle_static
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,11 +81,37 @@
|
||||
{{v.title}} {{v.vin}}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{v.profix_car}}</td>
|
||||
<td>
|
||||
{{v.profix_car}}<br>
|
||||
优惠金额:{{v.o_money_json.price_discount}}
|
||||
</td>
|
||||
<td>{{v.profix_car_after}}</td>
|
||||
<td>{{v.profix_insure}}</td>
|
||||
<td>{{v.profix_loan}}</td>
|
||||
<td>{{v.profix_carno}}</td>
|
||||
<td>
|
||||
{{v.profix_insure}}<br>
|
||||
强险佣金:
|
||||
<span v-if="v.money_json.profix_insuer_ins">{{v.money_json.profix_insuer_ins}}</span>
|
||||
<span v-else>0</span><br>
|
||||
商业险佣金:
|
||||
<span v-if="v.money_json.profix_insuer_bis">{{v.money_json.profix_insuer_bis}}</span>
|
||||
<span v-else>0</span><br>
|
||||
</td>
|
||||
<td>
|
||||
{{v.profix_loan}}<br>
|
||||
<template v-if="v.profix_loan>0">
|
||||
手续费:
|
||||
<span v-if="v.srv_json">{{v.srv_json}}</span>
|
||||
<span v-else>0</span><br>
|
||||
利润:{{v.profix_loan-v.srv_json}}
|
||||
</template>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
{{v.profix_carno}}<br>
|
||||
<template v-if="v.profix_carno">
|
||||
挂牌:{{v.o_money_json.fee_carno}}<br>
|
||||
手续费:{{v.o_money_json.fee_carno-v.profix_carno}}
|
||||
</template>
|
||||
</td>
|
||||
<td>{{v.profix_fine}}</td>
|
||||
<td>{{v.sum_srv}}</td>
|
||||
<td>{{v.sum_srv_after}}</td>
|
||||
|
||||
@@ -38,10 +38,9 @@
|
||||
</th>
|
||||
<th width="10%"><span>门店</span></th>
|
||||
<th width="10%"><span>单车总毛利</span></th>
|
||||
<th width="10%"><span>服务费</span></th>
|
||||
<th width="10%"><span>佣金</span></th>
|
||||
<th width="10%"><span>税后单车总毛利</span></th>
|
||||
<th width="10%"><span>水平业务总毛利</span></th>
|
||||
<th width="10%"><span>门店费用</span></th>
|
||||
<th width="10%"><span>精品</span></th>
|
||||
<th width="10%"><span>其它费用</span></th>
|
||||
<th width="10%"><span>总利润</span></th>
|
||||
<th width="10%"><span>分润</span></th>
|
||||
@@ -56,27 +55,35 @@
|
||||
</td>
|
||||
<td>{{v.biz_name}}</td>
|
||||
<td>{{v.profix_car}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{{v.profix_car_after}}</td>
|
||||
<td>{{v.price_all}}</td>
|
||||
<td>
|
||||
|
||||
<template v-if="v.money_json.biz_price">
|
||||
<template v-for="(v2,i2) in v.money_json.biz_price_list">
|
||||
{{i2}}:{{v2}}<br>
|
||||
</template>
|
||||
总费用:{{v.money_json.biz_price}}
|
||||
</template>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<template v-for="item in v.price_other">
|
||||
{{item.name}}:{{item.money}}({{type_arr[item.type]}})<br>
|
||||
</template>
|
||||
</td>
|
||||
<td>{{v.price_ml}}</td>
|
||||
<td>
|
||||
狸车分润:{{v.profix_liche}}<br>
|
||||
品牌店分润:{{v.profix_partner}}
|
||||
合伙人分润:{{v.profix_partner}}
|
||||
</td>
|
||||
<td>{{v.month_str}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="11">
|
||||
<a :data-open="'biz/settle?_biz_type=1&biz_id='+v.biz_id+'&month='+v.month" href="javascript:;">查看明细</a>
|
||||
<td colspan="10" class="align-r">
|
||||
<a class="am-btn am-btn-primary am-btn-xs" :data-open="'biz/settle?_biz_type=1&biz_id='+v.biz_id+'&month='+v.month" href="javascript:;">查看明细</a>
|
||||
<a class="am-btn am-btn-primary am-btn-xs" :data-modal="'biz/settle/add_price?id='+v.id" data-title="新增费用" href="javascript:;">新增费用</a>
|
||||
<!--
|
||||
<a class="am-btn am-btn-primary am-btn-xs" data-ajax="post" data-action="biz/settle/edit_static" :data-params-id="v.id" href="javascript:;">重新结算</a>
|
||||
-->
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
@@ -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']]);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user