From 4b63c7b7869f8ce15d2c86ec9669d079e5aeda0a Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Sun, 26 Apr 2020 17:50:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E7=BB=9F=E8=AE=A1bug?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Model/SpendModel.class.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index b53e4173f..e5eb3e061 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -885,16 +885,12 @@ SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count,g.sd public function totalGameStatistics($map, $join = true) { - $noticeFailData = M("Spend s use index(game_time)","tab_") - ->field("SUM(pay_amount) as notice_fail_count,game_id") - ->where(['s.pay_status' => 1, 'pay_game_status' => 0]) - ->where($map) - ->find(); + $query = M("Spend s use index(game_time)","tab_") ->field("SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count, SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count, -SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count"); +SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count,group_concat(s.game_id separator ',') gc_game_id"); if ($join) { $query = $query->join('LEFT JOIN tab_game as g ON s.game_id=g.id') ->join('LEFT JOIN tab_partner as p ON g.partner_id=p.id'); @@ -902,6 +898,15 @@ SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count"); $data = $query->where(['s.pay_status' => 1, 'pay_game_status' => 1]) ->where($map) ->find(); + + $gc_game_id = array_unique(explode(',',$data['gc_game_id'])); + + $noticeFailData = M("Spend s use index(game_time)","tab_") + ->field("SUM(pay_amount) as notice_fail_count,game_id") + ->where(['s.pay_status' => 1, 'pay_game_status' => 0,'game_id'=>['in',$gc_game_id]]) + ->where($map) + ->find(); + $data['notice_fail_count'] = $noticeFailData['notice_fail_count']; // dd($query->_sql()); return $data;