完成补点匹配功能开发

dev
曾超新 5 years ago
parent d1c4eda641
commit 70ba677eee
  1. 122
      frontend/controllers/FinanceController.php
  2. 93
      frontend/views/finance/receipt2-import.php
  3. 343
      frontend/views/finance/receipt2.php

@ -227,6 +227,10 @@ class FinanceController extends \frontend\controllers\UserBaseController
public function actionReceiptImport() {
return $this->render('receipt-import');
}
public function actionReceipt2Import() {
return $this->render('receipt2-import');
}
public function actionEmsReceipt()
{
$request = Yii::$app->request;
@ -3864,10 +3868,17 @@ class FinanceController extends \frontend\controllers\UserBaseController
return $result;
}
public function actionReceipt2()
public function actionReceipt2() {
$insurer_company_items = InsurerCompany2T::find()->all();
return $this->render('receipt2', [
'insurer_company_items' => $insurer_company_items
]);
}
public function actionReceipt2Json()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$page = $request->get('page', 1);
$begin_date = $request->get('begin_date');
$end_date = $request->get('end_date');
$r_begin_date = $request->get('r_begin_date');
@ -3878,43 +3889,14 @@ class FinanceController extends \frontend\controllers\UserBaseController
$sort_key = $request->get('sort_key');
$sort_value = $request->get('sort_value');
$company_id = $request->get('company_id');
if ($page < 1) $page = 1;
$insurer_type = $request->get('insurer_type');
$offset = $request->get('offset', 0);
$limit = $request->get('limit', 10);
// $query = OrderCaiwuT::find()
// ->where('budian_rate>0');
$query = CaiwuT::find()
->leftJoin(OrderCaiwuT::tableName(), "order_caiwu_t.order_id=caiwu_t.order_id")
->leftJoin(OrderT::tableName(), "order_caiwu_t.order_id=order_t.id")
->where('order_caiwu_t.budian_rate > 0');
// ->orderBy('order_t.print_date DESC');
// switch ($sort_key) {
// case 'total':
// $sort = 'caiwu_t.total ';
// break;
// case 'total_clear':
// $sort = 'caiwu_t.total_clear ';
// break;
// case 'total_rate':
// $sort = 'caiwu_t.total_rate ';
// break;
// case 'print_date'://默认按照print_date排序
// default:
// $sort = 'order_t.print_date ';
// break;
// }
// switch ($sort_value) {
// case 'ASC':
// $sort .= 'ASC';
// break;
// case 'DESC':
// default:
// $sort .= 'DESC';
// break;
// }
// $query = $query->orderBy($sort);
->where('caiwu_t.budian_rate > 0');
if( $company_id > 0) {
$query = $query->andWhere('order_t.company_id='.$company_id);
}
@ -3926,10 +3908,10 @@ class FinanceController extends \frontend\controllers\UserBaseController
}
if ($status > 0) {
if ($status == 1) {
$query = $query->andWhere('r_date=""');
$query = $query->andWhere('b1_date is null');
}
if ($status == 2) {
$query = $query->andWhere('r_date<>""');
$query = $query->andWhere('b1_date is not null');
}
}
if ($begin_date != "") {
@ -3944,43 +3926,38 @@ class FinanceController extends \frontend\controllers\UserBaseController
if ($r_end_date != "") {
$query = $query->andWhere('caiwu_t.r_date<="' . $r_end_date . '"');
}
if($insurer_type != 0){
$query = $query->andWhere('caiwu_t.insurer_type =' . $insurer_type);
}
// echo $query->createCommand()->rawSql;
$total = $query->count();
$pagination = new Pagination(['totalCount' => $total, 'pageSize' => 20]);
$pagination->setPage($page - 1);
$query = $query->offset($pagination->offset)->limit($pagination->limit);
$query->offset($offset)->limit($limit);
$items = $query->all();
// $sum_r_total = $query->sum('r_total');
//商业净保费综合
// $sum_total_clear = $query->sum('total_clear');
//商业总保费
// $sum_total = $query->sum('total');
$data = [];
$data['total'] = $total;
$data['rows'] = [];
foreach($items as $item) {
$row = $item->toArray();
$row['company_name'] = $item->order->company2->name;
$row['print_date'] = $item->order->print_date;
$row['total_real'] = round($item->total_clear,2);
$row['budian_rate'] = $item->budian_rate;
$row['budian_money'] = $item->budian_money;
$row['b1_total'] = $item->b1_total;
$row['b1_date'] = $item->b1_date;
$row['b2_total'] = $item->b2_total;
$row['b2_date'] = $item->b2_date;
$row['b3_total'] = $item->b3_total;
$row['b3_date'] = $item->b3_date;
$row['b_total'] = round($row['b1_total']+$row['b2_total']+$row['b3_total'],2);
$row['un_b_total'] = round($row['budian_money'] - $row['b_total'],2);
$data['rows'][] = $row;
}
$page_info = MyLib::getPageInfo($pagination);
$company_items = InsurerCompanyT::find()->all();
return $this->render('receipt2', [
'items' => $items,
'page' => $page,
'car_no' => $car_no,
'insurer_no' => $insurer_no,
'status' => $status,
'begin_date' => $begin_date,
'end_date' => $end_date,
'r_begin_date' => $r_begin_date,
'r_end_date' => $r_end_date,
'page_info' => $page_info,
'sort_key' => $sort_key,
'company_items' => $company_items,
'company_id' => $company_id,
'sort_value' => $sort_value
// 'sum_r_total' => $sum_r_total,
// 'sum_total_clear' => $sum_total_clear,
// 'sum_total' => $sum_total,
]);
return $data;
}
public function actionReceipt2Output()
{
@ -4139,22 +4116,13 @@ class FinanceController extends \frontend\controllers\UserBaseController
$insurer_total = $cell->getValue();//$data[$i][6];
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
$insurer_date = $cell->getFormattedValue();
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
$car_no = $cell->getValue();//$data[$i][8];
// if($insurer_no == 'PDAA201811010000089441') {
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
// exit;
// }
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
$row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
if ($row) {
CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
if($bdlx == 1) {
$row->b1_total = $insurer_total;
$row->b1_date = $insurer_date;

@ -0,0 +1,93 @@
<?php
use \common\libs\MyLib;
?>
<?php $this->beginBlock('header_css'); ?>
<?php $this->endBlock(); ?>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="row">
<div class="col-sm-12">
<form role="form" class="form-horizontal data-from" id="theFrm">
<div class="form-group">
<label class="control-label col-sm-2">批次</label>
<div class="col-sm-6">
<select name="bdlx" class="form-control">
<option value="1">补点1</option>
<option value="2">补点2</option>
<option value="3">补点3</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">导入文件</label>
<div class="col-sm-6">
<div class="input-group">
<input type="text" name="urlfile" id="urlfile" class="form-control" value="">
<a href="javascript:void(0);" class="input-group-addon" id="upload">
上传文件
</a>
</div>
</div>
</div>
<div>
<div class="row">
<div class="col-sm-5 col-sm-offset-5">
<button class="btn btn-primary btn-save" type="button">
<strong>导 入</strong>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php $this->beginBlock('footer_js'); ?>
<script type="text/javascript" language="javascript">
layui.use(['upload'], function(){
var upload = layui.upload;
var uploadInst = upload.render({
elem: '#upload' //绑定元素
,url: '/common/upload' //上传接口
,accept: 'file'
,done: function(res){
//上传完毕回调
if(res.status == 'SUCCESS') {
$('#urlfile').val(res.fileUrl);
}
}
,error: function(){
//请求异常回调
}
});
});
$(function () {
//提交按钮
$(".btn-save").click(function(){
parent.layer.confirm('是否确认提交?', {
btn: ['确认','取消'], //按钮
shade: false //不显示遮罩
}, function(){
var params = $("#theFrm").serialize();
$.post('/finance/receipt2-process',params,function(obj){
if(obj.success) {
parent.layer.msg('保存成功');
parent.refreshList();
layer_close();
} else {
parent.layer.msg(data.msg);
}
},'json');
}, function(){
//
});
});
})
</script>
<?php $this->endBlock('footer_js'); ?>

@ -1,222 +1,141 @@
<?php
use \common\libs\MyLib;
?>
<link rel="stylesheet" href="/js/fileupload/css/jquery.fileupload.css">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
<form id="theFrm">
<tr>
<td align="center" width="100" height="25" class="td_bg">导入类型</td>
<td height="25" class="td_bg">
<select name="bdlx">
<option value="1">补点1</option>
<option value="2">补点2</option>
<option value="3">补点3</option>
</select>
</td>
</tr>
<tr>
<td align="center" width="100" height="25" class="td_bg">批对日期</td>
<td height="25" class="td_bg">
<input type="text" name="urlfile" id="urlfile" style="width: 300px;">
<input id="fileupload" type="file" name="file">
</td>
</tr>
</form>
<tr>
<td height="22" colspan="2" align="center" class="td_bg">
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/>
&nbsp;&nbsp;
<input type="button" class="ACT_btn" name="Submit3" value=" 刷新 " onclick="window.location.reload();">
</td>
</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="searchForm">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<tr>
<td class="td_bg">
<!--新增搜索项-->
<!--完成程度-->
<select name="status" class="status">
<option value=0>全部</option>
<option value=1 <?= $status==1?'selected':'' ?>>未匹配</option>
<option value=2 <?= $status==2?'selected':'' ?>>已完成</option>
</select>
保单号:<input name="insurer_no" type="text" value="<?=$insurer_no?>">
车牌:<input name="car_no" type="text" value="<?=$car_no?>">
<!--日期-->
出单日期:
<input type="Text" class="Wdate" name="begin_date" onclick="WdatePicker()" value="<?= $begin_date ?>" />
--
<input type="Text" class="Wdate" name="end_date" onclick="WdatePicker()" value="<?= $end_date ?>" />
回单日期:
<input type="Text" class="Wdate" name="r_begin_date" onclick="WdatePicker()" value="<?= $r_begin_date ?>" />
--
<input type="Text" class="Wdate" name="r_end_date" onclick="WdatePicker()" value="<?= $r_end_date ?>" />
保险公司:<select name="company_id">
<option value="0">全部</option>
<?php
foreach($company_items as $item) {
echo '<option value="'.$item->id.'"';
if($item->id == $company_id)
echo ' selected ';
echo '>'.$item->name.'</option>';
}
?>
</select>
排序:
<select name="sort_key">
<option value="0">请选择</option>
<option value="print_date" <?= $sort_key == 'print_date' ? 'selected' : ''?>>出单日期</option>
<option value="total" <?= $sort_key == 'total' ? 'selected' : ''?>>商业总保费</option>
<option value="total_clear" <?= $sort_key == 'total_clear' ? 'selected' : ''?>>商业净保费</option>
<option value="total_rate" <?= $sort_key == 'total_rate' ? 'selected' : ''?>>手续费比例</option>
</select>
<select name="sort_value">
<option value="0">请选择</option>
<option value="ASC" <?= $sort_value == 'ASC' ? 'selected' : ''?>>正序</option>
<option value="DESC" <?= $sort_value == 'DESC' ? 'selected' : ''?>>倒序</option>
</select>
<input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索">
<input type="button" class="act_btn" id="output-btn" name="output-btn" value="导出">
</td>
</tr>
</form>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
<tr>
<td width="24" align="center" class="bg_tr">序号</td>
<td align="center" class="bg_tr">车牌号</td>
<td align="center" class="bg_tr">保险公司</td>
<td align="center" class="bg_tr">保单号</td>
<td align="center" class="bg_tr">出单日期</td>
<td align="center" class="bg_tr">商业净保费</td>
<td align="center" class="bg_tr">补点比例</td>
<td align="center" class="bg_tr">应得金额</td>
<td align="center" class="bg_tr">补点1回款</td>
<td align="center" class="bg_tr">补点1日期</td>
<td align="center" class="bg_tr">补点2回款</td>
<td align="center" class="bg_tr">补点2日期</td>
<td align="center" class="bg_tr">补点3回款</td>
<td align="center" class="bg_tr">补点3日期</td>
<td align="center" class="bg_tr">已回金额</td>
<td align="center" class="bg_tr">未回金额</td>
</tr>
<?php
foreach($items as $index => $item) {
$start_index = ($page-1)*20+$index;
$order = $item->order;
$caiwu = $order->caiwu;
// $caiwu = $order->caiwu;
// $rate = $caiwu ? $caiwu->budian_rate : 0;
if($item->insurer_type==2){
$caiwu->budian_rate=0;
}
$total_clear = round($item->total_clear * $caiwu->budian_rate/100,2);
$b_total = $item->b1_total+$item->b2_total+$item->b3_total;
// $total_clear_real = $item->total_clear * $rate/100;
// $total_dis = round($total_clear_real - $item->r_total,2);
?>
<tr style="height:24px;" onMouseOver="overColor(this)" onMouseOut="outColor(this)">
<td align="center" class="td_bg" nowrap><?=$start_index+1?></td>
<td align="center" class="td_bg" nowrap><?=$order->car_no?></td>
<td align="center" class="td_bg" nowrap><?=$order && $order->company ? $order->company->name:''?></td>
<td align="center" class="td_bg" nowrap><?=$item->insurer_no?></td>
<td align="center" class="td_bg" nowrap><?=$order->print_date?></td>
<td align="center" class="td_bg" nowrap><?=$item->total_clear?></td>
<td align="center" class="td_bg" nowrap><?=$caiwu->budian_rate?></td>
<td align="center" class="td_bg" nowrap><?=$total_clear?></td>
<td align="center" class="td_bg" nowrap><?=$item->b1_total?></td>
<td align="center" class="td_bg" nowrap><?=$item->b1_date?></td>
<td align="center" class="td_bg" nowrap><?=$item->b2_total?></td>
<td align="center" class="td_bg" nowrap><?=$item->b2_date?></td>
<td align="center" class="td_bg" nowrap><?=$item->b3_total?></td>
<td align="center" class="td_bg" nowrap><?=$item->b3_date?></td>
<td align="center" class="td_bg" nowrap><?=$b_total?></td>
<td align="center" class="td_bg" nowrap><?=$total_clear-$b_total?></td>
</tr>
<?php
}
?>
<tr>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
<td align="center" class="bg_tr" nowrap></td>
</tr>
<tr >
<td height="25" colspan="16" align="center" class="td_bg"><?=$page_info?></td>
</tr>
</table>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/datepicker/WdatePicker.js"></script>
<script type="text/javascript" language="javascript" src="/js/fileupload/js/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" language="javascript" src="/js/fileupload/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" language="javascript" src="/js/fileupload/js/jquery.fileupload.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
$(function () {
//上传按钮
$('#upload-btn').click(function(){
$('#fileupload').click();
});
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<?php $this->endBlock(); ?>
//提交按钮
$("#submit-btn").click(function(){
if(confirm('是否确认提交?')) {
var urlfile = $("#urlfile").val();
var import_type = $(".import_type").val();
<div class="wrapper wrapper-content animated fadeInRight">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>回单匹配</h5>
<div class="ibox-tools">
<a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="importDlg()">
<i class="fa fa-plus"></i> 补点导入
</a>
<a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="$('#listTable').bootstrapTable('refresh');">
<i class="fa fa-refresh"></i> 刷新
</a>
</div>
</div>
<div class="ibox-content">
<form role="form" id="searchFrm" class="form-inline" onsubmit="return search();">
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">匹配程度</label>
<select name="status" class="status" class="form-control">
<option value=0>全部</option>
<option value=1>未匹配</option>
<option value=2>已完成</option>
</select>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">保单号</label>
<input type="text" id="insurer_no" name="insurer_no" class="form-control">
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">车牌</label>
<input type="text" id="car_no" name="car_no" class="form-control">
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">出单日期</label>
<div class="input-group">
<input type="text" id="begin_date" name="begin_date" class="form-control date">
<div class="input-group-addon">-</div>
<input type="text" id="end_date" name="end_date" class="form-control date">
</div>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">回单日期</label>
<div class="input-group">
<input type="text" id="r_begin_date" name="r_begin_date" class="form-control date">
<div class="input-group-addon">-</div>
<input type="text" id="r_end_date" name="r_end_date" class="form-control date">
</div>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">保险公司</label>
<select name="company_id" id="company_id" class="form-control">
<option value="0">---请选择---</option>
<?php
foreach($insurer_company_items as $item) {
echo '<option value="'.$item->id.'">'.$item->name.'</option>';
}
?>
</select>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">级别</label>
<input type="text" id="name" name="name" class="form-control">
</div>
<button type="submit" class="btn btn-primary mb-8">搜索</button>
</form>
<div class="row">
<div class="col-md-12">
<table id="listTable">
<thead>
<tr>
<th data-field="id">ID</th>
<th data-field="car_no">车牌号</th>
<th data-field="company_name">保险公司</th>
<th data-field="insurer_no">保单号</th>
<th data-field="print_date">出单日期</th>
<th data-field="total_clear">商业净保费</th>
<th data-field="budian_rate">补点比例</th>
<th data-field="budian_money">应得金额</th>
<th data-field="b1_total">补点1回款</th>
<th data-field="b1_date">补点1日期</th>
<th data-field="b2_total">补点2回款</th>
<th data-field="b2_date">补点2日期</th>
<th data-field="b3_total">补点3回款</th>
<th data-field="b3_date">补点3日期</th>
<th data-field="b_total">已回金额</th>
<th data-field="un_b_total">未回金额</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
if(urlfile == ''){
alert('请先选择文件!');
return false;
}
var last_url = '/finance/receipt2-process';
var params = $("#theFrm").serialize();
$.post(last_url,params,function(obj){
alert(obj.msg);
if(obj.success){
$('#theFrm')[0].reset();
window.location.reload();
}
},'json');
}
<?php $this->beginBlock('footer_js'); ?>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
var o = {};
function importDlg(id) {
var title = '手续费导入';
layer_show(title, '/finance/receipt2-import');
}
function refreshList() {
$('#listTable').bootstrapTable('refresh');
}
function search() {
o = {};
var params = $("#searchFrm").serializeArray();
$.each(params, function(index) {
o[this['name']] = this['value'];
});
//上传
$('#fileupload').fileupload({
url: '/finance/receipt-upload',
dataType: 'json',
done: function (e, data) {
var file_info = data.result.files[0];
$('#urlfile').val(file_info.url);
$('#submit-btn').removeAttr('disabled');
$('#listTable').bootstrapTable('destroy');
$('#listTable').bootstrapTable({
url: "/finance/receipt2-json",
pagination: true,
sidePagination: 'server',
queryParams: function(params) {
o['offset'] = params['offset'];
o['limit'] = params['limit'];
return o;
}
});
//搜索
$("#search-btn").click(function(){
$('#page').val(0);
var params = $('#searchForm').serialize();
window.location.href = "/finance/receipt2?" + params;
});
//导出
$("#output-btn").click(function(){
$('#page').val(0);
var params = $('#searchForm').serialize();
window.location.href = "/finance/receipt2-output?" + params;
});
})
return false;
}
$(function() {
search();
});
</script>
<?php $this->endBlock(); ?>

Loading…
Cancel
Save