master
ELF 5 years ago
parent a14b18f54f
commit 22dcca566b

@ -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)

@ -330,12 +330,6 @@ class PromoteCoinController extends BaseController
{
$data = D('Promote')->find(PID);
if (IS_POST) {
// $child = get_prmoote_chlid_account(PID);
// $child = array_column($child,'id');
//子渠道过滤非法用户
// if (!in_array(I('promote_id'), $child)){
// $this->error('非法参数');
// }
$num = I('num');
if (!is_numeric($num)) {
@ -730,28 +724,22 @@ class PromoteCoinController extends BaseController
public function subPromotes()
{
$type = I('type', 1);
$level = I('level', 0);
$account = I('account', '');
$mobile = I('mobile', '');
$id = session('promote_auth.pid');
$promote = $this->getLoginPromote();
$map = [];
if ($type == 1) {
$map['_string'] = 'parent_id=' . $id . ' and grand_id=0';
} elseif ($type == 2) {
$level = get_promote_level($id);
if ($level == 1) {
$map['_string'] = 'grand_id=' . $id;
} elseif ($level == 2) {
$map['_string'] = 'parent_id=' . $id;
}
}
$map['level'] = $level;
$map['chain'] = ['like', $promote['chain'] . $promote['id'] . '/%'];
if ($account) {
$map['account'] = ['like', '%' . $account . '%'];
}
if ($mobile) {
$map['mobile_phone'] = ['like', '%' . $mobile . '%'];
}
$query = D('Promote')->field(['id', 'account', 'real_name', 'mobile_phone'])->where($map);
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'mobile_phone'])->where($map);
list($promotes, $pagination, $count) = $this->paginate($query);
$records = [];

@ -32,13 +32,16 @@
<tr>
<td class="l"><span class="req">*</span>账号类型:</td>
<td class="r">
<?php if ($parent_id == 0):?>
<label><input type="radio" name="shift_user_type" value="1" checked> 组长</label>
<?php if ($loginer['level'] <= 1):?>
<label><input type="radio" name="shift_user_type" value="1" <?php if($loginer['level'] == 1):?>checked<?php endif;?>> 部门长</label>
<?php endif;?>
<?php if ($parent_id == 0 || $grand_id == 0):?>
<label><input type="radio" name="shift_user_type" value="2" <?php if($parent_id > 0 && $grand_id == 0):?>checked<?php endif;?>> 推广员</label>
<?php if ($loginer['level'] <= 2):?>
<label><input type="radio" name="shift_user_type" value="2" <?php if($loginer['level'] == 2):?>checked<?php endif;?>> 组长</label>
<?php endif;?>
<label><input type="radio" name="shift_user_type" value="3" <?php if($parent_id > 0 && $grand_id > 0):?>checked<?php endif;?>> 玩家</label>
<?php if ($loginer['level'] <= 3):?>
<label><input type="radio" name="shift_user_type" value="3" <?php if($loginer['level'] == 3):?>checked<?php endif;?>> 推广员</label>
<?php endif;?>
<label><input type="radio" name="shift_user_type" value="4" <?php if($loginer['level'] == 4):?>checked<?php endif;?>> 玩家</label>
</td>
</tr>
<tr>
@ -142,18 +145,24 @@
$('#select-game-show').html('')
$('#select-user-show').html('')
}
})
})
$('#select-user').on({
click: function() {
var title = '选择组长'
var url = "{:U('PromoteCoin/subPromotes')}"
if (shiftUserType == 3) {
var title = ''
var url = ''
if (shiftUserType == 4) {
url = "{:U('PromoteCoin/promoteUsers')}"
title = '选择玩家'
} else if (shiftUserType == 2) {
} else if (shiftUserType == 3) {
title = '选择推广员'
url = "{:U('PromoteCoin/subPromotes', [type => 2])}"
url = "{:U('PromoteCoin/subPromotes', [level => 4])}"
} else if (shiftUserType == 2) {
title = '选择组长'
url = "{:U('PromoteCoin/subPromotes', [level => 3])}"
} else if (shiftUserType == 1) {
title = '选择部门长'
url = "{:U('PromoteCoin/subPromotes', [level => 2])}"
}
layer.open({
@ -291,7 +300,7 @@
function validation() {
var json_data = "";
var limits = {$data['balance_coin']|default=0};
var limits = parseInt("{$data['balance_coin']|default=0}");
if ($.trim($('#num').val()).length == 0) {
return json_data = {'status': 0, 'msg': '发送数量不能为空'}
}

Loading…
Cancel
Save