diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index 1e0c5546a..7c1b37dc2 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -138,7 +138,7 @@ class CompanyStatementController extends ThinkController $v["valid"] = "{$v['statement_begin_time']}-{$v['statement_end_time']}"; - $v['withdraw_type_1'] = ($v['withdraw_type'] == 1 ? "月结" :"周结"); + $v['withdraw_type_1'] = ($v['withdraw_type'] == 1 ? "月结" : ($v['withdraw_type'] == 3 ?"特殊补点" : "周结")); $v['withdraw_type_2'] = ($v['withdraw_type'] == 2 ? "补点" :"正常结算"); $v['verify_log'] = json_decode($v['verify_log'], true); @@ -245,10 +245,35 @@ class CompanyStatementController extends ThinkController //上游 $this->display("viewCpStatement"); }else{ - if($dbres["company_type"] == 1){ - $this->display("viewPcStatement"); - }else{ - $this->display("viewPuStatement"); + if ($dbres["withdraw_type"] == 3) { + if($dbres["company_type"] == 1){ + $this->display("viewPcStatement"); + }else{ + + if($dbres['company_type'] == 1) { + $dbres['company_type_str'] = '公司'; + } elseif($dbres['company_type'] == 2){ + $dbres['company_type_str'] = '个人'; + } + + if($dbres['company_belong'] == '0') { + $dbres['company_belong_str'] = '内团'; + } elseif($dbres['company_belong'] == '1') { + $dbres['company_belong_str'] = '外团'; + }elseif($dbres['company_belong'] == '2') { + $dbres['company_belong_str'] = '分发联盟'; + }elseif($dbres['company_belong'] == '3') { + $dbres['company_belong_str'] = '无'; + } + $this->assign('dbres',$dbres); + $this->display("viewPuComplementStatement"); + } + } else { + if($dbres["company_type"] == 1){ + $this->display("viewPcStatement"); + }else{ + $this->display("viewPuStatement"); + } } } @@ -288,21 +313,35 @@ class CompanyStatementController extends ThinkController //上游 $this->display("editCpStatement"); } else { - if($dbres["company_type"] == 1){ - $this->display("editPcStatement"); - }else{ - if($dbres['pay_type'] == 2){ - $payinfo = $dbres['second_party_info']; - $payinfo['type'] = "second_party_info"; + if ($dbres["withdraw_type"] == 3) { + if($dbres["company_type"] == 1){ + $this->display("editPcComplementStatement"); + }else{ + if($dbres['pay_type'] == 2){ + $payinfo = $dbres['second_party_info']; + $payinfo['type'] = "second_party_info"; + }else{ + $payinfo = $dbres['first_party_info']; + $payinfo['type'] = "first_party_info"; + } + $this->assign("payinfo", $payinfo); + $this->display("editPuComplementStatement"); + } + } else { + if($dbres["company_type"] == 1){ + $this->display("editPcStatement"); }else{ - $payinfo = $dbres['first_party_info']; - $payinfo['type'] = "first_party_info"; + if($dbres['pay_type'] == 2){ + $payinfo = $dbres['second_party_info']; + $payinfo['type'] = "second_party_info"; + }else{ + $payinfo = $dbres['first_party_info']; + $payinfo['type'] = "first_party_info"; + } + $this->assign("payinfo", $payinfo); + $this->display("editPuStatement"); } - $this->assign("payinfo", $payinfo); - $this->display("editPuStatement"); } - - } } } @@ -937,14 +976,15 @@ class CompanyStatementController extends ThinkController ->field("relation_game_id,relation_game_name") ->where(['relation_game_id'=>['in',$rvalue]]) ->find(); + $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; $handleData[$_REQUEST['company_id']]['begin_time'][] = strtotime(I('time_start')); $handleData[$_REQUEST['company_id']]['end_time'][] = strtotime(I('time_end')) + 86399; $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $rvalue; $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $game_name['relation_game_name']; - $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$handleRadioMould[$value['relation_game_id']]['ratio']:0; - $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; + $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$rvalue]['ratio']?$handleRadioMould[$rvalue]['ratio']:0; + $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$rvalue]['turnover_ratio']; } } @@ -977,8 +1017,8 @@ class CompanyStatementController extends ThinkController $handleData[$_REQUEST['company_id']]['end_time'][] = $value['begin_time']-1; $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; - $handleData[$_REQUEST['company_id']]['ratio'][] = $gameRatioMould['ratio']?$gameRatioMould['ratio']:0; - $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $gameRatioMould['turnover_ratio']; + $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$handleRadioMould[$value['relation_game_id']]['ratio']:0; + $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; } } @@ -992,8 +1032,8 @@ class CompanyStatementController extends ThinkController $handleData[$_REQUEST['company_id']]['end_time'][] = strtotime(I('time_end'))-86399; $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; - $handleData[$_REQUEST['company_id']]['ratio'][] = $gameRatioMould['ratio']?$gameRatioMould['ratio']:0; - $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $gameRatioMould['turnover_ratio']; + $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$handleRadioMould[$value['relation_game_id']]['ratio']:0; + $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; } } @@ -1006,8 +1046,8 @@ class CompanyStatementController extends ThinkController $handleData[$_REQUEST['company_id']]['end_time'][] = $radioData[$key+1]['begin_time'] - 1; $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; - $handleData[$_REQUEST['company_id']]['ratio'][] = $gameRatioMould['ratio']?$gameRatioMould['ratio']:0; - $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $gameRatioMould['turnover_ratio']; + $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$gameRatioMould['ratio']:0; + $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; } } } @@ -1050,8 +1090,8 @@ class CompanyStatementController extends ThinkController } - $handleData[$key]['begin_time'][$k] = date("Y.m.d",$value['begin_time'][$k]); - $handleData[$key]['end_time'][$k] = date("Y.m.d",$value['end_time'][$k]); + $handleData[$key]['begin_time'][$k] = date("Y-m-d",$value['begin_time'][$k]); + $handleData[$key]['end_time'][$k] = date("Y-m-d",$value['end_time'][$k]); } @@ -1065,8 +1105,9 @@ class CompanyStatementController extends ThinkController public function addSpecialComplementPost( ) { $data = json_decode($_REQUEST['data'],true); -// dump($data);die(); + $withdraw_type = 3; + $statement_data = []; M()->startTrans(); foreach ($data as $key => $value) { @@ -1083,7 +1124,7 @@ class CompanyStatementController extends ThinkController $insert['company_id'] = $value['company_id']; $insert['company_type'] = $company_data['company_type']; $insert['pay_type'] = $company_type['collection']; - $insert['verify_log'] = ''; + $insert['verify_log'] = json_encode(["create_user"=>session('user_auth')['username'],"create_time"=>date("Y-m-d H:i:s")]);; $proCompany_info['id'] = $company_data['id']; $proCompany_info['partner'] =$company_data['company_name']; @@ -1156,28 +1197,93 @@ class CompanyStatementController extends ThinkController $statement_info[$k]['statement_type'] = 0; $statement_info[$k]['fax_ratio'] = $company_data['fax_ratio']; - } + if ($company_data['company_type'] == 2) { - $statement_data['account'] = ''; - $statement_data['game_list'] = $statement_info; + $statement_insert = []; + + $promote_id = M("promote","tab_") + ->field("id") + ->where(['company_id'=>$value['company_id']]) + ->select(); + if ($promote_id) { + $amount_time['promote_id'] = ['in',array_column($promote_id,'id')]; + } else { + $amount_time['promote_id'] = '-1'; + } + $amount_time['tab_spend.pay_status'] = 1; + $amount_time['pay_way'] = ['egt',1]; + + foreach ($statement_info as $k => $v) { + $statement_begin_time = strtotime($v['statement_begin_time']); + $statement_end_time = strtotime($v['statement_end_time']); + $amount_time['_string'] = "payed_time between {$statement_begin_time} and {$statement_end_time} and relation_game_id={$v['relation_game_id']}"; + + $dataAmount = M("spend","tab_") + ->field("pay_amount,relation_game_id,relation_game_name,payed_time,game_type_name,substring_index(substring_index(promote.`chain`,'/',2),'/',-1) promote_id,chain,admin_id") + ->join("left join tab_promote promote on tab_spend.promote_id=promote.id") + ->join("left join tab_game game on tab_spend.game_id=game.id") + ->where($amount_time) + ->select(false); + + $dataAmount = M()->table("({$dataAmount})a") + ->field("a.*,sum(pay_amount) pay_amount,promote.account,member.real_name") + ->join("left join tab_promote promote on promote_id=promote.id") + ->join("left join sys_member member on promote.admin_id=member.uid ") + ->group("promote_id") + ->select(); + + foreach ($dataAmount as $akey => $aval) { + + $game_list['pay_amount'] = $aval['pay_amount']; + $game_list['relation_game_id'] = $aval['relation_game_id']; + $game_list['game_name'] = $aval['relation_game_name']; + $game_list['game_type_name'] = $aval['relation_game_id']; + + $game_list['ratio'] = $v['ratio']; + $game_list['fax_ratio'] = $company_data['fax_ratio']; + $game_list['sum_money'] = number_format(($aval['pay_amount']*($v['ratio']+$v['increment_ratio']))/100,2,'.',''); + $game_list['increment_ratio'] = $v['increment_ratio']; + $game_list['statement_begin_time'] = $v['statement_begin_time']; + $game_list['statement_end_time'] = $v['statement_end_time']; + $game_list['statement_type'] = '0'; + + $statement_data[$aval['account']."-".$aval['real_name']][] = $game_list; +// $statement_insert[] = $statement_data; + } + + } + + foreach ($statement_data as $k => $v) { + + $strKey = explode('-',$k); + + $statement['account'] = $strKey[0]; + $statement['real_name'] = $strKey[1]; + $statement['game_list'] = $v; + + $statement['row'] = count($v); + + $statement_insert[] = $statement; + + } - $insert['statement_info'] = json_encode($statement_data); + $insert['statement_info'] = json_encode($statement_insert); } else { $insert['statement_info'] = json_encode($statement_info); } $is_save = M('company_statement','tab_')->add($insert); - if (!$is_save) { M()->rollback(); $this->ajaxReturn(['status'=>1001]); } } + M()->commit(); $this->ajaxReturn(['status'=>1]); @@ -1186,12 +1292,13 @@ class CompanyStatementController extends ThinkController public function OpAuth($info) { $id = $info['id']; + $withdraw_type = $info['withdraw_type']; $img = $info['ext_field']; $remark = $info['remark']; //原始列表 $opBtn = [ "viewStatement"=>"查看", - "editStatement"=>"编辑", + "editStatement"=>"编辑", "addRemark"=>"新增备注", "editRemark"=>"修改备注", "viewRemark"=>"查看备注", @@ -1211,12 +1318,17 @@ class CompanyStatementController extends ThinkController default: break; } + if(empty($info['remark'])){ //未上传备注 $optist = array_diff($optist, ["editRemark", "viewRemark"]); }else{ $optist = array_diff($optist, ["addRemark"]); } + + if ($withdraw_type == 3) { + $optist = array_diff($optist, ["editStatement"]); + } // $resarr = []; foreach ($optist as $k => $v) { diff --git a/Application/Admin/View/CompanyStatement/editPcComplementStatement.html b/Application/Admin/View/CompanyStatement/editPcComplementStatement.html new file mode 100644 index 000000000..aa7f2bda9 --- /dev/null +++ b/Application/Admin/View/CompanyStatement/editPcComplementStatement.html @@ -0,0 +1,664 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
甲方: +
+ +
+
联系人: + +
联系电话: + +
邮寄地址: + +
公司税号: + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
乙方: +
+ +
+
联系人: + +
联系电话: + +
邮寄地址: + +
公司税号: + +
+
+
+
+
+

