@ -305,6 +305,7 @@ class SpendCountSetController extends \Think\Controller
$this->getRootUser();
$this->getParentUser();
$this->getPromoteUser();
$this->getInsideData2();
}
/** --------以下为辅助函数--------- **/
@ -315,17 +316,17 @@ 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,inside_cash_count FROM tab_spend_count WHERE root_id > 0 and count_date='{$month}' group by root_id
UNION
SELECT promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,inside_cash_count FROM tab_spend_count WHERE parent_id = 0 and count_date='{$month}' group by promote_id
UNION
SELECT parent_id,parent_name,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,inside_cash_count FROM tab_spend_count WHERE parent_id > 0 and root_id = 0 and count_date='{$month}' group by parent_id
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
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
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
@ -352,16 +353,15 @@ 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,inside_cash_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 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,inside_cash_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 FROM tab_spend_count WHERE parent_id >0 and root_id = 0 and count_date='{$month}' group by promote_id
@ -389,14 +388,13 @@ 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,inside_cash_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 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('*')
// ->limit(1)
->group("a.promote_id")
->having("cash_count > 0 or balance_coin_count > 0 or inside_cash_count > 0")
// ->having("cash_count > 0 or balance_coin_count > 0")
->select();
for ($i=0; $i<count($subQueryAll);$i++){
$adddata = array(
@ -408,8 +406,7 @@ class SpendCountSetController extends \Think\Controller
@ -417,5 +414,63 @@ class SpendCountSetController extends \Think\Controller
}
# code...
}
//处理inside_cash_count
public function getInsideData2()
{
$insideRes = M()
->table("tab_deposit deposit")
->field("promote_id,promote_account,IFNULL(promote.parent_id,0) parent_id,parent_name,sum(pay_amount) inside_cash_count,'{$this->date}' as count_date,'{$this->nowdata}' as create_time")