mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改静态调用
This commit is contained in:
parent
4850c690e0
commit
2fd2d3938e
@ -58,7 +58,7 @@ class UserAgent extends Command
|
|||||||
'path' => $path1, 'layer' => substr_count($path1, '-'),
|
'path' => $path1, 'layer' => substr_count($path1, '-'),
|
||||||
'pid0' => $parant['id'], 'pid1' => $parant['id'], 'pid2' => $parant['pid1'],
|
'pid0' => $parant['id'], 'pid1' => $parant['id'], 'pid2' => $parant['pid1'],
|
||||||
]);
|
]);
|
||||||
UserUpgradeService::instance()->upgrade($user['id'], true);
|
UserUpgradeService::upgrade($user['id'], true);
|
||||||
$this->setQueueMessage(1, 1, "更新指定用户[{$user['id']}]代理绑定成功!");
|
$this->setQueueMessage(1, 1, "更新指定用户[{$user['id']}]代理绑定成功!");
|
||||||
|
|
||||||
// 更新下级的代理关系
|
// 更新下级的代理关系
|
||||||
|
@ -34,7 +34,7 @@ class UserUpgrade extends Command
|
|||||||
[$total, $count] = [DataUser::mk()->count(), 0];
|
[$total, $count] = [DataUser::mk()->count(), 0];
|
||||||
foreach (DataUser::mk()->field('id')->cursor() as $user) {
|
foreach (DataUser::mk()->field('id')->cursor() as $user) {
|
||||||
$this->queue->message($total, ++$count, "正在计算用户 [{$user['id']}] 的等级");
|
$this->queue->message($total, ++$count, "正在计算用户 [{$user['id']}] 的等级");
|
||||||
UserUpgradeService::instance()->upgrade($user['id']);
|
UserUpgradeService::upgrade($user['id']);
|
||||||
$this->queue->message($total, $count, "完成计算用户 [{$user['id']}] 的等级", 1);
|
$this->queue->message($total, $count, "完成计算用户 [{$user['id']}] 的等级", 1);
|
||||||
}
|
}
|
||||||
$this->setQueueSuccess("此次共重新计算 {$total} 个用户等级。");
|
$this->setQueueSuccess("此次共重新计算 {$total} 个用户等级。");
|
||||||
|
@ -47,7 +47,7 @@ class News extends Controller
|
|||||||
$query = DataNewsItem::mQuery()->like('name,mark')->equal('id,code');
|
$query = DataNewsItem::mQuery()->like('name,mark')->equal('id,code');
|
||||||
$query->where(['deleted' => 0, 'status' => 1])->withoutField('sort,status,deleted');
|
$query->where(['deleted' => 0, 'status' => 1])->withoutField('sort,status,deleted');
|
||||||
$result = $query->order('sort desc,id desc')->page(true, false, false, 15);
|
$result = $query->order('sort desc,id desc')->page(true, false, false, 15);
|
||||||
NewsService::instance()->buildData($result['list'], input('uuid', 0));
|
NewsService::buildData($result['list'], input('uuid', 0));
|
||||||
$this->success('获取文章内容', $result);
|
$this->success('获取文章内容', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class News extends Controller
|
|||||||
$map = $this->_vali(['code.require' => '文章不能为空!']);
|
$map = $this->_vali(['code.require' => '文章不能为空!']);
|
||||||
$query = DataNewsXCollect::mQuery()->where(['type' => 4, 'status' => 2]);
|
$query = DataNewsXCollect::mQuery()->where(['type' => 4, 'status' => 2]);
|
||||||
$result = $query->where($map)->order('id desc')->page(true, false, false, 15);
|
$result = $query->where($map)->order('id desc')->page(true, false, false, 15);
|
||||||
NewsService::instance()->buildListByUidAndCode($result['list']);
|
NewsService::buildListByUidAndCode($result['list']);
|
||||||
$this->success('获取评论成功', $result);
|
$this->success('获取评论成功', $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -140,7 +140,7 @@ class Center extends Auth
|
|||||||
public function bindFrom()
|
public function bindFrom()
|
||||||
{
|
{
|
||||||
$data = $this->_vali(['from.require' => '邀请人不能为空']);
|
$data = $this->_vali(['from.require' => '邀请人不能为空']);
|
||||||
[$state, $message] = UserUpgradeService::instance()->bindAgent($this->uuid, $data['from'], 0);
|
[$state, $message] = UserUpgradeService::bindAgent($this->uuid, $data['from'], 0);
|
||||||
if ($state) {
|
if ($state) {
|
||||||
$this->success($message, UserAdminService::total($this->uuid));
|
$this->success($message, UserAdminService::total($this->uuid));
|
||||||
} else {
|
} else {
|
||||||
|
@ -96,7 +96,7 @@ class Company extends Controller
|
|||||||
public function sync()
|
public function sync()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$result = ExpressService::instance()->company();
|
$result = ExpressService::company();
|
||||||
if (empty($result['code'])) $this->error($result['info']);
|
if (empty($result['code'])) $this->error($result['info']);
|
||||||
foreach ($result['data'] as $vo) BasePostageCompany::mUpdate([
|
foreach ($result['data'] as $vo) BasePostageCompany::mUpdate([
|
||||||
'name' => $vo['title'],
|
'name' => $vo['title'],
|
||||||
|
@ -43,7 +43,7 @@ class Template extends Controller
|
|||||||
{
|
{
|
||||||
if ($this->request->isGet()) {
|
if ($this->request->isGet()) {
|
||||||
$this->title = '配送区域管理';
|
$this->title = '配送区域管理';
|
||||||
$this->citys = ExpressService::instance()->region(3, null);
|
$this->citys = ExpressService::region(3, null);
|
||||||
$this->fetch('form_region');
|
$this->fetch('form_region');
|
||||||
} else {
|
} else {
|
||||||
$data = $this->_vali(['nos.default' => '', 'oks.default' => '']);
|
$data = $this->_vali(['nos.default' => '', 'oks.default' => '']);
|
||||||
@ -83,7 +83,7 @@ class Template extends Controller
|
|||||||
$data['code'] = CodeExtend::uniqidDate(12, 'T');
|
$data['code'] = CodeExtend::uniqidDate(12, 'T');
|
||||||
}
|
}
|
||||||
if ($this->request->isGet()) {
|
if ($this->request->isGet()) {
|
||||||
$this->citys = ExpressService::instance()->region(2, 1);
|
$this->citys = ExpressService::region(2, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class NewsService extends Service
|
|||||||
* @param integer $uuid 用户UID
|
* @param integer $uuid 用户UID
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function buildData(array &$list, int $uuid = 0): array
|
public static function buildData(array &$list, int $uuid = 0): array
|
||||||
{
|
{
|
||||||
if (count($list) > 0) {
|
if (count($list) > 0) {
|
||||||
[$code2, $code1] = [[], []];
|
[$code2, $code1] = [[], []];
|
||||||
|
@ -7,6 +7,7 @@ use app\data\model\DataUser;
|
|||||||
use app\data\model\DataUserBalance;
|
use app\data\model\DataUserBalance;
|
||||||
use app\data\model\ShopOrder;
|
use app\data\model\ShopOrder;
|
||||||
use app\data\model\ShopOrderItem;
|
use app\data\model\ShopOrderItem;
|
||||||
|
use think\admin\Library;
|
||||||
use think\admin\Service;
|
use think\admin\Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +28,7 @@ class UserUpgradeService extends Service
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function bindAgent(int $uuid, int $pid0 = 0, int $mode = 1): array
|
public static function bindAgent(int $uuid, int $pid0 = 0, int $mode = 1): array
|
||||||
{
|
{
|
||||||
$user = DataUser::mk()->where(['id' => $uuid])->find();
|
$user = DataUser::mk()->where(['id' => $uuid])->find();
|
||||||
if (empty($user)) return [0, '查询用户资料失败'];
|
if (empty($user)) return [0, '查询用户资料失败'];
|
||||||
@ -41,7 +42,7 @@ class UserUpgradeService extends Service
|
|||||||
if (empty($agent['vip_code'])) return [0, '代理无推荐资格'];
|
if (empty($agent['vip_code'])) return [0, '代理无推荐资格'];
|
||||||
if (strpos($agent['path'], "-{$uuid}-") !== false) return [0, '不能绑定下属'];
|
if (strpos($agent['path'], "-{$uuid}-") !== false) return [0, '不能绑定下属'];
|
||||||
try {
|
try {
|
||||||
$this->app->db->transaction(function () use ($user, $agent, $mode) {
|
Library::$sapp->db->transaction(function () use ($user, $agent, $mode) {
|
||||||
// 更新用户代理
|
// 更新用户代理
|
||||||
$path1 = rtrim($agent['path'] ?: '-', '-') . "-{$agent['id']}-";
|
$path1 = rtrim($agent['path'] ?: '-', '-') . "-{$agent['id']}-";
|
||||||
$user->save(['pid0' => $agent['id'], 'pid1' => $agent['id'], 'pid2' => $agent['pid1'], 'pids' => $mode > 0 ? 1 : 0, 'path' => $path1, 'layer' => substr_count($path1, '-')]);
|
$user->save(['pid0' => $agent['id'], 'pid1' => $agent['id'], 'pid2' => $agent['pid1'], 'pids' => $mode > 0 ? 1 : 0, 'path' => $path1, 'layer' => substr_count($path1, '-')]);
|
||||||
@ -54,7 +55,7 @@ class UserUpgradeService extends Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$this->upgrade($user['id']);
|
static::upgrade($user['id']);
|
||||||
return [1, '绑定代理成功'];
|
return [1, '绑定代理成功'];
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
return [0, "绑定代理失败, {$exception->getMessage()}"];
|
return [0, "绑定代理失败, {$exception->getMessage()}"];
|
||||||
@ -71,7 +72,7 @@ class UserUpgradeService extends Service
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function upgrade(int $uuid, bool $parent = true, ?string $orderNo = null): bool
|
public static function upgrade(int $uuid, bool $parent = true, ?string $orderNo = null): bool
|
||||||
{
|
{
|
||||||
$user = DataUser::mk()->where(['id' => $uuid])->find();
|
$user = DataUser::mk()->where(['id' => $uuid])->find();
|
||||||
if (empty($user)) return true;
|
if (empty($user)) return true;
|
||||||
@ -133,9 +134,9 @@ class UserUpgradeService extends Service
|
|||||||
if ($data['vip_code'] !== $user['vip_code']) $data['vip_datetime'] = date('Y-m-d H:i:s');
|
if ($data['vip_code'] !== $user['vip_code']) $data['vip_datetime'] = date('Y-m-d H:i:s');
|
||||||
DataUser::mk()->where(['id' => $uuid])->update($data);
|
DataUser::mk()->where(['id' => $uuid])->update($data);
|
||||||
// 用户升级事件
|
// 用户升级事件
|
||||||
if ($user['vip_code'] < $vipCode) $this->app->event->trigger('UserUpgradeLevel', [
|
if ($user['vip_code'] < $vipCode) Library::$sapp->event->trigger('UserUpgradeLevel', [
|
||||||
'uuid' => $user['id'], 'order_no' => $orderNo, 'vip_code_old' => $user['vip_code'], 'vip_code_new' => $vipCode,
|
'uuid' => $user['id'], 'order_no' => $orderNo, 'vip_code_old' => $user['vip_code'], 'vip_code_new' => $vipCode,
|
||||||
]);
|
]);
|
||||||
return !($parent && $user['pid1'] > 0) || $this->upgrade($user['pid1'], false);
|
return !($parent && $user['pid1'] > 0) || static::upgrade($user['pid1'], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user