master
ELF 5 years ago
parent e020b09e4d
commit fc73d458c9

@ -21,10 +21,21 @@ class PromoteRepository {
/**
* 获取指定推广员底下的角色创建数
*/
public function getCreateRoleCountByIds(array $ids, $params)
public function getCreateRoleCountByIds(array $ids, array $params = [])
{
if (count($ids) == 0) {
return [];
}
$isContainSubs = false;
if (isset($params['isContainSubs']) && $params['isContainSubs']) {
$isContainSubs = true;
}
$map = [];
$map['id'] = ['in', $ids];
$map['promote_id'] = ['in', $ids];
if ($isContainSubs) {
$map['promote_id'] = ['in', array_merge($ids, array_keys($params['basicPromotes']))];
}
if (isset($params['begin_time']) && isset($params['begin_time'])) {
$map['create_time'] = ['between', [$params['begin_time'], $params['end_time']]];
}
@ -37,12 +48,18 @@ class PromoteRepository {
if (isset($params['sdk_version'])) {
$map['sdk_version'] = $params['sdk_version'];
}
$items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->groupBy('promote_id')->select();
$items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select();
$records = [];
foreach ($items as $item) {
$records[$item['promote_id']] = $item['count'];
$promoteId = $item['promote_id'];
if (isset($params['basicPromotes'][$item['promote_id']])) {
$promoteId = $params['basicPromotes'][$item['promote_id']];
}
if (isset($records[$promoteId])) {
$records[$promoteId] += $item['count'];
} else {
$records[$promoteId] = $item['count'];
}
}
$records = $this->assembleZero($ids, $records, 0);
@ -53,10 +70,20 @@ class PromoteRepository {
/**
* 获取指定推广员底下的角色创建的用户数
*/
public function getCreateRoleUserCountByIds($ids, $beginTime, $endTime)
public function getCreateRoleUserCountByIds(array $ids, array $params = [])
{
if (count($ids) == 0) {
return [];
}
$isContainSubs = false;
if (isset($params['isContainSubs']) && $params['isContainSubs']) {
$isContainSubs = true;
}
$map = [];
$map['id'] = ['in', $ids];
$map['promote_id'] = ['in', $ids];
if ($isContainSubs) {
$map['promote_id'] = ['in', array_merge($ids, array_keys($params['basicPromotes']))];
}
if (isset($params['begin_time']) && isset($params['begin_time'])) {
$map['create_time'] = ['between', [$params['begin_time'], $params['end_time']]];
}
@ -69,11 +96,19 @@ class PromoteRepository {
if (isset($params['sdk_version'])) {
$map['sdk_version'] = $params['sdk_version'];
}
$items = M('user_play_info', 'tab_')->field(['count(distinct user_id) count', 'promote_id'])->where($map)->groupBy('promote_id')->select();
$items = M('user_play_info', 'tab_')->field(['count(distinct user_id) count', 'promote_id'])->where($map)->group('promote_id')->select();
$records = [];
foreach ($items as $item) {
$records[$item['promote_id']] = $item['count'];
$promoteId = $item['promote_id'];
if (isset($params['basicPromotes'][$item['promote_id']])) {
$promoteId = $params['basicPromotes'][$item['promote_id']];
}
if (isset($records[$promoteId])) {
$records[$promoteId] += $item['count'];
} else {
$records[$promoteId] = $item['count'];
}
}
$records = $this->assembleZero($ids, $records, 0);
@ -82,25 +117,49 @@ class PromoteRepository {
}
/**
*
* 获取指定推广员底下的新创角设备数
*/
public function getCreateRoleDeviceCountByIds($ids, $beginTime, $endTime)
public function getNewCreateRoleDeviceCountByIds(array $ids, array $params = [])
{
$records = $this->assembleZero($ids, [], 0);
return $records;
}
public function getCreateRoleIpCountByIds($ids, $beginTime, $endTime)
/**
* 获取指定推广员底下的新创角IP数
*/
public function getNewCreateRoleIpCountByIds(array $ids, array $params = [])
{
$records = $this->assembleZero($ids, [], 0);
return $records;
}
/**
* 获取指定推广员底下的新创角用户数
*/
public function getNewCreateRoleUserCountByIds(array $ids, array $params = [])
{
$records = $this->assembleZero($ids, [], 0);
return $records;
}
/**
* 获取指定推广员底下的登录用户数
*/
public function getLoginUserCountByIds($ids, $beginTime, $endTime)
public function getLoginUserCountByIds(array $ids, array $params = [])
{
if (count($ids) == 0) {
return [];
}
$isContainSubs = false;
if (isset($params['isContainSubs']) && $params['isContainSubs']) {
$isContainSubs = true;
}
$map = [];
$map['id'] = ['in', $ids];
$map['promote_id'] = ['in', $ids];
if ($isContainSubs) {
$map['promote_id'] = ['in', array_merge($ids, array_keys($params['basicPromotes']))];
}
if (isset($params['begin_time']) && isset($params['begin_time'])) {
$map['login_time'] = ['between', [$params['begin_time'], $params['end_time']]];
}
@ -113,11 +172,19 @@ class PromoteRepository {
if (isset($params['sdk_version'])) {
$map['sdk_version'] = $params['sdk_version'];
}
$items = M('user', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->groupBy('promote_id')->select();
$items = M('user', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select();
$records = [];
foreach ($items as $item) {
$records[$item['promote_id']] = $item['count'];
$promoteId = $item['promote_id'];
if (isset($params['basicPromotes'][$item['promote_id']])) {
$promoteId = $params['basicPromotes'][$item['promote_id']];
}
if (isset($records[$promoteId])) {
$records[$promoteId] += $item['count'];
} else {
$records[$promoteId] = $item['count'];
}
}
$records = $this->assembleZero($ids, $records, 0);
@ -128,9 +195,19 @@ class PromoteRepository {
/**
* 获取指定推广员底下的充值次数
*/
public function getRechargeCountByIds($ids, $beginTime, $endTime)
public function getRechargeCountByIds(array $ids, array $params = [])
{
$map = ['pay_status' => 1, 'id' => ['in', $ids]];
if (count($ids) == 0) {
return [];
}
$isContainSubs = false;
if (isset($params['isContainSubs']) && $params['isContainSubs']) {
$isContainSubs = true;
}
$map = ['pay_status' => 1, 'promote_id' => ['in', $ids]];
if ($isContainSubs) {
$map['promote_id'] = ['in', array_merge($ids, array_keys($params['basicPromotes']))];
}
if (isset($params['begin_time']) && isset($params['begin_time'])) {
$map['pay_time'] = ['between', [$params['begin_time'], $params['end_time']]];
}
@ -144,11 +221,19 @@ class PromoteRepository {
$map['sdk_version'] = $params['sdk_version'];
}
$items = M('spend', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->groupBy('promote_id')->select();
$items = M('spend', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select();
$records = [];
foreach ($items as $item) {
$records[$item['promote_id']] = $item['count'];
$promoteId = $item['promote_id'];
if (isset($params['basicPromotes'][$item['promote_id']])) {
$promoteId = $params['basicPromotes'][$item['promote_id']];
}
if (isset($records[$promoteId])) {
$records[$promoteId] += $item['count'];
} else {
$records[$promoteId] = $item['count'];
}
}
$records = $this->assembleZero($ids, $records, 0);
@ -159,9 +244,19 @@ class PromoteRepository {
/**
* 获取指定推广员底下的充值用户数
*/
public function getRechargeUserCountByIds($ids, $beginTime, $endTime)
public function getRechargeUserCountByIds(array $ids, array $params = [])
{
$map = ['pay_status' => 1, 'id' => ['in', $ids]];
if (count($ids) == 0) {
return [];
}
$isContainSubs = false;
if (isset($params['isContainSubs']) && $params['isContainSubs']) {
$isContainSubs = true;
}
$map = ['pay_status' => 1, 'promote_id' => ['in', $ids]];
if ($isContainSubs) {
$map['promote_id'] = ['in', array_merge($ids, array_keys($params['basicPromotes']))];
}
if (isset($params['begin_time']) && isset($params['begin_time'])) {
$map['pay_time'] = ['between', [$params['begin_time'], $params['end_time']]];
}
@ -174,11 +269,19 @@ class PromoteRepository {
if (isset($params['sdk_version'])) {
$map['sdk_version'] = $params['sdk_version'];
}
$items = M('spend', 'tab_')->field(['count(distinct user_id) count', 'promote_id'])->where($map)->groupBy('promote_id')->select();
$items = M('spend', 'tab_')->field(['count(distinct user_id) count', 'promote_id'])->where($map)->group('promote_id')->select();
$records = [];
foreach ($items as $item) {
$records[$item['promote_id']] = $item['count'];
$promoteId = $item['promote_id'];
if (isset($params['basicPromotes'][$item['promote_id']])) {
$promoteId = $params['basicPromotes'][$item['promote_id']];
}
if (isset($records[$promoteId])) {
$records[$promoteId] += $item['count'];
} else {
$records[$promoteId] = $item['count'];
}
}
$records = $this->assembleZero($ids, $records, 0);
@ -186,9 +289,22 @@ class PromoteRepository {
return $records;
}
public function getRechargeAmountByIds($ids, $beginTime, $endTime)
/**
* 获取指定推广员底下的充值金额(分类型)
*/
public function getRechargeAmountByIds(array $ids, array $params = [])
{
$map = ['pay_status' => 1, 'id' => ['in', $ids]];
if (count($ids) == 0) {
return [];
}
$isContainSubs = false;
if (isset($params['isContainSubs']) && $params['isContainSubs']) {
$isContainSubs = true;
}
$map = ['pay_status' => 1, 'promote_id' => ['in', $ids]];
if ($isContainSubs) {
$map['promote_id'] = ['in', array_merge($ids, array_keys($params['basicPromotes']))];
}
if (isset($params['begin_time']) && isset($params['begin_time'])) {
$map['pay_time'] = ['between', [$params['begin_time'], $params['end_time']]];
}
@ -201,21 +317,39 @@ class PromoteRepository {
if (isset($params['sdk_version'])) {
$map['sdk_version'] = $params['sdk_version'];
}
$items = M('spend', 'tab_')->field(['sum(pay_amount) amount', 'promote_id', 'pay_way'])->where($map)->groupBy('promote_id, pay_way')->select();
$items = M('spend', 'tab_')->field(['sum(pay_amount) amount', 'promote_id', 'pay_way'])->where($map)->group('promote_id, pay_way')->select();
$records = [];
foreach ($items as $item) {
if (isset($records[$item['promote_id']])) {
if ($item['pay_way'] == -1) {
$records[$item['promote_id']]['ban_coin'] = $item['amount'];
} elseif ($item['pay_way'] == 0) {
$records[$item['promote_id']]['coin'] = $item['amount'];
if ($item['pay_way'] == -1) {
$records[$item['promote_id']]['ban_coin'] = $item['amount'];
} elseif ($item['pay_way'] == 0) {
$records[$item['promote_id']]['coin'] = $item['amount'];
} else {
if (isset($records[$item['promote_id']])) {
$records[$item['promote_id']]['cash'] = isset($records[$item['promote_id']]['cash']) ?
$records[$item['promote_id']]['cash'] + $item['amount'] :
$item['amount'];
} else {
$records[$item['promote_id']]['cash'] = isset$item['amount'];
$records[$item['promote_id']]['cash'] = $item['amount'];
}
}
}
foreach ($ids as $id) {
if (isset($records[$id])) {
$records[$id] = [
'ban_coin' => isset($records[$id]['ban_coin']) ? $records[$id]['ban_coin'] : 0,
'coin' => isset($records[$id]['coin']) ? $records[$id]['coin'] : 0,
'cash' => isset($records[$id]['cash']) ? $records[$id]['cash'] : 0,
];
} else {
$records[$id] = [
'ban_coin' => 0,
'coin' => 0,
'cash' => 0,
];
}
$records[$item['promote_id']] = $item['count'];
}
return $records;
}
}

@ -1890,23 +1890,58 @@ class QueryController extends BaseController
$sdkVersion = I('sdk_version', 0);
$gameId = I('game_id', 0);
$serverId = I('server_id', 0);
$promoteId = I('promote_id', 0);
$parentId = I('parent_id', 0);
$promote = $this->getLoginPromote();
$loginPromote = $this->getLoginPromote();
$promote = null;
if ($parentId > 0) {
$promote = M('promote', 'tab_')->where(['id' => $parentId])->find();
} else {
$promote = $loginPromote;
}
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']])->select();
list($promotes, $pagination, $count) = $this->paginate($query);
$subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']])->select();
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']]);
list($promotes, $pagination, $count) = $this->paginate($query);
$ids = array_column($promotes, 'id');
$rows = [];
if (count($ids) > 0) {
$rows = M('promote', 'tab_')->field(['id', 'parent_id'])->where(['parent_id' => ['in', $ids]])->select();
}
$basicPromotes = [];
foreach ($rows as $row) {
$basicPromotes[$row['id']] = $row['parent_id'];
}
$params = [
'isContainSubs' => true,
'basicPromotes' => $basicPromotes,
];
if ($gameId > 0) {
$params['game_id'] = $gameId;
}
if ($serverId > 0) {
$params['server_id'] = $serverId;
}
if ($sdkVersion > 0) {
$params['sdk_version'] = $sdkVersion;
}
$promoteRepository = new PromoteRepository();
$createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $beginTime, $endTime);
$createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $beginTime, $endTime);
$createRoleDeviceCountList = $promoteRepository->getCreateRoleDeviceCountByIds($ids, $beginTime, $endTime);
$createRoleIpCountList = $promoteRepository->getCreateRoleIpCountByIds($ids, $beginTime, $endTime);
$loginUserCountList = $promoteRepository->getLoginUserCountByIds($ids, $beginTime, $endTime);
$rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $beginTime, $endTime);
$rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $beginTime, $endTime);
$rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $beginTime, $endTime);
$createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params);
$createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $params);
$newCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds($ids, $params);
$newCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds($ids, $params);
$newCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds($ids, $params);
$loginUserCountList = $promoteRepository->getLoginUserCountByIds($ids, $params);
$rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params);
$rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params);
$rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params);
$records = [];
foreach ($promotes as $promote) {
@ -1917,15 +1952,32 @@ class QueryController extends BaseController
'real_name' => $promote['real_name'],
'create_role_count' => $createRoleCountList[$id],
'create_role_user_count' => $createRoleUserCountList[$id],
'create_role_device_count' => $createRoleDeviceCountList[$id],
'create_role_ip_count' => $createRoleIpCountList[$id],
'new_create_role_user_count' => $newCreateRoleUserCountList[$id],
'new_create_role_device_count' => $newCreateRoleDeviceCountList[$id],
'new_create_role_ip_count' => $newCreateRoleIpCountList[$id],
'login_user_count' => $loginUserCountList[$id],
'recharge_count' => $rechargeCountList[$id],
'recharge_user_count' => $rechargeUserCountList[$id],
'recharge_amount' => $rechargeAmountList[$id],
'recharge_amount' => $rechargeAmountList[$id]['ban_coin'] + $rechargeAmountList[$id]['coin'] + $rechargeAmountList[$id]['cash'],
'recharge_by_ban_coin' => $rechargeAmountList[$id]['ban_coin'],
'recharge_by_coin' => $rechargeAmountList[$id]['coin'],
'recharge_by_cash' => $rechargeAmountList[$id]['cash'],
];
}
$level = 0;
if ($parentId > 0) {
$level = 2;
} elseif ($loginPromote['parent_id'] == 0) {
$level = 1;
} elseif ($loginPromote['parent_id'] > 0 && $loginPromote['grand_id'] == 0) {
$level = 2;
} elseif ($loginPromote['parent_id'] > 0 && $loginPromote['grand_id'] > 0) {
$level = 3;
}
$this->assign('level', $level);
$this->assign('subPromotes', $subPromotes);
$this->assign('records', $records);
$this->assign('pagination', $pagination);
$this->assign('count', $count);

@ -54,27 +54,21 @@
<option value="2" <if condition="I('status') === '2'">selected</if>>冻结</option>
</select>
</div>
<div class="form-group normal_space">
<input type="text" name="role_name" class="txt normal_txt" id="uid" placeholder="请输入角色名" value="{:I('role_name')}">
</div>
<div class="form-group normal_space">
<input type="text" name="user_account" class="txt normal_txt" id="uid" placeholder="请输入玩家账号" value="{:I('user_account')}">
</div>
<if condition="$parent_id eq 0">
<div class="form-group normal_space">
<select id="group-select" name="headman_promote_id" class="reselect select_gallery" style="width: 220px;" >
<select name="promote_id" class="reselect select_gallery" style="width: 220px;" >
<option value="0">请选择组长</option>
<volist name="groupPromotes" id="promote">
<option ba-id="{$promote.id}" value="{$promote.id}" <if condition="I('headman_promote_id') == $promote['id']">selected</if>>{$promote.account}</option>
<volist name="subPromotes" id="promote">
<option ba-id="{$promote.id}" value="{$promote.id}" <if condition="I('promote_id') == $promote['id']">selected</if>>{$promote.account}</option>
</volist>
</select>
</div>
</if>
<if condition="$grand_id eq 0">
<if condition="$parent_id gt 0 and $grand_id eq 0">
<div class="form-group normal_space">
<select id="promote-select" name="promote_id" class="reselect select_gallery" style="width: 220px;" >
<select name="promote_id" class="reselect select_gallery" style="width: 220px;" >
<option value="0">请选择推广员</option>
<volist name="promotes" id="promote">
<volist name="subPromotes" id="promote">
<option ba-id="{$promote.id}" value="{$promote.id}" <if condition="I('promote_id') == $promote['id']">selected</if>>{$promote.account}</option>
</volist>
</select>
@ -105,7 +99,9 @@
<th>现金充值</th>
<th>通用币充值</th>
<th>绑定币充值</th>
<?php if($level == 1):?>
<th>操作</th>
<?php endif;?>
</tr>
<empty name="records">
<tr><td colspan="8" style="text-align: center;height: 45vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
@ -115,18 +111,19 @@
<td>{$record.account}({$record.real_name})</td>
<td>{$record.create_role_count}</td>
<td>{$record.create_role_user_count}</td>
<td></td>
<td></td>
<td></td>
<td>{$record.new_create_role_user_count}</td>
<td>{$record.new_create_role_device_count}</td>
<td>{$record.new_create_role_ip_count}</td>
<td>{$record.login_user_count}</td>
<td>{$record.create_role_user_count}</td>
<td>{$record.recharge_count}</td>
<td>{$record.recharge_user_count}</td>
<td>{$record.recharge_amount}</td>
<td></td>
<td></td>
<td></td>
<td><a href="">查看下级</a></td>
<td>{$record.recharge_by_cash}</td>
<td>{$record.recharge_by_coin}</td>
<td>{$record.recharge_by_ban_coin}</td>
<?php if($level == 1):?>
<td><a href="{:U('Query/achievement', ['parent_id' => $record['id']])}">查看下级</a></td>
<?php endif;?>
</tr>
</volist>
</empty>

Loading…
Cancel
Save