diff --git a/app/admin/view/full.html b/app/admin/view/full.html
index d9cc6e63f..36e1fc45e 100644
--- a/app/admin/view/full.html
+++ b/app/admin/view/full.html
@@ -20,7 +20,7 @@
{block name='body'}
-
{block name='content'}{/block}
+
{block name='content'}{/block}
{/block}
diff --git a/app/data/controller/api/auth/Center.php b/app/data/controller/api/auth/Center.php
index 78b7cecc2..36aa42d55 100644
--- a/app/data/controller/api/auth/Center.php
+++ b/app/data/controller/api/auth/Center.php
@@ -149,7 +149,7 @@ class Center extends Auth
public function bindFrom()
{
$data = $this->_vali(['from.require' => '邀请人不能为空']);
- [$state, $message] = UserUpgradeService::instance()->bindAgent($this->uuid, $data['from'], false);
+ [$state, $message] = UserUpgradeService::instance()->bindAgent($this->uuid, $data['from'], 0);
if ($state) {
$this->success($message, UserAdminService::instance()->total($this->uuid));
} else {
diff --git a/app/data/controller/user/Admin.php b/app/data/controller/user/Admin.php
index 1c34344a0..d4217083e 100644
--- a/app/data/controller/user/Admin.php
+++ b/app/data/controller/user/Admin.php
@@ -105,7 +105,7 @@ class Admin extends Controller
$map = $this->_vali(['id.require' => '用户ID不能为空!']);
$user = $this->app->db->name($this->table)->where($map)->find();
if (empty($user) || empty($user['pid0'])) $this->error('用户不符合操作要求!');
- [$status, $message] = UserUpgradeService::instance()->bindAgent($user['id'], $user['pid0'], true);
+ [$status, $message] = UserUpgradeService::instance()->bindAgent($user['id'], $user['pid0'], 1);
$status && sysoplog('前端用户管理', "后台修改用户[{$map['id']}]的代理为永久状态");
empty($status) ? $this->error($message) : $this->success($message);
}
@@ -130,10 +130,10 @@ class Admin extends Controller
$db = $this->_query($this->table)->equal('vip_code#from_vipcode')->like('phone#from_phone,username|nickname#from_username')->db();
if ($db->getOptions('where')) $query->whereRaw("pid1 in {$db->field('id')->buildSql()}");
// 数据查询分页
- $query->like('phone,username|nickname#username')->equal('status,vip_code')->dateBetween('create_at')->page();
+ $query->like('phone,username|nickname#username')->whereRaw('vip_code>0')->equal('status,vip_code')->dateBetween('create_at')->page();
} else {
$data = $this->_vali(['pid.require' => '待绑定代理不能为空!', 'uid.require' => '待操作用户不能为空!']);
- [$status, $message] = UserUpgradeService::instance()->bindAgent($data['uid'], $data['pid'], false);
+ [$status, $message] = UserUpgradeService::instance()->bindAgent($data['uid'], $data['pid'], 2);
$status && sysoplog('前端用户管理', "后台修改用户[{$data['uid']}]的代理为[{$data['pid']}]");
empty($status) ? $this->error($message) : $this->success($message);
}
diff --git a/app/data/service/OrderService.php b/app/data/service/OrderService.php
index 5745bf6c5..b85bf9513 100644
--- a/app/data/service/OrderService.php
+++ b/app/data/service/OrderService.php
@@ -58,7 +58,7 @@ class OrderService extends Service
// 尝试绑定代理用户
if (empty($user['pids']) && ($order['puid1'] > 0 || $user['pid1'] > 0)) {
$puid1 = $order['puid1'] > 0 ? $order['puid1'] : $user['pid0'];
- UserUpgradeService::instance()->bindAgent($user['id'], $puid1);
+ UserUpgradeService::instance()->bindAgent($user['id'], $puid1, 1);
}
// 重置用户信息并绑定订单
$user = $this->app->db->name('DataUser')->where(['id' => $order['uid']])->find();
diff --git a/app/data/service/UserUpgradeService.php b/app/data/service/UserUpgradeService.php
index 03a9c0831..d36fbcd62 100644
--- a/app/data/service/UserUpgradeService.php
+++ b/app/data/service/UserUpgradeService.php
@@ -26,17 +26,17 @@ class UserUpgradeService extends Service
* 尝试绑定上级代理
* @param integer $uid 用户UID
* @param integer $pid 代理UID
- * @param boolean $force 正式绑定
+ * @param integer $mod 操作类型(0临时绑定, 1永久绑定, 2强行绑定)
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
- public function bindAgent(int $uid, int $pid = 0, bool $force = true): array
+ public function bindAgent(int $uid, int $pid = 0, int $mod = 1): array
{
$user = $this->app->db->name('DataUser')->where(['id' => $uid])->find();
if (empty($user)) return [0, '用户查询失败'];
- if ($user['pids']) return [1, '已经绑定代理'];
+ if ($user['pids'] && in_array($mod, [0, 1])) return [1, '已经绑定代理'];
// 检查代理用户
if (empty($pid)) $pid = $user['pid0'];
if (empty($pid)) return [0, '绑定的代理不存在'];
@@ -47,12 +47,13 @@ class UserUpgradeService extends Service
if (stripos($agent['path'], "-{$uid}-") !== false) return [0, '不能绑定下属'];
// 组装代理数据
$result = [0, '绑定代理失败'];
- $this->app->db->transaction(function () use ($user, $agent, $force, &$result) {
+ $this->app->db->transaction(function () use ($user, $agent, $mod, &$result) {
// 更新用户代理
$path1 = rtrim($agent['path'] ?: '-', '-') . "-{$agent['id']}-";
- $data1 = ['pid0' => $agent['id'], 'pid1' => $agent['id'], 'pid2' => $agent['pid1']];
- $data2 = ['pids' => intval($force), 'path' => $path1, 'layer' => substr_count($path1, '-')];
- $this->app->db->name('DataUser')->where(['id' => $user['id']])->update(array_merge($data1, $data2));
+ $this->app->db->name('DataUser')->where(['id' => $user['id']])->update([
+ 'pid0' => $agent['id'], 'pid1' => $agent['id'], 'pid2' => $agent['pid1'],
+ 'pids' => $mod > 0 ? 1 : 0, 'path' => $path1, 'layer' => substr_count($path1, '-'),
+ ]);
// 更新下级代理
$path2 = "{$user['path']}{$user['id']}-";
if ($this->app->db->name('DataUser')->whereLike('path', "{$path2}%")->count() > 0) {
diff --git a/app/data/view/user/admin/index.html b/app/data/view/user/admin/index.html
index 39adaddb7..3693aea0d 100644
--- a/app/data/view/user/admin/index.html
+++ b/app/data/view/user/admin/index.html
@@ -100,7 +100,12 @@
累计交易:{$vo.order_amount_total+0} 元
使用状态:{if $vo.status eq 0} 已冻结{elseif $vo.status eq 1} 已激活{/if}
- 永久绑定
+
+ 永久绑定
+
+ 更改绑定
+
+
{notempty name='vo.pid0'}
临时绑定
@@ -109,7 +114,7 @@
{else}
没有绑定
- 设置绑定
+ 设置绑定
{/notempty}
diff --git a/app/data/view/user/admin/parent.html b/app/data/view/user/admin/parent.html
index 2041b20e2..758e06b48 100644
--- a/app/data/view/user/admin/parent.html
+++ b/app/data/view/user/admin/parent.html
@@ -10,6 +10,7 @@
用户信息 |
注册时间 |
|
+ |
{/notempty}
@@ -60,11 +61,9 @@
注册时间:{$vo.create_at|format_datetime}
|
-
- 确认选择
+ 选择绑定
-
|
{/foreach}
@@ -77,7 +76,6 @@
{block name='script'}