|
|
|
@ -203,26 +203,25 @@ class PromoteService {
|
|
|
|
|
$secondMap['parent_id'] = ['in', $shiftIds];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
M('promote', 'tab_')->where($firstMap)->save([
|
|
|
|
|
'parent_id' => $toPromote['id'],
|
|
|
|
|
'parent_name' => $toPromote['account'],
|
|
|
|
|
'chain' => $toPromote['chain'] . $toPromote['id'] . '/',
|
|
|
|
|
'level' . $toPromote['level'] => $toPromote['id']
|
|
|
|
|
]);
|
|
|
|
|
try {
|
|
|
|
|
M('promote', 'tab_')->where($firstMap)->save([
|
|
|
|
|
'parent_id' => $toPromote['id'],
|
|
|
|
|
'parent_name' => $toPromote['account'],
|
|
|
|
|
'chain' => $toPromote['chain'] . $toPromote['id'] . '/',
|
|
|
|
|
'level' . $toPromote['level'] => $toPromote['id']
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
M('promote', 'tab_')->where($secondMap)->save([
|
|
|
|
|
'chain' => ['exp', 'REPLACE(chain, "/' . $fromPromote['id'] . '/","/' . $toPromote['id'] . '/")'],
|
|
|
|
|
'level' . $toPromote['level'] => $toPromote['id']
|
|
|
|
|
]);
|
|
|
|
|
M('promote', 'tab_')->where($secondMap)->save([
|
|
|
|
|
'chain' => ['exp', 'REPLACE(chain, "/' . $fromPromote['id'] . '/","/' . $toPromote['id'] . '/")'],
|
|
|
|
|
'level' . $toPromote['level'] => $toPromote['id']
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$status = M('ShiftTask')->where('id=' . $task['id'])->save(['status' => 1, 'handle_time' => time()]);
|
|
|
|
|
if (!$status) {
|
|
|
|
|
$model->commit();
|
|
|
|
|
return ['status' => true, 'msg' => '推广帐号迁移成功'];
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$model->rollback();
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,修改迁移任务状态失败'];
|
|
|
|
|
return ['status' => true, 'msg' => '推广帐号迁移失败: ' . $e->getMessage()];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$model->commit();
|
|
|
|
|
return ['status' => true, 'msg' => '推广帐号迁移成功'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function shiftRemoveCoin($promote, $task)
|
|
|
|
@ -234,7 +233,7 @@ class PromoteService {
|
|
|
|
|
$topBalanceCoin = $this->getBalanceCoin($topPromote['id'], 0);
|
|
|
|
|
$topBalancePlus = 0;
|
|
|
|
|
|
|
|
|
|
$map = ['chain' => $promote['chain'] . $chain['id'] . '/%'];
|
|
|
|
|
$map = ['chain' => $promote['chain'] . $promote['id'] . '/%'];
|
|
|
|
|
if (count($shiftIds) > 0) {
|
|
|
|
|
$map['id'] = ['in', $shiftIds];
|
|
|
|
|
}
|
|
|
|
@ -358,7 +357,6 @@ class PromoteService {
|
|
|
|
|
$formConpany = M('promote_company', 'tab_')->field(['company_name', 'company_belong'])->where(['id' => $fromPromote['company_id']])->find();
|
|
|
|
|
$toConpany = M('promote_company', 'tab_')->field(['company_name', 'company_belong'])->where(['id' => $toPromote['company_id']])->find();
|
|
|
|
|
$belongs = PromoteCompanyService::$belongs;
|
|
|
|
|
|
|
|
|
|
$mends = [];
|
|
|
|
|
foreach ($users as $item) {
|
|
|
|
|
$amount = isset($payAmountRows[$item['id']]) ? round(floatval($payAmountRows[$item['id']]['pay_amount']), 2) : 0;
|
|
|
|
@ -404,7 +402,7 @@ class PromoteService {
|
|
|
|
|
|
|
|
|
|
$model = new Model();
|
|
|
|
|
$model->startTrans();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$status = M('mend', 'tab_')->addAll($mends);
|
|
|
|
|
if (!$status) {
|
|
|
|
|
$model->rollback();
|
|
|
|
@ -435,39 +433,62 @@ class PromoteService {
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,修改用户推广员失败'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
M('user_play', 'tab_')->where($otherMap)->save($updateData);
|
|
|
|
|
M('user_play_info', 'tab_')->where($otherMap)->save($updateData);
|
|
|
|
|
|
|
|
|
|
unset($spendMap['pay_status']);
|
|
|
|
|
try {
|
|
|
|
|
M('user_play', 'tab_')->where($otherMap)->save($updateData);
|
|
|
|
|
M('user_play_info', 'tab_')->where($otherMap)->save($updateData);
|
|
|
|
|
|
|
|
|
|
unset($spendMap['pay_status']);
|
|
|
|
|
|
|
|
|
|
$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($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' => 2]));
|
|
|
|
|
}
|
|
|
|
|
if (count($hasNotGameIds) > 0) {
|
|
|
|
|
$spendMap['game_id'] = ['in', $hasNotGameIds];
|
|
|
|
|
M('spend', 'tab_')->where($spendMap)->save(array_merge($updateData, $updateMarket, ['is_check' => 2]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$bindMap = $otherMap;
|
|
|
|
|
$bindMap['pay_time'] = ['egt', $orderTime];
|
|
|
|
|
M('bind_spend', 'tab_')->where($bindMap)->save($updateData);
|
|
|
|
|
$bindMap = $otherMap;
|
|
|
|
|
$bindMap['pay_time'] = ['egt', $orderTime];
|
|
|
|
|
M('bind_spend', 'tab_')->where($bindMap)->save($updateData);
|
|
|
|
|
|
|
|
|
|
$orderMap = $otherMap;
|
|
|
|
|
$orderMap['create_time'] = ['egt', $orderTime];
|
|
|
|
|
M('deposit', 'tab_')->where($orderMap)->save(array_merge($updateData, $updateMarket));
|
|
|
|
|
M('user_play_data_count', 'tab_')->where($orderMap)->save(['promote_id' => $toPromote['id']]);
|
|
|
|
|
$orderMap = $otherMap;
|
|
|
|
|
$orderMap['create_time'] = ['egt', $orderTime];
|
|
|
|
|
M('deposit', 'tab_')->where($orderMap)->save(array_merge($updateData, $updateMarket));
|
|
|
|
|
M('user_play_data_count', 'tab_')->where($orderMap)->save(['promote_id' => $toPromote['id']]);
|
|
|
|
|
|
|
|
|
|
$status = M('shift_task', 'sys_')->where('id=' . $task['id'])->save(['status' => 1, 'handle_time' => time()]);
|
|
|
|
|
if (!$status) {
|
|
|
|
|
$model->commit();
|
|
|
|
|
return ['status' => true, 'msg' => '玩家迁移成功'];
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$model->rollback();
|
|
|
|
|
return ['status' => false, 'msg' => '系统异常,修改迁移任务失败'];
|
|
|
|
|
return ['status' => true, 'msg' => '系统异常: ' . $e->getMessage()];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$model->commit();
|
|
|
|
|
return ['status' => true, 'msg' => '玩家迁移成功'];
|
|
|
|
|
public function afterShift($task, $result)
|
|
|
|
|
{
|
|
|
|
|
$data = [];
|
|
|
|
|
if ($result['status']) {
|
|
|
|
|
$data = ['status' => 1, 'result' => $result['msg'], 'handle_time' => time()];
|
|
|
|
|
} else {
|
|
|
|
|
$data = ['status' => 2, 'result' => $result['msg'], 'handle_time' => time()];
|
|
|
|
|
}
|
|
|
|
|
M('shift_task', 'sys_')->where('id=' . $task['id'])->save($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function shift($task)
|
|
|
|
|
{
|
|
|
|
|
$result = null;
|
|
|
|
|
if ($task['type'] == 1) {
|
|
|
|
|
$result = $this->shiftPromote($task);
|
|
|
|
|
} elseif ($task['type'] == 2) {
|
|
|
|
|
$result = $this->shiftPlayer($task);
|
|
|
|
|
} else {
|
|
|
|
|
$result = ['status' => false, 'msg' => '类型错误'];
|
|
|
|
|
}
|
|
|
|
|
$this->afterShift($task, $result);
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function cancelShift($params)
|
|
|
|
|