You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.4 KiB
PHTML

5 years ago
<?php
/**
* 定时自动完成
*/
namespace Admin\Controller;
use Admin\Model\SpendModel;
use Think\Think;
5 years ago
use Base\Tool\Printer;
use Base\Service\PromoteService;
5 years ago
class ConsoleController extends Think {
5 years ago
protected function _initialize()
{
C(api('Config/lists'));
}
public function modifyPromote()
5 years ago
{
$promotes = M('promote', 'tab_')->where(['parent_id' => 0])->select();
foreach ($promotes as $promote) {
$promote['chain'] = '/';
$promote['level'] = 1;
M('promote', 'tab_')->where(['id' => $promote['id']])->save(['chain' => '/', 'level' => 1]);
5 years ago
$subPromote = $promote;
unset($subPromote['id']);
$subPromote['parent_id'] = $promote['id'];
$subPromote['parent_name'] = $promote['account'];
$subPromote['chain'] = $promote['chain'] . $promote['id'] . '/';
$subPromote['level'] = $promote['level'] + 1;
$subPromote['account'] = 'second_' . $promote['account'];
$subPromote['nickname'] = '二级_' . $promote['nickname'];
$subPromote['mobile_phone'] = '';
$subPromote['email'] = '';
$subPromote['real_name'] = '';
$subPromote['money'] = 0;
$subPromote['total_money'] = 0;
$subPromote['balance_coin'] = 0;
$subPromote['create_time'] = time();
$subPromote['last_login_time'] = 0;
$subPromote['idcard'] = '';
M('promote', 'tab_')->add($subPromote);
$subId = M()->getLastInsID();
$subChain = $subPromote['chain'] . $subId . '/';
M('promote', 'tab_')->where(['parent_id' => $promote['id'], 'id' => ['neq', $subId]])->save([
'parent_id' => $subId,
'parent_name' => $subPromote['account'],
'chain' => $subChain,
'level' => 3,
]);
// echo M()->getLastSql() . "\n";
M('promote', 'tab_')->where(['grand_id' => $promote['id']])->save([
'chain' => ['exp', 'concat("' . $subChain. '",parent_id,"/")'],
'level' => 4,
]);
// echo M()->getLastSql() . "\n";
}
5 years ago
}
5 years ago
public function runShiftTask()
{
$promoteService = new PromoteService();
$tasks = M('shift_task', 'sys_')->where(['status' => 0, 'order_time' => ['elt', time()]])->select();
if (count($tasks) == 0) {
Printer::export('无可执行任务', true);
}
foreach ($tasks as $task) {
if ($task['type'] == 1) {
$message = '推广员迁移[' . $task['id'] . ']';
$result = $promoteService->shiftPromote($task);
if ($result['status']) {
$message = 'SUCCESS ----- ' . $message . $result['msg'];
} else {
$message = 'ERROR ----- ' . $message . $result['msg'];
}
Printer::export($message);
} elseif ($task['type'] == 2) {
$message = '玩家迁移[' . $task['id'] . ']';
$result = $promoteService->shiftPlayer($task);
if ($result['status']) {
$message = 'SUCCESS ----- ' . $message . $result['msg'];
} else {
$message = 'ERROR ----- ' . $message . $result['msg'];
}
Printer::export($message);
}
}
}
5 years ago
}