支付给:{$data.company_name} + +

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
结算时间产品平台总额(元)补点比例分成比例特殊补点比例结算金额(元)
+ 请先选择生成条件后点击生成对账数据 +
+
+
+
+
+
+ + + + + + + + + + + + + + + +
收款方名称: + +
银行账号: + +
开户行: + +
+
+
+ + + + + + + + + + + +
开票项目: + +
发票类型: +
+ +
+
+
+
+
+
+
+ 确认修改 +
+
+ + + + + + + + + \ No newline at end of file diff --git a/Application/Admin/View/CompanyStatement/editPuComplementStatement.html b/Application/Admin/View/CompanyStatement/editPuComplementStatement.html new file mode 100644 index 000000000..d2439f7c0 --- /dev/null +++ b/Application/Admin/View/CompanyStatement/editPuComplementStatement.html @@ -0,0 +1,666 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
甲方: +
+ +
+
联系人: + +
联系电话: + +
邮寄地址: + +
公司税号: + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
乙方: +
+ +
+
联系人: + +
联系电话: + +
邮寄地址: + +
公司税号: + +
+
+
+
+
+

支付给:{$data.company_name} + +

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
会长账号结算时间产品平台总额(元)补点比例分成比例特殊补点比例结算金额(元)
+ 请先选择生成条件后点击生成对账数据 +
+
+
+
+
+
+ + + + + + + + + + + + + + + +
收款方名称: + +
银行账号: + +
开户行: + +
+
+
+ + + + + + + + + + + +
开票项目: + +
发票类型: +
+ +
+
+
+
+
+
+
+ 确认修改 +
+
+ + + + + + + + + \ No newline at end of file diff --git a/Application/Admin/View/CompanyStatement/viewPuComplementStatement.html b/Application/Admin/View/CompanyStatement/viewPuComplementStatement.html new file mode 100644 index 000000000..157e27e5d --- /dev/null +++ b/Application/Admin/View/CompanyStatement/viewPuComplementStatement.html @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
公司名称: + +
+
+
+ + + + + + + + + + + +
下游类型: + +
下游性质: + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
市场员会长账号产品产品类型结算时间推广流水(元)补点比例分成比例结算金额(元)
{$it['real_name']}{$it['account']}{$it['game_list'][0]['game_name']}{$it['game_list'][0]['game_type_name']}{$it['game_list'][0]['statement_begin_time']}~{$it['game_list'][0]['statement_end_time']}{$it['game_list'][0]['pay_amount']}{$it['game_list'][0]['increment_ratio']}%{$it['game_list'][0]['ratio']}%{$it['game_list'][0]['sum_money']}
{$game_list['game_name']}{$game_list['game_type_name']}{$game_list['statement_begin_time']}~{$game_list['statement_end_time']}{$game_list['pay_amount']}{$game_list['increment_ratio']}%{$game_list['ratio']}%{$game_list['sum_money']}
合计{$data.statement_count.pay_amount}{$data.statement_count.statement_money}
本月分成总金额(人民币大写):{$data.statement_count.big_ratio_money}
+
+
+
+
+ + + + + + + + + + + + +
开户名: + +
开户支行: + +
+
+
+ + + + + + + +
银行卡号: + +
+
+
+ + diff --git a/Application/Admin/View/CompanyStatement/viewSpecialComplement.html b/Application/Admin/View/CompanyStatement/viewSpecialComplement.html index dc83c0ae4..7f3bc7514 100644 --- a/Application/Admin/View/CompanyStatement/viewSpecialComplement.html +++ b/Application/Admin/View/CompanyStatement/viewSpecialComplement.html @@ -215,7 +215,11 @@ - + 合计 + + + +