聚合财务重算

master
chenzhi 5 years ago
parent 253b47b2a9
commit 16d9813e18

@ -146,6 +146,65 @@ class AggregateFinanceSetController extends Controller {
echo "----补点统计ok".PHP_EOL;
}
}
public function updateAggregateFinanceData($id)
{
//获取基础信息
$Aggregate = M("aggregate_statement","tab_");
$info = $Aggregate->where("id='{$id}'")->find();
$sign = md5($info['begintime'].$info['endtime'].$info['withdraw_type'].$this->token);
$arr = [
"begintime"=>$info['begintime'],
"endtime"=>$info['endtime'],
"type"=>$info['withdraw_type'],
"sign"=>$sign,
"channel_id"=>$info['channel_id']
];
$dataurl .= $this->apihost."&".http_build_query($arr);
$html = file_get_contents($dataurl);
$rsp = json_decode($html,true);
if($rsp['code'] != 1){
echo $rsp['error'].PHP_EOL;die;
}
//更新信息
$begintimestr = date("Y-m-d",$info['begintime']);
$endtimestr = date("Y-m-d",$info['endtime']);
var_dump($rsp);
if($rsp['count'] > 0){
//插入数据
foreach ($rsp['data'] as $k => $v) {
foreach ($v["game_list"] as $ke => &$va) {
$va['begintime'] = $begintimestr;
$va['endtime'] = $endtimestr;
$va['fax_ratio'] = 0;
}
$v["statement_info"] = json_encode($v["game_list"],JSON_UNESCAPED_UNICODE);
unset($v["game_list"]);
$v['create_time'] = time();
$v['admin_name'] = $_SESSION['onethink_admin']['user_auth']['username'];
$v['admin_id'] = $_SESSION['onethink_admin']['user_auth']['uid'];
$v['verify_status'] = 0;
$res = $Aggregate->where("id='{$id}'")->save($v);
if(empty($res)){
return false;
}
}
}else{
$savedata = [
"create_time"=>time(),
"admin_name"=>$_SESSION['onethink_admin']['user_auth']['username'],
"admin_id"=>$_SESSION['onethink_admin']['user_auth']['uid'],
"verify_status"=>0,
"statement_info"=>json_encode([],JSON_UNESCAPED_UNICODE),
"ratio_money"=>0,
"pay_money"=>0
];
$res = $Aggregate->where("id='{$id}'")->save($savedata);
if(empty($res)){
return false;
}
}
return true;
}

@ -398,6 +398,27 @@ class AggregateFinanceStatementController extends ThinkController
"info"=>"已到账成功"
));
}
//重算金额
public function updateStatement()
{
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = explode(",",$_REQUEST['ids']);
foreach ($ids as $k => $v) {
$res = A("AggregateFinanceSet")->updateAggregateFinanceData($v);
var_dump($res);
if(!$res){
$this->ajaxReturn(array(
'status' => 0,
"info"=>"重算结算金额失败"
));
}
}
$this->ajaxReturn(array(
'status' => 1,
"info"=>"算结算金额成功"
));
}
//导出
public function export()
{

@ -117,8 +117,7 @@
<a class="butn" id="refuseApply" style="background-color: red;">审批拒绝</a>
<a class="butn" id="Invoiced">已开票</a>
<a class="butn" id="Received">已到账</a>
<a class="butn" id="upstream" style="width: 150px;background-color:green;">重算对账金额</a>
<a class="butn" id="updateStatement" style="width: 150px;background-color:green;">重算结算金额</a>
<a class="butn" id="export">批量导出</a>
</div>
@ -428,6 +427,39 @@
});
}
})
//重算金额
$("#updateStatement").on("click",function(){
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
return $(elem).val();
}).get().join(",");
if(text == ''){
layer.msg("<font style='color:white'>" + '无需要进行重新结算的结算单' + "</font>");
return;
}
layer.confirm("重算结算金额会对结算单回退到未申请发票状态,请慎重处理,点击取消停止操作",{title:false}, function(index){
_doReceived();
layer.close(index);
});
function _doReceived(){
//执行
$.ajax({
type: "POST",
url: "{:U('updateStatement')}",
dataType: 'json',
async: false,
data: {ids:text},
success:function(data){
if(data.status==1){
layer.msg("<font style='color:white'>" + data.info + "</font>");
setTimeout(function(){
window.location.reload();
},1500);
}
}
});
}
})
$("#shenhe").click(function () {
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {

Loading…
Cancel
Save