优化推广员充值统计今日本周本月不变

master
chenzhi 5 years ago
parent a61e0f36b5
commit 85b821081f

@ -594,20 +594,18 @@ class PlatformController extends ThinkController
$map1['promote_id'] = $map['promote_id'] = array('egt', 0); $map1['promote_id'] = $map['promote_id'] = array('egt', 0);
$spend = M('Spend', 'tab_'); $spend = M('Spend', 'tab_');
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
$map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; $map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
$pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . (strtotime($_REQUEST['timeend']) + 86399) . " ";
unset($_REQUEST['timestart']); unset($_REQUEST['timestart']);
unset($_REQUEST['timeend']); unset($_REQUEST['timeend']);
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
$map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; $map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
$pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . time() . " ";
unset($_REQUEST['timestart']); unset($_REQUEST['timestart']);
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
$map['create_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; $map['pay_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
$pay_time = " between 0 and " . (strtotime($_REQUEST['timeend']) + 86399) . " ";
unset($_REQUEST['timeend']); unset($_REQUEST['timeend']);
} else { } else {
$pay_time = " between 0 and " . time(); $map['pay_time'] = ['between', array(0, time())];
// $pay_time = " between 0 and " . time();
} }
$map1['pay_status'] = $map['pay_status'] = 1; $map1['pay_status'] = $map['pay_status'] = 1;
$today = total(1); $today = total(1);
@ -628,6 +626,17 @@ class PlatformController extends ThinkController
$pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->where($promote_map2)->find()['acount']; $pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->where($promote_map2)->find()['acount'];
// var_dump( $promote); // var_dump( $promote);
$tweek = total(2,false);
$tmonth = total(3,false);
//获取最小
$tmin = 0;
if($tweek[1][0] < $tmonth[1][0]){
$tmin = $tweek[1][0];
}else{
$tmin = $tmonth[1][0];
}
$data =array(); $data =array();
for ($i=0; $i < count($promote); $i++) { for ($i=0; $i < count($promote); $i++) {
# code... # code...
@ -645,30 +654,29 @@ class PlatformController extends ThinkController
$map['server_name'] = $_REQUEST['server_id']; $map['server_name'] = $_REQUEST['server_id'];
unset($_REQUEST['server_id']); unset($_REQUEST['server_id']);
} }
$dbdata = $spend }
->field(' $dbdata = $spend
floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, ->field('floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count')
floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, ->where($map)
floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, ->find();
floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') $tmap = $map;
->where($map) if(isset($map['pay_time'])){
->where("pay_time".$pay_time) $tmap['pay_time'] = ['between', array($tmin,$tmonth[1][1])];
->find();
$dbdata['promote_account'] = $promote[$i]['account'];
$dbdata['promote_id'] = $promote[$i]['id'];
} else {
$dbdata = $spend
->field('
floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count,
floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today,
floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week,
floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth')
->where($map)
->where("pay_time".$pay_time)
->find();
$dbdata['promote_account'] = $promote[$i]['account'];
$dbdata['promote_id'] = $promote[$i]['id'];
} }
$tdbdata = $spend
->field('
floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today,
floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week,
floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth')
->where($tmap)
->find();
$dbdata['today']= $tdbdata['today'];
$dbdata['week']= $tdbdata['week'];
$dbdata['mounth']= $tdbdata['mounth'];
$dbdata['promote_account'] = $promote[$i]['account'];
$dbdata['promote_id'] = $promote[$i]['id'];
$data[] = $dbdata; $data[] = $dbdata;
} }
$count = count($data); $count = count($data);
@ -812,10 +820,10 @@ class PlatformController extends ThinkController
$data[$key]['today']=$adata['today']==''?0:$adata['today']; $data[$key]['today']=$adata['today']==''?0:$adata['today'];
$data[$key]['week']=$adata['week']==''?0:$adata['week']; $data[$key]['week']=$adata['week']==''?0:$adata['week'];
$data[$key]['mounth']=$adata['mounth']==''?0:$adata['mounth']; */ $data[$key]['mounth']=$adata['mounth']==''?0:$adata['mounth']; */
// if ($data[$key]['promote_id'] == '0') { // if ($data[$key]['promote_id'] == '0') {
// unset($data[$key]); // unset($data[$key]);
// } // }
} }
$total = $this->data_total($data); $total = $this->data_total($data);
$this->assign('total', $total); $this->assign('total', $total);
if ($_REQUEST['data_order'] != '') { if ($_REQUEST['data_order'] != '') {

Loading…
Cancel
Save