diff --git a/Application/Admin/Controller/SpendCountSetController.class.php b/Application/Admin/Controller/SpendCountSetController.class.php index 6d8f3709f..2ed4f922c 100644 --- a/Application/Admin/Controller/SpendCountSetController.class.php +++ b/Application/Admin/Controller/SpendCountSetController.class.php @@ -239,19 +239,22 @@ class SpendCountSetController extends \Think\Controller $month = $this->date; $from = " ( - SELECT root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count FROM tab_spend_count WHERE root_id > 0 and count_date='{$month}' group by root_id + SELECT root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) bind_coin_count FROM tab_spend_count WHERE root_id > 0 and count_date='{$month}' group by root_id UNION ALL - SELECT promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count FROM tab_spend_count WHERE parent_id = 0 and count_date='{$month}' group by promote_id + SELECT promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) bind_coin_count FROM tab_spend_count WHERE parent_id = 0 and count_date='{$month}' group by promote_id UNION ALL - SELECT parent_id,parent_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count FROM tab_spend_count WHERE parent_id > 0 and root_id = 0 and count_date='{$month}' group by parent_id + SELECT parent_id,parent_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) bind_coin_count FROM tab_spend_count WHERE parent_id > 0 and root_id = 0 and count_date='{$month}' group by parent_id ) "; $subQueryAll = M()->table($from." a") - ->field('root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count') + ->field('root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(bind_coin_count) bind_coin_count') ->group("a.root_id") // ->having("cash_count > 0 OR balance_coin_count > 0") ->select(); for ($i=0; $i$subQueryAll[$i]['root_id'], "promote_account"=>$subQueryAll[$i]['root_name'], @@ -261,7 +264,8 @@ class SpendCountSetController extends \Think\Controller "root_name"=>'官方渠道', "cash_count"=>$subQueryAll[$i]['cash_count'], "balance_coin_count"=>$subQueryAll[$i]['balance_coin_count'], - "all_count"=>$subQueryAll[$i]['cash_count']-0+$subQueryAll[$i]['balance_coin_count'], + "bind_coin_count"=>$subQueryAll[$i]['bind_coin_count'], + "all_count"=>$subQueryAll[$i]['cash_count']-0+$subQueryAll[$i]['balance_coin_count']-0+$subQueryAll[$i]['bind_coin_count'], "count_date"=>$this->date, "create_time"=>$this->nowdata ); @@ -281,17 +285,20 @@ class SpendCountSetController extends \Think\Controller //获取数据 $from = " ( - SELECT parent_id,parent_name,root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count FROM tab_spend_count WHERE root_id > 0 and count_date='{$month}' group by parent_id + SELECT parent_id,parent_name,root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) bind_coin_count FROM tab_spend_count WHERE root_id > 0 and count_date='{$month}' group by parent_id UNION - SELECT promote_id,promote_account,parent_id,parent_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count FROM tab_spend_count WHERE parent_id >0 and root_id = 0 and count_date='{$month}' group by promote_id + SELECT promote_id,promote_account,parent_id,parent_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) bind_coin_count FROM tab_spend_count WHERE parent_id >0 and root_id = 0 and count_date='{$month}' group by promote_id ) "; $subQueryAll = M()->table($from." a") - ->field('parent_id,parent_name,root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count') + ->field('parent_id,parent_name,root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(bind_coin_count) bind_coin_count') ->group("a.parent_id") // ->having("cash_count > 0 or balance_coin_count > 0 ") ->select(); for ($i=0; $i$subQueryAll[$i]['parent_id'], "promote_account"=>$subQueryAll[$i]['parent_name'], @@ -301,7 +308,8 @@ class SpendCountSetController extends \Think\Controller "root_name"=>'官方渠道', "cash_count"=>$subQueryAll[$i]['cash_count'], "balance_coin_count"=>$subQueryAll[$i]['balance_coin_count'], - "all_count"=>$subQueryAll[$i]['cash_count']-0+$subQueryAll[$i]['balance_coin_count'], + "bind_coin_count"=>$subQueryAll[$i]['bind_coin_count'], + "all_count"=>$subQueryAll[$i]['cash_count']-0+$subQueryAll[$i]['balance_coin_count']-0+$subQueryAll[$i]['bind_coin_count'], "count_date"=>$this->date, "create_time"=>$this->nowdata ); @@ -321,7 +329,7 @@ class SpendCountSetController extends \Think\Controller //获取数据 $from = " ( - SELECT promote_id,promote_account,parent_id,parent_name,root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count FROM tab_spend_count WHERE parent_id > 0 and root_id > 0 and count_date='{$month}' group by promote_id + SELECT promote_id,promote_account,parent_id,parent_name,root_id,root_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) bind_coin_count FROM tab_spend_count WHERE parent_id > 0 and root_id > 0 and count_date='{$month}' group by promote_id ) "; $subQueryAll = M()->table($from." a") @@ -330,6 +338,9 @@ class SpendCountSetController extends \Think\Controller // ->having("cash_count > 0 or balance_coin_count > 0") ->select(); for ($i=0; $i$subQueryAll[$i]['promote_id'], "promote_account"=>$subQueryAll[$i]['promote_account'], @@ -339,7 +350,8 @@ class SpendCountSetController extends \Think\Controller "root_name"=>$subQueryAll[$i]['root_name'], "cash_count"=>$subQueryAll[$i]['cash_count'], "balance_coin_count"=>$subQueryAll[$i]['balance_coin_count'], - "all_count"=>$subQueryAll[$i]['cash_count']-0+$subQueryAll[$i]['balance_coin_count'], + "bind_coin_count"=>$subQueryAll[$i]['bind_coin_count'], + "all_count"=>$subQueryAll[$i]['cash_count']-0+$subQueryAll[$i]['balance_coin_count']-0+$subQueryAll[$i]['bind_coin_count'], "count_date"=>$this->date, "create_time"=>$this->nowdata ); @@ -390,20 +402,20 @@ class SpendCountSetController extends \Think\Controller "parent_id"=>0, "root_id"=>0, "inside_cash_count"=>$inside_cash_count, - "all_count"=>$inside_cash_count, + // "all_count"=>$inside_cash_count, "count_date"=>$this->date, "create_time"=>$this->nowdata ); $tempparentarr=array( "root_id"=>0, "inside_cash_count"=>$inside_cash_count, - "all_count"=>$inside_cash_count, + // "all_count"=>$inside_cash_count, "count_date"=>$this->date, "create_time"=>$this->nowdata ); $temppromotearr=array( "inside_cash_count"=>$inside_cash_count, - "all_count"=>$inside_cash_count, + // "all_count"=>$inside_cash_count, "count_date"=>$this->date, "create_time"=>$this->nowdata ); @@ -516,7 +528,8 @@ class SpendCountSetController extends \Think\Controller "count_date"=>$this->date ); $dbres = M("spend_user_count","tab_")->where($tempmap)->find(); - $savedata = array("inside_cash_count"=>$inside_cash_count-0+$dbres['inside_cash_count'],"all_count"=>$inside_cash_count-0+$dbres['all_count']); + // $savedata = array("inside_cash_count"=>$inside_cash_count-0+$dbres['inside_cash_count'],"all_count"=>$inside_cash_count-0+$dbres['all_count']); + $savedata = array("inside_cash_count"=>$inside_cash_count-0+$dbres['inside_cash_count']); $tempdbres = $this->usermodel->where($tempmap)->save($savedata); if($tempdbres === false){ $this->usermodel->rollback(); @@ -526,13 +539,21 @@ class SpendCountSetController extends \Think\Controller } /** --------以下为设定月份聚合---------- **/ + /** + * @param 现金流水 cash_count 游戏中充值的现金 + * @param 平台币流水 balance_coin_count 游戏中消耗的平台币 + * @param 绑定币流水 bind_coin_count 游戏中绑定币的消耗 + * @param 内充流水 inside_cash_count:(后台发放给玩家平台币-回收平台币 )+ (后台发放绑币给玩家 -回收的绑币) + * @param 平台币充值 balance_coin_deposit + * @return void + */ public function setMonthCount() { $initdata = $this->getMonthInit(); $balance = $this->getBalanceUser(); $bind = $this->getBindUser(); $deposit = $this->getBalanceDeposit(); - $initdata["inside_cash_count"] = $initdata["inside_cash_count"]-0+$balance-0+$bind; + $initdata["inside_cash_count"] = $balance-0+$bind; $initdata["balance_coin_deposit"] = $deposit; $initdata["all_count"] = $initdata["inside_cash_count"]-0+$initdata["cash_count"]-0+$deposit; $initdata["count_date"] = $this->date; @@ -547,7 +568,7 @@ class SpendCountSetController extends \Think\Controller "count_date"=>$this->date, "parent_id"=>0 ); - return M("spend_user_count","tab_")->field("sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count")->where($tempmap)->find(); + return M("spend_user_count","tab_")->field("sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(bind_coin_count) bind_coin_count")->where($tempmap)->find(); } //获取平台币充值流水 protected function getBalanceDeposit() diff --git a/Data/update.sql b/Data/update.sql index 97991b298..1ad199440 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -251,3 +251,10 @@ CREATE TABLE `tab_spend_month_count` ( ALTER TABLE `tab_spend_month_count` MODIFY COLUMN `balance_coin_count` decimal(10,2) NULL DEFAULT 0.00 COMMENT '平台币游戏支付流水' AFTER `cash_count`, ADD COLUMN `balance_coin_deposit` decimal(10,2) NULL DEFAULT 0.00 COMMENT '平台币充值流水' AFTER `balance_coin_count`; + +-- 2019-11-05 chenzhi +ALTER TABLE `tab_spend_month_count` +ADD COLUMN `bind_coin_count` decimal(10,2) NULL DEFAULT 0.00 COMMENT '绑币消耗' AFTER `balance_coin_deposit`; + +ALTER TABLE `tab_spend_user_count` +ADD COLUMN `bind_coin_count` decimal(10,2) NULL DEFAULT 0.00 COMMENT '绑定币消耗' AFTER `balance_coin_count`; \ No newline at end of file