|
|
|
@ -168,14 +168,7 @@ class PromoteService {
|
|
|
|
|
|
|
|
|
|
$toPromote = D('promote')->where(['id' => $toPromoteId])->find();
|
|
|
|
|
$fromPromote = D('promote')->where(['id' => $fromPromoteId])->find();
|
|
|
|
|
|
|
|
|
|
$topPromoteId = 0;
|
|
|
|
|
if ($fromPromote['grand_id'] > 0) {
|
|
|
|
|
$topPromoteId = $fromPromote['grand_id'];
|
|
|
|
|
} else {
|
|
|
|
|
$topPromoteId = $fromPromote['parent_id'];
|
|
|
|
|
}
|
|
|
|
|
$topPromote = D('promote')->where(['id' => $topPromoteId])->find();
|
|
|
|
|
$topPromote = $this->getTopPromote($fromPromote);
|
|
|
|
|
|
|
|
|
|
$status = $this->shiftRemoveCoin($fromPromote, $topPromote, $task);
|
|
|
|
|
|
|
|
|
@ -188,10 +181,16 @@ class PromoteService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promote = new PromoteModel();
|
|
|
|
|
$updateData = [
|
|
|
|
|
'parent_id' => $toPromote['id']
|
|
|
|
|
];
|
|
|
|
|
$updateData = [
|
|
|
|
|
'chain' => ['exp', 'replace(chain,\''.$fromPromote['chain'].'\',\''. $toPromote['chain'].'\')']
|
|
|
|
|
];
|
|
|
|
|
if ($fromPromote['grand_id'] == 0) {
|
|
|
|
|
$status = $promote->where('parent_id=' . $fromPromoteId)->save(['parent_id' => $toPromoteId]);
|
|
|
|
|
$status = $promote->where('parent_id=' . $fromPromoteId)->save($updateData);
|
|
|
|
|
} else {
|
|
|
|
|
$status = $promote->where('id=' . $fromPromoteId)->save(['parent_id' => $toPromoteId]);
|
|
|
|
|
$status = $promote->where('id=' . $fromPromoteId)->save($updateData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$status) {
|
|
|
|
@ -739,7 +738,22 @@ class PromoteService {
|
|
|
|
|
|
|
|
|
|
public function getLevelByChain($chain)
|
|
|
|
|
{
|
|
|
|
|
return count(explode('/', trim($chain, '/')));
|
|
|
|
|
$chain = trim($chain, '/');
|
|
|
|
|
return $chain == '' ? 1 : count(explode('/', $chain));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取最上级的推广员
|
|
|
|
|
*/
|
|
|
|
|
public function getTopPromote($promote)
|
|
|
|
|
{
|
|
|
|
|
$chain = trim($promote['chain'], '/');
|
|
|
|
|
if ($chain == '') {
|
|
|
|
|
return $promote;
|
|
|
|
|
} else {
|
|
|
|
|
$topPromoteId = explode('/', $chain)[0];
|
|
|
|
|
return M('promote', 'tab_')->where(['id' => $topPromoteId])->find();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getLevelName($level)
|
|
|
|
|