优化推广员统计

master
chenzhi 4 years ago
parent c91206c176
commit ce90ddf3ad

@ -256,12 +256,7 @@ class PlatformController extends ThinkController
"pay_status"=>1
];
D("Spend")->addSubsiteWhere($map);
if(IS_SUBSITE){
$SpendModel = M("Spend","tab_",SUBSITE_DB);
}else{
$SpendModel = M("Spend","tab_");
}
$Payamount = $SpendModel->field("sum(IF(is_check=1,pay_amount,0)) pay_amount,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select();
$Payamount = SM("Spend","tab_")->field("sum(IF(is_check=1,pay_amount,0)) pay_amount,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select();
if(empty($Payamount)) return ;
foreach ($Payamount as $v) {
$list[$v['paytime']]['payamount'] = $v['pay_amount'];
@ -276,12 +271,7 @@ class PlatformController extends ThinkController
"pay_time"=>["between",$yearMap],
"pay_status"=>1
];
if(IS_SUBSITE){
$SpendModel = M("Spend","tab_",SUBSITE_DB);
}else{
$SpendModel = M("Spend","tab_");
}
$Payamount = $SpendModel->field("sum(IF(is_check=2,pay_amount,0)) pay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select();
$Payamount = SM("Spend","tab_")->field("sum(IF(is_check=2,pay_amount,0)) pay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select();
if(empty($Payamount)) return ;
foreach ($Payamount as $v) {
$list[$v['paytime']]['unpayamount'] = $v['pay_amount'];

Loading…
Cancel
Save