From 13efc01d3d2350d9c2cf570769fef1c81d3c4c04 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Fri, 31 Jul 2020 10:25:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B4=A2=E5=8A=A1=E6=B1=87?= =?UTF-8?q?=E6=80=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinancialSummarySetController.class.php | 294 +++++++++--------- 1 file changed, 139 insertions(+), 155 deletions(-) diff --git a/Application/Admin/Controller/FinancialSummarySetController.class.php b/Application/Admin/Controller/FinancialSummarySetController.class.php index df5451699..0319cc3ac 100644 --- a/Application/Admin/Controller/FinancialSummarySetController.class.php +++ b/Application/Admin/Controller/FinancialSummarySetController.class.php @@ -145,7 +145,7 @@ class FinancialSummarySetController extends \Think\Controller "sort"=>3, ); $map = array( - "create_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "payed_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']; @@ -201,7 +201,7 @@ class FinancialSummarySetController extends \Think\Controller ->find()['pay_amount']; //获取平台币充值 $map1 = array( - "create_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), "pay_status"=>1 ); if($testlist) $map1['user_id']=array("in",$testlist); @@ -335,169 +335,153 @@ class FinancialSummarySetController extends \Think\Controller } public function setChannelMoney(){ - $r = D("PaymentMerchant")->Ways; - dd($r); - } - - - - - - - - /** - * 获取类型为4,5的数据/按支付渠道类型,支付类型类型 - */ - public function setPayWayMoney() - { - $moneyarry=[ - "wx"=>0, - "zfb"=>0, - "gfzfb"=>0, - "sqzfb"=>0, - "sqkj"=>0, - "ybzf"=>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, '.', '') - ); - $this->adddata[] = array( - "key_name"=>'ybzf_count', - "type"=>4,"sort"=>5, - "sum_money"=>number_format($moneyarry['ybzf']/100, 2, '.', '') - ); - $this->adddata[] = array( - "key_name"=>'ybzf_count', - "type"=>5,"sort"=>4, - "sum_money"=>number_format($moneyarry['ybzf']/100, 2, '.', '') - ); - echo 'success'; + $Channel = D("PaymentMerchant")->Channel; + foreach( $Channel as $k=>&$v){ + $v = 0; + } + $this->getChannelCount($Channel); + foreach( $Channel as $k=>$v){ + $this->adddata[] = array( + "key_name"=>$k, + "type"=>4, + "sort"=>$k, + "sum_money"=>number_format($v/100, 2, '.', '') + ); + } } - //获取spend表 - protected function getSpendPayWay(&$moneyarry){ + //获取Channel + protected function getChannelCount(&$Channel){ $map = array( - "payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), - "pay_status"=>1, - "pay_way"=>array("IN","1,2,3,9,15,17") + "s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "s.pay_status"=>1, + "s.merchant_id"=>["GT","0"] ); - $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, - IFNULL(SUM(CASE WHEN pay_way = 17 THEN pay_amount ELSE 0 END),0) as ybzf_count - ") + $spres=$this->SpendModel + ->alias("s") + ->field("SUM(s.pay_amount) pay_amount,p.channel") ->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; - $moneyarry['ybzf'] += $dbres['ybzf_count']*100; + ->group("p.channel") + ->join("left join tab_payment_merchant p ON p.id = s.merchant_id") + ->select(); + + //超级签 + $ss_map = [ + "s.pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "s.pay_status"=>1 + ]; + $ssres=$this->GameSupersignModel + ->alias("s") + ->field("SUM(s.pay_price) pay_amount,p.channel") + ->join("left join tab_payment_merchant p ON p.id = s.merchant_id") + ->group("p.channel") + ->where($ss_map) + ->select(); + + //玩家购买平台币 + $dp_map =[ + "s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "s.pay_status"=>1 + ]; + $dpres=$this->DepositModel + ->alias("s") + ->field("SUM(s.pay_amount) pay_amount,p.channel") + ->join("left join tab_payment_merchant p ON p.id = s.merchant_id") + ->group("p.channel") + ->where($dp_map) + ->select(); + + //会长充值平台币 + $co_map =[ + "s.pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "s.order_status"=>array("EGT",1) + ]; + $cores=$this->CoinPayOrderModel + ->alias("s") + ->field("SUM(s.pay_amount) pay_amount,p.channel") + ->join("left join tab_payment_merchant p ON p.id = s.merchant_id") + ->group("p.channel") + ->where($co_map) + ->select(); + + $dbres = array_merge($spres,$ssres,$dpres,$cores); + foreach ($dbres as $k=>$v){ + $Channel[$v['channel']] = $Channel[$v['channel']]-0; + $Channel[$v['channel']] += $v['pay_amount']; + } } - //获取超级签购买 - 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, - IFNULL(SUM(CASE WHEN pay_way = 17 THEN pay_price ELSE 0 END),0) as ybzf_count - ") - ->where($map) - ->find(); - $moneyarry['wx'] += $dbres['wx_count']*100; - $moneyarry['gfzfb'] += $dbres['zfb_count']*100; - $moneyarry['ybzf'] += $dbres['ybzf_count']*100; + + public function setPaywayMoney(){ + $Ways = D("PaymentMerchant")->Ways; + foreach( $Ways as $k=>&$v){ + $v = 0; + } + $this->getPaywayCount($Ways); + foreach($Ways as $k=>$v){ + $this->adddata[] = array( + "key_name"=>$k, + "type"=>5, + "sort"=>$k, + "sum_money"=>number_format($v/100, 2, '.', '') + ); + } } - //玩家购买平台币 - protected function getDepositPayWay(&$moneyarry) - { + //获取Channel + protected function getPaywayCount(&$Ways){ $map = array( - "create_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), - "pay_status"=>1, - "pay_way"=>array("IN","1,2,3,9,15,17") + "s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "s.pay_status"=>1, + "s.merchant_id"=>["GT","0"] ); - $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, - IFNULL(SUM(CASE WHEN pay_way = 17 THEN pay_amount ELSE 0 END),0) as ybzf_count - ") + $spres=$this->SpendModel + ->alias("s") + ->field("SUM(s.pay_amount) pay_amount,s.merchant_way") ->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; - $moneyarry['ybzf'] += $dbres['ybzf_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, - IFNULL(SUM(CASE WHEN pay_way = 17 THEN pay_amount ELSE 0 END),0) as ybzf_count - ") - ->where($map) - ->find(); - $moneyarry['wx'] += $dbres['wx_count']*100; - $moneyarry['gfzfb'] += $dbres['zfb_count']*100; - $moneyarry['ybzf'] += $dbres['ybzf_count']*100; + ->group("s.merchant_way") + ->select(); + + //超级签 + $ss_map = [ + "s.pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "s.pay_status"=>1 + ]; + $ssres=$this->GameSupersignModel + ->alias("s") + ->field("SUM(s.pay_price) pay_amount,s.merchant_way") + ->group("s.merchant_way") + ->where($ss_map) + ->select(); + + //玩家购买平台币 + $dp_map =[ + "s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "s.pay_status"=>1 + ]; + $dpres=$this->DepositModel + ->alias("s") + ->field("SUM(s.pay_amount) pay_amount,s.merchant_way") + ->group("s.merchant_way") + ->where($dp_map) + ->select(); + + //会长充值平台币 + $co_map =[ + "s.pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "s.order_status"=>array("EGT",1) + ]; + $cores=$this->CoinPayOrderModel + ->alias("s") + ->field("SUM(s.pay_amount) pay_amount,s.merchant_way") + ->group("s.merchant_way") + ->where($co_map) + ->select(); + + $dbres = array_merge($spres,$ssres,$dpres,$cores); + foreach ($dbres as $k=>$v){ + $Ways[$v['merchant_way']] = $Ways[$v['merchant_way']]-0; + $Ways[$v['merchant_way']] += $v['pay_amount']; + } } + public function addDb() { foreach ($this->adddata as $k=> &$v) {