diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 1d51bcf8d..3482da870 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -3142,4 +3142,40 @@ function getOrderHtml($field, $orderField, $orderType) } else { return ''; } +} + +function array_repeat($array,$keyid="id",$desc=false) +{ + $array = array_values($array); + //倒叙排列数 + if($desc) + { + $array = array_rsort($array,true); + } + + //提取需要判断的项目变成一维数组 + $a = array_column($array,$keyid); + + //去除一维数组重复值 + $a = array_unique($a); + //提取二维数组项目值 + foreach($array[0] AS $key=>$value) + { + $akey[] = $key; + } + //重新拼接二维数组 + foreach($akey AS $key=>$value) + { + $b = array_column($array,$value); + foreach($a AS $key2=>$value2) + { + $c[$key2][$value] = $b[$key2]; + } + } + + if($desc) + { + $c = array_rsort($c,true); + } + return $c; } \ No newline at end of file diff --git a/Application/Admin/Conf/config.php b/Application/Admin/Conf/config.php index 2b3384f87..1901229ee 100644 --- a/Application/Admin/Conf/config.php +++ b/Application/Admin/Conf/config.php @@ -128,6 +128,12 @@ return array( "tab_market_altogether", "tab_cmd_tasks", "tab_operation_log", - "sys_action_log" + "sys_action_log", + "tab_partner", + "tab_promote_company", + "tab_game", + "tab_reward_detail", + "tab_reward_record", + "tab_promote" ] ); \ No newline at end of file diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index cb3ad059a..498f391d4 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -227,6 +227,8 @@ class CompanyStatementController extends ThinkController if ($page) { $this->assign('_page', $page); } + + $this->assign("IS_SUBSITE",IS_SUBSITE); $this->assign('data',$data); $this->assign('count',$count); @@ -417,6 +419,503 @@ class CompanyStatementController extends ThinkController )); } + public function checkWmStatement() { + + $ids = $_POST['id']; + + if (!$ids) { + $this->ajaxReturn(["status"=>1]); + } + + $count = SM("company_statement","tab_") + ->where("id in({$ids})") + ->group("company_type,withdraw_type") + ->select(); + + if (count($count)>1) { + $this->ajaxReturn(["status"=>0,"msg"=>""]); + } else { + $this->ajaxReturn(["status"=>1]); + } + + } + + public function poolWmStatement() { + + $ids = $_GET['id']; + + $data = SM("company_statement","tab_") + ->where("id in({$ids})") + ->select(); + + $list = []; + $amount_data = []; + + $company_data = SM("promote_company","tab_")->where(["status"=>1,"company_type"=>$data[0]['company_type']])->select(); + + //游戏数据整合 + foreach ($data as $key => $value) { + + $promote_data = SM("promote","tab_")->field("id")->where(['company_id'=>$value['company_id']])->select(); + $promote_ids = array_column($promote_data,"id"); + + $statement_info = json_decode($value['statement_info'],true); +// dump($statement_info); + if ($value['company_type'] == 1) { + + $list = array_merge($list,$statement_info); + foreach ($statement_info as $k => $v) { + + $statement_begin_time = strtotime(str_replace(".", "-", $v['statement_begin_time'])); + $statement_end_time = strtotime(str_replace(".", "-", $v['statement_end_time'])) + 86399; + + if (!$amount_data['statement_begin_time'] || $amount_data['statement_begin_time'] > $v['statement_begin_time']) { + $amount_data['statement_begin_time'] = $v['statement_begin_time']; + } + + if (!$amount_data['statement_end_time'] || $amount_data['statement_end_time'] < $v['statement_end_time']) { + $amount_data['statement_end_time'] = $v['statement_end_time']; + } + + $user_data = SM("user", "tab_") + ->field("id") + ->where([ + 'promote_id' => ['in', $promote_ids], + 'fgame_name' => ['like', "%{$v['game_name']}%"], + "register_time" => ['between', [$statement_begin_time, $statement_end_time]] + ])->select(); + if ($v['game_name'] != '罚款' && $v['game_name'] != '奖励') { + $amount_data['pay_amount'] += $v["pay_amount"]; + } + if ($v['game_name'] == '罚款') { + $amount_data['sum_money'] -= $v["sum_money"]; + } else { + $amount_data['sum_money'] += $v["sum_money"]; + } + $amount_data['user_newcount'] += count($user_data); + + } + } elseif($value['company_type'] == 2) { + + foreach ($statement_info as $k => $v) { + + $game_list = $v["game_list"]; + + $list = array_merge($list,$game_list); + + foreach ($game_list as $gk=>$gv) { + $statement_begin_time = strtotime(str_replace(".", "-", $gv['statement_begin_time'])); + $statement_end_time = strtotime(str_replace(".", "-", $gv['statement_end_time'])) + 86399; + + if (!$amount_data['statement_begin_time'] || $amount_data['statement_begin_time'] > $gv['statement_begin_time']) { + $amount_data['statement_begin_time'] = $gv['statement_begin_time']; + } + + if (!$amount_data['statement_end_time'] || $amount_data['statement_end_time'] < $gv['statement_end_time']) { + $amount_data['statement_end_time'] = $gv['statement_end_time']; + } + + $user_data = SM("user", "tab_") + ->field("id") + ->where([ + 'promote_id' => ['in', $promote_ids], + 'fgame_name' => ['like', "%{$gv['game_name']}%"], + "register_time" => ['between', [$statement_begin_time, $statement_end_time]] + ])->select(); + if ($gv['game_name'] != '罚款' && $gv['game_name'] != '奖励') { + $amount_data['pay_amount'] += $gv["pay_amount"]; + } + + if ($gv['game_name'] == '罚款') { + $amount_data['sum_money'] -= $gv["sum_money"]; + } else { + $amount_data['sum_money'] += $gv["sum_money"]; + } + $amount_data['user_newcount'] += count($user_data); + } + + } + } + } + + $list = array_repeat($list,"game_name"); + + + $this->assign("company_data",$company_data); + $this->assign("row",count($list)); + $this->assign("data",$list); + $this->assign("amount_data",$amount_data); + $this->assign("js_amount_data",json_encode($amount_data)); + $this->assign("js_data",json_encode($list)); + + $this->display(); + + } + + //子系统列表 + public function showCpStatementList() { + + $params = I('get.'); + $page = $params['p'] ? intval($params['p']) : 1; + $row = $params['row'] ? intval($params['row']) : 10; + + $map['company_belong'] = 9; + + if ($_REQUEST["year"]) { + $start = strtotime($_REQUEST["year"]."-01-01"); + $end = strtotime(date("Y-m-t",strtotime($_REQUEST["year"]."-12"))) + 86399; + $map["statement_begin_time"] = ["between",[$start,$end]]; + } + + $data = SM("company_statement","tab_") + ->field("id,company_id,company_name,sum(statement_money) statement_money,sum(platform_amount) platform_amount") + ->where($map) + ->group("company_id") + ->page($page, $row) + ->select(); + + $count = SM("company_statement","tab_") + ->field("id") + ->where($map) + ->group("company_id") + ->select(); + + $count = count($count); + + $page = set_pagination($count, $row,$params); + if($page) { + $this->assign('_page', $page); + } + + A("FinancialSummary")->getYearList(); + $this->assign("data",$data); + + $this->display(); + + } + + //上游公司 + public function showCpStatementView() { + + $company_id = explode(",",$_REQUEST["company_id"]); + $time = $_REQUEST["time"]; + + $assign_data = []; + $sum = []; + + foreach ($company_id as $ckey => $cvalue) { + + $use_data = [ + "01"=>["time"=>"01"], + "02"=>["time"=>"02"], + "03"=>["time"=>"03"], + "04"=>["time"=>"04"], + "05"=>["time"=>"05"], + "06"=>["time"=>"06"], + "07"=>["time"=>"07"], + "08"=>["time"=>"08"], + "09"=>["time"=>"09"], + "10"=>["time"=>"10"], + "11"=>["time"=>"11"], + "12"=>["time"=>"12"], + ]; + + $map["company_id"] = $cvalue; + $map['company_belong'] = 9; + + $data = SM("company_statement","tab_") + ->field("id,company_id,company_name,FROM_UNIXTIME(statement_begin_time,'%m') time,statement_money,platform_amount,statement_info") + ->where($map) + ->select(); + + $row = 0; + + foreach($data as $key => $value) { + + $data[$key]['statement_info'] = json_decode($value['statement_info'],true); + + $statement_info = $data[$key]['statement_info']; + + $data[$key]['row'] = count($data[$key]['statement_info']); + + $row += $data[$key]['row']; + + foreach ($statement_info as $k => $v) { + + $statement_info[$k]['sum_amount'] = $v["platform_money"] + $v["aggregate_money"] ; + + $real_statement_amount + = number_format($v['platform_money']*(1-$v['promote_ratio']/100)*($v['ratio']/100)*(1-$v["fax_ratio"]/100),2,'.','');; + + $statement_info[$k]['other_amount'] = number_format($v["sum_money"] - $real_statement_amount,2,'.',''); + + $sum[$ckey]["ratio"] += $v["ratio"]; + $sum[$ckey]["promote_ratio"] += $v["promote_ratio"]; + $sum[$ckey]["fax_ratio"] += $v["fax_ratio"]; + + $statement_info[$k]['ratio'] = $v["ratio"]."%"; + $statement_info[$k]['promote_ratio'] = $v["promote_ratio"]."%"; + $statement_info[$k]['fax_ratio'] = $v["fax_ratio"]."%"; + + $sum[$ckey]["platform_money"] += $v["platform_money"]; + $sum[$ckey]["aggregate_money"] += $v["aggregate_money"]; + $sum[$ckey]["sum_amount"] += $statement_info[$k]["sum_amount"]; + $sum[$ckey]["other_amount"] += $statement_info[$k]["other_amount"]; + + if ($v["statement_type"] == 2) { + $sum[$ckey]["sum_money"] -= $v["sum_money"]; + } else { + $sum[$ckey]["sum_money"] += $v["sum_money"]; + } + + } + + $data[$key]["statement_info"] = $statement_info; + $use_data[$value['time']] = $data[$key]; + } + + $sum[$ckey]["ratio"] = number_format($sum[$ckey]["ratio"]/$row,2,'.','')."%"; + $sum[$ckey]["promote_ratio"] = number_format($sum[$ckey]["promote_ratio"]/$row,2,'.','')."%"; + $sum[$ckey]["fax_ratio"] = number_format($sum[$ckey]["fax_ratio"]/$row,2,'.','')."%"; + + $assign_data[] = array_values($use_data); + + } + + $is_export= false; + if (isset($_REQUEST['is_export']) && $_REQUEST['is_export']==1){ + $is_export = true; + } + + $this->assign("title","联运结算单汇总上游导出"); + $this->assign("is_export",$is_export); + $this->assign("sum",$sum); + $this->assign("time",$time); + $this->assign("data",$assign_data); + $this->display(); + + } + + public function checkCompanyData() { + + $statement_id = $_REQUEST["statement_id"]; + $company_id = $_REQUEST["company_id"]; + $begin_time = strtotime(str_replace(".","-",$_REQUEST["begin_time"])); + $end_time = strtotime(str_replace(".","-",$_REQUEST["end_time"]))+86399; + + if (!$company_id) { + $data = []; + } else { + $data = SM("company_statement","tab_") + ->where("statement_begin_time>={$begin_time} and statement_end_time<={$end_time} and company_id={$company_id} and id not in({$statement_id}) and (verify_status=1 or verify_status=-2)") + ->select(); + } + + $list = []; + $amount_data = json_decode($_REQUEST["amount_data"],true); + + //游戏数据整合 + foreach ($data as $key => $value) { + $promote_data = SM("promote", "tab_")->field("id")->where(['company_id' => $value['company_id']])->select(); + + $promote_ids = array_column($promote_data, "id"); + + $statement_info = json_decode($value['statement_info'], true); + + + if ($value['company_type'] == 1) { + $list = array_merge($list, $statement_info); + foreach ($statement_info as $k => $v) { + + $statement_begin_time = strtotime(str_replace(".", "-", $v['statement_begin_time'])); + $statement_end_time = strtotime(str_replace(".", "-", $v['statement_end_time'])) + 86399; + + $user_data = SM("user", "tab_") + ->field("id") + ->where([ + 'promote_id' => ['in', $promote_ids?$promote_ids:0], + 'fgame_name' => ['like', "%{$v['game_name']}%"], + "register_time" => ['between', [$statement_begin_time, $statement_end_time]] + ])->select(); + if ($v['game_name'] != '罚款' && $v['game_name'] != '奖励') { + $amount_data['pay_amount'] += $v["pay_amount"]; + } + + if ($v['game_name'] == '罚款') { + $amount_data['sum_money'] -= $v["sum_money"]; + } else { + $amount_data['sum_money'] += $v["sum_money"]; + } + + $amount_data['user_newcount'] += count($user_data); + + } + } elseif($value['company_type'] == 2) { + foreach ($statement_info as $k => $v) { + $game_list = $v["game_list"]; + $list = array_merge($list, $game_list); + foreach ($game_list as $gk=>$gv) { + $statement_begin_time = strtotime(str_replace(".", "-", $gv['statement_begin_time'])); + $statement_end_time = strtotime(str_replace(".", "-", $gv['statement_end_time'])) + 86399; + + if (!$amount_data['statement_begin_time'] || $amount_data['statement_begin_time'] > $gv['statement_begin_time']) { + $amount_data['statement_begin_time'] = $gv['statement_begin_time']; + } + + if (!$amount_data['statement_end_time'] || $amount_data['statement_end_time'] < $gv['statement_end_time']) { + $amount_data['statement_end_time'] = $gv['statement_end_time']; + } + + $user_data = SM("user", "tab_") + ->field("id") + ->where([ + 'promote_id' => ['in', $promote_ids?$promote_ids:0], + 'fgame_name' => ['like', "%{$gv['game_name']}%"], + "register_time" => ['between', [$statement_begin_time, $statement_end_time]] + ])->select(); + + if ($gv['game_name'] != '罚款' && $gv['game_name'] != '奖励') { + $amount_data['pay_amount'] += floatval($gv["pay_amount"]); + } + + if ($gv['game_name'] == '罚款') { + $amount_data['sum_money'] -= floatval($gv["sum_money"]); + } else { + $amount_data['sum_money'] += floatval($gv["sum_money"]); + } + + $amount_data['user_newcount'] += count($user_data); + } + } + } + } + if ($list) { + $list = array_repeat($list,"game_name"); + } + + $amount_data['pay_amount'] = number_format($amount_data['pay_amount'],2,'.',''); + $amount_data['sum_money'] = number_format($amount_data['sum_money'],2,'.',''); + + $this->ajaxReturn(['list'=>$list,'amount_data'=>$amount_data,"row"=>count($list),"status"=>1,"other_id"=>implode(",",array_column($data,"id"))]); + + } + + + public function saveCompanyData() { + + $list = array_merge(json_decode($_POST['list'],true),json_decode($_POST['other_list'],true)); + $amount_data = json_decode($_POST['amount_data'],true); + + $company_id = $_POST["company_id"]; + + $company_data = M("company_relation","tab_")->where("(first_company_id={$company_id} and first_company_type=2) or (second_company_id = {$company_id} and second_company_type=2)")->find(); + + $promote_company = []; + $partner = []; + + if ($company_data['first_company_type'] == 2) { + + $promote_company = M("promote_company","tab_")->where(['id'=>$company_data['first_company_id']])->find(); + $partner = M("company_info","tab_")->where(['id'=>$company_data['second_company_id']])->find(); + + }else if($company_data['second_company_type'] == 2) { + + $promote_company = M("promote_company","tab_")->where(['id'=>$company_data['second_company_id']])->find(); + $partner = M("company_info","tab_")->where(['id'=>$company_data['first_company_id']])->find(); + + } + + $company_info['id']=$promote_company['id']; + $company_info['partner']=$promote_company['company_name']; + $company_info['link_man']=$promote_company['settlement_contact']; + $company_info['phone']=$promote_company['contact_phone']; + $company_info['address']=$promote_company['address']; + + $company_info['bank_card']=$promote_company['bank_card']; + $company_info['bank_cardname']=$promote_company['bank_cardname']; + $company_info['bank_name']=$promote_company['bank_name']; + $company_info['bank_address']=$promote_company['bank_address']; + $company_info['ali_user']=$promote_company['ali_user']; + $company_info['ali_account']=$promote_company['ali_account']; + $company_info['is_payment'] = $company_data['is_payment']; + + $partner_info['id'] = $partner['id']; + $partner_info['partner'] = $partner['partner']; + $partner_info['link_man'] = $partner['link_man']; + $partner_info['link_phone'] = $partner['link_phone']; + $partner_info['invoice_type'] = $partner['invoice_type']; + $partner_info['invoice_item'] = $partner['invoice_item']; + $partner_info['address'] = $partner['address']; + + + if ($company_data['first_company_type'] == 2) { + + $first_company_info = $company_info; + $second_company_info = $partner_info; + + }else if($company_data['second_company_type'] == 2) { + + $first_company_info = $partner_info; + $second_company_info = $company_info; + + } + + $save['company_id'] = $company_id; + $save['company_name'] = $promote_company["company_name"]; + $save['statement_info'] = json_encode($list); + $save['first_party_info'] = json_encode($first_company_info); + $save['second_party_info'] = json_encode($second_company_info); + $save['statement_begin_time'] = strtotime(str_replace(".", "-", $amount_data['statement_begin_time'])); + $save['statement_end_time'] = strtotime(str_replace(".", "-", $amount_data['statement_end_time'])) + 86399; + $save['pay_amount'] = $amount_data['pay_amount']; + $save['sum_money'] = $amount_data['sum_money']-($amount_data['sum_money']*$_POST['fax_ratio']/100); + $save['user_newcount'] = $amount_data['user_newcount']; + $save['fax_ratio'] = $_POST['fax_ratio']; + + $is_success = SM("new_company_statement_info","tab_")->add($save); + + $pool['statement_num'] = "PL_".date('Ymd').date('His').sp_random_num(3); + $pool['statement_ids'] = $_POST['id'].','.$_POST['other_id']; + $pool['withdraw_type'] = 1; + $pool['wm_statement_ids'] = $is_success; + $pool['statement_begin_time'] = strtotime(str_replace(".", "-", $amount_data['statement_begin_time'])); + $pool['statement_end_time'] = strtotime(str_replace(".", "-", $amount_data['statement_end_time'])) + 86399; + $pool['statement_money'] = $save['sum_money']; + $pool['pay_amount'] = $save['pay_amount']; + $pool['platform_amount'] = $save['pay_amount']; + $pool['company_type'] = 2; + $pool['verify_log'] = json_encode(["create_user"=>$this->admininfo["username"],"create_time"=>date("Y.m.d H:i:s")]); + SM("company_statement_pool","tab_")->add($pool); + + + if ($_POST['other_id']) { + $statement_id = $_POST['id'].','.$_POST['other_id']; + } else { + $statement_id = $_POST['id']; + } + + + $dbres = $this->DBModel->field("id,verify_status,verify_log")->where("id in ({$statement_id})")->select(); + foreach ($dbres as $k => $v) { + $v['verify_log'] = json_decode($v['verify_log'],true); + $v['verify_log']['pool_user']=$this->admininfo["username"]; + $v['verify_log']['pool_time']=date("Y.m.d H:i:s"); + $v['verify_log']['pool_num']=$pool['statement_num']; + $v['verify_log'] = json_encode($v['verify_log']); + $v['verify_status']=2; + $v['op_time']=time(); + + SM("company_statement","tab_")->save($v); + } + + if ($is_success) { + $this->ajaxReturn(['status'=>1,'msg'=>'操作成功']); + } else { + $this->ajaxReturn(['status'=>0,'msg'=>'操作失败']); + } + + } + //审批通过 public function adminAgree(){ $this->setVerifyStatus(0,1,"admin"); diff --git a/Application/Admin/Controller/CompanyStatementPoolController.class.php b/Application/Admin/Controller/CompanyStatementPoolController.class.php index 1fdfd90d7..ce4d619ea 100644 --- a/Application/Admin/Controller/CompanyStatementPoolController.class.php +++ b/Application/Admin/Controller/CompanyStatementPoolController.class.php @@ -184,7 +184,12 @@ class CompanyStatementPoolController extends ThinkController $v["payment"] = '--'; } - $v['oplist'] = $this->OpAuth($v); +// $v['oplist'] = $this->OpAuth($v); + if (IS_SUBSITE) { + $v['oplist'] = $this->OpWmAuth($v); + } else { + $v['oplist'] = $this->OpAuth($v); + } } // dump($data);die(); $count = $this->DBModel->field("count(id) count,SUM(statement_money) as statement_money,SUM(lack_statement_money) lack_statement_money")->where($map)->find(); @@ -212,6 +217,7 @@ class CompanyStatementPoolController extends ThinkController $this->error('参数错误'); } $id = $_REQUEST['id']; + $is_export= false; if (isset($_REQUEST['export']) && $_REQUEST['export']==1){ $is_export = true; @@ -220,7 +226,7 @@ class CompanyStatementPoolController extends ThinkController $infolist = SM("company_statement_info","tab_")->field("*,'1' as st")->where("pool_id = '{$id}'")->select(); //获取母单 $pool_info = SM("company_statement_pool","tab_") - ->field('statement_num,create_lack_ids,verify_status,is_payment,withdraw_type,statement_begin_time,statement_end_time,verify_log')->where("id={$id}")->find(); + ->field('wm_statement_ids,statement_num,create_lack_ids,verify_status,is_payment,withdraw_type,statement_begin_time,statement_end_time,verify_log')->where("id={$id}")->find(); if(!empty($pool_info['create_lack_ids'])){ $l_ids = $pool_info['create_lack_ids']; $lack_info = SM("company_lack_statement_info","tab_")->field("*,'0' as st")->where("id in ({$l_ids})")->select(); @@ -258,6 +264,12 @@ class CompanyStatementPoolController extends ThinkController $pool_info["verify"] = '--'; } + if(true) { + + $this->viewWmStatement($pool_info['wm_statement_ids'],$is_export); + die(); + + } if(isset($pool_info['verify_log']['payment_user'])){ if($pool_info['verify_status'] == -2){ @@ -296,6 +308,133 @@ class CompanyStatementPoolController extends ThinkController } + public function exportWmStatement($wm_statement_ids = 0) { + + header("Content-type: text/html; charset=utf-8"); + error_reporting(E_ALL); + ini_set('display_errors', TRUE); + ini_set('display_startup_errors', TRUE); + + define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); + + Vendor("PHPExcel.PHPExcel"); + $objPHPExcel = new \PHPExcel(); + $objReader = \PHPExcel_IOFactory::createReader('Excel2007'); + + //设置模板文件 + $objPHPExcel = $objReader->load("Public/Admin/excel/wmStatement.xlsx"); + + $data = SM("new_company_statement_info","tab_")->where(['id'=>$wm_statement_ids])->find(); + + $list = json_decode($data['statement_info'],true); + $statement_begin_time = date("Y-m-d",$data['statement_begin_time']); + $statement_end_time = date("Y-m-d",$data['statement_end_time']); + + $amount_data['pay_amount'] = $data['pay_amount']; + $amount_data['user_newcount'] = $data['user_newcount']; + $amount_data['fax_ratio'] = $data['fax_ratio']; + $amount_data['sum_money'] = $data['sum_money']; + + $first_party_info = json_decode($data['first_party_info'],true); + $second_party_info = json_decode($data['second_party_info'],true); + + + $objPHPExcel->getActiveSheet()->setCellValue('A1', "《 {$data['company_name']} 》结算单\n({$statement_begin_time}-{$statement_end_time})"); + + $line = 3; + foreach ($list as $key => $value) { + $objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1); + $objPHPExcel->getActiveSheet()->removeConditionalStyles(); + + $objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $value['statement_begin_time'].'-'.$value['statement_end_time']); + $objPHPExcel->getActiveSheet()->setCellValue('B'.$line, $value['game_name']); + $line++; + } + $objPHPExcel->getActiveSheet()->setCellValue('C3', $amount_data['pay_amount']); + $objPHPExcel->getActiveSheet()->setCellValue('D3', $amount_data['user_newcount']); + $objPHPExcel->getActiveSheet()->setCellValue('E3', $amount_data['fax_ratio'])."%"; + $objPHPExcel->getActiveSheet()->setCellValue('F3', $amount_data['sum_money']); + + $tline = $line-1; + + $objPHPExcel->getActiveSheet()->mergeCells("C3:C{$tline}")->mergeCells("D3:D{$tline}")->mergeCells("E3:E{$tline}")->mergeCells("F3:F{$tline}"); + + $objPHPExcel->getActiveSheet()->setCellValue('B'.($line), convertAmountToCn($amount_data['sum_money'])); + + //甲方信息 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($tline+3), $first_party_info['partner']);//甲方 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($tline+4), $first_party_info['link_man']);//联系人 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($tline+5), $first_party_info['link_phone']."\t");//联系电话 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($tline+6), $first_party_info['invoice_item']);//开票项目 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($tline+7), $first_party_info['invoice_type']);//发票类型 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($tline+8), $first_party_info['address']);//发票类型 + + //乙方信息 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($tline+3), $second_party_info['partner']);//乙方 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($tline+4), $second_party_info['link_man']);//联系人 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($tline+5), $second_party_info['phone']."\t");//联系电话 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($tline+6), $second_party_info['address']);//邮寄地址 + if ($second_party_info['is_payment'] != 1) { + $objPHPExcel->getActiveSheet()->setCellValue('E'.($tline+8), $second_party_info['bank_address']);//户名 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($tline+9), $second_party_info['bank_card']."\t");//银行账号 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($tline+10), $second_party_info['bank_name']);//开户行 + } else { + $objPHPExcel->getActiveSheet()->setCellValue('E'.($tline+8), $second_party_info['ali_user']);//户名 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($tline+9), $second_party_info['ali_account']."\t");//银行账号 + } + + + + $fileName = "{$data['company_name']}&{$data['my_company']}-对账单{$statement_begin_time}-{$statement_end_time}"; +// dd($fileName); + ob_end_clean();//清除缓冲区,避免乱码 + header('pragma:public'); + header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls'); + header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印 + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); + $objWriter->save('php://output'); + exit; + + } + + + public function viewWmStatement($wm_statement_ids = '',$is_export=0) { + + if (!$wm_statement_ids) { + $this->error('参数错误'); + } + + if ($is_export) { + $this->exportWmStatement($wm_statement_ids); + } + + $data = SM("new_company_statement_info","tab_")->where(['id'=>$wm_statement_ids])->find(); + + $list = json_decode($data['statement_info'],true); + $statement_begin_time = date("Y-m-d",$data['statement_begin_time']); + $statement_end_time = date("Y-m-d",$data['statement_end_time']); + + $amount_data['pay_amount'] = $data['pay_amount']; + $amount_data['user_newcount'] = $data['user_newcount']; + $amount_data['fax_ratio'] = $data['fax_ratio']; + $amount_data['sum_money'] = $data['sum_money']; + + $first_party_info = json_decode($data['first_party_info'],true); + $second_party_info = json_decode($data['second_party_info'],true); + + $this->assign("list",$list); + $this->assign("row",count($list)); + $this->assign("company_name",$data['company_name']); + $this->assign("statement_begin_time",$statement_begin_time); + $this->assign("statement_end_time",$statement_end_time); + $this->assign("amount_data",$amount_data); + $this->assign("first_party_info",$first_party_info); + $this->assign("second_party_info",$second_party_info); + + $this->display("poolWmStatement"); + + } + //查看 public function viewUnPaymentPool() { @@ -310,7 +449,7 @@ class CompanyStatementPoolController extends ThinkController //获取基本信息 $infolist = SM("company_statement_info","tab_")->field("*,'1' as st")->where("pool_id = '{$id}' and pay_status!=1")->select(); //获取母单 - $pool_info = SM("company_statement_pool","tab_")->field('statement_num,create_lack_ids,verify_status,is_payment,withdraw_type,statement_begin_time,statement_end_time')->where("id={$id}")->find(); + $pool_info = SM("company_statement_pool","tab_")->field('wm_statement_ids,statement_num,create_lack_ids,verify_status,is_payment,withdraw_type,statement_begin_time,statement_end_time')->where("id={$id}")->find(); // if(!empty($pool_info['create_lack_ids'])){ // $l_ids = $pool_info['create_lack_ids']; // $lack_info = SM("company_lack_statement_info","tab_")->field("*,'0' as st")->where("id in ({$l_ids})")->select(); @@ -323,6 +462,7 @@ class CompanyStatementPoolController extends ThinkController $this->assign("title",$statement_num); $this->assign("pool_status",$pool_info['verify_status']); $this->assign("is_payment",$pool_info['is_payment']); + if($infolist[0]['company_type'] == 3){ //上游 $this->viewCpPool($infolist,$is_export); @@ -335,7 +475,6 @@ class CompanyStatementPoolController extends ThinkController } - public function editPool() { if(!isset($_REQUEST['id'])){ $this->error('参数错误'); @@ -1880,9 +2019,14 @@ class CompanyStatementPoolController extends ThinkController public function cancelPool(){ if(!isset($_REQUEST['id'])) $this->error("参数错误"); $id = $_REQUEST['id']; + //获取基础信息 $db_res = $this->DBModel->where("id='{$id}'")->find(); + if (IS_SUBSITE) { + $this->cancelWmCompanyPool($db_res); + } + $is_qz = (substr($db_res['statement_num'],0,2) == "QZ" ? true :false); //强制汇总的都允许回退 if($is_qz){ //强制汇总回退 @@ -1913,6 +2057,52 @@ class CompanyStatementPoolController extends ThinkController } } + + public function cancelWmCompanyPool($info) + { + if(in_array($info['verify_status'],[3,4])) return;//有打款就不允许回退 + + $sids = $info['statement_ids']; + $wm_statement_ids = $info['wm_statement_ids']; + + SM()->startTrans();//事务 + //删除info + $infores = SM("new_company_statement_info","tab_")->where(['id'=>$wm_statement_ids])->delete(); + if($infores === false){ + SM()->rollback(); + $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); + } + //删除自己 + $poolres = $this->DBModel->where("id = {$info['id']}")->delete(); + if($poolres === false){ + SM()->rollback(); + $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); + } + //修改结算单信息 + $sids = array_filter(explode(",",$sids)); + + $st_res = SM("company_statement","tab_")->field("id,verify_status,verify_log")->where(["id"=>['in',$sids]])->select(); + + foreach($st_res as $k=>&$v){ + $v['verify_log'] = json_decode($v['verify_log'],true); + $v['verify_log']['pool_user']=$this->admininfo["username"]; + $v['verify_log']['pool_time']=date("Y.m.d H:i:s"); + $v['verify_log'] = json_encode($v['verify_log']); + $v['verify_status']=-2; + $stres = SM("company_statement","tab_")->save($v); + if($stres === false){ + SM()->rollback(); + $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); + } + } + + SM()->commit(); + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"撤销汇总成功" + )); + } + /** * 重算 先全删再进行二次生成 */ @@ -2041,7 +2231,103 @@ class CompanyStatementPoolController extends ThinkController )); } + public function OpWmAuth($info) + { + $id = $info['id']; + $img = $info['ext_file']; + $remark = $info['remark']; + $create_lack_ids = $info['create_lack_ids']; + $is_qz = (substr($info['statement_num'],0,2) == "QZ" ? true :false); //强制汇总的都允许回退 + + //原始列表 + $opBtn = [ + "viewPool"=>"查看", + + "editPool"=>"编辑", + "editSpecialPuPool"=>"编辑", + + "addRemark"=>"新增备注", + "editRemark"=>"修改备注", + "viewRemark"=>"查看备注", + + "uploadVoucher"=>"上传凭证", + "viewVoucher"=>"查看凭证", + "editVoucher"=>" 编辑凭证", + + "setUlPayment"=>"线下打款", + + "setPayment"=>"打款信息确认", + "editPayment"=>"打款信息编辑", + "viewPayment"=>"打款详情", + + 'reCount'=>"重算", + 'cancelPool'=>"撤销汇总", + ]; + //操作对应菜单 + $optist = []; + switch ($info['verify_status']) { + case '-2': + case '-1': + case '0': + $optist = ["viewPool","cancelPool"]; + break; + case '1': + $optist = ["viewPool","viewVoucher","editVoucher","uploadVoucher","editPayment","setUlPayment"]; + break; + case '2': + $optist = ["viewPool","viewVoucher","editVoucher","uploadVoucher"]; + break; + case '3': + $optist = ["viewPool","viewVoucher","editVoucher","uploadVoucher","viewPayment"]; + break; + case '4': + $optist = ["viewPool","viewVoucher","editVoucher","uploadVoucher","viewPayment"]; + break; + case '5': + $optist = ["viewPool","cancelPool"]; + break; + case '6': + $optist = ["viewPool","cancelPool"]; + + break; + default: + break; + } + + if(empty($info['ext_file'])){ + //未上传凭证 + $optist = array_diff($optist, ["viewVoucher", "editVoucher"]); + }else{ + $optist = array_diff($optist, ["uploadVoucher"]); + } + + if($info['is_payment'] == 1){ + $optist = array_diff($optist, ["setUlPayment"]); + }else{ + $optist = array_diff($optist, ["setPayment","editPayment","viewPayment"]); + } + + if(empty($info['remark'])){ + //未上传备注 + $optist = array_diff($optist, ["editRemark", "viewRemark"]); + }else{ + $optist = array_diff($optist, ["addRemark"]); + } + + // + $resarr = []; + foreach ($optist as $k => $v) { + if(IS_ROOT){ + $resarr[] = $opBtn[$v]; + }else{ + if(in_array($v,$this->OpAuthList)){ + $resarr[] = $opBtn[$v]; + } + } + } + return $resarr; + } public function OpAuth($info) { diff --git a/Application/Admin/Controller/StatementMangementController.class.php b/Application/Admin/Controller/StatementMangementController.class.php index ed8c47fb4..a7b96b79a 100644 --- a/Application/Admin/Controller/StatementMangementController.class.php +++ b/Application/Admin/Controller/StatementMangementController.class.php @@ -247,9 +247,9 @@ class StatementMangementController extends ThinkController public function rewardManageList($row = 10, $p = 1) { - $companys[1] = array_column(M('partner', 'tab_')->field('id, partner as name')->select(), 'name', 'id'); - $companys[2] = array_column(M('promote_company', 'tab_')->field('id, company_name as name')->select(), 'name', 'id'); - $games = array_column(M('game', 'tab_')->field('relation_game_id, relation_game_name, partner_id')->group('relation_game_id')->select(), null, 'relation_game_id'); + $companys[1] = array_column(SM('partner', 'tab_')->field('id, partner as name')->select(), 'name', 'id'); + $companys[2] = array_column(SM('promote_company', 'tab_')->field('id, company_name as name')->select(), 'name', 'id'); + $games = array_column(SM('game', 'tab_')->field('relation_game_id, relation_game_name, partner_id')->group('relation_game_id')->select(), null, 'relation_game_id'); $map = ' 1=1 '; $params = $_GET; @@ -323,7 +323,7 @@ class StatementMangementController extends ThinkController $map .= " and rd.promote_account like ('%{$params['detail_promote_account_input']}%') "; } - $result = M('reward_record', 'tab_')->alias('r') + $result = SM('reward_record', 'tab_')->alias('r') ->field('r.id') ->join('tab_reward_detail as rd on rd.record_id = r.id', 'LEFT') ->where($map) @@ -344,7 +344,7 @@ class StatementMangementController extends ThinkController $map = '1<>1'; } - $list = M('reward_record', 'tab_')->alias('r') + $list = SM('reward_record', 'tab_')->alias('r') ->field(' r.id, r.relation_game_id, r.settlement_time, r.confirm_time, r.content, r.reward_type, r.creater_id, rd.id as rid, rd.type as detail_type, rd.company_type as detail_company_type, rd.company_id as detail_company_id , rd.company_name as detail_company_name, rd.settlement_type as detail_settlement_type, rd.promote_account as detail_promote_account,rd.amount as detail_amount @@ -400,9 +400,14 @@ class StatementMangementController extends ThinkController if ($page) { $this->assign('_page', $page); } + + if(IS_SUBSITE) { + $this->assign("IS_SUBSITE",true); + } + // ksort($record); $this->assign('list', $record); - $this->assign('promoters', array_column(M('promote', 'tab_')->where(['level'=>1])->field('id, nickname, account')->select(), null, 'id')); + $this->assign('promoters', array_column(SM('promote', 'tab_')->where(['level'=>1])->field('id, nickname, account')->select(), null, 'id')); $this->checkListOrCountAuthRestMap($map,[]); @@ -509,7 +514,7 @@ class StatementMangementController extends ThinkController //dd($settlment_info); // 更新结算信息 if ($id) { - M('reward_detail', 'tab_')->where(['record_id'=>$id])->delete(); + SM('reward_detail', 'tab_')->where(['record_id'=>$id])->delete(); } if (!empty($settlment_info[RewardModel::REWARD_TYPE_REWARD]) && !empty($settlment_info[RewardModel::REWARD_TYPE_PUNISH])) { $data['reward_type'] = RewardModel::REWARD_TYPE_ALL; @@ -529,14 +534,14 @@ class StatementMangementController extends ThinkController return $this->error("奖惩确认时间需在结算时间以后,请重新选择"); } - $upt = M('reward_record', 'tab_')->where(['id'=>$id])->save($data); + $upt = SM('reward_record', 'tab_')->where(['id'=>$id])->save($data); if ($upt === false) { $this->error('保存失败'); } else { foreach ($settlmentSet as $item) { - M('reward_detail', 'tab_')->add($item); + SM('reward_detail', 'tab_')->add($item); } - $companyName = M('partner','tab_')->field('partner')->where(['id'=>$data['company_id']])->find(); + $companyName = SM('partner','tab_')->field('partner')->where(['id'=>$data['company_id']])->find(); addOperationLog(['op_type'=>1,'key'=>$companyName['partner'].'/'.(($data['reward_type']==1)?'奖励':'惩罚').'/'.$data['money'],'op_name'=>'修改奖惩记录','url'=>U('Query/settlement'),'menu'=>'推广员-结算单管理-奖罚记录管理-修改奖惩记录']); $this->success('保存成功', U('StatementMangement/rewardManageList')); @@ -550,38 +555,38 @@ class StatementMangementController extends ThinkController $data['create_time'] = time(); $data['creater_id'] = is_login(); - $ins = M('reward_record', 'tab_')->add($data); + $ins = SM('reward_record', 'tab_')->add($data); - $record_id = M('reward_record', 'tab_')->getLastInsID(); + $record_id = SM('reward_record', 'tab_')->getLastInsID(); foreach ($settlmentSet as $item) { $item['record_id'] = $record_id; - M('reward_detail', 'tab_')->add($item); + SM('reward_detail', 'tab_')->add($item); } - $companyName = M('partner','tab_')->field('partner')->where(['id'=>$data['company_id']])->find(); + $companyName = SM('partner','tab_')->field('partner')->where(['id'=>$data['company_id']])->find(); addOperationLog(['op_type'=>0,'key'=>$companyName['partner'].'/'.(($data['reward_type']==1)?'奖励':'惩罚').'/'.$data['money'],'op_name'=>'新增奖惩记录','url'=>U('Query/settlement'),'menu'=>'推广员-结算单管理-奖罚记录管理-新增奖惩记录']); return $ins ? $this->success('新增成功', U('StatementMangement/rewardManageList')) : $this->error('新增失败'); } } else { - $games = M('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select(); + $games = SM('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select(); $this->assign('games', $games); if ($id) { if (I('delete')) { - $rewardRecordData = M('reward_record', 'tab_')->where(['id'=>$id])->find(); + $rewardRecordData = SM('reward_record', 'tab_')->where(['id'=>$id])->find(); - $upt = M('reward_record', 'tab_')->where(['id'=>$id])->delete(); + $upt = SM('reward_record', 'tab_')->where(['id'=>$id])->delete(); - M('reward_detail', 'tab_')->where(['record_id'=>$id])->delete(); + SM('reward_detail', 'tab_')->where(['record_id'=>$id])->delete(); - $companyName = M('partner','tab_')->field('partner')->where(['id'=>$rewardRecordData['company_id']])->find(); + $companyName = SM('partner','tab_')->field('partner')->where(['id'=>$rewardRecordData['company_id']])->find(); addOperationLog(['op_type'=>2,'key'=>$companyName['partner'].'/'.(($rewardRecordData['reward_type']==1)?'奖励':'惩罚').'/'.$rewardRecordData['money'],'op_name'=>'删除奖惩记录','url'=>U('StatementMangement/rewardManageList'),'menu'=>'推广员-结算单管理-奖罚记录管理']); return $upt ? $this->success('删除成功') : $this->error('删除失败'); } else { - $data = M('reward_record', 'tab_')->where(['id'=>$id])->find(); + $data = SM('reward_record', 'tab_')->where(['id'=>$id])->find(); if (!$data) return $this->error("未找到该记录"); $data['confirm_time'] = $data['confirm_time'] ? date('Y-m-d', $data['confirm_time']) : ''; $data['accounts'] = json_decode($data['accounts'], true) ?: []; @@ -592,15 +597,15 @@ class StatementMangementController extends ThinkController $data['reward_time'] = strtotime(date('Y-m-01')); } - $details = M('reward_detail', 'tab_')->where(['record_id'=>$id])->select(); + $details = SM('reward_detail', 'tab_')->where(['record_id'=>$id])->select(); // 根据type 来合并 foreach ($details as $item) { $item['info'] = $item; if (empty($item['company_name']) && $item['company_id']) { if ($item['company_type'] == RewardModel::COMPANY_TYPE_PARTNER) { - $item['company_name'] = M('partner', 'tab_')->where(['id'=>$item['company_id']])->getField('partner'); + $item['company_name'] = SM('partner', 'tab_')->where(['id'=>$item['company_id']])->getField('partner'); } else { - $item['company_name'] = M('promote_company', 'tab_')->where(['id'=>$item['company_id']])->getField('company_name'); + $item['company_name'] = SM('promote_company', 'tab_')->where(['id'=>$item['company_id']])->getField('company_name'); } } $tmp[$item['type']][] = $item; @@ -613,7 +618,7 @@ class StatementMangementController extends ThinkController $this->assign('details', $tmp); $this->assign('data', $data); - $this->assign('promoters', M('promote', 'tab_')->where(['level'=>1])->field('id, nickname')->select()); + $this->assign('promoters', SM('promote', 'tab_')->where(['level'=>1])->field('id, nickname')->select()); $this->assign('rewardTypes', RewardModel::$rewardTypes); $this->assign('settlementTypes', RewardModel::$settlementTypes); $this->assign('companyTypes', RewardModel::$companyTypes); @@ -679,24 +684,24 @@ class StatementMangementController extends ThinkController public function rewardManageDetail($id=0) { - $games = M('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select(); + $games = SM('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select(); $this->assign('games', $games); if ($id) { if (I('delete')) { - $rewardRecordData = M('reward_record', 'tab_')->where(['id'=>$id])->find(); + $rewardRecordData = SM('reward_record', 'tab_')->where(['id'=>$id])->find(); - $upt = M('reward_record', 'tab_')->where(['id'=>$id])->delete(); + $upt = SM('reward_record', 'tab_')->where(['id'=>$id])->delete(); - M('reward_detail', 'tab_')->where(['record_id'=>$id])->delete(); + SM('reward_detail', 'tab_')->where(['record_id'=>$id])->delete(); - $companyName = M('partner','tab_')->field('partner')->where(['id'=>$rewardRecordData['company_id']])->find(); + $companyName = SM('partner','tab_')->field('partner')->where(['id'=>$rewardRecordData['company_id']])->find(); addOperationLog(['op_type'=>2,'key'=>$companyName['partner'].'/'.(($rewardRecordData['reward_type']==1)?'奖励':'惩罚').'/'.$rewardRecordData['money'],'op_name'=>'删除奖惩记录','url'=>U('StatementMangement/rewardManageList'),'menu'=>'推广员-结算单管理-奖罚记录管理']); return $upt ? $this->success('删除成功') : $this->error('删除失败'); } else { - $data = M('reward_record', 'tab_')->where(['id'=>$id])->find(); + $data = SM('reward_record', 'tab_')->where(['id'=>$id])->find(); if (!$data) return $this->error("未找到该记录"); $data['confirm_time'] = $data['confirm_time'] ? date('Y-m-d', $data['confirm_time']) : ''; $data['accounts'] = json_decode($data['accounts'], true) ?: []; @@ -707,15 +712,15 @@ class StatementMangementController extends ThinkController $data['reward_time'] = strtotime(date('Y-m-01')); } - $details = M('reward_detail', 'tab_')->where(['record_id'=>$id])->select(); + $details = SM('reward_detail', 'tab_')->where(['record_id'=>$id])->select(); // 根据type 来合并 foreach ($details as $item) { $item['info'] = $item; if (empty($item['company_name']) && $item['company_id']) { if ($item['company_type'] == RewardModel::COMPANY_TYPE_PARTNER) { - $item['company_name'] = M('partner', 'tab_')->where(['id'=>$item['company_id']])->getField('partner'); + $item['company_name'] = SM('partner', 'tab_')->where(['id'=>$item['company_id']])->getField('partner'); } else { - $item['company_name'] = M('promote_company', 'tab_')->where(['id'=>$item['company_id']])->getField('company_name'); + $item['company_name'] = SM('promote_company', 'tab_')->where(['id'=>$item['company_id']])->getField('company_name'); } } $tmp[$item['type']][] = $item; @@ -728,21 +733,207 @@ class StatementMangementController extends ThinkController $this->assign('details', $tmp); $this->assign('data', $data); - $this->assign('promoters', M('promote', 'tab_')->where(['level'=>1])->field('id, nickname')->select()); + $this->assign('promoters', SM('promote', 'tab_')->where(['level'=>1])->field('id, nickname')->select()); $this->assign('rewardTypes', RewardModel::$rewardTypes); $this->assign('settlementTypes', RewardModel::$settlementTypes); $this->assign('companyTypes', RewardModel::$companyTypes); $this->display('rewardManagerDetail'); } + + public function addreward() { + + $batch = date('Ymd') . date('His') . sp_random_num(3); + $this->assign("batch", $batch); + $this->meta_title = 'EXCEL导入'; + $this->display(); + + } + + public function loopAdd() + { + + Vendor('PHPExcel.PHPExcel'); + $p = $_REQUEST; +// $batch = $p['batch']; + $checkarr = $p['checkarr']; + //循环获取添加 + if (count($checkarr) < 1) { + $this->ajaxReturn(["status" => 0, "msg" => "没有数据"]); + } + + $reward_type = [ + "无"=>0, + "奖励"=>1, + "惩罚"=>2, + "双向"=>3 + ]; + + $company_type = [ + "无"=>0, + "上游公司"=>1, + "下游公司"=>2, + "内部公司"=>3 + ]; + + $type = [ + "无"=>0, + "奖励方"=>1, + "惩罚方"=>2 + ]; + + $settlement_type = [ + "线下结算"=>1, + "线上结算"=>2 + ]; + + $all_record = []; + $all_detail = []; + $record = []; + $detail = []; + $md5 = ''; + foreach ($checkarr as $k => $v) { + + if ($v['game_name']) { + $record = []; + $detail = []; + $game_data = SM("game","tab_")->field("relation_game_id")->where(['relation_game_name'=>$v['game_name']])->find(); + + $record["reward_type"] = $reward_type[$v['reward_type']]; + $record["accounts"] = json_encode([]); + $record["relation_game_id"] = $game_data["relation_game_id"]?$game_data["relation_game_id"]:0; + $record["content"] = $v["content"]; + + $record["reward_time"] = strtotime(gmdate("Y-m-d", \PHPExcel_Shared_Date::ExcelToPHP($v["reward_time"]))); + $record["confirm_time"] = strtotime(gmdate("Y-m-d", \PHPExcel_Shared_Date::ExcelToPHP($v["confirm_time"]))); + $record["settlement_time"] = strtotime(gmdate("Y-m-d", \PHPExcel_Shared_Date::ExcelToPHP($v["settlement_time"]))); + $record["create_time"] = time(); + $record["creater_id"] = $_SESSION['onethink_admin']['user_auth']['uid']; + + $md5 = md5($record["relation_game_id"].$record["content"].$record["create_time"].$record["confirm_time"].$record["reward_time"].$record["settlement_time"]); + + $all_record[$md5] = $record; + if ($v["company_name"]!="无") { + + $company_data = SM("promote_company","tab_")->field("id")->where(['company_name'=>$v["company_name"]])->find(); + $detail["company_type"] = $company_type[$v["company_type"]]?$company_type[$v["company_type"]]:0; + $detail["type"] = $type[$v["type"]]?$type[$v["type"]]:0; + $detail["company_id"] = $company_data["id"]?$company_data["id"]:0; + $detail["company_name"] = $v["company_name"]?$v["company_name"]:''; + $detail["promote_account"] = $v["promote_account"]?$v["promote_account"]:''; + $detail["settlement_type"] = $settlement_type[$v["settlement_type"]]?$settlement_type[$v["settlement_type"]]:0; + $detail["amount"] = abs($v["amount"])?abs($v["amount"]):0; + $detail["confirm_time"] = $record["confirm_time"]; + + $all_detail[$md5][] = $detail; + + } + $detail = []; + if ($v["company_name_1"]!="无") { + + $company_data = SM("promote_company","tab_")->field("id")->where(['company_name'=>$v["company_name_1"]])->find(); + $detail["company_type"] = $company_type[$v["company_type_1"]]?$company_type[$v["company_type_1"]]:0; + $detail["type"] = $type[$v["type_1"]]?$type[$v["type_1"]]:0; + $detail["company_id"] = $company_data["id"]?$company_data["id"]:0; + $detail["company_name"] = $v["company_name_1"]?$v["company_name_1"]:''; + $detail["promote_account"] = $v["promote_account_1"]?$v["promote_account_1"]:''; + $detail["settlement_type"] = $settlement_type[$v["settlement_type_1"]]?$settlement_type[$v["settlement_type_1"]]:0; + $detail["amount"] = abs($v["amount_1"])?abs($v["amount_1"]):0; + $detail["confirm_time"] = $record["confirm_time"]; + + $all_detail[$md5][] = $detail; + + } + + } else { + $detail = []; + if ($v["company_name"]!="无") { + + $company_data = SM("promote_company","tab_")->field("id")->where(['company_name'=>$v["company_name"]])->find(); + $detail["company_type"] = $company_type[$v["company_type"]]?$company_type[$v["company_type"]]:0; + $detail["type"] = $type[$v["type"]]?$type[$v["type"]]:0; + $detail["company_id"] = $company_data["id"]?$company_data["id"]:0; + $detail["company_name"] = $v["company_name"]?$v["company_name"]:''; + $detail["promote_account"] = $v["promote_account"]?$v["promote_account"]:''; + $detail["settlement_type"] = $settlement_type[$v["settlement_type"]]?$settlement_type[$v["settlement_type"]]:0; + $detail["amount"] = abs($v["amount"])?abs($v["amount"]):0; + $detail["confirm_time"] = $record["confirm_time"]; + + $all_detail[$md5][] = $detail; + + } + $detail = []; + if ($v["company_name_1"]!="无") { + + $company_data = SM("promote_company","tab_")->field("id")->where(['company_name'=>$v["company_name_1"]])->find(); + $detail["company_type"] = $company_type[$v["company_type_1"]]; + $detail["type"] = $type[$v["type_1"]]?$type[$v["type_1"]]:0; + $detail["company_id"] = $company_data["id"]?$company_data["id"]:0; + $detail["company_name"] = $v["company_name_1"]?$v["company_name_1"]:''; + $detail["promote_account"] = $v["promote_account_1"]?$v["promote_account_1"]:''; + $detail["settlement_type"] = $settlement_type[$v["settlement_type_1"]]?$settlement_type[$v["settlement_type_1"]]:0; + $detail["amount"] = abs($v["amount_1"])?abs($v["amount_1"]):0; + $detail["confirm_time"] = $record["confirm_time"]; + + $all_detail[$md5][] = $detail; + + } + } + + } +// dump($all_record); + foreach ($all_record as $key => $value) { + + $insert_id = SM("reward_record","tab_")->add($value); + + foreach ($all_detail[$key] as $k => $v) { + $all_detail[$key][$k]['record_id'] = $insert_id; + } + + $is_success = SM("reward_detail","tab_")->addAll($all_detail[$key]); + + } + + $this->ajaxReturn(["status" => 1, "msg" => "导入成功"]); + + } + + //模板导出 + public function download() + { + + + header("Content-type: text/html; charset=utf-8"); + error_reporting(E_ALL); + ini_set('display_errors', TRUE); + ini_set('display_startup_errors', TRUE); + + define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); + + Vendor("PHPExcel.PHPExcel"); + $objPHPExcel = new \PHPExcel(); + $objReader = \PHPExcel_IOFactory::createReader('Excel2007'); + + //设置模板文件 + $objPHPExcel = $objReader->load("Public/Admin/excel/rewardOrfina.xlsx"); + + $fileName = "奖惩导入"; + ob_end_clean();//清除缓冲区,避免乱码 + header('pragma:public'); + header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls'); + header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印 + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); + $objWriter->save('php://output'); + exit; + } public function getCompanys($type=1) { if ($type == 1) { - $data = M('partner', 'tab_')->field('id, partner as name')->select(); + $data = SM('partner', 'tab_')->field('id, partner as name')->select(); } elseif ($type == 0) { $data = []; } else { - $data = M('promote_company', 'tab_')->field('id, company_name as name')->select(); + $data = SM('promote_company', 'tab_')->field('id, company_name as name')->select(); } return $this->success($data, '', true); } diff --git a/Application/Admin/View/CompanyStatement/lists.html b/Application/Admin/View/CompanyStatement/lists.html index 57ed0de84..a76a10e3f 100644 --- a/Application/Admin/View/CompanyStatement/lists.html +++ b/Application/Admin/View/CompanyStatement/lists.html @@ -475,6 +475,7 @@ }else if(id=="pool"){ var opname = "发起汇总"; var opurl = "{:U('pool_splice')}"; + var opst ="[审批通过,汇总撤销]"; var status = [1,-2]; }else if(id=="updateStatement"){ @@ -516,6 +517,7 @@ return; } text = text.join(","); + // console.log(text); if(flag){ layer.confirm(opname+"仅会对"+opst+"的申请进行处理,选择中包含其他的状态的申请将被忽略,点击取消停止操作",{title:false}, function(index){ @@ -538,6 +540,12 @@ } function _doAgreeApply(){ + var IS_SUBSITE = "{$IS_SUBSITE}"; + if (id=="pool" && IS_SUBSITE) { + _poolWmStatement(); + return; + } + //执行 layer.load(2); $.ajax({ @@ -560,6 +568,41 @@ } }); } + + function _poolWmStatement() { + layer.load(2); + $.ajax({ + type: 'post', + url: "{:U('checkWmStatement')}", + data:{id:text}, + success: function(data) { + if(data.status == 0) { + layer.msg("不同类型的结算单不能放在一起汇总"); + layer.closeAll("loading"); + } else { + var url = "{:U('poolWmStatement')}"+"&id="+text; + layer.open({ + type: 2, + title: "海南万盟天下科技有限公司", + shadeClose: true, + shade: 0.8, + area: ['70%', '80%'], + content: url + }); + layer.closeAll("loading"); + return; + } + + }, + error:function(){ + layer.closeAll("loading"); + layer.alert("网络错误或超时"); + return false; + } + }); + + + } }) $("#launch").on("click",function(){ var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { diff --git a/Application/Admin/View/CompanyStatement/poolWmStatement.html b/Application/Admin/View/CompanyStatement/poolWmStatement.html new file mode 100644 index 000000000..0b7b5752b --- /dev/null +++ b/Application/Admin/View/CompanyStatement/poolWmStatement.html @@ -0,0 +1,275 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +
+
+
结算单 +
({$amount_data['statement_begin_time']}-{$amount_data['statement_end_time']})
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
结算月份合作产品名称月累计用户充值流水月新增用户数税费费率结算金额(元)
{$data[0]['statement_begin_time']}-{$data[0]['statement_end_time']}{$data[0]['game_name']}{$amount_data['pay_amount']}{$amount_data['user_newcount']}%{$amount_data['sum_money']}
{$it['statement_begin_time']}-{$it['statement_end_time']}{$it['game_name']}
+
+
+ + 返回 + + +
+
+
+
+ + + diff --git a/Application/Admin/View/CompanyStatement/showCpStatementList.html b/Application/Admin/View/CompanyStatement/showCpStatementList.html new file mode 100644 index 000000000..55c4171ed --- /dev/null +++ b/Application/Admin/View/CompanyStatement/showCpStatementList.html @@ -0,0 +1,379 @@ + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ 搜索 +
+ +
+
+ +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
合作公司结算金额操作
aOh! 暂时还没有内容!
{$data.company_name}{$data.statement_money} + 查看 +
+
+ +
+
+ + + + {$_page|default=''} +
+
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + + + + diff --git a/Application/Admin/View/CompanyStatement/showCpStatementView.html b/Application/Admin/View/CompanyStatement/showCpStatementView.html new file mode 100644 index 000000000..32c0701e1 --- /dev/null +++ b/Application/Admin/View/CompanyStatement/showCpStatementView.html @@ -0,0 +1,280 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
结算时间产品联运流水聚合流水流水合计结算比例渠道费率税费费率其他结算金额
aOh! 暂时还没有内容!
{$time}年{$data["time"]}月{$data['statement_info'][0]['game_name']|default="--"}---------------{$data['statement_info'][0]['sum_money']|default="--"}{$data['statement_info'][0]['game_name']|default="--"}{$data['statement_info'][0]['platform_money']|default="--"}{$data['statement_info'][0]['aggregate_money']|default="--"}{$data['statement_info'][0]['sum_amount']|default="--"}{$data['statement_info'][0]['ratio']|default="--"}{$data['statement_info'][0]['promote_ratio']|default="--"}{$data['statement_info'][0]['fax_ratio']|default="--"}{$data['statement_info'][0]['other_amount']|default="--"}{$data['statement_info'][0]['sum_money']|default="--"}
{$statement_info['game_name']|default="--"}---------------{$statement_info['sum_money']|default="--"}
{$statement_info['game_name']|default="--"}{$statement_info['platform_money']|default="--"}{$statement_info['aggregate_money']|default="--"}{$statement_info['sum_amount']|default="--"}{$statement_info['ratio']|default="--"}{$statement_info['promote_ratio']|default="--"}{$statement_info['fax_ratio']|default="--"}{$statement_info['other_amount']|default="--"}{$statement_info['sum_money']|default="--"}
小计--{$sum[$index]['platform_money']}{$sum[$index]['aggregate_money']}{$sum[$index]['sum_amount']}{$sum[$index]['ratio']}{$sum[$index]['promote_ratio']}{$sum[$index]['fax_ratio']}{$sum[$index]['other_amount']}{$sum[$index]['sum_money']}
+
+
+ + + diff --git a/Application/Admin/View/CompanyStatementPool/lists.html b/Application/Admin/View/CompanyStatementPool/lists.html index 2159b014e..9dddb5595 100644 --- a/Application/Admin/View/CompanyStatementPool/lists.html +++ b/Application/Admin/View/CompanyStatementPool/lists.html @@ -542,8 +542,20 @@ layer.close(index); cancelPoolAjax(url,{id:id}); }); - + + }); + + //撤销汇总 + $(".cancelWmPool,.reCount").on("click",function(){ + var id = $(this).data('id'); + var url = "{:U('cancelWmPool')}"; + layer.confirm("撤销汇总/重算都是不可逆操作,请慎重选择",{title:false}, function(index){ + layer.close(index); + cancelPoolAjax(url,{id:id}); + }); + }) + //线下打款 $(".setUlPayment").on("click",function(){ var id = $(this).data('id'); diff --git a/Application/Admin/View/CompanyStatementPool/poolWmStatement.html b/Application/Admin/View/CompanyStatementPool/poolWmStatement.html new file mode 100644 index 000000000..5e0424ff1 --- /dev/null +++ b/Application/Admin/View/CompanyStatementPool/poolWmStatement.html @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ 《{$company_name}》结算单 +
+
+
+
+
+
+
({$statement_begin_time}-{$statement_end_time})
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
结算月份合作产品名称月累计用户充值流水月新增用户数税费费率结算金额(元)
{$list[0]['statement_begin_time']}-{$list[0]['statement_end_time']}{$list[0]['game_name']}{$amount_data['pay_amount']}{$amount_data['user_newcount']}{$amount_data['fax_ratio']}%{$amount_data['sum_money']}
{$it['statement_begin_time']}-{$it['statement_end_time']}{$it['game_name']}
支付金额{:convertAmountToCn($amount_data['sum_money'])}
备注结算金额按每月双方实际核定结算指标为准
甲方{$first_party_info['partner']}乙方{$second_party_info['partner']}
联系人{$first_party_info['link_man']}联系人{$second_party_info['link_man']}
联系电话{$first_party_info['link_phone']}联系电话{$second_party_info['phone']}
开票内容{$first_party_info['invoice_item']}邮寄地址{$second_party_info['address']}
发票类型{$first_party_info['invoice_type']}请汇入此账号
邮寄地址{$first_party_info['address']}户名{$second_party_info['ali_user']}{$second_party_info['bank_address']}
账号{$second_party_info['ali_account']}{$second_party_info['bank_card']}
开户行{$second_party_info['bank_name']}
甲方{$first_party_info['partner']}乙方{$second_party_info['partner']}
联系人{$first_party_info['link_man']}联系人{$second_party_info['link_man']}
联系电话{$first_party_info['link_phone']}联系电话{$second_party_info['phone']}
邮寄地址{$first_party_info['address']}开票内容{$second_party_info['invoice_item']}
请汇入此账号发票类型{$second_party_info['invoice_type']}
户名{$first_party_info['ali_user']}{$first_party_info['bank_address']}邮寄地址{$second_party_info['address']}
账号{$first_party_info['ali_account']}{$first_party_info['bank_card']}
开户行{$first_party_info['bank_name']}
+ +
+
+ + + diff --git a/Application/Admin/View/StatementMangement/addreward.html b/Application/Admin/View/StatementMangement/addreward.html new file mode 100644 index 000000000..19c35b751 --- /dev/null +++ b/Application/Admin/View/StatementMangement/addreward.html @@ -0,0 +1,467 @@ + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + +
本次批次号: +
+
+ 用于检索使用 +
*文件上传: +
+ +
+ 暂只支持.xls .xlsx 格式文件 +
+
+ +
+ + +
+
+
+ 文件格式参考:请严格按此格式,文件的第一行必须是字段名,且字段名不允许修改 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
序号游戏名游戏合作方奖惩时间结算时间奖惩确认时间时间说明奖惩性质奖惩类型结算公司类型结算方会长账号奖惩金额结算方式奖惩类型结算公司类型结算方会长账号奖惩金额结算方式添加人
1九天仙尘广州乐牛软件科技有限公司2021-01-012021-01-012021-01-01私聊非自己的玩家,并发微信给玩家,存在换端的嫌疑,违反平台规则,罚款1500元双向惩罚方下游公司南昌醉游网络科技有限公司ncsywl-1501线上结算奖励方下游公司万盟天下科技kefuguanlian1500线上结算wmtxhh
+
+ + +
+ + + + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + + \ No newline at end of file diff --git a/Application/Admin/View/StatementMangement/rewardManageList.html b/Application/Admin/View/StatementMangement/rewardManageList.html index 827556839..838361b13 100644 --- a/Application/Admin/View/StatementMangement/rewardManageList.html +++ b/Application/Admin/View/StatementMangement/rewardManageList.html @@ -164,6 +164,14 @@ +
+
+ + 奖惩导入 + +
+
+
diff --git a/Data/update.sql b/Data/update.sql index c6a40cc4d..e597752f2 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2792,3 +2792,6 @@ ADD COLUMN `leave_time` int(11) NOT NULL DEFAULT 0 COMMENT '离职时间' AFTER ALTER TABLE `tab_company_statement_info` ADD COLUMN `is_reward_fine_split` tinyint(255) NULL DEFAULT 0 COMMENT '是否是奖罚分离生成 0 否 1 是' AFTER `pay_check_time`; + +ALTER TABLE `platform_wm`.`tab_company_statement_pool` +ADD COLUMN `wm_statement_ids` int(11) NOT NULL DEFAULT 0 COMMENT '子系统财务结算单id' AFTER `remark`; \ No newline at end of file diff --git a/Public/Admin/excel/rewardOrfina.xlsx b/Public/Admin/excel/rewardOrfina.xlsx new file mode 100644 index 000000000..6a149dc05 Binary files /dev/null and b/Public/Admin/excel/rewardOrfina.xlsx differ diff --git a/Public/Admin/excel/wmStatement.xlsx b/Public/Admin/excel/wmStatement.xlsx new file mode 100644 index 000000000..6c5ddef82 Binary files /dev/null and b/Public/Admin/excel/wmStatement.xlsx differ