财务对比 v1

master
chenzhi 5 years ago
parent a2db46d1c0
commit b2ad4e8b6e

@ -6,12 +6,23 @@ class FinanceCompareController extends ThinkController
public $wx = [2,3];//微信渠道id
public $ybzf = [17];//易宝渠道id
public $erro_size = 2000;//商家不存在的错误阈值,到达就不执行
public $page_size = 10;//每次执行比较的数量
public $page_size = 1000;//每次执行比较的数量
public $payway = [
"1"=>"支付宝",
"2"=>"微信",
"3"=>"易宝"
];
public $checktype=[
"1"=>"金额不符",
"2"=>"商家数据缺失",
"3"=>"平台数据缺失",
"4"=>"状态不符",
"5"=>"渠道不符"
];
public $readtype=[
"0"=>"未处理",
"1"=>"已处理"
];
public function index($p=1)
{
@ -30,10 +41,10 @@ class FinanceCompareController extends ThinkController
}
$listdata = M("finance_compare","tab_")->where($map);
if(isset($_REQUEST['export'])){
$listdata = $listdata->page($page,$row)->select();
$listdata = $listdata->select();
$count = M("finance_compare","tab_")->where($map)->count();
}else{
$listdata = $listdata->select();
$listdata = $listdata->page($page,$row)->select();
$count = count($listdata);
}
foreach ($listdata as $k => &$v) {
@ -70,6 +81,125 @@ class FinanceCompareController extends ThinkController
$this->assign("page_size",$this->page_size);
$this->display();
}
public function list($p=1)
{
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$arraypage = $page;
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
if (isset($_REQUEST['compare_id'])) {
$compare_id = $_REQUEST['compare_id'];
}else{
$this->error("参数错误");
}
$map=["type"=>["gt",0],"compare_id"=>$compare_id];
if ($_REQUEST['pay_order_number'] != '') {
$map['pay_order_number'] = $_REQUEST['pay_order_number'];
}
if ($_REQUEST['is_read'] != '') {
$map['is_read'] = $_REQUEST['is_read'];
}
if ($_REQUEST['type'] != '') {
$map['type'] = $_REQUEST['type'];
}
$listdata = M("finance_compare_info","tab_")->where($map);
if(isset($_REQUEST['export'])){
$listdata = $listdata->select();
}else{
$listdata = $listdata->page($page,$row)->select();
}
foreach ($listdata as $k => &$v) {
$v['pay_way']=$this->payway[$v['pay_way']];
$v['type']=$this->checktype[$v['type']];
$v['read_str']=$this->readtype[$v['is_read']];
}
if(isset($_REQUEST['export'])){
$GetData = $_GET;
unset($GetData['export']);
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U(CONTROLLER_NAME.'/'.ACTION_NAME,$GetData),'menu'=>"统计-数据校验-订单校验-订单校验详情-导出"]);
data2csv($listdata,'订单校验详情',array(
"pay_order_number"=>"订单号",
"pay_way"=>"支付渠道",
"read_str"=>"状态",
"pt_pay_amount"=>"平台支付金额",
"sj_pay_amount"=>"商家订单金额",
"diff_money"=>"相差金额",
"type"=>"原因分类"
));
}
$count = M("finance_compare_info","tab_")
->field("count(*) count,
SUM(CASE WHEN is_read = 0 THEN pt_pay_amount ELSE 0 END) as noread_pt_pay_amount,
SUM(CASE WHEN is_read = 0 THEN sj_pay_amount ELSE 0 END) as noread_sj_pay_amount,
SUM(CASE WHEN is_read = 0 THEN diff_money ELSE 0 END) as noread_diff_money,
SUM(pt_pay_amount) pt_pay_amount,
SUM(sj_pay_amount) sj_pay_amount,
SUM(diff_money) diff_money")
->where($map)
->find();
$page = set_pagination($count['count'],$row);
if($page) {$this->assign('_page', $page);}
$this->assign('list_data',$listdata);
$this->assign('count_data',$count);
$this->assign('read_type',$this->readtype);
$this->assign('check_type',$this->checktype);
$this->display();
}
public function changeRead()
{
if (isset($_REQUEST['id']) && isset($_REQUEST['is_read']) && isset($_REQUEST['compare_id'])) {
$id = $_REQUEST['id'];
$is_read = $_REQUEST['is_read'];
$compare_id = $_REQUEST['compare_id'];
}else{
$this->error("参数错误");
}
//处理数据
$info = M("finance_compare_info","tab_")->where("id={$id}")->find();
if($info['is_read'] != $is_read){
$this->ajaxReturn(array("error"=>"此单已标记成功请勿重复点击","code"=>40001));
}
//获取
$fc = M("finance_compare","tab_")->where("id={$compare_id}")->find();
if($is_read == 0){
//改为已处理
$fcsavedata = [
"diff_count"=>$fc['diff_count']-1,
"diff_money"=>$fc['diff_money']-$info['diff_money'],
];
$isavedata = [
"is_read"=>1
];
}else{
//改为未处理
$fcsavedata = [
"diff_count"=>$fc['diff_count']-0+1,
"diff_money"=>$fc['diff_money']-0+$info['diff_money'],
];
$isavedata = [
"is_read"=>0
];
}
//保存
M("finance_compare","tab_")->where("id={$compare_id}")->save($fcsavedata);
M("finance_compare_info","tab_")->where("id={$id}")->save($isavedata);
$this->ajaxReturn(array("success"=>"处理成功","code"=>0));
}
/**
* 创建比较基础数据
*/
public function creatCompare()
{
$adddata = I("post.");
@ -85,6 +215,9 @@ class FinanceCompareController extends ThinkController
$this->ajaxReturn(array("error"=>"creat error","code"=>4000));
}
}
/**
* 循环比较数据
*/
public function compareData()
{
$checkdata = I('POST.');
@ -97,6 +230,9 @@ class FinanceCompareController extends ThinkController
$pf=[];
$er=[];
foreach($data as $k=>$v){
$v[$keys[0]] = trim($v[$keys[0]]);
$v[$keys[1]] = trim($v[$keys[1]]);
$pay_where = substr($v[$keys[0]], 0, 2);
$tmp = [
"pt_pay_amount"=>0,
@ -129,6 +265,7 @@ class FinanceCompareController extends ThinkController
}
$saveres = $this->saveCheckData($sp);
if($saveres == false){
$this->delCompare($compare_id);
$this->ajaxReturn(array("error"=>"添加失败","code"=>40001));
}
}
@ -142,6 +279,7 @@ class FinanceCompareController extends ThinkController
}
$saveres = $this->saveCheckData($pf);
if($saveres == false){
$this->delCompare($compare_id);
$this->ajaxReturn(array("error"=>"添加失败","code"=>40002));
}
}
@ -149,6 +287,7 @@ class FinanceCompareController extends ThinkController
if(count($er) > 0){
$saveerrores = $this->saveCheckData($er);
if($saveerrores == false){
$this->delCompare($compare_id);
$this->ajaxReturn(array("error"=>"添加失败","code"=>40003));
}
}
@ -183,6 +322,7 @@ class FinanceCompareController extends ThinkController
];
$res = M("Spend","tab_")->field("pay_order_number,pay_amount,pay_status,pay_way")->where($map)->limit($this->erro_size)->select();
if(count($res) >= $this->erro_size){
$this->delCompare($checkdata['compare_id']);
$this->ajaxReturn(array("error"=>"商家不存在的数据大于{$this->erro_size}条,没有比较的意义,请确认表格的渠道和时间是否正确","code"=>40004));
}
$saveres = true;
@ -208,6 +348,7 @@ class FinanceCompareController extends ThinkController
if($saveres){
$this->ajaxReturn(array("success"=>"ok","code"=>0,"data"=>[]));
}else{
$this->delCompare($checkdata['compare_id']);
$this->ajaxReturn(array("error"=>"比对数据添加失败","code"=>40005));
}
}
@ -239,6 +380,7 @@ class FinanceCompareController extends ThinkController
];
$res = M("Deposit","tab_")->field("pay_order_number,pay_amount,pay_status,pay_way")->where($map)->limit($this->erro_size)->select();
if(count($res) >= $this->erro_size){
$this->delCompare($checkdata['compare_id']);
$this->ajaxReturn(array("error"=>"商家不存在的数据大于{$this->erro_size}条,没有比较的意义,请确认表格的渠道和时间是否正确","code"=>40004));
}
$saveres = true;
@ -264,14 +406,12 @@ class FinanceCompareController extends ThinkController
if($saveres){
$this->ajaxReturn(array("success"=>"ok","code"=>0,"data"=>[]));
}else{
$this->delCompare($checkdata['compare_id']);
$this->ajaxReturn(array("error"=>"比对数据添加失败","code"=>40005));
}
}
/**
* 生成最终比较统计
* @param [type] $dbres
* @param [type] $ydata
* @return void
*/
public function creatCompareCount()
{
@ -282,7 +422,7 @@ class FinanceCompareController extends ThinkController
"compare_id"=>$compare_id,
"type"=>["gt",0]
];
$ires = M("finance_compare_info","tab_")->field("IFNULL(sum(diff_money),0) diff_money,IFNULL(count(*),0) count")->find();
$ires = M("finance_compare_info","tab_")->field("IFNULL(sum(diff_money),0) diff_money,IFNULL(count(*),0) count")->where($imap)->find();
$savedata = [
"diff_count"=>$ires['count'],
"diff_money"=>$ires['diff_money'],
@ -292,6 +432,7 @@ class FinanceCompareController extends ThinkController
if($res){
$this->ajaxReturn(array("success"=>"ok","code"=>0,"data"=>[]));
}else{
$this->delCompare($compare_id);
$this->ajaxReturn(array("error"=>"save error","code"=>40006));
}
@ -351,4 +492,10 @@ class FinanceCompareController extends ThinkController
unset($arr);
return $res;
}
//回退删除
protected function delCompare($compare_id){
M("finance_compare_info","tab_")->where("compare_id = '{$compare_id}'")->delete();
M("finance_compare","tab_")->where("id = '{$compare_id}'")->delete();
}
}

