|
|
|
@ -5,6 +5,7 @@ use Base\Model\PromoteModel;
|
|
|
|
|
use Base\Model\UserPlayInfoModel;
|
|
|
|
|
use Base\Model\UserPlayModel;
|
|
|
|
|
use Base\Model\UserModel;
|
|
|
|
|
use Base\Tool\IdCard;
|
|
|
|
|
use Think\Model;
|
|
|
|
|
|
|
|
|
|
class PromoteService {
|
|
|
|
@ -129,25 +130,10 @@ class PromoteService {
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (M('ShiftTask')->add($data)) {
|
|
|
|
|
$id = M()->getLastInsID();
|
|
|
|
|
$data['id'] = $id;
|
|
|
|
|
if ($isFuture) {
|
|
|
|
|
return [
|
|
|
|
|
'status' => true,
|
|
|
|
|
'msg'=>'迁移任务创建成功'
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
if ($type == 1) {
|
|
|
|
|
return $this->shiftPromote($data);
|
|
|
|
|
} elseif ($type == 2) {
|
|
|
|
|
return $this->shiftPlayer($data);
|
|
|
|
|
} else {
|
|
|
|
|
return [
|
|
|
|
|
'status' => false,
|
|
|
|
|
'msg'=>'数据异常'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return [
|
|
|
|
|
'status' => true,
|
|
|
|
|
'msg'=>'迁移任务创建成功'
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
return [
|
|
|
|
|
'status' => false,
|
|
|
|
@ -196,7 +182,7 @@ class PromoteService {
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,修改推广员CHAIN失败'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$status1 = M('ShiftTask')->where('id=' . $task['id'])->save(['status' => 1]);
|
|
|
|
|
$status1 = M('ShiftTask')->where('id=' . $task['id'])->save(['status' => 1, 'handle_time' => time()]);
|
|
|
|
|
if (!$status1) {
|
|
|
|
|
$model->rollback();
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,修改迁移任务状态失败'];
|
|
|
|
@ -300,22 +286,25 @@ class PromoteService {
|
|
|
|
|
|
|
|
|
|
public function shiftPlayer($task)
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @todo 加事务
|
|
|
|
|
*/
|
|
|
|
|
$toPromoteId = $task['to_promote_id'];
|
|
|
|
|
$fromPromoteId = $task['from_promote_id'];
|
|
|
|
|
$shiftIds = json_decode($task['shift_ids'], true) ?? [];
|
|
|
|
|
|
|
|
|
|
$createPromote = D('promote')->where(['create_promote_id' => $task['create_promote_id']])->find();
|
|
|
|
|
$createPromote = M('promote', 'tab_')->where(['create_promote_id' => $task['create_promote_id']])->find();
|
|
|
|
|
|
|
|
|
|
$toPromote = D('promote')->where(['id' => $toPromoteId])->find();
|
|
|
|
|
$fromPromote = D('promote')->where(['id' => $fromPromoteId])->find();
|
|
|
|
|
$toPromote = M('promote', 'tab_')->where(['id' => $toPromoteId])->find();
|
|
|
|
|
$fromPromote = M('promote', 'tab_')->where(['id' => $fromPromoteId])->find();
|
|
|
|
|
|
|
|
|
|
$user1 = new UserModel();
|
|
|
|
|
$users = $user1->field(['id', 'account', 'nickname'])->where('promote_id=' . $fromPromoteId)->select();
|
|
|
|
|
$map = ['promote_id' => $fromPromote['id']];
|
|
|
|
|
if (count($shiftIds) > 0) {
|
|
|
|
|
$map['id'] = ['in', $shiftIds];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$users = M('user', 'tab_')->field(['id', 'account', 'nickname'])->where($map)->select();
|
|
|
|
|
|
|
|
|
|
$mends = [];
|
|
|
|
|
foreach ($users as $item) {
|
|
|
|
|
$data = [
|
|
|
|
|
$mends[] = [
|
|
|
|
|
'user_id' => $item['id'],
|
|
|
|
|
'user_account' => $item['account'],
|
|
|
|
|
'user_nickname' => $item['nickname'],
|
|
|
|
@ -330,20 +319,57 @@ class PromoteService {
|
|
|
|
|
'op_type' => 1,
|
|
|
|
|
'bind_type' => 1,
|
|
|
|
|
];
|
|
|
|
|
M('Mend', 'tab_')->add($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user = new UserModel();
|
|
|
|
|
$user->where('promote_id=' . $fromPromoteId)->save(['promote_id' => $toPromoteId, 'promote_account' => $toPromote['account']]);
|
|
|
|
|
$model = new Model();
|
|
|
|
|
$model->startTrans();
|
|
|
|
|
|
|
|
|
|
$status = M('mend', 'tab_')->addAll($mends);
|
|
|
|
|
if (!$status) {
|
|
|
|
|
$model->rollback();
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,添加变更记录失败'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$userPlayer = new UserPlayModel();
|
|
|
|
|
$userPlayer->where('promote_id=' . $fromPromoteId)->save(['promote_id' => $toPromoteId, 'promote_account' => $toPromote['account']]);
|
|
|
|
|
$updateData = [
|
|
|
|
|
'promote_id' => $toPromote['id'],
|
|
|
|
|
'promote_account' => $toPromote['account']
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$map = $otherMap = ['promote_id' => $fromPromote['id']];
|
|
|
|
|
if (count($shiftIds) > 0) {
|
|
|
|
|
$map['id'] = ['in', $shiftIds];
|
|
|
|
|
$otherMap['user_id'] = ['in', $shiftIds];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$userPlayerInfo = new UserPlayInfoModel();
|
|
|
|
|
$userPlayerInfo->where('promote_id=' . $fromPromoteId)->save(['promote_id' => $toPromoteId, 'promote_account' => $toPromote['account']]);
|
|
|
|
|
$status = M('user', 'tab_')->where($map)->save($updateData);
|
|
|
|
|
if (!$status) {
|
|
|
|
|
$model->rollback();
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,修改用户推广员失败'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
M('ShiftTask')->where('id=' . $task['id'])->save(['status' => 1]);
|
|
|
|
|
$status = M('user_play', 'tab_')->where($otherMap)->save($updateData);
|
|
|
|
|
if (!$status) {
|
|
|
|
|
$model->rollback();
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,修改玩家推广员失败'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$status = M('user_play_info', 'tab_')->where($otherMap)->save($updateData);
|
|
|
|
|
if (!$status) {
|
|
|
|
|
$model->rollback();
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,修改角色推广员失败'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
M('spend', 'tab_')->where($otherMap)->where(['is_check' => ['in','1,2']])->save($updateData); // 只改未对账的数据
|
|
|
|
|
M('deposit', 'tab_')->where($otherMap)->save($updateData);
|
|
|
|
|
M('bind_spend', 'tab_')->where($otherMap)->save($updateData);
|
|
|
|
|
|
|
|
|
|
$status = M('shift_task', 'sys_')->where('id=' . $task['id'])->save(['status' => 1, 'handle_time' => time()]);
|
|
|
|
|
if (!$status) {
|
|
|
|
|
$model->rollback();
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,修改迁移任务失败'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$model->commit();
|
|
|
|
|
return ['status' => true, 'msg' => '玩家迁移成功'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -784,6 +810,45 @@ class PromoteService {
|
|
|
|
|
'message' => '账号长度为6-15个字符',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if ($mobile == '') {
|
|
|
|
|
return [
|
|
|
|
|
'status' => false,
|
|
|
|
|
'message' => '请输入手机号',
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
if (!preg_match("/^1[3456789]{1}\d{9}$/", $mobile)) {
|
|
|
|
|
return [
|
|
|
|
|
'status' => false,
|
|
|
|
|
'message' => '手机号格式错误',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($idcard == '') {
|
|
|
|
|
return [
|
|
|
|
|
'status' => false,
|
|
|
|
|
'message' => '请输入身份证号',
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
if (!IdCard::isIdcard($idcard)) {
|
|
|
|
|
return [
|
|
|
|
|
'status' => false,
|
|
|
|
|
'message' => '身份证格式错误',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($realName == '') {
|
|
|
|
|
return [
|
|
|
|
|
'status' => false,
|
|
|
|
|
'message' => '请输入姓名',
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
if (mb_strlen($realName) < 2 || mb_strlen($realName) > 4) {
|
|
|
|
|
return [
|
|
|
|
|
'status' => false,
|
|
|
|
|
'message' => '姓名长度为2-4个字符',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($password == '') {
|
|
|
|
|
return [
|
|
|
|
|
'status' => false,
|
|
|
|
|