Merge branch 'feature/fix_work_order' of wmtx/platform into release

修复问题
master
廖金灵 5 years ago committed by Gogs
commit b09ccfc42d

@ -9075,27 +9075,60 @@ class ExportController extends Controller
}
$pdlMap = "";
$weekMap = '';
if ($startTime = I('create_time_start')) {
$startTime = strtotime($startTime);
$pdlMap .= " and pdl.create_time >={$startTime}";
$weekMap .= " and register_time >={$startTime}";
}
if ($endTime = I('create_time_end')) {
$endTime = strtotime($endTime) + 86400;
$pdlMap .= " and pdl.create_time < {$endTime}";
$weekMap .= " and register_time < {$endTime}";
}
if ($startTime = I('create_time_start')) {
$startTime = strtotime($startTime);
$pdlMap .= " and pdl.create_time >={$startTime}";
$weekMap .= " and register_time >={$startTime}";
}
if ($level == PromoteModel::LEVEL_TEAM_MEMBER) {
$beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
$endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
$xlsData = M('promote', 'tab_')->alias('p')
->field('p.id, p.level, p.account, count(u.id) as iosCount, count(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null)) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left')
->join("tab_user u on u.promote_id = p.id and u.device_type=2", 'left')
->field('p.id, p.level, p.account')
->where($map)
->group('p.id')
->select();
if ($xlsData) {
$beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
$endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
if (empty($weekMap)) {
$weekMap = " and register_time between $beginThisweek and $endThisweek";
}
foreach ($xlsData as &$item) {
$item['ioscount'] = M('user', 'tab_')->where('device_type = 2 and promote_id = ' . $item['id'])->count();
$item['weekcount'] = M('user', 'tab_')->where("device_type = 2 and promote_id = {$item['id']}" . $weekMap)->count();
$itemCount = M('package_download_log', 'tab_')->alias('pdl')
->field('count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
->where("promote_id={$item['id']} $pdlMap")->select();
$item['signcount'] = $itemCount[0]['signcount'] ?? 0;
$item['tfcount'] = $itemCount[0]['tfcount'] ?? 0;
$item['supersigncount'] = $itemCount[0]['supersigncount'] ?? 0;
}
// $promoters = M('promote', 'tab_')->alias('p')->field('p.id, p.level, p.account')->where($map)->select();
// $pids = implode(',', array_column($promoters, 'id'));
// $total[0]['ioscount'] = M('user', 'tab_')->where("device_type = 2 and promote_id in ($pids)")->count();
// $total[0]['weekcount'] = M('user', 'tab_')->where("device_type = 2 and promote_id in ($pids)" . $weekMap)->count();
// $totalCount = M('package_download_log', 'tab_')->alias('pdl')
// ->field('count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
// ->where("promote_id in ($pids) $pdlMap")->select();
// $total[0]['signcount'] = $totalCount[0]['signcount'] ?? 0;
// $total[0]['tfcount'] = $totalCount[0]['tfcount'] ?? 0;
// $total[0]['supersigncount'] = $totalCount[0]['supersigncount'] ?? 0;
}
} else {
$xlsData = M('promote', 'tab_')->alias('p')
->field('p.id, p.level, p.account, count(if(p2.level = '.($level+1).', 1, null)) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
@ -9272,7 +9305,7 @@ class ExportController extends Controller
NULL AS total_complete_count
FROM
sys_member u
LEFT JOIN tab_work_order_info i ON i.creator_id = u.uid
JOIN tab_work_order_info i ON i.creator_id = u.uid
WHERE
u.uid in ({$userids})
GROUP BY u.uid

@ -1162,34 +1162,68 @@ class StatisticsController extends ThinkController {
$count = M('promote', 'tab_')->alias('p')->where($map)->count();
$pdlMap = "";
$weekMap = '';
if ($startTime = I('create_time_start')) {
$startTime = strtotime($startTime);
$pdlMap .= " and pdl.create_time >={$startTime}";
$weekMap .= " and register_time >={$startTime}";
}
if ($endTime = I('create_time_end')) {
$endTime = strtotime($endTime) + 86400;
$pdlMap .= " and pdl.create_time < {$endTime}";
$weekMap .= " and register_time < {$endTime}";
}
if ($level == PromoteModel::LEVEL_TEAM_MEMBER) {
$beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
$endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
if (empty($weekMap)) {
$weekMap = " and register_time between $beginThisweek and $endThisweek";
}
$list = M('promote', 'tab_')->alias('p')
->field('p.id, p.level, p.account, count(u.id) as iosCount, count(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null)) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left')
->join("tab_user u on u.promote_id = p.id and u.device_type=2", 'left')
->field('p.id, p.level, p.account')
->where($map)
->page($p, $row)
->group('p.id')
->select();
$total = M('promote', 'tab_')->alias('p')
->field('count(distinct(u.id)) as iosCount, count(distinct(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null))) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left')
->join("tab_user u on u.promote_id = p.id and u.device_type=2")
->where($map)
->select();
if ($list) {
foreach ($list as &$item) {
$item['ioscount'] = M('user', 'tab_')->where('device_type = 2 and promote_id = ' . $item['id'])->count();
$item['weekcount'] = M('user', 'tab_')->where("device_type = 2 and promote_id = {$item['id']}" . $weekMap)->count();
$itemCount = M('package_download_log', 'tab_')->alias('pdl')
->field('count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
->where("promote_id={$item['id']} $pdlMap")->select();
$item['signcount'] = $itemCount[0]['signcount'] ?? 0;
$item['tfcount'] = $itemCount[0]['tfcount'] ?? 0;
$item['supersigncount'] = $itemCount[0]['supersigncount'] ?? 0;
}
$promoters = M('promote', 'tab_')->alias('p')->field('p.id, p.level, p.account')->where($map)->select();
$pids = implode(',', array_column($promoters, 'id'));
$total[0]['ioscount'] = M('user', 'tab_')->where("device_type = 2 and promote_id in ($pids)")->count();
$total[0]['weekcount'] = M('user', 'tab_')->where("device_type = 2 and promote_id in ($pids)" . $weekMap)->count();
$totalCount = M('package_download_log', 'tab_')->alias('pdl')
->field('count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
->where("promote_id in ($pids) $pdlMap")->select();
$total[0]['signcount'] = $totalCount[0]['signcount'] ?? 0;
$total[0]['tfcount'] = $totalCount[0]['tfcount'] ?? 0;
$total[0]['supersigncount'] = $totalCount[0]['supersigncount'] ?? 0;
}
// $list = M('promote', 'tab_')->alias('p')
// ->field('p.id, p.level, p.account, count(u.id) as iosCount, count(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null)) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
// ->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left')
// ->join("tab_user u on u.promote_id = p.id and u.device_type=2", 'left')
// ->where($map)
// ->page($p, $row)
// ->group('p.id')
// ->select();
// $total = M('promote', 'tab_')->alias('p')
// ->field('count(distinct(u.id)) as iosCount, count(distinct(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null))) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
// ->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left')
// ->join("tab_user u on u.promote_id = p.id and u.device_type=2")
// ->where($map)
// ->select();
} else {
$list = M('promote', 'tab_')->alias('p')
->field('p.id, p.level, p.account, count(if(p2.level = '.($level+1).', 1, null)) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
@ -1271,7 +1305,7 @@ class StatisticsController extends ThinkController {
$beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
$endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
$total = M('package_download_log', 'tab_')->alias('pdl')
->field('count(distinct(if(u.device_type=2, 1, null))) as iosCount, count(distinct(if (u.device_type=2 and u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null))) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
->field('count(if(u.device_type=2, 1, null)) as iosCount, count(if (u.device_type=2 and u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null)) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount')
->join('tab_promote p on p.id = pdl.promote_id')
->join('tab_user u on u.id = pdl.user_id', 'left')
->where($map)

@ -403,7 +403,7 @@ class WorkOrderController extends ThinkController
NULL AS total_complete_count
FROM
sys_member u
LEFT JOIN tab_work_order_info i ON i.creator_id = u.uid
JOIN tab_work_order_info i ON i.creator_id = u.uid
WHERE
u.uid in ({$userids})
GROUP BY u.uid

Loading…
Cancel
Save