@@ -151,6 +161,7 @@
玩家账号 |
游戏名称 |
所属推广员 |
+
所属市场专员 |
充值ip |
区服ID |
游戏区服 |
@@ -170,7 +181,7 @@
- aOh! 暂时还没有内容! |
+ aOh! 暂时还没有内容! |
@@ -215,6 +226,7 @@
+ {$data.market_admin_username} |
{$data.spend_ip} |
— — |
@@ -272,7 +284,7 @@
汇总 |
-
+ |
当页充值:{:null_to_0(array_sum(array_column(array_status2value('pay_status','',$list_data),'pay_amount')))}
diff --git a/Application/Admin/View/User/rolelist.html b/Application/Admin/View/User/rolelist.html
index 77bf16481..678214c33 100644
--- a/Application/Admin/View/User/rolelist.html
+++ b/Application/Admin/View/User/rolelist.html
@@ -108,6 +108,16 @@
+
+
+
+
+
@@ -127,6 +137,7 @@
| 角色名 |
游戏等级 |
所属推广员 |
+ 所属市场专员 |
最后登录时间 |
最后登录IP |
@@ -161,13 +172,14 @@
{$data.promote_account|encryptStr}
+ {$data.market_admin_username} |
= date('Y-m-d H:i:s', $data['play_time']) ?> |
{$data.play_ip} |
- aOh! 暂时还没有内容! |
+ aOh! 暂时还没有内容! |
diff --git a/Application/Base/Repository/SpendRepository.class.php b/Application/Base/Repository/SpendRepository.class.php
index b9b483087..f6fe4b649 100644
--- a/Application/Base/Repository/SpendRepository.class.php
+++ b/Application/Base/Repository/SpendRepository.class.php
@@ -374,4 +374,175 @@ class SpendRepository
{
// return M('spend', 'tab_')->field($columns)->where($map);
}
+
+ public function achievement()
+ {
+ $time = I('time', date('Y-m-d'));
+ if (!empty($time)) {
+ $defaultTime = $time;
+ } else {
+ $defaultTime = date('Y-m-d', time());
+ }
+ $sdkVersion = I('sdk_version', 0);
+ $relationGameId = I('relation_game_id', 0);
+ $serverId = I('server_id', 0);
+ $parentId = I('parent_id', 0);
+ $promoteId = I('promote_id', 0);
+ $status = I('status', 0);
+ $searchLevel = 0;
+ $searchLevelName = '';
+ $currentDisplay = '';
+ $prevParentId = 0;
+
+ $promoteService = new PromoteService();
+ $loginPromote = $this->getLoginPromote();
+
+ $parent = null;
+ if ($parentId > 0) {
+ $parent = M('promote', 'tab_')->where(['id' => $parentId])->find();
+ $currentDisplay = $promoteService->getLevelName($parent['level']) . '推广';
+ $prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id'];
+ } else {
+ $parent = $loginPromote;
+ $currentDisplay = '自己';
+ }
+ $searchLevel = $parent['level'] + 1;
+ $searchLevelName = $promoteService->getLevelName($searchLevel);
+
+ $games = get_promote_serach_game();
+
+ $subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'group_remark'])->where(['parent_id' => $parent['id']])->select();
+
+ $map = ['parent_id' => $parent['id']];
+ if ($promoteId > 0) {
+ $map['id'] = $promoteId;
+ }
+
+ $query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map);
+ list($promotes, $pagination, $count) = $this->paginate($query);
+
+ $ids = array_column($promotes, 'id');
+
+ $rows = [];
+ if (count($ids) > 0) {
+ $rows = M('promote', 'tab_')
+ ->field(['id', 'chain'])
+ ->where(['chain' => ['like', [$parent['chain'] . $parent['id'] . '/%']], 'level' => ['gt', $parent['level'] + 1]])
+ ->select();
+ }
+
+ $basicPromotes = [];
+ foreach ($ids as $id) {
+ foreach ($rows as $row) {
+ $needChain = $parent['chain'] . $parent['id'] . '/' . $id . '/';
+ if (strpos($row['chain'], $needChain) !== false) {
+ $basicPromotes[$row['id']] = $id;
+ }
+ }
+ }
+ $params = [
+ 'isContainSubs' => true,
+ 'basicPromotes' => $basicPromotes,
+ ];
+ if ($relationGameId != 0 || $sdkVersion != 0) {
+ $gameIds = gameSearch($relationGameId, $sdkVersion);
+ $params['game_id'] = ['in', $gameIds];
+ }
+ if ($serverId > 0) {
+ $params['server_id'] = $serverId;
+ }
+ if ($status > 0) {
+ $params['lock_status'] = $status;
+ }
+ list($beginTime, $endTime) = $this->getBetweenTime($time);
+ $params['begin_time'] = $beginTime;
+ $params['end_time'] = $endTime;
+
+ $timeout = 0;
+ $records = [];
+ if (intval($endTime - $beginTime) / (24 * 3600) <= 7) {
+ $promoteRepository = new PromoteRepository();
+ $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 = [];
+ $rechargeUserCountList = [];
+ $rechargeAmountList = [];
+ if ($this->canViewUserRecharge) {
+ $rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params);
+ $rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params);
+ $rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params);
+ }
+
+ $promoteService = new PromoteService();
+
+ if (I('p', 1) == 1) {
+ $selfParams = $params;
+ $selfParams['isContainSubs'] = false;
+ $selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams);
+ $selfCreateRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds([$parent['id']], $selfParams);
+ $selfNewCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds([$parent['id']], $selfParams);
+ // $selfNewCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds([$parent['id']], $selfParams);
+ $selfNewCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds([$parent['id']], $selfParams);
+ $selfLoginUserCountList = $promoteRepository->getLoginUserCountByIds([$parent['id']], $selfParams);
+ $record = [
+ 'id' => $parent['id'],
+ 'account' => $parent['account'],
+ 'promote_group' => $promoteService->getGroupNameByChain($parent['chain'], $parent['id']),
+ 'real_name' => hideRealName($parent['real_name']),
+ 'level' => $parent['level'],
+ 'create_role_count' => $selfCreateRoleCountList[$parent['id']],
+ 'create_role_user_count' => $selfCreateRoleUserCountList[$parent['id']],
+ 'new_create_role_user_count' => $selfNewCreateRoleUserCountList[$parent['id']],
+ // 'new_create_role_device_count' => $selfNewCreateRoleDeviceCountList[$parent['id']],
+ 'new_create_role_ip_count' => $selfNewCreateRoleIpCountList[$parent['id']],
+ 'login_user_count' => $selfLoginUserCountList[$parent['id']],
+ 'current_display' => $currentDisplay,
+ ];
+ if ($this->canViewUserRecharge) {
+ $selfRechargeCountList = $promoteRepository->getRechargeCountByIds([$parent['id']], $selfParams);
+ $selfRechargeUserCountList = $promoteRepository->getRechargeUserCountByIds([$parent['id']], $selfParams);
+ $selfRechargeAmountList = $promoteRepository->getRechargeAmountByIds([$parent['id']], $selfParams);
+ $record['recharge_count'] = $selfRechargeCountList[$parent['id']];
+ $record['recharge_user_count'] = $selfRechargeUserCountList[$parent['id']];
+ $record['recharge_amount'] = $selfRechargeAmountList[$parent['id']]['ban_coin'] + $selfRechargeAmountList[$parent['id']]['coin'] + $selfRechargeAmountList[$parent['id']]['cash'];
+ $record['recharge_by_ban_coin'] = $selfRechargeAmountList[$parent['id']]['ban_coin'];
+ $record['recharge_by_coin'] = $selfRechargeAmountList[$parent['id']]['coin'];
+ $record['recharge_by_cash'] = $selfRechargeAmountList[$parent['id']]['cash'];
+ }
+ $records[] = $record;
+ }
+ foreach ($promotes as $promote) {
+ $id = $promote['id'];
+ $record = [
+ 'id' => $id,
+ 'account' => $promote['account'],
+ 'promote_group' => $promoteService->getGroupNameByChain($promote['chain'], $promote['id']),
+ 'real_name' => hideRealName($promote['real_name']),
+ 'level' => $promote['level'],
+ 'create_role_count' => $createRoleCountList[$id],
+ 'create_role_user_count' => $createRoleUserCountList[$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],
+ 'current_display' => '',
+ ];
+ if ($this->canViewUserRecharge) {
+ $record['recharge_count'] = $rechargeCountList[$id];
+ $record['recharge_user_count'] = $rechargeUserCountList[$id];
+ $record['recharge_amount'] = $rechargeAmountList[$id]['ban_coin'] + $rechargeAmountList[$id]['coin'] + $rechargeAmountList[$id]['cash'];
+ $record['recharge_by_ban_coin'] = $rechargeAmountList[$id]['ban_coin'];
+ $record['recharge_by_coin'] = $rechargeAmountList[$id]['coin'];
+ $record['recharge_by_cash'] = $rechargeAmountList[$id]['cash'];
+ }
+ $records[] = $record;
+ }
+ } else {
+ $timeout = 1;
+ }
}
\ No newline at end of file
diff --git a/Application/Base/Service/MarketService.class.php b/Application/Base/Service/MarketService.class.php
new file mode 100644
index 000000000..caeb9b26a
--- /dev/null
+++ b/Application/Base/Service/MarketService.class.php
@@ -0,0 +1,74 @@
+field(['chain', 'id', 'level', 'admin_id'])->where(['id' => $promoteId, 'admin_id' => $formId])->find();
+
+ if (!$promote) {
+ throw new \Exception('会长不存在');
+ }
+ if ($promote['level'] != 1) {
+ throw new \Exception('该账号非会长');
+ }
+ $promotes = (new PromoteService)->getAllChildren($promote, 0, ['id']);
+ $promoteIds = [$promote['id']];
+ $promoteIds = array_merge(array_column($promotes, 'id'), $promoteIds);
+
+ $this->shiftPromote($formId, $toId);
+ $this->shiftSpend($promoteIds, $formId, $toId, $time);
+ $this->shiftDeposit($promoteIds, $formId, $toId, $time);
+ }
+
+ private function shiftPromote($promoteId, $formId, $toId, $time = null)
+ {
+ $map = [];
+ $map['id'] = $promoteId;
+ M('promote', 'tab_')->where($map)->save(['admin_id' => $toId]);
+ }
+
+ private function shiftSpend($promoteIds, $formId, $toId, $time = null)
+ {
+ $map = [];
+ $map['promote_id'] = ['in', $promoteIds];
+ $map['market_admin_id'] = $formId;
+ if ($time) {
+ $map['pay_time'] = ['egt', $time];
+ }
+
+ $count = M('spend', 'tab_')->where($map)->count();
+ $limit = 50;
+ $pageCount = ceil($count/$limit);
+ for ($page = 0; $page <= $pageCount; $page ++) {
+ M('spend', 'tab_')->where($map)->limit($limit)->save(['market_admin_id' => $toId]);
+ }
+ M('spend', 'tab_')->where($map)->save(['market_admin_id' => $toId]);
+ }
+
+ private function shiftDeposit($promoteIds, $formId, $toId, $time = null)
+ {
+ $map = [];
+ $map['promote_id'] = ['in', $promoteIds];
+ $map['market_admin_id'] = $formId;
+ if ($time) {
+ $map['create_time'] = ['egt', $time];
+ }
+
+ $count = M('deposit', 'tab_')->where($map)->count();
+ $limit = 50;
+ $pageCount = ceil($count/$limit);
+ for ($page = 0; $page <= $pageCount; $page ++) {
+ M('deposit', 'tab_')->where($map)->limit($limit)->save(['market_admin_id' => $toId]);
+ }
+ M('deposit', 'tab_')->where($map)->save(['market_admin_id' => $toId]);
+ }
+}
\ No newline at end of file
diff --git a/Application/Base/Service/PaymentService.class.php b/Application/Base/Service/PaymentService.class.php
new file mode 100644
index 000000000..1cf22bf5a
--- /dev/null
+++ b/Application/Base/Service/PaymentService.class.php
@@ -0,0 +1,8 @@
+
+ */
+class BaseTask
+{
+ public $params;
+
+ public function __construct($params = [])
+ {
+ $this->params = $params;
+ }
+
+ public function run()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Application/Base/Task/MarketShiftTask.class.php b/Application/Base/Task/MarketShiftTask.class.php
new file mode 100644
index 000000000..7c1a36d7b
--- /dev/null
+++ b/Application/Base/Task/MarketShiftTask.class.php
@@ -0,0 +1,31 @@
+
+ */
+class MarketShiftTask extends BaseTask
+{
+ public function run()
+ {
+ $id = $this->params['market_shift_id'];
+ $record = M('market_shift', 'tab_')->where(['id' => $id])->find();
+ if (!$record) {
+ throw new \Exception('换绑记录不存在');
+ }
+ if ($record['status'] != 0) {
+ throw new \Exception('换绑记录状态错误');
+ }
+ try {
+ $marketService = new MarketService();
+ $marketService->shift($record);
+ M('market_shift', 'tab_')->where(['id' => $id])->save(['status' => 1]);
+ } catch (\Exception $e) {
+ M('market_shift', 'tab_')->where(['id' => $id])->save(['status' => 2]);
+ throw new \Exception($e->getMessage());
+ }
+ }
+}
\ No newline at end of file
diff --git a/Application/Base/Task/Task.class.php b/Application/Base/Task/Task.class.php
new file mode 100644
index 000000000..6e1db5765
--- /dev/null
+++ b/Application/Base/Task/Task.class.php
@@ -0,0 +1,83 @@
+
+ */
+class Task
+{
+ public static $types = [
+ 'market-shift' => '\Base\Task\MarketShiftTask',
+ ];
+
+ public $type;
+ public $tasks;
+
+ public function __construct($type = null)
+ {
+ $this->type = $type;
+ }
+
+ public function run($count = 1)
+ {
+ $map = ['status' => 0];
+ if ($this->type !== null) {
+ $map['type'] = $this->type;
+ }
+ $this->tasks = M('tasks', 'tab_')->where($map)->limit($count)->select();
+ if (count($this->tasks) == 0) {
+ throw new \Exception('暂无任务');
+ }
+
+ $this->updateTasks(['status' => 1, 'start_time' => time()]);
+
+ foreach ($this->tasks as $task) {
+ $class = $this->getTypeClass($task);
+ if (is_null($class) || !class_exists($class)) {
+ $this->updateTask($task, ['status' => 3, 'end_time' => time(), 'result' => '任务处理类不存在']);
+ continue;
+ }
+ try {
+ $params = json_decode($task['params'], true);
+ $obj = new $class($params);
+ $obj->run();
+ $this->updateTask($task, ['status' => 2, 'end_time' => time(), 'result' => '处理成功']);
+ } catch (\Exception $e) {
+ $this->updateTask($task, ['status' => 3, 'end_time' => time(), 'result' => $e->getMessage()]);
+ }
+ }
+ }
+
+ public function getTypeClass($task)
+ {
+ if (!isset(self::$types[$task['type']])) {
+ return null;
+ }
+ return self::$types[$task['type']];
+ }
+
+ private function updateTask($task, $data)
+ {
+ M('tasks', 'tab_')->where(['id' => $task['id']])->save($data);
+ }
+
+ private function updateTasks($data)
+ {
+ $ids = array_column($this->tasks, 'id');
+ M('tasks', 'tab_')->where(['id' => ['in', $ids]])->save($data);
+ }
+
+ public static function add($type, $params = [])
+ {
+ if (!isset(self::$types[$type])) {
+ return false;
+ }
+ $record = [
+ 'type' => $type,
+ 'params' => json_encode($params),
+ 'created_time' => time()
+ ];
+ return M('tasks', 'tab_')->add($record);
+ }
+}
\ No newline at end of file
diff --git a/Application/Base/Tool/ServiceClient.class.php b/Application/Base/Tool/ServiceClient.class.php
new file mode 100644
index 000000000..8bf2c1a21
--- /dev/null
+++ b/Application/Base/Tool/ServiceClient.class.php
@@ -0,0 +1,63 @@
+client = new Client([
+ 'base_uri' => C('SERVICE_URL'),
+ 'timeout' => 10.0,
+ ]);
+ }
+
+ protected function post($uri, $data)
+ {
+ $response = $this->client->post($uri, [
+ 'verify' => false,
+ 'form_params' => $data
+ ]);
+ $result = (string)$response->getBody();
+ return json_decode($result, true);
+ }
+
+ public function sendSmsCode(string $mobile, string $clientIp)
+ {
+ $options = ['type' => 'code', 'client_ip' => $clientIp];
+ return $this->sendSms($mobile, $options);
+ }
+
+ public function sendSmsContent(string $mobile, string $content)
+ {
+ $options = ['type' => 'content', 'content' => $content];
+ return $this->sendSms($mobile, $options);
+ }
+
+ public function sendSmsBatch(array $mobiles, string $content)
+ {
+ $options = ['type' => 'batch', 'content' => $content];
+ return $this->sendSms($mobiles, $options);
+ }
+
+ private function sendSms($mobile, array $options)
+ {
+ return $this->post('/message/sms-send', ['mobile' => $mobile, 'options' => $options]);
+ }
+
+ public function checkSms($mobile, $code)
+ {
+ return $this->post('/message/sms-check', ['mobile' => $mobile, 'code' => $code]);
+ }
+
+ public function registerEvent($userId, $source)
+ {
+ return $this->post('/game-event/register', ['user_id' => $userId, 'source' => $source]);
+ }
+}
\ No newline at end of file