@ -23,7 +23,7 @@
<!-- 标签页导航 -->
<div class="tab-wrap" style="display: flex;">
<div class="tab-content tabcon1711" style="min-width:50%;">
<div class="tab-content tabcon1711" style="min-width:900px;min-height: 60vh;border-right: 1px solid #333;">
<!-- 基础文档模型 -->
<div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0">
@ -79,13 +79,39 @@
</a>
</div>
</div>
<div>
4654654646
<div style="width: 400px;margin-left: 50px;">
<style>
#cktable td,#cktable th{
padding: 5px;
min-width: 100px;
}
</style>
<div style="width: 100%;height: 45px;font-size: 20px;">
文件格式参考:
</div>
<table id="cktable" style="width: 100%;margin: 0;padding: 0;text-align: center;border: 1px solid #777;" border="1px">
<thead>
<tr>
<th>订单号</th>
<th>金额</th>
</tr>
</thead>
<tbody>
<tr>
<td>SP_202003251032543yjX</td>
<td>0.01</td>
</tr>
<tr>
<td>PF_20200325103203fBPI</td>
<td>0.01</td>
</tr>
</tbody>
</table>
</div>
</div>
<div style="width: 100vw;height: 100vh;padding: 0;position: absolute;top: 0;z-index: 9999;display: none;" id="creat_msg">
<div class="layui-layer layui-layer-dialog layui-layer-border layui-layer-msg layui-layer-hui"
type="dialog" times="1" showtime="50000" contype="string" style="z-index: 19891015; top:30%; left: 45%;">
type="dialog" times="1" showtime="50000" contype="string" style="z-index: 19891015; top:30%; left:30%;">
<div class="layui-layer-content" style="padding: 15px 0 5px;font-size: 20px;font-weight: 600;">执行进度</div>
<div id="tip_msg" class="layui-layer-content">开始时间与结束时间都不允许为空</div>
<div class="layui-layer-content" style="padding: 5px 10px 15px;font-size: 10px;color: #BBB;">TIP:未执行完成之前请勿刷新或关闭此页面</div>

