diff --git a/Application/Admin/Controller/AggregateFinanceSetController.class.php b/Application/Admin/Controller/AggregateFinanceSetController.class.php
index 2b6bb592f..d6db14fbf 100644
--- a/Application/Admin/Controller/AggregateFinanceSetController.class.php
+++ b/Application/Admin/Controller/AggregateFinanceSetController.class.php
@@ -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;
+ }
diff --git a/Application/Admin/Controller/AggregateFinanceStatementController.class.php b/Application/Admin/Controller/AggregateFinanceStatementController.class.php
index 60583a02b..09be5a7f3 100644
--- a/Application/Admin/Controller/AggregateFinanceStatementController.class.php
+++ b/Application/Admin/Controller/AggregateFinanceStatementController.class.php
@@ -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()
{
diff --git a/Application/Admin/View/AggregateFinanceStatement/lists.html b/Application/Admin/View/AggregateFinanceStatement/lists.html
index e3f985e12..a2a11c5b0 100644
--- a/Application/Admin/View/AggregateFinanceStatement/lists.html
+++ b/Application/Admin/View/AggregateFinanceStatement/lists.html
@@ -117,8 +117,7 @@
审批拒绝
已开票
已到账
-
- 重算对账金额
+ 重算结算金额
批量导出
@@ -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("" + '无需要进行重新结算的结算单' + "");
+ 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("" + data.info + "");
+ setTimeout(function(){
+ window.location.reload();
+ },1500);
+ }
+ }
+ });
+ }
+ })
+
$("#shenhe").click(function () {
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {