master
ELF 4 years ago
parent 34e25f293a
commit 531b94bae8

@ -14,6 +14,8 @@ use Base\Task\Task;
use Base\Service\MarketService; use Base\Service\MarketService;
use Base\Tool\AggregateClient; use Base\Tool\AggregateClient;
use Base\Repository\GameRepository; use Base\Repository\GameRepository;
use Base\Tool\Redis;
use Think\Model;
class ConsoleController extends Think { class ConsoleController extends Think {
@ -666,4 +668,84 @@ class ConsoleController extends Think {
} }
echo '<table>' . PHP_EOL . $trs . '</table>'; echo '<table>' . PHP_EOL . $trs . '</table>';
} }
public function generateHistoryGame()
{
$items = M('spend', 'tab_')
->field(['tab_promote.level1_id', 'group_concat(distinct tab_spend.game_id) game_ids'])
->join('left join tab_promote on tab_spend.promote_id=tab_promote.id')
->where('tab_spend.is_check=1 and tab_spend.pay_status=1')
->group('tab_promote.level1_id')
->select();
foreach ($items as $item) {
if ($item['level1_id']) {
$key = Redis::getKey('promote_history_games', ['promote_id' => $item['level1_id']]);
Redis::set($key, $item['game_ids']);
}
}
}
public function updateHistoryGame()
{
$items = M('spend', 'tab_')
->field(['tab_promote.level1_id', 'group_concat(distinct tab_spend.game_id) game_ids'])
->join('left join tab_promote on tab_spend.promote_id=tab_promote.id')
->where('tab_spend.is_check=1 and tab_spend.pay_status=1 and tab_spend.pay_time>' . strtotime(date('Y-m-d 00:00:00')))
->group('tab_promote.level1_id')
->select();
foreach ($items as $item) {
if ($item['level1_id']) {
$key = Redis::getKey('promote_history_games', ['promote_id' => $item['level1_id']]);
$value = Redis::get($key);
$gameIds = $value ? explode(',', $value) : [];
$nowGameIds = explode(',', $item['game_ids']);
$gameIds = array_unique(array_merge($gameIds, $nowGameIds));
Redis::set($key, implode(',', $gameIds));
}
}
}
public function generatePromotesLevelId()
{
$promotes = M('promote', 'tab_')->field(['chain', 'id'])->select();
foreach ($promotes as $promote) {
$fullChain = explode('/', $promote['chain'] . $promote['id']);
M('promote', 'tab_')->where(['id' => $promote['id']])->save([
'level1_id' => $fullChain[1] ?? 0,
'level2_id' => $fullChain[2] ?? 0,
'level3_id' => $fullChain[3] ?? 0,
'level4_id' => $fullChain[4] ?? 0,
]);
}
}
public function setUserFirstPayTime()
{
$hasNext = true;
$limit = 500;
$lastId = 0;
do {
$items = M('spend', 'tab_')
->field(['user_id', 'min(pay_time) first_pay_time'])
->where(['pay_status' => 1, 'user_id' => ['gt', $lastId]])
->group('user_id')
->order('user_id asc')
->limit($limit)
->select();
$model = new Model();
$model->startTrans();
foreach ($items as $item) {
M('user', 'tab_')->where(['id' => $item['user_id']])->save([
'first_pay_time' => $item['first_pay_time']
]);
$lastId = $item['user_id'];
}
$model->commit();
if (count($items) < $limit) {
$hasNext = false;
}
} while($hasNext);
}
} }