@ -143,7 +143,7 @@
<td>{$data.diff_money}</td>
<td>{$data.create_time}</td>
<td>
<a href="{:U('list',['id'=>$data['id']])}">查看详情</a>
<a href="{:U('list',['compare_id'=>$data['id']])}">查看详情</a>
</td>
</tr>
</volist>

@ -0,0 +1,252 @@
<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;
}
.tooltip {
position: relative;
/* display: block; */
/* color: #056dae; */
}
.tooltip .tooltiptext {
display: none;
width: 100%;
background-color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 10px 5px 5px;
position: absolute;
z-index: 1;
bottom: 80%;
left: 0;
border: #000 solid 1px;
line-height: 20px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: black transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
color: #333;
display: block;
}
</style>
<!-- 标题栏 -->
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">订单校验</h3>
<p class="description_text">说明:对游戏订单及平台币订单等进行比较校验</p>
</div>
<div class="cf top_nav_list">
<!-- 高级搜索 -->
<div class="jssearch search_list fl cf">
<div class="input-list search-title-box">
<a class="sch-btn" href="javascript:history.go(-1)" style="background:#fff;color: #000;border: #000 solid 1px;width: 100px">返回</a>
</div>
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<div class="input-list">
<input type="text" name="pay_order_number" placeholder="订单号检索" class="" value="{:I('pay_order_number')}" style="width: 220px"/>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="is_read" name="is_read" class="select_gallery">
<option value="">请选择处理状态</option>
<foreach name="read_type" item="vo" >
<option value="{$key}" <?php echo I('is_read') && I('is_read') == $key ? "selected" : ''?>>{$vo}</option>
</foreach>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="type" name="type" class="select_gallery">
<option value="">请选择异常原因</option>
<foreach name="check_type" item="vo" >
<option value="{$key}" <?php echo I('type') == $key ? "selected" : ''?>>{$vo}</option>
</foreach>
</select>
</div>
<input type="hidden" name="row" value="{$_GET['row']}"/>
<input type="hidden" name="compare_id" value="{$_GET['compare_id']}"/>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search"
url="{:U('list',false)}">
搜索</a>
</div>
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th>订单号</th>
<th>支付渠道</th>
<th>状态</th>
<th>平台支付金额</th>
<th>商家订单金额</th>
<th>相差金额</th>
<th>原因分类</th>
<th>操作</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<empty name="list_data">
<td colspan="15" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="list_data" id="data">
<tr>
<td>{$data.pay_order_number}</td>
<td>{$data['pay_way']}</td>
<td>{$data['read_str']}</td>
<td>{$data.pt_pay_amount}</td>
<td>{$data.sj_pay_amount}</td>
<td>{$data.diff_money}</td>
<td>{$data.type}</td>
<td>
<if condition="$data.is_read eq 1">
<a style="color: #ff0000;" class="changeRead" href="javascript:;" url="{:U('changeRead',['id'=>$data['id'],'is_read'=>$data['is_read']])}">标记为未处理</a>
<else />
<a href="javascript:;" class="changeRead" url="{:U('changeRead',['id'=>$data['id'],'is_read'=>$data['is_read']])}">标记为处理</a>
</if>
</td>
</tr>
</volist>
</empty>
<tr style="padding: 10px 0;height: 80px;">
<td colspan="3"><span>汇总(检索内所有数据统计)</span></td>
<td style="line-height:2;">
待处理:{$count_data['noread_pt_pay_amount']} <br> 全部:{$count_data['pt_pay_amount']}
</td>
<td style="line-height:2;">
待处理:{$count_data['noread_sj_pay_amount']} <br>全部:{$count_data['sj_pay_amount']}
</td>
<td style="line-height:2;">
待处理:{$count_data['noread_diff_money']} <br>全部:{$count_data['diff_money']}
</td>
<td colspan="2">
校验数量:{$count_data['count']}
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="page">
<a class="sch-btn" href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
{$_page|default=''}
</div>
</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("index")}');
</script>
<script type="text/javascript">
$(function () {
$("#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;
}
window.location.replace(url)
// window.location.href = url;
});
$(".select_gallery").select2();
$('.page a').click(function () {
var href = $(this).attr('href');
$(this).removeAttr('href');
window.location.replace(href)
});
$(".changeRead").on("click",function(){
var url = $(this).attr("url");
var compare_id = $("input[name='compare_id']").val();
$.ajax({
type: 'post',
url: url,
data:{compare_id:compare_id},
success: function(data) {
if(data.success){
layer.msg("处理成功",function(){
window.location.reload();
});
}else{
layer.alert(data.error);
}
},
});
})
})
</script>
</block>
Loading…
Cancel
Save