Merge branch 'feature/promote' into dev

master
ELF 5 years ago
commit 7be62bb3b5

@ -5,6 +5,8 @@
namespace Admin\Controller;
use Admin\Model\SpendModel;
use Think\Think;
use Base\Tool\Printer;
use Base\Service\PromoteService;
class ConsoleController extends Think {
@ -56,4 +58,34 @@ class ConsoleController extends Think {
// echo M()->getLastSql() . "\n";
}
}
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);
}
}
}
}

@ -187,13 +187,19 @@ class PromoteService {
$secondMap['parent_id'] = ['in', $shiftIds];
}
$status = M('promote', 'tab_')->where($firstMap)->save(['parent_id' => $toPromote['id'], 'parent_name' => $toPromote['account']]);
$status = M('promote', 'tab_')->where($firstMap)->save([
'parent_id' => $toPromote['id'],
'parent_name' => $toPromote['account'],
'chain' => $toPromote['chain'] . $toPromote['id'] . '/'
]);
if (!$status) {
$model->rollback();
return ['status' => false, 'msg' => '系统异常,修改推广员上级失败'];
}
$status = M('promote', 'tab_')->where($secondMap)->save(['chain' => $toPromote['chain'] . $toPromote['id'] . '/']);
$status = M('promote', 'tab_')->where($secondMap)->save([
'chain' => ['exp', 'REPLACE(chain, "/' . $fromPromote['id'] . '/","/' . $toPromote['id'] . '/")'],
]);
if (!$status) {
$model->rollback();
return ['status' => false, 'msg' => '系统异常修改推广员CHAIN失败'];
@ -395,7 +401,7 @@ class PromoteService {
$promoteId = $params['promote_id'];
$type = $params['type'];
$status = M('ShiftTask')->where(['from_promote_id' => $promoteId, 'type' => $type, 'status' => 0])->save(['status' => 2]);
$status = M('ShiftTask')->where(['from_promote_id' => $promoteId, 'type' => $type, 'status' => 0])->save(['status' => 2, 'handle_time' => time()]);
if ($status) {
return ['status' => true, 'msg' => '取消成功'];

@ -916,11 +916,23 @@ class PromoteController extends BaseController
{
if (IS_POST) {
$params = I('post.');
$loginPromote = $this->getLoginPromote();
if ($params['promote_type'] == 0 && $loginPromote['level'] > 1) {
$this->ajaxReturn(['status' => 0, 'msg' => '无权限']);
}
if ($params['promote_type'] == 1 && $loginPromote['level'] > 2) {
$this->ajaxReturn(['status' => 0, 'msg' => '无权限']);
}
if ($params['promote_type'] == 2 && $loginPromote['level'] > 3) {
$this->ajaxReturn(['status' => 0, 'msg' => '无权限']);
}
$parent = null;
if (isset($params['parent_id'])) {
if (isset($params['parent_id']) && $params['parent_id']) {
$parent = M('promote', 'tab_')->where(['id' => $params['parent_id']])->find();
} else {
$parent = $this->getLoginPromote();
$parent = $loginPromote;
}
$promoteService = new PromoteService();
$result = $promoteService->checkAddPromote($params);

@ -103,6 +103,10 @@
var promote_type = $('[name=promote_type]').val();
var repassword = $('#repassword').val();
var parent_id = $('#parent_id').val();
if ($('#parent_id').length > 0 && parent_id == 0) {
layer.msg('请选择所属上级');
return
}
$.ajax({
type:"POST",
url:"{:U('addPromote')}",

Loading…
Cancel
Save