From cd427a940972d126fbd741e0c30d5b997e72f2c9 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 9 Jan 2020 14:29:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B7=BB=E5=8A=A0cp=E4=B8=8A?= =?UTF-8?q?=E6=B8=B8=E5=AF=B9=E8=B4=A6=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/StatementController.class.php | 211 +++++ .../View/Statement/createCpStatement.html | 793 ++++++++++++++++++ Data/update.sql | 24 +- 3 files changed, 1027 insertions(+), 1 deletion(-) create mode 100644 Application/Admin/Controller/StatementController.class.php create mode 100644 Application/Admin/View/Statement/createCpStatement.html diff --git a/Application/Admin/Controller/StatementController.class.php b/Application/Admin/Controller/StatementController.class.php new file mode 100644 index 000000000..4219e588f --- /dev/null +++ b/Application/Admin/Controller/StatementController.class.php @@ -0,0 +1,211 @@ + 0, + "partner" => "海南万盟天下科技有限公司", + "link_man" => "雷丽华", + "link_phone" => "13067391751", + "address" => "福建省福州市鼓楼区福大怡山创业园区11号103", + "company_tax_no" => "1243245", + "payee_name" => "雷丽华", + "bank_account" => "1654654564364635456", + "opening_bank" => "福州市福大分行" + ); + //创建 + public function createCpStatement() + { + $this->display(); + //获取cp推广公司 + + } + //获取推广公司基础信息 + public function getCpCompanyInfo() + { + $CompanyId = $_REQUEST['company_id']; + if($CompanyId == 0){ + $info = $this->mycompany; + }else{ + $info = M("partner","tab_")->where("id = '{$CompanyId}'")->find(); + } + + if(empty($info)){ + $this->ajaxReturn(array("error"=>"no find","code"=>2000)); + }else{ + $this->ajaxReturn(array("success"=>$info,"code"=>0)); + } + + } + //按时间-公司id-获取订单及分成比例 + public function getSpendStatement() + { + $map["pay_status"] = 1; + + $CompanyId = $_REQUEST['company_id']; //对账公司id + $statement_type = $_REQUEST['statement_type']; + + $is_month = false;//是否是月结判断 + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { + //判断是否是月结 + $tm = explode('-',$_REQUEST['time_start']); + $en = mktime(0,0,0,$tm[1]-0+1,1,$tm[0])-1; //当月最后一天时间戳 + $en2 = strtotime($_REQUEST['time_end']) + 86399; //上传的订单时间 + if($tm[2] == 1 && $en == $en2){ + $is_month = true; + } + $map['pay_time'] = ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]]; + } + + //获取对应cp公司的游戏 + $game_list = M("game","tab_")->field("id")->where("partner_id = '{$CompanyId}'")->select(); + if($game_list){ + $map['game_id'] = ['in', implode(',', array_column($game_list,'id'))]; + } + //获取统计 + $list = M("Spend","tab_")->field('sum(pay_amount) pay_amount,game_id,game_name')->where($map)->group('game_id')->select(); + $CpGameRatio = M("CpGameRatio","tab_"); + $countarr = array( + "pay_amount"=>0, + "sum_money"=>0 + ); + foreach($list as $k=>&$v){ + $map = array( + "game_id"=>$v['game_id'], + "begin_total_amount"=>0, + ); + if($is_month){ + $map['begin_total_amount'] = array("ELT",$v['pay_amount']); + }; + $ratiores = $CpGameRatio->where($map)->order("begin_total_amount desc")->limit(1)->select(); + if(empty($ratiores)){ + $redio = 0; + }else{ + $redio = $ratiores[0]['ratio']; + } + $v['second_ratio'] = $redio; + $v['first_ratio'] = (100-$redio); + if($statement_type == 0){ + $v['sum_money'] = round($v['pay_amount']*$v['first_ratio']/100,2); + }else{ + $v['sum_money'] = round($v['pay_amount']*$v['second_ratio']/100,2); + } + + $countarr['pay_amount'] += $v['pay_amount']; + $countarr['sum_money'] += $v['sum_money']; + $v['fax_ratio'] = 0; + $v['promote_ratio'] = 0; + $v['statement_begin_time']=$_REQUEST['time_start']; + $v['statement_end_time']=$_REQUEST['time_end']; + $v['statement_type']=0; + } + $countarr['pay_amount'] = round($countarr['pay_amount'],2); + $countarr['sum_money'] = round($countarr['sum_money'],2); + + $this->ajaxReturn(array("success"=>$list,"count"=>$countarr,"code"=>0)); + + } + //添加数据 + public function doAddCpStatement(){ + $second_party_info = $_REQUEST['second_party_info']; + $statement_info = $_REQUEST['statement_info']; + $statement_info[] = array( + "sum_money"=>$_REQUEST['fine'], + "type_name"=>"罚款", + "statement_type"=>1 + ); + //拼凑数据 + $adddata = array( + "statement_type"=>0, + "company_id"=>$second_party_info['id'], + "company_name"=>$second_party_info['partner'], + "link_phone"=>$second_party_info['link_phone'], + "statement_begin_time"=>strtotime($_REQUEST['statement_begin_time']), + "statement_end_time"=>strtotime($_REQUEST['statement_end_time']), + 'create_time'=>time(), + "statement_money"=>$_REQUEST['statement_count']['sum_money'], + "pay_amount"=>$_REQUEST['statement_count']['pay_amount'], + "is_confirm"=>0, + "pay_type"=>$_REQUEST['statement_type'] == 0 ? 1 :0, + "first_party_info"=>json_encode($_REQUEST['first_party_info'],JSON_UNESCAPED_UNICODE), + "second_party_info"=>json_encode($_REQUEST['second_party_info'],JSON_UNESCAPED_UNICODE), + "statement_info"=>json_encode($statement_info,JSON_UNESCAPED_UNICODE) + ); + $res = M("statement","tab_")->add($adddata); + if($res){ + $this->ajaxReturn(array("success"=>"ok","code"=>0)); + }else{ + $this->ajaxReturn(array("error"=>"database error","code"=>2000)); + } + + + } + //测试数据 + public function testData() + { + $mycompany = array( + "id" => 0, + "partner" => "甲方海南万盟天下科技有限公司", + "link_man" => "雷丽华", + "link_phone" => "13067391751", + "address" => "福建省福州市鼓楼区福大怡山创业园区11号103", + "company_tax_no" => "1243245", + "payee_name" => "雷丽华", + "bank_account" => "1423134654531321564561636", + "opening_bank" => "福州市福大分行" + ); + $cpcompany = array( + "id" => 1, + "partner" => "乙方海南万盟天下科技有限公司", + "link_man" => "乙方雷丽华", + "link_phone" => "13067391752", + "address" => "福建省福州市鼓楼区福大怡山创业园区11号103", + "company_tax_no" => "1243245445646", + "payee_name" => "乙方王大锤", + "bank_account" => "2343254353462332423", + "opening_bank" => "福州市鼓楼区分行" + ); + $statement =array( + array( + "pay_amount"=>10000, + "game_id"=>77, + "game_name"=>"帝王的纷争(安卓版)", + "second_ratio"=>40, + "first_ratio"=>60, + "promote_ratio"=>1, + "fax_ratio"=>1, + "sum_money"=>5880.6, + "statement_begin_time"=>"2019-11-01", + "statement_end_time"=>"2019-11-30", + "statement_type"=>0 + ), + array( + "sum_money"=>2000, + "type_name"=>"罚款", + "statement_type"=>1 + ) + ); + $arr = array( + "statement_type"=>0, + "company_id"=>3, + "company_name"=>'福州品象网络科技有限公司', + "link_phone"=>'18959188422', + "statement_begin_time"=>'1572537600', + "statement_end_time"=>'1575129599', + 'create_time'=>'1578397556', + "statement_money"=>3880.6, + "is_confirm"=>0, + "pay_type"=>0, + "first_party_info"=>json_encode($mycompany,JSON_UNESCAPED_UNICODE), + "second_party_info"=>json_encode($cpcompany,JSON_UNESCAPED_UNICODE), + "statement_info"=>json_encode($statement,JSON_UNESCAPED_UNICODE) + ); + $res = M("statement","tab_")->add($arr); + dd($res); + } + +} diff --git a/Application/Admin/View/Statement/createCpStatement.html b/Application/Admin/View/Statement/createCpStatement.html new file mode 100644 index 000000000..1518cc5c8 --- /dev/null +++ b/Application/Admin/View/Statement/createCpStatement.html @@ -0,0 +1,793 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+ 海南万盟天下科技有限公司 +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
甲方: +
+ +
+
联系人: + +
联系电话: + +
邮寄地址: + +
公司税号: + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
乙方: +
+ +
+
联系人: + +
联系电话: + +
邮寄地址: + +
公司税号: + +
+
+
+
+
+

