diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php
index 52ae4ab44..bf22be7ba 100644
--- a/Application/Admin/Common/extend.php
+++ b/Application/Admin/Common/extend.php
@@ -2135,5 +2135,42 @@ function getPromoteGameRatio($promoteID = 0, $relationGameId = 0, $amount=0, $ti
}
return $ratio;
}
+//验证账号
+function checkAccount($type,$account) {
+
+// $type = I('type');
+// $account = I('account');
+
+ $map = [];
+ $map['account'] = $account;
+
+ if ($type == 1) {
+
+ $result = M('promote','tab_')->field('account')->where($map)->find();
+
+ } else {
+ $result = M('user','tab_')->field('account')->where($map)->find();
+ }
+
+ if ($result) {
+ return 1;
+ } else {
+ return 0;
+ }
+
+ }
+//去重函数
+function a_array_unique($array){
+ $out = array();
+
+ foreach ($array as $key=>$value) {
+ if (!in_array($value, $out)){
+ $out[$key] = $value;
+ }
+ }
+
+ $out = array_values($out);
+ return $out;
+ }
?>
diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php
index 90a5f3ba0..f63370a9f 100644
--- a/Application/Admin/Controller/AjaxController.class.php
+++ b/Application/Admin/Controller/AjaxController.class.php
@@ -469,4 +469,75 @@ class AjaxController extends ThinkController{
}
+ public function addfile()
+ {
+ $this->meta_title = '文档添加';
+ $template = I('t');
+ $template = $template ?: 'Partner/addfile';
+ return $this->display($template);
+ }
+
+ //处理上传图片
+ public function saveFile()
+ {
+ $path = '/Uploads/';
+ $upload = new \Think\Upload();// 实例化上传类
+ $upload->maxSize = 0 ;// 设置附件上传大小
+ $upload->exts = '';// 设置附件上传类型
+ $upload->rootPath = '.'.$path; // 设置附件上传根目录
+ $upload->savePath = ''; // 设置附件上传(子)目录
+ // 上传文件
+ $info = $upload->upload();
+ // dump($info);
+ if(!$info) {// 上传错误提示错误信息
+ $msg = $upload->getError();
+ $array= array('status' => 0, 'info' => $msg);
+ }else{// 上传成功
+ $array=array(
+ "info"=>"上传成功",
+ "status"=>1,
+ "file_path"=>$path.$info['file']['savepath'].$info['file']['savename'],
+ "file_name"=>$_POST['file_name'],
+ "file_type"=>$_FILES['file']['type'],
+ "file_size"=>$_FILES['file']['size'],
+ "upload_time"=>date("Y-m-d H:i:s",time())
+ );
+ }
+ $this->ajaxReturn($array);
+ }
+ //删除图片
+ public function delFile()
+ {
+ $id = $_REQUEST['id'];
+ $index = $_REQUEST['index'] ?: false;
+ $file_path = $_REQUEST['file_path'] ?: false;
+ if($id == 0){
+ //未存入数据库,不用管
+ unlink("./".$file_path);
+ $this->ajaxReturn(array(
+ 'status' => 1,
+ 'info' => "删除成功"
+ ));
+ }
+ # code...
+ }
+
+ /**
+ *获取上下游公司
+ */
+ public function getCompanyList()
+ {
+ $company_type = I('company_type');//公司类型
+ if ($company_type ==1) {//上游公司
+ $data = M('partner','tab_')->field('id, partner as name,1 as type')->where(['status' => 1])->select();
+ } elseif ($company_type ==2) {//下游公司
+ $data = M('promote_company','tab_')->field('id, company_name as name,2 as type')->where(['status' => 1])->select();
+ } else {
+ $partner = M('partner','tab_')->field('id, partner as name,1 as type')->where(['status' => 1])->select();
+ $promote_company = M('promote_company','tab_')->field('id, company_name as name, 2 as type')->where(['status' => 1])->select();
+ $data = array_merge($partner, $promote_company);
+ }
+ $this->ajaxReturn($data);
+ }
+
}
\ No newline at end of file
diff --git a/Application/Admin/Controller/FinancialSummaryController.class.php b/Application/Admin/Controller/FinancialSummaryController.class.php
new file mode 100644
index 000000000..bd39dac4f
--- /dev/null
+++ b/Application/Admin/Controller/FinancialSummaryController.class.php
@@ -0,0 +1,128 @@
+"现金充值收入",
+ "balance_coin_spend"=>"平台币消耗",
+ "balance_coin_income"=>"平台币充值收入",
+ "game_supersign_income"=>"超级签购买收入",
+ "test_user_income"=>"测试收入",
+ "reward_count"=>"奖励",
+ "fine_count"=>"违规处罚",
+ "inside_count"=>"内团",
+ "outer_count"=>"外团",
+ "outer_branch_count"=>"外团-分发",
+ "other_group_count"=>"无归属团",
+ // "inside_count"=>"内团",
+ // "outer_count"=>"外团",
+ "gfwx_count"=>"官方-微信",
+ "gfzfb_count"=>"官方-支付宝",
+ "sqzfb_count"=>"双乾-支付宝",
+ "sqkj_count"=>"双乾-快捷",
+ "wx_count"=>"微信",
+ "zfb_count"=>"支付宝",
+ "kj_count"=>"快捷"
+ );
+ public function _initialize()
+ {
+ parent::_initialize();
+ // echo "
";
+ }
+ public function index($p=1)
+ {
+ if(!array_key_exists("year",$_REQUEST) || !array_key_exists("type",$_REQUEST)){
+ $this->redirect(ACTION_NAME, array('year' => date('Y',time()),"type"=>2));
+ }
+ $this->getYearList();
+ $this->getYearData();
+ $this->display();
+
+ }
+ //获取指定年份数据
+ public function getYearData()
+ {
+ $senddata = array(
+ "income"=>[
+ "count"=>[0,0,0,0,0,0,0,0,0,0,0,0,0]
+ ],
+ "promote"=>[
+ "count"=>[0,0,0,0,0,0,0,0,0,0,0,0,0]
+ ],
+ "channel"=>[
+ "count"=>[0,0,0,0,0,0,0,0,0,0,0,0,0]
+ ],
+ "payway"=>[
+ "count"=>[0,0,0,0,0,0,0,0,0,0,0,0,0]
+ ]
+ );
+ $data = [];
+ //初始化数据
+ foreach ($this->keyname as $k => $v) {
+ $data[$k] = array("name"=>$v,"money"=>[0,0,0,0,0,0,0,0,0,0,0,0,0]);
+ }
+ $map = array(
+ "count_year"=>$_REQUEST['year'],
+ "type"=>array("IN","1,{$_REQUEST['type']},4,5")
+ );
+ $dbres = M("FinancialSummary","tab_")->field("*")->where($map)->select();
+ foreach ($dbres as $k => $v) {
+ if($v['type'] == 1){
+ if(!in_array($v['key_name'],$senddata['income']['list'])){
+ $senddata['income']['list'][] = $v['key_name'];
+ }
+ }
+ if($v['type'] == 4){
+ if(!in_array($v['key_name'],$senddata['channel']['list'])){
+ $senddata['channel']['list'][] = $v['key_name'];
+ }
+ }
+ if($v['type'] == 5){
+ if(!in_array($v['key_name'],$senddata['payway']['list'])){
+ $senddata['payway']['list'][] = $v['key_name'];
+ }
+ }
+ if($v['type'] == $_REQUEST['type']){
+ if(!in_array($v['key_name'],$senddata['promote']['list'])){
+ $senddata['promote']['list'][] = $v['key_name'];
+ }
+ }
+ $data[$v['key_name']]["money"][((int)$v['count_month']-1)] = $v['sum_money'];
+ # code...
+ }
+ foreach ($senddata as $k => $v) {
+ foreach ($v as $ke => $va) {
+ if($ke !='count'){
+ foreach ($va as $key => $val) {
+ for ($i=0; $i < 12; $i++) {
+ $data[$val]["money"][12] += $data[$val]["money"][$i];
+ $senddata[$k]['count'][$i] += $data[$val]["money"][$i];
+ $senddata[$k]['count'][12] +=$data[$val]["money"][$i];
+ }
+ $senddata[$k][$ke][$key] = $data[$val];
+ }
+ }
+
+ }
+ }
+ $this->assign('data', $senddata);
+ }
+ //获取历史年份
+ public function getYearList()
+ {
+ $star = 2019;
+ $end = date("Y",time());
+ $list = [];
+ for ($i=$star; $i <= $end; $i++) {
+ $temp = array(
+ "value"=>$i,
+ "name"=>"{$i}年"
+ );
+ $list[] = $temp ;
+ }
+ $this->assign('YearList', $list);
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/Application/Admin/Controller/FinancialSummarySetController.class.php b/Application/Admin/Controller/FinancialSummarySetController.class.php
new file mode 100644
index 000000000..2f49c500a
--- /dev/null
+++ b/Application/Admin/Controller/FinancialSummarySetController.class.php
@@ -0,0 +1,475 @@
+beginThismonth = mktime(0,0,0,date('m')-1,1,date('Y'));
+ $this->endThismonth = mktime(0,0,0,date('m'),1,date('Y'))-1;
+ $temp = strtotime(date('Y-m-01 00:00:00',strtotime('-1 month')));
+ $this->year= date('Y',$temp);
+ $this->month= date('m',$temp);
+ $this->date = $this->year."-".$this->month;
+ $this->nowdata =time();
+
+ $this->FinancialSummaryModel =M("FinancialSummary",'tab_');
+ $this->DepositModel =M("Deposit",'tab_');
+ $this->SpendModel = M("Spend",'tab_');
+ $this->GameSupersignModel = M("GameSupersign",'tab_');
+ $this->CoinPayOrderModel = M("CoinPayOrder",'tab_');//会长充值平台币表
+
+
+ }
+ /**
+ * 更新某月数据
+ */
+ public function setMonthFinancialSummary($count_date)
+ {
+ $month = $count_date;
+ if(empty($month)) die("参数错误");
+
+ $this->adddata = [];//置空否者会脚本进来会重复计算
+ $this->date = $month;
+ $tarry = explode('-',$month);
+ $this->year= $tarry[0];
+ if(strlen($tarry[1]) < 2) $tarry[1]="0".$tarry[1];
+
+ $this->month= $tarry[1];
+ $this->beginThismonth=mktime(0,0,0,$tarry[1],1,$tarry[0]);
+ $this->endThismonth=mktime(0,0,0,$tarry[1]-0+1,1,$tarry[0])-1;
+ $this->reCount();
+ $this->setFinancialSummary();
+ }
+ /**
+ * 强制重新聚合
+ */
+ public function reCount()
+ {
+ $recount = I("recount");
+ if(empty($recount) || $recount != 1){return ;}
+ # code...
+ //清理之前的聚合
+ $temp =array(
+ "count_year"=>$this->year,
+ "count_month"=>$this->month
+ );
+ $this->FinancialSummaryModel->where($temp)->delete();
+ echo "重置成功执行重新生成:";
+ }
+
+
+ /**
+ * 每个月的统计接口
+ */
+ public function setFinancialSummary()
+ {
+ set_time_limit(0);
+ $t1 = microtime(true);
+ //判断是否已经聚合
+ $countRes = $this->FinancialSummaryModel->field("IFNULL(COUNT(*),0) count")->where("count_year = '{$this->year}' and count_month= '{$this->month}'")->find()['count'];
+ if($countRes > 0){
+ die("error:Repeated statistics,msg:{$this->date}已经聚合过");
+ }
+
+ //按收入类型
+ $this->setIncomeMoney();
+ //按合作方类型
+ $this->setPromoteMoney();
+ //支付渠道/支付类型
+ $this->setPayWayMoney();
+ //存入数据
+ $this->addDb();
+
+ $t2 = microtime(true);
+ echo ("success {$this->date}:ok runtime:".round($t2-$t1,3).'s'.PHP_EOL);
+ }
+ /**
+ * 获取类型为1的数据,按收入类型
+ */
+ public function setIncomeMoney()
+ {
+ $this->getCashAndBalanCoinSpend();
+ $this->getBalanceCoinIncome();
+ $this->getGameSupersignIncome();
+ $this->getTestUserIncome();
+ $this->getRewardRecordIncome();
+ }
+ //现金充值及平台币消耗
+ protected function getCashAndBalanCoinSpend()
+ {
+
+ $map = array(
+ "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "pay_status"=>1
+ );
+ $res = $this->SpendModel
+ ->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count,IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count")
+ ->where($map)
+ ->find();
+ $cash_spend["key_name"] = "cash_spend";
+ $cash_spend["type"] = 1;
+
+ $cash_spend["sort"] = 1;
+ $cash_spend["sum_money"] = $res['cash_count'];
+ $this->adddata[]=$cash_spend;
+
+ $balance_coin_spend["key_name"] = "balance_coin_spend";
+ $balance_coin_spend["type"] = 1;
+ $balance_coin_spend["sort"] = 2;
+ $balance_coin_spend["sum_money"] = $res['balance_coin_count'];
+ $this->adddata[]=$balance_coin_spend;
+ }
+ //平台币充值(deposit/CoinPayOrder)玩家及会长充值的平台币总额
+ protected function getBalanceCoinIncome()
+ {
+ $temparr = array(
+ "key_name"=>'balance_coin_income',
+ "type"=>1,
+ "sort"=>3,
+ );
+ $map = array(
+ "create_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "pay_status"=>1
+ );
+ $temparr['sum_money'] = $this->DepositModel->field("IFNULL(sum(pay_amount),0) pay_amount")->where($map)->find()['pay_amount'];
+ //获取会长充值的平台币
+ $map1= array(
+ "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "order_status"=>array("EGT",1)
+ );
+ $COMoney= $this->CoinPayOrderModel->field("IFNULL(sum(pay_amount),0) pay_amount")->where($map1)->find()['pay_amount'];
+ $temparr['sum_money'] = number_format(($temparr['sum_money']*100+$COMoney*100)/100, 2, '.', '');
+ $this->adddata[]=$temparr;
+ }
+ //超级签购买收入
+ protected function getGameSupersignIncome()
+ {
+ $temparr = array(
+ "key_name"=>'game_supersign_income',
+ "type"=>1,
+ "sort"=>4,
+ );
+ $map = array(
+ "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "pay_status"=>1
+ );
+ $temparr['sum_money'] = $this->GameSupersignModel->field("IFNULL(sum(pay_price),0) pay_price")->where($map)->find()['pay_price'];
+ $this->adddata[]=$temparr;
+ }
+ //测试账号收入
+ protected function getTestUserIncome()
+ {
+ $temparr = array(
+ "key_name"=>'test_user_income',
+ "type"=>1,
+ "sort"=>5
+ );
+ //获取测试白名单
+ $testlist = M("TestWhiteList",'tab_')->field("user_id")->select();
+ if($testlist){
+ $testlist = implode(",",array_column($testlist, 'user_id'));
+ }else{
+ $testlist = false;
+ }
+ //获取现金充值
+ $map = array(
+ "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "pay_status"=>1,
+ "pay_way"=>array("GT",0)
+ );
+ if($testlist) $map['user_id']=array("in",$testlist);
+ $cash_spend = $this->SpendModel
+ ->field("IFNULL(SUM(pay_amount),0) as pay_amount")
+ ->where($map)
+ ->find()['pay_amount'];
+ //获取平台币充值
+ $map1 = array(
+ "create_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "pay_status"=>1
+ );
+ if($testlist) $map1['user_id']=array("in",$testlist);
+ $deposit = $this->DepositModel->field("IFNULL(sum(pay_amount),0) pay_amount")->where($map1)->find()['pay_amount'];
+ $temparr['sum_money'] = number_format(($cash_spend*100+$deposit*100)/100, 2, '.', '');
+ $this->adddata[]=$temparr;
+ }
+ //奖罚收入
+ protected function getRewardRecordIncome()
+ {
+ $map = array(
+ "reward_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ );
+ $rrres = M("RewardRecord","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
+ ")
+ ->where($map)
+ ->find();
+ //奖励负,惩罚正
+ $this->adddata[] = array(
+ "key_name"=>'reward_count',
+ "type"=>1,
+ "sort"=>6,
+ 'sum_money'=>$rrres['reward_count']
+ );
+ $this->adddata[] = array(
+ "key_name"=>'fine_count',
+ "type"=>1,
+ "sort"=>7,
+ 'sum_money'=>$rrres['fine_count']
+ );
+ }
+ /**
+ * 获取类型为2,3的数据/按合作方类型
+ */
+ public function setPromoteMoney()
+ {
+ $map = array(
+ "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "pay_status"=>1
+ );
+ $res = $this->SpendModel
+ ->alias('s')
+ ->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count,
+ IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count,
+ IFNULL(SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END),0) as bind_coin_count,
+ promote.company_belong")
+ ->where($map)
+ ->join("tab_promote promote ON s.promote_id = promote.id", "left")
+ ->group("company_belong")
+ ->select();
+ $inside_count = 0;//内团
+ $outer_count = 0;//外团
+ $outer_branch_count = 0;//外团分发
+ $other_group_count = 0;//其他
+
+
+ $inside_nobind_count = 0;
+ $outer_nobind_count = 0;
+ $outer_branch_nobind_count = 0;
+ $other_group_nobind_count = 0;//其他
+ foreach ($res as $k => $v) {
+ if($v['company_belong'] == 1){
+ $outer_count = $v['cash_count']*100+$v['balance_coin_count']*100+$v['bind_coin_count']*100;
+ $outer_nobind_count = $v['cash_count']*100+$v['balance_coin_count']*100;
+ }elseif($v['company_belong'] == 2){
+ //外团分发
+ $outer_branch_count = $v['cash_count']*100+$v['balance_coin_count']*100+$v['bind_coin_count']*100;
+ $outer_branch_nobind_count = $v['cash_count']*100+$v['balance_coin_count']*100;
+ }elseif($v['company_belong'] == 3){
+ //其他
+ $other_group_count = $v['cash_count']*100+$v['balance_coin_count']*100+$v['bind_coin_count']*100;
+ $other_group_nobind_count = $v['cash_count']*100+$v['balance_coin_count']*100;
+ }else{
+ //有可能存在官方渠道,company_belong=null
+ $inside_count += ($v['cash_count']*100+$v['balance_coin_count']*100+$v['bind_coin_count']*100);
+ $inside_nobind_count += ($v['cash_count']*100+$v['balance_coin_count']*100);
+ }
+ }
+ //处理数据
+ $this->adddata[] = array(
+ "key_name"=>'inside_count',
+ "type"=>2,"sort"=>1,
+ "sum_money"=>number_format($inside_count/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'outer_count',
+ "type"=>2,"sort"=>2,
+ "sum_money"=>number_format($outer_count/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'outer_branch_count',
+ "type"=>2,"sort"=>3,
+ "sum_money"=>number_format($outer_branch_count/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'other_group_count',
+ "type"=>2,"sort"=>4,
+ "sum_money"=>number_format($other_group_count/100, 2, '.', '')
+ );
+ //不含绑定币
+ $this->adddata[] = array(
+ "key_name"=>'inside_count',
+ "type"=>3,"sort"=>1,
+ "sum_money"=>number_format($inside_nobind_count/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'outer_count',
+ "type"=>3,"sort"=>2,
+ "sum_money"=>number_format($outer_nobind_count/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'outer_branch_count',
+ "type"=>3,"sort"=>3,
+ "sum_money"=>number_format($outer_branch_nobind_count/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'other_group_count',
+ "type"=>3,"sort"=>4,
+ "sum_money"=>number_format($other_group_nobind_count/100, 2, '.', '')
+ );
+ }
+ /**
+ * 获取类型为4,5的数据/按支付渠道类型,支付类型类型
+ */
+ public function setPayWayMoney()
+ {
+ $moneyarry=[
+ "wx"=>0,
+ "zfb"=>0,
+ "gfzfb"=>0,
+ "sqzfb"=>0,
+ "sqkj"=>0
+ ];
+ $this->getSpendPayWay($moneyarry);
+ $this->getGameSupersignPayWay($moneyarry);
+ $this->getDepositPayWay($moneyarry);
+ $this->getCoinPayOrderPayWay($moneyarry);
+ //统计数据
+ $moneyarry['zfb'] = ($moneyarry['gfzfb']-0+$moneyarry['sqzfb']);
+ $this->adddata[] = array(
+ "key_name"=>'gfwx_count',
+ "type"=>4,"sort"=>1,
+ "sum_money"=>number_format($moneyarry['wx']/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'gfzfb_count',
+ "type"=>4,"sort"=>2,
+ "sum_money"=>number_format($moneyarry['gfzfb']/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'sqzfb_count',
+ "type"=>4,"sort"=>3,
+ "sum_money"=>number_format($moneyarry['sqzfb']/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'sqkj_count',
+ "type"=>4,"sort"=>4,
+ "sum_money"=>number_format($moneyarry['sqkj']/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'wx_count',
+ "type"=>5,"sort"=>1,
+ "sum_money"=>number_format($moneyarry['wx']/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'zfb_count',
+ "type"=>5,"sort"=>2,
+ "sum_money"=>number_format($moneyarry['zfb']/100, 2, '.', '')
+ );
+ $this->adddata[] = array(
+ "key_name"=>'kj_count',
+ "type"=>5,"sort"=>3,
+ "sum_money"=>number_format($moneyarry['sqkj']/100, 2, '.', '')
+ );
+ }
+ //获取spend表
+ protected function getSpendPayWay(&$moneyarry){
+ $map = array(
+ "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "pay_status"=>1,
+ "pay_way"=>array("IN","1,2,3,9,15")
+ );
+ $dbres=$this->SpendModel
+ ->field("
+ IFNULL(SUM(CASE WHEN pay_way = 2 THEN pay_amount ELSE 0 END),0) as wxsm_count,
+ IFNULL(SUM(CASE WHEN pay_way = 3 THEN pay_amount ELSE 0 END),0) as wxapp_count,
+ IFNULL(SUM(CASE WHEN pay_way = 1 THEN pay_amount ELSE 0 END),0) as zfbgf_count,
+ IFNULL(SUM(CASE WHEN pay_way = 9 THEN pay_amount ELSE 0 END),0) as zfbsq_count,
+ IFNULL(SUM(CASE WHEN pay_way = 15 THEN pay_amount ELSE 0 END),0) as kjsq_count
+ ")
+ ->where($map)
+ ->find();
+ $moneyarry['wx'] += ($dbres['wxsm_count']*100+$dbres['wxapp_count']*100);
+ $moneyarry['gfzfb'] += $dbres['zfbgf_count']*100;
+ $moneyarry['sqzfb'] += $dbres['zfbsq_count']*100;
+ $moneyarry['sqkj'] += $dbres['kjsq_count']*100;
+ }
+ //获取超级签购买
+ protected function getGameSupersignPayWay(&$moneyarry)
+ {
+ $map = array(
+ "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "pay_status"=>1
+ );
+ $dbres=$this->GameSupersignModel
+ ->field("
+ IFNULL(SUM(CASE WHEN pay_way = 2 THEN pay_price ELSE 0 END),0) as wx_count,
+ IFNULL(SUM(CASE WHEN pay_way = 1 THEN pay_price ELSE 0 END),0) as zfb_count
+ ")
+ ->where($map)
+ ->find();
+ $moneyarry['wx'] += $dbres['wx_count']*100;
+ $moneyarry['gfzfb'] += $dbres['zfb_count']*100;
+ }
+ //玩家购买平台币
+ protected function getDepositPayWay(&$moneyarry)
+ {
+ $map = array(
+ "create_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "pay_status"=>1,
+ "pay_way"=>array("IN","1,2,3,9,15")
+ );
+ $dbres=$this->DepositModel
+ ->field("
+ IFNULL(SUM(CASE WHEN pay_way = 2 THEN pay_amount ELSE 0 END),0) as wxsm_count,
+ IFNULL(SUM(CASE WHEN pay_way = 3 THEN pay_amount ELSE 0 END),0) as wxapp_count,
+ IFNULL(SUM(CASE WHEN pay_way = 1 THEN pay_amount ELSE 0 END),0) as zfbgf_count,
+ IFNULL(SUM(CASE WHEN pay_way = 9 THEN pay_amount ELSE 0 END),0) as zfbsq_count,
+ IFNULL(SUM(CASE WHEN pay_way = 15 THEN pay_amount ELSE 0 END),0) as kjsq_count
+ ")
+ ->where($map)
+ ->find();
+ $moneyarry['wx'] += ($dbres['wxsm_count']*100+$dbres['wxapp_count']*100);
+ $moneyarry['gfzfb'] += $dbres['zfbgf_count']*100;
+ $moneyarry['sqzfb'] += $dbres['zfbsq_count']*100;
+ $moneyarry['sqkj'] += $dbres['kjsq_count']*100;
+ }
+ //会长充值平台币
+ protected function getCoinPayOrderPayWay(&$moneyarry)
+ {
+ $map= array(
+ "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
+ "order_status"=>array("EGT",1)
+ );
+ $dbres= $this->CoinPayOrderModel
+ ->field("
+ IFNULL(SUM(CASE WHEN pay_way = 2 THEN pay_amount ELSE 0 END),0) as wx_count,
+ IFNULL(SUM(CASE WHEN pay_way = 1 THEN pay_amount ELSE 0 END),0) as zfb_count
+ ")
+ ->where($map)
+ ->find();
+ $moneyarry['wx'] += $dbres['wx_count']*100;
+ $moneyarry['gfzfb'] += $dbres['zfb_count']*100;
+ }
+ public function addDb()
+ {
+ foreach ($this->adddata as $k=> &$v) {
+ $v["count_month"] = $this->month;
+ $v["count_year"] = $this->year;
+ $v["create_time"] = $this->nowdata;
+ }
+ $res = $this->FinancialSummaryModel->addAll($this->adddata);
+ if(!$res){
+ echo "DB save error";
+ }else{
+
+ }
+ }
+
+}
diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php
index ebedb84e4..e8d1a2579 100644
--- a/Application/Admin/Controller/GameController.class.php
+++ b/Application/Admin/Controller/GameController.class.php
@@ -176,10 +176,10 @@ class GameController extends ThinkController
$downloadWays = $_POST['download_ways'] ?? [];
if (in_array(GameService::DOWNLOAD_BETA, $downloadWays)) {
if (empty($_POST['beta_url'])) {
- return $this->error("请在Beta按钮开启的情况填写Beta链接");
+ return $this->error("请在极速版下载按钮开启的情况填写极速版下载链接");
}
if (!preg_match("/^((https|http|itms-beta)?:\/\/)[^\s]+/i", $_POST['beta_url'])) {
- return $this->error("请填写正确的Beta链接");
+ return $this->error("请填写正确的极速版下载链接");
}
}
$_POST['relation_game_name'] = $_POST['game_name'];
@@ -355,10 +355,10 @@ class GameController extends ThinkController
$downloadWays = $_POST['download_ways'] ?? [];
if (in_array(GameService::DOWNLOAD_BETA, $downloadWays)) {
if (empty($_POST['beta_url'])) {
- return $this->error("请在Beta按钮开启的情况填写Beta链接");
+ return $this->error("请在极速版下载按钮开启的情况填写极速版下载链接");
}
if (!preg_match("/^((https|http|itms-beta)?:\/\/)[^\s]+/i", $_POST['beta_url'])) {
- return $this->error("请填写正确的Beta链接");
+ return $this->error("请填写正确的极速版下载链接");
}
}
/*if($_POST['apply_status']==0&&$_POST['game_status']==1){
diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php
index 37283c3ce..30e95b003 100644
--- a/Application/Admin/Controller/OldCountController.class.php
+++ b/Application/Admin/Controller/OldCountController.class.php
@@ -1,4 +1,5 @@
execute($sql);
+ echo "tab_financial_summary 清空成功".PHP_EOL;
+ //获取19年9月到上个月的所有月份
+ $monthList = $this->getMonthsList();
+ $Financial = new FinancialSummarySetController();
+ foreach ($monthList as $k => $v) {
+ $Financial->setMonthFinancialSummary($v);
+ }
+ }
//超级签订单新增识别微信或者支付宝2019-12-11
public function gameSupersignPaywayInit()
{
@@ -87,5 +102,25 @@ class OldCountController extends \Think\Controller
}
die("init ok");
}
+ //获取公司月结所需要的所有月份截止至上个月
+ public function getMonthsList()
+ {
+ $start_month = "2019-09";
+
+ $temp = strtotime(date('Y-m-01 00:00:00',strtotime('-1 month')));
+ $end_month = date('Y',$temp)."-".date('m',$temp);
+
+ $time_arr = [];
+ $begin = new \DateTime($start_month);
+ $end = new \DateTime($end_month);
+ $end = $end->modify('+1 month');
+ $interval = new \DateInterval('P1M');
+ $daterange = new \DatePeriod($begin, $interval ,$end);
+ foreach($daterange as $date){
+ $time_arr[] = $date->format("Y-m");
+ }
+ return $time_arr;
+ }
+
}
diff --git a/Application/Admin/Controller/PartnerController.class.php b/Application/Admin/Controller/PartnerController.class.php
index 563f7f621..2f96fe607 100644
--- a/Application/Admin/Controller/PartnerController.class.php
+++ b/Application/Admin/Controller/PartnerController.class.php
@@ -62,7 +62,7 @@ class PartnerController extends ThinkController
//获取分页数据
$query = $model->alias('p')
->field("p.partner,p.matche_platform,p.invoice_rate,p.settlement_type,p.bank_account,
- p.opening_bank,p.id,p.contract_start_time,p.contract_end_time,p.remark")
+ p.opening_bank,p.id,p.contract_start_time,p.contract_end_time,p.remark,p.company_type")
->where($map)
->order("id desc");
if($is_export){
@@ -98,9 +98,10 @@ class PartnerController extends ThinkController
->select();
// dd($cp_game_ratio_map);
- $parseGameRadiores = array();
+ $parseGameRadiores = array();//合作方分成比例
foreach ($gameradiores as $key =>$val) {
$val['row'] = 1;
+ $val['my_ratio'] = 100 - $val['ratio'];
if ($val['begin_total_amount'] == 0) {
$val['name'] = '默认比例';
if (isset($parseGameRadiores[$val['game_id']])) {
@@ -115,18 +116,25 @@ class PartnerController extends ThinkController
}
$parseGameRadiores[$val['game_id']][] = $val;
}
-// dd($parseGameRadiores);
+ $myGameRadiores = $parseGameRadiores;//我方分成比例
+ foreach ($myGameRadiores as $key => &$val) {
+ foreach ($val as $k => &$v) {
+ $v['ratio'] = 100 - $v['ratio'];
+ }
+ }
+
$parseGames = array();
foreach ($games as $key =>$val) {
$val['game_ratio'] = $parseGameRadiores[$val['id']];
+ $val['my_game_ratio'] = $myGameRadiores[$val['id']];
if(array_key_exists($val['id'],$parseGameRadiores)){//游戏有比例
$row2 = array_sum(array_column($val['game_ratio'], 'row')) ;
$val['row'] = empty($row2) ? 1: $row2;
} else {
$val["row"] = 1;
}
-
+ $val['original_package_name'] = $val['original_package_name'] ?: '-';
$parseGames[$val['partner_id']][] = $val;
}
@@ -146,15 +154,17 @@ class PartnerController extends ThinkController
} elseif ($value['settlement_type'] == 2) {
$value['settlement_type'] = '月结';
}
-
- $value['contract_time'] = time_format($value['contract_start_time'], 'Y/m/d') . '-' .
- time_format($value['contract_end_time'], 'Y/m/d');
+ $value['company_type'] = $value['company_type'] == 2 ? '个人' : '公司';
+ $contract_start_time = $value['contract_start_time'] ?
+ time_format($value['contract_start_time'], 'Y/m/d') : '-';
+ $contract_end_time = $value['contract_end_time'] ?
+ time_format($value['contract_end_time'], 'Y/m/d') : '-';
+ $value['contract_time'] = $contract_start_time . '-' . $contract_end_time;
$row2 = array_sum(array_column($value['game'], 'row')) ;
$value['row'] = empty($row2) ? 1: $row2;
$parseData[$value['partner_id']][] = $value;
}
$parseData = array_values($parseData);
-
if($is_export){
$this->assign('listData', $parseData[0]);
$this->display("export");
@@ -367,8 +377,12 @@ class PartnerController extends ThinkController
if (empty($data)) {
$this->error('数据异常', U('lists'));
}
- $data['contract_start_time'] = date('Y-m-d', $data['contract_start_time']);
- $data['contract_end_time'] = date('Y-m-d', $data['contract_end_time']);
+ if ($data['contract_start_time']) {
+ $data['contract_start_time'] = date('Y-m-d', $data['contract_start_time']);
+ }
+ if ($data['contract_end_time']) {
+ $data['contract_end_time'] = date('Y-m-d', $data['contract_end_time']);
+ }
$data['channel_rate'] *= 100;//存的是小数,显示百分比
$data['invoice_rate'] *= 100;//存的是小数,显示百分比
// dd($data);
@@ -405,55 +419,6 @@ class PartnerController extends ThinkController
$this->success('删除成功', U('lists'));
}
- public function addfile()
- {
- $this->meta_title = '文档添加';
- return $this->display();
- }
- //处理上传图片
- public function saveFile()
- {
- $path = '/Uploads/';
- $upload = new \Think\Upload();// 实例化上传类
- $upload->maxSize = 0 ;// 设置附件上传大小
- $upload->exts = '';// 设置附件上传类型
- $upload->rootPath = '.'.$path; // 设置附件上传根目录
- $upload->savePath = ''; // 设置附件上传(子)目录
- // 上传文件
- $info = $upload->upload();
- // dump($info);
- if(!$info) {// 上传错误提示错误信息
- $msg = $upload->getError();
- $array= array('status' => 0, 'info' => $msg);
- }else{// 上传成功
- $array=array(
- "info"=>"上传成功",
- "status"=>1,
- "file_path"=>$path.$info['file']['savepath'].$info['file']['savename'],
- "file_name"=>$_POST['file_name'],
- "file_type"=>$_FILES['file']['type'],
- "file_size"=>$_FILES['file']['size'],
- "upload_time"=>date("Y-m-d H:i:s",time())
- );
- }
- $this->ajaxReturn($array);
- }
- //删除图片
- public function delFile()
- {
- $id = $_REQUEST['id'];
- $index = $_REQUEST['index'] ?: false;
- $file_path = $_REQUEST['file_path'] ?: false;
- if($id == 0){
- //未存入数据库,不用管
- unlink("./".$file_path);
- $this->ajaxReturn(array(
- 'status' => 1,
- 'info' => "删除成功"
- ));
- }
- # code...
- }
}
diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php
index 1cc6d854c..29f49cf76 100644
--- a/Application/Admin/Controller/PromoteCompanyController.class.php
+++ b/Application/Admin/Controller/PromoteCompanyController.class.php
@@ -59,6 +59,8 @@ class PromoteCompanyController extends ThinkController
$companyids = implode(',', array_column($companyres, 'id'));
//获取所属会长及其游戏分成
$promotemap['company_id']=["in",$companyids];
+ $promotemap['level'] = 1;
+
$promoteres = M("Promote","tab_")
->field("id,company_id,account,settlement_type")
->where($promotemap)
@@ -177,20 +179,29 @@ class PromoteCompanyController extends ThinkController
if($v['platform_name'] == '' || $v['platform_name'] == "0"){
$v['platform_name'] = "--";
}
- $v["is_sign_contact"] = ($v["is_sign_contact"]=="1" ? "是" :'否');
-
+ $v["is_sign_contact"] = ($v["is_sign_contact"]=="1" ? "是" :'否');
+ $v["company_type"] = ($v["company_type"]=="1" ? "公司" :'个人');
+ $v["company_belong"] = ($v["company_belong"]=="0" ? "内团" : ($v["company_belong"]=="1" ? "外团" : ($v["company_belong"]=="2" ? "外团分发" : '无')));
}
// dd($companyres);
+
+
+ //公司及会长数量统计
+ $companycount = $model->field("id")->where($map)->select();
+ $count = count($companycount);
+ $companyallids = implode(',', array_column($companycount, 'id'));
+ $promotemap['company_id']=["in",$companyallids];
+ $promotecount = M("Promote","tab_")->where($promotemap)->count();
+
+ $this->assign('listData', $companyres);
+ $this->assign('count', $count);
+ $this->assign('promotecount', $promotecount);
if($is_export){
- $this->assign('listData', $companyres);
+ //导出
$this->display("export");
die();
}
- /* 查询记录总数 */
- $count = $model
- ->where($map)
- ->count();
//分页
$parameter['p'] = $page;
$parameter['row'] = $row;
@@ -198,9 +209,7 @@ class PromoteCompanyController extends ThinkController
if ($page) {
$this->assign('_page', $page);
}
-
- $this->assign('listData', $companyres);
- $this->assign('count', $count);
+ //分配其他页面需要参数
$this->assign('promoteList', getPromoteByLevel(1));
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/lists'])->find());
$this->meta_title = '推广公司';
diff --git a/Application/Admin/Controller/StatementMangementController.class.php b/Application/Admin/Controller/StatementMangementController.class.php
index 4cc3d58f8..6ad7ab8af 100644
--- a/Application/Admin/Controller/StatementMangementController.class.php
+++ b/Application/Admin/Controller/StatementMangementController.class.php
@@ -259,7 +259,7 @@ class StatementMangementController extends ThinkController
$item['reward_type_desc'] = $item['reward_type'] == 1 ? "奖励" : "惩罚";
$item['company_type_desc'] = $item['company_type'] == 1 ? "上游公司" : "下游公司";
$item['relation_game_name'] = $games[$item['relation_game_id']];
- $item['reward_time'] = date('Y-m-d H:i:s', $item['reward_time']);
+ $item['reward_time'] = $item['reward_time'] ? date('Y-m-d H:i:s', $item['reward_time']) : '-';
// if ($item['company_type'] == 1) {
// } else {
@@ -294,11 +294,19 @@ class StatementMangementController extends ThinkController
if ($accounts) {
foreach ($accounts as $index => $account) {
- $data['accounts'][] = array_merge(['account'=>$account], ['user_type'=>$user_types[$index]]);
+
+ if (checkAccount($user_types[$index],$account)==1) {
+ $data['accounts'][] = array_merge(['account'=>$account], ['user_type'=>$user_types[$index]]);
+ } else {
+ return $this->error('账号'.$account.'不存在,请重新输入');
+ }
+// $data['accounts'][] = array_merge(['account'=>$account], ['user_type'=>$user_types[$index]]);
}
} else {
$data['accounts'] = [];
}
+ $data['accounts']=a_array_unique($data['accounts']);
+// dump($data['accounts']);die();
$data['accounts'] = json_encode($data['accounts']);
if (!is_numeric(I('money'))) {
return $this->error('请输入正确的金额');
diff --git a/Application/Admin/Controller/TestOrderController.class.php b/Application/Admin/Controller/TestOrderController.class.php
index 5f0957d83..ffda1457e 100644
--- a/Application/Admin/Controller/TestOrderController.class.php
+++ b/Application/Admin/Controller/TestOrderController.class.php
@@ -24,7 +24,7 @@ class TestOrderController extends ThinkController
if (!empty($_REQUEST['server_type'])) {
$map['server_type'] = $_REQUEST['server_type'];
}
- if (!empty($_REQUEST['order_type'])) {
+ if (!empty($_REQUEST['order_type'])||$_REQUEST['order_type'] == '0') {
$map['order_type'] = $_REQUEST['order_type'];
}
if (!empty($_REQUEST['order_no'])) {
diff --git a/Application/Admin/Controller/ToolController.class.php b/Application/Admin/Controller/ToolController.class.php
index 37968f32b..6973bfc81 100644
--- a/Application/Admin/Controller/ToolController.class.php
+++ b/Application/Admin/Controller/ToolController.class.php
@@ -16,6 +16,17 @@ class ToolController extends ThinkController {
$config = I('config');
$data = array('config'=>json_encode($config),'template'=>$_POST['template'],'status'=>$_POST['status']);
$map['name']=$name;
+
+ $day_pay = $config['day_pay_limit'];
+ $month_pay = $config['month_pay_limit'];
+ if(!empty($day_pay) && !empty($month_pay)) {
+ if($month_pay / date('t') > $day_pay) {
+ $this->error('月支付限量较日支付限量过大');
+ } elseif ($month_pay < $day_pay) {
+ $this->error('月支付限量不能小于日支付限量');
+ }
+ }
+
if($_POST['status']==1&&$name=="weixin"){
$map_['name']=array("in",'wei_xin,wei_xin_app,weixin_gf');
M('tool','tab_')->where($map_)->setField('status','0');
diff --git a/Application/Admin/View/FinancialSummary/index.html b/Application/Admin/View/FinancialSummary/index.html
new file mode 100644
index 000000000..a94577f7d
--- /dev/null
+++ b/Application/Admin/View/FinancialSummary/index.html
@@ -0,0 +1,442 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索:
+
+
+
+
+ selected
+ >{$vo.name}
+
+
+
+
+
+ selected
+ >不包含绑币
+ selected
+ >包含绑币
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 按收入类型
+
+
+ 序号 流水类型 1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月 年度合计
+
+
+
+
+
+ {$incomekey}
+ {$income.name}
+
+ {$incomemoney}
+
+
+
+
+ 合计:
+
+ {$incomecount}
+
+
+
+
+
+ 按合作方类型
+
+
+ 序号 流水类型 1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月 年度合计
+
+
+
+
+
+ {$promotekey}
+ {$promote.name}
+
+ {$promotemoney}
+
+
+
+
+ 合计:
+
+ {$promotecount}
+
+
+
+
+
+ 按支付渠道类型
+
+
+ 序号 流水类型 1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月 年度合计
+
+
+
+
+
+ {$channelkey}
+ {$channel.name}
+
+ {$channelmoney}
+
+
+
+
+ 合计:
+
+ {$channelcount}
+
+
+
+
+
+ 支付类型类型
+
+
+ 序号 流水类型 1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月 年度合计
+
+
+
+
+
+ {$paywaykey}
+ {$payway.name}
+
+ {$paywaymoney}
+
+
+
+
+ 合计:
+
+ {$paywaycount}
+
+
+
+
+
+
+
+
+
+
+
+ if(C('COLOR_STYLE')=='blue_color') echo '
+ ';
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Application/Admin/View/Partner/add.html b/Application/Admin/View/Partner/add.html
index f5c1eee72..596e41090 100644
--- a/Application/Admin/View/Partner/add.html
+++ b/Application/Admin/View/Partner/add.html
@@ -61,7 +61,7 @@
开票税点:
-
+ %
@@ -186,7 +186,7 @@
文档管理
-
@@ -244,9 +244,10 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/Application/Admin/View/TestOrder/lists.html b/Application/Admin/View/TestOrder/lists.html
index 6b12f90f8..d54ff84ba 100644
--- a/Application/Admin/View/TestOrder/lists.html
+++ b/Application/Admin/View/TestOrder/lists.html
@@ -192,6 +192,16 @@
+