优化结算

master
chenzhi 3 years ago
parent 0b44c4a9fa
commit 35ef9c4ec2

@ -16,6 +16,15 @@ class StatementWarningController extends AdminController
3=>'毛利',
4=>'营业利润'
];
private $companyBelong=[
0=>'下游内团',
1=>'下游外团',
9=>'上游'
];
private $isWm=[
1=>'是',
2=>'否'
];
//创建
public function _initialize(){
//初始化
@ -278,5 +287,118 @@ class StatementWarningController extends AdminController
$this->ajaxReturn(["error"=>"error"]);
}
}
/*********** 详情 ***************/
public function infoLists()
{
if(!array_key_exists("time",$_REQUEST)){
$this->redirect(ACTION_NAME, array('time' => date('Y-m',time())));
}
$time = explode('-',$_REQUEST['time']);
$year= $time[0];
if(strlen($time[1]) < 2) $time[1]="0".$time[1];
$month= $time[1];
$data = $this->statementWarningInfoModel->where("count_year = '{$year}' AND count_month = '{$month}'")->order('FIELD(company_belong,9,0,1),is_wm asc,statement_money desc')->select();
$count = $this->statementWarningInfoModel->where("count_year = '{$year}' AND count_month = '{$month}'")->field("company_belong,sum(statement_money) statement_money,sum(wm_amount) wm_amount,sum(other_amount) other_amount")->group('company_belong')->select();
$this->setWaringInfShow($data,$count);
$this->getMonthLastUpdate($year,$month);
$this->display();
}
private function setWaringInfShow($data,$count)
{
$allcount = [
'statement_money'=>0,
'wm_amount'=>0,
'other_amount'=>0
];
$sendData = [];
foreach ($data as $key => $value) {
$value['statement_money'] = round($value['statement_money']/10000,2);
$value['wm_amount'] = round($value['wm_amount']/10000,2);
$value['other_amount'] = round($value['other_amount']/10000,2);
$value['is_wmstr'] = $this->isWm[$value['is_wm']];
$sendData[$value['company_belong']]['list'][] = $value;
}
foreach ($count as $key => $value) {
$value['statement_money'] = round($value['statement_money']/10000,2);
$value['wm_amount'] = round($value['wm_amount']/10000,2);
$value['other_amount'] = round($value['other_amount']/10000,2);
$sendData[$value['company_belong']]['name'] = $this->companyBelong[$value['company_belong']];
$sendData[$value['company_belong']]['row'] = count( $sendData[$value['company_belong']]['list'])-0+1;
$sendData[$value['company_belong']]['count'] = $value;
$allcount['statement_money'] += $value['statement_money'];
$allcount['wm_amount'] += $value['wm_amount'];
$allcount['other_amount'] += $value['other_amount'];
}
$this->assign('data',$sendData);
$this->assign('allcount',$allcount);
}
private function getMonthLastUpdate($year,$month)
{
$lastUpdate = $this->statementWarningModel->where([
'count_year'=>$year,
'count_month'=>$month,
])->field("MAX(create_time) create_time")->find();
if($lastUpdate){
$lastUpdate = date('Y-m-d H:i:s',$lastUpdate['create_time']);
}else{
$lastUpdate = '未更新';
}
$this->assign('last_update', $lastUpdate);
}
public function infoEdit()
{
$p = I('post.');
$id = $p['id'];
$info = $this->statementWarningInfoModel->where("id = '{$id}'")->find();
$diffMoney = $info['wm_amount'];
if(isset($p['is_wm']) && $p['is_wm'] != $info['is_wm']){
if($p['is_wm'] == 1){
$info['wm_amount'] = $info['statement_money'];
$info['other_amount'] = 0;
}else{
$info['wm_amount'] = 0;
$info['other_amount'] = $info['statement_money'];
}
$info['is_wm'] = $p['is_wm'];
}
if(isset($p['wm_amount'])){
$info['wm_amount'] = $p['wm_amount']*10000;
$info['other_amount'] = $info['statement_money']-$p['wm_amount']*10000;
}
$this->statementWarningInfoModel->save($info);
$diffMoney = ($diffMoney - $info['wm_amount']);
if($diffMoney != 0)
{
//获取母单
$poolname = '';
if($info['company_belong'] == 1){
$poolname = 'pu_statement';
}
if($info['company_belong'] == 0){
$poolname = 'pc_statement';
}
if($info['company_belong'] == 9){
$poolname = 'up_statement';
}
$this->statementWarningModel->where([
'count_year'=>$info['count_year'],
'count_month'=>$info['count_month'],
'name'=>$poolname,
])->setDec('money',$diffMoney);
}
$this->ajaxReturn(['success'=>'ok']);
}
}