支付给:

+
+
+ +
+
+
+
+

请选择需要生成结算订单的月份:

+
+
+ +  -  +
+ + +
+
+
+ 生成 +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
结算时间产品平台总额分成比例渠道费率税费费率结算金额
甲方乙方结算金额=平台总额*(1-渠道费)*分成比例*(1-税费费率)
+ 请先选择生成条件后点击生成对账数据 +
+
+
+
+
+ + + + + + + + + + + + + + + +
收款方名称: + +
银行账号: + +
开户行: + +
+
+
+ + + + + + + + + + + + + + + +
付款方名称: + +
银行账号: + +
开户行: + +
+
+
+
+ +
+ + + + + + + + diff --git a/Data/update.sql b/Data/update.sql index 0556fbc7d..f8d93b7b5 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -946,6 +946,28 @@ CREATE TABLE `tab_promote_belong` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='推广公会归属管理'; - +-- cp/公会对账单 2020-1-7 陈志 +CREATE TABLE `tab_statement` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键', + `statement_type` tinyint(2) DEFAULT '0' COMMENT '对账类型(0-上游对账单;1-下游对账单)', + `company_id` int(11) DEFAULT '0' COMMENT '对账公司id', + `company_name` varchar(60) NOT NULL COMMENT '对账公司名称', + `link_phone` varchar(24) DEFAULT NULL COMMENT '对账公司联系人电话', + `statement_begin_time` int(11) NOT NULL DEFAULT '0' COMMENT '对账开始时间', + `statement_end_time` int(11) NOT NULL DEFAULT '0' COMMENT '对账截止时间', + `create_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 '平台金额合计(已减罚款)', + `is_confirm` tinyint(2) DEFAULT '0' COMMENT '是否确认(0-未确认;1-确认)', + `pay_type` tinyint(2) DEFAULT '0' COMMENT '收款方(0-甲方付给乙方,乙方收款;1-乙方付给甲方,甲方收款)', + `ext_field` varchar(50) DEFAULT '' COMMENT '扩展字段,如果是下游为提现单号', + `first_party_info` longtext NOT NULL COMMENT '甲方相关信息json', + `second_party_info` longtext NOT NULL COMMENT '乙方相关信息json', + `statement_info` longtext NOT NULL COMMENT '订单相关信息json', + PRIMARY KEY (`id`), + KEY `statement_type` (`statement_type`), + KEY `company_id` (`company_id`), + KEY `link_phone` (`link_phone`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='cp/公会对账单';