@ -7,6 +7,7 @@ use Base\Model\UserPlayModel;
use Base\Model\UserModel; use Base\Model\UserModel;
use Base\Tool\IdCard; use Base\Tool\IdCard;
use Base\Tool\Registry; use Base\Tool\Registry;
use Base\Tool\Redis;
use Think\Model; use Think\Model;
use Base\Repository\SpendRepository; use Base\Repository\SpendRepository;
@ -396,6 +397,11 @@ class PromoteService {
} }
} }
$toTopPromote = $this->getTopPromote($toPromote);
$hasGameIds = $toTopPromote['game_ids'] == '' ? [] : explode(',', $toTopPromote['game_ids']);
$hasNotGameIds = M('game', 'tab_')->where(['game_id' => ['not in', $hasGameIds]])->getField('id', true);
$hasNotGameIds = $hasNotGameIds ?? [];
$model = new Model(); $model = new Model();
$model->startTrans(); $model->startTrans();
@ -433,7 +439,17 @@ class PromoteService {
M('user_play_info', 'tab_')->where($otherMap)->save($updateData); M('user_play_info', 'tab_')->where($otherMap)->save($updateData);
unset($spendMap['pay_status']); unset($spendMap['pay_status']);
M('spend', 'tab_')->where($spendMap)->save(array_merge($updateData, $updateMarket)); // 只改未对账的数据
$updateCheck = [];
if (count($hasGameIds) > 0) {
$spendMap['game_id'] = ['in', $hasGameIds];
M('spend', 'tab_')->where($spendMap)->save(array_merge($updateData, $updateMarket, ['is_check' => 1]));
}
if (count($hasNotGameIds) > 0) {
$spendMap['game_id'] = ['in', $hasNotGameIds];
M('spend', 'tab_')->where($spendMap)->save(array_merge($updateData, $updateMarket, ['is_check' => 0]));
}
$bindMap = $otherMap; $bindMap = $otherMap;
$bindMap['pay_time'] = ['egt', $orderTime]; $bindMap['pay_time'] = ['egt', $orderTime];
@ -1253,17 +1269,9 @@ class PromoteService {
public function getHistoryGameIds($promote) public function getHistoryGameIds($promote)
{ {
$topPromote = $this->getTopPromote($promote); $topPromote = $this->getTopPromote($promote);
$key = Redis::getKey('promote_history_games', ['promote_id' => $item['level1_id']]);
$spendRepository = new SpendRepository(); $value = Redis::get($key);
$historyGameIds = $value ? explode(',', $value) : [];
$map = [];
$map['_string'] = ' promote_id in(' . $this->subInSql($topPromote) . ')';
$map = $spendRepository->withIsCheck($map);
$historyGames = M('spend', 'tab_')->field(['distinct game_id'])->where($map)->select();
$historyGameIds = [];
if ($historyGames) {
$historyGameIds = array_column($historyGames, 'game_id');
}
$nowGameIds = $topPromote['game_ids'] == '' ? [] : explode(',', $topPromote['game_ids']); $nowGameIds = $topPromote['game_ids'] == '' ? [] : explode(',', $topPromote['game_ids']);
return array_unique(array_merge($historyGameIds, $nowGameIds)); return array_unique(array_merge($historyGameIds, $nowGameIds));
} }

@ -8,6 +8,22 @@ class Redis
{ {
private static $handler; private static $handler;
public static $allKeys = [
'promote_history_games' => 'promote_history_games:{promote_id}', // 会长历史游戏
];
public static function getKey($name, $params = [])
{
$realKey = self::$allKeys[$name] ?? null;
if (is_null($realKey)) {
throw new \Exception('KEY不存在');
}
foreach ($params as $key => $value) {
$realKey = str_replace('{' . $key . '}', $value, $realKey);
}
return $realKey;
}
public static function getHandler() public static function getHandler()
{ {
if(self::$handler == null) { if(self::$handler == null) {

@ -801,7 +801,7 @@ class QueryController extends BaseController
$newPayUserCountList = $spendRepository->getNewPayUserCountGroupByDay($params); $newPayUserCountList = $spendRepository->getNewPayUserCountGroupByDay($params);
$payAmountList = $spendRepository->getPayAmountGroupByDay($params); $payAmountList = $spendRepository->getPayAmountGroupByDay($params);
$newPayAmountList = $spendRepository->getNewPayAmountGroupByDay($params); $newPayAmountList = $spendRepository->getNewPayAmountGroupByDay($params);
$historyPayCountList = $spendRepository->getHistoryPayCountGroupByDay($params); // $historyPayCountList = $spendRepository->getHistoryPayCountGroupByDay($params);
$loginCountList = $userRepository->getLoginCountGroupByDay($params); $loginCountList = $userRepository->getLoginCountGroupByDay($params);
$registerCountList = $userRepository->getRegisterCountGroupByDay($params); $registerCountList = $userRepository->getRegisterCountGroupByDay($params);
@ -813,7 +813,7 @@ class QueryController extends BaseController
'newPayUserCount' => $newPayUserCountList[$day], 'newPayUserCount' => $newPayUserCountList[$day],
'payAmount' => number_format($payAmountList[$day], 2), 'payAmount' => number_format($payAmountList[$day], 2),
'newPayAmount' => number_format($newPayAmountList[$day], 2), 'newPayAmount' => number_format($newPayAmountList[$day], 2),
'historyPayCount' => $historyPayCountList[$day], // 'historyPayCount' => $historyPayCountList[$day],
'loginCount' => $loginCountList[$day], 'loginCount' => $loginCountList[$day],
'registerCount' => $registerCountList[$day], 'registerCount' => $registerCountList[$day],
'payRate' => $loginCountList[$day] == 0 ? '--' : round($payUserCountList[$day] / $loginCountList[$day] * 100, 2) . '%', 'payRate' => $loginCountList[$day] == 0 ? '--' : round($payUserCountList[$day] / $loginCountList[$day] * 100, 2) . '%',

@ -2781,3 +2781,15 @@ ALTER TABLE `tab_testing_resource_batch`
ADD COLUMN `verify_admin_id` int(11) NOT NULL DEFAULT 0 COMMENT '審核管理員ID' AFTER `verify_status`; ADD COLUMN `verify_admin_id` int(11) NOT NULL DEFAULT 0 COMMENT '審核管理員ID' AFTER `verify_status`;
ALTER TABLE `tab_testing_resource_batch` ALTER TABLE `tab_testing_resource_batch`
ADD COLUMN `apply_admin_id` int(11) NOT NULL DEFAULT 0 COMMENT '申請管理員ID' AFTER `apply_promote_id`; ADD COLUMN `apply_admin_id` int(11) NOT NULL DEFAULT 0 COMMENT '申請管理員ID' AFTER `apply_promote_id`;
ALTER TABLE `tab_promote`
ADD COLUMN `level1_id` int(11) NOT NULL DEFAULT 0 COMMENT '一级推广员ID(会长)' AFTER `chain`;
ALTER TABLE `tab_promote`
ADD COLUMN `level2_id` int(11) NOT NULL DEFAULT 0 COMMENT '二级推广员ID(部门长)' AFTER `level1_id`;
ALTER TABLE `tab_promote`
ADD COLUMN `level3_id` int(11) NOT NULL DEFAULT 0 COMMENT '三级推广员ID(组长)' AFTER `level2_id`;
ALTER TABLE `tab_promote`
ADD COLUMN `level4_id` int(11) NOT NULL DEFAULT 0 COMMENT '四级推广员ID(推广员)' AFTER `level3_id`;
ALTER TABLE `tab_user`
ADD COLUMN `first_pay_time` int(11) NOT NULL DEFAULT 0 COMMENT '首次充值时间' AFTER `fgame_name`;
Loading…
Cancel
Save