@ -385,7 +385,7 @@ class StatementWarningSetController extends Controller {
unset($company[$key]);
};
}
$puStatementAmount = $this->addStatementWarningInfo($company,0);
$puStatementAmount = $this->addStatementWarningInfo($company,1);
};
$this->addStatementWarning(2,'pu_statement',$puStatementAmount);
}

@ -0,0 +1,298 @@
<extend name="Public/base" />
<block name="body">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<script type="text/javascript" src="__STATIC__/layer3/layer.js"></script>
<style>
.select2-container--default .select2-selection--single {
color: #000;
resize: none;
border-width: 1px;
border-style: solid;
border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
box-shadow: 0px 3px 3px #F7F8F9 inset;
height: 35px;
height: 28px;
border-radius: 3px;
font-size: 12px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height: 35px;
line-height: 28px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height: 26px;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
height: 26px;
line-height: 26px;
font-size: 12px;
}
.select2-results__option[aria-selected] {
font-size: 12px;
}
.butnbox {padding:10px 0 15px;}
.butnbox .butnlist {overflow:hidden;clear:both;}
.butnbox .butnlist .butn,.butnbox .butnlist .butn:hover {text-decoration:none;border:none;}
.butnbox .butnlist .butn {display:inline-block;width:120px;height:28px;line-height:28px;text-align:center;color:#FFF;background:#3C95C8;border-radius:3px;}
.butnbox .butnlist .butn.last {background:#009900;}
.butnbox .butnlist .butn~.butn {margin-left:20px;}
.data_list table td{
border-right: 0;
}
</style>
<!-- 标题栏 -->
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">实时结算汇总单</h3>
<p class="description_text">说明:单位(万元)</p>
</div>
<style>
</style>
<div class="cf top_nav_list">
<!-- 高级搜索 -->
<div class="jssearch search_list fl cf" style="margin-bottom: 10px;">
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="time" name="time" class="select_gallery" style="width:150px;">
<option value="">请选择月份</option>
<volist name=":getMonth()" id="vo">
<option value="{$vo}" <if condition="$vo eq $_GET['time']">selected=selected</if>>{$vo}</option>
</volist>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search"
url="{:U('infoLists','model='.$model['name'] .'&row='.I('row'),false)}">
搜索</a>
</div>
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div style="display: flex;line-height: 3;justify-content:space-between;">
<div style="color: red;">
结算时间:{$last_update}
</div>
<div style="color: red;">
单位:万元
</div>
</div>
<table>
<thead>
<tr>
<th>项目</th><th>公司</th><th>实时结算金额合计</th><th>万盟结算金额</th><th>其他结算金额</th><th>是否万盟结算</th><th>操作</th>
</tr>
</thead>
<tbody>
<volist name="data" id="item" key="type">
<volist name="item.list" id="company" key="i">
<if condition="$i eq 1">
<tr style="border-top:1px solid #b6cad2;">
<td rowspan={$item['row']} style="border-right:1px solid #b6cad2;">{$item['name']}</td>
<td>{$item['list'][0]['company_name']}</td>
<td>{$item['list'][0]['statement_money']}</td>
<td>{$item['list'][0]['wm_amount']}</td>
<td>{$item['list'][0]['other_amount']}</td>
<td>{$item['list'][0]['is_wmstr']}</td>
<td><a class="infoedit" data-name="{$item['list'][0]['company_name']}" data-id="{$item['list'][0]['id']}" data-wmamount="{$item['list'][0]['wm_amount']}" data-iswm="{$item['list'][0]['is_wm']}">编辑</a></td>
</tr>
</if>
<if condition="$i neq 1">
<tr style="border-top:dotted 1px #c7c7c7;">
<td>{$company["company_name"]}</td>
<td>{$company['statement_money']}</td>
<td>{$company['wm_amount']}</td>
<td>{$company['other_amount']}</td>
<td>{$company['is_wmstr']}</td>
<td><a class="infoedit" data-name="{$company['company_name']}" data-id="{$company['id']}" data-wmamount="{$company['wm_amount']}" data-iswm="{$company['is_wm']}"">编辑</a></td>
</tr>
</if>
</volist>
<tr style="border-top:dotted 1px #c7c7c7;font-weight: 600;">
<td>小计:</td>
<td>{$item['count']['statement_money']}</td>
<td>{$item['count']['wm_amount']}</td>
<td>{$item['count']['other_amount']}</td>
<td></td>
<td></td>
</tr>
</volist>
<tr style="border-top:dotted 1px #c7c7c7;font-weight: 600;">
<td colspan="2">总计:</td>
<td>{$allcount['statement_money']}</td>
<td>{$allcount['wm_amount']}</td>
<td>{$allcount['other_amount']}</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<div style="width: 100%;height: 50px;"></div>
</div>
<script type="text/html" id="updateStatementTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
编辑结算相关数据,单位(万元)
</spend>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:30px;">
<input type="text" name="id" id="edit_id" value="0" style="display: none;">
<tr>
<td class="l noticeinfo" style="width:120px;">万盟结算金额:</td>
<td class="r table_radio">
<input type="number" class="txt ratio" name="wm_amount" id="edit_wm_amount" value="0" placeholder="" οninput="value=value.replace(/[^\w\.\/]/ig, '')" style="width: 150px;">
</td>
</tr>
<tr style="height:30px"></tr>
<tr>
<td class="l noticeinfo" style="width:120px;">是否万盟结算:</td>
<td class="r table_radio">
<div style="float: left;">
<select id="edit_iswm" name="type" style="width:150px;">
<option value="1"></option>
<option value="2"></option>
</select>
</div>
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="updateStatementSubmit" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
</block>
<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '
<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
charset="UTF-8"></script>
<script type="text/javascript">
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav('{:U("infoLists")}');
$(function () {
});
</script>
<script type="text/javascript">
$(function () {
$(".select_gallery").select2();
//搜索功能
$("#search").click(function () {
var url = $(this).attr('url');
var query = $('.jssearch').find('input').serialize();
query += "&" + $('.jssearch').find('select').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
query = query.replace(/^&/g, '');
if (url.indexOf('?') > 0) {
url += '&' + query;
} else {
url += '?' + query;
}
var start = $("#time_start").val();
var end = $("#time_end").val();
if (start != '' && end != '') {
if (Date.parse(start) > Date.parse(end)) {
layer.msg('开始时间必须小于等于结束时间');
return false;
}
}
window.location.href = url;
});
$(".infoedit").on("click",function(){
let data = $(this).data();
var html = $("#updateStatementTpl").html();
layer.open({
type: 1,
title: data.name+"/结算编辑",
maxWidth:720,
closeBtn: 1,
shadeClose: true,
content: html,
success:function(){
$("#edit_iswm").val(data.iswm);
$("#edit_id").val(data.id);
$("#edit_wm_amount").val(data.wmamount);
$("#updateStatementSubmit").off("click");
$("#updateStatementSubmit").on("click",function() {
var sendData = {};
var iswm = $("#edit_iswm").val();
var id = $("#edit_id").val();
var amount = $("#edit_wm_amount").val();
if(amount != data.wmamount){
sendData.wm_amount = amount;
}
if(iswm != data.iswm){
sendData.is_wm = iswm;
}
if($.isEmptyObject(sendData)){
layer.alert('未修改请直接关闭窗口');
return ;
}
sendData.id = id;
$.ajax({
type: 'post',
url: "{:U('infoEdit')}",
data:sendData,
success: function(data) {
if(data.success){
layer.alert('修改成功',function(){
window.location.reload();
});
}else{
layer.alert('修改失败');
}
},
error:function(){
layer.alert("网络错误或超时");
return false;
}
});
});
}
});
})
//回车自动提交
$('.jssearch').find('input').keyup(function (event) {
if (event.keyCode === 13) {
$("#search").click();
}
});
})
</script>
</block>
Loading…
Cancel
Save