新增打款

master
chenzhi 4 years ago
parent a2454e0446
commit 53004adf5d

@ -111,7 +111,6 @@ class CompanyGameRatioController extends AdminController
$this->assign("companyList",D("PromoteCompany")->getList());
$this->assign("gameList",D("Game")->getRelationGameLits());
$this->display();
dd( $dbres);
}
public function lists()

@ -700,7 +700,74 @@ class CompanyStatementController extends ThinkController
$savedata['statement_end_time'] = $v['statement_end_time'];
}
}
//设定并保存数据
//新增结算
//获取要结算的公司及日期
public function getNewStatement()
{
$senddata = [];
//1.获取要计算的公司
$statement = M("company_statement","tab_")->field("count(id) count,company_id")->group("company_id")->select();
$has_company_id =implode(",",array_column($statement, 'company_id'));
if(empty($has_company_id)){
$where = "1=1";
}else{
$where = "(first_company_type > 0 AND first_company_id NOT IN ({$has_company_id}) ) OR ( second_company_type > 0 AND second_company_id NOT IN ({$has_company_id}) )";
}
$relation = M("company_relation","tab_")->field("first_company_id,first_company_type,second_company_id,second_company_type")->where($where)->select();
$company_id = [];
foreach($relation as $k=>$v){
if($v['first_company_type'] == 0){
$company_id[]=$v['second_company_id'];
}else{
$company_id[]=$v['first_company_id'];
}
}
if(count($company_id) < 1){
$this->ajaxReturn(["error"=>'无新增关系,无需重算']);
}
$senddata['company_id'] = implode(",",$company_id);
//获取要结算的日期
$start = strtotime('-1 month');
$end = time();
$temp_datelist = get_date_list($start,$end,1);
$datelist = [];
foreach($temp_datelist as $k=>$v){
$w = (int)date("w",strtotime($v));
$d = (int)date("d",strtotime($v));
if($w == 1 || $d == 1){
$datelist[] = $v;
}
}
$senddata['datelist'] = $datelist;
$senddata['count'] = count($datelist);
$this->ajaxReturn(["success"=>'ok',"data"=>$senddata]);
}
public function updateNewStatement()
{
$company_id = $_REQUEST['company_id'];
$date = $_REQUEST['date'];
$CompanyStatementSet = A("CompanyStatementSet");
// dd($CompanyStatementSet);
$stime = strtotime($date);
$w = (int)date("w",strtotime($date));
$d = (int)date("d",strtotime($date));
if($w == 1){
$CompanyStatementSet->cpStatement(0,$stime,$company_id,false);
$CompanyStatementSet->promoteCompanyStatement(0,$stime,$company_id,false);
}
if($d == 1){
$CompanyStatementSet->cpStatement(1,$stime,$company_id,false);
$CompanyStatementSet->cpStatement(2,$stime,$company_id,false);
$CompanyStatementSet->promoteCompanyStatement(1,$stime,$company_id,false);
$CompanyStatementSet->promoteCompanyStatement(2,$stime,$company_id,false);
}
$this->ajaxReturn(array("success"=>"ok","data"=>[]));
}
public function OpAuth($info)
@ -762,7 +829,8 @@ class CompanyStatementController extends ThinkController
"launch"=>"<a class='butn' id='launch'>对外发起</a>",
"pool"=>"<a class='butn' id='pool'>发起汇总</a>",
"updateStatement"=>"<a class='butn' id='updateStatement' style='background-color: green;'>重算金额</a>",
"export"=>"<a class='butn' id='export'>批量导出</a>"
"export"=>"<a class='butn' id='export'>批量导出</a>",
"updateNewStatement"=>"<a class='butn' id='updateNewStatement'>新增结算</a>",
];
$resarr = [];
foreach ($mentBtn as $k => $v) {

@ -97,7 +97,7 @@ class CompanyStatementSetController extends Controller {
* 上游结算
* @param [string] $type 0:周结 1:月结 2周结补点
*/
public function cpStatement($type,$stime,$company_id=false)
public function cpStatement($type,$stime,$company_id=false,$recount=true)
{
$t = $this->setBeginAndEndTime($type,$stime);;
$begintime = $t[0];
@ -109,7 +109,7 @@ class CompanyStatementSetController extends Controller {
];
}else{
$where = [
"_string"=>"(first_company_type = '1' AND first_company_id = '{$company_id}') OR (second_company_type = '1' AND second_company_id = '{$company_id}')"
"_string"=>"(first_company_type = '1' AND first_company_id in ({$company_id}) ) OR (second_company_type = '1' AND second_company_id in ({$company_id}) )"
];
}
//获取哪些要结算
@ -339,12 +339,11 @@ class CompanyStatementSetController extends Controller {
return;
}
//添加
if($company_id === false){
if($recount && $company_id !== false){
//非重算
$StatementDb->add($add_data);
}else{
return $add_data;
}
$StatementDb->add($add_data);
}
}
@ -402,9 +401,8 @@ class CompanyStatementSetController extends Controller {
/**
* 下游结算
*/
public function promoteCompanyStatement($type,$stime,$company_id=false)
public function promoteCompanyStatement($type,$stime,$company_id=false,$recount=true)
{
$t = $this->setBeginAndEndTime($type,$stime);
$begintime = $t[0];
$endtime = $t[1];
@ -416,7 +414,7 @@ class CompanyStatementSetController extends Controller {
];
}else{
$where = [
"_string"=>"(first_company_type = '2' AND first_company_id = '{$company_id}') OR (second_company_type = '2' AND second_company_id = '{$company_id}')"
"_string"=>"(first_company_type = '2' AND first_company_id in ({$company_id}) ) OR (second_company_type = '2' AND second_company_id in ({$company_id}) )"
];
}
//获取哪些要结算
@ -549,7 +547,6 @@ class CompanyStatementSetController extends Controller {
$game['statement_type']=0;
$add_data['statement_info'][] = $game;
}
$add_data['platform_amount'] = $add_data['pay_amount'];
if($type < 2){
//非补点计算奖罚
@ -601,16 +598,23 @@ class CompanyStatementSetController extends Controller {
return;
}
//添加
if($company_id === false){
if($recount && $company_id !== false){
//非重算
$StatementDb->add($add_data);
}else{
return $add_data;
}
$StatementDb->add($add_data);
// if($company_id === false){
// //非重算
// $StatementDb->add($add_data);
// }else{
// return $add_data;
// }
}
}
//设定开始结束时间
protected function setBeginAndEndTime($type,$stime){
public function setBeginAndEndTime($type,$stime){
if($type == 0){
$begintime = mktime(0,0,0,date('m',$stime),date('d',$stime)-7,date('Y',$stime));
$endtime = mktime(0,0,0,date('m',$stime),date('d',$stime),date('Y',$stime))-1;
@ -632,7 +636,7 @@ class CompanyStatementSetController extends Controller {
return [$begintime,$endtime];
}
//获取推广公司推广金额
protected function getPromoteCompanySpend(&$pcList,$idarr,$begintime,$endtime){
public function getPromoteCompanySpend(&$pcList,$idarr,$begintime,$endtime){
$res = [];
//获取推广员
if(count($idarr) == 0){return $res;}
@ -922,7 +926,7 @@ class CompanyStatementSetController extends Controller {
/**
* 保存信息汇总信息
*/
protected function savePromotateUserPool($data){
public function savePromotateUserPool($data){
if(empty($data['create_lack_ids']) && empty($data['del_lack_ids']) && empty($data['info_ids'])){ return;}
if($data['statement_money'] == 0 && $type ==2){ return;}
if($data['statement_money'] == 0){
@ -947,7 +951,7 @@ class CompanyStatementSetController extends Controller {
/**
* 获取公司额为信息
*/
protected function getCompanyOtherInfo($company_info,$company_id)
public function getCompanyOtherInfo($company_info,$company_id)
{
$pl = M("promote_company","tab_")
->alias('pc')
@ -965,7 +969,7 @@ class CompanyStatementSetController extends Controller {
/**
* 获取游戏分类名称
*/
protected function getGameTypeName($relation_game_id){
public function getGameTypeName($relation_game_id){
return M("Game","tab_")->field("game_type_name")->where("relation_game_id = '{$relation_game_id}'")->find()['game_type_name'];
}

@ -56,11 +56,33 @@
font-weight: 400;
font-size: 14px;
}
.main-place .question_content:before{
right: 20px;
left: auto;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">联运平台结算单管理</h3>
<p class="description_text" id="order_url"></p>
<div class="question" style="float: right;margin-right: 20px;">
<i class="question_mark">?</i>
<ul class="question_content" style="right: -20px;left: auto;">
<li class="question_title">数据相关说明</li>
<li class="question_list">
<span class="">重算金额:</span>
<span class="">仅会重算当前公司,当前时间的结算金额</span>
</li>
<li class="question_list">
<span class="">撤销汇总:</span>
<span class="">需要进行重算才可以再次汇总</span>
</li>
<li class="question_list">
<span class="">新增结算:</span>
<span class="">对新增绑定的公司进行结算,仅统计当月数据(不含下游个人)</span>
</li>
</ul>
</div>
</div>
@ -235,6 +257,15 @@
</if>
{$_page|default=''}
</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%;">
<div class="layui-layer-content" style="padding: 15px 0 5px;font-size: 20px;font-weight: 600;color: white;">执行进度</div>
<div id="tip_msg" class="layui-layer-content" style="color: white;">开始时间与结束时间都不允许为空</div>
<div class="layui-layer-content" style="padding: 5px 10px 15px;font-size: 10px;color: #BBB;">TIP:未执行完成之前请勿刷新或关闭此页面</div>
<span class="layui-layer-setwin"></span>
</div>
</div>
</block>
<block name="script">
@ -256,6 +287,66 @@
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
var DATA={};
var MSG={
showmsg:function(str){
$("#creat_msg").show();
$("#tip_msg").html(str);
},
hidemsg:function(){
$("#creat_msg").hide();
$("#tip_msg").html('');
}
}
var COMPARE={
publiucAjax:function(url,senddata,callback){
$.ajax({
type: 'post',
url: url,
data:senddata,
success: function(data) {
if(data.success){
callback(data.data);
}else{
MSG.hidemsg();
layer.alert(data.error);
return false;
}
},
error:function(){
MSG.hidemsg();
layer.alert("网络错误或超时");
return false;
}
});
},
//获取基础参数
getNewStatement:function(callback){
MSG.showmsg("初始化获取校验中....");
COMPARE.publiucAjax("{:U('getNewStatement')}",{},function(data){
DATA = data;
DATA.now = 1;
MSG.showmsg("校验通过,开始统计 [0/"+DATA.count+"] ......");
callback();
});
},
//开始统计
updateNewStatement:function(callback){
var senddata = {date:DATA.datelist[(DATA.now-1)],company_id:DATA.company_id};
console.log(senddata);
COMPARE.publiucAjax("{:U('updateNewStatement')}",senddata,function(){
MSG.showmsg("开始统计 ["+DATA.now+"/"+DATA.count+"] ......");
DATA.now ++;
if( DATA.now > DATA.count){
callback();
}else{
COMPARE.updateNewStatement(callback)
}
});
}
}
</script>
<script type="text/javascript">
//导航高亮
@ -300,6 +391,20 @@
var order_url = window.location.protocol+"//"+window.location.host+"/admin.php?s=/Public/cp_login.html";
$("#order_url").html("流程说明:结算自动生成对账单--->财务审核对账单--->发起对外对账--->合作方进行确认--->进入报销流程【合作方确认地址:"+order_url+"】");
$("#updateNewStatement").on("click",function(){
layer.confirm("新增结算需要花费2分钟左右时间,并且只计算一个月内的新增结算,请勿在中途关闭页面,无需新增结算请取消",{title:false}, function(index){
COMPARE.getNewStatement(function(){
COMPARE.updateNewStatement(function(){
MSG.showmsg("统计完成,等待跳转中....");
setTimeout(function(){
window.location.reload();
},2000)
});
});
layer.close(index);
});
})
$(".viewStatement").click(function () {
var id = $(this).data("id");
var url = "{:U('viewStatement')}"+"&id="+id

Loading…
Cancel
Save