Merge branch 'feature/finance_statement723' of wmtx/platform into release

master
陈志 4 years ago committed by Gogs
commit dd5eaf72f7

@ -19,13 +19,18 @@ class CompanyStatementController extends ThinkController
"9"=>"上游"
];
public $VerifyStatus=[
"-2"=>"汇总撤销",
"-1"=>"审批拒绝",
"-3"=>"汇总撤销",
"-2"=>"审核拒绝",
"-1"=>"管理员审批拒绝",
"0"=>"未审批",
"1"=>"审核通过",
"2"=>"对外发起",
"3"=>"合作确认",
"4"=>"已汇总"
"1"=>"管理员审核通过",
"2"=>"审核通过",
"3"=>"已汇总"
];
public $ConfirmStatus=[
"0"=>"未发起",
"1"=>"已发起",
"2"=>"已确认"
];
public $admininfo;
public $DBModel;
@ -112,12 +117,15 @@ class CompanyStatementController extends ThinkController
if(isset($_REQUEST['verify_status'])){
$map['verify_status'] = $_REQUEST['verify_status'];
}
if(isset($_REQUEST['confirm_status'])){
$map['confirm_status'] = $_REQUEST['confirm_status'];
}
// $this->checkListOrCountAuthRestMap($map);//导出权限
//条件end
$data = M("company_statement","tab_")
->field("id,withdraw_type,company_name,company_belong,statement_begin_time,statement_end_time,statement_money,platform_amount,verify_status,verify_log,op_time,remark")
->field("id,withdraw_type,company_name,company_belong,statement_begin_time,statement_end_time,statement_money,platform_amount,verify_status,verify_log,confirm_status,confirm_log,op_time,remark")
->where($map)
->order("FIELD(verify_status,0,1,-1,2,3,-2,4,5),id desc")->page($page,$row)->select();
->order("FIELD(verify_status,0,1,-1,2,3,-2,-3),id desc")->page($page,$row)->select();
foreach($data as $k => &$v) {
$v['statement_begin_time'] = date('Y-m-d',$v['statement_begin_time']);
@ -132,14 +140,26 @@ class CompanyStatementController extends ThinkController
$v['withdraw_type_2'] = ($v['withdraw_type'] == 2 ? "补点" :"正常结算");
$v['verify_log'] = json_decode($v['verify_log'], true);
$v['confirm_log'] = json_decode($v['confirm_log'], true);
if (isset($params['export'])) {
$symbol = "\n";
} else {
$symbol = "<br>";
}
$v["create"]= "{$v['verify_log']['create_user']} {$symbol} {$v['verify_log']['create_time']}";
if(isset($v['verify_log']['verify_user'])){
if(isset($v['verify_log']['admin_user'])){
if($v['verify_status'] == -1){
$ts = "管理员审核拒绝";
}else{
$ts = "管理员审核通过";
}
$v["admin"]= "{$ts}({$v['verify_log']['admin_user']}) {$symbol} {$v['verify_log']['admin_time']}";
}else{
$v["admin"] = '--';
}
if(isset($v['verify_log']['verify_user'])){
if($v['verify_status'] == -2){
$ts = "审核拒绝";
}else{
$ts = "审核通过";
@ -149,21 +169,21 @@ class CompanyStatementController extends ThinkController
$v["verify"] = '--';
}
if(isset($v['verify_log']['launch_user'])){
if(isset($v['confirm_log']['launch_user'])){
$ts = "已发起";
$v["launch"]= "{$ts}({$v['verify_log']['launch_user']}) {$symbol} {$v['verify_log']['launch_time']}";
$v["launch"]= "{$ts}({$v['confirm_log']['launch_user']}) {$symbol} {$v['confirm_log']['launch_time']}";
}else{
$v["launch"] = '--';
}
if(isset($v['verify_log']['confirm_user'])){
if(isset($v['confirm_log']['confirm_user'])){
$ts = "已确认";
$v["confirm"]= "{$ts}({$v['verify_log']['confirm_user']}) {$symbol} {$v['verify_log']['confirm_time']}";
$v["confirm"]= "{$ts}({$v['confirm_log']['confirm_user']}) {$symbol} {$v['confirm_log']['confirm_time']}";
}else{
$v["confirm"] = '--';
}
if(isset($v['verify_log']['pool_user'])){
if($v['verify_status'] == -2){
if($v['verify_status'] == -3){
$ts = "撤销汇总";
$v["pool"]= "{$ts}({$v['verify_log']['pool_user']}){$symbol} {$v['verify_log']['pool_time']}";
}else{
@ -190,6 +210,7 @@ class CompanyStatementController extends ThinkController
$this->assign('CompanyType',$this->CompanyType);
$this->assign('CompanyBelong',$this->CompanyBelong);
$this->assign('VerifyStatus',$this->VerifyStatus);
$this->assign('ConfirmStatus',$this->ConfirmStatus);
$this->display();
}
@ -296,15 +317,40 @@ class CompanyStatementController extends ThinkController
}
}
//审批通过
public function adminAgree(){
$this->setVerifyStatus(0,1,"admin");
}
public function adminRefuse(){
$this->setVerifyStatus(0,-1,"admin");
}
public function verifyAgree(){
$this->setVerifyStatus(0,1,"verify");
$this->setVerifyStatus(1,2,"verify");
}
public function verifyRefuse(){
$this->setVerifyStatus(0,-1,"verify");
$this->setVerifyStatus(1,-2,"verify");
}
public function launch(){
$this->setVerifyStatus(1,2,"launch");
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$dbres = $this->DBModel->field("id,confirm_status,confirm_log")->where("id in ({$ids})")->select();
foreach($dbres as $k=>&$v){
if($v['confirm_status'] != 0) continue;
$v['confirm_log'] = json_decode($v['confirm_log'],true);
$v['confirm_log']['launch_user']=$this->admininfo["username"];
$v['confirm_log']['launch_time']=date("Y-m-d H:i:s");
$v['confirm_log'] = json_encode($v['confirm_log']);
$v['confirm_status']=1;
// $v['op_time'] = time();
$this->DBModel->save($v);
addOperationLog(['op_type'=>1,'key'=>$v['id'],"op_name"=>"发起确认",'url'=>U('lists')]);
}
$this->ajaxReturn(array(
'status' => 1,
"info"=>"对外发起成功"
));
}
protected function setVerifyStatus($old_status,$change_status,$op_pre)
{
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
@ -457,7 +503,7 @@ class CompanyStatementController extends ThinkController
}
foreach ($dbres as $k=>$v) {
if($v['verify_status'] != 3) continue;
if($v['verify_status'] != 2) continue;
if($v['company_belong'] == 9){
//上游
if($v['is_payment'] == 1){
@ -498,7 +544,12 @@ class CompanyStatementController extends ThinkController
$v['verify_status'] = 5;
$v['verify_log'] = json_encode(["create_user"=>$this->admininfo["username"],"create_time"=>date("Y-m-d H:i:s"),"verify_user"=>"system","verify_time"=>date("Y-m-d H:i:s"),"payment_user"=>"system","payment_time"=>date("Y-m-d H:i:s")]);
}
//判断周月结
if(($v["statement_end_time"]-$v['statement_begin_time']) > 7*24*3600){
$v["withdraw_type"] = 1;
}else{
$v["withdraw_type"] = 0;
}
$pool_id = $Pool->add($v);
if($pool_id == false){
$this->ajaxReturn(array('status' => 0,"info"=>"汇总失败"));
@ -511,7 +562,7 @@ class CompanyStatementController extends ThinkController
M("company_lack_statement_info","tab_")->where("id in ({$v['del_lack_ids']})")->save(["is_pool"=>1]);
}
//修改结算单规则
$this->updatePoolVerifyStatus($v['statement_ids'],3,4,"pool",$v['statement_num']);
$this->updatePoolVerifyStatus($v['statement_ids'],2,3,"pool",$v['statement_num']);
}
$this->ajaxReturn(array(
'status' => 1,
@ -838,9 +889,6 @@ class CompanyStatementController extends ThinkController
case '3':
$optist = ["viewStatement","addRemark","viewRemark","editRemark"];
break;
case '4':
$optist = ["viewStatement","addRemark","viewRemark","editRemark"];
break;
default:
break;
}
@ -866,13 +914,15 @@ class CompanyStatementController extends ThinkController
public function menuAuth()
{
$mentBtn = [
"adminAgree"=>"<a class='butn' id='adminAgree'>管理员审核通过</a>",
"adminRefuse"=>"<a class='butn' id='adminRefuse' style='background-color: red;'>管理员审核拒绝</a>",
"verifyAgree"=>"<a class='butn' id='verifyAgree'>审批通过</a>",
"verifyRefuse"=>"<a class='butn' id='verifyRefuse' style='background-color: red;'>审核拒绝</a>",
"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>",
"updateNewStatement"=>"<a class='butn' id='updateNewStatement' style='background-color: green;'>新增结算</a>",
"launch"=>"<a class='butn' id='launch'>对外发起</a>",
];
$resarr = [];
foreach ($mentBtn as $k => $v) {

@ -16,7 +16,11 @@ class CompanyStatementPoolController extends ThinkController
"1"=>"是",
"2"=>"否"
];
public $WithdrawType = [
"0"=>"周结",
"1"=>"月结",
"2"=>"下游个人补点"
];
public $VerifyStatus=[
"-2"=>"拒绝打款",
"-1"=>"审批拒绝",
@ -94,6 +98,9 @@ class CompanyStatementPoolController extends ThinkController
if(isset($_REQUEST['is_payment'])){
$map['is_payment'] = $_REQUEST['is_payment'];
}
if(isset($_REQUEST['withdraw_type'])){
$map['withdraw_type'] = $_REQUEST['withdraw_type'];
}
// $this->checkListOrCountAuthRestMap($map);//导出权限
@ -111,11 +118,15 @@ class CompanyStatementPoolController extends ThinkController
$v['company_type_str'] = $this->CompanyType[$v['company_type']];
$v['is_payment_str'] = $this->IsPayment[$v['is_payment']];
$v['can_export'] = $v['statement_money'] == 0 ? "0" : '1';
if($v['company_type'] == 2){
$v['can_export'] = 1;
}
$v['op_time'] = date('Y-m-d H:i:s',$v['op_time']);
$v["valid"] = "{$v['statement_begin_time']} ~ {$v['statement_end_time']}";
$v['ext_file_type'] = empty($v['ext_file']) ? "无" : "有";
$v['withdraw_type'] = $this->WithdrawType[$v['withdraw_type']];;
$v['verify_log'] = json_decode($v['verify_log'], true);
if (isset($params['export'])) {
@ -177,6 +188,7 @@ class CompanyStatementPoolController extends ThinkController
$this->assign('CompanyType',$this->CompanyType);
$this->assign('IsPayment',$this->IsPayment);
$this->assign('VerifyStatus',$this->VerifyStatus);
$this->assign('WithdrawType',$this->WithdrawType);
$this->display();
}
@ -192,9 +204,11 @@ class CompanyStatementPoolController extends ThinkController
$is_export = true;
}
//获取基本信息
$infolist = M("company_statement_info","tab_")->where("pool_id = '{$id}'")->select();
$infolist = M("company_statement_info","tab_")->field("*,'1' as st")->where("pool_id = '{$id}'")->select();
//获取母单
$statement_num = M("company_statement_pool","tab_")->field('statement_num')->where("id={$id}")->find()['statement_num'];
$statement_num =
$pool_info = M("company_statement_pool","tab_")->field('statement_num,create_lack_ids')->where("id={$id}")->find();
$statement_num = $pool_info['statement_num'];
$this->assign("title",$statement_num);
if($infolist[0]['company_type'] == 3){
@ -204,12 +218,20 @@ class CompanyStatementPoolController extends ThinkController
//下游公司
$this->viewPcPool($infolist,$is_export);
}else{
//获取母单
if(!empty($pool_info['create_lack_ids'])){
$l_ids = $pool_info['create_lack_ids'];
$lack_info = M("company_lack_statement_info","tab_")->field("*,'0' as st")->where("id in ({$l_ids})")->select();
$infolist += $lack_info;
}
$this->viewPuPool($infolist,$is_export);
}
}
//个人汇总结算查看
public function viewPuPool(&$infolist,$is_export){
// dd($infolist);
$line = 1;
$count = [];
//获取对接人
@ -232,13 +254,20 @@ class CompanyStatementPoolController extends ThinkController
if($is_export){
//J3*(K3+L3)+M3-N3
$va['sum_money'] = "=J{$line}*(K{$line}+L{$line})+M{$line}-N{$line}";
$count['sum_money_exp'] .= "O{$line}+";
$count['platform_amount_exp'] .= "J{$line}+";
if($va['statement_type'] > 0){ //罚款服务器费用
$va['sum_money'] = "=J{$line}";
}else{
$va['sum_money'] = "=J{$line}*(K{$line}+L{$line})+M{$line}-N{$line}";
}
if($v['st'] == 1){
$count['sum_money_exp'] .= "O{$line}+";
$count['platform_amount_exp'] .= "J{$line}+";
}
}else{
$count['platform_amount'] += $va['pay_amount'];
$count['sum_money'] += $va['sum_money'];
if($v['st'] == 1){
$count['platform_amount'] += $va['pay_amount'];
$count['sum_money'] += $va['sum_money'];
}
}
}
$v['statement_count'] = count($v['statement_info']);
@ -284,7 +313,7 @@ class CompanyStatementPoolController extends ThinkController
if($is_export){
$v['statement_money_exp'] .= "H{$line}+";
$va['d_statement_money'] = "=D{$line}*(1-G{$line})*(E{$line}+F{$line})";
$count['platform_amount_exp'] .= "D{$line}+";
@ -626,6 +655,62 @@ class CompanyStatementPoolController extends ThinkController
'info' => "删除成功"
));
}
//不结算
public function cancelStatement()
{
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
//获取结算信息
$v = M("company_statement_info","tab_")->where("id = '{$id}'")->find();
if(empty($v)){
$this->error("请勿重复操作");
}
$pool = M("company_statement_pool","tab_")->where("id = {$v['pool_id']}")->find();
// dump($pool);
//保存未结算
$lackcompany =[
"company_id"=>$v['company_id'],
"company_type"=>$v['company_type'],
"company_name"=>$v['company_name'],
"company_info"=>$v['company_info'],
"statement_money"=>$v['statement_money'],
"pay_amount"=>$v['pay_amount'],
"platform_amount"=>$v['platform_amount'],
"fine"=>$v['fine'],
"reward"=>$v['reward'],
"statement_begin_time"=>$v['statement_begin_time'],
"statement_end_time"=>$v['statement_end_time'],
"is_payment"=>$pool['is_payment'],
"statement_pool_num"=>$pool['statement_num'],
"statement_info"=>$v['statement_info'],
];
$l_id = M("company_lack_statement_info","tab_")->add($lackcompany);
//汇总表
$pool_data = [
"id"=>$pool['id'],
'statement_money'=>$pool['statement_money']-$v['statement_money'],
'pay_amount'=>$pool['pay_amount']-$v['pay_amount'],
'fine'=>$pool['fine']-$v['fine'],
'reward'=>$pool['reward']-$v['reward'],
'lack_statement_money'=>$pool['lack_statement_money']+$v['statement_money'],
'lack_platform_amount'=>$pool['lack_platform_amount']-0+$v['platform_amount']
];
//
if(empty($pool_data['create_lack_ids'])){
$pool_data['create_lack_ids'] = $l_id;
}else{
$pool_data['create_lack_ids'] = $pool_data['create_lack_ids'].",".$l_id;
}
$info_ids = explode(",",$pool['info_ids']);
$pool_data['info_ids'] =implode(",",array_diff($info_ids,[$id]));
M("company_statement_pool","tab_")->save($pool_data);
M("company_statement_info","tab_")->where("id='{$id}'")->delete();
$this->ajaxReturn(array(
'status' => 1,
"info"=>"不结算成功"
));
}
//撤销汇总
public function cancelPool(){
@ -855,7 +940,7 @@ class CompanyStatementPoolController extends ThinkController
break;
}
//
if($info['platform_amount'] <= 0){
if($info['platform_amount'] <= 0 && $info['company_type'] != 2){
$optist = array_diff($optist, ["viewPool"]);
}
//个人重算,上游撤销

@ -6,6 +6,7 @@ use Think\Controller;
/**
* 聚合渠道结算接口对接
* @author cz
* TODO: 罚款的游戏没有流水不统计补点为0 无法重算
*/
class CompanyStatementSetController extends Controller {
public $cpapihost;
@ -91,7 +92,7 @@ class CompanyStatementSetController extends Controller {
echo "∟----推广公司月结&补点统计ok".PHP_EOL;
$this->promoteUserPool(1,$stime);
// $this->promoteUserPool(2,$stime);
$this->promoteUserPool(2,$stime);
echo "∟----推广个人月结&补点统计ok".PHP_EOL;
}
}else{
@ -143,7 +144,7 @@ class CompanyStatementSetController extends Controller {
$cp_id = implode(",",array_flip(array_flip(array_keys($cpList))));
$js_id = implode(",",array_unique($js_id));
//获取cp公司
$tmpp = M("Partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank,channel_rate,invoice_rate,company_type,ali_user,ali_account")->where(["id"=>['in',$cp_id]])->select();
$tmpp = M("Partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank,channel_rate,invoice_rate,taxation_rate,company_type,ali_user,ali_account,has_advance_charge,has_server_fee,server_fee")->where(["id"=>['in',$cp_id]])->select();
$cp =[];
foreach ($tmpp as $v) {
$cp[$v['id']]=$v;
@ -242,9 +243,9 @@ class CompanyStatementSetController extends Controller {
$add_data['company_belong']=9;//上游
$add_data['company_type']=$cp[$add_data['company_id']]['company_type'];
$add_data['is_payment']=$v['is_payment'];
//获取渠道及发票税率
//获取渠道及税费费
$promote_ratio = $cp[$add_data['company_id']]['channel_rate'] ?? 0;
$fax_ratio = $cp[$add_data['company_id']]['invoice_rate'] ?? 0;
$fax_ratio = $cp[$add_data['company_id']]['taxation_rate'] ?? 0;
//游戏统计
if(!isset($v['list'])){continue;}
foreach($v['list'] as $ke=>$va){
@ -298,14 +299,15 @@ class CompanyStatementSetController extends Controller {
if($type < 2){
//非补点奖罚
$rrmap = array(
"reward_time" => ['between', [$begintime,$endtime]],
"confirm_time" => ['between', [$begintime,$endtime]],
"company_type"=>1,
"company_id"=>$add_data['company_id']
"company_id"=>$add_data['company_id'],
"settlement_type"=>2,
);
$rfres = M("RewardRecord","tab_")
$rfres = M("RewardDetail","tab_")
->field("
IFNULL(SUM(CASE WHEN reward_type = 1 THEN money ELSE 0 END),0) as reward_count,
IFNULL(SUM(CASE WHEN reward_type = 2 THEN money ELSE 0 END),0) as fine_count
IFNULL(SUM(CASE WHEN type = 1 THEN amount ELSE 0 END),0) as reward_count,
IFNULL(SUM(CASE WHEN type = 2 THEN amount ELSE 0 END),0) as fine_count
")
->where($rrmap)->find();
if($rfres['reward_count'] > 0){
@ -333,7 +335,22 @@ class CompanyStatementSetController extends Controller {
);
$add_data['statement_money'] -= $fine_count;
$add_data['pay_amount'] -= $fine_count;;
}
}
//获取服务器费用
$tmp_company_info= $cp[$add_data['company_id']];
if($tmp_company_info['has_server_fee'] == 1 && $tmp_company_info['server_fee'] >0){
$server_count = $tmp_company_info['server_fee'];
$add_data['statement_info'][] = array(
"statement_begin_time"=>$statement_begin_time,
"statement_end_time"=>$statement_end_time,
'statement_type'=>1,
"game_name"=>"服务器费用",
'pay_amount'=>$server_count,
'sum_money'=>$server_count,
);
$add_data['statement_money'] -= $server_count;
$add_data['pay_amount'] -= $server_count;;
}
}
$add_data['statement_info'] = json_encode($add_data['statement_info'],JSON_UNESCAPED_UNICODE);
@ -361,7 +378,7 @@ class CompanyStatementSetController extends Controller {
{
$game_where = "partner_id in ({$cp_id})";
$game = M('game','tab_');
$gameDbRes = $game->field("id,relation_game_name as game_name,partner_id as cp_id,original_package_name")->where($game_where)->select();
$gameDbRes = $game->field("id,relation_game_name as game_name,partner_id as cp_id,original_package_name,select_package_name")->where($game_where)->select();
$gameList=[];
foreach ($gameDbRes as $k => $v) {
$gameList[$v['id']] =$v;
@ -392,7 +409,11 @@ class CompanyStatementSetController extends Controller {
if(empty($v['original_package_name'])){
$game_name = $v['game_name'];
}else{
$game_name = $v['original_package_name'];
if($v['select_package_name'] == 1){
$game_name = $v['original_package_name'];
}else{
$game_name = $v['game_name'];
}
}
$cp_id = $v['cp_id'];
unset($v['cp_id']);
@ -430,7 +451,7 @@ class CompanyStatementSetController extends Controller {
}else{
$where['settlement_type']=1;
$pcDbRes = M("CompanyRelation","tab_")->where($where)->select();
}
}
$pcList=[];
$js_id = [];//己方公司
foreach ($pcDbRes as $k => $v) {
@ -450,11 +471,25 @@ class CompanyStatementSetController extends Controller {
return ;
}
//获取pc公司
$tmpp = M("PromoteCompany","tab_")->field("id,uid,company_name partner,settlement_contact link_man,contact_phone link_phone,bank_name opening_bank,bank_address payee_name,bank_card bank_account,fax_ratio,company_belong,company_type,ali_user,ali_account")
$tmpp = M("PromoteCompany","tab_")->field("id,uid,company_name partner,settlement_contact link_man,contact_phone link_phone,bank_name opening_bank,bank_address payee_name,bank_card bank_account,fax_ratio,taxation_rate,company_belong,company_type,ali_user,ali_account,has_server_fee,server_fee,has_ratio,turnover_ratio")
->where(["id"=>['in',$pc_id],"company_type"=>1])
->select();
$pc =[];
$pc =[];
$Promote = M("Promote","tab_");
foreach ($tmpp as $v) {
//获取会长的支付宝账号
$p_map = [
"company_id"=>$v['id'],
"withdraw_done"=>1
];
$pres = $Promote->field("alipay_account,alipay_real_name")->where($p_map)->find();
if(!empty($pres) && !empty($pres['alipay_account']) && !empty($pres['alipay_real_name'])){
$v['ali_user'] = $pres['alipay_real_name'];
$v['ali_account'] = $pres['alipay_account'];
}
if($v['has_ratio']){
$v['turnover_ratio'] = json_decode($v['turnover_ratio'],true);
}
$pc[$v['id']]=$v;
}
@ -466,20 +501,24 @@ class CompanyStatementSetController extends Controller {
$our[$v['id']]=$v;
}
unset($tmpp);
unset($js_id);
$this->getPromoteCompanySpend($pcList,array_unique(array_keys($pcList)),$begintime,$endtime);
unset($js_id);
$this->getPromoteCompanySpend($pcList,array_unique(array_keys($pcList)),$begintime,$endtime);
// dd($pcList);
//数据整合
$verify_log=json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]);
$StatementDb = M("CompanyStatement","tab_");
$statement_begin_time = date("Y-m-d",$begintime);
$statement_end_time = date("Y-m-d",$endtime);
$RewardRecord = M("RewardRecord","tab_");
$RewardRecord = M("RewardDetail","tab_");
foreach($pcList as $k=>$v){
if(!isset($pc[$k])){continue;}//不存在的公司不结算
if(!isset($pc[$k])){continue;}//不存在的公司不结算
if($pc[$k]['has_ratio'] == 1){
$company_ratio = $this->getCompanyRatio($v['pay_amount'],$pc[$k]['turnover_ratio']);
}else{
$company_ratio = 0;
}
$add_data=[];
//1.获取甲乙方信息
if($v['first_company_type'] > 0){
@ -513,7 +552,7 @@ class CompanyStatementSetController extends Controller {
$add_data['statement_info'] =[];
//获取渠道及发票税率
$fax_ratio = $pc[$add_data['company_id']]['fax_ratio'] ?? 0;
$fax_ratio = $pc[$add_data['company_id']]['taxation_rate'] ?? 0; //税费费率
$company_belong = $pc[$add_data['company_id']]['company_belong'];
$add_data['company_belong']=$company_belong;
$add_data['company_type']=$pc[$add_data['company_id']]['company_type'];
@ -526,14 +565,15 @@ class CompanyStatementSetController extends Controller {
//获取比例
$game['relation_game_id']=$va['relation_game_id'];
if($type == 1){
$tratio = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong);
$tratio = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong);
$tratio += $company_ratio;
}elseif($type == 0){
$tratio = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],false,$company_belong);
}else{
//补点
$tratio1 = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong);;
$tratio2 = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],false,$company_belong);
$tratio = $tratio1-$tratio2;
$tratio = $tratio1-$tratio2+$company_ratio;
if($tratio <= 0){ continue;}
}
@ -544,7 +584,7 @@ class CompanyStatementSetController extends Controller {
}
$add_data['pay_amount'] += $va['pay_amount'];
$game['sum_money']=round($va['pay_amount']*$tratio*(100-$fax_ratio)/(100*100),2);//结算金额=平台总额*1-渠道费)*分成比例*(1-税费费率)
$game['sum_money']=round($va['pay_amount']*$tratio*(100-$fax_ratio)/(100*100),2);//结算金额=平台总额*(分成比例+补点比例)*(1-税费费率)
$add_data['statement_money'] += $game['sum_money'];
$game['fax_ratio']=$fax_ratio;
@ -558,14 +598,15 @@ class CompanyStatementSetController extends Controller {
if($type < 2){
//非补点计算奖罚
$rrmap = array(
"reward_time" => ['between', [$begintime,$endtime]],
"confirm_time" => ['between', [$begintime,$endtime]],
"company_type"=>2,
"company_id"=>$add_data['company_id']
"company_id"=>$add_data['company_id'],
"settlement_type"=>2,
);
$rfres = M("RewardRecord","tab_")
$rfres = M("RewardDetail","tab_")
->field("
IFNULL(SUM(CASE WHEN reward_type = 1 THEN money ELSE 0 END),0) as reward_count,
IFNULL(SUM(CASE WHEN reward_type = 2 THEN money ELSE 0 END),0) as fine_count
IFNULL(SUM(CASE WHEN type = 1 THEN amount ELSE 0 END),0) as reward_count,
IFNULL(SUM(CASE WHEN type = 2 THEN amount ELSE 0 END),0) as fine_count
")
->where($rrmap)->find();
if($rfres['reward_count'] > 0){
@ -593,7 +634,22 @@ class CompanyStatementSetController extends Controller {
);
$add_data['statement_money'] -= $fine_count;
$add_data['pay_amount'] -= $fine_count;;
}
}
//获取服务器费用
$tmp_company_info= $pc[$add_data['company_id']];
if($tmp_company_info['has_server_fee'] == 1 && $tmp_company_info['server_fee'] >0){
$server_count = $tmp_company_info['server_fee'];
$add_data['statement_info'][] = array(
"statement_begin_time"=>$statement_begin_time,
"statement_end_time"=>$statement_end_time,
'statement_type'=>1,
"game_name"=>"服务器费用",
'pay_amount'=>$server_count,
'sum_money'=>$server_count,
);
$add_data['statement_money'] -= $server_count;
$add_data['pay_amount'] -= $server_count;;
}
}
$add_data['statement_info'] = json_encode($add_data['statement_info'],JSON_UNESCAPED_UNICODE);
@ -647,7 +703,8 @@ class CompanyStatementSetController extends Controller {
"s.pay_time"=>['between', [$begintime,$endtime]],
];
for ($i=0; $i <count($idarr); $i++) {
$company_id = $idarr[$i];
$company_id = $idarr[$i];
$pres = $Promote->field("group_concat(id) ids,count(id) count")->where("company_id = '{$company_id}'")->group("company_id")->find();
if($pres['count'] ==0 ){continue;}
$spenMap['s.promote_id']=["in",$pres['ids']];
@ -657,6 +714,11 @@ class CompanyStatementSetController extends Controller {
->select();
if(empty($list)){continue;}
foreach($list as $k=>$v){
try {
$res[$company_id]["pay_amount"] += $v['pay_amount'];
} catch (\Throwable $th) {
$res[$company_id]["pay_amount"] = $v['pay_amount'];
}
if(isset($res[$company_id][$v['relation_game_id']])){
//
$res[$company_id][$v['relation_game_id']]['pay_amount'] += $v['pay_amount'];
@ -665,9 +727,12 @@ class CompanyStatementSetController extends Controller {
$res[$company_id][$v['relation_game_id']]= $v;
}
}
}
}
foreach($res as $k=>$v){
$pcList[$k]["pay_amount"] = $v['pay_amount'];
unset($v['pay_amount']);
$pcList[$k]['list'] = $v;
}
}
public function promoteUserPool($type,$stime,$recount = false){
@ -703,13 +768,18 @@ class CompanyStatementSetController extends Controller {
if($type == 0){//周结
$this->doPromoteUserPool($user,$users,$type,$stime,$recount);
}else{
}else if($type == 1){
$users['withdraw_type'] = 1;
$user['withdraw_type'] = 1;
//月结&补点
$this->doPromoteUserPool($user,$users,1,$stime,$recount);
}else{
$users['withdraw_type'] = 2;
$user['withdraw_type'] = 2;
$this->doPromoteUserPool($user,$users,2,$stime,$recount);
}
$this->savePromotateUserPool($users);
$this->savePromotateUserPool($user);
}
@ -748,13 +818,28 @@ class CompanyStatementSetController extends Controller {
}
//获取pc公司
$pc_id = implode(",",array_flip(array_flip(array_keys($pcList))));
$tmpp = M("PromoteCompany","tab_")->field("id,uid,company_name partner,settlement_contact link_man,contact_phone link_phone,bank_name opening_bank,bank_address payee_name,bank_card bank_account,fax_ratio,company_belong,company_type,ali_user,ali_account")
$tmpp = M("PromoteCompany","tab_")
->field("id,uid,company_name partner,settlement_contact link_man,contact_phone link_phone,bank_name opening_bank,bank_address payee_name,bank_card bank_account,fax_ratio,taxation_rate,company_belong,company_type,ali_user,ali_account,has_server_fee,server_fee,has_ratio,turnover_ratio")
->where(["id"=>['in',$pc_id],"company_type"=>2])
->select();
if(count($tmpp)<1){return;}
$pc =[];
$Promote = M("Promote","tab_");
foreach ($tmpp as $v) {
$p_map = [
"company_id"=>$v['id'],
"withdraw_done"=>1
];
$pres = $Promote->field("alipay_account,alipay_real_name")->where($p_map)->find();
if(!empty($pres) && !empty($pres['alipay_account']) && !empty($pres['alipay_real_name'])){
$v['ali_user'] = $pres['alipay_real_name'];
$v['ali_account'] = $pres['alipay_account'];
}
if($v['has_ratio']){
$v['turnover_ratio'] = json_decode($v['turnover_ratio'],true);
}
$pc[$v['id']]=$v;
$pc[$v['id']]['is_payment']=$pcList[$v['id']]['is_payment'];
}
@ -764,11 +849,18 @@ class CompanyStatementSetController extends Controller {
$StatementDb = M("CompanyStatement","tab_");
$statement_begin_time = date("Y-m-d",$begintime);
$statement_end_time = date("Y-m-d",$endtime);
$RewardRecord = M("RewardRecord","tab_");
// $RewardRecord = M("RewardRecord","tab_");
$LackStatement = M("company_lack_statement_info","tab_");
$StatementInfo = M("company_statement_info","tab_");
foreach($pc as $k=>&$v){
$fax_ratio = $v['taxation_rate'];
$RewardRecordRes = $this->getPromoteUserRewardRecord($v['id'],$begintime,$endtime);
if($v['has_ratio'] == 1){
$company_ratio = $this->getCompanyRatio($v['pay_amount'],$pc[$k]['turnover_ratio']);
}else{
$company_ratio = 0;
}
//获取其他信息
$v = $this->getCompanyOtherInfo($v,$k);
if($v['is_payment'] == 1){
@ -782,6 +874,21 @@ class CompanyStatementSetController extends Controller {
$v['reward'] = 0;
$v['platform_amount'] = 0;
if(!isset($v['list'])){continue;}
//服务器费用
if ($type < 2) {
if ($v['has_server_fee'] == 1 && $v['server_fee'] > 0) {
$v['statement_info'][] = [
"game_name"=>"服务器费用",
"sum_money"=>-$v['server_fee'],
"pay_amount"=>-$v['server_fee'],
'statement_type'=>1,
"statement_begin_time"=>$statement_begin_time,
"statement_end_time"=>$statement_end_time
];
$v['pay_amount'] -= $v['server_fee'];
$v['statement_money'] -= $v['server_fee'];
}
}
foreach($v['list'] as $ke=>$va){
$game =[];
$game['pay_amount'] =$va['pay_amount'];
@ -792,13 +899,14 @@ class CompanyStatementSetController extends Controller {
if($type == 1){
$tratio = getGamePromoteCompanyRadio($v['id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong);
$tratio += $company_ratio;
}elseif($type == 0){
$tratio = getGamePromoteCompanyRadio($v['id'],$va['relation_game_id'],$endtime,$va['pay_amount'],false,$company_belong);
}else{
//补点
$tratio1 = getGamePromoteCompanyRadio($v['id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong);;
$tratio2 = getGamePromoteCompanyRadio($v['id'],$va['relation_game_id'],$endtime,$va['pay_amount'],false,$company_belong);
$tratio = $tratio1-$tratio2;
$tratio = $tratio1-$tratio2+$company_ratio;
if($tratio <= 0){
continue;
}
@ -813,23 +921,18 @@ class CompanyStatementSetController extends Controller {
//判断是否是个人
if($type < 2){
//非补点
$rrmap = array(
"reward_time" => ['between', [$begintime,$endtime]],
"company_type"=>2,
"company_id"=>$k,
"relation_game_id"=>$va['relation_game_id']
);
$rrfres =$RewardRecord->field("IFNULL(SUM(CASE WHEN reward_type = 1 THEN money ELSE 0 END),0) as reward_count,IFNULL(SUM(CASE WHEN reward_type = 2 THEN money ELSE 0 END),0) as fine_count")->where($rrmap)->find();
$v['fine'] += $rrfres['fine_count'];
$v['reward'] += $rrfres['reward_count'];
if($RewardRecordRes){
$rrfres = $RewardRecordRes[$va['relation_game_id']];
}else{
$rrfres = [
'reward_count'=>0,
'fine_count'=>0,
];
}
$game['reward'] = $rrfres['reward_count'];
$game['fine'] = $rrfres['fine_count'];
$game['sum_money']=round($va['pay_amount']*$tratio/100,2)+$game['reward']-$game['fine'];
}else{
$game['sum_money']=round($va['pay_amount']*$tratio*(100-$fax_ratio)/(100*100),2);//结算金额=平台总额*1-渠道费)*分成比例*(1-税费费率)
}
$game['sum_money']=round($va['pay_amount']*$tratio/100,2)+$game['reward']-$game['fine']; //个人等于 结算金额*比例-罚款+奖励
$v['statement_money'] += $game['sum_money'];
$game['fax_ratio']=$fax_ratio;
@ -944,7 +1047,9 @@ class CompanyStatementSetController extends Controller {
* 保存信息汇总信息
*/
public function savePromotateUserPool($data){
if(empty($data['create_lack_ids']) && empty($data['del_lack_ids']) && empty($data['info_ids'])){ return;}
if(empty($data['create_lack_ids']) && empty($data['del_lack_ids']) && empty($data['info_ids'])){ //补点为空不重算
return ;
}
if($data['statement_money'] == 0){
$data['verify_status'] = 5;
$data['verify_log'] = json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s"),"verify_user"=>"system","verify_time"=>date("Y-m-d H:i:s"),"payment_user"=>"system","payment_time"=>date("Y-m-d H:i:s")]);
@ -988,6 +1093,63 @@ class CompanyStatementSetController extends Controller {
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'];
}
/**
* 获取公司比例加成
* @param [type] $paymount 支付金额
* @param [type] $turnover_ratio 梯度
*/
protected function getCompanyRatio($paymount,$turnover_ratio)
{
$ratio = 0;
foreach($turnover_ratio as $k=>$v){
if($v['instanceof'] == 1){
if($paymount >= $v['turnover']){
$ratio = $v['ratio'];
}
}else{
if($paymount > $v['turnover']){
$ratio = $v['ratio'];
}
}
}
return $ratio;
}
/**
* 获取公司比例加成
* @param [type] $paymount 支付金额
* @param [type] $turnover_ratio 梯度
*/
protected function getPromoteUserRewardRecord($cpmpamy_id,$begintime,$endtime)
{
//获取所有公司的奖罚
$rrmap = array(
"d.confirm_time" => ['between', [$begintime,$endtime]],
"d.company_type"=>2,
"d.company_id"=>$cpmpamy_id,
"d.settlement_type"=>2,
);
$rfres = M("RewardDetail","tab_")
->alias("d")
->field("
IFNULL(SUM(CASE WHEN type = 1 THEN amount ELSE 0 END),0) as reward_count,
IFNULL(SUM(CASE WHEN type = 2 THEN amount ELSE 0 END),0) as fine_count,
r.relation_game_id
")
->where($rrmap)
->join("tab_reward_record as r on d.record_id = r.id")
->group("record_id,company_id")
->select();
if(empty($rfres)){
return false;
}else{
$s = [];
foreach($rfres as $k=>$v){
$s[$v['relation_game_id']] = $v;
}
return $s;
}
}
/**
* 重算接口

@ -146,6 +146,15 @@
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="confirm_status" name="confirm_status" class="select_gallery" >
<option value="">请选择确认状态</option>
<volist name="ConfirmStatus" id="vo">
<option value="{$key}" <if condition="isset($_GET['confirm_status']) && $key eq I('confirm_status')">selected</if> >{$vo}</option>
</volist>
</select>
</div>
<div class="input-list">
<input type="text" readonly id="time_start2" name="time_start2" class="" value="{:I('time_start2')}" placeholder="操作开始时间" />
&nbsp;-&nbsp;
@ -186,10 +195,11 @@
<th>结算金额</th>
<th>结算流水</th>
<th>创建记录</th>
<th>管理员审核</th>
<th>审批状态</th>
<th>汇总状态</th>
<th>对外发起</th>
<th>合作确认</th>
<th>汇总状态</th>
<th>操作</th>
</tr>
</thead>
@ -204,7 +214,7 @@
<notemtpy name = "data">
<volist name="data" id="data">
<tr>
<td ><input class="ids" type="checkbox" data-status="{$data.verify_status}" value="{$data['id']}" name="ids[]"></td>
<td ><input class="ids" type="checkbox" data-status="{$data.verify_status}" data-confirm="{$data.confirm_status}" value="{$data['id']}" name="ids[]"></td>
<td>{$data.company_name}</td>
<td>{$data.company_belong}</td>
<td>{$data.valid}</td>
@ -215,6 +225,17 @@
<td>{$data.create}</td>
<td>
<if condition="$data.verify_status eq -1 ">
<div style="line-height: 2;color: red;">
{$data.admin}
</div>
<else />
<div style="line-height: 2;">
{$data.admin}
</div>
</if>
</td>
<td>
<if condition="$data.verify_status eq -2 ">
<div style="line-height: 2;color: red;">
{$data.verify}
</div>
@ -224,10 +245,8 @@
</div>
</if>
</td>
<td>{$data.launch}</td>
<td>{$data.confirm}</td>
<td>
<if condition="$data.verify_status eq -2 ">
<if condition="$data.verify_status eq -3 ">
<div style="line-height: 2;color: red;">
{$data.pool}
</div>
@ -237,6 +256,8 @@
</div>
</if>
</td>
<td>{$data.launch}</td>
<td>{$data.confirm}</td>
<td>
<foreach name="data.oplist" item="vo" >
{$vo}
@ -244,7 +265,7 @@
</td>
</tr>
</volist>
<tr><td style="line-height: 42px;">合计</td><td colspan="13" style="line-height: 42px;">结算总金额:&nbsp;{$count.statement_money}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;结算总流水:&nbsp;{$count['platform_amount']}&nbsp;(补点不重复统计在内)</td></tr>
<tr><td style="line-height: 42px;">合计</td><td colspan="14" style="line-height: 42px;">结算总金额:&nbsp;{$count.statement_money}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;结算总流水:&nbsp;{$count['platform_amount']}&nbsp;(补点不重复统计在内)</td></tr>
</notemtpy>
</tbody>
</table>
@ -386,7 +407,7 @@
//设置对账网址
var order_url = window.location.protocol+"//"+window.location.host+"/admin.php?s=/Public/cp_login.html";
$("#order_url").html("流程说明:结算自动生成对账单--->财务审核对账单--->发起对外对账--->合作方进行确认--->进入报销流程【合作方确认地址:"+order_url+"】");
$("#order_url").html("流程说明:结算自动生成对账单--->管理员审核--->财务审核对账单--->发起汇总 / 确认流程: 发起对外对账--->合作方进行确认【合作方确认地址:"+order_url+"】");
$("#updateNewStatement").on("click",function(){
layer.confirm("新增结算需要花费2分钟左右时间,并且只计算一个月内的新增结算,请勿在中途关闭页面,无需新增结算请取消",{title:false}, function(index){
@ -428,33 +449,38 @@
});
});
$("#verifyAgree,#verifyRefuse,#launch,#pool,#updateStatement").on("click",function(){
$("#adminAgree,#adminRefuse,#verifyAgree,#verifyRefuse,#pool,#updateStatement").on("click",function(){
var id = $(this).attr("id");
if(id == "verifyAgree"){
var opname = "审批通过";
var opurl = "{:U('verifyAgree')}";
if(id == "adminAgree"){
var opname = "管理员审批通过";
var opurl = "{:U('adminAgree')}";
var opst ="[未进行审批]";
var status = [0];
}else if(id=="adminRefuse"){
var opname = "管理员审批拒绝";
var opurl = "{:U('adminRefuse')}";
var opst ="[未进行审批]";
var status = [0];
}else if(id == "verifyAgree"){
var opname = "审批通过";
var opurl = "{:U('verifyAgree')}";
var opst ="[管理员审批通过]";
var status = [1];
}else if(id=="verifyRefuse"){
var opname = "审批拒绝";
var opurl = "{:U('verifyRefuse')}";
var opst ="[未进行审批]";
var status = [0];
}else if(id=="launch"){
var opname = "对外发起";
var opurl = "{:U('launch')}";
var opst ="[审批通过]";
var opst ="[管理员审批通过]";
var status = [1];
}else if(id=="pool"){
var opname = "发起汇总";
var opurl = "{:U('pool')}";
var opst ="[合作方确认]";
var status = [3];
var opst ="[审批通过]";
var status = [2];
}else if(id=="updateStatement"){
var opname = "重算金额";
var opurl = "{:U('updateStatement')}";
var opst ="[汇总撤销,审批拒绝,未进行审批,审批通过,对外发起]";
var status = [-2,-1,0,1,2];
var opst ="[汇总撤销,管理员审批拒绝,审批拒绝,未进行审批,管理员审批通过,审批通过]";
var status = [-3,-2,-1,0,1,2];
var confirm = true;
}
var confirm = confirm ? confirm :false;
@ -521,6 +547,49 @@
});
}
})
$("#launch").on("click",function(){
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
if($(elem).data("confirm") == 0){
return $(elem).val();
}
}).get();
if(text.length < 1){
layer.msg("<font style='color:white'>" + '无需要进行[对外发起]的申请,仅[未发起]状态可以进行[对外发起]操作</font>');
return;
}
text = text.join(",");
layer.confirm('【警告】[对外发起]将不可回退,如需继续请点击确认', {
btn: ['确认','取消'],
title:false
}, function(index){
layer.close(index);
_doAgreeApply();
});
function _doAgreeApply(){
//执行
layer.load(2);
$.ajax({
type: "POST",
url: "{:U('launch')}",
dataType: 'json',
async: true,
data: {ids:text},
success:function(data){
layer.closeAll('loading');
if(data.status==1){
layer.msg("<font style='color:white'>" + data.info + "</font>");
setTimeout(function(){
window.location.reload();
},1500);
}else{
layer.msg("<font style='color:white'>" + data.info + "</font>");
return false;
}
}
});
}
})
$("#export").click(function () {
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {

@ -102,6 +102,15 @@
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="withdraw_type" name="withdraw_type" class="select_gallery" >
<option value="">结算周期</option>
<volist name="WithdrawType" id="vo">
<option value="{$key}" <if condition="isset($_GET['withdraw_type']) && $key eq I('withdraw_type')">selected</if> >{$vo}</option>
</volist>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="verify_status" name="verify_status" class="select_gallery" >
<option value="">请选择审核状态</option>
@ -146,6 +155,7 @@
<th>结算汇总单订单号</th>
<th>结算时间</th>
<th>结算类型</th>
<th>结算周期</th>
<th>是否打款</th>
<th>结算金额</th>
<th>结算流水</th>
@ -172,8 +182,8 @@
<td>{$data.statement_num}</td>
<td>{$data.valid}</td>
<td>{$data.company_type_str}</td>
<td>{$data.withdraw_type}</td>
<td>{$data.is_payment_str}</td>
<td>{$data.statement_money}</td>
<td>{$data.platform_amount}</td>
<td>{$data.lack_statement_money}</td>

@ -116,11 +116,17 @@
<th>开户支行</th>
<th>帐户类型</th>
<th>备注</th>
<if condition="$is_export">
<th>是否结算</th>
<else />
<th>操作</th>
</if>
</tr>
</thead>
<tbody id="statementShow">
<foreach name="data" item="com">
<tr>
<tr <if condition="$com['st'] eq 0">style='color:red;'</if>>
<td rowspan="{$com.statement_count}">{$key-0+1}</td>
<td rowspan="{$com.statement_count}">{$com.company_name}</td>
@ -133,30 +139,53 @@
<td>{$com['statement_info'][0]['game_type_name']}</td>
<td>{$com['statement_info'][0]['statement_begin_time']} ~ {$com['statement_info'][0]['statement_end_time']}</td>
<td>{$com['statement_info'][0]['pay_amount']}</td>
<if condition="$com['statement_info'][0]['statement_type'] neq 0">
<td></td>
<td></td>
<else />
<td>{$com['statement_info'][0]['ratio']|default=0}%</td>
<td>{$com['statement_info'][0]['increment_ratio']|default=0}%</td>
</if>
<td>{$com['statement_info'][0]['ratio']|default=0}%</td>
<td>{$com['statement_info'][0]['increment_ratio']|default=0}%</td>
<td>{$com['statement_info'][0]['reward']}</td>
<td>{$com['statement_info'][0]['fine']}</td>
<td>{$com['statement_info'][0]['sum_money']}</td>
<td rowspan="{$com.statement_count}">{$com.company_info.payee_name}</td>
<td rowspan="{$com.statement_count}">{$com.company_info.bank_account}</td>
<td rowspan="{$com.statement_count}">&nbsp;{$com.company_info.bank_account}</td>
<td rowspan="{$com.statement_count}">{$com.company_info.opening_bank}</td>
<td rowspan="{$com.statement_count}"></td>
<td rowspan="{$com.statement_count}">{$com.remark}</td>
<if condition="$is_export">
<td rowspan="{$com.statement_count}"><if condition="$com['st'] eq 0"><else /></if></td>
<else />
<td rowspan="{$com.statement_count}">
<if condition="$com['st'] eq 1">
<a data-id="{$com['id']}" class='butn no_statement' style="cursor:pointer">不结算</a>
</if>
</td>
</if>
</tr>
<foreach name="com.statement_info" item="it" key="k">
<if condition="$k neq 0">
<tr>
<tr <if condition="$com['st'] eq 0">style='color:red;'</if>>
<td>{$it['game_name']}</td>
<td>{$it['game_type_name']}</td>
<td>{$it['statement_begin_time']} ~ {$it['statement_end_time']}</td>
<td>{$it['pay_amount']}</td>
<td>{$it['ratio']|default=0}%</td>
<td>{$it['increment_ratio']|default=0}%</td>
<if condition="$it['statement_type'] neq 0">
<td></td>
<td></td>
<else />
<td>{$it['ratio']|default=0}%</td>
<td>{$it['increment_ratio']|default=0}%</td>
</if>
<td>{$it['reward']}</td>
<td>{$it['fine']}</td>
<td>{$it['sum_money']}</td>
@ -166,19 +195,20 @@
</foreach>
</foreach>
<tr>
<td colspan=9 >合计:</td>
<td>{$count.platform_amount}</td>
<td colspan=9 >合计(仅统计结算公司):</td>
<td>{$count.platform_amount|default=0}</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>{$count.sum_money}</td>
<td>{$count.sum_money|default=0}</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
@ -194,5 +224,26 @@
});
});
</if>
$(".no_statement").on("click",function(){
var id = $(this).data('id');
$.ajax({
type: "POST",
url: "{:U('cancelStatement')}",
dataType: 'json',
async: false,
data: {id:id},
success:function(data){
if(data.status==1){
layer.msg("<font style='color:white'>" + data.info + "</font>");
setTimeout(function(){
window.location.reload();
},1500);
}else{
layer.msg("<font style='color:white'>" + data.info + "</font>");
return false;
}
}
});
})
</script>
</html>

@ -2241,4 +2241,47 @@ INSERT INTO `tab_payment_member` (`id`, `real_name`, `mobile`, `last_login_time`
ALTER TABLE `tab_game`
ADD COLUMN `select_package_name` tinyint(2) NOT NULL DEFAULT 0 COMMENT '结算包名 0:原包名 1:现包名' AFTER `original_package_name`;
--chenzhi
CREATE TABLE `tab_company_statement` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`withdraw_type` tinyint(2) DEFAULT '0' COMMENT '对账类型(0-周结 1月结 2补点)',
`company_id` int(11) DEFAULT '0' COMMENT '对账公司id',
`company_name` varchar(60) NOT NULL DEFAULT '' COMMENT '对账公司名称',
`company_belong` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会归属0-下游内团1-下游外团 2-下游分发联盟 3 下游无9:上游',
`company_type` tinyint(3) NOT NULL DEFAULT '1' COMMENT '公司性质1-公司 2-个人',
`is_payment` tinyint(3) NOT NULL DEFAULT '1' COMMENT '是否需要打款1-是 2-否(线下)',
`statement_begin_time` int(11) NOT NULL DEFAULT '0' COMMENT '对账开始时间',
`statement_end_time` int(11) NOT NULL DEFAULT '0' COMMENT '对账截止时间',
`statement_money` decimal(10,2) DEFAULT '0.00' COMMENT '对账金额',
`pay_amount` decimal(10,2) DEFAULT '0.00' COMMENT '总计',
`platform_amount` decimal(10,2) DEFAULT '0.00' COMMENT '平台流水金额',
`verify_status` tinyint(2) NOT NULL DEFAULT '0' COMMENT '审核状态 -2:汇总驳回 -1审批拒绝 0:系统生成 1:审核通过 2:对外发起 3:合作确认 4:汇总',
`verify_log` text NOT NULL COMMENT '审批相关信息json',
`pay_type` tinyint(2) DEFAULT '0' COMMENT '1甲方收款;2乙方收款',
`first_party_info` text NOT NULL COMMENT '甲方相关信息json',
`second_party_info` text NOT NULL COMMENT '乙方相关信息json',
`statement_info` text NOT NULL COMMENT '订单相关信息json',
`op_time` int(11) NOT NULL DEFAULT '0' COMMENT '操作时间',
`remark` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '备注',
PRIMARY KEY (`id`),
KEY `withdraw_type` (`withdraw_type`) USING BTREE,
KEY `company_id` (`company_id`) USING BTREE,
KEY `statement_begin_time` (`statement_begin_time`) USING BTREE,
KEY `statement_end_time` (`statement_end_time`) USING BTREE,
KEY `verify_status` (`verify_status`) USING BTREE,
KEY `op_time` (`op_time`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='聚合上游联运上下游对账单';
ALTER TABLE `tab_company_statement`
ADD COLUMN `confirm_status` tinyint(2) NOT NULL DEFAULT 0 COMMENT '确认状态 0:未处理 1:发起 2审核' AFTER `verify_log`;
ALTER TABLE `tab_company_statement`
ADD COLUMN `confirm_log` text COMMENT '确认信息' AFTER `confirm_status`;
ALTER TABLE `tab_company_statement`
MODIFY COLUMN `verify_status` tinyint(2) NOT NULL DEFAULT 0 COMMENT '审核状态 -3:汇总驳回 -2:审核拒绝 -1管理员审批拒绝 0:系统生成 1:管理员审核通过 2:审核通过 3:汇总' AFTER `platform_amount`;
Loading…
Cancel
Save