|
|
|
@ -14,6 +14,8 @@ use Base\Task\Task;
|
|
|
|
|
use Base\Service\MarketService;
|
|
|
|
|
use Base\Tool\AggregateClient;
|
|
|
|
|
use Base\Repository\GameRepository;
|
|
|
|
|
use Base\Tool\Redis;
|
|
|
|
|
use Think\Model;
|
|
|
|
|
|
|
|
|
|
class ConsoleController extends Think {
|
|
|
|
|
|
|
|
|
@ -666,4 +668,84 @@ class ConsoleController extends Think {
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|